@typeonce/effect-machine 0.11.0 → 0.12.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 +33 -9
- package/dist/Machine.d.ts +43 -43
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +9 -9
- 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 -2
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +7 -7
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +3 -3
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +3 -3
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +25 -25
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +2 -2
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +20 -20
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.js +3 -3
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +3 -3
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js.map +1 -1
- package/docs/agent-guide.md +28 -11
- package/package.json +1 -1
- package/src/Machine.ts +43 -43
- package/src/internal/machine/cluster.ts +2 -2
- package/src/internal/machine/commandRuntime.ts +4 -2
- package/src/internal/machine/configuration.ts +10 -10
- package/src/internal/machine/executionPlan.ts +35 -35
- package/src/internal/machine/invocation.ts +1 -1
- package/src/internal/machine/planner.ts +30 -24
- package/src/internal/machine/process.ts +3 -3
- package/src/internal/machine/runtime.ts +4 -4
package/README.md
CHANGED
|
@@ -10,6 +10,27 @@ cluster adapter.
|
|
|
10
10
|
> This is early-release software. Its API may change, and each release targets
|
|
11
11
|
> one exact Effect beta.
|
|
12
12
|
|
|
13
|
+
## Design principles
|
|
14
|
+
|
|
15
|
+
- **Type-safe by construction:** reject invalid protocols, compositions, and
|
|
16
|
+
capabilities at compile time where possible, and preserve typed Effect
|
|
17
|
+
failures at runtime.
|
|
18
|
+
- **Explicit and opinionated:** give different semantics different names and
|
|
19
|
+
contracts. Builders and inference remove ceremony without making behavior
|
|
20
|
+
depend on ambiguous omissions.
|
|
21
|
+
- **Readable models:** keep schemas, topology, behavior, and effects concise
|
|
22
|
+
enough that a human can understand the complete model from its definition.
|
|
23
|
+
- **Effect-native:** design toward eventual inclusion in Effect core and follow
|
|
24
|
+
its API shape, module boundaries, ownership, and failure conventions.
|
|
25
|
+
|
|
26
|
+
The package is pre-1.0: a clearer or safer long-term API takes priority over
|
|
27
|
+
backward compatibility. Breaking changes use minor releases, compatible fixes
|
|
28
|
+
use patch releases, and compatibility aliases are not added by default.
|
|
29
|
+
|
|
30
|
+
The core machine model remains local. Distributed identity, placement,
|
|
31
|
+
transport, routing, delivery, and remote lifecycle semantics belong to Effect
|
|
32
|
+
Cluster and are exposed only through explicit integration boundaries.
|
|
33
|
+
|
|
13
34
|
## Install
|
|
14
35
|
|
|
15
36
|
```sh
|
|
@@ -136,7 +157,7 @@ data, put it on their compound parent.
|
|
|
136
157
|
|
|
137
158
|
### Separate inputs, raised events, and emissions
|
|
138
159
|
|
|
139
|
-
`events` is the public
|
|
160
|
+
`events` is the public machine-input protocol. Events raised to the same machine
|
|
140
161
|
belong in `internalEvents`. Ephemeral outward notifications have their own
|
|
141
162
|
`emittedEvents` protocol:
|
|
142
163
|
|
|
@@ -186,7 +207,7 @@ protocols but cannot expose a finite constructor set; pass a complete event
|
|
|
186
207
|
object to `send` or `Machine.plan` for those events.
|
|
187
208
|
|
|
188
209
|
`ref.emissions` is a hot `Stream`: it publishes only notifications produced
|
|
189
|
-
after subscription, replays nothing, and completes when the
|
|
210
|
+
after subscription, replays nothing, and completes when the machine terminates.
|
|
190
211
|
Snapshots remain separate and stateful: `ref.changes` begins with the current
|
|
191
212
|
lifecycle snapshot and then follows later changes. Use `Machine.prepare` when
|
|
192
213
|
an observer must be installed before initial-entry actions run:
|
|
@@ -209,10 +230,10 @@ emission: the observer is simply subscribed before initialization begins.
|
|
|
209
230
|
Invalid event and emission constructions fail the machine with a typed
|
|
210
231
|
`MachineSchemaDecodeError`; they do not throw from the constructor call.
|
|
211
232
|
|
|
212
|
-
### Send explicitly between
|
|
233
|
+
### Send explicitly between machines
|
|
213
234
|
|
|
214
|
-
`raise` targets the current machine in the same macrostep. `sendTo` targets
|
|
215
|
-
|
|
235
|
+
`raise` targets the current machine in the same macrostep. `sendTo` targets a
|
|
236
|
+
machine mailbox and is processed later. A child declares the subset of parent
|
|
216
237
|
inputs it may send with `parentEvents`:
|
|
217
238
|
|
|
218
239
|
```ts
|
|
@@ -244,15 +265,18 @@ const ParentInputs = Machine.events(Start, ParentEvents)
|
|
|
244
265
|
The same child remains isolated and may be started as a root, where `parent` is
|
|
245
266
|
`undefined`. When `Child` is invoked, the parent definition must accept every
|
|
246
267
|
event in `parentEvents`; otherwise `.handle(...)` is a compile-time error.
|
|
247
|
-
Inside the child, the parent
|
|
248
|
-
`emit` never sends to the parent: it only publishes on the emitting
|
|
268
|
+
Inside the child, the parent target accepts only those declared events.
|
|
269
|
+
`emit` never sends to the parent: it only publishes on the emitting machine's
|
|
249
270
|
`emissions` stream.
|
|
250
271
|
|
|
251
272
|
Every handler also receives `self`, which can be targeted with `sendTo` when a
|
|
252
273
|
later mailbox turn is required. Use `raise` instead for same-macrostep work.
|
|
274
|
+
Both `self` and `parent` are minimal `Machine.MachineTarget<Event>` values. The
|
|
275
|
+
shared `Machine.MachineReferences<InputEvents, ParentEvents>` context keeps
|
|
276
|
+
their input protocols separate without exposing snapshot or lifecycle APIs.
|
|
253
277
|
Structural state values use distinct names: `containingState` is the immediate
|
|
254
278
|
valued state in the same statechart, while `ancestors` maps valued ancestor
|
|
255
|
-
paths. `parent` always means the owning
|
|
279
|
+
paths. `parent` always means the owning machine target.
|
|
256
280
|
|
|
257
281
|
### Choose the target by scope
|
|
258
282
|
|
|
@@ -401,7 +425,7 @@ const childEmissions = AtomMachine.childEmissions(counterAtom.child(Worker))
|
|
|
401
425
|
```
|
|
402
426
|
|
|
403
427
|
These streams require the same `AtomRegistry`, follow the currently mounted
|
|
404
|
-
|
|
428
|
+
machine instance, and do not replay notifications from an earlier subscription
|
|
405
429
|
or child instance.
|
|
406
430
|
|
|
407
431
|
## Persistence
|
package/dist/Machine.d.ts
CHANGED
|
@@ -119,17 +119,17 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
119
119
|
*/
|
|
120
120
|
readonly internalEvents: Machine.EventProtocol<"internal", Machine.InternalEventSchemas<Events, InputEvents>>;
|
|
121
121
|
/**
|
|
122
|
-
* Ephemeral outward notifications published to this
|
|
123
|
-
* Emissions are never delivered implicitly to an owning
|
|
122
|
+
* Ephemeral outward notifications published to this machine's observers.
|
|
123
|
+
* Emissions are never delivered implicitly to an owning machine.
|
|
124
124
|
*
|
|
125
125
|
* @since 0.4.0
|
|
126
126
|
*/
|
|
127
127
|
readonly emittedEvents: Machine.EventProtocol<"emitted", Emits>;
|
|
128
128
|
/**
|
|
129
|
-
* Public input events accepted by an owning
|
|
129
|
+
* Public input events accepted by an owning machine when this machine is
|
|
130
130
|
* running as a child.
|
|
131
131
|
*
|
|
132
|
-
* The protocol types the optional `parent`
|
|
132
|
+
* The protocol types the optional `parent` machine target exposed to
|
|
133
133
|
* handlers and is checked against a concrete parent's public events at
|
|
134
134
|
* composition boundaries.
|
|
135
135
|
*
|
|
@@ -292,38 +292,38 @@ export interface Runtime<in Events, in Emits> {
|
|
|
292
292
|
*/
|
|
293
293
|
readonly raise: (event: Machine.EventInput<Events>) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
294
294
|
/**
|
|
295
|
-
* Publishes an ephemeral notification to the running
|
|
295
|
+
* Publishes an ephemeral notification to the running machine's observers.
|
|
296
296
|
*
|
|
297
297
|
* @since 0.4.0
|
|
298
298
|
*/
|
|
299
299
|
readonly emit: (event: Machine.EmittedEventInput<Emits>) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
300
300
|
}
|
|
301
301
|
/**
|
|
302
|
-
* Minimal typed
|
|
302
|
+
* Minimal typed target accepted by inter-machine send commands.
|
|
303
303
|
*
|
|
304
304
|
* @category models
|
|
305
|
-
* @since 0.
|
|
305
|
+
* @since 0.12.0
|
|
306
306
|
*/
|
|
307
|
-
export interface
|
|
307
|
+
export interface MachineTarget<in Event> {
|
|
308
308
|
readonly id: string;
|
|
309
309
|
readonly sessionId: string;
|
|
310
310
|
readonly send: (event: Event) => Effect.Effect<void, StoppedError>;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
313
|
+
* Machine targets available while evaluating machine behavior.
|
|
314
314
|
*
|
|
315
315
|
* @category models
|
|
316
|
-
* @since 0.
|
|
316
|
+
* @since 0.12.0
|
|
317
317
|
*/
|
|
318
|
-
export interface
|
|
319
|
-
/**
|
|
320
|
-
readonly self:
|
|
321
|
-
/**
|
|
322
|
-
readonly parent:
|
|
318
|
+
export interface MachineReferences<InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>> {
|
|
319
|
+
/** Target for the current machine. Sending queues a later mailbox event. */
|
|
320
|
+
readonly self: MachineTarget<Machine.EventInputOf<InputEvents>>;
|
|
321
|
+
/** Target for the owning machine, or `undefined` when running as a root. */
|
|
322
|
+
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>> | undefined;
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
325
325
|
* Synchronous commands available while a machine transition is being
|
|
326
|
-
* selected. Enqueuing only records statechart and
|
|
326
|
+
* selected. Enqueuing only records statechart and machine operations; it never
|
|
327
327
|
* executes an Effect.
|
|
328
328
|
*
|
|
329
329
|
* @category models
|
|
@@ -332,11 +332,11 @@ export interface ActorContext<InputEvents extends ReadonlyArray<Machine.TaggedSc
|
|
|
332
332
|
export interface Enqueue<in Events, in Emits> {
|
|
333
333
|
/** Raises an event inside the current macrostep. */
|
|
334
334
|
readonly raise: (event: Machine.EventInput<Events>) => void;
|
|
335
|
-
/** Publishes an ephemeral notification to this
|
|
335
|
+
/** Publishes an ephemeral notification to this machine's observers. */
|
|
336
336
|
readonly emit: (event: Machine.EmittedEventInput<Emits>) => void;
|
|
337
337
|
/** Sends an event to an invoked child after the transition is selected. */
|
|
338
338
|
readonly sendTo: {
|
|
339
|
-
<Event>(target:
|
|
339
|
+
<Event>(target: MachineTarget<Event>, event: Event): void;
|
|
340
340
|
<Child extends ChildMachine.Any>(child: Child, event: ChildMachine.Event<Child>): void;
|
|
341
341
|
<Address extends ChildAddress<never>>(child: Address, event: ChildAddress.Event<Address>): void;
|
|
342
342
|
};
|
|
@@ -347,14 +347,14 @@ export interface Enqueue<in Events, in Emits> {
|
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
|
-
* A closed
|
|
350
|
+
* A closed machine command recorded by a synchronous transition.
|
|
351
351
|
*
|
|
352
352
|
* @category models
|
|
353
353
|
* @since 0.4.0
|
|
354
354
|
*/
|
|
355
355
|
export type Command = {
|
|
356
356
|
readonly _tag: "SendTo";
|
|
357
|
-
readonly target:
|
|
357
|
+
readonly target: MachineTarget<unknown> | ChildMachine.Any | ChildAddress<never>;
|
|
358
358
|
readonly event: unknown;
|
|
359
359
|
} | {
|
|
360
360
|
readonly _tag: "Stop";
|
|
@@ -895,7 +895,7 @@ export interface Prepared<out State, in Event, out Error, out Output, out Emitte
|
|
|
895
895
|
* @category models
|
|
896
896
|
* @since 0.4.0
|
|
897
897
|
*/
|
|
898
|
-
export interface MachineRef<out State, in Event, out Error = never, out Output = never, out Emitted = never> extends
|
|
898
|
+
export interface MachineRef<out State, in Event, out Error = never, out Output = never, out Emitted = never> extends MachineTarget<Event> {
|
|
899
899
|
/** Stable machine definition id, or a generated fallback when none was declared. */
|
|
900
900
|
readonly id: string;
|
|
901
901
|
/** Unique identity for this running machine instance. */
|
|
@@ -908,7 +908,7 @@ export interface MachineRef<out State, in Event, out Error = never, out Output =
|
|
|
908
908
|
readonly changes: Stream.Stream<RuntimeSnapshot<State, Error, Output>>;
|
|
909
909
|
/**
|
|
910
910
|
* Streams ephemeral notifications published after subscription. Emissions
|
|
911
|
-
* are not retained or replayed; the stream completes when the
|
|
911
|
+
* are not retained or replayed; the stream completes when the machine stops.
|
|
912
912
|
*/
|
|
913
913
|
readonly emissions: Stream.Stream<Emitted>;
|
|
914
914
|
/** Waits for machine output or fails when execution fails or is stopped. */
|
|
@@ -988,9 +988,9 @@ export declare namespace Logic {
|
|
|
988
988
|
readonly parent: Address<unknown> | undefined;
|
|
989
989
|
/** Starts a child process owned by this scope. */
|
|
990
990
|
readonly spawn: Spawn;
|
|
991
|
-
/** Sends an event to
|
|
991
|
+
/** Sends an event to a machine target or typed parent-local child address. */
|
|
992
992
|
readonly sendTo: {
|
|
993
|
-
<TargetEvent>(target:
|
|
993
|
+
<TargetEvent>(target: MachineTarget<TargetEvent>, event: TargetEvent): Effect.Effect<void, StoppedError>;
|
|
994
994
|
<Address extends ChildAddress<never>>(id: Address, event: ChildAddress.Event<Address>): Effect.Effect<void, StoppedError>;
|
|
995
995
|
};
|
|
996
996
|
/** Stops a child process selected by its parent-local address. */
|
|
@@ -1303,7 +1303,7 @@ export declare namespace Machine {
|
|
|
1303
1303
|
* @since 0.4.0
|
|
1304
1304
|
*/
|
|
1305
1305
|
type InputEvents<M extends Any> = M[typeof MachineTypeId]["inputEvents"];
|
|
1306
|
-
/** Extracts the public input protocol required from an owning
|
|
1306
|
+
/** Extracts the public input protocol required from an owning machine. */
|
|
1307
1307
|
type ParentEvents<M extends Any> = M[typeof MachineTypeId]["parentEvents"];
|
|
1308
1308
|
/** Extracts an internal event schema tuple from the complete and public protocols. */
|
|
1309
1309
|
type InternalEventSchemas<Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>> = Events extends readonly [
|
|
@@ -2543,7 +2543,7 @@ export declare namespace Machine {
|
|
|
2543
2543
|
* @category models
|
|
2544
2544
|
* @since 0.4.0
|
|
2545
2545
|
*/
|
|
2546
|
-
interface HandlerContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2546
|
+
interface HandlerContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2547
2547
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2548
2548
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2549
2549
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2564,7 +2564,7 @@ export declare namespace Machine {
|
|
|
2564
2564
|
* @category models
|
|
2565
2565
|
* @since 0.4.0
|
|
2566
2566
|
*/
|
|
2567
|
-
interface StateActionContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2567
|
+
interface StateActionContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2568
2568
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2569
2569
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2570
2570
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2576,7 +2576,7 @@ export declare namespace Machine {
|
|
|
2576
2576
|
* @category models
|
|
2577
2577
|
* @since 0.4.0
|
|
2578
2578
|
*/
|
|
2579
|
-
interface InvokeContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2579
|
+
interface InvokeContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2580
2580
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2581
2581
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2582
2582
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2588,7 +2588,7 @@ export declare namespace Machine {
|
|
|
2588
2588
|
* @category models
|
|
2589
2589
|
* @since 0.4.0
|
|
2590
2590
|
*/
|
|
2591
|
-
interface InvokeSnapshotContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, State, Error, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2591
|
+
interface InvokeSnapshotContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, State, Error, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2592
2592
|
readonly id: string;
|
|
2593
2593
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2594
2594
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2604,7 +2604,7 @@ export declare namespace Machine {
|
|
|
2604
2604
|
* @category models
|
|
2605
2605
|
* @since 0.4.0
|
|
2606
2606
|
*/
|
|
2607
|
-
interface InvokeDoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2607
|
+
interface InvokeDoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2608
2608
|
readonly id: string;
|
|
2609
2609
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2610
2610
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2614,7 +2614,7 @@ export declare namespace Machine {
|
|
|
2614
2614
|
readonly output: Output;
|
|
2615
2615
|
}
|
|
2616
2616
|
/** Context passed to an invocation typed-failure transition. */
|
|
2617
|
-
interface InvokeFailureContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Error, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2617
|
+
interface InvokeFailureContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Error, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2618
2618
|
readonly id: string;
|
|
2619
2619
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2620
2620
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2629,7 +2629,7 @@ export declare namespace Machine {
|
|
|
2629
2629
|
* @category models
|
|
2630
2630
|
* @since 0.4.0
|
|
2631
2631
|
*/
|
|
2632
|
-
interface AlwaysContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2632
|
+
interface AlwaysContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2633
2633
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2634
2634
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2635
2635
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2651,7 +2651,7 @@ export declare namespace Machine {
|
|
|
2651
2651
|
* @category models
|
|
2652
2652
|
* @since 0.4.0
|
|
2653
2653
|
*/
|
|
2654
|
-
interface DoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2654
|
+
interface DoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2655
2655
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2656
2656
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2657
2657
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2669,7 +2669,7 @@ export declare namespace Machine {
|
|
|
2669
2669
|
readonly target: TargetBuilder<States, StateId>;
|
|
2670
2670
|
}
|
|
2671
2671
|
/** Context passed to a transient choice resolver. There is no `state` value. */
|
|
2672
|
-
interface ChoiceContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, ChoiceId extends ChoiceIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends
|
|
2672
|
+
interface ChoiceContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, ChoiceId extends ChoiceIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> extends MachineReferences<InputEvents, ParentEvents> {
|
|
2673
2673
|
readonly containingState: StateByIdentifier<States, Extract<ImmediateParentStateIdentifier<ChoiceId>, StateIdentifier<States>>>;
|
|
2674
2674
|
readonly ancestors: {
|
|
2675
2675
|
readonly [Parent in Extract<ParentStateIdentifier<ChoiceId>, ValuedStateIdentifier<States>>]: StateByIdentifier<States, Parent>;
|
|
@@ -3557,7 +3557,7 @@ interface Make {
|
|
|
3557
3557
|
* adds raised events and other machine-local deliveries.
|
|
3558
3558
|
* `Machine.emittedEvents` defines outward ephemeral notifications, while
|
|
3559
3559
|
* `parentEvents` declares the inputs a child may explicitly send to its owning
|
|
3560
|
-
*
|
|
3560
|
+
* machine. All descriptors expose deferred constructors while retaining their
|
|
3561
3561
|
* schemas opaquely for runtime validation. Public and internal tags must be
|
|
3562
3562
|
* disjoint.
|
|
3563
3563
|
*
|
|
@@ -3655,8 +3655,8 @@ export declare const internalEvents: {
|
|
|
3655
3655
|
};
|
|
3656
3656
|
/**
|
|
3657
3657
|
* Defines the ephemeral notifications a machine may publish to external
|
|
3658
|
-
* observers. Emitted events are separate from
|
|
3659
|
-
* implicitly to a parent
|
|
3658
|
+
* observers. Emitted events are separate from machine input and are never sent
|
|
3659
|
+
* implicitly to a parent machine. Observe them through `MachineRef.emissions` or
|
|
3660
3660
|
* the AtomMachine emission stream adapters.
|
|
3661
3661
|
*
|
|
3662
3662
|
* @category constructors
|
|
@@ -3891,11 +3891,11 @@ export declare const invoke: {
|
|
|
3891
3891
|
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Child extends ChildMachine.Any, const Config extends object>(config: Config & Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child, readonly [], readonly []>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<Machine.Output<Child["machine"]>, Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>, Machine.Services<Child["machine"]>, Machine.InitialError<Child["machine"]>, Machine.Emit<Child["machine"]>, Machine.EventOf<Machine.ParentEvents<Child["machine"]>>>;
|
|
3892
3892
|
};
|
|
3893
3893
|
/**
|
|
3894
|
-
* Plans the initial state for a machine without executing
|
|
3894
|
+
* Plans the initial state for a machine without executing machine commands.
|
|
3895
3895
|
*
|
|
3896
3896
|
* **Details**
|
|
3897
3897
|
*
|
|
3898
|
-
* The returned plan contains the settled initial snapshot,
|
|
3898
|
+
* The returned plan contains the settled initial snapshot, machine commands,
|
|
3899
3899
|
* emitted events, optional final output, and every startup microstep. Planning
|
|
3900
3900
|
* may evaluate transition logic and follow completion, eventless, and
|
|
3901
3901
|
* raised-event steps. Transition callbacks are evaluated synchronously.
|
|
@@ -3904,8 +3904,8 @@ export declare const invoke: {
|
|
|
3904
3904
|
*
|
|
3905
3905
|
* **Gotchas**
|
|
3906
3906
|
*
|
|
3907
|
-
* `start` executes the closed command list as part of the managed
|
|
3908
|
-
* protocol. Manual planners may inspect commands but need
|
|
3907
|
+
* `start` executes the closed command list as part of the managed machine commit
|
|
3908
|
+
* protocol. Manual planners may inspect commands but need running machine targets
|
|
3909
3909
|
* to execute child-addressed operations.
|
|
3910
3910
|
*
|
|
3911
3911
|
* **Example**
|
|
@@ -4029,7 +4029,7 @@ export declare const enabled: <const States extends Machine.StateSchemas, const
|
|
|
4029
4029
|
*
|
|
4030
4030
|
* **Gotchas**
|
|
4031
4031
|
*
|
|
4032
|
-
* `plan` returns data; it does not implement the
|
|
4032
|
+
* `plan` returns data; it does not implement the managed machine commit protocol.
|
|
4033
4033
|
* `start` executes child commands, publishes `next`, and then delivers
|
|
4034
4034
|
* `emittedEvents`. Events with no enabled transition are ignored and produce
|
|
4035
4035
|
* an unchanged plan.
|
|
@@ -4250,7 +4250,7 @@ export declare const prepare: <const States extends Machine.StateSchemas, const
|
|
|
4250
4250
|
* **Details**
|
|
4251
4251
|
*
|
|
4252
4252
|
* For each accepted event the runtime plans the complete synchronous
|
|
4253
|
-
* macrostep, executes closed
|
|
4253
|
+
* macrostep, executes closed machine commands, stops invokes for exited states,
|
|
4254
4254
|
* publishes the new state, delivers emitted events, and then starts invokes
|
|
4255
4255
|
* for entered states.
|
|
4256
4256
|
*
|