@typeonce/effect-machine 0.41.1 → 0.43.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.
Files changed (67) hide show
  1. package/README.md +31 -4
  2. package/dist/Machine.d.ts +159 -27
  3. package/dist/Machine.d.ts.map +1 -1
  4. package/dist/Machine.js +20 -6
  5. package/dist/Machine.js.map +1 -1
  6. package/dist/internal/machine/atom.d.ts +3 -7
  7. package/dist/internal/machine/atom.d.ts.map +1 -1
  8. package/dist/internal/machine/atom.js +153 -87
  9. package/dist/internal/machine/atom.js.map +1 -1
  10. package/dist/internal/machine/childRegistry.d.ts +7 -0
  11. package/dist/internal/machine/childRegistry.d.ts.map +1 -1
  12. package/dist/internal/machine/childRegistry.js +7 -0
  13. package/dist/internal/machine/childRegistry.js.map +1 -1
  14. package/dist/internal/machine/invocation.d.ts.map +1 -1
  15. package/dist/internal/machine/invocation.js +13 -2
  16. package/dist/internal/machine/invocation.js.map +1 -1
  17. package/dist/internal/machine/invocationDefinition.d.ts +7 -0
  18. package/dist/internal/machine/invocationDefinition.d.ts.map +1 -1
  19. package/dist/internal/machine/invocationDefinition.js +16 -0
  20. package/dist/internal/machine/invocationDefinition.js.map +1 -1
  21. package/dist/internal/machine/machine.d.ts.map +1 -1
  22. package/dist/internal/machine/machine.js +69 -6
  23. package/dist/internal/machine/machine.js.map +1 -1
  24. package/dist/internal/machine/plannedSnapshot.d.ts +30 -0
  25. package/dist/internal/machine/plannedSnapshot.d.ts.map +1 -0
  26. package/dist/internal/machine/plannedSnapshot.js +103 -0
  27. package/dist/internal/machine/plannedSnapshot.js.map +1 -0
  28. package/dist/internal/machine/planner.d.ts +5 -0
  29. package/dist/internal/machine/planner.d.ts.map +1 -1
  30. package/dist/internal/machine/planner.js +1 -1
  31. package/dist/internal/machine/planner.js.map +1 -1
  32. package/dist/internal/machine/runtime.d.ts +5 -4
  33. package/dist/internal/machine/runtime.d.ts.map +1 -1
  34. package/dist/internal/machine/runtime.js +60 -15
  35. package/dist/internal/machine/runtime.js.map +1 -1
  36. package/dist/internal/machine/runtimeCompiled.js +2 -2
  37. package/dist/internal/machine/runtimeCompiled.js.map +1 -1
  38. package/dist/internal/machine/runtimeGeneric.js +1 -1
  39. package/dist/internal/machine/runtimeGeneric.js.map +1 -1
  40. package/dist/internal/machine/runtimeProtocol.d.ts +2 -1
  41. package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -1
  42. package/dist/internal/machine/runtimeProtocol.js +2 -2
  43. package/dist/internal/machine/runtimeProtocol.js.map +1 -1
  44. package/dist/testing/MachineTest.d.ts +2 -2
  45. package/dist/testing/MachineTest.js +2 -2
  46. package/dist/unstable/reactivity/AtomMachine.d.ts +95 -19
  47. package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
  48. package/dist/unstable/reactivity/AtomMachine.js +13 -7
  49. package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
  50. package/docs/agent-guide.md +28 -5
  51. package/docs/effect-atom-react.md +262 -14
  52. package/docs/machine-review.md +18 -4
  53. package/package.json +1 -1
  54. package/src/Machine.ts +229 -32
  55. package/src/internal/machine/atom.ts +305 -113
  56. package/src/internal/machine/childRegistry.ts +9 -0
  57. package/src/internal/machine/invocation.ts +17 -2
  58. package/src/internal/machine/invocationDefinition.ts +19 -0
  59. package/src/internal/machine/machine.ts +65 -2
  60. package/src/internal/machine/plannedSnapshot.ts +113 -0
  61. package/src/internal/machine/planner.ts +1 -1
  62. package/src/internal/machine/runtime.ts +101 -28
  63. package/src/internal/machine/runtimeCompiled.ts +2 -2
  64. package/src/internal/machine/runtimeGeneric.ts +1 -1
  65. package/src/internal/machine/runtimeProtocol.ts +4 -2
  66. package/src/testing/MachineTest.ts +2 -2
  67. package/src/unstable/reactivity/AtomMachine.ts +104 -20
package/dist/Machine.js CHANGED
@@ -811,6 +811,9 @@ export const waitFor = internal.waitFor;
811
811
  * `prepared.start`. Ordinary callers can continue to use {@link start}, which
812
812
  * starts directly and does not allocate the prepared lifecycle boundary.
