@react-native-ohos/react-native-reanimated 3.18.1-rc.1 → 3.18.1-rc.3

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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +10 -0
  4. package/harmony/reanimated/BuildProfile.ets +16 -16
  5. package/harmony/reanimated/build-profile.json5 +11 -11
  6. package/harmony/reanimated/oh-package.json5 +11 -11
  7. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
  8. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
  9. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
  10. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +68 -68
  11. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
  12. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
  13. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
  14. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +87 -87
  15. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -252
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +155 -155
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +182 -182
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
  80. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +33 -2
  81. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +57 -57
  82. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
  83. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +3 -0
  84. package/harmony/reanimated/src/main/module.json5 +12 -12
  85. package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
  86. package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
  87. package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
  88. package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
  89. package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
  90. package/harmony/reanimated/ts.ts +6 -6
  91. package/harmony/reanimated.har +0 -0
  92. package/package.json +50 -50
@@ -1,98 +1,98 @@
1
- #pragma once
2
-
3
- #include <jsi/jsi.h>
4
-
5
- #ifdef RCT_NEW_ARCH_ENABLED
6
- #include <react/renderer/core/ReactPrimitives.h>
7
- #endif
8
-
9
- #include <string>
10
- #include <utility>
11
- #include <vector>
12
-
13
- using namespace facebook;
14
-
15
- #ifdef RCT_NEW_ARCH_ENABLED
16
- using namespace react;
17
- #endif
18
-
19
- namespace reanimated {
20
-
21
- #ifdef RCT_NEW_ARCH_ENABLED
22
-
23
- using UpdatePropsFunction =
24
- std::function<void(jsi::Runtime &rt, const jsi::Value &operations)>;
25
- using ObtainPropFunction = std::function<jsi::Value(
26
- jsi::Runtime &rt,
27
- const jsi::Value &shadowNodeWrapper,
28
- const jsi::Value &propName)>;
29
- using DispatchCommandFunction = std::function<void(
30
- jsi::Runtime &rt,
31
- const jsi::Value &shadowNodeValue,
32
- const jsi::Value &commandNameValue,
33
- const jsi::Value &argsValue)>;
34
- using MeasureFunction = std::function<
35
- jsi::Value(jsi::Runtime &rt, const jsi::Value &shadowNodeValue)>;
36
-
37
- #else
38
-
39
- using UpdatePropsFunction =
40
- std::function<void(jsi::Runtime &rt, const jsi::Value &operations)>;
41
- using ScrollToFunction = std::function<void(int, double, double, bool)>;
42
- using DispatchCommandFunction = std::function<void(
43
- jsi::Runtime &rt,
44
- const int viewTag,
45
- const jsi::Value &commandNameValue,
46
- const jsi::Value &argsValue)>;
47
- using MeasureFunction =
48
- std::function<std::vector<std::pair<std::string, double>>(int)>;
49
- using ObtainPropFunction =
50
- std::function<jsi::Value(jsi::Runtime &, const int, const jsi::Value &)>;
51
-
52
- #endif // RCT_NEW_ARCH_ENABLED
53
-
54
- using RequestRenderFunction =
55
- std::function<void(std::function<void(const double)>)>;
56
- using GetAnimationTimestampFunction = std::function<double(void)>;
57
-
58
- using ProgressLayoutAnimationFunction =
59
- std::function<void(jsi::Runtime &, int, jsi::Object, bool)>;
60
- using EndLayoutAnimationFunction = std::function<void(int, bool)>;
61
-
62
- using RegisterSensorFunction =
63
- std::function<int(int, int, int, std::function<void(double[], int)>)>;
64
- using UnregisterSensorFunction = std::function<void(int)>;
65
- using SetGestureStateFunction = std::function<void(int, int)>;
66
- using ConfigurePropsFunction = std::function<void(
67
- jsi::Runtime &rt,
68
- const jsi::Value &uiProps,
69
- const jsi::Value &nativeProps)>;
70
- using KeyboardEventSubscribeFunction =
71
- std::function<int(std::function<void(int, int)>, bool, bool)>;
72
- using KeyboardEventUnsubscribeFunction = std::function<void(int)>;
73
- using MaybeFlushUIUpdatesQueueFunction = std::function<void()>;
74
-
75
- struct PlatformDepMethodsHolder {
76
- RequestRenderFunction requestRender;
77
- #ifdef RCT_NEW_ARCH_ENABLED
78
- // nothing
79
- #else
80
- UpdatePropsFunction updatePropsFunction;
81
- ScrollToFunction scrollToFunction;
82
- DispatchCommandFunction dispatchCommandFunction;
83
- MeasureFunction measureFunction;
84
- ConfigurePropsFunction configurePropsFunction;
85
- ObtainPropFunction obtainPropFunction;
86
- #endif
87
- GetAnimationTimestampFunction getAnimationTimestamp;
88
- ProgressLayoutAnimationFunction progressLayoutAnimation;
89
- EndLayoutAnimationFunction endLayoutAnimation;
90
- RegisterSensorFunction registerSensor;
91
- UnregisterSensorFunction unregisterSensor;
92
- SetGestureStateFunction setGestureStateFunction;
93
- KeyboardEventSubscribeFunction subscribeForKeyboardEvents;
94
- KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEvents;
95
- MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueueFunction;
96
- };
97
-
98
- } // namespace reanimated
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #include <react/renderer/core/ReactPrimitives.h>
7
+ #endif
8
+
9
+ #include <string>
10
+ #include <utility>
11
+ #include <vector>
12
+
13
+ using namespace facebook;
14
+
15
+ #ifdef RCT_NEW_ARCH_ENABLED
16
+ using namespace react;
17
+ #endif
18
+
19
+ namespace reanimated {
20
+
21
+ #ifdef RCT_NEW_ARCH_ENABLED
22
+
23
+ using UpdatePropsFunction =
24
+ std::function<void(jsi::Runtime &rt, const jsi::Value &operations)>;
25
+ using ObtainPropFunction = std::function<jsi::Value(
26
+ jsi::Runtime &rt,
27
+ const jsi::Value &shadowNodeWrapper,
28
+ const jsi::Value &propName)>;
29
+ using DispatchCommandFunction = std::function<void(
30
+ jsi::Runtime &rt,
31
+ const jsi::Value &shadowNodeValue,
32
+ const jsi::Value &commandNameValue,
33
+ const jsi::Value &argsValue)>;
34
+ using MeasureFunction = std::function<
35
+ jsi::Value(jsi::Runtime &rt, const jsi::Value &shadowNodeValue)>;
36
+
37
+ #else
38
+
39
+ using UpdatePropsFunction =
40
+ std::function<void(jsi::Runtime &rt, const jsi::Value &operations)>;
41
+ using ScrollToFunction = std::function<void(int, double, double, bool)>;
42
+ using DispatchCommandFunction = std::function<void(
43
+ jsi::Runtime &rt,
44
+ const int viewTag,
45
+ const jsi::Value &commandNameValue,
46
+ const jsi::Value &argsValue)>;
47
+ using MeasureFunction =
48
+ std::function<std::vector<std::pair<std::string, double>>(int)>;
49
+ using ObtainPropFunction =
50
+ std::function<jsi::Value(jsi::Runtime &, const int, const jsi::Value &)>;
51
+
52
+ #endif // RCT_NEW_ARCH_ENABLED
53
+
54
+ using RequestRenderFunction =
55
+ std::function<void(std::function<void(const double)>)>;
56
+ using GetAnimationTimestampFunction = std::function<double(void)>;
57
+
58
+ using ProgressLayoutAnimationFunction =
59
+ std::function<void(jsi::Runtime &, int, jsi::Object, bool)>;
60
+ using EndLayoutAnimationFunction = std::function<void(int, bool)>;
61
+
62
+ using RegisterSensorFunction =
63
+ std::function<int(int, int, int, std::function<void(double[], int)>)>;
64
+ using UnregisterSensorFunction = std::function<void(int)>;
65
+ using SetGestureStateFunction = std::function<void(int, int)>;
66
+ using ConfigurePropsFunction = std::function<void(
67
+ jsi::Runtime &rt,
68
+ const jsi::Value &uiProps,
69
+ const jsi::Value &nativeProps)>;
70
+ using KeyboardEventSubscribeFunction =
71
+ std::function<int(std::function<void(int, int)>, bool, bool)>;
72
+ using KeyboardEventUnsubscribeFunction = std::function<void(int)>;
73
+ using MaybeFlushUIUpdatesQueueFunction = std::function<void()>;
74
+
75
+ struct PlatformDepMethodsHolder {
76
+ RequestRenderFunction requestRender;
77
+ #ifdef RCT_NEW_ARCH_ENABLED
78
+ // nothing
79
+ #else
80
+ UpdatePropsFunction updatePropsFunction;
81
+ ScrollToFunction scrollToFunction;
82
+ DispatchCommandFunction dispatchCommandFunction;
83
+ MeasureFunction measureFunction;
84
+ ConfigurePropsFunction configurePropsFunction;
85
+ ObtainPropFunction obtainPropFunction;
86
+ #endif
87
+ GetAnimationTimestampFunction getAnimationTimestamp;
88
+ ProgressLayoutAnimationFunction progressLayoutAnimation;
89
+ EndLayoutAnimationFunction endLayoutAnimation;
90
+ RegisterSensorFunction registerSensor;
91
+ UnregisterSensorFunction unregisterSensor;
92
+ SetGestureStateFunction setGestureStateFunction;
93
+ KeyboardEventSubscribeFunction subscribeForKeyboardEvents;
94
+ KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEvents;
95
+ MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueueFunction;
96
+ };
97
+
98
+ } // namespace reanimated
@@ -1,135 +1,135 @@
1
- #pragma once
2
- #include <string>
3
- #include <vector>
4
-
5
- #ifdef REANIMATED_PROFILING
6
-
7
- #if defined(__APPLE__)
8
- #include <os/trace_base.h>
9
-
10
- #if OS_LOG_TARGET_HAS_10_15_FEATURES
11
- #include <os/log.h>
12
- #include <os/signpost.h>
13
- #include <sstream>
14
- #endif // OS_LOG_TARGET_HAS_10_15_FEATURES
15
-
16
- #elif defined(ANDROID)
17
-
18
- #include <android/trace.h>
19
-
20
- #endif // defined(ANDROID)
21
-
22
- #endif // REANIMATED_PROFILING
23
-
24
- namespace reanimated {
25
-
26
- #if defined(ANDROID) && defined(REANIMATED_PROFILING)
27
-
28
- struct ReanimatedSystraceSection {
29
- public:
30
- template <typename... ConvertsToStringPiece>
31
- explicit ReanimatedSystraceSection(
32
- const char *name,
33
- ConvertsToStringPiece &&...args) {
34
- ATrace_beginSection(name);
35
- }
36
-
37
- ~ReanimatedSystraceSection() {
38
- ATrace_endSection();
39
- }
40
- };
41
-
42
- // The apple part is copied from React Native
43
- // from
44
- // https://github.com/facebook/react-native/blob/5697d923a05119314b4cfcd556cb243986637764/packages/react-native/ReactCommon/cxxreact/SystraceSection.h
45
- #elif defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && \
46
- defined(REANIMATED_PROFILING)
47
-
48
- template <typename T, typename = void>
49
- struct renderer {
50
- static std::string render(const T &t) {
51
- std::ostringstream oss;
52
- oss << t;
53
- return oss.str();
54
- }
55
- };
56
-
57
- template <typename T>
58
- static auto render(const T &t)
59
- -> decltype(renderer<T>::render(std::declval<const T &>())) {
60
- return renderer<T>::render(t);
61
- }
62
-
63
- inline os_log_t instrumentsLogHandle = nullptr;
64
-
65
- static inline os_log_t getOrCreateInstrumentsLogHandle() {
66
- if (!instrumentsLogHandle) {
67
- instrumentsLogHandle = os_log_create(
68
- "dev.reanimated.instruments", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
69
- }
70
- return instrumentsLogHandle;
71
- }
72
-
73
- struct ReanimatedSystraceSection {
74
- public:
75
- template <typename... ConvertsToStringPiece>
76
- explicit ReanimatedSystraceSection(
77
- const char *name,
78
- ConvertsToStringPiece &&...args) {
79
- os_log_t instrumentsLogHandle =
80
- reanimated::getOrCreateInstrumentsLogHandle();
81
-
82
- // If the log isn't enabled, we don't want the performance overhead of the
83
- // rest of the code below.
84
- if (!os_signpost_enabled(instrumentsLogHandle)) {
85
- return;
86
- }
87
-
88
- name_ = name;
89
-
90
- const auto argsVector =
91
- std::vector<std::string>{reanimated::render(args)...};
92
- std::string argsString = "";
93
- for (size_t i = 0; i < argsVector.size(); i += 2) {
94
- argsString += argsVector[i] + "=" + argsVector[i + 1] + ";";
95
- }
96
-
97
- signpostID_ = os_signpost_id_make_with_pointer(instrumentsLogHandle, this);
98
-
99
- os_signpost_interval_begin(
100
- instrumentsLogHandle,
101
- signpostID_,
102
- "Reanimated",
103
- "%s begin: %s",
104
- name,
105
- argsString.c_str());
106
- }
107
-
108
- ~ReanimatedSystraceSection() {
109
- os_signpost_interval_end(
110
- reanimated::instrumentsLogHandle,
111
- signpostID_,
112
- "Reanimated",
113
- "%s end",
114
- name_.data());
115
- }
116
-
117
- private:
118
- os_signpost_id_t signpostID_ = OS_SIGNPOST_ID_INVALID;
119
- std::string_view name_;
120
- };
121
-
122
- #else
123
-
124
- struct ReanimatedSystraceSection {
125
- public:
126
- template <typename... ConvertsToStringPiece>
127
- explicit ReanimatedSystraceSection(
128
- const char *name,
129
- ConvertsToStringPiece &&...args) {}
130
- };
131
-
132
- #endif // defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES &&
133
- // defined(REANIMATED_PROFILING)
134
-
135
- } // namespace reanimated
1
+ #pragma once
2
+ #include <string>
3
+ #include <vector>
4
+
5
+ #ifdef REANIMATED_PROFILING
6
+
7
+ #if defined(__APPLE__)
8
+ #include <os/trace_base.h>
9
+
10
+ #if OS_LOG_TARGET_HAS_10_15_FEATURES
11
+ #include <os/log.h>
12
+ #include <os/signpost.h>
13
+ #include <sstream>
14
+ #endif // OS_LOG_TARGET_HAS_10_15_FEATURES
15
+
16
+ #elif defined(ANDROID)
17
+
18
+ #include <android/trace.h>
19
+
20
+ #endif // defined(ANDROID)
21
+
22
+ #endif // REANIMATED_PROFILING
23
+
24
+ namespace reanimated {
25
+
26
+ #if defined(ANDROID) && defined(REANIMATED_PROFILING)
27
+
28
+ struct ReanimatedSystraceSection {
29
+ public:
30
+ template <typename... ConvertsToStringPiece>
31
+ explicit ReanimatedSystraceSection(
32
+ const char *name,
33
+ ConvertsToStringPiece &&...args) {
34
+ ATrace_beginSection(name);
35
+ }
36
+
37
+ ~ReanimatedSystraceSection() {
38
+ ATrace_endSection();
39
+ }
40
+ };
41
+
42
+ // The apple part is copied from React Native
43
+ // from
44
+ // https://github.com/facebook/react-native/blob/5697d923a05119314b4cfcd556cb243986637764/packages/react-native/ReactCommon/cxxreact/SystraceSection.h
45
+ #elif defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && \
46
+ defined(REANIMATED_PROFILING)
47
+
48
+ template <typename T, typename = void>
49
+ struct renderer {
50
+ static std::string render(const T &t) {
51
+ std::ostringstream oss;
52
+ oss << t;
53
+ return oss.str();
54
+ }
55
+ };
56
+
57
+ template <typename T>
58
+ static auto render(const T &t)
59
+ -> decltype(renderer<T>::render(std::declval<const T &>())) {
60
+ return renderer<T>::render(t);
61
+ }
62
+
63
+ inline os_log_t instrumentsLogHandle = nullptr;
64
+
65
+ static inline os_log_t getOrCreateInstrumentsLogHandle() {
66
+ if (!instrumentsLogHandle) {
67
+ instrumentsLogHandle = os_log_create(
68
+ "dev.reanimated.instruments", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
69
+ }
70
+ return instrumentsLogHandle;
71
+ }
72
+
73
+ struct ReanimatedSystraceSection {
74
+ public:
75
+ template <typename... ConvertsToStringPiece>
76
+ explicit ReanimatedSystraceSection(
77
+ const char *name,
78
+ ConvertsToStringPiece &&...args) {
79
+ os_log_t instrumentsLogHandle =
80
+ reanimated::getOrCreateInstrumentsLogHandle();
81
+
82
+ // If the log isn't enabled, we don't want the performance overhead of the
83
+ // rest of the code below.
84
+ if (!os_signpost_enabled(instrumentsLogHandle)) {
85
+ return;
86
+ }
87
+
88
+ name_ = name;
89
+
90
+ const auto argsVector =
91
+ std::vector<std::string>{reanimated::render(args)...};
92
+ std::string argsString = "";
93
+ for (size_t i = 0; i < argsVector.size(); i += 2) {
94
+ argsString += argsVector[i] + "=" + argsVector[i + 1] + ";";
95
+ }
96
+
97
+ signpostID_ = os_signpost_id_make_with_pointer(instrumentsLogHandle, this);
98
+
99
+ os_signpost_interval_begin(
100
+ instrumentsLogHandle,
101
+ signpostID_,
102
+ "Reanimated",
103
+ "%s begin: %s",
104
+ name,
105
+ argsString.c_str());
106
+ }
107
+
108
+ ~ReanimatedSystraceSection() {
109
+ os_signpost_interval_end(
110
+ reanimated::instrumentsLogHandle,
111
+ signpostID_,
112
+ "Reanimated",
113
+ "%s end",
114
+ name_.data());
115
+ }
116
+
117
+ private:
118
+ os_signpost_id_t signpostID_ = OS_SIGNPOST_ID_INVALID;
119
+ std::string_view name_;
120
+ };
121
+
122
+ #else
123
+
124
+ struct ReanimatedSystraceSection {
125
+ public:
126
+ template <typename... ConvertsToStringPiece>
127
+ explicit ReanimatedSystraceSection(
128
+ const char *name,
129
+ ConvertsToStringPiece &&...args) {}
130
+ };
131
+
132
+ #endif // defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES &&
133
+ // defined(REANIMATED_PROFILING)
134
+
135
+ } // namespace reanimated
@@ -1,47 +1,47 @@
1
- #include <string>
2
-
3
- #ifdef RCT_NEW_ARCH_ENABLED
4
- #include <react/renderer/uimanager/UIManagerBinding.h>
5
- #include <react/renderer/uimanager/primitives.h>
6
- #endif // RCT_NEW_ARCH_ENABLED
7
-
8
- #include <worklets/NativeModules/WorkletsModuleProxy.h>
9
- #include <worklets/SharedItems/Shareables.h>
10
- #include <worklets/Tools/Defs.h>
11
-
12
- #ifdef __ANDROID__
13
- #include <fbjni/fbjni.h>
14
- #endif // __ANDROID__
15
-
16
- #include <jsi/jsi.h>
17
-
18
- using namespace facebook;
19
-
20
- namespace worklets {
21
-
22
- WorkletsModuleProxy::WorkletsModuleProxy(
23
- const std::string &valueUnpackerCode,
24
- const std::shared_ptr<MessageQueueThread> &jsQueue,
25
- const std::shared_ptr<CallInvoker> &jsCallInvoker,
26
- const std::shared_ptr<JSScheduler> &jsScheduler,
27
- const std::shared_ptr<UIScheduler> &uiScheduler)
28
- : WorkletsModuleProxySpec(jsCallInvoker),
29
- valueUnpackerCode_(valueUnpackerCode),
30
- jsQueue_(jsQueue),
31
- jsScheduler_(jsScheduler),
32
- uiScheduler_(uiScheduler) {}
33
-
34
- WorkletsModuleProxy::~WorkletsModuleProxy() {}
35
-
36
- jsi::Value WorkletsModuleProxy::makeShareableClone(
37
- jsi::Runtime &rt,
38
- const jsi::Value &value,
39
- const jsi::Value &shouldRetainRemote,
40
- const jsi::Value &nativeStateSource) {
41
- // TODO: It might be a good idea to rename one of these methods to avoid
42
- // confusion.
43
- return worklets::makeShareableClone(
44
- rt, value, shouldRetainRemote, nativeStateSource);
45
- }
46
-
47
- } // namespace worklets
1
+ #include <string>
2
+
3
+ #ifdef RCT_NEW_ARCH_ENABLED
4
+ #include <react/renderer/uimanager/UIManagerBinding.h>
5
+ #include <react/renderer/uimanager/primitives.h>
6
+ #endif // RCT_NEW_ARCH_ENABLED
7
+
8
+ #include <worklets/NativeModules/WorkletsModuleProxy.h>
9
+ #include <worklets/SharedItems/Shareables.h>
10
+ #include <worklets/Tools/Defs.h>
11
+
12
+ #ifdef __ANDROID__
13
+ #include <fbjni/fbjni.h>
14
+ #endif // __ANDROID__
15
+
16
+ #include <jsi/jsi.h>
17
+
18
+ using namespace facebook;
19
+
20
+ namespace worklets {
21
+
22
+ WorkletsModuleProxy::WorkletsModuleProxy(
23
+ const std::string &valueUnpackerCode,
24
+ const std::shared_ptr<MessageQueueThread> &jsQueue,
25
+ const std::shared_ptr<CallInvoker> &jsCallInvoker,
26
+ const std::shared_ptr<JSScheduler> &jsScheduler,
27
+ const std::shared_ptr<UIScheduler> &uiScheduler)
28
+ : WorkletsModuleProxySpec(jsCallInvoker),
29
+ valueUnpackerCode_(valueUnpackerCode),
30
+ jsQueue_(jsQueue),
31
+ jsScheduler_(jsScheduler),
32
+ uiScheduler_(uiScheduler) {}
33
+
34
+ WorkletsModuleProxy::~WorkletsModuleProxy() {}
35
+
36
+ jsi::Value WorkletsModuleProxy::makeShareableClone(
37
+ jsi::Runtime &rt,
38
+ const jsi::Value &value,
39
+ const jsi::Value &shouldRetainRemote,
40
+ const jsi::Value &nativeStateSource) {
41
+ // TODO: It might be a good idea to rename one of these methods to avoid
42
+ // confusion.
43
+ return worklets::makeShareableClone(
44
+ rt, value, shouldRetainRemote, nativeStateSource);
45
+ }
46
+
47
+ } // namespace worklets