@depup/react-native-worklets 0.11.3-depup.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 (457) hide show
  1. package/.worklets/dummy.md +1 -0
  2. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +64 -0
  3. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
  4. package/Common/cpp/worklets/Compat/Holders.h +25 -0
  5. package/Common/cpp/worklets/Compat/StableApi.cpp +145 -0
  6. package/Common/cpp/worklets/Compat/StableApi.h +128 -0
  7. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +729 -0
  8. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +126 -0
  9. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +81 -0
  10. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +76 -0
  11. package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +95 -0
  12. package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +44 -0
  13. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +10 -0
  14. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +43 -0
  15. package/Common/cpp/worklets/RunLoop/AsyncQueue.h +14 -0
  16. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +69 -0
  17. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +48 -0
  18. package/Common/cpp/worklets/RunLoop/EventLoop.cpp +103 -0
  19. package/Common/cpp/worklets/RunLoop/EventLoop.h +52 -0
  20. package/Common/cpp/worklets/SharedItems/MemoryManager.cpp +60 -0
  21. package/Common/cpp/worklets/SharedItems/MemoryManager.h +29 -0
  22. package/Common/cpp/worklets/SharedItems/Serializable.cpp +373 -0
  23. package/Common/cpp/worklets/SharedItems/Serializable.h +413 -0
  24. package/Common/cpp/worklets/SharedItems/SerializableFactory.cpp +172 -0
  25. package/Common/cpp/worklets/SharedItems/SerializableFactory.h +85 -0
  26. package/Common/cpp/worklets/SharedItems/SerializableRemoteFunction.cpp +71 -0
  27. package/Common/cpp/worklets/SharedItems/SerializableRemoteFunction.h +75 -0
  28. package/Common/cpp/worklets/SharedItems/Shareable.cpp +84 -0
  29. package/Common/cpp/worklets/SharedItems/Shareable.h +43 -0
  30. package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +59 -0
  31. package/Common/cpp/worklets/SharedItems/Synchronizable.h +57 -0
  32. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +78 -0
  33. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +45 -0
  34. package/Common/cpp/worklets/SharedItems/UnpackerLoader.h +78 -0
  35. package/Common/cpp/worklets/Tools/FeatureFlags.cpp +18 -0
  36. package/Common/cpp/worklets/Tools/FeatureFlags.h +44 -0
  37. package/Common/cpp/worklets/Tools/JSISerializer.cpp +312 -0
  38. package/Common/cpp/worklets/Tools/JSISerializer.h +42 -0
  39. package/Common/cpp/worklets/Tools/JSLogger.cpp +92 -0
  40. package/Common/cpp/worklets/Tools/JSLogger.h +48 -0
  41. package/Common/cpp/worklets/Tools/JSScheduler.cpp +21 -0
  42. package/Common/cpp/worklets/Tools/JSScheduler.h +35 -0
  43. package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
  44. package/Common/cpp/worklets/Tools/RNRuntimeStatus.h +27 -0
  45. package/Common/cpp/worklets/Tools/ScriptBuffer.h +56 -0
  46. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +75 -0
  47. package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
  48. package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
  49. package/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
  50. package/Common/cpp/worklets/Tools/VersionUtils.cpp +61 -0
  51. package/Common/cpp/worklets/Tools/VersionUtils.h +24 -0
  52. package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +34 -0
  53. package/Common/cpp/worklets/Tools/WorkletEventHandler.h +44 -0
  54. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +30 -0
  55. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +222 -0
  56. package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +116 -0
  57. package/Common/cpp/worklets/Tools/WorkletsVersion.cpp +46 -0
  58. package/Common/cpp/worklets/Tools/WorkletsVersion.h +18 -0
  59. package/Common/cpp/worklets/WorkletRuntime/BundleModeConfig.h +17 -0
  60. package/Common/cpp/worklets/WorkletRuntime/HermesProfiling.cpp +45 -0
  61. package/Common/cpp/worklets/WorkletRuntime/HermesProfiling.h +12 -0
  62. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +68 -0
  63. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +24 -0
  64. package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +59 -0
  65. package/Common/cpp/worklets/WorkletRuntime/RuntimeData.h +38 -0
  66. package/Common/cpp/worklets/WorkletRuntime/RuntimeHolder.h +19 -0
  67. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +122 -0
  68. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +75 -0
  69. package/Common/cpp/worklets/WorkletRuntime/ScriptLoader.h +116 -0
  70. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +14 -0
  71. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +15 -0
  72. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +58 -0
  73. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +100 -0
  74. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +327 -0
  75. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +256 -0
  76. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
  77. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +320 -0
  78. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +36 -0
  79. package/LICENSE +20 -0
  80. package/README.md +43 -0
  81. package/RNWorklets.podspec +94 -0
  82. package/android/CMakeLists.txt +108 -0
  83. package/android/build.gradle.kts +369 -0
  84. package/android/fix-prefab.gradle.kts +56 -0
  85. package/android/generate-stub-pch.gradle.kts +84 -0
  86. package/android/gradle.properties +25 -0
  87. package/android/proguard-rules.pro +3 -0
  88. package/android/settings.gradle.kts +21 -0
  89. package/android/src/main/AndroidManifest.xml +2 -0
  90. package/android/src/main/cpp/WorkletsPCH.h +26 -0
  91. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +66 -0
  92. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +38 -0
  93. package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +30 -0
  94. package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.cpp +66 -0
  95. package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.h +48 -0
  96. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +51 -0
  97. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +43 -0
  98. package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +31 -0
  99. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +203 -0
  100. package/android/src/main/cpp/worklets/android/WorkletsModule.h +75 -0
  101. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +19 -0
  102. package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.kt +56 -0
  103. package/android/src/main/java/com/swmansion/worklets/ScriptBufferWrapper.kt +103 -0
  104. package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.kt +42 -0
  105. package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameCallback.kt +14 -0
  106. package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.kt +112 -0
  107. package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +27 -0
  108. package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +30 -0
  109. package/android/src/networking/com/swmansion/worklets/WorkletsModule.kt +187 -0
  110. package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +272 -0
  111. package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +1124 -0
  112. package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +40 -0
  113. package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +13 -0
  114. package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +98 -0
  115. package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +60 -0
  116. package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +87 -0
  117. package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +181 -0
  118. package/android/src/no-networking/com/swmansion/worklets/WorkletsModule.kt +143 -0
  119. package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
  120. package/apple/worklets/apple/AnimationFrameQueue.mm +145 -0
  121. package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
  122. package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +12 -0
  123. package/apple/worklets/apple/IOSUIScheduler.h +14 -0
  124. package/apple/worklets/apple/IOSUIScheduler.mm +29 -0
  125. package/apple/worklets/apple/Networking/WorkletsNetworking.h +25 -0
  126. package/apple/worklets/apple/Networking/WorkletsNetworking.mm +707 -0
  127. package/apple/worklets/apple/PlatformLogger.mm +31 -0
  128. package/apple/worklets/apple/SlowAnimations.h +8 -0
  129. package/apple/worklets/apple/SlowAnimations.mm +45 -0
  130. package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
  131. package/apple/worklets/apple/WorkletsModule.h +28 -0
  132. package/apple/worklets/apple/WorkletsModule.mm +177 -0
  133. package/bundleMode/index.d.ts +6 -0
  134. package/bundleMode/index.js +182 -0
  135. package/bundleMode/shims/reactNativeShim.js +21 -0
  136. package/bundleMode/shims/turboModuleRegistryShim.js +47 -0
  137. package/changes.json +58 -0
  138. package/compatibility.json +29 -0
  139. package/jest/pluginTestUtils.ts +16 -0
  140. package/jest/resolver.js +18 -0
  141. package/lib/module/WorkletsModule/NativeWorklets.js +4 -0
  142. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
  143. package/lib/module/WorkletsModule/NativeWorklets.native.js +199 -0
  144. package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -0
  145. package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
  146. package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
  147. package/lib/module/bundleMode/metroOverrides.native.js +26 -0
  148. package/lib/module/bundleMode/metroOverrides.native.js.map +1 -0
  149. package/lib/module/bundleMode/network.native.js +44 -0
  150. package/lib/module/bundleMode/network.native.js.map +1 -0
  151. package/lib/module/debug/bundleMode.js +6 -0
  152. package/lib/module/debug/bundleMode.js.map +1 -0
  153. package/lib/module/debug/bundleMode.native.js +11 -0
  154. package/lib/module/debug/bundleMode.native.js.map +1 -0
  155. package/lib/module/debug/checkCppVersion.js +29 -0
  156. package/lib/module/debug/checkCppVersion.js.map +1 -0
  157. package/lib/module/debug/errors.native.js +67 -0
  158. package/lib/module/debug/errors.native.js.map +1 -0
  159. package/lib/module/debug/jsVersion.js +9 -0
  160. package/lib/module/debug/jsVersion.js.map +1 -0
  161. package/lib/module/debug/logger.js +15 -0
  162. package/lib/module/debug/logger.js.map +1 -0
  163. package/lib/module/debug/slowAnimations.js +7 -0
  164. package/lib/module/debug/slowAnimations.js.map +1 -0
  165. package/lib/module/debug/slowAnimations.native.js +17 -0
  166. package/lib/module/debug/slowAnimations.native.js.map +1 -0
  167. package/lib/module/deprecated.js +27 -0
  168. package/lib/module/deprecated.js.map +1 -0
  169. package/lib/module/featureFlags/featureFlags.js +12 -0
  170. package/lib/module/featureFlags/featureFlags.js.map +1 -0
  171. package/lib/module/featureFlags/featureFlags.native.js +51 -0
  172. package/lib/module/featureFlags/featureFlags.native.js.map +1 -0
  173. package/lib/module/featureFlags/staticFlags.json +6 -0
  174. package/lib/module/featureFlags/types.js +16 -0
  175. package/lib/module/featureFlags/types.js.map +1 -0
  176. package/lib/module/guardImplementation.native.js +17 -0
  177. package/lib/module/guardImplementation.native.js.map +1 -0
  178. package/lib/module/index.js +26 -0
  179. package/lib/module/index.js.map +1 -0
  180. package/lib/module/initializers/initializers.js +24 -0
  181. package/lib/module/initializers/initializers.js.map +1 -0
  182. package/lib/module/initializers/initializers.native.js +195 -0
  183. package/lib/module/initializers/initializers.native.js.map +1 -0
  184. package/lib/module/memory/bundleUnpacker.native.js +38 -0
  185. package/lib/module/memory/bundleUnpacker.native.js.map +1 -0
  186. package/lib/module/memory/customSerializableUnpacker.native.js +20 -0
  187. package/lib/module/memory/customSerializableUnpacker.native.js.map +1 -0
  188. package/lib/module/memory/isShareable.js +8 -0
  189. package/lib/module/memory/isShareable.js.map +1 -0
  190. package/lib/module/memory/isSynchronizable.js +8 -0
  191. package/lib/module/memory/isSynchronizable.js.map +1 -0
  192. package/lib/module/memory/remoteFunctionUnpacker.native.js +18 -0
  193. package/lib/module/memory/remoteFunctionUnpacker.native.js.map +1 -0
  194. package/lib/module/memory/serializable.js +18 -0
  195. package/lib/module/memory/serializable.js.map +1 -0
  196. package/lib/module/memory/serializable.native.js +619 -0
  197. package/lib/module/memory/serializable.native.js.map +1 -0
  198. package/lib/module/memory/serializableMappingCache.js +11 -0
  199. package/lib/module/memory/serializableMappingCache.js.map +1 -0
  200. package/lib/module/memory/serializableMappingCache.native.js +29 -0
  201. package/lib/module/memory/serializableMappingCache.native.js.map +1 -0
  202. package/lib/module/memory/shareable.js +18 -0
  203. package/lib/module/memory/shareable.js.map +1 -0
  204. package/lib/module/memory/shareable.native.js +42 -0
  205. package/lib/module/memory/shareable.native.js.map +1 -0
  206. package/lib/module/memory/shareableGuestUnpacker.native.js +105 -0
  207. package/lib/module/memory/shareableGuestUnpacker.native.js.map +1 -0
  208. package/lib/module/memory/shareableHostUnpacker.native.js +20 -0
  209. package/lib/module/memory/shareableHostUnpacker.native.js.map +1 -0
  210. package/lib/module/memory/synchronizable.js +6 -0
  211. package/lib/module/memory/synchronizable.js.map +1 -0
  212. package/lib/module/memory/synchronizable.native.js +9 -0
  213. package/lib/module/memory/synchronizable.native.js.map +1 -0
  214. package/lib/module/memory/synchronizableUnpacker.native.js +47 -0
  215. package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -0
  216. package/lib/module/memory/types.js +12 -0
  217. package/lib/module/memory/types.js.map +1 -0
  218. package/lib/module/memory/valueUnpacker.native.js +52 -0
  219. package/lib/module/memory/valueUnpacker.native.js.map +1 -0
  220. package/lib/module/mock.js +85 -0
  221. package/lib/module/mock.js.map +1 -0
  222. package/lib/module/package.json +1 -0
  223. package/lib/module/platformChecker.js +4 -0
  224. package/lib/module/platformChecker.js.map +1 -0
  225. package/lib/module/platformChecker.native.js +4 -0
  226. package/lib/module/platformChecker.native.js.map +1 -0
  227. package/lib/module/privateGlobals.d.js +7 -0
  228. package/lib/module/privateGlobals.d.js.map +1 -0
  229. package/lib/module/runLoop/common/setImmediatePolyfill.js +15 -0
  230. package/lib/module/runLoop/common/setImmediatePolyfill.js.map +1 -0
  231. package/lib/module/runLoop/common/setIntervalPolyfill.js +26 -0
  232. package/lib/module/runLoop/common/setIntervalPolyfill.js.map +1 -0
  233. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js +10 -0
  234. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js.map +1 -0
  235. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +71 -0
  236. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -0
  237. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js +32 -0
  238. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js.map +1 -0
  239. package/lib/module/runLoop/workletRuntime/index.js +19 -0
  240. package/lib/module/runLoop/workletRuntime/index.js.map +1 -0
  241. package/lib/module/runLoop/workletRuntime/queueMicrotask.js +11 -0
  242. package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +1 -0
  243. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +48 -0
  244. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -0
  245. package/lib/module/runLoop/workletRuntime/setTimeout.js +28 -0
  246. package/lib/module/runLoop/workletRuntime/setTimeout.js.map +1 -0
  247. package/lib/module/runLoop/workletRuntime/taskQueue.js +37 -0
  248. package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -0
  249. package/lib/module/runtimeKind.js +92 -0
  250. package/lib/module/runtimeKind.js.map +1 -0
  251. package/lib/module/runtimes.js +36 -0
  252. package/lib/module/runtimes.js.map +1 -0
  253. package/lib/module/runtimes.native.js +379 -0
  254. package/lib/module/runtimes.native.js.map +1 -0
  255. package/lib/module/specs/NativeWorkletsModule.js +5 -0
  256. package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
  257. package/lib/module/specs/index.js +10 -0
  258. package/lib/module/specs/index.js.map +1 -0
  259. package/lib/module/threads.js +60 -0
  260. package/lib/module/threads.js.map +1 -0
  261. package/lib/module/threads.native.js +295 -0
  262. package/lib/module/threads.native.js.map +1 -0
  263. package/lib/module/types.js +5 -0
  264. package/lib/module/types.js.map +1 -0
  265. package/lib/module/workletFunction.js +36 -0
  266. package/lib/module/workletFunction.js.map +1 -0
  267. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +3 -0
  268. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
  269. package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts +3 -0
  270. package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -0
  271. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +59 -0
  272. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
  273. package/lib/typescript/bundleMode/metroOverrides.native.d.ts +9 -0
  274. package/lib/typescript/bundleMode/metroOverrides.native.d.ts.map +1 -0
  275. package/lib/typescript/bundleMode/network.native.d.ts +7 -0
  276. package/lib/typescript/bundleMode/network.native.d.ts.map +1 -0
  277. package/lib/typescript/debug/bundleMode.d.ts +2 -0
  278. package/lib/typescript/debug/bundleMode.d.ts.map +1 -0
  279. package/lib/typescript/debug/bundleMode.native.d.ts +2 -0
  280. package/lib/typescript/debug/bundleMode.native.d.ts.map +1 -0
  281. package/lib/typescript/debug/checkCppVersion.d.ts +3 -0
  282. package/lib/typescript/debug/checkCppVersion.d.ts.map +1 -0
  283. package/lib/typescript/debug/errors.native.d.ts +13 -0
  284. package/lib/typescript/debug/errors.native.d.ts.map +1 -0
  285. package/lib/typescript/debug/jsVersion.d.ts +7 -0
  286. package/lib/typescript/debug/jsVersion.d.ts.map +1 -0
  287. package/lib/typescript/debug/logger.d.ts +5 -0
  288. package/lib/typescript/debug/logger.d.ts.map +1 -0
  289. package/lib/typescript/debug/slowAnimations.d.ts +2 -0
  290. package/lib/typescript/debug/slowAnimations.d.ts.map +1 -0
  291. package/lib/typescript/debug/slowAnimations.native.d.ts +11 -0
  292. package/lib/typescript/debug/slowAnimations.native.d.ts.map +1 -0
  293. package/lib/typescript/deprecated.d.ts +19 -0
  294. package/lib/typescript/deprecated.d.ts.map +1 -0
  295. package/lib/typescript/featureFlags/featureFlags.d.ts +5 -0
  296. package/lib/typescript/featureFlags/featureFlags.d.ts.map +1 -0
  297. package/lib/typescript/featureFlags/featureFlags.native.d.ts +6 -0
  298. package/lib/typescript/featureFlags/featureFlags.native.d.ts.map +1 -0
  299. package/lib/typescript/featureFlags/types.d.ts +23 -0
  300. package/lib/typescript/featureFlags/types.d.ts.map +1 -0
  301. package/lib/typescript/guardImplementation.native.d.ts +3 -0
  302. package/lib/typescript/guardImplementation.native.d.ts.map +1 -0
  303. package/lib/typescript/index.d.ts +19 -0
  304. package/lib/typescript/index.d.ts.map +1 -0
  305. package/lib/typescript/initializers/initializers.d.ts +2 -0
  306. package/lib/typescript/initializers/initializers.d.ts.map +1 -0
  307. package/lib/typescript/initializers/initializers.native.d.ts +19 -0
  308. package/lib/typescript/initializers/initializers.native.d.ts.map +1 -0
  309. package/lib/typescript/memory/bundleUnpacker.native.d.ts +7 -0
  310. package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -0
  311. package/lib/typescript/memory/customSerializableUnpacker.native.d.ts +3 -0
  312. package/lib/typescript/memory/customSerializableUnpacker.native.d.ts.map +1 -0
  313. package/lib/typescript/memory/isShareable.d.ts +3 -0
  314. package/lib/typescript/memory/isShareable.d.ts.map +1 -0
  315. package/lib/typescript/memory/isSynchronizable.d.ts +3 -0
  316. package/lib/typescript/memory/isSynchronizable.d.ts.map +1 -0
  317. package/lib/typescript/memory/remoteFunctionUnpacker.native.d.ts +3 -0
  318. package/lib/typescript/memory/remoteFunctionUnpacker.native.d.ts.map +1 -0
  319. package/lib/typescript/memory/serializable.d.ts +7 -0
  320. package/lib/typescript/memory/serializable.d.ts.map +1 -0
  321. package/lib/typescript/memory/serializable.native.d.ts +37 -0
  322. package/lib/typescript/memory/serializable.native.d.ts.map +1 -0
  323. package/lib/typescript/memory/serializableMappingCache.d.ts +6 -0
  324. package/lib/typescript/memory/serializableMappingCache.d.ts.map +1 -0
  325. package/lib/typescript/memory/serializableMappingCache.native.d.ts +13 -0
  326. package/lib/typescript/memory/serializableMappingCache.native.d.ts.map +1 -0
  327. package/lib/typescript/memory/shareable.d.ts +15 -0
  328. package/lib/typescript/memory/shareable.d.ts.map +1 -0
  329. package/lib/typescript/memory/shareable.native.d.ts +15 -0
  330. package/lib/typescript/memory/shareable.native.d.ts.map +1 -0
  331. package/lib/typescript/memory/shareableGuestUnpacker.native.d.ts +4 -0
  332. package/lib/typescript/memory/shareableGuestUnpacker.native.d.ts.map +1 -0
  333. package/lib/typescript/memory/shareableHostUnpacker.native.d.ts +4 -0
  334. package/lib/typescript/memory/shareableHostUnpacker.native.d.ts.map +1 -0
  335. package/lib/typescript/memory/synchronizable.d.ts +3 -0
  336. package/lib/typescript/memory/synchronizable.d.ts.map +1 -0
  337. package/lib/typescript/memory/synchronizable.native.d.ts +3 -0
  338. package/lib/typescript/memory/synchronizable.native.d.ts.map +1 -0
  339. package/lib/typescript/memory/synchronizableUnpacker.native.d.ts +4 -0
  340. package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -0
  341. package/lib/typescript/memory/types.d.ts +136 -0
  342. package/lib/typescript/memory/types.d.ts.map +1 -0
  343. package/lib/typescript/memory/valueUnpacker.native.d.ts +7 -0
  344. package/lib/typescript/memory/valueUnpacker.native.d.ts.map +1 -0
  345. package/lib/typescript/mock.d.ts +2 -0
  346. package/lib/typescript/mock.d.ts.map +1 -0
  347. package/lib/typescript/package.json +1 -0
  348. package/lib/typescript/platformChecker.d.ts +2 -0
  349. package/lib/typescript/platformChecker.d.ts.map +1 -0
  350. package/lib/typescript/platformChecker.native.d.ts +2 -0
  351. package/lib/typescript/platformChecker.native.d.ts.map +1 -0
  352. package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts +2 -0
  353. package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts.map +1 -0
  354. package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts +2 -0
  355. package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts.map +1 -0
  356. package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts +6 -0
  357. package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts.map +1 -0
  358. package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts +2 -0
  359. package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -0
  360. package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts +2 -0
  361. package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts.map +1 -0
  362. package/lib/typescript/runLoop/workletRuntime/index.d.ts +2 -0
  363. package/lib/typescript/runLoop/workletRuntime/index.d.ts.map +1 -0
  364. package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts +2 -0
  365. package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +1 -0
  366. package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts +2 -0
  367. package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts.map +1 -0
  368. package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts +2 -0
  369. package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts.map +1 -0
  370. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +10 -0
  371. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -0
  372. package/lib/typescript/runtimeKind.d.ts +56 -0
  373. package/lib/typescript/runtimeKind.d.ts.map +1 -0
  374. package/lib/typescript/runtimes.d.ts +15 -0
  375. package/lib/typescript/runtimes.d.ts.map +1 -0
  376. package/lib/typescript/runtimes.native.d.ts +155 -0
  377. package/lib/typescript/runtimes.native.d.ts.map +1 -0
  378. package/lib/typescript/specs/NativeWorkletsModule.d.ts +9 -0
  379. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
  380. package/lib/typescript/specs/index.d.ts +3 -0
  381. package/lib/typescript/specs/index.d.ts.map +1 -0
  382. package/lib/typescript/threads.d.ts +8 -0
  383. package/lib/typescript/threads.d.ts.map +1 -0
  384. package/lib/typescript/threads.native.d.ts +125 -0
  385. package/lib/typescript/threads.native.d.ts.map +1 -0
  386. package/lib/typescript/types.d.ts +136 -0
  387. package/lib/typescript/types.d.ts.map +1 -0
  388. package/lib/typescript/workletFunction.d.ts +26 -0
  389. package/lib/typescript/workletFunction.d.ts.map +1 -0
  390. package/package.json +220 -0
  391. package/plugin/index.d.ts +168 -0
  392. package/plugin/index.js +2188 -0
  393. package/scripts/validate-react-native-version.js +43 -0
  394. package/scripts/worklets_utils.rb +94 -0
  395. package/src/WorkletsModule/NativeWorklets.native.ts +461 -0
  396. package/src/WorkletsModule/NativeWorklets.ts +5 -0
  397. package/src/WorkletsModule/workletsModuleProxy.ts +247 -0
  398. package/src/bundleMode/metroOverrides.native.ts +33 -0
  399. package/src/bundleMode/network.native.ts +63 -0
  400. package/src/debug/bundleMode.native.ts +18 -0
  401. package/src/debug/bundleMode.ts +5 -0
  402. package/src/debug/checkCppVersion.ts +34 -0
  403. package/src/debug/errors.native.ts +74 -0
  404. package/src/debug/jsVersion.ts +8 -0
  405. package/src/debug/logger.ts +16 -0
  406. package/src/debug/slowAnimations.native.ts +15 -0
  407. package/src/debug/slowAnimations.ts +6 -0
  408. package/src/deprecated.ts +38 -0
  409. package/src/featureFlags/featureFlags.native.ts +70 -0
  410. package/src/featureFlags/featureFlags.ts +20 -0
  411. package/src/featureFlags/staticFlags.json +6 -0
  412. package/src/featureFlags/types.ts +32 -0
  413. package/src/guardImplementation.native.ts +26 -0
  414. package/src/index.ts +95 -0
  415. package/src/initializers/initializers.native.ts +218 -0
  416. package/src/initializers/initializers.ts +24 -0
  417. package/src/memory/bundleUnpacker.native.ts +59 -0
  418. package/src/memory/customSerializableUnpacker.native.ts +30 -0
  419. package/src/memory/isShareable.ts +16 -0
  420. package/src/memory/isSynchronizable.ts +14 -0
  421. package/src/memory/remoteFunctionUnpacker.native.ts +27 -0
  422. package/src/memory/serializable.native.ts +889 -0
  423. package/src/memory/serializable.ts +36 -0
  424. package/src/memory/serializableMappingCache.native.ts +37 -0
  425. package/src/memory/serializableMappingCache.ts +12 -0
  426. package/src/memory/shareable.native.ts +68 -0
  427. package/src/memory/shareable.ts +27 -0
  428. package/src/memory/shareableGuestUnpacker.native.ts +168 -0
  429. package/src/memory/shareableHostUnpacker.native.ts +31 -0
  430. package/src/memory/synchronizable.native.ts +17 -0
  431. package/src/memory/synchronizable.ts +9 -0
  432. package/src/memory/synchronizableUnpacker.native.ts +65 -0
  433. package/src/memory/types.ts +191 -0
  434. package/src/memory/valueUnpacker.native.ts +79 -0
  435. package/src/mock.ts +111 -0
  436. package/src/platformChecker.native.ts +3 -0
  437. package/src/platformChecker.ts +4 -0
  438. package/src/privateGlobals.d.ts +127 -0
  439. package/src/runLoop/common/setImmediatePolyfill.ts +20 -0
  440. package/src/runLoop/common/setIntervalPolyfill.ts +38 -0
  441. package/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts +11 -0
  442. package/src/runLoop/uiRuntime/requestAnimationFrame.ts +87 -0
  443. package/src/runLoop/uiRuntime/setTimeoutPolyfill.ts +40 -0
  444. package/src/runLoop/workletRuntime/index.ts +18 -0
  445. package/src/runLoop/workletRuntime/queueMicrotask.ts +13 -0
  446. package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +61 -0
  447. package/src/runLoop/workletRuntime/setTimeout.ts +37 -0
  448. package/src/runLoop/workletRuntime/taskQueue.ts +44 -0
  449. package/src/runtimeKind.ts +85 -0
  450. package/src/runtimes.native.ts +572 -0
  451. package/src/runtimes.ts +107 -0
  452. package/src/specs/NativeWorkletsModule.ts +11 -0
  453. package/src/specs/index.ts +13 -0
  454. package/src/threads.native.ts +408 -0
  455. package/src/threads.ts +110 -0
  456. package/src/types.ts +164 -0
  457. package/src/workletFunction.ts +41 -0
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ const semverSatisfies = require('semver/functions/satisfies');
4
+ const semverPrerelease = require('semver/functions/prerelease');
5
+ const path = require('path');
6
+
7
+ const packageJsonPath = path.resolve(__dirname, '../package.json');
8
+ const packageJson = require(packageJsonPath);
9
+ const workletsVersion = packageJson.version;
10
+ const compatibilityFile = require('../compatibility.json');
11
+
12
+ const reactNativeVersion = process.argv[2];
13
+ const supportedRNVersions = [];
14
+
15
+ if (semverPrerelease(reactNativeVersion)) {
16
+ // Don't perform any checks for pre-release versions, like nightlies or
17
+ // feature previews. The user knows what they're doing.
18
+ process.exit(0);
19
+ }
20
+
21
+ for (const key in compatibilityFile) {
22
+ if (semverSatisfies(workletsVersion, key)) {
23
+ // @ts-ignore
24
+ supportedRNVersions.push(...compatibilityFile[key]['react-native']);
25
+ }
26
+ }
27
+
28
+ // If user uses a version of Reanimated that is not listed in the compatibility file, we skip the check
29
+ if (supportedRNVersions.length === 0) {
30
+ process.exit(0);
31
+ }
32
+
33
+ for (const version of supportedRNVersions) {
34
+ if (semverSatisfies(reactNativeVersion, `${version}.x`)) {
35
+ process.exit(0);
36
+ }
37
+ }
38
+
39
+ // eslint-disable-next-line reanimated/use-logger
40
+ console.error(
41
+ `[Worklets] Your installed version of React Native (${reactNativeVersion}) is not compatible with installed version of Worklets (${workletsVersion}). See the documentation for the list of supported versions: https://docs.swmansion.com/react-native-worklets/docs/guides/compatibility/`
42
+ );
43
+ process.exit(1);
@@ -0,0 +1,94 @@
1
+ module WorkletsUtils
2
+ module_function
3
+
4
+ def try_to_parse_react_native_package_json(react_native_dir)
5
+ react_native_package_json_path = File.join(react_native_dir, 'package.json')
6
+ if !File.exist?(react_native_package_json_path)
7
+ return nil
8
+ end
9
+ return JSON.parse(File.read(react_native_package_json_path))
10
+ end
11
+
12
+ def find_config()
13
+ result = {
14
+ :feature_flags_flag => nil,
15
+ :fetch_preview_flag => nil,
16
+ :is_reanimated_example_app => nil,
17
+ :react_native_version => nil,
18
+ :react_native_dir => nil,
19
+ :react_native_common_dir => nil,
20
+ }
21
+
22
+ react_native_dir = File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`)
23
+ react_native_json = try_to_parse_react_native_package_json(react_native_dir)
24
+
25
+ if react_native_json == nil
26
+ # user configuration, just in case
27
+ node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"]
28
+ react_native_json = try_to_parse_react_native_package_json(File.join(node_modules_dir, 'react-native'))
29
+ end
30
+
31
+ if react_native_json == nil
32
+ raise '[Worklets] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
33
+ end
34
+
35
+ result[:is_reanimated_example_app] = ENV["IS_REANIMATED_EXAMPLE_APP"] != nil
36
+ result[:react_native_version] = react_native_json['version']
37
+ result[:react_native_dir] = File.expand_path(react_native_dir)
38
+
39
+ pods_root = Pod::Config.instance.project_pods_root
40
+ react_native_common_dir_absolute = File.join(react_native_dir, 'ReactCommon')
41
+ react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
42
+ result[:react_native_common_dir] = react_native_common_dir_relative
43
+
44
+ feature_flags = get_static_feature_flags()
45
+ result[:feature_flags_flag] = get_static_feature_flags_flag(feature_flags)
46
+ result[:fetch_preview_flag] = get_flag_from_feature_flags(feature_flags, 'FETCH_PREVIEW_ENABLED')
47
+
48
+ return result
49
+ end
50
+
51
+ def assert_minimal_react_native_version(config)
52
+ validate_react_native_version_script = File.expand_path(File.join(__dir__, 'validate-react-native-version.js'))
53
+ unless system("node \"#{validate_react_native_version_script}\" #{config[:react_native_version]}")
54
+ raise "[Worklets] Your installed version of React Native is not compatible with installed version of Worklets. See the documentation for the list of supported versions: https://docs.swmansion.com/react-native-worklets/docs/guides/compatibility/"
55
+ end
56
+ end
57
+
58
+ def get_flag_from_feature_flags(feature_flags, flag_name)
59
+ if feature_flags[flag_name] == 'true'
60
+ return "-DWORKLETS_#{flag_name}"
61
+ else
62
+ return ''
63
+ end
64
+ end
65
+
66
+ def get_static_feature_flags()
67
+ feature_flags = {}
68
+
69
+ static_feature_flags_path = File.path('./src/featureFlags/staticFlags.json')
70
+ if !File.exist?(static_feature_flags_path)
71
+ raise "[Worklets] Feature flags file not found at #{static_feature_flags_path}."
72
+ end
73
+ static_feature_flags_json = JSON.parse(File.read(static_feature_flags_path))
74
+ static_feature_flags_json.each do |key, value|
75
+ feature_flags[key] = value.to_s
76
+ end
77
+
78
+ package_json_path = File.join(Pod::Config.instance.installation_root.to_s, '..', 'package.json')
79
+ if File.exist?(package_json_path)
80
+ package_json = JSON.parse(File.read(package_json_path))
81
+ if package_json['worklets'] && package_json['worklets']['staticFeatureFlags']
82
+ feature_flags_json = package_json['worklets']['staticFeatureFlags']
83
+ feature_flags_json.each do |key, value|
84
+ feature_flags[key] = value.to_s
85
+ end
86
+ end
87
+ end
88
+ return feature_flags
89
+ end
90
+
91
+ def get_static_feature_flags_flag(feature_flags)
92
+ return "-DWORKLETS_FEATURE_FLAGS=\"#{feature_flags.map { |key, value| "[#{key}:#{value}]" }.join('')}\""
93
+ end
94
+ end
@@ -0,0 +1,461 @@
1
+ 'use strict';
2
+
3
+ import { isBundleModeEnabled } from '../debug/bundleMode';
4
+ import { checkCppVersion } from '../debug/checkCppVersion';
5
+ import { jsVersion } from '../debug/jsVersion';
6
+ import { installCustomSerializableUnpacker } from '../memory/customSerializableUnpacker';
7
+ import { installRemoteFunctionUnpacker } from '../memory/remoteFunctionUnpacker';
8
+ import { installShareableGuestUnpacker } from '../memory/shareableGuestUnpacker';
9
+ import { installShareableHostUnpacker } from '../memory/shareableHostUnpacker';
10
+ import { installSynchronizableUnpacker } from '../memory/synchronizableUnpacker';
11
+ import type {
12
+ RemoteFunction,
13
+ SerializableRef,
14
+ SynchronizableRef,
15
+ } from '../memory/types';
16
+ import { installValueUnpacker } from '../memory/valueUnpacker';
17
+ import { isRNRuntime } from '../runtimeKind';
18
+ import { WorkletsTurboModule } from '../specs';
19
+ import type { WorkletFunction, WorkletRuntime } from '../types';
20
+ import type {
21
+ IWorkletsModule,
22
+ WorkletsModuleProxy,
23
+ } from './workletsModuleProxy';
24
+
25
+ class NativeWorklets implements IWorkletsModule {
26
+ #workletsModuleProxy: WorkletsModuleProxy;
27
+ #serializableUndefined: SerializableRef<undefined>;
28
+ #serializableNull: SerializableRef<null>;
29
+ #serializableTrue: SerializableRef<boolean>;
30
+ #serializableFalse: SerializableRef<boolean>;
31
+
32
+ constructor() {
33
+ const bundleModeEnabled = isBundleModeEnabled();
34
+ globalThis._WORKLETS_VERSION_JS = jsVersion;
35
+ const onRNRuntime = isRNRuntime();
36
+ if (globalThis.__workletsModuleProxy === undefined && onRNRuntime) {
37
+ WorkletsTurboModule?.installTurboModule(bundleModeEnabled);
38
+ if (!bundleModeEnabled) {
39
+ installUnpackers(globalThis.__workletsModuleProxy);
40
+ }
41
+ WorkletsTurboModule?.start();
42
+ }
43
+ if (globalThis.__workletsModuleProxy === undefined) {
44
+ throw new Error(
45
+ `[Worklets] Native part of Worklets doesn't seem to be initialized.
46
+ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#native-part-of-worklets-doesnt-seem-to-be-initialized for more details.`
47
+ );
48
+ }
49
+ if (__DEV__) {
50
+ if (bundleModeEnabled) {
51
+ console.log(
52
+ '[Worklets] Bundle mode initialization: Downloaded the bundle for Worklet Runtimes.'
53
+ );
54
+ }
55
+ if (onRNRuntime) {
56
+ checkCppVersion();
57
+ }
58
+ }
59
+ this.#workletsModuleProxy = globalThis.__workletsModuleProxy;
60
+ this.#serializableNull = this.#workletsModuleProxy.createSerializableNull();
61
+ this.#serializableUndefined =
62
+ this.#workletsModuleProxy.createSerializableUndefined();
63
+ this.#serializableTrue =
64
+ this.#workletsModuleProxy.createSerializableBoolean(true);
65
+ this.#serializableFalse =
66
+ this.#workletsModuleProxy.createSerializableBoolean(false);
67
+ }
68
+
69
+ createSerializableImport<TValue>(
70
+ from: string,
71
+ to: string
72
+ ): SerializableRef<TValue> {
73
+ return this.#workletsModuleProxy.createSerializableImport(from, to);
74
+ }
75
+
76
+ createSerializableString(str: string) {
77
+ return this.#workletsModuleProxy.createSerializableString(str);
78
+ }
79
+
80
+ createSerializableNumber(num: number) {
81
+ return this.#workletsModuleProxy.createSerializableNumber(num);
82
+ }
83
+
84
+ createSerializableBoolean(bool: boolean) {
85
+ return bool ? this.#serializableTrue : this.#serializableFalse;
86
+ }
87
+
88
+ createSerializableBigInt(bigInt: bigint) {
89
+ return this.#workletsModuleProxy.createSerializableBigInt(bigInt);
90
+ }
91
+
92
+ createSerializableUndefined() {
93
+ return this.#serializableUndefined;
94
+ }
95
+
96
+ createSerializableNull() {
97
+ return this.#serializableNull;
98
+ }
99
+
100
+ createSerializableTurboModuleLike<
101
+ TProps extends object,
102
+ TProto extends object,
103
+ >(props: TProps, proto: TProto): SerializableRef<TProps> {
104
+ return this.#workletsModuleProxy.createSerializableTurboModuleLike(
105
+ props,
106
+ proto
107
+ );
108
+ }
109
+
110
+ createSerializableObject<T extends object>(
111
+ obj: T,
112
+ shouldRetainRemote: boolean,
113
+ nativeStateSource?: object
114
+ ): SerializableRef<T> {
115
+ return this.#workletsModuleProxy.createSerializableObject(
116
+ obj,
117
+ shouldRetainRemote,
118
+ nativeStateSource
119
+ );
120
+ }
121
+
122
+ createSerializableHostObject<T extends object>(obj: T) {
123
+ return this.#workletsModuleProxy.createSerializableHostObject(obj);
124
+ }
125
+
126
+ createSerializableArray(
127
+ array: unknown[],
128
+ shouldRetainRemote: boolean = false
129
+ ) {
130
+ return this.#workletsModuleProxy.createSerializableArray(
131
+ array,
132
+ shouldRetainRemote
133
+ );
134
+ }
135
+
136
+ createSerializableArrayBuffer(arrayBuffer: ArrayBuffer) {
137
+ return this.#workletsModuleProxy.createSerializableArrayBuffer(arrayBuffer);
138
+ }
139
+
140
+ createSerializableMap<TKey, TValue>(
141
+ keys: TKey[],
142
+ values: TValue[]
143
+ ): SerializableRef<Map<TKey, TValue>> {
144
+ return this.#workletsModuleProxy.createSerializableMap(keys, values);
145
+ }
146
+
147
+ createSerializableSet<TValues>(
148
+ values: TValues[]
149
+ ): SerializableRef<Set<TValues>> {
150
+ return this.#workletsModuleProxy.createSerializableSet(values);
151
+ }
152
+
153
+ createSerializableError(
154
+ name: string,
155
+ message: string,
156
+ stack: string | undefined
157
+ ): SerializableRef<Error> {
158
+ return this.#workletsModuleProxy.createSerializableError(
159
+ name,
160
+ message,
161
+ stack
162
+ );
163
+ }
164
+
165
+ createSerializableRegExp(
166
+ pattern: string,
167
+ flags: string
168
+ ): SerializableRef<RegExp> {
169
+ return this.#workletsModuleProxy.createSerializableRegExp(pattern, flags);
170
+ }
171
+
172
+ createSerializableArrayBufferView<TValue extends ArrayBufferView>(
173
+ typeName: string,
174
+ buffer: ArrayBuffer,
175
+ byteOffset: number,
176
+ length: number
177
+ ): SerializableRef<TValue> {
178
+ return this.#workletsModuleProxy.createSerializableArrayBufferView<TValue>(
179
+ typeName,
180
+ buffer,
181
+ byteOffset,
182
+ length
183
+ );
184
+ }
185
+
186
+ createSerializableInitializer(obj: object) {
187
+ return this.#workletsModuleProxy.createSerializableInitializer(obj);
188
+ }
189
+
190
+ createSerializableNonWorkletFunction<TArgs extends unknown[], TReturn>(
191
+ fun: (...args: TArgs) => TReturn,
192
+ functionName: string | undefined
193
+ ): SerializableRef<(...args: TArgs) => TReturn> {
194
+ return this.#workletsModuleProxy.createSerializableNonWorkletFunction(
195
+ fun,
196
+ functionName
197
+ );
198
+ }
199
+
200
+ createSerializableWorklet(worklet: object, shouldPersistRemote: boolean) {
201
+ return this.#workletsModuleProxy.createSerializableWorklet(
202
+ worklet,
203
+ shouldPersistRemote
204
+ );
205
+ }
206
+
207
+ createCustomSerializable(
208
+ data: SerializableRef<unknown>,
209
+ typeId: number
210
+ ): SerializableRef<unknown> {
211
+ return this.#workletsModuleProxy.createCustomSerializable(data, typeId);
212
+ }
213
+
214
+ registerCustomSerializable(
215
+ determine: SerializableRef<object>,
216
+ pack: SerializableRef<object>,
217
+ unpack: SerializableRef<object>,
218
+ typeId: number
219
+ ): void {
220
+ this.#workletsModuleProxy.registerCustomSerializable(
221
+ determine,
222
+ pack,
223
+ unpack,
224
+ typeId
225
+ );
226
+ }
227
+
228
+ createShareable<TValue = unknown>(
229
+ hostRuntimeId: number,
230
+ initial: SerializableRef<TValue>,
231
+ initSynchronously: boolean,
232
+ decorateHost: SerializableRef,
233
+ decorateRef: SerializableRef
234
+ ): SerializableRef<TValue> {
235
+ return this.#workletsModuleProxy.createShareable(
236
+ hostRuntimeId,
237
+ initial,
238
+ initSynchronously,
239
+ decorateHost,
240
+ decorateRef
241
+ );
242
+ }
243
+
244
+ scheduleOnRN<TArgs extends unknown[]>(
245
+ fun: RemoteFunction | ((...args: TArgs) => unknown),
246
+ args: SerializableRef<TArgs> | undefined
247
+ ): void {
248
+ this.#workletsModuleProxy.scheduleOnRN(fun, args);
249
+ }
250
+
251
+ scheduleOnUI<TValue>(
252
+ serializableArrayOfWorklets: SerializableRef<TValue[]>,
253
+ scheduleStacks: string[] | undefined
254
+ ) {
255
+ return this.#workletsModuleProxy.scheduleOnUI(
256
+ serializableArrayOfWorklets,
257
+ scheduleStacks
258
+ );
259
+ }
260
+
261
+ runOnUISync<TValue, TReturn>(
262
+ worklet: SerializableRef<TValue>,
263
+ scheduleStack: string | undefined
264
+ ): TReturn {
265
+ return this.#workletsModuleProxy.runOnUISync(worklet, scheduleStack);
266
+ }
267
+
268
+ createWorkletRuntime(
269
+ name: string,
270
+ initializer: SerializableRef<() => void>,
271
+ useDefaultQueue: boolean,
272
+ customQueue: object | undefined,
273
+ enableEventLoop: boolean
274
+ ) {
275
+ return this.#workletsModuleProxy.createWorkletRuntime(
276
+ name,
277
+ initializer,
278
+ useDefaultQueue,
279
+ customQueue,
280
+ enableEventLoop
281
+ );
282
+ }
283
+
284
+ scheduleOnRuntime<TValue>(
285
+ workletRuntime: WorkletRuntime,
286
+ serializableWorklet: SerializableRef<TValue>,
287
+ scheduleStack: string | undefined
288
+ ) {
289
+ return this.#workletsModuleProxy.scheduleOnRuntime(
290
+ workletRuntime,
291
+ serializableWorklet,
292
+ scheduleStack
293
+ );
294
+ }
295
+
296
+ scheduleOnRuntimeWithId<TValue>(
297
+ runtimeId: number,
298
+ worklet: SerializableRef<TValue>,
299
+ scheduleStack: string | undefined
300
+ ) {
301
+ return this.#workletsModuleProxy.scheduleOnRuntimeWithId(
302
+ runtimeId,
303
+ worklet,
304
+ scheduleStack
305
+ );
306
+ }
307
+
308
+ runOnRuntimeSync<TValue, TReturn>(
309
+ workletRuntime: WorkletRuntime,
310
+ worklet: SerializableRef<TValue>,
311
+ scheduleStack: string | undefined
312
+ ): TReturn {
313
+ return this.#workletsModuleProxy.runOnRuntimeSync(
314
+ workletRuntime,
315
+ worklet,
316
+ scheduleStack
317
+ );
318
+ }
319
+
320
+ runOnRuntimeSyncWithId<TValue, TReturn>(
321
+ runtimeId: number,
322
+ worklet: SerializableRef<TValue>,
323
+ scheduleStack: string | undefined
324
+ ): TReturn {
325
+ return this.#workletsModuleProxy.runOnRuntimeSyncWithId(
326
+ runtimeId,
327
+ worklet,
328
+ scheduleStack
329
+ );
330
+ }
331
+
332
+ handlePromise<TValue>(
333
+ resolveOrReject:
334
+ | ((value: TValue | PromiseLike<TValue>) => void)
335
+ | RemoteFunction,
336
+ valueOrError: SerializableRef<TValue>
337
+ ) {
338
+ return this.#workletsModuleProxy.handlePromise(
339
+ resolveOrReject,
340
+ valueOrError
341
+ );
342
+ }
343
+
344
+ createSynchronizable<TValue>(value: TValue): SynchronizableRef<TValue> {
345
+ return this.#workletsModuleProxy.createSynchronizable(value);
346
+ }
347
+
348
+ synchronizableGetDirty<TValue>(
349
+ synchronizableRef: SynchronizableRef<TValue>
350
+ ): TValue {
351
+ return this.#workletsModuleProxy.synchronizableGetDirty(synchronizableRef);
352
+ }
353
+
354
+ synchronizableGetBlocking<TValue>(
355
+ synchronizableRef: SynchronizableRef<TValue>
356
+ ): TValue {
357
+ return this.#workletsModuleProxy.synchronizableGetBlocking(
358
+ synchronizableRef
359
+ );
360
+ }
361
+
362
+ synchronizableSetBlocking<TValue>(
363
+ synchronizableRef: SynchronizableRef<TValue>,
364
+ value: SerializableRef<TValue>
365
+ ) {
366
+ return this.#workletsModuleProxy.synchronizableSetBlocking(
367
+ synchronizableRef,
368
+ value
369
+ );
370
+ }
371
+
372
+ synchronizableLock<TValue>(
373
+ synchronizableRef: SynchronizableRef<TValue>
374
+ ): void {
375
+ return this.#workletsModuleProxy.synchronizableLock(synchronizableRef);
376
+ }
377
+
378
+ synchronizableUnlock<TValue>(
379
+ synchronizableRef: SynchronizableRef<TValue>
380
+ ): void {
381
+ return this.#workletsModuleProxy.synchronizableUnlock(synchronizableRef);
382
+ }
383
+
384
+ reportFatalErrorOnJS(message: string, stack: string, name: string) {
385
+ return this.#workletsModuleProxy.reportFatalErrorOnJS(message, stack, name);
386
+ }
387
+
388
+ getStaticFeatureFlag(name: string): boolean {
389
+ return this.#workletsModuleProxy.getStaticFeatureFlag(name);
390
+ }
391
+
392
+ setDynamicFeatureFlag(name: string, value: boolean) {
393
+ this.#workletsModuleProxy.setDynamicFeatureFlag(name, value);
394
+ }
395
+
396
+ getUIRuntimeHolder(): object {
397
+ return this.#workletsModuleProxy.getUIRuntimeHolder();
398
+ }
399
+
400
+ getUISchedulerHolder(): object {
401
+ return this.#workletsModuleProxy.getUISchedulerHolder();
402
+ }
403
+
404
+ toggleSlowAnimationsOnUIRuntime(): boolean {
405
+ return WorkletsTurboModule?.toggleSlowAnimationsOnUIRuntime() ?? false;
406
+ }
407
+ }
408
+
409
+ export const WorkletsModule: IWorkletsModule = new NativeWorklets();
410
+
411
+ function installUnpackers(workletsModuleProxy: WorkletsModuleProxy) {
412
+ const value = (installValueUnpacker as WorkletFunction).__initData!;
413
+ const synchronizable = (installSynchronizableUnpacker as WorkletFunction)
414
+ .__initData!;
415
+ const customSerializable = (
416
+ installCustomSerializableUnpacker as WorkletFunction
417
+ ).__initData!;
418
+ const shareableHost = (installShareableHostUnpacker as WorkletFunction)
419
+ .__initData!;
420
+ const shareableGuest = (installShareableGuestUnpacker as WorkletFunction)
421
+ .__initData!;
422
+ const remoteFunction = (installRemoteFunctionUnpacker as WorkletFunction)
423
+ .__initData!;
424
+
425
+ if (value.bytecode !== undefined) {
426
+ if (__DEV__) {
427
+ throw new Error(
428
+ '[Worklets] Unpackers were compiled to Hermes bytecode in a development build, which is not supported.'
429
+ );
430
+ }
431
+ workletsModuleProxy.loadUnpackersWithBytecode(
432
+ value.bytecode,
433
+ synchronizable.bytecode!,
434
+ customSerializable.bytecode!,
435
+ shareableHost.bytecode!,
436
+ shareableGuest.bytecode!,
437
+ remoteFunction.bytecode!
438
+ );
439
+ } else {
440
+ workletsModuleProxy.loadUnpackersWithCode(
441
+ value.code!,
442
+ value.location ?? '',
443
+ value.sourceMap ?? '',
444
+ synchronizable.code!,
445
+ synchronizable.location ?? '',
446
+ synchronizable.sourceMap ?? '',
447
+ customSerializable.code!,
448
+ customSerializable.location ?? '',
449
+ customSerializable.sourceMap ?? '',
450
+ shareableHost.code!,
451
+ shareableHost.location ?? '',
452
+ shareableHost.sourceMap ?? '',
453
+ shareableGuest.code!,
454
+ shareableGuest.location ?? '',
455
+ shareableGuest.sourceMap ?? '',
456
+ remoteFunction.code!,
457
+ remoteFunction.location ?? '',
458
+ remoteFunction.sourceMap ?? ''
459
+ );
460
+ }
461
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ import type { IWorkletsModule } from './workletsModuleProxy';
4
+
5
+ export const WorkletsModule: IWorkletsModule = null!;