813
813
  *
814
+ * `prepared.start` is one-shot and scoped: the `Scope` that first evaluates it
815
+ * owns the machine, and closing that `Scope` is equivalent to `ref.stop`.
816
+ *
814
817
  * ```ts
815
818
  * const prepared = yield* Machine.prepare(machine)
816
819
  *
@@ -827,7 +830,7 @@ export const waitFor = internal.waitFor;
827
830
  */
828
831
  export const prepare = internal.prepare;
829
832
  /**
830
- * Starts a machine.
833
+ * Starts a machine owned by the current `Scope`.
831
834
  *
832
835
  * **When to use**
833
836
  *
@@ -841,6 +844,13 @@ export const prepare = internal.prepare;
841
844
  * publishes the new state, delivers emitted events, and then starts invokes
842
845
  * for entered states.
843
846
  *
847
+ * The machine is a scoped resource, like `Effect.forkScoped`. Closing the
848
+ * `Scope` is equivalent to `ref.stop`: active invocations are interrupted,
849
+ * owned children stop, the snapshot becomes `stopped`, and later sends fail
850
+ * with `StoppedError`. An earlier `ref.stop` or terminal completion leaves the
851
+ * finalizer with nothing to do. Own a `Scope` explicitly, for example with
852
+ * `Scope.make` and `Scope.provide`, when the machine must outlive the caller.
853
+ *
844
854
  * **Gotchas**
845
855
  *
846
856
  * The returned handle's `send` operation only enqueues events. Transition
@@ -867,10 +877,10 @@ export const prepare = internal.prepare;
867
877
  * Idle: {}
868
878
  * }
869
879
  * })
870
- * const state = Effect.gen(function*() {
880
+ * const state = Effect.scoped(Effect.gen(function*() {
871
881
  * const ref = yield* Machine.start(machine)
872
882
  * return yield* ref.state
873
- * })
883
+ * }))
874
884
  * ```
875
885
  *
876
886
  * @see {@link plan} for inspecting the same transition plan without executing it.
@@ -880,10 +890,14 @@ export const prepare = internal.prepare;
880
890
  */
881
891
  export const start = internal.start;
