@wardic/core 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) 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 +15 -5
  8. package/dist/Batch.d.ts.map +1 -1
  9. package/dist/Batch.js +218 -20
  10. package/dist/Batch.js.map +1 -1
  11. package/dist/Clock.d.ts +7 -7
  12. package/dist/Clock.d.ts.map +1 -1
  13. package/dist/Clock.js +17 -16
  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 +5 -4
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +37 -14
  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 +1 -1
  34. package/dist/InputFeed.js +2 -2
  35. package/dist/InputSource.d.ts +3 -3
  36. package/dist/InputSource.js +2 -2
  37. package/dist/Interpolator.d.ts +2 -2
  38. package/dist/Interpolator.js +2 -2
  39. package/dist/InterpolatorRegistry.d.ts +29 -15
  40. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  41. package/dist/InterpolatorRegistry.js +17 -8
  42. package/dist/InterpolatorRegistry.js.map +1 -1
  43. package/dist/LiveValue.d.ts +7 -6
  44. package/dist/LiveValue.d.ts.map +1 -1
  45. package/dist/LiveValue.js +45 -14
  46. package/dist/LiveValue.js.map +1 -1
  47. package/dist/Machine.d.ts +7 -4
  48. package/dist/Machine.d.ts.map +1 -1
  49. package/dist/Machine.js +146 -45
  50. package/dist/Machine.js.map +1 -1
  51. package/dist/Playback.d.ts.map +1 -1
  52. package/dist/Playback.js +6 -1
  53. package/dist/Playback.js.map +1 -1
  54. package/dist/Projection.d.ts +9 -9
  55. package/dist/Projection.js +2 -2
  56. package/dist/Recognizer.d.ts +1 -1
  57. package/dist/Recognizer.js +6 -6
  58. package/dist/Recognizer.js.map +1 -1
  59. package/dist/ReducedMotion.d.ts +4 -4
  60. package/dist/ReducedMotion.js +6 -6
  61. package/dist/Renderer.d.ts +5 -5
  62. package/dist/Renderer.js +6 -6
  63. package/dist/Renderer.js.map +1 -1
  64. package/dist/Reorder.d.ts +1 -1
  65. package/dist/Reorder.d.ts.map +1 -1
  66. package/dist/Reorder.js +2 -1
  67. package/dist/Reorder.js.map +1 -1
  68. package/dist/ScrollSource.d.ts +1 -1
  69. package/dist/ScrollSource.d.ts.map +1 -1
  70. package/dist/Sequence.d.ts +1 -1
  71. package/dist/SharedSource.d.ts +3 -3
  72. package/dist/SharedSource.js +5 -5
  73. package/dist/SharedSource.js.map +1 -1
  74. package/dist/Spring.d.ts.map +1 -1
  75. package/dist/Spring.js +2 -1
  76. package/dist/Spring.js.map +1 -1
  77. package/dist/Values.d.ts +2 -2
  78. package/dist/Values.js +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/internal/carried.d.ts +13 -0
  82. package/dist/internal/carried.d.ts.map +1 -0
  83. package/dist/internal/carried.js +23 -0
  84. package/dist/internal/carried.js.map +1 -0
  85. package/dist/internal/firstSteps.d.ts +66 -0
  86. package/dist/internal/firstSteps.d.ts.map +1 -0
  87. package/dist/internal/firstSteps.js +107 -0
  88. package/dist/internal/firstSteps.js.map +1 -0
  89. package/dist/internal/frameLoop.d.ts +1 -1
  90. package/dist/internal/frameLoop.d.ts.map +1 -1
  91. package/dist/internal/frameLoop.js +102 -81
  92. package/dist/internal/frameLoop.js.map +1 -1
  93. package/dist/internal/lerpsNumbers.d.ts +11 -0
  94. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  95. package/dist/internal/lerpsNumbers.js +38 -0
  96. package/dist/internal/lerpsNumbers.js.map +1 -0
  97. package/dist/internal/options.d.ts +7 -7
  98. package/dist/internal/options.d.ts.map +1 -1
  99. package/dist/internal/options.js +10 -10
  100. package/dist/internal/options.js.map +1 -1
  101. package/dist/internal/stepper.d.ts +13 -2
  102. package/dist/internal/stepper.d.ts.map +1 -1
  103. package/dist/internal/stepper.js +16 -1
  104. package/dist/internal/stepper.js.map +1 -1
  105. package/dist/internal/tracing.d.ts +1 -1
  106. package/dist/internal/tracing.js +1 -1
  107. package/dist/unstable/AnimationControls.d.ts +37 -38
  108. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  109. package/dist/unstable/AnimationControls.js +39 -36
  110. package/dist/unstable/AnimationControls.js.map +1 -1
  111. package/dist/unstable/AppearHandoff.d.ts +5 -5
  112. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  113. package/dist/unstable/BatchCalls.d.ts +2 -2
  114. package/dist/unstable/BatchCalls.js +5 -5
  115. package/dist/unstable/Config.d.ts +19 -19
  116. package/dist/unstable/Config.d.ts.map +1 -1
  117. package/dist/unstable/FirstSteps.d.ts +25 -0
  118. package/dist/unstable/FirstSteps.d.ts.map +1 -0
  119. package/dist/unstable/FirstSteps.js +2 -0
  120. package/dist/unstable/FirstSteps.js.map +1 -0
  121. package/dist/unstable/FlushGate.d.ts +53 -51
  122. package/dist/unstable/FlushGate.d.ts.map +1 -1
  123. package/dist/unstable/FlushGate.js +56 -49
  124. package/dist/unstable/FlushGate.js.map +1 -1
  125. package/dist/unstable/FrameEffects.d.ts +2 -2
  126. package/dist/unstable/FrameEffects.js +2 -2
  127. package/dist/unstable/FrameTime.d.ts +1 -1
  128. package/dist/unstable/FrameTime.js +1 -1
  129. package/dist/unstable/Imperative.d.ts +29 -9
  130. package/dist/unstable/Imperative.d.ts.map +1 -1
  131. package/dist/unstable/Imperative.js +79 -47
  132. package/dist/unstable/Imperative.js.map +1 -1
  133. package/dist/unstable/OwnValues.js +1 -1
  134. package/dist/unstable/PresenceRecord.d.ts +26 -26
  135. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  136. package/dist/unstable/PresenceRecord.js +8 -8
  137. package/dist/unstable/PresenceRecord.js.map +1 -1
  138. package/dist/unstable/Projector.d.ts +34 -0
  139. package/dist/unstable/Projector.d.ts.map +1 -0
  140. package/dist/unstable/Projector.js +9 -0
  141. package/dist/unstable/Projector.js.map +1 -0
  142. package/dist/unstable/Report.d.ts +1 -1
  143. package/dist/unstable/Report.js +1 -1
  144. package/dist/unstable/RetargetLegs.d.ts +1 -1
  145. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  146. package/dist/unstable/RetargetLegs.js +9 -8
  147. package/dist/unstable/RetargetLegs.js.map +1 -1
  148. package/dist/unstable/Spine.d.ts +81 -72
  149. package/dist/unstable/Spine.d.ts.map +1 -1
  150. package/dist/unstable/Spine.js +152 -150
  151. package/dist/unstable/Spine.js.map +1 -1
  152. package/dist/unstable/Stops.d.ts +3 -3
  153. package/dist/unstable/Stops.js +4 -4
  154. package/dist/unstable/Subject.d.ts +2 -2
  155. package/dist/unstable/Subject.js +2 -2
  156. package/dist/unstable/Timelines.d.ts +11 -11
  157. package/dist/unstable/Timelines.d.ts.map +1 -1
  158. package/dist/unstable/Timelines.js +3 -3
  159. package/dist/unstable/VariantTarget.d.ts +7 -7
  160. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  161. package/dist/unstable/VariantTarget.js +11 -11
  162. package/dist/unstable/VariantTarget.js.map +1 -1
  163. package/dist/unstable/VariantTree.d.ts +36 -36
  164. package/dist/unstable/VariantTree.d.ts.map +1 -1
  165. package/dist/unstable/VariantTree.js +33 -33
  166. package/dist/unstable/VariantTree.js.map +1 -1
  167. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  168. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  169. package/dist/unstable/WardicConfigValue.js +4 -4
  170. package/dist/unstable/WardicConfigValue.js.map +1 -1
  171. package/package.json +1 -1
  172. package/src/Arc.ts +3 -3
  173. package/src/BaseValue.ts +18 -21
  174. package/src/Batch.ts +236 -22
  175. package/src/Clock.ts +18 -17
  176. package/src/DefaultTransition.ts +5 -3
  177. package/src/Drag.ts +32 -14
  178. package/src/DragActivity.ts +3 -3
  179. package/src/DragRecognizer.ts +41 -16
  180. package/src/Easing.ts +1 -1
  181. package/src/Frame.ts +5 -3
  182. package/src/InputFeed.ts +2 -2
  183. package/src/InputSource.ts +5 -5
  184. package/src/Interpolator.ts +3 -3
  185. package/src/InterpolatorRegistry.ts +22 -13
  186. package/src/LiveValue.ts +47 -17
  187. package/src/Machine.ts +199 -61
  188. package/src/Playback.ts +5 -1
  189. package/src/Projection.ts +9 -9
  190. package/src/Recognizer.ts +7 -7
  191. package/src/ReducedMotion.ts +6 -6
  192. package/src/Renderer.ts +6 -6
  193. package/src/Reorder.ts +3 -2
  194. package/src/ScrollSource.ts +1 -1
  195. package/src/Sequence.ts +1 -1
  196. package/src/SharedSource.ts +5 -5
  197. package/src/Spring.ts +2 -1
  198. package/src/Values.ts +2 -2
  199. package/src/index.ts +1 -1
  200. package/src/internal/carried.ts +22 -0
  201. package/src/internal/firstSteps.ts +139 -0
  202. package/src/internal/frameLoop.ts +103 -87
  203. package/src/internal/lerpsNumbers.ts +53 -0
  204. package/src/internal/options.ts +10 -10
  205. package/src/internal/stepper.ts +20 -2
  206. package/src/internal/tracing.ts +1 -1
  207. package/src/unstable/AnimationControls.ts +59 -56
  208. package/src/unstable/AppearHandoff.ts +6 -6
  209. package/src/unstable/BatchCalls.ts +5 -5
  210. package/src/unstable/Config.ts +19 -19
  211. package/src/unstable/FirstSteps.ts +26 -0
  212. package/src/unstable/FlushGate.ts +92 -82
  213. package/src/unstable/FrameEffects.ts +2 -2
  214. package/src/unstable/FrameTime.ts +1 -1
  215. package/src/unstable/Imperative.ts +126 -56
  216. package/src/unstable/OwnValues.ts +1 -1
  217. package/src/unstable/PresenceRecord.ts +29 -29
  218. package/src/unstable/Projector.ts +45 -0
  219. package/src/unstable/Report.ts +1 -1
  220. package/src/unstable/RetargetLegs.ts +10 -9
  221. package/src/unstable/Spine.ts +190 -188
  222. package/src/unstable/Stops.ts +6 -6
  223. package/src/unstable/Subject.ts +2 -2
  224. package/src/unstable/Timelines.ts +12 -12
  225. package/src/unstable/VariantTarget.ts +13 -13
  226. package/src/unstable/VariantTree.ts +42 -42
  227. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Drag activity: how many drags are active, and which element holds each axis. While a
