@playfast/reform 0.0.7 → 0.0.8

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 (237) hide show
  1. package/package.json +2 -2
  2. package/src/boundary/boundary.test.ts +301 -0
  3. package/src/boundary/boundary.ts +192 -0
  4. package/src/calc/asyncCalc.test.ts +556 -0
  5. package/src/calc/asyncCalc.ts +267 -0
  6. package/src/calc/asyncData.ts +96 -0
  7. package/src/calc/calc.test.ts +287 -0
  8. package/src/calc/calc.ts +120 -0
  9. package/src/calc/calcFamily.test.ts +206 -0
  10. package/src/calc/calcFamily.ts +194 -0
  11. package/src/calc/compose.test.ts +68 -0
  12. package/src/calc/compose.ts +69 -0
  13. package/src/channel/channel.ts +269 -0
  14. package/src/compose/composition.ts +112 -0
  15. package/{dist/compose/host.d.ts → src/compose/host.ts} +9 -8
  16. package/{dist/compose/props.js → src/compose/props.ts} +7 -5
  17. package/src/compose/provide.ts +70 -0
  18. package/{dist/compose/slot.d.ts → src/compose/slot.ts} +36 -19
  19. package/src/compose/ui.test.ts +62 -0
  20. package/src/compose/ui.ts +226 -0
  21. package/src/compose/ui.typecheck.ts +56 -0
  22. package/src/definition/definition.ts +76 -0
  23. package/src/event/event.test.ts +23 -0
  24. package/src/event/event.ts +65 -0
  25. package/src/event/eventGroup.ts +14 -0
  26. package/src/feature/feature.mount.test.ts +82 -0
  27. package/src/feature/feature.test.ts +60 -0
  28. package/{dist/feature/feature.d.ts → src/feature/feature.ts} +178 -92
  29. package/src/feature/feature.typecheck.ts +108 -0
  30. package/src/index.ts +176 -0
  31. package/{dist/internal/capture.d.ts → src/internal/capture.ts} +13 -11
  32. package/{dist/internal/ctx.d.ts → src/internal/ctx.ts} +8 -4
  33. package/src/internal/errors.test.ts +33 -0
  34. package/src/internal/errors.ts +145 -0
  35. package/src/internal/inspect.test.ts +28 -0
  36. package/src/internal/inspect.ts +34 -0
  37. package/src/internal/queryDriver.ts +247 -0
  38. package/src/internal/reuse.test.ts +116 -0
  39. package/src/internal/reuse.ts +73 -0
  40. package/src/internal/scheduler.ts +93 -0
  41. package/{dist/internal/seeds.d.ts → src/internal/seeds.ts} +6 -3
  42. package/src/internal/sources.ts +104 -0
  43. package/{dist/internal/stateRegistry.js → src/internal/stateRegistry.ts} +18 -14
  44. package/src/internal/store.test.ts +80 -0
  45. package/src/internal/store.ts +105 -0
  46. package/{dist/internal/track.d.ts → src/internal/track.ts} +17 -11
  47. package/src/procedure/procedure.ts +89 -0
  48. package/src/reducer/reducer.ts +137 -0
  49. package/src/remote/remoteState.test.ts +695 -0
  50. package/src/remote/remoteState.ts +571 -0
  51. package/src/remote/remoteState.typecheck.ts +195 -0
  52. package/src/runtime/bus.ts +40 -0
  53. package/src/runtime/hardening.test.ts +69 -0
  54. package/src/runtime/loop.test.ts +178 -0
  55. package/src/runtime/loop.ts +171 -0
  56. package/src/scene/scene.ts +76 -0
  57. package/src/scene/seedScene.test.ts +169 -0
  58. package/src/state/state.ts +94 -0
  59. package/src/state/stateFamily.test.ts +138 -0
  60. package/src/state/stateFamily.ts +174 -0
  61. package/src/state/stateGroup.ts +105 -0
  62. package/{dist/state/token.d.ts → src/state/token.ts} +22 -13
  63. package/src/synced/syncedStore.ts +99 -0
  64. package/{dist/ui/node.d.ts → src/ui/node.ts} +3 -3
  65. package/{dist/ui/trigger.d.ts → src/ui/trigger.ts} +1 -2
  66. package/src/wire/tree.test.ts +81 -0
  67. package/src/wire/tree.ts +129 -0
  68. package/src/wire/triggers.test.ts +76 -0
  69. package/src/wire/triggers.ts +98 -0
  70. package/dist/boundary/boundary.d.ts +0 -72
  71. package/dist/boundary/boundary.d.ts.map +0 -1
  72. package/dist/boundary/boundary.js +0 -83
  73. package/dist/boundary/boundary.js.map +0 -1
  74. package/dist/calc/asyncCalc.d.ts +0 -91
  75. package/dist/calc/asyncCalc.d.ts.map +0 -1
  76. package/dist/calc/asyncCalc.js +0 -95
  77. package/dist/calc/asyncCalc.js.map +0 -1
  78. package/dist/calc/asyncData.d.ts +0 -57
  79. package/dist/calc/asyncData.d.ts.map +0 -1
  80. package/dist/calc/asyncData.js +0 -34
  81. package/dist/calc/asyncData.js.map +0 -1
  82. package/dist/calc/calc.d.ts +0 -57
  83. package/dist/calc/calc.d.ts.map +0 -1
  84. package/dist/calc/calc.js +0 -58
  85. package/dist/calc/calc.js.map +0 -1
  86. package/dist/calc/calcFamily.d.ts +0 -57
  87. package/dist/calc/calcFamily.d.ts.map +0 -1
  88. package/dist/calc/calcFamily.js +0 -124
  89. package/dist/calc/calcFamily.js.map +0 -1
  90. package/dist/calc/compose.d.ts +0 -16
  91. package/dist/calc/compose.d.ts.map +0 -1
  92. package/dist/calc/compose.js +0 -7
  93. package/dist/calc/compose.js.map +0 -1
  94. package/dist/channel/channel.d.ts +0 -115
  95. package/dist/channel/channel.d.ts.map +0 -1
  96. package/dist/channel/channel.js +0 -138
  97. package/dist/channel/channel.js.map +0 -1
  98. package/dist/compose/composition.d.ts +0 -72
  99. package/dist/compose/composition.d.ts.map +0 -1
  100. package/dist/compose/composition.js +0 -46
  101. package/dist/compose/composition.js.map +0 -1
  102. package/dist/compose/host.d.ts.map +0 -1
  103. package/dist/compose/host.js +0 -6
  104. package/dist/compose/host.js.map +0 -1
  105. package/dist/compose/props.d.ts +0 -13
  106. package/dist/compose/props.d.ts.map +0 -1
  107. package/dist/compose/props.js.map +0 -1
  108. package/dist/compose/provide.d.ts +0 -22
  109. package/dist/compose/provide.d.ts.map +0 -1
  110. package/dist/compose/provide.js +0 -28
  111. package/dist/compose/provide.js.map +0 -1
  112. package/dist/compose/slot.d.ts.map +0 -1
  113. package/dist/compose/slot.js +0 -23
  114. package/dist/compose/slot.js.map +0 -1
  115. package/dist/compose/ui.d.ts +0 -135
  116. package/dist/compose/ui.d.ts.map +0 -1
  117. package/dist/compose/ui.js +0 -63
  118. package/dist/compose/ui.js.map +0 -1
  119. package/dist/definition/definition.d.ts +0 -33
  120. package/dist/definition/definition.d.ts.map +0 -1
  121. package/dist/definition/definition.js +0 -42
  122. package/dist/definition/definition.js.map +0 -1
  123. package/dist/event/event.d.ts +0 -33
  124. package/dist/event/event.d.ts.map +0 -1
  125. package/dist/event/event.js +0 -30
  126. package/dist/event/event.js.map +0 -1
  127. package/dist/event/eventGroup.d.ts +0 -9
  128. package/dist/event/eventGroup.d.ts.map +0 -1
  129. package/dist/event/eventGroup.js +0 -4
  130. package/dist/event/eventGroup.js.map +0 -1
  131. package/dist/feature/feature.d.ts.map +0 -1
  132. package/dist/feature/feature.js +0 -98
  133. package/dist/feature/feature.js.map +0 -1
  134. package/dist/index.d.ts +0 -53
  135. package/dist/index.d.ts.map +0 -1
  136. package/dist/index.js +0 -62
  137. package/dist/index.js.map +0 -1
  138. package/dist/internal/capture.d.ts.map +0 -1
  139. package/dist/internal/capture.js +0 -12
  140. package/dist/internal/capture.js.map +0 -1
  141. package/dist/internal/ctx.d.ts.map +0 -1
  142. package/dist/internal/ctx.js +0 -2
  143. package/dist/internal/ctx.js.map +0 -1
  144. package/dist/internal/errors.d.ts +0 -89
  145. package/dist/internal/errors.d.ts.map +0 -1
  146. package/dist/internal/errors.js +0 -102
  147. package/dist/internal/errors.js.map +0 -1
  148. package/dist/internal/inspect.d.ts +0 -17
  149. package/dist/internal/inspect.d.ts.map +0 -1
  150. package/dist/internal/inspect.js +0 -32
  151. package/dist/internal/inspect.js.map +0 -1
  152. package/dist/internal/queryDriver.d.ts +0 -65
  153. package/dist/internal/queryDriver.d.ts.map +0 -1
  154. package/dist/internal/queryDriver.js +0 -134
  155. package/dist/internal/queryDriver.js.map +0 -1
  156. package/dist/internal/reuse.d.ts +0 -10
  157. package/dist/internal/reuse.d.ts.map +0 -1
  158. package/dist/internal/reuse.js +0 -68
  159. package/dist/internal/reuse.js.map +0 -1
  160. package/dist/internal/scheduler.d.ts +0 -47
  161. package/dist/internal/scheduler.d.ts.map +0 -1
  162. package/dist/internal/scheduler.js +0 -70
  163. package/dist/internal/scheduler.js.map +0 -1
  164. package/dist/internal/seeds.d.ts.map +0 -1
  165. package/dist/internal/seeds.js +0 -17
  166. package/dist/internal/seeds.js.map +0 -1
  167. package/dist/internal/sources.d.ts +0 -39
  168. package/dist/internal/sources.d.ts.map +0 -1
  169. package/dist/internal/sources.js +0 -59
  170. package/dist/internal/sources.js.map +0 -1
  171. package/dist/internal/stateRegistry.d.ts +0 -2
  172. package/dist/internal/stateRegistry.d.ts.map +0 -1
  173. package/dist/internal/stateRegistry.js.map +0 -1
  174. package/dist/internal/store.d.ts +0 -47
  175. package/dist/internal/store.d.ts.map +0 -1
  176. package/dist/internal/store.js +0 -73
  177. package/dist/internal/store.js.map +0 -1
  178. package/dist/internal/track.d.ts.map +0 -1
  179. package/dist/internal/track.js +0 -19
  180. package/dist/internal/track.js.map +0 -1
  181. package/dist/procedure/procedure.d.ts +0 -40
  182. package/dist/procedure/procedure.d.ts.map +0 -1
  183. package/dist/procedure/procedure.js +0 -50
  184. package/dist/procedure/procedure.js.map +0 -1
  185. package/dist/reducer/reducer.d.ts +0 -44
  186. package/dist/reducer/reducer.d.ts.map +0 -1
  187. package/dist/reducer/reducer.js +0 -63
  188. package/dist/reducer/reducer.js.map +0 -1
  189. package/dist/remote/remoteState.d.ts +0 -119
  190. package/dist/remote/remoteState.d.ts.map +0 -1
  191. package/dist/remote/remoteState.js +0 -270
  192. package/dist/remote/remoteState.js.map +0 -1
  193. package/dist/runtime/bus.d.ts +0 -27
  194. package/dist/runtime/bus.d.ts.map +0 -1
  195. package/dist/runtime/bus.js +0 -21
  196. package/dist/runtime/bus.js.map +0 -1
  197. package/dist/runtime/loop.d.ts +0 -45
  198. package/dist/runtime/loop.d.ts.map +0 -1
  199. package/dist/runtime/loop.js +0 -117
  200. package/dist/runtime/loop.js.map +0 -1
  201. package/dist/scene/scene.d.ts +0 -44
  202. package/dist/scene/scene.d.ts.map +0 -1
  203. package/dist/scene/scene.js +0 -31
  204. package/dist/scene/scene.js.map +0 -1
  205. package/dist/state/state.d.ts +0 -37
  206. package/dist/state/state.d.ts.map +0 -1
  207. package/dist/state/state.js +0 -46
  208. package/dist/state/state.js.map +0 -1
  209. package/dist/state/stateFamily.d.ts +0 -79
  210. package/dist/state/stateFamily.d.ts.map +0 -1
  211. package/dist/state/stateFamily.js +0 -99
  212. package/dist/state/stateFamily.js.map +0 -1
  213. package/dist/state/stateGroup.d.ts +0 -50
  214. package/dist/state/stateGroup.d.ts.map +0 -1
  215. package/dist/state/stateGroup.js +0 -54
  216. package/dist/state/stateGroup.js.map +0 -1
  217. package/dist/state/token.d.ts.map +0 -1
  218. package/dist/state/token.js +0 -20
  219. package/dist/state/token.js.map +0 -1
  220. package/dist/synced/syncedStore.d.ts +0 -51
  221. package/dist/synced/syncedStore.d.ts.map +0 -1
  222. package/dist/synced/syncedStore.js +0 -43
  223. package/dist/synced/syncedStore.js.map +0 -1
  224. package/dist/ui/node.d.ts.map +0 -1
  225. package/dist/ui/node.js +0 -2
  226. package/dist/ui/node.js.map +0 -1
  227. package/dist/ui/trigger.d.ts.map +0 -1
  228. package/dist/ui/trigger.js +0 -2
  229. package/dist/ui/trigger.js.map +0 -1
  230. package/dist/wire/tree.d.ts +0 -66
  231. package/dist/wire/tree.d.ts.map +0 -1
  232. package/dist/wire/tree.js +0 -60
  233. package/dist/wire/tree.js.map +0 -1
  234. package/dist/wire/triggers.d.ts +0 -44
  235. package/dist/wire/triggers.d.ts.map +0 -1
  236. package/dist/wire/triggers.js +0 -31
  237. package/dist/wire/triggers.js.map +0 -1
