@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
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const LEGACY_CODES = {
4
+ IndexSizeError: 1,
5
+ HierarchyRequestError: 3,
6
+ WrongDocumentError: 4,
7
+ InvalidCharacterError: 5,
8
+ NoModificationAllowedError: 7,
9
+ NotFoundError: 8,
10
+ NotSupportedError: 9,
11
+ InUseAttributeError: 10,
12
+ InvalidStateError: 11,
13
+ SyntaxError: 12,
14
+ InvalidModificationError: 13,
15
+ NamespaceError: 14,
16
+ InvalidAccessError: 15,
17
+ TypeMismatchError: 17,
18
+ SecurityError: 18,
19
+ NetworkError: 19,
20
+ AbortError: 20,
21
+ URLMismatchError: 21,
22
+ QuotaExceededError: 22,
23
+ TimeoutError: 23,
24
+ InvalidNodeTypeError: 24,
25
+ DataCloneError: 25
26
+ };
27
+ export class DOMException extends Error {
28
+ constructor(message = '', name = 'Error') {
29
+ super(message);
30
+ Object.setPrototypeOf(this, DOMException.prototype);
31
+ this.name = name;
32
+ this.code = LEGACY_CODES[name] ?? 0;
33
+ }
34
+ }
35
+ //# sourceMappingURL=DOMException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LEGACY_CODES","IndexSizeError","HierarchyRequestError","WrongDocumentError","InvalidCharacterError","NoModificationAllowedError","NotFoundError","NotSupportedError","InUseAttributeError","InvalidStateError","SyntaxError","InvalidModificationError","NamespaceError","InvalidAccessError","TypeMismatchError","SecurityError","NetworkError","AbortError","URLMismatchError","QuotaExceededError","TimeoutError","InvalidNodeTypeError","DataCloneError","DOMException","Error","constructor","message","name","Object","setPrototypeOf","prototype","code"],"sourceRoot":"../../../src","sources":["networking/DOMException.ts"],"mappings":"AAAA,YAAY;;AAEZ,MAAMA,YAAoC,GAAG;EAC3CC,cAAc,EAAE,CAAC;EACjBC,qBAAqB,EAAE,CAAC;EACxBC,kBAAkB,EAAE,CAAC;EACrBC,qBAAqB,EAAE,CAAC;EACxBC,0BAA0B,EAAE,CAAC;EAC7BC,aAAa,EAAE,CAAC;EAChBC,iBAAiB,EAAE,CAAC;EACpBC,mBAAmB,EAAE,EAAE;EACvBC,iBAAiB,EAAE,EAAE;EACrBC,WAAW,EAAE,EAAE;EACfC,wBAAwB,EAAE,EAAE;EAC5BC,cAAc,EAAE,EAAE;EAClBC,kBAAkB,EAAE,EAAE;EACtBC,iBAAiB,EAAE,EAAE;EACrBC,aAAa,EAAE,EAAE;EACjBC,YAAY,EAAE,EAAE;EAChBC,UAAU,EAAE,EAAE;EACdC,gBAAgB,EAAE,EAAE;EACpBC,kBAAkB,EAAE,EAAE;EACtBC,YAAY,EAAE,EAAE;EAChBC,oBAAoB,EAAE,EAAE;EACxBC,cAAc,EAAE;AAClB,CAAC;AAED,OAAO,MAAMC,YAAY,SAASC,KAAK,CAAC;EAGtCC,WAAWA,CAACC,OAAO,GAAG,EAAE,EAAEC,IAAI,GAAG,OAAO,EAAE;IACxC,KAAK,CAACD,OAAO,CAAC;IACdE,MAAM,CAACC,cAAc,CAAC,IAAI,EAAEN,YAAY,CAACO,SAAS,CAAC;IACnD,IAAI,CAACH,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACI,IAAI,GAAG/B,YAAY,CAAC2B,IAAI,CAAC,IAAI,CAAC;EACrC;AACF","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ import { toArrayBuffer } from "./bytes.js";
4
+ import { utf8Decode } from "./utf8.js";
5
+ const EMPTY = 0;
6
+ const LOADING = 1;
7
+ const DONE = 2;
8
+ const CHARSET_PARAMETER_PATTERN = /;\s*charset\s*=\s*("([^"]*)"|([^;\s]*))/i;
9
+ export class FileReader {
10
+ static EMPTY = EMPTY;
11
+ static LOADING = LOADING;
12
+ static DONE = DONE;
13
+ EMPTY = EMPTY;
14
+ LOADING = LOADING;
15
+ DONE = DONE;
16
+ readyState = EMPTY;
17
+ result = null;
18
+ error = null;
19
+ onload = null;
20
+ onerror = null;
21
+ onloadend = null;
22
+ readAsArrayBuffer(blob) {
23
+ this.read(() => toArrayBuffer(readBytes(blob)));
24
+ }
25
+ readAsText(blob, encoding) {
26
+ this.read(() => {
27
+ const bytes = readBytes(blob);
28
+ const resolvedEncoding = encoding ?? extractCharset(blob.type);
29
+ const networking = globalThis.__workletsNetworking;
30
+ if (networking !== undefined) {
31
+ return networking.decodeText(toArrayBuffer(bytes), resolvedEncoding);
32
+ }
33
+ return utf8Decode(bytes);
34
+ });
35
+ }
36
+ read(produceResult) {
37
+ if (this.readyState === LOADING) {
38
+ throw new Error("[Worklets] Failed to execute 'read' on 'FileReader': the object is already loading.");
39
+ }
40
+ this.result = null;
41
+ this.error = null;
42
+ this.readyState = LOADING;
43
+ /**
44
+ * The File API fires read events from a task, not from a microtask, so
45
+ * `setTimeout` is used here rather than `queueMicrotask`. Reads are started
46
+ * from Promise continuations, which makes the distinction observable.
47
+ */
48
+ setTimeout(() => {
49
+ let failed = false;
50
+ try {
51
+ this.result = produceResult();
52
+ } catch (error) {
53
+ this.error = error;
54
+ failed = true;
55
+ }
56
+ this.readyState = DONE;
57
+ invoke(failed ? this.onerror : this.onload);
58
+ invoke(this.onloadend);
59
+ });
60
+ }
61
+ }
62
+ function invoke(handler) {
63
+ try {
64
+ handler?.();
65
+ } catch (error) {
66
+ console.error(error);
67
+ }
68
+ }
69
+ function readBytes(blob) {
70
+ if (typeof blob?.__getBytes !== 'function') {
71
+ throw new Error('[Worklets] FileReader can only read a Blob created by the Worklets networking module.');
72
+ }
73
+ return blob.__getBytes();
74
+ }
75
+ function extractCharset(mimeType) {
76
+ const match = CHARSET_PARAMETER_PATTERN.exec(mimeType);
77
+ if (match === null) {
78
+ return undefined;
79
+ }
80
+ const charset = match[2] ?? match[3] ?? '';
81
+ return charset !== '' ? charset : undefined;
82
+ }
83
+ //# sourceMappingURL=FileReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toArrayBuffer","utf8Decode","EMPTY","LOADING","DONE","CHARSET_PARAMETER_PATTERN","FileReader","readyState","result","error","onload","onerror","onloadend","readAsArrayBuffer","blob","read","readBytes","readAsText","encoding","bytes","resolvedEncoding","extractCharset","type","networking","globalThis","__workletsNetworking","undefined","decodeText","produceResult","Error","setTimeout","failed","invoke","handler","console","__getBytes","mimeType","match","exec","charset"],"sourceRoot":"../../../src","sources":["networking/FileReader.ts"],"mappings":"AAAA,YAAY;;AAGZ,SAASA,aAAa,QAAQ,YAAS;AACvC,SAASC,UAAU,QAAQ,WAAQ;AAEnC,MAAMC,KAAK,GAAG,CAAC;AACf,MAAMC,OAAO,GAAG,CAAC;AACjB,MAAMC,IAAI,GAAG,CAAC;AAEd,MAAMC,yBAAyB,GAAG,0CAA0C;AAE5E,OAAO,MAAMC,UAAU,CAAC;EACtB,OAAgBJ,KAAK,GAAGA,KAAK;EAC7B,OAAgBC,OAAO,GAAGA,OAAO;EACjC,OAAgBC,IAAI,GAAGA,IAAI;EAElBF,KAAK,GAAGA,KAAK;EACbC,OAAO,GAAGA,OAAO;EACjBC,IAAI,GAAGA,IAAI;EAEpBG,UAAU,GAAGL,KAAK;EAClBM,MAAM,GAAgC,IAAI;EAC1CC,KAAK,GAAY,IAAI;EAErBC,MAAM,GAAwB,IAAI;EAClCC,OAAO,GAAwB,IAAI;EACnCC,SAAS,GAAwB,IAAI;EAErCC,iBAAiBA,CA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IACxB,CAAC,CAAC;EACJ;AACF;AAEA,SAASoB,MAAMA,CAACC,OAA4B,EAAE;EAC5C,IAAI;IACFA,OAAO,GAAG,CAAC;EACb,CAAC,CAAC,OAAOxB,KAAK,EAAE;IACdyB,OAAO,CAACzB,KAAK,CAACA,KAAK,CAAC;EACtB;AACF;AAEA,SAASO,SAASA,CAACF,IAAU,EAAc;EACzC,IAAI,OAAOA,IAAI,EAAEqB,UAAU,KAAK,UAAU,EAAE;IAC1C,MAAM,IAAIN,KAAK,CACb,uFACF,CAAC;EACH;EACA,OAAOf,IAAI,CAACqB,UAAU,CAAC,CAAC;AAC1B;AAEA,SAASd,cAAcA,CAACe,QAAgB,EAAsB;EAC5D,MAAMC,KAAK,GAAGhC,yBAAyB,CAACiC,IAAI,CAACF,QAAQ,CAAC;EACtD,IAAIC,KAAK,KAAK,IAAI,EAAE;IAClB,OAAOX,SAAS;EAClB;EACA,MAAMa,OAAO,GAAGF,KAAK,CAAC,CAAC,CAAC,IAAIA,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;EAC1C,OAAOE,OAAO,KAAK,EAAE,GAAGA,OAAO,GAAGb,SAAS;AAC7C","ignoreList":[]}
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ import { toArrayBuffer } from "./bytes.js";
4
+ import { utf8Encode } from "./utf8.js";
5
+ export class FormData {
6
+ formEntries = [];
7
+ get [Symbol.toStringTag]() {
8
+ return 'FormData';
9
+ }
10
+ append(name, value) {
11
+ if (value !== null && typeof value === 'object') {
12
+ throw new TypeError("[Worklets] Failed to execute 'append' on 'FormData': only string values are supported.");
13
+ }
14
+ this.formEntries.push([String(name), String(value)]);
15
+ }
16
+ set(name, value) {
17
+ this.delete(name);
18
+ this.append(name, value);
19
+ }
20
+ get(name) {
21
+ const entry = this.formEntries.find(([entryName]) => entryName === String(name));
22
+ return entry !== undefined ? entry[1] : null;
23
+ }
24
+ getAll(name) {
25
+ return this.formEntries.filter(([entryName]) => entryName === String(name)).map(([, value]) => value);
26
+ }
27
+ has(name) {
28
+ return this.formEntries.some(([entryName]) => entryName === String(name));
29
+ }
30
+ delete(name) {
31
+ this.formEntries = this.formEntries.filter(([entryName]) => entryName !== String(name));
32
+ }
33
+ forEach(callback) {
34
+ for (const [name, value] of this.formEntries) {
35
+ callback(value, name, this);
36
+ }
37
+ }
38
+ *entries() {
39
+ for (const [name, value] of this.formEntries) {
40
+ yield [name, value];
41
+ }
42
+ }
43
+ *keys() {
44
+ for (const [name] of this.formEntries) {
45
+ yield name;
46
+ }
47
+ }
48
+ *values() {
49
+ for (const [, value] of this.formEntries) {
50
+ yield value;
51
+ }
52
+ }
53
+ [Symbol.iterator]() {
54
+ return this.entries();
55
+ }
56
+
57
+ /**
58
+ * Mirrors React Native's non-standard `FormData.getParts`. Its presence makes
59
+ * libraries like Axios treat this object as a React Native `FormData` and
60
+ * leave the multipart encoding to `XMLHttpRequest`.
61
+ */
62
+ getParts() {
63
+ return this.formEntries.map(([name, value]) => ({
64
+ string: value,
65
+ fieldName: name,
66
+ headers: {
67
+ 'content-disposition': `form-data; name="${escapeName(name)}"`
68
+ }
69
+ }));
70
+ }
71
+ __encodeMultipart() {
72
+ const parts = this.formEntries.map(([name, value]) => `content-disposition: form-data; name="${escapeName(name)}"\r\n\r\n${value}`);
73
+ const boundary = pickBoundary(parts);
74
+ let encoded = '';
75
+ for (const part of parts) {
76
+ encoded += `--${boundary}\r\n${part}\r\n`;
77
+ }
78
+ encoded += `--${boundary}--\r\n`;
79
+ return {
80
+ body: toArrayBuffer(utf8Encode(encoded)),
81
+ contentType: `multipart/form-data; boundary=${boundary}`
82
+ };
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Picks a boundary that appears in none of the parts. Entry values are written
88
+ * verbatim, so a value that contained the boundary could otherwise inject
89
+ * arbitrary parts into the request.
90
+ */
91
+ function pickBoundary(parts) {
92
+ for (;;) {
93
+ const boundary = `----WorkletsFormDataBoundary${randomToken()}${randomToken()}`;
94
+ if (!parts.some(part => part.includes(boundary))) {
95
+ return boundary;
96
+ }
97
+ }
98
+ }
99
+ function randomToken() {
100
+ return Math.random().toString(36).slice(2).padEnd(11, '0');
101
+ }
102
+ function escapeName(name) {
103
+ return name.replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/"/g, '%22');
104
+ }
105
+ //# sourceMappingURL=FormData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toArrayBuffer","utf8Encode","FormData","formEntries","Symbol","toStringTag","append","name","value","TypeError","push","String","set","delete","get","entry","find","entryName","undefined","getAll","filter","map","has","some","forEach","callback","entries","keys","values","iterator","getParts","string","fieldName","headers","escapeName","__encodeMultipart","parts","boundary","pickBoundary","encoded","part","body","contentType","randomToken","includes","Math","random","toString","slice","padEnd","replace"],"sourceRoot":"../../../src","sources":["networking/FormData.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,aAAa,QAAQ,YAAS;AACvC,SAASC,UAAU,QAAQ,WAAQ;AAEnC,OAAO,MAAMC,QAAQ,CAAC;EACZC,WAAW,GAA4B,EAAE;EAEjD,KAAKC,MAAM,CAACC,WAAW,IAAI;IACzB,OAAO,UAAU;EACnB;EAEAC,MAAMA,CAACC,IAAY,EAAEC,KAAc,EAAE;IACnC,IAAIA,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC/C,MAAM,IAAIC,SAAS,CACjB,wFACF,CAAC;IACH;IACA,IAAI,CAACN,WAAW,CAACO,IAAI,CAAC,CAACC,MAAM,CAACJ,IAAI,CAAC,EAAEI,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC;EACtD;EAEAI,GAAGA,CAACL,IAAY,EAAEC,KAAc,EAAE;IAChC,IAAI,CAACK,MAAM,CAACN,IAAI,CAAC;IACjB,IAAI,CAACD,MAAM,CAACC,IAAI,EAAEC,KAAK,CAAC;EAC1B;EAEAM,GAAGA,CAACP,IAAY,EAAiB;IAC/B,MAAMQ,KAAK,GAAG,IAAI,CAACZ,WAA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AAW,CAAC,CAAC,GAAGA,WAAW,CAAC,CAAC,EAAE;IAC/E,IAAI,CAACP,KAAK,CAACb,IAAI,CAAEiB,IAAI,IAAKA,IAAI,CAACI,QAAQ,CAACP,QAAQ,CAAC,CAAC,EAAE;MAClD,OAAOA,QAAQ;IACjB;EACF;AACF;AAEA,SAASM,WAAWA,CAAA,EAAW;EAC7B,OAAOE,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;AAC5D;AAEA,SAASf,UAAUA,CAAC3B,IAAY,EAAU;EACxC,OAAOA,IAAI,CAAC2C,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;AAC9E","ignoreList":[]}
@@ -0,0 +1,450 @@
1
+ 'use strict';
2
+
3
+ import { Blob } from "./Blob.js";
4
+ import { toArrayBuffer } from "./bytes.js";
5
+ import { DOMException } from "./DOMException.js";
6
+ import { EventTargetLite } from "./events.js";
7
+ import { FormData } from "./FormData.js";
8
+ import { combineHeader, extractCharset, getHeader, hasHeader, isForbiddenMethod, isForbiddenRequestHeader, isHeaderName, isHeaderValue, isSupportedRequestUrl, isToken, normalizeHeaderValue, normalizeMethod, sortAndCombineHeaders } from "./http.js";
9
+ import { stripUtf8Bom, utf8Decode, utf8Encode } from "./utf8.js";
10
+ const UNSENT = 0;
11
+ const OPENED = 1;
12
+ const HEADERS_RECEIVED = 2;
13
+ const LOADING = 3;
14
+ const DONE = 4;
15
+ const RESPONSE_TYPES = ['', 'text', 'arraybuffer', 'blob', 'json'];
16
+ class XMLHttpRequestUpload extends EventTargetLite {}
17
+ export class XMLHttpRequest extends EventTargetLite {
18
+ static UNSENT = UNSENT;
19
+ static OPENED = OPENED;
20
+ static HEADERS_RECEIVED = HEADERS_RECEIVED;
21
+ static LOADING = LOADING;
22
+ static DONE = DONE;
23
+ UNSENT = UNSENT;
24
+ OPENED = OPENED;
25
+ HEADERS_RECEIVED = HEADERS_RECEIVED;
26
+ LOADING = LOADING;
27
+ DONE = DONE;
28
+ readyState = UNSENT;
29
+ status = 0;
30
+ statusText = '';
31
+ responseURL = '';
32
+ timeout = 0;
33
+ /**
34
+ * The specification defaults this to `false`. React Native's own
35
+ * `XMLHttpRequest` defaults it to `true`, and Worklet Runtimes share the
36
+ * app's cookie storage, so the parity is deliberate.
37
+ */
38
+ withCredentials = true;
39
+ upload = new XMLHttpRequestUpload();
40
+ onreadystatechange = null;
41
+ onloadstart = null;
42
+ onprogress = null;
43
+ onload = null;
44
+ onloadend = null;
45
+ onerror = null;
46
+ ontimeout = null;
47
+ onabort = null;
48
+ requestId = null;
49
+ requestToken = 0;
50
+ method = 'GET';
51
+ url = '';
52
+ sent = false;
53
+ hasRequestBody = false;
54
+ requestBodyLength = 0;
55
+ uploadSettled = false;
56
+ downloadedBytes = 0;
57
+ mimeTypeOverride = null;
58
+ requestHeaders = [];
59
+ responseHeaders = [];
60
+ responseTypeValue = '';
61
+ responseBytes = null;
62
+ responseBlobValue = null;
63
+ responseTextValue = null;
64
+ responseJsonValue = undefined;
65
+ get responseType() {
66
+ return this.responseTypeValue;
67
+ }
68
+ set responseType(value) {
69
+ if (this.readyState >= LOADING) {
70
+ throw new DOMException("[Worklets] Failed to set 'responseType' on 'XMLHttpRequest': the response type cannot be changed once loading has started.", 'InvalidStateError');
71
+ }
72
+ if (!RESPONSE_TYPES.includes(value)) {
73
+ return;
74
+ }
75
+ this.responseTypeValue = value;
76
+ }
77
+ get response() {
78
+ switch (this.responseTypeValue) {
79
+ case '':
80
+ case 'text':
81
+ return this.readyState >= LOADING ? this.getResponseText() : '';
82
+ case 'arraybuffer':
83
+ return this.readyState === DONE ? this.responseBytes : null;
84
+ case 'blob':
85
+ if (this.readyState !== DONE || this.responseBytes === null) {
86
+ return null;
87
+ }
88
+ if (this.responseBlobValue === null) {
89
+ this.responseBlobValue = new Blob([this.responseBytes], {
90
+ type: this.mimeTypeOverride ?? this.getResponseHeader('content-type') ?? ''
91
+ });
92
+ }
93
+ return this.responseBlobValue;
94
+ case 'json':
95
+ if (this.readyState !== DONE) {
96
+ return null;
97
+ }
98
+ if (this.responseJsonValue === undefined) {
99
+ try {
100
+ this.responseJsonValue = JSON.parse(this.responseBytes === null ? '' : utf8Decode(stripUtf8Bom(new Uint8Array(this.responseBytes))));
101
+ } catch {
102
+ this.responseJsonValue = null;
103
+ }
104
+ }
105
+ return this.responseJsonValue;
106
+ default:
107
+ return null;
108
+ }
109
+ }
110
+ get responseText() {
111
+ if (this.responseTypeValue !== '' && this.responseTypeValue !== 'text') {
112
+ throw new DOMException("[Worklets] Failed to read 'responseText' on 'XMLHttpRequest': the value is only accessible if the object's 'responseType' is '' or 'text'.", 'InvalidStateError');
113
+ }
114
+ return this.readyState >= LOADING ? this.getResponseText() : '';
115
+ }
116
+ open(method, url, async = true) {
117
+ const methodValue = String(method);
118
+ const urlValue = String(url);
119
+ if (!isToken(methodValue)) {
120
+ throw new DOMException(`[Worklets] Failed to execute 'open' on 'XMLHttpRequest': '${methodValue}' is not a valid HTTP method.`, 'SyntaxError');
121
+ }
122
+ if (isForbiddenMethod(methodValue)) {
123
+ throw new DOMException(`[Worklets] Failed to execute 'open' on 'XMLHttpRequest': '${methodValue}' HTTP method is unsupported.`, 'SecurityError');
124
+ }
125
+ if (urlValue === '') {
126
+ throw new DOMException("[Worklets] Failed to execute 'open' on 'XMLHttpRequest': the URL cannot be empty.", 'SyntaxError');
127
+ }
128
+ if (!async) {
129
+ throw new DOMException('[Worklets] Synchronous XMLHttpRequest is not supported.', 'InvalidAccessError');
130
+ }
131
+ this.terminate();
132
+ this.method = normalizeMethod(methodValue);
133
+ this.url = urlValue;
134
+ this.sent = false;
135
+ this.hasRequestBody = false;
136
+ this.requestBodyLength = 0;
137
+ this.uploadSettled = false;
138
+ this.mimeTypeOverride = null;
139
+ this.requestHeaders = [];
140
+ this.resetResponse();
141
+ if (this.readyState !== OPENED) {
142
+ this.setReadyState(OPENED);
143
+ } else {
144
+ this.readyState = OPENED;
145
+ }
146
+ }
147
+ setRequestHeader(name, value) {
148
+ if (this.readyState !== OPENED || this.sent) {
149
+ throw new DOMException("[Worklets] Failed to execute 'setRequestHeader' on 'XMLHttpRequest': the object's state must be OPENED.", 'InvalidStateError');
150
+ }
151
+ const nameValue = String(name);
152
+ const headerValue = normalizeHeaderValue(String(value));
153
+ if (!isHeaderName(nameValue) || !isHeaderValue(headerValue)) {
154
+ throw new DOMException(`[Worklets] Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${nameValue}: ${headerValue}' is not a valid header.`, 'SyntaxError');
155
+ }
156
+ if (isForbiddenRequestHeader(nameValue, headerValue)) {
157
+ return;
158
+ }
159
+ combineHeader(this.requestHeaders, nameValue, headerValue);
160
+ }
161
+ getAllResponseHeaders() {
162
+ return sortAndCombineHeaders(this.responseHeaders);
163
+ }
164
+ getResponseHeader(name) {
165
+ return getHeader(this.responseHeaders, String(name));
166
+ }
167
+ overrideMimeType(mimeType) {
168
+ if (this.readyState >= LOADING) {
169
+ throw new DOMException("[Worklets] Failed to execute 'overrideMimeType' on 'XMLHttpRequest': the MIME type cannot be overridden once loading has started.", 'InvalidStateError');
170
+ }
171
+ this.mimeTypeOverride = String(mimeType);
172
+ this.responseTextValue = null;
173
+ }
174
+ send(body) {
175
+ const networking = globalThis.__workletsNetworking;
176
+ if (networking === undefined) {
177
+ throw new DOMException('[Worklets] XMLHttpRequest is not available on this runtime.', 'InvalidStateError');
178
+ }
179
+ if (this.readyState !== OPENED || this.sent) {
180
+ throw new DOMException("[Worklets] Failed to execute 'send' on 'XMLHttpRequest': the object's state must be OPENED.", 'InvalidStateError');
181
+ }
182
+ this.sent = true;
183
+ if (!isSupportedRequestUrl(this.url)) {
184
+ this.__dispatch('loadstart');
185
+ setTimeout(() => this.handleRequestError('network', `Only http and https URLs are supported, got '${this.url}'.`));
186
+ return;
187
+ }
188
+ const {
189
+ data,
190
+ contentType
191
+ } = this.method === 'GET' || this.method === 'HEAD' ? {
192
+ data: undefined,
193
+ contentType: undefined
194
+ } : normalizeBody(body);
195
+ const headers = [...this.requestHeaders];
196
+ if (contentType !== undefined && !hasHeader(headers, 'content-type')) {
197
+ headers.push(['Content-Type', contentType]);
198
+ }
199
+ this.hasRequestBody = data !== undefined;
200
+ this.requestBodyLength = typeof data === 'string' ? utf8Encode(data).length : data?.byteLength ?? 0;
201
+ const token = ++this.requestToken;
202
+ this.requestId = networking.sendRequest({
203
+ method: this.method,
204
+ url: this.url,
205
+ headers,
206
+ body: data,
207
+ timeoutMs: this.timeout,
208
+ withCredentials: this.withCredentials
209
+ }, (type, payload) => {
210
+ if (token === this.requestToken && this.requestId !== null) {
211
+ this.handleNetworkingEvent(type, payload);
212
+ }
213
+ });
214
+ this.__dispatch('loadstart');
215
+ if (this.hasRequestBody) {
216
+ this.upload.__dispatch('loadstart', {
217
+ loaded: 0,
218
+ total: this.requestBodyLength,
219
+ lengthComputable: this.requestBodyLength > 0
220
+ });
221
+ }
222
+ }
223
+ abort() {
224
+ const wasInFlight = this.terminate();
225
+ if (this.readyState === OPENED && !this.sent) {
226
+ return;
227
+ }
228
+ if (!wasInFlight || this.readyState === UNSENT) {
229
+ this.readyState = UNSENT;
230
+ return;
231
+ }
232
+ if (this.readyState === DONE) {
233
+ this.resetResponse();
234
+ this.readyState = UNSENT;
235
+ return;
236
+ }
237
+ this.resetResponse();
238
+ this.setReadyState(DONE);
239
+ this.settleUploadWithError('abort');
240
+ this.__dispatch('abort');
241
+ this.__dispatch('loadend');
242
+ if (this.readyState === DONE) {
243
+ this.readyState = UNSENT;
244
+ }
245
+ }
246
+ handleNetworkingEvent(type, payload) {
247
+ switch (type) {
248
+ case 'response':
249
+ {
250
+ const {
251
+ status,
252
+ statusText,
253
+ headers,
254
+ url
255
+ } = payload;
256
+ this.status = status;
257
+ this.statusText = statusText;
258
+ this.responseHeaders = headers;
259
+ this.responseURL = url;
260
+ this.settleUploadWithSuccess();
261
+ this.setReadyState(HEADERS_RECEIVED);
262
+ break;
263
+ }
264
+ case 'downloadProgress':
265
+ {
266
+ const {
267
+ loaded,
268
+ total
269
+ } = payload;
270
+ this.downloadedBytes = loaded;
271
+ if (this.readyState === HEADERS_RECEIVED) {
272
+ this.setReadyState(LOADING);
273
+ } else {
274
+ this.__dispatch('readystatechange');
275
+ }
276
+ this.__dispatch('progress', {
277
+ loaded,
278
+ total: total > 0 ? total : 0,
279
+ lengthComputable: total > 0
280
+ });
281
+ break;
282
+ }
283
+ case 'uploadProgress':
284
+ {
285
+ const {
286
+ loaded,
287
+ total
288
+ } = payload;
289
+ this.upload.__dispatch('progress', {
290
+ loaded,
291
+ total: total > 0 ? total : 0,
292
+ lengthComputable: total > 0
293
+ });
294
+ break;
295
+ }
296
+ case 'done':
297
+ {
298
+ this.requestId = null;
299
+ const {
300
+ body,
301
+ error,
302
+ message
303
+ } = payload;
304
+ if (error !== undefined) {
305
+ this.handleRequestError(error, message);
306
+ } else if (this.status === 0) {
307
+ this.handleRequestError('network', 'The request completed without a response.');
308
+ } else {
309
+ this.handleResponseEndOfBody(body);
310
+ }
311
+ break;
312
+ }
313
+ }
314
+ }
315
+ handleRequestError(error, message) {
316
+ const terminalEvent = error === 'timeout' ? 'timeout' : error === 'aborted' ? 'abort' : 'error';
317
+ this.resetResponse();
318
+ this.setReadyState(DONE);
319
+ this.settleUploadWithError(terminalEvent);
320
+ this.__dispatch(terminalEvent, {
321
+ message
322
+ });
323
+ this.__dispatch('loadend');
324
+ }
325
+ handleResponseEndOfBody(body) {
326
+ this.responseBytes = body ?? new ArrayBuffer(0);
327
+ this.responseTextValue = null;
328
+ this.responseBlobValue = null;
329
+ this.responseJsonValue = undefined;
330
+ const transmitted = Math.max(this.responseBytes.byteLength, this.downloadedBytes);
331
+ const rawContentLength = this.getResponseHeader('content-length');
332
+ const contentLength = rawContentLength === null ? Number.NaN : Number(rawContentLength);
333
+ const total = Number.isInteger(contentLength) && contentLength > 0 ? contentLength : 0;
334
+ const progress = {
335
+ loaded: transmitted,
336
+ total,
337
+ lengthComputable: total > 0
338
+ };
339
+ this.settleUploadWithSuccess();
340
+ this.__dispatch('progress', progress);
341
+ this.setReadyState(DONE);
342
+ this.__dispatch('load', progress);
343
+ this.__dispatch('loadend', progress);
344
+ }
345
+ settleUploadWithSuccess() {
346
+ if (!this.hasRequestBody || this.uploadSettled) {
347
+ return;
348
+ }
349
+ this.uploadSettled = true;
350
+ const progress = {
351
+ loaded: this.requestBodyLength,
352
+ total: this.requestBodyLength,
353
+ lengthComputable: this.requestBodyLength > 0
354
+ };
355
+ this.upload.__dispatch('progress', progress);
356
+ this.upload.__dispatch('load', progress);
357
+ this.upload.__dispatch('loadend', progress);
358
+ }
359
+ settleUploadWithError(type) {
360
+ if (!this.hasRequestBody || this.uploadSettled) {
361
+ return;
362
+ }
363
+ this.uploadSettled = true;
364
+ this.upload.__dispatch(type);
365
+ this.upload.__dispatch('loadend');
366
+ }
367
+ getResponseText() {
368
+ if (this.responseTextValue === null) {
369
+ this.responseTextValue = decodeResponseText(this.responseBytes, extractCharset(this.mimeTypeOverride) ?? extractCharset(this.getResponseHeader('content-type')));
370
+ }
371
+ return this.responseTextValue;
372
+ }
373
+ resetResponse() {
374
+ this.status = 0;
375
+ this.statusText = '';
376
+ this.responseURL = '';
377
+ this.downloadedBytes = 0;
378
+ this.responseHeaders = [];
379
+ this.responseBytes = null;
380
+ this.responseTextValue = null;
381
+ this.responseBlobValue = null;
382
+ this.responseJsonValue = undefined;
383
+ }
384
+ terminate() {
385
+ if (this.requestId === null) {
386
+ return this.sent;
387
+ }
388
+ globalThis.__workletsNetworking?.abortRequest(this.requestId);
389
+ this.requestId = null;
390
+ return true;
391
+ }
392
+ setReadyState(readyState) {
393
+ this.readyState = readyState;
394
+ this.__dispatch('readystatechange');
395
+ }
396
+ }
397
+ function decodeResponseText(bytes, charset) {
398
+ if (bytes === null || bytes.byteLength === 0) {
399
+ return '';
400
+ }
401
+ const networking = globalThis.__workletsNetworking;
402
+ if (networking !== undefined) {
403
+ return networking.decodeText(bytes, charset);
404
+ }
405
+ return utf8Decode(new Uint8Array(bytes));
406
+ }
407
+ function isBlobLike(body) {
408
+ return typeof body?.__getBytes === 'function';
409
+ }
410
+ function normalizeBody(body) {
411
+ if (body === null || body === undefined) {
412
+ return {};
413
+ }
414
+ if (typeof body === 'string') {
415
+ return {
416
+ data: body,
417
+ contentType: 'text/plain;charset=UTF-8'
418
+ };
419
+ }
420
+ if (body instanceof ArrayBuffer) {
421
+ return {
422
+ data: body
423
+ };
424
+ }
425
+ if (isBlobLike(body)) {
426
+ return {
427
+ data: toArrayBuffer(body.__getBytes()),
428
+ contentType: body.type !== '' ? body.type : undefined
429
+ };
430
+ }
431
+ if (body instanceof FormData) {
432
+ const {
433
+ body: data,
434
+ contentType
435
+ } = body.__encodeMultipart();
436
+ return {
437
+ data,
438
+ contentType
439
+ };
440
+ }
441
+ if (ArrayBuffer.isView(body)) {
442
+ return {
443
+ data: toArrayBuffer(new Uint8Array(body.buffer, body.byteOffset, body.byteLength))
444
+ };
445
+ }
446
+ return {
447
+ data: String(body)
448
+ };
449
+ }
450
+ //# sourceMappingURL=XMLHttpRequest.js.map