@playfast/reform 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/cjs/boundary/boundary.js +86 -0
- package/dist/cjs/calc/asyncCalc.js +128 -0
- package/dist/cjs/calc/asyncData.js +37 -0
- package/dist/cjs/calc/calc.js +58 -0
- package/dist/cjs/calc/calcFamily.js +127 -0
- package/dist/cjs/channel/channel.js +142 -0
- package/dist/cjs/compose/composition.js +50 -0
- package/dist/cjs/compose/host.js +8 -0
- package/dist/cjs/compose/props.js +14 -0
- package/dist/cjs/compose/provide.js +30 -0
- package/dist/cjs/compose/slot.js +27 -0
- package/dist/cjs/compose/ui.js +61 -0
- package/dist/cjs/definition/definition.js +46 -0
- package/dist/cjs/event/event.js +36 -0
- package/dist/cjs/event/eventGroup.js +7 -0
- package/dist/cjs/feature/feature.js +102 -0
- package/dist/cjs/index.js +116 -0
- package/dist/cjs/internal/capture.js +14 -0
- package/dist/cjs/internal/ctx.js +2 -0
- package/dist/cjs/internal/errors.js +62 -0
- package/dist/cjs/internal/inspect.js +36 -0
- package/dist/cjs/internal/queryDriver.js +138 -0
- package/dist/cjs/internal/reuse.js +71 -0
- package/dist/cjs/internal/scheduler.js +73 -0
- package/dist/cjs/internal/seeds.js +19 -0
- package/dist/cjs/internal/sources.js +61 -0
- package/dist/cjs/internal/store.js +77 -0
- package/dist/cjs/internal/track.js +22 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/procedure/procedure.js +52 -0
- package/dist/cjs/reducer/reducer.js +64 -0
- package/dist/cjs/remote/remoteState.js +307 -0
- package/dist/cjs/runtime/bus.js +25 -0
- package/dist/cjs/runtime/loop.js +119 -0
- package/dist/cjs/scene/scene.js +36 -0
- package/dist/cjs/state/state.js +47 -0
- package/dist/cjs/state/stateFamily.js +101 -0
- package/dist/cjs/state/stateGroup.js +47 -0
- package/dist/cjs/state/token.js +23 -0
- package/dist/cjs/ui/node.js +2 -0
- package/dist/cjs/ui/trigger.js +2 -0
- package/dist/dts/boundary/boundary.d.ts +72 -0
- package/dist/dts/boundary/boundary.d.ts.map +1 -0
- package/dist/dts/calc/asyncCalc.d.ts +91 -0
- package/dist/dts/calc/asyncCalc.d.ts.map +1 -0
- package/dist/dts/calc/asyncData.d.ts +55 -0
- package/dist/dts/calc/asyncData.d.ts.map +1 -0
- package/dist/dts/calc/calc.d.ts +57 -0
- package/dist/dts/calc/calc.d.ts.map +1 -0
- package/dist/dts/calc/calcFamily.d.ts +57 -0
- package/dist/dts/calc/calcFamily.d.ts.map +1 -0
- package/dist/dts/channel/channel.d.ts +115 -0
- package/dist/dts/channel/channel.d.ts.map +1 -0
- package/dist/dts/compose/composition.d.ts +72 -0
- package/dist/dts/compose/composition.d.ts.map +1 -0
- package/dist/dts/compose/host.d.ts +17 -0
- package/dist/dts/compose/host.d.ts.map +1 -0
- package/dist/dts/compose/props.d.ts +13 -0
- package/dist/dts/compose/props.d.ts.map +1 -0
- package/dist/dts/compose/provide.d.ts +22 -0
- package/dist/dts/compose/provide.d.ts.map +1 -0
- package/dist/dts/compose/slot.d.ts +49 -0
- package/dist/dts/compose/slot.d.ts.map +1 -0
- package/dist/dts/compose/ui.d.ts +50 -0
- package/dist/dts/compose/ui.d.ts.map +1 -0
- package/dist/dts/definition/definition.d.ts +33 -0
- package/dist/dts/definition/definition.d.ts.map +1 -0
- package/dist/dts/event/event.d.ts +33 -0
- package/dist/dts/event/event.d.ts.map +1 -0
- package/dist/dts/event/eventGroup.d.ts +9 -0
- package/dist/dts/event/eventGroup.d.ts.map +1 -0
- package/dist/dts/feature/feature.d.ts +220 -0
- package/dist/dts/feature/feature.d.ts.map +1 -0
- package/dist/dts/index.d.ts +43 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/internal/capture.d.ts +28 -0
- package/dist/dts/internal/capture.d.ts.map +1 -0
- package/dist/dts/internal/ctx.d.ts +12 -0
- package/dist/dts/internal/ctx.d.ts.map +1 -0
- package/dist/dts/internal/errors.d.ts +69 -0
- package/dist/dts/internal/errors.d.ts.map +1 -0
- package/dist/dts/internal/inspect.d.ts +17 -0
- package/dist/dts/internal/inspect.d.ts.map +1 -0
- package/dist/dts/internal/queryDriver.d.ts +65 -0
- package/dist/dts/internal/queryDriver.d.ts.map +1 -0
- package/dist/dts/internal/reuse.d.ts +10 -0
- package/dist/dts/internal/reuse.d.ts.map +1 -0
- package/dist/dts/internal/scheduler.d.ts +47 -0
- package/dist/dts/internal/scheduler.d.ts.map +1 -0
- package/dist/dts/internal/seeds.d.ts +17 -0
- package/dist/dts/internal/seeds.d.ts.map +1 -0
- package/dist/dts/internal/sources.d.ts +39 -0
- package/dist/dts/internal/sources.d.ts.map +1 -0
- package/dist/dts/internal/store.d.ts +47 -0
- package/dist/dts/internal/store.d.ts.map +1 -0
- package/dist/dts/internal/track.d.ts +33 -0
- package/dist/dts/internal/track.d.ts.map +1 -0
- package/dist/dts/procedure/procedure.d.ts +40 -0
- package/dist/dts/procedure/procedure.d.ts.map +1 -0
- package/dist/dts/reducer/reducer.d.ts +44 -0
- package/dist/dts/reducer/reducer.d.ts.map +1 -0
- package/dist/dts/remote/remoteState.d.ts +119 -0
- package/dist/dts/remote/remoteState.d.ts.map +1 -0
- package/dist/dts/runtime/bus.d.ts +27 -0
- package/dist/dts/runtime/bus.d.ts.map +1 -0
- package/dist/dts/runtime/loop.d.ts +45 -0
- package/dist/dts/runtime/loop.d.ts.map +1 -0
- package/dist/dts/scene/scene.d.ts +44 -0
- package/dist/dts/scene/scene.d.ts.map +1 -0
- package/dist/dts/state/state.d.ts +37 -0
- package/dist/dts/state/state.d.ts.map +1 -0
- package/dist/dts/state/stateFamily.d.ts +79 -0
- package/dist/dts/state/stateFamily.d.ts.map +1 -0
- package/dist/dts/state/stateGroup.d.ts +36 -0
- package/dist/dts/state/stateGroup.d.ts.map +1 -0
- package/dist/dts/state/token.d.ts +30 -0
- package/dist/dts/state/token.d.ts.map +1 -0
- package/dist/dts/ui/node.d.ts +9 -0
- package/dist/dts/ui/node.d.ts.map +1 -0
- package/dist/dts/ui/trigger.d.ts +7 -0
- package/dist/dts/ui/trigger.d.ts.map +1 -0
- package/dist/esm/boundary/boundary.js +83 -0
- package/dist/esm/boundary/boundary.js.map +1 -0
- package/dist/esm/calc/asyncCalc.js +95 -0
- package/dist/esm/calc/asyncCalc.js.map +1 -0
- package/dist/esm/calc/asyncData.js +34 -0
- package/dist/esm/calc/asyncData.js.map +1 -0
- package/dist/esm/calc/calc.js +58 -0
- package/dist/esm/calc/calc.js.map +1 -0
- package/dist/esm/calc/calcFamily.js +124 -0
- package/dist/esm/calc/calcFamily.js.map +1 -0
- package/dist/esm/channel/channel.js +136 -0
- package/dist/esm/channel/channel.js.map +1 -0
- package/dist/esm/compose/composition.js +46 -0
- package/dist/esm/compose/composition.js.map +1 -0
- package/dist/esm/compose/host.js +5 -0
- package/dist/esm/compose/host.js.map +1 -0
- package/dist/esm/compose/props.js +11 -0
- package/dist/esm/compose/props.js.map +1 -0
- package/dist/esm/compose/provide.js +28 -0
- package/dist/esm/compose/provide.js.map +1 -0
- package/dist/esm/compose/slot.js +23 -0
- package/dist/esm/compose/slot.js.map +1 -0
- package/dist/esm/compose/ui.js +57 -0
- package/dist/esm/compose/ui.js.map +1 -0
- package/dist/esm/definition/definition.js +42 -0
- package/dist/esm/definition/definition.js.map +1 -0
- package/dist/esm/event/event.js +30 -0
- package/dist/esm/event/event.js.map +1 -0
- package/dist/esm/event/eventGroup.js +4 -0
- package/dist/esm/event/eventGroup.js.map +1 -0
- package/dist/esm/feature/feature.js +98 -0
- package/dist/esm/feature/feature.js.map +1 -0
- package/dist/esm/index.js +45 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/capture.js +11 -0
- package/dist/esm/internal/capture.js.map +1 -0
- package/dist/esm/internal/ctx.js +2 -0
- package/dist/esm/internal/ctx.js.map +1 -0
- package/dist/esm/internal/errors.js +54 -0
- package/dist/esm/internal/errors.js.map +1 -0
- package/dist/esm/internal/inspect.js +32 -0
- package/dist/esm/internal/inspect.js.map +1 -0
- package/dist/esm/internal/queryDriver.js +134 -0
- package/dist/esm/internal/queryDriver.js.map +1 -0
- package/dist/esm/internal/reuse.js +68 -0
- package/dist/esm/internal/reuse.js.map +1 -0
- package/dist/esm/internal/scheduler.js +69 -0
- package/dist/esm/internal/scheduler.js.map +1 -0
- package/dist/esm/internal/seeds.js +17 -0
- package/dist/esm/internal/seeds.js.map +1 -0
- package/dist/esm/internal/sources.js +59 -0
- package/dist/esm/internal/sources.js.map +1 -0
- package/dist/esm/internal/store.js +73 -0
- package/dist/esm/internal/store.js.map +1 -0
- package/dist/esm/internal/track.js +18 -0
- package/dist/esm/internal/track.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/procedure/procedure.js +50 -0
- package/dist/esm/procedure/procedure.js.map +1 -0
- package/dist/esm/reducer/reducer.js +63 -0
- package/dist/esm/reducer/reducer.js.map +1 -0
- package/dist/esm/remote/remoteState.js +270 -0
- package/dist/esm/remote/remoteState.js.map +1 -0
- package/dist/esm/runtime/bus.js +20 -0
- package/dist/esm/runtime/bus.js.map +1 -0
- package/dist/esm/runtime/loop.js +116 -0
- package/dist/esm/runtime/loop.js.map +1 -0
- package/dist/esm/scene/scene.js +31 -0
- package/dist/esm/scene/scene.js.map +1 -0
- package/dist/esm/state/state.js +43 -0
- package/dist/esm/state/state.js.map +1 -0
- package/dist/esm/state/stateFamily.js +96 -0
- package/dist/esm/state/stateFamily.js.map +1 -0
- package/dist/esm/state/stateGroup.js +46 -0
- package/dist/esm/state/stateGroup.js.map +1 -0
- package/dist/esm/state/token.js +20 -0
- package/dist/esm/state/token.js.map +1 -0
- package/dist/esm/ui/node.js +2 -0
- package/dist/esm/ui/node.js.map +1 -0
- package/dist/esm/ui/trigger.js +2 -0
- package/dist/esm/ui/trigger.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Context, Effect, Option } from 'effect';
|
|
2
|
+
import { yieldableClass } from '../definition/definition.js';
|
|
3
|
+
import { CaptureSink } from '../internal/capture.js';
|
|
4
|
+
import { SlotRenderingUnavailable } from '../internal/errors.js';
|
|
5
|
+
import { CurrentSlots } from './host.js';
|
|
6
|
+
import {} from './slot.js';
|
|
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
|
+
/**
|
|
12
|
+
* A renderer-neutral UI contract. The logic resolves it (`yield* TodoAppUi`) to
|
|
13
|
+
* a `(props, events) => node` view with slots already bound; `.make` authors the
|
|
14
|
+
* presentation. Core defines the contract; `@reform/react` does the rendering.
|
|
15
|
+
*/
|
|
16
|
+
export const ui = (name) => () => {
|
|
17
|
+
const impl = Context.GenericTag(`reform/ui/${name}`);
|
|
18
|
+
const read = Effect.gen(function* () {
|
|
19
|
+
const render = yield* impl;
|
|
20
|
+
// Slots are bound by the host (`@reform/react`) per composition instance.
|
|
21
|
+
// Core has no renderer, so without a host every slot access throws.
|
|
22
|
+
const host = yield* Effect.serviceOption(CurrentSlots);
|
|
23
|
+
const slots = new Proxy({}, {
|
|
24
|
+
get(_t, key) {
|
|
25
|
+
if (Option.isNone(host)) {
|
|
26
|
+
throw new SlotRenderingUnavailable({ slot: String(key) });
|
|
27
|
+
}
|
|
28
|
+
return host.value.slot(String(key));
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
// A capturing host (proofs, the dev tool) reports each render's observable
|
|
32
|
+
// surface without replacing the presentation. Absent in production.
|
|
33
|
+
const sink = yield* Effect.serviceOption(CaptureSink);
|
|
34
|
+
return (props, events) => {
|
|
35
|
+
if (Option.isSome(sink)) {
|
|
36
|
+
sink.value.record({
|
|
37
|
+
name,
|
|
38
|
+
props,
|
|
39
|
+
events: (events ?? {}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return render(props, slots, (events ?? {}));
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return yieldableClass(read, {
|
|
46
|
+
[UiTypeId]: UiTypeId,
|
|
47
|
+
manifest: { kind: 'Ui', name },
|
|
48
|
+
impl,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Author the pure presentation for a contract — `Ui.make(TodoAppUi, (props,
|
|
53
|
+
* slots, events) => node)`. The contract argument fixes the view's types; wire
|
|
54
|
+
* the result with `provide(contract, view)`.
|
|
55
|
+
*/
|
|
56
|
+
export const make = (_contract, view) => view;
|
|
57
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/compose/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAChD,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,EAAgD,MAAM,QAAQ,CAAA;AAwBrE,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAY9D,oFAAoF;AACpF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAU,EAA4B,EAAE,CAC3D,CAAC,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,QAAQ,IAAI,CAAC,CAAA;AAEnF;;;;GAIG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C5D,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,cAAc,CAAC,IAAI,EAAE;QAC1B,CAAC,QAAQ,CAAC,EAAE,QAAQ;QACpB,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAa,EAAE,IAAI,EAAE;QACvC,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAA;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAuB,SAAqB,EAAE,IAAiB,EAAe,EAAE,CAClG,IAAI,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { attachInspectable } from '../internal/inspect.js';
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;AA8BtG;;;;;;;;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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Effect, PubSub, Runtime } from 'effect';
|
|
2
|
+
import { definitionClass } from '../definition/definition.js';
|
|
3
|
+
import { Bus, publish } from '../runtime/bus.js';
|
|
4
|
+
/** A pure data fact. Events depend on nothing — only reducers tie them to state. */
|
|
5
|
+
export const make = (name, schema) => {
|
|
6
|
+
const build = (payload) => ({ _tag: name, ...payload });
|
|
7
|
+
const trigger = Effect.gen(function* () {
|
|
8
|
+
const bus = yield* Bus;
|
|
9
|
+
const runtime = yield* Effect.runtime();
|
|
10
|
+
// Dispatch synchronously: on the unbounded bus `publish` only enqueues and
|
|
11
|
+
// returns, so `runSync` never suspends and no fiber is forked per UI event.
|
|
12
|
+
// The drain loop still folds reducers on its own fiber — publish is pure offer.
|
|
13
|
+
return (payload) => {
|
|
14
|
+
Runtime.runSync(runtime)(PubSub.publish(bus, { priority: 'High', event: build(payload) }));
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return definitionClass({
|
|
18
|
+
manifest: { kind: 'Event', name, schema },
|
|
19
|
+
tag: name,
|
|
20
|
+
build,
|
|
21
|
+
trigger,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/** Construct the tagged value for an event (used for `boot` events). */
|
|
25
|
+
export const construct = (event, payload) => event.build(payload);
|
|
26
|
+
/** Dispatch as a follow-up (Normal priority) from a procedure/effect. */
|
|
27
|
+
export const dispatch = (event, payload) => publish('Normal', event.build(payload));
|
|
28
|
+
/** A callback for the UI that dispatches at High priority via the runtime. */
|
|
29
|
+
export const trigger = (event) => event.trigger;
|
|
30
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/event/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAe,MAAM,QAAQ,CAAA;AAC7D,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAe,MAAM,gBAAgB,CAAA;AAyB1D,oFAAoF;AACpF,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,IAAO,EACP,MAA6B,EACX,EAAE;IACpB,MAAM,KAAK,GAAG,CAAC,OAAU,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,CAAA;QACtB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAA;QAC9C,2EAA2E;QAC3E,4EAA4E;QAC5E,gFAAgF;QAChF,OAAO,CAAC,OAAU,EAAE,EAAE;YACpB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5F,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,eAAe,CAAmB;QACvC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAgB,EAAE,IAAI,EAAE,MAAM,EAAE;QAClD,GAAG,EAAE,IAAI;QACT,KAAK;QACL,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAsB,KAAuB,EAAE,OAAU,EAAiB,EAAE,CACnG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAEtB,yEAAyE;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,KAAuB,EACvB,OAAU,EACuB,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAE7E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,KAAuB,EACgB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { definitionClass } from '../definition/definition.js';
|
|
2
|
+
/** Compose events into a group, the same variadic shape as `StateGroup`/`RpcGroup`. */
|
|
3
|
+
export const make = (...members) => definitionClass({ kind: 'EventGroup', members });
|
|
4
|
+
//# sourceMappingURL=eventGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventGroup.js","sourceRoot":"","sources":["../../../src/event/eventGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAS1D,uFAAuF;AACvF,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,GAAG,OAAgB,EACO,EAAE,CAC5B,eAAe,CAA2B,EAAE,IAAI,EAAE,YAAqB,EAAE,OAAO,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Effect, Layer } from 'effect';
|
|
2
|
+
import {} from '../runtime/loop.js';
|
|
3
|
+
import {} from '../internal/sources.js';
|
|
4
|
+
import { FeatureLoadFailed } from '../internal/errors.js';
|
|
5
|
+
import { definitionClass } from '../definition/definition.js';
|
|
6
|
+
import {} from '../compose/composition.js';
|
|
7
|
+
import {} from '../compose/ui.js';
|
|
8
|
+
import { publish } from '../runtime/bus.js';
|
|
9
|
+
/**
|
|
10
|
+
* Publish a feature's lazy half: pair its `requires` (a runtime tuple of shared
|
|
11
|
+
* carriers) with its `layer`. The covariant `RIn` bound does the checking — a
|
|
12
|
+
* layer that reaches for any service outside `EngineServices | ProvidedBy<requires>`
|
|
13
|
+
* is not assignable, so it fails to compile right here, next to the layer, with no
|
|
14
|
+
* cast. Listing an unused carrier is harmless; omitting a needed one is a type error.
|
|
15
|
+
*
|
|
16
|
+
* The bound also forbids a feature from *providing* `EngineServices` (they may only
|
|
17
|
+
* be open `RIn`), structurally enforcing the liveness rule: a feature can never
|
|
18
|
+
* bundle its own engine — it always shares the root's bus and registries.
|
|
19
|
+
*/
|
|
20
|
+
export const featureModule = (requires, layer) => ({ requires, layer });
|
|
21
|
+
/**
|
|
22
|
+
* Wrap a dynamic `import()` of a feature's `.live` module as an `Effect` — Reform
|
|
23
|
+
* never exposes a Promise/`await` on the feature surface. The unavoidable thenable
|
|
24
|
+
* is sealed here; a rejected import (missing chunk, network failure, module-eval
|
|
25
|
+
* throw) surfaces as a typed `FeatureLoadFailed` the host hands to
|
|
26
|
+
* `placeholder.failed`. The module's default export is its `FeatureModule`.
|
|
27
|
+
*/
|
|
28
|
+
export const lazyImport = (thunk) => Effect.tryPromise({
|
|
29
|
+
try: thunk,
|
|
30
|
+
catch: (cause) => new FeatureLoadFailed({ cause }),
|
|
31
|
+
}).pipe(Effect.map((module) => module.default));
|
|
32
|
+
/** Nominal brand identifying the value a `provide(slot, Feature)` puts under a slot tag. */
|
|
33
|
+
export const FeatureBindingTypeId = Symbol.for('reform/FeatureBinding');
|
|
34
|
+
/** Whether a slot's bound child is a lazy/eager feature (vs a plain composition). */
|
|
35
|
+
export const isFeatureBinding = (u) => typeof u === 'object' && u !== null && FeatureBindingTypeId in u;
|
|
36
|
+
/** Whether a value is a feature definition (its target shape in `provide(slot, Feature)`). */
|
|
37
|
+
export const isFeature = (u) => (typeof u === 'function' || typeof u === 'object') &&
|
|
38
|
+
u !== null &&
|
|
39
|
+
'manifest' in u &&
|
|
40
|
+
u.manifest?.kind === 'Feature';
|
|
41
|
+
/**
|
|
42
|
+
* Define a feature. The whole-app shape (this manifest, the composition, the
|
|
43
|
+
* placeholders) stays eager and reflectable; the `.live` layer in `module`/`load`
|
|
44
|
+
* is the deferred chunk. Flip `loadingStrategy` from `'default'` to `'lazy'` and
|
|
45
|
+
* the discriminated config *requires* `placeholder` — the compiler walks you to a
|
|
46
|
+
* complete code-split feature.
|
|
47
|
+
*/
|
|
48
|
+
export const make = (name, config) => {
|
|
49
|
+
const strategy = config.loadingStrategy ?? 'default';
|
|
50
|
+
const load = 'load' in config ? config.load : Effect.succeed(config.module);
|
|
51
|
+
const eagerModule = 'module' in config ? config.module : undefined;
|
|
52
|
+
const placeholder = 'placeholder' in config ? config.placeholder : undefined;
|
|
53
|
+
const manifest = {
|
|
54
|
+
kind: 'Feature',
|
|
55
|
+
name,
|
|
56
|
+
strategy,
|
|
57
|
+
composition: config.composition.manifest,
|
|
58
|
+
...(placeholder
|
|
59
|
+
? { placeholder: { loading: placeholder.loading.manifest, failed: placeholder.failed.manifest } }
|
|
60
|
+
: {}),
|
|
61
|
+
};
|
|
62
|
+
const binding = {
|
|
63
|
+
[FeatureBindingTypeId]: FeatureBindingTypeId,
|
|
64
|
+
manifest,
|
|
65
|
+
composition: config.composition,
|
|
66
|
+
strategy,
|
|
67
|
+
// The host is strategy-uniform: `default`'s `load` resolves immediately. The
|
|
68
|
+
// assignment to the erased `LoadedModule` needs no cast — see `LoadedModule`.
|
|
69
|
+
load,
|
|
70
|
+
...(placeholder ? { placeholder: { loading: placeholder.loading, failed: placeholder.failed } } : {}),
|
|
71
|
+
boot: config.boot ?? [],
|
|
72
|
+
};
|
|
73
|
+
return definitionClass({ manifest, load, binding, eagerModule });
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Mount a feature against a live engine. The renderer-neutral lifecycle, run on a
|
|
77
|
+
* per-feature `Scope`: load the module (an Effect — lazy = dynamic import; default
|
|
78
|
+
* = immediate), build its `.live` layer against the host's live `engineContext`
|
|
79
|
+
* (so its reducers/procedures register into the SHARED registries and its fibers
|
|
80
|
+
* fork onto this scope), then dispatch the feature's `boot`. Returns the merged
|
|
81
|
+
* context — engine services + the feature's own services — for the host to read
|
|
82
|
+
* the feature's composition and stores. Closing the scope disposes exactly this
|
|
83
|
+
* feature: its fibers stop and its stores are reclaimed.
|
|
84
|
+
*
|
|
85
|
+
* The single boundary cast (mirroring `buildRuntime`): `module.layer` is erased to
|
|
86
|
+
* `LoadedModule` so the host stays strategy- and type-uniform. The feature's real
|
|
87
|
+
* `RIn` was verified cast-free at `provide(slot, Feature)` and scene wiring; here
|
|
88
|
+
* we re-attach the concrete `engineContext` it builds against. `R` is the engine
|
|
89
|
+
* context's service set, supplied by the host.
|
|
90
|
+
*/
|
|
91
|
+
export const mountFeature = (binding, engineContext) => Effect.gen(function* () {
|
|
92
|
+
const { layer } = yield* binding.load;
|
|
93
|
+
const featureLayer = layer;
|
|
94
|
+
const context = yield* Layer.build(Layer.provideMerge(featureLayer, Layer.succeedContext(engineContext)));
|
|
95
|
+
yield* Effect.forEach(binding.boot, (event) => publish('High', event), { discard: true }).pipe(Effect.provide(context));
|
|
96
|
+
return context;
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../src/fe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CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrG,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;KACxB,CAAA;IAED,OAAO,eAAe,CAAqC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAA;AACtG,CAAC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAuB,EACvB,aAAiC,EACwC,EAAE,CAC3E,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;IACrC,MAAM,YAAY,GAAG,KAAuC,CAAA;IAC5D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAChC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CACtE,CAAA;IACD,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC5F,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CACxB,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Reform core — the renderer-neutral primitives and runtime.
|
|
2
|
+
// Definitions (`X.make`) are separate from implementations (`.live`)
|
|
3
|
+
// throughout, and nothing self-registers on import (principle #1, #6).
|
|
4
|
+
export * as State from './state/state.js';
|
|
5
|
+
export * as StateGroup from './state/stateGroup.js';
|
|
6
|
+
export * as StateFamily from './state/stateFamily.js';
|
|
7
|
+
export { StateToken } from './state/token.js';
|
|
8
|
+
export * as Event from './event/event.js';
|
|
9
|
+
export * as EventGroup from './event/eventGroup.js';
|
|
10
|
+
export * as Reducer from './reducer/reducer.js';
|
|
11
|
+
export * as Calc from './calc/calc.js';
|
|
12
|
+
export * as CalcFamily from './calc/calcFamily.js';
|
|
13
|
+
export * as AsyncCalc from './calc/asyncCalc.js';
|
|
14
|
+
export {} from './calc/asyncData.js';
|
|
15
|
+
export * as RemoteState from './remote/remoteState.js';
|
|
16
|
+
export * as Boundary from './boundary/boundary.js';
|
|
17
|
+
export * as Procedure from './procedure/procedure.js';
|
|
18
|
+
export * as Channel from './channel/channel.js';
|
|
19
|
+
export * as Composition from './compose/composition.js';
|
|
20
|
+
export { Props } from './compose/props.js';
|
|
21
|
+
export { isSlot, slot, SlotTypeId, } from './compose/slot.js';
|
|
22
|
+
export { CurrentSlots } from './compose/host.js';
|
|
23
|
+
export * as Ui from './compose/ui.js';
|
|
24
|
+
export { isUi, ui, UiTypeId, } from './compose/ui.js';
|
|
25
|
+
export { provide } from './compose/provide.js';
|
|
26
|
+
// Feature: the lazy/eager code-split unit. Definitions stay eager and reflectable;
|
|
27
|
+
// the heavy `.live` layer loads on demand (an Effect, never a Promise). See LAZY.md.
|
|
28
|
+
export * as Feature from './feature/feature.js';
|
|
29
|
+
export { FeatureBindingTypeId, featureModule, isFeature, isFeatureBinding, lazyImport, mountFeature, } from './feature/feature.js';
|
|
30
|
+
export {} from './compose/slot.js';
|
|
31
|
+
// A scene bundles a composition with the closed wiring that runs it — the single
|
|
32
|
+
// handle the react host, proofs, and the dev tool all consume.
|
|
33
|
+
export { isScene, scene, seedScene } from './scene/scene.js';
|
|
34
|
+
// Runtime surface for hosts (`@reform/react`) and headless tests.
|
|
35
|
+
export { Bus, publish } from './runtime/bus.js';
|
|
36
|
+
export { Engine, Reducers } from './runtime/loop.js';
|
|
37
|
+
export { Channels, Procedures, } from './channel/channel.js';
|
|
38
|
+
export { CurrentTracker } from './internal/track.js';
|
|
39
|
+
export { CaptureSink } from './internal/capture.js';
|
|
40
|
+
export { AsyncReducer, DuplicateRegistration, FeatureLoadFailed, InvalidProvideTarget, SlotRenderingUnavailable, UnknownGroupState, } from './internal/errors.js';
|
|
41
|
+
// Notification scheduler: hosts that need per-runtime isolation (concurrent SSR,
|
|
42
|
+
// multiple mounted roots) provide `Notifications` upstream of their state layers;
|
|
43
|
+
// everything else coalesces on the process-wide default.
|
|
44
|
+
export { defaultScheduler, makeScheduler, Notifications, notificationsLayer, } from './internal/scheduler.js';
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,qEAAqE;AACrE,uEAAuE;AAEvE,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AAKtC,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAK7C,OAAO,EAMN,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AAKnD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAS/C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK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,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,GAEnB,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* An OPTIONAL service. Core's `ui` read consults it via `serviceOption`: when a
|
|
4
|
+
* capturing host provides it (proofs, the dev tool), every resolved view reports
|
|
5
|
+
* its `(props, events)` before rendering, giving a faithful tree without
|
|
6
|
+
* replacing any presentation. Production never provides it, so nothing is
|
|
7
|
+
* recorded and there is no cost beyond one `serviceOption` lookup per render.
|
|
8
|
+
*/
|
|
9
|
+
export class CaptureSink extends Context.Tag('reform/internal/CaptureSink')() {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../../src/internal/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAmBhC;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAGxE;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctx.js","sourceRoot":"","sources":["../../../src/internal/ctx.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Data } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Tagged errors for the framework's synchronous boundaries. Even when thrown
|
|
4
|
+
* (React render, layer build, reflection), an error carries a `_tag` and its
|
|
5
|
+
* structured fields — never a bare `Error` — so callers and tooling can match on
|
|
6
|
+
* it. `Data.TaggedError` subclasses are real `Error`s, so `throw` still works.
|
|
7
|
+
*/
|
|
8
|
+
/** A `<slots.X/>` was rendered without a render-target host to realize it. */
|
|
9
|
+
export class SlotRenderingUnavailable extends Data.TaggedError('reform/SlotRenderingUnavailable') {
|
|
10
|
+
get message() {
|
|
11
|
+
return `reform: rendering slot '${this.slot}' requires @reform/react`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** `provide(target, …)` was handed something that is neither a ui contract nor a slot. */
|
|
15
|
+
export class InvalidProvideTarget extends Data.TaggedError('reform/InvalidProvideTarget') {
|
|
16
|
+
get message() {
|
|
17
|
+
return 'reform: provide target is neither a ui contract nor a slot';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** `StateGroup.select(group, name)` named a state the group does not contain. */
|
|
21
|
+
export class UnknownGroupState extends Data.TaggedError('reform/UnknownGroupState') {
|
|
22
|
+
get message() {
|
|
23
|
+
return `reform: unknown state '${this.name}' in group`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A lazy `Feature`'s `load` Effect failed — the dynamic `import()` rejected (a
|
|
28
|
+
* missing chunk, a network failure, a module-eval throw). Surfaced as a typed
|
|
29
|
+
* failure the host hands to the feature's `placeholder.failed`, never a bare
|
|
30
|
+
* rejection. `cause` is the original rejection value.
|
|
31
|
+
*/
|
|
32
|
+
export class FeatureLoadFailed extends Data.TaggedError('reform/FeatureLoadFailed') {
|
|
33
|
+
get message() {
|
|
34
|
+
return `reform: a feature failed to load (${String(this.cause)})`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** A reducer fold returned a thenable — folds must be pure synchronous writes. */
|
|
38
|
+
export class AsyncReducer extends Data.TaggedError('reform/AsyncReducer') {
|
|
39
|
+
get message() {
|
|
40
|
+
return 'reform: a reducer fold must be synchronous (it returned a Promise)';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Two distinct primitives were registered under one name into the same runtime —
|
|
45
|
+
* a silent footgun, since names key DI tags and channel lanes. Thrown for a
|
|
46
|
+
* channel name reused with a different policy (the second would otherwise be
|
|
47
|
+
* dropped). Reducer/procedure name clashes are warned (logged), not thrown.
|
|
48
|
+
*/
|
|
49
|
+
export class DuplicateRegistration extends Data.TaggedError('reform/DuplicateRegistration') {
|
|
50
|
+
get message() {
|
|
51
|
+
return `reform: duplicate ${this.kind} registered under name '${this.name}'`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B;;;;;GAKG;AAEH,8EAA8E;AAC9E,MAAM,OAAO,wBAAyB,SAAQ,IAAI,CAAC,WAAW,CAAC,iCAAiC,CAE9F;IACA,IAAa,OAAO;QAClB,OAAO,2BAA2B,IAAI,CAAC,IAAI,0BAA0B,CAAA;IACvE,CAAC;CACF;AAED,0FAA0F;AAC1F,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,6BAA6B,CAAK;IAC3F,IAAa,OAAO;QAClB,OAAO,4DAA4D,CAAA;IACrE,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAEhF;IACA,IAAa,OAAO;QAClB,OAAO,0BAA0B,IAAI,CAAC,IAAI,YAAY,CAAA;IACxD,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAEhF;IACA,IAAa,OAAO;QAClB,OAAO,qCAAqC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IACnE,CAAC;CACF;AAED,kFAAkF;AAClF,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAK;IAC3E,IAAa,OAAO;QAClB,OAAO,oEAAoE,CAAA;IAC7E,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAGxF;IACA,IAAa,OAAO;QAClB,OAAO,qBAAqB,IAAI,CAAC,IAAI,2BAA2B,IAAI,CAAC,IAAI,GAAG,CAAA;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { format, NodeInspectSymbol } from 'effect/Inspectable';
|
|
2
|
+
export { NodeInspectSymbol };
|
|
3
|
+
/**
|
|
4
|
+
* The `Inspectable` trio built around a `toJSON`, so every reform value prints
|
|
5
|
+
* like an Effect value — `_id`-tagged JSON under `console.log`, Node's
|
|
6
|
+
* inspector, `JSON.stringify`, and `String(...)` — instead of `[object Object]`.
|
|
7
|
+
* Mirrors Effect's `BaseProto` / `Inspectable.Class` (`Inspectable.ts:170`).
|
|
8
|
+
*/
|
|
9
|
+
export const inspectable = (toJSON) => ({
|
|
10
|
+
toJSON,
|
|
11
|
+
toString: () => format(toJSON()),
|
|
12
|
+
[NodeInspectSymbol]: () => toJSON(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Attach the `Inspectable` trio to an existing object as *non-enumerable* own
|
|
16
|
+
* properties (so they don't show up in `Object.keys`/`for…in` over a definition
|
|
17
|
+
* class). Used where the value is built by other means — the definition classes,
|
|
18
|
+
* whose statics are merged in separately.
|
|
19
|
+
*/
|
|
20
|
+
export const attachInspectable = (target, toJSON) => {
|
|
21
|
+
const trio = inspectable(toJSON);
|
|
22
|
+
for (const key of Reflect.ownKeys(trio)) {
|
|
23
|
+
Object.defineProperty(target, key, {
|
|
24
|
+
value: trio[key],
|
|
25
|
+
enumerable: false,
|
|
26
|
+
writable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../../src/internal/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEhF,OAAO,EAAoB,iBAAiB,EAAE,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAqB,EAAe,EAAE,CAAC,CAAC;IAClE,MAAM;IACN,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE;CACpC,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAmB,MAAS,EAAE,MAAqB,EAAK,EAAE;IACzF,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAA4C,CAAA;IAC3E,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;YAChB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Brand, Cause, Chunk, Effect, MutableRef, Option, Queue, Schema, Stream, } from 'effect';
|
|
2
|
+
import { AsyncData } from '../calc/asyncData.js';
|
|
3
|
+
import { reuse } from './reuse.js';
|
|
4
|
+
import { resolveScheduler } from './scheduler.js';
|
|
5
|
+
import { sameKey, wireSources, } from './sources.js';
|
|
6
|
+
import { makeStore } from './store.js';
|
|
7
|
+
import {} from '../state/token.js';
|
|
8
|
+
/** The runtime gated flag for an `alwaysOn` config, typed as its `Gated` literal. */
|
|
9
|
+
export const gatedFlag = (alwaysOn) => (alwaysOn !== true);
|
|
10
|
+
export const Revision = Brand.nominal();
|
|
11
|
+
export const RevisionSchema = Schema.Number.pipe(Schema.brand('reform/Revision'));
|
|
12
|
+
export const revisionZero = Revision(0);
|
|
13
|
+
export const bumpRevision = (r) => Revision(r + 1);
|
|
14
|
+
/**
|
|
15
|
+
* Build the driver: store + subscription + request queue + run fiber, all owned
|
|
16
|
+
* by the ambient scope (callers run this under `Layer.scoped`). A change to an
|
|
17
|
+
* input re-runs the query latest-wins (a new run cancels the in-flight one; or,
|
|
18
|
+
* with `coalesce: 'trailing'`, lets it finish and runs one trailing refetch);
|
|
19
|
+
* while a re-run is in flight the last `Success`/`Error` is kept with
|
|
20
|
+
* `refetching: true`.
|
|
21
|
+
*/
|
|
22
|
+
export const makeQueryDriver = (options) => Effect.gen(function* () {
|
|
23
|
+
const scheduler = yield* resolveScheduler;
|
|
24
|
+
const sources = yield* wireSources(options.inputs, options.invalidateBy);
|
|
25
|
+
const extraKey = options.extraKey;
|
|
26
|
+
const keyOf = (args) => extraKey === undefined ? sources.keyOf(args) : [...sources.keyOf(args), extraKey.read()];
|
|
27
|
+
const subscribeAll = (listener) => {
|
|
28
|
+
const offSources = sources.subscribe(listener);
|
|
29
|
+
const offExtra = extraKey?.subscribe(listener);
|
|
30
|
+
return () => {
|
|
31
|
+
offSources();
|
|
32
|
+
offExtra?.();
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const disabledNow = (args = sources.snapshot()) => options.gated && options.disabled !== undefined ? options.disabled(args) : false;
|
|
36
|
+
const store = makeStore(disabledNow() ? AsyncData.idle : AsyncData.loading, scheduler);
|
|
37
|
+
// The last requested key, so a change that doesn't move it (or only churns
|
|
38
|
+
// an input `invalidateBy` ignores) doesn't re-fetch.
|
|
39
|
+
const lastKey = MutableRef.make(undefined);
|
|
40
|
+
// The run-generation counter: bumped when a run is REQUESTED (enqueued), so
|
|
41
|
+
// `requested()` names the newest run that could possibly be in flight.
|
|
42
|
+
const generation = MutableRef.make(0);
|
|
43
|
+
const nextGeneration = () => {
|
|
44
|
+
MutableRef.update(generation, (n) => n + 1);
|
|
45
|
+
return MutableRef.get(generation);
|
|
46
|
+
};
|
|
47
|
+
// Mark a re-fetch in flight without dropping the visible value (SWR).
|
|
48
|
+
const markRefetching = () => {
|
|
49
|
+
const prev = store.get();
|
|
50
|
+
if (prev._tag === 'Success')
|
|
51
|
+
store.set(AsyncData.success(prev.value, true));
|
|
52
|
+
else if (prev._tag === 'Error')
|
|
53
|
+
store.set(AsyncData.error(prev.error, true));
|
|
54
|
+
else
|
|
55
|
+
store.set(AsyncData.loading);
|
|
56
|
+
};
|
|
57
|
+
// One run of the query, folded into the store. A failure becomes `Error`; an
|
|
58
|
+
// interrupt (latest-wins cancel) leaves the state untouched; a defect (a bug
|
|
59
|
+
// in the body) is logged and isolated — the driver keeps running. A `Success`
|
|
60
|
+
// additionally reports its generation through `onSettled`, after the write,
|
|
61
|
+
// so settle-driven consequences observe the converged value.
|
|
62
|
+
const runQuery = (request) => options.query(request.args).pipe(Effect.tapDefect((defect) => Effect.logError(`reform: ${options.label} '${options.name}' query defect`, defect)), Effect.matchCause({
|
|
63
|
+
onSuccess: (value) => {
|
|
64
|
+
if (!disabledNow()) {
|
|
65
|
+
// `reuse`: share unchanged subtrees with the previous Success
|
|
66
|
+
// value, so a refetch that barely moved keeps identities stable.
|
|
67
|
+
const prev = store.get();
|
|
68
|
+
const shared = options.reuse === true && prev._tag === 'Success'
|
|
69
|
+
? reuse(prev.value, value)
|
|
70
|
+
: value;
|
|
71
|
+
store.set(AsyncData.success(shared, false));
|
|
72
|
+
options.onSettled?.(request.generation);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onFailure: (cause) => {
|
|
76
|
+
const failure = Cause.failureOption(cause);
|
|
77
|
+
if (Option.isSome(failure) && !disabledNow()) {
|
|
78
|
+
store.set(AsyncData.error(failure.value, false));
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
// The driver. `'switch'` (default): each new request cancels the in-flight
|
|
83
|
+
// run — the same latest-wins semantics a `latest` channel gives procedures.
|
|
84
|
+
// `'trailing'`: a strictly sequential consumer that, on wake, drains every
|
|
85
|
+
// request that piled up during the flight and runs the LATEST one —
|
|
86
|
+
// "exactly one trailing run after settle" by construction. The trailing
|
|
87
|
+
// run's generation is the max drained (the latest request's), so it
|
|
88
|
+
// vouches for every request it conflated.
|
|
89
|
+
const trailing = options.coalesce === 'trailing';
|
|
90
|
+
const requests = yield* Queue.unbounded();
|
|
91
|
+
yield* Effect.forkScoped(trailing
|
|
92
|
+
? Effect.forever(Effect.gen(function* () {
|
|
93
|
+
const first = yield* Queue.take(requests);
|
|
94
|
+
const queued = yield* Queue.takeAll(requests);
|
|
95
|
+
const request = Option.getOrElse(Chunk.last(queued), () => first);
|
|
96
|
+
// A disable that landed while the request waited: skip the run.
|
|
97
|
+
if (!disabledNow())
|
|
98
|
+
yield* runQuery(request);
|
|
99
|
+
// The settle may have written a stale-key result with
|
|
100
|
+
// `refetching: false`; if a newer request is already waiting,
|
|
101
|
+
// restore the syncing flag before the next take — both writes
|
|
102
|
+
// coalesce into one scheduler flush for subscribers.
|
|
103
|
+
const pending = yield* Queue.size(requests);
|
|
104
|
+
if (pending > 0 && !disabledNow())
|
|
105
|
+
yield* Effect.sync(markRefetching);
|
|
106
|
+
}))
|
|
107
|
+
: Stream.fromQueue(requests).pipe(Stream.flatMap((request) => Stream.fromEffect(runQuery(request)), { switch: true }), Stream.runDrain));
|
|
108
|
+
const trigger = () => {
|
|
109
|
+
const args = sources.snapshot();
|
|
110
|
+
if (disabledNow(args)) {
|
|
111
|
+
// Switched off: show Idle and forget the key so re-enabling always re-runs.
|
|
112
|
+
MutableRef.set(lastKey, undefined);
|
|
113
|
+
store.set(AsyncData.idle);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const key = keyOf(args);
|
|
117
|
+
const previous = MutableRef.get(lastKey);
|
|
118
|
+
if (previous !== undefined && sameKey(key, previous))
|
|
119
|
+
return;
|
|
120
|
+
MutableRef.set(lastKey, key);
|
|
121
|
+
markRefetching();
|
|
122
|
+
Queue.unsafeOffer(requests, { args, generation: nextGeneration() });
|
|
123
|
+
};
|
|
124
|
+
const unsubscribe = subscribeAll(trigger);
|
|
125
|
+
yield* Effect.addFinalizer(() => Effect.sync(unsubscribe));
|
|
126
|
+
// Kick off the first fetch unless the query starts disabled.
|
|
127
|
+
const initial = sources.snapshot();
|
|
128
|
+
if (!disabledNow(initial)) {
|
|
129
|
+
MutableRef.set(lastKey, keyOf(initial));
|
|
130
|
+
Queue.unsafeOffer(requests, { args: initial, generation: nextGeneration() });
|
|
131
|
+
}
|
|
132
|
+
return { store, requested: () => MutableRef.get(generation) };
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=queryDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryDriver.js","sourceRoot":"","sources":["../../../src/internal/queryDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EAEN,MAAM,GACP,MAAM,QAAQ,CAAA;AACf,OAAO,EAAqB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAIL,OAAO,EACP,WAAW,GACZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAkB,MAAM,gBAAgB,CAAA;AAW/C,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG,CAA2B,QAA8B,EAAqB,EAAE,CACvG,CAAC,QAAQ,KAAK,IAAI,CAAsB,CAAA;AAU1C,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,O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