react-native-webgpu 0.5.11

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 (378) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +319 -0
  3. package/android/CMakeLists.txt +108 -0
  4. package/android/build.gradle +138 -0
  5. package/android/cpp/AndroidPlatformContext.h +207 -0
  6. package/android/cpp/cpp-adapter.cpp +71 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/java/com/webgpu/WebGPUAHBView.java +298 -0
  9. package/android/src/main/java/com/webgpu/WebGPUAPI.java +20 -0
  10. package/android/src/main/java/com/webgpu/WebGPUBaseView.java +61 -0
  11. package/android/src/main/java/com/webgpu/WebGPUModule.java +50 -0
  12. package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +41 -0
  13. package/android/src/main/java/com/webgpu/WebGPUSurfaceViewWithSC.java +79 -0
  14. package/android/src/main/java/com/webgpu/WebGPUTextureView.java +46 -0
  15. package/android/src/main/java/com/webgpu/WebGPUView.java +108 -0
  16. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +38 -0
  17. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +50 -0
  18. package/android/src/newarch/com/webgpu/WebGPUViewManagerSpec.java +24 -0
  19. package/apple/ApplePlatformContext.h +31 -0
  20. package/apple/ApplePlatformContext.mm +157 -0
  21. package/apple/MetalView.h +13 -0
  22. package/apple/MetalView.mm +50 -0
  23. package/apple/RNWGUIKit.h +16 -0
  24. package/apple/WebGPUModule.h +13 -0
  25. package/apple/WebGPUModule.mm +89 -0
  26. package/apple/WebGPUView.h +12 -0
  27. package/apple/WebGPUView.mm +66 -0
  28. package/cpp/WGPULogger.h +100 -0
  29. package/cpp/dawn_logging.cpp +119 -0
  30. package/cpp/jsi/EnumMapper.h +45 -0
  31. package/cpp/jsi/JSIConverter.h +473 -0
  32. package/cpp/jsi/NativeObject.h +607 -0
  33. package/cpp/jsi/Promise.cpp +44 -0
  34. package/cpp/jsi/Promise.h +35 -0
  35. package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
  36. package/cpp/jsi/RuntimeAwareCache.h +100 -0
  37. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
  38. package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
  39. package/cpp/rnwgpu/ArrayBuffer.h +73 -0
  40. package/cpp/rnwgpu/PlatformContext.h +46 -0
  41. package/cpp/rnwgpu/RNWebGPUManager.cpp +225 -0
  42. package/cpp/rnwgpu/RNWebGPUManager.h +46 -0
  43. package/cpp/rnwgpu/SurfaceRegistry.h +230 -0
  44. package/cpp/rnwgpu/api/Canvas.h +57 -0
  45. package/cpp/rnwgpu/api/Convertors.h +761 -0
  46. package/cpp/rnwgpu/api/External.h +12 -0
  47. package/cpp/rnwgpu/api/GPU.cpp +127 -0
  48. package/cpp/rnwgpu/api/GPU.h +58 -0
  49. package/cpp/rnwgpu/api/GPUAdapter.cpp +191 -0
  50. package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
  51. package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
  52. package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
  53. package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
  54. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
  55. package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
  56. package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
  57. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +67 -0
  58. package/cpp/rnwgpu/api/GPUCanvasContext.h +66 -0
  59. package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
  60. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
  61. package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
  62. package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
  63. package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
  64. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
  65. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
  66. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
  67. package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
  68. package/cpp/rnwgpu/api/GPUDevice.cpp +492 -0
  69. package/cpp/rnwgpu/api/GPUDevice.h +259 -0
  70. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
  71. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
  72. package/cpp/rnwgpu/api/GPUError.h +35 -0
  73. package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
  74. package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
  75. package/cpp/rnwgpu/api/GPUFeatures.h +203 -0
  76. package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
  77. package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
  78. package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
  79. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
  80. package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
  81. package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
  82. package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
  83. package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
  84. package/cpp/rnwgpu/api/GPUQueue.h +81 -0
  85. package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
  86. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
  87. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
  88. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
  89. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
  90. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
  91. package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
  92. package/cpp/rnwgpu/api/GPUSampler.h +44 -0
  93. package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
  94. package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
  95. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
  96. package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
  97. package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
  98. package/cpp/rnwgpu/api/GPUTexture.h +162 -0
  99. package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
  100. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +71 -0
  101. package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
  102. package/cpp/rnwgpu/api/ImageBitmap.h +40 -0
  103. package/cpp/rnwgpu/api/RNWebGPU.h +199 -0
  104. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +65 -0
  105. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +78 -0
  106. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +57 -0
  107. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +98 -0
  108. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +58 -0
  109. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +53 -0
  110. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +57 -0
  111. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +57 -0
  112. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +60 -0
  113. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
  114. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +76 -0
  115. package/cpp/rnwgpu/api/descriptors/GPUColor.h +67 -0
  116. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +59 -0
  117. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
  118. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +46 -0
  119. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +46 -0
  120. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +57 -0
  121. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +59 -0
  122. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +68 -0
  123. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +104 -0
  124. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +100 -0
  125. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +39 -0
  126. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +80 -0
  127. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +74 -0
  128. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +63 -0
  129. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +63 -0
  130. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +66 -0
  131. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +82 -0
  132. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +55 -0
  133. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
  134. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +55 -0
  135. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +58 -0
  136. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +70 -0
  137. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +62 -0
  138. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +56 -0
  139. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +44 -0
  140. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +46 -0
  141. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +81 -0
  142. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +82 -0
  143. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +102 -0
  144. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +93 -0
  145. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +59 -0
  146. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
  147. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +52 -0
  148. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +46 -0
  149. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +111 -0
  150. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +61 -0
  151. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +63 -0
  152. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
  153. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +65 -0
  154. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +60 -0
  155. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +60 -0
  156. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +92 -0
  157. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
  158. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +92 -0
  159. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +65 -0
  160. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +54 -0
  161. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +63 -0
  162. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +74 -0
  163. package/cpp/rnwgpu/api/descriptors/Unions.h +1969 -0
  164. package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
  165. package/cpp/rnwgpu/async/AsyncRunner.cpp +215 -0
  166. package/cpp/rnwgpu/async/AsyncRunner.h +53 -0
  167. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
  168. package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
  169. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
  170. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
  171. package/cpp/webgpu/webgpu.h +4918 -0
  172. package/cpp/webgpu/webgpu_cpp.h +10294 -0
  173. package/cpp/webgpu/webgpu_cpp_chained_struct.h +57 -0
  174. package/cpp/webgpu/webgpu_cpp_print.h +2755 -0
  175. package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
  176. package/lib/commonjs/Canvas.js +55 -0
  177. package/lib/commonjs/Canvas.js.map +1 -0
  178. package/lib/commonjs/NativeWebGPUModule.js +10 -0
  179. package/lib/commonjs/NativeWebGPUModule.js.map +1 -0
  180. package/lib/commonjs/Offscreen.js +103 -0
  181. package/lib/commonjs/Offscreen.js.map +1 -0
  182. package/lib/commonjs/WebGPUViewNativeComponent.js +10 -0
  183. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
  184. package/lib/commonjs/WebGPUViewNativeComponent.web.js +103 -0
  185. package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -0
  186. package/lib/commonjs/WebPolyfillGPUModule.js +40 -0
  187. package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -0
  188. package/lib/commonjs/external/ModuleProxy.js +36 -0
  189. package/lib/commonjs/external/ModuleProxy.js.map +1 -0
  190. package/lib/commonjs/external/index.js +17 -0
  191. package/lib/commonjs/external/index.js.map +1 -0
  192. package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
  193. package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
  194. package/lib/commonjs/external/reanimated/index.js +21 -0
  195. package/lib/commonjs/external/reanimated/index.js.map +1 -0
  196. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +49 -0
  197. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  198. package/lib/commonjs/hooks.js +83 -0
  199. package/lib/commonjs/hooks.js.map +1 -0
  200. package/lib/commonjs/index.js +17 -0
  201. package/lib/commonjs/index.js.map +1 -0
  202. package/lib/commonjs/main/index.js +91 -0
  203. package/lib/commonjs/main/index.js.map +1 -0
  204. package/lib/commonjs/main/index.web.js +51 -0
  205. package/lib/commonjs/main/index.web.js.map +1 -0
  206. package/lib/commonjs/types.js +2 -0
  207. package/lib/commonjs/types.js.map +1 -0
  208. package/lib/commonjs/utils.js +11 -0
  209. package/lib/commonjs/utils.js.map +1 -0
  210. package/lib/module/Canvas.js +46 -0
  211. package/lib/module/Canvas.js.map +1 -0
  212. package/lib/module/NativeWebGPUModule.js +4 -0
  213. package/lib/module/NativeWebGPUModule.js.map +1 -0
  214. package/lib/module/Offscreen.js +96 -0
  215. package/lib/module/Offscreen.js.map +1 -0
  216. package/lib/module/WebGPUViewNativeComponent.js +4 -0
  217. package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
  218. package/lib/module/WebGPUViewNativeComponent.web.js +96 -0
  219. package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -0
  220. package/lib/module/WebPolyfillGPUModule.js +38 -0
  221. package/lib/module/WebPolyfillGPUModule.js.map +1 -0
  222. package/lib/module/external/ModuleProxy.js +28 -0
  223. package/lib/module/external/ModuleProxy.js.map +1 -0
  224. package/lib/module/external/index.js +2 -0
  225. package/lib/module/external/index.js.map +1 -0
  226. package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
  227. package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
  228. package/lib/module/external/reanimated/index.js +3 -0
  229. package/lib/module/external/reanimated/index.js.map +1 -0
  230. package/lib/module/external/reanimated/registerWebGPUForReanimated.js +42 -0
  231. package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  232. package/lib/module/hooks.js +70 -0
  233. package/lib/module/hooks.js.map +1 -0
  234. package/lib/module/index.js +5 -0
  235. package/lib/module/index.js.map +1 -0
  236. package/lib/module/main/index.js +33 -0
  237. package/lib/module/main/index.js.map +1 -0
  238. package/lib/module/main/index.web.js +8 -0
  239. package/lib/module/main/index.web.js.map +1 -0
  240. package/lib/module/types.js +2 -0
  241. package/lib/module/types.js.map +1 -0
  242. package/lib/module/utils.js +5 -0
  243. package/lib/module/utils.js.map +1 -0
  244. package/lib/typescript/babel.config.d.ts +3 -0
  245. package/lib/typescript/babel.config.d.ts.map +1 -0
  246. package/lib/typescript/eslint.config.d.mts +3 -0
  247. package/lib/typescript/eslint.config.d.mts.map +1 -0
  248. package/lib/typescript/jest.config.d.ts +9 -0
  249. package/lib/typescript/jest.config.d.ts.map +1 -0
  250. package/lib/typescript/lib/commonjs/Canvas.d.ts +7 -0
  251. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
  252. package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts +5 -0
  253. package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
  254. package/lib/typescript/lib/commonjs/Offscreen.d.ts +26 -0
  255. package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +1 -0
  256. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +5 -0
  257. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
  258. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +4 -0
  259. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  260. package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +2 -0
  261. package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +1 -0
  262. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
  263. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
  264. package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
  265. package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
  266. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
  267. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  268. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
  269. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
  270. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
  271. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  272. package/lib/typescript/lib/commonjs/hooks.d.ts +18 -0
  273. package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -0
  274. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  275. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
  276. package/lib/typescript/lib/commonjs/main/index.d.ts +3 -0
  277. package/lib/typescript/lib/commonjs/main/index.d.ts.map +1 -0
  278. package/lib/typescript/lib/commonjs/main/index.web.d.ts +2 -0
  279. package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +1 -0
  280. package/lib/typescript/lib/commonjs/types.d.ts +1 -0
  281. package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
  282. package/lib/typescript/lib/commonjs/utils.d.ts +3 -0
  283. package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
  284. package/lib/typescript/lib/module/Canvas.d.ts +8 -0
  285. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
  286. package/lib/typescript/lib/module/NativeWebGPUModule.d.ts +3 -0
  287. package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
  288. package/lib/typescript/lib/module/Offscreen.d.ts +25 -0
  289. package/lib/typescript/lib/module/Offscreen.d.ts.map +1 -0
  290. package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +3 -0
  291. package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
  292. package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +3 -0
  293. package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  294. package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +2 -0
  295. package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +1 -0
  296. package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
  297. package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
  298. package/lib/typescript/lib/module/external/index.d.ts +2 -0
  299. package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
  300. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
  301. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  302. package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
  303. package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
  304. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
  305. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  306. package/lib/typescript/lib/module/hooks.d.ts +18 -0
  307. package/lib/typescript/lib/module/hooks.d.ts.map +1 -0
  308. package/lib/typescript/lib/module/index.d.ts +2 -0
  309. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  310. package/lib/typescript/lib/module/main/index.d.ts +6 -0
  311. package/lib/typescript/lib/module/main/index.d.ts.map +1 -0
  312. package/lib/typescript/lib/module/main/index.web.d.ts +5 -0
  313. package/lib/typescript/lib/module/main/index.web.d.ts.map +1 -0
  314. package/lib/typescript/lib/module/types.d.ts +1 -0
  315. package/lib/typescript/lib/module/types.d.ts.map +1 -0
  316. package/lib/typescript/lib/module/utils.d.ts +2 -0
  317. package/lib/typescript/lib/module/utils.d.ts.map +1 -0
  318. package/lib/typescript/src/Canvas.d.ts +35 -0
  319. package/lib/typescript/src/Canvas.d.ts.map +1 -0
  320. package/lib/typescript/src/NativeWebGPUModule.d.ts +7 -0
  321. package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
  322. package/lib/typescript/src/Offscreen.d.ts +30 -0
  323. package/lib/typescript/src/Offscreen.d.ts.map +1 -0
  324. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +9 -0
  325. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
  326. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +9 -0
  327. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  328. package/lib/typescript/src/WebPolyfillGPUModule.d.ts +2 -0
  329. package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +1 -0
  330. package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
  331. package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
  332. package/lib/typescript/src/external/index.d.ts +2 -0
  333. package/lib/typescript/src/external/index.d.ts.map +1 -0
  334. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
  335. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  336. package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
  337. package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
  338. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
  339. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  340. package/lib/typescript/src/hooks.d.ts +27 -0
  341. package/lib/typescript/src/hooks.d.ts.map +1 -0
  342. package/lib/typescript/src/index.d.ts +18 -0
  343. package/lib/typescript/src/index.d.ts.map +1 -0
  344. package/lib/typescript/src/main/index.d.ts +6 -0
  345. package/lib/typescript/src/main/index.d.ts.map +1 -0
  346. package/lib/typescript/src/main/index.web.d.ts +6 -0
  347. package/lib/typescript/src/main/index.web.d.ts.map +1 -0
  348. package/lib/typescript/src/types.d.ts +19 -0
  349. package/lib/typescript/src/types.d.ts.map +1 -0
  350. package/lib/typescript/src/utils.d.ts +2 -0
  351. package/lib/typescript/src/utils.d.ts.map +1 -0
  352. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  353. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  354. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  355. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  356. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +59 -0
  357. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  358. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  359. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  360. package/package.json +139 -0
  361. package/react-native-wgpu.podspec +47 -0
  362. package/src/Canvas.tsx +91 -0
  363. package/src/NativeWebGPUModule.ts +9 -0
  364. package/src/Offscreen.ts +113 -0
  365. package/src/WebGPUViewNativeComponent.ts +11 -0
  366. package/src/WebGPUViewNativeComponent.web.ts +113 -0
  367. package/src/WebPolyfillGPUModule.ts +53 -0
  368. package/src/external/ModuleProxy.ts +30 -0
  369. package/src/external/index.ts +1 -0
  370. package/src/external/reanimated/ReanimatedProxy.ts +19 -0
  371. package/src/external/reanimated/index.ts +2 -0
  372. package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
  373. package/src/hooks.tsx +93 -0
  374. package/src/index.tsx +31 -0
  375. package/src/main/index.tsx +40 -0
  376. package/src/main/index.web.tsx +8 -0
  377. package/src/types.ts +20 -0
  378. package/src/utils.ts +4 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerWebGPUForReanimated = void 0;
