@wardic/dom 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 (143) hide show
  1. package/dist/MeasuredPair.d.ts +14 -1
  2. package/dist/MeasuredPair.d.ts.map +1 -1
  3. package/dist/MeasuredPair.js +11 -13
  4. package/dist/MeasuredPair.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/appear.d.ts +6 -0
  10. package/dist/internal/appear.d.ts.map +1 -1
  11. package/dist/internal/appear.js +20 -2
  12. package/dist/internal/appear.js.map +1 -1
  13. package/dist/internal/batch-handoff.d.ts.map +1 -1
  14. package/dist/internal/batch-handoff.js +25 -15
  15. package/dist/internal/batch-handoff.js.map +1 -1
  16. package/dist/internal/batch-writer.d.ts +1 -1
  17. package/dist/internal/batch-writer.d.ts.map +1 -1
  18. package/dist/internal/batch-writer.js +32 -16
  19. package/dist/internal/batch-writer.js.map +1 -1
  20. package/dist/internal/clock.d.ts +6 -0
  21. package/dist/internal/clock.d.ts.map +1 -1
  22. package/dist/internal/clock.js +27 -0
  23. package/dist/internal/clock.js.map +1 -1
  24. package/dist/internal/default-transition.d.ts +3 -2
  25. package/dist/internal/default-transition.d.ts.map +1 -1
  26. package/dist/internal/default-transition.js +28 -3
  27. package/dist/internal/default-transition.js.map +1 -1
  28. package/dist/internal/failing.d.ts +9 -0
  29. package/dist/internal/failing.d.ts.map +1 -0
  30. package/dist/internal/failing.js +33 -0
  31. package/dist/internal/failing.js.map +1 -0
  32. package/dist/internal/length-keys.d.ts +19 -0
  33. package/dist/internal/length-keys.d.ts.map +1 -0
  34. package/dist/internal/length-keys.js +77 -0
  35. package/dist/internal/length-keys.js.map +1 -0
  36. package/dist/internal/measured-pairs.d.ts +3 -2
  37. package/dist/internal/measured-pairs.d.ts.map +1 -1
  38. package/dist/internal/measured-pairs.js +60 -23
  39. package/dist/internal/measured-pairs.js.map +1 -1
  40. package/dist/internal/own-values.d.ts.map +1 -1
  41. package/dist/internal/own-values.js +2 -2
  42. package/dist/internal/own-values.js.map +1 -1
  43. package/dist/internal/positional-keys.d.ts +1 -1
  44. package/dist/internal/positional-keys.d.ts.map +1 -1
  45. package/dist/internal/positional-keys.js +4 -2
  46. package/dist/internal/positional-keys.js.map +1 -1
  47. package/dist/internal/projection.d.ts.map +1 -1
  48. package/dist/internal/projection.js +180 -46
  49. package/dist/internal/projection.js.map +1 -1
  50. package/dist/internal/renderer.d.ts +59 -27
  51. package/dist/internal/renderer.d.ts.map +1 -1
  52. package/dist/internal/renderer.js +241 -207
  53. package/dist/internal/renderer.js.map +1 -1
  54. package/dist/internal/scroll.d.ts.map +1 -1
  55. package/dist/internal/scroll.js +26 -2
  56. package/dist/internal/scroll.js.map +1 -1
  57. package/dist/internal/starting-style.js +5 -5
  58. package/dist/internal/transform-keys.d.ts +23 -0
  59. package/dist/internal/transform-keys.d.ts.map +1 -0
  60. package/dist/internal/transform-keys.js +55 -0
  61. package/dist/internal/transform-keys.js.map +1 -0
  62. package/dist/unstable/AppearAnimations.d.ts +2 -1
  63. package/dist/unstable/AppearAnimations.d.ts.map +1 -1
  64. package/dist/unstable/AppearAnimations.js +73 -22
  65. package/dist/unstable/AppearAnimations.js.map +1 -1
  66. package/dist/unstable/BatchMembers.d.ts +2 -2
  67. package/dist/unstable/BatchMembers.d.ts.map +1 -1
  68. package/dist/unstable/BatchMembers.js +30 -7
  69. package/dist/unstable/BatchMembers.js.map +1 -1
  70. package/dist/unstable/DomValues.js +1 -1
  71. package/dist/unstable/DomValues.js.map +1 -1
  72. package/dist/unstable/DragTrack.d.ts +2 -2
  73. package/dist/unstable/DragTrack.d.ts.map +1 -1
  74. package/dist/unstable/DragTrack.js +37 -10
  75. package/dist/unstable/DragTrack.js.map +1 -1
  76. package/dist/unstable/ElementSetup.d.ts.map +1 -1
  77. package/dist/unstable/ElementSetup.js +3 -2
  78. package/dist/unstable/ElementSetup.js.map +1 -1
  79. package/dist/unstable/GestureFeatures.d.ts +8 -2
  80. package/dist/unstable/GestureFeatures.d.ts.map +1 -1
  81. package/dist/unstable/GestureFeatures.js +26 -40
  82. package/dist/unstable/GestureFeatures.js.map +1 -1
  83. package/dist/unstable/GestureInfo.d.ts +11 -0
  84. package/dist/unstable/GestureInfo.d.ts.map +1 -1
  85. package/dist/unstable/GestureInfo.js +8 -0
  86. package/dist/unstable/GestureInfo.js.map +1 -1
  87. package/dist/unstable/Imperative.d.ts +1 -1
  88. package/dist/unstable/Imperative.d.ts.map +1 -1
  89. package/dist/unstable/Imperative.js.map +1 -1
  90. package/dist/unstable/LiveStyle.d.ts +28 -2
  91. package/dist/unstable/LiveStyle.d.ts.map +1 -1
  92. package/dist/unstable/LiveStyle.js +8 -32
  93. package/dist/unstable/LiveStyle.js.map +1 -1
  94. package/dist/unstable/MemberHold.js +3 -3
  95. package/dist/unstable/MemberHold.js.map +1 -1
  96. package/dist/unstable/PointerValues.d.ts.map +1 -1
  97. package/dist/unstable/PointerValues.js +82 -8
  98. package/dist/unstable/PointerValues.js.map +1 -1
  99. package/dist/unstable/PresenceController.d.ts +5 -2
  100. package/dist/unstable/PresenceController.d.ts.map +1 -1
  101. package/dist/unstable/PresenceController.js +82 -55
  102. package/dist/unstable/PresenceController.js.map +1 -1
  103. package/dist/unstable/ReorderInput.d.ts +2 -2
  104. package/dist/unstable/ReorderInput.js +2 -2
  105. package/dist/unstable/WardConfig.d.ts +18 -9
  106. package/dist/unstable/WardConfig.d.ts.map +1 -1
  107. package/dist/unstable/WardConfig.js.map +1 -1
  108. package/dist/unstable/features/TimelineKeys.d.ts.map +1 -1
  109. package/dist/unstable/features/TimelineKeys.js +19 -3
  110. package/dist/unstable/features/TimelineKeys.js.map +1 -1
  111. package/package.json +3 -3
  112. package/src/MeasuredPair.ts +21 -1
  113. package/src/index.ts +4 -1
  114. package/src/internal/appear.ts +20 -2
  115. package/src/internal/batch-handoff.ts +19 -11
  116. package/src/internal/batch-writer.ts +32 -16
  117. package/src/internal/clock.ts +28 -0
  118. package/src/internal/default-transition.ts +28 -4
  119. package/src/internal/failing.ts +37 -0
  120. package/src/internal/length-keys.ts +80 -0
  121. package/src/internal/measured-pairs.ts +58 -22
  122. package/src/internal/own-values.ts +2 -2
  123. package/src/internal/positional-keys.ts +4 -2
  124. package/src/internal/projection.ts +190 -44
  125. package/src/internal/renderer.ts +272 -198
  126. package/src/internal/scroll.ts +24 -2
  127. package/src/internal/starting-style.ts +5 -5
  128. package/src/internal/transform-keys.ts +59 -0
  129. package/src/unstable/AppearAnimations.ts +73 -24
  130. package/src/unstable/BatchMembers.ts +33 -9
  131. package/src/unstable/DomValues.ts +1 -1
  132. package/src/unstable/DragTrack.ts +49 -14
  133. package/src/unstable/ElementSetup.ts +3 -2
  134. package/src/unstable/GestureFeatures.ts +38 -47
  135. package/src/unstable/GestureInfo.ts +24 -0
  136. package/src/unstable/Imperative.ts +1 -0
  137. package/src/unstable/LiveStyle.ts +12 -8
  138. package/src/unstable/MemberHold.ts +3 -3
  139. package/src/unstable/PointerValues.ts +73 -8
  140. package/src/unstable/PresenceController.ts +80 -54
  141. package/src/unstable/ReorderInput.ts +2 -2
  142. package/src/unstable/WardConfig.ts +22 -10
  143. package/src/unstable/features/TimelineKeys.ts +20 -3
