@react-native-ohos/flash-list 1.8.3-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.
- package/LICENSE +7 -0
- package/README.OpenSource +11 -0
- package/README.md +9 -0
- package/dist/AnimatedFlashList.d.ts +29 -0
- package/dist/AnimatedFlashList.d.ts.map +1 -0
- package/dist/AnimatedFlashList.js +31 -0
- package/dist/AnimatedFlashList.js.map +1 -0
- package/dist/FlashList.d.ts +182 -0
- package/dist/FlashList.d.ts.map +1 -0
- package/dist/FlashList.js +602 -0
- package/dist/FlashList.js.map +1 -0
- package/dist/FlashListProps.d.ts +279 -0
- package/dist/FlashListProps.d.ts.map +1 -0
- package/dist/FlashListProps.js +32 -0
- package/dist/FlashListProps.js.map +1 -0
- package/dist/GridLayoutProviderWithProps.d.ts +65 -0
- package/dist/GridLayoutProviderWithProps.d.ts.map +1 -0
- package/dist/GridLayoutProviderWithProps.js +138 -0
- package/dist/GridLayoutProviderWithProps.js.map +1 -0
- package/dist/MasonryFlashList.d.ts +74 -0
- package/dist/MasonryFlashList.d.ts.map +1 -0
- package/dist/MasonryFlashList.js +275 -0
- package/dist/MasonryFlashList.js.map +1 -0
- package/dist/PureComponentWrapper.d.ts +45 -0
- package/dist/PureComponentWrapper.d.ts.map +1 -0
- package/dist/PureComponentWrapper.js +60 -0
- package/dist/PureComponentWrapper.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.d.ts +41 -0
- package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -0
- package/dist/benchmark/AutoScrollHelper.js +91 -0
- package/dist/benchmark/AutoScrollHelper.js.map +1 -0
- package/dist/benchmark/JSFPSMonitor.d.ts +46 -0
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -0
- package/dist/benchmark/JSFPSMonitor.js +88 -0
- package/dist/benchmark/JSFPSMonitor.js.map +1 -0
- package/dist/benchmark/roundToDecimalPlaces.d.ts +25 -0
- package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -0
- package/dist/benchmark/roundToDecimalPlaces.js +32 -0
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -0
- package/dist/benchmark/useBenchmark.d.ts +58 -0
- package/dist/benchmark/useBenchmark.d.ts.map +1 -0
- package/dist/benchmark/useBenchmark.js +190 -0
- package/dist/benchmark/useBenchmark.js.map +1 -0
- package/dist/benchmark/useBlankAreaTracker.d.ts +57 -0
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +1 -0
- package/dist/benchmark/useBlankAreaTracker.js +90 -0
- package/dist/benchmark/useBlankAreaTracker.js.map +1 -0
- package/dist/benchmark/useDataMultiplier.d.ts +32 -0
- package/dist/benchmark/useDataMultiplier.d.ts.map +1 -0
- package/dist/benchmark/useDataMultiplier.js +48 -0
- package/dist/benchmark/useDataMultiplier.js.map +1 -0
- package/dist/benchmark/useFlatListBenchmark.d.ts +36 -0
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -0
- package/dist/benchmark/useFlatListBenchmark.js +123 -0
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -0
- package/dist/errors/CustomError.d.ts +31 -0
- package/dist/errors/CustomError.d.ts.map +1 -0
- package/dist/errors/CustomError.js +37 -0
- package/dist/errors/CustomError.js.map +1 -0
- package/dist/errors/ExceptionList.d.ts +47 -0
- package/dist/errors/ExceptionList.d.ts.map +1 -0
- package/dist/errors/ExceptionList.js +49 -0
- package/dist/errors/ExceptionList.js.map +1 -0
- package/dist/errors/Warnings.d.ts +32 -0
- package/dist/errors/Warnings.d.ts.map +1 -0
- package/dist/errors/Warnings.js +36 -0
- package/dist/errors/Warnings.js.map +1 -0
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +42 -0
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +1 -0
- package/dist/fabric/AutoLayoutNativeComponent.js +29 -0
- package/dist/fabric/AutoLayoutNativeComponent.js.map +1 -0
- package/dist/fabric/CellContainerNativeComponent.d.ts +31 -0
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +1 -0
- package/dist/fabric/CellContainerNativeComponent.js +29 -0
- package/dist/fabric/CellContainerNativeComponent.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutView.d.ts +45 -0
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutView.js +71 -0
- package/dist/native/auto-layout/AutoLayoutView.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +27 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +29 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +28 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +27 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +29 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +27 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +29 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +29 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +39 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +26 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +1 -0
- package/dist/native/cell-container/CellContainer.android.d.ts +29 -0
- package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.android.js +32 -0
- package/dist/native/cell-container/CellContainer.android.js.map +1 -0
- package/dist/native/cell-container/CellContainer.d.ts +31 -0
- package/dist/native/cell-container/CellContainer.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.harmony.d.ts +29 -0
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.harmony.js +32 -0
- package/dist/native/cell-container/CellContainer.harmony.js.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts +29 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.js +32 -0
- package/dist/native/cell-container/CellContainer.ios.js.map +1 -0
- package/dist/native/cell-container/CellContainer.js +34 -0
- package/dist/native/cell-container/CellContainer.js.map +1 -0
- package/dist/native/cell-container/CellContainer.web.d.ts +30 -0
- package/dist/native/cell-container/CellContainer.web.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.web.js +36 -0
- package/dist/native/cell-container/CellContainer.web.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +49 -0
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.android.js +46 -0
- package/dist/native/config/PlatformHelper.android.js.map +1 -0
- package/dist/native/config/PlatformHelper.d.ts +49 -0
- package/dist/native/config/PlatformHelper.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.harmony.d.ts +49 -0
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.harmony.js +45 -0
- package/dist/native/config/PlatformHelper.harmony.js.map +1 -0
- package/dist/native/config/PlatformHelper.ios.d.ts +49 -0
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.ios.js +45 -0
- package/dist/native/config/PlatformHelper.ios.js.map +1 -0
- package/dist/native/config/PlatformHelper.js +46 -0
- package/dist/native/config/PlatformHelper.js.map +1 -0
- package/dist/native/config/PlatformHelper.web.d.ts +50 -0
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.web.js +48 -0
- package/dist/native/config/PlatformHelper.web.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/AverageWindow.d.ts +44 -0
- package/dist/utils/AverageWindow.d.ts.map +1 -0
- package/dist/utils/AverageWindow.js +72 -0
- package/dist/utils/AverageWindow.js.map +1 -0
- package/dist/utils/ContentContainerUtils.d.ts +50 -0
- package/dist/utils/ContentContainerUtils.d.ts.map +1 -0
- package/dist/utils/ContentContainerUtils.js +71 -0
- package/dist/utils/ContentContainerUtils.js.map +1 -0
- package/dist/viewability/ViewToken.d.ts +31 -0
- package/dist/viewability/ViewToken.d.ts.map +1 -0
- package/dist/viewability/ViewToken.js +26 -0
- package/dist/viewability/ViewToken.js.map +1 -0
- package/dist/viewability/ViewabilityHelper.d.ts +49 -0
- package/dist/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/viewability/ViewabilityHelper.js +130 -0
- package/dist/viewability/ViewabilityHelper.js.map +1 -0
- package/dist/viewability/ViewabilityManager.d.ts +48 -0
- package/dist/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/viewability/ViewabilityManager.js +131 -0
- package/dist/viewability/ViewabilityManager.js.map +1 -0
- package/harmony/flash_list/BuildProfile.ets +17 -0
- package/harmony/flash_list/LICENSE +7 -0
- package/harmony/flash_list/build-profile.json5 +8 -0
- package/harmony/flash_list/hvigorfile.ts +1 -0
- package/harmony/flash_list/index.ets +27 -0
- package/harmony/flash_list/obfuscation-rules.txt +18 -0
- package/harmony/flash_list/oh-package.json5 +24 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +63 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +54 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +133 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +66 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +208 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +78 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +53 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +50 -0
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +80 -0
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +64 -0
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +39 -0
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +40 -0
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +40 -0
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +48 -0
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +77 -0
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +87 -0
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +57 -0
- package/harmony/flash_list/src/main/cpp/Props.cpp +52 -0
- package/harmony/flash_list/src/main/cpp/Props.h +64 -0
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +34 -0
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +48 -0
- package/harmony/flash_list/src/main/ets/Logger.ets +64 -0
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +154 -0
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +277 -0
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +113 -0
- package/harmony/flash_list/src/main/module.json5 +9 -0
- package/harmony/flash_list/src/main/resources/base/element/color.json +8 -0
- package/harmony/flash_list/src/main/resources/base/element/string.json +16 -0
- package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
- package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +16 -0
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +16 -0
- package/harmony/flash_list.har +0 -0
- package/jestSetup.js +41 -0
- package/package.json +82 -0
- package/src/AnimatedFlashList.ts +35 -0
- package/src/FlashList.tsx +955 -0
- package/src/FlashListProps.ts +359 -0
- package/src/GridLayoutProviderWithProps.ts +204 -0
- package/src/MasonryFlashList.tsx +499 -0
- package/src/PureComponentWrapper.tsx +65 -0
- package/src/benchmark/AutoScrollHelper.ts +94 -0
- package/src/benchmark/JSFPSMonitor.ts +98 -0
- package/src/benchmark/roundToDecimalPlaces.ts +28 -0
- package/src/benchmark/useBenchmark.ts +264 -0
- package/src/benchmark/useBlankAreaTracker.ts +141 -0
- package/src/benchmark/useDataMultiplier.ts +43 -0
- package/src/benchmark/useFlatListBenchmark.ts +131 -0
- package/src/errors/CustomError.ts +34 -0
- package/src/errors/ExceptionList.ts +52 -0
- package/src/errors/Warnings.ts +39 -0
- package/src/fabric/AutoLayoutNativeComponent.ts +52 -0
- package/src/fabric/CellContainerNativeComponent.ts +35 -0
- package/src/index.ts +67 -0
- package/src/native/auto-layout/AutoLayoutView.tsx +97 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +31 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +31 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +31 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +31 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +41 -0
- package/src/native/cell-container/CellContainer.android.ts +31 -0
- package/src/native/cell-container/CellContainer.harmony.ts +31 -0
- package/src/native/cell-container/CellContainer.ios.ts +31 -0
- package/src/native/cell-container/CellContainer.tsx +38 -0
- package/src/native/cell-container/CellContainer.web.tsx +33 -0
- package/src/native/config/PlatformHelper.android.ts +53 -0
- package/src/native/config/PlatformHelper.harmony.ts +52 -0
- package/src/native/config/PlatformHelper.ios.ts +52 -0
- package/src/native/config/PlatformHelper.ts +53 -0
- package/src/native/config/PlatformHelper.web.ts +58 -0
- package/src/utils/AverageWindow.ts +73 -0
- package/src/utils/ContentContainerUtils.ts +116 -0
- package/src/viewability/ViewToken.ts +31 -0
- package/src/viewability/ViewabilityHelper.ts +190 -0
- package/src/viewability/ViewabilityManager.ts +169 -0
|
@@ -0,0 +1,88 @@
|
|
|
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.JSFPSMonitor = void 0;
|
|
27
|
+
var roundToDecimalPlaces_1 = require("./roundToDecimalPlaces");
|
|
28
|
+
/**
|
|
29
|
+
* Can be used to monitor JS thread performance
|
|
30
|
+
* Use startTracking() and stopAndGetData() to start and stop tracking
|
|
31
|
+
*/
|
|
32
|
+
var JSFPSMonitor = /** @class */ (function () {
|
|
33
|
+
function JSFPSMonitor() {
|
|
34
|
+
var _this = this;
|
|
35
|
+
this.startTime = 0;
|
|
36
|
+
this.frameCount = 0;
|
|
37
|
+
this.timeWindow = {
|
|
38
|
+
frameCount: 0,
|
|
39
|
+
startTime: 0,
|
|
40
|
+
};
|
|
41
|
+
this.minFPS = Number.MAX_SAFE_INTEGER;
|
|
42
|
+
this.maxFPS = 0;
|
|
43
|
+
this.averageFPS = 0;
|
|
44
|
+
this.clearAnimationNumber = 0;
|
|
45
|
+
this.updateLoopCompute = function () {
|
|
46
|
+
_this.frameCount++;
|
|
47
|
+
var elapsedTime = (Date.now() - _this.startTime) / 1000;
|
|
48
|
+
_this.averageFPS = elapsedTime > 0 ? _this.frameCount / elapsedTime : 0;
|
|
49
|
+
_this.timeWindow.frameCount++;
|
|
50
|
+
var timeWindowElapsedTime = (Date.now() - _this.timeWindow.startTime) / 1000;
|
|
51
|
+
if (timeWindowElapsedTime >= 1) {
|
|
52
|
+
var timeWindowAverageFPS = _this.timeWindow.frameCount / timeWindowElapsedTime;
|
|
53
|
+
_this.minFPS = Math.min(_this.minFPS, timeWindowAverageFPS);
|
|
54
|
+
_this.maxFPS = Math.max(_this.maxFPS, timeWindowAverageFPS);
|
|
55
|
+
_this.timeWindow.frameCount = 0;
|
|
56
|
+
_this.timeWindow.startTime = Date.now();
|
|
57
|
+
}
|
|
58
|
+
_this.measureLoop();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
JSFPSMonitor.prototype.measureLoop = function () {
|
|
62
|
+
// This looks weird but I'm avoiding a new closure
|
|
63
|
+
this.clearAnimationNumber = requestAnimationFrame(this.updateLoopCompute);
|
|
64
|
+
};
|
|
65
|
+
JSFPSMonitor.prototype.startTracking = function () {
|
|
66
|
+
if (this.startTime !== 0) {
|
|
67
|
+
throw new Error("This FPS Monitor has already been run, please create a new instance");
|
|
68
|
+
}
|
|
69
|
+
this.startTime = Date.now();
|
|
70
|
+
this.timeWindow.startTime = Date.now();
|
|
71
|
+
this.measureLoop();
|
|
72
|
+
};
|
|
73
|
+
JSFPSMonitor.prototype.stopAndGetData = function () {
|
|
74
|
+
cancelAnimationFrame(this.clearAnimationNumber);
|
|
75
|
+
if (this.minFPS === Number.MAX_SAFE_INTEGER) {
|
|
76
|
+
this.minFPS = this.averageFPS;
|
|
77
|
+
this.maxFPS = this.averageFPS;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
minFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.minFPS, 1),
|
|
81
|
+
maxFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.maxFPS, 1),
|
|
82
|
+
averageFPS: (0, roundToDecimalPlaces_1.roundToDecimalPlaces)(this.averageFPS, 1),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
return JSFPSMonitor;
|
|
86
|
+
}());
|
|
87
|
+
exports.JSFPSMonitor = JSFPSMonitor;
|
|
88
|
+
//# sourceMappingURL=JSFPSMonitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSFPSMonitor.js","sourceRoot":"","sources":["../../src/benchmark/JSFPSMonitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,+DAA8D;AAE9D;;;GAGG;AACH;IAAA;QAAA,i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AC,CAAC;IAyBJ,CAAC;IA/CS,kCAAW,GAAnB;QACE,kDAAkD;QAClD,IAAI,CAAC,oBAAoB,GAAG,qBAAqB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;IAqBM,oCAAa,GAApB;QACE,IAAI,IAAI,CAAC,SAAS,KAAK,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,25 @@
|
|
|
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
|
+
export declare function roundToDecimalPlaces(value: number, decimalPlaces: number): number;
|
|
25
|
+
//# sourceMappingURL=roundToDecimalPlaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundToDecimalPlaces.d.ts","sourceRoot":"","sources":["../../src/benchmark/roundToDecimalPlaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAGxE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.roundToDecimalPlaces = void 0;
|
|
27
|
+
function roundToDecimalPlaces(value, decimalPlaces) {
|
|
28
|
+
var multiplier = Math.pow(10, decimalPlaces);
|
|
29
|
+
return Math.round(value * multiplier) / multiplier;
|
|
30
|
+
}
|
|
31
|
+
exports.roundToDecimalPlaces = roundToDecimalPlaces;
|
|
32
|
+
//# sourceMappingURL=roundToDecimalPlaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundToDecimalPlaces.js","sourceRoot":"","sources":["../../src/benchmark/roundToDecimalPlaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,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,58 @@
|
|
|
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 FlashList from "../FlashList";
|
|
26
|
+
import { JSFPSResult } from "./JSFPSMonitor";
|
|
27
|
+
import { BlankAreaTrackerResult } from "./useBlankAreaTracker";
|
|
28
|
+
export interface BenchmarkParams {
|
|
29
|
+
startDelayInMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Can be used to increase or decrease speed of scrolling
|
|
32
|
+
*/
|
|
33
|
+
speedMultiplier?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Specify the number of times benchmark should repeat itself
|
|
36
|
+
*/
|
|
37
|
+
repeatCount?: number;
|
|
38
|
+
/**
|
|
39
|
+
* When set to true, cumulative blank area will include sum of negative blank area values
|
|
40
|
+
* Blank area is negative when list is able to draw faster than the scroll speed.
|
|
41
|
+
*/
|
|
42
|
+
sumNegativeBlankAreaValues?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface BenchmarkResult {
|
|
45
|
+
js?: JSFPSResult;
|
|
46
|
+
interrupted: boolean;
|
|
47
|
+
suggestions: string[];
|
|
48
|
+
blankArea?: BlankAreaTrackerResult;
|
|
49
|
+
formattedString?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Runs the benchmark on FlashList.
|
|
53
|
+
* Response object has a formatted string that can be printed to the console or shown as an alert.
|
|
54
|
+
* Result is posted to the callback method passed to the hook.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useBenchmark(flashListRef: React.RefObject<FlashList<any>>, callback: (benchmarkResult: BenchmarkResult) => void, params?: BenchmarkParams): ((event: import("..").BlankAreaEvent) => void)[];
|
|
57
|
+
export declare function getFormattedString(res: BenchmarkResult): string;
|
|
58
|
+
//# sourceMappingURL=useBenchmark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBenchmark.d.ts","sourceRoot":"","sources":["../../src/benchmark/useBenchmark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,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,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.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
|
+
}
|
|
190
|
+
//# sourceMappingURL=useBenchmark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,SAAS,EACT,EAAE,iBAAiB,EAAE,MAAM,CAAC,0BAA0B,EAAE,cAAc,EAAE,CAAC,EAAE,CAC5E,IAAA,EAJM,eAAe,QAAA,EAAE,gBAAgB,QAIvC,CAAC;IACF,IAAA,iBAAS,EAAC;;QACR,IAAM,WAAW,GAAG,IAAI,8BAAW,EAAE,CAAC;QACtC,IAAM,WAAW,GAAa,EAAE,CAAC;QACjC,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,CAAC,MAAA,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,0CAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1D,MAA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
|
|
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
|
+
//# sourceMappingURL=useBlankAreaTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlankAreaTracker.d.ts","sourceRoot":"","sources":["../../src/benchmark/useBlankAreaTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,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,CAAC,EAC7C,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,90 @@
|
|
|
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.useBlankAreaTracker = void 0;
|
|
27
|
+
var react_1 = require("react");
|
|
28
|
+
/**
|
|
29
|
+
* Can be used to track visible blank area in production
|
|
30
|
+
* @param flashListRef Ref to the FlashList component
|
|
31
|
+
* @param onBlankAreaChange This event handler will be called when the blank area changes
|
|
32
|
+
* @param config additional configuration for the blank area tracker
|
|
33
|
+
* @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
|
|
34
|
+
*/
|
|
35
|
+
function useBlankAreaTracker(flashListRef, onBlankAreaChange, config) {
|
|
36
|
+
var _a;
|
|
37
|
+
var startDelay = (_a = config === null || config === void 0 ? void 0 : config.startDelayInMs) !== null && _a !== void 0 ? _a : 1000;
|
|
38
|
+
var blankAreaResult = (0, react_1.useRef)({
|
|
39
|
+
maxBlankArea: 0,
|
|
40
|
+
cumulativeBlankArea: 0,
|
|
41
|
+
}).current;
|
|
42
|
+
var waitOperations = (0, react_1.useRef)({ inProgress: false, complete: false }).current;
|
|
43
|
+
var onBlankAreaChangeRef = (0, react_1.useRef)(onBlankAreaChange);
|
|
44
|
+
onBlankAreaChangeRef.current = onBlankAreaChange;
|
|
45
|
+
var blankAreaTracker = (0, react_1.useCallback)(function (event) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
// we're ignoring some of the events that will be fired on list load
|
|
48
|
+
// initial events are fired on mount and thus, this won't lead to missing events during scroll
|
|
49
|
+
if (!waitOperations.complete && startDelay > 0) {
|
|
50
|
+
if (!waitOperations.inProgress) {
|
|
51
|
+
waitOperations.inProgress = true;
|
|
52
|
+
setTimeout(function () {
|
|
53
|
+
waitOperations.complete = true;
|
|
54
|
+
}, startDelay);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var rlv = (_a = flashListRef.current) === null || _a === void 0 ? void 0 : _a.recyclerlistview_unsafe;
|
|
59
|
+
var horizontal = Boolean((_b = flashListRef.current) === null || _b === void 0 ? void 0 : _b.props.horizontal);
|
|
60
|
+
if (rlv) {
|
|
61
|
+
processBlankAreaChange(rlv, horizontal, blankAreaResult, event, onBlankAreaChangeRef.current, config);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
[flashListRef]);
|
|
66
|
+
return [blankAreaResult, blankAreaTracker];
|
|
67
|
+
}
|
|
68
|
+
exports.useBlankAreaTracker = useBlankAreaTracker;
|
|
69
|
+
function processBlankAreaChange(rlv, horizontal, blankAreaResult, event, onBlankAreaChange, config) {
|
|
70
|
+
var listSize = horizontal
|
|
71
|
+
? rlv.getRenderedSize().width
|
|
72
|
+
: rlv.getRenderedSize().height;
|
|
73
|
+
var contentSize = horizontal
|
|
74
|
+
? rlv.getContentDimension().width
|
|
75
|
+
: rlv.getContentDimension().height;
|
|
76
|
+
// ignores blank events when there isn't enough content to fill the list
|
|
77
|
+
if (contentSize > listSize) {
|
|
78
|
+
var lastMaxBlankArea = blankAreaResult.maxBlankArea;
|
|
79
|
+
var lastCumulativeBlankArea = blankAreaResult.cumulativeBlankArea;
|
|
80
|
+
blankAreaResult.maxBlankArea = Math.max(blankAreaResult.maxBlankArea, event.blankArea, 0);
|
|
81
|
+
blankAreaResult.cumulativeBlankArea += (config === null || config === void 0 ? void 0 : config.sumNegativeValues)
|
|
82
|
+
? event.blankArea
|
|
83
|
+
: Math.max(event.blankArea, 0);
|
|
84
|
+
if (lastCumulativeBlankArea !== blankAreaResult.cumulativeBlankArea ||
|
|
85
|
+
lastMaxBlankArea !== blankAreaResult.maxBlankArea) {
|
|
86
|
+
onBlankAreaChange === null || onBlankAreaChange === void 0 ? void 0 : onBlankAreaChange(blankAreaResult);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=useBlankAreaTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlankAreaTracker.js","sourceRoot":"","sources":["../../src/benchmark/useBlankAreaTracker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,+BAAmD;AA6BnD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,YAA6C,EAC7C,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,UAAU,EAAE;gBAC9B,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC;gBACjC,UAAU,CAAC;oBACT,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACjC,CAAC,EAAE,UAAU,CAAC,CAAC;aAChB;YACD,OAAO;SACR;QACD,IAAM,GAAG,GAA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C,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,32 @@
|
|
|
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
|
+
/**
|
|
25
|
+
* Increases the data size by duplicating it, it's kept in hook format so that in future we can add auto pagination support.
|
|
26
|
+
* 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.
|
|
27
|
+
* @param data The data to duplicate
|
|
28
|
+
* @param count Final count of data to be returned from this hook
|
|
29
|
+
* @returns Multiplied data.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useDataMultiplier<T>(data: T[], count: number): [T[]];
|
|
32
|
+
//# sourceMappingURL=useDataMultiplier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataMultiplier.d.ts","sourceRoot":"","sources":["../../src/benchmark/useDataMultiplier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAWpE"}
|