@typeonce/effect-machine 0.41.1 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -4
- package/dist/Machine.d.ts +159 -27
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +20 -6
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +2 -7
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +132 -87
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/childRegistry.d.ts +7 -0
- package/dist/internal/machine/childRegistry.d.ts.map +1 -1
- package/dist/internal/machine/childRegistry.js +7 -0
- package/dist/internal/machine/childRegistry.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +13 -2
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts +7 -0
- package/dist/internal/machine/invocationDefinition.d.ts.map +1 -1
- package/dist/internal/machine/invocationDefinition.js +16 -0
- package/dist/internal/machine/invocationDefinition.js.map +1 -1
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +69 -6
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/plannedSnapshot.d.ts +30 -0
- package/dist/internal/machine/plannedSnapshot.d.ts.map +1 -0
- package/dist/internal/machine/plannedSnapshot.js +103 -0
- package/dist/internal/machine/plannedSnapshot.js.map +1 -0
- package/dist/internal/machine/planner.d.ts +5 -0
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +1 -1
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +5 -4
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +60 -15
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.js +2 -2
- package/dist/internal/machine/runtimeCompiled.js.map +1 -1
- package/dist/internal/machine/runtimeGeneric.js +1 -1
- package/dist/internal/machine/runtimeGeneric.js.map +1 -1
- package/dist/internal/machine/runtimeProtocol.d.ts +2 -1
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -1
- package/dist/internal/machine/runtimeProtocol.js +2 -2
- package/dist/internal/machine/runtimeProtocol.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +2 -2
- package/dist/testing/MachineTest.js +2 -2
- package/dist/unstable/reactivity/AtomMachine.d.ts +82 -19
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +0 -7
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +28 -5
- package/docs/effect-atom-react.md +207 -11
- package/docs/machine-review.md +18 -4
- package/package.json +1 -1
- package/src/Machine.ts +229 -32
- package/src/internal/machine/atom.ts +263 -113
- package/src/internal/machine/childRegistry.ts +9 -0
- package/src/internal/machine/invocation.ts +17 -2
- package/src/internal/machine/invocationDefinition.ts +19 -0
- package/src/internal/machine/machine.ts +65 -2
- package/src/internal/machine/plannedSnapshot.ts +113 -0
- package/src/internal/machine/planner.ts +1 -1
- package/src/internal/machine/runtime.ts +101 -28
- package/src/internal/machine/runtimeCompiled.ts +2 -2
- package/src/internal/machine/runtimeGeneric.ts +1 -1
- package/src/internal/machine/runtimeProtocol.ts +4 -2
- package/src/testing/MachineTest.ts +2 -2
- package/src/unstable/reactivity/AtomMachine.ts +90 -20
|
@@ -11,7 +11,7 @@ import type * as Schema from "effect/Schema"
|
|
|
11
11
|
import type * as Scope from "effect/Scope"
|
|
12
12
|
import type * as Stream from "effect/Stream"
|
|
13
13
|
import * as internal from "../../internal/machine/atom.js"
|
|
14
|
-
import type { ChildNotActiveError
|
|
14
|
+
import type { ChildNotActiveError } from "../../internal/machine/atom.js"
|
|
15
15
|
import type { EnsureExecutable } from "../../internal/machine/readiness.js"
|
|
16
16
|
import type {
|
|
17
17
|
ExcludeCompatibleRuntime as ExcludeCompatibleMachineRuntime,
|
|
@@ -19,14 +19,6 @@ import type {
|
|
|
19
19
|
} from "../../internal/machine/requirements.js"
|
|
20
20
|
import type * as Machine from "../../Machine.js"
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Error returned when a machine command is issued before startup completes.
|
|
24
|
-
*
|
|
25
|
-
* @category errors
|
|
26
|
-
* @since 0.4.0
|
|
27
|
-
*/
|
|
28
|
-
export { NotReadyError } from "../../internal/machine/atom.js"
|
|
29
|
-
|
|
30
22
|
/**
|
|
31
23
|
* Error returned when a command targets a child machine that is not active.
|
|
32
24
|
*
|
|
@@ -114,23 +106,34 @@ export interface MachineAtom<State, Event, Error = never, Output = never, StartE
|
|
|
114
106
|
readonly result: Atom.Atom<AsyncResult.AsyncResult<State, StartError | Error>>
|
|
115
107
|
|
|
116
108
|
/**
|
|
117
|
-
* Writable atom that sends events to the machine.
|
|
118
|
-
*
|
|
109
|
+
* Writable atom that sends events to the machine.
|
|
110
|
+
*
|
|
111
|
+
* **Details**
|
|
112
|
+
*
|
|
113
|
+
* Events written while the machine is still starting are held and delivered
|
|
114
|
+
* in write order once startup succeeds. The write result is waiting until
|
|
115
|
+
* the event is delivered, and fails with the startup failure when startup
|
|
116
|
+
* fails. Writes after the machine stopped or completed fail with
|
|
117
|
+
* `StoppedError`.
|
|
119
118
|
*
|
|
120
119
|
* @since 0.4.0
|
|
121
120
|
*/
|
|
122
121
|
readonly send: Atom.Writable<
|
|
123
|
-
AsyncResult.AsyncResult<void, StartError |
|
|
122
|
+
AsyncResult.AsyncResult<void, StartError | Machine.StoppedError>,
|
|
124
123
|
Event
|
|
125
124
|
>
|
|
126
125
|
|
|
127
126
|
/**
|
|
128
|
-
* Writable atom that stops the machine.
|
|
129
|
-
*
|
|
127
|
+
* Writable atom that stops the machine.
|
|
128
|
+
*
|
|
129
|
+
* **Details**
|
|
130
|
+
*
|
|
131
|
+
* A stop written while the machine is still starting is held behind earlier
|
|
132
|
+
* writes and stops the machine as soon as startup succeeds.
|
|
130
133
|
*
|
|
131
134
|
* @since 0.4.0
|
|
132
135
|
*/
|
|
133
|
-
readonly stop: Atom.Writable<AsyncResult.AsyncResult<void, StartError
|
|
136
|
+
readonly stop: Atom.Writable<AsyncResult.AsyncResult<void, StartError>, void>
|
|
134
137
|
|
|
135
138
|
/**
|
|
136
139
|
* Creates a reactive bridge for a directly owned child machine.
|
|
@@ -144,6 +147,39 @@ export interface MachineAtom<State, Event, Error = never, Output = never, StartE
|
|
|
144
147
|
) => ChildMachineAtom<Child, StartError>
|
|
145
148
|
}
|
|
146
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Namespace containing type-level members associated with `MachineAtom`.
|
|
152
|
+
*
|
|
153
|
+
* @category models
|
|
154
|
+
* @since 0.42.0
|
|
155
|
+
*/
|
|
156
|
+
export declare namespace MachineAtom {
|
|
157
|
+
/**
|
|
158
|
+
* Any machine bridge, including bridges for machines without events.
|
|
159
|
+
*
|
|
160
|
+
* @category utility types
|
|
161
|
+
* @since 0.42.0
|
|
162
|
+
*/
|
|
163
|
+
export type Any = MachineAtom<any, never, any, any, any, any>
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Extracts the state type of a machine bridge.
|
|
167
|
+
*
|
|
168
|
+
* @category utility types
|
|
169
|
+
* @since 0.42.0
|
|
170
|
+
*/
|
|
171
|
+
export type State<A extends Any> = A extends MachineAtom<infer State, infer _Event, any, any, any, any> ? State
|
|
172
|
+
: never
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Extracts the event type accepted by a machine bridge.
|
|
176
|
+
*
|
|
177
|
+
* @category utility types
|
|
178
|
+
* @since 0.42.0
|
|
179
|
+
*/
|
|
180
|
+
export type Event<A extends Any> = A extends MachineAtom<any, infer Event, any, any, any, any> ? Event : never
|
|
181
|
+
}
|
|
182
|
+
|
|
147
183
|
type RefState<Ref> = Ref extends Machine.MachineRef<infer State, any, any, any, any> ? State : never
|
|
148
184
|
|
|
149
185
|
type RefError<Ref> = Ref extends Machine.MachineRef<any, any, infer Error, any, any> ? Error : never
|
|
@@ -251,23 +287,31 @@ export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartE
|
|
|
251
287
|
/**
|
|
252
288
|
* Writable atom that sends events to the active child.
|
|
253
289
|
*
|
|
254
|
-
*
|
|
290
|
+
* **Details**
|
|
291
|
+
*
|
|
292
|
+
* Events written while the parent machine is still starting are held and
|
|
293
|
+
* delivered in write order once the parent is ready. Writes fail with
|
|
294
|
+
* `ChildNotActiveError` when the state that owns the child is not active.
|
|
255
295
|
*
|
|
256
296
|
* @since 0.4.0
|
|
257
297
|
*/
|
|
258
298
|
readonly send: Atom.Writable<
|
|
259
|
-
AsyncResult.AsyncResult<void, StartError |
|
|
299
|
+
AsyncResult.AsyncResult<void, StartError | ChildNotActiveError | Machine.StoppedError>,
|
|
260
300
|
Machine.ChildMachine.Event<Child>
|
|
261
301
|
>
|
|
262
302
|
/**
|
|
263
303
|
* Writable atom that stops the active child.
|
|
264
304
|
*
|
|
265
|
-
*
|
|
305
|
+
* **Details**
|
|
306
|
+
*
|
|
307
|
+
* A stop written while the parent machine is still starting is held behind
|
|
308
|
+
* earlier writes. Writes fail with `ChildNotActiveError` when the state that
|
|
309
|
+
* owns the child is not active.
|
|
266
310
|
*
|
|
267
311
|
* @since 0.4.0
|
|
268
312
|
*/
|
|
269
313
|
readonly stop: Atom.Writable<
|
|
270
|
-
AsyncResult.AsyncResult<void, StartError |
|
|
314
|
+
AsyncResult.AsyncResult<void, StartError | ChildNotActiveError>,
|
|
271
315
|
void
|
|
272
316
|
>
|
|
273
317
|
/**
|
|
@@ -282,6 +326,32 @@ export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartE
|
|
|
282
326
|
) => ChildMachineAtom<Nested, StartError>
|
|
283
327
|
}
|
|
284
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Namespace containing type-level members associated with `ChildMachineAtom`.
|
|
331
|
+
*
|
|
332
|
+
* @category models
|
|
333
|
+
* @since 0.42.0
|
|
334
|
+
*/
|
|
335
|
+
export declare namespace ChildMachineAtom {
|
|
336
|
+
/**
|
|
337
|
+
* Any child machine bridge.
|
|
338
|
+
*
|
|
339
|
+
* @category utility types
|
|
340
|
+
* @since 0.42.0
|
|
341
|
+
*/
|
|
342
|
+
export type Any = ChildMachineAtom<any, any>
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Extracts the state type of the child selected by a child bridge.
|
|
346
|
+
*
|
|
347
|
+
* @category utility types
|
|
348
|
+
* @since 0.42.0
|
|
349
|
+
*/
|
|
350
|
+
export type State<A extends Any> = A extends ChildMachineAtom<infer Child, any> ?
|
|
351
|
+
RefState<Machine.ChildMachine.Ref<Child>>
|
|
352
|
+
: never
|
|
353
|
+
}
|
|
354
|
+
|
|
285
355
|
type BridgeStartError<Bridge> = Bridge extends MachineAtom<any, never, any, any, infer StartError, any> ? StartError
|
|
286
356
|
: Bridge extends ChildMachineAtom<any, infer StartError> ? StartError
|
|
287
357
|
: never
|
|
@@ -294,7 +364,7 @@ type BridgeStartError<Bridge> = Bridge extends MachineAtom<any, never, any, any,
|
|
|
294
364
|
* @since 0.4.0
|
|
295
365
|
*/
|
|
296
366
|
export type ChildOf<
|
|
297
|
-
Parent extends MachineAtom
|
|
367
|
+
Parent extends MachineAtom.Any | ChildMachineAtom.Any,
|
|
298
368
|
Child extends Machine.ChildMachine.Any
|
|
299
369
|
> = ChildMachineAtom<Child, BridgeStartError<Parent>>
|
|
300
370
|
|