@wardic/core 1.3.2 → 1.5.0-next.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/Arc.d.ts +2 -2
- package/dist/Arc.js +1 -1
- package/dist/BaseValue.d.ts +11 -10
- package/dist/BaseValue.d.ts.map +1 -1
- package/dist/BaseValue.js +12 -15
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +15 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +218 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +7 -7
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +17 -16
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +8 -6
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +51 -16
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +1 -1
- package/dist/InputFeed.js +2 -2
- package/dist/InputSource.d.ts +9 -3
- package/dist/InputSource.d.ts.map +1 -1
- package/dist/InputSource.js +2 -2
- package/dist/InputSource.js.map +1 -1
- package/dist/Interpolator.d.ts +2 -2
- package/dist/Interpolator.js +2 -2
- package/dist/InterpolatorRegistry.d.ts +29 -15
- package/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +17 -8
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts +7 -6
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +45 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +7 -4
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +146 -45
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +6 -1
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +8 -19
- package/dist/Projection.d.ts.map +1 -1
- package/dist/Projection.js +3 -19
- package/dist/Projection.js.map +1 -1
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +22 -7
- package/dist/Recognizer.js.map +1 -1
- package/dist/ReducedMotion.d.ts +4 -4
- package/dist/ReducedMotion.js +6 -6
- package/dist/Renderer.d.ts +5 -5
- package/dist/Renderer.js +6 -6
- package/dist/Renderer.js.map +1 -1
- package/dist/Reorder.d.ts +12 -2
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +65 -37
- package/dist/Reorder.js.map +1 -1
- package/dist/ScrollSource.d.ts +1 -1
- package/dist/ScrollSource.d.ts.map +1 -1
- package/dist/Sequence.d.ts +1 -1
- package/dist/SharedSource.d.ts +3 -3
- package/dist/SharedSource.js +5 -5
- package/dist/SharedSource.js.map +1 -1
- package/dist/Spring.d.ts.map +1 -1
- package/dist/Spring.js +2 -1
- package/dist/Spring.js.map +1 -1
- package/dist/Values.d.ts +2 -2
- package/dist/Values.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/carried.d.ts +13 -0
- package/dist/internal/carried.d.ts.map +1 -0
- package/dist/internal/carried.js +23 -0
- package/dist/internal/carried.js.map +1 -0
- package/dist/internal/firstSteps.d.ts +66 -0
- package/dist/internal/firstSteps.d.ts.map +1 -0
- package/dist/internal/firstSteps.js +107 -0
- package/dist/internal/firstSteps.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +1 -1
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +102 -81
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/projectionRest.d.ts +22 -0
- package/dist/internal/projectionRest.d.ts.map +1 -0
- package/dist/internal/projectionRest.js +20 -0
- package/dist/internal/projectionRest.js.map +1 -0
- package/dist/internal/stepper.d.ts +13 -2
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +16 -1
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +37 -38
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +39 -36
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +5 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +19 -19
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +53 -51
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +56 -49
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +2 -2
- package/dist/unstable/FrameEffects.js +2 -2
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +29 -9
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +79 -47
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +31 -27
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js +8 -8
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Projector.d.ts +34 -0
- package/dist/unstable/Projector.d.ts.map +1 -0
- package/dist/unstable/Projector.js +9 -0
- package/dist/unstable/Projector.js.map +1 -0
- package/dist/unstable/Report.d.ts +1 -1
- package/dist/unstable/Report.js +1 -1
- package/dist/unstable/RetargetLegs.d.ts +1 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +9 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +81 -72
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +171 -164
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +7 -7
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +11 -11
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +43 -36
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +34 -34
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +236 -22
- package/src/Clock.ts +18 -17
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +65 -23
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +2 -2
- package/src/InputSource.ts +12 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +47 -17
- package/src/Machine.ts +199 -61
- package/src/Playback.ts +5 -1
- package/src/Projection.ts +10 -28
- package/src/Recognizer.ts +24 -8
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +84 -38
- package/src/ScrollSource.ts +1 -1
- package/src/Sequence.ts +1 -1
- package/src/SharedSource.ts +5 -5
- package/src/Spring.ts +2 -1
- package/src/Values.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internal/carried.ts +22 -0
- package/src/internal/firstSteps.ts +139 -0
- package/src/internal/frameLoop.ts +103 -87
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/projectionRest.ts +31 -0
- package/src/internal/stepper.ts +20 -2
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +59 -56
- package/src/unstable/AppearHandoff.ts +6 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +19 -19
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +92 -82
- package/src/unstable/FrameEffects.ts +2 -2
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +126 -56
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +34 -30
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +1 -1
- package/src/unstable/RetargetLegs.ts +10 -9
- package/src/unstable/Spine.ts +210 -201
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +13 -13
- package/src/unstable/VariantTree.ts +50 -43
- package/src/unstable/WardicConfigValue.ts +13 -13
package/dist/unstable/Spine.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The motion spine's Retarget (ADR-0005), on every binding: what
|
|
3
|
-
* when its target changes. A binding mounts the
|
|
4
|
-
* ({@link resolutionOf}), and calls {@link
|
|
2
|
+
* The motion spine's Retarget (ADR-0005), on every binding: what a Subject does from its mount on
|
|
3
|
+
* when its target changes. A binding mounts the Subject, resolves its Override stack reactively
|
|
4
|
+
* ({@link resolutionOf}), and calls {@link SubjectSpine.retarget} on each change, read where its
|
|
5
5
|
* reactivity doesn't track; everything a Retarget does is here:
|
|
6
6
|
*
|
|
7
7
|
* end the running legs -> carry the keys no entry sets back to their Base values (ADR-0022) ->
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @module
|
|
17
17
|
*/
|
|
18
|
-
// Unstable: ADR-0071, decision 5. #672: solid's `spine.ts`, moved for every binding's
|
|
18
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `spine.ts`, moved for every binding's Subjects to run it
|
|
19
19
|
// from core, Foldkit's among them; with it, the Batch hold's slot (Q14).
|
|
20
20
|
import * as BaseValue from "../BaseValue.js";
|
|
21
21
|
import * as Frame from "../Frame.js";
|
|
@@ -51,7 +51,7 @@ import * as Timelines from "./Timelines.js";
|
|
|
51
51
|
import * as VariantTree from "./VariantTree.js";
|
|
52
52
|
import * as VariantTarget from "./VariantTarget.js";
|
|
53
53
|
export { NO_VARIANT_STATE, resolveTarget, transitionOfTarget } from "./VariantTarget.js";
|
|
54
|
-
/** No exit:
|
|
54
|
+
/** No exit: a Subject outside a presence never resolves one. */
|
|
55
55
|
export const NO_EXIT_CONFIG = { exit: undefined, variants: undefined, custom: undefined, transition: undefined };
|
|
56
56
|
/** A record's place in the variant tree (#290), from its config at setup. */
|
|
57
57
|
export const presenceTreeOf = (c) => ({
|
|
@@ -60,20 +60,20 @@ export const presenceTreeOf = (c) => ({
|
|
|
60
60
|
twin: Predicate.isNotUndefined(c.layoutId),
|
|
61
61
|
});
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* whether it's a twin. With no presence, `set` itself: nothing is made per
|
|
63
|
+
* A Subject's ref that tells its presence it was made (#286, ADR-0048): its `key`, read once, and
|
|
64
|
+
* whether it's a twin. With no presence, `set` itself: nothing is made per Subject.
|
|
65
65
|
*/
|
|
66
66
|
export const madeWith = (presence, set, c) => {
|
|
67
67
|
if (Predicate.isUndefined(presence))
|
|
68
68
|
return set;
|
|
69
69
|
const key = c.key;
|
|
70
70
|
const twin = Predicate.isNotUndefined(c.layoutId);
|
|
71
|
-
return (
|
|
72
|
-
PresenceRecord.presenceMade(presence,
|
|
73
|
-
set(
|
|
71
|
+
return (subject) => {
|
|
72
|
+
PresenceRecord.presenceMade(presence, subject, key, twin);
|
|
73
|
+
set(subject);
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
/**
|
|
76
|
+
/** A Subject's {@link ExitConfig} from its config now. */
|
|
77
77
|
export const exitConfigOf = (c, parent) => ({
|
|
78
78
|
exit: c.exit,
|
|
79
79
|
variants: c.variants,
|
|
@@ -81,9 +81,9 @@ export const exitConfigOf = (c, parent) => ({
|
|
|
81
81
|
transition: VariantTree.ownOrInherited(c.transition, parent),
|
|
82
82
|
});
|
|
83
83
|
/**
|
|
84
|
-
* Resolve
|
|
85
|
-
* given (Motion's: the leaving
|
|
86
|
-
* its own transition, else the
|
|
84
|
+
* Resolve a Subject's exit as it leaves (#277): with its `<AnimatePresence custom>` when that's
|
|
85
|
+
* given (Motion's: the leaving Subject's own props can't change any more), else its own `custom`; on
|
|
86
|
+
* its own transition, else the Subject's.
|
|
87
87
|
*/
|
|
88
88
|
export const exitTargetOf = (config, presenceCustom, state, inherited) => {
|
|
89
89
|
const custom = UndefinedOr.match(presenceCustom, { onUndefined: () => config.custom, onDefined: identity });
|
|
@@ -109,11 +109,11 @@ export const exitTargetOf = (config, presenceCustom, state, inherited) => {
|
|
|
109
109
|
const target = VariantTarget.resolveTarget(entry, config.variants, custom, state);
|
|
110
110
|
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure };
|
|
111
111
|
};
|
|
112
|
-
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `
|
|
113
|
-
const exitGroupsOf = (targets,
|
|
112
|
+
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `wardTransition`. */
|
|
113
|
+
const exitGroupsOf = (targets, wardTransition) => Arr.map(targets, (target, i) => ({
|
|
114
114
|
name: target.name,
|
|
115
115
|
values: Rec.filter(target.values, (_, key) => Bool.not(Arr.some(Arr.drop(targets, i + 1), (later) => Object.hasOwn(later.values, key)))),
|
|
116
|
-
transition: VariantTarget.transitionOfTarget(target.transition,
|
|
116
|
+
transition: VariantTarget.transitionOfTarget(target.transition, wardTransition),
|
|
117
117
|
}));
|
|
118
118
|
/** A config given as a value or as an accessor, as an accessor. A config is always an object, so a function is the accessor. */
|
|
119
119
|
export const accessorOf = (config) => Bool.match(Predicate.isFunction(config), { onTrue: () => config, onFalse: () => () => config });
|
|
@@ -147,10 +147,10 @@ const keysByLayerOf = (t, layers, extraDelay, extra, listed, shut) => {
|
|
|
147
147
|
* The transition `key` animates on in a Retarget: its group's (#277, #297), else the Retarget's one,
|
|
148
148
|
* with no stagger (#448 reads its fields, not its delay).
|
|
149
149
|
*/
|
|
150
|
-
const keyTransitionOf = (resolution, groups, key, transition,
|
|
150
|
+
const keyTransitionOf = (resolution, groups, key, transition, wardTransition) => {
|
|
151
151
|
if (Predicate.isUndefined(groups))
|
|
152
152
|
return transition;
|
|
153
|
-
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition,
|
|
153
|
+
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, wardTransition, undefined, identity);
|
|
154
154
|
};
|
|
155
155
|
/** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
|
|
156
156
|
const velocityOf = (snapshot, key) => {
|
|
@@ -170,13 +170,15 @@ const pickKeys = (t, groups, i) => {
|
|
|
170
170
|
};
|
|
171
171
|
/** A transition's `delay`, 0 without one. */
|
|
172
172
|
export const delayOf = (transition) => UndefinedOr.match(transition, { onUndefined: () => 0, onDefined: ({ delay = 0 }) => delay });
|
|
173
|
-
/** No keys: what a drag moves on a projected
|
|
173
|
+
/** No keys: what a drag moves on a projected Subject, or one with no drag. */
|
|
174
174
|
const NO_KEYS = [];
|
|
175
175
|
/** The keys a drag of `axis` moves directly. Built once, at module load. */
|
|
176
176
|
const dragMovesOf = Match.type().pipe(Match.when("x", () => ["x"]), Match.when("y", () => ["y"]), Match.orElse(() => ["x", "y"]));
|
|
177
177
|
/** Whether a start link's value takes its target's shape: both numbers, or both strings. */
|
|
178
178
|
const isSameKind = (value, like) => Predicate.isNumber(value) === Predicate.isNumber(like);
|
|
179
179
|
/** The keys a drag direct-sets (ADR-0004). */
|
|
180
|
+
// `translateX` and `translateY` are the DOM's own keys since #1002 (ADR-0073, *Amendment (#1002)*, Q6): they
|
|
181
|
+
// stay here, plumbing, as the DOM's aliases of `x` and `y` that a drag holds back too.
|
|
180
182
|
const TRANSLATE_KEYS = new Set(["x", "y", "translateX", "translateY"]);
|
|
181
183
|
const TRANSLATE_KEY_LIST = Arr.fromIterable(TRANSLATE_KEYS);
|
|
182
184
|
/** Whether a value map has any key. */
|
|
@@ -248,7 +250,7 @@ const setsValues = (layer) => {
|
|
|
248
250
|
};
|
|
249
251
|
/** A single entry's name: itself, if a name; `undefined` for a values map. */
|
|
250
252
|
const labelOrUndefined = (entry) => Bool.match(Predicate.isString(entry), { onTrue: () => entry, onFalse: constUndefined });
|
|
251
|
-
/** Each gesture on: the
|
|
253
|
+
/** Each gesture on: the Subject's own, or its provider's too when it has one handing any down. */
|
|
252
254
|
const gesturesOnOf = (active, above) => {
|
|
253
255
|
if (above === VariantTree.NO_HAND_DOWN)
|
|
254
256
|
return active;
|
|
@@ -267,7 +269,7 @@ const activeNamesFor = (c, on, labels) => {
|
|
|
267
269
|
const anyOn = (on) => on.inView || on.focused || on.hovered || on.pressed || on.dragged;
|
|
268
270
|
/**
|
|
269
271
|
* Whether an active entry's name delays its keys otherwise than the first entry's (#297): a Variant
|
|
270
|
-
* child's names each take their own stagger slot. Never for
|
|
272
|
+
* child's names each take their own stagger slot. Never for a Subject that joins none, nor for one
|
|
271
273
|
* entry.
|
|
272
274
|
*/
|
|
273
275
|
const delaysDiffer = (layers, extraDelay, extra) => {
|
|
@@ -275,7 +277,7 @@ const delaysDiffer = (layers, extraDelay, extra) => {
|
|
|
275
277
|
return false;
|
|
276
278
|
return Arr.some(layers, (layer) => Bool.and(layer.active, extraOf(extraDelay, layer) !== extra));
|
|
277
279
|
};
|
|
278
|
-
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other
|
|
280
|
+
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other Subject. */
|
|
279
281
|
const extraOf = (extraDelay, layer) => {
|
|
280
282
|
if (Predicate.isUndefined(extraDelay))
|
|
281
283
|
return 0;
|
|
@@ -285,27 +287,27 @@ const extraOf = (extraDelay, layer) => {
|
|
|
285
287
|
};
|
|
286
288
|
/**
|
|
287
289
|
* The transition a key group runs on (#291, #297): unsplit, the base's (`transition`, its delay
|
|
288
|
-
* folded in); split, its entry's own, else the
|
|
289
|
-
* group carries its returns too, which run on the
|
|
290
|
+
* folded in); split, its entry's own, else the Subject's, at its name's delay. A list's first
|
|
291
|
+
* group carries its returns too, which run on the Subject's transition, as a list's base has no one
|
|
290
292
|
* transition of its own.
|
|
291
293
|
*/
|
|
292
|
-
const groupTransitionOf = (resolution, groups, i, transition,
|
|
294
|
+
const groupTransitionOf = (resolution, groups, i, transition, wardTransition, extraDelay, reuse) => {
|
|
293
295
|
if (Predicate.isUndefined(groups))
|
|
294
296
|
return transition;
|
|
295
297
|
if (Bool.and(i === 0, Bool.not(Arr.isArray(resolution.variant))))
|
|
296
298
|
return transition;
|
|
297
299
|
const layer = resolution.layers[i];
|
|
298
|
-
// A list's returns: the
|
|
300
|
+
// A list's returns: the Subject's, at its whole orchestration's delay.
|
|
299
301
|
if (Predicate.isUndefined(layer))
|
|
300
|
-
return staggeredOf(
|
|
301
|
-
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition,
|
|
302
|
+
return staggeredOf(wardTransition, extraOf(extraDelay, undefined), reuse);
|
|
303
|
+
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition, wardTransition), extraOf(extraDelay, layer), reuse);
|
|
302
304
|
};
|
|
303
305
|
/** No names. */
|
|
304
306
|
const NO_NAMES = [];
|
|
305
307
|
/** No legs. */
|
|
306
308
|
const NO_LEGS = [];
|
|
307
309
|
/**
|
|
308
|
-
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the
|
|
310
|
+
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the Subject
|
|
309
311
|
* unsettled, as it still owes an animation, and land nothing; the Retarget once the gate opens
|
|
310
312
|
* counts them.
|
|
311
313
|
*/
|
|
@@ -320,7 +322,7 @@ const gatedLandingOf = (onFrame) => ({
|
|
|
320
322
|
/** No running legs. */
|
|
321
323
|
export const NO_RUNNING = [];
|
|
322
324
|
/**
|
|
323
|
-
* The waiting Transition ends of
|
|
325
|
+
* The waiting Transition ends of Subject `id` (#508): made at its first end, so a Subject with none,
|
|
324
326
|
* nearly every one, pays nothing for them. `owners` holds the leg drawing each key.
|
|
325
327
|
*/
|
|
326
328
|
const waitingEndsOf = (owners, snapshot, gate, id, recordFrame) => {
|
|
@@ -410,7 +412,7 @@ const waitingEndsOf = (owners, snapshot, gate, id, recordFrame) => {
|
|
|
410
412
|
},
|
|
411
413
|
};
|
|
412
414
|
};
|
|
413
|
-
/** A leg's last frame lands the Transition ends waiting on it (#508);
|
|
415
|
+
/** A leg's last frame lands the Transition ends waiting on it (#508); a Subject with none has nothing to ask. */
|
|
414
416
|
const landEndsOf = (waiting) => {
|
|
415
417
|
if (Predicate.isNotUndefined(waiting))
|
|
416
418
|
waiting.land();
|
|
@@ -419,7 +421,7 @@ const landEndsOf = (waiting) => {
|
|
|
419
421
|
export const NO_VALUES = {};
|
|
420
422
|
/**
|
|
421
423
|
* Whether a change's starts, targets or Keyframes stops hold a Variable value (#542): only then can
|
|
422
|
-
* the
|
|
424
|
+
* the Subject's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
|
|
423
425
|
* built under it. It declines every pair with no `var()` at either end.
|
|
424
426
|
*/
|
|
425
427
|
export const holdsVariable = (variables, from, to, stops) => {
|
|
@@ -445,7 +447,7 @@ const stopsCheckOf = (variables) => {
|
|
|
445
447
|
stopsChecks.set(variables, check);
|
|
446
448
|
return check;
|
|
447
449
|
};
|
|
448
|
-
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto
|
|
450
|
+
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto the Subject's turn. */
|
|
449
451
|
const PATH_ROTATION = "pathRotation";
|
|
450
452
|
/** The turn back at 0, written once no leg draws it (#460). */
|
|
451
453
|
const TURNED_BACK = { [PATH_ROTATION]: 0 };
|
|
@@ -570,7 +572,7 @@ const restOf = (owners, target, axis) => {
|
|
|
570
572
|
/**
|
|
571
573
|
* Where a Path's axes that `target` leaves out rest (#574), read before their legs give them up: a
|
|
572
574
|
* new Path ends them there, so a toss caught mid-air curves back to its line. `undefined` for none:
|
|
573
|
-
* every
|
|
575
|
+
* every Subject's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
|
|
574
576
|
*/
|
|
575
577
|
export const restsOf = (owners, target) => {
|
|
576
578
|
const x = restOf(owners, target, "x");
|
|
@@ -613,7 +615,7 @@ const anyShutOf = (shut) => {
|
|
|
613
615
|
* variant does, unless keys it drives stay running. A list's returns' Live values follow with its
|
|
614
616
|
* returns' group, last; any other's with the first group.
|
|
615
617
|
*/
|
|
616
|
-
const splitLegsOf = (t, from, groups, resolution, listed, transition,
|
|
618
|
+
const splitLegsOf = (t, from, groups, resolution, listed, transition, wardTransition, extraDelay, reuse, reduce, skipped, positionalKeys, defaultTransition, velocities, follow, stops, measured, current, rests, unitScale) => {
|
|
617
619
|
let returnsAt = 0;
|
|
618
620
|
if (listed)
|
|
619
621
|
returnsAt = resolution.layers.length;
|
|
@@ -627,7 +629,7 @@ const splitLegsOf = (t, from, groups, resolution, listed, transition, element, e
|
|
|
627
629
|
let followed;
|
|
628
630
|
if (i === returnsAt)
|
|
629
631
|
followed = follow;
|
|
630
|
-
const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition,
|
|
632
|
+
const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition, wardTransition, extraDelay, reuse), reduce, skipped, positionalKeys, defaultTransition, velocities, followed, stops, measured, current, rests, unitScale);
|
|
631
633
|
Arr.forEach(groupLegs, (built) => {
|
|
632
634
|
legs.push(built);
|
|
633
635
|
tags.push(i);
|
|
@@ -639,7 +641,7 @@ const splitLegsOf = (t, from, groups, resolution, listed, transition, element, e
|
|
|
639
641
|
* A list's names at a Retarget (#297): told settled as the legs of the keys each drives settle, to
|
|
640
642
|
* the binding's callbacks (Solid 1's, PR 1) and to its orchestration (PR 2), told moving now; and each
|
|
641
643
|
* shut name's legs waiting on its gate (PR 2), its keys held where they start, so another name's first
|
|
642
|
-
* commit, which hands the
|
|
644
|
+
* commit, which hands the Subject's style back (ADR-0034), doesn't drop them to their own value.
|
|
643
645
|
*/
|
|
644
646
|
const listingOf = (of) => {
|
|
645
647
|
const { listed, told, byName, resolution, groups, legGroups, legCount, carriedGroups, shut, config } = of;
|
|
@@ -700,7 +702,7 @@ const logsDebugOn = (runtime) => {
|
|
|
700
702
|
return on;
|
|
701
703
|
};
|
|
702
704
|
/**
|
|
703
|
-
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so
|
|
705
|
+
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so a Subject
|
|
704
706
|
* none animates holds no map of its own (#460). Never written: a spine sets keys in a map of its own,
|
|
705
707
|
* and deletes only from one that has some.
|
|
706
708
|
*/
|
|
@@ -779,7 +781,7 @@ const hasKeyframes = (layer) => {
|
|
|
779
781
|
};
|
|
780
782
|
/**
|
|
781
783
|
* Each resolved key's Keyframes (#429): the stops of the entry that drives it, when that entry gives
|
|
782
|
-
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every
|
|
784
|
+
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every Subject's common
|
|
783
785
|
* case.
|
|
784
786
|
*/
|
|
785
787
|
const keyframesNowOf = (layers, resolved) => {
|
|
@@ -893,11 +895,11 @@ const keepsStart = (pairs, key, start, target) => {
|
|
|
893
895
|
const measuringOf = (found, keyframes) => Arr.appendAll(UndefinedOr.match(found, { onUndefined: () => [], onDefined: identity }), UndefinedOr.match(keyframes, { onUndefined: () => [], onDefined: Rec.keys }));
|
|
894
896
|
/**
|
|
895
897
|
* A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
|
|
896
|
-
* end-of-task batch with the values the
|
|
898
|
+
* end-of-task batch with the values the Subject draws now, but a key with Keyframes of more than two
|
|
897
899
|
* stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
|
|
898
|
-
* it couldn't read do, reported on `runtime` with the
|
|
900
|
+
* it couldn't read do, reported on `runtime` with the Subject's `id`.
|
|
899
901
|
*/
|
|
900
|
-
export const measuredOf = (measured,
|
|
902
|
+
export const measuredOf = (measured, subject, keys, from, to, values, many, runtime, id) => {
|
|
901
903
|
const pairs = {};
|
|
902
904
|
Arr.forEach(keys, (key) => {
|
|
903
905
|
if (RetargetLegs.hasManyStops(many, key))
|
|
@@ -911,8 +913,8 @@ export const measuredOf = (measured, element, keys, from, to, values, many, runt
|
|
|
911
913
|
});
|
|
912
914
|
if (Rec.isEmptyRecord(pairs))
|
|
913
915
|
return undefined;
|
|
914
|
-
// Its report made only for pairs asked, not once
|
|
915
|
-
return measured.measure(
|
|
916
|
+
// Its report made only for pairs asked, not once a Subject (#979, row 8): nearly every Retarget asks none.
|
|
917
|
+
return measured.measure(subject, pairs, values, pairsFailedOn("wardic.spine: a Retarget's Measured pairs failed", runtime, { id }));
|
|
916
918
|
};
|
|
917
919
|
/** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
|
|
918
920
|
const pairsFailedOn = (message, runtime, annotations) => (defect) => {
|
|
@@ -1056,15 +1058,15 @@ const nameSettlesOf = (names, resolution, groups, legGroups, legCount, carriedGr
|
|
|
1056
1058
|
* Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
|
|
1057
1059
|
* config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
|
|
1058
1060
|
* the config. A callback that throws is reported at the first of a run of throws, its next clean call
|
|
1059
|
-
* ending the run, and the
|
|
1061
|
+
* ending the run, and the Subject animates on. The Solid 2 binding's config has neither: it hands the
|
|
1060
1062
|
* same facts over as async values.
|
|
1061
1063
|
*/
|
|
1062
1064
|
export const animationCallbacks = (runtime, id) => {
|
|
1063
1065
|
// #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
|
|
1064
|
-
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per
|
|
1066
|
+
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per Subject.
|
|
1065
1067
|
let startFailing = false;
|
|
1066
1068
|
let completeFailing = false;
|
|
1067
|
-
// Per Retarget, per
|
|
1069
|
+
// Per Retarget, per Subject: the callback looked up first, and nothing made without one. Whether it threw,
|
|
1068
1070
|
// reported at a run's first throw (`failing` says one is on).
|
|
1069
1071
|
const tell = (name, callback, definition, failing) => {
|
|
1070
1072
|
try {
|
|
@@ -1112,7 +1114,7 @@ export const animationCallbacks = (runtime, id) => {
|
|
|
1112
1114
|
},
|
|
1113
1115
|
};
|
|
1114
1116
|
};
|
|
1115
|
-
/** The variant name
|
|
1117
|
+
/** The variant name a Subject animates to: its own `animate`'s, else the one its provider hands down. */
|
|
1116
1118
|
const variantOf = (animate, parent) => {
|
|
1117
1119
|
if (Predicate.isNotUndefined(animate))
|
|
1118
1120
|
return VariantTree.nameOf(animate);
|
|
@@ -1138,6 +1140,9 @@ const baseTargetOf = (own, variant, variants, custom, state, initialLink) => {
|
|
|
1138
1140
|
export const resolutionOf = (c, parent, initialLink, active, state, own) => {
|
|
1139
1141
|
// The Controls change in effect (#433): its own controls', else its provider's, read here so a new one Retargets.
|
|
1140
1142
|
const change = changeIn(own, parent);
|
|
1143
|
+
// Each key read once (#460, compose once): a binding's config can be a view that works a key out at
|
|
1144
|
+
// each read, a key several of a ward's parts give merged at each (probe: hooks-first), and this
|
|
1145
|
+
// read `animate` up to four times, and `custom` once for the base and once for each gesture.
|
|
1141
1146
|
const variants = c.variants;
|
|
1142
1147
|
// Base target resolution priority (ADR-0007):
|
|
1143
1148
|
// (1) local `animate` (a Values map or a variant name) — overrides any
|
|
@@ -1147,33 +1152,36 @@ export const resolutionOf = (c, parent, initialLink, active, state, own) => {
|
|
|
1147
1152
|
// sibling's "open"); read parent.variant() here so a parent flip
|
|
1148
1153
|
// recomputes the memo and retargets;
|
|
1149
1154
|
// (3) else the SSR-seeded `initial`.
|
|
1150
|
-
// Per Retarget, per
|
|
1151
|
-
const
|
|
1155
|
+
// Per Retarget, per Subject (#460, compose once): statements.
|
|
1156
|
+
const animate = c.animate;
|
|
1157
|
+
const variant = variantOf(animate, parent);
|
|
1158
|
+
// Read after `animate`, as it was: a key still loading throws at the first of them read.
|
|
1159
|
+
const custom = c.custom;
|
|
1152
1160
|
// A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
|
|
1153
1161
|
// that sets a key drives it. A single name or a values map takes the path below, as before.
|
|
1154
|
-
if (Arr.isArray(
|
|
1155
|
-
const targets = VariantTarget.resolveTargets(variant, variants,
|
|
1162
|
+
if (Arr.isArray(animate) || (Predicate.isUndefined(animate) && Arr.isArray(variant))) {
|
|
1163
|
+
const targets = VariantTarget.resolveTargets(variant, variants, custom, state);
|
|
1156
1164
|
const merged = VariantTarget.mergedOf(targets);
|
|
1157
1165
|
const listLayers = Arr.map(targets, namedLayerOf);
|
|
1158
|
-
return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change);
|
|
1166
|
+
return withGestures(c, variants, custom, parent, listLayers, merged.values, variant, active, merged.transition, state, change);
|
|
1159
1167
|
}
|
|
1160
|
-
// A dynamic variant resolves with this
|
|
1168
|
+
// A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
|
|
1161
1169
|
// Animation controls never reach here: its binding reads them once, each change its entry (#433).
|
|
1162
|
-
const target = baseTargetOf(
|
|
1170
|
+
const target = baseTargetOf(animate, variant, variants, custom, state, initialLink);
|
|
1163
1171
|
const base = target.values;
|
|
1164
1172
|
const baseLayer = layerOf(target, variant);
|
|
1165
1173
|
// A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
|
|
1166
1174
|
// its own `while*`, else the label the provider hands down. With no provider, its own: nothing made.
|
|
1167
1175
|
// The common case: nothing handed down and no gesture on. The base entry alone, and nothing else
|
|
1168
|
-
// made or called, at every
|
|
1176
|
+
// made or called, at every Subject's mount and Retarget.
|
|
1169
1177
|
if (VariantTree.handDownFrom(parent) === VariantTree.NO_HAND_DOWN && !anyOn(active)) {
|
|
1170
1178
|
const alone = [baseLayer];
|
|
1171
1179
|
const { resolved, ends, keyframes } = resolvedOf(alone);
|
|
1172
1180
|
return { resolved, base, dragging: active.dragging, variant, active, transition: target.transition, layers: alone, names: VariantTree.NO_GESTURE_NAMES, layersOn: VariantTree.NO_GESTURE_STATES, ends, keyframes, change };
|
|
1173
1181
|
}
|
|
1174
|
-
return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change);
|
|
1182
|
+
return withGestures(c, variants, custom, parent, [baseLayer], base, variant, active, target.transition, state, change);
|
|
1175
1183
|
};
|
|
1176
|
-
/** The **Controls change** in effect for
|
|
1184
|
+
/** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
|
|
1177
1185
|
const changeIn = (own, parent) => {
|
|
1178
1186
|
if (Predicate.isNotUndefined(own))
|
|
1179
1187
|
return own;
|
|
@@ -1202,10 +1210,9 @@ const overriddenOf = (resolution, override) => {
|
|
|
1202
1210
|
/**
|
|
1203
1211
|
* A resolution from its base entries (one, or one a name of a list, #297) and its gesture layers on
|
|
1204
1212
|
* top (#291), each gesture's an entry a name too: the Override stack resolved, and the names its
|
|
1205
|
-
* active gestures resolved.
|
|
1213
|
+
* active gestures resolved. `variants` and `custom` are `c`'s, read once by the caller.
|
|
1206
1214
|
*/
|
|
1207
|
-
const withGestures = (c, parent, layers, base, variant, active, transition, state, change) => {
|
|
1208
|
-
const variants = c.variants;
|
|
1215
|
+
const withGestures = (c, variants, custom, parent, layers, base, variant, active, transition, state, change) => {
|
|
1209
1216
|
const above = VariantTree.handDownFrom(parent);
|
|
1210
1217
|
if (Bool.and(above === VariantTree.NO_HAND_DOWN, Bool.not(anyOn(active)))) {
|
|
1211
1218
|
const { resolved, ends, keyframes } = resolvedOf(layers);
|
|
@@ -1215,28 +1222,28 @@ const withGestures = (c, parent, layers, base, variant, active, transition, stat
|
|
|
1215
1222
|
const labels = above.names;
|
|
1216
1223
|
// In Motion's priority, lowest first: a literal's fields are evaluated in order.
|
|
1217
1224
|
const layersOn = {
|
|
1218
|
-
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants,
|
|
1219
|
-
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants,
|
|
1220
|
-
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants,
|
|
1221
|
-
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants,
|
|
1225
|
+
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants, custom, state),
|
|
1226
|
+
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants, custom, state),
|
|
1227
|
+
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants, custom, state),
|
|
1228
|
+
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants, custom, state),
|
|
1222
1229
|
// whileDrag sits ABOVE tap (highest priority) — driven by the spring,
|
|
1223
1230
|
// NOT stripped, so e.g. `scale: 1.1` animates while held and returns
|
|
1224
1231
|
// after release.
|
|
1225
|
-
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants,
|
|
1232
|
+
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants, custom, state),
|
|
1226
1233
|
};
|
|
1227
1234
|
const { resolved, ends, keyframes } = resolvedOf(layers);
|
|
1228
1235
|
const names = activeNamesFor(c, on, labels);
|
|
1229
1236
|
return { resolved, base, dragging: active.dragging, variant, active, transition, layers, names, layersOn, ends, keyframes, change };
|
|
1230
1237
|
};
|
|
1231
1238
|
/**
|
|
1232
|
-
*
|
|
1239
|
+
* A Subject's {@link Start}, from its config read once and the context it inherits from. With
|
|
1233
1240
|
* `initial={false}` (its own, inherited, or an `<AnimatePresence initial={false}>`'s first render)
|
|
1234
1241
|
* it starts at its `animate`, and nothing animates at mount (#134).
|
|
1235
1242
|
*/
|
|
1236
1243
|
export const startOf = (config, parent, presenceBlocks, untrack) => {
|
|
1237
1244
|
const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks);
|
|
1238
1245
|
// Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
|
|
1239
|
-
// for
|
|
1246
|
+
// for a Subject with no variants, so its start makes nothing more (bench:solid's mount).
|
|
1240
1247
|
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom);
|
|
1241
1248
|
const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants);
|
|
1242
1249
|
return {
|
|
@@ -1251,25 +1258,25 @@ export const startOf = (config, parent, presenceBlocks, untrack) => {
|
|
|
1251
1258
|
const failedOn = (message) => (runtime) => (failure) => {
|
|
1252
1259
|
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }));
|
|
1253
1260
|
};
|
|
1254
|
-
/** How
|
|
1261
|
+
/** How a Subject's variant that throws is reported, on its runtime. */
|
|
1255
1262
|
const variantFailedOn = failedOn("wardic.ward: a variant failed");
|
|
1256
|
-
/** How an exit whose resolver throws is reported, on `runtime`, each time
|
|
1263
|
+
/** How an exit whose resolver throws is reported, on `runtime`, each time a Subject leaves: its Subject leaves without it (#979). */
|
|
1257
1264
|
export const exitVariantFailedOn = failedOn("wardic.presence: an exit variant failed");
|
|
1258
|
-
/**
|
|
1265
|
+
/** A Subject's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
|
|
1259
1266
|
export const variantFailedOnServer = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER);
|
|
1260
1267
|
/** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
|
|
1261
1268
|
const firstFailureOf = Arr.findFirst((layer) => layer.failure);
|
|
1262
1269
|
/** The first of a resolution's entries' resolvers that threw, and its variant's name (#979). */
|
|
1263
1270
|
export const failureOf = (resolution) => firstFailureOf(resolution.layers);
|
|
1264
|
-
/**
|
|
1265
|
-
// #979 (bench:solid's mount): one plain object
|
|
1271
|
+
/** A Subject's {@link VariantFailures}, none failing yet, reported on `runtime`. */
|
|
1272
|
+
// #979 (bench:solid's mount): one plain object a Subject, read by the functions below, not closures, and
|
|
1266
1273
|
// holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
|
|
1267
|
-
// WeakMap cost Solid 1's mount 6% (the lookup,
|
|
1274
|
+
// WeakMap cost Solid 1's mount 6% (the lookup, a Subject).
|
|
1268
1275
|
export const variantFailuresOf = (runtime) => ({ last: undefined, failing: undefined, delayFailing: false, runtime });
|
|
1269
|
-
/** Where a variant's failure was seen, until each resolves it again: its
|
|
1276
|
+
/** Where a variant's failure was seen, until each resolves it again: its Subject's resolutions, and its orchestration. */
|
|
1270
1277
|
const RESOLVING = 1;
|
|
1271
1278
|
const ORCHESTRATING = 2;
|
|
1272
|
-
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its
|
|
1279
|
+
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its Subject's alone. Each variant, by name,
|
|
1273
1280
|
// is reported as it starts failing and fails until every place that saw it fail resolves it again, so
|
|
1274
1281
|
// a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
|
|
1275
1282
|
// values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
|
|
@@ -1299,8 +1306,8 @@ const resolvedAt = (failing, name, at) => {
|
|
|
1299
1306
|
}
|
|
1300
1307
|
failing.set(name, after);
|
|
1301
1308
|
};
|
|
1302
|
-
/** `next`, else, while it carries a failure, the
|
|
1303
|
-
// Per Retarget, per
|
|
1309
|
+
/** `next`, else, while it carries a failure, the Subject's last good resolution: it keeps its target. */
|
|
1310
|
+
// Per Retarget, per Subject (#460, compose once): statements; nothing done while nothing fails.
|
|
1304
1311
|
export const keptOf = (failures, next) => {
|
|
1305
1312
|
const failure = failureOf(next);
|
|
1306
1313
|
if (Option.isSome(failure)) {
|
|
@@ -1323,7 +1330,7 @@ export const reportStart = (failures, start) => {
|
|
|
1323
1330
|
if (Option.isSome(start.failure))
|
|
1324
1331
|
failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING);
|
|
1325
1332
|
};
|
|
1326
|
-
/** What
|
|
1333
|
+
/** What a Subject's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
|
|
1327
1334
|
export const orchestrationOf = (failures) => (entry, failure) => {
|
|
1328
1335
|
if (Option.isSome(failure)) {
|
|
1329
1336
|
failedAt(failures, failure.value, ORCHESTRATING);
|
|
@@ -1413,9 +1420,9 @@ export const velocitiesNowOf = (snapshot) => {
|
|
|
1413
1420
|
return Rec.map(Rec.filter(snapshot.values, Predicate.isNumber), (_, key) => velocityAt(snapshot, UndefinedOr.match(owners, { onUndefined: constUndefined, onDefined: (map) => map.get(key) }), key, now));
|
|
1414
1421
|
};
|
|
1415
1422
|
/**
|
|
1416
|
-
* The transition a Retarget runs on (#66): the
|
|
1423
|
+
* The transition a Retarget runs on (#66): the Subject's last one when the new one has the same
|
|
1417
1424
|
* fields, so core's decode cache hits when the object is rebuilt with the same values (a staggered
|
|
1418
|
-
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per
|
|
1425
|
+
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per Subject.
|
|
1419
1426
|
*/
|
|
1420
1427
|
export const makeReuse = () => {
|
|
1421
1428
|
let lastTransition;
|
|
@@ -1428,12 +1435,12 @@ export const makeReuse = () => {
|
|
|
1428
1435
|
};
|
|
1429
1436
|
};
|
|
1430
1437
|
/**
|
|
1431
|
-
*
|
|
1438
|
+
* A Subject's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
|
|
1432
1439
|
* fires before any frame still has a `from`, and its `exit` ref, which the ward keeps current. An exit key with no value starts
|
|
1433
1440
|
* from its Base value's start links (ADR-0022), read from the Subject kept at the exit.
|
|
1434
1441
|
*/
|
|
1435
|
-
export const presenceRecordOf = (
|
|
1436
|
-
|
|
1442
|
+
export const presenceRecordOf = (subject, start, exitOf, links, tree, snapshot, reducedMotion, skipAnimations) => ({
|
|
1443
|
+
subject,
|
|
1437
1444
|
snapshot: { current: { ...start.initialValues } },
|
|
1438
1445
|
exitOf,
|
|
1439
1446
|
tree,
|
|
@@ -1442,18 +1449,18 @@ export const presenceRecordOf = (element, start, exitOf, links, tree, snapshot,
|
|
|
1442
1449
|
velocities: () => velocitiesNowOf(snapshot),
|
|
1443
1450
|
// Its own, under its nearest WardicConfig (#434): its exit honours it, not the presence's.
|
|
1444
1451
|
reducedMotion,
|
|
1445
|
-
// Its nearest WardicConfig's (#468): an exit is skipped as its
|
|
1452
|
+
// Its nearest WardicConfig's (#468): an exit is skipped as its Subject's animations are.
|
|
1446
1453
|
skipAnimations,
|
|
1447
1454
|
});
|
|
1448
1455
|
/**
|
|
1449
1456
|
* Merge an emitted frame's value-map into a presence record's snapshot (nothing without one). It
|
|
1450
|
-
* mirrors what the gate accumulates, so an exit departs from the
|
|
1457
|
+
* mirrors what the gate accumulates, so an exit departs from the Subject's actual resting value-map.
|
|
1451
1458
|
*/
|
|
1452
1459
|
export const recordFrameOf = (presence) => (value) => {
|
|
1453
1460
|
if (Predicate.isNotUndefined(presence))
|
|
1454
1461
|
Object.assign(presence.snapshot.current, value);
|
|
1455
1462
|
};
|
|
1456
|
-
/** Tell
|
|
1463
|
+
/** Tell a Subject's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for a Subject with none. */
|
|
1457
1464
|
export const tellStarted = (live, legs) => {
|
|
1458
1465
|
if (Predicate.isUndefined(live))
|
|
1459
1466
|
return;
|
|
@@ -1465,7 +1472,7 @@ let holds;
|
|
|
1465
1472
|
export const memberHoldsNow = () => holds;
|
|
1466
1473
|
/**
|
|
1467
1474
|
* Holds made from now on, through `holds` (`createBatch`, as it's called, gives a Batch's): a Batch's
|
|
1468
|
-
* members can be
|
|
1475
|
+
* members can be Wards' Subjects. The first one given stays.
|
|
1469
1476
|
*/
|
|
1470
1477
|
export const provideMemberHolds = (given) => {
|
|
1471
1478
|
if (Predicate.isNotUndefined(holds))
|
|
@@ -1473,29 +1480,20 @@ export const provideMemberHolds = (given) => {
|
|
|
1473
1480
|
holds = given;
|
|
1474
1481
|
};
|
|
1475
1482
|
/**
|
|
1476
|
-
* Each draggable
|
|
1477
|
-
*
|
|
1483
|
+
* Each draggable Subject's spine's drag hook (#665's PR 4): told `true` as its drag reads where the
|
|
1484
|
+
* Subject rests or writes `x`/`y`, and `false` as it hands them back. A Batch member's takes its
|
|
1478
1485
|
* transform from its Batch then, and gives it back.
|
|
1479
1486
|
*/
|
|
1480
|
-
// Module state (#460, Q7): held weakly by the
|
|
1487
|
+
// Module state (#460, Q7): held weakly by the Subject, so it goes with it.
|
|
1481
1488
|
const DRAG_HOOKS = new WeakMap();
|
|
1482
|
-
/** `
|
|
1483
|
-
export const tellDrag = (
|
|
1484
|
-
UndefinedOr.map(DRAG_HOOKS.get(
|
|
1489
|
+
/** `subject`'s drag hook told `on`, when its spine has one: its binding's drag start and end, and a drag's claim. */
|
|
1490
|
+
export const tellDrag = (subject, on) => {
|
|
1491
|
+
UndefinedOr.map(DRAG_HOOKS.get(subject), (tell) => tell(on));
|
|
1485
1492
|
};
|
|
1486
1493
|
/** Tell `timelineKeys` that each of `values`' keys is taken from its Live value (#240). */
|
|
1487
1494
|
const takeEach = (timelineKeys, values) => {
|
|
1488
1495
|
Arr.forEach(Rec.keys(values), (key) => timelineKeys.taken(key));
|
|
1489
1496
|
};
|
|
1490
|
-
/**
|
|
1491
|
-
* A mounted element's spine: its Retarget, the returns to its Base values, the follower of its
|
|
1492
|
-
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
1493
|
-
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
1494
|
-
* ElementSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
1495
|
-
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
1496
|
-
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
1497
|
-
* fiber Scope interrupts what's left when the provider ends.
|
|
1498
|
-
*/
|
|
1499
1497
|
/** Each runtime's unit scale, read once: a mount reads a WeakMap, not a run of its own. */
|
|
1500
1498
|
// Module state (#460, Q7): held weakly by the runtime, so it goes with it.
|
|
1501
1499
|
const UNIT_SCALES = new WeakMap();
|
|
@@ -1508,8 +1506,17 @@ export const unitScaleOf = (runtime) => {
|
|
|
1508
1506
|
UNIT_SCALES.set(runtime, read);
|
|
1509
1507
|
return read;
|
|
1510
1508
|
};
|
|
1511
|
-
|
|
1512
|
-
|
|
1509
|
+
/**
|
|
1510
|
+
* A mounted Subject's spine: its Retarget, the returns to its Base values, the follower of its
|
|
1511
|
+
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
1512
|
+
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
1513
|
+
* SubjectSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
1514
|
+
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
1515
|
+
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
1516
|
+
* fiber Scope interrupts what's left when the provider ends.
|
|
1517
|
+
*/
|
|
1518
|
+
export const makeSubjectSpine = (options) => {
|
|
1519
|
+
const { animation, byName, canStart, config, defaultTransition, diagnostics, extraDelay, gate, id, links, live, measuredPairs, onFrame, ownValues, parent, positionalKeys, presence, runtime, snapshot, start, styleNow, subject, tag, variableValues } = options;
|
|
1513
1520
|
// The Environment's unit scale (ADR-0069 decision 8, #883): read from the runtime the spine already holds,
|
|
1514
1521
|
// so no binding passes it; 1, Motion's own, unless the Environment's Layers give another.
|
|
1515
1522
|
const unitScale = unitScaleOf(runtime);
|
|
@@ -1518,9 +1525,9 @@ export const makeElementSpine = (options) => {
|
|
|
1518
1525
|
let handoff = options.handoff;
|
|
1519
1526
|
// Its mount tells nothing when it starts at its `animate` (#448): on until its first Retarget.
|
|
1520
1527
|
let quiet = start.quiet;
|
|
1521
|
-
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this
|
|
1528
|
+
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this Subject,
|
|
1522
1529
|
// added to each leg it starts, so a `var()` end blends what it resolves to here.
|
|
1523
|
-
const
|
|
1530
|
+
const subjectRules = [variableValues.values(subject)];
|
|
1524
1531
|
const recordFrame = recordFrameOf(presence);
|
|
1525
1532
|
// Whether its animations are skipped (#468): never, with nothing given.
|
|
1526
1533
|
const skipAnimations = UndefinedOr.match(options.skipAnimations, { onUndefined: () => constFalse, onDefined: identity });
|
|
@@ -1545,16 +1552,16 @@ export const makeElementSpine = (options) => {
|
|
|
1545
1552
|
const timelines = Context.getOrUndefined(services, Timelines.Timelines);
|
|
1546
1553
|
if (Predicate.isUndefined(timelines))
|
|
1547
1554
|
return undefined;
|
|
1548
|
-
timelineKeys = timelines.keysOf({ runtime, gate, id,
|
|
1555
|
+
timelineKeys = timelines.keysOf({ runtime, gate, id, subject, live: routes });
|
|
1549
1556
|
return timelineKeys;
|
|
1550
1557
|
};
|
|
1551
1558
|
// The keys a Retarget drove, each with its last target value (its shape), and the
|
|
1552
1559
|
// ones returning to their Base value until that return settles (ADR-0022). Both are
|
|
1553
1560
|
// the spine's: a Retarget mid-return carries them again, so a return is never
|
|
1554
1561
|
// frozen half-way, and a key that settled has left them, so a Retarget of the same
|
|
1555
|
-
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag
|
|
1562
|
+
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag Subject, the keys
|
|
1556
1563
|
// the drag moves leave the return while it runs, so they stay where it dropped them (C9)
|
|
1557
|
-
// until an entry sets them again; a projected
|
|
1564
|
+
// until an entry sets them again; a projected Subject's drag moves none, its projection
|
|
1558
1565
|
// target does (ADR-0016), and its own translate returns as any key does (#363).
|
|
1559
1566
|
const driven = new Map();
|
|
1560
1567
|
let returning = new Map();
|
|
@@ -1566,7 +1573,7 @@ export const makeElementSpine = (options) => {
|
|
|
1566
1573
|
return UndefinedOr.match(options.dragAxis, { onUndefined: () => NO_KEYS, onDefined: dragMovesOf });
|
|
1567
1574
|
};
|
|
1568
1575
|
// A Retarget's returns have settled (ADR-0022, D4). A key back at its `style` value is
|
|
1569
|
-
// handed back to the
|
|
1576
|
+
// handed back to the Subject's style, so a later style change shows at rest and the
|
|
1570
1577
|
// next gesture starts from it; any other key rests at its Base value where the gate drew
|
|
1571
1578
|
// it, and leaves the target. A key a later Retarget took over is left alone. A routed key (#130) stays
|
|
1572
1579
|
// in the gate, handed to the follower, which writes its value from now on.
|
|
@@ -1584,7 +1591,7 @@ export const makeElementSpine = (options) => {
|
|
|
1584
1591
|
const handedBack = Arr.filter(toStyle, Predicate.not(routedNow));
|
|
1585
1592
|
if (Arr.isReadonlyArrayEmpty(handedBack))
|
|
1586
1593
|
return;
|
|
1587
|
-
// The gate writes the user's current value back, as the
|
|
1594
|
+
// The gate writes the user's current value back, as the Subject's `style` would
|
|
1588
1595
|
// (ADR-0034). A key gone from the user's style by now is cleared, not restored stale.
|
|
1589
1596
|
const restore = UndefinedOr.map(styleNow, (now) => {
|
|
1590
1597
|
const style = now();
|
|
@@ -1608,7 +1615,7 @@ export const makeElementSpine = (options) => {
|
|
|
1608
1615
|
// The keys an Imperative animation took (#433), each with the target the Override stack had for it
|
|
1609
1616
|
// then: a Retarget leaves each where the animation leaves it while its target is still that one, and
|
|
1610
1617
|
// takes it back once it isn't, as a newer animation of Motion's value takes it (latest-wins).
|
|
1611
|
-
// Every
|
|
1618
|
+
// Every Subject reads it, nearly none sets it (#460): the shared empty one until the first key taken.
|
|
1612
1619
|
let taken = NONE_TAKEN;
|
|
1613
1620
|
// The legs that gave up a key in this Retarget: what each still draws is worked out at its end.
|
|
1614
1621
|
const losing = [];
|
|
@@ -1649,7 +1656,7 @@ export const makeElementSpine = (options) => {
|
|
|
1649
1656
|
leaveChange();
|
|
1650
1657
|
});
|
|
1651
1658
|
};
|
|
1652
|
-
// The
|
|
1659
|
+
// The Subject's waiting Transition ends (#508), made at its first: most Subjects never have one.
|
|
1653
1660
|
let waiting;
|
|
1654
1661
|
// A leg with no key left ends. Its fiber ends inline (ADR-0027, *Amendment (#200)*); one its token
|
|
1655
1662
|
// didn't reach, none of its runs on the loop, is interrupted. A Transition end it is (#508) is
|
|
@@ -1730,7 +1737,7 @@ export const makeElementSpine = (options) => {
|
|
|
1730
1737
|
giveUp(key, owner);
|
|
1731
1738
|
};
|
|
1732
1739
|
// A Path's turn goes back to 0 once no leg draws it (#460, ADR-0065 decision 3): after a Retarget
|
|
1733
|
-
// whose legs don't turn, a stop, a cancel. Most
|
|
1740
|
+
// whose legs don't turn, a stop, a cancel. Most Subjects never turn: a guard.
|
|
1734
1741
|
const turnBack = () => {
|
|
1735
1742
|
const turn = snapshot.values[PATH_ROTATION];
|
|
1736
1743
|
if (Bool.or(Predicate.isUndefined(turn), turn === 0))
|
|
@@ -1790,7 +1797,7 @@ export const makeElementSpine = (options) => {
|
|
|
1790
1797
|
});
|
|
1791
1798
|
/**
|
|
1792
1799
|
* A leg's run into its sink: one dispatcher, each sink built for the leg that needs it, a
|
|
1793
|
-
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the
|
|
1800
|
+
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the Subject's
|
|
1794
1801
|
* Key rules when its change holds a Variable value (`variables`, #542).
|
|
1795
1802
|
*/
|
|
1796
1803
|
const legProgram = (leg, running, variables) => {
|
|
@@ -1819,7 +1826,7 @@ export const makeElementSpine = (options) => {
|
|
|
1819
1826
|
// rather than replacing it, so the drag's direct-set x/y survive alongside the
|
|
1820
1827
|
// spring's keys (drag owns x/y, spring owns the rest) and the post-drag
|
|
1821
1828
|
// handoff continues from the rested position. Only the keys it still draws (#325).
|
|
1822
|
-
// In place, as the Follow sink writes (#659): a spread made two records per
|
|
1829
|
+
// In place, as the Follow sink writes (#659): a spread made two records per Subject per
|
|
1823
1830
|
// frame. The Snapshot's records are always its own (`snapshotOf`, `emptySnapshotOf`), and
|
|
1824
1831
|
// whatever keeps one copies it or reads it at once.
|
|
1825
1832
|
const value = running.values(frame.value);
|
|
@@ -1841,7 +1848,7 @@ export const makeElementSpine = (options) => {
|
|
|
1841
1848
|
}, running));
|
|
1842
1849
|
}
|
|
1843
1850
|
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
|
|
1844
|
-
// (#659; #895: a spread made a record per
|
|
1851
|
+
// (#659; #895: a spread made a record per Subject per frame). A blend's last two are kept for its keys'
|
|
1845
1852
|
// velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
|
|
1846
1853
|
const sink = (frame, dt) => {
|
|
1847
1854
|
const value = running.values(frame.value);
|
|
@@ -1864,7 +1871,7 @@ export const makeElementSpine = (options) => {
|
|
|
1864
1871
|
// Per leg (#460): a statement, Effect's calls data-first.
|
|
1865
1872
|
let built = Effect.suspend(leg.machine);
|
|
1866
1873
|
if (variables)
|
|
1867
|
-
built = InterpolatorRegistry.withKeyRules(built,
|
|
1874
|
+
built = InterpolatorRegistry.withKeyRules(built, subjectRules);
|
|
1868
1875
|
return Effect.flatMap(built, (machine) => Machine.run(machine, sink, running));
|
|
1869
1876
|
};
|
|
1870
1877
|
// A leg's end, told its landing: a Retarget's legs' and an Imperative animation's (#433).
|
|
@@ -1874,7 +1881,7 @@ export const makeElementSpine = (options) => {
|
|
|
1874
1881
|
// Per leg (#460): statements.
|
|
1875
1882
|
if (Exit.isSuccess(exit)) {
|
|
1876
1883
|
// A Superseded leg (#200) counts toward nothing, nor tells a name: the next Retarget's legs
|
|
1877
|
-
// land. Nothing made for it: a Retarget ends its
|
|
1884
|
+
// land. Nothing made for it: a Retarget ends its Subject's legs inline.
|
|
1878
1885
|
const end = exit.value;
|
|
1879
1886
|
if (Supersede.isSuperseded(end))
|
|
1880
1887
|
return Effect.void;
|
|
@@ -1895,7 +1902,7 @@ export const makeElementSpine = (options) => {
|
|
|
1895
1902
|
})));
|
|
1896
1903
|
};
|
|
1897
1904
|
// A gated Retarget (ADR-0007 `when`, #325): a running key it resolves to its leg's target runs on,
|
|
1898
|
-
// the
|
|
1905
|
+
// the Subject reported unsettled meanwhile, when an earlier change started that leg; every other
|
|
1899
1906
|
// running key freezes where it is. The change the gate holds may have started legs just before
|
|
1900
1907
|
// it shut (a child Retargets before its provider's effect resets its `beforeChildren` wait; an
|
|
1901
1908
|
// `afterChildren` provider starts before its children report): those freeze too, as before.
|
|
@@ -1983,7 +1990,7 @@ export const makeElementSpine = (options) => {
|
|
|
1983
1990
|
keepTheRest,
|
|
1984
1991
|
reducedMotion: options.reducedMotion,
|
|
1985
1992
|
skipAnimations,
|
|
1986
|
-
|
|
1993
|
+
subject,
|
|
1987
1994
|
positionalKeys,
|
|
1988
1995
|
defaultTransition,
|
|
1989
1996
|
unitScale,
|
|
@@ -1999,16 +2006,16 @@ export const makeElementSpine = (options) => {
|
|
|
1999
2006
|
id,
|
|
2000
2007
|
recordFrame,
|
|
2001
2008
|
runtime,
|
|
2002
|
-
|
|
2009
|
+
subjectRules,
|
|
2003
2010
|
measuredPairs,
|
|
2004
2011
|
variableValues,
|
|
2005
2012
|
};
|
|
2006
2013
|
}
|
|
2007
2014
|
return handedOver;
|
|
2008
2015
|
};
|
|
2009
|
-
// --- A Batch member's
|
|
2010
|
-
// Its hold on what it takes from its Batch: made as its
|
|
2011
|
-
// Retarget or a drag. Nearly no
|
|
2016
|
+
// --- A Batch member's Subject (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
|
|
2017
|
+
// Its hold on what it takes from its Batch: made as its Subject is first found a member's, at a
|
|
2018
|
+
// Retarget or a drag. Nearly no Subject is one: the rest pay a WeakMap read a Retarget.
|
|
2012
2019
|
let memberHold;
|
|
2013
2020
|
const holdNow = () => {
|
|
2014
2021
|
if (Predicate.isNotUndefined(memberHold))
|
|
@@ -2017,21 +2024,21 @@ export const makeElementSpine = (options) => {
|
|
|
2017
2024
|
const holds = memberHoldsNow();
|
|
2018
2025
|
if (Predicate.isUndefined(holds))
|
|
2019
2026
|
return undefined;
|
|
2020
|
-
if (!holds.isMember(
|
|
2027
|
+
if (!holds.isMember(subject))
|
|
2021
2028
|
return undefined;
|
|
2022
2029
|
memberHold = holds.make(host());
|
|
2023
2030
|
return memberHold;
|
|
2024
2031
|
};
|
|
2025
|
-
// A draggable
|
|
2032
|
+
// A draggable Subject's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
|
|
2026
2033
|
if (Predicate.isNotUndefined(options.dragAxis)) {
|
|
2027
|
-
DRAG_HOOKS.set(
|
|
2034
|
+
DRAG_HOOKS.set(subject, (on) => {
|
|
2028
2035
|
const member = holdNow();
|
|
2029
2036
|
if (Predicate.isNotUndefined(member))
|
|
2030
2037
|
member.drag(on);
|
|
2031
2038
|
});
|
|
2032
2039
|
}
|
|
2033
2040
|
const retarget = (given) => {
|
|
2034
|
-
// A Controls change (#433): the
|
|
2041
|
+
// A Controls change (#433): the Subject is in it from the Retarget it makes it run, held or not.
|
|
2035
2042
|
if (given.change !== joined)
|
|
2036
2043
|
joinChange(given.change);
|
|
2037
2044
|
// A key an entry sets isn't its Live value's from this Retarget on, held or not: its Timeline value
|
|
@@ -2039,7 +2046,7 @@ export const makeElementSpine = (options) => {
|
|
|
2039
2046
|
if (Predicate.isNotUndefined(timelineKeys))
|
|
2040
2047
|
takeEach(timelineKeys, given.resolved);
|
|
2041
2048
|
// `when` start-gate (ADR-0007): when canStart() is false, the keys whose target changed freeze
|
|
2042
|
-
// where they are (#325: the rest run on), and the
|
|
2049
|
+
// where they are (#325: the rest run on), and the Subject waits; the binding retargets once
|
|
2043
2050
|
// the gate flips true.
|
|
2044
2051
|
if (Predicate.isNotUndefined(canStart) && !canStart()) {
|
|
2045
2052
|
hold(given);
|
|
@@ -2097,7 +2104,7 @@ export const makeElementSpine = (options) => {
|
|
|
2097
2104
|
Arr.forEach(dragMoves(), (key) => keys.taken(key));
|
|
2098
2105
|
}
|
|
2099
2106
|
returning = new Map();
|
|
2100
|
-
// Over the Map itself: copying it into an array first costs ~20 times the walk, per
|
|
2107
|
+
// Over the Map itself: copying it into an array first costs ~20 times the walk, per Subject
|
|
2101
2108
|
// per Retarget (#69's PR 4). Deleting the entry being visited is safe in a Map's iteration.
|
|
2102
2109
|
Iter.forEach(driven, ([key, like]) => {
|
|
2103
2110
|
// A translate key the strip below holds back returns once the drag lets go.
|
|
@@ -2126,13 +2133,13 @@ export const makeElementSpine = (options) => {
|
|
|
2126
2133
|
Iter.forEach(taken, ([key]) => {
|
|
2127
2134
|
delete t[key];
|
|
2128
2135
|
});
|
|
2129
|
-
// A Batch member's
|
|
2136
|
+
// A Batch member's Subject (#665's PR 4, Q53): a group it moves is taken from its Batch first, and a
|
|
2130
2137
|
// key it'd leave where the Batch draws it stays the Batch's. A drag takes `x` and `y`.
|
|
2131
2138
|
const member = holdNow();
|
|
2132
2139
|
if (Predicate.isNotUndefined(member))
|
|
2133
2140
|
member.retarget(t, held);
|
|
2134
2141
|
// The keys this Retarget returns; once it lands, a key back at its `style` value is
|
|
2135
|
-
// handed back to the
|
|
2142
|
+
// handed back to the Subject's style (D4) and the rest rest where the gate drew them.
|
|
2136
2143
|
const returns = [...returning];
|
|
2137
2144
|
// The transition, read at Retarget time so a change applies to the next Retarget. A child
|
|
2138
2145
|
// with no local transition inherits the parent context's (ADR-0007).
|
|
@@ -2155,7 +2162,7 @@ export const makeElementSpine = (options) => {
|
|
|
2155
2162
|
return;
|
|
2156
2163
|
settleReturns(returns);
|
|
2157
2164
|
// The Retarget settled with its last leg (#257): told once the gate has flushed its last frame,
|
|
2158
|
-
// so the
|
|
2165
|
+
// so the Subject shows where it landed. Its Controls change hears it then too (#433).
|
|
2159
2166
|
if (Predicate.isNotUndefined(animation))
|
|
2160
2167
|
gate.afterFlush(() => animation.settled(resolution, previous, c));
|
|
2161
2168
|
leaveAfterFlush();
|
|
@@ -2184,7 +2191,7 @@ export const makeElementSpine = (options) => {
|
|
|
2184
2191
|
return tellFailed(error);
|
|
2185
2192
|
failedEarly = { error };
|
|
2186
2193
|
};
|
|
2187
|
-
// The
|
|
2194
|
+
// The Subject settles with its last leg (ADR-0024, D5): a string leg can outlast the
|
|
2188
2195
|
// numeric one, so each leg's frames report, and only the last leg's settle reports done.
|
|
2189
2196
|
let reporting = 0;
|
|
2190
2197
|
let settled = 0;
|
|
@@ -2198,9 +2205,9 @@ export const makeElementSpine = (options) => {
|
|
|
2198
2205
|
current = landing;
|
|
2199
2206
|
// The Retarget's transitions, read before its keys: a key already there asks its own for a
|
|
2200
2207
|
// velocity (#448).
|
|
2201
|
-
const
|
|
2208
|
+
const wardTransition = VariantTree.ownOrInherited(c.transition, parent);
|
|
2202
2209
|
// The base target's own transition (#277): the keys its entry drives animate on it.
|
|
2203
|
-
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition,
|
|
2210
|
+
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, wardTransition);
|
|
2204
2211
|
// Fold the per-child stagger delay (ADR-0007) into the effective
|
|
2205
2212
|
// transition.delay = base.delay + computedDelay. extraDelay() is read
|
|
2206
2213
|
// at Retarget time so a re-snapshot before this start is reflected. Each name's keys take that
|
|
@@ -2209,11 +2216,11 @@ export const makeElementSpine = (options) => {
|
|
|
2209
2216
|
const extra = extraOf(extraDelay, layers[0]);
|
|
2210
2217
|
const transition = staggeredOf(baseTransition, extra, options.reuse);
|
|
2211
2218
|
// With an entry's own transition (#277, #291), each key animates on its entry's: the base's keys
|
|
2212
|
-
// on the base target's, each active gesture's on its target's, else the
|
|
2219
|
+
// on the base target's, each active gesture's on its target's, else the Subject's, as Motion's
|
|
2213
2220
|
// each animation type runs on its own.
|
|
2214
2221
|
// A list's names (#297) split them too, each name's at its own delay; a list's returns run on the
|
|
2215
|
-
//
|
|
2216
|
-
// Guards, not matches: per Retarget, per
|
|
2222
|
+
// Subject's transition, in a group of their own, last.
|
|
2223
|
+
// Guards, not matches: per Retarget, per Subject. A list's work (#297) is done apart, for a list:
|
|
2217
2224
|
// the Retarget's other calls keep their inlining (docs/agents/effect-first.md).
|
|
2218
2225
|
const listed = Arr.isArray(resolution.variant);
|
|
2219
2226
|
// A list's names each wait for their own `when` (#297's PR 2): the entries whose gate is shut now.
|
|
@@ -2231,7 +2238,7 @@ export const makeElementSpine = (options) => {
|
|
|
2231
2238
|
// target (no motion).
|
|
2232
2239
|
//
|
|
2233
2240
|
// Every key's Own value is read first, at its first need, before anything writes it, so a return
|
|
2234
|
-
// later finds the
|
|
2241
|
+
// later finds the Subject's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
|
|
2235
2242
|
// a lookup. A transform key reads nothing.
|
|
2236
2243
|
let stays;
|
|
2237
2244
|
let carried;
|
|
@@ -2296,7 +2303,7 @@ export const makeElementSpine = (options) => {
|
|
|
2296
2303
|
// Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
|
|
2297
2304
|
// mount's never asks (#475): Motion animates nothing at a first render that starts at its
|
|
2298
2305
|
// `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
|
|
2299
|
-
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition,
|
|
2306
|
+
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, wardTransition), key))) {
|
|
2300
2307
|
if (Predicate.isUndefined(stays))
|
|
2301
2308
|
stays = new Set();
|
|
2302
2309
|
stays.add(key);
|
|
@@ -2321,7 +2328,7 @@ export const makeElementSpine = (options) => {
|
|
|
2321
2328
|
owners.forEach(giveUpUnresolved);
|
|
2322
2329
|
keepTheRest();
|
|
2323
2330
|
// A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
|
|
2324
|
-
// the resolved target doesn't name joins the keys already there, written with them as the
|
|
2331
|
+
// the resolved target doesn't name joins the keys already there, written with them as the Subject's first
|
|
2325
2332
|
// commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
|
|
2326
2333
|
// any. A Batch member's are its Batch's, which draws its groups.
|
|
2327
2334
|
if (Predicate.isUndefined(lastResolution)) {
|
|
@@ -2402,7 +2409,7 @@ export const makeElementSpine = (options) => {
|
|
|
2402
2409
|
// The legs (#48, ADR-0044 decision 8): one pure builder, which a server render's Appear
|
|
2403
2410
|
// animation samples too, so the two can't drift. Built here; each leg's machine is built
|
|
2404
2411
|
// in its own fiber, so a transition core rejects (#66, ADR-0025 *Amendment (#66)*) fails
|
|
2405
|
-
// that leg alone, reported as any leg's failure is, while the
|
|
2412
|
+
// that leg alone, reported as any leg's failure is, while the Subject's other legs run on.
|
|
2406
2413
|
// The returns to a moving Live value (#130, ADR-0043 decision 6): a number's follows it,
|
|
2407
2414
|
// in a leg of its own, and lands on it; the rest return to where it is now. Looked for
|
|
2408
2415
|
// only when this Retarget returns a key.
|
|
@@ -2417,7 +2424,7 @@ export const makeElementSpine = (options) => {
|
|
|
2417
2424
|
// animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
|
|
2418
2425
|
let measured;
|
|
2419
2426
|
if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
|
|
2420
|
-
measured = measuredOf(measuredPairs,
|
|
2427
|
+
measured = measuredOf(measuredPairs, subject, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id);
|
|
2421
2428
|
}
|
|
2422
2429
|
let told;
|
|
2423
2430
|
if (!silent)
|
|
@@ -2432,7 +2439,7 @@ export const makeElementSpine = (options) => {
|
|
|
2432
2439
|
retargetLegs = RetargetLegs.legsOf(from, fresh, transition, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale);
|
|
2433
2440
|
}
|
|
2434
2441
|
if (Predicate.isNotUndefined(groups)) {
|
|
2435
|
-
const split = splitLegsOf(fresh, from, groups, resolution, listed, transition,
|
|
2442
|
+
const split = splitLegsOf(fresh, from, groups, resolution, listed, transition, wardTransition, extraDelay, options.reuse, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale);
|
|
2436
2443
|
retargetLegs = split.legs;
|
|
2437
2444
|
legGroups = split.tags;
|
|
2438
2445
|
}
|
|
@@ -2484,9 +2491,9 @@ export const makeElementSpine = (options) => {
|
|
|
2484
2491
|
}
|
|
2485
2492
|
// Its Live routes hear the legs it starts (#443, PR4-Q1).
|
|
2486
2493
|
tellStarted(live, retargetLegs);
|
|
2487
|
-
// The
|
|
2494
|
+
// The Subject's Key rules only for a change a Variable value is in (#542).
|
|
2488
2495
|
const variables = holdsVariable(variableValues, from, fresh, manyStops);
|
|
2489
|
-
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per
|
|
2496
|
+
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per Subject). Each
|
|
2490
2497
|
// leg draws the keys it animates (#325) until a later Retarget takes them.
|
|
2491
2498
|
Arr.forEach(retargetLegs, (leg, i) => {
|
|
2492
2499
|
if (Predicate.isNotUndefined(legGates))
|
|
@@ -2554,7 +2561,7 @@ export const makeElementSpine = (options) => {
|
|
|
2554
2561
|
// A turn none of its legs draws now goes back (#460).
|
|
2555
2562
|
turnBack();
|
|
2556
2563
|
// The keys already there (#448), written with each key the Retarget moves at where it starts, as
|
|
2557
|
-
// its leg's first frame writes it: the
|
|
2564
|
+
// its leg's first frame writes it: the Subject's first commit, which takes its Starting style off,
|
|
2558
2565
|
// holds every key, whatever frame the legs first draw in (a gated name's draws later).
|
|
2559
2566
|
if (Predicate.isNotUndefined(there)) {
|
|
2560
2567
|
const written = { ...from, ...there };
|
|
@@ -2562,7 +2569,7 @@ export const makeElementSpine = (options) => {
|
|
|
2562
2569
|
recordFrame(written);
|
|
2563
2570
|
}
|
|
2564
2571
|
// The Retarget started, its legs on their way (#257); with none, its own or carried, it landed
|
|
2565
|
-
// at once (#325): its returns settle, and the
|
|
2572
|
+
// at once (#325): its returns settle, and the Subject reports settled at the gate's next flush,
|
|
2566
2573
|
// after the effects that start its orchestration's wait (ADR-0007).
|
|
2567
2574
|
previous = lastResolution;
|
|
2568
2575
|
lastResolution = resolution;
|
|
@@ -2596,7 +2603,7 @@ export const makeElementSpine = (options) => {
|
|
|
2596
2603
|
};
|
|
2597
2604
|
// --- Live values in `style` (#130, ADR-0043) ------------------------------
|
|
2598
2605
|
// A routed key (a Live value, or a transform key) is its `style` link, live: while no entry of
|
|
2599
|
-
// the Override stack sets it, no return is running to it and no drag moves it, the
|
|
2606
|
+
// the Override stack sets it, no return is running to it and no drag moves it, the Subject
|
|
2600
2607
|
// follows it, written through the gate on every change. A return hands it back here when it
|
|
2601
2608
|
// settles (`settleReturns`). The Starting style showed each one's value at render; from mount
|
|
2602
2609
|
// the gate holds them.
|
|
@@ -2604,7 +2611,7 @@ export const makeElementSpine = (options) => {
|
|
|
2604
2611
|
if (Predicate.isUndefined(live))
|
|
2605
2612
|
return;
|
|
2606
2613
|
const routes = live;
|
|
2607
|
-
// Built at the first routed key, at mount or later:
|
|
2614
|
+
// Built at the first routed key, at mount or later: a Subject whose `style` routes none builds nothing.
|
|
2608
2615
|
routes.whenRouted(() => {
|
|
2609
2616
|
// Read at each ask: `projected` is a getter while the track waits for `drag` (#551, #582).
|
|
2610
2617
|
const dragHolds = () => Bool.and(Bool.not(options.projected), Predicate.isNotUndefined(options.dragAxis));
|
|
@@ -2626,7 +2633,7 @@ export const makeElementSpine = (options) => {
|
|
|
2626
2633
|
gate.write(id, values);
|
|
2627
2634
|
recordFrame(values);
|
|
2628
2635
|
};
|
|
2629
|
-
// The
|
|
2636
|
+
// The Subject shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
|
|
2630
2637
|
const shown = (key) => {
|
|
2631
2638
|
const keys = timelineKeysNow(routes);
|
|
2632
2639
|
if (Predicate.isNotUndefined(keys))
|
|
@@ -2664,7 +2671,7 @@ export const makeElementSpine = (options) => {
|
|
|
2664
2671
|
delete snapshot.velocities[key];
|
|
2665
2672
|
if (Predicate.isNotUndefined(presence))
|
|
2666
2673
|
delete presence.snapshot.current[key];
|
|
2667
|
-
// Gone from `style`: the
|
|
2674
|
+
// Gone from `style`: the Subject's own value comes back, or none, its Environment's default now.
|
|
2668
2675
|
const restore = Option.match(ownValues.styleValueOf(UndefinedOr.match(styleNow, { onUndefined: constUndefined, onDefined: (style) => style() }), key), {
|
|
2669
2676
|
onNone: () => "",
|
|
2670
2677
|
onSome: String,
|
|
@@ -2698,8 +2705,8 @@ export const makeElementSpine = (options) => {
|
|
|
2698
2705
|
memberHold.dispose();
|
|
2699
2706
|
};
|
|
2700
2707
|
// A child back under its key (#286): its values and velocities from where the leaver is drawn, a
|
|
2701
|
-
// projected
|
|
2702
|
-
//
|
|
2708
|
+
// projected Subject's own translate among them (#363). Drawn at the end of the task, so nothing
|
|
2709
|
+
// draws the Subject at its `initial` first: not in the mount effect it's called in, where the
|
|
2703
2710
|
// first commit's Starting-style switch would flush Solid 2 inside an effect.
|
|
2704
2711
|
const seed = (from) => {
|
|
2705
2712
|
const values = from.values;
|
|
@@ -2736,7 +2743,7 @@ export const makeElementSpine = (options) => {
|
|
|
2736
2743
|
* one at mount; `sink` as it is otherwise. `config` reads it untracked.
|
|
2737
2744
|
*/
|
|
2738
2745
|
export const withOnUpdate = (sink, atMount, config) => {
|
|
2739
|
-
// Per
|
|
2746
|
+
// Per Subject at mount: most have none, and pay a check.
|
|
2740
2747
|
if (Predicate.isUndefined(atMount))
|
|
2741
2748
|
return sink;
|
|
2742
2749
|
return {
|
|
@@ -2750,8 +2757,8 @@ export const withOnUpdate = (sink, atMount, config) => {
|
|
|
2750
2757
|
};
|
|
2751
2758
|
/**
|
|
2752
2759
|
* A Retarget's note of the keys it started from their Base value, or returned to it (ADR-0022): run at
|
|
2753
|
-
* the head of its first leg, cold path (no fiber of its own: forking one per
|
|
2754
|
-
* at a 1000-
|
|
2760
|
+
* the head of its first leg, cold path (no fiber of its own: forking one per Subject cost 10-20 µs each
|
|
2761
|
+
* at a 1000-Subject mount).
|
|
2755
2762
|
*/
|
|
2756
2763
|
export const baseLog = (id, started, returns) => Effect.logDebug("wardic.base: a key with no value started from, or returned to, its Base value (ADR-0022)").pipe(Effect.annotateLogs({ id, started, returned: Object.fromEntries(returns) }));
|
|
2757
2764
|
/** The keys a Retarget returns to a Live value that's a number: each one's return follows it (#130). */
|
|
@@ -2766,9 +2773,9 @@ const liveTargetOf = (ownValues, routes, key, start) => {
|
|
|
2766
2773
|
return last;
|
|
2767
2774
|
};
|
|
2768
2775
|
};
|
|
2769
|
-
/** Whether a value is one
|
|
2776
|
+
/** Whether a value is one a Subject can take: a number or a string. */
|
|
2770
2777
|
const isValue = (value) => Bool.or(Predicate.isNumber(value), Predicate.isString(value));
|
|
2771
|
-
/** A provider runtime's `AtomRegistry`, read on first need:
|
|
2778
|
+
/** A provider runtime's `AtomRegistry`, read on first need: a Subject with no Atom never reads it. */
|
|
2772
2779
|
export const registryOf = (runtime) => {
|
|
2773
2780
|
let registry;
|
|
2774
2781
|
return () => {
|
|
@@ -2777,7 +2784,7 @@ export const registryOf = (runtime) => {
|
|
|
2777
2784
|
return registry;
|
|
2778
2785
|
};
|
|
2779
2786
|
};
|
|
2780
|
-
/** Whether a config makes its
|
|
2787
|
+
/** Whether a config makes its Subject a layout node: `layout` (or a mode), or a `layoutId`. */
|
|
2781
2788
|
export const isLayoutNode = (c) => Bool.or(Bool.and(Predicate.isNotUndefined(c.layout), c.layout !== false), Predicate.isNotUndefined(c.layoutId));
|
|
2782
2789
|
/** A mount animation's template field (#443): left out with none, as its key reads it. */
|
|
2783
2790
|
export const templateField = (template) => UndefinedOr.match(template, { onUndefined: () => ({}), onDefined: (t) => ({ template: t }) });
|