@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,102 @@
1
+ #pragma once
2
+
3
+ #include <cxxreact/MessageQueueThread.h>
4
+ #include <jsi/jsi.h>
5
+ #include <jsireact/JSIExecutor.h>
6
+ #include <react/debug/react_native_assert.h>
7
+
8
+ #include <worklets/Public/AsyncQueue.h>
9
+ #include <worklets/RunLoop/AsyncQueueImpl.h>
10
+ #include <worklets/RunLoop/EventLoop.h>
11
+ #include <worklets/SharedItems/Serializable.h>
12
+ #include <worklets/Tools/JSScheduler.h>
13
+ #include <worklets/WorkletRuntime/RuntimeData.h>
14
+
15
+ #include <memory>
16
+ #include <string>
17
+ #include <utility>
18
+ #include <vector>
19
+
20
+ using namespace facebook;
21
+ using namespace react;
22
+
23
+ namespace worklets {
24
+
25
+ /**
26
+ * Forward declaration to avoid circular dependencies.
27
+ */
28
+ class JSIWorkletsModuleProxy;
29
+
30
+ class WorkletRuntime : public jsi::HostObject,
31
+ public std::enable_shared_from_this<WorkletRuntime> {
32
+ public:
33
+ explicit WorkletRuntime(
34
+ uint64_t runtimeId,
35
+ const std::shared_ptr<MessageQueueThread> &jsQueue,
36
+ const std::string &name,
37
+ const std::shared_ptr<AsyncQueue> &queue = nullptr,
38
+ bool enableEventLoop = true);
39
+
40
+ void init(std::shared_ptr<JSIWorkletsModuleProxy> jsiWorkletsModuleProxy);
41
+
42
+ facebook::jsi::Runtime &getJSIRuntime() const {
43
+ return *runtime_;
44
+ }
45
+
46
+ template <typename... Args>
47
+ inline jsi::Value runGuarded(
48
+ const std::shared_ptr<SerializableWorklet> &serializableWorklet,
49
+ Args &&...args) const {
50
+ jsi::Runtime &rt = *runtime_;
51
+ return runOnRuntimeGuarded(
52
+ rt, serializableWorklet->toJSValue(rt), std::forward<Args>(args)...);
53
+ }
54
+
55
+ void runAsyncGuarded(const std::shared_ptr<SerializableWorklet> &worklet);
56
+
57
+ jsi::Value executeSync(facebook::jsi::Runtime &rt, const facebook::jsi::Value &worklet) const;
58
+
59
+ #ifdef WORKLETS_BUNDLE_MODE
60
+ jsi::Value executeSync(std::function<jsi::Value(jsi::Runtime &)> &&job) const;
61
+
62
+ jsi::Value executeSync(
63
+ const std::function<jsi::Value(jsi::Runtime &)> &job) const;
64
+ #endif // WORKLETS_BUNDLE_MODE
65
+
66
+ std::string toString() const {
67
+ return "[WorkletRuntime \"" + name_ + "\"]";
68
+ }
69
+
70
+ jsi::Value get(facebook::jsi::Runtime &rt, const facebook::jsi::PropNameID &propName) override;
71
+
72
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
73
+
74
+ [[nodiscard]] auto getRuntimeId() const -> uint64_t {
75
+ return runtimeId_;
76
+ }
77
+
78
+ [[nodiscard]] auto getRuntimeName() const -> std::string {
79
+ return name_;
80
+ }
81
+
82
+ private:
83
+ const uint64_t runtimeId_;
84
+ const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
85
+ const std::shared_ptr<jsi::Runtime> runtime_;
86
+ const std::string name_;
87
+ std::shared_ptr<AsyncQueue> queue_;
88
+ std::shared_ptr<EventLoop> eventLoop_;
89
+ };
90
+
91
+ // This function needs to be non-inline to avoid problems with dynamic_cast on
92
+ // Android
93
+ std::shared_ptr<WorkletRuntime> extractWorkletRuntime(
94
+ jsi::Runtime &rt,
95
+ const jsi::Value &value);
96
+
97
+ void scheduleOnRuntime(
98
+ jsi::Runtime &rt,
99
+ const jsi::Value &workletRuntimeValue,
100
+ const jsi::Value &serializableWorkletValue);
101
+
102
+ } // namespace worklets
@@ -0,0 +1,36 @@
1
+ #pragma once
2
+
3
+ #include <worklets/Registries/WorkletRuntimeRegistry.h>
4
+
5
+ #include <jsi/jsi.h>
6
+
7
+ #include <memory>
8
+
9
+ namespace worklets {
10
+
11
+ class WorkletRuntimeCollector : public jsi::HostObject {
12
+ // When worklet runtime is created, we inject an instance of this class as a
13
+ // `jsi::HostObject` into the global object. When worklet runtime is
14
+ // terminated, the object is garbage-collected, which runs the C++ destructor.
15
+ // In the destructor, we unregister the worklet runtime from the registry.
16
+
17
+ public:
18
+ explicit WorkletRuntimeCollector(jsi::Runtime &runtime) : runtime_(runtime) {
19
+ WorkletRuntimeRegistry::registerRuntime(runtime_);
20
+ }
21
+
22
+ ~WorkletRuntimeCollector() {
23
+ WorkletRuntimeRegistry::unregisterRuntime(runtime_);
24
+ }
25
+
26
+ static void install(jsi::Runtime &rt) {
27
+ auto collector = std::make_shared<WorkletRuntimeCollector>(rt);
28
+ auto object = jsi::Object::createFromHostObject(rt, collector);
29
+ rt.global().setProperty(rt, "__workletRuntimeCollector", object);
30
+ }
31
+
32
+ private:
33
+ jsi::Runtime &runtime_;
34
+ };
35
+
36
+ } // namespace worklets
@@ -0,0 +1,308 @@
1
+ #include <worklets/SharedItems/Serializable.h>
2
+ #include <worklets/Tools/JSISerializer.h>
3
+ #include <worklets/Tools/PlatformLogger.h>
4
+ #include <worklets/Tools/WorkletsJSIUtils.h>
5
+ #include <worklets/WorkletRuntime/RuntimeKind.h>
6
+ #include <worklets/WorkletRuntime/WorkletRuntime.h>
7
+ #include <worklets/WorkletRuntime/WorkletRuntimeDecorator.h>
8
+
9
+ #include <utility>
10
+ #include <vector>
11
+
12
+ namespace worklets {
13
+
14
+ static inline double performanceNow() {
15
+ // copied from JSExecutor.cpp
16
+ auto time = std::chrono::steady_clock::now();
17
+ auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
18
+ time.time_since_epoch())
19
+ .count();
20
+
21
+ constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
22
+ return duration / NANOSECONDS_IN_MILLISECOND;
23
+ }
24
+
25
+ static inline std::vector<jsi::Value> parseArgs(
26
+ jsi::Runtime &rt,
27
+ std::shared_ptr<SerializableArray> serializableArgs) {
28
+ if (serializableArgs == nullptr) {
29
+ return {};
30
+ }
31
+
32
+ auto argsArray = serializableArgs->toJSValue(rt).asObject(rt).asArray(rt);
33
+ auto argsSize = argsArray.size(rt);
34
+ std::vector<jsi::Value> result(argsSize);
35
+ for (size_t i = 0; i < argsSize; i++) {
36
+ result[i] = argsArray.getValueAtIndex(rt, i);
37
+ }
38
+ return result;
39
+ }
40
+
41
+ void WorkletRuntimeDecorator::decorate(
42
+ jsi::Runtime &rt,
43
+ const std::string &name,
44
+ const std::shared_ptr<JSScheduler> &jsScheduler,
45
+ const bool isDevBundle,
46
+ jsi::Object &&jsiWorkletsModuleProxy,
47
+ const std::shared_ptr<EventLoop> &eventLoop) {
48
+ // resolves "ReferenceError: Property 'global' doesn't exist at ..."
49
+ rt.global().setProperty(rt, "global", rt.global());
50
+
51
+ rt.global().setProperty(
52
+ rt, runtimeKindBindingName, static_cast<int>(RuntimeKind::Worker));
53
+
54
+ rt.global().setProperty(rt, "_WORKLET", true);
55
+
56
+ rt.global().setProperty(rt, "_LABEL", jsi::String::createFromAscii(rt, name));
57
+
58
+ // TODO: Remove _IS_FABRIC sometime in the future
59
+ // react-native-screens 4.9.0 depends on it
60
+ rt.global().setProperty(rt, "_IS_FABRIC", true);
61
+
62
+ rt.global().setProperty(rt, "__DEV__", isDevBundle);
63
+
64
+ rt.global().setProperty(
65
+ rt, "__workletsModuleProxy", std::move(jsiWorkletsModuleProxy));
66
+
67
+ #ifndef NDEBUG
68
+ auto evalWithSourceUrl = [](jsi::Runtime &rt,
69
+ const jsi::Value &thisValue,
70
+ const jsi::Value *args,
71
+ size_t count) -> jsi::Value {
72
+ auto code = std::make_shared<const jsi::StringBuffer>(
73
+ args[0].asString(rt).utf8(rt));
74
+ std::string url;
75
+ if (count > 1 && args[1].isString()) {
76
+ url = args[1].asString(rt).utf8(rt);
77
+ }
78
+ return rt.evaluateJavaScript(code, url);
79
+ };
80
+ rt.global().setProperty(
81
+ rt,
82
+ "evalWithSourceUrl",
83
+ jsi::Function::createFromHostFunction(
84
+ rt,
85
+ jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
86
+ 1,
87
+ evalWithSourceUrl));
88
+ #endif // NDEBUG
89
+
90
+ jsi_utils::installJsiFunction(
91
+ rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
92
+ PlatformLogger::log(stringifyJSIValue(rt, value));
93
+ });
94
+
95
+ jsi_utils::installJsiFunction(
96
+ rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
97
+ return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
98
+ });
99
+
100
+ jsi_utils::installJsiFunction(
101
+ rt,
102
+ "_createSerializable",
103
+ [](jsi::Runtime &rt,
104
+ const jsi::Value &value,
105
+ const jsi::Value &nativeStateSource) {
106
+ auto shouldRetainRemote = jsi::Value::undefined();
107
+ return makeSerializableClone(
108
+ rt, value, shouldRetainRemote, nativeStateSource);
109
+ });
110
+
111
+ jsi_utils::installJsiFunction(
112
+ rt,
113
+ "_createSerializableHostObject",
114
+ [](jsi::Runtime &rt, const jsi::Value &value) {
115
+ return makeSerializableHostObject(
116
+ rt, value.asObject(rt).asHostObject(rt));
117
+ });
118
+
119
+ jsi_utils::installJsiFunction(
120
+ rt,
121
+ "_createSerializableString",
122
+ [](jsi::Runtime &rt, const jsi::Value &value) {
123
+ return makeSerializableString(rt, value.asString(rt));
124
+ });
125
+
126
+ jsi_utils::installJsiFunction(
127
+ rt,
128
+ "_createSerializableNumber",
129
+ [](jsi::Runtime &rt, const jsi::Value &value) {
130
+ return makeSerializableNumber(rt, value.asNumber());
131
+ });
132
+
133
+ jsi_utils::installJsiFunction(
134
+ rt,
135
+ "_createSerializableBoolean",
136
+ [](jsi::Runtime &rt, const jsi::Value &value) {
137
+ return makeSerializableBoolean(rt, value.asBool());
138
+ });
139
+
140
+ jsi_utils::installJsiFunction(
141
+ rt,
142
+ "_createSerializableBigInt",
143
+ [](jsi::Runtime &rt, const jsi::Value &value) {
144
+ return makeSerializableBigInt(rt, value.asBigInt(rt));
145
+ });
146
+
147
+ jsi_utils::installJsiFunction(
148
+ rt, "_createSerializableUndefined", [](jsi::Runtime &rt) {
149
+ return makeSerializableUndefined(rt);
150
+ });
151
+
152
+ jsi_utils::installJsiFunction(
153
+ rt,
154
+ "_createSerializableArray",
155
+ [](jsi::Runtime &rt, const jsi::Value &value) {
156
+ return makeSerializableArray(rt, value.asObject(rt).asArray(rt), false);
157
+ });
158
+
159
+ jsi_utils::installJsiFunction(
160
+ rt, "_createSerializableNull", [](jsi::Runtime &rt) {
161
+ return makeSerializableNull(rt);
162
+ });
163
+
164
+ jsi_utils::installJsiFunction(
165
+ rt,
166
+ "_createSerializableObject",
167
+ [](jsi::Runtime &rt,
168
+ const jsi::Value &value,
169
+ const jsi::Value &shouldRetainRemote,
170
+ const jsi::Value &nativeStateSource) {
171
+ return makeSerializableObject(
172
+ rt,
173
+ value.getObject(rt),
174
+ shouldRetainRemote.getBool(),
175
+ nativeStateSource);
176
+ });
177
+
178
+ jsi_utils::installJsiFunction(
179
+ rt,
180
+ "_createSerializableWorklet",
181
+ [](jsi::Runtime &rt, const jsi::Value &value) {
182
+ return makeSerializableWorklet(rt, value.asObject(rt), false);
183
+ });
184
+
185
+ jsi_utils::installJsiFunction(
186
+ rt,
187
+ "_createSerializableInitializer",
188
+ [](jsi::Runtime &rt, const jsi::Value &value) {
189
+ return makeSerializableInitializer(rt, value.asObject(rt));
190
+ });
191
+
192
+ jsi_utils::installJsiFunction(
193
+ rt,
194
+ "_createSerializableFunction",
195
+ [](jsi::Runtime &rt, const jsi::Value &value) {
196
+ return makeSerializableFunction(rt, value.asObject(rt).asFunction(rt));
197
+ });
198
+
199
+ jsi_utils::installJsiFunction(
200
+ rt,
201
+ "_createSerializableSynchronizable",
202
+ [](jsi::Runtime &rt, const jsi::Value &value) {
203
+ return SerializableJSRef::newNativeStateObject(
204
+ rt, extractSerializableOrThrow(rt, value));
205
+ });
206
+
207
+ jsi_utils::installJsiFunction(
208
+ rt,
209
+ "_scheduleRemoteFunctionOnJS",
210
+ [jsScheduler](
211
+ jsi::Runtime &rt,
212
+ const jsi::Value &funValue,
213
+ const jsi::Value &argsValue) {
214
+ auto serializableRemoteFun = extractSerializableOrThrow<
215
+ SerializableRemoteFunction>(
216
+ rt,
217
+ funValue,
218
+ "[Worklets] Incompatible object passed to scheduleOnJS. It is only allowed to schedule worklets or functions defined on the React Native JS runtime this way.");
219
+
220
+ auto serializableArgs = argsValue.isUndefined()
221
+ ? nullptr
222
+ : extractSerializableOrThrow<SerializableArray>(
223
+ rt, argsValue, "[Worklets] Args must be an array.");
224
+
225
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
226
+ auto fun =
227
+ serializableRemoteFun->toJSValue(rt).asObject(rt).asFunction(rt);
228
+ if (serializableArgs == nullptr) {
229
+ // fast path for remote function w/o arguments
230
+ fun.call(rt);
231
+ } else {
232
+ auto args = parseArgs(rt, serializableArgs);
233
+ fun.call(
234
+ rt, const_cast<const jsi::Value *>(args.data()), args.size());
235
+ }
236
+ });
237
+ });
238
+
239
+ jsi_utils::installJsiFunction(
240
+ rt,
241
+ "_scheduleHostFunctionOnJS",
242
+ [jsScheduler](
243
+ jsi::Runtime &rt,
244
+ const jsi::Value &hostFunValue,
245
+ const jsi::Value &argsValue) {
246
+ auto hostFun =
247
+ hostFunValue.asObject(rt).asFunction(rt).getHostFunction(rt);
248
+
249
+ auto serializableArgs = argsValue.isUndefined()
250
+ ? nullptr
251
+ : extractSerializableOrThrow<SerializableArray>(
252
+ rt, argsValue, "[Worklets] Args must be an array.");
253
+
254
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) {
255
+ auto args = parseArgs(rt, serializableArgs);
256
+ hostFun(
257
+ rt,
258
+ jsi::Value::undefined(),
259
+ const_cast<const jsi::Value *>(args.data()),
260
+ args.size());
261
+ });
262
+ });
263
+
264
+ jsi_utils::installJsiFunction(
265
+ rt,
266
+ "_scheduleOnRuntime",
267
+ [](jsi::Runtime &rt,
268
+ const jsi::Value &workletRuntimeValue,
269
+ const jsi::Value &serializableWorkletValue) {
270
+ scheduleOnRuntime(rt, workletRuntimeValue, serializableWorkletValue);
271
+ });
272
+
273
+ jsi::Object performance(rt);
274
+ performance.setProperty(
275
+ rt,
276
+ "now",
277
+ jsi::Function::createFromHostFunction(
278
+ rt,
279
+ jsi::PropNameID::forAscii(rt, "now"),
280
+ 0,
281
+ [](jsi::Runtime &runtime,
282
+ const jsi::Value &,
283
+ const jsi::Value *args,
284
+ size_t count) { return jsi::Value(performanceNow()); }));
285
+ rt.global().setProperty(rt, "performance", performance);
286
+
287
+ jsi_utils::installJsiFunction(
288
+ rt,
289
+ "_scheduleTimeoutCallback",
290
+ [weakEventLoop = std::weak_ptr<EventLoop>(eventLoop)](
291
+ jsi::Runtime &rt,
292
+ const jsi::Value &delayJs,
293
+ const jsi::Value &handlerIdJs) -> jsi::Value {
294
+ const auto delay = delayJs.asNumber();
295
+ const auto handlerId = handlerIdJs.asNumber();
296
+ const auto job = [handlerId](jsi::Runtime &rt) {
297
+ rt.global()
298
+ .getPropertyAsFunction(rt, "__runTimeoutCallback")
299
+ .call(rt, handlerId);
300
+ };
301
+ if (auto strongEventLoop = weakEventLoop.lock()) {
302
+ strongEventLoop->pushTimeout(job, delay);
303
+ }
304
+ return jsi::Value::undefined();
305
+ });
306
+ }
307
+
308
+ } // namespace worklets
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+
3
+ #include <worklets/RunLoop/EventLoop.h>
4
+ #include <worklets/Tools/JSScheduler.h>
5
+
6
+ #include <jsi/jsi.h>
7
+
8
+ #include <memory>
9
+ #include <string>
10
+
11
+ using namespace facebook;
12
+
13
+ namespace worklets {
14
+
15
+ class WorkletRuntimeDecorator {
16
+ public:
17
+ static void decorate(
18
+ jsi::Runtime &rt,
19
+ const std::string &name,
20
+ const std::shared_ptr<JSScheduler> &jsScheduler,
21
+ const bool isDevBundle,
22
+ jsi::Object &&jsiWorkletsModuleProxy,
23
+ const std::shared_ptr<EventLoop> &eventLoop);
24
+ };
25
+
26
+ } // namespace worklets
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
2
+
3
+ These materials are licensed as "Program Materials" under the Program Materials License Agreement (the "Agreement"). The Agreement is available at https://developer.amazon.com/support/legal/pml. See the Agreement for the specific terms and conditions of the Agreement. Capitalized terms not defined in this file have the meanings given to them in the Agreement.
4
+
5
+ If you do not agree to the above terms and conditions, you may not use any file in this package.
6
+
7
+ YOUR USE OF THE PROGRAM MATERIALS IN OR ASSOCIATED WITH THIS PACKAGE IS AT YOUR SOLE RISK. IN NO EVENT WILL AMAZON BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL, INCIDENTAL, OR PUNITIVE DAMAGES (INCLUDING FOR ANY LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, OR COMPUTER FAILURE OR MALFUNCTION) ARISING FROM OR RELATING TO SUCH PROGRAM MATERIALS, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, EVEN IF AMAZON HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS AND DISCLAIMERS APPLY EXCEPT TO THE EXTENT PROHIBITED BY APPLICABLE LAW.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ ![header](https://github.com/user-attachments/assets/41b37472-e55a-4c54-9064-31258e03870c)
2
+
3
+ ### The React Native multithreading library
4
+
5
+ React Native Worklets is a library that allows you to run JavaScript code in parallel on multiple threads and runtimes.
6
+
7
+ While the library is in transitional period where we hone the API, all its features are functionally stable and ready to use in production.
8
+
9
+ ## Documentation
10
+
11
+ Check out our dedicated documentation page for info about this library, API reference and more: [https://docs.swmansion.com/react-native-worklets/](https://docs.swmansion.com/react-native-worklets/)
12
+
13
+ ## License
14
+
15
+ Worklets library is licensed under [The MIT License](LICENSE).
16
+
17
+ ## Credits
18
+
19
+ 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)
20
+
21
+ [![shopify](https://avatars1.githubusercontent.com/u/8085?v=3&s=100 'Shopify.com')](https://shopify.com)
22
+ [![expo](https://avatars2.githubusercontent.com/u/12504344?v=3&s=100 'Expo.io')](https://expo.io)
23
+ [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-reanimated-github 'Software Mansion')](https://swmansion.com)
24
+
25
+ ## Community Discord
26
+
27
+ [Join the Software Mansion Community Discord](https://discord.swmansion.com) to chat about Worklets or other Software Mansion libraries.
28
+
29
+ ## Worklets are created by Software Mansion
30
+
31
+ 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,94 @@
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
+ $new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] != '0'
9
+ worklets_assert_new_architecture_enabled($new_arch_enabled)
10
+
11
+ ios_min_version = '13.4'
12
+
13
+ feature_flags = "-DWORKLETS_FEATURE_FLAGS=\"#{worklets_get_static_feature_flags()}\""
14
+ version_flags = "-DWORKLETS_VERSION=#{package['version']}"
15
+
16
+ Pod::Spec.new do |s|
17
+ s.name = "RNWorklets"
18
+ s.version = package["version"]
19
+ s.summary = package["description"]
20
+ s.homepage = "https://github.com/software-mansion/react-native-reanimated"
21
+ s.license = package["license"]
22
+ s.authors = { "author" => "author@domain.com" }
23
+ s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
24
+ s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }
25
+
26
+ s.subspec "worklets" do |ss|
27
+ ss.source_files = "Common/cpp/worklets/**/*.{cpp,h}"
28
+ ss.header_dir = "worklets"
29
+ ss.header_mappings_dir = "Common/cpp/worklets"
30
+
31
+ ss.subspec "apple" do |sss|
32
+ # Please be careful with the snakes.
33
+ # 🐍🐍🐍
34
+ # Thank you for your understanding.
35
+ sss.source_files = "apple/worklets/**/*.{mm,h,m}"
36
+ sss.header_dir = "worklets"
37
+ sss.header_mappings_dir = "apple/worklets"
38
+ end
39
+ end
40
+
41
+ # Use install_modules_dependencies helper to install the dependencies.
42
+ # See https://github.com/facebook/react-native/blob/c925872e72d2422be46670777bfa2111e13c9e4c/packages/react-native/scripts/cocoapods/new_architecture.rb#L71.
43
+ install_modules_dependencies(s)
44
+
45
+ s.dependency 'React-jsi'
46
+ using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
47
+ if using_hermes && !$worklets_config[:is_tvos_target]
48
+ s.dependency 'React-hermes'
49
+ end
50
+
51
+ # React Native doesn't expose these flags, but not having them
52
+ # can lead to runtime errors due to ABI mismatches.
53
+ # There's also
54
+ # HERMESVM_PROFILER_OPCODE
55
+ # HERMESVM_PROFILER_BB
56
+ # which shouldn't be defined in standard setups.
57
+ hermes_debug_hidden_flags = 'HERMES_ENABLE_DEBUGGER=1'
58
+
59
+ bundle_mode_flag = $worklets_config[:bundle_mode] ? 'WORKLETS_BUNDLE_MODE=1' : ''
60
+
61
+ s.pod_target_xcconfig = {
62
+ "USE_HEADERMAP" => "YES",
63
+ "DEFINES_MODULE" => "YES",
64
+ "HEADER_SEARCH_PATHS" => [
65
+ '"$(PODS_TARGET_SRCROOT)/ReactCommon"',
66
+ '"$(PODS_TARGET_SRCROOT)"',
67
+ '"$(PODS_ROOT)/RCT-Folly"',
68
+ '"$(PODS_ROOT)/boost"',
69
+ '"$(PODS_ROOT)/boost-for-react-native"',
70
+ '"$(PODS_ROOT)/DoubleConversion"',
71
+ '"$(PODS_ROOT)/Headers/Private/React-Core"',
72
+ '"$(PODS_ROOT)/Headers/Private/Yoga"',
73
+ ].join(' '),
74
+ "FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
75
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
76
+ "GCC_PREPROCESSOR_DEFINITIONS[config=*Debug*]" => "$(inherited) #{hermes_debug_hidden_flags} #{bundle_mode_flag}",
77
+ "GCC_PREPROCESSOR_DEFINITIONS[config=*Release*]" => "$(inherited) #{bundle_mode_flag}",
78
+ "OTHER_CFLAGS" => "$(inherited) #{feature_flags} #{version_flags}",
79
+ }
80
+ s.xcconfig = {
81
+ "HEADER_SEARCH_PATHS" => [
82
+ '"$(PODS_ROOT)/boost"',
83
+ '"$(PODS_ROOT)/boost-for-react-native"',
84
+ '"$(PODS_ROOT)/glog"',
85
+ '"$(PODS_ROOT)/RCT-Folly"',
86
+ '"$(PODS_ROOT)/Headers/Public/React-hermes"',
87
+ '"$(PODS_ROOT)/Headers/Public/hermes-engine"',
88
+ "\"$(PODS_ROOT)/#{$worklets_config[:react_native_common_dir]}\"",
89
+ "\"$(PODS_ROOT)/#{$worklets_config[:dynamic_frameworks_worklets_dir]}/apple\"",
90
+ "\"$(PODS_ROOT)/#{$worklets_config[:dynamic_frameworks_worklets_dir]}/Common/cpp\"",
91
+ ].join(' '),
92
+ }
93
+
94
+ end