11import {
2- initCache ,
32 getItemSize as _getItemSize ,
43 getItemOffset as _getItemOffset ,
54 UNCACHED ,
@@ -9,14 +8,10 @@ import {
98 computeRange ,
109 takeCacheSnapshot ,
1110 findIndex ,
11+ Cache ,
1212} from "./cache.js" ;
1313import { isIOSWebKit } from "./environment.js" ;
14- import type {
15- CacheSnapshot ,
16- InternalCacheSnapshot ,
17- ItemResize ,
18- ItemsRange ,
19- } from "./types.js" ;
14+ import type { CacheSnapshot , ItemResize , ItemsRange } from "./types.js" ;
2015import { abs , max , min , NULL } from "./utils.js" ;
2116
2217const MAX_INT_32 = 0x7fffffff ;
@@ -117,10 +112,8 @@ export type VirtualStore = {
117112 * @internal
118113 */
119114export const createVirtualStore = (
120- elementsCount : number ,
121- itemSize : number = 40 ,
115+ cache : Cache ,
122116 ssrCount : number = 0 ,
123- cacheSnapshot ?: CacheSnapshot | undefined ,
124117 shouldAutoEstimateItemSize : boolean = false
125118) : VirtualStore => {
126119 let isSSR = ! ! ssrCount ;
@@ -137,11 +130,6 @@ export const createVirtualStore = (
137130 let _prevRange : ItemsRange = [ 0 , isSSR ? max ( ssrCount - 1 , 0 ) : - 1 ] ;
138131 let _totalMeasuredSize = 0 ;
139132
140- const cache = initCache (
141- elementsCount ,
142- itemSize ,
143- cacheSnapshot as unknown as InternalCacheSnapshot | undefined
144- ) ;
145133 const subscribers = new Set < [ number , Subscriber ] > ( ) ;
146134 const getRelativeScrollOffset = ( ) => scrollOffset - startSpacerSize ;
147135 const getVisibleOffset = ( ) => getRelativeScrollOffset ( ) + pendingJump + jump ;
0 commit comments