@typeonce/effect-machine 0.17.0 → 0.18.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 +79 -64
- package/dist/Machine.d.ts +139 -272
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +3 -49
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +48 -10
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +4 -4
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/docs/agent-guide.md +106 -67
- package/package.json +1 -1
- package/src/Machine.ts +552 -1040
- package/src/internal/machine/invocation.ts +1 -1
- package/src/internal/machine/machine.ts +64 -8
- package/src/internal/testing/machine/exploration.ts +1 -1
- package/src/internal/testing/machine/trace.ts +1 -1
- package/src/internal/testing/machine/verification.ts +1 -1
- package/src/testing/MachineTest.ts +4 -4
- package/src/unstable/reactivity/AtomMachine.ts +1 -1
package/src/Machine.ts
CHANGED
|
@@ -634,6 +634,7 @@ type IncompatibleRuntime<Requirements, Events, Emits> = Requirements extends Run
|
|
|
634
634
|
const InvokeTypeId: typeof internal.InvokeTypeId = internal.InvokeTypeId
|
|
635
635
|
const TransitionTypeId: typeof internal.TransitionTypeId = internal.TransitionTypeId
|
|
636
636
|
declare const TransitionBuilderTypeId: unique symbol
|
|
637
|
+
declare const InvokeBuilderTypeId: unique symbol
|
|
637
638
|
declare const InitialBuilderTypeId: unique symbol
|
|
638
639
|
|
|
639
640
|
type StateDefinitionError<
|
|
@@ -2192,7 +2193,7 @@ export interface MachineRef<out State, in Event, out Error = never, out Output =
|
|
|
2192
2193
|
}
|
|
2193
2194
|
|
|
2194
2195
|
/**
|
|
2195
|
-
* Machine-specific process logic used by `spawn` and
|
|
2196
|
+
* Machine-specific process logic used by `spawn` and state-owned invocations.
|
|
2196
2197
|
*
|
|
2197
2198
|
* @category models
|
|
2198
2199
|
* @since 0.4.0
|
|
@@ -2608,12 +2609,26 @@ export declare namespace Machine {
|
|
|
2608
2609
|
export type Events<M extends Any> = M[typeof MachineTypeId]["events"]
|
|
2609
2610
|
|
|
2610
2611
|
/**
|
|
2611
|
-
* Extracts the input schema carried by a machine definition.
|
|
2612
|
+
* Extracts the startup input schema carried by a machine definition.
|
|
2612
2613
|
*
|
|
2613
2614
|
* @category utility types
|
|
2614
|
-
* @since 0.
|
|
2615
|
+
* @since 0.18.0
|
|
2616
|
+
*/
|
|
2617
|
+
export type InputSchema<M extends Any> = M[typeof MachineTypeId]["input"]
|
|
2618
|
+
|
|
2619
|
+
/**
|
|
2620
|
+
* Extracts the decoded startup input accepted by a machine definition.
|
|
2621
|
+
*
|
|
2622
|
+
* Machines declared with `Schema.Void` do not accept a startup input, so
|
|
2623
|
+
* their extracted input type is `never`.
|
|
2624
|
+
*
|
|
2625
|
+
* @category utility types
|
|
2626
|
+
* @since 0.18.0
|
|
2615
2627
|
*/
|
|
2616
|
-
export type Input<M extends Any> = M
|
|
2628
|
+
export type Input<M extends Any> = InputSchema<M> extends infer Input extends Schema.Top
|
|
2629
|
+
? Input extends typeof Schema.Void ? never
|
|
2630
|
+
: Input["Type"]
|
|
2631
|
+
: never
|
|
2617
2632
|
|
|
2618
2633
|
/**
|
|
2619
2634
|
* Extracts state paths that do not yet have handlers.
|
|
@@ -5213,11 +5228,19 @@ export declare namespace Machine {
|
|
|
5213
5228
|
: never
|
|
5214
5229
|
/** Extracts transition results returned by invocation lifecycle handlers. */
|
|
5215
5230
|
export type InvokeOutcomeReturn<Invoke> = Invoke extends unknown ?
|
|
5231
|
+
| (Invoke extends {
|
|
5232
|
+
readonly [InvokeTypeId]: { readonly outcomes: Types.Covariant<infer Outcomes> }
|
|
5233
|
+
} ? EventTransitionReturn<Outcomes> :
|
|
5234
|
+
never)
|
|
5216
5235
|
| (Invoke extends { readonly onDone?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5217
5236
|
| (Invoke extends { readonly onFailure?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5218
5237
|
| (Invoke extends { readonly onElement?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5219
5238
|
| (Invoke extends { readonly onSnapshot?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5220
5239
|
: never
|
|
5240
|
+
type InvokeOutcomeError<Invoke> = IsAny<InvokeOutcomeReturn<Invoke>> extends true ? never
|
|
5241
|
+
: Effect.Error<InvokeOutcomeReturn<Invoke>>
|
|
5242
|
+
type InvokeOutcomeServices<Invoke> = IsAny<InvokeOutcomeReturn<Invoke>> extends true ? never
|
|
5243
|
+
: Effect.Services<InvokeOutcomeReturn<Invoke>>
|
|
5221
5244
|
/**
|
|
5222
5245
|
* Extracts the parent transition error contribution from invoked children.
|
|
5223
5246
|
*
|
|
@@ -5228,7 +5251,7 @@ export declare namespace Machine {
|
|
|
5228
5251
|
:
|
|
5229
5252
|
| ChildAlreadyExistsError
|
|
5230
5253
|
| InvokeInitialError<InvokeReturn<Config>>
|
|
5231
|
-
|
|
|
5254
|
+
| InvokeOutcomeError<InvokeReturn<Config>>
|
|
5232
5255
|
/**
|
|
5233
5256
|
* Extracts the parent service requirement contribution from invoked children.
|
|
5234
5257
|
*
|
|
@@ -5239,9 +5262,7 @@ export declare namespace Machine {
|
|
|
5239
5262
|
:
|
|
5240
5263
|
| MachineRuntimeRequirement
|
|
5241
5264
|
| InvokeServices<InvokeReturn<Config>>
|
|
5242
|
-
|
|
|
5243
|
-
InvokeOutcomeReturn<InvokeReturn<Config>>
|
|
5244
|
-
>
|
|
5265
|
+
| InvokeOutcomeServices<InvokeReturn<Config>>
|
|
5245
5266
|
/**
|
|
5246
5267
|
* Extracts the return value from an eventless transition.
|
|
5247
5268
|
*
|
|
@@ -5796,8 +5817,16 @@ export declare namespace Machine {
|
|
|
5796
5817
|
>
|
|
5797
5818
|
}
|
|
5798
5819
|
|
|
5799
|
-
/** Type evidence retained by
|
|
5800
|
-
export interface InvokeTyped<
|
|
5820
|
+
/** Type evidence retained by a completed state-owned invocation. */
|
|
5821
|
+
export interface InvokeTyped<
|
|
5822
|
+
Output,
|
|
5823
|
+
Error,
|
|
5824
|
+
Requirements,
|
|
5825
|
+
InitialError,
|
|
5826
|
+
Emits = never,
|
|
5827
|
+
ParentEvent = never,
|
|
5828
|
+
Outcomes = never
|
|
5829
|
+
> {
|
|
5801
5830
|
readonly [InvokeTypeId]: {
|
|
5802
5831
|
readonly output: Types.Covariant<Output>
|
|
5803
5832
|
readonly error: Types.Covariant<Error>
|
|
@@ -5805,10 +5834,11 @@ export declare namespace Machine {
|
|
|
5805
5834
|
readonly initialError: Types.Covariant<InitialError>
|
|
5806
5835
|
readonly emits: Types.Covariant<Emits>
|
|
5807
5836
|
readonly parentEvents: Types.Covariant<ParentEvent>
|
|
5837
|
+
readonly outcomes: Types.Covariant<Outcomes>
|
|
5808
5838
|
}
|
|
5809
5839
|
}
|
|
5810
5840
|
|
|
5811
|
-
|
|
5841
|
+
type StoredInvokeConfig<
|
|
5812
5842
|
States extends StateSchemas,
|
|
5813
5843
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5814
5844
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -5899,221 +5929,16 @@ export declare namespace Machine {
|
|
|
5899
5929
|
}
|
|
5900
5930
|
)
|
|
5901
5931
|
|
|
5902
|
-
|
|
5903
|
-
export type InvokeDefinition<
|
|
5904
|
-
States extends StateSchemas,
|
|
5905
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5906
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5907
|
-
StateId extends StateIdentifier<States>,
|
|
5908
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5909
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5910
|
-
> =
|
|
5911
|
-
| InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5912
|
-
| ReadonlyArray<InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
5913
|
-
|
|
5914
|
-
type TypedInvokeDefinition =
|
|
5915
|
-
| InvokeTyped<any, any, any, any, any, any>
|
|
5916
|
-
| ReadonlyArray<InvokeTyped<any, any, any, any, any, any>>
|
|
5917
|
-
|
|
5918
|
-
type InvokeHandlerRequirement<Value, Handler> = IsAny<Value> extends true ? { readonly handler: Handler }
|
|
5919
|
-
: [Value] extends [never] ? { readonly handler?: never }
|
|
5920
|
-
: { readonly handler: Handler }
|
|
5921
|
-
|
|
5922
|
-
export type InvokeDoneRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5923
|
-
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onDone: Required }
|
|
5924
|
-
: { readonly onDone?: never }
|
|
5925
|
-
: never
|
|
5926
|
-
|
|
5927
|
-
export type InvokeFailureRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5928
|
-
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onFailure: Required }
|
|
5929
|
-
: { readonly onFailure?: never }
|
|
5930
|
-
: never
|
|
5931
|
-
|
|
5932
|
-
export type InvokeElementRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5933
|
-
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onElement: Required }
|
|
5934
|
-
: { readonly onElement?: never }
|
|
5935
|
-
: never
|
|
5936
|
-
|
|
5937
|
-
export type TimerInvokeArgs<
|
|
5938
|
-
States extends StateSchemas,
|
|
5939
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5940
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5941
|
-
StateId extends StateIdentifier<States>,
|
|
5942
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5943
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5944
|
-
> = {
|
|
5945
|
-
readonly id: InvokeLifecycleId
|
|
5946
|
-
readonly after: InvokeSource<
|
|
5947
|
-
Duration.Input,
|
|
5948
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5949
|
-
>
|
|
5950
|
-
readonly effect?: never
|
|
5951
|
-
readonly stream?: never
|
|
5952
|
-
readonly logic?: never
|
|
5953
|
-
readonly child?: never
|
|
5954
|
-
readonly address?: never
|
|
5955
|
-
readonly onFailure?: never
|
|
5956
|
-
readonly onElement?: never
|
|
5957
|
-
readonly onSnapshot?: never
|
|
5958
|
-
readonly onDone: InvokeTransition<
|
|
5959
|
-
States,
|
|
5960
|
-
Events,
|
|
5961
|
-
Emits,
|
|
5962
|
-
StateId,
|
|
5963
|
-
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
5964
|
-
>
|
|
5965
|
-
}
|
|
5966
|
-
|
|
5967
|
-
export type LogicInvokeArgs<
|
|
5968
|
-
States extends StateSchemas,
|
|
5969
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5970
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5971
|
-
StateId extends StateIdentifier<States>,
|
|
5972
|
-
ChildState,
|
|
5973
|
-
ChildEvent,
|
|
5974
|
-
ChildError,
|
|
5975
|
-
ChildRequirements,
|
|
5976
|
-
ChildOutput,
|
|
5977
|
-
ChildInitialError,
|
|
5978
|
-
Address extends ChildAddress<never>,
|
|
5979
|
-
Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
5980
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5981
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5982
|
-
> =
|
|
5983
|
-
& {
|
|
5984
|
-
readonly id: InvokeLifecycleId
|
|
5985
|
-
readonly address: Address & ChildAddress.Compatibility<Address, ChildEvent>
|
|
5986
|
-
readonly logic: Source
|
|
5987
|
-
readonly effect?: never
|
|
5988
|
-
readonly stream?: never
|
|
5989
|
-
readonly after?: never
|
|
5990
|
-
readonly child?: never
|
|
5991
|
-
readonly onElement?: never
|
|
5992
|
-
readonly onSnapshot?: InvokeTransition<
|
|
5993
|
-
States,
|
|
5994
|
-
Events,
|
|
5995
|
-
Emits,
|
|
5996
|
-
StateId,
|
|
5997
|
-
InvokeSnapshotContext<
|
|
5998
|
-
States,
|
|
5999
|
-
Events,
|
|
6000
|
-
Emits,
|
|
6001
|
-
StateId,
|
|
6002
|
-
NoInfer<ChildState>,
|
|
6003
|
-
NoInfer<ChildError>,
|
|
6004
|
-
NoInfer<ChildOutput>,
|
|
6005
|
-
InputEvents,
|
|
6006
|
-
ParentEvents
|
|
6007
|
-
>
|
|
6008
|
-
>
|
|
6009
|
-
}
|
|
6010
|
-
& InvokeDoneRequirement<
|
|
6011
|
-
NoInfer<ChildOutput>,
|
|
6012
|
-
InvokeTransition<
|
|
6013
|
-
States,
|
|
6014
|
-
Events,
|
|
6015
|
-
Emits,
|
|
6016
|
-
StateId,
|
|
6017
|
-
InvokeDoneContext<States, Events, Emits, StateId, NoInfer<ChildOutput>, InputEvents, ParentEvents>
|
|
6018
|
-
>
|
|
6019
|
-
>
|
|
6020
|
-
& InvokeFailureRequirement<
|
|
6021
|
-
NoInfer<ChildError>,
|
|
6022
|
-
InvokeTransition<
|
|
6023
|
-
States,
|
|
6024
|
-
Events,
|
|
6025
|
-
Emits,
|
|
6026
|
-
StateId,
|
|
6027
|
-
InvokeFailureContext<States, Events, Emits, StateId, NoInfer<ChildError>, InputEvents, ParentEvents>
|
|
6028
|
-
>
|
|
6029
|
-
>
|
|
6030
|
-
|
|
6031
|
-
export type ChildInvokeArgs<
|
|
5932
|
+
type StoredInvokeDefinition<
|
|
6032
5933
|
States extends StateSchemas,
|
|
6033
5934
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
6034
5935
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6035
5936
|
StateId extends StateIdentifier<States>,
|
|
6036
|
-
ChildDefinition extends Machine.Any,
|
|
6037
|
-
Child extends ChildMachine<string, ChildDefinition>,
|
|
6038
5937
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6039
5938
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6040
5939
|
> =
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
& Child
|
|
6044
|
-
& (ChildDefinition extends EnsureExecutable<
|
|
6045
|
-
Machine.States<ChildDefinition>,
|
|
6046
|
-
Machine.UnhandledStates<ChildDefinition>,
|
|
6047
|
-
Machine.OutputStates<ChildDefinition>
|
|
6048
|
-
> ? unknown :
|
|
6049
|
-
never)
|
|
6050
|
-
readonly id?: never
|
|
6051
|
-
readonly address?: never
|
|
6052
|
-
readonly effect?: never
|
|
6053
|
-
readonly stream?: never
|
|
6054
|
-
readonly after?: never
|
|
6055
|
-
readonly logic?: never
|
|
6056
|
-
readonly onElement?: never
|
|
6057
|
-
readonly onSnapshot?: InvokeTransition<
|
|
6058
|
-
States,
|
|
6059
|
-
Events,
|
|
6060
|
-
Emits,
|
|
6061
|
-
StateId,
|
|
6062
|
-
InvokeSnapshotContext<
|
|
6063
|
-
States,
|
|
6064
|
-
Events,
|
|
6065
|
-
Emits,
|
|
6066
|
-
StateId,
|
|
6067
|
-
Snapshot<Machine.States<ChildDefinition>>,
|
|
6068
|
-
Error<ChildDefinition>,
|
|
6069
|
-
Output<ChildDefinition>,
|
|
6070
|
-
InputEvents,
|
|
6071
|
-
ParentEvents
|
|
6072
|
-
>
|
|
6073
|
-
>
|
|
6074
|
-
}
|
|
6075
|
-
& (Input<ChildDefinition> extends typeof Schema.Void ? { readonly input?: never } : {
|
|
6076
|
-
readonly input: InvokeSource<
|
|
6077
|
-
Input<ChildDefinition>["Type"],
|
|
6078
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6079
|
-
>
|
|
6080
|
-
})
|
|
6081
|
-
& InvokeDoneRequirement<
|
|
6082
|
-
Output<ChildDefinition>,
|
|
6083
|
-
InvokeTransition<
|
|
6084
|
-
States,
|
|
6085
|
-
Events,
|
|
6086
|
-
Emits,
|
|
6087
|
-
StateId,
|
|
6088
|
-
InvokeDoneContext<
|
|
6089
|
-
States,
|
|
6090
|
-
Events,
|
|
6091
|
-
Emits,
|
|
6092
|
-
StateId,
|
|
6093
|
-
Output<ChildDefinition>,
|
|
6094
|
-
InputEvents,
|
|
6095
|
-
ParentEvents
|
|
6096
|
-
>
|
|
6097
|
-
>
|
|
6098
|
-
>
|
|
6099
|
-
& InvokeFailureRequirement<
|
|
6100
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
6101
|
-
InvokeTransition<
|
|
6102
|
-
States,
|
|
6103
|
-
Events,
|
|
6104
|
-
Emits,
|
|
6105
|
-
StateId,
|
|
6106
|
-
InvokeFailureContext<
|
|
6107
|
-
States,
|
|
6108
|
-
Events,
|
|
6109
|
-
Emits,
|
|
6110
|
-
StateId,
|
|
6111
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
6112
|
-
InputEvents,
|
|
6113
|
-
ParentEvents
|
|
6114
|
-
>
|
|
6115
|
-
>
|
|
6116
|
-
>
|
|
5940
|
+
| StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5941
|
+
| ReadonlyArray<StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
6117
5942
|
|
|
6118
5943
|
type LogicInitialEffectOf<Value> = Value extends { readonly initial: infer Initial } ?
|
|
6119
5944
|
Initial extends (...args: ReadonlyArray<any>) => infer Result ? Result : never
|
|
@@ -6134,253 +5959,512 @@ export declare namespace Machine {
|
|
|
6134
5959
|
export type LogicOutputOf<Value> = Effect.Success<LogicRunEffectOf<Value>>
|
|
6135
5960
|
export type LogicInitialErrorOf<Value> = Effect.Error<LogicInitialEffectOf<Value>>
|
|
6136
5961
|
|
|
6137
|
-
type
|
|
5962
|
+
type RequiredInvokeChannel<Value, Channel extends string> = IsAny<Value> extends true ? Channel
|
|
5963
|
+
: [Value] extends [never] ? never
|
|
5964
|
+
: Channel
|
|
5965
|
+
|
|
5966
|
+
type InvokeBuilderResult<
|
|
6138
5967
|
States extends StateSchemas,
|
|
6139
5968
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
6140
5969
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6141
5970
|
StateId extends StateIdentifier<States>,
|
|
6142
5971
|
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6143
5972
|
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
5973
|
+
Output,
|
|
5974
|
+
Error,
|
|
5975
|
+
Requirements,
|
|
5976
|
+
InitialError,
|
|
5977
|
+
ChildEmits,
|
|
5978
|
+
ChildParentEvent,
|
|
5979
|
+
Outcomes
|
|
5980
|
+
> =
|
|
5981
|
+
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5982
|
+
& InvokeTyped<Output, Error, Requirements, InitialError, ChildEmits, ChildParentEvent, Outcomes>
|
|
5983
|
+
& { readonly [InvokeBuilderTypeId]: true }
|
|
5984
|
+
|
|
5985
|
+
type InvokeBuilder<
|
|
5986
|
+
States extends StateSchemas,
|
|
5987
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5988
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5989
|
+
StateId extends StateIdentifier<States>,
|
|
5990
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
5991
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
5992
|
+
Output,
|
|
5993
|
+
Error,
|
|
5994
|
+
Requirements,
|
|
5995
|
+
InitialError,
|
|
5996
|
+
ChildEmits,
|
|
5997
|
+
ChildParentEvent,
|
|
5998
|
+
Element,
|
|
5999
|
+
Pending extends string,
|
|
6000
|
+
SnapshotHandler,
|
|
6001
|
+
Outcomes = never
|
|
6002
|
+
> =
|
|
6003
|
+
& ([Pending] extends [never] ? InvokeBuilderResult<
|
|
6004
|
+
States,
|
|
6005
|
+
Events,
|
|
6006
|
+
Emits,
|
|
6007
|
+
StateId,
|
|
6008
|
+
InputEvents,
|
|
6009
|
+
ParentEvents,
|
|
6010
|
+
Output,
|
|
6011
|
+
Error,
|
|
6012
|
+
Requirements,
|
|
6013
|
+
InitialError,
|
|
6014
|
+
ChildEmits,
|
|
6015
|
+
ChildParentEvent,
|
|
6016
|
+
Outcomes
|
|
6017
|
+
>
|
|
6018
|
+
: {})
|
|
6019
|
+
& ("done" extends Pending ? {
|
|
6020
|
+
readonly onDone: <
|
|
6021
|
+
const Handler extends InvokeTransition<
|
|
6022
|
+
States,
|
|
6023
|
+
Events,
|
|
6024
|
+
Emits,
|
|
6025
|
+
StateId,
|
|
6026
|
+
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
6190
6027
|
>
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
Emits,
|
|
6196
|
-
StateId,
|
|
6197
|
-
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
6198
|
-
>
|
|
6199
|
-
}
|
|
6200
|
-
& InvokeFailureRequirement<
|
|
6201
|
-
Stream.Error<SourceStream>,
|
|
6202
|
-
InvokeTransition<
|
|
6028
|
+
>(
|
|
6029
|
+
handler:
|
|
6030
|
+
& Handler
|
|
6031
|
+
& InvokeTransition<
|
|
6203
6032
|
States,
|
|
6204
6033
|
Events,
|
|
6205
6034
|
Emits,
|
|
6206
6035
|
StateId,
|
|
6207
|
-
|
|
6208
|
-
States,
|
|
6209
|
-
Events,
|
|
6210
|
-
Emits,
|
|
6211
|
-
StateId,
|
|
6212
|
-
Stream.Error<SourceStream>,
|
|
6213
|
-
InputEvents,
|
|
6214
|
-
ParentEvents
|
|
6215
|
-
>
|
|
6036
|
+
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
6216
6037
|
>
|
|
6217
|
-
|
|
6218
|
-
& { readonly onSnapshot?: never }
|
|
6219
|
-
: never
|
|
6220
|
-
: Raw extends { readonly after: unknown } ? {
|
|
6221
|
-
readonly onDone: InvokeTransition<
|
|
6038
|
+
) => InvokeBuilder<
|
|
6222
6039
|
States,
|
|
6223
6040
|
Events,
|
|
6224
6041
|
Emits,
|
|
6225
6042
|
StateId,
|
|
6226
|
-
|
|
6043
|
+
InputEvents,
|
|
6044
|
+
ParentEvents,
|
|
6045
|
+
Output,
|
|
6046
|
+
Error,
|
|
6047
|
+
Requirements,
|
|
6048
|
+
InitialError,
|
|
6049
|
+
ChildEmits,
|
|
6050
|
+
ChildParentEvent,
|
|
6051
|
+
Element,
|
|
6052
|
+
Exclude<Pending, "done">,
|
|
6053
|
+
SnapshotHandler,
|
|
6054
|
+
Outcomes | Handler
|
|
6227
6055
|
>
|
|
6228
|
-
readonly onFailure?: never
|
|
6229
|
-
readonly onSnapshot?: never
|
|
6230
6056
|
}
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
InvokeDoneContext<States, Events, Emits, StateId, InvokeOutput<Raw>, InputEvents, ParentEvents>
|
|
6241
|
-
>
|
|
6242
|
-
>
|
|
6243
|
-
& InvokeFailureRequirement<
|
|
6244
|
-
InvokeRuntimeError<Raw>,
|
|
6245
|
-
InvokeTransition<
|
|
6246
|
-
States,
|
|
6247
|
-
Events,
|
|
6248
|
-
Emits,
|
|
6249
|
-
StateId,
|
|
6250
|
-
InvokeFailureContext<
|
|
6251
|
-
States,
|
|
6252
|
-
Events,
|
|
6253
|
-
Emits,
|
|
6254
|
-
StateId,
|
|
6255
|
-
InvokeRuntimeError<Raw>,
|
|
6256
|
-
InputEvents,
|
|
6257
|
-
ParentEvents
|
|
6258
|
-
>
|
|
6259
|
-
>
|
|
6260
|
-
>
|
|
6261
|
-
& {
|
|
6262
|
-
readonly address:
|
|
6263
|
-
& ChildAddress<never>
|
|
6264
|
-
& ChildAddress.Compatibility<
|
|
6265
|
-
Address,
|
|
6266
|
-
ChildLogic extends Logic<any, infer ChildEvent, any, any, any, any> ? ChildEvent : never
|
|
6267
|
-
>
|
|
6268
|
-
readonly onSnapshot?: InvokeTransition<
|
|
6269
|
-
States,
|
|
6270
|
-
Events,
|
|
6271
|
-
Emits,
|
|
6272
|
-
StateId,
|
|
6273
|
-
InvokeSnapshotContext<
|
|
6274
|
-
States,
|
|
6275
|
-
Events,
|
|
6276
|
-
Emits,
|
|
6277
|
-
StateId,
|
|
6278
|
-
ChildLogic extends Logic<infer ChildState, any, any, any, any, any> ? ChildState : never,
|
|
6279
|
-
InvokeRuntimeError<Raw>,
|
|
6280
|
-
InvokeOutput<Raw>,
|
|
6281
|
-
InputEvents,
|
|
6282
|
-
ParentEvents
|
|
6283
|
-
>
|
|
6284
|
-
>
|
|
6285
|
-
}
|
|
6286
|
-
: never
|
|
6287
|
-
: Raw extends { readonly child: infer Child extends ChildMachine<string, infer ChildDefinition> } ?
|
|
6288
|
-
ChildMachineLogic<Child> extends infer ChildLogic extends Logic<any, any, any, any, any, any> ?
|
|
6289
|
-
& InvokeDoneRequirement<
|
|
6290
|
-
Output<ChildDefinition>,
|
|
6291
|
-
InvokeTransition<
|
|
6292
|
-
States,
|
|
6293
|
-
Events,
|
|
6294
|
-
Emits,
|
|
6295
|
-
StateId,
|
|
6296
|
-
InvokeDoneContext<
|
|
6297
|
-
States,
|
|
6298
|
-
Events,
|
|
6299
|
-
Emits,
|
|
6300
|
-
StateId,
|
|
6301
|
-
Output<ChildDefinition>,
|
|
6302
|
-
InputEvents,
|
|
6303
|
-
ParentEvents
|
|
6304
|
-
>
|
|
6305
|
-
>
|
|
6057
|
+
: {})
|
|
6058
|
+
& ("failure" extends Pending ? {
|
|
6059
|
+
readonly onFailure: <
|
|
6060
|
+
const Handler extends InvokeTransition<
|
|
6061
|
+
States,
|
|
6062
|
+
Events,
|
|
6063
|
+
Emits,
|
|
6064
|
+
StateId,
|
|
6065
|
+
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
6306
6066
|
>
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6067
|
+
>(
|
|
6068
|
+
handler:
|
|
6069
|
+
& Handler
|
|
6070
|
+
& InvokeTransition<
|
|
6310
6071
|
States,
|
|
6311
6072
|
Events,
|
|
6312
6073
|
Emits,
|
|
6313
6074
|
StateId,
|
|
6314
|
-
InvokeFailureContext<
|
|
6315
|
-
States,
|
|
6316
|
-
Events,
|
|
6317
|
-
Emits,
|
|
6318
|
-
StateId,
|
|
6319
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
6320
|
-
InputEvents,
|
|
6321
|
-
ParentEvents
|
|
6322
|
-
>
|
|
6075
|
+
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
6323
6076
|
>
|
|
6077
|
+
) => InvokeBuilder<
|
|
6078
|
+
States,
|
|
6079
|
+
Events,
|
|
6080
|
+
Emits,
|
|
6081
|
+
StateId,
|
|
6082
|
+
InputEvents,
|
|
6083
|
+
ParentEvents,
|
|
6084
|
+
Output,
|
|
6085
|
+
Error,
|
|
6086
|
+
Requirements,
|
|
6087
|
+
InitialError,
|
|
6088
|
+
ChildEmits,
|
|
6089
|
+
ChildParentEvent,
|
|
6090
|
+
Element,
|
|
6091
|
+
Exclude<Pending, "failure">,
|
|
6092
|
+
SnapshotHandler,
|
|
6093
|
+
Outcomes | Handler
|
|
6094
|
+
>
|
|
6095
|
+
}
|
|
6096
|
+
: {})
|
|
6097
|
+
& ("element" extends Pending ? {
|
|
6098
|
+
readonly onElement: <
|
|
6099
|
+
const Handler extends InvokeTransition<
|
|
6100
|
+
States,
|
|
6101
|
+
Events,
|
|
6102
|
+
Emits,
|
|
6103
|
+
StateId,
|
|
6104
|
+
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
6324
6105
|
>
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
>
|
|
6330
|
-
})
|
|
6331
|
-
& {
|
|
6332
|
-
readonly onSnapshot?: InvokeTransition<
|
|
6106
|
+
>(
|
|
6107
|
+
handler:
|
|
6108
|
+
& Handler
|
|
6109
|
+
& InvokeTransition<
|
|
6333
6110
|
States,
|
|
6334
6111
|
Events,
|
|
6335
6112
|
Emits,
|
|
6336
6113
|
StateId,
|
|
6337
|
-
|
|
6338
|
-
States,
|
|
6339
|
-
Events,
|
|
6340
|
-
Emits,
|
|
6341
|
-
StateId,
|
|
6342
|
-
Snapshot<Machine.States<ChildDefinition>>,
|
|
6343
|
-
Error<ChildDefinition>,
|
|
6344
|
-
Output<ChildDefinition>,
|
|
6345
|
-
InputEvents,
|
|
6346
|
-
ParentEvents
|
|
6347
|
-
>
|
|
6114
|
+
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
6348
6115
|
>
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6116
|
+
) => InvokeBuilder<
|
|
6117
|
+
States,
|
|
6118
|
+
Events,
|
|
6119
|
+
Emits,
|
|
6120
|
+
StateId,
|
|
6121
|
+
InputEvents,
|
|
6122
|
+
ParentEvents,
|
|
6123
|
+
Output,
|
|
6124
|
+
Error,
|
|
6125
|
+
Requirements,
|
|
6126
|
+
InitialError,
|
|
6127
|
+
ChildEmits,
|
|
6128
|
+
ChildParentEvent,
|
|
6129
|
+
Element,
|
|
6130
|
+
Exclude<Pending, "element">,
|
|
6131
|
+
SnapshotHandler,
|
|
6132
|
+
Outcomes | Handler
|
|
6133
|
+
>
|
|
6134
|
+
}
|
|
6135
|
+
: {})
|
|
6136
|
+
& ([SnapshotHandler] extends [never] ? {} : {
|
|
6137
|
+
readonly onSnapshot: <const Handler extends SnapshotHandler>(handler: Handler & SnapshotHandler) => InvokeBuilder<
|
|
6363
6138
|
States,
|
|
6364
6139
|
Events,
|
|
6365
6140
|
Emits,
|
|
6366
6141
|
StateId,
|
|
6367
6142
|
InputEvents,
|
|
6368
6143
|
ParentEvents,
|
|
6369
|
-
|
|
6144
|
+
Output,
|
|
6145
|
+
Error,
|
|
6146
|
+
Requirements,
|
|
6147
|
+
InitialError,
|
|
6148
|
+
ChildEmits,
|
|
6149
|
+
ChildParentEvent,
|
|
6150
|
+
Element,
|
|
6151
|
+
Pending,
|
|
6152
|
+
never,
|
|
6153
|
+
Outcomes | Handler
|
|
6370
6154
|
>
|
|
6371
|
-
}
|
|
6372
|
-
: ContextualInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents, Raw>
|
|
6155
|
+
})
|
|
6373
6156
|
|
|
6374
|
-
type
|
|
6157
|
+
type EffectInvokeBuilder<
|
|
6375
6158
|
States extends StateSchemas,
|
|
6376
6159
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
6160
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6377
6161
|
StateId extends StateIdentifier<States>,
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6162
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6163
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6164
|
+
Source extends (...args: ReadonlyArray<any>) => Effect.Effect<any, any, any>
|
|
6165
|
+
> = InvokeBuilder<
|
|
6166
|
+
States,
|
|
6167
|
+
Events,
|
|
6168
|
+
Emits,
|
|
6169
|
+
StateId,
|
|
6170
|
+
InputEvents,
|
|
6171
|
+
ParentEvents,
|
|
6172
|
+
Effect.Success<ReturnType<Source>>,
|
|
6173
|
+
Effect.Error<ReturnType<Source>>,
|
|
6174
|
+
Effect.Services<ReturnType<Source>>,
|
|
6175
|
+
never,
|
|
6176
|
+
never,
|
|
6177
|
+
never,
|
|
6178
|
+
never,
|
|
6179
|
+
| RequiredInvokeChannel<Effect.Success<ReturnType<Source>>, "done">
|
|
6180
|
+
| RequiredInvokeChannel<Effect.Error<ReturnType<Source>>, "failure">,
|
|
6181
|
+
never
|
|
6182
|
+
>
|
|
6183
|
+
|
|
6184
|
+
type StreamInvokeBuilder<
|
|
6185
|
+
States extends StateSchemas,
|
|
6186
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6187
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6188
|
+
StateId extends StateIdentifier<States>,
|
|
6189
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6190
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6191
|
+
Source extends (...args: ReadonlyArray<any>) => Stream.Stream<any, any, any>
|
|
6192
|
+
> = InvokeBuilder<
|
|
6193
|
+
States,
|
|
6194
|
+
Events,
|
|
6195
|
+
Emits,
|
|
6196
|
+
StateId,
|
|
6197
|
+
InputEvents,
|
|
6198
|
+
ParentEvents,
|
|
6199
|
+
void,
|
|
6200
|
+
Stream.Error<ReturnType<Source>>,
|
|
6201
|
+
Stream.Services<ReturnType<Source>>,
|
|
6202
|
+
never,
|
|
6203
|
+
never,
|
|
6204
|
+
never,
|
|
6205
|
+
Stream.Success<ReturnType<Source>>,
|
|
6206
|
+
| "done"
|
|
6207
|
+
| RequiredInvokeChannel<Stream.Success<ReturnType<Source>>, "element">
|
|
6208
|
+
| RequiredInvokeChannel<Stream.Error<ReturnType<Source>>, "failure">,
|
|
6209
|
+
never
|
|
6210
|
+
>
|
|
6211
|
+
|
|
6212
|
+
type LogicInvokeBuilder<
|
|
6213
|
+
States extends StateSchemas,
|
|
6214
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6215
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6216
|
+
StateId extends StateIdentifier<States>,
|
|
6217
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6218
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6219
|
+
ChildLogic
|
|
6220
|
+
> = InvokeBuilder<
|
|
6221
|
+
States,
|
|
6222
|
+
Events,
|
|
6223
|
+
Emits,
|
|
6224
|
+
StateId,
|
|
6225
|
+
InputEvents,
|
|
6226
|
+
ParentEvents,
|
|
6227
|
+
LogicOutputOf<ChildLogic>,
|
|
6228
|
+
LogicErrorOf<ChildLogic>,
|
|
6229
|
+
LogicServicesOf<ChildLogic>,
|
|
6230
|
+
LogicInitialErrorOf<ChildLogic>,
|
|
6231
|
+
never,
|
|
6232
|
+
never,
|
|
6233
|
+
never,
|
|
6234
|
+
| RequiredInvokeChannel<LogicOutputOf<ChildLogic>, "done">
|
|
6235
|
+
| RequiredInvokeChannel<LogicErrorOf<ChildLogic>, "failure">,
|
|
6236
|
+
InvokeTransition<
|
|
6237
|
+
States,
|
|
6238
|
+
Events,
|
|
6239
|
+
Emits,
|
|
6240
|
+
StateId,
|
|
6241
|
+
InvokeSnapshotContext<
|
|
6242
|
+
States,
|
|
6243
|
+
Events,
|
|
6244
|
+
Emits,
|
|
6245
|
+
StateId,
|
|
6246
|
+
LogicStateOf<ChildLogic>,
|
|
6247
|
+
LogicErrorOf<ChildLogic>,
|
|
6248
|
+
LogicOutputOf<ChildLogic>,
|
|
6249
|
+
InputEvents,
|
|
6250
|
+
ParentEvents
|
|
6251
|
+
>
|
|
6252
|
+
>
|
|
6253
|
+
>
|
|
6254
|
+
|
|
6255
|
+
type ChildInvokeBuilder<
|
|
6256
|
+
States extends StateSchemas,
|
|
6257
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6258
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6259
|
+
StateId extends StateIdentifier<States>,
|
|
6260
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6261
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6262
|
+
Child extends ChildMachine.Any,
|
|
6263
|
+
ChildDefinition extends Machine.Any = Child["machine"]
|
|
6264
|
+
> = InvokeBuilder<
|
|
6265
|
+
States,
|
|
6266
|
+
Events,
|
|
6267
|
+
Emits,
|
|
6268
|
+
StateId,
|
|
6269
|
+
InputEvents,
|
|
6270
|
+
ParentEvents,
|
|
6271
|
+
Output<ChildDefinition>,
|
|
6272
|
+
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
6273
|
+
Services<ChildDefinition>,
|
|
6274
|
+
InitialError<ChildDefinition>,
|
|
6275
|
+
Emit<ChildDefinition>,
|
|
6276
|
+
EventOf<Machine.ParentEvents<ChildDefinition>>,
|
|
6277
|
+
never,
|
|
6278
|
+
| RequiredInvokeChannel<Output<ChildDefinition>, "done">
|
|
6279
|
+
| RequiredInvokeChannel<Error<ChildDefinition> | ActionError<Services<ChildDefinition>>, "failure">,
|
|
6280
|
+
InvokeTransition<
|
|
6281
|
+
States,
|
|
6282
|
+
Events,
|
|
6283
|
+
Emits,
|
|
6284
|
+
StateId,
|
|
6285
|
+
InvokeSnapshotContext<
|
|
6286
|
+
States,
|
|
6287
|
+
Events,
|
|
6288
|
+
Emits,
|
|
6289
|
+
StateId,
|
|
6290
|
+
Snapshot<Machine.States<ChildDefinition>>,
|
|
6291
|
+
Error<ChildDefinition>,
|
|
6292
|
+
Output<ChildDefinition>,
|
|
6293
|
+
InputEvents,
|
|
6294
|
+
ParentEvents
|
|
6295
|
+
>
|
|
6296
|
+
>
|
|
6297
|
+
>
|
|
6298
|
+
|
|
6299
|
+
/**
|
|
6300
|
+
* Selects state-owned work and begins its lifecycle-handler chain.
|
|
6301
|
+
*
|
|
6302
|
+
* Each source exposes exactly the lifecycle methods that it can produce. A
|
|
6303
|
+
* chain becomes returnable from `invoke` only after every reachable required
|
|
6304
|
+
* channel has been handled.
|
|
6305
|
+
*
|
|
6306
|
+
* @category models
|
|
6307
|
+
* @since 0.18.0
|
|
6308
|
+
*/
|
|
6309
|
+
export interface InvokeSelector<
|
|
6310
|
+
States extends StateSchemas,
|
|
6311
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6312
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6313
|
+
StateId extends StateIdentifier<States>,
|
|
6314
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6315
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6316
|
+
> {
|
|
6317
|
+
/** Starts a fresh Effect each time the owning state is entered. */
|
|
6318
|
+
readonly effect: <
|
|
6319
|
+
const Source extends (
|
|
6320
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6321
|
+
) => Effect.Effect<unknown, unknown, unknown>
|
|
6322
|
+
>(
|
|
6323
|
+
id: InvokeLifecycleId,
|
|
6324
|
+
source: Source
|
|
6325
|
+
) => EffectInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
6326
|
+
|
|
6327
|
+
/** Starts a fresh, backpressured Stream each time the owning state is entered. */
|
|
6328
|
+
readonly stream: <
|
|
6329
|
+
const Source extends (
|
|
6330
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6331
|
+
) => Stream.Stream<unknown, unknown, any>
|
|
6332
|
+
>(
|
|
6333
|
+
id: InvokeLifecycleId,
|
|
6334
|
+
source: Source
|
|
6335
|
+
) => StreamInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
6336
|
+
|
|
6337
|
+
/** Starts a cancellable state-scoped timer. */
|
|
6338
|
+
readonly timer: (
|
|
6339
|
+
id: InvokeLifecycleId,
|
|
6340
|
+
duration: InvokeSource<
|
|
6341
|
+
Duration.Input,
|
|
6342
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6343
|
+
>
|
|
6344
|
+
) => InvokeBuilder<
|
|
6345
|
+
States,
|
|
6346
|
+
Events,
|
|
6347
|
+
Emits,
|
|
6348
|
+
StateId,
|
|
6349
|
+
InputEvents,
|
|
6350
|
+
ParentEvents,
|
|
6351
|
+
void,
|
|
6352
|
+
never,
|
|
6353
|
+
never,
|
|
6354
|
+
never,
|
|
6355
|
+
never,
|
|
6356
|
+
never,
|
|
6357
|
+
never,
|
|
6358
|
+
"done",
|
|
6359
|
+
never
|
|
6360
|
+
>
|
|
6361
|
+
|
|
6362
|
+
/** Starts reusable process logic at a typed parent-local address. */
|
|
6363
|
+
readonly logic: {
|
|
6364
|
+
<
|
|
6365
|
+
const Source extends (
|
|
6366
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6367
|
+
) => unknown,
|
|
6368
|
+
Address extends ChildAddress<never>
|
|
6369
|
+
>(
|
|
6370
|
+
id: InvokeLifecycleId,
|
|
6371
|
+
options: {
|
|
6372
|
+
readonly address:
|
|
6373
|
+
& Address
|
|
6374
|
+
& ChildAddress.Compatibility<Address, LogicEventOf<ReturnType<NoInfer<Source>>>>
|
|
6375
|
+
readonly logic: Source
|
|
6376
|
+
},
|
|
6377
|
+
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
6378
|
+
"logic factory must return Machine.Logic"
|
|
6379
|
+
]
|
|
6380
|
+
): LogicInvokeBuilder<
|
|
6381
|
+
States,
|
|
6382
|
+
Events,
|
|
6383
|
+
Emits,
|
|
6384
|
+
StateId,
|
|
6385
|
+
InputEvents,
|
|
6386
|
+
ParentEvents,
|
|
6387
|
+
ReturnType<Source>
|
|
6388
|
+
>
|
|
6389
|
+
<const Source, Address extends ChildAddress<never>>(
|
|
6390
|
+
id: InvokeLifecycleId,
|
|
6391
|
+
options: {
|
|
6392
|
+
readonly address: Address & ChildAddress.Compatibility<Address, LogicEventOf<NoInfer<Source>>>
|
|
6393
|
+
readonly logic: Source
|
|
6394
|
+
},
|
|
6395
|
+
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
6396
|
+
"logic must implement Machine.Logic"
|
|
6397
|
+
]
|
|
6398
|
+
): LogicInvokeBuilder<
|
|
6399
|
+
States,
|
|
6400
|
+
Events,
|
|
6401
|
+
Emits,
|
|
6402
|
+
StateId,
|
|
6403
|
+
InputEvents,
|
|
6404
|
+
ParentEvents,
|
|
6405
|
+
Source
|
|
6406
|
+
>
|
|
6407
|
+
}
|
|
6408
|
+
|
|
6409
|
+
/** Starts a complete child statechart represented by a reusable descriptor. */
|
|
6410
|
+
readonly child: <const Child extends ChildMachine.Any>(
|
|
6411
|
+
child:
|
|
6412
|
+
& Child
|
|
6413
|
+
& (Child["machine"] extends EnsureExecutable<
|
|
6414
|
+
Machine.States<Child["machine"]>,
|
|
6415
|
+
Machine.UnhandledStates<Child["machine"]>,
|
|
6416
|
+
Machine.OutputStates<Child["machine"]>
|
|
6417
|
+
> ? unknown
|
|
6418
|
+
: never),
|
|
6419
|
+
...options: InputSchema<Child["machine"]> extends typeof Schema.Void ? [options?: { readonly input?: never }]
|
|
6420
|
+
: [options: {
|
|
6421
|
+
readonly input: InvokeSource<
|
|
6422
|
+
Input<Child["machine"]>,
|
|
6423
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6424
|
+
>
|
|
6425
|
+
}]
|
|
6426
|
+
) => ChildInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Child>
|
|
6427
|
+
}
|
|
6428
|
+
|
|
6429
|
+
/**
|
|
6430
|
+
* Inline invocation declaration accepted by an active state handler.
|
|
6431
|
+
*
|
|
6432
|
+
* Return one completed source chain or an array of completed chains. Source
|
|
6433
|
+
* computations and child descriptors may be extracted, but the chain stays
|
|
6434
|
+
* local to preserve the owning state and machine protocols.
|
|
6435
|
+
*
|
|
6436
|
+
* @category models
|
|
6437
|
+
* @since 0.18.0
|
|
6438
|
+
*/
|
|
6439
|
+
export type InvokeBuilderInput<
|
|
6440
|
+
States extends StateSchemas,
|
|
6441
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6442
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6443
|
+
StateId extends StateIdentifier<States>,
|
|
6444
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6445
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6446
|
+
> = (
|
|
6447
|
+
from: InvokeSelector<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6448
|
+
) =>
|
|
6449
|
+
| (InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
6450
|
+
readonly [InvokeBuilderTypeId]: true
|
|
6451
|
+
})
|
|
6452
|
+
| ReadonlyArray<
|
|
6453
|
+
InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
6454
|
+
readonly [InvokeBuilderTypeId]: true
|
|
6455
|
+
}
|
|
6456
|
+
>
|
|
6457
|
+
|
|
6458
|
+
type OutputHandlerConfig<
|
|
6459
|
+
States extends StateSchemas,
|
|
6460
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6461
|
+
StateId extends StateIdentifier<States>,
|
|
6462
|
+
Context
|
|
6463
|
+
> = NodeByIdentifier<States, StateId> extends { readonly output: Schema.Top } ? {
|
|
6464
|
+
readonly output: (context: Context) => OutputByIdentifier<States, StateId>
|
|
6465
|
+
}
|
|
6466
|
+
: {
|
|
6467
|
+
readonly output?: never
|
|
6384
6468
|
}
|
|
6385
6469
|
|
|
6386
6470
|
type ActiveOutputHandlerConfig<
|
|
@@ -6421,9 +6505,7 @@ export declare namespace Machine {
|
|
|
6421
6505
|
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
6422
6506
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
6423
6507
|
) => StateActionResult<any, any>
|
|
6424
|
-
readonly invoke?:
|
|
6425
|
-
| InvokeDefinition<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6426
|
-
| TypedInvokeDefinition
|
|
6508
|
+
readonly invoke?: InvokeBuilderInput<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6427
6509
|
readonly always?: TransitionConfig<
|
|
6428
6510
|
States,
|
|
6429
6511
|
Events,
|
|
@@ -6727,55 +6809,6 @@ export declare namespace Machine {
|
|
|
6727
6809
|
: Path extends keyof Config ? Config[Path]
|
|
6728
6810
|
: never
|
|
6729
6811
|
|
|
6730
|
-
type HandlerInvokeContextAtPath<
|
|
6731
|
-
AllStates extends StateSchemas,
|
|
6732
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6733
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6734
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6735
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6736
|
-
Config,
|
|
6737
|
-
StateId extends StateNodeIdentifier<AllStates>,
|
|
6738
|
-
NodeConfig = HandlerConfigAtPath<Config, StateId>
|
|
6739
|
-
> = StateId extends StateIdentifier<AllStates> ?
|
|
6740
|
-
NodeConfig extends { readonly invoke: infer Invoke } ? HandlerValidationAtPath<
|
|
6741
|
-
StateId,
|
|
6742
|
-
{
|
|
6743
|
-
readonly invoke: ContextualInvokeDefinition<
|
|
6744
|
-
AllStates,
|
|
6745
|
-
Events,
|
|
6746
|
-
Emits,
|
|
6747
|
-
StateId,
|
|
6748
|
-
InputEvents,
|
|
6749
|
-
ParentEvents,
|
|
6750
|
-
Invoke
|
|
6751
|
-
>
|
|
6752
|
-
}
|
|
6753
|
-
>
|
|
6754
|
-
: unknown
|
|
6755
|
-
: unknown
|
|
6756
|
-
|
|
6757
|
-
type HandlerInvokeContexts<
|
|
6758
|
-
AllStates extends StateSchemas,
|
|
6759
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6760
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6761
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6762
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6763
|
-
Config
|
|
6764
|
-
> = Types.UnionToIntersection<
|
|
6765
|
-
StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ?
|
|
6766
|
-
StateId extends StateNodeIdentifier<AllStates> ? HandlerInvokeContextAtPath<
|
|
6767
|
-
AllStates,
|
|
6768
|
-
Events,
|
|
6769
|
-
InputEvents,
|
|
6770
|
-
Emits,
|
|
6771
|
-
ParentEvents,
|
|
6772
|
-
Config,
|
|
6773
|
-
StateId
|
|
6774
|
-
>
|
|
6775
|
-
: never
|
|
6776
|
-
: never
|
|
6777
|
-
>
|
|
6778
|
-
|
|
6779
6812
|
// Rebuild the public nested handler shape so branded validation errors stay
|
|
6780
6813
|
// attached to the exact property that introduced them.
|
|
6781
6814
|
type HandlerValidationAtPath<Path extends string, Validation> = Path extends `${infer Head}.${infer Rest}` ? {
|
|
@@ -7375,7 +7408,6 @@ export declare namespace Machine {
|
|
|
7375
7408
|
>(
|
|
7376
7409
|
config:
|
|
7377
7410
|
& Config
|
|
7378
|
-
& HandlerInvokeContexts<States, Events, InputEvents, Emits, ParentEvents, NoInfer<Config>>
|
|
7379
7411
|
& HandlerTreeValidation<
|
|
7380
7412
|
States,
|
|
7381
7413
|
Events,
|
|
@@ -7474,7 +7506,7 @@ export declare namespace Machine {
|
|
|
7474
7506
|
context: StateActionContext<States, Events, Emits, StateId>,
|
|
7475
7507
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
7476
7508
|
) => StateActionResult<E, R>
|
|
7477
|
-
readonly invoke?:
|
|
7509
|
+
readonly invoke?: StoredInvokeDefinition<States, Events, Emits, StateId>
|
|
7478
7510
|
readonly always?: TransitionConfig<
|
|
7479
7511
|
States,
|
|
7480
7512
|
Events,
|
|
@@ -7522,15 +7554,49 @@ export declare namespace Machine {
|
|
|
7522
7554
|
>
|
|
7523
7555
|
}
|
|
7524
7556
|
|
|
7557
|
+
type StateSource = Machine.DefinedStates<any> | Machine.Any
|
|
7558
|
+
|
|
7559
|
+
type StateSchemasOf<Source extends StateSource> = Source extends Machine.DefinedStates<infer States> ? States
|
|
7560
|
+
: Source extends Machine.Any ? Machine.States<Source>
|
|
7561
|
+
: never
|
|
7562
|
+
|
|
7525
7563
|
/**
|
|
7526
|
-
* Extracts the complete logical snapshot represented by a state definition
|
|
7564
|
+
* Extracts the complete logical snapshot represented by a state definition or
|
|
7565
|
+
* machine.
|
|
7527
7566
|
*
|
|
7528
7567
|
* @category utility types
|
|
7529
7568
|
* @since 0.15.0
|
|
7530
7569
|
*/
|
|
7531
|
-
export type Snapshot<
|
|
7532
|
-
|
|
7533
|
-
|
|
7570
|
+
export type Snapshot<Source extends StateSource> = Machine.Snapshot<StateSchemasOf<Source>>
|
|
7571
|
+
|
|
7572
|
+
/**
|
|
7573
|
+
* Extracts the decoded value owned by a schema-backed state path.
|
|
7574
|
+
*
|
|
7575
|
+
* The source may be the object returned by {@link states} or a machine
|
|
7576
|
+
* definition. Control-only state paths are intentionally excluded.
|
|
7577
|
+
*
|
|
7578
|
+
* @category utility types
|
|
7579
|
+
* @since 0.18.0
|
|
7580
|
+
*/
|
|
7581
|
+
export type Value<
|
|
7582
|
+
Source extends StateSource,
|
|
7583
|
+
Path extends Machine.ValuedStateIdentifier<StateSchemasOf<Source>>
|
|
7584
|
+
> = Machine.StateByIdentifier<StateSchemasOf<Source>, Path>
|
|
7585
|
+
|
|
7586
|
+
/**
|
|
7587
|
+
* Extracts the logical snapshot rooted at a state path.
|
|
7588
|
+
*
|
|
7589
|
+
* The source may be the object returned by {@link states} or a machine
|
|
7590
|
+
* definition. This is the type-level counterpart of
|
|
7591
|
+
* `DefinedStates.getSnapshot`.
|
|
7592
|
+
*
|
|
7593
|
+
* @category utility types
|
|
7594
|
+
* @since 0.18.0
|
|
7595
|
+
*/
|
|
7596
|
+
export type SnapshotAt<
|
|
7597
|
+
Source extends StateSource,
|
|
7598
|
+
Path extends Machine.StateIdentifier<StateSchemasOf<Source>>
|
|
7599
|
+
> = Machine.SnapshotByIdentifier<StateSchemasOf<Source>, Path>
|
|
7534
7600
|
|
|
7535
7601
|
/**
|
|
7536
7602
|
* Returns `true` if a value is a `Machine`.
|
|
@@ -8111,199 +8177,6 @@ export const decodeSnapshot: <
|
|
|
8111
8177
|
Machine.SnapshotDecodingServices<States>
|
|
8112
8178
|
> = internal.decodeSnapshot as any
|
|
8113
8179
|
|
|
8114
|
-
type EffectInvokeSource<
|
|
8115
|
-
States extends Machine.StateSchemas,
|
|
8116
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8117
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8118
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8119
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8120
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8121
|
-
Source extends (
|
|
8122
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8123
|
-
) => Effect.Effect<unknown, unknown, unknown>
|
|
8124
|
-
> = {
|
|
8125
|
-
readonly id: InvokeLifecycleId
|
|
8126
|
-
readonly effect: Source
|
|
8127
|
-
readonly stream?: never
|
|
8128
|
-
readonly after?: never
|
|
8129
|
-
readonly logic?: never
|
|
8130
|
-
readonly child?: never
|
|
8131
|
-
readonly address?: never
|
|
8132
|
-
readonly onElement?: never
|
|
8133
|
-
readonly onSnapshot?: never
|
|
8134
|
-
}
|
|
8135
|
-
|
|
8136
|
-
type EffectDoneHandler<
|
|
8137
|
-
States extends Machine.StateSchemas,
|
|
8138
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8139
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8140
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8141
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8142
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8143
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
8144
|
-
> = Machine.InvokeTransition<
|
|
8145
|
-
States,
|
|
8146
|
-
Events,
|
|
8147
|
-
Emits,
|
|
8148
|
-
StateId,
|
|
8149
|
-
Machine.InvokeDoneContext<
|
|
8150
|
-
States,
|
|
8151
|
-
Events,
|
|
8152
|
-
Emits,
|
|
8153
|
-
StateId,
|
|
8154
|
-
Effect.Success<ReturnType<NoInfer<Source>>>,
|
|
8155
|
-
InputEvents,
|
|
8156
|
-
ParentEvents
|
|
8157
|
-
>
|
|
8158
|
-
>
|
|
8159
|
-
|
|
8160
|
-
type EffectFailureHandler<
|
|
8161
|
-
States extends Machine.StateSchemas,
|
|
8162
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8163
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8164
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8165
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8166
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8167
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
8168
|
-
> = Machine.InvokeTransition<
|
|
8169
|
-
States,
|
|
8170
|
-
Events,
|
|
8171
|
-
Emits,
|
|
8172
|
-
StateId,
|
|
8173
|
-
Machine.InvokeFailureContext<
|
|
8174
|
-
States,
|
|
8175
|
-
Events,
|
|
8176
|
-
Emits,
|
|
8177
|
-
StateId,
|
|
8178
|
-
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
8179
|
-
InputEvents,
|
|
8180
|
-
ParentEvents
|
|
8181
|
-
>
|
|
8182
|
-
>
|
|
8183
|
-
|
|
8184
|
-
type EffectInvokeResult<
|
|
8185
|
-
States extends Machine.StateSchemas,
|
|
8186
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8187
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8188
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8189
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8190
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8191
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
8192
|
-
> =
|
|
8193
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8194
|
-
& Machine.InvokeTyped<
|
|
8195
|
-
Effect.Success<ReturnType<Source>>,
|
|
8196
|
-
Effect.Error<ReturnType<Source>>,
|
|
8197
|
-
Effect.Services<ReturnType<Source>>,
|
|
8198
|
-
never
|
|
8199
|
-
>
|
|
8200
|
-
|
|
8201
|
-
type StreamInvokeSource<
|
|
8202
|
-
States extends Machine.StateSchemas,
|
|
8203
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8204
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8205
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8206
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8207
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8208
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8209
|
-
> = {
|
|
8210
|
-
readonly id: InvokeLifecycleId
|
|
8211
|
-
readonly stream:
|
|
8212
|
-
& Source
|
|
8213
|
-
& ((context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
8214
|
-
readonly effect?: never
|
|
8215
|
-
readonly after?: never
|
|
8216
|
-
readonly logic?: never
|
|
8217
|
-
readonly child?: never
|
|
8218
|
-
readonly address?: never
|
|
8219
|
-
readonly onSnapshot?: never
|
|
8220
|
-
}
|
|
8221
|
-
|
|
8222
|
-
type StreamSourceResult<Source extends (...args: ReadonlyArray<any>) => unknown> = ReturnType<Source> extends
|
|
8223
|
-
infer Result extends Stream.Stream<any, any, any> ? Result : never
|
|
8224
|
-
|
|
8225
|
-
type StreamElementHandler<
|
|
8226
|
-
States extends Machine.StateSchemas,
|
|
8227
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8228
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8229
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8230
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8231
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8232
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8233
|
-
> = Machine.InvokeTransition<
|
|
8234
|
-
States,
|
|
8235
|
-
Events,
|
|
8236
|
-
Emits,
|
|
8237
|
-
StateId,
|
|
8238
|
-
Machine.InvokeElementContext<
|
|
8239
|
-
States,
|
|
8240
|
-
Events,
|
|
8241
|
-
Emits,
|
|
8242
|
-
StateId,
|
|
8243
|
-
Stream.Success<StreamSourceResult<NoInfer<Source>>>,
|
|
8244
|
-
InputEvents,
|
|
8245
|
-
ParentEvents
|
|
8246
|
-
>
|
|
8247
|
-
>
|
|
8248
|
-
|
|
8249
|
-
type StreamDoneHandler<
|
|
8250
|
-
States extends Machine.StateSchemas,
|
|
8251
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8252
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8253
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8254
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8255
|
-
StateId extends Machine.StateIdentifier<States>
|
|
8256
|
-
> = Machine.InvokeTransition<
|
|
8257
|
-
States,
|
|
8258
|
-
Events,
|
|
8259
|
-
Emits,
|
|
8260
|
-
StateId,
|
|
8261
|
-
Machine.InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
8262
|
-
>
|
|
8263
|
-
|
|
8264
|
-
type StreamFailureHandler<
|
|
8265
|
-
States extends Machine.StateSchemas,
|
|
8266
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8267
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8268
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8269
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8270
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8271
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8272
|
-
> = Machine.InvokeTransition<
|
|
8273
|
-
States,
|
|
8274
|
-
Events,
|
|
8275
|
-
Emits,
|
|
8276
|
-
StateId,
|
|
8277
|
-
Machine.InvokeFailureContext<
|
|
8278
|
-
States,
|
|
8279
|
-
Events,
|
|
8280
|
-
Emits,
|
|
8281
|
-
StateId,
|
|
8282
|
-
Stream.Error<StreamSourceResult<NoInfer<Source>>>,
|
|
8283
|
-
InputEvents,
|
|
8284
|
-
ParentEvents
|
|
8285
|
-
>
|
|
8286
|
-
>
|
|
8287
|
-
|
|
8288
|
-
type StreamInvokeResult<
|
|
8289
|
-
States extends Machine.StateSchemas,
|
|
8290
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8291
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8292
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8293
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8294
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8295
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8296
|
-
> =
|
|
8297
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8298
|
-
& Machine.InvokeTyped<
|
|
8299
|
-
void,
|
|
8300
|
-
Stream.Error<StreamSourceResult<Source>>,
|
|
8301
|
-
Stream.Services<StreamSourceResult<Source>>,
|
|
8302
|
-
never
|
|
8303
|
-
>
|
|
8304
|
-
|
|
8305
|
-
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
8306
|
-
|
|
8307
8180
|
type TransitionBranchRecordError<Message extends string, Key extends PropertyKey = never> = {
|
|
8308
8181
|
readonly "~effect/Machine/TransitionBranchRecordError": Message
|
|
8309
8182
|
readonly key: Key
|
|
@@ -8319,368 +8192,6 @@ type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never]
|
|
|
8319
8192
|
InvalidStaticTransitionBranchKey<Branches>
|
|
8320
8193
|
>
|
|
8321
8194
|
|
|
8322
|
-
/**
|
|
8323
|
-
* Preserves inference for a state-owned invocation configuration.
|
|
8324
|
-
*
|
|
8325
|
-
* Use `effect` for one-shot work, `stream` for repeated values, `after` for a
|
|
8326
|
-
* cancellable timer, `logic` for reusable process logic, or `child` for a
|
|
8327
|
-
* complete child machine. Stream elements are handled by `onElement` before
|
|
8328
|
-
* the next element is pulled. `onDone` is required whenever the source can
|
|
8329
|
-
* complete, while `onFailure` is required only when the source has a typed
|
|
8330
|
-
* failure channel.
|
|
8331
|
-
*
|
|
8332
|
-
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
8333
|
-
* inference through published declarations. Effect and Stream factories run
|
|
8334
|
-
* when their owning state is entered and infer the owner context, value,
|
|
8335
|
-
* output, error, and service channels together without a return annotation.
|
|
8336
|
-
* Durations may be
|
|
8337
|
-
* supplied directly or derived from the owning state's entry context. Logic
|
|
8338
|
-
* invocations require both a lifecycle `id` and a typed communication
|
|
8339
|
-
* `address`. Child descriptors already own their identity, so `id` and
|
|
8340
|
-
* `address` must not be repeated.
|
|
8341
|
-
*
|
|
8342
|
-
* Inside `handle(...)`, the owning definition contextually supplies its public
|
|
8343
|
-
* input and declared parent protocols. Invocation sources and lifecycle handlers
|
|
8344
|
-
* can therefore send through `self` and `parent` without naming the definition.
|
|
8345
|
-
* The standard `Machine.invoke(...)` constructor preserves these contexts
|
|
8346
|
-
* directly; no intermediate definition method is required.
|
|
8347
|
-
*
|
|
8348
|
-
* ```ts
|
|
8349
|
-
* invoke: Machine.invoke({
|
|
8350
|
-
* id: "load",
|
|
8351
|
-
* effect: () =>
|
|
8352
|
-
* Effect.tryPromise({
|
|
8353
|
-
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
8354
|
-
* catch: (cause) => new LoadError({ cause })
|
|
8355
|
-
* }),
|
|
8356
|
-
* onDone: (to) =>
|
|
8357
|
-
* to.full.Ready().resolve(({ output, target }) =>
|
|
8358
|
-
* target.from({ data: output })),
|
|
8359
|
-
* onFailure: (to) =>
|
|
8360
|
-
* to.full.Failed().resolve(({ error, target }) =>
|
|
8361
|
-
* target.from({ error }))
|
|
8362
|
-
* })
|
|
8363
|
-
* ```
|
|
8364
|
-
*
|
|
8365
|
-
* @category constructors
|
|
8366
|
-
* @since 0.9.0
|
|
8367
|
-
*/
|
|
8368
|
-
export const invoke: {
|
|
8369
|
-
<
|
|
8370
|
-
const States extends Machine.StateSchemas,
|
|
8371
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8372
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8373
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8374
|
-
const Source extends (
|
|
8375
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8376
|
-
) => Effect.Effect<unknown, unknown, unknown>,
|
|
8377
|
-
const Config extends object,
|
|
8378
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8379
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8380
|
-
>(
|
|
8381
|
-
config:
|
|
8382
|
-
& Config
|
|
8383
|
-
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8384
|
-
& {
|
|
8385
|
-
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8386
|
-
readonly onFailure: EffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8387
|
-
},
|
|
8388
|
-
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
8389
|
-
"onDone must be omitted when the Effect output is never"
|
|
8390
|
-
]
|
|
8391
|
-
: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
8392
|
-
"onFailure must be omitted when the Effect error is never"
|
|
8393
|
-
]
|
|
8394
|
-
: []
|
|
8395
|
-
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8396
|
-
<
|
|
8397
|
-
const States extends Machine.StateSchemas,
|
|
8398
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8399
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8400
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8401
|
-
const Source extends (
|
|
8402
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8403
|
-
) => Effect.Effect<unknown, never, unknown>,
|
|
8404
|
-
const Config extends object,
|
|
8405
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8406
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8407
|
-
>(
|
|
8408
|
-
config:
|
|
8409
|
-
& Config
|
|
8410
|
-
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8411
|
-
& {
|
|
8412
|
-
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8413
|
-
readonly onFailure?: never
|
|
8414
|
-
},
|
|
8415
|
-
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
8416
|
-
"onDone must be omitted when the Effect output is never"
|
|
8417
|
-
]
|
|
8418
|
-
: []
|
|
8419
|
-
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8420
|
-
<
|
|
8421
|
-
const States extends Machine.StateSchemas,
|
|
8422
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8423
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8424
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8425
|
-
const Source extends (
|
|
8426
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8427
|
-
) => Effect.Effect<never, unknown, unknown>,
|
|
8428
|
-
const Config extends object,
|
|
8429
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8430
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8431
|
-
>(
|
|
8432
|
-
config:
|
|
8433
|
-
& Config
|
|
8434
|
-
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8435
|
-
& {
|
|
8436
|
-
readonly onDone?: never
|
|
8437
|
-
readonly onFailure: EffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8438
|
-
},
|
|
8439
|
-
..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
8440
|
-
"onFailure must be omitted when the Effect error is never"
|
|
8441
|
-
]
|
|
8442
|
-
: []
|
|
8443
|
-
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8444
|
-
<
|
|
8445
|
-
const States extends Machine.StateSchemas,
|
|
8446
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8447
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8448
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8449
|
-
const Source extends (
|
|
8450
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8451
|
-
) => Effect.Effect<never, never, unknown>,
|
|
8452
|
-
const Config extends object,
|
|
8453
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8454
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8455
|
-
>(
|
|
8456
|
-
config:
|
|
8457
|
-
& Config
|
|
8458
|
-
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8459
|
-
& {
|
|
8460
|
-
readonly onDone?: never
|
|
8461
|
-
readonly onFailure?: never
|
|
8462
|
-
}
|
|
8463
|
-
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8464
|
-
<
|
|
8465
|
-
const States extends Machine.StateSchemas,
|
|
8466
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8467
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8468
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8469
|
-
const Source extends (
|
|
8470
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8471
|
-
) => Stream.Stream<unknown, unknown, any>,
|
|
8472
|
-
const Config extends object,
|
|
8473
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8474
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8475
|
-
>(
|
|
8476
|
-
config:
|
|
8477
|
-
& Config
|
|
8478
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8479
|
-
& {
|
|
8480
|
-
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8481
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8482
|
-
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8483
|
-
},
|
|
8484
|
-
..._validation: InvokeChannelIsNever<Stream.Success<ReturnType<Source>>> extends true ? [
|
|
8485
|
-
"onElement must be omitted when the Stream element is never"
|
|
8486
|
-
]
|
|
8487
|
-
: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8488
|
-
"onFailure must be omitted when the Stream error is never"
|
|
8489
|
-
]
|
|
8490
|
-
: []
|
|
8491
|
-
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8492
|
-
<
|
|
8493
|
-
const States extends Machine.StateSchemas,
|
|
8494
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8495
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8496
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8497
|
-
const Source extends (
|
|
8498
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8499
|
-
) => Stream.Stream<never, unknown, any>,
|
|
8500
|
-
const Config extends object,
|
|
8501
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8502
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8503
|
-
>(
|
|
8504
|
-
config:
|
|
8505
|
-
& Config
|
|
8506
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8507
|
-
& {
|
|
8508
|
-
readonly onElement?: never
|
|
8509
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8510
|
-
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8511
|
-
},
|
|
8512
|
-
..._validation: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8513
|
-
"onFailure must be omitted when the Stream error is never"
|
|
8514
|
-
]
|
|
8515
|
-
: []
|
|
8516
|
-
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8517
|
-
<
|
|
8518
|
-
const States extends Machine.StateSchemas,
|
|
8519
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8520
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8521
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8522
|
-
const Source extends (
|
|
8523
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8524
|
-
) => Stream.Stream<never, never, any>,
|
|
8525
|
-
const Config extends object,
|
|
8526
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8527
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8528
|
-
>(
|
|
8529
|
-
config:
|
|
8530
|
-
& Config
|
|
8531
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8532
|
-
& {
|
|
8533
|
-
readonly onElement?: never
|
|
8534
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8535
|
-
readonly onFailure?: never
|
|
8536
|
-
}
|
|
8537
|
-
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8538
|
-
<
|
|
8539
|
-
const States extends Machine.StateSchemas,
|
|
8540
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8541
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8542
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8543
|
-
const Source extends (
|
|
8544
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8545
|
-
) => Stream.Stream<unknown, never, any>,
|
|
8546
|
-
const Config extends object,
|
|
8547
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8548
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8549
|
-
>(
|
|
8550
|
-
config:
|
|
8551
|
-
& Config
|
|
8552
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8553
|
-
& {
|
|
8554
|
-
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8555
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8556
|
-
readonly onFailure?: never
|
|
8557
|
-
}
|
|
8558
|
-
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8559
|
-
<
|
|
8560
|
-
const States extends Machine.StateSchemas,
|
|
8561
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8562
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8563
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8564
|
-
const Config extends object,
|
|
8565
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8566
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8567
|
-
>(
|
|
8568
|
-
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8569
|
-
):
|
|
8570
|
-
& NoInfer<Config>
|
|
8571
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8572
|
-
& Machine.InvokeTyped<void, never, never, never>
|
|
8573
|
-
<
|
|
8574
|
-
const States extends Machine.StateSchemas,
|
|
8575
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8576
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8577
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8578
|
-
const Source extends (
|
|
8579
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8580
|
-
) => unknown,
|
|
8581
|
-
Address extends ChildAddress<never>,
|
|
8582
|
-
const Config extends object,
|
|
8583
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8584
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8585
|
-
>(
|
|
8586
|
-
config:
|
|
8587
|
-
& Config
|
|
8588
|
-
& { readonly logic: Source }
|
|
8589
|
-
& Machine.LogicInvokeArgs<
|
|
8590
|
-
States,
|
|
8591
|
-
Events,
|
|
8592
|
-
Emits,
|
|
8593
|
-
StateId,
|
|
8594
|
-
Machine.LogicStateOf<ReturnType<Source>>,
|
|
8595
|
-
Machine.LogicEventOf<ReturnType<Source>>,
|
|
8596
|
-
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8597
|
-
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8598
|
-
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8599
|
-
Machine.LogicInitialErrorOf<ReturnType<Source>>,
|
|
8600
|
-
Address,
|
|
8601
|
-
Source,
|
|
8602
|
-
InputEvents,
|
|
8603
|
-
ParentEvents
|
|
8604
|
-
>,
|
|
8605
|
-
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8606
|
-
"logic factory must return Machine.Logic"
|
|
8607
|
-
]
|
|
8608
|
-
):
|
|
8609
|
-
& NoInfer<Config>
|
|
8610
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8611
|
-
& Machine.InvokeTyped<
|
|
8612
|
-
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8613
|
-
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8614
|
-
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8615
|
-
Machine.LogicInitialErrorOf<ReturnType<Source>>
|
|
8616
|
-
>
|
|
8617
|
-
<
|
|
8618
|
-
const States extends Machine.StateSchemas,
|
|
8619
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8620
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8621
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8622
|
-
const Source,
|
|
8623
|
-
Address extends ChildAddress<never>,
|
|
8624
|
-
const Config extends object,
|
|
8625
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8626
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8627
|
-
>(
|
|
8628
|
-
config:
|
|
8629
|
-
& Config
|
|
8630
|
-
& { readonly logic: Source }
|
|
8631
|
-
& Machine.LogicInvokeArgs<
|
|
8632
|
-
States,
|
|
8633
|
-
Events,
|
|
8634
|
-
Emits,
|
|
8635
|
-
StateId,
|
|
8636
|
-
Machine.LogicStateOf<Source>,
|
|
8637
|
-
Machine.LogicEventOf<Source>,
|
|
8638
|
-
Machine.LogicErrorOf<Source>,
|
|
8639
|
-
Machine.LogicServicesOf<Source>,
|
|
8640
|
-
Machine.LogicOutputOf<Source>,
|
|
8641
|
-
Machine.LogicInitialErrorOf<Source>,
|
|
8642
|
-
Address,
|
|
8643
|
-
Source,
|
|
8644
|
-
InputEvents,
|
|
8645
|
-
ParentEvents
|
|
8646
|
-
>,
|
|
8647
|
-
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8648
|
-
"logic must implement Machine.Logic"
|
|
8649
|
-
]
|
|
8650
|
-
):
|
|
8651
|
-
& NoInfer<Config>
|
|
8652
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8653
|
-
& Machine.InvokeTyped<
|
|
8654
|
-
Machine.LogicOutputOf<Source>,
|
|
8655
|
-
Machine.LogicErrorOf<Source>,
|
|
8656
|
-
Machine.LogicServicesOf<Source>,
|
|
8657
|
-
Machine.LogicInitialErrorOf<Source>
|
|
8658
|
-
>
|
|
8659
|
-
<
|
|
8660
|
-
const States extends Machine.StateSchemas,
|
|
8661
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8662
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8663
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8664
|
-
const Child extends ChildMachine.Any,
|
|
8665
|
-
const Config extends object,
|
|
8666
|
-
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8667
|
-
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8668
|
-
>(
|
|
8669
|
-
config:
|
|
8670
|
-
& Config
|
|
8671
|
-
& Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child, InputEvents, ParentEvents>
|
|
8672
|
-
):
|
|
8673
|
-
& Config
|
|
8674
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8675
|
-
& Machine.InvokeTyped<
|
|
8676
|
-
Machine.Output<Child["machine"]>,
|
|
8677
|
-
Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>,
|
|
8678
|
-
Machine.Services<Child["machine"]>,
|
|
8679
|
-
Machine.InitialError<Child["machine"]>,
|
|
8680
|
-
Machine.Emit<Child["machine"]>,
|
|
8681
|
-
Machine.EventOf<Machine.ParentEvents<Child["machine"]>>
|
|
8682
|
-
>
|
|
8683
|
-
} = ((config: unknown) => config) as any
|
|
8684
8195
|
/**
|
|
8685
8196
|
* Plans the initial state for a machine without executing machine commands.
|
|
8686
8197
|
*
|
|
@@ -9128,7 +8639,7 @@ export const child: <const Id extends string, M extends Machine.Any>(id: Id, mac
|
|
|
9128
8639
|
* Creates a typed parent-local address for lower-level child process logic.
|
|
9129
8640
|
*
|
|
9130
8641
|
* The default event protocol is `never`; provide an event type before using
|
|
9131
|
-
* the address with `spawn`,
|
|
8642
|
+
* the address with `spawn`, a state-owned logic invocation, or `sendTo`.
|
|
9132
8643
|
*
|
|
9133
8644
|
* @category constructors
|
|
9134
8645
|
* @since 0.4.0
|
|
@@ -9149,7 +8660,8 @@ export const childAddress: <Event = never>(id: string) => ChildAddress<Event> =
|
|
|
9149
8660
|
* This Effect requires a managed process runtime. A named child id must be
|
|
9150
8661
|
* unique for the current parent until that child stops.
|
|
9151
8662
|
*
|
|
9152
|
-
*
|
|
8663
|
+
* Use a state's `invoke: (from) => from.logic(...)` declaration for children
|
|
8664
|
+
* that start and stop with that state.
|
|
9153
8665
|
* @see {@link sendTo} for sending events to named children.
|
|
9154
8666
|
* @category runtime
|
|
9155
8667
|
* @since 0.4.0
|