@typeonce/effect-machine 0.4.0 → 0.5.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 +207 -1
- 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 +147 -0
- package/package.json +11 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runs Effect machines as persisted Cluster entities.
|
|
3
3
|
*
|
|
4
|
-
* @since 4.0
|
|
4
|
+
* @since 0.4.0
|
|
5
5
|
*/
|
|
6
6
|
import type * as Effect from "effect/Effect";
|
|
7
7
|
import type * as Layer from "effect/Layer";
|
|
@@ -24,7 +24,7 @@ type Snowflake = Snowflake.Snowflake;
|
|
|
24
24
|
* checkpoint.
|
|
25
25
|
*
|
|
26
26
|
* @category models
|
|
27
|
-
* @since 4.0
|
|
27
|
+
* @since 0.4.0
|
|
28
28
|
*/
|
|
29
29
|
export interface Checkpoint {
|
|
30
30
|
/** Stable identity of the machine definition that produced the snapshot. */
|
|
@@ -46,7 +46,7 @@ export interface Checkpoint {
|
|
|
46
46
|
* redelivery even after later requests have advanced the checkpoint.
|
|
47
47
|
*
|
|
48
48
|
* @category models
|
|
49
|
-
* @since 4.0
|
|
49
|
+
* @since 0.4.0
|
|
50
50
|
*/
|
|
51
51
|
export interface LoadResult {
|
|
52
52
|
/** Latest checkpoint for the entity, when one has been committed. */
|
|
@@ -58,14 +58,14 @@ export interface LoadResult {
|
|
|
58
58
|
* Result of atomically committing a Cluster machine request.
|
|
59
59
|
*
|
|
60
60
|
* @category models
|
|
61
|
-
* @since 4.0
|
|
61
|
+
* @since 0.4.0
|
|
62
62
|
*/
|
|
63
63
|
export type CommitResult = CommitResult.Committed | CommitResult.Duplicate;
|
|
64
64
|
/**
|
|
65
65
|
* Constructors and types for Cluster machine commit results.
|
|
66
66
|
*
|
|
67
67
|
* @category models
|
|
68
|
-
* @since 4.0
|
|
68
|
+
* @since 0.4.0
|
|
69
69
|
*/
|
|
70
70
|
export declare const CommitResult: {
|
|
71
71
|
Committed: () => CommitResult.Committed;
|
|
@@ -74,14 +74,15 @@ export declare const CommitResult: {
|
|
|
74
74
|
/**
|
|
75
75
|
* Types for Cluster machine commit results.
|
|
76
76
|
*
|
|
77
|
-
* @
|
|
77
|
+
* @category models
|
|
78
|
+
* @since 0.4.0
|
|
78
79
|
*/
|
|
79
80
|
export declare namespace CommitResult {
|
|
80
81
|
/**
|
|
81
82
|
* Indicates that the request id and checkpoint were committed atomically.
|
|
82
83
|
*
|
|
83
84
|
* @category models
|
|
84
|
-
* @since 4.0
|
|
85
|
+
* @since 0.4.0
|
|
85
86
|
*/
|
|
86
87
|
interface Committed {
|
|
87
88
|
readonly _tag: "Committed";
|
|
@@ -90,7 +91,7 @@ export declare namespace CommitResult {
|
|
|
90
91
|
* Indicates that the request id was already committed.
|
|
91
92
|
*
|
|
92
93
|
* @category models
|
|
93
|
-
* @since 4.0
|
|
94
|
+
* @since 0.4.0
|
|
94
95
|
*/
|
|
95
96
|
interface Duplicate {
|
|
96
97
|
readonly _tag: "Duplicate";
|
|
@@ -114,7 +115,7 @@ export declare namespace CommitResult {
|
|
|
114
115
|
* provide checkpoint-and-emission atomicity.
|
|
115
116
|
*
|
|
116
117
|
* @category services
|
|
117
|
-
* @since 4.0
|
|
118
|
+
* @since 0.4.0
|
|
118
119
|
*/
|
|
119
120
|
export { Storage };
|
|
120
121
|
/**
|
|
@@ -122,7 +123,7 @@ export { Storage };
|
|
|
122
123
|
* recognized as a redelivery.
|
|
123
124
|
*
|
|
124
125
|
* @category models
|
|
125
|
-
* @since 4.0
|
|
126
|
+
* @since 0.4.0
|
|
126
127
|
*/
|
|
127
128
|
export { Accepted };
|
|
128
129
|
/**
|
|
@@ -130,14 +131,14 @@ export { Accepted };
|
|
|
130
131
|
* advancing its checkpoint.
|
|
131
132
|
*
|
|
132
133
|
* @category models
|
|
133
|
-
* @since 4.0
|
|
134
|
+
* @since 0.4.0
|
|
134
135
|
*/
|
|
135
136
|
export declare const RejectionReason: Schema.Literals<readonly ["MachineIdMismatch", "VersionMismatch", "InvalidCheckpoint", "UnsupportedProcessLocal", "TransitionFailure", "PersistenceFailure", "EmissionFailure"]>;
|
|
136
137
|
/**
|
|
137
138
|
* Type of {@link RejectionReason}.
|
|
138
139
|
*
|
|
139
140
|
* @category models
|
|
140
|
-
* @since 4.0
|
|
141
|
+
* @since 0.4.0
|
|
141
142
|
*/
|
|
142
143
|
export type RejectionReason = typeof RejectionReason.Type;
|
|
143
144
|
/**
|
|
@@ -145,14 +146,14 @@ export type RejectionReason = typeof RejectionReason.Type;
|
|
|
145
146
|
* leaves the previous checkpoint in place and suppresses emitted events.
|
|
146
147
|
*
|
|
147
148
|
* @category models
|
|
148
|
-
* @since 4.0
|
|
149
|
+
* @since 0.4.0
|
|
149
150
|
*/
|
|
150
151
|
export { Rejected };
|
|
151
152
|
/**
|
|
152
153
|
* Schema for Cluster machine request outcomes.
|
|
153
154
|
*
|
|
154
155
|
* @category schemas
|
|
155
|
-
* @since 4.0
|
|
156
|
+
* @since 0.4.0
|
|
156
157
|
*/
|
|
157
158
|
export declare const SendResult: Schema.Union<readonly [typeof internal.Accepted, typeof internal.Rejected]>;
|
|
158
159
|
type SendRpc<Events extends ReadonlyArray<Machine.Machine.TaggedSchema>> = Rpc.Rpc<"send", Schema.Union<Events>, typeof SendResult>;
|
|
@@ -168,7 +169,7 @@ type MachineEmits<M extends Machine.Machine.Any> = Machine.Machine.Emits<M>;
|
|
|
168
169
|
* the checkpoint at most once.
|
|
169
170
|
*
|
|
170
171
|
* @category models
|
|
171
|
-
* @since 4.0
|
|
172
|
+
* @since 0.4.0
|
|
172
173
|
*/
|
|
173
174
|
export interface ClusterMachine<in out Type extends string, in out M extends Machine.Machine.Any, out Services = MachineServices<M>> {
|
|
174
175
|
/** Machine definition executed by each entity instance. */
|
|
@@ -186,7 +187,7 @@ export interface ClusterMachine<in out Type extends string, in out M extends Mac
|
|
|
186
187
|
* is persisted after commit and recovered through request-id deduplication if
|
|
187
188
|
* delivery is interrupted. Machines that never emit may omit `enqueue`.
|
|
188
189
|
*
|
|
189
|
-
* @since 4.0
|
|
190
|
+
* @since 0.4.0
|
|
190
191
|
*/
|
|
191
192
|
readonly toLayer: <R = never>(options?: {
|
|
192
193
|
readonly enqueue?: (event: Machine.Machine.EmitOf<MachineEmits<M>>) => Effect.Effect<void, unknown, R>;
|
|
@@ -209,14 +210,14 @@ type ExcludeCompatibleRuntime<Requirements, Events, Emits> = Requirements extend
|
|
|
209
210
|
* `MessageStorage` transaction marker.
|
|
210
211
|
*
|
|
211
212
|
* @category constructors
|
|
212
|
-
* @since 4.0
|
|
213
|
+
* @since 0.4.0
|
|
213
214
|
*/
|
|
214
215
|
export declare const makeMemory: Effect.Effect<Storage["Service"]>;
|
|
215
216
|
/**
|
|
216
217
|
* Layer providing the in-memory Cluster machine checkpoint store.
|
|
217
218
|
*
|
|
218
219
|
* @category layers
|
|
219
|
-
* @since 4.0
|
|
220
|
+
* @since 0.4.0
|
|
220
221
|
*/
|
|
221
222
|
export declare const layerMemory: Layer.Layer<Storage>;
|
|
222
223
|
/**
|
|
@@ -243,8 +244,26 @@ export declare const layerMemory: Layer.Layer<Storage>;
|
|
|
243
244
|
* Arbitrary action effects may run again after a crash before checkpoint
|
|
244
245
|
* commit, so the bridge does not provide exactly-once external effects.
|
|
245
246
|
*
|
|
247
|
+
* **Example**
|
|
248
|
+
*
|
|
249
|
+
* ```ts
|
|
250
|
+
* import { Schema } from "effect"
|
|
251
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
252
|
+
* import { ClusterMachine } from "@typeonce/effect-machine/cluster"
|
|
253
|
+
*
|
|
254
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
255
|
+
* const States = Machine.defineStates({ Idle })
|
|
256
|
+
* const machine = Machine.make({
|
|
257
|
+
* states: States.states,
|
|
258
|
+
* events: [],
|
|
259
|
+
* initial: () => States.initial.Idle.from()
|
|
260
|
+
* }).handle({ Idle: {} })
|
|
261
|
+
*
|
|
262
|
+
* const adapter = ClusterMachine.make("IdleMachine", machine, { version: "1" })
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
246
265
|
* @category constructors
|
|
247
|
-
* @since 4.0
|
|
266
|
+
* @since 0.4.0
|
|
248
267
|
*/
|
|
249
268
|
export declare const make: <const Type extends string, States extends Machine.Machine.StateSchemas, Events extends ReadonlyArray<Machine.Machine.TaggedSchema>, Input extends Schema.Top, UnhandledStates extends Machine.Machine.StateIdentifier<States>, E, R, InitialE, InitialR, FinalStates extends Machine.Machine.StateIdentifier<States>, Output, Emits extends ReadonlyArray<Machine.Machine.TaggedSchema>, OutputStates extends Machine.Machine.StateIdentifier<States>, InputEvents extends ReadonlyArray<Machine.Machine.TaggedSchema> = Events>(type: Type, machine: Machine.Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, options: {
|
|
250
269
|
readonly version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClusterMachine.d.ts","sourceRoot":"","sources":["../../../src/unstable/cluster/ClusterMachine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA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MAAM,CAAC,CACnC,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { Accepted, Rejected, Storage } from "../../internal/machine/cluster.js";
|
|
|
5
5
|
* Constructors and types for Cluster machine commit results.
|
|
6
6
|
*
|
|
7
7
|
* @category models
|
|
8
|
-
* @since 4.0
|
|
8
|
+
* @since 0.4.0
|
|
9
9
|
*/
|
|
10
10
|
export const CommitResult = {
|
|
11
11
|
Committed: () => ({ _tag: "Committed" }),
|
|
@@ -29,7 +29,7 @@ export const CommitResult = {
|
|
|
29
29
|
* provide checkpoint-and-emission atomicity.
|
|
30
30
|
*
|
|
31
31
|
* @category services
|
|
32
|
-
* @since 4.0
|
|
32
|
+
* @since 0.4.0
|
|
33
33
|
*/
|
|
34
34
|
export { Storage };
|
|
35
35
|
/**
|
|
@@ -37,7 +37,7 @@ export { Storage };
|
|
|
37
37
|
* recognized as a redelivery.
|
|
38
38
|
*
|
|
39
39
|
* @category models
|
|
40
|
-
* @since 4.0
|
|
40
|
+
* @since 0.4.0
|
|
41
41
|
*/
|
|
42
42
|
export { Accepted };
|
|
43
43
|
/**
|
|
@@ -45,7 +45,7 @@ export { Accepted };
|
|
|
45
45
|
* advancing its checkpoint.
|
|
46
46
|
*
|
|
47
47
|
* @category models
|
|
48
|
-
* @since 4.0
|
|
48
|
+
* @since 0.4.0
|
|
49
49
|
*/
|
|
50
50
|
export const RejectionReason = Schema.Literals([
|
|
51
51
|
"MachineIdMismatch",
|
|
@@ -61,14 +61,14 @@ export const RejectionReason = Schema.Literals([
|
|
|
61
61
|
* leaves the previous checkpoint in place and suppresses emitted events.
|
|
62
62
|
*
|
|
63
63
|
* @category models
|
|
64
|
-
* @since 4.0
|
|
64
|
+
* @since 0.4.0
|
|
65
65
|
*/
|
|
66
66
|
export { Rejected };
|
|
67
67
|
/**
|
|
68
68
|
* Schema for Cluster machine request outcomes.
|
|
69
69
|
*
|
|
70
70
|
* @category schemas
|
|
71
|
-
* @since 4.0
|
|
71
|
+
* @since 0.4.0
|
|
72
72
|
*/
|
|
73
73
|
export const SendResult = Schema.Union([Accepted, Rejected]);
|
|
74
74
|
/**
|
|
@@ -85,14 +85,14 @@ export const SendResult = Schema.Union([Accepted, Rejected]);
|
|
|
85
85
|
* `MessageStorage` transaction marker.
|
|
86
86
|
*
|
|
87
87
|
* @category constructors
|
|
88
|
-
* @since 4.0
|
|
88
|
+
* @since 0.4.0
|
|
89
89
|
*/
|
|
90
90
|
export const makeMemory = internal.makeMemory;
|
|
91
91
|
/**
|
|
92
92
|
* Layer providing the in-memory Cluster machine checkpoint store.
|
|
93
93
|
*
|
|
94
94
|
* @category layers
|
|
95
|
-
* @since 4.0
|
|
95
|
+
* @since 0.4.0
|
|
96
96
|
*/
|
|
97
97
|
export const layerMemory = internal.layerMemory;
|
|
98
98
|
/**
|
|
@@ -119,8 +119,26 @@ export const layerMemory = internal.layerMemory;
|
|
|
119
119
|
* Arbitrary action effects may run again after a crash before checkpoint
|
|
120
120
|
* commit, so the bridge does not provide exactly-once external effects.
|
|
121
121
|
*
|
|
122
|
+
* **Example**
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { Schema } from "effect"
|
|
126
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
127
|
+
* import { ClusterMachine } from "@typeonce/effect-machine/cluster"
|
|
128
|
+
*
|
|
129
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
130
|
+
* const States = Machine.defineStates({ Idle })
|
|
131
|
+
* const machine = Machine.make({
|
|
132
|
+
* states: States.states,
|
|
133
|
+
* events: [],
|
|
134
|
+
* initial: () => States.initial.Idle.from()
|
|
135
|
+
* }).handle({ Idle: {} })
|
|
136
|
+
*
|
|
137
|
+
* const adapter = ClusterMachine.make("IdleMachine", machine, { version: "1" })
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
122
140
|
* @category constructors
|
|
123
|
-
* @since 4.0
|
|
141
|
+
* @since 0.4.0
|
|
124
142
|
*/
|
|
125
143
|
export const make = internal.make;
|
|
126
144
|
//# sourceMappingURL=ClusterMachine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClusterMachine.js","sourceRoot":"","sources":["../../../src/unstable/cluster/ClusterMachine.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,QAAQ,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AA4D/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAChE,SAAS,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;CACjE,CAAA;
|
|
1
|
+
{"version":3,"file":"ClusterMachine.js","sourceRoot":"","sources":["../../../src/unstable/cluster/ClusterMachine.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,QAAQ,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AA4D/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAChE,SAAS,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;CACjE,CAAA;AA8BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,CAAA;AAEnB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7C,mBAAmB;IACnB,iBAAiB;IACjB,mBAAmB;IACnB,yBAAyB;IACzB,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;CAClB,CAAC,CAAA;AAUF;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,CAAA;AAEnB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AA0E5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsC,QAAQ,CAAC,UAAU,CAAA;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAyB,QAAQ,CAAC,WAAW,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,IAAI,GA8Db,QAAQ,CAAC,IAAI,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Atom bridge for running machines.
|
|
3
3
|
*
|
|
4
|
-
* @since 4.0
|
|
4
|
+
* @since 0.4.0
|
|
5
5
|
*/
|
|
6
6
|
import type * as Option from "effect/Option";
|
|
7
7
|
import type * as Schema from "effect/Schema";
|
|
@@ -14,14 +14,14 @@ import type * as Machine from "../../Machine.js";
|
|
|
14
14
|
* Error returned when a machine command is issued before startup completes.
|
|
15
15
|
*
|
|
16
16
|
* @category errors
|
|
17
|
-
* @since 4.0
|
|
17
|
+
* @since 0.4.0
|
|
18
18
|
*/
|
|
19
19
|
export { NotReadyError } from "../../internal/machine/atom.js";
|
|
20
20
|
/**
|
|
21
21
|
* Error returned when a command targets a child machine that is not active.
|
|
22
22
|
*
|
|
23
23
|
* @category errors
|
|
24
|
-
* @since 4.0
|
|
24
|
+
* @since 0.4.0
|
|
25
25
|
*/
|
|
26
26
|
export { ChildNotActiveError } from "../../internal/machine/atom.js";
|
|
27
27
|
type AtomSupportedRequirements = Scope.Scope | AtomRegistry.AtomRegistry;
|
|
@@ -46,19 +46,19 @@ type MachineStartError<InitialE, E, InitialR, R, RuntimeError = never> = Initial
|
|
|
46
46
|
* same atom values share one running machine per registry.
|
|
47
47
|
*
|
|
48
48
|
* @category models
|
|
49
|
-
* @since 4.0
|
|
49
|
+
* @since 0.4.0
|
|
50
50
|
*/
|
|
51
51
|
export interface MachineAtom<State, Event, Error = never, Output = never, StartError = never> {
|
|
52
52
|
/**
|
|
53
53
|
* Atom containing the running machine handle once startup succeeds.
|
|
54
54
|
*
|
|
55
|
-
* @since 4.0
|
|
55
|
+
* @since 0.4.0
|
|
56
56
|
*/
|
|
57
57
|
readonly ref: Atom.Atom<AsyncResult.AsyncResult<Machine.MachineRef<State, Event, Error, Output>, StartError>>;
|
|
58
58
|
/**
|
|
59
59
|
* Atom containing the latest machine lifecycle snapshot.
|
|
60
60
|
*
|
|
61
|
-
* @since 4.0
|
|
61
|
+
* @since 0.4.0
|
|
62
62
|
*/
|
|
63
63
|
readonly snapshot: Atom.Atom<AsyncResult.AsyncResult<Machine.RuntimeSnapshot<State, Error, Output>, StartError>>;
|
|
64
64
|
/**
|
|
@@ -68,28 +68,28 @@ export interface MachineAtom<State, Event, Error = never, Output = never, StartE
|
|
|
68
68
|
* runtime snapshot reports a terminal error. Use `result` when runtime
|
|
69
69
|
* failures must be represented in the atom failure channel.
|
|
70
70
|
*
|
|
71
|
-
* @since 4.0
|
|
71
|
+
* @since 0.4.0
|
|
72
72
|
*/
|
|
73
73
|
readonly state: Atom.Atom<AsyncResult.AsyncResult<State, StartError>>;
|
|
74
74
|
/**
|
|
75
75
|
* Atom containing the current state, with startup and runtime failures in
|
|
76
76
|
* one typed failure channel.
|
|
77
77
|
*
|
|
78
|
-
* @since 4.0
|
|
78
|
+
* @since 0.4.0
|
|
79
79
|
*/
|
|
80
80
|
readonly result: Atom.Atom<AsyncResult.AsyncResult<State, StartError | Error>>;
|
|
81
81
|
/**
|
|
82
82
|
* Writable atom that sends events to the machine. Writes before startup
|
|
83
83
|
* completes fail with `NotReadyError`.
|
|
84
84
|
*
|
|
85
|
-
* @since 4.0
|
|
85
|
+
* @since 0.4.0
|
|
86
86
|
*/
|
|
87
87
|
readonly send: Atom.Writable<AsyncResult.AsyncResult<void, StartError | NotReadyError | Machine.StoppedError>, Event>;
|
|
88
88
|
/**
|
|
89
89
|
* Writable atom that stops the machine. Writes before startup completes fail
|
|
90
90
|
* with `NotReadyError`.
|
|
91
91
|
*
|
|
92
|
-
* @since 4.0
|
|
92
|
+
* @since 0.4.0
|
|
93
93
|
*/
|
|
94
94
|
readonly stop: Atom.Writable<AsyncResult.AsyncResult<void, StartError | NotReadyError>, void>;
|
|
95
95
|
/**
|
|
@@ -97,7 +97,7 @@ export interface MachineAtom<State, Event, Error = never, Output = never, StartE
|
|
|
97
97
|
* Reusing the same descriptor returns the same live bridge while it remains
|
|
98
98
|
* referenced.
|
|
99
99
|
*
|
|
100
|
-
* @since 4.0
|
|
100
|
+
* @since 0.4.0
|
|
101
101
|
*/
|
|
102
102
|
readonly child: <Child extends Machine.ChildMachine.Any>(child: Child) => ChildMachineAtom<Child, StartError>;
|
|
103
103
|
}
|
|
@@ -119,19 +119,19 @@ type RefOutput<Ref> = Ref extends Machine.MachineRef<any, any, any, infer Output
|
|
|
119
119
|
* machine invoked by the selected child.
|
|
120
120
|
*
|
|
121
121
|
* @category models
|
|
122
|
-
* @since 4.0
|
|
122
|
+
* @since 0.4.0
|
|
123
123
|
*/
|
|
124
124
|
export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartError = unknown> {
|
|
125
125
|
/**
|
|
126
126
|
* Atom containing the current child reference when the child is active.
|
|
127
127
|
*
|
|
128
|
-
* @since 4.0
|
|
128
|
+
* @since 0.4.0
|
|
129
129
|
*/
|
|
130
130
|
readonly ref: Atom.Atom<AsyncResult.AsyncResult<Option.Option<Machine.ChildMachine.Ref<Child>>, StartError>>;
|
|
131
131
|
/**
|
|
132
132
|
* Atom containing the current child lifecycle snapshot when active.
|
|
133
133
|
*
|
|
134
|
-
* @since 4.0
|
|
134
|
+
* @since 0.4.0
|
|
135
135
|
*/
|
|
136
136
|
readonly snapshot: Atom.Atom<AsyncResult.AsyncResult<Option.Option<Machine.RuntimeSnapshot<RefState<Machine.ChildMachine.Ref<Child>>, RefError<Machine.ChildMachine.Ref<Child>>, RefOutput<Machine.ChildMachine.Ref<Child>>>>, StartError>>;
|
|
137
137
|
/**
|
|
@@ -140,14 +140,14 @@ export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartE
|
|
|
140
140
|
* Runtime failures retain the last successful state. Use `result` when they
|
|
141
141
|
* must be represented in the atom failure channel.
|
|
142
142
|
*
|
|
143
|
-
* @since 4.0
|
|
143
|
+
* @since 0.4.0
|
|
144
144
|
*/
|
|
145
145
|
readonly state: Atom.Atom<AsyncResult.AsyncResult<Option.Option<RefState<Machine.ChildMachine.Ref<Child>>>, StartError>>;
|
|
146
146
|
/**
|
|
147
147
|
* Atom containing the current child state when active, with startup and
|
|
148
148
|
* runtime failures in one typed failure channel.
|
|
149
149
|
*
|
|
150
|
-
* @since 4.0
|
|
150
|
+
* @since 0.4.0
|
|
151
151
|
*/
|
|
152
152
|
readonly result: Atom.Atom<AsyncResult.AsyncResult<Option.Option<RefState<Machine.ChildMachine.Ref<Child>>>, StartError | RefError<Machine.ChildMachine.Ref<Child>>>>;
|
|
153
153
|
/**
|
|
@@ -155,7 +155,7 @@ export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartE
|
|
|
155
155
|
*
|
|
156
156
|
* Writes fail with `ChildNotActiveError` while the child is inactive.
|
|
157
157
|
*
|
|
158
|
-
* @since 4.0
|
|
158
|
+
* @since 0.4.0
|
|
159
159
|
*/
|
|
160
160
|
readonly send: Atom.Writable<AsyncResult.AsyncResult<void, StartError | NotReadyError | ChildNotActiveError | Machine.StoppedError>, Machine.ChildMachine.Event<Child>>;
|
|
161
161
|
/**
|
|
@@ -163,14 +163,14 @@ export interface ChildMachineAtom<Child extends Machine.ChildMachine.Any, StartE
|
|
|
163
163
|
*
|
|
164
164
|
* Writes fail with `ChildNotActiveError` while the child is inactive.
|
|
165
165
|
*
|
|
166
|
-
* @since 4.0
|
|
166
|
+
* @since 0.4.0
|
|
167
167
|
*/
|
|
168
168
|
readonly stop: Atom.Writable<AsyncResult.AsyncResult<void, StartError | NotReadyError | ChildNotActiveError>, void>;
|
|
169
169
|
/**
|
|
170
170
|
* Creates a reactive bridge for a directly owned nested child. Reusing the
|
|
171
171
|
* same descriptor returns the same live bridge while it remains referenced.
|
|
172
172
|
*
|
|
173
|
-
* @since 4.0
|
|
173
|
+
* @since 0.4.0
|
|
174
174
|
*/
|
|
175
175
|
readonly child: <Nested extends Machine.ChildMachine.Any>(child: Nested) => ChildMachineAtom<Nested, StartError>;
|
|
176
176
|
}
|
|
@@ -180,7 +180,7 @@ type BridgeStartError<Bridge> = Bridge extends MachineAtom<any, any, any, any, i
|
|
|
180
180
|
* descriptor.
|
|
181
181
|
*
|
|
182
182
|
* @category utility types
|
|
183
|
-
* @since 4.0
|
|
183
|
+
* @since 0.4.0
|
|
184
184
|
*/
|
|
185
185
|
export type ChildOf<Parent extends MachineAtom<any, any, any, any, any> | ChildMachineAtom<any, any>, Child extends Machine.ChildMachine.Any> = ChildMachineAtom<Child, BridgeStartError<Parent>>;
|
|
186
186
|
type SnapshotNode<State> = State extends Machine.Machine.AtomicSnapshot<string, unknown> ? State | (State extends {
|
|
@@ -206,12 +206,26 @@ type ChildState<Child extends Machine.ChildMachine.Any> = RefState<Machine.Child
|
|
|
206
206
|
* **Example**
|
|
207
207
|
*
|
|
208
208
|
* ```ts
|
|
209
|
-
*
|
|
210
|
-
*
|
|
209
|
+
* import { Schema } from "effect"
|
|
210
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
211
|
+
* import { AtomMachine } from "@typeonce/effect-machine/reactivity"
|
|
212
|
+
*
|
|
213
|
+
* class Count extends Schema.TaggedClass<Count>("Count")("Count", {
|
|
214
|
+
* value: Schema.Number
|
|
215
|
+
* }) {}
|
|
216
|
+
* const States = Machine.defineStates({ Count })
|
|
217
|
+
* const machine = Machine.make({
|
|
218
|
+
* states: States.states,
|
|
219
|
+
* events: [],
|
|
220
|
+
* initial: () => States.initial.Count(new Count({ value: 0 }))
|
|
221
|
+
* }).handle({ Count: {} })
|
|
222
|
+
* const machineAtom = AtomMachine.make(machine)
|
|
223
|
+
*
|
|
224
|
+
* const countAtom = AtomMachine.select(machineAtom, "Count")
|
|
211
225
|
* ```
|
|
212
226
|
*
|
|
213
227
|
* @category combinators
|
|
214
|
-
* @since 4.0
|
|
228
|
+
* @since 0.4.0
|
|
215
229
|
*/
|
|
216
230
|
export declare const select: <State extends Machine.Machine.AtomicSnapshot<string, unknown>, Event, Error, Output, StartError, const Path extends SnapshotIdentifier<State>>(self: MachineAtom<State, Event, Error, Output, StartError>, path: Path) => Atom.Atom<AsyncResult.AsyncResult<Option.Option<SnapshotValueByIdentifier<State, Path>>, StartError | Error>>;
|
|
217
231
|
/**
|
|
@@ -229,7 +243,7 @@ export declare const select: <State extends Machine.Machine.AtomicSnapshot<strin
|
|
|
229
243
|
* ```
|
|
230
244
|
*
|
|
231
245
|
* @category combinators
|
|
232
|
-
* @since 4.0
|
|
246
|
+
* @since 0.4.0
|
|
233
247
|
*/
|
|
234
248
|
export declare const selectChild: <Child extends Machine.ChildMachine.Any, StartError, const Path extends SnapshotIdentifier<ChildState<Child>>>(self: ChildMachineAtom<Child, StartError>, path: Path) => Atom.Atom<AsyncResult.AsyncResult<Option.Option<SnapshotValueByIdentifier<ChildState<Child>, Path>>, StartError | RefError<Machine.ChildMachine.Ref<Child>>>>;
|
|
235
249
|
/**
|
|
@@ -239,8 +253,27 @@ export declare const selectChild: <Child extends Machine.ChildMachine.Any, Start
|
|
|
239
253
|
* The derived atom suppresses equal updates. Runtime failures remain in the
|
|
240
254
|
* typed failure channel.
|
|
241
255
|
*
|
|
256
|
+
* **Example**
|
|
257
|
+
*
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { Schema } from "effect"
|
|
260
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
261
|
+
* import { AtomMachine } from "@typeonce/effect-machine/reactivity"
|
|
262
|
+
*
|
|
263
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
264
|
+
* const States = Machine.defineStates({ Idle })
|
|
265
|
+
* const machine = Machine.make({
|
|
266
|
+
* states: States.states,
|
|
267
|
+
* events: [],
|
|
268
|
+
* initial: () => States.initial.Idle.from()
|
|
269
|
+
* }).handle({ Idle: {} })
|
|
270
|
+
* const machineAtom = AtomMachine.make(machine)
|
|
271
|
+
*
|
|
272
|
+
* const isIdleAtom = AtomMachine.matches(machineAtom, "Idle")
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
242
275
|
* @category combinators
|
|
243
|
-
* @since 4.0
|
|
276
|
+
* @since 0.4.0
|
|
244
277
|
*/
|
|
245
278
|
export declare const matches: <State extends Machine.Machine.AtomicSnapshot<string, unknown>, Event, Error, Output, StartError, const Path extends SnapshotIdentifier<State>>(self: MachineAtom<State, Event, Error, Output, StartError>, path: Path) => Atom.Atom<AsyncResult.AsyncResult<boolean, StartError | Error>>;
|
|
246
279
|
/**
|
|
@@ -251,7 +284,7 @@ export declare const matches: <State extends Machine.Machine.AtomicSnapshot<stri
|
|
|
251
284
|
* constructing it inside a component.
|
|
252
285
|
*
|
|
253
286
|
* @category combinators
|
|
254
|
-
* @since 4.0
|
|
287
|
+
* @since 0.4.0
|
|
255
288
|
*/
|
|
256
289
|
export declare const matchesChild: <Child extends Machine.ChildMachine.Any, StartError, const Path extends SnapshotIdentifier<ChildState<Child>>>(self: ChildMachineAtom<Child, StartError>, path: Path) => Atom.Atom<AsyncResult.AsyncResult<boolean, StartError | RefError<Machine.ChildMachine.Ref<Child>>>>;
|
|
257
290
|
declare const BoundRequirementsTypeId = "~effect/reactivity/AtomMachine/BoundRequirements";
|
|
@@ -281,7 +314,7 @@ type ResumedMachineAtomOf<M extends Machine.Machine.Any, RuntimeError> = Machine
|
|
|
281
314
|
* An `AtomMachine` factory with one owned Effect runtime.
|
|
282
315
|
*
|
|
283
316
|
* @category models
|
|
284
|
-
* @since 4.0
|
|
317
|
+
* @since 0.4.0
|
|
285
318
|
*/
|
|
286
319
|
export interface Bound<Services, RuntimeError = never> {
|
|
287
320
|
/**
|
|
@@ -290,7 +323,7 @@ export interface Bound<Services, RuntimeError = never> {
|
|
|
290
323
|
* The machine's external service requirements must be provided by the
|
|
291
324
|
* runtime. Machine-native runtime requirements are supplied automatically.
|
|
292
325
|
*
|
|
293
|
-
* @since 4.0
|
|
326
|
+
* @since 0.4.0
|
|
294
327
|
*/
|
|
295
328
|
readonly make: <M extends Machine.Machine.Any>(machine: M & EnsureBoundRequirements<Services, NoInfer<M>> & EnsureMachineExecutable<NoInfer<M>>, ...args: MachineInputArgsOf<M>) => MachineAtomOf<M, RuntimeError>;
|
|
296
329
|
/** Creates a lazy bridge from a decoded logical snapshot. */
|
|
@@ -302,8 +335,26 @@ export interface Bound<Services, RuntimeError = never> {
|
|
|
302
335
|
* Use `bind(runtime).make(machine)` when the machine requires external
|
|
303
336
|
* services.
|
|
304
337
|
*
|
|
338
|
+
* **Example**
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import { Schema } from "effect"
|
|
342
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
343
|
+
* import { AtomMachine } from "@typeonce/effect-machine/reactivity"
|
|
344
|
+
*
|
|
345
|
+
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
346
|
+
* const States = Machine.defineStates({ Idle })
|
|
347
|
+
* const machine = Machine.make({
|
|
348
|
+
* states: States.states,
|
|
349
|
+
* events: [],
|
|
350
|
+
* initial: () => States.initial.Idle.from()
|
|
351
|
+
* }).handle({ Idle: {} })
|
|
352
|
+
*
|
|
353
|
+
* const machineAtom = AtomMachine.make(machine)
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
305
356
|
* @category constructors
|
|
306
|
-
* @since 4.0
|
|
357
|
+
* @since 0.4.0
|
|
307
358
|
*/
|
|
308
359
|
export declare const make: {
|
|
309
360
|
<const States extends Machine.Machine.StateSchemas, const Events extends ReadonlyArray<Machine.Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.Machine.TaggedSchema> = any, const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.Machine.StateIdentifier<States> = Machine.Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.Machine.TaggedSchema> = Events>(machine: Machine.Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureNoExternalRequirements<MachineRequirements<InitialR, R, Machine.Machine.EventOf<Events>, Machine.Machine.EmitOf<Emits>>> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.Machine.InputArgs<Input>]): MachineAtom<Machine.Machine.Snapshot<States>, Machine.Machine.EventOf<InputEvents>, MachineRuntimeError<E, R>, Output, MachineStartError<InitialE, E, InitialR, R>>;
|
|
@@ -316,7 +367,7 @@ export declare const make: {
|
|
|
316
367
|
* function and its input, errors, and services are not involved.
|
|
317
368
|
*
|
|
318
369
|
* @category constructors
|
|
319
|
-
* @since 4.0
|
|
370
|
+
* @since 0.4.0
|
|
320
371
|
*/
|
|
321
372
|
export declare const resume: {
|
|
322
373
|
<M extends Machine.Machine.Any>(machine: M & EnsureNoExternalRequirements<MachineResumeRequirementsOf<NoInfer<M>>> & EnsureMachineExecutable<NoInfer<M>>, snapshot: Machine.Machine.Snapshot<Machine.Machine.States<M>>): ResumedMachineAtomOf<M, never>;
|
|
@@ -329,7 +380,7 @@ export declare const resume: {
|
|
|
329
380
|
* while every call to `make` still creates an independent machine bridge.
|
|
330
381
|
*
|
|
331
382
|
* @category constructors
|
|
332
|
-
* @since 4.0
|
|
383
|
+
* @since 0.4.0
|
|
333
384
|
*/
|
|
334
385
|
export declare const bind: <Services, RuntimeError>(runtime: Atom.AtomRuntime<Services, RuntimeError>) => Bound<Services, RuntimeError>;
|
|
335
386
|
//# sourceMappingURL=AtomMachine.d.ts.map
|