2
+ * Drag activity: how many drags are active, and which Subject holds each axis. While a
3
3
  * drag is active no hover and no press starts, as Motion's; and a drag that claims an axis another
4
- * element holds is refused, so a nested drag on the same axis doesn't move both. A drag counts in once
4
+ * Subject holds is refused, so a nested drag on the same axis doesn't move both. A drag counts in once
5
5
  * it's past its threshold, and counts off at its end or when it's interrupted. `DragRecognizer`'s drags
6
6
  * keep it; a recognizer of your own reads it, or counts in and claims as a drag does.
7
7
  *
@@ -12,7 +12,7 @@
12
12
  * import * as DragActivity from "@wardic/core/DragActivity"
13
13
  *
14
14
  * const activity = yield* DragActivity.DragActivity
15
- * const release = activity.claim(card, "x") // None when another element holds x
15
+ * const release = activity.claim(card, "x") // None when another Subject holds x
16
16
  * activity.isDragActive() // true until it's released
17
17
  */
18
18
  // ADR-0019, decision 3b (Drag activity), and *Amendment (#29)* (Drag claims): Motion's `isDragging`
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The pointer's drags and pans. `drag` is a Stream of `Drag.Sample`s as a pointer drags `target`, kept
3
- * to its axis, and refused when another element holds that axis; `pan` gives the same samples with a
3
+ * to its axis, and refused when another Subject holds that axis; `pan` gives the same samples with a
4
4
  * session's start at each down, moves nothing, and stops no drag. `watchDrag` and `watchPan` call you
