react-native-reanimated 3.0.0-rc.9 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
  3. package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
  4. package/Common/cpp/Fabric/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
  7. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
  9. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
  16. package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
  17. package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
  18. package/Common/cpp/SharedItems/Shareables.cpp +9 -63
  19. package/Common/cpp/SharedItems/Shareables.h +77 -72
  20. package/Common/cpp/Tools/CollectionUtils.h +14 -0
  21. package/Common/cpp/Tools/JsiUtils.cpp +26 -0
  22. package/Common/cpp/Tools/JsiUtils.h +176 -0
  23. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
  24. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  25. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  26. package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
  27. package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
  28. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
  29. package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
  30. package/RNReanimated.podspec +2 -1
  31. package/android/CMakeLists.txt +188 -181
  32. package/android/build.gradle +362 -311
  33. package/android/proguard-rules.pro +2 -0
  34. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  35. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  36. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  37. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  38. package/android/src/main/cpp/NativeProxy.h +22 -28
  39. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  40. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  41. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  42. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  48. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  53. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  56. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  57. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  60. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  61. package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
  63. package/ios/LayoutReanimation/REAFrame.h +10 -0
  64. package/ios/LayoutReanimation/REAFrame.m +15 -0
  65. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  67. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  68. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  69. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  71. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  72. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  73. package/ios/LayoutReanimation/REAUIManager.mm +64 -17
  74. package/ios/REAModule.mm +2 -7
  75. package/ios/REANodesManager.mm +1 -21
  76. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  77. package/ios/native/NativeProxy.mm +75 -114
  78. package/ios/native/REAInitializer.mm +2 -7
  79. package/ios/native/REAJSIUtils.h +60 -2
  80. package/ios/sensor/ReanimatedSensor.h +6 -2
  81. package/ios/sensor/ReanimatedSensor.m +43 -7
  82. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  83. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  84. package/lib/commonjs/createAnimatedComponent.js +232 -28
  85. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  86. package/lib/commonjs/reanimated2/Colors.js +43 -22
  87. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  88. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  90. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  92. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  93. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  94. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  96. package/lib/commonjs/reanimated2/core.js +33 -14
  97. package/lib/commonjs/reanimated2/core.js.map +1 -1
  98. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  100. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  101. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  102. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  103. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  104. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  106. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  110. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
  112. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  114. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  116. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  118. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  119. package/lib/commonjs/reanimated2/index.js +13 -0
  120. package/lib/commonjs/reanimated2/index.js.map +1 -1
  121. package/lib/commonjs/reanimated2/initializers.js +71 -32
  122. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  123. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  124. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  125. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  126. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  127. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
  128. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  129. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  130. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  132. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  133. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  134. package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
  135. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  136. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  137. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  138. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  139. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  140. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  141. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  145. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  147. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  155. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  157. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  158. package/lib/commonjs/reanimated2/mappers.js +18 -6
  159. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  160. package/lib/commonjs/reanimated2/mock.js +20 -1
  161. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  162. package/lib/commonjs/reanimated2/mutables.js +4 -2
  163. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  164. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  165. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  166. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  167. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  168. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  169. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  170. package/lib/commonjs/reanimated2/shareables.js +36 -15
  171. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  172. package/lib/commonjs/reanimated2/threads.js +114 -4
  173. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  174. package/lib/commonjs/reanimated2/utils.js +7 -0
  175. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  176. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  177. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  178. package/lib/module/createAnimatedComponent.js +229 -29
  179. package/lib/module/createAnimatedComponent.js.map +1 -1
  180. package/lib/module/reanimated2/Colors.js +35 -19
  181. package/lib/module/reanimated2/Colors.js.map +1 -1
  182. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
  183. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  184. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  185. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  186. package/lib/module/reanimated2/animation/util.js +17 -16
  187. package/lib/module/reanimated2/animation/util.js.map +1 -1
  188. package/lib/module/reanimated2/commonTypes.js +29 -0
  189. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  190. package/lib/module/reanimated2/core.js +32 -7
  191. package/lib/module/reanimated2/core.js.map +1 -1
  192. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  193. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  194. package/lib/module/reanimated2/globals.d.js.map +1 -1
  195. package/lib/module/reanimated2/hook/index.js +1 -1
  196. package/lib/module/reanimated2/hook/index.js.map +1 -1
  197. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  198. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  199. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  200. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  201. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  202. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  203. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  204. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
  206. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  208. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  210. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  211. package/lib/module/reanimated2/hook/utils.js +17 -60
  212. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  213. package/lib/module/reanimated2/index.js +1 -0
  214. package/lib/module/reanimated2/index.js.map +1 -1
  215. package/lib/module/reanimated2/initializers.js +72 -33
  216. package/lib/module/reanimated2/initializers.js.map +1 -1
  217. package/lib/module/reanimated2/interpolateColor.js +96 -19
  218. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  219. package/lib/module/reanimated2/jestUtils.js +1 -1
  220. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  221. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
  222. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  223. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  224. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  225. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  226. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  227. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  228. package/lib/module/reanimated2/js-reanimated/global.js +0 -2
  229. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  230. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  231. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  232. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  233. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  234. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  235. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  236. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
  237. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  238. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  239. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  241. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  243. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  245. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  249. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  251. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  252. package/lib/module/reanimated2/mappers.js +16 -6
  253. package/lib/module/reanimated2/mappers.js.map +1 -1
  254. package/lib/module/reanimated2/mock.js +20 -1
  255. package/lib/module/reanimated2/mock.js.map +1 -1
  256. package/lib/module/reanimated2/mutables.js +4 -2
  257. package/lib/module/reanimated2/mutables.js.map +1 -1
  258. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  259. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  260. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  261. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  262. package/lib/module/reanimated2/pluginUtils.js +4 -0
  263. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  264. package/lib/module/reanimated2/shareables.js +36 -12
  265. package/lib/module/reanimated2/shareables.js.map +1 -1
  266. package/lib/module/reanimated2/threads.js +105 -4
  267. package/lib/module/reanimated2/threads.js.map +1 -1
  268. package/lib/module/reanimated2/utils.js +5 -0
  269. package/lib/module/reanimated2/utils.js.map +1 -1
  270. package/lib/module/reanimated2/valueSetter.js +1 -2
  271. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  272. package/package.json +10 -10
  273. package/{plugin.js → plugin/index.js} +128 -249
  274. package/react-native-reanimated.d.ts +57 -10
  275. package/scripts/reanimated_utils.rb +15 -2
  276. package/src/createAnimatedComponent.tsx +238 -28
  277. package/src/reanimated2/Colors.ts +38 -11
  278. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
  279. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  280. package/src/reanimated2/animation/util.ts +29 -16
  281. package/src/reanimated2/commonTypes.ts +28 -1
  282. package/src/reanimated2/core.ts +42 -9
  283. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  284. package/src/reanimated2/globals.d.ts +12 -15
  285. package/src/reanimated2/hook/index.ts +1 -1
  286. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  287. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  288. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  289. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  290. package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
  291. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  292. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  293. package/src/reanimated2/hook/utils.ts +15 -61
  294. package/src/reanimated2/index.ts +1 -0
  295. package/src/reanimated2/initializers.ts +76 -35
  296. package/src/reanimated2/interpolateColor.ts +104 -20
  297. package/src/reanimated2/jestUtils.ts +1 -1
  298. package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
  299. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  300. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  301. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  302. package/src/reanimated2/js-reanimated/global.ts +0 -1
  303. package/src/reanimated2/js-reanimated/index.ts +0 -1
  304. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  305. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  306. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
  307. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  308. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  309. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  310. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  311. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  312. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  313. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  314. package/src/reanimated2/mappers.ts +17 -6
  315. package/src/reanimated2/mock.ts +24 -1
  316. package/src/reanimated2/mutables.ts +2 -0
  317. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  318. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  319. package/src/reanimated2/pluginUtils.ts +8 -0
  320. package/src/reanimated2/shareables.ts +45 -16
  321. package/src/reanimated2/threads.ts +103 -1
  322. package/src/reanimated2/utils.ts +6 -0
  323. package/src/reanimated2/valueSetter.ts +1 -2
  324. package/lib/commonjs/reanimated2/time.js +0 -55
  325. package/lib/commonjs/reanimated2/time.js.map +0 -1
  326. package/lib/module/reanimated2/time.js +0 -37
  327. package/lib/module/reanimated2/time.js.map +0 -1
  328. package/src/reanimated2/time.ts +0 -30
  329. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -10,7 +10,7 @@ void EventHandlerRegistry::registerEventHandler(
10
10
  eventHandlers[eventHandler->id] = eventHandler;
11
11
  }
