@react-native-ohos/flash-list 1.8.3-rc.3 → 1.8.3-rc.4
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.
- package/LICENSE +6 -6
- package/README.OpenSource +10 -10
- package/README.md +9 -9
- package/dist/AnimatedFlashList.d.ts +28 -25
- package/dist/AnimatedFlashList.d.ts.map +1 -1
- package/dist/AnimatedFlashList.js +30 -30
- package/dist/FlashList.d.ts +179 -179
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +599 -598
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +278 -278
- package/dist/FlashListProps.js +31 -31
- package/dist/GridLayoutProviderWithProps.d.ts +64 -64
- package/dist/GridLayoutProviderWithProps.js +137 -136
- package/dist/GridLayoutProviderWithProps.js.map +1 -1
- package/dist/MasonryFlashList.d.ts +73 -73
- package/dist/MasonryFlashList.d.ts.map +1 -1
- package/dist/MasonryFlashList.js +274 -274
- package/dist/MasonryFlashList.js.map +1 -1
- package/dist/PureComponentWrapper.d.ts +44 -44
- package/dist/PureComponentWrapper.js +59 -59
- package/dist/PureComponentWrapper.js.map +1 -1
- package/dist/benchmark/AutoScrollHelper.d.ts +40 -40
- package/dist/benchmark/AutoScrollHelper.js +90 -90
- package/dist/benchmark/AutoScrollHelper.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts +45 -45
- package/dist/benchmark/JSFPSMonitor.js +87 -87
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.d.ts +24 -24
- package/dist/benchmark/roundToDecimalPlaces.js +31 -30
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +57 -57
- package/dist/benchmark/useBenchmark.js +189 -188
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +56 -56
- package/dist/benchmark/useBlankAreaTracker.js +89 -88
- package/dist/benchmark/useBlankAreaTracker.js.map +1 -1
- package/dist/benchmark/useDataMultiplier.d.ts +31 -31
- package/dist/benchmark/useDataMultiplier.js +47 -46
- package/dist/benchmark/useDataMultiplier.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts +35 -34
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +122 -121
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/CustomError.d.ts +30 -30
- package/dist/errors/CustomError.js +36 -36
- package/dist/errors/CustomError.js.map +1 -1
- package/dist/errors/ExceptionList.d.ts +46 -46
- package/dist/errors/ExceptionList.js +48 -48
- package/dist/errors/Warnings.d.ts +31 -31
- package/dist/errors/Warnings.js +35 -35
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +41 -41
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +1 -1
- package/dist/fabric/AutoLayoutNativeComponent.js +28 -28
- package/dist/fabric/CellContainerNativeComponent.d.ts +30 -30
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +1 -1
- package/dist/fabric/CellContainerNativeComponent.js +28 -28
- package/dist/index.d.ts +36 -36
- package/dist/index.js +54 -52
- package/dist/index.js.map +1 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +44 -44
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutView.js +70 -70
- package/dist/native/auto-layout/AutoLayoutView.js.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +26 -25
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +28 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +27 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +26 -25
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +28 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +26 -25
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +28 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +28 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +38 -38
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +25 -25
- package/dist/native/cell-container/CellContainer.android.d.ts +28 -28
- package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -1
- package/dist/native/cell-container/CellContainer.android.js +31 -31
- package/dist/native/cell-container/CellContainer.d.ts +30 -29
- package/dist/native/cell-container/CellContainer.d.ts.map +1 -1
- package/dist/native/cell-container/CellContainer.harmony.d.ts +28 -28
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +1 -1
- package/dist/native/cell-container/CellContainer.harmony.js +31 -31
- package/dist/native/cell-container/CellContainer.ios.d.ts +28 -28
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -1
- package/dist/native/cell-container/CellContainer.ios.js +31 -31
- package/dist/native/cell-container/CellContainer.js +33 -33
- package/dist/native/cell-container/CellContainer.web.d.ts +29 -28
- package/dist/native/cell-container/CellContainer.web.d.ts.map +1 -1
- package/dist/native/cell-container/CellContainer.web.js +35 -35
- package/dist/native/config/PlatformHelper.android.d.ts +48 -48
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +45 -45
- package/dist/native/config/PlatformHelper.d.ts +48 -48
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.d.ts +48 -48
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.js +44 -44
- package/dist/native/config/PlatformHelper.ios.d.ts +48 -48
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +44 -44
- package/dist/native/config/PlatformHelper.js +45 -45
- package/dist/native/config/PlatformHelper.web.d.ts +49 -49
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +47 -47
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.d.ts +43 -43
- package/dist/utils/AverageWindow.js +71 -71
- package/dist/utils/ContentContainerUtils.d.ts +49 -49
- package/dist/utils/ContentContainerUtils.d.ts.map +1 -1
- package/dist/utils/ContentContainerUtils.js +70 -70
- package/dist/utils/ContentContainerUtils.js.map +1 -1
- package/dist/viewability/ViewToken.d.ts +30 -30
- package/dist/viewability/ViewToken.js +25 -25
- package/dist/viewability/ViewabilityHelper.d.ts +48 -48
- package/dist/viewability/ViewabilityHelper.js +129 -129
- package/dist/viewability/ViewabilityHelper.js.map +1 -1
- package/dist/viewability/ViewabilityManager.d.ts +47 -47
- package/dist/viewability/ViewabilityManager.d.ts.map +1 -1
- package/dist/viewability/ViewabilityManager.js +130 -130
- package/dist/viewability/ViewabilityManager.js.map +1 -1
- package/harmony/flash_list/BuildProfile.ets +16 -16
- package/harmony/flash_list/LICENSE +7 -7
- package/harmony/flash_list/build-profile.json5 +7 -7
- package/harmony/flash_list/hvigorfile.ts +1 -1
- package/harmony/flash_list/index.ets +27 -27
- package/harmony/flash_list/obfuscation-rules.txt +17 -17
- package/harmony/flash_list/oh-package.json5 +23 -23
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +63 -140
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +53 -53
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +31 -24
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +66 -66
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +208 -208
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +78 -78
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +53 -53
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +50 -50
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +6 -6
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +79 -79
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +63 -63
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +38 -38
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +40 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +39 -39
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +48 -48
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +77 -77
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +87 -87
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +56 -56
- package/harmony/flash_list/src/main/cpp/Props.cpp +51 -51
- package/harmony/flash_list/src/main/cpp/Props.h +64 -64
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +33 -33
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +48 -48
- package/harmony/flash_list/src/main/ets/Logger.ets +63 -63
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +153 -153
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +276 -276
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +113 -113
- package/harmony/flash_list/src/main/module.json5 +9 -9
- package/harmony/flash_list/src/main/resources/base/element/color.json +7 -7
- package/harmony/flash_list/src/main/resources/base/element/string.json +15 -15
- package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/flash_list.har +0 -0
- package/jestSetup.js +40 -40
- package/package.json +82 -82
- package/src/AnimatedFlashList.ts +35 -35
- package/src/FlashList.tsx +949 -949
- package/src/FlashListProps.ts +359 -359
- package/src/GridLayoutProviderWithProps.ts +204 -204
- package/src/MasonryFlashList.tsx +499 -499
- package/src/PureComponentWrapper.tsx +65 -65
- package/src/benchmark/AutoScrollHelper.ts +94 -94
- package/src/benchmark/JSFPSMonitor.ts +98 -98
- package/src/benchmark/roundToDecimalPlaces.ts +28 -28
- package/src/benchmark/useBenchmark.ts +264 -264
- package/src/benchmark/useBlankAreaTracker.ts +141 -141
- package/src/benchmark/useDataMultiplier.ts +43 -43
- package/src/benchmark/useFlatListBenchmark.ts +131 -131
- package/src/errors/CustomError.ts +34 -34
- package/src/errors/ExceptionList.ts +52 -52
- package/src/errors/Warnings.ts +39 -39
- package/src/fabric/AutoLayoutNativeComponent.ts +52 -52
- package/src/fabric/CellContainerNativeComponent.ts +35 -35
- package/src/index.ts +67 -67
- package/src/native/auto-layout/AutoLayoutView.tsx +97 -97
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +31 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +31 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +31 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +31 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +41 -41
- package/src/native/cell-container/CellContainer.android.ts +31 -31
- package/src/native/cell-container/CellContainer.harmony.ts +31 -31
- package/src/native/cell-container/CellContainer.ios.ts +31 -31
- package/src/native/cell-container/CellContainer.tsx +38 -38
- package/src/native/cell-container/CellContainer.web.tsx +33 -33
- package/src/native/config/PlatformHelper.android.ts +53 -53
- package/src/native/config/PlatformHelper.harmony.ts +52 -52
- package/src/native/config/PlatformHelper.ios.ts +52 -52
- package/src/native/config/PlatformHelper.ts +53 -53
- package/src/native/config/PlatformHelper.web.ts +58 -58
- package/src/utils/AverageWindow.ts +73 -73
- package/src/utils/ContentContainerUtils.ts +116 -116
- package/src/viewability/ViewToken.ts +31 -31
- package/src/viewability/ViewabilityHelper.ts +190 -190
- package/src/viewability/ViewabilityManager.ts +169 -169
|
@@ -1,189 +1,190 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useBenchmark =
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
jsFPSMonitor
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_a.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
jsProfilerResponse
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function getFormattedString(res) {
|
|
94
|
-
var _a, _b, _c, _d, _e;
|
|
95
|
-
return ("Results:\n\n" +
|
|
96
|
-
"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") +
|
|
97
|
-
"".concat(res.blankArea
|
|
98
|
-
? "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")
|
|
99
|
-
: "") +
|
|
100
|
-
"".concat(res.suggestions.length > 0
|
|
101
|
-
? "Suggestions:\n\n".concat(res.suggestions
|
|
102
|
-
.map(function (value, index) { return "".concat(index + 1, ". ").concat(value); })
|
|
103
|
-
.join("\n"))
|
|
104
|
-
: ""));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_a.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getFormattedString = exports.useBenchmark = void 0;
|
|
27
|
+
var tslib_1 = require("tslib");
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
var AutoScrollHelper_1 = require("./AutoScrollHelper");
|
|
30
|
+
var JSFPSMonitor_1 = require("./JSFPSMonitor");
|
|
31
|
+
var roundToDecimalPlaces_1 = require("./roundToDecimalPlaces");
|
|
32
|
+
var useBlankAreaTracker_1 = require("./useBlankAreaTracker");
|
|
33
|
+
/**
|
|
34
|
+
* Runs the benchmark on FlashList.
|
|
35
|
+
* Response object has a formatted string that can be printed to the console or shown as an alert.
|
|
36
|
+
* Result is posted to the callback method passed to the hook.
|
|
37
|
+
*/
|
|
38
|
+
function useBenchmark(flashListRef, callback, params) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
if (params === void 0) { params = {}; }
|
|
41
|
+
var _a = tslib_1.__read((0, useBlankAreaTracker_1.useBlankAreaTracker)(flashListRef, undefined, { sumNegativeValues: params.sumNegativeBlankAreaValues, startDelayInMs: 0 }), 2), blankAreaResult = _a[0], blankAreaTracker = _a[1];
|
|
42
|
+
(0, react_1.useEffect)(function () {
|
|
43
|
+
var _a;
|
|
44
|
+
var cancellable = new AutoScrollHelper_1.Cancellable();
|
|
45
|
+
var suggestions = [];
|
|
46
|
+
if (flashListRef.current) {
|
|
47
|
+
if (!(Number((_a = flashListRef.current.props.data) === null || _a === void 0 ? void 0 : _a.length) > 0)) {
|
|
48
|
+
throw new Error("Data is empty, cannot run benchmark");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var cancelTimeout = setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
52
|
+
var jsFPSMonitor, i, jsProfilerResponse, result;
|
|
53
|
+
return tslib_1.__generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
jsFPSMonitor = new JSFPSMonitor_1.JSFPSMonitor();
|
|
57
|
+
jsFPSMonitor.startTracking();
|
|
58
|
+
i = 0;
|
|
59
|
+
_a.label = 1;
|
|
60
|
+
case 1:
|
|
61
|
+
if (!(i < (params.repeatCount || 1))) return [3 /*break*/, 4];
|
|
62
|
+
return [4 /*yield*/, runScrollBenchmark(flashListRef, cancellable, params.speedMultiplier || 1)];
|
|
63
|
+
case 2:
|
|
64
|
+
_a.sent();
|
|
65
|
+
_a.label = 3;
|
|
66
|
+
case 3:
|
|
67
|
+
i++;
|
|
68
|
+
return [3 /*break*/, 1];
|
|
69
|
+
case 4:
|
|
70
|
+
jsProfilerResponse = jsFPSMonitor.stopAndGetData();
|
|
71
|
+
if (jsProfilerResponse.averageFPS < 35) {
|
|
72
|
+
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");
|
|
73
|
+
}
|
|
74
|
+
computeSuggestions(flashListRef, suggestions);
|
|
75
|
+
result = generateResult(jsProfilerResponse, blankAreaResult, suggestions, cancellable);
|
|
76
|
+
if (!cancellable.isCancelled()) {
|
|
77
|
+
result.formattedString = getFormattedString(result);
|
|
78
|
+
}
|
|
79
|
+
callback(result);
|
|
80
|
+
return [2 /*return*/];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}); }, params.startDelayInMs || 3000);
|
|
84
|
+
return function () {
|
|
85
|
+
clearTimeout(cancelTimeout);
|
|
86
|
+
cancellable.cancel();
|
|
87
|
+
};
|
|
88
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
+
}, []);
|
|
90
|
+
return [blankAreaTracker];
|
|
91
|
+
}
|
|
92
|
+
exports.useBenchmark = useBenchmark;
|
|
93
|
+
function getFormattedString(res) {
|
|
94
|
+
var _a, _b, _c, _d, _e;
|
|
95
|
+
return ("Results:\n\n" +
|
|
96
|
+
"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") +
|
|
97
|
+
"".concat(res.blankArea
|
|
98
|
+
? "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")
|
|
99
|
+
: "") +
|
|
100
|
+
"".concat(res.suggestions.length > 0
|
|
101
|
+
? "Suggestions:\n\n".concat(res.suggestions
|
|
102
|
+
.map(function (value, index) { return "".concat(index + 1, ". ").concat(value); })
|
|
103
|
+
.join("\n"))
|
|
104
|
+
: ""));
|
|
105
|
+
}
|
|
106
|
+
exports.getFormattedString = getFormattedString;
|
|
107
|
+
function generateResult(jsProfilerResponse, blankAreaResult, suggestions, cancellable) {
|
|
108
|
+
return {
|
|
109
|
+
js: jsProfilerResponse,
|
|
110
|
+
blankArea: blankAreaResult.maxBlankArea >= 0
|
|
111
|
+
? {
|
|
112
|
+
maxBlankArea: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(blankAreaResult.maxBlankArea, 0),
|
|
113
|
+
cumulativeBlankArea: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(blankAreaResult.cumulativeBlankArea, 0),
|
|
114
|
+
}
|
|
115
|
+
: undefined,
|
|
116
|
+
suggestions: suggestions,
|
|
117
|
+
interrupted: cancellable.isCancelled(),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Scrolls to the end of the list and then back to the top
|
|
122
|
+
*/
|
|
123
|
+
function runScrollBenchmark(flashListRef, cancellable, scrollSpeedMultiplier) {
|
|
124
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var horizontal_1, rlv, rlvSize, rlvContentSize, fromX, fromY, toX, toY, scrollNow;
|
|
126
|
+
return tslib_1.__generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
if (!flashListRef.current) return [3 /*break*/, 3];
|
|
130
|
+
horizontal_1 = flashListRef.current.props.horizontal;
|
|
131
|
+
rlv = flashListRef.current.recyclerlistview_unsafe;
|
|
132
|
+
if (!rlv) return [3 /*break*/, 3];
|
|
133
|
+
rlvSize = rlv.getRenderedSize();
|
|
134
|
+
rlvContentSize = rlv.getContentDimension();
|
|
135
|
+
fromX = 0;
|
|
136
|
+
fromY = 0;
|
|
137
|
+
toX = rlvContentSize.width - rlvSize.width;
|
|
138
|
+
toY = rlvContentSize.height - rlvSize.height;
|
|
139
|
+
scrollNow = function (x, y) {
|
|
140
|
+
var _a;
|
|
141
|
+
(_a = flashListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToOffset({
|
|
142
|
+
offset: horizontal_1 ? x : y,
|
|
143
|
+
animated: false,
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
return [4 /*yield*/, (0, AutoScrollHelper_1.autoScroll)(scrollNow, fromX, fromY, toX, toY, scrollSpeedMultiplier, cancellable)];
|
|
147
|
+
case 1:
|
|
148
|
+
_a.sent();
|
|
149
|
+
return [4 /*yield*/, (0, AutoScrollHelper_1.autoScroll)(scrollNow, toX, toY, fromX, fromY, scrollSpeedMultiplier, cancellable)];
|
|
150
|
+
case 2:
|
|
151
|
+
_a.sent();
|
|
152
|
+
_a.label = 3;
|
|
153
|
+
case 3: return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function computeSuggestions(flashListRef, suggestions) {
|
|
159
|
+
var _a;
|
|
160
|
+
if (flashListRef.current) {
|
|
161
|
+
if (flashListRef.current.props.data.length < 200) {
|
|
162
|
+
suggestions.push("Data count is low. Try to increase it to a large number (e.g 200) using the 'useDataMultiplier' hook.");
|
|
163
|
+
}
|
|
164
|
+
var distanceFromWindow = (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(flashListRef.current.firstItemOffset, 0);
|
|
165
|
+
if ((flashListRef.current.props.estimatedFirstItemOffset || 0) !==
|
|
166
|
+
distanceFromWindow) {
|
|
167
|
+
suggestions.push("estimatedFirstItemOffset can be set to ".concat(distanceFromWindow));
|
|
168
|
+
}
|
|
169
|
+
var rlv_1 = flashListRef.current.recyclerlistview_unsafe;
|
|
170
|
+
var horizontal_2 = flashListRef.current.props.horizontal;
|
|
171
|
+
if (rlv_1) {
|
|
172
|
+
var sizeArray = rlv_1.props.dataProvider
|
|
173
|
+
.getAllData()
|
|
174
|
+
.map(function (_, index) {
|
|
175
|
+
var _a, _b, _c, _d;
|
|
176
|
+
return horizontal_2
|
|
177
|
+
? ((_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
|
|
178
|
+
: ((_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;
|
|
179
|
+
});
|
|
180
|
+
var averageSize = Math.round(sizeArray.reduce(function (prev, current) { return prev + current; }, 0) /
|
|
181
|
+
sizeArray.length);
|
|
182
|
+
if (Math.abs(averageSize -
|
|
183
|
+
((_a = flashListRef.current.props.estimatedItemSize) !== null && _a !== void 0 ? _a : flashListRef.current.state.layoutProvider
|
|
184
|
+
.defaultEstimatedItemSize)) > 5) {
|
|
185
|
+
suggestions.push("estimatedItemSize can be set to ".concat(averageSize));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
189
190
|
//# sourceMappingURL=useBenchmark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBenchmark.js","sourceRoot":"","sources":["../../src/benchmark/useBenchmark.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG
|
|
1
|
+
{"version":3,"file":"useBenchmark.js","sourceRoot":"","sources":["../../src/benchmark/useBenchmark.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,+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,EAC7D,YAAY,EACZ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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"}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import React from "react";
|
|
25
|
-
import { BlankAreaEvent } from "../native/auto-layout/AutoLayoutView";
|
|
26
|
-
import FlashList from "../FlashList";
|
|
27
|
-
export interface BlankAreaTrackerResult {
|
|
28
|
-
/**
|
|
29
|
-
* Max blank area displayed
|
|
30
|
-
*/
|
|
31
|
-
maxBlankArea: number;
|
|
32
|
-
/**
|
|
33
|
-
* Sum of all blank area values across all frames
|
|
34
|
-
*/
|
|
35
|
-
cumulativeBlankArea: number;
|
|
36
|
-
}
|
|
37
|
-
export interface BlankAreaTrackerConfig {
|
|
38
|
-
/**
|
|
39
|
-
* When set to true the hook will also sum all negative blank area values.
|
|
40
|
-
* Blank area is negative when list is able to draw faster than the scroll speed.
|
|
41
|
-
*/
|
|
42
|
-
sumNegativeValues?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* By default, the hook ignores blank events for 1s after the list load. This value can be changed using this parameter.
|
|
45
|
-
* Please note that this duration kicks in after the list has loaded and not after the first scroll.
|
|
46
|
-
*/
|
|
47
|
-
startDelayInMs?: number;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Can be used to track visible blank area in production
|
|
51
|
-
* @param flashListRef Ref to the FlashList component
|
|
52
|
-
* @param onBlankAreaChange This event handler will be called when the blank area changes
|
|
53
|
-
* @param config additional configuration for the blank area tracker
|
|
54
|
-
* @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
|
|
55
|
-
*/
|
|
56
|
-
export declare function useBlankAreaTracker(flashListRef: React.RefObject<FlashList<any>>, onBlankAreaChange?: (value: BlankAreaTrackerResult) => void, config?: BlankAreaTrackerConfig): [BlankAreaTrackerResult, (event: BlankAreaEvent) => void];
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React from "react";
|
|
25
|
+
import { BlankAreaEvent } from "../native/auto-layout/AutoLayoutView";
|
|
26
|
+
import FlashList from "../FlashList";
|
|
27
|
+
export interface BlankAreaTrackerResult {
|
|
28
|
+
/**
|
|
29
|
+
* Max blank area displayed
|
|
30
|
+
*/
|
|
31
|
+
maxBlankArea: number;
|
|
32
|
+
/**
|
|
33
|
+
* Sum of all blank area values across all frames
|
|
34
|
+
*/
|
|
35
|
+
cumulativeBlankArea: number;
|
|
36
|
+
}
|
|
37
|
+
export interface BlankAreaTrackerConfig {
|
|
38
|
+
/**
|
|
39
|
+
* When set to true the hook will also sum all negative blank area values.
|
|
40
|
+
* Blank area is negative when list is able to draw faster than the scroll speed.
|
|
41
|
+
*/
|
|
42
|
+
sumNegativeValues?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* By default, the hook ignores blank events for 1s after the list load. This value can be changed using this parameter.
|
|
45
|
+
* Please note that this duration kicks in after the list has loaded and not after the first scroll.
|
|
46
|
+
*/
|
|
47
|
+
startDelayInMs?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Can be used to track visible blank area in production
|
|
51
|
+
* @param flashListRef Ref to the FlashList component
|
|
52
|
+
* @param onBlankAreaChange This event handler will be called when the blank area changes
|
|
53
|
+
* @param config additional configuration for the blank area tracker
|
|
54
|
+
* @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useBlankAreaTracker(flashListRef: React.RefObject<FlashList<any>>, onBlankAreaChange?: (value: BlankAreaTrackerResult) => void, config?: BlankAreaTrackerConfig): [BlankAreaTrackerResult, (event: BlankAreaEvent) => void];
|
|
57
57
|
//# sourceMappingURL=useBlankAreaTracker.d.ts.map
|