@wardic/core 1.3.2 → 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 +15 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +218 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +7 -7
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +17 -16
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +5 -4
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +37 -14
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +1 -1
- package/dist/InputFeed.js +2 -2
- package/dist/InputSource.d.ts +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 +7 -6
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +45 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +7 -4
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +146 -45
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +6 -1
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +9 -9
- package/dist/Projection.js +2 -2
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.js +6 -6
- 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 +1 -1
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +102 -81
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/stepper.d.ts +13 -2
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +16 -1
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +37 -38
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +39 -36
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +5 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +19 -19
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +53 -51
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +56 -49
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +2 -2
- package/dist/unstable/FrameEffects.js +2 -2
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +29 -9
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +79 -47
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +26 -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 +1 -1
- package/dist/unstable/Report.js +1 -1
- package/dist/unstable/RetargetLegs.d.ts +1 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +9 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +81 -72
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +152 -150
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +7 -7
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +11 -11
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +36 -36
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +33 -33
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +236 -22
- package/src/Clock.ts +18 -17
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +41 -16
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +2 -2
- package/src/InputSource.ts +5 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +47 -17
- package/src/Machine.ts +199 -61
- package/src/Playback.ts +5 -1
- package/src/Projection.ts +9 -9
- package/src/Recognizer.ts +7 -7
- 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 +103 -87
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/stepper.ts +20 -2
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +59 -56
- package/src/unstable/AppearHandoff.ts +6 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +19 -19
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +92 -82
- package/src/unstable/FrameEffects.ts +2 -2
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +126 -56
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +29 -29
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +1 -1
- package/src/unstable/RetargetLegs.ts +10 -9
- package/src/unstable/Spine.ts +190 -188
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +13 -13
- package/src/unstable/VariantTree.ts +42 -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 })
|
|
@@ -142,12 +142,12 @@ export const exitTargetOf = (config: ExitConfig, presenceCustom: unknown, state:
|
|
|
142
142
|
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure }
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `
|
|
146
|
-
const exitGroupsOf = (targets: ReadonlyArray<VariantTarget.NamedTarget>,
|
|
145
|
+
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `wardTransition`. */
|
|
146
|
+
const exitGroupsOf = (targets: ReadonlyArray<VariantTarget.NamedTarget>, wardTransition: Config.WardicTransition | undefined): ReadonlyArray<PresenceRecord.ExitGroup> =>
|
|
147
147
|
Arr.map(targets, (target, i) => ({
|
|
148
148
|
name: target.name as string,
|
|
149
149
|
values: Rec.filter(target.values, (_, key) => Bool.not(Arr.some(Arr.drop(targets, i + 1), (later) => Object.hasOwn(later.values, key)))),
|
|
150
|
-
transition: VariantTarget.transitionOfTarget(target.transition,
|
|
150
|
+
transition: VariantTarget.transitionOfTarget(target.transition, wardTransition),
|
|
151
151
|
}))
|
|
152
152
|
|
|
153
153
|
/** A config given as a value or as an accessor, as an accessor. A config is always an object, so a function is the accessor. */
|
|
@@ -200,10 +200,10 @@ const keyTransitionOf = (
|
|
|
200
200
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
201
201
|
key: string,
|
|
202
202
|
transition: Config.WardicTransition | undefined,
|
|
203
|
-
|
|
203
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
204
204
|
): Config.WardicTransition | undefined => {
|
|
205
205
|
if (Predicate.isUndefined(groups)) return transition
|
|
206
|
-
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition,
|
|
206
|
+
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, wardTransition, undefined, identity)
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
|
|
@@ -225,7 +225,7 @@ const pickKeys = (t: Values.Values, groups: ReadonlyArray<ReadonlySet<string>> |
|
|
|
225
225
|
export const delayOf = (transition: Config.WardicTransition | undefined): number =>
|
|
226
226
|
UndefinedOr.match(transition, { onUndefined: () => 0, onDefined: ({ delay = 0 }) => delay })
|
|
227
227
|
|
|
228
|
-
/** No keys: what a drag moves on a projected
|
|
228
|
+
/** No keys: what a drag moves on a projected Subject, or one with no drag. */
|
|
229
229
|
const NO_KEYS: ReadonlyArray<string> = []
|
|
230
230
|
|
|
231
231
|
/** The keys a drag of `axis` moves directly. Built once, at module load. */
|
|
@@ -239,6 +239,8 @@ const dragMovesOf: (axis: boolean | "x" | "y") => ReadonlyArray<string> = Match.
|
|
|
239
239
|
const isSameKind = (value: number | string, like: number | string): boolean => Predicate.isNumber(value) === Predicate.isNumber(like)
|
|
240
240
|
|
|
241
241
|
/** The keys a drag direct-sets (ADR-0004). */
|
|
242
|
+
// `translateX` and `translateY` are the DOM's own keys since #1002 (ADR-0073, *Amendment (#1002)*, Q6): they
|
|
243
|
+
// stay here, plumbing, as the DOM's aliases of `x` and `y` that a drag holds back too.
|
|
242
244
|
const TRANSLATE_KEYS: ReadonlySet<string> = new Set(["x", "y", "translateX", "translateY"])
|
|
243
245
|
const TRANSLATE_KEY_LIST: ReadonlyArray<string> = Arr.fromIterable(TRANSLATE_KEYS)
|
|
244
246
|
|
|
@@ -402,7 +404,7 @@ const setsValues = (layer: OverrideEntry): boolean => {
|
|
|
402
404
|
/** A single entry's name: itself, if a name; `undefined` for a values map. */
|
|
403
405
|
const labelOrUndefined = (entry: VariantTarget.Entry): string | undefined => Bool.match(Predicate.isString(entry), { onTrue: () => entry as string, onFalse: constUndefined })
|
|
404
406
|
|
|
405
|
-
/** Each gesture on: the
|
|
407
|
+
/** Each gesture on: the Subject's own, or its provider's too when it has one handing any down. */
|
|
406
408
|
const gesturesOnOf = (active: Active, above: VariantTree.GestureHandDown): VariantTree.GestureStates => {
|
|
407
409
|
if (above === VariantTree.NO_HAND_DOWN) return active
|
|
408
410
|
return VariantTree.gesturesOn(active, above.on)
|
|
@@ -422,7 +424,7 @@ const anyOn = (on: VariantTree.GestureStates): boolean => on.inView || on.focuse
|
|
|
422
424
|
|
|
423
425
|
/**
|
|
424
426
|
* Whether an active entry's name delays its keys otherwise than the first entry's (#297): a Variant
|
|
425
|
-
* child's names each take their own stagger slot. Never for
|
|
427
|
+
* child's names each take their own stagger slot. Never for a Subject that joins none, nor for one
|
|
426
428
|
* entry.
|
|
427
429
|
*/
|
|
428
430
|
const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name: string | undefined) => number) | undefined, extra: number): boolean => {
|
|
@@ -430,7 +432,7 @@ const delaysDiffer = (layers: ReadonlyArray<OverrideEntry>, extraDelay: ((name:
|
|
|
430
432
|
return Arr.some(layers, (layer) => Bool.and(layer.active, extraOf(extraDelay, layer) !== extra))
|
|
431
433
|
}
|
|
432
434
|
|
|
433
|
-
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other
|
|
435
|
+
/** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other Subject. */
|
|
434
436
|
const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined, layer: OverrideEntry | undefined): number => {
|
|
435
437
|
if (Predicate.isUndefined(extraDelay)) return 0
|
|
436
438
|
if (Predicate.isUndefined(layer)) return extraDelay(undefined)
|
|
@@ -439,8 +441,8 @@ const extraOf = (extraDelay: ((name: string | undefined) => number) | undefined,
|
|
|
439
441
|
|
|
440
442
|
/**
|
|
441
443
|
* The transition a key group runs on (#291, #297): unsplit, the base's (`transition`, its delay
|
|
442
|
-
* folded in); split, its entry's own, else the
|
|
443
|
-
* group carries its returns too, which run on the
|
|
444
|
+
* folded in); split, its entry's own, else the Subject's, at its name's delay. A list's first
|
|
445
|
+
* group carries its returns too, which run on the Subject's transition, as a list's base has no one
|
|
444
446
|
* transition of its own.
|
|
445
447
|
*/
|
|
446
448
|
const groupTransitionOf = (
|
|
@@ -448,16 +450,16 @@ const groupTransitionOf = (
|
|
|
448
450
|
groups: ReadonlyArray<ReadonlySet<string>> | undefined,
|
|
449
451
|
i: number,
|
|
450
452
|
transition: Config.WardicTransition | undefined,
|
|
451
|
-
|
|
453
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
452
454
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
453
455
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
454
456
|
): Config.WardicTransition | undefined => {
|
|
455
457
|
if (Predicate.isUndefined(groups)) return transition
|
|
456
458
|
if (Bool.and(i === 0, Bool.not(Arr.isArray(resolution.variant)))) return transition
|
|
457
459
|
const layer = resolution.layers[i]
|
|
458
|
-
// A list's returns: the
|
|
459
|
-
if (Predicate.isUndefined(layer)) return staggeredOf(
|
|
460
|
-
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition,
|
|
460
|
+
// A list's returns: the Subject's, at its whole orchestration's delay.
|
|
461
|
+
if (Predicate.isUndefined(layer)) return staggeredOf(wardTransition, extraOf(extraDelay, undefined), reuse)
|
|
462
|
+
return staggeredOf(VariantTarget.transitionOfTarget(layer.transition, wardTransition), extraOf(extraDelay, layer), reuse)
|
|
461
463
|
}
|
|
462
464
|
|
|
463
465
|
/** No names. */
|
|
@@ -480,7 +482,7 @@ export interface Landing {
|
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
/**
|
|
483
|
-
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the
|
|
485
|
+
* A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the Subject
|
|
484
486
|
* unsettled, as it still owes an animation, and land nothing; the Retarget once the gate opens
|
|
485
487
|
* counts them.
|
|
486
488
|
*/
|
|
@@ -564,7 +566,7 @@ interface PendingEnd {
|
|
|
564
566
|
state: "waiting" | "due" | "written" | "dropped"
|
|
565
567
|
}
|
|
566
568
|
|
|
567
|
-
/**
|
|
569
|
+
/** A Subject's waiting Transition ends (#508). */
|
|
568
570
|
interface WaitingEnds {
|
|
569
571
|
/** An entry's end, waiting for its keys, or due already when they've landed. */
|
|
570
572
|
readonly add: (end: PendingEnd) => void
|
|
@@ -572,12 +574,12 @@ interface WaitingEnds {
|
|
|
572
574
|
readonly land: () => void
|
|
573
575
|
/** The end `running` is, dropped, whether it waits or is due: given up, stopped or ended. */
|
|
574
576
|
readonly drop: (running: Running) => void
|
|
575
|
-
/** The
|
|
577
|
+
/** The Subject is gone: none is written. */
|
|
576
578
|
readonly dispose: () => void
|
|
577
579
|
}
|
|
578
580
|
|
|
579
581
|
/**
|
|
580
|
-
* The waiting Transition ends of
|
|
582
|
+
* The waiting Transition ends of Subject `id` (#508): made at its first end, so a Subject with none,
|
|
581
583
|
* nearly every one, pays nothing for them. `owners` holds the leg drawing each key.
|
|
582
584
|
*/
|
|
583
585
|
const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape, id: string, recordFrame: (value: Values.Values) => void): WaitingEnds => {
|
|
@@ -661,7 +663,7 @@ const waitingEndsOf = (owners: Owners, snapshot: Snapshot, gate: FlushGate.Shape
|
|
|
661
663
|
}
|
|
662
664
|
}
|
|
663
665
|
|
|
664
|
-
/** A leg's last frame lands the Transition ends waiting on it (#508);
|
|
666
|
+
/** A leg's last frame lands the Transition ends waiting on it (#508); a Subject with none has nothing to ask. */
|
|
665
667
|
const landEndsOf = (waiting: WaitingEnds | undefined): void => {
|
|
666
668
|
if (Predicate.isNotUndefined(waiting)) waiting.land()
|
|
667
669
|
}
|
|
@@ -671,7 +673,7 @@ export const NO_VALUES: Values.Values = {}
|
|
|
671
673
|
|
|
672
674
|
/**
|
|
673
675
|
* Whether a change's starts, targets or Keyframes stops hold a Variable value (#542): only then can
|
|
674
|
-
* the
|
|
676
|
+
* the Subject's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
|
|
675
677
|
* built under it. It declines every pair with no `var()` at either end.
|
|
676
678
|
*/
|
|
677
679
|
export const holdsVariable = (variables: VariableValues.Shape, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined): boolean => {
|
|
@@ -696,7 +698,7 @@ const stopsCheckOf = (variables: VariableValues.Shape): ((stops: ReadonlyArray<n
|
|
|
696
698
|
return check
|
|
697
699
|
}
|
|
698
700
|
|
|
699
|
-
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto
|
|
701
|
+
/** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto the Subject's turn. */
|
|
700
702
|
const PATH_ROTATION = "pathRotation"
|
|
701
703
|
|
|
702
704
|
/** The turn back at 0, written once no leg draws it (#460). */
|
|
@@ -824,7 +826,7 @@ const restOf = (owners: Owners, target: Values.Values, axis: "x" | "y"): number
|
|
|
824
826
|
/**
|
|
825
827
|
* Where a Path's axes that `target` leaves out rest (#574), read before their legs give them up: a
|
|
826
828
|
* new Path ends them there, so a toss caught mid-air curves back to its line. `undefined` for none:
|
|
827
|
-
* every
|
|
829
|
+
* every Subject's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
|
|
828
830
|
*/
|
|
829
831
|
export const restsOf = (owners: Owners, target: Values.Values): Values.Values | undefined => {
|
|
830
832
|
const x = restOf(owners, target, "x")
|
|
@@ -877,7 +879,7 @@ const splitLegsOf = (
|
|
|
877
879
|
resolution: Resolution,
|
|
878
880
|
listed: boolean,
|
|
879
881
|
transition: Config.WardicTransition | undefined,
|
|
880
|
-
|
|
882
|
+
wardTransition: Config.WardicTransition | undefined,
|
|
881
883
|
extraDelay: ((name: string | undefined) => number) | undefined,
|
|
882
884
|
reuse: (transition: Config.WardicTransition) => Config.WardicTransition,
|
|
883
885
|
reduce: boolean,
|
|
@@ -902,7 +904,7 @@ const splitLegsOf = (
|
|
|
902
904
|
if (Rec.isEmptyRecord(picked)) return
|
|
903
905
|
let followed: RetargetLegs.Follows | undefined
|
|
904
906
|
if (i === returnsAt) followed = follow
|
|
905
|
-
const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition,
|
|
907
|
+
const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition, wardTransition, extraDelay, reuse), reduce, skipped, positionalKeys, defaultTransition, velocities, followed, stops, measured, current, rests, unitScale)
|
|
906
908
|
Arr.forEach(groupLegs, (built) => {
|
|
907
909
|
legs.push(built)
|
|
908
910
|
tags.push(i)
|
|
@@ -939,7 +941,7 @@ interface ListingOf {
|
|
|
939
941
|
* A list's names at a Retarget (#297): told settled as the legs of the keys each drives settle, to
|
|
940
942
|
* the binding's callbacks (Solid 1's, PR 1) and to its orchestration (PR 2), told moving now; and each
|
|
941
943
|
* shut name's legs waiting on its gate (PR 2), its keys held where they start, so another name's first
|
|
942
|
-
* commit, which hands the
|
|
944
|
+
* commit, which hands the Subject's style back (ADR-0034), doesn't drop them to their own value.
|
|
943
945
|
*/
|
|
944
946
|
const listingOf = (of: ListingOf): Listing => {
|
|
945
947
|
const { listed, told, byName, resolution, groups, legGroups, legCount, carriedGroups, shut, config } = of
|
|
@@ -1002,7 +1004,7 @@ const logsDebugOn = (runtime: WardicServices.Runner<WardicServices.WardicService
|
|
|
1002
1004
|
}
|
|
1003
1005
|
|
|
1004
1006
|
/**
|
|
1005
|
-
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so
|
|
1007
|
+
* No key taken by an Imperative animation (#433): every spine's until its first, shared, so a Subject
|
|
1006
1008
|
* none animates holds no map of its own (#460). Never written: a spine sets keys in a map of its own,
|
|
1007
1009
|
* and deletes only from one that has some.
|
|
1008
1010
|
*/
|
|
@@ -1102,7 +1104,7 @@ const hasKeyframes = (layer: OverrideEntry): boolean => {
|
|
|
1102
1104
|
|
|
1103
1105
|
/**
|
|
1104
1106
|
* Each resolved key's Keyframes (#429): the stops of the entry that drives it, when that entry gives
|
|
1105
|
-
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every
|
|
1107
|
+
* it Keyframes. `undefined`, with nothing made, when no active entry has any: every Subject's common
|
|
1106
1108
|
* case.
|
|
1107
1109
|
*/
|
|
1108
1110
|
const keyframesNowOf = (layers: ReadonlyArray<OverrideEntry>, resolved: Values.Values): KeyframesNow | undefined => {
|
|
@@ -1212,11 +1214,11 @@ const measuringOf = (found: ReadonlyArray<string> | undefined, keyframes: Keyfra
|
|
|
1212
1214
|
|
|
1213
1215
|
/**
|
|
1214
1216
|
* A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
|
|
1215
|
-
* end-of-task batch with the values the
|
|
1217
|
+
* end-of-task batch with the values the Subject draws now, but a key with Keyframes of more than two
|
|
1216
1218
|
* stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
|
|
1217
|
-
* it couldn't read do, reported on `runtime` with the
|
|
1219
|
+
* it couldn't read do, reported on `runtime` with the Subject's `id`.
|
|
1218
1220
|
*/
|
|
1219
|
-
export const measuredOf = (measured: MeasuredPairs.Shape,
|
|
1221
|
+
export const measuredOf = (measured: MeasuredPairs.Shape, subject: Subject.Subject, keys: ReadonlyArray<string>, from: Values.Values, to: Values.Values, values: Values.Values, many: RetargetLegs.StopsByKey | undefined, runtime: Pick<WardicServices.Runner<never>, "runFork">, id: string): RetargetLegs.MeasuredPairs | undefined => {
|
|
1220
1222
|
const pairs: Record<string, { readonly from: number | string; readonly to: number | string }> = {}
|
|
1221
1223
|
Arr.forEach(keys, (key) => {
|
|
1222
1224
|
if (RetargetLegs.hasManyStops(many, key)) return
|
|
@@ -1226,8 +1228,8 @@ export const measuredOf = (measured: MeasuredPairs.Shape, element: Subject.Subje
|
|
|
1226
1228
|
if (measured.needs(key, start as number | string, target as number | string)) pairs[key] = { from: start as number | string, to: target as number | string }
|
|
1227
1229
|
})
|
|
1228
1230
|
if (Rec.isEmptyRecord(pairs)) return undefined
|
|
1229
|
-
// Its report made only for pairs asked, not once
|
|
1230
|
-
return measured.measure(
|
|
1231
|
+
// Its report made only for pairs asked, not once a Subject (#979, row 8): nearly every Retarget asks none.
|
|
1232
|
+
return measured.measure(subject, pairs, values, pairsFailedOn("wardic.spine: a Retarget's Measured pairs failed", runtime, { id }))
|
|
1231
1233
|
}
|
|
1232
1234
|
|
|
1233
1235
|
/** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
|
|
@@ -1419,15 +1421,15 @@ const nameSettlesOf = (
|
|
|
1419
1421
|
* Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
|
|
1420
1422
|
* config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
|
|
1421
1423
|
* the config. A callback that throws is reported at the first of a run of throws, its next clean call
|
|
1422
|
-
* ending the run, and the
|
|
1424
|
+
* ending the run, and the Subject animates on. The Solid 2 binding's config has neither: it hands the
|
|
1423
1425
|
* same facts over as async values.
|
|
1424
1426
|
*/
|
|
1425
1427
|
export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices.WardicServices>, id: string): AnimationHooks => {
|
|
1426
1428
|
// #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
|
|
1427
|
-
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per
|
|
1429
|
+
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per Subject.
|
|
1428
1430
|
let startFailing = false
|
|
1429
1431
|
let completeFailing = false
|
|
1430
|
-
// Per Retarget, per
|
|
1432
|
+
// Per Retarget, per Subject: the callback looked up first, and nothing made without one. Whether it threw,
|
|
1431
1433
|
// reported at a run's first throw (`failing` says one is on).
|
|
1432
1434
|
const tell = (
|
|
1433
1435
|
name: "onAnimationStart" | "onAnimationComplete",
|
|
@@ -1489,7 +1491,7 @@ export interface Active {
|
|
|
1489
1491
|
readonly dragging: boolean
|
|
1490
1492
|
}
|
|
1491
1493
|
|
|
1492
|
-
/** The variant name
|
|
1494
|
+
/** The variant name a Subject animates to: its own `animate`'s, else the one its provider hands down. */
|
|
1493
1495
|
const variantOf = (animate: Config.SpineConfig["animate"], parent: VariantTree.WardicVariantContextValue | undefined): Config.WardicVariantLabels | undefined => {
|
|
1494
1496
|
if (Predicate.isNotUndefined(animate)) return VariantTree.nameOf(animate)
|
|
1495
1497
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1536,7 +1538,7 @@ export const resolutionOf = (
|
|
|
1536
1538
|
// sibling's "open"); read parent.variant() here so a parent flip
|
|
1537
1539
|
// recomputes the memo and retargets;
|
|
1538
1540
|
// (3) else the SSR-seeded `initial`.
|
|
1539
|
-
// Per Retarget, per
|
|
1541
|
+
// Per Retarget, per Subject (#460, compose once): statements.
|
|
1540
1542
|
const variant = variantOf(c.animate, parent)
|
|
1541
1543
|
// A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
|
|
1542
1544
|
// that sets a key drives it. A single name or a values map takes the path below, as before.
|
|
@@ -1546,7 +1548,7 @@ export const resolutionOf = (
|
|
|
1546
1548
|
const listLayers: Array<OverrideEntry> = Arr.map(targets, namedLayerOf)
|
|
1547
1549
|
return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1548
1550
|
}
|
|
1549
|
-
// A dynamic variant resolves with this
|
|
1551
|
+
// A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
|
|
1550
1552
|
// Animation controls never reach here: its binding reads them once, each change its entry (#433).
|
|
1551
1553
|
const target = baseTargetOf(c.animate as VariantTarget.Entry | undefined, variant, variants, c.custom, state, initialLink)
|
|
1552
1554
|
const base = target.values
|
|
@@ -1554,7 +1556,7 @@ export const resolutionOf = (
|
|
|
1554
1556
|
// A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
|
|
1555
1557
|
// its own `while*`, else the label the provider hands down. With no provider, its own: nothing made.
|
|
1556
1558
|
// The common case: nothing handed down and no gesture on. The base entry alone, and nothing else
|
|
1557
|
-
// made or called, at every
|
|
1559
|
+
// made or called, at every Subject's mount and Retarget.
|
|
1558
1560
|
if (VariantTree.handDownFrom(parent) === VariantTree.NO_HAND_DOWN && !anyOn(active)) {
|
|
1559
1561
|
const alone: ReadonlyArray<OverrideEntry> = [baseLayer]
|
|
1560
1562
|
const { resolved, ends, keyframes } = resolvedOf(alone)
|
|
@@ -1563,7 +1565,7 @@ export const resolutionOf = (
|
|
|
1563
1565
|
return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1564
1566
|
}
|
|
1565
1567
|
|
|
1566
|
-
/** 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. */
|
|
1567
1569
|
const changeIn = (own: AnimationControls.ControlsChange | undefined, parent: VariantTree.WardicVariantContextValue | undefined): AnimationControls.ControlsChange | undefined => {
|
|
1568
1570
|
if (Predicate.isNotUndefined(own)) return own
|
|
1569
1571
|
if (Predicate.isUndefined(parent)) return undefined
|
|
@@ -1627,7 +1629,7 @@ const withGestures = (
|
|
|
1627
1629
|
return { resolved, base, dragging: active.dragging, variant, active, transition, layers, names, layersOn, ends, keyframes, change }
|
|
1628
1630
|
}
|
|
1629
1631
|
|
|
1630
|
-
/** The values
|
|
1632
|
+
/** The values a Subject starts from, read once at setup (ADR-0003, #134). */
|
|
1631
1633
|
export interface Start {
|
|
1632
1634
|
/** Its Starting style's values: its `initial` (own or inherited, #50), or its `animate` when it starts there. */
|
|
1633
1635
|
readonly initialValues: Values.Values
|
|
@@ -1647,7 +1649,7 @@ export interface Start {
|
|
|
1647
1649
|
}
|
|
1648
1650
|
|
|
1649
1651
|
/**
|
|
1650
|
-
*
|
|
1652
|
+
* A Subject's {@link Start}, from its config read once and the context it inherits from. With
|
|
1651
1653
|
* `initial={false}` (its own, inherited, or an `<AnimatePresence initial={false}>`'s first render)
|
|
1652
1654
|
* it starts at its `animate`, and nothing animates at mount (#134).
|
|
1653
1655
|
*/
|
|
@@ -1659,7 +1661,7 @@ export const startOf = (
|
|
|
1659
1661
|
): Start => {
|
|
1660
1662
|
const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks)
|
|
1661
1663
|
// Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
|
|
1662
|
-
// for
|
|
1664
|
+
// for a Subject with no variants, so its start makes nothing more (bench:solid's mount).
|
|
1663
1665
|
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom)
|
|
1664
1666
|
const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants)
|
|
1665
1667
|
return {
|
|
@@ -1679,15 +1681,15 @@ const failedOn =
|
|
|
1679
1681
|
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }))
|
|
1680
1682
|
}
|
|
1681
1683
|
|
|
1682
|
-
/** How
|
|
1684
|
+
/** How a Subject's variant that throws is reported, on its runtime. */
|
|
1683
1685
|
const variantFailedOn = failedOn("wardic.ward: a variant failed")
|
|
1684
1686
|
|
|
1685
|
-
/** How an exit whose resolver throws is reported, on `runtime`, each time
|
|
1687
|
+
/** How an exit whose resolver throws is reported, on `runtime`, each time a Subject leaves: its Subject leaves without it (#979). */
|
|
1686
1688
|
export const exitVariantFailedOn: (runtime: Pick<WardicServices.Runner<never>, "runFork">) => (failure: VariantTarget.VariantFailure) => void = failedOn(
|
|
1687
1689
|
"wardic.presence: an exit variant failed",
|
|
1688
1690
|
)
|
|
1689
1691
|
|
|
1690
|
-
/**
|
|
1692
|
+
/** A Subject's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
|
|
1691
1693
|
export const variantFailedOnServer: (failure: VariantTarget.VariantFailure) => void = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER)
|
|
1692
1694
|
|
|
1693
1695
|
/** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
|
|
@@ -1697,31 +1699,31 @@ const firstFailureOf = Arr.findFirst<OverrideEntry, VariantTarget.VariantFailure
|
|
|
1697
1699
|
export const failureOf = (resolution: Resolution): Option.Option<VariantTarget.VariantFailure> => firstFailureOf(resolution.layers)
|
|
1698
1700
|
|
|
1699
1701
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
* the places that saw it fail. One
|
|
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
|
|
1702
1704
|
* read through {@link keptOf}, {@link reportStart} and {@link orchestrationOf}: each variant is
|
|
1703
1705
|
* reported once, until it resolves again.
|
|
1704
1706
|
*/
|
|
1705
1707
|
export interface VariantFailures extends VariantTree.DelayFailures {
|
|
1706
1708
|
/** Its last resolution with no failure: what {@link keptOf} gives while one carries a failure. */
|
|
1707
1709
|
last: Resolution | undefined
|
|
1708
|
-
/** Each failing variant, by name, and where it was seen; made at the first failure: most
|
|
1710
|
+
/** Each failing variant, by name, and where it was seen; made at the first failure: most Subjects never have one. */
|
|
1709
1711
|
failing: Map<string, number> | undefined
|
|
1710
1712
|
/** The runtime its failures are reported on, at Error. */
|
|
1711
1713
|
readonly runtime: Pick<WardicServices.Runner<never>, "runFork">
|
|
1712
1714
|
}
|
|
1713
1715
|
|
|
1714
|
-
/**
|
|
1715
|
-
// #979 (bench:solid's mount): one plain object
|
|
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
|
|
1716
1718
|
// holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
|
|
1717
|
-
// WeakMap cost Solid 1's mount 6% (the lookup,
|
|
1719
|
+
// WeakMap cost Solid 1's mount 6% (the lookup, a Subject).
|
|
1718
1720
|
export const variantFailuresOf = (runtime: Pick<WardicServices.Runner<never>, "runFork">): VariantFailures => ({ last: undefined, failing: undefined, delayFailing: false, runtime })
|
|
1719
1721
|
|
|
1720
|
-
/** Where a variant's failure was seen, until each resolves it again: its
|
|
1722
|
+
/** Where a variant's failure was seen, until each resolves it again: its Subject's resolutions, and its orchestration. */
|
|
1721
1723
|
const RESOLVING = 1
|
|
1722
1724
|
const ORCHESTRATING = 2
|
|
1723
1725
|
|
|
1724
|
-
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its
|
|
1726
|
+
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its Subject's alone. Each variant, by name,
|
|
1725
1727
|
// is reported as it starts failing and fails until every place that saw it fail resolves it again, so
|
|
1726
1728
|
// a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
|
|
1727
1729
|
// values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
|
|
@@ -1750,8 +1752,8 @@ const resolvedAt = (failing: Map<string, number>, name: string | undefined, at:
|
|
|
1750
1752
|
failing.set(name, after)
|
|
1751
1753
|
}
|
|
1752
1754
|
|
|
1753
|
-
/** `next`, else, while it carries a failure, the
|
|
1754
|
-
// Per Retarget, per
|
|
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.
|
|
1755
1757
|
export const keptOf = (failures: VariantFailures, next: Resolution): Resolution => {
|
|
1756
1758
|
const failure = failureOf(next)
|
|
1757
1759
|
if (Option.isSome(failure)) {
|
|
@@ -1773,7 +1775,7 @@ export const reportStart = (failures: VariantFailures, start: Start): void => {
|
|
|
1773
1775
|
if (Option.isSome(start.failure)) failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING)
|
|
1774
1776
|
}
|
|
1775
1777
|
|
|
1776
|
-
/** What
|
|
1778
|
+
/** What a Subject's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
|
|
1777
1779
|
export const orchestrationOf =
|
|
1778
1780
|
(failures: VariantFailures): VariantTarget.Orchestrated =>
|
|
1779
1781
|
(entry, failure) => {
|
|
@@ -1893,9 +1895,9 @@ export const velocitiesNowOf = (snapshot: Snapshot): Readonly<Record<string, num
|
|
|
1893
1895
|
}
|
|
1894
1896
|
|
|
1895
1897
|
/**
|
|
1896
|
-
* 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
|
|
1897
1899
|
* fields, so core's decode cache hits when the object is rebuilt with the same values (a staggered
|
|
1898
|
-
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per
|
|
1900
|
+
* child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per Subject.
|
|
1899
1901
|
*/
|
|
1900
1902
|
export const makeReuse = (): ((transition: Config.WardicTransition) => Config.WardicTransition) => {
|
|
1901
1903
|
let lastTransition: Config.WardicTransition | undefined
|
|
@@ -1908,7 +1910,7 @@ export const makeReuse = (): ((transition: Config.WardicTransition) => Config.Wa
|
|
|
1908
1910
|
}
|
|
1909
1911
|
|
|
1910
1912
|
/**
|
|
1911
|
-
* A mounted
|
|
1913
|
+
* A mounted Subject's Base-value links (ADR-0022), as its binding reads them: its Own value per key,
|
|
1912
1914
|
* the links for a key's start coerced to the shape of its target (`like`), and that start.
|
|
1913
1915
|
*/
|
|
1914
1916
|
// #672: the spine names what it calls; the binding's `startLinksOf` (`element-setup.ts`) makes them.
|
|
@@ -1919,12 +1921,12 @@ export interface StartLinks {
|
|
|
1919
1921
|
}
|
|
1920
1922
|
|
|
1921
1923
|
/**
|
|
1922
|
-
*
|
|
1924
|
+
* A Subject's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
|
|
1923
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
|
|
1924
1926
|
* from its Base value's start links (ADR-0022), read from the Subject kept at the exit.
|
|
1925
1927
|
*/
|
|
1926
1928
|
export const presenceRecordOf = <E extends Subject.Subject>(
|
|
1927
|
-
|
|
1929
|
+
subject: E,
|
|
1928
1930
|
start: Start,
|
|
1929
1931
|
exitOf: (custom: unknown, inherited: Config.WardicVariantLabels | undefined) => ExitTarget,
|
|
1930
1932
|
links: StartLinks,
|
|
@@ -1933,7 +1935,7 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1933
1935
|
reducedMotion: () => boolean,
|
|
1934
1936
|
skipAnimations: () => boolean,
|
|
1935
1937
|
): PresenceRecord.PresenceRecord<E> => ({
|
|
1936
|
-
|
|
1938
|
+
subject,
|
|
1937
1939
|
snapshot: { current: { ...start.initialValues } },
|
|
1938
1940
|
exitOf,
|
|
1939
1941
|
tree,
|
|
@@ -1942,30 +1944,30 @@ export const presenceRecordOf = <E extends Subject.Subject>(
|
|
|
1942
1944
|
velocities: () => velocitiesNowOf(snapshot),
|
|
1943
1945
|
// Its own, under its nearest WardicConfig (#434): its exit honours it, not the presence's.
|
|
1944
1946
|
reducedMotion,
|
|
1945
|
-
// 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.
|
|
1946
1948
|
skipAnimations,
|
|
1947
1949
|
})
|
|
1948
1950
|
|
|
1949
1951
|
/**
|
|
1950
1952
|
* Merge an emitted frame's value-map into a presence record's snapshot (nothing without one). It
|
|
1951
|
-
* mirrors what the gate accumulates, so an exit departs from the
|
|
1953
|
+
* mirrors what the gate accumulates, so an exit departs from the Subject's actual resting value-map.
|
|
1952
1954
|
*/
|
|
1953
1955
|
export const recordFrameOf = (presence: PresenceRecord.PresenceRecord | undefined): ((value: Values.Values) => void) => (value) => {
|
|
1954
1956
|
if (Predicate.isNotUndefined(presence)) Object.assign(presence.snapshot.current, value)
|
|
1955
1957
|
}
|
|
1956
1958
|
|
|
1957
|
-
/** Tell
|
|
1959
|
+
/** Tell a Subject's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for a Subject with none. */
|
|
1958
1960
|
export const tellStarted = (live: LiveRoutes | undefined, legs: ReadonlyArray<RetargetLegs.Leg>): void => {
|
|
1959
1961
|
if (Predicate.isUndefined(live)) return
|
|
1960
1962
|
live.started(legs)
|
|
1961
1963
|
}
|
|
1962
1964
|
|
|
1963
1965
|
// A Batch member's hold's slot (#665, #746; #672's Q14: the spine's, so it reads no Batch code).
|
|
1964
|
-
/** What a Batch member's hold reads of what its
|
|
1965
|
-
export type HoldHost = Pick<SpineHost, "
|
|
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">
|
|
1966
1968
|
|
|
1967
1969
|
/**
|
|
1968
|
-
* 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,
|
|
1969
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
|
|
1970
1972
|
* at its Batch's next change of it.
|
|
1971
1973
|
*/
|
|
@@ -1980,13 +1982,13 @@ export interface MemberHold {
|
|
|
1980
1982
|
readonly settle: () => void
|
|
1981
1983
|
/** Its drag reads or writes `x`/`y` (`true`): it takes the transform; or hands them back (`false`). */
|
|
1982
1984
|
readonly drag: (on: boolean) => void
|
|
1983
|
-
/** Its
|
|
1985
|
+
/** Its Subject unmounted: every group back to the Batch. */
|
|
1984
1986
|
readonly dispose: () => void
|
|
1985
1987
|
}
|
|
1986
1988
|
|
|
1987
|
-
/** How a spine finds its
|
|
1989
|
+
/** How a spine finds its Subject a Batch member's, and makes its hold. */
|
|
1988
1990
|
export interface MemberHolds {
|
|
1989
|
-
readonly isMember: (
|
|
1991
|
+
readonly isMember: (subject: Subject.Subject) => boolean
|
|
1990
1992
|
readonly make: (host: HoldHost) => MemberHold
|
|
1991
1993
|
}
|
|
1992
1994
|
|
|
@@ -1998,7 +2000,7 @@ export const memberHoldsNow = (): MemberHolds | undefined => holds
|
|
|
1998
2000
|
|
|
1999
2001
|
/**
|
|
2000
2002
|
* Holds made from now on, through `holds` (`createBatch`, as it's called, gives a Batch's): a Batch's
|
|
2001
|
-
* members can be
|
|
2003
|
+
* members can be Wards' Subjects. The first one given stays.
|
|
2002
2004
|
*/
|
|
2003
2005
|
export const provideMemberHolds = (given: MemberHolds): void => {
|
|
2004
2006
|
if (Predicate.isNotUndefined(holds)) return
|
|
@@ -2006,22 +2008,22 @@ export const provideMemberHolds = (given: MemberHolds): void => {
|
|
|
2006
2008
|
}
|
|
2007
2009
|
|
|
2008
2010
|
/**
|
|
2009
|
-
* Each draggable
|
|
2010
|
-
*
|
|
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
|
|
2011
2013
|
* transform from its Batch then, and gives it back.
|
|
2012
2014
|
*/
|
|
2013
|
-
// Module state (#460, Q7): held weakly by the
|
|
2015
|
+
// Module state (#460, Q7): held weakly by the Subject, so it goes with it.
|
|
2014
2016
|
const DRAG_HOOKS = new WeakMap<Subject.Subject, (on: boolean) => void>()
|
|
2015
2017
|
|
|
2016
|
-
/** `
|
|
2017
|
-
export const tellDrag = (
|
|
2018
|
-
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))
|
|
2019
2021
|
}
|
|
2020
2022
|
|
|
2021
2023
|
/**
|
|
2022
|
-
* 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):
|
|
2023
2025
|
* the routed keys' values now, and each one's change and removal as they come; and the legs each
|
|
2024
|
-
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its
|
|
2026
|
+
* Retarget starts, which its binding's routes may act on (`@wardic/dom`'s readies its Subject for them, #443).
|
|
2025
2027
|
*/
|
|
2026
2028
|
// #672 (PR3-Q1): the spine names what it calls, so it reads no `style` code; dom's LiveStyle meets it.
|
|
2027
2029
|
export interface LiveRoutes {
|
|
@@ -2042,7 +2044,7 @@ export interface LiveFollower {
|
|
|
2042
2044
|
}
|
|
2043
2045
|
|
|
2044
2046
|
/**
|
|
2045
|
-
* 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
|
|
2046
2048
|
* release in flight (#340). Its binding's drag track gives it.
|
|
2047
2049
|
*/
|
|
2048
2050
|
// #672 (Q15): the spine names what it calls, so it reads no drag code.
|
|
@@ -2050,16 +2052,16 @@ export interface SpineDrag {
|
|
|
2050
2052
|
readonly takeRelease: (retargeted: { readonly x: boolean; readonly y: boolean }) => boolean
|
|
2051
2053
|
}
|
|
2052
2054
|
|
|
2053
|
-
/** What {@link
|
|
2054
|
-
export interface
|
|
2055
|
+
/** What {@link makeSubjectSpine} reads. */
|
|
2056
|
+
export interface SubjectSpineOptions {
|
|
2055
2057
|
/** The provider runtime the legs fork on. */
|
|
2056
2058
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
2057
2059
|
/** The provider-owned flush gate (ADR-0006). */
|
|
2058
2060
|
readonly gate: FlushGate.Shape
|
|
2059
|
-
/** The
|
|
2061
|
+
/** The Subject's gate id. */
|
|
2060
2062
|
readonly id: string
|
|
2061
|
-
/** The mounted
|
|
2062
|
-
readonly
|
|
2063
|
+
/** The mounted Subject. */
|
|
2064
|
+
readonly subject: Subject.Subject
|
|
2063
2065
|
/** Its tag, for a Handoff's check (its Environment routes some keys by it): `undefined` when it isn't known. */
|
|
2064
2066
|
readonly tag: string | undefined
|
|
2065
2067
|
/** Its config now, read where the binding doesn't track. */
|
|
@@ -2119,7 +2121,7 @@ export interface ElementSpineOptions {
|
|
|
2119
2121
|
readonly animation?: AnimationHooks | undefined
|
|
2120
2122
|
/**
|
|
2121
2123
|
* A list's names orchestrated each on their own (#297's PR 2): a name's keys start once its gate
|
|
2122
|
-
* opens, and its starts and settles are told. Omitted for
|
|
2124
|
+
* opens, and its starts and settles are told. Omitted for a Subject that joins nothing and
|
|
2123
2125
|
* provides nothing.
|
|
2124
2126
|
*/
|
|
2125
2127
|
readonly byName?: VariantTree.NameOrchestration | undefined
|
|
@@ -2145,16 +2147,16 @@ const takeEach = (timelineKeys: Timelines.TimelineKeys, values: Values.Values):
|
|
|
2145
2147
|
Arr.forEach(Rec.keys(values), (key) => timelineKeys.taken(key))
|
|
2146
2148
|
}
|
|
2147
2149
|
|
|
2148
|
-
/** What the follower reads of the
|
|
2150
|
+
/** What the follower reads of the Subject's Override stack and drag, untracked. */
|
|
2149
2151
|
export interface FollowNow {
|
|
2150
2152
|
readonly resolved: () => Values.Values
|
|
2151
2153
|
readonly dragging: () => boolean
|
|
2152
2154
|
}
|
|
2153
2155
|
|
|
2154
|
-
/** What an **Imperative animation** tells of its legs on one
|
|
2156
|
+
/** What an **Imperative animation** tells of its legs on one Subject (#433). */
|
|
2155
2157
|
export interface ImperativeHooks {
|
|
2156
2158
|
/**
|
|
2157
|
-
* 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:
|
|
2158
2160
|
* `landed` false when a key of it was taken by a later animation, which it then never lands (#951).
|
|
2159
2161
|
*/
|
|
2160
2162
|
readonly settled: (landed: boolean) => void
|
|
@@ -2162,7 +2164,7 @@ export interface ImperativeHooks {
|
|
|
2162
2164
|
readonly failed: (cause: Cause.Cause<unknown>) => void
|
|
2163
2165
|
}
|
|
2164
2166
|
|
|
2165
|
-
/** An **Imperative animation** on one
|
|
2167
|
+
/** An **Imperative animation** on one Subject (#433): its legs, built at the call, run through its Playhead. */
|
|
2166
2168
|
export interface ImperativeTrack {
|
|
2167
2169
|
/**
|
|
2168
2170
|
* Run every leg from the Playhead's time: those running end first, so a seek starts them again there,
|
|
@@ -2178,7 +2180,7 @@ export interface ImperativeTrack {
|
|
|
2178
2180
|
}
|
|
2179
2181
|
|
|
2180
2182
|
/**
|
|
2181
|
-
* What
|
|
2183
|
+
* What a Subject's spine hands over (#746, ADR-0067 *Amendment (#746)*): its state and its leg
|
|
2182
2184
|
* machinery, read live, for the two that work on it from outside, `imperative.ts`, which builds an
|
|
2183
2185
|
* **Imperative animation**'s track, and `member-hold.ts`, a Batch member's hold. An app with neither
|
|
2184
2186
|
* ships neither's code. Made at the first call, once a spine.
|
|
@@ -2186,7 +2188,7 @@ export interface ImperativeTrack {
|
|
|
2186
2188
|
export interface SpineHost {
|
|
2187
2189
|
/** The resolution of the last Retarget, whose targets a taken key is noted with. */
|
|
2188
2190
|
readonly lastResolution: () => Resolution | undefined
|
|
2189
|
-
/** The
|
|
2191
|
+
/** The Subject's values, velocities and owners. */
|
|
2190
2192
|
readonly snapshot: Snapshot
|
|
2191
2193
|
/** Each key's running leg. */
|
|
2192
2194
|
readonly owners: Owners
|
|
@@ -2202,7 +2204,7 @@ export interface SpineHost {
|
|
|
2202
2204
|
readonly giveUp: (key: string, running: Running) => void
|
|
2203
2205
|
/** Its `initial` values: a key without one is owned when it's first drawn. */
|
|
2204
2206
|
readonly initialValues: Values.Values
|
|
2205
|
-
/** Own `key` on the
|
|
2207
|
+
/** Own `key` on the Subject (its style's value gives way). */
|
|
2206
2208
|
readonly ownValue: (key: string) => void
|
|
2207
2209
|
/** Start `key` where it's drawn, noting what it starts from in `started`. */
|
|
2208
2210
|
readonly startKey: (key: string, like: number | string, started: Record<string, string>) => void
|
|
@@ -2212,7 +2214,7 @@ export interface SpineHost {
|
|
|
2212
2214
|
readonly reducedMotion: () => boolean
|
|
2213
2215
|
/** Whether its animations are skipped now (#468). */
|
|
2214
2216
|
readonly skipAnimations: () => boolean
|
|
2215
|
-
readonly
|
|
2217
|
+
readonly subject: Subject.Subject
|
|
2216
2218
|
readonly positionalKeys: ReducedMotion.PositionalKeys["Service"]
|
|
2217
2219
|
readonly defaultTransition: DefaultTransition.DefaultTransition["Service"]
|
|
2218
2220
|
/** The Environment's unit scale, its legs' rest thresholds' for `x`, `y` and `z` (ADR-0069 decision 8). */
|
|
@@ -2240,20 +2242,20 @@ export interface SpineHost {
|
|
|
2240
2242
|
readonly recordFrame: (value: Values.Values) => void
|
|
2241
2243
|
readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
|
|
2242
2244
|
/** Its Variable values' Key rule (#55): a blend's are built with it. */
|
|
2243
|
-
readonly
|
|
2245
|
+
readonly subjectRules: ReadonlyArray<InterpolatorRegistry.KeyRule>
|
|
2244
2246
|
/** The Environment's Measured pairs (#430, #672). */
|
|
2245
2247
|
readonly measuredPairs: MeasuredPairs.Shape
|
|
2246
2248
|
/** The Environment's Variable values (#55, #672). */
|
|
2247
2249
|
readonly variableValues: VariableValues.Shape
|
|
2248
2250
|
}
|
|
2249
2251
|
|
|
2250
|
-
/** A mounted
|
|
2251
|
-
export interface
|
|
2252
|
+
/** A mounted Subject's spine. */
|
|
2253
|
+
export interface SubjectSpine {
|
|
2252
2254
|
/** A Retarget toward `resolution`: called by the binding on each change of its target, untracked. */
|
|
2253
2255
|
readonly retarget: (resolution: Resolution) => void
|
|
2254
|
-
/** Follow the
|
|
2256
|
+
/** Follow the Subject's Live values in `style` (#130), from its first routed key on. */
|
|
2255
2257
|
readonly follow: (now: FollowNow) => void
|
|
2256
|
-
/** The
|
|
2258
|
+
/** The Subject's teardown: following stops, and the legs end. */
|
|
2257
2259
|
readonly dispose: () => void
|
|
2258
2260
|
/**
|
|
2259
2261
|
* Start where a leaver is drawn (#286, ADR-0048), before the first Retarget: each key's value and
|
|
@@ -2262,7 +2264,7 @@ export interface ElementSpine {
|
|
|
2262
2264
|
*/
|
|
2263
2265
|
readonly seed: (from: PresenceRecord.PresenceSeed) => void
|
|
2264
2266
|
/**
|
|
2265
|
-
* 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
|
|
2266
2268
|
* `imperative.ts` builds over it, and to a Batch member's hold (#665). Made at the first call, once.
|
|
2267
2269
|
*/
|
|
2268
2270
|
readonly host: () => SpineHost
|
|
@@ -2270,15 +2272,6 @@ export interface ElementSpine {
|
|
|
2270
2272
|
readonly stop: () => void
|
|
2271
2273
|
}
|
|
2272
2274
|
|
|
2273
|
-
/**
|
|
2274
|
-
* A mounted element's spine: its Retarget, the returns to its Base values, the follower of its
|
|
2275
|
-
* Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
|
|
2276
|
-
* its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
|
|
2277
|
-
* ElementSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
|
|
2278
|
-
* run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
|
|
2279
|
-
* *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
|
|
2280
|
-
* fiber Scope interrupts what's left when the provider ends.
|
|
2281
|
-
*/
|
|
2282
2275
|
/** Each runtime's unit scale, read once: a mount reads a WeakMap, not a run of its own. */
|
|
2283
2276
|
// Module state (#460, Q7): held weakly by the runtime, so it goes with it.
|
|
2284
2277
|
const UNIT_SCALES = new WeakMap<object, UnitScale.Rule>()
|
|
@@ -2292,8 +2285,17 @@ export const unitScaleOf = (runtime: WardicServices.Runner<WardicServices.Wardic
|
|
|
2292
2285
|
return read
|
|
2293
2286
|
}
|
|
2294
2287
|
|
|
2295
|
-
|
|
2296
|
-
|
|
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
|
|
2297
2299
|
// The Environment's unit scale (ADR-0069 decision 8, #883): read from the runtime the spine already holds,
|
|
2298
2300
|
// so no binding passes it; 1, Motion's own, unless the Environment's Layers give another.
|
|
2299
2301
|
const unitScale = unitScaleOf(runtime)
|
|
@@ -2302,9 +2304,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2302
2304
|
let handoff = options.handoff
|
|
2303
2305
|
// Its mount tells nothing when it starts at its `animate` (#448): on until its first Retarget.
|
|
2304
2306
|
let quiet = start.quiet
|
|
2305
|
-
// 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,
|
|
2306
2308
|
// added to each leg it starts, so a `var()` end blends what it resolves to here.
|
|
2307
|
-
const
|
|
2309
|
+
const subjectRules = [variableValues.values(subject)]
|
|
2308
2310
|
const recordFrame = recordFrameOf(presence)
|
|
2309
2311
|
// Whether its animations are skipped (#468): never, with nothing given.
|
|
2310
2312
|
const skipAnimations = UndefinedOr.match(options.skipAnimations, { onUndefined: () => constFalse, onDefined: identity })
|
|
@@ -2327,7 +2329,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2327
2329
|
featuresSeen = services
|
|
2328
2330
|
const timelines = Context.getOrUndefined(services as Context.Context<Timelines.Timelines>, Timelines.Timelines)
|
|
2329
2331
|
if (Predicate.isUndefined(timelines)) return undefined
|
|
2330
|
-
timelineKeys = timelines.keysOf({ runtime, gate, id,
|
|
2332
|
+
timelineKeys = timelines.keysOf({ runtime, gate, id, subject, live: routes })
|
|
2331
2333
|
return timelineKeys
|
|
2332
2334
|
}
|
|
2333
2335
|
|
|
@@ -2335,9 +2337,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2335
2337
|
// ones returning to their Base value until that return settles (ADR-0022). Both are
|
|
2336
2338
|
// the spine's: a Retarget mid-return carries them again, so a return is never
|
|
2337
2339
|
// frozen half-way, and a key that settled has left them, so a Retarget of the same
|
|
2338
|
-
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag
|
|
2340
|
+
// target (a `when` gate reopening, ADR-0007) leaves it be. On a drag Subject, the keys
|
|
2339
2341
|
// the drag moves leave the return while it runs, so they stay where it dropped them (C9)
|
|
2340
|
-
// until an entry sets them again; a projected
|
|
2342
|
+
// until an entry sets them again; a projected Subject's drag moves none, its projection
|
|
2341
2343
|
// target does (ADR-0016), and its own translate returns as any key does (#363).
|
|
2342
2344
|
const driven = new Map<string, number | string>()
|
|
2343
2345
|
let returning = new Map<string, BaseValue.BaseSource>()
|
|
@@ -2349,7 +2351,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2349
2351
|
}
|
|
2350
2352
|
|
|
2351
2353
|
// A Retarget's returns have settled (ADR-0022, D4). A key back at its `style` value is
|
|
2352
|
-
// handed back to the
|
|
2354
|
+
// handed back to the Subject's style, so a later style change shows at rest and the
|
|
2353
2355
|
// next gesture starts from it; any other key rests at its Base value where the gate drew
|
|
2354
2356
|
// it, and leaves the target. A key a later Retarget took over is left alone. A routed key (#130) stays
|
|
2355
2357
|
// in the gate, handed to the follower, which writes its value from now on.
|
|
@@ -2366,7 +2368,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2366
2368
|
Arr.forEach(Arr.filter(toStyle, routedNow), (key) => handBack(key))
|
|
2367
2369
|
const handedBack = Arr.filter(toStyle, Predicate.not(routedNow))
|
|
2368
2370
|
if (Arr.isReadonlyArrayEmpty(handedBack)) return
|
|
2369
|
-
// 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
|
|
2370
2372
|
// (ADR-0034). A key gone from the user's style by now is cleared, not restored stale.
|
|
2371
2373
|
const restore = UndefinedOr.map(styleNow, (now) => {
|
|
2372
2374
|
const style = now()
|
|
@@ -2392,7 +2394,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2392
2394
|
// The keys an Imperative animation took (#433), each with the target the Override stack had for it
|
|
2393
2395
|
// then: a Retarget leaves each where the animation leaves it while its target is still that one, and
|
|
2394
2396
|
// takes it back once it isn't, as a newer animation of Motion's value takes it (latest-wins).
|
|
2395
|
-
// Every
|
|
2397
|
+
// Every Subject reads it, nearly none sets it (#460): the shared empty one until the first key taken.
|
|
2396
2398
|
let taken: Map<string, number | string | undefined> = NONE_TAKEN
|
|
2397
2399
|
// The legs that gave up a key in this Retarget: what each still draws is worked out at its end.
|
|
2398
2400
|
const losing: Array<Running> = []
|
|
@@ -2429,7 +2431,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2429
2431
|
})
|
|
2430
2432
|
}
|
|
2431
2433
|
|
|
2432
|
-
// The
|
|
2434
|
+
// The Subject's waiting Transition ends (#508), made at its first: most Subjects never have one.
|
|
2433
2435
|
let waiting: WaitingEnds | undefined
|
|
2434
2436
|
|
|
2435
2437
|
// A leg with no key left ends. Its fiber ends inline (ADR-0027, *Amendment (#200)*); one its token
|
|
@@ -2504,7 +2506,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2504
2506
|
}
|
|
2505
2507
|
|
|
2506
2508
|
// A Path's turn goes back to 0 once no leg draws it (#460, ADR-0065 decision 3): after a Retarget
|
|
2507
|
-
// whose legs don't turn, a stop, a cancel. Most
|
|
2509
|
+
// whose legs don't turn, a stop, a cancel. Most Subjects never turn: a guard.
|
|
2508
2510
|
const turnBack = (): void => {
|
|
2509
2511
|
const turn = snapshot.values[PATH_ROTATION]
|
|
2510
2512
|
if (Bool.or(Predicate.isUndefined(turn), turn === 0)) return
|
|
@@ -2561,7 +2563,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2561
2563
|
|
|
2562
2564
|
/**
|
|
2563
2565
|
* A leg's run into its sink: one dispatcher, each sink built for the leg that needs it, a
|
|
2564
|
-
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the
|
|
2566
|
+
* Retarget's and an Imperative animation's (#433). A blend's machine is built under the Subject's
|
|
2565
2567
|
* Key rules when its change holds a Variable value (`variables`, #542).
|
|
2566
2568
|
*/
|
|
2567
2569
|
const legProgram = (leg: RetargetLegs.Leg, running: Running, variables: boolean): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
@@ -2591,7 +2593,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2591
2593
|
// rather than replacing it, so the drag's direct-set x/y survive alongside the
|
|
2592
2594
|
// spring's keys (drag owns x/y, spring owns the rest) and the post-drag
|
|
2593
2595
|
// handoff continues from the rested position. Only the keys it still draws (#325).
|
|
2594
|
-
// In place, as the Follow sink writes (#659): a spread made two records per
|
|
2596
|
+
// In place, as the Follow sink writes (#659): a spread made two records per Subject per
|
|
2595
2597
|
// frame. The Snapshot's records are always its own (`snapshotOf`, `emptySnapshotOf`), and
|
|
2596
2598
|
// whatever keeps one copies it or reads it at once.
|
|
2597
2599
|
const value = running.values(frame.value)
|
|
@@ -2614,7 +2616,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2614
2616
|
)
|
|
2615
2617
|
}
|
|
2616
2618
|
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
|
|
2617
|
-
// (#659; #895: a spread made a record per
|
|
2619
|
+
// (#659; #895: a spread made a record per Subject per frame). A blend's last two are kept for its keys'
|
|
2618
2620
|
// velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
|
|
2619
2621
|
const sink = (frame: Frame.Frame<Values.Values>, dt: number): undefined => {
|
|
2620
2622
|
const value = running.values(frame.value)
|
|
@@ -2635,7 +2637,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2635
2637
|
}
|
|
2636
2638
|
// Per leg (#460): a statement, Effect's calls data-first.
|
|
2637
2639
|
let built = Effect.suspend(leg.machine)
|
|
2638
|
-
if (variables) built = InterpolatorRegistry.withKeyRules(built,
|
|
2640
|
+
if (variables) built = InterpolatorRegistry.withKeyRules(built, subjectRules)
|
|
2639
2641
|
return Effect.flatMap(built, (machine) => Machine.run(machine, sink, running))
|
|
2640
2642
|
}
|
|
2641
2643
|
|
|
@@ -2646,7 +2648,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2646
2648
|
// Per leg (#460): statements.
|
|
2647
2649
|
if (Exit.isSuccess(exit)) {
|
|
2648
2650
|
// A Superseded leg (#200) counts toward nothing, nor tells a name: the next Retarget's legs
|
|
2649
|
-
// land. Nothing made for it: a Retarget ends its
|
|
2651
|
+
// land. Nothing made for it: a Retarget ends its Subject's legs inline.
|
|
2650
2652
|
const end = exit.value
|
|
2651
2653
|
if (Supersede.isSuperseded(end)) return Effect.void
|
|
2652
2654
|
return Effect.sync(() => {
|
|
@@ -2668,7 +2670,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2668
2670
|
}
|
|
2669
2671
|
|
|
2670
2672
|
// A gated Retarget (ADR-0007 `when`, #325): a running key it resolves to its leg's target runs on,
|
|
2671
|
-
// the
|
|
2673
|
+
// the Subject reported unsettled meanwhile, when an earlier change started that leg; every other
|
|
2672
2674
|
// running key freezes where it is. The change the gate holds may have started legs just before
|
|
2673
2675
|
// it shut (a child Retargets before its provider's effect resets its `beforeChildren` wait; an
|
|
2674
2676
|
// `afterChildren` provider starts before its children report): those freeze too, as before.
|
|
@@ -2749,7 +2751,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2749
2751
|
keepTheRest,
|
|
2750
2752
|
reducedMotion: options.reducedMotion,
|
|
2751
2753
|
skipAnimations,
|
|
2752
|
-
|
|
2754
|
+
subject,
|
|
2753
2755
|
positionalKeys,
|
|
2754
2756
|
defaultTransition,
|
|
2755
2757
|
unitScale,
|
|
@@ -2765,7 +2767,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2765
2767
|
id,
|
|
2766
2768
|
recordFrame,
|
|
2767
2769
|
runtime,
|
|
2768
|
-
|
|
2770
|
+
subjectRules,
|
|
2769
2771
|
measuredPairs,
|
|
2770
2772
|
variableValues,
|
|
2771
2773
|
}
|
|
@@ -2773,37 +2775,37 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2773
2775
|
return handedOver
|
|
2774
2776
|
}
|
|
2775
2777
|
|
|
2776
|
-
// --- A Batch member's
|
|
2778
|
+
// --- A Batch member's Subject (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
|
|
2777
2779
|
|
|
2778
|
-
// Its hold on what it takes from its Batch: made as its
|
|
2779
|
-
// 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.
|
|
2780
2782
|
let memberHold: MemberHold | undefined
|
|
2781
2783
|
const holdNow = (): MemberHold | undefined => {
|
|
2782
2784
|
if (Predicate.isNotUndefined(memberHold)) return memberHold
|
|
2783
2785
|
// An app with no Batch has no way to make one, nor any member.
|
|
2784
2786
|
const holds = memberHoldsNow()
|
|
2785
2787
|
if (Predicate.isUndefined(holds)) return undefined
|
|
2786
|
-
if (!holds.isMember(
|
|
2788
|
+
if (!holds.isMember(subject)) return undefined
|
|
2787
2789
|
memberHold = holds.make(host())
|
|
2788
2790
|
return memberHold
|
|
2789
2791
|
}
|
|
2790
|
-
// A draggable
|
|
2792
|
+
// A draggable Subject's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
|
|
2791
2793
|
if (Predicate.isNotUndefined(options.dragAxis)) {
|
|
2792
|
-
DRAG_HOOKS.set(
|
|
2794
|
+
DRAG_HOOKS.set(subject, (on) => {
|
|
2793
2795
|
const member = holdNow()
|
|
2794
2796
|
if (Predicate.isNotUndefined(member)) member.drag(on)
|
|
2795
2797
|
})
|
|
2796
2798
|
}
|
|
2797
2799
|
|
|
2798
2800
|
const retarget = (given: Resolution): void => {
|
|
2799
|
-
// 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.
|
|
2800
2802
|
if (given.change !== joined) joinChange(given.change)
|
|
2801
2803
|
// A key an entry sets isn't its Live value's from this Retarget on, held or not: its Timeline value
|
|
2802
2804
|
// stops (#240), and the gate draws the key in the flush that writes the entry's first value.
|
|
2803
2805
|
if (Predicate.isNotUndefined(timelineKeys)) takeEach(timelineKeys, given.resolved)
|
|
2804
2806
|
|
|
2805
2807
|
// `when` start-gate (ADR-0007): when canStart() is false, the keys whose target changed freeze
|
|
2806
|
-
// where they are (#325: the rest run on), and the
|
|
2808
|
+
// where they are (#325: the rest run on), and the Subject waits; the binding retargets once
|
|
2807
2809
|
// the gate flips true.
|
|
2808
2810
|
if (Predicate.isNotUndefined(canStart) && !canStart()) {
|
|
2809
2811
|
hold(given)
|
|
@@ -2857,7 +2859,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2857
2859
|
if (Predicate.isNotUndefined(keys)) Arr.forEach(dragMoves(), (key) => keys.taken(key))
|
|
2858
2860
|
}
|
|
2859
2861
|
returning = new Map()
|
|
2860
|
-
// 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
|
|
2861
2863
|
// per Retarget (#69's PR 4). Deleting the entry being visited is safe in a Map's iteration.
|
|
2862
2864
|
Iter.forEach(driven, ([key, like]) => {
|
|
2863
2865
|
// A translate key the strip below holds back returns once the drag lets go.
|
|
@@ -2882,12 +2884,12 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2882
2884
|
if (taken.size > 0) Iter.forEach(taken, ([key]) => {
|
|
2883
2885
|
delete t[key]
|
|
2884
2886
|
})
|
|
2885
|
-
// 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
|
|
2886
2888
|
// key it'd leave where the Batch draws it stays the Batch's. A drag takes `x` and `y`.
|
|
2887
2889
|
const member = holdNow()
|
|
2888
2890
|
if (Predicate.isNotUndefined(member)) member.retarget(t, held)
|
|
2889
2891
|
// The keys this Retarget returns; once it lands, a key back at its `style` value is
|
|
2890
|
-
// handed back to the
|
|
2892
|
+
// handed back to the Subject's style (D4) and the rest rest where the gate drew them.
|
|
2891
2893
|
const returns = [...returning]
|
|
2892
2894
|
// The transition, read at Retarget time so a change applies to the next Retarget. A child
|
|
2893
2895
|
// with no local transition inherits the parent context's (ADR-0007).
|
|
@@ -2908,7 +2910,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2908
2910
|
if (--legs !== 0) return
|
|
2909
2911
|
settleReturns(returns)
|
|
2910
2912
|
// The Retarget settled with its last leg (#257): told once the gate has flushed its last frame,
|
|
2911
|
-
// so the
|
|
2913
|
+
// so the Subject shows where it landed. Its Controls change hears it then too (#433).
|
|
2912
2914
|
if (Predicate.isNotUndefined(animation)) gate.afterFlush(() => animation.settled(resolution, previous, c))
|
|
2913
2915
|
leaveAfterFlush()
|
|
2914
2916
|
}
|
|
@@ -2932,7 +2934,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2932
2934
|
if (startedTold) return tellFailed(error)
|
|
2933
2935
|
failedEarly = { error }
|
|
2934
2936
|
}
|
|
2935
|
-
// The
|
|
2937
|
+
// The Subject settles with its last leg (ADR-0024, D5): a string leg can outlast the
|
|
2936
2938
|
// numeric one, so each leg's frames report, and only the last leg's settle reports done.
|
|
2937
2939
|
let reporting = 0
|
|
2938
2940
|
let settled = 0
|
|
@@ -2945,9 +2947,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2945
2947
|
|
|
2946
2948
|
// The Retarget's transitions, read before its keys: a key already there asks its own for a
|
|
2947
2949
|
// velocity (#448).
|
|
2948
|
-
const
|
|
2950
|
+
const wardTransition = VariantTree.ownOrInherited(c.transition, parent)
|
|
2949
2951
|
// The base target's own transition (#277): the keys its entry drives animate on it.
|
|
2950
|
-
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition,
|
|
2952
|
+
const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, wardTransition)
|
|
2951
2953
|
// Fold the per-child stagger delay (ADR-0007) into the effective
|
|
2952
2954
|
// transition.delay = base.delay + computedDelay. extraDelay() is read
|
|
2953
2955
|
// at Retarget time so a re-snapshot before this start is reflected. Each name's keys take that
|
|
@@ -2956,11 +2958,11 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2956
2958
|
const extra = extraOf(extraDelay, layers[0])
|
|
2957
2959
|
const transition = staggeredOf(baseTransition, extra, options.reuse)
|
|
2958
2960
|
// With an entry's own transition (#277, #291), each key animates on its entry's: the base's keys
|
|
2959
|
-
// on the base target's, each active gesture's on its target's, else the
|
|
2961
|
+
// on the base target's, each active gesture's on its target's, else the Subject's, as Motion's
|
|
2960
2962
|
// each animation type runs on its own.
|
|
2961
2963
|
// A list's names (#297) split them too, each name's at its own delay; a list's returns run on the
|
|
2962
|
-
//
|
|
2963
|
-
// Guards, not matches: per Retarget, per
|
|
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:
|
|
2964
2966
|
// the Retarget's other calls keep their inlining (docs/agents/effect-first.md).
|
|
2965
2967
|
const listed = Arr.isArray(resolution.variant)
|
|
2966
2968
|
// A list's names each wait for their own `when` (#297's PR 2): the entries whose gate is shut now.
|
|
@@ -2977,7 +2979,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
2977
2979
|
// target (no motion).
|
|
2978
2980
|
//
|
|
2979
2981
|
// Every key's Own value is read first, at its first need, before anything writes it, so a return
|
|
2980
|
-
// later finds the
|
|
2982
|
+
// later finds the Subject's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
|
|
2981
2983
|
// a lookup. A transform key reads nothing.
|
|
2982
2984
|
let stays: Set<string> | undefined
|
|
2983
2985
|
let carried: Array<Running> | undefined
|
|
@@ -3035,7 +3037,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3035
3037
|
// Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
|
|
3036
3038
|
// mount's never asks (#475): Motion animates nothing at a first render that starts at its
|
|
3037
3039
|
// `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
|
|
3038
|
-
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition,
|
|
3040
|
+
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, wardTransition), key))) {
|
|
3039
3041
|
if (Predicate.isUndefined(stays)) stays = new Set()
|
|
3040
3042
|
stays.add(key)
|
|
3041
3043
|
if (Predicate.isUndefined(there)) there = {}
|
|
@@ -3056,7 +3058,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3056
3058
|
owners.forEach(giveUpUnresolved)
|
|
3057
3059
|
keepTheRest()
|
|
3058
3060
|
// A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
|
|
3059
|
-
// the resolved target doesn't name joins the keys already there, written with them as the
|
|
3061
|
+
// the resolved target doesn't name joins the keys already there, written with them as the Subject's first
|
|
3060
3062
|
// commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
|
|
3061
3063
|
// any. A Batch member's are its Batch's, which draws its groups.
|
|
3062
3064
|
if (Predicate.isUndefined(lastResolution)) {
|
|
@@ -3130,7 +3132,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3130
3132
|
// The legs (#48, ADR-0044 decision 8): one pure builder, which a server render's Appear
|
|
3131
3133
|
// animation samples too, so the two can't drift. Built here; each leg's machine is built
|
|
3132
3134
|
// in its own fiber, so a transition core rejects (#66, ADR-0025 *Amendment (#66)*) fails
|
|
3133
|
-
// that leg alone, reported as any leg's failure is, while the
|
|
3135
|
+
// that leg alone, reported as any leg's failure is, while the Subject's other legs run on.
|
|
3134
3136
|
// The returns to a moving Live value (#130, ADR-0043 decision 6): a number's follows it,
|
|
3135
3137
|
// in a leg of its own, and lands on it; the rest return to where it is now. Looked for
|
|
3136
3138
|
// only when this Retarget returns a key.
|
|
@@ -3145,7 +3147,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3145
3147
|
// animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
|
|
3146
3148
|
let measured: RetargetLegs.MeasuredPairs | undefined
|
|
3147
3149
|
if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
|
|
3148
|
-
measured = measuredOf(measuredPairs,
|
|
3150
|
+
measured = measuredOf(measuredPairs, subject, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id)
|
|
3149
3151
|
}
|
|
3150
3152
|
let told: ToldNames | undefined
|
|
3151
3153
|
if (!silent) told = namesToldOf(animation, resolution, lastResolution)
|
|
@@ -3159,7 +3161,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3159
3161
|
retargetLegs = RetargetLegs.legsOf(from, fresh, transition, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale)
|
|
3160
3162
|
}
|
|
3161
3163
|
if (Predicate.isNotUndefined(groups)) {
|
|
3162
|
-
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)
|
|
3163
3165
|
retargetLegs = split.legs
|
|
3164
3166
|
legGroups = split.tags
|
|
3165
3167
|
}
|
|
@@ -3211,9 +3213,9 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3211
3213
|
}
|
|
3212
3214
|
// Its Live routes hear the legs it starts (#443, PR4-Q1).
|
|
3213
3215
|
tellStarted(live, retargetLegs)
|
|
3214
|
-
// The
|
|
3216
|
+
// The Subject's Key rules only for a change a Variable value is in (#542).
|
|
3215
3217
|
const variables = holdsVariable(variableValues, from, fresh, manyStops)
|
|
3216
|
-
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per
|
|
3218
|
+
// Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per Subject). Each
|
|
3217
3219
|
// leg draws the keys it animates (#325) until a later Retarget takes them.
|
|
3218
3220
|
Arr.forEach(retargetLegs, (leg: RetargetLegs.Leg, i): void => {
|
|
3219
3221
|
if (Predicate.isNotUndefined(legGates)) gateNow = legGates[i]
|
|
@@ -3271,7 +3273,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3271
3273
|
// A turn none of its legs draws now goes back (#460).
|
|
3272
3274
|
turnBack()
|
|
3273
3275
|
// The keys already there (#448), written with each key the Retarget moves at where it starts, as
|
|
3274
|
-
// its leg's first frame writes it: the
|
|
3276
|
+
// its leg's first frame writes it: the Subject's first commit, which takes its Starting style off,
|
|
3275
3277
|
// holds every key, whatever frame the legs first draw in (a gated name's draws later).
|
|
3276
3278
|
if (Predicate.isNotUndefined(there)) {
|
|
3277
3279
|
const written = { ...from, ...there }
|
|
@@ -3279,7 +3281,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3279
3281
|
recordFrame(written)
|
|
3280
3282
|
}
|
|
3281
3283
|
// The Retarget started, its legs on their way (#257); with none, its own or carried, it landed
|
|
3282
|
-
// at once (#325): its returns settle, and the
|
|
3284
|
+
// at once (#325): its returns settle, and the Subject reports settled at the gate's next flush,
|
|
3283
3285
|
// after the effects that start its orchestration's wait (ADR-0007).
|
|
3284
3286
|
previous = lastResolution
|
|
3285
3287
|
lastResolution = resolution
|
|
@@ -3309,14 +3311,14 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3309
3311
|
|
|
3310
3312
|
// --- Live values in `style` (#130, ADR-0043) ------------------------------
|
|
3311
3313
|
// A routed key (a Live value, or a transform key) is its `style` link, live: while no entry of
|
|
3312
|
-
// the Override stack sets it, no return is running to it and no drag moves it, the
|
|
3314
|
+
// the Override stack sets it, no return is running to it and no drag moves it, the Subject
|
|
3313
3315
|
// follows it, written through the gate on every change. A return hands it back here when it
|
|
3314
3316
|
// settles (`settleReturns`). The Starting style showed each one's value at render; from mount
|
|
3315
3317
|
// the gate holds them.
|
|
3316
3318
|
const follow = (now: FollowNow): void => {
|
|
3317
3319
|
if (Predicate.isUndefined(live)) return
|
|
3318
3320
|
const routes = live
|
|
3319
|
-
// 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.
|
|
3320
3322
|
routes.whenRouted(() => {
|
|
3321
3323
|
// Read at each ask: `projected` is a getter while the track waits for `drag` (#551, #582).
|
|
3322
3324
|
const dragHolds = (): boolean => Bool.and(Bool.not(options.projected), Predicate.isNotUndefined(options.dragAxis))
|
|
@@ -3339,7 +3341,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3339
3341
|
gate.write(id, values)
|
|
3340
3342
|
recordFrame(values)
|
|
3341
3343
|
}
|
|
3342
|
-
// The
|
|
3344
|
+
// The Subject shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
|
|
3343
3345
|
const shown = (key: string): void => {
|
|
3344
3346
|
const keys = timelineKeysNow(routes)
|
|
3345
3347
|
if (Predicate.isNotUndefined(keys)) keys.shown(key)
|
|
@@ -3372,7 +3374,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3372
3374
|
delete snapshot.values[key]
|
|
3373
3375
|
delete snapshot.velocities[key]
|
|
3374
3376
|
if (Predicate.isNotUndefined(presence)) delete presence.snapshot.current[key]
|
|
3375
|
-
// Gone from `style`: the
|
|
3377
|
+
// Gone from `style`: the Subject's own value comes back, or none, its Environment's default now.
|
|
3376
3378
|
const restore = Option.match(ownValues.styleValueOf(UndefinedOr.match(styleNow, { onUndefined: constUndefined, onDefined: (style) => style() }), key), {
|
|
3377
3379
|
onNone: () => "",
|
|
3378
3380
|
onSome: String,
|
|
@@ -3402,8 +3404,8 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3402
3404
|
}
|
|
3403
3405
|
|
|
3404
3406
|
// A child back under its key (#286): its values and velocities from where the leaver is drawn, a
|
|
3405
|
-
// projected
|
|
3406
|
-
//
|
|
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
|
|
3407
3409
|
// first commit's Starting-style switch would flush Solid 2 inside an effect.
|
|
3408
3410
|
const seed = (from: PresenceRecord.PresenceSeed): void => {
|
|
3409
3411
|
const values = from.values
|
|
@@ -3440,7 +3442,7 @@ export const makeElementSpine = (options: ElementSpineOptions): ElementSpine =>
|
|
|
3440
3442
|
* one at mount; `sink` as it is otherwise. `config` reads it untracked.
|
|
3441
3443
|
*/
|
|
3442
3444
|
export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["onUpdate"], config: () => Config.SpineConfig): FlushGate.Sink => {
|
|
3443
|
-
// Per
|
|
3445
|
+
// Per Subject at mount: most have none, and pay a check.
|
|
3444
3446
|
if (Predicate.isUndefined(atMount)) return sink
|
|
3445
3447
|
return {
|
|
3446
3448
|
...sink,
|
|
@@ -3453,8 +3455,8 @@ export const withOnUpdate = (sink: FlushGate.Sink, atMount: Config.SpineConfig["
|
|
|
3453
3455
|
|
|
3454
3456
|
/**
|
|
3455
3457
|
* A Retarget's note of the keys it started from their Base value, or returned to it (ADR-0022): run at
|
|
3456
|
-
* the head of its first leg, cold path (no fiber of its own: forking one per
|
|
3457
|
-
* at a 1000-
|
|
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).
|
|
3458
3460
|
*/
|
|
3459
3461
|
export const baseLog = (id: string, started: Record<string, string>, returns: ReadonlyArray<readonly [string, BaseValue.BaseSource]>): Effect.Effect<void> =>
|
|
3460
3462
|
Effect.logDebug("wardic.base: a key with no value started from, or returned to, its Base value (ADR-0022)").pipe(
|
|
@@ -3475,10 +3477,10 @@ const liveTargetOf = (ownValues: OwnValues.Shape, routes: LiveRoutes, key: strin
|
|
|
3475
3477
|
}
|
|
3476
3478
|
}
|
|
3477
3479
|
|
|
3478
|
-
/** Whether a value is one
|
|
3480
|
+
/** Whether a value is one a Subject can take: a number or a string. */
|
|
3479
3481
|
const isValue = (value: unknown): value is number | string => Bool.or(Predicate.isNumber(value), Predicate.isString(value))
|
|
3480
3482
|
|
|
3481
|
-
/** 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. */
|
|
3482
3484
|
export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicServices>): (() => AtomRegistry.AtomRegistry) => {
|
|
3483
3485
|
let registry: AtomRegistry.AtomRegistry | undefined
|
|
3484
3486
|
return () => {
|
|
@@ -3487,7 +3489,7 @@ export const registryOf = (runtime: WardicServices.Runner<WardicServices.WardicS
|
|
|
3487
3489
|
}
|
|
3488
3490
|
}
|
|
3489
3491
|
|
|
3490
|
-
/** Whether a config makes its
|
|
3492
|
+
/** Whether a config makes its Subject a layout node: `layout` (or a mode), or a `layoutId`. */
|
|
3491
3493
|
export const isLayoutNode = (c: Config.SpineConfig): boolean =>
|
|
3492
3494
|
Bool.or(Bool.and(Predicate.isNotUndefined(c.layout), c.layout !== false), Predicate.isNotUndefined(c.layoutId))
|
|
3493
3495
|
|