Sign In

foldkit

Package Overview
Dependencies
Maintainers
1
Versions
229
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

foldkit - npm Package Compare versions

Comparing version
0.141.2
to
0.142.0
+1
-1
dist/subscription/public.d.ts
export { aggregate, lift, make, persistent } from './subscription.js';
export type { EntryWithoutKeepAlive, Subscription, Subscriptions, } from './subscription.js';
export type { EntryWithoutKeepAlive, GatedDependencies, Subscription, Subscriptions, } from './subscription.js';
export { animationFrame } from './animationFrame.js';

@@ -4,0 +4,0 @@ export type { AnimationFrameConfig } from './animationFrame.js';

@@ -1,1 +0,1 @@

{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/subscription/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAErE,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAE9D,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA"}
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/subscription/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAErE,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAE9D,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA"}

@@ -1,2 +0,2 @@

import { type Equivalence, Schema, Stream } from 'effect';
import { type Equivalence, Option, Schema, Stream } from 'effect';
type SubscriptionBrand = {

@@ -137,2 +137,49 @@ readonly __subscription: never;

/**
* The dependencies of a Subscription lifted through a parent's `when` gate:
* the child entry's own dependencies under `maybeDependencies`, and `None`
* for as long as the parent holds the gate closed.
*
* A closed gate is a real teardown rather than a paused Stream. The entry's
* Stream is torn down, and the child's `modelToDependencies` does not run
* again until the parent reopens the gate, so child state that changes behind
* a closed gate causes no restarts.
*/
export type GatedDependencies<Dependencies> = Readonly<{
maybeDependencies: Option.Option<Dependencies>;
}>;
type WhenPredicate<ParentModel> = (parentModel: ParentModel) => boolean;
/**
* The per-entry form of a lift's `when`: a partial map from entry name to
* gate. Entries the map names are gated, and entries it omits are lifted
* ungated.
*/
export type EntryGates<ParentModel, Subscriptions> = Readonly<Partial<Record<keyof Subscriptions, WhenPredicate<ParentModel>>>>;
type LiftConfig<ParentModel, ParentMessage, Subscriptions> = Readonly<{
toChildModel: (parentModel: ParentModel) => ChildModelOf<Subscriptions>;
toParentMessage: (message: ChildMessageOf<Subscriptions>) => ParentMessage;
}>;
type GatedLiftConfig<ParentModel, ParentMessage, Subscriptions> = LiftConfig<ParentModel, ParentMessage, Subscriptions> & Readonly<{
when: WhenPredicate<ParentModel>;
}>;
type PerEntryGatedLiftConfig<ParentModel, ParentMessage, Subscriptions, Gates> = LiftConfig<ParentModel, ParentMessage, Subscriptions> & Readonly<{
when: Gates;
}>;
type LiftedSubscriptions<ParentModel, ParentMessage, Subscriptions> = {
readonly [K in keyof Subscriptions]: Subscriptions[K] extends Subscription<any, any, infer Dependencies, infer Services> ? Subscription<ParentModel, ParentMessage, Dependencies, Services> : never;
};
type GatedLiftedSubscriptions<ParentModel, ParentMessage, Subscriptions> = {
readonly [K in keyof Subscriptions]: Subscriptions[K] extends Subscription<any, any, infer Dependencies, infer Services> ? Subscription<ParentModel, ParentMessage, GatedDependencies<Dependencies>, Services> : never;
};
/**
* The lifted record for a per-entry `when`. An entry the gate map names
* carries {@link GatedDependencies}; an entry it omits keeps the child's own
* dependencies. When the gate map's own type is not precise enough to say
* which is which, because the call passed explicit `ParentModel` and
* `ParentMessage` type arguments and so suppressed inference on it, the entry
* carries both possibilities.
*/
type PerEntryGatedLiftedSubscriptions<ParentModel, ParentMessage, Subscriptions, Gates> = {
readonly [K in keyof Subscriptions]: Subscriptions[K] extends Subscription<any, any, infer Dependencies, infer Services> ? K extends keyof Gates ? undefined extends Gates[K] ? Subscription<ParentModel, ParentMessage, Dependencies | GatedDependencies<Dependencies>, Services> : Subscription<ParentModel, ParentMessage, GatedDependencies<Dependencies>, Services> : Subscription<ParentModel, ParentMessage, Dependencies, Services> : never;
};
/**
* Lifts a record of child Subscriptions into a parent's Model and Message

@@ -143,8 +190,53 @@ * context, applying a Model accessor and a Message wrapper uniformly to

* `readDependencies`) matches its source entry's.
*
* The optional `when` is the parent's own gate. The parent writes it here on
* its `lift` call and answers it from the parent Model, which is what makes
* it useful: it carries the half of a condition the child cannot see, such as
* the route a page Submodel sits behind. The child neither declares nor sees
* the gate, and keeps holding its own half in `modelToDependencies`. A gated
* entry runs only while its gate returns `true`, and a closed gate tears it
* down.
*
* `when` takes either shape:
*
* - One predicate gates every entry in the record, for the common case where
* the whole child answers to one parent condition.
* - An {@link EntryGates} map gates entries by name, for a child whose
* Subscriptions answer to different parent conditions. Entries the map
* omits are lifted ungated. A child never has to organize its records
* around its parent's gating.
*
* Gating rewrites a gated entry's dependencies to {@link GatedDependencies},
* so its `readDependencies` returns the last dependencies seen through an
* open gate. Ungated entries keep the child's dependencies untouched. Passing
* `ParentModel` and `ParentMessage` explicitly suppresses inference on the
* gate map, which leaves each named entry's dependencies as either shape; let
* both infer from an annotated `toChildModel` when you want the exact per
* entry types.
*
* @example
* ```ts
* const homeSubscriptions = Subscription.lift(Home.subscriptions)<
* Model,
* Message
* >({
* toChildModel: model => model.home,
* toParentMessage: message => GotHomeMessage({ message }),
* when: ({ route }) => route._tag === 'Home',
* })
*
* const roomSubscriptions = Subscription.lift(Room.subscriptions)({
* toChildModel: (model: Model) => model.room,
* toParentMessage: (message: Room.Message.Message): Message =>
* GotRoomMessage({ message }),
* when: { roomKeyboard: ({ route }) => route._tag === 'Room' },
* })
* ```
*/
export declare const lift: <Subscriptions extends Readonly<Record<string, Subscription<any, any, any, any>>>>(subscriptions: Subscriptions) => <ParentModel, ParentMessage>(config: {
readonly toChildModel: (parentModel: ParentModel) => ChildModelOf<Subscriptions>;
readonly toParentMessage: (message: ChildMessageOf<Subscriptions>) => ParentMessage;
}) => { readonly [K in keyof Subscriptions]: Subscriptions[K] extends Subscription<any, any, infer Dependencies, infer Services> ? Subscription<ParentModel, ParentMessage, Dependencies, Services> : never; };
export declare const lift: <Subscriptions extends Readonly<Record<string, Subscription<any, any, any, any>>>>(subscriptions: Subscriptions) => {
<ParentModel, ParentMessage>(config: GatedLiftConfig<ParentModel, ParentMessage, Subscriptions>): GatedLiftedSubscriptions<ParentModel, ParentMessage, Subscriptions>;
<ParentModel, ParentMessage_1, Gates extends EntryGates<ParentModel, Subscriptions> = EntryGates<ParentModel, Subscriptions>>(config: PerEntryGatedLiftConfig<ParentModel, ParentMessage_1, Subscriptions, Gates>): PerEntryGatedLiftedSubscriptions<ParentModel, ParentMessage_1, Subscriptions, Gates>;
<ParentModel, ParentMessage_2>(config: LiftConfig<ParentModel, ParentMessage_2, Subscriptions>): LiftedSubscriptions<ParentModel, ParentMessage_2, Subscriptions>;
};
export {};
//# sourceMappingURL=subscription.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/subscription/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,EAAE,MAAM,EAAE,MA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CACV,CAAA;AA6HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,IAAI,GAEb,aAAa,SAAS,QAAQ,CAC5B,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CACjD,EAED,eAAe,aAAa,KAC3B;IACD,CAAC,WAAW,EAAE,aAAa,EACzB,MAAM,EAAE,eAAe,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC,GACjE,wBAAwB,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC,CAAA;IACtE,CACE,WAAW,EACX,eAAa,EACb,KAAK,SAAS,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,UAAU,CAC/D,WAAW,EACX,aAAa,CACd,EAED,MAAM,EAAE,uBAAuB,CAC7B,WAAW,EACX,eAAa,EACb,aAAa,EACb,KAAK,CACN,GACA,gCAAgC,CACjC,WAAW,EACX,eAAa,EACb,aAAa,EACb,KAAK,CACN,CAAA;IACD,CAAC,WAAW,EAAE,eAAa,EACzB,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,eAAa,EAAE,aAAa,CAAC,GAC5D,mBAAmB,CAAC,WAAW,EAAE,eAAa,EAAE,aAAa,CAAC,CAAA;CASzD,CAAA"}

@@ -1,2 +0,2 @@

import { Record, Schema, Stream } from 'effect';
import { Option, Record, Schema, Stream, pipe } from 'effect';
/**

@@ -66,14 +66,16 @@ * Declares a Subscriptions record. The Model, Message, and optional Services

});
/**
* Lifts a record of child Subscriptions into a parent's Model and Message
* context, applying a Model accessor and a Message wrapper uniformly to
* every entry. Per-entry dependency types, schemas, and `keepAliveEquivalence`
* settings are preserved; each lifted entry's variant (with or without
* `readDependencies`) matches its source entry's.
*/
export const lift = (subscriptions) => (config) =>
/* eslint-disable @typescript-eslint/consistent-type-assertions */
Record.map(subscriptions, subscription => {
const toEntryWhen = (when, key) => {
if (when === undefined) {
return Option.none();
}
else if (typeof when === 'function') {
return Option.some(when);
}
else {
return pipe(Record.get(when, key), Option.flatMap(Option.fromNullishOr));
}
};
const toParentStream = (config, stream) => Stream.map(stream, config.toParentMessage);
const toLiftedEntry = (subscription, config) => {
const modelToDependencies = (parentModel) => subscription.modelToDependencies(config.toChildModel(parentModel));
const wrapStream = (stream) => Stream.map(stream, config.toParentMessage);
if (subscription.keepAliveEquivalence !== undefined) {

@@ -84,3 +86,3 @@ return {

keepAliveEquivalence: subscription.keepAliveEquivalence,
dependenciesToStream: (dependencies, readDependencies) => wrapStream(subscription.dependenciesToStream(dependencies, readDependencies)),
dependenciesToStream: (dependencies, readDependencies) => toParentStream(config, subscription.dependenciesToStream(dependencies, readDependencies)),
};

@@ -91,5 +93,89 @@ }

modelToDependencies,
dependenciesToStream: (dependencies) => wrapStream(subscription.dependenciesToStream(dependencies)),
dependenciesToStream: (dependencies) => toParentStream(config, subscription.dependenciesToStream(dependencies)),
};
});
/* eslint-enable @typescript-eslint/consistent-type-assertions */
};
const toGatedEntry = (subscription, config, when) => {
const dependenciesSchema = Schema.Struct({
maybeDependencies: Schema.Option(subscription.dependenciesSchema),
});
const modelToDependencies = (parentModel) => ({
maybeDependencies: pipe(parentModel, Option.liftPredicate(when), Option.map(config.toChildModel), Option.map(subscription.modelToDependencies)),
});
if (subscription.keepAliveEquivalence !== undefined) {
const maybeKeepAliveEquivalence = Option.makeEquivalence(subscription.keepAliveEquivalence);
return {
dependenciesSchema,
modelToDependencies,
keepAliveEquivalence: (left, right) => maybeKeepAliveEquivalence(left.maybeDependencies, right.maybeDependencies),
dependenciesToStream: (gatedDependencies, readGatedDependencies) => Option.match(gatedDependencies.maybeDependencies, {
onNone: () => Stream.empty,
onSome: dependencies => toParentStream(config, subscription.dependenciesToStream(dependencies, () => Option.getOrElse(readGatedDependencies().maybeDependencies, () => dependencies))),
}),
};
}
return {
dependenciesSchema,
modelToDependencies,
dependenciesToStream: (gatedDependencies) => Option.match(gatedDependencies.maybeDependencies, {
onNone: () => Stream.empty,
onSome: dependencies => toParentStream(config, subscription.dependenciesToStream(dependencies)),
}),
};
};
/**
* Lifts a record of child Subscriptions into a parent's Model and Message
* context, applying a Model accessor and a Message wrapper uniformly to
* every entry. Per-entry dependency types, schemas, and `keepAliveEquivalence`
* settings are preserved; each lifted entry's variant (with or without
* `readDependencies`) matches its source entry's.
*
* The optional `when` is the parent's own gate. The parent writes it here on
* its `lift` call and answers it from the parent Model, which is what makes
* it useful: it carries the half of a condition the child cannot see, such as
* the route a page Submodel sits behind. The child neither declares nor sees
* the gate, and keeps holding its own half in `modelToDependencies`. A gated
* entry runs only while its gate returns `true`, and a closed gate tears it
* down.
*
* `when` takes either shape:
*
* - One predicate gates every entry in the record, for the common case where
* the whole child answers to one parent condition.
* - An {@link EntryGates} map gates entries by name, for a child whose
* Subscriptions answer to different parent conditions. Entries the map
* omits are lifted ungated. A child never has to organize its records
* around its parent's gating.
*
* Gating rewrites a gated entry's dependencies to {@link GatedDependencies},
* so its `readDependencies` returns the last dependencies seen through an
* open gate. Ungated entries keep the child's dependencies untouched. Passing
* `ParentModel` and `ParentMessage` explicitly suppresses inference on the
* gate map, which leaves each named entry's dependencies as either shape; let
* both infer from an annotated `toChildModel` when you want the exact per
* entry types.
*
* @example
* ```ts
* const homeSubscriptions = Subscription.lift(Home.subscriptions)<
* Model,
* Message
* >({
* toChildModel: model => model.home,
* toParentMessage: message => GotHomeMessage({ message }),
* when: ({ route }) => route._tag === 'Home',
* })
*
* const roomSubscriptions = Subscription.lift(Room.subscriptions)({
* toChildModel: (model: Model) => model.room,
* toParentMessage: (message: Room.Message.Message): Message =>
* GotRoomMessage({ message }),
* when: { roomKeyboard: ({ route }) => route._tag === 'Room' },
* })
* ```
*/
export const lift = (subscriptions) => (config) =>
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
Record.map(subscriptions, (subscription, key) => Option.match(toEntryWhen(config.when, key), {
onNone: () => toLiftedEntry(subscription, config),
onSome: entryWhen => toGatedEntry(subscription, config, entryWhen),
}));

@@ -1,3 +0,3 @@

export { combine, foldChild, refresh } from './index.js';
export type { Commands, Return, ReturnWithOutMessage, Step, StepWithOutMessage, Refreshable, ChildFold, ChildFoldWithOutMessage, ChildFoldWithParentOutMessage, Fold, FoldWithOutMessage, } from './index.js';
export { combine, foldChild, foldChildStep, refresh } from './index.js';
export type { Commands, Return, ReturnWithOutMessage, Step, StepWithOutMessage, Refreshable, ChildFold, ChildFoldWithOutMessage, ChildFoldWithParentOutMessage, ChildStepFold, ChildStepFoldWithOutMessage, FoldContext, Fold, FoldWithOutMessage, } from './index.js';
//# sourceMappingURL=public.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/update/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAExD,YAAY,EACV,QAAQ,EACR,MAAM,EACN,oBAAoB,EACpB,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,6BAA6B,EAC7B,IAAI,EACJ,kBAAkB,GACnB,MAAM,YAAY,CAAA"}
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/update/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEvE,YAAY,EACV,QAAQ,EACR,MAAM,EACN,oBAAoB,EACpB,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,6BAA6B,EAC7B,aAAa,EACb,2BAA2B,EAC3B,WAAW,EACX,IAAI,EACJ,kBAAkB,GACnB,MAAM,YAAY,CAAA"}

@@ -1,1 +0,1 @@

export { combine, foldChild, refresh } from './index.js';
export { combine, foldChild, foldChildStep, refresh } from './index.js';

@@ -122,2 +122,43 @@ import { Option } from 'effect';

}>;
/** The lifters a `foldOutMessage` receives as its second parameter,
* already bound to the fold config's `toParentMessage`.
*
* The fold lifts the Commands the child's `update` returns on its own.
* This covers the other case: a Command the parent returns on the
* child's behalf from the OutMessage Step, whose result Message is the
* child's and therefore still needs wrapping, such as a parent handling
* a child's `Requested*` fact by returning the child's Command that
* fulfills it, built with context only the parent holds.
*
* The lifters apply the same lift the fold gives the child's own
* Commands, so the Step writes no `Command.mapMessage` call and keeps
* no second copy of the wrapper, and the mapping stays recorded on the
* Command for `Story.Command.resolve` and `Scene.Command.resolve`.
*
* The annotated standalone const takes both parameters, so the match
* moves from `M.type` to `M.value` on the OutMessage:
*
* ```ts
* const foldLoginOutMessage: (
* outMessage: Login.OutMessage,
* context: Update.FoldContext<Login.Message, Message>,
* ) => Update.Step<Model, Message> = (outMessage, { liftCommand }) =>
* M.value(outMessage).pipe(
* M.withReturnType<Update.Step<Model, Message>>(),
* M.tagsExhaustive({
* RequestedMagicLink: ({ email }) => model => [
* model,
* [
* liftCommand(
* Login.SendMagicLink({ email, redirectRoute: model.route }),
* ),
* ],
* ],
* }),
* )
* ``` */
export type FoldContext<ChildMessage, ParentMessage> = Readonly<{
liftCommand: <E = never, R = never>(command: Command<ChildMessage, E, R>) => Command<ParentMessage, E, R>;
liftCommands: <E = never, R = never>(commands: ReadonlyArray<Command<ChildMessage, E, R>>) => ReadonlyArray<Command<ParentMessage, E, R>>;
}>;
/** {@link ChildFold} for a child whose update returns

@@ -131,3 +172,5 @@ * {@link ReturnWithOutMessage}, adding the fifth capability:

* (`M.tagsExhaustive`), and build a multi-step fold with
* {@link combine}. */
* {@link combine}. Takes an optional second parameter, a
* {@link FoldContext} of lifters bound to `toParentMessage`, for a
* Command the Step returns whose result is the child's Message. */
export type ChildFoldWithOutMessage<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, R = never> = Readonly<{

@@ -138,3 +181,3 @@ update: (childModel: ChildModel, input: Input) => ReturnWithOutMessage<ChildModel, ChildMessage, ChildOutMessage, R>;

toParentMessage: (message: ChildMessage) => ParentMessage;
foldOutMessage: (outMessage: ChildOutMessage) => Step<ParentModel, ParentMessage, R>;
foldOutMessage: (outMessage: ChildOutMessage, context: FoldContext<ChildMessage, ParentMessage>) => Step<ParentModel, ParentMessage, R>;
}>;

