@react-native-ohos/react-native-reanimated 3.18.2 → 3.18.3-beta.2

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 (94) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +10 -10
  4. package/harmony/reanimated/BuildProfile.ets +1 -1
  5. package/harmony/reanimated/build-profile.json5 +11 -11
  6. package/harmony/reanimated/oh-package-lock.json5 +29 -0
  7. package/harmony/reanimated/oh-package.json5 +11 -11
  8. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
  9. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
  10. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
  11. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +73 -68
  12. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
  13. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
  14. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
  15. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -96
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -254
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -173
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -189
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
  81. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +4 -6
  82. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
  83. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
  84. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +22 -4
  85. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +88 -13
  86. package/harmony/reanimated/src/main/module.json5 +12 -12
  87. package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
  88. package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
  89. package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
  90. package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
  91. package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
  92. package/harmony/reanimated/ts.ts +6 -6
  93. package/harmony/reanimated.har +0 -0
  94. package/package.json +51 -50
@@ -1,189 +1,189 @@
1
- #include <worklets/SharedItems/Shareables.h>
2
- #include <worklets/Tools/JSISerializer.h>
3
- #include <worklets/Tools/PlatformLogger.h>
4
- #include <worklets/Tools/ReanimatedJSIUtils.h>
5
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
6
- #include <worklets/WorkletRuntime/WorkletRuntimeDecorator.h>
7
-
8
- #include <vector>
9
-
10
- namespace worklets {
11
-
12
- static inline double performanceNow() {
13
- // copied from JSExecutor.cpp
14
- auto time = std::chrono::steady_clock::now();
15
- auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
16
- time.time_since_epoch())
17
- .count();
18
-
19
- constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
20
- return duration / NANOSECONDS_IN_MILLISECOND;
21
- }
22
-
23
- static inline std::vector<jsi::Value> parseArgs(
24
- jsi::Runtime &rt,
25
- std::shared_ptr<ShareableArray> shareableArgs) {
26
- if (shareableArgs == nullptr) {
27
- return {};
28
- }
29
-
30
- auto argsArray = shareableArgs->toJSValue(rt).asObject(rt).asArray(rt);
31
- auto argsSize = argsArray.size(rt);
32
- std::vector<jsi::Value> result(argsSize);
33
- for (size_t i = 0; i < argsSize; i++) {
34
- result[i] = argsArray.getValueAtIndex(rt, i);
35
- }
36
- return result;
37
- }
38
-
39
- void WorkletRuntimeDecorator::decorate(
40
- jsi::Runtime &rt,
41
- const std::string &name,
42
- const std::shared_ptr<JSScheduler> &jsScheduler) {
43
- // resolves "ReferenceError: Property 'global' doesn't exist at ..."
44
- rt.global().setProperty(rt, "global", rt.global());
45
-
46
- rt.global().setProperty(rt, "_WORKLET", true);
47
-
48
- rt.global().setProperty(rt, "_LABEL", jsi::String::createFromAscii(rt, name));
49
-
50
- #ifdef RCT_NEW_ARCH_ENABLED
51
- constexpr auto isFabric = true;
52
- #else
53
- constexpr auto isFabric = false;
54
- #endif // RCT_NEW_ARCH_ENABLED
55
- rt.global().setProperty(rt, "_IS_FABRIC", isFabric);
56
-
57
- #ifndef NDEBUG
58
- auto evalWithSourceUrl = [](jsi::Runtime &rt,
59
- const jsi::Value &thisValue,
60
- const jsi::Value *args,
61
- size_t count) -> jsi::Value {
62
- auto code = std::make_shared<const jsi::StringBuffer>(
63
- args[0].asString(rt).utf8(rt));
64
- std::string url;
65
- if (count > 1 && args[1].isString()) {
66
- url = args[1].asString(rt).utf8(rt);
67
- }
68
- return rt.evaluateJavaScript(code, url);
69
- };
70
- rt.global().setProperty(
71
- rt,
72
- "evalWithSourceUrl",
73
- jsi::Function::createFromHostFunction(
74
- rt,
75
- jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
76
- 1,
77
- evalWithSourceUrl));
78
- #endif // NDEBUG
79
-
80
- jsi_utils::installJsiFunction(
81
- rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
82
- PlatformLogger::log(stringifyJSIValue(rt, value));
83
- });
84
-
85
- jsi_utils::installJsiFunction(
86
- rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
87
- return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
88
- });
89
-
90
- jsi_utils::installJsiFunction(
91
- rt,
92
- "_makeShareableClone",
93
- [](jsi::Runtime &rt,
94
- const jsi::Value &value,
95
- const jsi::Value &nativeStateSource) {
96
- auto shouldRetainRemote = jsi::Value::undefined();
97
- return makeShareableClone(
98
- rt, value, shouldRetainRemote, nativeStateSource);
99
- });
100
-
101
- jsi_utils::installJsiFunction(
102
- rt,
103
- "_scheduleRemoteFunctionOnJS",
104
- [jsScheduler](
105
- jsi::Runtime &rt,
106
- const jsi::Value &funValue,
107
- const jsi::Value &argsValue) {
108
- auto shareableRemoteFun = extractShareableOrThrow<
109
- ShareableRemoteFunction>(
110
- rt,
111
- funValue,
112
- "[Reanimated] Incompatible object passed to scheduleOnJS. It is only allowed to schedule worklets or functions defined on the React Native JS runtime this way.");
113
-
114
- auto shareableArgs = argsValue.isUndefined()
115
- ? nullptr
116
- : extractShareableOrThrow<ShareableArray>(
117
- rt, argsValue, "[Reanimated] Args must be an array.");
118
-
119
- jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
120
- auto fun =
121
- shareableRemoteFun->toJSValue(rt).asObject(rt).asFunction(rt);
122
- if (shareableArgs == nullptr) {
123
- // fast path for remote function w/o arguments
124
- fun.call(rt);
125
- } else {
126
- auto args = parseArgs(rt, shareableArgs);
127
- fun.call(
128
- rt, const_cast<const jsi::Value *>(args.data()), args.size());
129
- }
130
- });
131
- });
132
-
133
- jsi_utils::installJsiFunction(
134
- rt,
135
- "_scheduleHostFunctionOnJS",
136
- [jsScheduler](
137
- jsi::Runtime &rt,
138
- const jsi::Value &hostFunValue,
139
- const jsi::Value &argsValue) {
140
- if (hostFunValue.isUndefined() || !hostFunValue.isObject()) {
141
- return;
142
- }
143
- auto hostFunObject = hostFunValue.asObject(rt);
144
- if (!hostFunObject.isFunction(rt) || !hostFunObject.asFunction(rt).isHostFunction(rt)) {
145
- return;
146
- }
147
- auto hostFun =
148
- hostFunObject.asFunction(rt).getHostFunction(rt);
149
-
150
- auto shareableArgs = argsValue.isUndefined()
151
- ? nullptr
152
- : extractShareableOrThrow<ShareableArray>(
153
- rt, argsValue, "[Reanimated] Args must be an array.");
154
-
155
- jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
156
- auto args = parseArgs(rt, shareableArgs);
157
- hostFun(
158
- rt,
159
- jsi::Value::undefined(),
160
- const_cast<const jsi::Value *>(args.data()),
161
- args.size());
162
- });
163
- });
164
-
165
- jsi_utils::installJsiFunction(
166
- rt,
167
- "_scheduleOnRuntime",
168
- [](jsi::Runtime &rt,
169
- const jsi::Value &workletRuntimeValue,
170
- const jsi::Value &shareableWorkletValue) {
171
- scheduleOnRuntime(rt, workletRuntimeValue, shareableWorkletValue);
172
- });
173
-
174
- jsi::Object performance(rt);
175
- performance.setProperty(
176
- rt,
177
- "now",
178
- jsi::Function::createFromHostFunction(
179
- rt,
180
- jsi::PropNameID::forAscii(rt, "now"),
181
- 0,
182
- [](jsi::Runtime &runtime,
183
- const jsi::Value &,
184
- const jsi::Value *args,
185
- size_t count) { return jsi::Value(performanceNow()); }));
186
- rt.global().setProperty(rt, "performance", performance);
187
- }
188
-
189
- } // namespace worklets
1
+ #include <worklets/SharedItems/Shareables.h>
2
+ #include <worklets/Tools/JSISerializer.h>
3
+ #include <worklets/Tools/PlatformLogger.h>
4
+ #include <worklets/Tools/ReanimatedJSIUtils.h>
5
+ #include <worklets/WorkletRuntime/WorkletRuntime.h>
6
+ #include <worklets/WorkletRuntime/WorkletRuntimeDecorator.h>
7
+
8
+ #include <vector>
9
+
10
+ namespace worklets {
11
+
12
+ static inline double performanceNow() {
13
+ // copied from JSExecutor.cpp
14
+ auto time = std::chrono::steady_clock::now();
15
+ auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
16
+ time.time_since_epoch())
17
+ .count();
18
+
19
+ constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
20
+ return duration / NANOSECONDS_IN_MILLISECOND;
21
+ }
22
+
23
+ static inline std::vector<jsi::Value> parseArgs(
24
+ jsi::Runtime &rt,
25
+ std::shared_ptr<ShareableArray> shareableArgs) {
26
+ if (shareableArgs == nullptr) {
27
+ return {};
28
+ }
29
+
30
+ auto argsArray = shareableArgs->toJSValue(rt).asObject(rt).asArray(rt);
31
+ auto argsSize = argsArray.size(rt);
32
+ std::vector<jsi::Value> result(argsSize);
33
+ for (size_t i = 0; i < argsSize; i++) {
34
+ result[i] = argsArray.getValueAtIndex(rt, i);
35
+ }
36
+ return result;
37
+ }
38
+
39
+ void WorkletRuntimeDecorator::decorate(
40
+ jsi::Runtime &rt,
41
+ const std::string &name,
42
+ const std::shared_ptr<JSScheduler> &jsScheduler) {
43
+ // resolves "ReferenceError: Property 'global' doesn't exist at ..."
44
+ rt.global().setProperty(rt, "global", rt.global());
45
+
46
+ rt.global().setProperty(rt, "_WORKLET", true);
47
+
48
+ rt.global().setProperty(rt, "_LABEL", jsi::String::createFromAscii(rt, name));
49
+
50
+ #ifdef RCT_NEW_ARCH_ENABLED
51
+ constexpr auto isFabric = true;
52
+ #else
53
+ constexpr auto isFabric = false;
54
+ #endif // RCT_NEW_ARCH_ENABLED
55
+ rt.global().setProperty(rt, "_IS_FABRIC", isFabric);
56
+
57
+ #ifndef NDEBUG
58
+ auto evalWithSourceUrl = [](jsi::Runtime &rt,
59
+ const jsi::Value &thisValue,
60
+ const jsi::Value *args,
61
+ size_t count) -> jsi::Value {
62
+ auto code = std::make_shared<const jsi::StringBuffer>(
63
+ args[0].asString(rt).utf8(rt));
64
+ std::string url;
65
+ if (count > 1 && args[1].isString()) {
66
+ url = args[1].asString(rt).utf8(rt);
67
+ }
68
+ return rt.evaluateJavaScript(code, url);
69
+ };
70
+ rt.global().setProperty(
71
+ rt,
72
+ "evalWithSourceUrl",
73
+ jsi::Function::createFromHostFunction(
74
+ rt,
75
+ jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
76
+ 1,
77
+ evalWithSourceUrl));
78
+ #endif // NDEBUG
79
+
80
+ jsi_utils::installJsiFunction(
81
+ rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
82
+ PlatformLogger::log(stringifyJSIValue(rt, value));
83
+ });
84
+
85
+ jsi_utils::installJsiFunction(
86
+ rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
87
+ return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
88
+ });
89
+
90
+ jsi_utils::installJsiFunction(
91
+ rt,
92
+ "_makeShareableClone",
93
+ [](jsi::Runtime &rt,
94
+ const jsi::Value &value,
95
+ const jsi::Value &nativeStateSource) {
96
+ auto shouldRetainRemote = jsi::Value::undefined();
97
+ return makeShareableClone(
98
+ rt, value, shouldRetainRemote, nativeStateSource);
99
+ });
100
+
101
+ jsi_utils::installJsiFunction(
102
+ rt,
103
+ "_scheduleRemoteFunctionOnJS",
104
+ [jsScheduler](
105
+ jsi::Runtime &rt,
106
+ const jsi::Value &funValue,
107
+ const jsi::Value &argsValue) {
108
+ auto shareableRemoteFun = extractShareableOrThrow<
109
+ ShareableRemoteFunction>(
110
+ rt,
111
+ funValue,
112
+ "[Reanimated] Incompatible object passed to scheduleOnJS. It is only allowed to schedule worklets or functions defined on the React Native JS runtime this way.");
113
+
114
+ auto shareableArgs = argsValue.isUndefined()
115
+ ? nullptr
116
+ : extractShareableOrThrow<ShareableArray>(
117
+ rt, argsValue, "[Reanimated] Args must be an array.");
118
+
119
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
120
+ auto fun =
121
+ shareableRemoteFun->toJSValue(rt).asObject(rt).asFunction(rt);
122
+ if (shareableArgs == nullptr) {
123
+ // fast path for remote function w/o arguments
124
+ fun.call(rt);
125
+ } else {
126
+ auto args = parseArgs(rt, shareableArgs);
127
+ fun.call(
128
+ rt, const_cast<const jsi::Value *>(args.data()), args.size());
129
+ }
130
+ });
131
+ });
132
+
133
+ jsi_utils::installJsiFunction(
134
+ rt,
135
+ "_scheduleHostFunctionOnJS",
136
+ [jsScheduler](
137
+ jsi::Runtime &rt,
138
+ const jsi::Value &hostFunValue,
139
+ const jsi::Value &argsValue) {
140
+ if (hostFunValue.isUndefined() || !hostFunValue.isObject()) {
141
+ return;
142
+ }
143
+ auto hostFunObject = hostFunValue.asObject(rt);
144
+ if (!hostFunObject.isFunction(rt) || !hostFunObject.asFunction(rt).isHostFunction(rt)) {
145
+ return;
146
+ }
147
+ auto hostFun =
148
+ hostFunObject.asFunction(rt).getHostFunction(rt);
149
+
150
+ auto shareableArgs = argsValue.isUndefined()
151
+ ? nullptr
152
+ : extractShareableOrThrow<ShareableArray>(
153
+ rt, argsValue, "[Reanimated] Args must be an array.");
154
+
155
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
156
+ auto args = parseArgs(rt, shareableArgs);
157
+ hostFun(
158
+ rt,
159
+ jsi::Value::undefined(),
160
+ const_cast<const jsi::Value *>(args.data()),
161
+ args.size());
162
+ });
163
+ });
164
+
165
+ jsi_utils::installJsiFunction(
166
+ rt,
167
+ "_scheduleOnRuntime",
168
+ [](jsi::Runtime &rt,
169
+ const jsi::Value &workletRuntimeValue,
170
+ const jsi::Value &shareableWorkletValue) {
171
+ scheduleOnRuntime(rt, workletRuntimeValue, shareableWorkletValue);
172
+ });
173
+
174
+ jsi::Object performance(rt);
175
+ performance.setProperty(
176
+ rt,
177
+ "now",
178
+ jsi::Function::createFromHostFunction(
179
+ rt,
180
+ jsi::PropNameID::forAscii(rt, "now"),
181
+ 0,
182
+ [](jsi::Runtime &runtime,
183
+ const jsi::Value &,
184
+ const jsi::Value *args,
185
+ size_t count) { return jsi::Value(performanceNow()); }));
186
+ rt.global().setProperty(rt, "performance", performance);
187
+ }
188
+
189
+ } // namespace worklets
@@ -1,22 +1,22 @@
1
- #pragma once
2
-
3
- #include <worklets/Tools/JSScheduler.h>
4
-
5
- #include <jsi/jsi.h>
6
-
7
- #include <memory>
8
- #include <string>
9
-
10
- using namespace facebook;
11
-
12
- namespace worklets {
13
-
14
- class WorkletRuntimeDecorator {
15
- public:
16
- static void decorate(
17
- jsi::Runtime &rt,
18
- const std::string &name,
19
- const std::shared_ptr<JSScheduler> &jsScheduler);
20
- };
21
-
22
- } // namespace worklets
1
+ #pragma once
2
+
3
+ #include <worklets/Tools/JSScheduler.h>
4
+
5
+ #include <jsi/jsi.h>
6
+
7
+ #include <memory>
8
+ #include <string>
9
+
10
+ using namespace facebook;
11
+
12
+ namespace worklets {
13
+
14
+ class WorkletRuntimeDecorator {
15
+ public:
16
+ static void decorate(
17
+ jsi::Runtime &rt,
18
+ const std::string &name,
19
+ const std::shared_ptr<JSScheduler> &jsScheduler);
20
+ };
21
+
22
+ } // namespace worklets
@@ -50,9 +50,6 @@ ReanimatedModule::~ReanimatedModule()
50
50
  if (keyboardEventDataUpdater_) {
51
51
  keyboardEventDataUpdater_ = nullptr;
52
52
  }