5
5
  * with each sample inside its pointer event's dispatch while a Scope is open, with no fiber of their own:
6
6
  * a binding's drags run on these. They're apart from `Recognizer`'s gestures, so an app that never drags
@@ -114,6 +114,13 @@ type StaleRule = "unpressed move" | "second down"
114
114
  // Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
115
115
  const staleEnds = /*#__PURE__*/ new WeakMap<Drag.Sample, StaleRule>()
116
116
 
117
+ /**
118
+ * The cancels folded in place of a release whose point its mapping couldn't give ({@link standInFor}):
119
+ * a release all the same, which {@link onRelease} ends as one, with its moves' velocity.
120
+ */
121
+ // Module state (#1042): a mark held weakly by the event it's on, so it goes with it.
122
+ const unmappedReleases = /*#__PURE__*/ new WeakSet<InputSource.PointerLikeEvent>()
123
+
117
124
  /** No samples: the event changes nothing a consumer sees. */
118
125
  const NO_SAMPLES: ReadonlyArray<Drag.Sample> = []
119
126
 
@@ -136,6 +143,7 @@ const staleEnd = (state: DragState, rule: StaleRule, timeStamp: number, raw: unk
136
143
  scroll: state.lastScroll,
137
144
  raw,
138
145
  axis: "xy",
146
+ endedBy: "lost",
139
147
  }
140
148
  staleEnds.set(sample, rule)
141
149
  return [sample]
@@ -207,19 +215,26 @@ const onRelease = (state: DragState, event: InputSource.PointerLikeEvent): Step
207
215
  onFalse: () => [initState, NO_SAMPLES],
208
216
  onTrue: () => {
209
217
  // A cancel's coordinates aren't the pointer's (Chromium's pointercancel carries
210
- // (0, 0)), so it ends at the last move's point, with the moves' velocity, as
211
- // Motion's pan session does (PanSession.ts:329-333 at 16c6122).
218
+ // (0, 0)), so it ends at the last move's point, as Motion's pan session does
219
+ // (PanSession.ts:329-333 at 16c6122). With no velocity, where Motion's keeps the
220
+ // moves': a gesture the platform took away doesn't fling, as a lost release doesn't
221
+ // (#1042, ADR-0019's *Amendment (#1042)*).
222
+ // A release its mapping couldn't place comes as a cancel too, and ends at the last point all the
223
+ // same, but it was let go: a release, with its moves' velocity (#1000, #1042).
212
224
  const sample: Drag.Sample = Bool.match(event.type === "cancel", {
213
225
  onTrue: () => ({
214
226
  point: state.last,
215
227
  offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
216
228
  delta: { x: 0, y: 0 },
217
- velocity: windowVelocity(state.history),
218
229
  phase: "end",
219
230
  timeStamp: event.timeStamp,
220
231
  scroll: state.lastScroll,
221
232
  raw: event.raw,
222
233
  axis: "xy",
234
+ ...Bool.match(unmappedReleases.has(event), {
235
+ onTrue: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
236
+ onFalse: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: { x: 0, y: 0 }, endedBy: "cancel" }),
237
+ }),
223
238
  }),
224
239
  onFalse: () => {
225
240
  const point = pointOf(event)
@@ -235,6 +250,7 @@ const onRelease = (state: DragState, event: InputSource.PointerLikeEvent): Step
235
250
  scroll: event.scroll,
236
251
  raw: event.raw,
237
252
  axis: "xy",
253
+ endedBy: "release",
238
254
  }
239
255
  },
240
256
  })
@@ -302,8 +318,9 @@ const onMove = (state: DragState, event: InputSource.PointerLikeEvent, starts: S
302
318
  /**
303
319
  * The gesture ended from outside its pointer (#431, Motion's drag controls): an `"end"` at its last
304
320
  * point, with that event's time and platform event, as a cancel's. `stop`'s has the moves' velocity,
305
- * a release; `cancel`'s none, marked `cancelled`. A gesture that hasn't started resets with no sample,
306
- * as a tap does. Either way its pointer's later events are left out, until a down claims again.
321
+ * a release; `cancel`'s none, ended by `"controls"` and marked `cancelled`. A gesture that hasn't
322
+ * started resets with no sample, as a tap does. Either way its pointer's later events are left out,
323
+ * until a down claims again.
307
324
  */
308
325
  const endedFromOutside = (state: DragState, cancelled: boolean): Step =>
309
326
  Bool.match(state.phase === "active", {
@@ -313,14 +330,17 @@ const endedFromOutside = (state: DragState, cancelled: boolean): Step =>
313
330
  point: state.last,
314
331
  offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
315
332
  delta: { x: 0, y: 0 },
316
- velocity: Bool.match(cancelled, { onTrue: () => ({ x: 0, y: 0 }), onFalse: () => windowVelocity(state.history) }),
317
333
  phase: "end",
318
334
  timeStamp: Option.match(Arr.last(state.history), { onNone: () => 0, onSome: (p) => p.timeStamp }),
319
335
  scroll: state.lastScroll,
320
336
  raw: state.lastRaw,
321
337
  axis: "xy",
338
+ ...Bool.match(cancelled, {
339
+ onTrue: (): Pick<Drag.Sample, "velocity" | "endedBy" | "cancelled"> => ({ velocity: { x: 0, y: 0 }, endedBy: "controls", cancelled: true }),
340
+ onFalse: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
341
+ }),
322
342
  }
323
- return [initState, [Bool.match(cancelled, { onTrue: (): Drag.Sample => ({ ...end, cancelled: true }), onFalse: () => end })]]
343
+ return [initState, [end]]
324
344
  },
325
345
  })
326
346
 
