virtua 0.49.2 → 0.50.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 (59) hide show
  1. package/README.md +39 -5
  2. package/lib/angular/ListItem.d.ts +1 -0
  3. package/lib/angular/VList.d.ts +85 -0
  4. package/lib/angular/Virtualizer.d.ts +141 -0
  5. package/lib/angular/WindowVirtualizer.d.ts +103 -0
  6. package/lib/angular/index.d.ts +6 -0
  7. package/lib/angular/index.js +1148 -0
  8. package/lib/angular/index.js.map +1 -0
  9. package/lib/angular/utils.d.ts +19 -0
  10. package/lib/core/index.cjs +237 -233
  11. package/lib/core/index.cjs.map +1 -1
  12. package/lib/core/index.d.ts +6 -6
  13. package/lib/core/index.js +272 -272
  14. package/lib/core/index.js.map +1 -1
  15. package/lib/index.cjs +529 -499
  16. package/lib/index.cjs.map +1 -1
  17. package/lib/index.d.ts +2 -2
  18. package/lib/index.js +321 -315
  19. package/lib/index.js.map +1 -1
  20. package/lib/react/VGrid.d.ts +2 -2
  21. package/lib/react/VList.d.ts +3 -3
  22. package/lib/react/Virtualizer.d.ts +3 -3
  23. package/lib/react/WindowVirtualizer.d.ts +3 -3
  24. package/lib/react/index.d.ts +9 -9
  25. package/lib/react/types.d.ts +1 -1
  26. package/lib/solid/VList.d.ts +3 -6
  27. package/lib/solid/Virtualizer.d.ts +2 -5
  28. package/lib/solid/WindowVirtualizer.d.ts +2 -5
  29. package/lib/solid/index.cjs +331 -323
  30. package/lib/solid/index.cjs.map +1 -1
  31. package/lib/solid/index.d.ts +7 -7
  32. package/lib/solid/index.js +249 -257
  33. package/lib/solid/index.js.map +1 -1
  34. package/lib/solid/index.jsx +1224 -1566
  35. package/lib/solid/index.jsx.map +1 -1
  36. package/lib/solid/types.d.ts +1 -1
  37. package/lib/svelte/ListItem.svelte +12 -2
  38. package/lib/svelte/VList.svelte +2 -0
  39. package/lib/svelte/VList.type.d.ts +3 -3
  40. package/lib/svelte/Virtualizer.svelte +2 -0
  41. package/lib/svelte/Virtualizer.type.d.ts +8 -3
  42. package/lib/svelte/WindowVirtualizer.type.d.ts +2 -2
  43. package/lib/svelte/index.d.ts +6 -6
  44. package/lib/svelte/index.js +4 -4
  45. package/lib/svelte/types.d.ts +1 -1
  46. package/lib/svelte/utils.d.ts +7 -0
  47. package/lib/svelte/utils.js +11 -11
  48. package/lib/svelte/utils.js.map +1 -1
  49. package/lib/vue/VList.d.ts +2 -3
  50. package/lib/vue/Virtualizer.d.ts +3 -4
  51. package/lib/vue/WindowVirtualizer.d.ts +2 -3
  52. package/lib/vue/index.cjs +327 -317
  53. package/lib/vue/index.cjs.map +1 -1
  54. package/lib/vue/index.d.ts +6 -6
  55. package/lib/vue/index.js +284 -284
  56. package/lib/vue/index.js.map +1 -1
  57. package/lib/vue/utils.d.ts +1 -1
  58. package/package.json +40 -17
  59. package/lib/svelte/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/core/utils.ts","../../src/core/cache.ts","../../src/core/environment.ts","../../src/core/store.ts","../../src/core/scroller.ts","../../src/core/resizer.ts","../../src/angular/ListItem.ts","../../src/angular/utils.ts","../../src/angular/Virtualizer.ts","../../src/angular/VList.ts","../../src/angular/WindowVirtualizer.ts"],"sourcesContent":["/** @internal */\nexport const NULL = null;\n\n/** @internal */\nexport const { min, max, abs, floor } = Math;\n\n/**\n * @internal\n */\nexport const clamp = (\n value: number,\n minValue: number,\n maxValue: number,\n): number => min(maxValue, max(minValue, value));\n\n/**\n * @internal\n */\nexport const sort = <T extends number>(arr: readonly T[]): T[] => {\n return [...arr].sort((a, b) => a - b);\n};\n\n/**\n * @internal\n */\nexport const microtask: (fn: () => void) => void =\n typeof queueMicrotask === \"function\"\n ? queueMicrotask\n : (fn) => {\n Promise.resolve().then(fn);\n };\n\n/**\n * @internal\n */\nexport const createPromise = <T = void>(): [Promise<T>, (arg: T) => void] => {\n let resolve: ((arg: T) => void) | undefined;\n const promise = new Promise<T>((res) => {\n resolve = res;\n });\n return [promise, resolve!];\n};\n\n/**\n * @internal\n */\nexport const once = <T>(fn: () => T): (() => T) => {\n let cache: T;\n\n return () => {\n if (fn) {\n cache = fn();\n fn = undefined!;\n }\n return cache;\n };\n};\n","import { type InternalCacheSnapshot, type ItemsRange } from \"./types.js\";\nimport { clamp, floor, max, min, sort } from \"./utils.js\";\n\ntype Writeable<T> = {\n -readonly [key in keyof T]: Writeable<T[key]>;\n};\n\n/** @internal */\nexport const UNCACHED = -1;\n\n/**\n * @internal\n */\nexport type Cache = {\n readonly _length: number;\n // sizes\n readonly _sizes: number[];\n readonly _defaultItemSize: number;\n // offsets\n readonly _computedOffsetIndex: number;\n readonly _offsets: number[];\n};\n\nconst fill = (array: number[], length: number, prepend?: boolean): number[] => {\n const key = prepend ? \"unshift\" : \"push\";\n for (let i = 0; i < length; i++) {\n array[key](UNCACHED);\n }\n return array;\n};\n\n/**\n * @internal\n */\nexport const getItemSize = (cache: Cache, index: number): number => {\n const size = cache._sizes[index]!;\n return size === UNCACHED ? cache._defaultItemSize : size;\n};\n\n/**\n * @internal\n */\nexport const setItemSize = (\n cache: Writeable<Cache>,\n index: number,\n size: number,\n): boolean => {\n const isInitialMeasurement = cache._sizes[index] === UNCACHED;\n cache._sizes[index] = size;\n // mark as dirty\n cache._computedOffsetIndex = min(index, cache._computedOffsetIndex);\n return isInitialMeasurement;\n};\n\n/**\n * @internal\n */\nexport const getItemOffset = (\n cache: Writeable<Cache>,\n index: number,\n): number => {\n if (!cache._length) return 0;\n if (cache._computedOffsetIndex >= index) {\n return cache._offsets[index]!;\n }\n\n if (cache._computedOffsetIndex < 0) {\n // first offset must be 0 to avoid returning NaN, which can cause infinite rerender.\n // https://github.com/inokawa/virtua/pull/160\n cache._offsets[0] = 0;\n cache._computedOffsetIndex = 0;\n }\n let i = cache._computedOffsetIndex;\n let top = cache._offsets[i]!;\n while (i < index) {\n top += getItemSize(cache, i);\n cache._offsets[++i] = top;\n }\n // mark as measured\n cache._computedOffsetIndex = index;\n return top;\n};\n\n/**\n * Finds the index of an item in the cache whose computed offset is closest to the specified offset.\n *\n * @internal\n */\nexport const findIndex = (\n cache: Cache,\n offset: number,\n low: number = 0,\n high: number = cache._length - 1,\n): number => {\n // Find with binary search\n let found: number = low;\n while (low <= high) {\n const mid = floor((low + high) / 2);\n if (getItemOffset(cache, mid) <= offset) {\n found = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n return clamp(found, 0, cache._length - 1);\n};\n\n/**\n * @internal\n */\nexport const computeRange = (\n cache: Cache,\n startOffset: number,\n endOffset: number,\n prevStartIndex: number,\n): ItemsRange => {\n // Clamp because prevStartIndex may exceed the limit when children decreased a lot after scrolling\n prevStartIndex = min(prevStartIndex, cache._length - 1);\n\n if (getItemOffset(cache, prevStartIndex) <= startOffset) {\n // search forward\n // start <= end, prevStartIndex <= start\n const end = findIndex(cache, endOffset, prevStartIndex);\n return [findIndex(cache, startOffset, prevStartIndex, end), end];\n } else {\n // search backward\n // start <= end, start <= prevStartIndex\n const start = findIndex(cache, startOffset, undefined, prevStartIndex);\n return [start, findIndex(cache, endOffset, start)];\n }\n};\n\n/**\n * @internal\n */\nexport const estimateDefaultItemSize = (\n cache: Writeable<Cache>,\n startIndex: number,\n): number => {\n let measuredCountBeforeStart = 0;\n // This function will be called after measurement so measured size array must be longer than 0\n const measuredSizes: number[] = [];\n cache._sizes.forEach((s, i) => {\n if (s !== UNCACHED) {\n measuredSizes.push(s);\n if (i < startIndex) {\n measuredCountBeforeStart++;\n }\n }\n });\n\n // Discard cache for now\n cache._computedOffsetIndex = -1;\n\n // Calculate median\n const sorted = sort(measuredSizes);\n const len = sorted.length;\n const mid = (len / 2) | 0;\n const median =\n len % 2 === 0 ? (sorted[mid - 1]! + sorted[mid]!) / 2 : sorted[mid]!;\n\n const prevDefaultItemSize = cache._defaultItemSize;\n\n // Calculate diff of unmeasured items before start\n return (\n ((cache._defaultItemSize = median) - prevDefaultItemSize) *\n max(startIndex - measuredCountBeforeStart, 0)\n );\n};\n\n/**\n * @internal\n */\nexport const initCache = (\n length: number,\n itemSize: number,\n sizes?: readonly number[],\n): Cache => {\n return {\n _defaultItemSize: itemSize,\n _sizes: sizes\n ? // https://github.com/inokawa/virtua/issues/441\n fill(\n sizes.slice(0, min(length, sizes.length)),\n max(0, length - sizes.length),\n )\n : fill([], length),\n _length: length,\n _computedOffsetIndex: -1,\n _offsets: fill([], length + 1),\n };\n};\n\n/**\n * @internal\n */\nexport const takeCacheSnapshot = (cache: Cache): InternalCacheSnapshot => {\n return [cache._sizes.slice(), cache._defaultItemSize];\n};\n\n/**\n * @internal\n */\nexport const updateCacheLength = (\n cache: Writeable<Cache>,\n length: number,\n isShift?: boolean,\n): number => {\n const diff = length - cache._length;\n\n cache._computedOffsetIndex = isShift\n ? // Discard cache for now\n -1\n : min(length - 1, cache._computedOffsetIndex);\n cache._length = length;\n\n if (diff > 0) {\n // Added\n fill(cache._offsets, diff);\n fill(cache._sizes, diff, isShift);\n return cache._defaultItemSize * diff;\n } else {\n // Removed\n cache._offsets.splice(diff);\n return (\n isShift ? cache._sizes.splice(0, -diff) : cache._sizes.splice(diff)\n ).reduce(\n (acc, removed) =>\n acc - (removed === UNCACHED ? cache._defaultItemSize : removed),\n 0,\n );\n }\n};\n","import { once } from \"./utils.js\";\n\n/**\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\n/**\n * @internal\n */\nexport const getDocumentElement = (doc: Document): HTMLElement =>\n doc.documentElement;\n\n/**\n * @internal\n */\nexport const getCurrentDocument = (node: HTMLElement): Document =>\n node.ownerDocument;\n\n/**\n * @internal\n */\nexport const getCurrentWindow = (doc: Document) => doc.defaultView!;\n\n/**\n * Currently, all browsers on iOS/iPadOS are WebKit, including WebView.\n * @internal\n */\nexport const isIOSWebKit = /*#__PURE__*/ once((): boolean => {\n if (/iP(hone|od|ad)/.test(navigator.userAgent)) {\n return true;\n }\n // Modern iPad detection (iPadOS 13+)\n // iPadOS 13+ reports the same userAgent/platform information as macOS, to enable desktop sites.\n // So we treat devices that have macOS like information but with touch support as iPadOS.\n // https://stackoverflow.com/questions/57776001/how-to-detect-ipad-pro-as-ipad-using-javascript\n return navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 0;\n});\n\n/**\n * @internal\n */\nexport const isSmoothScrollSupported = /*#__PURE__*/ once((): boolean => {\n return \"scrollBehavior\" in getDocumentElement(document).style;\n});\n","import {\n initCache,\n getItemSize as _getItemSize,\n getItemOffset as _getItemOffset,\n UNCACHED,\n setItemSize,\n estimateDefaultItemSize,\n updateCacheLength,\n computeRange,\n takeCacheSnapshot,\n findIndex,\n} from \"./cache.js\";\nimport { isIOSWebKit } from \"./environment.js\";\nimport type {\n CacheSnapshot,\n InternalCacheSnapshot,\n ItemResize,\n ItemsRange,\n} from \"./types.js\";\nimport { abs, max, min, NULL } from \"./utils.js\";\n\nconst MAX_INT_32 = 0x7fffffff;\n\nconst SCROLL_IDLE = 0;\nconst SCROLL_DOWN = 1;\nconst SCROLL_UP = 2;\ntype ScrollDirection =\n | typeof SCROLL_IDLE\n | typeof SCROLL_DOWN\n | typeof SCROLL_UP;\n\nconst SCROLL_BY_NATIVE = 0;\nconst SCROLL_BY_MANUAL_SCROLL = 1;\nconst SCROLL_BY_SHIFT = 2;\ntype ScrollMode =\n | typeof SCROLL_BY_NATIVE\n | typeof SCROLL_BY_MANUAL_SCROLL\n | typeof SCROLL_BY_SHIFT;\n\n/** @internal */\nexport const ACTION_SCROLL = 1;\n/** @internal */\nexport const ACTION_SCROLL_END = 2;\n/** @internal */\nexport const ACTION_ITEM_RESIZE = 3;\n/** @internal */\nexport const ACTION_VIEWPORT_RESIZE = 4;\n/** @internal */\nexport const ACTION_ITEMS_LENGTH_CHANGE = 5;\n/** @internal */\nexport const ACTION_START_OFFSET_CHANGE = 6;\n/** @internal */\nexport const ACTION_MANUAL_SCROLL = 7;\n/** @internal */\nexport const ACTION_BEFORE_MANUAL_SMOOTH_SCROLL = 8;\n\ntype Actions =\n | [type: typeof ACTION_SCROLL, offset: number]\n | [type: typeof ACTION_SCROLL_END, dummy?: void]\n | [type: typeof ACTION_ITEM_RESIZE, entries: ItemResize[]]\n | [type: typeof ACTION_VIEWPORT_RESIZE, size: number]\n | [\n type: typeof ACTION_ITEMS_LENGTH_CHANGE,\n arg: [length: number, isShift?: boolean | undefined],\n ]\n | [type: typeof ACTION_START_OFFSET_CHANGE, offset: number]\n | [type: typeof ACTION_MANUAL_SCROLL, dummy?: void]\n | [type: typeof ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, offset: number];\n\n/** @internal */\nexport const UPDATE_VIRTUAL_STATE = 0b0001;\n/** @internal */\nexport const UPDATE_SIZE_EVENT = 0b0010;\n/** @internal */\nexport const UPDATE_SCROLL_EVENT = 0b0100;\n/** @internal */\nexport const UPDATE_SCROLL_END_EVENT = 0b1000;\n\n/**\n * @internal\n */\nexport const getScrollSize = (store: VirtualStore): number => {\n return max(store.$getTotalSize(), store.$getViewportSize());\n};\n\ntype Subscriber = (sync?: boolean) => void;\n\n/** @internal */\nexport type StateVersion =\n number & {} /* hack for typescript to pretend as not falsy */;\n\n/**\n * @internal\n */\nexport type VirtualStore = {\n $dispose(): void;\n $getStateVersion(): StateVersion;\n $getCacheSnapshot(): CacheSnapshot;\n $getRange(bufferSize?: number): ItemsRange;\n $findItemIndex(offset: number): number;\n $isUnmeasuredItem(index: number): boolean;\n $getItemOffset(index: number, fromEnd?: boolean): number;\n $getItemSize(index: number): number;\n $getItemsLength(): number;\n $getScrollOffset(): number;\n $isScrolling(): boolean;\n $getViewportSize(): number;\n $getStartSpacerSize(): number;\n $getTotalSize(): number;\n _flushJump(): [number, boolean];\n $subscribe(target: number, cb: Subscriber): () => void;\n $update(...action: Actions): void;\n};\n\n/**\n * @internal\n */\nexport const createVirtualStore = (\n elementsCount: number,\n itemSize: number = 40,\n ssrCount: number = 0,\n cacheSnapshot?: CacheSnapshot | undefined,\n shouldAutoEstimateItemSize: boolean = false,\n): VirtualStore => {\n let isSSR = !!ssrCount;\n let stateVersion: StateVersion = 1;\n let viewportSize = 0;\n let startSpacerSize = 0;\n let scrollOffset = 0;\n let jump = 0;\n let pendingJump = 0;\n let _flushedJump = 0;\n let _scrollDirection: ScrollDirection = SCROLL_IDLE;\n let _scrollMode: ScrollMode = SCROLL_BY_NATIVE;\n let _frozenRange: ItemsRange | null = NULL;\n let _prevRange: ItemsRange = [0, isSSR ? max(ssrCount - 1, 0) : -1];\n let _totalMeasuredSize = 0;\n let _isViewportMeasured = false;\n\n const cache = initCache(\n elementsCount,\n cacheSnapshot\n ? (cacheSnapshot as unknown as InternalCacheSnapshot)[1]\n : itemSize,\n cacheSnapshot && (cacheSnapshot as unknown as InternalCacheSnapshot)[0],\n );\n const subscribers = new Set<[number, Subscriber]>();\n const getRelativeScrollOffset = () => scrollOffset - startSpacerSize;\n const getVisibleOffset = () => getRelativeScrollOffset() + pendingJump + jump;\n const getRange = (startOffset: number, endOffset: number) => {\n return computeRange(cache, startOffset, endOffset, _prevRange[0]);\n };\n const getTotalSize = (): number => _getItemOffset(cache, cache._length);\n const getItemOffset = (index: number, fromEnd?: boolean): number => {\n const offset = _getItemOffset(cache, index) - pendingJump;\n if (fromEnd) {\n return getTotalSize() - offset - getItemSize(index);\n }\n return offset;\n };\n const getItemSize = (index: number): number => {\n return _getItemSize(cache, index);\n };\n const isSizeEqual = (index: number, value: number = UNCACHED): boolean => {\n return cache._sizes[index] === value;\n };\n\n const applyJump = (j: number) => {\n if (j) {\n if (\n // In iOS WebKit browsers, updating scroll position will stop scrolling so it have to be deferred during scrolling.\n (isIOSWebKit() && _scrollDirection !== SCROLL_IDLE) ||\n // Before imperative smooth scrolling, we measure all items which may be visible during scrolling.\n // However, especially in Firefox, there are rare cases where items resize while scrolling, which can stop smooth scrolling.\n (_frozenRange && _scrollMode === SCROLL_BY_MANUAL_SCROLL)\n ) {\n pendingJump += j;\n } else {\n jump += j;\n }\n }\n };\n\n return {\n $dispose: () => {\n subscribers.clear();\n },\n $getStateVersion: () => stateVersion,\n $getCacheSnapshot: () => {\n return takeCacheSnapshot(cache) as unknown as CacheSnapshot;\n },\n $getRange: (bufferSize = 200) => {\n if (!_isViewportMeasured || isSSR) {\n // Return range for SSR, or return [0, -1] to render nothing, until the scroll offset and viewport size are determined.\n // https://github.com/inokawa/virtua/issues/415\n // https://github.com/inokawa/virtua/pull/818\n return _prevRange;\n }\n let startIndex: number;\n let endIndex: number;\n if (_flushedJump) {\n // Return previous range for consistent render until next scroll event comes in.\n // And it must be clamped. https://github.com/inokawa/virtua/issues/597\n [startIndex, endIndex] = _prevRange;\n } else {\n let startOffset = max(0, getVisibleOffset());\n let endOffset = startOffset + viewportSize;\n\n // For faster initial render pass, returns without buffer if measurement seems to be in progress.\n if (!shouldAutoEstimateItemSize) {\n bufferSize = max(0, bufferSize);\n\n if (_scrollDirection !== SCROLL_DOWN) {\n startOffset -= bufferSize;\n }\n if (_scrollDirection !== SCROLL_UP) {\n endOffset += bufferSize;\n }\n }\n\n [startIndex, endIndex] = _prevRange = getRange(\n max(0, startOffset),\n max(0, endOffset),\n );\n if (_frozenRange) {\n startIndex = min(startIndex, _frozenRange[0]);\n endIndex = max(endIndex, _frozenRange[1]);\n }\n }\n\n return [max(startIndex, 0), min(endIndex, cache._length - 1)];\n },\n $findItemIndex: (offset) => findIndex(cache, offset - startSpacerSize),\n $isUnmeasuredItem: isSizeEqual,\n $getItemOffset: getItemOffset,\n $getItemSize: getItemSize,\n $getItemsLength: () => cache._length,\n $getScrollOffset: () => scrollOffset,\n $isScrolling: () => _scrollDirection !== SCROLL_IDLE,\n $getViewportSize: () => viewportSize,\n $getStartSpacerSize: () => startSpacerSize,\n $getTotalSize: getTotalSize,\n _flushJump: () => {\n _flushedJump = jump;\n jump = 0;\n return [_flushedJump, _scrollMode === SCROLL_BY_SHIFT];\n },\n $subscribe: (target, cb) => {\n const sub: [number, Subscriber] = [target, cb];\n subscribers.add(sub);\n return () => {\n subscribers.delete(sub);\n };\n },\n $update: (type, payload): void => {\n let shouldFlushPendingJump: boolean | undefined;\n let shouldSync: boolean | undefined;\n let mutated = 0;\n\n switch (type) {\n case ACTION_SCROLL: {\n if (payload === scrollOffset && _scrollMode === SCROLL_BY_NATIVE) {\n // Ignore scroll events from different direction\n break;\n }\n\n const flushedJump = _flushedJump;\n _flushedJump = 0;\n\n const delta = payload - scrollOffset;\n const distance = abs(delta);\n\n // Scroll event after jump compensation is not reliable because it may result in the opposite direction.\n // The delta of artificial scroll may not be equal with the jump because it may be batched with other scrolls.\n // And at least in latest Chrome/Firefox/Safari in 2023, setting value to scrollTop/scrollLeft can lose subpixel because its integer (sometimes float probably depending on dpr).\n const isJustJumped = flushedJump && distance < abs(flushedJump) + 1;\n\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (\n !isJustJumped &&\n // Ignore until manual scrolling\n _scrollMode === SCROLL_BY_NATIVE\n ) {\n _scrollDirection = delta < 0 ? SCROLL_UP : SCROLL_DOWN;\n }\n\n // TODO This will cause glitch in reverse infinite scrolling. Disable this until better solution is found.\n // if (\n // pendingJump &&\n // ((_scrollDirection === SCROLL_UP &&\n // payload - max(pendingJump, 0) <= 0) ||\n // (_scrollDirection === SCROLL_DOWN &&\n // payload - min(pendingJump, 0) >= getScrollOffsetMax()))\n // ) {\n // // Flush if almost reached to start or end\n // shouldFlushPendingJump = true;\n // }\n\n if (isSSR) {\n isSSR = false;\n }\n\n scrollOffset = payload;\n mutated = UPDATE_SCROLL_EVENT;\n\n // Skip if offset is not changed\n // Scroll offset may exceed min or max especially in Safari's elastic scrolling.\n const relativeOffset = getRelativeScrollOffset();\n if (\n relativeOffset >= -viewportSize &&\n relativeOffset <= getTotalSize()\n ) {\n mutated += UPDATE_VIRTUAL_STATE;\n\n // Update synchronously if scrolled a lot\n shouldSync = distance > viewportSize;\n }\n break;\n }\n case ACTION_SCROLL_END: {\n mutated = UPDATE_SCROLL_END_EVENT;\n if (_scrollDirection !== SCROLL_IDLE) {\n shouldFlushPendingJump = true;\n mutated += UPDATE_VIRTUAL_STATE;\n }\n _scrollDirection = SCROLL_IDLE;\n _scrollMode = SCROLL_BY_NATIVE;\n _frozenRange = NULL;\n break;\n }\n case ACTION_ITEM_RESIZE: {\n const updated = payload.filter(\n ([index, size]) => !isSizeEqual(index, size),\n );\n\n // Skip if all items are cached and not updated\n if (!updated.length) {\n break;\n }\n\n // Calculate jump by resize to minimize junks in appearance\n applyJump(\n updated.reduce((acc, [index, size]) => {\n let shouldKeep: boolean;\n if (\n // Keep distance from end during shifting\n _scrollMode === SCROLL_BY_SHIFT\n ) {\n shouldKeep = true;\n } else if (\n _frozenRange &&\n _scrollMode === SCROLL_BY_MANUAL_SCROLL\n ) {\n // https://github.com/inokawa/virtua/issues/380\n // https://github.com/inokawa/virtua/issues/758\n shouldKeep = index < _frozenRange[0];\n } else {\n // Otherwise we should maintain visible position\n const start = getRelativeScrollOffset();\n const itemOffset = getItemOffset(index);\n const itemSize = getItemSize(index);\n shouldKeep =\n _scrollDirection !== SCROLL_DOWN &&\n _scrollMode === SCROLL_BY_NATIVE\n ? // https://github.com/inokawa/virtua/issues/385\n // https://github.com/inokawa/virtua/discussions/865\n // https://github.com/inokawa/virtua/issues/893\n // Use \"<=\" instead of \"<\" here so the item whose bottom rests\n // exactly on the viewport top (the row directly above an\n // item anchored to the top) is compensated too.\n itemOffset + itemSize <= start\n : // https://github.com/inokawa/virtua/pull/868\n itemOffset < start &&\n itemOffset + itemSize < start + viewportSize;\n }\n\n if (shouldKeep) {\n acc += size - getItemSize(index);\n }\n return acc;\n }, 0),\n );\n\n // Update item sizes\n for (const [index, size] of updated) {\n const prevSize = getItemSize(index);\n const isInitialMeasurement = setItemSize(cache, index, size);\n\n if (shouldAutoEstimateItemSize) {\n _totalMeasuredSize += isInitialMeasurement\n ? size\n : size - prevSize;\n }\n }\n\n // Estimate initial item size from measured sizes\n if (\n shouldAutoEstimateItemSize &&\n viewportSize &&\n // If the total size is lower than the viewport, the item may be a empty state\n _totalMeasuredSize > viewportSize\n ) {\n applyJump(\n estimateDefaultItemSize(\n cache,\n findIndex(cache, getVisibleOffset()),\n ),\n );\n shouldAutoEstimateItemSize = false;\n }\n\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n\n // Synchronous update is necessary in current design to minimize visible glitch in concurrent rendering.\n // However this seems to be the main cause of the errors from ResizeObserver.\n // https://github.com/inokawa/virtua/issues/470\n //\n // And in React, synchronous update with flushSync after asynchronous update will overtake the asynchronous one.\n // If items resize happens just after scroll, race condition can occur depending on implementation.\n shouldSync = true;\n break;\n }\n case ACTION_VIEWPORT_RESIZE: {\n if (viewportSize !== payload) {\n if (!viewportSize) {\n _isViewportMeasured = shouldSync = true;\n }\n viewportSize = payload;\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n }\n break;\n }\n case ACTION_ITEMS_LENGTH_CHANGE: {\n if (payload[1]) {\n applyJump(updateCacheLength(cache, payload[0], true));\n _scrollMode = SCROLL_BY_SHIFT;\n mutated = UPDATE_VIRTUAL_STATE;\n } else {\n updateCacheLength(cache, payload[0]);\n // https://github.com/inokawa/virtua/issues/552\n // https://github.com/inokawa/virtua/issues/557\n mutated = UPDATE_VIRTUAL_STATE;\n }\n break;\n }\n case ACTION_START_OFFSET_CHANGE: {\n startSpacerSize = payload;\n break;\n }\n case ACTION_MANUAL_SCROLL: {\n _scrollMode = SCROLL_BY_MANUAL_SCROLL;\n break;\n }\n case ACTION_BEFORE_MANUAL_SMOOTH_SCROLL: {\n _frozenRange = getRange(payload, payload + viewportSize);\n mutated = UPDATE_VIRTUAL_STATE;\n break;\n }\n }\n\n if (mutated) {\n stateVersion = (stateVersion & MAX_INT_32) + 1;\n\n if (shouldFlushPendingJump && pendingJump) {\n jump += pendingJump;\n pendingJump = 0;\n }\n\n subscribers.forEach(([target, cb]) => {\n // Early return to skip React's computation\n if (!(mutated & target)) {\n return;\n }\n // https://github.com/facebook/react/issues/25191\n // https://github.com/facebook/react/blob/a5fc797db14c6e05d4d5c4dbb22a0dd70d41f5d5/packages/react-reconciler/src/ReactFiberWorkLoop.js#L1443-L1447\n cb(shouldSync);\n });\n }\n },\n };\n};\n","import {\n getCurrentDocument,\n getCurrentWindow,\n getDocumentElement,\n isIOSWebKit,\n isSmoothScrollSupported,\n} from \"./environment.js\";\nimport {\n ACTION_SCROLL,\n type VirtualStore,\n ACTION_SCROLL_END,\n UPDATE_SIZE_EVENT,\n ACTION_MANUAL_SCROLL,\n ACTION_BEFORE_MANUAL_SMOOTH_SCROLL,\n ACTION_START_OFFSET_CHANGE,\n} from \"./store.js\";\nimport { type ScrollToIndexOpts } from \"./types.js\";\nimport { clamp, createPromise, microtask, NULL } from \"./utils.js\";\n\nconst timeout = setTimeout;\n\nconst debounce = <T extends () => void>(fn: T, ms: number) => {\n let id: ReturnType<typeof setTimeout> | undefined | null;\n\n const cancel = () => {\n if (id != NULL) {\n clearTimeout(id);\n }\n };\n const debouncedFn = () => {\n cancel();\n id = timeout(() => {\n id = NULL;\n fn();\n }, ms);\n };\n debouncedFn._cancel = cancel;\n return debouncedFn;\n};\n\n/**\n * scrollTop/scrollLeft can be negative value under certain styles.\n * - direction: rtl https://github.com/othree/jquery.rtl-scroll-type\n * - writing-mode https://people.igalia.com/fwang/scrollable-elements-in-non-default-writing-modes/\n * - flex-direction: column-reverse/row-reverse\n *\n * top/left bottom/right\n * 0 100 spec compliant bottom/right overflow, or possibly top/left overflow in Chrome earlier than v85\n * -100 0 spec compliant top/left overflow\n * https://drafts.csswg.org/cssom-view/#scroll-an-element\n */\nconst normalizeScrollOffset = (offset: number, isNegative: boolean): number => {\n return isNegative ? -offset : offset;\n};\n\nconst createScrollObserver = (\n store: VirtualStore,\n viewport: HTMLElement | Window,\n isHorizontal: boolean,\n getScrollOffset: () => number,\n updateScrollOffset: (\n value: number,\n shift: boolean,\n isMomentumScrolling: boolean,\n ) => void,\n getStartOffset?: () => number,\n) => {\n const now = Date.now;\n\n let lastScrollTime = 0;\n let wheeling = false;\n let touching = false;\n let justTouchEnded = false;\n let stillMomentumScrolling = false;\n\n const onScrollEnd = debounce(() => {\n if (wheeling || touching) {\n wheeling = false;\n\n // Wait while wheeling or touching\n onScrollEnd();\n return;\n }\n\n justTouchEnded = false;\n\n store.$update(ACTION_SCROLL_END);\n }, 150);\n\n const onScroll = () => {\n lastScrollTime = now();\n\n if (justTouchEnded) {\n stillMomentumScrolling = true;\n }\n\n if (getStartOffset) {\n store.$update(ACTION_START_OFFSET_CHANGE, getStartOffset());\n }\n store.$update(ACTION_SCROLL, getScrollOffset());\n\n onScrollEnd();\n };\n\n // Infer scroll state also from wheel events\n // Sometimes scroll events do not fire when frame dropped even if the visual have been already scrolled\n const onWheel = ((e: WheelEvent) => {\n if (\n wheeling ||\n // Scroll start should be detected with scroll event\n !store.$isScrolling() ||\n // Probably a pinch-to-zoom gesture\n e.ctrlKey\n ) {\n return;\n }\n\n const timeDelta = now() - lastScrollTime;\n if (\n // Check if wheel event occurs some time after scrolling\n 150 > timeDelta &&\n 50 < timeDelta &&\n // Get delta before checking deltaMode for firefox behavior\n // https://github.com/w3c/uievents/issues/181#issuecomment-392648065\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1392460#c34\n (isHorizontal ? e.deltaX : e.deltaY)\n ) {\n wheeling = true;\n }\n }) as (e: Event) => void; // FIXME type error. why only here?\n\n const onTouchStart = () => {\n touching = true;\n justTouchEnded = stillMomentumScrolling = false;\n };\n const onTouchEnd = () => {\n touching = false;\n if (isIOSWebKit()) {\n justTouchEnded = true;\n }\n };\n\n viewport.addEventListener(\"scroll\", onScroll);\n viewport.addEventListener(\"wheel\", onWheel, { passive: true });\n viewport.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n viewport.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n\n return {\n _dispose: () => {\n viewport.removeEventListener(\"scroll\", onScroll);\n viewport.removeEventListener(\"wheel\", onWheel);\n viewport.removeEventListener(\"touchstart\", onTouchStart);\n viewport.removeEventListener(\"touchend\", onTouchEnd);\n onScrollEnd._cancel();\n },\n _fixScrollJump: () => {\n const [jump, shift] = store._flushJump();\n if (!jump) return;\n updateScrollOffset(jump, shift, stillMomentumScrolling);\n stillMomentumScrolling = false;\n\n if (shift && store.$getViewportSize() > store.$getTotalSize()) {\n // In this case applying jump may not cause scroll.\n // Current logic expects scroll event occurs after applying jump so we dispatch it manually.\n store.$update(ACTION_SCROLL, getScrollOffset());\n }\n },\n };\n};\n\ntype ScrollObserver = ReturnType<typeof createScrollObserver>;\n\ntype ScheduleScrollFunction = (\n getTargetOffset: () => number,\n smooth?: boolean,\n) => Promise<void>;\n\nconst createScrollScheduler = (\n store: VirtualStore,\n initialized: () => Promise<boolean>,\n scroll: (offset: number, smooth?: boolean) => void,\n): [scroll: ScheduleScrollFunction, cancel: () => void] => {\n let cancelScroll: (() => void) | undefined;\n\n // The given offset will be clamped by browser\n // https://drafts.csswg.org/cssom-view/#dom-element-scrolltop\n return [\n async (getTargetOffset, smooth) => {\n // Wait for element assign. The element may be undefined if scrollRef prop is used and scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (!(await initialized())) {\n return;\n }\n\n if (cancelScroll) {\n // Cancel waiting scrollTo\n cancelScroll();\n }\n\n const waitForMeasurement = (): [Promise<boolean>, () => void] => {\n // Wait for the scroll destination items to be measured.\n // The measurement will be done asynchronously and the timing is not predictable so we use promise.\n const [promise, resolve] = createPromise<boolean>();\n cancelScroll = () => {\n resolve(false);\n };\n\n // Resize event may not happen when the window/tab is not visible, or during browser back in Safari.\n // We have to wait for the initial measurement to avoid failing imperative scroll on mount.\n // https://github.com/inokawa/virtua/issues/450\n if (store.$getViewportSize()) {\n // Cancel when items around scroll destination completely measured\n timeout(cancelScroll, 150);\n }\n return [\n promise,\n store.$subscribe(UPDATE_SIZE_EVENT, () => {\n resolve(true);\n }),\n ];\n };\n\n if (smooth && isSmoothScrollSupported()) {\n store.$update(ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, getTargetOffset());\n\n // https://github.com/inokawa/virtua/issues/590\n microtask(async () => {\n while (true) {\n let done = true;\n for (let [i, end] = store.$getRange(); i <= end; i++) {\n if (store.$isUnmeasuredItem(i)) {\n done = false;\n break;\n }\n }\n if (done) {\n break;\n }\n const [promise, unsubscribe] = waitForMeasurement();\n\n try {\n if (!(await promise)) {\n // canceled\n return;\n }\n } finally {\n unsubscribe();\n }\n }\n\n store.$update(ACTION_MANUAL_SCROLL);\n scroll(getTargetOffset(), smooth);\n });\n } else {\n while (true) {\n const [promise, unsubscribe] = waitForMeasurement();\n\n try {\n store.$update(ACTION_MANUAL_SCROLL);\n scroll(getTargetOffset());\n\n if (!(await promise)) {\n // canceled or finished\n return;\n }\n } finally {\n unsubscribe();\n }\n }\n }\n },\n () => {\n cancelScroll && cancelScroll();\n },\n ];\n};\n\ninterface Scroller<T extends HTMLElement | void> {\n $observe: (containerElement: HTMLElement, viewport: T) => void;\n $dispose(): void;\n $fixScrollJump: () => void;\n $isNegative(): boolean;\n}\n\n/**\n * @internal\n */\nexport const createScroller = (\n store: VirtualStore,\n isHorizontal: boolean,\n): Scroller<HTMLElement> & {\n $scrollTo: (offset: number) => void;\n $scrollBy: (offset: number) => void;\n $scrollToIndex: (index: number, opts?: ScrollToIndexOpts) => void;\n} => {\n let viewportElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n let isNegative = false;\n const scrollOffsetKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const overflowKey = isHorizontal ? \"overflowX\" : \"overflowY\";\n\n const [scheduleScroll, cancelScroll] = createScrollScheduler(\n store,\n () => initialized[0],\n (offset, smooth) => {\n offset = normalizeScrollOffset(offset, isNegative);\n\n if (smooth) {\n viewportElement!.scrollTo({\n [isHorizontal ? \"left\" : \"top\"]: offset,\n behavior: \"smooth\",\n });\n } else {\n viewportElement![scrollOffsetKey] = offset;\n }\n },\n );\n\n return {\n $observe(_, viewport) {\n viewportElement = viewport;\n\n if (isHorizontal) {\n isNegative = getComputedStyle(viewport).direction === \"rtl\";\n }\n\n scrollObserver = createScrollObserver(\n store,\n viewport,\n isHorizontal,\n () => normalizeScrollOffset(viewport[scrollOffsetKey], isNegative),\n (jump, shift, isMomentumScrolling) => {\n // If we update scroll position while touching on iOS, the position will be reverted.\n // However iOS WebKit fires touch events only once at the beginning of momentum scrolling.\n // That means we have no reliable way to confirm still touched or not if user touches more than once during momentum scrolling...\n // This is a hack for the suspectable situations, inspired by https://github.com/prud/ios-overflow-scroll-to-top\n if (isMomentumScrolling) {\n const style = viewport.style;\n const prev = style[overflowKey];\n style[overflowKey] = \"hidden\";\n timeout(() => {\n style[overflowKey] = prev;\n });\n }\n\n // Use absolute position not to exceed scrollable bounds\n // https://github.com/inokawa/virtua/discussions/475\n viewport[scrollOffsetKey] = normalizeScrollOffset(\n store.$getScrollOffset() + jump,\n isNegative,\n );\n if (shift) {\n // https://github.com/inokawa/virtua/issues/357\n cancelScroll();\n }\n },\n );\n\n initialized[1](true);\n },\n $dispose() {\n scrollObserver && scrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $isNegative: () => isNegative,\n $scrollTo(offset) {\n scheduleScroll(() => offset);\n },\n $scrollBy(offset) {\n offset += store.$getScrollOffset();\n scheduleScroll(() => offset);\n },\n $scrollToIndex(index, { align, smooth, offset = 0 } = {}) {\n index = clamp(index, 0, store.$getItemsLength() - 1);\n\n if (align === \"nearest\") {\n const itemOffset = store.$getItemOffset(index);\n const scrollOffset = store.$getScrollOffset();\n\n if (itemOffset < scrollOffset) {\n align = \"start\";\n } else if (\n itemOffset + store.$getItemSize(index) >\n scrollOffset + store.$getViewportSize()\n ) {\n align = \"end\";\n } else {\n // already completely visible\n return;\n }\n }\n\n scheduleScroll(() => {\n return (\n offset +\n store.$getStartSpacerSize() +\n store.$getItemOffset(index) +\n (align === \"end\"\n ? store.$getItemSize(index) - store.$getViewportSize()\n : align === \"center\"\n ? (store.$getItemSize(index) - store.$getViewportSize()) / 2\n : 0)\n );\n }, smooth);\n },\n $fixScrollJump: () => {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n };\n};\n\n/**\n * @internal\n */\nexport const createWindowScroller = (\n store: VirtualStore,\n isHorizontal: boolean,\n): Scroller<void> & {\n $scrollToIndex: (index: number, opts?: ScrollToIndexOpts) => void;\n} => {\n let containerElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n let isNegative = false;\n const scrollToKey = isHorizontal ? \"left\" : \"top\";\n\n const [scheduleScroll] = createScrollScheduler(\n store,\n () => initialized[0],\n (offset, smooth) => {\n offset = normalizeScrollOffset(offset, isNegative);\n\n const window = getCurrentWindow(getCurrentDocument(containerElement!));\n\n if (smooth) {\n window.scroll({\n [scrollToKey]: offset,\n behavior: \"smooth\",\n });\n } else {\n window.scroll({\n [scrollToKey]: offset,\n });\n }\n },\n );\n\n const calcOffsetToViewport = (\n node: HTMLElement,\n viewport: HTMLElement,\n window: Window,\n isHorizontal: boolean,\n offset: number = 0,\n ): number => {\n // TODO calc offset only when it changes (maybe impossible)\n const offsetKey = isHorizontal ? \"offsetLeft\" : \"offsetTop\";\n const offsetSum =\n offset +\n (isHorizontal && isNegative\n ? window.innerWidth - node[offsetKey] - node.offsetWidth\n : node[offsetKey]);\n\n const parent = node.offsetParent;\n if (node === viewport || !parent) {\n return offsetSum;\n }\n\n return calcOffsetToViewport(\n parent as HTMLElement,\n viewport,\n window,\n isHorizontal,\n offsetSum,\n );\n };\n\n return {\n $observe(container) {\n containerElement = container;\n const scrollOffsetKey = isHorizontal ? \"scrollX\" : \"scrollY\";\n\n const document = getCurrentDocument(container);\n const window = getCurrentWindow(document);\n\n if (isHorizontal) {\n // Detect RTL document\n isNegative =\n getComputedStyle(getDocumentElement(document)).direction === \"rtl\";\n }\n\n scrollObserver = createScrollObserver(\n store,\n window,\n isHorizontal,\n () => normalizeScrollOffset(window[scrollOffsetKey], isNegative),\n (jump, shift) => {\n // TODO support case two window scrollers exist in the same view\n if (shift) {\n // Use absolute position not to exceed scrollable bounds\n window.scroll({\n [scrollToKey]: normalizeScrollOffset(\n store.$getScrollOffset() + jump,\n isNegative,\n ),\n });\n } else {\n // Use window.scrollBy here, which causes less layout shift for some reason.\n window.scrollBy({\n [scrollToKey]: normalizeScrollOffset(jump, isNegative),\n });\n }\n },\n () =>\n calcOffsetToViewport(container, document.body, window, isHorizontal),\n );\n\n initialized[1](true);\n },\n $dispose() {\n scrollObserver && scrollObserver._dispose();\n containerElement = undefined;\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $isNegative: () => isNegative,\n $fixScrollJump: () => {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n $scrollToIndex(index, { align, smooth, offset = 0 } = {}) {\n if (!containerElement) return;\n\n index = clamp(index, 0, store.$getItemsLength() - 1);\n\n if (align === \"nearest\") {\n const itemOffset = store.$getItemOffset(index);\n const scrollOffset = store.$getScrollOffset();\n\n if (itemOffset < scrollOffset) {\n align = \"start\";\n } else if (\n itemOffset + store.$getItemSize(index) >\n scrollOffset + store.$getViewportSize()\n ) {\n align = \"end\";\n } else {\n return;\n }\n }\n\n const document = getCurrentDocument(containerElement);\n const window = getCurrentWindow(document);\n const html = getDocumentElement(document);\n const getScrollbarSize = () =>\n store.$getViewportSize() -\n (isHorizontal ? html.clientWidth : html.clientHeight);\n\n scheduleScroll(() => {\n return (\n offset +\n // Calculate target scroll position including container's offset from document\n calcOffsetToViewport(\n containerElement!,\n document.body,\n window,\n isHorizontal,\n ) +\n // store._getStartSpacerSize() +\n store.$getItemOffset(index) +\n (align === \"end\"\n ? store.$getItemSize(index) -\n (store.$getViewportSize() - getScrollbarSize())\n : align === \"center\"\n ? (store.$getItemSize(index) -\n (store.$getViewportSize() - getScrollbarSize())) /\n 2\n : 0)\n );\n }, smooth);\n },\n };\n};\n\n/**\n * @internal\n */\nexport interface GridScroller extends Scroller<HTMLElement> {\n $scrollTo: (offsetX?: number, offsetY?: number) => void;\n $scrollBy: (offsetX?: number, offsetY?: number) => void;\n $scrollToIndex: (indexX?: number, indexY?: number) => void;\n}\n\n/**\n * @internal\n */\nexport const createGridScroller = (\n rowStore: VirtualStore,\n colStore: VirtualStore,\n): GridScroller => {\n const rowScroller = createScroller(rowStore, false);\n const colScroller = createScroller(colStore, true);\n return {\n $observe(container, viewport) {\n rowScroller.$observe(container, viewport);\n colScroller.$observe(container, viewport);\n },\n $dispose() {\n rowScroller.$dispose();\n colScroller.$dispose();\n },\n $isNegative: colScroller.$isNegative,\n $scrollTo(row, col) {\n if (row != null) {\n rowScroller.$scrollTo(row);\n }\n if (col != null) {\n colScroller.$scrollTo(col);\n }\n },\n $scrollBy(row, col) {\n if (row != null) {\n rowScroller.$scrollBy(row);\n }\n if (col != null) {\n colScroller.$scrollBy(col);\n }\n },\n $scrollToIndex(row, col) {\n if (row != null) {\n rowScroller.$scrollToIndex(row);\n }\n if (col != null) {\n colScroller.$scrollToIndex(col);\n }\n },\n $fixScrollJump() {\n rowScroller.$fixScrollJump();\n colScroller.$fixScrollJump();\n },\n };\n};\n","import { getCurrentDocument, getCurrentWindow } from \"./environment.js\";\nimport {\n ACTION_ITEM_RESIZE,\n ACTION_VIEWPORT_RESIZE,\n type VirtualStore,\n} from \"./store.js\";\nimport { type ItemResize } from \"./types.js\";\nimport { max, microtask, NULL } from \"./utils.js\";\n\nconst createResizeObserver = (cb: ResizeObserverCallback) => {\n let ro: ResizeObserver | undefined;\n\n return {\n _observe(e: HTMLElement) {\n // Initialize ResizeObserver lazily for SSR\n // https://www.w3.org/TR/resize-observer/#intro\n (\n ro ||\n // https://bugs.chromium.org/p/chromium/issues/detail?id=1491739\n (ro = new (getCurrentWindow(getCurrentDocument(e)).ResizeObserver)(cb))\n ).observe(e);\n },\n _unobserve(e: HTMLElement) {\n ro!.unobserve(e);\n },\n _dispose() {\n ro && ro.disconnect();\n },\n };\n};\n\n/**\n * @internal\n */\nexport type ItemResizeObserver = (el: HTMLElement, i: number) => () => void;\n\ninterface ListResizer {\n $observeRoot(viewportElement: HTMLElement): void;\n $observeItem: ItemResizeObserver;\n $dispose(): void;\n}\n\n/**\n * @internal\n */\nexport const createResizer = (\n store: VirtualStore,\n isHorizontal: boolean,\n): ListResizer => {\n let viewportElement: HTMLElement | undefined;\n const sizeKey = isHorizontal ? \"width\" : \"height\";\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const { target, contentRect } of entries) {\n // Skip zero-sized rects that may be observed under `display: none` style\n if (!(target as HTMLElement).offsetParent) continue;\n\n if (target === viewportElement) {\n store.$update(ACTION_VIEWPORT_RESIZE, contentRect[sizeKey]);\n } else {\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, contentRect[sizeKey]]);\n }\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n return {\n $observeRoot(viewport: HTMLElement) {\n resizeObserver._observe((viewportElement = viewport));\n },\n $observeItem: (el: HTMLElement, i: number) => {\n mountedIndexes.set(el, i);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n $dispose: resizeObserver._dispose,\n };\n};\n\ninterface WindowListResizer {\n $observeRoot(container: HTMLElement): void;\n $observeItem: ItemResizeObserver;\n $dispose(): void;\n}\n\n/**\n * @internal\n */\nexport const createWindowResizer = (\n store: VirtualStore,\n isHorizontal: boolean,\n): WindowListResizer => {\n const sizeKey = isHorizontal ? \"width\" : \"height\";\n const windowSizeKey = isHorizontal ? \"innerWidth\" : \"innerHeight\";\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const { target, contentRect } of entries) {\n // Skip zero-sized rects that may be observed under `display: none` style\n if (!(target as HTMLElement).offsetParent) continue;\n\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, contentRect[sizeKey]]);\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n let cleanupOnWindowResize: (() => void) | undefined;\n\n return {\n $observeRoot(container) {\n const window = getCurrentWindow(getCurrentDocument(container));\n const onWindowResize = () => {\n store.$update(ACTION_VIEWPORT_RESIZE, window[windowSizeKey]);\n };\n window.addEventListener(\"resize\", onWindowResize);\n\n // https://github.com/inokawa/virtua/issues/792\n microtask(onWindowResize);\n\n cleanupOnWindowResize = () => {\n window.removeEventListener(\"resize\", onWindowResize);\n };\n },\n $observeItem: (el: HTMLElement, i: number) => {\n mountedIndexes.set(el, i);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n $dispose() {\n cleanupOnWindowResize && cleanupOnWindowResize();\n resizeObserver._dispose();\n },\n };\n};\n\n/**\n * @internal\n */\nexport const createGridResizer = (\n rowStore: VirtualStore,\n colStore: VirtualStore,\n) => {\n let viewportElement: HTMLElement | undefined;\n\n const mountedIndexes = new WeakMap<\n Element,\n [rowIndex: number, colIndex: number]\n >();\n\n type CellSize = [height: number, width: number];\n const maybeCachedRowIndexes = new Set<number>();\n const maybeCachedColIndexes = new Set<number>();\n const sizeCache = new Map<string, CellSize>();\n const getKey = (rowIndex: number, colIndex: number): string =>\n `${rowIndex}-${colIndex}`;\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizedRows = new Set<number>();\n const resizedCols = new Set<number>();\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n // Skip zero-sized rects that may be observed under `display: none` style\n if (!(target as HTMLElement).offsetParent) continue;\n\n if (target === viewportElement) {\n rowStore.$update(ACTION_VIEWPORT_RESIZE, height);\n colStore.$update(ACTION_VIEWPORT_RESIZE, width);\n } else {\n const cell = mountedIndexes.get(target);\n if (cell) {\n const [rowIndex, colIndex] = cell;\n const key = getKey(rowIndex, colIndex);\n const prevSize = sizeCache.get(key);\n let rowResized: boolean | undefined;\n let colResized: boolean | undefined;\n if (!prevSize) {\n rowResized = colResized = true;\n } else {\n if (prevSize[0] !== height) {\n rowResized = true;\n }\n if (prevSize[1] !== width) {\n colResized = true;\n }\n }\n if (rowResized) {\n resizedRows.add(rowIndex);\n }\n if (colResized) {\n resizedCols.add(colIndex);\n }\n if (rowResized || colResized) {\n sizeCache.set(key, [height, width]);\n }\n }\n }\n }\n\n if (resizedRows.size) {\n const heightResizes: ItemResize[] = [];\n resizedRows.forEach((rowIndex) => {\n let maxHeight = 0;\n maybeCachedColIndexes.forEach((colIndex) => {\n const size = sizeCache.get(getKey(rowIndex, colIndex));\n if (size) {\n maxHeight = max(maxHeight, size[0]);\n }\n });\n if (maxHeight) {\n heightResizes.push([rowIndex, maxHeight]);\n }\n });\n rowStore.$update(ACTION_ITEM_RESIZE, heightResizes);\n }\n if (resizedCols.size) {\n const widthResizes: ItemResize[] = [];\n resizedCols.forEach((colIndex) => {\n let maxWidth = 0;\n maybeCachedRowIndexes.forEach((rowIndex) => {\n const size = sizeCache.get(getKey(rowIndex, colIndex));\n if (size) {\n maxWidth = max(maxWidth, size[1]);\n }\n });\n if (maxWidth) {\n widthResizes.push([colIndex, maxWidth]);\n }\n });\n colStore.$update(ACTION_ITEM_RESIZE, widthResizes);\n }\n });\n\n return {\n $observeRoot(viewport: HTMLElement) {\n resizeObserver._observe((viewportElement = viewport));\n },\n $observeItem(el: HTMLElement, rowIndex: number, colIndex: number) {\n mountedIndexes.set(el, [rowIndex, colIndex]);\n maybeCachedRowIndexes.add(rowIndex);\n maybeCachedColIndexes.add(colIndex);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n $resizeCols(cols: ItemResize[]) {\n for (const [c] of cols) {\n for (let r = 0; r < rowStore.$getItemsLength(); r++) {\n sizeCache.delete(getKey(r, c));\n }\n }\n colStore.$update(ACTION_ITEM_RESIZE, cols);\n },\n $resizeRows(rows: ItemResize[]) {\n for (const [r] of rows) {\n for (let c = 0; c < colStore.$getItemsLength(); c++) {\n sizeCache.delete(getKey(r, c));\n }\n }\n rowStore.$update(ACTION_ITEM_RESIZE, rows);\n },\n $dispose: resizeObserver._dispose,\n };\n};\n\n/**\n * @internal\n */\nexport type GridResizer = ReturnType<typeof createGridResizer>;\n","import {\n DestroyRef,\n Directive,\n ElementRef,\n afterRenderEffect,\n computed,\n effect,\n inject,\n input,\n untracked,\n} from \"@angular/core\";\nimport { type ItemResizeObserver } from \"../core/index.js\";\nimport { type ItemProps } from \"./utils.js\";\n\n/**\n * @internal\n */\n@Directive({\n selector: \"div[virtuaListItem]\",\n host: {\n \"[style]\": \"style()\",\n \"[class]\": \"attrs()?.class\",\n },\n})\nexport class ListItem {\n readonly index = input.required<number>();\n readonly offset = input.required<number>();\n readonly hide = input.required<boolean>();\n readonly horizontal = input.required<boolean>();\n readonly resizer = input.required<ItemResizeObserver>();\n readonly attrs = input<ReturnType<ItemProps>>();\n\n /** @internal */\n protected style = computed(() => {\n const horizontal = this.horizontal();\n const style: Record<string, string | undefined> = {\n contain: \"layout style\",\n position: \"absolute\",\n [horizontal ? \"height\" : \"width\"]: \"100%\",\n [horizontal ? \"top\" : \"left\"]: \"0px\",\n [horizontal ? \"left\" : \"top\"]: this.offset() + \"px\",\n visibility: this.hide() ? \"hidden\" : undefined,\n ...this.attrs()?.style,\n };\n if (horizontal) {\n style[\"display\"] = \"inline-flex\";\n }\n return style;\n });\n\n constructor() {\n const element: HTMLElement = inject(ElementRef).nativeElement;\n\n // afterRenderEffect instead of effect, because ResizeObserver doesn't exist on the server.\n // The index may be changed if elements are inserted to or removed from the start of data.\n let cleanupResizer: (() => void) | undefined;\n afterRenderEffect({\n read: () => {\n const index = this.index();\n if (cleanupResizer) cleanupResizer();\n cleanupResizer = untracked(this.resizer)(element, index);\n },\n });\n\n // `style` and `class` are bound to the host above, the rest is set as attributes\n let prevKeys: string[] = [];\n effect(() => {\n const attrs = this.attrs();\n for (const key of prevKeys) {\n element.removeAttribute(key);\n }\n prevKeys = [];\n for (const key in attrs) {\n if (key === \"style\" || key === \"class\") continue;\n element.setAttribute(key, attrs[key]);\n prevKeys.push(key);\n }\n });\n\n inject(DestroyRef).onDestroy(() => {\n if (cleanupResizer) cleanupResizer();\n });\n }\n}\n","export const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n\n/**\n * A function that provides properties/attributes for item element\n */\nexport type ItemProps<T = unknown> = (payload: { item: T; index: number }) =>\n | {\n [key: string]: any;\n style?: Record<string, string | undefined>;\n class?: string;\n }\n | undefined;\n\n/**\n * Context of the item template.\n */\nexport type ItemContext<T> = {\n $implicit: T;\n index: number;\n};\n","import {\n ApplicationRef,\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n type OnInit,\n TemplateRef,\n afterNextRender,\n afterRenderEffect,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n signal,\n untracked,\n} from \"@angular/core\";\nimport { NgTemplateOutlet } from \"@angular/common\";\nimport {\n ACTION_ITEMS_LENGTH_CHANGE,\n ACTION_START_OFFSET_CHANGE,\n type CacheSnapshot,\n type ScrollToIndexOpts,\n type StateVersion,\n UPDATE_SCROLL_END_EVENT,\n UPDATE_SCROLL_EVENT,\n UPDATE_VIRTUAL_STATE,\n createResizer,\n createScroller,\n createVirtualStore,\n getScrollSize as _getScrollSize,\n sort,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { defaultGetKey, type ItemContext, type ItemProps } from \"./utils.js\";\n\n/**\n * Methods of {@link Virtualizer}.\n */\nexport interface VirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n getCache: () => CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true.\n */\n getScrollOffset: () => number;\n /**\n * Get current scrollHeight, or scrollWidth if horizontal: true.\n */\n getScrollSize: () => number;\n /**\n * Get current offsetHeight, or offsetWidth if horizontal: true.\n */\n getViewportSize: () => number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n /**\n * Scroll to the given offset.\n * @param offset offset from start\n */\n scrollTo(offset: number): void;\n /**\n * Scroll by the given offset.\n * @param offset offset from current position\n */\n scrollBy(offset: number): void;\n}\n\n/**\n * Customizable list virtualizer for advanced usage. See {@link VirtualizerHandle}.\n *\n * The host element is the container of the items. Use the attribute selector to change its tag,\n * like `<ul virtuaVirtualizer [data]=\"data\">`.\n */\n@Component({\n selector: \"virtua-virtualizer, [virtuaVirtualizer]\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ListItem, NgTemplateOutlet],\n host: {\n \"[style]\": \"containerStyle()\",\n },\n template: `\n @for (item of items(); track item.key) {\n <div\n virtuaListItem\n [index]=\"item.index\"\n [offset]=\"item.offset\"\n [hide]=\"item.hide\"\n [attrs]=\"item.attrs\"\n [horizontal]=\"horizontal()\"\n [resizer]=\"resizer.$observeItem\"\n >\n <ng-container\n [ngTemplateOutlet]=\"template()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n index: item.index,\n }\"\n />\n </div>\n }\n `,\n})\nexport class Virtualizer<T> implements OnInit, VirtualizerHandle {\n /**\n * The data items rendered by this component.\n */\n readonly data = input.required<readonly T[]>();\n /**\n * Function that returns the key of an item in the list. It's recommended to specify whenever possible for performance.\n * @default defaultGetKey (returns index of item)\n */\n readonly getKey =\n input<(data: T, index: number) => string | number>(defaultGetKey);\n /**\n * A function that provides properties/attributes for item element\n */\n readonly itemProps = input<ItemProps<T>>();\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n readonly bufferSize = input<number>();\n /**\n * Reference to the scrollable element. The default will get the direct parent element of virtualizer.\n */\n readonly scrollRef = input<HTMLElement>();\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n readonly itemSize = input<number>();\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n readonly ssrCount = input<number>();\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n readonly shift = input(false);\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n readonly horizontal = input(false);\n /**\n * List of indexes that should be always mounted, even when off screen.\n */\n readonly keepMounted = input<readonly number[]>();\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.getCache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n readonly cache = input<CacheSnapshot>();\n /**\n * The offset to the scrollable parent before virtualizer in pixels. If you put an element before virtualizer, you have to set its height to this prop.\n */\n readonly startMargin = input(0);\n\n /**\n * Emitted whenever scroll offset changes. The value is current scrollTop, or scrollLeft if horizontal: true.\n */\n readonly scroll = output<number>();\n /**\n * Emitted when scrolling stops.\n */\n readonly scrollEnd = output<void>();\n\n /**\n * Item template forwarded by {@link VList}, which can't pass its own content\n * through `ng-content` because content queries don't cross projection.\n * @internal\n */\n readonly itemTemplate = input<TemplateRef<ItemContext<T>>>();\n // not _ prefixed, because the mangler does not rename the property name kept\n // as a string in the partial compilation output\n /** @internal */\n private contentTemplate =\n contentChild<TemplateRef<ItemContext<T>>>(TemplateRef);\n /** @internal */\n protected template = computed(\n () => (this.itemTemplate() ?? this.contentTemplate())!,\n );\n\n /** @internal */\n private _store!: ReturnType<typeof createVirtualStore>;\n /** @internal */\n protected resizer!: ReturnType<typeof createResizer>;\n /** @internal */\n private _scroller!: ReturnType<typeof createScroller>;\n /** @internal */\n private _element: HTMLElement = inject(ElementRef).nativeElement;\n /** @internal */\n private _appRef = inject(ApplicationRef);\n\n /** @internal */\n private _stateVersion = signal<StateVersion>(undefined!);\n\n /** @internal */\n private _indexes = computed(() => {\n this._stateVersion(); // the store is not a signal, so depend on its version\n // https://github.com/inokawa/virtua/pull/847\n const len = this.data().length;\n\n const [start, end] = this._store.$getRange(this.bufferSize());\n const keepMounted = this.keepMounted();\n const arr: number[] = [];\n if (keepMounted) {\n const mounted = new Set(keepMounted);\n for (let i = start; i <= end; i++) {\n mounted.add(i);\n }\n for (const index of sort([...mounted])) {\n if (index < len) {\n arr.push(index);\n }\n }\n } else {\n for (let i = start; i <= end; i++) {\n if (i < len) {\n arr.push(i);\n }\n }\n }\n return arr;\n });\n\n /** @internal */\n protected items = computed(() => {\n this._stateVersion(); // the store is not a signal, so depend on its version\n const store = this._store;\n const data = this.data();\n const getKey = this.getKey();\n const itemProps = this.itemProps();\n const negative = this._scroller.$isNegative();\n return this._indexes().map((index) => {\n const item = data[index]!;\n return {\n key: getKey(item, index),\n index,\n data: item,\n offset: store.$getItemOffset(index, negative),\n hide: store.$isUnmeasuredItem(index),\n attrs: itemProps?.({ item, index }),\n };\n });\n });\n\n /** @internal */\n protected containerStyle = computed(() => {\n this._stateVersion(); // the store is not a signal, so depend on its version\n const horizontal = this.horizontal();\n const totalSize = this._store.$getTotalSize();\n return {\n display: \"block\", // host of a custom element is inline by default\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n \"overflow-anchor\": \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: horizontal ? totalSize + \"px\" : \"100%\",\n height: horizontal ? \"100%\" : totalSize + \"px\",\n \"pointer-events\": this._store.$isScrolling() ? \"none\" : undefined,\n };\n });\n\n constructor() {\n // $effect.pre equivalents: component effects run before this component's template refreshes\n effect(() => {\n const len = this.data().length;\n if (!this._store) return;\n if (len !== this._store.$getItemsLength()) {\n this._store.$update(ACTION_ITEMS_LENGTH_CHANGE, [\n len,\n untracked(this.shift),\n ]);\n }\n });\n effect(() => {\n const startMargin = this.startMargin();\n if (!this._store) return;\n if (startMargin !== this._store.$getStartSpacerSize()) {\n this._store.$update(ACTION_START_OFFSET_CHANGE, startMargin);\n }\n });\n\n // parent's ref may not exist on mount https://github.com/inokawa/virtua/issues/603 https://github.com/inokawa/virtua/issues/690\n afterNextRender({\n read: () => {\n const scrollable = this.scrollRef() ?? this._element.parentElement!;\n this.resizer.$observeRoot(scrollable);\n this._scroller.$observe(this._element, scrollable);\n },\n });\n\n afterRenderEffect({\n read: () => {\n this._stateVersion();\n this._scroller.$fixScrollJump();\n },\n });\n\n inject(DestroyRef).onDestroy(() => {\n this._store?.$dispose();\n this.resizer?.$dispose();\n this._scroller?.$dispose();\n });\n }\n\n ngOnInit(): void {\n const itemSize = this.itemSize();\n const store = (this._store = createVirtualStore(\n this.data().length,\n itemSize,\n this.ssrCount(),\n this.cache(),\n !itemSize,\n ));\n this.resizer = createResizer(store, this.horizontal());\n this._scroller = createScroller(store, this.horizontal());\n store.$subscribe(UPDATE_VIRTUAL_STATE, (sync) => {\n this._stateVersion.set(store.$getStateVersion());\n if (sync) {\n // The store requires the DOM to be updated synchronously, otherwise\n // imperative scroll may be clamped by the stale container size.\n this._appRef.tick();\n }\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n this.scroll.emit(store.$getScrollOffset());\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n this.scrollEnd.emit();\n });\n this._stateVersion.set(store.$getStateVersion());\n }\n\n getCache(): CacheSnapshot {\n return this._store.$getCacheSnapshot();\n }\n getScrollOffset(): number {\n return this._store.$getScrollOffset();\n }\n getScrollSize(): number {\n return _getScrollSize(this._store);\n }\n getViewportSize(): number {\n return this._store.$getViewportSize();\n }\n findItemIndex(offset: number): number {\n return this._store.$findItemIndex(offset);\n }\n getItemOffset(index: number): number {\n return this._store.$getItemOffset(index);\n }\n getItemSize(index: number): number {\n return this._store.$getItemSize(index);\n }\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void {\n this._scroller.$scrollToIndex(index, opts);\n }\n scrollTo(offset: number): void {\n this._scroller.$scrollTo(offset);\n }\n scrollBy(offset: number): void {\n this._scroller.$scrollBy(offset);\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n type OnInit,\n TemplateRef,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from \"@angular/core\";\nimport { type CacheSnapshot, type ScrollToIndexOpts } from \"../core/index.js\";\nimport { Virtualizer, type VirtualizerHandle } from \"./Virtualizer.js\";\nimport { defaultGetKey, type ItemContext, type ItemProps } from \"./utils.js\";\n\n/**\n * Methods of {@link VList}.\n */\nexport interface VListHandle extends VirtualizerHandle {}\n\n/**\n * Virtualized list component. See {@link VListHandle}.\n *\n * The host element is the scrollable viewport of the list.\n */\n@Component({\n selector: \"virtua-vlist\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [Virtualizer],\n template: `\n <div\n virtuaVirtualizer\n [data]=\"data()\"\n [getKey]=\"getKey()\"\n [itemProps]=\"itemProps()\"\n [bufferSize]=\"bufferSize()\"\n [itemSize]=\"itemSize()\"\n [ssrCount]=\"ssrCount()\"\n [shift]=\"shift()\"\n [horizontal]=\"horizontal()\"\n [keepMounted]=\"keepMounted()\"\n [cache]=\"cache()\"\n [itemTemplate]=\"template()\"\n (scroll)=\"scroll.emit($event)\"\n (scrollEnd)=\"scrollEnd.emit()\"\n ></div>\n `,\n})\nexport class VList<T> implements OnInit, VListHandle {\n /**\n * The data items rendered by this component.\n */\n readonly data = input.required<readonly T[]>();\n /**\n * Function that returns the key of an item in the list. It's recommended to specify whenever possible for performance.\n * @default defaultGetKey (returns index of item)\n */\n readonly getKey =\n input<(data: T, index: number) => string | number>(defaultGetKey);\n /**\n * A function that provides properties/attributes for item element\n */\n readonly itemProps = input<ItemProps<T>>();\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n readonly bufferSize = input<number>();\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n readonly itemSize = input<number>();\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n readonly ssrCount = input<number>();\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n readonly shift = input(false);\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n readonly horizontal = input(false);\n /**\n * List of indexes that should be always mounted, even when off screen.\n */\n readonly keepMounted = input<readonly number[]>();\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VListHandle.getCache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n readonly cache = input<CacheSnapshot>();\n\n /**\n * Emitted whenever scroll offset changes. The value is current scrollTop, or scrollLeft if horizontal: true.\n */\n readonly scroll = output<number>();\n /**\n * Emitted when scrolling stops.\n */\n readonly scrollEnd = output<void>();\n\n /** @internal */\n protected template =\n contentChild.required<TemplateRef<ItemContext<T>>>(TemplateRef);\n // not _ prefixed, because the mangler does not rename the property name kept\n // as a string in the partial compilation output\n /** @internal */\n private virtualizer = viewChild.required<Virtualizer<T>>(Virtualizer);\n /** @internal */\n private _element: HTMLElement = inject(ElementRef).nativeElement;\n\n ngOnInit(): void {\n // Written once because horizontal is fixed after init. A host style binding\n // can't be used here, because it would win over the styles set by the user.\n const horizontal = this.horizontal();\n const element = this._element;\n element.setAttribute(\n \"style\",\n `display:${horizontal ? \"inline-block\" : \"block\"};` +\n `${horizontal ? \"overflow-x\" : \"overflow-y\"}:auto;` +\n \"contain:strict;width:100%;height:100%;\" +\n (element.getAttribute(\"style\") || \"\"),\n );\n }\n\n getCache(): CacheSnapshot {\n return this.virtualizer().getCache();\n }\n getScrollOffset(): number {\n return this.virtualizer().getScrollOffset();\n }\n getScrollSize(): number {\n return this.virtualizer().getScrollSize();\n }\n getViewportSize(): number {\n return this.virtualizer().getViewportSize();\n }\n findItemIndex(offset: number): number {\n return this.virtualizer().findItemIndex(offset);\n }\n getItemOffset(index: number): number {\n return this.virtualizer().getItemOffset(index);\n }\n getItemSize(index: number): number {\n return this.virtualizer().getItemSize(index);\n }\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void {\n this.virtualizer().scrollToIndex(index, opts);\n }\n scrollTo(offset: number): void {\n this.virtualizer().scrollTo(offset);\n }\n scrollBy(offset: number): void {\n this.virtualizer().scrollBy(offset);\n }\n}\n","import {\n ApplicationRef,\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n type OnInit,\n TemplateRef,\n afterNextRender,\n afterRenderEffect,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n signal,\n untracked,\n} from \"@angular/core\";\nimport { NgTemplateOutlet } from \"@angular/common\";\nimport {\n ACTION_ITEMS_LENGTH_CHANGE,\n type CacheSnapshot,\n type ScrollToIndexOpts,\n type StateVersion,\n UPDATE_SCROLL_END_EVENT,\n UPDATE_SCROLL_EVENT,\n UPDATE_VIRTUAL_STATE,\n createVirtualStore,\n createWindowResizer,\n createWindowScroller,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { defaultGetKey, type ItemContext } from \"./utils.js\";\n\n/**\n * Methods of {@link WindowVirtualizer}.\n */\nexport interface WindowVirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n getCache: () => CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true.\n */\n getScrollOffset: () => number;\n /**\n * Get current offsetHeight, or offsetWidth if horizontal: true.\n */\n getViewportSize: () => number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n}\n\n/**\n * {@link Virtualizer} controlled by the window scrolling. See {@link WindowVirtualizerHandle}.\n *\n * The host element is the container of the items. Use the attribute selector to change its tag,\n * like `<ul virtuaWindowVirtualizer [data]=\"data\">`.\n */\n@Component({\n selector: \"virtua-window-virtualizer, [virtuaWindowVirtualizer]\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ListItem, NgTemplateOutlet],\n host: {\n \"[style]\": \"containerStyle()\",\n },\n template: `\n @for (item of items(); track item.key) {\n <div\n virtuaListItem\n [index]=\"item.index\"\n [offset]=\"item.offset\"\n [hide]=\"item.hide\"\n [horizontal]=\"horizontal()\"\n [resizer]=\"resizer.$observeItem\"\n >\n <ng-container\n [ngTemplateOutlet]=\"template()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n index: item.index,\n }\"\n />\n </div>\n }\n `,\n})\nexport class WindowVirtualizer<T> implements OnInit, WindowVirtualizerHandle {\n /**\n * The data items rendered by this component.\n */\n readonly data = input.required<readonly T[]>();\n /**\n * Function that returns the key of an item in the list. It's recommended to specify whenever possible for performance.\n * @default defaultGetKey (returns index of item)\n */\n readonly getKey =\n input<(data: T, index: number) => string | number>(defaultGetKey);\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n readonly bufferSize = input<number>();\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n readonly itemSize = input<number>();\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n readonly shift = input(false);\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n readonly horizontal = input(false);\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.getCache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n readonly cache = input<CacheSnapshot>();\n\n /**\n * Emitted whenever scroll offset changes.\n */\n // https://github.com/inokawa/virtua/discussions/580\n readonly scroll = output<void>();\n /**\n * Emitted when scrolling stops.\n */\n readonly scrollEnd = output<void>();\n\n /** @internal */\n protected template =\n contentChild.required<TemplateRef<ItemContext<T>>>(TemplateRef);\n\n /** @internal */\n private _store!: ReturnType<typeof createVirtualStore>;\n /** @internal */\n protected resizer!: ReturnType<typeof createWindowResizer>;\n /** @internal */\n private _scroller!: ReturnType<typeof createWindowScroller>;\n /** @internal */\n private _element: HTMLElement = inject(ElementRef).nativeElement;\n /** @internal */\n private _appRef = inject(ApplicationRef);\n\n /** @internal */\n private _stateVersion = signal<StateVersion>(undefined!);\n\n /** @internal */\n protected items = computed(() => {\n this._stateVersion(); // the store is not a signal, so depend on its version\n const store = this._store;\n const data = this.data();\n const getKey = this.getKey();\n const negative = this._scroller.$isNegative();\n const [start, end] = store.$getRange(this.bufferSize());\n // https://github.com/inokawa/virtua/pull/847\n const items = [];\n for (let index = start; index <= end && index < data.length; index++) {\n const item = data[index]!;\n items.push({\n key: getKey(item, index),\n index,\n data: item,\n offset: store.$getItemOffset(index, negative),\n hide: store.$isUnmeasuredItem(index),\n });\n }\n return items;\n });\n\n /** @internal */\n protected containerStyle = computed(() => {\n this._stateVersion(); // the store is not a signal, so depend on its version\n const horizontal = this.horizontal();\n const totalSize = this._store.$getTotalSize();\n return {\n display: \"block\", // host of a custom element is inline by default\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n \"overflow-anchor\": \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: horizontal ? totalSize + \"px\" : \"100%\",\n height: horizontal ? \"100%\" : totalSize + \"px\",\n \"pointer-events\": this._store.$isScrolling() ? \"none\" : undefined,\n };\n });\n\n constructor() {\n effect(() => {\n const len = this.data().length;\n if (!this._store) return;\n if (len !== this._store.$getItemsLength()) {\n this._store.$update(ACTION_ITEMS_LENGTH_CHANGE, [\n len,\n untracked(this.shift),\n ]);\n }\n });\n\n afterNextRender({\n read: () => {\n this.resizer.$observeRoot(this._element);\n this._scroller.$observe(this._element);\n },\n });\n\n afterRenderEffect({\n read: () => {\n this._stateVersion();\n this._scroller.$fixScrollJump();\n },\n });\n\n inject(DestroyRef).onDestroy(() => {\n this._store?.$dispose();\n this.resizer?.$dispose();\n this._scroller?.$dispose();\n });\n }\n\n ngOnInit(): void {\n const itemSize = this.itemSize();\n const store = (this._store = createVirtualStore(\n this.data().length,\n itemSize,\n undefined,\n this.cache(),\n !itemSize,\n ));\n this.resizer = createWindowResizer(store, this.horizontal());\n this._scroller = createWindowScroller(store, this.horizontal());\n store.$subscribe(UPDATE_VIRTUAL_STATE, (sync) => {\n this._stateVersion.set(store.$getStateVersion());\n if (sync) {\n // The store requires the DOM to be updated synchronously, otherwise\n // imperative scroll may be clamped by the stale container size.\n this._appRef.tick();\n }\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n this.scroll.emit();\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n this.scrollEnd.emit();\n });\n this._stateVersion.set(store.$getStateVersion());\n }\n\n getCache(): CacheSnapshot {\n return this._store.$getCacheSnapshot();\n }\n getScrollOffset(): number {\n return this._store.$getScrollOffset();\n }\n getViewportSize(): number {\n return this._store.$getViewportSize();\n }\n findItemIndex(offset: number): number {\n return this._store.$findItemIndex(offset);\n }\n getItemOffset(index: number): number {\n return this._store.$getItemOffset(index);\n }\n getItemSize(index: number): number {\n return this._store.$getItemSize(index);\n }\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void {\n this._scroller.$scrollToIndex(index, opts);\n }\n}\n"],"mappings":";;;;;;AAIA,KAAa,KAAE,GAAA,KAAK,GAAA,KAAK,GAAA,OAAK,KAAU,MAK3B,IAAA,CACX,GACA,GACA,MACW,EAAI,GAAU,EAAI,GAAU,KAK5B,IAA0B,KAC9B,KAAI,IAAK,KAAA,CAAM,GAAG,MAAM,IAAI,IAMxB,IACe,qBAAnB,iBACH,iBACC;IACC,QAAQ,UAAU,KAAK;GAMlB,IAAA;IACX,IAAI;IAIJ,OAAO,EAAC,IAHY,QAAY;QAC9B,IAAU;QAEK;GAMN,IAAW;IACtB,IAAI;IAEJ,OAAA,OACM,MACF,IAAQ,KACR,SAAK,IAEA;GC/BL,IAAA,CAAQ,GAAiB,GAAgB;IAC7C,MAAM,IAAM,IAAU,YAAY;IAClC,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,EAAM,IAAA;IAER,OAAO;GAMI,IAAA,CAAe,GAAc;IACxC,MAAM,IAAO,EAAM,EAAO;IAC1B,QAAO,MAAA,IAAoB,EAAM,IAAmB;GAMzC,IAAA,CACX,GACA,GACA;IAEA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BACH,YAAE;;gBAEF,aAAO;gBACP,mBAAgB;;YAEjB,OAAO;gBACN,mBAAE;gBACJ,YAAA;;gBAEA,aAAY;gBACV,mBAAiB;;YAElB,YAAY;gBACX,mBAAU;gBACV,YAAW;gBACX,WAAO;gBACP,aAAW;gBACX,mBAAE;;YAEH,OAAM;gBACL,mBAAiB;gBACjB,YAAO;gBACP,WAAU;gBACV,aAAW;gBACX,mBAAkB;;;QAGpB,SAAI;YACH,QAAQ;YACR,WAAQ;;QAET,MAAE;YAAM,YAAW;gBAAA,OAAA;;;QACnB,SAAS,EAAA;YACR,cAAG;YACH,QAAM;YACP,WAAA;;YAEA,cAAY;YACX,WAAQ;;QAET,UAAA;QACA,UAAS;QACT,WAAA;QACA,cAAA,EAAe;YACd,MAAC;YACF,MAAA,EAAA,WAAA,MAAA;YACA,UAAA;YACC,QAAQ,EACT,SACA,UACE,QACF,cACA,WACE;WAEF;YACC,MAAM;YACP,MAAA,EAAA,WAAA,MAAA;;iDACF"}
@@ -0,0 +1,19 @@
1
+ export declare const defaultGetKey: (_data: unknown, i: number) => string;
2
+ /**
3
+ * A function that provides properties/attributes for item element
4
+ */
5
+ export type ItemProps<T = unknown> = (payload: {
6
+ item: T;
7
+ index: number;
8
+ }) => {
9
+ [key: string]: any;
10
+ style?: Record<string, string | undefined>;
11
+ class?: string;
12
+ } | undefined;
13
+ /**
14
+ * Context of the item template.
15
+ */
16
+ export type ItemContext<T> = {
17
+ $implicit: T;
18
+ index: number;
19
+ };