@@ -1,134 +0,0 @@
1
- import { Brand, Cause, Chunk, Effect, MutableRef, Option, Queue, Schema, Stream, } from 'effect';
2
- import { AsyncData } from '../calc/asyncData';
3
- import { reuse } from './reuse';
4
- import { resolveScheduler } from './scheduler';
5
- import { sameKey, wireSources, } from './sources';
6
- import { makeStore } from './store';
7
- import {} from '../state/token';
8
- /** The runtime gated flag for an `alwaysOn` config, typed as its `Gated` literal. */
9
- export const gatedFlag = (alwaysOn) => (alwaysOn !== true);
10
- export const Revision = Brand.nominal();
11
- export const RevisionSchema = Schema.Number.pipe(Schema.brand('reform/Revision'));
12
- export const revisionZero = Revision(0);
13
- export const bumpRevision = (r) => Revision(r + 1);
14
- /**
15
- * Build the driver: store + subscription + request queue + run fiber, all owned
16
- * by the ambient scope (callers run this under `Layer.scoped`). A change to an
17
- * input re-runs the query latest-wins (a new run cancels the in-flight one; or,
18
- * with `coalesce: 'trailing'`, lets it finish and runs one trailing refetch);
19
- * while a re-run is in flight the last `Success`/`Error` is kept with
20
- * `refetching: true`.
21
- */
22
- export const makeQueryDriver = (options) => Effect.gen(function* () {
23
- const scheduler = yield* resolveScheduler;
24
- const sources = yield* wireSources(options.inputs, options.invalidateBy);
25
- const extraKey = options.extraKey;
26
- const keyOf = (args) => extraKey === undefined ? sources.keyOf(args) : [...sources.keyOf(args), extraKey.read()];
27
- const subscribeAll = (listener) => {
28
- const offSources = sources.subscribe(listener);
29
- const offExtra = extraKey?.subscribe(listener);
30
- return () => {
31
- offSources();
32
- offExtra?.();
33
- };
34
- };
35
- const disabledNow = (args = sources.snapshot()) => options.gated && options.disabled !== undefined ? options.disabled(args) : false;
36
- const store = makeStore(disabledNow() ? AsyncData.idle : AsyncData.loading, scheduler);
37
- // The last requested key, so a change that doesn't move it (or only churns
38
- // an input `invalidateBy` ignores) doesn't re-fetch.
39
- const lastKey = MutableRef.make(undefined);
40
- // The run-generation counter: bumped when a run is REQUESTED (enqueued), so
41
- // `requested()` names the newest run that could possibly be in flight.
42
- const generation = MutableRef.make(0);
43
- const nextGeneration = () => {
44
- MutableRef.update(generation, (n) => n + 1);
45
- return MutableRef.get(generation);
46
- };
47
- // Mark a re-fetch in flight without dropping the visible value (SWR).
48
- const markRefetching = () => {
49
- const prev = store.get();
50
- if (prev._tag === 'Success')
51
- store.set(AsyncData.success(prev.value, true));
52
- else if (prev._tag === 'Error')
53
- store.set(AsyncData.error(prev.error, true));
54
- else
55
- store.set(AsyncData.loading);
56
- };
57
- // One run of the query, folded into the store. A failure becomes `Error`; an
58
- // interrupt (latest-wins cancel) leaves the state untouched; a defect (a bug
59
- // in the body) is logged and isolated — the driver keeps running. A `Success`
60
- // additionally reports its generation through `onSettled`, after the write,
61
- // so settle-driven consequences observe the converged value.
62
- const runQuery = (request) => options.query(request.args).pipe(Effect.tapDefect((defect) => Effect.logError(`reform: ${options.label} '${options.name}' query defect`, defect)), Effect.matchCause({
63
- onSuccess: (value) => {
64
- if (!disabledNow()) {
65
- // `reuse`: share unchanged subtrees with the previous Success
66
- // value, so a refetch that barely moved keeps identities stable.
67
- const prev = store.get();
68
- const shared = options.reuse === true && prev._tag === 'Success'
69
- ? reuse(prev.value, value)
70
- : value;
71
- store.set(AsyncData.success(shared, false));
72
- options.onSettled?.(request.generation);
73
- }
74
- },
75
- onFailure: (cause) => {
76
- const failure = Cause.failureOption(cause);
77
- if (Option.isSome(failure) && !disabledNow()) {
78
- store.set(AsyncData.error(failure.value, false));
79
- }
80
- },
81
- }));
82
- // The driver. `'switch'` (default): each new request cancels the in-flight
83
- // run — the same latest-wins semantics a `latest` channel gives procedures.
84
- // `'trailing'`: a strictly sequential consumer that, on wake, drains every
85
- // request that piled up during the flight and runs the LATEST one —
86
- // "exactly one trailing run after settle" by construction. The trailing
87
- // run's generation is the max drained (the latest request's), so it
88
- // vouches for every request it conflated.
89
- const trailing = options.coalesce === 'trailing';
90
- const requests = yield* Queue.unbounded();
91
- yield* Effect.forkScoped(trailing
92
- ? Effect.forever(Effect.gen(function* () {
93
- const first = yield* Queue.take(requests);
94
- const queued = yield* Queue.takeAll(requests);
95
- const request = Option.getOrElse(Chunk.last(queued), () => first);
96
- // A disable that landed while the request waited: skip the run.
97
- if (!disabledNow())
98
- yield* runQuery(request);
99
- // The settle may have written a stale-key result with
100
- // `refetching: false`; if a newer request is already waiting,
101
- // restore the syncing flag before the next take — both writes
102
- // coalesce into one scheduler flush for subscribers.
103
- const pending = yield* Queue.size(requests);
104
- if (pending > 0 && !disabledNow())
105
- yield* Effect.sync(markRefetching);
106
- }))
107
- : Stream.fromQueue(requests).pipe(Stream.flatMap((request) => Stream.fromEffect(runQuery(request)), { switch: true }), Stream.runDrain));
108
- const trigger = () => {
109
- const args = sources.snapshot();
110
- if (disabledNow(args)) {
111
- // Switched off: show Idle and forget the key so re-enabling always re-runs.
112
- MutableRef.set(lastKey, undefined);
113
- store.set(AsyncData.idle);
114
- return;
115
- }
116
- const key = keyOf(args);
117
- const previous = MutableRef.get(lastKey);
118
- if (previous !== undefined && sameKey(key, previous))
119
- return;
120
- MutableRef.set(lastKey, key);
121
- markRefetching();
122
- Queue.unsafeOffer(requests, { args, generation: nextGeneration() });
123
- };
124
- const unsubscribe = subscribeAll(trigger);
125
- yield* Effect.addFinalizer(() => Effect.sync(unsubscribe));
126
- // Kick off the first fetch unless the query starts disabled.
127
- const initial = sources.snapshot();
128
- if (!disabledNow(initial)) {
129
- MutableRef.set(lastKey, keyOf(initial));
130
- Queue.unsafeOffer(requests, { args: initial, generation: nextGeneration() });
131
- }
132
- return { store, requested: () => MutableRef.get(generation) };
133
- });
134
- //# sourceMappingURL=queryDriver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queryDriver.js","sourceRoot":"","sources":["../../src/internal/queryDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EAEN,MAAM,GACP,MAAM,QAAQ,CAAA;AACf,OAAO,EAAqB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAIL,OAAO,EACP,WAAW,GACZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAkB,MAAM,gBAAgB,CAAA;AAW/C,qFAAq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AQ,EAAE,CAAA;IAClC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACvC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAA;AAC/D,CAAC,CAAC,CAAA"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Substitute `previous` nodes into `next` wherever they are value-equal. The
3
- * walker only ever returns `previous`, `next`, or a key/index-wise
4
- * reconstruction of `next` whose every leaf came from one of them, so the
5
- * result is value-equal to `next` and the type is preserved by construction —
6
- * the single cast below is that argument, in the style of `wireSources` /
7
- * `narrowStore`.
8
- */
9
- export declare const reuse: <A>(previous: A, next: A) => A;
10
- //# sourceMappingURL=reuse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reuse.d.ts","sourceRoot":"","sources":["../../src/internal/reuse.ts"],"names":[],"mappings":"AAgEA;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,KAAG,CAAsC,CAAA"}
@@ -1,68 +0,0 @@
1
- import { Equal } from 'effect';
2
- // Structural sharing for recomputed calc outputs: reconcile a fresh output
3
- // against the previous one, substituting previous nodes wherever value equality
4
- // holds, so identities only move where values moved. Downstream memo boundaries
5
- // (React subtrees keyed on object identity) then skip everything that didn't
6
- // change. Referentially transparent: the result is value-equal to `next` — only
7
- // identities shift toward `previous` — and neither argument is mutated, so the
8
- // pass composes with the framework's Equal-based invalidation untouched.
9
- // Bounds the walk; calc outputs are shallow plain data by framework convention.
10
- const maxDepth = 16;
11
- const isPlainRecord = (v) => typeof v === 'object' &&
12
- v !== null &&
13
- (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
14
- const go = (prev, next, depth) => {
15
- if (Object.is(prev, next))
16
- return prev;
17
- // Data/Schema classes implement Equal+Hash: substitute wholesale on value
18
- // equality. Plain objects/arrays fall through (their Equal is referential).
19
- if (Equal.equals(prev, next))
20
- return prev;
21
- if (depth <= 0)
22
- return next;
23
- if (Array.isArray(prev) && Array.isArray(next)) {
24
- const out = next.map((item, i) => (i < prev.length ? go(prev[i], item, depth - 1) : item));
25
- return prev.length === next.length && out.every((v, i) => Object.is(v, prev[i]))
26
- ? prev
27
- : out;
28
- }
29
- if (isPlainRecord(prev) && isPlainRecord(next)) {
30
- const keys = Object.keys(next);
31
- const out = {};
32
- for (const key of keys)
33
- out[key] = key in prev ? go(prev[key], next[key], depth - 1) : next[key];
34
- const allPrev = keys.length === Object.keys(prev).length &&
35
- keys.every((key) => key in prev && Object.is(out[key], prev[key]));
36
- return allPrev ? prev : out;
37
- }
38
- // Data/Schema class instances that DIFFER still get walked: their Equal is
39
- // fieldwise over own enumerable fields, so a reconstruction over reconciled
40
- // fields (same prototype; the constructor is bypassed, but every leaf is a
41
- // validated value out of `prev` or `next`) stays value-equal to `next` while
42
- // unchanged children — e.g. one untouched element inside a class-typed
43
- // container — keep their `prev` identity.
44
- if (Equal.isEqual(prev) &&
45
- Equal.isEqual(next) &&
46
- Object.getPrototypeOf(prev) === Object.getPrototypeOf(next)) {
47
- const prevFields = Object.fromEntries(Object.entries(prev));
48
- const nextFields = Object.entries(next);
49
- const out = {};
50
- for (const [key, value] of nextFields)
51
- out[key] = key in prevFields ? go(prevFields[key], value, depth - 1) : value;
52
- const allPrev = nextFields.length === Object.keys(prevFields).length &&
53
- nextFields.every(([key]) => key in prevFields && Object.is(out[key], prevFields[key]));
54
- return allPrev ? prev : Object.assign(Object.create(Object.getPrototypeOf(next)), out);
55
- }
56
- // Class instances without Equal (Date, Map, …) are opaque leaves.
57
- return next;
58
- };
59
- /**
60
- * Substitute `previous` nodes into `next` wherever they are value-equal. The
61
- * walker only ever returns `previous`, `next`, or a key/index-wise
62
- * reconstruction of `next` whose every leaf came from one of them, so the
63
- * result is value-equal to `next` and the type is preserved by construction —
64
- * the single cast below is that argument, in the style of `wireSources` /
65
- * `narrowStore`.
66
- */
67
- export const reuse = (previous, next) => go(previous, next, maxDepth);
68
- //# sourceMappingURL=reuse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reuse.js","sourceRoot":"","sources":["../../src/internal/reuse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,yEAAyE;AAEzE,gFAAgF;AAChF,MAAM,QAAQ,GAAG,EAAE,CAAA;AAEnB,MAAM,aAAa,GAAG,CAAC,CAAU,EAAgC,EAAE,CACjE,OAAO,CAAC,KAAK,QAAQ;IACrB,CAAC,KAAK,IAAI;IACV,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;AAEtF,MAAM,EAAE,GAAG,CAAC,IAAa,EAAE,IAAa,EAAE,KAAa,EAAW,EAAE;IAClE,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACtC,0EAA0E;IAC1E,4EAA4E;IAC5E,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACzC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAA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AAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACxF,CAAC;IACD,kEAAkE;IAClE,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,QAAW,EAAE,IAAO,EAAK,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAM,CAAA"}
@@ -1,47 +0,0 @@
1
- import { Context, Effect, Layer } from 'effect';
2
- /**
3
- * Coalesces store notifications into a single microtask flush so a batch of
4
- * writes wakes each subscriber at most once (RESEARCH #3). React owns frame
5
- * timing; we only collapse the notifications.
6
- *
7
- * One scheduler is shared by every store in a runtime, so writes across
8
- * different stores in the same tick batch into one flush. The instance is
9
- * resolved per store at creation: `Notifications` when a runtime provides it
10
- * (per-runtime isolation — see `resolveScheduler`), else the process-wide
11
- * `defaultScheduler`.
12
- */
13
- export interface Scheduler {
14
- readonly schedule: (listeners: Iterable<() => void>) => void;
15
- }
16
- export declare const makeScheduler: () => Scheduler;
17
- /**
18
- * The process-wide scheduler, used by any store created outside a runtime that
19
- * provides its own `Notifications`. Fine for a single client app (microtask
20
- * ordering is global anyway); a runtime that needs isolation — concurrent SSR,
21
- * multiple mounted roots — provides `Notifications` upstream of its stores.
22
- */
23
- export declare const defaultScheduler: Scheduler;
24
- /**
25
- * Optional per-runtime scheduler. When a runtime provides it upstream of its
26
- * state/calc layers, those stores coalesce on it instead of the global default,
27
- * isolating their notification timing from other runtimes in the same process.
28
- */
29
- declare const NotificationsBase: Context.TagClass<Notifications, 'reform/Notifications', Scheduler>;
30
- export declare class Notifications extends NotificationsBase {
31
- }
32
- /**
33
- * A fresh per-runtime scheduler. Merged into `Engine`, so a runtime that wires
34
- * its state/calc layers *downstream* of `Engine` gets isolated notification
35
- * timing; the common sibling wiring falls back to `defaultScheduler` (still
36
- * correct, just process-shared).
37
- */
38
- export declare const notificationsLayer: Layer.Layer<Notifications>;
39
- /**
40
- * Resolve the scheduler a store should use: the runtime's `Notifications` if one
41
- * is in context, else the global default. Uses `serviceOption` so it imposes no
42
- * hard requirement — a store layer wired as a sibling of the runtime (the common
43
- * pattern) simply falls back to the default.
44
- */
45
- export declare const resolveScheduler: Effect.Effect<Scheduler>;
46
- export {};
47
- //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/internal/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAsB,MAAM,QAAQ,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,CAAA;CAC7D;AAED,eAAO,MAAM,aAAa,QAAO,SAuChC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAA2B,CAAA;AAE1D;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,sBAAsB,EAAE,SAAS,CACzB,CAAA;AACjE,qBAAa,aAAc,SAAQ,iBAAiB;CAAG;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAA4C,CAAA;AAEtG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAGrD,CAAA"}
@@ -1,70 +0,0 @@
1
- import { Context, Effect, Layer, MutableRef, Option } from 'effect';
2
- export const makeScheduler = () => {
3
- const pending = new Set();
4
- const armed = MutableRef.make(false);
5
- const flush = () => {
6
- MutableRef.set(armed, false);
7
- // Drain to a fixpoint within ONE microtask. A derived store's `onChange`
8
- // re-schedules during the pass (it is itself a listener of its upstream), so
9
- // resolving the whole dependency graph here — instead of re-arming a fresh
10
- // microtask per layer — collapses a depth-N propagation into a single flush
11
- // and wakes each leaf subscriber once at its final value. Converges because
12
- // a derived store schedules only when its output actually moves (Equal).
13
- while (pending.size > 0) {
14
- const due = [...pending];
15
- pending.clear();
16
- for (const listener of due) {
17
- // One listener's throw (a defect in a user calc body) must not abandon
18
- // the rest of the flush; surface it to the host's global handler on a
19
- // fresh microtask instead of unwinding this loop.
20
- try {
21
- listener();
22
- }
23
- catch (error) {
24
- queueMicrotask(() => {
25
- throw error;
26
- });
27
- }
28
- }
29
- }
30
- };
31
- const schedule = (listeners) => {
32
- for (const listener of listeners)
33
- pending.add(listener);
34
- if (pending.size > 0 && !MutableRef.get(armed)) {
35
- MutableRef.set(armed, true);
36
- queueMicrotask(flush);
37
- }
38
- };
39
- return { schedule };
40
- };
41
- /**
42
- * The process-wide scheduler, used by any store created outside a runtime that
43
- * provides its own `Notifications`. Fine for a single client app (microtask
44
- * ordering is global anyway); a runtime that needs isolation — concurrent SSR,
45
- * multiple mounted roots — provides `Notifications` upstream of its stores.
46
- */
47
- export const defaultScheduler = makeScheduler();
48
- /**
49
- * Optional per-runtime scheduler. When a runtime provides it upstream of its
50
- * state/calc layers, those stores coalesce on it instead of the global default,
51
- * isolating their notification timing from other runtimes in the same process.
52
- */
53
- const NotificationsBase = Context.Tag('reform/Notifications')();
54
- export class Notifications extends NotificationsBase {
55
- }
56
- /**
57
- * A fresh per-runtime scheduler. Merged into `Engine`, so a runtime that wires
58
- * its state/calc layers *downstream* of `Engine` gets isolated notification
59
- * timing; the common sibling wiring falls back to `defaultScheduler` (still
60
- * correct, just process-shared).
61
- */
62
- export const notificationsLayer = Layer.sync(Notifications, makeScheduler);
63
- /**
64
- * Resolve the scheduler a store should use: the runtime's `Notifications` if one
65
- * is in context, else the global default. Uses `serviceOption` so it imposes no
66
- * hard requirement — a store layer wired as a sibling of the runtime (the common
67
- * pattern) simply falls back to the default.
68
- */
69
- export const resolveScheduler = Effect.map(Effect.serviceOption(Notifications), Option.getOrElse(() => defaultScheduler));
70
- //# sourceMappingURL=scheduler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/internal/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAiBnE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAc,EAAE;IAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAc,CAAA;IACrC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAEpC,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC5B,yEAAyE;QACzE,6EAA6E;QAC7E,2EAA2E;QAC3E,4EAA4E;QAC5E,4EAA4E;QAC5E,yEAAyE;QACzE,OAAO,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,CAAC,GAAG,OAAO,CAAC,CAAA;YACxB,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,QAAQ,IAAI,GAAG,EAAE,CAAC;gBAC3B,uEAAuE;gBACvE,sEAAsE;gBACtE,kDAAkD;gBAClD,IAAI,CAAC;oBACH,QAAQ,EAAE,CAAA;gBACZ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,cAAc,CAAC,GAAG,EAAE;wBAClB,MAAM,KAAK,CAAA;oBACb,CAAC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,CAAC,SAA+B,EAAE,EAAE;QACnD,KAAK,MAAM,QAAQ,IAAI,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACvD,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAC3B,cAAc,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,CAAA;AACrB,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAc,aAAa,EAAE,CAAA;AAE1D;;;;GAIG;AACH,MAAM,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAA4B,CAAA;AACjE,MAAM,OAAO,aAAc,SAAQ,iBAAiB;CAAG;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA+B,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAEtG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA6B,MAAM,CAAC,GAAG,CAClE,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,EACnC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CACzC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"seeds.d.ts","sourceRoot":"","sources":["../../src/internal/seeds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,QAAQ,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAGnF,CAAA"}
@@ -1,17 +0,0 @@
1
- import { FiberRef, GlobalValue } from 'effect';
2
- /**
3
- * The sanctioned tooling/test seam for seeding CLOSED scenes. A scene's layers
4
- * are pre-composed (each state group seeds its own live store), so an outer
5
- * layer cannot override an inner store — but a FiberRef set via
6
- * `Layer.locally(ref, value)(layer)` IS visible inside the construction effects
7
- * of nested layers. `State.live` consults this ref at store-construction time:
8
- * if the state's member name is present, the (schema-validated) value replaces
9
- * the authored seed; otherwise the authored seed wins.
10
- *
11
- * Empty by default — production wiring never touches it. The dev-tool inspector
12
- * (`Scene.seedScene`) and proofs are the only intended writers. `globalValue`
13
- * keeps a single ref instance even if the module is loaded twice (duplicated
14
- * bundles, HMR), so the writer and the reader always agree.
15
- */
16
- export const CurrentSeedOverrides = GlobalValue.globalValue(Symbol.for('reform/CurrentSeedOverrides'), () => FiberRef.unsafeMake({}));
17
- //# sourceMappingURL=seeds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seeds.js","sourceRoot":"","sources":["../../src/internal/seeds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAAE,GAAG,EAAE,CACtE,QAAQ,CAAC,UAAU,CAAoC,EAAE,CAAC,CAC3D,CAAA"}
@@ -1,39 +0,0 @@
1
- import { type Context, Effect } from 'effect';
2
- import { type AnySource, type SourceName, type SourceValue } from '../state/token';
3
- /** The decoded inputs handed to a calc body, keyed by each source's name. */
4
- export type InputsObject<Inputs extends ReadonlyArray<AnySource>> = {
5
- readonly [S in Inputs[number] as SourceName<S>]: SourceValue<S>;
6
- };
7
- /**
8
- * The store services a list of store-carriers requires, as a *union of distinct*
9
- * stores (each carrier has its own backing tag), not a single store of a union.
10
- * Structural over the `store` tag, so it serves both calc inputs (`Source`s) and
11
- * state-group members (`StateClass`es) — anything carrying a `store` tag.
12
- */
13
- export type StoresOf<Items extends ReadonlyArray<unknown>> = {
14
- [I in keyof Items]: Items[I] extends {
15
- readonly store: Context.Tag<infer Svc, any>;
16
- } ? Svc : never;
17
- }[number];
18
- /** The store requirement a calc's inputs impose. */
19
- export type InputStores<Inputs extends ReadonlyArray<AnySource>> = StoresOf<Inputs>;
20
- /** Project inputs into a comparable key; the calc reacts only when it moves. */
21
- export type InvalidateBy<Inputs extends ReadonlyArray<AnySource>> = (inputs: InputsObject<Inputs>) => ReadonlyArray<unknown>;
22
- /** Element-wise value equality of two invalidation keys. */
23
- export declare const sameKey: (a: ReadonlyArray<unknown>, b: ReadonlyArray<unknown>) => boolean;
24
- /** The sensing surface both `Calc.live` and `AsyncCalc.live` build on. */
25
- export interface WiredSources<Inputs extends ReadonlyArray<AnySource>> {
26
- /** Snapshot every input by name — the decoded inputs object a calc body sees. */
27
- readonly snapshot: () => InputsObject<Inputs>;
28
- /** The invalidation key for an inputs object: the projection, or all input values. */
29
- readonly keyOf: (inputs: InputsObject<Inputs>) => ReadonlyArray<unknown>;
30
- /** Subscribe to every source at once; the returned thunk unsubscribes from all. */
31
- readonly subscribe: (listener: () => void) => () => void;
32
- }
33
- /**
34
- * Read each input's backing store and return the shared sensing surface. The
35
- * caller owns lifecycle: register the `subscribe` result's unsubscribe as a
36
- * scope finalizer (both live bodies run under `Layer.scoped`).
37
- */
38
- export declare const wireSources: <Inputs extends ReadonlyArray<AnySource>>(inputs: Inputs, invalidateBy?: InvalidateBy<Inputs>) => Effect.Effect<WiredSources<Inputs>, never, InputStores<Inputs>>;
39
- //# sourceMappingURL=sources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/internal/sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAQlF,6EAA6E;AAC7E,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,aAAa,CAAC,SAAS,CAAC,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AM,IAAI,CAAA;CACzD;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,aAAa,CAAC,SAAS,CAAC,EACjE,QAAQ,MAAM,EACd,eAAe,YAAY,CAAC,MAAM,CAAC,KAClC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CA4BM,CAAA"}
@@ -1,59 +0,0 @@
1
- import { Effect, Equal, Predicate } from 'effect';
2
- import {} from '../state/token';
3
- import {} from './store';
4
- /**
5
- * The runtime key an input contributes to the inputs object. Prefer the
6
- * explicit `manifest.name` — the string handed to `make` — over the structural
7
- * `name`: a `Calc`/`AsyncCalc` *class* satisfies `Source` through its static
8
- * `name`, and a user subclass declaration (`class Feed extends Calc.make(…)`)
9
- * defines its OWN `name` from the class binding, shadowing the explicit one.
10
- * That binding is what minifiers rename, so keying the snapshot by `input.name`
11
- * made every subclassed calc input `undefined` in production builds (and would
12
- * silently mis-key in dev whenever the binding differs from the `make` name —
13
- * the type-level key, `SourceName<S>`, is always the `make` string). The
14
- * manifest is inherited through the static prototype chain and never shadowed.
15
- * `StateToken`s carry no manifest; their `name` is an instance field holding
16
- * the explicit member key, so the fallback is always the declared string.
17
- */
18
- const inputKey = (input) => Predicate.hasProperty(input, 'manifest') &&
19
- Predicate.isRecord(input.manifest) &&
20
- Predicate.isString(input.manifest['name'])
21
- ? input.manifest['name']
22
- : input.name;
23
- /** Element-wise value equality of two invalidation keys. */
24
- export const sameKey = (a, b) => a.length === b.length && a.every((value, i) => Equal.equals(value, b[i]));
25
- /**
26
- * Read each input's backing store and return the shared sensing surface. The
27
- * caller owns lifecycle: register the `subscribe` result's unsubscribe as a
28
- * scope finalizer (both live bodies run under `Layer.scoped`).
29
- */
30
- export const wireSources = (inputs, invalidateBy) => Effect.gen(function* () {
31
- const sources = [];
32
- for (const input of inputs)
33
- sources.push(yield* input.store);
34
- const snapshot = () => {
35
- const args = {};
36
- inputs.forEach((input, i) => {
37
- // `noUncheckedIndexedAccess`: `sources` is built 1:1 with `inputs`, but
38
- // guard the index so the read is honestly total.
39
- const source = sources[i];
40
- if (source !== undefined)
41
- args[inputKey(input)] = source.getSnapshot();
42
- });
43
- return args;
44
- };
45
- const keyOf = (args) => invalidateBy ? invalidateBy(args) : Object.values(args);
46
- const subscribe = (listener) => {
47
- const unsubscribes = sources.map((source) => source.subscribe(listener));
48
- return () => {
49
- for (const unsubscribe of unsubscribes)
50
- unsubscribe();
51
- };
52
- };
53
- return { snapshot, keyOf, subscribe };
54
- // Yielding each `input.store` (a `Context.Tag<Store<unknown>>`) widens the
55
- // inferred requirement to `Store<unknown>`; restate the precise per-input
56
- // `InputStores<Inputs>` union the signature promises. This is the single
57
- // place that cast lives — `Calc.live`/`AsyncCalc.live` inherit it.
58
- });
59
- //# sourceMappingURL=sources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/internal/sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAqD,MAAM,gBAAgB,CAAA;AAClF,OAAO,EAAc,MAAM,SAAS,CAAA;AA8BpC;;;;;;;;;;;;;GAaG;AACH,MAAM,QAAQ,GAAG,CAAC,KAAgB,EAAU,EAAE,CAC5C,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;AAEhB,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAyB,EAAE,CAAyB,EAAW,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AC,CAAA;QACxE,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,WAAW,IAAI,YAAY;gBAAE,WAAW,EAAE,CAAA;QACvD,CAAC,CAAA;IACH,CAAC,CAAA;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;IACrC,2EAA2E;IAC3E,0EAA0E;IAC1E,yEAAyE;IACzE,mEAAmE;AACrE,CAAC,CAAoE,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const claimStateTag: (identifier: string) => void;
2
- //# sourceMappingURL=stateRegistry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateRegistry.d.ts","sourceRoot":"","sources":["../../src/internal/stateRegistry.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,KAAG,IAYlD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateRegistry.js","sourceRoot":"","sources":["../../src/internal/stateRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;AACjC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAQ,EAAE;IACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,OAAM;IACR,CAAC;IACD,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;QAAE,OAAM;IAClC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACtB,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,UAAU,CACf,gCAAgC,UAAU,sFAAsF,CACjI,CACF,CAAA;AACH,CAAC,CAAA"}
@@ -1,47 +0,0 @@
1
- import { type Inspectable } from './inspect';
2
- import { type Scheduler } from './scheduler';
3
- /**
4
- * A reactive cell living outside Effect. The single source of truth for one
5
- * slice of state. `set` is internal: only the reduce loop ever holds a Store
6
- * (reducers return values, the loop writes them), which is how "state changes
7
- * only in the reduce loop" is enforced structurally — there is no public writer.
8
- *
9
- * This is the synchronous, React-facing analog of Effect's `SubscriptionRef`
10
- * (a `Ref` + `PubSub` + a `changes` `Stream`). We don't use `SubscriptionRef`
11
- * directly because `useSyncExternalStore` requires a *synchronous* `getSnapshot`
12
- * and a *synchronous* `subscribe` returning an unsubscribe thunk, whereas
13
- * `SubscriptionRef.get` is an `Effect` and its `changes` is a `Stream` (a fiber
14
- * per subscription). Mutable state is held in a `MutableRef` (Effect's mutable
15
- * cell), so there is no reassigned binding.
16
- *
17
- * `getSnapshot` + `subscribe` are the stable pair the React bridge binds to;
18
- * `getSnapshot` returns the same reference until the value actually changes.
19
- * `getVersion` returns a monotonic counter bumped on every real change — the
20
- * host sums it across a render's tracked stores for a `useSyncExternalStore`
21
- * snapshot, which closes the tear/dropped-update window a value snapshot can't.
22
- */
23
- export interface Store<in out A> extends Inspectable {
24
- get(): A;
25
- set(value: A): void;
26
- getSnapshot(): A;
27
- getVersion(): number;
28
- subscribe(listener: () => void): () => void;
29
- }
30
- export declare const makeStore: <A>(initial: A, scheduler?: Scheduler) => Store<A>;
31
- /**
32
- * A read-only `Store` whose value is computed from upstream sources.
33
- *
34
- * Reads are pull-fresh: `get`/`getSnapshot` call `compute` directly, so a
35
- * headless snapshot always reflects the current source state without waiting for
36
- * a notification (`compute` must memoize so an unchanged read returns a stable
37
- * reference — `useSyncExternalStore` requires it). *Notifications*, by contrast,
38
- * run through the same coalescing scheduler as `makeStore`: an upstream change
39
- * recomputes once and wakes subscribers only when the output actually moves (by
40
- * `Equal.equals`), so every store kind shares one notification timing. `set` is
41
- * a no-op — the only writer is the upstream subscription.
42
- */
43
- export declare const makeDerivedStore: <A>(compute: () => A, subscribeUpstream: (onChange: () => void) => () => void, scheduler?: Scheduler) => {
44
- readonly store: Store<A>;
45
- readonly unsubscribe: () => void;
46
- };
47
- //# sourceMappingURL=store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,WAAW,CAAA;AACzD,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,SAAQ,WAAW;IAClD,GAAG,IAAI,CAAC,CAAA;IACR,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACnB,WAAW,IAAI,CAAC,CAAA;IAChB,UAAU,IAAI,MAAM,CAAA;IACpB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CAC5C;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,SAAS,CAAC,EAAE,YAAW,SAA4B,KAAG,KAAK,CAAC,CAAC,CAwBzF,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,SAAS,MAAM,CAAC,EAChB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,EACvD,YAAW,SAA4B,KACtC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CA8B9D,CAAA"}