react-native-worklets 0.0.1-alpha → 0.1.0

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 (246) hide show
  1. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +71 -0
  2. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
  3. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +131 -0
  4. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +82 -0
  5. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +72 -0
  6. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +44 -0
  7. package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
  8. package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -0
  9. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
  10. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -0
  11. package/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -0
  12. package/Common/cpp/worklets/SharedItems/Shareables.h +345 -0
  13. package/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -0
  14. package/Common/cpp/worklets/Tools/AsyncQueue.h +35 -0
  15. package/Common/cpp/worklets/Tools/Defs.h +10 -0
  16. package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
  17. package/Common/cpp/worklets/Tools/JSISerializer.h +47 -0
  18. package/Common/cpp/worklets/Tools/JSLogger.cpp +16 -0
  19. package/Common/cpp/worklets/Tools/JSLogger.h +20 -0
  20. package/Common/cpp/worklets/Tools/JSScheduler.cpp +10 -0
  21. package/Common/cpp/worklets/Tools/JSScheduler.h +29 -0
  22. package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
  23. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -0
  24. package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
  25. package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
  26. package/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
  27. package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
  28. package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
  29. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +26 -0
  30. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +199 -0
  31. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +20 -0
  32. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -0
  33. package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
  34. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +19 -0
  35. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
  36. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +108 -0
  37. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +127 -0
  38. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +183 -0
  39. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -0
  40. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
  41. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +179 -0
  42. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -0
  43. package/LICENSE +20 -0
  44. package/README.md +27 -0
  45. package/RNWorklets.podspec +70 -0
  46. package/android/CMakeLists.txt +56 -0
  47. package/android/build.gradle +313 -0
  48. package/android/gradle.properties +5 -0
  49. package/android/proguard-rules.pro +3 -0
  50. package/android/spotless.gradle +9 -0
  51. package/android/src/main/AndroidManifest.xml +2 -0
  52. package/android/src/main/cpp/worklets/CMakeLists.txt +85 -0
  53. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
  54. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +41 -0
  55. package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +32 -0
  56. package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
  57. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +83 -0
  58. package/android/src/main/cpp/worklets/android/WorkletsModule.h +63 -0
  59. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
  60. package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
  61. package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameCallback.java +20 -0
  62. package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameQueue.java +113 -0
  63. package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
  64. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
  65. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +72 -0
  66. package/android/src/main/java/com/swmansion/worklets/WorkletsModule.java +106 -0
  67. package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +49 -0
  68. package/android/src/paper/com/swmansion/worklets/NativeWorkletsModuleSpec.java +26 -0
  69. package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
  70. package/apple/worklets/apple/AnimationFrameQueue.mm +81 -0
  71. package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
  72. package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
  73. package/apple/worklets/apple/IOSUIScheduler.h +14 -0
  74. package/apple/worklets/apple/IOSUIScheduler.mm +24 -0
  75. package/apple/worklets/apple/PlatformLogger.mm +31 -0
  76. package/apple/worklets/apple/SlowAnimations.h +8 -0
  77. package/apple/worklets/apple/SlowAnimations.mm +47 -0
  78. package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
  79. package/apple/worklets/apple/WorkletsMessageThread.h +16 -0
  80. package/apple/worklets/apple/WorkletsMessageThread.mm +32 -0
  81. package/apple/worklets/apple/WorkletsModule.h +10 -0
  82. package/apple/worklets/apple/WorkletsModule.mm +85 -0
  83. package/lib/module/PlatformChecker.js +35 -0
  84. package/lib/module/PlatformChecker.js.map +1 -0
  85. package/lib/module/WorkletsError.js +13 -0
  86. package/lib/module/WorkletsError.js.map +1 -0
  87. package/lib/module/WorkletsModule/JSWorklets.js +36 -0
  88. package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
  89. package/lib/module/WorkletsModule/NativeWorklets.js +39 -0
  90. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
  91. package/lib/module/WorkletsModule/index.js +4 -0
  92. package/lib/module/WorkletsModule/index.js.map +1 -0
  93. package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
  94. package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
  95. package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
  96. package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
  97. package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
  98. package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
  99. package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js +10 -0
  100. package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js.map +1 -0
  101. package/lib/module/animationFrameQueue/requestAnimationFrame.js +36 -0
  102. package/lib/module/animationFrameQueue/requestAnimationFrame.js.map +1 -0
  103. package/lib/module/errors.js +78 -0
  104. package/lib/module/errors.js.map +1 -0
  105. package/lib/module/index.js +17 -0
  106. package/lib/module/index.js.map +1 -0
  107. package/lib/module/initializers.js +158 -0
  108. package/lib/module/initializers.js.map +1 -0
  109. package/lib/module/logger/LogBox.js +15 -0
  110. package/lib/module/logger/LogBox.js.map +1 -0
  111. package/lib/module/logger/index.js +5 -0
  112. package/lib/module/logger/index.js.map +1 -0
  113. package/lib/module/logger/logger.js +137 -0
  114. package/lib/module/logger/logger.js.map +1 -0
  115. package/lib/module/privateGlobals.d.js +8 -0
  116. package/lib/module/privateGlobals.d.js.map +1 -0
  117. package/lib/module/runtimes.js +63 -0
  118. package/lib/module/runtimes.js.map +1 -0
  119. package/lib/module/shareableMappingCache.js +39 -0
  120. package/lib/module/shareableMappingCache.js.map +1 -0
  121. package/lib/module/shareables.js +417 -0
  122. package/lib/module/shareables.js.map +1 -0
  123. package/lib/module/specs/NativeWorkletsModule.js +5 -0
  124. package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
  125. package/lib/module/specs/index.js +5 -0
  126. package/lib/module/specs/index.js.map +1 -0
  127. package/lib/module/threads.js +204 -0
  128. package/lib/module/threads.js.map +1 -0
  129. package/lib/module/valueUnpacker.js +83 -0
  130. package/lib/module/valueUnpacker.js.map +1 -0
  131. package/lib/module/workletFunction.js +37 -0
  132. package/lib/module/workletFunction.js.map +1 -0
  133. package/lib/module/workletTypes.js +12 -0
  134. package/lib/module/workletTypes.js.map +1 -0
  135. package/lib/typescript/PlatformChecker.d.ts +7 -0
  136. package/lib/typescript/PlatformChecker.d.ts.map +1 -0
  137. package/lib/typescript/WorkletsError.d.ts +3 -0
  138. package/lib/typescript/WorkletsError.d.ts.map +1 -0
  139. package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
  140. package/lib/typescript/WorkletsModule/JSWorklets.d.ts.map +1 -0
  141. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +5 -0
  142. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
  143. package/lib/typescript/WorkletsModule/index.d.ts +3 -0
  144. package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
  145. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
  146. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
  147. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
  148. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
  149. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +12 -0
  150. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
  151. package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts +6 -0
  152. package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts.map +1 -0
  153. package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts +2 -0
  154. package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts.map +1 -0
  155. package/lib/typescript/errors.d.ts +19 -0
  156. package/lib/typescript/errors.d.ts.map +1 -0
  157. package/lib/typescript/index.d.ts +13 -0
  158. package/lib/typescript/index.d.ts.map +1 -0
  159. package/lib/typescript/initializers.d.ts +6 -0
  160. package/lib/typescript/initializers.d.ts.map +1 -0
  161. package/lib/typescript/logger/LogBox.d.ts +32 -0
  162. package/lib/typescript/logger/LogBox.d.ts.map +1 -0
  163. package/lib/typescript/logger/index.d.ts +3 -0
  164. package/lib/typescript/logger/index.d.ts.map +1 -0
  165. package/lib/typescript/logger/logger.d.ts +52 -0
  166. package/lib/typescript/logger/logger.d.ts.map +1 -0
  167. package/lib/typescript/runtimes.d.ts +16 -0
  168. package/lib/typescript/runtimes.d.ts.map +1 -0
  169. package/lib/typescript/shareableMappingCache.d.ts +16 -0
  170. package/lib/typescript/shareableMappingCache.d.ts.map +1 -0
  171. package/lib/typescript/shareables.d.ts +15 -0
  172. package/lib/typescript/shareables.d.ts.map +1 -0
  173. package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
  174. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
  175. package/lib/typescript/specs/index.d.ts +3 -0
  176. package/lib/typescript/specs/index.d.ts.map +1 -0
  177. package/lib/typescript/threads.d.ts +49 -0
  178. package/lib/typescript/threads.d.ts.map +1 -0
  179. package/lib/typescript/valueUnpacker.d.ts +2 -0
  180. package/lib/typescript/valueUnpacker.d.ts.map +1 -0
  181. package/lib/typescript/workletFunction.d.ts +27 -0
  182. package/lib/typescript/workletFunction.d.ts.map +1 -0
  183. package/lib/typescript/workletTypes.d.ts +49 -0
  184. package/lib/typescript/workletTypes.d.ts.map +1 -0
  185. package/package.json +106 -8
  186. package/plugin/index.js +3 -0
  187. package/scripts/worklets_utils.rb +53 -0
  188. package/src/PlatformChecker.ts +43 -0
  189. package/src/WorkletsError.ts +13 -0
  190. package/src/WorkletsModule/JSWorklets.ts +57 -0
  191. package/src/WorkletsModule/NativeWorklets.ts +68 -0
  192. package/src/WorkletsModule/index.ts +7 -0
  193. package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
  194. package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
  195. package/src/WorkletsModule/workletsModuleProxy.ts +30 -0
  196. package/src/animationFrameQueue/mockedRequestAnimationFrame.ts +11 -0
  197. package/src/animationFrameQueue/requestAnimationFrame.ts +41 -0
  198. package/src/errors.ts +103 -0
  199. package/src/index.ts +42 -0
  200. package/src/initializers.ts +175 -0
  201. package/src/logger/LogBox.ts +55 -0
  202. package/src/logger/index.ts +3 -0
  203. package/src/logger/logger.ts +155 -0
  204. package/src/privateGlobals.d.ts +41 -0
  205. package/src/runtimes.ts +92 -0
  206. package/src/shareableMappingCache.ts +44 -0
  207. package/src/shareables.ts +577 -0
  208. package/src/specs/NativeWorkletsModule.ts +9 -0
  209. package/src/specs/index.ts +5 -0
  210. package/src/threads.ts +275 -0
  211. package/src/valueUnpacker.ts +110 -0
  212. package/src/workletFunction.ts +47 -0
  213. package/src/workletTypes.ts +76 -0
  214. package/Animated.js +0 -13
  215. package/AnimatedEvent.js +0 -167
  216. package/AnimatedImplementation.js +0 -666
  217. package/CoreAnimated.js +0 -43
  218. package/Easing.js +0 -236
  219. package/NativeAnimatedHelper.js +0 -226
  220. package/SpringConfig.js +0 -79
  221. package/animations/Animation.js +0 -36
  222. package/animations/DecayAnimation.js +0 -70
  223. package/animations/SpringAnimation.js +0 -125
  224. package/animations/TimingAnimation.js +0 -70
  225. package/bezier.js +0 -128
  226. package/createAnimatedComponent.js +0 -188
  227. package/nodes/AnimatedBlock.js +0 -19
  228. package/nodes/AnimatedClock.js +0 -76
  229. package/nodes/AnimatedCond.js +0 -23
  230. package/nodes/AnimatedDetach.js +0 -15
  231. package/nodes/AnimatedInterpolation.js +0 -338
  232. package/nodes/AnimatedNode.js +0 -97
  233. package/nodes/AnimatedOnChange.js +0 -28
  234. package/nodes/AnimatedOp.js +0 -17
  235. package/nodes/AnimatedProps.js +0 -154
  236. package/nodes/AnimatedSet.js +0 -19
  237. package/nodes/AnimatedStartClock.js +0 -21
  238. package/nodes/AnimatedStopClock.js +0 -21
  239. package/nodes/AnimatedStyle.js +0 -89
  240. package/nodes/AnimatedTracking.js +0 -36
  241. package/nodes/AnimatedTransform.js +0 -93
  242. package/nodes/AnimatedValue.js +0 -271
  243. package/nodes/AnimatedWithInput.js +0 -21
  244. package/nodes/SpringNode.js +0 -106
  245. package/nodes/TimingStep.js +0 -44
  246. package/utils.js +0 -28