@@ -65,6 +65,7 @@ import * as Box from "@wardic/core/Box"
65
65
  import * as Clock from "@wardic/core/Clock"
66
66
  import type * as Frame from "@wardic/core/Frame"
67
67
  import * as FrameLoop from "@wardic/core/FrameLoop"
68
+ import * as FirstSteps from "@wardic/core/unstable/FirstSteps"
68
69
  import * as Inertia from "@wardic/core/Inertia"
69
70
  import * as Microtask from "@wardic/core/Microtask"
70
71
  import type * as Arc from "@wardic/core/Arc"
@@ -125,6 +126,7 @@ import { pending as appearRuns } from "./appear-slot.ts"
125
126
  import * as Report from "@wardic/core/unstable/Report"
126
127
  import { blendRadius, borderRadiusCorrector, isUnitScale, SCALE_CORRECTORS, type ScaleCorrector, type ScaleCorrectorEntry, scaleRadius, ZERO_RADIUS } from "./scale-correction.ts"
127
128
  import { dashCase } from "./svg.ts"
129
+ import * as Failing from "./failing.ts"
128
130
 
129
131
  /**
130
132
  * What the engine writes each node's projection through: a `FlushGate` is one, so the engine never
@@ -173,6 +175,9 @@ const COORDINATOR_RUNNING: Frame.Frame<void> = { value: undefined, done: false }
173
175
  const COORDINATOR_SETTLED: Frame.Frame<void> = { value: undefined, done: true }
174
176
  const ignoreFrame: FrameLoop.Sink<Frame.Frame<void>> = () => undefined
175
177
 
178
+ /** The coordinator's run keeps the frame timeline's time: each flight keeps the late-frame rule itself (#1028). */
179
+ const ON_THE_FRAME_TIMELINE: Machine.RunOptions = { onFrameTimeline: true }
180
+
176
181
  /** Identity tree-scale (no ancestor scaling). */
