@wardic/core 1.3.1 → 1.4.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 +12 -6
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +374 -30
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +16 -0
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +22 -8
- 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 +14 -8
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +93 -34
- 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 +11 -8
- package/dist/InputFeed.d.ts.map +1 -1
- package/dist/InputFeed.js +18 -37
- package/dist/InputFeed.js.map +1 -1
- package/dist/InputSource.d.ts +3 -3
- package/dist/InputSource.js +2 -2
- 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 +16 -9
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +204 -27
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +21 -8
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +184 -60
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +16 -9
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +9 -9
- package/dist/Projection.js +2 -2
- package/dist/Recognizer.d.ts +2 -2
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +15 -10
- 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 +1 -1
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +2 -1
- 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 +11 -3
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +190 -39
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/guarded.d.ts +16 -0
- package/dist/internal/guarded.d.ts.map +1 -0
- package/dist/internal/guarded.js +68 -0
- package/dist/internal/guarded.js.map +1 -0
- 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/stepper.d.ts +21 -4
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +21 -5
- 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 +45 -39
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +59 -35
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +11 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/AppearHandoff.js.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +21 -17
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/Config.js.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 +54 -50
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +201 -77
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +6 -3
- package/dist/unstable/FrameEffects.d.ts.map +1 -1
- package/dist/unstable/FrameEffects.js +14 -3
- package/dist/unstable/FrameEffects.js.map +1 -1
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +42 -13
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +279 -88
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/MeasuredPairs.d.ts +6 -2
- package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
- package/dist/unstable/MeasuredPairs.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +30 -26
- 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 +8 -1
- package/dist/unstable/Report.d.ts.map +1 -1
- package/dist/unstable/Report.js +18 -2
- package/dist/unstable/Report.js.map +1 -1
- package/dist/unstable/RetargetLegs.d.ts +7 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +24 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +123 -68
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +319 -167
- 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 +32 -10
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +73 -20
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +68 -34
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +83 -36
- 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 +391 -27
- package/src/Clock.ts +29 -8
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +118 -41
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +39 -42
- package/src/InputSource.ts +5 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +186 -30
- package/src/Machine.ts +252 -81
- package/src/Playback.ts +15 -9
- package/src/Projection.ts +9 -9
- package/src/Recognizer.ts +16 -10
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +3 -2
- 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 +203 -41
- package/src/internal/guarded.ts +69 -0
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/stepper.ts +33 -6
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +88 -57
- package/src/unstable/AppearHandoff.ts +13 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +23 -17
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +250 -108
- package/src/unstable/FrameEffects.ts +17 -4
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +342 -101
- package/src/unstable/MeasuredPairs.ts +7 -1
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +33 -29
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +20 -2
- package/src/unstable/RetargetLegs.ts +24 -9
- package/src/unstable/Spine.ts +399 -202
- 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 +102 -23
- package/src/unstable/VariantTree.ts +123 -42
- 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 })
|
|
@@ -127,24 +127,27 @@ export const exitTargetOf = (config: ExitConfig, presenceCustom: unknown, state:
|
|
|
127
127
|
// A list (#297): merged, and each name's own keys on its own transition.
|
|
128
128
|
const targets = VariantTarget.resolveTargets(entry, config.variants, custom, state)
|
|
129
129
|
const merged = VariantTarget.mergedOf(targets)
|
|
130
|
+
// One of its names' resolvers threw (#979, Q3): it leaves without the whole exit, as with one name.
|
|
131
|
+
if (Option.isSome(merged.failure)) return { values: {}, transition: config.transition, name, keyframes: undefined, failure: merged.failure }
|
|
130
132
|
return {
|
|
131
133
|
values: merged.values,
|
|
132
134
|
transition: VariantTarget.transitionOfTarget(merged.transition, config.transition),
|
|
133
135
|
name,
|
|
134
136
|
groups: exitGroupsOf(targets, config.transition),
|
|
135
137
|
keyframes: merged.keyframes,
|
|
138
|
+
failure: merged.failure,
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
const target = VariantTarget.resolveTarget(entry, config.variants, custom, state)
|
|
139
|
-
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes }
|
|
142
|
+
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure }
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `
|
|
143
|
-
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> =>
|
|
144
147
|
Arr.map(targets, (target, i) => ({
|
|
145
148
|
name: target.name as string,
|
|
146
149
|
values: Rec.filter(target.values, (_, key) => Bool.not(Arr.some(Arr.drop(targets, i + 1), (later) => Object.hasOwn(later.values, key)))),
|
|
147
|
-
transition: VariantTarget.transitionOfTarget(target.transition,
|
|
150
|
+
transition: VariantTarget.transitionOfTarget(target.transition, wardTransition),
|
|
148
151
|
}))
|
|
149
152
|
|
|
150
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. */
|
|
@@ -197,17 +200,10 @@ const keyTransitionOf = (
|
|
|
197
200
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
198
201
|
key: string,
|
|
199
202
|
transition: Config.WardicTransition | undefined,
|
|
200
|
-
|
|
203
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
201
204
|
): Config.WardicTransition | undefined => {
|
|
202
205
|
if (Predicate.isUndefined(groups)) return transition
|
|
203
|
-
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition,
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** Whether `given` gives `key` a velocity (#448, Motion's `valueTransition.velocity`): it kicks the key, so it animates though at its target. */
|
|
207
|
-
const givesVelocity = (given: Config.WardicTransition | undefined, key: string): boolean => {
|
|
208
|
-
const own = RetargetLegs.transitionForKey(given, key) as { readonly velocity?: unknown } | undefined
|
|
209
|
-
if (Predicate.isUndefined(own)) return false
|
|
210
|
-
return Bool.and(Predicate.isNumber(own.velocity), own.velocity !== 0)
|
|
206
|
+
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, wardTransition, undefined, identity)
|
|
211
207
|
}
|
|
212
208
|
|
|
213
209
|
/** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
|
|
@@ -229,7 +225,7 @@ const pickKeys = (t: Values.Values, groups: ReadonlyArray<ReadonlySet<string>> |
|
|
|
229
225
|
export const delayOf = (transition: Config.WardicTransition | undefined): number =>
|
|
230
226
|
UndefinedOr.match(transition, { onUndefined: () => 0, onDefined: ({ delay = 0 }) => delay })
|
|
231
227
|
|
|
232
|
-
/** 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. */
|
|
233
229
|
const NO_KEYS: ReadonlyArray<string> = []
|
|
234
230
|
|
|
235
231
|
/** The keys a drag of `axis` moves directly. Built once, at module load. */
|
|
@@ -243,6 +239,8 @@ const dragMovesOf: (axis: boolean | "x" | "y") => ReadonlyArray<string> = Match.
|
|
|
243
239
|
const isSameKind = (value: number | string, like: number | string): boolean => Predicate.isNumber(value) === Predicate.isNumber(like)
|
|
244
240
|
|
|
245
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.
|
|
246
244
|
const TRANSLATE_KEYS: ReadonlySet<string> = new Set(["x", "y", "translateX", "translateY"])
|
|
247
245
|
const TRANSLATE_KEY_LIST: ReadonlyArray<string> = Arr.fromIterable(TRANSLATE_KEYS)
|
|
248
246
|
|
|
@@ -349,10 +347,12 @@ export interface OverrideEntry {
|
|
|
349
347
|
readonly ends: Values.Values
|
|
350
348
|
/** Its target's **Keyframes** (#429): each such key's stops, its value in `values` their last. */
|
|
351
349
|
readonly keyframes: VariantTarget.Keyframes | undefined
|
|
350
|
+
/** Its target's resolver that threw, and its variant's name (#979): it has none of that target's values. */
|
|
351
|
+
readonly failure: Option.Option<VariantTarget.VariantFailure>
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/** A gesture layer that's off: nothing is resolved for it. */
|
|
355
|
-
const OFF: OverrideEntry = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined }
|
|
355
|
+
const OFF: OverrideEntry = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined, failure: VariantTarget.NO_FAILURE }
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
358
|
* A gesture layer (#291), while it's on (its own, or its provider's): its own `while*` (a target, or
|
|
@@ -404,7 +404,7 @@ const setsValues = (layer: OverrideEntry): boolean => {
|
|
|
404
404
|
/** A single entry's name: itself, if a name; `undefined` for a values map. */
|
|
405
405
|
const labelOrUndefined = (entry: VariantTarget.Entry): string | undefined => Bool.match(Predicate.isString(entry), { onTrue: () => entry as string, onFalse: constUndefined })
|
|
406
406
|
|
|
407
|
-
/** Each gesture on: the
|
|
407
|
+
/** Each gesture on: the Subject's own, or its provider's too when it has one handing any down. */
|
|
408
408
|
const gesturesOnOf = (active: Active, above: VariantTree.GestureHandDown): VariantTree.GestureStates => {
|
|
409
409
|
if (above === VariantTree.NO_HAND_DOWN) return active
|
|
410
410
|
return VariantTree.gesturesOn(active, above.on)
|
|
@@ -424,7 +424,7 @@ const anyOn = (on: VariantTree.GestureStates): boolean => on.inView || on.focuse
|
|
|
424
424
|
|
|
425
425
|
/**
|
|
426
426
|
* Whether an active entry's name delays its keys otherwise than the first entry's (#297): a Variant
|
|
427
|
-
* 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
|
|
428
428
|
* entry.
|
|
429
429
|
*/
|
|
430
430
|
const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name: string | undefined) => number) | undefined, extra: number): boolean => {
|
|
@@ -432,7 +432,7 @@ const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name:
|
|
|
432
432
|
return Arr.some(layers, (layer) => Bool.and(layer.active, extraOf(extraDelay, layer) !== extra))
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
/** 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. */
|
|
436
436
|
const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined, layer: OverrideEntry | undefined): number => {
|
|
437
437
|
if (Predicate.isUndefined(extraDelay)) return 0
|
|
438
438
|
if (Predicate.isUndefined(layer)) return extraDelay(undefined)
|
|
@@ -441,8 +441,8 @@ const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined,
|
|
|
441
441
|
|
|
442
442
|
/**
|
|
443
443
|
* The transition a key group runs on (#291, #297): unsplit, the base's (`transition`, its delay
|
|
444
|
-
* folded in); split, its entry's own, else the
|
|
445
|
-
* 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
|
|
446
446
|
* transition of its own.
|
|
447
447
|
*/
|
|
448
448
|
const groupTransitionOf = (
|
|
@@ -450,16 +450,16 @@ const groupTransitionOf = (
|
|
|
450
450
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
451
451
|
i: number,
|
|
452
452
|
transition: Config.WardicTransition | undefined,
|
|
453
|
-
|
|
453
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
454
454
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
455
455
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
456
456
|
): Config.WardicTransition | undefined => {
|
|
457
457
|
if (Predicate.isUndefined(groups)) return transition
|
|
458
458
|
if (Bool.and(i === 0, Bool.not(Arr.isArray(resolution.variant)))) return transition
|
|
459
459
|
const layer = resolution.layers[i]
|
|
460
|
-
// A list's returns: the
|
|
461
|
-
if (Predicate.isUndefined(layer)) return staggeredOf(
|
|
462
|
-
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)
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/** No names. */
|
|
@@ -482,7 +482,7 @@ export interface Landing {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
/**
|
|
485
|
-
* 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
|
|
486
486
|
* unsettled, as it still owes an animation, and land nothing; the Retarget once the gate opens
|
|
487
487
|
* counts them.
|
|
488
488
|
*/
|
|
@@ -501,6 +501,9 @@ const gatedLandingOf = (onFrame: ((done: boolean) => void) | undefined): Landing
|
|
|
501
501
|
* other key is given up, and a leg left with none is ended.
|
|
502
502
|
*/
|
|
503
503
|
export interface Running extends Machine.RunOptions {
|
|
504
|
+
readonly supersede: Supersede.Supersede
|
|
505
|
+
/** It picks an Appear animation up where it has got, on the frame timeline (#1026): a Handoff's first legs. */
|
|
506
|
+
readonly onFrameTimeline: boolean
|
|
504
507
|
/** Each key it animates, with the target its Retarget gave it. */
|
|
505
508
|
readonly targets: Values.Values
|
|
506
509
|
/** The resolution of the Retarget that started it: a `when` gate holds that change's legs. */
|
|
@@ -524,7 +527,10 @@ export interface Running extends Machine.RunOptions {
|
|
|
524
527
|
frames: number
|
|
525
528
|
/** When it drew its last frame, on {@link FrameTime.frameNow}'s clock; -Infinity before its first (#464). */
|
|
526
529
|
lastAt: number
|
|
527
|
-
/**
|
|
530
|
+
/**
|
|
531
|
+
* A Blend leg's last frame's values, and the ones before them (the Snapshot's, before its first) (#464):
|
|
532
|
+
* two records of its own, swapped each frame (`keepFrame`).
|
|
533
|
+
*/
|
|
528
534
|
last: Values.Values | undefined
|
|
529
535
|
before: Values.Values | undefined
|
|
530
536
|
/** The time, in ms, its last frame's step covered: its run's dt then, which a Blend's change is over (#865). */
|
|
@@ -560,7 +566,7 @@ interface PendingEnd {
|
|
|
560
566
|
state: "waiting" | "due" | "written" | "dropped"
|
|
561
567
|
}
|
|
562
568
|
|
|
563
|
-
/**
|
|
569
|
+
/** A Subject's waiting Transition ends (#508). */
|
|
564
570
|
interface WaitingEnds {
|
|
565
571
|
/** An entry's end, waiting for its keys, or due already when they've landed. */
|
|
566
572
|
readonly add: (end: PendingEnd) => void
|
|
@@ -568,12 +574,12 @@ interface WaitingEnds {
|
|
|
568
574
|
readonly land: () => void
|
|
569
575
|
/** The end `running` is, dropped, whether it waits or is due: given up, stopped or ended. */
|
|
570
576
|
readonly drop: (running: Running) => void
|
|
571
|
-
/** The
|
|
577
|
+
/** The Subject is gone: none is written. */
|
|
572
578
|
readonly dispose: () => void
|
|
573
579
|
}
|
|
574
580
|
|
|
575
581
|
/**
|
|
576
|
-
* The waiting Transition ends of
|
|
582
|
+
* The waiting Transition ends of Subject `id` (#508): made at its first end, so a Subject with none,
|
|
577
583
|
* nearly every one, pays nothing for them. `owners` holds the leg drawing each key.
|
|
578
584
|
*/
|
|
579
585
|
const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape, id: string, recordFrame: (value: Values.Values) => void): WaitingEnds => {
|
|
@@ -657,7 +663,7 @@ const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape
|
|
|
657
663
|
}
|
|
658
664
|
}
|
|
659
665
|
|
|
660
|
-
/** 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. */
|
|
661
667
|
const landEndsOf = (waiting: WaitingEnds | undefined): void => {
|
|
662
668
|
if (Predicate.isNotUndefined(waiting)) waiting.land()
|
|
663
669
|
}
|
|
@@ -667,7 +673,7 @@ export const NO_VALUES: Values.Values = {}
|
|
|
667
673
|
|
|
668
674
|
/**
|
|
669
675
|
* Whether a change's starts, targets or Keyframes stops hold a Variable value (#542): only then can
|
|
670
|
-
* the
|
|
676
|
+
* the Subject's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
|
|
671
677
|
* built under it. It declines every pair with no `var()` at either end.
|
|
672
678
|
*/
|
|
673
679
|
export const holdsVariable = (variables: VariableValues.Shape, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined): boolean => {
|
|
@@ -692,7 +698,7 @@ const stopsCheckOf = (variables: VariableValues.Shape): ((stops: ReadonlyArray<n
|
|
|
692
698
|
return check
|
|
693
699
|
}
|
|
694
700
|
|
|
695
|
-
/** 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. */
|
|
696
702
|
const PATH_ROTATION = "pathRotation"
|
|
697
703
|
|
|
698
704
|
/** The turn back at 0, written once no leg draws it (#460). */
|
|
@@ -705,9 +711,13 @@ const TURNED_BACK: Values.Values = { [PATH_ROTATION]: 0 }
|
|
|
705
711
|
*/
|
|
706
712
|
export type Owners = Map<string, Running | undefined>
|
|
707
713
|
|
|
708
|
-
/**
|
|
709
|
-
|
|
714
|
+
/**
|
|
715
|
+
* A leg over the keys of `to` (#325), counting toward `landing`: the spine gives it the keys. A Handoff's
|
|
716
|
+
* leg is `onFrameTimeline` (#1026).
|
|
717
|
+
*/
|
|
718
|
+
export const runningOf = (to: Values.Values, resolution: Resolution, landing: Landing, kind: RetargetLegs.Leg["_tag"], onFrameTimeline = false): Running => ({
|
|
710
719
|
supersede: Supersede.make(),
|
|
720
|
+
onFrameTimeline,
|
|
711
721
|
targets: to,
|
|
712
722
|
resolution,
|
|
713
723
|
count: 0,
|
|
@@ -751,6 +761,28 @@ const blendVelocityOf = (running: Running, key: string): number => {
|
|
|
751
761
|
return (((last as number) - (before as number)) * 1000) / apart
|
|
752
762
|
}
|
|
753
763
|
|
|
764
|
+
/**
|
|
765
|
+
* A Blend leg's last two frames' values, kept for its velocity (#464): two records of its own, swapped each
|
|
766
|
+
* frame, the frame's values copied into the newer, since its Frame is its run's, rewritten each tick. Before
|
|
767
|
+
* its first frame, the Snapshot's values are its older. A leg that lands on its first frame keeps none: its
|
|
768
|
+
* velocity is 0.
|
|
769
|
+
*/
|
|
770
|
+
// #895: per frame, plain calls; its two records made at its first frame, nothing after.
|
|
771
|
+
const keepFrame = (running: Running, frame: Frame.Frame<Values.Values>, snapshotValues: Values.Values): void => {
|
|
772
|
+
const older = running.last
|
|
773
|
+
if (Predicate.isUndefined(older)) {
|
|
774
|
+
if (frame.done) return
|
|
775
|
+
running.before = { ...snapshotValues }
|
|
776
|
+
running.last = { ...frame.value }
|
|
777
|
+
return
|
|
778
|
+
}
|
|
779
|
+
// Set with `last` at its first frame: present by construction.
|
|
780
|
+
const newer = UndefinedOr.getOrThrow(running.before)
|
|
781
|
+
Object.assign(newer, frame.value)
|
|
782
|
+
running.before = older
|
|
783
|
+
running.last = newer
|
|
784
|
+
}
|
|
785
|
+
|
|
754
786
|
/** A leg's frame drawn (#325) at `now`: its last lands the keys it draws. Per frame: plain calls. */
|
|
755
787
|
const drew = (running: Running, done: boolean, now: number): void => {
|
|
756
788
|
if (done) running.done = true
|
|
@@ -794,7 +826,7 @@ const restOf = (owners: Owners, target: Values.Values, axis: "x" | "y"): number
|
|
|
794
826
|
/**
|
|
795
827
|
* Where a Path's axes that `target` leaves out rest (#574), read before their legs give them up: a
|
|
796
828
|
* new Path ends them there, so a toss caught mid-air curves back to its line. `undefined` for none:
|
|
797
|
-
* every
|
|
829
|
+
* every Subject's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
|
|
798
830
|
*/
|
|
799
831
|
export const restsOf = (owners: Owners, target: Values.Values): Values.Values | undefined => {
|
|
800
832
|
const x = restOf(owners, target, "x")
|
|
@@ -847,7 +879,7 @@ const splitLegsOf = (
|
|
|
847
879
|
resolution: Resolution,
|
|
848
880
|
listed: boolean,
|
|
849
881
|
transition: Config.WardicTransition | undefined,
|
|
850
|
-
|
|
882
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
851
883
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
852
884
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
853
885
|
reduce: boolean,
|
|
@@ -872,7 +904,7 @@ const splitLegsOf = (
|
|
|
872
904
|
if (Rec.isEmptyRecord(picked)) return
|
|
873
905
|
let followed: RetargetLegs.Follows | undefined
|
|
874
906
|
if (i === returnsAt) followed = follow
|
|
875
|
-
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)
|
|
876
908
|
Arr.forEach(groupLegs, (built) => {
|
|
877
909
|
legs.push(built)
|
|
878
910
|
tags.push(i)
|
|
@@ -909,7 +941,7 @@ interface ListingOf {
|
|
|
909
941
|
* A list's names at a Retarget (#297): told settled as the legs of the keys each drives settle, to
|
|
910
942
|
* the binding's callbacks (Solid 1's, PR 1) and to its orchestration (PR 2), told moving now; and each
|
|
911
943
|
* shut name's legs waiting on its gate (PR 2), its keys held where they start, so another name's first
|
|
912
|
-
* commit, which hands the
|
|
944
|
+
* commit, which hands the Subject's style back (ADR-0034), doesn't drop them to their own value.
|
|
913
945
|
*/
|
|
914
946
|
const listingOf = (of: ListingOf): Listing => {
|
|
915
947
|
const { listed, told, byName, resolution, groups, legGroups, legCount, carriedGroups, shut, config } = of
|
|
@@ -972,7 +1004,7 @@ const logsDebugOn = (runtime: WardicServices.Runner<WardicServices.WardicService
|
|
|
972
1004
|
}
|
|
973
1005
|
|
|
974
1006
|
/**
|
|
975
|
-
* 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
|
|
976
1008
|
* none animates holds no map of its own (#460). Never written: a spine sets keys in a map of its own,
|
|
977
1009
|
* and deletes only from one that has some.
|
|
978
1010
|
*/
|
|
@@ -1010,6 +1042,7 @@ const layerOf = (target: VariantTarget.Target, name: string | undefined): Overri
|
|
|
1010
1042
|
name,
|
|
1011
1043
|
ends: endsOfTarget(target),
|
|
1012
1044
|
keyframes: target.keyframes,
|
|
1045
|
+
failure: target.failure,
|
|
1013
1046
|
})
|
|
1014
1047
|
|
|
1015
1048
|
/** A list's target as an active entry (#297). */
|
|
@@ -1071,7 +1104,7 @@ const hasKeyframes = (layer: OverrideEntry): boolean => {
|
|
|
1071
1104
|
|
|
1072
1105
|
/**
|
|
1073
1106
|
* Each resolved key's Keyframes (#429): the stops of the entry that drives it, when that entry gives
|
|
1074
|
-
* 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
|
|
1075
1108
|
* case.
|
|
1076
1109
|
*/
|
|
1077
1110
|
const keyframesNowOf = (layers: ReadonlyArray<OverrideEntry>, resolved: Values.Values): KeyframesNow | undefined => {
|
|
@@ -1181,10 +1214,11 @@ const measuringOf = (found: ReadonlyArray<string> | undefined, keyframes: Keyfra
|
|
|
1181
1214
|
|
|
1182
1215
|
/**
|
|
1183
1216
|
* A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
|
|
1184
|
-
* end-of-task batch with the values the
|
|
1185
|
-
* stops (`many`, #460). `undefined` with none.
|
|
1217
|
+
* end-of-task batch with the values the Subject draws now, but a key with Keyframes of more than two
|
|
1218
|
+
* stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
|
|
1219
|
+
* it couldn't read do, reported on `runtime` with the Subject's `id`.
|
|
1186
1220
|
*/
|
|
1187
|
-
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 => {
|
|
1188
1222
|
const pairs: Record<string, { readonly from: number | string; readonly to: number | string }> = {}
|
|
1189
1223
|
Arr.forEach(keys, (key) => {
|
|
1190
1224
|
if (RetargetLegs.hasManyStops(many, key)) return
|
|
@@ -1194,9 +1228,21 @@ export const measuredOf = (measured: MeasuredPairs.Shape, element: Subject.Subje
|
|
|
1194
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 }
|
|
1195
1229
|
})
|
|
1196
1230
|
if (Rec.isEmptyRecord(pairs)) return undefined
|
|
1197
|
-
|
|
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 }))
|
|
1198
1233
|
}
|
|
1199
1234
|
|
|
1235
|
+
/** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
|
|
1236
|
+
const pairsFailedOn =
|
|
1237
|
+
(message: string, runtime: Pick<WardicServices.Runner<never>, "runFork">, annotations: Readonly<Record<string, unknown>>) =>
|
|
1238
|
+
(defect: unknown): void => {
|
|
1239
|
+
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(defect)), annotations))
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/** How an exit's Measured pairs the batch couldn't take (its Transform template threw) are reported, on `runtime`. */
|
|
1243
|
+
export const exitMeasuredFailedOn = (runtime: Pick<WardicServices.Runner<never>, "runFork">): ((defect: unknown) => void) =>
|
|
1244
|
+
pairsFailedOn("wardic.presence: an exit's Measured pairs failed", runtime, {})
|
|
1245
|
+
|
|
1200
1246
|
/** A key's Keyframes in `keyframes` (#429): per key, per Retarget, so a guard, nothing made. */
|
|
1201
1247
|
const keyframesAtOf = (keyframes: KeyframesNow | undefined, key: string): KeyframesAt | undefined => {
|
|
1202
1248
|
if (Predicate.isUndefined(keyframes)) return undefined
|
|
@@ -1374,16 +1420,29 @@ const nameSettlesOf = (
|
|
|
1374
1420
|
/**
|
|
1375
1421
|
* Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
|
|
1376
1422
|
* config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
|
|
1377
|
-
* the config. A callback that throws is reported
|
|
1378
|
-
* config has neither: it hands the
|
|
1423
|
+
* the config. A callback that throws is reported at the first of a run of throws, its next clean call
|
|
1424
|
+
* ending the run, and the Subject animates on. The Solid 2 binding's config has neither: it hands the
|
|
1425
|
+
* same facts over as async values.
|
|
1379
1426
|
*/
|
|
1380
1427
|
export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices.WardicServices>, id: string): AnimationHooks => {
|
|
1381
|
-
//
|
|
1382
|
-
|
|
1428
|
+
// #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
|
|
1429
|
+
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per Subject.
|
|
1430
|
+
let startFailing = false
|
|
1431
|
+
let completeFailing = false
|
|
1432
|
+
// Per Retarget, per Subject: the callback looked up first, and nothing made without one. Whether it threw,
|
|
1433
|
+
// reported at a run's first throw (`failing` says one is on).
|
|
1434
|
+
const tell = (
|
|
1435
|
+
name: "onAnimationStart" | "onAnimationComplete",
|
|
1436
|
+
callback: (definition: Config.WardicAnimationDefinition) => void,
|
|
1437
|
+
definition: Config.WardicAnimationDefinition,
|
|
1438
|
+
failing: boolean,
|
|
1439
|
+
): boolean => {
|
|
1383
1440
|
try {
|
|
1384
1441
|
callback(definition)
|
|
1442
|
+
return false
|
|
1385
1443
|
} catch (defect) {
|
|
1386
|
-
runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
|
|
1444
|
+
if (!failing) runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
|
|
1445
|
+
return true
|
|
1387
1446
|
}
|
|
1388
1447
|
}
|
|
1389
1448
|
return {
|
|
@@ -1393,10 +1452,12 @@ export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices
|
|
|
1393
1452
|
if (Predicate.isUndefined(callback)) return
|
|
1394
1453
|
const definition = definitionOf(resolution, previous)
|
|
1395
1454
|
if (Arr.isArray(definition)) {
|
|
1396
|
-
Arr.forEach(definition as ReadonlyArray<string>, (name) =>
|
|
1455
|
+
Arr.forEach(definition as ReadonlyArray<string>, (name) => {
|
|
1456
|
+
startFailing = tell("onAnimationStart", callback, name, startFailing)
|
|
1457
|
+
})
|
|
1397
1458
|
return
|
|
1398
1459
|
}
|
|
1399
|
-
tell("onAnimationStart", callback, definition)
|
|
1460
|
+
startFailing = tell("onAnimationStart", callback, definition, startFailing)
|
|
1400
1461
|
},
|
|
1401
1462
|
// A list's names were each told as they settled (`namesSettled`).
|
|
1402
1463
|
settled: (resolution, previous, config) => {
|
|
@@ -1404,12 +1465,14 @@ export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices
|
|
|
1404
1465
|
if (Predicate.isUndefined(callback)) return
|
|
1405
1466
|
const definition = definitionOf(resolution, previous)
|
|
1406
1467
|
if (Arr.isArray(definition)) return
|
|
1407
|
-
tell("onAnimationComplete", callback, definition)
|
|
1468
|
+
completeFailing = tell("onAnimationComplete", callback, definition, completeFailing)
|
|
1408
1469
|
},
|
|
1409
1470
|
namesSettled: (names, config) => {
|
|
1410
1471
|
const callback = config.onAnimationComplete
|
|
1411
1472
|
if (Predicate.isUndefined(callback)) return
|
|
1412
|
-
Arr.forEach(names, (name) =>
|
|
1473
|
+
Arr.forEach(names, (name) => {
|
|
1474
|
+
completeFailing = tell("onAnimationComplete", callback, name, completeFailing)
|
|
1475
|
+
})
|
|
1413
1476
|
},
|
|
1414
1477
|
}
|
|
1415
1478
|
}
|
|
@@ -1428,7 +1491,7 @@ export interface Active {
|
|
|
1428
1491
|
readonly dragging: boolean
|
|
1429
1492
|
}
|
|
1430
1493
|
|
|
1431
|
-
/** The variant name
|
|
1494
|
+
/** The variant name a Subject animates to: its own `animate`'s, else the one its provider hands down. */
|
|
1432
1495
|
const variantOf = (animate: Config.SpineConfig["animate"], parent: VariantTree.WardicVariantContextValue | undefined): Config.WardicVariantLabels | undefined => {
|
|
1433
1496
|
if (Predicate.isNotUndefined(animate)) return VariantTree.nameOf(animate)
|
|
1434
1497
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1446,7 +1509,7 @@ const baseTargetOf = (
|
|
|
1446
1509
|
): VariantTarget.Target => {
|
|
1447
1510
|
if (Predicate.isNotUndefined(own)) return VariantTarget.resolveTarget(own, variants, custom, state)
|
|
1448
1511
|
if (Predicate.isNotUndefined(variant)) return VariantTarget.resolveTarget(variant, variants, custom, state)
|
|
1449
|
-
return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined }
|
|
1512
|
+
return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined, failure: VariantTarget.NO_FAILURE }
|
|
1450
1513
|
}
|
|
1451
1514
|
|
|
1452
1515
|
/**
|
|
@@ -1475,7 +1538,7 @@ export const resolutionOf = (
|
|
|
1475
1538
|
// sibling's "open"); read parent.variant() here so a parent flip
|
|
1476
1539
|
// recomputes the memo and retargets;
|
|
1477
1540
|
// (3) else the SSR-seeded `initial`.
|
|
1478
|
-
// Per Retarget, per
|
|
1541
|
+
// Per Retarget, per Subject (#460, compose once): statements.
|
|
1479
1542
|
const variant = variantOf(c.animate, parent)
|
|
1480
1543
|
// A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
|
|
1481
1544
|
// that sets a key drives it. A single name or a values map takes the path below, as before.
|
|
@@ -1485,7 +1548,7 @@ export const resolutionOf = (
|
|
|
1485
1548
|
const listLayers: Array<OverrideEntry> = Arr.map(targets, namedLayerOf)
|
|
1486
1549
|
return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1487
1550
|
}
|
|
1488
|
-
// A dynamic variant resolves with this
|
|
1551
|
+
// A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
|
|
1489
1552
|
// Animation controls never reach here: its binding reads them once, each change its entry (#433).
|
|
1490
1553
|
const target = baseTargetOf(c.animate as VariantTarget.Entry | undefined, variant, variants, c.custom, state, initialLink)
|
|
1491
1554
|
const base = target.values
|
|
@@ -1493,7 +1556,7 @@ export const resolutionOf = (
|
|
|
1493
1556
|
// A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
|
|
1494
1557
|
// its own `while*`, else the label the provider hands down. With no provider, its own: nothing made.
|
|
1495
1558
|
// The common case: nothing handed down and no gesture on. The base entry alone, and nothing else
|
|
1496
|
-
// made or called, at every
|
|
1559
|
+
// made or called, at every Subject's mount and Retarget.
|
|
1497
1560
|
if (VariantTree.handDownFrom(parent) === VariantTree.NO_HAND_DOWN && !anyOn(active)) {
|
|
1498
1561
|
const alone: ReadonlyArray<OverrideEntry> = [baseLayer]
|
|
1499
1562
|
const { resolved, ends, keyframes } = resolvedOf(alone)
|
|
@@ -1502,7 +1565,7 @@ export const resolutionOf = (
|
|
|
1502
1565
|
return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1503
1566
|
}
|
|
1504
1567
|
|
|
1505
|
-
/** The **Controls change** in effect for
|
|
1568
|
+
/** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
|
|
1506
1569
|
const changeIn = (own: AnimationControls.ControlsChange | undefined, parent: VariantTree.WardicVariantContextValue | undefined): AnimationControls.ControlsChange | undefined => {
|
|
1507
1570
|
if (Predicate.isNotUndefined(own)) return own
|
|
1508
1571
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1566,7 +1629,7 @@ const withGestures = (
|
|
|
1566
1629
|
return { resolved, base, dragging: active.dragging, variant, active, transition, layers, names, layersOn, ends, keyframes, change }
|
|
1567
1630
|
}
|
|
1568
1631
|
|
|
1569
|
-
/** The values
|
|
1632
|
+
/** The values a Subject starts from, read once at setup (ADR-0003, #134). */
|
|
1570
1633
|
export interface Start {
|
|
1571
1634
|
/** Its Starting style's values: its `initial` (own or inherited, #50), or its `animate` when it starts there. */
|
|
1572
1635
|
readonly initialValues: Values.Values
|
|
@@ -1581,10 +1644,12 @@ export interface Start {
|
|
|
1581
1644
|
* landing with nothing to animate, is told to no one.
|
|
1582
1645
|
*/
|
|
1583
1646
|
readonly quiet: boolean
|
|
1647
|
+
/** The first of its variants whose resolver threw as it was set up (#979): that entry gave no values. */
|
|
1648
|
+
readonly failure: Option.Option<VariantTarget.VariantFailure>
|
|
1584
1649
|
}
|
|
1585
1650
|
|
|
1586
1651
|
/**
|
|
1587
|
-
*
|
|
1652
|
+
* A Subject's {@link Start}, from its config read once and the context it inherits from. With
|
|
1588
1653
|
* `initial={false}` (its own, inherited, or an `<AnimatePresence initial={false}>`'s first render)
|
|
1589
1654
|
* it starts at its `animate`, and nothing animates at mount (#134).
|
|
1590
1655
|
*/
|
|
@@ -1595,15 +1660,134 @@ export const startOf = (
|
|
|
1595
1660
|
untrack: Reactivity.Reactivity["untrack"],
|
|
1596
1661
|
): Start => {
|
|
1597
1662
|
const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks)
|
|
1598
|
-
|
|
1663
|
+
// Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
|
|
1664
|
+
// for a Subject with no variants, so its start makes nothing more (bench:solid's mount).
|
|
1665
|
+
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom)
|
|
1666
|
+
const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants)
|
|
1599
1667
|
return {
|
|
1600
1668
|
quiet: VariantTree.startsQuiet(config, parent, presenceBlocks, untrack),
|
|
1601
1669
|
initialValues,
|
|
1602
1670
|
initialLink: Bool.match(startedAtAnimate, { onTrue: () => ({}), onFalse: () => initialValues }),
|
|
1603
1671
|
startedLink: Bool.match(startedAtAnimate, { onTrue: () => initialValues, onFalse: () => ({}) }),
|
|
1672
|
+
failure: variants.failure,
|
|
1604
1673
|
}
|
|
1605
1674
|
}
|
|
1606
1675
|
|
|
1676
|
+
/** How a variant's failure is reported under `message`, on a runtime: at Error, its cause what the resolver threw, annotated with the variant's name. */
|
|
1677
|
+
const failedOn =
|
|
1678
|
+
(message: string) =>
|
|
1679
|
+
(runtime: Pick<WardicServices.Runner<never>, "runFork">) =>
|
|
1680
|
+
(failure: VariantTarget.VariantFailure): void => {
|
|
1681
|
+
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }))
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
/** How a Subject's variant that throws is reported, on its runtime. */
|
|
1685
|
+
const variantFailedOn = failedOn("wardic.ward: a variant failed")
|
|
1686
|
+
|
|
1687
|
+
/** How an exit whose resolver throws is reported, on `runtime`, each time a Subject leaves: its Subject leaves without it (#979). */
|
|
1688
|
+
export const exitVariantFailedOn: (runtime: Pick<WardicServices.Runner<never>, "runFork">) => (failure: VariantTarget.VariantFailure) => void = failedOn(
|
|
1689
|
+
"wardic.presence: an exit variant failed",
|
|
1690
|
+
)
|
|
1691
|
+
|
|
1692
|
+
/** A Subject's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
|
|
1693
|
+
export const variantFailedOnServer: (failure: VariantTarget.VariantFailure) => void = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER)
|
|
1694
|
+
|
|
1695
|
+
/** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
|
|
1696
|
+
const firstFailureOf = Arr.findFirst<OverrideEntry, VariantTarget.VariantFailure>((layer) => layer.failure)
|
|
1697
|
+
|
|
1698
|
+
/** The first of a resolution's entries' resolvers that threw, and its variant's name (#979). */
|
|
1699
|
+
export const failureOf = (resolution: Resolution): Option.Option<VariantTarget.VariantFailure> => firstFailureOf(resolution.layers)
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* A Subject's dynamic variants that throw: its last good resolution, and each variant failing now with
|
|
1703
|
+
* the places that saw it fail. One a Subject, made by its binding with `report` on its runtime, and
|
|
1704
|
+
* read through {@link keptOf}, {@link reportStart} and {@link orchestrationOf}: each variant is
|
|
1705
|
+
* reported once, until it resolves again.
|
|
1706
|
+
*/
|
|
1707
|
+
export interface VariantFailures extends VariantTree.DelayFailures {
|
|
1708
|
+
/** Its last resolution with no failure: what {@link keptOf} gives while one carries a failure. */
|
|
1709
|
+
last: Resolution | undefined
|
|
1710
|
+
/** Each failing variant, by name, and where it was seen; made at the first failure: most Subjects never have one. */
|
|
1711
|
+
failing: Map<string, number> | undefined
|
|
1712
|
+
/** The runtime its failures are reported on, at Error. */
|
|
1713
|
+
readonly runtime: Pick<WardicServices.Runner<never>, "runFork">
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/** A Subject's {@link VariantFailures}, none failing yet, reported on `runtime`. */
|
|
1717
|
+
// #979 (bench:solid's mount): one plain object a Subject, read by the functions below, not closures, and
|
|
1718
|
+
// holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
|
|
1719
|
+
// WeakMap cost Solid 1's mount 6% (the lookup, a Subject).
|
|
1720
|
+
export const variantFailuresOf = (runtime: Pick<WardicServices.Runner<never>, "runFork">): VariantFailures => ({ last: undefined, failing: undefined, delayFailing: false, runtime })
|
|
1721
|
+
|
|
1722
|
+
/** Where a variant's failure was seen, until each resolves it again: its Subject's resolutions, and its orchestration. */
|
|
1723
|
+
const RESOLVING = 1
|
|
1724
|
+
const ORCHESTRATING = 2
|
|
1725
|
+
|
|
1726
|
+
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its Subject's alone. Each variant, by name,
|
|
1727
|
+
// is reported as it starts failing and fails until every place that saw it fail resolves it again, so
|
|
1728
|
+
// a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
|
|
1729
|
+
// values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
|
|
1730
|
+
// no values isn't reported again at the first change its orchestration reads.
|
|
1731
|
+
const failedAt = (failures: VariantFailures, failure: VariantTarget.VariantFailure, at: number): void => {
|
|
1732
|
+
const name = UndefinedOr.match(failure.name, { onDefined: identity, onUndefined: () => "" })
|
|
1733
|
+
if (Predicate.isUndefined(failures.failing)) failures.failing = new Map()
|
|
1734
|
+
const before = failures.failing.get(name)
|
|
1735
|
+
if (Predicate.isUndefined(before)) {
|
|
1736
|
+
failures.failing.set(name, at)
|
|
1737
|
+
variantFailedOn(failures.runtime)(failure)
|
|
1738
|
+
return
|
|
1739
|
+
}
|
|
1740
|
+
failures.failing.set(name, before | at)
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
const resolvedAt = (failing: Map<string, number>, name: string | undefined, at: number): void => {
|
|
1744
|
+
if (Predicate.isUndefined(name)) return
|
|
1745
|
+
const before = failing.get(name)
|
|
1746
|
+
if (Predicate.isUndefined(before)) return
|
|
1747
|
+
const after = before & ~at
|
|
1748
|
+
if (after === 0) {
|
|
1749
|
+
failing.delete(name)
|
|
1750
|
+
return
|
|
1751
|
+
}
|
|
1752
|
+
failing.set(name, after)
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
/** `next`, else, while it carries a failure, the Subject's last good resolution: it keeps its target. */
|
|
1756
|
+
// Per Retarget, per Subject (#460, compose once): statements; nothing done while nothing fails.
|
|
1757
|
+
export const keptOf = (failures: VariantFailures, next: Resolution): Resolution => {
|
|
1758
|
+
const failure = failureOf(next)
|
|
1759
|
+
if (Option.isSome(failure)) {
|
|
1760
|
+
failedAt(failures, failure.value, RESOLVING)
|
|
1761
|
+
// The first one has no last good one: its failed entry resolved to nothing.
|
|
1762
|
+
const last = failures.last
|
|
1763
|
+
if (Predicate.isUndefined(last)) return next
|
|
1764
|
+
return last
|
|
1765
|
+
}
|
|
1766
|
+
failures.last = next
|
|
1767
|
+
const failing = failures.failing
|
|
1768
|
+
if (Predicate.isUndefined(failing) || failing.size === 0) return next
|
|
1769
|
+
Arr.forEach(next.layers, (layer) => resolvedAt(failing, layer.name, RESOLVING))
|
|
1770
|
+
return next
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
/** A start's failure, setup's or a re-entry's fresh start's: setup resolves as orchestration does, so it stands for both until each resolves the variant again. */
|
|
1774
|
+
export const reportStart = (failures: VariantFailures, start: Start): void => {
|
|
1775
|
+
if (Option.isSome(start.failure)) failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING)
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/** What a Subject's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
|
|
1779
|
+
export const orchestrationOf =
|
|
1780
|
+
(failures: VariantFailures): VariantTarget.Orchestrated =>
|
|
1781
|
+
(entry, failure) => {
|
|
1782
|
+
if (Option.isSome(failure)) {
|
|
1783
|
+
failedAt(failures, failure.value, ORCHESTRATING)
|
|
1784
|
+
return
|
|
1785
|
+
}
|
|
1786
|
+
const failing = failures.failing
|
|
1787
|
+
if (Predicate.isUndefined(failing) || failing.size === 0) return
|
|
1788
|
+
Arr.forEach(Arr.ensure(entry), (name) => resolvedAt(failing, name, ORCHESTRATING))
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1607
1791
|
/**
|
|
1608
1792
|
* The Snapshot: each key's last emitted value, a number or a string, and the numeric velocities.
|
|
1609
1793
|
* A Retarget starts each key from where it is, with its velocity carried across the seam (ADR-0005,
|
|
@@ -1711,9 +1895,9 @@ export const velocitiesNowOf = (snapshot: Snapshot): Readonly<Record<string, num
|
|
|
1711
1895
|
}
|
|
1712
1896
|
|
|
1713
1897
|
/**
|
|
1714
|
-
* The transition a Retarget runs on (#66): the
|
|
1898
|
+
* The transition a Retarget runs on (#66): the Subject's last one when the new one has the same
|
|
1715
1899
|
* fields, so core's decode cache hits when the object is rebuilt with the same values (a staggered
|
|
1716
|
-
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per
|
|
1900
|
+
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per Subject.
|
|
1717
1901
|
*/
|
|
1718
1902
|
export const makeReuse = (): ((transition: Config.WardicTransition) => Config.WardicTransition) => {
|
|
1719
1903
|
let lastTransition: Config.WardicTransition | undefined
|
|
@@ -1726,7 +1910,7 @@ export const makeReuse = (): ((transition: Config.WardicTransition) => Config.Wa
|
|
|
1726
1910
|
}
|
|
1727
1911
|
|
|
1728
1912
|
/**
|
|
1729
|
-
* A mounted
|
|
1913
|
+
* A mounted Subject's Base-value links (ADR-0022), as its binding reads them: its Own value per key,
|
|
1730
1914
|
* the links for a key's start coerced to the shape of its target (`like`), and that start.
|
|
1731
1915
|
*/
|
|
1732
1916
|
// #672: the spine names what it calls; the binding's `startLinksOf` (`element-setup.ts`) makes them.
|
|
@@ -1737,12 +1921,12 @@ export interface StartLinks {
|
|
|
1737
1921
|
}
|
|
1738
1922
|
|
|
1739
1923
|
/**
|
|
1740
|
-
*
|
|
1924
|
+
* A Subject's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
|
|
1741
1925
|
* fires before any frame still has a `from`, and its `exit` ref, which the ward keeps current. An exit key with no value starts
|
|
1742
1926
|
* from its Base value's start links (ADR-0022), read from the Subject kept at the exit.
|
|
1743
1927
|
*/
|
|
1744
1928
|
export const presenceRecordOf = <E extends Subject.Subject>(
|
|
1745
|
-
|
|
1929
|
+
subject: E,
|
|
1746
1930
|
start: Start,
|
|
1747
1931
|
exitOf: (custom: unknown, inherited: Config.WardicVariantLabels | undefined) => ExitTarget,
|
|
1748
1932
|
links: StartLinks,
|
|
@@ -1751,7 +1935,7 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1751
1935
|
reducedMotion: () => boolean,
|
|
1752
1936
|
skipAnimations: () => boolean,
|
|
1753
1937
|
): PresenceRecord.PresenceRecord<E> => ({
|
|
1754
|
-
|
|
1938
|
+
subject,
|
|
1755
1939
|
snapshot: { current: { ...start.initialValues } },
|
|
1756
1940
|
exitOf,
|
|
1757
1941
|
tree,
|
|
@@ -1760,30 +1944,30 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1760
1944
|
velocities: () => velocitiesNowOf(snapshot),
|
|
1761
1945
|
// Its own, under its nearest WardicConfig (#434): its exit honours it, not the presence's.
|
|
1762
1946
|
reducedMotion,
|
|
1763
|
-
// Its nearest WardicConfig's (#468): an exit is skipped as its
|
|
1947
|
+
// Its nearest WardicConfig's (#468): an exit is skipped as its Subject's animations are.
|
|
1764
1948
|
skipAnimations,
|
|
1765
1949
|
})
|
|
1766
1950
|
|
|
1767
1951
|
/**
|
|
1768
1952
|
* Merge an emitted frame's value-map into a presence record's snapshot (nothing without one). It
|
|
1769
|
-
* mirrors what the gate accumulates, so an exit departs from the
|
|
1953
|
+
* mirrors what the gate accumulates, so an exit departs from the Subject's actual resting value-map.
|
|
1770
1954
|
*/
|
|
1771
1955
|
export const recordFrameOf = (presence: PresenceRecord.PresenceRecord | undefined): ((value: Values.Values) => void) => (value) => {
|
|
1772
1956
|
if (Predicate.isNotUndefined(presence)) Object.assign(presence.snapshot.current, value)
|
|
1773
1957
|
}
|
|
1774
1958
|
|
|
1775
|
-
/** Tell
|
|
1959
|
+
/** Tell a Subject's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for a Subject with none. */
|
|
1776
1960
|
export const tellStarted = (live: LiveRoutes | undefined, legs: ReadonlyArray<RetargetLegs.Leg>): void => {
|
|
1777
1961
|
if (Predicate.isUndefined(live)) return
|
|
1778
1962
|
live.started(legs)
|
|
1779
1963
|
}
|
|
1780
1964
|
|
|
1781
1965
|
// A Batch member's hold's slot (#665, #746; #672's Q14: the spine's, so it reads no Batch code).
|
|
1782
|
-
/** What a Batch member's hold reads of what its
|
|
1783
|
-
export type HoldHost = Pick<SpineHost, "
|
|
1966
|
+
/** What a Batch member's hold reads of what its Subject's spine hands over (#746). */
|
|
1967
|
+
export type HoldHost = Pick<SpineHost, "subject" | "gate" | "id" | "snapshot" | "owners" | "giveUp" | "keepTheRest" | "driven" | "returning">
|
|
1784
1968
|
|
|
1785
1969
|
/**
|
|
1786
|
-
* A Batch member's
|
|
1970
|
+
* A Batch member's Subject's hold on the groups it takes from its Batch: its transform, or its opacity,
|
|
1787
1971
|
* 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
|
|
1788
1972
|
* at its Batch's next change of it.
|
|
1789
1973
|
*/
|
|
@@ -1798,13 +1982,13 @@ export interface MemberHold {
|
|
|
1798
1982
|
readonly settle: () => void
|
|
1799
1983
|
/** Its drag reads or writes `x`/`y` (`true`): it takes the transform; or hands them back (`false`). */
|
|
1800
1984
|
readonly drag: (on: boolean) => void
|
|
1801
|
-
/** Its
|
|
1985
|
+
/** Its Subject unmounted: every group back to the Batch. */
|
|
1802
1986
|
readonly dispose: () => void
|
|
1803
1987
|
}
|
|
1804
1988
|
|
|
1805
|
-
/** How a spine finds its
|
|
1989
|
+
/** How a spine finds its Subject a Batch member's, and makes its hold. */
|
|
1806
1990
|
export interface MemberHolds {
|
|
1807
|
-
readonly isMember: (
|
|
1991
|
+
readonly isMember: (subject: Subject.Subject) => boolean
|
|
1808
1992
|
readonly make: (host: HoldHost) => MemberHold
|
|
1809
1993
|
}
|
|
1810
1994
|
|
|
@@ -1816,7 +2000,7 @@ export const memberHoldsNow = (): MemberHolds | undefined => holds
|
|
|
1816
2000
|
|
|
1817
2001
|
/**
|
|
1818
2002
|
* Holds made from now on, through `holds` (`createBatch`, as it's called, gives a Batch's): a Batch's
|
|
1819
|
-
* members can be
|
|
2003
|
+
* members can be Wards' Subjects. The first one given stays.
|
|
1820
2004
|
*/
|
|
1821
2005
|
export const provideMemberHolds = (given: MemberHolds): void => {
|
|
1822
2006
|
if (Predicate.isNotUndefined(holds)) return
|
|
@@ -1824,22 +2008,22 @@ export const provideMemberHolds = (given: MemberHolds): void => {
|
|
|
1824
2008
|
}
|
|
1825
2009
|
|
|
1826
2010
|
/**
|
|
1827
|
-
* Each draggable
|
|
1828
|
-
*
|
|
2011
|
+
* Each draggable Subject's spine's drag hook (#665's PR 4): told `true` as its drag reads where the
|
|
2012
|
+
* Subject rests or writes `x`/`y`, and `false` as it hands them back. A Batch member's takes its
|
|
1829
2013
|
* transform from its Batch then, and gives it back.
|
|
1830
2014
|
*/
|
|
1831
|
-
// Module state (#460, Q7): held weakly by the
|
|
2015
|
+
// Module state (#460, Q7): held weakly by the Subject, so it goes with it.
|
|
1832
2016
|
const DRAG_HOOKS = new WeakMap<Subject.Subject, (on: boolean) => void>()
|
|
1833
2017
|
|
|
1834
|
-
/** `
|
|
1835
|
-
export const tellDrag = (
|
|
1836
|
-
UndefinedOr.map(DRAG_HOOKS.get(
|
|
2018
|
+
/** `subject`'s drag hook told `on`, when its spine has one: its binding's drag start and end, and a drag's claim. */
|
|
2019
|
+
export const tellDrag = (subject: Subject.Subject, on: boolean): void => {
|
|
2020
|
+
UndefinedOr.map(DRAG_HOOKS.get(subject), (tell) => tell(on))
|
|
1837
2021
|
}
|
|
1838
2022
|
|
|
1839
2023
|
/**
|
|
1840
|
-
* What a spine calls of its
|
|
2024
|
+
* What a spine calls of its Subject's Live values routed through its binding's props (#130, ADR-0043):
|
|
1841
2025
|
* the routed keys' values now, and each one's change and removal as they come; and the legs each
|
|
1842
|
-
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its
|
|
2026
|
+
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its Subject for them, #443).
|
|
1843
2027
|
*/
|
|
1844
2028
|
// #672 (PR3-Q1): the spine names what it calls, so it reads no `style` code; dom's LiveStyle meets it.
|
|
1845
2029
|
export interface LiveRoutes {
|
|
@@ -1860,7 +2044,7 @@ export interface LiveFollower {
|
|
|
1860
2044
|
}
|
|
1861
2045
|
|
|
1862
2046
|
/**
|
|
1863
|
-
* What a spine calls of its
|
|
2047
|
+
* What a spine calls of its Subject's drag: a new target for `x` or `y` takes over a free drag's
|
|
1864
2048
|
* release in flight (#340). Its binding's drag track gives it.
|
|
1865
2049
|
*/
|
|
1866
2050
|
// #672 (Q15): the spine names what it calls, so it reads no drag code.
|
|
@@ -1868,16 +2052,16 @@ export interface SpineDrag {
|
|
|
1868
2052
|
readonly takeRelease: (retargeted: { readonly x: boolean; readonly y: boolean }) => boolean
|
|
1869
2053
|
}
|
|
1870
2054
|
|
|
1871
|
-
/** What {@link
|
|
1872
|
-
export interface
|
|
2055
|
+
/** What {@link makeSubjectSpine} reads. */
|
|
2056
|
+
export interface SubjectSpineOptions {
|
|
1873
2057
|
/** The provider runtime the legs fork on. */
|
|
1874
2058
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
1875
2059
|
/** The provider-owned flush gate (ADR-0006). */
|
|
1876
2060
|
readonly gate: FlushGate.Shape
|
|
1877
|
-
/** The
|
|
2061
|
+
/** The Subject's gate id. */
|
|
1878
2062
|
readonly id: string
|
|
1879
|
-
/** The mounted
|
|
1880
|
-
readonly
|
|
2063
|
+
/** The mounted Subject. */
|
|
2064
|
+
readonly subject: Subject.Subject
|
|
1881
2065
|
/** Its tag, for a Handoff's check (its Environment routes some keys by it): `undefined` when it isn't known. */
|
|
1882
2066
|
readonly tag: string | undefined
|
|
1883
2067
|
/** Its config now, read where the binding doesn't track. */
|
|
@@ -1937,7 +2121,7 @@ export interface ElementSpineOptions {
|
|
|
1937
2121
|
readonly animation?: AnimationHooks | undefined
|
|
1938
2122
|
/**
|
|
1939
2123
|
* A list's names orchestrated each on their own (#297's PR 2): a name's keys start once its gate
|
|
1940
|
-
* opens, and its starts and settles are told. Omitted for
|
|
2124
|
+
* opens, and its starts and settles are told. Omitted for a Subject that joins nothing and
|
|
1941
2125
|
* provides nothing.
|
|
1942
2126
|
*/
|
|
1943
2127
|
readonly byName?: VariantTree.NameOrchestration | undefined
|
|
@@ -1963,16 +2147,16 @@ const takeEach = (timelineKeys: Timelines.TimelineKeys, values: Values.Values):
|
|
|
1963
2147
|
Arr.forEach(Rec.keys(values), (key) => timelineKeys.taken(key))
|
|
1964
2148
|
}
|
|
1965
2149
|
|
|
1966
|
-
/** What the follower reads of the
|
|
2150
|
+
/** What the follower reads of the Subject's Override stack and drag, untracked. */
|
|
1967
2151
|
export interface FollowNow {
|
|
1968
2152
|
readonly resolved: () => Values.Values
|
|
1969
2153
|
readonly dragging: () => boolean
|
|
1970
2154
|
}
|
|
1971
2155
|
|
|
1972
|
-
/** What an **Imperative animation** tells of its legs on one
|
|
2156
|
+
/** What an **Imperative animation** tells of its legs on one Subject (#433). */
|
|
1973
2157
|
export interface ImperativeHooks {
|
|
1974
2158
|
/**
|
|
1975
|
-
* Every leg it started on the
|
|
2159
|
+
* Every leg it started on the Subject landed, told after the gate's flush of their last frames:
|
|
1976
2160
|
* `landed` false when a key of it was taken by a later animation, which it then never lands (#951).
|
|
1977
2161
|
*/
|
|
1978
2162
|
readonly settled: (landed: boolean) => void
|
|
@@ -1980,7 +2164,7 @@ export interface ImperativeHooks {
|
|
|
1980
2164
|
readonly failed: (cause: Cause.Cause<unknown>) => void
|
|
1981
2165
|
}
|
|
1982
2166
|
|
|
1983
|
-
/** An **Imperative animation** on one
|
|
2167
|
+
/** An **Imperative animation** on one Subject (#433): its legs, built at the call, run through its Playhead. */
|
|
1984
2168
|
export interface ImperativeTrack {
|
|
1985
2169
|
/**
|
|
1986
2170
|
* Run every leg from the Playhead's time: those running end first, so a seek starts them again there,
|
|
@@ -1996,7 +2180,7 @@ export interface ImperativeTrack {
|
|
|
1996
2180
|
}
|
|
1997
2181
|
|
|
1998
2182
|
/**
|
|
1999
|
-
* What
|
|
2183
|
+
* What a Subject's spine hands over (#746, ADR-0067 *Amendment (#746)*): its state and its leg
|
|
2000
2184
|
* machinery, read live, for the two that work on it from outside, `imperative.ts`, which builds an
|
|
2001
2185
|
* **Imperative animation**'s track, and `member-hold.ts`, a Batch member's hold. An app with neither
|
|
2002
2186
|
* ships neither's code. Made at the first call, once a spine.
|
|
@@ -2004,7 +2188,7 @@ export interface ImperativeTrack {
|
|
|
2004
2188
|
export interface SpineHost {
|
|
2005
2189
|
/** The resolution of the last Retarget, whose targets a taken key is noted with. */
|
|
2006
2190
|
readonly lastResolution: () => Resolution | undefined
|
|
2007
|
-
/** The
|
|
2191
|
+
/** The Subject's values, velocities and owners. */
|
|
2008
2192
|
readonly snapshot: Snapshot
|
|
2009
2193
|
/** Each key's running leg. */
|
|
2010
2194
|
readonly owners: Owners
|
|
@@ -2020,7 +2204,7 @@ export interface SpineHost {
|
|
|
2020
2204
|
readonly giveUp: (key: string, running: Running) => void
|
|
2021
2205
|
/** Its `initial` values: a key without one is owned when it's first drawn. */
|
|
2022
2206
|
readonly initialValues: Values.Values
|
|
2023
|
-
/** Own `key` on the
|
|
2207
|
+
/** Own `key` on the Subject (its style's value gives way). */
|
|
2024
2208
|
readonly ownValue: (key: string) => void
|
|
2025
2209
|
/** Start `key` where it's drawn, noting what it starts from in `started`. */
|
|
2026
2210
|
readonly startKey: (key: string, like: number | string, started: Record<string, string>) => void
|
|
@@ -2030,7 +2214,7 @@ export interface SpineHost {
|
|
|
2030
2214
|
readonly reducedMotion: () => boolean
|
|
2031
2215
|
/** Whether its animations are skipped now (#468). */
|
|
2032
2216
|
readonly skipAnimations: () => boolean
|
|
2033
|
-
readonly
|
|
2217
|
+
readonly subject: Subject.Subject
|
|
2034
2218
|
readonly positionalKeys: ReducedMotion.PositionalKeys["Service"]
|
|
2035
2219
|
readonly defaultTransition: DefaultTransition.DefaultTransition["Service"]
|
|
2036
2220
|
/** The Environment's unit scale, its legs' rest thresholds' for `x`, `y` and `z` (ADR-0069 decision 8). */
|
|
@@ -2058,20 +2242,20 @@ export interface SpineHost {
|
|
|
2058
2242
|
readonly recordFrame: (value: Values.Values) => void
|
|
2059
2243
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
2060
2244
|
/** Its Variable values' Key rule (#55): a blend's are built with it. */
|
|
2061
|
-
readonly
|
|
2245
|
+
readonly subjectRules: ReadonlyArray<InterpolatorRegistry.KeyRule>
|
|
2062
2246
|
/** The Environment's Measured pairs (#430, #672). */
|
|
2063
2247
|
readonly measuredPairs: MeasuredPairs.Shape
|
|
2064
2248
|
/** The Environment's Variable values (#55, #672). */
|
|
2065
2249
|
readonly variableValues: VariableValues.Shape
|
|
2066
2250
|
}
|
|
2067
2251
|
|
|
2068
|
-
/** A mounted
|
|
2069
|
-
export interface
|
|
2252
|
+
/** A mounted Subject's spine. */
|
|
2253
|
+
export interface SubjectSpine {
|
|
2070
2254
|
/** A Retarget toward `resolution`: called by the binding on each change of its target, untracked. */
|
|
2071
2255
|
readonly retarget: (resolution: Resolution) => void
|
|
2072
|
-
/** Follow the
|
|
2256
|
+
/** Follow the Subject's Live values in `style` (#130), from its first routed key on. */
|
|
2073
2257
|
readonly follow: (now: FollowNow) => void
|
|
2074
|
-
/** The
|
|
2258
|
+
/** The Subject's teardown: following stops, and the legs end. */
|
|
2075
2259
|
readonly dispose: () => void
|
|
2076
2260
|
/**
|
|
2077
2261
|
* Start where a leaver is drawn (#286, ADR-0048), before the first Retarget: each key's value and
|
|
@@ -2080,7 +2264,7 @@ export interface ElementSpine {
|
|
|
2080
2264
|
*/
|
|
2081
2265
|
readonly seed: (from: PresenceRecord.PresenceSeed) => void
|
|
2082
2266
|
/**
|
|
2083
|
-
* What the spine hands over (#746): to an **Imperative animation** of the
|
|
2267
|
+
* What the spine hands over (#746): to an **Imperative animation** of the Subject (#433), whose track
|
|
2084
2268
|
* `imperative.ts` builds over it, and to a Batch member's hold (#665). Made at the first call, once.
|
|
2085
2269
|
*/
|
|
2086
2270
|
readonly host: () => SpineHost
|
|
@@ -2088,15 +2272,6 @@ export interface ElementSpine {
|
|
|
2088
2272
|
readonly stop: () => void
|
|
2089
2273
|
}
|
|
2090
2274
|
|
|
2091
|
-
/**
|
|
2092
|
-
* A mounted element's spine: its Retarget, the returns to its Base values, the follower of its
|
|
2093
|
-
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
2094
|
-
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
2095
|
-
* ElementSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
2096
|
-
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
2097
|
-
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
2098
|
-
* fiber Scope interrupts what's left when the provider ends.
|
|
2099
|
-
*/
|
|
2100
2275
|
/** Each runtime's unit scale, read once: a mount reads a WeakMap, not a run of its own. */
|
|
2101
2276
|
// Module state (#460, Q7): held weakly by the runtime, so it goes with it.
|
|
2102
2277
|
const UNIT_SCALES = new WeakMap<object, UnitScale.Rule>()
|
|
@@ -2110,8 +2285,17 @@ export const unitScaleOf = (runtime: WardicServices.Runner<WardicServices.Wardic
|
|
|
2110
2285
|
return read
|
|
2111
2286
|
}
|
|
2112
2287
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2288
|
+
/**
|
|
2289
|
+
* A mounted Subject's spine: its Retarget, the returns to its Base values, the follower of its
|
|
2290
|
+
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
2291
|
+
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
2292
|
+
* SubjectSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
2293
|
+
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
2294
|
+
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
2295
|
+
* fiber Scope interrupts what's left when the provider ends.
|
|
2296
|
+
*/
|
|
2297
|
+
export const makeSubjectSpine = (options: SubjectSpineOptions): SubjectSpine => {
|
|
2298
|
+
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
|
|
2115
2299
|
// The Environment's unit scale (ADR-0069 decision 8, #883): read from the runtime the spine already holds,
|
|
2116
2300
|
// so no binding passes it; 1, Motion's own, unless the Environment's Layers give another.
|
|
2117
2301
|
const unitScale = unitScaleOf(runtime)
|
|
@@ -2120,9 +2304,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2120
2304
|
let handoff = options.handoff
|
|
2121
2305
|
// Its mount tells nothing when it starts at its `animate` (#448): on until its first Retarget.
|
|
2122
2306
|
let quiet = start.quiet
|
|
2123
|
-
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this
|
|
2307
|
+
// Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this Subject,
|
|
2124
2308
|
// added to each leg it starts, so a `var()` end blends what it resolves to here.
|
|
2125
|
-
const
|
|
2309
|
+
const subjectRules = [variableValues.values(subject)]
|
|
2126
2310
|
const recordFrame = recordFrameOf(presence)
|
|
2127
2311
|
// Whether its animations are skipped (#468): never, with nothing given.
|
|
2128
2312
|
const skipAnimations = UndefinedOr.match(options.skipAnimations, { onUndefined: () => constFalse, onDefined: identity })
|
|
@@ -2145,7 +2329,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2145
2329
|
featuresSeen = services
|
|
2146
2330
|
const timelines = Context.getOrUndefined(services as Context.Context<Timelines.Timelines>, Timelines.Timelines)
|
|
2147
2331
|
if (Predicate.isUndefined(timelines)) return undefined
|
|
2148
|
-
timelineKeys = timelines.keysOf({ runtime, gate, id,
|
|
2332
|
+
timelineKeys = timelines.keysOf({ runtime, gate, id, subject, live: routes })
|
|
2149
2333
|
return timelineKeys
|
|
2150
2334
|
}
|
|
2151
2335
|
|
|
@@ -2153,9 +2337,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2153
2337
|
// ones returning to their Base value until that return settles (ADR-0022). Both are
|
|
2154
2338
|
// the spine's: a Retarget mid-return carries them again, so a return is never
|
|
2155
2339
|
// frozen half-way, and a key that settled has left them, so a Retarget of the same
|
|
2156
|
-
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag
|
|
2340
|
+
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag Subject, the keys
|
|
2157
2341
|
// the drag moves leave the return while it runs, so they stay where it dropped them (C9)
|
|
2158
|
-
// until an entry sets them again; a projected
|
|
2342
|
+
// until an entry sets them again; a projected Subject's drag moves none, its projection
|
|
2159
2343
|
// target does (ADR-0016), and its own translate returns as any key does (#363).
|
|
2160
2344
|
const driven = new Map<string, number | string>()
|
|
2161
2345
|
let returning = new Map<string, BaseValue.BaseSource>()
|
|
@@ -2167,7 +2351,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2167
2351
|
}
|
|
2168
2352
|
|
|
2169
2353
|
// A Retarget's returns have settled (ADR-0022, D4). A key back at its `style` value is
|
|
2170
|
-
// handed back to the
|
|
2354
|
+
// handed back to the Subject's style, so a later style change shows at rest and the
|
|
2171
2355
|
// next gesture starts from it; any other key rests at its Base value where the gate drew
|
|
2172
2356
|
// it, and leaves the target. A key a later Retarget took over is left alone. A routed key (#130) stays
|
|
2173
2357
|
// in the gate, handed to the follower, which writes its value from now on.
|
|
@@ -2184,7 +2368,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2184
2368
|
Arr.forEach(Arr.filter(toStyle, routedNow), (key) => handBack(key))
|
|
2185
2369
|
const handedBack = Arr.filter(toStyle, Predicate.not(routedNow))
|
|
2186
2370
|
if (Arr.isReadonlyArrayEmpty(handedBack)) return
|
|
2187
|
-
// The gate writes the user's current value back, as the
|
|
2371
|
+
// The gate writes the user's current value back, as the Subject's `style` would
|
|
2188
2372
|
// (ADR-0034). A key gone from the user's style by now is cleared, not restored stale.
|
|
2189
2373
|
const restore = UndefinedOr.map(styleNow, (now) => {
|
|
2190
2374
|
const style = now()
|
|
@@ -2210,7 +2394,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2210
2394
|
// The keys an Imperative animation took (#433), each with the target the Override stack had for it
|
|
2211
2395
|
// then: a Retarget leaves each where the animation leaves it while its target is still that one, and
|
|
2212
2396
|
// takes it back once it isn't, as a newer animation of Motion's value takes it (latest-wins).
|
|
2213
|
-
// Every
|
|
2397
|
+
// Every Subject reads it, nearly none sets it (#460): the shared empty one until the first key taken.
|
|
2214
2398
|
let taken: Map<string, number | string | undefined> = NONE_TAKEN
|
|
2215
2399
|
// The legs that gave up a key in this Retarget: what each still draws is worked out at its end.
|
|
2216
2400
|
const losing: Array<Running> = []
|
|
@@ -2247,7 +2431,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2247
2431
|
})
|
|
2248
2432
|
}
|
|
2249
2433
|
|
|
2250
|
-
// The
|
|
2434
|
+
// The Subject's waiting Transition ends (#508), made at its first: most Subjects never have one.
|
|
2251
2435
|
let waiting: WaitingEnds | undefined
|
|
2252
2436
|
|
|
2253
2437
|
// A leg with no key left ends. Its fiber ends inline (ADR-0027, *Amendment (#200)*); one its token
|
|
@@ -2322,7 +2506,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2322
2506
|
}
|
|
2323
2507
|
|
|
2324
2508
|
// A Path's turn goes back to 0 once no leg draws it (#460, ADR-0065 decision 3): after a Retarget
|
|
2325
|
-
// whose legs don't turn, a stop, a cancel. Most
|
|
2509
|
+
// whose legs don't turn, a stop, a cancel. Most Subjects never turn: a guard.
|
|
2326
2510
|
const turnBack = (): void => {
|
|
2327
2511
|
const turn = snapshot.values[PATH_ROTATION]
|
|
2328
2512
|
if (Bool.or(Predicate.isUndefined(turn), turn === 0)) return
|
|
@@ -2379,7 +2563,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2379
2563
|
|
|
2380
2564
|
/**
|
|
2381
2565
|
* A leg's run into its sink: one dispatcher, each sink built for the leg that needs it, a
|
|
2382
|
-
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the
|
|
2566
|
+
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the Subject's
|
|
2383
2567
|
* Key rules when its change holds a Variable value (`variables`, #542).
|
|
2384
2568
|
*/
|
|
2385
2569
|
const legProgram = (leg: RetargetLegs.Leg, running: Running, variables: boolean): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
@@ -2409,7 +2593,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2409
2593
|
// rather than replacing it, so the drag's direct-set x/y survive alongside the
|
|
2410
2594
|
// spring's keys (drag owns x/y, spring owns the rest) and the post-drag
|
|
2411
2595
|
// handoff continues from the rested position. Only the keys it still draws (#325).
|
|
2412
|
-
// In place, as the Follow sink writes (#659): a spread made two records per
|
|
2596
|
+
// In place, as the Follow sink writes (#659): a spread made two records per Subject per
|
|
2413
2597
|
// frame. The Snapshot's records are always its own (`snapshotOf`, `emptySnapshotOf`), and
|
|
2414
2598
|
// whatever keeps one copies it or reads it at once.
|
|
2415
2599
|
const value = running.values(frame.value)
|
|
@@ -2431,19 +2615,15 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2431
2615
|
}, running)
|
|
2432
2616
|
)
|
|
2433
2617
|
}
|
|
2434
|
-
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004), as the spring's are
|
|
2435
|
-
//
|
|
2436
|
-
//
|
|
2618
|
+
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
|
|
2619
|
+
// (#659; #895: a spread made a record per Subject per frame). A blend's last two are kept for its keys'
|
|
2620
|
+
// velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
|
|
2437
2621
|
const sink = (frame: Frame.Frame<Values.Values>, dt: number): undefined => {
|
|
2438
2622
|
const value = running.values(frame.value)
|
|
2439
|
-
|
|
2440
|
-
// Its first frame: from the Snapshot's values.
|
|
2441
|
-
if (Predicate.isUndefined(before)) before = snapshot.values
|
|
2442
|
-
running.before = before
|
|
2623
|
+
keepFrame(running, frame, snapshot.values)
|
|
2443
2624
|
// Over the time its step covered (#865), its first's included: its run's dt, in ms.
|
|
2444
2625
|
running.lastStep = dt * 1000
|
|
2445
|
-
|
|
2446
|
-
snapshot.values = { ...snapshot.values, ...value }
|
|
2626
|
+
Object.assign(snapshot.values, value)
|
|
2447
2627
|
gate.write(id, value)
|
|
2448
2628
|
recordFrame(value)
|
|
2449
2629
|
drew(running, frame.done, snapshot.now())
|
|
@@ -2457,7 +2637,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2457
2637
|
}
|
|
2458
2638
|
// Per leg (#460): a statement, Effect's calls data-first.
|
|
2459
2639
|
let built = Effect.suspend(leg.machine)
|
|
2460
|
-
if (variables) built = InterpolatorRegistry.withKeyRules(built,
|
|
2640
|
+
if (variables) built = InterpolatorRegistry.withKeyRules(built, subjectRules)
|
|
2461
2641
|
return Effect.flatMap(built, (machine) => Machine.run(machine, sink, running))
|
|
2462
2642
|
}
|
|
2463
2643
|
|
|
@@ -2468,7 +2648,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2468
2648
|
// Per leg (#460): statements.
|
|
2469
2649
|
if (Exit.isSuccess(exit)) {
|
|
2470
2650
|
// A Superseded leg (#200) counts toward nothing, nor tells a name: the next Retarget's legs
|
|
2471
|
-
// land. Nothing made for it: a Retarget ends its
|
|
2651
|
+
// land. Nothing made for it: a Retarget ends its Subject's legs inline.
|
|
2472
2652
|
const end = exit.value
|
|
2473
2653
|
if (Supersede.isSuperseded(end)) return Effect.void
|
|
2474
2654
|
return Effect.sync(() => {
|
|
@@ -2490,7 +2670,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2490
2670
|
}
|
|
2491
2671
|
|
|
2492
2672
|
// A gated Retarget (ADR-0007 `when`, #325): a running key it resolves to its leg's target runs on,
|
|
2493
|
-
// the
|
|
2673
|
+
// the Subject reported unsettled meanwhile, when an earlier change started that leg; every other
|
|
2494
2674
|
// running key freezes where it is. The change the gate holds may have started legs just before
|
|
2495
2675
|
// it shut (a child Retargets before its provider's effect resets its `beforeChildren` wait; an
|
|
2496
2676
|
// `afterChildren` provider starts before its children report): those freeze too, as before.
|
|
@@ -2571,7 +2751,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2571
2751
|
keepTheRest,
|
|
2572
2752
|
reducedMotion: options.reducedMotion,
|
|
2573
2753
|
skipAnimations,
|
|
2574
|
-
|
|
2754
|
+
subject,
|
|
2575
2755
|
positionalKeys,
|
|
2576
2756
|
defaultTransition,
|
|
2577
2757
|
unitScale,
|
|
@@ -2587,7 +2767,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2587
2767
|
id,
|
|
2588
2768
|
recordFrame,
|
|
2589
2769
|
runtime,
|
|
2590
|
-
|
|
2770
|
+
subjectRules,
|
|
2591
2771
|
measuredPairs,
|
|
2592
2772
|
variableValues,
|
|
2593
2773
|
}
|
|
@@ -2595,37 +2775,37 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2595
2775
|
return handedOver
|
|
2596
2776
|
}
|
|
2597
2777
|
|
|
2598
|
-
// --- A Batch member's
|
|
2778
|
+
// --- A Batch member's Subject (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
|
|
2599
2779
|
|
|
2600
|
-
// Its hold on what it takes from its Batch: made as its
|
|
2601
|
-
// Retarget or a drag. Nearly no
|
|
2780
|
+
// Its hold on what it takes from its Batch: made as its Subject is first found a member's, at a
|
|
2781
|
+
// Retarget or a drag. Nearly no Subject is one: the rest pay a WeakMap read a Retarget.
|
|
2602
2782
|
let memberHold: MemberHold | undefined
|
|
2603
2783
|
const holdNow = (): MemberHold | undefined => {
|
|
2604
2784
|
if (Predicate.isNotUndefined(memberHold)) return memberHold
|
|
2605
2785
|
// An app with no Batch has no way to make one, nor any member.
|
|
2606
2786
|
const holds = memberHoldsNow()
|
|
2607
2787
|
if (Predicate.isUndefined(holds)) return undefined
|
|
2608
|
-
if (!holds.isMember(
|
|
2788
|
+
if (!holds.isMember(subject)) return undefined
|
|
2609
2789
|
memberHold = holds.make(host())
|
|
2610
2790
|
return memberHold
|
|
2611
2791
|
}
|
|
2612
|
-
// A draggable
|
|
2792
|
+
// A draggable Subject's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
|
|
2613
2793
|
if (Predicate.isNotUndefined(options.dragAxis)) {
|
|
2614
|
-
DRAG_HOOKS.set(
|
|
2794
|
+
DRAG_HOOKS.set(subject, (on) => {
|
|
2615
2795
|
const member = holdNow()
|
|
2616
2796
|
if (Predicate.isNotUndefined(member)) member.drag(on)
|
|
2617
2797
|
})
|
|
2618
2798
|
}
|
|
2619
2799
|
|
|
2620
2800
|
const retarget = (given: Resolution): void => {
|
|
2621
|
-
// A Controls change (#433): the
|
|
2801
|
+
// A Controls change (#433): the Subject is in it from the Retarget it makes it run, held or not.
|
|
2622
2802
|
if (given.change !== joined) joinChange(given.change)
|
|
2623
2803
|
// A key an entry sets isn't its Live value's from this Retarget on, held or not: its Timeline value
|
|
2624
2804
|
// stops (#240), and the gate draws the key in the flush that writes the entry's first value.
|
|
2625
2805
|
if (Predicate.isNotUndefined(timelineKeys)) takeEach(timelineKeys, given.resolved)
|
|
2626
2806
|
|
|
2627
2807
|
// `when` start-gate (ADR-0007): when canStart() is false, the keys whose target changed freeze
|
|
2628
|
-
// where they are (#325: the rest run on), and the
|
|
2808
|
+
// where they are (#325: the rest run on), and the Subject waits; the binding retargets once
|
|
2629
2809
|
// the gate flips true.
|
|
2630
2810
|
if (Predicate.isNotUndefined(canStart) && !canStart()) {
|
|
2631
2811
|
hold(given)
|
|
@@ -2679,7 +2859,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2679
2859
|
if (Predicate.isNotUndefined(keys)) Arr.forEach(dragMoves(), (key) => keys.taken(key))
|
|
2680
2860
|
}
|
|
2681
2861
|
returning = new Map()
|
|
2682
|
-
// Over the Map itself: copying it into an array first costs ~20 times the walk, per
|
|
2862
|
+
// Over the Map itself: copying it into an array first costs ~20 times the walk, per Subject
|
|
2683
2863
|
// per Retarget (#69's PR 4). Deleting the entry being visited is safe in a Map's iteration.
|
|
2684
2864
|
Iter.forEach(driven, ([key, like]) => {
|
|
2685
2865
|
// A translate key the strip below holds back returns once the drag lets go.
|
|
@@ -2704,12 +2884,12 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2704
2884
|
if (taken.size > 0) Iter.forEach(taken, ([key]) => {
|
|
2705
2885
|
delete t[key]
|
|
2706
2886
|
})
|
|
2707
|
-
// A Batch member's
|
|
2887
|
+
// A Batch member's Subject (#665's PR 4, Q53): a group it moves is taken from its Batch first, and a
|
|
2708
2888
|
// key it'd leave where the Batch draws it stays the Batch's. A drag takes `x` and `y`.
|
|
2709
2889
|
const member = holdNow()
|
|
2710
2890
|
if (Predicate.isNotUndefined(member)) member.retarget(t, held)
|
|
2711
2891
|
// The keys this Retarget returns; once it lands, a key back at its `style` value is
|
|
2712
|
-
// handed back to the
|
|
2892
|
+
// handed back to the Subject's style (D4) and the rest rest where the gate drew them.
|
|
2713
2893
|
const returns = [...returning]
|
|
2714
2894
|
// The transition, read at Retarget time so a change applies to the next Retarget. A child
|
|
2715
2895
|
// with no local transition inherits the parent context's (ADR-0007).
|
|
@@ -2730,7 +2910,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2730
2910
|
if (--legs !== 0) return
|
|
2731
2911
|
settleReturns(returns)
|
|
2732
2912
|
// The Retarget settled with its last leg (#257): told once the gate has flushed its last frame,
|
|
2733
|
-
// so the
|
|
2913
|
+
// so the Subject shows where it landed. Its Controls change hears it then too (#433).
|
|
2734
2914
|
if (Predicate.isNotUndefined(animation)) gate.afterFlush(() => animation.settled(resolution, previous, c))
|
|
2735
2915
|
leaveAfterFlush()
|
|
2736
2916
|
}
|
|
@@ -2754,7 +2934,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2754
2934
|
if (startedTold) return tellFailed(error)
|
|
2755
2935
|
failedEarly = { error }
|
|
2756
2936
|
}
|
|
2757
|
-
// The
|
|
2937
|
+
// The Subject settles with its last leg (ADR-0024, D5): a string leg can outlast the
|
|
2758
2938
|
// numeric one, so each leg's frames report, and only the last leg's settle reports done.
|
|
2759
2939
|
let reporting = 0
|
|
2760
2940
|
let settled = 0
|
|
@@ -2767,9 +2947,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2767
2947
|
|
|
2768
2948
|
// The Retarget's transitions, read before its keys: a key already there asks its own for a
|
|
2769
2949
|
// velocity (#448).
|
|
2770
|
-
const
|
|
2950
|
+
const wardTransition = VariantTree.ownOrInherited(c.transition, parent)
|
|
2771
2951
|
// The base target's own transition (#277): the keys its entry drives animate on it.
|
|
2772
|
-
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition,
|
|
2952
|
+
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, wardTransition)
|
|
2773
2953
|
// Fold the per-child stagger delay (ADR-0007) into the effective
|
|
2774
2954
|
// transition.delay = base.delay + computedDelay. extraDelay() is read
|
|
2775
2955
|
// at Retarget time so a re-snapshot before this start is reflected. Each name's keys take that
|
|
@@ -2778,11 +2958,11 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2778
2958
|
const extra = extraOf(extraDelay, layers[0])
|
|
2779
2959
|
const transition = staggeredOf(baseTransition, extra, options.reuse)
|
|
2780
2960
|
// With an entry's own transition (#277, #291), each key animates on its entry's: the base's keys
|
|
2781
|
-
// on the base target's, each active gesture's on its target's, else the
|
|
2961
|
+
// on the base target's, each active gesture's on its target's, else the Subject's, as Motion's
|
|
2782
2962
|
// each animation type runs on its own.
|
|
2783
2963
|
// A list's names (#297) split them too, each name's at its own delay; a list's returns run on the
|
|
2784
|
-
//
|
|
2785
|
-
// Guards, not matches: per Retarget, per
|
|
2964
|
+
// Subject's transition, in a group of their own, last.
|
|
2965
|
+
// Guards, not matches: per Retarget, per Subject. A list's work (#297) is done apart, for a list:
|
|
2786
2966
|
// the Retarget's other calls keep their inlining (docs/agents/effect-first.md).
|
|
2787
2967
|
const listed = Arr.isArray(resolution.variant)
|
|
2788
2968
|
// A list's names each wait for their own `when` (#297's PR 2): the entries whose gate is shut now.
|
|
@@ -2799,7 +2979,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2799
2979
|
// target (no motion).
|
|
2800
2980
|
//
|
|
2801
2981
|
// Every key's Own value is read first, at its first need, before anything writes it, so a return
|
|
2802
|
-
// later finds the
|
|
2982
|
+
// later finds the Subject's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
|
|
2803
2983
|
// a lookup. A transform key reads nothing.
|
|
2804
2984
|
let stays: Set<string> | undefined
|
|
2805
2985
|
let carried: Array<Running> | undefined
|
|
@@ -2857,7 +3037,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2857
3037
|
// Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
|
|
2858
3038
|
// mount's never asks (#475): Motion animates nothing at a first render that starts at its
|
|
2859
3039
|
// `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
|
|
2860
|
-
if (still && Predicate.isUndefined(stops) && (quiet || !givesVelocity(keyTransitionOf(resolution, groups, key, transition,
|
|
3040
|
+
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, wardTransition), key))) {
|
|
2861
3041
|
if (Predicate.isUndefined(stays)) stays = new Set()
|
|
2862
3042
|
stays.add(key)
|
|
2863
3043
|
if (Predicate.isUndefined(there)) there = {}
|
|
@@ -2877,6 +3057,19 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2877
3057
|
resolvedNow = t
|
|
2878
3058
|
owners.forEach(giveUpUnresolved)
|
|
2879
3059
|
keepTheRest()
|
|
3060
|
+
// A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
|
|
3061
|
+
// the resolved target doesn't name joins the keys already there, written with them as the Subject's first
|
|
3062
|
+
// commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
|
|
3063
|
+
// any. A Batch member's are its Batch's, which draws its groups.
|
|
3064
|
+
if (Predicate.isUndefined(lastResolution)) {
|
|
3065
|
+
if (Predicate.isUndefined(member)) {
|
|
3066
|
+
Arr.forEach(Rec.keys(initialValues), (key) => {
|
|
3067
|
+
if (Object.hasOwn(resolved, key)) return
|
|
3068
|
+
if (Predicate.isUndefined(there)) there = {}
|
|
3069
|
+
there[key] = UndefinedOr.getOrThrow(snapshot.values[key])
|
|
3070
|
+
})
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
2880
3073
|
// The keys this Retarget starts legs for: all of them, unless some stay.
|
|
2881
3074
|
let fresh: Values.Values = t
|
|
2882
3075
|
if (Predicate.isNotUndefined(stays)) {
|
|
@@ -2939,7 +3132,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2939
3132
|
// The legs (#48, ADR-0044 decision 8): one pure builder, which a server render's Appear
|
|
2940
3133
|
// animation samples too, so the two can't drift. Built here; each leg's machine is built
|
|
2941
3134
|
// in its own fiber, so a transition core rejects (#66, ADR-0025 *Amendment (#66)*) fails
|
|
2942
|
-
// that leg alone, reported as any leg's failure is, while the
|
|
3135
|
+
// that leg alone, reported as any leg's failure is, while the Subject's other legs run on.
|
|
2943
3136
|
// The returns to a moving Live value (#130, ADR-0043 decision 6): a number's follows it,
|
|
2944
3137
|
// in a leg of its own, and lands on it; the rest return to where it is now. Looked for
|
|
2945
3138
|
// only when this Retarget returns a key.
|
|
@@ -2954,7 +3147,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2954
3147
|
// animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
|
|
2955
3148
|
let measured: RetargetLegs.MeasuredPairs | undefined
|
|
2956
3149
|
if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
|
|
2957
|
-
measured = measuredOf(measuredPairs,
|
|
3150
|
+
measured = measuredOf(measuredPairs, subject, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id)
|
|
2958
3151
|
}
|
|
2959
3152
|
let told: ToldNames | undefined
|
|
2960
3153
|
if (!silent) told = namesToldOf(animation, resolution, lastResolution)
|
|
@@ -2968,17 +3161,21 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2968
3161
|
retargetLegs = RetargetLegs.legsOf(from, fresh, transition, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale)
|
|
2969
3162
|
}
|
|
2970
3163
|
if (Predicate.isNotUndefined(groups)) {
|
|
2971
|
-
const split = splitLegsOf(fresh, from, groups, resolution, listed, transition,
|
|
3164
|
+
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)
|
|
2972
3165
|
retargetLegs = split.legs
|
|
2973
3166
|
legGroups = split.tags
|
|
2974
3167
|
}
|
|
2975
3168
|
// The Handoff (#48, ADR-0044 decision 6): the first Retarget that starts picks the Appear
|
|
2976
|
-
// animation up as far in as it has got, read at the legs' first tick.
|
|
3169
|
+
// animation up as far in as it has got, read at the legs' first tick. Its legs keep the frame
|
|
3170
|
+
// timeline's time, where the Appear animation's `currentTime` is (#1026).
|
|
3171
|
+
let takenOver = false
|
|
2977
3172
|
if (Predicate.isNotUndefined(handoff)) {
|
|
3173
|
+
takenOver = true
|
|
2978
3174
|
const taken = handoff
|
|
2979
3175
|
handoff = undefined
|
|
2980
3176
|
if (Predicate.isNotUndefined(diagnostics)) {
|
|
2981
|
-
|
|
3177
|
+
// With the keys it leaves where they are (#1004), which the server's rule holds beside the moving ones.
|
|
3178
|
+
diagnostics.checkHandoff(runtime, id, taken, { tag, from, to: fresh, transition: baseTransition, reduced: reduce, layout: isLayoutNode(c), stops: manyStops, ...AppearHandoff.skippedField(skipped), ...templateField(c.transformTemplate), held: there })
|
|
2982
3179
|
}
|
|
2983
3180
|
const at = AppearHandoff.startAtOf(taken, baseTransition, delayOf(transition))
|
|
2984
3181
|
retargetLegs = Arr.map(retargetLegs, (one) => RetargetLegs.startingAt(one, at))
|
|
@@ -3016,13 +3213,13 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3016
3213
|
}
|
|
3017
3214
|
// Its Live routes hear the legs it starts (#443, PR4-Q1).
|
|
3018
3215
|
tellStarted(live, retargetLegs)
|
|
3019
|
-
// The
|
|
3216
|
+
// The Subject's Key rules only for a change a Variable value is in (#542).
|
|
3020
3217
|
const variables = holdsVariable(variableValues, from, fresh, manyStops)
|
|
3021
|
-
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per
|
|
3218
|
+
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per Subject). Each
|
|
3022
3219
|
// leg draws the keys it animates (#325) until a later Retarget takes them.
|
|
3023
3220
|
Arr.forEach(retargetLegs, (leg: RetargetLegs.Leg, i): void => {
|
|
3024
3221
|
if (Predicate.isNotUndefined(legGates)) gateNow = legGates[i]
|
|
3025
|
-
const running = runningOf(leg.to, resolution, landing, leg._tag)
|
|
3222
|
+
const running = runningOf(leg.to, resolution, landing, leg._tag, takenOver)
|
|
3026
3223
|
own(running)
|
|
3027
3224
|
runLeg(running, legProgram(leg, running, variables))
|
|
3028
3225
|
})
|
|
@@ -3076,7 +3273,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3076
3273
|
// A turn none of its legs draws now goes back (#460).
|
|
3077
3274
|
turnBack()
|
|
3078
3275
|
// The keys already there (#448), written with each key the Retarget moves at where it starts, as
|
|
3079
|
-
// its leg's first frame writes it: the
|
|
3276
|
+
// its leg's first frame writes it: the Subject's first commit, which takes its Starting style off,
|
|
3080
3277
|
// holds every key, whatever frame the legs first draw in (a gated name's draws later).
|
|
3081
3278
|
if (Predicate.isNotUndefined(there)) {
|
|
3082
3279
|
const written = { ...from, ...there }
|
|
@@ -3084,7 +3281,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3084
3281
|
recordFrame(written)
|
|
3085
3282
|
}
|
|
3086
3283
|
// The Retarget started, its legs on their way (#257); with none, its own or carried, it landed
|
|
3087
|
-
// at once (#325): its returns settle, and the
|
|
3284
|
+
// at once (#325): its returns settle, and the Subject reports settled at the gate's next flush,
|
|
3088
3285
|
// after the effects that start its orchestration's wait (ADR-0007).
|
|
3089
3286
|
previous = lastResolution
|
|
3090
3287
|
lastResolution = resolution
|
|
@@ -3114,14 +3311,14 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3114
3311
|
|
|
3115
3312
|
// --- Live values in `style` (#130, ADR-0043) ------------------------------
|
|
3116
3313
|
// A routed key (a Live value, or a transform key) is its `style` link, live: while no entry of
|
|
3117
|
-
// the Override stack sets it, no return is running to it and no drag moves it, the
|
|
3314
|
+
// the Override stack sets it, no return is running to it and no drag moves it, the Subject
|
|
3118
3315
|
// follows it, written through the gate on every change. A return hands it back here when it
|
|
3119
3316
|
// settles (`settleReturns`). The Starting style showed each one's value at render; from mount
|
|
3120
3317
|
// the gate holds them.
|
|
3121
3318
|
const follow = (now: FollowNow): void => {
|
|
3122
3319
|
if (Predicate.isUndefined(live)) return
|
|
3123
3320
|
const routes = live
|
|
3124
|
-
// Built at the first routed key, at mount or later:
|
|
3321
|
+
// Built at the first routed key, at mount or later: a Subject whose `style` routes none builds nothing.
|
|
3125
3322
|
routes.whenRouted(() => {
|
|
3126
3323
|
// Read at each ask: `projected` is a getter while the track waits for `drag` (#551, #582).
|
|
3127
3324
|
const dragHolds = (): boolean => Bool.and(Bool.not(options.projected), Predicate.isNotUndefined(options.dragAxis))
|
|
@@ -3144,7 +3341,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3144
3341
|
gate.write(id, values)
|
|
3145
3342
|
recordFrame(values)
|
|
3146
3343
|
}
|
|
3147
|
-
// The
|
|
3344
|
+
// The Subject shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
|
|
3148
3345
|
const shown = (key: string): void => {
|
|
3149
3346
|
const keys = timelineKeysNow(routes)
|
|
3150
3347
|
if (Predicate.isNotUndefined(keys)) keys.shown(key)
|
|
@@ -3177,7 +3374,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3177
3374
|
delete snapshot.values[key]
|
|
3178
3375
|
delete snapshot.velocities[key]
|
|
3179
3376
|
if (Predicate.isNotUndefined(presence)) delete presence.snapshot.current[key]
|
|
3180
|
-
// Gone from `style`: the
|
|
3377
|
+
// Gone from `style`: the Subject's own value comes back, or none, its Environment's default now.
|
|
3181
3378
|
const restore = Option.match(ownValues.styleValueOf(UndefinedOr.match(styleNow, { onUndefined: constUndefined, onDefined: (style) => style() }), key), {
|
|
3182
3379
|
onNone: () => "",
|
|
3183
3380
|
onSome: String,
|
|
@@ -3207,8 +3404,8 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3207
3404
|
}
|
|
3208
3405
|
|
|
3209
3406
|
// A child back under its key (#286): its values and velocities from where the leaver is drawn, a
|
|
3210
|
-
// projected
|
|
3211
|
-
//
|
|
3407
|
+
// projected Subject's own translate among them (#363). Drawn at the end of the task, so nothing
|
|
3408
|
+
// draws the Subject at its `initial` first: not in the mount effect it's called in, where the
|
|
3212
3409
|
// first commit's Starting-style switch would flush Solid 2 inside an effect.
|
|
3213
3410
|
const seed = (from: PresenceRecord.PresenceSeed): void => {
|
|
3214
3411
|
const values = from.values
|
|
@@ -3245,7 +3442,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3245
3442
|
* one at mount; `sink` as it is otherwise. `config` reads it untracked.
|
|
3246
3443
|
*/
|
|
3247
3444
|
export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["onUpdate"], config: () => Config.SpineConfig): FlushGate.Sink => {
|
|
3248
|
-
// Per
|
|
3445
|
+
// Per Subject at mount: most have none, and pay a check.
|
|
3249
3446
|
if (Predicate.isUndefined(atMount)) return sink
|
|
3250
3447
|
return {
|
|
3251
3448
|
...sink,
|
|
@@ -3258,8 +3455,8 @@ export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["
|
|
|
3258
3455
|
|
|
3259
3456
|
/**
|
|
3260
3457
|
* A Retarget's note of the keys it started from their Base value, or returned to it (ADR-0022): run at
|
|
3261
|
-
* the head of its first leg, cold path (no fiber of its own: forking one per
|
|
3262
|
-
* at a 1000-
|
|
3458
|
+
* the head of its first leg, cold path (no fiber of its own: forking one per Subject cost 10-20 µs each
|
|
3459
|
+
* at a 1000-Subject mount).
|
|
3263
3460
|
*/
|
|
3264
3461
|
export const baseLog = (id: string, started: Record<string, string>, returns: ReadonlyArray<readonly [string, BaseValue.BaseSource]>): Effect.Effect<void> =>
|
|
3265
3462
|
Effect.logDebug("wardic.base: a key with no value started from, or returned to, its Base value (ADR-0022)").pipe(
|
|
@@ -3280,10 +3477,10 @@ const liveTargetOf = (ownValues: OwnValues.Shape, routes: LiveRoutes, key: strin
|
|
|
3280
3477
|
}
|
|
3281
3478
|
}
|
|
3282
3479
|
|
|
3283
|
-
/** Whether a value is one
|
|
3480
|
+
/** Whether a value is one a Subject can take: a number or a string. */
|
|
3284
3481
|
const isValue = (value: unknown): value is number | string => Bool.or(Predicate.isNumber(value), Predicate.isString(value))
|
|
3285
3482
|
|
|
3286
|
-
/** A provider runtime's `AtomRegistry`, read on first need:
|
|
3483
|
+
/** A provider runtime's `AtomRegistry`, read on first need: a Subject with no Atom never reads it. */
|
|
3287
3484
|
export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicServices>): (() => AtomRegistry.AtomRegistry) => {
|
|
3288
3485
|
let registry: AtomRegistry.AtomRegistry | undefined
|
|
3289
3486
|
return () => {
|
|
@@ -3292,7 +3489,7 @@ export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicS
|
|
|
3292
3489
|
}
|
|
3293
3490
|
}
|
|
3294
3491
|
|
|
3295
|
-
/** Whether a config makes its
|
|
3492
|
+
/** Whether a config makes its Subject a layout node: `layout` (or a mode), or a `layoutId`. */
|
|
3296
3493
|
export const isLayoutNode = (c: Config.SpineConfig): boolean =>
|
|
3297
3494
|
Bool.or(Bool.and(Predicate.isNotUndefined(c.layout), c.layout !== false), Predicate.isNotUndefined(c.layoutId))
|
|
3298
3495
|
|