foldkit 0.153.0 → 0.154.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/html/index.d.ts +85 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +57 -39
- package/dist/html/public.d.ts +1 -1
- package/dist/html/public.d.ts.map +1 -1
- package/dist/html/public.js +1 -1
- package/dist/test/apps/bubbling.d.ts +10 -0
- package/dist/test/apps/bubbling.d.ts.map +1 -1
- package/dist/test/apps/bubbling.js +52 -1
- package/dist/test/apps/focusBoundary.d.ts +26 -0
- package/dist/test/apps/focusBoundary.d.ts.map +1 -0
- package/dist/test/apps/focusBoundary.js +37 -0
- package/dist/test/scene.d.ts +10 -6
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +167 -57
- package/dist/update/public.d.ts +1 -1
- package/dist/update/public.d.ts.map +1 -1
- package/dist/update/update.d.ts +73 -40
- package/dist/update/update.d.ts.map +1 -1
- package/dist/update/update.js +26 -22
- package/package.json +1 -1
package/dist/update/update.js
CHANGED
|
@@ -108,12 +108,13 @@ export const refresh = (refreshable) => model => pipe(refreshable.read(model), O
|
|
|
108
108
|
* Command that produces the child's Message, such as an animating
|
|
109
109
|
* component's overridable leave Command.
|
|
110
110
|
*
|
|
111
|
-
* A parent that is itself a Submodel
|
|
112
|
-
* {@link
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
111
|
+
* A parent that is itself a Submodel receives a
|
|
112
|
+
* {@link FoldWithOutMessage} when `foldOutMessage` emits a derived parent
|
|
113
|
+
* OutMessage. Add `toParentOutMessage` only when at least one child OutMessage
|
|
114
|
+
* should continue to the current Submodel's parent. When provided,
|
|
115
|
+
* `foldOutMessage` still handles forwarded variants locally. A derived
|
|
116
|
+
* OutMessage replaces the one-to-one lift for the dispatch. When the Step
|
|
117
|
+
* emits nothing, the lift runs as usual.
|
|
117
118
|
*
|
|
118
119
|
* An entry point that takes nothing but the child Model, such as
|
|
119
120
|
* `Dialog.close`, has no input to pass: fold it with
|
|
@@ -153,21 +154,18 @@ const runChildFold = (childFold, context, model, input) => pipe(model, childFold
|
|
|
153
154
|
const update = childFold.foldOutMessage === undefined ||
|
|
154
155
|
childUpdate.outMessage === undefined
|
|
155
156
|
? { model: modelWithChild, commands: mappedCommands }
|
|
156
|
-
:
|
|
157
|
-
|
|
158
|
-
model: stepModel,
|
|
159
|
-
commands: mappedCommands,
|
|
160
|
-
}),
|
|
161
|
-
childFold.foldOutMessage(childUpdate.outMessage, context),
|
|
162
|
-
]);
|
|
163
|
-
if (childFold.toParentOutMessage === undefined) {
|
|
157
|
+
: appendOutMessageStep(childFold.foldOutMessage, childUpdate.outMessage, context, modelWithChild, mappedCommands);
|
|
158
|
+
if (update.outMessage !== undefined) {
|
|
164
159
|
return update;
|
|
165
160
|
}
|
|
166
|
-
if (
|
|
161
|
+
if (childFold.toParentOutMessage === undefined ||
|
|
162
|
+
childUpdate.outMessage === undefined) {
|
|
167
163
|
return update;
|
|
168
164
|
}
|
|
169
165
|
const parentOutMessage = childFold.toParentOutMessage(childUpdate.outMessage);
|
|
170
|
-
return
|
|
166
|
+
return parentOutMessage === undefined
|
|
167
|
+
? update
|
|
168
|
+
: { ...update, outMessage: parentOutMessage };
|
|
171
169
|
},
|
|
172
170
|
}));
|
|
173
171
|
/** Folds a child entry point that takes nothing but the child Model, and
|
|
@@ -199,13 +197,19 @@ const runChildFold = (childFold, context, model, input) => pipe(model, childFold
|
|
|
199
197
|
* `liftCommands` bound to this config's `toParentMessage`, for a Command the
|
|
200
198
|
* Step returns whose result is the child's Message.
|
|
201
199
|
*
|
|
202
|
-
* A parent that is itself a Submodel
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
200
|
+
* A parent that is itself a Submodel receives a
|
|
201
|
+
* {@link StepWithOutMessage} when `foldOutMessage` emits a derived parent
|
|
202
|
+
* OutMessage. Add `toParentOutMessage` only when at least one child OutMessage
|
|
203
|
+
* should continue to the current Submodel's parent. When provided,
|
|
204
|
+
* `foldOutMessage` still handles forwarded variants locally. A derived
|
|
205
|
+
* OutMessage replaces the one-to-one lift for the dispatch. When the Step
|
|
206
|
+
* emits nothing, the lift runs as usual. */
|
|
208
207
|
export const foldChildStep = (childFold) => {
|
|
209
208
|
const context = makeFoldContext(childFold.toParentMessage);
|
|
210
209
|
return (model) => runChildFold(childFold, context, model, undefined);
|
|
211
210
|
};
|
|
211
|
+
const appendOutMessageStep = (foldOutMessage, outMessage, context, modelWithChild, mappedCommands) => {
|
|
212
|
+
const outMessageFold = foldOutMessage(outMessage, context)(modelWithChild);
|
|
213
|
+
const commands = [...mappedCommands, ...(outMessageFold.commands ?? [])];
|
|
214
|
+
return { ...outMessageFold, commands };
|
|
215
|
+
};
|