@@ -160,3 +203,3 @@ /** {@link ChildFoldWithOutMessage} for a parent that is itself a

toParentOutMessage: (outMessage: ChildOutMessage) => Option.Option<ParentOutMessage>;
foldOutMessage?: (outMessage: ChildOutMessage) => Step<ParentModel, ParentMessage, R>;
foldOutMessage?: (outMessage: ChildOutMessage, context: FoldContext<ChildMessage, ParentMessage>) => Step<ParentModel, ParentMessage, R>;
}>;

@@ -209,2 +252,8 @@ /** {@link Step} for an update that also surfaces an OutMessage to its

*
* `foldOutMessage` takes an optional second parameter, a
* {@link FoldContext} carrying `liftCommand` and `liftCommands` bound to
* this config's `toParentMessage`. Reach for it when the Step returns a
* Command that produces the child's Message, such as an animating
* component's overridable leave Command.
*
* A parent that is itself a Submodel passes a

@@ -215,2 +264,6 @@ * {@link ChildFoldWithParentOutMessage} and receives a

*
* An entry point that takes nothing but the child Model, such as
* `Dialog.close`, has no input to pass: fold it with
* {@link foldChildStep}, which returns the {@link Step} directly.
*
* `update` closes over per-dispatch context, and the data-last form

@@ -238,2 +291,59 @@ * composes with {@link combine}, here to put a navigation Command ahead

};
/** {@link ChildFold} for an entry point that takes nothing but the child
* Model, such as `Dialog.close` or a Submodel's `informRouteChanged` that
* derives everything it needs from its own state. There is no `input`, so
* {@link foldChildStep} returns the {@link Step} itself rather than a dual
* {@link Fold}. */
export type ChildStepFold<ParentModel, ParentMessage, ChildModel, ChildMessage, R = never> = Readonly<{
update: (childModel: ChildModel) => Return<ChildModel, ChildMessage, R>;
read: (model: ParentModel) => Option.Option<ChildModel>;
write: (model: ParentModel, nextChildModel: ChildModel) => ParentModel;
toParentMessage: (message: ChildMessage) => ParentMessage;
}>;
/** {@link ChildStepFold} for an entry point whose return carries the child's
* OutMessage channel, adding `foldOutMessage`. It behaves exactly as it does
* in {@link ChildFoldWithOutMessage}, down to the optional second parameter,
* a {@link FoldContext} of lifters bound to `toParentMessage`. */
export type ChildStepFoldWithOutMessage<ParentModel, ParentMessage, ChildModel, ChildMessage, ChildOutMessage, R = never> = Readonly<{
update: (childModel: ChildModel) => ReturnWithOutMessage<ChildModel, ChildMessage, ChildOutMessage, R>;
read: (model: ParentModel) => Option.Option<ChildModel>;
write: (model: ParentModel, nextChildModel: ChildModel) => ParentModel;
toParentMessage: (message: ChildMessage) => ParentMessage;
foldOutMessage: (outMessage: ChildOutMessage, context: FoldContext<ChildMessage, ParentMessage>) => Step<ParentModel, ParentMessage, R>;
}>;
/** Folds a child entry point that takes nothing but the child Model, and
* returns the {@link Step} directly. Everything else matches
* {@link foldChild}: the child is read, updated, and written back, its
* Commands are lifted through `toParentMessage`, a `None` from `read` makes
* the Step a no-op, and `foldOutMessage` runs against the Model with the
* child already written back.
*
* Reach for it wherever a Submodel exposes a no-argument entry point, so the
* call site composes with {@link combine} as a plain Step and never invents
* an input the child does not take:
*
* ```ts
* const foldMobileMenuDialogClose = Update.foldChildStep({
* update: Dialog.close,
* read: readMobileMenuDialog,
* write: writeMobileMenuDialog,
* toParentMessage: toGotMobileMenuDialogMessage,
* foldOutMessage: foldMobileMenuDialogOutMessage,
* })
*
* // in the parent update
* Update.combine(model, [writeRouteFields, foldMobileMenuDialogClose])
* ```
*
* `foldOutMessage` takes the same optional second parameter `foldChild`'s
* does, a {@link FoldContext} carrying `liftCommand` and `liftCommands` bound
* to this config's `toParentMessage`, for a Command the Step returns whose
* result is the child's Message.
*
* A parent that is itself a Submodel, and so needs its own OutMessage
* channel on the result, uses {@link foldChild}. */
export declare const foldChildStep: {
<ParentModel, ParentMessage, ChildModel, ChildMessage, ChildOutMessage, R = never>(childFold: ChildStepFoldWithOutMessage<ParentModel, ParentMessage, ChildModel, ChildMessage, ChildOutMessage, R>): Step<ParentModel, ParentMessage, R>;
<ParentModel, ParentMessage, ChildModel, ChildMessage, R = never>(childFold: ChildStepFold<ParentModel, ParentMessage, ChildModel, ChildMessage, R>): Step<ParentModel, ParentMessage, R>;
};
//# sourceMappingURL=update.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/update/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,qBAAqB,CAAA;AAE/D;;;;;;;;;UASU;AACV,MAAM,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,aAAa,CACtD,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAC3B,CAAA;AAED;;;;;;;;;UASU;AACV,MAAM,MAAM,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,SAAS;IACvD,KAAK;IACL,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACrB,CAAA;AAED;;;;yDAIyD;AACzD,MAAM,MAAM,oBAAoB,CAC9B,KAAK,EACL,OAAO,EACP,UAAU,EACV,CAAC,GAAG,KAAK,IACP,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;AAErE;;mEAEmE;AACnE,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,CAC5C,KAAK,EAAE,KAAK,KACT,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;UAwBU;AACV,eAAO,MAAM,OAAO,EAAE;IACpB,CAAC,KAAK,EAAE,OAAO,EAAE,C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YAAY,EACZ,CAAC,CACF,GACA,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC,CAAA;CAKvC,CAAA"}
import { Array, Function, Option, pipe } from 'effect';
import { mapMessages } from '../command/index.js';
import { mapMessage, mapMessages } from '../command/index.js';
/** Composes a list of update steps into one. Each step runs against the

@@ -81,2 +81,8 @@ * Model the previous step produced, and every step's Commands are

*
* `foldOutMessage` takes an optional second parameter, a
* {@link FoldContext} carrying `liftCommand` and `liftCommands` bound to
* this config's `toParentMessage`. Reach for it when the Step returns a
* Command that produces the child's Message, such as an animating
* component's overridable leave Command.
*
* A parent that is itself a Submodel passes a

@@ -87,2 +93,6 @@ * {@link ChildFoldWithParentOutMessage} and receives a

*
* An entry point that takes nothing but the child Model, such as
* `Dialog.close`, has no input to pass: fold it with
* {@link foldChildStep}, which returns the {@link Step} directly.
*
* `update` closes over per-dispatch context, and the data-last form

@@ -105,3 +115,11 @@ * composes with {@link combine}, here to put a navigation Command ahead

* ``` */
export const foldChild = (childFold) => Function.dual(2, (model, input) => pipe(model, childFold.read, Option.match({
export const foldChild = (childFold) => {
const context = makeFoldContext(childFold.toParentMessage);
return Function.dual(2, (model, input) => runChildFold(childFold, context, model, input));
};
const makeFoldContext = (toParentMessage) => ({
liftCommand: command => mapMessage(command, toParentMessage),
liftCommands: commands => mapMessages(commands, toParentMessage),
});
const runChildFold = (childFold, context, model, input) => pipe(model, childFold.read, Option.match({
onNone: () => childFold.toParentOutMessage === undefined

@@ -118,3 +136,3 @@ ? [model, []]

? [modelWithChild, mappedCommands]
: appendOutMessageStep(childFold.foldOutMessage, maybeOutMessage.value, modelWithChild, mappedCommands);
: appendOutMessageStep(childFold.foldOutMessage, maybeOutMessage.value, context, modelWithChild, mappedCommands);
if (childFold.toParentOutMessage === undefined) {

@@ -128,6 +146,41 @@ return [nextModel, commands];

},
})));
const appendOutMessageStep = (foldOutMessage, outMessage, modelWithChild, mappedCommands) => {
const [nextModel, outCommands] = foldOutMessage(outMessage)(modelWithChild);
}));
/** Folds a child entry point that takes nothing but the child Model, and
* returns the {@link Step} directly. Everything else matches
* {@link foldChild}: the child is read, updated, and written back, its
* Commands are lifted through `toParentMessage`, a `None` from `read` makes
* the Step a no-op, and `foldOutMessage` runs against the Model with the
* child already written back.
*
* Reach for it wherever a Submodel exposes a no-argument entry point, so the
* call site composes with {@link combine} as a plain Step and never invents
* an input the child does not take:
*
* ```ts
* const foldMobileMenuDialogClose = Update.foldChildStep({
* update: Dialog.close,
* read: readMobileMenuDialog,
* write: writeMobileMenuDialog,
* toParentMessage: toGotMobileMenuDialogMessage,
* foldOutMessage: foldMobileMenuDialogOutMessage,
* })
*
* // in the parent update
* Update.combine(model, [writeRouteFields, foldMobileMenuDialogClose])
* ```
*
* `foldOutMessage` takes the same optional second parameter `foldChild`'s
* does, a {@link FoldContext} carrying `liftCommand` and `liftCommands` bound
* to this config's `toParentMessage`, for a Command the Step returns whose
* result is the child's Message.
*
* A parent that is itself a Submodel, and so needs its own OutMessage
* channel on the result, uses {@link foldChild}. */
export const foldChildStep = (childFold) => {
const context = makeFoldContext(childFold.toParentMessage);
return model => runChildFold(childFold, context, model, undefined);
};
const appendOutMessageStep = (foldOutMessage, outMessage, context, modelWithChild, mappedCommands) => {
const [nextModel, outCommands] = foldOutMessage(outMessage, context)(modelWithChild);
return [nextModel, [...mappedCommands, ...outCommands]];
};
{
"name": "foldkit",
"version": "0.141.2",
"version": "0.142.0",
"description": "A TypeScript frontend framework, built on Effect and architected like Elm",

@@ -5,0 +5,0 @@ "type": "module",