@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
@@ -64,6 +64,7 @@
64
64
  import * as Box from "@wardic/core/Box";
65
65
  import * as Clock from "@wardic/core/Clock";
66
66
  import * as FrameLoop from "@wardic/core/FrameLoop";
67
+ import * as FirstSteps from "@wardic/core/unstable/FirstSteps";
67
68
  import * as Inertia from "@wardic/core/Inertia";
68
69
  import * as Microtask from "@wardic/core/Microtask";
69
70
  import * as Probe from "@wardic/core/Probe";
@@ -98,6 +99,7 @@ import { pending as appearRuns } from "./appear-slot.js";
98
99
  import * as Report from "@wardic/core/unstable/Report";
99
100
  import { blendRadius, borderRadiusCorrector, isUnitScale, SCALE_CORRECTORS, scaleRadius, ZERO_RADIUS } from "./scale-correction.js";
100
101
  import { dashCase } from "./svg.js";
102
+ import * as Failing from "./failing.js";
101
103
  /** How many pass -> flush rounds one Measure pass runs before the rest waits for the next task (ADR-0018). */
102
104
  const MAX_ROUNDS = 5;
103
105
  /**
@@ -107,6 +109,8 @@ const MAX_ROUNDS = 5;
107
109
  const COORDINATOR_RUNNING = { value: undefined, done: false };
108
110
  const COORDINATOR_SETTLED = { value: undefined, done: true };
109
111
  const ignoreFrame = () => undefined;
112
+ /** The coordinator's run keeps the frame timeline's time: each flight keeps the late-frame rule itself (#1028). */
113
+ const ON_THE_FRAME_TIMELINE = { onFrameTimeline: true };
110
114
  /** Identity tree-scale (no ancestor scaling). */
111
115
  const TREE_SCALE_IDENTITY = { x: 1, y: 1 };
112
116
  /** Default relative-projection anchor (top-left) when a node sets no `layoutAnchor` (ADR-0013). */
