@wardic/core 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/dist/Arc.d.ts +2 -2
  2. package/dist/Arc.js +1 -1
  3. package/dist/BaseValue.d.ts +11 -10
  4. package/dist/BaseValue.d.ts.map +1 -1
  5. package/dist/BaseValue.js +12 -15
  6. package/dist/BaseValue.js.map +1 -1
  7. package/dist/Batch.d.ts +12 -6
  8. package/dist/Batch.d.ts.map +1 -1
  9. package/dist/Batch.js +374 -30
  10. package/dist/Batch.js.map +1 -1
  11. package/dist/Clock.d.ts +16 -0
  12. package/dist/Clock.d.ts.map +1 -1
  13. package/dist/Clock.js +22 -8
  14. package/dist/Clock.js.map +1 -1
  15. package/dist/DefaultTransition.d.ts +3 -2
  16. package/dist/DefaultTransition.d.ts.map +1 -1
  17. package/dist/DefaultTransition.js +5 -3
  18. package/dist/DefaultTransition.js.map +1 -1
  19. package/dist/Drag.d.ts +24 -9
  20. package/dist/Drag.d.ts.map +1 -1
  21. package/dist/Drag.js +10 -10
  22. package/dist/Drag.js.map +1 -1
  23. package/dist/DragActivity.js +3 -3
  24. package/dist/DragRecognizer.d.ts +14 -8
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +93 -34
  27. package/dist/DragRecognizer.js.map +1 -1
  28. package/dist/Easing.d.ts +1 -1
  29. package/dist/Easing.js +1 -1
  30. package/dist/Frame.d.ts.map +1 -1
  31. package/dist/Frame.js +5 -3
  32. package/dist/Frame.js.map +1 -1
  33. package/dist/InputFeed.d.ts +11 -8
  34. package/dist/InputFeed.d.ts.map +1 -1
  35. package/dist/InputFeed.js +18 -37
  36. package/dist/InputFeed.js.map +1 -1
  37. package/dist/InputSource.d.ts +3 -3
  38. package/dist/InputSource.js +2 -2
  39. package/dist/Interpolator.d.ts +2 -2
  40. package/dist/Interpolator.js +2 -2
  41. package/dist/InterpolatorRegistry.d.ts +29 -15
  42. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  43. package/dist/InterpolatorRegistry.js +17 -8
  44. package/dist/InterpolatorRegistry.js.map +1 -1
  45. package/dist/LiveValue.d.ts +16 -9
  46. package/dist/LiveValue.d.ts.map +1 -1
  47. package/dist/LiveValue.js +204 -27
  48. package/dist/LiveValue.js.map +1 -1
  49. package/dist/Machine.d.ts +21 -8
  50. package/dist/Machine.d.ts.map +1 -1
  51. package/dist/Machine.js +184 -60
  52. package/dist/Machine.js.map +1 -1
  53. package/dist/Playback.d.ts.map +1 -1
  54. package/dist/Playback.js +16 -9
  55. package/dist/Playback.js.map +1 -1
  56. package/dist/Projection.d.ts +9 -9
  57. package/dist/Projection.js +2 -2
  58. package/dist/Recognizer.d.ts +2 -2
  59. package/dist/Recognizer.d.ts.map +1 -1
  60. package/dist/Recognizer.js +15 -10
  61. package/dist/Recognizer.js.map +1 -1
  62. package/dist/ReducedMotion.d.ts +4 -4
  63. package/dist/ReducedMotion.js +6 -6
  64. package/dist/Renderer.d.ts +5 -5
  65. package/dist/Renderer.js +6 -6
  66. package/dist/Renderer.js.map +1 -1
  67. package/dist/Reorder.d.ts +1 -1
  68. package/dist/Reorder.d.ts.map +1 -1
  69. package/dist/Reorder.js +2 -1
  70. package/dist/Reorder.js.map +1 -1
  71. package/dist/ScrollSource.d.ts +1 -1
  72. package/dist/ScrollSource.d.ts.map +1 -1
  73. package/dist/Sequence.d.ts +1 -1
  74. package/dist/SharedSource.d.ts +3 -3
  75. package/dist/SharedSource.js +5 -5
  76. package/dist/SharedSource.js.map +1 -1
  77. package/dist/Spring.d.ts.map +1 -1
  78. package/dist/Spring.js +2 -1
  79. package/dist/Spring.js.map +1 -1
  80. package/dist/Values.d.ts +2 -2
  81. package/dist/Values.js +1 -1
  82. package/dist/index.d.ts +1 -1
  83. package/dist/index.js +1 -1
  84. package/dist/internal/carried.d.ts +13 -0
  85. package/dist/internal/carried.d.ts.map +1 -0
  86. package/dist/internal/carried.js +23 -0
  87. package/dist/internal/carried.js.map +1 -0
  88. package/dist/internal/firstSteps.d.ts +66 -0
  89. package/dist/internal/firstSteps.d.ts.map +1 -0
  90. package/dist/internal/firstSteps.js +107 -0
  91. package/dist/internal/firstSteps.js.map +1 -0
  92. package/dist/internal/frameLoop.d.ts +11 -3
  93. package/dist/internal/frameLoop.d.ts.map +1 -1
  94. package/dist/internal/frameLoop.js +190 -39
  95. package/dist/internal/frameLoop.js.map +1 -1
  96. package/dist/internal/guarded.d.ts +16 -0
  97. package/dist/internal/guarded.d.ts.map +1 -0
  98. package/dist/internal/guarded.js +68 -0
  99. package/dist/internal/guarded.js.map +1 -0
  100. package/dist/internal/lerpsNumbers.d.ts +11 -0
  101. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  102. package/dist/internal/lerpsNumbers.js +38 -0
  103. package/dist/internal/lerpsNumbers.js.map +1 -0
  104. package/dist/internal/options.d.ts +7 -7
  105. package/dist/internal/options.d.ts.map +1 -1
  106. package/dist/internal/options.js +10 -10
  107. package/dist/internal/options.js.map +1 -1
  108. package/dist/internal/stepper.d.ts +21 -4
  109. package/dist/internal/stepper.d.ts.map +1 -1
  110. package/dist/internal/stepper.js +21 -5
  111. package/dist/internal/stepper.js.map +1 -1
  112. package/dist/internal/tracing.d.ts +1 -1
  113. package/dist/internal/tracing.js +1 -1
  114. package/dist/unstable/AnimationControls.d.ts +45 -39
  115. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  116. package/dist/unstable/AnimationControls.js +59 -35
  117. package/dist/unstable/AnimationControls.js.map +1 -1
  118. package/dist/unstable/AppearHandoff.d.ts +11 -5
  119. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  120. package/dist/unstable/AppearHandoff.js.map +1 -1
  121. package/dist/unstable/BatchCalls.d.ts +2 -2
  122. package/dist/unstable/BatchCalls.js +5 -5
  123. package/dist/unstable/Config.d.ts +21 -17
  124. package/dist/unstable/Config.d.ts.map +1 -1
  125. package/dist/unstable/Config.js.map +1 -1
  126. package/dist/unstable/FirstSteps.d.ts +25 -0
  127. package/dist/unstable/FirstSteps.d.ts.map +1 -0
  128. package/dist/unstable/FirstSteps.js +2 -0
  129. package/dist/unstable/FirstSteps.js.map +1 -0
  130. package/dist/unstable/FlushGate.d.ts +54 -50
  131. package/dist/unstable/FlushGate.d.ts.map +1 -1
  132. package/dist/unstable/FlushGate.js +201 -77
  133. package/dist/unstable/FlushGate.js.map +1 -1
  134. package/dist/unstable/FrameEffects.d.ts +6 -3
  135. package/dist/unstable/FrameEffects.d.ts.map +1 -1
  136. package/dist/unstable/FrameEffects.js +14 -3
  137. package/dist/unstable/FrameEffects.js.map +1 -1
  138. package/dist/unstable/FrameTime.d.ts +1 -1
  139. package/dist/unstable/FrameTime.js +1 -1
  140. package/dist/unstable/Imperative.d.ts +42 -13
  141. package/dist/unstable/Imperative.d.ts.map +1 -1
  142. package/dist/unstable/Imperative.js +279 -88
  143. package/dist/unstable/Imperative.js.map +1 -1
  144. package/dist/unstable/MeasuredPairs.d.ts +6 -2
  145. package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
  146. package/dist/unstable/MeasuredPairs.js.map +1 -1
  147. package/dist/unstable/OwnValues.js +1 -1
  148. package/dist/unstable/PresenceRecord.d.ts +30 -26
  149. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  150. package/dist/unstable/PresenceRecord.js +8 -8
  151. package/dist/unstable/PresenceRecord.js.map +1 -1
  152. package/dist/unstable/Projector.d.ts +34 -0
  153. package/dist/unstable/Projector.d.ts.map +1 -0
  154. package/dist/unstable/Projector.js +9 -0
  155. package/dist/unstable/Projector.js.map +1 -0
  156. package/dist/unstable/Report.d.ts +8 -1
  157. package/dist/unstable/Report.d.ts.map +1 -1
  158. package/dist/unstable/Report.js +18 -2
  159. package/dist/unstable/Report.js.map +1 -1
  160. package/dist/unstable/RetargetLegs.d.ts +7 -1
  161. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  162. package/dist/unstable/RetargetLegs.js +24 -8
  163. package/dist/unstable/RetargetLegs.js.map +1 -1
  164. package/dist/unstable/Spine.d.ts +123 -68
  165. package/dist/unstable/Spine.d.ts.map +1 -1
  166. package/dist/unstable/Spine.js +319 -167
  167. package/dist/unstable/Spine.js.map +1 -1
  168. package/dist/unstable/Stops.d.ts +3 -3
  169. package/dist/unstable/Stops.js +4 -4
  170. package/dist/unstable/Subject.d.ts +2 -2
  171. package/dist/unstable/Subject.js +2 -2
  172. package/dist/unstable/Timelines.d.ts +11 -11
  173. package/dist/unstable/Timelines.d.ts.map +1 -1
  174. package/dist/unstable/Timelines.js +3 -3
  175. package/dist/unstable/VariantTarget.d.ts +32 -10
  176. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  177. package/dist/unstable/VariantTarget.js +73 -20
  178. package/dist/unstable/VariantTarget.js.map +1 -1
  179. package/dist/unstable/VariantTree.d.ts +68 -34
  180. package/dist/unstable/VariantTree.d.ts.map +1 -1
  181. package/dist/unstable/VariantTree.js +83 -36
  182. package/dist/unstable/VariantTree.js.map +1 -1
  183. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  184. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  185. package/dist/unstable/WardicConfigValue.js +4 -4
  186. package/dist/unstable/WardicConfigValue.js.map +1 -1
  187. package/package.json +1 -1
  188. package/src/Arc.ts +3 -3
  189. package/src/BaseValue.ts +18 -21
  190. package/src/Batch.ts +391 -27
  191. package/src/Clock.ts +29 -8
  192. package/src/DefaultTransition.ts +5 -3
  193. package/src/Drag.ts +32 -14
  194. package/src/DragActivity.ts +3 -3
  195. package/src/DragRecognizer.ts +118 -41
  196. package/src/Easing.ts +1 -1
  197. package/src/Frame.ts +5 -3
  198. package/src/InputFeed.ts +39 -42
  199. package/src/InputSource.ts +5 -5
  200. package/src/Interpolator.ts +3 -3
  201. package/src/InterpolatorRegistry.ts +22 -13
  202. package/src/LiveValue.ts +186 -30
  203. package/src/Machine.ts +252 -81
  204. package/src/Playback.ts +15 -9
  205. package/src/Projection.ts +9 -9
  206. package/src/Recognizer.ts +16 -10
  207. package/src/ReducedMotion.ts +6 -6
  208. package/src/Renderer.ts +6 -6
  209. package/src/Reorder.ts +3 -2
  210. package/src/ScrollSource.ts +1 -1
  211. package/src/Sequence.ts +1 -1
  212. package/src/SharedSource.ts +5 -5
  213. package/src/Spring.ts +2 -1
  214. package/src/Values.ts +2 -2
  215. package/src/index.ts +1 -1
  216. package/src/internal/carried.ts +22 -0
  217. package/src/internal/firstSteps.ts +139 -0
  218. package/src/internal/frameLoop.ts +203 -41
  219. package/src/internal/guarded.ts +69 -0
  220. package/src/internal/lerpsNumbers.ts +53 -0
  221. package/src/internal/options.ts +10 -10
  222. package/src/internal/stepper.ts +33 -6
  223. package/src/internal/tracing.ts +1 -1
  224. package/src/unstable/AnimationControls.ts +88 -57
  225. package/src/unstable/AppearHandoff.ts +13 -6
  226. package/src/unstable/BatchCalls.ts +5 -5
  227. package/src/unstable/Config.ts +23 -17
  228. package/src/unstable/FirstSteps.ts +26 -0
  229. package/src/unstable/FlushGate.ts +250 -108
  230. package/src/unstable/FrameEffects.ts +17 -4
  231. package/src/unstable/FrameTime.ts +1 -1
  232. package/src/unstable/Imperative.ts +342 -101
  233. package/src/unstable/MeasuredPairs.ts +7 -1
  234. package/src/unstable/OwnValues.ts +1 -1
  235. package/src/unstable/PresenceRecord.ts +33 -29
  236. package/src/unstable/Projector.ts +45 -0
  237. package/src/unstable/Report.ts +20 -2
  238. package/src/unstable/RetargetLegs.ts +24 -9
  239. package/src/unstable/Spine.ts +399 -202
  240. package/src/unstable/Stops.ts +6 -6
  241. package/src/unstable/Subject.ts +2 -2
  242. package/src/unstable/Timelines.ts +12 -12
  243. package/src/unstable/VariantTarget.ts +102 -23
  244. package/src/unstable/VariantTree.ts +123 -42
  245. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The motion spine's Retarget (ADR-0005), on every binding: what an element does from its mount on
