@depup/react-native-worklets 0.12.1-depup.0 → 0.13.0-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 (311) hide show
  1. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +1 -2
  2. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +1 -1
  3. package/Common/cpp/worklets/Compat/StableApi.cpp +24 -8
  4. package/Common/cpp/worklets/Compat/StableApi.h +1 -1
  5. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +113 -50
  6. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +10 -1
  7. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +95 -37
  8. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +57 -7
  9. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.cpp +94 -0
  10. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.h +58 -0
  11. package/Common/cpp/worklets/Networking/Networking.cpp +283 -0
  12. package/Common/cpp/worklets/Networking/Networking.h +51 -0
  13. package/Common/cpp/worklets/Networking/NetworkingBackend.h +47 -0
  14. package/Common/cpp/worklets/Networking/NetworkingInstaller.cpp +127 -0
  15. package/Common/cpp/worklets/Networking/NetworkingInstaller.h +19 -0
  16. package/Common/cpp/worklets/Networking/NetworkingTypes.h +33 -0
  17. package/Common/cpp/worklets/Networking/TextDecoding.cpp +189 -0
  18. package/Common/cpp/worklets/Networking/TextDecoding.h +29 -0
  19. package/Common/cpp/worklets/RunLoop/AsyncQueue.h +28 -0
  20. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +9 -0
  21. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +6 -0
  22. package/Common/cpp/worklets/RunLoop/EventLoop.cpp +19 -4
  23. package/Common/cpp/worklets/RunLoop/EventLoop.h +3 -0
  24. package/Common/cpp/worklets/SharedItems/MemoryManager.cpp +1 -1
  25. package/Common/cpp/worklets/SharedItems/MemoryManager.h +2 -1
  26. package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.cpp +37 -0
  27. package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.h +33 -0
  28. package/Common/cpp/worklets/SharedItems/Serializable/RetainingSerializable.h +112 -0
  29. package/Common/cpp/worklets/SharedItems/Serializable/Serializable.cpp +129 -0
  30. package/Common/cpp/worklets/SharedItems/Serializable/Serializable.h +121 -0
  31. package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.cpp +38 -0
  32. package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.h +39 -0
  33. package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.cpp +35 -0
  34. package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.h +43 -0
  35. package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.cpp +23 -0
  36. package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.h +35 -0
  37. package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.cpp +38 -0
  38. package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.h +30 -0
  39. package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.cpp +24 -0
  40. package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.h +32 -0
  41. package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.cpp +19 -0
  42. package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.h +25 -0
  43. package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.cpp +29 -0
  44. package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.h +25 -0
  45. package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.cpp +44 -0
  46. package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.h +25 -0
  47. package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.cpp +80 -0
  48. package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.h +35 -0
  49. package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.cpp +22 -0
  50. package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.h +25 -0
  51. package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.cpp → Serializable/SerializableRemoteFunction.cpp} +30 -2
  52. package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.h → Serializable/SerializableRemoteFunction.h} +24 -10
  53. package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.cpp +46 -0
  54. package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.h +41 -0
  55. package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.cpp +36 -0
  56. package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.h +23 -0
  57. package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.cpp +19 -0
  58. package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.h +22 -0
  59. package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.cpp +26 -0
  60. package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.h +33 -0
  61. package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.cpp +31 -0
  62. package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.h +23 -0
  63. package/Common/cpp/worklets/SharedItems/Serializable.h +21 -409
  64. package/Common/cpp/worklets/SharedItems/Shareable.cpp +1 -1
  65. package/Common/cpp/worklets/SharedItems/Shareable.h +1 -1
  66. package/Common/cpp/worklets/SharedItems/Synchronizable.h +43 -20
  67. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +24 -26
  68. package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +5 -7
  69. package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.cpp +36 -0
  70. package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.h +27 -0
  71. package/Common/cpp/worklets/SharedItems/SynchronizableFixed.cpp +76 -0
  72. package/Common/cpp/worklets/SharedItems/SynchronizableFixed.h +48 -0
  73. package/Common/cpp/worklets/Tools/ScriptBuffer.h +0 -5
  74. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +16 -30
  75. package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +27 -30
  76. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +4 -3
  77. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +2 -1
  78. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +79 -29
  79. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +34 -19
  80. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +13 -86
  81. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +1 -7
  82. package/Package.swift +147 -0
  83. package/README.md +7 -7
  84. package/RNWorklets.podspec +1 -2
  85. package/android/CMakeLists.txt +7 -26
  86. package/android/build.gradle.kts +5 -31
  87. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +46 -129
  88. package/android/src/main/cpp/worklets/android/WorkletsModule.h +21 -11
  89. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +2 -4
  90. package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.cpp +82 -0
  91. package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.h +32 -0
  92. package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.cpp +73 -0
  93. package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.h +38 -0
  94. package/android/src/{no-networking → main/java}/com/swmansion/worklets/WorkletsModule.kt +40 -28
  95. package/android/src/main/java/com/swmansion/worklets/networking/NetworkRequestListener.kt +37 -0
  96. package/android/src/main/java/com/swmansion/worklets/networking/Networking.kt +244 -0
  97. package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.kt +40 -5
  98. package/apple/worklets/apple/AnimationFrameQueue.mm +9 -1
  99. package/apple/worklets/apple/AssertJavaScriptQueue.h +3 -2
  100. package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +4 -0
  101. package/apple/worklets/apple/IOSUIScheduler.mm +3 -0
  102. package/apple/worklets/apple/Networking/AppleNetworkingBackend.h +29 -0
  103. package/apple/worklets/apple/Networking/AppleNetworkingBackend.mm +93 -0
  104. package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.h +37 -0
  105. package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.mm +447 -0
  106. package/apple/worklets/apple/WorkletsModule.h +3 -2
  107. package/apple/worklets/apple/WorkletsModule.mm +82 -74
  108. package/bundleMode/index.js +10 -47
  109. package/bundleMode/polyfills/prepareBundleMode.js +16 -0
  110. package/changes.json +6 -6
  111. package/compatibility.json +4 -1
  112. package/lib/module/WorkletsModule/NativeWorklets.native.js +12 -9
  113. package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
  114. package/lib/module/debug/jsVersion.js +1 -1
  115. package/lib/module/featureFlags/staticFlags.json +0 -1
  116. package/lib/module/featureFlags/types.js +0 -1
  117. package/lib/module/featureFlags/types.js.map +1 -1
  118. package/lib/module/index.js +1 -1
  119. package/lib/module/index.js.map +1 -1
  120. package/lib/module/initializers/initializers.native.js +5 -12
  121. package/lib/module/initializers/initializers.native.js.map +1 -1
  122. package/lib/module/memory/bundleUnpacker.native.js +2 -10
  123. package/lib/module/memory/bundleUnpacker.native.js.map +1 -1
  124. package/lib/module/memory/serializable.native.js +3 -31
  125. package/lib/module/memory/serializable.native.js.map +1 -1
  126. package/lib/module/memory/synchronizable.js +1 -1
  127. package/lib/module/memory/synchronizable.js.map +1 -1
  128. package/lib/module/memory/synchronizable.native.js +7 -3
  129. package/lib/module/memory/synchronizable.native.js.map +1 -1
  130. package/lib/module/memory/synchronizableUnpacker.native.js +22 -9
  131. package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -1
  132. package/lib/module/memory/valueUnpacker.native.js +0 -8
  133. package/lib/module/memory/valueUnpacker.native.js.map +1 -1
  134. package/lib/module/mock.js +22 -1
  135. package/lib/module/mock.js.map +1 -1
  136. package/lib/module/networking/AbortController.js +43 -0
  137. package/lib/module/networking/AbortController.js.map +1 -0
  138. package/lib/module/networking/Blob.js +60 -0
  139. package/lib/module/networking/Blob.js.map +1 -0
  140. package/lib/module/networking/DOMException.js +35 -0
  141. package/lib/module/networking/DOMException.js.map +1 -0
  142. package/lib/module/networking/FileReader.js +83 -0
  143. package/lib/module/networking/FileReader.js.map +1 -0
  144. package/lib/module/networking/FormData.js +105 -0
  145. package/lib/module/networking/FormData.js.map +1 -0
  146. package/lib/module/networking/XMLHttpRequest.js +450 -0
  147. package/lib/module/networking/XMLHttpRequest.js.map +1 -0
  148. package/lib/module/networking/bytes.js +6 -0
  149. package/lib/module/networking/bytes.js.map +1 -0
  150. package/lib/module/networking/events.js +44 -0
  151. package/lib/module/networking/events.js.map +1 -0
  152. package/lib/module/networking/http.js +100 -0
  153. package/lib/module/networking/http.js.map +1 -0
  154. package/lib/module/networking/install.js +37 -0
  155. package/lib/module/networking/install.js.map +1 -0
  156. package/lib/module/networking/utf8.js +99 -0
  157. package/lib/module/networking/utf8.js.map +1 -0
  158. package/lib/module/privateGlobals.d.js +0 -1
  159. package/lib/module/privateGlobals.d.js.map +1 -1
  160. package/lib/module/runLoop/common/queueMicrotaskPolyfill.js +9 -0
  161. package/lib/module/runLoop/common/queueMicrotaskPolyfill.js.map +1 -0
  162. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +7 -3
  163. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -1
  164. package/lib/module/runLoop/workletRuntime/index.js +1 -1
  165. package/lib/module/runLoop/workletRuntime/index.js.map +1 -1
  166. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +1 -1
  167. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -1
  168. package/lib/module/runLoop/workletRuntime/taskQueue.js +0 -13
  169. package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -1
  170. package/lib/module/runtimes.native.js +8 -1
  171. package/lib/module/runtimes.native.js.map +1 -1
  172. package/lib/module/specs/NativeWorkletsModule.js.map +1 -1
  173. package/lib/module/threads.js +11 -0
  174. package/lib/module/threads.js.map +1 -1
  175. package/lib/module/threads.native.js +35 -42
  176. package/lib/module/threads.native.js.map +1 -1
  177. package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
  178. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +6 -5
  179. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
  180. package/lib/typescript/debug/jsVersion.d.ts +1 -1
  181. package/lib/typescript/featureFlags/types.d.ts +0 -1
  182. package/lib/typescript/featureFlags/types.d.ts.map +1 -1
  183. package/lib/typescript/index.d.ts +2 -2
  184. package/lib/typescript/index.d.ts.map +1 -1
  185. package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -1
  186. package/lib/typescript/memory/serializable.native.d.ts.map +1 -1
  187. package/lib/typescript/memory/synchronizable.d.ts +6 -2
  188. package/lib/typescript/memory/synchronizable.d.ts.map +1 -1
  189. package/lib/typescript/memory/synchronizable.native.d.ts +6 -2
  190. package/lib/typescript/memory/synchronizable.native.d.ts.map +1 -1
  191. package/lib/typescript/memory/synchronizableUnpacker.native.d.ts +1 -1
  192. package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -1
  193. package/lib/typescript/memory/types.d.ts +6 -0
  194. package/lib/typescript/memory/types.d.ts.map +1 -1
  195. package/lib/typescript/memory/valueUnpacker.native.d.ts.map +1 -1
  196. package/lib/typescript/networking/AbortController.d.ts +16 -0
  197. package/lib/typescript/networking/AbortController.d.ts.map +1 -0
  198. package/lib/typescript/networking/Blob.d.ts +16 -0
  199. package/lib/typescript/networking/Blob.d.ts.map +1 -0
  200. package/lib/typescript/networking/DOMException.d.ts +5 -0
  201. package/lib/typescript/networking/DOMException.d.ts.map +1 -0
  202. package/lib/typescript/networking/FileReader.d.ts +19 -0
  203. package/lib/typescript/networking/FileReader.d.ts.map +1 -0
  204. package/lib/typescript/networking/FormData.d.ts +30 -0
  205. package/lib/typescript/networking/FormData.d.ts.map +1 -0
  206. package/lib/typescript/networking/XMLHttpRequest.d.ts +77 -0
  207. package/lib/typescript/networking/XMLHttpRequest.d.ts.map +1 -0
  208. package/lib/typescript/networking/bytes.d.ts +2 -0
  209. package/lib/typescript/networking/bytes.d.ts.map +1 -0
  210. package/lib/typescript/networking/events.d.ts +18 -0
  211. package/lib/typescript/networking/events.d.ts.map +1 -0
  212. package/lib/typescript/networking/http.d.ts +14 -0
  213. package/lib/typescript/networking/http.d.ts.map +1 -0
  214. package/lib/typescript/networking/install.d.ts +2 -0
  215. package/lib/typescript/networking/install.d.ts.map +1 -0
  216. package/lib/typescript/networking/utf8.d.ts +4 -0
  217. package/lib/typescript/networking/utf8.d.ts.map +1 -0
  218. package/lib/typescript/runLoop/{workletRuntime/queueMicrotask.d.ts → common/queueMicrotaskPolyfill.d.ts} +1 -1
  219. package/lib/typescript/runLoop/common/queueMicrotaskPolyfill.d.ts.map +1 -0
  220. package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -1
  221. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +0 -2
  222. package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -1
  223. package/lib/typescript/runtimes.native.d.ts.map +1 -1
  224. package/lib/typescript/specs/NativeWorkletsModule.d.ts +1 -0
  225. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -1
  226. package/lib/typescript/threads.d.ts +8 -0
  227. package/lib/typescript/threads.d.ts.map +1 -1
  228. package/lib/typescript/threads.native.d.ts +8 -1
  229. package/lib/typescript/threads.native.d.ts.map +1 -1
  230. package/lib/typescript/types.d.ts +9 -5
  231. package/lib/typescript/types.d.ts.map +1 -1
  232. package/package.json +36 -22
  233. package/plugin/index.js +63 -93
  234. package/plugin-oxc/babel.d.ts +7 -0
  235. package/plugin-oxc/babel.js +200 -0
  236. package/plugin-oxc/index.d.ts +33 -0
  237. package/plugin-oxc/index.js +36 -0
  238. package/plugin-oxc/worklets-oxc-plugin.darwin-arm64.node +0 -0
  239. package/plugin-oxc/worklets-oxc-plugin.darwin-x64.node +0 -0
  240. package/plugin-oxc/worklets-oxc-plugin.linux-arm64.node +0 -0
  241. package/plugin-oxc/worklets-oxc-plugin.linux-x64.node +0 -0
  242. package/plugin-oxc/worklets-oxc-plugin.win32-arm64.node +0 -0
  243. package/plugin-oxc/worklets-oxc-plugin.win32-x64.node +0 -0
  244. package/react-native.config.js +5 -0
  245. package/scripts/worklets_utils.rb +0 -10
  246. package/src/WorkletsModule/NativeWorklets.native.ts +26 -9
  247. package/src/WorkletsModule/workletsModuleProxy.ts +15 -5
  248. package/src/debug/jsVersion.ts +1 -1
  249. package/src/featureFlags/staticFlags.json +0 -1
  250. package/src/featureFlags/types.ts +0 -1
  251. package/src/index.ts +3 -0
  252. package/src/initializers/initializers.native.ts +5 -13
  253. package/src/memory/bundleUnpacker.native.ts +6 -13
  254. package/src/memory/serializable.native.ts +6 -46
  255. package/src/memory/synchronizable.native.ts +38 -4
  256. package/src/memory/synchronizable.ts +22 -2
  257. package/src/memory/synchronizableUnpacker.native.ts +38 -13
  258. package/src/memory/types.ts +9 -0
  259. package/src/memory/valueUnpacker.native.ts +0 -8
  260. package/src/mock.ts +28 -1
  261. package/src/networking/AbortController.ts +57 -0
  262. package/src/networking/Blob.ts +74 -0
  263. package/src/networking/DOMException.ts +37 -0
  264. package/src/networking/FileReader.ts +99 -0
  265. package/src/networking/FormData.ts +135 -0
  266. package/src/networking/XMLHttpRequest.ts +557 -0
  267. package/src/networking/bytes.ts +8 -0
  268. package/src/networking/events.ts +61 -0
  269. package/src/networking/http.ts +173 -0
  270. package/src/networking/install.ts +38 -0
  271. package/src/networking/utf8.ts +122 -0
  272. package/src/privateGlobals.d.ts +20 -13
  273. package/src/runLoop/common/queueMicrotaskPolyfill.ts +12 -0
  274. package/src/runLoop/uiRuntime/requestAnimationFrame.ts +7 -4
  275. package/src/runLoop/workletRuntime/index.ts +1 -1
  276. package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +1 -1
  277. package/src/runLoop/workletRuntime/taskQueue.ts +0 -15
  278. package/src/runtimes.native.ts +10 -1
  279. package/src/specs/NativeWorkletsModule.ts +1 -0
  280. package/src/threads.native.ts +49 -54
  281. package/src/threads.ts +11 -0
  282. package/src/types.ts +9 -5
  283. package/Common/cpp/worklets/SharedItems/Serializable.cpp +0 -373
  284. package/Common/cpp/worklets/SharedItems/SerializableFactory.cpp +0 -172
  285. package/Common/cpp/worklets/SharedItems/SerializableFactory.h +0 -85
  286. package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +0 -59
  287. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +0 -51
  288. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +0 -43
  289. package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +0 -27
  290. package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +0 -30
  291. package/android/src/networking/com/swmansion/worklets/WorkletsModule.kt +0 -203
  292. package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +0 -272
  293. package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +0 -1124
  294. package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +0 -40
  295. package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +0 -13
  296. package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +0 -98
  297. package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +0 -60
  298. package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +0 -87
  299. package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +0 -181
  300. package/apple/worklets/apple/Networking/WorkletsNetworking.h +0 -25
  301. package/apple/worklets/apple/Networking/WorkletsNetworking.mm +0 -707
  302. package/bundleMode/shims/turboModuleRegistryShim.js +0 -47
  303. package/lib/module/bundleMode/network.native.js +0 -44
  304. package/lib/module/bundleMode/network.native.js.map +0 -1
  305. package/lib/module/runLoop/workletRuntime/queueMicrotask.js +0 -11
  306. package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +0 -1
  307. package/lib/typescript/bundleMode/network.native.d.ts +0 -7
  308. package/lib/typescript/bundleMode/network.native.d.ts.map +0 -1
  309. package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +0 -1
  310. package/src/bundleMode/network.native.ts +0 -63
  311. package/src/runLoop/workletRuntime/queueMicrotask.ts +0 -13