@@ -364,7 +368,17 @@ const timingOf = (transition) => Match.value(transition).pipe(Match.discriminato
364
368
  /** A flight already landed: what reduced motion starts (ADR-0029), at 1 with no delay, settling on its first step. */
365
369
  const LANDED = springTiming(Spring.resolve({}));
366
370
  /** A flight at 1 on {@link LANDED}: it ends on its first step, the node on its new box. */
367
- const landedFlight = () => ({ position: 1, elapsed: 0, spring: Spring.init({ from: 1 }), timing: LANDED, started: false, landed: false, curve: undefined });
371
+ // It owes nothing (#1028): it lands at its first step, whatever its dt.
372
+ const landedFlight = () => ({
373
+ position: 1,
374
+ elapsed: 0,
375
+ spring: Spring.init({ from: 1 }),
376
+ timing: LANDED,
377
+ started: false,
378
+ landed: false,
379
+ curve: undefined,
380
+ owed: 0,
381
+ });
368
382
  /** Motion's distance floor for a curved layout animation (#438): a shift shorter than this goes straight. */
369
383
  const MIN_CURVE_DISTANCE = 20;
370
384
  /** No links: an ancestor that doesn't move the twin, or the top of the chain. */
@@ -576,17 +590,6 @@ const NO_TRANSLATE = { x: 0, y: 0 };
576
590
  const NO_OWN_TRANSLATE = () => NO_TRANSLATE;
577
591
  /** No values registered for an element (#443): an app's corrector reads its base then. */
578
592
  const NO_VALUES = {};
579
- /**
580
- * The transform a Measure pass holds `node` at (#443): its Transform template's, `none` for a node
581
- * with none (Motion's `resetTransform`), which is what an at-rest node already draws (#674). Per pass
582
- * per node: a field read and an early return.
583
- */
584
- const heldTransformFor = (node) => {
585
- const held = node.heldTransform;
586
- if (Predicate.isUndefined(held))
587
- return "none";
588
- return held();
589
- };
590
593
  /** No own rotation or opacity of its own: a node the binding gives none, or a leaving one (*Amendment (#166)*). */
591
594
  const NO_OWN_ROTATE = () => 0;
592
595
  const NO_OWN_OPACITY = () => 1;
@@ -668,7 +671,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
668
671
  * transition read now, Motion's default with none, its delay held first, and with no velocity
669
672
  * (Motion's). When reduced motion applies to `node` (ADR-0029), or its animations are skipped
670
673
  * (#468), at 1 with no delay, so the node lands on its new box at once and the flight ends on its
671
- * first step.
674
+ * first step. Stamped with when it began and what it owes of a long task's time (#1028, `flightDt`).
672
675
  */
673
676
  const startFlight = (node) => Bool.match(Bool.or(node.skipAnimations(), Bool.and(node.respectReducedMotion(), node.reducedMotion())), {
674
677
  onTrue: landedFlight,
@@ -677,7 +680,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
677
680
  // this one animation: reported, and the node lands, as reduced motion lands it.
678
681
  try {
679
682
  const timing = timingOf(Option.getOrElse(node.transition(), () => DEFAULT_LAYOUT_TRANSITION));
680
- return { position: 0, elapsed: 0, spring: Spring.init({}), timing, started: false, landed: false, curve: curveOf(node) };
683
+ return { position: 0, elapsed: 0, spring: Spring.init({}), timing, started: false, landed: false, curve: curveOf(node), owed: ticks.madeOwing() };
681
684
  }
682
685
  catch (defect) {
683
686
  runtime.runFork(Report.failure("wardic.projection: layout transition rejected", Cause.die(defect)));
@@ -798,6 +801,10 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
798
801
  // The Environment's Frame loop: the coordinator runs on it, the engine's hook is on its ticks, and a
799
802
  // trigger reads whether its Late window is open (#673, #680).
800
803
  const loop = runtime.runSync(Effect.service(FrameLoop.FrameLoop));
804
+ // Its ticks as the late-frame rule reads them (#1028, core's `unstable/FirstSteps`): each flight keeps the
805
+ // rule, as a Batch's members do, the coordinator's run on the frame timeline. Read once; a loop that
806
+ // carries no reader (a test's own) is read as one under which nothing owes.
807
+ const ticks = Option.getOrElse(FirstSteps.readerOf(loop), () => FirstSteps.owingNothing);
801
808
  // Whether the coordinator's step is running: a stop from inside it settles the run.
802
809
  let inStep = false;
803
810
  // The turn a turning flight's curve gives at its target just placed (#438), for `derive` to draw:
@@ -925,7 +932,19 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
925
932
  const patch = projectionPatchOf(value, corrected);
926
933
  // A leaving node is driven directly: its gate registration is gone.
927
934
  if (node.leaving) {
928
- renderer.commit(node.element, renderer.project(withExitValues(node, patch)));
935
+ // #979, row 5 (ADR-0074): as the gate takes each element's write on its own (#969), a leaver's
936
+ // write that throws (its Transform template's, say) leaves it as it was drawn, and every other
937
+ // node goes on: before, it failed the coordinator's run, so every layout animation stopped.
938
+ try {
939
+ renderer.commit(node.element, renderer.project(withExitValues(node, patch)));
940
+ if (node.writeFailing)
941
+ node.writeFailing = false;
942
+ }
943
+ catch (defect) {
944
+ if (!node.writeFailing)
945
+ runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a leaving node's write failed", Cause.die(defect)), { id: node.id }));
946
+ node.writeFailing = true;
947
+ }
929
948
  return;
930
949
  }
931
950
  sink.write(node.id, patch);
@@ -992,12 +1011,37 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
992
1011
  out[key] = String(latest);
993
1012
  continue;
994
1013
  }
995
- const corrected = String(corrector.correct(latest, { target: node.lastTarget, treeScale, projectionDelta: node.lastDelta }));
1014
+ // #979, row 5 (ADR-0074): the app's corrector is its node's own. One that throws leaves its keys
1015
+ // at their last value this frame, and the node's other keys and every other node go on: before,
1016
+ // it failed the coordinator's run, or the Measure pass that seeded it, so nothing moved.
1017
+ let corrected;
1018
+ try {
1019
+ corrected = String(corrector.correct(latest, { target: node.lastTarget, treeScale, projectionDelta: node.lastDelta }));
1020
+ const failing = node.failingCorrectors;
1021
+ if (Predicate.isNotUndefined(failing))
1022
+ failing.delete(corrector);
1023
+ }
1024
+ catch (defect) {
1025
+ correctorFailed(node, corrector, defect);
1026
+ continue;
1027
+ }
996
1028
  for (const key of corrector.writes)
997
1029
  out[key] = corrected;
998
1030
  }
999
1031
  return out;
1000
1032
  };
1033
+ /** `corrector` threw for `node`: reported at its first throw of a run, until a clean call. */
1034
+ const correctorFailed = (node, corrector, defect) => {
1035
+ let failing = node.failingCorrectors;
1036
+ if (Predicate.isUndefined(failing)) {
1037
+ failing = new Set();
1038
+ node.failingCorrectors = failing;
1039
+ }
1040
+ if (failing.has(corrector))
1041
+ return;
1042
+ failing.add(corrector);
1043
+ runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a scale corrector failed", Cause.die(defect)), { id: node.id, key: corrector.key }));
1044
+ };
1001
1045
  /** An app's corrector's value for `node` (#443): its own for the key, a number or a string, else its base, else none. */
1002
1046
  const latestFor = (node, corrector, values) => {
1003
1047
  const own = values[corrector.key];
@@ -2556,7 +2600,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2556
2600
  onTrue: () => undefined,
2557
2601
  onFalse: () => UndefinedOr.map(twin.chain, (links) => UndefinedOr.match(wrapperLinkOf(child, twin.shift), { onUndefined: () => links, onDefined: (link) => withLink(links, link, child) })),
2558
2602
  });
2559
- const follower = makeLeavingNode(leaver.element, layoutId, last, undefined, undefined, chain);
2603
+ const follower = makeLeavingNode(leaver.id, leaver.element, layoutId, last, undefined, undefined, chain);
2560
2604
  follower.fade = readOpacity(leaver.element);
2561
2605
  addNode(follower);
2562
2606
  elementToNode.set(leaver.element, follower);
@@ -2592,7 +2636,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2592
2636
  const last = lastPassOf(node);
2593
2637
  if (Predicate.isUndefined(last))
2594
2638
  return;
2595
- hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false });
2639
+ hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false });
2596
2640
  };
