foldkit 0.140.0 → 0.141.0
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/command/index.d.ts +16 -56
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +10 -2
- package/dist/update/public.d.ts +2 -2
- package/dist/update/public.d.ts.map +1 -1
- package/dist/update/public.js +1 -1
- package/dist/update/update.d.ts +130 -0
- package/dist/update/update.d.ts.map +1 -1
- package/dist/update/update.js +75 -0
- package/package.json +6 -6
package/dist/command/index.d.ts
CHANGED
|
@@ -182,24 +182,8 @@ export declare function define<const Name extends string, const Messages extends
|
|
|
182
182
|
* see the child's raw Message instead of the wrapped one. Lift result Messages
|
|
183
183
|
* with {@link mapMessage} / {@link mapMessages}, which record the lift. */
|
|
184
184
|
export declare const mapEffect: {
|
|
185
|
-
<A, E1, R1, B, E2, R2>(f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): (command:
|
|
186
|
-
|
|
187
|
-
args?: Record<string, unknown>;
|
|
188
|
-
effect: Effect.Effect<A, E1, R1>;
|
|
189
|
-
}>) => Readonly<{
|
|
190
|
-
name: string;
|
|
191
|
-
args?: Record<string, unknown>;
|
|
192
|
-
effect: Effect.Effect<B, E2, R2>;
|
|
193
|
-
}>;
|
|
194
|
-
<A, E1, R1, B, E2, R2>(command: Readonly<{
|
|
195
|
-
name: string;
|
|
196
|
-
args?: Record<string, unknown>;
|
|
197
|
-
effect: Effect.Effect<A, E1, R1>;
|
|
198
|
-
}>, f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): Readonly<{
|
|
199
|
-
name: string;
|
|
200
|
-
args?: Record<string, unknown>;
|
|
201
|
-
effect: Effect.Effect<B, E2, R2>;
|
|
202
|
-
}>;
|
|
185
|
+
<A, E1, R1, B, E2, R2>(f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): (command: Command<A, E1, R1>) => Command<B, E2, R2>;
|
|
186
|
+
<A, E1, R1, B, E2, R2>(command: Command<A, E1, R1>, f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): Command<B, E2, R2>;
|
|
203
187
|
};
|
|
204
188
|
/** Lifts a single Command's result Message through `f`, transforming
|
|
205
189
|
* `FromMessage` to `ToMessage`. The singular complement to
|
|
@@ -217,26 +201,14 @@ export declare const mapEffect: {
|
|
|
217
201
|
* Preserves the Command's `name` and `args` so traces still attribute
|
|
218
202
|
* it to the originating Submodel. When you need to transform the
|
|
219
203
|
* Effect itself (not just the result Message), reach for
|
|
220
|
-
* {@link mapEffect} instead.
|
|
204
|
+
* {@link mapEffect} instead.
|
|
205
|
+
*
|
|
206
|
+
* Typed against {@link Command} in argument and result positions, so a
|
|
207
|
+
* generic combinator over a type-parameter Message unifies with
|
|
208
|
+
* `Command.Command<Message>` directly. */
|
|
221
209
|
export declare const mapMessage: {
|
|
222
|
-
<FromMessage, ToMessage, E = never, R = never>(command:
|
|
223
|
-
|
|
224
|
-
args?: Record<string, unknown>;
|
|
225
|
-
effect: Effect.Effect<FromMessage, E, R>;
|
|
226
|
-
}>, f: (message: FromMessage) => ToMessage): Readonly<{
|
|
227
|
-
name: string;
|
|
228
|
-
args?: Record<string, unknown>;
|
|
229
|
-
effect: Effect.Effect<ToMessage, E, R>;
|
|
230
|
-
}>;
|
|
231
|
-
<FromMessage, ToMessage>(f: (message: FromMessage) => ToMessage): <E = never, R = never>(command: Readonly<{
|
|
232
|
-
name: string;
|
|
233
|
-
args?: Record<string, unknown>;
|
|
234
|
-
effect: Effect.Effect<FromMessage, E, R>;
|
|
235
|
-
}>) => Readonly<{
|
|
236
|
-
name: string;
|
|
237
|
-
args?: Record<string, unknown>;
|
|
238
|
-
effect: Effect.Effect<ToMessage, E, R>;
|
|
239
|
-
}>;
|
|
210
|
+
<FromMessage, ToMessage, E = never, R = never>(command: Command<FromMessage, E, R>, f: (message: FromMessage) => ToMessage): Command<ToMessage, E, R>;
|
|
211
|
+
<FromMessage, ToMessage>(f: (message: FromMessage) => ToMessage): <E = never, R = never>(command: Command<FromMessage, E, R>) => Command<ToMessage, E, R>;
|
|
240
212
|
};
|
|
241
213
|
/** Lifts every Command in a list through `f`, transforming the result
|
|
242
214
|
* Message type from `FromMessage` to `ToMessage`. Reach for this at the
|
|
@@ -261,25 +233,13 @@ export declare const mapMessage: {
|
|
|
261
233
|
* from the matched Command.
|
|
262
234
|
* Preserves each Command's `name` and `args` so traces still attribute the
|
|
263
235
|
* Command to the originating Submodel. When you need to transform the Effect
|
|
264
|
-
* itself (not just the result Message), reach for {@link mapEffect} instead.
|
|
236
|
+
* itself (not just the result Message), reach for {@link mapEffect} instead.
|
|
237
|
+
*
|
|
238
|
+
* Typed against {@link Command} in argument and result positions, so a
|
|
239
|
+
* generic combinator over a type-parameter Message unifies with
|
|
240
|
+
* `Command.Command<Message>` directly. */
|
|
265
241
|
export declare const mapMessages: {
|
|
266
|
-
<FromMessage, ToMessage, E = never, R = never>(commands: ReadonlyArray<
|
|
267
|
-
|
|
268
|
-
args?: Record<string, unknown>;
|
|
269
|
-
effect: Effect.Effect<FromMessage, E, R>;
|
|
270
|
-
}>>, f: (message: FromMessage) => ToMessage): ReadonlyArray<Readonly<{
|
|
271
|
-
name: string;
|
|
272
|
-
args?: Record<string, unknown>;
|
|
273
|
-
effect: Effect.Effect<ToMessage, E, R>;
|
|
274
|
-
}>>;
|
|
275
|
-
<FromMessage, ToMessage>(f: (message: FromMessage) => ToMessage): <E = never, R = never>(commands: ReadonlyArray<Readonly<{
|
|
276
|
-
name: string;
|
|
277
|
-
args?: Record<string, unknown>;
|
|
278
|
-
effect: Effect.Effect<FromMessage, E, R>;
|
|
279
|
-
}>>) => ReadonlyArray<Readonly<{
|
|
280
|
-
name: string;
|
|
281
|
-
args?: Record<string, unknown>;
|
|
282
|
-
effect: Effect.Effect<ToMessage, E, R>;
|
|
283
|
-
}>>;
|
|
242
|
+
<FromMessage, ToMessage, E = never, R = never>(commands: ReadonlyArray<Command<FromMessage, E, R>>, f: (message: FromMessage) => ToMessage): ReadonlyArray<Command<ToMessage, E, R>>;
|
|
243
|
+
<FromMessage, ToMessage>(f: (message: FromMessage) => ToMessage): <E = never, R = never>(commands: ReadonlyArray<Command<FromMessage, E, R>>) => ReadonlyArray<Command<ToMessage, E, R>>;
|
|
284
244
|
};
|
|
285
245
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAA+B,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE3E,OAAO,EAAE,uBAAuB,EAAqB,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAElC;;;mEAGmE;AACnE,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GACnE,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CACnD,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC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1C,CAAC,WAAW,EAAE,SAAS,EACrB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,GACrC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EACtB,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAChD,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;CAQ7C,CAAA"}
|
package/dist/command/index.js
CHANGED
|
@@ -113,7 +113,11 @@ export const mapEffect = Function.dual(2, (command, f) => ({ ...command, effect:
|
|
|
113
113
|
* Preserves the Command's `name` and `args` so traces still attribute
|
|
114
114
|
* it to the originating Submodel. When you need to transform the
|
|
115
115
|
* Effect itself (not just the result Message), reach for
|
|
116
|
-
* {@link mapEffect} instead.
|
|
116
|
+
* {@link mapEffect} instead.
|
|
117
|
+
*
|
|
118
|
+
* Typed against {@link Command} in argument and result positions, so a
|
|
119
|
+
* generic combinator over a type-parameter Message unifies with
|
|
120
|
+
* `Command.Command<Message>` directly. */
|
|
117
121
|
export const mapMessage = Function.dual(2, (command, f) => {
|
|
118
122
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
119
123
|
const withMappers = command;
|
|
@@ -147,5 +151,9 @@ export const mapMessage = Function.dual(2, (command, f) => {
|
|
|
147
151
|
* from the matched Command.
|
|
148
152
|
* Preserves each Command's `name` and `args` so traces still attribute the
|
|
149
153
|
* Command to the originating Submodel. When you need to transform the Effect
|
|
150
|
-
* itself (not just the result Message), reach for {@link mapEffect} instead.
|
|
154
|
+
* itself (not just the result Message), reach for {@link mapEffect} instead.
|
|
155
|
+
*
|
|
156
|
+
* Typed against {@link Command} in argument and result positions, so a
|
|
157
|
+
* generic combinator over a type-parameter Message unifies with
|
|
158
|
+
* `Command.Command<Message>` directly. */
|
|
151
159
|
export const mapMessages = Function.dual(2, (commands, f) => Array.map(commands, command => mapMessage(command, f)));
|
package/dist/update/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { combine, refresh } from './index.js';
|
|
2
|
-
export type { Commands, Return, ReturnWithOutMessage, Step, Refreshable, } from './index.js';
|
|
1
|
+
export { combine, foldChild, refresh } from './index.js';
|
|
2
|
+
export type { Commands, Return, ReturnWithOutMessage, Step, StepWithOutMessage, Refreshable, ChildFold, ChildFoldWithOutMessage, ChildFoldWithParentOutMessage, Fold, FoldWithOutMessage, } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/update/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
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"}
|
package/dist/update/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { combine, refresh } from './index.js';
|
|
1
|
+
export { combine, foldChild, refresh } from './index.js';
|
package/dist/update/update.d.ts
CHANGED
|
@@ -99,4 +99,134 @@ export type Refreshable<Model, Message, A, E, R = never> = Readonly<{
|
|
|
99
99
|
* })
|
|
100
100
|
* ``` */
|
|
101
101
|
export declare const refresh: <Model, Message, A, E, R = never>(refreshable: Refreshable<Model, Message, A, E, R>) => Step<Model, Message, R>;
|
|
102
|
+
/** The four capabilities that fold one child Submodel's update into the
|
|
103
|
+
* parent, for a child without an OutMessage channel.
|
|
104
|
+
*
|
|
105
|
+
* - `update`: the child update function to run.
|
|
106
|
+
* - `read`: the getter half of the lens onto the child: reads the child
|
|
107
|
+
* Model from the parent Model. Returns an `Option` because a child
|
|
108
|
+
* may not be mounted (for example a page behind a route or a keyed
|
|
109
|
+
* collection miss); a single always-present field wraps in
|
|
110
|
+
* `Option.some`.
|
|
111
|
+
* - `write`: the setter half of the lens: writes the updated child
|
|
112
|
+
* Model back into the parent Model.
|
|
113
|
+
* - `toParentMessage`: lifts a child Message into the parent's Message,
|
|
114
|
+
* the same contract `h.submodel` takes for the view half. Always the
|
|
115
|
+
* child's `Got*` wrapper: `message => GotSearchMessage({ message })`. */
|
|
116
|
+
export type ChildFold<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, R = never> = Readonly<{
|
|
117
|
+
update: (childModel: ChildModel, input: Input) => Return<ChildModel, ChildMessage, R>;
|
|
118
|
+
read: (model: ParentModel) => Option.Option<ChildModel>;
|
|
119
|
+
write: (model: ParentModel, nextChildModel: ChildModel) => ParentModel;
|
|
120
|
+
toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
121
|
+
}>;
|
|
122
|
+
/** {@link ChildFold} for a child whose update returns
|
|
123
|
+
* {@link ReturnWithOutMessage}, adding the fifth capability:
|
|
124
|
+
*
|
|
125
|
+
* - `foldOutMessage`: folds the child's OutMessage into the parent as a
|
|
126
|
+
* {@link Step}. The Step receives the parent Model with the child
|
|
127
|
+
* already written back, and its Commands follow the child's in the
|
|
128
|
+
* returned batch. Match on the OutMessage tag inside
|
|
129
|
+
* (`M.tagsExhaustive`), and build a multi-step fold with
|
|
130
|
+
* {@link combine}. */
|
|
131
|
+
export type ChildFoldWithOutMessage<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, R = never> = Readonly<{
|
|
132
|
+
update: (childModel: ChildModel, input: Input) => ReturnWithOutMessage<ChildModel, ChildMessage, ChildOutMessage, R>;
|
|
133
|
+
read: (model: ParentModel) => Option.Option<ChildModel>;
|
|
134
|
+
write: (model: ParentModel, nextChildModel: ChildModel) => ParentModel;
|
|
135
|
+
toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
136
|
+
foldOutMessage: (outMessage: ChildOutMessage) => Step<ParentModel, ParentMessage, R>;
|
|
137
|
+
}>;
|
|
138
|
+
/** {@link ChildFoldWithOutMessage} for a parent that is itself a
|
|
139
|
+
* Submodel, so the fold's result carries the parent's own OutMessage
|
|
140
|
+
* channel as a third tuple element. Adds:
|
|
141
|
+
*
|
|
142
|
+
* - `toParentOutMessage`: lifts the child's OutMessage into the
|
|
143
|
+
* parent's own OutMessage; `None` passes nothing upward. When the
|
|
144
|
+
* child returns no OutMessage the fold's third element is `None`.
|
|
145
|
+
* - `foldOutMessage` stays available for a parent that also updates
|
|
146
|
+
* its own state from the child's OutMessage, and is optional here.
|
|
147
|
+
*
|
|
148
|
+
* A parent Submodel embedding a child with no OutMessage channel needs
|
|
149
|
+
* no config at all: spread the plain fold into its return,
|
|
150
|
+
* `[...foldStartDate(model, message), Option.none()]`. */
|
|
151
|
+
export type ChildFoldWithParentOutMessage<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, ParentOutMessage, R = never> = Readonly<{
|
|
152
|
+
update: (childModel: ChildModel, input: Input) => ReturnWithOutMessage<ChildModel, ChildMessage, ChildOutMessage, R>;
|
|
153
|
+
read: (model: ParentModel) => Option.Option<ChildModel>;
|
|
154
|
+
write: (model: ParentModel, nextChildModel: ChildModel) => ParentModel;
|
|
155
|
+
toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
156
|
+
toParentOutMessage: (outMessage: ChildOutMessage) => Option.Option<ParentOutMessage>;
|
|
157
|
+
foldOutMessage?: (outMessage: ChildOutMessage) => Step<ParentModel, ParentMessage, R>;
|
|
158
|
+
}>;
|
|
159
|
+
/** {@link Step} for an update that also surfaces an OutMessage to its
|
|
160
|
+
* parent: maps a Model to a {@link ReturnWithOutMessage} over the same
|
|
161
|
+
* Model. */
|
|
162
|
+
export type StepWithOutMessage<Model, Message, OutMessage, R = never> = (model: Model) => ReturnWithOutMessage<Model, Message, OutMessage, R>;
|
|
163
|
+
/** The dual function {@link foldChild} returns. Data-first runs the
|
|
164
|
+
* fold now (`fold(model, input)` returns a {@link Return}); data-last
|
|
165
|
+
* builds a composable {@link Step} (`fold(input)`, for
|
|
166
|
+
* {@link combine}). */
|
|
167
|
+
export type Fold<ParentModel, ParentMessage, Input, R = never> = {
|
|
168
|
+
(model: ParentModel, input: Input): Return<ParentModel, ParentMessage, R>;
|
|
169
|
+
(input: Input): Step<ParentModel, ParentMessage, R>;
|
|
170
|
+
};
|
|
171
|
+
/** {@link Fold} for a {@link ChildFoldWithParentOutMessage}: the
|
|
172
|
+
* data-first form returns a {@link ReturnWithOutMessage} and the
|
|
173
|
+
* data-last form builds a {@link StepWithOutMessage}, so the fold slots
|
|
174
|
+
* directly into a parent that is itself a Submodel. */
|
|
175
|
+
export type FoldWithOutMessage<ParentModel, ParentMessage, Input, ParentOutMessage, R = never> = {
|
|
176
|
+
(model: ParentModel, input: Input): ReturnWithOutMessage<ParentModel, ParentMessage, ParentOutMessage, R>;
|
|
177
|
+
(input: Input): StepWithOutMessage<ParentModel, ParentMessage, ParentOutMessage, R>;
|
|
178
|
+
};
|
|
179
|
+
/** Folds a child Submodel's update into the parent: the update half of
|
|
180
|
+
* embedding a child, complementing `h.submodel` on the view half. Give
|
|
181
|
+
* it the facts that vary per child (a {@link ChildFold}, or a
|
|
182
|
+
* {@link ChildFoldWithOutMessage} when the child's update returns
|
|
183
|
+
* OutMessages) and it returns a dual {@link Fold}:
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* const foldSearch = Update.foldChild({
|
|
187
|
+
* update: Search.update,
|
|
188
|
+
* read: (model: Model) => Option.some(model.search),
|
|
189
|
+
* write: (model, nextSearch) => evo(model, { search: () => nextSearch }),
|
|
190
|
+
* toParentMessage: message => GotSearchMessage({ message }),
|
|
191
|
+
* })
|
|
192
|
+
*
|
|
193
|
+
* // in the parent update
|
|
194
|
+
* GotSearchMessage: ({ message }) => foldSearch(model, message),
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* The fold runs `update` against the child Model `read` returns, writes
|
|
198
|
+
* the child back, and lifts the child's Commands through
|
|
199
|
+
* `toParentMessage`. When `read` returns `None` the fold returns
|
|
200
|
+
* `[model, []]`: a Message for an unmounted child is a no-op. When the
|
|
201
|
+
* child's update returns an OutMessage, `foldOutMessage` runs against
|
|
202
|
+
* the Model with the child already written back, and its Commands
|
|
203
|
+
* follow the child's in the returned batch.
|
|
204
|
+
*
|
|
205
|
+
* A parent that is itself a Submodel passes a
|
|
206
|
+
* {@link ChildFoldWithParentOutMessage} and receives a
|
|
207
|
+
* {@link FoldWithOutMessage}, whose results carry the parent's own
|
|
208
|
+
* OutMessage channel as a third element.
|
|
209
|
+
*
|
|
210
|
+
* `update` closes over per-dispatch context, and the data-last form
|
|
211
|
+
* composes with {@link combine}, here to put a navigation Command ahead
|
|
212
|
+
* of the child's:
|
|
213
|
+
*
|
|
214
|
+
* ```ts
|
|
215
|
+
* const joinRoom = (roomId: string, player: Player): UpdateStep =>
|
|
216
|
+
* Update.combine([
|
|
217
|
+
* model => [model, [NavigateToRoom({ roomId })]],
|
|
218
|
+
* Update.foldChild({
|
|
219
|
+
* update: (room: Room.Model, player: Player) =>
|
|
220
|
+
* Room.join(room, player, { roomId }),
|
|
221
|
+
* read: readRoom,
|
|
222
|
+
* write: writeRoom,
|
|
223
|
+
* toParentMessage: toGotRoomMessage,
|
|
224
|
+
* })(player),
|
|
225
|
+
* ])
|
|
226
|
+
* ``` */
|
|
227
|
+
export declare const foldChild: {
|
|
228
|
+
<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, ParentOutMessage, R = never>(childFold: ChildFoldWithParentOutMessage<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, ParentOutMessage, R>): FoldWithOutMessage<ParentModel, ParentMessage, Input, ParentOutMessage, R>;
|
|
229
|
+
<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, R = never>(childFold: ChildFoldWithOutMessage<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, ChildOutMessage, R>): Fold<ParentModel, ParentMessage, Input, R>;
|
|
230
|
+
<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, R = never>(childFold: ChildFold<ParentModel, ParentMessage, ChildModel, Input, ChildMessage, R>): Fold<ParentModel, ParentMessage, Input, R>;
|
|
231
|
+
};
|
|
102
232
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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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,EAAE,aAAa,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAA;IAC7E,CACE,WAAW,EACX,aAAa,EACb,UAAU,EACV,KAAK,EACL,YAAY,EACZ,eAAe,EACf,CAAC,GAAG,KAAK,EAET,SAAS,EAAE,uBAAuB,CAChC,WAAW,EACX,aAAa,EACb,UAAU,EACV,KAAK,EACL,YAAY,EACZ,eAAe,EACf,CAAC,CACF,GACA,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IAC7C,CAAC,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,GAAG,KAAK,EACrE,SAAS,EAAE,SAAS,CAClB,WAAW,EACX,aAAa,EACb,UAAU,EACV,KAAK,EACL,YAAY,EACZ,CAAC,CACF,GACA,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;CA4C5C,CAAA"}
|
package/dist/update/update.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Array, Function, Option, pipe } from 'effect';
|
|
2
|
+
import { mapMessages } from '../command/index.js';
|
|
2
3
|
/** Composes a list of update steps into one. Each step runs against the
|
|
3
4
|
* Model the previous step produced, and every step's Commands are
|
|
4
5
|
* concatenated into a single batch, in step order.
|
|
@@ -51,3 +52,77 @@ export const refresh = (refreshable) => model => pipe(refreshable.read(model), O
|
|
|
51
52
|
onNone: () => [model, []],
|
|
52
53
|
onSome: next => [refreshable.write(model, next), [refreshable.load]],
|
|
53
54
|
}));
|
|
55
|
+
/** Folds a child Submodel's update into the parent: the update half of
|
|
56
|
+
* embedding a child, complementing `h.submodel` on the view half. Give
|
|
57
|
+
* it the facts that vary per child (a {@link ChildFold}, or a
|
|
58
|
+
* {@link ChildFoldWithOutMessage} when the child's update returns
|
|
59
|
+
* OutMessages) and it returns a dual {@link Fold}:
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* const foldSearch = Update.foldChild({
|
|
63
|
+
* update: Search.update,
|
|
64
|
+
* read: (model: Model) => Option.some(model.search),
|
|
65
|
+
* write: (model, nextSearch) => evo(model, { search: () => nextSearch }),
|
|
66
|
+
* toParentMessage: message => GotSearchMessage({ message }),
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // in the parent update
|
|
70
|
+
* GotSearchMessage: ({ message }) => foldSearch(model, message),
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* The fold runs `update` against the child Model `read` returns, writes
|
|
74
|
+
* the child back, and lifts the child's Commands through
|
|
75
|
+
* `toParentMessage`. When `read` returns `None` the fold returns
|
|
76
|
+
* `[model, []]`: a Message for an unmounted child is a no-op. When the
|
|
77
|
+
* child's update returns an OutMessage, `foldOutMessage` runs against
|
|
78
|
+
* the Model with the child already written back, and its Commands
|
|
79
|
+
* follow the child's in the returned batch.
|
|
80
|
+
*
|
|
81
|
+
* A parent that is itself a Submodel passes a
|
|
82
|
+
* {@link ChildFoldWithParentOutMessage} and receives a
|
|
83
|
+
* {@link FoldWithOutMessage}, whose results carry the parent's own
|
|
84
|
+
* OutMessage channel as a third element.
|
|
85
|
+
*
|
|
86
|
+
* `update` closes over per-dispatch context, and the data-last form
|
|
87
|
+
* composes with {@link combine}, here to put a navigation Command ahead
|
|
88
|
+
* of the child's:
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* const joinRoom = (roomId: string, player: Player): UpdateStep =>
|
|
92
|
+
* Update.combine([
|
|
93
|
+
* model => [model, [NavigateToRoom({ roomId })]],
|
|
94
|
+
* Update.foldChild({
|
|
95
|
+
* update: (room: Room.Model, player: Player) =>
|
|
96
|
+
* Room.join(room, player, { roomId }),
|
|
97
|
+
* read: readRoom,
|
|
98
|
+
* write: writeRoom,
|
|
99
|
+
* toParentMessage: toGotRoomMessage,
|
|
100
|
+
* })(player),
|
|
101
|
+
* ])
|
|
102
|
+
* ``` */
|
|
103
|
+
export const foldChild = (childFold) => Function.dual(2, (model, input) => pipe(model, childFold.read, Option.match({
|
|
104
|
+
onNone: () => childFold.toParentOutMessage === undefined
|
|
105
|
+
? [model, []]
|
|
106
|
+
: [model, [], Option.none()],
|
|
107
|
+
onSome: childModel => {
|
|
108
|
+
const [nextChildModel, childCommands, maybeOutMessage] = childFold.update(childModel, input);
|
|
109
|
+
const modelWithChild = childFold.write(model, nextChildModel);
|
|
110
|
+
const mappedCommands = mapMessages(childCommands, childFold.toParentMessage);
|
|
111
|
+
const [nextModel, commands] = childFold.foldOutMessage === undefined ||
|
|
112
|
+
maybeOutMessage === undefined ||
|
|
113
|
+
Option.isNone(maybeOutMessage)
|
|
114
|
+
? [modelWithChild, mappedCommands]
|
|
115
|
+
: appendOutMessageStep(childFold.foldOutMessage, maybeOutMessage.value, modelWithChild, mappedCommands);
|
|
116
|
+
if (childFold.toParentOutMessage === undefined) {
|
|
117
|
+
return [nextModel, commands];
|
|
118
|
+
}
|
|
119
|
+
const maybeParentOutMessage = maybeOutMessage === undefined
|
|
120
|
+
? Option.none()
|
|
121
|
+
: Option.flatMap(maybeOutMessage, childFold.toParentOutMessage);
|
|
122
|
+
return [nextModel, commands, maybeParentOutMessage];
|
|
123
|
+
},
|
|
124
|
+
})));
|
|
125
|
+
const appendOutMessageStep = (foldOutMessage, outMessage, modelWithChild, mappedCommands) => {
|
|
126
|
+
const [nextModel, outCommands] = foldOutMessage(outMessage)(modelWithChild);
|
|
127
|
+
return [nextModel, [...mappedCommands, ...outCommands]];
|
|
128
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.141.0",
|
|
4
4
|
"description": "A TypeScript frontend framework, built on Effect and architected like Elm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -154,14 +154,14 @@
|
|
|
154
154
|
"THIRD-PARTY-NOTICES.md"
|
|
155
155
|
],
|
|
156
156
|
"peerDependencies": {
|
|
157
|
-
"@effect/platform-browser": "4.0.0-beta.
|
|
158
|
-
"effect": "4.0.0-beta.
|
|
157
|
+
"@effect/platform-browser": "4.0.0-beta.105",
|
|
158
|
+
"effect": "4.0.0-beta.105"
|
|
159
159
|
},
|
|
160
160
|
"devDependencies": {
|
|
161
|
-
"@effect/platform-browser": "4.0.0-beta.
|
|
162
|
-
"@effect/vitest": "4.0.0-beta.
|
|
161
|
+
"@effect/platform-browser": "4.0.0-beta.105",
|
|
162
|
+
"@effect/vitest": "4.0.0-beta.105",
|
|
163
163
|
"@vitest/coverage-v8": "^4.1.9",
|
|
164
|
-
"effect": "4.0.0-beta.
|
|
164
|
+
"effect": "4.0.0-beta.105",
|
|
165
165
|
"happy-dom": "^20.10.4",
|
|
166
166
|
"rimraf": "^6.1.3",
|
|
167
167
|
"typedoc": "^0.28.19",
|