7
+ // Declare global WebGPU worklet helper functions (installed by native module)
8
+
9
+ let isRegistered = false;
10
+
11
+ /**
12
+ * Register WebGPU objects for Worklets serialization.
13
+ * This allows GPUDevice, GPUCanvasContext, etc. to be passed to worklets.
14
+ *
15
+ * This is called automatically when the module loads if react-native-worklets is installed.
16
+ */
17
+ const registerWebGPUForReanimated = () => {
18
+ if (isRegistered) {
19
+ return;
20
+ }
21
+ isRegistered = true;
22
+ try {
23
+ const {
24
+ registerCustomSerializable
25
+ } = require("react-native-worklets");
26
+ registerCustomSerializable({
27
+ name: "WebGPU",
28
+ determine: value => {
29
+ "worklet";
30
+
31
+ return __webgpuIsWebGPUObject(value);
32
+ },
33
+ pack: value => {
34
+ "worklet";
35
+
36
+ return __webgpuBox(value);
37
+ },
38
+ unpack: boxed => {
39
+ "worklet";
40
+
41
+ return boxed.unbox();
42
+ }
43
+ });
44
+ } catch {
45
+ // react-native-worklets not installed, skip registration
46
+ }
47
+ };
48
+ exports.registerWebGPUForReanimated = registerWebGPUForReanimated;
49
+ //# sourceMappingURL=registerWebGPUForReanimated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isRegistered","registerWebGPUForReanimated","registerCustomSerializable","require","name","determine","value","__webgpuIsWebGPUObject","pack","__webgpuBox","unpack","boxed","unbox","exports"],"sourceRoot":"../../../../src","sources":["external/reanimated/registerWebGPUForReanimated.ts"],"mappings":";;;;;;AAAA;;AAOA,IAAIA,YAAY,GAAG,KAAK;;AAExB;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,GAAGA,CAAA,KAAM;EAC/C,IAAID,YAAY,EAAE;IAChB;EACF;EACAA,YAAY,GAAG,IAAI;EAEnB,IAAI;IACF,MAAM;MAAEE;IAA2B,CAAC,GAAGC,OAAO,CAAC,uBAAuB,CAAC;IAEvED,0BAA0B,CAAC;MACzBE,IAAI,EAAE,QAAQ;MACdC,SAAS,EAAGC,KAAa,IAAsB;QAC7C,SAAS;;QACT,OAAOC,sBAAsB,CAACD,KAAK,CAAC;MACtC,CAAC;MACDE,IAAI,EAAGF,KAAa,IAAK;QACvB,SAAS;;QACT,OAAOG,WAAW,CAACH,KAAK,CAAC;MAC3B,CAAC;MACDI,MAAM,EAAGC,KAA8B,IAAK;QAC1C,SAAS;;QACT,OAAOA,KAAK,CAACC,KAAK,CAAC,CAAC;MACtB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ,CAAC;AAACC,OAAA,CAAAZ,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.warnIfNotHardwareAccelerated = exports.useSurface = exports.useMainDevice = exports.useDevice = exports.useCanvasRef = exports.GPUDeviceProvider = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
+ const warnIfNotHardwareAccelerated = adapter => {
10
+ // Check if adapter is a fallback adapter using the new GPUAdapterInfo API
11
+ // Note: isFallbackAdapter was moved from GPUAdapter to GPUAdapterInfo in Chrome 140
12
+ if (adapter.info && adapter.info.isFallbackAdapter) {
13
+ console.warn("GPUAdapter is not hardware accelerated. This is common on Android emulators. Rendering will be slow. Some features may be unavailable.");
14
+ }
15
+ };
16
+ exports.warnIfNotHardwareAccelerated = warnIfNotHardwareAccelerated;
17
+ const DeviceContext = /*#__PURE__*/(0, _react.createContext)(null);
18
+ const GPUDeviceProvider = ({
19
+ children,
20
+ adapterOptions,
21
+ deviceDescriptor
22
+ }) => {
23
+ const state = useDevice(adapterOptions, deviceDescriptor);
24
+ if (!state.device) {
25
+ return null;
26
+ }
27
+ return /*#__PURE__*/_react.default.createElement(DeviceContext.Provider, {
28
+ value: state
29
+ }, children);
30
+ };
31
+ exports.GPUDeviceProvider = GPUDeviceProvider;
32
+ const useSurface = () => {
33
+ const ref = (0, _react.useRef)(null);
34
+ const [surface, setSurface] = (0, _react.useState)(null);
35
+ (0, _react.useLayoutEffect)(() => {
36
+ const sur = ref.current.getNativeSurface();
37
+ setSurface(sur);
38
+ }, []);
39
+ return {
40
+ ref,
41
+ surface
42
+ };
43
+ };
44
+ exports.useSurface = useSurface;
45
+ const useMainDevice = () => {
46
+ const ctx = (0, _react.useContext)(DeviceContext);
47
+ if (!ctx) {
48
+ throw new Error("No DeviceContext found.");
49
+ }
50
+ return ctx;
51
+ };
52
+ exports.useMainDevice = useMainDevice;
53
+ const useCanvasRef = () => (0, _react.useRef)(null);
54
+ exports.useCanvasRef = useCanvasRef;
55
+ const useDevice = (adapterOptions, deviceDescriptor) => {
56
+ const [state, setState] = (0, _react.useState)(null);
57
+ (0, _react.useEffect)(() => {
58
+ (async () => {
59
+ if (!state) {
60
+ const adapter = await navigator.gpu.requestAdapter(adapterOptions);
61
+ if (!adapter) {
62
+ throw new Error("No appropriate GPUAdapter found.");
63
+ }
64
+ warnIfNotHardwareAccelerated(adapter);
65
+ const device = await adapter.requestDevice(deviceDescriptor);
66
+ if (!device) {
67
+ throw new Error("No appropriate GPUDevice found.");
68
+ }
69
+ setState({
70
+ adapter,
71
+ device
72
+ });
73
+ return;
74
+ }
75
+ })();
76
+ }, [adapterOptions, deviceDescriptor, state]);
77
+ return {
78
+ adapter: state?.adapter ?? null,
79
+ device: state?.device ?? null
80
+ };
81
+ };
82
+ exports.useDevice = useDevice;
83
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","warnIfNotHardwareAccelerated","adapter","info","isFallbackAdapter","console","warn","exports","DeviceContext","createContext","GPUDeviceProvider","children","adapterOptions","deviceDescriptor","state","useDevice","device","createElement","Provider","value","useSurface","ref","useRef","surface","setSurface","useState","useLayoutEffect","sur","current","getNativeSurface","useMainDevice","ctx","useContext","Error","useCanvasRef","setState","useEffect","navigator","gpu","requestAdapter","requestDevice"],"sourceRoot":"../../src","sources":["hooks.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOe,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAKR,MAAMkB,4BAA4B,GAAIC,OAAmB,IAAK;EACnE;EACA;EACA,I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7
+ Object.keys(_main).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _main[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _main[key];
14
+ }
15
+ });
16
+ });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_main","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ WebGPUModule: true
8
+ };
9
+ Object.defineProperty(exports, "WebGPUModule", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _NativeWebGPUModule.default;
13
+ }
14
+ });
15
+ var _external = require("../external");
16
+ var _NativeWebGPUModule = _interopRequireDefault(require("../NativeWebGPUModule"));
17
+ var _Canvas = require("../Canvas");
18
+ Object.keys(_Canvas).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _Canvas[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _Canvas[key];
26
+ }
27
+ });
28
+ });
29
+ var _Offscreen = require("../Offscreen");
30
+ Object.keys(_Offscreen).forEach(function (key) {
31
+ if (key === "default" || key === "__esModule") return;
32
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
33
+ if (key in exports && exports[key] === _Offscreen[key]) return;
34
+ Object.defineProperty(exports, key, {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _Offscreen[key];
38
+ }
39
+ });
40
+ });
41
+ var _WebGPUViewNativeComponent = require("../WebGPUViewNativeComponent");
42
+ Object.keys(_WebGPUViewNativeComponent).forEach(function (key) {
43
+ if (key === "default" || key === "__esModule") return;
44
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
45
+ if (key in exports && exports[key] === _WebGPUViewNativeComponent[key]) return;
46
+ Object.defineProperty(exports, key, {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _WebGPUViewNativeComponent[key];
50
+ }
51
+ });
52
+ });
53
+ var _hooks = require("../hooks");
54
+ Object.keys(_hooks).forEach(function (key) {
55
+ if (key === "default" || key === "__esModule") return;
56
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
57
+ if (key in exports && exports[key] === _hooks[key]) return;
58
+ Object.defineProperty(exports, key, {
59
+ enumerable: true,
60
+ get: function () {
61
+ return _hooks[key];
62
+ }
63
+ });
64
+ });
65
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
66
+ const _installOk = _NativeWebGPUModule.default.install();
67
+ (0, _external.registerWebGPUForReanimated)();
68
+ if (typeof RNWebGPU !== "undefined") {
69
+ if (!navigator) {
70
+ // @ts-expect-error Navigation object is more complex than this, setting it to an empty object to add gpu property
71
+ navigator = {
72
+ gpu: RNWebGPU.gpu,
73
+ userAgent: "react-native"
74
+ };
75
+ } else {
76
+ navigator.gpu = RNWebGPU.gpu;
77
+ if (typeof navigator.userAgent !== "string") {
78
+ try {
79
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // @ts-ignore - Hermes navigator may not include a userAgent, align with the polyfill if needed
81
+ navigator.userAgent = "react-native";
82
+ } catch {
83
+ // navigator.userAgent can be read-only; ignore if assignment fails
84
+ }
85
+ }
86
+ }
87
+ global.createImageBitmap = global.createImageBitmap ?? RNWebGPU.createImageBitmap.bind(RNWebGPU);
88
+ } else {
89
+ console.warn(`[react-native-wgpu] install() returned ${_installOk} but RNWebGPU global is not available`);
90
+ }
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_external","require","_NativeWebGPUModule","_interopRequireDefault","_Canvas","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Offscreen","_WebGPUViewNativeComponent","_hooks","e","__esModule","default","_installOk","WebGPUModule","install","registerWebGPUForReanimated","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind","console","warn"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAhB,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAA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AAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIzB,MAAMG,UAAU,GAAGC,2BAAY,CAACC,OAAO,CAAC,CAAC;AAEzC,IAAAC,qCAA2B,EAAC,CAAC;AAE7B,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACnC,IAAI,CAACC,SAAS,EAAE;IACd;IACAA,SAAS,GAAG;MACVC,GAAG,EAAEF,QAAQ,CAACE,GAAG;MACjBC,SAAS,EAAE;IACb,CAAC;EACH,CAAC,MAAM;IACLF,SAAS,CAACC,GAAG,GAAGF,QAAQ,CAACE,GAAG;IAC5B,IAAI,OAAOD,SAAS,CAACE,SAAS,KAAK,QAAQ,EAAE;MAC3C,IAAI;QACF;QACA;QACAF,SAAS,CAACE,SAAS,GAAG,cAAc;MACtC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF;EACAC,MAAM,CAACC,iBAAiB,GACtBD,MAAM,CAACC,iBAAiB,IAAIL,QAAQ,CAACK,iBAAiB,CAACC,IAAI,CAACN,QAAQ,CAAC;AACzE,CAAC,MAAM;EACLO,OAAO,CAACC,IAAI,CACV,0CAA0CZ,UAAU,uCACtD,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ require("../WebPolyfillGPUModule");
7
+ var _Canvas = require("../Canvas");
8
+ Object.keys(_Canvas).forEach(function (key) {
9
+ if (key === "default" || key === "__esModule") return;
10
+ if (key in exports && exports[key] === _Canvas[key]) return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _Canvas[key];
15
+ }
16
+ });
17
+ });
18
+ var _Offscreen = require("../Offscreen");
19
+ Object.keys(_Offscreen).forEach(function (key) {
20
+ if (key === "default" || key === "__esModule") return;
21
+ if (key in exports && exports[key] === _Offscreen[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _Offscreen[key];
26
+ }
27
+ });
28
+ });
29
+ var _WebGPUViewNativeComponent = require("../WebGPUViewNativeComponent");
30
+ Object.keys(_WebGPUViewNativeComponent).forEach(function (key) {
31
+ if (key === "default" || key === "__esModule") return;
32
+ if (key in exports && exports[key] === _WebGPUViewNativeComponent[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _WebGPUViewNativeComponent[key];
37
+ }
38
+ });
39
+ });
40
+ var _hooks = require("../hooks");
41
+ Object.keys(_hooks).forEach(function (key) {
42
+ if (key === "default" || key === "__esModule") return;
43
+ if (key in exports && exports[key] === _hooks[key]) return;
44
+ Object.defineProperty(exports, key, {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _hooks[key];
48
+ }
49
+ });
50
+ });
51
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require","_Canvas","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Offscreen","_WebGPUViewNativeComponent","_hooks"],"sourceRoot":"../../../src","sources":["main/index.web.tsx"],"mappings":";;;;;AAAAA,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAR,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAV,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,0BAAA,GAAAX,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAQ,0BAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,0BAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,0BAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,MAAA,GAAAZ,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAS,MAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,MAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,MAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contextIdToId = contextIdToId;
7
+ // Only used on the web
8
+ function contextIdToId(contextId) {
9
+ return "rnwgpu-canvas-" + contextId;
10
+ }
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["contextIdToId","contextId"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;;;;;AAAA;AACO,SAASA,aAAaA,CAACC,SAAiB,EAAE;EAC/C,OAAO,gBAAgB,GAAGA,SAAS;AACrC","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { useImperativeHandle, useRef, useState } from "react";
3
+ import { View } from "react-native";
4
+ import WebGPUNativeView from "./WebGPUViewNativeComponent";
5
+ let CONTEXT_COUNTER = 1;
6
+ function generateContextId() {
7
+ return CONTEXT_COUNTER++;
8
+ }
9
+ export const Canvas = ({
10
+ transparent,
11
+ ref,
12
+ ...props
13
+ }) => {
14
+ const viewRef = useRef(null);
15
+ const [contextId, _] = useState(() => generateContextId());
16
+ useImperativeHandle(ref, () => ({
17
+ getContextId: () => contextId,
18
+ getNativeSurface: () => {
19
+ return RNWebGPU.getNativeSurface(contextId);
20
+ },
21
+ getContext(contextName) {
22
+ if (contextName !== "webgpu") {
23
+ throw new Error(`[WebGPU] Unsupported context: ${contextName}`);
24
+ }
25
+ if (!viewRef.current) {
26
+ throw new Error("[WebGPU] Cannot get context before mount");
27
+ }
28
+ // getBoundingClientRect became stable in RN 0.83
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const view = viewRef.current;
31
+ const size = "getBoundingClientRect" in view ? view.getBoundingClientRect() : view.unstable_getBoundingClientRect();
32
+ return RNWebGPU.MakeWebGPUCanvasContext(contextId, size.width, size.height);
33
+ }
34
+ }));
35
+ return /*#__PURE__*/React.createElement(View, _extends({
36
+ collapsable: false,
37
+ ref: viewRef
38
+ }, props), /*#__PURE__*/React.createElement(WebGPUNativeView, {
39
+ style: {
40
+ flex: 1
41
+ },
42
+ contextId: contextId,
43
+ transparent: !!transparent
44
+ }));
45
+ };
46
+ //# sourceMappingURL=Canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useImperativeHandle","useRef","useState","View","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","contextId","_","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","_extends","collapsable","style","flex"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpE,SAASC,IAAI,QAAQ,cAAc;AAEnC,OAAOC,gBAAgB,MAAM,6BAA6B;AAE1D,IAAIC,eAAe,GAAG,CAAC;AACvB,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,eAAe,EAAE;AAC1B;AA0CA,OAAO,MAAME,MAAM,GAAGA,CAAC;EAAEC,WAAW;EAAEC,GAAG;EAAE,GAAGC;AAAmB,CAAC,KAAK;EACrE,MAAMC,OAAO,GAAGV,MAAM,CAAC,IAAI,CAAC;EAC5B,MAAM,CAACW,SAAS,EAAEC,CAAC,CAAC,GAAGX,QAAQ,CAAC,MAAMI,iBAAiB,CAAC,CAAC,CAAC;EAC1DN,mBAAmB,CAACS,GAAG,EAAE,OAAO;IAC9BK,YAAY,EAAEA,CAAA,KAAMF,SAAS;IAC7BG,gBAAgB,EAAEA,CAAA,KAAM;MACtB,OAAOC,QAAQ,CAACD,gBAAgB,CAACH,SAAS,CAAC;IAC7C,CAAC;IACDK,UAAUA,CAACC,WAAqB,EAA0B;MACxD,IAAIA,WAAW,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIC,KAAK,CAAC,iCAAiCD,WAAW,EAAE,CAAC;MACjE;MACA,IAAI,CAACP,OAAO,CAACS,OAAO,EAAE;QACpB,MAAM,IAAID,KAAK,CAAC,0CAA0C,CAAC;MAC7D;MACA;MACA;MACA,MAAME,IAAI,GAAGV,OAAO,CAACS,OAAc;MACnC,MAAME,IAAI,GACR,uBAAuB,IAAID,IAAI,GAC3BA,IAAI,CAACE,qBAAqB,CAAC,CAAC,GAC5BF,IAAI,CAACG,8BAA8B,CAAC,CAAC;MAC3C,OAAOR,QAAQ,CAACS,uBAAuB,CACrCb,SAAS,EACTU,IAAI,CAACI,KAAK,EACVJ,IAAI,CAACK,MACP,CAAC;IACH;EACF,CAAC,CAAC,CAAC;EAEH,oBACE5B,KAAA,CAAA6B,aAAA,CAACzB,IAAI,EAAA0B,QAAA;IAACC,WAAW,EAAE,KAAM;IAACrB,GAAG,EAAEE;EAAQ,GAAKD,KAAK,gBAC/CX,KAAA,CAAA6B,aAAA,CAACxB,gBAAgB;IACf2B,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBpB,SAAS,EAAEA,SAAU;IACrBJ,WAAW,EAAE,CAAC,CAACA;EAAY,CAC5B,CACG,CAAC;AAEX,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { TurboModuleRegistry } from "react-native";
2
+ // eslint-disable-next-line import/no-default-export
3
+ export default TurboModuleRegistry.getEnforcing("WebGPUModule");
4
+ //# sourceMappingURL=NativeWebGPUModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAOlD;AACA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
@@ -0,0 +1,96 @@
1
+ export class GPUOffscreenCanvas {
2
+ constructor(width, height) {
3
+ this.width = width;
4
+ this.height = height;
5
+ this.context = new GPUOffscreenCanvasContext(this);
6
+ }
7
+ getContext(contextId) {
8
+ if (contextId === "webgpu") {
9
+ return this.context;
10
+ }
11
+ // Implement other context types if necessary
12
+ return null;
13
+ }
14
+ getImageData() {
15
+ const device = this.context.getDevice();
16
+ const texture = this.context.getTexture();
17
+ const commandEncoder = device.createCommandEncoder();
18
+ const bytesPerRow = this.width * 4;
19
+ const buffer = device.createBuffer({
20
+ size: bytesPerRow * this.height,
21
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
22
+ });
23
+ commandEncoder.copyTextureToBuffer({
24
+ texture: texture
25
+ }, {
26
+ buffer: buffer,
27
+ bytesPerRow
28
+ }, [this.width, this.height]);
29
+ device.queue.submit([commandEncoder.finish()]);
30
+ return buffer.mapAsync(GPUMapMode.READ).then(() => {
31
+ const arrayBuffer = buffer.getMappedRange();
32
+ const uint8Array = new Uint8Array(arrayBuffer);
33
+ const data = Array.from(uint8Array);
34
+ buffer.unmap();
35
+ return {
36
+ data,
37
+ width: this.width,
38
+ height: this.height,
39
+ format: navigator.gpu.getPreferredCanvasFormat()
40
+ };
41
+ });
42
+ }
43
+ }
44
+ class GPUOffscreenCanvasContext {
45
+ __brand = "GPUCanvasContext";
46
+ texture = null;
47
+ device = null;
48
+
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ constructor(canvas) {
51
+ this.canvas = canvas;
52
+ this.textureFormat = navigator.gpu.getPreferredCanvasFormat();
53
+ }
54
+ getConfiguration() {
55
+ throw new Error("Method not implemented.");
56
+ }
57
+ present() {
58
+ // Do nothing
59
+ }
60
+ getDevice() {
61
+ if (!this.device) {
62
+ throw new Error("Device is not configured.");
63
+ }
64
+ return this.device;
65
+ }
66
+ getTexture() {
67
+ if (!this.texture) {
68
+ throw new Error("Texture is not configured");
69
+ }
70
+ return this.texture;
71
+ }
72
+ configure(config) {
73
+ // Configure the canvas context with the device and format
74
+ this.device = config.device;
75
+ this.texture = config.device.createTexture({
76
+ size: [this.canvas.width, this.canvas.height],
77
+ format: this.textureFormat,
78
+ usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC | GPUTextureUsage.TEXTURE_BINDING
79
+ });
80
+ return undefined;
81
+ }
82
+ unconfigure() {
83
+ // Unconfigure the canvas context
84
+ if (this.texture) {
85
+ this.texture.destroy();
86
+ }
87
+ return undefined;
88
+ }
89
+ getCurrentTexture() {
90
+ if (!this.texture) {
91
+ throw new Error("Texture is not configured");
92
+ }
93
+ return this.texture;
94
+ }
95
+ }
96
+ //# sourceMappingURL=Offscreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GPUOffscreenCanvas","constructor","width","height","context","GPUOffscreenCanvasContext","getContext","contextId","getImageData","device","getDevice","texture","getTexture","commandEncoder","createCommandEncoder","bytesPerRow","buffer","createBuffer","size","usage","GPUBufferUsage","COPY_DST","MAP_READ","copyTextureToBuffer","queue","submit","finish","mapAsync","GPUMapMode","READ","then","arrayBuffer","getMappedRange","uint8Array","Uint8Array","data","Array","from","unmap","format","navigator","gpu","getPreferredCanvasFormat","__brand","canvas","textureFormat","getConfiguration","Error","present","configure","config","createTexture","GPUTextureUsage","RENDER_ATTACHMENT","COPY_SRC","TEXTURE_BINDING","undefined","unconfigure","destroy","getCurrentTexture"],"sourceRoot":"../../src","sources":["Offscreen.ts"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,CAAC;EAM9BC,WAAWA,CAACC,KAAa,EAAEC,MAAc,EAAE;IACzC,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAG,IAAIC,yBAAyB,CAAC,IAAI,CAAC;EACpD;EAEAC,UAAUA,CAACC,SAAmB,EAAoC;IAChE,IAAIA,SAAS,KAAK,QAAQ,EAAE;MAC1B,OAAO,IAAI,CAACH,OAAO;IACrB;IACA;IACA,OAAO,IAAI;EACb;EAEAI,YAAYA,CAAA,EAAG;IACb,MAAMC,MAAM,GAAG,IAAI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;IACA,OAAOF,SAAS;EAClB;EAEAG,iBAAiBA,CAAA,EAAe;IAC9B,IAAI,CAAC,IAAI,CAAChD,OAAO,EAAE;MACjB,MAAM,IAAIoC,KAAK,CAAC,2BAA2B,CAAC;IAC9C;IACA,OAAO,IAAI,CAACpC,OAAO;EACrB;AACF","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { codegenNativeComponent } from "react-native";
2
+ // eslint-disable-next-line import/no-default-export
3
+ export default codegenNativeComponent("WebGPUView");
4
+ //# sourceMappingURL=WebGPUViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AASrD;AACA,eAAeA,sBAAsB,CAAc,YAAY,CAAC","ignoreList":[]}
@@ -0,0 +1,96 @@
1
+ import React, { useEffect, useRef } from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { contextIdToId } from "./utils";
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ function debounce(func, wait, immediate = false) {
6
+ let timeout;
7
+ return function debounced(...args) {
8
+ const context = this;
9
+ const callNow = immediate && !timeout;
10
+ if (timeout) {
11
+ clearTimeout(timeout);
12
+ }
13
+ timeout = setTimeout(() => {
14
+ timeout = undefined;
15
+ if (!immediate) {
16
+ func.apply(context, args);
17
+ }
18
+ }, wait);
19
+ if (callNow) {
20
+ func.apply(context, args);
21
+ }
22
+ };
23
+ }
24
+ function resizeCanvas(canvas) {
25
+ if (!canvas) {
26
+ return;
27
+ }
28
+ const dpr = window.devicePixelRatio || 1;
29
+ const {
30
+ height,
31
+ width
32
+ } = canvas.getBoundingClientRect();
33
+ canvas.setAttribute("height", (height * dpr).toString());
34
+ canvas.setAttribute("width", (width * dpr).toString());
35
+ }
36
+
37
+ // eslint-disable-next-line import/no-default-export
38
+ export default function WebGPUViewNativeComponent(props) {
39
+ const {
40
+ contextId,
41
+ style,
42
+ transparent,
43
+ ...rest
44
+ } = props;
45
+ const canvasElm = useRef();
46
+ useEffect(() => {
47
+ const onResize = debounce(() => resizeCanvas(canvasElm.current ?? null), 100);
48
+ window.addEventListener("resize", onResize);
49
+ return () => {
50
+ window.removeEventListener("resize", onResize);
51
+ };
52
+ }, []);
53
+ return /*#__PURE__*/React.createElement("canvas", {
54
+ ...rest,
55
+ id: contextIdToId(contextId),
56
+ style: {
57
+ ...styles.view,
58
+ ...styles.flex1,
59
+ ...(transparent === false ? {
60
+ backgroundColor: "white"
61
+ } : {}),
62
+ ...(typeof style === "object" ? style : {})
63
+ },
64
+ ref: ref => {
65
+ canvasElm.current = ref;
66
+ if (ref) {
67
+ resizeCanvas(ref);
68
+ }
69
+ }
70
+ });
71
+ }
72
+ const styles = StyleSheet.create({
73
+ flex1: {
74
+ flex: 1
75
+ },
76
+ view: {
77
+ alignItems: "stretch",
78
+ backgroundColor: "transparent",
79
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // @ts-expect-error
81
+ border: "0 solid black",
82
+ boxSizing: "border-box",
83
+ display: "flex",
84
+ flexBasis: "auto",
85
+ flexDirection: "column",
86
+ flexShrink: 0,
87
+ listStyle: "none",
88
+ margin: 0,
89
+ minHeight: 0,
90
+ minWidth: 0,
91
+ padding: 0,
92
+ position: "relative",
93
+ zIndex: 0
94
+ }
95
+ });
96
+ //# sourceMappingURL=WebGPUViewNativeComponent.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useRef","StyleSheet","contextIdToId","debounce","func","wait","immediate","timeout","debounced","args","context","callNow","clearTimeout","setTimeout","undefined","apply","resizeCanvas","canvas","dpr","window","devicePixelRatio","height","width","getBoundingClientRect","setAttribute","toString","WebGPUViewNativeComponent","props","contextId","style","transparent","rest","canvasElm","onResize","current","addEventListener","removeEventListener","createElement","id","styles","view","flex1","backgroundColor","ref","create","flex","alignItems","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","zIndex"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.web.ts"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,UAAU,QAAQ,cAAc;AAIzC,SAASC,aAAa,QAAQ,SAAS;AAOvC;AACA,SAASC,QAAQA,CACfC,IAAO,EACPC,IAAY,EACZC,SAAS,GAAG,KAAK,EACjB;EACA,IAAIC,OAAkD;EACtD,OAAO,SAASC,SAASA,CAEvB,GAAGC,IAAmB,EACtB;IACA,MAAMC,OAAO,GAAG,IAAI;IACpB,MAAMC,OAAO,GAAGL,SAAS,IAAI,CAACC,OAAO;IACrC,IAAIA,OAAO,EAAE;MACXK,YAAY,CAACL,OAAO,CAAC;IACvB;IACAA,OAAO,GAAGM,UAAU,CAAC,MAAM;MACzBN,OAAO,GAAGO,SAAS;MACnB,IAAI,CAACR,SAAS,EAAE;QACdF,IAAI,CAACW,KAAK,CAACL,OAAO,EAAED,IAAI,CAAC;MAC3B;IACF,CAAC,EAAEJ,IAAI,CAAC;IACR,IAAIM,OAAO,EAAE;MACXP,IAAI,CAACW,KAAK,CAACL,OAAO,EAAED,IAAI,CAAC;IAC3B;EACF,CAAC;AACH;AAEA,SAASO,YAAYA,CAACC,MAAgC,EAAE;EACtD,IAAI,CAACA,MAAM,EAAE;IACX;EACF;EAEA,MAAMC,GAAG,GAAGC,MAAM,CAACC,gBAAgB,IAAI,CAAC;EAExC,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGL,MAAM,CAACM,qBAAqB,CAAC,CAAC;EACxDN,MAAM,CAACO,YAAY,CAAC,QAAQ,EAAE,CAACH,MAAM,GAAGH,GAAG,EAAEO,QAAQ,CAAC,CAAC,CAAC;EACxDR,MAAM,CAACO,YAAY,CAAC,OAAO,EAAE,CAACF,KAAK,GAAGJ,GAAG,EAAEO,QAAQ,CAAC,CAAC,CAAC;AACxD;;AAEA;AACA,eAAe,SA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