@northgraindata/dsui 0.4.1 → 0.5.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 (120) hide show
  1. package/bin/dsui.mjs +1 -1
  2. package/dist/plugin-sdk.mjs +1 -1
  3. package/dist/runtime/plugins/code-repository.browser.mjs +60 -0
  4. package/dist/runtime/plugins/code-repository.mjs +2 -2
  5. package/dist/runtime/plugins/example-plugin.mjs +1 -1
  6. package/dist/runtime/plugins/health.browser.mjs +202 -68
  7. package/dist/runtime/plugins/health.mjs +97 -6
  8. package/dist/runtime/plugins/monitoring.mjs +11 -1
  9. package/dist/runtime/plugins/status-pages.browser.mjs +5033 -0
  10. package/dist/runtime/plugins/status-pages.mjs +52 -0
  11. package/dist/server.mjs +205 -188
  12. package/package.json +1 -1
  13. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@northgraindata/dsui-ui/src/components/input.tsx +2 -5
  14. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@northgraindata/dsui-ui/src/components/suggest-input.tsx +197 -0
  15. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@northgraindata/dsui-ui/src/index.tsx +5 -0
  16. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@northgraindata/dsui-ui/src/styles.css +54 -0
  17. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs +3 -2
  18. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs.map +1 -1
  19. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js +3 -2
  20. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js.map +1 -1
  21. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/package.json +2 -2
  22. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/src/index.tsx +11 -2
  23. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs +79 -26
  24. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs.map +1 -1
  25. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.d.cts +12 -1
  26. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs +14 -2
  27. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs.map +1 -1
  28. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.d.cts +3 -2
  29. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.d.ts +12 -1
  30. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js +79 -26
  31. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js.map +1 -1
  32. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.d.ts +3 -2
  33. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js +14 -2
  34. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js.map +1 -1
  35. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/package.json +1 -1
  36. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/src/index.ts +135 -24
  37. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/src/scroll-classifier.ts +31 -3
  38. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/define.ts +22 -1
  39. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/index.ts +1 -0
  40. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/presentation.test.ts +73 -0
  41. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/presentation.ts +34 -0
  42. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/types.ts +23 -0
  43. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/layout/gauge.tsx +14 -2
  44. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/dataset/dataset.test.ts +134 -0
  45. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/dataset/index.ts +141 -0
  46. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/index.ts +23 -0
  47. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs +3 -2
  48. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs.map +1 -1
  49. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js +3 -2
  50. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js.map +1 -1
  51. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/package.json +2 -2
  52. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/react-virtual/src/index.tsx +11 -2
  53. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs +79 -26
  54. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs.map +1 -1
  55. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.d.cts +12 -1
  56. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs +14 -2
  57. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs.map +1 -1
  58. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.d.cts +3 -2
  59. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.d.ts +12 -1
  60. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js +79 -26
  61. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js.map +1 -1
  62. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.d.ts +3 -2
  63. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js +14 -2
  64. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js.map +1 -1
  65. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/package.json +1 -1
  66. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/src/index.ts +135 -24
  67. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/node_modules/@tanstack/virtual-core/src/scroll-classifier.ts +31 -3
  68. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/define.ts +22 -1
  69. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/index.ts +1 -0
  70. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/presentation.test.ts +73 -0
  71. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/presentation.ts +34 -0
  72. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/adapter/types.ts +23 -0
  73. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/layout/gauge.tsx +14 -2
  74. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/dataset/dataset.test.ts +134 -0
  75. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/dataset/index.ts +141 -0
  76. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/index.ts +23 -0
  77. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs +3 -2
  78. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/dist/cjs/index.cjs.map +1 -1
  79. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js +3 -2
  80. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/dist/esm/index.js.map +1 -1
  81. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/package.json +2 -2
  82. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/react-virtual/src/index.tsx +11 -2
  83. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs +79 -26
  84. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs.map +1 -1
  85. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/index.d.cts +12 -1
  86. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs +14 -2
  87. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.cjs.map +1 -1
  88. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/cjs/scroll-classifier.d.cts +3 -2
  89. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.d.ts +12 -1
  90. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js +79 -26
  91. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/index.js.map +1 -1
  92. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.d.ts +3 -2
  93. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js +14 -2
  94. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/dist/esm/scroll-classifier.js.map +1 -1
  95. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/package.json +1 -1
  96. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/src/index.ts +135 -24
  97. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@tanstack/virtual-core/src/scroll-classifier.ts +31 -3
  98. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/package.json +2 -1
  99. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/src/diagnostics.ts +24 -0
  100. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/src/events.ts +6 -0
  101. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/src/index.ts +162 -2
  102. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/src/modal.test.ts +76 -0
  103. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/src/modal.ts +200 -0
  104. package/sdk/node_modules/@northgraindata/dsui-ui/src/components/input.tsx +2 -5
  105. package/sdk/node_modules/@northgraindata/dsui-ui/src/components/suggest-input.tsx +197 -0
  106. package/sdk/node_modules/@northgraindata/dsui-ui/src/index.tsx +5 -0
  107. package/sdk/node_modules/@northgraindata/dsui-ui/src/styles.css +54 -0
  108. package/web/assets/index-DQkPkPN7.css +1 -0
  109. package/web/assets/index-w07fgRf1.js +218 -0
  110. package/web/index.html +2 -2
  111. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/keyed-items.test.ts +0 -23
  112. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/query-editor/column-profile.test.ts +0 -109
  113. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/query-editor/query-explorer.test.ts +0 -29
  114. package/sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/table-data.test.ts +0 -65
  115. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/keyed-items.test.ts +0 -23
  116. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/query-editor/column-profile.test.ts +0 -109
  117. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/query-editor/query-explorer.test.ts +0 -29
  118. package/sdk/node_modules/@northgraindata/dsui-plugin-sdk/node_modules/@northgraindata/dsui-adapter-sdk/src/components/ui/table-data.test.ts +0 -65
  119. package/web/assets/index-BBd7EEtd.js +0 -98
  120. package/web/assets/index-C16grSph.css +0 -1
@@ -1,4 +1,4 @@
1
- type ScrollEventKind = 'spurious' | 'readBack' | 'clampedReadBack' | 'clampedEcho' | 'external';
1
+ type ScrollEventKind = 'spurious' | 'readBack' | 'clampedReadBack' | 'clampedEcho' | 'restEcho' | 'external';
2
2
  export interface ScrollEventInput {
3
3
  offset: number;
4
4
  isScrolling: boolean;
@@ -11,8 +11,9 @@ export interface ScrollEventInput {
11
11
  lowMaxes?: Array<number>;
12
12
  } | null;
13
13
  clampedMaxAtWrite: number | null;
14
+ ownWriteAt: number | null;
14
15
  }
15
- export declare function classifyScrollEvent({ offset, isScrolling, elementMax, holdOffset, scrollOffset, pendingWrite, clampedMaxAtWrite, }: ScrollEventInput): ScrollEventKind;
16
+ export declare function classifyScrollEvent({ offset, isScrolling, elementMax, holdOffset, scrollOffset, pendingWrite, clampedMaxAtWrite, ownWriteAt, }: ScrollEventInput): ScrollEventKind;
16
17
  export type ScrollPhase = 'queued' | 'smooth' | 'smoothLanded' | 'smoothFinishing' | 'instant';
