@typeonce/effect-machine 0.47.0 → 0.48.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/AGENTS.md +374 -22
- package/CLAUDE.md +374 -22
- package/README.md +56 -7
- package/ai-docs/src/10_modeling/01_create-a-machine.ts +3 -3
- package/ai-docs/src/10_modeling/index.md +64 -17
- package/ai-docs/src/20_root-api/index.md +2 -2
- package/ai-docs/src/35_cluster/index.md +213 -0
- package/ai-docs/src/37_new-host/index.md +90 -0
- package/dist/LocalMachine.d.ts +417 -0
- package/dist/LocalMachine.d.ts.map +1 -0
- package/dist/LocalMachine.js +193 -0
- package/dist/LocalMachine.js.map +1 -0
- package/dist/Machine.d.ts +1122 -814
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +195 -186
- package/dist/Machine.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +8 -10
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +7 -6
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/capability.d.ts +101 -0
- package/dist/internal/machine/capability.d.ts.map +1 -0
- package/dist/internal/machine/capability.js +70 -0
- package/dist/internal/machine/capability.js.map +1 -0
- package/dist/internal/machine/{invocationDefinition.d.ts → capturedInvocation.d.ts} +11 -11
- package/dist/internal/machine/capturedInvocation.d.ts.map +1 -0
- package/dist/internal/machine/{invocationDefinition.js → capturedInvocation.js} +2 -2
- package/dist/internal/machine/capturedInvocation.js.map +1 -0
- package/dist/internal/machine/child.d.ts +14 -0
- package/dist/internal/machine/child.d.ts.map +1 -0
- package/dist/internal/machine/child.js +19 -0
- package/dist/internal/machine/child.js.map +1 -0
- package/dist/internal/machine/childRegistry.d.ts +0 -2
- package/dist/internal/machine/childRegistry.d.ts.map +1 -1
- package/dist/internal/machine/childRegistry.js +2 -2
- package/dist/internal/machine/childRegistry.js.map +1 -1
- package/dist/internal/machine/cluster.d.ts +19 -4
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js +263 -110
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/clusterChild.d.ts +66 -0
- package/dist/internal/machine/clusterChild.d.ts.map +1 -0
- package/dist/internal/machine/clusterChild.js +105 -0
- package/dist/internal/machine/clusterChild.js.map +1 -0
- package/dist/internal/machine/clusterFailure.d.ts +14 -0
- package/dist/internal/machine/clusterFailure.d.ts.map +1 -0
- package/dist/internal/machine/clusterFailure.js +44 -0
- package/dist/internal/machine/clusterFailure.js.map +1 -0
- package/dist/internal/machine/clusterInstance.d.ts +194 -0
- package/dist/internal/machine/clusterInstance.d.ts.map +1 -0
- package/dist/internal/machine/clusterInstance.js +1076 -0
- package/dist/internal/machine/clusterInstance.js.map +1 -0
- package/dist/internal/machine/clusterKeepAlive.d.ts +47 -0
- package/dist/internal/machine/clusterKeepAlive.d.ts.map +1 -0
- package/dist/internal/machine/clusterKeepAlive.js +72 -0
- package/dist/internal/machine/clusterKeepAlive.js.map +1 -0
- package/dist/internal/machine/clusterProgress.d.ts +73 -0
- package/dist/internal/machine/clusterProgress.d.ts.map +1 -0
- package/dist/internal/machine/clusterProgress.js +116 -0
- package/dist/internal/machine/clusterProgress.js.map +1 -0
- package/dist/internal/machine/clusterProtocol.d.ts +37 -4
- package/dist/internal/machine/clusterProtocol.d.ts.map +1 -1
- package/dist/internal/machine/clusterProtocol.js +18 -4
- package/dist/internal/machine/clusterProtocol.js.map +1 -1
- package/dist/internal/machine/clusterProxy.d.ts +46 -0
- package/dist/internal/machine/clusterProxy.d.ts.map +1 -0
- package/dist/internal/machine/clusterProxy.js +150 -0
- package/dist/internal/machine/clusterProxy.js.map +1 -0
- package/dist/internal/machine/clusterRead.d.ts +61 -0
- package/dist/internal/machine/clusterRead.d.ts.map +1 -0
- package/dist/internal/machine/clusterRead.js +108 -0
- package/dist/internal/machine/clusterRead.js.map +1 -0
- package/dist/internal/machine/clusterSqlStorage.d.ts +16 -0
- package/dist/internal/machine/clusterSqlStorage.d.ts.map +1 -0
- package/dist/internal/machine/clusterSqlStorage.js +138 -0
- package/dist/internal/machine/clusterSqlStorage.js.map +1 -0
- package/dist/internal/machine/clusterStorageCheck.d.ts +19 -0
- package/dist/internal/machine/clusterStorageCheck.d.ts.map +1 -0
- package/dist/internal/machine/clusterStorageCheck.js +186 -0
- package/dist/internal/machine/clusterStorageCheck.js.map +1 -0
- package/dist/internal/machine/clusterTarget.d.ts +74 -0
- package/dist/internal/machine/clusterTarget.d.ts.map +1 -0
- package/dist/internal/machine/clusterTarget.js +81 -0
- package/dist/internal/machine/clusterTarget.js.map +1 -0
- package/dist/internal/machine/clusterTimer.d.ts +21 -0
- package/dist/internal/machine/clusterTimer.d.ts.map +1 -0
- package/dist/internal/machine/clusterTimer.js +50 -0
- package/dist/internal/machine/clusterTimer.js.map +1 -0
- package/dist/internal/machine/clusterWake.d.ts +61 -0
- package/dist/internal/machine/clusterWake.d.ts.map +1 -0
- package/dist/internal/machine/clusterWake.js +81 -0
- package/dist/internal/machine/clusterWake.js.map +1 -0
- package/dist/internal/machine/clusterWork.d.ts +130 -0
- package/dist/internal/machine/clusterWork.d.ts.map +1 -0
- package/dist/internal/machine/clusterWork.js +191 -0
- package/dist/internal/machine/clusterWork.js.map +1 -0
- package/dist/internal/machine/command.d.ts +4 -4
- package/dist/internal/machine/command.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.d.ts +8 -6
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.js +1 -5
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +0 -13
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +0 -151
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/errors.d.ts +11 -2
- package/dist/internal/machine/errors.d.ts.map +1 -1
- package/dist/internal/machine/errors.js +11 -2
- package/dist/internal/machine/errors.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +45 -3
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +328 -191
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/implementation.d.ts +6 -6
- package/dist/internal/machine/implementation.d.ts.map +1 -1
- package/dist/internal/machine/inspectionRuntime.d.ts +1 -1
- package/dist/internal/machine/inspectionRuntime.d.ts.map +1 -1
- package/dist/internal/machine/invocationChanges.d.ts +60 -0
- package/dist/internal/machine/invocationChanges.d.ts.map +1 -0
- package/dist/internal/machine/invocationChanges.js +54 -0
- package/dist/internal/machine/invocationChanges.js.map +1 -0
- package/dist/internal/machine/{activities.d.ts → invocationDefinitions.d.ts} +8 -8
- package/dist/internal/machine/invocationDefinitions.d.ts.map +1 -0
- package/dist/internal/machine/{activities.js → invocationDefinitions.js} +5 -5
- package/dist/internal/machine/invocationDefinitions.js.map +1 -0
- package/dist/internal/machine/invocationEvent.d.ts +16 -7
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +26 -12
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/invocationOutcome.d.ts +89 -0
- package/dist/internal/machine/invocationOutcome.d.ts.map +1 -0
- package/dist/internal/machine/invocationOutcome.js +76 -0
- package/dist/internal/machine/invocationOutcome.js.map +1 -0
- package/dist/internal/machine/invocationResolution.d.ts +137 -0
- package/dist/internal/machine/invocationResolution.d.ts.map +1 -0
- package/dist/internal/machine/invocationResolution.js +150 -0
- package/dist/internal/machine/invocationResolution.js.map +1 -0
- package/dist/internal/machine/logicScope.d.ts +24 -0
- package/dist/internal/machine/logicScope.d.ts.map +1 -0
- package/dist/internal/machine/logicScope.js +33 -0
- package/dist/internal/machine/logicScope.js.map +1 -0
- package/dist/internal/machine/machine.d.ts +17 -23
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +24 -40
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/observation.d.ts +3 -0
- package/dist/internal/machine/observation.d.ts.map +1 -1
- package/dist/internal/machine/observation.js +56 -2
- package/dist/internal/machine/observation.js.map +1 -1
- package/dist/internal/machine/plannedSnapshot.d.ts.map +1 -1
- package/dist/internal/machine/plannedSnapshot.js +11 -20
- package/dist/internal/machine/plannedSnapshot.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +36 -23
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +15 -8
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +17 -9
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +43 -503
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +1 -1
- package/dist/internal/machine/protocol.d.ts.map +1 -1
- package/dist/internal/machine/protocol.js +48 -10
- package/dist/internal/machine/protocol.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +20 -16
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +93 -88
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.d.ts.map +1 -1
- package/dist/internal/machine/runtimeCompiled.js +359 -120
- package/dist/internal/machine/runtimeCompiled.js.map +1 -1
- package/dist/internal/machine/runtimeProtocol.d.ts +151 -82
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -1
- package/dist/internal/machine/runtimeProtocol.js +236 -219
- package/dist/internal/machine/runtimeProtocol.js.map +1 -1
- package/dist/internal/machine/stateDefinition.d.ts +0 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +0 -1
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/step.d.ts +486 -0
- package/dist/internal/machine/step.d.ts.map +1 -0
- package/dist/internal/machine/step.js +957 -0
- package/dist/internal/machine/step.js.map +1 -0
- package/dist/internal/machine/stepHost.d.ts +33 -0
- package/dist/internal/machine/stepHost.d.ts.map +1 -0
- package/dist/internal/machine/stepHost.js +501 -0
- package/dist/internal/machine/stepHost.js.map +1 -0
- package/dist/internal/machine/symbols.d.ts +2 -11
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -2
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/transition.d.ts +7 -7
- package/dist/internal/machine/transition.d.ts.map +1 -1
- package/dist/internal/testing/machine/check.d.ts.map +1 -1
- package/dist/internal/testing/machine/check.js +217 -25
- package/dist/internal/testing/machine/check.js.map +1 -1
- package/dist/internal/testing/machine/exploration.d.ts +19 -2
- package/dist/internal/testing/machine/exploration.d.ts.map +1 -1
- package/dist/internal/testing/machine/exploration.js +14 -3
- package/dist/internal/testing/machine/exploration.js.map +1 -1
- package/dist/internal/testing/machine/format.js.map +1 -1
- package/dist/internal/testing/machine/probe.d.ts.map +1 -1
- package/dist/internal/testing/machine/probe.js +1 -1
- package/dist/internal/testing/machine/probe.js.map +1 -1
- package/dist/internal/testing/machine/runtime.d.ts +2 -2
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -1
- package/dist/internal/testing/machine/runtime.js +10 -3
- package/dist/internal/testing/machine/runtime.js.map +1 -1
- package/dist/internal/testing/machine/trace.d.ts +38 -3
- package/dist/internal/testing/machine/trace.d.ts.map +1 -1
- package/dist/internal/testing/machine/trace.js +180 -33
- package/dist/internal/testing/machine/trace.js.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +9 -1
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/internal/testing/machine/work.d.ts +47 -0
- package/dist/internal/testing/machine/work.d.ts.map +1 -0
- package/dist/internal/testing/machine/work.js +74 -0
- package/dist/internal/testing/machine/work.js.map +1 -0
- package/dist/testing/MachineTest.d.ts +253 -37
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +81 -9
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +1071 -41
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +441 -12
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachineProxy.d.ts +257 -0
- package/dist/unstable/cluster/ClusterMachineProxy.d.ts.map +1 -0
- package/dist/unstable/cluster/ClusterMachineProxy.js +73 -0
- package/dist/unstable/cluster/ClusterMachineProxy.js.map +1 -0
- package/dist/unstable/cluster/SqlMachineStorage.d.ts +125 -0
- package/dist/unstable/cluster/SqlMachineStorage.d.ts.map +1 -0
- package/dist/unstable/cluster/SqlMachineStorage.js +62 -0
- package/dist/unstable/cluster/SqlMachineStorage.js.map +1 -0
- package/dist/unstable/cluster/index.d.ts +13 -0
- package/dist/unstable/cluster/index.d.ts.map +1 -1
- package/dist/unstable/cluster/index.js +13 -0
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +21 -26
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/package.json +5 -3
- package/src/LocalMachine.ts +611 -0
- package/src/Machine.ts +1383 -1336
- package/src/index.ts +1 -0
- package/src/internal/machine/atom.ts +20 -49
- package/src/internal/machine/capability.ts +123 -0
- package/src/internal/machine/{invocationDefinition.ts → capturedInvocation.ts} +13 -13
- package/src/internal/machine/child.ts +25 -0
- package/src/internal/machine/childRegistry.ts +1 -4
- package/src/internal/machine/cluster.ts +420 -205
- package/src/internal/machine/clusterChild.ts +117 -0
- package/src/internal/machine/clusterFailure.ts +53 -0
- package/src/internal/machine/clusterInstance.ts +1779 -0
- package/src/internal/machine/clusterKeepAlive.ts +93 -0
- package/src/internal/machine/clusterProgress.ts +159 -0
- package/src/internal/machine/clusterProtocol.ts +46 -4
- package/src/internal/machine/clusterProxy.ts +233 -0
- package/src/internal/machine/clusterRead.ts +207 -0
- package/src/internal/machine/clusterSqlStorage.ts +181 -0
- package/src/internal/machine/clusterStorageCheck.ts +274 -0
- package/src/internal/machine/clusterTarget.ts +154 -0
- package/src/internal/machine/clusterTimer.ts +58 -0
- package/src/internal/machine/clusterWake.ts +100 -0
- package/src/internal/machine/clusterWork.ts +269 -0
- package/src/internal/machine/command.ts +4 -4
- package/src/internal/machine/commandRuntime.ts +12 -24
- package/src/internal/machine/configuration.ts +0 -181
- package/src/internal/machine/errors.ts +11 -2
- package/src/internal/machine/executionPlan.ts +493 -263
- package/src/internal/machine/implementation.ts +6 -6
- package/src/internal/machine/inspectionRuntime.ts +1 -1
- package/src/internal/machine/invocationChanges.ts +89 -0
- package/src/internal/machine/{activities.ts → invocationDefinitions.ts} +10 -10
- package/src/internal/machine/invocationEvent.ts +35 -12
- package/src/internal/machine/invocationOutcome.ts +145 -0
- package/src/internal/machine/invocationResolution.ts +307 -0
- package/src/internal/machine/logicScope.ts +47 -0
- package/src/internal/machine/machine.ts +35 -100
- package/src/internal/machine/observation.ts +67 -2
- package/src/internal/machine/plannedSnapshot.ts +17 -20
- package/src/internal/machine/planner.ts +75 -99
- package/src/internal/machine/process.ts +78 -722
- package/src/internal/machine/protocol.ts +70 -26
- package/src/internal/machine/runtime.ts +198 -195
- package/src/internal/machine/runtimeCompiled.ts +496 -171
- package/src/internal/machine/runtimeProtocol.ts +416 -305
- package/src/internal/machine/stateDefinition.ts +0 -5
- package/src/internal/machine/step.ts +1518 -0
- package/src/internal/machine/stepHost.ts +634 -0
- package/src/internal/machine/symbols.ts +3 -14
- package/src/internal/machine/transition.ts +11 -11
- package/src/internal/testing/machine/check.ts +240 -36
- package/src/internal/testing/machine/exploration.ts +42 -3
- package/src/internal/testing/machine/format.ts +1 -1
- package/src/internal/testing/machine/probe.ts +2 -1
- package/src/internal/testing/machine/runtime.ts +15 -5
- package/src/internal/testing/machine/trace.ts +261 -41
- package/src/internal/testing/machine/transitionCoverage.ts +1 -1
- package/src/internal/testing/machine/verification.ts +11 -5
- package/src/internal/testing/machine/work.ts +101 -0
- package/src/testing/MachineTest.ts +268 -44
- package/src/unstable/cluster/ClusterMachine.ts +1183 -59
- package/src/unstable/cluster/ClusterMachineProxy.ts +372 -0
- package/src/unstable/cluster/SqlMachineStorage.ts +136 -0
- package/src/unstable/cluster/index.ts +15 -0
- package/src/unstable/reactivity/AtomMachine.ts +27 -88
- package/dist/internal/machine/activities.d.ts.map +0 -1
- package/dist/internal/machine/activities.js.map +0 -1
- package/dist/internal/machine/invocation.d.ts +0 -33
- package/dist/internal/machine/invocation.d.ts.map +0 -1
- package/dist/internal/machine/invocation.js +0 -220
- package/dist/internal/machine/invocation.js.map +0 -1
- package/dist/internal/machine/invocationDefinition.d.ts.map +0 -1
- package/dist/internal/machine/invocationDefinition.js.map +0 -1
- package/dist/internal/machine/requirements.d.ts +0 -4
- package/dist/internal/machine/requirements.d.ts.map +0 -1
- package/dist/internal/machine/requirements.js +0 -2
- package/dist/internal/machine/requirements.js.map +0 -1
- package/dist/internal/machine/runtimeGeneric.d.ts +0 -3
- package/dist/internal/machine/runtimeGeneric.d.ts.map +0 -1
- package/dist/internal/machine/runtimeGeneric.js +0 -465
- package/dist/internal/machine/runtimeGeneric.js.map +0 -1
- package/src/internal/machine/invocation.ts +0 -376
- package/src/internal/machine/requirements.ts +0 -11
- package/src/internal/machine/runtimeGeneric.ts +0 -797
package/dist/Machine.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Schema-first machine
|
|
2
|
+
* Schema-first machine models.
|
|
3
|
+
*
|
|
4
|
+
* This module declares machines, plans their steps, encodes their snapshots, and
|
|
5
|
+
* defines the contracts their types mention. It runs nothing: a host executes a
|
|
6
|
+
* machine, such as `LocalMachine` in memory or `ClusterMachine` as a Cluster
|
|
7
|
+
* entity.
|
|
3
8
|
*
|
|
4
9
|
* @since 0.4.0
|
|
5
10
|
*/
|
|
6
11
|
import { hasProperty } from "effect/Predicate";
|
|
7
12
|
import * as internal from "./internal/machine/machine.js";
|
|
8
|
-
import { InitialEventTypeId } from "./internal/machine/machine.js";
|
|
13
|
+
import { InitialEventTypeId, InvocationEventTypeId } from "./internal/machine/machine.js";
|
|
9
14
|
/**
|
|
10
15
|
* Runtime type identifier attached to `Machine` values.
|
|
11
16
|
*
|
|
@@ -36,6 +41,21 @@ export const InitialEvent = { _tag: InitialEventTypeId };
|
|
|
36
41
|
* @since 0.4.0
|
|
37
42
|
*/
|
|
38
43
|
export const isInitialEvent = (u) => hasProperty(u, "_tag") && u._tag === InitialEventTypeId;
|
|
44
|
+
/**
|
|
45
|
+
* Type identifier used for the synthetic event of a step caused by invoked work.
|
|
46
|
+
*
|
|
47
|
+
* @category type IDs
|
|
48
|
+
* @since 0.48.0
|
|
49
|
+
*/
|
|
50
|
+
export { InvocationEventTypeId };
|
|
51
|
+
/**
|
|
52
|
+
* Returns `true` if a value is the synthetic event of a step caused by invoked
|
|
53
|
+
* work.
|
|
54
|
+
*
|
|
55
|
+
* @category guards
|
|
56
|
+
* @since 0.48.0
|
|
57
|
+
*/
|
|
58
|
+
export const isInvocationEvent = (u) => hasProperty(u, "_tag") && u._tag === InvocationEventTypeId;
|
|
39
59
|
export {
|
|
40
60
|
/**
|
|
41
61
|
* Error returned by `spawn` when a child process with the same id already
|
|
@@ -70,8 +90,17 @@ MachineSchemaDecodeError,
|
|
|
70
90
|
*/
|
|
71
91
|
MachineSchemaEncodeError,
|
|
72
92
|
/**
|
|
73
|
-
* Error
|
|
74
|
-
*
|
|
93
|
+
* Error raised when invoked work uses an operation that requires a local
|
|
94
|
+
* machine process, on a host that does not provide one.
|
|
95
|
+
*
|
|
96
|
+
* **Details**
|
|
97
|
+
*
|
|
98
|
+
* `ClusterMachine` raises it when work reads `self.sessionId`, calls
|
|
99
|
+
* `self.send`, or calls an operation of `children`. The step functions of
|
|
100
|
+
* {@link toStep} raise it when work calls an operation on children and the
|
|
101
|
+
* host passed no `children`. It is a defect rather than a typed failure,
|
|
102
|
+
* because the same work runs correctly on a local machine.
|
|
103
|
+
* `operation` names the refused operation.
|
|
75
104
|
*
|
|
76
105
|
* @category errors
|
|
77
106
|
* @since 0.4.0
|
|
@@ -93,8 +122,6 @@ StartupError,
|
|
|
93
122
|
* @since 0.4.0
|
|
94
123
|
*/
|
|
95
124
|
StoppedError } from "./internal/machine/machine.js";
|
|
96
|
-
const RuntimeRequirementTypeId = "~effect/Machine/RuntimeRequirement";
|
|
97
|
-
const ActionRequirementTypeId = "~effect/Machine/ActionRequirement";
|
|
98
125
|
const StateTypeId = "~effect/Machine/State";
|
|
99
126
|
const ChildAddressTypeId = "~effect/Machine/ChildAddress";
|
|
100
127
|
const ChildAddressCompatibilityErrorTypeId = "~effect/Machine/ChildAddressCompatibilityError";
|
|
@@ -172,6 +199,13 @@ export const state = internal.state;
|
|
|
172
199
|
* registered source by name with `invoke: { src }`, and only invoked sources
|
|
173
200
|
* add to the machine's requirements.
|
|
174
201
|
*
|
|
202
|
+
* Each run of invoked work owns a `Scope`, which every host closes when the run
|
|
203
|
+
* ends or is stopped. An Effect and a Stream get a new one for each run, and
|
|
204
|
+
* logic gets one from its `initial` through the end of its `run`. Finalizers
|
|
205
|
+
* added with `Effect.addFinalizer` or `Effect.acquireRelease` therefore run with
|
|
206
|
+
* the work, not when the machine stops. A timer acquires nothing, and a child
|
|
207
|
+
* machine has no scope of its own: its invoked work follows the same rule.
|
|
208
|
+
*
|
|
175
209
|
* `Machine.events` defines the public input protocol. `Machine.internalEvents`
|
|
176
210
|
* adds raised events and other machine-local deliveries.
|
|
177
211
|
* `Machine.emittedEvents` defines outward ephemeral notifications. The
|
|
@@ -189,7 +223,7 @@ export const state = internal.state;
|
|
|
189
223
|
* **Example** (Invoking a registered Effect)
|
|
190
224
|
*
|
|
191
225
|
* ```ts import.meta.vitest
|
|
192
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
226
|
+
* import { LocalMachine, Machine } from "@typeonce/effect-machine"
|
|
193
227
|
* import { Effect, Option, Schema } from "effect"
|
|
194
228
|
*
|
|
195
229
|
* const Lookup = Schema.TaggedUnion({ Loading: { id: Schema.String }, Ready: { name: Schema.String } })
|
|
@@ -215,7 +249,7 @@ export const state = internal.state;
|
|
|
215
249
|
* })
|
|
216
250
|
*
|
|
217
251
|
* const name = Effect.scoped(Effect.gen(function*() {
|
|
218
|
-
* const ref = yield*
|
|
252
|
+
* const ref = yield* LocalMachine.start(machine)
|
|
219
253
|
* yield* ref.send(Events.Load({ id: "1" }))
|
|
220
254
|
* const ready = yield* Machine.waitFor(ref, ({ state }) => state.state.path === "Ready").pipe(Effect.timeout("5 seconds"))
|
|
221
255
|
* return States.get(ready.state, "Ready").pipe(Option.map((state) => state.name))
|
|
@@ -301,7 +335,7 @@ export const events = internal.eventsFromFields;
|
|
|
301
335
|
* **Example** (Reusing a tagged union as the event protocol)
|
|
302
336
|
*
|
|
303
337
|
* ```ts import.meta.vitest
|
|
304
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
338
|
+
* import { LocalMachine, Machine } from "@typeonce/effect-machine"
|
|
305
339
|
* import { Effect, Schema } from "effect"
|
|
306
340
|
*
|
|
307
341
|
* const Event = Machine.eventsFromSchemas(
|
|
@@ -319,7 +353,7 @@ export const events = internal.eventsFromFields;
|
|
|
319
353
|
* })
|
|
320
354
|
*
|
|
321
355
|
* const count = Effect.scoped(Effect.gen(function*() {
|
|
322
|
-
* const ref = yield*
|
|
356
|
+
* const ref = yield* LocalMachine.start(machine)
|
|
323
357
|
* yield* ref.send(Event.Increment({ by: 1 }))
|
|
324
358
|
* return (yield* ref.state).value.count
|
|
325
359
|
* }))
|
|
@@ -459,7 +493,7 @@ export const emittedEventsFromSchemas = internal.emittedEvents;
|
|
|
459
493
|
* **When to use**
|
|
460
494
|
*
|
|
461
495
|
* Use when you need to store or transport a statechart snapshot independently
|
|
462
|
-
* of
|
|
496
|
+
* of the host that runs the machine.
|
|
463
497
|
*
|
|
464
498
|
* **Details**
|
|
465
499
|
*
|
|
@@ -563,9 +597,9 @@ export const decodeSnapshot = internal.decodeSnapshot;
|
|
|
563
597
|
*
|
|
564
598
|
* **Gotchas**
|
|
565
599
|
*
|
|
566
|
-
*
|
|
567
|
-
* protocol. Manual planners may inspect commands
|
|
568
|
-
* to execute child-addressed operations.
|
|
600
|
+
* Planning does not execute the closed command list. A host such as `LocalMachine`
|
|
601
|
+
* executes it as part of its commit protocol. Manual planners may inspect commands
|
|
602
|
+
* but need running machine targets to execute child-addressed operations.
|
|
569
603
|
*
|
|
570
604
|
* **Example** (Planning startup without running the machine)
|
|
571
605
|
*
|
|
@@ -584,7 +618,6 @@ export const decodeSnapshot = internal.decodeSnapshot;
|
|
|
584
618
|
* ```
|
|
585
619
|
*
|
|
586
620
|
* @see {@link plan} for planning a received event.
|
|
587
|
-
* @see {@link start} for the managed runtime protocol.
|
|
588
621
|
* @category constructors
|
|
589
622
|
* @since 0.4.0
|
|
590
623
|
*/
|
|
@@ -647,7 +680,7 @@ export const inputEventSchemas = internal.inputEventSchemas;
|
|
|
647
680
|
*/
|
|
648
681
|
export const transitionDefinitions = internal.transitionDefinitions;
|
|
649
682
|
/**
|
|
650
|
-
* Returns serializable descriptions of every state-owned
|
|
683
|
+
* Returns serializable descriptions of every state-owned invocation.
|
|
651
684
|
*
|
|
652
685
|
* **Details**
|
|
653
686
|
*
|
|
@@ -658,7 +691,7 @@ export const transitionDefinitions = internal.transitionDefinitions;
|
|
|
658
691
|
* @category getters
|
|
659
692
|
* @since 0.4.0
|
|
660
693
|
*/
|
|
661
|
-
export const
|
|
694
|
+
export const invocationDefinitions = internal.invocationDefinitions;
|
|
662
695
|
/**
|
|
663
696
|
* Returns every state node active in a decoded snapshot, in definition order.
|
|
664
697
|
*
|
|
@@ -752,8 +785,8 @@ export const can = internal.can;
|
|
|
752
785
|
*
|
|
753
786
|
* **Gotchas**
|
|
754
787
|
*
|
|
755
|
-
* `plan` returns data; it does not implement
|
|
756
|
-
* `
|
|
788
|
+
* `plan` returns data; it does not implement a commit protocol. A host such as
|
|
789
|
+
* `LocalMachine` executes child commands, publishes `next`, and then delivers
|
|
757
790
|
* `emittedEvents`. Events with no enabled transition are ignored and produce
|
|
758
791
|
* an unchanged plan.
|
|
759
792
|
*
|
|
@@ -784,11 +817,129 @@ export const can = internal.can;
|
|
|
784
817
|
* ```
|
|
785
818
|
*
|
|
786
819
|
* @see {@link planInitial} for planning machine startup.
|
|
787
|
-
* @see {@link start} for managed execution and lifecycle observation.
|
|
788
820
|
* @category combinators
|
|
789
821
|
* @since 0.4.0
|
|
790
822
|
*/
|
|
791
823
|
export const plan = internal.plan;
|
|
824
|
+
/**
|
|
825
|
+
* Extracts the step function of a machine: its pure form, for code that runs
|
|
826
|
+
* a machine on a new host.
|
|
827
|
+
*
|
|
828
|
+
* **When to use**
|
|
829
|
+
*
|
|
830
|
+
* Applications run machines with `LocalMachine`, `AtomMachine`, or
|
|
831
|
+
* `ClusterMachine`. Use `toStep` to write a host for a new runtime, such as a
|
|
832
|
+
* UI framework or a store, that keeps the state itself, runs the work of the
|
|
833
|
+
* machine, and reports back how it ended.
|
|
834
|
+
*
|
|
835
|
+
* **Details**
|
|
836
|
+
*
|
|
837
|
+
* The returned {@link MachineStep} runs nothing, and calls no user code for the
|
|
838
|
+
* work it lists. Each of its functions returns the next state, as a value,
|
|
839
|
+
* together with the commands to carry out, the work to stop and to start, in
|
|
840
|
+
* the order the host carries them out. Work is an Effect, a timer, a Stream, a
|
|
841
|
+
* `Logic`, or a child machine, described as data that the host evaluates when
|
|
842
|
+
* it starts it. The current entry of a state is part of the state value, so a
|
|
843
|
+
* result of work whose state was exited is ignored without the host comparing
|
|
844
|
+
* anything.
|
|
845
|
+
*
|
|
846
|
+
* `toStep` accepts every machine that `LocalMachine.start` accepts, and also a
|
|
847
|
+
* machine that declares a parent. A host states in its own types which kinds of
|
|
848
|
+
* work it runs, with {@link MachineStep.Supported}. The options are the
|
|
849
|
+
* {@link MachineStep.Options} of the machine: `self`, the `parent` of a machine
|
|
850
|
+
* that has one, and the `children` that its work acts on.
|
|
851
|
+
*
|
|
852
|
+
* `send` rejects an event that does not match its schema, and keeps the
|
|
853
|
+
* machine, as `send` of every host does.
|
|
854
|
+
*
|
|
855
|
+
* **Gotchas**
|
|
856
|
+
*
|
|
857
|
+
* The compiler reads only the requirements of a machine, and an input mapper
|
|
858
|
+
* receives `children` whatever its machine requires. A host that passes no
|
|
859
|
+
* `children` refuses every operation on them at run time with
|
|
860
|
+
* `ProcessLocalError`, as a defect that fails the machine.
|
|
861
|
+
*
|
|
862
|
+
* **Example** (Stepping a machine that loads a document)
|
|
863
|
+
*
|
|
864
|
+
* ```ts import.meta.vitest
|
|
865
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
866
|
+
* import { Effect, Exit, Schema } from "effect"
|
|
867
|
+
*
|
|
868
|
+
* const Events = Machine.events({ Load: {} })
|
|
869
|
+
* const machine = Machine.make({
|
|
870
|
+
* root: Machine.state({
|
|
871
|
+
* states: { Idle: {}, Loading: {}, Loaded: { fields: { text: Schema.String } } }
|
|
872
|
+
* }),
|
|
873
|
+
* events: Events,
|
|
874
|
+
* effects: { load: Effect.succeed("hello") }
|
|
875
|
+
* }).handle({
|
|
876
|
+
* initial: { target: "Idle" },
|
|
877
|
+
* states: {
|
|
878
|
+
* Idle: { on: { Load: { target: "Loading" } } },
|
|
879
|
+
* Loading: { invoke: { src: "load", onDone: { target: "Loaded", data: ({ output }) => ({ text: output }) } } }
|
|
880
|
+
* }
|
|
881
|
+
* })
|
|
882
|
+
*
|
|
883
|
+
* const self = { id: "loader", sessionId: "loader-1", send: () => Effect.void }
|
|
884
|
+
* const step = Machine.toStep(machine, { self })
|
|
885
|
+
*
|
|
886
|
+
* const program = Effect.gen(function*() {
|
|
887
|
+
* const started = yield* step.start()
|
|
888
|
+
* const loading = yield* step.send(started.state, Events.Load())
|
|
889
|
+
* const [work] = loading.start
|
|
890
|
+
* if (work?._tag !== "Effect") return "no work"
|
|
891
|
+
* const effect = work.effect()
|
|
892
|
+
* if (Exit.isFailure(effect)) return "cannot start"
|
|
893
|
+
* const loaded = step.settle(loading.state, work, yield* Effect.exit(effect.value))
|
|
894
|
+
* return loaded.snapshot.state.path
|
|
895
|
+
* })
|
|
896
|
+
*
|
|
897
|
+
* await Effect.runPromise(program) // => "Loaded"
|
|
898
|
+
* ```
|
|
899
|
+
*
|
|
900
|
+
* **Example** (Starting work whose input mapper throws)
|
|
901
|
+
*
|
|
902
|
+
* ```ts import.meta.vitest
|
|
903
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
904
|
+
* import { Effect, Exit } from "effect"
|
|
905
|
+
*
|
|
906
|
+
* const machine = Machine.make({
|
|
907
|
+
* root: Machine.state({ states: { Loading: {} } }),
|
|
908
|
+
* events: Machine.events({}),
|
|
909
|
+
* effects: { load: (_: string) => Effect.void }
|
|
910
|
+
* }).handle({
|
|
911
|
+
* initial: { target: "Loading" },
|
|
912
|
+
* states: {
|
|
913
|
+
* Loading: {
|
|
914
|
+
* invoke: {
|
|
915
|
+
* src: "load",
|
|
916
|
+
* input: (): string => {
|
|
917
|
+
* throw new Error("no input")
|
|
918
|
+
* },
|
|
919
|
+
* onDone: { stay: true }
|
|
920
|
+
* }
|
|
921
|
+
* }
|
|
922
|
+
* }
|
|
923
|
+
* })
|
|
924
|
+
*
|
|
925
|
+
* const self = { id: "loader", sessionId: "loader-1", send: () => Effect.void }
|
|
926
|
+
* const step = Machine.toStep(machine, { self })
|
|
927
|
+
*
|
|
928
|
+
* // An `Exit` is an Effect, so the step that starts the machine runs as one.
|
|
929
|
+
* const started = Effect.runSync(step.start())
|
|
930
|
+
* const [work] = started.start
|
|
931
|
+
* // The step called no user code: the host evaluates work as it starts it.
|
|
932
|
+
* const effect = work?._tag === "Effect" ? work.effect() : undefined
|
|
933
|
+
* const failed = effect !== undefined && Exit.isFailure(effect) ? step.settle(started.state, work!, effect) : started
|
|
934
|
+
*
|
|
935
|
+
* failed.exit !== undefined && Exit.isFailure(failed.exit) // => true
|
|
936
|
+
* ```
|
|
937
|
+
*
|
|
938
|
+
* @see {@link plan} for planning one event without work.
|
|
939
|
+
* @category destructors
|
|
940
|
+
* @since 0.48.0
|
|
941
|
+
*/
|
|
942
|
+
export const toStep = internal.toStep;
|
|
792
943
|
/**
|
|
793
944
|
* Creates advanced stateful process logic from explicit initialization and
|
|
794
945
|
* execution methods.
|
|
@@ -862,8 +1013,8 @@ export const childAddress = internal.childAddress;
|
|
|
862
1013
|
*
|
|
863
1014
|
* **Gotchas**
|
|
864
1015
|
*
|
|
865
|
-
* This Effect requires
|
|
866
|
-
* unique for the current parent until that child stops.
|
|
1016
|
+
* This Effect requires {@link MachineRuntime}, which only some hosts provide. A
|
|
1017
|
+
* named child id must be unique for the current parent until that child stops.
|
|
867
1018
|
*
|
|
868
1019
|
* Register logic in `make({ logic })` and use `invoke: { src, id, address, ...outcomes }` for children
|
|
869
1020
|
* that start and stop with that state.
|
|
@@ -875,6 +1026,14 @@ export const spawn = internal.spawn;
|
|
|
875
1026
|
/**
|
|
876
1027
|
* Sends an event to a named child process of the running machine.
|
|
877
1028
|
*
|
|
1029
|
+
* **Details**
|
|
1030
|
+
*
|
|
1031
|
+
* With the descriptor of an invoked child machine, it requires only
|
|
1032
|
+
* {@link ChildMachineRuntime}, which `ClusterMachine` provides too. With a
|
|
1033
|
+
* child address, it requires {@link MachineRuntime}. When the addressed child
|
|
1034
|
+
* is a machine whose event schema refuses the event, fails with
|
|
1035
|
+
* {@link MachineSchemaDecodeError} and leaves the child running.
|
|
1036
|
+
*
|
|
878
1037
|
* @category runtime
|
|
879
1038
|
* @since 0.4.0
|
|
880
1039
|
*/
|
|
@@ -882,6 +1041,12 @@ export const sendTo = internal.sendTo;
|
|
|
882
1041
|
/**
|
|
883
1042
|
* Stops a named child process of the running machine.
|
|
884
1043
|
*
|
|
1044
|
+
* **Details**
|
|
1045
|
+
*
|
|
1046
|
+
* With the descriptor of an invoked child machine, it requires only
|
|
1047
|
+
* {@link ChildMachineRuntime}, which `ClusterMachine` provides too. With a
|
|
1048
|
+
* child address, it requires {@link MachineRuntime}.
|
|
1049
|
+
*
|
|
885
1050
|
* @category runtime
|
|
886
1051
|
* @since 0.4.0
|
|
887
1052
|
*/
|
|
@@ -889,6 +1054,9 @@ export const stopChild = internal.stopChild;
|
|
|
889
1054
|
/**
|
|
890
1055
|
* Returns a stream of terminal lifecycle outcomes for a running machine.
|
|
891
1056
|
*
|
|
1057
|
+
* Reads only the `changes` of the reference, so it works with a reference from
|
|
1058
|
+
* any host.
|
|
1059
|
+
*
|
|
892
1060
|
* @category combinators
|
|
893
1061
|
* @since 0.4.0
|
|
894
1062
|
*/
|
|
@@ -896,6 +1064,9 @@ export const watch = internal.watch;
|
|
|
896
1064
|
/**
|
|
897
1065
|
* Waits for the first current or subsequent published snapshot matching a predicate.
|
|
898
1066
|
*
|
|
1067
|
+
* Reads only the `changes` of the reference, so it works with a reference from
|
|
1068
|
+
* any host.
|
|
1069
|
+
*
|
|
899
1070
|
* Use for external Effect coordination and tests. Prefer atom selectors for UI
|
|
900
1071
|
* reads, invocation outcomes for workflow behavior, and `ref.join` for output.
|
|
901
1072
|
* This observes state; it does not acknowledge or correlate a sent event.
|
|
@@ -913,7 +1084,7 @@ export const watch = internal.watch;
|
|
|
913
1084
|
* **Example** (Waiting for a state with a timeout)
|
|
914
1085
|
*
|
|
915
1086
|
* ```ts import.meta.vitest
|
|
916
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
1087
|
+
* import { LocalMachine, Machine } from "@typeonce/effect-machine"
|
|
917
1088
|
* import { Effect } from "effect"
|
|
918
1089
|
*
|
|
919
1090
|
* const Events = Machine.events({ Finish: {} })
|
|
@@ -928,7 +1099,7 @@ export const watch = internal.watch;
|
|
|
928
1099
|
* })
|
|
929
1100
|
*
|
|
930
1101
|
* const path = Effect.scoped(Effect.gen(function*() {
|
|
931
|
-
* const ref = yield*
|
|
1102
|
+
* const ref = yield* LocalMachine.start(machine)
|
|
932
1103
|
* yield* ref.send(Events.Finish())
|
|
933
1104
|
* const ready = yield* Machine.waitFor(ref, ({ state }) => state.state.path === "Ready").pipe(Effect.timeout("5 seconds"))
|
|
934
1105
|
* return ready.state.state.path
|
|
@@ -940,166 +1111,4 @@ export const watch = internal.watch;
|
|
|
940
1111
|
* @since 0.37.0
|
|
941
1112
|
*/
|
|
942
1113
|
export const waitFor = internal.waitFor;
|
|
943
|
-
/**
|
|
944
|
-
* Prepares a fresh machine without initializing it.
|
|
945
|
-
*
|
|
946
|
-
* Use this constructor when observation must be composed before initial-entry
|
|
947
|
-
* actions run. Subscribe to `prepared.emissions`, then evaluate
|
|
948
|
-
* `prepared.start`. Ordinary callers can continue to use {@link start}, which
|
|
949
|
-
* starts directly and does not allocate the prepared lifecycle boundary.
|
|
950
|
-
*
|
|
951
|
-
* `prepared.start` is one-shot and scoped: the `Scope` that first evaluates it
|
|
952
|
-
* owns the machine, and closing that `Scope` is equivalent to `ref.stop`.
|
|
953
|
-
*
|
|
954
|
-
* **Example** (Observing emissions before startup)
|
|
955
|
-
*
|
|
956
|
-
* ```ts import.meta.vitest
|
|
957
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
958
|
-
* import { Effect, Stream } from "effect"
|
|
959
|
-
*
|
|
960
|
-
* const Emitted = Machine.emittedEvents({ Started: {} })
|
|
961
|
-
* const machine = Machine.make({
|
|
962
|
-
* root: Machine.state({ states: { Idle: {} } }),
|
|
963
|
-
* events: Machine.events({}),
|
|
964
|
-
* emittedEvents: Emitted
|
|
965
|
-
* }).handle({
|
|
966
|
-
* initial: { target: "Idle" },
|
|
967
|
-
* states: {
|
|
968
|
-
* Idle: {
|
|
969
|
-
* entry: (_, enqueue) => {
|
|
970
|
-
* enqueue.emit(Emitted.Started())
|
|
971
|
-
* }
|
|
972
|
-
* }
|
|
973
|
-
* }
|
|
974
|
-
* })
|
|
975
|
-
*
|
|
976
|
-
* const emitted = Effect.scoped(Effect.gen(function*() {
|
|
977
|
-
* const prepared = yield* Machine.prepare(machine)
|
|
978
|
-
* const seen: Array<string> = []
|
|
979
|
-
* yield* prepared.emissions.pipe(
|
|
980
|
-
* Stream.runForEach((event) => Effect.sync(() => seen.push(event._tag))),
|
|
981
|
-
* Effect.forkScoped({ startImmediately: true })
|
|
982
|
-
* )
|
|
983
|
-
* yield* prepared.start
|
|
984
|
-
* yield* Effect.yieldNow
|
|
985
|
-
* return seen
|
|
986
|
-
* }))
|
|
987
|
-
*
|
|
988
|
-
* await Effect.runPromise(emitted) // => ["Started"]
|
|
989
|
-
* ```
|
|
990
|
-
*
|
|
991
|
-
* @category constructors
|
|
992
|
-
* @since 0.11.0
|
|
993
|
-
*/
|
|
994
|
-
export const prepare = internal.prepare;
|
|
995
|
-
/**
|
|
996
|
-
* Starts a machine owned by the current `Scope`.
|
|
997
|
-
*
|
|
998
|
-
* **When to use**
|
|
999
|
-
*
|
|
1000
|
-
* Use when you want asynchronous event delivery, lifecycle snapshots, `join`,
|
|
1001
|
-
* and machine-owned spawned or invoked children.
|
|
1002
|
-
*
|
|
1003
|
-
* **Details**
|
|
1004
|
-
*
|
|
1005
|
-
* For each accepted event the runtime plans the complete synchronous
|
|
1006
|
-
* macrostep, executes closed machine commands, stops invokes for exited states,
|
|
1007
|
-
* publishes the new state, delivers emitted events, and then starts invokes
|
|
1008
|
-
* for entered states.
|
|
1009
|
-
*
|
|
1010
|
-
* The machine is a scoped resource, like `Effect.forkScoped`. Closing the
|
|
1011
|
-
* `Scope` is equivalent to `ref.stop`: active invocations are interrupted,
|
|
1012
|
-
* owned children stop, the snapshot becomes `stopped`, and later sends fail
|
|
1013
|
-
* with `StoppedError`. An earlier `ref.stop` or terminal completion leaves the
|
|
1014
|
-
* finalizer with nothing to do. Own a `Scope` explicitly, for example with
|
|
1015
|
-
* `Scope.make` and `Scope.provide`, when the machine must outlive the caller.
|
|
1016
|
-
*
|
|
1017
|
-
* **Gotchas**
|
|
1018
|
-
*
|
|
1019
|
-
* The returned handle's `send` operation only enqueues events. Transition
|
|
1020
|
-
* failures are reported through the runtime snapshot, `changes`, and `join`
|
|
1021
|
-
* rather than being returned by `send`. Sending after the machine reaches any
|
|
1022
|
-
* terminal state fails immediately with `StoppedError`.
|
|
1023
|
-
*
|
|
1024
|
-
* **Example** (Starting a machine in a scope)
|
|
1025
|
-
*
|
|
1026
|
-
* ```ts import.meta.vitest
|
|
1027
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
1028
|
-
* import { Effect } from "effect"
|
|
1029
|
-
*
|
|
1030
|
-
* const States = Machine.state({ states: { Idle: {} } })
|
|
1031
|
-
* const machine = Machine.make({ root: States, events: Machine.events({}) }).handle({
|
|
1032
|
-
* initial: { target: "Idle" }
|
|
1033
|
-
* })
|
|
1034
|
-
*
|
|
1035
|
-
* const path = Effect.scoped(Effect.gen(function*() {
|
|
1036
|
-
* const ref = yield* Machine.start(machine)
|
|
1037
|
-
* return (yield* ref.state).state.path
|
|
1038
|
-
* }))
|
|
1039
|
-
*
|
|
1040
|
-
* await Effect.runPromise(path) // => "Idle"
|
|
1041
|
-
* ```
|
|
1042
|
-
*
|
|
1043
|
-
* @see {@link plan} for inspecting the same transition plan without executing it.
|
|
1044
|
-
* @see {@link watch} for classified terminal outcomes.
|
|
1045
|
-
* @category constructors
|
|
1046
|
-
* @since 0.4.0
|
|
1047
|
-
*/
|
|
1048
|
-
export const start = internal.start;
|
|
1049
|
-
/**
|
|
1050
|
-
* Starts a fresh managed runtime from a decoded logical snapshot, owned by the
|
|
1051
|
-
* current `Scope`.
|
|
1052
|
-
*
|
|
1053
|
-
* **Details**
|
|
1054
|
-
*
|
|
1055
|
-
* The resumed machine has the same scoped lifetime as {@link start}: closing
|
|
1056
|
-
* the `Scope` is equivalent to `ref.stop`.
|
|
1057
|
-
*
|
|
1058
|
-
* `resume` validates and normalizes the supplied snapshot before publishing it
|
|
1059
|
-
* as the first state. It does not construct the declared initial state, replay
|
|
1060
|
-
* entry or transition actions, re-deliver raised or emitted events, or
|
|
1061
|
-
* re-evaluate historical completion and eventless transitions. Active-state
|
|
1062
|
-
* invokes start once in ancestor and document order with {@link InitialEvent};
|
|
1063
|
-
* timer invocations restart their complete duration and child-machine
|
|
1064
|
-
* invocations start from their own initial state.
|
|
1065
|
-
*
|
|
1066
|
-
* Only logical state, completion, and history metadata are resumed. Queues,
|
|
1067
|
-
* scopes, subscriptions, fibers, spawned children, invoke progress, and prior
|
|
1068
|
-
* runtime status are process-local and are not restored. A final snapshot
|
|
1069
|
-
* immediately produces a completed ref with its current-machine output.
|
|
1070
|
-
*
|
|
1071
|
-
* Decode encoded data explicitly with {@link decodeSnapshot} before calling
|
|
1072
|
-
* this function. Stable snapshots are hosted as supplied; newly enabled
|
|
1073
|
-
* eventless or completion transitions in a changed machine definition are not
|
|
1074
|
-
* evaluated merely because the runtime was resumed; only ordinary subsequent
|
|
1075
|
-
* transition planning can enter and stabilize states.
|
|
1076
|
-
*
|
|
1077
|
-
* **Example** (Resuming from a decoded snapshot)
|
|
1078
|
-
*
|
|
1079
|
-
* ```ts import.meta.vitest
|
|
1080
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
1081
|
-
* import { Effect } from "effect"
|
|
1082
|
-
*
|
|
1083
|
-
* const States = Machine.state({ states: { Idle: {} } })
|
|
1084
|
-
* const machine = Machine.make({ root: States, events: Machine.events({}) }).handle({
|
|
1085
|
-
* initial: { target: "Idle" }
|
|
1086
|
-
* })
|
|
1087
|
-
*
|
|
1088
|
-
* const path = Effect.scoped(Effect.gen(function*() {
|
|
1089
|
-
* const initial = yield* Machine.planInitial(machine)
|
|
1090
|
-
* const encoded = yield* Machine.encodeSnapshot(machine, initial.state)
|
|
1091
|
-
* const snapshot = yield* Machine.decodeSnapshot(machine, encoded)
|
|
1092
|
-
* const ref = yield* Machine.resume(machine, snapshot)
|
|
1093
|
-
* return (yield* ref.state).state.path
|
|
1094
|
-
* }))
|
|
1095
|
-
*
|
|
1096
|
-
* await Effect.runPromise(path) // => "Idle"
|
|
1097
|
-
* ```
|
|
1098
|
-
*
|
|
1099
|
-
* @see {@link decodeSnapshot} for the schema and transport boundary.
|
|
1100
|
-
* @see {@link start} for ordinary initial startup.
|
|
1101
|
-
* @category constructors
|
|
1102
|
-
* @since 0.4.0
|
|
1103
|
-
*/
|
|
1104
|
-
export const resume = internal.resume;
|
|
1105
1114
|
//# sourceMappingURL=Machine.js.map
|
package/dist/Machine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Machine.js","sourceRoot":"","sources":["../src/Machine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Machine.js","sourceRoot":"","sources":["../src/Machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAe9C,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAczF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAW,iBAAiB,CAAA;AA4B/C,MAAM,YAAY,GAAG,wBAAwB,CAAA;AAE7C;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAa7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAA;AAEtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAU,EAAqB,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAA;AAExH;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAkChC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAU,EAAwB,EAAE,CACpE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,qBAAqB,CAAA;AA0Q5D,OAAO;AACL;;;;;;GAMG;AACH,uBAAuB;AACvB;;;;;;GAMG;AACH,uBAAuB;AACvB;;;;;;GAMG;AACH,wBAAwB;AACxB;;;;;;GAMG;AACH,wBAAwB;AACxB;;;;;;;;;;;;;;;GAeG;AACH,iBAAiB;AACjB;;;;;;GAMG;AACH,YAAY;AACZ;;;;;;GAMG;AACH,YAAY,EACb,MAAM,+BAA+B,CAAA;AAobtC,MAAM,WAAW,GAAG,uBAAuB,CAAA;AAwkB3C,MAAM,kBAAkB,GAAG,8BAA8B,CAAA;AACzD,MAAM,oCAAoC,GAAG,gDAAgD,CAAA;AAC7F,MAAM,mCAAmC,GAAG,+CAA+C,CAAA;AAC3F,MAAM,kBAAkB,GAAG,8BAA8B,CAAA;AA0vJzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAqC,QAAQ,CAAC,SAAS,CAAA;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GA6BiD,QAAQ,CAAC,OAAO,CAAA;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,KAAK,GAAqB,QAAQ,CAAC,KAAyB,CAAA;AA8IzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkHG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS,QAAQ,CAAC,IAAI,CAAA;AA0BvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,MAAM,GAE+C,QAAQ,CAAC,gBAAgB,CAAA;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAI1B,QAAQ,CAAC,MAAM,CAAA;AAEnB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAEe,QAAQ,CAAC,MAAM,CAAA;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAEO,QAAQ,CAAC,cAAc,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,CAAC,MAAM,cAAc,GAKyC,QAAQ,CAAC,wBAAwB,CAAA;AAErG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAIlC,QAAQ,CAAC,cAAc,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,aAAa,GAKyC,QAAQ,CAAC,uBAAuB,CAAA;AAEnG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAIjC,QAAQ,CAAC,aAAa,CAAA;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,cAAc,GAiCvB,QAAQ,CAAC,cAAc,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAC,MAAM,cAAc,GAiCvB,QAAQ,CAAC,cAAc,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,WAAW,GAuEpB,QAAQ,CAAC,WAAW,CAAA;AAExB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAMnB,QAAQ,CAAC,UAAU,CAAA;AAEvB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAE1B,QAAQ,CAAC,iBAAiB,CAAA;AAE9B;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,QAAQ,CAAC,iBAAiB,CAAA;AAE5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAM9B,QAAQ,CAAC,qBAAqB,CAAA;AAElC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAGhC,QAAQ,CAAC,qBAAqB,CAAA;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAQtB,QAAQ,CAAC,aAAa,CAAA;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GA6BgC,QAAQ,CAAC,OAAO,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,GAAG,GAsEZ,QAAQ,CAAC,GAAG,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,MAAM,IAAI,GAuEb,QAAQ,CAAC,IAAI,CAAA;AAsqBjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqHG;AACH,MAAM,CAAC,MAAM,MAAM,GA6Df,QAAQ,CAAC,MAAe,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,KAAK,GAkB2E,QAAQ,CAAC,KAAK,CAAA;AAE3G;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,KAAK,GAChB,QAAQ,CAAC,KAAK,CAAA;AAEhB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkE,QAAQ,CAAC,WAAW,CAAA;AAE9G;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAuD,QAAQ,CAAC,YAAY,CAAA;AAErG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,KAAK,GAsCd,QAAQ,CAAC,KAAK,CAAA;AAElB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,MAAM,GASf,QAAQ,CAAC,MAAe,CAAA;AAE5B;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAGlB,QAAQ,CAAC,SAAkB,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,KAAK,GAEyC,QAAQ,CAAC,KAAK,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,CAAC,MAAM,OAAO,GAqBhB,QAAQ,CAAC,OAAO,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
@@ -8,10 +8,10 @@ import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
|
|
|
8
8
|
import type * as Schema from "effect/Schema";
|
|
9
9
|
import type * as Scope from "effect/Scope";
|
|
10
10
|
import * as Stream from "effect/Stream";
|
|
11
|
+
import type * as LocalMachine from "../../LocalMachine.js";
|
|
11
12
|
import type * as Machine from "../../Machine.js";
|
|
12
13
|
import type { Bound, ChildMachineAtom, MachineAtom } from "../../unstable/reactivity/AtomMachine.js";
|
|
13
14
|
import type { EnsureExecutable } from "./readiness.js";
|
|
14
|
-
import type { ExcludeCompatibleRuntime as ExcludeCompatibleMachineRuntime, IsAny } from "./requirements.js";
|
|
15
15
|
declare const ChildNotActiveError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
16
16
|
readonly _tag: "ChildNotActiveError";
|
|
17
17
|
} & Readonly<A>;
|
|
@@ -19,22 +19,21 @@ export declare class ChildNotActiveError extends ChildNotActiveError_base<{
|
|
|
19
19
|
readonly id: string;
|
|
20
20
|
}> {
|
|
21
21
|
}
|
|
22
|
+
type IsAny<A> = 0 extends (1 & A) ? true : false;
|
|
22
23
|
type AtomSupportedRequirements = Scope.Scope | AtomRegistry.AtomRegistry;
|
|
23
24
|
type ExternalRequirements<Requirements> = Exclude<Requirements, AtomSupportedRequirements>;
|
|
24
25
|
declare const ExternalRequirementsTypeId = "~effect/reactivity/AtomMachine/ExternalRequirements";
|
|
25
26
|
type EnsureNoExternalRequirements<Requirements> = [ExternalRequirements<Requirements>] extends [never] ? unknown : {
|
|
26
27
|
readonly [ExternalRequirementsTypeId]: ExternalRequirements<Requirements>;
|
|
27
28
|
};
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type MachineRuntimeError<E, R> = E | Machine.ActionError<R> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StoppedError;
|
|
31
|
-
type MachineStartError<InitialE, E, InitialR, R, RuntimeError = never> = InitialE | E | Machine.ActionError<InitialR | R> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StartupError | Machine.StoppedError | RuntimeError;
|
|
29
|
+
type MachineRuntimeError<E> = E | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StoppedError;
|
|
30
|
+
type MachineStartError<E, RuntimeError = never> = E | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StartupError | Machine.StoppedError | RuntimeError;
|
|
32
31
|
export declare const isMachineAtom: (u: unknown) => u is MachineAtom<any, never, any, any, any, any>;
|
|
33
32
|
type RefState<Ref> = Ref extends Machine.MachineRef<infer State, any, any, any, any> ? State : never;
|
|
34
33
|
type RefError<Ref> = Ref extends Machine.MachineRef<any, any, infer Error, any, any> ? Error : never;
|
|
35
34
|
type RefEmitted<Ref> = Ref extends Machine.MachineRef<any, any, any, any, infer Emitted> ? Emitted : never;
|
|
36
35
|
export declare const emissions: <State, Event, Error, Output, StartError, Emitted>(self: MachineAtom<State, Event, Error, Output, StartError, Emitted>) => Stream.Stream<Emitted, StartError, AtomRegistry.AtomRegistry>;
|
|
37
|
-
export declare const inspection: <State, Event, Error, Output, StartError, Emitted>(self: MachineAtom<State, Event, Error, Output, StartError, Emitted>) => Stream.Stream<
|
|
36
|
+
export declare const inspection: <State, Event, Error, Output, StartError, Emitted>(self: MachineAtom<State, Event, Error, Output, StartError, Emitted>) => Stream.Stream<LocalMachine.Inspection.Event, StartError, AtomRegistry.AtomRegistry>;
|
|
38
37
|
export declare const childEmissions: <Child extends Machine.ChildMachine.Any, StartError>(self: ChildMachineAtom<Child, StartError>) => Stream.Stream<RefEmitted<Machine.ChildMachine.Ref<Child>>, StartError, AtomRegistry.AtomRegistry>;
|
|
39
38
|
type SnapshotNode<State> = State extends Machine.Machine.AtomicSnapshot<string, unknown> ? State | (State extends {
|
|
40
39
|
readonly state: infer Child;
|
|
@@ -65,17 +64,16 @@ export declare const selectSnapshotChild: <Child extends Machine.ChildMachine.An
|
|
|
65
64
|
export declare const matches: <State extends Machine.Machine.AtomicSnapshot<string, unknown>, Event, Error, Output, StartError, Emitted, const Path extends SnapshotIdentifier<State>>(self: MachineAtom<State, Event, Error, Output, StartError, Emitted>, path: Path) => Atom.Atom<AsyncResult.AsyncResult<boolean, StartError | Error>>;
|
|
66
65
|
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>>>>;
|
|
67
66
|
export declare const can: (event: unknown) => (self: MachineAtom<any, any, any, any, any, any>) => Atom.Atom<AsyncResult.AsyncResult<boolean, any>>;
|
|
68
|
-
type MachineResumeRequirementsOf<M extends Machine.Machine.Any> = MachineResumeRequirements<Machine.Machine.Services<M>, Machine.Machine.Event<M>, Machine.Machine.EmittedEvent<M>>;
|
|
69
67
|
type EnsureMachineExecutable<M extends Machine.Machine.Any> = IsAny<Machine.Machine.States<M>> extends true ? {
|
|
70
68
|
readonly "~effect/reactivity/AtomMachine/ConcreteMachineRequired": M;
|
|
71
69
|
} : EnsureExecutable<Machine.Machine.States<M>, Machine.Machine.UnhandledStates<M>, Machine.Machine.OutputStates<M>>;
|
|
72
|
-
type ResumedMachineAtomOf<M extends Machine.Machine.Any, RuntimeError> = MachineAtom<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>, MachineRuntimeError<Machine.Machine.Error<M
|
|
70
|
+
type ResumedMachineAtomOf<M extends Machine.Machine.Any, RuntimeError> = MachineAtom<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>, MachineRuntimeError<Machine.Machine.Error<M>>, Machine.Machine.Output<M>, Machine.MachineSchemaDecodeError | RuntimeError, Machine.Machine.EmittedEvent<M>>;
|
|
73
71
|
export declare const make: {
|
|
74
|
-
<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,
|
|
72
|
+
<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, FinalStates extends Machine.Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.Machine.TaggedSchema> = Events, ParentEvents extends ReadonlyArray<Machine.Machine.TaggedSchema> = readonly []>(machine: Machine.Machine<States, Events, Input, UnhandledStates, E, R, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureNoExternalRequirements<LocalMachine.RequiredServices<R>> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.Machine.RootCompatible<ParentEvents>, ...args: [...Machine.Machine.InputArgs<Input>]): MachineAtom<Machine.Machine.Snapshot<States>, Machine.Machine.EventInputOf<InputEvents>, MachineRuntimeError<E>, Output, MachineStartError<E>, Machine.Machine.EmittedEventOf<Emits>>;
|
|
75
73
|
};
|
|
76
74
|
export declare const factory: any;
|
|
77
75
|
export declare const resume: {
|
|
78
|
-
<M extends Machine.Machine.Any>(machine: M & EnsureNoExternalRequirements<
|
|
76
|
+
<M extends Machine.Machine.Any>(machine: M & EnsureNoExternalRequirements<LocalMachine.RequiredServices<Machine.Machine.Services<NoInfer<M>>>> & EnsureMachineExecutable<NoInfer<M>> & Machine.Machine.RootCompatible<Machine.Machine.ParentEvents<NoInfer<M>>>, snapshot: Machine.Machine.Snapshot<Machine.Machine.States<M>>): ResumedMachineAtomOf<M, never>;
|
|
79
77
|
};
|
|
80
78
|
type FamilyBridge = MachineAtom.Any | ChildMachineAtom.Any;
|
|
81
79
|
type FamilyOptions = {
|