3
- * when its target changes. A binding mounts the element, resolves its Override stack reactively
4
- * ({@link resolutionOf}), and calls {@link ElementSpine.retarget} on each change, read where its
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 elements to run it
18
+ // Unstable: ADR-0071, decision 5. #672: solid's `spine.ts`, moved for every binding's Subjects to run it
19
19
  // from core, Foldkit's among them; with it, the Batch hold's slot (Q14).
20
20
  import * as BaseValue from "../BaseValue.js";
21
21
  import * as Frame from "../Frame.js";
@@ -51,7 +51,7 @@ import * as Timelines from "./Timelines.js";
51
51
  import * as VariantTree from "./VariantTree.js";
52
52
  import * as VariantTarget from "./VariantTarget.js";
53
53
  export { NO_VARIANT_STATE, resolveTarget, transitionOfTarget } from "./VariantTarget.js";
54
- /** No exit: an element outside a presence never resolves one. */
54
+ /** No exit: a Subject outside a presence never resolves one. */
55
55
  export const NO_EXIT_CONFIG = { exit: undefined, variants: undefined, custom: undefined, transition: undefined };
56
56
  /** A record's place in the variant tree (#290), from its config at setup. */
57
57
  export const presenceTreeOf = (c) => ({
@@ -60,20 +60,20 @@ export const presenceTreeOf = (c) => ({
60
60
  twin: Predicate.isNotUndefined(c.layoutId),
61
61
  });
62
62
  /**
63
- * An element's ref that tells its presence it was made (#286, ADR-0048): its `key`, read once, and
64
- * whether it's a twin. With no presence, `set` itself: nothing is made per element.
63
+ * A Subject's ref that tells its presence it was made (#286, ADR-0048): its `key`, read once, and
64
+ * whether it's a twin. With no presence, `set` itself: nothing is made per Subject.
65
65
  */
66
66
  export const madeWith = (presence, set, c) => {
67
67
  if (Predicate.isUndefined(presence))
68
68
  return set;
69
69
  const key = c.key;
70
70
  const twin = Predicate.isNotUndefined(c.layoutId);
71
- return (el) => {
72
- PresenceRecord.presenceMade(presence, el, key, twin);
73
- set(el);
71
+ return (subject) => {
72
+ PresenceRecord.presenceMade(presence, subject, key, twin);
73
+ set(subject);
74
74
  };
75
75
  };
76
- /** An element's {@link ExitConfig} from its config now. */
76
+ /** A Subject's {@link ExitConfig} from its config now. */
77
77
  export const exitConfigOf = (c, parent) => ({
78
78
  exit: c.exit,
79
79
  variants: c.variants,
@@ -81,9 +81,9 @@ export const exitConfigOf = (c, parent) => ({
81
81
  transition: VariantTree.ownOrInherited(c.transition, parent),
82
82
  });
83
83
  /**
84
- * Resolve an element's exit as it leaves (#277): with its `<AnimatePresence custom>` when that's
85
- * given (Motion's: the leaving element's own props can't change any more), else its own `custom`; on
86
- * its own transition, else the element's.
84
+ * Resolve a Subject's exit as it leaves (#277): with its `<AnimatePresence custom>` when that's
85
+ * given (Motion's: the leaving Subject's own props can't change any more), else its own `custom`; on
86
+ * its own transition, else the Subject's.
87
87
  */
88
88
  export const exitTargetOf = (config, presenceCustom, state, inherited) => {
89
89
  const custom = UndefinedOr.match(presenceCustom, { onUndefined: () => config.custom, onDefined: identity });
@@ -94,22 +94,26 @@ export const exitTargetOf = (config, presenceCustom, state, inherited) => {
94
94
  // A list (#297): merged, and each name's own keys on its own transition.
95
95
  const targets = VariantTarget.resolveTargets(entry, config.variants, custom, state);
96
96
  const merged = VariantTarget.mergedOf(targets);
97
+ // One of its names' resolvers threw (#979, Q3): it leaves without the whole exit, as with one name.
98
+ if (Option.isSome(merged.failure))
99
+ return { values: {}, transition: config.transition, name, keyframes: undefined, failure: merged.failure };
97
100
  return {
98
101
  values: merged.values,
99
102
  transition: VariantTarget.transitionOfTarget(merged.transition, config.transition),
100
103
  name,
101
104
  groups: exitGroupsOf(targets, config.transition),
102
105
  keyframes: merged.keyframes,
106
+ failure: merged.failure,
103
107
  };
104
108
  }
105
109
  const target = VariantTarget.resolveTarget(entry, config.variants, custom, state);
106
- return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes };
110
+ return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure };
107
111
  };
108
- /** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `element`. */
109
- const exitGroupsOf = (targets, element) => Arr.map(targets, (target, i) => ({
112
+ /** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `wardTransition`. */
113
+ const exitGroupsOf = (targets, wardTransition) => Arr.map(targets, (target, i) => ({
110
114
  name: target.name,
111
115
  values: Rec.filter(target.values, (_, key) => Bool.not(Arr.some(Arr.drop(targets, i + 1), (later) => Object.hasOwn(later.values, key)))),
112
- transition: VariantTarget.transitionOfTarget(target.transition, element),
116
+ transition: VariantTarget.transitionOfTarget(target.transition, wardTransition),
113
117
  }));
114
118
  /** A config given as a value or as an accessor, as an accessor. A config is always an object, so a function is the accessor. */
115
119
  export const accessorOf = (config) => Bool.match(Predicate.isFunction(config), { onTrue: () => config, onFalse: () => () => config });
@@ -143,17 +147,10 @@ const keysByLayerOf = (t, layers, extraDelay, extra, listed, shut) => {
143
147
  * The transition `key` animates on in a Retarget: its group's (#277, #297), else the Retarget's one,
144
148
  * with no stagger (#448 reads its fields, not its delay).
145
149
  */
146
- const keyTransitionOf = (resolution, groups, key, transition, element) => {
150
+ const keyTransitionOf = (resolution, groups, key, transition, wardTransition) => {
147
151
  if (Predicate.isUndefined(groups))
148
152
  return transition;
149
- return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, element, undefined, identity);
150
- };
151
- /** Whether `given` gives `key` a velocity (#448, Motion's `valueTransition.velocity`): it kicks the key, so it animates though at its target. */
152
- const givesVelocity = (given, key) => {
153
- const own = RetargetLegs.transitionForKey(given, key);
154
- if (Predicate.isUndefined(own))
155
- return false;
156
- return Bool.and(Predicate.isNumber(own.velocity), own.velocity !== 0);
153
+ return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, wardTransition, undefined, identity);
157
154
  };
158
155
  /** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
159
156
  const velocityOf = (snapshot, key) => {
@@ -173,13 +170,15 @@ const pickKeys = (t, groups, i) => {
173
170
  };
174
171
  /** A transition's `delay`, 0 without one. */
175
172
  export const delayOf = (transition) => UndefinedOr.match(transition, { onUndefined: () => 0, onDefined: ({ delay = 0 }) => delay });
176
- /** No keys: what a drag moves on a projected element, or one with no drag. */
173
+ /** No keys: what a drag moves on a projected Subject, or one with no drag. */
177
174
  const NO_KEYS = [];
178
175
  /** The keys a drag of `axis` moves directly. Built once, at module load. */
179
176
  const dragMovesOf = Match.type().pipe(Match.when("x", () => ["x"]), Match.when("y", () => ["y"]), Match.orElse(() => ["x", "y"]));
180
177
  /** Whether a start link's value takes its target's shape: both numbers, or both strings. */
181
178
  const isSameKind = (value, like) => Predicate.isNumber(value) === Predicate.isNumber(like);
182
179
  /** The keys a drag direct-sets (ADR-0004). */
180
+ // `translateX` and `translateY` are the DOM's own keys since #1002 (ADR-0073, *Amendment (#1002)*, Q6): they
181
+ // stay here, plumbing, as the DOM's aliases of `x` and `y` that a drag holds back too.
183
182
  const TRANSLATE_KEYS = new Set(["x", "y", "translateX", "translateY"]);
184
183
  const TRANSLATE_KEY_LIST = Arr.fromIterable(TRANSLATE_KEYS);
185
184
  /** Whether a value map has any key. */
@@ -209,7 +208,7 @@ const sameField = (a, b) => {
209
208
  return false;
210
209
  };
211
210
  /** A gesture layer that's off: nothing is resolved for it. */
212
- const OFF = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined };
211
+ const OFF = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined, failure: VariantTarget.NO_FAILURE };
213
212
  /**
214
213
  * A gesture layer (#291), while it's on (its own, or its provider's): its own `while*` (a target, or
215
214
  * a variant name), else the label its provider hands down. Off, or with neither, nothing is resolved.
@@ -251,7 +250,7 @@ const setsValues = (layer) => {
251
250
  };
252
251
  /** A single entry's name: itself, if a name; `undefined` for a values map. */
253
252
  const labelOrUndefined = (entry) => Bool.match(Predicate.isString(entry), { onTrue: () => entry, onFalse: constUndefined });
254
- /** Each gesture on: the element's own, or its provider's too when it has one handing any down. */
253
+ /** Each gesture on: the Subject's own, or its provider's too when it has one handing any down. */
255
254
  const gesturesOnOf = (active, above) => {
256
255
  if (above === VariantTree.NO_HAND_DOWN)
257
256
  return active;
@@ -270,7 +269,7 @@ const activeNamesFor = (c, on, labels) => {
270
269
  const anyOn = (on) => on.inView || on.focused || on.hovered || on.pressed || on.dragged;
271
270
  /**
272
271
  * Whether an active entry's name delays its keys otherwise than the first entry's (#297): a Variant
273
- * child's names each take their own stagger slot. Never for an element that joins none, nor for one
272
+ * child's names each take their own stagger slot. Never for a Subject that joins none, nor for one
274
273
  * entry.
275
274
  */
276
275
  const delaysDiffer = (layers, extraDelay, extra) => {
@@ -278,7 +277,7 @@ const delaysDiffer = (layers, extraDelay, extra) => {
278
277
  return false;
279
278
  return Arr.some(layers, (layer) => Bool.and(layer.active, extraOf(extraDelay, layer) !== extra));
280
279
  };
281
- /** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other element. */
280
+ /** An entry's stagger delay (ADR-0007, #297): its name's, for a Variant child; 0 for any other Subject. */
282
281
  const extraOf = (extraDelay, layer) => {
283
282
  if (Predicate.isUndefined(extraDelay))
284
283
  return 0;
@@ -288,27 +287,27 @@ const extraOf = (extraDelay, layer) => {
288
287
  };
289
288
  /**
290
289
  * The transition a key group runs on (#291, #297): unsplit, the base's (`transition`, its delay
291
- * folded in); split, its entry's own, else the element's, at its name's delay. A list's first
292
- * group carries its returns too, which run on the element's transition, as a list's base has no one
290
+ * folded in); split, its entry's own, else the Subject's, at its name's delay. A list's first
291
+ * group carries its returns too, which run on the Subject's transition, as a list's base has no one
293
292
  * transition of its own.
294
293
  */
295
- const groupTransitionOf = (resolution, groups, i, transition, element, extraDelay, reuse) => {
294
+ const groupTransitionOf = (resolution, groups, i, transition, wardTransition, extraDelay, reuse) => {
296
295
  if (Predicate.isUndefined(groups))
297
296
  return transition;
298
297
  if (Bool.and(i === 0, Bool.not(Arr.isArray(resolution.variant))))
299
298
  return transition;
300
299
  const layer = resolution.layers[i];
301
- // A list's returns: the element's, at its whole orchestration's delay.
300
+ // A list's returns: the Subject's, at its whole orchestration's delay.
302
301
  if (Predicate.isUndefined(layer))
303
- return staggeredOf(element, extraOf(extraDelay, undefined), reuse);
304
- return staggeredOf(VariantTarget.transitionOfTarget(layer.transition, element), extraOf(extraDelay, layer), reuse);
302
+ return staggeredOf(wardTransition, extraOf(extraDelay, undefined), reuse);
303
+ return staggeredOf(VariantTarget.transitionOfTarget(layer.transition, wardTransition), extraOf(extraDelay, layer), reuse);
305
304
  };
306
305
  /** No names. */
307
306
  const NO_NAMES = [];
308
307
  /** No legs. */
309
308
  const NO_LEGS = [];
310
309
  /**
311
- * A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the element
310
+ * A gated Retarget's landing (ADR-0007 `when`, #325): the legs it carries report the Subject
312
311
  * unsettled, as it still owes an animation, and land nothing; the Retarget once the gate opens
313
312
  * counts them.
314
313
  */
@@ -323,7 +322,7 @@ const gatedLandingOf = (onFrame) => ({
323
322
  /** No running legs. */
324
323
  export const NO_RUNNING = [];
325
324
  /**
326
- * The waiting Transition ends of element `id` (#508): made at its first end, so an element with none,
325
+ * The waiting Transition ends of Subject `id` (#508): made at its first end, so a Subject with none,
327
326
  * nearly every one, pays nothing for them. `owners` holds the leg drawing each key.
328
327
  */
329
328
  const waitingEndsOf = (owners, snapshot, gate, id, recordFrame) => {
@@ -413,7 +412,7 @@ const waitingEndsOf = (owners, snapshot, gate, id, recordFrame) => {
413
412
  },
414
413
  };
415
414
  };
416
- /** A leg's last frame lands the Transition ends waiting on it (#508); an element with none has nothing to ask. */
415
+ /** A leg's last frame lands the Transition ends waiting on it (#508); a Subject with none has nothing to ask. */
417
416
  const landEndsOf = (waiting) => {
418
417
  if (Predicate.isNotUndefined(waiting))
419
418
  waiting.land();
@@ -422,7 +421,7 @@ const landEndsOf = (waiting) => {
422
421
  export const NO_VALUES = {};
423
422
  /**
424
423
  * Whether a change's starts, targets or Keyframes stops hold a Variable value (#542): only then can
425
- * the element's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
424
+ * the Subject's Key rule, its Variable values (#55), take a pair, so only then is a leg's machine
426
425
  * built under it. It declines every pair with no `var()` at either end.
427
426
  */
428
427
  export const holdsVariable = (variables, from, to, stops) => {
@@ -448,13 +447,17 @@ const stopsCheckOf = (variables) => {
448
447
  stopsChecks.set(variables, check);
449
448
  return check;
450
449
  };
451
- /** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto `rotate`. */
450
+ /** A Path's turn (#438, ADR-0065): the reserved key its Environment's renderer adds onto the Subject's turn. */
452
451
  const PATH_ROTATION = "pathRotation";
453
452
  /** The turn back at 0, written once no leg draws it (#460). */
454
453
  const TURNED_BACK = { [PATH_ROTATION]: 0 };
455
- /** A leg over the keys of `to` (#325), counting toward `landing`: the spine gives it the keys. */
456
- export const runningOf = (to, resolution, landing, kind) => ({
454
+ /**
455
+ * A leg over the keys of `to` (#325), counting toward `landing`: the spine gives it the keys. A Handoff's
456
+ * leg is `onFrameTimeline` (#1026).
457
+ */
458
+ export const runningOf = (to, resolution, landing, kind, onFrameTimeline = false) => ({
457
459
  supersede: Supersede.make(),
460
+ onFrameTimeline,
458
461
  targets: to,
459
462
  resolution,
460
463
  count: 0,
@@ -502,6 +505,28 @@ const blendVelocityOf = (running, key) => {
502
505
  return 0;
503
506
  return ((last - before) * 1000) / apart;
504
507
  };
508
+ /**
509
+ * A Blend leg's last two frames' values, kept for its velocity (#464): two records of its own, swapped each
510
+ * frame, the frame's values copied into the newer, since its Frame is its run's, rewritten each tick. Before
511
+ * its first frame, the Snapshot's values are its older. A leg that lands on its first frame keeps none: its
512
+ * velocity is 0.
513
+ */
514
+ // #895: per frame, plain calls; its two records made at its first frame, nothing after.
515
+ const keepFrame = (running, frame, snapshotValues) => {
516
+ const older = running.last;
517
+ if (Predicate.isUndefined(older)) {
518
+ if (frame.done)
519
+ return;
520
+ running.before = { ...snapshotValues };
521
+ running.last = { ...frame.value };
522
+ return;
523
+ }
524
+ // Set with `last` at its first frame: present by construction.
525
+ const newer = UndefinedOr.getOrThrow(running.before);
526
+ Object.assign(newer, frame.value);
527
+ running.before = older;
528
+ running.last = newer;
529
+ };
505
530
  /** A leg's frame drawn (#325) at `now`: its last lands the keys it draws. Per frame: plain calls. */
506
531
  const drew = (running, done, now) => {
507
532
  if (done)
@@ -547,7 +572,7 @@ const restOf = (owners, target, axis) => {
547
572
  /**
548
573
  * Where a Path's axes that `target` leaves out rest (#574), read before their legs give them up: a
549
574
  * new Path ends them there, so a toss caught mid-air curves back to its line. `undefined` for none:
550
- * every element's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
575
+ * every Subject's Retarget asks, nearly always with no Path in flight, so guards, nothing built.
551
576
  */
552
577
  export const restsOf = (owners, target) => {
553
578
  const x = restOf(owners, target, "x");
@@ -590,7 +615,7 @@ const anyShutOf = (shut) => {
590
615
  * variant does, unless keys it drives stay running. A list's returns' Live values follow with its
591
616
  * returns' group, last; any other's with the first group.
592
617
  */
593
- const splitLegsOf = (t, from, groups, resolution, listed, transition, element, extraDelay, reuse, reduce, skipped, positionalKeys, defaultTransition, velocities, follow, stops, measured, current, rests, unitScale) => {
618
+ const splitLegsOf = (t, from, groups, resolution, listed, transition, wardTransition, extraDelay, reuse, reduce, skipped, positionalKeys, defaultTransition, velocities, follow, stops, measured, current, rests, unitScale) => {
594
619
  let returnsAt = 0;
595
620
  if (listed)
596
621
  returnsAt = resolution.layers.length;
@@ -604,7 +629,7 @@ const splitLegsOf = (t, from, groups, resolution, listed, transition, element, e
604
629
  let followed;
605
630
  if (i === returnsAt)
606
631
  followed = follow;
607
- const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition, element, extraDelay, reuse), reduce, skipped, positionalKeys, defaultTransition, velocities, followed, stops, measured, current, rests, unitScale);
632
+ const groupLegs = RetargetLegs.legsOf(from, picked, groupTransitionOf(resolution, groups, i, transition, wardTransition, extraDelay, reuse), reduce, skipped, positionalKeys, defaultTransition, velocities, followed, stops, measured, current, rests, unitScale);
608
633
  Arr.forEach(groupLegs, (built) => {
609
634
  legs.push(built);
610
635
  tags.push(i);
@@ -616,7 +641,7 @@ const splitLegsOf = (t, from, groups, resolution, listed, transition, element, e
616
641
  * A list's names at a Retarget (#297): told settled as the legs of the keys each drives settle, to
617
642
  * the binding's callbacks (Solid 1's, PR 1) and to its orchestration (PR 2), told moving now; and each
618
643
  * shut name's legs waiting on its gate (PR 2), its keys held where they start, so another name's first
619
- * commit, which hands the element's style back (ADR-0034), doesn't drop them to their own value.
644
+ * commit, which hands the Subject's style back (ADR-0034), doesn't drop them to their own value.
620
645
  */
621
646
  const listingOf = (of) => {
622
647
  const { listed, told, byName, resolution, groups, legGroups, legCount, carriedGroups, shut, config } = of;
@@ -677,7 +702,7 @@ const logsDebugOn = (runtime) => {
677
702
  return on;
678
703
  };
679
704
  /**
680
- * No key taken by an Imperative animation (#433): every spine's until its first, shared, so an element
705
+ * No key taken by an Imperative animation (#433): every spine's until its first, shared, so a Subject
681
706
  * none animates holds no map of its own (#460). Never written: a spine sets keys in a map of its own,
682
707
  * and deletes only from one that has some.
683
708
  */
@@ -705,6 +730,7 @@ const layerOf = (target, name) => ({
705
730
  name,
706
731
  ends: endsOfTarget(target),
707
732
  keyframes: target.keyframes,
733
+ failure: target.failure,
708
734
  });
709
735
  /** A list's target as an active entry (#297). */
710
736
  const namedLayerOf = (target) => layerOf(target, target.name);
@@ -755,7 +781,7 @@ const hasKeyframes = (layer) => {
755
781
  };
756
782
  /**
757
783
  * Each resolved key's Keyframes (#429): the stops of the entry that drives it, when that entry gives
758
- * it Keyframes. `undefined`, with nothing made, when no active entry has any: every element's common
784
+ * it Keyframes. `undefined`, with nothing made, when no active entry has any: every Subject's common
759
785
  * case.
760
786
  */
761
787
  const keyframesNowOf = (layers, resolved) => {
@@ -869,10 +895,11 @@ const keepsStart = (pairs, key, start, target) => {
869
895
  const measuringOf = (found, keyframes) => Arr.appendAll(UndefinedOr.match(found, { onUndefined: () => [], onDefined: identity }), UndefinedOr.match(keyframes, { onUndefined: () => [], onDefined: Rec.keys }));
870
896
  /**
871
897
  * A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
872
- * end-of-task batch with the values the element draws now, but a key with Keyframes of more than two
873
- * stops (`many`, #460). `undefined` with none.
898
+ * end-of-task batch with the values the Subject draws now, but a key with Keyframes of more than two
899
+ * stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
900
+ * it couldn't read do, reported on `runtime` with the Subject's `id`.
874
901
  */
875
- export const measuredOf = (measured, element, keys, from, to, values, many) => {
902
+ export const measuredOf = (measured, subject, keys, from, to, values, many, runtime, id) => {
876
903
  const pairs = {};
877
904
  Arr.forEach(keys, (key) => {
878
905
  if (RetargetLegs.hasManyStops(many, key))
@@ -886,8 +913,15 @@ export const measuredOf = (measured, element, keys, from, to, values, many) => {
886
913
  });
887
914
  if (Rec.isEmptyRecord(pairs))
888
915
  return undefined;
889
- return measured.measure(element, pairs, values);
916
+ // Its report made only for pairs asked, not once a Subject (#979, row 8): nearly every Retarget asks none.
917
+ return measured.measure(subject, pairs, values, pairsFailedOn("wardic.spine: a Retarget's Measured pairs failed", runtime, { id }));
918
+ };
919
+ /** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
920
+ const pairsFailedOn = (message, runtime, annotations) => (defect) => {
921
+ runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(defect)), annotations));
890
922
  };
923
+ /** How an exit's Measured pairs the batch couldn't take (its Transform template threw) are reported, on `runtime`. */
924
+ export const exitMeasuredFailedOn = (runtime) => pairsFailedOn("wardic.presence: an exit's Measured pairs failed", runtime, {});
891
925
  /** A key's Keyframes in `keyframes` (#429): per key, per Retarget, so a guard, nothing made. */
892
926
  const keyframesAtOf = (keyframes, key) => {
893
927
  if (Predicate.isUndefined(keyframes))
@@ -1023,17 +1057,26 @@ const nameSettlesOf = (names, resolution, groups, legGroups, legCount, carriedGr
1023
1057
  /**
1024
1058
  * Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
1025
1059
  * config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
1026
- * the config. A callback that throws is reported, and the element animates on. The Solid 2 binding's
1027
- * config has neither: it hands the same facts over as async values.
1060
+ * the config. A callback that throws is reported at the first of a run of throws, its next clean call
1061
+ * ending the run, and the Subject animates on. The Solid 2 binding's config has neither: it hands the
1062
+ * same facts over as async values.
1028
1063
  */
1029
1064
  export const animationCallbacks = (runtime, id) => {
1030
- // Per Retarget, per element: the callback looked up first, and nothing made without one.
1031
- const tell = (name, callback, definition) => {
1065
+ // #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
1066
+ // each name of a list one call, so a clean name ends it. Two lets, nothing more made per Subject.
1067
+ let startFailing = false;
1068
+ let completeFailing = false;
1069
+ // Per Retarget, per Subject: the callback looked up first, and nothing made without one. Whether it threw,
1070
+ // reported at a run's first throw (`failing` says one is on).
1071
+ const tell = (name, callback, definition, failing) => {
1032
1072
  try {
1033
1073
  callback(definition);
1074
+ return false;
1034
1075
  }
1035
1076
  catch (defect) {
1036
- runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })));
1077
+ if (!failing)
1078
+ runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })));
1079
+ return true;
1037
1080
  }
1038
1081
  };
1039
1082
  return {
@@ -1044,10 +1087,12 @@ export const animationCallbacks = (runtime, id) => {
1044
1087
  return;
1045
1088
  const definition = definitionOf(resolution, previous);
1046
1089
  if (Arr.isArray(definition)) {
1047
- Arr.forEach(definition, (name) => tell("onAnimationStart", callback, name));
1090
+ Arr.forEach(definition, (name) => {
1091
+ startFailing = tell("onAnimationStart", callback, name, startFailing);
1092
+ });
1048
1093
  return;
1049
1094
  }
1050
- tell("onAnimationStart", callback, definition);
1095
+ startFailing = tell("onAnimationStart", callback, definition, startFailing);
1051
1096
  },
1052
1097
  // A list's names were each told as they settled (`namesSettled`).
1053
1098
  settled: (resolution, previous, config) => {
@@ -1057,17 +1102,19 @@ export const animationCallbacks = (runtime, id) => {
1057
1102
  const definition = definitionOf(resolution, previous);
1058
1103
  if (Arr.isArray(definition))
1059
1104
  return;
1060
- tell("onAnimationComplete", callback, definition);
1105
+ completeFailing = tell("onAnimationComplete", callback, definition, completeFailing);
1061
1106
  },
1062
1107
  namesSettled: (names, config) => {
1063
1108
  const callback = config.onAnimationComplete;
1064
1109
  if (Predicate.isUndefined(callback))
1065
1110
  return;
1066
- Arr.forEach(names, (name) => tell("onAnimationComplete", callback, name));
1111
+ Arr.forEach(names, (name) => {
1112
+ completeFailing = tell("onAnimationComplete", callback, name, completeFailing);
1113
+ });
1067
1114
  },
1068
1115
  };
1069
1116
  };
1070
- /** The variant name an element animates to: its own `animate`'s, else the one its provider hands down. */
1117
+ /** The variant name a Subject animates to: its own `animate`'s, else the one its provider hands down. */
1071
1118
  const variantOf = (animate, parent) => {
1072
1119
  if (Predicate.isNotUndefined(animate))
1073
1120
  return VariantTree.nameOf(animate);
@@ -1081,7 +1128,7 @@ const baseTargetOf = (own, variant, variants, custom, state, initialLink) => {
1081
1128
  return VariantTarget.resolveTarget(own, variants, custom, state);
1082
1129
  if (Predicate.isNotUndefined(variant))
1083
1130
  return VariantTarget.resolveTarget(variant, variants, custom, state);
1084
- return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined };
1131
+ return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined, failure: VariantTarget.NO_FAILURE };
1085
1132
  };
1086
1133
  /**
1087
1134
  * The Override stack resolved (ascending priority, Motion's `variantPriorityOrder`): base (animate, or
@@ -1102,7 +1149,7 @@ export const resolutionOf = (c, parent, initialLink, active, state, own) => {
1102
1149
  // sibling's "open"); read parent.variant() here so a parent flip
1103
1150
  // recomputes the memo and retargets;
1104
1151
  // (3) else the SSR-seeded `initial`.
1105
- // Per Retarget, per element (#460, compose once): statements.
1152
+ // Per Retarget, per Subject (#460, compose once): statements.
1106
1153
  const variant = variantOf(c.animate, parent);
1107
1154
  // A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
1108
1155
  // that sets a key drives it. A single name or a values map takes the path below, as before.
@@ -1112,7 +1159,7 @@ export const resolutionOf = (c, parent, initialLink, active, state, own) => {
1112
1159
  const listLayers = Arr.map(targets, namedLayerOf);
1113
1160
  return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change);
1114
1161
  }
1115
- // A dynamic variant resolves with this element's own `custom` (#277), as Motion's each child's.
1162
+ // A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
1116
1163
  // Animation controls never reach here: its binding reads them once, each change its entry (#433).
1117
1164
  const target = baseTargetOf(c.animate, variant, variants, c.custom, state, initialLink);
1118
1165
  const base = target.values;
@@ -1120,7 +1167,7 @@ export const resolutionOf = (c, parent, initialLink, active, state, own) => {
1120
1167
  // A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
1121
1168
  // its own `while*`, else the label the provider hands down. With no provider, its own: nothing made.
1122
1169
  // The common case: nothing handed down and no gesture on. The base entry alone, and nothing else
1123
- // made or called, at every element's mount and Retarget.
1170
+ // made or called, at every Subject's mount and Retarget.
1124
1171
  if (VariantTree.handDownFrom(parent) === VariantTree.NO_HAND_DOWN && !anyOn(active)) {
1125
1172
  const alone = [baseLayer];
1126
1173
  const { resolved, ends, keyframes } = resolvedOf(alone);
@@ -1128,7 +1175,7 @@ export const resolutionOf = (c, parent, initialLink, active, state, own) => {
1128
1175
  }
1129
1176
  return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change);
1130
1177
  };
1131
- /** The **Controls change** in effect for an element (#433): its own, else its provider's; per Retarget, a guard. */
1178
+ /** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
1132
1179
  const changeIn = (own, parent) => {
1133
1180
  if (Predicate.isNotUndefined(own))
1134
1181
  return own;
@@ -1184,20 +1231,111 @@ const withGestures = (c, parent, layers, base, variant, active, transition, stat
1184
1231
  return { resolved, base, dragging: active.dragging, variant, active, transition, layers, names, layersOn, ends, keyframes, change };
1185
1232
  };
1186
1233
  /**
1187
- * An element's {@link Start}, from its config read once and the context it inherits from. With
1234
+ * A Subject's {@link Start}, from its config read once and the context it inherits from. With
1188
1235
  * `initial={false}` (its own, inherited, or an `<AnimatePresence initial={false}>`'s first render)
1189
1236
  * it starts at its `animate`, and nothing animates at mount (#134).
1190
1237
  */
1191
1238
  export const startOf = (config, parent, presenceBlocks, untrack) => {
1192
1239
  const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks);
1193
- const initialValues = VariantTree.startingValuesOf(config, parent, presenceBlocks, untrack);
1240
+ // Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
1241
+ // for a Subject with no variants, so its start makes nothing more (bench:solid's mount).
1242
+ const variants = VariantTarget.startingVariantsOf(config.variants, config.custom);
1243
+ const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants);
1194
1244
  return {
1195
1245
  quiet: VariantTree.startsQuiet(config, parent, presenceBlocks, untrack),
1196
1246
  initialValues,
1197
1247
  initialLink: Bool.match(startedAtAnimate, { onTrue: () => ({}), onFalse: () => initialValues }),
1198
1248
  startedLink: Bool.match(startedAtAnimate, { onTrue: () => initialValues, onFalse: () => ({}) }),
1249
+ failure: variants.failure,
1199
1250
  };
1200
1251
  };
1252
+ /** How a variant's failure is reported under `message`, on a runtime: at Error, its cause what the resolver threw, annotated with the variant's name. */
1253
+ const failedOn = (message) => (runtime) => (failure) => {
1254
+ runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }));
1255
+ };
1256
+ /** How a Subject's variant that throws is reported, on its runtime. */
1257
+ const variantFailedOn = failedOn("wardic.ward: a variant failed");
1258
+ /** How an exit whose resolver throws is reported, on `runtime`, each time a Subject leaves: its Subject leaves without it (#979). */
1259
+ export const exitVariantFailedOn = failedOn("wardic.presence: an exit variant failed");
1260
+ /** A Subject's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
1261
+ export const variantFailedOnServer = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER);
1262
+ /** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
1263
+ const firstFailureOf = Arr.findFirst((layer) => layer.failure);
1264
+ /** The first of a resolution's entries' resolvers that threw, and its variant's name (#979). */
1265
+ export const failureOf = (resolution) => firstFailureOf(resolution.layers);
1266
+ /** A Subject's {@link VariantFailures}, none failing yet, reported on `runtime`. */
1267
+ // #979 (bench:solid's mount): one plain object a Subject, read by the functions below, not closures, and
1268
+ // holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
1269
+ // WeakMap cost Solid 1's mount 6% (the lookup, a Subject).
1270
+ export const variantFailuresOf = (runtime) => ({ last: undefined, failing: undefined, delayFailing: false, runtime });
1271
+ /** Where a variant's failure was seen, until each resolves it again: its Subject's resolutions, and its orchestration. */
1272
+ const RESOLVING = 1;
1273
+ const ORCHESTRATING = 2;
1274
+ // #979 (ADR-0074; Q6 and its review): a resolver's throw is its Subject's alone. Each variant, by name,
1275
+ // is reported as it starts failing and fails until every place that saw it fail resolves it again, so
1276
+ // a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
1277
+ // values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
1278
+ // no values isn't reported again at the first change its orchestration reads.
1279
+ const failedAt = (failures, failure, at) => {
1280
+ const name = UndefinedOr.match(failure.name, { onDefined: identity, onUndefined: () => "" });
1281
+ if (Predicate.isUndefined(failures.failing))
1282
+ failures.failing = new Map();
1283
+ const before = failures.failing.get(name);
1284
+ if (Predicate.isUndefined(before)) {
1285
+ failures.failing.set(name, at);
1286
+ variantFailedOn(failures.runtime)(failure);
1287
+ return;
1288
+ }
1289
+ failures.failing.set(name, before | at);
1290
+ };
1291
+ const resolvedAt = (failing, name, at) => {
1292
+ if (Predicate.isUndefined(name))
1293
+ return;
1294
+ const before = failing.get(name);
1295
+ if (Predicate.isUndefined(before))
1296
+ return;
1297
+ const after = before & ~at;
1298
+ if (after === 0) {
1299
+ failing.delete(name);
1300
+ return;
1301
+ }
1302
+ failing.set(name, after);
1303
+ };
1304
+ /** `next`, else, while it carries a failure, the Subject's last good resolution: it keeps its target. */
1305
+ // Per Retarget, per Subject (#460, compose once): statements; nothing done while nothing fails.
1306
+ export const keptOf = (failures, next) => {
1307
+ const failure = failureOf(next);
1308
+ if (Option.isSome(failure)) {
1309
+ failedAt(failures, failure.value, RESOLVING);
1310
+ // The first one has no last good one: its failed entry resolved to nothing.
1311
+ const last = failures.last;
1312
+ if (Predicate.isUndefined(last))
1313
+ return next;
1314
+ return last;
1315
+ }
1316
+ failures.last = next;
1317
+ const failing = failures.failing;
1318
+ if (Predicate.isUndefined(failing) || failing.size === 0)
1319
+ return next;
1320
+ Arr.forEach(next.layers, (layer) => resolvedAt(failing, layer.name, RESOLVING));
1321
+ return next;
1322
+ };
1323
+ /** A start's failure, setup's or a re-entry's fresh start's: setup resolves as orchestration does, so it stands for both until each resolves the variant again. */
1324
+ export const reportStart = (failures, start) => {
1325
+ if (Option.isSome(start.failure))
1326
+ failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING);
1327
+ };
1328
+ /** What a Subject's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
1329
+ export const orchestrationOf = (failures) => (entry, failure) => {
1330
+ if (Option.isSome(failure)) {
1331
+ failedAt(failures, failure.value, ORCHESTRATING);
1332
+ return;
1333
+ }
1334
+ const failing = failures.failing;
1335
+ if (Predicate.isUndefined(failing) || failing.size === 0)
1336
+ return;
1337
+ Arr.forEach(Arr.ensure(entry), (name) => resolvedAt(failing, name, ORCHESTRATING));
1338
+ };
1201
1339
  /** A Snapshot seeded from the Starting values, velocities 0, so frame 1 flows out of the seed (no snap). */
1202
1340
  export const snapshotOf = (start) => emptySnapshotOf({ ...start.initialValues });
1203
1341
  /** A Snapshot of `values`, nothing moving: read as it is until a spine reads it. */
@@ -1277,9 +1415,9 @@ export const velocitiesNowOf = (snapshot) => {
1277
1415
  return Rec.map(Rec.filter(snapshot.values, Predicate.isNumber), (_, key) => velocityAt(snapshot, UndefinedOr.match(owners, { onUndefined: constUndefined, onDefined: (map) => map.get(key) }), key, now));
1278
1416
  };
1279
1417
  /**
1280
- * The transition a Retarget runs on (#66): the element's last one when the new one has the same
1418
+ * The transition a Retarget runs on (#66): the Subject's last one when the new one has the same
1281
1419
  * fields, so core's decode cache hits when the object is rebuilt with the same values (a staggered
1282
- * child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per element.
1420
+ * child's, ADR-0007, or one Solid rebuilds as it reads a signal). One per Subject.
1283
1421
  */
1284
1422
  export const makeReuse = () => {
1285
1423
  let lastTransition;
@@ -1292,12 +1430,12 @@ export const makeReuse = () => {
1292
1430
  };
1293
1431
  };
1294
1432
  /**
1295
- * An element's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
1433
+ * A Subject's presence record (ADR-0007 exit): seeded with its Starting values, so an exit that
1296
1434
  * fires before any frame still has a `from`, and its `exit` ref, which the ward keeps current. An exit key with no value starts
1297
1435
  * from its Base value's start links (ADR-0022), read from the Subject kept at the exit.
1298
1436
  */
1299
- export const presenceRecordOf = (element, start, exitOf, links, tree, snapshot, reducedMotion, skipAnimations) => ({
1300
- element,
1437
+ export const presenceRecordOf = (subject, start, exitOf, links, tree, snapshot, reducedMotion, skipAnimations) => ({
1438
+ subject,
1301
1439
  snapshot: { current: { ...start.initialValues } },
1302
1440
  exitOf,
1303
1441
  tree,
@@ -1306,18 +1444,18 @@ export const presenceRecordOf = (element, start, exitOf, links, tree, snapshot,
1306
1444
  velocities: () => velocitiesNowOf(snapshot),
1307
1445
  // Its own, under its nearest WardicConfig (#434): its exit honours it, not the presence's.
1308
1446
  reducedMotion,
1309
- // Its nearest WardicConfig's (#468): an exit is skipped as its element's animations are.
1447
+ // Its nearest WardicConfig's (#468): an exit is skipped as its Subject's animations are.
1310
1448
  skipAnimations,
1311
1449
  });
1312
1450
  /**
1313
1451
  * Merge an emitted frame's value-map into a presence record's snapshot (nothing without one). It
1314
- * mirrors what the gate accumulates, so an exit departs from the element's actual resting value-map.
1452
+ * mirrors what the gate accumulates, so an exit departs from the Subject's actual resting value-map.
1315
1453
  */
1316
1454
  export const recordFrameOf = (presence) => (value) => {
1317
1455
  if (Predicate.isNotUndefined(presence))
1318
1456
  Object.assign(presence.snapshot.current, value);
1319
1457
  };
1320
- /** Tell an element's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for an element with none. */
1458
+ /** Tell a Subject's Live routes the legs a Retarget starts ({@link LiveRoutes.started}): nothing for a Subject with none. */
1321
1459
  export const tellStarted = (live, legs) => {
1322
1460
  if (Predicate.isUndefined(live))
1323
1461
  return;
@@ -1329,7 +1467,7 @@ let holds;
1329
1467
  export const memberHoldsNow = () => holds;
1330
1468
  /**
1331
1469
  * Holds made from now on, through `holds` (`createBatch`, as it's called, gives a Batch's): a Batch's
1332
- * members can be Wardic elements. The first one given stays.
1470
+ * members can be Wards' Subjects. The first one given stays.
1333
1471
  */
1334
1472
  export const provideMemberHolds = (given) => {
1335
1473
  if (Predicate.isNotUndefined(holds))
@@ -1337,29 +1475,20 @@ export const provideMemberHolds = (given) => {
1337
1475
  holds = given;
1338
1476
  };
1339
1477
  /**
1340
- * Each draggable element's spine's drag hook (#665's PR 4): told `true` as its drag reads where the
1341
- * element rests or writes `x`/`y`, and `false` as it hands them back. A Batch member's takes its
1478
+ * Each draggable Subject's spine's drag hook (#665's PR 4): told `true` as its drag reads where the
1479
+ * Subject rests or writes `x`/`y`, and `false` as it hands them back. A Batch member's takes its
1342
1480
  * transform from its Batch then, and gives it back.
1343
1481
  */
1344
- // Module state (#460, Q7): held weakly by the element, so it goes with it.
1482
+ // Module state (#460, Q7): held weakly by the Subject, so it goes with it.
1345
1483
  const DRAG_HOOKS = new WeakMap();
1346
- /** `element`'s drag hook told `on`, when its spine has one: its binding's drag start and end, and a drag's claim. */
1347
- export const tellDrag = (element, on) => {
1348
- UndefinedOr.map(DRAG_HOOKS.get(element), (tell) => tell(on));
1484
+ /** `subject`'s drag hook told `on`, when its spine has one: its binding's drag start and end, and a drag's claim. */
1485
+ export const tellDrag = (subject, on) => {
1486
+ UndefinedOr.map(DRAG_HOOKS.get(subject), (tell) => tell(on));
1349
1487
  };
1350
1488
  /** Tell `timelineKeys` that each of `values`' keys is taken from its Live value (#240). */
1351
1489
  const takeEach = (timelineKeys, values) => {
1352
1490
  Arr.forEach(Rec.keys(values), (key) => timelineKeys.taken(key));
1353
1491
  };
1354
- /**
1355
- * A mounted element's spine: its Retarget, the returns to its Base values, the follower of its
1356
- * Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
1357
- * its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
1358
- * ElementSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
1359
- * run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
1360
- * *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
1361
- * fiber Scope interrupts what's left when the provider ends.
1362
- */
1363
1492
  /** Each runtime's unit scale, read once: a mount reads a WeakMap, not a run of its own. */
1364
1493
  // Module state (#460, Q7): held weakly by the runtime, so it goes with it.
1365
1494
  const UNIT_SCALES = new WeakMap();
@@ -1372,8 +1501,17 @@ export const unitScaleOf = (runtime) => {
1372
1501
  UNIT_SCALES.set(runtime, read);
1373
1502
  return read;
1374
1503
  };
1375
- export const makeElementSpine = (options) => {
1376
- const { animation, byName, canStart, config, defaultTransition, diagnostics, element, extraDelay, gate, id, links, live, measuredPairs, onFrame, ownValues, parent, positionalKeys, presence, runtime, snapshot, start, styleNow, tag, variableValues } = options;
1504
+ /**
1505
+ * A mounted Subject's spine: its Retarget, the returns to its Base values, the follower of its
1506
+ * Live values, and its legs' lifetime. Every leg is a fiber of its provider's runtime, and joins
1507
+ * its Retarget's token: a Retarget ends the token before it starts its own legs, and {@link
1508
+ * SubjectSpine.dispose} ends every leg's (#542). Both end the legs in the calling task: each leg's
1509
+ * run leaves the loop at once, and its fiber ends Superseded, inline (ADR-0027, decision 5,
1510
+ * *Amendment (#200)*). A leg the token didn't reach is interrupted (`endLeg`). The runtime's own
1511
+ * fiber Scope interrupts what's left when the provider ends.
1512
+ */
1513
+ export const makeSubjectSpine = (options) => {
1514
+ 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;
1377
1515
  // The Environment's unit scale (ADR-0069 decision 8, #883): read from the runtime the spine already holds,
1378
1516
  // so no binding passes it; 1, Motion's own, unless the Environment's Layers give another.
1379
1517
  const unitScale = unitScaleOf(runtime);
@@ -1382,9 +1520,9 @@ export const makeElementSpine = (options) => {
1382
1520
  let handoff = options.handoff;
1383
1521
  // Its mount tells nothing when it starts at its `animate` (#448): on until its first Retarget.
1384
1522
  let quiet = start.quiet;
1385
- // Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this element,
1523
+ // Its Variable values (#55, ADR-0035 *Amendment (#55)*): the Key rule bound to this Subject,
1386
1524
  // added to each leg it starts, so a `var()` end blends what it resolves to here.
1387
- const elementRules = [variableValues.values(element)];
1525
+ const subjectRules = [variableValues.values(subject)];
1388
1526
  const recordFrame = recordFrameOf(presence);
1389
1527
  // Whether its animations are skipped (#468): never, with nothing given.
1390
1528
  const skipAnimations = UndefinedOr.match(options.skipAnimations, { onUndefined: () => constFalse, onDefined: identity });
@@ -1409,16 +1547,16 @@ export const makeElementSpine = (options) => {
1409
1547
  const timelines = Context.getOrUndefined(services, Timelines.Timelines);
1410
1548
  if (Predicate.isUndefined(timelines))
1411
1549
  return undefined;
1412
- timelineKeys = timelines.keysOf({ runtime, gate, id, element, live: routes });
1550
+ timelineKeys = timelines.keysOf({ runtime, gate, id, subject, live: routes });
1413
1551
  return timelineKeys;
1414
1552
  };
1415
1553
  // The keys a Retarget drove, each with its last target value (its shape), and the
1416
1554
  // ones returning to their Base value until that return settles (ADR-0022). Both are
1417
1555
  // the spine's: a Retarget mid-return carries them again, so a return is never
1418
1556
  // frozen half-way, and a key that settled has left them, so a Retarget of the same
1419
- // target (a `when` gate reopening, ADR-0007) leaves it be. On a drag element, the keys
1557
+ // target (a `when` gate reopening, ADR-0007) leaves it be. On a drag Subject, the keys
1420
1558
  // the drag moves leave the return while it runs, so they stay where it dropped them (C9)
1421
- // until an entry sets them again; a projected element's drag moves none, its projection
1559
+ // until an entry sets them again; a projected Subject's drag moves none, its projection
1422
1560
  // target does (ADR-0016), and its own translate returns as any key does (#363).
1423
1561
  const driven = new Map();
1424
1562
  let returning = new Map();
@@ -1430,7 +1568,7 @@ export const makeElementSpine = (options) => {
1430
1568
  return UndefinedOr.match(options.dragAxis, { onUndefined: () => NO_KEYS, onDefined: dragMovesOf });
1431
1569
  };
1432
1570
  // A Retarget's returns have settled (ADR-0022, D4). A key back at its `style` value is
1433
- // handed back to the element's style, so a later style change shows at rest and the
1571
+ // handed back to the Subject's style, so a later style change shows at rest and the
1434
1572
  // next gesture starts from it; any other key rests at its Base value where the gate drew
1435
1573
  // it, and leaves the target. A key a later Retarget took over is left alone. A routed key (#130) stays
1436
1574
  // in the gate, handed to the follower, which writes its value from now on.
@@ -1448,7 +1586,7 @@ export const makeElementSpine = (options) => {
1448
1586
  const handedBack = Arr.filter(toStyle, Predicate.not(routedNow));
1449
1587
  if (Arr.isReadonlyArrayEmpty(handedBack))
1450
1588
  return;
1451
- // The gate writes the user's current value back, as the element's `style` would
1589
+ // The gate writes the user's current value back, as the Subject's `style` would
1452
1590
  // (ADR-0034). A key gone from the user's style by now is cleared, not restored stale.
1453
1591
  const restore = UndefinedOr.map(styleNow, (now) => {
1454
1592
  const style = now();
@@ -1472,7 +1610,7 @@ export const makeElementSpine = (options) => {
1472
1610
  // The keys an Imperative animation took (#433), each with the target the Override stack had for it
1473
1611
  // then: a Retarget leaves each where the animation leaves it while its target is still that one, and
1474
1612
  // takes it back once it isn't, as a newer animation of Motion's value takes it (latest-wins).
1475
- // Every element reads it, nearly none sets it (#460): the shared empty one until the first key taken.
1613
+ // Every Subject reads it, nearly none sets it (#460): the shared empty one until the first key taken.
1476
1614
  let taken = NONE_TAKEN;
1477
1615
  // The legs that gave up a key in this Retarget: what each still draws is worked out at its end.
1478
1616
  const losing = [];
@@ -1513,7 +1651,7 @@ export const makeElementSpine = (options) => {
1513
1651
  leaveChange();
1514
1652
  });
1515
1653
  };
1516
- // The element's waiting Transition ends (#508), made at its first: most elements never have one.
1654
+ // The Subject's waiting Transition ends (#508), made at its first: most Subjects never have one.
1517
1655
  let waiting;
1518
1656
  // A leg with no key left ends. Its fiber ends inline (ADR-0027, *Amendment (#200)*); one its token
1519
1657
  // didn't reach, none of its runs on the loop, is interrupted. A Transition end it is (#508) is
@@ -1594,7 +1732,7 @@ export const makeElementSpine = (options) => {
1594
1732
  giveUp(key, owner);
1595
1733
  };
1596
1734
  // A Path's turn goes back to 0 once no leg draws it (#460, ADR-0065 decision 3): after a Retarget
1597
- // whose legs don't turn, a stop, a cancel. Most elements never turn: a guard.
1735
+ // whose legs don't turn, a stop, a cancel. Most Subjects never turn: a guard.
1598
1736
  const turnBack = () => {
1599
1737
  const turn = snapshot.values[PATH_ROTATION];
1600
1738
  if (Bool.or(Predicate.isUndefined(turn), turn === 0))
@@ -1654,7 +1792,7 @@ export const makeElementSpine = (options) => {
1654
1792
  });
1655
1793
  /**
1656
1794
  * A leg's run into its sink: one dispatcher, each sink built for the leg that needs it, a
1657
- * Retarget's and an Imperative animation's (#433). A blend's machine is built under the element's
1795
+ * Retarget's and an Imperative animation's (#433). A blend's machine is built under the Subject's
1658
1796
  * Key rules when its change holds a Variable value (`variables`, #542).
1659
1797
  */
1660
1798
  const legProgram = (leg, running, variables) => {
@@ -1683,7 +1821,7 @@ export const makeElementSpine = (options) => {
1683
1821
  // rather than replacing it, so the drag's direct-set x/y survive alongside the
1684
1822
  // spring's keys (drag owns x/y, spring owns the rest) and the post-drag
1685
1823
  // handoff continues from the rested position. Only the keys it still draws (#325).
1686
- // In place, as the Follow sink writes (#659): a spread made two records per element per
1824
+ // In place, as the Follow sink writes (#659): a spread made two records per Subject per
1687
1825
  // frame. The Snapshot's records are always its own (`snapshotOf`, `emptySnapshotOf`), and
1688
1826
  // whatever keeps one copies it or reads it at once.
1689
1827
  const value = running.values(frame.value);
@@ -1704,20 +1842,15 @@ export const makeElementSpine = (options) => {
1704
1842
  return undefined;
1705
1843
  }, running));
1706
1844
  }
1707
- // A snap's or a blend's frames: merged into the Snapshot (ADR-0004), as the spring's are. A blend's
1708
- // last two are kept, its keys' velocities read from them (#464): the frame's own values, which a
1709
- // blend makes anew each frame (`values` writes one object for a leg that lost keys).
1845
+ // A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
1846
+ // (#659; #895: a spread made a record per Subject per frame). A blend's last two are kept for its keys'
1847
+ // velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
1710
1848
  const sink = (frame, dt) => {
1711
1849
  const value = running.values(frame.value);
1712
- let before = running.last;
1713
- // Its first frame: from the Snapshot's values.
1714
- if (Predicate.isUndefined(before))
1715
- before = snapshot.values;
1716
- running.before = before;
1850
+ keepFrame(running, frame, snapshot.values);
1717
1851
  // Over the time its step covered (#865), its first's included: its run's dt, in ms.
1718
1852
  running.lastStep = dt * 1000;
1719
- running.last = frame.value;
1720
- snapshot.values = { ...snapshot.values, ...value };
1853
+ Object.assign(snapshot.values, value);
1721
1854
  gate.write(id, value);
1722
1855
  recordFrame(value);
1723
1856
  drew(running, frame.done, snapshot.now());
@@ -1733,7 +1866,7 @@ export const makeElementSpine = (options) => {
1733
1866
  // Per leg (#460): a statement, Effect's calls data-first.
1734
1867
  let built = Effect.suspend(leg.machine);
1735
1868
  if (variables)
1736
- built = InterpolatorRegistry.withKeyRules(built, elementRules);
1869
+ built = InterpolatorRegistry.withKeyRules(built, subjectRules);
1737
1870
  return Effect.flatMap(built, (machine) => Machine.run(machine, sink, running));
1738
1871
  };
1739
1872
  // A leg's end, told its landing: a Retarget's legs' and an Imperative animation's (#433).
@@ -1743,7 +1876,7 @@ export const makeElementSpine = (options) => {
1743
1876
  // Per leg (#460): statements.
1744
1877
  if (Exit.isSuccess(exit)) {
1745
1878
  // A Superseded leg (#200) counts toward nothing, nor tells a name: the next Retarget's legs
1746
- // land. Nothing made for it: a Retarget ends its element's legs inline.
1879
+ // land. Nothing made for it: a Retarget ends its Subject's legs inline.
1747
1880
  const end = exit.value;
1748
1881
  if (Supersede.isSuperseded(end))
1749
1882
  return Effect.void;
@@ -1764,7 +1897,7 @@ export const makeElementSpine = (options) => {
1764
1897
  })));
1765
1898
  };
1766
1899
  // A gated Retarget (ADR-0007 `when`, #325): a running key it resolves to its leg's target runs on,
1767
- // the element reported unsettled meanwhile, when an earlier change started that leg; every other
1900
+ // the Subject reported unsettled meanwhile, when an earlier change started that leg; every other
1768
1901
  // running key freezes where it is. The change the gate holds may have started legs just before
1769
1902
  // it shut (a child Retargets before its provider's effect resets its `beforeChildren` wait; an
1770
1903
  // `afterChildren` provider starts before its children report): those freeze too, as before.
@@ -1852,7 +1985,7 @@ export const makeElementSpine = (options) => {
1852
1985
  keepTheRest,
1853
1986
  reducedMotion: options.reducedMotion,
1854
1987
  skipAnimations,
1855
- element,
1988
+ subject,
1856
1989
  positionalKeys,
1857
1990
  defaultTransition,
1858
1991
  unitScale,
@@ -1868,16 +2001,16 @@ export const makeElementSpine = (options) => {
1868
2001
  id,
1869
2002
  recordFrame,
1870
2003
  runtime,
1871
- elementRules,
2004
+ subjectRules,
1872
2005
  measuredPairs,
1873
2006
  variableValues,
1874
2007
  };
1875
2008
  }
1876
2009
  return handedOver;
1877
2010
  };
1878
- // --- A Batch member's element (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
1879
- // Its hold on what it takes from its Batch: made as its element is first found a member's, at a
1880
- // Retarget or a drag. Nearly no element is one: the rest pay a WeakMap read a Retarget.
2011
+ // --- A Batch member's Subject (#665's PR 4, ADR-0069 decision 17, Q52–Q54) -----------------------
2012
+ // Its hold on what it takes from its Batch: made as its Subject is first found a member's, at a
2013
+ // Retarget or a drag. Nearly no Subject is one: the rest pay a WeakMap read a Retarget.
1881
2014
  let memberHold;
1882
2015
  const holdNow = () => {
1883
2016
  if (Predicate.isNotUndefined(memberHold))
@@ -1886,21 +2019,21 @@ export const makeElementSpine = (options) => {
1886
2019
  const holds = memberHoldsNow();
1887
2020
  if (Predicate.isUndefined(holds))
1888
2021
  return undefined;
1889
- if (!holds.isMember(element))
2022
+ if (!holds.isMember(subject))
1890
2023
  return undefined;
1891
2024
  memberHold = holds.make(host());
1892
2025
  return memberHold;
1893
2026
  };
1894
- // A draggable element's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
2027
+ // A draggable Subject's drag tells it as it holds `x`/`y` and hands them back: a member's hold hears.
1895
2028
  if (Predicate.isNotUndefined(options.dragAxis)) {
1896
- DRAG_HOOKS.set(element, (on) => {
2029
+ DRAG_HOOKS.set(subject, (on) => {
1897
2030
  const member = holdNow();
1898
2031
  if (Predicate.isNotUndefined(member))
1899
2032
  member.drag(on);
1900
2033
  });
1901
2034
  }
1902
2035
  const retarget = (given) => {
1903
- // A Controls change (#433): the element is in it from the Retarget it makes it run, held or not.
2036
+ // A Controls change (#433): the Subject is in it from the Retarget it makes it run, held or not.
1904
2037
  if (given.change !== joined)
1905
2038
  joinChange(given.change);
1906
2039
  // A key an entry sets isn't its Live value's from this Retarget on, held or not: its Timeline value
@@ -1908,7 +2041,7 @@ export const makeElementSpine = (options) => {
1908
2041
  if (Predicate.isNotUndefined(timelineKeys))
1909
2042
  takeEach(timelineKeys, given.resolved);
1910
2043
  // `when` start-gate (ADR-0007): when canStart() is false, the keys whose target changed freeze
1911
- // where they are (#325: the rest run on), and the element waits; the binding retargets once
2044
+ // where they are (#325: the rest run on), and the Subject waits; the binding retargets once
1912
2045
  // the gate flips true.
1913
2046
  if (Predicate.isNotUndefined(canStart) && !canStart()) {
1914
2047
  hold(given);
@@ -1966,7 +2099,7 @@ export const makeElementSpine = (options) => {
1966
2099
  Arr.forEach(dragMoves(), (key) => keys.taken(key));
1967
2100
  }
1968
2101
  returning = new Map();
1969
- // Over the Map itself: copying it into an array first costs ~20 times the walk, per element
2102
+ // Over the Map itself: copying it into an array first costs ~20 times the walk, per Subject
1970
2103
  // per Retarget (#69's PR 4). Deleting the entry being visited is safe in a Map's iteration.
1971
2104
  Iter.forEach(driven, ([key, like]) => {
1972
2105
  // A translate key the strip below holds back returns once the drag lets go.
@@ -1995,13 +2128,13 @@ export const makeElementSpine = (options) => {
1995
2128
  Iter.forEach(taken, ([key]) => {
1996
2129
  delete t[key];
1997
2130
  });
1998
- // A Batch member's element (#665's PR 4, Q53): a group it moves is taken from its Batch first, and a
2131
+ // A Batch member's Subject (#665's PR 4, Q53): a group it moves is taken from its Batch first, and a
1999
2132
  // key it'd leave where the Batch draws it stays the Batch's. A drag takes `x` and `y`.
2000
2133
  const member = holdNow();
2001
2134
  if (Predicate.isNotUndefined(member))
2002
2135
  member.retarget(t, held);
2003
2136
  // The keys this Retarget returns; once it lands, a key back at its `style` value is
2004
- // handed back to the element's style (D4) and the rest rest where the gate drew them.
2137
+ // handed back to the Subject's style (D4) and the rest rest where the gate drew them.
2005
2138
  const returns = [...returning];
2006
2139
  // The transition, read at Retarget time so a change applies to the next Retarget. A child
2007
2140
  // with no local transition inherits the parent context's (ADR-0007).
@@ -2024,7 +2157,7 @@ export const makeElementSpine = (options) => {
2024
2157
  return;
2025
2158
  settleReturns(returns);
2026
2159
  // The Retarget settled with its last leg (#257): told once the gate has flushed its last frame,
2027
- // so the element shows where it landed. Its Controls change hears it then too (#433).
2160
+ // so the Subject shows where it landed. Its Controls change hears it then too (#433).
2028
2161
  if (Predicate.isNotUndefined(animation))
2029
2162
  gate.afterFlush(() => animation.settled(resolution, previous, c));
2030
2163
  leaveAfterFlush();
@@ -2053,7 +2186,7 @@ export const makeElementSpine = (options) => {
2053
2186
  return tellFailed(error);
2054
2187
  failedEarly = { error };
2055
2188
  };
2056
- // The element settles with its last leg (ADR-0024, D5): a string leg can outlast the
2189
+ // The Subject settles with its last leg (ADR-0024, D5): a string leg can outlast the
2057
2190
  // numeric one, so each leg's frames report, and only the last leg's settle reports done.
2058
2191
  let reporting = 0;
2059
2192
  let settled = 0;
@@ -2067,9 +2200,9 @@ export const makeElementSpine = (options) => {
2067
2200
  current = landing;
2068
2201
  // The Retarget's transitions, read before its keys: a key already there asks its own for a
2069
2202
  // velocity (#448).
2070
- const elementTransition = VariantTree.ownOrInherited(c.transition, parent);
2203
+ const wardTransition = VariantTree.ownOrInherited(c.transition, parent);
2071
2204
  // The base target's own transition (#277): the keys its entry drives animate on it.
2072
- const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, elementTransition);
2205
+ const baseTransition = VariantTarget.transitionOfTarget(resolution.transition, wardTransition);
2073
2206
  // Fold the per-child stagger delay (ADR-0007) into the effective
2074
2207
  // transition.delay = base.delay + computedDelay. extraDelay() is read
2075
2208
  // at Retarget time so a re-snapshot before this start is reflected. Each name's keys take that
@@ -2078,11 +2211,11 @@ export const makeElementSpine = (options) => {
2078
2211
  const extra = extraOf(extraDelay, layers[0]);
2079
2212
  const transition = staggeredOf(baseTransition, extra, options.reuse);
2080
2213
  // With an entry's own transition (#277, #291), each key animates on its entry's: the base's keys
2081
- // on the base target's, each active gesture's on its target's, else the element's, as Motion's
2214
+ // on the base target's, each active gesture's on its target's, else the Subject's, as Motion's
2082
2215
  // each animation type runs on its own.
2083
2216
  // A list's names (#297) split them too, each name's at its own delay; a list's returns run on the
2084
- // element's transition, in a group of their own, last.
2085
- // Guards, not matches: per Retarget, per element. A list's work (#297) is done apart, for a list:
2217
+ // Subject's transition, in a group of their own, last.
2218
+ // Guards, not matches: per Retarget, per Subject. A list's work (#297) is done apart, for a list:
2086
2219
  // the Retarget's other calls keep their inlining (docs/agents/effect-first.md).
2087
2220
  const listed = Arr.isArray(resolution.variant);
2088
2221
  // A list's names each wait for their own `when` (#297's PR 2): the entries whose gate is shut now.
@@ -2100,7 +2233,7 @@ export const makeElementSpine = (options) => {
2100
2233
  // target (no motion).
2101
2234
  //
2102
2235
  // Every key's Own value is read first, at its first need, before anything writes it, so a return
2103
- // later finds the element's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
2236
+ // later finds the Subject's value, not Wardic's (ADR-0022, D3). The read is kept: a later need is
2104
2237
  // a lookup. A transform key reads nothing.
2105
2238
  let stays;
2106
2239
  let carried;
@@ -2165,7 +2298,7 @@ export const makeElementSpine = (options) => {
2165
2298
  // Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
2166
2299
  // mount's never asks (#475): Motion animates nothing at a first render that starts at its
2167
2300
  // `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
2168
- if (still && Predicate.isUndefined(stops) && (quiet || !givesVelocity(keyTransitionOf(resolution, groups, key, transition, elementTransition), key))) {
2301
+ if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, wardTransition), key))) {
2169
2302
  if (Predicate.isUndefined(stays))
2170
2303
  stays = new Set();
2171
2304
  stays.add(key);
@@ -2189,6 +2322,21 @@ export const makeElementSpine = (options) => {
2189
2322
  resolvedNow = t;
2190
2323
  owners.forEach(giveUpUnresolved);
2191
2324
  keepTheRest();
2325
+ // A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
2326
+ // the resolved target doesn't name joins the keys already there, written with them as the Subject's first
2327
+ // commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
2328
+ // any. A Batch member's are its Batch's, which draws its groups.
2329
+ if (Predicate.isUndefined(lastResolution)) {
2330
+ if (Predicate.isUndefined(member)) {
2331
+ Arr.forEach(Rec.keys(initialValues), (key) => {
2332
+ if (Object.hasOwn(resolved, key))
2333
+ return;
2334
+ if (Predicate.isUndefined(there))
2335
+ there = {};
2336
+ there[key] = UndefinedOr.getOrThrow(snapshot.values[key]);
2337
+ });
2338
+ }
2339
+ }
2192
2340
  // The keys this Retarget starts legs for: all of them, unless some stay.
2193
2341
  let fresh = t;
2194
2342
  if (Predicate.isNotUndefined(stays)) {
@@ -2256,7 +2404,7 @@ export const makeElementSpine = (options) => {
2256
2404
  // The legs (#48, ADR-0044 decision 8): one pure builder, which a server render's Appear
2257
2405
  // animation samples too, so the two can't drift. Built here; each leg's machine is built
2258
2406
  // in its own fiber, so a transition core rejects (#66, ADR-0025 *Amendment (#66)*) fails
2259
- // that leg alone, reported as any leg's failure is, while the element's other legs run on.
2407
+ // that leg alone, reported as any leg's failure is, while the Subject's other legs run on.
2260
2408
  // The returns to a moving Live value (#130, ADR-0043 decision 6): a number's follows it,
2261
2409
  // in a leg of its own, and lands on it; the rest return to where it is now. Looked for
2262
2410
  // only when this Retarget returns a key.
@@ -2271,7 +2419,7 @@ export const makeElementSpine = (options) => {
2271
2419
  // animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
2272
2420
  let measured;
2273
2421
  if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
2274
- measured = measuredOf(measuredPairs, element, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops);
2422
+ measured = measuredOf(measuredPairs, subject, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id);
2275
2423
  }
2276
2424
  let told;
2277
2425
  if (!silent)
@@ -2286,17 +2434,21 @@ export const makeElementSpine = (options) => {
2286
2434
  retargetLegs = RetargetLegs.legsOf(from, fresh, transition, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale);
2287
2435
  }
2288
2436
  if (Predicate.isNotUndefined(groups)) {
2289
- const split = splitLegsOf(fresh, from, groups, resolution, listed, transition, elementTransition, extraDelay, options.reuse, reduce, skipped, positionalKeys, defaultTransition, readVelocity, follow, manyStops, measured, snapshot.values, rests, unitScale);
2437
+ 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);
2290
2438
  retargetLegs = split.legs;
2291
2439
  legGroups = split.tags;
2292
2440
  }
2293
2441
  // The Handoff (#48, ADR-0044 decision 6): the first Retarget that starts picks the Appear
2294
- // animation up as far in as it has got, read at the legs' first tick.
2442
+ // animation up as far in as it has got, read at the legs' first tick. Its legs keep the frame
2443
+ // timeline's time, where the Appear animation's `currentTime` is (#1026).
2444
+ let takenOver = false;
2295
2445
  if (Predicate.isNotUndefined(handoff)) {
2446
+ takenOver = true;
2296
2447
  const taken = handoff;
2297
2448
  handoff = undefined;
2298
2449
  if (Predicate.isNotUndefined(diagnostics)) {
2299
- diagnostics.checkHandoff(runtime, id, taken, { tag, from, to: fresh, transition: baseTransition, reduced: reduce, layout: isLayoutNode(c), stops: manyStops, ...AppearHandoff.skippedField(skipped), ...templateField(c.transformTemplate) });
2450
+ // With the keys it leaves where they are (#1004), which the server's rule holds beside the moving ones.
2451
+ diagnostics.checkHandoff(runtime, id, taken, { tag, from, to: fresh, transition: baseTransition, reduced: reduce, layout: isLayoutNode(c), stops: manyStops, ...AppearHandoff.skippedField(skipped), ...templateField(c.transformTemplate), held: there });
2300
2452
  }
2301
2453
  const at = AppearHandoff.startAtOf(taken, baseTransition, delayOf(transition));
2302
2454
  retargetLegs = Arr.map(retargetLegs, (one) => RetargetLegs.startingAt(one, at));
@@ -2334,14 +2486,14 @@ export const makeElementSpine = (options) => {
2334
2486
  }
2335
2487
  // Its Live routes hear the legs it starts (#443, PR4-Q1).
2336
2488
  tellStarted(live, retargetLegs);
2337
- // The element's Key rules only for a change a Variable value is in (#542).
2489
+ // The Subject's Key rules only for a change a Variable value is in (#542).
2338
2490
  const variables = holdsVariable(variableValues, from, fresh, manyStops);
2339
- // Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per element). Each
2491
+ // Each leg into its sink, in the builder's order (#69's PR 2: a Retarget is per Subject). Each
2340
2492
  // leg draws the keys it animates (#325) until a later Retarget takes them.
2341
2493
  Arr.forEach(retargetLegs, (leg, i) => {
2342
2494
  if (Predicate.isNotUndefined(legGates))
2343
2495
  gateNow = legGates[i];
2344
- const running = runningOf(leg.to, resolution, landing, leg._tag);
2496
+ const running = runningOf(leg.to, resolution, landing, leg._tag, takenOver);
2345
2497
  own(running);
2346
2498
  runLeg(running, legProgram(leg, running, variables));
2347
2499
  });
@@ -2404,7 +2556,7 @@ export const makeElementSpine = (options) => {
2404
2556
  // A turn none of its legs draws now goes back (#460).
2405
2557
  turnBack();
2406
2558
  // The keys already there (#448), written with each key the Retarget moves at where it starts, as
2407
- // its leg's first frame writes it: the element's first commit, which takes its Starting style off,
2559
+ // its leg's first frame writes it: the Subject's first commit, which takes its Starting style off,
2408
2560
  // holds every key, whatever frame the legs first draw in (a gated name's draws later).
2409
2561
  if (Predicate.isNotUndefined(there)) {
2410
2562
  const written = { ...from, ...there };
@@ -2412,7 +2564,7 @@ export const makeElementSpine = (options) => {
2412
2564
  recordFrame(written);
2413
2565
  }
2414
2566
  // The Retarget started, its legs on their way (#257); with none, its own or carried, it landed
2415
- // at once (#325): its returns settle, and the element reports settled at the gate's next flush,
2567
+ // at once (#325): its returns settle, and the Subject reports settled at the gate's next flush,
2416
2568
  // after the effects that start its orchestration's wait (ADR-0007).
2417
2569
  previous = lastResolution;
2418
2570
  lastResolution = resolution;
@@ -2446,7 +2598,7 @@ export const makeElementSpine = (options) => {
2446
2598
  };
2447
2599
  // --- Live values in `style` (#130, ADR-0043) ------------------------------
2448
2600
  // A routed key (a Live value, or a transform key) is its `style` link, live: while no entry of
2449
- // the Override stack sets it, no return is running to it and no drag moves it, the element
2601
+ // the Override stack sets it, no return is running to it and no drag moves it, the Subject
2450
2602
  // follows it, written through the gate on every change. A return hands it back here when it
2451
2603
  // settles (`settleReturns`). The Starting style showed each one's value at render; from mount
2452
2604
  // the gate holds them.
@@ -2454,7 +2606,7 @@ export const makeElementSpine = (options) => {
2454
2606
  if (Predicate.isUndefined(live))
2455
2607
  return;
2456
2608
  const routes = live;
2457
- // Built at the first routed key, at mount or later: an element whose `style` routes none builds nothing.
2609
+ // Built at the first routed key, at mount or later: a Subject whose `style` routes none builds nothing.
2458
2610
  routes.whenRouted(() => {
2459
2611
  // Read at each ask: `projected` is a getter while the track waits for `drag` (#551, #582).
2460
2612
  const dragHolds = () => Bool.and(Bool.not(options.projected), Predicate.isNotUndefined(options.dragAxis));
@@ -2476,7 +2628,7 @@ export const makeElementSpine = (options) => {
2476
2628
  gate.write(id, values);
2477
2629
  recordFrame(values);
2478
2630
  };
2479
- // The element shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
2631
+ // The Subject shows `key`'s Live value now: its Timeline value runs, when it has one (#240).
2480
2632
  const shown = (key) => {
2481
2633
  const keys = timelineKeysNow(routes);
2482
2634
  if (Predicate.isNotUndefined(keys))
@@ -2514,7 +2666,7 @@ export const makeElementSpine = (options) => {
2514
2666
  delete snapshot.velocities[key];
2515
2667
  if (Predicate.isNotUndefined(presence))
2516
2668
  delete presence.snapshot.current[key];
2517
- // Gone from `style`: the element's own value comes back, or none, its Environment's default now.
2669
+ // Gone from `style`: the Subject's own value comes back, or none, its Environment's default now.
2518
2670
  const restore = Option.match(ownValues.styleValueOf(UndefinedOr.match(styleNow, { onUndefined: constUndefined, onDefined: (style) => style() }), key), {
2519
2671
  onNone: () => "",
2520
2672
  onSome: String,
@@ -2548,8 +2700,8 @@ export const makeElementSpine = (options) => {
2548
2700
  memberHold.dispose();
2549
2701
  };
2550
2702
  // A child back under its key (#286): its values and velocities from where the leaver is drawn, a
2551
- // projected element's own translate among them (#363). Drawn at the end of the task, so nothing
2552
- // paints the element at its `initial` first: not in the mount effect it's called in, where the
2703
+ // projected Subject's own translate among them (#363). Drawn at the end of the task, so nothing
2704
+ // draws the Subject at its `initial` first: not in the mount effect it's called in, where the
2553
2705
  // first commit's Starting-style switch would flush Solid 2 inside an effect.
2554
2706
  const seed = (from) => {
2555
2707
  const values = from.values;
@@ -2586,7 +2738,7 @@ export const makeElementSpine = (options) => {
2586
2738
  * one at mount; `sink` as it is otherwise. `config` reads it untracked.
2587
2739
  */
2588
2740
  export const withOnUpdate = (sink, atMount, config) => {
2589
- // Per element at mount: most have none, and pay a check.
2741
+ // Per Subject at mount: most have none, and pay a check.
2590
2742
  if (Predicate.isUndefined(atMount))
2591
2743
  return sink;
2592
2744
  return {
@@ -2600,8 +2752,8 @@ export const withOnUpdate = (sink, atMount, config) => {
2600
2752
  };
2601
2753
  /**
2602
2754
  * A Retarget's note of the keys it started from their Base value, or returned to it (ADR-0022): run at
2603
- * the head of its first leg, cold path (no fiber of its own: forking one per element cost 10-20 µs each
2604
- * at a 1000-element mount).
2755
+ * the head of its first leg, cold path (no fiber of its own: forking one per Subject cost 10-20 µs each
2756
+ * at a 1000-Subject mount).
2605
2757
  */
2606
2758
  export const baseLog = (id, started, returns) => Effect.logDebug("wardic.base: a key with no value started from, or returned to, its Base value (ADR-0022)").pipe(Effect.annotateLogs({ id, started, returned: Object.fromEntries(returns) }));
2607
2759
  /** The keys a Retarget returns to a Live value that's a number: each one's return follows it (#130). */
@@ -2616,9 +2768,9 @@ const liveTargetOf = (ownValues, routes, key, start) => {
2616
2768
  return last;
2617
2769
  };
2618
2770
  };
2619
- /** Whether a value is one an element can take: a number or a string. */
2771
+ /** Whether a value is one a Subject can take: a number or a string. */
2620
2772
  const isValue = (value) => Bool.or(Predicate.isNumber(value), Predicate.isString(value));
2621
- /** A provider runtime's `AtomRegistry`, read on first need: an element with no Atom never reads it. */
2773
+ /** A provider runtime's `AtomRegistry`, read on first need: a Subject with no Atom never reads it. */
2622
2774
  export const registryOf = (runtime) => {
2623
2775
  let registry;
2624
2776
  return () => {
@@ -2627,7 +2779,7 @@ export const registryOf = (runtime) => {
2627
2779
  return registry;
2628
2780
  };
2629
2781
  };
2630
- /** Whether a config makes its element a layout node: `layout` (or a mode), or a `layoutId`. */
2782
+ /** Whether a config makes its Subject a layout node: `layout` (or a mode), or a `layoutId`. */
2631
2783
  export const isLayoutNode = (c) => Bool.or(Bool.and(Predicate.isNotUndefined(c.layout), c.layout !== false), Predicate.isNotUndefined(c.layoutId));
2632
2784
  /** A mount animation's template field (#443): left out with none, as its key reads it. */
2633
2785
  export const templateField = (template) => UndefinedOr.match(template, { onUndefined: () => ({}), onDefined: (t) => ({ template: t }) });