177
182
  const TREE_SCALE_IDENTITY: Point.Point = { x: 1, y: 1 }
178
183
 
@@ -470,6 +475,12 @@ interface Flight {
470
475
  landed: boolean
471
476
  /** Its curve along its Path (#438, ADR-0065), built at its start; `undefined` for a straight flight. */
472
477
  readonly curve: FlightCurve | undefined
478
+ /**
479
+ * What it owes of a long task's time (#1028, core's `unstable/FirstSteps`): its first step, until it's taken,
480
+ * then that frame's lateness, which its second step leaves out, then 0. 0 from the start where
481
+ * the Frame loop carries no reader of its ticks.
482
+ */
483
+ owed: number
473
484
  }
474
485
 
475
486
  /** A flight's curve along its Path (#438, ADR-0065). */
@@ -507,7 +518,17 @@ const timingOf = (transition: LayoutTransition): FlightTiming =>
507
518
  const LANDED: FlightTiming = springTiming(Spring.resolve({}))
508
519
 
509
520
  /** A flight at 1 on {@link LANDED}: it ends on its first step, the node on its new box. */
510
- const landedFlight = (): Flight => ({ position: 1, elapsed: 0, spring: Spring.init({ from: 1 }), timing: LANDED, started: false, landed: false, curve: undefined })
521
+ // It owes nothing (#1028): it lands at its first step, whatever its dt.
522
+ const landedFlight = (): Flight => ({
523
+ position: 1,
524
+ elapsed: 0,
525
+ spring: Spring.init({ from: 1 }),
526
+ timing: LANDED,
527
+ started: false,
528
+ landed: false,
529
+ curve: undefined,
530
+ owed: 0,
531
+ })
511
532
 
512
533
  /** Motion's distance floor for a curved layout animation (#438): a shift shorter than this goes straight. */
513
534
  const MIN_CURVE_DISTANCE = 20
