@wardic/dom 1.4.0 → 1.5.0-next.1

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 (81) hide show
  1. package/dist/Color.d.ts +2 -1
  2. package/dist/Color.d.ts.map +1 -1
  3. package/dist/Color.js +3 -1
  4. package/dist/Color.js.map +1 -1
  5. package/dist/Report.d.ts +1 -1
  6. package/dist/Report.d.ts.map +1 -1
  7. package/dist/Report.js +1 -1
  8. package/dist/Report.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/internal/colorSpaces.d.ts +8 -0
  14. package/dist/internal/colorSpaces.d.ts.map +1 -0
  15. package/dist/internal/colorSpaces.js +26 -0
  16. package/dist/internal/colorSpaces.js.map +1 -0
  17. package/dist/internal/colors.d.ts +0 -7
  18. package/dist/internal/colors.d.ts.map +1 -1
  19. package/dist/internal/colors.js +3 -15
  20. package/dist/internal/colors.js.map +1 -1
  21. package/dist/internal/diagnostic-codes.d.ts +10 -0
  22. package/dist/internal/diagnostic-codes.d.ts.map +1 -0
  23. package/dist/internal/diagnostic-codes.js +38 -0
  24. package/dist/internal/diagnostic-codes.js.map +1 -0
  25. package/dist/internal/input.d.ts.map +1 -1
  26. package/dist/internal/input.js +18 -0
  27. package/dist/internal/input.js.map +1 -1
  28. package/dist/internal/layout-box.d.ts +29 -0
  29. package/dist/internal/layout-box.d.ts.map +1 -0
  30. package/dist/internal/layout-box.js +48 -0
  31. package/dist/internal/layout-box.js.map +1 -0
  32. package/dist/internal/measure.d.ts +1 -19
  33. package/dist/internal/measure.d.ts.map +1 -1
  34. package/dist/internal/measure.js +4 -47
  35. package/dist/internal/measure.js.map +1 -1
  36. package/dist/internal/projection.d.ts +5 -1
  37. package/dist/internal/projection.d.ts.map +1 -1
  38. package/dist/internal/projection.js +11 -10
  39. package/dist/internal/projection.js.map +1 -1
  40. package/dist/internal/reorder.d.ts +7 -0
  41. package/dist/internal/reorder.d.ts.map +1 -1
  42. package/dist/internal/reorder.js +43 -22
  43. package/dist/internal/reorder.js.map +1 -1
  44. package/dist/internal/scroll.js +1 -1
  45. package/dist/internal/scroll.js.map +1 -1
  46. package/dist/unstable/DragTrack.d.ts +1 -1
  47. package/dist/unstable/DragTrack.d.ts.map +1 -1
  48. package/dist/unstable/DragTrack.js +15 -3
  49. package/dist/unstable/DragTrack.js.map +1 -1
  50. package/dist/unstable/ElementSetup.d.ts +4 -1
  51. package/dist/unstable/ElementSetup.d.ts.map +1 -1
  52. package/dist/unstable/ElementSetup.js +6 -2
  53. package/dist/unstable/ElementSetup.js.map +1 -1
  54. package/dist/unstable/Feature.d.ts +9 -4
  55. package/dist/unstable/Feature.d.ts.map +1 -1
  56. package/dist/unstable/Feature.js +8 -6
  57. package/dist/unstable/Feature.js.map +1 -1
  58. package/dist/unstable/PointerValues.js +1 -1
  59. package/dist/unstable/PointerValues.js.map +1 -1
  60. package/dist/unstable/PresenceController.d.ts +36 -0
  61. package/dist/unstable/PresenceController.d.ts.map +1 -1
  62. package/dist/unstable/PresenceController.js +29 -5
  63. package/dist/unstable/PresenceController.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/Color.ts +2 -1
  66. package/src/Report.ts +1 -1
  67. package/src/index.ts +1 -1
  68. package/src/internal/colorSpaces.ts +27 -0
  69. package/src/internal/colors.ts +3 -36
  70. package/src/internal/diagnostic-codes.ts +46 -0
  71. package/src/internal/input.ts +18 -0
  72. package/src/internal/layout-box.ts +57 -0
  73. package/src/internal/measure.ts +4 -47
  74. package/src/internal/projection.ts +22 -12
  75. package/src/internal/reorder.ts +55 -26
  76. package/src/internal/scroll.ts +1 -1
  77. package/src/unstable/DragTrack.ts +27 -4
  78. package/src/unstable/ElementSetup.ts +8 -3
  79. package/src/unstable/Feature.ts +15 -10
  80. package/src/unstable/PointerValues.ts +1 -1
  81. package/src/unstable/PresenceController.ts +30 -7