2597
2641
  /**
2598
2642
  * Hold a disposed `layoutId` node (ADR-0010 *Amendment (#13)*): the last pass a presence
@@ -2611,7 +2655,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2611
2655
  const seed = UndefinedOr.map(seedBox, (box) => seedOf(node, layoutId, box, look, measureDocumentScroll()));
2612
2656
  if (Predicate.isUndefined(last) && Predicate.isUndefined(seedBox))
2613
2657
  return;
2614
- hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false });
2658
+ hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false });
2615
2659
  };
2616
2660
  /**
2617
2661
  * A disposed twin's Switch seed (ADR-0010 *Amendment (#13)*): handed straight to the twin that
@@ -2712,13 +2756,15 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2712
2756
  };
2713
2757
  /** The nodes a Measure round measured that have an `onLayoutMeasure` (#443), told at its end. Reused: most rounds tell none. */
2714
2758
  const measuredNow = [];
2715
- /** Call an app's measure hook (#443): a throw is reported, and the pass goes on. */
2716
- const callMeasureHook = (hook, name) => {
2759
+ /** Call `node`'s measure hook `name` (#443): a throw is reported at its run's first, and the pass goes on. */
2760
+ const callMeasureHook = (node, hook, name) => {
2717
2761
  try {
2718
2762
  hook();
2763
+ Failing.endRunOf(node, name);
2719
2764
  }
2720
2765
  catch (defect) {
2721
- runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)));
2766
+ if (Failing.firstThrowOf(node, name))
2767
+ runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)));
2722
2768
  }
2723
2769
  };
