@shopify/flash-list 2.0.0-alpha.21 → 2.0.0-alpha.22

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 (283) hide show
  1. package/dist/AnimatedFlashList.js +2 -2
  2. package/dist/AnimatedFlashList.js.map +1 -1
  3. package/dist/FlashList.d.ts +1 -167
  4. package/dist/FlashList.d.ts.map +1 -1
  5. package/dist/FlashList.js +3 -595
  6. package/dist/FlashList.js.map +1 -1
  7. package/dist/FlashListProps.d.ts +2 -63
  8. package/dist/FlashListProps.d.ts.map +1 -1
  9. package/dist/FlashListProps.js.map +1 -1
  10. package/dist/__tests__/ViewabilityHelper.test.js +3 -4
  11. package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
  12. package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
  13. package/dist/benchmark/JSFPSMonitor.js +2 -1
  14. package/dist/benchmark/JSFPSMonitor.js.map +1 -1
  15. package/dist/benchmark/useBenchmark.d.ts +2 -4
  16. package/dist/benchmark/useBenchmark.d.ts.map +1 -1
  17. package/dist/benchmark/useBenchmark.js +12 -24
  18. package/dist/benchmark/useBenchmark.js.map +1 -1
  19. package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
  20. package/dist/benchmark/useFlatListBenchmark.js +2 -1
  21. package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
  22. package/dist/errors/ErrorMessages.d.ts +16 -0
  23. package/dist/errors/ErrorMessages.d.ts.map +1 -0
  24. package/dist/errors/ErrorMessages.js +19 -0
  25. package/dist/errors/ErrorMessages.js.map +1 -0
  26. package/dist/errors/WarningMessages.d.ts +4 -0
  27. package/dist/errors/WarningMessages.d.ts.map +1 -0
  28. package/dist/errors/WarningMessages.js +7 -0
  29. package/dist/errors/WarningMessages.js.map +1 -0
  30. package/dist/index.d.ts +3 -9
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +7 -29
  33. package/dist/index.js.map +1 -1
  34. package/dist/isNewArch.d.ts +2 -0
  35. package/dist/isNewArch.d.ts.map +1 -0
  36. package/dist/isNewArch.js +25 -0
  37. package/dist/isNewArch.js.map +1 -0
  38. package/dist/native/config/PlatformHelper.android.d.ts +1 -22
  39. package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
  40. package/dist/native/config/PlatformHelper.android.js +1 -16
  41. package/dist/native/config/PlatformHelper.android.js.map +1 -1
  42. package/dist/native/config/PlatformHelper.d.ts +1 -22
  43. package/dist/native/config/PlatformHelper.d.ts.map +1 -1
  44. package/dist/native/config/PlatformHelper.ios.d.ts +1 -22
  45. package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
  46. package/dist/native/config/PlatformHelper.ios.js +1 -15
  47. package/dist/native/config/PlatformHelper.ios.js.map +1 -1
  48. package/dist/native/config/PlatformHelper.js +1 -16
  49. package/dist/native/config/PlatformHelper.js.map +1 -1
  50. package/dist/native/config/PlatformHelper.web.d.ts +1 -23
  51. package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
  52. package/dist/native/config/PlatformHelper.web.js +1 -18
  53. package/dist/native/config/PlatformHelper.web.js.map +1 -1
  54. package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
  55. package/dist/recyclerview/RecyclerView.js +5 -0
  56. package/dist/recyclerview/RecyclerView.js.map +1 -1
  57. package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
  58. package/dist/recyclerview/RecyclerViewManager.js +9 -8
  59. package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
  60. package/dist/recyclerview/RecyclerViewProps.d.ts +1 -8
  61. package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
  62. package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
  63. package/dist/recyclerview/hooks/useRecyclerViewController.js +4 -0
  64. package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
  65. package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
  66. package/dist/recyclerview/layout-managers/LayoutManager.js +2 -1
  67. package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
  68. package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
  69. package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
  70. package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.d.ts +2 -2
  71. package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
  72. package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js +2 -4
  73. package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js.map +1 -1
  74. package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.d.ts +3 -3
  75. package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
  76. package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.js +16 -16
  77. package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +3 -14
  80. package/src/AnimatedFlashList.ts +2 -2
  81. package/src/FlashList.ts +1 -0
  82. package/src/FlashListProps.ts +3 -79
  83. package/src/__tests__/ViewabilityHelper.test.ts +13 -14
  84. package/src/benchmark/JSFPSMonitor.ts +3 -3
  85. package/src/benchmark/useBenchmark.ts +12 -40
  86. package/src/benchmark/useFlatListBenchmark.ts +3 -1
  87. package/src/errors/ErrorMessages.ts +26 -0
  88. package/src/errors/WarningMessages.ts +4 -0
  89. package/src/index.ts +7 -43
  90. package/src/isNewArch.ts +25 -0
  91. package/src/native/config/PlatformHelper.android.ts +1 -25
  92. package/src/native/config/PlatformHelper.ios.ts +1 -24
  93. package/src/native/config/PlatformHelper.ts +1 -25
  94. package/src/native/config/PlatformHelper.web.ts +1 -30
  95. package/src/recyclerview/RecyclerView.tsx +5 -0
  96. package/src/recyclerview/RecyclerViewManager.ts +9 -18
  97. package/src/recyclerview/RecyclerViewProps.ts +1 -11
  98. package/src/recyclerview/hooks/useRecyclerViewController.tsx +4 -0
  99. package/src/recyclerview/layout-managers/LayoutManager.ts +2 -1
  100. package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -9
  101. package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +18 -20
  102. package/RNFlashList.podspec +0 -37
  103. package/android/build.gradle +0 -89
  104. package/android/src/main/AndroidManifest.xml +0 -3
  105. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +0 -105
  106. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +0 -158
  107. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutViewManager.kt +0 -70
  108. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +0 -29
  109. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainer.java +0 -16
  110. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerImpl.kt +0 -16
  111. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerManager.kt +0 -34
  112. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/FlashListPackage.kt +0 -19
  113. package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java +0 -47
  114. package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java +0 -21
  115. package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java +0 -32
  116. package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java +0 -16
  117. package/android/src/test/java/com/shopify/reactnative/flash_list/AutoLayoutShadowTest.kt +0 -147
  118. package/android/src/test/java/com/shopify/reactnative/flash_list/models/Rect.kt +0 -61
  119. package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestCollection.kt +0 -6
  120. package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestDataModel.kt +0 -8
  121. package/android/src/test/resources/LayoutTestData.json +0 -788
  122. package/dist/GridLayoutProviderWithProps.d.ts +0 -42
  123. package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
  124. package/dist/GridLayoutProviderWithProps.js +0 -114
  125. package/dist/GridLayoutProviderWithProps.js.map +0 -1
  126. package/dist/MasonryFlashList.d.ts +0 -51
  127. package/dist/MasonryFlashList.d.ts.map +0 -1
  128. package/dist/MasonryFlashList.js +0 -252
  129. package/dist/MasonryFlashList.js.map +0 -1
  130. package/dist/PureComponentWrapper.d.ts +0 -22
  131. package/dist/PureComponentWrapper.d.ts.map +0 -1
  132. package/dist/PureComponentWrapper.js +0 -37
  133. package/dist/PureComponentWrapper.js.map +0 -1
  134. package/dist/__tests__/ContentContainerUtils.test.d.ts +0 -2
  135. package/dist/__tests__/ContentContainerUtils.test.d.ts.map +0 -1
  136. package/dist/__tests__/ContentContainerUtils.test.js +0 -85
  137. package/dist/__tests__/ContentContainerUtils.test.js.map +0 -1
  138. package/dist/__tests__/FlashList.test.d.ts +0 -2
  139. package/dist/__tests__/FlashList.test.d.ts.map +0 -1
  140. package/dist/__tests__/FlashList.test.js +0 -902
  141. package/dist/__tests__/FlashList.test.js.map +0 -1
  142. package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +0 -2
  143. package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +0 -1
  144. package/dist/__tests__/GridLayoutProviderWithProps.test.js +0 -143
  145. package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +0 -1
  146. package/dist/__tests__/MasonryFlashList.test.d.ts +0 -2
  147. package/dist/__tests__/MasonryFlashList.test.d.ts.map +0 -1
  148. package/dist/__tests__/MasonryFlashList.test.js +0 -254
  149. package/dist/__tests__/MasonryFlashList.test.js.map +0 -1
  150. package/dist/__tests__/PlatformHelper.web.test.d.ts +0 -2
  151. package/dist/__tests__/PlatformHelper.web.test.d.ts.map +0 -1
  152. package/dist/__tests__/PlatformHelper.web.test.js +0 -33
  153. package/dist/__tests__/PlatformHelper.web.test.js.map +0 -1
  154. package/dist/__tests__/helpers/mountFlashList.d.ts +0 -19
  155. package/dist/__tests__/helpers/mountFlashList.d.ts.map +0 -1
  156. package/dist/__tests__/helpers/mountFlashList.js +0 -44
  157. package/dist/__tests__/helpers/mountFlashList.js.map +0 -1
  158. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +0 -18
  159. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +0 -1
  160. package/dist/__tests__/helpers/mountMasonryFlashList.js +0 -49
  161. package/dist/__tests__/helpers/mountMasonryFlashList.js.map +0 -1
  162. package/dist/__tests__/useBlankAreaTracker.test.d.ts +0 -2
  163. package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +0 -1
  164. package/dist/__tests__/useBlankAreaTracker.test.js +0 -179
  165. package/dist/__tests__/useBlankAreaTracker.test.js.map +0 -1
  166. package/dist/benchmark/useBlankAreaTracker.d.ts +0 -34
  167. package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
  168. package/dist/benchmark/useBlankAreaTracker.js +0 -66
  169. package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
  170. package/dist/enableNewCore.d.ts +0 -3
  171. package/dist/enableNewCore.d.ts.map +0 -1
  172. package/dist/enableNewCore.js +0 -25
  173. package/dist/enableNewCore.js.map +0 -1
  174. package/dist/errors/CustomError.d.ts +0 -8
  175. package/dist/errors/CustomError.d.ts.map +0 -1
  176. package/dist/errors/CustomError.js +0 -14
  177. package/dist/errors/CustomError.js.map +0 -1
  178. package/dist/errors/ExceptionList.d.ts +0 -24
  179. package/dist/errors/ExceptionList.d.ts.map +0 -1
  180. package/dist/errors/ExceptionList.js +0 -26
  181. package/dist/errors/ExceptionList.js.map +0 -1
  182. package/dist/errors/Warnings.d.ts +0 -9
  183. package/dist/errors/Warnings.d.ts.map +0 -1
  184. package/dist/errors/Warnings.js +0 -13
  185. package/dist/errors/Warnings.js.map +0 -1
  186. package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -22
  187. package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
  188. package/dist/native/auto-layout/AutoLayoutView.js +0 -48
  189. package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
  190. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -4
  191. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
  192. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -6
  193. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
  194. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -5
  195. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
  196. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -4
  197. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
  198. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -6
  199. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
  200. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -6
  201. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
  202. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -16
  203. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
  204. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -3
  205. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
  206. package/dist/native/cell-container/CellContainer.android.d.ts +0 -6
  207. package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
  208. package/dist/native/cell-container/CellContainer.android.js +0 -9
  209. package/dist/native/cell-container/CellContainer.android.js.map +0 -1
  210. package/dist/native/cell-container/CellContainer.d.ts +0 -8
  211. package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
  212. package/dist/native/cell-container/CellContainer.ios.d.ts +0 -6
  213. package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
  214. package/dist/native/cell-container/CellContainer.ios.js +0 -9
  215. package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
  216. package/dist/native/cell-container/CellContainer.js +0 -11
  217. package/dist/native/cell-container/CellContainer.js.map +0 -1
  218. package/dist/native/cell-container/CellContainer.web.d.ts +0 -7
  219. package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
  220. package/dist/native/cell-container/CellContainer.web.js +0 -13
  221. package/dist/native/cell-container/CellContainer.web.js.map +0 -1
  222. package/dist/specs/AutoLayoutNativeComponent.d.ts +0 -18
  223. package/dist/specs/AutoLayoutNativeComponent.d.ts.map +0 -1
  224. package/dist/specs/AutoLayoutNativeComponent.js +0 -6
  225. package/dist/specs/AutoLayoutNativeComponent.js.map +0 -1
  226. package/dist/specs/CellContainerNativeComponent.d.ts +0 -8
  227. package/dist/specs/CellContainerNativeComponent.d.ts.map +0 -1
  228. package/dist/specs/CellContainerNativeComponent.js +0 -6
  229. package/dist/specs/CellContainerNativeComponent.js.map +0 -1
  230. package/dist/utils/ContentContainerUtils.d.ts +0 -27
  231. package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
  232. package/dist/utils/ContentContainerUtils.js +0 -48
  233. package/dist/utils/ContentContainerUtils.js.map +0 -1
  234. package/dist/viewability/ViewToken.d.ts.map +0 -1
  235. package/dist/viewability/ViewToken.js.map +0 -1
  236. package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
  237. package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
  238. package/dist/viewability/ViewabilityManager.js.map +0 -1
  239. package/ios/RNFlashList.xcodeproj/project.pbxproj +0 -3
  240. package/ios/RNFlashList.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  241. package/ios/Sources/AutoLayoutView.swift +0 -294
  242. package/ios/Sources/AutoLayoutViewComponentView.h +0 -16
  243. package/ios/Sources/AutoLayoutViewComponentView.mm +0 -90
  244. package/ios/Sources/AutoLayoutViewManager.mm +0 -14
  245. package/ios/Sources/AutoLayoutViewManager.swift +0 -12
  246. package/ios/Sources/CellContainerComponentView.h +0 -18
  247. package/ios/Sources/CellContainerComponentView.mm +0 -62
  248. package/ios/Sources/CellContainerManager.mm +0 -8
  249. package/ios/Sources/CellContainerManager.swift +0 -12
  250. package/ios/Sources/FlatListPro-Bridging-Header.h +0 -11
  251. package/ios/Tests/AutoLayoutViewTests.swift +0 -113
  252. package/src/FlashList.tsx +0 -953
  253. package/src/GridLayoutProviderWithProps.ts +0 -180
  254. package/src/MasonryFlashList.tsx +0 -476
  255. package/src/PureComponentWrapper.tsx +0 -42
  256. package/src/__tests__/ContentContainerUtils.test.ts +0 -130
  257. package/src/__tests__/FlashList.test.tsx +0 -1001
  258. package/src/__tests__/GridLayoutProviderWithProps.test.ts +0 -179
  259. package/src/__tests__/MasonryFlashList.test.ts +0 -292
  260. package/src/__tests__/PlatformHelper.web.test.ts +0 -45
  261. package/src/__tests__/helpers/mountFlashList.tsx +0 -62
  262. package/src/__tests__/helpers/mountMasonryFlashList.tsx +0 -70
  263. package/src/__tests__/useBlankAreaTracker.test.tsx +0 -206
  264. package/src/benchmark/useBlankAreaTracker.ts +0 -117
  265. package/src/enableNewCore.ts +0 -24
  266. package/src/errors/CustomError.ts +0 -10
  267. package/src/errors/ExceptionList.ts +0 -28
  268. package/src/errors/Warnings.ts +0 -15
  269. package/src/native/auto-layout/AutoLayoutView.tsx +0 -73
  270. package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -7
  271. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -7
  272. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -7
  273. package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -17
  274. package/src/native/cell-container/CellContainer.android.ts +0 -7
  275. package/src/native/cell-container/CellContainer.ios.ts +0 -7
  276. package/src/native/cell-container/CellContainer.tsx +0 -14
  277. package/src/native/cell-container/CellContainer.web.tsx +0 -9
  278. package/src/specs/AutoLayoutNativeComponent.ts +0 -24
  279. package/src/specs/CellContainerNativeComponent.ts +0 -9
  280. package/src/utils/ContentContainerUtils.ts +0 -92
  281. /package/dist/{viewability → recyclerview/viewability}/ViewToken.d.ts +0 -0
  282. /package/dist/{viewability → recyclerview/viewability}/ViewToken.js +0 -0
  283. /package/src/{viewability → recyclerview/viewability}/ViewToken.ts +0 -0
