fix(app): make virtua patch bun-compatible

This commit is contained in:
LukeParkerDev 2026-05-20 18:20:58 +10:00
parent c4e8640e00
commit 20dc43c416

View file

@ -1,5 +1,20 @@
diff --git a/lib/solid/Virtualizer.d.ts b/lib/solid/Virtualizer.d.ts
index 144dd7f..819aab9 100644
--- a/lib/solid/Virtualizer.d.ts
+++ b/lib/solid/Virtualizer.d.ts
@@ -38,6 +38,10 @@ export interface VirtualizerHandle {
* @param index index of item
*/
getItemSize(index: number): number;
+ /**
+ * Synchronously measure currently mounted items and update cached item sizes.
+ */
+ measure(): void;
/**
* Scroll to the item specified by index.
* @param index index of item
diff --git a/lib/solid/index.jsx b/lib/solid/index.jsx
index 029201a2c8..e3c4c0ca3a 100644
index 029201a..3949cd4 100644
--- a/lib/solid/index.jsx
+++ b/lib/solid/index.jsx
@@ -1085,6 +1085,7 @@ const createResizer = (store, isHorizontal) => {
@ -38,7 +53,16 @@ index 029201a2c8..e3c4c0ca3a 100644
$dispose: resizeObserver._dispose,
};
};
@@ -1380,6 +1396,7 @@ const Virtualizer = (props) => {
@@ -1354,6 +1370,8 @@ const Virtualizer = (props) => {
const range = createMemo((prev) => {
stateVersion();
const next = store.$getRange(props.bufferSize);
+ next[0] = Math.max(0, next[0]);
+ next[1] = Math.min(props.data.length - 1, next[1]);
if (prev && isSameRange(prev, next)) {
return prev;
}
@@ -1380,6 +1398,7 @@ const Virtualizer = (props) => {
findItemIndex: store.$findItemIndex,
getItemOffset: store.$getItemOffset,
getItemSize: store.$getItemSize,
@ -46,46 +70,24 @@ index 029201a2c8..e3c4c0ca3a 100644
scrollToIndex: scroller.$scrollToIndex,
scrollTo: scroller.$scrollTo,
scrollBy: scroller.$scrollBy,
@@ -1423,5 +1440,7 @@ const Virtualizer = (props) => {
}
sort([...mounted]).forEach((index) => {
+ if (index < 0 || index >= count)
+ return;
items.push(props.data[index]);
indexes.push(index);
});
@@ -1430,5 +1449,7 @@ const Virtualizer = (props) => {
else {
for (let [i, j] = range(); i <= j; i++) {
- items.push(props.data[i]);
- indexes.push(i);
+ if (i >= 0 && i < count) {
+ items.push(props.data[i]);
+ indexes.push(i);
@@ -1417,6 +1436,11 @@ const Virtualizer = (props) => {
const indexes = [];
if (props.keepMounted) {
const mounted = new Set(props.keepMounted);
+ mounted.forEach((index) => {
+ if (index < 0 || index >= count) {
+ mounted.delete(index);
+ }
+ });
for (let [i, j] = range(); i <= j; i++) {
mounted.add(i);
}
@@ -1579,6 +1600,8 @@ const VList = (props) => {
});
const items = [];
for (let [i, j] = range(); i <= j; i++) {
- items.push(props.data[i]);
+ if (i >= 0 && i < count) {
+ items.push(props.data[i]);
+ }
@@ -1528,6 +1552,8 @@ const WindowVirtualizer = (props) => {
const range = createMemo((prev) => {
stateVersion();
const next = store.$getRange(props.bufferSize);
+ next[0] = Math.max(0, next[0]);
+ next[1] = Math.min(props.data.length - 1, next[1]);
if (prev && isSameRange(prev, next)) {
return prev;
}
return items;
diff --git a/lib/solid/Virtualizer.d.ts b/lib/solid/Virtualizer.d.ts
index 144dd7fba8..819aab92c5 100644
--- a/lib/solid/Virtualizer.d.ts
+++ b/lib/solid/Virtualizer.d.ts
@@ -38,6 +38,10 @@ export interface VirtualizerHandle {
* @param index index of item
*/
getItemSize(index: number): number;
+ /**
+ * Synchronously measure currently mounted items and update cached item sizes.
+ */
+ measure(): void;
/**
* Scroll to the item specified by index.
* @param index index of item