@typeonce/effect-machine 0.32.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 -635
- package/dist/Machine.d.ts +814 -545
- 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 +149 -280
- 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 +68 -23
- package/package.json +1 -1
- package/src/Machine.ts +1387 -2011
- 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 +210 -389
- 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<
|
|
@@ -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,116 +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 TransitionReenterOption<Reenter extends boolean> = [Reenter] extends [true] ? {
|
|
6019
|
-
/** Forces the source state to exit and enter even when active paths remain unchanged. */
|
|
6020
|
-
readonly reenter?: boolean
|
|
6021
|
-
}
|
|
6022
|
-
: { readonly reenter?: never }
|
|
6023
|
-
|
|
6024
|
-
type TransitionRequiredOptions<Reenter extends boolean> =
|
|
6025
|
-
& TransitionReenterOption<Reenter>
|
|
6026
|
-
& {
|
|
6027
|
-
/** Keeps the transition required. The resolver cannot return `decline()`. */
|
|
6028
|
-
readonly declinable?: false
|
|
6029
|
-
}
|
|
6030
|
-
|
|
6031
|
-
type TransitionDeclinableOptions<Reenter extends boolean> =
|
|
6032
|
-
& TransitionReenterOption<Reenter>
|
|
6033
|
-
& {
|
|
6034
|
-
/** Adds `decline()` to the resolver context and permits declining this candidate. */
|
|
6035
|
-
readonly declinable: true
|
|
6036
|
-
}
|
|
6037
|
-
|
|
6038
|
-
type BuiltTransition<
|
|
6039
|
-
States extends StateSchemas,
|
|
6040
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6041
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6042
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6043
|
-
Context,
|
|
6044
|
-
Reenter extends boolean,
|
|
6045
|
-
Result,
|
|
6046
|
-
Acceptance extends TransitionAcceptance
|
|
6047
|
-
> =
|
|
6048
|
-
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6049
|
-
& TransitionBuilderEvidence<Result, Acceptance>
|
|
6050
|
-
|
|
6051
|
-
interface TransitionResolveRequired<
|
|
6052
|
-
States extends StateSchemas,
|
|
6053
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6054
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6055
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6056
|
-
Context,
|
|
6057
|
-
Reenter extends boolean,
|
|
6058
|
-
Selection extends TargetSelection<any, any, any>
|
|
6059
|
-
> {
|
|
6060
|
-
(
|
|
6061
|
-
resolve: TransitionResolver<Events, Emits, Context, Selection>,
|
|
6062
|
-
options?: TransitionRequiredOptions<Reenter>
|
|
6063
|
-
): BuiltTransition<
|
|
6064
|
-
States,
|
|
6065
|
-
Events,
|
|
6066
|
-
Emits,
|
|
6067
|
-
StateId,
|
|
6068
|
-
Context,
|
|
6069
|
-
Reenter,
|
|
6070
|
-
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
6071
|
-
"required"
|
|
6072
|
-
>
|
|
6073
|
-
}
|
|
6074
|
-
|
|
6075
|
-
interface TransitionResolveDeclinable<
|
|
6076
|
-
States extends StateSchemas,
|
|
6077
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6078
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6079
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6080
|
-
Context,
|
|
6081
|
-
Reenter extends boolean,
|
|
6082
|
-
Selection extends TargetSelection<any, any, any>
|
|
6083
|
-
> {
|
|
6084
|
-
(
|
|
6085
|
-
resolve: DeclinableTransitionResolver<Events, Emits, Context, Selection>,
|
|
6086
|
-
options: TransitionDeclinableOptions<Reenter>
|
|
6087
|
-
): BuiltTransition<
|
|
6088
|
-
States,
|
|
6089
|
-
Events,
|
|
6090
|
-
Emits,
|
|
6091
|
-
StateId,
|
|
6092
|
-
Context,
|
|
6093
|
-
Reenter,
|
|
6094
|
-
| (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined)
|
|
6095
|
-
| Declined,
|
|
6096
|
-
"declinable"
|
|
6097
|
-
>
|
|
6098
|
-
}
|
|
6099
|
-
|
|
6100
5716
|
type ConstructionCallbacks<Context, Builder, Result> = {
|
|
6101
5717
|
readonly [
|
|
6102
5718
|
Method in Extract<keyof Builder, "from" | "decoded"> as Builder[Method] extends (...args: infer Args) => unknown
|
|
@@ -6108,317 +5724,6 @@ export declare namespace Machine {
|
|
|
6108
5724
|
never
|
|
6109
5725
|
}
|
|
6110
5726
|
|
|
6111
|
-
type GuardedTransition<
|
|
6112
|
-
States extends StateSchemas,
|
|
6113
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6114
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6115
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6116
|
-
Context,
|
|
6117
|
-
Reenter extends boolean,
|
|
6118
|
-
Selection extends TargetSelection<any, any, any>
|
|
6119
|
-
> =
|
|
6120
|
-
& ConstructionCallbacks<
|
|
6121
|
-
Omit<Context, "target">,
|
|
6122
|
-
SelectionBuilder<Selection>,
|
|
6123
|
-
BuiltTransition<
|
|
6124
|
-
States,
|
|
6125
|
-
Events,
|
|
6126
|
-
Emits,
|
|
6127
|
-
StateId,
|
|
6128
|
-
Context,
|
|
6129
|
-
Reenter,
|
|
6130
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6131
|
-
"declinable"
|
|
6132
|
-
>
|
|
6133
|
-
>
|
|
6134
|
-
& (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<
|
|
6135
|
-
States,
|
|
6136
|
-
Events,
|
|
6137
|
-
Emits,
|
|
6138
|
-
StateId,
|
|
6139
|
-
Context,
|
|
6140
|
-
Reenter,
|
|
6141
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6142
|
-
"declinable"
|
|
6143
|
-
>
|
|
6144
|
-
: {})
|
|
6145
|
-
& {
|
|
6146
|
-
readonly resolve: (
|
|
6147
|
-
resolve: TransitionResolver<Events, Emits, Context, Selection>,
|
|
6148
|
-
options?: TransitionRequiredOptions<Reenter>
|
|
6149
|
-
) => BuiltTransition<
|
|
6150
|
-
States,
|
|
6151
|
-
Events,
|
|
6152
|
-
Emits,
|
|
6153
|
-
StateId,
|
|
6154
|
-
Context,
|
|
6155
|
-
Reenter,
|
|
6156
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6157
|
-
"declinable"
|
|
6158
|
-
>
|
|
6159
|
-
}
|
|
6160
|
-
|
|
6161
|
-
/**
|
|
6162
|
-
* A selected transition target with target-specific resolver operations.
|
|
6163
|
-
*
|
|
6164
|
-
* **Example** (Updating state while reentering)
|
|
6165
|
-
*
|
|
6166
|
-
* ```ts
|
|
6167
|
-
* Reset: (to) =>
|
|
6168
|
-
* to.branch.Ready().resolve(
|
|
6169
|
-
* ({ target }) => target.from(),
|
|
6170
|
-
* { reenter: true }
|
|
6171
|
-
* )
|
|
6172
|
-
* ```
|
|
6173
|
-
*
|
|
6174
|
-
* @inlineType TransitionRequiredOptions
|
|
6175
|
-
* @inlineType TransitionDeclinableOptions
|
|
6176
|
-
* @inlineType TransitionReenterOption
|
|
6177
|
-
*/
|
|
6178
|
-
export type TransitionTarget<
|
|
6179
|
-
States extends StateSchemas,
|
|
6180
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6181
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6182
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6183
|
-
Context,
|
|
6184
|
-
Reenter extends boolean,
|
|
6185
|
-
Acceptance extends TransitionAcceptance,
|
|
6186
|
-
Selection extends TargetSelection<any, any, any>
|
|
6187
|
-
> =
|
|
6188
|
-
& Selection
|
|
6189
|
-
& ("declinable" extends Acceptance ? {
|
|
6190
|
-
/** Declines this candidate before construction when the predicate is false. */
|
|
6191
|
-
readonly guard: (
|
|
6192
|
-
predicate: (context: Omit<Context, "target">) => boolean
|
|
6193
|
-
) => GuardedTransition<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6194
|
-
} :
|
|
6195
|
-
{})
|
|
6196
|
-
& ConstructionCallbacks<
|
|
6197
|
-
Omit<Context, "target">,
|
|
6198
|
-
SelectionBuilder<Selection>,
|
|
6199
|
-
BuiltTransition<
|
|
6200
|
-
States,
|
|
6201
|
-
Events,
|
|
6202
|
-
Emits,
|
|
6203
|
-
StateId,
|
|
6204
|
-
Context,
|
|
6205
|
-
Reenter,
|
|
6206
|
-
SelectedTargetResult<Selection>,
|
|
6207
|
-
"required"
|
|
6208
|
-
>
|
|
6209
|
-
>
|
|
6210
|
-
& (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<
|
|
6211
|
-
States,
|
|
6212
|
-
Events,
|
|
6213
|
-
Emits,
|
|
6214
|
-
StateId,
|
|
6215
|
-
Context,
|
|
6216
|
-
Reenter,
|
|
6217
|
-
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
6218
|
-
"required"
|
|
6219
|
-
>
|
|
6220
|
-
: {})
|
|
6221
|
-
& {
|
|
6222
|
-
/** Evaluates state construction after this transition is selected. */
|
|
6223
|
-
readonly resolve:
|
|
6224
|
-
& TransitionResolveRequired<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6225
|
-
& ("declinable" extends Acceptance ? TransitionResolveDeclinable<
|
|
6226
|
-
States,
|
|
6227
|
-
Events,
|
|
6228
|
-
Emits,
|
|
6229
|
-
StateId,
|
|
6230
|
-
Context,
|
|
6231
|
-
Reenter,
|
|
6232
|
-
Selection
|
|
6233
|
-
>
|
|
6234
|
-
: {})
|
|
6235
|
-
}
|
|
6236
|
-
& ([Reenter] extends [true] ? SelectionSupportsDefaultConstruction<Selection> extends true ? {
|
|
6237
|
-
/** Reenters the source using the selected target's default construction. */
|
|
6238
|
-
readonly reenter: () => BuiltTransition<
|
|
6239
|
-
States,
|
|
6240
|
-
Events,
|
|
6241
|
-
Emits,
|
|
6242
|
-
StateId,
|
|
6243
|
-
Context,
|
|
6244
|
-
Reenter,
|
|
6245
|
-
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
6246
|
-
"required"
|
|
6247
|
-
>
|
|
6248
|
-
}
|
|
6249
|
-
: {}
|
|
6250
|
-
: {})
|
|
6251
|
-
& (SelectionKind<Selection> extends "state" ?
|
|
6252
|
-
SelectionScope<Selection> extends "local" | "branch" ?
|
|
6253
|
-
RetainedUpdateOwner<States, StateId, Selection> extends infer Owner extends ValuedStateIdentifier<States> ?
|
|
6254
|
-
[Owner] extends [never] ? {}
|
|
6255
|
-
: {
|
|
6256
|
-
/** Declares one valued owner retained by the selected topology. */
|
|
6257
|
-
readonly updating: <SelectedOwner extends Owner>(
|
|
6258
|
-
owner: RetainedOwnerSelector<SelectedOwner>
|
|
6259
|
-
) => UpdatingTransitionTarget<
|
|
6260
|
-
States,
|
|
6261
|
-
Events,
|
|
6262
|
-
Emits,
|
|
6263
|
-
StateId,
|
|
6264
|
-
Context,
|
|
6265
|
-
Reenter,
|
|
6266
|
-
Acceptance,
|
|
6267
|
-
Selection,
|
|
6268
|
-
SelectedOwner
|
|
6269
|
-
>
|
|
6270
|
-
}
|
|
6271
|
-
: {}
|
|
6272
|
-
: {}
|
|
6273
|
-
: {})
|
|
6274
|
-
|
|
6275
|
-
/** A topology selection that requires one retained owner replacement. */
|
|
6276
|
-
export type UpdatingTransitionTarget<
|
|
6277
|
-
States extends StateSchemas,
|
|
6278
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6279
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6280
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6281
|
-
Context,
|
|
6282
|
-
Reenter extends boolean,
|
|
6283
|
-
Acceptance extends TransitionAcceptance,
|
|
6284
|
-
Selection extends TargetSelection<any, any, "state">,
|
|
6285
|
-
Owner extends ValuedStateIdentifier<States>
|
|
6286
|
-
> = Selection & {
|
|
6287
|
-
/** @internal */
|
|
6288
|
-
readonly "~effect/Machine/UpdatingTransitionTarget": Owner
|
|
6289
|
-
readonly resolve:
|
|
6290
|
-
& ((
|
|
6291
|
-
resolve: (
|
|
6292
|
-
context: UpdatingTransitionResolveContext<States, Context, Selection, Owner>,
|
|
6293
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6294
|
-
) => CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>,
|
|
6295
|
-
options?: TransitionRequiredOptions<Reenter>
|
|
6296
|
-
) => BuiltTransition<
|
|
6297
|
-
States,
|
|
6298
|
-
Events,
|
|
6299
|
-
Emits,
|
|
6300
|
-
StateId,
|
|
6301
|
-
Context,
|
|
6302
|
-
Reenter,
|
|
6303
|
-
CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner>,
|
|
6304
|
-
"required"
|
|
6305
|
-
>)
|
|
6306
|
-
& ("declinable" extends Acceptance ? (
|
|
6307
|
-
resolve: (
|
|
6308
|
-
context: UpdatingTransitionResolveContext<States, Context, Selection, Owner> & DeclineCapability,
|
|
6309
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
6310
|
-
) => CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner> | Declined,
|
|
6311
|
-
options: TransitionDeclinableOptions<Reenter>
|
|
6312
|
-
) => BuiltTransition<
|
|
6313
|
-
States,
|
|
6314
|
-
Events,
|
|
6315
|
-
Emits,
|
|
6316
|
-
StateId,
|
|
6317
|
-
Context,
|
|
6318
|
-
Reenter,
|
|
6319
|
-
CombinedTarget<UnwrapConstruction<SelectedTargetResult<Selection>>, States, Owner> | Declined,
|
|
6320
|
-
"declinable"
|
|
6321
|
-
>
|
|
6322
|
-
: {})
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
|
-
/** @internal */
|
|
6326
|
-
interface StateUpdateTransitionRequired<
|
|
6327
|
-
States extends StateSchemas,
|
|
6328
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6329
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6330
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6331
|
-
Context,
|
|
6332
|
-
Reenter extends boolean,
|
|
6333
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6334
|
-
> {
|
|
6335
|
-
(
|
|
6336
|
-
resolve: StateUpdateResolver<
|
|
6337
|
-
States,
|
|
6338
|
-
Events,
|
|
6339
|
-
Emits,
|
|
6340
|
-
Context,
|
|
6341
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6342
|
-
>,
|
|
6343
|
-
options?: TransitionRequiredOptions<Reenter>
|
|
6344
|
-
): BuiltTransition<
|
|
6345
|
-
States,
|
|
6346
|
-
Events,
|
|
6347
|
-
Emits,
|
|
6348
|
-
StateId,
|
|
6349
|
-
Context,
|
|
6350
|
-
Reenter,
|
|
6351
|
-
SelectedTargetResult<Selection>,
|
|
6352
|
-
"required"
|
|
6353
|
-
>
|
|
6354
|
-
}
|
|
6355
|
-
|
|
6356
|
-
/** @internal */
|
|
6357
|
-
interface StateUpdateTransitionDeclinable<
|
|
6358
|
-
States extends StateSchemas,
|
|
6359
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6360
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6361
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6362
|
-
Context,
|
|
6363
|
-
Reenter extends boolean,
|
|
6364
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6365
|
-
> {
|
|
6366
|
-
(
|
|
6367
|
-
resolve: DeclinableStateUpdateResolver<
|
|
6368
|
-
States,
|
|
6369
|
-
Events,
|
|
6370
|
-
Emits,
|
|
6371
|
-
Context,
|
|
6372
|
-
Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>
|
|
6373
|
-
>,
|
|
6374
|
-
options: TransitionDeclinableOptions<Reenter>
|
|
6375
|
-
): BuiltTransition<
|
|
6376
|
-
States,
|
|
6377
|
-
Events,
|
|
6378
|
-
Emits,
|
|
6379
|
-
StateId,
|
|
6380
|
-
Context,
|
|
6381
|
-
Reenter,
|
|
6382
|
-
SelectedTargetResult<Selection> | Declined,
|
|
6383
|
-
"declinable"
|
|
6384
|
-
>
|
|
6385
|
-
}
|
|
6386
|
-
|
|
6387
|
-
/** @internal */
|
|
6388
|
-
type StateUpdateTransition<
|
|
6389
|
-
States extends StateSchemas,
|
|
6390
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6391
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6392
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6393
|
-
Context,
|
|
6394
|
-
Reenter extends boolean,
|
|
6395
|
-
Acceptance extends TransitionAcceptance,
|
|
6396
|
-
Selection extends TargetSelection<any, any, "update">
|
|
6397
|
-
> =
|
|
6398
|
-
& Selection
|
|
6399
|
-
& ConstructionCallbacks<
|
|
6400
|
-
Omit<
|
|
6401
|
-
StateUpdateResolveContext<States, Context, Extract<SelectionPath<Selection>, ValuedStateIdentifier<States>>>,
|
|
6402
|
-
"owner"
|
|
6403
|
-
>,
|
|
6404
|
-
SelectionBuilder<Selection>,
|
|
6405
|
-
BuiltTransition<States, Events, Emits, StateId, Context, Reenter, SelectedTargetResult<Selection>, "required">
|
|
6406
|
-
>
|
|
6407
|
-
& {
|
|
6408
|
-
readonly resolve:
|
|
6409
|
-
& StateUpdateTransitionRequired<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
6410
|
-
& ("declinable" extends Acceptance ? StateUpdateTransitionDeclinable<
|
|
6411
|
-
States,
|
|
6412
|
-
Events,
|
|
6413
|
-
Emits,
|
|
6414
|
-
StateId,
|
|
6415
|
-
Context,
|
|
6416
|
-
Reenter,
|
|
6417
|
-
Selection
|
|
6418
|
-
>
|
|
6419
|
-
: {})
|
|
6420
|
-
}
|
|
6421
|
-
|
|
6422
5727
|
/** @internal Type evidence retained by a machine initial-entry declaration. */
|
|
6423
5728
|
export interface InitialBuilderEvidence<out Selection> {
|
|
6424
5729
|
readonly [InitialBuilderTypeId]: Types.Covariant<Selection>
|
|
@@ -6506,186 +5811,6 @@ export declare namespace Machine {
|
|
|
6506
5811
|
}
|
|
6507
5812
|
) => InitialBuilderEvidence<TargetSelection<any, any, any>>
|
|
6508
5813
|
|
|
6509
|
-
type TransitionSelectorNode<
|
|
6510
|
-
States extends StateSchemas,
|
|
6511
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6512
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6513
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6514
|
-
Context,
|
|
6515
|
-
Reenter extends boolean,
|
|
6516
|
-
Acceptance extends TransitionAcceptance,
|
|
6517
|
-
Node
|
|
6518
|
-
> = Node extends TargetSelection<any, any, "update"> ? StateUpdateTransition<
|
|
6519
|
-
States,
|
|
6520
|
-
Events,
|
|
6521
|
-
Emits,
|
|
6522
|
-
StateId,
|
|
6523
|
-
Context,
|
|
6524
|
-
Reenter,
|
|
6525
|
-
Acceptance,
|
|
6526
|
-
Node
|
|
6527
|
-
>
|
|
6528
|
-
: Node extends (...args: infer Args) => infer Selection ? Selection extends TargetSelection<any, any, any> ?
|
|
6529
|
-
& ((...args: Args) => TransitionTarget<
|
|
6530
|
-
States,
|
|
6531
|
-
Events,
|
|
6532
|
-
Emits,
|
|
6533
|
-
StateId,
|
|
6534
|
-
Context,
|
|
6535
|
-
Reenter,
|
|
6536
|
-
Acceptance,
|
|
6537
|
-
Selection
|
|
6538
|
-
>)
|
|
6539
|
-
& {
|
|
6540
|
-
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
6541
|
-
States,
|
|
6542
|
-
Events,
|
|
6543
|
-
Emits,
|
|
6544
|
-
StateId,
|
|
6545
|
-
Context,
|
|
6546
|
-
Reenter,
|
|
6547
|
-
Acceptance,
|
|
6548
|
-
Node[Key]
|
|
6549
|
-
>
|
|
6550
|
-
}
|
|
6551
|
-
: never
|
|
6552
|
-
: Node extends TargetSelection<any, any, any> ? TransitionTarget<
|
|
6553
|
-
States,
|
|
6554
|
-
Events,
|
|
6555
|
-
Emits,
|
|
6556
|
-
StateId,
|
|
6557
|
-
Context,
|
|
6558
|
-
Reenter,
|
|
6559
|
-
Acceptance,
|
|
6560
|
-
Node
|
|
6561
|
-
>
|
|
6562
|
-
: {
|
|
6563
|
-
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
6564
|
-
States,
|
|
6565
|
-
Events,
|
|
6566
|
-
Emits,
|
|
6567
|
-
StateId,
|
|
6568
|
-
Context,
|
|
6569
|
-
Reenter,
|
|
6570
|
-
Acceptance,
|
|
6571
|
-
Node[Key]
|
|
6572
|
-
>
|
|
6573
|
-
}
|
|
6574
|
-
|
|
6575
|
-
interface TransitionBranchesResolveRequired<
|
|
6576
|
-
States extends StateSchemas,
|
|
6577
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6578
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6579
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6580
|
-
Context,
|
|
6581
|
-
Reenter extends boolean,
|
|
6582
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6583
|
-
> {
|
|
6584
|
-
(
|
|
6585
|
-
resolve: TransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
6586
|
-
options?: TransitionRequiredOptions<Reenter>
|
|
6587
|
-
): BuiltTransition<
|
|
6588
|
-
States,
|
|
6589
|
-
Events,
|
|
6590
|
-
Emits,
|
|
6591
|
-
StateId,
|
|
6592
|
-
Context,
|
|
6593
|
-
Reenter,
|
|
6594
|
-
BranchSelectionResult<Branches>,
|
|
6595
|
-
"required"
|
|
6596
|
-
>
|
|
6597
|
-
}
|
|
6598
|
-
|
|
6599
|
-
interface TransitionBranchesResolveDeclinable<
|
|
6600
|
-
States extends StateSchemas,
|
|
6601
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6602
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6603
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6604
|
-
Context,
|
|
6605
|
-
Reenter extends boolean,
|
|
6606
|
-
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
6607
|
-
> {
|
|
6608
|
-
(
|
|
6609
|
-
resolve: DeclinableTransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
6610
|
-
options: TransitionDeclinableOptions<Reenter>
|
|
6611
|
-
): BuiltTransition<
|
|
6612
|
-
States,
|
|
6613
|
-
Events,
|
|
6614
|
-
Emits,
|
|
6615
|
-
StateId,
|
|
6616
|
-
Context,
|
|
6617
|
-
Reenter,
|
|
6618
|
-
BranchSelectionResult<Branches> | Declined,
|
|
6619
|
-
"declinable"
|
|
6620
|
-
>
|
|
6621
|
-
}
|
|
6622
|
-
|
|
6623
|
-
type TransitionSelectorTargets<
|
|
6624
|
-
in out States extends StateSchemas,
|
|
6625
|
-
in out Events extends ReadonlyArray<TaggedSchema>,
|
|
6626
|
-
in out Emits extends ReadonlyArray<TaggedSchema>,
|
|
6627
|
-
in out StateId extends StateNodeIdentifier<States>,
|
|
6628
|
-
in out Context,
|
|
6629
|
-
in out Reenter extends boolean,
|
|
6630
|
-
in out Acceptance extends TransitionAcceptance
|
|
6631
|
-
> = {
|
|
6632
|
-
readonly [Key in keyof TargetSelector<States, StateId>]: TransitionSelectorNode<
|
|
6633
|
-
States,
|
|
6634
|
-
Events,
|
|
6635
|
-
Emits,
|
|
6636
|
-
StateId,
|
|
6637
|
-
Context,
|
|
6638
|
-
Key extends "self" ? false : Reenter,
|
|
6639
|
-
Acceptance,
|
|
6640
|
-
TargetSelector<States, StateId>[Key]
|
|
6641
|
-
>
|
|
6642
|
-
}
|
|
6643
|
-
|
|
6644
|
-
/** Selector supplied to inline transition declarations. */
|
|
6645
|
-
export interface TransitionSelector<
|
|
6646
|
-
in out States extends StateSchemas,
|
|
6647
|
-
in out Events extends ReadonlyArray<TaggedSchema>,
|
|
6648
|
-
in out Emits extends ReadonlyArray<TaggedSchema>,
|
|
6649
|
-
in out StateId extends StateNodeIdentifier<States>,
|
|
6650
|
-
in out Context,
|
|
6651
|
-
in out Reenter extends boolean,
|
|
6652
|
-
in out Acceptance extends TransitionAcceptance
|
|
6653
|
-
> extends TransitionSelectorTargets<States, Events, Emits, StateId, Context, Reenter, Acceptance> {
|
|
6654
|
-
/** Declares a closed set of named destinations for one resolver. */
|
|
6655
|
-
readonly branches: <const Branches extends Readonly<Record<string, TransitionBranchInput>>>(
|
|
6656
|
-
branches: Branches & ValidateTransitionBranchRecord<NoInfer<Branches>>
|
|
6657
|
-
) => {
|
|
6658
|
-
/** Resolves exactly one declared branch after this transition is selected. */
|
|
6659
|
-
readonly resolve:
|
|
6660
|
-
& TransitionBranchesResolveRequired<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
6661
|
-
& ("declinable" extends Acceptance ? TransitionBranchesResolveDeclinable<
|
|
6662
|
-
States,
|
|
6663
|
-
Events,
|
|
6664
|
-
Emits,
|
|
6665
|
-
StateId,
|
|
6666
|
-
Context,
|
|
6667
|
-
Reenter,
|
|
6668
|
-
Branches
|
|
6669
|
-
>
|
|
6670
|
-
: {})
|
|
6671
|
-
}
|
|
6672
|
-
}
|
|
6673
|
-
|
|
6674
|
-
/** Inline transition declaration accepted by state and invocation handlers. */
|
|
6675
|
-
export type TransitionBuilderInput<
|
|
6676
|
-
States extends StateSchemas,
|
|
6677
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6678
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6679
|
-
StateId extends StateNodeIdentifier<States>,
|
|
6680
|
-
Context,
|
|
6681
|
-
Reenter extends boolean,
|
|
6682
|
-
Acceptance extends TransitionAcceptance
|
|
6683
|
-
> = (
|
|
6684
|
-
to: TransitionSelector<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6685
|
-
) =>
|
|
6686
|
-
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
6687
|
-
& TransitionBuilderEvidence<any, Acceptance>
|
|
6688
|
-
|
|
6689
5814
|
export type InvokeTransition<
|
|
6690
5815
|
States extends StateSchemas,
|
|
6691
5816
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
@@ -6697,7 +5822,7 @@ export declare namespace Machine {
|
|
|
6697
5822
|
export type InvokeSource<Value, Context> = Value | ((context: Context) => Value)
|
|
6698
5823
|
|
|
6699
5824
|
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
6700
|
-
|
|
5825
|
+
interface InvokeOwned<
|
|
6701
5826
|
States extends StateSchemas,
|
|
6702
5827
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
6703
5828
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -6710,27 +5835,6 @@ export declare namespace Machine {
|
|
|
6710
5835
|
>
|
|
6711
5836
|
}
|
|
6712
5837
|
|
|
6713
|
-
/** Type evidence retained by a completed state-owned invocation. */
|
|
6714
|
-
export interface InvokeTyped<
|
|
6715
|
-
Output,
|
|
6716
|
-
Error,
|
|
6717
|
-
Requirements,
|
|
6718
|
-
InitialError,
|
|
6719
|
-
Emits = never,
|
|
6720
|
-
ParentEvent = never,
|
|
6721
|
-
Outcomes = never
|
|
6722
|
-
> {
|
|
6723
|
-
readonly [InvokeTypeId]: {
|
|
6724
|
-
readonly output: Types.Covariant<Output>
|
|
6725
|
-
readonly error: Types.Covariant<Error>
|
|
6726
|
-
readonly requirements: Types.Covariant<Requirements>
|
|
6727
|
-
readonly initialError: Types.Covariant<InitialError>
|
|
6728
|
-
readonly emits: Types.Covariant<Emits>
|
|
6729
|
-
readonly parentEvents: Types.Covariant<ParentEvent>
|
|
6730
|
-
readonly outcomes: Types.Covariant<Outcomes>
|
|
6731
|
-
}
|
|
6732
|
-
}
|
|
6733
|
-
|
|
6734
5838
|
type StoredInvokeConfig<
|
|
6735
5839
|
States extends StateSchemas,
|
|
6736
5840
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
@@ -6852,569 +5956,21 @@ export declare namespace Machine {
|
|
|
6852
5956
|
export type LogicOutputOf<Value> = Effect.Success<LogicRunEffectOf<Value>>
|
|
6853
5957
|
export type LogicInitialErrorOf<Value> = Effect.Error<LogicInitialEffectOf<Value>>
|
|
6854
5958
|
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
: Channel
|
|
6858
|
-
|
|
6859
|
-
type InvokeBuilderResult<
|
|
5959
|
+
/** Output construction available to final and output-producing parallel states. */
|
|
5960
|
+
type OutputHandlerConfig<
|
|
6860
5961
|
States extends StateSchemas,
|
|
6861
5962
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
6862
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6863
5963
|
StateId extends StateIdentifier<States>,
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
Outcomes
|
|
6873
|
-
> =
|
|
6874
|
-
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
6875
|
-
& InvokeTyped<Output, Error, Requirements, InitialError, ChildEmits, ChildParentEvent, Outcomes>
|
|
6876
|
-
& { readonly [InvokeBuilderTypeId]: true }
|
|
5964
|
+
Context
|
|
5965
|
+
> = NodeByIdentifier<States, StateId> extends { readonly output: Schema.Top } ? {
|
|
5966
|
+
/** Constructs the decoded output declared by the state's `output` schema. */
|
|
5967
|
+
readonly output: (context: Context) => OutputByIdentifier<States, StateId>
|
|
5968
|
+
}
|
|
5969
|
+
: {
|
|
5970
|
+
readonly output?: never
|
|
5971
|
+
}
|
|
6877
5972
|
|
|
6878
|
-
|
|
6879
|
-
type InvokeBuilder<
|
|
6880
|
-
States extends StateSchemas,
|
|
6881
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
6882
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6883
|
-
StateId extends StateIdentifier<States>,
|
|
6884
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
6885
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
6886
|
-
Output,
|
|
6887
|
-
Error,
|
|
6888
|
-
Requirements,
|
|
6889
|
-
InitialError,
|
|
6890
|
-
ChildEmits,
|
|
6891
|
-
ChildParentEvent,
|
|
6892
|
-
Element,
|
|
6893
|
-
Pending extends string,
|
|
6894
|
-
SnapshotHandler,
|
|
6895
|
-
Outcomes = never
|
|
6896
|
-
> =
|
|
6897
|
-
& ([Pending] extends [never] ? InvokeBuilderResult<
|
|
6898
|
-
States,
|
|
6899
|
-
Events,
|
|
6900
|
-
Emits,
|
|
6901
|
-
StateId,
|
|
6902
|
-
InputEvents,
|
|
6903
|
-
ParentEvents,
|
|
6904
|
-
Output,
|
|
6905
|
-
Error,
|
|
6906
|
-
Requirements,
|
|
6907
|
-
InitialError,
|
|
6908
|
-
ChildEmits,
|
|
6909
|
-
ChildParentEvent,
|
|
6910
|
-
Outcomes
|
|
6911
|
-
>
|
|
6912
|
-
: {})
|
|
6913
|
-
& ("done" extends Pending ? {
|
|
6914
|
-
/** Handles successful completion and exposes the invocation output. */
|
|
6915
|
-
readonly onDone: <
|
|
6916
|
-
const Handler extends InvokeTransition<
|
|
6917
|
-
States,
|
|
6918
|
-
Events,
|
|
6919
|
-
Emits,
|
|
6920
|
-
StateId,
|
|
6921
|
-
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
6922
|
-
>
|
|
6923
|
-
>(
|
|
6924
|
-
handler:
|
|
6925
|
-
& Handler
|
|
6926
|
-
& InvokeTransition<
|
|
6927
|
-
States,
|
|
6928
|
-
Events,
|
|
6929
|
-
Emits,
|
|
6930
|
-
StateId,
|
|
6931
|
-
InvokeDoneContext<States, Events, Emits, StateId, Output, InputEvents, ParentEvents>
|
|
6932
|
-
>
|
|
6933
|
-
) => InvokeBuilder<
|
|
6934
|
-
States,
|
|
6935
|
-
Events,
|
|
6936
|
-
Emits,
|
|
6937
|
-
StateId,
|
|
6938
|
-
InputEvents,
|
|
6939
|
-
ParentEvents,
|
|
6940
|
-
Output,
|
|
6941
|
-
Error,
|
|
6942
|
-
Requirements,
|
|
6943
|
-
InitialError,
|
|
6944
|
-
ChildEmits,
|
|
6945
|
-
ChildParentEvent,
|
|
6946
|
-
Element,
|
|
6947
|
-
Exclude<Pending, "done">,
|
|
6948
|
-
SnapshotHandler,
|
|
6949
|
-
Outcomes | Handler
|
|
6950
|
-
>
|
|
6951
|
-
}
|
|
6952
|
-
: {})
|
|
6953
|
-
& ("failure" extends Pending ? {
|
|
6954
|
-
/** Handles typed failure and exposes the invocation error. */
|
|
6955
|
-
readonly onFailure: <
|
|
6956
|
-
const Handler extends InvokeTransition<
|
|
6957
|
-
States,
|
|
6958
|
-
Events,
|
|
6959
|
-
Emits,
|
|
6960
|
-
StateId,
|
|
6961
|
-
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
6962
|
-
>
|
|
6963
|
-
>(
|
|
6964
|
-
handler:
|
|
6965
|
-
& Handler
|
|
6966
|
-
& InvokeTransition<
|
|
6967
|
-
States,
|
|
6968
|
-
Events,
|
|
6969
|
-
Emits,
|
|
6970
|
-
StateId,
|
|
6971
|
-
InvokeFailureContext<States, Events, Emits, StateId, Error, InputEvents, ParentEvents>
|
|
6972
|
-
>
|
|
6973
|
-
) => InvokeBuilder<
|
|
6974
|
-
States,
|
|
6975
|
-
Events,
|
|
6976
|
-
Emits,
|
|
6977
|
-
StateId,
|
|
6978
|
-
InputEvents,
|
|
6979
|
-
ParentEvents,
|
|
6980
|
-
Output,
|
|
6981
|
-
Error,
|
|
6982
|
-
Requirements,
|
|
6983
|
-
InitialError,
|
|
6984
|
-
ChildEmits,
|
|
6985
|
-
ChildParentEvent,
|
|
6986
|
-
Element,
|
|
6987
|
-
Exclude<Pending, "failure">,
|
|
6988
|
-
SnapshotHandler,
|
|
6989
|
-
Outcomes | Handler
|
|
6990
|
-
>
|
|
6991
|
-
}
|
|
6992
|
-
: {})
|
|
6993
|
-
& ("element" extends Pending ? {
|
|
6994
|
-
/** Handles each backpressured element emitted by an invoked Stream. */
|
|
6995
|
-
readonly onElement: <
|
|
6996
|
-
const Handler extends InvokeTransition<
|
|
6997
|
-
States,
|
|
6998
|
-
Events,
|
|
6999
|
-
Emits,
|
|
7000
|
-
StateId,
|
|
7001
|
-
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
7002
|
-
>
|
|
7003
|
-
>(
|
|
7004
|
-
handler:
|
|
7005
|
-
& Handler
|
|
7006
|
-
& InvokeTransition<
|
|
7007
|
-
States,
|
|
7008
|
-
Events,
|
|
7009
|
-
Emits,
|
|
7010
|
-
StateId,
|
|
7011
|
-
InvokeElementContext<States, Events, Emits, StateId, Element, InputEvents, ParentEvents>
|
|
7012
|
-
>
|
|
7013
|
-
) => InvokeBuilder<
|
|
7014
|
-
States,
|
|
7015
|
-
Events,
|
|
7016
|
-
Emits,
|
|
7017
|
-
StateId,
|
|
7018
|
-
InputEvents,
|
|
7019
|
-
ParentEvents,
|
|
7020
|
-
Output,
|
|
7021
|
-
Error,
|
|
7022
|
-
Requirements,
|
|
7023
|
-
InitialError,
|
|
7024
|
-
ChildEmits,
|
|
7025
|
-
ChildParentEvent,
|
|
7026
|
-
Element,
|
|
7027
|
-
Exclude<Pending, "element">,
|
|
7028
|
-
SnapshotHandler,
|
|
7029
|
-
Outcomes | Handler
|
|
7030
|
-
>
|
|
7031
|
-
}
|
|
7032
|
-
: {})
|
|
7033
|
-
& ([SnapshotHandler] extends [never] ? {} : {
|
|
7034
|
-
/** Handles each active snapshot published by invoked logic or a child machine. */
|
|
7035
|
-
readonly onSnapshot: <const Handler extends SnapshotHandler>(handler: Handler & SnapshotHandler) => InvokeBuilder<
|
|
7036
|
-
States,
|
|
7037
|
-
Events,
|
|
7038
|
-
Emits,
|
|
7039
|
-
StateId,
|
|
7040
|
-
InputEvents,
|
|
7041
|
-
ParentEvents,
|
|
7042
|
-
Output,
|
|
7043
|
-
Error,
|
|
7044
|
-
Requirements,
|
|
7045
|
-
InitialError,
|
|
7046
|
-
ChildEmits,
|
|
7047
|
-
ChildParentEvent,
|
|
7048
|
-
Element,
|
|
7049
|
-
Pending,
|
|
7050
|
-
never,
|
|
7051
|
-
Outcomes | Handler
|
|
7052
|
-
>
|
|
7053
|
-
})
|
|
7054
|
-
|
|
7055
|
-
type EffectInvokeBuilder<
|
|
7056
|
-
States extends StateSchemas,
|
|
7057
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7058
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7059
|
-
StateId extends StateIdentifier<States>,
|
|
7060
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7061
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7062
|
-
Source extends (...args: ReadonlyArray<any>) => Effect.Effect<any, any, any>
|
|
7063
|
-
> = InvokeBuilder<
|
|
7064
|
-
States,
|
|
7065
|
-
Events,
|
|
7066
|
-
Emits,
|
|
7067
|
-
StateId,
|
|
7068
|
-
InputEvents,
|
|
7069
|
-
ParentEvents,
|
|
7070
|
-
Effect.Success<ReturnType<Source>>,
|
|
7071
|
-
Effect.Error<ReturnType<Source>>,
|
|
7072
|
-
Effect.Services<ReturnType<Source>>,
|
|
7073
|
-
never,
|
|
7074
|
-
never,
|
|
7075
|
-
never,
|
|
7076
|
-
never,
|
|
7077
|
-
| RequiredInvokeChannel<Effect.Success<ReturnType<Source>>, "done">
|
|
7078
|
-
| RequiredInvokeChannel<Effect.Error<ReturnType<Source>>, "failure">,
|
|
7079
|
-
never
|
|
7080
|
-
>
|
|
7081
|
-
|
|
7082
|
-
type StreamInvokeBuilder<
|
|
7083
|
-
States extends StateSchemas,
|
|
7084
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7085
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7086
|
-
StateId extends StateIdentifier<States>,
|
|
7087
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7088
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7089
|
-
Source extends (...args: ReadonlyArray<any>) => Stream.Stream<any, any, any>
|
|
7090
|
-
> = InvokeBuilder<
|
|
7091
|
-
States,
|
|
7092
|
-
Events,
|
|
7093
|
-
Emits,
|
|
7094
|
-
StateId,
|
|
7095
|
-
InputEvents,
|
|
7096
|
-
ParentEvents,
|
|
7097
|
-
void,
|
|
7098
|
-
Stream.Error<ReturnType<Source>>,
|
|
7099
|
-
Stream.Services<ReturnType<Source>>,
|
|
7100
|
-
never,
|
|
7101
|
-
never,
|
|
7102
|
-
never,
|
|
7103
|
-
Stream.Success<ReturnType<Source>>,
|
|
7104
|
-
| "done"
|
|
7105
|
-
| RequiredInvokeChannel<Stream.Success<ReturnType<Source>>, "element">
|
|
7106
|
-
| RequiredInvokeChannel<Stream.Error<ReturnType<Source>>, "failure">,
|
|
7107
|
-
never
|
|
7108
|
-
>
|
|
7109
|
-
|
|
7110
|
-
type LogicInvokeBuilder<
|
|
7111
|
-
States extends StateSchemas,
|
|
7112
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7113
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7114
|
-
StateId extends StateIdentifier<States>,
|
|
7115
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7116
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7117
|
-
ChildLogic
|
|
7118
|
-
> = InvokeBuilder<
|
|
7119
|
-
States,
|
|
7120
|
-
Events,
|
|
7121
|
-
Emits,
|
|
7122
|
-
StateId,
|
|
7123
|
-
InputEvents,
|
|
7124
|
-
ParentEvents,
|
|
7125
|
-
LogicOutputOf<ChildLogic>,
|
|
7126
|
-
LogicErrorOf<ChildLogic>,
|
|
7127
|
-
LogicServicesOf<ChildLogic>,
|
|
7128
|
-
LogicInitialErrorOf<ChildLogic>,
|
|
7129
|
-
never,
|
|
7130
|
-
never,
|
|
7131
|
-
never,
|
|
7132
|
-
| RequiredInvokeChannel<LogicOutputOf<ChildLogic>, "done">
|
|
7133
|
-
| RequiredInvokeChannel<LogicErrorOf<ChildLogic>, "failure">,
|
|
7134
|
-
InvokeTransition<
|
|
7135
|
-
States,
|
|
7136
|
-
Events,
|
|
7137
|
-
Emits,
|
|
7138
|
-
StateId,
|
|
7139
|
-
InvokeSnapshotContext<
|
|
7140
|
-
States,
|
|
7141
|
-
Events,
|
|
7142
|
-
Emits,
|
|
7143
|
-
StateId,
|
|
7144
|
-
LogicStateOf<ChildLogic>,
|
|
7145
|
-
LogicErrorOf<ChildLogic>,
|
|
7146
|
-
LogicOutputOf<ChildLogic>,
|
|
7147
|
-
InputEvents,
|
|
7148
|
-
ParentEvents
|
|
7149
|
-
>
|
|
7150
|
-
>
|
|
7151
|
-
>
|
|
7152
|
-
|
|
7153
|
-
type ChildInvokeBuilder<
|
|
7154
|
-
States extends StateSchemas,
|
|
7155
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7156
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7157
|
-
StateId extends StateIdentifier<States>,
|
|
7158
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7159
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7160
|
-
Child extends ChildMachine.Any,
|
|
7161
|
-
ChildDefinition extends Machine.Any = Child["machine"]
|
|
7162
|
-
> = InvokeBuilder<
|
|
7163
|
-
States,
|
|
7164
|
-
Events,
|
|
7165
|
-
Emits,
|
|
7166
|
-
StateId,
|
|
7167
|
-
InputEvents,
|
|
7168
|
-
ParentEvents,
|
|
7169
|
-
Output<ChildDefinition>,
|
|
7170
|
-
Error<ChildDefinition> | ActionError<Services<ChildDefinition>>,
|
|
7171
|
-
Services<ChildDefinition>,
|
|
7172
|
-
InitialError<ChildDefinition>,
|
|
7173
|
-
EmittedEvent<ChildDefinition>,
|
|
7174
|
-
EventOf<Machine.ParentEvents<ChildDefinition>>,
|
|
7175
|
-
never,
|
|
7176
|
-
| RequiredInvokeChannel<Output<ChildDefinition>, "done">
|
|
7177
|
-
| RequiredInvokeChannel<Error<ChildDefinition> | ActionError<Services<ChildDefinition>>, "failure">,
|
|
7178
|
-
InvokeTransition<
|
|
7179
|
-
States,
|
|
7180
|
-
Events,
|
|
7181
|
-
Emits,
|
|
7182
|
-
StateId,
|
|
7183
|
-
InvokeSnapshotContext<
|
|
7184
|
-
States,
|
|
7185
|
-
Events,
|
|
7186
|
-
Emits,
|
|
7187
|
-
StateId,
|
|
7188
|
-
Snapshot<Machine.States<ChildDefinition>>,
|
|
7189
|
-
Error<ChildDefinition>,
|
|
7190
|
-
Output<ChildDefinition>,
|
|
7191
|
-
InputEvents,
|
|
7192
|
-
ParentEvents
|
|
7193
|
-
>
|
|
7194
|
-
>
|
|
7195
|
-
>
|
|
7196
|
-
|
|
7197
|
-
/**
|
|
7198
|
-
* Selects state-owned work and begins its lifecycle-handler chain.
|
|
7199
|
-
*
|
|
7200
|
-
* Each source exposes exactly the lifecycle methods that it can produce. A
|
|
7201
|
-
* chain becomes returnable from `invoke` only after every reachable required
|
|
7202
|
-
* channel has been handled.
|
|
7203
|
-
*
|
|
7204
|
-
* **Example** (Invoking an Effect)
|
|
7205
|
-
*
|
|
7206
|
-
* ```ts
|
|
7207
|
-
* invoke: (from) =>
|
|
7208
|
-
* from.effect("load-user", () => loadUser).onDone((to) =>
|
|
7209
|
-
* to.branch.Ready().resolve(({ output, target }) => target.from({ user: output }))
|
|
7210
|
-
* ).onFailure((to) =>
|
|
7211
|
-
* to.branch.Failed().resolve(({ error, target }) => target.from({ error }))
|
|
7212
|
-
* )
|
|
7213
|
-
* ```
|
|
7214
|
-
*
|
|
7215
|
-
* @inlineType EffectInvokeBuilder
|
|
7216
|
-
* @inlineType StreamInvokeBuilder
|
|
7217
|
-
* @inlineType LogicInvokeBuilder
|
|
7218
|
-
* @inlineType ChildInvokeBuilder
|
|
7219
|
-
* @inlineType InvokeBuilder
|
|
7220
|
-
*
|
|
7221
|
-
* @category models
|
|
7222
|
-
* @since 0.18.0
|
|
7223
|
-
*/
|
|
7224
|
-
export interface InvokeSelector<
|
|
7225
|
-
States extends StateSchemas,
|
|
7226
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7227
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7228
|
-
StateId extends StateIdentifier<States>,
|
|
7229
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7230
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7231
|
-
> {
|
|
7232
|
-
/**
|
|
7233
|
-
* Starts a fresh Effect each time the owning state is entered.
|
|
7234
|
-
*
|
|
7235
|
-
* @param id Parent-local lifecycle identifier.
|
|
7236
|
-
* @param source Lazy Effect factory evaluated on every entry.
|
|
7237
|
-
*/
|
|
7238
|
-
readonly effect: <
|
|
7239
|
-
const Source extends (
|
|
7240
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7241
|
-
) => Effect.Effect<unknown, unknown, unknown>
|
|
7242
|
-
>(
|
|
7243
|
-
id: InvokeLifecycleId,
|
|
7244
|
-
source: Source
|
|
7245
|
-
) => EffectInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
7246
|
-
|
|
7247
|
-
/**
|
|
7248
|
-
* Starts a fresh, backpressured Stream each time the owning state is entered.
|
|
7249
|
-
*
|
|
7250
|
-
* @param id Parent-local lifecycle identifier.
|
|
7251
|
-
* @param source Lazy Stream factory evaluated on every entry.
|
|
7252
|
-
*/
|
|
7253
|
-
readonly stream: <
|
|
7254
|
-
const Source extends (
|
|
7255
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7256
|
-
) => Stream.Stream<unknown, unknown, any>
|
|
7257
|
-
>(
|
|
7258
|
-
id: InvokeLifecycleId,
|
|
7259
|
-
source: Source
|
|
7260
|
-
) => StreamInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Source>
|
|
7261
|
-
|
|
7262
|
-
/**
|
|
7263
|
-
* Starts a cancellable state-scoped timer.
|
|
7264
|
-
*
|
|
7265
|
-
* @param id Parent-local lifecycle identifier.
|
|
7266
|
-
* @param duration Duration input or context-dependent duration factory.
|
|
7267
|
-
*/
|
|
7268
|
-
readonly timer: (
|
|
7269
|
-
id: InvokeLifecycleId,
|
|
7270
|
-
duration: InvokeSource<
|
|
7271
|
-
Duration.Input,
|
|
7272
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7273
|
-
>
|
|
7274
|
-
) => InvokeBuilder<
|
|
7275
|
-
States,
|
|
7276
|
-
Events,
|
|
7277
|
-
Emits,
|
|
7278
|
-
StateId,
|
|
7279
|
-
InputEvents,
|
|
7280
|
-
ParentEvents,
|
|
7281
|
-
void,
|
|
7282
|
-
never,
|
|
7283
|
-
never,
|
|
7284
|
-
never,
|
|
7285
|
-
never,
|
|
7286
|
-
never,
|
|
7287
|
-
never,
|
|
7288
|
-
"done",
|
|
7289
|
-
never
|
|
7290
|
-
>
|
|
7291
|
-
|
|
7292
|
-
/**
|
|
7293
|
-
* Starts reusable process logic at a typed parent-local address.
|
|
7294
|
-
*
|
|
7295
|
-
* @param id Parent-local lifecycle identifier.
|
|
7296
|
-
* @param options Address and reusable logic value or factory.
|
|
7297
|
-
*/
|
|
7298
|
-
readonly logic: {
|
|
7299
|
-
<
|
|
7300
|
-
const Source extends (
|
|
7301
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7302
|
-
) => unknown,
|
|
7303
|
-
Address extends ChildAddress<never>
|
|
7304
|
-
>(
|
|
7305
|
-
id: InvokeLifecycleId,
|
|
7306
|
-
options: {
|
|
7307
|
-
/** Typed parent-local address used to send events to this logic. */
|
|
7308
|
-
readonly address:
|
|
7309
|
-
& Address
|
|
7310
|
-
& ChildAddress.Compatibility<Address, LogicEventOf<ReturnType<NoInfer<Source>>>>
|
|
7311
|
-
/** Context-dependent factory that returns reusable process logic. */
|
|
7312
|
-
readonly logic: Source
|
|
7313
|
-
},
|
|
7314
|
-
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
7315
|
-
"logic factory must return Machine.Logic"
|
|
7316
|
-
]
|
|
7317
|
-
): LogicInvokeBuilder<
|
|
7318
|
-
States,
|
|
7319
|
-
Events,
|
|
7320
|
-
Emits,
|
|
7321
|
-
StateId,
|
|
7322
|
-
InputEvents,
|
|
7323
|
-
ParentEvents,
|
|
7324
|
-
ReturnType<Source>
|
|
7325
|
-
>
|
|
7326
|
-
<const Source, Address extends ChildAddress<never>>(
|
|
7327
|
-
id: InvokeLifecycleId,
|
|
7328
|
-
options: {
|
|
7329
|
-
/** Typed parent-local address used to send events to this logic. */
|
|
7330
|
-
readonly address: Address & ChildAddress.Compatibility<Address, LogicEventOf<NoInfer<Source>>>
|
|
7331
|
-
/** Reusable process logic started when the owning state enters. */
|
|
7332
|
-
readonly logic: Source
|
|
7333
|
-
},
|
|
7334
|
-
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
7335
|
-
"logic must implement Machine.Logic"
|
|
7336
|
-
]
|
|
7337
|
-
): LogicInvokeBuilder<
|
|
7338
|
-
States,
|
|
7339
|
-
Events,
|
|
7340
|
-
Emits,
|
|
7341
|
-
StateId,
|
|
7342
|
-
InputEvents,
|
|
7343
|
-
ParentEvents,
|
|
7344
|
-
Source
|
|
7345
|
-
>
|
|
7346
|
-
}
|
|
7347
|
-
|
|
7348
|
-
/**
|
|
7349
|
-
* Starts a complete child statechart represented by a reusable descriptor.
|
|
7350
|
-
*
|
|
7351
|
-
* @param child Reusable descriptor created with `Machine.child`.
|
|
7352
|
-
* @param options Input construction for a child with a non-void input schema.
|
|
7353
|
-
*/
|
|
7354
|
-
readonly child: <const Child extends ChildMachine.Any>(
|
|
7355
|
-
child:
|
|
7356
|
-
& Child
|
|
7357
|
-
& (Child["machine"] extends EnsureExecutable<
|
|
7358
|
-
Machine.States<Child["machine"]>,
|
|
7359
|
-
Machine.UnhandledStates<Child["machine"]>,
|
|
7360
|
-
Machine.OutputStates<Child["machine"]>
|
|
7361
|
-
> ? unknown
|
|
7362
|
-
: never),
|
|
7363
|
-
...options: InputSchema<Child["machine"]> extends typeof Schema.Void ? [options?: { readonly input?: never }]
|
|
7364
|
-
: [options: {
|
|
7365
|
-
/** Child input value or factory evaluated from the owning state context. */
|
|
7366
|
-
readonly input: InvokeSource<
|
|
7367
|
-
Input<Child["machine"]>,
|
|
7368
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7369
|
-
>
|
|
7370
|
-
}]
|
|
7371
|
-
) => ChildInvokeBuilder<States, Events, Emits, StateId, InputEvents, ParentEvents, Child>
|
|
7372
|
-
}
|
|
7373
|
-
|
|
7374
|
-
/**
|
|
7375
|
-
* Inline invocation declaration accepted by an active state handler.
|
|
7376
|
-
*
|
|
7377
|
-
* Return one completed source chain or an array of completed chains. Source
|
|
7378
|
-
* computations and child descriptors may be extracted, but the chain stays
|
|
7379
|
-
* local to preserve the owning state and machine protocols.
|
|
7380
|
-
*
|
|
7381
|
-
* @category models
|
|
7382
|
-
* @since 0.18.0
|
|
7383
|
-
*/
|
|
7384
|
-
export type InvokeBuilderInput<
|
|
7385
|
-
States extends StateSchemas,
|
|
7386
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7387
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7388
|
-
StateId extends StateIdentifier<States>,
|
|
7389
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7390
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7391
|
-
> = (
|
|
7392
|
-
from: InvokeSelector<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7393
|
-
) =>
|
|
7394
|
-
| (InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
7395
|
-
readonly [InvokeBuilderTypeId]: true
|
|
7396
|
-
})
|
|
7397
|
-
| ReadonlyArray<
|
|
7398
|
-
InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
7399
|
-
readonly [InvokeBuilderTypeId]: true
|
|
7400
|
-
}
|
|
7401
|
-
>
|
|
7402
|
-
|
|
7403
|
-
/** Output construction available to final and output-producing parallel states. */
|
|
7404
|
-
type OutputHandlerConfig<
|
|
7405
|
-
States extends StateSchemas,
|
|
7406
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7407
|
-
StateId extends StateIdentifier<States>,
|
|
7408
|
-
Context
|
|
7409
|
-
> = NodeByIdentifier<States, StateId> extends { readonly output: Schema.Top } ? {
|
|
7410
|
-
/** Constructs the decoded output declared by the state's `output` schema. */
|
|
7411
|
-
readonly output: (context: Context) => OutputByIdentifier<States, StateId>
|
|
7412
|
-
}
|
|
7413
|
-
: {
|
|
7414
|
-
readonly output?: never
|
|
7415
|
-
}
|
|
7416
|
-
|
|
7417
|
-
type ActiveOutputHandlerConfig<
|
|
5973
|
+
type ActiveOutputHandlerConfig<
|
|
7418
5974
|
States extends StateSchemas,
|
|
7419
5975
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
7420
5976
|
StateId extends StateIdentifier<States>
|
|
@@ -7428,86 +5984,6 @@ export declare namespace Machine {
|
|
|
7428
5984
|
readonly output?: never
|
|
7429
5985
|
}
|
|
7430
5986
|
|
|
7431
|
-
/**
|
|
7432
|
-
* Configuration accepted for a non-final state.
|
|
7433
|
-
*
|
|
7434
|
-
* **Example** (State actions, events, and invocation)
|
|
7435
|
-
*
|
|
7436
|
-
* ```ts
|
|
7437
|
-
* machine.handle({ states: {
|
|
7438
|
-
* Loading: {
|
|
7439
|
-
* entry: (_, enqueue) => enqueue.emit({ _tag: "Started" }),
|
|
7440
|
-
* invoke: (from) =>
|
|
7441
|
-
* from.effect("load", () => load).onDone((to) => to.branch.Ready()),
|
|
7442
|
-
* on: { Cancel: (to) => to.branch.Idle() }
|
|
7443
|
-
* }
|
|
7444
|
-
* } })
|
|
7445
|
-
* ```
|
|
7446
|
-
*
|
|
7447
|
-
* @inlineType ActiveOutputHandlerConfig
|
|
7448
|
-
* @inlineType OutputHandlerConfig
|
|
7449
|
-
*
|
|
7450
|
-
* @category models
|
|
7451
|
-
* @since 0.4.0
|
|
7452
|
-
*/
|
|
7453
|
-
export type ActiveStateConfig<
|
|
7454
|
-
States extends StateSchemas,
|
|
7455
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7456
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7457
|
-
StateId extends StateIdentifier<States>,
|
|
7458
|
-
E,
|
|
7459
|
-
R,
|
|
7460
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7461
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7462
|
-
> = {
|
|
7463
|
-
/** Runs synchronously when the state is entered and may enqueue commands. */
|
|
7464
|
-
readonly entry?: (
|
|
7465
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7466
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7467
|
-
) => StateActionResult<any, any>
|
|
7468
|
-
/** Runs synchronously before the state is exited and may enqueue commands. */
|
|
7469
|
-
readonly exit?: (
|
|
7470
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7471
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7472
|
-
) => StateActionResult<any, any>
|
|
7473
|
-
/** Starts state-owned Effect, Stream, timer, logic, or child lifecycles. */
|
|
7474
|
-
readonly invoke?: InvokeBuilderInput<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7475
|
-
/** Eventless transition evaluated after the state becomes stable. */
|
|
7476
|
-
readonly always?: TransitionConfig<
|
|
7477
|
-
States,
|
|
7478
|
-
Events,
|
|
7479
|
-
Emits,
|
|
7480
|
-
StateId,
|
|
7481
|
-
AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7482
|
-
false,
|
|
7483
|
-
TransitionAcceptance
|
|
7484
|
-
>
|
|
7485
|
-
/** Transition evaluated after this compound or parallel state completes. */
|
|
7486
|
-
readonly onDone?: TransitionConfig<
|
|
7487
|
-
States,
|
|
7488
|
-
Events,
|
|
7489
|
-
Emits,
|
|
7490
|
-
StateId,
|
|
7491
|
-
DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7492
|
-
false,
|
|
7493
|
-
TransitionAcceptance
|
|
7494
|
-
>
|
|
7495
|
-
/** Event handlers keyed by the `_tag` of the machine's public or internal events. */
|
|
7496
|
-
readonly on?: {
|
|
7497
|
-
readonly [EventTag in TagOf<Events[number]>]?: TransitionConfig<
|
|
7498
|
-
States,
|
|
7499
|
-
Events,
|
|
7500
|
-
Emits,
|
|
7501
|
-
StateId,
|
|
7502
|
-
HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>,
|
|
7503
|
-
true,
|
|
7504
|
-
TransitionAcceptance
|
|
7505
|
-
>
|
|
7506
|
-
}
|
|
7507
|
-
/** Supplies missing direct initial-child values required by implicit entry and shallow history. */
|
|
7508
|
-
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7509
|
-
} & ActiveOutputHandlerConfig<States, Events, StateId>
|
|
7510
|
-
|
|
7511
5987
|
/**
|
|
7512
5988
|
* Values constructed for a state's schema-valued direct initial children.
|
|
7513
5989
|
*
|
|
@@ -7687,7 +6163,7 @@ export declare namespace Machine {
|
|
|
7687
6163
|
}
|
|
7688
6164
|
|
|
7689
6165
|
/** Required implementation for a choice pseudo-state. */
|
|
7690
|
-
|
|
6166
|
+
interface ChoiceStateConfig<
|
|
7691
6167
|
States extends StateSchemas,
|
|
7692
6168
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
7693
6169
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -7700,82 +6176,21 @@ export declare namespace Machine {
|
|
|
7700
6176
|
States,
|
|
7701
6177
|
Events,
|
|
7702
6178
|
Emits,
|
|
7703
|
-
ChoiceId,
|
|
7704
|
-
ChoiceContext<States, Events, Emits, ChoiceId, InputEvents, ParentEvents>
|
|
7705
|
-
>
|
|
7706
|
-
readonly entry?: never
|
|
7707
|
-
readonly exit?: never
|
|
7708
|
-
readonly invoke?: never
|
|
7709
|
-
readonly always?: never
|
|
7710
|
-
readonly on?: never
|
|
7711
|
-
readonly onDone?: never
|
|
7712
|
-
readonly output?: never
|
|
7713
|
-
readonly initialize?: never
|
|
7714
|
-
}
|
|
7715
|
-
|
|
7716
|
-
/**
|
|
7717
|
-
* Configuration accepted for a final state.
|
|
7718
|
-
*
|
|
7719
|
-
* @inlineType OutputHandlerConfig
|
|
7720
|
-
*
|
|
7721
|
-
* @category models
|
|
7722
|
-
* @since 0.4.0
|
|
7723
|
-
*/
|
|
7724
|
-
export type FinalStateConfig<
|
|
7725
|
-
States extends StateSchemas,
|
|
7726
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7727
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7728
|
-
StateId extends StateIdentifier<States>,
|
|
7729
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7730
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7731
|
-
> = {
|
|
7732
|
-
/** Runs synchronously when the final state is entered and may enqueue commands. */
|
|
7733
|
-
readonly entry?: (
|
|
7734
|
-
context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
7735
|
-
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
7736
|
-
) => StateActionResult<any, any>
|
|
7737
|
-
readonly exit?: never
|
|
7738
|
-
readonly always?: never
|
|
7739
|
-
readonly onDone?: never
|
|
7740
|
-
readonly on?: never
|
|
7741
|
-
} & OutputHandlerConfig<States, Events, StateId, FinalOutputContext<States, Events, StateId>>
|
|
7742
|
-
|
|
7743
|
-
/**
|
|
7744
|
-
* Configuration accepted by `handle` for a state tag.
|
|
7745
|
-
*
|
|
7746
|
-
* @category models
|
|
7747
|
-
* @since 0.4.0
|
|
7748
|
-
*/
|
|
7749
|
-
export type HandlerConfig<
|
|
7750
|
-
States extends StateSchemas,
|
|
7751
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7752
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7753
|
-
StateId extends StateIdentifier<States>,
|
|
7754
|
-
E,
|
|
7755
|
-
R,
|
|
7756
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
7757
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
7758
|
-
> = NodeByIdentifier<States, StateId> extends { readonly type: "final" } ?
|
|
7759
|
-
FinalStateConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7760
|
-
: ActiveStateConfig<States, Events, Emits, StateId, E, R, InputEvents, ParentEvents>
|
|
7761
|
-
|
|
7762
|
-
type HandlerNodeConfig<
|
|
7763
|
-
States extends StateSchemas,
|
|
7764
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7765
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7766
|
-
Path extends StateNodeIdentifier<States>,
|
|
7767
|
-
E,
|
|
7768
|
-
R,
|
|
7769
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7770
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>
|
|
7771
|
-
> = Path extends ChoiceIdentifier<States> ? ChoiceStateConfig<States, Events, Emits, Path, InputEvents, ParentEvents>
|
|
7772
|
-
: Path extends StateIdentifier<States> ? HandlerConfig<States, Events, Emits, Path, E, R, InputEvents, ParentEvents>
|
|
7773
|
-
: never
|
|
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
|
+
}
|
|
7774
6191
|
|
|
7775
6192
|
type HandlerChildren<Node> = Node extends { readonly states: infer Children extends StateSchemas } ? Children : never
|
|
7776
6193
|
|
|
7777
|
-
type HandlerNodeId<States extends StateSchemas, Path extends string> = Extract<Path, StateNodeIdentifier<States>>
|
|
7778
|
-
|
|
7779
6194
|
type HandlerConfigPart<Config> = {
|
|
7780
6195
|
readonly [Key in keyof Config as Key extends "states" ? never : Key]: Config[Key]
|
|
7781
6196
|
}
|
|
@@ -7818,78 +6233,6 @@ export declare namespace Machine {
|
|
|
7818
6233
|
}
|
|
7819
6234
|
: { readonly [Key in Path]?: Validation }
|
|
7820
6235
|
|
|
7821
|
-
/** Nested handler-tree structure shared by active and final state configs. */
|
|
7822
|
-
type HandlerNode<
|
|
7823
|
-
AllStates extends StateSchemas,
|
|
7824
|
-
Node,
|
|
7825
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7826
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7827
|
-
E,
|
|
7828
|
-
R,
|
|
7829
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7830
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7831
|
-
StateId extends StateNodeIdentifier<AllStates>
|
|
7832
|
-
> =
|
|
7833
|
-
& HandlerNodeConfig<AllStates, Events, Emits, StateId, E, R, InputEvents, ParentEvents>
|
|
7834
|
-
& (StateId extends ChoiceIdentifier<AllStates> ? {
|
|
7835
|
-
readonly states?: never
|
|
7836
|
-
readonly history?: never
|
|
7837
|
-
}
|
|
7838
|
-
: HandlerChildren<Node> extends infer Children extends StateSchemas ? [Children] extends [never] ? {
|
|
7839
|
-
readonly states?: never
|
|
7840
|
-
readonly history?: never
|
|
7841
|
-
}
|
|
7842
|
-
: {
|
|
7843
|
-
/** Child-state handlers nested according to the declared state topology. */
|
|
7844
|
-
readonly states?: HandlerTree<
|
|
7845
|
-
AllStates,
|
|
7846
|
-
Children,
|
|
7847
|
-
Events,
|
|
7848
|
-
Emits,
|
|
7849
|
-
E,
|
|
7850
|
-
R,
|
|
7851
|
-
InputEvents,
|
|
7852
|
-
ParentEvents,
|
|
7853
|
-
Extract<StateId, StateIdentifier<AllStates>>
|
|
7854
|
-
>
|
|
7855
|
-
/** First-use defaults keyed by direct history pseudo-state. */
|
|
7856
|
-
readonly history?: HistoryDefaultConfig<
|
|
7857
|
-
AllStates,
|
|
7858
|
-
Events,
|
|
7859
|
-
Emits,
|
|
7860
|
-
Extract<StateId, StateIdentifier<AllStates>>,
|
|
7861
|
-
Children
|
|
7862
|
-
>
|
|
7863
|
-
}
|
|
7864
|
-
: {
|
|
7865
|
-
readonly states?: never
|
|
7866
|
-
readonly history?: never
|
|
7867
|
-
})
|
|
7868
|
-
|
|
7869
|
-
type HandlerTree<
|
|
7870
|
-
AllStates extends StateSchemas,
|
|
7871
|
-
States extends StateSchemas,
|
|
7872
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
7873
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
7874
|
-
E,
|
|
7875
|
-
R,
|
|
7876
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
7877
|
-
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
7878
|
-
Prefix extends string
|
|
7879
|
-
> = {
|
|
7880
|
-
readonly [Key in ActiveStateKey<States> | ChoiceStateKey<States>]?: HandlerNode<
|
|
7881
|
-
AllStates,
|
|
7882
|
-
States[Key],
|
|
7883
|
-
Events,
|
|
7884
|
-
Emits,
|
|
7885
|
-
E,
|
|
7886
|
-
R,
|
|
7887
|
-
InputEvents,
|
|
7888
|
-
ParentEvents,
|
|
7889
|
-
HandlerNodeId<AllStates, JoinPath<Prefix, Key>>
|
|
7890
|
-
>
|
|
7891
|
-
}
|
|
7892
|
-
|
|
7893
6236
|
type HandlerNodeConfigKey =
|
|
7894
6237
|
| "always"
|
|
7895
6238
|
| "choice"
|
|
@@ -8031,30 +6374,6 @@ export declare namespace Machine {
|
|
|
8031
6374
|
>
|
|
8032
6375
|
: never
|
|
8033
6376
|
|
|
8034
|
-
type HandlerInitializeValidationAtPath<Config, Path extends string> = HandlerConfigAtPath<Config, Path> extends
|
|
8035
|
-
infer StateConfig ? [StateConfig] extends [never] ? HandlerValidationAtPath<Path, {
|
|
8036
|
-
readonly initialize: HandlerValidationError<
|
|
8037
|
-
"State requires initialize because a transition enters its declared initial configuration",
|
|
8038
|
-
Path
|
|
8039
|
-
>
|
|
8040
|
-
}>
|
|
8041
|
-
: "initialize" extends keyof StateConfig ? never
|
|
8042
|
-
: HandlerValidationAtPath<Path, {
|
|
8043
|
-
readonly initialize: HandlerValidationError<
|
|
8044
|
-
"State requires initialize because a transition enters its declared initial configuration",
|
|
8045
|
-
Path
|
|
8046
|
-
>
|
|
8047
|
-
}>
|
|
8048
|
-
: never
|
|
8049
|
-
|
|
8050
|
-
type HandlerInitialTargetValidationForPaths<
|
|
8051
|
-
AllStates extends StateSchemas,
|
|
8052
|
-
Config,
|
|
8053
|
-
Required
|
|
8054
|
-
> = Types.UnionToIntersection<
|
|
8055
|
-
Required extends string ? HandlerInitializeValidationAtPath<Config, Required> : unknown
|
|
8056
|
-
>
|
|
8057
|
-
|
|
8058
6377
|
type HandlerTreeInitialTargetPath<Config> = string extends keyof Config ? never
|
|
8059
6378
|
: Config extends object ? {
|
|
8060
6379
|
readonly [Key in keyof Config]:
|
|
@@ -8063,16 +6382,6 @@ export declare namespace Machine {
|
|
|
8063
6382
|
}[keyof Config]
|
|
8064
6383
|
: never
|
|
8065
6384
|
|
|
8066
|
-
type HandlerInitialTargetValidation<
|
|
8067
|
-
AllStates extends StateSchemas,
|
|
8068
|
-
Config
|
|
8069
|
-
> = HandlerTreeInitialTargetPath<Config> extends infer TargetPath ? HandlerInitialTargetValidationForPaths<
|
|
8070
|
-
AllStates,
|
|
8071
|
-
Config,
|
|
8072
|
-
RequiredInitializersForTargetPath<AllStates, TargetPath>
|
|
8073
|
-
>
|
|
8074
|
-
: unknown
|
|
8075
|
-
|
|
8076
6385
|
type HandlerChildrenValidation<
|
|
8077
6386
|
Node,
|
|
8078
6387
|
Prefix extends string,
|
|
@@ -8203,64 +6512,6 @@ export declare namespace Machine {
|
|
|
8203
6512
|
> = [Incompatible] extends [never] ? unknown
|
|
8204
6513
|
: HandlerValidationError<"Handler config requires an incompatible machine runtime", StateId, Incompatible>
|
|
8205
6514
|
|
|
8206
|
-
type HandlerNodeValidationAtPath<
|
|
8207
|
-
AllStates extends StateSchemas,
|
|
8208
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8209
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8210
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8211
|
-
Config,
|
|
8212
|
-
AvailableOutputStates extends StateIdentifier<AllStates>,
|
|
8213
|
-
StateId extends StateNodeIdentifier<AllStates>,
|
|
8214
|
-
NodeConfig = HandlerConfigAtPath<Config, StateId>
|
|
8215
|
-
> = [NodeConfig] extends [never] ? never
|
|
8216
|
-
: HandlerNodeValidation<
|
|
8217
|
-
AllStates,
|
|
8218
|
-
HandlerNodeByPath<AllStates, StateId>,
|
|
8219
|
-
Events,
|
|
8220
|
-
InputEvents,
|
|
8221
|
-
Emits,
|
|
8222
|
-
StateId,
|
|
8223
|
-
NodeConfig,
|
|
8224
|
-
AvailableOutputStates
|
|
8225
|
-
> extends infer Validation ? unknown extends Validation ? never
|
|
8226
|
-
: "" extends keyof AllStates ? StateId extends "" ? { readonly ""?: Validation }
|
|
8227
|
-
: { readonly ""?: { readonly states: HandlerValidationAtPath<StateId, Validation> } }
|
|
8228
|
-
: HandlerValidationAtPath<StateId, Validation>
|
|
8229
|
-
: never
|
|
8230
|
-
|
|
8231
|
-
type HandlerTreeNodeValidations<
|
|
8232
|
-
AllStates extends StateSchemas,
|
|
8233
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8234
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8235
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8236
|
-
Config,
|
|
8237
|
-
AvailableOutputStates extends StateIdentifier<AllStates>
|
|
8238
|
-
> = Types.UnionToIntersection<
|
|
8239
|
-
StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ?
|
|
8240
|
-
StateId extends StateNodeIdentifier<AllStates> ? HandlerNodeValidationAtPath<
|
|
8241
|
-
AllStates,
|
|
8242
|
-
Events,
|
|
8243
|
-
InputEvents,
|
|
8244
|
-
Emits,
|
|
8245
|
-
Config,
|
|
8246
|
-
AvailableOutputStates,
|
|
8247
|
-
StateId
|
|
8248
|
-
>
|
|
8249
|
-
: never
|
|
8250
|
-
: never
|
|
8251
|
-
>
|
|
8252
|
-
|
|
8253
|
-
type HandlerTreeValidation<
|
|
8254
|
-
AllStates extends StateSchemas,
|
|
8255
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
8256
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8257
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
8258
|
-
Config,
|
|
8259
|
-
AvailableOutputStates extends StateIdentifier<AllStates>
|
|
8260
|
-
> =
|
|
8261
|
-
& HandlerUnknownStateKeyValidation<AllStates, "", Config>
|
|
8262
|
-
& HandlerTreeNodeValidations<AllStates, Events, InputEvents, Emits, Config, AvailableOutputStates>
|
|
8263
|
-
|
|
8264
6515
|
type RootInitialTargetValidation<States extends StateSchemas, Config> =
|
|
8265
6516
|
RequiredInitializersForTargetPath<States, HandlerTreeInitialTargetPath<{ readonly "": Config }>> extends
|
|
8266
6517
|
infer Required ? Types.UnionToIntersection<
|
|
@@ -8394,128 +6645,1062 @@ export declare namespace Machine {
|
|
|
8394
6645
|
NodeConfig
|
|
8395
6646
|
>
|
|
8396
6647
|
: never
|
|
8397
|
-
readonly error: HandlerConfigError<HandlerConfigPart<NodeConfig>>
|
|
8398
|
-
readonly services: ConfigServices<HandlerConfigPart<NodeConfig>>
|
|
8399
|
-
readonly outputState: StateId extends StateIdentifier<AllStates> ? HandlerOutputStates<
|
|
8400
|
-
AllStates,
|
|
8401
|
-
StateId,
|
|
8402
|
-
HandlerConfigPart<NodeConfig>
|
|
8403
|
-
>
|
|
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
|
|
8404
7216
|
: never
|
|
8405
|
-
}
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
type
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
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>,
|
|
8422
7268
|
R,
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
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>
|
|
8452
7650
|
/**
|
|
8453
|
-
* Adds
|
|
7651
|
+
* Adds object handlers while checking topology, protocols, invocation outcomes, and readiness.
|
|
8454
7652
|
*
|
|
8455
7653
|
* @category combinators
|
|
8456
|
-
* @since 0.
|
|
7654
|
+
* @since 0.34.0
|
|
8457
7655
|
*/
|
|
8458
7656
|
export interface Handler<
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
OutputStates extends StateIdentifier<States>,
|
|
8471
|
-
InputEvents extends ReadonlyArray<TaggedSchema>,
|
|
8472
|
-
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
|
|
8473
7668
|
> {
|
|
8474
|
-
<
|
|
8475
|
-
const Config
|
|
8476
|
-
>(
|
|
7669
|
+
<const C>(
|
|
8477
7670
|
config:
|
|
8478
|
-
&
|
|
8479
|
-
& (
|
|
8480
|
-
&
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
Emits,
|
|
8485
|
-
E,
|
|
8486
|
-
R,
|
|
8487
|
-
InputEvents,
|
|
8488
|
-
ParentEvents,
|
|
8489
|
-
Extract<"", StateNodeIdentifier<States>>
|
|
8490
|
-
>
|
|
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>
|
|
8491
7677
|
& RootHandlerValidation<
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
NoInfer<
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
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>
|
|
8501
7686
|
>
|
|
8502
7687
|
>
|
|
8503
7688
|
): HandleTreeResult<
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
{ 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> }
|
|
8519
7704
|
>
|
|
8520
7705
|
}
|
|
8521
7706
|
|
|
@@ -8573,15 +7758,19 @@ export declare namespace Machine {
|
|
|
8573
7758
|
E,
|
|
8574
7759
|
R
|
|
8575
7760
|
> {
|
|
7761
|
+
/** Runs synchronously on entry and may enqueue commands. */
|
|
8576
7762
|
readonly entry?: (
|
|
8577
7763
|
context: StateActionContext<States, Events, Emits, StateId>,
|
|
8578
7764
|
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
8579
7765
|
) => StateActionResult<E, R>
|
|
7766
|
+
/** Runs synchronously on exit and may enqueue commands. */
|
|
8580
7767
|
readonly exit?: (
|
|
8581
7768
|
context: StateActionContext<States, Events, Emits, StateId>,
|
|
8582
7769
|
enqueue: Enqueue<EventOf<Events>, EmittedEventOf<Emits>>
|
|
8583
7770
|
) => StateActionResult<E, R>
|
|
7771
|
+
/** One registered invocation or an array with distinct lifecycle identities. */
|
|
8584
7772
|
readonly invoke?: StoredInvokeDefinition<States, Events, Emits, StateId>
|
|
7773
|
+
/** Eventless transition evaluated during stabilization. */
|
|
8585
7774
|
readonly always?: TransitionConfig<
|
|
8586
7775
|
States,
|
|
8587
7776
|
Events,
|
|
@@ -8591,6 +7780,7 @@ export declare namespace Machine {
|
|
|
8591
7780
|
false,
|
|
8592
7781
|
TransitionAcceptance
|
|
8593
7782
|
>
|
|
7783
|
+
/** Handles successful invocation or state completion with its exact output type. */
|
|
8594
7784
|
readonly onDone?: TransitionConfig<
|
|
8595
7785
|
States,
|
|
8596
7786
|
Events,
|
|
@@ -8600,9 +7790,11 @@ export declare namespace Machine {
|
|
|
8600
7790
|
false,
|
|
8601
7791
|
TransitionAcceptance
|
|
8602
7792
|
>
|
|
7793
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
8603
7794
|
readonly output?:
|
|
8604
7795
|
| ((context: FinalOutputContext<States, Events, StateId>) => unknown)
|
|
8605
7796
|
| ((context: ParallelOutputContext<States, Events, StateId>) => unknown)
|
|
7797
|
+
/** Event handlers keyed by the public or internal event tag. */
|
|
8606
7798
|
readonly on?: EventHandlerMap<States, Events, Emits, StateId, EventTag, E, R>
|
|
8607
7799
|
}
|
|
8608
7800
|
|
|
@@ -8654,7 +7846,10 @@ export declare namespace Snapshot {
|
|
|
8654
7846
|
export type Node<State> = State extends { readonly path: string; readonly value: unknown } ?
|
|
8655
7847
|
| State
|
|
8656
7848
|
| (State extends { readonly state: infer Child } ? Node<Child>
|
|
8657
|
-
: 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]>
|
|
8658
7853
|
: never) :
|
|
8659
7854
|
never
|
|
8660
7855
|
/** Every valid absolute path in a logical snapshot type. */
|
|
@@ -8782,6 +7977,76 @@ export const isFinal: <
|
|
|
8782
7977
|
*/
|
|
8783
7978
|
export const state: StateConstructor = internal.state as StateConstructor
|
|
8784
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
|
+
|
|
8785
8050
|
type MakeConfig<
|
|
8786
8051
|
Root extends Machine.StateNodeConfig,
|
|
8787
8052
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8790,8 +8055,28 @@ type MakeConfig<
|
|
|
8790
8055
|
InitialE,
|
|
8791
8056
|
InitialR,
|
|
8792
8057
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8793
|
-
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>
|
|
8794
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]>> }
|
|
8795
8080
|
/** Stable definition identifier used by inspection and visualization. */
|
|
8796
8081
|
readonly id?: string
|
|
8797
8082
|
/** State topology and value schemas, captured by a `Machine.state` descriptor. */
|
|
@@ -8823,7 +8108,13 @@ type MakeResult<
|
|
|
8823
8108
|
InitialE,
|
|
8824
8109
|
InitialR,
|
|
8825
8110
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8826
|
-
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>>>>
|
|
8827
8118
|
> = Definition<
|
|
8828
8119
|
{ readonly "": Root },
|
|
8829
8120
|
readonly [...InputEvents, ...InternalEvents],
|
|
@@ -8834,14 +8125,37 @@ type MakeResult<
|
|
|
8834
8125
|
Machine.TerminalOutput<{ readonly "": Root }>,
|
|
8835
8126
|
Emits,
|
|
8836
8127
|
InputEvents,
|
|
8837
|
-
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
|
+
}
|
|
8838
8143
|
>
|
|
8839
8144
|
|
|
8840
8145
|
type RootInitialization<Root extends Machine.StateNodeConfig, Input> =
|
|
8841
8146
|
& { readonly initialConfiguration?: never }
|
|
8842
|
-
& (Machine.NodeSchema<Root> extends never ? {
|
|
8843
|
-
|
|
8844
|
-
|
|
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
|
+
})
|
|
8845
8159
|
|
|
8846
8160
|
/** @inline */
|
|
8847
8161
|
interface Make {
|
|
@@ -8854,10 +8168,32 @@ interface Make {
|
|
|
8854
8168
|
InitialE = never,
|
|
8855
8169
|
InitialR = never,
|
|
8856
8170
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8857
|
-
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>> = {}
|
|
8858
8178
|
>(
|
|
8859
8179
|
config:
|
|
8860
|
-
& 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>>
|
|
8861
8197
|
& {
|
|
8862
8198
|
/** Mutually exclusive with a complete initial configuration. */
|
|
8863
8199
|
readonly initial?: never
|
|
@@ -8875,7 +8211,13 @@ interface Make {
|
|
|
8875
8211
|
InitialE,
|
|
8876
8212
|
InitialR,
|
|
8877
8213
|
InternalEvents,
|
|
8878
|
-
ParentDeclaration
|
|
8214
|
+
ParentDeclaration,
|
|
8215
|
+
Effects,
|
|
8216
|
+
Streams,
|
|
8217
|
+
Timers,
|
|
8218
|
+
Logics,
|
|
8219
|
+
Children,
|
|
8220
|
+
Branches
|
|
8879
8221
|
>
|
|
8880
8222
|
/** @param config Complete schema-first machine definition. */
|
|
8881
8223
|
<
|
|
@@ -8886,10 +8228,32 @@ interface Make {
|
|
|
8886
8228
|
InitialE = never,
|
|
8887
8229
|
InitialR = never,
|
|
8888
8230
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8889
|
-
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>> = {}
|
|
8890
8238
|
>(
|
|
8891
8239
|
config:
|
|
8892
|
-
& 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>>
|
|
8893
8257
|
& Exclude<
|
|
8894
8258
|
RootInitialization<NoInfer<Root>, Input["Type"]>,
|
|
8895
8259
|
{ readonly initialConfiguration: unknown }
|
|
@@ -8902,7 +8266,13 @@ interface Make {
|
|
|
8902
8266
|
InitialE,
|
|
8903
8267
|
InitialR,
|
|
8904
8268
|
InternalEvents,
|
|
8905
|
-
ParentDeclaration
|
|
8269
|
+
ParentDeclaration,
|
|
8270
|
+
Effects,
|
|
8271
|
+
Streams,
|
|
8272
|
+
Timers,
|
|
8273
|
+
Logics,
|
|
8274
|
+
Children,
|
|
8275
|
+
Branches
|
|
8906
8276
|
>
|
|
8907
8277
|
}
|
|
8908
8278
|
|
|
@@ -8947,6 +8317,7 @@ interface Make {
|
|
|
8947
8317
|
*
|
|
8948
8318
|
* const States = Machine.state({ initial: "Count", states: { Count } })
|
|
8949
8319
|
* const Events = Machine.eventsFromSchemas(Increment)
|
|
8320
|
+
* const targets = Machine.targets(States)
|
|
8950
8321
|
*
|
|
8951
8322
|
* const counter = Machine.make({
|
|
8952
8323
|
* root: States,
|
|
@@ -8955,9 +8326,10 @@ interface Make {
|
|
|
8955
8326
|
* }).handle({ states: {
|
|
8956
8327
|
* Count: {
|
|
8957
8328
|
* on: {
|
|
8958
|
-
* Increment:
|
|
8959
|
-
*
|
|
8960
|
-
*
|
|
8329
|
+
* Increment: {
|
|
8330
|
+
* update: targets.root.Count,
|
|
8331
|
+
* decoded: ({ event, state }) => new Count({ value: state.value + event.by })
|
|
8332
|
+
* }
|
|
8961
8333
|
* }
|
|
8962
8334
|
* }
|
|
8963
8335
|
* } })
|
|
@@ -9329,25 +8701,24 @@ type TransitionBranchRecordError<Message extends string, Key extends PropertyKey
|
|
|
9329
8701
|
readonly key: Key
|
|
9330
8702
|
}
|
|
9331
8703
|
|
|
9332
|
-
type InvalidStaticTransitionBranchKey<Branches> = Extract<
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
readonly target: { readonly "~effect/Machine/UpdatingTransitionTarget": string }
|
|
9337
|
-
} ? Key
|
|
9338
|
-
: never
|
|
9339
|
-
}[keyof Branches]
|
|
8704
|
+
type InvalidStaticTransitionBranchKey<Branches> = Extract<
|
|
8705
|
+
keyof Branches,
|
|
8706
|
+
"" | number | symbol | `${number}` | "NaN" | "Infinity" | "-Infinity"
|
|
8707
|
+
>
|
|
9340
8708
|
|
|
9341
8709
|
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ?
|
|
9342
8710
|
TransitionBranchRecordError<"Branch records must contain at least one branch">
|
|
9343
|
-
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ?
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
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",
|
|
9351
8722
|
InvalidStaticTransitionBranchKey<Branches>
|
|
9352
8723
|
>
|
|
9353
8724
|
|
|
@@ -9455,10 +8826,12 @@ export const planInitial: <
|
|
|
9455
8826
|
& (
|
|
9456
8827
|
| {
|
|
9457
8828
|
readonly done: true
|
|
8829
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9458
8830
|
readonly output: Output
|
|
9459
8831
|
}
|
|
9460
8832
|
| {
|
|
9461
8833
|
readonly done: false
|
|
8834
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9462
8835
|
readonly output: undefined
|
|
9463
8836
|
}
|
|
9464
8837
|
),
|
|
@@ -9664,7 +9037,7 @@ export const enabled: <
|
|
|
9664
9037
|
* events: Machine.eventsFromSchemas(),
|
|
9665
9038
|
* internalEvents,
|
|
9666
9039
|
* initialConfiguration: (root) => root.resolve(({ target }) => target.from((to) => to.Idle.from()))
|
|
9667
|
-
* }).handle({ states: { Idle: { on: { Loaded:
|
|
9040
|
+
* }).handle({ states: { Idle: { on: { Loaded: { none: true } } } } })
|
|
9668
9041
|
*
|
|
9669
9042
|
* export const canLoad = Effect.gen(function*() {
|
|
9670
9043
|
* const initial = yield* Machine.planInitial(machine)
|
|
@@ -9782,6 +9155,7 @@ export const can: {
|
|
|
9782
9155
|
* class On extends Schema.TaggedClass<On>("On")("On", {}) {}
|
|
9783
9156
|
* class Toggle extends Schema.TaggedClass<Toggle>("Toggle")("Toggle", {}) {}
|
|
9784
9157
|
* const States = Machine.state({ initial: "Off", states: { Off, On } })
|
|
9158
|
+
* const targets = Machine.targets(States)
|
|
9785
9159
|
* const machine = Machine.make({
|
|
9786
9160
|
* root: States,
|
|
9787
9161
|
* events: Machine.eventsFromSchemas(Toggle),
|
|
@@ -9789,8 +9163,7 @@ export const can: {
|
|
|
9789
9163
|
* }).handle({ states: {
|
|
9790
9164
|
* Off: {
|
|
9791
9165
|
* on: {
|
|
9792
|
-
* Toggle:
|
|
9793
|
-
* to.branch.On().resolve(({ target }) => target.from())
|
|
9166
|
+
* Toggle: { target: targets.root.On }
|
|
9794
9167
|
* }
|
|
9795
9168
|
* },
|
|
9796
9169
|
* On: {}
|
|
@@ -9871,10 +9244,12 @@ export const plan: <
|
|
|
9871
9244
|
& (
|
|
9872
9245
|
| {
|
|
9873
9246
|
readonly done: true
|
|
9247
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9874
9248
|
readonly output: Output
|
|
9875
9249
|
}
|
|
9876
9250
|
| {
|
|
9877
9251
|
readonly done: false
|
|
9252
|
+
/** Constructs the decoded output declared by the state schema. */
|
|
9878
9253
|
readonly output: undefined
|
|
9879
9254
|
}
|
|
9880
9255
|
),
|
|
@@ -9919,6 +9294,7 @@ export const logic: <
|
|
|
9919
9294
|
InitialError = never,
|
|
9920
9295
|
InitialRequirements = never
|
|
9921
9296
|
>(options: {
|
|
9297
|
+
/** Enters a compound or parallel subtree through its declared initialization. */
|
|
9922
9298
|
readonly initial:
|
|
9923
9299
|
| State
|
|
9924
9300
|
| ((
|
|
@@ -9977,7 +9353,7 @@ export const childAddress: <Event = never>(id: string) => ChildAddress<Event> =
|
|
|
9977
9353
|
* This Effect requires a managed process runtime. A named child id must be
|
|
9978
9354
|
* unique for the current parent until that child stops.
|
|
9979
9355
|
*
|
|
9980
|
-
*
|
|
9356
|
+
* Register logic in `make({ logic })` and use `invoke: { src, id, address, ...outcomes }` for children
|
|
9981
9357
|
* that start and stop with that state.
|
|
9982
9358
|
* @see {@link sendTo} for sending events to named children.
|
|
9983
9359
|
* @category runtime
|