@@ -1247,6 +1268,9 @@ interface NodeState {
1247
1268
  /** Called as a Measure pass that measures it begins, and with its box after the read (#443); most nodes have neither. */
1248
1269
  readonly onBeforeMeasure: (() => void) | undefined
1249
1270
  readonly onMeasure: ((box: Box.Box, prev: Option.Option<Box.Box>) => void) | undefined
1271
+ /** The names of the app's callbacks on it whose last call threw, made at the first throw: most nodes never see one. */
1272
+ // #979 group I, row 29 (ADR-0074 decision 3).
1273
+ failing: Set<LayoutCallbackName> | undefined
1250
1274
  /**
1251
1275
  * What the node's handover blends from (ADR-0010 *Amendment (#166)*): the twin's radius, rotation
1252
1276
  * and, for a Switch, opacity, as they were drawn as it began. Eased into the node's own over the
@@ -1418,6 +1442,17 @@ interface NodeState {
1418
1442
  customBases: Readonly<Record<string, string>> | undefined
1419
1443
  /** Whether an app's corrector's value is written corrected now (so it's put back once at rest). */
1420
1444
  customCorrected: boolean
1445
+ // --- the app's code, its own (#979, row 5; ADR-0074): each reported once a run of throws ---
1446
+ /** Whether its layout animation's ease threw at its last call. */
1447
+ easeFailing: boolean
1448
+ /** The app's correctors that threw for it at their last call: made at the first throw. */
1449
+ failingCorrectors: Set<CustomCorrector> | undefined
1450
+ /** Whether its write threw at its last call, as a leaving node writes straight onto its element. */
1451
+ writeFailing: boolean
1452
+ /** Whether its Transform template threw as a Measure pass held it for the read. */
1453
+ heldFailing: boolean
1454
+ /** Its Transform template's last result, which a pass holds it at when the template throws: `none` before one. */
1455
+ lastHeld: string
1421
1456
  // --- drag (ADR-0016) ---
1422
1457
  /** Whether this node is being dragged: its target follows the pointer (no spring), held active. */
1423
1458
  dragging: boolean
@@ -1479,6 +1514,8 @@ interface LastPass {
1479
1514
  * `handleLeave` brought it back.
1480
1515
  */
1481
1516
  interface Leaver {
1517
+ /** Its node's id: a node it comes back as is reported by it (#979, row 5). */
1518
+ readonly id: string
1482
1519
  readonly element: HTMLElement
1483
1520
  /** Its last pass; `undefined` when it never had one, and then it can't come back. */
1484
1521
  readonly last: LastPass | undefined
@@ -1552,17 +1589,6 @@ const NO_OWN_TRANSLATE = (): Point.Point => NO_TRANSLATE
1552
1589
  /** No values registered for an element (#443): an app's corrector reads its base then. */
1553
1590
  const NO_VALUES: Readonly<Record<string, unknown>> = {}
1554
1591
 
1555
- /**
1556
- * The transform a Measure pass holds `node` at (#443): its Transform template's, `none` for a node
1557
- * with none (Motion's `resetTransform`), which is what an at-rest node already draws (#674). Per pass
1558
- * per node: a field read and an early return.
1559
- */
1560
- const heldTransformFor = (node: { readonly heldTransform: (() => string) | undefined }): string => {
1561
- const held = node.heldTransform
1562
- if (Predicate.isUndefined(held)) return "none"
1563
- return held()
1564
- }
1565
-
1566
1592
  /** No own rotation or opacity of its own: a node the binding gives none, or a leaving one (*Amendment (#166)*). */
1567
1593
  const NO_OWN_ROTATE = (): number => 0
1568
1594
  const NO_OWN_OPACITY = (): number => 1
@@ -1599,6 +1625,10 @@ const SIZE_EPSILON = 0.01
1599
1625
 
1600
1626
  /** No layout animation callback: a node the binding gives none (#191). */
1601
1627
  const NO_CALLBACK = (): Option.Option<() => void> => Option.none()
1628
+
1629
+ /** An app's callback on a layout node, by the name its report gives it. */
1630
+ type LayoutCallbackName = "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "onDragTransitionEnd" | "onBeforeLayoutMeasure" | "onLayoutMeasure"
1631
+
1602
1632
  /** A call with no options. */
1603
1633
  const NO_ANIMATE_LAYOUT_OPTIONS: AnimateLayoutOptions = {}
1604
1634
 
@@ -1716,7 +1746,7 @@ export const makeProjectionSystem = (
1716
1746
  * transition read now, Motion's default with none, its delay held first, and with no velocity
1717
1747
  * (Motion's). When reduced motion applies to `node` (ADR-0029), or its animations are skipped
1718
1748
  * (#468), at 1 with no delay, so the node lands on its new box at once and the flight ends on its
1719
- * first step.
1749
+ * first step. Stamped with when it began and what it owes of a long task's time (#1028, `flightDt`).
1720
1750
  */
1721
1751
  const startFlight = (node: NodeState): Flight =>
1722
1752
  Bool.match(Bool.or(node.skipAnimations(), Bool.and(node.respectReducedMotion(), node.reducedMotion())), {
@@ -1726,7 +1756,7 @@ export const makeProjectionSystem = (
1726
1756
  // this one animation: reported, and the node lands, as reduced motion lands it.
1727
1757
  try {
1728
1758
  const timing = timingOf(Option.getOrElse(node.transition(), () => DEFAULT_LAYOUT_TRANSITION))
1729
- return { position: 0, elapsed: 0, spring: Spring.init({}), timing, started: false, landed: false, curve: curveOf(node) }
1759
+ return { position: 0, elapsed: 0, spring: Spring.init({}), timing, started: false, landed: false, curve: curveOf(node), owed: ticks.madeOwing() }
1730
1760
  } catch (defect) {
1731
1761
  runtime.runFork(Report.failure("wardic.projection: layout transition rejected", Cause.die(defect)))
1732
1762
  return landedFlight()
@@ -1843,6 +1873,10 @@ export const makeProjectionSystem = (
1843
1873
  // The Environment's Frame loop: the coordinator runs on it, the engine's hook is on its ticks, and a
1844
1874
  // trigger reads whether its Late window is open (#673, #680).
1845
1875
  const loop = runtime.runSync(Effect.service(FrameLoop.FrameLoop))
1876
+ // Its ticks as the late-frame rule reads them (#1028, core's `unstable/FirstSteps`): each flight keeps the
1877
+ // rule, as a Batch's members do, the coordinator's run on the frame timeline. Read once; a loop that
1878
+ // carries no reader (a test's own) is read as one under which nothing owes.
1879
+ const ticks = Option.getOrElse(FirstSteps.readerOf(loop), () => FirstSteps.owingNothing)
1846
1880
  // Whether the coordinator's step is running: a stop from inside it settles the run.
1847
1881
  let inStep = false
1848
1882
  // The turn a turning flight's curve gives at its target just placed (#438), for `derive` to draw:
@@ -1991,7 +2025,16 @@ export const makeProjectionSystem = (
1991
2025
  const patch = projectionPatchOf(value, corrected)
1992
2026
  // A leaving node is driven directly: its gate registration is gone.
1993
2027
  if (node.leaving) {
1994
- renderer.commit(node.element, renderer.project(withExitValues(node, patch)))
2028
+ // #979, row 5 (ADR-0074): as the gate takes each element's write on its own (#969), a leaver's
2029
+ // write that throws (its Transform template's, say) leaves it as it was drawn, and every other
2030
+ // node goes on: before, it failed the coordinator's run, so every layout animation stopped.
2031
+ try {
2032
+ renderer.commit(node.element, renderer.project(withExitValues(node, patch)))
2033
+ if (node.writeFailing) node.writeFailing = false
2034
+ } catch (defect) {
2035
+ if (!node.writeFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a leaving node's write failed", Cause.die(defect)), { id: node.id }))
2036
+ node.writeFailing = true
2037
+ }
1995
2038
  return
1996
2039
  }
1997
2040
  sink.write(node.id, patch)
@@ -2053,12 +2096,35 @@ export const makeProjectionSystem = (
2053
2096
  for (const key of corrector.writes) out[key] = String(latest)
2054
2097
  continue
2055
2098
  }
2056
- const corrected = String(corrector.correct(latest, { target: node.lastTarget as Box.Box, treeScale, projectionDelta: node.lastDelta }))
2099
+ // #979, row 5 (ADR-0074): the app's corrector is its node's own. One that throws leaves its keys
2100
+ // at their last value this frame, and the node's other keys and every other node go on: before,
2101
+ // it failed the coordinator's run, or the Measure pass that seeded it, so nothing moved.
2102
+ let corrected: string
2103
+ try {
2104
+ corrected = String(corrector.correct(latest, { target: node.lastTarget as Box.Box, treeScale, projectionDelta: node.lastDelta }))
2105
+ const failing = node.failingCorrectors
2106
+ if (Predicate.isNotUndefined(failing)) failing.delete(corrector)
2107
+ } catch (defect) {
2108
+ correctorFailed(node, corrector, defect)
2109
+ continue
2110
+ }
2057
2111
  for (const key of corrector.writes) out[key] = corrected
2058
2112
  }
2059
2113
  return out
2060
2114
  }
2061
2115
 
2116
+ /** `corrector` threw for `node`: reported at its first throw of a run, until a clean call. */
2117
+ const correctorFailed = (node: NodeState, corrector: CustomCorrector, defect: unknown): void => {
2118
+ let failing = node.failingCorrectors
2119
+ if (Predicate.isUndefined(failing)) {
2120
+ failing = new Set()
2121
+ node.failingCorrectors = failing
2122
+ }
2123
+ if (failing.has(corrector)) return
2124
+ failing.add(corrector)
2125
+ runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a scale corrector failed", Cause.die(defect)), { id: node.id, key: corrector.key }))
2126
+ }
2127
+
2062
2128
  /** An app's corrector's value for `node` (#443): its own for the key, a number or a string, else its base, else none. */
2063
2129
  const latestFor = (node: NodeState, corrector: CustomCorrector, values: Readonly<Record<string, unknown>>): string | number | undefined => {
2064
2130
  const own = values[corrector.key]
@@ -3597,7 +3663,7 @@ export const makeProjectionSystem = (
3597
3663
  UndefinedOr.match(wrapperLinkOf(child, twin.shift), { onUndefined: () => links, onDefined: (link) => withLink(links, link, child) }),
3598
3664
  ),
3599
3665
  })
3600
- const follower = makeLeavingNode(leaver.element, layoutId, last, undefined, undefined, chain)
3666
+ const follower = makeLeavingNode(leaver.id, leaver.element, layoutId, last, undefined, undefined, chain)
3601
3667
  follower.fade = readOpacity(leaver.element)
3602
3668
  addNode(follower)
3603
3669
  elementToNode.set(leaver.element, follower)
@@ -3629,7 +3695,7 @@ export const makeProjectionSystem = (
3629
3695
  const holdNode = (node: NodeState): void => {
3630
3696
  const last = lastPassOf(node)
3631
3697
  if (Predicate.isUndefined(last)) return
3632
- hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false })
3698
+ hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false })
3633
3699
  }
3634
3700
 
3635
3701
  /**
@@ -3648,7 +3714,7 @@ export const makeProjectionSystem = (
3648
3714
  // Seen as it goes, at the page's scroll now (#480): a scroll after, a router's at a navigation, comes out.
3649
3715
  const seed = UndefinedOr.map(seedBox, (box) => seedOf(node, layoutId, box, look, measureDocumentScroll()))
3650
3716
  if (Predicate.isUndefined(last) && Predicate.isUndefined(seedBox)) return
3651
- hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false })
3717
+ hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false })
3652
3718
  }
3653
3719
 
3654
3720
  /**
@@ -3764,12 +3830,13 @@ export const makeProjectionSystem = (
3764
3830
  /** The nodes a Measure round measured that have an `onLayoutMeasure` (#443), told at its end. Reused: most rounds tell none. */
3765
3831
  const measuredNow: Array<{ readonly node: NodeState; readonly box: Box.Box; readonly prev: Box.Box | undefined }> = []
3766
3832
 
3767
- /** Call an app's measure hook (#443): a throw is reported, and the pass goes on. */
3768
- const callMeasureHook = (hook: () => void, name: string): void => {
3833
+ /** Call `node`'s measure hook `name` (#443): a throw is reported at its run's first, and the pass goes on. */
3834
+ const callMeasureHook = (node: NodeState, hook: () => void, name: "onBeforeLayoutMeasure" | "onLayoutMeasure"): void => {
3769
3835
  try {
3770
3836
  hook()
3837
+ Failing.endRunOf(node, name)
3771
3838
  } catch (defect) {
3772
- runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)))
3839
+ if (Failing.firstThrowOf(node, name)) runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)))
3773
3840
  }
3774
3841
  }
3775
3842
 
@@ -3812,9 +3879,26 @@ export const makeProjectionSystem = (
3812
3879
  const savedTransforms: Array<string | undefined> = []
3813
3880
  for (const node of ordered) {
3814
3881
  // Its app's `onBeforeLayoutMeasure` (#443), before its transform is held for the read.
3815
- if (Predicate.isNotUndefined(node.onBeforeMeasure)) callMeasureHook(node.onBeforeMeasure, "onBeforeLayoutMeasure")
3882
+ if (Predicate.isNotUndefined(node.onBeforeMeasure)) callMeasureHook(node, node.onBeforeMeasure, "onBeforeLayoutMeasure")
3816
3883
  const own = node.element.style.transform
3817
- const held = heldTransformFor(node)
3884
+ // Its Transform template's, `none` for a node with none (Motion's `resetTransform`), which is
3885
+ // what an at-rest node already draws (#674). Per pass per node: a field read.
3886
+ let held = "none"
3887
+ const template = node.heldTransform
3888
+ // #979, row 13 (ADR-0074): the app's template is its node's own. One that throws holds its node
3889
+ // where its last call did, so a static part of it is still measured, and the pass goes on:
3890
+ // before, the throw ended it here, every node held before it left held and nothing seeded.
3891
+ if (Predicate.isNotUndefined(template)) {
3892
+ try {
3893
+ held = template()
3894
+ node.lastHeld = held
3895
+ if (node.heldFailing) node.heldFailing = false
3896
+ } catch (defect) {
3897
+ if (!node.heldFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a transformTemplate failed at a Measure pass", Cause.die(defect)), { id: node.id }))
3898
+ node.heldFailing = true
3899
+ held = node.lastHeld
3900
+ }
3901
+ }
3818
3902
  // A server's Appear animation not yet handed off (#245, ADR-0044 *Amendment (#245)*): its CSS
3819
3903
  // transform beats an inline one, but not an important one. Its timeline runs on; the restore
3820
3904
  // below gives the old value back, at its own priority.
@@ -4011,6 +4095,11 @@ export const makeProjectionSystem = (
4011
4095
  // --- WRITE: FLIP detection + seeding, on the already-measured boxes. ------
4012
4096
  for (let i = 0; i < ordered.length; i++) {
4013
4097
  const node = ordered[i]
4098
+ // A node never measured whose element isn't on the page yet (#1024): held off it by a boundary
4099
+ // that waits, as a Solid 2 `<Loading>` holds an element whose ward was made outside it, it reads
4100
+ // 0x0 at the viewport's origin, and a later pass would grow it from there. It's left unmeasured:
4101
+ // its first box is the one a pass reads once it's on the page, which doesn't animate.
4102
+ if (Bool.and(Predicate.isUndefined(node.retained), Bool.not(node.element.isConnected))) continue
4014
4103
  // A `display: contents` element has no box (ADR-0009 *Amendment (#9)*): its rect is 0x0 at
4015
4104
  // the viewport's origin, which a scroll would read as a move. It never animates or carries a
4016
4105
  // delta, and what it holds projects as if it weren't there.
@@ -4268,7 +4357,7 @@ export const makeProjectionSystem = (
4268
4357
  if (measuredNow.length > 0) {
4269
4358
  for (const { node, box, prev } of measuredNow.splice(0)) {
4270
4359
  const tell = node.onMeasure
4271
- if (Predicate.isNotUndefined(tell)) callMeasureHook(() => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure")
4360
+ if (Predicate.isNotUndefined(tell)) callMeasureHook(node, () => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure")
4272
4361
  }
4273
4362
  }
4274
4363
  deriveGroup(groupOf(changed))
@@ -4400,7 +4489,7 @@ export const makeProjectionSystem = (
4400
4489
  inAfterTickStep = false
4401
4490
  }
4402
4491
  if (Arr.isArrayNonEmpty(flightStarts)) {
4403
- for (const node of flightStarts.splice(0)) callAppIfAny(node.onLayoutAnimationStart(), "onLayoutAnimationStart")
4492
+ for (const node of flightStarts.splice(0)) callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart")
4404
4493
  }
4405
4494
  return stepped.size
4406
4495
  }
@@ -4437,6 +4526,7 @@ export const makeProjectionSystem = (
4437
4526
  }
4438
4527
 
4439
4528
  /** Call an app's `callback` (#191): one that throws is reported, and the engine goes on. */
4529
+ // Each time: an `onSettled` is called once (#979 group I, ADR-0074 decision 3).
4440
4530
  const callApp = (callback: () => void, name: string): void => {
4441
4531
  try {
4442
4532
  callback()
@@ -4445,9 +4535,22 @@ export const makeProjectionSystem = (
4445
4535
  }
4446
4536
  }
4447
4537
 
4448
- /** The app's callback, if it gave one: called as {@link callApp} calls it. */
4449
- const callAppIfAny = (callback: Option.Option<() => void>, name: string): void => {
4450
- if (Option.isSome(callback)) callApp(callback.value, name)
4538
+ /**
4539
+ * `node`'s app callback `name`, read from `callbackOf` and called if it gave one: a throw from either is
4540
+ * reported at the first of a run of its throws, its next clean call ending the run, and the engine goes on.
4541
+ */
4542
+ // #191; once a run, #979 group I (row 29). The read in the try too (ADR-0074's open list): a binding's
4543
+ // getter can be the app's config (Solid 1's `createWard` accessor), and one that threw came out of the
4544
+ // tick's hook, the nodes after it in the tick's list missing their callbacks.
4545
+ const callAppIfAny = (node: NodeState, callbackOf: () => Option.Option<() => void>, name: LayoutCallbackName): void => {
4546
+ try {
4547
+ const callback = callbackOf()
4548
+ if (Option.isNone(callback)) return
4549
+ callback.value()
4550
+ Failing.endRunOf(node, name)
4551
+ } catch (defect) {
4552
+ if (Failing.firstThrowOf(node, name)) runtime.runFork(Report.failure(`wardic.projection: ${name} failed`, Cause.die(defect)))
4553
+ }
4451
4554
  }
4452
4555
 
4453
4556
  /** Whether `flight` still runs on `node`: not landed, not replaced by a restart, not cut short, not unmounted. */
@@ -4497,13 +4600,13 @@ export const makeProjectionSystem = (
4497
4600
  tickFrame = frameTime()
4498
4601
  tickDt = dt
4499
4602
  if (Arr.isArrayNonEmpty(flightStarts)) {
4500
- for (const node of flightStarts.splice(0)) callAppIfAny(node.onLayoutAnimationStart(), "onLayoutAnimationStart")
4603
+ for (const node of flightStarts.splice(0)) callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart")
4501
4604
  }
4502
4605
  if (Arr.isArrayNonEmpty(flightLands)) {
4503
- for (const node of flightLands.splice(0)) callAppIfAny(node.onLayoutAnimationComplete(), "onLayoutAnimationComplete")
4606
+ for (const node of flightLands.splice(0)) callAppIfAny(node, node.onLayoutAnimationComplete, "onLayoutAnimationComplete")
4504
4607
  }
4505
4608
  if (Arr.isArrayNonEmpty(releaseEnds)) {
4506
- for (const node of releaseEnds.splice(0)) callAppIfAny(node.onReleaseEnd(), "onDragTransitionEnd")
4609
+ for (const node of releaseEnds.splice(0)) callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd")
4507
4610
  }
4508
4611
  checkSettlings()
4509
4612
  return undefined
@@ -4754,15 +4857,33 @@ export const makeProjectionSystem = (
4754
4857
  finishSettled(settled)
4755
4858
  }
4756
4859
 
4860
+ // A flight takes none of a long task's time from before it began (#1028, ADR-0027 *Amendment (#1028)*):
4861
+ // #1026's rule, kept per flight, since the coordinator is one run on the Frame loop for every node. A node
4862
+ // already moving catches up, as before.
4863
+
4864
+ /**
4865
+ * The dt `flight` steps at, in a step at the tick's `dt`: that, less what it owes of a long task's time. A
4866
+ * dt-0 step (the coordinator's again, after a Late round) leaves what it owes as it was, as the Frame loop's
4867
+ * own does. Per frame: a field read, and nothing made.
4868
+ */
4869
+ const flightDt = (flight: Flight, dt: number): number => {
4870
+ const owed = flight.owed
4871
+ if (owed === 0) return dt
4872
+ if (dt === 0) return dt
4873
+ flight.owed = ticks.owedAfter(owed)
4874
+ return ticks.owingDt(owed, dt)
4875
+ }
4876
+
4757
4877
  /**
4758
4878
  * Step `node`'s layout animation, if one runs; whether it is at rest (ADR-0009 *Amendment (#171)*):
4759
4879
  * a spring stepped toward 1 (`Spring.step` holds its delay; `Spring.stepTimed` for one that ends
4760
- * at its duration, #359), or a tween's eased progress by its time, held at 0 through its delay. Per
4761
- * frame: statement `if`s, written in place.
4880
+ * at its duration, #359), or a tween's eased progress by its time, held at 0 through its delay. At
4881
+ * its own dt (`flightDt`). Per frame: statement `if`s, written in place.
4762
4882
  */
4763
- const stepFlight = (node: NodeState, dt: number): boolean => {
4883
+ const stepFlight = (node: NodeState, tickDt: number): boolean => {
4764
4884
  const flight = node.flight
4765
4885
  if (Predicate.isUndefined(flight)) return true
4886
+ const dt = flightDt(flight, tickDt)
4766
4887
  flight.elapsed += dt
4767
4888
  const timing = flight.timing
4768
4889
  if (timing.kind === "spring") {
@@ -4780,7 +4901,17 @@ export const makeProjectionSystem = (
4780
4901
  const active = flight.elapsed - timing.delay
4781
4902
  if (active < 0) return false
4782
4903
  const t = Math.min(1, active / timing.duration)
4783
- flight.position = timing.ease(t)
4904
+ // #979, row 5 (ADR-0074): the app's ease is its node's own. One that throws leaves the node where
4905
+ // its last ease put it, landing on its target on time, and the coordinator's other nodes go on:
4906
+ // before, it failed the coordinator's run, so every layout animation stopped.
4907
+ try {
4908
+ flight.position = timing.ease(t)
4909
+ if (node.easeFailing) node.easeFailing = false
4910
+ } catch (defect) {
4911
+ if (!node.easeFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a layout animation's ease failed", Cause.die(defect)), { id: node.id }))
4912
+ node.easeFailing = true
4913
+ if (t >= 1) flight.position = 1
4914
+ }
4784
4915
  return t >= 1
4785
4916
  }
4786
4917
 
@@ -5156,9 +5287,10 @@ export const makeProjectionSystem = (
5156
5287
  /**
5157
5288
  * The coordinator's end, told apart (ADR-0027, decision 7): a settle, or an
5158
5289
  * interruption (a stop outside its step, the system's dispose), is nothing; anything
5159
- * else (a step that threw, the Frame loop's own failure) is logged and reported
5290
+ * else (a step whose own code threw, the Frame loop's own failure) is logged and reported
5160
5291
  * (`Report.failure`, ADR-0030 decision 4). Its nodes then wait where the last step left
5161
- * them, and the next trigger starts a fresh run.
5292
+ * them, and the next trigger starts a fresh run. An app's code on the step is its node's
5293
+ * own, caught where it's called (#979, row 5), so it never ends the run.
5162
5294
  */
5163
5295
  const coordinatorEnded = (exit: Exit.Exit<unknown>): Effect.Effect<void> =>
5164
5296
  Exit.match(exit, {
@@ -5198,7 +5330,7 @@ export const makeProjectionSystem = (
5198
5330
  FiberHandle.setUnsafe(
5199
5331
  coordinator,
5200
5332
  runtime.runFork(
5201
- FrameLoop.FrameLoop.use((loop) => loop.runLast(coordinatorMachine(), ignoreFrame)).pipe(
5333
+ FrameLoop.FrameLoop.use((loop) => loop.runLast(coordinatorMachine(), ignoreFrame, ON_THE_FRAME_TIMELINE)).pipe(
5202
5334
  Effect.onExit(coordinatorEnded),
5203
5335
  Effect.asVoid,
5204
5336
  ),
@@ -5300,6 +5432,7 @@ export const makeProjectionSystem = (
5300
5432
  * its last pass.
5301
5433
  */
5302
5434
  const makeLeavingNode = (
5435
+ id: string,
5303
5436
  el: HTMLElement,
5304
5437
  layoutId: string | undefined,
5305
5438
  recent: LastPass,
@@ -5307,7 +5440,8 @@ export const makeProjectionSystem = (
5307
5440
  layoutAnchor: Point.Point | false | undefined,
5308
5441
  chain: ReadonlyArray<PaintLink> | undefined,
5309
5442
  ): NodeState => ({
5310
- id: "", // a leaving Follower is driven via the Renderer, not the gate — no id needed
5443
+ // Driven through the Renderer, not the gate: its id names it in its reports alone.
5444
+ id,
5311
5445
  element: el,
5312
5446
  transition: Option.none,
5313
5447
  path: Option.none,
@@ -5327,6 +5461,7 @@ export const makeProjectionSystem = (
5327
5461
  heldTransform: undefined,
5328
5462
  onBeforeMeasure: undefined,
5329
5463
  onMeasure: undefined,
5464
+ failing: undefined,
5330
5465
  blend: undefined,
5331
5466
  seedBlend: undefined,
5332
5467
  seedScroll: undefined,
@@ -5360,6 +5495,11 @@ export const makeProjectionSystem = (
5360
5495
  corrected: false,
5361
5496
  customBases: readCustomBases(el),
5362
5497
  customCorrected: false,
5498
+ easeFailing: false,
5499
+ failingCorrectors: undefined,
5500
+ writeFailing: false,
5501
+ heldFailing: false,
5502
+ lastHeld: "none",
5363
5503
  isScroll: false,
5364
5504
  scroll: { x: 0, y: 0 },
5365
5505
  isScrollRoot: false,
@@ -5441,7 +5581,7 @@ export const makeProjectionSystem = (
5441
5581
  if (Predicate.isUndefined(last)) return false
5442
5582
  const stack = stacks.get(layoutId)
5443
5583
  if (Predicate.isUndefined(stack)) return false
5444
- const follower = makeLeavingNode(el, layoutId, last, onDone, undefined, undefined)
5584
+ const follower = makeLeavingNode(recent.id, el, layoutId, last, onDone, undefined, undefined)
5445
5585
  recent.reintroduced = true
5446
5586
  addNode(follower)
5447
5587
  elementToNode.set(el, follower)
@@ -5516,7 +5656,7 @@ export const makeProjectionSystem = (
5516
5656
  // Not onto a Lead that is leaving itself (#682): it has no handover to ride.
5517
5657
  if (lead.leaving) return
5518
5658
  if (Bool.not(takesOver(lead))) return
5519
- const twin = makeLeavingNode(inner, held.layoutId, last, () => undefined, undefined, chainOf(held))
5659
+ const twin = makeLeavingNode(recent.id, inner, held.layoutId, last, () => undefined, undefined, chainOf(held))
5520
5660
  recent.reintroduced = true
5521
5661
  addNode(twin)
5522
5662
  elementToNode.set(inner, twin)
@@ -5539,7 +5679,7 @@ export const makeProjectionSystem = (
5539
5679
  if (recent.reintroduced) return
5540
5680
  if (Bool.not(contains(container, inner))) return
5541
5681
  recent.reintroduced = true
5542
- const node = makeLeavingNode(inner, undefined, last, undefined, recent.layoutAnchor, undefined)
5682
+ const node = makeLeavingNode(recent.id, inner, undefined, last, undefined, recent.layoutAnchor, undefined)
5543
5683
  addNode(node)
5544
5684
  elementToNode.set(inner, node)
5545
5685
  carried.push(node)
@@ -5870,6 +6010,7 @@ export const makeProjectionSystem = (
5870
6010
  heldTransform: opts.heldTransform,
5871
6011
  onBeforeMeasure: opts.onBeforeMeasure,
5872
6012
  onMeasure: opts.onMeasure,
6013
+ failing: undefined,
5873
6014
  blend: undefined,
5874
6015
  seedBlend: undefined,
5875
6016
  seedScroll: undefined,
@@ -5903,6 +6044,11 @@ export const makeProjectionSystem = (
5903
6044
  corrected: false,
5904
6045
  customBases: undefined,
5905
6046
  customCorrected: false,
6047
+ easeFailing: false,
6048
+ failingCorrectors: undefined,
6049
+ writeFailing: false,
6050
+ heldFailing: false,
6051
+ lastHeld: "none",
5906
6052
  isScroll: opts.layoutScroll === true,
5907
6053
  scroll: { x: 0, y: 0 },
5908
6054
  isScrollRoot: false,
@@ -6069,7 +6215,7 @@ export const makeProjectionSystem = (
6069
6215
  if (active.size === 0) stopTicking()
6070
6216
  // No release runs, so it has ended (#273): told from a microtask, as Motion's instant one resolves.
6071
6217
  queueMicrotask(() => {
6072
- if (nodes.has(node)) callAppIfAny(node.onReleaseEnd(), "onDragTransitionEnd")
6218
+ if (nodes.has(node)) callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd")
6073
6219
  })
6074
6220
  return
6075
6221
  }