@octanejs/tanstack-virtual 0.1.68 → 0.1.70
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.
- package/UPSTREAM.md +15 -9
- package/package.json +6 -6
- package/src/index.ts +51 -24
package/UPSTREAM.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Upstream
|
|
2
2
|
|
|
3
3
|
- Repository: https://github.com/TanStack/virtual
|
|
4
|
-
- Package: `@tanstack/react-virtual@3.14.
|
|
5
|
-
- Release commit: `
|
|
4
|
+
- Package: `@tanstack/react-virtual@3.14.26`
|
|
5
|
+
- Release commit: `11b48e4ab8b08d483c8fe29a31ef11261ffbda04`
|
|
6
6
|
- Source root: `packages/react-virtual/src`
|
|
7
7
|
- Test roots: `packages/react-virtual/tests` and `packages/react-virtual/e2e`
|
|
8
8
|
- License: MIT; exact root license in `LICENSE.upstream`
|
|
9
|
-
- npm artifact SHA-256: `
|
|
10
|
-
- Runtime dependency: `@tanstack/virtual-core@3.
|
|
9
|
+
- npm artifact SHA-256: `1c6d0c9c5ec85d51946e074eff195b4ed81f9764e748498cd6d896bd06ecde77`
|
|
10
|
+
- Runtime dependency: `@tanstack/virtual-core@3.19.11`, imported directly
|
|
11
11
|
|
|
12
12
|
## Source boundary
|
|
13
13
|
|
|
14
|
-
`audit/upstream.lock.json` pins all
|
|
14
|
+
`audit/upstream.lock.json` pins all 56 files in the upstream package, including
|
|
15
15
|
its complete source, unit tests and browser fixtures. The immutable source and
|
|
16
16
|
artifact are test inputs and are excluded from publication. The binding adapts
|
|
17
17
|
the React hook implementation; `src/internal.ts` supplies native slot handling.
|
|
@@ -24,18 +24,24 @@ regression with the old adapter as the failing control, the same current core,
|
|
|
24
24
|
and assertions on scroll extent, offset and retained row identity. Public hook
|
|
25
25
|
signatures also exclude the compiler's internal trailing slot argument.
|
|
26
26
|
|
|
27
|
+
`tests/browser-contracts/history-append.spec.ts` holds the reconcile frame that
|
|
28
|
+
the chat fixture's initial `scrollToEnd()` queues, scrolls up into history,
|
|
29
|
+
appends and then releases the frame. With virtual-core 3.17.10 as the failing
|
|
30
|
+
control, the release moved `scrollTop` from 350 to 1,198 px (#2860). The
|
|
31
|
+
upstream fix lets an external scroll retire the pending command.
|
|
32
|
+
|
|
27
33
|
## Executable coverage
|
|
28
34
|
|
|
29
|
-
The exact release contains
|
|
35
|
+
The exact release contains 11 unit registrations and 44 browser registrations,
|
|
30
36
|
including expanded positioning-mode cases. `audit/registrations.json` and
|
|
31
|
-
`audit/crosswalk.json` account for all
|
|
37
|
+
`audit/crosswalk.json` account for all 55. `materialize run` regenerates the Octane
|
|
32
38
|
adaptation using only the mechanical rewrites in the lock. No upstream runtime
|
|
33
39
|
assertions are removed or relaxed.
|
|
34
40
|
|
|
35
41
|
| Suite | React | Octane |
|
|
36
42
|
| --- | --- | --- |
|
|
37
|
-
| Unit |
|
|
38
|
-
| Chromium | All
|
|
43
|
+
| Unit | All 11 unchanged cases | All 11 mechanically adapted cases |
|
|
44
|
+
| Chromium | All 44 unchanged browser cases | All 44 adapted cases plus three end-anchor regressions |
|
|
39
45
|
| Dedicated upstream type cases | None at this release | None to materialize |
|
|
40
46
|
| Authored strict public type probes | All 26 exports with negative controls | The same contracts and negative controls |
|
|
41
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-virtual",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -40,20 +40,20 @@
|
|
|
40
40
|
".": "./src/index.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@tanstack/virtual-core": "3.
|
|
43
|
+
"@tanstack/virtual-core": "3.19.11"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"octane": "^0.
|
|
46
|
+
"octane": "^0.21.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@tanstack/react-virtual": "3.14.
|
|
49
|
+
"@tanstack/react-virtual": "3.14.26",
|
|
50
50
|
"@tsrx/react": "^0.4.5",
|
|
51
51
|
"esbuild": "^0.28.1",
|
|
52
|
-
"octane": "0.
|
|
52
|
+
"octane": "0.21.0",
|
|
53
53
|
"react": "19.2.7",
|
|
54
54
|
"react-dom": "19.2.7",
|
|
55
55
|
"vitest": "^4.1.10",
|
|
56
|
-
"@octanejs/testing-library": "0.1.
|
|
56
|
+
"@octanejs/testing-library": "0.1.73",
|
|
57
57
|
"@testing-library/react": "^16.3.2",
|
|
58
58
|
"@testing-library/jest-dom": "^6.9.1",
|
|
59
59
|
"@babel/core": "7.29.7",
|
package/src/index.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
observeWindowRect,
|
|
33
33
|
windowScroll,
|
|
34
34
|
} from '@tanstack/virtual-core';
|
|
35
|
-
import type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core';
|
|
35
|
+
import type { PartialKeys, VirtualItem, VirtualizerOptions } from '@tanstack/virtual-core';
|
|
36
36
|
import { splitSlot, subSlot } from './internal';
|
|
37
37
|
|
|
38
38
|
export * from '@tanstack/virtual-core';
|
|
@@ -104,6 +104,10 @@ function useVirtualizerBase<TScrollElement extends Element | Window, TItemElemen
|
|
|
104
104
|
directRef.current.enabled = directDomUpdates;
|
|
105
105
|
directRef.current.mode = directDomUpdatesMode;
|
|
106
106
|
|
|
107
|
+
// Set while the virtualizer measures an item through `measureElement`, which is
|
|
108
|
+
// passed as a ref and therefore runs while the renderer is committing.
|
|
109
|
+
const measuringFromRef = useRef(false, subSlot(slot, 'uvb:mr'));
|
|
110
|
+
|
|
107
111
|
const applyContainerSize = (instance: Virtualizer<TScrollElement, TItemElement>) => {
|
|
108
112
|
const state = directRef.current;
|
|
109
113
|
if (!state.enabled || !state.container) return;
|
|
@@ -115,28 +119,34 @@ function useVirtualizerBase<TScrollElement extends Element | Window, TItemElemen
|
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
121
|
|
|
122
|
+
// Writes one item's main-axis position to its element. Idempotent — guarded
|
|
123
|
+
// by lastPositions.
|
|
124
|
+
const applyItemPosition = (
|
|
125
|
+
instance: Virtualizer<TScrollElement, TItemElement>,
|
|
126
|
+
item: VirtualItem,
|
|
127
|
+
el: HTMLElement,
|
|
128
|
+
) => {
|
|
129
|
+
const state = directRef.current;
|
|
130
|
+
const horizontal = !!instance.options.horizontal;
|
|
131
|
+
const next = item.start - instance.options.scrollMargin;
|
|
132
|
+
if (state.lastPositions.get(el) === next) return;
|
|
133
|
+
state.lastPositions.set(el, next);
|
|
134
|
+
if (state.mode === 'transform') {
|
|
135
|
+
el.style.transform = horizontal
|
|
136
|
+
? `translate3d(${next}px, 0, 0)`
|
|
137
|
+
: `translate3d(0, ${next}px, 0)`;
|
|
138
|
+
} else {
|
|
139
|
+
el.style[horizontal ? 'left' : 'top'] = `${next}px`;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
118
143
|
const applyDirectStyles = (instance: Virtualizer<TScrollElement, TItemElement>) => {
|
|
119
144
|
const state = directRef.current;
|
|
120
145
|
if (!state.enabled || !state.container) return;
|
|
121
146
|
applyContainerSize(instance);
|
|
122
|
-
const
|
|
123
|
-
const useTransform = state.mode === 'transform';
|
|
124
|
-
const posAxis = horizontal ? 'left' : 'top';
|
|
125
|
-
const scrollMargin = instance.options.scrollMargin;
|
|
126
|
-
const items = instance.getVirtualItems();
|
|
127
|
-
for (const item of items) {
|
|
128
|
-
const next = item.start - scrollMargin;
|
|
147
|
+
for (const item of instance.getVirtualItems()) {
|
|
129
148
|
const el = instance.elementsCache.get(item.key) as HTMLElement | undefined;
|
|
130
|
-
if (
|
|
131
|
-
if (state.lastPositions.get(el) === next) continue;
|
|
132
|
-
state.lastPositions.set(el, next);
|
|
133
|
-
if (useTransform) {
|
|
134
|
-
el.style.transform = horizontal
|
|
135
|
-
? `translate3d(${next}px, 0, 0)`
|
|
136
|
-
: `translate3d(0, ${next}px, 0)`;
|
|
137
|
-
} else {
|
|
138
|
-
el.style[posAxis] = `${next}px`;
|
|
139
|
-
}
|
|
149
|
+
if (el) applyItemPosition(instance, item, el);
|
|
140
150
|
}
|
|
141
151
|
};
|
|
142
152
|
|
|
@@ -165,7 +175,9 @@ function useVirtualizerBase<TScrollElement extends Element | Window, TItemElemen
|
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
if (shouldRerender) {
|
|
168
|
-
|
|
178
|
+
// A sync notify raised from `measureElement` (a ref callback) arrives
|
|
179
|
+
// mid-commit, which already runs at sync priority, so it skips flushSync.
|
|
180
|
+
if (useFlushSync && sync && !measuringFromRef.current) {
|
|
169
181
|
// OCTANE DIVERGENCE[nested-flushsync-degradation][conformance:nested-flush-sync-scroll]:
|
|
170
182
|
// nested flushSync degrades to the ambient flush under Octane.
|
|
171
183
|
flushSync(rerender);
|
|
@@ -180,16 +192,31 @@ function useVirtualizerBase<TScrollElement extends Element | Window, TItemElemen
|
|
|
180
192
|
const [instance] = useState(
|
|
181
193
|
() => {
|
|
182
194
|
const v = new Virtualizer<TScrollElement, TItemElement>(resolvedOptions);
|
|
195
|
+
const measureElement = v.measureElement;
|
|
196
|
+
v.measureElement = (node: TItemElement | null) => {
|
|
197
|
+
measuringFromRef.current = true;
|
|
198
|
+
try {
|
|
199
|
+
measureElement(node);
|
|
200
|
+
} finally {
|
|
201
|
+
measuringFromRef.current = false;
|
|
202
|
+
}
|
|
203
|
+
// A row can mount in a commit that does not re-render this component,
|
|
204
|
+
// which the applyDirectStyles effect never sees. Position it as it
|
|
205
|
+
// registers; rows the effect covers are skipped by lastPositions.
|
|
206
|
+
const state = directRef.current;
|
|
207
|
+
if (node !== null && state.enabled && state.container) {
|
|
208
|
+
const item = v.measurementsCache[v.indexFromElement(node)];
|
|
209
|
+
if (item) applyItemPosition(v, item, node as unknown as HTMLElement);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
183
212
|
return Object.assign(v, {
|
|
184
213
|
containerRef: (node: HTMLElement | null) => {
|
|
185
214
|
const state = directRef.current;
|
|
186
215
|
state.container = node;
|
|
187
216
|
state.lastSize = null;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const axis = v.options.horizontal ? 'width' : 'height';
|
|
192
|
-
node.style[axis] = `${total}px`;
|
|
217
|
+
// Sizes the container and positions rows whose refs attached first.
|
|
218
|
+
if (node !== null) {
|
|
219
|
+
applyDirectStyles(v);
|
|
193
220
|
}
|
|
194
221
|
},
|
|
195
222
|
});
|