@typeonce/effect-machine 0.4.0 → 0.5.1
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 +166 -588
- package/dist/Machine.d.ts +426 -240
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +219 -43
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +1 -1
- package/dist/internal/machine/activities.js +1 -1
- package/dist/internal/machine/atom.d.ts +1 -1
- package/dist/internal/machine/atom.js +1 -1
- package/dist/internal/machine/cluster.d.ts +2 -2
- package/dist/internal/machine/cluster.js +1 -1
- package/dist/internal/machine/command.d.ts +1 -1
- package/dist/internal/machine/command.js +1 -1
- package/dist/internal/machine/commandRuntime.d.ts +1 -1
- package/dist/internal/machine/commandRuntime.js +1 -1
- package/dist/internal/machine/configuration.d.ts +1 -1
- package/dist/internal/machine/configuration.js +1 -1
- package/dist/internal/machine/errors.d.ts +7 -7
- package/dist/internal/machine/errors.js +7 -7
- package/dist/internal/machine/executionPlan.d.ts +2 -2
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +17 -8
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/planner.d.ts +1 -1
- package/dist/internal/machine/planner.js +1 -1
- package/dist/internal/machine/process.d.ts +1 -1
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +76 -24
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +1 -1
- package/dist/internal/machine/protocol.js +1 -1
- package/dist/internal/machine/runtime.d.ts +32 -4
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +120 -12
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/serialization.d.ts +1 -1
- package/dist/internal/machine/serialization.js +1 -1
- package/dist/internal/machine/topology.d.ts +1 -1
- package/dist/internal/machine/topology.js +1 -1
- package/dist/internal/testing/machine/arbitrary.d.ts +3 -3
- package/dist/internal/testing/machine/exploration.d.ts +30 -0
- package/dist/internal/testing/machine/exploration.d.ts.map +1 -0
- package/dist/internal/testing/machine/exploration.js +237 -0
- package/dist/internal/testing/machine/exploration.js.map +1 -0
- package/dist/internal/testing/machine/finiteModel.d.ts +20 -20
- package/dist/internal/testing/machine/finiteModel.js +2 -2
- package/dist/internal/testing/machine/invariant.d.ts +31 -0
- package/dist/internal/testing/machine/invariant.d.ts.map +1 -0
- package/dist/internal/testing/machine/invariant.js +214 -0
- package/dist/internal/testing/machine/invariant.js.map +1 -0
- package/dist/internal/testing/machine/probe.d.ts +26 -0
- package/dist/internal/testing/machine/probe.d.ts.map +1 -0
- package/dist/internal/testing/machine/probe.js +45 -0
- package/dist/internal/testing/machine/probe.js.map +1 -0
- package/dist/internal/testing/machine/referenceModel.d.ts +14 -14
- package/dist/internal/testing/machine/referenceModel.js +2 -2
- package/dist/internal/testing/machine/runtime.d.ts +329 -26
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -1
- package/dist/internal/testing/machine/runtime.js +303 -14
- package/dist/internal/testing/machine/runtime.js.map +1 -1
- package/dist/internal/testing/machine/runtimeInvariant.d.ts +32 -0
- package/dist/internal/testing/machine/runtimeInvariant.d.ts.map +1 -0
- package/dist/internal/testing/machine/runtimeInvariant.js +334 -0
- package/dist/internal/testing/machine/runtimeInvariant.js.map +1 -0
- package/dist/internal/testing/machine/trace.d.ts +17 -0
- package/dist/internal/testing/machine/trace.d.ts.map +1 -0
- package/dist/internal/testing/machine/trace.js +94 -0
- package/dist/internal/testing/machine/trace.js.map +1 -0
- package/dist/internal/testing/machine/verification.d.ts +9 -6
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +8 -79
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +1029 -47
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +315 -11
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +38 -19
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +27 -9
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +82 -31
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +63 -12
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +160 -18
- package/package.json +11 -2
package/dist/Machine.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Schema-first machine definitions.
|
|
3
3
|
*
|
|
4
|
-
* @since 4.0
|
|
4
|
+
* @since 0.4.0
|
|
5
5
|
*/
|
|
6
6
|
import type * as Cause from "effect/Cause";
|
|
7
7
|
import type * as Duration from "effect/Duration";
|
|
@@ -25,14 +25,14 @@ import type * as Topology from "./internal/machine/topology.js";
|
|
|
25
25
|
* values.
|
|
26
26
|
*
|
|
27
27
|
* @category type IDs
|
|
28
|
-
* @since 4.0
|
|
28
|
+
* @since 0.4.0
|
|
29
29
|
*/
|
|
30
30
|
export type TypeId = "~effect/Machine";
|
|
31
31
|
/**
|
|
32
32
|
* Runtime type identifier attached to `Machine` values.
|
|
33
33
|
*
|
|
34
34
|
* @category type IDs
|
|
35
|
-
* @since 4.0
|
|
35
|
+
* @since 0.4.0
|
|
36
36
|
*/
|
|
37
37
|
export declare const TypeId: TypeId;
|
|
38
38
|
declare const MachineOutputStatesTypeId: unique symbol;
|
|
@@ -42,7 +42,7 @@ declare const MachineTypeId: unique symbol;
|
|
|
42
42
|
* actions.
|
|
43
43
|
*
|
|
44
44
|
* @category type IDs
|
|
45
|
-
* @since 4.0
|
|
45
|
+
* @since 0.4.0
|
|
46
46
|
*/
|
|
47
47
|
export { InitialEventTypeId };
|
|
48
48
|
/**
|
|
@@ -50,7 +50,7 @@ export { InitialEventTypeId };
|
|
|
50
50
|
* that run while the machine is settling its initial state.
|
|
51
51
|
*
|
|
52
52
|
* @category models
|
|
53
|
-
* @since 4.0
|
|
53
|
+
* @since 0.4.0
|
|
54
54
|
*/
|
|
55
55
|
export interface InitialEvent {
|
|
56
56
|
readonly _tag: typeof InitialEventTypeId;
|
|
@@ -59,14 +59,14 @@ export interface InitialEvent {
|
|
|
59
59
|
* Synthetic event value used while the machine settles its initial state.
|
|
60
60
|
*
|
|
61
61
|
* @category constructors
|
|
62
|
-
* @since 4.0
|
|
62
|
+
* @since 0.4.0
|
|
63
63
|
*/
|
|
64
64
|
export declare const InitialEvent: InitialEvent;
|
|
65
65
|
/**
|
|
66
66
|
* Returns `true` if a value is the synthetic machine initial event.
|
|
67
67
|
*
|
|
68
68
|
* @category guards
|
|
69
|
-
* @since 4.0
|
|
69
|
+
* @since 0.4.0
|
|
70
70
|
*/
|
|
71
71
|
export declare const isInitialEvent: (u: unknown) => u is InitialEvent;
|
|
72
72
|
type IsAny<A> = 0 extends (1 & A) ? true : false;
|
|
@@ -88,7 +88,7 @@ type IsAny<A> = 0 extends (1 & A) ? true : false;
|
|
|
88
88
|
* flow. Use `after` for cancellable state-scoped delayed events.
|
|
89
89
|
*
|
|
90
90
|
* @category models
|
|
91
|
-
* @since 4.0
|
|
91
|
+
* @since 0.4.0
|
|
92
92
|
*/
|
|
93
93
|
export interface Machine<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events> extends Pipeable {
|
|
94
94
|
readonly [TypeId]: TypeId;
|
|
@@ -99,37 +99,37 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
99
99
|
/**
|
|
100
100
|
* State tree that defines the machine topology and state value schemas.
|
|
101
101
|
*
|
|
102
|
-
* @since 4.0
|
|
102
|
+
* @since 0.4.0
|
|
103
103
|
*/
|
|
104
104
|
readonly states: States;
|
|
105
105
|
/**
|
|
106
106
|
* Events accepted through public machine input boundaries.
|
|
107
107
|
*
|
|
108
|
-
* @since 4.0
|
|
108
|
+
* @since 0.4.0
|
|
109
109
|
*/
|
|
110
110
|
readonly events: InputEvents;
|
|
111
111
|
/**
|
|
112
112
|
* Events reserved for invokes, child emissions, and other machine-local work.
|
|
113
113
|
*
|
|
114
|
-
* @since 4.0
|
|
114
|
+
* @since 0.4.0
|
|
115
115
|
*/
|
|
116
116
|
readonly internalEvents: ReadonlyArray<Machine.TaggedSchema>;
|
|
117
117
|
/**
|
|
118
118
|
* Events that the machine may emit to its parent or external adapter.
|
|
119
119
|
*
|
|
120
|
-
* @since 4.0
|
|
120
|
+
* @since 0.4.0
|
|
121
121
|
*/
|
|
122
122
|
readonly emits: Emits;
|
|
123
123
|
/**
|
|
124
124
|
* Optional schema used to decode the machine input before initialization.
|
|
125
125
|
*
|
|
126
|
-
* @since 4.0
|
|
126
|
+
* @since 0.4.0
|
|
127
127
|
*/
|
|
128
128
|
readonly input: Input | undefined;
|
|
129
129
|
/**
|
|
130
130
|
* Optional stable identity used by runtime and persistence integrations.
|
|
131
131
|
*
|
|
132
|
-
* @since 4.0
|
|
132
|
+
* @since 0.4.0
|
|
133
133
|
*/
|
|
134
134
|
readonly id: string | undefined;
|
|
135
135
|
/** @internal */
|
|
@@ -146,7 +146,7 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
146
146
|
* later mutation of the objects supplied to this call cannot alter the
|
|
147
147
|
* resulting machine.
|
|
148
148
|
*
|
|
149
|
-
* @since 4.0
|
|
149
|
+
* @since 0.4.0
|
|
150
150
|
*/
|
|
151
151
|
readonly handle: Machine.Handler<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents>;
|
|
152
152
|
/** @internal */
|
|
@@ -158,7 +158,7 @@ export {
|
|
|
158
158
|
* exists for the current machine.
|
|
159
159
|
*
|
|
160
160
|
* @category errors
|
|
161
|
-
* @since 4.0
|
|
161
|
+
* @since 0.4.0
|
|
162
162
|
*/
|
|
163
163
|
ChildAlreadyExistsError,
|
|
164
164
|
/**
|
|
@@ -166,7 +166,7 @@ ChildAlreadyExistsError,
|
|
|
166
166
|
* number of macrostep iterations.
|
|
167
167
|
*
|
|
168
168
|
* @category errors
|
|
169
|
-
* @since 4.0
|
|
169
|
+
* @since 0.4.0
|
|
170
170
|
*/
|
|
171
171
|
InfiniteTransitionError,
|
|
172
172
|
/**
|
|
@@ -174,7 +174,7 @@ InfiniteTransitionError,
|
|
|
174
174
|
* structural configuration declared for a machine boundary.
|
|
175
175
|
*
|
|
176
176
|
* @category errors
|
|
177
|
-
* @since 4.0
|
|
177
|
+
* @since 0.4.0
|
|
178
178
|
*/
|
|
179
179
|
MachineSchemaDecodeError,
|
|
180
180
|
/**
|
|
@@ -182,7 +182,7 @@ MachineSchemaDecodeError,
|
|
|
182
182
|
* its declared state or output schemas.
|
|
183
183
|
*
|
|
184
184
|
* @category errors
|
|
185
|
-
* @since 4.0
|
|
185
|
+
* @since 0.4.0
|
|
186
186
|
*/
|
|
187
187
|
MachineSchemaEncodeError,
|
|
188
188
|
/**
|
|
@@ -190,7 +190,7 @@ MachineSchemaEncodeError,
|
|
|
190
190
|
* requires a managed machine process.
|
|
191
191
|
*
|
|
192
192
|
* @category errors
|
|
193
|
-
* @since 4.0
|
|
193
|
+
* @since 0.4.0
|
|
194
194
|
*/
|
|
195
195
|
ProcessLocalError,
|
|
196
196
|
/**
|
|
@@ -198,7 +198,7 @@ ProcessLocalError,
|
|
|
198
198
|
* logic after the initial state has been computed.
|
|
199
199
|
*
|
|
200
200
|
* @category errors
|
|
201
|
-
* @since 4.0
|
|
201
|
+
* @since 0.4.0
|
|
202
202
|
*/
|
|
203
203
|
StartupError,
|
|
204
204
|
/**
|
|
@@ -206,7 +206,7 @@ StartupError,
|
|
|
206
206
|
* producing an output.
|
|
207
207
|
*
|
|
208
208
|
* @category errors
|
|
209
|
-
* @since 4.0
|
|
209
|
+
* @since 0.4.0
|
|
210
210
|
*/
|
|
211
211
|
StoppedError } from "./internal/machine/machine.js";
|
|
212
212
|
declare const RuntimeRequirementTypeId = "~effect/Machine/RuntimeRequirement";
|
|
@@ -217,7 +217,7 @@ type MachineRuntimeRequirement = internalRuntime.MachineRuntime;
|
|
|
217
217
|
* the Effect that plans a machine step.
|
|
218
218
|
*
|
|
219
219
|
* @category services
|
|
220
|
-
* @since 4.0
|
|
220
|
+
* @since 0.4.0
|
|
221
221
|
*/
|
|
222
222
|
export interface ActionRequirement<Error, Requirements> {
|
|
223
223
|
readonly [ActionRequirementTypeId]: {
|
|
@@ -229,47 +229,47 @@ export interface ActionRequirement<Error, Requirements> {
|
|
|
229
229
|
* Extracts the typed error channel of staged machine actions.
|
|
230
230
|
*
|
|
231
231
|
* @category utility types
|
|
232
|
-
* @since 4.0
|
|
232
|
+
* @since 0.4.0
|
|
233
233
|
*/
|
|
234
234
|
export type ActionError<Requirements> = Requirements extends ActionRequirement<infer Error, any> ? Error : never;
|
|
235
235
|
/**
|
|
236
236
|
* Extracts the service requirements of staged machine actions.
|
|
237
237
|
*
|
|
238
238
|
* @category utility types
|
|
239
|
-
* @since 4.0
|
|
239
|
+
* @since 0.4.0
|
|
240
240
|
*/
|
|
241
241
|
export type ActionServices<Requirements> = Requirements extends ActionRequirement<any, infer Services> ? Services : never;
|
|
242
242
|
/**
|
|
243
243
|
* Removes staged action requirements from machine planning services.
|
|
244
244
|
*
|
|
245
245
|
* @category utility types
|
|
246
|
-
* @since 4.0
|
|
246
|
+
* @since 0.4.0
|
|
247
247
|
*/
|
|
248
248
|
export type PlanningServices<Requirements> = Exclude<Requirements, ActionRequirement<any, any>>;
|
|
249
249
|
/**
|
|
250
250
|
* Resolves all services needed to execute a machine at runtime.
|
|
251
251
|
*
|
|
252
252
|
* @category utility types
|
|
253
|
-
* @since 4.0
|
|
253
|
+
* @since 0.4.0
|
|
254
254
|
*/
|
|
255
255
|
export type ExecutionServices<Requirements> = Exclude<PlanningServices<Requirements>, MachineRuntimeRequirement> | Exclude<ActionServices<Requirements>, MachineRuntimeRequirement>;
|
|
256
256
|
/**
|
|
257
257
|
* Managed runtime capability used to deliver raised and emitted events.
|
|
258
258
|
*
|
|
259
259
|
* @category models
|
|
260
|
-
* @since 4.0
|
|
260
|
+
* @since 0.4.0
|
|
261
261
|
*/
|
|
262
262
|
export interface Runtime<in Events, in Emits> {
|
|
263
263
|
/**
|
|
264
264
|
* Queues an event for the current machine macrostep.
|
|
265
265
|
*
|
|
266
|
-
* @since 4.0
|
|
266
|
+
* @since 0.4.0
|
|
267
267
|
*/
|
|
268
268
|
readonly raise: (event: Events) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
269
269
|
/**
|
|
270
270
|
* Emits an event through the running machine's parent boundary.
|
|
271
271
|
*
|
|
272
|
-
* @since 4.0
|
|
272
|
+
* @since 0.4.0
|
|
273
273
|
*/
|
|
274
274
|
readonly sendParent: (event: Emits) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
275
275
|
}
|
|
@@ -279,7 +279,7 @@ export interface Runtime<in Events, in Emits> {
|
|
|
279
279
|
* executes an Effect.
|
|
280
280
|
*
|
|
281
281
|
* @category models
|
|
282
|
-
* @since 4.0
|
|
282
|
+
* @since 0.4.0
|
|
283
283
|
*/
|
|
284
284
|
export interface Enqueue<in Events, in Emits> {
|
|
285
285
|
/** Raises an event inside the current macrostep. */
|
|
@@ -297,7 +297,12 @@ export interface Enqueue<in Events, in Emits> {
|
|
|
297
297
|
<Event>(child: ChildAddress<Event>): void;
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
|
-
/**
|
|
300
|
+
/**
|
|
301
|
+
* A closed actor command recorded by a synchronous machine transition.
|
|
302
|
+
*
|
|
303
|
+
* @category models
|
|
304
|
+
* @since 0.4.0
|
|
305
|
+
*/
|
|
301
306
|
export type Command = {
|
|
302
307
|
readonly _tag: "SendTo";
|
|
303
308
|
readonly child: ChildMachine.Any | ChildAddress<never>;
|
|
@@ -309,14 +314,15 @@ export type Command = {
|
|
|
309
314
|
/**
|
|
310
315
|
* Namespace containing type-level members associated with `Runtime`.
|
|
311
316
|
*
|
|
312
|
-
* @
|
|
317
|
+
* @category models
|
|
318
|
+
* @since 0.4.0
|
|
313
319
|
*/
|
|
314
320
|
export declare namespace Runtime {
|
|
315
321
|
/**
|
|
316
322
|
* Protocol annotation for managed event delivery.
|
|
317
323
|
*
|
|
318
324
|
* @category models
|
|
319
|
-
* @since 4.0
|
|
325
|
+
* @since 0.4.0
|
|
320
326
|
*/
|
|
321
327
|
interface Protocol {
|
|
322
328
|
readonly events?: unknown;
|
|
@@ -326,7 +332,7 @@ export declare namespace Runtime {
|
|
|
326
332
|
* Extracts the events required by a runtime protocol annotation.
|
|
327
333
|
*
|
|
328
334
|
* @category utility types
|
|
329
|
-
* @since 4.0
|
|
335
|
+
* @since 0.4.0
|
|
330
336
|
*/
|
|
331
337
|
type Events<Protocol> = Protocol extends {
|
|
332
338
|
readonly events: infer Events;
|
|
@@ -335,7 +341,7 @@ export declare namespace Runtime {
|
|
|
335
341
|
* Extracts the emitted events required by a runtime protocol annotation.
|
|
336
342
|
*
|
|
337
343
|
* @category utility types
|
|
338
|
-
* @since 4.0
|
|
344
|
+
* @since 0.4.0
|
|
339
345
|
*/
|
|
340
346
|
type Emits<Protocol> = Protocol extends {
|
|
341
347
|
readonly emits: infer Emits;
|
|
@@ -344,7 +350,7 @@ export declare namespace Runtime {
|
|
|
344
350
|
* Opaque service requirement for a machine runtime capability.
|
|
345
351
|
*
|
|
346
352
|
* @category services
|
|
347
|
-
* @since 4.0
|
|
353
|
+
* @since 0.4.0
|
|
348
354
|
*/
|
|
349
355
|
interface Requirement<Events, Emits> {
|
|
350
356
|
readonly [RuntimeRequirementTypeId]: {
|
|
@@ -471,7 +477,7 @@ type FromMethod<Arguments extends ReadonlyArray<unknown>, Result> = {
|
|
|
471
477
|
* machine plans the resulting configuration. The input may be omitted when
|
|
472
478
|
* the schema accepts an empty constructor object.
|
|
473
479
|
*
|
|
474
|
-
* @since 4.0
|
|
480
|
+
* @since 0.4.0
|
|
475
481
|
*/
|
|
476
482
|
readonly from: FromCallable<Arguments, Machine.StateConstruction<Result>>;
|
|
477
483
|
};
|
|
@@ -675,7 +681,7 @@ type LocalTargetBuilderForScope<States extends Machine.StateSchemas, Scope exten
|
|
|
675
681
|
* Updates the value of the state containing the local group and moves to
|
|
676
682
|
* one of the states inside it. Values in other active branches are kept.
|
|
677
683
|
*
|
|
678
|
-
* @since 4.0
|
|
684
|
+
* @since 0.4.0
|
|
679
685
|
*/
|
|
680
686
|
readonly with: (<Result extends ConstructionResult<LocalTargetResultWithPrefix<States, Children, Scope>>>(value: Machine.StateByIdentifier<States, Scope>, state: (builder: LocalTargetBuilderWithPrefix<States, Children, Scope, Source>) => Result) => Result) & {
|
|
681
687
|
readonly from: ConstructionSelectorFromCallable<Machine.SchemaByIdentifier<States, Scope>["~type.make.in"], LocalTargetBuilderWithPrefix<States, Children, Scope, Source>, LocalTargetResultWithPrefix<States, Children, Scope>>;
|
|
@@ -760,7 +766,7 @@ type SpawnResult<State, Event, Error, Requirements, Output, SpawnError, InitialE
|
|
|
760
766
|
* with output or fail while processing an event.
|
|
761
767
|
*
|
|
762
768
|
* @category models
|
|
763
|
-
* @since 4.0
|
|
769
|
+
* @since 0.4.0
|
|
764
770
|
*/
|
|
765
771
|
export type RuntimeSnapshot<State, Error = never, Output = never> = {
|
|
766
772
|
readonly status: "active";
|
|
@@ -781,7 +787,7 @@ export type RuntimeSnapshot<State, Error = never, Output = never> = {
|
|
|
781
787
|
* Represents a classified terminal outcome derived from a runtime snapshot.
|
|
782
788
|
*
|
|
783
789
|
* @category models
|
|
784
|
-
* @since 4.0
|
|
790
|
+
* @since 0.4.0
|
|
785
791
|
*/
|
|
786
792
|
export type RuntimeOutcome<State, Error = never, Output = never> = {
|
|
787
793
|
readonly _tag: "Done";
|
|
@@ -833,7 +839,7 @@ export type RuntimeOutcome<State, Error = never, Output = never> = {
|
|
|
833
839
|
* `StoppedError`.
|
|
834
840
|
*
|
|
835
841
|
* @category models
|
|
836
|
-
* @since 4.0
|
|
842
|
+
* @since 0.4.0
|
|
837
843
|
*/
|
|
838
844
|
export interface MachineRef<out State, in Event, out Error = never, out Output = never> {
|
|
839
845
|
/** Stable machine definition id, or a generated fallback when none was declared. */
|
|
@@ -855,13 +861,13 @@ export interface MachineRef<out State, in Event, out Error = never, out Output =
|
|
|
855
861
|
/**
|
|
856
862
|
* Returns the current directly owned child for a typed descriptor.
|
|
857
863
|
*
|
|
858
|
-
* @since 4.0
|
|
864
|
+
* @since 0.4.0
|
|
859
865
|
*/
|
|
860
866
|
readonly child: <Child extends ChildMachine.Any>(child: Child) => Effect.Effect<Option.Option<ChildMachine.Ref<Child>>>;
|
|
861
867
|
/**
|
|
862
868
|
* Streams activation, replacement, and removal of a directly owned child.
|
|
863
869
|
*
|
|
864
|
-
* @since 4.0
|
|
870
|
+
* @since 0.4.0
|
|
865
871
|
*/
|
|
866
872
|
readonly childChanges: <Child extends ChildMachine.Any>(child: Child) => Stream.Stream<Option.Option<ChildMachine.Ref<Child>>>;
|
|
867
873
|
}
|
|
@@ -869,7 +875,7 @@ export interface MachineRef<out State, in Event, out Error = never, out Output =
|
|
|
869
875
|
* Machine-specific process logic used by `spawn` and `invoke`.
|
|
870
876
|
*
|
|
871
877
|
* @category models
|
|
872
|
-
* @since 4.0
|
|
878
|
+
* @since 0.4.0
|
|
873
879
|
*/
|
|
874
880
|
export interface Logic<State, Event, out Error = never, out Requirements = never, out Output = never, out InitialError = never> {
|
|
875
881
|
/** Creates the initial process state and may spawn scoped child processes. */
|
|
@@ -880,14 +886,15 @@ export interface Logic<State, Event, out Error = never, out Requirements = never
|
|
|
880
886
|
/**
|
|
881
887
|
* Public types used by advanced machine process logic.
|
|
882
888
|
*
|
|
883
|
-
* @
|
|
889
|
+
* @category models
|
|
890
|
+
* @since 0.4.0
|
|
884
891
|
*/
|
|
885
892
|
export declare namespace Logic {
|
|
886
893
|
/**
|
|
887
894
|
* Machine-local endpoint that can receive events and be stopped.
|
|
888
895
|
*
|
|
889
896
|
* @category models
|
|
890
|
-
* @since 4.0
|
|
897
|
+
* @since 0.4.0
|
|
891
898
|
*/
|
|
892
899
|
interface Address<in Event> {
|
|
893
900
|
/** Parent-local address id. */
|
|
@@ -903,7 +910,7 @@ export declare namespace Logic {
|
|
|
903
910
|
* Starts child process logic owned by the current machine process.
|
|
904
911
|
*
|
|
905
912
|
* @category models
|
|
906
|
-
* @since 4.0
|
|
913
|
+
* @since 0.4.0
|
|
907
914
|
*/
|
|
908
915
|
interface Spawn {
|
|
909
916
|
<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError = never>(logic: Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>): Effect.Effect<MachineRef<ChildState, ChildEvent, ChildError, ChildOutput>, ChildInitialError, Exclude<ChildRequirements, Scope.Scope>>;
|
|
@@ -919,7 +926,7 @@ export declare namespace Logic {
|
|
|
919
926
|
* invoke snapshot mapper when either can represent the communication.
|
|
920
927
|
*
|
|
921
928
|
* @category models
|
|
922
|
-
* @since 4.0
|
|
929
|
+
* @since 0.4.0
|
|
923
930
|
*/
|
|
924
931
|
interface Scope<Event> {
|
|
925
932
|
/** Address of the process being initialized. */
|
|
@@ -939,7 +946,7 @@ export declare namespace Logic {
|
|
|
939
946
|
* Machine-local capabilities available while stateful process logic runs.
|
|
940
947
|
*
|
|
941
948
|
* @category models
|
|
942
|
-
* @since 4.0
|
|
949
|
+
* @since 0.4.0
|
|
943
950
|
*/
|
|
944
951
|
interface Context<State, Event> extends Scope<Event> {
|
|
945
952
|
/** Waits for the next event delivered to this process. */
|
|
@@ -968,7 +975,7 @@ type InvokeLifecycleId = string & {
|
|
|
968
975
|
* event, error, and output types are inferred without separate annotations.
|
|
969
976
|
*
|
|
970
977
|
* @category models
|
|
971
|
-
* @since 4.0
|
|
978
|
+
* @since 0.4.0
|
|
972
979
|
*/
|
|
973
980
|
export interface ChildMachine<Id extends string, M extends Machine.Any> {
|
|
974
981
|
readonly [ChildMachineTypeId]: typeof ChildMachineTypeId;
|
|
@@ -980,28 +987,29 @@ export interface ChildMachine<Id extends string, M extends Machine.Any> {
|
|
|
980
987
|
/**
|
|
981
988
|
* Namespace containing type-level members associated with `ChildMachine`.
|
|
982
989
|
*
|
|
983
|
-
* @
|
|
990
|
+
* @category models
|
|
991
|
+
* @since 0.4.0
|
|
984
992
|
*/
|
|
985
993
|
export declare namespace ChildMachine {
|
|
986
994
|
/**
|
|
987
995
|
* Any typed child machine descriptor.
|
|
988
996
|
*
|
|
989
997
|
* @category models
|
|
990
|
-
* @since 4.0
|
|
998
|
+
* @since 0.4.0
|
|
991
999
|
*/
|
|
992
1000
|
type Any = ChildMachine<string, Machine.Any>;
|
|
993
1001
|
/**
|
|
994
1002
|
* Running machine reference selected by a child descriptor.
|
|
995
1003
|
*
|
|
996
1004
|
* @category utility types
|
|
997
|
-
* @since 4.0
|
|
1005
|
+
* @since 0.4.0
|
|
998
1006
|
*/
|
|
999
1007
|
type Ref<Child> = Child extends ChildMachine<string, infer M> ? MachineRef<Machine.Snapshot<Machine.States<M>>, Machine.InputEvent<M>, Machine.Error<M> | ActionError<Machine.Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Machine.Output<M>> : never;
|
|
1000
1008
|
/**
|
|
1001
1009
|
* Event accepted by the child selected by a descriptor.
|
|
1002
1010
|
*
|
|
1003
1011
|
* @category utility types
|
|
1004
|
-
* @since 4.0
|
|
1012
|
+
* @since 0.4.0
|
|
1005
1013
|
*/
|
|
1006
1014
|
type Event<Child> = Ref<Child> extends MachineRef<any, infer Event, any, any> ? Event : never;
|
|
1007
1015
|
}
|
|
@@ -1009,20 +1017,21 @@ export declare namespace ChildMachine {
|
|
|
1009
1017
|
* Parent-local address for a child process that can receive events.
|
|
1010
1018
|
*
|
|
1011
1019
|
* @category models
|
|
1012
|
-
* @since 4.0
|
|
1020
|
+
* @since 0.4.0
|
|
1013
1021
|
*/
|
|
1014
1022
|
export type ChildAddress<Event> = string & ChildAddress.Variance<Event>;
|
|
1015
1023
|
/**
|
|
1016
1024
|
* Namespace containing type-level members associated with `ChildAddress`.
|
|
1017
1025
|
*
|
|
1018
|
-
* @
|
|
1026
|
+
* @category models
|
|
1027
|
+
* @since 0.4.0
|
|
1019
1028
|
*/
|
|
1020
1029
|
export declare namespace ChildAddress {
|
|
1021
1030
|
/**
|
|
1022
1031
|
* Variance marker carried by a typed child process address.
|
|
1023
1032
|
*
|
|
1024
1033
|
* @category models
|
|
1025
|
-
* @since 4.0
|
|
1034
|
+
* @since 0.4.0
|
|
1026
1035
|
*/
|
|
1027
1036
|
interface Variance<in Event> {
|
|
1028
1037
|
readonly [ChildAddressTypeId]: {
|
|
@@ -1033,7 +1042,7 @@ export declare namespace ChildAddress {
|
|
|
1033
1042
|
* Extracts the event protocol accepted by a child address.
|
|
1034
1043
|
*
|
|
1035
1044
|
* @category utility types
|
|
1036
|
-
* @since 4.0
|
|
1045
|
+
* @since 0.4.0
|
|
1037
1046
|
*/
|
|
1038
1047
|
type Event<Address> = Address extends ChildAddress<infer Event> ? Event : unknown;
|
|
1039
1048
|
/**
|
|
@@ -1041,7 +1050,7 @@ export declare namespace ChildAddress {
|
|
|
1041
1050
|
* protocol.
|
|
1042
1051
|
*
|
|
1043
1052
|
* @category utility types
|
|
1044
|
-
* @since 4.0
|
|
1053
|
+
* @since 0.4.0
|
|
1045
1054
|
*/
|
|
1046
1055
|
type Compatibility<Address, Event> = [Address] extends [ChildAddress<infer AddressEvent>] ? [
|
|
1047
1056
|
AddressEvent
|
|
@@ -1056,7 +1065,7 @@ export declare namespace ChildAddress {
|
|
|
1056
1065
|
* child process event protocol.
|
|
1057
1066
|
*
|
|
1058
1067
|
* @category utility types
|
|
1059
|
-
* @since 4.0
|
|
1068
|
+
* @since 0.4.0
|
|
1060
1069
|
*/
|
|
1061
1070
|
type OptionsCompatibility<Options, Event> = "id" extends keyof Options ? Options extends {
|
|
1062
1071
|
readonly id?: infer Address;
|
|
@@ -1066,7 +1075,7 @@ export declare namespace ChildAddress {
|
|
|
1066
1075
|
* Options for spawning child processes.
|
|
1067
1076
|
*
|
|
1068
1077
|
* @category models
|
|
1069
|
-
* @since 4.0
|
|
1078
|
+
* @since 0.4.0
|
|
1070
1079
|
*/
|
|
1071
1080
|
export interface SpawnOptions {
|
|
1072
1081
|
readonly id?: string;
|
|
@@ -1075,7 +1084,7 @@ export interface SpawnOptions {
|
|
|
1075
1084
|
* Options for spawning child processes with a parent-local id.
|
|
1076
1085
|
*
|
|
1077
1086
|
* @category models
|
|
1078
|
-
* @since 4.0
|
|
1087
|
+
* @since 0.4.0
|
|
1079
1088
|
*/
|
|
1080
1089
|
export interface SpawnIdOptions extends SpawnOptions {
|
|
1081
1090
|
readonly id: string;
|
|
@@ -1083,7 +1092,8 @@ export interface SpawnIdOptions extends SpawnOptions {
|
|
|
1083
1092
|
/**
|
|
1084
1093
|
* Namespace containing type-level members associated with `Machine`.
|
|
1085
1094
|
*
|
|
1086
|
-
* @
|
|
1095
|
+
* @category models
|
|
1096
|
+
* @since 0.4.0
|
|
1087
1097
|
*/
|
|
1088
1098
|
export declare namespace Machine {
|
|
1089
1099
|
/**
|
|
@@ -1116,7 +1126,7 @@ export declare namespace Machine {
|
|
|
1116
1126
|
* that proof on another concrete `Machine` type.
|
|
1117
1127
|
*
|
|
1118
1128
|
* @category models
|
|
1119
|
-
* @since 4.0
|
|
1129
|
+
* @since 0.4.0
|
|
1120
1130
|
*/
|
|
1121
1131
|
interface Any extends Pipeable {
|
|
1122
1132
|
readonly [TypeId]: TypeId;
|
|
@@ -1143,112 +1153,112 @@ export declare namespace Machine {
|
|
|
1143
1153
|
* Extracts the state schema tree carried by a machine definition.
|
|
1144
1154
|
*
|
|
1145
1155
|
* @category utility types
|
|
1146
|
-
* @since 4.0
|
|
1156
|
+
* @since 0.4.0
|
|
1147
1157
|
*/
|
|
1148
1158
|
type States<M extends Any> = M[typeof MachineTypeId]["states"];
|
|
1149
1159
|
/**
|
|
1150
1160
|
* Extracts the complete event schema tuple carried by a machine definition.
|
|
1151
1161
|
*
|
|
1152
1162
|
* @category utility types
|
|
1153
|
-
* @since 4.0
|
|
1163
|
+
* @since 0.4.0
|
|
1154
1164
|
*/
|
|
1155
1165
|
type Events<M extends Any> = M[typeof MachineTypeId]["events"];
|
|
1156
1166
|
/**
|
|
1157
1167
|
* Extracts the input schema carried by a machine definition.
|
|
1158
1168
|
*
|
|
1159
1169
|
* @category utility types
|
|
1160
|
-
* @since 4.0
|
|
1170
|
+
* @since 0.4.0
|
|
1161
1171
|
*/
|
|
1162
1172
|
type Input<M extends Any> = M[typeof MachineTypeId]["input"];
|
|
1163
1173
|
/**
|
|
1164
1174
|
* Extracts state paths that do not yet have handlers.
|
|
1165
1175
|
*
|
|
1166
1176
|
* @category utility types
|
|
1167
|
-
* @since 4.0
|
|
1177
|
+
* @since 0.4.0
|
|
1168
1178
|
*/
|
|
1169
1179
|
type UnhandledStates<M extends Any> = M[typeof MachineTypeId]["unhandledStates"];
|
|
1170
1180
|
/**
|
|
1171
1181
|
* Extracts the runtime error channel carried by a machine definition.
|
|
1172
1182
|
*
|
|
1173
1183
|
* @category utility types
|
|
1174
|
-
* @since 4.0
|
|
1184
|
+
* @since 0.4.0
|
|
1175
1185
|
*/
|
|
1176
1186
|
type Error<M extends Any> = M[typeof MachineTypeId]["error"];
|
|
1177
1187
|
/**
|
|
1178
1188
|
* Extracts runtime service requirements carried by a machine definition.
|
|
1179
1189
|
*
|
|
1180
1190
|
* @category utility types
|
|
1181
|
-
* @since 4.0
|
|
1191
|
+
* @since 0.4.0
|
|
1182
1192
|
*/
|
|
1183
1193
|
type Services<M extends Any> = M[typeof MachineTypeId]["services"];
|
|
1184
1194
|
/**
|
|
1185
1195
|
* Extracts the startup error channel carried by a machine definition.
|
|
1186
1196
|
*
|
|
1187
1197
|
* @category utility types
|
|
1188
|
-
* @since 4.0
|
|
1198
|
+
* @since 0.4.0
|
|
1189
1199
|
*/
|
|
1190
1200
|
type InitialError<M extends Any> = M[typeof MachineTypeId]["initialError"];
|
|
1191
1201
|
/**
|
|
1192
1202
|
* Extracts startup service requirements carried by a machine definition.
|
|
1193
1203
|
*
|
|
1194
1204
|
* @category utility types
|
|
1195
|
-
* @since 4.0
|
|
1205
|
+
* @since 0.4.0
|
|
1196
1206
|
*/
|
|
1197
1207
|
type InitialServices<M extends Any> = M[typeof MachineTypeId]["initialServices"];
|
|
1198
1208
|
/**
|
|
1199
1209
|
* Extracts final state paths carried by a machine definition.
|
|
1200
1210
|
*
|
|
1201
1211
|
* @category utility types
|
|
1202
|
-
* @since 4.0
|
|
1212
|
+
* @since 0.4.0
|
|
1203
1213
|
*/
|
|
1204
1214
|
type FinalStates<M extends Any> = M[typeof MachineTypeId]["finalStates"];
|
|
1205
1215
|
/**
|
|
1206
1216
|
* Extracts the terminal output channel carried by a machine definition.
|
|
1207
1217
|
*
|
|
1208
1218
|
* @category utility types
|
|
1209
|
-
* @since 4.0
|
|
1219
|
+
* @since 0.4.0
|
|
1210
1220
|
*/
|
|
1211
1221
|
type Output<M extends Any> = M[typeof MachineTypeId]["output"];
|
|
1212
1222
|
/**
|
|
1213
1223
|
* Extracts the emitted event schema tuple carried by a machine definition.
|
|
1214
1224
|
*
|
|
1215
1225
|
* @category utility types
|
|
1216
|
-
* @since 4.0
|
|
1226
|
+
* @since 0.4.0
|
|
1217
1227
|
*/
|
|
1218
1228
|
type Emits<M extends Any> = M[typeof MachineTypeId]["emits"];
|
|
1219
1229
|
/**
|
|
1220
1230
|
* Extracts state paths with implemented output handlers.
|
|
1221
1231
|
*
|
|
1222
1232
|
* @category utility types
|
|
1223
|
-
* @since 4.0
|
|
1233
|
+
* @since 0.4.0
|
|
1224
1234
|
*/
|
|
1225
1235
|
type OutputStates<M extends Any> = M[typeof MachineTypeId]["outputStates"];
|
|
1226
1236
|
/**
|
|
1227
1237
|
* Extracts the public input event schema tuple carried by a machine definition.
|
|
1228
1238
|
*
|
|
1229
1239
|
* @category utility types
|
|
1230
|
-
* @since 4.0
|
|
1240
|
+
* @since 0.4.0
|
|
1231
1241
|
*/
|
|
1232
1242
|
type InputEvents<M extends Any> = M[typeof MachineTypeId]["inputEvents"];
|
|
1233
1243
|
/**
|
|
1234
1244
|
* Extracts the complete event protocol handled inside a machine.
|
|
1235
1245
|
*
|
|
1236
1246
|
* @category utility types
|
|
1237
|
-
* @since 4.0
|
|
1247
|
+
* @since 0.4.0
|
|
1238
1248
|
*/
|
|
1239
1249
|
type Event<M extends Any> = EventOf<Events<M>>;
|
|
1240
1250
|
/**
|
|
1241
1251
|
* Extracts the event protocol accepted by public machine input boundaries.
|
|
1242
1252
|
*
|
|
1243
1253
|
* @category utility types
|
|
1244
|
-
* @since 4.0
|
|
1254
|
+
* @since 0.4.0
|
|
1245
1255
|
*/
|
|
1246
1256
|
type InputEvent<M extends Any> = EventOf<InputEvents<M>>;
|
|
1247
1257
|
/**
|
|
1248
1258
|
* Extracts the event protocol emitted by a machine.
|
|
1249
1259
|
*
|
|
1250
1260
|
* @category utility types
|
|
1251
|
-
* @since 4.0
|
|
1261
|
+
* @since 0.4.0
|
|
1252
1262
|
*/
|
|
1253
1263
|
type Emit<M extends Any> = EmitOf<Emits<M>>;
|
|
1254
1264
|
/**
|
|
@@ -1259,7 +1269,7 @@ export declare namespace Machine {
|
|
|
1259
1269
|
* This mirrors the tagged-schema constraint used by `Schema.toTaggedUnion`.
|
|
1260
1270
|
*
|
|
1261
1271
|
* @category models
|
|
1262
|
-
* @since 4.0
|
|
1272
|
+
* @since 0.4.0
|
|
1263
1273
|
*/
|
|
1264
1274
|
type TaggedSchema = Schema.Top & {
|
|
1265
1275
|
readonly Type: {
|
|
@@ -1274,7 +1284,7 @@ export declare namespace Machine {
|
|
|
1274
1284
|
* affect state identity, targeting, or runtime behavior.
|
|
1275
1285
|
*
|
|
1276
1286
|
* @category models
|
|
1277
|
-
* @since 4.0
|
|
1287
|
+
* @since 0.4.0
|
|
1278
1288
|
*/
|
|
1279
1289
|
interface StateNodeAnnotations extends Schema.Annotations.Annotations {
|
|
1280
1290
|
readonly title?: string | undefined;
|
|
@@ -1287,7 +1297,7 @@ export declare namespace Machine {
|
|
|
1287
1297
|
* Configuration accepted for an atomic object state node.
|
|
1288
1298
|
*
|
|
1289
1299
|
* @category models
|
|
1290
|
-
* @since 4.0
|
|
1300
|
+
* @since 0.4.0
|
|
1291
1301
|
*/
|
|
1292
1302
|
type AtomicStateNodeConfig = {
|
|
1293
1303
|
readonly schema: TaggedSchema;
|
|
@@ -1302,7 +1312,7 @@ export declare namespace Machine {
|
|
|
1302
1312
|
* Configuration accepted for a compound object state node.
|
|
1303
1313
|
*
|
|
1304
1314
|
* @category models
|
|
1305
|
-
* @since 4.0
|
|
1315
|
+
* @since 0.4.0
|
|
1306
1316
|
*/
|
|
1307
1317
|
interface CompoundStateNodeConfig {
|
|
1308
1318
|
readonly schema: TaggedSchema;
|
|
@@ -1314,7 +1324,7 @@ export declare namespace Machine {
|
|
|
1314
1324
|
* Configuration accepted for a parallel object state node.
|
|
1315
1325
|
*
|
|
1316
1326
|
* @category models
|
|
1317
|
-
* @since 4.0
|
|
1327
|
+
* @since 0.4.0
|
|
1318
1328
|
*/
|
|
1319
1329
|
interface ParallelStateNodeConfig {
|
|
1320
1330
|
readonly schema: TaggedSchema;
|
|
@@ -1332,7 +1342,7 @@ export declare namespace Machine {
|
|
|
1332
1342
|
* history owner, so its validity is independent of the transition source.
|
|
1333
1343
|
*
|
|
1334
1344
|
* @category models
|
|
1335
|
-
* @since 4.0
|
|
1345
|
+
* @since 0.4.0
|
|
1336
1346
|
*/
|
|
1337
1347
|
interface HistoryStateNodeConfig {
|
|
1338
1348
|
readonly type: "history";
|
|
@@ -1348,7 +1358,7 @@ export declare namespace Machine {
|
|
|
1348
1358
|
* Effect to select a typed target.
|
|
1349
1359
|
*
|
|
1350
1360
|
* @category models
|
|
1351
|
-
* @since 4.0
|
|
1361
|
+
* @since 0.4.0
|
|
1352
1362
|
*/
|
|
1353
1363
|
interface ChoiceStateNodeConfig {
|
|
1354
1364
|
readonly type: "choice";
|
|
@@ -1358,7 +1368,7 @@ export declare namespace Machine {
|
|
|
1358
1368
|
* Configuration accepted for an object state node.
|
|
1359
1369
|
*
|
|
1360
1370
|
* @category models
|
|
1361
|
-
* @since 4.0
|
|
1371
|
+
* @since 0.4.0
|
|
1362
1372
|
*/
|
|
1363
1373
|
type StateNodeConfig = AtomicStateNodeConfig | CompoundStateNodeConfig | ParallelStateNodeConfig | HistoryStateNodeConfig | ChoiceStateNodeConfig;
|
|
1364
1374
|
/**
|
|
@@ -1368,14 +1378,14 @@ export declare namespace Machine {
|
|
|
1368
1378
|
* prototype-mutating key `__proto__` and symbol keys are not accepted.
|
|
1369
1379
|
*
|
|
1370
1380
|
* @category models
|
|
1371
|
-
* @since 4.0
|
|
1381
|
+
* @since 0.4.0
|
|
1372
1382
|
*/
|
|
1373
1383
|
type StateTree = Readonly<Record<string, TaggedSchema | StateNodeConfig>>;
|
|
1374
1384
|
/**
|
|
1375
1385
|
* State schema definitions accepted by `make`.
|
|
1376
1386
|
*
|
|
1377
1387
|
* @category models
|
|
1378
|
-
* @since 4.0
|
|
1388
|
+
* @since 0.4.0
|
|
1379
1389
|
*/
|
|
1380
1390
|
type StateSchemas = StateTree;
|
|
1381
1391
|
/**
|
|
@@ -1392,7 +1402,7 @@ export declare namespace Machine {
|
|
|
1392
1402
|
* require every direct region for parallel states.
|
|
1393
1403
|
*
|
|
1394
1404
|
* @category utility types
|
|
1395
|
-
* @since 4.0
|
|
1405
|
+
* @since 0.4.0
|
|
1396
1406
|
*/
|
|
1397
1407
|
type InitialBuilder<States extends StateSchemas> = InitialSnapshotBuilderWithPrefix<States>;
|
|
1398
1408
|
/**
|
|
@@ -1405,7 +1415,7 @@ export declare namespace Machine {
|
|
|
1405
1415
|
* state tree.
|
|
1406
1416
|
*
|
|
1407
1417
|
* @category models
|
|
1408
|
-
* @since 4.0
|
|
1418
|
+
* @since 0.4.0
|
|
1409
1419
|
*/
|
|
1410
1420
|
interface DefinedStates<States extends StateSchemas> {
|
|
1411
1421
|
/** Original state tree supplied to {@link defineStates}. */
|
|
@@ -1415,7 +1425,7 @@ export declare namespace Machine {
|
|
|
1415
1425
|
/**
|
|
1416
1426
|
* Returns the decoded value for an active state path.
|
|
1417
1427
|
*
|
|
1418
|
-
* @since 4.0
|
|
1428
|
+
* @since 0.4.0
|
|
1419
1429
|
*/
|
|
1420
1430
|
readonly get: <Path extends StateIdentifier<States>>(snapshot: Snapshot<States>, path: Path) => Option.Option<StateByIdentifier<States, Path>>;
|
|
1421
1431
|
/**
|
|
@@ -1426,19 +1436,19 @@ export declare namespace Machine {
|
|
|
1426
1436
|
*
|
|
1427
1437
|
* Parent values are keyed by their full state paths.
|
|
1428
1438
|
*
|
|
1429
|
-
* @since 4.0
|
|
1439
|
+
* @since 0.4.0
|
|
1430
1440
|
*/
|
|
1431
1441
|
readonly getWithParents: <Path extends StateIdentifier<States>>(snapshot: Snapshot<States>, path: Path) => Option.Option<StateWithParents<States, Path>>;
|
|
1432
1442
|
/**
|
|
1433
1443
|
* Returns the snapshot for an active state path.
|
|
1434
1444
|
*
|
|
1435
|
-
* @since 4.0
|
|
1445
|
+
* @since 0.4.0
|
|
1436
1446
|
*/
|
|
1437
1447
|
readonly getSnapshot: <Path extends StateIdentifier<States>>(snapshot: Snapshot<States>, path: Path) => Option.Option<SnapshotByIdentifier<States, Path>>;
|
|
1438
1448
|
/**
|
|
1439
1449
|
* Returns whether a state path is active in the snapshot.
|
|
1440
1450
|
*
|
|
1441
|
-
* @since 4.0
|
|
1451
|
+
* @since 0.4.0
|
|
1442
1452
|
*/
|
|
1443
1453
|
readonly matches: <Path extends StateIdentifier<States>>(snapshot: Snapshot<States>, path: Path) => boolean;
|
|
1444
1454
|
}
|
|
@@ -1446,7 +1456,7 @@ export declare namespace Machine {
|
|
|
1446
1456
|
* Validates the nested shape of state schema definitions.
|
|
1447
1457
|
*
|
|
1448
1458
|
* @category utility types
|
|
1449
|
-
* @since 4.0
|
|
1459
|
+
* @since 0.4.0
|
|
1450
1460
|
*/
|
|
1451
1461
|
type ValidateStateSchemas<States extends StateSchemas> = ValidateStateTree<States>;
|
|
1452
1462
|
/** Properties shared by every compiled state-node variant. */
|
|
@@ -1526,7 +1536,7 @@ export declare namespace Machine {
|
|
|
1526
1536
|
* property while preserving a uniform inspection shape.
|
|
1527
1537
|
*
|
|
1528
1538
|
* @category models
|
|
1529
|
-
* @since 4.0
|
|
1539
|
+
* @since 0.4.0
|
|
1530
1540
|
*/
|
|
1531
1541
|
type ActiveStateNode<ActivePath extends string = string, ChoicePath extends string = ActivePath> = AtomicStateNode<ActivePath, ActivePath> | CompoundStateNode<ActivePath, ActivePath, ChoicePath> | ParallelStateNode<ActivePath, ActivePath> | FinalStateNode<ActivePath, ActivePath>;
|
|
1532
1542
|
type StateNode<ActivePath extends string = string, HistoryPath extends string = ActivePath, ChoicePath extends string = ActivePath> = ActiveStateNode<ActivePath, ChoicePath> | HistoryStateNode<HistoryPath, ActivePath> | ChoiceStateNode<ChoicePath, ActivePath>;
|
|
@@ -1534,7 +1544,7 @@ export declare namespace Machine {
|
|
|
1534
1544
|
* Runtime lookup table for state nodes.
|
|
1535
1545
|
*
|
|
1536
1546
|
* @category models
|
|
1537
|
-
* @since 4.0
|
|
1547
|
+
* @since 0.4.0
|
|
1538
1548
|
*/
|
|
1539
1549
|
interface StateNodes<ActivePath extends string = string, HistoryPath extends string = ActivePath, ChoicePath extends string = ActivePath> {
|
|
1540
1550
|
readonly byPath: ReadonlyMap<ActivePath | HistoryPath | ChoicePath, StateNode<ActivePath, HistoryPath, ChoicePath>>;
|
|
@@ -1544,7 +1554,7 @@ export declare namespace Machine {
|
|
|
1544
1554
|
* Trigger that selects a registered transition handler.
|
|
1545
1555
|
*
|
|
1546
1556
|
* @category models
|
|
1547
|
-
* @since 4.0
|
|
1557
|
+
* @since 0.4.0
|
|
1548
1558
|
*/
|
|
1549
1559
|
type TransitionTrigger<EventTag extends PropertyKey = PropertyKey> = {
|
|
1550
1560
|
readonly type: "event";
|
|
@@ -1561,7 +1571,7 @@ export declare namespace Machine {
|
|
|
1561
1571
|
* A declared parent path covers every descendant below that state.
|
|
1562
1572
|
*
|
|
1563
1573
|
* @category models
|
|
1564
|
-
* @since 4.0
|
|
1574
|
+
* @since 0.4.0
|
|
1565
1575
|
*/
|
|
1566
1576
|
type TransitionTargets<Path extends string = string> = {
|
|
1567
1577
|
readonly type: "dynamic";
|
|
@@ -1580,7 +1590,7 @@ export declare namespace Machine {
|
|
|
1580
1590
|
* available without executing the handler.
|
|
1581
1591
|
*
|
|
1582
1592
|
* @category models
|
|
1583
|
-
* @since 4.0
|
|
1593
|
+
* @since 0.4.0
|
|
1584
1594
|
*/
|
|
1585
1595
|
interface TransitionDefinition<SourcePath extends string = string, EventTag extends PropertyKey = PropertyKey, TargetPath extends string = SourcePath> {
|
|
1586
1596
|
readonly source: SourcePath;
|
|
@@ -1596,7 +1606,7 @@ export declare namespace Machine {
|
|
|
1596
1606
|
* invoke factory is reported as dynamic and is never evaluated by inspection.
|
|
1597
1607
|
*
|
|
1598
1608
|
* @category models
|
|
1599
|
-
* @since 4.0
|
|
1609
|
+
* @since 0.4.0
|
|
1600
1610
|
*/
|
|
1601
1611
|
type ActivityDefinition<SourcePath extends string = string> = Activities.ActivityDefinition<SourcePath>;
|
|
1602
1612
|
/**
|
|
@@ -1604,7 +1614,7 @@ export declare namespace Machine {
|
|
|
1604
1614
|
* one planned microstep.
|
|
1605
1615
|
*
|
|
1606
1616
|
* @category models
|
|
1607
|
-
* @since 4.0
|
|
1617
|
+
* @since 0.4.0
|
|
1608
1618
|
*/
|
|
1609
1619
|
interface RetainedTransition<SourcePath extends string = string, EventTag extends PropertyKey = PropertyKey, TargetPath extends string = SourcePath> {
|
|
1610
1620
|
readonly source: SourcePath;
|
|
@@ -1619,21 +1629,21 @@ export declare namespace Machine {
|
|
|
1619
1629
|
* Constructor arguments for a machine initial state function.
|
|
1620
1630
|
*
|
|
1621
1631
|
* @category utility types
|
|
1622
|
-
* @since 4.0
|
|
1632
|
+
* @since 0.4.0
|
|
1623
1633
|
*/
|
|
1624
1634
|
type InputArgs<Input extends Schema.Top> = Input extends typeof Schema.Void ? [] : [input: Input["Type"]];
|
|
1625
1635
|
/**
|
|
1626
1636
|
* Extracts the discriminator value represented by a tagged schema.
|
|
1627
1637
|
*
|
|
1628
1638
|
* @category utility types
|
|
1629
|
-
* @since 4.0
|
|
1639
|
+
* @since 0.4.0
|
|
1630
1640
|
*/
|
|
1631
1641
|
type TagOf<S extends TaggedSchema> = S["Type"]["_tag"];
|
|
1632
1642
|
/**
|
|
1633
1643
|
* Extracts the schema from a state tree node definition.
|
|
1634
1644
|
*
|
|
1635
1645
|
* @category utility types
|
|
1636
|
-
* @since 4.0
|
|
1646
|
+
* @since 0.4.0
|
|
1637
1647
|
*/
|
|
1638
1648
|
type NodeSchema<Node> = Node extends TaggedSchema ? Node : Node extends {
|
|
1639
1649
|
readonly schema: infer Schema extends TaggedSchema;
|
|
@@ -1642,14 +1652,14 @@ export declare namespace Machine {
|
|
|
1642
1652
|
* Prefixes a state path with its parent path.
|
|
1643
1653
|
*
|
|
1644
1654
|
* @category utility types
|
|
1645
|
-
* @since 4.0
|
|
1655
|
+
* @since 0.4.0
|
|
1646
1656
|
*/
|
|
1647
1657
|
type JoinPath<Parent extends string, Child extends string> = Parent extends "" ? Child : `${Parent}.${Child}`;
|
|
1648
1658
|
/**
|
|
1649
1659
|
* Extracts the state path values represented by a state definition.
|
|
1650
1660
|
*
|
|
1651
1661
|
* @category utility types
|
|
1652
|
-
* @since 4.0
|
|
1662
|
+
* @since 0.4.0
|
|
1653
1663
|
*/
|
|
1654
1664
|
type StateIdentifier<States extends StateSchemas> = StateIdentifierWithPrefix<States>;
|
|
1655
1665
|
/**
|
|
@@ -1657,7 +1667,7 @@ export declare namespace Machine {
|
|
|
1657
1667
|
* parent path prefix.
|
|
1658
1668
|
*
|
|
1659
1669
|
* @category utility types
|
|
1660
|
-
* @since 4.0
|
|
1670
|
+
* @since 0.4.0
|
|
1661
1671
|
*/
|
|
1662
1672
|
type StateIdentifierWithPrefix<States extends StateSchemas, Prefix extends string = ""> = {
|
|
1663
1673
|
readonly [Key in Extract<keyof States, string>]: States[Key] extends HistoryStateNodeConfig | ChoiceStateNodeConfig ? never : States[Key] extends {
|
|
@@ -1668,7 +1678,7 @@ export declare namespace Machine {
|
|
|
1668
1678
|
* Extracts the transition-only history pseudo-state paths in a definition.
|
|
1669
1679
|
*
|
|
1670
1680
|
* @category utility types
|
|
1671
|
-
* @since 4.0
|
|
1681
|
+
* @since 0.4.0
|
|
1672
1682
|
*/
|
|
1673
1683
|
type HistoryIdentifier<States extends StateSchemas> = HistoryIdentifierWithPrefix<States>;
|
|
1674
1684
|
/** Extracts the transition-only choice pseudo-state paths. */
|
|
@@ -1677,7 +1687,7 @@ export declare namespace Machine {
|
|
|
1677
1687
|
* Extracts every compiled state-node path, including history pseudo-states.
|
|
1678
1688
|
*
|
|
1679
1689
|
* @category utility types
|
|
1680
|
-
* @since 4.0
|
|
1690
|
+
* @since 0.4.0
|
|
1681
1691
|
*/
|
|
1682
1692
|
type StateNodeIdentifier<States extends StateSchemas> = StateIdentifier<States> | HistoryIdentifier<States> | ChoiceIdentifier<States>;
|
|
1683
1693
|
/** @internal */
|
|
@@ -1709,7 +1719,7 @@ export declare namespace Machine {
|
|
|
1709
1719
|
* shallow history restoration.
|
|
1710
1720
|
*
|
|
1711
1721
|
* @category utility types
|
|
1712
|
-
* @since 4.0
|
|
1722
|
+
* @since 0.4.0
|
|
1713
1723
|
*/
|
|
1714
1724
|
type RequiredHistoryInitializers<States extends StateSchemas> = [HistoryIdentifier<States>] extends [never] ? never : Extract<RequiredHistoryInitializersWithPrefix<States, States, "">, StateIdentifier<States>>;
|
|
1715
1725
|
/** Active parent states that own one or more history pseudo-states. */
|
|
@@ -1732,7 +1742,7 @@ export declare namespace Machine {
|
|
|
1732
1742
|
* Extracts a state-tree node by state path.
|
|
1733
1743
|
*
|
|
1734
1744
|
* @category utility types
|
|
1735
|
-
* @since 4.0
|
|
1745
|
+
* @since 0.4.0
|
|
1736
1746
|
*/
|
|
1737
1747
|
type NodeByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = StateId extends `${infer Head}.${infer Rest}` ? Head extends keyof States ? States[Head] extends {
|
|
1738
1748
|
readonly states: infer Children extends StateSchemas;
|
|
@@ -1741,21 +1751,21 @@ export declare namespace Machine {
|
|
|
1741
1751
|
* Extracts a schema from a state definition by state identifier.
|
|
1742
1752
|
*
|
|
1743
1753
|
* @category utility types
|
|
1744
|
-
* @since 4.0
|
|
1754
|
+
* @since 0.4.0
|
|
1745
1755
|
*/
|
|
1746
1756
|
type SchemaByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeSchema<NodeByIdentifier<States, StateId>>;
|
|
1747
1757
|
/**
|
|
1748
1758
|
* Extracts the union of state values represented by a state definition.
|
|
1749
1759
|
*
|
|
1750
1760
|
* @category utility types
|
|
1751
|
-
* @since 4.0
|
|
1761
|
+
* @since 0.4.0
|
|
1752
1762
|
*/
|
|
1753
1763
|
type StateOf<States extends StateSchemas> = StateIdentifier<States> extends infer StateId ? StateId extends StateIdentifier<States> ? SchemaByIdentifier<States, StateId>["Type"] : never : never;
|
|
1754
1764
|
/**
|
|
1755
1765
|
* Extracts the union of event values represented by an event schema list.
|
|
1756
1766
|
*
|
|
1757
1767
|
* @category utility types
|
|
1758
|
-
* @since 4.0
|
|
1768
|
+
* @since 0.4.0
|
|
1759
1769
|
*/
|
|
1760
1770
|
type EventOf<Events extends ReadonlyArray<TaggedSchema>> = Events[number]["Type"];
|
|
1761
1771
|
/**
|
|
@@ -1763,42 +1773,42 @@ export declare namespace Machine {
|
|
|
1763
1773
|
* schema list.
|
|
1764
1774
|
*
|
|
1765
1775
|
* @category utility types
|
|
1766
|
-
* @since 4.0
|
|
1776
|
+
* @since 0.4.0
|
|
1767
1777
|
*/
|
|
1768
1778
|
type EmitOf<Emits extends ReadonlyArray<TaggedSchema>> = Emits[number]["Type"];
|
|
1769
1779
|
/**
|
|
1770
1780
|
* Event values received by lifecycle callbacks.
|
|
1771
1781
|
*
|
|
1772
1782
|
* @category utility types
|
|
1773
|
-
* @since 4.0
|
|
1783
|
+
* @since 0.4.0
|
|
1774
1784
|
*/
|
|
1775
1785
|
type LifecycleEvent<Events extends ReadonlyArray<TaggedSchema>> = EventOf<Events> | InitialEvent;
|
|
1776
1786
|
/**
|
|
1777
1787
|
* Extracts a state value from a state definition by identifier.
|
|
1778
1788
|
*
|
|
1779
1789
|
* @category utility types
|
|
1780
|
-
* @since 4.0
|
|
1790
|
+
* @since 0.4.0
|
|
1781
1791
|
*/
|
|
1782
1792
|
type StateByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = Extract<StateOf<States>, SchemaByIdentifier<States, StateId>["Type"]>;
|
|
1783
1793
|
/**
|
|
1784
1794
|
* Extracts every parent state path from a state identifier.
|
|
1785
1795
|
*
|
|
1786
1796
|
* @category utility types
|
|
1787
|
-
* @since 4.0
|
|
1797
|
+
* @since 0.4.0
|
|
1788
1798
|
*/
|
|
1789
1799
|
type ParentStateIdentifier<StateId extends string> = StateId extends `${infer Parent}.${infer Child}` ? Parent | (Child extends `${string}.${string}` ? `${Parent}.${ParentStateIdentifier<Child>}` : never) : never;
|
|
1790
1800
|
/**
|
|
1791
1801
|
* Extracts the nearest parent state path from a state identifier.
|
|
1792
1802
|
*
|
|
1793
1803
|
* @category utility types
|
|
1794
|
-
* @since 4.0
|
|
1804
|
+
* @since 0.4.0
|
|
1795
1805
|
*/
|
|
1796
1806
|
type ImmediateParentStateIdentifier<StateId extends string> = StateId extends `${infer Head}.${infer Tail}` ? Tail extends `${string}.${string}` ? `${Head}.${ImmediateParentStateIdentifier<Tail>}` : Head : never;
|
|
1797
1807
|
/**
|
|
1798
1808
|
* Maps every parent state path of a state identifier to its decoded value.
|
|
1799
1809
|
*
|
|
1800
1810
|
* @category utility types
|
|
1801
|
-
* @since 4.0
|
|
1811
|
+
* @since 0.4.0
|
|
1802
1812
|
*/
|
|
1803
1813
|
type ParentStateValues<States extends StateSchemas, StateId extends StateIdentifier<States>> = StateId extends StateIdentifier<States> ? {
|
|
1804
1814
|
readonly [Parent in Extract<ParentStateIdentifier<StateId>, StateIdentifier<States>>]: StateByIdentifier<States, Parent>;
|
|
@@ -1807,14 +1817,14 @@ export declare namespace Machine {
|
|
|
1807
1817
|
* Extracts the nearest parent value, or `undefined` for a root state.
|
|
1808
1818
|
*
|
|
1809
1819
|
* @category utility types
|
|
1810
|
-
* @since 4.0
|
|
1820
|
+
* @since 0.4.0
|
|
1811
1821
|
*/
|
|
1812
1822
|
type ParentStateValue<States extends StateSchemas, StateId extends StateIdentifier<States>> = StateId extends StateIdentifier<States> ? Extract<ImmediateParentStateIdentifier<StateId>, StateIdentifier<States>> extends infer Parent ? [Parent] extends [never] ? undefined : Parent extends StateIdentifier<States> ? StateByIdentifier<States, Parent> : undefined : undefined : never;
|
|
1813
1823
|
/**
|
|
1814
1824
|
* Represents a decoded state value together with all of its parent values.
|
|
1815
1825
|
*
|
|
1816
1826
|
* @category models
|
|
1817
|
-
* @since 4.0
|
|
1827
|
+
* @since 0.4.0
|
|
1818
1828
|
*/
|
|
1819
1829
|
type StateWithParents<States extends StateSchemas, StateId extends StateIdentifier<States>> = StateId extends StateIdentifier<States> ? {
|
|
1820
1830
|
readonly value: StateByIdentifier<States, StateId>;
|
|
@@ -1828,7 +1838,7 @@ export declare namespace Machine {
|
|
|
1828
1838
|
* Extracts the declared output type for a state node.
|
|
1829
1839
|
*
|
|
1830
1840
|
* @category utility types
|
|
1831
|
-
* @since 4.0
|
|
1841
|
+
* @since 0.4.0
|
|
1832
1842
|
*/
|
|
1833
1843
|
type OutputByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeOutput<NodeByIdentifier<States, StateId>>;
|
|
1834
1844
|
type DirectFinalCompletionOutput<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeByIdentifier<States, StateId> extends {
|
|
@@ -1842,7 +1852,7 @@ export declare namespace Machine {
|
|
|
1842
1852
|
* Extracts the output passed when a state node completes.
|
|
1843
1853
|
*
|
|
1844
1854
|
* @category utility types
|
|
1845
|
-
* @since 4.0
|
|
1855
|
+
* @since 0.4.0
|
|
1846
1856
|
*/
|
|
1847
1857
|
type CompletionOutputByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeByIdentifier<States, StateId> extends infer Node ? Node extends {
|
|
1848
1858
|
readonly type: "parallel";
|
|
@@ -1865,7 +1875,7 @@ export declare namespace Machine {
|
|
|
1865
1875
|
* before that root becomes the machine's terminal result.
|
|
1866
1876
|
*
|
|
1867
1877
|
* @category utility types
|
|
1868
|
-
* @since 4.0
|
|
1878
|
+
* @since 0.4.0
|
|
1869
1879
|
*/
|
|
1870
1880
|
type TerminalOutput<States extends StateSchemas> = {
|
|
1871
1881
|
readonly [Key in Extract<keyof States, string>]: Extract<Key, StateIdentifier<States>> extends infer StateId extends StateIdentifier<States> ? NodeByIdentifier<States, StateId> extends infer Node ? Node extends {
|
|
@@ -1878,7 +1888,7 @@ export declare namespace Machine {
|
|
|
1878
1888
|
* Extracts every state path whose definition declares an output schema.
|
|
1879
1889
|
*
|
|
1880
1890
|
* @category utility types
|
|
1881
|
-
* @since 4.0
|
|
1891
|
+
* @since 0.4.0
|
|
1882
1892
|
*/
|
|
1883
1893
|
type DeclaredOutputState<States extends StateSchemas> = {
|
|
1884
1894
|
readonly [StateId in StateIdentifier<States>]: NodeByIdentifier<States, StateId> extends {
|
|
@@ -1890,7 +1900,7 @@ export declare namespace Machine {
|
|
|
1890
1900
|
* implementation before a machine is planned or started.
|
|
1891
1901
|
*
|
|
1892
1902
|
* @category utility types
|
|
1893
|
-
* @since 4.0
|
|
1903
|
+
* @since 0.4.0
|
|
1894
1904
|
*/
|
|
1895
1905
|
type EnsureOutputImplementations<States extends StateSchemas, OutputStates extends StateIdentifier<States>> = [
|
|
1896
1906
|
Exclude<DeclaredOutputState<States>, OutputStates>
|
|
@@ -1907,7 +1917,7 @@ export declare namespace Machine {
|
|
|
1907
1917
|
* machine snapshot.
|
|
1908
1918
|
*
|
|
1909
1919
|
* @category utility types
|
|
1910
|
-
* @since 4.0
|
|
1920
|
+
* @since 0.4.0
|
|
1911
1921
|
*/
|
|
1912
1922
|
type SnapshotDecodingServices<States extends StateSchemas> = StateIdentifier<States> extends infer StateId ? StateId extends StateIdentifier<States> ? DecodingServices<SchemaByIdentifier<States, StateId>> | DecodingServices<OutputSchema<NodeByIdentifier<States, StateId>>> : never : never;
|
|
1913
1923
|
/**
|
|
@@ -1915,14 +1925,14 @@ export declare namespace Machine {
|
|
|
1915
1925
|
* machine snapshot.
|
|
1916
1926
|
*
|
|
1917
1927
|
* @category utility types
|
|
1918
|
-
* @since 4.0
|
|
1928
|
+
* @since 0.4.0
|
|
1919
1929
|
*/
|
|
1920
1930
|
type SnapshotEncodingServices<States extends StateSchemas> = StateIdentifier<States> extends infer StateId ? StateId extends StateIdentifier<States> ? EncodingServices<SchemaByIdentifier<States, StateId>> | EncodingServices<OutputSchema<NodeByIdentifier<States, StateId>>> : never : never;
|
|
1921
1931
|
/**
|
|
1922
1932
|
* Encoded value for one active state path in a normalized machine snapshot.
|
|
1923
1933
|
*
|
|
1924
1934
|
* @category models
|
|
1925
|
-
* @since 4.0
|
|
1935
|
+
* @since 0.4.0
|
|
1926
1936
|
*/
|
|
1927
1937
|
interface EncodedSnapshotState {
|
|
1928
1938
|
readonly path: string;
|
|
@@ -1933,7 +1943,7 @@ export declare namespace Machine {
|
|
|
1933
1943
|
* snapshot. An omitted output represents `undefined`.
|
|
1934
1944
|
*
|
|
1935
1945
|
* @category models
|
|
1936
|
-
* @since 4.0
|
|
1946
|
+
* @since 0.4.0
|
|
1937
1947
|
*/
|
|
1938
1948
|
interface EncodedSnapshotCompletion {
|
|
1939
1949
|
readonly path: string;
|
|
@@ -1955,7 +1965,7 @@ export declare namespace Machine {
|
|
|
1955
1965
|
* scopes, queues, and subscriptions is not included.
|
|
1956
1966
|
*
|
|
1957
1967
|
* @category models
|
|
1958
|
-
* @since 4.0
|
|
1968
|
+
* @since 0.4.0
|
|
1959
1969
|
*/
|
|
1960
1970
|
interface EncodedSnapshot {
|
|
1961
1971
|
readonly _tag: "MachineSnapshot";
|
|
@@ -1967,7 +1977,7 @@ export declare namespace Machine {
|
|
|
1967
1977
|
* Completed state path and its resolved output value.
|
|
1968
1978
|
*
|
|
1969
1979
|
* @category models
|
|
1970
|
-
* @since 4.0
|
|
1980
|
+
* @since 0.4.0
|
|
1971
1981
|
*/
|
|
1972
1982
|
interface SnapshotCompletion {
|
|
1973
1983
|
readonly path: string;
|
|
@@ -1993,7 +2003,7 @@ export declare namespace Machine {
|
|
|
1993
2003
|
* or transport boundary.
|
|
1994
2004
|
*
|
|
1995
2005
|
* @category models
|
|
1996
|
-
* @since 4.0
|
|
2006
|
+
* @since 0.4.0
|
|
1997
2007
|
*/
|
|
1998
2008
|
interface SnapshotMetadata {
|
|
1999
2009
|
readonly completed?: ReadonlyArray<SnapshotCompletion>;
|
|
@@ -2004,7 +2014,7 @@ export declare namespace Machine {
|
|
|
2004
2014
|
* decoded state value.
|
|
2005
2015
|
*
|
|
2006
2016
|
* @category models
|
|
2007
|
-
* @since 4.0
|
|
2017
|
+
* @since 0.4.0
|
|
2008
2018
|
*/
|
|
2009
2019
|
interface AtomicSnapshot<Path extends string, Value> extends SnapshotMetadata {
|
|
2010
2020
|
readonly path: Path;
|
|
@@ -2015,7 +2025,7 @@ export declare namespace Machine {
|
|
|
2015
2025
|
* snapshot.
|
|
2016
2026
|
*
|
|
2017
2027
|
* @category models
|
|
2018
|
-
* @since 4.0
|
|
2028
|
+
* @since 0.4.0
|
|
2019
2029
|
*/
|
|
2020
2030
|
interface CompoundSnapshot<Path extends string, Value, Child> extends SnapshotMetadata {
|
|
2021
2031
|
readonly path: Path;
|
|
@@ -2027,7 +2037,7 @@ export declare namespace Machine {
|
|
|
2027
2037
|
* per child region.
|
|
2028
2038
|
*
|
|
2029
2039
|
* @category models
|
|
2030
|
-
* @since 4.0
|
|
2040
|
+
* @since 0.4.0
|
|
2031
2041
|
*/
|
|
2032
2042
|
interface ParallelSnapshot<Path extends string, Value, Regions> extends SnapshotMetadata {
|
|
2033
2043
|
readonly path: Path;
|
|
@@ -2039,7 +2049,7 @@ export declare namespace Machine {
|
|
|
2039
2049
|
* identifier.
|
|
2040
2050
|
*
|
|
2041
2051
|
* @category utility types
|
|
2042
|
-
* @since 4.0
|
|
2052
|
+
* @since 0.4.0
|
|
2043
2053
|
*/
|
|
2044
2054
|
type SnapshotByIdentifier<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeByIdentifier<States, StateId> extends infer Node ? Node extends {
|
|
2045
2055
|
readonly type: "parallel";
|
|
@@ -2051,7 +2061,7 @@ export declare namespace Machine {
|
|
|
2051
2061
|
* Extracts child snapshots under a parent path prefix.
|
|
2052
2062
|
*
|
|
2053
2063
|
* @category utility types
|
|
2054
|
-
* @since 4.0
|
|
2064
|
+
* @since 0.4.0
|
|
2055
2065
|
*/
|
|
2056
2066
|
type SnapshotWithPrefix<States extends StateSchemas, Prefix extends string> = {
|
|
2057
2067
|
readonly [Key in ActiveStateKey<States>]: SnapshotByIdentifierWithPath<States, Key, JoinPath<Prefix, Key>>;
|
|
@@ -2061,7 +2071,7 @@ export declare namespace Machine {
|
|
|
2061
2071
|
* child region.
|
|
2062
2072
|
*
|
|
2063
2073
|
* @category utility types
|
|
2064
|
-
* @since 4.0
|
|
2074
|
+
* @since 0.4.0
|
|
2065
2075
|
*/
|
|
2066
2076
|
type SnapshotRegionsWithPrefix<States extends StateSchemas, Prefix extends string> = {
|
|
2067
2077
|
readonly [Key in ActiveStateKey<States>]: SnapshotByIdentifierWithPath<States, Key, JoinPath<Prefix, Key>>;
|
|
@@ -2070,7 +2080,7 @@ export declare namespace Machine {
|
|
|
2070
2080
|
* Extracts a snapshot for a state node while preserving its full path.
|
|
2071
2081
|
*
|
|
2072
2082
|
* @category utility types
|
|
2073
|
-
* @since 4.0
|
|
2083
|
+
* @since 0.4.0
|
|
2074
2084
|
*/
|
|
2075
2085
|
type SnapshotByIdentifierWithPath<States extends StateSchemas, StateId extends ActiveStateKey<States>, Path extends string> = States[StateId] extends {
|
|
2076
2086
|
readonly type: "parallel";
|
|
@@ -2086,7 +2096,7 @@ export declare namespace Machine {
|
|
|
2086
2096
|
* are narrowed to the branch leading to `Owner`.
|
|
2087
2097
|
*
|
|
2088
2098
|
* @category utility types
|
|
2089
|
-
* @since 4.0
|
|
2099
|
+
* @since 0.4.0
|
|
2090
2100
|
*/
|
|
2091
2101
|
type CompleteSnapshotContaining<States extends StateSchemas, Owner extends StateIdentifier<States>> = HistorySnapshotWithPrefix<States, Owner, "">;
|
|
2092
2102
|
/**
|
|
@@ -2094,7 +2104,7 @@ export declare namespace Machine {
|
|
|
2094
2104
|
* definition.
|
|
2095
2105
|
*
|
|
2096
2106
|
* @category models
|
|
2097
|
-
* @since 4.0
|
|
2107
|
+
* @since 0.4.0
|
|
2098
2108
|
*/
|
|
2099
2109
|
type Snapshot<States extends StateSchemas> = {
|
|
2100
2110
|
readonly [StateId in ActiveStateKey<States>]: SnapshotByIdentifier<States, StateId & StateIdentifier<States>>;
|
|
@@ -2103,21 +2113,21 @@ export declare namespace Machine {
|
|
|
2103
2113
|
* Extracts the root state identifier from a state path.
|
|
2104
2114
|
*
|
|
2105
2115
|
* @category utility types
|
|
2106
|
-
* @since 4.0
|
|
2116
|
+
* @since 0.4.0
|
|
2107
2117
|
*/
|
|
2108
2118
|
type RootStateIdentifier<StateId extends string> = StateId extends `${infer Root}.${string}` ? Root : StateId;
|
|
2109
2119
|
/**
|
|
2110
2120
|
* Extracts the public snapshot shape that contains a final state path.
|
|
2111
2121
|
*
|
|
2112
2122
|
* @category utility types
|
|
2113
|
-
* @since 4.0
|
|
2123
|
+
* @since 0.4.0
|
|
2114
2124
|
*/
|
|
2115
2125
|
type SnapshotContainingFinal<States extends StateSchemas, FinalStates extends StateIdentifier<States>> = FinalStates extends StateIdentifier<States> ? RootStateIdentifier<FinalStates> extends infer Root extends StateIdentifier<States> ? SnapshotByIdentifier<States, Root> : never : never;
|
|
2116
2126
|
/**
|
|
2117
2127
|
* Extracts state identifiers whose state-tree definition marks them final.
|
|
2118
2128
|
*
|
|
2119
2129
|
* @category utility types
|
|
2120
|
-
* @since 4.0
|
|
2130
|
+
* @since 0.4.0
|
|
2121
2131
|
*/
|
|
2122
2132
|
type FinalStateFromDefinition<States extends StateSchemas> = {
|
|
2123
2133
|
readonly [StateId in StateIdentifier<States>]: NodeByIdentifier<States, StateId> extends {
|
|
@@ -2128,7 +2138,7 @@ export declare namespace Machine {
|
|
|
2128
2138
|
* Extracts an event value from an event schema list by tag.
|
|
2129
2139
|
*
|
|
2130
2140
|
* @category utility types
|
|
2131
|
-
* @since 4.0
|
|
2141
|
+
* @since 0.4.0
|
|
2132
2142
|
*/
|
|
2133
2143
|
type EventByTag<Events extends ReadonlyArray<TaggedSchema>, Tag extends TagOf<Events[number]>> = Extract<EventOf<Events>, {
|
|
2134
2144
|
readonly _tag: Tag;
|
|
@@ -2145,7 +2155,7 @@ export declare namespace Machine {
|
|
|
2145
2155
|
* planning succeeds.
|
|
2146
2156
|
*
|
|
2147
2157
|
* @category models
|
|
2148
|
-
* @since 4.0
|
|
2158
|
+
* @since 0.4.0
|
|
2149
2159
|
*/
|
|
2150
2160
|
interface StateConstruction<Result> {
|
|
2151
2161
|
readonly [Topology.StateConstructionTypeId]: Result;
|
|
@@ -2154,7 +2164,7 @@ export declare namespace Machine {
|
|
|
2154
2164
|
* Machine-bound target instruction accepted from transition handlers.
|
|
2155
2165
|
*
|
|
2156
2166
|
* @category models
|
|
2157
|
-
* @since 4.0
|
|
2167
|
+
* @since 0.4.0
|
|
2158
2168
|
*/
|
|
2159
2169
|
interface Target<States extends StateSchemas, StateId extends StateIdentifier<States>> {
|
|
2160
2170
|
readonly [Topology.TargetTypeId]: typeof Topology.TargetTypeId;
|
|
@@ -2173,7 +2183,7 @@ export declare namespace Machine {
|
|
|
2173
2183
|
* history node's typed default when no record exists.
|
|
2174
2184
|
*
|
|
2175
2185
|
* @category models
|
|
2176
|
-
* @since 4.0
|
|
2186
|
+
* @since 0.4.0
|
|
2177
2187
|
*/
|
|
2178
2188
|
interface HistoryTarget<States extends StateSchemas, HistoryId extends HistoryIdentifier<States>> {
|
|
2179
2189
|
readonly [Topology.HistoryTargetTypeId]: typeof Topology.HistoryTargetTypeId;
|
|
@@ -2202,14 +2212,14 @@ export declare namespace Machine {
|
|
|
2202
2212
|
* every active child below the selected root.
|
|
2203
2213
|
*
|
|
2204
2214
|
* @category utility types
|
|
2205
|
-
* @since 4.0
|
|
2215
|
+
* @since 0.4.0
|
|
2206
2216
|
*/
|
|
2207
2217
|
type FullTargetBuilder<States extends StateSchemas> = FullSnapshotBuilderWithPrefix<States>;
|
|
2208
2218
|
/**
|
|
2209
2219
|
* Builder for a complete fallback configuration containing a history owner.
|
|
2210
2220
|
*
|
|
2211
2221
|
* @category utility types
|
|
2212
|
-
* @since 4.0
|
|
2222
|
+
* @since 0.4.0
|
|
2213
2223
|
*/
|
|
2214
2224
|
type HistoryDefaultTargetBuilder<States extends StateSchemas, Owner extends StateIdentifier<States>> = HistorySnapshotBuilderWithPrefix<States, Owner>;
|
|
2215
2225
|
/**
|
|
@@ -2221,7 +2231,7 @@ export declare namespace Machine {
|
|
|
2221
2231
|
* the source state and should preserve active ancestor and sibling values.
|
|
2222
2232
|
*
|
|
2223
2233
|
* @category utility types
|
|
2224
|
-
* @since 4.0
|
|
2234
|
+
* @since 0.4.0
|
|
2225
2235
|
*/
|
|
2226
2236
|
type LocalTargetBuilder<States extends StateSchemas, Source extends StateNodeIdentifier<States>> = NearestCompoundScope<States, Source> extends infer Scope ? [Scope] extends [never] ? {} : Scope extends StateIdentifier<States> ? LocalTargetBuilderForScope<States, Scope, Source> : {} : {};
|
|
2227
2237
|
/**
|
|
@@ -2233,7 +2243,7 @@ export declare namespace Machine {
|
|
|
2233
2243
|
* root while preserving unmentioned active ancestors or parallel regions.
|
|
2234
2244
|
*
|
|
2235
2245
|
* @category utility types
|
|
2236
|
-
* @since 4.0
|
|
2246
|
+
* @since 0.4.0
|
|
2237
2247
|
*/
|
|
2238
2248
|
type BranchTargetBuilder<States extends StateSchemas, Source extends StateNodeIdentifier<States>> = BranchTargetBuilderForRoot<States, Extract<RootStateIdentifier<Source>, ActiveStateKey<States>>, Source>;
|
|
2239
2249
|
/**
|
|
@@ -2253,14 +2263,14 @@ export declare namespace Machine {
|
|
|
2253
2263
|
* enter again.
|
|
2254
2264
|
*
|
|
2255
2265
|
* @category models
|
|
2256
|
-
* @since 4.0
|
|
2266
|
+
* @since 0.4.0
|
|
2257
2267
|
*/
|
|
2258
2268
|
interface TargetBuilder<States extends StateSchemas, Source extends StateNodeIdentifier<States>> {
|
|
2259
2269
|
/**
|
|
2260
2270
|
* Moves to another state in the same local group. The value of the state
|
|
2261
2271
|
* containing that group, and values in other active branches, are kept.
|
|
2262
2272
|
*
|
|
2263
|
-
* @since 4.0
|
|
2273
|
+
* @since 0.4.0
|
|
2264
2274
|
*/
|
|
2265
2275
|
readonly local: LocalTargetBuilder<States, Source>;
|
|
2266
2276
|
/**
|
|
@@ -2268,7 +2278,7 @@ export declare namespace Machine {
|
|
|
2268
2278
|
* values change only when their builder methods are explicitly called;
|
|
2269
2279
|
* other active branches are kept.
|
|
2270
2280
|
*
|
|
2271
|
-
* @since 4.0
|
|
2281
|
+
* @since 0.4.0
|
|
2272
2282
|
*/
|
|
2273
2283
|
readonly branch: BranchTargetBuilder<States, Source>;
|
|
2274
2284
|
/**
|
|
@@ -2281,7 +2291,7 @@ export declare namespace Machine {
|
|
|
2281
2291
|
* When it contains parallel states, an active state must be provided for
|
|
2282
2292
|
* every region.
|
|
2283
2293
|
*
|
|
2284
|
-
* @since 4.0
|
|
2294
|
+
* @since 0.4.0
|
|
2285
2295
|
*/
|
|
2286
2296
|
readonly full: FullTargetBuilder<States>;
|
|
2287
2297
|
/** Restores a declared shallow or deep history pseudo-state. */
|
|
@@ -2291,7 +2301,7 @@ export declare namespace Machine {
|
|
|
2291
2301
|
* Context passed to a state/event handler.
|
|
2292
2302
|
*
|
|
2293
2303
|
* @category models
|
|
2294
|
-
* @since 4.0
|
|
2304
|
+
* @since 0.4.0
|
|
2295
2305
|
*/
|
|
2296
2306
|
interface HandlerContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> {
|
|
2297
2307
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2304,7 +2314,7 @@ export declare namespace Machine {
|
|
|
2304
2314
|
* Provides typed builders for choosing the next active state from this
|
|
2305
2315
|
* handler. Each builder documents which existing state values it keeps.
|
|
2306
2316
|
*
|
|
2307
|
-
* @since 4.0
|
|
2317
|
+
* @since 0.4.0
|
|
2308
2318
|
*/
|
|
2309
2319
|
readonly target: TargetBuilder<States, StateId>;
|
|
2310
2320
|
}
|
|
@@ -2312,7 +2322,7 @@ export declare namespace Machine {
|
|
|
2312
2322
|
* Context passed to an entry or exit state handler.
|
|
2313
2323
|
*
|
|
2314
2324
|
* @category models
|
|
2315
|
-
* @since 4.0
|
|
2325
|
+
* @since 0.4.0
|
|
2316
2326
|
*/
|
|
2317
2327
|
interface StateActionContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2318
2328
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2324,7 +2334,7 @@ export declare namespace Machine {
|
|
|
2324
2334
|
* Context passed to an invoked child process source.
|
|
2325
2335
|
*
|
|
2326
2336
|
* @category models
|
|
2327
|
-
* @since 4.0
|
|
2337
|
+
* @since 0.4.0
|
|
2328
2338
|
*/
|
|
2329
2339
|
interface InvokeContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2330
2340
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2336,7 +2346,7 @@ export declare namespace Machine {
|
|
|
2336
2346
|
* Context passed to an invoked child process active snapshot mapper.
|
|
2337
2347
|
*
|
|
2338
2348
|
* @category models
|
|
2339
|
-
* @since 4.0
|
|
2349
|
+
* @since 0.4.0
|
|
2340
2350
|
*/
|
|
2341
2351
|
interface InvokeSnapshotContext<State, Error, Output> {
|
|
2342
2352
|
readonly id: string;
|
|
@@ -2348,7 +2358,7 @@ export declare namespace Machine {
|
|
|
2348
2358
|
* Context passed to an invoked machine terminal output mapper.
|
|
2349
2359
|
*
|
|
2350
2360
|
* @category models
|
|
2351
|
-
* @since 4.0
|
|
2361
|
+
* @since 0.4.0
|
|
2352
2362
|
*/
|
|
2353
2363
|
interface InvokeDoneContext<Output> {
|
|
2354
2364
|
readonly id: string;
|
|
@@ -2358,7 +2368,7 @@ export declare namespace Machine {
|
|
|
2358
2368
|
* Context passed to an eventless transition handler.
|
|
2359
2369
|
*
|
|
2360
2370
|
* @category models
|
|
2361
|
-
* @since 4.0
|
|
2371
|
+
* @since 0.4.0
|
|
2362
2372
|
*/
|
|
2363
2373
|
interface AlwaysContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2364
2374
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2372,7 +2382,7 @@ export declare namespace Machine {
|
|
|
2372
2382
|
* eventless handler. Each builder documents which existing state values it
|
|
2373
2383
|
* keeps.
|
|
2374
2384
|
*
|
|
2375
|
-
* @since 4.0
|
|
2385
|
+
* @since 0.4.0
|
|
2376
2386
|
*/
|
|
2377
2387
|
readonly target: TargetBuilder<States, StateId>;
|
|
2378
2388
|
}
|
|
@@ -2380,7 +2390,7 @@ export declare namespace Machine {
|
|
|
2380
2390
|
* Context passed to a state completion transition handler.
|
|
2381
2391
|
*
|
|
2382
2392
|
* @category models
|
|
2383
|
-
* @since 4.0
|
|
2393
|
+
* @since 0.4.0
|
|
2384
2394
|
*/
|
|
2385
2395
|
interface DoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2386
2396
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2395,7 +2405,7 @@ export declare namespace Machine {
|
|
|
2395
2405
|
* state completes. Each builder documents which existing state values it
|
|
2396
2406
|
* keeps.
|
|
2397
2407
|
*
|
|
2398
|
-
* @since 4.0
|
|
2408
|
+
* @since 0.4.0
|
|
2399
2409
|
*/
|
|
2400
2410
|
readonly target: TargetBuilder<States, StateId>;
|
|
2401
2411
|
}
|
|
@@ -2412,7 +2422,7 @@ export declare namespace Machine {
|
|
|
2412
2422
|
* Context passed to a final state output function.
|
|
2413
2423
|
*
|
|
2414
2424
|
* @category models
|
|
2415
|
-
* @since 4.0
|
|
2425
|
+
* @since 0.4.0
|
|
2416
2426
|
*/
|
|
2417
2427
|
interface FinalOutputContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2418
2428
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2424,7 +2434,7 @@ export declare namespace Machine {
|
|
|
2424
2434
|
* Extracts region outputs for a completed parallel state.
|
|
2425
2435
|
*
|
|
2426
2436
|
* @category utility types
|
|
2427
|
-
* @since 4.0
|
|
2437
|
+
* @since 0.4.0
|
|
2428
2438
|
*/
|
|
2429
2439
|
type ParallelOutputRegions<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeByIdentifier<States, StateId> extends {
|
|
2430
2440
|
readonly type: "parallel";
|
|
@@ -2436,7 +2446,7 @@ export declare namespace Machine {
|
|
|
2436
2446
|
* Context passed to a parallel state output function.
|
|
2437
2447
|
*
|
|
2438
2448
|
* @category models
|
|
2439
|
-
* @since 4.0
|
|
2449
|
+
* @since 0.4.0
|
|
2440
2450
|
*/
|
|
2441
2451
|
interface ParallelOutputContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2442
2452
|
readonly state: StateByIdentifier<States, StateId>;
|
|
@@ -2449,14 +2459,14 @@ export declare namespace Machine {
|
|
|
2449
2459
|
* Return value accepted from entry and exit state actions.
|
|
2450
2460
|
*
|
|
2451
2461
|
* @category utility types
|
|
2452
|
-
* @since 4.0
|
|
2462
|
+
* @since 0.4.0
|
|
2453
2463
|
*/
|
|
2454
2464
|
type StateActionResult<E, R> = undefined;
|
|
2455
2465
|
/**
|
|
2456
2466
|
* Return value accepted from a machine initial state function.
|
|
2457
2467
|
*
|
|
2458
2468
|
* @category utility types
|
|
2459
|
-
* @since 4.0
|
|
2469
|
+
* @since 0.4.0
|
|
2460
2470
|
*/
|
|
2461
2471
|
type InitialResult<States extends StateSchemas, E, R> = Snapshot<States> | InitialSnapshot<States> | StateConstruction<Snapshot<States> | InitialSnapshot<States>>;
|
|
2462
2472
|
/** Initial snapshots may transiently terminate in a declared choice node. */
|
|
@@ -2473,7 +2483,7 @@ export declare namespace Machine {
|
|
|
2473
2483
|
* accepted at transition boundaries.
|
|
2474
2484
|
*
|
|
2475
2485
|
* @category utility types
|
|
2476
|
-
* @since 4.0
|
|
2486
|
+
* @since 0.4.0
|
|
2477
2487
|
*/
|
|
2478
2488
|
type HandlerResult<States extends StateSchemas, E, R> = Snapshot<States> | Target<States, StateIdentifier<States>> | HistoryTarget<States, HistoryIdentifier<States>> | ChoiceTarget<States, ChoiceIdentifier<States>> | StateConstruction<Snapshot<States> | Target<States, StateIdentifier<States>> | HistoryTarget<States, HistoryIdentifier<States>> | ChoiceTarget<States, ChoiceIdentifier<States>>> | void;
|
|
2479
2489
|
/** A choice resolver must always select a typed target synchronously. */
|
|
@@ -2482,35 +2492,35 @@ export declare namespace Machine {
|
|
|
2482
2492
|
* Extracts the union of handler return values from a handler map.
|
|
2483
2493
|
*
|
|
2484
2494
|
* @category utility types
|
|
2485
|
-
* @since 4.0
|
|
2495
|
+
* @since 0.4.0
|
|
2486
2496
|
*/
|
|
2487
2497
|
type HandlerEffect<Handlers> = Handlers[keyof Handlers];
|
|
2488
2498
|
/**
|
|
2489
2499
|
* Extracts the error type from a handler return value.
|
|
2490
2500
|
*
|
|
2491
2501
|
* @category utility types
|
|
2492
|
-
* @since 4.0
|
|
2502
|
+
* @since 0.4.0
|
|
2493
2503
|
*/
|
|
2494
2504
|
type HandlerError<Handlers> = Effect.Error<HandlerEffect<Handlers>>;
|
|
2495
2505
|
/**
|
|
2496
2506
|
* Extracts the service requirements from a handler return value.
|
|
2497
2507
|
*
|
|
2498
2508
|
* @category utility types
|
|
2499
|
-
* @since 4.0
|
|
2509
|
+
* @since 0.4.0
|
|
2500
2510
|
*/
|
|
2501
2511
|
type HandlerServices<Handlers> = Effect.Services<HandlerEffect<Handlers>>;
|
|
2502
2512
|
/**
|
|
2503
2513
|
* Extracts the return value from an initial state function.
|
|
2504
2514
|
*
|
|
2505
2515
|
* @category utility types
|
|
2506
|
-
* @since 4.0
|
|
2516
|
+
* @since 0.4.0
|
|
2507
2517
|
*/
|
|
2508
2518
|
type InitialReturn<Initial> = Initial extends (...args: any) => infer Ret ? Ret : never;
|
|
2509
2519
|
/**
|
|
2510
2520
|
* Extracts the return value from an entry or exit action.
|
|
2511
2521
|
*
|
|
2512
2522
|
* @category utility types
|
|
2513
|
-
* @since 4.0
|
|
2523
|
+
* @since 0.4.0
|
|
2514
2524
|
*/
|
|
2515
2525
|
type StateActionReturn<Config, Key extends "entry" | "exit"> = Key extends keyof Config ? NonNullable<Config[Key]> extends (...args: any) => infer Ret ? Ret : never : never;
|
|
2516
2526
|
/** Extracts the return value from an implicit initial child implementation. */
|
|
@@ -2535,7 +2545,7 @@ export declare namespace Machine {
|
|
|
2535
2545
|
* Extracts the return value from an event transition config.
|
|
2536
2546
|
*
|
|
2537
2547
|
* @category utility types
|
|
2538
|
-
* @since 4.0
|
|
2548
|
+
* @since 0.4.0
|
|
2539
2549
|
*/
|
|
2540
2550
|
type EventTransitionReturn<Transition> = Transition extends (...args: any) => infer Ret ? Ret : Transition extends {
|
|
2541
2551
|
readonly transition: (...args: any) => infer Ret;
|
|
@@ -2544,7 +2554,7 @@ export declare namespace Machine {
|
|
|
2544
2554
|
* Extracts the return value from a state's event handlers.
|
|
2545
2555
|
*
|
|
2546
2556
|
* @category utility types
|
|
2547
|
-
* @since 4.0
|
|
2557
|
+
* @since 0.4.0
|
|
2548
2558
|
*/
|
|
2549
2559
|
type EventHandlerReturn<Config> = Config extends {
|
|
2550
2560
|
readonly on?: infer On;
|
|
@@ -2555,7 +2565,7 @@ export declare namespace Machine {
|
|
|
2555
2565
|
* Extracts the invoke config or configs from a state config.
|
|
2556
2566
|
*
|
|
2557
2567
|
* @category utility types
|
|
2558
|
-
* @since 4.0
|
|
2568
|
+
* @since 0.4.0
|
|
2559
2569
|
*/
|
|
2560
2570
|
type InvokeReturn<Config> = "invoke" extends keyof Config ? Config extends {
|
|
2561
2571
|
readonly invoke?: infer Invoke;
|
|
@@ -2564,7 +2574,7 @@ export declare namespace Machine {
|
|
|
2564
2574
|
* Extracts the child process logic returned by an invoke source.
|
|
2565
2575
|
*
|
|
2566
2576
|
* @category utility types
|
|
2567
|
-
* @since 4.0
|
|
2577
|
+
* @since 0.4.0
|
|
2568
2578
|
*/
|
|
2569
2579
|
type InvokeLogic<Invoke> = Invoke extends {
|
|
2570
2580
|
readonly src: (...args: any) => infer Logic;
|
|
@@ -2573,7 +2583,7 @@ export declare namespace Machine {
|
|
|
2573
2583
|
* Extracts the startup error from an invoke source child process logic.
|
|
2574
2584
|
*
|
|
2575
2585
|
* @category utility types
|
|
2576
|
-
* @since 4.0
|
|
2586
|
+
* @since 0.4.0
|
|
2577
2587
|
*/
|
|
2578
2588
|
type InvokeInitialError<Invoke> = Invoke extends {
|
|
2579
2589
|
readonly [InvokeTypeId]: {
|
|
@@ -2584,7 +2594,7 @@ export declare namespace Machine {
|
|
|
2584
2594
|
* Extracts the runtime error from an invoked child process.
|
|
2585
2595
|
*
|
|
2586
2596
|
* @category utility types
|
|
2587
|
-
* @since 4.0
|
|
2597
|
+
* @since 0.4.0
|
|
2588
2598
|
*/
|
|
2589
2599
|
type InvokeRuntimeError<Invoke> = Invoke extends {
|
|
2590
2600
|
readonly [InvokeTypeId]: {
|
|
@@ -2595,7 +2605,7 @@ export declare namespace Machine {
|
|
|
2595
2605
|
* Extracts the output from an invoked child process.
|
|
2596
2606
|
*
|
|
2597
2607
|
* @category utility types
|
|
2598
|
-
* @since 4.0
|
|
2608
|
+
* @since 0.4.0
|
|
2599
2609
|
*/
|
|
2600
2610
|
type InvokeOutput<Invoke> = Invoke extends {
|
|
2601
2611
|
readonly [InvokeTypeId]: {
|
|
@@ -2606,7 +2616,7 @@ export declare namespace Machine {
|
|
|
2606
2616
|
* Extracts the service requirements from an invoke source child process logic.
|
|
2607
2617
|
*
|
|
2608
2618
|
* @category utility types
|
|
2609
|
-
* @since 4.0
|
|
2619
|
+
* @since 0.4.0
|
|
2610
2620
|
*/
|
|
2611
2621
|
type InvokeServices<Invoke> = Invoke extends {
|
|
2612
2622
|
readonly [InvokeTypeId]: {
|
|
@@ -2617,7 +2627,7 @@ export declare namespace Machine {
|
|
|
2617
2627
|
* Extracts events emitted directly by an invoked child.
|
|
2618
2628
|
*
|
|
2619
2629
|
* @category utility types
|
|
2620
|
-
* @since 4.0
|
|
2630
|
+
* @since 0.4.0
|
|
2621
2631
|
*/
|
|
2622
2632
|
type InvokeEmits<Invoke> = Invoke extends {
|
|
2623
2633
|
readonly [InvokeTypeId]: {
|
|
@@ -2628,7 +2638,7 @@ export declare namespace Machine {
|
|
|
2628
2638
|
* Extracts events returned by an invoked child snapshot mapper.
|
|
2629
2639
|
*
|
|
2630
2640
|
* @category utility types
|
|
2631
|
-
* @since 4.0
|
|
2641
|
+
* @since 0.4.0
|
|
2632
2642
|
*/
|
|
2633
2643
|
type InvokeSnapshotEvent<Invoke> = Invoke extends {
|
|
2634
2644
|
readonly [InvokeTypeId]: {
|
|
@@ -2639,21 +2649,21 @@ export declare namespace Machine {
|
|
|
2639
2649
|
* Extracts the parent transition error contribution from invoked children.
|
|
2640
2650
|
*
|
|
2641
2651
|
* @category utility types
|
|
2642
|
-
* @since 4.0
|
|
2652
|
+
* @since 0.4.0
|
|
2643
2653
|
*/
|
|
2644
2654
|
type InvokeError<Config> = [InvokeReturn<Config>] extends [never] ? never : ChildAlreadyExistsError | InvokeInitialError<InvokeReturn<Config>> | InvokeRuntimeError<InvokeReturn<Config>>;
|
|
2645
2655
|
/**
|
|
2646
2656
|
* Extracts the parent service requirement contribution from invoked children.
|
|
2647
2657
|
*
|
|
2648
2658
|
* @category utility types
|
|
2649
|
-
* @since 4.0
|
|
2659
|
+
* @since 0.4.0
|
|
2650
2660
|
*/
|
|
2651
2661
|
type InvokeRequirements<Config> = [InvokeReturn<Config>] extends [never] ? never : MachineRuntimeRequirement | InvokeServices<InvokeReturn<Config>>;
|
|
2652
2662
|
/**
|
|
2653
2663
|
* Extracts the return value from an eventless transition.
|
|
2654
2664
|
*
|
|
2655
2665
|
* @category utility types
|
|
2656
|
-
* @since 4.0
|
|
2666
|
+
* @since 0.4.0
|
|
2657
2667
|
*/
|
|
2658
2668
|
type AlwaysReturn<Config> = Config extends {
|
|
2659
2669
|
readonly always?: infer Always;
|
|
@@ -2662,7 +2672,7 @@ export declare namespace Machine {
|
|
|
2662
2672
|
* Extracts the return value from a state completion transition.
|
|
2663
2673
|
*
|
|
2664
2674
|
* @category utility types
|
|
2665
|
-
* @since 4.0
|
|
2675
|
+
* @since 0.4.0
|
|
2666
2676
|
*/
|
|
2667
2677
|
type DoneReturn<Config> = Config extends {
|
|
2668
2678
|
readonly onDone?: infer OnDone;
|
|
@@ -2671,7 +2681,7 @@ export declare namespace Machine {
|
|
|
2671
2681
|
* Extracts the return value from a final state output function.
|
|
2672
2682
|
*
|
|
2673
2683
|
* @category utility types
|
|
2674
|
-
* @since 4.0
|
|
2684
|
+
* @since 0.4.0
|
|
2675
2685
|
*/
|
|
2676
2686
|
type FinalOutputReturn<Config> = Config extends {
|
|
2677
2687
|
readonly output?: infer Output;
|
|
@@ -2680,14 +2690,14 @@ export declare namespace Machine {
|
|
|
2680
2690
|
* Extracts all service requirements contributed by a state handler config.
|
|
2681
2691
|
*
|
|
2682
2692
|
* @category utility types
|
|
2683
|
-
* @since 4.0
|
|
2693
|
+
* @since 0.4.0
|
|
2684
2694
|
*/
|
|
2685
2695
|
type ConfigServices<Config> = Effect.Services<EventHandlerReturn<Config>> | Effect.Services<AlwaysReturn<Config>> | Effect.Services<DoneReturn<Config>> | Effect.Services<StateActionReturn<Config, "entry">> | Effect.Services<StateActionReturn<Config, "exit">> | Effect.Services<StateInitialReturn<Config>> | Effect.Services<HistoryDefaultReturn<Config>> | Effect.Services<ChoiceReturn<Config>> | InvokeRequirements<Config>;
|
|
2686
2696
|
/**
|
|
2687
2697
|
* Configuration for invoking a child process while a state is active.
|
|
2688
2698
|
*
|
|
2689
2699
|
* @category models
|
|
2690
|
-
* @since 4.0
|
|
2700
|
+
* @since 0.4.0
|
|
2691
2701
|
*/
|
|
2692
2702
|
interface InvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Event, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, ChildEmits = never, DeliveredOutput = ChildOutput> {
|
|
2693
2703
|
readonly [InvokeTypeId]: {
|
|
@@ -2737,7 +2747,7 @@ export declare namespace Machine {
|
|
|
2737
2747
|
* event before constructing one or more invoke configurations.
|
|
2738
2748
|
*
|
|
2739
2749
|
* @category models
|
|
2740
|
-
* @since 4.0
|
|
2750
|
+
* @since 0.4.0
|
|
2741
2751
|
*/
|
|
2742
2752
|
type InvokeDefinition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> = InvokeDefinitionValue | ReadonlyArray<InvokeDefinitionValue> | ((context: InvokeContext<States, Events, Emits, StateId>) => InvokeDefinitionValue | ReadonlyArray<InvokeDefinitionValue>);
|
|
2743
2753
|
type OutputHandlerConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Context> = NodeByIdentifier<States, StateId> extends {
|
|
@@ -2756,7 +2766,7 @@ export declare namespace Machine {
|
|
|
2756
2766
|
* Configuration accepted for a non-final state.
|
|
2757
2767
|
*
|
|
2758
2768
|
* @category models
|
|
2759
|
-
* @since 4.0
|
|
2769
|
+
* @since 0.4.0
|
|
2760
2770
|
*/
|
|
2761
2771
|
type ActiveStateConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, E, R> = {
|
|
2762
2772
|
readonly entry?: (context: StateActionContext<States, Events, Emits, StateId>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<any, any>;
|
|
@@ -2840,7 +2850,7 @@ export declare namespace Machine {
|
|
|
2840
2850
|
* Configuration accepted for a final state.
|
|
2841
2851
|
*
|
|
2842
2852
|
* @category models
|
|
2843
|
-
* @since 4.0
|
|
2853
|
+
* @since 0.4.0
|
|
2844
2854
|
*/
|
|
2845
2855
|
type FinalStateConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> = {
|
|
2846
2856
|
readonly entry?: (context: StateActionContext<States, Events, Emits, StateId>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<any, any>;
|
|
@@ -2853,7 +2863,7 @@ export declare namespace Machine {
|
|
|
2853
2863
|
* Configuration accepted by `handle` for a state tag.
|
|
2854
2864
|
*
|
|
2855
2865
|
* @category models
|
|
2856
|
-
* @since 4.0
|
|
2866
|
+
* @since 0.4.0
|
|
2857
2867
|
*/
|
|
2858
2868
|
type HandlerConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, E, R> = NodeByIdentifier<States, StateId> extends {
|
|
2859
2869
|
readonly type: "final";
|
|
@@ -3026,7 +3036,7 @@ export declare namespace Machine {
|
|
|
3026
3036
|
* Adds state handlers from a root state object.
|
|
3027
3037
|
*
|
|
3028
3038
|
* @category combinators
|
|
3029
|
-
* @since 4.0
|
|
3039
|
+
* @since 0.4.0
|
|
3030
3040
|
*/
|
|
3031
3041
|
interface Handler<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Input extends Schema.Top, UnhandledStates extends StateIdentifier<States>, E, R, InitialE, InitialR, FinalStates extends StateIdentifier<States>, Output, OutputStates extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>> {
|
|
3032
3042
|
<const Config extends HandlerTree<States, States, Events, Emits, E, R, "">>(config: Config & HandlerTreeValidation<States, Events, Emits, NoInfer<Config>, OutputStates | Extract<HandlerTreeEvidence<States, NoInfer<Config>>["outputState"], StateIdentifier<States>>>): HandleTreeResult<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents, Config>;
|
|
@@ -3035,14 +3045,14 @@ export declare namespace Machine {
|
|
|
3035
3045
|
* Any state config.
|
|
3036
3046
|
*
|
|
3037
3047
|
* @category utility types
|
|
3038
|
-
* @since 4.0
|
|
3048
|
+
* @since 0.4.0
|
|
3039
3049
|
*/
|
|
3040
3050
|
type AnyStateConfig = StateConfig<any, any, any, any, any, any, any> | ChoiceStateConfig<any, any, any, any>;
|
|
3041
3051
|
/**
|
|
3042
3052
|
* Runtime event-handler map stored for a single state tag.
|
|
3043
3053
|
*
|
|
3044
3054
|
* @category models
|
|
3045
|
-
* @since 4.0
|
|
3055
|
+
* @since 0.4.0
|
|
3046
3056
|
*/
|
|
3047
3057
|
type EventHandlerMap<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> = Readonly<Record<PropertyKey, ((context: HandlerContext<States, Events, Emits, StateId, EventTag, E, R>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, E, R>) | {
|
|
3048
3058
|
readonly reenter?: boolean;
|
|
@@ -3054,7 +3064,7 @@ export declare namespace Machine {
|
|
|
3054
3064
|
* Runtime state config stored for a single state tag.
|
|
3055
3065
|
*
|
|
3056
3066
|
* @category models
|
|
3057
|
-
* @since 4.0
|
|
3067
|
+
* @since 0.4.0
|
|
3058
3068
|
*/
|
|
3059
3069
|
interface StateConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> {
|
|
3060
3070
|
readonly entry?: (context: StateActionContext<States, Events, Emits, StateId>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<E, R>;
|
|
@@ -3075,7 +3085,7 @@ export declare namespace Machine {
|
|
|
3075
3085
|
* Runtime handler table stored on a machine.
|
|
3076
3086
|
*
|
|
3077
3087
|
* @category models
|
|
3078
|
-
* @since 4.0
|
|
3088
|
+
* @since 0.4.0
|
|
3079
3089
|
*/
|
|
3080
3090
|
type StateConfigs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> = Readonly<Record<PropertyKey, StateConfig<States, Events, Emits, StateId, EventTag, E, R> | ChoiceStateConfig<States, Events, Emits, ChoiceIdentifier<States>>>>;
|
|
3081
3091
|
}
|
|
@@ -3083,14 +3093,14 @@ export declare namespace Machine {
|
|
|
3083
3093
|
* Returns `true` if a value is a `Machine`.
|
|
3084
3094
|
*
|
|
3085
3095
|
* @category guards
|
|
3086
|
-
* @since 4.0
|
|
3096
|
+
* @since 0.4.0
|
|
3087
3097
|
*/
|
|
3088
3098
|
export declare const isMachine: (u: unknown) => u is Machine.Any;
|
|
3089
3099
|
/**
|
|
3090
3100
|
* Returns `true` if a state snapshot is final for a machine.
|
|
3091
3101
|
*
|
|
3092
3102
|
* @category guards
|
|
3093
|
-
* @since 4.0
|
|
3103
|
+
* @since 0.4.0
|
|
3094
3104
|
*/
|
|
3095
3105
|
export declare const isFinal: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents>, state: Machine.Snapshot<States>) => state is Machine.SnapshotContainingFinal<States, FinalStates>;
|
|
3096
3106
|
/**
|
|
@@ -3125,7 +3135,7 @@ export declare const isFinal: <const States extends Machine.StateSchemas, const
|
|
|
3125
3135
|
* ```
|
|
3126
3136
|
*
|
|
3127
3137
|
* @category constructors
|
|
3128
|
-
* @since 4.0
|
|
3138
|
+
* @since 0.4.0
|
|
3129
3139
|
*/
|
|
3130
3140
|
export declare const defineStates: DefineStates;
|
|
3131
3141
|
type MakeConfig<States extends Machine.StateSchemas, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top, InitialE, InitialR, InternalEvents extends ReadonlyArray<Machine.TaggedSchema>> = {
|
|
@@ -3192,7 +3202,7 @@ interface Make {
|
|
|
3192
3202
|
*
|
|
3193
3203
|
* @see {@link defineStates} for typed initial snapshot builders.
|
|
3194
3204
|
* @category constructors
|
|
3195
|
-
* @since 4.0
|
|
3205
|
+
* @since 0.4.0
|
|
3196
3206
|
*/
|
|
3197
3207
|
export declare const make: Make;
|
|
3198
3208
|
type EventConstructorArgs<EventSchema extends Machine.TaggedSchema> = {} extends EventSchema["~type.make.in"] ? [
|
|
@@ -3216,12 +3226,26 @@ type EventConstructorArgs<EventSchema extends Machine.TaggedSchema> = {} extends
|
|
|
3216
3226
|
* **Example**
|
|
3217
3227
|
*
|
|
3218
3228
|
* ```ts
|
|
3229
|
+
* import { Schema } from "effect"
|
|
3230
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3231
|
+
*
|
|
3232
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3233
|
+
* class Increment extends Schema.TaggedClass<Increment>("Increment")("Increment", {
|
|
3234
|
+
* by: Schema.Number
|
|
3235
|
+
* }) {}
|
|
3236
|
+
*
|
|
3237
|
+
* const States = Machine.defineStates({ Idle })
|
|
3238
|
+
* const counter = Machine.make({
|
|
3239
|
+
* states: States.states,
|
|
3240
|
+
* events: [Increment],
|
|
3241
|
+
* initial: () => States.initial.Idle.from()
|
|
3242
|
+
* }).handle({ Idle: { on: { Increment: () => States.initial.Idle.from() } } })
|
|
3243
|
+
*
|
|
3219
3244
|
* const increment = Machine.event(counter, Increment, { by: 1 })
|
|
3220
|
-
* yield* ref.send(increment)
|
|
3221
3245
|
* ```
|
|
3222
3246
|
*
|
|
3223
3247
|
* @category constructors
|
|
3224
|
-
* @since 4.0
|
|
3248
|
+
* @since 0.4.0
|
|
3225
3249
|
*/
|
|
3226
3250
|
export declare const event: <const M extends Machine.Any, const EventSchema extends Machine.TaggedSchema>(machine: M, schema: EventSchema & ([EventSchema["Type"]] extends [Machine.Event<M>] ? unknown : never), ...args: EventConstructorArgs<EventSchema>) => EventSchema["Type"];
|
|
3227
3251
|
/**
|
|
@@ -3247,9 +3271,29 @@ export declare const event: <const M extends Machine.Any, const EventSchema exte
|
|
|
3247
3271
|
* guarantee JSON-compatible values; schemas used with JSON-backed storage must
|
|
3248
3272
|
* have JSON-compatible encoded representations.
|
|
3249
3273
|
*
|
|
3274
|
+
* **Example**
|
|
3275
|
+
*
|
|
3276
|
+
* ```ts
|
|
3277
|
+
* import { Effect, Schema } from "effect"
|
|
3278
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3279
|
+
*
|
|
3280
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3281
|
+
* const States = Machine.defineStates({ Idle })
|
|
3282
|
+
* const machine = Machine.make({
|
|
3283
|
+
* states: States.states,
|
|
3284
|
+
* events: [],
|
|
3285
|
+
* initial: () => States.initial.Idle.from()
|
|
3286
|
+
* }).handle({ Idle: {} })
|
|
3287
|
+
*
|
|
3288
|
+
* const encoded = Effect.gen(function*() {
|
|
3289
|
+
* const initial = yield* Machine.planInitial(machine)
|
|
3290
|
+
* return yield* Machine.encodeSnapshot(machine, initial.state)
|
|
3291
|
+
* })
|
|
3292
|
+
* ```
|
|
3293
|
+
*
|
|
3250
3294
|
* @see {@link decodeSnapshot} for restoring an encoded snapshot.
|
|
3251
3295
|
* @category encoding
|
|
3252
|
-
* @since 4.0
|
|
3296
|
+
* @since 0.4.0
|
|
3253
3297
|
*/
|
|
3254
3298
|
export declare const encodeSnapshot: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents>, snapshot: Machine.Snapshot<States>) => Effect.Effect<Machine.EncodedSnapshot, MachineSchemaEncodeError, Machine.SnapshotEncodingServices<States>>;
|
|
3255
3299
|
/**
|
|
@@ -3271,9 +3315,30 @@ export declare const encodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
3271
3315
|
* Decoding restores logical statechart data only. It does not restart invoked
|
|
3272
3316
|
* processes, recreate spawned children, or restore a previous `MachineRef`.
|
|
3273
3317
|
*
|
|
3318
|
+
* **Example**
|
|
3319
|
+
*
|
|
3320
|
+
* ```ts
|
|
3321
|
+
* import { Effect, Schema } from "effect"
|
|
3322
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3323
|
+
*
|
|
3324
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3325
|
+
* const States = Machine.defineStates({ Idle })
|
|
3326
|
+
* const machine = Machine.make({
|
|
3327
|
+
* states: States.states,
|
|
3328
|
+
* events: [],
|
|
3329
|
+
* initial: () => States.initial.Idle.from()
|
|
3330
|
+
* }).handle({ Idle: {} })
|
|
3331
|
+
*
|
|
3332
|
+
* const roundTrip = Effect.gen(function*() {
|
|
3333
|
+
* const initial = yield* Machine.planInitial(machine)
|
|
3334
|
+
* const encoded = yield* Machine.encodeSnapshot(machine, initial.state)
|
|
3335
|
+
* return yield* Machine.decodeSnapshot(machine, encoded)
|
|
3336
|
+
* })
|
|
3337
|
+
* ```
|
|
3338
|
+
*
|
|
3274
3339
|
* @see {@link encodeSnapshot} for creating the normalized representation.
|
|
3275
3340
|
* @category decoding
|
|
3276
|
-
* @since 4.0
|
|
3341
|
+
* @since 0.4.0
|
|
3277
3342
|
*/
|
|
3278
3343
|
export declare const decodeSnapshot: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents>, encoded: unknown) => Effect.Effect<Machine.Snapshot<States>, MachineSchemaDecodeError, Machine.SnapshotDecodingServices<States>>;
|
|
3279
3344
|
/**
|
|
@@ -3317,7 +3382,7 @@ export declare const decodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
3317
3382
|
* @see {@link effect} for one-shot child effects.
|
|
3318
3383
|
* @see {@link spawn} for children whose lifetime is controlled by actions.
|
|
3319
3384
|
* @category constructors
|
|
3320
|
-
* @since 4.0
|
|
3385
|
+
* @since 0.4.0
|
|
3321
3386
|
*/
|
|
3322
3387
|
export declare const invoke: <ChildState, ChildEvent, ChildError = never, ChildRequirements = never, ChildOutput = never, ChildInitialError = never, Event = never, Address extends ChildAddress<never> | undefined = undefined>(config: {
|
|
3323
3388
|
readonly id: InvokeLifecycleId;
|
|
@@ -3352,10 +3417,27 @@ type InvokeEffectConfig<Fx extends Effect.Effect<any, any, any>, SuccessEvent, F
|
|
|
3352
3417
|
* Declare mapped outcomes in `internalEvents` unless they are also legitimate
|
|
3353
3418
|
* public commands.
|
|
3354
3419
|
*
|
|
3420
|
+
* **Example**
|
|
3421
|
+
*
|
|
3422
|
+
* ```ts
|
|
3423
|
+
* import { Effect, Schema } from "effect"
|
|
3424
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3425
|
+
*
|
|
3426
|
+
* class Loaded extends Schema.TaggedClass<Loaded>("Loaded")("Loaded", {
|
|
3427
|
+
* value: Schema.String
|
|
3428
|
+
* }) {}
|
|
3429
|
+
*
|
|
3430
|
+
* const load = Machine.invokeEffect({
|
|
3431
|
+
* id: "load",
|
|
3432
|
+
* effect: Effect.succeed("ready"),
|
|
3433
|
+
* onSuccess: (value) => new Loaded({ value })
|
|
3434
|
+
* })
|
|
3435
|
+
* ```
|
|
3436
|
+
*
|
|
3355
3437
|
* @see {@link invoke} for arbitrary child process logic.
|
|
3356
3438
|
* @see {@link after} for a state-scoped delayed event.
|
|
3357
3439
|
* @category constructors
|
|
3358
|
-
* @since 4.0
|
|
3440
|
+
* @since 0.4.0
|
|
3359
3441
|
*/
|
|
3360
3442
|
export declare const invokeEffect: <const Fx extends Effect.Effect<any, any, any>, SuccessEvent, FailureEvent = never>(config: InvokeEffectConfig<Fx, SuccessEvent, FailureEvent>) => InvokeEffectResult<Effect.Services<Fx>, SuccessEvent | (InvokeEffectIsInfallible<Fx> extends true ? never : FailureEvent)>;
|
|
3361
3443
|
/**
|
|
@@ -3365,8 +3447,19 @@ export declare const invokeEffect: <const Fx extends Effect.Effect<any, any, any
|
|
|
3365
3447
|
* that state exits. The delayed value should normally be declared in
|
|
3366
3448
|
* `internalEvents`.
|
|
3367
3449
|
*
|
|
3450
|
+
* **Example**
|
|
3451
|
+
*
|
|
3452
|
+
* ```ts
|
|
3453
|
+
* import { Schema } from "effect"
|
|
3454
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3455
|
+
*
|
|
3456
|
+
* class TimedOut extends Schema.TaggedClass<TimedOut>("TimedOut")("TimedOut", {}) {}
|
|
3457
|
+
*
|
|
3458
|
+
* const timeout = Machine.after("5 seconds", new TimedOut({}))
|
|
3459
|
+
* ```
|
|
3460
|
+
*
|
|
3368
3461
|
* @category constructors
|
|
3369
|
-
* @since 4.0
|
|
3462
|
+
* @since 0.4.0
|
|
3370
3463
|
*/
|
|
3371
3464
|
export declare const after: <Event extends {
|
|
3372
3465
|
readonly _tag: PropertyKey;
|
|
@@ -3402,7 +3495,7 @@ type RetagArgs<Target extends Machine.TaggedSchema, Source> = [
|
|
|
3402
3495
|
* remains authoritative at runtime.
|
|
3403
3496
|
*
|
|
3404
3497
|
* @category constructors
|
|
3405
|
-
* @since 4.0
|
|
3498
|
+
* @since 0.4.0
|
|
3406
3499
|
*/
|
|
3407
3500
|
export declare const retag: <const Target extends Machine.TaggedSchema, const Source extends {
|
|
3408
3501
|
readonly _tag: PropertyKey;
|
|
@@ -3435,7 +3528,7 @@ type InvokeMachineInput<Input extends Schema.Top> = Input extends typeof Schema.
|
|
|
3435
3528
|
* @see {@link invoke} for invoking lower-level process logic.
|
|
3436
3529
|
* @see {@link sendTo} for sending events to the invoked machine.
|
|
3437
3530
|
* @category constructors
|
|
3438
|
-
* @since 4.0
|
|
3531
|
+
* @since 0.4.0
|
|
3439
3532
|
*/
|
|
3440
3533
|
export declare const invokeMachine: {
|
|
3441
3534
|
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, SnapshotEvent = never, DoneEvent = never, Id extends string = string, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(config: {
|
|
@@ -3467,10 +3560,27 @@ export declare const invokeMachine: {
|
|
|
3467
3560
|
* protocol. Manual planners may inspect commands but need a running actor scope
|
|
3468
3561
|
* to execute child-addressed operations.
|
|
3469
3562
|
*
|
|
3563
|
+
* **Example**
|
|
3564
|
+
*
|
|
3565
|
+
* ```ts
|
|
3566
|
+
* import { Effect, Schema } from "effect"
|
|
3567
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3568
|
+
*
|
|
3569
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3570
|
+
* const States = Machine.defineStates({ Idle })
|
|
3571
|
+
* const machine = Machine.make({
|
|
3572
|
+
* states: States.states,
|
|
3573
|
+
* events: [],
|
|
3574
|
+
* initial: () => States.initial.Idle.from()
|
|
3575
|
+
* }).handle({ Idle: {} })
|
|
3576
|
+
*
|
|
3577
|
+
* const initialState = Effect.map(Machine.planInitial(machine), (plan) => plan.state)
|
|
3578
|
+
* ```
|
|
3579
|
+
*
|
|
3470
3580
|
* @see {@link plan} for planning a received event.
|
|
3471
3581
|
* @see {@link start} for the managed runtime protocol.
|
|
3472
3582
|
* @category constructors
|
|
3473
|
-
* @since 4.0
|
|
3583
|
+
* @since 0.4.0
|
|
3474
3584
|
*/
|
|
3475
3585
|
export declare const planInitial: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<{
|
|
3476
3586
|
readonly startingState: Machine.Snapshot<States>;
|
|
@@ -3508,7 +3618,7 @@ export declare const planInitial: <const States extends Machine.StateSchemas, co
|
|
|
3508
3618
|
* active configuration.
|
|
3509
3619
|
*
|
|
3510
3620
|
* @category getters
|
|
3511
|
-
* @since 4.0
|
|
3621
|
+
* @since 0.4.0
|
|
3512
3622
|
*/
|
|
3513
3623
|
export declare const stateNodes: <M extends Machine.Any>(machine: M) => ReadonlyArray<Machine.StateNode<Machine.StateIdentifier<Machine.States<M>>, Machine.HistoryIdentifier<Machine.States<M>>, Machine.ChoiceIdentifier<Machine.States<M>>>>;
|
|
3514
3624
|
/**
|
|
@@ -3523,7 +3633,7 @@ export declare const stateNodes: <M extends Machine.Any>(machine: M) => Readonly
|
|
|
3523
3633
|
* remain dynamic.
|
|
3524
3634
|
*
|
|
3525
3635
|
* @category getters
|
|
3526
|
-
* @since 4.0
|
|
3636
|
+
* @since 0.4.0
|
|
3527
3637
|
*/
|
|
3528
3638
|
export declare const transitionDefinitions: <M extends Machine.Any>(machine: M) => ReadonlyArray<Machine.TransitionDefinition<Machine.StateNodeIdentifier<Machine.States<M>>, Machine.TagOf<Machine.Events<M>[number]>, Machine.StateNodeIdentifier<Machine.States<M>>>>;
|
|
3529
3639
|
/**
|
|
@@ -3537,7 +3647,7 @@ export declare const transitionDefinitions: <M extends Machine.Any>(machine: M)
|
|
|
3537
3647
|
* never evaluated during inspection.
|
|
3538
3648
|
*
|
|
3539
3649
|
* @category getters
|
|
3540
|
-
* @since 4.0
|
|
3650
|
+
* @since 0.4.0
|
|
3541
3651
|
*/
|
|
3542
3652
|
export declare const activityDefinitions: <M extends Machine.Any>(machine: M) => ReadonlyArray<Machine.ActivityDefinition<Machine.StateIdentifier<Machine.States<M>>>>;
|
|
3543
3653
|
/**
|
|
@@ -3550,14 +3660,14 @@ export declare const activityDefinitions: <M extends Machine.Any>(machine: M) =>
|
|
|
3550
3660
|
* and are not returned.
|
|
3551
3661
|
*
|
|
3552
3662
|
* @category getters
|
|
3553
|
-
* @since 4.0
|
|
3663
|
+
* @since 0.4.0
|
|
3554
3664
|
*/
|
|
3555
3665
|
export declare const configuration: <M extends Machine.Any>(machine: M, state: Machine.Snapshot<Machine.States<M>>) => ReadonlyArray<Machine.ActiveStateNode<Machine.StateIdentifier<Machine.States<M>>, Machine.ChoiceIdentifier<Machine.States<M>>>>;
|
|
3556
3666
|
/**
|
|
3557
3667
|
* Returns the event tags handled by the current state snapshot.
|
|
3558
3668
|
*
|
|
3559
3669
|
* @category getters
|
|
3560
|
-
* @since 4.0
|
|
3670
|
+
* @since 0.4.0
|
|
3561
3671
|
*/
|
|
3562
3672
|
export declare const enabled: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents>, state: Machine.Snapshot<States>) => ReadonlyArray<Machine.TagOf<Events[number]>>;
|
|
3563
3673
|
/**
|
|
@@ -3577,10 +3687,32 @@ export declare const enabled: <const States extends Machine.StateSchemas, const
|
|
|
3577
3687
|
* `emittedEvents`. Events with no enabled transition are ignored and produce
|
|
3578
3688
|
* an unchanged plan.
|
|
3579
3689
|
*
|
|
3690
|
+
* **Example**
|
|
3691
|
+
*
|
|
3692
|
+
* ```ts
|
|
3693
|
+
* import { Effect, Schema } from "effect"
|
|
3694
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3695
|
+
*
|
|
3696
|
+
* class Off extends Schema.TaggedClass<Off>("Off")("Off", {}) {}
|
|
3697
|
+
* class On extends Schema.TaggedClass<On>("On")("On", {}) {}
|
|
3698
|
+
* class Toggle extends Schema.TaggedClass<Toggle>("Toggle")("Toggle", {}) {}
|
|
3699
|
+
* const States = Machine.defineStates({ Off, On })
|
|
3700
|
+
* const machine = Machine.make({
|
|
3701
|
+
* states: States.states,
|
|
3702
|
+
* events: [Toggle],
|
|
3703
|
+
* initial: () => States.initial.Off.from()
|
|
3704
|
+
* }).handle({ Off: { on: { Toggle: () => States.initial.On.from() } }, On: {} })
|
|
3705
|
+
*
|
|
3706
|
+
* const nextState = Effect.gen(function*() {
|
|
3707
|
+
* const initial = yield* Machine.planInitial(machine)
|
|
3708
|
+
* return (yield* Machine.plan(machine, initial.state, new Toggle({}))).next
|
|
3709
|
+
* })
|
|
3710
|
+
* ```
|
|
3711
|
+
*
|
|
3580
3712
|
* @see {@link planInitial} for planning machine startup.
|
|
3581
3713
|
* @see {@link start} for managed execution and lifecycle observation.
|
|
3582
3714
|
* @category combinators
|
|
3583
|
-
* @since 4.0
|
|
3715
|
+
* @since 0.4.0
|
|
3584
3716
|
*/
|
|
3585
3717
|
export declare const plan: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, state: Machine.Snapshot<States>, event: Machine.EventOf<InputEvents>) => Effect.Effect<{
|
|
3586
3718
|
readonly next: Machine.Snapshot<States>;
|
|
@@ -3644,7 +3776,7 @@ export declare const plan: <const States extends Machine.StateSchemas, const Eve
|
|
|
3644
3776
|
* @see {@link transition} for event-driven state.
|
|
3645
3777
|
* @see {@link logic} for direct control over intermediate snapshots.
|
|
3646
3778
|
* @category constructors
|
|
3647
|
-
* @since 4.0
|
|
3779
|
+
* @since 0.4.0
|
|
3648
3780
|
*/
|
|
3649
3781
|
export declare const effect: <Output, Error = never, Requirements = never>(effect: Effect.Effect<Output, Error, Requirements>) => Logic<void, never, Error, Requirements, Output>;
|
|
3650
3782
|
/**
|
|
@@ -3673,7 +3805,7 @@ export declare const effect: <Output, Error = never, Requirements = never>(effec
|
|
|
3673
3805
|
* @see {@link effect} for one-shot work.
|
|
3674
3806
|
* @see {@link transition} for event-driven state.
|
|
3675
3807
|
* @category constructors
|
|
3676
|
-
* @since 4.0
|
|
3808
|
+
* @since 0.4.0
|
|
3677
3809
|
*/
|
|
3678
3810
|
export declare const logic: <State, Event = never, Output = void, Error = never, Requirements = never, InitialError = never, InitialRequirements = never>(options: {
|
|
3679
3811
|
readonly initial: State | ((scope: Logic.Scope<Event>) => Effect.Effect<State, InitialError, InitialRequirements>);
|
|
@@ -3692,10 +3824,22 @@ export declare const logic: <State, Event = never, Output = void, Error = never,
|
|
|
3692
3824
|
* Each received event runs the transition Effect against the latest state. The
|
|
3693
3825
|
* resulting state is published before the next queued event is processed.
|
|
3694
3826
|
*
|
|
3827
|
+
* **Example**
|
|
3828
|
+
*
|
|
3829
|
+
* ```ts
|
|
3830
|
+
* import { Effect } from "effect"
|
|
3831
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3832
|
+
*
|
|
3833
|
+
* const counter = Machine.transition(
|
|
3834
|
+
* 0,
|
|
3835
|
+
* (count, event: { readonly by: number }) => Effect.succeed(count + event.by)
|
|
3836
|
+
* )
|
|
3837
|
+
* ```
|
|
3838
|
+
*
|
|
3695
3839
|
* @see {@link effect} for one-shot work.
|
|
3696
3840
|
* @see {@link logic} for direct process lifecycle control.
|
|
3697
3841
|
* @category constructors
|
|
3698
|
-
* @since 4.0
|
|
3842
|
+
* @since 0.4.0
|
|
3699
3843
|
*/
|
|
3700
3844
|
export declare const transition: <State, Event, Error = never, Requirements = never>(initial: State, transition: (state: State, event: Event) => Effect.Effect<State, Error, Requirements>) => Logic<State, Event, Error, Requirements, never>;
|
|
3701
3845
|
/**
|
|
@@ -3705,7 +3849,7 @@ export declare const transition: <State, Event, Error = never, Requirements = ne
|
|
|
3705
3849
|
* constructed descriptors for the same pair address the same invoked child.
|
|
3706
3850
|
*
|
|
3707
3851
|
* @category constructors
|
|
3708
|
-
* @since 4.0
|
|
3852
|
+
* @since 0.4.0
|
|
3709
3853
|
*/
|
|
3710
3854
|
export declare const child: <const Id extends string, M extends Machine.Any>(id: Id, machine: M) => ChildMachine<Id, M>;
|
|
3711
3855
|
/**
|
|
@@ -3715,7 +3859,7 @@ export declare const child: <const Id extends string, M extends Machine.Any>(id:
|
|
|
3715
3859
|
* the address with `spawn`, `invoke`, or `sendTo`.
|
|
3716
3860
|
*
|
|
3717
3861
|
* @category constructors
|
|
3718
|
-
* @since 4.0
|
|
3862
|
+
* @since 0.4.0
|
|
3719
3863
|
*/
|
|
3720
3864
|
export declare const childAddress: <Event = never>(id: string) => ChildAddress<Event>;
|
|
3721
3865
|
/**
|
|
@@ -3735,7 +3879,7 @@ export declare const childAddress: <Event = never>(id: string) => ChildAddress<E
|
|
|
3735
3879
|
* @see {@link invoke} for children that start and stop with a state.
|
|
3736
3880
|
* @see {@link sendTo} for sending events to named children.
|
|
3737
3881
|
* @category runtime
|
|
3738
|
-
* @since 4.0
|
|
3882
|
+
* @since 0.4.0
|
|
3739
3883
|
*/
|
|
3740
3884
|
export declare const spawn: {
|
|
3741
3885
|
<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError = never>(logic: Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>): SpawnResult<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, never, ChildInitialError>;
|
|
@@ -3745,7 +3889,7 @@ export declare const spawn: {
|
|
|
3745
3889
|
* Sends an event to a named child process of the running machine.
|
|
3746
3890
|
*
|
|
3747
3891
|
* @category runtime
|
|
3748
|
-
* @since 4.0
|
|
3892
|
+
* @since 0.4.0
|
|
3749
3893
|
*/
|
|
3750
3894
|
export declare const sendTo: {
|
|
3751
3895
|
<Child extends ChildMachine.Any>(child: Child, event: ChildMachine.Event<Child>): Effect.Effect<void, StoppedError, MachineRuntimeRequirement>;
|
|
@@ -3755,7 +3899,7 @@ export declare const sendTo: {
|
|
|
3755
3899
|
* Stops a named child process of the running machine.
|
|
3756
3900
|
*
|
|
3757
3901
|
* @category runtime
|
|
3758
|
-
* @since 4.0
|
|
3902
|
+
* @since 0.4.0
|
|
3759
3903
|
*/
|
|
3760
3904
|
export declare const stopChild: {
|
|
3761
3905
|
<Event>(child: ChildAddress<Event>): Effect.Effect<void, never, MachineRuntimeRequirement>;
|
|
@@ -3765,7 +3909,7 @@ export declare const stopChild: {
|
|
|
3765
3909
|
* Returns a stream of terminal lifecycle outcomes for a running machine.
|
|
3766
3910
|
*
|
|
3767
3911
|
* @category combinators
|
|
3768
|
-
* @since 4.0
|
|
3912
|
+
* @since 0.4.0
|
|
3769
3913
|
*/
|
|
3770
3914
|
export declare const watch: <State, Event, Error = never, Output = never>(ref: MachineRef<State, Event, Error, Output>) => Stream.Stream<RuntimeOutcome<State, Error, Output>>;
|
|
3771
3915
|
/**
|
|
@@ -3790,10 +3934,30 @@ export declare const watch: <State, Event, Error = never, Output = never>(ref: M
|
|
|
3790
3934
|
* rather than being returned by `send`. Sending after the machine reaches any
|
|
3791
3935
|
* terminal state fails immediately with `StoppedError`.
|
|
3792
3936
|
*
|
|
3937
|
+
* **Example**
|
|
3938
|
+
*
|
|
3939
|
+
* ```ts
|
|
3940
|
+
* import { Effect, Schema } from "effect"
|
|
3941
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3942
|
+
*
|
|
3943
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3944
|
+
* const States = Machine.defineStates({ Idle })
|
|
3945
|
+
* const machine = Machine.make({
|
|
3946
|
+
* states: States.states,
|
|
3947
|
+
* events: [],
|
|
3948
|
+
* initial: () => States.initial.Idle.from()
|
|
3949
|
+
* }).handle({ Idle: {} })
|
|
3950
|
+
*
|
|
3951
|
+
* const state = Effect.gen(function*() {
|
|
3952
|
+
* const ref = yield* Machine.start(machine)
|
|
3953
|
+
* return yield* ref.state
|
|
3954
|
+
* })
|
|
3955
|
+
* ```
|
|
3956
|
+
*
|
|
3793
3957
|
* @see {@link plan} for inspecting the same transition plan without executing it.
|
|
3794
3958
|
* @see {@link watch} for classified terminal outcomes.
|
|
3795
3959
|
* @category constructors
|
|
3796
|
-
* @since 4.0
|
|
3960
|
+
* @since 0.4.0
|
|
3797
3961
|
*/
|
|
3798
3962
|
export declare const start: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
3799
3963
|
/**
|
|
@@ -3820,10 +3984,32 @@ export declare const start: <const States extends Machine.StateSchemas, const Ev
|
|
|
3820
3984
|
* evaluated merely because the runtime was resumed; only ordinary subsequent
|
|
3821
3985
|
* transition planning can enter and stabilize states.
|
|
3822
3986
|
*
|
|
3987
|
+
* **Example**
|
|
3988
|
+
*
|
|
3989
|
+
* ```ts
|
|
3990
|
+
* import { Effect, Schema } from "effect"
|
|
3991
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
3992
|
+
*
|
|
3993
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
3994
|
+
* const States = Machine.defineStates({ Idle })
|
|
3995
|
+
* const machine = Machine.make({
|
|
3996
|
+
* states: States.states,
|
|
3997
|
+
* events: [],
|
|
3998
|
+
* initial: () => States.initial.Idle.from()
|
|
3999
|
+
* }).handle({ Idle: {} })
|
|
4000
|
+
*
|
|
4001
|
+
* const resumed = Effect.gen(function*() {
|
|
4002
|
+
* const initial = yield* Machine.planInitial(machine)
|
|
4003
|
+
* const encoded = yield* Machine.encodeSnapshot(machine, initial.state)
|
|
4004
|
+
* const snapshot = yield* Machine.decodeSnapshot(machine, encoded)
|
|
4005
|
+
* return yield* Machine.resume(machine, snapshot)
|
|
4006
|
+
* })
|
|
4007
|
+
* ```
|
|
4008
|
+
*
|
|
3823
4009
|
* @see {@link decodeSnapshot} for the schema and transport boundary.
|
|
3824
4010
|
* @see {@link start} for ordinary initial startup.
|
|
3825
4011
|
* @category constructors
|
|
3826
|
-
* @since 4.0
|
|
4012
|
+
* @since 0.4.0
|
|
3827
4013
|
*/
|
|
3828
4014
|
export declare const resume: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, snapshot: Machine.Snapshot<States>) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>, MachineSchemaDecodeError, ExcludeCompatibleRuntime<ExecutionServices<R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
3829
4015
|
//# sourceMappingURL=Machine.d.ts.map
|