9388d141b94fb6370244ddded6f1eefb.json
15.8 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.computeWindowedRenderLimits=computeWindowedRenderLimits;exports.elementsThatOverlapOffsets=elementsThatOverlapOffsets;exports.newRangeCount=newRangeCount;exports.default=void 0;var _invariant=_interopRequireDefault(require(\"fbjs/lib/invariant\"));function elementsThatOverlapOffsets(offsets,itemCount,getFrameMetrics){var out=[];var outLength=0;for(var ii=0;ii<itemCount;ii++){var frame=getFrameMetrics(ii);var trailingOffset=frame.offset+frame.length;for(var kk=0;kk<offsets.length;kk++){if(out[kk]==null&&trailingOffset>=offsets[kk]){out[kk]=ii;outLength++;if(kk===offsets.length-1){(0,_invariant.default)(outLength===offsets.length,'bad offsets input, should be in increasing order: %s',JSON.stringify(offsets));return out;}}}}return out;}function newRangeCount(prev,next){return next.last-next.first+1-Math.max(0,1+Math.min(next.last,prev.last)-Math.max(next.first,prev.first));}function computeWindowedRenderLimits(props,prev,getFrameMetricsApprox,scrollMetrics){var data=props.data,getItemCount=props.getItemCount,maxToRenderPerBatch=props.maxToRenderPerBatch,windowSize=props.windowSize;var itemCount=getItemCount(data);if(itemCount===0){return prev;}var offset=scrollMetrics.offset,velocity=scrollMetrics.velocity,visibleLength=scrollMetrics.visibleLength;var visibleBegin=Math.max(0,offset);var visibleEnd=visibleBegin+visibleLength;var overscanLength=(windowSize-1)*visibleLength;var leadFactor=0.5;var fillPreference=velocity>1?'after':velocity<-1?'before':'none';var overscanBegin=Math.max(0,visibleBegin-(1-leadFactor)*overscanLength);var overscanEnd=Math.max(0,visibleEnd+leadFactor*overscanLength);var lastItemOffset=getFrameMetricsApprox(itemCount-1).offset;if(lastItemOffset<overscanBegin){return{first:Math.max(0,itemCount-1-maxToRenderPerBatch),last:itemCount-1};}var _elementsThatOverlapO=elementsThatOverlapOffsets([overscanBegin,visibleBegin,visibleEnd,overscanEnd],props.getItemCount(props.data),getFrameMetricsApprox),overscanFirst=_elementsThatOverlapO[0],first=_elementsThatOverlapO[1],last=_elementsThatOverlapO[2],overscanLast=_elementsThatOverlapO[3];overscanFirst=overscanFirst==null?0:overscanFirst;first=first==null?Math.max(0,overscanFirst):first;overscanLast=overscanLast==null?itemCount-1:overscanLast;last=last==null?Math.min(overscanLast,first+maxToRenderPerBatch-1):last;var visible={first:first,last:last};var newCellCount=newRangeCount(prev,visible);while(true){if(first<=overscanFirst&&last>=overscanLast){break;}var maxNewCells=newCellCount>=maxToRenderPerBatch;var firstWillAddMore=first<=prev.first||first>prev.last;var firstShouldIncrement=first>overscanFirst&&(!maxNewCells||!firstWillAddMore);var lastWillAddMore=last>=prev.last||last<prev.first;var lastShouldIncrement=last<overscanLast&&(!maxNewCells||!lastWillAddMore);if(maxNewCells&&!firstShouldIncrement&&!lastShouldIncrement){break;}if(firstShouldIncrement&&!(fillPreference==='after'&&lastShouldIncrement&&lastWillAddMore)){if(firstWillAddMore){newCellCount++;}first--;}if(lastShouldIncrement&&!(fillPreference==='before'&&firstShouldIncrement&&firstWillAddMore)){if(lastWillAddMore){newCellCount++;}last++;}}if(!(last>=first&&first>=0&&last<itemCount&&first>=overscanFirst&&last<=overscanLast&&first<=visible.first&&last>=visible.last)){throw new Error('Bad window calculation '+JSON.stringify({first:first,last:last,itemCount:itemCount,overscanFirst:overscanFirst,overscanLast:overscanLast,visible:visible}));}return{first:first,last:last};}var VirtualizeUtils={computeWindowedRenderLimits:computeWindowedRenderLimits,elementsThatOverlapOffsets:elementsThatOverlapOffsets,newRangeCount:newRangeCount};var _default=VirtualizeUtils;exports.default=_default;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-web/dist/vendor/react-native/VirtualizeUtils/index.js"],"names":["elementsThatOverlapOffsets","offsets","itemCount","getFrameMetrics","out","outLength","ii","frame","trailingOffset","offset","length","kk","JSON","stringify","newRangeCount","prev","next","last","first","Math","max","min","computeWindowedRenderLimits","props","getFrameMetricsApprox","scrollMetrics","data","getItemCount","maxToRenderPerBatch","windowSize","velocity","visibleLength","visibleBegin","visibleEnd","overscanLength","leadFactor","fillPreference","overscanBegin","overscanEnd","lastItemOffset","_elementsThatOverlapO","overscanFirst","overscanLast","visible","newCellCount","maxNewCells","firstWillAddMore","firstShouldIncrement","lastWillAddMore","lastShouldIncrement","Error","VirtualizeUtils"],"mappings":"qUASA,qEAOA,QAASA,CAAAA,0BAAT,CAAoCC,OAApC,CAA6CC,SAA7C,CAAwDC,eAAxD,CAAyE,CACvE,GAAIC,CAAAA,GAAG,CAAG,EAAV,CACA,GAAIC,CAAAA,SAAS,CAAG,CAAhB,CAEA,IAAK,GAAIC,CAAAA,EAAE,CAAG,CAAd,CAAiBA,EAAE,CAAGJ,SAAtB,CAAiCI,EAAE,EAAnC,CAAuC,CACrC,GAAIC,CAAAA,KAAK,CAAGJ,eAAe,CAACG,EAAD,CAA3B,CACA,GAAIE,CAAAA,cAAc,CAAGD,KAAK,CAACE,MAAN,CAAeF,KAAK,CAACG,MAA1C,CAEA,IAAK,GAAIC,CAAAA,EAAE,CAAG,CAAd,CAAiBA,EAAE,CAAGV,OAAO,CAACS,MAA9B,CAAsCC,EAAE,EAAxC,CAA4C,CAC1C,GAAIP,GAAG,CAACO,EAAD,CAAH,EAAW,IAAX,EAAmBH,cAAc,EAAIP,OAAO,CAACU,EAAD,CAAhD,CAAsD,CACpDP,GAAG,CAACO,EAAD,CAAH,CAAUL,EAAV,CACAD,SAAS,GAET,GAAIM,EAAE,GAAKV,OAAO,CAACS,MAAR,CAAiB,CAA5B,CAA+B,CAC7B,uBAAUL,SAAS,GAAKJ,OAAO,CAACS,MAAhC,CAAwC,sDAAxC,CAAgGE,IAAI,CAACC,SAAL,CAAeZ,OAAf,CAAhG,EACA,MAAOG,CAAAA,GAAP,CACD,CACF,CACF,CACF,CAED,MAAOA,CAAAA,GAAP,CACD,CASD,QAASU,CAAAA,aAAT,CAAuBC,IAAv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IE,eAAJ,CAAqB,CACnBJ,YAAY,GACb,CAED3B,IAAI,GACL,CACF,CAED,GAAI,EAAEA,IAAI,EAAIC,KAAR,EAAiBA,KAAK,EAAI,CAA1B,EAA+BD,IAAI,CAAGf,SAAtC,EAAmDgB,KAAK,EAAIuB,aAA5D,EAA6ExB,IAAI,EAAIyB,YAArF,EAAqGxB,KAAK,EAAIyB,OAAO,CAACzB,KAAtH,EAA+HD,IAAI,EAAI0B,OAAO,CAAC1B,IAAjJ,CAAJ,CAA4J,CAC1J,KAAM,IAAIiC,CAAAA,KAAJ,CAAU,0BAA4BtC,IAAI,CAACC,SAAL,CAAe,CACzDK,KAAK,CAAEA,KADkD,CAEzDD,IAAI,CAAEA,IAFmD,CAGzDf,SAAS,CAAEA,SAH8C,CAIzDuC,aAAa,CAAEA,aAJ0C,CAKzDC,YAAY,CAAEA,YAL2C,CAMzDC,OAAO,CAAEA,OANgD,CAAf,CAAtC,CAAN,CAQD,CAED,MAAO,CACLzB,KAAK,CAAEA,KADF,CAELD,IAAI,CAAEA,IAFD,CAAP,CAID,CAGD,GAAIkC,CAAAA,eAAe,CAAG,CACpB7B,2BAA2B,CAAEA,2BADT,CAEpBtB,0BAA0B,CAAEA,0BAFR,CAGpBc,aAAa,CAAEA,aAHK,CAAtB,C,aAKeqC,e","sourcesContent":["/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\nimport invariant from 'fbjs/lib/invariant';\n/**\n * Used to find the indices of the frames that overlap the given offsets. Useful for finding the\n * items that bound different windows of content, such as the visible area or the buffered overscan\n * area.\n */\n\nfunction elementsThatOverlapOffsets(offsets, itemCount, getFrameMetrics) {\n var out = [];\n var outLength = 0;\n\n for (var ii = 0; ii < itemCount; ii++) {\n var frame = getFrameMetrics(ii);\n var trailingOffset = frame.offset + frame.length;\n\n for (var kk = 0; kk < offsets.length; kk++) {\n if (out[kk] == null && trailingOffset >= offsets[kk]) {\n out[kk] = ii;\n outLength++;\n\n if (kk === offsets.length - 1) {\n invariant(outLength === offsets.length, 'bad offsets input, should be in increasing order: %s', JSON.stringify(offsets));\n return out;\n }\n }\n }\n }\n\n return out;\n}\n/**\n * Computes the number of elements in the `next` range that are new compared to the `prev` range.\n * Handy for calculating how many new items will be rendered when the render window changes so we\n * can restrict the number of new items render at once so that content can appear on the screen\n * faster.\n */\n\n\nfunction newRangeCount(prev, next) {\n return next.last - next.first + 1 - Math.max(0, 1 + Math.min(next.last, prev.last) - Math.max(next.first, prev.first));\n}\n/**\n * Custom logic for determining which items should be rendered given the current frame and scroll\n * metrics, as well as the previous render state. The algorithm may evolve over time, but generally\n * prioritizes the visible area first, then expands that with overscan regions ahead and behind,\n * biased in the direction of scroll.\n */\n\n\nfunction computeWindowedRenderLimits(props, prev, getFrameMetricsApprox, scrollMetrics) {\n var data = props.data,\n getItemCount = props.getItemCount,\n maxToRenderPerBatch = props.maxToRenderPerBatch,\n windowSize = props.windowSize;\n var itemCount = getItemCount(data);\n\n if (itemCount === 0) {\n return prev;\n }\n\n var offset = scrollMetrics.offset,\n velocity = scrollMetrics.velocity,\n visibleLength = scrollMetrics.visibleLength; // Start with visible area, then compute maximum overscan region by expanding from there, biased\n // in the direction of scroll. Total overscan area is capped, which should cap memory consumption\n // too.\n\n var visibleBegin = Math.max(0, offset);\n var visibleEnd = visibleBegin + visibleLength;\n var overscanLength = (windowSize - 1) * visibleLength; // Considering velocity seems to introduce more churn than it's worth.\n\n var leadFactor = 0.5; // Math.max(0, Math.min(1, velocity / 25 + 0.5));\n\n var fillPreference = velocity > 1 ? 'after' : velocity < -1 ? 'before' : 'none';\n var overscanBegin = Math.max(0, visibleBegin - (1 - leadFactor) * overscanLength);\n var overscanEnd = Math.max(0, visibleEnd + leadFactor * overscanLength);\n var lastItemOffset = getFrameMetricsApprox(itemCount - 1).offset;\n\n if (lastItemOffset < overscanBegin) {\n // Entire list is before our overscan window\n return {\n first: Math.max(0, itemCount - 1 - maxToRenderPerBatch),\n last: itemCount - 1\n };\n } // Find the indices that correspond to the items at the render boundaries we're targeting.\n\n\n var _elementsThatOverlapO = elementsThatOverlapOffsets([overscanBegin, visibleBegin, visibleEnd, overscanEnd], props.getItemCount(props.data), getFrameMetricsApprox),\n overscanFirst = _elementsThatOverlapO[0],\n first = _elementsThatOverlapO[1],\n last = _elementsThatOverlapO[2],\n overscanLast = _elementsThatOverlapO[3];\n\n overscanFirst = overscanFirst == null ? 0 : overscanFirst;\n first = first == null ? Math.max(0, overscanFirst) : first;\n overscanLast = overscanLast == null ? itemCount - 1 : overscanLast;\n last = last == null ? Math.min(overscanLast, first + maxToRenderPerBatch - 1) : last;\n var visible = {\n first: first,\n last: last\n }; // We want to limit the number of new cells we're rendering per batch so that we can fill the\n // content on the screen quickly. If we rendered the entire overscan window at once, the user\n // could be staring at white space for a long time waiting for a bunch of offscreen content to\n // render.\n\n var newCellCount = newRangeCount(prev, visible);\n\n while (true) {\n if (first <= overscanFirst && last >= overscanLast) {\n // If we fill the entire overscan range, we're done.\n break;\n }\n\n var maxNewCells = newCellCount >= maxToRenderPerBatch;\n var firstWillAddMore = first <= prev.first || first > prev.last;\n var firstShouldIncrement = first > overscanFirst && (!maxNewCells || !firstWillAddMore);\n var lastWillAddMore = last >= prev.last || last < prev.first;\n var lastShouldIncrement = last < overscanLast && (!maxNewCells || !lastWillAddMore);\n\n if (maxNewCells && !firstShouldIncrement && !lastShouldIncrement) {\n // We only want to stop if we've hit maxNewCells AND we cannot increment first or last\n // without rendering new items. This let's us preserve as many already rendered items as\n // possible, reducing render churn and keeping the rendered overscan range as large as\n // possible.\n break;\n }\n\n if (firstShouldIncrement && !(fillPreference === 'after' && lastShouldIncrement && lastWillAddMore)) {\n if (firstWillAddMore) {\n newCellCount++;\n }\n\n first--;\n }\n\n if (lastShouldIncrement && !(fillPreference === 'before' && firstShouldIncrement && firstWillAddMore)) {\n if (lastWillAddMore) {\n newCellCount++;\n }\n\n last++;\n }\n }\n\n if (!(last >= first && first >= 0 && last < itemCount && first >= overscanFirst && last <= overscanLast && first <= visible.first && last >= visible.last)) {\n throw new Error('Bad window calculation ' + JSON.stringify({\n first: first,\n last: last,\n itemCount: itemCount,\n overscanFirst: overscanFirst,\n overscanLast: overscanLast,\n visible: visible\n }));\n }\n\n return {\n first: first,\n last: last\n };\n}\n\nexport { computeWindowedRenderLimits, elementsThatOverlapOffsets, newRangeCount };\nvar VirtualizeUtils = {\n computeWindowedRenderLimits: computeWindowedRenderLimits,\n elementsThatOverlapOffsets: elementsThatOverlapOffsets,\n newRangeCount: newRangeCount\n};\nexport default VirtualizeUtils;"]},"metadata":{},"sourceType":"script"}