@typeonce/effect-machine 0.33.0 → 0.35.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 +272 -628
- package/dist/Machine.d.ts +1076 -896
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +141 -90
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/childRegistry.d.ts +1 -1
- package/dist/internal/machine/childRegistry.d.ts.map +1 -1
- package/dist/internal/machine/cluster.d.ts +2 -50
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js +4 -27
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/clusterProtocol.d.ts +35 -0
- package/dist/internal/machine/clusterProtocol.d.ts.map +1 -0
- package/dist/internal/machine/clusterProtocol.js +28 -0
- package/dist/internal/machine/clusterProtocol.js.map +1 -0
- package/dist/internal/machine/commandRuntime.d.ts +1 -1
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/configuration.d.ts +2 -2
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +38 -64
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/declaration.d.ts +17 -0
- package/dist/internal/machine/declaration.d.ts.map +1 -0
- package/dist/internal/machine/declaration.js +120 -0
- package/dist/internal/machine/declaration.js.map +1 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +15 -22
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/implementation.d.ts +34 -0
- package/dist/internal/machine/implementation.d.ts.map +1 -0
- package/dist/internal/machine/implementation.js +3 -0
- package/dist/internal/machine/implementation.js.map +1 -0
- package/dist/internal/machine/initialDeclaration.d.ts +14 -0
- package/dist/internal/machine/initialDeclaration.d.ts.map +1 -0
- package/dist/internal/machine/initialDeclaration.js +137 -0
- package/dist/internal/machine/initialDeclaration.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts.map +1 -1
- package/dist/internal/machine/machine.d.ts +13 -4
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +169 -388
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +8 -0
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +37 -78
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +8 -7
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +16 -12
- 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.map +1 -1
- package/dist/internal/machine/runtime.d.ts +2 -230
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +8 -1857
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.d.ts +5 -0
- package/dist/internal/machine/runtimeCompiled.d.ts.map +1 -0
- package/dist/internal/machine/runtimeCompiled.js +867 -0
- package/dist/internal/machine/runtimeCompiled.js.map +1 -0
- package/dist/internal/machine/runtimeGeneric.d.ts +3 -0
- package/dist/internal/machine/runtimeGeneric.d.ts.map +1 -0
- package/dist/internal/machine/runtimeGeneric.js +471 -0
- package/dist/internal/machine/runtimeGeneric.js.map +1 -0
- package/dist/internal/machine/runtimeProtocol.d.ts +312 -0
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -0
- package/dist/internal/machine/runtimeProtocol.js +561 -0
- package/dist/internal/machine/runtimeProtocol.js.map +1 -0
- package/dist/internal/machine/stateDefinition.d.ts +1 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +1 -13
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/targetReference.d.ts +15 -0
- package/dist/internal/machine/targetReference.d.ts.map +1 -0
- package/dist/internal/machine/targetReference.js +41 -0
- package/dist/internal/machine/targetReference.js.map +1 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +5 -3
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +53 -46
- package/dist/internal/testing/machine/finiteModel.js.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/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +7 -1
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +105 -73
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +105 -73
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +18 -13
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +18 -25
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +41 -24
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +41 -24
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +66 -91
- package/docs/machine-review.md +19 -49
- package/docs/root-api.md +62 -62
- package/package.json +1 -1
- package/src/Machine.ts +1836 -2907
- package/src/internal/machine/childRegistry.ts +1 -1
- package/src/internal/machine/cluster.ts +7 -73
- package/src/internal/machine/clusterProtocol.ts +56 -0
- package/src/internal/machine/commandRuntime.ts +1 -1
- package/src/internal/machine/configuration.ts +53 -65
- package/src/internal/machine/declaration.ts +140 -0
- package/src/internal/machine/executionPlan.ts +16 -22
- package/src/internal/machine/implementation.ts +41 -0
- package/src/internal/machine/initialDeclaration.ts +157 -0
- package/src/internal/machine/invocation.ts +3 -3
- package/src/internal/machine/invocationDefinition.ts +1 -1
- package/src/internal/machine/machine.ts +225 -576
- package/src/internal/machine/planner.ts +84 -118
- package/src/internal/machine/process.ts +40 -33
- package/src/internal/machine/protocol.ts +3 -3
- package/src/internal/machine/runtime.ts +20 -3037
- package/src/internal/machine/runtimeCompiled.ts +1166 -0
- package/src/internal/machine/runtimeGeneric.ts +799 -0
- package/src/internal/machine/runtimeProtocol.ts +1213 -0
- package/src/internal/machine/stateDefinition.ts +1 -15
- package/src/internal/machine/targetReference.ts +55 -0
- package/src/internal/machine/topology.ts +5 -3
- package/src/internal/testing/machine/finiteModel.ts +58 -53
- package/src/internal/testing/machine/probe.ts +1 -1
- package/src/internal/testing/machine/verification.ts +7 -1
- package/src/testing/MachineTest.ts +105 -73
- package/src/unstable/cluster/ClusterMachine.ts +22 -25
- package/src/unstable/reactivity/AtomMachine.ts +41 -24
|
@@ -14,10 +14,12 @@ import * as Configuration from "./configuration.js"
|
|
|
14
14
|
import { InfiniteTransitionError, MachineSchemaDecodeError, StartupError } from "./errors.js"
|
|
15
15
|
import type { StoppedError } from "./errors.js"
|
|
16
16
|
import * as ExecutionPlan from "./executionPlan.js"
|
|
17
|
+
import { type CapturedStateConfig, toImpl } from "./implementation.js"
|
|
17
18
|
import * as Invocation from "./invocation.js"
|
|
18
19
|
import * as internalPlanner from "./planner.js"
|
|
19
20
|
import type { ExcludeCompatibleRuntime } from "./requirements.js"
|
|
20
21
|
import * as internalRuntime from "./runtime.js"
|
|
22
|
+
import * as internalRuntimeProtocol from "./runtimeProtocol.js"
|
|
21
23
|
import * as Serialization from "./serialization.js"
|
|
22
24
|
|
|
23
25
|
type ProcessEntry<States extends Machine.StateSchemas, Input extends Schema.Top> =
|
|
@@ -80,7 +82,7 @@ const hasInvokeCapability = (machine: Machine.Any): boolean => {
|
|
|
80
82
|
return cached
|
|
81
83
|
}
|
|
82
84
|
const hasInvokes = Object.values(
|
|
83
|
-
machine.handlers as Record<string,
|
|
85
|
+
toImpl(machine).handlers as Record<string, CapturedStateConfig>
|
|
84
86
|
).some((config) => config.invoke !== undefined)
|
|
85
87
|
invokeCapabilityCache.set(machine, hasInvokes)
|
|
86
88
|
return hasInvokes
|
|
@@ -90,7 +92,7 @@ const makeChildlessCompiledDrain = (
|
|
|
90
92
|
machine: Machine.Any,
|
|
91
93
|
checkInitialFinal: boolean
|
|
92
94
|
): (
|
|
93
|
-
context:
|
|
95
|
+
context: internalRuntimeProtocol.CompiledProcessContext<any, any>
|
|
94
96
|
) => Effect.Effect<Option.Option<any>, any, any> => {
|
|
95
97
|
const executionPlan = ExecutionPlan.compileExecutionPlan(machine)
|
|
96
98
|
return (context) => {
|
|
@@ -114,7 +116,7 @@ const makeChildlessCompiledDrain = (
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
const message = pending.value
|
|
117
|
-
const acknowledged =
|
|
119
|
+
const acknowledged = internalRuntimeProtocol.isAcknowledgedMessage(message)
|
|
118
120
|
const event = acknowledged ? message.event : message
|
|
119
121
|
const before = current
|
|
120
122
|
|
|
@@ -180,7 +182,7 @@ const makeChildlessCompiledDrain = (
|
|
|
180
182
|
beforeCommit.pipe(Effect.andThen(Effect.suspend(commitAndContinue)))
|
|
181
183
|
)
|
|
182
184
|
})
|
|
183
|
-
return
|
|
185
|
+
return internalRuntimeProtocol.provideMachineRuntime(loop, context.scope)
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
188
|
|
|
@@ -207,7 +209,7 @@ const makeInvokingCompiledDrain = (
|
|
|
207
209
|
machine: Machine.Any,
|
|
208
210
|
checkInitialFinal: boolean
|
|
209
211
|
): (
|
|
210
|
-
context:
|
|
212
|
+
context: internalRuntimeProtocol.CompiledProcessContext<any, any>
|
|
211
213
|
) => Effect.Effect<Option.Option<any>, any, any> => {
|
|
212
214
|
const executionPlan = ExecutionPlan.compileExecutionPlan(machine)
|
|
213
215
|
return (context) => {
|
|
@@ -238,7 +240,7 @@ const makeInvokingCompiledDrain = (
|
|
|
238
240
|
}
|
|
239
241
|
|
|
240
242
|
const message = pending.value
|
|
241
|
-
const acknowledged =
|
|
243
|
+
const acknowledged = internalRuntimeProtocol.isAcknowledgedMessage(message)
|
|
242
244
|
const event = acknowledged ? message.event : message
|
|
243
245
|
const before = current
|
|
244
246
|
|
|
@@ -364,7 +366,7 @@ const makeInvokingCompiledDrain = (
|
|
|
364
366
|
execution.initialized = true
|
|
365
367
|
return starting === undefined ? loop : starting.pipe(Effect.andThen(loop))
|
|
366
368
|
}
|
|
367
|
-
return
|
|
369
|
+
return internalRuntimeProtocol.provideMachineRuntime(Effect.suspend(initialize), scope)
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
|
|
@@ -383,12 +385,12 @@ const makeProcessLogic: <
|
|
|
383
385
|
>(
|
|
384
386
|
machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits>,
|
|
385
387
|
entry: ProcessEntry<States, Input>
|
|
386
|
-
) =>
|
|
388
|
+
) => internalRuntimeProtocol.ProcessLogic<
|
|
387
389
|
Machine.Snapshot<States>,
|
|
388
390
|
Machine.EventOf<Events>,
|
|
389
391
|
E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError,
|
|
390
392
|
ExcludeCompatibleRuntime<
|
|
391
|
-
Exclude<ExecutionServices<InitialR | R>,
|
|
393
|
+
Exclude<ExecutionServices<InitialR | R>, internalRuntimeProtocol.MachineRuntime>,
|
|
392
394
|
Machine.EventOf<Events>,
|
|
393
395
|
Machine.EmittedEventOf<Emits>
|
|
394
396
|
>,
|
|
@@ -421,7 +423,7 @@ const makeProcessLogic: <
|
|
|
421
423
|
const initialArgs = entry._tag === "Initial" ? entry.args : []
|
|
422
424
|
const compiledInitial = entry._tag === "Initial" ? executionPlan.initial : undefined
|
|
423
425
|
const makeCompiledInitial = compiledInitial === undefined ? undefined : (
|
|
424
|
-
scope:
|
|
426
|
+
scope: internalRuntimeProtocol.ProcessScope<Machine.EventOf<Events>>
|
|
425
427
|
) => {
|
|
426
428
|
try {
|
|
427
429
|
const planned = compiledInitial(initialArgs, scope)
|
|
@@ -448,10 +450,10 @@ const makeProcessLogic: <
|
|
|
448
450
|
}
|
|
449
451
|
}
|
|
450
452
|
const makeInitial = (
|
|
451
|
-
scope:
|
|
453
|
+
scope: internalRuntimeProtocol.ProcessScope<Machine.EventOf<Events>>
|
|
452
454
|
) =>
|
|
453
455
|
compiledInitial === undefined
|
|
454
|
-
?
|
|
456
|
+
? internalRuntimeProtocol.provideMachineRuntime(
|
|
455
457
|
internalPlanner.planInitial(internalPlanner.withMachineReferences(machine, scope), ...initialArgs).pipe(
|
|
456
458
|
Effect.flatMap((planned) => {
|
|
457
459
|
scope.inspectInitial(planned.initialEntryPaths, planned.microsteps)
|
|
@@ -495,10 +497,13 @@ const makeProcessLogic: <
|
|
|
495
497
|
},
|
|
496
498
|
initial: (scope) =>
|
|
497
499
|
entry._tag === "Resume"
|
|
498
|
-
?
|
|
500
|
+
? internalRuntimeProtocol.provideMachineRuntime(
|
|
501
|
+
Serialization.normalizeSnapshotEffect(machine, entry.snapshot),
|
|
502
|
+
scope
|
|
503
|
+
)
|
|
499
504
|
: makeInitial(scope).pipe(Effect.map((initialized) => initialized.state)),
|
|
500
505
|
run: (context) =>
|
|
501
|
-
|
|
506
|
+
internalRuntimeProtocol.provideMachineRuntime(
|
|
502
507
|
Effect.gen(function*() {
|
|
503
508
|
const { completeMessage, pollMessage, receiveMessage, state, setState } = context
|
|
504
509
|
if (completeMessage === undefined || pollMessage === undefined || receiveMessage === undefined) {
|
|
@@ -523,12 +528,13 @@ const makeProcessLogic: <
|
|
|
523
528
|
// per iteration; every iteration still crosses Effect boundaries,
|
|
524
529
|
// so the Effect scheduler remains responsible for cooperative yield.
|
|
525
530
|
let configuration: Configuration.ActiveConfiguration | undefined
|
|
526
|
-
let pendingMessage: Option.Option<
|
|
531
|
+
let pendingMessage: Option.Option<internalRuntimeProtocol.ProcessMessage<Machine.EventOf<Events>>> = Option
|
|
532
|
+
.none()
|
|
527
533
|
let liveRuntime: Runtime<Machine.EventOf<Events>, Machine.EmittedEventOf<Emits>> | undefined
|
|
528
534
|
while (terminal === undefined) {
|
|
529
535
|
const message = Option.isSome(pendingMessage) ? pendingMessage.value : yield* receiveMessage
|
|
530
536
|
pendingMessage = Option.none()
|
|
531
|
-
const acknowledged =
|
|
537
|
+
const acknowledged = internalRuntimeProtocol.isAcknowledgedMessage(message)
|
|
532
538
|
const event = acknowledged ? message.event : message
|
|
533
539
|
const before = current
|
|
534
540
|
let planned
|
|
@@ -631,7 +637,8 @@ const makeProcessLogic: <
|
|
|
631
637
|
// As above, keep the normalized configuration only while this
|
|
632
638
|
// worker can continue draining an already queued batch.
|
|
633
639
|
configuration = undefined
|
|
634
|
-
let pendingMessage: Option.Option<
|
|
640
|
+
let pendingMessage: Option.Option<internalRuntimeProtocol.ProcessMessage<Machine.EventOf<Events>>> = Option
|
|
641
|
+
.none()
|
|
635
642
|
let liveRuntime: Runtime<Machine.EventOf<Events>, Machine.EmittedEventOf<Emits>> | undefined
|
|
636
643
|
|
|
637
644
|
// Match the compact non-invoke loop while retaining state-scoped
|
|
@@ -639,7 +646,7 @@ const makeProcessLogic: <
|
|
|
639
646
|
while (terminal === undefined) {
|
|
640
647
|
const message = Option.isSome(pendingMessage) ? pendingMessage.value : yield* receiveMessage
|
|
641
648
|
pendingMessage = Option.none()
|
|
642
|
-
const acknowledged =
|
|
649
|
+
const acknowledged = internalRuntimeProtocol.isAcknowledgedMessage(message)
|
|
643
650
|
const event = acknowledged ? message.event : message
|
|
644
651
|
const before = current
|
|
645
652
|
let planned
|
|
@@ -727,12 +734,12 @@ const makeProcessLogic: <
|
|
|
727
734
|
}),
|
|
728
735
|
context
|
|
729
736
|
)
|
|
730
|
-
}) as
|
|
737
|
+
}) as internalRuntimeProtocol.ProcessLogic<
|
|
731
738
|
Machine.Snapshot<States>,
|
|
732
739
|
Machine.EventOf<Events>,
|
|
733
740
|
E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError,
|
|
734
741
|
ExcludeCompatibleRuntime<
|
|
735
|
-
Exclude<ExecutionServices<InitialR | R>,
|
|
742
|
+
Exclude<ExecutionServices<InitialR | R>, internalRuntimeProtocol.MachineRuntime>,
|
|
736
743
|
Machine.EventOf<Events>,
|
|
737
744
|
Machine.EmittedEventOf<Emits>
|
|
738
745
|
>,
|
|
@@ -749,7 +756,7 @@ const makeProcessLogic: <
|
|
|
749
756
|
|
|
750
757
|
const initialProcessLogicCache = new WeakMap<
|
|
751
758
|
Machine.Any,
|
|
752
|
-
|
|
759
|
+
internalRuntimeProtocol.ProcessLogic<any, any, any, any, any, any>
|
|
753
760
|
>()
|
|
754
761
|
|
|
755
762
|
export const toProcessLogic: <
|
|
@@ -767,12 +774,12 @@ export const toProcessLogic: <
|
|
|
767
774
|
>(
|
|
768
775
|
machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits>,
|
|
769
776
|
...args: [...Machine.InputArgs<Input>]
|
|
770
|
-
) =>
|
|
777
|
+
) => internalRuntimeProtocol.ProcessLogic<
|
|
771
778
|
Machine.Snapshot<States>,
|
|
772
779
|
Machine.EventOf<Events>,
|
|
773
780
|
E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError,
|
|
774
781
|
ExcludeCompatibleRuntime<
|
|
775
|
-
Exclude<ExecutionServices<InitialR | R>,
|
|
782
|
+
Exclude<ExecutionServices<InitialR | R>, internalRuntimeProtocol.MachineRuntime>,
|
|
776
783
|
Machine.EventOf<Events>,
|
|
777
784
|
Machine.EmittedEventOf<Emits>
|
|
778
785
|
>,
|
|
@@ -805,7 +812,7 @@ export const toProcessLogic: <
|
|
|
805
812
|
const toResumedProcessLogic = (
|
|
806
813
|
machine: Machine.Any,
|
|
807
814
|
snapshot: Machine.Snapshot<any>
|
|
808
|
-
):
|
|
815
|
+
): internalRuntimeProtocol.ProcessLogic<any, any, any, any, any, any> =>
|
|
809
816
|
(makeProcessLogic as any)(machine, { _tag: "Resume", snapshot })
|
|
810
817
|
|
|
811
818
|
/** @internal Test-only runtime strategy selection for a fresh machine. */
|
|
@@ -813,7 +820,7 @@ export const startWithRuntimeStrategyForTesting = (
|
|
|
813
820
|
machine: Machine.Any,
|
|
814
821
|
strategy: internalRuntime.ProcessRuntimeStrategy,
|
|
815
822
|
...args: ReadonlyArray<unknown>
|
|
816
|
-
): Effect.Effect<
|
|
823
|
+
): Effect.Effect<internalRuntimeProtocol.MachineRef<any, any, any, any>, any, any> =>
|
|
817
824
|
internalRuntime.startProcessWithStrategyForTesting(
|
|
818
825
|
(toProcessLogic as any)(machine, ...args),
|
|
819
826
|
strategy,
|
|
@@ -825,7 +832,7 @@ export const prepareWithRuntimeStrategyForTesting = (
|
|
|
825
832
|
machine: Machine.Any,
|
|
826
833
|
strategy: internalRuntime.ProcessRuntimeStrategy,
|
|
827
834
|
...args: ReadonlyArray<unknown>
|
|
828
|
-
): Effect.Effect<
|
|
835
|
+
): Effect.Effect<internalRuntimeProtocol.PreparedProcess<any, any, any, any, any, any, any>, any, any> =>
|
|
829
836
|
internalRuntime.prepareProcessWithStrategyForTesting(
|
|
830
837
|
(toProcessLogic as any)(machine, ...args),
|
|
831
838
|
strategy,
|
|
@@ -837,7 +844,7 @@ export const resumeWithRuntimeStrategyForTesting = (
|
|
|
837
844
|
machine: Machine.Any,
|
|
838
845
|
snapshot: Machine.Snapshot<any>,
|
|
839
846
|
strategy: internalRuntime.ProcessRuntimeStrategy
|
|
840
|
-
): Effect.Effect<
|
|
847
|
+
): Effect.Effect<internalRuntimeProtocol.MachineRef<any, any, any, any>, any, any> =>
|
|
841
848
|
internalRuntime.startProcessWithStrategyForTesting(
|
|
842
849
|
toResumedProcessLogic(machine, snapshot),
|
|
843
850
|
strategy,
|
|
@@ -860,7 +867,7 @@ export const start: <
|
|
|
860
867
|
machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits>,
|
|
861
868
|
...args: [...Machine.InputArgs<Input>]
|
|
862
869
|
) => Effect.Effect<
|
|
863
|
-
|
|
870
|
+
internalRuntimeProtocol.MachineRef<
|
|
864
871
|
Machine.Snapshot<States>,
|
|
865
872
|
Machine.EventOf<Events>,
|
|
866
873
|
| E
|
|
@@ -878,7 +885,7 @@ export const start: <
|
|
|
878
885
|
| StartupError
|
|
879
886
|
| StoppedError,
|
|
880
887
|
ExcludeCompatibleRuntime<
|
|
881
|
-
Exclude<ExecutionServices<InitialR | R>,
|
|
888
|
+
Exclude<ExecutionServices<InitialR | R>, internalRuntimeProtocol.MachineRuntime>,
|
|
882
889
|
Machine.EventOf<Events>,
|
|
883
890
|
Machine.EmittedEventOf<Emits>
|
|
884
891
|
>
|
|
@@ -904,7 +911,7 @@ export const prepare: <
|
|
|
904
911
|
machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits>,
|
|
905
912
|
...args: [...Machine.InputArgs<Input>]
|
|
906
913
|
) => Effect.Effect<
|
|
907
|
-
|
|
914
|
+
internalRuntimeProtocol.PreparedProcess<
|
|
908
915
|
Machine.Snapshot<States>,
|
|
909
916
|
Machine.EventOf<Events>,
|
|
910
917
|
| E
|
|
@@ -922,7 +929,7 @@ export const prepare: <
|
|
|
922
929
|
| StartupError
|
|
923
930
|
| StoppedError,
|
|
924
931
|
ExcludeCompatibleRuntime<
|
|
925
|
-
Exclude<ExecutionServices<InitialR | R>,
|
|
932
|
+
Exclude<ExecutionServices<InitialR | R>, internalRuntimeProtocol.MachineRuntime>,
|
|
926
933
|
Machine.EventOf<Events>,
|
|
927
934
|
Machine.EmittedEventOf<Emits>
|
|
928
935
|
>
|
|
@@ -949,7 +956,7 @@ export const resume: <
|
|
|
949
956
|
machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits>,
|
|
950
957
|
snapshot: Machine.Snapshot<States>
|
|
951
958
|
) => Effect.Effect<
|
|
952
|
-
|
|
959
|
+
internalRuntimeProtocol.MachineRef<
|
|
953
960
|
Machine.Snapshot<States>,
|
|
954
961
|
Machine.EventOf<Events>,
|
|
955
962
|
E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError,
|
|
@@ -957,7 +964,7 @@ export const resume: <
|
|
|
957
964
|
>,
|
|
958
965
|
MachineSchemaDecodeError,
|
|
959
966
|
ExcludeCompatibleRuntime<
|
|
960
|
-
Exclude<ExecutionServices<R>,
|
|
967
|
+
Exclude<ExecutionServices<R>, internalRuntimeProtocol.MachineRuntime>,
|
|
961
968
|
Machine.EventOf<Events>,
|
|
962
969
|
Machine.EmittedEventOf<Emits>
|
|
963
970
|
>
|
|
@@ -82,7 +82,7 @@ const getBoundaryResultDecoder = (schema: Schema.Top): BoundaryResultDecoder =>
|
|
|
82
82
|
|
|
83
83
|
const MachineProtocolTypeId = Symbol.for("effect/Machine/protocol")
|
|
84
84
|
|
|
85
|
-
const getProtocolSchemas = (machine:
|
|
85
|
+
const getProtocolSchemas = (machine: object): MachineProtocolSchemas => {
|
|
86
86
|
const protocol = (machine as any)[MachineProtocolTypeId] as MachineProtocolSchemas | undefined
|
|
87
87
|
if (protocol === undefined) {
|
|
88
88
|
throw new Error("Machine protocol is unavailable")
|
|
@@ -90,7 +90,7 @@ const getProtocolSchemas = (machine: Machine.Any): MachineProtocolSchemas => {
|
|
|
90
90
|
return protocol
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const setProtocolSchemas = (machine:
|
|
93
|
+
const setProtocolSchemas = (machine: object, protocol: MachineProtocolSchemas): void => {
|
|
94
94
|
Object.defineProperty(machine, MachineProtocolTypeId, {
|
|
95
95
|
value: protocol,
|
|
96
96
|
enumerable: false
|
|
@@ -173,7 +173,7 @@ export const setProtocol = (machine: Machine.Any): void => {
|
|
|
173
173
|
})
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export const copyProtocol = (source:
|
|
176
|
+
export const copyProtocol = (source: object, target: object): void =>
|
|
177
177
|
setProtocolSchemas(target, getProtocolSchemas(source))
|
|
178
178
|
|
|
179
179
|
export const getEventName = (event: unknown): string | undefined =>
|