@@ -319,7 +319,9 @@ const placedOf = (el: Element): Placed => ({
319
319
  * a right-to-left one flips). An HTML one's offsets are whole pixels, the DOM's `offsetTop`; an
320
320
  * `<svg>` root's are fractional, from rects (#744).
321
321
  */
322
- interface PopBox {
322
+ // Exported for the hooks-first probe's `show` and `wards` (probe: hooks-first): a ward that pops itself as it
323
+ // leaves measures and pins as a presence's leaver does. The presence's own use is unchanged.
324
+ export interface PopBox {
323
325
  /** The element it pins: an HTML one, or an outermost `<svg>` (#744). No other SVG element is popped (#702). */
324
326
  readonly el: HTMLElement | SVGSVGElement
325
327
  readonly width: number
@@ -340,7 +342,7 @@ export interface PopAnchors {
340
342
  * A leaver's border box's gap from its containing block's padding edge on each side, in the block's
341
343
  * own pixels (#744): what an HTML one reads from its offsets, and an `<svg>` root from rects.
342
344
  */
343
- interface EdgeGaps {
345
+ export interface EdgeGaps {
344
346
  readonly left: number
345
347
  readonly top: number
346
348
  readonly right: number
@@ -376,7 +378,7 @@ const gapsNowOf = (el: Element): EdgeGaps | undefined => {
376
378
  * With `ahead`, its gaps as a binding's snapshot measured them before its framework's change (#840), the
377
379
  * box is at those, not at the gaps the change has left it with.
378
380
  */
379
- const popBoxOf = (el: Element, anchors: PopAnchors, ahead: EdgeGaps | undefined): PopBox | undefined => {
381
+ export const popBoxOf = (el: Element, anchors: PopAnchors, ahead: EdgeGaps | undefined): PopBox | undefined => {
380
382
  if (isPopped(el)) return pinBoxOf(el, anchors, (measured) => UndefinedOr.match(ahead, { onUndefined: () => gapsNowOf(measured), onDefined: identity }))
381
383
  return undefined
382
384
  }
@@ -474,7 +476,7 @@ const svgGapsOf = (el: SVGSVGElement): EdgeGaps | undefined =>
474
476
  })
475
477
 
476
478
  /** Pin a leaver where `box` measured it, out of the flow, over any style of its own. */
477
- const pin = (box: PopBox): void => {
479
+ export const pin = (box: PopBox): void => {
478
480
  const style = box.el.style
479
481
  style.setProperty("position", "absolute", "important")
480
482
  style.setProperty("width", `${box.width}px`, "important")
@@ -705,7 +707,7 @@ export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices
705
707
  } catch (defect) {
706
708
  if (failing) return
707
709
  failing = true
708
- runtime.runFork(Report.failure("wardic.presence: onExitComplete failed", Cause.die(defect)))
710
+ runtime.runFork(Report.callbackFailed("wardic.presence: onExitComplete failed", Cause.die(defect)))
709
711
  }
710
712
  },
711
713
  }
@@ -924,6 +926,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
924
926
  // in-flight fiber bookkeeping. Idempotent. `completed`: its exit ended on its own (#257).
925
927
  const finishExit = (el: Element, completed = true): void => {
926
928
  exiting.delete(el)
929
+ const told = toldHooks.get(el)
927
930
  toldHooks.delete(el)
928
931
  registry.delete(el)
929
932
  draws.delete(el)
@@ -956,6 +959,26 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
956
959
  if (Bool.and(moves, affectsLayout())) projection.notify()
957
960
  // Told once the node is gone, as Motion's `onExitComplete` finds it (#257).
958
961
  leaveEnds(el, completed)
962
+ // The hooks told it left hear it has gone, its exit completed (an interrupted one's heard so already).
963
+ if (completed) UndefinedOr.map(told, (hooks) => Arr.forEach(hooks, (watch) => UndefinedOr.map(watch.ended, (ended) => ended())))
964
+ }
965
+
966
+ /**
967
+ * A hold a hook takes on a leaving child after it was told it left (its `leave`'s `hold`): one more
968
+ * part of the child's exit, ended by the release it hands back, once. Nothing for a child gone
969
+ * already, or one whose parts aren't counted (it went at once).
970
+ */
971
+ const holdLate = (el: Element, counted: boolean): (() => void) => {
972
+ if (Bool.not(counted)) return constVoid
973
+ const parts = pending.get(el)
974
+ if (Predicate.isUndefined(parts)) return constVoid
975
+ pending.set(el, parts + 1)
976
+ let released = false
977
+ return () => {
978
+ if (released) return
979
+ released = true
980
+ partDone(el)
981
+ }
959
982
  }
960
983
 
961
984
  // One of a leaving child's parts ended (#181): it goes with the last. A child already removed
@@ -1511,9 +1534,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1511
1534
  partDone(el)
1512
1535
  }
1513
1536
  try {
1514
- watch.leave(custom, release)
1537
+ watch.leave(custom, release, () => holdLate(el, counted))
1515
1538
  } catch (defect) {
1516
- runtime.runFork(Report.failure("wardic.presence: a usePresence callback failed", Cause.die(defect)))
1539
+ runtime.runFork(Report.callbackFailed("wardic.presence: a usePresence callback failed", Cause.die(defect)))
1517
1540
  release()
1518
1541
  }
1519
1542
  })