@@ -0,0 +1,179 @@
1
+ #include <worklets/SharedItems/Shareables.h>
2
+ #include <worklets/Tools/JSISerializer.h>
3
+ #include <worklets/Tools/PlatformLogger.h>
4
+ #include <worklets/Tools/WorkletsJSIUtils.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
+ // TODO: Remove _IS_FABRIC sometime in the future
51
+ // react-native-screens 4.9.0 depends on it
52
+ rt.global().setProperty(rt, "_IS_FABRIC", true);
53
+
54
+ #ifndef NDEBUG
55
+ auto evalWithSourceUrl = [](jsi::Runtime &rt,
56
+ const jsi::Value &thisValue,
57
+ const jsi::Value *args,
58
+ size_t count) -> jsi::Value {
59
+ auto code = std::make_shared<const jsi::StringBuffer>(
60
+ args[0].asString(rt).utf8(rt));
61
+ std::string url;
62
+ if (count > 1 && args[1].isString()) {
63
+ url = args[1].asString(rt).utf8(rt);
64
+ }
65
+ return rt.evaluateJavaScript(code, url);
66
+ };
67
+ rt.global().setProperty(
68
+ rt,
69
+ "evalWithSourceUrl",
70
+ jsi::Function::createFromHostFunction(
71
+ rt,
72
+ jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
73
+ 1,
74
+ evalWithSourceUrl));
75
+ #endif // NDEBUG
76
+
77
+ jsi_utils::installJsiFunction(
78
+ rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
79
+ PlatformLogger::log(stringifyJSIValue(rt, value));
80
+ });
81
+
82
+ jsi_utils::installJsiFunction(
83
+ rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
84
+ return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
85
+ });
86
+
87
+ jsi_utils::installJsiFunction(
88
+ rt,
89
+ "_makeShareableClone",
90
+ [](jsi::Runtime &rt,
91
+ const jsi::Value &value,
92
+ const jsi::Value &nativeStateSource) {
93
+ auto shouldRetainRemote = jsi::Value::undefined();
94
+ return makeShareableClone(
95
+ rt, value, shouldRetainRemote, nativeStateSource);
96
+ });
97
+
98
+ jsi_utils::installJsiFunction(
99
+ rt,
100
+ "_scheduleRemoteFunctionOnJS",
101
+ [jsScheduler](
102
+ jsi::Runtime &rt,
103
+ const jsi::Value &funValue,
104
+ const jsi::Value &argsValue) {
105
+ auto shareableRemoteFun = extractShareableOrThrow<
106
+ ShareableRemoteFunction>(
107
+ rt,
108
+ funValue,
109
+ "[Worklets] Incompatible object passed to scheduleOnJS. It is only allowed to schedule worklets or functions defined on the React Native JS runtime this way.");
110
+
111
+ auto shareableArgs = argsValue.isUndefined()
112
+ ? nullptr
113
+ : extractShareableOrThrow<ShareableArray>(
114
+ rt, argsValue, "[Worklets] Args must be an array.");
115
+
116
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
117
+ auto fun =
118
+ shareableRemoteFun->toJSValue(rt).asObject(rt).asFunction(rt);
119
+ if (shareableArgs == nullptr) {
120
+ // fast path for remote function w/o arguments
121
+ fun.call(rt);
122
+ } else {
123
+ auto args = parseArgs(rt, shareableArgs);
124
+ fun.call(
125
+ rt, const_cast<const jsi::Value *>(args.data()), args.size());
126
+ }
127
+ });
128
+ });
129
+
130
+ jsi_utils::installJsiFunction(
131
+ rt,
132
+ "_scheduleHostFunctionOnJS",
133
+ [jsScheduler](
134
+ jsi::Runtime &rt,
135
+ const jsi::Value &hostFunValue,
136
+ const jsi::Value &argsValue) {
137
+ auto hostFun =
138
+ hostFunValue.asObject(rt).asFunction(rt).getHostFunction(rt);
139
+
140
+ auto shareableArgs = argsValue.isUndefined()
141
+ ? nullptr
142
+ : extractShareableOrThrow<ShareableArray>(
143
+ rt, argsValue, "[Worklets] Args must be an array.");
144
+
145
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
146
+ auto args = parseArgs(rt, shareableArgs);
147
+ hostFun(
148
+ rt,
149
+ jsi::Value::undefined(),
150
+ const_cast<const jsi::Value *>(args.data()),
151
+ args.size());
152
+ });
153
+ });
154
+
155
+ jsi_utils::installJsiFunction(
156
+ rt,
157
+ "_scheduleOnRuntime",
158
+ [](jsi::Runtime &rt,
159
+ const jsi::Value &workletRuntimeValue,
160
+ const jsi::Value &shareableWorkletValue) {
161
+ scheduleOnRuntime(rt, workletRuntimeValue, shareableWorkletValue);
162
+ });
163
+
164
+ jsi::Object performance(rt);
165
+ performance.setProperty(
166
+ rt,
167
+ "now",
168
+ jsi::Function::createFromHostFunction(
169
+ rt,
170
+ jsi::PropNameID::forAscii(rt, "now"),
171
+ 0,
172
+ [](jsi::Runtime &runtime,
173
+ const jsi::Value &,
174
+ const jsi::Value *args,
175
+ size_t count) { return jsi::Value(performanceNow()); }));
176
+ rt.global().setProperty(rt, "performance", performance);
177
+ }
178
+
179
+ } // namespace worklets
@@ -0,0 +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
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 nobody
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ ![header](https://github.com/user-attachments/assets/41b37472-e55a-4c54-9064-31258e03870c)
2
+
3
+ ### The React Native multithreading library
4
+
5
+ Work in progress!
6
+
7
+ Do not consider any of the APIs as stable.
8
+
9
+ ## License
10
+
11
+ Worklets library is licensed under [The MIT License](LICENSE).
12
+
13
+ ## Credits
14
+
15
+ This project has been built and is maintained thanks to the support from [Shopify](https://shopify.com), [Expo.io](https://expo.io) and [Software Mansion](https://swmansion.com)
16
+
17
+ [![shopify](https://avatars1.githubusercontent.com/u/8085?v=3&s=100 'Shopify.com')](https://shopify.com)
18
+ [![expo](https://avatars2.githubusercontent.com/u/12504344?v=3&s=100 'Expo.io')](https://expo.io)
19
+ [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-reanimated-github 'Software Mansion')](https://swmansion.com)
20
+
21
+ ## Community Discord
22
+
23
+ [Join the Software Mansion Community Discord](https://discord.swmansion.com) to chat about Worklets or other Software Mansion libraries.
24
+
25
+ ## Worklets are created by Software Mansion
26
+
27
+ Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=reanimated&utm_medium=readme).
@@ -0,0 +1,70 @@
1
+ require "json"
2
+ require_relative './scripts/worklets_utils'
3
+
4
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
+ $worklets_config = worklets_find_config()
6
+ worklets_assert_minimal_react_native_version($worklets_config)
7
+
8
+ ios_min_version = '13.4'
9
+
10
+ Pod::Spec.new do |s|
11
+ s.name = "RNWorklets"
12
+ s.version = package["version"]
13
+ s.summary = package["description"]
14
+ s.homepage = "https://github.com/software-mansion/react-native-reanimated"
15
+ s.license = package["license"]
16
+ s.authors = { "author" => "author@domain.com" }
17
+ s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
18
+ s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }
19
+
20
+ s.source_files = "apple/*.{h,m,mm,cpp}"
21
+
22
+ s.subspec "worklets" do |ss|
23
+ ss.source_files = "Common/cpp/worklets/**/*.{cpp,h}"
24
+ ss.header_dir = "worklets"
25
+ ss.header_mappings_dir = "Common/cpp/worklets"
26
+
27
+ ss.subspec "apple" do |sss|
28
+ # Please be careful with the snakes.
29
+ # 🐍🐍🐍
30
+ # Thank you for your understanding.
31
+ sss.source_files = "apple/worklets/**/*.{mm,h,m}"
32
+ sss.header_dir = "worklets"
33
+ sss.header_mappings_dir = "apple/worklets"
34
+ end
35
+ end
36
+
37
+ # Use install_modules_dependencies helper to install the dependencies.
38
+ # See https://github.com/facebook/react-native/blob/c925872e72d2422be46670777bfa2111e13c9e4c/packages/react-native/scripts/cocoapods/new_architecture.rb#L71.
39
+ install_modules_dependencies(s)
40
+
41
+ s.pod_target_xcconfig = {
42
+ "USE_HEADERMAP" => "YES",
43
+ "DEFINES_MODULE" => "YES",
44
+ "HEADER_SEARCH_PATHS" => [
45
+ '"$(PODS_TARGET_SRCROOT)/ReactCommon"',
46
+ '"$(PODS_TARGET_SRCROOT)"',
47
+ '"$(PODS_ROOT)/RCT-Folly"',
48
+ '"$(PODS_ROOT)/boost"',
49
+ '"$(PODS_ROOT)/boost-for-react-native"',
50
+ '"$(PODS_ROOT)/DoubleConversion"',
51
+ '"$(PODS_ROOT)/Headers/Private/React-Core"',
52
+ '"$(PODS_ROOT)/Headers/Private/Yoga"',
53
+ "\"$(PODS_ROOT)/#{$worklets_config[:react_native_common_dir]}\"",
54
+ ].join(' '),
55
+ "FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
56
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
57
+ }
58
+ s.xcconfig = {
59
+ "HEADER_SEARCH_PATHS" => [
60
+ '"$(PODS_ROOT)/boost"',
61
+ '"$(PODS_ROOT)/boost-for-react-native"',
62
+ '"$(PODS_ROOT)/glog"',
63
+ '"$(PODS_ROOT)/RCT-Folly"',
64
+ '"$(PODS_ROOT)/Headers/Public/React-hermes"',
65
+ '"$(PODS_ROOT)/Headers/Public/hermes-engine"',
66
+ "\"$(PODS_ROOT)/#{$worklets_config[:react_native_common_dir]}\"",
67
+ ].join(' '),
68
+ }
69
+
70
+ end
@@ -0,0 +1,56 @@
1
+ project(Worklets)
2
+ cmake_minimum_required(VERSION 3.8)
3
+
4
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5
+
6
+ set(CMAKE_CXX_STANDARD 20)
7
+
8
+ # default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections
9
+ # -funwind-tables -fstack-protector-strong -no-canonical-prefixes
10
+ # -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"
11
+ include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
12
+ add_compile_options(${folly_FLAGS})
13
+
14
+ string(
15
+ APPEND
16
+ CMAKE_CXX_FLAGS
17
+ " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} \
18
+ -DREANIMATED_VERSION=${REANIMATED_VERSION} \
19
+ -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}")
20
+
21
+ string(APPEND CMAKE_CXX_FLAGS
22
+ " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all \
23
+ -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
24
+
25
+ if(${IS_NEW_ARCHITECTURE_ENABLED})
26
+ string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
27
+ endif()
28
+
29
+ if(${IS_REANIMATED_EXAMPLE_APP})
30
+ string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP -Wpedantic")
31
+ endif()
32
+
33
+ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
34
+ string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
35
+ endif()
36
+
37
+ if(${JS_RUNTIME} STREQUAL "hermes")
38
+ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
39
+ elseif(${JS_RUNTIME} STREQUAL "jsc")
40
+ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
41
+ elseif(${JS_RUNTIME} STREQUAL "v8")
42
+ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
43
+ else()
44
+ message(FATAL_ERROR "Unknown JS runtime ${JS_RUNTIME}.")
45
+ endif()
46
+
47
+ # Resolves "CMake Warning: Manually-specified variables were not used by the
48
+ # project" when any of the following variables is not used in some build
49
+ # configuration.
50
+ set(IGNORE_ME "${JS_RUNTIME_DIR}")
51
+
52
+ set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
53
+ set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
54
+ set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")
55
+
56
+ add_subdirectory("${ANDROID_CPP_DIR}/worklets")
@@ -0,0 +1,313 @@
1
+ import groovy.json.JsonSlurper
2
+ import java.nio.file.Paths
3
+ import org.apache.tools.ant.taskdefs.condition.Os
4
+
5
+ def safeExtGet(prop, fallback) {
6
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
7
+ }
8
+
9
+ def safeAppExtGet(prop, fallback) {
10
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
11
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
12
+ }
13
+
14
+ def isNewArchitectureEnabled() {
15
+ // To opt-in for the New Architecture, you can either:
16
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
17
+ // - Invoke gradle with `-newArchEnabled=true`
18
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
19
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
20
+ }
21
+
22
+ def resolveReactNativeDirectory() {
23
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
24
+ if (reactNativeLocation != null) {
25
+ return file(reactNativeLocation)
26
+ }
27
+
28
+ // Fallback to node resolver for custom directory structures like monorepos.
29
+ def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
30
+ if (reactNativePackage.exists()) {
31
+ return reactNativePackage.parentFile
32
+ }
33
+
34
+ throw new GradleException(
35
+ "[Worklets] Unable to resolve react-native location in node_modules. You should set project extension property (in `app/build.gradle`) named `REACT_NATIVE_NODE_MODULES_DIR` with the path to react-native in node_modules."
36
+ )
37
+ }
38
+
39
+ def getReactNativeMinorVersion() {
40
+ def reactNativeRootDir = resolveReactNativeDirectory()
41
+ def reactProperties = new Properties()
42
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
43
+ def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
44
+ return reactNativeVersion.startsWith("0.0.0-") ? 1000 : reactNativeVersion.split("\\.")[1].toInteger()
45
+ }
46
+
47
+ def getWorkletsVersion() {
48
+ def inputFile = file(projectDir.path + '/../package.json')
49
+ def json = new JsonSlurper().parseText(inputFile.text)
50
+ return json.version
51
+ }
52
+
53
+ def toPlatformFileString(String path) {
54
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
55
+ path = path.replace(File.separatorChar, '/' as char)
56
+ }
57
+ return path
58
+ }
59
+
60
+ if (isNewArchitectureEnabled()) {
61
+ apply plugin: "com.facebook.react"
62
+ }
63
+
64
+ def reactNativeRootDir = resolveReactNativeDirectory()
65
+ def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
66
+ def WORKLETS_VERSION = getWorkletsVersion()
67
+ def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
68
+ def IS_REANIMATED_EXAMPLE_APP = safeAppExtGet("isReanimatedExampleApp", false)
69
+
70
+ // Set version for prefab
71
+ version WORKLETS_VERSION
72
+
73
+ def workletsPrefabHeadersDir = project.file("$buildDir/prefab-headers/worklets")
74
+
75
+ def JS_RUNTIME = {
76
+ // Override JS runtime with environment variable
77
+ if (System.getenv("JS_RUNTIME")) {
78
+ return System.getenv("JS_RUNTIME")
79
+ }
80
+
81
+ // Enable V8 runtime if react-native-v8 is installed
82
+ def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" }
83
+ if (v8Project != null) {
84
+ return "v8"
85
+ }
86
+
87
+ // Check if Hermes is enabled in app setup
88
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
89
+ if (appProject?.hermesEnabled?.toBoolean() || appProject?.ext?.react?.enableHermes?.toBoolean()) {
90
+ return "hermes"
91
+ }
92
+
93
+ // Use JavaScriptCore (JSC) by default
94
+ return "jsc"
95
+ }.call()
96
+
97
+ def jsRuntimeDir = {
98
+ if (JS_RUNTIME == "hermes") {
99
+ return Paths.get(reactNativeRootDir.path, "sdks", "hermes")
100
+ } else if (JS_RUNTIME == "v8") {
101
+ return findProject(":react-native-v8").getProjectDir().getParent()
102
+ } else {
103
+ return Paths.get(reactNativeRootDir.path, "ReactCommon", "jsi")
104
+ }
105
+ }.call()
106
+
107
+ def reactNativeArchitectures() {
108
+ def value = project.getProperties().get("reactNativeArchitectures")
109
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
110
+ }
111
+
112
+ buildscript {
113
+ repositories {
114
+ google()
115
+ mavenCentral()
116
+ }
117
+ dependencies {
118
+ classpath "com.android.tools.build:gradle:8.2.1"
119
+ classpath "de.undercouch:gradle-download-task:5.6.0"
120
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
121
+ }
122
+ }
123
+
124
+ if (project == rootProject) {
125
+ apply from: "spotless.gradle"
126
+ }
127
+
128
+ apply plugin: "com.android.library"
129
+ apply plugin: "maven-publish"
130
+ apply plugin: "de.undercouch.download"
131
+
132
+
133
+ android {
134
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
135
+
136
+ namespace "com.swmansion.worklets"
137
+
138
+ if (rootProject.hasProperty("ndkPath")) {
139
+ ndkPath rootProject.ext.ndkPath
140
+ }
141
+ if (rootProject.hasProperty("ndkVersion")) {
142
+ ndkVersion rootProject.ext.ndkVersion
143
+ }
144
+
145
+ buildFeatures {
146
+ prefab true
147
+ prefabPublishing true
148
+ buildConfig true
149
+ }
150
+
151
+ prefab {
152
+ worklets {
153
+ headers workletsPrefabHeadersDir.absolutePath
154
+ }
155
+ }
156
+
157
+ defaultConfig {
158
+ minSdkVersion safeExtGet("minSdkVersion", 23)
159
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
160
+ versionCode 1
161
+ versionName WORKLETS_VERSION
162
+
163
+ buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
164
+ buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
165
+ buildConfigField("int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString())
166
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString())
167
+
168
+ externalNativeBuild {
169
+ cmake {
170
+ arguments "-DANDROID_STL=c++_shared",
171
+ "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
172
+ "-DANDROID_TOOLCHAIN=clang",
173
+ "-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
174
+ "-DJS_RUNTIME=${JS_RUNTIME}",
175
+ "-DJS_RUNTIME_DIR=${jsRuntimeDir}",
176
+ "-DIS_NEW_ARCHITECTURE_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}",
177
+ "-DIS_REANIMATED_EXAMPLE_APP=${IS_REANIMATED_EXAMPLE_APP}",
178
+ "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
179
+ abiFilters (*reactNativeArchitectures())
180
+ targets("worklets")
181
+ }
182
+ }
183
+
184
+ consumerProguardFiles 'proguard-rules.pro'
185
+ }
186
+ externalNativeBuild {
187
+ cmake {
188
+ version = System.getenv("CMAKE_VERSION") ?: "3.22.1"
189
+ path "CMakeLists.txt"
190
+ }
191
+ }
192
+ buildTypes {
193
+ debug {
194
+ externalNativeBuild {
195
+ cmake {
196
+ if (JS_RUNTIME == "hermes") {
197
+ arguments "-DHERMES_ENABLE_DEBUGGER=1"
198
+ } else {
199
+ arguments "-DHERMES_ENABLE_DEBUGGER=0"
200
+ }
201
+ }
202
+ }
203
+ packagingOptions {
204
+ doNotStrip "**/**/*.so"
205
+ }
206
+ }
207
+ release {
208
+ externalNativeBuild {
209
+ cmake {
210
+ arguments "-DHERMES_ENABLE_DEBUGGER=0"
211
+ }
212
+ }
213
+ }
214
+ }
215
+ lintOptions {
216
+ abortOnError false
217
+ }
218
+ packagingOptions {
219
+ // For some reason gradle only complains about the duplicated version of librrc_root and libreact_render libraries
220
+ // while there are more libraries copied in intermediates folder of the lib build directory, we exclude
221
+ // only the ones that make the build fail (ideally we should only include libreanimated but we
222
+ // are only allowed to specify exclude patterns)
223
+ excludes = [
224
+ "META-INF",
225
+ "META-INF/**",
226
+ "**/libc++_shared.so",
227
+ "**/libfbjni.so",
228
+ "**/libjsi.so",
229
+ "**/libfolly_json.so",
230
+ "**/libfolly_runtime.so",
231
+ "**/libglog.so",
232
+ "**/libhermes.so",
233
+ "**/libhermes-executor-debug.so",
234
+ "**/libhermes_executor.so",
235
+ "**/libhermestooling.so",
236
+ "**/libreactnativejni.so",
237
+ "**/libturbomodulejsijni.so",
238
+ "**/libreactnative.so",
239
+ "**/libreact_nativemodule_core.so",
240
+ "**/libreact_render*.so",
241
+ "**/librrc_root.so",
242
+ "**/libjscexecutor.so",
243
+ "**/libv8executor.so",
244
+ ]
245
+ }
246
+ compileOptions {
247
+ sourceCompatibility JavaVersion.VERSION_1_8
248
+ targetCompatibility JavaVersion.VERSION_1_8
249
+ }
250
+ sourceSets {
251
+ main {
252
+ java {
253
+ if (!IS_NEW_ARCHITECTURE_ENABLED) {
254
+ srcDirs += "src/worklets/paper"
255
+ }
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ task assertMinimalReactNativeVersionTask {
262
+ // If you change the minimal React Native version remember to update Compatibility Table in docs
263
+ def minimalReactNativeVersion = 75
264
+ onlyIf { REACT_NATIVE_MINOR_VERSION < minimalReactNativeVersion }
265
+ doFirst {
266
+ throw new GradleException("[Worklets] Unsupported React Native version. Please use $minimalReactNativeVersion or newer.")
267
+ }
268
+ }
269
+
270
+ preBuild.dependsOn(assertMinimalReactNativeVersionTask)
271
+
272
+ task prepareWorkletsHeadersForPrefabs(type: Copy) {
273
+ from("$projectDir/src/main/cpp")
274
+ from("$projectDir/../Common/cpp")
275
+ include("worklets/**/*.h")
276
+ into(workletsPrefabHeadersDir)
277
+ }
278
+
279
+ task cleanCmakeCache() {
280
+ tasks.getByName("clean").dependsOn(cleanCmakeCache)
281
+ doFirst {
282
+ delete "${projectDir}/.cxx"
283
+ }
284
+ }
285
+
286
+ repositories {
287
+ mavenCentral()
288
+ google()
289
+ }
290
+
291
+ dependencies {
292
+ implementation "com.facebook.yoga:proguard-annotations:1.19.0"
293
+ implementation "androidx.transition:transition:1.1.0"
294
+ implementation "androidx.core:core:1.6.0"
295
+
296
+ implementation "com.facebook.react:react-android" // version substituted by RNGP
297
+ if (JS_RUNTIME == "hermes") {
298
+ implementation "com.facebook.react:hermes-android" // version substituted by RNGP
299
+ }
300
+ }
301
+
302
+ preBuild.dependsOn(prepareWorkletsHeadersForPrefabs)
303
+
304
+ afterEvaluate {
305
+ if (JS_RUNTIME == "v8") {
306
+ def buildTasks = tasks.findAll({ task ->
307
+ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel")) })
308
+ buildTasks.forEach { task ->
309
+ def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
310
+ task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly")
311
+ }
312
+ }
313
+ }