@playfast/reform 0.0.7 → 0.0.9

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 (241) 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 +146 -0
  15. package/src/compose/host.ts +12 -0
  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/structure.test.ts +90 -0
  20. package/src/compose/structure.ts +145 -0
  21. package/src/compose/ui.test.ts +34 -0
  22. package/src/compose/ui.ts +204 -0
  23. package/src/compose/ui.typecheck.ts +56 -0
  24. package/src/definition/definition.ts +76 -0
  25. package/src/event/event.test.ts +23 -0
  26. package/src/event/event.ts +65 -0
  27. package/src/event/eventGroup.ts +14 -0
  28. package/src/feature/feature.mount.test.ts +82 -0
  29. package/src/feature/feature.test.ts +60 -0
  30. package/{dist/feature/feature.d.ts → src/feature/feature.ts} +178 -92
  31. package/src/feature/feature.typecheck.ts +108 -0
  32. package/src/index.ts +191 -0
  33. package/src/internal/capture.ts +38 -0
  34. package/{dist/internal/ctx.d.ts → src/internal/ctx.ts} +8 -4
  35. package/src/internal/errors.test.ts +33 -0
  36. package/src/internal/errors.ts +133 -0
  37. package/src/internal/inspect.test.ts +28 -0
  38. package/src/internal/inspect.ts +34 -0
  39. package/src/internal/queryDriver.ts +247 -0
  40. package/src/internal/reuse.test.ts +116 -0
  41. package/src/internal/reuse.ts +73 -0
  42. package/src/internal/scheduler.ts +93 -0
  43. package/{dist/internal/seeds.d.ts → src/internal/seeds.ts} +6 -3
  44. package/src/internal/sources.ts +104 -0
  45. package/{dist/internal/stateRegistry.js → src/internal/stateRegistry.ts} +18 -14
  46. package/src/internal/store.test.ts +80 -0
  47. package/src/internal/store.ts +105 -0
  48. package/{dist/internal/track.d.ts → src/internal/track.ts} +17 -11
  49. package/src/procedure/procedure.ts +89 -0
  50. package/src/reducer/reducer.ts +137 -0
  51. package/src/remote/remoteState.test.ts +695 -0
  52. package/src/remote/remoteState.ts +571 -0
  53. package/src/remote/remoteState.typecheck.ts +195 -0
  54. package/src/runtime/bus.ts +40 -0
  55. package/src/runtime/hardening.test.ts +69 -0
  56. package/src/runtime/loop.test.ts +178 -0
  57. package/src/runtime/loop.ts +171 -0
  58. package/src/scene/scene.ts +88 -0
  59. package/src/scene/seedScene.test.ts +176 -0
  60. package/src/state/state.ts +94 -0
  61. package/src/state/stateFamily.test.ts +138 -0
  62. package/src/state/stateFamily.ts +174 -0
  63. package/src/state/stateGroup.ts +125 -0
  64. package/{dist/state/token.d.ts → src/state/token.ts} +22 -13
  65. package/src/synced/syncedStore.ts +99 -0
  66. package/{dist/ui/node.d.ts → src/ui/node.ts} +3 -3
  67. package/{dist/ui/trigger.d.ts → src/ui/trigger.ts} +1 -2
  68. package/src/wire/tree.test.ts +81 -0
  69. package/src/wire/tree.ts +129 -0
  70. package/src/wire/triggers.test.ts +76 -0
  71. package/src/wire/triggers.ts +98 -0
  72. package/dist/boundary/boundary.d.ts +0 -72
  73. package/dist/boundary/boundary.d.ts.map +0 -1
  74. package/dist/boundary/boundary.js +0 -83
  75. package/dist/boundary/boundary.js.map +0 -1
  76. package/dist/calc/asyncCalc.d.ts +0 -91
  77. package/dist/calc/asyncCalc.d.ts.map +0 -1
  78. package/dist/calc/asyncCalc.js +0 -95
  79. package/dist/calc/asyncCalc.js.map +0 -1
  80. package/dist/calc/asyncData.d.ts +0 -57
  81. package/dist/calc/asyncData.d.ts.map +0 -1
  82. package/dist/calc/asyncData.js +0 -34
  83. package/dist/calc/asyncData.js.map +0 -1
  84. package/dist/calc/calc.d.ts +0 -57
  85. package/dist/calc/calc.d.ts.map +0 -1
  86. package/dist/calc/calc.js +0 -58
  87. package/dist/calc/calc.js.map +0 -1
  88. package/dist/calc/calcFamily.d.ts +0 -57
  89. package/dist/calc/calcFamily.d.ts.map +0 -1
  90. package/dist/calc/calcFamily.js +0 -124
  91. package/dist/calc/calcFamily.js.map +0 -1
  92. package/dist/calc/compose.d.ts +0 -16
  93. package/dist/calc/compose.d.ts.map +0 -1
  94. package/dist/calc/compose.js +0 -7
  95. package/dist/calc/compose.js.map +0 -1
  96. package/dist/channel/channel.d.ts +0 -115
  97. package/dist/channel/channel.d.ts.map +0 -1
  98. package/dist/channel/channel.js +0 -138
  99. package/dist/channel/channel.js.map +0 -1
  100. package/dist/compose/composition.d.ts +0 -72
  101. package/dist/compose/composition.d.ts.map +0 -1
  102. package/dist/compose/composition.js +0 -46
  103. package/dist/compose/composition.js.map +0 -1
  104. package/dist/compose/host.d.ts +0 -17
  105. package/dist/compose/host.d.ts.map +0 -1
  106. package/dist/compose/host.js +0 -6
  107. package/dist/compose/host.js.map +0 -1
  108. package/dist/compose/props.d.ts +0 -13
  109. package/dist/compose/props.d.ts.map +0 -1
  110. package/dist/compose/props.js.map +0 -1
  111. package/dist/compose/provide.d.ts +0 -22
  112. package/dist/compose/provide.d.ts.map +0 -1
  113. package/dist/compose/provide.js +0 -28
  114. package/dist/compose/provide.js.map +0 -1
  115. package/dist/compose/slot.d.ts.map +0 -1
  116. package/dist/compose/slot.js +0 -23
  117. package/dist/compose/slot.js.map +0 -1
  118. package/dist/compose/ui.d.ts +0 -135
  119. package/dist/compose/ui.d.ts.map +0 -1
  120. package/dist/compose/ui.js +0 -63
  121. package/dist/compose/ui.js.map +0 -1
  122. package/dist/definition/definition.d.ts +0 -33
  123. package/dist/definition/definition.d.ts.map +0 -1
  124. package/dist/definition/definition.js +0 -42
  125. package/dist/definition/definition.js.map +0 -1
  126. package/dist/event/event.d.ts +0 -33
  127. package/dist/event/event.d.ts.map +0 -1
  128. package/dist/event/event.js +0 -30
  129. package/dist/event/event.js.map +0 -1
  130. package/dist/event/eventGroup.d.ts +0 -9
  131. package/dist/event/eventGroup.d.ts.map +0 -1
  132. package/dist/event/eventGroup.js +0 -4
  133. package/dist/event/eventGroup.js.map +0 -1
  134. package/dist/feature/feature.d.ts.map +0 -1
  135. package/dist/feature/feature.js +0 -98
  136. package/dist/feature/feature.js.map +0 -1
  137. package/dist/index.d.ts +0 -53
  138. package/dist/index.d.ts.map +0 -1
  139. package/dist/index.js +0 -62
  140. package/dist/index.js.map +0 -1
  141. package/dist/internal/capture.d.ts +0 -28
  142. package/dist/internal/capture.d.ts.map +0 -1
  143. package/dist/internal/capture.js +0 -12
  144. package/dist/internal/capture.js.map +0 -1
  145. package/dist/internal/ctx.d.ts.map +0 -1
  146. package/dist/internal/ctx.js +0 -2
  147. package/dist/internal/ctx.js.map +0 -1
  148. package/dist/internal/errors.d.ts +0 -89
  149. package/dist/internal/errors.d.ts.map +0 -1
  150. package/dist/internal/errors.js +0 -102
  151. package/dist/internal/errors.js.map +0 -1
  152. package/dist/internal/inspect.d.ts +0 -17
  153. package/dist/internal/inspect.d.ts.map +0 -1
  154. package/dist/internal/inspect.js +0 -32
  155. package/dist/internal/inspect.js.map +0 -1
  156. package/dist/internal/queryDriver.d.ts +0 -65
  157. package/dist/internal/queryDriver.d.ts.map +0 -1
  158. package/dist/internal/queryDriver.js +0 -134
  159. package/dist/internal/queryDriver.js.map +0 -1
  160. package/dist/internal/reuse.d.ts +0 -10
  161. package/dist/internal/reuse.d.ts.map +0 -1
  162. package/dist/internal/reuse.js +0 -68
  163. package/dist/internal/reuse.js.map +0 -1
  164. package/dist/internal/scheduler.d.ts +0 -47
  165. package/dist/internal/scheduler.d.ts.map +0 -1
  166. package/dist/internal/scheduler.js +0 -70
  167. package/dist/internal/scheduler.js.map +0 -1
  168. package/dist/internal/seeds.d.ts.map +0 -1
  169. package/dist/internal/seeds.js +0 -17
  170. package/dist/internal/seeds.js.map +0 -1
  171. package/dist/internal/sources.d.ts +0 -39
  172. package/dist/internal/sources.d.ts.map +0 -1
  173. package/dist/internal/sources.js +0 -59
  174. package/dist/internal/sources.js.map +0 -1
  175. package/dist/internal/stateRegistry.d.ts +0 -2
  176. package/dist/internal/stateRegistry.d.ts.map +0 -1
  177. package/dist/internal/stateRegistry.js.map +0 -1
  178. package/dist/internal/store.d.ts +0 -47
  179. package/dist/internal/store.d.ts.map +0 -1
  180. package/dist/internal/store.js +0 -73
  181. package/dist/internal/store.js.map +0 -1
  182. package/dist/internal/track.d.ts.map +0 -1
  183. package/dist/internal/track.js +0 -19
  184. package/dist/internal/track.js.map +0 -1
  185. package/dist/procedure/procedure.d.ts +0 -40
  186. package/dist/procedure/procedure.d.ts.map +0 -1
  187. package/dist/procedure/procedure.js +0 -50
  188. package/dist/procedure/procedure.js.map +0 -1
  189. package/dist/reducer/reducer.d.ts +0 -44
  190. package/dist/reducer/reducer.d.ts.map +0 -1
  191. package/dist/reducer/reducer.js +0 -63
  192. package/dist/reducer/reducer.js.map +0 -1
  193. package/dist/remote/remoteState.d.ts +0 -119
  194. package/dist/remote/remoteState.d.ts.map +0 -1
  195. package/dist/remote/remoteState.js +0 -270
  196. package/dist/remote/remoteState.js.map +0 -1
  197. package/dist/runtime/bus.d.ts +0 -27
  198. package/dist/runtime/bus.d.ts.map +0 -1
  199. package/dist/runtime/bus.js +0 -21
  200. package/dist/runtime/bus.js.map +0 -1
  201. package/dist/runtime/loop.d.ts +0 -45
  202. package/dist/runtime/loop.d.ts.map +0 -1
  203. package/dist/runtime/loop.js +0 -117
  204. package/dist/runtime/loop.js.map +0 -1
  205. package/dist/scene/scene.d.ts +0 -44
  206. package/dist/scene/scene.d.ts.map +0 -1
  207. package/dist/scene/scene.js +0 -31
  208. package/dist/scene/scene.js.map +0 -1
  209. package/dist/state/state.d.ts +0 -37
  210. package/dist/state/state.d.ts.map +0 -1
  211. package/dist/state/state.js +0 -46
  212. package/dist/state/state.js.map +0 -1
  213. package/dist/state/stateFamily.d.ts +0 -79
  214. package/dist/state/stateFamily.d.ts.map +0 -1
  215. package/dist/state/stateFamily.js +0 -99
  216. package/dist/state/stateFamily.js.map +0 -1
  217. package/dist/state/stateGroup.d.ts +0 -50
  218. package/dist/state/stateGroup.d.ts.map +0 -1
  219. package/dist/state/stateGroup.js +0 -54
  220. package/dist/state/stateGroup.js.map +0 -1
  221. package/dist/state/token.d.ts.map +0 -1
  222. package/dist/state/token.js +0 -20
  223. package/dist/state/token.js.map +0 -1
  224. package/dist/synced/syncedStore.d.ts +0 -51
  225. package/dist/synced/syncedStore.d.ts.map +0 -1
  226. package/dist/synced/syncedStore.js +0 -43
  227. package/dist/synced/syncedStore.js.map +0 -1
  228. package/dist/ui/node.d.ts.map +0 -1
  229. package/dist/ui/node.js +0 -2
  230. package/dist/ui/node.js.map +0 -1
  231. package/dist/ui/trigger.d.ts.map +0 -1
  232. package/dist/ui/trigger.js +0 -2
  233. package/dist/ui/trigger.js.map +0 -1
  234. package/dist/wire/tree.d.ts +0 -66
  235. package/dist/wire/tree.d.ts.map +0 -1
  236. package/dist/wire/tree.js +0 -60
  237. package/dist/wire/tree.js.map +0 -1
  238. package/dist/wire/triggers.d.ts +0 -44
  239. package/dist/wire/triggers.d.ts.map +0 -1
  240. package/dist/wire/triggers.js +0 -31
  241. package/dist/wire/triggers.js.map +0 -1