882
892
  /**
883
- * Starts a fresh managed runtime from a decoded logical snapshot.
893
+ * Starts a fresh managed runtime from a decoded logical snapshot, owned by the
894
+ * current `Scope`.
884
895
  *
885
896
  * **Details**
886
897
  *
898
+ * The resumed machine has the same scoped lifetime as {@link start}: closing
899
+ * the `Scope` is equivalent to `ref.stop`.
900
+ *
887
901
  * `resume` validates and normalizes the supplied snapshot before publishing it
888
902
  * as the first state. It does not call the machine's initial function, replay
889
903
  * entry or transition actions, re-deliver raised or emitted events, or
@@ -922,12 +936,12 @@ export const start = internal.start;
922
936
  * Idle: {}
923
937
  * }
924
938
  * })
925
- * const resumed = Effect.gen(function*() {
939
+ * const resumed = Effect.scoped(Effect.gen(function*() {
926
940
  * const initial = yield* Machine.planInitial(machine)
927
941
  * const encoded = yield* Machine.encodeSnapshot(machine, initial.state)
928
942
  * const snapshot = yield* Machine.decodeSnapshot(machine, encoded)
929
943
  * return yield* Machine.resume(machine, snapshot)
930
- * })
944
+ * }))
931
945
  * ```
932
946
  *
933
947
  * @see {@link decodeSnapshot} for the schema and transport boundary.
@@ -1 +1 @@
1
- {"version":3,"file":"Machine.js","sourceRoot":"","sources":["../src/Machine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAc9C,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAgBlE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAW,iBAAiB,CAAA;AAS/C,MAAM,YAAY,GAAG,wBAAwB,CAAA;AAE7C,MAAM,uBAAuB,GAA4C,QAAQ,CAAC,uBAAuB,CAAA;AAEzG;;;;;;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;AAmQxH,OAAO;AACL;;;;;;GAMG;AACH,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;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GASf,QAAQ,CAAC,MAAM,CAAA;AAEnB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAGlB,QAAQ,CAAC,SAAS,CAAA;AAEtB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAEyC,QAAQ,CAAC,KAAK,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAqBhB,QAAQ,CAAC,OAAO,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,OAAO,GA6DhB,QAAQ,CAAC,OAAO,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,MAAM,KAAK,GA6Dd,QAAQ,CAAC,KAAK,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,MAAM,MAAM,GAuDf,QAAQ,CAAC,MAAM,CAAA"}
@@ -12,11 +12,6 @@ import type * as Machine from "../../Machine.js";
12
12
  import type { Bound, ChildMachineAtom, MachineAtom } from "../../unstable/reactivity/AtomMachine.js";
13
13
  import type { EnsureExecutable } from "./readiness.js";
14
14
  import type { ExcludeCompatibleRuntime as ExcludeCompatibleMachineRuntime, IsAny } from "./requirements.js";
15
- declare const NotReadyError_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
- readonly _tag: "NotReadyError";
17
- } & Readonly<A>;
18
- export declare class NotReadyError extends NotReadyError_base {
19
- }
20
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 & {
21
16
  readonly _tag: "ChildNotActiveError";
22
17
  } & Readonly<A>;
@@ -34,6 +29,7 @@ type MachineRequirements<InitialR, R, Events, Emits> = ExcludeCompatibleMachineR
34
29
  type MachineResumeRequirements<R, Events, Emits> = ExcludeCompatibleMachineRuntime<Machine.ExecutionServices<R>, Events, Emits>;
35
30
  type MachineRuntimeError<E, R> = E | Machine.ActionError<R> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StoppedError;
36
31
  type MachineStartError<InitialE, E, InitialR, R, RuntimeError = never> = InitialE | E | Machine.ActionError<InitialR | R> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StartupError | Machine.StoppedError | RuntimeError;
32
+ export declare const isMachineAtom: (u: unknown) => u is MachineAtom<any, never, any, any, any, any>;
37
33
  type RefState<Ref> = Ref extends Machine.MachineRef<infer State, any, any, any, any> ? State : never;
38
34
  type RefError<Ref> = Ref extends Machine.MachineRef<any, any, infer Error, any, any> ? Error : never;
39
35
  type RefEmitted<Ref> = Ref extends Machine.MachineRef<any, any, any, any, infer Emitted> ? Emitted : never;
@@ -81,13 +77,13 @@ export declare const factory: any;
81
77
  export declare const resume: {
82
78
  <M extends Machine.Machine.Any>(machine: M & EnsureNoExternalRequirements<MachineResumeRequirementsOf<NoInfer<M>>> & EnsureMachineExecutable<NoInfer<M>> & Machine.Machine.RootCompatible<Machine.Machine.ParentEvents<NoInfer<M>>>, snapshot: Machine.Machine.Snapshot<Machine.Machine.States<M>>): ResumedMachineAtomOf<M, never>;
83
79
  };
84
- type FamilyBridge = MachineAtom<any, never, any, any, any, any> | ChildMachineAtom<any, any>;
80
+ type FamilyBridge = MachineAtom.Any | ChildMachineAtom.Any;
85
81
  type FamilyOptions = {
86
82
  readonly atoms: Readonly<Record<string, (bridge: FamilyBridge) => Atom.Atom<any>>>;
87
83
  readonly label?: (key: any, atomName: string) => string | undefined;
88
84
  };
89
85
  export declare const family: (machine: Machine.Machine.Any, options: FamilyOptions) => Readonly<Record<string, (key: any) => Atom.Atom<any>>>;
90
- export declare const familyChild: (parent: MachineAtom<any, never, any, any, any, any> | ChildMachineAtom<any, any>, options: FamilyOptions & {
86
+ export declare const familyChild: (parent: FamilyBridge, options: FamilyOptions & {
91
87
  readonly child: (key: any) => Machine.ChildMachine.Any;
92
88
  }) => Readonly<Record<string, (key: any) => Atom.Atom<any>>>;
93
89
  export declare const bind: <Services, RuntimeError>(runtime: Atom.AtomRuntime<Services, RuntimeError>) => Bound<Services, RuntimeError>;
@@ -1 +1 @@
1
- {"version":3,"file":"atom.d.ts","sourceRoot":"","sources":["../../../src/internal/machine/atom.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAEpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,KAAK,EAAE,wBAAwB,IAAI,+BAA+B,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;;;;AAG3G,qBAAa,aAAc,SAAQ,kBAAiC;CAAG;;;;AAEvE,qBAAa,mBAAoB,SAAQ,yBAAwC;IAC/E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB,CAAC;CAAG;AAEL,KAAK,yBAAyB,GAAG,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,YAAY,CAAA;AAExE,KAAK,oB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  import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
13
13
  import * as Stream from "effect/Stream";
14
14
  import * as internalMachine from "./machine.js";
15
+ import * as PlannedSnapshot from "./plannedSnapshot.js";
15
16
  import * as Topology from "./topology.js";
16
- export class NotReadyError extends Data.TaggedError("NotReadyError") {
17
- }
18
17
  export class ChildNotActiveError extends Data.TaggedError("ChildNotActiveError") {
19
18
  }
20
19
  const ExternalRequirementsTypeId = "~effect/reactivity/AtomMachine/ExternalRequirements";
21
20
  const preparedByMachineAtom = new WeakMap();
22
21
  const machineByMachineAtom = new WeakMap();
22
+ export const isMachineAtom = (u) => typeof u === "object" && u !== null && machineByMachineAtom.has(u);
23
23
  // This follows Atom.family, but cleanup is generation-aware. A finalizer for a
24
24
  // collected value must not remove a newer value installed for the same key.
25
25
  const retainedFamily = (makeValue) => {
@@ -51,6 +51,40 @@ const retainedFamily = (makeValue) => {
51
51
  const runMachineAtomEffect = (get, start) => Effect.scoped(Effect.acquireRelease(start, (ref) => ref.stop).pipe(Effect.tap((ref) => Effect.sync(() => get.setSelf(AsyncResult.success(ref)))), Effect.flatMap(() => Effect.never)));
52
52
  const startPreparedMachineAtomEffect = (get, prepared) => runMachineAtomEffect(get, get.result(prepared).pipe(Effect.flatMap((prepared) => prepared.start)));
53
53
  const resumeMachineAtomEffect = (get, machine, snapshot) => runMachineAtomEffect(get, internalMachine.resume(machine, snapshot));
54
+ // Effect stores the server read on the atom without exposing it in `Atom`'s
55
+ // type. This is the only erased boundary of the server protocol.
56
+ const readServerValue = (atom, get) => Atom.ServerValueTypeId in atom ? atom[Atom.ServerValueTypeId](get) : get(atom);
57
+ // React requires a referentially stable server snapshot, but Effect does not
58
+ // cache server reads. A server value is a pure function of the bridge plan and
59
+ // of the server values it reads, so each atom memoizes its latest result on the
60
+ // identity of those inputs. Unchanged inputs therefore return the same value
61
+ // for every read and registry, and derived atoms stay stable because their
62
+ // sources are.
63
+ const stableServerValue = (read, compute) => {
64
+ let memo;
65
+ return (get) => {
66
+ const inputs = read(get);
67
+ if (memo === undefined ||
68
+ memo.inputs.length !== inputs.length ||
69
+ !memo.inputs.every((input, index) => Object.is(input, inputs[index]))) {
70
+ memo = { inputs, value: compute(...inputs) };
71
+ }
72
+ return memo.value;
73
+ };
74
+ };
75
+ // Plans are computed on the first server read, at most once per bridge, so
76
+ // client starts never pay for them.
77
+ const lazyPlan = (plan) => {
78
+ let planned;
79
+ return () => {
80
+ if (planned === undefined)
81
+ planned = { value: plan() };
82
+ return planned.value;
83
+ };
84
+ };
85
+ // Planned snapshots are erased to the machine's snapshot schema; the bridge
86
+ // that owns a plan types its state, error and output.
87
+ const plannedSnapshot = (planned) => planned.snapshot;
54
88
  export const emissions = (self) => {
55
89
  const prepared = preparedByMachineAtom.get(self);
56
90
  if (prepared === undefined) {
@@ -102,6 +136,64 @@ export const childEmissions = (self) => Atom.toStreamResult(self.ref).pipe(Strea
102
136
  onNone: () => Stream.empty,
103
137
  onSome: (ref) => ref.emissions
104
138
  })));
139
+ // A write context exposes no registry, but a read through it does. Commands
140
+ // written before a machine is ready wait on that registry for the ref.
141
+ const registryAtom = Atom.readable((get) => get.registry).pipe(Atom.keepAlive);
142
+ const drainCommands = (queue) => Effect.suspend(() => {
143
+ const next = queue.pending.shift();
144
+ if (next === undefined) {
145
+ queue.draining = false;
146
+ return Effect.void;
147
+ }
148
+ return Effect.andThen(next, drainCommands(queue));
149
+ });
150
+ const getCommandQueue = (queues, registry) => {
151
+ let queue = queues.get(registry);
152
+ if (queue === undefined) {
153
+ queue = { pending: [], draining: false };
154
+ queues.set(registry, queue);
155
+ }
156
+ return queue;
157
+ };
158
+ /**
159
+ * Builds a command atom over a bridge ref.
160
+ *
161
+ * A write runs the command at once when the ref is ready and no earlier
162
+ * command is held. Otherwise the command is held until the ref settles, the
163
+ * write result stays waiting, and it settles with the command exit or with the
164
+ * startup failure.
165
+ */
166
+ const makeCommandAtom = (ref, queues, command) => Atom.writable((get) => {
167
+ const current = AsyncResult.map(get(ref), () => undefined);
168
+ const queue = queues.get(get.registry);
169
+ if (queue === undefined || !queue.draining) {
170
+ return current;
171
+ }
172
+ return Option.getOrElse(Option.map(get.self(), AsyncResult.waiting), () => AsyncResult.initial(true));
173
+ }, (ctx, value) => {
174
+ const current = ctx.get(ref);
175
+ const registry = ctx.get(registryAtom);
176
+ const queue = getCommandQueue(queues, registry);
177
+ if (AsyncResult.isInitial(current) || queue.draining) {
178
+ ctx.setSelf(AsyncResult.initial(true));
179
+ queue.pending.push(AtomRegistry.getResult(registry, ref).pipe(Effect.flatMap((ready) => command(ready, value)), Effect.exit, Effect.map((exit) => {
180
+ const result = AsyncResult.fromExit(exit);
181
+ ctx.setSelf(queue.pending.length === 0 ? result : AsyncResult.waiting(result));
182
+ })));
183
+ if (!queue.draining) {
184
+ queue.draining = true;
185
+ Effect.runFork(drainCommands(queue));
186
+ }
187
+ }
188
+ else if (AsyncResult.isFailure(current)) {
189
+ ctx.setSelf(AsyncResult.map(current, () => undefined));
190
+ }
191
+ else {
192
+ Effect.runCallback(command(current.value, value), {
193
+ onExit: (exit) => ctx.setSelf(AsyncResult.fromExit(exit))
194
+ });
195
+ }
196
+ }).pipe(Atom.withServerValueInitial);
105
197
  const makeRuntimeResultAtom = (snapshot) => Atom.readable((get) => {
106
198
  const current = get(snapshot);
107
199
  if (AsyncResult.isInitial(current)) {
@@ -122,7 +214,9 @@ const makeRuntimeResultAtom = (snapshot) => Atom.readable((get) => {
122
214
  return AsyncResult.success(current.value.state, {
123
215
  waiting: current.waiting
124
216
  });
125
- }).pipe(Atom.withEquality(Equal.equals));
217
+ }).pipe(Atom.withEquality(Equal.equals),
218
+ // A planned snapshot is never an error, so its state is the server result.
219
+ Atom.withServerValue(stableServerValue((get) => [readServerValue(snapshot, get)], (current) => AsyncResult.map(current, (current) => current.state))));
126
220
  const makeChildRuntimeResultAtom = (snapshot) => Atom.readable((get) => {
127
221
  const current = get(snapshot);
128
222
  if (AsyncResult.isInitial(current)) {
@@ -152,7 +246,7 @@ const makeChildRuntimeResultAtom = (snapshot) => Atom.readable((get) => {
152
246
  return AsyncResult.success(Option.some(current.value.value.state), {
153
247
  waiting: current.waiting
154
248
  });
155
- }).pipe(Atom.withEquality(Equal.equals));
249
+ }).pipe(Atom.withEquality(Equal.equals), Atom.withServerValue(stableServerValue((get) => [readServerValue(snapshot, get)], (current) => AsyncResult.map(current, Option.map((current) => current.state)))));
156
250
  const makeChildRefAtom = (parentRef, child) => Atom.readable((get) => {
157
251
  const parent = get(parentRef);
158
252
  if (AsyncResult.isInitial(parent)) {
@@ -172,8 +266,8 @@ const makeChildRefAtom = (parentRef, child) => Atom.readable((get) => {
172
266
  const cancel = Effect.runCallback(Effect.yieldNow.pipe(Effect.andThen(handle.childChanges(child).pipe(Stream.runForEach((ref) => Effect.sync(() => get.setSelf(AsyncResult.success(ref))))))));
173
267
  get.addFinalizer(cancel);
174
268
  return AsyncResult.success(current);
175
- });
176
- const makeChildFromRefAtom = (ref, descriptor) => {
269
+ }).pipe(Atom.withServerValueInitial);
270
+ const makeChildFromRefAtom = (ref, descriptor, plan) => {
177
271
  const snapshot = Atom.readable((get) => {
178
272
  const result = get(ref);
179
273
  if (AsyncResult.isInitial(result)) {
@@ -192,40 +286,19 @@ const makeChildFromRefAtom = (ref, descriptor) => {
192
286
  const cancel = Effect.runCallback(handle.changes.pipe(Stream.runForEach((snapshot) => Effect.sync(() => get.setSelf(AsyncResult.success(Option.some(snapshot)))))));
193
287
  get.addFinalizer(cancel);
194
288
  return AsyncResult.success(Option.some(Effect.runSync(handle.snapshot)));
195
- });
196
- const send = Atom.writable((get) => AsyncResult.map(get(ref), () => undefined), (ctx, event) => {
197
- const result = ctx.get(ref);
198
- if (AsyncResult.isInitial(result)) {
199
- ctx.setSelf(AsyncResult.fail(new NotReadyError()));
200
- }
201
- else if (AsyncResult.isFailure(result)) {
202
- ctx.setSelf(AsyncResult.map(result, () => undefined));
203
- }
204
- else if (Option.isNone(result.value)) {
205
- ctx.setSelf(AsyncResult.fail(new ChildNotActiveError({ id: descriptor.id })));
206
- }
207
- else {
208
- Effect.runCallback(result.value.value.send(event), {
209
- onExit: (exit) => ctx.setSelf(AsyncResult.fromExit(exit))
210
- });
211
- }
212
- });
213
- const stop = Atom.writable((get) => AsyncResult.map(get(ref), () => undefined), (ctx) => {
214
- const result = ctx.get(ref);
215
- if (AsyncResult.isInitial(result)) {
216
- ctx.setSelf(AsyncResult.fail(new NotReadyError()));
217
- }
218
- else if (AsyncResult.isFailure(result)) {
219
- ctx.setSelf(AsyncResult.map(result, () => undefined));
220
- }
221
- else if (Option.isNone(result.value)) {
222
- ctx.setSelf(AsyncResult.fail(new ChildNotActiveError({ id: descriptor.id })));
223
- }
224
- else {
225
- Effect.runCallback(result.value.value.stop);
226
- }
227
- });
228
- const child = makeChildSelector(ref);
289
+ }).pipe(Atom.withServerValue(stableServerValue(() => [], () => {
290
+ const planned = plan();
291
+ return planned === undefined
292
+ ? AsyncResult.initial(true)
293
+ : AsyncResult.success(Option.map(planned, (plannedSnapshot)), { waiting: true });
294
+ })));
295
+ const commands = new WeakMap();
296
+ const activeChild = (current) => Option.isSome(current)
297
+ ? Effect.succeed(current.value)
298
+ : Effect.fail(new ChildNotActiveError({ id: descriptor.id }));
299
+ const send = makeCommandAtom(ref, commands, (current, event) => Effect.flatMap(activeChild(current), (child) => child.send(event)));
300
+ const stop = makeCommandAtom(ref, commands, (current, _) => Effect.flatMap(activeChild(current), (child) => child.stop));
301
+ const child = makeChildSelector(ref, plan);
229
302
  return {
230
303
  ref,
231
304
  snapshot,
@@ -235,7 +308,7 @@ const makeChildFromRefAtom = (ref, descriptor) => {
235
308
  child
236
309
  };
237
310
  };
238
- const makeChildSelector = (parentRef) => {
311
+ const makeChildSelector = (parentRef, parentPlan) => {
239
312
  const byMachine = new WeakMap();
240
313
  return (descriptor) => {
241
314
  let family = byMachine.get(descriptor.machine);
@@ -243,7 +316,12 @@ const makeChildSelector = (parentRef) => {
243
316
  const machine = descriptor.machine;
244
317
  const atoms = Atom.family((id) => {
245
318
  const child = internalMachine.child(id, machine);
246
- return makeChildFromRefAtom(makeChildRefAtom(parentRef, child), child);
319
+ return makeChildFromRefAtom(makeChildRefAtom(parentRef, child), child, lazyPlan(() => {
320
+ const parent = parentPlan();
321
+ return parent === undefined || Option.isNone(parent)
322
+ ? parent
323
+ : PlannedSnapshot.planInvokedChild(parent.value, child);
324
+ }));
247
325
  });
248
326
  family = (id) => atoms(id);
249
327
  byMachine.set(machine, family);
@@ -251,7 +329,8 @@ const makeChildSelector = (parentRef) => {
251
329
  return family(descriptor.id);
252
330
  };
253
331
  };
254
- const makeFromRefAtom = (ref, machine) => {
332
+ const makeFromRefAtom = (liveRef, machine, plan) => {
333
+ const ref = Atom.withServerValueInitial(liveRef);
255
334
  const snapshot = Atom.readable((get) => {
256
335
  const result = get(ref);
257
336
  if (AsyncResult.isInitial(result)) {
@@ -272,35 +351,20 @@ const makeFromRefAtom = (ref, machine) => {
272
351
  return AsyncResult.success(current, {
273
352
  waiting: current.status === "active"
274
353
  });
275
- });
276
- const send = Atom.writable((get) => AsyncResult.map(get(ref), () => undefined), (ctx, event) => {
277
- const result = ctx.get(ref);
278
- if (AsyncResult.isInitial(result)) {
279
- ctx.setSelf(AsyncResult.fail(new NotReadyError()));
280
- }
281
- else if (AsyncResult.isFailure(result)) {
282
- ctx.setSelf(AsyncResult.map(result, () => undefined));
283
- }
284
- else {
285
- Effect.runCallback(result.value.send(event), {
286
- onExit: (exit) => ctx.setSelf(AsyncResult.fromExit(exit))
287
- });
288
- }
289
- });
290
- const stop = Atom.writable((get) => AsyncResult.map(get(ref), () => undefined), (ctx) => {
291
- const result = ctx.get(ref);
292
- if (AsyncResult.isInitial(result)) {
293
- ctx.setSelf(AsyncResult.fail(new NotReadyError()));
294
- }
295
- else if (AsyncResult.isFailure(result)) {
296
- ctx.setSelf(AsyncResult.map(result, () => undefined));
297
- }
298
- else {
299
- Effect.runCallback(result.value.stop);
300
- }
301
- });
354
+ }).pipe(Atom.withServerValue(stableServerValue(() => [], () => {
355
+ const planned = plan();
356
+ return planned === undefined
357
+ ? AsyncResult.initial(true)
358
+ : AsyncResult.success(plannedSnapshot(planned), { waiting: true });
359
+ })));
360
+ const commands = new WeakMap();
361
+ const send = makeCommandAtom(ref, commands, (handle, event) => handle.send(event));
362
+ const stop = makeCommandAtom(ref, commands, (handle, _) => handle.stop);
302
363
  const optionalRef = Atom.mapResult(ref, Option.some);
303
- const child = makeChildSelector(optionalRef);
364
+ const child = makeChildSelector(optionalRef, () => {
365
+ const planned = plan();
366
+ return planned === undefined ? undefined : Option.some(planned);
367
+ });
304
368
  const result = {
305
369
  ref,
306
370
  snapshot,
@@ -314,6 +378,8 @@ const makeFromRefAtom = (ref, machine) => {
314
378
  };
315
379
  const selectValueByPath = (snapshot, path) => Topology.getSnapshotByPath(snapshot, path).pipe(Option.map((snapshot) => snapshot.value));
316
380
  const selectSnapshotByPath = (snapshot, path) => Topology.getSnapshotByPath(snapshot, path);
381
+ // Selectors project the bridge result live and its planned result on the server.
382
+ const mapResultSelector = (source, f) => Atom.mapResult(source, f).pipe(Atom.withEquality(Equal.equals), Atom.withServerValue(stableServerValue((get) => [readServerValue(source, get)], (current) => AsyncResult.map(current, f))));
317
383
  const selectorsByBridge = new WeakMap();
318
384
  const cachedSelector = (bridge, kind, path, make) => {
319
385
  let selectorsByKind = selectorsByBridge.get(bridge);
@@ -334,12 +400,12 @@ const cachedSelector = (bridge, kind, path, make) => {
334
400
  selectorsByPath.set(path, selector);
335
401
  return selector;
336
402
  };
337
- export const select = (self, path) => cachedSelector(self, "select", path, () => Atom.mapResult(self.result, (snapshot) => selectValueByPath(snapshot, path)).pipe(Atom.withEquality(Equal.equals)));
338
- export const selectSnapshot = (self, path) => cachedSelector(self, "selectSnapshot", path, () => Atom.mapResult(self.result, (snapshot) => selectSnapshotByPath(snapshot, path)).pipe(Atom.withEquality(Equal.equals)));
339
- export const selectChild = (self, path) => cachedSelector(self, "selectChild", path, () => Atom.mapResult(self.result, Option.flatMap((snapshot) => selectValueByPath(snapshot, path))).pipe(Atom.withEquality(Equal.equals)));
340
- export const selectSnapshotChild = (self, path) => cachedSelector(self, "selectSnapshotChild", path, () => Atom.mapResult(self.result, Option.flatMap((snapshot) => selectSnapshotByPath(snapshot, path))).pipe(Atom.withEquality(Equal.equals)));
341
- export const matches = (self, path) => cachedSelector(self, "matches", path, () => Atom.mapResult(self.result, (snapshot) => Option.isSome(Topology.getSnapshotByPath(snapshot, path))).pipe(Atom.withEquality(Equal.equals)));
342
- export const matchesChild = (self, path) => cachedSelector(self, "matchesChild", path, () => Atom.mapResult(self.result, Option.exists((snapshot) => Option.isSome(Topology.getSnapshotByPath(snapshot, path)))).pipe(Atom.withEquality(Equal.equals)));
403
+ export const select = (self, path) => cachedSelector(self, "select", path, () => mapResultSelector(self.result, (snapshot) => selectValueByPath(snapshot, path)));
404
+ export const selectSnapshot = (self, path) => cachedSelector(self, "selectSnapshot", path, () => mapResultSelector(self.result, (snapshot) => selectSnapshotByPath(snapshot, path)));
405
+ export const selectChild = (self, path) => cachedSelector(self, "selectChild", path, () => mapResultSelector(self.result, Option.flatMap((snapshot) => selectValueByPath(snapshot, path))));
406
+ export const selectSnapshotChild = (self, path) => cachedSelector(self, "selectSnapshotChild", path, () => mapResultSelector(self.result, Option.flatMap((snapshot) => selectSnapshotByPath(snapshot, path))));
407
+ export const matches = (self, path) => cachedSelector(self, "matches", path, () => mapResultSelector(self.result, (snapshot) => Option.isSome(Topology.getSnapshotByPath(snapshot, path))));
408
+ export const matchesChild = (self, path) => cachedSelector(self, "matchesChild", path, () => mapResultSelector(self.result, Option.exists((snapshot) => Option.isSome(Topology.getSnapshotByPath(snapshot, path)))));
343
409
  export const can = (event) => {
344
410
  const byBridge = new WeakMap();
345
411
  return (self) => {
@@ -350,9 +416,7 @@ export const can = (event) => {
350
416
  const query = machine === undefined
351
417
  ? () => Effect.die(new Error("AtomMachine.can requires a machine atom created by AtomMachine"))
352
418
  : internalMachine.can(machine);
353
- const result = Atom.readable((get) => {
354
- const current = get(self.snapshot);
355
- const previous = get.self();
419
+ const evaluate = (current, input, previous) => {
356
420
  if (AsyncResult.isInitial(current)) {
357
421
  return AsyncResult.initial(current.waiting);
358
422
  }
@@ -371,7 +435,6 @@ export const can = (event) => {
371
435
  else if (current.value.status !== "active") {
372
436
  return AsyncResult.success(false, { waiting: current.waiting });
373
437
  }
374
- const input = Atom.isAtom(event) ? get(event) : event;
375
438
  const exit = Effect.runSyncExit(query(current.value.state, input));
376
439
  return exit._tag === "Success"
377
440
  ? AsyncResult.success(exit.value, { waiting: current.waiting })
@@ -379,7 +442,8 @@ export const can = (event) => {
379
442
  previous,
380
443
  waiting: current.waiting
381
444
  });
382
- }).pipe(Atom.withEquality(Equal.equals));
445
+ };
446
+ const result = Atom.readable((get) => evaluate(get(self.snapshot), Atom.isAtom(event) ? get(event) : event, get.self())).pipe(Atom.withEquality(Equal.equals), Atom.withServerValue(stableServerValue((get) => [readServerValue(self.snapshot, get), Atom.isAtom(event) ? readServerValue(event, get) : event], (current, input) => evaluate(current, input, Option.none()))));
383
447
  byBridge.set(self, result);
384
448
  return result;
385
449
  };
@@ -387,29 +451,31 @@ export const can = (event) => {
387
451
  export const make = ((machine, ...args) => {
388
452
  const prepared = Atom.make(() => internalMachine.prepare(machine, ...args));
389
453
  const ref = Atom.make((get) => startPreparedMachineAtomEffect(get, prepared));
390
- const result = makeFromRefAtom(ref, machine);
454
+ const result = makeFromRefAtom(ref, machine, lazyPlan(() => PlannedSnapshot.planStart(machine, args)));
391
455
  preparedByMachineAtom.set(result, prepared);
392
456
  return result;
393
457
  });
394
458
  export const factory = ((machine) => (...args) => make(machine, ...args));
395
459
  export const resume = ((machine, snapshot) => {
396
460
  const ref = Atom.make((get) => resumeMachineAtomEffect(get, machine, snapshot));
397
- return makeFromRefAtom(ref, machine);
461
+ return makeFromRefAtom(ref, machine, lazyPlan(() => PlannedSnapshot.planResume(machine, snapshot)));
398
462
  });
399
463
  const makeWithRuntime = (runtime, machine, args) => {
400
464
  const prepared = runtime.atom(() => internalMachine.prepare(machine, ...args));
401
465
  const ref = runtime.atom((get) => startPreparedMachineAtomEffect(get, prepared));
402
- const result = makeFromRefAtom(ref, machine);
466
+ const result = makeFromRefAtom(ref, machine, lazyPlan(() => PlannedSnapshot.planStart(machine, args)));
403
467
  preparedByMachineAtom.set(result, prepared);
404
468
  return result;
405
469
  };
406
470
  const resumeWithRuntime = (runtime, machine, snapshot) => {
407
471
  const ref = runtime.atom((get) => resumeMachineAtomEffect(get, machine, snapshot));
408
- return makeFromRefAtom(ref, machine);
472
+ return makeFromRefAtom(ref, machine, lazyPlan(() => PlannedSnapshot.planResume(machine, snapshot)));
409
473
  };
410
474
  const retainFamilyOwner = (owner, source, label) => {
411
475
  const retained = { owner, source };
412
- let atom = Atom.transform(source, (get) => get(retained.source), { initialValueTarget: source }).pipe(Atom.withEquality((value, next) => retained.source.equals(value, next)));
476
+ let atom = Atom.transform(source, (get) => get(retained.source), { initialValueTarget: source }).pipe(Atom.withEquality((value, next) => retained.source.equals(value, next)),
477
+ // The source's server value is already stable, so it passes through as is.
478
+ Atom.withServerValue((get) => readServerValue(retained.source, get)));
413
479
  if (label !== undefined) {
414
480
  atom = atom.pipe(Atom.withLabel(label));
415
481
  }