@react-native-ohos/flash-list 1.6.4-rc.1

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 (298) hide show
  1. package/LICENSE +7 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +9 -0
  4. package/dist/AnimatedFlashList.d.ts +6 -0
  5. package/dist/AnimatedFlashList.d.ts.map +1 -0
  6. package/dist/AnimatedFlashList.js +8 -0
  7. package/dist/AnimatedFlashList.js.map +1 -0
  8. package/dist/FlashList.d.ts +126 -0
  9. package/dist/FlashList.d.ts.map +1 -0
  10. package/dist/FlashList.js +524 -0
  11. package/dist/FlashList.js.map +1 -0
  12. package/dist/FlashListProps.d.ts +256 -0
  13. package/dist/FlashListProps.d.ts.map +1 -0
  14. package/dist/FlashListProps.js +9 -0
  15. package/dist/FlashListProps.js.map +1 -0
  16. package/dist/GridLayoutProviderWithProps.d.ts +42 -0
  17. package/dist/GridLayoutProviderWithProps.d.ts.map +1 -0
  18. package/dist/GridLayoutProviderWithProps.js +115 -0
  19. package/dist/GridLayoutProviderWithProps.js.map +1 -0
  20. package/dist/MasonryFlashList.d.ts +51 -0
  21. package/dist/MasonryFlashList.d.ts.map +1 -0
  22. package/dist/MasonryFlashList.js +252 -0
  23. package/dist/MasonryFlashList.js.map +1 -0
  24. package/dist/PureComponentWrapper.d.ts +22 -0
  25. package/dist/PureComponentWrapper.d.ts.map +1 -0
  26. package/dist/PureComponentWrapper.js +37 -0
  27. package/dist/PureComponentWrapper.js.map +1 -0
  28. package/dist/__tests__/AverageWindow.test.d.ts +2 -0
  29. package/dist/__tests__/AverageWindow.test.d.ts.map +1 -0
  30. package/dist/__tests__/AverageWindow.test.js +69 -0
  31. package/dist/__tests__/AverageWindow.test.js.map +1 -0
  32. package/dist/__tests__/ContentContainerUtils.test.d.ts +2 -0
  33. package/dist/__tests__/ContentContainerUtils.test.d.ts.map +1 -0
  34. package/dist/__tests__/ContentContainerUtils.test.js +85 -0
  35. package/dist/__tests__/ContentContainerUtils.test.js.map +1 -0
  36. package/dist/__tests__/FlashList.test.d.ts +2 -0
  37. package/dist/__tests__/FlashList.test.d.ts.map +1 -0
  38. package/dist/__tests__/FlashList.test.js +792 -0
  39. package/dist/__tests__/FlashList.test.js.map +1 -0
  40. package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +2 -0
  41. package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +1 -0
  42. package/dist/__tests__/GridLayoutProviderWithProps.test.js +143 -0
  43. package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +1 -0
  44. package/dist/__tests__/MasonryFlashList.test.d.ts +2 -0
  45. package/dist/__tests__/MasonryFlashList.test.d.ts.map +1 -0
  46. package/dist/__tests__/MasonryFlashList.test.js +254 -0
  47. package/dist/__tests__/MasonryFlashList.test.js.map +1 -0
  48. package/dist/__tests__/PlatformHelper.web.test.d.ts +2 -0
  49. package/dist/__tests__/PlatformHelper.web.test.d.ts.map +1 -0
  50. package/dist/__tests__/PlatformHelper.web.test.js +33 -0
  51. package/dist/__tests__/PlatformHelper.web.test.js.map +1 -0
  52. package/dist/__tests__/ViewabilityHelper.test.d.ts +2 -0
  53. package/dist/__tests__/ViewabilityHelper.test.d.ts.map +1 -0
  54. package/dist/__tests__/ViewabilityHelper.test.js +187 -0
  55. package/dist/__tests__/ViewabilityHelper.test.js.map +1 -0
  56. package/dist/__tests__/helpers/mountFlashList.d.ts +19 -0
  57. package/dist/__tests__/helpers/mountFlashList.d.ts.map +1 -0
  58. package/dist/__tests__/helpers/mountFlashList.js +44 -0
  59. package/dist/__tests__/helpers/mountFlashList.js.map +1 -0
  60. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +18 -0
  61. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +1 -0
  62. package/dist/__tests__/helpers/mountMasonryFlashList.js +49 -0
  63. package/dist/__tests__/helpers/mountMasonryFlashList.js.map +1 -0
  64. package/dist/__tests__/useBlankAreaTracker.test.d.ts +2 -0
  65. package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +1 -0
  66. package/dist/__tests__/useBlankAreaTracker.test.js +177 -0
  67. package/dist/__tests__/useBlankAreaTracker.test.js.map +1 -0
  68. package/dist/benchmark/AutoScrollHelper.d.ts +18 -0
  69. package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -0
  70. package/dist/benchmark/AutoScrollHelper.js +68 -0
  71. package/dist/benchmark/AutoScrollHelper.js.map +1 -0
  72. package/dist/benchmark/JSFPSMonitor.d.ts +23 -0
  73. package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -0
  74. package/dist/benchmark/JSFPSMonitor.js +65 -0
  75. package/dist/benchmark/JSFPSMonitor.js.map +1 -0
  76. package/dist/benchmark/roundToDecimalPlaces.d.ts +2 -0
  77. package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -0
  78. package/dist/benchmark/roundToDecimalPlaces.js +9 -0
  79. package/dist/benchmark/roundToDecimalPlaces.js.map +1 -0
  80. package/dist/benchmark/useBenchmark.d.ts +35 -0
  81. package/dist/benchmark/useBenchmark.d.ts.map +1 -0
  82. package/dist/benchmark/useBenchmark.js +167 -0
  83. package/dist/benchmark/useBenchmark.js.map +1 -0
  84. package/dist/benchmark/useBlankAreaTracker.d.ts +34 -0
  85. package/dist/benchmark/useBlankAreaTracker.d.ts.map +1 -0
  86. package/dist/benchmark/useBlankAreaTracker.js +67 -0
  87. package/dist/benchmark/useBlankAreaTracker.js.map +1 -0
  88. package/dist/benchmark/useDataMultiplier.d.ts +9 -0
  89. package/dist/benchmark/useDataMultiplier.d.ts.map +1 -0
  90. package/dist/benchmark/useDataMultiplier.js +25 -0
  91. package/dist/benchmark/useDataMultiplier.js.map +1 -0
  92. package/dist/benchmark/useFlatListBenchmark.d.ts +13 -0
  93. package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -0
  94. package/dist/benchmark/useFlatListBenchmark.js +100 -0
  95. package/dist/benchmark/useFlatListBenchmark.js.map +1 -0
  96. package/dist/errors/CustomError.d.ts +8 -0
  97. package/dist/errors/CustomError.d.ts.map +1 -0
  98. package/dist/errors/CustomError.js +14 -0
  99. package/dist/errors/CustomError.js.map +1 -0
  100. package/dist/errors/ExceptionList.d.ts +24 -0
  101. package/dist/errors/ExceptionList.d.ts.map +1 -0
  102. package/dist/errors/ExceptionList.js +26 -0
  103. package/dist/errors/ExceptionList.js.map +1 -0
  104. package/dist/errors/Warnings.d.ts +9 -0
  105. package/dist/errors/Warnings.d.ts.map +1 -0
  106. package/dist/errors/Warnings.js +13 -0
  107. package/dist/errors/Warnings.js.map +1 -0
  108. package/dist/fabric/AutoLayoutNativeComponent.d.ts +19 -0
  109. package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +1 -0
  110. package/dist/fabric/AutoLayoutNativeComponent.js +29 -0
  111. package/dist/fabric/AutoLayoutNativeComponent.js.map +1 -0
  112. package/dist/fabric/CellContainerNativeComponent.d.ts +8 -0
  113. package/dist/fabric/CellContainerNativeComponent.d.ts.map +1 -0
  114. package/dist/fabric/CellContainerNativeComponent.js +29 -0
  115. package/dist/fabric/CellContainerNativeComponent.js.map +1 -0
  116. package/dist/index.d.ts +14 -0
  117. package/dist/index.d.ts.map +1 -0
  118. package/dist/index.js +32 -0
  119. package/dist/index.js.map +1 -0
  120. package/dist/native/auto-layout/AutoLayoutView.d.ts +22 -0
  121. package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -0
  122. package/dist/native/auto-layout/AutoLayoutView.js +48 -0
  123. package/dist/native/auto-layout/AutoLayoutView.js.map +1 -0
  124. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +4 -0
  125. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -0
  126. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +6 -0
  127. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +1 -0
  128. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +5 -0
  129. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -0
  130. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +4 -0
  131. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +1 -0
  132. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +29 -0
  133. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +1 -0
  134. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +4 -0
  135. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -0
  136. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +6 -0
  137. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +1 -0
  138. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +6 -0
  139. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +1 -0
  140. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +16 -0
  141. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -0
  142. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +3 -0
  143. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +1 -0
  144. package/dist/native/cell-container/CellContainer.android.d.ts +6 -0
  145. package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -0
  146. package/dist/native/cell-container/CellContainer.android.js +9 -0
  147. package/dist/native/cell-container/CellContainer.android.js.map +1 -0
  148. package/dist/native/cell-container/CellContainer.d.ts +8 -0
  149. package/dist/native/cell-container/CellContainer.d.ts.map +1 -0
  150. package/dist/native/cell-container/CellContainer.harmony.d.ts +6 -0
  151. package/dist/native/cell-container/CellContainer.harmony.d.ts.map +1 -0
  152. package/dist/native/cell-container/CellContainer.harmony.js +32 -0
  153. package/dist/native/cell-container/CellContainer.harmony.js.map +1 -0
  154. package/dist/native/cell-container/CellContainer.ios.d.ts +6 -0
  155. package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -0
  156. package/dist/native/cell-container/CellContainer.ios.js +9 -0
  157. package/dist/native/cell-container/CellContainer.ios.js.map +1 -0
  158. package/dist/native/cell-container/CellContainer.js +11 -0
  159. package/dist/native/cell-container/CellContainer.js.map +1 -0
  160. package/dist/native/cell-container/CellContainer.web.d.ts +7 -0
  161. package/dist/native/cell-container/CellContainer.web.d.ts.map +1 -0
  162. package/dist/native/cell-container/CellContainer.web.js +13 -0
  163. package/dist/native/cell-container/CellContainer.web.js.map +1 -0
  164. package/dist/native/config/PlatformHelper.android.d.ts +26 -0
  165. package/dist/native/config/PlatformHelper.android.d.ts.map +1 -0
  166. package/dist/native/config/PlatformHelper.android.js +23 -0
  167. package/dist/native/config/PlatformHelper.android.js.map +1 -0
  168. package/dist/native/config/PlatformHelper.d.ts +26 -0
  169. package/dist/native/config/PlatformHelper.d.ts.map +1 -0
  170. package/dist/native/config/PlatformHelper.harmony.d.ts +26 -0
  171. package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -0
  172. package/dist/native/config/PlatformHelper.harmony.js +22 -0
  173. package/dist/native/config/PlatformHelper.harmony.js.map +1 -0
  174. package/dist/native/config/PlatformHelper.ios.d.ts +26 -0
  175. package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -0
  176. package/dist/native/config/PlatformHelper.ios.js +22 -0
  177. package/dist/native/config/PlatformHelper.ios.js.map +1 -0
  178. package/dist/native/config/PlatformHelper.js +23 -0
  179. package/dist/native/config/PlatformHelper.js.map +1 -0
  180. package/dist/native/config/PlatformHelper.web.d.ts +27 -0
  181. package/dist/native/config/PlatformHelper.web.d.ts.map +1 -0
  182. package/dist/native/config/PlatformHelper.web.js +25 -0
  183. package/dist/native/config/PlatformHelper.web.js.map +1 -0
  184. package/dist/tsconfig.tsbuildinfo +1 -0
  185. package/dist/utils/AverageWindow.d.ts +21 -0
  186. package/dist/utils/AverageWindow.d.ts.map +1 -0
  187. package/dist/utils/AverageWindow.js +49 -0
  188. package/dist/utils/AverageWindow.js.map +1 -0
  189. package/dist/utils/ContentContainerUtils.d.ts +27 -0
  190. package/dist/utils/ContentContainerUtils.d.ts.map +1 -0
  191. package/dist/utils/ContentContainerUtils.js +48 -0
  192. package/dist/utils/ContentContainerUtils.js.map +1 -0
  193. package/dist/viewability/ViewToken.d.ts +8 -0
  194. package/dist/viewability/ViewToken.d.ts.map +1 -0
  195. package/dist/viewability/ViewToken.js +3 -0
  196. package/dist/viewability/ViewToken.js.map +1 -0
  197. package/dist/viewability/ViewabilityHelper.d.ts +25 -0
  198. package/dist/viewability/ViewabilityHelper.d.ts.map +1 -0
  199. package/dist/viewability/ViewabilityHelper.js +104 -0
  200. package/dist/viewability/ViewabilityHelper.js.map +1 -0
  201. package/dist/viewability/ViewabilityManager.d.ts +24 -0
  202. package/dist/viewability/ViewabilityManager.d.ts.map +1 -0
  203. package/dist/viewability/ViewabilityManager.js +94 -0
  204. package/dist/viewability/ViewabilityManager.js.map +1 -0
  205. package/harmony/flash_list/BuildProfile.ets +5 -0
  206. package/harmony/flash_list/LICENSE +7 -0
  207. package/harmony/flash_list/build-profile.json5 +8 -0
  208. package/harmony/flash_list/hvigorfile.ts +1 -0
  209. package/harmony/flash_list/index.ets +29 -0
  210. package/harmony/flash_list/obfuscation-rules.txt +18 -0
  211. package/harmony/flash_list/oh-package-lock.json5 +17 -0
  212. package/harmony/flash_list/oh-package.json5 +13 -0
  213. package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +63 -0
  214. package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +57 -0
  215. package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +140 -0
  216. package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +66 -0
  217. package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +208 -0
  218. package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +78 -0
  219. package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +53 -0
  220. package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +50 -0
  221. package/harmony/flash_list/src/main/cpp/CMakeLists.txt +7 -0
  222. package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +80 -0
  223. package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +67 -0
  224. package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +39 -0
  225. package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +40 -0
  226. package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +40 -0
  227. package/harmony/flash_list/src/main/cpp/EventEmitters.h +48 -0
  228. package/harmony/flash_list/src/main/cpp/FlashListPackage.h +78 -0
  229. package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +89 -0
  230. package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +59 -0
  231. package/harmony/flash_list/src/main/cpp/Props.cpp +52 -0
  232. package/harmony/flash_list/src/main/cpp/Props.h +64 -0
  233. package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +34 -0
  234. package/harmony/flash_list/src/main/cpp/ShadowNodes.h +48 -0
  235. package/harmony/flash_list/src/main/ets/Logger.ets +64 -0
  236. package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +154 -0
  237. package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +252 -0
  238. package/harmony/flash_list/src/main/ets/RNCellContainer.ets +113 -0
  239. package/harmony/flash_list/src/main/module.json5 +7 -0
  240. package/harmony/flash_list/src/main/resources/base/element/color.json +8 -0
  241. package/harmony/flash_list/src/main/resources/base/element/string.json +16 -0
  242. package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
  243. package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +5 -0
  244. package/harmony/flash_list/src/main/resources/en_US/element/string.json +16 -0
  245. package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +16 -0
  246. package/harmony/flash_list.har +0 -0
  247. package/jestSetup.js +16 -0
  248. package/package.json +88 -0
  249. package/src/AnimatedFlashList.ts +11 -0
  250. package/src/FlashList.tsx +870 -0
  251. package/src/FlashListProps.ts +335 -0
  252. package/src/GridLayoutProviderWithProps.ts +180 -0
  253. package/src/MasonryFlashList.tsx +476 -0
  254. package/src/PureComponentWrapper.tsx +42 -0
  255. package/src/__tests__/AverageWindow.test.ts +80 -0
  256. package/src/__tests__/ContentContainerUtils.test.ts +130 -0
  257. package/src/__tests__/FlashList.test.tsx +886 -0
  258. package/src/__tests__/GridLayoutProviderWithProps.test.ts +179 -0
  259. package/src/__tests__/MasonryFlashList.test.ts +292 -0
  260. package/src/__tests__/PlatformHelper.web.test.ts +45 -0
  261. package/src/__tests__/ViewabilityHelper.test.ts +283 -0
  262. package/src/__tests__/helpers/mountFlashList.tsx +62 -0
  263. package/src/__tests__/helpers/mountMasonryFlashList.tsx +70 -0
  264. package/src/__tests__/useBlankAreaTracker.test.tsx +204 -0
  265. package/src/benchmark/AutoScrollHelper.ts +70 -0
  266. package/src/benchmark/JSFPSMonitor.ts +74 -0
  267. package/src/benchmark/roundToDecimalPlaces.ts +4 -0
  268. package/src/benchmark/useBenchmark.ts +240 -0
  269. package/src/benchmark/useBlankAreaTracker.ts +117 -0
  270. package/src/benchmark/useDataMultiplier.ts +19 -0
  271. package/src/benchmark/useFlatListBenchmark.ts +107 -0
  272. package/src/errors/CustomError.ts +10 -0
  273. package/src/errors/ExceptionList.ts +28 -0
  274. package/src/errors/Warnings.ts +15 -0
  275. package/src/fabric/AutoLayoutNativeComponent.ts +51 -0
  276. package/src/fabric/CellContainerNativeComponent.ts +34 -0
  277. package/src/index.ts +43 -0
  278. package/src/native/auto-layout/AutoLayoutView.tsx +73 -0
  279. package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +7 -0
  280. package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +30 -0
  281. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +7 -0
  282. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +7 -0
  283. package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +17 -0
  284. package/src/native/cell-container/CellContainer.android.ts +7 -0
  285. package/src/native/cell-container/CellContainer.harmony.ts +30 -0
  286. package/src/native/cell-container/CellContainer.ios.ts +6 -0
  287. package/src/native/cell-container/CellContainer.tsx +14 -0
  288. package/src/native/cell-container/CellContainer.web.tsx +9 -0
  289. package/src/native/config/PlatformHelper.android.ts +29 -0
  290. package/src/native/config/PlatformHelper.harmony.ts +51 -0
  291. package/src/native/config/PlatformHelper.ios.ts +28 -0
  292. package/src/native/config/PlatformHelper.ts +29 -0
  293. package/src/native/config/PlatformHelper.web.ts +34 -0
  294. package/src/utils/AverageWindow.ts +49 -0
  295. package/src/utils/ContentContainerUtils.ts +92 -0
  296. package/src/viewability/ViewToken.ts +7 -0
  297. package/src/viewability/ViewabilityHelper.ts +162 -0
  298. package/src/viewability/ViewabilityManager.ts +134 -0
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cancellable = exports.autoScroll = void 0;
4
+ /**
5
+ * This method can be used to trigger scroll events that can be forwarded to an element. Anything that implements scrollable can leverage this.
6
+ * @param scroll The scrollable element
7
+ * @param fromX The x offset to start from
8
+ * @param fromY The y offset to start from
9
+ * @param toX the x offset to end scroll at
10
+ * @param toY the y offset to end scroll at
11
+ * @param speedMultiplier the speed multiplier to use
12
+ * @param cancellable can be used to cancel the scroll
13
+ * @returns Promise that resolves when the scroll is complete
14
+ */
15
+ function autoScroll(scroll, fromX, fromY, toX, toY, speedMultiplier, cancellable) {
16
+ if (speedMultiplier === void 0) { speedMultiplier = 1; }
17
+ if (cancellable === void 0) { cancellable = new Cancellable(); }
18
+ return new Promise(function (resolve) {
19
+ scroll(fromX, fromY, false);
20
+ // Very fast scrolls on Android/iOS typically move content 7px every millisecond.
21
+ var incrementPerMs = 7 * speedMultiplier;
22
+ var directionMultiplierX = toX > fromX ? 1 : -1;
23
+ var directionMultiplierY = toY > fromY ? 1 : -1;
24
+ var comparatorX = toX > fromX ? Math.min : Math.max;
25
+ var comparatorY = toY > fromY ? Math.min : Math.max;
26
+ var startTime = Date.now();
27
+ var startX = fromX;
28
+ var startY = fromY;
29
+ // Computes the number of pixels to scroll in the given time
30
+ // Also invokes the scrollable to update the scroll position
31
+ var animationLoop = function () {
32
+ requestAnimationFrame(function () {
33
+ if (cancellable.isCancelled()) {
34
+ resolve(false);
35
+ return;
36
+ }
37
+ var currentTime = Date.now();
38
+ var timeElapsed = currentTime - startTime;
39
+ var distanceToCover = incrementPerMs * timeElapsed;
40
+ startX += distanceToCover * directionMultiplierX;
41
+ startY += distanceToCover * directionMultiplierY;
42
+ scroll(comparatorX(toX, startX), comparatorY(toY, startY), false);
43
+ startTime = currentTime;
44
+ if (comparatorX(toX, startX) !== toX ||
45
+ comparatorY(toY, startY) !== toY) {
46
+ return animationLoop();
47
+ }
48
+ resolve(true);
49
+ });
50
+ };
51
+ animationLoop();
52
+ });
53
+ }
54
+ exports.autoScroll = autoScroll;
55
+ var Cancellable = /** @class */ (function () {
56
+ function Cancellable() {
57
+ this._isCancelled = false;
58
+ }
59
+ Cancellable.prototype.cancel = function () {
60
+ this._isCancelled = true;
61
+ };
62
+ Cancellable.prototype.isCancelled = function () {
63
+ return this._isCancelled;
64
+ };
65
+ return Cancellable;
66
+ }());
67
+ exports.Cancellable = Cancellable;
68
+ //# sourceMappingURL=AutoScrollHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoScrollHelper.js","sourceRoot":"","sources":["../../src/benchmark/AutoScrollHelper.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,MAAyD,EACzD,KAAa,EACb,KAAa,EACb,GAAW,EACX,GAAW,EACX,eAAmB,EACnB,WAA4C;IAD5C,gCAAA,EAAA,mBAAmB;IACnB,4BAAA,EAAA,kBAA+B,WAAW,E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E,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;gBAClE,SAAS,GAAG,WAAW,CAAC;gBACxB,IACE,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG;oBAChC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG,EAChC;oBACA,OAAO,aAAa,EAAE,CAAC;iBACxB;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QACF,aAAa,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AA9CD,gCA8CC;AAED;IAAA;QASS,iBAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IATQ,4BAAM,GAAb;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEM,iCAAW,GAAlB;QACE,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAGH,kBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,kCAAW"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Can be used to monitor JS thread performance
3
+ * Use startTracking() and stopAndGetData() to start and stop tracking
4
+ */
5
+ export declare class JSFPSMonitor {
6
+ private startTime;
7
+ private frameCount;
8
+ private timeWindow;
9
+ private minFPS;
10
+ private maxFPS;
11
+ private averageFPS;
12
+ private clearAnimationNumber;
13
+ private measureLoop;
14
+ private updateLoopCompute;
15
+ startTracking(): void;
16
+ stopAndGetData(): JSFPSResult;
17
+ }
18
+ export interface JSFPSResult {
19
+ minFPS: number;
20
+ maxFPS: number;
21
+ averageFPS: number;
22
+ }
23
+ //# sourceMappingURL=JSFPSMonitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JSFPSMonitor.d.ts","sourceRoot":"","sources":["../../src/benchmark/JSFPSMonitor.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAGhB;IAEF,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,UAAU,CAAK;IAEvB,OAAO,CAAC,oBAAoB,CAAK;IAEjC,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,iBAAiB,CAiBvB;IAEK,aAAa;IAWb,cAAc,IAAI,WAAW;CAYrC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSFPSMonitor = void 0;
4
+ var roundToDecimalPlaces_1 = require("./roundToDecimalPlaces");
5
+ /**
6
+ * Can be used to monitor JS thread performance
7
+ * Use startTracking() and stopAndGetData() to start and stop tracking
8
+ */
9
+ var JSFPSMonitor = /** @class */ (function () {
10
+ function JSFPSMonitor() {
11
+ var _this = this;
12
+ this.startTime = 0;
13
+ this.frameCount = 0;
14
+ this.timeWindow = {
15
+ frameCount: 0,
16
+ startTime: 0,
17
+ };
18
+ this.minFPS = Number.MAX_SAFE_INTEGER;
19
+ this.maxFPS = 0;
20
+ this.averageFPS = 0;
21
+ this.clearAnimationNumber = 0;
22
+ this.updateLoopCompute = function () {
23
+ _this.frameCount++;
24
+ var elapsedTime = (Date.now() - _this.startTime) / 1000;
25
+ _this.averageFPS = elapsedTime > 0 ? _this.frameCount / elapsedTime : 0;
26
+ _this.timeWindow.frameCount++;
27
+ var timeWindowElapsedTime = (Date.now() - _this.timeWindow.startTime) / 1000;
28
+ if (timeWindowElapsedTime >= 1) {
29
+ var timeWindowAverageFPS = _this.timeWindow.frameCount / timeWindowElapsedTime;
30
+ _this.minFPS = Math.min(_this.minFPS, timeWindowAverageFPS);
31
+ _this.maxFPS = Math.max(_this.maxFPS, timeWindowAverageFPS);
32
+ _this.timeWindow.frameCount = 0;
33
+ _this.timeWindow.startTime = Date.now();
34
+ }
35
+ _this.measureLoop();
36
+ };
37
+ }
38
+ JSFPSMonitor.prototype.measureLoop = function () {
39
+ // This looks weird but I'm avoiding a new closure
40
+ this.clearAnimationNumber = requestAnimationFrame(this.updateLoopCompute);
41
+ };
42
+ JSFPSMonitor.prototype.startTracking = function () {
43
+ if (this.startTime !== 0) {
44
+ throw new Error("This FPS Monitor has already been run, please create a new instance");
45
+ }
46
+ this.startTime = Date.now();
47
+ this.timeWindow.startTime = Date.now();
48
+ this.measureLoop();
49
+ };
50
+ JSFPSMonitor.prototype.stopAndGetData = function () {
51
+ cancelAnimationFrame(this.clearAnimationNumber);
52
+ if (this.minFPS === Number.MAX_SAFE_INTEGER) {
53
+ this.minFPS = this.averageFPS;
54
+ this.maxFPS = this.averageFPS;
55
+ }
56
+ return {
57
+ minFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.minFPS, 1),
58
+ maxFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.maxFPS, 1),
59
+ averageFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.averageFPS, 1),
60
+ };
61
+ };
62
+ return JSFPSMonitor;
63
+ }());
64
+ exports.JSFPSMonitor = JSFPSMonitor;
65
+ //# sourceMappingURL=JSFPSMonitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JSFPSMonitor.js","sourceRoot":"","sources":["../../src/benchmark/JSFPSMonitor.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAE9D;;;GAGG;AACH;IAAA;QAAA,iBA6DC;QA5DS,cAAS,GAAG,CAAC,CAAC;QACd,eAAU,GAAG,CAAC,CAAC;QACf,eAAU,GAAG;YACnB,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;SACb,CAAC;QAEM,WAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjC,WAAM,GAAG,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K,CAAC,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;SACH;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEM,qCAAc,GAArB;QACE,oBAAoB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,gBAAgB,EAAE;YAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;SAC/B;QACD,OAAO;YACL,MAAM,EAAE,IAAA,2CAAoB,EAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5C,MAAM,EAAE,IAAA,2CAAoB,EAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5C,UAAU,EAAE,IAAA,2CAAoB,EAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;SACrD,CAAC;IACJ,CAAC;IACH,mBAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,oCAAY"}
@@ -0,0 +1,2 @@
1
+ export declare function roundToDecimalPlaces(value: number, decimalPlaces: number): number;
2
+ //# sourceMappingURL=roundToDecimalPlaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roundToDecimalPlaces.d.ts","sourceRoot":"","sources":["../../src/benchmark/roundToDecimalPlaces.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAGxE"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.roundToDecimalPlaces = void 0;
4
+ function roundToDecimalPlaces(value, decimalPlaces) {
5
+ var multiplier = Math.pow(10, decimalPlaces);
6
+ return Math.round(value * multiplier) / multiplier;
7
+ }
8
+ exports.roundToDecimalPlaces = roundToDecimalPlaces;
9
+ //# sourceMappingURL=roundToDecimalPlaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roundToDecimalPlaces.js","sourceRoot":"","sources":["../../src/benchmark/roundToDecimalPlaces.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAAC,KAAa,EAAE,aAAqB;IACvE,IAAM,UAAU,GAAG,SAAA,EAAE,EAAI,aAAa,CAAA,CAAC;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;AACrD,CAAC;AAHD,oDAGC"}
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import FlashList from "../FlashList";
3
+ import { JSFPSResult } from "./JSFPSMonitor";
4
+ import { BlankAreaTrackerResult } from "./useBlankAreaTracker";
5
+ export interface BenchmarkParams {
6
+ startDelayInMs?: number;
7
+ /**
8
+ * Can be used to increase or decrease speed of scrolling
9
+ */
10
+ speedMultiplier?: number;
11
+ /**
12
+ * Specify the number of times benchmark should repeat itself
13
+ */
14
+ repeatCount?: number;
15
+ /**
16
+ * When set to true, cumulative blank area will include sum of negative blank area values
17
+ * Blank area is negative when list is able to draw faster than the scroll speed.
18
+ */
19
+ sumNegativeBlankAreaValues?: boolean;
20
+ }
21
+ export interface BenchmarkResult {
22
+ js?: JSFPSResult;
23
+ interrupted: boolean;
24
+ suggestions: string[];
25
+ blankArea?: BlankAreaTrackerResult;
26
+ formattedString?: string;
27
+ }
28
+ /**
29
+ * Runs the benchmark on FlashList.
30
+ * Response object has a formatted string that can be printed to the console or shown as an alert.
31
+ * Result is posted to the callback method passed to the hook.
32
+ */
33
+ export declare function useBenchmark(flashListRef: React.RefObject<FlashList<any>>, callback: (benchmarkResult: BenchmarkResult) => void, params?: BenchmarkParams): ((event: import("..").BlankAreaEvent) => void)[];
34
+ export declare function getFormattedString(res: BenchmarkResult): string;
35
+ //# sourceMappingURL=useBenchmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBenchmark.d.ts","sourceRoot":"","sources":["../../src/benchmark/useBenchmark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EAAgB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EACL,sBAAsB,EAEvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AAEH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAC7C,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,EACpD,MAAM,GAAE,eAAoB,oDAkD7B;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,UAiBtD"}
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFormattedString = exports.useBenchmark = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var AutoScrollHelper_1 = require("./AutoScrollHelper");
7
+ var JSFPSMonitor_1 = require("./JSFPSMonitor");
8
+ var roundToDecimalPlaces_1 = require("./roundToDecimalPlaces");
9
+ var useBlankAreaTracker_1 = require("./useBlankAreaTracker");
10
+ /**
11
+ * Runs the benchmark on FlashList.
12
+ * Response object has a formatted string that can be printed to the console or shown as an alert.
13
+ * Result is posted to the callback method passed to the hook.
14
+ */
15
+ function useBenchmark(flashListRef, callback, params) {
16
+ var _this = this;
17
+ if (params === void 0) { params = {}; }
18
+ var _a = tslib_1.__read((0, useBlankAreaTracker_1.useBlankAreaTracker)(flashListRef, undefined, { sumNegativeValues: params.sumNegativeBlankAreaValues, startDelayInMs: 0 }), 2), blankAreaResult = _a[0], blankAreaTracker = _a[1];
19
+ (0, react_1.useEffect)(function () {
20
+ var _a;
21
+ var cancellable = new AutoScrollHelper_1.Cancellable();
22
+ var suggestions = [];
23
+ if (flashListRef.current) {
24
+ if (!(Number((_a = flashListRef.current.props.data) === null || _a === void 0 ? void 0 : _a.length) > 0)) {
25
+ throw new Error("Data is empty, cannot run benchmark");
26
+ }
27
+ }
28
+ var cancelTimeout = setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
29
+ var jsFPSMonitor, i, jsProfilerResponse, result;
30
+ return tslib_1.__generator(this, function (_a) {
31
+ switch (_a.label) {
32
+ case 0:
33
+ jsFPSMonitor = new JSFPSMonitor_1.JSFPSMonitor();
34
+ jsFPSMonitor.startTracking();
35
+ i = 0;
36
+ _a.label = 1;
37
+ case 1:
38
+ if (!(i < (params.repeatCount || 1))) return [3 /*break*/, 4];
39
+ return [4 /*yield*/, runScrollBenchmark(flashListRef, cancellable, params.speedMultiplier || 1)];
40
+ case 2:
41
+ _a.sent();
42
+ _a.label = 3;
43
+ case 3:
44
+ i++;
45
+ return [3 /*break*/, 1];
46
+ case 4:
47
+ jsProfilerResponse = jsFPSMonitor.stopAndGetData();
48
+ if (jsProfilerResponse.averageFPS < 35) {
49
+ suggestions.push("Your average JS FPS is low. This can indicate that your components are doing too much work. Try to optimize your components and reduce re-renders if any");
50
+ }
51
+ computeSuggestions(flashListRef, suggestions);
52
+ result = generateResult(jsProfilerResponse, blankAreaResult, suggestions, cancellable);
53
+ if (!cancellable.isCancelled()) {
54
+ result.formattedString = getFormattedString(result);
55
+ }
56
+ callback(result);
57
+ return [2 /*return*/];
58
+ }
59
+ });
60
+ }); }, params.startDelayInMs || 3000);
61
+ return function () {
62
+ clearTimeout(cancelTimeout);
63
+ cancellable.cancel();
64
+ };
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, []);
67
+ return [blankAreaTracker];
68
+ }
69
+ exports.useBenchmark = useBenchmark;
70
+ function getFormattedString(res) {
71
+ var _a, _b, _c, _d, _e;
72
+ return ("Results:\n\n" +
73
+ "JS FPS: Avg: ".concat((_a = res.js) === null || _a === void 0 ? void 0 : _a.averageFPS, " | Min: ").concat((_b = res.js) === null || _b === void 0 ? void 0 : _b.minFPS, " | Max: ").concat((_c = res.js) === null || _c === void 0 ? void 0 : _c.maxFPS, "\n\n") +
74
+ "".concat(res.blankArea
75
+ ? "Blank Area: Max: ".concat((_d = res.blankArea) === null || _d === void 0 ? void 0 : _d.maxBlankArea, " Cumulative: ").concat((_e = res.blankArea) === null || _e === void 0 ? void 0 : _e.cumulativeBlankArea, "\n\n")
76
+ : "") +
77
+ "".concat(res.suggestions.length > 0
78
+ ? "Suggestions:\n\n".concat(res.suggestions
79
+ .map(function (value, index) { return "".concat(index + 1, ". ").concat(value); })
80
+ .join("\n"))
81
+ : ""));
82
+ }
83
+ exports.getFormattedString = getFormattedString;
84
+ function generateResult(jsProfilerResponse, blankAreaResult, suggestions, cancellable) {
85
+ return {
86
+ js: jsProfilerResponse,
87
+ blankArea: blankAreaResult.maxBlankArea >= 0
88
+ ? {
89
+ maxBlankArea: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(blankAreaResult.maxBlankArea, 0),
90
+ cumulativeBlankArea: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(blankAreaResult.cumulativeBlankArea, 0),
91
+ }
92
+ : undefined,
93
+ suggestions: suggestions,
94
+ interrupted: cancellable.isCancelled(),
95
+ };
96
+ }
97
+ /**
98
+ * Scrolls to the end of the list and then back to the top
99
+ */
100
+ function runScrollBenchmark(flashListRef, cancellable, scrollSpeedMultiplier) {
101
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
102
+ var horizontal_1, rlv, rlvSize, rlvContentSize, fromX, fromY, toX, toY, scrollNow;
103
+ return tslib_1.__generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0:
106
+ if (!flashListRef.current) return [3 /*break*/, 3];
107
+ horizontal_1 = flashListRef.current.props.horizontal;
108
+ rlv = flashListRef.current.recyclerlistview_unsafe;
109
+ if (!rlv) return [3 /*break*/, 3];
110
+ rlvSize = rlv.getRenderedSize();
111
+ rlvContentSize = rlv.getContentDimension();
112
+ fromX = 0;
113
+ fromY = 0;
114
+ toX = rlvContentSize.width - rlvSize.width;
115
+ toY = rlvContentSize.height - rlvSize.height;
116
+ scrollNow = function (x, y) {
117
+ var _a;
118
+ (_a = flashListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({
119
+ offset: horizontal_1 ? x : y,
120
+ animated: false,
121
+ });
122
+ };
123
+ return [4 /*yield*/, (0, AutoScrollHelper_1.autoScroll)(scrollNow, fromX, fromY, toX, toY, scrollSpeedMultiplier, cancellable)];
124
+ case 1:
125
+ _a.sent();
126
+ return [4 /*yield*/, (0, AutoScrollHelper_1.autoScroll)(scrollNow, toX, toY, fromX, fromY, scrollSpeedMultiplier, cancellable)];
127
+ case 2:
128
+ _a.sent();
129
+ _a.label = 3;
130
+ case 3: return [2 /*return*/];
131
+ }
132
+ });
133
+ });
134
+ }
135
+ function computeSuggestions(flashListRef, suggestions) {
136
+ var _a;
137
+ if (flashListRef.current) {
138
+ if (flashListRef.current.props.data.length < 200) {
139
+ suggestions.push("Data count is low. Try to increase it to a large number (e.g 200) using the 'useDataMultiplier' hook.");
140
+ }
141
+ var distanceFromWindow = (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(flashListRef.current.firstItemOffset, 0);
142
+ if ((flashListRef.current.props.estimatedFirstItemOffset || 0) !==
143
+ distanceFromWindow) {
144
+ suggestions.push("estimatedFirstItemOffset can be set to ".concat(distanceFromWindow));
145
+ }
146
+ var rlv_1 = flashListRef.current.recyclerlistview_unsafe;
147
+ var horizontal_2 = flashListRef.current.props.horizontal;
148
+ if (rlv_1) {
149
+ var sizeArray = rlv_1.props.dataProvider
150
+ .getAllData()
151
+ .map(function (_, index) {
152
+ var _a, _b, _c, _d;
153
+ return horizontal_2
154
+ ? ((_b = (_a = rlv_1.getLayout) === null || _a === void 0 ? void 0 : _a.call(rlv_1, index)) === null || _b === void 0 ? void 0 : _b.width) || 0
155
+ : ((_d = (_c = rlv_1.getLayout) === null || _c === void 0 ? void 0 : _c.call(rlv_1, index)) === null || _d === void 0 ? void 0 : _d.height) || 0;
156
+ });
157
+ var averageSize = Math.round(sizeArray.reduce(function (prev, current) { return prev + current; }, 0) /
158
+ sizeArray.length);
159
+ if (Math.abs(averageSize -
160
+ ((_a = flashListRef.current.props.estimatedItemSize) !== null && _a !== void 0 ? _a : flashListRef.current.state.layoutProvider
161
+ .defaultEstimatedItemSize)) > 5) {
162
+ suggestions.push("estimatedItemSize can be set to ".concat(averageSize));
163
+ }
164
+ }
165
+ }
166
+ }
167
+ //# sourceMappingURL=useBenchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBenchmark.js","sourceRoot":"","sources":["../../src/benchmark/useBenchmark.ts"],"names":[],"mappings":";;;;AAAA,+BAAyC;AAIzC,uDAA6D;AAC7D,+CAA2D;AAC3D,+DAA8D;AAC9D,6DAG+B;AA8B/B;;;;GAIG;AAEH,SAAgB,YAAY,CAC1B,YAA6C,EAC7C,QAAoD,EACpD,MAA4B;IAH9B,iBAqDC;IAlDC,uBAAA,EAAA,WAA4B;IAEtB,IAAA,KAAA,eAAsC,IAAA,yCAAmB,EAC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K,OAAA,IAAI,GAAG,OAAO,EAAd,CAAc,EAAE,CAAC,CAAC;gBACpD,SAAS,CAAC,MAAM,CACnB,CAAC;YACF,IACE,IAAI,CAAC,GAAG,CACN,WAAW;gBACT,CAAC,MAAA,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,mCAC3C,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc;qBACtC,wBAAwB,CAAC,CACjC,GAAG,CAAC,EACL;gBACA,WAAW,CAAC,IAAI,CAAC,0CAAmC,WAAW,CAAE,CAAC,CAAC;aACpE;SACF;KACF;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { BlankAreaEvent } from "../native/auto-layout/AutoLayoutView";
3
+ import FlashList from "../FlashList";
4
+ export interface BlankAreaTrackerResult {
5
+ /**
6
+ * Max blank area displayed
7
+ */
8
+ maxBlankArea: number;
9
+ /**
10
+ * Sum of all blank area values across all frames
11
+ */
12
+ cumulativeBlankArea: number;
13
+ }
14
+ export interface BlankAreaTrackerConfig {
15
+ /**
16
+ * When set to true the hook will also sum all negative blank area values.
17
+ * Blank area is negative when list is able to draw faster than the scroll speed.
18
+ */
19
+ sumNegativeValues?: boolean;
20
+ /**
21
+ * By default, the hook ignores blank events for 1s after the list load. This value can be changed using this parameter.
22
+ * Please note that this duration kicks in after the list has loaded and not after the first scroll.
23
+ */
24
+ startDelayInMs?: number;
25
+ }
26
+ /**
27
+ * Can be used to track visible blank area in production
28
+ * @param flashListRef Ref to the FlashList component
29
+ * @param onBlankAreaChange This event handler will be called when the blank area changes
30
+ * @param config additional configuration for the blank area tracker
31
+ * @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
32
+ */
33
+ export declare function useBlankAreaTracker(flashListRef: React.RefObject<FlashList<any> | null>, onBlankAreaChange?: (value: BlankAreaTrackerResult) => void, config?: BlankAreaTrackerConfig): [BlankAreaTrackerResult, (event: BlankAreaEvent) => void];
34
+ //# sourceMappingURL=useBlankAreaTracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBlankAreaTracker.d.ts","sourceRoot":"","sources":["../../src/benchmark/useBlankAreaTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AACD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EACpD,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,EAC3D,MAAM,CAAC,EAAE,sBAAsB,GAC9B,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC,CAwC3D"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBlankAreaTracker = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * Can be used to track visible blank area in production
7
+ * @param flashListRef Ref to the FlashList component
8
+ * @param onBlankAreaChange This event handler will be called when the blank area changes
9
+ * @param config additional configuration for the blank area tracker
10
+ * @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
11
+ */
12
+ function useBlankAreaTracker(flashListRef, onBlankAreaChange, config) {
13
+ var _a;
14
+ var startDelay = (_a = config === null || config === void 0 ? void 0 : config.startDelayInMs) !== null && _a !== void 0 ? _a : 1000;
15
+ var blankAreaResult = (0, react_1.useRef)({
16
+ maxBlankArea: 0,
17
+ cumulativeBlankArea: 0,
18
+ }).current;
19
+ var waitOperations = (0, react_1.useRef)({ inProgress: false, complete: false }).current;
20
+ var onBlankAreaChangeRef = (0, react_1.useRef)(onBlankAreaChange);
21
+ onBlankAreaChangeRef.current = onBlankAreaChange;
22
+ var blankAreaTracker = (0, react_1.useCallback)(function (event) {
23
+ var _a, _b;
24
+ // we're ignoring some of the events that will be fired on list load
25
+ // initial events are fired on mount and thus, this won't lead to missing events during scroll
26
+ if (!waitOperations.complete && startDelay > 0) {
27
+ if (!waitOperations.inProgress) {
28
+ waitOperations.inProgress = true;
29
+ setTimeout(function () {
30
+ waitOperations.complete = true;
31
+ }, startDelay);
32
+ }
33
+ return;
34
+ }
35
+ var rlv = (_a = flashListRef.current) === null || _a === void 0 ? void 0 : _a.recyclerlistview_unsafe;
36
+ var horizontal = Boolean((_b = flashListRef.current) === null || _b === void 0 ? void 0 : _b.props.horizontal);
37
+ if (rlv) {
38
+ processBlankAreaChange(rlv, horizontal, blankAreaResult, event, onBlankAreaChangeRef.current, config);
39
+ }
40
+ },
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ [flashListRef]);
43
+ return [blankAreaResult, blankAreaTracker];
44
+ }
45
+ exports.useBlankAreaTracker = useBlankAreaTracker;
46
+ function processBlankAreaChange(rlv, horizontal, blankAreaResult, event, onBlankAreaChange, config) {
47
+ var listSize = horizontal
48
+ ? rlv.getRenderedSize().width
49
+ : rlv.getRenderedSize().height;
50
+ var contentSize = horizontal
51
+ ? rlv.getContentDimension().width
52
+ : rlv.getContentDimension().height;
53
+ // ignores blank events when there isn't enough content to fill the list
54
+ if (contentSize > listSize) {
55
+ var lastMaxBlankArea = blankAreaResult.maxBlankArea;
56
+ var lastCumulativeBlankArea = blankAreaResult.cumulativeBlankArea;
57
+ blankAreaResult.maxBlankArea = Math.max(blankAreaResult.maxBlankArea, event.blankArea, 0);
58
+ blankAreaResult.cumulativeBlankArea += (config === null || config === void 0 ? void 0 : config.sumNegativeValues)
59
+ ? event.blankArea
60
+ : Math.max(event.blankArea, 0);
61
+ if (lastCumulativeBlankArea !== blankAreaResult.cumulativeBlankArea ||
62
+ lastMaxBlankArea !== blankAreaResult.maxBlankArea) {
63
+ onBlankAreaChange === null || onBlankAreaChange === void 0 ? void 0 : onBlankAreaChange(blankAreaResult);
64
+ }
65
+ }
66
+ }
67
+ //# sourceMappingURL=useBlankAreaTracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBlankAreaTracker.js","sourceRoot":"","sources":["../../src/benchmark/useBlankAreaTracker.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AA6BnD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,YAAoD,EACpD,iBAA2D,EAC3D,MAA+B;;IAE/B,IAAM,UAAU,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,mCAAI,IAAI,CAAC;IAClD,IAAM,eAAe,GAAG,IAAA,cAAM,EAAC;QAC7B,YAAY,EAAE,CAAC;QACf,mBAAmB,EAAE,CAAC;KACvB,CAAC,CAAC,OAAO,CAAC;IACX,IAAM,cAAc,GAAG,IAAA,cAAM,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;IAC9E,IAAM,oBAAoB,GAAG,IAAA,cAAM,EAAC,iBAAiB,CAAC,CAAC;IACvD,oBAAoB,CAAC,OAAO,GAAG,iBAAiB,CAAC;IAEjD,IAAM,gBAAgB,GAAG,IAAA,mBAAW,EAClC,UAAC,KAAqB;;QACpB,oEAAoE;QACpE,8FAA8F;QAC9F,IAAI,CAAC,cAAc,CAAC,QAAQ,IAAI,UAAU,GAAG,CAAC,EAAE;YAC9C,IAAI,CAAC,cAAc,CAAC,U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e,CAAC,YAAY,EAC5B,KAAK,CAAC,SAAS,EACf,CAAC,CACF,CAAC;QACF,eAAe,CAAC,mBAAmB,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,iBAAiB;YAC9D,CAAC,CAAC,KAAK,CAAC,SAAS;YACjB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACjC,IACE,uBAAuB,KAAK,eAAe,CAAC,mBAAmB;YAC/D,gBAAgB,KAAK,eAAe,CAAC,YAAY,EACjD;YACA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,eAAe,CAAC,CAAC;SACtC;KACF;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Increases the data size by duplicating it, it's kept in hook format so that in future we can add auto pagination support.
3
+ * If you're using this with FlatList then make sure you remove `keyExtractor` because this method might duplicate ids that might be in the data.
4
+ * @param data The data to duplicate
5
+ * @param count Final count of data to be returned from this hook
6
+ * @returns Multiplied data.
7
+ */
8
+ export declare function useDataMultiplier<T>(data: T[], count: number): [T[]];
9
+ //# sourceMappingURL=useDataMultiplier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataMultiplier.d.ts","sourceRoot":"","sources":["../../src/benchmark/useDataMultiplier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAWpE"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDataMultiplier = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /**
6
+ * Increases the data size by duplicating it, it's kept in hook format so that in future we can add auto pagination support.
7
+ * If you're using this with FlatList then make sure you remove `keyExtractor` because this method might duplicate ids that might be in the data.
8
+ * @param data The data to duplicate
9
+ * @param count Final count of data to be returned from this hook
10
+ * @returns Multiplied data.
11
+ */
12
+ function useDataMultiplier(data, count) {
13
+ var len = data.length;
14
+ var arr = new Array(count);
15
+ var isObject = false;
16
+ if (typeof data[0] === "object") {
17
+ isObject = true;
18
+ }
19
+ for (var i = 0; i < count; i++) {
20
+ arr[i] = isObject ? tslib_1.__assign({}, data[i % len]) : data[i % len];
21
+ }
22
+ return [arr];
23
+ }
24
+ exports.useDataMultiplier = useDataMultiplier;
25
+ //# sourceMappingURL=useDataMultiplier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataMultiplier.js","sourceRoot":"","sources":["../../src/benchmark/useDataMultiplier.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAI,IAAS,EAAE,KAAa;IAC3D,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,IAAM,GAAG,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,CAAC;IAChC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QAC/B,QAAQ,GAAG,IAAI,CAAC;KACjB;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,sBAAM,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,EAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;KAC1D;IACD,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAXD,8CAWC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { FlatList } from "react-native";
3
+ import { BenchmarkParams, BenchmarkResult } from "./useBenchmark";
4
+ export interface FlatListBenchmarkParams extends BenchmarkParams {
5
+ targetOffset: number;
6
+ }
7
+ /**
8
+ * Runs the benchmark on FlatList and calls the callback method with the result.
9
+ * Target offset is mandatory in params.
10
+ * It's recommended to remove pagination while running the benchmark. Removing the onEndReached callback is the easiest way to do that.
11
+ */
12
+ export declare function useFlatListBenchmark(flatListRef: React.RefObject<FlatList<any>>, callback: (benchmarkResult: BenchmarkResult) => void, params: FlatListBenchmarkParams): never[];
13
+ //# sourceMappingURL=useFlatListBenchmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFlatListBenchmark.d.ts","sourceRoot":"","sources":["../../src/benchmark/useFlatListBenchmark.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,OAAO,EACL,eAAe,EACf,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAC3C,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,EACpD,MAAM,EAAE,uBAAuB,WAsChC"}