@amazon-devices/react-native-worklets 1.0.0-rn-83

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 (348) 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/JSIWorkletsModuleProxy.cpp +712 -0
  4. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +88 -0
  5. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +89 -0
  6. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +80 -0
  7. package/Common/cpp/worklets/Public/AsyncQueue.h +14 -0
  8. package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
  9. package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +51 -0
  10. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
  11. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +40 -0
  12. package/Common/cpp/worklets/Resources/SynchronizableUnpacker.cpp +49 -0
  13. package/Common/cpp/worklets/Resources/Unpackers.h +6 -0
  14. package/Common/cpp/worklets/Resources/ValueUnpacker.cpp +53 -0
  15. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +62 -0
  16. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +46 -0
  17. package/Common/cpp/worklets/RunLoop/EventLoop.cpp +112 -0
  18. package/Common/cpp/worklets/RunLoop/EventLoop.h +52 -0
  19. package/Common/cpp/worklets/SharedItems/Serializable.cpp +545 -0
  20. package/Common/cpp/worklets/SharedItems/Serializable.h +473 -0
  21. package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +67 -0
  22. package/Common/cpp/worklets/SharedItems/Synchronizable.h +59 -0
  23. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +81 -0
  24. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +45 -0
  25. package/Common/cpp/worklets/Tools/Defs.h +10 -0
  26. package/Common/cpp/worklets/Tools/FeatureFlags.cpp +15 -0
  27. package/Common/cpp/worklets/Tools/FeatureFlags.h +44 -0
  28. package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
  29. package/Common/cpp/worklets/Tools/JSISerializer.h +51 -0
  30. package/Common/cpp/worklets/Tools/JSLogger.cpp +68 -0
  31. package/Common/cpp/worklets/Tools/JSLogger.h +37 -0
  32. package/Common/cpp/worklets/Tools/JSScheduler.cpp +24 -0
  33. package/Common/cpp/worklets/Tools/JSScheduler.h +39 -0
  34. package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
  35. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +82 -0
  36. package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
  37. package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
  38. package/Common/cpp/worklets/Tools/UIScheduler.h +26 -0
  39. package/Common/cpp/worklets/Tools/VersionUtils.cpp +75 -0
  40. package/Common/cpp/worklets/Tools/VersionUtils.h +28 -0
  41. package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
  42. package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
  43. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +46 -0
  44. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +208 -0
  45. package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +161 -0
  46. package/Common/cpp/worklets/Tools/WorkletsVersion.cpp +54 -0
  47. package/Common/cpp/worklets/Tools/WorkletsVersion.h +20 -0
  48. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +38 -0
  49. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +21 -0
  50. package/Common/cpp/worklets/WorkletRuntime/RuntimeData.cpp +3 -0
  51. package/Common/cpp/worklets/WorkletRuntime/RuntimeData.h +12 -0
  52. package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
  53. package/Common/cpp/worklets/WorkletRuntime/RuntimeKind.h +16 -0
  54. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +105 -0
  55. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +63 -0
  56. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +23 -0
  57. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
  58. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +119 -0
  59. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +134 -0
  60. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +244 -0
  61. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +102 -0
  62. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
  63. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +308 -0
  64. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +26 -0
  65. package/LICENSE +7 -0
  66. package/README.md +31 -0
  67. package/RNWorklets.podspec +94 -0
  68. package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.bundle +10512 -0
  69. package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.map +3771 -0
  70. package/SystemModules/amzn__react-native-worklets-1.modules.txt +39 -0
  71. package/SystemModules/amzn__react-native-worklets-1.private.modules.txt +61 -0
  72. package/SystemModules/keplerscript-system-bundle-config.json +7 -0
  73. package/android/CMakeLists.txt +124 -0
  74. package/android/build.gradle +350 -0
  75. package/android/gradle.properties +5 -0
  76. package/android/proguard-rules.pro +3 -0
  77. package/android/spotless.gradle +9 -0
  78. package/android/src/experimentalBundling/com/swmansion/worklets/WorkletsModule.java +149 -0
  79. package/android/src/legacyBundling/com/swmansion/worklets/WorkletsModule.java +122 -0
  80. package/android/src/main/AndroidManifest.xml +2 -0
  81. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
  82. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +43 -0
  83. package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +34 -0
  84. package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
  85. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +115 -0
  86. package/android/src/main/cpp/worklets/android/WorkletsModule.h +78 -0
  87. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
  88. package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
  89. package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
  90. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
  91. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +73 -0
  92. package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +48 -0
  93. package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameCallback.java +19 -0
  94. package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.java +113 -0
  95. package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
  96. package/apple/worklets/apple/AnimationFrameQueue.mm +135 -0
  97. package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
  98. package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
  99. package/apple/worklets/apple/IOSUIScheduler.h +15 -0
  100. package/apple/worklets/apple/IOSUIScheduler.mm +29 -0
  101. package/apple/worklets/apple/PlatformLogger.mm +31 -0
  102. package/apple/worklets/apple/SlowAnimations.h +8 -0
  103. package/apple/worklets/apple/SlowAnimations.mm +45 -0
  104. package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
  105. package/apple/worklets/apple/WorkletsMessageThread.h +16 -0
  106. package/apple/worklets/apple/WorkletsMessageThread.mm +31 -0
  107. package/apple/worklets/apple/WorkletsModule.h +28 -0
  108. package/apple/worklets/apple/WorkletsModule.mm +121 -0
  109. package/bundleMode/index.d.ts +3 -0
  110. package/bundleMode/index.js +59 -0
  111. package/compatibility.json +11 -0
  112. package/kepler-compatibility.json +5 -0
  113. package/kepler-transformed-package-info.json +3 -0
  114. package/lib/module/PlatformChecker/PlatformChecker.js +8 -0
  115. package/lib/module/PlatformChecker/PlatformChecker.js.map +1 -0
  116. package/lib/module/PlatformChecker/index.js +18 -0
  117. package/lib/module/PlatformChecker/index.js.map +1 -0
  118. package/lib/module/WorkletsError.js +29 -0
  119. package/lib/module/WorkletsError.js.map +1 -0
  120. package/lib/module/WorkletsModule/JSWorklets.js +111 -0
  121. package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
  122. package/lib/module/WorkletsModule/NativeWorklets.js +126 -0
  123. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
  124. package/lib/module/WorkletsModule/index.js +4 -0
  125. package/lib/module/WorkletsModule/index.js.map +1 -0
  126. package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
  127. package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
  128. package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
  129. package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
  130. package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
  131. package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
  132. package/lib/module/bundleUnpacker.js +47 -0
  133. package/lib/module/bundleUnpacker.js.map +1 -0
  134. package/lib/module/callGuard.js +30 -0
  135. package/lib/module/callGuard.js.map +1 -0
  136. package/lib/module/deprecated.js +20 -0
  137. package/lib/module/deprecated.js.map +1 -0
  138. package/lib/module/errors.js +69 -0
  139. package/lib/module/errors.js.map +1 -0
  140. package/lib/module/featureFlags/index.js +48 -0
  141. package/lib/module/featureFlags/index.js.map +1 -0
  142. package/lib/module/featureFlags/staticFlags.json +4 -0
  143. package/lib/module/index.js +26 -0
  144. package/lib/module/index.js.map +1 -0
  145. package/lib/module/initializers.js +221 -0
  146. package/lib/module/initializers.js.map +1 -0
  147. package/lib/module/isSynchronizable.js +6 -0
  148. package/lib/module/isSynchronizable.js.map +1 -0
  149. package/lib/module/logger.js +15 -0
  150. package/lib/module/logger.js.map +1 -0
  151. package/lib/module/privateGlobals.d.js +7 -0
  152. package/lib/module/privateGlobals.d.js.map +1 -0
  153. package/lib/module/publicGlobals.js +6 -0
  154. package/lib/module/publicGlobals.js.map +1 -0
  155. package/lib/module/runLoop/common/setImmediatePolyfill.js +15 -0
  156. package/lib/module/runLoop/common/setImmediatePolyfill.js.map +1 -0
  157. package/lib/module/runLoop/common/setIntervalPolyfill.js +26 -0
  158. package/lib/module/runLoop/common/setIntervalPolyfill.js.map +1 -0
  159. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js +10 -0
  160. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js.map +1 -0
  161. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +52 -0
  162. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -0
  163. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js +32 -0
  164. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js.map +1 -0
  165. package/lib/module/runLoop/workletRuntime/index.js +19 -0
  166. package/lib/module/runLoop/workletRuntime/index.js.map +1 -0
  167. package/lib/module/runLoop/workletRuntime/queueMicrotask.js +11 -0
  168. package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +1 -0
  169. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +48 -0
  170. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -0
  171. package/lib/module/runLoop/workletRuntime/setTimeout.js +28 -0
  172. package/lib/module/runLoop/workletRuntime/setTimeout.js.map +1 -0
  173. package/lib/module/runLoop/workletRuntime/taskQueue.js +37 -0
  174. package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -0
  175. package/lib/module/runtimeKind.js +39 -0
  176. package/lib/module/runtimeKind.js.map +1 -0
  177. package/lib/module/runtimes.js +100 -0
  178. package/lib/module/runtimes.js.map +1 -0
  179. package/lib/module/serializable.js +568 -0
  180. package/lib/module/serializable.js.map +1 -0
  181. package/lib/module/serializableMappingCache.js +37 -0
  182. package/lib/module/serializableMappingCache.js.map +1 -0
  183. package/lib/module/specs/NativeWorkletsModule.js +5 -0
  184. package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
  185. package/lib/module/specs/NativeWorkletsModule.kepler.js +7 -0
  186. package/lib/module/specs/NativeWorkletsModule.kepler.js.map +1 -0
  187. package/lib/module/specs/index.js +10 -0
  188. package/lib/module/specs/index.js.map +1 -0
  189. package/lib/module/synchronizable.js +9 -0
  190. package/lib/module/synchronizable.js.map +1 -0
  191. package/lib/module/synchronizableUnpacker.js +42 -0
  192. package/lib/module/synchronizableUnpacker.js.map +1 -0
  193. package/lib/module/threads.js +347 -0
  194. package/lib/module/threads.js.map +1 -0
  195. package/lib/module/utils/checkCppVersion.js +30 -0
  196. package/lib/module/utils/checkCppVersion.js.map +1 -0
  197. package/lib/module/utils/jsVersion.js +9 -0
  198. package/lib/module/utils/jsVersion.js.map +1 -0
  199. package/lib/module/valueUnpacker.js +60 -0
  200. package/lib/module/valueUnpacker.js.map +1 -0
  201. package/lib/module/workletFunction.js +37 -0
  202. package/lib/module/workletFunction.js.map +1 -0
  203. package/lib/module/workletRuntimeEntry.js +32 -0
  204. package/lib/module/workletRuntimeEntry.js.map +1 -0
  205. package/lib/module/workletTypes.js +12 -0
  206. package/lib/module/workletTypes.js.map +1 -0
  207. package/lib/typescript/PlatformChecker/PlatformChecker.d.ts +5 -0
  208. package/lib/typescript/PlatformChecker/PlatformChecker.d.ts.map +1 -0
  209. package/lib/typescript/PlatformChecker/index.d.ts +10 -0
  210. package/lib/typescript/PlatformChecker/index.d.ts.map +1 -0
  211. package/lib/typescript/WorkletsError.d.ts +15 -0
  212. package/lib/typescript/WorkletsError.d.ts.map +1 -0
  213. package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
  214. package/lib/typescript/WorkletsModule/JSWorklets.d.ts.map +1 -0
  215. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +3 -0
  216. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
  217. package/lib/typescript/WorkletsModule/index.d.ts +3 -0
  218. package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
  219. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
  220. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
  221. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
  222. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
  223. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +37 -0
  224. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
  225. package/lib/typescript/bundleUnpacker.d.ts +7 -0
  226. package/lib/typescript/bundleUnpacker.d.ts.map +1 -0
  227. package/lib/typescript/callGuard.d.ts +4 -0
  228. package/lib/typescript/callGuard.d.ts.map +1 -0
  229. package/lib/typescript/deprecated.d.ts +20 -0
  230. package/lib/typescript/deprecated.d.ts.map +1 -0
  231. package/lib/typescript/errors.d.ts +16 -0
  232. package/lib/typescript/errors.d.ts.map +1 -0
  233. package/lib/typescript/featureFlags/index.d.ts +23 -0
  234. package/lib/typescript/featureFlags/index.d.ts.map +1 -0
  235. package/lib/typescript/index.d.ts +17 -0
  236. package/lib/typescript/index.d.ts.map +1 -0
  237. package/lib/typescript/initializers.d.ts +17 -0
  238. package/lib/typescript/initializers.d.ts.map +1 -0
  239. package/lib/typescript/isSynchronizable.d.ts +3 -0
  240. package/lib/typescript/isSynchronizable.d.ts.map +1 -0
  241. package/lib/typescript/logger.d.ts +5 -0
  242. package/lib/typescript/logger.d.ts.map +1 -0
  243. package/lib/typescript/publicGlobals.d.ts +31 -0
  244. package/lib/typescript/publicGlobals.d.ts.map +1 -0
  245. package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts +2 -0
  246. package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts.map +1 -0
  247. package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts +2 -0
  248. package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts.map +1 -0
  249. package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts +6 -0
  250. package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts.map +1 -0
  251. package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts +2 -0
  252. package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -0
  253. package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts +2 -0
  254. package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts.map +1 -0
  255. package/lib/typescript/runLoop/workletRuntime/index.d.ts +2 -0
  256. package/lib/typescript/runLoop/workletRuntime/index.d.ts.map +1 -0
  257. package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts +2 -0
  258. package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +1 -0
  259. package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts +2 -0
  260. package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts.map +1 -0
  261. package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts +2 -0
  262. package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts.map +1 -0
  263. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +10 -0
  264. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -0
  265. package/lib/typescript/runtimeKind.d.ts +25 -0
  266. package/lib/typescript/runtimeKind.d.ts.map +1 -0
  267. package/lib/typescript/runtimes.d.ts +77 -0
  268. package/lib/typescript/runtimes.d.ts.map +1 -0
  269. package/lib/typescript/serializable.d.ts +20 -0
  270. package/lib/typescript/serializable.d.ts.map +1 -0
  271. package/lib/typescript/serializableMappingCache.d.ts +16 -0
  272. package/lib/typescript/serializableMappingCache.d.ts.map +1 -0
  273. package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
  274. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
  275. package/lib/typescript/specs/NativeWorkletsModule.kepler.d.ts +7 -0
  276. package/lib/typescript/specs/NativeWorkletsModule.kepler.d.ts.map +1 -0
  277. package/lib/typescript/specs/index.d.ts +3 -0
  278. package/lib/typescript/specs/index.d.ts.map +1 -0
  279. package/lib/typescript/synchronizable.d.ts +15 -0
  280. package/lib/typescript/synchronizable.d.ts.map +1 -0
  281. package/lib/typescript/synchronizableUnpacker.d.ts +4 -0
  282. package/lib/typescript/synchronizableUnpacker.d.ts.map +1 -0
  283. package/lib/typescript/threads.d.ts +138 -0
  284. package/lib/typescript/threads.d.ts.map +1 -0
  285. package/lib/typescript/utils/checkCppVersion.d.ts +3 -0
  286. package/lib/typescript/utils/checkCppVersion.d.ts.map +1 -0
  287. package/lib/typescript/utils/jsVersion.d.ts +7 -0
  288. package/lib/typescript/utils/jsVersion.d.ts.map +1 -0
  289. package/lib/typescript/valueUnpacker.d.ts +6 -0
  290. package/lib/typescript/valueUnpacker.d.ts.map +1 -0
  291. package/lib/typescript/workletFunction.d.ts +27 -0
  292. package/lib/typescript/workletFunction.d.ts.map +1 -0
  293. package/lib/typescript/workletRuntimeEntry.d.ts +14 -0
  294. package/lib/typescript/workletRuntimeEntry.d.ts.map +1 -0
  295. package/lib/typescript/workletTypes.d.ts +61 -0
  296. package/lib/typescript/workletTypes.d.ts.map +1 -0
  297. package/package.json +153 -0
  298. package/plugin/index.js +1761 -0
  299. package/react-native.config.js +21 -0
  300. package/scripts/validate-react-native-version.js +43 -0
  301. package/scripts/worklets_utils.rb +94 -0
  302. package/src/PlatformChecker/PlatformChecker.ts +7 -0
  303. package/src/PlatformChecker/index.ts +30 -0
  304. package/src/WorkletsError.ts +36 -0
  305. package/src/WorkletsModule/JSWorklets.ts +200 -0
  306. package/src/WorkletsModule/NativeWorklets.ts +256 -0
  307. package/src/WorkletsModule/index.ts +7 -0
  308. package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
  309. package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
  310. package/src/WorkletsModule/workletsModuleProxy.ts +126 -0
  311. package/src/bundleUnpacker.ts +75 -0
  312. package/src/callGuard.ts +33 -0
  313. package/src/deprecated.ts +32 -0
  314. package/src/errors.ts +80 -0
  315. package/src/featureFlags/index.ts +72 -0
  316. package/src/featureFlags/staticFlags.json +4 -0
  317. package/src/index.ts +53 -0
  318. package/src/initializers.ts +262 -0
  319. package/src/isSynchronizable.ts +13 -0
  320. package/src/logger.ts +16 -0
  321. package/src/privateGlobals.d.ts +79 -0
  322. package/src/publicGlobals.ts +39 -0
  323. package/src/runLoop/common/setImmediatePolyfill.ts +20 -0
  324. package/src/runLoop/common/setIntervalPolyfill.ts +38 -0
  325. package/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts +11 -0
  326. package/src/runLoop/uiRuntime/requestAnimationFrame.ts +66 -0
  327. package/src/runLoop/uiRuntime/setTimeoutPolyfill.ts +40 -0
  328. package/src/runLoop/workletRuntime/index.ts +18 -0
  329. package/src/runLoop/workletRuntime/queueMicrotask.ts +13 -0
  330. package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +61 -0
  331. package/src/runLoop/workletRuntime/setTimeout.ts +37 -0
  332. package/src/runLoop/workletRuntime/taskQueue.ts +44 -0
  333. package/src/runtimeKind.ts +37 -0
  334. package/src/runtimes.ts +193 -0
  335. package/src/serializable.ts +801 -0
  336. package/src/serializableMappingCache.ts +42 -0
  337. package/src/specs/NativeWorkletsModule.kepler.ts +11 -0
  338. package/src/specs/NativeWorkletsModule.ts +9 -0
  339. package/src/specs/index.ts +13 -0
  340. package/src/synchronizable.ts +32 -0
  341. package/src/synchronizableUnpacker.ts +67 -0
  342. package/src/threads.ts +452 -0
  343. package/src/utils/checkCppVersion.ts +34 -0
  344. package/src/utils/jsVersion.ts +7 -0
  345. package/src/valueUnpacker.ts +90 -0
  346. package/src/workletFunction.ts +42 -0
  347. package/src/workletRuntimeEntry.ts +35 -0
  348. package/src/workletTypes.ts +81 -0