@@ -1,206 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { render } from "@quilted/react-testing";
3
-
4
- import {
5
- BlankAreaTrackerConfig,
6
- BlankAreaTrackerResult,
7
- useBlankAreaTracker,
8
- } from "../benchmark/useBlankAreaTracker";
9
- import FlashList from "../FlashList";
10
-
11
- import { MockFlashListProps, renderFlashList } from "./helpers/mountFlashList";
12
-
13
- type BlankTrackingFlashListProps = MockFlashListProps & {
14
- onCumulativeBlankAreaResult?: (result: BlankAreaTrackerResult) => void;
15
- onCumulativeBlankAreaChange?: (updatedResult: BlankAreaTrackerResult) => void;
16
- blankAreaTrackerConfig?: BlankAreaTrackerConfig;
17
- instance?: React.RefObject<FlashList<any>>;
18
- };
19
-
20
- const BlankTrackingFlashList = (props?: BlankTrackingFlashListProps) => {
21
- const ref = props?.instance!;
22
- const [blankAreaTrackerResult, onBlankArea] = useBlankAreaTracker(
23
- ref,
24
- props?.onCumulativeBlankAreaChange,
25
- {
26
- startDelayInMs: props?.blankAreaTrackerConfig?.startDelayInMs ?? 500,
27
- sumNegativeValues:
28
- props?.blankAreaTrackerConfig?.sumNegativeValues ?? false,
29
- }
30
- );
31
- useEffect(() => {
32
- return () => {
33
- props?.onCumulativeBlankAreaResult?.(blankAreaTrackerResult);
34
- };
35
- // eslint-disable-next-line react-hooks/exhaustive-deps
36
- }, []);
37
- return renderFlashList(
38
- { ...props, onBlankArea, estimatedItemSize: 400 },
39
- ref
40
- );
41
- };
42
-
43
- const mountBlankTrackingFlashList = (props?: BlankTrackingFlashListProps) => {
44
- const flashListRef: React.RefObject<FlashList<any>> = {
45
- current: null,
46
- };
47
- const blankTrackingFlashList = render(
48
- <BlankTrackingFlashList {...props} instance={flashListRef} />
49
- );
50
- return {
51
- root: blankTrackingFlashList,
52
- instance: flashListRef.current!,
53
- };
54
- };
55
-
56
- describe("useBlankAreaTracker Hook", () => {
57
- beforeEach(() => {
58
- jest.clearAllMocks();
59
- jest.useFakeTimers();
60
- });
61
-
62
- it("ignores blank events for 500ms on mount and if content is not enough to fill the list", () => {
63
- const onCumulativeBlankAreaChange = jest.fn();
64
- const flashList = mountBlankTrackingFlashList({
65
- onCumulativeBlankAreaChange,
66
- });
67
- flashList.instance.props.onBlankArea!({
68
- blankArea: 100,
69
- offsetEnd: 100,
70
- offsetStart: 0,
71
- });
72
- flashList.instance.props.onBlankArea!({
73
- blankArea: 100,
74
- offsetEnd: 100,
75
- offsetStart: 0,
76
- });
77
- jest.advanceTimersByTime(400);
78
- flashList.instance.props.onBlankArea!({
79
- blankArea: 100,
80
- offsetEnd: 100,
81
- offsetStart: 0,
82
- });
83
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(0);
84
- jest.advanceTimersByTime(100);
85
- flashList.instance.props.onBlankArea!({
86
- blankArea: 100,
87
- offsetEnd: 100,
88
- offsetStart: 0,
89
- });
90
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(1);
91
- onCumulativeBlankAreaChange.mockClear();
92
-
93
- flashList.root.setProps({ data: ["1"] });
94
- flashList.instance.props.onBlankArea!({
95
- blankArea: 100,
96
- offsetEnd: 100,
97
- offsetStart: 0,
98
- });
99
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(0);
100
- flashList.root.unmount();
101
- });
102
- it("keeps result object updated with correct values on unmount", () => {
103
- let resultObjectCopy: BlankAreaTrackerResult | undefined;
104
- const onCumulativeBlankAreaChange = jest.fn(
105
- (result: BlankAreaTrackerResult) => {
106
- if (!resultObjectCopy) {
107
- resultObjectCopy = result;
108
- }
109
- }
110
- );
111
- const onCumulativeBlankAreaResult = jest.fn();
112
- const flashList = mountBlankTrackingFlashList({
113
- onCumulativeBlankAreaResult,
114
- onCumulativeBlankAreaChange,
115
- blankAreaTrackerConfig: { startDelayInMs: 300 },
116
- });
117
- flashList.instance.props.onBlankArea!({
118
- blankArea: 100,
119
- offsetEnd: 100,
120
- offsetStart: 0,
121
- });
122
- jest.advanceTimersByTime(300);
123
- flashList.instance.props.onBlankArea!({
124
- blankArea: 100,
125
- offsetEnd: 100,
126
- offsetStart: 0,
127
- });
128
- expect(resultObjectCopy!.cumulativeBlankArea).toBe(100);
129
- expect(resultObjectCopy!.maxBlankArea).toBe(100);
130
-
131
- flashList.instance.props.onBlankArea!({
132
- blankArea: 200,
133
- offsetEnd: 200,
134
- offsetStart: 0,
135
- });
136
- flashList.instance.props.onBlankArea!({
137
- blankArea: -200,
138
- offsetEnd: -200,
139
- offsetStart: 0,
140
- });
141
- expect(resultObjectCopy!.cumulativeBlankArea).toBe(300);
142
- expect(resultObjectCopy!.maxBlankArea).toBe(200);
143
-
144
- flashList.root.unmount();
145
- expect(onCumulativeBlankAreaResult).toHaveBeenCalledWith(resultObjectCopy!);
146
- });
147
- it("can track negative values on demand", () => {
148
- const onCumulativeBlankAreaResult = jest.fn();
149
- const flashList = mountBlankTrackingFlashList({
150
- onCumulativeBlankAreaResult,
151
- blankAreaTrackerConfig: { sumNegativeValues: true },
152
- });
153
- flashList.instance.props.onBlankArea!({
154
- blankArea: -200,
155
- offsetEnd: -200,
156
- offsetStart: 0,
157
- });
158
- jest.advanceTimersByTime(500);
159
- flashList.instance.props.onBlankArea!({
160
- blankArea: -200,
161
- offsetEnd: -200,
162
- offsetStart: 0,
163
- });
164
- flashList.instance.props.onBlankArea!({
165
- blankArea: -200,
166
- offsetEnd: -200,
167
- offsetStart: 0,
168
- });
169
- flashList.root.unmount();
170
- expect(onCumulativeBlankAreaResult).toHaveBeenCalledWith({
171
- cumulativeBlankArea: -400,
172
- maxBlankArea: 0,
173
- });
174
- });
175
- it("only calls onCumulativeBlankAreaChange when values have a change", () => {
176
- const onCumulativeBlankAreaChange = jest.fn();
177
- const flashList = mountBlankTrackingFlashList({
178
- onCumulativeBlankAreaChange,
179
- });
180
- flashList.instance.props.onBlankArea!({
181
- blankArea: -200,
182
- offsetEnd: -200,
183
- offsetStart: 0,
184
- });
185
- jest.advanceTimersByTime(500);
186
- flashList.instance.props.onBlankArea!({
187
- blankArea: -200,
188
- offsetEnd: -200,
189
- offsetStart: 0,
190
- });
191
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(0);
192
- flashList.instance.props.onBlankArea!({
193
- blankArea: -100,
194
- offsetEnd: -100,
195
- offsetStart: 0,
196
- });
197
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(0);
198
- flashList.instance.props.onBlankArea!({
199
- blankArea: 100,
200
- offsetEnd: 100,
201
- offsetStart: 0,
202
- });
203
- expect(onCumulativeBlankAreaChange).toHaveBeenCalledTimes(1);
204
- flashList.root.unmount();
205
- });
206
- });
@@ -1,117 +0,0 @@
1
- import React, { useCallback, useRef } from "react";
2
- import { RecyclerListView, RecyclerListViewProps } from "recyclerlistview";
3
-
4
- import { BlankAreaEvent } from "../native/auto-layout/AutoLayoutView";
5
- import FlashList from "../FlashList";
6
-
7
- export interface BlankAreaTrackerResult {
8
- /**
9
- * Max blank area displayed
10
- */
11
- maxBlankArea: number;
12
- /**
13
- * Sum of all blank area values across all frames
14
- */
15
- cumulativeBlankArea: number;
16
- }
17
- export interface BlankAreaTrackerConfig {
18
- /**
19
- * When set to true the hook will also sum all negative blank area values.
20
- * Blank area is negative when list is able to draw faster than the scroll speed.
21
- */
22
- sumNegativeValues?: boolean;
23
- /**
24
- * By default, the hook ignores blank events for 1s after the list load. This value can be changed using this parameter.
25
- * Please note that this duration kicks in after the list has loaded and not after the first scroll.
26
- */
27
- startDelayInMs?: number;
28
- }
29
-
30
- /**
31
- * Can be used to track visible blank area in production
32
- * @param flashListRef Ref to the FlashList component
33
- * @param onBlankAreaChange This event handler will be called when the blank area changes
34
- * @param config additional configuration for the blank area tracker
35
- * @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
36
- */
37
- export function useBlankAreaTracker(
38
- flashListRef: React.RefObject<FlashList<any>>,
39
- onBlankAreaChange?: (value: BlankAreaTrackerResult) => void,
40
- config?: BlankAreaTrackerConfig
41
- ): [BlankAreaTrackerResult, (event: BlankAreaEvent) => void] {
42
- const startDelay = config?.startDelayInMs ?? 1000;
43
- const blankAreaResult = useRef({
44
- maxBlankArea: 0,
45
- cumulativeBlankArea: 0,
46
- }).current;
47
- const waitOperations = useRef({ inProgress: false, complete: false }).current;
48
- const onBlankAreaChangeRef = useRef(onBlankAreaChange);
49
- onBlankAreaChangeRef.current = onBlankAreaChange;
50
-
51
- const blankAreaTracker = useCallback(
52
- (event: BlankAreaEvent) => {
53
- // we're ignoring some of the events that will be fired on list load
54
- // initial events are fired on mount and thus, this won't lead to missing events during scroll
55
- if (!waitOperations.complete && startDelay > 0) {
56
- if (!waitOperations.inProgress) {
57
- waitOperations.inProgress = true;
58
- setTimeout(() => {
59
- waitOperations.complete = true;
60
- }, startDelay);
61
- }
62
- return;
63
- }
64
- const rlv = flashListRef.current?.recyclerlistview_unsafe;
65
- const horizontal = Boolean(flashListRef.current?.props.horizontal);
66
- if (rlv) {
67
- processBlankAreaChange(
68
- rlv,
69
- horizontal,
70
- blankAreaResult,
71
- event,
72
- onBlankAreaChangeRef.current,
73
- config
74
- );
75
- }
76
- },
77
- // eslint-disable-next-line react-hooks/exhaustive-deps
78
- [flashListRef]
79
- );
80
- return [blankAreaResult, blankAreaTracker];
81
- }
82
-
83
- function processBlankAreaChange(
84
- rlv: RecyclerListView<RecyclerListViewProps, any>,
85
- horizontal: boolean,
86
- blankAreaResult: BlankAreaTrackerResult,
87
- event: BlankAreaEvent,
88
- onBlankAreaChange?: (value: BlankAreaTrackerResult) => void,
89
- config?: BlankAreaTrackerConfig
90
- ) {
91
- const listSize = horizontal
92
- ? rlv.getRenderedSize().width
93
- : rlv.getRenderedSize().height;
94
- const contentSize = horizontal
95
- ? rlv.getContentDimension().width
96
- : rlv.getContentDimension().height;
97
-
98
- // ignores blank events when there isn't enough content to fill the list
99
- if (contentSize > listSize) {
100
- const lastMaxBlankArea = blankAreaResult.maxBlankArea;
101
- const lastCumulativeBlankArea = blankAreaResult.cumulativeBlankArea;
102
- blankAreaResult.maxBlankArea = Math.max(
103
- blankAreaResult.maxBlankArea,
104
- event.blankArea,
105
- 0
106
- );
107
- blankAreaResult.cumulativeBlankArea += config?.sumNegativeValues
108
- ? event.blankArea
109
- : Math.max(event.blankArea, 0);
110
- if (
111
- lastCumulativeBlankArea !== blankAreaResult.cumulativeBlankArea ||
112
- lastMaxBlankArea !== blankAreaResult.maxBlankArea
113
- ) {
114
- onBlankAreaChange?.(blankAreaResult);
115
- }
116
- }
117
- }
@@ -1,24 +0,0 @@
1
- import { Platform } from "react-native";
2
-
3
- let useNewCore: boolean | undefined;
4
- export function enableNewCore(enable: boolean) {
5
- useNewCore = enable;
6
- }
7
-
8
- export function isNewCoreEnabled() {
9
- return useNewCore ?? isReactNativeNewArchitecture();
10
- }
11
-
12
- function isReactNativeNewArchitecture(): boolean {
13
- try {
14
- // Check for Fabric UI Manager
15
- const hasFabricUIManager = Boolean((global as any)?.nativeFabricUIManager);
16
-
17
- // Check for TurboModule system
18
- const hasTurboModule = Boolean((global as any)?.__turboModuleProxy);
19
-
20
- return hasFabricUIManager || hasTurboModule || Platform.OS === "web";
21
- } catch {
22
- return false;
23
- }
24
- }
@@ -1,10 +0,0 @@
1
- export default class CustomError extends Error {
2
- constructor(exception: Exception) {
3
- super(`${exception.type}: ${exception.message}`);
4
- this.name = exception.type;
5
- }
6
- }
7
- export interface Exception {
8
- type: string;
9
- message: string;
10
- }
@@ -1,28 +0,0 @@
1
- const ExceptionList = {
2
- refreshBooleanMissing: {
3
- message:
4
- "`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `undefined`.",
5
- type: "InvariantViolation",
6
- },
7
- stickyWhileHorizontalNotSupported: {
8
- message:
9
- "sticky headers are not supported when list is in horizontal mode. Remove `stickyHeaderIndices` prop.",
10
- type: "NotSupportedException",
11
- },
12
- columnsWhileHorizontalNotSupported: {
13
- message:
14
- "numColumns is not supported when list is in horizontal mode. Please remove or set numColumns to 1.",
15
- type: "NotSupportedException",
16
- },
17
- multipleViewabilityThresholdTypesNotSupported: {
18
- message:
19
- "You can set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold. Specifying both is not supported.",
20
- type: "MultipleViewabilityThresholdTypesException",
21
- },
22
- overrideItemLayoutRequiredForMasonryOptimization: {
23
- message:
24
- "optimizeItemArrangement has been enabled on `MasonryFlashList` but overrideItemLayout is not set.",
25
- type: "InvariantViolation",
26
- },
27
- };
28
- export default ExceptionList;
@@ -1,15 +0,0 @@
1
- const WarningList = {
2
- styleUnsupported:
3
- "You have passed a style to FlashList. This list doesn't support styling, use contentContainerStyle or wrap the list in a parent and apply style to it instead.",
4
- styleContentContainerUnsupported:
5
- "FlashList only supports padding related props and backgroundColor in contentContainerStyle. Please remove other values as they're not used.",
6
- unusableRenderedSize:
7
- "FlashList's rendered size is not usable. Either the height or width is too small (<2px). " +
8
- "Please make sure that the parent view of the list has a valid size. FlashList will match the size of the parent.",
9
- missingKeyExtractor:
10
- "FlashList requires a keyExtractor prop to be defined when animating elements. Without it, the animations will not run as expected.",
11
- estimatedItemSizeMissingWarning:
12
- "estimatedItemSize FlashList prop is not defined - based on current configuration you can set it to @size to optimize list performance. " +
13
- "Refer to FlashList documentation for more details.",
14
- };
15
- export default WarningList;
@@ -1,73 +0,0 @@
1
- import React, { useEffect, ReactNode } from "react";
2
- import { LayoutChangeEvent } from "react-native";
3
-
4
- import AutoLayoutViewNativeComponent from "./AutoLayoutViewNativeComponent";
5
- import { OnBlankAreaEvent } from "./AutoLayoutViewNativeComponentProps";
6
-
7
- export type BlankAreaEventHandler = (blankAreaEvent: BlankAreaEvent) => void;
8
- const listeners: BlankAreaEventHandler[] = [];
9
-
10
- export const useOnNativeBlankAreaEvents = (
11
- onBlankAreaEvent: (blankAreaEvent: BlankAreaEvent) => void
12
- ) => {
13
- useEffect(() => {
14
- listeners.push(onBlankAreaEvent);
15
- return () => {
16
- listeners.filter((callback) => callback !== onBlankAreaEvent);
17
- };
18
- }, [onBlankAreaEvent]);
19
- };
20
-
21
- export interface BlankAreaEvent {
22
- offsetStart: number;
23
- offsetEnd: number;
24
- blankArea: number;
25
- }
26
-
27
- export interface AutoLayoutViewProps {
28
- children?: ReactNode;
29
- onBlankAreaEvent?: BlankAreaEventHandler;
30
- onLayout?: (event: LayoutChangeEvent) => void;
31
- disableAutoLayout?: boolean;
32
- }
33
-
34
- class AutoLayoutView extends React.Component<AutoLayoutViewProps> {
35
- private onBlankAreaEventCallback = ({
36
- nativeEvent,
37
- }: OnBlankAreaEvent): void => {
38
- const blankArea = Math.max(nativeEvent.offsetStart, nativeEvent.offsetEnd);
39
- const blankEventValue = {
40
- blankArea,
41
- offsetStart: nativeEvent.offsetStart,
42
- offsetEnd: nativeEvent.offsetEnd,
43
- };
44
- this.broadcastBlankEvent(blankEventValue);
45
- if (this.props.onBlankAreaEvent) {
46
- this.props.onBlankAreaEvent(blankEventValue);
47
- }
48
- };
49
-
50
- private broadcastBlankEvent(value: BlankAreaEvent) {
51
- const len = listeners.length;
52
- for (let i = 0; i < len; i++) {
53
- listeners[i](value);
54
- }
55
- }
56
-
57
- render() {
58
- return (
59
- <AutoLayoutViewNativeComponent
60
- {...this.props}
61
- onBlankAreaEvent={this.onBlankAreaEventCallback}
62
- enableInstrumentation={
63
- listeners.length !== 0 || Boolean(this.props.onBlankAreaEvent)
64
- }
65
- disableAutoLayout={this.props.disableAutoLayout}
66
- >
67
- {this.props.children}
68
- </AutoLayoutViewNativeComponent>
69
- );
70
- }
71
- }
72
-
73
- export default AutoLayoutView;
@@ -1,7 +0,0 @@
1
- import { requireNativeComponent } from "react-native";
2
-
3
- import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
4
-
5
- const AutoLayoutViewNativeComponent =
6
- requireNativeComponent<AutoLayoutViewNativeComponentProps>("AutoLayoutView");
7
- export default AutoLayoutViewNativeComponent;
@@ -1,7 +0,0 @@
1
- import { requireNativeComponent } from "react-native";
2
-
3
- import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
4
-
5
- const AutoLayoutViewNativeComponent =
6
- requireNativeComponent<AutoLayoutViewNativeComponentProps>("AutoLayoutView");
7
- export default AutoLayoutViewNativeComponent;
@@ -1,7 +0,0 @@
1
- import { HostComponent, View } from "react-native";
2
-
3
- import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
4
-
5
- const AutoLayoutViewNativeComponent =
6
- View as any as HostComponent<AutoLayoutViewNativeComponentProps>;
7
- export default AutoLayoutViewNativeComponent;
@@ -1,17 +0,0 @@
1
- import { ReactNode } from "react";
2
-
3
- export interface OnBlankAreaEvent {
4
- nativeEvent: {
5
- offsetStart: number;
6
- offsetEnd: number;
7
- };
8
- }
9
-
10
- type OnBlankAreaEventHandler = (event: OnBlankAreaEvent) => void;
11
-
12
- export interface AutoLayoutViewNativeComponentProps {
13
- children?: ReactNode;
14
- onBlankAreaEvent: OnBlankAreaEventHandler;
15
- enableInstrumentation: boolean;
16
- disableAutoLayout?: boolean;
17
- }
@@ -1,7 +0,0 @@
1
- import { requireNativeComponent } from "react-native";
2
-
3
- /**
4
- * Behaves as a regular `View` with an extra `index` prop that is saved in the native layer.
5
- */
6
- const CellContainer = requireNativeComponent("CellContainer");
7
- export default CellContainer;
@@ -1,7 +0,0 @@
1
- import { requireNativeComponent } from "react-native";
2
-
3
- /**
4
- * Behaves as a regular `View` with an extra `index` prop that is saved in the native layer.
5
- */
6
- const CellContainer = requireNativeComponent("CellContainer");
7
- export default CellContainer;
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { View, ViewProps } from "react-native";
3
-
4
- export interface CellContainerProps extends ViewProps {
5
- index: number;
6
- }
7
-
8
- const CellContainer = React.forwardRef(
9
- (props: CellContainerProps, ref: any) => {
10
- return <View ref={ref} {...props} />;
11
- }
12
- );
13
- CellContainer.displayName = "CellContainer";
14
- export default CellContainer;
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- /**
3
- * On web we use a view instead of cell container till we build native web implementations
4
- */
5
- const CellContainer = React.forwardRef((props: any, ref) => {
6
- return <div ref={ref} {...props} />;
7
- });
8
- CellContainer.displayName = "CellContainer";
9
- export default CellContainer;
@@ -1,24 +0,0 @@
1
- import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2
- import type { ViewProps } from "react-native";
3
- import type {
4
- Int32,
5
- Double,
6
- DirectEventHandler,
7
- } from "react-native/Libraries/Types/CodegenTypes";
8
-
9
- type BlankAreaEvent = Readonly<{
10
- offsetStart: Int32;
11
- offsetEnd: Int32;
12
- }>;
13
-
14
- interface NativeProps extends ViewProps {
15
- horizontal?: boolean;
16
- scrollOffset?: Double;
17
- windowSize?: Double;
18
- renderAheadOffset?: Double;
19
- enableInstrumentation?: boolean;
20
- disableAutoLayout?: boolean;
21
- onBlankAreaEvent?: DirectEventHandler<BlankAreaEvent>;
22
- }
23
-
24
- export default codegenNativeComponent<NativeProps>("AutoLayoutView");
@@ -1,9 +0,0 @@
1
- import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2
- import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
3
- import type { ViewProps } from "react-native";
4
-
5
- interface NativeProps extends ViewProps {
6
- index?: Int32;
7
- }
8
-
9
- export default codegenNativeComponent<NativeProps>("CellContainer");