2724
2770
  /**
@@ -2760,9 +2806,29 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2760
2806
  for (const node of ordered) {
2761
2807
  // Its app's `onBeforeLayoutMeasure` (#443), before its transform is held for the read.
2762
2808
  if (Predicate.isNotUndefined(node.onBeforeMeasure))
2763
- callMeasureHook(node.onBeforeMeasure, "onBeforeLayoutMeasure");
2809
+ callMeasureHook(node, node.onBeforeMeasure, "onBeforeLayoutMeasure");
2764
2810
  const own = node.element.style.transform;
2765
- const held = heldTransformFor(node);
2811
+ // Its Transform template's, `none` for a node with none (Motion's `resetTransform`), which is
2812
+ // what an at-rest node already draws (#674). Per pass per node: a field read.
2813
+ let held = "none";
2814
+ const template = node.heldTransform;
2815
+ // #979, row 13 (ADR-0074): the app's template is its node's own. One that throws holds its node
2816
+ // where its last call did, so a static part of it is still measured, and the pass goes on:
2817
+ // before, the throw ended it here, every node held before it left held and nothing seeded.
2818
+ if (Predicate.isNotUndefined(template)) {
2819
+ try {
2820
+ held = template();
2821
+ node.lastHeld = held;
2822
+ if (node.heldFailing)
2823
+ node.heldFailing = false;
2824
+ }
2825
+ catch (defect) {
2826
+ if (!node.heldFailing)
2827
+ runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a transformTemplate failed at a Measure pass", Cause.die(defect)), { id: node.id }));
2828
+ node.heldFailing = true;
2829
+ held = node.lastHeld;
2830
+ }
2831
+ }
2766
2832
  // A server's Appear animation not yet handed off (#245, ADR-0044 *Amendment (#245)*): its CSS
2767
2833
  // transform beats an inline one, but not an important one. Its timeline runs on; the restore
2768
2834
  // below gives the old value back, at its own priority.
@@ -2968,6 +3034,12 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
2968
3034
  // --- WRITE: FLIP detection + seeding, on the already-measured boxes. ------
2969
3035
  for (let i = 0; i < ordered.length; i++) {
2970
3036
  const node = ordered[i];
3037
+ // A node never measured whose element isn't on the page yet (#1024): held off it by a boundary
3038
+ // that waits, as a Solid 2 `<Loading>` holds an element whose ward was made outside it, it reads
3039
+ // 0x0 at the viewport's origin, and a later pass would grow it from there. It's left unmeasured:
3040
+ // its first box is the one a pass reads once it's on the page, which doesn't animate.
3041
+ if (Bool.and(Predicate.isUndefined(node.retained), Bool.not(node.element.isConnected)))
3042
+ continue;
2971
3043
  // A `display: contents` element has no box (ADR-0009 *Amendment (#9)*): its rect is 0x0 at
2972
3044
  // the viewport's origin, which a scroll would read as a move. It never animates or carries a
2973
3045
  // delta, and what it holds projects as if it weren't there.
@@ -3227,7 +3299,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3227
3299
  for (const { node, box, prev } of measuredNow.splice(0)) {
3228
3300
  const tell = node.onMeasure;
3229
3301
  if (Predicate.isNotUndefined(tell))
3230
- callMeasureHook(() => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure");
3302
+ callMeasureHook(node, () => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure");
3231
3303
  }
3232
3304
  }
3233
3305
  deriveGroup(groupOf(changed));
@@ -3370,7 +3442,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3370
3442
  }
3371
3443
  if (Arr.isArrayNonEmpty(flightStarts)) {
3372
3444
  for (const node of flightStarts.splice(0))
3373
- callAppIfAny(node.onLayoutAnimationStart(), "onLayoutAnimationStart");
3445
+ callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart");
3374
3446
  }
3375
3447
  return stepped.size;
3376
3448
  };
@@ -3399,6 +3471,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3399
3471
  FiberSet.addUnsafe(taskFibers, runtime.runFork(Microtask.next.pipe(Effect.andThen(measurePass), Effect.tapCause((cause) => Report.failure("wardic.projection: measure pass failed", cause)))));
3400
3472
  };
3401
3473
  /** Call an app's `callback` (#191): one that throws is reported, and the engine goes on. */
3474
+ // Each time: an `onSettled` is called once (#979 group I, ADR-0074 decision 3).
3402
3475
  const callApp = (callback, name) => {
3403
3476
  try {
3404
3477
  callback();
@@ -3407,10 +3480,25 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3407
3480
  runtime.runFork(Report.failure(`wardic.projection: ${name} failed`, Cause.die(defect)));
3408
3481
  }
3409
3482
  };
