@playfast/reform 0.0.5 → 0.0.7

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 (209) hide show
  1. package/dist/boundary/boundary.d.ts +72 -0
  2. package/dist/boundary/boundary.d.ts.map +1 -0
  3. package/dist/boundary/boundary.js +83 -0
  4. package/dist/boundary/boundary.js.map +1 -0
  5. package/dist/calc/asyncCalc.d.ts +91 -0
  6. package/dist/calc/asyncCalc.d.ts.map +1 -0
  7. package/dist/calc/asyncCalc.js +95 -0
  8. package/dist/calc/asyncCalc.js.map +1 -0
  9. package/{src/calc/asyncData.ts → dist/calc/asyncData.d.ts} +22 -53
  10. package/dist/calc/asyncData.d.ts.map +1 -0
  11. package/dist/calc/asyncData.js +34 -0
  12. package/dist/calc/asyncData.js.map +1 -0
  13. package/dist/calc/calc.d.ts +57 -0
  14. package/dist/calc/calc.d.ts.map +1 -0
  15. package/dist/calc/calc.js +58 -0
  16. package/dist/calc/calc.js.map +1 -0
  17. package/dist/calc/calcFamily.d.ts +57 -0
  18. package/dist/calc/calcFamily.d.ts.map +1 -0
  19. package/dist/calc/calcFamily.js +124 -0
  20. package/dist/calc/calcFamily.js.map +1 -0
  21. package/dist/calc/compose.d.ts +16 -0
  22. package/dist/calc/compose.d.ts.map +1 -0
  23. package/dist/calc/compose.js +7 -0
  24. package/dist/calc/compose.js.map +1 -0
  25. package/dist/channel/channel.d.ts +115 -0
  26. package/dist/channel/channel.d.ts.map +1 -0
  27. package/dist/channel/channel.js +138 -0
  28. package/dist/channel/channel.js.map +1 -0
  29. package/dist/compose/composition.d.ts +72 -0
  30. package/dist/compose/composition.d.ts.map +1 -0
  31. package/dist/compose/composition.js +46 -0
  32. package/dist/compose/composition.js.map +1 -0
  33. package/{src/compose/host.ts → dist/compose/host.d.ts} +8 -6
  34. package/dist/compose/host.d.ts.map +1 -0
  35. package/dist/compose/host.js +6 -0
  36. package/dist/compose/host.js.map +1 -0
  37. package/dist/compose/props.d.ts +13 -0
  38. package/dist/compose/props.d.ts.map +1 -0
  39. package/{src/compose/props.ts → dist/compose/props.js} +5 -3
  40. package/dist/compose/props.js.map +1 -0
  41. package/dist/compose/provide.d.ts +22 -0
  42. package/dist/compose/provide.d.ts.map +1 -0
  43. package/dist/compose/provide.js +28 -0
  44. package/dist/compose/provide.js.map +1 -0
  45. package/{src/compose/slot.ts → dist/compose/slot.d.ts} +19 -36
  46. package/dist/compose/slot.d.ts.map +1 -0
  47. package/dist/compose/slot.js +23 -0
  48. package/dist/compose/slot.js.map +1 -0
  49. package/dist/compose/ui.d.ts +135 -0
  50. package/dist/compose/ui.d.ts.map +1 -0
  51. package/dist/compose/ui.js +63 -0
  52. package/dist/compose/ui.js.map +1 -0
  53. package/dist/definition/definition.d.ts +33 -0
  54. package/dist/definition/definition.d.ts.map +1 -0
  55. package/dist/definition/definition.js +42 -0
  56. package/dist/definition/definition.js.map +1 -0
  57. package/dist/event/event.d.ts +33 -0
  58. package/dist/event/event.d.ts.map +1 -0
  59. package/dist/event/event.js +30 -0
  60. package/dist/event/event.js.map +1 -0
  61. package/dist/event/eventGroup.d.ts +9 -0
  62. package/dist/event/eventGroup.d.ts.map +1 -0
  63. package/dist/event/eventGroup.js +4 -0
  64. package/dist/event/eventGroup.js.map +1 -0
  65. package/{src/feature/feature.ts → dist/feature/feature.d.ts} +92 -178
  66. package/dist/feature/feature.d.ts.map +1 -0
  67. package/dist/feature/feature.js +98 -0
  68. package/dist/feature/feature.js.map +1 -0
  69. package/dist/index.d.ts +53 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +62 -0
  72. package/dist/index.js.map +1 -0
  73. package/{src/internal/capture.ts → dist/internal/capture.d.ts} +11 -13
  74. package/dist/internal/capture.d.ts.map +1 -0
  75. package/dist/internal/capture.js +12 -0
  76. package/dist/internal/capture.js.map +1 -0
  77. package/{src/internal/ctx.ts → dist/internal/ctx.d.ts} +4 -8
  78. package/dist/internal/ctx.d.ts.map +1 -0
  79. package/dist/internal/ctx.js +2 -0
  80. package/dist/internal/ctx.js.map +1 -0
  81. package/dist/internal/errors.d.ts +89 -0
  82. package/dist/internal/errors.d.ts.map +1 -0
  83. package/dist/internal/errors.js +102 -0
  84. package/dist/internal/errors.js.map +1 -0
  85. package/dist/internal/inspect.d.ts +17 -0
  86. package/dist/internal/inspect.d.ts.map +1 -0
  87. package/dist/internal/inspect.js +32 -0
  88. package/dist/internal/inspect.js.map +1 -0
  89. package/dist/internal/queryDriver.d.ts +65 -0
  90. package/dist/internal/queryDriver.d.ts.map +1 -0
  91. package/dist/internal/queryDriver.js +134 -0
  92. package/dist/internal/queryDriver.js.map +1 -0
  93. package/dist/internal/reuse.d.ts +10 -0
  94. package/dist/internal/reuse.d.ts.map +1 -0
  95. package/dist/internal/reuse.js +68 -0
  96. package/dist/internal/reuse.js.map +1 -0
  97. package/dist/internal/scheduler.d.ts +47 -0
  98. package/dist/internal/scheduler.d.ts.map +1 -0
  99. package/dist/internal/scheduler.js +70 -0
  100. package/dist/internal/scheduler.js.map +1 -0
  101. package/{src/internal/seeds.ts → dist/internal/seeds.d.ts} +3 -6
  102. package/dist/internal/seeds.d.ts.map +1 -0
  103. package/dist/internal/seeds.js +17 -0
  104. package/dist/internal/seeds.js.map +1 -0
  105. package/dist/internal/sources.d.ts +39 -0
  106. package/dist/internal/sources.d.ts.map +1 -0
  107. package/dist/internal/sources.js +59 -0
  108. package/dist/internal/sources.js.map +1 -0
  109. package/dist/internal/stateRegistry.d.ts +2 -0
  110. package/dist/internal/stateRegistry.d.ts.map +1 -0
  111. package/dist/internal/stateRegistry.js +28 -0
  112. package/dist/internal/stateRegistry.js.map +1 -0
  113. package/dist/internal/store.d.ts +47 -0
  114. package/dist/internal/store.d.ts.map +1 -0
  115. package/dist/internal/store.js +73 -0
  116. package/dist/internal/store.js.map +1 -0
  117. package/{src/internal/track.ts → dist/internal/track.d.ts} +11 -15
  118. package/dist/internal/track.d.ts.map +1 -0
  119. package/dist/internal/track.js +19 -0
  120. package/dist/internal/track.js.map +1 -0
  121. package/dist/procedure/procedure.d.ts +40 -0
  122. package/dist/procedure/procedure.d.ts.map +1 -0
  123. package/dist/procedure/procedure.js +50 -0
  124. package/dist/procedure/procedure.js.map +1 -0
  125. package/dist/reducer/reducer.d.ts +44 -0
  126. package/dist/reducer/reducer.d.ts.map +1 -0
  127. package/dist/reducer/reducer.js +63 -0
  128. package/dist/reducer/reducer.js.map +1 -0
  129. package/dist/remote/remoteState.d.ts +119 -0
  130. package/dist/remote/remoteState.d.ts.map +1 -0
  131. package/dist/remote/remoteState.js +270 -0
  132. package/dist/remote/remoteState.js.map +1 -0
  133. package/dist/runtime/bus.d.ts +27 -0
  134. package/dist/runtime/bus.d.ts.map +1 -0
  135. package/{src/runtime/bus.ts → dist/runtime/bus.js} +8 -23
  136. package/dist/runtime/bus.js.map +1 -0
  137. package/dist/runtime/loop.d.ts +45 -0
  138. package/dist/runtime/loop.d.ts.map +1 -0
  139. package/dist/runtime/loop.js +117 -0
  140. package/dist/runtime/loop.js.map +1 -0
  141. package/dist/scene/scene.d.ts +44 -0
  142. package/dist/scene/scene.d.ts.map +1 -0
  143. package/dist/scene/scene.js +31 -0
  144. package/dist/scene/scene.js.map +1 -0
  145. package/dist/state/state.d.ts +37 -0
  146. package/dist/state/state.d.ts.map +1 -0
  147. package/dist/state/state.js +46 -0
  148. package/dist/state/state.js.map +1 -0
  149. package/dist/state/stateFamily.d.ts +79 -0
  150. package/dist/state/stateFamily.d.ts.map +1 -0
  151. package/dist/state/stateFamily.js +99 -0
  152. package/dist/state/stateFamily.js.map +1 -0
  153. package/dist/state/stateGroup.d.ts +50 -0
  154. package/dist/state/stateGroup.d.ts.map +1 -0
  155. package/dist/state/stateGroup.js +54 -0
  156. package/dist/state/stateGroup.js.map +1 -0
  157. package/{src/state/token.ts → dist/state/token.d.ts} +13 -21
  158. package/dist/state/token.d.ts.map +1 -0
  159. package/dist/state/token.js +20 -0
  160. package/dist/state/token.js.map +1 -0
  161. package/dist/synced/syncedStore.d.ts +51 -0
  162. package/dist/synced/syncedStore.d.ts.map +1 -0
  163. package/dist/synced/syncedStore.js +43 -0
  164. package/dist/synced/syncedStore.js.map +1 -0
  165. package/{src/ui/node.ts → dist/ui/node.d.ts} +3 -3
  166. package/dist/ui/node.d.ts.map +1 -0
  167. package/dist/ui/node.js +2 -0
  168. package/dist/ui/node.js.map +1 -0
  169. package/{src/ui/trigger.ts → dist/ui/trigger.d.ts} +2 -1
  170. package/dist/ui/trigger.d.ts.map +1 -0
  171. package/dist/ui/trigger.js +2 -0
  172. package/dist/ui/trigger.js.map +1 -0
  173. package/dist/wire/tree.d.ts +66 -0
  174. package/dist/wire/tree.d.ts.map +1 -0
  175. package/dist/wire/tree.js +60 -0
  176. package/dist/wire/tree.js.map +1 -0
  177. package/dist/wire/triggers.d.ts +44 -0
  178. package/dist/wire/triggers.d.ts.map +1 -0
  179. package/dist/wire/triggers.js +31 -0
  180. package/dist/wire/triggers.js.map +1 -0
  181. package/package.json +32 -11
  182. package/src/boundary/boundary.ts +0 -192
  183. package/src/calc/asyncCalc.ts +0 -267
  184. package/src/calc/calc.ts +0 -120
  185. package/src/calc/calcFamily.ts +0 -194
  186. package/src/calc/compose.ts +0 -69
  187. package/src/channel/channel.ts +0 -265
  188. package/src/compose/composition.ts +0 -112
  189. package/src/compose/provide.ts +0 -70
  190. package/src/compose/ui.ts +0 -97
  191. package/src/definition/definition.ts +0 -74
  192. package/src/event/event.ts +0 -65
  193. package/src/event/eventGroup.ts +0 -14
  194. package/src/index.ts +0 -140
  195. package/src/internal/errors.ts +0 -69
  196. package/src/internal/inspect.ts +0 -34
  197. package/src/internal/queryDriver.ts +0 -247
  198. package/src/internal/reuse.ts +0 -73
  199. package/src/internal/scheduler.ts +0 -91
  200. package/src/internal/sources.ts +0 -104
  201. package/src/internal/store.ts +0 -105
  202. package/src/procedure/procedure.ts +0 -89
  203. package/src/reducer/reducer.ts +0 -137
  204. package/src/remote/remoteState.ts +0 -571
  205. package/src/runtime/loop.ts +0 -169
  206. package/src/scene/scene.ts +0 -76
  207. package/src/state/state.ts +0 -91
  208. package/src/state/stateFamily.ts +0 -171
  209. package/src/state/stateGroup.ts +0 -78