17
18
  export interface RetireInput {
18
19
  kind: ScrollEventKind;
@@ -6,7 +6,8 @@ function classifyScrollEvent({
6
6
  holdOffset,
7
7
  scrollOffset,
8
8
  pendingWrite,
9
- clampedMaxAtWrite
9
+ clampedMaxAtWrite,
10
+ ownWriteAt
10
11
  }) {
11
12
  var _a;
12
13
  if (isScrolling && pendingWrite === null && offset === scrollOffset) {
@@ -24,6 +25,9 @@ function classifyScrollEvent({
24
25
  if (clampedMaxAtWrite !== null && Math.abs(offset - clampedMaxAtWrite) < 1.5) {
25
26
  return "clampedEcho";
26
27
  }
28
+ if (!isScrolling && ownWriteAt !== null && Math.abs(offset - ownWriteAt) < 1.5) {
29
+ return "restEcho";
30
+ }
27
31
  return "external";
28
32
  }
29
33
  const isAnimating = (phase) => phase === "smooth" || phase === "smoothFinishing";
@@ -33,6 +37,8 @@ function externalRetiresCommand({
33
37
  command,
34
38
  target
35
39
  }) {
40
+ let fresh;
41
+ const freshTarget = () => fresh ?? (fresh = target());
36
42
  return kind !== "spurious" && kind !== "readBack" && // Our own write, clamped (`clampedReadBack`, #1310): the command is not
37
43
  // retired by it, and reconcile retargets below the new max.
38
44
  kind !== "clampedReadBack" && (command == null ? void 0 : command.index) != null && // Nothing has been written for a command waiting for the tail; these
@@ -45,7 +51,13 @@ function externalRetiresCommand({
45
51
  // keeps it reconciling (#1294). While a smooth scroll's animation may
46
52
  // still report, its events look like a user's, so it yields only once it
47
53
  // has landed.
48
- !isAnimating(command.phase) && !approxEqual(offset, command.lastTargetOffset) && !approxEqual(offset, target()) && // A compensation write's clamped echo (#1258) keeps the command. The
54
+ !isAnimating(command.phase) && !approxEqual(offset, command.lastTargetOffset) && !approxEqual(offset, freshTarget()) && // Our own write reported again at rest (`restEcho`): nothing else has
55
+ // moved the element, but reconcile writes only a target that moved. Once
56
+ // the target has moved since the command wrote it, reconcile lands the
57
+ // command there (with `scrollend`, a correction's echo arrives before
58
+ // reconcile has run on the measurements behind it); while it has not,
59
+ // nothing will bring the element back, and the command ends here.
60
+ (kind !== "restEcho" || freshTarget() === command.lastTargetOffset) && // A compensation write's clamped echo (#1258) keeps the command. The
49
61
  // order is deliberate, not tidiness: this clause stays after `target()`
50
62
  // (and `clampedReadBack` before it) because `target()` can rebuild the
51
63
  // measurements, so it must run for exactly the events it always did.
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-classifier.js","sources":["../../src/scroll-classifier.ts"],"sourcesContent":["import { approxEqual } from './utils'\n\n// Why a scroll event arrived, decided from the virtualizer's state as it was\n// before the event, before the scroll handler mutates anything. The first\n// match in this order wins:\n// spurious Safari/Firefox re-emit at the position we hold, nothing\n// pending\n// readBack our last write reporting back (within 1.5px of its\n// target)\n// clampedReadBack our last non-smooth write, clamped at the element's\n// current max or at a smaller max the layout passed\n// through since the write\n// clampedEcho a compensation write the browser clamped (#1258)\n// reporting at the max seen at write time\n// external anything else: the user, a fling, a smooth animation\n// frame\ntype ScrollEventKind =\n | 'spurious'\n | 'readBack'\n | 'clampedReadBack'\n | 'clampedEcho'\n | 'external'\n\nexport interface ScrollEventInput {\n // The reported position in layout coordinates (the element's offset plus\n // the held correction and a pending prepend anchor's delta).\n offset: number\n isScrolling: boolean\n // The element's own scroll max, read only while scrolling (null otherwise\n // or where it cannot be read).\n elementMax: number | null\n // How far the element sits behind the layout while a correction is held.\n holdOffset: number\n // The layout position the virtualizer holds.\n scrollOffset: number | null\n // Our last write to the element, until a scroll event reports it, with\n // the scroll maxima below its target the element had since (see\n // `lowMaxes` on `pendingWrite` in the virtualizer).\n pendingWrite: {\n target: number\n smooth: boolean\n lowMaxes?: Array<number>\n } | null\n // The element's max when a clamped compensation write was made (#1258),\n // or null when none is pending.\n clampedMaxAtWrite: number | null\n}\n\nexport function classifyScrollEvent({\n offset,\n isScrolling,\n elementMax,\n holdOffset,\n scrollOffset,\n pendingWrite,\n clampedMaxAtWrite,\n}: ScrollEventInput): ScrollEventKind {\n // A scroll event that reports movement but lands on the offset we already\n // hold — and isn't a self-write read-back — is a spurious no-op re-emit\n // that Safari/Firefox fire after a re-render's layout (Chrome doesn't).\n // Treating it as scrolling re-arms `isScrolling`, which forces a render\n // that triggers another such event: an infinite re-render loop.\n if (isScrolling && pendingWrite === null && offset === scrollOffset) {\n return 'spurious'\n }\n if (pendingWrite !== null && Math.abs(offset - pendingWrite.target) < 1.5) {\n return 'readBack'\n }\n // A non-smooth write past the element's max reads back at the max: ours,\n // clamped because the sizer shrank between the write and the report (rows\n // above the target measured smaller in a same-task render, #1310). The\n // element is where it says. A finger that drags to the max while such a\n // write is pending (iOS ignored it) is read the same way; the command then\n // retires at the next frame, its target clamped to the same max.\n if (\n pendingWrite !== null &&\n !pendingWrite.smooth &&\n elementMax !== null &&\n pendingWrite.target > elementMax + holdOffset + 0.5 &&\n Math.abs(offset - (elementMax + holdOffset)) < 1.5\n ) {\n return 'clampedReadBack'\n }\n // The same, clamped to a smaller max than the element's current one: the\n // sizer shrank below the target after the write (rows measured smaller,\n // a count change) and the browser clamped there, then it grew back, all\n // before the report. The clamp lands on one of those maxima; a position\n // between them is not one.\n if (\n pendingWrite !== null &&\n !pendingWrite.smooth &&\n pendingWrite.lowMaxes?.some((max) => Math.abs(offset - max) < 1.5)\n ) {\n return 'clampedReadBack'\n }\n if (\n clampedMaxAtWrite !== null &&\n Math.abs(offset - clampedMaxAtWrite) < 1.5\n ) {\n return 'clampedEcho'\n }\n return 'external'\n}\n\n// Where an in-flight scroll command is in its lifecycle, which decides how\n// its scroll events and measurements are read:\n// queued the first write waits for the momentum tail to close\n// (iOS 27, see `_startScroll`). Nothing has been written:\n// the fling's scroll events do not retire the command, a\n// drag does, and reconcile only keeps the safety valve\n// smooth a smooth animation is travelling to the target\n// smoothLanded a smooth scroll is at its target, waiting to retire\n// smoothFinishing a smooth scroll switched to instant writes for the\n// final approach; its animation can still report positions\n// instant instant writes\nexport type ScrollPhase =\n | 'queued'\n | 'smooth'\n | 'smoothLanded'\n | 'smoothFinishing'\n | 'instant'\n\n// The smooth animation may still be reporting positions, so a scroll event\n// that isn't the read-back of our own write may not be the user.\nconst isAnimating = (phase: ScrollPhase) =>\n phase === 'smooth' || phase === 'smoothFinishing'\n\nexport interface RetireInput {\n kind: ScrollEventKind\n // The reported position in layout coordinates, as classified.\n offset: number\n // The in-flight scroll command, or null.\n command: {\n index: number | null\n phase: ScrollPhase\n lastTargetOffset: number\n } | null\n // The command's target recomputed against the current layout. Called\n // only once every cheaper clause has passed, and at most once.\n target: () => number\n}\n\n// Whether a scroll event that is not the read-back of our own write retires\n// the in-flight index command: an external scroll moved away from its\n// target. Our own measurement updates (including clamped writes) still need\n// to reconcile.\nexport function externalRetiresCommand({\n kind,\n offset,\n command,\n target,\n}: RetireInput): boolean {\n return (\n kind !== 'spurious' &&\n kind !== 'readBack' &&\n // Our own write, clamped (`clampedReadBack`, #1310): the command is not\n // retired by it, and reconcile retargets below the new max.\n kind !== 'clampedReadBack' &&\n command?.index != null &&\n // Nothing has been written for a command waiting for the tail; these\n // are the fling's events.\n command.phase !== 'queued' &&\n // A non-smooth write lands at once, so any other scroll event is the\n // user's, even before reconcile saw the target reached (the target may\n // keep moving, or iOS ignored the write under a finger). A write the\n // browser clamped because the sizer hasn't grown yet reads back at the\n // max, which is also where the fresh target clamps, so the check below\n // keeps it reconciling (#1294). While a smooth scroll's animation may\n // still report, its events look like a user's, so it yields only once it\n // has landed.\n !isAnimating(command.phase) &&\n !approxEqual(offset, command.lastTargetOffset) &&\n !approxEqual(offset, target()) &&\n // A compensation write's clamped echo (#1258) keeps the command. The\n // order is deliberate, not tidiness: this clause stays after `target()`\n // (and `clampedReadBack` before it) because `target()` can rebuild the\n // measurements, so it must run for exactly the events it always did.\n kind !== 'clampedEcho'\n )\n}\n\n// A scroll position reported at a time, in the element's own coordinates.\nexport interface ScrollSample {\n t: number\n offset: number\n}\n\nconst FLING_WINDOW_MS = 40\n\n// Whether the scroll sped up: a finger flicked again or dragged on during a\n// fling. iOS fires no touch events for a touch that lands on a fling\n// (#1307), so this, and a turn against the fling, is all that shows it.\n// Momentum only slows down. Scroll events arrive 7–26ms apart and some\n// carry two frames, so one event can read 2–3× faster than its neighbours;\n// the speed is taken over the last 40ms and compared with the 40ms before.\n// On an iPhone (27.0.1) the flicks read 2.4–6× faster than the window before\n// and at least 1.5px/ms more, momentum alone at most 1.7× (#1307).\nexport function flingSpedUp(samples: ReadonlyArray<ScrollSample>): boolean {\n const last = samples[samples.length - 1]\n if (last === undefined) return false\n let j = samples.length - 2\n while (j >= 0 && last.t - samples[j]!.t < FLING_WINDOW_MS) j--\n if (j < 0) return false\n const mid = samples[j]!\n let k = j - 1\n while (k >= 0 && mid.t - samples[k]!.t < FLING_WINDOW_MS) k--\n if (k < 0) return false\n const first = samples[k]!\n const recent = (last.offset - mid.offset) / (last.t - mid.t)\n const before = (mid.offset - first.offset) / (mid.t - first.t)\n return (\n recent * before >= 0 &&\n Math.abs(recent) >= 2 * Math.abs(before) &&\n Math.abs(recent) - Math.abs(before) >= 0.8\n )\n}\n\n// Whether a fling that sent its last scroll event was still going at\n// 0.05px/ms or more over its last 40ms: a finger caught it. A fling that\n// ends on its own fades to at most 0.015px/ms first; taps stopped one at\n// 0.21–1.43px/ms (iPhones on 27.0.1, #1307). The finger stays down with no\n// touch events, and iOS undoes a write made under it. A tap in the last\n// pixels of a fling reads as its end.\nexport function flingCaught(samples: ReadonlyArray<ScrollSample>): boolean {\n const last = samples[samples.length - 1]\n if (last === undefined) return false\n let j = samples.length - 2\n while (j >= 0 && last.t - samples[j]!.t < FLING_WINDOW_MS) j--\n if (j < 0) return false\n const from = samples[j]!\n return Math.abs(last.offset - from.offset) / (last.t - from.t) >= 0.05\n}\n"],"names":[],"mappings":";AAgDO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsC;;AAMpC,MAAI,eAAe,iBAAiB,QAAQ,WAAW,cAAc;AACnE,WAAO;AAAA,EACT;AACA,MAAI,iBAAiB,QAAQ,KAAK,IAAI,SAAS,aAAa,MAAM,IAAI,KAAK;AACzE,WAAO;AAAA,EACT;AAOA,MACE,iBAAiB,QACjB,CAAC,aAAa,UACd,eAAe,QACf,aAAa,SAAS,aAAa,aAAa,OAChD,KAAK,IAAI,UAAU,aAAa,WAAW,IAAI,KAC/C;AACA,WAAO;AAAA,EACT;AAMA,MACE,iBAAiB,QACjB,CAAC,aAAa,YACd,kBAAa,aAAb,mBAAuB,KAAK,CAAC,QAAQ,KAAK,IAAI,SAAS,GAAG,IAAI,OAC9D;AACA,WAAO;AAAA,EACT;AACA,MACE,sBAAsB,QACtB,KAAK,IAAI,SAAS,iBAAiB,IAAI,KACvC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAsBA,MAAM,cAAc,CAAC,UACnB,UAAU,YAAY,UAAU;AAqB3B,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,SACE,SAAS,cACT,SAAS;AAAA;AAAA,EAGT,SAAS,sBACT,mCAAS,UAAS;AAAA;AAAA,EAGlB,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlB,CAAC,YAAY,QAAQ,KAAK,KAC1B,CAAC,YAAY,QAAQ,QAAQ,gBAAgB,KAC7C,CAAC,YAAY,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA,EAK7B,SAAS;AAEb;AAQA,MAAM,kBAAkB;AAUjB,SAAS,YAAY,SAA+C;AACzE,QAAM,OAAO,QAAQ,QAAQ,SAAS,CAAC;AACvC,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,IAAI,QAAQ,SAAS;AACzB,SAAO,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC3D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,MAAM,QAAQ,CAAC;AACrB,MAAI,IAAI,IAAI;AACZ,SAAO,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC1D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,UAAU,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI;AAC1D,QAAM,UAAU,IAAI,SAAS,MAAM,WAAW,IAAI,IAAI,MAAM;AAC5D,SACE,SAAS,UAAU,KACnB,KAAK,IAAI,MAAM,KAAK,IAAI,KAAK,IAAI,MAAM,KACvC,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,KAAK;AAE3C;AAQO,SAAS,YAAY,SAA+C;AACzE,QAAM,OAAO,QAAQ,QAAQ,SAAS,CAAC;AACvC,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,IAAI,QAAQ,SAAS;AACzB,SAAO,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC3D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,OAAO,QAAQ,CAAC;AACtB,SAAO,KAAK,IAAI,KAAK,SAAS,KAAK,MAAM,KAAK,KAAK,IAAI,KAAK,MAAM;AACpE;"}
1
+ {"version":3,"file":"scroll-classifier.js","sources":["../../src/scroll-classifier.ts"],"sourcesContent":["import { approxEqual } from './utils'\n\n// Why a scroll event arrived, decided from the virtualizer's state as it was\n// before the event, before the scroll handler mutates anything. The first\n// match in this order wins:\n// spurious Safari/Firefox re-emit at the position we hold, nothing\n// pending\n// readBack our last write reporting back (within 1.5px of its\n// target)\n// clampedReadBack our last non-smooth write, clamped at the element's\n// current max or at a smaller max the layout passed\n// through since the write\n// clampedEcho a compensation write the browser clamped (#1258)\n// reporting at the max seen at write time\n// restEcho our own write reported again at rest, where the last\n// scroll event reported it\n// external anything else: the user, a fling, a smooth animation\n// frame\ntype ScrollEventKind =\n | 'spurious'\n | 'readBack'\n | 'clampedReadBack'\n | 'clampedEcho'\n | 'restEcho'\n | 'external'\n\nexport interface ScrollEventInput {\n // The reported position in layout coordinates (the element's offset plus\n // the held correction and a pending prepend anchor's delta).\n offset: number\n isScrolling: boolean\n // The element's own scroll max, read only while scrolling (null otherwise\n // or where it cannot be read).\n elementMax: number | null\n // How far the element sits behind the layout while a correction is held.\n holdOffset: number\n // The layout position the virtualizer holds.\n scrollOffset: number | null\n // Our last write to the element, until a scroll event reports it, with\n // the scroll maxima below its target the element had since (see\n // `lowMaxes` on `pendingWrite` in the virtualizer).\n pendingWrite: {\n target: number\n smooth: boolean\n lowMaxes?: Array<number>\n } | null\n // The element's max when a clamped compensation write was made (#1258),\n // or null when none is pending.\n clampedMaxAtWrite: number | null\n // Where the last scroll event reported our own write (read back, clamped\n // or echoed), until a report anywhere else.\n ownWriteAt: number | null\n}\n\nexport function classifyScrollEvent({\n offset,\n isScrolling,\n elementMax,\n holdOffset,\n scrollOffset,\n pendingWrite,\n clampedMaxAtWrite,\n ownWriteAt,\n}: ScrollEventInput): ScrollEventKind {\n // A scroll event that reports movement but lands on the offset we already\n // hold — and isn't a self-write read-back — is a spurious no-op re-emit\n // that Safari/Firefox fire after a re-render's layout (Chrome doesn't).\n // Treating it as scrolling re-arms `isScrolling`, which forces a render\n // that triggers another such event: an infinite re-render loop.\n if (isScrolling && pendingWrite === null && offset === scrollOffset) {\n return 'spurious'\n }\n if (pendingWrite !== null && Math.abs(offset - pendingWrite.target) < 1.5) {\n return 'readBack'\n }\n // A non-smooth write past the element's max reads back at the max: ours,\n // clamped because the sizer shrank between the write and the report (rows\n // above the target measured smaller in a same-task render, #1310). The\n // element is where it says. A finger that drags to the max while such a\n // write is pending (iOS ignored it) is read the same way; the command then\n // retires at the next frame, its target clamped to the same max.\n if (\n pendingWrite !== null &&\n !pendingWrite.smooth &&\n elementMax !== null &&\n pendingWrite.target > elementMax + holdOffset + 0.5 &&\n Math.abs(offset - (elementMax + holdOffset)) < 1.5\n ) {\n return 'clampedReadBack'\n }\n // The same, clamped to a smaller max than the element's current one: the\n // sizer shrank below the target after the write (rows measured smaller,\n // a count change) and the browser clamped there, then it grew back, all\n // before the report. The clamp lands on one of those maxima; a position\n // between them is not one.\n if (\n pendingWrite !== null &&\n !pendingWrite.smooth &&\n pendingWrite.lowMaxes?.some((max) => Math.abs(offset - max) < 1.5)\n ) {\n return 'clampedReadBack'\n }\n if (\n clampedMaxAtWrite !== null &&\n Math.abs(offset - clampedMaxAtWrite) < 1.5\n ) {\n return 'clampedEcho'\n }\n // A write is reported again when the element comes to rest: `scrollend`\n // follows its scroll event in the same frame's scroll steps, before\n // reconcile; the fallback follows it after `isScrollingResetDelay`.\n // Nothing has moved the element in between.\n if (\n !isScrolling &&\n ownWriteAt !== null &&\n Math.abs(offset - ownWriteAt) < 1.5\n ) {\n return 'restEcho'\n }\n return 'external'\n}\n\n// Where an in-flight scroll command is in its lifecycle, which decides how\n// its scroll events and measurements are read:\n// queued the first write waits for the momentum tail to close\n// (iOS 27, see `_startScroll`). Nothing has been written:\n// the fling's scroll events do not retire the command, a\n// drag does, and reconcile only keeps the safety valve\n// smooth a smooth animation is travelling to the target\n// smoothLanded a smooth scroll is at its target, waiting to retire\n// smoothFinishing a smooth scroll switched to instant writes for the\n// final approach; its animation can still report positions\n// instant instant writes\nexport type ScrollPhase =\n | 'queued'\n | 'smooth'\n | 'smoothLanded'\n | 'smoothFinishing'\n | 'instant'\n\n// The smooth animation may still be reporting positions, so a scroll event\n// that isn't the read-back of our own write may not be the user.\nconst isAnimating = (phase: ScrollPhase) =>\n phase === 'smooth' || phase === 'smoothFinishing'\n\nexport interface RetireInput {\n kind: ScrollEventKind\n // The reported position in layout coordinates, as classified.\n offset: number\n // The in-flight scroll command, or null.\n command: {\n index: number | null\n phase: ScrollPhase\n lastTargetOffset: number\n } | null\n // The command's target recomputed against the current layout. Called\n // only once every cheaper clause has passed, and at most once.\n target: () => number\n}\n\n// Whether a scroll event that is not the read-back of our own write retires\n// the in-flight index command: an external scroll moved away from its\n// target, or our own write left the element where reconcile will not move\n// it. Our own measurement updates (including clamped writes) still need to\n// reconcile.\nexport function externalRetiresCommand({\n kind,\n offset,\n command,\n target,\n}: RetireInput): boolean {\n let fresh: number | undefined\n const freshTarget = () => (fresh ??= target())\n return (\n kind !== 'spurious' &&\n kind !== 'readBack' &&\n // Our own write, clamped (`clampedReadBack`, #1310): the command is not\n // retired by it, and reconcile retargets below the new max.\n kind !== 'clampedReadBack' &&\n command?.index != null &&\n // Nothing has been written for a command waiting for the tail; these\n // are the fling's events.\n command.phase !== 'queued' &&\n // A non-smooth write lands at once, so any other scroll event is the\n // user's, even before reconcile saw the target reached (the target may\n // keep moving, or iOS ignored the write under a finger). A write the\n // browser clamped because the sizer hasn't grown yet reads back at the\n // max, which is also where the fresh target clamps, so the check below\n // keeps it reconciling (#1294). While a smooth scroll's animation may\n // still report, its events look like a user's, so it yields only once it\n // has landed.\n !isAnimating(command.phase) &&\n !approxEqual(offset, command.lastTargetOffset) &&\n !approxEqual(offset, freshTarget()) &&\n // Our own write reported again at rest (`restEcho`): nothing else has\n // moved the element, but reconcile writes only a target that moved. Once\n // the target has moved since the command wrote it, reconcile lands the\n // command there (with `scrollend`, a correction's echo arrives before\n // reconcile has run on the measurements behind it); while it has not,\n // nothing will bring the element back, and the command ends here.\n (kind !== 'restEcho' || freshTarget() === command.lastTargetOffset) &&\n // A compensation write's clamped echo (#1258) keeps the command. The\n // order is deliberate, not tidiness: this clause stays after `target()`\n // (and `clampedReadBack` before it) because `target()` can rebuild the\n // measurements, so it must run for exactly the events it always did.\n kind !== 'clampedEcho'\n )\n}\n\n// A scroll position reported at a time, in the element's own coordinates.\nexport interface ScrollSample {\n t: number\n offset: number\n}\n\nconst FLING_WINDOW_MS = 40\n\n// Whether the scroll sped up: a finger flicked again or dragged on during a\n// fling. iOS fires no touch events for a touch that lands on a fling\n// (#1307), so this, and a turn against the fling, is all that shows it.\n// Momentum only slows down. Scroll events arrive 7–26ms apart and some\n// carry two frames, so one event can read 2–3× faster than its neighbours;\n// the speed is taken over the last 40ms and compared with the 40ms before.\n// On an iPhone (27.0.1) the flicks read 2.4–6× faster than the window before\n// and at least 1.5px/ms more, momentum alone at most 1.7× (#1307).\nexport function flingSpedUp(samples: ReadonlyArray<ScrollSample>): boolean {\n const last = samples[samples.length - 1]\n if (last === undefined) return false\n let j = samples.length - 2\n while (j >= 0 && last.t - samples[j]!.t < FLING_WINDOW_MS) j--\n if (j < 0) return false\n const mid = samples[j]!\n let k = j - 1\n while (k >= 0 && mid.t - samples[k]!.t < FLING_WINDOW_MS) k--\n if (k < 0) return false\n const first = samples[k]!\n const recent = (last.offset - mid.offset) / (last.t - mid.t)\n const before = (mid.offset - first.offset) / (mid.t - first.t)\n return (\n recent * before >= 0 &&\n Math.abs(recent) >= 2 * Math.abs(before) &&\n Math.abs(recent) - Math.abs(before) >= 0.8\n )\n}\n\n// Whether a fling that sent its last scroll event was still going at\n// 0.05px/ms or more over its last 40ms: a finger caught it. A fling that\n// ends on its own fades to at most 0.015px/ms first; taps stopped one at\n// 0.21–1.43px/ms (iPhones on 27.0.1, #1307). The finger stays down with no\n// touch events, and iOS undoes a write made under it. A tap in the last\n// pixels of a fling reads as its end.\nexport function flingCaught(samples: ReadonlyArray<ScrollSample>): boolean {\n const last = samples[samples.length - 1]\n if (last === undefined) return false\n let j = samples.length - 2\n while (j >= 0 && last.t - samples[j]!.t < FLING_WINDOW_MS) j--\n if (j < 0) return false\n const from = samples[j]!\n return Math.abs(last.offset - from.offset) / (last.t - from.t) >= 0.05\n}\n"],"names":[],"mappings":";AAsDO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsC;;AAMpC,MAAI,eAAe,iBAAiB,QAAQ,WAAW,cAAc;AACnE,WAAO;AAAA,EACT;AACA,MAAI,iBAAiB,QAAQ,KAAK,IAAI,SAAS,aAAa,MAAM,IAAI,KAAK;AACzE,WAAO;AAAA,EACT;AAOA,MACE,iBAAiB,QACjB,CAAC,aAAa,UACd,eAAe,QACf,aAAa,SAAS,aAAa,aAAa,OAChD,KAAK,IAAI,UAAU,aAAa,WAAW,IAAI,KAC/C;AACA,WAAO;AAAA,EACT;AAMA,MACE,iBAAiB,QACjB,CAAC,aAAa,YACd,kBAAa,aAAb,mBAAuB,KAAK,CAAC,QAAQ,KAAK,IAAI,SAAS,GAAG,IAAI,OAC9D;AACA,WAAO;AAAA,EACT;AACA,MACE,sBAAsB,QACtB,KAAK,IAAI,SAAS,iBAAiB,IAAI,KACvC;AACA,WAAO;AAAA,EACT;AAKA,MACE,CAAC,eACD,eAAe,QACf,KAAK,IAAI,SAAS,UAAU,IAAI,KAChC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAsBA,MAAM,cAAc,CAAC,UACnB,UAAU,YAAY,UAAU;AAsB3B,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,MAAI;AACJ,QAAM,cAAc,MAAO,kBAAU,OAAA;AACrC,SACE,SAAS,cACT,SAAS;AAAA;AAAA,EAGT,SAAS,sBACT,mCAAS,UAAS;AAAA;AAAA,EAGlB,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlB,CAAC,YAAY,QAAQ,KAAK,KAC1B,CAAC,YAAY,QAAQ,QAAQ,gBAAgB,KAC7C,CAAC,YAAY,QAAQ,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOjC,SAAS,cAAc,kBAAkB,QAAQ;AAAA;AAAA;AAAA;AAAA,EAKlD,SAAS;AAEb;AAQA,MAAM,kBAAkB;AAUjB,SAAS,YAAY,SAA+C;AACzE,QAAM,OAAO,QAAQ,QAAQ,SAAS,CAAC;AACvC,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,IAAI,QAAQ,SAAS;AACzB,SAAO,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC3D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,MAAM,QAAQ,CAAC;AACrB,MAAI,IAAI,IAAI;AACZ,SAAO,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC1D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,UAAU,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI;AAC1D,QAAM,UAAU,IAAI,SAAS,MAAM,WAAW,IAAI,IAAI,MAAM;AAC5D,SACE,SAAS,UAAU,KACnB,KAAK,IAAI,MAAM,KAAK,IAAI,KAAK,IAAI,MAAM,KACvC,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,KAAK;AAE3C;AAQO,SAAS,YAAY,SAA+C;AACzE,QAAM,OAAO,QAAQ,QAAQ,SAAS,CAAC;AACvC,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,IAAI,QAAQ,SAAS;AACzB,SAAO,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAG,IAAI,gBAAiB;AAC3D,MAAI,IAAI,EAAG,QAAO;AAClB,QAAM,OAAO,QAAQ,CAAC;AACtB,SAAO,KAAK,IAAI,KAAK,SAAS,KAAK,MAAM,KAAK,KAAK,IAAI,KAAK,MAAM;AACpE;"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/virtual-core",
3
- "version": "3.19.11",
3
+ "version": "3.19.13",
4
4
  "description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -496,12 +496,20 @@ export class Virtualizer<
496
496
  } | null = null
497
497
  itemSizeCache = new Map<Key, number>()
498
498
  private itemSizeCacheVersion = 0
499
+ private builtMeasurementOptions: object | null = null
500
+ private builtItemSizeCacheVersion = -1
501
+ private pendingResizes: Array<{ index: number; delta: number }> = []
499
502
  private laneAssignments = new Map<number, number>() // index → lane cache
500
503
  // Earliest index dirtied since last getMeasurements() rebuild, or null.
501
504
  private pendingMin: number | null = null
502
505
  private prevLanes: number | undefined = undefined
503
506
  private lanesChangedFlag = false
504
507
  private lanesSettling = false
508
+ // Whether `initialMeasurementsCache` has seeded `itemSizeCache`. It is
509
+ // read once: a list that empties and refills keeps the sizes measured
510
+ // since, rather than going back to the snapshot's. `enabled: false`
511
+ // resets it along with the sizes.
512
+ private initialMeasurementsCacheApplied = false
505
513
  private pendingScrollAnchor: PendingScrollAnchor | null = null
506
514
  scrollRect: Rect | null = null
507
515
  /**
@@ -549,6 +557,13 @@ export class Virtualizer<
549
557
  // (`followOnAppend does not follow 'trim only'`; reading the element at
550
558
  // write time still moves 49 of 1080 snapshot seeds).
551
559
  private _reportedOverscroll = false
560
+ // How far the scroll element extends past the end of the list: other
561
+ // content that shares it (#1371). Read with the element's scroll range on
562
+ // scroll reports and on attach, against the sizer the element has (the
563
+ // last `getTotalSize()` an adapter drew), not a layout that measurements
564
+ // moved since.
565
+ private _trailing = 0
566
+ private _drawnListEnd = Infinity
552
567
  // The touch gesture in progress (see `IosGesture`). Its tail closing on
553
568
  // its own makes a write possible again: the last momentum frame may have
554
569
  // come before the timer. The hold is released first, so a command that
@@ -626,6 +641,10 @@ export class Virtualizer<
626
641
  smooth: boolean
627
642
  lowMaxes?: Array<number>
628
643
  } | null = null
644
+ // Where the last scroll event reported our own write, until a report
645
+ // anywhere else. The browser reports the write again when the element
646
+ // comes to rest (`restEcho`).
647
+ private _ownWriteAt: number | null = null
629
648
  // A compensation write from `applyScrollAdjustment` whose target exceeded
630
649
  // the element's scroll max at the moment of the write. The browser clamps
631
650
  // such a write because the consumer's sizer has not grown yet: an
@@ -949,7 +968,7 @@ export class Virtualizer<
949
968
  // the rows and the total shifted back by it, so the reader's row
950
969
  // stays put, and the flush writes it once a write is possible.
951
970
  this._holdOffset += anchorDelta
952
- this._followOffsetTarget(anchorDelta)
971
+ this._followAnchor(anchorDelta)
953
972
  }
954
973
  }
955
974
  }
@@ -1069,10 +1088,12 @@ export class Virtualizer<
1069
1088
  // its next touch cycle.
1070
1089
  this._holdOffset = 0
1071
1090
  this._reportedOverscroll = false
1091
+ this._trailing = 0
1072
1092
  // (The gesture was ended with its listeners, in the unsubs above.)
1073
1093
  this._clampedAdjustment = null
1074
1094
  // A write to the old element will never be read back.
1075
1095
  this.pendingWrite = null
1096
+ this._ownWriteAt = null
1076
1097
  this.scrollElement = null
1077
1098
  this.targetWindow = null
1078
1099
  }
@@ -1121,6 +1142,7 @@ export class Virtualizer<
1121
1142
  // judged only while scrolling: at rest the element has clamped,
1122
1143
  // and a stale sizer makes no bounce.
1123
1144
  const elementMax = isScrolling ? this._elementMaxScrollOffset() : null
1145
+ this._readTrailing(elementMax)
1124
1146
  const wasOverscrolled = this._reportedOverscroll
1125
1147
  this._reportedOverscroll =
1126
1148
  offset < 0 || (elementMax !== null && offset > elementMax + 1)
@@ -1161,6 +1183,17 @@ export class Virtualizer<
1161
1183
  this.scrollState = null
1162
1184
  }
1163
1185
  this.pendingWrite = null
1186
+ // Remember where our own write was reported. Its echo at rest
1187
+ // leaves that as it is; any other report clears it.
1188
+ if (
1189
+ kind === 'readBack' ||
1190
+ kind === 'clampedReadBack' ||
1191
+ kind === 'clampedEcho'
1192
+ ) {
1193
+ this._ownWriteAt = offset
1194
+ } else if (kind !== 'restEcho') {
1195
+ this._ownWriteAt = null
1196
+ }
1164
1197
 
1165
1198
  // A pending clamped compensation write (#1258) survives only its
1166
1199
  // own read-back, which the browser reports at the scroll max we
@@ -1259,6 +1292,10 @@ export class Virtualizer<
1259
1292
  }
1260
1293
 
1261
1294
  this._scrollToOffset(this.getScrollOffset())
1295
+ // The rect observer has notified already; reading what follows the
1296
+ // list can change the range again.
1297
+ this._readTrailing(this._elementMaxScrollOffset())
1298
+ this.maybeNotify()
1262
1299
  }
1263
1300
 
1264
1301
  // The consumer has committed the sizer.
@@ -1279,14 +1316,11 @@ export class Virtualizer<
1279
1316
  // an update scheduled from a layout effect commits before paint.
1280
1317
  if (!this._canWriteScroll()) {
1281
1318
  this._holdOffset += anchor.delta
1282
- this._followOffsetTarget(anchor.delta)
1319
+ this._followAnchor(anchor.delta)
1283
1320
  this.notify(false)
1284
1321
  } else if (
1285
1322
  isSmoothScroll(this.scrollState) &&
1286
- !approxEqual(
1287
- this.getScrollOffset() - anchor.delta,
1288
- this.scrollState.lastTargetOffset,
1289
- )
1323
+ !this._landedBeforeAnchor(this.scrollState, anchor.delta)
1290
1324
  ) {
1291
1325
  // A smooth programmatic scroll is still travelling. Writing scrollTop
1292
1326
  // here would cancel the browser's animation, and Chromium drops a
@@ -1294,10 +1328,10 @@ export class Virtualizer<
1294
1328
  // the journey would be stranded. The target is index-based and
1295
1329
  // recomputes against the new layout in reconcileScroll, so let the
1296
1330
  // animation run; the next scroll event re-syncs the tracked offset.
1297
- // A smooth scroll that has already landed (offset at its target,
1298
- // reconcile not yet retired it) still gets the anchor sync.
1331
+ // A smooth scroll that has already landed (reconcile not yet
1332
+ // retired it) still gets the anchor sync.
1299
1333
  } else {
1300
- this._followOffsetTarget(anchor.delta)
1334
+ this._followAnchor(anchor.delta)
1301
1335
  this._scrollToOffset(this.getScrollOffset())
1302
1336
  }
1303
1337
  } else {
@@ -1332,6 +1366,7 @@ export class Virtualizer<
1332
1366
  scrollOffset: this.scrollOffset,
1333
1367
  pendingWrite: this.pendingWrite,
1334
1368
  clampedMaxAtWrite: this._clampedAdjustment?.maxAtWrite ?? null,
1369
+ ownWriteAt: this._ownWriteAt,
1335
1370
  })
1336
1371
 
1337
1372
  // Re-issue a compensation write the browser clamped because the sizer had
@@ -1647,8 +1682,8 @@ export class Virtualizer<
1647
1682
 
1648
1683
  private getMeasurements = memo(
1649
1684
  () => [this.getMeasurementOptions(), this.itemSizeCacheVersion],
1650
- (
1651
- {
1685
+ (measurementOptions, itemSizeCacheVersion) => {
1686
+ const {
1652
1687
  count,
1653
1688
  paddingStart,
1654
1689
  scrollMargin,
@@ -1657,15 +1692,17 @@ export class Virtualizer<
1657
1692
  lanes,
1658
1693
  laneAssignmentMode,
1659
1694
  gap,
1660
- },
1661
- _itemSizeCacheVersion,
1662
- ) => {
1695
+ } = measurementOptions
1696
+ this.builtMeasurementOptions = measurementOptions
1697
+ this.builtItemSizeCacheVersion = itemSizeCacheVersion
1698
+ this.pendingResizes = []
1663
1699
  const itemSizeCache = this.itemSizeCache
1664
1700
  if (!enabled) {
1665
1701
  this.measurementsCache = []
1666
1702
  this._singleLaneMeasurements = null
1667
1703
  this.itemSizeCache.clear()
1668
1704
  this.laneAssignments.clear()
1705
+ this.initialMeasurementsCacheApplied = false
1669
1706
  return []
1670
1707
  }
1671
1708
 
@@ -1692,7 +1729,12 @@ export class Virtualizer<
1692
1729
 
1693
1730
  // Don't restore from initialMeasurementsCache during lane changes
1694
1731
  // as it contains stale lane assignments from the previous lane count
1695
- if (this.measurementsCache.length === 0 && !this.lanesSettling) {
1732
+ if (
1733
+ !this.initialMeasurementsCacheApplied &&
1734
+ this.measurementsCache.length === 0 &&
1735
+ !this.lanesSettling
1736
+ ) {
1737
+ this.initialMeasurementsCacheApplied = true
1696
1738
  this.measurementsCache = this.options.initialMeasurementsCache
1697
1739
  this.measurementsCache.forEach((item) => {
1698
1740
  this.itemSizeCache.set(item.key, item.size)
@@ -1876,16 +1918,19 @@ export class Virtualizer<
1876
1918
  // scrollOffset is measured in the scroll element and the layout total
1877
1919
  // from the list start, so the list ends scrollMargin further down.
1878
1920
  this._getLayoutTotalSize() + this.options.scrollMargin,
1921
+ this._trailing,
1879
1922
  ],
1880
- (measurements, outerSize, scrollOffset, lanes, listEnd) => {
1923
+ (measurements, outerSize, scrollOffset, lanes, listEnd, trailing) => {
1881
1924
  if (measurements.length === 0 || outerSize === 0) {
1882
1925
  this.range = null
1883
1926
  return null
1884
1927
  }
1885
1928
  // Until the element reports a clamped position (the list shrank, a
1886
1929
  // rubber-band bounce), the offset can sit past the last row, which
1887
- // would leave only that row in the range.
1888
- const maxScrollOffset = Math.max(listEnd - outerSize, 0)
1930
+ // would leave only that row in the range. The element ends `trailing`
1931
+ // past the list where other content follows it, and an offset up to
1932
+ // there is where the element is.
1933
+ const maxScrollOffset = Math.max(listEnd + trailing - outerSize, 0)
1889
1934
  this.range = calculateRangeImpl(
1890
1935
  measurements,
1891
1936
  outerSize,
@@ -2028,6 +2073,16 @@ export class Virtualizer<
2028
2073
  }
2029
2074
  }
2030
2075
 
2076
+ private canShiftFromPendingResizes = (): boolean =>
2077
+ this.options.lanes === 1 &&
2078
+ this._singleLaneMeasurements !== null &&
2079
+ this.shouldAdjustScrollPositionOnItemSizeChange === undefined &&
2080
+ !this.lanesChangedFlag &&
2081
+ !this.lanesSettling &&
2082
+ this.getMeasurementOptions() === this.builtMeasurementOptions &&
2083
+ this.itemSizeCacheVersion ===
2084
+ this.builtItemSizeCacheVersion + this.pendingResizes.length
2085
+
2031
2086
  resizeItem = (index: number, size: number) => {
2032
2087
  if (!this.isIndexInRange(index)) return
2033
2088
 
@@ -2037,7 +2092,16 @@ export class Virtualizer<
2037
2092
  // this item's current start, not a stale one, against the adjusted
2038
2093
  // offset (#1218). Without a scroll move, the caches are exactly as stale
2039
2094
  // as they were before batching, so skip the rebuild.
2040
- if (this._resizeBatch?.sync) this.getMeasurements()
2095
+ let startShift = 0
2096
+ if (this._resizeBatch?.sync) {
2097
+ if (this.canShiftFromPendingResizes()) {
2098
+ for (const resize of this.pendingResizes) {
2099
+ if (resize.index < index) startShift += resize.delta
2100
+ }
2101
+ } else {
2102
+ this.getMeasurements()
2103
+ }
2104
+ }
2041
2105
 
2042
2106
  // Fast field reads. For lanes===1 we read raw start/size from the flat
2043
2107
  // typed array, avoiding a Proxy.get + VirtualItem allocation per call.
@@ -2048,7 +2112,7 @@ export class Virtualizer<
2048
2112
  const flat = this._singleLaneMeasurements?.flat
2049
2113
  if (this.options.lanes === 1 && flat != null) {
2050
2114
  key = this.options.getItemKey(index)
2051
- itemStart = flat[index * 2]!
2115
+ itemStart = flat[index * 2]! + startShift
2052
2116
  cachedSize = flat[index * 2 + 1]!
2053
2117
  } else {
2054
2118
  const item = this.measurementsCache[index]
@@ -2109,6 +2173,7 @@ export class Virtualizer<
2109
2173
  }
2110
2174
  this.itemSizeCache.set(key, size)
2111
2175
  this.itemSizeCacheVersion++
2176
+ this.pendingResizes.push({ index, delta })
2112
2177
 
2113
2178
  // Before a command's read-back, an index or end target is retargeted
2114
2179
  // from fresh measurements by reconcileScroll next frame; an offset
@@ -2149,6 +2214,17 @@ export class Virtualizer<
2149
2214
  // `_willUpdate` (#1266).
2150
2215
  this._flushHoldIfReady(true)
2151
2216
  this._retryClampedAdjustment()
2217
+ } else if (
2218
+ this.options.lanes > 1 &&
2219
+ !this.options.useCachedMeasurements &&
2220
+ !this.laneAssignments.has(index)
2221
+ ) {
2222
+ // Measured at its estimate, so no rebuild will cache its lane. A single
2223
+ // lane has none to cache, a size under useCachedMeasurements is not a
2224
+ // measurement, and a lane already cached (as always in 'estimate' mode)
2225
+ // must not change.
2226
+ const item = this.getMeasurements()[index]
2227
+ if (item) this.laneAssignments.set(index, item.lane)
2152
2228
  }
2153
2229
  }
2154
2230
 
@@ -2241,6 +2317,12 @@ export class Virtualizer<
2241
2317
  return offset
2242
2318
  }
2243
2319
 
2320
+ private _readTrailing = (elementMax: number | null) => {
2321
+ if (elementMax === null) return
2322
+ const trailing = elementMax + this.getSize() - this._drawnListEnd
2323
+ this._trailing = trailing > 0 ? trailing : 0
2324
+ }
2325
+
2244
2326
  // The element's own scroll range, or null where it cannot be read (no
2245
2327
  // element, or a bare test double without `scrollHeight` / `document`).
2246
2328
  private _elementMaxScrollOffset = (): number | null => {
@@ -2598,18 +2680,21 @@ export class Virtualizer<
2598
2680
  // The size the consumer gives the container: the layout's total, short by
2599
2681
  // a held correction so the rows exposed shifted by it still fill it (see
2600
2682
  // `_holdOffset`).
2601
- getTotalSize = () =>
2602
- Math.max(this._getLayoutTotalSize() - this._holdOffset, 0)
2683
+ getTotalSize = () => {
2684
+ const total = Math.max(this._getLayoutTotalSize() - this._holdOffset, 0)
2685
+ this._drawnListEnd = total + this.options.scrollMargin
2686
+ return total
2687
+ }
2603
2688
 
2604
2689
  private _getLayoutTotalSize = () => {
2605
2690
  const measurements = this.getMeasurements()
2606
2691
 
2607
2692
  let end: number
2608
- // If there are no measurements, set the end to paddingStart
2693
+ // If there are no measurements, include the scroll origin and start padding
2609
2694
  // If there is only one lane, use the last measurement's end
2610
2695
  // Otherwise find the maximum end value among all measurements
2611
2696
  if (measurements.length === 0) {
2612
- end = this.options.paddingStart
2697
+ end = this.options.scrollMargin + this.options.paddingStart
2613
2698
  } else if (this.options.lanes === 1) {
2614
2699
  // Fast path: read last item's end directly from the flat typed array
2615
2700
  // when available; avoids a Proxy.get + VirtualItem materialization
@@ -2738,6 +2823,32 @@ export class Virtualizer<
2738
2823
  }
2739
2824
  }
2740
2825
 
2826
+ // Whether a command had landed where a prepend's anchor (`delta`, already
2827
+ // in `getScrollOffset()`) found the viewport: it has written (a `queued`
2828
+ // command has not, wherever the fling is), and reconcile has seen it at
2829
+ // its target or the viewport is where it last wrote. A correction since
2830
+ // then can have moved the viewport and the target together.
2831
+ private _landedBeforeAnchor = (state: ScrollState, delta: number) =>
2832
+ state.phase !== 'queued' &&
2833
+ (state.stableFrames > 0 ||
2834
+ approxEqual(this.getScrollOffset() - delta, state.lastTargetOffset))
2835
+
2836
+ // A prepend's anchor moves the viewport with the rows it shows. An offset
2837
+ // target moves with it. An index command that had landed is done: the
2838
+ // reader stays on the rows it was aimed at, and its index now names
2839
+ // others. An end target is still the end.
2840
+ private _followAnchor = (delta: number) => {
2841
+ this._followOffsetTarget(delta)
2842
+ const state = this.scrollState
2843
+ if (
2844
+ state?.index != null &&
2845
+ !state.toEnd &&
2846
+ this._landedBeforeAnchor(state, delta)
2847
+ ) {
2848
+ this.scrollState = null
2849
+ }
2850
+ }
2851
+
2741
2852
  measure = () => {
2742
2853
  // Reset pendingMin so the next getMeasurements rebuilds from index 0.
2743
2854
  // Without this, a prior resizeItem() that left pendingMin > 0 would
@@ -12,6 +12,8 @@ import { approxEqual } from './utils'
12
12
  // through since the write
13
13
  // clampedEcho a compensation write the browser clamped (#1258)
14
14
  // reporting at the max seen at write time
15
+ // restEcho our own write reported again at rest, where the last
16
+ // scroll event reported it
15
17
  // external anything else: the user, a fling, a smooth animation
16
18
  // frame
17
19
  type ScrollEventKind =
@@ -19,6 +21,7 @@ type ScrollEventKind =
19
21
  | 'readBack'
20
22
  | 'clampedReadBack'
21
23
  | 'clampedEcho'
24
+ | 'restEcho'
22
25
  | 'external'
23
26
 
24
27
  export interface ScrollEventInput {
@@ -44,6 +47,9 @@ export interface ScrollEventInput {
44
47
  // The element's max when a clamped compensation write was made (#1258),
45
48
  // or null when none is pending.
46
49
  clampedMaxAtWrite: number | null
50
+ // Where the last scroll event reported our own write (read back, clamped
51
+ // or echoed), until a report anywhere else.
52
+ ownWriteAt: number | null
47
53
  }
48
54
 
49
55
  export function classifyScrollEvent({
@@ -54,6 +60,7 @@ export function classifyScrollEvent({
54
60
  scrollOffset,
55
61
  pendingWrite,
56
62
  clampedMaxAtWrite,
63
+ ownWriteAt,
57
64
  }: ScrollEventInput): ScrollEventKind {
58
65
  // A scroll event that reports movement but lands on the offset we already
59
66
  // hold — and isn't a self-write read-back — is a spurious no-op re-emit
@@ -99,6 +106,17 @@ export function classifyScrollEvent({
99
106
  ) {
100
107
  return 'clampedEcho'
101
108
  }
109
+ // A write is reported again when the element comes to rest: `scrollend`
110
+ // follows its scroll event in the same frame's scroll steps, before
111
+ // reconcile; the fallback follows it after `isScrollingResetDelay`.
112
+ // Nothing has moved the element in between.
113
+ if (
114
+ !isScrolling &&
115
+ ownWriteAt !== null &&
116
+ Math.abs(offset - ownWriteAt) < 1.5
117
+ ) {
118
+ return 'restEcho'
119
+ }
102
120
  return 'external'
103
121
  }
104
122
 
@@ -142,14 +160,17 @@ export interface RetireInput {
142
160
 
143
161
  // Whether a scroll event that is not the read-back of our own write retires
144
162
  // the in-flight index command: an external scroll moved away from its
145
- // target. Our own measurement updates (including clamped writes) still need
146
- // to reconcile.
163
+ // target, or our own write left the element where reconcile will not move
164
+ // it. Our own measurement updates (including clamped writes) still need to
165
+ // reconcile.
147
166
  export function externalRetiresCommand({
148
167
  kind,
149
168
  offset,
150
169
  command,
151
170
  target,
152
171
  }: RetireInput): boolean {
172
+ let fresh: number | undefined
173
+ const freshTarget = () => (fresh ??= target())
153
174
  return (
154
175
  kind !== 'spurious' &&
155
176
  kind !== 'readBack' &&
@@ -170,7 +191,14 @@ export function externalRetiresCommand({
170
191
  // has landed.
171
192
  !isAnimating(command.phase) &&
172
193
  !approxEqual(offset, command.lastTargetOffset) &&
173
- !approxEqual(offset, target()) &&
194
+ !approxEqual(offset, freshTarget()) &&
195
+ // Our own write reported again at rest (`restEcho`): nothing else has
196
+ // moved the element, but reconcile writes only a target that moved. Once
197
+ // the target has moved since the command wrote it, reconcile lands the
198
+ // command there (with `scrollend`, a correction's echo arrives before
199
+ // reconcile has run on the measurements behind it); while it has not,
200
+ // nothing will bring the element back, and the command ends here.
201
+ (kind !== 'restEcho' || freshTarget() === command.lastTargetOffset) &&
174
202
  // A compensation write's clamped echo (#1258) keeps the command. The
175
203
  // order is deliberate, not tidiness: this clause stays after `target()`
176
204
  // (and `clampedReadBack` before it) because `target()` can rebuild the
@@ -3,7 +3,8 @@
3
3
  "version": "0.3.0",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": "./src/index.ts"
6
+ ".": "./src/index.ts",
7
+ "./modal": "./src/modal.ts"
7
8
  },
8
9
  "scripts": {
9
10
  "test": "bun test",
@@ -0,0 +1,24 @@
1
+ /** Metadata only: inputs, connection details and result bodies are never collected. */
2
+ export interface DiagnosticOperation {
3
+ id: string;
4
+ adapterId: string;
5
+ serviceId: string | null;
6
+ kind: string;
7
+ startedAt: number;
8
+ durationMs: number;
9
+ outcome: "active" | "success" | "error";
10
+ }
11
+
12
+ export interface DiagnosticProcess {
13
+ adapterId: string;
14
+ serviceId: string | null;
15
+ pid: number;
16
+ rssBytes: number | null;
17
+ cpuPercent: number | null;
18
+ }
19
+
20
+ export interface DiagnosticSnapshot {
21
+ processes?: readonly DiagnosticProcess[];
22
+ operations: readonly DiagnosticOperation[];
23
+ droppedOperations: number;
24
+ }
@@ -7,6 +7,12 @@ export const signalEventSchema = z.object({
7
7
  sourceType: z.string(),
8
8
  sourceId: z.string(),
9
9
  serviceId: z.string().optional(),
10
+ /**
11
+ * The principal id of the person whose request caused the signal, such as
12
+ * someone running a service action. Absent for background work, local
13
+ * single-user mode and signals recorded before this field existed.
14
+ */
15
+ actor: z.string().optional(),
10
16
  payload: z.unknown(),
11
17
  occurredAt: z.string(),
12
18
  });