3410
- /** The app's callback, if it gave one: called as {@link callApp} calls it. */
3411
- const callAppIfAny = (callback, name) => {
3412
- if (Option.isSome(callback))
3413
- callApp(callback.value, name);
3483
+ /**
3484
+ * `node`'s app callback `name`, read from `callbackOf` and called if it gave one: a throw from either is
3485
+ * reported at the first of a run of its throws, its next clean call ending the run, and the engine goes on.
3486
+ */
3487
+ // #191; once a run, #979 group I (row 29). The read in the try too (ADR-0074's open list): a binding's
3488
+ // getter can be the app's config (Solid 1's `createWard` accessor), and one that threw came out of the
3489
+ // tick's hook, the nodes after it in the tick's list missing their callbacks.
3490
+ const callAppIfAny = (node, callbackOf, name) => {
3491
+ try {
3492
+ const callback = callbackOf();
3493
+ if (Option.isNone(callback))
3494
+ return;
3495
+ callback.value();
3496
+ Failing.endRunOf(node, name);
3497
+ }
3498
+ catch (defect) {
3499
+ if (Failing.firstThrowOf(node, name))
3500
+ runtime.runFork(Report.failure(`wardic.projection: ${name} failed`, Cause.die(defect)));
3501
+ }
3414
3502
  };
3415
3503
  /** Whether `flight` still runs on `node`: not landed, not replaced by a restart, not cut short, not unmounted. */
3416
3504
  const stillFlying = ([node, flight]) => Bool.every([nodes.has(node), node.flight === flight, Bool.not(flight.landed)]);
@@ -3462,15 +3550,15 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3462
3550
  tickDt = dt;
3463
3551
  if (Arr.isArrayNonEmpty(flightStarts)) {
3464
3552
  for (const node of flightStarts.splice(0))
3465
- callAppIfAny(node.onLayoutAnimationStart(), "onLayoutAnimationStart");
3553
+ callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart");
3466
3554
  }
3467
3555
  if (Arr.isArrayNonEmpty(flightLands)) {
3468
3556
  for (const node of flightLands.splice(0))
3469
- callAppIfAny(node.onLayoutAnimationComplete(), "onLayoutAnimationComplete");
3557
+ callAppIfAny(node, node.onLayoutAnimationComplete, "onLayoutAnimationComplete");
3470
3558
  }
3471
3559
  if (Arr.isArrayNonEmpty(releaseEnds)) {
3472
3560
  for (const node of releaseEnds.splice(0))
3473
- callAppIfAny(node.onReleaseEnd(), "onDragTransitionEnd");
3561
+ callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd");
3474
3562
  }
3475
3563
  checkSettlings();
3476
3564
  return undefined;
@@ -3739,16 +3827,34 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3739
3827
  deriveAll();
3740
3828
  finishSettled(settled);
3741
3829
  };
3830
+ // A flight takes none of a long task's time from before it began (#1028, ADR-0027 *Amendment (#1028)*):
3831
+ // #1026's rule, kept per flight, since the coordinator is one run on the Frame loop for every node. A node
3832
+ // already moving catches up, as before.
3833
+ /**
3834
+ * 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
3835
+ * dt-0 step (the coordinator's again, after a Late round) leaves what it owes as it was, as the Frame loop's
3836
+ * own does. Per frame: a field read, and nothing made.
3837
+ */
3838
+ const flightDt = (flight, dt) => {
3839
+ const owed = flight.owed;
3840
+ if (owed === 0)
3841
+ return dt;
3842
+ if (dt === 0)
3843
+ return dt;
3844
+ flight.owed = ticks.owedAfter(owed);
3845
+ return ticks.owingDt(owed, dt);
3846
+ };
3742
3847
  /**
3743
3848
  * Step `node`'s layout animation, if one runs; whether it is at rest (ADR-0009 *Amendment (#171)*):
3744
3849
  * a spring stepped toward 1 (`Spring.step` holds its delay; `Spring.stepTimed` for one that ends
3745
- * at its duration, #359), or a tween's eased progress by its time, held at 0 through its delay. Per
3746
- * frame: statement `if`s, written in place.
3850
+ * at its duration, #359), or a tween's eased progress by its time, held at 0 through its delay. At
3851
+ * its own dt (`flightDt`). Per frame: statement `if`s, written in place.
3747
3852
  */