12
12
 
13
- void EventHandlerRegistry::unregisterEventHandler(unsigned long id) {
13
+ void EventHandlerRegistry::unregisterEventHandler(uint64_t id) {
14
14
  const std::lock_guard<std::mutex> lock(instanceMutex);
15
15
  auto handlerIt = eventHandlers.find(id);
16
16
  if (handlerIt != eventHandlers.end()) {
@@ -24,13 +24,9 @@ void EventHandlerRegistry::unregisterEventHandler(unsigned long id) {
24
24
 
25
25
  void EventHandlerRegistry::processEvent(
26
26
  jsi::Runtime &rt,
27
- std::string eventName,
28
- #ifdef RCT_NEW_ARCH_ENABLED
29
- jsi::Value &eventPayload
30
- #else
31
- std::string eventPayload
32
- #endif
33
- /**/) {
27
+ double eventTimestamp,
28
+ const std::string &eventName,
29
+ const jsi::Value &eventPayload) {
34
30
  std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
35
31
  {
36
32
  const std::lock_guard<std::mutex> lock(instanceMutex);
@@ -41,38 +37,16 @@ void EventHandlerRegistry::processEvent(
41
37
  }
42
38
  }
43
39
  }
44
- #ifdef RCT_NEW_ARCH_ENABLED
45
- eventPayload.asObject(rt).setProperty(
46
- rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
47
- for (auto handler : handlersForEvent) {
48
- handler->process(rt, eventPayload);
49
- }
50
- #else
51
- // We receive here a JS Map with JSON as a value of NativeMap key
52
- // { NativeMap: { "jsonProp": "json value" } }
53
- // So we need to extract only JSON part
54
- std::string delimimter = "NativeMap:";
55
- auto positionToSplit = eventPayload.find(delimimter) + delimimter.size();
56
- auto lastBracketCharactedPosition = eventPayload.size() - positionToSplit - 1;
57
- auto eventJSON =
58
- eventPayload.substr(positionToSplit, lastBracketCharactedPosition);
59
40
 
60
- if (eventJSON.compare(std::string("null")) == 0) {
61
- return;
62
- }
63
-
64
- auto eventObject = jsi::Value::createFromJsonUtf8(
65
- rt, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
66
-
67
- eventObject.asObject(rt).setProperty(
41
+ eventPayload.asObject(rt).setProperty(
68
42
  rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
69
43
  for (auto handler : handlersForEvent) {
70
- handler->process(rt, eventObject);
44
+ handler->process(eventTimestamp, eventPayload);
71
45
  }
72
- #endif
73
46
  }
74
47
 
75
- bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(std::string eventName) {
48
+ bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
49
+ const std::string &eventName) {
76
50
  const std::lock_guard<std::mutex> lock(instanceMutex);
77
51
  auto it = eventMappings.find(eventName);
78
52
  return (it != eventMappings.end()) && (!(it->second).empty());
@@ -18,28 +18,22 @@ class WorkletEventHandler;
18
18
  class EventHandlerRegistry {
19
19
  std::map<
20
20
  std::string,
21
- std::unordered_map<unsigned long, std::shared_ptr<WorkletEventHandler>>>
21
+ std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
22
22
  eventMappings;
23
- std::map<unsigned long, std::shared_ptr<WorkletEventHandler>> eventHandlers;
23
+ std::map<uint64_t, std::shared_ptr<WorkletEventHandler>> eventHandlers;
24
24
  std::mutex instanceMutex;
25
25
 
26
26
  public:
27
27
  void registerEventHandler(std::shared_ptr<WorkletEventHandler> eventHandler);
28
- void unregisterEventHandler(unsigned long id);
28
+ void unregisterEventHandler(uint64_t id);
29
29
 
30
- #ifdef RCT_NEW_ARCH_ENABLED
31
30
  void processEvent(
32
31
  jsi::Runtime &rt,
33
- std::string eventName,
34
- jsi::Value &eventPayload);
35
- #else
36
- void processEvent(
37
- jsi::Runtime &rt,
38
- std::string eventName,
39
- std::string eventPayload);
40
- #endif
32
+ double eventTimestamp,
33
+ const std::string &eventName,
34
+ const jsi::Value &eventPayload);
41
35
 
42
- bool isAnyHandlerWaitingForEvent(std::string eventName);
36
+ bool isAnyHandlerWaitingForEvent(const std::string &eventName);
43
37
  };
44
38
 
45
39
  } // namespace reanimated
@@ -11,10 +11,12 @@ CoreFunction::CoreFunction(
11
11
  jsi::Runtime &rt = *runtimeHelper->rnRuntime();
12
12
  auto workletObject = workletValue.asObject(rt);
13
13
  rnFunction_ = std::make_unique<jsi::Function>(workletObject.asFunction(rt));
14
- functionBody_ =
15
- workletObject.getProperty(rt, "asString").asString(rt).utf8(rt);
14
+ functionBody_ = workletObject.getPropertyAsObject(rt, "__initData")
15
+ .getProperty(rt, "code")
16
+ .asString(rt)
17
+ .utf8(rt);
16
18
  location_ = "worklet_" +
17
- std::to_string(static_cast<unsigned long long>(
19
+ std::to_string(static_cast<uint64_t>(
18
20
  workletObject.getProperty(rt, "__workletHash").getNumber()));
19
21
  }
20
22
 
@@ -59,61 +61,8 @@ std::shared_ptr<Shareable> extractShareableOrThrow(
59
61
 
60
62
  Shareable::~Shareable() {}
61
63
 
62
- #if HAS_JS_WEAK_OBJECTS
63
-
64
- jsi::Value RetainingShareable::getJSValue(jsi::Runtime &rt) {
65
- jsi::Value value;
66
- if (runtimeHelper_->isRNRuntime(rt)) {
67
- // TODO: it is suboptimal to generate new object every time getJS is called
68
- // on host runtime – the objects we are generating already exists and we
69
- // should possibly just grab a hold of such object and use it here instead
70
- // of creating a new JS representation. As far as I understand the only
71
- // case where it can be realistically called this way is when a shared
72
- // value is created and then accessed on the same runtime
73
- return toJSValue(rt);
74
- } else if (remoteValue_ == nullptr) {
75
- value = toJSValue(rt);
76
- remoteValue_ = std::make_unique<jsi::WeakObject>(rt, value.asObject(rt));
77
- } else {
78
- value = remoteValue_->lock(rt);
79
- if (value.isUndefined()) {
80
- value = toJSValue(rt);
81
- remoteValue_ = std::make_unique<jsi::WeakObject>(rt, value.asObject(rt));
82
- }
83
- }
84
- return value;
85
- }
86
-
87
- RetainingShareable::~RetainingShareable() {
88
- if (runtimeHelper_->uiRuntimeDestroyed) {
89
- // The below use of unique_ptr.release prevents the smart pointer from
90
- // calling the destructor of the kept object. This effectively results in
91
- // leaking some memory. We do this on purpose, as sometimes we would keep
92
- // references to JSI objects past the lifetime of its runtime (e.g., shared
93
- // values references from the RN VM holds reference to JSI objects on the
94
- // UI runtime). When the UI runtime is terminated, the orphaned JSI objects
95
- // would crash the app when their destructors are called, because they
96
- // call into a memory that's managed by the terminated runtime. We accept
97
- // the tradeoff of leaking memory here, as it has a limited impact. This
98
- // scenario can only occur when the React instance is torn down which
99
- // happens in development mode during app reloads, or in production when the
100
- // app is being shut down gracefully by the system. An alternative solution
101
- // would require us to keep track of all JSI values that are in use which
102
- // would require additional data structure and compute spent on bookkeeping
103
- // that only for the sake of destroying the values in time before the
104
- // runtime is terminated. Note that the underlying memory that jsi::Value
105
- // refers to is managed by the VM and gets freed along with the runtime.
106
- remoteValue_.release();
107
- }
108
- }
109
-
110
- #endif // HAS_JS_WEAK_OBJECTS
111
-
112
- ShareableArray::ShareableArray(
113
- const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
114
- jsi::Runtime &rt,
115
- const jsi::Array &array)
116
- : RetainingShareable(runtimeHelper, rt, ArrayType) {
64
+ ShareableArray::ShareableArray(jsi::Runtime &rt, const jsi::Array &array)
65
+ : Shareable(ArrayType) {
117
66
  auto size = array.size(rt);
118
67
  data_.reserve(size);
119
68
  for (size_t i = 0; i < size; i++) {
@@ -121,11 +70,8 @@ ShareableArray::ShareableArray(
121
70
  }
122
71
  }
123
72
 
124
- ShareableObject::ShareableObject(
125
- const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
126
- jsi::Runtime &rt,
127
- const jsi::Object &object)
128
- : RetainingShareable(runtimeHelper, rt, ObjectType) {
73
+ ShareableObject::ShareableObject(jsi::Runtime &rt, const jsi::Object &object)
74
+ : Shareable(ObjectType) {
129
75
  auto propertyNames = object.getPropertyNames(rt);
130
76
  auto size = propertyNames.size(rt);
131
77
  data_.reserve(size);
@@ -6,16 +6,10 @@
6
6
  #include <utility>
7
7
  #include <vector>
8
8
 
9
- #ifdef RCT_NEW_ARCH_ENABLED
10
- #include <react/renderer/uimanager/primitives.h>
11
- #endif
12
-
13
9
  #include "ReanimatedRuntime.h"
14
10
  #include "RuntimeManager.h"
15
11
  #include "Scheduler.h"
16
12
 
17
- #define HAS_JS_WEAK_OBJECTS (JS_RUNTIME_HERMES || JS_RUNTIME_V8)
18
-
19
13
  using namespace facebook;
20
14
 
21
15
  namespace reanimated {
@@ -57,7 +51,7 @@ class JSRuntimeHelper {
57
51
  const std::shared_ptr<Scheduler> &scheduler)
58
52
  : rnRuntime_(rnRuntime), uiRuntime_(uiRuntime), scheduler_(scheduler) {}
59
53
 
60
- volatile bool uiRuntimeDestroyed;
54
+ volatile bool uiRuntimeDestroyed = false;
61
55
  std::unique_ptr<CoreFunction> callGuard;
62
56
  std::unique_ptr<CoreFunction> valueUnpacker;
63
57
 
@@ -121,9 +115,7 @@ class Shareable {
121
115
  RemoteFunctionType,
122
116
  HandleType,
123
117
  SynchronizedDataHolder,
124
- #ifdef RCT_NEW_ARCH_ENABLED
125
- ShadowNode,
126
- #endif
118
+ HostObjectType,
127
119
  };
128
120
 
129
121
  explicit Shareable(ValueType valueType) : valueType_(valueType) {}
@@ -141,34 +133,57 @@ class Shareable {
141
133
  ValueType valueType_;
142
134
  };
143
135
 
144
- class RetainingShareable : public Shareable {
145
- protected:
146
- std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
147
-
148
- #if HAS_JS_WEAK_OBJECTS
149
-
136
+ template <typename BaseClass>
137
+ class RetainingShareable : virtual public BaseClass {
150
138
  private:
151
- std::unique_ptr<jsi::WeakObject> remoteValue_;
152
-
153
- public:
154
- jsi::Value getJSValue(jsi::Runtime &rt) final;
155
-
156
- RetainingShareable(
157
- const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
158
- jsi::Runtime &rt,
159
- ValueType valueType)
160
- : Shareable(valueType), runtimeHelper_(runtimeHelper) {}
161
-
162
- ~RetainingShareable();
163
- #else
139
+ std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
140
+ std::unique_ptr<jsi::Value> remoteValue_;
164
141
 
165
142
  public:
143
+ template <typename... Args>
166
144
  RetainingShareable(
167
145
  const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
168
- jsi::Runtime &rt,
169
- ValueType valueType)
170
- : Shareable(valueType), runtimeHelper_(runtimeHelper) {}
171
- #endif
146
+ Args &&...args)
147
+ : BaseClass(std::forward<Args>(args)...), runtimeHelper_(runtimeHelper) {}
148
+ jsi::Value getJSValue(jsi::Runtime &rt) {
149
+ if (runtimeHelper_->isRNRuntime(rt)) {
150
+ // TODO: it is suboptimal to generate new object every time getJS is
151
+ // called on host runtime – the objects we are generating already exists
152
+ // and we should possibly just grab a hold of such object and use it here
153
+ // instead of creating a new JS representation. As far as I understand the
154
+ // only case where it can be realistically called this way is when a
155
+ // shared value is created and then accessed on the same runtime
156
+ return BaseClass::toJSValue(rt);
157
+ } else if (remoteValue_ == nullptr) {
158
+ auto value = BaseClass::toJSValue(rt);
159
+ remoteValue_ = std::make_unique<jsi::Value>(rt, value);
160
+ return value;
161
+ }
162
+ return jsi::Value(rt, *remoteValue_);
163
+ }
164
+ ~RetainingShareable() {
165
+ if (runtimeHelper_->uiRuntimeDestroyed) {
166
+ // The below use of unique_ptr.release prevents the smart pointer from
167
+ // calling the destructor of the kept object. This effectively results in
168
+ // leaking some memory. We do this on purpose, as sometimes we would keep
169
+ // references to JSI objects past the lifetime of its runtime (e.g.,
170
+ // shared values references from the RN VM holds reference to JSI objects
171
+ // on the UI runtime). When the UI runtime is terminated, the orphaned JSI
172
+ // objects would crash the app when their destructors are called, because
173
+ // they call into a memory that's managed by the terminated runtime. We
174
+ // accept the tradeoff of leaking memory here, as it has a limited impact.
175
+ // This scenario can only occur when the React instance is torn down which
176
+ // happens in development mode during app reloads, or in production when
177
+ // the app is being shut down gracefully by the system. An alternative
178
+ // solution would require us to keep track of all JSI values that are in
179
+ // use which would require additional data structure and compute spent on
180
+ // bookkeeping that only for the sake of destroying the values in time
181
+ // before the runtime is terminated. Note that the underlying memory that
182
+ // jsi::Value refers to is managed by the VM and gets freed along with the
183
+ // runtime.
184
+ remoteValue_.release();
185
+ }
186
+ }
172
187
  };
173
188
 
174
189
  class ShareableJSRef : public jsi::HostObject {
@@ -210,12 +225,9 @@ std::shared_ptr<T> extractShareableOrThrow(
210
225
  return res;
211
226
  }
212
227
 
213
- class ShareableArray : public RetainingShareable {
228
+ class ShareableArray : public Shareable {
214
229
  public:
215
- ShareableArray(
216
- const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
217
- jsi::Runtime &rt,
218
- const jsi::Array &array);
230
+ ShareableArray(jsi::Runtime &rt, const jsi::Array &array);
219
231
 
220
232
  jsi::Value toJSValue(jsi::Runtime &rt) override {
221
233
  auto size = data_.size();
@@ -230,12 +242,9 @@ class ShareableArray : public RetainingShareable {
230
242
  std::vector<std::shared_ptr<Shareable>> data_;
231
243
  };
232
244
 
233
- class ShareableObject : public RetainingShareable {
245
+ class ShareableObject : public Shareable {
234
246
  public:
235
- ShareableObject(
236
- const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
237
- jsi::Runtime &rt,
238
- const jsi::Object &object);
247
+ ShareableObject(jsi::Runtime &rt, const jsi::Object &object);
239
248
  jsi::Value toJSValue(jsi::Runtime &rt) override {
240
249
  auto obj = jsi::Object(rt);
241
250
  for (size_t i = 0, size = data_.size(); i < size; i++) {
@@ -249,34 +258,31 @@ class ShareableObject : public RetainingShareable {
249
258
  std::vector<std::pair<std::string, std::shared_ptr<Shareable>>> data_;
250
259
  };
251
260
 
252
- #ifdef RCT_NEW_ARCH_ENABLED
253
- class ShareableShadowNodeWrapper : public Shareable {
254
- private:
255
- react::ShadowNode::Shared shadowNode_;
256
-
261
+ class ShareableHostObject : public Shareable {
257
262
  public:
258
- ShareableShadowNodeWrapper(
263
+ ShareableHostObject(
259
264
  const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
260
265
  jsi::Runtime &rt,
261
- const jsi::Object &wrapperObject)
262
- : Shareable(ShadowNode) {
263
- shadowNode_ =
264
- wrapperObject.getHostObject<ShadowNodeWrapper>(rt)->shadowNode;
265
- }
266
+ const std::shared_ptr<jsi::HostObject> &hostObject)
267
+ : Shareable(HostObjectType), hostObject_(hostObject) {}
266
268
  jsi::Value toJSValue(jsi::Runtime &rt) override {
267
- return jsi::Object::createFromHostObject(
268
- rt, std::make_shared<ShadowNodeWrapper>(shadowNode_));
269
+ return jsi::Object::createFromHostObject(rt, hostObject_);
269
270
  }
271
+
272
+ protected:
273
+ std::shared_ptr<jsi::HostObject> hostObject_;
270
274
  };
271
- #endif
272
275
 
273
276
  class ShareableWorklet : public ShareableObject {
277
+ private:
278
+ std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
279
+
274
280
  public:
275
281
  ShareableWorklet(
276
282
  const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
277
283
  jsi::Runtime &rt,
278
284
  const jsi::Object &worklet)
279
- : ShareableObject(runtimeHelper, rt, worklet) {
285
+ : ShareableObject(rt, worklet), runtimeHelper_(runtimeHelper) {
280
286
  valueType_ = WorkletType;
281
287
  }
282
288
  jsi::Value toJSValue(jsi::Runtime &rt) override {
@@ -286,18 +292,20 @@ class ShareableWorklet : public ShareableObject {
286
292
  };
287
293
 
288
294
  class ShareableRemoteFunction
289
- : public RetainingShareable,
295
+ : public Shareable,
290
296
  public std::enable_shared_from_this<ShareableRemoteFunction> {
291
297
  private:
292
298
  jsi::Function function_;
299
+ std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
293
300
 
294
301
  public:
295
302
  ShareableRemoteFunction(
296
303
  const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
297
304
  jsi::Runtime &rt,
298
305
  jsi::Function &&function)
299
- : RetainingShareable(runtimeHelper, rt, RemoteFunctionType),
300
- function_(std::move(function)) {}
306
+ : Shareable(RemoteFunctionType),
307
+ function_(std::move(function)),
308
+ runtimeHelper_(runtimeHelper) {}
301
309
  jsi::Value toJSValue(jsi::Runtime &rt) override {
302
310
  if (runtimeHelper_->isUIRuntime(rt)) {
303
311
  #ifdef DEBUG
@@ -326,8 +334,7 @@ class ShareableHandle : public Shareable {
326
334
  jsi::Runtime &rt,
327
335
  const jsi::Object &initializerObject)
328
336
  : Shareable(HandleType), runtimeHelper_(runtimeHelper) {
329
- initializer_ =
330
- std::make_unique<ShareableObject>(runtimeHelper, rt, initializerObject);
337
+ initializer_ = std::make_unique<ShareableObject>(rt, initializerObject);
331
338
  }
332
339
  ~ShareableHandle() {
333
340
  if (runtimeHelper_->uiRuntimeDestroyed) {
@@ -372,7 +379,7 @@ class ShareableSynchronizedDataHolder
372
379
  std::shared_ptr<Shareable> data_;
373
380
  std::shared_ptr<jsi::Value> uiValue_;
374
381
  std::shared_ptr<jsi::Value> rnValue_;
375
- std::mutex dataAccessLock_;
382
+ std::mutex dataAccessMutex_; // Protects `data_`.
376
383
 
377
384
  public:
378
385
  ShareableSynchronizedDataHolder(
@@ -384,7 +391,7 @@ class ShareableSynchronizedDataHolder
384
391
  data_(extractShareableOrThrow(rt, initialValue)) {}
385
392
 
386
393
  jsi::Value get(jsi::Runtime &rt) {
387
- std::unique_lock<std::mutex> read_lock(dataAccessLock_);
394
+ std::unique_lock<std::mutex> read_lock(dataAccessMutex_);
388
395
  if (runtimeHelper_->isUIRuntime(rt)) {
389
396
  if (uiValue_ == nullptr) {
390
397
  auto value = data_->getJSValue(rt);
@@ -405,7 +412,7 @@ class ShareableSynchronizedDataHolder
405
412
  }
406
413
 
407
414
  void set(jsi::Runtime &rt, const jsi::Value &data) {
408
- std::unique_lock<std::mutex> write_lock(dataAccessLock_);
415
+ std::unique_lock<std::mutex> write_lock(dataAccessMutex_);
409
416
  data_ = extractShareableOrThrow(rt, data);
410
417
  uiValue_.reset();
411
418
  rnValue_.reset();
@@ -418,16 +425,14 @@ class ShareableSynchronizedDataHolder
418
425
 
419
426
  class ShareableString : public Shareable {
420
427
  public:
421
- ShareableString(jsi::Runtime &rt, const jsi::String &string)
422
- : Shareable(StringType) {
423
- data = string.utf8(rt);
424
- }
428
+ explicit ShareableString(const std::string &string)
429
+ : Shareable(StringType), data_(string) {}
425
430
  jsi::Value toJSValue(jsi::Runtime &rt) override {
426
- return jsi::String::createFromUtf8(rt, data);
431
+ return jsi::String::createFromUtf8(rt, data_);
427
432
  }
428
433
 
429
434
  protected:
430
- std::string data;
435
+ std::string data_;
431
436
  };
432
437
 
433
438
  class ShareableScalar : public Shareable {
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+
3
+ #include <algorithm>
4
+
5
+ namespace reanimated {
6
+ namespace collection {
7
+
8
+ template <class CollectionType, class ValueType>
9
+ inline bool contains(CollectionType &collection, const ValueType &value) {
10
+ return collection.find(value) != collection.end();
11
+ }
12
+
13
+ } // namespace collection
14
+ } // namespace reanimated
@@ -0,0 +1,26 @@
1
+ #include "JsiUtils.h"
2
+ #include <vector>
3
+
4
+ using namespace facebook;
5
+
6
+ namespace reanimated::jsi_utils {
7
+
8
+ jsi::Array convertStringToArray(
9
+ jsi::Runtime &rt,
10
+ const std::string &value,
11
+ const unsigned int expectedSize) {
12
+ std::vector<float> transformMatrixList;
13
+ std::istringstream stringStream(value);
14
+ std::copy(
15
+ std::istream_iterator<float>(stringStream),
16
+ std::istream_iterator<float>(),
17
+ std::back_inserter(transformMatrixList));
18
+ assert(transformMatrixList.size() == expectedSize);
19
+ jsi::Array matrix(rt, expectedSize);
20
+ for (int i = 0; i < expectedSize; i++) {
21
+ matrix.setValueAtIndex(rt, i, transformMatrixList[i]);
22
+ }
23
+ return matrix;
24
+ }
25
+
26
+ } // namespace reanimated::jsi_utils