@typeonce/effect-machine 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -13
- package/dist/Machine.d.ts +396 -127
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +21 -19
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +1 -0
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +23 -0
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/cluster.js +2 -2
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.js +2 -5
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +12 -7
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +9 -5
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +4 -3
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +68 -43
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/initialization.d.ts +5 -0
- package/dist/internal/machine/initialization.d.ts.map +1 -0
- package/dist/internal/machine/initialization.js +61 -0
- package/dist/internal/machine/initialization.js.map +1 -0
- package/dist/internal/machine/inspectionRuntime.d.ts +25 -0
- package/dist/internal/machine/inspectionRuntime.d.ts.map +1 -0
- package/dist/internal/machine/inspectionRuntime.js +79 -0
- package/dist/internal/machine/inspectionRuntime.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +2 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +18 -11
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +1 -2
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +21 -6
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +17 -2
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +137 -64
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +7 -5
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +29 -5
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +440 -64
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/symbols.d.ts +2 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -0
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +13 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +9 -0
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +3 -3
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +9 -0
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +9 -0
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +130 -20
- package/package.json +5 -5
- package/src/Machine.ts +548 -217
- package/src/internal/machine/atom.ts +26 -0
- package/src/internal/machine/cluster.ts +2 -2
- package/src/internal/machine/commandRuntime.ts +2 -7
- package/src/internal/machine/configuration.ts +38 -13
- package/src/internal/machine/executionPlan.ts +85 -52
- package/src/internal/machine/initialization.ts +73 -0
- package/src/internal/machine/inspectionRuntime.ts +102 -0
- package/src/internal/machine/invocation.ts +38 -13
- package/src/internal/machine/machine.ts +31 -6
- package/src/internal/machine/planner.ts +166 -66
- package/src/internal/machine/process.ts +7 -5
- package/src/internal/machine/runtime.ts +663 -91
- package/src/internal/machine/symbols.ts +3 -0
- package/src/internal/machine/topology.ts +27 -0
- package/src/internal/testing/machine/finiteModel.ts +8 -7
- package/src/unstable/reactivity/AtomMachine.ts +12 -0
package/src/Machine.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type * as Cause from "effect/Cause"
|
|
8
8
|
import type * as Duration from "effect/Duration"
|
|
9
9
|
import type * as Effect from "effect/Effect"
|
|
10
|
+
import type * as Exit from "effect/Exit"
|
|
10
11
|
import type * as Option from "effect/Option"
|
|
11
12
|
import type { Pipeable } from "effect/Pipeable"
|
|
12
13
|
import { hasProperty } from "effect/Predicate"
|
|
@@ -175,18 +176,18 @@ export interface Machine<
|
|
|
175
176
|
>
|
|
176
177
|
|
|
177
178
|
/**
|
|
178
|
-
* Ephemeral outward notifications published to this
|
|
179
|
-
* Emissions are never delivered implicitly to an owning
|
|
179
|
+
* Ephemeral outward notifications published to this machine's observers.
|
|
180
|
+
* Emissions are never delivered implicitly to an owning machine.
|
|
180
181
|
*
|
|
181
182
|
* @since 0.4.0
|
|
182
183
|
*/
|
|
183
184
|
readonly emittedEvents: Machine.EventProtocol<"emitted", Emits>
|
|
184
185
|
|
|
185
186
|
/**
|
|
186
|
-
* Public input events accepted by an owning
|
|
187
|
+
* Public input events accepted by an owning machine when this machine is
|
|
187
188
|
* running as a child.
|
|
188
189
|
*
|
|
189
|
-
* The protocol types the optional `parent`
|
|
190
|
+
* The protocol types the optional `parent` machine target exposed to
|
|
190
191
|
* handlers and is checked against a concrete parent's public events at
|
|
191
192
|
* composition boundaries.
|
|
192
193
|
*
|
|
@@ -387,7 +388,7 @@ export interface Runtime<in Events, in Emits> {
|
|
|
387
388
|
readonly raise: (event: Machine.EventInput<Events>) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>
|
|
388
389
|
|
|
389
390
|
/**
|
|
390
|
-
* Publishes an ephemeral notification to the running
|
|
391
|
+
* Publishes an ephemeral notification to the running machine's observers.
|
|
391
392
|
*
|
|
392
393
|
* @since 0.4.0
|
|
393
394
|
*/
|
|
@@ -397,37 +398,37 @@ export interface Runtime<in Events, in Emits> {
|
|
|
397
398
|
}
|
|
398
399
|
|
|
399
400
|
/**
|
|
400
|
-
* Minimal typed
|
|
401
|
+
* Minimal typed target accepted by inter-machine send commands.
|
|
401
402
|
*
|
|
402
403
|
* @category models
|
|
403
|
-
* @since 0.
|
|
404
|
+
* @since 0.12.0
|
|
404
405
|
*/
|
|
405
|
-
export interface
|
|
406
|
+
export interface MachineTarget<in Event> {
|
|
406
407
|
readonly id: string
|
|
407
408
|
readonly sessionId: string
|
|
408
409
|
readonly send: (event: Event) => Effect.Effect<void, StoppedError>
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
/**
|
|
412
|
-
*
|
|
413
|
+
* Machine targets available while evaluating machine behavior.
|
|
413
414
|
*
|
|
414
415
|
* @category models
|
|
415
|
-
* @since 0.
|
|
416
|
+
* @since 0.12.0
|
|
416
417
|
*/
|
|
417
|
-
export interface
|
|
418
|
+
export interface MachineReferences<
|
|
418
419
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
419
420
|
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>
|
|
420
421
|
> {
|
|
421
|
-
/**
|
|
422
|
-
readonly self:
|
|
422
|
+
/** Target for the current machine. Sending queues a later mailbox event. */
|
|
423
|
+
readonly self: MachineTarget<Machine.EventInputOf<InputEvents>>
|
|
423
424
|
|
|
424
|
-
/**
|
|
425
|
-
readonly parent:
|
|
425
|
+
/** Target for the owning machine, or `undefined` when running as a root. */
|
|
426
|
+
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>> | undefined
|
|
426
427
|
}
|
|
427
428
|
|
|
428
429
|
/**
|
|
429
430
|
* Synchronous commands available while a machine transition is being
|
|
430
|
-
* selected. Enqueuing only records statechart and
|
|
431
|
+
* selected. Enqueuing only records statechart and machine operations; it never
|
|
431
432
|
* executes an Effect.
|
|
432
433
|
*
|
|
433
434
|
* @category models
|
|
@@ -437,12 +438,12 @@ export interface Enqueue<in Events, in Emits> {
|
|
|
437
438
|
/** Raises an event inside the current macrostep. */
|
|
438
439
|
readonly raise: (event: Machine.EventInput<Events>) => void
|
|
439
440
|
|
|
440
|
-
/** Publishes an ephemeral notification to this
|
|
441
|
+
/** Publishes an ephemeral notification to this machine's observers. */
|
|
441
442
|
readonly emit: (event: Machine.EmittedEventInput<Emits>) => void
|
|
442
443
|
|
|
443
444
|
/** Sends an event to an invoked child after the transition is selected. */
|
|
444
445
|
readonly sendTo: {
|
|
445
|
-
<Event>(target:
|
|
446
|
+
<Event>(target: MachineTarget<Event>, event: Event): void
|
|
446
447
|
<Child extends ChildMachine.Any>(child: Child, event: ChildMachine.Event<Child>): void
|
|
447
448
|
<Address extends ChildAddress<never>>(child: Address, event: ChildAddress.Event<Address>): void
|
|
448
449
|
}
|
|
@@ -455,7 +456,7 @@ export interface Enqueue<in Events, in Emits> {
|
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
/**
|
|
458
|
-
* A closed
|
|
459
|
+
* A closed machine command recorded by a synchronous transition.
|
|
459
460
|
*
|
|
460
461
|
* @category models
|
|
461
462
|
* @since 0.4.0
|
|
@@ -463,7 +464,7 @@ export interface Enqueue<in Events, in Emits> {
|
|
|
463
464
|
export type Command =
|
|
464
465
|
| {
|
|
465
466
|
readonly _tag: "SendTo"
|
|
466
|
-
readonly target:
|
|
467
|
+
readonly target: MachineTarget<unknown> | ChildMachine.Any | ChildAddress<never>
|
|
467
468
|
readonly event: unknown
|
|
468
469
|
}
|
|
469
470
|
| {
|
|
@@ -840,6 +841,42 @@ type NodeMethod<
|
|
|
840
841
|
> = Machine.NodeSchema<Node> extends never ? FromMethod<FromArguments, Result>
|
|
841
842
|
: ((...args: Arguments) => Result) & FromMethod<FromArguments, Result>
|
|
842
843
|
|
|
844
|
+
type NodeMethodWithInitial<
|
|
845
|
+
Node,
|
|
846
|
+
Arguments extends ReadonlyArray<unknown>,
|
|
847
|
+
Result,
|
|
848
|
+
FromArguments extends ReadonlyArray<unknown>,
|
|
849
|
+
Path extends string
|
|
850
|
+
> = Machine.NodeSchema<Node> extends never ? {
|
|
851
|
+
readonly from: FromCallable<FromArguments, Machine.StateConstruction<Result>>
|
|
852
|
+
readonly initial: InitialTargetFactory<Node, Path>
|
|
853
|
+
}
|
|
854
|
+
:
|
|
855
|
+
& ((...args: Arguments) => Result)
|
|
856
|
+
& {
|
|
857
|
+
readonly from: FromCallable<FromArguments, Machine.StateConstruction<Result>>
|
|
858
|
+
readonly initial: InitialTargetFactory<Node, Path>
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
interface InitialTargetMethod<
|
|
862
|
+
Node,
|
|
863
|
+
Path extends string
|
|
864
|
+
> {
|
|
865
|
+
/** Enters this state through its declared initial configuration. */
|
|
866
|
+
readonly initial: InitialTargetFactory<Node, Path>
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
interface InitialTargetFactory<
|
|
870
|
+
Node,
|
|
871
|
+
Path extends string
|
|
872
|
+
> {
|
|
873
|
+
(...args: WithNodeValue<Node, readonly []>): Machine.InitialTarget<Path>
|
|
874
|
+
readonly from: FromCallable<
|
|
875
|
+
WithNodeInput<Node, readonly []>,
|
|
876
|
+
Machine.StateConstruction<Machine.InitialTarget<Path>>
|
|
877
|
+
>
|
|
878
|
+
}
|
|
879
|
+
|
|
843
880
|
type NodeConstructionSelectorFromCallable<Node, Builder, Result> = Machine.NodeSchema<Node> extends never ? {
|
|
844
881
|
<Selected extends ConstructionResult<Result>>(
|
|
845
882
|
state: (builder: Builder) => Selected
|
|
@@ -847,15 +884,19 @@ type NodeConstructionSelectorFromCallable<Node, Builder, Result> = Machine.NodeS
|
|
|
847
884
|
}
|
|
848
885
|
: ConstructionSelectorFromCallable<NodeMakeInput<Node>, Builder, Result>
|
|
849
886
|
|
|
850
|
-
type NestedTargetMethod<Node, Builder, Result> = Machine.NodeSchema<Node> extends never ? {
|
|
887
|
+
type NestedTargetMethod<Node, Builder, Result, Path extends string> = Machine.NodeSchema<Node> extends never ? {
|
|
851
888
|
readonly from: NodeConstructionSelectorFromCallable<Node, Builder, Result>
|
|
889
|
+
readonly initial: InitialTargetFactory<Node, Path>
|
|
852
890
|
}
|
|
853
891
|
:
|
|
854
892
|
& (<Selected extends ConstructionResult<Result>>(
|
|
855
893
|
value: NodeValue<Node>,
|
|
856
894
|
state: (builder: Builder) => Selected
|
|
857
895
|
) => Selected)
|
|
858
|
-
& {
|
|
896
|
+
& {
|
|
897
|
+
readonly from: NodeConstructionSelectorFromCallable<Node, Builder, Result>
|
|
898
|
+
readonly initial: InitialTargetFactory<Node, Path>
|
|
899
|
+
}
|
|
859
900
|
|
|
860
901
|
type ConstructionSelectorFromCallable<Input, Builder, Result> = {} extends Input ? {
|
|
861
902
|
<Selected extends ConstructionResult<Result>>(
|
|
@@ -1093,6 +1134,14 @@ type FullSnapshotResult<
|
|
|
1093
1134
|
Path extends string = Machine.JoinPath<Prefix, StateId>
|
|
1094
1135
|
> = Machine.SnapshotByIdentifierWithPath<States, StateId, Path>
|
|
1095
1136
|
|
|
1137
|
+
type InitialEntryStateKey<States extends Machine.StateSchemas> = {
|
|
1138
|
+
readonly [Key in ActiveStateKey<States>]: States[Key] extends { readonly states: Machine.StateSchemas } ? Key : never
|
|
1139
|
+
}[ActiveStateKey<States>]
|
|
1140
|
+
|
|
1141
|
+
type FullInitialTargetBuilder<States extends Machine.StateSchemas> = {
|
|
1142
|
+
readonly [Key in InitialEntryStateKey<States>]: InitialTargetMethod<States[Key], Key>
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1096
1145
|
type FullParallelBuilder<
|
|
1097
1146
|
States extends Machine.StateSchemas,
|
|
1098
1147
|
Prefix extends string,
|
|
@@ -1383,9 +1432,10 @@ type LocalTargetMethod<
|
|
|
1383
1432
|
Source extends Path | `${Path}.${string}` ? NestedTargetMethod<
|
|
1384
1433
|
Node,
|
|
1385
1434
|
LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>,
|
|
1386
|
-
LocalTargetResultWithPrefix<AllStates, Children, Path
|
|
1435
|
+
LocalTargetResultWithPrefix<AllStates, Children, Path>,
|
|
1436
|
+
Path
|
|
1387
1437
|
>
|
|
1388
|
-
:
|
|
1438
|
+
: NodeMethodWithInitial<
|
|
1389
1439
|
Node,
|
|
1390
1440
|
WithNodeValue<Node, [
|
|
1391
1441
|
states: (
|
|
@@ -1397,12 +1447,14 @@ type LocalTargetMethod<
|
|
|
1397
1447
|
states: (
|
|
1398
1448
|
builder: FullParallelBuilder<Children, Path>
|
|
1399
1449
|
) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>, boolean>
|
|
1400
|
-
]
|
|
1450
|
+
]>,
|
|
1451
|
+
Path
|
|
1401
1452
|
>
|
|
1402
1453
|
: Node extends { readonly states: infer Children extends Machine.StateSchemas } ? NestedTargetMethod<
|
|
1403
1454
|
Node,
|
|
1404
1455
|
LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>,
|
|
1405
|
-
LocalTargetResultWithPrefix<AllStates, Children, Path
|
|
1456
|
+
LocalTargetResultWithPrefix<AllStates, Children, Path>,
|
|
1457
|
+
Path
|
|
1406
1458
|
>
|
|
1407
1459
|
: NodeMethod<
|
|
1408
1460
|
Node,
|
|
@@ -1497,10 +1549,11 @@ type BranchTargetMethod<
|
|
|
1497
1549
|
& NestedTargetMethod<
|
|
1498
1550
|
Node,
|
|
1499
1551
|
BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>,
|
|
1500
|
-
BranchTargetResultWithPrefix<AllStates, Children, Path
|
|
1552
|
+
BranchTargetResultWithPrefix<AllStates, Children, Path>,
|
|
1553
|
+
Path
|
|
1501
1554
|
>
|
|
1502
1555
|
& BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>
|
|
1503
|
-
:
|
|
1556
|
+
: NodeMethodWithInitial<
|
|
1504
1557
|
Node,
|
|
1505
1558
|
WithNodeValue<Node, [
|
|
1506
1559
|
states: (
|
|
@@ -1512,13 +1565,15 @@ type BranchTargetMethod<
|
|
|
1512
1565
|
states: (
|
|
1513
1566
|
builder: FullParallelBuilder<Children, Path>
|
|
1514
1567
|
) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>, boolean>
|
|
1515
|
-
]
|
|
1568
|
+
]>,
|
|
1569
|
+
Path
|
|
1516
1570
|
>
|
|
1517
1571
|
: Node extends { readonly states: infer Children extends Machine.StateSchemas } ?
|
|
1518
1572
|
& NestedTargetMethod<
|
|
1519
1573
|
Node,
|
|
1520
1574
|
BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>,
|
|
1521
|
-
BranchTargetResultWithPrefix<AllStates, Children, Path
|
|
1575
|
+
BranchTargetResultWithPrefix<AllStates, Children, Path>,
|
|
1576
|
+
Path
|
|
1522
1577
|
>
|
|
1523
1578
|
& BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>
|
|
1524
1579
|
: NodeMethod<
|
|
@@ -1664,6 +1719,187 @@ export type RuntimeSnapshot<State, Error = never, Output = never> =
|
|
|
1664
1719
|
readonly state: State
|
|
1665
1720
|
}
|
|
1666
1721
|
|
|
1722
|
+
/**
|
|
1723
|
+
* Live, root-scoped records describing one prepared machine tree.
|
|
1724
|
+
*
|
|
1725
|
+
* Inspection records deliberately erase machine-specific values to `unknown`:
|
|
1726
|
+
* one stream may contain unrelated root, child-machine, and `Logic` protocols.
|
|
1727
|
+
* The record structure remains a closed discriminated union, while typed
|
|
1728
|
+
* application observation continues through `changes` and `emissions`.
|
|
1729
|
+
*
|
|
1730
|
+
* @category models
|
|
1731
|
+
* @since 0.13.0
|
|
1732
|
+
*/
|
|
1733
|
+
export declare namespace Inspection {
|
|
1734
|
+
/** Read-only identity of a local machine endpoint. */
|
|
1735
|
+
export interface Endpoint {
|
|
1736
|
+
readonly id: string
|
|
1737
|
+
readonly sessionId: string
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
/** Read-only identity of a runtime represented in the inspection tree. */
|
|
1741
|
+
export interface Subject extends Endpoint {
|
|
1742
|
+
readonly kind: "Machine" | "Logic"
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/** Causal origin of an inspected runtime. */
|
|
1746
|
+
export type Origin =
|
|
1747
|
+
| { readonly _tag: "Root" }
|
|
1748
|
+
| {
|
|
1749
|
+
readonly _tag: "Invoke"
|
|
1750
|
+
readonly ownerPath: string
|
|
1751
|
+
readonly invokeId: string
|
|
1752
|
+
}
|
|
1753
|
+
| {
|
|
1754
|
+
readonly _tag: "Spawn"
|
|
1755
|
+
readonly address: string | undefined
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/** Causal owner of a send or emission. */
|
|
1759
|
+
export type Causation =
|
|
1760
|
+
| { readonly _tag: "Initialization" }
|
|
1761
|
+
| { readonly _tag: "Macrostep"; readonly macrostepId: number }
|
|
1762
|
+
| { readonly _tag: "Activity"; readonly activitySessionId: string }
|
|
1763
|
+
|
|
1764
|
+
/** Closed command projection safe for observation. */
|
|
1765
|
+
export type Command =
|
|
1766
|
+
| {
|
|
1767
|
+
readonly _tag: "SendTo"
|
|
1768
|
+
readonly target: Endpoint | { readonly id: string }
|
|
1769
|
+
readonly event: unknown
|
|
1770
|
+
}
|
|
1771
|
+
| {
|
|
1772
|
+
readonly _tag: "Stop"
|
|
1773
|
+
readonly target: Endpoint | { readonly id: string }
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/** One statechart microstep in a committed macrostep. */
|
|
1777
|
+
export interface Microstep {
|
|
1778
|
+
readonly event: unknown
|
|
1779
|
+
readonly transitions: ReadonlyArray<Machine.RetainedTransition>
|
|
1780
|
+
readonly raisedEvents: ReadonlyArray<unknown>
|
|
1781
|
+
readonly emittedEvents: ReadonlyArray<unknown>
|
|
1782
|
+
readonly commands: ReadonlyArray<Command>
|
|
1783
|
+
readonly exitPaths: ReadonlyArray<string>
|
|
1784
|
+
readonly entryPaths: ReadonlyArray<string>
|
|
1785
|
+
readonly changed: boolean
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** Common ordering and identity fields for every record. */
|
|
1789
|
+
export interface Base {
|
|
1790
|
+
/** Total publication order within this prepared root. */
|
|
1791
|
+
readonly sequence: number
|
|
1792
|
+
/** Session id of the prepared root that owns this inspection stream. */
|
|
1793
|
+
readonly rootSessionId: string
|
|
1794
|
+
/** Runtime instance described by this record. */
|
|
1795
|
+
readonly subject: Subject
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
/** Announces allocation of a root or owned process identity. */
|
|
1799
|
+
export interface Created extends Base {
|
|
1800
|
+
readonly _tag: "Created"
|
|
1801
|
+
readonly parent: Subject | undefined
|
|
1802
|
+
readonly origin: Origin
|
|
1803
|
+
/** Compiled statechart definition; absent for generic `Logic`. */
|
|
1804
|
+
readonly definition: Machine.Any | undefined
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
/** Announces successful initialization. */
|
|
1808
|
+
export interface Initialized extends Base {
|
|
1809
|
+
readonly _tag: "Initialized"
|
|
1810
|
+
readonly snapshot: RuntimeSnapshot<unknown, unknown, unknown>
|
|
1811
|
+
readonly initialEntryPaths: ReadonlyArray<string>
|
|
1812
|
+
readonly microsteps: ReadonlyArray<Microstep>
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
/** Announces failure before an initial runtime snapshot exists. */
|
|
1816
|
+
export interface StartFailed extends Base {
|
|
1817
|
+
readonly _tag: "StartFailed"
|
|
1818
|
+
readonly cause: Cause.Cause<unknown>
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/** Announces acceptance of an event by a local mailbox. */
|
|
1822
|
+
export interface EventSent extends Base {
|
|
1823
|
+
readonly _tag: "EventSent"
|
|
1824
|
+
readonly deliveryId: number
|
|
1825
|
+
readonly source: Subject | undefined
|
|
1826
|
+
readonly target: Endpoint
|
|
1827
|
+
readonly event: unknown
|
|
1828
|
+
readonly causedBy: Causation | undefined
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
/** Announces complete processing of one statechart mailbox event. */
|
|
1832
|
+
export interface EventProcessed extends Base {
|
|
1833
|
+
readonly _tag: "EventProcessed"
|
|
1834
|
+
readonly macrostepId: number
|
|
1835
|
+
readonly deliveryId: number
|
|
1836
|
+
readonly source: Subject | undefined
|
|
1837
|
+
readonly event: unknown
|
|
1838
|
+
readonly before: RuntimeSnapshot<unknown, unknown, unknown>
|
|
1839
|
+
readonly after: RuntimeSnapshot<unknown, unknown, unknown>
|
|
1840
|
+
readonly handled: boolean
|
|
1841
|
+
readonly configurationChanged: boolean
|
|
1842
|
+
readonly microsteps: ReadonlyArray<Microstep>
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
/** Announces a direct state update made by generic `Logic`. */
|
|
1846
|
+
export interface StateChanged extends Base {
|
|
1847
|
+
readonly _tag: "StateChanged"
|
|
1848
|
+
readonly before: unknown
|
|
1849
|
+
readonly after: unknown
|
|
1850
|
+
readonly causedByDeliveryId: number | undefined
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
/** Announces actual publication on a machine's domain emission stream. */
|
|
1854
|
+
export interface Emitted extends Base {
|
|
1855
|
+
readonly _tag: "Emitted"
|
|
1856
|
+
readonly emission: unknown
|
|
1857
|
+
readonly causedBy: Causation | undefined
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
/** Identity of one Effect or timer invocation run. */
|
|
1861
|
+
export interface Activity {
|
|
1862
|
+
readonly id: string
|
|
1863
|
+
readonly sessionId: string
|
|
1864
|
+
readonly owner: Subject
|
|
1865
|
+
readonly ownerPath: string
|
|
1866
|
+
readonly kind: "Effect" | "Timer"
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/** Announces an Effect or timer invocation starting. */
|
|
1870
|
+
export interface ActivityStarted extends Base {
|
|
1871
|
+
readonly _tag: "ActivityStarted"
|
|
1872
|
+
readonly activity: Activity
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/** Announces an Effect or timer invocation outcome. */
|
|
1876
|
+
export interface ActivityStopped extends Base {
|
|
1877
|
+
readonly _tag: "ActivityStopped"
|
|
1878
|
+
readonly activity: Activity
|
|
1879
|
+
/** Success or failure from the invoke; interruption means its owner stopped it. */
|
|
1880
|
+
readonly exit: Exit.Exit<unknown, unknown>
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
/** Announces a terminal local runtime snapshot. */
|
|
1884
|
+
export interface Terminated extends Base {
|
|
1885
|
+
readonly _tag: "Terminated"
|
|
1886
|
+
readonly snapshot: RuntimeSnapshot<unknown, unknown, unknown>
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
/** Complete live inspection protocol. */
|
|
1890
|
+
export type Event =
|
|
1891
|
+
| Created
|
|
1892
|
+
| Initialized
|
|
1893
|
+
| StartFailed
|
|
1894
|
+
| EventSent
|
|
1895
|
+
| EventProcessed
|
|
1896
|
+
| StateChanged
|
|
1897
|
+
| Emitted
|
|
1898
|
+
| ActivityStarted
|
|
1899
|
+
| ActivityStopped
|
|
1900
|
+
| Terminated
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1667
1903
|
/**
|
|
1668
1904
|
* Represents a classified terminal outcome derived from a runtime snapshot.
|
|
1669
1905
|
*
|
|
@@ -1726,6 +1962,14 @@ export interface Prepared<out State, in Event, out Error, out Output, out Emitte
|
|
|
1726
1962
|
/** Streams ephemeral notifications published after subscription. */
|
|
1727
1963
|
readonly emissions: Stream.Stream<Emitted>
|
|
1728
1964
|
|
|
1965
|
+
/**
|
|
1966
|
+
* Streams ordered operational records for this root and every locally owned
|
|
1967
|
+
* descendant. The stream is hot, non-replayed, never fails, and completes
|
|
1968
|
+
* after the prepared root terminates. Subscribe before evaluating `start` to
|
|
1969
|
+
* observe initialization.
|
|
1970
|
+
*/
|
|
1971
|
+
readonly inspection: Stream.Stream<Inspection.Event>
|
|
1972
|
+
|
|
1729
1973
|
/** Initializes this machine once and returns its running reference. */
|
|
1730
1974
|
readonly start: Effect.Effect<MachineRef<State, Event, Error, Output, Emitted>, StartError, StartRequirements>
|
|
1731
1975
|
}
|
|
@@ -1745,7 +1989,7 @@ export interface Prepared<out State, in Event, out Error, out Output, out Emitte
|
|
|
1745
1989
|
* @since 0.4.0
|
|
1746
1990
|
*/
|
|
1747
1991
|
export interface MachineRef<out State, in Event, out Error = never, out Output = never, out Emitted = never>
|
|
1748
|
-
extends
|
|
1992
|
+
extends MachineTarget<Event>
|
|
1749
1993
|
{
|
|
1750
1994
|
/** Stable machine definition id, or a generated fallback when none was declared. */
|
|
1751
1995
|
readonly id: string
|
|
@@ -1764,7 +2008,7 @@ export interface MachineRef<out State, in Event, out Error = never, out Output =
|
|
|
1764
2008
|
|
|
1765
2009
|
/**
|
|
1766
2010
|
* Streams ephemeral notifications published after subscription. Emissions
|
|
1767
|
-
* are not retained or replayed; the stream completes when the
|
|
2011
|
+
* are not retained or replayed; the stream completes when the machine stops.
|
|
1768
2012
|
*/
|
|
1769
2013
|
readonly emissions: Stream.Stream<Emitted>
|
|
1770
2014
|
|
|
@@ -1892,9 +2136,9 @@ export declare namespace Logic {
|
|
|
1892
2136
|
/** Starts a child process owned by this scope. */
|
|
1893
2137
|
readonly spawn: Spawn
|
|
1894
2138
|
|
|
1895
|
-
/** Sends an event to
|
|
2139
|
+
/** Sends an event to a machine target or typed parent-local child address. */
|
|
1896
2140
|
readonly sendTo: {
|
|
1897
|
-
<TargetEvent>(target:
|
|
2141
|
+
<TargetEvent>(target: MachineTarget<TargetEvent>, event: TargetEvent): Effect.Effect<void, StoppedError>
|
|
1898
2142
|
<Address extends ChildAddress<never>>(
|
|
1899
2143
|
id: Address,
|
|
1900
2144
|
event: ChildAddress.Event<Address>
|
|
@@ -2276,7 +2520,7 @@ export declare namespace Machine {
|
|
|
2276
2520
|
*/
|
|
2277
2521
|
export type InputEvents<M extends Any> = M[typeof MachineTypeId]["inputEvents"]
|
|
2278
2522
|
|
|
2279
|
-
/** Extracts the public input protocol required from an owning
|
|
2523
|
+
/** Extracts the public input protocol required from an owning machine. */
|
|
2280
2524
|
export type ParentEvents<M extends Any> = M[typeof MachineTypeId]["parentEvents"]
|
|
2281
2525
|
|
|
2282
2526
|
/** Extracts an internal event schema tuple from the complete and public protocols. */
|
|
@@ -3843,6 +4087,23 @@ export declare namespace Machine {
|
|
|
3843
4087
|
readonly parent: Extract<ParentPath<HistoryId>, StateIdentifier<States>>
|
|
3844
4088
|
}
|
|
3845
4089
|
|
|
4090
|
+
/**
|
|
4091
|
+
* Transition instruction that enters a compound or parallel state through
|
|
4092
|
+
* its declared initial configuration.
|
|
4093
|
+
*
|
|
4094
|
+
* @category models
|
|
4095
|
+
* @since 0.13.0
|
|
4096
|
+
*/
|
|
4097
|
+
export interface InitialTarget<StateId extends string> {
|
|
4098
|
+
readonly [Topology.TargetTypeId]: typeof Topology.TargetTypeId
|
|
4099
|
+
readonly [Topology.TargetSnapshotTypeId]?: never
|
|
4100
|
+
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId
|
|
4101
|
+
readonly _tag: "InitialTarget"
|
|
4102
|
+
readonly path: StateId
|
|
4103
|
+
readonly value: never
|
|
4104
|
+
readonly values?: never
|
|
4105
|
+
}
|
|
4106
|
+
|
|
3846
4107
|
/** Branded transient target instruction used while constructing initial states. */
|
|
3847
4108
|
export interface ChoiceTargetInstruction<ChoiceId extends string = string> {
|
|
3848
4109
|
readonly [Topology.ChoiceTargetTypeId]: typeof Topology.ChoiceTargetTypeId
|
|
@@ -3873,7 +4134,9 @@ export declare namespace Machine {
|
|
|
3873
4134
|
* @category utility types
|
|
3874
4135
|
* @since 0.4.0
|
|
3875
4136
|
*/
|
|
3876
|
-
export type FullTargetBuilder<States extends StateSchemas> =
|
|
4137
|
+
export type FullTargetBuilder<States extends StateSchemas> = [InitialEntryStateKey<States>] extends [never] ?
|
|
4138
|
+
FullSnapshotBuilderWithPrefix<States>
|
|
4139
|
+
: FullSnapshotBuilderWithPrefix<States> & FullInitialTargetBuilder<States>
|
|
3877
4140
|
|
|
3878
4141
|
/**
|
|
3879
4142
|
* Builder for a complete fallback configuration containing a history owner.
|
|
@@ -4011,7 +4274,7 @@ export declare namespace Machine {
|
|
|
4011
4274
|
R,
|
|
4012
4275
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4013
4276
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4014
|
-
> extends
|
|
4277
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4015
4278
|
readonly state: StateByIdentifier<States, StateId>
|
|
4016
4279
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4017
4280
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4041,7 +4304,7 @@ export declare namespace Machine {
|
|
|
4041
4304
|
StateId extends StateIdentifier<States>,
|
|
4042
4305
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4043
4306
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4044
|
-
> extends
|
|
4307
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4045
4308
|
readonly state: StateByIdentifier<States, StateId>
|
|
4046
4309
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4047
4310
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4061,7 +4324,7 @@ export declare namespace Machine {
|
|
|
4061
4324
|
StateId extends StateIdentifier<States>,
|
|
4062
4325
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4063
4326
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4064
|
-
> extends
|
|
4327
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4065
4328
|
readonly state: StateByIdentifier<States, StateId>
|
|
4066
4329
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4067
4330
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4084,7 +4347,7 @@ export declare namespace Machine {
|
|
|
4084
4347
|
Output,
|
|
4085
4348
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4086
4349
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4087
|
-
> extends
|
|
4350
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4088
4351
|
readonly id: string
|
|
4089
4352
|
readonly state: StateByIdentifier<States, StateId>
|
|
4090
4353
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4107,7 +4370,7 @@ export declare namespace Machine {
|
|
|
4107
4370
|
Output,
|
|
4108
4371
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4109
4372
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4110
|
-
> extends
|
|
4373
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4111
4374
|
readonly id: string
|
|
4112
4375
|
readonly state: StateByIdentifier<States, StateId>
|
|
4113
4376
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4126,7 +4389,7 @@ export declare namespace Machine {
|
|
|
4126
4389
|
Error,
|
|
4127
4390
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4128
4391
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4129
|
-
> extends
|
|
4392
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4130
4393
|
readonly id: string
|
|
4131
4394
|
readonly state: StateByIdentifier<States, StateId>
|
|
4132
4395
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4149,7 +4412,7 @@ export declare namespace Machine {
|
|
|
4149
4412
|
StateId extends StateIdentifier<States>,
|
|
4150
4413
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4151
4414
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4152
|
-
> extends
|
|
4415
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4153
4416
|
readonly state: StateByIdentifier<States, StateId>
|
|
4154
4417
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4155
4418
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4180,7 +4443,7 @@ export declare namespace Machine {
|
|
|
4180
4443
|
StateId extends StateIdentifier<States>,
|
|
4181
4444
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4182
4445
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4183
|
-
> extends
|
|
4446
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4184
4447
|
readonly state: StateByIdentifier<States, StateId>
|
|
4185
4448
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4186
4449
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4207,7 +4470,7 @@ export declare namespace Machine {
|
|
|
4207
4470
|
ChoiceId extends ChoiceIdentifier<States>,
|
|
4208
4471
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4209
4472
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4210
|
-
> extends
|
|
4473
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4211
4474
|
readonly containingState: StateByIdentifier<
|
|
4212
4475
|
States,
|
|
4213
4476
|
Extract<ImmediateParentStateIdentifier<ChoiceId>, StateIdentifier<States>>
|
|
@@ -4376,8 +4639,8 @@ export declare namespace Machine {
|
|
|
4376
4639
|
? NonNullable<Config[Key]> extends (...args: any) => infer Ret ? Ret : never
|
|
4377
4640
|
: never
|
|
4378
4641
|
/** Extracts the return value from an implicit initial child implementation. */
|
|
4379
|
-
export type
|
|
4380
|
-
? NonNullable<
|
|
4642
|
+
export type StateInitializeReturn<Config> = Config extends { readonly initialize?: infer Initialize }
|
|
4643
|
+
? NonNullable<Initialize> extends (...args: any) => infer Ret ? Ret : never
|
|
4381
4644
|
: never
|
|
4382
4645
|
/** Extracts the return values from a state's history defaults. */
|
|
4383
4646
|
export type HistoryDefaultReturn<Config> = Config extends { readonly history?: infer History } ? {
|
|
@@ -4434,6 +4697,8 @@ export declare namespace Machine {
|
|
|
4434
4697
|
*/
|
|
4435
4698
|
export type InvokeResolvedSource<Source> = Source extends (...args: any) => infer Resolved ? Resolved : Source
|
|
4436
4699
|
|
|
4700
|
+
type InvokeFactoryResult<Source> = Source extends (...args: any) => infer Resolved ? Resolved : never
|
|
4701
|
+
|
|
4437
4702
|
type ChildMachineLogic<Child> = Child extends ChildMachine<string, infer M> ? Logic<
|
|
4438
4703
|
Snapshot<States<M>>,
|
|
4439
4704
|
EventInput<InputEvent<M>>,
|
|
@@ -4455,7 +4720,7 @@ export declare namespace Machine {
|
|
|
4455
4720
|
: never
|
|
4456
4721
|
|
|
4457
4722
|
export type InvokeLogic<Invoke> = Invoke extends { readonly effect: infer Source } ?
|
|
4458
|
-
|
|
4723
|
+
InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ? Logic<
|
|
4459
4724
|
void,
|
|
4460
4725
|
never,
|
|
4461
4726
|
Effect.Error<Fx>,
|
|
@@ -4600,7 +4865,6 @@ export declare namespace Machine {
|
|
|
4600
4865
|
| Effect.Services<DoneReturn<Config>>
|
|
4601
4866
|
| Effect.Services<StateActionReturn<Config, "entry">>
|
|
4602
4867
|
| Effect.Services<StateActionReturn<Config, "exit">>
|
|
4603
|
-
| Effect.Services<StateInitialReturn<Config>>
|
|
4604
4868
|
| Effect.Services<HistoryDefaultReturn<Config>>
|
|
4605
4869
|
| Effect.Services<ChoiceReturn<Config>>
|
|
4606
4870
|
| InvokeRequirements<Config>
|
|
@@ -4611,12 +4875,12 @@ export declare namespace Machine {
|
|
|
4611
4875
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4612
4876
|
Context
|
|
4613
4877
|
> =
|
|
4614
|
-
| ((context: Context
|
|
4878
|
+
| ((context: NoInfer<Context>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>)
|
|
4615
4879
|
| {
|
|
4616
4880
|
readonly reenter?: boolean
|
|
4617
4881
|
readonly targets?: ReadonlyArray<StateNodeIdentifier<States>>
|
|
4618
4882
|
readonly transition: (
|
|
4619
|
-
context: Context
|
|
4883
|
+
context: NoInfer<Context>,
|
|
4620
4884
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
4621
4885
|
) => HandlerResult<States, any, any>
|
|
4622
4886
|
}
|
|
@@ -4662,10 +4926,9 @@ export declare namespace Machine {
|
|
|
4662
4926
|
& (
|
|
4663
4927
|
| {
|
|
4664
4928
|
readonly id: string
|
|
4665
|
-
readonly effect:
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
>
|
|
4929
|
+
readonly effect: (
|
|
4930
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
4931
|
+
) => Effect.Effect<any, any, any>
|
|
4669
4932
|
readonly after?: never
|
|
4670
4933
|
readonly logic?: never
|
|
4671
4934
|
readonly child?: never
|
|
@@ -4749,60 +5012,6 @@ export declare namespace Machine {
|
|
|
4749
5012
|
: { readonly onFailure?: never }
|
|
4750
5013
|
: never
|
|
4751
5014
|
|
|
4752
|
-
export type EffectInvokeArgs<
|
|
4753
|
-
States extends StateSchemas,
|
|
4754
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
4755
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4756
|
-
StateId extends StateIdentifier<States>,
|
|
4757
|
-
Fx extends Effect.Effect<any, any, any>,
|
|
4758
|
-
Source = Fx,
|
|
4759
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4760
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4761
|
-
> =
|
|
4762
|
-
& {
|
|
4763
|
-
readonly id: InvokeLifecycleId
|
|
4764
|
-
readonly effect: Source
|
|
4765
|
-
readonly after?: never
|
|
4766
|
-
readonly logic?: never
|
|
4767
|
-
readonly child?: never
|
|
4768
|
-
readonly address?: never
|
|
4769
|
-
readonly onSnapshot?: never
|
|
4770
|
-
}
|
|
4771
|
-
& InvokeDoneRequirement<
|
|
4772
|
-
Effect.Success<NoInfer<Fx>>,
|
|
4773
|
-
InvokeTransition<
|
|
4774
|
-
States,
|
|
4775
|
-
Events,
|
|
4776
|
-
Emits,
|
|
4777
|
-
InvokeDoneContext<
|
|
4778
|
-
States,
|
|
4779
|
-
Events,
|
|
4780
|
-
Emits,
|
|
4781
|
-
StateId,
|
|
4782
|
-
Effect.Success<NoInfer<Fx>>,
|
|
4783
|
-
InputEvents,
|
|
4784
|
-
ParentEvents
|
|
4785
|
-
>
|
|
4786
|
-
>
|
|
4787
|
-
>
|
|
4788
|
-
& InvokeFailureRequirement<
|
|
4789
|
-
Effect.Error<NoInfer<Fx>>,
|
|
4790
|
-
InvokeTransition<
|
|
4791
|
-
States,
|
|
4792
|
-
Events,
|
|
4793
|
-
Emits,
|
|
4794
|
-
InvokeFailureContext<
|
|
4795
|
-
States,
|
|
4796
|
-
Events,
|
|
4797
|
-
Emits,
|
|
4798
|
-
StateId,
|
|
4799
|
-
Effect.Error<NoInfer<Fx>>,
|
|
4800
|
-
InputEvents,
|
|
4801
|
-
ParentEvents
|
|
4802
|
-
>
|
|
4803
|
-
>
|
|
4804
|
-
>
|
|
4805
|
-
|
|
4806
5015
|
export type TimerInvokeArgs<
|
|
4807
5016
|
States extends StateSchemas,
|
|
4808
5017
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4988,7 +5197,7 @@ export declare namespace Machine {
|
|
|
4988
5197
|
Raw
|
|
4989
5198
|
> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown
|
|
4990
5199
|
: Raw extends { readonly effect: infer Source } ?
|
|
4991
|
-
|
|
5200
|
+
InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ?
|
|
4992
5201
|
& InvokeDoneRequirement<
|
|
4993
5202
|
Effect.Success<Fx>,
|
|
4994
5203
|
InvokeTransition<
|
|
@@ -5255,11 +5464,16 @@ export declare namespace Machine {
|
|
|
5255
5464
|
) => HandlerResult<States, any, any>
|
|
5256
5465
|
}
|
|
5257
5466
|
}
|
|
5258
|
-
readonly
|
|
5467
|
+
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5259
5468
|
} & ActiveOutputHandlerConfig<States, Events, StateId>
|
|
5260
5469
|
|
|
5261
|
-
/**
|
|
5262
|
-
|
|
5470
|
+
/**
|
|
5471
|
+
* Values constructed for a state's schema-valued direct initial children.
|
|
5472
|
+
*
|
|
5473
|
+
* @category utility types
|
|
5474
|
+
* @since 0.13.0
|
|
5475
|
+
*/
|
|
5476
|
+
export type StateInitializeValue<
|
|
5263
5477
|
States extends StateSchemas,
|
|
5264
5478
|
StateId extends StateIdentifier<States>
|
|
5265
5479
|
> = NodeByIdentifier<States, StateId> extends infer Node ?
|
|
@@ -5270,23 +5484,92 @@ export declare namespace Machine {
|
|
|
5270
5484
|
}
|
|
5271
5485
|
: Node extends { readonly states: infer Children extends StateSchemas; readonly initial: infer Initial } ?
|
|
5272
5486
|
Initial extends ActiveStateKey<Children> ? NodeSchema<Children[Initial]> extends never ? never
|
|
5273
|
-
: NodeValue<Children[Initial]>
|
|
5487
|
+
: { readonly [Key in Initial]: NodeValue<Children[Initial]> }
|
|
5274
5488
|
: never
|
|
5275
5489
|
: never
|
|
5276
5490
|
: never
|
|
5277
5491
|
|
|
5278
|
-
|
|
5279
|
-
|
|
5492
|
+
type StateInitializeCompoundBuilder<Node, Initial extends PropertyKey> = Node extends {
|
|
5493
|
+
readonly states: infer Children extends StateSchemas
|
|
5494
|
+
} ? Initial extends ActiveStateKey<Children> ? NodeSchema<Children[Initial]> extends never ? never
|
|
5495
|
+
: NodeBuilderMethod<
|
|
5496
|
+
Children[Initial],
|
|
5497
|
+
readonly [value: NodeValue<Children[Initial]>],
|
|
5498
|
+
SnapshotBuilderComplete<{ readonly [Key in Initial]: NodeValue<Children[Initial]> }>,
|
|
5499
|
+
readonly [input: NodeMakeInput<Children[Initial]>],
|
|
5500
|
+
SnapshotBuilderComplete<{ readonly [Key in Initial]: NodeValue<Children[Initial]> }, true>
|
|
5501
|
+
>
|
|
5502
|
+
: never
|
|
5503
|
+
: never
|
|
5504
|
+
|
|
5505
|
+
type StateInitializeParallelBuilder<
|
|
5506
|
+
Children extends StateSchemas,
|
|
5507
|
+
Remaining extends ActiveStateKey<Children> = {
|
|
5508
|
+
readonly [Key in ActiveStateKey<Children>]: NodeSchema<Children[Key]> extends never ? never : Key
|
|
5509
|
+
}[ActiveStateKey<Children>],
|
|
5510
|
+
Values = {},
|
|
5511
|
+
Constructed extends boolean = false
|
|
5512
|
+
> =
|
|
5513
|
+
& SnapshotBuilderComplete<Values, Constructed>
|
|
5514
|
+
& {
|
|
5515
|
+
readonly [Key in Remaining]: NodeBuilderMethod<
|
|
5516
|
+
Children[Key],
|
|
5517
|
+
readonly [value: NodeValue<Children[Key]>],
|
|
5518
|
+
StateInitializeParallelBuilder<
|
|
5519
|
+
Children,
|
|
5520
|
+
Exclude<Remaining, Key>,
|
|
5521
|
+
Values & { readonly [Region in Key]: NodeValue<Children[Key]> },
|
|
5522
|
+
Constructed
|
|
5523
|
+
>,
|
|
5524
|
+
readonly [input: NodeMakeInput<Children[Key]>],
|
|
5525
|
+
StateInitializeParallelBuilder<
|
|
5526
|
+
Children,
|
|
5527
|
+
Exclude<Remaining, Key>,
|
|
5528
|
+
Values & { readonly [Region in Key]: NodeValue<Children[Key]> },
|
|
5529
|
+
true
|
|
5530
|
+
>
|
|
5531
|
+
>
|
|
5532
|
+
}
|
|
5533
|
+
|
|
5534
|
+
/**
|
|
5535
|
+
* Builder bound to the direct initial child or regions owned by a state.
|
|
5536
|
+
*
|
|
5537
|
+
* @category utility types
|
|
5538
|
+
* @since 0.13.0
|
|
5539
|
+
*/
|
|
5540
|
+
export type StateInitializeBuilder<
|
|
5541
|
+
States extends StateSchemas,
|
|
5542
|
+
StateId extends StateIdentifier<States>,
|
|
5543
|
+
Node = NodeByIdentifier<States, StateId>
|
|
5544
|
+
> = Node extends { readonly type: "parallel"; readonly states: infer Children extends StateSchemas } ?
|
|
5545
|
+
StateInitializeParallelBuilder<Children>
|
|
5546
|
+
: Node extends { readonly initial: infer Initial } ? StateInitializeCompoundBuilder<Node, Initial & PropertyKey>
|
|
5547
|
+
: never
|
|
5548
|
+
|
|
5549
|
+
/**
|
|
5550
|
+
* Context passed to an implicit child-state initializer.
|
|
5551
|
+
*
|
|
5552
|
+
* @category models
|
|
5553
|
+
* @since 0.13.0
|
|
5554
|
+
*/
|
|
5555
|
+
export type StateInitializeContext<
|
|
5280
5556
|
States extends StateSchemas,
|
|
5281
5557
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5282
5558
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5283
5559
|
StateId extends StateIdentifier<States>,
|
|
5284
5560
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5285
5561
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5286
|
-
> = StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5562
|
+
> = StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
5563
|
+
readonly builder: StateInitializeBuilder<States, StateId>
|
|
5564
|
+
}
|
|
5287
5565
|
|
|
5288
|
-
/**
|
|
5289
|
-
|
|
5566
|
+
/**
|
|
5567
|
+
* Initial child value implementation for a compound or parallel state.
|
|
5568
|
+
*
|
|
5569
|
+
* @category models
|
|
5570
|
+
* @since 0.13.0
|
|
5571
|
+
*/
|
|
5572
|
+
export type StateInitializeHandler<
|
|
5290
5573
|
States extends StateSchemas,
|
|
5291
5574
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5292
5575
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -5294,9 +5577,9 @@ export declare namespace Machine {
|
|
|
5294
5577
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5295
5578
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5296
5579
|
> = (
|
|
5297
|
-
context:
|
|
5580
|
+
context: StateInitializeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
5298
5581
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5299
|
-
) =>
|
|
5582
|
+
) => SnapshotBuilderComplete<StateInitializeValue<States, StateId>, boolean>
|
|
5300
5583
|
|
|
5301
5584
|
/** Context used only when a history node has no previously captured record. */
|
|
5302
5585
|
export interface HistoryDefaultContext<
|
|
@@ -5366,7 +5649,7 @@ export declare namespace Machine {
|
|
|
5366
5649
|
readonly on?: never
|
|
5367
5650
|
readonly onDone?: never
|
|
5368
5651
|
readonly output?: never
|
|
5369
|
-
readonly
|
|
5652
|
+
readonly initialize?: never
|
|
5370
5653
|
}
|
|
5371
5654
|
|
|
5372
5655
|
/**
|
|
@@ -5589,7 +5872,7 @@ export declare namespace Machine {
|
|
|
5589
5872
|
| "entry"
|
|
5590
5873
|
| "exit"
|
|
5591
5874
|
| "history"
|
|
5592
|
-
| "
|
|
5875
|
+
| "initialize"
|
|
5593
5876
|
| "invoke"
|
|
5594
5877
|
| "on"
|
|
5595
5878
|
| "onDone"
|
|
@@ -5702,6 +5985,75 @@ export declare namespace Machine {
|
|
|
5702
5985
|
: Result extends { readonly path: infer Path extends string } ? Path
|
|
5703
5986
|
: never
|
|
5704
5987
|
|
|
5988
|
+
type TransitionResultInitialTargetPath<Result> = IsAny<Result> extends true ? never
|
|
5989
|
+
: Result extends Effect.Effect<infer Success, any, any> ? TransitionResultInitialTargetPath<Success>
|
|
5990
|
+
: Result extends StateConstruction<infer Constructed> ? TransitionResultInitialTargetPath<Constructed>
|
|
5991
|
+
: Result extends {
|
|
5992
|
+
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId
|
|
5993
|
+
readonly _tag: "InitialTarget"
|
|
5994
|
+
} ? Result extends { readonly path: infer Path extends string } ? Path : never
|
|
5995
|
+
: never
|
|
5996
|
+
|
|
5997
|
+
type HandlerConfigInitialTargetPath<Config> = TransitionResultInitialTargetPath<
|
|
5998
|
+
| EventHandlerReturn<Config>
|
|
5999
|
+
| AlwaysReturn<Config>
|
|
6000
|
+
| DoneReturn<Config>
|
|
6001
|
+
| ChoiceReturn<Config>
|
|
6002
|
+
| InvokeOutcomeReturn<InvokeReturn<Config>>
|
|
6003
|
+
>
|
|
6004
|
+
|
|
6005
|
+
type RequiredInitializersForTargetPath<
|
|
6006
|
+
AllStates extends StateSchemas,
|
|
6007
|
+
Path
|
|
6008
|
+
> = string extends Path ? never : Path extends StateIdentifier<AllStates> ? InitializerClosureForNode<
|
|
6009
|
+
AllStates,
|
|
6010
|
+
NodeByIdentifier<AllStates, Path>,
|
|
6011
|
+
Path
|
|
6012
|
+
>
|
|
6013
|
+
: never
|
|
6014
|
+
|
|
6015
|
+
type HandlerInitializeValidationAtPath<Config, Path extends string> = HandlerConfigAtPath<Config, Path> extends
|
|
6016
|
+
infer StateConfig ? [StateConfig] extends [never] ? HandlerValidationAtPath<Path, {
|
|
6017
|
+
readonly initialize: HandlerValidationError<
|
|
6018
|
+
"State requires initialize because a transition enters its declared initial configuration",
|
|
6019
|
+
Path
|
|
6020
|
+
>
|
|
6021
|
+
}>
|
|
6022
|
+
: "initialize" extends keyof StateConfig ? never
|
|
6023
|
+
: HandlerValidationAtPath<Path, {
|
|
6024
|
+
readonly initialize: HandlerValidationError<
|
|
6025
|
+
"State requires initialize because a transition enters its declared initial configuration",
|
|
6026
|
+
Path
|
|
6027
|
+
>
|
|
6028
|
+
}>
|
|
6029
|
+
: never
|
|
6030
|
+
|
|
6031
|
+
type HandlerInitialTargetValidationForPaths<
|
|
6032
|
+
AllStates extends StateSchemas,
|
|
6033
|
+
Config,
|
|
6034
|
+
Required
|
|
6035
|
+
> = Types.UnionToIntersection<
|
|
6036
|
+
Required extends string ? HandlerInitializeValidationAtPath<Config, Required> : unknown
|
|
6037
|
+
>
|
|
6038
|
+
|
|
6039
|
+
type HandlerTreeInitialTargetPath<Config> = string extends keyof Config ? never
|
|
6040
|
+
: Config extends object ? {
|
|
6041
|
+
readonly [Key in keyof Config]:
|
|
6042
|
+
| HandlerConfigInitialTargetPath<HandlerConfigPart<Config[Key]>>
|
|
6043
|
+
| (Config[Key] extends { readonly states: infer Children } ? HandlerTreeInitialTargetPath<Children> : never)
|
|
6044
|
+
}[keyof Config]
|
|
6045
|
+
: never
|
|
6046
|
+
|
|
6047
|
+
type HandlerInitialTargetValidation<
|
|
6048
|
+
AllStates extends StateSchemas,
|
|
6049
|
+
Config
|
|
6050
|
+
> = HandlerTreeInitialTargetPath<Config> extends infer TargetPath ? HandlerInitialTargetValidationForPaths<
|
|
6051
|
+
AllStates,
|
|
6052
|
+
Config,
|
|
6053
|
+
RequiredInitializersForTargetPath<AllStates, TargetPath>
|
|
6054
|
+
>
|
|
6055
|
+
: unknown
|
|
6056
|
+
|
|
5705
6057
|
type DeclaredTransitionTarget<Transition> = Transition extends {
|
|
5706
6058
|
readonly targets: infer Targets extends ReadonlyArray<string>
|
|
5707
6059
|
} ? Targets[number]
|
|
@@ -5809,6 +6161,19 @@ export declare namespace Machine {
|
|
|
5809
6161
|
: unknown
|
|
5810
6162
|
: unknown)
|
|
5811
6163
|
|
|
6164
|
+
type HandlerRequiredHistoryInitializeValidation<
|
|
6165
|
+
AllStates extends StateSchemas,
|
|
6166
|
+
StateId extends StateIdentifier<AllStates>,
|
|
6167
|
+
Config
|
|
6168
|
+
> = [HistoryIdentifier<AllStates>] extends [never] ? unknown
|
|
6169
|
+
: StateId extends RequiredHistoryInitializers<AllStates> ? "initialize" extends keyof Config ? unknown : {
|
|
6170
|
+
readonly initialize: HandlerValidationError<
|
|
6171
|
+
"State requires initialize for shallow history restoration",
|
|
6172
|
+
StateId
|
|
6173
|
+
>
|
|
6174
|
+
}
|
|
6175
|
+
: unknown
|
|
6176
|
+
|
|
5812
6177
|
type HandlerNodeValidation<
|
|
5813
6178
|
AllStates extends StateSchemas,
|
|
5814
6179
|
Node,
|
|
@@ -5831,6 +6196,7 @@ export declare namespace Machine {
|
|
|
5831
6196
|
& HandlerInvokeParentEventsValidation<InputEvents, StateId, Config>
|
|
5832
6197
|
& HandlerChildrenValidation<Node, StateId, Config>
|
|
5833
6198
|
& HandlerOutputRequirementValidation<AllStates, StateId, AvailableOutputStates, Config>
|
|
6199
|
+
& HandlerRequiredHistoryInitializeValidation<AllStates, StateId, Config>
|
|
5834
6200
|
& HandlerRuntimeValidation<Events, Emits, StateId, Config>
|
|
5835
6201
|
: unknown
|
|
5836
6202
|
|
|
@@ -5944,7 +6310,7 @@ export declare namespace Machine {
|
|
|
5944
6310
|
AllStates extends StateSchemas,
|
|
5945
6311
|
StateId extends StateIdentifier<AllStates>,
|
|
5946
6312
|
Config
|
|
5947
|
-
> = StateId extends RequiredHistoryInitializers<AllStates> ? "
|
|
6313
|
+
> = StateId extends RequiredHistoryInitializers<AllStates> ? "initialize" extends keyof Config ? true : false : true
|
|
5948
6314
|
|
|
5949
6315
|
type HandlerHasRequiredHistoryDefaults<Node, Config> = Node extends {
|
|
5950
6316
|
readonly states: infer Children extends StateSchemas
|
|
@@ -5984,7 +6350,6 @@ export declare namespace Machine {
|
|
|
5984
6350
|
| Effect.Error<DoneReturn<Config>>
|
|
5985
6351
|
| Effect.Error<StateActionReturn<Config, "entry">>
|
|
5986
6352
|
| Effect.Error<StateActionReturn<Config, "exit">>
|
|
5987
|
-
| Effect.Error<StateInitialReturn<Config>>
|
|
5988
6353
|
| Effect.Error<HistoryDefaultReturn<Config>>
|
|
5989
6354
|
| Effect.Error<ChoiceReturn<Config>>
|
|
5990
6355
|
| InvokeError<Config>
|
|
@@ -6107,6 +6472,11 @@ export declare namespace Machine {
|
|
|
6107
6472
|
StateIdentifier<States>
|
|
6108
6473
|
>
|
|
6109
6474
|
>
|
|
6475
|
+
& ([StateIdentifier<States>] extends [UnhandledStates] ? HandlerInitialTargetValidation<
|
|
6476
|
+
States,
|
|
6477
|
+
NoInfer<Config>
|
|
6478
|
+
>
|
|
6479
|
+
: unknown)
|
|
6110
6480
|
): HandleTreeResult<
|
|
6111
6481
|
States,
|
|
6112
6482
|
Events,
|
|
@@ -6431,7 +6801,7 @@ interface Make {
|
|
|
6431
6801
|
* adds raised events and other machine-local deliveries.
|
|
6432
6802
|
* `Machine.emittedEvents` defines outward ephemeral notifications, while
|
|
6433
6803
|
* `parentEvents` declares the inputs a child may explicitly send to its owning
|
|
6434
|
-
*
|
|
6804
|
+
* machine. All descriptors expose deferred constructors while retaining their
|
|
6435
6805
|
* schemas opaquely for runtime validation. Public and internal tags must be
|
|
6436
6806
|
* disjoint.
|
|
6437
6807
|
*
|
|
@@ -6543,8 +6913,8 @@ export const internalEvents: {
|
|
|
6543
6913
|
|
|
6544
6914
|
/**
|
|
6545
6915
|
* Defines the ephemeral notifications a machine may publish to external
|
|
6546
|
-
* observers. Emitted events are separate from
|
|
6547
|
-
* implicitly to a parent
|
|
6916
|
+
* observers. Emitted events are separate from machine input and are never sent
|
|
6917
|
+
* implicitly to a parent machine. Observe them through `MachineRef.emissions` or
|
|
6548
6918
|
* the AtomMachine emission stream adapters.
|
|
6549
6919
|
*
|
|
6550
6920
|
* @category constructors
|
|
@@ -6728,7 +7098,7 @@ export const decodeSnapshot: <
|
|
|
6728
7098
|
Machine.SnapshotDecodingServices<States>
|
|
6729
7099
|
> = internal.decodeSnapshot as any
|
|
6730
7100
|
|
|
6731
|
-
type
|
|
7101
|
+
type EffectInvokeSource<
|
|
6732
7102
|
States extends Machine.StateSchemas,
|
|
6733
7103
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6734
7104
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6746,7 +7116,7 @@ type DynamicEffectInvokeSource<
|
|
|
6746
7116
|
readonly onSnapshot?: never
|
|
6747
7117
|
}
|
|
6748
7118
|
|
|
6749
|
-
type
|
|
7119
|
+
type EffectDoneHandler<
|
|
6750
7120
|
States extends Machine.StateSchemas,
|
|
6751
7121
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6752
7122
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6767,7 +7137,7 @@ type DynamicEffectDoneHandler<
|
|
|
6767
7137
|
>
|
|
6768
7138
|
>
|
|
6769
7139
|
|
|
6770
|
-
type
|
|
7140
|
+
type EffectFailureHandler<
|
|
6771
7141
|
States extends Machine.StateSchemas,
|
|
6772
7142
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6773
7143
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6788,7 +7158,7 @@ type DynamicEffectFailureHandler<
|
|
|
6788
7158
|
>
|
|
6789
7159
|
>
|
|
6790
7160
|
|
|
6791
|
-
type
|
|
7161
|
+
type EffectInvokeResult<
|
|
6792
7162
|
States extends Machine.StateSchemas,
|
|
6793
7163
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6794
7164
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6805,7 +7175,7 @@ type DynamicEffectInvokeResult<
|
|
|
6805
7175
|
|
|
6806
7176
|
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
6807
7177
|
|
|
6808
|
-
type
|
|
7178
|
+
type BoundEffectInvokeSource<
|
|
6809
7179
|
States extends Machine.StateSchemas,
|
|
6810
7180
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6811
7181
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6825,7 +7195,7 @@ type BoundDynamicEffectInvokeSource<
|
|
|
6825
7195
|
readonly onSnapshot?: never
|
|
6826
7196
|
}
|
|
6827
7197
|
|
|
6828
|
-
type
|
|
7198
|
+
type BoundEffectDoneHandler<
|
|
6829
7199
|
States extends Machine.StateSchemas,
|
|
6830
7200
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6831
7201
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6848,7 +7218,7 @@ type BoundDynamicEffectDoneHandler<
|
|
|
6848
7218
|
>
|
|
6849
7219
|
>
|
|
6850
7220
|
|
|
6851
|
-
type
|
|
7221
|
+
type BoundEffectFailureHandler<
|
|
6852
7222
|
States extends Machine.StateSchemas,
|
|
6853
7223
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6854
7224
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6871,7 +7241,7 @@ type BoundDynamicEffectFailureHandler<
|
|
|
6871
7241
|
>
|
|
6872
7242
|
>
|
|
6873
7243
|
|
|
6874
|
-
type
|
|
7244
|
+
type BoundEffectInvokeResult<
|
|
6875
7245
|
States extends Machine.StateSchemas,
|
|
6876
7246
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
6877
7247
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -6909,9 +7279,9 @@ export interface Invoker<
|
|
|
6909
7279
|
) => Effect.Effect<unknown, unknown, unknown>
|
|
6910
7280
|
>(
|
|
6911
7281
|
config:
|
|
6912
|
-
&
|
|
7282
|
+
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6913
7283
|
& {
|
|
6914
|
-
readonly onDone:
|
|
7284
|
+
readonly onDone: BoundEffectDoneHandler<
|
|
6915
7285
|
States,
|
|
6916
7286
|
Events,
|
|
6917
7287
|
Emits,
|
|
@@ -6920,7 +7290,7 @@ export interface Invoker<
|
|
|
6920
7290
|
StateId,
|
|
6921
7291
|
Source
|
|
6922
7292
|
>
|
|
6923
|
-
readonly onFailure:
|
|
7293
|
+
readonly onFailure: BoundEffectFailureHandler<
|
|
6924
7294
|
States,
|
|
6925
7295
|
Events,
|
|
6926
7296
|
Emits,
|
|
@@ -6937,7 +7307,7 @@ export interface Invoker<
|
|
|
6937
7307
|
"onFailure must be omitted when the Effect error is never"
|
|
6938
7308
|
]
|
|
6939
7309
|
: []
|
|
6940
|
-
):
|
|
7310
|
+
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6941
7311
|
<
|
|
6942
7312
|
StateId extends Machine.StateIdentifier<States>,
|
|
6943
7313
|
const Source extends (
|
|
@@ -6945,9 +7315,9 @@ export interface Invoker<
|
|
|
6945
7315
|
) => Effect.Effect<unknown, never, unknown>
|
|
6946
7316
|
>(
|
|
6947
7317
|
config:
|
|
6948
|
-
&
|
|
7318
|
+
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6949
7319
|
& {
|
|
6950
|
-
readonly onDone:
|
|
7320
|
+
readonly onDone: BoundEffectDoneHandler<
|
|
6951
7321
|
States,
|
|
6952
7322
|
Events,
|
|
6953
7323
|
Emits,
|
|
@@ -6962,7 +7332,7 @@ export interface Invoker<
|
|
|
6962
7332
|
"onDone must be omitted when the Effect output is never"
|
|
6963
7333
|
]
|
|
6964
7334
|
: []
|
|
6965
|
-
):
|
|
7335
|
+
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6966
7336
|
<
|
|
6967
7337
|
StateId extends Machine.StateIdentifier<States>,
|
|
6968
7338
|
const Source extends (
|
|
@@ -6970,10 +7340,10 @@ export interface Invoker<
|
|
|
6970
7340
|
) => Effect.Effect<never, unknown, unknown>
|
|
6971
7341
|
>(
|
|
6972
7342
|
config:
|
|
6973
|
-
&
|
|
7343
|
+
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6974
7344
|
& {
|
|
6975
7345
|
readonly onDone?: never
|
|
6976
|
-
readonly onFailure:
|
|
7346
|
+
readonly onFailure: BoundEffectFailureHandler<
|
|
6977
7347
|
States,
|
|
6978
7348
|
Events,
|
|
6979
7349
|
Emits,
|
|
@@ -6987,7 +7357,7 @@ export interface Invoker<
|
|
|
6987
7357
|
"onFailure must be omitted when the Effect error is never"
|
|
6988
7358
|
]
|
|
6989
7359
|
: []
|
|
6990
|
-
):
|
|
7360
|
+
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6991
7361
|
<
|
|
6992
7362
|
StateId extends Machine.StateIdentifier<States>,
|
|
6993
7363
|
const Source extends (
|
|
@@ -6995,33 +7365,12 @@ export interface Invoker<
|
|
|
6995
7365
|
) => Effect.Effect<never, never, unknown>
|
|
6996
7366
|
>(
|
|
6997
7367
|
config:
|
|
6998
|
-
&
|
|
7368
|
+
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
6999
7369
|
& {
|
|
7000
7370
|
readonly onDone?: never
|
|
7001
7371
|
readonly onFailure?: never
|
|
7002
7372
|
}
|
|
7003
|
-
):
|
|
7004
|
-
<
|
|
7005
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7006
|
-
const Fx extends Effect.Effect<any, any, any>,
|
|
7007
|
-
const Config extends object
|
|
7008
|
-
>(
|
|
7009
|
-
config:
|
|
7010
|
-
& Config
|
|
7011
|
-
& Machine.EffectInvokeArgs<
|
|
7012
|
-
States,
|
|
7013
|
-
Events,
|
|
7014
|
-
Emits,
|
|
7015
|
-
StateId,
|
|
7016
|
-
Fx,
|
|
7017
|
-
Fx,
|
|
7018
|
-
InputEvents,
|
|
7019
|
-
ParentEvents
|
|
7020
|
-
>
|
|
7021
|
-
):
|
|
7022
|
-
& Config
|
|
7023
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
7024
|
-
& Machine.InvokeTyped<Effect.Success<Fx>, Effect.Error<Fx>, Effect.Services<Fx>, never>
|
|
7373
|
+
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
7025
7374
|
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(
|
|
7026
7375
|
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7027
7376
|
): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>
|
|
@@ -7133,12 +7482,13 @@ export interface Invoker<
|
|
|
7133
7482
|
* is required only when the source has a typed failure channel.
|
|
7134
7483
|
*
|
|
7135
7484
|
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
7136
|
-
* inference through published declarations.
|
|
7137
|
-
*
|
|
7138
|
-
*
|
|
7139
|
-
*
|
|
7140
|
-
* lifecycle `id` and a typed communication
|
|
7141
|
-
* own their identity, so `id` and
|
|
7485
|
+
* inference through published declarations. Effect factories run when their
|
|
7486
|
+
* owning state is entered and infer the owner context, output, error, and
|
|
7487
|
+
* service channels together without a return annotation. Durations may be
|
|
7488
|
+
* supplied directly or derived from the owning state's entry context. Logic
|
|
7489
|
+
* invocations require both a lifecycle `id` and a typed communication
|
|
7490
|
+
* `address`. Child descriptors already own their identity, so `id` and
|
|
7491
|
+
* `address` must not be repeated.
|
|
7142
7492
|
*
|
|
7143
7493
|
* Owner references are intentionally non-sendable here because this standalone
|
|
7144
7494
|
* constructor does not know the owning definition. When a callback sends to
|
|
@@ -7149,10 +7499,11 @@ export interface Invoker<
|
|
|
7149
7499
|
* ```ts
|
|
7150
7500
|
* invoke: Machine.invoke({
|
|
7151
7501
|
* id: "load",
|
|
7152
|
-
* effect:
|
|
7153
|
-
*
|
|
7154
|
-
*
|
|
7155
|
-
*
|
|
7502
|
+
* effect: () =>
|
|
7503
|
+
* Effect.tryPromise({
|
|
7504
|
+
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
7505
|
+
* catch: (cause) => new LoadError({ cause })
|
|
7506
|
+
* }),
|
|
7156
7507
|
* onDone: ({ output, target }) => target.full.Ready({ data: output }),
|
|
7157
7508
|
* onFailure: ({ error, target }) => target.full.Failed({ error })
|
|
7158
7509
|
* })
|
|
@@ -7172,10 +7523,10 @@ export const invoke: {
|
|
|
7172
7523
|
) => Effect.Effect<unknown, unknown, unknown>
|
|
7173
7524
|
>(
|
|
7174
7525
|
config:
|
|
7175
|
-
&
|
|
7526
|
+
& EffectInvokeSource<States, Events, Emits, StateId, Source>
|
|
7176
7527
|
& {
|
|
7177
|
-
readonly onDone:
|
|
7178
|
-
readonly onFailure:
|
|
7528
|
+
readonly onDone: EffectDoneHandler<States, Events, Emits, StateId, Source>
|
|
7529
|
+
readonly onFailure: EffectFailureHandler<States, Events, Emits, StateId, Source>
|
|
7179
7530
|
},
|
|
7180
7531
|
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
7181
7532
|
"onDone must be omitted when the Effect output is never"
|
|
@@ -7184,7 +7535,7 @@ export const invoke: {
|
|
|
7184
7535
|
"onFailure must be omitted when the Effect error is never"
|
|
7185
7536
|
]
|
|
7186
7537
|
: []
|
|
7187
|
-
):
|
|
7538
|
+
): EffectInvokeResult<States, Events, Emits, StateId, Source>
|
|
7188
7539
|
<
|
|
7189
7540
|
const States extends Machine.StateSchemas,
|
|
7190
7541
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7195,16 +7546,16 @@ export const invoke: {
|
|
|
7195
7546
|
) => Effect.Effect<unknown, never, unknown>
|
|
7196
7547
|
>(
|
|
7197
7548
|
config:
|
|
7198
|
-
&
|
|
7549
|
+
& EffectInvokeSource<States, Events, Emits, StateId, Source>
|
|
7199
7550
|
& {
|
|
7200
|
-
readonly onDone:
|
|
7551
|
+
readonly onDone: EffectDoneHandler<States, Events, Emits, StateId, Source>
|
|
7201
7552
|
readonly onFailure?: never
|
|
7202
7553
|
},
|
|
7203
7554
|
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
7204
7555
|
"onDone must be omitted when the Effect output is never"
|
|
7205
7556
|
]
|
|
7206
7557
|
: []
|
|
7207
|
-
):
|
|
7558
|
+
): EffectInvokeResult<States, Events, Emits, StateId, Source>
|
|
7208
7559
|
<
|
|
7209
7560
|
const States extends Machine.StateSchemas,
|
|
7210
7561
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7215,16 +7566,16 @@ export const invoke: {
|
|
|
7215
7566
|
) => Effect.Effect<never, unknown, unknown>
|
|
7216
7567
|
>(
|
|
7217
7568
|
config:
|
|
7218
|
-
&
|
|
7569
|
+
& EffectInvokeSource<States, Events, Emits, StateId, Source>
|
|
7219
7570
|
& {
|
|
7220
7571
|
readonly onDone?: never
|
|
7221
|
-
readonly onFailure:
|
|
7572
|
+
readonly onFailure: EffectFailureHandler<States, Events, Emits, StateId, Source>
|
|
7222
7573
|
},
|
|
7223
7574
|
..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
7224
7575
|
"onFailure must be omitted when the Effect error is never"
|
|
7225
7576
|
]
|
|
7226
7577
|
: []
|
|
7227
|
-
):
|
|
7578
|
+
): EffectInvokeResult<States, Events, Emits, StateId, Source>
|
|
7228
7579
|
<
|
|
7229
7580
|
const States extends Machine.StateSchemas,
|
|
7230
7581
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7235,32 +7586,12 @@ export const invoke: {
|
|
|
7235
7586
|
) => Effect.Effect<never, never, unknown>
|
|
7236
7587
|
>(
|
|
7237
7588
|
config:
|
|
7238
|
-
&
|
|
7589
|
+
& EffectInvokeSource<States, Events, Emits, StateId, Source>
|
|
7239
7590
|
& {
|
|
7240
7591
|
readonly onDone?: never
|
|
7241
7592
|
readonly onFailure?: never
|
|
7242
7593
|
}
|
|
7243
|
-
):
|
|
7244
|
-
<
|
|
7245
|
-
const States extends Machine.StateSchemas,
|
|
7246
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7247
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7248
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7249
|
-
const Fx extends Effect.Effect<any, any, any>,
|
|
7250
|
-
const Config extends object
|
|
7251
|
-
>(
|
|
7252
|
-
config:
|
|
7253
|
-
& Config
|
|
7254
|
-
& Machine.EffectInvokeArgs<States, Events, Emits, StateId, Fx, Fx, readonly [], readonly []>
|
|
7255
|
-
):
|
|
7256
|
-
& Config
|
|
7257
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
7258
|
-
& Machine.InvokeTyped<
|
|
7259
|
-
Effect.Success<Fx>,
|
|
7260
|
-
Effect.Error<Fx>,
|
|
7261
|
-
Effect.Services<Fx>,
|
|
7262
|
-
never
|
|
7263
|
-
>
|
|
7594
|
+
): EffectInvokeResult<States, Events, Emits, StateId, Source>
|
|
7264
7595
|
<
|
|
7265
7596
|
const States extends Machine.StateSchemas,
|
|
7266
7597
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7379,11 +7710,11 @@ export const invoke: {
|
|
|
7379
7710
|
>
|
|
7380
7711
|
} = ((config: unknown) => config) as any
|
|
7381
7712
|
/**
|
|
7382
|
-
* Plans the initial state for a machine without executing
|
|
7713
|
+
* Plans the initial state for a machine without executing machine commands.
|
|
7383
7714
|
*
|
|
7384
7715
|
* **Details**
|
|
7385
7716
|
*
|
|
7386
|
-
* The returned plan contains the settled initial snapshot,
|
|
7717
|
+
* The returned plan contains the settled initial snapshot, machine commands,
|
|
7387
7718
|
* emitted events, optional final output, and every startup microstep. Planning
|
|
7388
7719
|
* may evaluate transition logic and follow completion, eventless, and
|
|
7389
7720
|
* raised-event steps. Transition callbacks are evaluated synchronously.
|
|
@@ -7392,8 +7723,8 @@ export const invoke: {
|
|
|
7392
7723
|
*
|
|
7393
7724
|
* **Gotchas**
|
|
7394
7725
|
*
|
|
7395
|
-
* `start` executes the closed command list as part of the managed
|
|
7396
|
-
* protocol. Manual planners may inspect commands but need
|
|
7726
|
+
* `start` executes the closed command list as part of the managed machine commit
|
|
7727
|
+
* protocol. Manual planners may inspect commands but need running machine targets
|
|
7397
7728
|
* to execute child-addressed operations.
|
|
7398
7729
|
*
|
|
7399
7730
|
* **Example**
|
|
@@ -7628,7 +7959,7 @@ export const enabled: <
|
|
|
7628
7959
|
*
|
|
7629
7960
|
* **Gotchas**
|
|
7630
7961
|
*
|
|
7631
|
-
* `plan` returns data; it does not implement the
|
|
7962
|
+
* `plan` returns data; it does not implement the managed machine commit protocol.
|
|
7632
7963
|
* `start` executes child commands, publishes `next`, and then delivers
|
|
7633
7964
|
* `emittedEvents`. Events with no enabled transition are ignored and produce
|
|
7634
7965
|
* an unchanged plan.
|
|
@@ -8029,7 +8360,7 @@ export const prepare: <
|
|
|
8029
8360
|
* **Details**
|
|
8030
8361
|
*
|
|
8031
8362
|
* For each accepted event the runtime plans the complete synchronous
|
|
8032
|
-
* macrostep, executes closed
|
|
8363
|
+
* macrostep, executes closed machine commands, stops invokes for exited states,
|
|
8033
8364
|
* publishes the new state, delivers emitted events, and then starts invokes
|
|
8034
8365
|
* for entered states.
|
|
8035
8366
|
*
|