@wardic/foldkit 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +59 -2
- package/THIRD_PARTY_NOTICES.md +145 -0
- package/dist/AnimationControls.d.ts +37 -0
- package/dist/AnimationControls.d.ts.map +1 -0
- package/dist/AnimationControls.js +37 -0
- package/dist/AnimationControls.js.map +1 -0
- package/dist/AnimationScope.d.ts +20 -0
- package/dist/AnimationScope.d.ts.map +1 -0
- package/dist/AnimationScope.js +20 -0
- package/dist/AnimationScope.js.map +1 -0
- package/dist/DragControls.d.ts +25 -0
- package/dist/DragControls.d.ts.map +1 -0
- package/dist/DragControls.js +21 -0
- package/dist/DragControls.js.map +1 -0
- package/dist/Features.d.ts +36 -0
- package/dist/Features.d.ts.map +1 -0
- package/dist/Features.js +44 -0
- package/dist/Features.js.map +1 -0
- package/dist/Ward.d.ts +301 -0
- package/dist/Ward.d.ts.map +1 -0
- package/dist/Ward.js +6 -0
- package/dist/Ward.js.map +1 -0
- package/dist/Wardic.d.ts +363 -0
- package/dist/Wardic.d.ts.map +1 -0
- package/dist/Wardic.js +85 -0
- package/dist/Wardic.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/builder.d.ts +8 -0
- package/dist/internal/builder.d.ts.map +1 -0
- package/dist/internal/builder.js +242 -0
- package/dist/internal/builder.js.map +1 -0
- package/dist/internal/commands.d.ts +143 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +242 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/delivery.d.ts +44 -0
- package/dist/internal/delivery.d.ts.map +1 -0
- package/dist/internal/delivery.js +85 -0
- package/dist/internal/delivery.js.map +1 -0
- package/dist/internal/dev.d.ts +10 -0
- package/dist/internal/dev.d.ts.map +1 -0
- package/dist/internal/dev.js +10 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/dev.production.d.ts +8 -0
- package/dist/internal/dev.production.d.ts.map +1 -0
- package/dist/internal/dev.production.js +8 -0
- package/dist/internal/dev.production.js.map +1 -0
- package/dist/internal/drag.d.ts +66 -0
- package/dist/internal/drag.d.ts.map +1 -0
- package/dist/internal/drag.js +71 -0
- package/dist/internal/drag.js.map +1 -0
- package/dist/internal/element.d.ts +59 -0
- package/dist/internal/element.d.ts.map +1 -0
- package/dist/internal/element.js +582 -0
- package/dist/internal/element.js.map +1 -0
- package/dist/internal/gestures.d.ts +62 -0
- package/dist/internal/gestures.d.ts.map +1 -0
- package/dist/internal/gestures.js +109 -0
- package/dist/internal/gestures.js.map +1 -0
- package/dist/internal/hydrate.d.ts +5 -0
- package/dist/internal/hydrate.d.ts.map +1 -0
- package/dist/internal/hydrate.js +27 -0
- package/dist/internal/hydrate.js.map +1 -0
- package/dist/internal/keys.d.ts +21 -0
- package/dist/internal/keys.d.ts.map +1 -0
- package/dist/internal/keys.js +12 -0
- package/dist/internal/keys.js.map +1 -0
- package/dist/internal/layout.d.ts +29 -0
- package/dist/internal/layout.d.ts.map +1 -0
- package/dist/internal/layout.js +88 -0
- package/dist/internal/layout.js.map +1 -0
- package/dist/internal/mount.d.ts +22 -0
- package/dist/internal/mount.d.ts.map +1 -0
- package/dist/internal/mount.js +100 -0
- package/dist/internal/mount.js.map +1 -0
- package/dist/internal/presence.d.ts +33 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +338 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/reactivity.d.ts +15 -0
- package/dist/internal/reactivity.d.ts.map +1 -0
- package/dist/internal/reactivity.js +26 -0
- package/dist/internal/reactivity.js.map +1 -0
- package/dist/internal/reorder.d.ts +47 -0
- package/dist/internal/reorder.d.ts.map +1 -0
- package/dist/internal/reorder.js +250 -0
- package/dist/internal/reorder.js.map +1 -0
- package/dist/internal/scope.d.ts +28 -0
- package/dist/internal/scope.d.ts.map +1 -0
- package/dist/internal/scope.js +44 -0
- package/dist/internal/scope.js.map +1 -0
- package/dist/internal/server.d.ts +13 -0
- package/dist/internal/server.d.ts.map +1 -0
- package/dist/internal/server.js +13 -0
- package/dist/internal/server.js.map +1 -0
- package/dist/internal/server.node.d.ts +8 -0
- package/dist/internal/server.node.d.ts.map +1 -0
- package/dist/internal/server.node.js +8 -0
- package/dist/internal/server.node.js.map +1 -0
- package/dist/internal/services.d.ts +222 -0
- package/dist/internal/services.d.ts.map +1 -0
- package/dist/internal/services.js +338 -0
- package/dist/internal/services.js.map +1 -0
- package/dist/internal/tree.d.ts +71 -0
- package/dist/internal/tree.d.ts.map +1 -0
- package/dist/internal/tree.js +207 -0
- package/dist/internal/tree.js.map +1 -0
- package/dist/internal/variant-node.d.ts +62 -0
- package/dist/internal/variant-node.d.ts.map +1 -0
- package/dist/internal/variant-node.js +279 -0
- package/dist/internal/variant-node.js.map +1 -0
- package/dist/internal/view-transition.d.ts +10 -0
- package/dist/internal/view-transition.d.ts.map +1 -0
- package/dist/internal/view-transition.js +36 -0
- package/dist/internal/view-transition.js.map +1 -0
- package/dist/internal/walk.d.ts +26 -0
- package/dist/internal/walk.d.ts.map +1 -0
- package/dist/internal/walk.js +162 -0
- package/dist/internal/walk.js.map +1 -0
- package/package.json +99 -4
- package/src/AnimationControls.ts +46 -0
- package/src/AnimationScope.ts +19 -0
- package/src/DragControls.ts +27 -0
- package/src/Features.ts +45 -0
- package/src/Ward.ts +434 -0
- package/src/Wardic.ts +410 -0
- package/src/index.ts +20 -0
- package/src/internal/builder.ts +262 -0
- package/src/internal/commands.ts +359 -0
- package/src/internal/delivery.ts +116 -0
- package/src/internal/dev.production.ts +7 -0
- package/src/internal/dev.ts +9 -0
- package/src/internal/drag.ts +136 -0
- package/src/internal/element.ts +668 -0
- package/src/internal/gestures.ts +184 -0
- package/src/internal/hydrate.ts +29 -0
- package/src/internal/keys.ts +19 -0
- package/src/internal/layout.ts +109 -0
- package/src/internal/mount.ts +124 -0
- package/src/internal/presence.ts +362 -0
- package/src/internal/reactivity.ts +45 -0
- package/src/internal/reorder.ts +313 -0
- package/src/internal/scope.ts +60 -0
- package/src/internal/server.node.ts +7 -0
- package/src/internal/server.ts +12 -0
- package/src/internal/services.ts +486 -0
- package/src/internal/tree.ts +230 -0
- package/src/internal/variant-node.ts +352 -0
- package/src/internal/view-transition.ts +43 -0
- package/src/internal/walk.ts +211 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree, by DOM ancestry (ADR-0071 decisions 21 and 22, *Amendment (#791)* item 7): a `w.*`
|
|
3
|
+
* element's variant parent and its nearest `w.Config` are the nearest Wardic ancestors', found by
|
|
4
|
+
* walking `parentElement` to an element carrying a delivered config, which Foldkit's props module
|
|
5
|
+
* wrote at `create`, before the children exist. Foldkit runs a child's Mount before its parent's, so
|
|
6
|
+
* an element's node and config value are made by whichever first asks, cached by the element, and
|
|
7
|
+
* adopted by its own Mount when that runs.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
|
|
12
|
+
import type * as Ward from "../Ward.ts";
|
|
13
|
+
import { type VariantNode } from "./variant-node.ts";
|
|
14
|
+
/** The nearest ancestor of `element` that `has` what's looked for, or none at the top. Per element at mount, up the tree. */
|
|
15
|
+
export declare const nearestAncestor: (element: Element, has: (ancestor: Element) => boolean) => Element | undefined;
|
|
16
|
+
/** Whether `node` is a `w.*` element or under one: a change of the Handle's own, not another app's under the body (decision 33). */
|
|
17
|
+
export declare const underWard: (node: Node) => boolean;
|
|
18
|
+
/** The nearest `w.Presence` element above `element` (decision 29), found as the variant parent is. */
|
|
19
|
+
export declare const nearestPresenceElement: (element: Element) => Element | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The id of the **Layout group** `element` is in (#432, Motion's `LayoutGroup`): the nearest
|
|
22
|
+
* `w.LayoutGroup` above it, its own id joined with the group's above as its `inherit` says
|
|
23
|
+
* (`layoutGroupIdOf`), or none outside any. Read once, at mount, as Solid's is.
|
|
24
|
+
*/
|
|
25
|
+
export declare const layoutGroupOf: (element: Element) => string | undefined;
|
|
26
|
+
/** Mark `element`'s Mount as run: from now on, a `w.Presence` a render adds to it can't run (its Mount is made once). */
|
|
27
|
+
export declare const markMounted: (element: Element) => void;
|
|
28
|
+
/** A start waiting its turn: a child's for its nearest `w.*` ancestor's here, or for its presence's delivery (`presence.ts`). */
|
|
29
|
+
export interface Waiting {
|
|
30
|
+
readonly element: Element;
|
|
31
|
+
/** Starts the element; returns its release. */
|
|
32
|
+
readonly begin: () => () => void;
|
|
33
|
+
/** The start's release, once it ran. */
|
|
34
|
+
release: (() => void) | undefined;
|
|
35
|
+
/** Its Mount destroyed before it began. */
|
|
36
|
+
gone: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A waiting start's release, at its Mount's destroy: gone from now on; the start's own release when it
|
|
40
|
+
* ran, else the node its Mount registered dropped, so no slot of a child that never came stays with
|
|
41
|
+
* its ancestor's orchestration.
|
|
42
|
+
*/
|
|
43
|
+
export declare const releaseWaiting: (entry: Waiting) => void;
|
|
44
|
+
/**
|
|
45
|
+
* `begin` run now, or once the nearest `w.*` ancestor of `element` has started (#848): a tree mounted by
|
|
46
|
+
* one patch starts top-down, every child registered with its ancestor's orchestration before any reads
|
|
47
|
+
* its stagger slot. Returns the release.
|
|
48
|
+
*/
|
|
49
|
+
export declare const startUnder: (element: Element, begin: () => () => void) => (() => void);
|
|
50
|
+
/** Whether `element`'s Mount has run. */
|
|
51
|
+
export declare const isMounted: (element: Element) => boolean;
|
|
52
|
+
/** `element`'s variant node: made at the first ask (a child's, or its own Mount's), over its latest delivered config. */
|
|
53
|
+
export declare const nodeOf: (element: Element) => VariantNode;
|
|
54
|
+
/** Drop `element`'s node at its release: its registration with its ancestor given up. */
|
|
55
|
+
export declare const dropNode: (element: Element) => void;
|
|
56
|
+
/**
|
|
57
|
+
* The `WardicConfigValue` in effect for `element` (#434, ADR-0062): its own `w.Config` over the nearest
|
|
58
|
+
* ancestor's, over the Handle's `config` (`root`). Each setting is read when an animation starts, so a
|
|
59
|
+
* change moves nothing by itself. An element with no `w.Config` of its own shares its ancestor's.
|
|
60
|
+
*/
|
|
61
|
+
export declare const configValueOf: (element: Element, root: WardicConfigValue.WardicConfigValue | undefined) => WardicConfigValue.WardicConfigValue | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The `WardicConfigValue` of an element whose `w.Config` is `own()`, under `parent`'s (ADR-0062): each
|
|
64
|
+
* setting read when an animation starts, so a change moves nothing by itself. What {@link configValueOf}
|
|
65
|
+
* keeps for a mounted element, and the walk at a Provider element's build carries down a server render
|
|
66
|
+
* (#794, PR 2).
|
|
67
|
+
*/
|
|
68
|
+
export declare const configValueUnder: (own: () => Ward.ConfigOptions | undefined, parent: WardicConfigValue.WardicConfigValue | undefined) => WardicConfigValue.WardicConfigValue;
|
|
69
|
+
/** The Handle's app-wide config (`Wardic.make({ config })`), as the root of every element's chain; none without one. */
|
|
70
|
+
export declare const rootConfigValueOf: (options: Ward.ConfigOptions | undefined) => WardicConfigValue.WardicConfigValue | undefined;
|
|
71
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/internal/tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,iBAAiB,MAAM,yCAAyC,CAAA;AAS5E,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAA;AAIvC,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,mBAAmB,CAAA;AASnE,6HAA6H;AAC7H,eAAO,MAAM,eAAe,YAAa,OAAO,OAAO,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,KAAG,OAAO,GAAG,SAKjG,CAAA;AAWD,oIAA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,iBAAiB,CAAC,iBAOtJ,CAAA;AAEF,wHAAwH;AACxH,eAAO,MAAM,iBAAiB,YAAa,IAAI,CAAC,aAAa,GAAG,SAAS,KAAG,iBAAiB,CAAC,iBAAiB,GAAG,SASjH,CAAA"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree, by DOM ancestry (ADR-0071 decisions 21 and 22, *Amendment (#791)* item 7): a `w.*`
|
|
3
|
+
* element's variant parent and its nearest `w.Config` are the nearest Wardic ancestors', found by
|
|
4
|
+
* walking `parentElement` to an element carrying a delivered config, which Foldkit's props module
|
|
5
|
+
* wrote at `create`, before the children exist. Foldkit runs a child's Mount before its parent's, so
|
|
6
|
+
* an element's node and config value are made by whichever first asks, cached by the element, and
|
|
7
|
+
* adopted by its own Mount when that runs.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
|
|
12
|
+
import * as LayoutGroup from "@wardic/dom/unstable/LayoutGroup";
|
|
13
|
+
import * as Arr from "effect/Array";
|
|
14
|
+
import * as Bool from "effect/Boolean";
|
|
15
|
+
import { constUndefined, constVoid, identity } from "effect/Function";
|
|
16
|
+
import * as Option from "effect/Option";
|
|
17
|
+
import * as Predicate from "effect/Predicate";
|
|
18
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
19
|
+
import { deliveredTo } from "./delivery.js";
|
|
20
|
+
import { configOf } from "./element.js";
|
|
21
|
+
import { recheck } from "./reactivity.js";
|
|
22
|
+
import { variantNodeOf } from "./variant-node.js";
|
|
23
|
+
// Module state (#460, Q7): each element's node, held weakly by the element.
|
|
24
|
+
const nodes = new WeakMap();
|
|
25
|
+
// Module state (#460, Q7): each element's config value, held weakly by the element.
|
|
26
|
+
const values = new WeakMap();
|
|
27
|
+
// Module state (#460, Q7): the elements whose Mount has run, held weakly: what a later render's `w.Presence` is told by.
|
|
28
|
+
const mounted = new WeakSet();
|
|
29
|
+
/** The nearest ancestor of `element` that `has` what's looked for, or none at the top. Per element at mount, up the tree. */
|
|
30
|
+
export const nearestAncestor = (element, has) => {
|
|
31
|
+
const ancestor = element.parentElement;
|
|
32
|
+
if (Predicate.isNull(ancestor))
|
|
33
|
+
return undefined;
|
|
34
|
+
if (has(ancestor))
|
|
35
|
+
return ancestor;
|
|
36
|
+
return nearestAncestor(ancestor, has);
|
|
37
|
+
};
|
|
38
|
+
/** Whether an element carries a delivered config: a `w.*` element, or one with the bundle. */
|
|
39
|
+
const isWard = (element) => Predicate.isNotUndefined(deliveredTo(element));
|
|
40
|
+
/** Whether an element carries `w.Presence`. */
|
|
41
|
+
const isPresence = (element) => Predicate.isNotUndefined(configOf(deliveredTo(element)).presence);
|
|
42
|
+
/** The nearest Wardic ancestor of `element`: one carrying a delivered config. */
|
|
43
|
+
const nearestWard = (element) => nearestAncestor(element, isWard);
|
|
44
|
+
/** Whether `node` is a `w.*` element or under one: a change of the Handle's own, not another app's under the body (decision 33). */
|
|
45
|
+
export const underWard = (node) => {
|
|
46
|
+
const element = Bool.match(node instanceof Element, { onTrue: () => node, onFalse: () => node.parentElement });
|
|
47
|
+
if (Predicate.isNull(element))
|
|
48
|
+
return false;
|
|
49
|
+
if (isWard(element))
|
|
50
|
+
return true;
|
|
51
|
+
return Predicate.isNotUndefined(nearestWard(element));
|
|
52
|
+
};
|
|
53
|
+
/** The nearest `w.Presence` element above `element` (decision 29), found as the variant parent is. */
|
|
54
|
+
export const nearestPresenceElement = (element) => nearestAncestor(element, isPresence);
|
|
55
|
+
/** Whether an element carries `w.LayoutGroup`. */
|
|
56
|
+
const isLayoutGroup = (element) => Predicate.isNotUndefined(configOf(deliveredTo(element)).layoutGroup);
|
|
57
|
+
// Module state (#460, Q7): each `w.LayoutGroup` element's id, held weakly, read once as the first `layoutId` under it mounts.
|
|
58
|
+
const groupIds = new WeakMap();
|
|
59
|
+
/**
|
|
60
|
+
* The id of the **Layout group** `element` is in (#432, Motion's `LayoutGroup`): the nearest
|
|
61
|
+
* `w.LayoutGroup` above it, its own id joined with the group's above as its `inherit` says
|
|
62
|
+
* (`layoutGroupIdOf`), or none outside any. Read once, at mount, as Solid's is.
|
|
63
|
+
*/
|
|
64
|
+
export const layoutGroupOf = (element) => UndefinedOr.match(nearestAncestor(element, isLayoutGroup), { onUndefined: constUndefined, onDefined: groupIdOf });
|
|
65
|
+
/** A `w.LayoutGroup` element's id: made at the first ask, from the group above it and its own options. */
|
|
66
|
+
const groupIdOf = (group) => UndefinedOr.match(groupIds.get(group), {
|
|
67
|
+
onDefined: Option.getOrUndefined,
|
|
68
|
+
onUndefined: () => {
|
|
69
|
+
const options = UndefinedOr.match(configOf(deliveredTo(group)).layoutGroup, { onUndefined: () => ({}), onDefined: identity });
|
|
70
|
+
const id = LayoutGroup.layoutGroupIdOf(layoutGroupOf(group), options.id, options.inherit);
|
|
71
|
+
groupIds.set(group, Option.fromUndefinedOr(id));
|
|
72
|
+
return id;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
/** Mark `element`'s Mount as run: from now on, a `w.Presence` a render adds to it can't run (its Mount is made once). */
|
|
76
|
+
export const markMounted = (element) => {
|
|
77
|
+
mounted.add(element);
|
|
78
|
+
};
|
|
79
|
+
// Module state (#848): the elements whose own start has run, held weakly.
|
|
80
|
+
const started = new WeakSet();
|
|
81
|
+
// Module state (#848): the children waiting to start with each element, held weakly by it.
|
|
82
|
+
const waiting = new WeakMap();
|
|
83
|
+
/**
|
|
84
|
+
* A waiting start's release, at its Mount's destroy: gone from now on; the start's own release when it
|
|
85
|
+
* ran, else the node its Mount registered dropped, so no slot of a child that never came stays with
|
|
86
|
+
* its ancestor's orchestration.
|
|
87
|
+
*/
|
|
88
|
+
export const releaseWaiting = (entry) => {
|
|
89
|
+
entry.gone = true;
|
|
90
|
+
UndefinedOr.match(entry.release, { onUndefined: () => dropNode(entry.element), onDefined: (release) => release() });
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* `element`'s own start, `begin`, run now, then the starts of the children that waited for it, in their
|
|
94
|
+
* Mounts' order. A start that fails is the one element's (decision 13): the parent's failing still starts
|
|
95
|
+
* the children, and a child's failing starts its siblings, its defect thrown on a microtask for the
|
|
96
|
+
* page's error handling, as nothing of the parent's Mount is to blame. Returns the release.
|
|
97
|
+
*/
|
|
98
|
+
const startNow = (element, begin) => {
|
|
99
|
+
let release = constVoid;
|
|
100
|
+
try {
|
|
101
|
+
release = begin();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
started.add(element);
|
|
105
|
+
UndefinedOr.map(waiting.get(element), (children) => {
|
|
106
|
+
waiting.delete(element);
|
|
107
|
+
Arr.forEach(children, (child) => {
|
|
108
|
+
if (child.gone)
|
|
109
|
+
return;
|
|
110
|
+
try {
|
|
111
|
+
child.release = startNow(child.element, child.begin);
|
|
112
|
+
}
|
|
113
|
+
catch (defect) {
|
|
114
|
+
queueMicrotask(() => {
|
|
115
|
+
throw defect;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
started.delete(element);
|
|
123
|
+
release();
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* `begin` run now, or once the nearest `w.*` ancestor of `element` has started (#848): a tree mounted by
|
|
128
|
+
* one patch starts top-down, every child registered with its ancestor's orchestration before any reads
|
|
129
|
+
* its stagger slot. Returns the release.
|
|
130
|
+
*/
|
|
131
|
+
export const startUnder = (element, begin) => {
|
|
132
|
+
const ancestor = nearestWard(element);
|
|
133
|
+
if (Predicate.isUndefined(ancestor))
|
|
134
|
+
return startNow(element, begin);
|
|
135
|
+
if (started.has(ancestor))
|
|
136
|
+
return startNow(element, begin);
|
|
137
|
+
const entry = { element, begin, release: undefined, gone: false };
|
|
138
|
+
const children = UndefinedOr.match(waiting.get(ancestor), { onUndefined: () => [], onDefined: identity });
|
|
139
|
+
children.push(entry);
|
|
140
|
+
waiting.set(ancestor, children);
|
|
141
|
+
return () => releaseWaiting(entry);
|
|
142
|
+
};
|
|
143
|
+
/** Whether `element`'s Mount has run. */
|
|
144
|
+
export const isMounted = (element) => mounted.has(element);
|
|
145
|
+
/** The variant context the nearest Wardic ancestor of `element` provides, or none at the top. */
|
|
146
|
+
const parentContextOf = (element) => UndefinedOr.match(nearestWard(element), { onUndefined: constUndefined, onDefined: (ancestor) => nodeOf(ancestor).provided });
|
|
147
|
+
/** `element`'s variant node: made at the first ask (a child's, or its own Mount's), over its latest delivered config. */
|
|
148
|
+
export const nodeOf = (element) => {
|
|
149
|
+
const known = nodes.get(element);
|
|
150
|
+
if (Predicate.isNotUndefined(known))
|
|
151
|
+
return known;
|
|
152
|
+
const node = variantNodeOf(() => configOf(deliveredTo(element)), parentContextOf(element), recheck);
|
|
153
|
+
nodes.set(element, node);
|
|
154
|
+
return node;
|
|
155
|
+
};
|
|
156
|
+
/** Drop `element`'s node at its release: its registration with its ancestor given up. */
|
|
157
|
+
export const dropNode = (element) => {
|
|
158
|
+
const node = nodes.get(element);
|
|
159
|
+
if (Predicate.isUndefined(node))
|
|
160
|
+
return;
|
|
161
|
+
nodes.delete(element);
|
|
162
|
+
node.dispose();
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* The `WardicConfigValue` in effect for `element` (#434, ADR-0062): its own `w.Config` over the nearest
|
|
166
|
+
* ancestor's, over the Handle's `config` (`root`). Each setting is read when an animation starts, so a
|
|
167
|
+
* change moves nothing by itself. An element with no `w.Config` of its own shares its ancestor's.
|
|
168
|
+
*/
|
|
169
|
+
export const configValueOf = (element, root) => {
|
|
170
|
+
const own = () => configOf(deliveredTo(element)).config;
|
|
171
|
+
const parent = UndefinedOr.match(nearestWard(element), { onUndefined: () => root, onDefined: (ancestor) => configValueOf(ancestor, root) });
|
|
172
|
+
if (Predicate.isUndefined(own()))
|
|
173
|
+
return parent;
|
|
174
|
+
const known = values.get(element);
|
|
175
|
+
if (Predicate.isNotUndefined(known))
|
|
176
|
+
return known;
|
|
177
|
+
const value = configValueUnder(own, parent);
|
|
178
|
+
values.set(element, value);
|
|
179
|
+
return value;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* The `WardicConfigValue` of an element whose `w.Config` is `own()`, under `parent`'s (ADR-0062): each
|
|
183
|
+
* setting read when an animation starts, so a change moves nothing by itself. What {@link configValueOf}
|
|
184
|
+
* keeps for a mounted element, and the walk at a Provider element's build carries down a server render
|
|
185
|
+
* (#794, PR 2).
|
|
186
|
+
*/
|
|
187
|
+
export const configValueUnder = (own, parent) => ({
|
|
188
|
+
transition: () => WardicConfigValue.configTransitionOf(UndefinedOr.map(own(), (c) => c.transition), parent),
|
|
189
|
+
reducedMotion: () => WardicConfigValue.configReducedMotionOf(UndefinedOr.map(own(), (c) => c.reducedMotion), parent),
|
|
190
|
+
skipAnimations: () => WardicConfigValue.configSkipAnimationsOf(UndefinedOr.map(own(), (c) => c.skipAnimations), parent),
|
|
191
|
+
isValidProp: () => WardicConfigValue.configIsValidPropOf(undefined, parent),
|
|
192
|
+
// Where a drag's and a pan's points are (#793, Q9): the nearest `transformPagePoint` up the chain.
|
|
193
|
+
transformPagePoint: () => WardicConfigValue.configTransformPagePointOf(UndefinedOr.map(own(), (c) => c.transformPagePoint), parent),
|
|
194
|
+
});
|
|
195
|
+
/** The Handle's app-wide config (`Wardic.make({ config })`), as the root of every element's chain; none without one. */
|
|
196
|
+
export const rootConfigValueOf = (options) => {
|
|
197
|
+
if (Predicate.isUndefined(options))
|
|
198
|
+
return undefined;
|
|
199
|
+
return {
|
|
200
|
+
transition: () => WardicConfigValue.configTransitionOf(options.transition, undefined),
|
|
201
|
+
reducedMotion: () => options.reducedMotion,
|
|
202
|
+
skipAnimations: () => options.skipAnimations,
|
|
203
|
+
isValidProp: constUndefined,
|
|
204
|
+
transformPagePoint: () => options.transformPagePoint,
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
//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,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACpI,CAAC,CAAA;AAEF,wHAAwH;AACxH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAuC,EAAmD,EAAE;IAC5H,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAA;IACpD,OAAO;QACL,UAAU,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC;QACrF,aAAa,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,aAAa;QAC1C,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc;QAC5C,WAAW,EAAE,cAAc;QAC3B,kBAAkB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAkB;KACrD,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An element's place in variant orchestration on Foldkit (ADR-0007, #50; ADR-0071 decisions 17 and
|
|
3
|
+
* 21): Solid's `variant-node.ts` over the `Reactivity` port's getters, with no reactive graph. The
|
|
4
|
+
* rules it runs are core's `unstable/VariantTree`. What Solid keeps in memos is read on each ask here:
|
|
5
|
+
* the names handed down, the orchestration, the stagger; what a Solid effect did at a trigger (the
|
|
6
|
+
* slots marked stale, the names waiting again, `beforeChildren` waiting again) is done on the first
|
|
7
|
+
* read after the trigger key changes, so a child's Retarget in the same patch reads a fresh slot. A
|
|
8
|
+
* settle that changes a gate (`beforeChildren`, `afterChildren`) tells the port's watches to re-check,
|
|
9
|
+
* which is how a held Retarget is released.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import * as AnimationControls from "@wardic/core/unstable/AnimationControls";
|
|
14
|
+
import * as VariantTree from "@wardic/core/unstable/VariantTree";
|
|
15
|
+
import type * as CoreConfig from "@wardic/core/unstable/Config";
|
|
16
|
+
/** An element's place in variant orchestration, on the client. */
|
|
17
|
+
export interface VariantNode {
|
|
18
|
+
/** What its children read: its own context, its parent's passed through, or none. */
|
|
19
|
+
readonly provided: VariantTree.WardicVariantContextValue | undefined;
|
|
20
|
+
/** The context its spine inherits names and its default transition from: its parent's, for a Variant child. */
|
|
21
|
+
readonly inherited: VariantTree.WardicVariantContextValue | undefined;
|
|
22
|
+
/** Its stagger delay in seconds, as a Variant child; `undefined` for any other element. */
|
|
23
|
+
readonly extraDelay: ((name: string | undefined) => number) | undefined;
|
|
24
|
+
/** Whether its spine may start a Retarget: its ancestor's `beforeChildren` and its own `afterChildren` allow it. */
|
|
25
|
+
readonly canStart: () => boolean;
|
|
26
|
+
/** Its spine's settle report on each frame: to its ancestor's registry, and to its own `beforeChildren`. */
|
|
27
|
+
readonly onFrame: (done: boolean) => void;
|
|
28
|
+
/** A list's names orchestrated each on their own (#297's PR 2). Only an element that joins a provider or provides has one. */
|
|
29
|
+
readonly names: VariantTree.NameOrchestration | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Which of its element's gestures are on (#291, #793), read into the names it hands its Variant
|
|
32
|
+
* children: bound by the element's Mount. Nothing for an element with no variants of its own, which
|
|
33
|
+
* hands down what it takes.
|
|
34
|
+
*/
|
|
35
|
+
readonly bindGestures: (states: () => VariantTree.GestureStates) => void;
|
|
36
|
+
/** Its registration with the ancestor it joined, given up: at its element's release. */
|
|
37
|
+
readonly dispose: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* A config as everything of the element reads it (#433; #798, Q4): with **Animation controls** as its
|
|
40
|
+
* first delivery's `animate`, the Controls change in effect as its entry (none before the first start
|
|
41
|
+
* or set, a later delivery's values dropped); else as delivered, controls a later delivery gives
|
|
42
|
+
* stripped. Built once, at the node's making.
|
|
43
|
+
*/
|
|
44
|
+
readonly configured: <C extends Pick<CoreConfig.SpineConfig, "animate">>(config: C) => C;
|
|
45
|
+
/** The Controls change in effect: its own controls', else the one its inherited context is in (core's `controlsChangeOf`), else none. */
|
|
46
|
+
readonly change: () => AnimationControls.ControlsChange | undefined;
|
|
47
|
+
/** A start or set of its own controls: the change made its entry, which the next resolution reads. */
|
|
48
|
+
readonly setChange: (change: AnimationControls.ControlsChange) => void;
|
|
49
|
+
}
|
|
50
|
+
/** A delivered config as the node reads it: the tree's keys, and `animate` as the spine types it, for the controls' forms. */
|
|
51
|
+
type Delivered = VariantTree.VariantConfig & Pick<CoreConfig.SpineConfig, "animate">;
|
|
52
|
+
/**
|
|
53
|
+
* An element's place in variant orchestration on the client, from its delivered config (read on each
|
|
54
|
+
* ask) and the context the nearest Wardic ancestor provides. `notify` re-checks the port's watches.
|
|
55
|
+
* With **Animation controls** as its first delivery's `animate` (#433; #798, Q4), the config everything
|
|
56
|
+
* here reads has the Controls change in effect as its entry, none before the first; the change its
|
|
57
|
+
* children read is its own, else the one its inherited context is in, so a start above reaches a
|
|
58
|
+
* Variant child's own Variant children (core's `controlsChangeOf`, as Solid's node reads it).
|
|
59
|
+
*/
|
|
60
|
+
export declare const variantNodeOf: (delivered: () => Delivered, parent: VariantTree.WardicVariantContextValue | undefined, notify: () => void) => VariantNode;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=variant-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant-node.d.ts","sourceRoot":"","sources":["../../src/internal/variant-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,iBAAiB,MAAM,yCAAyC,CAAA;AAG5E,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAOhE,OAAO,KAAK,KAAK,UAAU,MAAM,8BAA8B,CAAA;AAE/D,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,yBAAyB,GAAG,SAAS,CAAA;IACpE,+GAA+G;IA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+1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An element's place in variant orchestration on Foldkit (ADR-0007, #50; ADR-0071 decisions 17 and
|
|
3
|
+
* 21): Solid's `variant-node.ts` over the `Reactivity` port's getters, with no reactive graph. The
|
|
4
|
+
* rules it runs are core's `unstable/VariantTree`. What Solid keeps in memos is read on each ask here:
|
|
5
|
+
* the names handed down, the orchestration, the stagger; what a Solid effect did at a trigger (the
|
|
6
|
+
* slots marked stale, the names waiting again, `beforeChildren` waiting again) is done on the first
|
|
7
|
+
* read after the trigger key changes, so a child's Retarget in the same patch reads a fresh slot. A
|
|
8
|
+
* settle that changes a gate (`beforeChildren`, `afterChildren`) tells the port's watches to re-check,
|
|
9
|
+
* which is how a held Retarget is released.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import * as AnimationControls from "@wardic/core/unstable/AnimationControls";
|
|
14
|
+
import * as VariantTarget from "@wardic/core/unstable/VariantTarget";
|
|
15
|
+
import * as VariantTree from "@wardic/core/unstable/VariantTree";
|
|
16
|
+
import * as Arr from "effect/Array";
|
|
17
|
+
import * as Bool from "effect/Boolean";
|
|
18
|
+
import { constTrue, constUndefined, constVoid } from "effect/Function";
|
|
19
|
+
import * as MutableRef from "effect/MutableRef";
|
|
20
|
+
import * as Predicate from "effect/Predicate";
|
|
21
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
22
|
+
/** No gesture on: what an element hands down before its Mount binds its gestures. */
|
|
23
|
+
const noGestures = () => VariantTree.NO_GESTURE_STATES;
|
|
24
|
+
/**
|
|
25
|
+
* The registry, stagger and `when` an element with variants of its own runs for its Variant children
|
|
26
|
+
* (ADR-0007), and the names it hands them. `notify` re-checks the port's watches: called when a gate
|
|
27
|
+
* a child waits on changes. `change` is the Controls change in effect (#433): a trigger even to the
|
|
28
|
+
* same name, and its override the children's orchestration while it's the latest.
|
|
29
|
+
*/
|
|
30
|
+
const ownOrchestration = (read, parent, inherited, notify) => {
|
|
31
|
+
const cfg = read.config;
|
|
32
|
+
const change = read.change;
|
|
33
|
+
const config = cfg();
|
|
34
|
+
// Children in mount order (a Set keeps insertion order); the slots are rewritten at each trigger.
|
|
35
|
+
const records = new Set();
|
|
36
|
+
let unsettled = 0;
|
|
37
|
+
// The names of a list whose own keys have settled since the list last changed (#297's PR 2).
|
|
38
|
+
const ownNames = new Set();
|
|
39
|
+
// True once this element's own animation settles; false again at each trigger. Drives `beforeChildren`.
|
|
40
|
+
let ownSettled = false;
|
|
41
|
+
// The names handed down. `animate`'s is read on each ask; `initial`'s is read once.
|
|
42
|
+
const variant = () => {
|
|
43
|
+
const c = cfg();
|
|
44
|
+
return VariantTree.handedDown(c, () => VariantTree.nameOf(c.animate), () => UndefinedOr.map(parent, (p) => p.variant()));
|
|
45
|
+
};
|
|
46
|
+
// What it hands down for its gestures (#291): which of its own are on, bound by its element's Mount (#793), and what it inherits, passed on.
|
|
47
|
+
const ownStates = MutableRef.make(noGestures);
|
|
48
|
+
const gestures = () => VariantTree.handDownOf(cfg(), MutableRef.get(ownStates)(), VariantTree.handDownFrom(inherited));
|
|
49
|
+
const triggerKey = () => VariantTree.triggerKeyOf(variant(), gestures(), change());
|
|
50
|
+
// Snapshot-at-trigger (ADR-0007): each child's index and total are recomputed only when a trigger
|
|
51
|
+
// (this element's variant, or its gestures' names) changes, so a mount, unmount or reorder
|
|
52
|
+
// mid-transition doesn't reshuffle in-flight delays. The change is seen on the first read after it:
|
|
53
|
+
// a child the same patch Retargets reads its slot before anything else of this element's runs.
|
|
54
|
+
let stale = true;
|
|
55
|
+
let lastKey;
|
|
56
|
+
let at;
|
|
57
|
+
const checkTrigger = () => {
|
|
58
|
+
const next = triggerKey();
|
|
59
|
+
if (next === lastKey)
|
|
60
|
+
return;
|
|
61
|
+
lastKey = next;
|
|
62
|
+
at = VariantTree.changeAtTrigger(change(), next, at);
|
|
63
|
+
stale = true;
|
|
64
|
+
// Each name waits again (#297's PR 2): its keys, and its children's, settle anew.
|
|
65
|
+
ownNames.clear();
|
|
66
|
+
records.forEach((record) => record.names.clear());
|
|
67
|
+
// `beforeChildren` waits again at each trigger, until this element's own animation settles.
|
|
68
|
+
ownSettled = false;
|
|
69
|
+
};
|
|
70
|
+
const fresh = () => {
|
|
71
|
+
checkTrigger();
|
|
72
|
+
if (!stale)
|
|
73
|
+
return;
|
|
74
|
+
stale = false;
|
|
75
|
+
const n = records.size;
|
|
76
|
+
let i = 0;
|
|
77
|
+
records.forEach((record) => {
|
|
78
|
+
record.total = n;
|
|
79
|
+
record.index = i;
|
|
80
|
+
i++;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const register = () => {
|
|
84
|
+
const record = { index: 0, total: 1, names: new Set() };
|
|
85
|
+
let settled = false;
|
|
86
|
+
records.add(record);
|
|
87
|
+
unsettled++;
|
|
88
|
+
const setSettled = (done) => {
|
|
89
|
+
if (done === settled)
|
|
90
|
+
return;
|
|
91
|
+
settled = done;
|
|
92
|
+
const before = unsettled;
|
|
93
|
+
unsettled += Bool.match(done, { onTrue: () => -1, onFalse: () => 1 });
|
|
94
|
+
// `afterChildren`'s gate changed: what waits on it re-checks.
|
|
95
|
+
if (before === 0 || unsettled === 0)
|
|
96
|
+
notify();
|
|
97
|
+
};
|
|
98
|
+
const dispose = () => {
|
|
99
|
+
if (!records.delete(record))
|
|
100
|
+
return;
|
|
101
|
+
if (!settled) {
|
|
102
|
+
unsettled--;
|
|
103
|
+
if (unsettled === 0)
|
|
104
|
+
notify();
|
|
105
|
+
}
|
|
106
|
+
stale = true;
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
index: () => {
|
|
110
|
+
fresh();
|
|
111
|
+
return record.index;
|
|
112
|
+
},
|
|
113
|
+
total: () => {
|
|
114
|
+
fresh();
|
|
115
|
+
return record.total;
|
|
116
|
+
},
|
|
117
|
+
setSettled,
|
|
118
|
+
setSettledFor: (name, done) => {
|
|
119
|
+
Bool.match(done, { onTrue: () => record.names.add(name), onFalse: () => record.names.delete(name) });
|
|
120
|
+
},
|
|
121
|
+
dispose,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
// Its orchestration (#277, #291, Motion's): the own transition of its highest active gesture's name,
|
|
125
|
+
// else of its target (the variant it names), else its `transition`.
|
|
126
|
+
const orchestration = () => {
|
|
127
|
+
checkTrigger();
|
|
128
|
+
return VariantTree.orchestrationAt(UndefinedOr.getOrThrow(at), () => {
|
|
129
|
+
const c = cfg();
|
|
130
|
+
const own = UndefinedOr.match(VariantTree.topGestureName(VariantTree.activeNamesOf(gestures())), {
|
|
131
|
+
onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom),
|
|
132
|
+
onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom),
|
|
133
|
+
});
|
|
134
|
+
return VariantTarget.transitionOfTarget(own, c.transition);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const stagger = () => VariantTree.staggerOf(orchestration());
|
|
138
|
+
// A list's names have each their own (#297's PR 2): none for the list as a whole.
|
|
139
|
+
const when = () => {
|
|
140
|
+
if (Arr.isArray(variant()))
|
|
141
|
+
return undefined;
|
|
142
|
+
return UndefinedOr.map(orchestration(), (t) => t.when);
|
|
143
|
+
};
|
|
144
|
+
const initial = VariantTree.handedDown(config, () => VariantTree.initialNameOf(config.initial), () => UndefinedOr.map(parent, (p) => p.initial));
|
|
145
|
+
// Each name's orchestration for the Variant children's keys of that name (#297): its own transition's,
|
|
146
|
+
// else the element's. Kept per name until the config changes.
|
|
147
|
+
let byName = new Map();
|
|
148
|
+
let byNameFor;
|
|
149
|
+
const configOf = (name) => {
|
|
150
|
+
checkTrigger();
|
|
151
|
+
const changed = VariantTree.changeConfigOf(UndefinedOr.getOrThrow(at));
|
|
152
|
+
if (Predicate.isNotUndefined(changed))
|
|
153
|
+
return changed;
|
|
154
|
+
const c = cfg();
|
|
155
|
+
if (c !== byNameFor) {
|
|
156
|
+
byNameFor = c;
|
|
157
|
+
byName = new Map();
|
|
158
|
+
}
|
|
159
|
+
const kept = byName.get(name);
|
|
160
|
+
if (Predicate.isNotUndefined(kept))
|
|
161
|
+
return kept;
|
|
162
|
+
const made = VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom), c.transition));
|
|
163
|
+
byName.set(name, made);
|
|
164
|
+
return made;
|
|
165
|
+
};
|
|
166
|
+
const staggerFor = (name) => {
|
|
167
|
+
if (Predicate.isUndefined(name))
|
|
168
|
+
return stagger();
|
|
169
|
+
return configOf(name).stagger;
|
|
170
|
+
};
|
|
171
|
+
const mayStartFor = (name) => Bool.or(configOf(name).when !== "beforeChildren", ownNames.has(name));
|
|
172
|
+
const canStartFor = (name) => {
|
|
173
|
+
if (configOf(name).when !== "afterChildren")
|
|
174
|
+
return true;
|
|
175
|
+
let all = true;
|
|
176
|
+
records.forEach((record) => {
|
|
177
|
+
if (Bool.not(record.names.has(name)))
|
|
178
|
+
all = false;
|
|
179
|
+
});
|
|
180
|
+
return all;
|
|
181
|
+
};
|
|
182
|
+
const settledFor = (names, done) => Arr.forEach(names, (name) => {
|
|
183
|
+
Bool.match(done, { onTrue: () => ownNames.add(name), onFalse: () => ownNames.delete(name) });
|
|
184
|
+
});
|
|
185
|
+
const childrenMayStart = () => {
|
|
186
|
+
checkTrigger();
|
|
187
|
+
return when() !== "beforeChildren" || ownSettled;
|
|
188
|
+
};
|
|
189
|
+
const allChildrenSettled = () => unsettled === 0;
|
|
190
|
+
// The transition its children default to: its own, else the one it inherits.
|
|
191
|
+
const transition = () => VariantTree.ownOrInherited(cfg().transition, inherited);
|
|
192
|
+
return {
|
|
193
|
+
context: { variant, initial, transition, gestures, register, stagger, staggerFor, mayStartFor, when, childrenMayStart, allChildrenSettled, change },
|
|
194
|
+
// It holds its own start for `afterChildren` (it owns the registry, so it reads it directly).
|
|
195
|
+
canStart: () => when() !== "afterChildren" || allChildrenSettled(),
|
|
196
|
+
settled: (done) => {
|
|
197
|
+
checkTrigger();
|
|
198
|
+
if (done === ownSettled)
|
|
199
|
+
return;
|
|
200
|
+
ownSettled = done;
|
|
201
|
+
// `beforeChildren`'s gate changed: the children waiting on it re-check.
|
|
202
|
+
if (when() === "beforeChildren")
|
|
203
|
+
notify();
|
|
204
|
+
},
|
|
205
|
+
canStartFor,
|
|
206
|
+
settledFor,
|
|
207
|
+
bindGestures: (states) => {
|
|
208
|
+
MutableRef.set(ownStates, states);
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* An element's place in variant orchestration on the client, from its delivered config (read on each
|
|
214
|
+
* ask) and the context the nearest Wardic ancestor provides. `notify` re-checks the port's watches.
|
|
215
|
+
* With **Animation controls** as its first delivery's `animate` (#433; #798, Q4), the config everything
|
|
216
|
+
* here reads has the Controls change in effect as its entry, none before the first; the change its
|
|
217
|
+
* children read is its own, else the one its inherited context is in, so a start above reaches a
|
|
218
|
+
* Variant child's own Variant children (core's `controlsChangeOf`, as Solid's node reads it).
|
|
219
|
+
*/
|
|
220
|
+
export const variantNodeOf = (delivered, parent, notify) => {
|
|
221
|
+
const own = MutableRef.make(undefined);
|
|
222
|
+
const ownChange = () => MutableRef.get(own);
|
|
223
|
+
const controlled = AnimationControls.isAnimationControls(delivered().animate);
|
|
224
|
+
const configured = Bool.match(controlled, {
|
|
225
|
+
onTrue: () => (c) => AnimationControls.controlledConfigOf(c, ownChange()),
|
|
226
|
+
onFalse: () => AnimationControls.uncontrolledOf,
|
|
227
|
+
});
|
|
228
|
+
const config = configured(delivered());
|
|
229
|
+
const inherited = VariantTree.inheritedContext(config, parent);
|
|
230
|
+
const change = VariantTree.controlsChangeOf(Bool.match(controlled, { onTrue: () => ownChange, onFalse: constUndefined }), inherited);
|
|
231
|
+
const read = { config: () => configured(delivered()), change };
|
|
232
|
+
// A Variant child registers with the ancestor it joins, for its stagger slot and its `when`.
|
|
233
|
+
const joined = UndefinedOr.map(inherited, (context) => ({ context, registration: context.register() }));
|
|
234
|
+
const orchestration = Bool.match(VariantTree.hasOwnVariants(config), {
|
|
235
|
+
onFalse: constUndefined,
|
|
236
|
+
onTrue: () => ownOrchestration(read, parent, inherited, notify),
|
|
237
|
+
});
|
|
238
|
+
// The spine reports on every frame (the per-frame path): both reports resolved once, two plain calls a frame.
|
|
239
|
+
const reportJoined = UndefinedOr.match(joined, { onUndefined: () => constVoid, onDefined: ({ registration }) => registration.setSettled });
|
|
240
|
+
const reportOwn = UndefinedOr.match(orchestration, { onUndefined: () => constVoid, onDefined: (o) => o.settled });
|
|
241
|
+
return {
|
|
242
|
+
provided: UndefinedOr.match(orchestration, { onDefined: (o) => o.context, onUndefined: () => VariantTree.passedThrough(config, parent) }),
|
|
243
|
+
inherited,
|
|
244
|
+
extraDelay: UndefinedOr.map(joined, ({ context, registration }) => (name) => {
|
|
245
|
+
const s = VariantTree.staggerOfName(context, name);
|
|
246
|
+
const n = registration.total();
|
|
247
|
+
return VariantTree.childDelayOf(s, registration.index(), n);
|
|
248
|
+
}),
|
|
249
|
+
canStart: () => UndefinedOr.match(inherited, { onUndefined: constTrue, onDefined: (context) => context.childrenMayStart() }) &&
|
|
250
|
+
UndefinedOr.match(orchestration, { onUndefined: constTrue, onDefined: (o) => o.canStart() }),
|
|
251
|
+
onFrame: (done) => {
|
|
252
|
+
reportJoined(done);
|
|
253
|
+
reportOwn(done);
|
|
254
|
+
},
|
|
255
|
+
names: namesOf(joined, orchestration),
|
|
256
|
+
bindGestures: UndefinedOr.match(orchestration, { onUndefined: () => constVoid, onDefined: (o) => o.bindGestures }),
|
|
257
|
+
dispose: UndefinedOr.match(joined, { onUndefined: () => constVoid, onDefined: ({ registration }) => registration.dispose }),
|
|
258
|
+
configured,
|
|
259
|
+
change,
|
|
260
|
+
setChange: (made) => {
|
|
261
|
+
MutableRef.set(own, made);
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
/** Its spine's per-name orchestration (#297's PR 2), as Solid's. None for an element that joins nothing and provides nothing. */
|
|
266
|
+
const namesOf = (joined, own) => {
|
|
267
|
+
if (Bool.and(Predicate.isUndefined(joined), Predicate.isUndefined(own)))
|
|
268
|
+
return undefined;
|
|
269
|
+
const tell = (names, done) => {
|
|
270
|
+
UndefinedOr.map(joined, ({ registration }) => UndefinedOr.map(registration.setSettledFor, (set) => Arr.forEach(names, (name) => set(name, done))));
|
|
271
|
+
UndefinedOr.map(own, (o) => o.settledFor(names, done));
|
|
272
|
+
};
|
|
273
|
+
return {
|
|
274
|
+
mayStart: (name) => Bool.and(UndefinedOr.match(joined, { onUndefined: constTrue, onDefined: ({ context }) => VariantTree.mayStartOf(context, name) }), UndefinedOr.match(own, { onUndefined: constTrue, onDefined: (o) => o.canStartFor(name) })),
|
|
275
|
+
moving: (names) => tell(names, false),
|
|
276
|
+
settled: (names) => tell(names, true),
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=variant-node.js.map
|