@@ -417,7 +437,8 @@ export interface DragOptions {
417
437
  *
418
438
  * A mapping that throws is reported through `onDefect`, once a run of throws, and the gesture goes on
419
439
  * without that point: a move is left out; a release ends the gesture at its last point, with its moves'
420
- * velocity, as a cancel does; a down starts nothing, and ends a gesture its pointer had left open.
440
+ * velocity, a release all the same (`endedBy: "release"`); a down starts nothing, and ends a gesture its
441
+ * pointer had left open.
421
442
  */
422
443
  // #443; an `Option` (#618, A1). #1000 (ADR-0074): the points mapped, and a throw's.
423
444
  readonly mapPoint?: LazyArg<Option.Option<PointMap>> | undefined
@@ -464,14 +485,18 @@ const mappedEvents = (mapPoint: DragOptions["mapPoint"]): ((event: InputSource.P
464
485
 
465
486
  /**
466
487
  * The event folded in place of one whose point its mapping can't give, an event whose point isn't read:
467
- * a release's a cancel, which ends the gesture at its last point with its moves' velocity; a down's an
468
- * unpressed move, a lost release, which ends a gesture of its pointer's still open, at its last point
469
- * with no velocity, and starts none. None for a move, left out.
488
+ * a release's a cancel marked as a release ({@link unmappedReleases}), which ends the gesture at its last
489
+ * point with its moves' velocity; a down's an unpressed move, a lost release, which ends a gesture of its
490
+ * pointer's still open, at its last point with no velocity, and starts none. None for a move, left out.
470
491
  */
471
492
  // #1000 (ADR-0074): a release left out kept its gesture going, active and claimed, until the next press;
472
493
  // a down left out kept one a lost release had left open, for good while the mapping threw at each down.
473
494
  const standInFor: (event: InputSource.PointerLikeEvent) => Option.Option<InputSource.PointerLikeEvent> = /*#__PURE__*/ Match.type<InputSource.PointerLikeEvent>().pipe(
474
- Match.when({ type: "up" }, (up) => Option.some<InputSource.PointerLikeEvent>({ ...up, type: "cancel" })),
495
+ Match.when({ type: "up" }, (up) => {
496
+ const standIn: InputSource.PointerLikeEvent = { ...up, type: "cancel" }
497
+ unmappedReleases.add(standIn)
498
+ return Option.some(standIn)
499
+ }),
475
500
  Match.when({ type: "down" }, (down) => Option.some<InputSource.PointerLikeEvent>({ ...down, type: "move", pressed: false })),
476
501
  Match.orElse(() => Option.none()),
477
502
  )
@@ -523,7 +548,7 @@ export interface WatchedDrag {}
523
548
  export interface AdoptableDrag extends WatchedDrag {
524
549
  /** Ends the gesture as its pointer's release would: an `"end"` at its last point, with its moves' velocity. */
525
550
  readonly stop: () => void
526
- /** Ends the gesture where it is: an `"end"` with no velocity, marked `cancelled`. */
551
+ /** Ends the gesture where it is: an `"end"` with no velocity, `endedBy: "controls"` (and the deprecated `cancelled`). */
527
552
  readonly cancel: () => void
528
553
  }
529
554
 
@@ -701,7 +726,7 @@ export const drag = (target: unknown, options: DragOptions = {}): Stream.Stream<
701
726
  * - **It starts** once the pointer has moved `threshold` px, 3 by default, from its down.
702
727
  * - **Its axis is claimed** at its `"start"`, before `on` hears it, and counts as an active drag, so no
703
728
  * hover or press starts elsewhere while it's on. Every watch on one target shares the claim. When
704
- * another element holds an axis it needs, the gesture is refused: it tells nothing until its end, as a
729
+ * another Subject holds an axis it needs, the gesture is refused: it tells nothing until its end, as a
705
730
  * tap tells nothing, and doesn't retry. Of nested drags, the innermost claims first. With `claim: false`
706
731
  * it only counts.
707
732
  * - **Its claim is given back** at its `"end"`, before `on` hears it, or when the Scope closes mid-drag,
@@ -868,7 +893,7 @@ const panStep = (state: DragState, event: InputSource.PointerLikeEvent): PanStep
868
893
  * A pan claims no axis, so it never stops a drag, nested or not, and no drag stops it. Once started it
869
894
  * counts as an active drag until its end, so a press it took over ends as neither a tap nor a cancel,
870
895
  * and no hover starts meanwhile: that's Wardic's, not Motion's, whose swipe let go over a tappable
871
- * element taps it too.
896
+ * Subject taps it too.
872
897
  */
873
898
  // #273, ADR-0047: no **Drag claim**; counted in the **Drag activity**. Motion's pan is invisible to its
874
899
  // drag lock.
package/src/Easing.ts CHANGED
@@ -161,7 +161,7 @@ export const easeInOutBounce: Easing = (t) => {
161
161
 
162
162
  /**
163
163
  * A cubic Bézier easing through the control points `(x1, y1)` and `(x2, y2)`. An `ease` of
164
- * `[x1, y1, x2, y2]` is the same. `x1` and `x2` are from 0 to 1, as CSS's `cubic-bezier()` takes them;
164
+ * `[x1, y1, x2, y2]` is the same. `x1` and `x2` are from 0 to 1, so the curve is a function of time;
165
165
  * `y1` and `y2` may be any finite number, so the curve may overshoot. Anything else throws an
166
166
  * `OptionError` naming the point, as an `ease` given in a transition does.
167
167
  *
package/src/Frame.ts CHANGED
@@ -12,9 +12,11 @@
12
12
  * if (Frame.isPhysics(frame)) speed = frame.velocity
13
13
  * }
14
14
  */
15
- // CONTEXT.md's Frame; docs/adr/0001-core-stream-contract.md. A plain shape, so it has no prototype
16
- // (ADR-0028, decision 1): a step allocates one every tick, or rewrites one per run in place, as
17
- // `springValues`', a tween's and the blends' do (ADR-0030, decision 11 and *Amendment (#895)*). Only the physics Primitives (`spring`, `decay`, `chase`)
15
+ // CONTEXT.md's Frame; docs/adr/0001-core-stream-contract.md. A plain shape, with no methods (ADR-0028,
16
+ // decision 1): a step allocates one every tick, or rewrites one per run in place, as `springValues`', a
17
+ // tween's, the blends' and `keyframesValues`' do (ADR-0030, decision 11 and *Amendments (#895, #1031)*). A
18
+ // tween's is a class's instance, still with no methods, so V8 gives it a hidden class of its own (#1031).
19
+ // Only the physics Primitives (`spring`, `decay`, `chase`)
18
20
  // emit `velocity`, the field `isPhysics` narrows on.
19
21
  import * as Predicate from "effect/Predicate"
20
22
 
package/src/InputFeed.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * can still prevent the platform's default. `watchWith` is its form for a handler that can stop.
9
9
  * - **`toStream`** gives a feed's events as a Stream, still inside the dispatch.
10
10
  * - **`byTarget`** shares one target's feed among everyone who subscribes to it, so hover, press and
11
- * drag on one element start one source, not three.
11
+ * drag on one Subject start one source, not three.
12
12
  * - **`switched`** is a subscription its owner opens and closes, for a feed it needs only some of the
13
13
  * time.
14
14
  *
@@ -180,7 +180,7 @@ export interface Switch {
180
180
  * A subscription to `feed` its owner opens and closes, each event handed to `handle` inside its emit, a
181
181
  * run of throws to `onDefect` at its first. With none, the run is reported then on Effect's default runtime, as
182
182
  * a subscription has no context of its own, and it goes on. For a feed a watch needs only some of the time: a keyboard
183
- * press holds its target's keys only while focus is within it, so an element at rest holds none. The feed
183
+ * press holds its target's keys only while focus is within it, so a Subject at rest holds none. The feed
184
184
  * running out ends nothing; its owner closes it when it's done.
185
185
  */
186
186
  // #460: a **Keyboard press**.
@@ -2,8 +2,8 @@
2
2
  * Input from the Environment: the `InputSource` service, which gives each target's pointer, keys and
3
3
  * focus as Input feeds, and the events they carry, in core's own terms, so no recognizer reads a
4
4
  * platform's events. An Environment provides it, mapping its platform's events onto these, as
5
- * `@wardic/dom` does. A target is the Environment's own, opaque to core: an element, a node in a scene
6
- * graph.
5
+ * `@wardic/dom` does. A target is the Environment's own, opaque to core: a Subject, or a part of one,
6
+ * such as a node in a scene graph.
7
7
  * `heldPointer` is how an Environment builds a target's pointer feed: once a pointer goes down on the
8
8
  * target, its moves and its release keep reaching it wherever they land.
9
9
  *
@@ -269,15 +269,15 @@ export class InputSource extends Context.Service<InputSource, {
269
269
  readonly focus: (target: unknown) => InputFeed.InputFeed<FocusLikeEvent>
270
270
  /**
271
271
  * Whether focus is now on `target` or inside it, from an Environment that can say. A keyboard press
272
- * then holds its target's keys only while it is, as Motion's listens for keys once its element has
273
- * focus, so an element at rest holds none. Absent: a keyboard press holds the keys throughout, for an
272
+ * then holds its target's keys only while it is, as Motion's listens for keys once its Subject has
273
+ * focus, so a Subject at rest holds none. Absent: a keyboard press holds the keys throughout, for an
274
274
  * Environment whose keys can reach a target without its focus.
275
275
  */
276
276
  // #460: a **Keyboard press**.
277
277
  readonly focusWithin?: ((target: unknown) => boolean) | undefined
278
278
  /**
279
279
  * `pointer(target)` with the downs `adoptPointer` hands `target` too: for a target that can be handed
280
- * one, a drag given drag controls. The plain `pointer` then subscribes to no handing, so an element
280
+ * one, a drag given drag controls. The plain `pointer` then subscribes to no handing, so a Subject
281
281
  * that's only hovered or pressed pays for none. Absent: `pointer` delivers the handed downs itself.
282
282
  */
283
283
  // #431, #507: **Drag controls**.
@@ -60,7 +60,7 @@ export interface Entry<Decoded, Encoded> {
60
60
  readonly format: (value: Decoded) => Encoded
61
61
  /**
62
62
  * Two read endpoints' blend: the closure the frame calls with `t`, or `None`. Pure, and so is the
63
- * closure: a blend is kept and shared, so one pair's closure serves every element animating it, and
63
+ * closure: a blend is kept and shared, so one pair's closure serves every Subject animating it, and
64
64
  * state kept between calls would leak from one to the next.
65
65
  */
66
66
  readonly blend: (from: Decoded, to: Decoded) => Option.Option<(t: number) => Encoded>
@@ -122,7 +122,7 @@ const endAt = (to: ReadonlyArray<number>, index: number, fallback: number): numb
122
122
  }
123
123
 
124
124
  /**
125
- * Two arrays' blend, element by element, `from`'s length: past `to`'s end an element holds
125
+ * Two arrays' blend, item by item, `from`'s length: past `to`'s end an item holds
126
126
  * `from`'s. On the per-frame path (ADR-0025): a counted loop into a new array each frame, and no
127
127
  * closure per frame.
128
128
  */
@@ -137,7 +137,7 @@ const blendArrays =
137
137
  /** An array of numbers, each any number. */
138
138
  const isNumberArray = (value: unknown): value is ReadonlyArray<number> => Arr.isArray(value) && Arr.every(value, Predicate.isNumber)
139
139
 
140
- /** Interpolates fixed-length numeric arrays element-wise (e.g. RGB tuples): it reads an array of numbers as it is. */
140
+ /** Interpolates fixed-length numeric arrays item by item (e.g. RGB tuples): it reads an array of numbers as it is. */
141
141
  export const array: Entry<ReadonlyArray<number>, ReadonlyArray<number>> = {
142
142
  name: "array",
143
143
  parse: Option.liftPredicate(isNumberArray),
@@ -2,7 +2,7 @@
2
2
  * The registry of value kinds: given two values, it finds the kind that blends them and returns the
3
3
  * blend each frame calls. An Environment builds one over core's kinds and its own (`make`, or `layer`
4
4
  * for core's alone), and adds Key rules, which blend a key by its name, as `@wardic/dom`'s keep a key
5
- * that hides an element at its old value until an animation's last frame. A binding resolves each pair once, as it builds an animation.
5
+ * that hides a Subject at its old value until an animation's last frame. A binding resolves each pair once, as it builds an animation.
6
6
  *
7
7
  * @example
8
8
  * import * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry"
@@ -22,6 +22,7 @@ import * as Option from "effect/Option"
22
22
  import * as Predicate from "effect/Predicate"
23
23
  import * as Interpolator from "./Interpolator.ts"
24
24
  import { dual } from "./internal/dual.ts"
25
+ import * as LerpsNumbers from "./internal/lerpsNumbers.ts"
25
26
 
26
27
  // The registry is heterogeneous by design: its entries are `Interpolator.Entry<any, any>`.
27
28
 
@@ -69,7 +70,7 @@ export type ResolveByValue = <From, To>(from: From, to: To) => Effect.Effect<(t:
69
70
  /**
70
71
  * A key's pair as the rules after one rule, then the kinds, blend it: what a rule that rewrites a pair
71
72
  * hands it on to, so the rules after it still apply. A rule that reads a value from elsewhere, as
72
- * `@wardic/dom`'s for an element's own variables, resolves it, then blends what it resolved to through
73
+ * `@wardic/dom`'s for a Subject's own variables, resolves it, then blends what it resolved to through
73
74
  * `next`, so the key's other rules still apply to it.
74
75
  */
75
76
  // ADR-0035, *Amendment (#55)*: its Animatable none.
@@ -80,9 +81,9 @@ export type KeyBlendOf = (key: string, from: number | string, to: number | strin
80
81
 
81
82
  /**
82
83
  * An Environment's Key rule: how one key's pair blends, picked by the key's name, as `@wardic/dom`'s keep
83
- * a key that hides an element at its old value until an animation's last frame. Core holds none: which
84
- * keys need one is the Environment's to know. Most hold for the whole Environment (`make`, `registerKeyRule`); one that reads an element
85
- * is added for that element's animations with `withKeyRules`.
84
+ * a key that hides a Subject at its old value until an animation's last frame. Core holds none: which
85
+ * keys need one is the Environment's to know. Most hold for the whole Environment (`make`, `registerKeyRule`); one that reads a Subject
86
+ * is added for that Subject's animations with `withKeyRules`.
86
87
  */
87
88
  // CONTEXT.md, ADR-0035; `@wardic/dom`'s are its `keyRules`. The registry asks every rule for every
88
89
  // key of every leg it builds, so a key no rule wants costs what it did with none (ADR-0035, *Amendment
@@ -192,7 +193,7 @@ const blendDecoded = <From, To>(decoded: DecodedPair, from: From, to: To): Effec
192
193
  const CACHE_CAPACITY = 1024
193
194
 
194
195
  /**
195
- * Resolved blends of string pairs, by `from`, then `to` (ADR-0026, decision 9). Elements often
196
+ * Resolved blends of string pairs, by `from`, then `to` (ADR-0026, decision 9). Subjects often
196
197
  * animate the same pair (a hover state's value, say), so each pair is decoded
197
198
  * and built once per registry, and every stream that resolves it shares the closure. That's safe:
198
199
  * the closures are pure, and `complex`'s, which reuses one numbers array, rewrites every number and
@@ -267,6 +268,14 @@ export const make = (
267
268
  return blendDecoded(decoded.value, from, to)
268
269
  }
269
270
 
271
+ /** Whether a pair of numbers resolves to `Interpolator.number` itself: the first kind that reads it. */
272
+ // Per key, each leg (#460, compose once): statements. #1036: a blend machine computes such a pair in its loop.
273
+ const lerpsNumbers = (from: number, to: number): boolean => {
274
+ const decoded = select(entries, from, to)
275
+ if (Option.isNone(decoded)) return false
276
+ return decoded.value.entry === Interpolator.number
277
+ }
278
+
270
279
  /** A pair of strings, from the cache, or resolved and kept. */
271
280
  const resolveCached = (from: string, to: string): Effect.Effect<Blend<any, any>> => {
272
281
  const kept = cache.get(from, to)
@@ -282,7 +291,7 @@ export const make = (
282
291
 
283
292
  MutableRef.set(chain, chainOf(rules, resolve, noRule))
284
293
 
285
- return {
294
+ return LerpsNumbers.attach({
286
295
  register: Effect.fnUntraced(function* <Decoded, Encoded>(entry: Interpolator.Entry<Decoded, Encoded>) {
287
296
  entries.unshift(entry)
288
297
  cache.clear()
@@ -303,18 +312,18 @@ export const make = (
303
312
  keyBlendOf: (key: string, from: number | string, to: number | string): Option.Option<Effect.Effect<KeyBlend>> =>
304
313
  MutableRef.get(chain)(key, from, to),
305
314
  forget: Effect.sync(() => cache.clear()),
306
- }
315
+ }, lerpsNumbers)
307
316
  })
308
317
 
309
318
  /**
310
319
  * `self` run with `rules` asked first, ahead of the registry's own Key rules, for that run alone: how a
311
- * binding adds a rule bound to one element, as `@wardic/dom`'s for its own variables, to that element's
320
+ * binding adds a rule bound to one Subject, as `@wardic/dom`'s for its own variables, to that Subject's
312
321
  * animations.
313
322
  * Each rule's `next` is the rules after it, then the registry's, then by value. The registry itself is
314
- * unchanged, so one element's rule never reaches another's.
323
+ * unchanged, so one Subject's rule never reaches another's.
315
324
  *
316
325
  * @example
317
- * yield* buildLegs.pipe(InterpolatorRegistry.withKeyRules([ruleOf(element)]))
326
+ * yield* buildLegs.pipe(InterpolatorRegistry.withKeyRules([ruleOf(subject)]))
318
327
  */
319
328
  // ADR-0035, *Amendment (#55)*: `@wardic/dom`'s `variableValues(element)`.
320
329
  export const withKeyRules: {
@@ -331,8 +340,8 @@ type Service = InterpolatorRegistry["Service"]
331
340
 
332
341
  /**
333
342
  * Each rule list's layered registries, by the registry under them: a binding binds one list to an
334
- * element and wraps each leg it starts with it, so the chain is built once per element and
335
- * Environment, not per leg. Weak, so an element's list goes with it.
343
+ * Subject and wraps each leg it starts with it, so the chain is built once per Subject and
344
+ * Environment, not per leg. Weak, so a Subject's list goes with it.
336
345
  */
337
346
  // Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
338
347
  const layered = new WeakMap<ReadonlyArray<KeyRule>, WeakMap<Service, Service>>()
package/src/LiveValue.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Live values: values derived from other values as they change, each an `effect/reactivity` Atom an
3
- * element's `style` can follow. `transform` maps one through ranges, `follow` and `spring` follow one on
3
+ * Subject's `style` can follow. `transform` maps one through ranges, `follow` and `spring` follow one on
4
4
  * a transition, `velocity` tracks how fast one moves, `scroll` gives a container's scroll, `time` the
5
5
  * time since it started, and `eachFrame` calls you every frame. A binding wraps them in its own
6
6
  * reactive values, as Solid's `createSpring` and `createTransform` do.
@@ -12,8 +12,8 @@
12
12
  * const x = yield* LiveValue.spring(pointerX, { stiffness: 300, damping: 30 })
13
13
  * const opacity = yield* LiveValue.transform(x, [0, 200], [1, 0])
14
14
  */
15
- // #130, ADR-0043: a Live value is one the user moves themselves, given in an element's `style`: the
16
- // key's `style` link, which the element follows while no entry of the Override stack sets it
15
+ // #130, ADR-0043: a Live value is one the user moves themselves, given in a Subject's `style`: the
16
+ // key's `style` link, which the Subject follows while no entry of the Override stack sets it
17
17
  // (CONTEXT.md). Its shared form is an Atom, as core's other live data is (`Probe.viewport`). Motion's
18
18
  // `useTransform` (with a `mixer`, #440), `interpolate`, `followValue` (#441), `useSpring`,
19
19
  // `MotionValue.jump` (#257 item 7), `useScroll` (#234), `useVelocity`, `useTime`, `useAnimationFrame`
@@ -33,6 +33,7 @@ import * as AtomRegistry from "effect/reactivity/AtomRegistry"
33
33
  import * as Rec from "effect/Record"
34
34
  import type * as Scope from "effect/Scope"
35
35
  import * as UndefinedOr from "effect/UndefinedOr"
36
+ import * as Clock from "./Clock.ts"
36
37
  import * as FrameLoop from "./FrameLoop.ts"
37
38
  import * as Easing from "./Easing.ts"
38
39
  import * as InterpolatorRegistry from "./InterpolatorRegistry.ts"
@@ -326,7 +327,8 @@ export const jump: {
326
327
  }),
327
328
  )
328
329
 
329
- /** Motion's spring, for the physics a follow's spring leaves out (`motion-dom`'s `springDefaults`). */
330
+ /** Motion's spring, for the physics a follow's spring leaves out (Motion's `springDefaults`). */
331
+ // `motion-dom`'s `springDefaults`.
330
332
  const MOTION_PHYSICS = { stiffness: 100, damping: 10, mass: 1 } as const
331
333
 
332
334
  /** Motion's follower's rest thresholds, for those a spring or an inertia leaves out (`follow()`'s). */
@@ -630,8 +632,8 @@ export interface ScrollTransform {
630
632
  * How a Live value derives from a container's scroll, in no Environment's terms: the scroll it
631
633
  * reads, as `scroll` was given it; whether it reads how far the container is scrolled (`current`) or
632
634
  * its progress; on which axis; and each `transform` it went through since, in order. An Environment
633
- * that can run a scroll-linked value with the scroll itself, as the DOM's native scroll timelines do (a
634
- * **Timeline value**), reads it to decide whether it can, and how.
635
+ * that can run a scroll-linked value with the scroll itself, as `@wardic/dom` can (a **Timeline value**),
636
+ * reads it to decide whether it can, and how.
635
637
  */
636
638
  export interface ScrollDerivation {
637
639
  /** The scroll's options, as `scroll` was given them. */
@@ -700,7 +702,7 @@ const derivationNow = (atom: Atom.Atom<unknown>): ScrollDerivation | undefined =
700
702
  /**
701
703
  * Describe `atom` as deriving from a container's scroll as `source` does: for an Atom a binding
702
704
  * keeps for a value's life and sets from `source`, made after it, as a `createScroll` does once its
703
- * elements are there. A `transform` made over `atom` before then derives through it too. Called again,
705
+ * Subjects are there. A `transform` made over `atom` before then derives through it too. Called again,
704
706
  * it derives as the new `source` does. `source` mustn't derive from `atom`.
705
707
  *
706
708
  * @example
@@ -723,8 +725,8 @@ export const derivesAs: {
723
725
  * How `atom` derives from a container's scroll, now: one of `scroll`'s values, an Atom
724
726
  * `derivesAs` one, or a `transform` over either, a `transform` over that, and so on; `None` for any
725
727
  * other, a `spring` or a `velocity` of one among them. Read again while nothing it derives from
726
- * changed, it's the same object. An Environment reads it to run the value on a native scroll timeline
727
- * where it can (a **Timeline value**).
728
+ * changed, it's the same object. An Environment reads it to run the value with the scroll itself where it
729
+ * can, as `@wardic/dom` can (a **Timeline value**).
728
730
  *
729
731
  * @example
730
732
  * const { scrollYProgress } = yield* LiveValue.scroll({ container })
@@ -755,8 +757,10 @@ const numberMachine = (name: string, settles: boolean, start: () => (dt: number)
755
757
  // tick whose Late step doesn't come (back-to-back frames, or past the Late rounds) takes its first step at
756
758
  // the next tick, and would otherwise count two frames' change over one `dt`. Its Late step, at the loop's
757
759
  // tick count it started at, reads from the source before the change that started it, since the tick's hook
758
- // has read past that change by then (#991, ADR-0043 *Amendment (#991)*).
759
- export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<number>, never, FrameLoop.FrameLoop | AtomRegistry.AtomRegistry | Scope.Scope> = Effect.fnUntraced(
760
+ // has read past that change by then (#991, ADR-0043 *Amendment (#991)*). A change is over the time it took
761
+ // (#1046): the tick's dt, on the frame timeline, unless the time since the read at the run's own last step,
762
+ // a tick before, differs from it by more than half, a late frame's stamps misstating it either way (below).
763
+ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<number>, never, Clock.Clock | FrameLoop.FrameLoop | AtomRegistry.AtomRegistry | Scope.Scope> = Effect.fnUntraced(
760
764
  function* (source: Atom.Atom<number>) {
761
765
  const registry = yield* AtomRegistry.AtomRegistry
762
766
  // Mounted for the Scope, not kept alive: a kept-alive Atom's node never leaves the registry.
@@ -779,9 +783,19 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
779
783
  let startedAt = 0
780
784
  let firstDue = false
781
785
  const loop = yield* FrameLoop.FrameLoop
786
+ // When `previous` was read, on the Clock's `now()`, and at which tick; and the tick of the run's last
787
+ // step, `-1` before its first. A step right after the run's own last one divides its change by the time
788
+ // since that tick's read, which a late frame's stamps misstate (#1046): a running run keeps the loop
789
+ // ticking every frame, where the loop idles between runs and its tick count skips the frames it missed.
790
+ const clock = yield* Clock.Clock
791
+ let previousAt = 0
792
+ let previousTick = -1
793
+ let stepTick = -1
782
794
  yield* loop.afterTick(() => {
783
795
  try {
784
796
  previous = registry.get(source)
797
+ previousAt = clock.now()
798
+ previousTick = loop.tickCount()
785
799
  if (sourceFailing) sourceFailing = false
786
800
  } catch (defect) {
787
801
  if (!sourceFailing) Report.failureOn(context, SOURCE_FAILED, Cause.die(defect))
@@ -793,6 +807,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
793
807
  const unhear = onJump(registry, source, (value) => {
794
808
  previous = value
795
809
  seed = value
810
+ stepTick = -1
796
811
  })
797
812
  // One token for its lifetime, and one run program, started afresh on the change after a rest:
798
813
  // a change while a run goes costs a check, nothing built.
@@ -807,7 +822,18 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
807
822
  return previous
808
823
  }
809
824
  const program = numberMachine("wardic.velocity", true, () => (dt) => {
810
- const step = Math.min(dt, Machine.MAX_DT)
825
+ // Over the tick's dt, unless, right after the run's own last step, the time since that tick's read
826
+ // differs from it by more than half: a late frame, whose stamps misstate it (#1046). An on-time frame's
827
+ // reads differ from its dt by their jitter, which the stamps don't have. A run's first step, its Late
828
+ // step among them, has no read of its own a tick before.
829
+ const tick = loop.tickCount()
830
+ let seconds = dt
831
+ if (stepTick === tick - 1 && previousTick === stepTick) {
832
+ const since = (clock.now() - previousAt) / 1000
833
+ if (Math.abs(since - dt) > dt / 2) seconds = since
834
+ }
835
+ stepTick = tick
836
+ const step = Math.min(seconds, Machine.MAX_DT)
811
837
  // A tick in no time (never from the Clock) reads as still.
812
838
  if (step === 0) return { value: 0, done: true }
813
839
  // A check on every later step: the first's alone reads the tick count (#991).
@@ -835,7 +861,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
835
861
  }
836
862
  if (frame.done) running = false
837
863
  return undefined
838
- }, { supersede: token }),
864
+ }, { supersede: token, onFrameTimeline: true }),
839
865
  )
840
866
  const follow = (): void => {
841
867
  if (running) return
@@ -843,6 +869,7 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
843
869
  seed = previous
844
870
  startedAt = loop.tickCount()
845
871
  firstDue = true
872
+ stepTick = -1
846
873
  run(program, { onlyIfMissing: true })
847
874
  }
848
875
  const unsubscribe = registry.subscribe(source, follow)
@@ -864,7 +891,9 @@ export const velocity: (source: Atom.Atom<number>) => Effect.Effect<Atom.Atom<nu
864
891
  * @example
865
892
  * const rotate = yield* LiveValue.transform(yield* LiveValue.time(), [0, 4000], [0, 360], { clamp: false })
866
893
  */
867
- // A run on the Frame loop that never settles, adding each tick's `dt` as the Clock gives it, unclamped.
894
+ // A run on the Frame loop that never settles, adding each tick's `dt` as the Clock gives it, unclamped. On
895
+ // the frame timeline (#1046, ADR-0027 *Amendment (#1046)*): it reports the frames' time, so a late first frame's
896
+ // counts whole, where an animation made in a long task leaves it out.
868
897
  export const time: () => Effect.Effect<Atom.Atom<number>, never, FrameLoop.FrameLoop | AtomRegistry.AtomRegistry | Scope.Scope> = Effect.fnUntraced(
869
898
  function* () {
870
899
  const registry = yield* AtomRegistry.AtomRegistry
@@ -893,7 +922,7 @@ export const time: () => Effect.Effect<Atom.Atom<number>, never, FrameLoop.Frame
893
922
  failing = true
894
923
  }
895
924
  return undefined
896
- }, { supersede: token }),
925
+ }, { supersede: token, onFrameTimeline: true }),
897
926
  ),
898
927
  )
899
928
  yield* Effect.addFinalizer(() =>
@@ -922,7 +951,8 @@ const FRAME_DELTA = { minimum: 1, maximum: 40 } as const
922
951
  * yield* LiveValue.eachFrame((time) => draw(context, time))
923
952
  */
924
953
  // #443. A run's first frame after the Clock wakes is the Clock's nominal frame, 16.7 ms, as Motion's is.
925
- // A throw is a run's defect (ADR-0027, decision 7).
954
+ // A throw is a run's defect (ADR-0027, decision 7). On the frame timeline (#1046): its time and delta are the
955
+ // frames' own, as Motion's `timestamp - initialTimestamp` is, a late frame's included.
926
956
  export const eachFrame: (callback: (time: number, delta: number) => void) => Effect.Effect<void, never, FrameLoop.FrameLoop | Scope.Scope> = Effect.fnUntraced(
927
957
  function* (callback: (time: number, delta: number) => void) {
928
958
  const run = yield* FiberHandle.makeRuntime<FrameLoop.FrameLoop, never, unknown>()
@@ -939,7 +969,7 @@ export const eachFrame: (callback: (time: number, delta: number) => void) => Eff
939
969
  return { value: ms, done: false }
940
970
  }
941
971
  })
942
- run(frames.pipe(Machine.run(constUndefined, { supersede: token })))
972
+ run(frames.pipe(Machine.run(constUndefined, { supersede: token, onFrameTimeline: true })))
943
973
  yield* Effect.addFinalizer(() => Effect.sync(() => Supersede.end(token)))
944
974
  })
945
975