@typeonce/effect-machine 0.10.0 → 0.11.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 +43 -4
- package/dist/Machine.d.ts +159 -47
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +29 -0
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +1 -1
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +38 -7
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +1 -0
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +4 -0
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/process.d.ts +3 -0
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +3 -0
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +14 -0
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +82 -32
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +4 -2
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +4 -2
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +50 -8
- package/package.json +1 -1
- package/src/Machine.ts +661 -53
- package/src/internal/machine/atom.ts +50 -52
- package/src/internal/machine/machine.ts +6 -0
- package/src/internal/machine/process.ts +57 -0
- package/src/internal/machine/runtime.ts +172 -43
- package/src/unstable/reactivity/AtomMachine.ts +4 -2
package/src/Machine.ts
CHANGED
|
@@ -246,6 +246,15 @@ export interface Machine<
|
|
|
246
246
|
ParentEvents
|
|
247
247
|
>
|
|
248
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Preserves invocation inference with this machine's public input and parent
|
|
251
|
+
* protocols. Prefer this bound constructor when an invocation source or
|
|
252
|
+
* lifecycle handler uses `self` or `parent`.
|
|
253
|
+
*
|
|
254
|
+
* @since 0.11.0
|
|
255
|
+
*/
|
|
256
|
+
readonly invoke: Invoker<States, Events, Emits, InputEvents, ParentEvents>
|
|
257
|
+
|
|
249
258
|
/** @internal */
|
|
250
259
|
readonly initial: (...args: [...Machine.InputArgs<Input>]) => Machine.InitialResult<States, InitialE, InitialR>
|
|
251
260
|
}
|
|
@@ -1694,6 +1703,33 @@ export type RuntimeOutcome<State, Error = never, Output = never> =
|
|
|
1694
1703
|
readonly snapshot: Extract<RuntimeSnapshot<State, Error, Output>, { readonly status: "stopped" }>
|
|
1695
1704
|
}
|
|
1696
1705
|
|
|
1706
|
+
/**
|
|
1707
|
+
* A fresh machine whose observable streams exist before initialization.
|
|
1708
|
+
*
|
|
1709
|
+
* Subscribe to `emissions` before evaluating `start` when initial-entry
|
|
1710
|
+
* emissions must be observed. `start` is one-shot: concurrent and repeated
|
|
1711
|
+
* evaluations share the same initialization and running reference.
|
|
1712
|
+
*
|
|
1713
|
+
* @category models
|
|
1714
|
+
* @since 0.11.0
|
|
1715
|
+
*/
|
|
1716
|
+
export interface Prepared<out State, in Event, out Error, out Output, out Emitted, out StartError, StartRequirements> {
|
|
1717
|
+
/** Stable machine definition id, or a generated fallback when none was declared. */
|
|
1718
|
+
readonly id: string
|
|
1719
|
+
|
|
1720
|
+
/** Unique identity reserved for this prepared machine instance. */
|
|
1721
|
+
readonly sessionId: string
|
|
1722
|
+
|
|
1723
|
+
/** Waits for startup, then streams the initial lifecycle snapshot and later changes. */
|
|
1724
|
+
readonly changes: Stream.Stream<RuntimeSnapshot<State, Error, Output>, StartError>
|
|
1725
|
+
|
|
1726
|
+
/** Streams ephemeral notifications published after subscription. */
|
|
1727
|
+
readonly emissions: Stream.Stream<Emitted>
|
|
1728
|
+
|
|
1729
|
+
/** Initializes this machine once and returns its running reference. */
|
|
1730
|
+
readonly start: Effect.Effect<MachineRef<State, Event, Error, Output, Emitted>, StartError, StartRequirements>
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1697
1733
|
/**
|
|
1698
1734
|
* Provides access to a running machine's state, lifecycle, event input, and
|
|
1699
1735
|
* termination operations.
|
|
@@ -2128,6 +2164,8 @@ export declare namespace Machine {
|
|
|
2128
2164
|
/** @internal */
|
|
2129
2165
|
readonly handle: any
|
|
2130
2166
|
/** @internal */
|
|
2167
|
+
readonly invoke: any
|
|
2168
|
+
/** @internal */
|
|
2131
2169
|
readonly initial: any
|
|
2132
2170
|
}
|
|
2133
2171
|
|
|
@@ -4616,13 +4654,18 @@ export declare namespace Machine {
|
|
|
4616
4654
|
States extends StateSchemas,
|
|
4617
4655
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4618
4656
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4619
|
-
StateId extends StateIdentifier<States
|
|
4657
|
+
StateId extends StateIdentifier<States>,
|
|
4658
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4659
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4620
4660
|
> =
|
|
4621
4661
|
& InvokeOwned<States, Events, Emits, StateId>
|
|
4622
4662
|
& (
|
|
4623
4663
|
| {
|
|
4624
4664
|
readonly id: string
|
|
4625
|
-
readonly effect: InvokeSource<
|
|
4665
|
+
readonly effect: InvokeSource<
|
|
4666
|
+
Effect.Effect<any, any, any>,
|
|
4667
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4668
|
+
>
|
|
4626
4669
|
readonly after?: never
|
|
4627
4670
|
readonly logic?: never
|
|
4628
4671
|
readonly child?: never
|
|
@@ -4633,7 +4676,10 @@ export declare namespace Machine {
|
|
|
4633
4676
|
}
|
|
4634
4677
|
| {
|
|
4635
4678
|
readonly id: string
|
|
4636
|
-
readonly after: InvokeSource<
|
|
4679
|
+
readonly after: InvokeSource<
|
|
4680
|
+
Duration.Input,
|
|
4681
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4682
|
+
>
|
|
4637
4683
|
readonly effect?: never
|
|
4638
4684
|
readonly logic?: never
|
|
4639
4685
|
readonly child?: never
|
|
@@ -4645,7 +4691,10 @@ export declare namespace Machine {
|
|
|
4645
4691
|
| {
|
|
4646
4692
|
readonly id: string
|
|
4647
4693
|
readonly address: string
|
|
4648
|
-
readonly logic: InvokeSource<
|
|
4694
|
+
readonly logic: InvokeSource<
|
|
4695
|
+
AnyLogicSource,
|
|
4696
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4697
|
+
>
|
|
4649
4698
|
readonly effect?: never
|
|
4650
4699
|
readonly after?: never
|
|
4651
4700
|
readonly child?: never
|
|
@@ -4655,7 +4704,10 @@ export declare namespace Machine {
|
|
|
4655
4704
|
}
|
|
4656
4705
|
| {
|
|
4657
4706
|
readonly child: ChildMachine.Any
|
|
4658
|
-
readonly input?:
|
|
4707
|
+
readonly input?:
|
|
4708
|
+
| {}
|
|
4709
|
+
| null
|
|
4710
|
+
| ((context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
4659
4711
|
readonly id?: never
|
|
4660
4712
|
readonly address?: never
|
|
4661
4713
|
readonly effect?: never
|
|
@@ -4672,10 +4724,16 @@ export declare namespace Machine {
|
|
|
4672
4724
|
States extends StateSchemas,
|
|
4673
4725
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4674
4726
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4675
|
-
StateId extends StateIdentifier<States
|
|
4727
|
+
StateId extends StateIdentifier<States>,
|
|
4728
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4729
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4676
4730
|
> =
|
|
4677
|
-
| InvokeConfig<States, Events, Emits, StateId>
|
|
4678
|
-
| ReadonlyArray<InvokeConfig<States, Events, Emits, StateId>>
|
|
4731
|
+
| InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4732
|
+
| ReadonlyArray<InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
4733
|
+
|
|
4734
|
+
type TypedInvokeDefinition =
|
|
4735
|
+
| InvokeTyped<any, any, any, any, any, any>
|
|
4736
|
+
| ReadonlyArray<InvokeTyped<any, any, any, any, any, any>>
|
|
4679
4737
|
|
|
4680
4738
|
type InvokeHandlerRequirement<Value, Handler> = IsAny<Value> extends true ? { readonly handler: Handler }
|
|
4681
4739
|
: [Value] extends [never] ? { readonly handler?: never }
|
|
@@ -4697,7 +4755,9 @@ export declare namespace Machine {
|
|
|
4697
4755
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4698
4756
|
StateId extends StateIdentifier<States>,
|
|
4699
4757
|
Fx extends Effect.Effect<any, any, any>,
|
|
4700
|
-
Source = Fx
|
|
4758
|
+
Source = Fx,
|
|
4759
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4760
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4701
4761
|
> =
|
|
4702
4762
|
& {
|
|
4703
4763
|
readonly id: InvokeLifecycleId
|
|
@@ -4714,7 +4774,15 @@ export declare namespace Machine {
|
|
|
4714
4774
|
States,
|
|
4715
4775
|
Events,
|
|
4716
4776
|
Emits,
|
|
4717
|
-
InvokeDoneContext<
|
|
4777
|
+
InvokeDoneContext<
|
|
4778
|
+
States,
|
|
4779
|
+
Events,
|
|
4780
|
+
Emits,
|
|
4781
|
+
StateId,
|
|
4782
|
+
Effect.Success<NoInfer<Fx>>,
|
|
4783
|
+
InputEvents,
|
|
4784
|
+
ParentEvents
|
|
4785
|
+
>
|
|
4718
4786
|
>
|
|
4719
4787
|
>
|
|
4720
4788
|
& InvokeFailureRequirement<
|
|
@@ -4723,7 +4791,15 @@ export declare namespace Machine {
|
|
|
4723
4791
|
States,
|
|
4724
4792
|
Events,
|
|
4725
4793
|
Emits,
|
|
4726
|
-
InvokeFailureContext<
|
|
4794
|
+
InvokeFailureContext<
|
|
4795
|
+
States,
|
|
4796
|
+
Events,
|
|
4797
|
+
Emits,
|
|
4798
|
+
StateId,
|
|
4799
|
+
Effect.Error<NoInfer<Fx>>,
|
|
4800
|
+
InputEvents,
|
|
4801
|
+
ParentEvents
|
|
4802
|
+
>
|
|
4727
4803
|
>
|
|
4728
4804
|
>
|
|
4729
4805
|
|
|
@@ -4731,10 +4807,15 @@ export declare namespace Machine {
|
|
|
4731
4807
|
States extends StateSchemas,
|
|
4732
4808
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4733
4809
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4734
|
-
StateId extends StateIdentifier<States
|
|
4810
|
+
StateId extends StateIdentifier<States>,
|
|
4811
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4812
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4735
4813
|
> = {
|
|
4736
4814
|
readonly id: InvokeLifecycleId
|
|
4737
|
-
readonly after: InvokeSource<
|
|
4815
|
+
readonly after: InvokeSource<
|
|
4816
|
+
Duration.Input,
|
|
4817
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4818
|
+
>
|
|
4738
4819
|
readonly effect?: never
|
|
4739
4820
|
readonly logic?: never
|
|
4740
4821
|
readonly child?: never
|
|
@@ -4745,7 +4826,7 @@ export declare namespace Machine {
|
|
|
4745
4826
|
States,
|
|
4746
4827
|
Events,
|
|
4747
4828
|
Emits,
|
|
4748
|
-
InvokeDoneContext<States, Events, Emits, StateId, void>
|
|
4829
|
+
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
4749
4830
|
>
|
|
4750
4831
|
}
|
|
4751
4832
|
|
|
@@ -4761,7 +4842,9 @@ export declare namespace Machine {
|
|
|
4761
4842
|
ChildOutput,
|
|
4762
4843
|
ChildInitialError,
|
|
4763
4844
|
Address extends ChildAddress<never>,
|
|
4764
|
-
Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError
|
|
4845
|
+
Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
4846
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4847
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4765
4848
|
> =
|
|
4766
4849
|
& {
|
|
4767
4850
|
readonly id: InvokeLifecycleId
|
|
@@ -4774,16 +4857,36 @@ export declare namespace Machine {
|
|
|
4774
4857
|
States,
|
|
4775
4858
|
Events,
|
|
4776
4859
|
Emits,
|
|
4777
|
-
InvokeSnapshotContext<
|
|
4860
|
+
InvokeSnapshotContext<
|
|
4861
|
+
States,
|
|
4862
|
+
Events,
|
|
4863
|
+
Emits,
|
|
4864
|
+
StateId,
|
|
4865
|
+
ChildState,
|
|
4866
|
+
ChildError,
|
|
4867
|
+
ChildOutput,
|
|
4868
|
+
InputEvents,
|
|
4869
|
+
ParentEvents
|
|
4870
|
+
>
|
|
4778
4871
|
>
|
|
4779
4872
|
}
|
|
4780
4873
|
& InvokeDoneRequirement<
|
|
4781
4874
|
ChildOutput,
|
|
4782
|
-
InvokeTransition<
|
|
4875
|
+
InvokeTransition<
|
|
4876
|
+
States,
|
|
4877
|
+
Events,
|
|
4878
|
+
Emits,
|
|
4879
|
+
InvokeDoneContext<States, Events, Emits, StateId, ChildOutput, InputEvents, ParentEvents>
|
|
4880
|
+
>
|
|
4783
4881
|
>
|
|
4784
4882
|
& InvokeFailureRequirement<
|
|
4785
4883
|
ChildError,
|
|
4786
|
-
InvokeTransition<
|
|
4884
|
+
InvokeTransition<
|
|
4885
|
+
States,
|
|
4886
|
+
Events,
|
|
4887
|
+
Emits,
|
|
4888
|
+
InvokeFailureContext<States, Events, Emits, StateId, ChildError, InputEvents, ParentEvents>
|
|
4889
|
+
>
|
|
4787
4890
|
>
|
|
4788
4891
|
|
|
4789
4892
|
export type ChildInvokeArgs<
|
|
@@ -4792,7 +4895,9 @@ export declare namespace Machine {
|
|
|
4792
4895
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4793
4896
|
StateId extends StateIdentifier<States>,
|
|
4794
4897
|
ChildDefinition extends Machine.Any,
|
|
4795
|
-
Child extends ChildMachine<string, ChildDefinition
|
|
4898
|
+
Child extends ChildMachine<string, ChildDefinition>,
|
|
4899
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4900
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4796
4901
|
> =
|
|
4797
4902
|
& {
|
|
4798
4903
|
readonly child:
|
|
@@ -4819,12 +4924,17 @@ export declare namespace Machine {
|
|
|
4819
4924
|
StateId,
|
|
4820
4925
|
Snapshot<Machine.States<ChildDefinition>>,
|
|
4821
4926
|
Error<ChildDefinition>,
|
|
4822
|
-
Output<ChildDefinition
|
|
4927
|
+
Output<ChildDefinition>,
|
|
4928
|
+
InputEvents,
|
|
4929
|
+
ParentEvents
|
|
4823
4930
|
>
|
|
4824
4931
|
>
|
|
4825
4932
|
}
|
|
4826
4933
|
& (Input<ChildDefinition> extends typeof Schema.Void ? { readonly input?: never } : {
|
|
4827
|
-
readonly input: InvokeSource<
|
|
4934
|
+
readonly input: InvokeSource<
|
|
4935
|
+
Input<ChildDefinition>["Type"],
|
|
4936
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4937
|
+
>
|
|
4828
4938
|
})
|
|
4829
4939
|
& InvokeDoneRequirement<
|
|
4830
4940
|
Output<ChildDefinition>,
|
|
@@ -4832,7 +4942,15 @@ export declare namespace Machine {
|
|
|
4832
4942
|
States,
|
|
4833
4943
|
Events,
|
|
4834
4944
|
Emits,
|
|
4835
|
-
InvokeDoneContext<
|
|
4945
|
+
InvokeDoneContext<
|
|
4946
|
+
States,
|
|
4947
|
+
Events,
|
|
4948
|
+
Emits,
|
|
4949
|
+
StateId,
|
|
4950
|
+
Output<ChildDefinition>,
|
|
4951
|
+
InputEvents,
|
|
4952
|
+
ParentEvents
|
|
4953
|
+
>
|
|
4836
4954
|
>
|
|
4837
4955
|
>
|
|
4838
4956
|
& InvokeFailureRequirement<
|
|
@@ -4846,7 +4964,9 @@ export declare namespace Machine {
|
|
|
4846
4964
|
Events,
|
|
4847
4965
|
Emits,
|
|
4848
4966
|
StateId,
|
|
4849
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition
|
|
4967
|
+
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
4968
|
+
InputEvents,
|
|
4969
|
+
ParentEvents
|
|
4850
4970
|
>
|
|
4851
4971
|
>
|
|
4852
4972
|
>
|
|
@@ -4863,6 +4983,8 @@ export declare namespace Machine {
|
|
|
4863
4983
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4864
4984
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4865
4985
|
StateId extends StateIdentifier<States>,
|
|
4986
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
4987
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
4866
4988
|
Raw
|
|
4867
4989
|
> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown
|
|
4868
4990
|
: Raw extends { readonly effect: infer Source } ?
|
|
@@ -4873,7 +4995,7 @@ export declare namespace Machine {
|
|
|
4873
4995
|
States,
|
|
4874
4996
|
Events,
|
|
4875
4997
|
Emits,
|
|
4876
|
-
InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<Fx
|
|
4998
|
+
InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<Fx>, InputEvents, ParentEvents>
|
|
4877
4999
|
>
|
|
4878
5000
|
>
|
|
4879
5001
|
& InvokeFailureRequirement<
|
|
@@ -4882,7 +5004,7 @@ export declare namespace Machine {
|
|
|
4882
5004
|
States,
|
|
4883
5005
|
Events,
|
|
4884
5006
|
Emits,
|
|
4885
|
-
InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<Fx
|
|
5007
|
+
InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<Fx>, InputEvents, ParentEvents>
|
|
4886
5008
|
>
|
|
4887
5009
|
>
|
|
4888
5010
|
& { readonly onSnapshot?: never }
|
|
@@ -4892,7 +5014,7 @@ export declare namespace Machine {
|
|
|
4892
5014
|
States,
|
|
4893
5015
|
Events,
|
|
4894
5016
|
Emits,
|
|
4895
|
-
InvokeDoneContext<States, Events, Emits, StateId, void>
|
|
5017
|
+
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
4896
5018
|
>
|
|
4897
5019
|
readonly onFailure?: never
|
|
4898
5020
|
readonly onSnapshot?: never
|
|
@@ -4905,7 +5027,7 @@ export declare namespace Machine {
|
|
|
4905
5027
|
States,
|
|
4906
5028
|
Events,
|
|
4907
5029
|
Emits,
|
|
4908
|
-
InvokeDoneContext<States, Events, Emits, StateId, InvokeOutput<Raw
|
|
5030
|
+
InvokeDoneContext<States, Events, Emits, StateId, InvokeOutput<Raw>, InputEvents, ParentEvents>
|
|
4909
5031
|
>
|
|
4910
5032
|
>
|
|
4911
5033
|
& InvokeFailureRequirement<
|
|
@@ -4914,7 +5036,15 @@ export declare namespace Machine {
|
|
|
4914
5036
|
States,
|
|
4915
5037
|
Events,
|
|
4916
5038
|
Emits,
|
|
4917
|
-
InvokeFailureContext<
|
|
5039
|
+
InvokeFailureContext<
|
|
5040
|
+
States,
|
|
5041
|
+
Events,
|
|
5042
|
+
Emits,
|
|
5043
|
+
StateId,
|
|
5044
|
+
InvokeRuntimeError<Raw>,
|
|
5045
|
+
InputEvents,
|
|
5046
|
+
ParentEvents
|
|
5047
|
+
>
|
|
4918
5048
|
>
|
|
4919
5049
|
>
|
|
4920
5050
|
& {
|
|
@@ -4935,7 +5065,9 @@ export declare namespace Machine {
|
|
|
4935
5065
|
StateId,
|
|
4936
5066
|
ChildLogic extends Logic<infer ChildState, any, any, any, any, any> ? ChildState : never,
|
|
4937
5067
|
InvokeRuntimeError<Raw>,
|
|
4938
|
-
InvokeOutput<Raw
|
|
5068
|
+
InvokeOutput<Raw>,
|
|
5069
|
+
InputEvents,
|
|
5070
|
+
ParentEvents
|
|
4939
5071
|
>
|
|
4940
5072
|
>
|
|
4941
5073
|
}
|
|
@@ -4948,7 +5080,15 @@ export declare namespace Machine {
|
|
|
4948
5080
|
States,
|
|
4949
5081
|
Events,
|
|
4950
5082
|
Emits,
|
|
4951
|
-
InvokeDoneContext<
|
|
5083
|
+
InvokeDoneContext<
|
|
5084
|
+
States,
|
|
5085
|
+
Events,
|
|
5086
|
+
Emits,
|
|
5087
|
+
StateId,
|
|
5088
|
+
Output<ChildDefinition>,
|
|
5089
|
+
InputEvents,
|
|
5090
|
+
ParentEvents
|
|
5091
|
+
>
|
|
4952
5092
|
>
|
|
4953
5093
|
>
|
|
4954
5094
|
& InvokeFailureRequirement<
|
|
@@ -4962,12 +5102,17 @@ export declare namespace Machine {
|
|
|
4962
5102
|
Events,
|
|
4963
5103
|
Emits,
|
|
4964
5104
|
StateId,
|
|
4965
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition
|
|
5105
|
+
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
5106
|
+
InputEvents,
|
|
5107
|
+
ParentEvents
|
|
4966
5108
|
>
|
|
4967
5109
|
>
|
|
4968
5110
|
>
|
|
4969
5111
|
& (Input<ChildDefinition> extends typeof Schema.Void ? { readonly input?: never } : {
|
|
4970
|
-
readonly input: InvokeSource<
|
|
5112
|
+
readonly input: InvokeSource<
|
|
5113
|
+
Input<ChildDefinition>["Type"],
|
|
5114
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5115
|
+
>
|
|
4971
5116
|
})
|
|
4972
5117
|
& {
|
|
4973
5118
|
readonly onSnapshot?: InvokeTransition<
|
|
@@ -4981,7 +5126,9 @@ export declare namespace Machine {
|
|
|
4981
5126
|
StateId,
|
|
4982
5127
|
Snapshot<Machine.States<ChildDefinition>>,
|
|
4983
5128
|
Error<ChildDefinition>,
|
|
4984
|
-
Output<ChildDefinition
|
|
5129
|
+
Output<ChildDefinition>,
|
|
5130
|
+
InputEvents,
|
|
5131
|
+
ParentEvents
|
|
4985
5132
|
>
|
|
4986
5133
|
>
|
|
4987
5134
|
}
|
|
@@ -4993,11 +5140,21 @@ export declare namespace Machine {
|
|
|
4993
5140
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4994
5141
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4995
5142
|
StateId extends StateIdentifier<States>,
|
|
5143
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
5144
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
4996
5145
|
Raw
|
|
4997
5146
|
> = Raw extends ReadonlyArray<any> ? {
|
|
4998
|
-
readonly [Index in keyof Raw]: ContextualInvokeConfig<
|
|
5147
|
+
readonly [Index in keyof Raw]: ContextualInvokeConfig<
|
|
5148
|
+
States,
|
|
5149
|
+
Events,
|
|
5150
|
+
Emits,
|
|
5151
|
+
StateId,
|
|
5152
|
+
InputEvents,
|
|
5153
|
+
ParentEvents,
|
|
5154
|
+
Raw[Index]
|
|
5155
|
+
>
|
|
4999
5156
|
}
|
|
5000
|
-
: ContextualInvokeConfig<States, Events, Emits, StateId, Raw>
|
|
5157
|
+
: ContextualInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents, Raw>
|
|
5001
5158
|
|
|
5002
5159
|
type OutputHandlerConfig<
|
|
5003
5160
|
States extends StateSchemas,
|
|
@@ -5049,7 +5206,9 @@ export declare namespace Machine {
|
|
|
5049
5206
|
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
5050
5207
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5051
5208
|
) => StateActionResult<any, any>
|
|
5052
|
-
readonly invoke?:
|
|
5209
|
+
readonly invoke?:
|
|
5210
|
+
| InvokeDefinition<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5211
|
+
| TypedInvokeDefinition
|
|
5053
5212
|
readonly always?:
|
|
5054
5213
|
| ((
|
|
5055
5214
|
context: AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
@@ -5300,14 +5459,26 @@ export declare namespace Machine {
|
|
|
5300
5459
|
type HandlerInvokeContextAtPath<
|
|
5301
5460
|
AllStates extends StateSchemas,
|
|
5302
5461
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5462
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
5303
5463
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5464
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
5304
5465
|
Config,
|
|
5305
5466
|
StateId extends StateNodeIdentifier<AllStates>,
|
|
5306
5467
|
NodeConfig = HandlerConfigAtPath<Config, StateId>
|
|
5307
5468
|
> = StateId extends StateIdentifier<AllStates> ?
|
|
5308
5469
|
NodeConfig extends { readonly invoke: infer Invoke } ? HandlerValidationAtPath<
|
|
5309
5470
|
StateId,
|
|
5310
|
-
{
|
|
5471
|
+
{
|
|
5472
|
+
readonly invoke: ContextualInvokeDefinition<
|
|
5473
|
+
AllStates,
|
|
5474
|
+
Events,
|
|
5475
|
+
Emits,
|
|
5476
|
+
StateId,
|
|
5477
|
+
InputEvents,
|
|
5478
|
+
ParentEvents,
|
|
5479
|
+
Invoke
|
|
5480
|
+
>
|
|
5481
|
+
}
|
|
5311
5482
|
>
|
|
5312
5483
|
: unknown
|
|
5313
5484
|
: unknown
|
|
@@ -5315,14 +5486,18 @@ export declare namespace Machine {
|
|
|
5315
5486
|
type HandlerInvokeContexts<
|
|
5316
5487
|
AllStates extends StateSchemas,
|
|
5317
5488
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5489
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
5318
5490
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5491
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
5319
5492
|
Config
|
|
5320
5493
|
> = Types.UnionToIntersection<
|
|
5321
5494
|
StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ?
|
|
5322
5495
|
StateId extends StateNodeIdentifier<AllStates> ? HandlerInvokeContextAtPath<
|
|
5323
5496
|
AllStates,
|
|
5324
5497
|
Events,
|
|
5498
|
+
InputEvents,
|
|
5325
5499
|
Emits,
|
|
5500
|
+
ParentEvents,
|
|
5326
5501
|
Config,
|
|
5327
5502
|
StateId
|
|
5328
5503
|
>
|
|
@@ -5919,7 +6094,7 @@ export declare namespace Machine {
|
|
|
5919
6094
|
>(
|
|
5920
6095
|
config:
|
|
5921
6096
|
& Config
|
|
5922
|
-
& HandlerInvokeContexts<States, Events, Emits, NoInfer<Config>>
|
|
6097
|
+
& HandlerInvokeContexts<States, Events, InputEvents, Emits, ParentEvents, NoInfer<Config>>
|
|
5923
6098
|
& HandlerTreeValidation<
|
|
5924
6099
|
States,
|
|
5925
6100
|
Events,
|
|
@@ -6559,7 +6734,7 @@ type DynamicEffectInvokeSource<
|
|
|
6559
6734
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6560
6735
|
StateId extends Machine.StateIdentifier<States>,
|
|
6561
6736
|
Source extends (
|
|
6562
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId>
|
|
6737
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6563
6738
|
) => Effect.Effect<unknown, unknown, unknown>
|
|
6564
6739
|
> = {
|
|
6565
6740
|
readonly id: InvokeLifecycleId
|
|
@@ -6581,7 +6756,15 @@ type DynamicEffectDoneHandler<
|
|
|
6581
6756
|
States,
|
|
6582
6757
|
Events,
|
|
6583
6758
|
Emits,
|
|
6584
|
-
Machine.InvokeDoneContext<
|
|
6759
|
+
Machine.InvokeDoneContext<
|
|
6760
|
+
States,
|
|
6761
|
+
Events,
|
|
6762
|
+
Emits,
|
|
6763
|
+
StateId,
|
|
6764
|
+
Effect.Success<ReturnType<NoInfer<Source>>>,
|
|
6765
|
+
readonly [],
|
|
6766
|
+
readonly []
|
|
6767
|
+
>
|
|
6585
6768
|
>
|
|
6586
6769
|
|
|
6587
6770
|
type DynamicEffectFailureHandler<
|
|
@@ -6594,7 +6777,15 @@ type DynamicEffectFailureHandler<
|
|
|
6594
6777
|
States,
|
|
6595
6778
|
Events,
|
|
6596
6779
|
Emits,
|
|
6597
|
-
Machine.InvokeFailureContext<
|
|
6780
|
+
Machine.InvokeFailureContext<
|
|
6781
|
+
States,
|
|
6782
|
+
Events,
|
|
6783
|
+
Emits,
|
|
6784
|
+
StateId,
|
|
6785
|
+
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
6786
|
+
readonly [],
|
|
6787
|
+
readonly []
|
|
6788
|
+
>
|
|
6598
6789
|
>
|
|
6599
6790
|
|
|
6600
6791
|
type DynamicEffectInvokeResult<
|
|
@@ -6604,7 +6795,7 @@ type DynamicEffectInvokeResult<
|
|
|
6604
6795
|
StateId extends Machine.StateIdentifier<States>,
|
|
6605
6796
|
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
6606
6797
|
> =
|
|
6607
|
-
& Machine.InvokeConfig<States, Events, Emits, StateId>
|
|
6798
|
+
& Machine.InvokeConfig<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6608
6799
|
& Machine.InvokeTyped<
|
|
6609
6800
|
Effect.Success<ReturnType<Source>>,
|
|
6610
6801
|
Effect.Error<ReturnType<Source>>,
|
|
@@ -6614,6 +6805,325 @@ type DynamicEffectInvokeResult<
|
|
|
6614
6805
|
|
|
6615
6806
|
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
6616
6807
|
|
|
6808
|
+
type BoundDynamicEffectInvokeSource<
|
|
6809
|
+
States extends Machine.StateSchemas,
|
|
6810
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6811
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6812
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6813
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6814
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6815
|
+
Source extends (
|
|
6816
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6817
|
+
) => Effect.Effect<unknown, unknown, unknown>
|
|
6818
|
+
> = {
|
|
6819
|
+
readonly id: InvokeLifecycleId
|
|
6820
|
+
readonly effect: Source
|
|
6821
|
+
readonly after?: never
|
|
6822
|
+
readonly logic?: never
|
|
6823
|
+
readonly child?: never
|
|
6824
|
+
readonly address?: never
|
|
6825
|
+
readonly onSnapshot?: never
|
|
6826
|
+
}
|
|
6827
|
+
|
|
6828
|
+
type BoundDynamicEffectDoneHandler<
|
|
6829
|
+
States extends Machine.StateSchemas,
|
|
6830
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6831
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6832
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6833
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6834
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6835
|
+
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
6836
|
+
> = Machine.InvokeTransition<
|
|
6837
|
+
States,
|
|
6838
|
+
Events,
|
|
6839
|
+
Emits,
|
|
6840
|
+
Machine.InvokeDoneContext<
|
|
6841
|
+
States,
|
|
6842
|
+
Events,
|
|
6843
|
+
Emits,
|
|
6844
|
+
StateId,
|
|
6845
|
+
Effect.Success<ReturnType<NoInfer<Source>>>,
|
|
6846
|
+
InputEvents,
|
|
6847
|
+
ParentEvents
|
|
6848
|
+
>
|
|
6849
|
+
>
|
|
6850
|
+
|
|
6851
|
+
type BoundDynamicEffectFailureHandler<
|
|
6852
|
+
States extends Machine.StateSchemas,
|
|
6853
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6854
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6855
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6856
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6857
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6858
|
+
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
6859
|
+
> = Machine.InvokeTransition<
|
|
6860
|
+
States,
|
|
6861
|
+
Events,
|
|
6862
|
+
Emits,
|
|
6863
|
+
Machine.InvokeFailureContext<
|
|
6864
|
+
States,
|
|
6865
|
+
Events,
|
|
6866
|
+
Emits,
|
|
6867
|
+
StateId,
|
|
6868
|
+
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
6869
|
+
InputEvents,
|
|
6870
|
+
ParentEvents
|
|
6871
|
+
>
|
|
6872
|
+
>
|
|
6873
|
+
|
|
6874
|
+
type BoundDynamicEffectInvokeResult<
|
|
6875
|
+
States extends Machine.StateSchemas,
|
|
6876
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6877
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6878
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6879
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6880
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6881
|
+
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
6882
|
+
> =
|
|
6883
|
+
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6884
|
+
& Machine.InvokeTyped<
|
|
6885
|
+
Effect.Success<ReturnType<Source>>,
|
|
6886
|
+
Effect.Error<ReturnType<Source>>,
|
|
6887
|
+
Effect.Services<ReturnType<Source>>,
|
|
6888
|
+
never
|
|
6889
|
+
>
|
|
6890
|
+
|
|
6891
|
+
/**
|
|
6892
|
+
* Machine-bound invocation constructor that preserves the owning machine's
|
|
6893
|
+
* public input and parent protocols in every invocation callback.
|
|
6894
|
+
*
|
|
6895
|
+
* @category constructors
|
|
6896
|
+
* @since 0.11.0
|
|
6897
|
+
*/
|
|
6898
|
+
export interface Invoker<
|
|
6899
|
+
States extends Machine.StateSchemas,
|
|
6900
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6901
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6902
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6903
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>
|
|
6904
|
+
> {
|
|
6905
|
+
<
|
|
6906
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6907
|
+
const Source extends (
|
|
6908
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6909
|
+
) => Effect.Effect<unknown, unknown, unknown>
|
|
6910
|
+
>(
|
|
6911
|
+
config:
|
|
6912
|
+
& BoundDynamicEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6913
|
+
& {
|
|
6914
|
+
readonly onDone: BoundDynamicEffectDoneHandler<
|
|
6915
|
+
States,
|
|
6916
|
+
Events,
|
|
6917
|
+
Emits,
|
|
6918
|
+
InputEvents,
|
|
6919
|
+
ParentEvents,
|
|
6920
|
+
StateId,
|
|
6921
|
+
Source
|
|
6922
|
+
>
|
|
6923
|
+
readonly onFailure: BoundDynamicEffectFailureHandler<
|
|
6924
|
+
States,
|
|
6925
|
+
Events,
|
|
6926
|
+
Emits,
|
|
6927
|
+
InputEvents,
|
|
6928
|
+
ParentEvents,
|
|
6929
|
+
StateId,
|
|
6930
|
+
Source
|
|
6931
|
+
>
|
|
6932
|
+
},
|
|
6933
|
+
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
6934
|
+
"onDone must be omitted when the Effect output is never"
|
|
6935
|
+
]
|
|
6936
|
+
: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
6937
|
+
"onFailure must be omitted when the Effect error is never"
|
|
6938
|
+
]
|
|
6939
|
+
: []
|
|
6940
|
+
): BoundDynamicEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6941
|
+
<
|
|
6942
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6943
|
+
const Source extends (
|
|
6944
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6945
|
+
) => Effect.Effect<unknown, never, unknown>
|
|
6946
|
+
>(
|
|
6947
|
+
config:
|
|
6948
|
+
& BoundDynamicEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6949
|
+
& {
|
|
6950
|
+
readonly onDone: BoundDynamicEffectDoneHandler<
|
|
6951
|
+
States,
|
|
6952
|
+
Events,
|
|
6953
|
+
Emits,
|
|
6954
|
+
InputEvents,
|
|
6955
|
+
ParentEvents,
|
|
6956
|
+
StateId,
|
|
6957
|
+
Source
|
|
6958
|
+
>
|
|
6959
|
+
readonly onFailure?: never
|
|
6960
|
+
},
|
|
6961
|
+
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
6962
|
+
"onDone must be omitted when the Effect output is never"
|
|
6963
|
+
]
|
|
6964
|
+
: []
|
|
6965
|
+
): BoundDynamicEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6966
|
+
<
|
|
6967
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6968
|
+
const Source extends (
|
|
6969
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6970
|
+
) => Effect.Effect<never, unknown, unknown>
|
|
6971
|
+
>(
|
|
6972
|
+
config:
|
|
6973
|
+
& BoundDynamicEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6974
|
+
& {
|
|
6975
|
+
readonly onDone?: never
|
|
6976
|
+
readonly onFailure: BoundDynamicEffectFailureHandler<
|
|
6977
|
+
States,
|
|
6978
|
+
Events,
|
|
6979
|
+
Emits,
|
|
6980
|
+
InputEvents,
|
|
6981
|
+
ParentEvents,
|
|
6982
|
+
StateId,
|
|
6983
|
+
Source
|
|
6984
|
+
>
|
|
6985
|
+
},
|
|
6986
|
+
..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
6987
|
+
"onFailure must be omitted when the Effect error is never"
|
|
6988
|
+
]
|
|
6989
|
+
: []
|
|
6990
|
+
): BoundDynamicEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6991
|
+
<
|
|
6992
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
6993
|
+
const Source extends (
|
|
6994
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6995
|
+
) => Effect.Effect<never, never, unknown>
|
|
6996
|
+
>(
|
|
6997
|
+
config:
|
|
6998
|
+
& BoundDynamicEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6999
|
+
& {
|
|
7000
|
+
readonly onDone?: never
|
|
7001
|
+
readonly onFailure?: never
|
|
7002
|
+
}
|
|
7003
|
+
): BoundDynamicEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
7004
|
+
<
|
|
7005
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7006
|
+
const Fx extends Effect.Effect<any, any, any>,
|
|
7007
|
+
const Config extends object
|
|
7008
|
+
>(
|
|
7009
|
+
config:
|
|
7010
|
+
& Config
|
|
7011
|
+
& Machine.EffectInvokeArgs<
|
|
7012
|
+
States,
|
|
7013
|
+
Events,
|
|
7014
|
+
Emits,
|
|
7015
|
+
StateId,
|
|
7016
|
+
Fx,
|
|
7017
|
+
Fx,
|
|
7018
|
+
InputEvents,
|
|
7019
|
+
ParentEvents
|
|
7020
|
+
>
|
|
7021
|
+
):
|
|
7022
|
+
& Config
|
|
7023
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
7024
|
+
& Machine.InvokeTyped<Effect.Success<Fx>, Effect.Error<Fx>, Effect.Services<Fx>, never>
|
|
7025
|
+
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(
|
|
7026
|
+
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7027
|
+
): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>
|
|
7028
|
+
<
|
|
7029
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7030
|
+
ChildState,
|
|
7031
|
+
ChildEvent,
|
|
7032
|
+
ChildError,
|
|
7033
|
+
ChildRequirements,
|
|
7034
|
+
ChildOutput,
|
|
7035
|
+
ChildInitialError,
|
|
7036
|
+
Address extends ChildAddress<never>
|
|
7037
|
+
>(
|
|
7038
|
+
config: Machine.LogicInvokeArgs<
|
|
7039
|
+
States,
|
|
7040
|
+
Events,
|
|
7041
|
+
Emits,
|
|
7042
|
+
StateId,
|
|
7043
|
+
ChildState,
|
|
7044
|
+
ChildEvent,
|
|
7045
|
+
ChildError,
|
|
7046
|
+
ChildRequirements,
|
|
7047
|
+
ChildOutput,
|
|
7048
|
+
ChildInitialError,
|
|
7049
|
+
Address,
|
|
7050
|
+
(context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Logic<
|
|
7051
|
+
ChildState,
|
|
7052
|
+
ChildEvent,
|
|
7053
|
+
ChildError,
|
|
7054
|
+
ChildRequirements,
|
|
7055
|
+
ChildOutput,
|
|
7056
|
+
ChildInitialError
|
|
7057
|
+
>,
|
|
7058
|
+
InputEvents,
|
|
7059
|
+
ParentEvents
|
|
7060
|
+
>
|
|
7061
|
+
):
|
|
7062
|
+
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7063
|
+
& Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>
|
|
7064
|
+
<
|
|
7065
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7066
|
+
ChildState,
|
|
7067
|
+
ChildEvent,
|
|
7068
|
+
ChildError,
|
|
7069
|
+
ChildRequirements,
|
|
7070
|
+
ChildOutput,
|
|
7071
|
+
ChildInitialError,
|
|
7072
|
+
Address extends ChildAddress<never>,
|
|
7073
|
+
const Config extends object
|
|
7074
|
+
>(
|
|
7075
|
+
config:
|
|
7076
|
+
& Config
|
|
7077
|
+
& Machine.LogicInvokeArgs<
|
|
7078
|
+
States,
|
|
7079
|
+
Events,
|
|
7080
|
+
Emits,
|
|
7081
|
+
StateId,
|
|
7082
|
+
ChildState,
|
|
7083
|
+
ChildEvent,
|
|
7084
|
+
ChildError,
|
|
7085
|
+
ChildRequirements,
|
|
7086
|
+
ChildOutput,
|
|
7087
|
+
ChildInitialError,
|
|
7088
|
+
Address,
|
|
7089
|
+
Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
7090
|
+
InputEvents,
|
|
7091
|
+
ParentEvents
|
|
7092
|
+
>
|
|
7093
|
+
):
|
|
7094
|
+
& Config
|
|
7095
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
7096
|
+
& Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>
|
|
7097
|
+
<
|
|
7098
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7099
|
+
const Child extends ChildMachine.Any,
|
|
7100
|
+
const Config extends object
|
|
7101
|
+
>(
|
|
7102
|
+
config:
|
|
7103
|
+
& Config
|
|
7104
|
+
& Machine.ChildInvokeArgs<
|
|
7105
|
+
States,
|
|
7106
|
+
Events,
|
|
7107
|
+
Emits,
|
|
7108
|
+
StateId,
|
|
7109
|
+
Child["machine"],
|
|
7110
|
+
Child,
|
|
7111
|
+
InputEvents,
|
|
7112
|
+
ParentEvents
|
|
7113
|
+
>
|
|
7114
|
+
):
|
|
7115
|
+
& Config
|
|
7116
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
7117
|
+
& Machine.InvokeTyped<
|
|
7118
|
+
Machine.Output<Child["machine"]>,
|
|
7119
|
+
Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>,
|
|
7120
|
+
Machine.Services<Child["machine"]>,
|
|
7121
|
+
Machine.InitialError<Child["machine"]>,
|
|
7122
|
+
Machine.Emit<Child["machine"]>,
|
|
7123
|
+
Machine.EventOf<Machine.ParentEvents<Child["machine"]>>
|
|
7124
|
+
>
|
|
7125
|
+
}
|
|
7126
|
+
|
|
6617
7127
|
/**
|
|
6618
7128
|
* Preserves inference for a state-owned invocation configuration.
|
|
6619
7129
|
*
|
|
@@ -6630,6 +7140,12 @@ type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] e
|
|
|
6630
7140
|
* lifecycle `id` and a typed communication `address`. Child descriptors already
|
|
6631
7141
|
* own their identity, so `id` and `address` must not be repeated.
|
|
6632
7142
|
*
|
|
7143
|
+
* Owner references are intentionally non-sendable here because this standalone
|
|
7144
|
+
* constructor does not know the owning definition. When a callback sends to
|
|
7145
|
+
* `self` or `parent`, use the bound constructor on the owning definition
|
|
7146
|
+
* (`definition.invoke(...)`) so the exact public input and `parentEvents`
|
|
7147
|
+
* protocols are available.
|
|
7148
|
+
*
|
|
6633
7149
|
* ```ts
|
|
6634
7150
|
* invoke: Machine.invoke({
|
|
6635
7151
|
* id: "load",
|
|
@@ -6652,7 +7168,7 @@ export const invoke: {
|
|
|
6652
7168
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6653
7169
|
StateId extends Machine.StateIdentifier<States>,
|
|
6654
7170
|
const Source extends (
|
|
6655
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId>
|
|
7171
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6656
7172
|
) => Effect.Effect<unknown, unknown, unknown>
|
|
6657
7173
|
>(
|
|
6658
7174
|
config:
|
|
@@ -6675,7 +7191,7 @@ export const invoke: {
|
|
|
6675
7191
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6676
7192
|
StateId extends Machine.StateIdentifier<States>,
|
|
6677
7193
|
const Source extends (
|
|
6678
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId>
|
|
7194
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6679
7195
|
) => Effect.Effect<unknown, never, unknown>
|
|
6680
7196
|
>(
|
|
6681
7197
|
config:
|
|
@@ -6695,7 +7211,7 @@ export const invoke: {
|
|
|
6695
7211
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6696
7212
|
StateId extends Machine.StateIdentifier<States>,
|
|
6697
7213
|
const Source extends (
|
|
6698
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId>
|
|
7214
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6699
7215
|
) => Effect.Effect<never, unknown, unknown>
|
|
6700
7216
|
>(
|
|
6701
7217
|
config:
|
|
@@ -6715,7 +7231,7 @@ export const invoke: {
|
|
|
6715
7231
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6716
7232
|
StateId extends Machine.StateIdentifier<States>,
|
|
6717
7233
|
const Source extends (
|
|
6718
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId>
|
|
7234
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6719
7235
|
) => Effect.Effect<never, never, unknown>
|
|
6720
7236
|
>(
|
|
6721
7237
|
config:
|
|
@@ -6733,7 +7249,9 @@ export const invoke: {
|
|
|
6733
7249
|
const Fx extends Effect.Effect<any, any, any>,
|
|
6734
7250
|
const Config extends object
|
|
6735
7251
|
>(
|
|
6736
|
-
config:
|
|
7252
|
+
config:
|
|
7253
|
+
& Config
|
|
7254
|
+
& Machine.EffectInvokeArgs<States, Events, Emits, StateId, Fx, Fx, readonly [], readonly []>
|
|
6737
7255
|
):
|
|
6738
7256
|
& Config
|
|
6739
7257
|
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
@@ -6750,7 +7268,7 @@ export const invoke: {
|
|
|
6750
7268
|
StateId extends Machine.StateIdentifier<States>,
|
|
6751
7269
|
const Config extends object
|
|
6752
7270
|
>(
|
|
6753
|
-
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId>
|
|
7271
|
+
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6754
7272
|
): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>
|
|
6755
7273
|
<
|
|
6756
7274
|
const States extends Machine.StateSchemas,
|
|
@@ -6777,17 +7295,19 @@ export const invoke: {
|
|
|
6777
7295
|
ChildOutput,
|
|
6778
7296
|
ChildInitialError,
|
|
6779
7297
|
Address,
|
|
6780
|
-
(context: Machine.InvokeContext<States, Events, Emits, StateId>) => Logic<
|
|
7298
|
+
(context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Logic<
|
|
6781
7299
|
ChildState,
|
|
6782
7300
|
ChildEvent,
|
|
6783
7301
|
ChildError,
|
|
6784
7302
|
ChildRequirements,
|
|
6785
7303
|
ChildOutput,
|
|
6786
7304
|
ChildInitialError
|
|
6787
|
-
|
|
7305
|
+
>,
|
|
7306
|
+
readonly [],
|
|
7307
|
+
readonly []
|
|
6788
7308
|
>
|
|
6789
7309
|
):
|
|
6790
|
-
& Machine.InvokeConfig<States, Events, Emits, StateId>
|
|
7310
|
+
& Machine.InvokeConfig<States, Events, Emits, StateId, readonly [], readonly []>
|
|
6791
7311
|
& Machine.InvokeTyped<
|
|
6792
7312
|
ChildOutput,
|
|
6793
7313
|
ChildError,
|
|
@@ -6821,7 +7341,10 @@ export const invoke: {
|
|
|
6821
7341
|
ChildRequirements,
|
|
6822
7342
|
ChildOutput,
|
|
6823
7343
|
ChildInitialError,
|
|
6824
|
-
Address
|
|
7344
|
+
Address,
|
|
7345
|
+
Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
7346
|
+
readonly [],
|
|
7347
|
+
readonly []
|
|
6825
7348
|
>
|
|
6826
7349
|
):
|
|
6827
7350
|
& Config
|
|
@@ -6840,7 +7363,9 @@ export const invoke: {
|
|
|
6840
7363
|
const Child extends ChildMachine.Any,
|
|
6841
7364
|
const Config extends object
|
|
6842
7365
|
>(
|
|
6843
|
-
config:
|
|
7366
|
+
config:
|
|
7367
|
+
& Config
|
|
7368
|
+
& Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child, readonly [], readonly []>
|
|
6844
7369
|
):
|
|
6845
7370
|
& Config
|
|
6846
7371
|
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
@@ -7410,6 +7935,89 @@ export const watch: <State, Event, Error = never, Output = never>(
|
|
|
7410
7935
|
ref: MachineRef<State, Event, Error, Output>
|
|
7411
7936
|
) => Stream.Stream<RuntimeOutcome<State, Error, Output>> = internal.watch
|
|
7412
7937
|
|
|
7938
|
+
/**
|
|
7939
|
+
* Prepares a fresh machine without initializing it.
|
|
7940
|
+
*
|
|
7941
|
+
* Use this constructor when observation must be composed before initial-entry
|
|
7942
|
+
* actions run. Subscribe to `prepared.emissions`, then evaluate
|
|
7943
|
+
* `prepared.start`. Ordinary callers can continue to use {@link start}, which
|
|
7944
|
+
* starts directly and does not allocate the prepared lifecycle boundary.
|
|
7945
|
+
*
|
|
7946
|
+
* ```ts
|
|
7947
|
+
* const prepared = yield* Machine.prepare(machine)
|
|
7948
|
+
*
|
|
7949
|
+
* yield* prepared.emissions.pipe(
|
|
7950
|
+
* Stream.runForEach(handleEmission),
|
|
7951
|
+
* Effect.forkScoped({ startImmediately: true })
|
|
7952
|
+
* )
|
|
7953
|
+
*
|
|
7954
|
+
* const ref = yield* prepared.start
|
|
7955
|
+
* ```
|
|
7956
|
+
*
|
|
7957
|
+
* @category constructors
|
|
7958
|
+
* @since 0.11.0
|
|
7959
|
+
*/
|
|
7960
|
+
export const prepare: <
|
|
7961
|
+
const States extends Machine.StateSchemas,
|
|
7962
|
+
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7963
|
+
const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
7964
|
+
const Input extends Schema.Top = typeof Schema.Void,
|
|
7965
|
+
UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>,
|
|
7966
|
+
E = never,
|
|
7967
|
+
R = never,
|
|
7968
|
+
InitialE = never,
|
|
7969
|
+
InitialR = never,
|
|
7970
|
+
FinalStates extends Machine.StateIdentifier<States> = never,
|
|
7971
|
+
Output = never,
|
|
7972
|
+
OutputStates extends Machine.StateIdentifier<States> = never,
|
|
7973
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events,
|
|
7974
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
7975
|
+
>(
|
|
7976
|
+
machine:
|
|
7977
|
+
& Machine<
|
|
7978
|
+
States,
|
|
7979
|
+
Events,
|
|
7980
|
+
Input,
|
|
7981
|
+
UnhandledStates,
|
|
7982
|
+
E,
|
|
7983
|
+
R,
|
|
7984
|
+
InitialE,
|
|
7985
|
+
InitialR,
|
|
7986
|
+
FinalStates,
|
|
7987
|
+
Output,
|
|
7988
|
+
Emits,
|
|
7989
|
+
OutputStates,
|
|
7990
|
+
InputEvents,
|
|
7991
|
+
ParentEvents
|
|
7992
|
+
>
|
|
7993
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>,
|
|
7994
|
+
...args: [...Machine.InputArgs<Input>]
|
|
7995
|
+
) => Effect.Effect<
|
|
7996
|
+
Prepared<
|
|
7997
|
+
Machine.Snapshot<States>,
|
|
7998
|
+
Machine.EventInputOf<InputEvents>,
|
|
7999
|
+
| E
|
|
8000
|
+
| ActionError<R>
|
|
8001
|
+
| InfiniteTransitionError
|
|
8002
|
+
| MachineSchemaDecodeError
|
|
8003
|
+
| StoppedError,
|
|
8004
|
+
Output,
|
|
8005
|
+
Machine.EmittedEventOf<Emits>,
|
|
8006
|
+
| InitialE
|
|
8007
|
+
| E
|
|
8008
|
+
| ActionError<InitialR | R>
|
|
8009
|
+
| InfiniteTransitionError
|
|
8010
|
+
| MachineSchemaDecodeError
|
|
8011
|
+
| StartupError
|
|
8012
|
+
| StoppedError,
|
|
8013
|
+
ExcludeCompatibleRuntime<
|
|
8014
|
+
ExecutionServices<InitialR | R>,
|
|
8015
|
+
Machine.EventOf<Events>,
|
|
8016
|
+
Machine.EmitOf<Emits>
|
|
8017
|
+
>
|
|
8018
|
+
>
|
|
8019
|
+
> = internal.prepare as any
|
|
8020
|
+
|
|
7413
8021
|
/**
|
|
7414
8022
|
* Starts a machine.
|
|
7415
8023
|
*
|