@@ -0,0 +1,58 @@
1
+ import { Context, Effect, Layer, MutableRef } from 'effect';
2
+ import { yieldableClass } from '../definition/definition';
3
+ import { sameKey, wireSources, } from '../internal/sources';
4
+ import { resolveScheduler } from '../internal/scheduler';
5
+ import { reuse } from '../internal/reuse';
6
+ import { makeDerivedStore } from '../internal/store';
7
+ import { readTracked } from '../internal/track';
8
+ import {} from '../state/token';
9
+ // Re-exported so `Calc.InputsObject` / `Calc.InvalidateBy` keep their home here
10
+ // even though the reactive plumbing now lives in `internal/sources`.
11
+ export {} from '../internal/sources';
12
+ /**
13
+ * A derived, memoized value over explicit inputs (state members, other calcs, or
14
+ * async calcs). The *definition* fixes the inputs and the output schema; the
15
+ * *implementation* is the pure projection. Recomputes only when an input changes;
16
+ * `yield* Calc` reads the memoized value.
17
+ */
18
+ export const make = (name, config) => {
19
+ const store = Context.GenericTag(`reform/calc/${name}`);
20
+ const manifest = { kind: 'Calc', name, output: config.output };
21
+ const read = Effect.flatMap(store, readTracked);
22
+ return yieldableClass(read, { manifest, store, name, inputs: config.inputs });
23
+ };
24
+ /**
25
+ * Wire the pure projection for a calc. Recomputes only when its invalidation key
26
+ * changes (by default every input value; override with `invalidateBy`), memoized
27
+ * on that key; `yield* Calc` reads the memoized value. The derived store reuses
28
+ * the shared coalescing scheduler, so a recompute that yields an equal value
29
+ * wakes no subscriber.
30
+ */
31
+ export const live = (calc, compute, options = {}) =>
32
+ // Scoped so the source subscriptions are released when the layer's scope
33
+ // closes (each proof/test builds and disposes its own runtime).
34
+ Layer.scoped(calc.store, Effect.gen(function* () {
35
+ const scheduler = yield* resolveScheduler;
36
+ const sources = yield* wireSources(calc.inputs, options.invalidateBy);
37
+ // Memo cell: key and output captured together so reads are always
38
+ // consistent (no separate output that could lag the key it was computed for).
39
+ const memo = MutableRef.make(undefined);
40
+ const recompute = () => {
41
+ const args = sources.snapshot();
42
+ const key = sources.keyOf(args);
43
+ const prev = MutableRef.get(memo);
44
+ if (prev !== undefined && sameKey(key, prev.key))
45
+ return prev.output;
46
+ const fresh = compute(args);
47
+ // With `reuse`, a recompute that lands value-equal to the previous
48
+ // output returns the previous reference — the derived store's Equal
49
+ // gate then wakes no subscriber at all.
50
+ const output = options.reuse === true && prev !== undefined ? reuse(prev.output, fresh) : fresh;
51
+ MutableRef.set(memo, { key, output });
52
+ return output;
53
+ };
54
+ const derived = makeDerivedStore(recompute, sources.subscribe, scheduler);
55
+ yield* Effect.addFinalizer(() => Effect.sync(derived.unsubscribe));
56
+ return derived.store;
57
+ }));
58
+ //# sourceMappingURL=calc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calc.js","sourceRoot":"","sources":["../../src/calc/calc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAe,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAIL,OAAO,EACP,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAc,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAkB,MAAM,gBAAgB,CAAA;AAE/C,gFAAgF;AAChF,qEAAqE;AACrE,OAAO,EAA0D,MAAM,qBAAqB,CAAA;AA0C5F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,IAAO,EACP,MAA+B,EACJ,EAAE;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAyB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G,OAAO,CAAC,IAAI,CAAC,CAAA;QAC3B,mEAAmE;QACnE,oEAAoE;QACpE,wCAAwC;QACxC,MAAM,MAAM,GACV,OAAO,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAClF,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;QACrC,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACzE,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;IAClE,OAAO,OAAO,CAAC,KAAK,CAAA;AACtB,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,57 @@
1
+ import { Context, Effect, Layer, type Schema } from 'effect';
2
+ import { type Manifest } from '../definition/definition';
3
+ import { type InputsObject, type InputStores, type InvalidateBy } from '../internal/sources';
4
+ import { type FamilyOptions, type FamilyStore } from '../state/stateFamily';
5
+ import { type AnySource } from '../state/token';
6
+ export interface CalcFamilyManifest<N extends string, K, Out> extends Manifest {
7
+ readonly kind: 'CalcFamily';
8
+ readonly name: N;
9
+ readonly key: Schema.Schema<K, any>;
10
+ readonly output: Schema.Schema<Out, any>;
11
+ }
12
+ export interface CalcFamilyClass<out N extends string, out Inputs extends ReadonlyArray<AnySource>, in out K, in out Out> {
13
+ /** Instance carries the key phantom so `Family['Key']` resolves in key types. */
14
+ new (): {
15
+ readonly Key: K;
16
+ };
17
+ readonly manifest: CalcFamilyManifest<N, K, Out>;
18
+ readonly store: Context.Tag<FamilyStore<K, Out>, FamilyStore<K, Out>>;
19
+ /** Marker data read by `CalcFamily.live` and the editor's graph builder. */
20
+ readonly inputs: Inputs;
21
+ }
22
+ export interface CalcFamilyConfig<Inputs extends ReadonlyArray<AnySource>, K, Out> {
23
+ readonly key: Schema.Schema<K, any>;
24
+ readonly inputs: Inputs;
25
+ readonly output: Schema.Schema<Out, any>;
26
+ }
27
+ /**
28
+ * Define a keyed derived value: per-key memoized projections over shared
29
+ * inputs. The *definition* fixes the key/output schemas and the inputs; the
30
+ * *implementation* (the per-key projection) is supplied by `CalcFamily.live`.
31
+ */
32
+ export declare const make: <const N extends string, const Inputs extends ReadonlyArray<AnySource>, K, Out>(name: N, config: CalcFamilyConfig<Inputs, K, Out>) => CalcFamilyClass<N, Inputs, K, Out>;
33
+ /**
34
+ * Read one member by key — `CalcFamily.read(GroupProjection, id)`. Inside a
35
+ * render it subscribes exactly that member's store (unrelated members never
36
+ * wake the subtree); elsewhere it just snapshots — the same one-read-API
37
+ * contract as `StateFamily.read`.
38
+ */
39
+ export declare const read: <N extends string, Inputs extends ReadonlyArray<AnySource>, K, Out>(family: CalcFamilyClass<N, Inputs, K, Out>, key: K) => Effect.Effect<Out, never, FamilyStore<K, Out>>;
40
+ export interface CalcFamilyLiveOptions<Inputs extends ReadonlyArray<AnySource>> extends FamilyOptions {
41
+ /**
42
+ * Family-wide invalidation key over the SHARED inputs (the member key plays
43
+ * no part — it is fixed per member). Same contract as `Calc`'s.
44
+ */
45
+ readonly invalidateBy?: InvalidateBy<Inputs>;
46
+ }
47
+ /**
48
+ * Wire the per-key projection. `compute` is curried — `(key) => (inputs) =>
49
+ * Out` — so per-key construction (closing over key-derived constants) runs once
50
+ * per member while the inner projection runs per recompute. Each member is a
51
+ * lazy derived store over the shared wired sources: memoized on the family's
52
+ * invalidation key, notifying only when its own output moves. Unlike a
53
+ * `StateFamily` entry, a member holds an upstream subscription, so every
54
+ * removal path (forget / clear / eviction / the layer finalizer) releases it.
55
+ */
56
+ export declare const live: <N extends string, Inputs extends ReadonlyArray<AnySource>, K, Out>(family: CalcFamilyClass<N, Inputs, K, Out>, compute: (key: K) => (inputs: InputsObject<Inputs>) => Out, options?: CalcFamilyLiveOptions<Inputs>) => Layer.Layer<FamilyStore<K, Out>, never, InputStores<Inputs>>;
57
+ //# sourceMappingURL=calcFamily.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calcFamily.d.ts","sourceRoot":"","sources":["../../src/calc/calcFamily.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAc,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,0BAA0B,CAAA;AACzE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAW/C,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,CAAE,SAAQ,QAAQ;IAC5E,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACzC;AAED,MAAM,WAAW,eAAe,CAC9B,GAAG,CAAC,CAAC,SAAS,MAAM,EACpB,GAAG,CAAC,MAAM,SAAS,aAAa,CAAC,SAAS,CAAC,EAC3C,EAAE,CAAC,GAAG,CAAC,CAAC,EACR,EAAE,CAAC,GAAG,CAAC,GAAG;IAEV,iFAAiF;IACjF,QAAQ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EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,CACe,CAAA;AAE/D,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,aAAa,CAAC,SAAS,CAAC,CAC5E,SAAQ,aAAa;IACrB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;CAC7C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,GAAG,EACpF,QAAQ,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAC1C,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,GAAG,EAC1D,UAAS,qBAAqB,CAAC,MAAM,CAAM,KAC1C,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAmF3D,CAAA"}
@@ -0,0 +1,124 @@
1
+ import { Context, Effect, Layer, MutableRef } from 'effect';
2
+ import { definitionClass } from '../definition/definition';
3
+ import { sameKey, wireSources, } from '../internal/sources';
4
+ import { resolveScheduler } from '../internal/scheduler';
5
+ import { makeDerivedStore } from '../internal/store';
6
+ import { readTracked } from '../internal/track';
7
+ import {} from '../state/stateFamily';
8
+ import {} from '../state/token';
9
+ /**
10
+ * Define a keyed derived value: per-key memoized projections over shared
11
+ * inputs. The *definition* fixes the key/output schemas and the inputs; the
12
+ * *implementation* (the per-key projection) is supplied by `CalcFamily.live`.
13
+ */
14
+ export const make = (name, config) => {
15
+ const store = Context.GenericTag(`reform/calcFamily/${name}`);
16
+ const manifest = {
17
+ kind: 'CalcFamily',
18
+ name,
19
+ key: config.key,
20
+ output: config.output,
21
+ };
22
+ return definitionClass({
23
+ manifest,
24
+ store,
25
+ inputs: config.inputs,
26
+ });
27
+ };
28
+ /**
29
+ * Read one member by key — `CalcFamily.read(GroupProjection, id)`. Inside a
30
+ * render it subscribes exactly that member's store (unrelated members never
31
+ * wake the subtree); elsewhere it just snapshots — the same one-read-API
32
+ * contract as `StateFamily.read`.
33
+ */
34
+ export const read = (family, key) => Effect.flatMap(family.store, (fs) => readTracked(fs.at(key)));
35
+ /**
36
+ * Wire the per-key projection. `compute` is curried — `(key) => (inputs) =>
37
+ * Out` — so per-key construction (closing over key-derived constants) runs once
38
+ * per member while the inner projection runs per recompute. Each member is a
39
+ * lazy derived store over the shared wired sources: memoized on the family's
40
+ * invalidation key, notifying only when its own output moves. Unlike a
41
+ * `StateFamily` entry, a member holds an upstream subscription, so every
42
+ * removal path (forget / clear / eviction / the layer finalizer) releases it.
43
+ */
44
+ export const live = (family, compute, options = {}) => Layer.scoped(family.store, Effect.gen(function* () {
45
+ const scheduler = yield* resolveScheduler;
46
+ // Wired ONCE for the whole family — members share the sensing surface.
47
+ const sources = yield* wireSources(family.inputs, options.invalidateBy);
48
+ const entries = new Map();
49
+ const evictWhenUnused = options.evictWhenUnused === true;
50
+ // Live subscriber count per key — maintained only when eviction is on.
51
+ const subscribers = new Map();
52
+ const dropEntry = (key) => {
53
+ const entry = entries.get(key);
54
+ if (entry !== undefined)
55
+ entry.unsubscribe();
56
+ entries.delete(key);
57
+ subscribers.delete(key);
58
+ };
59
+ // One member: the same memo block as `Calc.live`, with the key closed over.
60
+ const createMember = (key) => {
61
+ const body = compute(key);
62
+ const memo = MutableRef.make(undefined);
63
+ const recompute = () => {
64
+ const args = sources.snapshot();
65
+ const memoKey = sources.keyOf(args);
66
+ const prev = MutableRef.get(memo);
67
+ if (prev !== undefined && sameKey(memoKey, prev.key))
68
+ return prev.output;
69
+ const output = body(args);
70
+ MutableRef.set(memo, { key: memoKey, output });
71
+ return output;
72
+ };
73
+ return makeDerivedStore(recompute, sources.subscribe, scheduler);
74
+ };
75
+ // The `StateFamily` ref-count idiom: evict on the next microtask once a
76
+ // key falls idle (a same-commit re-subscribe cancels it) — here eviction
77
+ // also releases the member's upstream subscription via `dropEntry`.
78
+ const refCounted = (key, store) => ({
79
+ ...store,
80
+ subscribe: (listener) => {
81
+ subscribers.set(key, (subscribers.get(key) ?? 0) + 1);
82
+ const off = store.subscribe(listener);
83
+ const released = { done: false };
84
+ return () => {
85
+ if (released.done)
86
+ return;
87
+ released.done = true;
88
+ off();
89
+ const remaining = (subscribers.get(key) ?? 1) - 1;
90
+ if (remaining > 0) {
91
+ subscribers.set(key, remaining);
92
+ return;
93
+ }
94
+ subscribers.delete(key);
95
+ queueMicrotask(() => {
96
+ if ((subscribers.get(key) ?? 0) === 0)
97
+ dropEntry(key);
98
+ });
99
+ };
100
+ },
101
+ });
102
+ const familyStore = {
103
+ at: (key) => {
104
+ const existing = entries.get(key);
105
+ if (existing !== undefined)
106
+ return existing.store;
107
+ const member = createMember(key);
108
+ const created = evictWhenUnused
109
+ ? { store: refCounted(key, member.store), unsubscribe: member.unsubscribe }
110
+ : member;
111
+ entries.set(key, created);
112
+ return created.store;
113
+ },
114
+ forget: dropEntry,
115
+ clear: () => {
116
+ for (const key of [...entries.keys()])
117
+ dropEntry(key);
118
+ },
119
+ size: () => entries.size,
120
+ };
121
+ yield* Effect.addFinalizer(() => Effect.sync(() => familyStore.clear()));
122
+ return familyStore;
123
+ }));
124
+ //# sourceMappingURL=calcFamily.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calcFamily.js","sourceRoot":"","sources":["../../src/calc/calcFamily.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAe,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAIL,OAAO,EACP,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MA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AAE,EAAE;YACV,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAC,KAAK,CAAA;YACjD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;YAChC,MAAM,OAAO,GAAG,eAAe;gBAC7B,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE;gBAC3E,CAAC,CAAC,MAAM,CAAA;YACV,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YACzB,OAAO,OAAO,CAAC,KAAK,CAAA;QACtB,CAAC;QACD,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,GAAG,EAAE;YACV,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;gBAAE,SAAS,CAAC,GAAG,CAAC,CAAA;QACvD,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI;KACzB,CAAA;IACD,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACxE,OAAO,WAAW,CAAA;AACpB,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { Layer } from 'effect';
2
+ /**
3
+ * Compose a calc-dependency chain: provide each upstream calc's `.live` layer
4
+ * into the downstream one, nearest dependency first. The result exposes every
5
+ * calc store in the chain and requires only the chain's *external* inputs (the
6
+ * base state stores) — never the intermediate calc stores.
7
+ *
8
+ * Order is leaf-first, then its upstreams in dependency order:
9
+ * `composeCalcs(FilteredLive, AllLive, QueryLive)` ≡
10
+ * `FilteredLive.pipe(Layer.provideMerge(AllLive), Layer.provideMerge(QueryLive))`.
11
+ * For chains deeper than three upstreams, nest `composeCalcs`.
12
+ */
13
+ export declare function composeCalcs<LOut, LErr, LIn, AOut, AErr, AIn>(leaf: Layer.Layer<LOut, LErr, LIn>, upstream: Layer.Layer<AOut, AErr, AIn>): Layer.Layer<LOut | AOut, LErr | AErr, AIn | Exclude<LIn, AOut>>;
14
+ export declare function composeCalcs<LOut, LErr, LIn, AOut, AErr, AIn, BOut, BErr, BIn>(leaf: Layer.Layer<LOut, LErr, LIn>, upstream1: Layer.Layer<AOut, AErr, AIn>, upstream2: Layer.Layer<BOut, BErr, BIn>): Layer.Layer<LOut | AOut | BOut, LErr | AErr | BErr, BIn | Exclude<AIn | Exclude<LIn, AOut>, BOut>>;
15
+ export declare function composeCalcs<LOut, LErr, LIn, AOut, AErr, AIn, BOut, BErr, BIn, COut, CErr, CIn>(leaf: Layer.Layer<LOut, LErr, LIn>, upstream1: Layer.Layer<AOut, AErr, AIn>, upstream2: Layer.Layer<BOut, BErr, BIn>, upstream3: Layer.Layer<COut, CErr, CIn>): Layer.Layer<LOut | AOut | BOut | COut, LErr | AErr | BErr | CErr, CIn | Exclude<BIn | Exclude<AIn | Exclude<LIn, AOut>, BOut>, COut>>;
16
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/calc/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAW9B;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAC3D,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAClC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,GACrC,KAA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,GAAG,IAAI,EACzB,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EACzB,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CACnE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Layer } from 'effect';
2
+ export function composeCalcs(leaf, ...upstream) {
3
+ // Fold leaf-first: each upstream is provided into the accumulated downstream,
4
+ // so dependency order is exactly the argument order.
5
+ return upstream.reduce((downstream, up) => Layer.provideMerge(downstream, up), leaf);
6
+ }
7
+ //# sourceMappingURL=compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/calc/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AA0D9B,MAAM,UAAU,YAAY,CAC1B,IAA4C,EAC5C,GAAG,QAA+D;IAElE,8EAA8E;IAC9E,qDAAqD;IACrD,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,EACtD,IAAI,CACL,CAAA;AACH,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { Context, type Duration, Effect, Layer } from 'effect';
2
+ import { type Manifest } from '../definition/definition';
3
+ import type { Tagged } from '../runtime/bus';
4
+ /**
5
+ * How a channel schedules the procedure work routed to it. Channels generalize
6
+ * the old per-procedure `concurrency`: a named lane with one policy, shared by
7
+ * every procedure that declares it.
8
+ *
9
+ * - `merge` run every routed event concurrently (the default).
10
+ * - `latest` a new event cancels the in-flight run (switch).
11
+ * - `debounce` collapse a burst, run only after `duration` of quiet.
12
+ * - `throttle` rate-limit to `units` per `duration` (shape or enforce).
13
+ * - `exclusive` one run at a time across the whole channel (mutual exclusion).
14
+ */
15
+ export type ChannelPolicy = {
16
+ readonly _tag: 'merge';
17
+ } | {
18
+ readonly _tag: 'latest';
19
+ } | {
20
+ readonly _tag: 'debounce';
21
+ readonly duration: Duration.DurationInput;
22
+ } | {
23
+ readonly _tag: 'throttle';
24
+ readonly units: number;
25
+ readonly duration: Duration.DurationInput;
26
+ readonly cost?: number;
27
+ readonly burst?: number;
28
+ readonly strategy?: 'enforce' | 'shape';
29
+ } | {
30
+ readonly _tag: 'exclusive';
31
+ };
32
+ /** The reflectable descriptor a channel carries. */
33
+ export interface ChannelManifest extends Manifest {
34
+ readonly kind: 'Channel';
35
+ }
36
+ export interface ChannelClass {
37
+ new (): {};
38
+ readonly manifest: ChannelManifest;
39
+ readonly policy: ChannelPolicy;
40
+ }
41
+ export interface ChannelConfig {
42
+ readonly policy: ChannelPolicy;
43
+ }
44
+ /**
45
+ * A registered procedure body, with its trigger events and the channel it runs
46
+ * on. `run`'s context (RPC clients, etc.) is already provided at registration
47
+ * (see `Procedure.live`), so the channel fiber can run it with no R.
48
+ */
49
+ export interface ProcedureEntry {
50
+ /** The procedure's name — used only to warn on duplicate registration. */
51
+ readonly name: string;
52
+ readonly channelName: string;
53
+ readonly handles: ReadonlySet<string>;
54
+ readonly run: (event: Tagged) => Effect.Effect<unknown, unknown, never>;
55
+ }
56
+ /**
57
+ * Mutable collector procedures register into; channels read it to find their
58
+ * bodies. `byTag` indexes entries by trigger tag, so a channel routes an event
59
+ * to O(procedures handling it) rather than scanning every registered procedure.
60
+ */
61
+ export interface ProcedureRegistry {
62
+ readonly entries: Array<ProcedureEntry>;
63
+ readonly byTag: Map<string, Array<ProcedureEntry>>;
64
+ /**
65
+ * Distinct channel names per event tag. The drain loop routes through this so
66
+ * it offers each event to each channel exactly once — not once per matching
67
+ * procedure, which would re-run every procedure on a shared channel per offer.
68
+ */
69
+ readonly channelsByTag: Map<string, Array<string>>;
70
+ /**
71
+ * Procedures keyed by (channel, tag), so a channel's `runMatching` is a direct
72
+ * lookup instead of scanning `byTag` and re-filtering by channel per event.
73
+ */
74
+ readonly byChannelTag: Map<string, Map<string, Array<ProcedureEntry>>>;
75
+ readonly register: (entry: ProcedureEntry) => void;
76
+ /**
77
+ * Remove a previously-registered entry — the inverse of `register`, used when a
78
+ * lazy feature unmounts (scope close) so its procedures stop running and their
79
+ * index entries are reclaimed. Eager procedures (root scope) never call it.
80
+ */
81
+ readonly unregister: (entry: ProcedureEntry) => void;
82
+ }
83
+ declare const ProceduresBase: Context.TagClass<Procedures, 'reform/Procedures', ProcedureRegistry>;
84
+ export declare class Procedures extends ProceduresBase {
85
+ }
86
+ export declare const proceduresLayer: Layer.Layer<Procedures>;
87
+ /** A live channel: the single loop offers events here; the channel drives them. */
88
+ export interface ChannelRuntime {
89
+ readonly name: string;
90
+ /** The policy this channel was built with — used to reject a name clash. */
91
+ readonly policy: ChannelPolicy;
92
+ readonly offer: (event: Tagged) => void;
93
+ }
94
+ /** Registry of live channels, keyed by name. The single loop routes through it. */
95
+ declare const ChannelsBase: Context.TagClass<Channels, 'reform/Channels', {
96
+ readonly byName: Map<string, ChannelRuntime>;
97
+ }>;
98
+ export declare class Channels extends ChannelsBase {
99
+ }
100
+ export declare const channelsLayer: Layer.Layer<Channels>;
101
+ /**
102
+ * A scheduling lane for procedures. The *definition* (`Channel.make`) is a
103
+ * reflectable name + policy; the *implementation* (`Channel.live`) builds the
104
+ * queue + fiber that applies the policy. Procedures reference a channel by value
105
+ * and register into it; `Channel.live` is merged into the app once per channel.
106
+ */
107
+ export declare const make: (name: string, config: ChannelConfig) => ChannelClass;
108
+ /**
109
+ * Build and register the live machinery for a channel. Idempotent by name, so
110
+ * procedures sharing an `exclusive`/`latest` channel share one queue + fiber +
111
+ * semaphore (and therefore truly serialize / cancel across each other).
112
+ */
113
+ export declare const live: (channel: ChannelClass) => Layer.Layer<never, never, Channels | Procedures>;
114
+ export {};
115
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"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4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAED,mFAAmF;AACnF,QAAA,MAAM,YAAY,EAAE,OAAO,CAAC,QAAQ,CAClC,QAAQ,EACR,iBAAiB,EACjB;IAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CAAE,CAC8C,CAAA;AAChG,qBAAa,QAAS,SAAQ,YAAY;CAAG;AAE7C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAuD,CAAA;AAEvG;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,QAAQ,aAAa,KAAG,YAIvD,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,SAAS,YAAY,KAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,UAAU,CAoFzF,CAAA"}
@@ -0,0 +1,138 @@
1
+ import { Chunk, Context, Effect, Layer, Match, Queue, Stream } from 'effect';
2
+ import { definitionClass } from '../definition/definition';
3
+ import { DuplicateRegistration } from '../internal/errors';
4
+ const ProceduresBase = Context.Tag('reform/Procedures')();
5
+ export class Procedures extends ProceduresBase {
6
+ }
7
+ /** Get a map entry, creating and inserting it on first access (avoids `let`). */
8
+ const getOrCreate = (map, key, make) => {
9
+ const existing = map.get(key);
10
+ if (existing !== undefined)
11
+ return existing;
12
+ const created = make();
13
+ map.set(key, created);
14
+ return created;
15
+ };
16
+ /** Drop an item from a `Map<K, Array>` bucket, pruning the key when it empties. */
17
+ const dropFrom = (map, key, item) => {
18
+ const bucket = map.get(key);
19
+ if (bucket === undefined)
20
+ return;
21
+ const next = bucket.filter((value) => value !== item);
22
+ if (next.length === 0)
23
+ map.delete(key);
24
+ else
25
+ map.set(key, next);
26
+ };
27
+ const makeProcedureRegistry = () => {
28
+ const entries = [];
29
+ const byTag = new Map();
30
+ const channelsByTag = new Map();
31
+ const byChannelTag = new Map();
32
+ return {
33
+ entries,
34
+ byTag,
35
+ channelsByTag,
36
+ byChannelTag,
37
+ register: (entry) => {
38
+ entries.push(entry);
39
+ for (const tag of entry.handles) {
40
+ getOrCreate(byTag, tag, () => []).push(entry);
41
+ const channels = getOrCreate(channelsByTag, tag, () => []);
42
+ if (!channels.includes(entry.channelName))
43
+ channels.push(entry.channelName);
44
+ getOrCreate(getOrCreate(byChannelTag, entry.channelName, () => new Map()), tag, () => []).push(entry);
45
+ }
46
+ },
47
+ unregister: (entry) => {
48
+ const index = entries.indexOf(entry);
49
+ if (index >= 0)
50
+ entries.splice(index, 1);
51
+ for (const tag of entry.handles) {
52
+ dropFrom(byTag, tag, entry);
53
+ const channelMap = byChannelTag.get(entry.channelName);
54
+ if (channelMap !== undefined) {
55
+ dropFrom(channelMap, tag, entry);
56
+ // If no procedure on this channel still handles the tag, drop the
57
+ // channel from `channelsByTag[tag]` so the loop stops offering to it.
58
+ if (channelMap.get(tag) === undefined)
59
+ dropFrom(channelsByTag, tag, entry.channelName);
60
+ if (channelMap.size === 0)
61
+ byChannelTag.delete(entry.channelName);
62
+ }
63
+ }
64
+ },
65
+ };
66
+ };
67
+ export const proceduresLayer = Layer.sync(Procedures, makeProcedureRegistry);
68
+ /** Registry of live channels, keyed by name. The single loop routes through it. */
69
+ const ChannelsBase = Context.Tag('reform/Channels')();
70
+ export class Channels extends ChannelsBase {
71
+ }
72
+ export const channelsLayer = Layer.sync(Channels, () => ({ byName: new Map() }));
73
+ /**
74
+ * A scheduling lane for procedures. The *definition* (`Channel.make`) is a
75
+ * reflectable name + policy; the *implementation* (`Channel.live`) builds the
76
+ * queue + fiber that applies the policy. Procedures reference a channel by value
77
+ * and register into it; `Channel.live` is merged into the app once per channel.
78
+ */
79
+ export const make = (name, config) => definitionClass({
80
+ manifest: { kind: 'Channel', name },
81
+ policy: config.policy,
82
+ });
83
+ /**
84
+ * Build and register the live machinery for a channel. Idempotent by name, so
85
+ * procedures sharing an `exclusive`/`latest` channel share one queue + fiber +
86
+ * semaphore (and therefore truly serialize / cancel across each other).
87
+ */
88
+ export const live = (channel) => Layer.scopedDiscard(Effect.gen(function* () {
89
+ const name = channel.manifest.name;
90
+ const channels = yield* Channels;
91
+ const existing = channels.byName.get(name);
92
+ if (existing !== undefined) {
93
+ // Idempotent for the *same* channel `.live`'d through several sub-layers
94
+ // (shared `exclusive`/`latest` lane). A *different* channel reusing the
95
+ // name is a silent footgun — the second policy would be dropped — so
96
+ // reject it loudly instead.
97
+ if (existing.policy !== channel.policy) {
98
+ throw new DuplicateRegistration({ kind: 'Channel', name });
99
+ }
100
+ return;
101
+ }
102
+ const procedures = yield* Procedures;
103
+ const queue = yield* Queue.unbounded();
104
+ // Run every procedure on THIS channel that handles the event. Read the live
105
+ // index each time so procedures registered later are still seen.
106
+ // A procedure is expected to model expected failures as events; a leaked
107
+ // defect (a bug in the body) is logged before being isolated, so one
108
+ // procedure's crash never tears down the channel fiber — but is observable.
109
+ const runMatching = (event) => Effect.forEach(procedures.byChannelTag.get(name)?.get(event._tag) ?? [], (e) => e.run(event).pipe(Effect.tapErrorCause((cause) => Effect.logError(`reform: procedure on channel '${name}' failed`, cause)), Effect.catchAllCause(() => Effect.void)), { discard: true, concurrency: 'unbounded' });
110
+ // Map the policy to its scheduling stream. `Match.exhaustive` makes a new
111
+ // policy variant a compile error, and each arm is a self-contained const.
112
+ const events = Stream.fromQueue(queue);
113
+ const driven = Match.value(channel.policy).pipe(Match.tag('merge', () => Stream.mapEffect(events, runMatching, { concurrency: 'unbounded' })), Match.tag('latest', () => Stream.flatMap(events, (e) => Stream.fromEffect(runMatching(e)), { switch: true })), Match.tag('debounce', (policy) => events.pipe(Stream.debounce(policy.duration), Stream.mapEffect(runMatching, { concurrency: 'unbounded' }))), Match.tag('throttle', (policy) => events.pipe(Stream.throttle({
114
+ cost: (chunk) => Chunk.size(chunk) * (policy.cost ?? 1),
115
+ units: policy.units,
116
+ duration: policy.duration,
117
+ ...(policy.burst !== undefined ? { burst: policy.burst } : {}),
118
+ strategy: policy.strategy ?? 'shape',
119
+ }), Stream.mapEffect(runMatching, { concurrency: 'unbounded' }))),
120
+ // `concurrency: 1` runs one event at a time AND in offer order — a true
121
+ // serialized lane. (An unbounded fork racing for a single semaphore permit
122
+ // would serialize but could reorder under contention.)
123
+ Match.tag('exclusive', () => Stream.mapEffect(events, runMatching, { concurrency: 1 })), Match.exhaustive);
124
+ yield* Effect.forkScoped(Stream.runDrain(driven));
125
+ channels.byName.set(name, {
126
+ name,
127
+ policy: channel.policy,
128
+ offer: (event) => {
129
+ Queue.unsafeOffer(queue, event);
130
+ },
131
+ });
132
+ // On scope close (a lazy feature unmounting) remove the live channel so the
133
+ // loop stops routing to it; the drain fiber is already torn down by
134
+ // `forkScoped`. Eager channels live on the root scope, so this is a no-op
135
+ // until app dispose.
136
+ yield* Effect.addFinalizer(() => Effect.sync(() => channels.byName.delete(name)));
137
+ }));
138
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/channel/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAiB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC3F,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAoF1D,MAAM,cAAc,GAClB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAiC,CAAA;AACnE,MAAM,OAAO,UAAW,SAAQ,cAAc;CAAG;AAEjD,iFAAiF;AACjF,MAAM,WAAW,GAAG,CAAO,GAAc,EAAE,GAAM,EAAE,IAAa,EAAK,EAAE;IACrE,MAAM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