package/plugin/index.js CHANGED
@@ -486,8 +486,8 @@ var require_autoworkletization = __commonJS({
486
486
  ["useDerivedValue", [0]],
487
487
  ["useAnimatedScrollHandler", [0]],
488
488
  ["useAnimatedReaction", [0, 1]],
489
- ["withTiming", [2]],
490
- ["withSpring", [2]],
489
+ ["withTiming", [2, 3]],
490
+ ["withSpring", [2, 3]],
491
491
  ["withDecay", [1]],
492
492
  ["withRepeat", [3]],
493
493
  ["runOnUI", [0]],
@@ -549,7 +549,8 @@ var require_bundleMode = __commonJS({
549
549
  (0, path_1.join)(WORKLETS_SRC_DIR, "index.ts"),
550
550
  (0, path_1.join)(WORKLETS_SRC_DIR, "debug", "bundleMode.native.ts"),
551
551
  (0, path_1.join)(WORKLETS_LIB_DIR, "index.js"),
552
- (0, path_1.join)(WORKLETS_LIB_DIR, "debug", "bundleMode.native.js")
552
+ (0, path_1.join)(WORKLETS_LIB_DIR, "debug", "bundleMode.native.js"),
553
+ (0, path_1.join)(WORKLETS_PACKAGE, "bundleMode", "polyfills", "prepareBundleMode.js")
553
554
  ];
554
555
  function toggleBundleMode(path, state) {
555
556
  if (!state.opts.bundleMode || !togglePaths.some((togglePath) => {
@@ -846,6 +847,9 @@ var require_classMethod = __commonJS({
846
847
  var types_12 = require("@babel/types");
847
848
  var assert_1 = require("assert");
848
849
  function processIfWorkletMethod(path) {
850
+ if (path.node.kind !== "method") {
851
+ return;
852
+ }
849
853
  if (path.node.body.directives.some((d) => d.value.value === "worklet")) {
850
854
  (0, assert_1.strict)((0, types_12.isIdentifier)(path.node.key), "ClassMethod key must be an Identifier");
851
855
  const methodIdentifier = path.node.key;
@@ -855,48 +859,13 @@ var require_classMethod = __commonJS({
855
859
  }
856
860
  });
857
861
 
858
- // lib/contextObject.js
859
- var require_contextObject = __commonJS({
860
- "lib/contextObject.js"(exports2) {
861
- "use strict";
862
- Object.defineProperty(exports2, "__esModule", { value: true });
863
- exports2.contextObjectMarker = void 0;
864
- exports2.processIfWorkletContextObject = processIfWorkletContextObject;
865
- exports2.isContextObject = isContextObject;
866
- var types_12 = require("@babel/types");
867
- var directives_12 = require_directives();
868
- exports2.contextObjectMarker = "__workletContextObject";
869
- function processIfWorkletContextObject(path, _state) {
870
- if (!isContextObject(path.node)) {
871
- return false;
872
- }
873
- removeContextObjectMarker(path.node);
874
- processWorkletContextObject(path.node);
875
- return true;
876
- }
877
- function isContextObject(objectExpression) {
878
- return objectExpression.properties.some((property) => (0, types_12.isObjectProperty)(property) && (0, types_12.isIdentifier)(property.key) && property.key.name === exports2.contextObjectMarker);
879
- }
880
- function processWorkletContextObject(objectExpression) {
881
- const workletObjectFactory = (0, types_12.functionExpression)(null, [], (0, types_12.blockStatement)([(0, types_12.returnStatement)((0, types_12.cloneNode)(objectExpression))]));
882
- (0, directives_12.addWorkletDirectivesToFunctionBody)(workletObjectFactory.body);
883
- objectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)(`${exports2.contextObjectMarker}Factory`), workletObjectFactory));
884
- }
885
- function removeContextObjectMarker(objectExpression) {
886
- objectExpression.properties = objectExpression.properties.filter((property) => !((0, types_12.isObjectProperty)(property) && (0, types_12.isIdentifier)(property.key) && property.key.name === exports2.contextObjectMarker));
887
- }
888
- }
889
- });
890
-
891
862
  // lib/file.js
892
863
  var require_file = __commonJS({
893
864
  "lib/file.js"(exports2) {
894
865
  "use strict";
895
866
  Object.defineProperty(exports2, "__esModule", { value: true });
896
867
  exports2.processIfWorkletFile = processIfWorkletFile;
897
- exports2.isImplicitContextObject = isImplicitContextObject;
898
868
  var types_12 = require("@babel/types");
899
- var contextObject_12 = require_contextObject();
900
869
  var directives_12 = require_directives();
901
870
  var types_2 = require_types();
902
871
  function processIfWorkletFile(path, state) {
@@ -927,11 +896,7 @@ var require_file = __commonJS({
927
896
  if ((0, types_2.isWorkletizableFunctionPath)(nodePath)) {
928
897
  (0, directives_12.addWorkletDirectivesToPath)(nodePath);
929
898
  } else if ((0, types_2.isWorkletizableObjectPath)(nodePath)) {
930
- if (isImplicitContextObject(nodePath)) {
931
- appendWorkletContextObjectMarker(nodePath.node);
932
- } else {
933
- processWorkletAggregator(nodePath, state);
934
- }
899
+ processWorkletAggregator(nodePath, state);
935
900
  } else if (nodePath.isVariableDeclaration()) {
936
901
  processVariableDeclaration(nodePath, state);
937
902
  } else if (nodePath.isClassDeclaration()) {
@@ -964,31 +929,6 @@ var require_file = __commonJS({
964
929
  }
965
930
  });
966
931
  }
967
- function appendWorkletContextObjectMarker(objectExpression) {
968
- if (objectExpression.properties.some((value) => (0, types_12.isObjectProperty)(value) && (0, types_12.isIdentifier)(value.key) && value.key.name === contextObject_12.contextObjectMarker)) {
969
- return;
970
- }
971
- objectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)(`${contextObject_12.contextObjectMarker}`), (0, types_12.booleanLiteral)(true)));
972
- }
973
- function isImplicitContextObject(path) {
974
- const propertyPaths = path.get("properties");
975
- return propertyPaths.some((propertyPath) => {
976
- if (!propertyPath.isObjectMethod()) {
977
- return false;
978
- }
979
- return hasThisExpression(propertyPath);
980
- });
981
- }
982
- function hasThisExpression(path) {
983
- let result = false;
984
- path.traverse({
985
- ThisExpression(thisPath) {
986
- result = true;
987
- thisPath.stop();
988
- }
989
- });
990
- return result;
991
- }
992
932
  function appendWorkletClassMarker(classBody) {
993
933
  classBody.body.push((0, types_12.classProperty)((0, types_12.identifier)("__workletClass"), (0, types_12.booleanLiteral)(true)));
994
934
  }
@@ -1008,7 +948,17 @@ var require_file = __commonJS({
1008
948
  }
1009
949
  }
1010
950
  function isCommonJSExport(statement) {
1011
- return (0, types_12.isExpressionStatement)(statement) && (0, types_12.isAssignmentExpression)(statement.expression) && (0, types_12.isMemberExpression)(statement.expression.left) && (0, types_12.isIdentifier)(statement.expression.left.object) && statement.expression.left.object.name === "exports";
951
+ return (0, types_12.isExpressionStatement)(statement) && (0, types_12.isAssignmentExpression)(statement.expression) && (0, types_12.isMemberExpression)(statement.expression.left) && isCommonJSExportTarget(statement.expression.left);
952
+ }
953
+ function isCommonJSExportTarget(target) {
954
+ const object = target.object;
955
+ if ((0, types_12.isIdentifier)(object)) {
956
+ return object.name === "exports" || object.name === "module" && isExportsProperty(target);
957
+ }
958
+ return (0, types_12.isMemberExpression)(object) && isCommonJSExportTarget(object);
959
+ }
960
+ function isExportsProperty(target) {
961
+ return target.computed ? (0, types_12.isStringLiteral)(target.property, { value: "exports" }) : (0, types_12.isIdentifier)(target.property, { name: "exports" });
1012
962
  }
1013
963
  }
1014
964
  });
@@ -1123,11 +1073,20 @@ var require_globals = __commonJS({
1123
1073
  "self",
1124
1074
  "console",
1125
1075
  "performance",
1076
+ "navigator",
1126
1077
  "arguments",
1127
1078
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
1128
1079
  "require",
1129
1080
  "fetch",
1081
+ "Headers",
1082
+ "Request",
1083
+ "Response",
1130
1084
  "XMLHttpRequest",
1085
+ "FormData",
1086
+ "AbortController",
1087
+ "AbortSignal",
1088
+ "Blob",
1089
+ "FileReader",
1131
1090
  "WebSocket",
1132
1091
  // Run loop
1133
1092
  "queueMicrotask",
@@ -1181,10 +1140,7 @@ var require_globals = __commonJS({
1181
1140
  exports2.globals = new Set(exports2.defaultGlobals);
1182
1141
  }
1183
1142
  var defaultAllowedPaths = ["react-native-worklets"];
1184
- var defaultAllowedModules = [
1185
- "react-native-worklets",
1186
- "react-native/Libraries/Core/setUpXHR"
1187
- ];
1143
+ var defaultAllowedModules = ["react-native-worklets"];
1188
1144
  function addCustomGlobals(state) {
1189
1145
  if (state.opts && Array.isArray(state.opts.globals)) {
1190
1146
  state.opts.globals.forEach((name) => {
@@ -1367,6 +1323,9 @@ var require_closure = __commonJS({
1367
1323
  var types_12 = require("@babel/types");
1368
1324
  var globals_12 = require_globals();
1369
1325
  var imports_1 = require_imports();
1326
+ function toClosureIdentifier(node) {
1327
+ return (0, types_12.isJSXIdentifier)(node) ? (0, types_12.identifier)(node.name) : (0, types_12.cloneNode)(node, true);
1328
+ }
1370
1329
  function getClosure(funPath, state) {
1371
1330
  const capturedNames = /* @__PURE__ */ new Set();
1372
1331
  const closureVariables = new Array();
@@ -1396,7 +1355,7 @@ var require_closure = __commonJS({
1396
1355
  return;
1397
1356
  }
1398
1357
  capturedNames.add(name);
1399
- closureVariables.push((0, types_12.cloneNode)(idPath.node, true));
1358
+ closureVariables.push(toClosureIdentifier(idPath.node));
1400
1359
  return;
1401
1360
  }
1402
1361
  if ("id" in funPath.node) {
@@ -1426,7 +1385,7 @@ var require_closure = __commonJS({
1426
1385
  }
1427
1386
  }
1428
1387
  capturedNames.add(name);
1429
- closureVariables.push((0, types_12.cloneNode)(idPath.node, true));
1388
+ closureVariables.push(toClosureIdentifier(idPath.node));
1430
1389
  }
1431
1390
  }, state);
1432
1391
  return {
@@ -1460,7 +1419,13 @@ var require_generate = __commonJS({
1460
1419
  const filesDirPath = (0, path_1.resolve)((0, path_1.dirname)(require.resolve("react-native-worklets/package.json")), types_2.generatedWorkletsDir);
1461
1420
  const relativeImports = Array.from(relativeBindingsToImport).filter((binding) => binding.path.isImportSpecifier() && binding.path.parentPath.isImportDeclaration()).map((binding) => (0, types_12.importDeclaration)([(0, types_12.cloneNode)(binding.path.node, true)], (0, imports_1.createImportPathLiteral)(binding.path.parentPath.node.source.value, state)));
1462
1421
  const imports = [...libraryImports, ...relativeImports];
1463
- const newProg = (0, types_12.program)([...imports, (0, types_12.exportDefaultDeclaration)(factory)]);
1422
+ const statements = [...factory.body.body];
1423
+ const returnedWorklet = statements.pop();
1424
+ (0, assert_1.default)((0, types_12.isReturnStatement)(returnedWorklet) && returnedWorklet.argument);
1425
+ const newProg = (0, types_12.program)([
1426
+ ...imports,
1427
+ ...factory.params.length === 0 ? [...statements, (0, types_12.exportDefaultDeclaration)(returnedWorklet.argument)] : [(0, types_12.exportDefaultDeclaration)(factory)]
1428
+ ]);
1464
1429
  const transformedProg = (_a = (0, core_1.transformFromAstSync)(newProg, void 0, {
1465
1430
  filename: state.file.opts.filename,
1466
1431
  presets: [resolvePresetTypescript()],
@@ -1786,7 +1751,7 @@ var require_workletStringCode = __commonJS({
1786
1751
  }
1787
1752
  function getClosurePlugin(closureVariables) {
1788
1753
  const closureDeclaration = (0, types_12.variableDeclaration)("const", [
1789
- (0, types_12.variableDeclarator)((0, types_12.objectPattern)(closureVariables.map((variable) => (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.identifier)(variable.name), false, true))), (0, types_12.memberExpression)((0, types_12.thisExpression)(), (0, types_12.identifier)("__closure")))
1754
+ (0, types_12.variableDeclarator)((0, types_12.arrayPattern)(closureVariables.map((variable) => (0, types_12.identifier)(variable.name))), (0, types_12.memberExpression)((0, types_12.thisExpression)(), (0, types_12.identifier)("__closure")))
1790
1755
  ]);
1791
1756
  return {
1792
1757
  visitor: {
@@ -1852,7 +1817,14 @@ var require_workletFactory = __commonJS({
1852
1817
  };
1853
1818
  const clone = (0, types_12.cloneNode)(fun.node);
1854
1819
  const funExpression = (0, types_12.isBlockStatement)(clone.body) ? (0, types_12.functionExpression)(null, clone.params, clone.body, clone.generator, clone.async) : clone;
1855
- const { workletName, reactName } = makeWorkletName(fun, state);
1820
+ const { workletName, reactName: initialReactName } = makeWorkletName(fun, state);
1821
+ let reactName = initialReactName;
1822
+ if (state.opts.bundleMode && closureVariables.length === 0) {
1823
+ const importedNames = new Set([...moduleBindingsToImport, ...relativeBindingsToImport].map((binding) => binding.identifier.name));
1824
+ while (importedNames.has(reactName)) {
1825
+ reactName = `_${reactName}`;
1826
+ }
1827
+ }
1856
1828
  let mutatedClosureVariables;
1857
1829
  if (state.opts.bundleMode) {
1858
1830
  mutatedClosureVariables = closureVariables.map((variable) => (0, types_12.cloneNode)(variable, true));
@@ -1910,7 +1882,9 @@ var require_workletFactory = __commonJS({
1910
1882
  (0, types_12.variableDeclaration)("const", [
1911
1883
  (0, types_12.variableDeclarator)((0, types_12.identifier)(reactName), funExpression)
1912
1884
  ]),
1913
- (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(closureVariables.map((variable) => !state.opts.bundleMode && variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.cloneNode)(variable, true), (0, types_12.cloneNode)(variable, true), false, true))))),
1885
+ ...closureVariables.length > 0 ? [
1886
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.arrayExpression)(closureVariables.map((variable) => !state.opts.bundleMode && variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name)) : (0, types_12.cloneNode)(variable, true)))))
1887
+ ] : [],
1914
1888
  (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
1915
1889
  ];
1916
1890
  const shouldInjectVersion = !(0, utils_1.isRelease)(state);
@@ -1942,10 +1916,9 @@ var require_workletFactory = __commonJS({
1942
1916
  if (shouldIncludeInitData) {
1943
1917
  factoryParams.unshift((0, types_12.cloneNode)(initDataId, true));
1944
1918
  }
1945
- const factoryParamObjectPattern = (0, types_12.objectPattern)(factoryParams.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
1946
- const factory = (0, types_12.functionExpression)((0, types_12.identifier)(workletName + "Factory"), [factoryParamObjectPattern], (0, types_12.blockStatement)(statements));
1919
+ const factory = (0, types_12.functionExpression)((0, types_12.identifier)(workletName + "Factory"), factoryParams.length > 0 ? [(0, types_12.arrayPattern)(factoryParams.map((param) => (0, types_12.cloneNode)(param, true)))] : [], (0, types_12.blockStatement)(statements));
1947
1920
  const factoryCallArgs = factoryParams.map((param) => (0, types_12.cloneNode)(param, true));
1948
- const factoryCallParamPack = (0, types_12.objectExpression)(factoryCallArgs.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
1921
+ const factoryCallParamPack = (0, types_12.arrayExpression)(factoryCallArgs);
1949
1922
  if (state.opts.bundleMode) {
1950
1923
  (0, imports_1.updateRelativeRequires)(factory, state);
1951
1924
  (0, generate_1.generateWorkletFile)(moduleBindingsToImport, relativeBindingsToImport, factory, workletHash, state);
@@ -2043,11 +2016,16 @@ var require_workletFactoryCall = __commonJS({
2043
2016
  const { factory, factoryCallParamPack, workletHash } = (0, workletFactory_1.makeWorkletFactory)(path, state);
2044
2017
  let factoryCall;
2045
2018
  if (state.opts.bundleMode) {
2046
- factoryCall = (0, types_12.callExpression)((0, types_12.memberExpression)((0, types_12.callExpression)((0, types_12.identifier)("require"), [
2019
+ const workletModule = (0, types_12.memberExpression)((0, types_12.callExpression)((0, types_12.identifier)("require"), [
2047
2020
  (0, types_12.stringLiteral)(`react-native-worklets/${types_2.generatedWorkletsDir}/${workletHash}.js`)
2048
- ]), (0, types_12.identifier)("default")), [factoryCallParamPack]);
2021
+ ]), (0, types_12.identifier)("default"));
2022
+ if (factoryCallParamPack.elements.length === 0) {
2023
+ workletModule.loc = path.node.loc;
2024
+ return workletModule;
2025
+ }
2026
+ factoryCall = (0, types_12.callExpression)(workletModule, [factoryCallParamPack]);
2049
2027
  } else {
2050
- factoryCall = (0, types_12.callExpression)(factory, [factoryCallParamPack]);
2028
+ factoryCall = (0, types_12.callExpression)(factory, factoryCallParamPack.elements.length > 0 ? [factoryCallParamPack] : []);
2051
2029
  }
2052
2030
  addStackTraceDataToWorkletFactory(path, factoryCall);
2053
2031
  const replacement = factoryCall;
@@ -2126,7 +2104,6 @@ var autoworkletization_1 = require_autoworkletization();
2126
2104
  var bundleMode_1 = require_bundleMode();
2127
2105
  var class_1 = require_class();
2128
2106
  var classMethod_1 = require_classMethod();
2129
- var contextObject_1 = require_contextObject();
2130
2107
  var directives_1 = require_directives();
2131
2108
  var file_1 = require_file();
2132
2109
  var globals_1 = require_globals();
@@ -2173,13 +2150,6 @@ module.exports = function WorkletsBabelPlugin() {
2173
2150
  });
2174
2151
  }
2175
2152
  },
2176
- ObjectExpression: {
2177
- enter(path, state) {
2178
- runWithTaggedExceptions(state, () => {
2179
- (0, contextObject_1.processIfWorkletContextObject)(path, state);
2180
- });
2181
- }
2182
- },
2183
2153
  ClassDeclaration: {
2184
2154
  enter(path, state) {
2185
2155
  runWithTaggedExceptions(state, () => {
@@ -0,0 +1,7 @@
1
+ import type * as babel from '@babel/core';
2
+
3
+ declare function workletsPluginOxcBabelShim(
4
+ babelApi: typeof babel
5
+ ): babel.PluginObj;
6
+
7
+ export = workletsPluginOxcBabelShim;
@@ -0,0 +1,200 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ const oxc = require('./index.js');
6
+
7
+ // Previous steps can pass their output sourcemap
8
+ // it needs to be merged with this plugin's one
9
+ // to preserve correct mappings
10
+ const remapping = require('@jridgewell/remapping');
11
+
12
+ const PARSE_ERROR_CODE = 'WORKLETS_ERR_PARSE';
13
+ const FLOW_ERROR_CODE = 'WORKLETS_ERR_FLOW';
14
+
15
+ let warnedAboutIgnoredOptions = false;
16
+ let cachedWorkletsPkgDir;
17
+ let cachedSyntaxJsx;
18
+ let cachedSyntaxTypescript;
19
+
20
+ /**
21
+ * @param {typeof import('@babel/core')} babelApi
22
+ * @returns {import('@babel/core').PluginObj}
23
+ */
24
+ function workletsPluginOxcBabelShim(babelApi) {
25
+ return {
26
+ name: 'worklets-oxc-plugin',
27
+ visitor: {
28
+ Program: {
29
+ enter(programPath, state) {
30
+ if (state.file.__workletsOxcRan) {
31
+ return;
32
+ }
33
+ state.file.__workletsOxcRan = true;
34
+
35
+ const filename = state.filename;
36
+ if (filename == null) {
37
+ throw new Error(
38
+ '[Worklets] the OXC transform needs a filename to name worklets ' +
39
+ 'and to place their generated files, but Babel was given none.'
40
+ );
41
+ }
42
+
43
+ const result = transform(state.file.code, filename, state);
44
+ if (!result.changed) {
45
+ return;
46
+ }
47
+
48
+ adoptSourceMap(result, state);
49
+ programPath.replaceWith(
50
+ reparse(babelApi, result.code, filename, state)
51
+ );
52
+ },
53
+ },
54
+ },
55
+ };
56
+ }
57
+
58
+ /**
59
+ * @param {string} sourceText
60
+ * @param {string} filename
61
+ * @param {import('@babel/core').PluginPass} state
62
+ * @returns {import('./index').TransformResult}
63
+ */
64
+ function transform(sourceText, filename, state) {
65
+ warnAboutIgnoredOptions(state.opts);
66
+ try {
67
+ return oxc.transform(sourceText, filename, {
68
+ ...state.opts,
69
+ envName: state.file.opts.envName,
70
+ workletsPackageDir: resolveWorkletsPkgDir(),
71
+ });
72
+ } catch (error) {
73
+ const message = (error && error.message) || '';
74
+ if (message.includes(FLOW_ERROR_CODE)) {
75
+ return { code: sourceText, files: [], changed: false };
76
+ }
77
+ if (message.includes(PARSE_ERROR_CODE)) {
78
+ throw new Error(
79
+ `[Worklets] ${filename} could not be parsed, so no worklets in it ` +
80
+ `were compiled.\n${message}`
81
+ );
82
+ }
83
+ throw error;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * @param {import('./index').PluginOptions} options
89
+ * @returns {void}
90
+ */
91
+ function warnAboutIgnoredOptions(options) {
92
+ if (warnedAboutIgnoredOptions) {
93
+ return;
94
+ }
95
+ const hasExtras =
96
+ (options?.extraPlugins?.length ?? 0) > 0 ||
97
+ (options?.extraPresets?.length ?? 0) > 0;
98
+ if (!hasExtras) {
99
+ return;
100
+ }
101
+ warnedAboutIgnoredOptions = true;
102
+ console.warn(
103
+ '[Worklets] `extraPlugins`/`extraPresets` are accepted for option-surface ' +
104
+ 'compatibility with `react-native-worklets/plugin` but ignored — the OXC transform ' +
105
+ 'cannot dispatch arbitrary Babel plugins. Compose them around this plugin in ' +
106
+ 'babel.config.js instead.'
107
+ );
108
+ }
109
+
110
+ /** @returns {string} */
111
+ function resolveWorkletsPkgDir() {
112
+ if (cachedWorkletsPkgDir === undefined) {
113
+ try {
114
+ cachedWorkletsPkgDir = path.dirname(
115
+ require.resolve('react-native-worklets/package.json')
116
+ );
117
+ } catch (error) {
118
+ throw new Error(
119
+ "[Worklets] couldn't find the react-native-worklets package on disk, " +
120
+ 'so the generated worklet files have nowhere to go. ' +
121
+ `Make sure it's installed. Cause: ${error.message}`
122
+ );
123
+ }
124
+ }
125
+ return cachedWorkletsPkgDir;
126
+ }
127
+
128
+ /**
129
+ * @param {import('./index').TransformResult} result
130
+ * @param {import('@babel/core').PluginPass} state
131
+ * @returns {void}
132
+ */
133
+ function adoptSourceMap(result, state) {
134
+ if (!result.map) {
135
+ return;
136
+ }
137
+ const map = JSON.parse(result.map);
138
+ const sourceFileName = state.file.opts.generatorOpts?.sourceFileName;
139
+ if (sourceFileName) {
140
+ map.sources = [sourceFileName];
141
+ }
142
+ const previous = state.file.inputMap;
143
+ if (previous) {
144
+ const previousMap = previous.toObject();
145
+ const composed = remapping([map, previousMap], () => null, true);
146
+ state.file.inputMap = { toObject: () => composed };
147
+ return;
148
+ }
149
+ state.file.inputMap = { toObject: () => map };
150
+ }
151
+
152
+ /**
153
+ * @param {typeof import('@babel/core')} babelApi
154
+ * @param {string} code
155
+ * @param {string} filename
156
+ * @param {import('@babel/core').PluginPass} state
157
+ * @returns {import('@babel/types').Program}
158
+ */
159
+ function reparse(babelApi, code, filename, state) {
160
+ const parse = (babelApi && babelApi.parse) || require('@babel/core').parse;
161
+ const parserOpts = state.file.opts.parserOpts ?? {};
162
+ const ast = parse(code, {
163
+ sourceType:
164
+ parserOpts.sourceType ?? state.file.opts.sourceType ?? 'unambiguous',
165
+ parserOpts: { ...parserOpts },
166
+ babelrc: false,
167
+ configFile: false,
168
+ plugins: reparseSyntaxPlugins(filename),
169
+ });
170
+ return ast.program;
171
+ }
172
+
173
+ /**
174
+ * @param {string} filename
175
+ * @returns {import('@babel/core').PluginItem[]}
176
+ */
177
+ function reparseSyntaxPlugins(filename) {
178
+ if (filename.endsWith('.tsx')) {
179
+ return [[syntaxTypescript(), { isTSX: true }]];
180
+ }
181
+ if (/\.(ts|mts|cts)$/.test(filename)) {
182
+ return [[syntaxTypescript(), { isTSX: false }]];
183
+ }
184
+ return [[syntaxJsx()]];
185
+ }
186
+
187
+ /** @returns {string} */
188
+ function syntaxTypescript() {
189
+ cachedSyntaxTypescript ??= require.resolve('@babel/plugin-syntax-typescript');
190
+ return cachedSyntaxTypescript;
191
+ }
192
+
193
+ /** @returns {string} */
194
+ function syntaxJsx() {
195
+ cachedSyntaxJsx ??= require.resolve('@babel/plugin-syntax-jsx');
196
+ return cachedSyntaxJsx;
197
+ }
198
+
199
+ module.exports = workletsPluginOxcBabelShim;
200
+ module.exports.default = workletsPluginOxcBabelShim;
@@ -0,0 +1,33 @@
1
+ export interface PluginOptions {
2
+ extraPlugins?: string[];
3
+ extraPresets?: string[];
4
+ importForwarding?: {
5
+ moduleNames?: string[];
6
+ relativePaths?: string[];
7
+ };
8
+ }
9
+
10
+ export interface TransformOptions extends PluginOptions {
11
+ envName?: string;
12
+ pluginVersion?: string;
13
+ workletsPackageDir?: string;
14
+ }
15
+
16
+ export interface EmittedFile {
17
+ path: string;
18
+ content: string;
19
+ }
20
+
21
+ export interface TransformResult {
22
+ code: string;
23
+ map?: string;
24
+ files: EmittedFile[];
25
+ /** Whether the transform rewrote anything; if not, the input AST still stands. */
26
+ changed: boolean;
27
+ }
28
+
29
+ export function transform(
30
+ sourceText: string,
31
+ filename: string,
32
+ options?: TransformOptions
33
+ ): TransformResult;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const { existsSync } = require('fs');
4
+ const { join } = require('path');
5
+
6
+ const platform = process.platform;
7
+ const arch = process.arch;
8
+
9
+ function candidates() {
10
+ return [
11
+ join(__dirname, `worklets-oxc-plugin.${platform}-${arch}.node`),
12
+ join(__dirname, 'worklets-oxc-plugin.node'),
13
+ ];
14
+ }
15
+
16
+ let binding = null;
17
+ let lastError = null;
18
+ for (const p of candidates()) {
19
+ if (existsSync(p)) {
20
+ try {
21
+ binding = require(p);
22
+ break;
23
+ } catch (e) {
24
+ lastError = e;
25
+ }
26
+ }
27
+ }
28
+
29
+ if (!binding) {
30
+ throw new Error(
31
+ `[Worklets] Could not load native binding. Run \`yarn build\` (or \`cargo build --release\`) in ${__dirname}. Last error: ${lastError && lastError.message}`
32
+ );
33
+ }
34
+
35
+ module.exports = binding;
36
+ module.exports.default = binding;
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ spm: {
3
+ name: 'RNWorklets',
4
+ },
5
+ };
@@ -12,7 +12,6 @@ module WorkletsUtils
12
12
  def find_config()
13
13
  result = {
14
14
  :feature_flags_flag => nil,
15
- :fetch_preview_flag => nil,
16
15
  :is_reanimated_example_app => nil,
17
16
  :react_native_version => nil,
18
17
  :react_native_dir => nil,
@@ -43,7 +42,6 @@ module WorkletsUtils
43
42
 
44
43
  feature_flags = get_static_feature_flags()
45
44
  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
45
 
48
46
  return result
49
47
  end
@@ -55,14 +53,6 @@ module WorkletsUtils
55
53
  end
56
54
  end
57
55
 
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
56
  def get_static_feature_flags()
67
57
  feature_flags = {}
68
58