@playfast/reform 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boundary/boundary.d.ts +72 -0
- package/dist/boundary/boundary.d.ts.map +1 -0
- package/dist/boundary/boundary.js +83 -0
- package/dist/boundary/boundary.js.map +1 -0
- package/dist/calc/asyncCalc.d.ts +91 -0
- package/dist/calc/asyncCalc.d.ts.map +1 -0
- package/dist/calc/asyncCalc.js +95 -0
- package/dist/calc/asyncCalc.js.map +1 -0
- package/{src/calc/asyncData.ts → dist/calc/asyncData.d.ts} +22 -53
- package/dist/calc/asyncData.d.ts.map +1 -0
- package/dist/calc/asyncData.js +34 -0
- package/dist/calc/asyncData.js.map +1 -0
- package/dist/calc/calc.d.ts +57 -0
- package/dist/calc/calc.d.ts.map +1 -0
- package/dist/calc/calc.js +58 -0
- package/dist/calc/calc.js.map +1 -0
- package/dist/calc/calcFamily.d.ts +57 -0
- package/dist/calc/calcFamily.d.ts.map +1 -0
- package/dist/calc/calcFamily.js +124 -0
- package/dist/calc/calcFamily.js.map +1 -0
- package/dist/calc/compose.d.ts +16 -0
- package/dist/calc/compose.d.ts.map +1 -0
- package/dist/calc/compose.js +7 -0
- package/dist/calc/compose.js.map +1 -0
- package/dist/channel/channel.d.ts +115 -0
- package/dist/channel/channel.d.ts.map +1 -0
- package/dist/channel/channel.js +138 -0
- package/dist/channel/channel.js.map +1 -0
- package/dist/compose/composition.d.ts +72 -0
- package/dist/compose/composition.d.ts.map +1 -0
- package/dist/compose/composition.js +46 -0
- package/dist/compose/composition.js.map +1 -0
- package/{src/compose/host.ts → dist/compose/host.d.ts} +8 -6
- package/dist/compose/host.d.ts.map +1 -0
- package/dist/compose/host.js +6 -0
- package/dist/compose/host.js.map +1 -0
- package/dist/compose/props.d.ts +13 -0
- package/dist/compose/props.d.ts.map +1 -0
- package/{src/compose/props.ts → dist/compose/props.js} +5 -3
- package/dist/compose/props.js.map +1 -0
- package/dist/compose/provide.d.ts +22 -0
- package/dist/compose/provide.d.ts.map +1 -0
- package/dist/compose/provide.js +28 -0
- package/dist/compose/provide.js.map +1 -0
- package/{src/compose/slot.ts → dist/compose/slot.d.ts} +19 -36
- package/dist/compose/slot.d.ts.map +1 -0
- package/dist/compose/slot.js +23 -0
- package/dist/compose/slot.js.map +1 -0
- package/dist/compose/ui.d.ts +135 -0
- package/dist/compose/ui.d.ts.map +1 -0
- package/dist/compose/ui.js +63 -0
- package/dist/compose/ui.js.map +1 -0
- package/dist/definition/definition.d.ts +33 -0
- package/dist/definition/definition.d.ts.map +1 -0
- package/dist/definition/definition.js +42 -0
- package/dist/definition/definition.js.map +1 -0
- package/dist/event/event.d.ts +33 -0
- package/dist/event/event.d.ts.map +1 -0
- package/dist/event/event.js +30 -0
- package/dist/event/event.js.map +1 -0
- package/dist/event/eventGroup.d.ts +9 -0
- package/dist/event/eventGroup.d.ts.map +1 -0
- package/dist/event/eventGroup.js +4 -0
- package/dist/event/eventGroup.js.map +1 -0
- package/{src/feature/feature.ts → dist/feature/feature.d.ts} +92 -178
- package/dist/feature/feature.d.ts.map +1 -0
- package/dist/feature/feature.js +98 -0
- package/dist/feature/feature.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/{src/internal/capture.ts → dist/internal/capture.d.ts} +11 -13
- package/dist/internal/capture.d.ts.map +1 -0
- package/dist/internal/capture.js +12 -0
- package/dist/internal/capture.js.map +1 -0
- package/{src/internal/ctx.ts → dist/internal/ctx.d.ts} +4 -8
- package/dist/internal/ctx.d.ts.map +1 -0
- package/dist/internal/ctx.js +2 -0
- package/dist/internal/ctx.js.map +1 -0
- package/dist/internal/errors.d.ts +89 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +102 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/inspect.d.ts +17 -0
- package/dist/internal/inspect.d.ts.map +1 -0
- package/dist/internal/inspect.js +32 -0
- package/dist/internal/inspect.js.map +1 -0
- package/dist/internal/queryDriver.d.ts +65 -0
- package/dist/internal/queryDriver.d.ts.map +1 -0
- package/dist/internal/queryDriver.js +134 -0
- package/dist/internal/queryDriver.js.map +1 -0
- package/dist/internal/reuse.d.ts +10 -0
- package/dist/internal/reuse.d.ts.map +1 -0
- package/dist/internal/reuse.js +68 -0
- package/dist/internal/reuse.js.map +1 -0
- package/dist/internal/scheduler.d.ts +47 -0
- package/dist/internal/scheduler.d.ts.map +1 -0
- package/dist/internal/scheduler.js +70 -0
- package/dist/internal/scheduler.js.map +1 -0
- package/{src/internal/seeds.ts → dist/internal/seeds.d.ts} +3 -6
- package/dist/internal/seeds.d.ts.map +1 -0
- package/dist/internal/seeds.js +17 -0
- package/dist/internal/seeds.js.map +1 -0
- package/dist/internal/sources.d.ts +39 -0
- package/dist/internal/sources.d.ts.map +1 -0
- package/dist/internal/sources.js +59 -0
- package/dist/internal/sources.js.map +1 -0
- package/dist/internal/stateRegistry.d.ts +2 -0
- package/dist/internal/stateRegistry.d.ts.map +1 -0
- package/dist/internal/stateRegistry.js +28 -0
- package/dist/internal/stateRegistry.js.map +1 -0
- package/dist/internal/store.d.ts +47 -0
- package/dist/internal/store.d.ts.map +1 -0
- package/dist/internal/store.js +73 -0
- package/dist/internal/store.js.map +1 -0
- package/{src/internal/track.ts → dist/internal/track.d.ts} +11 -15
- package/dist/internal/track.d.ts.map +1 -0
- package/dist/internal/track.js +19 -0
- package/dist/internal/track.js.map +1 -0
- package/dist/procedure/procedure.d.ts +40 -0
- package/dist/procedure/procedure.d.ts.map +1 -0
- package/dist/procedure/procedure.js +50 -0
- package/dist/procedure/procedure.js.map +1 -0
- package/dist/reducer/reducer.d.ts +44 -0
- package/dist/reducer/reducer.d.ts.map +1 -0
- package/dist/reducer/reducer.js +63 -0
- package/dist/reducer/reducer.js.map +1 -0
- package/dist/remote/remoteState.d.ts +119 -0
- package/dist/remote/remoteState.d.ts.map +1 -0
- package/dist/remote/remoteState.js +270 -0
- package/dist/remote/remoteState.js.map +1 -0
- package/dist/runtime/bus.d.ts +27 -0
- package/dist/runtime/bus.d.ts.map +1 -0
- package/{src/runtime/bus.ts → dist/runtime/bus.js} +8 -23
- package/dist/runtime/bus.js.map +1 -0
- package/dist/runtime/loop.d.ts +45 -0
- package/dist/runtime/loop.d.ts.map +1 -0
- package/dist/runtime/loop.js +117 -0
- package/dist/runtime/loop.js.map +1 -0
- package/dist/scene/scene.d.ts +44 -0
- package/dist/scene/scene.d.ts.map +1 -0
- package/dist/scene/scene.js +31 -0
- package/dist/scene/scene.js.map +1 -0
- package/dist/state/state.d.ts +37 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.js +46 -0
- package/dist/state/state.js.map +1 -0
- package/dist/state/stateFamily.d.ts +79 -0
- package/dist/state/stateFamily.d.ts.map +1 -0
- package/dist/state/stateFamily.js +99 -0
- package/dist/state/stateFamily.js.map +1 -0
- package/dist/state/stateGroup.d.ts +50 -0
- package/dist/state/stateGroup.d.ts.map +1 -0
- package/dist/state/stateGroup.js +54 -0
- package/dist/state/stateGroup.js.map +1 -0
- package/{src/state/token.ts → dist/state/token.d.ts} +13 -21
- package/dist/state/token.d.ts.map +1 -0
- package/dist/state/token.js +20 -0
- package/dist/state/token.js.map +1 -0
- package/dist/synced/syncedStore.d.ts +51 -0
- package/dist/synced/syncedStore.d.ts.map +1 -0
- package/dist/synced/syncedStore.js +43 -0
- package/dist/synced/syncedStore.js.map +1 -0
- package/{src/ui/node.ts → dist/ui/node.d.ts} +3 -3
- package/dist/ui/node.d.ts.map +1 -0
- package/dist/ui/node.js +2 -0
- package/dist/ui/node.js.map +1 -0
- package/{src/ui/trigger.ts → dist/ui/trigger.d.ts} +2 -1
- package/dist/ui/trigger.d.ts.map +1 -0
- package/dist/ui/trigger.js +2 -0
- package/dist/ui/trigger.js.map +1 -0
- package/dist/wire/tree.d.ts +66 -0
- package/dist/wire/tree.d.ts.map +1 -0
- package/dist/wire/tree.js +60 -0
- package/dist/wire/tree.js.map +1 -0
- package/dist/wire/triggers.d.ts +44 -0
- package/dist/wire/triggers.d.ts.map +1 -0
- package/dist/wire/triggers.js +31 -0
- package/dist/wire/triggers.js.map +1 -0
- package/package.json +32 -11
- package/src/boundary/boundary.ts +0 -192
- package/src/calc/asyncCalc.ts +0 -267
- package/src/calc/calc.ts +0 -120
- package/src/calc/calcFamily.ts +0 -194
- package/src/calc/compose.ts +0 -69
- package/src/channel/channel.ts +0 -265
- package/src/compose/composition.ts +0 -112
- package/src/compose/provide.ts +0 -70
- package/src/compose/ui.ts +0 -97
- package/src/definition/definition.ts +0 -74
- package/src/event/event.ts +0 -65
- package/src/event/eventGroup.ts +0 -14
- package/src/index.ts +0 -140
- package/src/internal/errors.ts +0 -69
- package/src/internal/inspect.ts +0 -34
- package/src/internal/queryDriver.ts +0 -247
- package/src/internal/reuse.ts +0 -73
- package/src/internal/scheduler.ts +0 -91
- package/src/internal/sources.ts +0 -104
- package/src/internal/store.ts +0 -105
- package/src/procedure/procedure.ts +0 -89
- package/src/reducer/reducer.ts +0 -137
- package/src/remote/remoteState.ts +0 -571
- package/src/runtime/loop.ts +0 -169
- package/src/scene/scene.ts +0 -76
- package/src/state/state.ts +0 -91
- package/src/state/stateFamily.ts +0 -171
- package/src/state/stateGroup.ts +0 -78
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
|
@@ -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;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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7D,OAAO,EAAE,KAAK,Q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AM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;AAEzF,oFAAoF;AACpF,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC5C,MAAM,CAAC,EACP,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,KAC5B,UAAU,CAAC,CAAC,EAAE,CAAC,CAkBjB,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,KAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAC3E,CAAA;AAEtB,yEAAyE;AACzE,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAC1C,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,SAAS,CAAC,KACT,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAA4C,CAAA;AAE7E,8EAA8E;AAC9E,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EACzC,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KACtB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAkB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Effect, PubSub, Runtime } from 'effect';
|
|
2
|
+
import { definitionClass } from '../definition/definition';
|
|
3
|
+
import { Bus, publish } from '../runtime/bus';
|
|
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,9 @@
|
|
|
1
|
+
import type { AnyEvent } from './event';
|
|
2
|
+
export interface EventGroupClass<Members extends ReadonlyArray<AnyEvent>> {
|
|
3
|
+
new (): {};
|
|
4
|
+
readonly kind: 'EventGroup';
|
|
5
|
+
readonly members: Members;
|
|
6
|
+
}
|
|
7
|
+
/** Compose events into a group, the same variadic shape as `StateGroup`/`RpcGroup`. */
|
|
8
|
+
export declare const make: <const Members extends ReadonlyArray<AnyEvent>>(...members: Members) => EventGroupClass<Members>;
|
|
9
|
+
//# sourceMappingURL=eventGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventGroup.d.ts","sourceRoot":"","sources":["../../src/event/eventGroup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,eAAe,CAAC,OAAO,SAAS,aAAa,CAAC,QAAQ,CAAC;IACtE,QAAQ,EAAE,CAAA;IACV,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,uFAAuF;AACvF,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,OAAO,SAAS,aAAa,CAAC,QAAQ,CAAC,EAChE,GAAG,SAAS,OAAO,KAClB,eAAe,CAAC,OAAO,CAC2D,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { definitionClass } from '../definition/definition';
|
|
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"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { type Context, Effect, Layer, type Scope } from 'effect'
|
|
2
|
-
import { type Engine } from '../runtime/loop'
|
|
3
|
-
import { type StoresOf } from '../internal/sources'
|
|
4
|
-
import { FeatureLoadFailed } from '../internal/errors'
|
|
5
|
-
import { type Manifest
|
|
6
|
-
import { type CompositionClass } from '../compose/composition'
|
|
7
|
-
import { type UiContract } from '../compose/ui'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
// A `Feature` is the unit of lazy code-split, ownership, reflection, and proof.
|
|
11
|
-
// It splits on the seam Reform already has: definitions (manifests, schemas, the
|
|
12
|
-
// composition class, placeholders) stay eager and reflectable; the heavy `.live`
|
|
13
|
-
// layer loads on demand. The whole-app *shape* stays inspectable with no chunk
|
|
14
|
-
// loaded. Everything here is additive — `provide(slot, Composition)` and eager
|
|
15
|
-
// scenes are unchanged. See `LAZY.md` for the design rationale and variance proof.
|
|
16
|
-
|
|
1
|
+
import { type Context, Effect, Layer, type Scope } from 'effect';
|
|
2
|
+
import { type Engine } from '../runtime/loop';
|
|
3
|
+
import { type StoresOf } from '../internal/sources';
|
|
4
|
+
import { FeatureLoadFailed } from '../internal/errors';
|
|
5
|
+
import { type Manifest } from '../definition/definition';
|
|
6
|
+
import { type CompositionClass } from '../compose/composition';
|
|
7
|
+
import { type UiContract } from '../compose/ui';
|
|
8
|
+
import { type Tagged } from '../runtime/bus';
|
|
17
9
|
/**
|
|
18
10
|
* The always-on engine services a feature builds against: the shared event `Bus`
|
|
19
11
|
* plus the reducer/channel/procedure registries. Derived from the `Engine`
|
|
@@ -21,18 +13,20 @@ import { publish, type Tagged } from '../runtime/bus'
|
|
|
21
13
|
* these only as OPEN requirements (its `RIn`) and must never *provide* them — that
|
|
22
14
|
* is what keeps the engine single and shared across every lazily-mounted feature.
|
|
23
15
|
*/
|
|
24
|
-
export type EngineServices = Layer.Layer.Success<typeof Engine
|
|
25
|
-
|
|
16
|
+
export type EngineServices = Layer.Layer.Success<typeof Engine>;
|
|
26
17
|
/**
|
|
27
18
|
* A shared-state carrier a feature may declare in `requires`: a `State`,
|
|
28
19
|
* `StateFamily`, `Calc`, or `AsyncCalc` (each carrying a `store` tag), or a
|
|
29
20
|
* `StateGroup` (carrying `members`, each with its own `store`). Per the design,
|
|
30
21
|
* a feature depends on shared state/calc only — never on another feature.
|
|
31
22
|
*/
|
|
32
|
-
export type RequireCarrier =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
export type RequireCarrier = {
|
|
24
|
+
readonly store: Context.Tag<any, any>;
|
|
25
|
+
} | {
|
|
26
|
+
readonly members: ReadonlyArray<{
|
|
27
|
+
readonly store: Context.Tag<any, any>;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
36
30
|
/**
|
|
37
31
|
* The Context services a `requires` tuple makes available to a feature layer: a
|
|
38
32
|
* `StateGroup` contributes its members' stores (the shared `StoresOf`); every
|
|
@@ -43,15 +37,12 @@ export type RequireCarrier =
|
|
|
43
37
|
* is ordinary assignability — no `as`, no `infer` gymnastics in user code.
|
|
44
38
|
*/
|
|
45
39
|
export type ProvidedBy<Requires extends ReadonlyArray<RequireCarrier>> = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
: never
|
|
53
|
-
}[number]
|
|
54
|
-
|
|
40
|
+
[I in keyof Requires]: Requires[I] extends {
|
|
41
|
+
readonly members: infer M extends ReadonlyArray<unknown>;
|
|
42
|
+
} ? StoresOf<M> : Requires[I] extends {
|
|
43
|
+
readonly store: Context.Tag<infer Svc, any>;
|
|
44
|
+
} ? Svc : never;
|
|
45
|
+
}[number];
|
|
55
46
|
/**
|
|
56
47
|
* A loaded feature's two artifacts. `requires` is the runtime-enumerable list the
|
|
57
48
|
* editor reads (types are erased, so the carriers are kept as values); `layer` is
|
|
@@ -62,10 +53,9 @@ export type ProvidedBy<Requires extends ReadonlyArray<RequireCarrier>> = {
|
|
|
62
53
|
* a feature's lazy half.
|
|
63
54
|
*/
|
|
64
55
|
export interface FeatureModule<ROut, Requires extends ReadonlyArray<RequireCarrier>> {
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
readonly requires: Requires;
|
|
57
|
+
readonly layer: Layer.Layer<ROut, never, EngineServices | ProvidedBy<Requires>>;
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
/**
|
|
70
60
|
* Publish a feature's lazy half: pair its `requires` (a runtime tuple of shared
|
|
71
61
|
* carriers) with its `layer`. The covariant `RIn` bound does the checking — a
|
|
@@ -77,11 +67,7 @@ export interface FeatureModule<ROut, Requires extends ReadonlyArray<RequireCarri
|
|
|
77
67
|
* be open `RIn`), structurally enforcing the liveness rule: a feature can never
|
|
78
68
|
* bundle its own engine — it always shares the root's bus and registries.
|
|
79
69
|
*/
|
|
80
|
-
export const featureModule
|
|
81
|
-
requires: Requires,
|
|
82
|
-
layer: Layer.Layer<ROut, never, EngineServices | ProvidedBy<Requires>>,
|
|
83
|
-
): FeatureModule<ROut, Requires> => ({ requires, layer })
|
|
84
|
-
|
|
70
|
+
export declare const featureModule: <const Requires extends ReadonlyArray<RequireCarrier>, ROut>(requires: Requires, layer: Layer.Layer<ROut, never, EngineServices | ProvidedBy<Requires>>) => FeatureModule<ROut, Requires>;
|
|
85
71
|
/**
|
|
86
72
|
* Wrap a dynamic `import()` of a feature's `.live` module as an `Effect` — Reform
|
|
87
73
|
* never exposes a Promise/`await` on the feature surface. The unavoidable thenable
|
|
@@ -89,20 +75,14 @@ export const featureModule = <const Requires extends ReadonlyArray<RequireCarrie
|
|
|
89
75
|
* throw) surfaces as a typed `FeatureLoadFailed` the host hands to
|
|
90
76
|
* `placeholder.failed`. The module's default export is its `FeatureModule`.
|
|
91
77
|
*/
|
|
92
|
-
export const lazyImport
|
|
93
|
-
|
|
94
|
-
)
|
|
95
|
-
Effect.tryPromise({
|
|
96
|
-
try: thunk,
|
|
97
|
-
catch: (cause) => new FeatureLoadFailed({ cause }),
|
|
98
|
-
}).pipe(Effect.map((module) => module.default))
|
|
99
|
-
|
|
78
|
+
export declare const lazyImport: <M>(thunk: () => Promise<{
|
|
79
|
+
readonly default: M;
|
|
80
|
+
}>) => Effect.Effect<M, FeatureLoadFailed>;
|
|
100
81
|
/** The props the host injects into a lazy feature's `failed` placeholder. */
|
|
101
82
|
export interface FailedProps {
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
readonly error: FeatureLoadFailed;
|
|
84
|
+
readonly retry: () => void;
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
/**
|
|
107
87
|
* The reflectable shape of a feature: its strategy, the composition it mounts,
|
|
108
88
|
* and (when lazy) its placeholder compositions — all as manifests, so the editor
|
|
@@ -110,16 +90,21 @@ export interface FailedProps {
|
|
|
110
90
|
* runtime data and lives on the `FeatureBinding`, not here.
|
|
111
91
|
*/
|
|
112
92
|
export interface FeatureManifest extends Manifest {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
readonly
|
|
120
|
-
|
|
93
|
+
readonly kind: 'Feature';
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly strategy: 'lazy' | 'default';
|
|
96
|
+
readonly composition: Manifest & {
|
|
97
|
+
readonly kind: 'Composition';
|
|
98
|
+
};
|
|
99
|
+
readonly placeholder?: {
|
|
100
|
+
readonly loading: Manifest & {
|
|
101
|
+
readonly kind: 'Composition';
|
|
102
|
+
};
|
|
103
|
+
readonly failed: Manifest & {
|
|
104
|
+
readonly kind: 'Composition';
|
|
105
|
+
};
|
|
106
|
+
};
|
|
121
107
|
}
|
|
122
|
-
|
|
123
108
|
/**
|
|
124
109
|
* A feature's loaded artifacts with type params erased, for the renderer-neutral,
|
|
125
110
|
* strategy-uniform host. The erasure is cast-free *into*: because `Layer`'s `ROut`
|
|
@@ -129,14 +114,12 @@ export interface FeatureManifest extends Manifest {
|
|
|
129
114
|
* documented boundary cast there, mirroring `buildRuntime`).
|
|
130
115
|
*/
|
|
131
116
|
export interface LoadedModule {
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
readonly requires: ReadonlyArray<RequireCarrier>;
|
|
118
|
+
readonly layer: Layer.Layer<never, never, unknown>;
|
|
134
119
|
}
|
|
135
|
-
|
|
136
120
|
/** Nominal brand identifying the value a `provide(slot, Feature)` puts under a slot tag. */
|
|
137
|
-
export const FeatureBindingTypeId: unique symbol
|
|
138
|
-
export type FeatureBindingTypeId = typeof FeatureBindingTypeId
|
|
139
|
-
|
|
121
|
+
export declare const FeatureBindingTypeId: unique symbol;
|
|
122
|
+
export type FeatureBindingTypeId = typeof FeatureBindingTypeId;
|
|
140
123
|
/**
|
|
141
124
|
* What `provide(slot, Feature)` binds under the slot tag — everything the host
|
|
142
125
|
* needs to mount the feature, with types erased (the host is renderer-neutral and
|
|
@@ -147,22 +130,19 @@ export type FeatureBindingTypeId = typeof FeatureBindingTypeId
|
|
|
147
130
|
* each.
|
|
148
131
|
*/
|
|
149
132
|
export interface FeatureBinding {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
133
|
+
readonly [FeatureBindingTypeId]: FeatureBindingTypeId;
|
|
134
|
+
readonly manifest: FeatureManifest;
|
|
135
|
+
readonly composition: CompositionClass<unknown>;
|
|
136
|
+
readonly strategy: 'lazy' | 'default';
|
|
137
|
+
readonly load: Effect.Effect<LoadedModule, FeatureLoadFailed>;
|
|
138
|
+
readonly placeholder?: {
|
|
139
|
+
readonly loading: CompositionClass<unknown>;
|
|
140
|
+
readonly failed: CompositionClass<unknown>;
|
|
141
|
+
};
|
|
142
|
+
readonly boot: ReadonlyArray<Tagged>;
|
|
160
143
|
}
|
|
161
|
-
|
|
162
144
|
/** Whether a slot's bound child is a lazy/eager feature (vs a plain composition). */
|
|
163
|
-
export const isFeatureBinding
|
|
164
|
-
typeof u === 'object' && u !== null && FeatureBindingTypeId in u
|
|
165
|
-
|
|
145
|
+
export declare const isFeatureBinding: (u: unknown) => u is FeatureBinding;
|
|
166
146
|
/**
|
|
167
147
|
* A feature *definition*: a reflectable manifest (`kind: 'Feature'`) that carries
|
|
168
148
|
* the eager half (composition + placeholders) and an Effect `load` for the heavy
|
|
@@ -170,37 +150,25 @@ export const isFeatureBinding = (u: unknown): u is FeatureBinding =>
|
|
|
170
150
|
* shared-carrier tuple the loaded module declares. `load` is an `Effect`, never a
|
|
171
151
|
* Promise — consumers `yield* Feature.load`.
|
|
172
152
|
*/
|
|
173
|
-
export interface FeatureClass<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
readonly load: Effect.Effect<FeatureModule<ROut, Requires>, FeatureLoadFailed>
|
|
189
|
-
/** The value `provide(slot, Feature)` binds under the slot tag. */
|
|
190
|
-
readonly binding: FeatureBinding
|
|
191
|
-
/** The eagerly-available module — present only for `loadingStrategy: 'default'`. */
|
|
192
|
-
readonly eagerModule: FeatureModule<ROut, Requires> | undefined
|
|
153
|
+
export interface FeatureClass<P, C extends UiContract, ROut, Requires extends ReadonlyArray<RequireCarrier>> {
|
|
154
|
+
new (): {};
|
|
155
|
+
readonly manifest: FeatureManifest;
|
|
156
|
+
/** Phantom carrying the mounted composition's props type (for `provide` checks). */
|
|
157
|
+
readonly Props: P;
|
|
158
|
+
/** Phantom carrying the composition's UI contract (for typed reflection consumers). */
|
|
159
|
+
readonly Contract: C;
|
|
160
|
+
/** Phantom carrying the declared shared-carrier tuple. */
|
|
161
|
+
readonly Requires: Requires;
|
|
162
|
+
/** Load the feature's module — `yield* Feature.load` → its `FeatureModule`, or `FeatureLoadFailed`. */
|
|
163
|
+
readonly load: Effect.Effect<FeatureModule<ROut, Requires>, FeatureLoadFailed>;
|
|
164
|
+
/** The value `provide(slot, Feature)` binds under the slot tag. */
|
|
165
|
+
readonly binding: FeatureBinding;
|
|
166
|
+
/** The eagerly-available module — present only for `loadingStrategy: 'default'`. */
|
|
167
|
+
readonly eagerModule: FeatureModule<ROut, Requires> | undefined;
|
|
193
168
|
}
|
|
194
|
-
|
|
195
|
-
export type AnyFeature = FeatureClass<any, any, any, ReadonlyArray<RequireCarrier>>
|
|
196
|
-
|
|
169
|
+
export type AnyFeature = FeatureClass<any, any, any, ReadonlyArray<RequireCarrier>>;
|
|
197
170
|
/** Whether a value is a feature definition (its target shape in `provide(slot, Feature)`). */
|
|
198
|
-
export const isFeature
|
|
199
|
-
(typeof u === 'function' || typeof u === 'object') &&
|
|
200
|
-
u !== null &&
|
|
201
|
-
'manifest' in u &&
|
|
202
|
-
(u as { readonly manifest: { readonly kind?: unknown } }).manifest?.kind === 'Feature'
|
|
203
|
-
|
|
171
|
+
export declare const isFeature: (u: unknown) => u is AnyFeature;
|
|
204
172
|
/**
|
|
205
173
|
* The placeholders a lazy feature must ship — both eager compositions (their
|
|
206
174
|
* `.live` is in the eager bundle, so they paint the load gap). `loading` receives
|
|
@@ -209,28 +177,20 @@ export const isFeature = (u: unknown): u is AnyFeature =>
|
|
|
209
177
|
* are not schema-decoded inputs.
|
|
210
178
|
*/
|
|
211
179
|
export interface Placeholders {
|
|
212
|
-
|
|
213
|
-
|
|
180
|
+
readonly loading: CompositionClass<any, UiContract>;
|
|
181
|
+
readonly failed: CompositionClass<any, UiContract>;
|
|
214
182
|
}
|
|
215
|
-
|
|
216
183
|
type FeatureConfig<P, C extends UiContract, ROut, Requires extends ReadonlyArray<RequireCarrier>> = {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} & (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// LAZY: the module loads on mount via an Effect. Placeholders required.
|
|
228
|
-
readonly loadingStrategy: 'lazy'
|
|
229
|
-
readonly load: Effect.Effect<FeatureModule<ROut, Requires>, FeatureLoadFailed>
|
|
230
|
-
readonly placeholder: Placeholders
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
|
|
184
|
+
readonly composition: CompositionClass<P, C>;
|
|
185
|
+
readonly boot?: ReadonlyArray<Tagged>;
|
|
186
|
+
} & ({
|
|
187
|
+
readonly loadingStrategy?: 'default';
|
|
188
|
+
readonly module: FeatureModule<ROut, Requires>;
|
|
189
|
+
} | {
|
|
190
|
+
readonly loadingStrategy: 'lazy';
|
|
191
|
+
readonly load: Effect.Effect<FeatureModule<ROut, Requires>, FeatureLoadFailed>;
|
|
192
|
+
readonly placeholder: Placeholders;
|
|
193
|
+
});
|
|
234
194
|
/**
|
|
235
195
|
* Define a feature. The whole-app shape (this manifest, the composition, the
|
|
236
196
|
* placeholders) stays eager and reflectable; the `.live` layer in `module`/`load`
|
|
@@ -238,41 +198,7 @@ type FeatureConfig<P, C extends UiContract, ROut, Requires extends ReadonlyArray
|
|
|
238
198
|
* the discriminated config *requires* `placeholder` — the compiler walks you to a
|
|
239
199
|
* complete code-split feature.
|
|
240
200
|
*/
|
|
241
|
-
export const make
|
|
242
|
-
name: string,
|
|
243
|
-
config: FeatureConfig<P, C, ROut, Requires>,
|
|
244
|
-
): FeatureClass<P, C, ROut, Requires> => {
|
|
245
|
-
const strategy: 'lazy' | 'default' = config.loadingStrategy ?? 'default'
|
|
246
|
-
const load: Effect.Effect<FeatureModule<ROut, Requires>, FeatureLoadFailed> =
|
|
247
|
-
'load' in config ? config.load : Effect.succeed(config.module)
|
|
248
|
-
const eagerModule = 'module' in config ? config.module : undefined
|
|
249
|
-
const placeholder = 'placeholder' in config ? config.placeholder : undefined
|
|
250
|
-
|
|
251
|
-
const manifest: FeatureManifest = {
|
|
252
|
-
kind: 'Feature',
|
|
253
|
-
name,
|
|
254
|
-
strategy,
|
|
255
|
-
composition: config.composition.manifest,
|
|
256
|
-
...(placeholder
|
|
257
|
-
? { placeholder: { loading: placeholder.loading.manifest, failed: placeholder.failed.manifest } }
|
|
258
|
-
: {}),
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const binding: FeatureBinding = {
|
|
262
|
-
[FeatureBindingTypeId]: FeatureBindingTypeId,
|
|
263
|
-
manifest,
|
|
264
|
-
composition: config.composition,
|
|
265
|
-
strategy,
|
|
266
|
-
// The host is strategy-uniform: `default`'s `load` resolves immediately. The
|
|
267
|
-
// assignment to the erased `LoadedModule` needs no cast — see `LoadedModule`.
|
|
268
|
-
load,
|
|
269
|
-
...(placeholder ? { placeholder: { loading: placeholder.loading, failed: placeholder.failed } } : {}),
|
|
270
|
-
boot: config.boot ?? [],
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return definitionClass<FeatureClass<P, C, ROut, Requires>>({ manifest, load, binding, eagerModule })
|
|
274
|
-
}
|
|
275
|
-
|
|
201
|
+
export declare const make: <P, C extends UiContract, ROut, Requires extends ReadonlyArray<RequireCarrier>>(name: string, config: FeatureConfig<P, C, ROut, Requires>) => FeatureClass<P, C, ROut, Requires>;
|
|
276
202
|
/**
|
|
277
203
|
* Mount a feature against a live engine. The renderer-neutral lifecycle, run on a
|
|
278
204
|
* per-feature `Scope`: load the module (an Effect — lazy = dynamic import; default
|
|
@@ -289,18 +215,6 @@ export const make = <P, C extends UiContract, ROut, Requires extends ReadonlyArr
|
|
|
289
215
|
* we re-attach the concrete `engineContext` it builds against. `R` is the engine
|
|
290
216
|
* context's service set, supplied by the host.
|
|
291
217
|
*/
|
|
292
|
-
export const mountFeature
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
): Effect.Effect<Context.Context<unknown>, FeatureLoadFailed, Scope.Scope> =>
|
|
296
|
-
Effect.gen(function* () {
|
|
297
|
-
const { layer } = yield* binding.load
|
|
298
|
-
const featureLayer = layer as Layer.Layer<unknown, never, R>
|
|
299
|
-
const context = yield* Layer.build(
|
|
300
|
-
Layer.provideMerge(featureLayer, Layer.succeedContext(engineContext)),
|
|
301
|
-
)
|
|
302
|
-
yield* Effect.forEach(binding.boot, (event) => publish('High', event), { discard: true }).pipe(
|
|
303
|
-
Effect.provide(context),
|
|
304
|
-
)
|
|
305
|
-
return context
|
|
306
|
-
})
|
|
218
|
+
export declare const mountFeature: <R>(binding: FeatureBinding, engineContext: Context.Context<R>) => Effect.Effect<Context.Context<unknown>, FeatureLoadFailed, Scope.Scope>;
|
|
219
|
+
export {};
|
|
220
|
+
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../src/feature/feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AASrD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,MAAM,CAAC,CAAA;AAE/D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAAE,GACzC;IAAE,QAAQ,CAAC,OAAO,EAAE,aA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