@typeonce/effect-machine 0.33.0 → 0.34.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 +216 -636
- package/dist/Machine.d.ts +815 -583
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +20 -8
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/childRegistry.d.ts +1 -1
- package/dist/internal/machine/childRegistry.d.ts.map +1 -1
- package/dist/internal/machine/cluster.d.ts +2 -50
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js +4 -27
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/clusterProtocol.d.ts +35 -0
- package/dist/internal/machine/clusterProtocol.d.ts.map +1 -0
- package/dist/internal/machine/clusterProtocol.js +28 -0
- package/dist/internal/machine/clusterProtocol.js.map +1 -0
- package/dist/internal/machine/commandRuntime.d.ts +1 -1
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/configuration.d.ts +2 -1
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +38 -45
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/declaration.d.ts +17 -0
- package/dist/internal/machine/declaration.d.ts.map +1 -0
- package/dist/internal/machine/declaration.js +120 -0
- package/dist/internal/machine/declaration.js.map +1 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +5 -4
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/implementation.d.ts +34 -0
- package/dist/internal/machine/implementation.d.ts.map +1 -0
- package/dist/internal/machine/implementation.js +3 -0
- package/dist/internal/machine/implementation.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts.map +1 -1
- package/dist/internal/machine/machine.d.ts +13 -2
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +140 -278
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +12 -11
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +8 -7
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +16 -12
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +2 -230
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +8 -1857
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.d.ts +5 -0
- package/dist/internal/machine/runtimeCompiled.d.ts.map +1 -0
- package/dist/internal/machine/runtimeCompiled.js +867 -0
- package/dist/internal/machine/runtimeCompiled.js.map +1 -0
- package/dist/internal/machine/runtimeGeneric.d.ts +3 -0
- package/dist/internal/machine/runtimeGeneric.d.ts.map +1 -0
- package/dist/internal/machine/runtimeGeneric.js +471 -0
- package/dist/internal/machine/runtimeGeneric.js.map +1 -0
- package/dist/internal/machine/runtimeProtocol.d.ts +312 -0
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -0
- package/dist/internal/machine/runtimeProtocol.js +561 -0
- package/dist/internal/machine/runtimeProtocol.js.map +1 -0
- package/dist/internal/machine/targetReference.d.ts +15 -0
- package/dist/internal/machine/targetReference.d.ts.map +1 -0
- package/dist/internal/machine/targetReference.js +31 -0
- package/dist/internal/machine/targetReference.js.map +1 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +2 -1
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +38 -40
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/internal/testing/machine/probe.js +1 -1
- package/dist/internal/testing/machine/probe.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +5 -5
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +5 -17
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/docs/agent-guide.md +66 -91
- package/docs/machine-review.md +19 -49
- package/docs/root-api.md +62 -62
- package/package.json +1 -1
- package/src/Machine.ts +1514 -2312
- package/src/internal/machine/childRegistry.ts +1 -1
- package/src/internal/machine/cluster.ts +7 -73
- package/src/internal/machine/clusterProtocol.ts +56 -0
- package/src/internal/machine/commandRuntime.ts +1 -1
- package/src/internal/machine/configuration.ts +53 -45
- package/src/internal/machine/declaration.ts +140 -0
- package/src/internal/machine/executionPlan.ts +6 -5
- package/src/internal/machine/implementation.ts +41 -0
- package/src/internal/machine/invocation.ts +3 -3
- package/src/internal/machine/invocationDefinition.ts +1 -1
- package/src/internal/machine/machine.ts +199 -409
- package/src/internal/machine/planner.ts +54 -35
- package/src/internal/machine/process.ts +40 -33
- package/src/internal/machine/runtime.ts +20 -3037
- package/src/internal/machine/runtimeCompiled.ts +1166 -0
- package/src/internal/machine/runtimeGeneric.ts +799 -0
- package/src/internal/machine/runtimeProtocol.ts +1213 -0
- package/src/internal/machine/targetReference.ts +40 -0
- package/src/internal/machine/topology.ts +2 -1
- package/src/internal/testing/machine/finiteModel.ts +42 -43
- package/src/internal/testing/machine/probe.ts +1 -1
- package/src/unstable/cluster/ClusterMachine.ts +9 -17
package/src/Machine.ts
CHANGED
|
@@ -28,7 +28,7 @@ import * as internal from "./internal/machine/machine.js"
|
|
|
28
28
|
import { InitialEventTypeId } from "./internal/machine/machine.js"
|
|
29
29
|
import type { EnsureExecutable } from "./internal/machine/readiness.js"
|
|
30
30
|
import type { ExcludeCompatibleRuntime } from "./internal/machine/requirements.js"
|
|
31
|
-
import type * as internalRuntime from "./internal/machine/
|
|
31
|
+
import type * as internalRuntime from "./internal/machine/runtimeProtocol.js"
|
|
32
32
|
import type * as StateDefinition from "./internal/machine/stateDefinition.js"
|
|
33
33
|
import type * as Topology from "./internal/machine/topology.js"
|
|
34
34
|
|
|
@@ -111,9 +111,33 @@ type IsAny<A> = 0 extends (1 & A) ? true : false
|
|
|
111
111
|
*
|
|
112
112
|
* **Gotchas**
|
|
113
113
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
114
|
+
* Use `guard` to decline a transition before constructing its next state.
|
|
115
|
+
* Use `declinable: true` when a named branch resolver may return `decline()`.
|
|
116
|
+
* Register cancellable state-scoped delays in `make({ timers })`.
|
|
117
|
+
*
|
|
118
|
+
* **Example**
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
122
|
+
* import { Schema } from "effect"
|
|
123
|
+
*
|
|
124
|
+
* const events = Machine.events({ Add: { by: Schema.Number } })
|
|
125
|
+
* const Root = Machine.state({ fields: { count: Schema.Number } })
|
|
126
|
+
* const targets = Machine.targets(Root)
|
|
127
|
+
* export const counter = Machine.make({
|
|
128
|
+
* root: Root,
|
|
129
|
+
* events,
|
|
130
|
+
* initial: (root) => root.from(() => ({ count: 0 }))
|
|
131
|
+
* }).handle({
|
|
132
|
+
* on: {
|
|
133
|
+
* Add: {
|
|
134
|
+
* update: targets.root,
|
|
135
|
+
* guard: ({ event }) => event.by > 0,
|
|
136
|
+
* from: ({ root, event }) => ({ count: root.count + event.by })
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
* })
|
|
140
|
+
* ```
|
|
117
141
|
*
|
|
118
142
|
* @category models
|
|
119
143
|
* @since 0.4.0
|
|
@@ -225,7 +249,7 @@ export interface Machine<
|
|
|
225
249
|
) => Machine.TargetBuilder<States, Source>
|
|
226
250
|
|
|
227
251
|
/** @internal */
|
|
228
|
-
readonly handlers:
|
|
252
|
+
readonly handlers: Readonly<Record<string, unknown>>
|
|
229
253
|
|
|
230
254
|
/** @internal */
|
|
231
255
|
readonly initial: (...args: [...Machine.InputArgs<Input>]) => Machine.InitialResult<States, InitialE, InitialR>
|
|
@@ -257,7 +281,8 @@ export interface Definition<
|
|
|
257
281
|
Output = never,
|
|
258
282
|
Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
259
283
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events,
|
|
260
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
284
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
285
|
+
Registrations extends Machine.Registrations = {}
|
|
261
286
|
> extends
|
|
262
287
|
Machine<
|
|
263
288
|
States,
|
|
@@ -285,12 +310,14 @@ export interface Definition<
|
|
|
285
310
|
* **Example**
|
|
286
311
|
*
|
|
287
312
|
* ```ts
|
|
313
|
+
* const targets = Machine.targets(States)
|
|
288
314
|
* const counter = definition.handle({ states: {
|
|
289
315
|
* Count: {
|
|
290
316
|
* on: {
|
|
291
|
-
* Increment:
|
|
292
|
-
*
|
|
293
|
-
*
|
|
317
|
+
* Increment: {
|
|
318
|
+
* update: targets.root.Count,
|
|
319
|
+
* decoded: ({ event, state }) => new Count({ value: state.value + event.by })
|
|
320
|
+
* }
|
|
294
321
|
* }
|
|
295
322
|
* }
|
|
296
323
|
* } })
|
|
@@ -303,16 +330,13 @@ export interface Definition<
|
|
|
303
330
|
Events,
|
|
304
331
|
Emits,
|
|
305
332
|
Input,
|
|
306
|
-
Machine.StateIdentifier<States>,
|
|
307
|
-
never,
|
|
308
|
-
never,
|
|
309
333
|
InitialE,
|
|
310
334
|
InitialR,
|
|
311
335
|
FinalStates,
|
|
312
336
|
Output,
|
|
313
|
-
never,
|
|
314
337
|
InputEvents,
|
|
315
|
-
ParentEvents
|
|
338
|
+
ParentEvents,
|
|
339
|
+
Registrations
|
|
316
340
|
>
|
|
317
341
|
}
|
|
318
342
|
|
|
@@ -644,9 +668,6 @@ type IncompatibleRuntime<Requirements, Events, Emits> = Requirements extends Run
|
|
|
644
668
|
: never
|
|
645
669
|
|
|
646
670
|
const InvokeTypeId: typeof internal.InvokeTypeId = internal.InvokeTypeId
|
|
647
|
-
const TransitionTypeId: typeof internal.TransitionTypeId = internal.TransitionTypeId
|
|
648
|
-
declare const TransitionBuilderTypeId: unique symbol
|
|
649
|
-
declare const InvokeBuilderTypeId: unique symbol
|
|
650
671
|
declare const InitialBuilderTypeId: unique symbol
|
|
651
672
|
|
|
652
673
|
type StateDefinitionError<
|
|
@@ -4729,7 +4750,7 @@ export declare namespace Machine {
|
|
|
4729
4750
|
* do not directly control state re-entry. Exit and entry paths are derived
|
|
4730
4751
|
* from the previous and next active paths. Shared active ancestors remain
|
|
4731
4752
|
* entered even when a `full` target supplies their values again. Use an event
|
|
4732
|
-
* transition with
|
|
4753
|
+
* transition with `reenter: true` when the source should explicitly exit and
|
|
4733
4754
|
* enter again.
|
|
4734
4755
|
*
|
|
4735
4756
|
* @category models
|
|
@@ -4820,206 +4841,8 @@ export declare namespace Machine {
|
|
|
4820
4841
|
Scope extends Topology.TargetSelectionScope | undefined = Topology.TargetSelectionScope | undefined
|
|
4821
4842
|
> = () => SelectionValue<Builder, Path, Kind, Scope>
|
|
4822
4843
|
|
|
4823
|
-
type InitialSelectionMethod<
|
|
4824
|
-
Builder,
|
|
4825
|
-
Path extends string,
|
|
4826
|
-
Scope extends Topology.TargetSelectionScope
|
|
4827
|
-
> = Builder extends { readonly initial: infer Initial } ? {
|
|
4828
|
-
readonly initial: SelectionValue<Initial, Path, "initial", Scope>
|
|
4829
|
-
}
|
|
4830
|
-
: {}
|
|
4831
|
-
|
|
4832
|
-
type SelectionTreeWithPrefix<
|
|
4833
|
-
AllStates extends StateSchemas,
|
|
4834
|
-
States extends StateSchemas,
|
|
4835
|
-
Prefix extends string,
|
|
4836
|
-
Scope extends "local" | "branch",
|
|
4837
|
-
Builder
|
|
4838
|
-
> = {
|
|
4839
|
-
readonly [Key in Extract<ActiveStateKey<States> | ChoiceStateKey<States>, keyof Builder>]: SelectionNode<
|
|
4840
|
-
AllStates,
|
|
4841
|
-
States[Key],
|
|
4842
|
-
JoinPath<Prefix, Key>,
|
|
4843
|
-
Scope,
|
|
4844
|
-
Builder[Key]
|
|
4845
|
-
>
|
|
4846
|
-
}
|
|
4847
|
-
|
|
4848
|
-
type SelectionNode<
|
|
4849
|
-
AllStates extends StateSchemas,
|
|
4850
|
-
Node,
|
|
4851
|
-
Path extends string,
|
|
4852
|
-
Scope extends "local" | "branch",
|
|
4853
|
-
Builder
|
|
4854
|
-
> = Node extends ChoiceStateNodeConfig ? SelectionMethod<
|
|
4855
|
-
Builder,
|
|
4856
|
-
Path,
|
|
4857
|
-
"choice",
|
|
4858
|
-
Scope
|
|
4859
|
-
>
|
|
4860
|
-
: Node extends { readonly states: infer Children extends StateSchemas } ?
|
|
4861
|
-
& SelectionMethod<Builder, Path, "state", Scope>
|
|
4862
|
-
& InitialSelectionMethod<Builder, Path, Scope>
|
|
4863
|
-
& SelectionTreeWithPrefix<AllStates, Children, Path, Scope, Builder>
|
|
4864
|
-
: SelectionMethod<Builder, Path, "state", Scope>
|
|
4865
|
-
|
|
4866
|
-
/** @internal */
|
|
4867
|
-
type StateUpdateSelectionForNode<
|
|
4868
|
-
AllStates extends StateSchemas,
|
|
4869
|
-
Node,
|
|
4870
|
-
Path extends string,
|
|
4871
|
-
Scope extends "local" | "branch"
|
|
4872
|
-
> = Node extends { readonly type: "final" } ? {} : NodeSchema<Node> extends never ? {}
|
|
4873
|
-
: {
|
|
4874
|
-
readonly update: SelectionValue<
|
|
4875
|
-
StateUpdateBuilder<AllStates, Extract<Path, ValuedStateIdentifier<AllStates>>>,
|
|
4876
|
-
Path,
|
|
4877
|
-
"update",
|
|
4878
|
-
Scope
|
|
4879
|
-
>
|
|
4880
|
-
}
|
|
4881
|
-
|
|
4882
|
-
/** @internal */
|
|
4883
|
-
type BranchUpdateSelectionPath<
|
|
4884
|
-
AllStates extends StateSchemas,
|
|
4885
|
-
Node,
|
|
4886
|
-
Path extends string,
|
|
4887
|
-
Rest extends string,
|
|
4888
|
-
Scope extends "local" | "branch" = "branch"
|
|
4889
|
-
> =
|
|
4890
|
-
& StateUpdateSelectionForNode<AllStates, Node, Path, Scope>
|
|
4891
|
-
& (Node extends { readonly states: infer Children extends StateSchemas } ?
|
|
4892
|
-
Rest extends `${infer Head}.${infer Tail}` ? Head extends keyof Children ? {
|
|
4893
|
-
readonly [Key in Head]: BranchUpdateSelectionPath<
|
|
4894
|
-
AllStates,
|
|
4895
|
-
Children[Head],
|
|
4896
|
-
JoinPath<Path, Head>,
|
|
4897
|
-
Tail,
|
|
4898
|
-
Scope
|
|
4899
|
-
>
|
|
4900
|
-
}
|
|
4901
|
-
: {}
|
|
4902
|
-
: Rest extends keyof Children ? {
|
|
4903
|
-
readonly [Key in Rest]: StateUpdateSelectionForNode<
|
|
4904
|
-
AllStates,
|
|
4905
|
-
Children[Rest],
|
|
4906
|
-
JoinPath<Path, Rest>,
|
|
4907
|
-
Scope
|
|
4908
|
-
>
|
|
4909
|
-
}
|
|
4910
|
-
: {}
|
|
4911
|
-
: {})
|
|
4912
|
-
|
|
4913
|
-
type FullSelectionNode<
|
|
4914
|
-
AllStates extends StateSchemas,
|
|
4915
|
-
Node,
|
|
4916
|
-
Path extends StateIdentifier<AllStates>,
|
|
4917
|
-
Builder
|
|
4918
|
-
> = Node extends { readonly states: StateSchemas } ?
|
|
4919
|
-
& SelectionMethod<Builder, Path, "state", "full">
|
|
4920
|
-
& InitialSelectionMethod<Builder, Path, "full">
|
|
4921
|
-
: SelectionMethod<Builder, Path, "state", "full">
|
|
4922
|
-
|
|
4923
4844
|
type RootBuilder<Builder> = Builder extends { readonly "": infer Root } ? Root : never
|
|
4924
4845
|
|
|
4925
|
-
type FullTargetSelector<States extends StateSchemas> =
|
|
4926
|
-
& SelectionValue<RootBuilder<FullTargetBuilder<States>>, "", "state", "full">
|
|
4927
|
-
& InitialSelectionMethod<RootBuilder<FullTargetBuilder<States>>, "", "full">
|
|
4928
|
-
|
|
4929
|
-
type BranchTargetSelector<States extends StateSchemas, Source extends StateNodeIdentifier<States>> =
|
|
4930
|
-
States[""] extends { readonly states: infer Children extends StateSchemas } ?
|
|
4931
|
-
& SelectionTreeWithPrefix<States, Children, "", "branch", RootBuilder<BranchTargetBuilder<States, Source>>>
|
|
4932
|
-
& (Source extends ChoiceIdentifier<States> ? {}
|
|
4933
|
-
: Omit<BranchUpdateSelectionPath<States, States[""], "", Source>, "update">)
|
|
4934
|
-
: {}
|
|
4935
|
-
|
|
4936
|
-
type LocalTargetSelector<
|
|
4937
|
-
States extends StateSchemas,
|
|
4938
|
-
Source extends StateNodeIdentifier<States>
|
|
4939
|
-
> = NearestCompoundScope<States, Source> extends infer Scope ? [Scope] extends [never] ? {}
|
|
4940
|
-
: Scope extends StateIdentifier<States> ?
|
|
4941
|
-
ChildrenOf<States, Scope> extends infer Children extends StateSchemas ?
|
|
4942
|
-
LocalTargetBuilder<States, Source> extends infer Builder ?
|
|
4943
|
-
& SelectionTreeWithPrefix<States, Children, Scope, "local", Builder>
|
|
4944
|
-
& ("with" extends keyof Builder ? {
|
|
4945
|
-
readonly with: SelectionValue<Builder["with"], Scope, "state", "local">
|
|
4946
|
-
}
|
|
4947
|
-
: {})
|
|
4948
|
-
& (Source extends ChoiceIdentifier<States> ? {}
|
|
4949
|
-
: Scope extends ValuedStateIdentifier<States> ? {
|
|
4950
|
-
readonly update: SelectionValue<StateUpdateBuilder<States, Scope>, Scope, "update", "local">
|
|
4951
|
-
}
|
|
4952
|
-
: {})
|
|
4953
|
-
: {}
|
|
4954
|
-
: {}
|
|
4955
|
-
: {}
|
|
4956
|
-
: {}
|
|
4957
|
-
|
|
4958
|
-
type HistorySelectionTree<
|
|
4959
|
-
AllStates extends StateSchemas,
|
|
4960
|
-
States extends StateSchemas,
|
|
4961
|
-
Prefix extends string,
|
|
4962
|
-
Builder
|
|
4963
|
-
> = {
|
|
4964
|
-
readonly [Key in Extract<HistoryContainingKey<States>, keyof Builder>]: States[Key] extends HistoryStateNodeConfig ?
|
|
4965
|
-
SelectionValue<
|
|
4966
|
-
Builder[Key],
|
|
4967
|
-
JoinPath<Prefix, Key>,
|
|
4968
|
-
"history",
|
|
4969
|
-
"full"
|
|
4970
|
-
>
|
|
4971
|
-
: States[Key] extends { readonly states: infer Children extends StateSchemas } ? HistorySelectionTree<
|
|
4972
|
-
AllStates,
|
|
4973
|
-
Children,
|
|
4974
|
-
JoinPath<Prefix, Key>,
|
|
4975
|
-
Builder[Key]
|
|
4976
|
-
>
|
|
4977
|
-
: never
|
|
4978
|
-
}
|
|
4979
|
-
|
|
4980
|
-
/**
|
|
4981
|
-
* Definition-time topology selector available to an ordinary transition.
|
|
4982
|
-
*
|
|
4983
|
-
* Topology-only instructions (`none`, declared `initial` and history
|
|
4984
|
-
* selections, and `local.with`) are values.
|
|
4985
|
-
*
|
|
4986
|
-
* State and choice destinations remain callable selection methods so their
|
|
4987
|
-
* target-specific resolver APIs retain exact inference.
|
|
4988
|
-
*/
|
|
4989
|
-
export interface TargetSelector<
|
|
4990
|
-
States extends StateSchemas,
|
|
4991
|
-
Source extends StateNodeIdentifier<States>
|
|
4992
|
-
> {
|
|
4993
|
-
/** Replaces this handler owner's value without reentry. */
|
|
4994
|
-
/** Selects the current handler owner for a value update without reentry. */
|
|
4995
|
-
readonly self: Source extends ValuedStateIdentifier<States>
|
|
4996
|
-
? StateUpdateSelectionForNode<States, NodeByIdentifier<States, Source>, Source, "branch">
|
|
4997
|
-
: {}
|
|
4998
|
-
/** Addresses the root and its retained value from any active descendant. */
|
|
4999
|
-
readonly root: "" extends ActiveStateKey<States> ?
|
|
5000
|
-
& SelectionNode<
|
|
5001
|
-
States,
|
|
5002
|
-
States[""],
|
|
5003
|
-
"",
|
|
5004
|
-
"branch",
|
|
5005
|
-
(BranchTargetBuilder<States, Source> extends { readonly "": infer Builder } ? Builder : never)
|
|
5006
|
-
>
|
|
5007
|
-
& StateUpdateSelectionForNode<States, States[""], "", "branch">
|
|
5008
|
-
: never
|
|
5009
|
-
/** Handles the trigger without selecting a destination. */
|
|
5010
|
-
readonly none: SelectionValue<TargetBuilder<States, Source>["none"], never, "none", "local">
|
|
5011
|
-
/** Selects a destination or updates the nearest active compound scope. */
|
|
5012
|
-
readonly local: LocalTargetSelector<States, Source>
|
|
5013
|
-
/** Selects a destination or updates a valued active ancestor under the current root. */
|
|
5014
|
-
readonly branch: BranchTargetSelector<States, Source>
|
|
5015
|
-
/** Selects a complete destination under any top-level state. */
|
|
5016
|
-
readonly full: FullTargetSelector<States>
|
|
5017
|
-
/** Restores a shallow or deep history pseudo-state. */
|
|
5018
|
-
readonly history: States[""] extends { readonly states: infer Children extends StateSchemas }
|
|
5019
|
-
? HistorySelectionTree<States, Children, "", RootBuilder<HistoryTargetBuilder<States>>>
|
|
5020
|
-
: {}
|
|
5021
|
-
}
|
|
5022
|
-
|
|
5023
4846
|
/** Definition-time selector that can choose only a valid top-level initial entry. */
|
|
5024
4847
|
type InitialTargetSelector<States extends StateSchemas> = {
|
|
5025
4848
|
readonly [Key in Extract<ActiveStateKey<States>, keyof InitialBuilder<States>>]: States[Key] extends
|
|
@@ -5057,13 +4880,8 @@ export declare namespace Machine {
|
|
|
5057
4880
|
/** Event that selected this handler, narrowed by its `_tag`. */
|
|
5058
4881
|
readonly event: EventByTag<Events, EventTag>
|
|
5059
4882
|
|
|
5060
|
-
/**
|
|
5061
|
-
|
|
5062
|
-
* handler. Each builder documents which existing state values it keeps.
|
|
5063
|
-
*
|
|
5064
|
-
* @since 0.4.0
|
|
5065
|
-
*/
|
|
5066
|
-
readonly target: TargetBuilder<States, StateId>
|
|
4883
|
+
/** Value owned by the logical root. */
|
|
4884
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5067
4885
|
}
|
|
5068
4886
|
|
|
5069
4887
|
/**
|
|
@@ -5108,6 +4926,8 @@ export declare namespace Machine {
|
|
|
5108
4926
|
readonly children: ChildOwner<EventOf<InputEvents>>
|
|
5109
4927
|
/** Value owned by the state that owns this invocation. */
|
|
5110
4928
|
readonly state: StateByIdentifier<States, StateId>
|
|
4929
|
+
/** Value owned by the logical root. */
|
|
4930
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5111
4931
|
/** Value owned by the nearest schema-backed ancestor, when one exists. */
|
|
5112
4932
|
readonly containingState: ParentStateValue<States, StateId>
|
|
5113
4933
|
/** Schema-backed ancestor values keyed by their complete state paths. */
|
|
@@ -5141,8 +4961,8 @@ export declare namespace Machine {
|
|
|
5141
4961
|
readonly containingState: ParentStateValue<States, StateId>
|
|
5142
4962
|
/** Schema-backed ancestor values keyed by their complete state paths. */
|
|
5143
4963
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
5144
|
-
/**
|
|
5145
|
-
readonly
|
|
4964
|
+
/** Value owned by the logical root. */
|
|
4965
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5146
4966
|
/** Latest active lifecycle snapshot published by the invoked logic or child. */
|
|
5147
4967
|
readonly snapshot: Extract<RuntimeSnapshot<State, Error, Output>, { readonly status: "active" }>
|
|
5148
4968
|
}
|
|
@@ -5172,8 +4992,8 @@ export declare namespace Machine {
|
|
|
5172
4992
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
5173
4993
|
/** Complete owning-machine configuration captured for this transition. */
|
|
5174
4994
|
readonly snapshot: Snapshot<States>
|
|
5175
|
-
/**
|
|
5176
|
-
readonly
|
|
4995
|
+
/** Value owned by the logical root. */
|
|
4996
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5177
4997
|
/** Successful output produced by the invocation. */
|
|
5178
4998
|
readonly output: Output
|
|
5179
4999
|
}
|
|
@@ -5198,8 +5018,8 @@ export declare namespace Machine {
|
|
|
5198
5018
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
5199
5019
|
/** Complete owning-machine configuration captured for this transition. */
|
|
5200
5020
|
readonly snapshot: Snapshot<States>
|
|
5201
|
-
/**
|
|
5202
|
-
readonly
|
|
5021
|
+
/** Value owned by the logical root. */
|
|
5022
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5203
5023
|
/** Next element emitted by the invoked Stream. */
|
|
5204
5024
|
readonly element: Element
|
|
5205
5025
|
}
|
|
@@ -5224,8 +5044,8 @@ export declare namespace Machine {
|
|
|
5224
5044
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
5225
5045
|
/** Complete owning-machine configuration captured for this transition. */
|
|
5226
5046
|
readonly snapshot: Snapshot<States>
|
|
5227
|
-
/**
|
|
5228
|
-
readonly
|
|
5047
|
+
/** Value owned by the logical root. */
|
|
5048
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5229
5049
|
/** Typed failure produced by the invocation. */
|
|
5230
5050
|
readonly error: Error
|
|
5231
5051
|
}
|
|
@@ -5255,14 +5075,8 @@ export declare namespace Machine {
|
|
|
5255
5075
|
/** Lifecycle event retained while the eventless transition is evaluated. */
|
|
5256
5076
|
readonly event: LifecycleEvent<Events>
|
|
5257
5077
|
|
|
5258
|
-
/**
|
|
5259
|
-
|
|
5260
|
-
* eventless handler. Each builder documents which existing state values it
|
|
5261
|
-
* keeps.
|
|
5262
|
-
*
|
|
5263
|
-
* @since 0.4.0
|
|
5264
|
-
*/
|
|
5265
|
-
readonly target: TargetBuilder<States, StateId>
|
|
5078
|
+
/** Value owned by the logical root. */
|
|
5079
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5266
5080
|
}
|
|
5267
5081
|
|
|
5268
5082
|
/**
|
|
@@ -5292,14 +5106,8 @@ export declare namespace Machine {
|
|
|
5292
5106
|
/** Output produced by the completed final child or parallel regions. */
|
|
5293
5107
|
readonly output: CompletionOutputByIdentifier<States, StateId>
|
|
5294
5108
|
|
|
5295
|
-
/**
|
|
5296
|
-
|
|
5297
|
-
* state completes. Each builder documents which existing state values it
|
|
5298
|
-
* keeps.
|
|
5299
|
-
*
|
|
5300
|
-
* @since 0.4.0
|
|
5301
|
-
*/
|
|
5302
|
-
readonly target: TargetBuilder<States, StateId>
|
|
5109
|
+
/** Value owned by the logical root. */
|
|
5110
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5303
5111
|
}
|
|
5304
5112
|
|
|
5305
5113
|
/** Context passed to a transient choice resolver. There is no `state` value. */
|
|
@@ -5325,8 +5133,8 @@ export declare namespace Machine {
|
|
|
5325
5133
|
}
|
|
5326
5134
|
/** Lifecycle event that led to the transient choice. */
|
|
5327
5135
|
readonly event: LifecycleEvent<Events>
|
|
5328
|
-
/**
|
|
5329
|
-
readonly
|
|
5136
|
+
/** Value owned by the logical root. */
|
|
5137
|
+
readonly root: StateByIdentifier<States, Extract<"", StateIdentifier<States>>>
|
|
5330
5138
|
}
|
|
5331
5139
|
|
|
5332
5140
|
/**
|
|
@@ -5423,7 +5231,7 @@ export declare namespace Machine {
|
|
|
5423
5231
|
*
|
|
5424
5232
|
* Handlers return snapshots for complete state replacement, target builder
|
|
5425
5233
|
* results for path-safe partial transitions, state-value updates, or
|
|
5426
|
-
* an explicit targetless result. In a machine definition, select `
|
|
5234
|
+
* an explicit targetless result. In a machine definition, select `{ none: true }`;
|
|
5427
5235
|
* its optional resolver returns `undefined`. Raw decoded state values are
|
|
5428
5236
|
* not accepted as transition targets.
|
|
5429
5237
|
*
|
|
@@ -5521,8 +5329,8 @@ export declare namespace Machine {
|
|
|
5521
5329
|
* @category utility types
|
|
5522
5330
|
* @since 0.4.0
|
|
5523
5331
|
*/
|
|
5524
|
-
export type EventTransitionReturn<Transition> = Transition extends
|
|
5525
|
-
|
|
5332
|
+
export type EventTransitionReturn<Transition> = Transition extends
|
|
5333
|
+
{ readonly initial: TargetReference<any, infer P, any> } ? InitialTarget<P>
|
|
5526
5334
|
: Transition extends { readonly resolve?: infer Resolve } ?
|
|
5527
5335
|
NonNullable<Resolve> extends (...args: any) => infer Ret ? Ret : never
|
|
5528
5336
|
: never
|
|
@@ -5557,7 +5365,9 @@ export declare namespace Machine {
|
|
|
5557
5365
|
* @category utility types
|
|
5558
5366
|
* @since 0.4.0
|
|
5559
5367
|
*/
|
|
5560
|
-
export type InvokeResolvedSource<Source> = Source extends
|
|
5368
|
+
export type InvokeResolvedSource<Source> = Source extends LazyProgramValue ? Source
|
|
5369
|
+
: Source extends (...args: any) => infer Resolved ? Resolved
|
|
5370
|
+
: Source
|
|
5561
5371
|
|
|
5562
5372
|
type InvokeFactoryResult<Source> = Source extends (...args: any) => infer Resolved ? Resolved : never
|
|
5563
5373
|
|
|
@@ -5612,8 +5422,7 @@ export declare namespace Machine {
|
|
|
5612
5422
|
export type InvokeInitialError<Invoke> = Invoke extends {
|
|
5613
5423
|
readonly [InvokeTypeId]: { readonly initialError: Types.Covariant<infer InitialError> }
|
|
5614
5424
|
} ? InitialError
|
|
5615
|
-
: InvokeLogic<Invoke
|
|
5616
|
-
: never
|
|
5425
|
+
: LogicInitialErrorOf<InvokeLogic<Invoke>>
|
|
5617
5426
|
/**
|
|
5618
5427
|
* Extracts the runtime error from an invoked child process.
|
|
5619
5428
|
*
|
|
@@ -5623,8 +5432,7 @@ export declare namespace Machine {
|
|
|
5623
5432
|
export type InvokeRuntimeError<Invoke> = Invoke extends {
|
|
5624
5433
|
readonly [InvokeTypeId]: { readonly error: Types.Covariant<infer Error> }
|
|
5625
5434
|
} ? Error
|
|
5626
|
-
: InvokeLogic<Invoke
|
|
5627
|
-
: never
|
|
5435
|
+
: LogicErrorOf<InvokeLogic<Invoke>>
|
|
5628
5436
|
/**
|
|
5629
5437
|
* Extracts the output from an invoked child process.
|
|
5630
5438
|
*
|
|
@@ -5634,8 +5442,7 @@ export declare namespace Machine {
|
|
|
5634
5442
|
export type InvokeOutput<Invoke> = Invoke extends {
|
|
5635
5443
|
readonly [InvokeTypeId]: { readonly output: Types.Covariant<infer Output> }
|
|
5636
5444
|
} ? Output
|
|
5637
|
-
: InvokeLogic<Invoke
|
|
5638
|
-
: never
|
|
5445
|
+
: LogicOutputOf<InvokeLogic<Invoke>>
|
|
5639
5446
|
/**
|
|
5640
5447
|
* Extracts the service requirements from an invoke source child process logic.
|
|
5641
5448
|
*
|
|
@@ -5645,8 +5452,7 @@ export declare namespace Machine {
|
|
|
5645
5452
|
export type InvokeServices<Invoke> = Invoke extends {
|
|
5646
5453
|
readonly [InvokeTypeId]: { readonly requirements: Types.Covariant<infer Requirements> }
|
|
5647
5454
|
} ? Requirements
|
|
5648
|
-
: InvokeLogic<Invoke
|
|
5649
|
-
: never
|
|
5455
|
+
: LogicServicesOf<InvokeLogic<Invoke>>
|
|
5650
5456
|
/**
|
|
5651
5457
|
* Extracts events emitted directly by an invoked child.
|
|
5652
5458
|
*
|
|
@@ -5747,24 +5553,8 @@ export declare namespace Machine {
|
|
|
5747
5553
|
| Effect.Services<ChoiceReturn<Config>>
|
|
5748
5554
|
| InvokeRequirements<Config>
|
|
5749
5555
|
|
|
5750
|
-
/** Type evidence retained by an authored transition without affecting runtime data. */
|
|
5751
|
-
export interface TransitionTyped<
|
|
5752
|
-
States extends StateSchemas,
|
|
5753
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5754
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5755
|
-
StateId extends StateNodeIdentifier<States>,
|
|
5756
|
-
Context,
|
|
5757
|
-
Reenter extends boolean,
|
|
5758
|
-
Acceptance extends TransitionAcceptance = "required"
|
|
5759
|
-
> {
|
|
5760
|
-
readonly [TransitionTypeId]: {
|
|
5761
|
-
readonly owner: Types.Covariant<readonly [States, Events, Emits, StateId, Context]>
|
|
5762
|
-
readonly acceptance: Types.Covariant<Acceptance>
|
|
5763
|
-
}
|
|
5764
|
-
}
|
|
5765
|
-
|
|
5766
5556
|
/** The only transition value accepted by machine handler APIs. */
|
|
5767
|
-
|
|
5557
|
+
type TransitionConfig<
|
|
5768
5558
|
States extends StateSchemas,
|
|
5769
5559
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5770
5560
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -5772,13 +5562,12 @@ export declare namespace Machine {
|
|
|
5772
5562
|
Context,
|
|
5773
5563
|
Reenter extends boolean = false,
|
|
5774
5564
|
Acceptance extends TransitionAcceptance = "required"
|
|
5775
|
-
> =
|
|
5565
|
+
> = Transition<States, StateId, Context, Events, Emits, {}, Reenter, Acceptance>
|
|
5776
5566
|
|
|
5777
5567
|
export type SelectionBuilder<Selection> = Selection extends TargetSelection<infer Builder, any, any, any> ? Builder
|
|
5778
5568
|
: never
|
|
5779
5569
|
export type SelectionKind<Selection> = Selection extends TargetSelection<any, any, infer Kind, any> ? Kind : never
|
|
5780
5570
|
export type SelectionPath<Selection> = Selection extends TargetSelection<any, infer Path, any, any> ? Path : never
|
|
5781
|
-
type SelectionScope<Selection> = Selection extends TargetSelection<any, any, any, infer Scope> ? Scope : never
|
|
5782
5571
|
export type TargetBuilderResult<Builder> =
|
|
5783
5572
|
| (Builder extends (...args: any) => infer Result ? Result : never)
|
|
5784
5573
|
| (Builder extends { readonly decoded: (...args: any) => infer Result } ? Result : never)
|
|
@@ -5787,20 +5576,9 @@ export declare namespace Machine {
|
|
|
5787
5576
|
TargetBuilderResult<Builder>
|
|
5788
5577
|
: never
|
|
5789
5578
|
|
|
5790
|
-
type RetainedUpdateOwner<
|
|
5791
|
-
States extends StateSchemas,
|
|
5792
|
-
Source extends StateNodeIdentifier<States>,
|
|
5793
|
-
Selection
|
|
5794
|
-
> = Extract<
|
|
5795
|
-
ParentStateIdentifier<Source>,
|
|
5796
|
-
ParentStateIdentifier<Extract<SelectionPath<Selection>, string>> & ValuedStateIdentifier<States>
|
|
5797
|
-
>
|
|
5798
|
-
|
|
5799
|
-
type RetainedOwnerSelector<Owner extends string> = () => TargetSelection<any, Owner, "state", "branch">
|
|
5800
|
-
|
|
5801
5579
|
/**
|
|
5802
5580
|
* Destination construction returned when a transition declares one retained
|
|
5803
|
-
* valued owner with
|
|
5581
|
+
* valued owner with a `{ target, update }` declaration.
|
|
5804
5582
|
*
|
|
5805
5583
|
* @category models
|
|
5806
5584
|
* @since 0.22.0
|
|
@@ -5852,83 +5630,12 @@ export declare namespace Machine {
|
|
|
5852
5630
|
& Omit<Context, "target">
|
|
5853
5631
|
& (SelectionKind<Selection> extends "none" ? {} : { readonly target: SelectionBuilder<Selection> })
|
|
5854
5632
|
|
|
5855
|
-
type StateUpdateResolveContext<
|
|
5856
|
-
States extends StateSchemas,
|
|
5857
|
-
Context,
|
|
5858
|
-
Owner extends ValuedStateIdentifier<States>
|
|
5859
|
-
> = Omit<Context, "target"> & {
|
|
5860
|
-
/** Decoded owner value from the pre-transition snapshot. */
|
|
5861
|
-
readonly current: StateByIdentifier<States, Owner>
|
|
5862
|
-
/** Constructs the complete replacement for the selected owner. */
|
|
5863
|
-
readonly owner: StateUpdateBuilder<States, Owner>
|
|
5864
|
-
}
|
|
5865
|
-
|
|
5866
|
-
type UpdatingTransitionResolveContext<
|
|
5867
|
-
States extends StateSchemas,
|
|
5868
|
-
Context,
|
|
5869
|
-
Selection,
|
|
5870
|
-
Owner extends ValuedStateIdentifier<States>
|
|
5871
|
-
> = Omit<Context, "target"> & {
|
|
5872
|
-
/** Decoded owner value from the pre-transition snapshot. */
|
|
5873
|
-
readonly current: StateByIdentifier<States, Owner>
|
|
5874
|
-
/** Constructs the selected topology and requires `.update(...)`. */
|
|
5875
|
-
readonly target: UpdatingTargetBuilder<SelectionBuilder<Selection>, States, Owner>
|
|
5876
|
-
/** Constructs the complete replacement for the retained owner. */
|
|
5877
|
-
readonly owner: StateUpdateBuilder<States, Owner>
|
|
5878
|
-
}
|
|
5879
|
-
|
|
5880
5633
|
/** Context capability available only to explicitly declinable resolvers. */
|
|
5881
5634
|
export interface DeclineCapability {
|
|
5882
5635
|
/** Declines this candidate and continues hierarchical transition selection. */
|
|
5883
5636
|
readonly decline: () => Declined
|
|
5884
5637
|
}
|
|
5885
5638
|
|
|
5886
|
-
export type TransitionResolver<
|
|
5887
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5888
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5889
|
-
Context,
|
|
5890
|
-
Selection
|
|
5891
|
-
> = (
|
|
5892
|
-
context: TransitionResolveContext<Context, Selection>,
|
|
5893
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
5894
|
-
) => SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined
|
|
5895
|
-
|
|
5896
|
-
export type DeclinableTransitionResolver<
|
|
5897
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5898
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5899
|
-
Context,
|
|
5900
|
-
Selection
|
|
5901
|
-
> = (
|
|
5902
|
-
context: TransitionResolveContext<Context, Selection> & DeclineCapability,
|
|
5903
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
5904
|
-
) =>
|
|
5905
|
-
| (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined)
|
|
5906
|
-
| Declined
|
|
5907
|
-
|
|
5908
|
-
/** @internal */
|
|
5909
|
-
type StateUpdateResolver<
|
|
5910
|
-
States extends StateSchemas,
|
|
5911
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5912
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5913
|
-
Context,
|
|
5914
|
-
Owner extends ValuedStateIdentifier<States>
|
|
5915
|
-
> = (
|
|
5916
|
-
context: StateUpdateResolveContext<States, Context, Owner>,
|
|
5917
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
5918
|
-
) => StateUpdate<States, Owner>
|
|
5919
|
-
|
|
5920
|
-
/** @internal */
|
|
5921
|
-
type DeclinableStateUpdateResolver<
|
|
5922
|
-
States extends StateSchemas,
|
|
5923
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5924
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5925
|
-
Context,
|
|
5926
|
-
Owner extends ValuedStateIdentifier<States>
|
|
5927
|
-
> = (
|
|
5928
|
-
context: StateUpdateResolveContext<States, Context, Owner> & DeclineCapability,
|
|
5929
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
5930
|
-
) => StateUpdate<States, Owner> | Declined
|
|
5931
|
-
|
|
5932
5639
|
/** One named destination declared by a branching transition. */
|
|
5933
5640
|
export interface TransitionBranchInput<
|
|
5934
5641
|
Selection extends TargetSelection<any, any, any> = TargetSelection<any, any, any>
|
|
@@ -5947,14 +5654,33 @@ export declare namespace Machine {
|
|
|
5947
5654
|
}
|
|
5948
5655
|
}
|
|
5949
5656
|
|
|
5657
|
+
type CompletedBranchResult<R> = R extends { readonly update: unknown }
|
|
5658
|
+
? R extends UpdatingStateConstruction<infer Target, infer S, infer Owner>
|
|
5659
|
+
? CombinedTarget<UnwrapConstruction<Target>, S, Owner>
|
|
5660
|
+
: R
|
|
5661
|
+
: R
|
|
5662
|
+
type SelectedConstruction<K extends string, R> = R extends { readonly update: unknown } ?
|
|
5663
|
+
R extends UpdatingStateConstruction<infer Target, infer S, infer Owner> ? {
|
|
5664
|
+
readonly update: SelectedBranchBuilder<StateUpdateBuilder<S, Owner>, K> extends infer B ? {
|
|
5665
|
+
readonly [M in keyof B]:
|
|
5666
|
+
StateUpdateBuilder<S, Owner>[Extract<M, keyof StateUpdateBuilder<S, Owner>>] extends
|
|
5667
|
+
(...args: infer A) => unknown
|
|
5668
|
+
? (...args: A) => SelectedBranch<K, CombinedTarget<UnwrapConstruction<Target>, S, Owner>>
|
|
5669
|
+
: never
|
|
5670
|
+
} :
|
|
5671
|
+
never
|
|
5672
|
+
}
|
|
5673
|
+
: SelectedBranch<K, R> :
|
|
5674
|
+
SelectedBranch<K, R>
|
|
5950
5675
|
type SelectedBranchCallable<Callable, Key extends string> = Callable extends {
|
|
5951
5676
|
(...args: infer Arguments1): infer Result1
|
|
5952
5677
|
(...args: infer Arguments2): infer Result2
|
|
5953
5678
|
} ? {
|
|
5954
|
-
(...args: Arguments1):
|
|
5955
|
-
(...args: Arguments2):
|
|
5679
|
+
(...args: Arguments1): SelectedConstruction<Key, Result1>
|
|
5680
|
+
(...args: Arguments2): SelectedConstruction<Key, Result2>
|
|
5956
5681
|
}
|
|
5957
|
-
: Callable extends (...args: infer Arguments) => infer Result ?
|
|
5682
|
+
: Callable extends (...args: infer Arguments) => infer Result ?
|
|
5683
|
+
(...args: Arguments) => SelectedConstruction<Key, Result>
|
|
5958
5684
|
: {}
|
|
5959
5685
|
|
|
5960
5686
|
type SelectedBranchBuilderProperties<Builder, Key extends string> = {
|
|
@@ -5978,7 +5704,7 @@ export declare namespace Machine {
|
|
|
5978
5704
|
export type BranchSelectionResult<Branches extends Readonly<Record<string, TransitionBranchInput>>> = {
|
|
5979
5705
|
readonly [Key in Extract<keyof Branches, string>]: SelectedBranch<
|
|
5980
5706
|
Key,
|
|
5981
|
-
SelectedTargetResult<Branches[Key]["target"]
|
|
5707
|
+
CompletedBranchResult<SelectedTargetResult<Branches[Key]["target"]>>
|
|
5982
5708
|
>
|
|
5983
5709
|
}[Extract<keyof Branches, string>]
|
|
5984
5710
|
|
|
@@ -5987,108 +5713,6 @@ export declare namespace Machine {
|
|
|
5987
5713
|
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5988
5714
|
> = Omit<Context, "target"> & { readonly select: BranchSelectors<Branches> }
|
|
5989
5715
|
|
|
5990
|
-
export type TransitionBranchesResolver<
|
|
5991
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5992
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5993
|
-
Context,
|
|
5994
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5995
|
-
> = (
|
|
5996
|
-
context: TransitionBranchesResolveContext<Context, Branches>,
|
|
5997
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
5998
|
-
) => BranchSelectionResult<Branches>
|
|
5999
|
-
|
|
6000
|
-
export type DeclinableTransitionBranchesResolver<
|
|
6001
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6002
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6003
|
-
Context,
|
|
6004
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6005
|
-
> = (
|
|
6006
|
-
context: TransitionBranchesResolveContext<Context, Branches> & DeclineCapability,
|
|
6007
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6008
|
-
) => BranchSelectionResult<Branches> | Declined
|
|
6009
|
-
|
|
6010
|
-
/** @internal Type evidence retained by a transition authored through its bound selector. */
|
|
6011
|
-
export interface TransitionBuilderEvidence<out Result, out Acceptance extends TransitionAcceptance> {
|
|
6012
|
-
readonly [TransitionBuilderTypeId]: {
|
|
6013
|
-
readonly result: Types.Covariant<Result>
|
|
6014
|
-
readonly acceptance: Types.Covariant<Acceptance>
|
|
6015
|
-
}
|
|
6016
|
-
}
|
|
6017
|
-
|
|
6018
|
-
type TransitionRequiredOptions = {
|
|
6019
|
-
/** Keeps the transition required. The resolver cannot return `decline()`. */
|
|
6020
|
-
readonly declinable?: false
|
|
6021
|
-
readonly reenter?: never
|
|
6022
|
-
}
|
|
6023
|
-
|
|
6024
|
-
type TransitionDeclinableOptions = {
|
|
6025
|
-
/** Adds `decline()` to the resolver context and permits declining this candidate. */
|
|
6026
|
-
readonly declinable: true
|
|
6027
|
-
readonly reenter?: never
|
|
6028
|
-
}
|
|
6029
|
-
|
|
6030
|
-
type BuiltTransition<
|
|
6031
|
-
States extends StateSchemas,
|
|
6032
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6033
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6034
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6035
|
-
Context,
|
|
6036
|
-
Reenter extends boolean,
|
|
6037
|
-
Result,
|
|
6038
|
-
Acceptance extends TransitionAcceptance
|
|
6039
|
-
> =
|
|
6040
|
-
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6041
|
-
& TransitionBuilderEvidence<Result, Acceptance>
|
|
6042
|
-
|
|
6043
|
-
interface TransitionResolveRequired<
|
|
6044
|
-
States extends StateSchemas,
|
|
6045
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6046
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6047
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6048
|
-
Context,
|
|
6049
|
-
Reenter extends boolean,
|
|
6050
|
-
Selection extends TargetSelection<any, any, any>
|
|
6051
|
-
> {
|
|
6052
|
-
(
|
|
6053
|
-
resolve: TransitionResolver<Events, Emits, Context, Selection>,
|
|
6054
|
-
options?: TransitionRequiredOptions
|
|
6055
|
-
): BuiltTransition<
|
|
6056
|
-
States,
|
|
6057
|
-
Events,
|
|
6058
|
-
Emits,
|
|
6059
|
-
StateId,
|
|
6060
|
-
Context,
|
|
6061
|
-
Reenter,
|
|
6062
|
-
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
6063
|
-
"required"
|
|
6064
|
-
>
|
|
6065
|
-
}
|
|
6066
|
-
|
|
6067
|
-
interface TransitionResolveDeclinable<
|
|
6068
|
-
States extends StateSchemas,
|
|
6069
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6070
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6071
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6072
|
-
Context,
|
|
6073
|
-
Reenter extends boolean,
|
|
6074
|
-
Selection extends TargetSelection<any, any, any>
|
|
6075
|
-
> {
|
|
6076
|
-
(
|
|
6077
|
-
resolve: DeclinableTransitionResolver<Events, Emits, Context, Selection>,
|
|
6078
|
-
options: TransitionDeclinableOptions
|
|
6079
|
-
): BuiltTransition<
|
|
6080
|
-
States,
|
|
6081
|
-
Events,
|
|
6082
|
-
Emits,
|
|
6083
|
-
StateId,
|
|
6084
|
-
Context,
|
|
6085
|
-
Reenter,
|
|
6086
|
-
| (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined)
|
|
6087
|
-
| Declined,
|
|
6088
|
-
"declinable"
|
|
6089
|
-
>
|
|
6090
|
-
}
|
|
6091
|
-
|
|
6092
5716
|
type ConstructionCallbacks<Context, Builder, Result> = {
|
|
6093
5717
|
readonly [
|
|
6094
5718
|
Method in Extract<keyof Builder, "from" | "decoded"> as Builder[Method] extends (...args: infer Args) => unknown
|
|
@@ -6100,481 +5724,6 @@ export declare namespace Machine {
|
|
|
6100
5724
|
never
|
|
6101
5725
|
}
|
|
6102
5726
|
|
|
6103
|
-
type GuardedTransition<
|
|
6104
|
-
States extends StateSchemas,
|
|
6105
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6106
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6107
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6108
|
-
Context,
|
|
6109
|
-
Reenter extends boolean,
|
|
6110
|
-
Selection extends TargetSelection<any, any, any>
|
|
6111
|
-
> =
|
|
6112
|
-
& ConstructionCallbacks<
|
|
6113
|
-
Omit<Context, "target">,
|
|
6114
|
-
SelectionBuilder<Selection>,
|
|
6115
|
-
BuiltTransition<
|
|
6116
|
-
States,
|
|
6117
|
-
Events,
|
|
6118
|
-
Emits,
|
|
6119
|
-
StateId,
|
|
6120
|
-
Context,
|
|
6121
|
-
Reenter,
|
|
6122
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6123
|
-
"declinable"
|
|
6124
|
-
>
|
|
6125
|
-
>
|
|
6126
|
-
& (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<
|
|
6127
|
-
States,
|
|
6128
|
-
Events,
|
|
6129
|
-
Emits,
|
|
6130
|
-
StateId,
|
|
6131
|
-
Context,
|
|
6132
|
-
Reenter,
|
|
6133
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6134
|
-
"declinable"
|
|
6135
|
-
>
|
|
6136
|
-
: {})
|
|
6137
|
-
& {
|
|
6138
|
-
readonly resolve: (
|
|
6139
|
-
resolve: TransitionResolver<Events, Emits, Context, Selection>,
|
|
6140
|
-
options?: TransitionRequiredOptions
|
|
6141
|
-
) => BuiltTransition<
|
|
6142
|
-
States,
|
|
6143
|
-
Events,
|
|
6144
|
-
Emits,
|
|
6145
|
-
StateId,
|
|
6146
|
-
Context,
|
|
6147
|
-
Reenter,
|
|
6148
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6149
|
-
"declinable"
|
|
6150
|
-
>
|
|
6151
|
-
}
|
|
6152
|
-
|
|
6153
|
-
/**
|
|
6154
|
-
* A selected transition target with target-specific resolver operations.
|
|
6155
|
-
*
|
|
6156
|
-
* **Example** (Constructing state while reentering)
|
|
6157
|
-
*
|
|
6158
|
-
* ```ts
|
|
6159
|
-
* Reset: (to) =>
|
|
6160
|
-
* to.branch.Ready().reenter().from(({ event }) => ({ count: event.count }))
|
|
6161
|
-
* ```
|
|
6162
|
-
*
|
|
6163
|
-
* @inlineType TransitionRequiredOptions
|
|
6164
|
-
* @inlineType TransitionDeclinableOptions
|
|
6165
|
-
*/
|
|
6166
|
-
export type TransitionTarget<
|
|
6167
|
-
States extends StateSchemas,
|
|
6168
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6169
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6170
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6171
|
-
Context,
|
|
6172
|
-
Reenter extends boolean,
|
|
6173
|
-
Acceptance extends TransitionAcceptance,
|
|
6174
|
-
Selection extends TargetSelection<any, any, any>
|
|
6175
|
-
> =
|
|
6176
|
-
& Selection
|
|
6177
|
-
& ("declinable" extends Acceptance ? {
|
|
6178
|
-
/** Declines this candidate before construction when the predicate is false. */
|
|
6179
|
-
readonly guard: (
|
|
6180
|
-
predicate: (context: Omit<Context, "target">) => boolean
|
|
6181
|
-
) => GuardedTransition<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6182
|
-
} :
|
|
6183
|
-
{})
|
|
6184
|
-
& ConstructionCallbacks<
|
|
6185
|
-
Omit<Context, "target">,
|
|
6186
|
-
SelectionBuilder<Selection>,
|
|
6187
|
-
BuiltTransition<
|
|
6188
|
-
States,
|
|
6189
|
-
Events,
|
|
6190
|
-
Emits,
|
|
6191
|
-
StateId,
|
|
6192
|
-
Context,
|
|
6193
|
-
Reenter,
|
|
6194
|
-
SelectedTargetResult<Selection>,
|
|
6195
|
-
"required"
|
|
6196
|
-
>
|
|
6197
|
-
>
|
|
6198
|
-
& (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<
|
|
6199
|
-
States,
|
|
6200
|
-
Events,
|
|
6201
|
-
Emits,
|
|
6202
|
-
StateId,
|
|
6203
|
-
Context,
|
|
6204
|
-
Reenter,
|
|
6205
|
-
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
6206
|
-
"required"
|
|
6207
|
-
>
|
|
6208
|
-
: {})
|
|
6209
|
-
& {
|
|
6210
|
-
/** Evaluates state construction after this transition is selected. */
|
|
6211
|
-
readonly resolve:
|
|
6212
|
-
& TransitionResolveRequired<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6213
|
-
& ("declinable" extends Acceptance ? TransitionResolveDeclinable<
|
|
6214
|
-
States,
|
|
6215
|
-
Events,
|
|
6216
|
-
Emits,
|
|
6217
|
-
StateId,
|
|
6218
|
-
Context,
|
|
6219
|
-
Reenter,
|
|
6220
|
-
Selection
|
|
6221
|
-
>
|
|
6222
|
-
: {})
|
|
6223
|
-
}
|
|
6224
|
-
& ([Reenter] extends [true] ? {
|
|
6225
|
-
/** Forces source exit and entry, preserving subsequent construction and guards. */
|
|
6226
|
-
readonly reenter: () => Omit<
|
|
6227
|
-
TransitionTarget<States, Events, Emits, StateId, Context, Reenter, Acceptance, Selection>,
|
|
6228
|
-
typeof Topology.TargetSelectionTypeId
|
|
6229
|
-
>
|
|
6230
|
-
} :
|
|
6231
|
-
{})
|
|
6232
|
-
& (SelectionKind<Selection> extends "state" ?
|
|
6233
|
-
SelectionScope<Selection> extends "local" | "branch" ?
|
|
6234
|
-
RetainedUpdateOwner<States, StateId, Selection> extends infer Owner extends ValuedStateIdentifier<States> ?
|
|
6235
|
-
[Owner] extends [never] ? {}
|
|
6236
|
-
: {
|
|
6237
|
-
/** Declares one valued owner retained by the selected topology. */
|
|
6238
|
-
readonly updating: <SelectedOwner extends Owner>(
|
|
6239
|
-
owner: RetainedOwnerSelector<SelectedOwner>
|
|
6240
|
-
) => UpdatingTransitionTarget<
|
|
6241
|
-
States,
|
|
6242
|
-
Events,
|
|
6243
|
-
Emits,
|
|
6244
|
-
StateId,
|
|
6245
|
-
Context,
|
|
6246
|
-
Reenter,
|
|
6247
|
-
Acceptance,
|
|
6248
|
-
Selection,
|
|
6249
|
-
SelectedOwner
|
|
6250
|
-
>
|
|
6251
|
-
}
|
|
6252
|
-
: {}
|
|
6253
|
-
: {}
|
|
6254
|
-
: {})
|
|
6255
|
-
|
|
6256
|
-
type UpdatingConstructionCallbacks<Context, Builder, OwnerBuilder, Result> = {
|
|
6257
|
-
readonly [
|
|
6258
|
-
Method in Extract<keyof Builder & keyof OwnerBuilder, "from" | "decoded"> as Builder[Method] extends
|
|
6259
|
-
(...args: infer Args) => unknown ? Args extends readonly [unknown?] ? Method : never : never
|
|
6260
|
-
]: Builder[Method] extends (...args: infer Args) => unknown ?
|
|
6261
|
-
OwnerBuilder[Method] extends (value: infer Update) => unknown ?
|
|
6262
|
-
(construct: (context: Context) => { readonly target: Args[0]; readonly update: Update }) => Result
|
|
6263
|
-
: never :
|
|
6264
|
-
never
|
|
6265
|
-
}
|
|
6266
|
-
|
|
6267
|
-
type UpdatingCallbacks<
|
|
6268
|
-
States extends StateSchemas,
|
|
6269
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6270
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6271
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6272
|
-
Context,
|
|
6273
|
-
Reenter extends boolean,
|
|
6274
|
-
Selection extends TargetSelection<any, any, "state">,
|
|
6275
|
-
Owner extends ValuedStateIdentifier<States>,
|
|
6276
|
-
Acceptance extends TransitionAcceptance
|
|
6277
|
-
> = UpdatingConstructionCallbacks<
|
|
6278
|
-
Omit<UpdatingTransitionResolveContext<States, Context, Selection, Owner>, "owner" | "target">,
|
|
6279
|
-
SelectionBuilder<Selection>,
|
|
6280
|
-
StateUpdateBuilder<States, Owner>,
|
|
6281
|
-
BuiltTransition<
|
|
6282
|
-
States,
|
|
6283
|
-
Events,
|
|
6284
|
-
Emits,
|
|
6285
|
-
StateId,
|
|
6286
|
-
Context,
|
|
6287
|
-
Reenter,
|
|
6288
|
-
| CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>
|
|
6289
|
-
| (Acceptance extends "declinable" ? Declined : never),
|
|
6290
|
-
Acceptance
|
|
6291
|
-
>
|
|
6292
|
-
>
|
|
6293
|
-
|
|
6294
|
-
type GuardedUpdatingTransition<
|
|
6295
|
-
States extends StateSchemas,
|
|
6296
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6297
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6298
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6299
|
-
Context,
|
|
6300
|
-
Reenter extends boolean,
|
|
6301
|
-
Selection extends TargetSelection<any, any, "state">,
|
|
6302
|
-
Owner extends ValuedStateIdentifier<States>
|
|
6303
|
-
> = UpdatingCallbacks<States, Events, Emits, StateId, Context, Reenter, Selection, Owner, "declinable"> & {
|
|
6304
|
-
readonly resolve: (
|
|
6305
|
-
resolve: (
|
|
6306
|
-
context: UpdatingTransitionResolveContext<States, Context, Selection, Owner>,
|
|
6307
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6308
|
-
) => CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>,
|
|
6309
|
-
options?: TransitionRequiredOptions
|
|
6310
|
-
) => BuiltTransition<
|
|
6311
|
-
States,
|
|
6312
|
-
Events,
|
|
6313
|
-
Emits,
|
|
6314
|
-
StateId,
|
|
6315
|
-
Context,
|
|
6316
|
-
Reenter,
|
|
6317
|
-
CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner> | Declined,
|
|
6318
|
-
"declinable"
|
|
6319
|
-
>
|
|
6320
|
-
}
|
|
6321
|
-
|
|
6322
|
-
/**
|
|
6323
|
-
* A topology selection that requires one retained owner replacement.
|
|
6324
|
-
*
|
|
6325
|
-
* `.from` constructs both values from schema inputs; `.decoded` accepts both
|
|
6326
|
-
* decoded values. Both callbacks return `{ target, update }` and read the same
|
|
6327
|
-
* pre-transition snapshot. Use `.resolve` for explicit child construction,
|
|
6328
|
-
* mixed construction methods, or queued commands.
|
|
6329
|
-
*
|
|
6330
|
-
* **Example** (Guarding an atomic destination and owner update)
|
|
6331
|
-
*
|
|
6332
|
-
* ```ts
|
|
6333
|
-
* Save: (to) => to.local.Saving().updating(to.root)
|
|
6334
|
-
* .guard(({ current }) => current.draft.length > 0)
|
|
6335
|
-
* .from(({ current }) => ({
|
|
6336
|
-
* target: { text: current.draft },
|
|
6337
|
-
* update: { ...current, attempts: current.attempts + 1 }
|
|
6338
|
-
* }))
|
|
6339
|
-
* ```
|
|
6340
|
-
*/
|
|
6341
|
-
export type UpdatingTransitionTarget<
|
|
6342
|
-
States extends StateSchemas,
|
|
6343
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6344
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6345
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6346
|
-
Context,
|
|
6347
|
-
Reenter extends boolean,
|
|
6348
|
-
Acceptance extends TransitionAcceptance,
|
|
6349
|
-
Selection extends TargetSelection<any, any, "state">,
|
|
6350
|
-
Owner extends ValuedStateIdentifier<States>
|
|
6351
|
-
> =
|
|
6352
|
-
& Selection
|
|
6353
|
-
& UpdatingCallbacks<States, Events, Emits, StateId, Context, Reenter, Selection, Owner, "required">
|
|
6354
|
-
& ([Reenter] extends [true] ? {
|
|
6355
|
-
readonly reenter: () => Omit<
|
|
6356
|
-
UpdatingTransitionTarget<States, Events, Emits, StateId, Context, Reenter, Acceptance, Selection, Owner>,
|
|
6357
|
-
typeof Topology.TargetSelectionTypeId
|
|
6358
|
-
>
|
|
6359
|
-
} :
|
|
6360
|
-
{})
|
|
6361
|
-
& ("declinable" extends Acceptance ? {
|
|
6362
|
-
/** Declines before either value is constructed or any commands are enqueued. */
|
|
6363
|
-
readonly guard: (
|
|
6364
|
-
predicate: (
|
|
6365
|
-
context: Omit<UpdatingTransitionResolveContext<States, Context, Selection, Owner>, "owner" | "target">
|
|
6366
|
-
) => boolean
|
|
6367
|
-
) => GuardedUpdatingTransition<States, Events, Emits, StateId, Context, Reenter, Selection, Owner>
|
|
6368
|
-
} :
|
|
6369
|
-
{})
|
|
6370
|
-
& {
|
|
6371
|
-
/** @internal */
|
|
6372
|
-
readonly "~effect/Machine/UpdatingTransitionTarget": Owner
|
|
6373
|
-
readonly resolve:
|
|
6374
|
-
& ((
|
|
6375
|
-
resolve: (
|
|
6376
|
-
context: UpdatingTransitionResolveContext<States, Context, Selection, Owner>,
|
|
6377
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6378
|
-
) => CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>,
|
|
6379
|
-
options?: TransitionRequiredOptions
|
|
6380
|
-
) => BuiltTransition<
|
|
6381
|
-
States,
|
|
6382
|
-
Events,
|
|
6383
|
-
Emits,
|
|
6384
|
-
StateId,
|
|
6385
|
-
Context,
|
|
6386
|
-
Reenter,
|
|
6387
|
-
CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>,
|
|
6388
|
-
"required"
|
|
6389
|
-
>)
|
|
6390
|
-
& ("declinable" extends Acceptance ? (
|
|
6391
|
-
resolve: (
|
|
6392
|
-
context: UpdatingTransitionResolveContext<States, Context, Selection, Owner> & DeclineCapability,
|
|
6393
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6394
|
-
) => CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner> | Declined,
|
|
6395
|
-
options: TransitionDeclinableOptions
|
|
6396
|
-
) => BuiltTransition<
|
|
6397
|
-
States,
|
|
6398
|
-
Events,
|
|
6399
|
-
Emits,
|
|
6400
|
-
StateId,
|
|
6401
|
-
Context,
|
|
6402
|
-
Reenter,
|
|
6403
|
-
CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner> | Declined,
|
|
6404
|
-
"declinable"
|
|
6405
|
-
>
|
|
6406
|
-
: {})
|
|
6407
|
-
}
|
|
6408
|
-
|
|
6409
|
-
/** @internal */
|
|
6410
|
-
interface StateUpdateTransitionRequired<
|
|
6411
|
-
States extends StateSchemas,
|
|
6412
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6413
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6414
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6415
|
-
Context,
|
|
6416
|
-
Reenter extends boolean,
|
|
6417
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6418
|
-
> {
|
|
6419
|
-
(
|
|
6420
|
-
resolve: StateUpdateResolver<
|
|
6421
|
-
States,
|
|
6422
|
-
Events,
|
|
6423
|
-
Emits,
|
|
6424
|
-
Context,
|
|
6425
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6426
|
-
>,
|
|
6427
|
-
options?: TransitionRequiredOptions
|
|
6428
|
-
): BuiltTransition<
|
|
6429
|
-
States,
|
|
6430
|
-
Events,
|
|
6431
|
-
Emits,
|
|
6432
|
-
StateId,
|
|
6433
|
-
Context,
|
|
6434
|
-
Reenter,
|
|
6435
|
-
SelectedTargetResult<Selection>,
|
|
6436
|
-
"required"
|
|
6437
|
-
>
|
|
6438
|
-
}
|
|
6439
|
-
|
|
6440
|
-
/** @internal */
|
|
6441
|
-
interface StateUpdateTransitionDeclinable<
|
|
6442
|
-
States extends StateSchemas,
|
|
6443
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6444
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6445
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6446
|
-
Context,
|
|
6447
|
-
Reenter extends boolean,
|
|
6448
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6449
|
-
> {
|
|
6450
|
-
(
|
|
6451
|
-
resolve: DeclinableStateUpdateResolver<
|
|
6452
|
-
States,
|
|
6453
|
-
Events,
|
|
6454
|
-
Emits,
|
|
6455
|
-
Context,
|
|
6456
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6457
|
-
>,
|
|
6458
|
-
options: TransitionDeclinableOptions
|
|
6459
|
-
): BuiltTransition<
|
|
6460
|
-
States,
|
|
6461
|
-
Events,
|
|
6462
|
-
Emits,
|
|
6463
|
-
StateId,
|
|
6464
|
-
Context,
|
|
6465
|
-
Reenter,
|
|
6466
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6467
|
-
"declinable"
|
|
6468
|
-
>
|
|
6469
|
-
}
|
|
6470
|
-
|
|
6471
|
-
type GuardedStateUpdateTransition<
|
|
6472
|
-
States extends StateSchemas,
|
|
6473
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6474
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6475
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6476
|
-
Context,
|
|
6477
|
-
Reenter extends boolean,
|
|
6478
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6479
|
-
> =
|
|
6480
|
-
& ConstructionCallbacks<
|
|
6481
|
-
Omit<
|
|
6482
|
-
StateUpdateResolveContext<States, Context, Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>>,
|
|
6483
|
-
"owner"
|
|
6484
|
-
>,
|
|
6485
|
-
SelectionBuilder<Selection>,
|
|
6486
|
-
BuiltTransition<
|
|
6487
|
-
States,
|
|
6488
|
-
Events,
|
|
6489
|
-
Emits,
|
|
6490
|
-
StateId,
|
|
6491
|
-
Context,
|
|
6492
|
-
Reenter,
|
|
6493
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6494
|
-
"declinable"
|
|
6495
|
-
>
|
|
6496
|
-
>
|
|
6497
|
-
& {
|
|
6498
|
-
readonly resolve: (
|
|
6499
|
-
resolve: StateUpdateResolver<
|
|
6500
|
-
States,
|
|
6501
|
-
Events,
|
|
6502
|
-
Emits,
|
|
6503
|
-
Context,
|
|
6504
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6505
|
-
>,
|
|
6506
|
-
options?: TransitionRequiredOptions
|
|
6507
|
-
) => BuiltTransition<
|
|
6508
|
-
States,
|
|
6509
|
-
Events,
|
|
6510
|
-
Emits,
|
|
6511
|
-
StateId,
|
|
6512
|
-
Context,
|
|
6513
|
-
Reenter,
|
|
6514
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6515
|
-
"declinable"
|
|
6516
|
-
>
|
|
6517
|
-
}
|
|
6518
|
-
|
|
6519
|
-
/** @internal */
|
|
6520
|
-
type StateUpdateTransition<
|
|
6521
|
-
States extends StateSchemas,
|
|
6522
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6523
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6524
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6525
|
-
Context,
|
|
6526
|
-
Reenter extends boolean,
|
|
6527
|
-
Acceptance extends TransitionAcceptance,
|
|
6528
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6529
|
-
> =
|
|
6530
|
-
& Selection
|
|
6531
|
-
& ([Reenter] extends [true] ? {
|
|
6532
|
-
/** Reenters the source while updating its retained valued ancestor. */
|
|
6533
|
-
readonly reenter: () => Omit<
|
|
6534
|
-
StateUpdateTransition<States, Events, Emits, StateId, Context, Reenter, Acceptance, Selection>,
|
|
6535
|
-
typeof Topology.TargetSelectionTypeId
|
|
6536
|
-
>
|
|
6537
|
-
} :
|
|
6538
|
-
{})
|
|
6539
|
-
& ("declinable" extends Acceptance ? {
|
|
6540
|
-
/** Declines before replacing the selected owner value. */
|
|
6541
|
-
readonly guard: (
|
|
6542
|
-
predicate: (
|
|
6543
|
-
context: Omit<
|
|
6544
|
-
StateUpdateResolveContext<
|
|
6545
|
-
States,
|
|
6546
|
-
Context,
|
|
6547
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6548
|
-
>,
|
|
6549
|
-
"owner"
|
|
6550
|
-
>
|
|
6551
|
-
) => boolean
|
|
6552
|
-
) => GuardedStateUpdateTransition<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6553
|
-
} :
|
|
6554
|
-
{})
|
|
6555
|
-
& ConstructionCallbacks<
|
|
6556
|
-
Omit<
|
|
6557
|
-
StateUpdateResolveContext<States, Context, Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>>,
|
|
6558
|
-
"owner"
|
|
6559
|
-
>,
|
|
6560
|
-
SelectionBuilder<Selection>,
|
|
6561
|
-
BuiltTransition<States, Events, Emits, StateId, Context, Reenter, SelectedTargetResult<Selection>, "required">
|
|
6562
|
-
>
|
|
6563
|
-
& {
|
|
6564
|
-
readonly resolve:
|
|
6565
|
-
& StateUpdateTransitionRequired<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6566
|
-
& ("declinable" extends Acceptance ? StateUpdateTransitionDeclinable<
|
|
6567
|
-
States,
|
|
6568
|
-
Events,
|
|
6569
|
-
Emits,
|
|
6570
|
-
StateId,
|
|
6571
|
-
Context,
|
|
6572
|
-
Reenter,
|
|
6573
|
-
Selection
|
|
6574
|
-
>
|
|
6575
|
-
: {})
|
|
6576
|
-
}
|
|
6577
|
-
|
|
6578
5727
|
/** @internal Type evidence retained by a machine initial-entry declaration. */
|
|
6579
5728
|
export interface InitialBuilderEvidence<out Selection> {
|
|
6580
5729
|
readonly [InitialBuilderTypeId]: Types.Covariant<Selection>
|
|
@@ -6660,919 +5809,152 @@ export declare namespace Machine {
|
|
|
6660
5809
|
) => ConstructionResult<Snapshot<{ readonly "": Root }>>
|
|
6661
5810
|
) => InitialBuilderEvidence<RootConfigurationSelection<Root>>
|
|
6662
5811
|
}
|
|
6663
|
-
) => InitialBuilderEvidence<TargetSelection<any, any, any>>
|
|
6664
|
-
|
|
6665
|
-
type TransitionSelectorNode<
|
|
6666
|
-
States extends StateSchemas,
|
|
6667
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6668
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6669
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6670
|
-
Context,
|
|
6671
|
-
Reenter extends boolean,
|
|
6672
|
-
Acceptance extends TransitionAcceptance,
|
|
6673
|
-
Node
|
|
6674
|
-
> = Node extends TargetSelection<any, any, "update"> ? StateUpdateTransition<
|
|
6675
|
-
States,
|
|
6676
|
-
Events,
|
|
6677
|
-
Emits,
|
|
6678
|
-
StateId,
|
|
6679
|
-
Context,
|
|
6680
|
-
Reenter,
|
|
6681
|
-
Acceptance,
|
|
6682
|
-
Node
|
|
6683
|
-
>
|
|
6684
|
-
: Node extends (...args: infer Args) => infer Selection ? Selection extends TargetSelection<any, any, any> ?
|
|
6685
|
-
& ((...args: Args) => TransitionTarget<
|
|
6686
|
-
States,
|
|
6687
|
-
Events,
|
|
6688
|
-
Emits,
|
|
6689
|
-
StateId,
|
|
6690
|
-
Context,
|
|
6691
|
-
Reenter,
|
|
6692
|
-
Acceptance,
|
|
6693
|
-
Selection
|
|
6694
|
-
>)
|
|
6695
|
-
& {
|
|
6696
|
-
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
6697
|
-
States,
|
|
6698
|
-
Events,
|
|
6699
|
-
Emits,
|
|
6700
|
-
StateId,
|
|
6701
|
-
Context,
|
|
6702
|
-
Reenter,
|
|
6703
|
-
Acceptance,
|
|
6704
|
-
Node[Key]
|
|
6705
|
-
>
|
|
6706
|
-
}
|
|
6707
|
-
: never
|
|
6708
|
-
: Node extends TargetSelection<any, any, any> ? TransitionTarget<
|
|
6709
|
-
States,
|
|
6710
|
-
Events,
|
|
6711
|
-
Emits,
|
|
6712
|
-
StateId,
|
|
6713
|
-
Context,
|
|
6714
|
-
Reenter,
|
|
6715
|
-
Acceptance,
|
|
6716
|
-
Node
|
|
6717
|
-
>
|
|
6718
|
-
: {
|
|
6719
|
-
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
6720
|
-
States,
|
|
6721
|
-
Events,
|
|
6722
|
-
Emits,
|
|
6723
|
-
StateId,
|
|
6724
|
-
Context,
|
|
6725
|
-
Reenter,
|
|
6726
|
-
Acceptance,
|
|
6727
|
-
Node[Key]
|
|
6728
|
-
>
|
|
6729
|
-
}
|
|
6730
|
-
|
|
6731
|
-
interface TransitionBranchesResolveRequired<
|
|
6732
|
-
States extends StateSchemas,
|
|
6733
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6734
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6735
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6736
|
-
Context,
|
|
6737
|
-
Reenter extends boolean,
|
|
6738
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6739
|
-
> {
|
|
6740
|
-
(
|
|
6741
|
-
resolve: TransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
6742
|
-
options?: TransitionRequiredOptions
|
|
6743
|
-
): BuiltTransition<
|
|
6744
|
-
States,
|
|
6745
|
-
Events,
|
|
6746
|
-
Emits,
|
|
6747
|
-
StateId,
|
|
6748
|
-
Context,
|
|
6749
|
-
Reenter,
|
|
6750
|
-
BranchSelectionResult<Branches>,
|
|
6751
|
-
"required"
|
|
6752
|
-
>
|
|
6753
|
-
}
|
|
6754
|
-
|
|
6755
|
-
interface TransitionBranchesResolveDeclinable<
|
|
6756
|
-
States extends StateSchemas,
|
|
6757
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6758
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6759
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6760
|
-
Context,
|
|
6761
|
-
Reenter extends boolean,
|
|
6762
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6763
|
-
> {
|
|
6764
|
-
(
|
|
6765
|
-
resolve: DeclinableTransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
6766
|
-
options: TransitionDeclinableOptions
|
|
6767
|
-
): BuiltTransition<
|
|
6768
|
-
States,
|
|
6769
|
-
Events,
|
|
6770
|
-
Emits,
|
|
6771
|
-
StateId,
|
|
6772
|
-
Context,
|
|
6773
|
-
Reenter,
|
|
6774
|
-
BranchSelectionResult<Branches> | Declined,
|
|
6775
|
-
"declinable"
|
|
6776
|
-
>
|
|
6777
|
-
}
|
|
6778
|
-
|
|
6779
|
-
type TransitionSelectorTargets<
|
|
6780
|
-
in out States extends StateSchemas,
|
|
6781
|
-
in out Events extends ReadonlyArray<TaggedSchema>,
|
|
6782
|
-
in out Emits extends ReadonlyArray<TaggedSchema>,
|
|
6783
|
-
in out StateId extends StateNodeIdentifier<States>,
|
|
6784
|
-
in out Context,
|
|
6785
|
-
in out Reenter extends boolean,
|
|
6786
|
-
in out Acceptance extends TransitionAcceptance
|
|
6787
|
-
> = {
|
|
6788
|
-
readonly [Key in keyof TargetSelector<States, StateId>]: TransitionSelectorNode<
|
|
6789
|
-
States,
|
|
6790
|
-
Events,
|
|
6791
|
-
Emits,
|
|
6792
|
-
StateId,
|
|
6793
|
-
Context,
|
|
6794
|
-
Key extends "self" ? false : Reenter,
|
|
6795
|
-
Acceptance,
|
|
6796
|
-
TargetSelector<States, StateId>[Key]
|
|
6797
|
-
>
|
|
6798
|
-
}
|
|
6799
|
-
|
|
6800
|
-
type TransitionBranchesTarget<
|
|
6801
|
-
States extends StateSchemas,
|
|
6802
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6803
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6804
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6805
|
-
Context,
|
|
6806
|
-
Reenter extends boolean,
|
|
6807
|
-
Acceptance extends TransitionAcceptance,
|
|
6808
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6809
|
-
> =
|
|
6810
|
-
& {
|
|
6811
|
-
/** Resolves exactly one declared branch after this transition is selected. */
|
|
6812
|
-
readonly resolve:
|
|
6813
|
-
& TransitionBranchesResolveRequired<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
6814
|
-
& ("declinable" extends Acceptance
|
|
6815
|
-
? TransitionBranchesResolveDeclinable<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
6816
|
-
: {})
|
|
6817
|
-
}
|
|
6818
|
-
& ([Reenter] extends [true] ? {
|
|
6819
|
-
readonly reenter: () => TransitionBranchesTarget<
|
|
6820
|
-
States,
|
|
6821
|
-
Events,
|
|
6822
|
-
Emits,
|
|
6823
|
-
StateId,
|
|
6824
|
-
Context,
|
|
6825
|
-
Reenter,
|
|
6826
|
-
Acceptance,
|
|
6827
|
-
Branches
|
|
6828
|
-
>
|
|
6829
|
-
} :
|
|
6830
|
-
{})
|
|
6831
|
-
|
|
6832
|
-
/** Selector supplied to inline transition declarations. */
|
|
6833
|
-
export interface TransitionSelector<
|
|
6834
|
-
in out States extends StateSchemas,
|
|
6835
|
-
in out Events extends ReadonlyArray<TaggedSchema>,
|
|
6836
|
-
in out Emits extends ReadonlyArray<TaggedSchema>,
|
|
6837
|
-
in out StateId extends StateNodeIdentifier<States>,
|
|
6838
|
-
in out Context,
|
|
6839
|
-
in out Reenter extends boolean,
|
|
6840
|
-
in out Acceptance extends TransitionAcceptance
|
|
6841
|
-
> extends TransitionSelectorTargets<States, Events, Emits, StateId, Context, Reenter, Acceptance> {
|
|
6842
|
-
/** Declares a closed set of named destinations for one resolver. */
|
|
6843
|
-
readonly branches: <const Branches extends Readonly<Record<string, TransitionBranchInput>>>(
|
|
6844
|
-
branches: Branches & ValidateTransitionBranchRecord<NoInfer<Branches>>
|
|
6845
|
-
) => TransitionBranchesTarget<States, Events, Emits, StateId, Context, Reenter, Acceptance, Branches>
|
|
6846
|
-
}
|
|
6847
|
-
|
|
6848
|
-
/** Inline transition declaration accepted by state and invocation handlers. */
|
|
6849
|
-
export type TransitionBuilderInput<
|
|
6850
|
-
States extends StateSchemas,
|
|
6851
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6852
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6853
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6854
|
-
Context,
|
|
6855
|
-
Reenter extends boolean,
|
|
6856
|
-
Acceptance extends TransitionAcceptance
|
|
6857
|
-
> = (
|
|
6858
|
-
to: TransitionSelector<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6859
|
-
) =>
|
|
6860
|
-
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6861
|
-
& TransitionBuilderEvidence<any, Acceptance>
|
|
6862
|
-
|
|
6863
|
-
export type InvokeTransition<
|
|
6864
|
-
States extends StateSchemas,
|
|
6865
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6866
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6867
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6868
|
-
Context
|
|
6869
|
-
> = TransitionConfig<States, Events, Emits, StateId, Context, true, TransitionAcceptance>
|
|
6870
|
-
|
|
6871
|
-
export type InvokeSource<Value, Context> = Value | ((context: Context) => Value)
|
|
6872
|
-
|
|
6873
|
-
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
6874
|
-
export interface InvokeOwned<
|
|
6875
|
-
States extends StateSchemas,
|
|
6876
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6877
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6878
|
-
StateId extends StateIdentifier<States>,
|
|
6879
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6880
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6881
|
-
> {
|
|
6882
|
-
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<
|
|
6883
|
-
readonly [States, Events, Emits, StateId, InputEvents, ParentEvents]
|
|
6884
|
-
>
|
|
6885
|
-
}
|
|
6886
|
-
|
|
6887
|
-
/** Type evidence retained by a completed state-owned invocation. */
|
|
6888
|
-
export interface InvokeTyped<
|
|
6889
|
-
Output,
|
|
6890
|
-
Error,
|
|
6891
|
-
Requirements,
|
|
6892
|
-
InitialError,
|
|
6893
|
-
Emits = never,
|
|
6894
|
-
ParentEvent = never,
|
|
6895
|
-
Outcomes = never
|
|
6896
|
-
> {
|
|
6897
|
-
readonly [InvokeTypeId]: {
|
|
6898
|
-
readonly output: Types.Covariant<Output>
|
|
6899
|
-
readonly error: Types.Covariant<Error>
|
|
6900
|
-
readonly requirements: Types.Covariant<Requirements>
|
|
6901
|
-
readonly initialError: Types.Covariant<InitialError>
|
|
6902
|
-
readonly emits: Types.Covariant<Emits>
|
|
6903
|
-
readonly parentEvents: Types.Covariant<ParentEvent>
|
|
6904
|
-
readonly outcomes: Types.Covariant<Outcomes>
|
|
6905
|
-
}
|
|
6906
|
-
}
|
|
6907
|
-
|
|
6908
|
-
type StoredInvokeConfig<
|
|
6909
|
-
States extends StateSchemas,
|
|
6910
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6911
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6912
|
-
StateId extends StateIdentifier<States>,
|
|
6913
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6914
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6915
|
-
> =
|
|
6916
|
-
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6917
|
-
& (
|
|
6918
|
-
| {
|
|
6919
|
-
readonly id: string
|
|
6920
|
-
readonly effect: (
|
|
6921
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6922
|
-
) => Effect.Effect<any, any, any>
|
|
6923
|
-
readonly stream?: never
|
|
6924
|
-
readonly after?: never
|
|
6925
|
-
readonly logic?: never
|
|
6926
|
-
readonly child?: never
|
|
6927
|
-
readonly address?: never
|
|
6928
|
-
readonly onDone?: unknown
|
|
6929
|
-
readonly onFailure?: unknown
|
|
6930
|
-
readonly onElement?: never
|
|
6931
|
-
readonly onSnapshot?: never
|
|
6932
|
-
}
|
|
6933
|
-
| {
|
|
6934
|
-
readonly id: string
|
|
6935
|
-
readonly stream: (
|
|
6936
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6937
|
-
) => Stream.Stream<any, any, any>
|
|
6938
|
-
readonly effect?: never
|
|
6939
|
-
readonly after?: never
|
|
6940
|
-
readonly logic?: never
|
|
6941
|
-
readonly child?: never
|
|
6942
|
-
readonly address?: never
|
|
6943
|
-
readonly onElement?: unknown
|
|
6944
|
-
readonly onDone: unknown
|
|
6945
|
-
readonly onFailure?: unknown
|
|
6946
|
-
readonly onSnapshot?: never
|
|
6947
|
-
}
|
|
6948
|
-
| {
|
|
6949
|
-
readonly id: string
|
|
6950
|
-
readonly after: InvokeSource<
|
|
6951
|
-
Duration.Input,
|
|
6952
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6953
|
-
>
|
|
6954
|
-
readonly effect?: never
|
|
6955
|
-
readonly stream?: never
|
|
6956
|
-
readonly logic?: never
|
|
6957
|
-
readonly child?: never
|
|
6958
|
-
readonly address?: never
|
|
6959
|
-
readonly onDone: unknown
|
|
6960
|
-
readonly onFailure?: never
|
|
6961
|
-
readonly onElement?: never
|
|
6962
|
-
readonly onSnapshot?: never
|
|
6963
|
-
}
|
|
6964
|
-
| {
|
|
6965
|
-
readonly id: string
|
|
6966
|
-
readonly address: string
|
|
6967
|
-
readonly logic: InvokeSource<
|
|
6968
|
-
Logic<any, any, any, any, any, any>,
|
|
6969
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6970
|
-
>
|
|
6971
|
-
readonly effect?: never
|
|
6972
|
-
readonly stream?: never
|
|
6973
|
-
readonly after?: never
|
|
6974
|
-
readonly child?: never
|
|
6975
|
-
readonly onDone?: unknown
|
|
6976
|
-
readonly onFailure?: unknown
|
|
6977
|
-
readonly onElement?: never
|
|
6978
|
-
readonly onSnapshot?: unknown
|
|
6979
|
-
}
|
|
6980
|
-
| {
|
|
6981
|
-
readonly child: ChildMachine.Any
|
|
6982
|
-
readonly input?:
|
|
6983
|
-
| {}
|
|
6984
|
-
| null
|
|
6985
|
-
| ((context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
6986
|
-
readonly id?: never
|
|
6987
|
-
readonly address?: never
|
|
6988
|
-
readonly effect?: never
|
|
6989
|
-
readonly stream?: never
|
|
6990
|
-
readonly after?: never
|
|
6991
|
-
readonly logic?: never
|
|
6992
|
-
readonly onDone?: unknown
|
|
6993
|
-
readonly onFailure?: unknown
|
|
6994
|
-
readonly onElement?: never
|
|
6995
|
-
readonly onSnapshot?: unknown
|
|
6996
|
-
}
|
|
6997
|
-
)
|
|
6998
|
-
|
|
6999
|
-
type StoredInvokeDefinition<
|
|
7000
|
-
States extends StateSchemas,
|
|
7001
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7002
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7003
|
-
StateId extends StateIdentifier<States>,
|
|
7004
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7005
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7006
|
-
> =
|
|
7007
|
-
| StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7008
|
-
| ReadonlyArray<StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
7009
|
-
|
|
7010
|
-
type LogicInitialEffectOf<Value> = Value extends { readonly initial: infer Initial } ?
|
|
7011
|
-
Initial extends (...args: ReadonlyArray<any>) => infer Result ? Result : never
|
|
7012
|
-
: never
|
|
7013
|
-
|
|
7014
|
-
type LogicRunEffectOf<Value> = Value extends { readonly run: infer Run } ?
|
|
7015
|
-
Run extends (...args: ReadonlyArray<any>) => infer Result ? Result : never
|
|
7016
|
-
: never
|
|
7017
|
-
|
|
7018
|
-
export type LogicStateOf<Value> = Effect.Success<LogicInitialEffectOf<Value>>
|
|
7019
|
-
export type LogicEventOf<Value> = Value extends { readonly initial: infer Initial } ?
|
|
7020
|
-
Initial extends (scope: infer LogicScope, ...args: ReadonlyArray<any>) => any ?
|
|
7021
|
-
LogicScope extends Logic.Scope<infer Event> ? Event : never
|
|
7022
|
-
: never
|
|
7023
|
-
: never
|
|
7024
|
-
export type LogicErrorOf<Value> = Effect.Error<LogicRunEffectOf<Value>>
|
|
7025
|
-
export type LogicServicesOf<Value> = Effect.Services<LogicInitialEffectOf<Value> | LogicRunEffectOf<Value>>
|
|
7026
|
-
export type LogicOutputOf<Value> = Effect.Success<LogicRunEffectOf<Value>>
|
|
7027
|
-
export type LogicInitialErrorOf<Value> = Effect.Error<LogicInitialEffectOf<Value>>
|
|
7028
|
-
|
|
7029
|
-
type RequiredInvokeChannel<Value, Channel extends string> = IsAny<Value> extends true ? Channel
|
|
7030
|
-
: [Value] extends [never] ? never
|
|
7031
|
-
: Channel
|
|
7032
|
-
|
|
7033
|
-
type InvokeBuilderResult<
|
|
7034
|
-
States extends StateSchemas,
|
|
7035
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7036
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7037
|
-
StateId extends StateIdentifier<States>,
|
|
7038
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7039
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7040
|
-
Output,
|
|
7041
|
-
Error,
|
|
7042
|
-
Requirements,
|
|
7043
|
-
InitialError,
|
|
7044
|
-
ChildEmits,
|
|
7045
|
-
ChildParentEvent,
|
|
7046
|
-
Outcomes
|
|
7047
|
-
> =
|
|
7048
|
-
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7049
|
-
& InvokeTyped<Output, Error, Requirements, InitialError, ChildEmits, ChildParentEvent, Outcomes>
|
|
7050
|
-
& { readonly [InvokeBuilderTypeId]: true }
|
|
7051
|
-
|
|
7052
|
-
/** Lifecycle handlers exposed according to the selected invocation source. */
|
|
7053
|
-
type InvokeBuilder<
|
|
7054
|
-
States extends StateSchemas,
|
|
7055
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7056
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7057
|
-
StateId extends StateIdentifier<States>,
|
|
7058
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7059
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7060
|
-
Output,
|
|
7061
|
-
Error,
|
|
7062
|
-
Requirements,
|
|
7063
|
-
InitialError,
|
|
7064
|
-
ChildEmits,
|
|
7065
|
-
ChildParentEvent,
|
|
7066
|
-
Element,
|
|
7067
|
-
Pending extends string,
|
|
7068
|
-
SnapshotHandler,
|
|
7069
|
-
Outcomes = never
|
|
7070
|
-
> =
|
|
7071
|
-
& ([Pending] extends [never] ? InvokeBuilderResult<
|
|
7072
|
-
States,
|
|
7073
|
-
Events,
|
|
7074
|
-
Emits,
|
|
7075
|
-
StateId,
|
|
7076
|
-
InputEvents,
|
|
7077
|
-
ParentEvents,
|
|
7078
|
-
Output,
|
|
7079
|
-
Error,
|
|
7080
|
-
Requirements,
|
|
7081
|
-
InitialError,
|
|
7082
|
-
ChildEmits,
|
|
7083
|
-
ChildParentEvent,
|
|
7084
|
-
Outcomes
|
|
7085
|
-
>
|
|
7086
|
-
: {})
|
|
7087
|
-
& ("done" extends Pending ? {
|
|
7088
|
-
/** Handles successful completion and exposes the invocation output. */
|
|
7089
|
-
readonly onDone: <
|
|
7090
|
-
const Handler extends InvokeTransition<
|
|
7091
|
-
States,
|
|
7092
|
-
Events,
|
|
7093
|
-
Emits,
|
|
7094
|
-
StateId,
|
|
7095
|
-
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
7096
|
-
>
|
|
7097
|
-
>(
|
|
7098
|
-
handler:
|
|
7099
|
-
& Handler
|
|
7100
|
-
& InvokeTransition<
|
|
7101
|
-
States,
|
|
7102
|
-
Events,
|
|
7103
|
-
Emits,
|
|
7104
|
-
StateId,
|
|
7105
|
-
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
7106
|
-
>
|
|
7107
|
-
) => InvokeBuilder<
|
|
7108
|
-
States,
|
|
7109
|
-
Events,
|
|
7110
|
-
Emits,
|
|
7111
|
-
StateId,
|
|
7112
|
-
InputEvents,
|
|
7113
|
-
ParentEvents,
|
|
7114
|
-
Output,
|
|
7115
|
-
Error,
|
|
7116
|
-
Requirements,
|
|
7117
|
-
InitialError,
|
|
7118
|
-
ChildEmits,
|
|
7119
|
-
ChildParentEvent,
|
|
7120
|
-
Element,
|
|
7121
|
-
Exclude<Pending, "done">,
|
|
7122
|
-
SnapshotHandler,
|
|
7123
|
-
Outcomes | Handler
|
|
7124
|
-
>
|
|
7125
|
-
}
|
|
7126
|
-
: {})
|
|
7127
|
-
& ("failure" extends Pending ? {
|
|
7128
|
-
/** Handles typed failure and exposes the invocation error. */
|
|
7129
|
-
readonly onFailure: <
|
|
7130
|
-
const Handler extends InvokeTransition<
|
|
7131
|
-
States,
|
|
7132
|
-
Events,
|
|
7133
|
-
Emits,
|
|
7134
|
-
StateId,
|
|
7135
|
-
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
7136
|
-
>
|
|
7137
|
-
>(
|
|
7138
|
-
handler:
|
|
7139
|
-
& Handler
|
|
7140
|
-
& InvokeTransition<
|
|
7141
|
-
States,
|
|
7142
|
-
Events,
|
|
7143
|
-
Emits,
|
|
7144
|
-
StateId,
|
|
7145
|
-
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
7146
|
-
>
|
|
7147
|
-
) => InvokeBuilder<
|
|
7148
|
-
States,
|
|
7149
|
-
Events,
|
|
7150
|
-
Emits,
|
|
7151
|
-
StateId,
|
|
7152
|
-
InputEvents,
|
|
7153
|
-
ParentEvents,
|
|
7154
|
-
Output,
|
|
7155
|
-
Error,
|
|
7156
|
-
Requirements,
|
|
7157
|
-
InitialError,
|
|
7158
|
-
ChildEmits,
|
|
7159
|
-
ChildParentEvent,
|
|
7160
|
-
Element,
|
|
7161
|
-
Exclude<Pending, "failure">,
|
|
7162
|
-
SnapshotHandler,
|
|
7163
|
-
Outcomes | Handler
|
|
7164
|
-
>
|
|
7165
|
-
}
|
|
7166
|
-
: {})
|
|
7167
|
-
& ("element" extends Pending ? {
|
|
7168
|
-
/** Handles each backpressured element emitted by an invoked Stream. */
|
|
7169
|
-
readonly onElement: <
|
|
7170
|
-
const Handler extends InvokeTransition<
|
|
7171
|
-
States,
|
|
7172
|
-
Events,
|
|
7173
|
-
Emits,
|
|
7174
|
-
StateId,
|
|
7175
|
-
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
7176
|
-
>
|
|
7177
|
-
>(
|
|
7178
|
-
handler:
|
|
7179
|
-
& Handler
|
|
7180
|
-
& InvokeTransition<
|
|
7181
|
-
States,
|
|
7182
|
-
Events,
|
|
7183
|
-
Emits,
|
|
7184
|
-
StateId,
|
|
7185
|
-
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
7186
|
-
>
|
|
7187
|
-
) => InvokeBuilder<
|
|
7188
|
-
States,
|
|
7189
|
-
Events,
|
|
7190
|
-
Emits,
|
|
7191
|
-
StateId,
|
|
7192
|
-
InputEvents,
|
|
7193
|
-
ParentEvents,
|
|
7194
|
-
Output,
|
|
7195
|
-
Error,
|
|
7196
|
-
Requirements,
|
|
7197
|
-
InitialError,
|
|
7198
|
-
ChildEmits,
|
|
7199
|
-
ChildParentEvent,
|
|
7200
|
-
Element,
|
|
7201
|
-
Exclude<Pending, "element">,
|
|
7202
|
-
SnapshotHandler,
|
|
7203
|
-
Outcomes | Handler
|
|
7204
|
-
>
|
|
7205
|
-
}
|
|
7206
|
-
: {})
|
|
7207
|
-
& ([SnapshotHandler] extends [never] ? {} : {
|
|
7208
|
-
/** Handles each active snapshot published by invoked logic or a child machine. */
|
|
7209
|
-
readonly onSnapshot: <const Handler extends SnapshotHandler>(handler: Handler & SnapshotHandler) => InvokeBuilder<
|
|
7210
|
-
States,
|
|
7211
|
-
Events,
|
|
7212
|
-
Emits,
|
|
7213
|
-
StateId,
|
|
7214
|
-
InputEvents,
|
|
7215
|
-
ParentEvents,
|
|
7216
|
-
Output,
|
|
7217
|
-
Error,
|
|
7218
|
-
Requirements,
|
|
7219
|
-
InitialError,
|
|
7220
|
-
ChildEmits,
|
|
7221
|
-
ChildParentEvent,
|
|
7222
|
-
Element,
|
|
7223
|
-
Pending,
|
|
7224
|
-
never,
|
|
7225
|
-
Outcomes | Handler
|
|
7226
|
-
>
|
|
7227
|
-
})
|
|
7228
|
-
|
|
7229
|
-
type EffectInvokeBuilder<
|
|
7230
|
-
States extends StateSchemas,
|
|
7231
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7232
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7233
|
-
StateId extends StateIdentifier<States>,
|
|
7234
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7235
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7236
|
-
Source extends (...args: ReadonlyArray<any>) => Effect.Effect<any, any, any>
|
|
7237
|
-
> = InvokeBuilder<
|
|
7238
|
-
States,
|
|
7239
|
-
Events,
|
|
7240
|
-
Emits,
|
|
7241
|
-
StateId,
|
|
7242
|
-
InputEvents,
|
|
7243
|
-
ParentEvents,
|
|
7244
|
-
Effect.Success<ReturnType<Source>>,
|
|
7245
|
-
Effect.Error<ReturnType<Source>>,
|
|
7246
|
-
Effect.Services<ReturnType<Source>>,
|
|
7247
|
-
never,
|
|
7248
|
-
never,
|
|
7249
|
-
never,
|
|
7250
|
-
never,
|
|
7251
|
-
| RequiredInvokeChannel<Effect.Success<ReturnType<Source>>, "done">
|
|
7252
|
-
| RequiredInvokeChannel<Effect.Error<ReturnType<Source>>, "failure">,
|
|
7253
|
-
never
|
|
7254
|
-
>
|
|
7255
|
-
|
|
7256
|
-
type StreamInvokeBuilder<
|
|
7257
|
-
States extends StateSchemas,
|
|
7258
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7259
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7260
|
-
StateId extends StateIdentifier<States>,
|
|
7261
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7262
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7263
|
-
Source extends (...args: ReadonlyArray<any>) => Stream.Stream<any, any, any>
|
|
7264
|
-
> = InvokeBuilder<
|
|
7265
|
-
States,
|
|
7266
|
-
Events,
|
|
7267
|
-
Emits,
|
|
7268
|
-
StateId,
|
|
7269
|
-
InputEvents,
|
|
7270
|
-
ParentEvents,
|
|
7271
|
-
void,
|
|
7272
|
-
Stream.Error<ReturnType<Source>>,
|
|
7273
|
-
Stream.Services<ReturnType<Source>>,
|
|
7274
|
-
never,
|
|
7275
|
-
never,
|
|
7276
|
-
never,
|
|
7277
|
-
Stream.Success<ReturnType<Source>>,
|
|
7278
|
-
| "done"
|
|
7279
|
-
| RequiredInvokeChannel<Stream.Success<ReturnType<Source>>, "element">
|
|
7280
|
-
| RequiredInvokeChannel<Stream.Error<ReturnType<Source>>, "failure">,
|
|
7281
|
-
never
|
|
7282
|
-
>
|
|
7283
|
-
|
|
7284
|
-
type LogicInvokeBuilder<
|
|
7285
|
-
States extends StateSchemas,
|
|
7286
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7287
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7288
|
-
StateId extends StateIdentifier<States>,
|
|
7289
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7290
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7291
|
-
ChildLogic
|
|
7292
|
-
> = InvokeBuilder<
|
|
7293
|
-
States,
|
|
7294
|
-
Events,
|
|
7295
|
-
Emits,
|
|
7296
|
-
StateId,
|
|
7297
|
-
InputEvents,
|
|
7298
|
-
ParentEvents,
|
|
7299
|
-
LogicOutputOf<ChildLogic>,
|
|
7300
|
-
LogicErrorOf<ChildLogic>,
|
|
7301
|
-
LogicServicesOf<ChildLogic>,
|
|
7302
|
-
LogicInitialErrorOf<ChildLogic>,
|
|
7303
|
-
never,
|
|
7304
|
-
never,
|
|
7305
|
-
never,
|
|
7306
|
-
| RequiredInvokeChannel<LogicOutputOf<ChildLogic>, "done">
|
|
7307
|
-
| RequiredInvokeChannel<LogicErrorOf<ChildLogic>, "failure">,
|
|
7308
|
-
InvokeTransition<
|
|
7309
|
-
States,
|
|
7310
|
-
Events,
|
|
7311
|
-
Emits,
|
|
7312
|
-
StateId,
|
|
7313
|
-
InvokeSnapshotContext<
|
|
7314
|
-
States,
|
|
7315
|
-
Events,
|
|
7316
|
-
Emits,
|
|
7317
|
-
StateId,
|
|
7318
|
-
LogicStateOf<ChildLogic>,
|
|
7319
|
-
LogicErrorOf<ChildLogic>,
|
|
7320
|
-
LogicOutputOf<ChildLogic>,
|
|
7321
|
-
InputEvents,
|
|
7322
|
-
ParentEvents
|
|
7323
|
-
>
|
|
7324
|
-
>
|
|
7325
|
-
>
|
|
7326
|
-
|
|
7327
|
-
type ChildInvokeBuilder<
|
|
7328
|
-
States extends StateSchemas,
|
|
7329
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7330
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7331
|
-
StateId extends StateIdentifier<States>,
|
|
7332
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7333
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7334
|
-
Child extends ChildMachine.Any,
|
|
7335
|
-
ChildDefinition extends Machine.Any = Child["machine"]
|
|
7336
|
-
> = InvokeBuilder<
|
|
7337
|
-
States,
|
|
7338
|
-
Events,
|
|
7339
|
-
Emits,
|
|
7340
|
-
StateId,
|
|
7341
|
-
InputEvents,
|
|
7342
|
-
ParentEvents,
|
|
7343
|
-
Output<ChildDefinition>,
|
|
7344
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
7345
|
-
Services<ChildDefinition>,
|
|
7346
|
-
InitialError<ChildDefinition>,
|
|
7347
|
-
EmittedEvent<ChildDefinition>,
|
|
7348
|
-
EventOf<Machine.ParentEvents<ChildDefinition>>,
|
|
7349
|
-
never,
|
|
7350
|
-
| RequiredInvokeChannel<Output<ChildDefinition>, "done">
|
|
7351
|
-
| RequiredInvokeChannel<Error<ChildDefinition> | ActionError<Services<ChildDefinition>>, "failure">,
|
|
7352
|
-
InvokeTransition<
|
|
7353
|
-
States,
|
|
7354
|
-
Events,
|
|
7355
|
-
Emits,
|
|
7356
|
-
StateId,
|
|
7357
|
-
InvokeSnapshotContext<
|
|
7358
|
-
States,
|
|
7359
|
-
Events,
|
|
7360
|
-
Emits,
|
|
7361
|
-
StateId,
|
|
7362
|
-
Snapshot<Machine.States<ChildDefinition>>,
|
|
7363
|
-
Error<ChildDefinition>,
|
|
7364
|
-
Output<ChildDefinition>,
|
|
7365
|
-
InputEvents,
|
|
7366
|
-
ParentEvents
|
|
7367
|
-
>
|
|
7368
|
-
>
|
|
7369
|
-
>
|
|
7370
|
-
|
|
7371
|
-
/**
|
|
7372
|
-
* Selects state-owned work and begins its lifecycle-handler chain.
|
|
7373
|
-
*
|
|
7374
|
-
* Each source exposes exactly the lifecycle methods that it can produce. A
|
|
7375
|
-
* chain becomes returnable from `invoke` only after every reachable required
|
|
7376
|
-
* channel has been handled.
|
|
7377
|
-
*
|
|
7378
|
-
* **Example** (Invoking an Effect)
|
|
7379
|
-
*
|
|
7380
|
-
* ```ts
|
|
7381
|
-
* invoke: (from) =>
|
|
7382
|
-
* from.effect("load-user", () => loadUser).onDone((to) =>
|
|
7383
|
-
* to.branch.Ready().resolve(({ output, target }) => target.from({ user: output }))
|
|
7384
|
-
* ).onFailure((to) =>
|
|
7385
|
-
* to.branch.Failed().resolve(({ error, target }) => target.from({ error }))
|
|
7386
|
-
* )
|
|
7387
|
-
* ```
|
|
7388
|
-
*
|
|
7389
|
-
* @inlineType EffectInvokeBuilder
|
|
7390
|
-
* @inlineType StreamInvokeBuilder
|
|
7391
|
-
* @inlineType LogicInvokeBuilder
|
|
7392
|
-
* @inlineType ChildInvokeBuilder
|
|
7393
|
-
* @inlineType InvokeBuilder
|
|
7394
|
-
*
|
|
7395
|
-
* @category models
|
|
7396
|
-
* @since 0.18.0
|
|
7397
|
-
*/
|
|
7398
|
-
export interface InvokeSelector<
|
|
7399
|
-
States extends StateSchemas,
|
|
7400
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7401
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7402
|
-
StateId extends StateIdentifier<States>,
|
|
7403
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7404
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7405
|
-
> {
|
|
7406
|
-
/**
|
|
7407
|
-
* Starts a fresh Effect each time the owning state is entered.
|
|
7408
|
-
*
|
|
7409
|
-
* @param id Parent-local lifecycle identifier.
|
|
7410
|
-
* @param source Lazy Effect factory evaluated on every entry.
|
|
7411
|
-
*/
|
|
7412
|
-
readonly effect: <
|
|
7413
|
-
const Source extends (
|
|
7414
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7415
|
-
) => Effect.Effect<unknown, unknown, unknown>
|
|
7416
|
-
>(
|
|
7417
|
-
id: InvokeLifecycleId,
|
|
7418
|
-
source: Source
|
|
7419
|
-
) => EffectInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
7420
|
-
|
|
7421
|
-
/**
|
|
7422
|
-
* Starts a fresh, backpressured Stream each time the owning state is entered.
|
|
7423
|
-
*
|
|
7424
|
-
* @param id Parent-local lifecycle identifier.
|
|
7425
|
-
* @param source Lazy Stream factory evaluated on every entry.
|
|
7426
|
-
*/
|
|
7427
|
-
readonly stream: <
|
|
7428
|
-
const Source extends (
|
|
7429
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7430
|
-
) => Stream.Stream<unknown, unknown, any>
|
|
7431
|
-
>(
|
|
7432
|
-
id: InvokeLifecycleId,
|
|
7433
|
-
source: Source
|
|
7434
|
-
) => StreamInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
7435
|
-
|
|
7436
|
-
/**
|
|
7437
|
-
* Starts a cancellable state-scoped timer.
|
|
7438
|
-
*
|
|
7439
|
-
* @param id Parent-local lifecycle identifier.
|
|
7440
|
-
* @param duration Duration input or context-dependent duration factory.
|
|
7441
|
-
*/
|
|
7442
|
-
readonly timer: (
|
|
7443
|
-
id: InvokeLifecycleId,
|
|
7444
|
-
duration: InvokeSource<
|
|
7445
|
-
Duration.Input,
|
|
7446
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7447
|
-
>
|
|
7448
|
-
) => InvokeBuilder<
|
|
7449
|
-
States,
|
|
7450
|
-
Events,
|
|
7451
|
-
Emits,
|
|
7452
|
-
StateId,
|
|
7453
|
-
InputEvents,
|
|
7454
|
-
ParentEvents,
|
|
7455
|
-
void,
|
|
7456
|
-
never,
|
|
7457
|
-
never,
|
|
7458
|
-
never,
|
|
7459
|
-
never,
|
|
7460
|
-
never,
|
|
7461
|
-
never,
|
|
7462
|
-
"done",
|
|
7463
|
-
never
|
|
7464
|
-
>
|
|
7465
|
-
|
|
7466
|
-
/**
|
|
7467
|
-
* Starts reusable process logic at a typed parent-local address.
|
|
7468
|
-
*
|
|
7469
|
-
* @param id Parent-local lifecycle identifier.
|
|
7470
|
-
* @param options Address and reusable logic value or factory.
|
|
7471
|
-
*/
|
|
7472
|
-
readonly logic: {
|
|
7473
|
-
<
|
|
7474
|
-
const Source extends (
|
|
7475
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7476
|
-
) => unknown,
|
|
7477
|
-
Address extends ChildAddress<never>
|
|
7478
|
-
>(
|
|
7479
|
-
id: InvokeLifecycleId,
|
|
7480
|
-
options: {
|
|
7481
|
-
/** Typed parent-local address used to send events to this logic. */
|
|
7482
|
-
readonly address:
|
|
7483
|
-
& Address
|
|
7484
|
-
& ChildAddress.Compatibility<Address, LogicEventOf<ReturnType<NoInfer<Source>>>>
|
|
7485
|
-
/** Context-dependent factory that returns reusable process logic. */
|
|
7486
|
-
readonly logic: Source
|
|
7487
|
-
},
|
|
7488
|
-
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
7489
|
-
"logic factory must return Machine.Logic"
|
|
7490
|
-
]
|
|
7491
|
-
): LogicInvokeBuilder<
|
|
7492
|
-
States,
|
|
7493
|
-
Events,
|
|
7494
|
-
Emits,
|
|
7495
|
-
StateId,
|
|
7496
|
-
InputEvents,
|
|
7497
|
-
ParentEvents,
|
|
7498
|
-
ReturnType<Source>
|
|
7499
|
-
>
|
|
7500
|
-
<const Source, Address extends ChildAddress<never>>(
|
|
7501
|
-
id: InvokeLifecycleId,
|
|
7502
|
-
options: {
|
|
7503
|
-
/** Typed parent-local address used to send events to this logic. */
|
|
7504
|
-
readonly address: Address & ChildAddress.Compatibility<Address, LogicEventOf<NoInfer<Source>>>
|
|
7505
|
-
/** Reusable process logic started when the owning state enters. */
|
|
7506
|
-
readonly logic: Source
|
|
7507
|
-
},
|
|
7508
|
-
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
7509
|
-
"logic must implement Machine.Logic"
|
|
7510
|
-
]
|
|
7511
|
-
): LogicInvokeBuilder<
|
|
7512
|
-
States,
|
|
7513
|
-
Events,
|
|
7514
|
-
Emits,
|
|
7515
|
-
StateId,
|
|
7516
|
-
InputEvents,
|
|
7517
|
-
ParentEvents,
|
|
7518
|
-
Source
|
|
7519
|
-
>
|
|
7520
|
-
}
|
|
5812
|
+
) => InitialBuilderEvidence<TargetSelection<any, any, any>>
|
|
7521
5813
|
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
}]
|
|
7545
|
-
) => ChildInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Child>
|
|
5814
|
+
export type InvokeTransition<
|
|
5815
|
+
States extends StateSchemas,
|
|
5816
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5817
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5818
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5819
|
+
Context
|
|
5820
|
+
> = TransitionConfig<States, Events, Emits, StateId, Context, true, TransitionAcceptance>
|
|
5821
|
+
|
|
5822
|
+
export type InvokeSource<Value, Context> = Value | ((context: Context) => Value)
|
|
5823
|
+
|
|
5824
|
+
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
5825
|
+
interface InvokeOwned<
|
|
5826
|
+
States extends StateSchemas,
|
|
5827
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5828
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5829
|
+
StateId extends StateIdentifier<States>,
|
|
5830
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5831
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5832
|
+
> {
|
|
5833
|
+
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<
|
|
5834
|
+
readonly [States, Events, Emits, StateId, InputEvents, ParentEvents]
|
|
5835
|
+
>
|
|
7546
5836
|
}
|
|
7547
5837
|
|
|
7548
|
-
|
|
7549
|
-
* Inline invocation declaration accepted by an active state handler.
|
|
7550
|
-
*
|
|
7551
|
-
* Return one completed source chain or an array of completed chains. Source
|
|
7552
|
-
* computations and child descriptors may be extracted, but the chain stays
|
|
7553
|
-
* local to preserve the owning state and machine protocols.
|
|
7554
|
-
*
|
|
7555
|
-
* @category models
|
|
7556
|
-
* @since 0.18.0
|
|
7557
|
-
*/
|
|
7558
|
-
export type InvokeBuilderInput<
|
|
5838
|
+
type StoredInvokeConfig<
|
|
7559
5839
|
States extends StateSchemas,
|
|
7560
5840
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
7561
5841
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7562
5842
|
StateId extends StateIdentifier<States>,
|
|
7563
5843
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7564
5844
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7565
|
-
> =
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
readonly
|
|
5845
|
+
> =
|
|
5846
|
+
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5847
|
+
& (
|
|
5848
|
+
| {
|
|
5849
|
+
readonly id: string
|
|
5850
|
+
readonly effect: (
|
|
5851
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5852
|
+
) => Effect.Effect<any, any, any>
|
|
5853
|
+
readonly stream?: never
|
|
5854
|
+
readonly after?: never
|
|
5855
|
+
readonly logic?: never
|
|
5856
|
+
readonly child?: never
|
|
5857
|
+
readonly address?: never
|
|
5858
|
+
readonly onDone?: unknown
|
|
5859
|
+
readonly onFailure?: unknown
|
|
5860
|
+
readonly onElement?: never
|
|
5861
|
+
readonly onSnapshot?: never
|
|
7574
5862
|
}
|
|
7575
|
-
|
|
5863
|
+
| {
|
|
5864
|
+
readonly id: string
|
|
5865
|
+
readonly stream: (
|
|
5866
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5867
|
+
) => Stream.Stream<any, any, any>
|
|
5868
|
+
readonly effect?: never
|
|
5869
|
+
readonly after?: never
|
|
5870
|
+
readonly logic?: never
|
|
5871
|
+
readonly child?: never
|
|
5872
|
+
readonly address?: never
|
|
5873
|
+
readonly onElement?: unknown
|
|
5874
|
+
readonly onDone: unknown
|
|
5875
|
+
readonly onFailure?: unknown
|
|
5876
|
+
readonly onSnapshot?: never
|
|
5877
|
+
}
|
|
5878
|
+
| {
|
|
5879
|
+
readonly id: string
|
|
5880
|
+
readonly after: InvokeSource<
|
|
5881
|
+
Duration.Input,
|
|
5882
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5883
|
+
>
|
|
5884
|
+
readonly effect?: never
|
|
5885
|
+
readonly stream?: never
|
|
5886
|
+
readonly logic?: never
|
|
5887
|
+
readonly child?: never
|
|
5888
|
+
readonly address?: never
|
|
5889
|
+
readonly onDone: unknown
|
|
5890
|
+
readonly onFailure?: never
|
|
5891
|
+
readonly onElement?: never
|
|
5892
|
+
readonly onSnapshot?: never
|
|
5893
|
+
}
|
|
5894
|
+
| {
|
|
5895
|
+
readonly id: string
|
|
5896
|
+
readonly address: string
|
|
5897
|
+
readonly logic: InvokeSource<
|
|
5898
|
+
Logic<any, any, any, any, any, any>,
|
|
5899
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5900
|
+
>
|
|
5901
|
+
readonly effect?: never
|
|
5902
|
+
readonly stream?: never
|
|
5903
|
+
readonly after?: never
|
|
5904
|
+
readonly child?: never
|
|
5905
|
+
readonly onDone?: unknown
|
|
5906
|
+
readonly onFailure?: unknown
|
|
5907
|
+
readonly onElement?: never
|
|
5908
|
+
readonly onSnapshot?: unknown
|
|
5909
|
+
}
|
|
5910
|
+
| {
|
|
5911
|
+
readonly child: ChildMachine.Any
|
|
5912
|
+
readonly input?:
|
|
5913
|
+
| {}
|
|
5914
|
+
| null
|
|
5915
|
+
| ((context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
5916
|
+
readonly id?: never
|
|
5917
|
+
readonly address?: never
|
|
5918
|
+
readonly effect?: never
|
|
5919
|
+
readonly stream?: never
|
|
5920
|
+
readonly after?: never
|
|
5921
|
+
readonly logic?: never
|
|
5922
|
+
readonly onDone?: unknown
|
|
5923
|
+
readonly onFailure?: unknown
|
|
5924
|
+
readonly onElement?: never
|
|
5925
|
+
readonly onSnapshot?: unknown
|
|
5926
|
+
}
|
|
5927
|
+
)
|
|
5928
|
+
|
|
5929
|
+
type StoredInvokeDefinition<
|
|
5930
|
+
States extends StateSchemas,
|
|
5931
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5932
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5933
|
+
StateId extends StateIdentifier<States>,
|
|
5934
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5935
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5936
|
+
> =
|
|
5937
|
+
| StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5938
|
+
| ReadonlyArray<StoredInvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
5939
|
+
|
|
5940
|
+
type LogicInitialEffectOf<Value> = Value extends { readonly initial: infer Initial } ?
|
|
5941
|
+
Initial extends (...args: ReadonlyArray<any>) => infer Result ? Result : never
|
|
5942
|
+
: never
|
|
5943
|
+
|
|
5944
|
+
type LogicRunEffectOf<Value> = Value extends { readonly run: infer Run } ?
|
|
5945
|
+
Run extends (...args: ReadonlyArray<any>) => infer Result ? Result : never
|
|
5946
|
+
: never
|
|
5947
|
+
|
|
5948
|
+
export type LogicStateOf<Value> = Effect.Success<LogicInitialEffectOf<Value>>
|
|
5949
|
+
export type LogicEventOf<Value> = Value extends { readonly initial: infer Initial } ?
|
|
5950
|
+
Initial extends (scope: infer LogicScope, ...args: ReadonlyArray<any>) => any ?
|
|
5951
|
+
LogicScope extends Logic.Scope<infer Event> ? Event : never
|
|
5952
|
+
: never
|
|
5953
|
+
: never
|
|
5954
|
+
export type LogicErrorOf<Value> = Effect.Error<LogicRunEffectOf<Value>>
|
|
5955
|
+
export type LogicServicesOf<Value> = Effect.Services<LogicInitialEffectOf<Value> | LogicRunEffectOf<Value>>
|
|
5956
|
+
export type LogicOutputOf<Value> = Effect.Success<LogicRunEffectOf<Value>>
|
|
5957
|
+
export type LogicInitialErrorOf<Value> = Effect.Error<LogicInitialEffectOf<Value>>
|
|
7576
5958
|
|
|
7577
5959
|
/** Output construction available to final and output-producing parallel states. */
|
|
7578
5960
|
type OutputHandlerConfig<
|
|
@@ -7602,86 +5984,6 @@ export declare namespace Machine {
|
|
|
7602
5984
|
readonly output?: never
|
|
7603
5985
|
}
|
|
7604
5986
|
|
|
7605
|
-
/**
|
|
7606
|
-
* Configuration accepted for a non-final state.
|
|
7607
|
-
*
|
|
7608
|
-
* **Example** (State actions, events, and invocation)
|
|
7609
|
-
*
|
|
7610
|
-
* ```ts
|
|
7611
|
-
* machine.handle({ states: {
|
|
7612
|
-
* Loading: {
|
|
7613
|
-
* entry: (_, enqueue) => enqueue.emit({ _tag: "Started" }),
|
|
7614
|
-
* invoke: (from) =>
|
|
7615
|
-
* from.effect("load", () => load).onDone((to) => to.branch.Ready()),
|
|
7616
|
-
* on: { Cancel: (to) => to.branch.Idle() }
|
|
7617
|
-
* }
|
|
7618
|
-
* } })
|
|
7619
|
-
* ```
|
|
7620
|
-
*
|
|
7621
|
-
* @inlineType ActiveOutputHandlerConfig
|
|
7622
|
-
* @inlineType OutputHandlerConfig
|
|
7623
|
-
*
|
|
7624
|
-
* @category models
|
|
7625
|
-
* @since 0.4.0
|
|
7626
|
-
*/
|
|
7627
|
-
export type ActiveStateConfig<
|
|
7628
|
-
States extends StateSchemas,
|
|
7629
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7630
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7631
|
-
StateId extends StateIdentifier<States>,
|
|
7632
|
-
E,
|
|
7633
|
-
R,
|
|
7634
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7635
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7636
|
-
> = {
|
|
7637
|
-
/** Runs synchronously when the state is entered and may enqueue commands. */
|
|
7638
|
-
readonly entry?: (
|
|
7639
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7640
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7641
|
-
) => StateActionResult<any, any>
|
|
7642
|
-
/** Runs synchronously before the state is exited and may enqueue commands. */
|
|
7643
|
-
readonly exit?: (
|
|
7644
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7645
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7646
|
-
) => StateActionResult<any, any>
|
|
7647
|
-
/** Starts state-owned Effect, Stream, timer, logic, or child lifecycles. */
|
|
7648
|
-
readonly invoke?: InvokeBuilderInput<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7649
|
-
/** Eventless transition evaluated after the state becomes stable. */
|
|
7650
|
-
readonly always?: TransitionConfig<
|
|
7651
|
-
States,
|
|
7652
|
-
Events,
|
|
7653
|
-
Emits,
|
|
7654
|
-
StateId,
|
|
7655
|
-
AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7656
|
-
false,
|
|
7657
|
-
TransitionAcceptance
|
|
7658
|
-
>
|
|
7659
|
-
/** Transition evaluated after this compound or parallel state completes. */
|
|
7660
|
-
readonly onDone?: TransitionConfig<
|
|
7661
|
-
States,
|
|
7662
|
-
Events,
|
|
7663
|
-
Emits,
|
|
7664
|
-
StateId,
|
|
7665
|
-
DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7666
|
-
false,
|
|
7667
|
-
TransitionAcceptance
|
|
7668
|
-
>
|
|
7669
|
-
/** Event handlers keyed by the `_tag` of the machine's public or internal events. */
|
|
7670
|
-
readonly on?: {
|
|
7671
|
-
readonly [EventTag in TagOf<Events[number]>]?: TransitionConfig<
|
|
7672
|
-
States,
|
|
7673
|
-
Events,
|
|
7674
|
-
Emits,
|
|
7675
|
-
StateId,
|
|
7676
|
-
HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>,
|
|
7677
|
-
true,
|
|
7678
|
-
TransitionAcceptance
|
|
7679
|
-
>
|
|
7680
|
-
}
|
|
7681
|
-
/** Supplies missing direct initial-child values required by implicit entry and shallow history. */
|
|
7682
|
-
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7683
|
-
} & ActiveOutputHandlerConfig<States, Events, StateId>
|
|
7684
|
-
|
|
7685
5987
|
/**
|
|
7686
5988
|
* Values constructed for a state's schema-valued direct initial children.
|
|
7687
5989
|
*
|
|
@@ -7861,7 +6163,7 @@ export declare namespace Machine {
|
|
|
7861
6163
|
}
|
|
7862
6164
|
|
|
7863
6165
|
/** Required implementation for a choice pseudo-state. */
|
|
7864
|
-
|
|
6166
|
+
interface ChoiceStateConfig<
|
|
7865
6167
|
States extends StateSchemas,
|
|
7866
6168
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
7867
6169
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -7872,84 +6174,23 @@ export declare namespace Machine {
|
|
|
7872
6174
|
/** Required transition that resolves this transient choice to a concrete destination. */
|
|
7873
6175
|
readonly choice: TransitionConfig<
|
|
7874
6176
|
States,
|
|
7875
|
-
Events,
|
|
7876
|
-
Emits,
|
|
7877
|
-
ChoiceId,
|
|
7878
|
-
ChoiceContext<States, Events, Emits, ChoiceId, InputEvents, ParentEvents>
|
|
7879
|
-
>
|
|
7880
|
-
readonly entry?: never
|
|
7881
|
-
readonly exit?: never
|
|
7882
|
-
readonly invoke?: never
|
|
7883
|
-
readonly always?: never
|
|
7884
|
-
readonly on?: never
|
|
7885
|
-
readonly onDone?: never
|
|
7886
|
-
readonly output?: never
|
|
7887
|
-
readonly initialize?: never
|
|
7888
|
-
}
|
|
7889
|
-
|
|
7890
|
-
/**
|
|
7891
|
-
* Configuration accepted for a final state.
|
|
7892
|
-
*
|
|
7893
|
-
* @inlineType OutputHandlerConfig
|
|
7894
|
-
*
|
|
7895
|
-
* @category models
|
|
7896
|
-
* @since 0.4.0
|
|
7897
|
-
*/
|
|
7898
|
-
export type FinalStateConfig<
|
|
7899
|
-
States extends StateSchemas,
|
|
7900
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7901
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7902
|
-
StateId extends StateIdentifier<States>,
|
|
7903
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7904
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7905
|
-
> = {
|
|
7906
|
-
/** Runs synchronously when the final state is entered and may enqueue commands. */
|
|
7907
|
-
readonly entry?: (
|
|
7908
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7909
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7910
|
-
) => StateActionResult<any, any>
|
|
7911
|
-
readonly exit?: never
|
|
7912
|
-
readonly always?: never
|
|
7913
|
-
readonly onDone?: never
|
|
7914
|
-
readonly on?: never
|
|
7915
|
-
} & OutputHandlerConfig<States, Events, StateId, FinalOutputContext<States, Events, StateId>>
|
|
7916
|
-
|
|
7917
|
-
/**
|
|
7918
|
-
* Configuration accepted by `handle` for a state tag.
|
|
7919
|
-
*
|
|
7920
|
-
* @category models
|
|
7921
|
-
* @since 0.4.0
|
|
7922
|
-
*/
|
|
7923
|
-
export type HandlerConfig<
|
|
7924
|
-
States extends StateSchemas,
|
|
7925
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7926
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7927
|
-
StateId extends StateIdentifier<States>,
|
|
7928
|
-
E,
|
|
7929
|
-
R,
|
|
7930
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7931
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7932
|
-
> = NodeByIdentifier<States, StateId> extends { readonly type: "final" } ?
|
|
7933
|
-
FinalStateConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7934
|
-
: ActiveStateConfig<States, Events, Emits, StateId, E, R, InputEvents, ParentEvents>
|
|
7935
|
-
|
|
7936
|
-
type HandlerNodeConfig<
|
|
7937
|
-
States extends StateSchemas,
|
|
7938
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7939
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7940
|
-
Path extends StateNodeIdentifier<States>,
|
|
7941
|
-
E,
|
|
7942
|
-
R,
|
|
7943
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7944
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>
|
|
7945
|
-
> = Path extends ChoiceIdentifier<States> ? ChoiceStateConfig<States, Events, Emits, Path, InputEvents, ParentEvents>
|
|
7946
|
-
: Path extends StateIdentifier<States> ? HandlerConfig<States, Events, Emits, Path, E, R, InputEvents, ParentEvents>
|
|
7947
|
-
: never
|
|
6177
|
+
Events,
|
|
6178
|
+
Emits,
|
|
6179
|
+
ChoiceId,
|
|
6180
|
+
ChoiceContext<States, Events, Emits, ChoiceId, InputEvents, ParentEvents>
|
|
6181
|
+
>
|
|
6182
|
+
readonly entry?: never
|
|
6183
|
+
readonly exit?: never
|
|
6184
|
+
readonly invoke?: never
|
|
6185
|
+
readonly always?: never
|
|
6186
|
+
readonly on?: never
|
|
6187
|
+
readonly onDone?: never
|
|
6188
|
+
readonly output?: never
|
|
6189
|
+
readonly initialize?: never
|
|
6190
|
+
}
|
|
7948
6191
|
|
|
7949
6192
|
type HandlerChildren<Node> = Node extends { readonly states: infer Children extends StateSchemas } ? Children : never
|
|
7950
6193
|
|
|
7951
|
-
type HandlerNodeId<States extends StateSchemas, Path extends string> = Extract<Path, StateNodeIdentifier<States>>
|
|
7952
|
-
|
|
7953
6194
|
type HandlerConfigPart<Config> = {
|
|
7954
6195
|
readonly [Key in keyof Config as Key extends "states" ? never : Key]: Config[Key]
|
|
7955
6196
|
}
|
|
@@ -7992,78 +6233,6 @@ export declare namespace Machine {
|
|
|
7992
6233
|
}
|
|
7993
6234
|
: { readonly [Key in Path]?: Validation }
|
|
7994
6235
|
|
|
7995
|
-
/** Nested handler-tree structure shared by active and final state configs. */
|
|
7996
|
-
type HandlerNode<
|
|
7997
|
-
AllStates extends StateSchemas,
|
|
7998
|
-
Node,
|
|
7999
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8000
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8001
|
-
E,
|
|
8002
|
-
R,
|
|
8003
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8004
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
8005
|
-
StateId extends StateNodeIdentifier<AllStates>
|
|
8006
|
-
> =
|
|
8007
|
-
& HandlerNodeConfig<AllStates, Events, Emits, StateId, E, R, InputEvents, ParentEvents>
|
|
8008
|
-
& (StateId extends ChoiceIdentifier<AllStates> ? {
|
|
8009
|
-
readonly states?: never
|
|
8010
|
-
readonly history?: never
|
|
8011
|
-
}
|
|
8012
|
-
: HandlerChildren<Node> extends infer Children extends StateSchemas ? [Children] extends [never] ? {
|
|
8013
|
-
readonly states?: never
|
|
8014
|
-
readonly history?: never
|
|
8015
|
-
}
|
|
8016
|
-
: {
|
|
8017
|
-
/** Child-state handlers nested according to the declared state topology. */
|
|
8018
|
-
readonly states?: HandlerTree<
|
|
8019
|
-
AllStates,
|
|
8020
|
-
Children,
|
|
8021
|
-
Events,
|
|
8022
|
-
Emits,
|
|
8023
|
-
E,
|
|
8024
|
-
R,
|
|
8025
|
-
InputEvents,
|
|
8026
|
-
ParentEvents,
|
|
8027
|
-
Extract<StateId, StateIdentifier<AllStates>>
|
|
8028
|
-
>
|
|
8029
|
-
/** First-use defaults keyed by direct history pseudo-state. */
|
|
8030
|
-
readonly history?: HistoryDefaultConfig<
|
|
8031
|
-
AllStates,
|
|
8032
|
-
Events,
|
|
8033
|
-
Emits,
|
|
8034
|
-
Extract<StateId, StateIdentifier<AllStates>>,
|
|
8035
|
-
Children
|
|
8036
|
-
>
|
|
8037
|
-
}
|
|
8038
|
-
: {
|
|
8039
|
-
readonly states?: never
|
|
8040
|
-
readonly history?: never
|
|
8041
|
-
})
|
|
8042
|
-
|
|
8043
|
-
type HandlerTree<
|
|
8044
|
-
AllStates extends StateSchemas,
|
|
8045
|
-
States extends StateSchemas,
|
|
8046
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8047
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8048
|
-
E,
|
|
8049
|
-
R,
|
|
8050
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8051
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
8052
|
-
Prefix extends string
|
|
8053
|
-
> = {
|
|
8054
|
-
readonly [Key in ActiveStateKey<States> | ChoiceStateKey<States>]?: HandlerNode<
|
|
8055
|
-
AllStates,
|
|
8056
|
-
States[Key],
|
|
8057
|
-
Events,
|
|
8058
|
-
Emits,
|
|
8059
|
-
E,
|
|
8060
|
-
R,
|
|
8061
|
-
InputEvents,
|
|
8062
|
-
ParentEvents,
|
|
8063
|
-
HandlerNodeId<AllStates, JoinPath<Prefix, Key>>
|
|
8064
|
-
>
|
|
8065
|
-
}
|
|
8066
|
-
|
|
8067
6236
|
type HandlerNodeConfigKey =
|
|
8068
6237
|
| "always"
|
|
8069
6238
|
| "choice"
|
|
@@ -8205,30 +6374,6 @@ export declare namespace Machine {
|
|
|
8205
6374
|
>
|
|
8206
6375
|
: never
|
|
8207
6376
|
|
|
8208
|
-
type HandlerInitializeValidationAtPath<Config, Path extends string> = HandlerConfigAtPath<Config, Path> extends
|
|
8209
|
-
infer StateConfig ? [StateConfig] extends [never] ? HandlerValidationAtPath<Path, {
|
|
8210
|
-
readonly initialize: HandlerValidationError<
|
|
8211
|
-
"State requires initialize because a transition enters its declared initial configuration",
|
|
8212
|
-
Path
|
|
8213
|
-
>
|
|
8214
|
-
}>
|
|
8215
|
-
: "initialize" extends keyof StateConfig ? never
|
|
8216
|
-
: HandlerValidationAtPath<Path, {
|
|
8217
|
-
readonly initialize: HandlerValidationError<
|
|
8218
|
-
"State requires initialize because a transition enters its declared initial configuration",
|
|
8219
|
-
Path
|
|
8220
|
-
>
|
|
8221
|
-
}>
|
|
8222
|
-
: never
|
|
8223
|
-
|
|
8224
|
-
type HandlerInitialTargetValidationForPaths<
|
|
8225
|
-
AllStates extends StateSchemas,
|
|
8226
|
-
Config,
|
|
8227
|
-
Required
|
|
8228
|
-
> = Types.UnionToIntersection<
|
|
8229
|
-
Required extends string ? HandlerInitializeValidationAtPath<Config, Required> : unknown
|
|
8230
|
-
>
|
|
8231
|
-
|
|
8232
6377
|
type HandlerTreeInitialTargetPath<Config> = string extends keyof Config ? never
|
|
8233
6378
|
: Config extends object ? {
|
|
8234
6379
|
readonly [Key in keyof Config]:
|
|
@@ -8237,16 +6382,6 @@ export declare namespace Machine {
|
|
|
8237
6382
|
}[keyof Config]
|
|
8238
6383
|
: never
|
|
8239
6384
|
|
|
8240
|
-
type HandlerInitialTargetValidation<
|
|
8241
|
-
AllStates extends StateSchemas,
|
|
8242
|
-
Config
|
|
8243
|
-
> = HandlerTreeInitialTargetPath<Config> extends infer TargetPath ? HandlerInitialTargetValidationForPaths<
|
|
8244
|
-
AllStates,
|
|
8245
|
-
Config,
|
|
8246
|
-
RequiredInitializersForTargetPath<AllStates, TargetPath>
|
|
8247
|
-
>
|
|
8248
|
-
: unknown
|
|
8249
|
-
|
|
8250
6385
|
type HandlerChildrenValidation<
|
|
8251
6386
|
Node,
|
|
8252
6387
|
Prefix extends string,
|
|
@@ -8377,64 +6512,6 @@ export declare namespace Machine {
|
|
|
8377
6512
|
> = [Incompatible] extends [never] ? unknown
|
|
8378
6513
|
: HandlerValidationError<"Handler config requires an incompatible machine runtime", StateId, Incompatible>
|
|
8379
6514
|
|
|
8380
|
-
type HandlerNodeValidationAtPath<
|
|
8381
|
-
AllStates extends StateSchemas,
|
|
8382
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8383
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8384
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8385
|
-
Config,
|
|
8386
|
-
AvailableOutputStates extends StateIdentifier<AllStates>,
|
|
8387
|
-
StateId extends StateNodeIdentifier<AllStates>,
|
|
8388
|
-
NodeConfig = HandlerConfigAtPath<Config, StateId>
|
|
8389
|
-
> = [NodeConfig] extends [never] ? never
|
|
8390
|
-
: HandlerNodeValidation<
|
|
8391
|
-
AllStates,
|
|
8392
|
-
HandlerNodeByPath<AllStates, StateId>,
|
|
8393
|
-
Events,
|
|
8394
|
-
InputEvents,
|
|
8395
|
-
Emits,
|
|
8396
|
-
StateId,
|
|
8397
|
-
NodeConfig,
|
|
8398
|
-
AvailableOutputStates
|
|
8399
|
-
> extends infer Validation ? unknown extends Validation ? never
|
|
8400
|
-
: "" extends keyof AllStates ? StateId extends "" ? { readonly ""?: Validation }
|
|
8401
|
-
: { readonly ""?: { readonly states: HandlerValidationAtPath<StateId, Validation> } }
|
|
8402
|
-
: HandlerValidationAtPath<StateId, Validation>
|
|
8403
|
-
: never
|
|
8404
|
-
|
|
8405
|
-
type HandlerTreeNodeValidations<
|
|
8406
|
-
AllStates extends StateSchemas,
|
|
8407
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8408
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8409
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8410
|
-
Config,
|
|
8411
|
-
AvailableOutputStates extends StateIdentifier<AllStates>
|
|
8412
|
-
> = Types.UnionToIntersection<
|
|
8413
|
-
StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ?
|
|
8414
|
-
StateId extends StateNodeIdentifier<AllStates> ? HandlerNodeValidationAtPath<
|
|
8415
|
-
AllStates,
|
|
8416
|
-
Events,
|
|
8417
|
-
InputEvents,
|
|
8418
|
-
Emits,
|
|
8419
|
-
Config,
|
|
8420
|
-
AvailableOutputStates,
|
|
8421
|
-
StateId
|
|
8422
|
-
>
|
|
8423
|
-
: never
|
|
8424
|
-
: never
|
|
8425
|
-
>
|
|
8426
|
-
|
|
8427
|
-
type HandlerTreeValidation<
|
|
8428
|
-
AllStates extends StateSchemas,
|
|
8429
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8430
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8431
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8432
|
-
Config,
|
|
8433
|
-
AvailableOutputStates extends StateIdentifier<AllStates>
|
|
8434
|
-
> =
|
|
8435
|
-
& HandlerUnknownStateKeyValidation<AllStates, "", Config>
|
|
8436
|
-
& HandlerTreeNodeValidations<AllStates, Events, InputEvents, Emits, Config, AvailableOutputStates>
|
|
8437
|
-
|
|
8438
6515
|
type RootInitialTargetValidation<States extends StateSchemas, Config> =
|
|
8439
6516
|
RequiredInitializersForTargetPath<States, HandlerTreeInitialTargetPath<{ readonly "": Config }>> extends
|
|
8440
6517
|
infer Required ? Types.UnionToIntersection<
|
|
@@ -8568,128 +6645,1062 @@ export declare namespace Machine {
|
|
|
8568
6645
|
NodeConfig
|
|
8569
6646
|
>
|
|
8570
6647
|
: never
|
|
8571
|
-
readonly error: HandlerConfigError<HandlerConfigPart<NodeConfig>>
|
|
8572
|
-
readonly services: ConfigServices<HandlerConfigPart<NodeConfig>>
|
|
8573
|
-
readonly outputState: StateId extends StateIdentifier<AllStates> ? HandlerOutputStates<
|
|
8574
|
-
AllStates,
|
|
8575
|
-
StateId,
|
|
8576
|
-
HandlerConfigPart<NodeConfig>
|
|
8577
|
-
>
|
|
6648
|
+
readonly error: HandlerConfigError<HandlerConfigPart<NodeConfig>>
|
|
6649
|
+
readonly services: ConfigServices<HandlerConfigPart<NodeConfig>>
|
|
6650
|
+
readonly outputState: StateId extends StateIdentifier<AllStates> ? HandlerOutputStates<
|
|
6651
|
+
AllStates,
|
|
6652
|
+
StateId,
|
|
6653
|
+
HandlerConfigPart<NodeConfig>
|
|
6654
|
+
>
|
|
6655
|
+
: never
|
|
6656
|
+
}
|
|
6657
|
+
|
|
6658
|
+
// Compute every accumulated channel from one normalized node union instead
|
|
6659
|
+
// of repeating recursive walks for states, errors, services, and outputs.
|
|
6660
|
+
type HandlerTreeEvidence<AllStates extends StateSchemas, Config> = StateNodeIdentifier<AllStates> extends
|
|
6661
|
+
infer StateId extends StateNodeIdentifier<AllStates> ?
|
|
6662
|
+
StateId extends StateNodeIdentifier<AllStates> ? HandlerNodeEvidence<AllStates, Config, StateId>
|
|
6663
|
+
: never
|
|
6664
|
+
: never
|
|
6665
|
+
|
|
6666
|
+
type HandleTreeResult<
|
|
6667
|
+
AllStates extends StateSchemas,
|
|
6668
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6669
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6670
|
+
Input extends Schema.Top,
|
|
6671
|
+
UnhandledStates extends StateIdentifier<AllStates>,
|
|
6672
|
+
E,
|
|
6673
|
+
R,
|
|
6674
|
+
InitialE,
|
|
6675
|
+
InitialR,
|
|
6676
|
+
FinalStates extends StateIdentifier<AllStates>,
|
|
6677
|
+
Output,
|
|
6678
|
+
OutputStates extends StateIdentifier<AllStates>,
|
|
6679
|
+
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6680
|
+
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6681
|
+
Config
|
|
6682
|
+
> = Machine<
|
|
6683
|
+
AllStates,
|
|
6684
|
+
Events,
|
|
6685
|
+
Input,
|
|
6686
|
+
Exclude<UnhandledStates, HandlerTreeEvidence<AllStates, Config>["stateId"]>,
|
|
6687
|
+
E | HandlerTreeEvidence<AllStates, Config>["error"],
|
|
6688
|
+
ExcludeCompatibleRuntime<
|
|
6689
|
+
R | HandlerTreeEvidence<AllStates, Config>["services"],
|
|
6690
|
+
EventOf<Events>,
|
|
6691
|
+
EmittedEventOf<Emits>
|
|
6692
|
+
>,
|
|
6693
|
+
InitialE,
|
|
6694
|
+
InitialR,
|
|
6695
|
+
FinalStates,
|
|
6696
|
+
Output,
|
|
6697
|
+
Emits,
|
|
6698
|
+
OutputStates | Extract<HandlerTreeEvidence<AllStates, Config>["outputState"], StateIdentifier<AllStates>>,
|
|
6699
|
+
InputEvents,
|
|
6700
|
+
ParentEvents
|
|
6701
|
+
>
|
|
6702
|
+
|
|
6703
|
+
type ObjectCompoundPath<S extends StateSchemas> = {
|
|
6704
|
+
readonly [P in StateIdentifier<S>]: NodeByIdentifier<S, P> extends {
|
|
6705
|
+
/** Child handlers nested according to the declared root topology. */
|
|
6706
|
+
readonly states: StateSchemas
|
|
6707
|
+
} ? P :
|
|
6708
|
+
never
|
|
6709
|
+
}[StateIdentifier<S>]
|
|
6710
|
+
type LazyProgramValue = Effect.Effect<unknown, unknown, unknown> | Stream.Stream<unknown, unknown, unknown>
|
|
6711
|
+
|
|
6712
|
+
/** Registered lazy programs and their optional explicit input adapters. */
|
|
6713
|
+
export type Program<Value> = Value | ((...args: never[]) => Value)
|
|
6714
|
+
export type EffectSources = Readonly<Record<string, Program<Effect.Effect<unknown, unknown, unknown>>>>
|
|
6715
|
+
export type StreamSources = Readonly<Record<string, Program<Stream.Stream<unknown, unknown, unknown>>>>
|
|
6716
|
+
export type TimerSources = Readonly<Record<string, Program<Duration.Input>>>
|
|
6717
|
+
export type LogicSources = Readonly<Record<string, unknown>>
|
|
6718
|
+
export type ValidateLogicSources<Sources> = {
|
|
6719
|
+
readonly [K in keyof Sources]: InvokeResolvedSource<Sources[K]> extends {
|
|
6720
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6721
|
+
readonly initial: (...args: never[]) => Effect.Effect<unknown, unknown, unknown>
|
|
6722
|
+
readonly run: (...args: never[]) => Effect.Effect<unknown, unknown, unknown>
|
|
6723
|
+
} ? unknown
|
|
6724
|
+
: never
|
|
6725
|
+
}
|
|
6726
|
+
|
|
6727
|
+
export type ChildSources = Readonly<Record<string, ChildMachine.Any>>
|
|
6728
|
+
export type ValidatePrograms<Sources> = {
|
|
6729
|
+
readonly [K in keyof Sources]: Sources[K] extends LazyProgramValue ? unknown :
|
|
6730
|
+
Sources[K] extends (...args: never[]) => unknown ? Parameters<Sources[K]>["length"] extends 1 ? unknown : never
|
|
6731
|
+
: unknown
|
|
6732
|
+
}
|
|
6733
|
+
type ReferenceRoot<S extends StateSchemas> = "~effect/Machine/ExplicitInitial" extends keyof S[""]
|
|
6734
|
+
? Extract<Omit<S[""], "~effect/Machine/ExplicitInitial">, StateNodeConfig>
|
|
6735
|
+
: Extract<S[""], StateNodeConfig>
|
|
6736
|
+
type ReferenceAt<S extends StateSchemas, P extends StateNodeIdentifier<S> | HistoryIdentifier<S>> = TargetReference<
|
|
6737
|
+
ReferenceRoot<S>,
|
|
6738
|
+
P,
|
|
6739
|
+
P extends HistoryIdentifier<S> ? "history" : P extends ChoiceIdentifier<S> ? "choice" : "state"
|
|
6740
|
+
>
|
|
6741
|
+
type ReferenceUnion<S extends StateSchemas, Paths extends StateNodeIdentifier<S> | HistoryIdentifier<S>> = {
|
|
6742
|
+
readonly [P in Paths]: ReferenceAt<S, P>
|
|
6743
|
+
}[Paths]
|
|
6744
|
+
type DestinationPath<S extends StateSchemas> = Exclude<StateNodeIdentifier<S>, "">
|
|
6745
|
+
type RootSchemas<Root extends StateNodeConfig> = { readonly "": Root }
|
|
6746
|
+
|
|
6747
|
+
/** A topology declaration; its state values are constructed by a resolver. */
|
|
6748
|
+
export type BranchDeclaration<Root extends StateNodeConfig, S extends StateSchemas = RootSchemas<Root>> =
|
|
6749
|
+
& {
|
|
6750
|
+
/** Optional presentation label for this named branch. */
|
|
6751
|
+
readonly title?: string
|
|
6752
|
+
}
|
|
6753
|
+
& (
|
|
6754
|
+
| {
|
|
6755
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6756
|
+
readonly target: ReferenceUnion<S, DestinationPath<S>>
|
|
6757
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6758
|
+
readonly update?: ReferenceUnion<S, ValuedStateIdentifier<S>>
|
|
6759
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6760
|
+
readonly initial?: never
|
|
6761
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6762
|
+
readonly history?: never
|
|
6763
|
+
/** Accepts the event without selecting a new destination. */
|
|
6764
|
+
readonly none?: never
|
|
6765
|
+
}
|
|
6766
|
+
| {
|
|
6767
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6768
|
+
readonly update: ReferenceUnion<S, ValuedStateIdentifier<S>>
|
|
6769
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6770
|
+
readonly target?: never
|
|
6771
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6772
|
+
readonly initial?: never
|
|
6773
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6774
|
+
readonly history?: never
|
|
6775
|
+
/** Accepts the event without selecting a new destination. */
|
|
6776
|
+
readonly none?: never
|
|
6777
|
+
}
|
|
6778
|
+
| {
|
|
6779
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6780
|
+
readonly initial: ReferenceUnion<S, Exclude<ObjectCompoundPath<S>, "">>
|
|
6781
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6782
|
+
readonly target?: never
|
|
6783
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6784
|
+
readonly update?: never
|
|
6785
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6786
|
+
readonly history?: never
|
|
6787
|
+
/** Accepts the event without selecting a new destination. */
|
|
6788
|
+
readonly none?: never
|
|
6789
|
+
}
|
|
6790
|
+
| {
|
|
6791
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6792
|
+
readonly history: ReferenceUnion<S, HistoryIdentifier<S>>
|
|
6793
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6794
|
+
readonly target?: never
|
|
6795
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6796
|
+
readonly update?: never
|
|
6797
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6798
|
+
readonly initial?: never
|
|
6799
|
+
/** Accepts the event without selecting a new destination. */
|
|
6800
|
+
readonly none?: never
|
|
6801
|
+
}
|
|
6802
|
+
| {
|
|
6803
|
+
/** Accepts the event without selecting a new destination. */
|
|
6804
|
+
readonly none: true
|
|
6805
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6806
|
+
readonly target?: never
|
|
6807
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6808
|
+
readonly update?: never
|
|
6809
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6810
|
+
readonly initial?: never
|
|
6811
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6812
|
+
readonly history?: never
|
|
6813
|
+
}
|
|
6814
|
+
)
|
|
6815
|
+
export type BranchDefinitions<Root extends StateNodeConfig> = Readonly<
|
|
6816
|
+
Record<string, Readonly<Record<string, BranchDeclaration<Root>>>>
|
|
6817
|
+
>
|
|
6818
|
+
/** Source programs and named topology declarations captured by a machine definition. */
|
|
6819
|
+
export interface Registrations {
|
|
6820
|
+
/** Lazy Effects or functions with one required input, invoked by registered name. */
|
|
6821
|
+
readonly effects?: EffectSources
|
|
6822
|
+
/** Lazy Streams or functions with one required input, invoked by registered name. */
|
|
6823
|
+
readonly streams?: StreamSources
|
|
6824
|
+
/** Cancellable delays, supplied as durations or functions of one required input. */
|
|
6825
|
+
readonly timers?: TimerSources
|
|
6826
|
+
/** Logic values or functions of one required input; their Effect channels remain inferred. */
|
|
6827
|
+
readonly logic?: LogicSources
|
|
6828
|
+
/** Child machine descriptors registered for state-owned invocation. */
|
|
6829
|
+
readonly children?: ChildSources
|
|
6830
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
6831
|
+
readonly branches?: Readonly<Record<string, Readonly<Record<string, unknown>>>>
|
|
6832
|
+
}
|
|
6833
|
+
type Registered<R, Kind extends PropertyKey> = Kind extends keyof R ? NonNullable<R[Kind]> : {}
|
|
6834
|
+
type AtBuilder<T, P extends string> = P extends "" ? T
|
|
6835
|
+
: P extends `${infer H}.${infer Rest}` ? H extends keyof T ? AtBuilder<T[H], Rest> : never
|
|
6836
|
+
: P extends keyof T ? T[P]
|
|
6837
|
+
: never
|
|
6838
|
+
type BranchBuilderAt<S extends StateSchemas, Src extends StateNodeIdentifier<S>, P extends string> = AtBuilder<
|
|
6839
|
+
RootBuilder<BranchTargetBuilder<S, Src>>,
|
|
6840
|
+
P
|
|
6841
|
+
>
|
|
6842
|
+
type RefPath<R> = R extends TargetReference<any, infer P, any> ? P : never
|
|
6843
|
+
type SelectionOf<S extends StateSchemas, Src extends StateNodeIdentifier<S>, D> = D extends {
|
|
6844
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6845
|
+
readonly target: infer Ref
|
|
6846
|
+
} ? RefPath<Ref> extends infer P extends StateNodeIdentifier<S> ? D extends {
|
|
6847
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6848
|
+
readonly update: infer Update
|
|
6849
|
+
} ?
|
|
6850
|
+
RefPath<Update> extends
|
|
6851
|
+
infer Owner extends Extract<ParentStateIdentifier<Src>, ParentStateIdentifier<P> & ValuedStateIdentifier<S>>
|
|
6852
|
+
? TargetSelection<UpdatingTargetBuilder<BranchBuilderAt<S, Src, P>, S, Owner>, P, "state", "branch"> :
|
|
6853
|
+
never
|
|
6854
|
+
: TargetSelection<BranchBuilderAt<S, Src, P>, P, P extends ChoiceIdentifier<S> ? "choice" : "state", "branch">
|
|
6855
|
+
: never
|
|
6856
|
+
: D extends {
|
|
6857
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6858
|
+
readonly initial: infer Ref
|
|
6859
|
+
} ? RefPath<Ref> extends infer P extends string ? BranchBuilderAt<S, Src, P> extends {
|
|
6860
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6861
|
+
readonly initial: infer B
|
|
6862
|
+
} ? TargetSelection<B, P, "initial", "branch">
|
|
6863
|
+
: never :
|
|
6864
|
+
never
|
|
6865
|
+
: D extends {
|
|
6866
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6867
|
+
readonly history: infer Ref
|
|
6868
|
+
} ?
|
|
6869
|
+
RefPath<Ref> extends infer P extends string
|
|
6870
|
+
? TargetSelection<AtBuilder<RootBuilder<HistoryTargetBuilder<S>>, P>, P, "history", "full"> :
|
|
6871
|
+
never
|
|
6872
|
+
: D extends {
|
|
6873
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6874
|
+
readonly update: infer Ref
|
|
6875
|
+
} ?
|
|
6876
|
+
RefPath<Ref> extends infer P extends Extract<Src | ParentStateIdentifier<Src>, ValuedStateIdentifier<S>>
|
|
6877
|
+
? TargetSelection<StateUpdateBuilder<S, P>, P, "update", "branch"> :
|
|
6878
|
+
never
|
|
6879
|
+
: D extends {
|
|
6880
|
+
/** Accepts the event without selecting a new destination. */
|
|
6881
|
+
readonly none: true
|
|
6882
|
+
} ? TargetSelection<() => NoTarget, never, "none", "local">
|
|
6883
|
+
: never
|
|
6884
|
+
type BuilderArgs<B, K extends PropertyKey> = K extends keyof B
|
|
6885
|
+
? B[K] extends (...args: infer A) => unknown ? A : never
|
|
6886
|
+
: never
|
|
6887
|
+
type ObjectConstruction<C, B> = {
|
|
6888
|
+
readonly [M in Extract<keyof B, "from" | "decoded">]: BuilderArgs<B, M> extends readonly [unknown?] ?
|
|
6889
|
+
& { readonly [K in M]: (context: C) => BuilderArgs<B, M>[0] }
|
|
6890
|
+
& { readonly [K in Exclude<"from" | "decoded", M>]?: never }
|
|
6891
|
+
: never
|
|
6892
|
+
}[Extract<keyof B, "from" | "decoded">]
|
|
6893
|
+
type ObjectDefault<B> = B extends {
|
|
6894
|
+
/** Constructs schema make input from the typed source context. */
|
|
6895
|
+
readonly from: () => unknown
|
|
6896
|
+
} | (() => unknown) ? {
|
|
6897
|
+
/** Constructs schema make input from the typed source context. */
|
|
6898
|
+
readonly from?: never /** Supplies an already decoded schema value from the typed source context. */
|
|
6899
|
+
readonly decoded?: never
|
|
6900
|
+
}
|
|
6901
|
+
: never
|
|
6902
|
+
type ObjectPolicy<C, Reenter extends boolean, Acceptance extends TransitionAcceptance> = {
|
|
6903
|
+
/** Set to true to exit and reenter the handler source. */
|
|
6904
|
+
readonly reenter?: Reenter extends true ? boolean : never
|
|
6905
|
+
/** Declines the transition before construction when the predicate returns false. */
|
|
6906
|
+
readonly guard?: "declinable" extends Acceptance ? ((context: C) => boolean) | undefined : never
|
|
6907
|
+
}
|
|
6908
|
+
// Leaf construction needs only schema inputs; expanding the path builder also
|
|
6909
|
+
// computes unrelated nested targets for each contextual event callback.
|
|
6910
|
+
type InlineNodeConstruction<C, Node> = [NodeSchema<Node>] extends [never] ? {
|
|
6911
|
+
readonly from?: (context: C) => undefined
|
|
6912
|
+
readonly decoded?: never
|
|
6913
|
+
} :
|
|
6914
|
+
| { readonly from: (context: C) => NodeMakeInput<Node>; readonly decoded?: never }
|
|
6915
|
+
| { readonly decoded: (context: C) => NodeValue<Node>; readonly from?: never }
|
|
6916
|
+
| ({} extends NodeMakeInput<Node> ? { readonly from?: never; readonly decoded?: never } : never)
|
|
6917
|
+
type InlineDestinationConstruction<
|
|
6918
|
+
S extends StateSchemas,
|
|
6919
|
+
Src extends StateNodeIdentifier<S>,
|
|
6920
|
+
P extends DestinationPath<S>,
|
|
6921
|
+
C
|
|
6922
|
+
> = P extends ChoiceIdentifier<S> ? { readonly from?: never; readonly decoded?: never }
|
|
6923
|
+
: P extends StateIdentifier<S> ?
|
|
6924
|
+
NodeByIdentifier<S, P> extends { readonly states: StateSchemas }
|
|
6925
|
+
? [NodeSchema<NodeByIdentifier<S, P>>] extends [never]
|
|
6926
|
+
? ObjectConstruction<C, BranchBuilderAt<S, Src, P>> | ObjectDefault<BranchBuilderAt<S, Src, P>>
|
|
6927
|
+
: never
|
|
6928
|
+
: InlineNodeConstruction<C, NodeByIdentifier<S, P>>
|
|
6929
|
+
: never
|
|
6930
|
+
type InlineDestination<S extends StateSchemas, Src extends StateNodeIdentifier<S>, C> = {
|
|
6931
|
+
readonly [P in DestinationPath<S>]:
|
|
6932
|
+
& {
|
|
6933
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6934
|
+
readonly target: ReferenceAt<S, P>
|
|
6935
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6936
|
+
readonly update?: never
|
|
6937
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
6938
|
+
readonly initial?: never
|
|
6939
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
6940
|
+
readonly history?: never
|
|
6941
|
+
/** Accepts the event without selecting a new destination. */
|
|
6942
|
+
readonly none?: never
|
|
6943
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
6944
|
+
readonly branches?: never
|
|
6945
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
6946
|
+
readonly resolve?: never
|
|
6947
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
6948
|
+
readonly declinable?: never
|
|
6949
|
+
}
|
|
6950
|
+
& InlineDestinationConstruction<S, Src, P, C>
|
|
6951
|
+
}[DestinationPath<S>]
|
|
6952
|
+
type InlinePairConstruction<
|
|
6953
|
+
S extends StateSchemas,
|
|
6954
|
+
Src extends StateNodeIdentifier<S>,
|
|
6955
|
+
P extends string,
|
|
6956
|
+
Owner extends ValuedStateIdentifier<S>,
|
|
6957
|
+
C
|
|
6958
|
+
> = P extends StateIdentifier<S> ? NodeByIdentifier<S, P> extends { readonly states: StateSchemas } ? {
|
|
6959
|
+
readonly [
|
|
6960
|
+
M in Extract<keyof BranchBuilderAt<S, Src, P> & keyof StateUpdateBuilder<S, Owner>, "from" | "decoded">
|
|
6961
|
+
]: BuilderArgs<BranchBuilderAt<S, Src, P>, M> extends readonly [unknown?] ?
|
|
6962
|
+
& {
|
|
6963
|
+
readonly [K in M]: (
|
|
6964
|
+
context: C
|
|
6965
|
+
) => {
|
|
6966
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
6967
|
+
readonly target: BuilderArgs<BranchBuilderAt<S, Src, P>, M>[0]
|
|
6968
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
6969
|
+
readonly update: BuilderArgs<StateUpdateBuilder<S, Owner>, M>[0]
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6972
|
+
& { readonly [K in Exclude<"from" | "decoded", M>]?: never }
|
|
6973
|
+
: never
|
|
6974
|
+
}[Extract<keyof BranchBuilderAt<S, Src, P> & keyof StateUpdateBuilder<S, Owner>, "from" | "decoded">]
|
|
6975
|
+
:
|
|
6976
|
+
| {
|
|
6977
|
+
readonly from: (
|
|
6978
|
+
context: C
|
|
6979
|
+
) => {
|
|
6980
|
+
readonly target: [NodeSchema<NodeByIdentifier<S, P>>] extends [never] ? undefined
|
|
6981
|
+
: NodeMakeInput<NodeByIdentifier<S, P>>
|
|
6982
|
+
readonly update: SchemaByIdentifier<S, Owner>["~type.make.in"]
|
|
6983
|
+
}
|
|
6984
|
+
readonly decoded?: never
|
|
6985
|
+
}
|
|
6986
|
+
| ([NodeSchema<NodeByIdentifier<S, P>>] extends [never] ? never
|
|
6987
|
+
: {
|
|
6988
|
+
readonly decoded: (
|
|
6989
|
+
context: C
|
|
6990
|
+
) => { readonly target: NodeValue<NodeByIdentifier<S, P>>; readonly update: StateByIdentifier<S, Owner> }
|
|
6991
|
+
readonly from?: never
|
|
6992
|
+
})
|
|
6993
|
+
: never
|
|
6994
|
+
type InlineCombined<S extends StateSchemas, Src extends StateNodeIdentifier<S>, C> = Src extends ChoiceIdentifier<S> ?
|
|
6995
|
+
never :
|
|
6996
|
+
[Extract<ParentStateIdentifier<Src>, ValuedStateIdentifier<S>>] extends [never] ? never :
|
|
6997
|
+
{
|
|
6998
|
+
readonly [P in DestinationPath<S>]: {
|
|
6999
|
+
readonly [Owner in Extract<ParentStateIdentifier<Src>, ParentStateIdentifier<P> & ValuedStateIdentifier<S>>]:
|
|
7000
|
+
& {
|
|
7001
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7002
|
+
readonly target: ReferenceAt<S, P>
|
|
7003
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7004
|
+
readonly update: ReferenceAt<S, Owner>
|
|
7005
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7006
|
+
readonly initial?: never
|
|
7007
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7008
|
+
readonly history?: never
|
|
7009
|
+
/** Accepts the event without selecting a new destination. */
|
|
7010
|
+
readonly none?: never
|
|
7011
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7012
|
+
readonly branches?: never
|
|
7013
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7014
|
+
readonly resolve?: never
|
|
7015
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7016
|
+
readonly declinable?: never
|
|
7017
|
+
}
|
|
7018
|
+
& InlinePairConstruction<S, Src, P, Owner, C>
|
|
7019
|
+
}[Extract<ParentStateIdentifier<Src>, ParentStateIdentifier<P> & ValuedStateIdentifier<S>>]
|
|
7020
|
+
}[DestinationPath<S>]
|
|
7021
|
+
type InlineUpdate<S extends StateSchemas, Src extends StateNodeIdentifier<S>, C> = Src extends ChoiceIdentifier<S> ?
|
|
7022
|
+
never :
|
|
7023
|
+
{
|
|
7024
|
+
readonly [P in Extract<Src | ParentStateIdentifier<Src>, ValuedStateIdentifier<S>>]:
|
|
7025
|
+
& {
|
|
7026
|
+
/** Set to true to exit and reenter the handler source. */
|
|
7027
|
+
readonly reenter?: P extends Src ? never : boolean
|
|
7028
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7029
|
+
readonly update: ReferenceAt<S, P>
|
|
7030
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7031
|
+
readonly target?: never
|
|
7032
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7033
|
+
readonly initial?: never
|
|
7034
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7035
|
+
readonly history?: never
|
|
7036
|
+
/** Accepts the event without selecting a new destination. */
|
|
7037
|
+
readonly none?: never
|
|
7038
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7039
|
+
readonly branches?: never
|
|
7040
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7041
|
+
readonly resolve?: never
|
|
7042
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7043
|
+
readonly declinable?: never
|
|
7044
|
+
}
|
|
7045
|
+
& ObjectConstruction<C, StateUpdateBuilder<S, P>>
|
|
7046
|
+
}[Extract<Src | ParentStateIdentifier<Src>, ValuedStateIdentifier<S>>]
|
|
7047
|
+
type InlineInitial<S extends StateSchemas, Src extends StateNodeIdentifier<S>, C> =
|
|
7048
|
+
[Exclude<ObjectCompoundPath<S>, "">] extends [never] ? never : {
|
|
7049
|
+
readonly [P in Exclude<ObjectCompoundPath<S>, "">]: InitialTargetFactory<NodeByIdentifier<S, P>, P> extends
|
|
7050
|
+
infer B ?
|
|
7051
|
+
& {
|
|
7052
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7053
|
+
readonly initial: ReferenceAt<S, P>
|
|
7054
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7055
|
+
readonly target?: never
|
|
7056
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7057
|
+
readonly update?: never
|
|
7058
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7059
|
+
readonly history?: never
|
|
7060
|
+
/** Accepts the event without selecting a new destination. */
|
|
7061
|
+
readonly none?: never
|
|
7062
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7063
|
+
readonly branches?: never
|
|
7064
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7065
|
+
readonly resolve?: never
|
|
7066
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7067
|
+
readonly declinable?: never
|
|
7068
|
+
}
|
|
7069
|
+
& (ObjectConstruction<C, B> | ObjectDefault<B>) :
|
|
7070
|
+
never
|
|
7071
|
+
}[Exclude<ObjectCompoundPath<S>, "">]
|
|
7072
|
+
type BranchSelections<S extends StateSchemas, Src extends StateNodeIdentifier<S>, Group> = {
|
|
7073
|
+
readonly [K in Extract<keyof Group, string>]: {
|
|
7074
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7075
|
+
readonly target: SelectionOf<S, Src, Group[K]>
|
|
7076
|
+
}
|
|
7077
|
+
}
|
|
7078
|
+
type ObjectBranchResolver<
|
|
7079
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7080
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7081
|
+
C,
|
|
7082
|
+
B extends Readonly<Record<string, TransitionBranchInput>>,
|
|
7083
|
+
Declinable extends boolean
|
|
7084
|
+
> = (
|
|
7085
|
+
context: C & { readonly select: BranchSelectors<B> } & DeclineCapability,
|
|
7086
|
+
enqueue: Enqueue<EventOf<Ev>, EmittedEventOf<Em>>
|
|
7087
|
+
) => BranchSelectionResult<B> | (Declinable extends true ? Declined : never)
|
|
7088
|
+
type InvalidBranchSelection<S extends StateSchemas, Src extends StateNodeIdentifier<S>, Group> = {
|
|
7089
|
+
readonly [K in keyof Group]: Src extends ChoiceIdentifier<S> ? Group[K] extends {
|
|
7090
|
+
/** Accepts the event without selecting a new destination. */
|
|
7091
|
+
readonly none: true
|
|
7092
|
+
} | {
|
|
7093
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7094
|
+
readonly update: unknown
|
|
7095
|
+
} ? K
|
|
7096
|
+
: [SelectionBuilder<SelectionOf<S, Src, Group[K]>>] extends [never] ? K
|
|
7097
|
+
: never
|
|
7098
|
+
: [SelectionBuilder<SelectionOf<S, Src, Group[K]>>] extends [never] ? K
|
|
7099
|
+
: never
|
|
7100
|
+
}[keyof Group]
|
|
7101
|
+
type ObjectBranches<
|
|
7102
|
+
S extends StateSchemas,
|
|
7103
|
+
Src extends StateNodeIdentifier<S>,
|
|
7104
|
+
C,
|
|
7105
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7106
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7107
|
+
R,
|
|
7108
|
+
Acceptance extends TransitionAcceptance
|
|
7109
|
+
> = {
|
|
7110
|
+
readonly [K in Extract<keyof Registered<R, "branches">, string>]:
|
|
7111
|
+
& ([InvalidBranchSelection<S, Src, Registered<R, "branches">[K]>] extends [never] ? unknown : never)
|
|
7112
|
+
& {
|
|
7113
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7114
|
+
readonly branches: K
|
|
7115
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7116
|
+
readonly target?: never
|
|
7117
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7118
|
+
readonly update?: never
|
|
7119
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7120
|
+
readonly initial?: never
|
|
7121
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7122
|
+
readonly history?: never
|
|
7123
|
+
/** Accepts the event without selecting a new destination. */
|
|
7124
|
+
readonly none?: never
|
|
7125
|
+
/** Constructs schema make input from the typed source context. */
|
|
7126
|
+
readonly from?: never
|
|
7127
|
+
/** Supplies an already decoded schema value from the typed source context. */
|
|
7128
|
+
readonly decoded?: never
|
|
7129
|
+
}
|
|
7130
|
+
& {
|
|
7131
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7132
|
+
readonly declinable?: "declinable" extends Acceptance ? boolean : false
|
|
7133
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7134
|
+
readonly resolve: ObjectBranchResolver<Ev, Em, C, BranchSelections<S, Src, Registered<R, "branches">[K]>, true>
|
|
7135
|
+
}
|
|
7136
|
+
}[Extract<keyof Registered<R, "branches">, string>]
|
|
7137
|
+
/**
|
|
7138
|
+
* A transition with an inspectable destination and source-specific construction.
|
|
7139
|
+
*
|
|
7140
|
+
* @category models
|
|
7141
|
+
* @since 0.34.0
|
|
7142
|
+
*/
|
|
7143
|
+
export type Transition<
|
|
7144
|
+
S extends StateSchemas,
|
|
7145
|
+
Src extends StateNodeIdentifier<S>,
|
|
7146
|
+
C,
|
|
7147
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7148
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7149
|
+
R,
|
|
7150
|
+
Reenter extends boolean = false,
|
|
7151
|
+
Acceptance extends TransitionAcceptance = "required"
|
|
7152
|
+
> =
|
|
7153
|
+
& ObjectPolicy<C, Reenter, Acceptance>
|
|
7154
|
+
& (
|
|
7155
|
+
| InlineDestination<S, Src, C>
|
|
7156
|
+
| InlineUpdate<S, Src, C>
|
|
7157
|
+
| InlineCombined<S, Src, C>
|
|
7158
|
+
| InlineInitial<S, Src, C>
|
|
7159
|
+
| {
|
|
7160
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7161
|
+
readonly history: ReferenceUnion<S, HistoryIdentifier<S>>
|
|
7162
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7163
|
+
readonly target?: never
|
|
7164
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7165
|
+
readonly update?: never
|
|
7166
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7167
|
+
readonly initial?: never
|
|
7168
|
+
/** Accepts the event without selecting a new destination. */
|
|
7169
|
+
readonly none?: never
|
|
7170
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7171
|
+
readonly branches?: never
|
|
7172
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7173
|
+
readonly resolve?: never
|
|
7174
|
+
/** Constructs schema make input from the typed source context. */
|
|
7175
|
+
readonly from?: never
|
|
7176
|
+
/** Supplies an already decoded schema value from the typed source context. */
|
|
7177
|
+
readonly decoded?: never
|
|
7178
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7179
|
+
readonly declinable?: never
|
|
7180
|
+
}
|
|
7181
|
+
| (Src extends ChoiceIdentifier<S> ? never : {
|
|
7182
|
+
/** Accepts the event without selecting a new destination. */
|
|
7183
|
+
readonly none: true
|
|
7184
|
+
/** Selects the declared descendant destination. Supply required values with from or decoded. */
|
|
7185
|
+
readonly target?: never
|
|
7186
|
+
/** Replaces the complete value of a retained source or ancestor without replacing its active children. */
|
|
7187
|
+
readonly update?: never
|
|
7188
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
7189
|
+
readonly initial?: never
|
|
7190
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7191
|
+
readonly history?: never
|
|
7192
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
7193
|
+
readonly branches?: never
|
|
7194
|
+
/** Constructs schema make input from the typed source context. */
|
|
7195
|
+
readonly from?: never
|
|
7196
|
+
/** Supplies an already decoded schema value from the typed source context. */
|
|
7197
|
+
readonly decoded?: never
|
|
7198
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7199
|
+
readonly declinable?: "declinable" extends Acceptance ? boolean : false
|
|
7200
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7201
|
+
readonly resolve?: (
|
|
7202
|
+
context: C & DeclineCapability,
|
|
7203
|
+
enqueue: Enqueue<EventOf<Ev>, EmittedEventOf<Em>>
|
|
7204
|
+
) => undefined | Declined
|
|
7205
|
+
})
|
|
7206
|
+
| ObjectBranches<S, Src, C, Ev, Em, R, Acceptance>
|
|
7207
|
+
)
|
|
7208
|
+
type SourceValue<R, K extends PropertyKey> = {
|
|
7209
|
+
readonly [Kind in "effects" | "streams" | "timers" | "logic" | "children"]: K extends keyof Registered<R, Kind>
|
|
7210
|
+
? Registered<R, Kind>[K]
|
|
7211
|
+
: never
|
|
7212
|
+
}["effects" | "streams" | "timers" | "logic" | "children"]
|
|
7213
|
+
type SourceKind<R, K extends PropertyKey> = {
|
|
7214
|
+
readonly [Kind in "effects" | "streams" | "timers" | "logic" | "children"]: K extends keyof Registered<R, Kind>
|
|
7215
|
+
? Kind
|
|
8578
7216
|
: never
|
|
8579
|
-
}
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
type
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
7217
|
+
}["effects" | "streams" | "timers" | "logic" | "children"]
|
|
7218
|
+
type SourceKeys<R> = {
|
|
7219
|
+
readonly [Kind in "effects" | "streams" | "timers" | "logic" | "children"]: keyof Registered<R, Kind>
|
|
7220
|
+
}["effects" | "streams" | "timers" | "logic" | "children"]
|
|
7221
|
+
type SourceInput<F, C> = F extends LazyProgramValue ? { readonly input?: never } :
|
|
7222
|
+
F extends (...args: never[]) => unknown ? Parameters<F>["length"] extends 1 ? {
|
|
7223
|
+
/** Maps the owning state context to the registered source input. */
|
|
7224
|
+
readonly input: (context: C) => Parameters<F>[0]
|
|
7225
|
+
} :
|
|
7226
|
+
never
|
|
7227
|
+
: {
|
|
7228
|
+
/** Maps the owning state context to the registered source input. */
|
|
7229
|
+
readonly input?: never
|
|
7230
|
+
}
|
|
7231
|
+
type ResolvedInvoke<R, K extends PropertyKey> = SourceKind<R, K> extends "effects" ?
|
|
7232
|
+
{ readonly effect: () => InvokeResolvedSource<SourceValue<R, K>> }
|
|
7233
|
+
: SourceKind<R, K> extends "streams" ? { readonly stream: () => InvokeResolvedSource<SourceValue<R, K>> }
|
|
7234
|
+
: SourceKind<R, K> extends "timers" ? { readonly after: Duration.Input }
|
|
7235
|
+
: SourceKind<R, K> extends "logic" ? {
|
|
7236
|
+
/** Logic values or functions of one required input; their Effect channels remain inferred. */
|
|
7237
|
+
readonly logic: InvokeResolvedSource<SourceValue<R, K>>
|
|
7238
|
+
}
|
|
7239
|
+
: SourceKind<R, K> extends "children" ?
|
|
7240
|
+
& { readonly child: SourceValue<R, K> }
|
|
7241
|
+
& (SourceValue<R, K> extends ChildMachine<string, infer M> ? {
|
|
7242
|
+
readonly [InvokeTypeId]: {
|
|
7243
|
+
readonly error: Types.Covariant<Error<M> | ActionError<Services<M>>>
|
|
7244
|
+
readonly initialError: Types.Covariant<InitialError<M>>
|
|
7245
|
+
readonly requirements: Types.Covariant<Services<M>>
|
|
7246
|
+
}
|
|
7247
|
+
} :
|
|
7248
|
+
never) :
|
|
7249
|
+
never
|
|
7250
|
+
type RegisteredInvocationInput<R, K extends PropertyKey, C> = SourceKind<R, K> extends "children" ?
|
|
7251
|
+
SourceValue<R, K> extends ChildMachine<string, infer M> ? InputSchema<M> extends typeof Schema.Void ? {
|
|
7252
|
+
/** Maps the owning state context to the registered source input. */
|
|
7253
|
+
readonly input?: never
|
|
7254
|
+
}
|
|
7255
|
+
: {
|
|
7256
|
+
/** Maps the owning state context to the registered source input. */
|
|
7257
|
+
readonly input: (context: C) => Input<M>
|
|
7258
|
+
} :
|
|
7259
|
+
never
|
|
7260
|
+
: SourceInput<SourceValue<R, K>, C>
|
|
7261
|
+
type ObjectOutcome<
|
|
7262
|
+
S extends StateSchemas,
|
|
7263
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7264
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7265
|
+
Src extends StateIdentifier<S>,
|
|
7266
|
+
In extends ReadonlyArray<TaggedSchema>,
|
|
7267
|
+
Pa extends ReadonlyArray<TaggedSchema>,
|
|
8596
7268
|
R,
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
7269
|
+
V,
|
|
7270
|
+
Channel extends "onDone" | "onFailure" | "onElement" | "onSnapshot"
|
|
7271
|
+
> = [V] extends [never] ? {} : Channel extends "onDone" ? {
|
|
7272
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
7273
|
+
readonly onDone: Transition<
|
|
7274
|
+
S,
|
|
7275
|
+
Src,
|
|
7276
|
+
InvokeDoneContext<S, Ev, Em, Src, V, In, Pa>,
|
|
7277
|
+
Ev,
|
|
7278
|
+
Em,
|
|
7279
|
+
R,
|
|
7280
|
+
true,
|
|
7281
|
+
TransitionAcceptance
|
|
7282
|
+
>
|
|
7283
|
+
} :
|
|
7284
|
+
Channel extends "onFailure" ? {
|
|
7285
|
+
/** Handles the typed failure of the invoked source; required exactly when that channel is reachable. */
|
|
7286
|
+
readonly onFailure: Transition<
|
|
7287
|
+
S,
|
|
7288
|
+
Src,
|
|
7289
|
+
InvokeFailureContext<S, Ev, Em, Src, V, In, Pa>,
|
|
7290
|
+
Ev,
|
|
7291
|
+
Em,
|
|
7292
|
+
R,
|
|
7293
|
+
true,
|
|
7294
|
+
TransitionAcceptance
|
|
7295
|
+
>
|
|
7296
|
+
} :
|
|
7297
|
+
Channel extends "onElement" ? {
|
|
7298
|
+
/** Handles each Stream element; required when the element type is reachable. */
|
|
7299
|
+
readonly onElement: Transition<
|
|
7300
|
+
S,
|
|
7301
|
+
Src,
|
|
7302
|
+
InvokeElementContext<S, Ev, Em, Src, V, In, Pa>,
|
|
7303
|
+
Ev,
|
|
7304
|
+
Em,
|
|
7305
|
+
R,
|
|
7306
|
+
true,
|
|
7307
|
+
TransitionAcceptance
|
|
7308
|
+
>
|
|
7309
|
+
} :
|
|
7310
|
+
{
|
|
7311
|
+
/** Optionally handles active snapshots of invoked logic or a child machine. */
|
|
7312
|
+
readonly onSnapshot: Transition<
|
|
7313
|
+
S,
|
|
7314
|
+
Src,
|
|
7315
|
+
InvokeSnapshotContext<S, Ev, Em, Src, V, never, never, In, Pa>,
|
|
7316
|
+
Ev,
|
|
7317
|
+
Em,
|
|
7318
|
+
R,
|
|
7319
|
+
true,
|
|
7320
|
+
TransitionAcceptance
|
|
7321
|
+
>
|
|
7322
|
+
}
|
|
7323
|
+
type RegisteredInvokeError<R, K extends PropertyKey> = SourceKind<R, K> extends "children"
|
|
7324
|
+
? SourceValue<R, K> extends ChildMachine<string, infer M> ? Error<M> | ActionError<Services<M>> : never
|
|
7325
|
+
: InvokeRuntimeError<ResolvedInvoke<R, K>>
|
|
7326
|
+
/**
|
|
7327
|
+
* A registered source invocation with its required input and reachable outcomes.
|
|
7328
|
+
*
|
|
7329
|
+
* @category models
|
|
7330
|
+
* @since 0.34.0
|
|
7331
|
+
*/
|
|
7332
|
+
export type Invocation<
|
|
7333
|
+
S extends StateSchemas,
|
|
7334
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7335
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7336
|
+
Src extends StateIdentifier<S>,
|
|
7337
|
+
In extends ReadonlyArray<TaggedSchema>,
|
|
7338
|
+
Pa extends ReadonlyArray<TaggedSchema>,
|
|
7339
|
+
R
|
|
7340
|
+
> = {
|
|
7341
|
+
readonly [K in Extract<SourceKeys<R>, string>]: Types.Simplify<
|
|
7342
|
+
& {
|
|
7343
|
+
/** Name of the source registered in make. */
|
|
7344
|
+
readonly src: K
|
|
7345
|
+
}
|
|
7346
|
+
& (SourceKind<R, K> extends "children" ? {
|
|
7347
|
+
/** Lifecycle identifier; Effects, Streams, and timers default to their registered source name. */
|
|
7348
|
+
readonly id?:
|
|
7349
|
+
never /** Typed runtime address required for invoked logic; child descriptors carry their own address. */
|
|
7350
|
+
readonly address?: never
|
|
7351
|
+
}
|
|
7352
|
+
: SourceKind<R, K> extends "logic" ? {
|
|
7353
|
+
/** Lifecycle identifier; Effects, Streams, and timers default to their registered source name. */
|
|
7354
|
+
readonly id: InvokeLifecycleId
|
|
7355
|
+
/** Typed runtime address required for invoked logic; child descriptors carry their own address. */
|
|
7356
|
+
readonly address: ChildAddress<LogicEventOf<InvokeResolvedSource<SourceValue<R, K>>>>
|
|
7357
|
+
}
|
|
7358
|
+
: {
|
|
7359
|
+
/** Lifecycle identifier; Effects, Streams, and timers default to their registered source name. */
|
|
7360
|
+
readonly id?:
|
|
7361
|
+
InvokeLifecycleId /** Typed runtime address required for invoked logic; child descriptors carry their own address. */
|
|
7362
|
+
readonly address?: never
|
|
7363
|
+
})
|
|
7364
|
+
& (SourceKind<R, K> extends "children"
|
|
7365
|
+
? SourceValue<R, K> extends ChildMachine<string, infer M>
|
|
7366
|
+
? M extends EnsureExecutable<States<M>, UnhandledStates<M>, OutputStates<M>> ? unknown : never
|
|
7367
|
+
: never
|
|
7368
|
+
: unknown)
|
|
7369
|
+
& RegisteredInvocationInput<R, K, InvokeContext<S, Ev, Em, Src, In, Pa>>
|
|
7370
|
+
& ObjectOutcome<S, Ev, Em, Src, In, Pa, R, InvokeOutput<ResolvedInvoke<R, K>>, "onDone">
|
|
7371
|
+
& ObjectOutcome<S, Ev, Em, Src, In, Pa, R, RegisteredInvokeError<R, K>, "onFailure">
|
|
7372
|
+
& ObjectOutcome<
|
|
7373
|
+
S,
|
|
7374
|
+
Ev,
|
|
7375
|
+
Em,
|
|
7376
|
+
Src,
|
|
7377
|
+
In,
|
|
7378
|
+
Pa,
|
|
7379
|
+
R,
|
|
7380
|
+
SourceKind<R, K> extends "streams"
|
|
7381
|
+
? Stream.Success<Extract<InvokeResolvedSource<SourceValue<R, K>>, Stream.Stream<any, any, any>>> :
|
|
7382
|
+
never,
|
|
7383
|
+
"onElement"
|
|
7384
|
+
>
|
|
7385
|
+
& (SourceKind<R, K> extends "logic" | "children" ? Partial<
|
|
7386
|
+
ObjectOutcome<S, Ev, Em, Src, In, Pa, R, LogicStateOf<InvokeLogic<ResolvedInvoke<R, K>>>, "onSnapshot">
|
|
7387
|
+
>
|
|
7388
|
+
: {})
|
|
7389
|
+
>
|
|
7390
|
+
}[Extract<SourceKeys<R>, string>]
|
|
7391
|
+
type ObjectLifecycle<
|
|
7392
|
+
S extends StateSchemas,
|
|
7393
|
+
Node,
|
|
7394
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7395
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7396
|
+
Src extends StateNodeIdentifier<S>,
|
|
7397
|
+
In extends ReadonlyArray<TaggedSchema>,
|
|
7398
|
+
Pa extends ReadonlyArray<TaggedSchema>
|
|
7399
|
+
> = Src extends StateIdentifier<S> ?
|
|
7400
|
+
& {
|
|
7401
|
+
/** Runs synchronously on entry and may enqueue commands. */
|
|
7402
|
+
readonly entry?: (
|
|
7403
|
+
context: StateActionContext<S, Ev, Em, Src, In, Pa>,
|
|
7404
|
+
enqueue: Enqueue<EventOf<Ev>, EmittedEventOf<Em>>
|
|
7405
|
+
) => StateActionResult<any, any>
|
|
7406
|
+
}
|
|
7407
|
+
& (Node extends { readonly type: "final" } ?
|
|
7408
|
+
& {
|
|
7409
|
+
/** Runs synchronously on exit and may enqueue commands. */
|
|
7410
|
+
readonly exit?: never /** Constructs required values for the declared initial child or parallel regions. */
|
|
7411
|
+
readonly initialize?: never
|
|
7412
|
+
}
|
|
7413
|
+
& OutputHandlerConfig<S, Ev, Src, FinalOutputContext<S, Ev, Src>>
|
|
7414
|
+
: {
|
|
7415
|
+
/** Runs synchronously on exit and may enqueue commands. */
|
|
7416
|
+
readonly exit?: (
|
|
7417
|
+
context: StateActionContext<S, Ev, Em, Src, In, Pa>,
|
|
7418
|
+
enqueue: Enqueue<EventOf<Ev>, EmittedEventOf<Em>>
|
|
7419
|
+
) => StateActionResult<any, any>
|
|
7420
|
+
/** Constructs required values for the declared initial child or parallel regions. */
|
|
7421
|
+
readonly initialize?: StateInitializeHandler<S, Ev, Em, Src, In, Pa>
|
|
7422
|
+
} & ActiveOutputHandlerConfig<S, Ev, Src>)
|
|
7423
|
+
: {
|
|
7424
|
+
/** Runs synchronously on entry and may enqueue commands. */
|
|
7425
|
+
readonly entry?: never /** Runs synchronously on exit and may enqueue commands. */
|
|
7426
|
+
readonly exit?: never /** Constructs required values for the declared initial child or parallel regions. */
|
|
7427
|
+
readonly initialize?: never /** Constructs the decoded output declared by the state schema. */
|
|
7428
|
+
readonly output?: never
|
|
7429
|
+
}
|
|
7430
|
+
/**
|
|
7431
|
+
* Handlers for a node of the declared root tree.
|
|
7432
|
+
*
|
|
7433
|
+
* @category models
|
|
7434
|
+
* @since 0.34.0
|
|
7435
|
+
*/
|
|
7436
|
+
export type StateHandler<
|
|
7437
|
+
S extends StateSchemas,
|
|
7438
|
+
Node,
|
|
7439
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7440
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7441
|
+
Src extends StateNodeIdentifier<S>,
|
|
7442
|
+
In extends ReadonlyArray<TaggedSchema>,
|
|
7443
|
+
Pa extends ReadonlyArray<TaggedSchema>,
|
|
7444
|
+
R
|
|
7445
|
+
> =
|
|
7446
|
+
& ObjectLifecycle<S, Node, Ev, Em, Src, In, Pa>
|
|
7447
|
+
& (Src extends ChoiceIdentifier<S> ? {
|
|
7448
|
+
/** Required total transition for a transient choice state. */
|
|
7449
|
+
readonly choice: Transition<S, Src, ChoiceContext<S, Ev, Em, Src, In, Pa>, Ev, Em, R>
|
|
7450
|
+
/** Event handlers keyed by the public or internal event tag. */
|
|
7451
|
+
readonly on?: never
|
|
7452
|
+
/** Eventless transition evaluated during stabilization. */
|
|
7453
|
+
readonly always?: never
|
|
7454
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
7455
|
+
readonly onDone?: never
|
|
7456
|
+
/** One registered invocation or an array with distinct lifecycle identities. */
|
|
7457
|
+
readonly invoke?: never
|
|
7458
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7459
|
+
readonly states?: never
|
|
7460
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7461
|
+
readonly history?: never
|
|
7462
|
+
}
|
|
7463
|
+
: Src extends StateIdentifier<S> ? Node extends { readonly type: "final" } ? {
|
|
7464
|
+
/** Event handlers keyed by the public or internal event tag. */
|
|
7465
|
+
readonly on?: never
|
|
7466
|
+
/** Eventless transition evaluated during stabilization. */
|
|
7467
|
+
readonly always?: never
|
|
7468
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
7469
|
+
readonly onDone?: never
|
|
7470
|
+
/** Required total transition for a transient choice state. */
|
|
7471
|
+
readonly choice?: never
|
|
7472
|
+
/** One registered invocation or an array with distinct lifecycle identities. */
|
|
7473
|
+
readonly invoke?: never
|
|
7474
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7475
|
+
readonly states?: never
|
|
7476
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7477
|
+
readonly history?: never
|
|
7478
|
+
}
|
|
7479
|
+
:
|
|
7480
|
+
& {
|
|
7481
|
+
/** Event handlers keyed by the public or internal event tag. */
|
|
7482
|
+
readonly on?: {
|
|
7483
|
+
readonly [Tag in TagOf<Ev[number]>]?: Transition<
|
|
7484
|
+
S,
|
|
7485
|
+
Src,
|
|
7486
|
+
HandlerContext<S, Ev, Em, Src, Tag, never, never, In, Pa>,
|
|
7487
|
+
Ev,
|
|
7488
|
+
Em,
|
|
7489
|
+
R,
|
|
7490
|
+
true,
|
|
7491
|
+
TransitionAcceptance
|
|
7492
|
+
>
|
|
7493
|
+
}
|
|
7494
|
+
/** Eventless transition evaluated during stabilization. */
|
|
7495
|
+
readonly always?: Transition<
|
|
7496
|
+
S,
|
|
7497
|
+
Src,
|
|
7498
|
+
AlwaysContext<S, Ev, Em, Src, In, Pa>,
|
|
7499
|
+
Ev,
|
|
7500
|
+
Em,
|
|
7501
|
+
R,
|
|
7502
|
+
false,
|
|
7503
|
+
TransitionAcceptance
|
|
7504
|
+
>
|
|
7505
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
7506
|
+
readonly onDone?: Transition<
|
|
7507
|
+
S,
|
|
7508
|
+
Src,
|
|
7509
|
+
DoneContext<S, Ev, Em, Src, In, Pa>,
|
|
7510
|
+
Ev,
|
|
7511
|
+
Em,
|
|
7512
|
+
R,
|
|
7513
|
+
false,
|
|
7514
|
+
TransitionAcceptance
|
|
7515
|
+
>
|
|
7516
|
+
/** Required total transition for a transient choice state. */
|
|
7517
|
+
readonly choice?: never
|
|
7518
|
+
/** One registered invocation or an array with distinct lifecycle identities. */
|
|
7519
|
+
readonly invoke?:
|
|
7520
|
+
| Invocation<S, Ev, Em, Src, In, Pa, R>
|
|
7521
|
+
| (ReadonlyArray<Invocation<S, Ev, Em, Src, In, Pa, R>> & {
|
|
7522
|
+
/** Name of the source registered in make. */
|
|
7523
|
+
readonly src?: never
|
|
7524
|
+
})
|
|
7525
|
+
}
|
|
7526
|
+
& (Node extends {
|
|
7527
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7528
|
+
readonly states: infer Children extends StateSchemas
|
|
7529
|
+
} ? {
|
|
7530
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7531
|
+
readonly states?: {
|
|
7532
|
+
readonly [K in ActiveStateKey<Children> | ChoiceStateKey<Children>]?: StateHandler<
|
|
7533
|
+
S,
|
|
7534
|
+
Children[K],
|
|
7535
|
+
Ev,
|
|
7536
|
+
Em,
|
|
7537
|
+
Extract<JoinPath<Src, K>, StateNodeIdentifier<S>>,
|
|
7538
|
+
In,
|
|
7539
|
+
Pa,
|
|
7540
|
+
R
|
|
7541
|
+
>
|
|
7542
|
+
}
|
|
7543
|
+
/** Restores the declared history reference, using its fallback on first entry. */
|
|
7544
|
+
readonly history?: HistoryDefaultConfig<S, Ev, Em, Src, Children>
|
|
7545
|
+
} :
|
|
7546
|
+
{
|
|
7547
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7548
|
+
readonly states?: never /** Restores the declared history reference, using its fallback on first entry. */
|
|
7549
|
+
readonly history?: never
|
|
7550
|
+
}) :
|
|
7551
|
+
never)
|
|
7552
|
+
type ValidateObjectTransition<T> =
|
|
7553
|
+
& {
|
|
7554
|
+
readonly [
|
|
7555
|
+
K in Exclude<
|
|
7556
|
+
keyof T,
|
|
7557
|
+
| "target"
|
|
7558
|
+
| "update"
|
|
7559
|
+
| "initial"
|
|
7560
|
+
| "history"
|
|
7561
|
+
| "none"
|
|
7562
|
+
| "branches"
|
|
7563
|
+
| "from"
|
|
7564
|
+
| "decoded"
|
|
7565
|
+
| "resolve"
|
|
7566
|
+
| "guard"
|
|
7567
|
+
| "reenter"
|
|
7568
|
+
| "declinable"
|
|
7569
|
+
>
|
|
7570
|
+
]: never
|
|
7571
|
+
}
|
|
7572
|
+
& (T extends {
|
|
7573
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7574
|
+
readonly declinable: infer D
|
|
7575
|
+
} ? boolean extends D ? {
|
|
7576
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7577
|
+
readonly declinable: never
|
|
7578
|
+
} :
|
|
7579
|
+
unknown
|
|
7580
|
+
: unknown)
|
|
7581
|
+
& (T extends {
|
|
7582
|
+
/** Set to true when the resolver can explicitly return decline(). */
|
|
7583
|
+
readonly declinable: true
|
|
7584
|
+
} ? unknown
|
|
7585
|
+
: T extends {
|
|
7586
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7587
|
+
readonly resolve: (...args: any[]) => infer Result
|
|
7588
|
+
} ? [Extract<Result, Declined>] extends [never] ? unknown : {
|
|
7589
|
+
/** Selects one declared branch and may enqueue synchronous commands. */
|
|
7590
|
+
readonly resolve: never
|
|
7591
|
+
}
|
|
7592
|
+
: unknown)
|
|
7593
|
+
type AllowedInvokeChannels<R, K extends PropertyKey> =
|
|
7594
|
+
| ([InvokeOutput<ResolvedInvoke<R, K>>] extends [never] ? never : "onDone")
|
|
7595
|
+
| ([RegisteredInvokeError<R, K>] extends [never] ? never : "onFailure")
|
|
7596
|
+
| (SourceKind<R, K> extends "streams"
|
|
7597
|
+
? [Stream.Success<Extract<InvokeResolvedSource<SourceValue<R, K>>, Stream.Stream<any, any, any>>>] extends [never]
|
|
7598
|
+
? never
|
|
7599
|
+
: "onElement"
|
|
7600
|
+
: never)
|
|
7601
|
+
| (SourceKind<R, K> extends "logic" | "children" ? "onSnapshot" : never)
|
|
7602
|
+
type ValidateObjectInvoke<I, R> = I extends ReadonlyArray<unknown> ?
|
|
7603
|
+
{ readonly [K in keyof I]: ValidateObjectInvoke<I[K], R> } :
|
|
7604
|
+
I extends {
|
|
7605
|
+
/** Name of the source registered in make. */
|
|
7606
|
+
readonly src: infer Src extends PropertyKey
|
|
7607
|
+
} ? {
|
|
7608
|
+
readonly [K in keyof I]: K extends AllowedInvokeChannels<R, Src> ? ValidateObjectTransition<I[K]>
|
|
7609
|
+
: K extends "src" | "id" | "address" | "input" ? unknown
|
|
7610
|
+
: never
|
|
7611
|
+
} :
|
|
7612
|
+
never
|
|
7613
|
+
type ObjectDeclarations<C> =
|
|
7614
|
+
| Extract<keyof C, "on" | "always" | "onDone" | "choice" | "invoke">
|
|
7615
|
+
| (C extends { readonly states: infer Children }
|
|
7616
|
+
? { readonly [K in keyof Children]: ObjectDeclarations<Children[K]> }[keyof Children]
|
|
7617
|
+
: never)
|
|
7618
|
+
type ValidateObjectConfig<C, R> = [ObjectDeclarations<C>] extends [never] ? unknown : {
|
|
7619
|
+
readonly [K in keyof C]: K extends "states" ? { readonly [P in keyof C[K]]: ValidateObjectConfig<C[K][P], R> }
|
|
7620
|
+
: K extends "on" ? { readonly [P in keyof C[K]]: ValidateObjectTransition<C[K][P]> }
|
|
7621
|
+
: K extends "always" | "onDone" | "choice" ? ValidateObjectTransition<C[K]>
|
|
7622
|
+
: K extends "invoke" ? ValidateObjectInvoke<C[K], R>
|
|
7623
|
+
: unknown
|
|
7624
|
+
}
|
|
7625
|
+
type NormalizeObjectInvoke<I, R> = I extends ReadonlyArray<unknown> ?
|
|
7626
|
+
{ readonly [K in keyof I]: NormalizeObjectInvoke<I[K], R> }
|
|
7627
|
+
: I extends {
|
|
7628
|
+
/** Name of the source registered in make. */
|
|
7629
|
+
readonly src: infer K extends PropertyKey
|
|
7630
|
+
} ? Omit<I, "src"> & ResolvedInvoke<R, K>
|
|
7631
|
+
: I
|
|
7632
|
+
type NormalizeObjectConfig<C, R> = [SourceKeys<R>] extends [never] ? C : {
|
|
7633
|
+
readonly [K in keyof C]: K extends "states" ? { readonly [P in keyof C[K]]: NormalizeObjectConfig<C[K][P], R> }
|
|
7634
|
+
: K extends "invoke" ? NormalizeObjectInvoke<C[K], R>
|
|
7635
|
+
: C[K]
|
|
7636
|
+
}
|
|
7637
|
+
// Reverse-map authored fields to avoid expanding every possible transition.
|
|
7638
|
+
// Retain missing fields from H for required handlers and editor completion.
|
|
7639
|
+
type HandlerShape<C, H> =
|
|
7640
|
+
& {
|
|
7641
|
+
readonly [K in keyof C]: K extends keyof H ? K extends "states" ? {
|
|
7642
|
+
readonly [P in keyof C[K]]: P extends keyof NonNullable<H[K]>
|
|
7643
|
+
? HandlerShape<C[K][P], NonNullable<NonNullable<H[K]>[P]>>
|
|
7644
|
+
: never
|
|
7645
|
+
}
|
|
7646
|
+
: H[K]
|
|
7647
|
+
: never
|
|
7648
|
+
}
|
|
7649
|
+
& Omit<H, keyof C>
|
|
8626
7650
|
/**
|
|
8627
|
-
* Adds
|
|
7651
|
+
* Adds object handlers while checking topology, protocols, invocation outcomes, and readiness.
|
|
8628
7652
|
*
|
|
8629
7653
|
* @category combinators
|
|
8630
|
-
* @since 0.
|
|
7654
|
+
* @since 0.34.0
|
|
8631
7655
|
*/
|
|
8632
7656
|
export interface Handler<
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
OutputStates extends StateIdentifier<States>,
|
|
8645
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8646
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>
|
|
7657
|
+
S extends StateSchemas,
|
|
7658
|
+
Ev extends ReadonlyArray<TaggedSchema>,
|
|
7659
|
+
Em extends ReadonlyArray<TaggedSchema>,
|
|
7660
|
+
I extends Schema.Top,
|
|
7661
|
+
IE,
|
|
7662
|
+
IR,
|
|
7663
|
+
Final extends StateIdentifier<S>,
|
|
7664
|
+
Out,
|
|
7665
|
+
In extends ReadonlyArray<TaggedSchema>,
|
|
7666
|
+
Pa extends ReadonlyArray<TaggedSchema>,
|
|
7667
|
+
R
|
|
8647
7668
|
> {
|
|
8648
|
-
<
|
|
8649
|
-
const Config
|
|
8650
|
-
>(
|
|
7669
|
+
<const C>(
|
|
8651
7670
|
config:
|
|
8652
|
-
&
|
|
8653
|
-
& (
|
|
8654
|
-
&
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
Emits,
|
|
8659
|
-
E,
|
|
8660
|
-
R,
|
|
8661
|
-
InputEvents,
|
|
8662
|
-
ParentEvents,
|
|
8663
|
-
Extract<"", StateNodeIdentifier<States>>
|
|
8664
|
-
>
|
|
7671
|
+
& C
|
|
7672
|
+
& (C extends (...args: never[]) => unknown ? never : unknown)
|
|
7673
|
+
& ([Ev[number] | keyof Registered<R, "branches"> | SourceKeys<R>] extends [never]
|
|
7674
|
+
? StateHandler<S, S[""], Ev, Em, Extract<"", StateNodeIdentifier<S>>, In, Pa, R>
|
|
7675
|
+
: HandlerShape<C, StateHandler<S, S[""], Ev, Em, Extract<"", StateNodeIdentifier<S>>, In, Pa, R>>)
|
|
7676
|
+
& ValidateObjectConfig<NoInfer<C>, R>
|
|
8665
7677
|
& RootHandlerValidation<
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
NoInfer<
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
StateIdentifier<States>
|
|
7678
|
+
S,
|
|
7679
|
+
Ev,
|
|
7680
|
+
In,
|
|
7681
|
+
Em,
|
|
7682
|
+
NormalizeObjectConfig<NoInfer<C>, R>,
|
|
7683
|
+
Extract<
|
|
7684
|
+
HandlerTreeEvidence<S, { readonly "": NormalizeObjectConfig<NoInfer<C>, R> }>["outputState"],
|
|
7685
|
+
StateIdentifier<S>
|
|
8675
7686
|
>
|
|
8676
7687
|
>
|
|
8677
7688
|
): HandleTreeResult<
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
{ readonly "":
|
|
7689
|
+
S,
|
|
7690
|
+
Ev,
|
|
7691
|
+
Em,
|
|
7692
|
+
I,
|
|
7693
|
+
StateIdentifier<S>,
|
|
7694
|
+
never,
|
|
7695
|
+
never,
|
|
7696
|
+
IE,
|
|
7697
|
+
IR,
|
|
7698
|
+
Final,
|
|
7699
|
+
Out,
|
|
7700
|
+
never,
|
|
7701
|
+
In,
|
|
7702
|
+
Pa,
|
|
7703
|
+
{ readonly "": NormalizeObjectConfig<C, R> }
|
|
8693
7704
|
>
|
|
8694
7705
|
}
|
|
8695
7706
|
|
|
@@ -8747,15 +7758,19 @@ export declare namespace Machine {
|
|
|
8747
7758
|
E,
|
|
8748
7759
|
R
|
|
8749
7760
|
> {
|
|
7761
|
+
/** Runs synchronously on entry and may enqueue commands. */
|
|
8750
7762
|
readonly entry?: (
|
|
8751
7763
|
context: StateActionContext<States, Events, Emits, StateId>,
|
|
8752
7764
|
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
8753
7765
|
) => StateActionResult<E, R>
|
|
7766
|
+
/** Runs synchronously on exit and may enqueue commands. */
|
|
8754
7767
|
readonly exit?: (
|
|
8755
7768
|
context: StateActionContext<States, Events, Emits, StateId>,
|
|
8756
7769
|
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
8757
7770
|
) => StateActionResult<E, R>
|
|
7771
|
+
/** One registered invocation or an array with distinct lifecycle identities. */
|
|
8758
7772
|
readonly invoke?: StoredInvokeDefinition<States, Events, Emits, StateId>
|
|
7773
|
+
/** Eventless transition evaluated during stabilization. */
|
|
8759
7774
|
readonly always?: TransitionConfig<
|
|
8760
7775
|
States,
|
|
8761
7776
|
Events,
|
|
@@ -8765,6 +7780,7 @@ export declare namespace Machine {
|
|
|
8765
7780
|
false,
|
|
8766
7781
|
TransitionAcceptance
|
|
8767
7782
|
>
|
|
7783
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
8768
7784
|
readonly onDone?: TransitionConfig<
|
|
8769
7785
|
States,
|
|
8770
7786
|
Events,
|
|
@@ -8774,9 +7790,11 @@ export declare namespace Machine {
|
|
|
8774
7790
|
false,
|
|
8775
7791
|
TransitionAcceptance
|
|
8776
7792
|
>
|
|
7793
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
8777
7794
|
readonly output?:
|
|
8778
7795
|
| ((context: FinalOutputContext<States, Events, StateId>) => unknown)
|
|
8779
7796
|
| ((context: ParallelOutputContext<States, Events, StateId>) => unknown)
|
|
7797
|
+
/** Event handlers keyed by the public or internal event tag. */
|
|
8780
7798
|
readonly on?: EventHandlerMap<States, Events, Emits, StateId, EventTag, E, R>
|
|
8781
7799
|
}
|
|
8782
7800
|
|
|
@@ -8828,7 +7846,10 @@ export declare namespace Snapshot {
|
|
|
8828
7846
|
export type Node<State> = State extends { readonly path: string; readonly value: unknown } ?
|
|
8829
7847
|
| State
|
|
8830
7848
|
| (State extends { readonly state: infer Child } ? Node<Child>
|
|
8831
|
-
: State extends {
|
|
7849
|
+
: State extends {
|
|
7850
|
+
/** Child handlers nested according to the declared root topology. */
|
|
7851
|
+
readonly states: infer Regions
|
|
7852
|
+
} ? Node<Regions[keyof Regions]>
|
|
8832
7853
|
: never) :
|
|
8833
7854
|
never
|
|
8834
7855
|
/** Every valid absolute path in a logical snapshot type. */
|
|
@@ -8956,6 +7977,76 @@ export const isFinal: <
|
|
|
8956
7977
|
*/
|
|
8957
7978
|
export const state: StateConstructor = internal.state as StateConstructor
|
|
8958
7979
|
|
|
7980
|
+
/**
|
|
7981
|
+
* An opaque reference to one node in a declared state tree.
|
|
7982
|
+
*
|
|
7983
|
+
* @category models
|
|
7984
|
+
* @since 0.34.0
|
|
7985
|
+
*/
|
|
7986
|
+
export interface TargetReference<
|
|
7987
|
+
Root extends Machine.StateNodeConfig,
|
|
7988
|
+
Path extends string,
|
|
7989
|
+
Kind extends "state" | "choice" | "history"
|
|
7990
|
+
> {
|
|
7991
|
+
readonly [internal.TargetReferenceTypeId]: {
|
|
7992
|
+
readonly root: { readonly node: Root }
|
|
7993
|
+
readonly path: Path
|
|
7994
|
+
readonly kind: Kind
|
|
7995
|
+
}
|
|
7996
|
+
}
|
|
7997
|
+
|
|
7998
|
+
type TargetReferenceTree<Root extends Machine.StateNodeConfig, Node, Path extends string> =
|
|
7999
|
+
& TargetReference<
|
|
8000
|
+
Root,
|
|
8001
|
+
Path,
|
|
8002
|
+
Node extends { readonly type: "history" } ? "history"
|
|
8003
|
+
: Node extends { readonly type: "choice" } ? "choice"
|
|
8004
|
+
: "state"
|
|
8005
|
+
>
|
|
8006
|
+
& (Node extends {
|
|
8007
|
+
/** Child handlers nested according to the declared root topology. */
|
|
8008
|
+
readonly states: infer Children
|
|
8009
|
+
} ? {
|
|
8010
|
+
readonly [Key in Extract<keyof Children, string>]: TargetReferenceTree<
|
|
8011
|
+
Root,
|
|
8012
|
+
Children[Key],
|
|
8013
|
+
Machine.JoinPath<Path, Key>
|
|
8014
|
+
>
|
|
8015
|
+
} :
|
|
8016
|
+
{})
|
|
8017
|
+
|
|
8018
|
+
/**
|
|
8019
|
+
* References for every path in a declared root tree.
|
|
8020
|
+
*
|
|
8021
|
+
* @category models
|
|
8022
|
+
* @since 0.34.0
|
|
8023
|
+
*/
|
|
8024
|
+
export interface Targets<Root extends Machine.StateNodeConfig> {
|
|
8025
|
+
/** Root data owner and the starting point for descendant state references. */
|
|
8026
|
+
readonly root: TargetReferenceTree<Root, Root, "">
|
|
8027
|
+
}
|
|
8028
|
+
|
|
8029
|
+
/**
|
|
8030
|
+
* Derives immutable state references from a root descriptor.
|
|
8031
|
+
*
|
|
8032
|
+
* References follow the declared tree: `targets.root.Checkout.Review`.
|
|
8033
|
+
* Creating references does not construct state values or start machine work.
|
|
8034
|
+
*
|
|
8035
|
+
* @category constructors
|
|
8036
|
+
* @since 0.34.0
|
|
8037
|
+
*/
|
|
8038
|
+
export const targets: <const Root extends Machine.StateNodeConfig>(root: State<Root>) => Targets<Root> = internal
|
|
8039
|
+
.targets as unknown as <const Root extends Machine.StateNodeConfig>(
|
|
8040
|
+
root: State<Root>
|
|
8041
|
+
) => Targets<Root>
|
|
8042
|
+
|
|
8043
|
+
type UniqueSourceNames<F, S, T, L, C> = [
|
|
8044
|
+
| Extract<keyof F, keyof S | keyof T | keyof L | keyof C>
|
|
8045
|
+
| Extract<keyof S, keyof T | keyof L | keyof C>
|
|
8046
|
+
| Extract<keyof T, keyof L | keyof C>
|
|
8047
|
+
| Extract<keyof L, keyof C>
|
|
8048
|
+
] extends [never] ? unknown : { readonly "~effect/Machine/DuplicateSourceName": never }
|
|
8049
|
+
|
|
8959
8050
|
type MakeConfig<
|
|
8960
8051
|
Root extends Machine.StateNodeConfig,
|
|
8961
8052
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8964,8 +8055,28 @@ type MakeConfig<
|
|
|
8964
8055
|
InitialE,
|
|
8965
8056
|
InitialR,
|
|
8966
8057
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8967
|
-
ParentDeclaration extends Parent.Any | undefined
|
|
8058
|
+
ParentDeclaration extends Parent.Any | undefined,
|
|
8059
|
+
Effects extends Machine.EffectSources,
|
|
8060
|
+
Streams extends Machine.StreamSources,
|
|
8061
|
+
Timers extends Machine.TimerSources,
|
|
8062
|
+
Logics extends Machine.LogicSources,
|
|
8063
|
+
Children extends Machine.ChildSources,
|
|
8064
|
+
Branches extends Machine.BranchDefinitions<Root>
|
|
8968
8065
|
> = {
|
|
8066
|
+
/** Lazy Effects or functions with one required input, invoked by registered name. */
|
|
8067
|
+
readonly effects?: Effects & Machine.ValidatePrograms<Effects>
|
|
8068
|
+
/** Lazy Streams or functions with one required input, invoked by registered name. */
|
|
8069
|
+
readonly streams?: Streams & Machine.ValidatePrograms<Streams>
|
|
8070
|
+
/** Cancellable delays, supplied as durations or functions of one required input. */
|
|
8071
|
+
readonly timers?: Timers & Machine.ValidatePrograms<Timers>
|
|
8072
|
+
/** Logic values or functions of one required input; their Effect channels remain inferred. */
|
|
8073
|
+
readonly logic?: Logics & Machine.ValidatePrograms<Logics> & Machine.ValidateLogicSources<NoInfer<Logics>>
|
|
8074
|
+
/** Child machine descriptors registered for state-owned invocation. */
|
|
8075
|
+
readonly children?: Children
|
|
8076
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
8077
|
+
readonly branches?:
|
|
8078
|
+
& Branches
|
|
8079
|
+
& { readonly [K in keyof Branches]: ValidateTransitionBranchRecord<NoInfer<Branches[K]>> }
|
|
8969
8080
|
/** Stable definition identifier used by inspection and visualization. */
|
|
8970
8081
|
readonly id?: string
|
|
8971
8082
|
/** State topology and value schemas, captured by a `Machine.state` descriptor. */
|
|
@@ -8997,7 +8108,13 @@ type MakeResult<
|
|
|
8997
8108
|
InitialE,
|
|
8998
8109
|
InitialR,
|
|
8999
8110
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
9000
|
-
ParentDeclaration extends Parent.Any | undefined
|
|
8111
|
+
ParentDeclaration extends Parent.Any | undefined,
|
|
8112
|
+
Effects extends Machine.EffectSources,
|
|
8113
|
+
Streams extends Machine.StreamSources,
|
|
8114
|
+
Timers extends Machine.TimerSources,
|
|
8115
|
+
Logics extends Machine.LogicSources,
|
|
8116
|
+
Children extends Machine.ChildSources,
|
|
8117
|
+
Branches extends Readonly<Record<string, Readonly<Record<string, unknown>>>>
|
|
9001
8118
|
> = Definition<
|
|
9002
8119
|
{ readonly "": Root },
|
|
9003
8120
|
readonly [...InputEvents, ...InternalEvents],
|
|
@@ -9008,14 +8125,37 @@ type MakeResult<
|
|
|
9008
8125
|
Machine.TerminalOutput<{ readonly "": Root }>,
|
|
9009
8126
|
Emits,
|
|
9010
8127
|
InputEvents,
|
|
9011
|
-
Machine.ParentEventsOf<ParentDeclaration
|
|
8128
|
+
Machine.ParentEventsOf<ParentDeclaration>,
|
|
8129
|
+
{
|
|
8130
|
+
/** Lazy Effects or functions with one required input, invoked by registered name. */
|
|
8131
|
+
readonly effects: Effects
|
|
8132
|
+
/** Lazy Streams or functions with one required input, invoked by registered name. */
|
|
8133
|
+
readonly streams: Streams
|
|
8134
|
+
/** Cancellable delays, supplied as durations or functions of one required input. */
|
|
8135
|
+
readonly timers: Timers
|
|
8136
|
+
/** Logic values or functions of one required input; their Effect channels remain inferred. */
|
|
8137
|
+
readonly logic: Logics
|
|
8138
|
+
/** Child machine descriptors registered for state-owned invocation. */
|
|
8139
|
+
readonly children: Children
|
|
8140
|
+
/** Named groups of inspectable destinations used by transition resolvers. */
|
|
8141
|
+
readonly branches: Branches
|
|
8142
|
+
}
|
|
9012
8143
|
>
|
|
9013
8144
|
|
|
9014
8145
|
type RootInitialization<Root extends Machine.StateNodeConfig, Input> =
|
|
9015
8146
|
& { readonly initialConfiguration?: never }
|
|
9016
|
-
& (Machine.NodeSchema<Root> extends never ? {
|
|
9017
|
-
|
|
9018
|
-
|
|
8147
|
+
& (Machine.NodeSchema<Root> extends never ? {
|
|
8148
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
8149
|
+
readonly initial?: Machine.RootInitialBuilderInput<Root, Input>
|
|
8150
|
+
}
|
|
8151
|
+
: {} extends NodeMakeInput<Root> ? {
|
|
8152
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
8153
|
+
readonly initial?: Machine.RootInitialBuilderInput<Root, Input>
|
|
8154
|
+
}
|
|
8155
|
+
: {
|
|
8156
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
8157
|
+
readonly initial: Machine.RootInitialBuilderInput<Root, Input>
|
|
8158
|
+
})
|
|
9019
8159
|
|
|
9020
8160
|
/** @inline */
|
|
9021
8161
|
interface Make {
|
|
@@ -9028,10 +8168,32 @@ interface Make {
|
|
|
9028
8168
|
InitialE = never,
|
|
9029
8169
|
InitialR = never,
|
|
9030
8170
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
9031
|
-
const ParentDeclaration extends Parent.Any | undefined = undefined
|
|
8171
|
+
const ParentDeclaration extends Parent.Any | undefined = undefined,
|
|
8172
|
+
const Effects extends Machine.EffectSources = {},
|
|
8173
|
+
const Streams extends Machine.StreamSources = {},
|
|
8174
|
+
const Timers extends Machine.TimerSources = {},
|
|
8175
|
+
const Logics extends Machine.LogicSources = {},
|
|
8176
|
+
const Children extends Machine.ChildSources = {},
|
|
8177
|
+
const Branches extends Machine.BranchDefinitions<NoInfer<Root>> = {}
|
|
9032
8178
|
>(
|
|
9033
8179
|
config:
|
|
9034
|
-
& MakeConfig<
|
|
8180
|
+
& MakeConfig<
|
|
8181
|
+
Root,
|
|
8182
|
+
InputEvents,
|
|
8183
|
+
Emits,
|
|
8184
|
+
Input,
|
|
8185
|
+
InitialE,
|
|
8186
|
+
InitialR,
|
|
8187
|
+
InternalEvents,
|
|
8188
|
+
ParentDeclaration,
|
|
8189
|
+
Effects,
|
|
8190
|
+
Streams,
|
|
8191
|
+
Timers,
|
|
8192
|
+
Logics,
|
|
8193
|
+
Children,
|
|
8194
|
+
Branches
|
|
8195
|
+
>
|
|
8196
|
+
& UniqueSourceNames<NoInfer<Effects>, NoInfer<Streams>, NoInfer<Timers>, NoInfer<Logics>, NoInfer<Children>>
|
|
9035
8197
|
& {
|
|
9036
8198
|
/** Mutually exclusive with a complete initial configuration. */
|
|
9037
8199
|
readonly initial?: never
|
|
@@ -9049,7 +8211,13 @@ interface Make {
|
|
|
9049
8211
|
InitialE,
|
|
9050
8212
|
InitialR,
|
|
9051
8213
|
InternalEvents,
|
|
9052
|
-
ParentDeclaration
|
|
8214
|
+
ParentDeclaration,
|
|
8215
|
+
Effects,
|
|
8216
|
+
Streams,
|
|
8217
|
+
Timers,
|
|
8218
|
+
Logics,
|
|
8219
|
+
Children,
|
|
8220
|
+
Branches
|
|
9053
8221
|
>
|
|
9054
8222
|
/** @param config Complete schema-first machine definition. */
|
|
9055
8223
|
<
|
|
@@ -9060,10 +8228,32 @@ interface Make {
|
|
|
9060
8228
|
InitialE = never,
|
|
9061
8229
|
InitialR = never,
|
|
9062
8230
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
9063
|
-
const ParentDeclaration extends Parent.Any | undefined = undefined
|
|
8231
|
+
const ParentDeclaration extends Parent.Any | undefined = undefined,
|
|
8232
|
+
const Effects extends Machine.EffectSources = {},
|
|
8233
|
+
const Streams extends Machine.StreamSources = {},
|
|
8234
|
+
const Timers extends Machine.TimerSources = {},
|
|
8235
|
+
const Logics extends Machine.LogicSources = {},
|
|
8236
|
+
const Children extends Machine.ChildSources = {},
|
|
8237
|
+
const Branches extends Machine.BranchDefinitions<NoInfer<Root>> = {}
|
|
9064
8238
|
>(
|
|
9065
8239
|
config:
|
|
9066
|
-
& MakeConfig<
|
|
8240
|
+
& MakeConfig<
|
|
8241
|
+
Root,
|
|
8242
|
+
InputEvents,
|
|
8243
|
+
Emits,
|
|
8244
|
+
Input,
|
|
8245
|
+
InitialE,
|
|
8246
|
+
InitialR,
|
|
8247
|
+
InternalEvents,
|
|
8248
|
+
ParentDeclaration,
|
|
8249
|
+
Effects,
|
|
8250
|
+
Streams,
|
|
8251
|
+
Timers,
|
|
8252
|
+
Logics,
|
|
8253
|
+
Children,
|
|
8254
|
+
Branches
|
|
8255
|
+
>
|
|
8256
|
+
& UniqueSourceNames<NoInfer<Effects>, NoInfer<Streams>, NoInfer<Timers>, NoInfer<Logics>, NoInfer<Children>>
|
|
9067
8257
|
& Exclude<
|
|
9068
8258
|
RootInitialization<NoInfer<Root>, Input["Type"]>,
|
|
9069
8259
|
{ readonly initialConfiguration: unknown }
|
|
@@ -9076,7 +8266,13 @@ interface Make {
|
|
|
9076
8266
|
InitialE,
|
|
9077
8267
|
InitialR,
|
|
9078
8268
|
InternalEvents,
|
|
9079
|
-
ParentDeclaration
|
|
8269
|
+
ParentDeclaration,
|
|
8270
|
+
Effects,
|
|
8271
|
+
Streams,
|
|
8272
|
+
Timers,
|
|
8273
|
+
Logics,
|
|
8274
|
+
Children,
|
|
8275
|
+
Branches
|
|
9080
8276
|
>
|
|
9081
8277
|
}
|
|
9082
8278
|
|
|
@@ -9121,6 +8317,7 @@ interface Make {
|
|
|
9121
8317
|
*
|
|
9122
8318
|
* const States = Machine.state({ initial: "Count", states: { Count } })
|
|
9123
8319
|
* const Events = Machine.eventsFromSchemas(Increment)
|
|
8320
|
+
* const targets = Machine.targets(States)
|
|
9124
8321
|
*
|
|
9125
8322
|
* const counter = Machine.make({
|
|
9126
8323
|
* root: States,
|
|
@@ -9129,9 +8326,10 @@ interface Make {
|
|
|
9129
8326
|
* }).handle({ states: {
|
|
9130
8327
|
* Count: {
|
|
9131
8328
|
* on: {
|
|
9132
|
-
* Increment:
|
|
9133
|
-
*
|
|
9134
|
-
*
|
|
8329
|
+
* Increment: {
|
|
8330
|
+
* update: targets.root.Count,
|
|
8331
|
+
* decoded: ({ event, state }) => new Count({ value: state.value + event.by })
|
|
8332
|
+
* }
|
|
9135
8333
|
* }
|
|
9136
8334
|
* }
|
|
9137
8335
|
* } })
|
|
@@ -9503,25 +8701,24 @@ type TransitionBranchRecordError<Message extends string, Key extends PropertyKey
|
|
|
9503
8701
|
readonly key: Key
|
|
9504
8702
|
}
|
|
9505
8703
|
|
|
9506
|
-
type InvalidStaticTransitionBranchKey<Branches> = Extract<
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
readonly target: { readonly "~effect/Machine/UpdatingTransitionTarget": string }
|
|
9511
|
-
} ? Key
|
|
9512
|
-
: never
|
|
9513
|
-
}[keyof Branches]
|
|
8704
|
+
type InvalidStaticTransitionBranchKey<Branches> = Extract<
|
|
8705
|
+
keyof Branches,
|
|
8706
|
+
"" | number | symbol | `${number}` | "NaN" | "Infinity" | "-Infinity"
|
|
8707
|
+
>
|
|
9514
8708
|
|
|
9515
8709
|
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ?
|
|
9516
8710
|
TransitionBranchRecordError<"Branch records must contain at least one branch">
|
|
9517
|
-
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ?
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
8711
|
+
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ? {
|
|
8712
|
+
readonly [K in keyof Branches]:
|
|
8713
|
+
& {
|
|
8714
|
+
readonly [
|
|
8715
|
+
Extra in Exclude<keyof Branches[K], "target" | "update" | "initial" | "history" | "none" | "title">
|
|
8716
|
+
]: never
|
|
8717
|
+
}
|
|
8718
|
+
& (Branches[K] extends { readonly title: "" } ? { readonly title: never } : unknown)
|
|
8719
|
+
} :
|
|
8720
|
+
TransitionBranchRecordError<
|
|
8721
|
+
"Branch keys must be non-empty, non-numeric strings",
|
|
9525
8722
|
InvalidStaticTransitionBranchKey<Branches>
|
|
9526
8723
|
>
|
|
9527
8724
|
|
|
@@ -9629,10 +8826,12 @@ export const planInitial: <
|
|
|
9629
8826
|
& (
|
|
9630
8827
|
| {
|
|
9631
8828
|
readonly done: true
|
|
8829
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9632
8830
|
readonly output: Output
|
|
9633
8831
|
}
|
|
9634
8832
|
| {
|
|
9635
8833
|
readonly done: false
|
|
8834
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9636
8835
|
readonly output: undefined
|
|
9637
8836
|
}
|
|
9638
8837
|
),
|
|
@@ -9838,7 +9037,7 @@ export const enabled: <
|
|
|
9838
9037
|
* events: Machine.eventsFromSchemas(),
|
|
9839
9038
|
* internalEvents,
|
|
9840
9039
|
* initialConfiguration: (root) => root.resolve(({ target }) => target.from((to) => to.Idle.from()))
|
|
9841
|
-
* }).handle({ states: { Idle: { on: { Loaded:
|
|
9040
|
+
* }).handle({ states: { Idle: { on: { Loaded: { none: true } } } } })
|
|
9842
9041
|
*
|
|
9843
9042
|
* export const canLoad = Effect.gen(function*() {
|
|
9844
9043
|
* const initial = yield* Machine.planInitial(machine)
|
|
@@ -9956,6 +9155,7 @@ export const can: {
|
|
|
9956
9155
|
* class On extends Schema.TaggedClass<On>("On")("On", {}) {}
|
|
9957
9156
|
* class Toggle extends Schema.TaggedClass<Toggle>("Toggle")("Toggle", {}) {}
|
|
9958
9157
|
* const States = Machine.state({ initial: "Off", states: { Off, On } })
|
|
9158
|
+
* const targets = Machine.targets(States)
|
|
9959
9159
|
* const machine = Machine.make({
|
|
9960
9160
|
* root: States,
|
|
9961
9161
|
* events: Machine.eventsFromSchemas(Toggle),
|
|
@@ -9963,8 +9163,7 @@ export const can: {
|
|
|
9963
9163
|
* }).handle({ states: {
|
|
9964
9164
|
* Off: {
|
|
9965
9165
|
* on: {
|
|
9966
|
-
* Toggle:
|
|
9967
|
-
* to.branch.On().resolve(({ target }) => target.from())
|
|
9166
|
+
* Toggle: { target: targets.root.On }
|
|
9968
9167
|
* }
|
|
9969
9168
|
* },
|
|
9970
9169
|
* On: {}
|
|
@@ -10045,10 +9244,12 @@ export const plan: <
|
|
|
10045
9244
|
& (
|
|
10046
9245
|
| {
|
|
10047
9246
|
readonly done: true
|
|
9247
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
10048
9248
|
readonly output: Output
|
|
10049
9249
|
}
|
|
10050
9250
|
| {
|
|
10051
9251
|
readonly done: false
|
|
9252
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
10052
9253
|
readonly output: undefined
|
|
10053
9254
|
}
|
|
10054
9255
|
),
|
|
@@ -10093,6 +9294,7 @@ export const logic: <
|
|
|
10093
9294
|
InitialError = never,
|
|
10094
9295
|
InitialRequirements = never
|
|
10095
9296
|
>(options: {
|
|
9297
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
10096
9298
|
readonly initial:
|
|
10097
9299
|
| State
|
|
10098
9300
|
| ((
|
|
@@ -10151,7 +9353,7 @@ export const childAddress: <Event = never>(id: string) => ChildAddress<Event> =
|
|
|
10151
9353
|
* This Effect requires a managed process runtime. A named child id must be
|
|
10152
9354
|
* unique for the current parent until that child stops.
|
|
10153
9355
|
*
|
|
10154
|
-
*
|
|
9356
|
+
* Register logic in `make({ logic })` and use `invoke: { src, id, address, ...outcomes }` for children
|
|
10155
9357
|
* that start and stop with that state.
|
|
10156
9358
|
* @see {@link sendTo} for sending events to named children.
|
|
10157
9359
|
* @category runtime
|