@@ -1,72 +0,0 @@
1
- import { Context, Effect, Layer, type Schema } from 'effect';
2
- import type { YieldWrap } from 'effect/Utils';
3
- import { type Manifest } from '../definition/definition';
4
- import { type Ctx } from '../internal/ctx';
5
- import type { Tracker } from '../internal/track';
6
- import { type SlotHost } from './host';
7
- import type { Node, SlotClass } from './slot';
8
- import type { UiClass, UiContract } from './ui';
9
- import { Props } from './props';
10
- /** Everything the host injects per render: the instance props, the dependency tracker, and slot bindings. */
11
- export interface RenderEnv {
12
- readonly props: unknown;
13
- readonly tracker: Tracker;
14
- readonly slots: SlotHost;
15
- }
16
- /** A mounted composition: given a render environment, produces the current frame's node. */
17
- export interface CompositionService {
18
- readonly render: (env: RenderEnv) => Effect.Effect<Node, never, never>;
19
- }
20
- export interface CompositionConfig {
21
- readonly title: string;
22
- readonly description?: string;
23
- readonly props?: Schema.Schema<any, any>;
24
- readonly states?: ReadonlyArray<unknown>;
25
- readonly calcs?: ReadonlyArray<unknown>;
26
- readonly events?: ReadonlyArray<unknown>;
27
- readonly slots?: Record<string, SlotClass>;
28
- readonly ui: {
29
- readonly manifest: Manifest & {
30
- readonly kind: 'Ui';
31
- };
32
- };
33
- }
34
- type PropsOf<Config> = Config extends {
35
- props: Schema.Schema<infer P, any>;
36
- } ? P : unknown;
37
- export interface CompositionClass<out P, out C extends UiContract = UiContract> {
38
- new (): {};
39
- readonly manifest: Manifest & {
40
- readonly kind: 'Composition';
41
- } & CompositionConfig;
42
- /** Phantom carrying the props type for `provide(slot, composition)` checks. */
43
- readonly Props: P;
44
- /**
45
- * Phantom carrying the resolved UI contract (props + events + slots). It lets
46
- * reflection consumers — proofs, the dev tool — recover the full contract from
47
- * a composition value and stay fully typed. Covariant (output only); the
48
- * invariant `impl` tag is never stored here, so no variance regression.
49
- */
50
- readonly Contract: C;
51
- readonly tag: Context.Tag<CompositionService, CompositionService>;
52
- }
53
- /**
54
- * A component's logic. The *definition* (`Composition.make`) is a reflectable
55
- * manifest that doubles as a requirement/tag; the *implementation*
56
- * (`Composition.live`) is the synchronous body, provided separately and
57
- * checked against it.
58
- */
59
- export declare const make: <const Config extends CompositionConfig, C extends UiContract>(name: string, config: Config & {
60
- readonly ui: UiClass<C>;
61
- }) => CompositionClass<PropsOf<Config>, C>;
62
- /**
63
- * Wire a composition's synchronous logic (D2): read state, acquire triggers,
64
- * resolve the UI, return the view. Its requirements (minus `Props`, which the
65
- * host injects per render) surface as the Layer's `RIn`; the runtime runs the
66
- * body per render within the captured context.
67
- */
68
- export declare const live: <P, Eff extends YieldWrap<Effect.Effect<unknown, never, unknown>>>(composition: CompositionClass<P, any>, body: () => Generator<Eff, Node, never>) => Layer.Layer<CompositionService, never, Exclude<Ctx<Eff>, Props>>;
69
- /** Run a mounted composition for one frame, producing its node. */
70
- export declare const render: (service: CompositionService, env: RenderEnv) => Effect.Effect<Node, never, never>;
71
- export {};
72
- //# sourceMappingURL=composition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/compose/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,6GAA6G;AAC7G,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CACzB;AAED,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MA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;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAA;CAClE;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,MAAM,SAAS,iBAAiB,EAAE,CAAC,SAAS,UAAU,EAC/E,MAAM,MAAM,EAIZ,QAAQ,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAAE,KAC3C,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAMrC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAEnF,aAAa,gBAAgB,CAAC,CAAC,EAAE,GAAG,CAAC,EACrC,MAAM,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,KACtC,KAAK,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAqBjE,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,MAAM,GAAI,SAAS,kBAAkB,EAAE,KAAK,SAAS,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAChF,CAAA"}
@@ -1,46 +0,0 @@
1
- import { Context, Effect, Layer } from 'effect';
2
- import { definitionClass } from '../definition/definition';
3
- import {} from '../internal/ctx';
4
- import { CurrentTracker } from '../internal/track';
5
- import { CurrentSlots } from './host';
6
- import { Props } from './props';
7
- /**
8
- * A component's logic. The *definition* (`Composition.make`) is a reflectable
9
- * manifest that doubles as a requirement/tag; the *implementation*
10
- * (`Composition.live`) is the synchronous body, provided separately and
11
- * checked against it.
12
- */
13
- export const make = (name,
14
- // Constrain `ui` to the full `UiClass<C>` so `C` is inferred here; the stored
15
- // manifest still sees only the erased `{ manifest }` carrier (CompositionConfig),
16
- // so the manifest type — and its variance — is unchanged.
17
- config) => {
18
- const tag = Context.GenericTag(`reform/composition/${name}`);
19
- const manifest = { kind: 'Composition', name, ...config };
20
- return definitionClass({ manifest, tag });
21
- };
22
- /**
23
- * Wire a composition's synchronous logic (D2): read state, acquire triggers,
24
- * resolve the UI, return the view. Its requirements (minus `Props`, which the
25
- * host injects per render) surface as the Layer's `RIn`; the runtime runs the
26
- * body per render within the captured context.
27
- */
28
- export const live = (
29
- // `live` doesn't use the contract type; accept any composition.
30
- composition, body) => {
31
- const logic = Effect.gen(body);
32
- return Layer.effect(composition.tag, Effect.gen(function* () {
33
- // Capture the build-time context (state stores, calc, ui, bus). `Props`,
34
- // the tracker, and slots are injected per render below.
35
- const context = yield* Effect.context();
36
- const render = (env) =>
37
- // Total once fully provided: the body is synchronous, reads can't fail,
38
- // and every requirement is now satisfied (D2). `Effect.gen` widens the
39
- // error channel to `unknown` for a generic body, so we restate it.
40
- logic.pipe(Effect.provideService(Props, env.props), Effect.provideService(CurrentTracker, env.tracker), Effect.provideService(CurrentSlots, env.slots), Effect.provide(context));
41
- return { render };
42
- }));
43
- };
44
- /** Run a mounted composition for one frame, producing its node. */
45
- export const render = (service, env) => service.render(env);
46
- //# sourceMappingURL=composition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../src/compose/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAe,MAAM,QAAQ,CAAA;AAE5D,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAY,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAiB,MA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CAAA;IACnB,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAA2B,EAAE,GAAc,EAAqC,EAAE,CACvG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA"}
@@ -1,17 +0,0 @@
1
- import { Context } from 'effect';
2
- import type { Node } from './slot';
3
- /**
4
- * Binds a parent's slots to concrete child renderers. The host package
5
- * (`@reform/react`) builds one per composition instance from the manifest's
6
- * slot map; the `ui` read consults it so `<slots.Item .../>` renders the wired
7
- * child. Core stays renderer-neutral — it only defines this hole.
8
- */
9
- export interface SlotHost {
10
- slot(name: string): (props: unknown) => Node;
11
- }
12
- declare const CurrentSlotsBase: Context.TagClass<CurrentSlots, 'reform/Slots', SlotHost>;
13
- /** The active composition's slot bindings, provided per render by the host. */
14
- export declare class CurrentSlots extends CurrentSlotsBase {
15
- }
16
- export {};
17
- //# sourceMappingURL=host.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/compose/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7C;AAED,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,CACxB,CAAA;AAEvD,+EAA+E;AAC/E,qBAAa,YAAa,SAAQ,gBAAgB;CAAG"}
@@ -1,6 +0,0 @@
1
- import { Context } from 'effect';
2
- const CurrentSlotsBase = Context.Tag('reform/Slots')();
3
- /** The active composition's slot bindings, provided per render by the host. */
4
- export class CurrentSlots extends CurrentSlotsBase {
5
- }
6
- //# sourceMappingURL=host.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/compose/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAahC,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAA0B,CAAA;AAEvD,+EAA+E;AAC/E,MAAM,OAAO,YAAa,SAAQ,gBAAgB;CAAG"}
@@ -1,13 +0,0 @@
1
- import { Context } from 'effect';
2
- /**
3
- * The current composition instance's props. Bound per render by the runtime; a
4
- * composition body reads them with `const { todo } = yield* Props`.
5
- *
6
- * (Per-instance typing of Props is DESIGN #26 — for now the value is opaque and
7
- * narrowed at the use site against the composition's declared props schema.)
8
- */
9
- declare const PropsBase: Context.TagClass<Props, 'reform/Props', any>;
10
- export declare class Props extends PropsBase {
11
- }
12
- export {};
13
- //# sourceMappingURL=props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/compose/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC;;;;;;GAMG;AACH,QAAA,MAAM,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,CAGzD,CAAA;AACH,qBAAa,KAAM,SAAQ,SAAS;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/compose/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,SAAS,GAAiD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAGxF,CAAA;AACH,MAAM,OAAO,KAAM,SAAQ,SAAS;CAAG"}
@@ -1,22 +0,0 @@
1
- import { Layer } from 'effect';
2
- import type { CompositionClass } from './composition';
3
- import { type EngineServices, type FeatureClass, type ProvidedBy, type RequireCarrier } from '../feature/feature';
4
- import { type SlotChild, type SlotClass } from './slot';
5
- import { type UiClass, type UiContract, type ViewImpl } from './ui';
6
- /**
7
- * Wire an implementation to a contract. Provides a `.make` presentation to a UI
8
- * contract, a child composition into a parent's slot, or a `Feature` into a slot.
9
- * The compose code never imports its implementations — they meet here.
10
- */
11
- export declare function provide<C extends UiContract>(contract: UiClass<C>, view: ViewImpl<C>): Layer.Layer<ViewImpl<C>>;
12
- export declare function provide<Comp extends CompositionClass<any, any>>(hole: SlotClass<Comp>, composition: Comp): Layer.Layer<CompositionClass<unknown>>;
13
- /**
14
- * Fill a slot with a feature. The slot's child composition type
15
- * (`CompositionClass<P, C>`) must match the feature's mounted composition, so the
16
- * facade/contract stays typed. The returned layer surfaces the feature's shared
17
- * requirement (`EngineServices | ProvidedBy<Requires>`) as an open `RIn`, so the
18
- * scene that wires it won't compile unless it provides the matching `Core` — even
19
- * for a lazy feature whose own `.live` layer isn't built until mount.
20
- */
21
- export declare function provide<Comp extends CompositionClass<any, any>, ROut, Requires extends ReadonlyArray<RequireCarrier>>(hole: SlotClass<Comp>, feature: FeatureClass<Comp extends CompositionClass<infer P, any> ? P : never, Comp extends CompositionClass<any, infer C> ? C : never, ROut, Requires>): Layer.Layer<SlotChild, never, EngineServices | ProvidedBy<Requires>>;
22
- //# sourceMappingURL=provide.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provide.d.ts","sourceRoot":"","sources":["../../src/compose/provide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAQ,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEzE;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAC1C,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAChB,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3B,wBAAgB,OAAO,CAAC,IAAI,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC7D,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EACrB,WAAW,EAAE,IAAI,GAChB,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;AACzC;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,IAAI,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EACvC,IAAI,EACJ,QAAQ,SAAS,aAAa,CAAC,cAAc,CAAC,EAE9C,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EACrB,OAAO,EAAE,YAAY,CACnB,IAAI,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,EACvD,IAAI,SAAS,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EACvD,IAAI,EACJ,QAAQ,CACT,GACA,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA"}
@@ -1,28 +0,0 @@
1
- import { Layer } from 'effect';
2
- import { InvalidProvideTarget } from '../internal/errors';
3
- import { isFeature, } from '../feature/feature';
4
- import { isSlot } from './slot';
5
- import { isUi } from './ui';
6
- export function provide(target, impl) {
7
- // Discriminate the target by its nominal brand, not by which DI-hole property
8
- // happens to exist: a UI contract provides under its `impl` tag, a slot under
9
- // its `tag`. Anything else is a wiring mistake. The overloads above pair
10
- // `impl` with the chosen tag; this implementation sees both erased, so view
11
- // the tag loosely (the one documented cast) to provide the service under it.
12
- const tag = (isUi(target) ? target.impl : isSlot(target) ? target.tag : undefined);
13
- if (tag === undefined)
14
- throw new InvalidProvideTarget();
15
- if (isFeature(impl)) {
16
- const eager = impl.eagerModule;
17
- // Lazy: bind the `FeatureBinding`; the host drives load → mount, painting the
18
- // placeholders. Default: bind the composition (so the existing `Compose` path
19
- // renders it, no host, no flash) and merge the eager `.live` layer, whose `RIn`
20
- // surfaces to the scene. Either way the overload's return type carries the
21
- // shared `RIn`, so the scene still type-demands `Core`.
22
- return eager === undefined
23
- ? Layer.succeed(tag, impl.binding)
24
- : Layer.merge(Layer.succeed(tag, impl.binding.composition), eager.layer);
25
- }
26
- return Layer.succeed(tag, impl);
27
- }
28
- //# sourceMappingURL=provide.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provide.js","sourceRoot":"","sources":["../../src/compose/provide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,EAGL,SAAS,GAGV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAkC,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAgD,MAAM,MAAM,CAAA;AAoCzE,MAAM,UAAU,OAAO,CAAC,MAAe,EAAE,IAAa;IACpD,8EAA8E;IAC9E,8EAA8E;IAC9E,yEAAyE;IACzE,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CA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Ac;IACvD,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CACrB;AAED;;;;;;;;GAQG;AACH,6EAA6E;AAC7E,eAAO,MAAM,UAAU,EAAE,OAAO,MAAkC,CAAA;AAClE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAA;AAE1C,MAAM,WAAW,SAAS,CAAC,IAAI,SAAS,cAAc,GAAG,cAAc;IACrE,QAAQ,YAAY,CAAC,IAAI,CAAC,CAAA;IAC1B,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,4FAA4F;IAC5F,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;CAChD;AAED,6EAA6E;AAC7E,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,SAC4C,CAAA;AAErF,8EAA8E;AAC9E,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,YAAY,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAA;AAErF,eAAO,MAAM,IAAI,GACd,MAAM,MAAM,MAGZ,IAAI,SAAS,cAAc,GAAG,cAAc,OAAK,SAAS,CAAC,IAAI,CAG/D,CAAA"}
@@ -1,23 +0,0 @@
1
- import { Context } from 'effect';
2
- import { definitionClass } from '../definition/definition';
3
- /**
4
- * A DI hole for a child composition. The parent declares
5
- * `slot('Item')<typeof TodoItem>()` and renders through it; the concrete child
6
- * is wired with `provide(Item, TodoItem)`, so the parent never imports the
7
- * child's *implementation* (the `typeof` is a type-only reference to the
8
- * definition). `Comp` lives only in the phantom instance (so `SlotClass` is
9
- * covariant and a `{ Item: ItemSlot }` map is well-typed); the match is enforced
10
- * by `provide`'s signature, not the (invariant) tag.
11
- */
12
- /** Nominal brand identifying a slot at runtime (Effect's `TypeId` idiom). */
13
- export const SlotTypeId = Symbol.for('reform/Slot');
14
- /** Whether a value is a slot — discriminates a `provide` target by brand. */
15
- export const isSlot = (u) => (typeof u === 'function' || typeof u === 'object') && u !== null && SlotTypeId in u;
16
- export const slot = (name) =>
17
- // Defaulted so a slot whose child carries no meaningful props/contract can be
18
- // declared bare (`slot('Tree')()`); pass `typeof Child` to type the facade.
19
- () => {
20
- const tag = Context.GenericTag(`reform/slot/${name}`);
21
- return definitionClass({ [SlotTypeId]: SlotTypeId, kind: 'Slot', tag });
22
- };
23
- //# sourceMappingURL=slot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/compose/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AA6B1D;;;;;;;;GAQG;AACH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAkB,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;AAWlE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAkB,EAAE,CACnD,CAAC,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,UAAU,IAAI,CAAC,CAAA;AAKrF,MAAM,CAAC,MAAM,IAAI,GACf,CAAC,IAAY,EAAE,EAAE;AACjB,8EAA8E;AAC9E,4EAA4E;AAC5E,GAAkE,EAAE;IAClE,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAuB,eAAe,IAAI,EAAE,CAAC,CAAA;IAC3E,OAAO,eAAe,CAAkB,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAe,EAAE,GAAG,EAAE,CAAC,CAAA;AACnG,CAAC,CAAA"}
@@ -1,135 +0,0 @@
1
- import type { FunctionComponent } from 'react';
2
- import { Context, Effect, type Schema } from 'effect';
3
- import { type Manifest } from '../definition/definition';
4
- import type { Trigger } from '../ui/trigger';
5
- import { type Node, type SlotClass, type SlotInstance, type SlotProps } from './slot';
6
- export interface UiContract {
7
- props: unknown;
8
- slots?: Record<string, SlotInstance<any>>;
9
- events?: Record<string, Trigger<any>>;
10
- }
11
- type PropsOf<C extends UiContract> = C['props'];
12
- type EventsOf<C extends UiContract> = C extends {
13
- events: infer E;
14
- } ? E : Record<never, never>;
15
- type SlotsOf<C extends UiContract> = C extends {
16
- slots: infer S;
17
- } ? {
18
- readonly [K in keyof S]: FunctionComponent<Partial<SlotProps<S[K]> & {
19
- readonly slotKey?: string;
20
- }>>;
21
- } : Record<never, never>;
22
- /** What the composition logic calls: props + handlers in, a node out. Slots are bound by the renderer. */
23
- export type LogicView<C extends UiContract> = (props: PropsOf<C>, events?: EventsOf<C>) => Node;
24
- /** What `.make` authors: the pure presentation. Slots are injected by the renderer. */
25
- export type ViewImpl<C extends UiContract> = (props: PropsOf<C>, slots: SlotsOf<C>, events: EventsOf<C>) => Node;
26
- /** Nominal brand identifying a UI contract at runtime (Effect's `TypeId` idiom). */
27
- export declare const UiTypeId: unique symbol;
28
- export type UiTypeId = typeof UiTypeId;
29
- /**
30
- * The reflectable descriptor a contract carries. The wire `props` / `events`
31
- * schemas are present *only* on the schema (wired) form — the type-only form
32
- * carries neither, so a local contract has no schema cost and no schema surface.
33
- */
34
- export interface UiManifest extends Manifest {
35
- readonly kind: 'Ui';
36
- readonly props?: Schema.Schema<any, any>;
37
- readonly events?: Readonly<Record<string, Schema.Schema<any, any>>>;
38
- }
39
- /** A `UiManifest` whose wire schema is present — the runtime brand of a remote-capable contract. */
40
- export interface WiredUiManifest extends UiManifest {
41
- readonly props: Schema.Schema<any, any>;
42
- }
43
- export interface UiClass<C extends UiContract> extends Effect.Effect<LogicView<C>, never, ViewImpl<C>> {
44
- new (): {};
45
- readonly [UiTypeId]: UiTypeId;
46
- readonly manifest: UiManifest;
47
- /** Internal DI tag the `Ui.make` presentation is provided under. */
48
- readonly impl: Context.Tag<ViewImpl<C>, ViewImpl<C>>;
49
- }
50
- /**
51
- * Recover a contract's `UiContract` type from its `Ui` class — `Ui.Contract<typeof
52
- * SomeUi>`. Lets a consumer (a proof, a reflection tool) name the contract derived
53
- * from a wired `ui('X', {…})` without re-declaring it.
54
- */
55
- export type Contract<U> = U extends UiClass<infer C> ? C : never;
56
- /**
57
- * A contract authored with wire schemas. Structurally a `UiClass<C>` whose
58
- * manifest *carries* the schemas (`WiredUiManifest`), so it is the subtype the
59
- * remote seam (`provideRemote`, the wire registry) demands while plain `provide`
60
- * / `scene` / `Composition.make` keep accepting any `UiClass<C>`.
61
- */
62
- export type WiredUi<C extends UiContract> = UiClass<C> & {
63
- readonly manifest: WiredUiManifest;
64
- };
65
- /** The wire schemas a contract is authored from: props, a payload schema per event, and
66
- * (type-only) the slots the view fills. Slots carry no wire schema — the children that
67
- * fill them are their own contracts — but declaring them here threads typed slots into
68
- * the derived contract, so a WIRED contract can also have slots (e.g. a parent whose
69
- * props the client reads AND that renders slot children). */
70
- export interface WireSchemas {
71
- readonly props: Schema.Schema<any, any>;
72
- readonly events?: Readonly<Record<string, Schema.Schema<any, any>>>;
73
- readonly slots?: Readonly<Record<string, SlotClass>>;
74
- }
75
- type DerivedEvents<Sch extends WireSchemas> = Sch extends {
76
- readonly events: infer E extends Record<string, Schema.Schema<any, any>>;
77
- } ? {
78
- readonly [K in keyof E]: Trigger<Schema.Schema.Type<E[K]>>;
79
- } : Record<never, never>;
80
- type DerivedSlots<Sch extends WireSchemas> = Sch extends {
81
- readonly slots: infer S extends Record<string, SlotClass>;
82
- } ? {
83
- readonly [K in keyof S]: InstanceType<S[K]>;
84
- } : Record<never, never>;
85
- /**
86
- * The `UiContract` a set of wire schemas denotes — props and event-payload
87
- * *types* derived from the schemas via `Schema.Type`, plus any declared slots. The
88
- * schema is the single source of truth; the contract type is inferred, never written
89
- * a second time.
90
- */
91
- export type DerivedContract<Sch extends WireSchemas> = {
92
- readonly props: Schema.Schema.Type<Sch['props']>;
93
- readonly slots: DerivedSlots<Sch>;
94
- readonly events: DerivedEvents<Sch>;
95
- };
96
- /** Whether a value is a UI contract — discriminates a `provide` target by brand. */
97
- export declare const isUi: (u: unknown) => u is UiClass<UiContract>;
98
- /**
99
- * A renderer-neutral UI contract. The logic resolves it (`yield* TodoAppUi`) to
100
- * a `(props, events) => node` view with slots already bound; `.make` authors the
101
- * presentation. Core defines the contract; `@reform/react` does the rendering.
102
- *
103
- * Two authoring forms, one source of truth each:
104
- *
105
- * - **Type-only (local):** `ui('Counter')<{ props: { count: number } }>()` — no
106
- * schema, no ceremony, exactly as before.
107
- * - **Schema (wired):** `ui('Counter', { props: S.Struct({ count: S.Number }) })`
108
- * — the schema *is* the definition; the contract type is derived via
109
- * `Schema.Type` (never re-written), and the result is a `WiredUi` the remote
110
- * seam accepts. Make a local contract remote by rewriting this one line.
111
- */
112
- export declare function ui(name: string): <C extends UiContract>() => UiClass<C>;
113
- export declare function ui<const Sch extends WireSchemas>(name: string, schemas: Sch): WiredUi<DerivedContract<Sch>>;
114
- /** Brand under which a `Ui.make` view carries its own contract. */
115
- export declare const UiViewContract: unique symbol;
116
- export type UiViewContract = typeof UiViewContract;
117
- /**
118
- * A `Ui.make` view that carries its contract, so a consumer can recover the
119
- * contract (its wire name + props schema) straight from the view — no separate
120
- * registration call. This is what makes the remote client view-set
121
- * (`remoteViews<AppContract>({ Some: SomeView, … })`) work with the very same
122
- * `Ui.make` views the local renderer uses.
123
- */
124
- export type MadeView<C extends UiContract> = ViewImpl<C> & {
125
- readonly [UiViewContract]: UiClass<C>;
126
- };
127
- /**
128
- * Author the pure presentation for a contract — `Ui.make(TodoAppUi, (props,
129
- * slots, events) => node)`. The contract argument fixes the view's types AND is
130
- * carried on the returned view (`MadeView`), so the same view is reusable as a
131
- * remote client presentation. Wire the result with `provide(contract, view)`.
132
- */
133
- export declare const make: <C extends UiContract>(contract: UiClass<C>, view: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AG,OAAO,cAAc,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,UAAU,EAAE,UAAU,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,CAC1C,CAAA"}
@@ -1,63 +0,0 @@
1
- import { Context, Effect, Option } from 'effect';
2
- import { yieldableClass } from '../definition/definition';
3
- import { CaptureSink } from '../internal/capture';
4
- import { SlotRenderingUnavailable } from '../internal/errors';
5
- import { CurrentSlots } from './host';
6
- import {} from './slot';
7
- /** Nominal brand identifying a UI contract at runtime (Effect's `TypeId` idiom). */
8
- export const UiTypeId = Symbol.for('reform/Ui');
9
- /** Whether a value is a UI contract — discriminates a `provide` target by brand. */
10
- export const isUi = (u) => (typeof u === 'function' || typeof u === 'object') && u !== null && UiTypeId in u;
11
- const buildUi = (name, manifest) => {
12
- const impl = Context.GenericTag(`reform/ui/${name}`);
13
- const read = Effect.gen(function* () {
14
- const render = yield* impl;
15
- // Slots are bound by the host (`@reform/react`) per composition instance.
16
- // Core has no renderer, so without a host every slot access throws.
17
- const host = yield* Effect.serviceOption(CurrentSlots);
18
- const slots = new Proxy({}, {
19
- get(_t, key) {
20
- if (Option.isNone(host)) {
21
- throw new SlotRenderingUnavailable({ slot: String(key) });
22
- }
23
- return host.value.slot(String(key));
24
- },
25
- });
26
- // A capturing host (proofs, the dev tool) reports each render's observable
27
- // surface without replacing the presentation. Absent in production.
28
- const sink = yield* Effect.serviceOption(CaptureSink);
29
- return (props, events) => {
30
- if (Option.isSome(sink)) {
31
- sink.value.record({
32
- name,
33
- props,
34
- events: (events ?? {}),
35
- });
36
- }
37
- return render(props, slots, (events ?? {}));
38
- };
39
- });
40
- return yieldableClass(read, {
41
- [UiTypeId]: UiTypeId,
42
- manifest,
43
- impl,
44
- });
45
- };
46
- export function ui(name, schemas) {
47
- if (schemas === undefined) {
48
- return () => buildUi(name, { kind: 'Ui', name });
49
- }
50
- const eventFields = schemas.events === undefined ? {} : { events: schemas.events };
51
- const manifest = { kind: 'Ui', name, props: schemas.props, ...eventFields };
52
- return buildUi(name, manifest);
53
- }
54
- /** Brand under which a `Ui.make` view carries its own contract. */
55
- export const UiViewContract = Symbol.for('reform/ui/view-contract');
56
- /**
57
- * Author the pure presentation for a contract — `Ui.make(TodoAppUi, (props,
58
- * slots, events) => node)`. The contract argument fixes the view's types AND is
59
- * carried on the returned view (`MadeView`), so the same view is reusable as a
60
- * remote client presentation. Wire the result with `provide(contract, view)`.
61
- */
62
- export const make = (contract, view) => Object.assign(view, { [UiViewContract]: contract });
63
- //# sourceMappingURL=ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/compose/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAA;AAC7D,OAAO,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAgE,MAAM,QAAQ,CAAA;AA8CrF,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAmF9D,oFAAoF;AACpF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAU,EAA4B,EAAE,CAC3D,CAAC,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO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,EAAE,KAAK,EAAE,CAAC,MAAM,IAAI,EAAE,CAAgB,CAAC,CAAA;QAC5D,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,cAAc,CAAC,IAAI,EAAE;QAC1B,CAAC,QAAQ,CAAC,EAAE,QAAQ;QACpB,QAAQ;QACR,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAA;AAkBD,MAAM,UAAU,EAAE,CAAC,IAAY,EAAE,OAAqB;IACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,GAAqC,EAAE,CAAC,OAAO,CAAgB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACnG,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;IAClF,MAAM,QAAQ,GAAoB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,WAAW,EAAE,CAAA;IAC5F,OAAO,OAAO,CAAgD,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC/E,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAkB,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AAYlF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAuB,QAAoB,EAAE,IAAiB,EAAe,EAAE,CACjG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA"}
@@ -1,33 +0,0 @@
1
- import { Effect } from 'effect';
2
- /**
3
- * The reflectable descriptor every primitive carries (principle #6). The editor
4
- * and proof packages read these without running any logic.
5
- */
6
- export type Kind = 'State' | 'StateGroup' | 'StateFamily' | 'Event' | 'EventGroup' | 'Reducer' | 'Calc' | 'CalcFamily' | 'AsyncCalc' | 'Resource' | 'RemoteState' | 'SyncedStore' | 'Boundary' | 'Procedure' | 'Channel' | 'Composition' | 'Ui' | 'Slot' | 'Feature';
7
- export interface Manifest {
8
- readonly kind: Kind;
9
- readonly name: string;
10
- }
11
- /**
12
- * Build a class whose *static* side is itself an Effect, so `yield* TheClass`
13
- * runs `read` and returns its value (the same mechanism `Context.Tag` uses).
14
- * Subclasses inherit the protocol through the prototype chain, so the user's
15
- * `class FeedState extends State.make(...) {}` is yieldable too.
16
- *
17
- * `statics` (manifest, `.live`, tag, …) are attached as own properties
18
- * and likewise inherited by the subclass.
19
- */
20
- export declare const yieldableClass: <A, E, R, Statics extends object>(read: Effect.Effect<A, E, R>, statics: Statics) => {
21
- new (): {};
22
- } & Effect.Effect<A, E, R> & Statics;
23
- /**
24
- * Build a *definition class*: an empty constructible carrying static marker data
25
- * (manifest, tag, policy, members, …) that the editor and proof packages reflect
26
- * on. Definition interfaces declare phantom, type-only fields — a composition's
27
- * `Props`, a family instance's `Key` — that exist purely for inference and have
28
- * no runtime value, so the assembled object cannot *structurally* satisfy the
29
- * interface. The one assertion to `Class` lives here, documented, instead of a
30
- * scattered `as never` / `as unknown as` at every `*.make`.
31
- */
32
- export declare const definitionClass: <Class>(statics: object) => Class;
33
- //# sourceMappingURL=definition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/definition/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAM/B;;;GAGG;AACH,MAAM,MAAM,IAAI,GACZ,OAAO,GACP,YAAY,GACZ,aAAa,GACb,OAAO,GACP,YAAY,GACZ,SAAS,GACT,MAAM,GACN,YAAY,GACZ,WAAW,GACX,UAAU,GACV,aAAa,GACb,aAAa,GACb,UAAU,GACV,WAAW,GACX,SAAS,GACT,aAAa,GACb,IAAI,GACJ,MAAM,GACN,SAAS,CAAA;AAEb,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,SAAS,MAAM,EAC5D,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,SAAS,OAAO,KACf;IAAE,QAAQ,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAe5C,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,EAAE,SAAS,MAAM,KAAG,KACyC,CAAA"}
@@ -1,42 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { attachInspectable } from '../internal/inspect';
3
- /** A definition's `toJSON`: its reflectable manifest, else its raw statics. */
4
- const describe = (statics) => statics.manifest ?? statics;
5
- /**
6
- * Build a class whose *static* side is itself an Effect, so `yield* TheClass`
7
- * runs `read` and returns its value (the same mechanism `Context.Tag` uses).
8
- * Subclasses inherit the protocol through the prototype chain, so the user's
9
- * `class FeedState extends State.make(...) {}` is yieldable too.
10
- *
11
- * `statics` (manifest, `.live`, tag, …) are attached as own properties
12
- * and likewise inherited by the subclass.
13
- */
14
- export const yieldableClass = (read, statics) => {
15
- class Base {
16
- }
17
- Object.setPrototypeOf(Base, read);
18
- // `defineProperty` over `Reflect.ownKeys`, not `Object.assign` over
19
- // `Object.entries`: a static can shadow a non-writable own property of the
20
- // class function (notably `name`, which a `Source`-shaped definition like a
21
- // Calc carries) and `assign` would throw on those; and `ownKeys` (unlike
22
- // `entries`) carries symbol-keyed statics — the `TypeId` brands.
23
- for (const key of Reflect.ownKeys(statics)) {
24
- const value = statics[key];
25
- Object.defineProperty(Base, key, { value, writable: true, enumerable: true, configurable: true });
26
- }
27
- // Print like an Effect value (the manifest), not `[object Object]`.
28
- attachInspectable(Base, () => describe(statics));
29
- return Base;
30
- };
31
- /**
32
- * Build a *definition class*: an empty constructible carrying static marker data
33
- * (manifest, tag, policy, members, …) that the editor and proof packages reflect
34
- * on. Definition interfaces declare phantom, type-only fields — a composition's
35
- * `Props`, a family instance's `Key` — that exist purely for inference and have
36
- * no runtime value, so the assembled object cannot *structurally* satisfy the
37
- * interface. The one assertion to `Class` lives here, documented, instead of a
38
- * scattered `as never` / `as unknown as` at every `*.make`.
39
- */
40
- export const definitionClass = (statics) => attachInspectable(Object.assign(class {
41
- }, statics), () => describe(statics));
42
- //# sourceMappingURL=definition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/definition/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,+EAA+E;AAC/E,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAW,EAAE,CAAE,OAAkC,CAAC,QAAQ,IAAI,OAAO,CAAA;AAgCtG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAA4B,EAC5B,OAAgB,EACmC,EAAE;IACrD,MAAM,IAAI;KAAG;IACb,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACjC,oEAAoE;IACpE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,iEAAiE;IACjE,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAI,OAAwC,CAAC,GAAG,CAAC,CAAA;QAC5D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;IACnG,CAAC;IACD,oEAAoE;IACpE,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAChD,OAAO,IAAa,CAAA;AACtB,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAQ,OAAe,EAAS,EAAE,CAC/D,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC;CAAQ,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAqB,CAAA"}
@@ -1,33 +0,0 @@
1
- import { Effect, type Schema } from 'effect';
2
- import { type Manifest } from '../definition/definition';
3
- import { Bus, type Tagged } from '../runtime/bus';
4
- import type { Trigger } from '../ui/trigger';
5
- /** The dispatched value of an event: `{ _tag, ...payload }`, matched with `Match.tags`. */
6
- export type EventOf<N extends string, P> = Tagged & {
7
- readonly _tag: N;
8
- } & P;
9
- export interface EventManifest<N extends string, P> extends Manifest {
10
- readonly kind: 'Event';
11
- readonly name: N;
12
- readonly schema: Schema.Schema<P, any>;
13
- }
14
- export interface EventClass<out N extends string, in out P> {
15
- new (): {};
16
- readonly manifest: EventManifest<N, P>;
17
- readonly tag: N;
18
- /** Carrier for `Event.construct` — builds the tagged value `{ _tag, ...payload }`. */
19
- readonly build: (payload: P) => EventOf<N, P>;
20
- /** Carrier for `Event.trigger` — the UI callback effect (High priority). */
21
- readonly trigger: Effect.Effect<Trigger<P>, never, Bus>;
22
- }
23
- export type AnyEvent = EventClass<string, any>;
24
- export type EventType<E> = E extends EventClass<infer N, infer P> ? EventOf<N, P> : never;
25
- /** A pure data fact. Events depend on nothing — only reducers tie them to state. */
26
- export declare const make: <const N extends string, P>(name: N, schema: Schema.Schema<P, any>) => EventClass<N, P>;
27
- /** Construct the tagged value for an event (used for `boot` events). */
28
- export declare const construct: <N extends string, P>(event: EventClass<N, P>, payload: P) => EventOf<N, P>;
29
- /** Dispatch as a follow-up (Normal priority) from a procedure/effect. */
30
- export declare const dispatch: <N extends string, P>(event: EventClass<N, P>, payload: P) => Effect.Effect<void, never, Bus>;
31
- /** A callback for the UI that dispatches at High priority via the runtime. */
32
- export declare const trigger: <N extends string, P>(event: EventClass<N, P>) => Effect.Effect<Trigger<P>, never, Bus>;
33
- //# sourceMappingURL=event.d.ts.map