@typeonce/effect-machine 0.2.0 → 0.4.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 +345 -42
- package/dist/Machine.d.ts +1273 -347
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +161 -426
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +57 -0
- package/dist/internal/machine/activities.d.ts.map +1 -0
- package/dist/internal/machine/activities.js +49 -0
- package/dist/internal/machine/activities.js.map +1 -0
- package/dist/internal/machine/atom.d.ts +69 -0
- package/dist/internal/machine/atom.d.ts.map +1 -0
- package/dist/{AtomMachine.js → internal/machine/atom.js} +19 -94
- package/dist/internal/machine/atom.js.map +1 -0
- package/dist/internal/machine/cluster.d.ts +63 -0
- package/dist/internal/machine/cluster.d.ts.map +1 -0
- package/dist/{ClusterMachine.js → internal/machine/cluster.js} +15 -119
- package/dist/internal/machine/cluster.js.map +1 -0
- package/dist/internal/machine/command.d.ts +16 -0
- package/dist/internal/machine/command.d.ts.map +1 -0
- package/dist/internal/machine/command.js +45 -0
- package/dist/internal/machine/command.js.map +1 -0
- package/dist/internal/machine/commandRuntime.d.ts +13 -0
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -0
- package/dist/internal/machine/commandRuntime.js +16 -0
- package/dist/internal/machine/commandRuntime.js.map +1 -0
- package/dist/internal/{machineModel.d.ts → machine/configuration.d.ts} +32 -38
- package/dist/internal/machine/configuration.d.ts.map +1 -0
- package/dist/internal/machine/configuration.js +965 -0
- package/dist/internal/machine/configuration.js.map +1 -0
- package/dist/internal/{machineErrors.d.ts → machine/errors.d.ts} +3 -3
- package/dist/internal/machine/errors.d.ts.map +1 -0
- package/dist/internal/{machineErrors.js → machine/errors.js} +1 -1
- package/dist/internal/machine/errors.js.map +1 -0
- package/dist/internal/machine/executionPlan.d.ts +49 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -0
- package/dist/internal/machine/executionPlan.js +667 -0
- package/dist/internal/machine/executionPlan.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +23 -0
- package/dist/internal/machine/invocation.d.ts.map +1 -0
- package/dist/internal/machine/invocation.js +77 -0
- package/dist/internal/machine/invocation.js.map +1 -0
- package/dist/internal/machine/machine.d.ts +183 -0
- package/dist/internal/machine/machine.d.ts.map +1 -0
- package/dist/internal/machine/machine.js +552 -0
- package/dist/internal/machine/machine.js.map +1 -0
- package/dist/internal/machine/planner.d.ts +182 -0
- package/dist/internal/machine/planner.d.ts.map +1 -0
- package/dist/internal/machine/planner.js +1082 -0
- package/dist/internal/machine/planner.js.map +1 -0
- package/dist/internal/{machineProcess.d.ts → machine/process.d.ts} +10 -4
- package/dist/internal/machine/process.d.ts.map +1 -0
- package/dist/internal/machine/process.js +446 -0
- package/dist/internal/machine/process.js.map +1 -0
- package/dist/internal/machine/protocol.d.ts +34 -0
- package/dist/internal/machine/protocol.d.ts.map +1 -0
- package/dist/internal/machine/protocol.js +182 -0
- package/dist/internal/machine/protocol.js.map +1 -0
- package/dist/internal/machine/readiness.d.ts +4 -0
- package/dist/internal/machine/readiness.d.ts.map +1 -0
- package/dist/internal/machine/readiness.js +2 -0
- package/dist/internal/machine/readiness.js.map +1 -0
- package/dist/internal/{machineRuntime.d.ts → machine/runtime.d.ts} +104 -2
- package/dist/internal/machine/runtime.d.ts.map +1 -0
- package/dist/internal/machine/runtime.js +1381 -0
- package/dist/internal/machine/runtime.js.map +1 -0
- package/dist/internal/machine/serialization.d.ts +14 -0
- package/dist/internal/machine/serialization.d.ts.map +1 -0
- package/dist/internal/machine/serialization.js +338 -0
- package/dist/internal/machine/serialization.js.map +1 -0
- package/dist/internal/machine/stateDefinition.d.ts +15 -0
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -0
- package/dist/internal/machine/stateDefinition.js +210 -0
- package/dist/internal/machine/stateDefinition.js.map +1 -0
- package/dist/internal/machine/symbols.d.ts +3 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -0
- package/dist/internal/machine/symbols.js +3 -0
- package/dist/internal/machine/symbols.js.map +1 -0
- package/dist/internal/machine/topology.d.ts +98 -0
- package/dist/internal/machine/topology.d.ts.map +1 -0
- package/dist/internal/machine/topology.js +347 -0
- package/dist/internal/machine/topology.js.map +1 -0
- package/dist/internal/testing/machine/arbitrary.d.ts +36 -0
- package/dist/internal/testing/machine/arbitrary.d.ts.map +1 -0
- package/dist/internal/testing/machine/arbitrary.js +68 -0
- package/dist/internal/testing/machine/arbitrary.js.map +1 -0
- package/dist/internal/testing/machine/finiteModel.d.ts +322 -0
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -0
- package/dist/internal/testing/machine/finiteModel.js +976 -0
- package/dist/internal/testing/machine/finiteModel.js.map +1 -0
- package/dist/internal/testing/machine/referenceModel.d.ts +203 -0
- package/dist/internal/testing/machine/referenceModel.d.ts.map +1 -0
- package/dist/internal/testing/machine/referenceModel.js +1012 -0
- package/dist/internal/testing/machine/referenceModel.js.map +1 -0
- package/dist/internal/testing/machine/runtime.d.ts +328 -0
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -0
- package/dist/internal/testing/machine/runtime.js +437 -0
- package/dist/internal/testing/machine/runtime.js.map +1 -0
- package/dist/internal/testing/machine/verification.d.ts +33 -0
- package/dist/internal/testing/machine/verification.d.ts.map +1 -0
- package/dist/internal/testing/machine/verification.js +1446 -0
- package/dist/internal/testing/machine/verification.js.map +1 -0
- package/dist/testing/MachineTest.d.ts +606 -0
- package/dist/testing/MachineTest.d.ts.map +1 -0
- package/dist/testing/MachineTest.js +102 -0
- package/dist/testing/MachineTest.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/{ClusterMachine.d.ts → unstable/cluster/ClusterMachine.d.ts} +22 -30
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -0
- package/dist/unstable/cluster/ClusterMachine.js +126 -0
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -0
- package/dist/{cluster.js → unstable/cluster/index.d.ts} +1 -1
- package/dist/unstable/cluster/index.d.ts.map +1 -0
- package/dist/{cluster.d.ts → unstable/cluster/index.js} +1 -1
- package/dist/unstable/cluster/index.js.map +1 -0
- package/dist/{AtomMachine.d.ts → unstable/reactivity/AtomMachine.d.ts} +40 -23
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -0
- package/dist/unstable/reactivity/AtomMachine.js +113 -0
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -0
- package/dist/{reactivity.js → unstable/reactivity/index.d.ts} +1 -1
- package/dist/unstable/reactivity/index.d.ts.map +1 -0
- package/dist/{reactivity.d.ts → unstable/reactivity/index.js} +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -0
- package/docs/agent-guide.md +271 -38
- package/package.json +23 -13
- package/dist/AtomMachine.d.ts.map +0 -1
- package/dist/AtomMachine.js.map +0 -1
- package/dist/ClusterMachine.d.ts.map +0 -1
- package/dist/ClusterMachine.js.map +0 -1
- package/dist/cluster.d.ts.map +0 -1
- package/dist/cluster.js.map +0 -1
- package/dist/internal/machineErrors.d.ts.map +0 -1
- package/dist/internal/machineErrors.js.map +0 -1
- package/dist/internal/machineModel.d.ts.map +0 -1
- package/dist/internal/machineModel.js +0 -766
- package/dist/internal/machineModel.js.map +0 -1
- package/dist/internal/machinePlanner.d.ts +0 -74
- package/dist/internal/machinePlanner.d.ts.map +0 -1
- package/dist/internal/machinePlanner.js +0 -621
- package/dist/internal/machinePlanner.js.map +0 -1
- package/dist/internal/machineProcess.d.ts.map +0 -1
- package/dist/internal/machineProcess.js +0 -181
- package/dist/internal/machineProcess.js.map +0 -1
- package/dist/internal/machineRuntime.d.ts.map +0 -1
- package/dist/internal/machineRuntime.js +0 -365
- package/dist/internal/machineRuntime.js.map +0 -1
- package/dist/reactivity.d.ts.map +0 -1
- package/dist/reactivity.js.map +0 -1
package/dist/Machine.js
CHANGED
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @since 4.0.0
|
|
5
5
|
*/
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
import * as Inspectable from "effect/Inspectable";
|
|
8
|
-
import * as Option from "effect/Option";
|
|
9
|
-
import { Prototype as PipeablePrototype } from "effect/Pipeable";
|
|
10
6
|
import { hasProperty } from "effect/Predicate";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import * as internalPlanner from "./internal/machinePlanner.js";
|
|
14
|
-
import * as internalProcess from "./internal/machineProcess.js";
|
|
15
|
-
import * as internalRuntime from "./internal/machineRuntime.js";
|
|
7
|
+
import * as internal from "./internal/machine/machine.js";
|
|
8
|
+
import { InitialEventTypeId } from "./internal/machine/machine.js";
|
|
16
9
|
/**
|
|
17
10
|
* Runtime type identifier attached to `Machine` values.
|
|
18
11
|
*
|
|
@@ -27,14 +20,14 @@ export const TypeId = "~effect/Machine";
|
|
|
27
20
|
* @category type IDs
|
|
28
21
|
* @since 4.0.0
|
|
29
22
|
*/
|
|
30
|
-
export
|
|
23
|
+
export { InitialEventTypeId };
|
|
31
24
|
/**
|
|
32
25
|
* Synthetic event value used while the machine settles its initial state.
|
|
33
26
|
*
|
|
34
27
|
* @category constructors
|
|
35
28
|
* @since 4.0.0
|
|
36
29
|
*/
|
|
37
|
-
export const InitialEvent =
|
|
30
|
+
export const InitialEvent = { _tag: InitialEventTypeId };
|
|
38
31
|
/**
|
|
39
32
|
* Returns `true` if a value is the synthetic machine initial event.
|
|
40
33
|
*
|
|
@@ -98,252 +91,29 @@ StartupError,
|
|
|
98
91
|
* @category errors
|
|
99
92
|
* @since 4.0.0
|
|
100
93
|
*/
|
|
101
|
-
StoppedError } from "./internal/
|
|
94
|
+
StoppedError } from "./internal/machine/machine.js";
|
|
102
95
|
const RuntimeRequirementTypeId = "~effect/Machine/RuntimeRequirement";
|
|
103
96
|
const ActionRequirementTypeId = "~effect/Machine/ActionRequirement";
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
97
|
+
const InvokeTypeId = internal.InvokeTypeId;
|
|
98
|
+
const SnapshotBuilderStateTypeId = internal.SnapshotBuilderStateTypeId;
|
|
99
|
+
const SnapshotBuilderConstructionTypeId = Symbol("effect/Machine/SnapshotBuilderConstruction");
|
|
107
100
|
const ChildAddressTypeId = "~effect/Machine/ChildAddress";
|
|
108
101
|
const ChildAddressCompatibilityErrorTypeId = "~effect/Machine/ChildAddressCompatibilityError";
|
|
109
102
|
const ChildMachineTypeId = "~effect/Machine/ChildMachine";
|
|
110
|
-
const Proto = {
|
|
111
|
-
...Inspectable.BaseProto,
|
|
112
|
-
...PipeablePrototype,
|
|
113
|
-
[TypeId]: TypeId,
|
|
114
|
-
toJSON() {
|
|
115
|
-
return {
|
|
116
|
-
_id: "Machine"
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const cloneWithHandlers = (self, handlers) => {
|
|
121
|
-
const machine = Object.create(Proto);
|
|
122
|
-
machine.states = self.states;
|
|
123
|
-
machine.events = self.events;
|
|
124
|
-
machine.internalEvents = self.internalEvents;
|
|
125
|
-
machine.emits = self.emits;
|
|
126
|
-
machine.input = self.input;
|
|
127
|
-
machine.id = self.id;
|
|
128
|
-
machine.initial = self.initial;
|
|
129
|
-
machine.stateNodes = self.stateNodes;
|
|
130
|
-
machine.makeTargetBuilder = self.makeTargetBuilder;
|
|
131
|
-
machine.handlers = handlers;
|
|
132
|
-
machine.handle = makeHandle(machine);
|
|
133
|
-
Model.copyProtocol(self, machine);
|
|
134
|
-
return machine;
|
|
135
|
-
};
|
|
136
|
-
const flattenHandlers = (handlers, states, prefix, config) => {
|
|
137
|
-
for (const key of Object.keys(config)) {
|
|
138
|
-
const path = prefix === "" ? key : `${prefix}.${key}`;
|
|
139
|
-
if (!hasProperty(states, key)) {
|
|
140
|
-
throw new Error(`Machine received handler for unknown state "${path}"`);
|
|
141
|
-
}
|
|
142
|
-
const nodeConfig = config[key];
|
|
143
|
-
if (typeof nodeConfig !== "object" || nodeConfig === null) {
|
|
144
|
-
throw new Error(`Machine expected state "${path}" handler to be an object`);
|
|
145
|
-
}
|
|
146
|
-
const { states: childConfig, ...stateConfig } = nodeConfig;
|
|
147
|
-
handlers[path] = stateConfig;
|
|
148
|
-
if (childConfig !== undefined) {
|
|
149
|
-
const node = Model.getStateNodeDefinition(path, states[key]);
|
|
150
|
-
if (node.states === undefined) {
|
|
151
|
-
throw new Error(`Machine expected state "${path}" to declare child states`);
|
|
152
|
-
}
|
|
153
|
-
if (typeof childConfig !== "object" || childConfig === null) {
|
|
154
|
-
throw new Error(`Machine expected state "${path}" child handlers to be an object`);
|
|
155
|
-
}
|
|
156
|
-
flattenHandlers(handlers, node.states, path, childConfig);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const makeHandle = (self) => ((config) => {
|
|
161
|
-
const handlers = Object.assign(Object.create(null), self.handlers);
|
|
162
|
-
flattenHandlers(handlers, self.states, "", config);
|
|
163
|
-
return cloneWithHandlers(self, handlers);
|
|
164
|
-
});
|
|
165
103
|
/**
|
|
166
104
|
* Returns `true` if a value is a `Machine`.
|
|
167
105
|
*
|
|
168
106
|
* @category guards
|
|
169
107
|
* @since 4.0.0
|
|
170
108
|
*/
|
|
171
|
-
export const isMachine =
|
|
109
|
+
export const isMachine = internal.isMachine;
|
|
172
110
|
/**
|
|
173
111
|
* Returns `true` if a state snapshot is final for a machine.
|
|
174
112
|
*
|
|
175
113
|
* @category guards
|
|
176
114
|
* @since 4.0.0
|
|
177
115
|
*/
|
|
178
|
-
export const isFinal =
|
|
179
|
-
const makeSnapshotBuilder = (states, options) => {
|
|
180
|
-
const builder = {};
|
|
181
|
-
for (const key of Object.keys(states)) {
|
|
182
|
-
builder[key] = (value, selector) => makeSnapshotForNode(states[key], key, value, selector, options);
|
|
183
|
-
}
|
|
184
|
-
return builder;
|
|
185
|
-
};
|
|
186
|
-
const makeParallelSnapshotBuilder = (states, options, regions) => {
|
|
187
|
-
const builder = {};
|
|
188
|
-
Object.defineProperty(builder, SnapshotBuilderStateTypeId, {
|
|
189
|
-
value: regions,
|
|
190
|
-
enumerable: false
|
|
191
|
-
});
|
|
192
|
-
for (const key of Object.keys(states)) {
|
|
193
|
-
if (hasProperty(regions, key)) {
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
builder[key] = (value, selector) => {
|
|
197
|
-
const nextRegions = {};
|
|
198
|
-
for (const regionKey of Object.keys(regions)) {
|
|
199
|
-
nextRegions[regionKey] = regions[regionKey];
|
|
200
|
-
}
|
|
201
|
-
nextRegions[key] = makeSnapshotForNode(states[key], key, value, selector, options);
|
|
202
|
-
return makeParallelSnapshotBuilder(states, options, nextRegions);
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return builder;
|
|
206
|
-
};
|
|
207
|
-
const getParallelSnapshotBuilderRegions = (path, states, builder) => {
|
|
208
|
-
if (typeof builder !== "object" || builder === null || !hasProperty(builder, SnapshotBuilderStateTypeId)) {
|
|
209
|
-
throw new Error(`Machine expected parallel state "${path}" builder callback to return a builder`);
|
|
210
|
-
}
|
|
211
|
-
const regions = builder[SnapshotBuilderStateTypeId];
|
|
212
|
-
for (const key of Object.keys(states)) {
|
|
213
|
-
if (!hasProperty(regions, key)) {
|
|
214
|
-
throw new Error(`Machine expected parallel state "${path}" builder callback to provide region "${key}"`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return regions;
|
|
218
|
-
};
|
|
219
|
-
const makeSnapshotForNode = (definition, key, value, selector, options) => {
|
|
220
|
-
const path = options.prefix === "" ? key : `${options.prefix}.${key}`;
|
|
221
|
-
const node = Model.getStateNodeDefinition(path, definition);
|
|
222
|
-
const snapshot = {
|
|
223
|
-
path,
|
|
224
|
-
value
|
|
225
|
-
};
|
|
226
|
-
if (node.states === undefined) {
|
|
227
|
-
return snapshot;
|
|
228
|
-
}
|
|
229
|
-
if (selector === undefined) {
|
|
230
|
-
throw new Error(`Machine expected state "${path}" builder to provide active child states`);
|
|
231
|
-
}
|
|
232
|
-
if (node.type === "parallel") {
|
|
233
|
-
const builder = makeParallelSnapshotBuilder(node.states, { ...options, prefix: path }, {});
|
|
234
|
-
snapshot.states = getParallelSnapshotBuilderRegions(path, node.states, selector(builder));
|
|
235
|
-
return snapshot;
|
|
236
|
-
}
|
|
237
|
-
const childStates = options.mode === "initial" && node.initial !== undefined
|
|
238
|
-
? { [node.initial]: node.states[node.initial] }
|
|
239
|
-
: node.states;
|
|
240
|
-
snapshot.state = selector(makeSnapshotBuilder(childStates, { ...options, prefix: path }));
|
|
241
|
-
return snapshot;
|
|
242
|
-
};
|
|
243
|
-
const getTargetBuilderNode = (stateNodes, path) => {
|
|
244
|
-
const node = stateNodes.byPath.get(path);
|
|
245
|
-
if (node === undefined) {
|
|
246
|
-
throw new Error(`Machine expected state path "${path}" to exist`);
|
|
247
|
-
}
|
|
248
|
-
return node;
|
|
249
|
-
};
|
|
250
|
-
const getLocalTargetScope = (stateNodes, source) => {
|
|
251
|
-
let current = source;
|
|
252
|
-
while (current !== undefined) {
|
|
253
|
-
const node = stateNodes.byPath.get(current);
|
|
254
|
-
if (node === undefined) {
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
|
-
if (node.type === "compound") {
|
|
258
|
-
return node.path;
|
|
259
|
-
}
|
|
260
|
-
current = node.parent;
|
|
261
|
-
}
|
|
262
|
-
return undefined;
|
|
263
|
-
};
|
|
264
|
-
const hasTargetValues = (values) => values !== undefined && Object.keys(values).length > 0;
|
|
265
|
-
const makeTargetWithValues = (path, value, values) => hasTargetValues(values)
|
|
266
|
-
? Model.makeTarget(path, value, { values: values })
|
|
267
|
-
: Model.makeTarget(path, value);
|
|
268
|
-
const extendTargetValues = (values, path, value) => {
|
|
269
|
-
const next = {};
|
|
270
|
-
if (values !== undefined) {
|
|
271
|
-
for (const key of Object.keys(values)) {
|
|
272
|
-
next[key] = values[key];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
next[path] = value;
|
|
276
|
-
return next;
|
|
277
|
-
};
|
|
278
|
-
const makeLocalTargetChildBuilder = (stateNodes, parentPath, values) => {
|
|
279
|
-
const parent = getTargetBuilderNode(stateNodes, parentPath);
|
|
280
|
-
const builder = {};
|
|
281
|
-
for (const childPath of parent.children) {
|
|
282
|
-
const child = getTargetBuilderNode(stateNodes, childPath);
|
|
283
|
-
builder[child.key] = (value, selector) => {
|
|
284
|
-
if (child.type === "atomic" || child.type === "final") {
|
|
285
|
-
return makeTargetWithValues(child.path, value, values);
|
|
286
|
-
}
|
|
287
|
-
if (selector === undefined) {
|
|
288
|
-
throw new Error(`Machine expected target "${child.path}" builder to provide an active child state`);
|
|
289
|
-
}
|
|
290
|
-
return selector(makeLocalTargetChildBuilder(stateNodes, child.path, extendTargetValues(values, child.path, value)));
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
return builder;
|
|
294
|
-
};
|
|
295
|
-
const makeLocalTargetBuilder = (stateNodes, source) => {
|
|
296
|
-
const scope = getLocalTargetScope(stateNodes, source);
|
|
297
|
-
if (scope === undefined) {
|
|
298
|
-
return {};
|
|
299
|
-
}
|
|
300
|
-
const builder = makeLocalTargetChildBuilder(stateNodes, scope, undefined);
|
|
301
|
-
builder.with = (value, selector) => {
|
|
302
|
-
if (selector === undefined) {
|
|
303
|
-
throw new Error(`Machine expected target "${scope}" builder to provide an active child state`);
|
|
304
|
-
}
|
|
305
|
-
return selector(makeLocalTargetChildBuilder(stateNodes, scope, { [scope]: value }));
|
|
306
|
-
};
|
|
307
|
-
return builder;
|
|
308
|
-
};
|
|
309
|
-
const addBranchTargetChildren = (builder, stateNodes, parentPath, values) => {
|
|
310
|
-
const parent = getTargetBuilderNode(stateNodes, parentPath);
|
|
311
|
-
for (const childPath of parent.children) {
|
|
312
|
-
const child = getTargetBuilderNode(stateNodes, childPath);
|
|
313
|
-
builder[child.key] = makeBranchTargetNodeBuilder(stateNodes, child.path, values);
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
const makeBranchTargetNodeBuilder = (stateNodes, path, values) => {
|
|
317
|
-
const node = getTargetBuilderNode(stateNodes, path);
|
|
318
|
-
if (node.type === "atomic" || node.type === "final") {
|
|
319
|
-
return (value) => makeTargetWithValues(node.path, value, values);
|
|
320
|
-
}
|
|
321
|
-
const builder = ((value, selector) => {
|
|
322
|
-
if (selector === undefined) {
|
|
323
|
-
throw new Error(`Machine expected target "${node.path}" builder to provide an active child state`);
|
|
324
|
-
}
|
|
325
|
-
const nextBuilder = {};
|
|
326
|
-
addBranchTargetChildren(nextBuilder, stateNodes, node.path, extendTargetValues(values, node.path, value));
|
|
327
|
-
return selector(nextBuilder);
|
|
328
|
-
});
|
|
329
|
-
addBranchTargetChildren(builder, stateNodes, node.path, values);
|
|
330
|
-
return builder;
|
|
331
|
-
};
|
|
332
|
-
const makeBranchTargetBuilder = (stateNodes, source) => {
|
|
333
|
-
const rootPath = source.split(".")[0];
|
|
334
|
-
const root = getTargetBuilderNode(stateNodes, rootPath);
|
|
335
|
-
return {
|
|
336
|
-
[root.key]: makeBranchTargetNodeBuilder(stateNodes, root.path, undefined)
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
const makeTargetBuilder = (states, stateNodes) => {
|
|
340
|
-
const full = makeSnapshotBuilder(states, { mode: "full", prefix: "" });
|
|
341
|
-
return (source) => ({
|
|
342
|
-
local: makeLocalTargetBuilder(stateNodes, source),
|
|
343
|
-
branch: makeBranchTargetBuilder(stateNodes, source),
|
|
344
|
-
full
|
|
345
|
-
});
|
|
346
|
-
};
|
|
116
|
+
export const isFinal = internal.isFinal;
|
|
347
117
|
/**
|
|
348
118
|
* Defines a state tree while preserving literal state paths.
|
|
349
119
|
*
|
|
@@ -371,24 +141,14 @@ const makeTargetBuilder = (states, stateNodes) => {
|
|
|
371
141
|
* Machine.make({
|
|
372
142
|
* states: States.states,
|
|
373
143
|
* events: [],
|
|
374
|
-
* initial: () => States.initial.idle(
|
|
144
|
+
* initial: () => States.initial.idle.from()
|
|
375
145
|
* })
|
|
376
146
|
* ```
|
|
377
147
|
*
|
|
378
148
|
* @category constructors
|
|
379
149
|
* @since 4.0.0
|
|
380
150
|
*/
|
|
381
|
-
export const defineStates =
|
|
382
|
-
states: states,
|
|
383
|
-
initial: makeSnapshotBuilder(states, { mode: "initial", prefix: "" }),
|
|
384
|
-
get: ((snapshot, path) => Model.getSnapshotByPath(snapshot, path).pipe(Option.map((snapshot) => snapshot.value))),
|
|
385
|
-
getWithParents: ((snapshot, path) => {
|
|
386
|
-
const parents = {};
|
|
387
|
-
return Model.getSnapshotByPath(snapshot, path, parents).pipe(Option.map((snapshot) => ({ value: snapshot.value, parents })));
|
|
388
|
-
}),
|
|
389
|
-
getSnapshot: Model.getSnapshotByPath,
|
|
390
|
-
matches: (snapshot, path) => Option.isSome(Model.getSnapshotByPath(snapshot, path))
|
|
391
|
-
});
|
|
151
|
+
export const defineStates = internal.defineStates;
|
|
392
152
|
/**
|
|
393
153
|
* Creates a schema-first machine definition.
|
|
394
154
|
*
|
|
@@ -439,22 +199,33 @@ export const defineStates = (states, ..._validation) => ({
|
|
|
439
199
|
* @category constructors
|
|
440
200
|
* @since 4.0.0
|
|
441
201
|
*/
|
|
442
|
-
export const make =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
202
|
+
export const make = internal.make;
|
|
203
|
+
/**
|
|
204
|
+
* Constructs an event from a schema owned by a machine's protocol.
|
|
205
|
+
*
|
|
206
|
+
* **Details**
|
|
207
|
+
*
|
|
208
|
+
* The schema constructor runs exactly once. The resulting decoded event is
|
|
209
|
+
* trusted by this machine and definitions derived from it with `handle`, so
|
|
210
|
+
* repeated delivery does not decode the same already-constructed value again.
|
|
211
|
+
* Events supplied through ordinary `send` and `plan` calls remain untrusted
|
|
212
|
+
* and continue through full runtime schema validation.
|
|
213
|
+
* Treat the returned event as immutable after construction.
|
|
214
|
+
*
|
|
215
|
+
* The schema must be one of the machine's configured public or internal event
|
|
216
|
+
* schemas, or a case schema belonging to a configured `Schema.TaggedUnion`.
|
|
217
|
+
*
|
|
218
|
+
* **Example**
|
|
219
|
+
*
|
|
220
|
+
* ```ts
|
|
221
|
+
* const increment = Machine.event(counter, Increment, { by: 1 })
|
|
222
|
+
* yield* ref.send(increment)
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @category constructors
|
|
226
|
+
* @since 4.0.0
|
|
227
|
+
*/
|
|
228
|
+
export const event = internal.event;
|
|
458
229
|
/**
|
|
459
230
|
* Encodes a decoded machine snapshot into a normalized data representation.
|
|
460
231
|
*
|
|
@@ -482,7 +253,7 @@ export const make = (config, ..._validation) => {
|
|
|
482
253
|
* @category encoding
|
|
483
254
|
* @since 4.0.0
|
|
484
255
|
*/
|
|
485
|
-
export const encodeSnapshot =
|
|
256
|
+
export const encodeSnapshot = internal.encodeSnapshot;
|
|
486
257
|
/**
|
|
487
258
|
* Decodes a normalized data representation into a validated machine snapshot.
|
|
488
259
|
*
|
|
@@ -506,7 +277,7 @@ export const encodeSnapshot = Model.encodeSnapshot;
|
|
|
506
277
|
* @category decoding
|
|
507
278
|
* @since 4.0.0
|
|
508
279
|
*/
|
|
509
|
-
export const decodeSnapshot =
|
|
280
|
+
export const decodeSnapshot = internal.decodeSnapshot;
|
|
510
281
|
/**
|
|
511
282
|
* Creates an invoked child process configuration for an active state.
|
|
512
283
|
*
|
|
@@ -550,7 +321,7 @@ export const decodeSnapshot = Model.decodeSnapshot;
|
|
|
550
321
|
* @category constructors
|
|
551
322
|
* @since 4.0.0
|
|
552
323
|
*/
|
|
553
|
-
export const invoke =
|
|
324
|
+
export const invoke = internal.invoke;
|
|
554
325
|
/**
|
|
555
326
|
* Invokes one Effect and maps its typed outcome into machine-local events.
|
|
556
327
|
*
|
|
@@ -569,15 +340,7 @@ export const invoke = (config) => ({ ...config, [InvokeTypeId]: undefined });
|
|
|
569
340
|
* @category constructors
|
|
570
341
|
* @since 4.0.0
|
|
571
342
|
*/
|
|
572
|
-
export const invokeEffect =
|
|
573
|
-
id: config.id,
|
|
574
|
-
src: () => effect(config.onFailure === undefined
|
|
575
|
-
? Effect.map(config.effect, config.onSuccess)
|
|
576
|
-
: Effect.matchEffect(config.effect, {
|
|
577
|
-
onFailure: (error) => Effect.succeed(config.onFailure(error)),
|
|
578
|
-
onSuccess: (value) => Effect.succeed(config.onSuccess(value))
|
|
579
|
-
}))
|
|
580
|
-
}))(config);
|
|
343
|
+
export const invokeEffect = internal.invokeEffect;
|
|
581
344
|
/**
|
|
582
345
|
* Creates a cancellable state-scoped delayed event.
|
|
583
346
|
*
|
|
@@ -588,10 +351,7 @@ export const invokeEffect = (config) => ((config) => invoke({
|
|
|
588
351
|
* @category constructors
|
|
589
352
|
* @since 4.0.0
|
|
590
353
|
*/
|
|
591
|
-
export const after =
|
|
592
|
-
id: options?.id ?? `Machine.after:${String(event._tag)}`,
|
|
593
|
-
src: () => effect(Effect.as(Effect.sleep(duration), event))
|
|
594
|
-
});
|
|
354
|
+
export const after = internal.after;
|
|
595
355
|
/**
|
|
596
356
|
* Constructs another tagged case from compatible source fields.
|
|
597
357
|
*
|
|
@@ -605,10 +365,7 @@ export const after = (duration, event, options) => invoke({
|
|
|
605
365
|
* @category constructors
|
|
606
366
|
* @since 4.0.0
|
|
607
367
|
*/
|
|
608
|
-
export const retag =
|
|
609
|
-
const { _tag: _, ...fields } = source;
|
|
610
|
-
return target.make({ ...fields, ...(args[0] ?? {}) });
|
|
611
|
-
};
|
|
368
|
+
export const retag = internal.retag;
|
|
612
369
|
/**
|
|
613
370
|
* Creates an invoked child process from a complete statechart machine.
|
|
614
371
|
*
|
|
@@ -634,153 +391,118 @@ export const retag = (target, source, ...args) => {
|
|
|
634
391
|
* @category constructors
|
|
635
392
|
* @since 4.0.0
|
|
636
393
|
*/
|
|
637
|
-
export const invokeMachine =
|
|
638
|
-
const machine = config.child.machine;
|
|
639
|
-
return {
|
|
640
|
-
id: config.child.id,
|
|
641
|
-
address: config.child.id,
|
|
642
|
-
descriptor: config.child,
|
|
643
|
-
src: () => machine.input === undefined
|
|
644
|
-
? internalProcess.toProcessLogic(machine)
|
|
645
|
-
: internalProcess.toProcessLogic(machine, config.input),
|
|
646
|
-
snapshot: config.snapshot,
|
|
647
|
-
onDone: config.onDone,
|
|
648
|
-
[InvokeTypeId]: undefined
|
|
649
|
-
};
|
|
650
|
-
});
|
|
394
|
+
export const invokeMachine = internal.invokeMachine;
|
|
651
395
|
/**
|
|
652
|
-
* Plans the initial state for a machine without
|
|
396
|
+
* Plans the initial state for a machine without executing actor commands.
|
|
653
397
|
*
|
|
654
398
|
* **Details**
|
|
655
399
|
*
|
|
656
|
-
* The returned plan contains the settled initial snapshot,
|
|
657
|
-
* emitted events,
|
|
658
|
-
* logic and follow completion, eventless, and
|
|
659
|
-
*
|
|
400
|
+
* The returned plan contains the settled initial snapshot, actor commands,
|
|
401
|
+
* emitted events, optional final output, and every startup microstep. Planning
|
|
402
|
+
* may evaluate transition logic and follow completion, eventless, and
|
|
403
|
+
* raised-event steps. Transition callbacks are evaluated synchronously.
|
|
404
|
+
* `startingState` and `initialEntryPaths` describe the normalized
|
|
405
|
+
* configuration before entry callbacks and settlement begin.
|
|
660
406
|
*
|
|
661
407
|
* **Gotchas**
|
|
662
408
|
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
409
|
+
* `start` executes the closed command list as part of the managed actor commit
|
|
410
|
+
* protocol. Manual planners may inspect commands but need a running actor scope
|
|
411
|
+
* to execute child-addressed operations.
|
|
666
412
|
*
|
|
667
413
|
* @see {@link plan} for planning a received event.
|
|
668
414
|
* @see {@link start} for the managed runtime protocol.
|
|
669
415
|
* @category constructors
|
|
670
416
|
* @since 4.0.0
|
|
671
417
|
*/
|
|
672
|
-
export const planInitial =
|
|
418
|
+
export const planInitial = internal.planInitial;
|
|
673
419
|
/**
|
|
674
|
-
* Returns
|
|
420
|
+
* Returns every compiled state node in definition order.
|
|
421
|
+
*
|
|
422
|
+
* **Details**
|
|
423
|
+
*
|
|
424
|
+
* The result includes atomic, compound, parallel, final, history, and choice
|
|
425
|
+
* nodes together with their resolved descriptive annotations. Use each node's
|
|
426
|
+
* `parent` property to reconstruct the complete hierarchy. Pseudo-states are
|
|
427
|
+
* intentionally omitted from `children` because they can never appear in an
|
|
428
|
+
* active configuration.
|
|
675
429
|
*
|
|
676
430
|
* @category getters
|
|
677
431
|
* @since 4.0.0
|
|
678
432
|
*/
|
|
679
|
-
export const
|
|
433
|
+
export const stateNodes = internal.stateNodes;
|
|
680
434
|
/**
|
|
681
|
-
*
|
|
435
|
+
* Returns every registered transition handler in state definition order.
|
|
682
436
|
*
|
|
683
437
|
* **Details**
|
|
684
438
|
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* **Gotchas**
|
|
691
|
-
*
|
|
692
|
-
* `plan` returns data; it does not implement the runtime commit protocol. Run
|
|
693
|
-
* actions sequentially, publish `next` only after they succeed, and then
|
|
694
|
-
* deliver `emittedEvents`. A failed action must retain the previously
|
|
695
|
-
* published state and suppress emissions. Events with no enabled transition
|
|
696
|
-
* are ignored and produce an unchanged plan.
|
|
439
|
+
* Event handlers retain their handler-key order within each source state and
|
|
440
|
+
* are followed by eventless and completion handlers. This function does not
|
|
441
|
+
* execute handlers. Object-form event, eventless, and completion handlers with
|
|
442
|
+
* a `targets` declaration expose those possible paths; handlers without one
|
|
443
|
+
* remain dynamic.
|
|
697
444
|
*
|
|
698
|
-
* @
|
|
699
|
-
* @see {@link start} for managed execution and lifecycle observation.
|
|
700
|
-
* @category combinators
|
|
445
|
+
* @category getters
|
|
701
446
|
* @since 4.0.0
|
|
702
447
|
*/
|
|
703
|
-
export const
|
|
448
|
+
export const transitionDefinitions = internal.transitionDefinitions;
|
|
704
449
|
/**
|
|
705
|
-
*
|
|
450
|
+
* Returns serializable descriptions of every state-owned activity.
|
|
706
451
|
*
|
|
707
452
|
* **Details**
|
|
708
453
|
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* value after staging.
|
|
454
|
+
* Static `invoke`, `invokeEffect`, `after`, and `invokeMachine` descriptors
|
|
455
|
+
* expose stable ownership and lifecycle metadata without serializing runtime
|
|
456
|
+
* values. Function-valued invoke factories are represented as dynamic and are
|
|
457
|
+
* never evaluated during inspection.
|
|
714
458
|
*
|
|
715
|
-
*
|
|
459
|
+
* @category getters
|
|
460
|
+
* @since 4.0.0
|
|
461
|
+
*/
|
|
462
|
+
export const activityDefinitions = internal.activityDefinitions;
|
|
463
|
+
/**
|
|
464
|
+
* Returns every state node active in a decoded snapshot, in definition order.
|
|
716
465
|
*
|
|
717
|
-
*
|
|
718
|
-
* import { Context, Effect } from "effect"
|
|
719
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
466
|
+
* **Details**
|
|
720
467
|
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
468
|
+
* Active compound ancestors and parallel regions are included together with
|
|
469
|
+
* their active descendants. History and choice pseudo-states are never active
|
|
470
|
+
* and are not returned.
|
|
724
471
|
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
|
|
728
|
-
|
|
472
|
+
* @category getters
|
|
473
|
+
* @since 4.0.0
|
|
474
|
+
*/
|
|
475
|
+
export const configuration = internal.configuration;
|
|
476
|
+
/**
|
|
477
|
+
* Returns the event tags handled by the current state snapshot.
|
|
729
478
|
*
|
|
730
|
-
* @
|
|
731
|
-
* @category combinators
|
|
479
|
+
* @category getters
|
|
732
480
|
* @since 4.0.0
|
|
733
481
|
*/
|
|
734
|
-
export const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
});
|
|
738
|
-
const processLocal = (operation) => Effect.die(new ProcessLocalErrorValue({ operation }));
|
|
739
|
-
const standaloneProcessRuntime = internalRuntime.MachineRuntime.of({
|
|
740
|
-
self: {
|
|
741
|
-
id: "Machine.runActions",
|
|
742
|
-
sessionId: "Machine.runActions",
|
|
743
|
-
stop: processLocal("stop self"),
|
|
744
|
-
send: () => processLocal("send to self")
|
|
745
|
-
},
|
|
746
|
-
parent: undefined,
|
|
747
|
-
spawn: () => processLocal("spawn"),
|
|
748
|
-
sendParent: () => processLocal("send to parent"),
|
|
749
|
-
sendTo: () => processLocal("send to child"),
|
|
750
|
-
stopChild: () => processLocal("stop child"),
|
|
751
|
-
failCause: () => processLocal("fail process")
|
|
752
|
-
});
|
|
753
|
-
/**
|
|
754
|
-
* Runs staged machine actions sequentially with the supplied runtime.
|
|
482
|
+
export const enabled = internal.enabled;
|
|
483
|
+
/**
|
|
484
|
+
* Plans the next state snapshot synchronously.
|
|
755
485
|
*
|
|
756
|
-
* **
|
|
486
|
+
* **Details**
|
|
757
487
|
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
488
|
+
* Planning selects child transitions before conflicting ancestors, permits
|
|
489
|
+
* non-conflicting transitions in parallel regions, processes completion and
|
|
490
|
+
* eventless transitions, and drains raised events in FIFO order. Exit paths
|
|
491
|
+
* are deepest-first and entry paths are parent-first.
|
|
760
492
|
*
|
|
761
493
|
* **Gotchas**
|
|
762
494
|
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
* owns the actions.
|
|
768
|
-
*
|
|
769
|
-
* @see {@link plan} for creating a transition plan.
|
|
770
|
-
* @see {@link planInitial} for creating an initial plan.
|
|
771
|
-
* @category running
|
|
772
|
-
* @since 4.0.0
|
|
773
|
-
*/
|
|
774
|
-
export const runActions = (actions, runtime) => internalRuntime.provideMachineRuntime(internalPlanner.runActions(actions, runtime), standaloneProcessRuntime).pipe(Effect.catchDefect((defect) => defect instanceof ProcessLocalErrorValue
|
|
775
|
-
? Effect.fail(defect)
|
|
776
|
-
: Effect.die(defect)));
|
|
777
|
-
/**
|
|
778
|
-
* Returns the typed runtime capability for the current machine.
|
|
495
|
+
* `plan` returns data; it does not implement the actor commit protocol.
|
|
496
|
+
* `start` executes child commands, publishes `next`, and then delivers
|
|
497
|
+
* `emittedEvents`. Events with no enabled transition are ignored and produce
|
|
498
|
+
* an unchanged plan.
|
|
779
499
|
*
|
|
500
|
+
* @see {@link planInitial} for planning machine startup.
|
|
501
|
+
* @see {@link start} for managed execution and lifecycle observation.
|
|
780
502
|
* @category combinators
|
|
781
503
|
* @since 4.0.0
|
|
782
504
|
*/
|
|
783
|
-
export const
|
|
505
|
+
export const plan = internal.plan;
|
|
784
506
|
/**
|
|
785
507
|
* Creates a one-shot child process from an Effect.
|
|
786
508
|
*
|
|
@@ -823,10 +545,7 @@ export const runtime = () => internalPlanner.runtime();
|
|
|
823
545
|
* @category constructors
|
|
824
546
|
* @since 4.0.0
|
|
825
547
|
*/
|
|
826
|
-
export const effect =
|
|
827
|
-
initial: () => Effect.void,
|
|
828
|
-
run: () => effect
|
|
829
|
-
});
|
|
548
|
+
export const effect = internal.effect;
|
|
830
549
|
/**
|
|
831
550
|
* Creates advanced stateful process logic from explicit initialization and
|
|
832
551
|
* execution methods.
|
|
@@ -855,12 +574,7 @@ export const effect = (effect) => ({
|
|
|
855
574
|
* @category constructors
|
|
856
575
|
* @since 4.0.0
|
|
857
576
|
*/
|
|
858
|
-
export const logic =
|
|
859
|
-
initial: (scope) => typeof options.initial === "function"
|
|
860
|
-
? options.initial(scope)
|
|
861
|
-
: Effect.succeed(options.initial),
|
|
862
|
-
run: options.run
|
|
863
|
-
});
|
|
577
|
+
export const logic = internal.logic;
|
|
864
578
|
/**
|
|
865
579
|
* Creates child process logic from an initial state and a transition function.
|
|
866
580
|
*
|
|
@@ -879,10 +593,7 @@ export const logic = (options) => ({
|
|
|
879
593
|
* @category constructors
|
|
880
594
|
* @since 4.0.0
|
|
881
595
|
*/
|
|
882
|
-
export const transition =
|
|
883
|
-
initial,
|
|
884
|
-
run: ({ receive, updateState }) => receive.pipe(Effect.flatMap((event) => updateState((state) => transition(state, event))), Effect.forever)
|
|
885
|
-
});
|
|
596
|
+
export const transition = internal.transition;
|
|
886
597
|
/**
|
|
887
598
|
* Creates a typed descriptor for a complete child machine.
|
|
888
599
|
*
|
|
@@ -892,11 +603,7 @@ export const transition = (initial, transition) => logic({
|
|
|
892
603
|
* @category constructors
|
|
893
604
|
* @since 4.0.0
|
|
894
605
|
*/
|
|
895
|
-
export const child =
|
|
896
|
-
[ChildMachineTypeId]: ChildMachineTypeId,
|
|
897
|
-
id,
|
|
898
|
-
machine
|
|
899
|
-
});
|
|
606
|
+
export const child = internal.child;
|
|
900
607
|
/**
|
|
901
608
|
* Creates a typed parent-local address for lower-level child process logic.
|
|
902
609
|
*
|
|
@@ -906,49 +613,48 @@ export const child = (id, machine) => ({
|
|
|
906
613
|
* @category constructors
|
|
907
614
|
* @since 4.0.0
|
|
908
615
|
*/
|
|
909
|
-
export const childAddress =
|
|
616
|
+
export const childAddress = internal.childAddress;
|
|
910
617
|
/**
|
|
911
618
|
* Spawns a child process owned by the currently running machine.
|
|
912
619
|
*
|
|
913
620
|
* **When to use**
|
|
914
621
|
*
|
|
915
|
-
* Use
|
|
916
|
-
*
|
|
917
|
-
*
|
|
622
|
+
* Use from lower-level process logic to create children that should be
|
|
623
|
+
* addressed or stopped by the owning process instead of tied to a single
|
|
624
|
+
* state's `invoke` lifecycle.
|
|
918
625
|
*
|
|
919
626
|
* **Gotchas**
|
|
920
627
|
*
|
|
921
|
-
* This
|
|
922
|
-
*
|
|
923
|
-
* that child stops.
|
|
628
|
+
* This Effect requires a managed process runtime. A named child id must be
|
|
629
|
+
* unique for the current parent until that child stops.
|
|
924
630
|
*
|
|
925
631
|
* @see {@link invoke} for children that start and stop with a state.
|
|
926
632
|
* @see {@link sendTo} for sending events to named children.
|
|
927
633
|
* @category runtime
|
|
928
634
|
* @since 4.0.0
|
|
929
635
|
*/
|
|
930
|
-
export const spawn =
|
|
636
|
+
export const spawn = internal.spawn;
|
|
931
637
|
/**
|
|
932
638
|
* Sends an event to a named child process of the running machine.
|
|
933
639
|
*
|
|
934
640
|
* @category runtime
|
|
935
641
|
* @since 4.0.0
|
|
936
642
|
*/
|
|
937
|
-
export const sendTo =
|
|
643
|
+
export const sendTo = internal.sendTo;
|
|
938
644
|
/**
|
|
939
645
|
* Stops a named child process of the running machine.
|
|
940
646
|
*
|
|
941
647
|
* @category runtime
|
|
942
648
|
* @since 4.0.0
|
|
943
649
|
*/
|
|
944
|
-
export const stopChild =
|
|
650
|
+
export const stopChild = internal.stopChild;
|
|
945
651
|
/**
|
|
946
652
|
* Returns a stream of terminal lifecycle outcomes for a running machine.
|
|
947
653
|
*
|
|
948
654
|
* @category combinators
|
|
949
655
|
* @since 4.0.0
|
|
950
656
|
*/
|
|
951
|
-
export const watch =
|
|
657
|
+
export const watch = internal.watch;
|
|
952
658
|
/**
|
|
953
659
|
* Starts a machine.
|
|
954
660
|
*
|
|
@@ -959,11 +665,10 @@ export const watch = (ref) => internalRuntime.watch(ref);
|
|
|
959
665
|
*
|
|
960
666
|
* **Details**
|
|
961
667
|
*
|
|
962
|
-
* For each accepted event the runtime plans the complete
|
|
963
|
-
*
|
|
964
|
-
* state, delivers emitted events, and then starts invokes
|
|
965
|
-
*
|
|
966
|
-
* from that plan are suppressed.
|
|
668
|
+
* For each accepted event the runtime plans the complete synchronous
|
|
669
|
+
* macrostep, executes closed actor commands, stops invokes for exited states,
|
|
670
|
+
* publishes the new state, delivers emitted events, and then starts invokes
|
|
671
|
+
* for entered states.
|
|
967
672
|
*
|
|
968
673
|
* **Gotchas**
|
|
969
674
|
*
|
|
@@ -977,5 +682,35 @@ export const watch = (ref) => internalRuntime.watch(ref);
|
|
|
977
682
|
* @category constructors
|
|
978
683
|
* @since 4.0.0
|
|
979
684
|
*/
|
|
980
|
-
export const start =
|
|
685
|
+
export const start = internal.start;
|
|
686
|
+
/**
|
|
687
|
+
* Starts a fresh managed runtime from a decoded logical snapshot.
|
|
688
|
+
*
|
|
689
|
+
* **Details**
|
|
690
|
+
*
|
|
691
|
+
* `resume` validates and normalizes the supplied snapshot before publishing it
|
|
692
|
+
* as the first state. It does not call the machine's initial function, replay
|
|
693
|
+
* entry or transition actions, re-deliver raised or emitted events, or
|
|
694
|
+
* re-evaluate historical completion and eventless transitions. Active-state
|
|
695
|
+
* invokes start once in ancestor and document order with {@link InitialEvent};
|
|
696
|
+
* delayed invokes restart their complete duration and invoked machines start
|
|
697
|
+
* from their own initial state.
|
|
698
|
+
*
|
|
699
|
+
* Only logical state, completion, and history metadata are resumed. Queues,
|
|
700
|
+
* scopes, subscriptions, fibers, spawned children, invoke progress, and prior
|
|
701
|
+
* runtime status are process-local and are not restored. A final snapshot
|
|
702
|
+
* immediately produces a completed ref with its current-machine output.
|
|
703
|
+
*
|
|
704
|
+
* Decode encoded data explicitly with {@link decodeSnapshot} before calling
|
|
705
|
+
* this function. Stable snapshots are hosted as supplied; newly enabled
|
|
706
|
+
* eventless or completion transitions in a changed machine definition are not
|
|
707
|
+
* evaluated merely because the runtime was resumed; only ordinary subsequent
|
|
708
|
+
* transition planning can enter and stabilize states.
|
|
709
|
+
*
|
|
710
|
+
* @see {@link decodeSnapshot} for the schema and transport boundary.
|
|
711
|
+
* @see {@link start} for ordinary initial startup.
|
|
712
|
+
* @category constructors
|
|
713
|
+
* @since 4.0.0
|
|
714
|
+
*/
|
|
715
|
+
export const resume = internal.resume;
|
|
981
716
|
//# sourceMappingURL=Machine.js.map
|