3748
- const stepFlight = (node, dt) => {
3853
+ const stepFlight = (node, tickDt) => {
3749
3854
  const flight = node.flight;
3750
3855
  if (Predicate.isUndefined(flight))
3751
3856
  return true;
3857
+ const dt = flightDt(flight, tickDt);
3752
3858
  flight.elapsed += dt;
3753
3859
  const timing = flight.timing;
3754
3860
  if (timing.kind === "spring") {
@@ -3767,7 +3873,21 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
3767
3873
  if (active < 0)
3768
3874
  return false;
3769
3875
  const t = Math.min(1, active / timing.duration);
3770
- flight.position = timing.ease(t);
3876
+ // #979, row 5 (ADR-0074): the app's ease is its node's own. One that throws leaves the node where
3877
+ // its last ease put it, landing on its target on time, and the coordinator's other nodes go on:
3878
+ // before, it failed the coordinator's run, so every layout animation stopped.
3879
+ try {
3880
+ flight.position = timing.ease(t);
3881
+ if (node.easeFailing)
3882
+ node.easeFailing = false;
3883
+ }
3884
+ catch (defect) {
3885
+ if (!node.easeFailing)
3886
+ runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a layout animation's ease failed", Cause.die(defect)), { id: node.id }));
3887
+ node.easeFailing = true;
3888
+ if (t >= 1)
3889
+ flight.position = 1;
3890
+ }
3771
3891
  return t >= 1;
3772
3892
  };
3773
3893
  /** `node`'s Release offset at rest: its end told once, after this tick's flush (#273). Per frame: statement `if`s. */
@@ -4158,9 +4278,10 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4158
4278
  /**
4159
4279
  * The coordinator's end, told apart (ADR-0027, decision 7): a settle, or an
4160
4280
  * interruption (a stop outside its step, the system's dispose), is nothing; anything
4161
- * else (a step that threw, the Frame loop's own failure) is logged and reported
4281
+ * else (a step whose own code threw, the Frame loop's own failure) is logged and reported
4162
4282
  * (`Report.failure`, ADR-0030 decision 4). Its nodes then wait where the last step left
4163
- * them, and the next trigger starts a fresh run.
4283
+ * them, and the next trigger starts a fresh run. An app's code on the step is its node's
4284
+ * own, caught where it's called (#979, row 5), so it never ends the run.
4164
4285
  */
4165
4286
  const coordinatorEnded = (exit) => Exit.match(exit, {
4166
4287
  onSuccess: () => Effect.void,
@@ -4189,7 +4310,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4189
4310
  // A popped leaver to keep where it was seen (#480) takes one frame, with nothing active too.
4190
4311
  if (coordinating() || active.size + seenKeeps.size === 0)
4191
4312
  return;
4192
- FiberHandle.setUnsafe(coordinator, runtime.runFork(FrameLoop.FrameLoop.use((loop) => loop.runLast(coordinatorMachine(), ignoreFrame)).pipe(Effect.onExit(coordinatorEnded), Effect.asVoid)));
4313
+ FiberHandle.setUnsafe(coordinator, runtime.runFork(FrameLoop.FrameLoop.use((loop) => loop.runLast(coordinatorMachine(), ignoreFrame, ON_THE_FRAME_TIMELINE)).pipe(Effect.onExit(coordinatorEnded), Effect.asVoid)));
4193
4314
  };
4194
4315
  /**
4195
4316
  * Stop the coordinator: nothing is active. Inside its own step (its settle, or a node
@@ -4293,8 +4414,9 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4293
4414
  * `chain`, its conversions follow those ancestors live (ADR-0010 *Amendment (#181)*); without, as of
4294
4415
  * its last pass.
4295
4416
  */
4296
- const makeLeavingNode = (el, layoutId, recent, onDone, layoutAnchor, chain) => ({
4297
- id: "", // a leaving Follower is driven via the Renderer, not the gate — no id needed
4417
+ const makeLeavingNode = (id, el, layoutId, recent, onDone, layoutAnchor, chain) => ({
4418
+ // Driven through the Renderer, not the gate: its id names it in its reports alone.
4419
+ id,
4298
4420
  element: el,
4299
4421
  transition: Option.none,
4300
4422
  path: Option.none,
@@ -4314,6 +4436,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4314
4436
  heldTransform: undefined,
4315
4437
  onBeforeMeasure: undefined,
4316
4438
  onMeasure: undefined,
4439
+ failing: undefined,
4317
4440
  blend: undefined,
4318
4441
  seedBlend: undefined,
4319
4442
  seedScroll: undefined,
@@ -4347,6 +4470,11 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4347
4470
  corrected: false,
4348
4471
  customBases: readCustomBases(el),
4349
4472
  customCorrected: false,
4473
+ easeFailing: false,
4474
+ failingCorrectors: undefined,
4475
+ writeFailing: false,
4476
+ heldFailing: false,
4477
+ lastHeld: "none",
4350
4478
  isScroll: false,
4351
4479
  scroll: { x: 0, y: 0 },
4352
4480
  isScrollRoot: false,
@@ -4429,7 +4557,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4429
4557
  const stack = stacks.get(layoutId);
4430
4558
  if (Predicate.isUndefined(stack))
4431
4559
  return false;
4432
- const follower = makeLeavingNode(el, layoutId, last, onDone, undefined, undefined);
4560
+ const follower = makeLeavingNode(recent.id, el, layoutId, last, onDone, undefined, undefined);
4433
4561
  recent.reintroduced = true;
4434
4562
  addNode(follower);
4435
4563
  elementToNode.set(el, follower);
@@ -4503,7 +4631,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4503
4631
  return;
4504
4632
  if (Bool.not(takesOver(lead)))
4505
4633
  return;
4506
- const twin = makeLeavingNode(inner, held.layoutId, last, () => undefined, undefined, chainOf(held));
4634
+ const twin = makeLeavingNode(recent.id, inner, held.layoutId, last, () => undefined, undefined, chainOf(held));
4507
4635
  recent.reintroduced = true;
4508
4636
  addNode(twin);
4509
4637
  elementToNode.set(inner, twin);
@@ -4529,7 +4657,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4529
4657
  if (Bool.not(contains(container, inner)))
4530
4658
  return;
4531
4659
  recent.reintroduced = true;
4532
- const node = makeLeavingNode(inner, undefined, last, undefined, recent.layoutAnchor, undefined);
4660
+ const node = makeLeavingNode(recent.id, inner, undefined, last, undefined, recent.layoutAnchor, undefined);
4533
4661
  addNode(node);
4534
4662
  elementToNode.set(inner, node);
4535
4663
  carried.push(node);
@@ -4844,6 +4972,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4844
4972
  heldTransform: opts.heldTransform,
4845
4973
  onBeforeMeasure: opts.onBeforeMeasure,
4846
4974
  onMeasure: opts.onMeasure,
4975
+ failing: undefined,
4847
4976
  blend: undefined,
4848
4977
  seedBlend: undefined,
4849
4978
  seedScroll: undefined,
@@ -4877,6 +5006,11 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
4877
5006
  corrected: false,
4878
5007
  customBases: undefined,
4879
5008
  customCorrected: false,
5009
+ easeFailing: false,
5010
+ failingCorrectors: undefined,
5011
+ writeFailing: false,
5012
+ heldFailing: false,
5013
+ lastHeld: "none",
4880
5014
  isScroll: opts.layoutScroll === true,
4881
5015
  scroll: { x: 0, y: 0 },
4882
5016
  isScrollRoot: false,
@@ -5051,7 +5185,7 @@ export const makeProjectionSystem = (runtime, sink, options = {}) => {
5051
5185
  // No release runs, so it has ended (#273): told from a microtask, as Motion's instant one resolves.
5052
5186
  queueMicrotask(() => {
5053
5187
  if (nodes.has(node))
5054
- callAppIfAny(node.onReleaseEnd(), "onDragTransitionEnd");
5188
+ callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd");
5055
5189
  });
5056
5190
  return;
5057
5191
  }