@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/src/unstable/Spine.ts
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.ts"
|
|
21
21
|
import type * as DefaultTransition from "../DefaultTransition.ts"
|
|
@@ -69,7 +69,7 @@ declare const queueMicrotask: (callback: () => void) => void
|
|
|
69
69
|
|
|
70
70
|
export { NO_VARIANT_STATE, resolveTarget, type Target, transitionOfTarget, type VariantState } from "./VariantTarget.ts"
|
|
71
71
|
|
|
72
|
-
/** What
|
|
72
|
+
/** What a Subject's exit is resolved from (#277): its last config, kept current while it's alive. */
|
|
73
73
|
export interface ExitConfig {
|
|
74
74
|
readonly exit: Config.WardicVariant | Config.WardicVariantLabels | undefined
|
|
75
75
|
readonly variants: Config.WardicVariants | undefined
|
|
@@ -78,7 +78,7 @@ export interface ExitConfig {
|
|
|
78
78
|
readonly transition: Config.WardicTransition | undefined
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
/** No exit:
|
|
81
|
+
/** No exit: a Subject outside a presence never resolves one. */
|
|
82
82
|
export const NO_EXIT_CONFIG: ExitConfig = { exit: undefined, variants: undefined, custom: undefined, transition: undefined }
|
|
83
83
|
|
|
84
84
|
/** A record's place in the variant tree (#290), from its config at setup. */
|
|
@@ -89,20 +89,20 @@ export const presenceTreeOf = (c: Config.SpineConfig): PresenceRecord.PresenceTr
|
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
* whether it's a twin. With no presence, `set` itself: nothing is made per
|
|
92
|
+
* A Subject's ref that tells its presence it was made (#286, ADR-0048): its `key`, read once, and
|
|
93
|
+
* whether it's a twin. With no presence, `set` itself: nothing is made per Subject.
|
|
94
94
|
*/
|
|
95
|
-
export const madeWith = <E extends Subject.Subject>(presence: PresenceRecord.PresenceContextValue<E> | undefined, set: (
|
|
95
|
+
export const madeWith = <E extends Subject.Subject>(presence: PresenceRecord.PresenceContextValue<E> | undefined, set: (subject: E) => void, c: Config.SpineConfig): ((subject: E) => void) => {
|
|
96
96
|
if (Predicate.isUndefined(presence)) return set
|
|
97
97
|
const key = c.key
|
|
98
98
|
const twin = Predicate.isNotUndefined(c.layoutId)
|
|
99
|
-
return (
|
|
100
|
-
PresenceRecord.presenceMade(presence,
|
|
101
|
-
set(
|
|
99
|
+
return (subject) => {
|
|
100
|
+
PresenceRecord.presenceMade(presence, subject, key, twin)
|
|
101
|
+
set(subject)
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
/**
|
|
105
|
+
/** A Subject's {@link ExitConfig} from its config now. */
|
|
106
106
|
export const exitConfigOf = (c: Config.SpineConfig, parent: VariantTree.WardicVariantContextValue | undefined): ExitConfig => ({
|
|
107
107
|
exit: c.exit,
|
|
108
108
|
variants: c.variants,
|
|
@@ -114,9 +114,9 @@ export const exitConfigOf = (c: Config.SpineConfig, parent: VariantTree.WardicVa
|
|
|
114
114
|
export type ExitTarget = PresenceRecord.PresenceExit
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* Resolve
|
|
118
|
-
* given (Motion's: the leaving
|
|
119
|
-
* its own transition, else the
|
|
117
|
+
* Resolve a Subject's exit as it leaves (#277): with its `<AnimatePresence custom>` when that's
|
|
118
|
+
* given (Motion's: the leaving Subject's own props can't change any more), else its own `custom`; on
|
|
119
|
+
* its own transition, else the Subject's.
|
|
120
120
|
*/
|
|
121
121
|
export const exitTargetOf = (config: ExitConfig, presenceCustom: unknown, state: VariantTarget.VariantState, inherited: Config.WardicVariantLabels | undefined): ExitTarget => {
|
|
122
122
|
const custom = UndefinedOr.match(presenceCustom, { onUndefined: () => config.custom, onDefined: identity })
|
|
@@ -142,12 +142,12 @@ export const exitTargetOf = (config: ExitConfig, presenceCustom: unknown, state:
|
|
|
142
142
|
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure }
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `
|
|
146
|
-
const exitGroupsOf = (targets: ReadonlyArray<VariantTarget.NamedTarget>,
|
|
145
|
+
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `wardTransition`. */
|
|
146
|
+
const exitGroupsOf = (targets: ReadonlyArray<VariantTarget.NamedTarget>, wardTransition: Config.WardicTransition | undefined): ReadonlyArray<PresenceRecord.ExitGroup> =>
|
|
147
147
|
Arr.map(targets, (target, i) => ({
|
|
148
148
|
name: target.name as string,
|
|
149
149
|
values: Rec.filter(target.values, (_, key) => Bool.not(Arr.some(Arr.drop(targets, i + 1), (later) => Object.hasOwn(later.values, key)))),
|
|
150
|
-
transition: VariantTarget.transitionOfTarget(target.transition,
|
|
150
|
+
transition: VariantTarget.transitionOfTarget(target.transition, wardTransition),
|
|
151
151
|
}))
|
|
152
152
|
|
|
153
153
|
/** 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. */
|
|
@@ -200,10 +200,10 @@ const keyTransitionOf = (
|
|
|
200
200
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
201
201
|
key: string,
|
|
202
202
|
transition: Config.WardicTransition | undefined,
|
|
203
|
-
|
|
203
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
204
204
|
): Config.WardicTransition | undefined => {
|
|
205
205
|
if (Predicate.isUndefined(groups)) return transition
|
|
206
|
-
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition,
|
|
206
|
+
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, wardTransition, undefined, identity)
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
|
|
@@ -225,7 +225,7 @@ const pickKeys = (t: Values.Values, groups: ReadonlyArray<ReadonlySet<string>> |
|
|
|
225
225
|
export const delayOf = (transition: Config.WardicTransition | undefined): number =>
|
|
226
226
|
UndefinedOr.match(transition, { onUndefined: () => 0, onDefined: ({ delay = 0 }) => delay })
|
|
227
227
|
|
|
228
|
-
/** No keys: what a drag moves on a projected
|
|
228
|
+
/** No keys: what a drag moves on a projected Subject, or one with no drag. */
|
|
229
229
|
const NO_KEYS: ReadonlyArray<string> = []
|
|
230
230
|
|
|
231
231
|
/** The keys a drag of `axis` moves directly. Built once, at module load. */
|
|
@@ -239,6 +239,8 @@ const dragMovesOf: (axis: boolean | "x" | "y") => ReadonlyArray<string> = Match.
|
|
|
239
239
|
const isSameKind = (value: number | string, like: number | string): boolean => Predicate.isNumber(value) === Predicate.isNumber(like)
|
|
240
240
|
|
|
241
241
|
/** The keys a drag direct-sets (ADR-0004). */
|
|
242
|
+
// `translateX` and `translateY` are the DOM's own keys since #1002 (ADR-0073, *Amendment (#1002)*, Q6): they
|
|
243
|
+
// stay here, plumbing, as the DOM's aliases of `x` and `y` that a drag holds back too.
|
|
242
244
|
const TRANSLATE_KEYS: ReadonlySet<string> = new Set(["x", "y", "translateX", "translateY"])
|
|
243
245
|
const TRANSLATE_KEY_LIST: ReadonlyArray<string> = Arr.fromIterable(TRANSLATE_KEYS)
|
|
244
246
|
|
|
@@ -402,7 +404,7 @@ const setsValues = (layer: OverrideEntry): boolean => {
|
|
|
402
404
|
/** A single entry's name: itself, if a name; `undefined` for a values map. */
|
|
403
405
|
const labelOrUndefined = (entry: VariantTarget.Entry): string | undefined => Bool.match(Predicate.isString(entry), { onTrue: () => entry as string, onFalse: constUndefined })
|
|
404
406
|
|
|
405
|
-
/** Each gesture on: the
|
|
407
|
+
/** Each gesture on: the Subject's own, or its provider's too when it has one handing any down. */
|
|
406
408
|
const gesturesOnOf = (active: Active, above: VariantTree.GestureHandDown): VariantTree.GestureStates => {
|
|
407
409
|
if (above === VariantTree.NO_HAND_DOWN) return active
|
|
408
410
|
return VariantTree.gesturesOn(active, above.on)
|
|
@@ -422,7 +424,7 @@ const anyOn = (on: VariantTree.GestureStates): boolean => on.inView || on.focuse
|
|
|
422
424
|
|
|
423
425
|
/**
|
|
424
426
|
* Whether an active entry's name delays its keys otherwise than the first entry's (#297): a Variant
|
|
425
|
-
* child's names each take their own stagger slot. Never for
|
|
427
|
+
* child's names each take their own stagger slot. Never for a Subject that joins none, nor for one
|
|
426
428
|
* entry.
|
|
427
429
|
*/
|
|
428
430
|
const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name: string | undefined) => number) | undefined, extra: number): boolean => {
|
|
@@ -430,7 +432,7 @@ const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name:
|
|
|
430
432
|
return Arr.some(layers, (layer) => Bool.and(layer.active, extraOf(extraDelay, layer) !== extra))
|
|
431
433
|
}
|
|
432
434
|
|
|
433
|
-
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other
|
|
435
|
+
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other Subject. */
|
|
434
436
|
const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined, layer: OverrideEntry | undefined): number => {
|
|
435
437
|
if (Predicate.isUndefined(extraDelay)) return 0
|
|
436
438
|
if (Predicate.isUndefined(layer)) return extraDelay(undefined)
|
|
@@ -439,8 +441,8 @@ const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined,
|
|
|
439
441
|
|
|
440
442
|
/**
|
|
441
443
|
* The transition a key group runs on (#291, #297): unsplit, the base's (`transition`, its delay
|
|
442
|
-
* folded in); split, its entry's own, else the
|
|
443
|
-
* group carries its returns too, which run on the
|
|
444
|
+
* folded in); split, its entry's own, else the Subject's, at its name's delay. A list's first
|
|
445
|
+
* group carries its returns too, which run on the Subject's transition, as a list's base has no one
|
|
444
446
|
* transition of its own.
|
|
445
447
|
*/
|
|
446
448
|
const groupTransitionOf = (
|
|
@@ -448,16 +450,16 @@ const groupTransitionOf = (
|
|
|
448
450
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
449
451
|
i: number,
|
|
450
452
|
transition: Config.WardicTransition | undefined,
|
|
451
|
-
|
|
453
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
452
454
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
453
455
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
454
456
|
): Config.WardicTransition | undefined => {
|
|
455
457
|
if (Predicate.isUndefined(groups)) return transition
|
|
456
458
|
if (Bool.and(i === 0, Bool.not(Arr.isArray(resolution.variant)))) return transition
|
|
457
459
|
const layer = resolution.layers[i]
|
|
458
|
-
// A list's returns: the
|
|
459
|
-
if (Predicate.isUndefined(layer)) return staggeredOf(
|
|
460
|
-
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition,
|
|
460
|
+
// A list's returns: the Subject's, at its whole orchestration's delay.
|
|
461
|
+
if (Predicate.isUndefined(layer)) return staggeredOf(wardTransition, extraOf(extraDelay, undefined), reuse)
|
|
462
|
+
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition, wardTransition), extraOf(extraDelay, layer), reuse)
|
|
461
463
|
}
|
|
462
464
|
|
|
463
465
|
/** No names. */
|
|
@@ -480,7 +482,7 @@ export interface Landing {
|
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
/**
|
|
483
|
-
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the
|
|
485
|
+
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the Subject
|
|
484
486
|
* unsettled, as it still owes an animation, and land nothing; the Retarget once the gate opens
|
|
485
487
|
* counts them.
|
|
486
488
|
*/
|
|
@@ -564,7 +566,7 @@ interface PendingEnd {
|
|
|
564
566
|
state: "waiting" | "due" | "written" | "dropped"
|
|
565
567
|
}
|
|
566
568
|
|
|
567
|
-
/**
|
|
569
|
+
/** A Subject's waiting Transition ends (#508). */
|
|
568
570
|
interface WaitingEnds {
|
|
569
571
|
/** An entry's end, waiting for its keys, or due already when they've landed. */
|
|
570
572
|
readonly add: (end: PendingEnd) => void
|
|
@@ -572,12 +574,12 @@ interface WaitingEnds {
|
|
|
572
574
|
readonly land: () => void
|
|
573
575
|
/** The end `running` is, dropped, whether it waits or is due: given up, stopped or ended. */
|
|
574
576
|
readonly drop: (running: Running) => void
|
|
575
|
-
/** The
|
|
577
|
+
/** The Subject is gone: none is written. */
|
|
576
578
|
readonly dispose: () => void
|
|
577
579
|
}
|
|
578
580
|
|
|
579
581
|
/**
|
|
580
|
-
* The waiting Transition ends of
|
|
582
|
+
* The waiting Transition ends of Subject `id` (#508): made at its first end, so a Subject with none,
|
|
581
583
|
* nearly every one, pays nothing for them. `owners` holds the leg drawing each key.
|
|
582
584
|
*/
|
|
583
585
|
const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape, id: string, recordFrame: (value: Values.Values) => void): WaitingEnds => {
|
|
@@ -661,7 +663,7 @@ const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape
|
|
|
661
663
|
}
|
|
662
664
|
}
|
|
663
665
|
|
|
664
|
-
/** A leg's last frame lands the Transition ends waiting on it (#508);
|
|
666
|
+
/** A leg's last frame lands the Transition ends waiting on it (#508); a Subject with none has nothing to ask. */
|
|
665
667
|
const landEndsOf = (waiting: WaitingEnds | undefined): void => {
|
|
666
668
|
if (Predicate.isNotUndefined(waiting)) waiting.land()
|
|
667
669
|
}
|
|
@@ -671,7 +673,7 @@ export const NO_VALUES: Values.Values = {}
|
|
|
671
673
|
|
|
672
674
|
/**
|
|
673
675
|
* Whether a change's starts, targets or Keyframes stops hold a Variable value (#542): only then can
|
|
674
|
-
* the
|
|
676
|
+
* the Subject's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
|
|
675
677
|
* built under it. It declines every pair with no `var()` at either end.
|
|
676
678
|
*/
|
|
677
679
|
export const holdsVariable = (variables: VariableValues.Shape, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined): boolean => {
|
|
@@ -696,7 +698,7 @@ const stopsCheckOf = (variables: VariableValues.Shape): ((stops: ReadonlyArray<n
|
|
|
696
698
|
return check
|
|
697
699
|
}
|
|
698
700
|
|
|
699
|
-
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto
|
|
701
|
+
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto the Subject's turn. */
|
|
700
702
|
const PATH_ROTATION = "pathRotation"
|
|
701
703
|
|
|
702
704
|
/** The turn back at 0, written once no leg draws it (#460). */
|
|
@@ -824,7 +826,7 @@ const restOf = (owners: Owners, target: Values.Values, axis: "x" | "y"): number
|
|
|
824
826
|
/**
|
|
825
827
|
* Where a Path's axes that `target` leaves out rest (#574), read before their legs give them up: a
|
|
826
828
|
* new Path ends them there, so a toss caught mid-air curves back to its line. `undefined` for none:
|
|
827
|
-
* every
|
|
829
|
+
* every Subject's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
|
|
828
830
|
*/
|
|
829
831
|
export const restsOf = (owners: Owners, target: Values.Values): Values.Values | undefined => {
|
|
830
832
|
const x = restOf(owners, target, "x")
|
|
@@ -877,7 +879,7 @@ const splitLegsOf = (
|
|
|
877
879
|
resolution: Resolution,
|
|
878
880
|
listed: boolean,
|
|
879
881
|
transition: Config.WardicTransition | undefined,
|
|
880
|
-
|
|
882
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
881
883
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
882
884
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
883
885
|
reduce: boolean,
|
|
@@ -902,7 +904,7 @@ const splitLegsOf = (
|
|
|
902
904
|
if (Rec.isEmptyRecord(picked)) return
|
|
903
905
|
let followed: RetargetLegs.Follows | undefined
|
|
904
906
|
if (i === returnsAt) followed = follow
|
|
905
|
-
const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition,
|
|
907
|
+
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)
|
|
906
908
|
Arr.forEach(groupLegs, (built) => {
|
|
907
909
|
legs.push(built)
|
|
908
910
|
tags.push(i)
|
|
@@ -939,7 +941,7 @@ interface ListingOf {
|
|
|
939
941
|
* A list's names at a Retarget (#297): told settled as the legs of the keys each drives settle, to
|
|
940
942
|
* the binding's callbacks (Solid 1's, PR 1) and to its orchestration (PR 2), told moving now; and each
|
|
941
943
|
* shut name's legs waiting on its gate (PR 2), its keys held where they start, so another name's first
|
|
942
|
-
* commit, which hands the
|
|
944
|
+
* commit, which hands the Subject's style back (ADR-0034), doesn't drop them to their own value.
|
|
943
945
|
*/
|
|
944
946
|
const listingOf = (of: ListingOf): Listing => {
|
|
945
947
|
const { listed, told, byName, resolution, groups, legGroups, legCount, carriedGroups, shut, config } = of
|
|
@@ -1002,7 +1004,7 @@ const logsDebugOn = (runtime: WardicServices.Runner<WardicServices.WardicService
|
|
|
1002
1004
|
}
|
|
1003
1005
|
|
|
1004
1006
|
/**
|
|
1005
|
-
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so
|
|
1007
|
+
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so a Subject
|
|
1006
1008
|
* none animates holds no map of its own (#460). Never written: a spine sets keys in a map of its own,
|
|
1007
1009
|
* and deletes only from one that has some.
|
|
1008
1010
|
*/
|
|
@@ -1102,7 +1104,7 @@ const hasKeyframes = (layer: OverrideEntry): boolean => {
|
|
|
1102
1104
|
|
|
1103
1105
|
/**
|
|
1104
1106
|
* Each resolved key's Keyframes (#429): the stops of the entry that drives it, when that entry gives
|
|
1105
|
-
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every
|
|
1107
|
+
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every Subject's common
|
|
1106
1108
|
* case.
|
|
1107
1109
|
*/
|
|
1108
1110
|
const keyframesNowOf = (layers: ReadonlyArray<OverrideEntry>, resolved: Values.Values): KeyframesNow | undefined => {
|
|
@@ -1212,11 +1214,11 @@ const measuringOf = (found: ReadonlyArray<string> | undefined, keyframes: Keyfra
|
|
|
1212
1214
|
|
|
1213
1215
|
/**
|
|
1214
1216
|
* A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
|
|
1215
|
-
* end-of-task batch with the values the
|
|
1217
|
+
* end-of-task batch with the values the Subject draws now, but a key with Keyframes of more than two
|
|
1216
1218
|
* stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
|
|
1217
|
-
* it couldn't read do, reported on `runtime` with the
|
|
1219
|
+
* it couldn't read do, reported on `runtime` with the Subject's `id`.
|
|
1218
1220
|
*/
|
|
1219
|
-
export const measuredOf = (measured: MeasuredPairs.Shape,
|
|
1221
|
+
export const measuredOf = (measured: MeasuredPairs.Shape, subject: Subject.Subject, keys: ReadonlyArray<string>, from: Values.Values, to: Values.Values, values: Values.Values, many: RetargetLegs.StopsByKey | undefined, runtime: Pick<WardicServices.Runner<never>, "runFork">, id: string): RetargetLegs.MeasuredPairs | undefined => {
|
|
1220
1222
|
const pairs: Record<string, { readonly from: number | string; readonly to: number | string }> = {}
|
|
1221
1223
|
Arr.forEach(keys, (key) => {
|
|
1222
1224
|
if (RetargetLegs.hasManyStops(many, key)) return
|
|
@@ -1226,8 +1228,8 @@ export const measuredOf = (measured: MeasuredPairs.Shape, element: Subject.Subje
|
|
|
1226
1228
|
if (measured.needs(key, start as number | string, target as number | string)) pairs[key] = { from: start as number | string, to: target as number | string }
|
|
1227
1229
|
})
|
|
1228
1230
|
if (Rec.isEmptyRecord(pairs)) return undefined
|
|
1229
|
-
// Its report made only for pairs asked, not once
|
|
1230
|
-
return measured.measure(
|
|
1231
|
+
// Its report made only for pairs asked, not once a Subject (#979, row 8): nearly every Retarget asks none.
|
|
1232
|
+
return measured.measure(subject, pairs, values, pairsFailedOn("wardic.spine: a Retarget's Measured pairs failed", runtime, { id }))
|
|
1231
1233
|
}
|
|
1232
1234
|
|
|
1233
1235
|
/** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
|
|
@@ -1419,15 +1421,15 @@ const nameSettlesOf = (
|
|
|
1419
1421
|
* Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
|
|
1420
1422
|
* config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
|
|
1421
1423
|
* the config. A callback that throws is reported at the first of a run of throws, its next clean call
|
|
1422
|
-
* ending the run, and the
|
|
1424
|
+
* ending the run, and the Subject animates on. The Solid 2 binding's config has neither: it hands the
|
|
1423
1425
|
* same facts over as async values.
|
|
1424
1426
|
*/
|
|
1425
1427
|
export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices.WardicServices>, id: string): AnimationHooks => {
|
|
1426
1428
|
// #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
|
|
1427
|
-
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per
|
|
1429
|
+
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per Subject.
|
|
1428
1430
|
let startFailing = false
|
|
1429
1431
|
let completeFailing = false
|
|
1430
|
-
// Per Retarget, per
|
|
1432
|
+
// Per Retarget, per Subject: the callback looked up first, and nothing made without one. Whether it threw,
|
|
1431
1433
|
// reported at a run's first throw (`failing` says one is on).
|
|
1432
1434
|
const tell = (
|
|
1433
1435
|
name: "onAnimationStart" | "onAnimationComplete",
|
|
@@ -1489,7 +1491,7 @@ export interface Active {
|
|
|
1489
1491
|
readonly dragging: boolean
|
|
1490
1492
|
}
|
|
1491
1493
|
|
|
1492
|
-
/** The variant name
|
|
1494
|
+
/** The variant name a Subject animates to: its own `animate`'s, else the one its provider hands down. */
|
|
1493
1495
|
const variantOf = (animate: Config.SpineConfig["animate"], parent: VariantTree.WardicVariantContextValue | undefined): Config.WardicVariantLabels | undefined => {
|
|
1494
1496
|
if (Predicate.isNotUndefined(animate)) return VariantTree.nameOf(animate)
|
|
1495
1497
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1527,6 +1529,9 @@ export const resolutionOf = (
|
|
|
1527
1529
|
): Resolution => {
|
|
1528
1530
|
// The Controls change in effect (#433): its own controls', else its provider's, read here so a new one Retargets.
|
|
1529
1531
|
const change = changeIn(own, parent)
|
|
1532
|
+
// Each key read once (#460, compose once): a binding's config can be a view that works a key out at
|
|
1533
|
+
// each read, a key several of a ward's parts give merged at each (probe: hooks-first), and this
|
|
1534
|
+
// read `animate` up to four times, and `custom` once for the base and once for each gesture.
|
|
1530
1535
|
const variants = c.variants
|
|
1531
1536
|
// Base target resolution priority (ADR-0007):
|
|
1532
1537
|
// (1) local `animate` (a Values map or a variant name) — overrides any
|
|
@@ -1536,34 +1541,37 @@ export const resolutionOf = (
|
|
|
1536
1541
|
// sibling's "open"); read parent.variant() here so a parent flip
|
|
1537
1542
|
// recomputes the memo and retargets;
|
|
1538
1543
|
// (3) else the SSR-seeded `initial`.
|
|
1539
|
-
// Per Retarget, per
|
|
1540
|
-
const
|
|
1544
|
+
// Per Retarget, per Subject (#460, compose once): statements.
|
|
1545
|
+
const animate = c.animate
|
|
1546
|
+
const variant = variantOf(animate, parent)
|
|
1547
|
+
// Read after `animate`, as it was: a key still loading throws at the first of them read.
|
|
1548
|
+
const custom = c.custom
|
|
1541
1549
|
// A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
|
|
1542
1550
|
// that sets a key drives it. A single name or a values map takes the path below, as before.
|
|
1543
|
-
if (Arr.isArray(
|
|
1544
|
-
const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants,
|
|
1551
|
+
if (Arr.isArray(animate) || (Predicate.isUndefined(animate) && Arr.isArray(variant))) {
|
|
1552
|
+
const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants, custom, state)
|
|
1545
1553
|
const merged = VariantTarget.mergedOf(targets)
|
|
1546
1554
|
const listLayers: Array<OverrideEntry> = Arr.map(targets, namedLayerOf)
|
|
1547
|
-
return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1555
|
+
return withGestures(c, variants, custom, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1548
1556
|
}
|
|
1549
|
-
// A dynamic variant resolves with this
|
|
1557
|
+
// A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
|
|
1550
1558
|
// Animation controls never reach here: its binding reads them once, each change its entry (#433).
|
|
1551
|
-
const target = baseTargetOf(
|
|
1559
|
+
const target = baseTargetOf(animate as VariantTarget.Entry | undefined, variant, variants, custom, state, initialLink)
|
|
1552
1560
|
const base = target.values
|
|
1553
1561
|
const baseLayer: OverrideEntry = layerOf(target, variant as string | undefined)
|
|
1554
1562
|
// A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
|
|
1555
1563
|
// its own `while*`, else the label the provider hands down. With no provider, its own: nothing made.
|
|
1556
1564
|
// The common case: nothing handed down and no gesture on. The base entry alone, and nothing else
|
|
1557
|
-
// made or called, at every
|
|
1565
|
+
// made or called, at every Subject's mount and Retarget.
|
|
1558
1566
|
if (VariantTree.handDownFrom(parent) === VariantTree.NO_HAND_DOWN && !anyOn(active)) {
|
|
1559
1567
|
const alone: ReadonlyArray<OverrideEntry> = [baseLayer]
|
|
1560
1568
|
const { resolved, ends, keyframes } = resolvedOf(alone)
|
|
1561
1569
|
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 }
|
|
1562
1570
|
}
|
|
1563
|
-
return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1571
|
+
return withGestures(c, variants, custom, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1564
1572
|
}
|
|
1565
1573
|
|
|
1566
|
-
/** The **Controls change** in effect for
|
|
1574
|
+
/** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
|
|
1567
1575
|
const changeIn = (own: AnimationControls.ControlsChange | undefined, parent: VariantTree.WardicVariantContextValue | undefined): AnimationControls.ControlsChange | undefined => {
|
|
1568
1576
|
if (Predicate.isNotUndefined(own)) return own
|
|
1569
1577
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1590,10 +1598,12 @@ const overriddenOf = (resolution: Resolution, override: Config.WardicTransition)
|
|
|
1590
1598
|
/**
|
|
1591
1599
|
* A resolution from its base entries (one, or one a name of a list, #297) and its gesture layers on
|
|
1592
1600
|
* top (#291), each gesture's an entry a name too: the Override stack resolved, and the names its
|
|
1593
|
-
* active gestures resolved.
|
|
1601
|
+
* active gestures resolved. `variants` and `custom` are `c`'s, read once by the caller.
|
|
1594
1602
|
*/
|
|
1595
1603
|
const withGestures = (
|
|
1596
1604
|
c: Config.SpineConfig,
|
|
1605
|
+
variants: Config.SpineConfig["variants"],
|
|
1606
|
+
custom: Config.SpineConfig["custom"],
|
|
1597
1607
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
1598
1608
|
layers: Array<OverrideEntry>,
|
|
1599
1609
|
base: Values.Values,
|
|
@@ -1603,7 +1613,6 @@ const withGestures = (
|
|
|
1603
1613
|
state: VariantTarget.VariantState,
|
|
1604
1614
|
change: AnimationControls.ControlsChange | undefined,
|
|
1605
1615
|
): Resolution => {
|
|
1606
|
-
const variants = c.variants
|
|
1607
1616
|
const above = VariantTree.handDownFrom(parent)
|
|
1608
1617
|
if (Bool.and(above === VariantTree.NO_HAND_DOWN, Bool.not(anyOn(active)))) {
|
|
1609
1618
|
const { resolved, ends, keyframes } = resolvedOf(layers)
|
|
@@ -1613,21 +1622,21 @@ const withGestures = (
|
|
|
1613
1622
|
const labels = above.names
|
|
1614
1623
|
// In Motion's priority, lowest first: a literal's fields are evaluated in order.
|
|
1615
1624
|
const layersOn: VariantTree.GestureStates = {
|
|
1616
|
-
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants,
|
|
1617
|
-
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants,
|
|
1618
|
-
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants,
|
|
1619
|
-
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants,
|
|
1625
|
+
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants, custom, state),
|
|
1626
|
+
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants, custom, state),
|
|
1627
|
+
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants, custom, state),
|
|
1628
|
+
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants, custom, state),
|
|
1620
1629
|
// whileDrag sits ABOVE tap (highest priority) — driven by the spring,
|
|
1621
1630
|
// NOT stripped, so e.g. `scale: 1.1` animates while held and returns
|
|
1622
1631
|
// after release.
|
|
1623
|
-
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants,
|
|
1632
|
+
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants, custom, state),
|
|
1624
1633
|
}
|
|
1625
1634
|
const { resolved, ends, keyframes } = resolvedOf(layers)
|
|
1626
1635
|
const names = activeNamesFor(c, on, labels)
|
|
1627
1636
|
return { resolved, base, dragging: active.dragging, variant, active, transition, layers, names, layersOn, ends, keyframes, change }
|
|
1628
1637
|
}
|
|
1629
1638
|
|
|
1630
|
-
/** The values
|
|
1639
|
+
/** The values a Subject starts from, read once at setup (ADR-0003, #134). */
|
|
1631
1640
|
export interface Start {
|
|
1632
1641
|
/** Its Starting style's values: its `initial` (own or inherited, #50), or its `animate` when it starts there. */
|
|
1633
1642
|
readonly initialValues: Values.Values
|
|
@@ -1647,7 +1656,7 @@ export interface Start {
|
|
|
1647
1656
|
}
|
|
1648
1657
|
|
|
1649
1658
|
/**
|
|
1650
|
-
*
|
|
1659
|
+
* A Subject's {@link Start}, from its config read once and the context it inherits from. With
|
|
1651
1660
|
* `initial={false}` (its own, inherited, or an `<AnimatePresence initial={false}>`'s first render)
|
|
1652
1661
|
* it starts at its `animate`, and nothing animates at mount (#134).
|
|
1653
1662
|
*/
|
|
@@ -1659,7 +1668,7 @@ export const startOf = (
|
|
|
1659
1668
|
): Start => {
|
|
1660
1669
|
const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks)
|
|
1661
1670
|
// Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
|
|
1662
|
-
// for
|
|
1671
|
+
// for a Subject with no variants, so its start makes nothing more (bench:solid's mount).
|
|
1663
1672
|
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom)
|
|
1664
1673
|
const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants)
|
|
1665
1674
|
return {
|
|
@@ -1679,15 +1688,15 @@ const failedOn =
|
|
|
1679
1688
|
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }))
|
|
1680
1689
|
}
|
|
1681
1690
|
|
|
1682
|
-
/** How
|
|
1691
|
+
/** How a Subject's variant that throws is reported, on its runtime. */
|
|
1683
1692
|
const variantFailedOn = failedOn("wardic.ward: a variant failed")
|
|
1684
1693
|
|
|
1685
|
-
/** How an exit whose resolver throws is reported, on `runtime`, each time
|
|
1694
|
+
/** How an exit whose resolver throws is reported, on `runtime`, each time a Subject leaves: its Subject leaves without it (#979). */
|
|
1686
1695
|
export const exitVariantFailedOn: (runtime: Pick<WardicServices.Runner<never>, "runFork">) => (failure: VariantTarget.VariantFailure) => void = failedOn(
|
|
1687
1696
|
"wardic.presence: an exit variant failed",
|
|
1688
1697
|
)
|
|
1689
1698
|
|
|
1690
|
-
/**
|
|
1699
|
+
/** A Subject's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
|
|
1691
1700
|
export const variantFailedOnServer: (failure: VariantTarget.VariantFailure) => void = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER)
|
|
1692
1701
|
|
|
1693
1702
|
/** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
|
|
@@ -1697,31 +1706,31 @@ const firstFailureOf = Arr.findFirst<OverrideEntry, VariantTarget.VariantFailure
|
|
|
1697
1706
|
export const failureOf = (resolution: Resolution): Option.Option<VariantTarget.VariantFailure> => firstFailureOf(resolution.layers)
|
|
1698
1707
|
|
|
1699
1708
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
* the places that saw it fail. One
|
|
1709
|
+
* A Subject's dynamic variants that throw: its last good resolution, and each variant failing now with
|
|
1710
|
+
* the places that saw it fail. One a Subject, made by its binding with `report` on its runtime, and
|
|
1702
1711
|
* read through {@link keptOf}, {@link reportStart} and {@link orchestrationOf}: each variant is
|
|
1703
1712
|
* reported once, until it resolves again.
|
|
1704
1713
|
*/
|
|
1705
1714
|
export interface VariantFailures extends VariantTree.DelayFailures {
|
|
1706
1715
|
/** Its last resolution with no failure: what {@link keptOf} gives while one carries a failure. */
|
|
1707
1716
|
last: Resolution | undefined
|
|
1708
|
-
/** Each failing variant, by name, and where it was seen; made at the first failure: most
|
|
1717
|
+
/** Each failing variant, by name, and where it was seen; made at the first failure: most Subjects never have one. */
|
|
1709
1718
|
failing: Map<string, number> | undefined
|
|
1710
1719
|
/** The runtime its failures are reported on, at Error. */
|
|
1711
1720
|
readonly runtime: Pick<WardicServices.Runner<never>, "runFork">
|
|
1712
1721
|
}
|
|
1713
1722
|
|
|
1714
|
-
/**
|
|
1715
|
-
// #979 (bench:solid's mount): one plain object
|
|
1723
|
+
/** A Subject's {@link VariantFailures}, none failing yet, reported on `runtime`. */
|
|
1724
|
+
// #979 (bench:solid's mount): one plain object a Subject, read by the functions below, not closures, and
|
|
1716
1725
|
// holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
|
|
1717
|
-
// WeakMap cost Solid 1's mount 6% (the lookup,
|
|
1726
|
+
// WeakMap cost Solid 1's mount 6% (the lookup, a Subject).
|
|
1718
1727
|
export const variantFailuresOf = (runtime: Pick<WardicServices.Runner<never>, "runFork">): VariantFailures => ({ last: undefined, failing: undefined, delayFailing: false, runtime })
|
|
1719
1728
|
|
|
1720
|
-
/** Where a variant's failure was seen, until each resolves it again: its
|
|
1729
|
+
/** Where a variant's failure was seen, until each resolves it again: its Subject's resolutions, and its orchestration. */
|
|
1721
1730
|
const RESOLVING = 1
|
|
1722
1731
|
const ORCHESTRATING = 2
|
|
1723
1732
|
|
|
1724
|
-
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its
|
|
1733
|
+
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its Subject's alone. Each variant, by name,
|
|
1725
1734
|
// is reported as it starts failing and fails until every place that saw it fail resolves it again, so
|
|
1726
1735
|
// a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
|
|
1727
1736
|
// values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
|
|
@@ -1750,8 +1759,8 @@ const resolvedAt = (failing: Map<string, number>, name: string | undefined, at:
|
|
|
1750
1759
|
failing.set(name, after)
|
|
1751
1760
|
}
|
|
1752
1761
|
|
|
1753
|
-
/** `next`, else, while it carries a failure, the
|
|
1754
|
-
// Per Retarget, per
|
|
1762
|
+
/** `next`, else, while it carries a failure, the Subject's last good resolution: it keeps its target. */
|
|
1763
|
+
// Per Retarget, per Subject (#460, compose once): statements; nothing done while nothing fails.
|
|
1755
1764
|
export const keptOf = (failures: VariantFailures, next: Resolution): Resolution => {
|
|
1756
1765
|
const failure = failureOf(next)
|
|
1757
1766
|
if (Option.isSome(failure)) {
|
|
@@ -1773,7 +1782,7 @@ export const reportStart = (failures: VariantFailures, start: Start): void => {
|
|
|
1773
1782
|
if (Option.isSome(start.failure)) failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING)
|
|
1774
1783
|
}
|
|
1775
1784
|
|
|
1776
|
-
/** What
|
|
1785
|
+
/** What a Subject's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
|
|
1777
1786
|
export const orchestrationOf =
|
|
1778
1787
|
(failures: VariantFailures): VariantTarget.Orchestrated =>
|
|
1779
1788
|
(entry, failure) => {
|
|
@@ -1893,9 +1902,9 @@ export const velocitiesNowOf = (snapshot: Snapshot): Readonly<Record<string, num
|
|
|
1893
1902
|
}
|
|
1894
1903
|
|
|
1895
1904
|
/**
|
|
1896
|
-
* The transition a Retarget runs on (#66): the
|
|
1905
|
+
* The transition a Retarget runs on (#66): the Subject's last one when the new one has the same
|
|
1897
1906
|
* fields, so core's decode cache hits when the object is rebuilt with the same values (a staggered
|
|
1898
|
-
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per
|
|
1907
|
+
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per Subject.
|
|
1899
1908
|
*/
|
|
1900
1909
|
export const makeReuse = (): ((transition: Config.WardicTransition) => Config.WardicTransition) => {
|
|
1901
1910
|
let lastTransition: Config.WardicTransition | undefined
|
|
@@ -1908,7 +1917,7 @@ export const makeReuse = (): ((transition: Config.WardicTransition) => Config.Wa
|
|
|
1908
1917
|
}
|
|
1909
1918
|
|
|
1910
1919
|
/**
|
|
1911
|
-
* A mounted
|
|
1920
|
+
* A mounted Subject's Base-value links (ADR-0022), as its binding reads them: its Own value per key,
|
|
1912
1921
|
* the links for a key's start coerced to the shape of its target (`like`), and that start.
|
|
1913
1922
|
*/
|
|
1914
1923
|
// #672: the spine names what it calls; the binding's `startLinksOf` (`element-setup.ts`) makes them.
|
|
@@ -1919,12 +1928,12 @@ export interface StartLinks {
|
|
|
1919
1928
|
}
|
|
1920
1929
|
|
|
1921
1930
|
/**
|
|
1922
|
-
*
|
|
1931
|
+
* A Subject's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
|
|
1923
1932
|
* fires before any frame still has a `from`, and its `exit` ref, which the ward keeps current. An exit key with no value starts
|
|
1924
1933
|
* from its Base value's start links (ADR-0022), read from the Subject kept at the exit.
|
|
1925
1934
|
*/
|
|
1926
1935
|
export const presenceRecordOf = <E extends Subject.Subject>(
|
|
1927
|
-
|
|
1936
|
+
subject: E,
|
|
1928
1937
|
start: Start,
|
|
1929
1938
|
exitOf: (custom: unknown, inherited: Config.WardicVariantLabels | undefined) => ExitTarget,
|
|
1930
1939
|
links: StartLinks,
|
|
@@ -1933,7 +1942,7 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1933
1942
|
reducedMotion: () => boolean,
|
|
1934
1943
|
skipAnimations: () => boolean,
|
|
1935
1944
|
): PresenceRecord.PresenceRecord<E> => ({
|
|
1936
|
-
|
|
1945
|
+
subject,
|
|
1937
1946
|
snapshot: { current: { ...start.initialValues } },
|
|
1938
1947
|
exitOf,
|
|
1939
1948
|
tree,
|
|
@@ -1942,30 +1951,30 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1942
1951
|
velocities: () => velocitiesNowOf(snapshot),
|
|
1943
1952
|
// Its own, under its nearest WardicConfig (#434): its exit honours it, not the presence's.
|
|
1944
1953
|
reducedMotion,
|
|
1945
|
-
// Its nearest WardicConfig's (#468): an exit is skipped as its
|
|
1954
|
+
// Its nearest WardicConfig's (#468): an exit is skipped as its Subject's animations are.
|
|
1946
1955
|
skipAnimations,
|
|
1947
1956
|
})
|
|
1948
1957
|
|
|
1949
1958
|
/**
|
|
1950
1959
|
* Merge an emitted frame's value-map into a presence record's snapshot (nothing without one). It
|
|
1951
|
-
* mirrors what the gate accumulates, so an exit departs from the
|
|
1960
|
+
* mirrors what the gate accumulates, so an exit departs from the Subject's actual resting value-map.
|
|
1952
1961
|
*/
|
|
1953
1962
|
export const recordFrameOf = (presence: PresenceRecord.PresenceRecord | undefined): ((value: Values.Values) => void) => (value) => {
|
|
1954
1963
|
if (Predicate.isNotUndefined(presence)) Object.assign(presence.snapshot.current, value)
|
|
1955
1964
|
}
|
|
1956
1965
|
|
|
1957
|
-
/** Tell
|
|
1966
|
+
/** Tell a Subject's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for a Subject with none. */
|
|
1958
1967
|
export const tellStarted = (live: LiveRoutes | undefined, legs: ReadonlyArray<RetargetLegs.Leg>): void => {
|
|
1959
1968
|
if (Predicate.isUndefined(live)) return
|
|
1960
1969
|
live.started(legs)
|
|
1961
1970
|
}
|
|
1962
1971
|
|
|
1963
1972
|
// A Batch member's hold's slot (#665, #746; #672's Q14: the spine's, so it reads no Batch code).
|
|
1964
|
-
/** What a Batch member's hold reads of what its
|
|
1965
|
-
export type HoldHost = Pick<SpineHost, "
|
|
1973
|
+
/** What a Batch member's hold reads of what its Subject's spine hands over (#746). */
|
|
1974
|
+
export type HoldHost = Pick<SpineHost, "subject" | "gate" | "id" | "snapshot" | "owners" | "giveUp" | "keepTheRest" | "driven" | "returning">
|
|
1966
1975
|
|
|
1967
1976
|
/**
|
|
1968
|
-
* A Batch member's
|
|
1977
|
+
* A Batch member's Subject's hold on the groups it takes from its Batch: its transform, or its opacity,
|
|
1969
1978
|
* taken as a leg on a key of it starts or a drag moves it, and given back as its last leg on it ends, or
|
|
1970
1979
|
* at its Batch's next change of it.
|
|
1971
1980
|
*/
|
|
@@ -1980,13 +1989,13 @@ export interface MemberHold {
|
|
|
1980
1989
|
readonly settle: () => void
|
|
1981
1990
|
/** Its drag reads or writes `x`/`y` (`true`): it takes the transform; or hands them back (`false`). */
|
|
1982
1991
|
readonly drag: (on: boolean) => void
|
|
1983
|
-
/** Its
|
|
1992
|
+
/** Its Subject unmounted: every group back to the Batch. */
|
|
1984
1993
|
readonly dispose: () => void
|
|
1985
1994
|
}
|
|
1986
1995
|
|
|
1987
|
-
/** How a spine finds its
|
|
1996
|
+
/** How a spine finds its Subject a Batch member's, and makes its hold. */
|
|
1988
1997
|
export interface MemberHolds {
|
|
1989
|
-
readonly isMember: (
|
|
1998
|
+
readonly isMember: (subject: Subject.Subject) => boolean
|
|
1990
1999
|
readonly make: (host: HoldHost) => MemberHold
|
|
1991
2000
|
}
|
|
1992
2001
|
|
|
@@ -1998,7 +2007,7 @@ export const memberHoldsNow = (): MemberHolds | undefined => holds
|
|
|
1998
2007
|
|
|
1999
2008
|
/**
|
|
2000
2009
|
* Holds made from now on, through `holds` (`createBatch`, as it's called, gives a Batch's): a Batch's
|
|
2001
|
-
* members can be
|
|
2010
|
+
* members can be Wards' Subjects. The first one given stays.
|
|
2002
2011
|
*/
|
|
2003
2012
|
export const provideMemberHolds = (given: MemberHolds): void => {
|
|
2004
2013
|
if (Predicate.isNotUndefined(holds)) return
|
|
@@ -2006,22 +2015,22 @@ export const provideMemberHolds = (given: MemberHolds): void => {
|
|
|
2006
2015
|
}
|
|
2007
2016
|
|
|
2008
2017
|
/**
|
|
2009
|
-
* Each draggable
|
|
2010
|
-
*
|
|
2018
|
+
* Each draggable Subject's spine's drag hook (#665's PR 4): told `true` as its drag reads where the
|
|
2019
|
+
* Subject rests or writes `x`/`y`, and `false` as it hands them back. A Batch member's takes its
|
|
2011
2020
|
* transform from its Batch then, and gives it back.
|
|
2012
2021
|
*/
|
|
2013
|
-
// Module state (#460, Q7): held weakly by the
|
|
2022
|
+
// Module state (#460, Q7): held weakly by the Subject, so it goes with it.
|
|
2014
2023
|
const DRAG_HOOKS = new WeakMap<Subject.Subject, (on: boolean) => void>()
|
|
2015
2024
|
|
|
2016
|
-
/** `
|
|
2017
|
-
export const tellDrag = (
|
|
2018
|
-
UndefinedOr.map(DRAG_HOOKS.get(
|
|
2025
|
+
/** `subject`'s drag hook told `on`, when its spine has one: its binding's drag start and end, and a drag's claim. */
|
|
2026
|
+
export const tellDrag = (subject: Subject.Subject, on: boolean): void => {
|
|
2027
|
+
UndefinedOr.map(DRAG_HOOKS.get(subject), (tell) => tell(on))
|
|
2019
2028
|
}
|
|
2020
2029
|
|
|
2021
2030
|
/**
|
|
2022
|
-
* What a spine calls of its
|
|
2031
|
+
* What a spine calls of its Subject's Live values routed through its binding's props (#130, ADR-0043):
|
|
2023
2032
|
* the routed keys' values now, and each one's change and removal as they come; and the legs each
|
|
2024
|
-
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its
|
|
2033
|
+
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its Subject for them, #443).
|
|
2025
2034
|
*/
|
|
2026
2035
|
// #672 (PR3-Q1): the spine names what it calls, so it reads no `style` code; dom's LiveStyle meets it.
|
|
2027
2036
|
export interface LiveRoutes {
|
|
@@ -2042,7 +2051,7 @@ export interface LiveFollower {
|
|
|
2042
2051
|
}
|
|
2043
2052
|
|
|
2044
2053
|
/**
|
|
2045
|
-
* What a spine calls of its
|
|
2054
|
+
* What a spine calls of its Subject's drag: a new target for `x` or `y` takes over a free drag's
|
|
2046
2055
|
* release in flight (#340). Its binding's drag track gives it.
|
|
2047
2056
|
*/
|
|
2048
2057
|
// #672 (Q15): the spine names what it calls, so it reads no drag code.
|
|
@@ -2050,16 +2059,16 @@ export interface SpineDrag {
|
|
|
2050
2059
|
readonly takeRelease: (retargeted: { readonly x: boolean; readonly y: boolean }) => boolean
|
|
2051
2060
|
}
|
|
2052
2061
|
|
|
2053
|
-
/** What {@link
|
|
2054
|
-
export interface
|
|
2062
|
+
/** What {@link makeSubjectSpine} reads. */
|
|
2063
|
+
export interface SubjectSpineOptions {
|
|
2055
2064
|
/** The provider runtime the legs fork on. */
|
|
2056
2065
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
2057
2066
|
/** The provider-owned flush gate (ADR-0006). */
|
|
2058
2067
|
readonly gate: FlushGate.Shape
|
|
2059
|
-
/** The
|
|
2068
|
+
/** The Subject's gate id. */
|
|
2060
2069
|
readonly id: string
|
|
2061
|
-
/** The mounted
|
|
2062
|
-
readonly
|
|
2070
|
+
/** The mounted Subject. */
|
|
2071
|
+
readonly subject: Subject.Subject
|
|
2063
2072
|
/** Its tag, for a Handoff's check (its Environment routes some keys by it): `undefined` when it isn't known. */
|
|
2064
2073
|
readonly tag: string | undefined
|
|
2065
2074
|
/** Its config now, read where the binding doesn't track. */
|
|
@@ -2119,7 +2128,7 @@ export interface ElementSpineOptions {
|
|
|
2119
2128
|
readonly animation?: AnimationHooks | undefined
|
|
2120
2129
|
/**
|
|
2121
2130
|
* A list's names orchestrated each on their own (#297's PR 2): a name's keys start once its gate
|
|
2122
|
-
* opens, and its starts and settles are told. Omitted for
|
|
2131
|
+
* opens, and its starts and settles are told. Omitted for a Subject that joins nothing and
|
|
2123
2132
|
* provides nothing.
|
|
2124
2133
|
*/
|
|
2125
2134
|
readonly byName?: VariantTree.NameOrchestration | undefined
|
|
@@ -2145,16 +2154,16 @@ const takeEach = (timelineKeys: Timelines.TimelineKeys, values: Values.Values):
|
|
|
2145
2154
|
Arr.forEach(Rec.keys(values), (key) => timelineKeys.taken(key))
|
|
2146
2155
|
}
|
|
2147
2156
|
|
|
2148
|
-
/** What the follower reads of the
|
|
2157
|
+
/** What the follower reads of the Subject's Override stack and drag, untracked. */
|
|
2149
2158
|
export interface FollowNow {
|
|
2150
2159
|
readonly resolved: () => Values.Values
|
|
2151
2160
|
readonly dragging: () => boolean
|
|
2152
2161
|
}
|
|
2153
2162
|
|
|
2154
|
-
/** What an **Imperative animation** tells of its legs on one
|
|
2163
|
+
/** What an **Imperative animation** tells of its legs on one Subject (#433). */
|
|
2155
2164
|
export interface ImperativeHooks {
|
|
2156
2165
|
/**
|
|
2157
|
-
* Every leg it started on the
|
|
2166
|
+
* Every leg it started on the Subject landed, told after the gate's flush of their last frames:
|
|
2158
2167
|
* `landed` false when a key of it was taken by a later animation, which it then never lands (#951).
|
|
2159
2168
|
*/
|
|
2160
2169
|
readonly settled: (landed: boolean) => void
|
|
@@ -2162,7 +2171,7 @@ export interface ImperativeHooks {
|
|
|
2162
2171
|
readonly failed: (cause: Cause.Cause<unknown>) => void
|
|
2163
2172
|
}
|
|
2164
2173
|
|
|
2165
|
-
/** An **Imperative animation** on one
|
|
2174
|
+
/** An **Imperative animation** on one Subject (#433): its legs, built at the call, run through its Playhead. */
|
|
2166
2175
|
export interface ImperativeTrack {
|
|
2167
2176
|
/**
|
|
2168
2177
|
* Run every leg from the Playhead's time: those running end first, so a seek starts them again there,
|
|
@@ -2178,7 +2187,7 @@ export interface ImperativeTrack {
|
|
|
2178
2187
|
}
|
|
2179
2188
|
|
|
2180
2189
|
/**
|
|
2181
|
-
* What
|
|
2190
|
+
* What a Subject's spine hands over (#746, ADR-0067 *Amendment (#746)*): its state and its leg
|
|
2182
2191
|
* machinery, read live, for the two that work on it from outside, `imperative.ts`, which builds an
|
|
2183
2192
|
* **Imperative animation**'s track, and `member-hold.ts`, a Batch member's hold. An app with neither
|
|
2184
2193
|
* ships neither's code. Made at the first call, once a spine.
|
|
@@ -2186,7 +2195,7 @@ export interface ImperativeTrack {
|
|
|
2186
2195
|
export interface SpineHost {
|
|
2187
2196
|
/** The resolution of the last Retarget, whose targets a taken key is noted with. */
|
|
2188
2197
|
readonly lastResolution: () => Resolution | undefined
|
|
2189
|
-
/** The
|
|
2198
|
+
/** The Subject's values, velocities and owners. */
|
|
2190
2199
|
readonly snapshot: Snapshot
|
|
2191
2200
|
/** Each key's running leg. */
|
|
2192
2201
|
readonly owners: Owners
|
|
@@ -2202,7 +2211,7 @@ export interface SpineHost {
|
|
|
2202
2211
|
readonly giveUp: (key: string, running: Running) => void
|
|
2203
2212
|
/** Its `initial` values: a key without one is owned when it's first drawn. */
|
|
2204
2213
|
readonly initialValues: Values.Values
|
|
2205
|
-
/** Own `key` on the
|
|
2214
|
+
/** Own `key` on the Subject (its style's value gives way). */
|
|
2206
2215
|
readonly ownValue: (key: string) => void
|
|
2207
2216
|
/** Start `key` where it's drawn, noting what it starts from in `started`. */
|
|
2208
2217
|
readonly startKey: (key: string, like: number | string, started: Record<string, string>) => void
|
|
@@ -2212,7 +2221,7 @@ export interface SpineHost {
|
|
|
2212
2221
|
readonly reducedMotion: () => boolean
|
|
2213
2222
|
/** Whether its animations are skipped now (#468). */
|
|
2214
2223
|
readonly skipAnimations: () => boolean
|
|
2215
|
-
readonly
|
|
2224
|
+
readonly subject: Subject.Subject
|
|
2216
2225
|
readonly positionalKeys: ReducedMotion.PositionalKeys["Service"]
|
|
2217
2226
|
readonly defaultTransition: DefaultTransition.DefaultTransition["Service"]
|
|
2218
2227
|
/** The Environment's unit scale, its legs' rest thresholds' for `x`, `y` and `z` (ADR-0069 decision 8). */
|
|
@@ -2240,20 +2249,20 @@ export interface SpineHost {
|
|
|
2240
2249
|
readonly recordFrame: (value: Values.Values) => void
|
|
2241
2250
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
2242
2251
|
/** Its Variable values' Key rule (#55): a blend's are built with it. */
|
|
2243
|
-
readonly
|
|
2252
|
+
readonly subjectRules: ReadonlyArray<InterpolatorRegistry.KeyRule>
|
|
2244
2253
|
/** The Environment's Measured pairs (#430, #672). */
|
|
2245
2254
|
readonly measuredPairs: MeasuredPairs.Shape
|
|
2246
2255
|
/** The Environment's Variable values (#55, #672). */
|
|
2247
2256
|
readonly variableValues: VariableValues.Shape
|
|
2248
2257
|
}
|
|
2249
2258
|
|
|
2250
|
-
/** A mounted
|
|
2251
|
-
export interface
|
|
2259
|
+
/** A mounted Subject's spine. */
|
|
2260
|
+
export interface SubjectSpine {
|
|
2252
2261
|
/** A Retarget toward `resolution`: called by the binding on each change of its target, untracked. */
|
|
2253
2262
|
readonly retarget: (resolution: Resolution) => void
|
|
2254
|
-
/** Follow the
|
|
2263
|
+
/** Follow the Subject's Live values in `style` (#130), from its first routed key on. */
|
|
2255
2264
|
readonly follow: (now: FollowNow) => void
|
|
2256
|
-
/** The
|
|
2265
|
+
/** The Subject's teardown: following stops, and the legs end. */
|
|
2257
2266
|
readonly dispose: () => void
|
|
2258
2267
|
/**
|
|
2259
2268
|
* Start where a leaver is drawn (#286, ADR-0048), before the first Retarget: each key's value and
|
|
@@ -2262,7 +2271,7 @@ export interface ElementSpine {
|
|
|
2262
2271
|
*/
|
|
2263
2272
|
readonly seed: (from: PresenceRecord.PresenceSeed) => void
|
|
2264
2273
|
/**
|
|
2265
|
-
* What the spine hands over (#746): to an **Imperative animation** of the
|
|
2274
|
+
* What the spine hands over (#746): to an **Imperative animation** of the Subject (#433), whose track
|
|
2266
2275
|
* `imperative.ts` builds over it, and to a Batch member's hold (#665). Made at the first call, once.
|
|
2267
2276
|
*/
|
|
2268
2277
|
readonly host: () => SpineHost
|
|
@@ -2270,15 +2279,6 @@ export interface ElementSpine {
|
|
|
2270
2279
|
readonly stop: () => void
|
|
2271
2280
|
}
|
|
2272
2281
|
|
|
2273
|
-
/**
|
|
2274
|
-
* A mounted element's spine: its Retarget, the returns to its Base values, the follower of its
|
|
2275
|
-
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
2276
|
-
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
2277
|
-
* ElementSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
2278
|
-
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
2279
|
-
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
2280
|
-
* fiber Scope interrupts what's left when the provider ends.
|
|
2281
|
-
*/
|
|
2282
2282
|
/** Each runtime's unit scale, read once: a mount reads a WeakMap, not a run of its own. */
|
|
2283
2283
|
// Module state (#460, Q7): held weakly by the runtime, so it goes with it.
|
|
2284
2284
|
const UNIT_SCALES = new WeakMap<object, UnitScale.Rule>()
|
|
@@ -2292,8 +2292,17 @@ export const unitScaleOf = (runtime: WardicServices.Runner<WardicServices.Wardic
|
|
|
2292
2292
|
return read
|
|
2293
2293
|
}
|
|
2294
2294
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2295
|
+
/**
|
|
2296
|
+
* A mounted Subject's spine: its Retarget, the returns to its Base values, the follower of its
|
|
2297
|
+
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
2298
|
+
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
2299
|
+
* SubjectSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
2300
|
+
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
2301
|
+
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
2302
|
+
* fiber Scope interrupts what's left when the provider ends.
|
|
2303
|
+
*/
|
|
2304
|
+
export const makeSubjectSpine = (options: SubjectSpineOptions): SubjectSpine => {
|
|
2305
|
+
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
|
|
2297
2306
|
// The Environment's unit scale (ADR-0069 decision 8, #883): read from the runtime the spine already holds,
|
|
2298
2307
|
// so no binding passes it; 1, Motion's own, unless the Environment's Layers give another.
|
|
2299
2308
|
const unitScale = unitScaleOf(runtime)
|
|
@@ -2302,9 +2311,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2302
2311
|
let handoff = options.handoff
|
|
2303
2312
|
// Its mount tells nothing when it starts at its `animate` (#448): on until its first Retarget.
|
|
2304
2313
|
let quiet = start.quiet
|
|
2305
|
-
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this
|
|
2314
|
+
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this Subject,
|
|
2306
2315
|
// added to each leg it starts, so a `var()` end blends what it resolves to here.
|
|
2307
|
-
const
|
|
2316
|
+
const subjectRules = [variableValues.values(subject)]
|
|
2308
2317
|
const recordFrame = recordFrameOf(presence)
|
|
2309
2318
|
// Whether its animations are skipped (#468): never, with nothing given.
|
|
2310
2319
|
const skipAnimations = UndefinedOr.match(options.skipAnimations, { onUndefined: () => constFalse, onDefined: identity })
|
|
@@ -2327,7 +2336,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2327
2336
|
featuresSeen = services
|
|
2328
2337
|
const timelines = Context.getOrUndefined(services as Context.Context<Timelines.Timelines>, Timelines.Timelines)
|
|
2329
2338
|
if (Predicate.isUndefined(timelines)) return undefined
|
|
2330
|
-
timelineKeys = timelines.keysOf({ runtime, gate, id,
|
|
2339
|
+
timelineKeys = timelines.keysOf({ runtime, gate, id, subject, live: routes })
|
|
2331
2340
|
return timelineKeys
|
|
2332
2341
|
}
|
|
2333
2342
|
|
|
@@ -2335,9 +2344,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2335
2344
|
// ones returning to their Base value until that return settles (ADR-0022). Both are
|
|
2336
2345
|
// the spine's: a Retarget mid-return carries them again, so a return is never
|
|
2337
2346
|
// frozen half-way, and a key that settled has left them, so a Retarget of the same
|
|
2338
|
-
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag
|
|
2347
|
+
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag Subject, the keys
|
|
2339
2348
|
// the drag moves leave the return while it runs, so they stay where it dropped them (C9)
|
|
2340
|
-
// until an entry sets them again; a projected
|
|
2349
|
+
// until an entry sets them again; a projected Subject's drag moves none, its projection
|
|
2341
2350
|
// target does (ADR-0016), and its own translate returns as any key does (#363).
|
|
2342
2351
|
const driven = new Map<string, number | string>()
|
|
2343
2352
|
let returning = new Map<string, BaseValue.BaseSource>()
|
|
@@ -2349,7 +2358,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2349
2358
|
}
|
|
2350
2359
|
|
|
2351
2360
|
// A Retarget's returns have settled (ADR-0022, D4). A key back at its `style` value is
|
|
2352
|
-
// handed back to the
|
|
2361
|
+
// handed back to the Subject's style, so a later style change shows at rest and the
|
|
2353
2362
|
// next gesture starts from it; any other key rests at its Base value where the gate drew
|
|
2354
2363
|
// it, and leaves the target. A key a later Retarget took over is left alone. A routed key (#130) stays
|
|
2355
2364
|
// in the gate, handed to the follower, which writes its value from now on.
|
|
@@ -2366,7 +2375,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2366
2375
|
Arr.forEach(Arr.filter(toStyle, routedNow), (key) => handBack(key))
|
|
2367
2376
|
const handedBack = Arr.filter(toStyle, Predicate.not(routedNow))
|
|
2368
2377
|
if (Arr.isReadonlyArrayEmpty(handedBack)) return
|
|
2369
|
-
// The gate writes the user's current value back, as the
|
|
2378
|
+
// The gate writes the user's current value back, as the Subject's `style` would
|
|
2370
2379
|
// (ADR-0034). A key gone from the user's style by now is cleared, not restored stale.
|
|
2371
2380
|
const restore = UndefinedOr.map(styleNow, (now) => {
|
|
2372
2381
|
const style = now()
|
|
@@ -2392,7 +2401,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2392
2401
|
// The keys an Imperative animation took (#433), each with the target the Override stack had for it
|
|
2393
2402
|
// then: a Retarget leaves each where the animation leaves it while its target is still that one, and
|
|
2394
2403
|
// takes it back once it isn't, as a newer animation of Motion's value takes it (latest-wins).
|
|
2395
|
-
// Every
|
|
2404
|
+
// Every Subject reads it, nearly none sets it (#460): the shared empty one until the first key taken.
|
|
2396
2405
|
let taken: Map<string, number | string | undefined> = NONE_TAKEN
|
|
2397
2406
|
// The legs that gave up a key in this Retarget: what each still draws is worked out at its end.
|
|
2398
2407
|
const losing: Array<Running> = []
|
|
@@ -2429,7 +2438,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2429
2438
|
})
|
|
2430
2439
|
}
|
|
2431
2440
|
|
|
2432
|
-
// The
|
|
2441
|
+
// The Subject's waiting Transition ends (#508), made at its first: most Subjects never have one.
|
|
2433
2442
|
let waiting: WaitingEnds | undefined
|
|
2434
2443
|
|
|
2435
2444
|
// A leg with no key left ends. Its fiber ends inline (ADR-0027, *Amendment (#200)*); one its token
|
|
@@ -2504,7 +2513,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2504
2513
|
}
|
|
2505
2514
|
|
|
2506
2515
|
// A Path's turn goes back to 0 once no leg draws it (#460, ADR-0065 decision 3): after a Retarget
|
|
2507
|
-
// whose legs don't turn, a stop, a cancel. Most
|
|
2516
|
+
// whose legs don't turn, a stop, a cancel. Most Subjects never turn: a guard.
|
|
2508
2517
|
const turnBack = (): void => {
|
|
2509
2518
|
const turn = snapshot.values[PATH_ROTATION]
|
|
2510
2519
|
if (Bool.or(Predicate.isUndefined(turn), turn === 0)) return
|
|
@@ -2561,7 +2570,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2561
2570
|
|
|
2562
2571
|
/**
|
|
2563
2572
|
* A leg's run into its sink: one dispatcher, each sink built for the leg that needs it, a
|
|
2564
|
-
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the
|
|
2573
|
+
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the Subject's
|
|
2565
2574
|
* Key rules when its change holds a Variable value (`variables`, #542).
|
|
2566
2575
|
*/
|
|
2567
2576
|
const legProgram = (leg: RetargetLegs.Leg, running: Running, variables: boolean): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
@@ -2591,7 +2600,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2591
2600
|
// rather than replacing it, so the drag's direct-set x/y survive alongside the
|
|
2592
2601
|
// spring's keys (drag owns x/y, spring owns the rest) and the post-drag
|
|
2593
2602
|
// handoff continues from the rested position. Only the keys it still draws (#325).
|
|
2594
|
-
// In place, as the Follow sink writes (#659): a spread made two records per
|
|
2603
|
+
// In place, as the Follow sink writes (#659): a spread made two records per Subject per
|
|
2595
2604
|
// frame. The Snapshot's records are always its own (`snapshotOf`, `emptySnapshotOf`), and
|
|
2596
2605
|
// whatever keeps one copies it or reads it at once.
|
|
2597
2606
|
const value = running.values(frame.value)
|
|
@@ -2614,7 +2623,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2614
2623
|
)
|
|
2615
2624
|
}
|
|
2616
2625
|
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
|
|
2617
|
-
// (#659; #895: a spread made a record per
|
|
2626
|
+
// (#659; #895: a spread made a record per Subject per frame). A blend's last two are kept for its keys'
|
|
2618
2627
|
// velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
|
|
2619
2628
|
const sink = (frame: Frame.Frame<Values.Values>, dt: number): undefined => {
|
|
2620
2629
|
const value = running.values(frame.value)
|
|
@@ -2635,7 +2644,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2635
2644
|
}
|
|
2636
2645
|
// Per leg (#460): a statement, Effect's calls data-first.
|
|
2637
2646
|
let built = Effect.suspend(leg.machine)
|
|
2638
|
-
if (variables) built = InterpolatorRegistry.withKeyRules(built,
|
|
2647
|
+
if (variables) built = InterpolatorRegistry.withKeyRules(built, subjectRules)
|
|
2639
2648
|
return Effect.flatMap(built, (machine) => Machine.run(machine, sink, running))
|
|
2640
2649
|
}
|
|
2641
2650
|
|
|
@@ -2646,7 +2655,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2646
2655
|
// Per leg (#460): statements.
|
|
2647
2656
|
if (Exit.isSuccess(exit)) {
|
|
2648
2657
|
// A Superseded leg (#200) counts toward nothing, nor tells a name: the next Retarget's legs
|
|
2649
|
-
// land. Nothing made for it: a Retarget ends its
|
|
2658
|
+
// land. Nothing made for it: a Retarget ends its Subject's legs inline.
|
|
2650
2659
|
const end = exit.value
|
|
2651
2660
|
if (Supersede.isSuperseded(end)) return Effect.void
|
|
2652
2661
|
return Effect.sync(() => {
|
|
@@ -2668,7 +2677,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2668
2677
|
}
|
|
2669
2678
|
|
|
2670
2679
|
// A gated Retarget (ADR-0007 `when`, #325): a running key it resolves to its leg's target runs on,
|
|
2671
|
-
// the
|
|
2680
|
+
// the Subject reported unsettled meanwhile, when an earlier change started that leg; every other
|
|
2672
2681
|
// running key freezes where it is. The change the gate holds may have started legs just before
|
|
2673
2682
|
// it shut (a child Retargets before its provider's effect resets its `beforeChildren` wait; an
|
|
2674
2683
|
// `afterChildren` provider starts before its children report): those freeze too, as before.
|
|
@@ -2749,7 +2758,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2749
2758
|
keepTheRest,
|
|
2750
2759
|
reducedMotion: options.reducedMotion,
|
|
2751
2760
|
skipAnimations,
|
|
2752
|
-
|
|
2761
|
+
subject,
|
|
2753
2762
|
positionalKeys,
|
|
2754
2763
|
defaultTransition,
|
|
2755
2764
|
unitScale,
|
|
@@ -2765,7 +2774,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2765
2774
|
id,
|
|
2766
2775
|
recordFrame,
|
|
2767
2776
|
runtime,
|
|
2768
|
-
|
|
2777
|
+
subjectRules,
|
|
2769
2778
|
measuredPairs,
|
|
2770
2779
|
variableValues,
|
|
2771
2780
|
}
|
|
@@ -2773,37 +2782,37 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2773
2782
|
return handedOver
|
|
2774
2783
|
}
|
|
2775
2784
|
|
|
2776
|
-
// --- A Batch member's
|
|
2785
|
+
// --- A Batch member's Subject (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
|
|
2777
2786
|
|
|
2778
|
-
// Its hold on what it takes from its Batch: made as its
|
|
2779
|
-
// Retarget or a drag. Nearly no
|
|
2787
|
+
// Its hold on what it takes from its Batch: made as its Subject is first found a member's, at a
|
|
2788
|
+
// Retarget or a drag. Nearly no Subject is one: the rest pay a WeakMap read a Retarget.
|
|
2780
2789
|
let memberHold: MemberHold | undefined
|
|
2781
2790
|
const holdNow = (): MemberHold | undefined => {
|
|
2782
2791
|
if (Predicate.isNotUndefined(memberHold)) return memberHold
|
|
2783
2792
|
// An app with no Batch has no way to make one, nor any member.
|
|
2784
2793
|
const holds = memberHoldsNow()
|
|
2785
2794
|
if (Predicate.isUndefined(holds)) return undefined
|
|
2786
|
-
if (!holds.isMember(
|
|
2795
|
+
if (!holds.isMember(subject)) return undefined
|
|
2787
2796
|
memberHold = holds.make(host())
|
|
2788
2797
|
return memberHold
|
|
2789
2798
|
}
|
|
2790
|
-
// A draggable
|
|
2799
|
+
// A draggable Subject's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
|
|
2791
2800
|
if (Predicate.isNotUndefined(options.dragAxis)) {
|
|
2792
|
-
DRAG_HOOKS.set(
|
|
2801
|
+
DRAG_HOOKS.set(subject, (on) => {
|
|
2793
2802
|
const member = holdNow()
|
|
2794
2803
|
if (Predicate.isNotUndefined(member)) member.drag(on)
|
|
2795
2804
|
})
|
|
2796
2805
|
}
|
|
2797
2806
|
|
|
2798
2807
|
const retarget = (given: Resolution): void => {
|
|
2799
|
-
// A Controls change (#433): the
|
|
2808
|
+
// A Controls change (#433): the Subject is in it from the Retarget it makes it run, held or not.
|
|
2800
2809
|
if (given.change !== joined) joinChange(given.change)
|
|
2801
2810
|
// A key an entry sets isn't its Live value's from this Retarget on, held or not: its Timeline value
|
|
2802
2811
|
// stops (#240), and the gate draws the key in the flush that writes the entry's first value.
|
|
2803
2812
|
if (Predicate.isNotUndefined(timelineKeys)) takeEach(timelineKeys, given.resolved)
|
|
2804
2813
|
|
|
2805
2814
|
// `when` start-gate (ADR-0007): when canStart() is false, the keys whose target changed freeze
|
|
2806
|
-
// where they are (#325: the rest run on), and the
|
|
2815
|
+
// where they are (#325: the rest run on), and the Subject waits; the binding retargets once
|
|
2807
2816
|
// the gate flips true.
|
|
2808
2817
|
if (Predicate.isNotUndefined(canStart) && !canStart()) {
|
|
2809
2818
|
hold(given)
|
|
@@ -2857,7 +2866,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2857
2866
|
if (Predicate.isNotUndefined(keys)) Arr.forEach(dragMoves(), (key) => keys.taken(key))
|
|
2858
2867
|
}
|
|
2859
2868
|
returning = new Map()
|
|
2860
|
-
// Over the Map itself: copying it into an array first costs ~20 times the walk, per
|
|
2869
|
+
// Over the Map itself: copying it into an array first costs ~20 times the walk, per Subject
|
|
2861
2870
|
// per Retarget (#69's PR 4). Deleting the entry being visited is safe in a Map's iteration.
|
|
2862
2871
|
Iter.forEach(driven, ([key, like]) => {
|
|
2863
2872
|
// A translate key the strip below holds back returns once the drag lets go.
|
|
@@ -2882,12 +2891,12 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2882
2891
|
if (taken.size > 0) Iter.forEach(taken, ([key]) => {
|
|
2883
2892
|
delete t[key]
|
|
2884
2893
|
})
|
|
2885
|
-
// A Batch member's
|
|
2894
|
+
// A Batch member's Subject (#665's PR 4, Q53): a group it moves is taken from its Batch first, and a
|
|
2886
2895
|
// key it'd leave where the Batch draws it stays the Batch's. A drag takes `x` and `y`.
|
|
2887
2896
|
const member = holdNow()
|
|
2888
2897
|
if (Predicate.isNotUndefined(member)) member.retarget(t, held)
|
|
2889
2898
|
// The keys this Retarget returns; once it lands, a key back at its `style` value is
|
|
2890
|
-
// handed back to the
|
|
2899
|
+
// handed back to the Subject's style (D4) and the rest rest where the gate drew them.
|
|
2891
2900
|
const returns = [...returning]
|
|
2892
2901
|
// The transition, read at Retarget time so a change applies to the next Retarget. A child
|
|
2893
2902
|
// with no local transition inherits the parent context's (ADR-0007).
|
|
@@ -2908,7 +2917,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2908
2917
|
if (--legs !== 0) return
|
|
2909
2918
|
settleReturns(returns)
|
|
2910
2919
|
// The Retarget settled with its last leg (#257): told once the gate has flushed its last frame,
|
|
2911
|
-
// so the
|
|
2920
|
+
// so the Subject shows where it landed. Its Controls change hears it then too (#433).
|
|
2912
2921
|
if (Predicate.isNotUndefined(animation)) gate.afterFlush(() => animation.settled(resolution, previous, c))
|
|
2913
2922
|
leaveAfterFlush()
|
|
2914
2923
|
}
|
|
@@ -2932,7 +2941,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2932
2941
|
if (startedTold) return tellFailed(error)
|
|
2933
2942
|
failedEarly = { error }
|
|
2934
2943
|
}
|
|
2935
|
-
// The
|
|
2944
|
+
// The Subject settles with its last leg (ADR-0024, D5): a string leg can outlast the
|
|
2936
2945
|
// numeric one, so each leg's frames report, and only the last leg's settle reports done.
|
|
2937
2946
|
let reporting = 0
|
|
2938
2947
|
let settled = 0
|
|
@@ -2945,9 +2954,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2945
2954
|
|
|
2946
2955
|
// The Retarget's transitions, read before its keys: a key already there asks its own for a
|
|
2947
2956
|
// velocity (#448).
|
|
2948
|
-
const
|
|
2957
|
+
const wardTransition = VariantTree.ownOrInherited(c.transition, parent)
|
|
2949
2958
|
// The base target's own transition (#277): the keys its entry drives animate on it.
|
|
2950
|
-
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition,
|
|
2959
|
+
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, wardTransition)
|
|
2951
2960
|
// Fold the per-child stagger delay (ADR-0007) into the effective
|
|
2952
2961
|
// transition.delay = base.delay + computedDelay. extraDelay() is read
|
|
2953
2962
|
// at Retarget time so a re-snapshot before this start is reflected. Each name's keys take that
|
|
@@ -2956,11 +2965,11 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2956
2965
|
const extra = extraOf(extraDelay, layers[0])
|
|
2957
2966
|
const transition = staggeredOf(baseTransition, extra, options.reuse)
|
|
2958
2967
|
// With an entry's own transition (#277, #291), each key animates on its entry's: the base's keys
|
|
2959
|
-
// on the base target's, each active gesture's on its target's, else the
|
|
2968
|
+
// on the base target's, each active gesture's on its target's, else the Subject's, as Motion's
|
|
2960
2969
|
// each animation type runs on its own.
|
|
2961
2970
|
// A list's names (#297) split them too, each name's at its own delay; a list's returns run on the
|
|
2962
|
-
//
|
|
2963
|
-
// Guards, not matches: per Retarget, per
|
|
2971
|
+
// Subject's transition, in a group of their own, last.
|
|
2972
|
+
// Guards, not matches: per Retarget, per Subject. A list's work (#297) is done apart, for a list:
|
|
2964
2973
|
// the Retarget's other calls keep their inlining (docs/agents/effect-first.md).
|
|
2965
2974
|
const listed = Arr.isArray(resolution.variant)
|
|
2966
2975
|
// A list's names each wait for their own `when` (#297's PR 2): the entries whose gate is shut now.
|
|
@@ -2977,7 +2986,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2977
2986
|
// target (no motion).
|
|
2978
2987
|
//
|
|
2979
2988
|
// Every key's Own value is read first, at its first need, before anything writes it, so a return
|
|
2980
|
-
// later finds the
|
|
2989
|
+
// later finds the Subject's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
|
|
2981
2990
|
// a lookup. A transform key reads nothing.
|
|
2982
2991
|
let stays: Set<string> | undefined
|
|
2983
2992
|
let carried: Array<Running> | undefined
|
|
@@ -3035,7 +3044,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3035
3044
|
// Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
|
|
3036
3045
|
// mount's never asks (#475): Motion animates nothing at a first render that starts at its
|
|
3037
3046
|
// `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
|
|
3038
|
-
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition,
|
|
3047
|
+
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, wardTransition), key))) {
|
|
3039
3048
|
if (Predicate.isUndefined(stays)) stays = new Set()
|
|
3040
3049
|
stays.add(key)
|
|
3041
3050
|
if (Predicate.isUndefined(there)) there = {}
|
|
@@ -3056,7 +3065,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3056
3065
|
owners.forEach(giveUpUnresolved)
|
|
3057
3066
|
keepTheRest()
|
|
3058
3067
|
// A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
|
|
3059
|
-
// the resolved target doesn't name joins the keys already there, written with them as the
|
|
3068
|
+
// the resolved target doesn't name joins the keys already there, written with them as the Subject's first
|
|
3060
3069
|
// commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
|
|
3061
3070
|
// any. A Batch member's are its Batch's, which draws its groups.
|
|
3062
3071
|
if (Predicate.isUndefined(lastResolution)) {
|
|
@@ -3130,7 +3139,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3130
3139
|
// The legs (#48, ADR-0044 decision 8): one pure builder, which a server render's Appear
|
|
3131
3140
|
// animation samples too, so the two can't drift. Built here; each leg's machine is built
|
|
3132
3141
|
// in its own fiber, so a transition core rejects (#66, ADR-0025 *Amendment (#66)*) fails
|
|
3133
|
-
// that leg alone, reported as any leg's failure is, while the
|
|
3142
|
+
// that leg alone, reported as any leg's failure is, while the Subject's other legs run on.
|
|
3134
3143
|
// The returns to a moving Live value (#130, ADR-0043 decision 6): a number's follows it,
|
|
3135
3144
|
// in a leg of its own, and lands on it; the rest return to where it is now. Looked for
|
|
3136
3145
|
// only when this Retarget returns a key.
|
|
@@ -3145,7 +3154,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3145
3154
|
// animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
|
|
3146
3155
|
let measured: RetargetLegs.MeasuredPairs | undefined
|
|
3147
3156
|
if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
|
|
3148
|
-
measured = measuredOf(measuredPairs,
|
|
3157
|
+
measured = measuredOf(measuredPairs, subject, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id)
|
|
3149
3158
|
}
|
|
3150
3159
|
let told: ToldNames | undefined
|
|
3151
3160
|
if (!silent) told = namesToldOf(animation, resolution, lastResolution)
|
|
@@ -3159,7 +3168,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3159
3168
|
retargetLegs = RetargetLegs.legsOf(from, fresh, transition, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale)
|
|
3160
3169
|
}
|
|
3161
3170
|
if (Predicate.isNotUndefined(groups)) {
|
|
3162
|
-
const split = splitLegsOf(fresh, from, groups, resolution, listed, transition,
|
|
3171
|
+
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)
|
|
3163
3172
|
retargetLegs = split.legs
|
|
3164
3173
|
legGroups = split.tags
|
|
3165
3174
|
}
|
|
@@ -3211,9 +3220,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3211
3220
|
}
|
|
3212
3221
|
// Its Live routes hear the legs it starts (#443, PR4-Q1).
|
|
3213
3222
|
tellStarted(live, retargetLegs)
|
|
3214
|
-
// The
|
|
3223
|
+
// The Subject's Key rules only for a change a Variable value is in (#542).
|
|
3215
3224
|
const variables = holdsVariable(variableValues, from, fresh, manyStops)
|
|
3216
|
-
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per
|
|
3225
|
+
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per Subject). Each
|
|
3217
3226
|
// leg draws the keys it animates (#325) until a later Retarget takes them.
|
|
3218
3227
|
Arr.forEach(retargetLegs, (leg: RetargetLegs.Leg, i): void => {
|
|
3219
3228
|
if (Predicate.isNotUndefined(legGates)) gateNow = legGates[i]
|
|
@@ -3271,7 +3280,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3271
3280
|
// A turn none of its legs draws now goes back (#460).
|
|
3272
3281
|
turnBack()
|
|
3273
3282
|
// The keys already there (#448), written with each key the Retarget moves at where it starts, as
|
|
3274
|
-
// its leg's first frame writes it: the
|
|
3283
|
+
// its leg's first frame writes it: the Subject's first commit, which takes its Starting style off,
|
|
3275
3284
|
// holds every key, whatever frame the legs first draw in (a gated name's draws later).
|
|
3276
3285
|
if (Predicate.isNotUndefined(there)) {
|
|
3277
3286
|
const written = { ...from, ...there }
|
|
@@ -3279,7 +3288,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3279
3288
|
recordFrame(written)
|
|
3280
3289
|
}
|
|
3281
3290
|
// The Retarget started, its legs on their way (#257); with none, its own or carried, it landed
|
|
3282
|
-
// at once (#325): its returns settle, and the
|
|
3291
|
+
// at once (#325): its returns settle, and the Subject reports settled at the gate's next flush,
|
|
3283
3292
|
// after the effects that start its orchestration's wait (ADR-0007).
|
|
3284
3293
|
previous = lastResolution
|
|
3285
3294
|
lastResolution = resolution
|
|
@@ -3309,14 +3318,14 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3309
3318
|
|
|
3310
3319
|
// --- Live values in `style` (#130, ADR-0043) ------------------------------
|
|
3311
3320
|
// A routed key (a Live value, or a transform key) is its `style` link, live: while no entry of
|
|
3312
|
-
// the Override stack sets it, no return is running to it and no drag moves it, the
|
|
3321
|
+
// the Override stack sets it, no return is running to it and no drag moves it, the Subject
|
|
3313
3322
|
// follows it, written through the gate on every change. A return hands it back here when it
|
|
3314
3323
|
// settles (`settleReturns`). The Starting style showed each one's value at render; from mount
|
|
3315
3324
|
// the gate holds them.
|
|
3316
3325
|
const follow = (now: FollowNow): void => {
|
|
3317
3326
|
if (Predicate.isUndefined(live)) return
|
|
3318
3327
|
const routes = live
|
|
3319
|
-
// Built at the first routed key, at mount or later:
|
|
3328
|
+
// Built at the first routed key, at mount or later: a Subject whose `style` routes none builds nothing.
|
|
3320
3329
|
routes.whenRouted(() => {
|
|
3321
3330
|
// Read at each ask: `projected` is a getter while the track waits for `drag` (#551, #582).
|
|
3322
3331
|
const dragHolds = (): boolean => Bool.and(Bool.not(options.projected), Predicate.isNotUndefined(options.dragAxis))
|
|
@@ -3339,7 +3348,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3339
3348
|
gate.write(id, values)
|
|
3340
3349
|
recordFrame(values)
|
|
3341
3350
|
}
|
|
3342
|
-
// The
|
|
3351
|
+
// The Subject shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
|
|
3343
3352
|
const shown = (key: string): void => {
|
|
3344
3353
|
const keys = timelineKeysNow(routes)
|
|
3345
3354
|
if (Predicate.isNotUndefined(keys)) keys.shown(key)
|
|
@@ -3372,7 +3381,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3372
3381
|
delete snapshot.values[key]
|
|
3373
3382
|
delete snapshot.velocities[key]
|
|
3374
3383
|
if (Predicate.isNotUndefined(presence)) delete presence.snapshot.current[key]
|
|
3375
|
-
// Gone from `style`: the
|
|
3384
|
+
// Gone from `style`: the Subject's own value comes back, or none, its Environment's default now.
|
|
3376
3385
|
const restore = Option.match(ownValues.styleValueOf(UndefinedOr.match(styleNow, { onUndefined: constUndefined, onDefined: (style) => style() }), key), {
|
|
3377
3386
|
onNone: () => "",
|
|
3378
3387
|
onSome: String,
|
|
@@ -3402,8 +3411,8 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3402
3411
|
}
|
|
3403
3412
|
|
|
3404
3413
|
// A child back under its key (#286): its values and velocities from where the leaver is drawn, a
|
|
3405
|
-
// projected
|
|
3406
|
-
//
|
|
3414
|
+
// projected Subject's own translate among them (#363). Drawn at the end of the task, so nothing
|
|
3415
|
+
// draws the Subject at its `initial` first: not in the mount effect it's called in, where the
|
|
3407
3416
|
// first commit's Starting-style switch would flush Solid 2 inside an effect.
|
|
3408
3417
|
const seed = (from: PresenceRecord.PresenceSeed): void => {
|
|
3409
3418
|
const values = from.values
|
|
@@ -3440,7 +3449,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3440
3449
|
* one at mount; `sink` as it is otherwise. `config` reads it untracked.
|
|
3441
3450
|
*/
|
|
3442
3451
|
export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["onUpdate"], config: () => Config.SpineConfig): FlushGate.Sink => {
|
|
3443
|
-
// Per
|
|
3452
|
+
// Per Subject at mount: most have none, and pay a check.
|
|
3444
3453
|
if (Predicate.isUndefined(atMount)) return sink
|
|
3445
3454
|
return {
|
|
3446
3455
|
...sink,
|
|
@@ -3453,8 +3462,8 @@ export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["
|
|
|
3453
3462
|
|
|
3454
3463
|
/**
|
|
3455
3464
|
* A Retarget's note of the keys it started from their Base value, or returned to it (ADR-0022): run at
|
|
3456
|
-
* the head of its first leg, cold path (no fiber of its own: forking one per
|
|
3457
|
-
* at a 1000-
|
|
3465
|
+
* the head of its first leg, cold path (no fiber of its own: forking one per Subject cost 10-20 µs each
|
|
3466
|
+
* at a 1000-Subject mount).
|
|
3458
3467
|
*/
|
|
3459
3468
|
export const baseLog = (id: string, started: Record<string, string>, returns: ReadonlyArray<readonly [string, BaseValue.BaseSource]>): Effect.Effect<void> =>
|
|
3460
3469
|
Effect.logDebug("wardic.base: a key with no value started from, or returned to, its Base value (ADR-0022)").pipe(
|
|
@@ -3475,10 +3484,10 @@ const liveTargetOf = (ownValues: OwnValues.Shape, routes: LiveRoutes, key: strin
|
|
|
3475
3484
|
}
|
|
3476
3485
|
}
|
|
3477
3486
|
|
|
3478
|
-
/** Whether a value is one
|
|
3487
|
+
/** Whether a value is one a Subject can take: a number or a string. */
|
|
3479
3488
|
const isValue = (value: unknown): value is number | string => Bool.or(Predicate.isNumber(value), Predicate.isString(value))
|
|
3480
3489
|
|
|
3481
|
-
/** A provider runtime's `AtomRegistry`, read on first need:
|
|
3490
|
+
/** A provider runtime's `AtomRegistry`, read on first need: a Subject with no Atom never reads it. */
|
|
3482
3491
|
export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicServices>): (() => AtomRegistry.AtomRegistry) => {
|
|
3483
3492
|
let registry: AtomRegistry.AtomRegistry | undefined
|
|
3484
3493
|
return () => {
|
|
@@ -3487,7 +3496,7 @@ export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicS
|
|
|
3487
3496
|
}
|
|
3488
3497
|
}
|
|
3489
3498
|
|
|
3490
|
-
/** Whether a config makes its
|
|
3499
|
+
/** Whether a config makes its Subject a layout node: `layout` (or a mode), or a `layoutId`. */
|
|
3491
3500
|
export const isLayoutNode = (c: Config.SpineConfig): boolean =>
|
|
3492
3501
|
Bool.or(Bool.and(Predicate.isNotUndefined(c.layout), c.layout !== false), Predicate.isNotUndefined(c.layoutId))
|
|
3493
3502
|
|