53
- if (auto nativeReanimatedModule = weakNativeReanimatedModule_.lock()) {
54
- nativeReanimatedModule->invalidate();
55
- }
56
53
  }
57
54
 
58
55
  void ReanimatedModule::installTurboModule(facebook::jsi::Runtime &rt)
@@ -108,11 +105,12 @@ void ReanimatedModule::installTurboModule(facebook::jsi::Runtime &rt)
108
105
  self->keyboardEventDataUpdater_ = std::move(keyboardEventDataUpdater);
109
106
  auto weakExecutor = std::weak_ptr(self->m_ctx.taskExecutor);
110
107
  if (auto taskExecutor = weakExecutor.lock()) {
111
- taskExecutor->runTask(TaskThread::MAIN, [ctx = self->m_ctx, isStatusBarTranslucent]() {
108
+ taskExecutor->runTask(TaskThread::MAIN, [ctx = self->m_ctx, isStatusBarTranslucent, isNavigationBarTranslucent]() {
112
109
  ArkJS arkJs(ctx.env);
113
- // arkJs.createBoolean(isStatusBarTranslucent);
110
+ auto isStatusBarTranslucentValue = arkJs.createBoolean(isStatusBarTranslucent);
111
+ auto isNavigationBarTranslucentValue = arkJs.createBoolean(isNavigationBarTranslucent);
114
112
  auto napiTurboModuleObject = arkJs.getObject(ctx.arkTSTurboModuleInstanceRef);
115
- napiTurboModuleObject.call("subscribeKeyBordListeners", {});
113
+ napiTurboModuleObject.call("subscribeKeyBordListeners", {isStatusBarTranslucentValue, isNavigationBarTranslucentValue});
116
114
  });
117
115
  }
118
116
  return 0;
@@ -1,61 +1,61 @@
1
- // Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
2
- // Use of this source code is governed by a MIT license that can be
3
- // found in the LICENSE file.
4
-
5
- #include "RNOH/ArkTSTurboModule.h"
6
- #include "ReanimatedUIScheduler.h"
7
- #include "WorkletsModule.h"
8
- #include "RNRuntimeWorkletDecorator.h"
9
- #include "PlatformLogger.h"
10
-
11
- using namespace facebook;
12
- namespace worklets {
13
- jsi::Value installTurboModule(facebook::jsi::Runtime &rt, react::TurboModule &turboModule,
14
- const facebook::jsi::Value *args, size_t count)
15
- {
16
- auto self = static_cast<WorkletsModule *>(&turboModule);
17
- if (count < 1) {
18
- LOG(ERROR) << "WorkletsModule: Missing required argument";
19
- return facebook::jsi::Value(false);
20
- }
21
- if (!args[0].isString()) {
22
- LOG(ERROR) << "WorkletsModule: First argument must be a string";
23
- return facebook::jsi::Value(false);
24
- }
25
-
26
- std::string valueUnpackerCode = args[0].getString(rt).utf8(rt);
27
- if (self == nullptr) {
28
- return facebook::jsi::Value::undefined();
29
- }
30
- self->installTurboModule(rt, valueUnpackerCode);
31
- return facebook::jsi::Value(true);
32
- }
33
-
34
- WorkletsModule::WorkletsModule(const ArkTSTurboModule::Context ctx, const std::string name)
35
- : ArkTSTurboModule(ctx, name)
36
- {
37
- methodMap_ = { { "installTurboModule", { 0, worklets::installTurboModule } } };
38
- }
39
-
40
- WorkletsModule::~WorkletsModule()
41
- {
42
- LOG(INFO) << "WorkletsModule::~WorkletsModule";
43
- }
44
-
45
- void WorkletsModule::installTurboModule(facebook::jsi::Runtime &runtime, std::string valueUnpackerCode)
46
- {
47
- if (workletsModuleProxy_) {
48
- LOG(WARNING) << "WorkletsModuleProxy already initialized";
49
- return;
50
- }
51
-
52
- workletsModuleProxy_ = std::make_shared<WorkletsModuleProxy>(valueUnpackerCode, m_ctx.jsQueue, jsInvoker_,
53
- std::make_shared<worklets::JSScheduler>(runtime, jsInvoker_),
54
- std::make_shared<rnoh::ReanimatedUIScheduler>(m_ctx.taskExecutor));
55
- RNRuntimeWorkletDecorator::decorate(runtime, workletsModuleProxy_);
56
- }
57
- std::shared_ptr<worklets::WorkletsModuleProxy> WorkletsModule::getWorkletsModuleProxy()
58
- {
59
- return workletsModuleProxy_;
60
- }
1
+ // Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
2
+ // Use of this source code is governed by a MIT license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #include "RNOH/ArkTSTurboModule.h"
6
+ #include "ReanimatedUIScheduler.h"
7
+ #include "WorkletsModule.h"
8
+ #include "RNRuntimeWorkletDecorator.h"
9
+ #include "PlatformLogger.h"
10
+
11
+ using namespace facebook;
12
+ namespace worklets {
13
+ jsi::Value installTurboModule(facebook::jsi::Runtime &rt, react::TurboModule &turboModule,
14
+ const facebook::jsi::Value *args, size_t count)
15
+ {
16
+ auto self = static_cast<WorkletsModule *>(&turboModule);
17
+ if (count < 1) {
18
+ LOG(ERROR) << "WorkletsModule: Missing required argument";
19
+ return facebook::jsi::Value(false);
20
+ }
21
+ if (!args[0].isString()) {
22
+ LOG(ERROR) << "WorkletsModule: First argument must be a string";
23
+ return facebook::jsi::Value(false);
24
+ }
25
+
26
+ std::string valueUnpackerCode = args[0].getString(rt).utf8(rt);
27
+ if (self == nullptr) {
28
+ return facebook::jsi::Value::undefined();
29
+ }
30
+ self->installTurboModule(rt, valueUnpackerCode);
31
+ return facebook::jsi::Value(true);
32
+ }
33
+
34
+ WorkletsModule::WorkletsModule(const ArkTSTurboModule::Context ctx, const std::string name)
35
+ : ArkTSTurboModule(ctx, name)
36
+ {
37
+ methodMap_ = { { "installTurboModule", { 0, worklets::installTurboModule } } };
38
+ }
39
+
40
+ WorkletsModule::~WorkletsModule()
41
+ {
42
+ LOG(INFO) << "WorkletsModule::~WorkletsModule";
43
+ }
44
+
45
+ void WorkletsModule::installTurboModule(facebook::jsi::Runtime &runtime, std::string valueUnpackerCode)
46
+ {
47
+ if (workletsModuleProxy_) {
48
+ LOG(WARNING) << "WorkletsModuleProxy already initialized";
49
+ return;
50
+ }
51
+
52
+ workletsModuleProxy_ = std::make_shared<WorkletsModuleProxy>(valueUnpackerCode, m_ctx.jsQueue, jsInvoker_,
53
+ std::make_shared<worklets::JSScheduler>(runtime, jsInvoker_),
54
+ std::make_shared<rnoh::ReanimatedUIScheduler>(m_ctx.taskExecutor));
55
+ RNRuntimeWorkletDecorator::decorate(runtime, workletsModuleProxy_);
56
+ }
57
+ std::shared_ptr<worklets::WorkletsModuleProxy> WorkletsModule::getWorkletsModuleProxy()
58
+ {
59
+ return workletsModuleProxy_;
60
+ }
61
61
  } // namespace worklets