@@ -0,0 +1,39 @@
1
+ node_modules/@amzn/react-native-worklets_1/src/index.ts:92dc5fad3e3c1eeb4368
2
+ node_modules/@amzn/react-native-worklets_1/src/runtimeKind.ts:c61bd1d326ebb2baf5b9
3
+ node_modules/@amzn/react-native-worklets_1/src/WorkletsModule/index.ts:9450964c02b706827b89
4
+ node_modules/@amzn/react-native-worklets_1/src/WorkletsModule/workletsModuleInstance.ts:e79c59849894fd2eba81
5
+ node_modules/@amzn/react-native-worklets_1/src/PlatformChecker/index.ts:8aea4a1fe67b9152ae38
6
+ node_modules/@amzn/react-native-worklets_1/src/PlatformChecker/PlatformChecker.ts:7c985777cfff18a29798
7
+ node_modules/@amzn/react-native-worklets_1/src/WorkletsModule/JSWorklets.ts:879795fe4f62c2ff3488
8
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts:72f11271103bf8ddffba
9
+ node_modules/@amzn/react-native-worklets_1/src/WorkletsError.ts:80a0712d800414a8838a
10
+ node_modules/@amzn/react-native-worklets_1/src/WorkletsModule/NativeWorklets.ts:ca34ec291cb9aae170e3
11
+ node_modules/@amzn/react-native-worklets_1/src/utils/jsVersion.ts:fe5c8ac3d1ad6d8b767c
12
+ node_modules/@amzn/react-native-worklets_1/src/specs/index.ts:ee9af6e25724f0b06aa0
13
+ node_modules/@amzn/react-native-worklets_1/src/specs/NativeWorkletsModule.kepler.ts:d4a43c6a0f0a92da5b7f
14
+ node_modules/@amzn/react-native-worklets_1/src/threads.ts:57269a569e68db39f877
15
+ node_modules/@amzn/react-native-worklets_1/src/serializable.ts:4b5d5d7ee5afc1561858
16
+ node_modules/@amzn/react-native-worklets_1/src/serializableMappingCache.ts:b7986763a699028eec54
17
+ node_modules/@amzn/react-native-worklets_1/src/workletFunction.ts:e4cf6b5e8a9c81f6eeff
18
+ node_modules/@amzn/react-native-worklets_1/src/isSynchronizable.ts:74e162ea64939358d949
19
+ node_modules/@amzn/react-native-worklets_1/src/logger.ts:51a72bffa8e86d7e7a5d
20
+ node_modules/@amzn/react-native-worklets_1/src/synchronizable.ts:36f8eb64e47bac46f42b
21
+ node_modules/@amzn/react-native-worklets_1/src/runtimes.ts:50ca147e06e1da2ca8fa
22
+ node_modules/@amzn/react-native-worklets_1/src/initializers.ts:2b74ece7a557c3b3fa49
23
+ node_modules/@amzn/react-native-worklets_1/src/bundleUnpacker.ts:6a9818d606734fb8416e
24
+ node_modules/@amzn/react-native-worklets_1/src/synchronizableUnpacker.ts:57ccf9652fbf59f79c4c
25
+ node_modules/@amzn/react-native-worklets_1/src/errors.ts:5d1c55fd565874fe9e81
26
+ node_modules/@amzn/react-native-worklets_1/src/callGuard.ts:230af24ef4079adb05d7
27
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/uiRuntime/requestAnimationFrame.ts:5aeb6347f6febeb18aef
28
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/uiRuntime/setTimeoutPolyfill.ts:9c04cddeca5fcd2c7198
29
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/common/setImmediatePolyfill.ts:4d73e3d5ecf23f11ffa4
30
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/common/setIntervalPolyfill.ts:f0e787d0a0a9a2c35fcd
31
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/workletRuntime/index.ts:d07e735ad5410f41845d
32
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/workletRuntime/taskQueue.ts:70fb444782abd8166215
33
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/workletRuntime/queueMicrotask.ts:db789b4a6b8711586dd7
34
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/workletRuntime/setTimeout.ts:edf6238aaab78ba17e71
35
+ node_modules/@amzn/react-native-worklets_1/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts:9a1bd7cba70f58b1b662
36
+ node_modules/@amzn/react-native-worklets_1/src/featureFlags/index.ts:2317d96aabfc07d73724
37
+ node_modules/@amzn/react-native-worklets_1/src/deprecated.ts:cec2482e114cab853b83
38
+ node_modules/@amzn/react-native-worklets_1/src/publicGlobals.ts:f984eca71d566323835c
39
+ node_modules/@amzn/react-native-worklets_1/src/workletRuntimeEntry.ts:693a19bd3e7620854352
@@ -0,0 +1,61 @@
1
+ node_modules/@babel/runtime_7.28.6/helpers/interopRequireDefault.js:1658e9d806cecc7d513f
2
+ node_modules/@babel/runtime_7.28.6/helpers/classCallCheck.js:058f50a76315fc88ad5c
3
+ node_modules/@babel/runtime_7.28.6/helpers/createClass.js:0d1487bbdd0385fe6673
4
+ node_modules/@babel/runtime_7.28.6/helpers/toPropertyKey.js:48405da1a82590964a03
5
+ node_modules/@babel/runtime_7.28.6/helpers/toPrimitive.js:0f8abf3c8b18480a6d47
6
+ node_modules/@babel/runtime_7.28.6/helpers/typeof.js:13ae0d75f4934933ecaf
7
+ node_modules/@babel/runtime_7.28.6/helpers/possibleConstructorReturn.js:4aa94a74d7bb7221b923
8
+ node_modules/@babel/runtime_7.28.6/helpers/assertThisInitialized.js:25fb38428dda46d6800f
9
+ node_modules/@babel/runtime_7.28.6/helpers/getPrototypeOf.js:d2ca1962320a7fc595a6
10
+ node_modules/@babel/runtime_7.28.6/helpers/get.js:d8dcd13dae0a344bbc4a
11
+ node_modules/@babel/runtime_7.28.6/helpers/superPropBase.js:1f15365ae02704dfefe4
12
+ node_modules/@babel/runtime_7.28.6/helpers/inherits.js:c3969dfc5dcf704d89df
13
+ node_modules/@babel/runtime_7.28.6/helpers/setPrototypeOf.js:8b411d7eeb55832922af
14
+ node_modules/@babel/runtime_7.28.6/helpers/classPrivateFieldLooseBase.js:84b970236b4776e847c4
15
+ node_modules/@babel/runtime_7.28.6/helpers/classPrivateFieldLooseKey.js:c408e8c609dabd10913e
16
+ node_modules/invariant_2.2.4/browser.js:fd099686726b2dfb6f66
17
+ node_modules/@babel/runtime_7.28.6/helpers/slicedToArray.js:b5c3a0dfb06038f36d1a
18
+ node_modules/@babel/runtime_7.28.6/helpers/arrayWithHoles.js:3e4d5f17df2fc26aca06
19
+ node_modules/@babel/runtime_7.28.6/helpers/iterableToArrayLimit.js:7c9be9833a5bd1bcfc84
20
+ node_modules/@babel/runtime_7.28.6/helpers/unsupportedIterableToArray.js:41618dd1a0cab1d4d4b6
21
+ node_modules/@babel/runtime_7.28.6/helpers/arrayLikeToArray.js:b23f086000fa770c51b1
22
+ node_modules/@babel/runtime_7.28.6/helpers/nonIterableRest.js:7fc60d42dbf0dbb04c4b
23
+ node_modules/@react-native/normalize-colors_0.83.0/index.js:e8e087936fed8afe0814
24
+ node_modules/@babel/runtime_7.28.6/helpers/objectWithoutProperties.js:c4820e134611e601fe3c
25
+ node_modules/@babel/runtime_7.28.6/helpers/objectWithoutPropertiesLoose.js:2819355eb1660a78a270
26
+ node_modules/nullthrows_1.1.1/nullthrows.js:afd4874b36ccd4e13961
27
+ node_modules/@react-native/assets-registry_0.83.0/registry.js:5ff9e23a9ba5a1a1e0ac
28
+ node_modules/@react-native/assets-registry_0.83.0/path-support.js:fb4eb45d6b2fc494317c
29
+ node_modules/@babel/runtime_7.28.6/helpers/wrapNativeSuper.js:583997f8f86d03f2b30d
30
+ node_modules/@babel/runtime_7.28.6/helpers/isNativeFunction.js:251a25cb216e38430b20
31
+ node_modules/@babel/runtime_7.28.6/helpers/construct.js:594614f416b5f1160b89
32
+ node_modules/@babel/runtime_7.28.6/helpers/isNativeReflectConstruct.js:f3459bbdfb4afe15ce21
33
+ node_modules/promise_8.3.0/setimmediate/es6-extensions.js:a7846fdeffeb1ebf6241
34
+ node_modules/promise_8.3.0/setimmediate/core.js:890f60fa94d3f6854a19
35
+ node_modules/promise_8.3.0/setimmediate/finally.js:15bc4ccb25fc2d0c4428
36
+ node_modules/stacktrace-parser_0.1.11/dist/stack-trace-parser.cjs.js:aa725aa4c0b37e1add33
37
+ node_modules/regenerator-runtime_0.13.11/runtime.js:af823d9710c534173a4d
38
+ node_modules/base64-js_1.5.1/index.js:71af70f51435e3e1b37b
39
+ node_modules/whatwg-fetch_3.6.20/dist/fetch.umd.js:ca4b0363146267ef3e77
40
+ node_modules/abort-controller_3.0.0/dist/abort-controller.js:ea8fcbd647aab1cfcdaa
41
+ node_modules/event-target-shim_5.0.1/dist/event-target-shim.js:2bd3f165b1ed6b916de7
42
+ node_modules/scheduler_0.27.0/index.native.js:ec9ec59f48073ee6e9f5
43
+ node_modules/scheduler_0.27.0/cjs/scheduler.native.production.js:d8f1930d0c79328207a3
44
+ node_modules/@babel/runtime_7.28.6/helpers/readOnlyError.js:09c040dc0dcec28a54ae
45
+ node_modules/@react-native/virtualized-lists_0.83.0/index.js:a7726730afdc356adbe4
46
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizeUtils.js:d0ff6d3d1f2c9580ab13
47
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizedList.js:8d139349672eea405ffb
48
+ node_modules/@react-native/virtualized-lists_0.83.0/Utilities/clamp.js:a78a6606e498a2fdbf2d
49
+ node_modules/@react-native/virtualized-lists_0.83.0/Utilities/infoLog.js:017b2813127d2e7f4d70
50
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/ChildListCollection.js:9c3630060e6e634bfb8b
51
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/FillRateHelper.js:c1e83141f045b25e26fc
52
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/ListMetricsAggregator.js:480fcd792bed2eb457f3
53
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/StateSafePureComponent.js:fd4823cbe6aa108a7d62
54
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/ViewabilityHelper.js:a44a41089be71f9f7b1e
55
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizedListCellRenderer.js:8aa7cf31c704a4a85db2
56
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizedListContext.js:4b89f56515b0628d3446
57
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizedListProps.js:516cf3cf4ecb4e256407
58
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/CellRenderMask.js:95aa36c0870d6d5cfdb1
59
+ node_modules/@react-native/virtualized-lists_0.83.0/Lists/VirtualizedSectionList.js:cb8631f113fda0d4a92c
60
+ node_modules/memoize-one_5.2.1/dist/memoize-one.cjs.js:d381691ed29bec5a2050
61
+ node_modules/@babel/runtime_7.28.6/helpers/asyncToGenerator.js:949e187ecf57bddc8118
@@ -0,0 +1,7 @@
1
+ {
2
+ "@amzn/react-native-worklets": {
3
+ "nameOnDevice": "index.amzn__react-native-worklets-1.hermes.bundle",
4
+ "modulesPath": "amzn__react-native-worklets-1.modules.txt",
5
+ "privateModulesPath": "amzn__react-native-worklets-1.private.modules.txt"
6
+ }
7
+ }
@@ -0,0 +1,124 @@
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
+ -DWORKLETS_VERSION=${WORKLETS_VERSION}\
19
+ -DWORKLETS_FEATURE_FLAGS=\"${WORKLETS_FEATURE_FLAGS}\"")
20
+
21
+ string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer -fstack-protector-all")
22
+
23
+ if(${IS_REANIMATED_EXAMPLE_APP})
24
+ string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP -Wpedantic")
25
+ endif()
26
+ if(${WORKLETS_BUNDLE_MODE})
27
+ string(APPEND CMAKE_CXX_FLAGS " -DWORKLETS_BUNDLE_MODE")
28
+ endif()
29
+
30
+ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
31
+ string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
32
+ endif()
33
+
34
+ if(${JS_RUNTIME} STREQUAL "hermes")
35
+ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
36
+ elseif(${JS_RUNTIME} STREQUAL "jsc")
37
+ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
38
+ else()
39
+ message(FATAL_ERROR "Unknown JS runtime ${JS_RUNTIME}.")
40
+ endif()
41
+
42
+ set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
43
+ set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
44
+ set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")
45
+
46
+ file(GLOB_RECURSE WORKLETS_COMMON_CPP_SOURCES CONFIGURE_DEPENDS
47
+ "${COMMON_CPP_DIR}/worklets/*.cpp")
48
+ file(GLOB_RECURSE WORKLETS_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS
49
+ "${ANDROID_CPP_DIR}/worklets/*.cpp")
50
+
51
+ # Consume shared libraries and headers from prefabs
52
+ find_package(fbjni REQUIRED CONFIG)
53
+ find_package(ReactAndroid REQUIRED CONFIG)
54
+
55
+ if(${JS_RUNTIME} STREQUAL "hermes")
56
+ find_package(hermes-engine REQUIRED CONFIG)
57
+ endif()
58
+
59
+ add_library(worklets SHARED ${WORKLETS_COMMON_CPP_SOURCES}
60
+ ${WORKLETS_ANDROID_CPP_SOURCES})
61
+
62
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
63
+ include(
64
+ "${REACT_NATIVE_DIR}/ReactCommon/cmake-utils/react-native-flags.cmake")
65
+ target_compile_reactnative_options(worklets PUBLIC)
66
+ else()
67
+ string(APPEND CMAKE_CXX_FLAGS
68
+ " -fexceptions -frtti -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
69
+ endif()
70
+
71
+ # includes
72
+ target_include_directories(worklets PUBLIC "${COMMON_CPP_DIR}"
73
+ "${ANDROID_CPP_DIR}")
74
+
75
+ target_include_directories(
76
+ worklets
77
+ PRIVATE "${REACT_NATIVE_DIR}/ReactCommon"
78
+ "${REACT_NATIVE_DIR}/ReactCommon/yoga"
79
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
80
+ "${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core/ReactCommon"
81
+ "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
82
+ "${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
83
+ "${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
84
+ "${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
85
+ )
86
+
87
+ if(ReactAndroid_VERSION_MINOR LESS 76)
88
+ target_link_libraries(
89
+ worklets ReactAndroid::fabricjni ReactAndroid::react_debug
90
+ ReactAndroid::react_render_core
91
+ ReactAndroid::react_render_componentregistry ReactAndroid::rrc_view)
92
+ endif()
93
+
94
+ # build shared lib
95
+ set_target_properties(worklets PROPERTIES LINKER_LANGUAGE CXX)
96
+
97
+ target_link_libraries(worklets log ReactAndroid::jsi fbjni::fbjni)
98
+
99
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
100
+ target_link_libraries(worklets ReactAndroid::reactnative)
101
+ else()
102
+ target_link_libraries(
103
+ worklets ReactAndroid::react_nativemodule_core ReactAndroid::folly_runtime
104
+ ReactAndroid::glog ReactAndroid::reactnativejni)
105
+ endif()
106
+
107
+ if(${JS_RUNTIME} STREQUAL "hermes")
108
+ target_link_libraries(worklets hermes-engine::libhermes)
109
+
110
+ if(${HERMES_ENABLE_DEBUGGER})
111
+ string(APPEND CMAKE_CXX_FLAGS " -DHERMES_ENABLE_DEBUGGER=1")
112
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
113
+ target_link_libraries(worklets ReactAndroid::hermestooling)
114
+ else()
115
+ target_link_libraries(worklets ReactAndroid::hermes_executor)
116
+ endif()
117
+ endif()
118
+ elseif(${JS_RUNTIME} STREQUAL "jsc")
119
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
120
+ target_link_libraries(worklets ReactAndroid::jsctooling)
121
+ else()
122
+ target_link_libraries(worklets ReactAndroid::jscexecutor)
123
+ endif()
124
+ endif()
@@ -0,0 +1,350 @@
1
+ import com.android.build.gradle.tasks.ExternalNativeBuildJsonTask
2
+ import groovy.json.JsonSlurper
3
+ import java.nio.file.Paths
4
+ import org.apache.tools.ant.taskdefs.condition.Os
5
+
6
+ def safeExtGet(prop, fallback) {
7
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
8
+ }
9
+
10
+ def safeAppExtGet(prop, fallback) {
11
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
12
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
13
+ }
14
+
15
+ def isNewArchitectureEnabled() {
16
+ // To opt-in for the New Architecture, you can either:
17
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
18
+ // - Invoke gradle with `-newArchEnabled=true`
19
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
20
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
21
+ }
22
+
23
+ def resolveReactNativeDirectory() {
24
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
25
+ if (reactNativeLocation != null) {
26
+ return file(reactNativeLocation)
27
+ }
28
+
29
+ // Fallback to node resolver for custom directory structures like monorepos.
30
+ def reactNativePackage = file(
31
+ providers.exec {
32
+ workingDir(rootDir)
33
+ commandLine("node", "--print", "require.resolve('react-native/package.json')")
34
+ }.standardOutput.asText.get().trim()
35
+ )
36
+ if (reactNativePackage.exists()) {
37
+ return reactNativePackage.parentFile
38
+ }
39
+
40
+ throw new GradleException(
41
+ "[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."
42
+ )
43
+ }
44
+
45
+ def getReactNativeVersion() {
46
+ def reactNativeRootDir = resolveReactNativeDirectory()
47
+ def reactProperties = new Properties()
48
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
49
+ return reactProperties.getProperty("VERSION_NAME")
50
+ }
51
+
52
+ def getReactNativeMinorVersion() {
53
+ def reactNativeVersion = getReactNativeVersion()
54
+ return reactNativeVersion.startsWith("0.0.0-") ? 1000 : reactNativeVersion.split("\\.")[1].toInteger()
55
+ }
56
+
57
+ def getWorkletsVersion() {
58
+ def inputFile = file(projectDir.path + '/../package.json')
59
+ def json = new JsonSlurper().parseText(inputFile.text)
60
+ return json.version
61
+ }
62
+
63
+ def toPlatformFileString(String path) {
64
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
65
+ path = path.replace(File.separatorChar, '/' as char)
66
+ }
67
+ return path
68
+ }
69
+
70
+ def getStaticFeatureFlags() {
71
+ def featureFlags = new HashMap<String, String>()
72
+
73
+ def staticFeatureFlagsFile = file(projectDir.path + "/../src/featureFlags/staticFlags.json")
74
+ if (!staticFeatureFlagsFile.exists()) {
75
+ throw new GradleException("[Worklets] Feature flags file not found at ${staticFeatureFlagsFile.absolutePath}.")
76
+ }
77
+ new JsonSlurper().parseText(staticFeatureFlagsFile.text).each { key, value ->
78
+ featureFlags[key] = value.toString()
79
+ }
80
+
81
+ def packageJsonFile = file(rootDir.path + "/../package.json")
82
+ if (packageJsonFile.exists()) {
83
+ def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
84
+ packageJson.worklets?.staticFeatureFlags?.each { key, value ->
85
+ featureFlags[key] = value.toString()
86
+ }
87
+ }
88
+
89
+ return featureFlags.collect { key, value -> "[${key}:${value}]" }.join("")
90
+ }
91
+
92
+ if (isNewArchitectureEnabled()) {
93
+ apply plugin: "com.facebook.react"
94
+ }
95
+
96
+ def packageDir = project.projectDir.parentFile
97
+ def reactNativeRootDir = resolveReactNativeDirectory()
98
+ def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
99
+ def REACT_NATIVE_VERSION = getReactNativeVersion()
100
+ def WORKLETS_VERSION = getWorkletsVersion()
101
+ def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
102
+ def IS_REANIMATED_EXAMPLE_APP = safeAppExtGet("isReanimatedExampleApp", false)
103
+ def BUNDLE_MODE = safeAppExtGet("workletsBundleMode", false)
104
+ def WORKLETS_FEATURE_FLAGS = getStaticFeatureFlags()
105
+
106
+ // Set version for prefab
107
+ version WORKLETS_VERSION
108
+
109
+ def workletsPrefabHeadersDir = project.file("$buildDir/prefab-headers/worklets")
110
+
111
+ def JS_RUNTIME = {
112
+ // Override JS runtime with environment variable
113
+ if (System.getenv("JS_RUNTIME")) {
114
+ return System.getenv("JS_RUNTIME")
115
+ }
116
+
117
+ // Check if Hermes is enabled in app setup
118
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
119
+ if (appProject?.hermesEnabled?.toBoolean() || appProject?.ext?.react?.enableHermes?.toBoolean()) {
120
+ return "hermes"
121
+ }
122
+
123
+ // Use JavaScriptCore (JSC) by default
124
+ return "jsc"
125
+ }.call()
126
+
127
+ def reactNativeArchitectures() {
128
+ def value = project.getProperties().get("reactNativeArchitectures")
129
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
130
+ }
131
+
132
+ buildscript {
133
+ repositories {
134
+ google()
135
+ mavenCentral()
136
+ }
137
+ dependencies {
138
+ classpath "com.android.tools.build:gradle:8.2.1"
139
+ classpath "de.undercouch:gradle-download-task:5.6.0"
140
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
141
+ }
142
+ }
143
+
144
+ if (project == rootProject) {
145
+ apply from: "spotless.gradle"
146
+ }
147
+
148
+ apply plugin: "com.android.library"
149
+ apply plugin: "maven-publish"
150
+ apply plugin: "de.undercouch.download"
151
+
152
+
153
+ android {
154
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
155
+
156
+ namespace "com.swmansion.worklets"
157
+
158
+ if (rootProject.hasProperty("ndkPath")) {
159
+ ndkPath rootProject.ext.ndkPath
160
+ }
161
+ if (rootProject.hasProperty("ndkVersion")) {
162
+ ndkVersion rootProject.ext.ndkVersion
163
+ }
164
+
165
+ buildFeatures {
166
+ prefab true
167
+ prefabPublishing true
168
+ buildConfig true
169
+ }
170
+
171
+ prefab {
172
+ worklets {
173
+ headers workletsPrefabHeadersDir.absolutePath
174
+ }
175
+ }
176
+
177
+ defaultConfig {
178
+ minSdkVersion safeExtGet("minSdkVersion", 23)
179
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
180
+ versionCode 1
181
+ versionName WORKLETS_VERSION
182
+
183
+ buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
184
+ buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
185
+ buildConfigField("int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString())
186
+ buildConfigField("boolean", "BUNDLE_MODE", BUNDLE_MODE.toString())
187
+
188
+ externalNativeBuild {
189
+ cmake {
190
+ arguments "-DANDROID_STL=c++_shared",
191
+ "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
192
+ "-DANDROID_TOOLCHAIN=clang",
193
+ "-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
194
+ "-DJS_RUNTIME=${JS_RUNTIME}",
195
+ "-DIS_REANIMATED_EXAMPLE_APP=${IS_REANIMATED_EXAMPLE_APP}",
196
+ "-DWORKLETS_BUNDLE_MODE=${BUNDLE_MODE}",
197
+ "-DWORKLETS_VERSION=${WORKLETS_VERSION}",
198
+ "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
199
+ "-DWORKLETS_FEATURE_FLAGS=${WORKLETS_FEATURE_FLAGS}"
200
+ abiFilters (*reactNativeArchitectures())
201
+ targets("worklets")
202
+ }
203
+ }
204
+
205
+ consumerProguardFiles 'proguard-rules.pro'
206
+ }
207
+ externalNativeBuild {
208
+ cmake {
209
+ version = System.getenv("CMAKE_VERSION") ?: "3.22.1"
210
+ path "CMakeLists.txt"
211
+ }
212
+ }
213
+ buildTypes {
214
+ debug {
215
+ externalNativeBuild {
216
+ cmake {
217
+ if (JS_RUNTIME == "hermes") {
218
+ // React Native doesn't expose these flags, but not having them
219
+ // can lead to runtime errors due to ABI mismatches.
220
+ // There's also
221
+ // HERMESVM_PROFILER_OPCODE
222
+ // HERMESVM_PROFILER_BB
223
+ // which shouldn't be defined in standard setups.
224
+ arguments "-DHERMES_ENABLE_DEBUGGER=1"
225
+ }
226
+ }
227
+ }
228
+ packagingOptions {
229
+ doNotStrip "**/**/*.so"
230
+ }
231
+ }
232
+ }
233
+ lintOptions {
234
+ abortOnError false
235
+ }
236
+ packagingOptions {
237
+ // For some reason gradle only complains about the duplicated version of librrc_root and libreact_render libraries
238
+ // while there are more libraries copied in intermediates folder of the lib build directory, we exclude
239
+ // only the ones that make the build fail (ideally we should only include libreanimated but we
240
+ // are only allowed to specify exclude patterns)
241
+ excludes = [
242
+ "META-INF",
243
+ "META-INF/**",
244
+ "**/libc++_shared.so",
245
+ "**/libfbjni.so",
246
+ "**/libjsi.so",
247
+ "**/libfolly_json.so",
248
+ "**/libfolly_runtime.so",
249
+ "**/libglog.so",
250
+ "**/libhermes.so",
251
+ "**/libhermes-executor-debug.so",
252
+ "**/libhermes_executor.so",
253
+ "**/libhermestooling.so",
254
+ "**/libreactnativejni.so",
255
+ "**/libturbomodulejsijni.so",
256
+ "**/libreactnative.so",
257
+ "**/libreact_nativemodule_core.so",
258
+ "**/libreact_render*.so",
259
+ "**/librrc_root.so",
260
+ "**/libjscexecutor.so",
261
+ ]
262
+ }
263
+ compileOptions {
264
+ sourceCompatibility JavaVersion.VERSION_17
265
+ targetCompatibility JavaVersion.VERSION_17
266
+ }
267
+ sourceSets {
268
+ main {
269
+ java {
270
+ if (BUNDLE_MODE) {
271
+ srcDirs += "src/experimentalBundling"
272
+ } else {
273
+ srcDirs += "src/legacyBundling"
274
+ }
275
+ }
276
+ }
277
+ }
278
+ tasks.withType(ExternalNativeBuildJsonTask) {
279
+ compileTask ->
280
+ compileTask.doLast {
281
+ if (!IS_REANIMATED_EXAMPLE_APP) {
282
+ return
283
+ }
284
+
285
+ def generated = new File("${compileTask.abi.getCxxBuildFolder()}/compile_commands.json")
286
+ def output = new File("${packageDir}/compile_commands.json")
287
+
288
+ output.text = generated.text
289
+
290
+ println("Generated clangd metadata.")
291
+ }
292
+ }
293
+ }
294
+
295
+ def validateReactNativeVersionResult = providers.exec {
296
+ workingDir(projectDir.path)
297
+ commandLine("node", "./../scripts/validate-react-native-version.js", REACT_NATIVE_VERSION.toString())
298
+ ignoreExitValue = true
299
+ }
300
+
301
+ task assertMinimalReactNativeVersionTask {
302
+ doFirst {
303
+ if (validateReactNativeVersionResult.getResult().get().exitValue != 0) {
304
+ throw new GradleException(validateReactNativeVersionResult.getStandardError().getAsText().get().trim())
305
+ }
306
+ }
307
+ }
308
+
309
+ preBuild.dependsOn(assertMinimalReactNativeVersionTask)
310
+
311
+ task assertNewArchitectureEnabledTask {
312
+ onlyIf { !IS_NEW_ARCHITECTURE_ENABLED }
313
+ doFirst {
314
+ throw new GradleException("[Worklets] Worklets require new architecture to be enabled. Please enable it by setting `newArchEnabled` to `true` in `gradle.properties`.")
315
+ }
316
+ }
317
+
318
+ preBuild.dependsOn(assertNewArchitectureEnabledTask)
319
+
320
+ task prepareWorkletsHeadersForPrefabs(type: Copy) {
321
+ from("$projectDir/src/main/cpp")
322
+ from("$projectDir/../Common/cpp")
323
+ include("worklets/**/*.h")
324
+ into(workletsPrefabHeadersDir)
325
+ }
326
+
327
+ task cleanCmakeCache() {
328
+ tasks.getByName("clean").dependsOn(cleanCmakeCache)
329
+ doFirst {
330
+ delete "${projectDir}/.cxx"
331
+ }
332
+ }
333
+
334
+ repositories {
335
+ mavenCentral()
336
+ google()
337
+ }
338
+
339
+ dependencies {
340
+ implementation "com.facebook.yoga:proguard-annotations:1.19.0"
341
+ implementation "androidx.transition:transition:1.1.0"
342
+ implementation "androidx.core:core:1.6.0"
343
+
344
+ implementation "com.facebook.react:react-android" // version substituted by RNGP
345
+ if (JS_RUNTIME == "hermes") {
346
+ implementation "com.facebook.react:hermes-android" // version substituted by RNGP
347
+ }
348
+ }
349
+
350
+ preBuild.dependsOn(prepareWorkletsHeadersForPrefabs)
@@ -0,0 +1,5 @@
1
+ Worklets_kotlinVersion=1.7.0
2
+ Worklets_minSdkVersion=21
3
+ Worklets_targetSdkVersion=31
4
+ Worklets_compileSdkVersion=31
5
+ Worklets_ndkversion=21.4.7075529
@@ -0,0 +1,3 @@
1
+ -keep class com.swmansion.worklets.** { *; }
2
+ -keep class com.facebook.react.turbomodule.** { *; }
3
+ -keep class com.facebook.react.fabric.** { *; }
@@ -0,0 +1,9 @@
1
+ // formatter & linter configuration for java
2
+ apply plugin: 'com.diffplug.spotless'
3
+
4
+ spotless {
5
+ java {
6
+ target 'src/**/*.java'
7
+ googleJavaFormat()
8
+ }
9
+ }