@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,82 @@
1
+ #pragma once
2
+
3
+ #ifndef NDEBUG
4
+
5
+ #include <react/debug/react_native_assert.h>
6
+
7
+ #include <cxxabi.h>
8
+
9
+ #include <atomic>
10
+ #include <cassert>
11
+ #include <iostream>
12
+ #include <string>
13
+
14
+ #ifdef ANDROID
15
+ #include <android/log.h>
16
+ #endif // ANDROID
17
+
18
+ // amzn_mod - use KPLog for logging on Kepler
19
+ #ifdef KEPLER
20
+ #include <KeplerScript/logger/KPLog.h>
21
+ #endif // KEPLER
22
+
23
+ namespace worklets {
24
+
25
+ // This is a class that counts how many instances of a different class there
26
+ // are. It is meant only to be used with classes that should only have one
27
+ // instance.
28
+
29
+ template <class T>
30
+ class SingleInstanceChecker {
31
+ public:
32
+ SingleInstanceChecker();
33
+ ~SingleInstanceChecker();
34
+
35
+ private:
36
+ void assertWithMessage(bool condition, std::string message) {
37
+ if (!condition) {
38
+
39
+ #ifdef ANDROID
40
+ __android_log_print(ANDROID_LOG_WARN, "Worklets", "%s", message.c_str());
41
+ // amzn_mod - add logging on Kepler
42
+ #elif defined(KEPLER)
43
+ volta::react::KPLog.warn("[Worklets] {}", message);
44
+ #else
45
+ std::cerr << "[Worklets] " << message << std::endl;
46
+ #endif
47
+
48
+ #ifdef IS_REANIMATED_EXAMPLE_APP
49
+ react_native_assert(false && "SingleInstanceChecker failed");
50
+ #endif
51
+ }
52
+ }
53
+
54
+ // A static field will exist separately for every class template.
55
+ // This has to be inline for automatic initialization.
56
+ inline static std::atomic<int> instanceCount_;
57
+ };
58
+
59
+ template <class T>
60
+ SingleInstanceChecker<T>::SingleInstanceChecker() {
61
+ int status = 0;
62
+ std::string className =
63
+ __cxxabiv1::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
64
+
65
+ // React Native can spawn up to two instances of a Native Module at the same
66
+ // time. This happens during a reload when a new instance of React Native is
67
+ // created while simultaneously the old one is torn down.
68
+ instanceCount_++;
69
+ assertWithMessage(
70
+ instanceCount_ <= 2,
71
+ "[Worklets] More than two instances of " + className +
72
+ " present. This may indicate a memory leak due to a retain cycle.");
73
+ }
74
+
75
+ template <class T>
76
+ SingleInstanceChecker<T>::~SingleInstanceChecker() {
77
+ instanceCount_--;
78
+ }
79
+
80
+ } // namespace worklets
81
+
82
+ #endif // NDEBUG
@@ -0,0 +1,49 @@
1
+ #pragma once
2
+
3
+ #include <condition_variable>
4
+ #include <mutex>
5
+ #include <queue>
6
+ #include <utility>
7
+
8
+ namespace worklets {
9
+
10
+ //
11
+ // Copyright (c) 2013 Juan Palacios juan.palacios.puyana@gmail.com
12
+ // Subject to the BSD 2-Clause License
13
+ // - see < https://opensource.org/license/bsd-2-clause/ >
14
+ //
15
+ template <typename T>
16
+ class ThreadSafeQueue {
17
+ public:
18
+ T pop() {
19
+ std::unique_lock<std::mutex> mlock(mutex_);
20
+ while (queue_.empty()) {
21
+ cond_.wait(mlock);
22
+ }
23
+ const auto item = queue_.front();
24
+ queue_.pop();
25
+ return item;
26
+ }
27
+
28
+ void push(T &&item) {
29
+ std::unique_lock<std::mutex> mlock(mutex_);
30
+ queue_.push(std::move(item));
31
+ mlock.unlock();
32
+ cond_.notify_one();
33
+ }
34
+
35
+ bool empty() const {
36
+ std::unique_lock<std::mutex> mlock(mutex_);
37
+ const auto res = queue_.empty();
38
+ mlock.unlock();
39
+ cond_.notify_one();
40
+ return res;
41
+ }
42
+
43
+ private:
44
+ std::queue<T> queue_;
45
+ mutable std::mutex mutex_;
46
+ mutable std::condition_variable cond_;
47
+ };
48
+
49
+ } // namespace worklets
@@ -0,0 +1,19 @@
1
+ #include <worklets/Tools/UIScheduler.h>
2
+
3
+ #include <utility>
4
+
5
+ namespace worklets {
6
+
7
+ void UIScheduler::scheduleOnUI(std::function<void()> job) {
8
+ uiJobs_.push(std::move(job));
9
+ }
10
+
11
+ void UIScheduler::triggerUI() {
12
+ scheduledOnUI_ = false;
13
+ while (!uiJobs_.empty()) {
14
+ const auto job = uiJobs_.pop();
15
+ job();
16
+ }
17
+ }
18
+
19
+ } // namespace worklets
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+
3
+ // amznmod_react - export symbols for reanimated
4
+ #include <keplerui-083/keplerscript-export.h>
5
+
6
+ #include <worklets/Tools/ThreadSafeQueue.h>
7
+
8
+ #include <ReactCommon/CallInvoker.h>
9
+
10
+ #include <atomic>
11
+
12
+ namespace worklets {
13
+
14
+ // amznmod_react - export symbols for reanimated
15
+ class KEPLERSCRIPT_EXPORT UIScheduler {
16
+ public:
17
+ virtual void scheduleOnUI(std::function<void()> job);
18
+ virtual void triggerUI();
19
+ virtual ~UIScheduler() = default;
20
+
21
+ protected:
22
+ std::atomic<bool> scheduledOnUI_{false};
23
+ ThreadSafeQueue<std::function<void()>> uiJobs_;
24
+ };
25
+
26
+ } // namespace worklets
@@ -0,0 +1,75 @@
1
+ #include <worklets/Tools/VersionUtils.h>
2
+
3
+ #include <iostream>
4
+ #include <regex>
5
+
6
+ using namespace facebook;
7
+
8
+ namespace worklets {
9
+
10
+ bool matchVersion(const std::string &version1, const std::string &version2) {
11
+ std::regex pattern("^\\d+\\.\\d+\\.\\d+$");
12
+ if (std::regex_match(version1, pattern) &&
13
+ std::regex_match(version2, pattern)) {
14
+ auto majorPattern = std::regex("^\\d+");
15
+ std::smatch major1;
16
+ std::smatch major2;
17
+ std::regex_search(version1, major1, majorPattern);
18
+ std::regex_search(version2, major2, majorPattern);
19
+ if (major1 != major2) {
20
+ return false;
21
+ }
22
+ auto minorPattern = std::regex("\\.\\d+\\.");
23
+ std::smatch minor1;
24
+ std::smatch minor2;
25
+ std::regex_search(version1, minor1, minorPattern);
26
+ std::regex_search(version2, minor2, minorPattern);
27
+ if (minor1 != minor2) {
28
+ return false;
29
+ }
30
+ return true;
31
+ } else {
32
+ return version1 == version2;
33
+ }
34
+ }
35
+
36
+ void checkJSVersion(
37
+ jsi::Runtime &runtime,
38
+ jsi::Value &jsVersionValue,
39
+ const std::shared_ptr<worklets::JSLogger> &jsLogger,
40
+ const std::string &cppVersion,
41
+ const std::string &libraryName,
42
+ const std::string &docsBaseUrl) {
43
+ const auto libraryPrefix = std::string("[" + libraryName + "] ");
44
+
45
+ if (jsVersionValue.isUndefined()) {
46
+ jsLogger->warnOnJS(
47
+ std::string(
48
+ libraryPrefix +
49
+ "C++ side failed to resolve JavaScript code "
50
+ "version\n") +
51
+ "See " + docsBaseUrl +
52
+ "/guides/"
53
+ "troubleshooting#c-side-failed-to-resolve-javascript-code-version` for "
54
+ "more details.");
55
+ return;
56
+ }
57
+
58
+ const auto jsVersion = jsVersionValue.asString(runtime).utf8(runtime);
59
+
60
+ if (!matchVersion(cppVersion, jsVersion)) {
61
+ jsLogger->warnOnJS(
62
+ std::string(
63
+ libraryPrefix +
64
+ "Mismatch between C++ code version and "
65
+ "JavaScript code version (") +
66
+ cppVersion + " vs. " + jsVersion + " respectively).\n" + "See " +
67
+ docsBaseUrl +
68
+ "/guides/"
69
+ "troubleshooting#mismatch-between-c-code-version-and-javascript-code-"
70
+ "version` for more details.");
71
+ return;
72
+ }
73
+ }
74
+
75
+ }; // namespace worklets
@@ -0,0 +1,28 @@
1
+ #pragma once
2
+
3
+ // amznmod_react - export symbols for reanimated
4
+ #include <keplerui-083/keplerscript-export.h>
5
+
6
+ #include <worklets/Tools/JSLogger.h>
7
+
8
+ #include <jsi/jsi.h>
9
+ #include <memory>
10
+ #include <regex>
11
+ #include <string>
12
+
13
+ using namespace facebook;
14
+
15
+ namespace worklets {
16
+
17
+ bool matchVersion(const std::string &version1, const std::string &version2);
18
+
19
+ // amznmod_react - export symbols for reanimated
20
+ void KEPLERSCRIPT_EXPORT checkJSVersion(
21
+ jsi::Runtime &runtime,
22
+ jsi::Value &jsVersionValue,
23
+ const std::shared_ptr<worklets::JSLogger> &jsLogger,
24
+ const std::string &cppVersion,
25
+ const std::string &libraryName,
26
+ const std::string &docsBaseUrl);
27
+
28
+ }; // namespace worklets
@@ -0,0 +1,29 @@
1
+ #include <worklets/Tools/WorkletEventHandler.h>
2
+
3
+ namespace worklets {
4
+
5
+ void WorkletEventHandler::process(
6
+ const std::shared_ptr<WorkletRuntime> &workletRuntime,
7
+ const double eventTimestamp,
8
+ const jsi::Value &eventValue) const {
9
+ workletRuntime->runGuarded(
10
+ handlerFunction_, jsi::Value(eventTimestamp), eventValue);
11
+ }
12
+
13
+ uint64_t WorkletEventHandler::getHandlerId() const {
14
+ return handlerId_;
15
+ }
16
+
17
+ const std::string &WorkletEventHandler::getEventName() const {
18
+ return eventName_;
19
+ }
20
+
21
+ uint64_t WorkletEventHandler::getEmitterReactTag() const {
22
+ return emitterReactTag_;
23
+ }
24
+
25
+ bool WorkletEventHandler::shouldIgnoreEmitterReactTag() const {
26
+ return emitterReactTag_ == -1;
27
+ }
28
+
29
+ } // namespace worklets
@@ -0,0 +1,41 @@
1
+ #pragma once
2
+
3
+ #include <worklets/SharedItems/Serializable.h>
4
+ #include <worklets/WorkletRuntime/WorkletRuntime.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 WorkletEventHandler {
16
+ const uint64_t handlerId_;
17
+ const uint64_t emitterReactTag_;
18
+ const std::string eventName_;
19
+ const std::shared_ptr<SerializableWorklet> handlerFunction_;
20
+
21
+ public:
22
+ WorkletEventHandler(
23
+ const uint64_t handlerId,
24
+ const std::string &eventName,
25
+ const uint64_t emitterReactTag,
26
+ const std::shared_ptr<SerializableWorklet> &handlerFunction)
27
+ : handlerId_(handlerId),
28
+ emitterReactTag_(emitterReactTag),
29
+ eventName_(eventName),
30
+ handlerFunction_(handlerFunction) {}
31
+ void process(
32
+ const std::shared_ptr<WorkletRuntime> &workletRuntime,
33
+ double eventTimestamp,
34
+ const jsi::Value &eventValue) const;
35
+ uint64_t getHandlerId() const;
36
+ const std::string &getEventName() const;
37
+ uint64_t getEmitterReactTag() const;
38
+ bool shouldIgnoreEmitterReactTag() const;
39
+ };
40
+
41
+ } // namespace worklets
@@ -0,0 +1,46 @@
1
+ #include <worklets/Tools/WorkletsJSIUtils.h>
2
+
3
+ #include <react/debug/react_native_assert.h>
4
+
5
+ // amznmod_react - fix compilation errors
6
+ #include <iterator>
7
+ #include <memory>
8
+ #include <sstream>
9
+ #include <vector>
10
+
11
+ using namespace facebook;
12
+
13
+ namespace worklets::jsi_utils {
14
+
15
+ jsi::Array convertStringToArray(
16
+ jsi::Runtime &rt,
17
+ const std::string &value,
18
+ const unsigned int expectedSize) {
19
+ std::vector<float> transformMatrixList;
20
+ std::istringstream stringStream(value);
21
+ std::copy(
22
+ std::istream_iterator<float>(stringStream),
23
+ std::istream_iterator<float>(),
24
+ std::back_inserter(transformMatrixList));
25
+ react_native_assert(
26
+ transformMatrixList.size() == expectedSize &&
27
+ "Transform matrix list size is different than expected");
28
+ jsi::Array matrix(rt, expectedSize);
29
+ for (unsigned int i = 0; i < expectedSize; i++) {
30
+ matrix.setValueAtIndex(rt, i, transformMatrixList[i]);
31
+ }
32
+ return matrix;
33
+ }
34
+
35
+ jsi::Object optimizedFromHostObject(
36
+ jsi::Runtime &rt,
37
+ std::shared_ptr<jsi::HostObject> &&hostObject) {
38
+ auto optimizedObject = jsi::Object(rt);
39
+ for (const auto &propertyName : hostObject->getPropertyNames(rt)) {
40
+ optimizedObject.setProperty(
41
+ rt, propertyName, hostObject->get(rt, propertyName));
42
+ }
43
+ return optimizedObject;
44
+ }
45
+
46
+ } // namespace worklets::jsi_utils
@@ -0,0 +1,208 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+ #include <react/debug/react_native_assert.h>
5
+ #include <memory>
6
+ #include <string>
7
+ #include <tuple>
8
+ #include <utility>
9
+
10
+ using namespace facebook;
11
+
12
+ namespace worklets::jsi_utils {
13
+
14
+ // `get` functions take a pointer to `jsi::Value` and
15
+ // call an appropriate method to cast to the native type
16
+ template <typename T>
17
+ inline T get(jsi::Runtime &rt, const jsi::Value *value);
18
+
19
+ template <>
20
+ inline double get<double>(jsi::Runtime &, const jsi::Value *value) {
21
+ return value->asNumber();
22
+ }
23
+
24
+ template <>
25
+ inline int get<int>(jsi::Runtime &, const jsi::Value *value) {
26
+ return value->asNumber();
27
+ }
28
+
29
+ template <>
30
+ inline bool get<bool>(jsi::Runtime &, const jsi::Value *value) {
31
+ if (!value->isBool()) {
32
+ throw jsi::JSINativeException("[Worklets] Expected a boolean.");
33
+ }
34
+ return value->getBool();
35
+ }
36
+
37
+ template <>
38
+ inline jsi::Object get<jsi::Object>(jsi::Runtime &rt, const jsi::Value *value) {
39
+ return value->asObject(rt);
40
+ }
41
+
42
+ template <>
43
+ inline jsi::Value const &get<jsi::Value const &>(
44
+ jsi::Runtime &,
45
+ const jsi::Value *value) {
46
+ return *value;
47
+ }
48
+
49
+ // `convertArgs` functions take a variadic template parameter of target (C++)
50
+ // argument types `Targs` and a `jsi::Value` array `args`, and converts `args`
51
+ // to a tuple of typed C++ arguments to be passed to the native implementation.
52
+ // This is accomplished by dispatching (at compile time) to the correct
53
+ // implementation based on the first type of `Targs`, using SFINAE to select the
54
+ // correct specialization, and concatenating with the result of recursion on the
55
+ // rest of `Targs`
56
+
57
+ // BEGIN implementations for `convertArgs` specializations.
58
+ // specialization for empty `Targs` - returns an empty tuple
59
+ template <typename... Args>
60
+ inline std::enable_if_t<(sizeof...(Args) == 0), std::tuple<>> convertArgs(
61
+ jsi::Runtime &,
62
+ const jsi::Value *) {
63
+ return std::make_tuple();
64
+ }
65
+
66
+ // calls `get<First>` on the first argument to retrieve the native type,
67
+ // then calls recursively on the rest of `args`
68
+ // and returns the concatenation of results
69
+ template <typename T, typename... Rest>
70
+ inline std::tuple<T, Rest...> convertArgs(
71
+ jsi::Runtime &rt,
72
+ const jsi::Value *args) {
73
+ auto arg = std::tuple<T>(get<T>(rt, args));
74
+ auto rest = convertArgs<Rest...>(rt, std::next(args));
75
+ return std::tuple_cat(std::move(arg), std::move(rest));
76
+ }
77
+ // END implementations for `convertArgs` specializations.
78
+
79
+ // returns a tuple with the result of casting `args` to appropriate
80
+ // native C++ types needed to call `function`
81
+ template <typename Ret, typename... Args>
82
+ std::tuple<Args...> getArgsForFunction(
83
+ std::function<Ret(Args...)>,
84
+ jsi::Runtime &rt,
85
+ const jsi::Value *args,
86
+ const size_t count) {
87
+ react_native_assert(
88
+ sizeof...(Args) == count &&
89
+ "Argument list has different length than expected");
90
+ return convertArgs<Args...>(rt, args);
91
+ }
92
+
93
+ // returns a tuple with the result of casting `args` to appropriate
94
+ // native C++ types needed to call `function`,
95
+ // passing `rt` as the first argument
96
+ template <typename Ret, typename... Args>
97
+ std::tuple<jsi::Runtime &, Args...> getArgsForFunction(
98
+ std::function<Ret(jsi::Runtime &, Args...)>,
99
+ jsi::Runtime &rt,
100
+ const jsi::Value *args,
101
+ const size_t count) {
102
+ react_native_assert(
103
+ sizeof...(Args) == count &&
104
+ "Argument list has different length than expected");
105
+ return std::tuple_cat(std::tie(rt), convertArgs<Args...>(rt, args));
106
+ }
107
+
108
+ // calls `function` with `args`
109
+ template <typename Ret, typename... Args>
110
+ inline jsi::Value apply(
111
+ std::function<Ret(Args...)> function,
112
+ std::tuple<Args...> args) {
113
+ return std::apply(function, std::move(args));
114
+ }
115
+
116
+ // calls string-returning `function` with `args`,
117
+ // and returns the string
118
+ template <typename... Args>
119
+ inline jsi::Value apply(
120
+ jsi::Runtime &rt,
121
+ std::function<std::string(Args...)> function,
122
+ std::tuple<Args...> args) {
123
+ return jsi::String::createFromUtf8(rt, std::apply(function, std::move(args)));
124
+ }
125
+
126
+ // calls void-returning `function` with `args`,
127
+ // and returns `undefined`
128
+ template <typename... Args>
129
+ inline jsi::Value apply(
130
+ std::function<void(Args...)> function,
131
+ std::tuple<Args...> args) {
132
+ std::apply(function, std::move(args));
133
+ return jsi::Value::undefined();
134
+ }
135
+
136
+ // returns a function with JSI calling convention
137
+ // from a native function `function`
138
+ template <typename Fun>
139
+ jsi::HostFunctionType createHostFunction(Fun function) {
140
+ return [function](
141
+ jsi::Runtime &rt,
142
+ const jsi::Value &,
143
+ const jsi::Value *args,
144
+ const size_t count) {
145
+ auto argz = getArgsForFunction(function, rt, args, count);
146
+ return apply(function, std::move(argz));
147
+ };
148
+ }
149
+
150
+ // returns a function with JSI calling convention
151
+ // from a native function `function` returning a string
152
+ template <typename... Args>
153
+ jsi::HostFunctionType createHostFunction(
154
+ std::function<std::string(Args...)> function) {
155
+ return [function](
156
+ jsi::Runtime &rt,
157
+ const jsi::Value &,
158
+ const jsi::Value *args,
159
+ const size_t count) {
160
+ auto argz = getArgsForFunction(function, rt, args, count);
161
+ return apply(rt, function, std::move(argz));
162
+ };
163
+ }
164
+
165
+ // used to determine if `function<Ret(Args...)>`
166
+ // takes `Runtime &` as its first argument
167
+ template <typename... Args>
168
+ struct takes_runtime {
169
+ static constexpr size_t value = 0;
170
+ };
171
+
172
+ // specialization for `function<Ret(Runtime &, Rest...)`
173
+ template <typename... Rest>
174
+ struct takes_runtime<jsi::Runtime &, Rest...> {
175
+ static constexpr size_t value = 1;
176
+ };
177
+
178
+ // creates a JSI compatible function from `function`
179
+ // and installs it as a global function named `name`
180
+ // in the `rt` JS runtime
181
+ template <typename Ret, typename... Args>
182
+ void installJsiFunction(
183
+ jsi::Runtime &rt,
184
+ std::string_view name,
185
+ std::function<Ret(Args...)> function) {
186
+ auto clb = createHostFunction(function);
187
+ auto argsCount = sizeof...(Args) - takes_runtime<Args...>::value;
188
+ jsi::Value jsiFunction = jsi::Function::createFromHostFunction(
189
+ rt, jsi::PropNameID::forAscii(rt, name.data()), argsCount, clb);
190
+ rt.global().setProperty(rt, name.data(), jsiFunction);
191
+ }
192
+
193
+ // this should take care of passing types convertible to `function`
194
+ template <typename Fun>
195
+ void installJsiFunction(jsi::Runtime &rt, std::string_view name, Fun function) {
196
+ installJsiFunction(rt, name, std::function(std::forward<Fun>(function)));
197
+ }
198
+
199
+ jsi::Array convertStringToArray(
200
+ jsi::Runtime &rt,
201
+ const std::string &value,
202
+ const unsigned int expectedSize);
203
+
204
+ jsi::Object optimizedFromHostObject(
205
+ jsi::Runtime &rt,
206
+ std::shared_ptr<jsi::HostObject> &&hostObject);
207
+
208
+ } // namespace worklets::jsi_utils