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.
- package/LICENSE +20 -0
- package/README.md +319 -0
- package/android/CMakeLists.txt +108 -0
- package/android/build.gradle +138 -0
- package/android/cpp/AndroidPlatformContext.h +207 -0
- package/android/cpp/cpp-adapter.cpp +71 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +298 -0
- package/android/src/main/java/com/webgpu/WebGPUAPI.java +20 -0
- package/android/src/main/java/com/webgpu/WebGPUBaseView.java +61 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +50 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +41 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceViewWithSC.java +79 -0
- package/android/src/main/java/com/webgpu/WebGPUTextureView.java +46 -0
- package/android/src/main/java/com/webgpu/WebGPUView.java +108 -0
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +38 -0
- package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +50 -0
- package/android/src/newarch/com/webgpu/WebGPUViewManagerSpec.java +24 -0
- package/apple/ApplePlatformContext.h +31 -0
- package/apple/ApplePlatformContext.mm +157 -0
- package/apple/MetalView.h +13 -0
- package/apple/MetalView.mm +50 -0
- package/apple/RNWGUIKit.h +16 -0
- package/apple/WebGPUModule.h +13 -0
- package/apple/WebGPUModule.mm +89 -0
- package/apple/WebGPUView.h +12 -0
- package/apple/WebGPUView.mm +66 -0
- package/cpp/WGPULogger.h +100 -0
- package/cpp/dawn_logging.cpp +119 -0
- package/cpp/jsi/EnumMapper.h +45 -0
- package/cpp/jsi/JSIConverter.h +473 -0
- package/cpp/jsi/NativeObject.h +607 -0
- package/cpp/jsi/Promise.cpp +44 -0
- package/cpp/jsi/Promise.h +35 -0
- package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
- package/cpp/jsi/RuntimeAwareCache.h +100 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
- package/cpp/rnwgpu/ArrayBuffer.h +73 -0
- package/cpp/rnwgpu/PlatformContext.h +46 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +225 -0
- package/cpp/rnwgpu/RNWebGPUManager.h +46 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +230 -0
- package/cpp/rnwgpu/api/Canvas.h +57 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +127 -0
- package/cpp/rnwgpu/api/GPU.h +58 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +191 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +67 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +66 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +492 -0
- package/cpp/rnwgpu/api/GPUDevice.h +259 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +203 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +81 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +162 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +71 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +40 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +199 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +78 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +98 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +76 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +68 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +100 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +70 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +44 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +102 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +93 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +111 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1969 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +215 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +53 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/cpp/webgpu/webgpu.h +4918 -0
- package/cpp/webgpu/webgpu_cpp.h +10294 -0
- package/cpp/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/webgpu/webgpu_cpp_print.h +2755 -0
- package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/lib/commonjs/Canvas.js +55 -0
- package/lib/commonjs/Canvas.js.map +1 -0
- package/lib/commonjs/NativeWebGPUModule.js +10 -0
- package/lib/commonjs/NativeWebGPUModule.js.map +1 -0
- package/lib/commonjs/Offscreen.js +103 -0
- package/lib/commonjs/Offscreen.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js +10 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js +103 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/WebPolyfillGPUModule.js +40 -0
- package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -0
- package/lib/commonjs/external/ModuleProxy.js +36 -0
- package/lib/commonjs/external/ModuleProxy.js.map +1 -0
- package/lib/commonjs/external/index.js +17 -0
- package/lib/commonjs/external/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/index.js +21 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +49 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/commonjs/hooks.js +83 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/main/index.js +91 -0
- package/lib/commonjs/main/index.js.map +1 -0
- package/lib/commonjs/main/index.web.js +51 -0
- package/lib/commonjs/main/index.web.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +11 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/Canvas.js +46 -0
- package/lib/module/Canvas.js.map +1 -0
- package/lib/module/NativeWebGPUModule.js +4 -0
- package/lib/module/NativeWebGPUModule.js.map +1 -0
- package/lib/module/Offscreen.js +96 -0
- package/lib/module/Offscreen.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.js +4 -0
- package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.web.js +96 -0
- package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/module/WebPolyfillGPUModule.js +38 -0
- package/lib/module/WebPolyfillGPUModule.js.map +1 -0
- package/lib/module/external/ModuleProxy.js +28 -0
- package/lib/module/external/ModuleProxy.js.map +1 -0
- package/lib/module/external/index.js +2 -0
- package/lib/module/external/index.js.map +1 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/module/external/reanimated/index.js +3 -0
- package/lib/module/external/reanimated/index.js.map +1 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js +42 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/module/hooks.js +70 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/main/index.js +33 -0
- package/lib/module/main/index.js.map +1 -0
- package/lib/module/main/index.web.js +8 -0
- package/lib/module/main/index.web.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +5 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +3 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/eslint.config.d.mts +3 -0
- package/lib/typescript/eslint.config.d.mts.map +1 -0
- package/lib/typescript/jest.config.d.ts +9 -0
- package/lib/typescript/jest.config.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts +7 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts +5 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts +26 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +5 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +4 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts +18 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/main/index.d.ts +3 -0
- package/lib/typescript/lib/commonjs/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts +2 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/utils.d.ts +3 -0
- package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
- package/lib/typescript/lib/module/Canvas.d.ts +8 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts +3 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/Offscreen.d.ts +25 -0
- package/lib/typescript/lib/module/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/index.d.ts +2 -0
- package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks.d.ts +18 -0
- package/lib/typescript/lib/module/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.d.ts +6 -0
- package/lib/typescript/lib/module/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.web.d.ts +5 -0
- package/lib/typescript/lib/module/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/types.d.ts +1 -0
- package/lib/typescript/lib/module/types.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils.d.ts +2 -0
- package/lib/typescript/lib/module/utils.d.ts.map +1 -0
- package/lib/typescript/src/Canvas.d.ts +35 -0
- package/lib/typescript/src/Canvas.d.ts.map +1 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts +7 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/Offscreen.d.ts +30 -0
- package/lib/typescript/src/Offscreen.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +9 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +9 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/index.d.ts +2 -0
- package/lib/typescript/src/external/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +27 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/main/index.d.ts +6 -0
- package/lib/typescript/src/main/index.d.ts.map +1 -0
- package/lib/typescript/src/main/index.web.d.ts +6 -0
- package/lib/typescript/src/main/index.web.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +19 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +59 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/package.json +139 -0
- package/react-native-wgpu.podspec +47 -0
- package/src/Canvas.tsx +91 -0
- package/src/NativeWebGPUModule.ts +9 -0
- package/src/Offscreen.ts +113 -0
- package/src/WebGPUViewNativeComponent.ts +11 -0
- package/src/WebGPUViewNativeComponent.web.ts +113 -0
- package/src/WebPolyfillGPUModule.ts +53 -0
- package/src/external/ModuleProxy.ts +30 -0
- package/src/external/index.ts +1 -0
- package/src/external/reanimated/ReanimatedProxy.ts +19 -0
- package/src/external/reanimated/index.ts +2 -0
- package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
- package/src/hooks.tsx +93 -0
- package/src/index.tsx +31 -0
- package/src/main/index.tsx +40 -0
- package/src/main/index.web.tsx +8 -0
- package/src/types.ts +20 -0
- package/src/utils.ts +4 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Copyright 2017 The Dawn & Tint Authors
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without
|
|
4
|
+
// modification, are permitted provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
// list of conditions and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
// this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
// and/or other materials provided with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its
|
|
14
|
+
// contributors may be used to endorse or promote products derived from
|
|
15
|
+
// this software without specific prior written permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
#ifndef WEBGPU_ENUM_CLASS_BITMASKS_H_
|
|
29
|
+
#define WEBGPU_ENUM_CLASS_BITMASKS_H_
|
|
30
|
+
|
|
31
|
+
#include <type_traits>
|
|
32
|
+
|
|
33
|
+
// The operators in wgpu:: namespace need be introduced into other namespaces with
|
|
34
|
+
// using-declarations for C++ Argument Dependent Lookup to work.
|
|
35
|
+
#define WGPU_IMPORT_BITMASK_OPERATORS \
|
|
36
|
+
using wgpu::operator|; \
|
|
37
|
+
using wgpu::operator&; \
|
|
38
|
+
using wgpu::operator^; \
|
|
39
|
+
using wgpu::operator~; \
|
|
40
|
+
using wgpu::operator&=; \
|
|
41
|
+
using wgpu::operator|=; \
|
|
42
|
+
using wgpu::operator^=; \
|
|
43
|
+
using wgpu::HasZeroOrOneBits;
|
|
44
|
+
|
|
45
|
+
namespace wgpu {
|
|
46
|
+
|
|
47
|
+
template <typename T>
|
|
48
|
+
struct IsWGPUBitmask {
|
|
49
|
+
static constexpr bool enable = false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
template <typename T, typename Enable = void>
|
|
53
|
+
struct LowerBitmask {
|
|
54
|
+
static constexpr bool enable = false;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
template <typename T>
|
|
58
|
+
struct LowerBitmask<T, typename std::enable_if<IsWGPUBitmask<T>::enable>::type> {
|
|
59
|
+
static constexpr bool enable = true;
|
|
60
|
+
using type = T;
|
|
61
|
+
constexpr static T Lower(T t) { return t; }
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
template <typename T>
|
|
65
|
+
struct BoolConvertible {
|
|
66
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
67
|
+
|
|
68
|
+
// NOLINTNEXTLINE(runtime/explicit)
|
|
69
|
+
explicit constexpr BoolConvertible(Integral value) : value(value) {}
|
|
70
|
+
constexpr operator bool() const { return value != 0; }
|
|
71
|
+
constexpr operator T() const { return static_cast<T>(value); }
|
|
72
|
+
|
|
73
|
+
Integral value;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
template <typename T>
|
|
77
|
+
struct LowerBitmask<BoolConvertible<T>> {
|
|
78
|
+
static constexpr bool enable = true;
|
|
79
|
+
using type = T;
|
|
80
|
+
static constexpr type Lower(BoolConvertible<T> t) { return t; }
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
template <
|
|
84
|
+
typename T1,
|
|
85
|
+
typename T2,
|
|
86
|
+
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
87
|
+
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
|
|
88
|
+
using T = typename LowerBitmask<T1>::type;
|
|
89
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
90
|
+
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
|
|
91
|
+
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
template <
|
|
95
|
+
typename T1,
|
|
96
|
+
typename T2,
|
|
97
|
+
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
98
|
+
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
|
|
99
|
+
using T = typename LowerBitmask<T1>::type;
|
|
100
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
101
|
+
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
|
|
102
|
+
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
template <
|
|
106
|
+
typename T1,
|
|
107
|
+
typename T2,
|
|
108
|
+
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
109
|
+
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
|
|
110
|
+
using T = typename LowerBitmask<T1>::type;
|
|
111
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
112
|
+
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
|
|
113
|
+
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
template <typename T1>
|
|
117
|
+
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
|
|
118
|
+
using T = typename LowerBitmask<T1>::type;
|
|
119
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
120
|
+
return BoolConvertible<T>(~static_cast<Integral>(LowerBitmask<T1>::Lower(t)));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
template <
|
|
124
|
+
typename T,
|
|
125
|
+
typename T2,
|
|
126
|
+
typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
127
|
+
constexpr T& operator&=(T& l, T2 right) {
|
|
128
|
+
T r = LowerBitmask<T2>::Lower(right);
|
|
129
|
+
l = l & r;
|
|
130
|
+
return l;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
template <
|
|
134
|
+
typename T,
|
|
135
|
+
typename T2,
|
|
136
|
+
typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
137
|
+
constexpr T& operator|=(T& l, T2 right) {
|
|
138
|
+
T r = LowerBitmask<T2>::Lower(right);
|
|
139
|
+
l = l | r;
|
|
140
|
+
return l;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
template <
|
|
144
|
+
typename T,
|
|
145
|
+
typename T2,
|
|
146
|
+
typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
147
|
+
constexpr T& operator^=(T& l, T2 right) {
|
|
148
|
+
T r = LowerBitmask<T2>::Lower(right);
|
|
149
|
+
l = l ^ r;
|
|
150
|
+
return l;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
template <typename T>
|
|
154
|
+
constexpr bool HasZeroOrOneBits(T value) {
|
|
155
|
+
using Integral = typename std::underlying_type<T>::type;
|
|
156
|
+
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
} // namespace wgpu
|
|
160
|
+
|
|
161
|
+
#endif // WEBGPU_ENUM_CLASS_BITMASKS_H_
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Canvas = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _WebGPUViewNativeComponent = _interopRequireDefault(require("./WebGPUViewNativeComponent"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
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); }
|
|
12
|
+
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); }
|
|
13
|
+
let CONTEXT_COUNTER = 1;
|
|
14
|
+
function generateContextId() {
|
|
15
|
+
return CONTEXT_COUNTER++;
|
|
16
|
+
}
|
|
17
|
+
const Canvas = ({
|
|
18
|
+
transparent,
|
|
19
|
+
ref,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const viewRef = (0, _react.useRef)(null);
|
|
23
|
+
const [contextId, _] = (0, _react.useState)(() => generateContextId());
|
|
24
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
25
|
+
getContextId: () => contextId,
|
|
26
|
+
getNativeSurface: () => {
|
|
27
|
+
return RNWebGPU.getNativeSurface(contextId);
|
|
28
|
+
},
|
|
29
|
+
getContext(contextName) {
|
|
30
|
+
if (contextName !== "webgpu") {
|
|
31
|
+
throw new Error(`[WebGPU] Unsupported context: ${contextName}`);
|
|
32
|
+
}
|
|
33
|
+
if (!viewRef.current) {
|
|
34
|
+
throw new Error("[WebGPU] Cannot get context before mount");
|
|
35
|
+
}
|
|
36
|
+
// getBoundingClientRect became stable in RN 0.83
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const view = viewRef.current;
|
|
39
|
+
const size = "getBoundingClientRect" in view ? view.getBoundingClientRect() : view.unstable_getBoundingClientRect();
|
|
40
|
+
return RNWebGPU.MakeWebGPUCanvasContext(contextId, size.width, size.height);
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
|
|
44
|
+
collapsable: false,
|
|
45
|
+
ref: viewRef
|
|
46
|
+
}, props), /*#__PURE__*/_react.default.createElement(_WebGPUViewNativeComponent.default, {
|
|
47
|
+
style: {
|
|
48
|
+
flex: 1
|
|
49
|
+
},
|
|
50
|
+
contextId: contextId,
|
|
51
|
+
transparent: !!transparent
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
exports.Canvas = Canvas;
|
|
55
|
+
//# sourceMappingURL=Canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_WebGPUViewNativeComponent","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","useRef","contextId","_","useState","useImperativeHandle","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","View","collapsable","style","flex","exports"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,0BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA2D,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAK,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA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,CAAC;IAC7C,CAAC;IACDO,UAAUA,CAACC,WAAqB,EAA0B;MACxD,IAAIA,WAAW,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIC,KAAK,CAAC,iCAAiCD,WAAW,EAAE,CAAC;MACjE;MACA,IAAI,CAACV,OAAO,CAACY,OAAO,EAAE;QACpB,MAAM,IAAID,KAAK,CAAC,0CAA0C,CAAC;MAC7D;MACA;MACA;MACA,MAAME,IAAI,GAAGb,OAAO,CAACY,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,CACrCf,SAAS,EACTY,IAAI,CAACI,KAAK,EACVJ,IAAI,CAACK,MACP,CAAC;IACH;EACF,CAAC,CAAC,CAAC;EAEH,oBACExD,MAAA,CAAAQ,OAAA,CAAAiD,aAAA,CAACtD,YAAA,CAAAuD,IAAI,EAAAjC,QAAA;IAACkC,WAAW,EAAE,KAAM;IAACxB,GAAG,EAAEE;EAAQ,GAAKD,KAAK,gBAC/CpC,MAAA,CAAAQ,OAAA,CAAAiD,aAAA,CAACrD,0BAAA,CAAAI,OAAgB;IACfoD,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBtB,SAAS,EAAEA,SAAU;IACrBL,WAAW,EAAE,CAAC,CAACA;EAAY,CAC5B,CACG,CAAC;AAEX,CAAC;AAAC4B,OAAA,CAAA7B,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
// eslint-disable-next-line import/no-default-export
|
|
9
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing("WebGPUModule");
|
|
10
|
+
//# sourceMappingURL=NativeWebGPUModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GPUOffscreenCanvas = void 0;
|
|
7
|
+
class GPUOffscreenCanvas {
|
|
8
|
+
constructor(width, height) {
|
|
9
|
+
this.width = width;
|
|
10
|
+
this.height = height;
|
|
11
|
+
this.context = new GPUOffscreenCanvasContext(this);
|
|
12
|
+
}
|
|
13
|
+
getContext(contextId) {
|
|
14
|
+
if (contextId === "webgpu") {
|
|
15
|
+
return this.context;
|
|
16
|
+
}
|
|
17
|
+
// Implement other context types if necessary
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
getImageData() {
|
|
21
|
+
const device = this.context.getDevice();
|
|
22
|
+
const texture = this.context.getTexture();
|
|
23
|
+
const commandEncoder = device.createCommandEncoder();
|
|
24
|
+
const bytesPerRow = this.width * 4;
|
|
25
|
+
const buffer = device.createBuffer({
|
|
26
|
+
size: bytesPerRow * this.height,
|
|
27
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
28
|
+
});
|
|
29
|
+
commandEncoder.copyTextureToBuffer({
|
|
30
|
+
texture: texture
|
|
31
|
+
}, {
|
|
32
|
+
buffer: buffer,
|
|
33
|
+
bytesPerRow
|
|
34
|
+
}, [this.width, this.height]);
|
|
35
|
+
device.queue.submit([commandEncoder.finish()]);
|
|
36
|
+
return buffer.mapAsync(GPUMapMode.READ).then(() => {
|
|
37
|
+
const arrayBuffer = buffer.getMappedRange();
|
|
38
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
|
39
|
+
const data = Array.from(uint8Array);
|
|
40
|
+
buffer.unmap();
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
width: this.width,
|
|
44
|
+
height: this.height,
|
|
45
|
+
format: navigator.gpu.getPreferredCanvasFormat()
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.GPUOffscreenCanvas = GPUOffscreenCanvas;
|
|
51
|
+
class GPUOffscreenCanvasContext {
|
|
52
|
+
__brand = "GPUCanvasContext";
|
|
53
|
+
texture = null;
|
|
54
|
+
device = null;
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
constructor(canvas) {
|
|
58
|
+
this.canvas = canvas;
|
|
59
|
+
this.textureFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
60
|
+
}
|
|
61
|
+
getConfiguration() {
|
|
62
|
+
throw new Error("Method not implemented.");
|
|
63
|
+
}
|
|
64
|
+
present() {
|
|
65
|
+
// Do nothing
|
|
66
|
+
}
|
|
67
|
+
getDevice() {
|
|
68
|
+
if (!this.device) {
|
|
69
|
+
throw new Error("Device is not configured.");
|
|
70
|
+
}
|
|
71
|
+
return this.device;
|
|
72
|
+
}
|
|
73
|
+
getTexture() {
|
|
74
|
+
if (!this.texture) {
|
|
75
|
+
throw new Error("Texture is not configured");
|
|
76
|
+
}
|
|
77
|
+
return this.texture;
|
|
78
|
+
}
|
|
79
|
+
configure(config) {
|
|
80
|
+
// Configure the canvas context with the device and format
|
|
81
|
+
this.device = config.device;
|
|
82
|
+
this.texture = config.device.createTexture({
|
|
83
|
+
size: [this.canvas.width, this.canvas.height],
|
|
84
|
+
format: this.textureFormat,
|
|
85
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC | GPUTextureUsage.TEXTURE_BINDING
|
|
86
|
+
});
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
unconfigure() {
|
|
90
|
+
// Unconfigure the canvas context
|
|
91
|
+
if (this.texture) {
|
|
92
|
+
this.texture.destroy();
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
getCurrentTexture() {
|
|
97
|
+
if (!this.texture) {
|
|
98
|
+
throw new Error("Texture is not configured");
|
|
99
|
+
}
|
|
100
|
+
return this.texture;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# 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","exports","__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":";;;;;;AAAO,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,IAA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AQ,GACxBF,eAAe,CAACG;IACpB,CAAC,CAAC;IACF,OAAOC,SAAS;EAClB;EAEAC,WAAWA,CAAA,EAAG;IACZ;IACA,IAAI,IAAI,CAAC/C,OAAO,EAAE;MAChB,IAAI,CAACA,OAAO,CAACgD,OAAO,CAAC,CAAC;IACxB;IACA,OAAOF,SAAS;EAClB;EAEAG,iBAAiBA,CAAA,EAAe;IAC9B,IAAI,CAAC,IAAI,CAACjD,OAAO,EAAE;MACjB,MAAM,IAAIqC,KAAK,CAAC,2BAA2B,CAAC;IAC9C;IACA,OAAO,IAAI,CAACrC,OAAO;EACrB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
// eslint-disable-next-line import/no-default-export
|
|
9
|
+
var _default = exports.default = (0, _reactNative.codegenNativeComponent)("WebGPUView");
|
|
10
|
+
//# sourceMappingURL=WebGPUViewNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","codegenNativeComponent"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe,IAAAC,mCAAsB,EAAc,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = WebGPUViewNativeComponent;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
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); }
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
function debounce(func, wait, immediate = false) {
|
|
13
|
+
let timeout;
|
|
14
|
+
return function debounced(...args) {
|
|
15
|
+
const context = this;
|
|
16
|
+
const callNow = immediate && !timeout;
|
|
17
|
+
if (timeout) {
|
|
18
|
+
clearTimeout(timeout);
|
|
19
|
+
}
|
|
20
|
+
timeout = setTimeout(() => {
|
|
21
|
+
timeout = undefined;
|
|
22
|
+
if (!immediate) {
|
|
23
|
+
func.apply(context, args);
|
|
24
|
+
}
|
|
25
|
+
}, wait);
|
|
26
|
+
if (callNow) {
|
|
27
|
+
func.apply(context, args);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function resizeCanvas(canvas) {
|
|
32
|
+
if (!canvas) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const dpr = window.devicePixelRatio || 1;
|
|
36
|
+
const {
|
|
37
|
+
height,
|
|
38
|
+
width
|
|
39
|
+
} = canvas.getBoundingClientRect();
|
|
40
|
+
canvas.setAttribute("height", (height * dpr).toString());
|
|
41
|
+
canvas.setAttribute("width", (width * dpr).toString());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line import/no-default-export
|
|
45
|
+
function WebGPUViewNativeComponent(props) {
|
|
46
|
+
const {
|
|
47
|
+
contextId,
|
|
48
|
+
style,
|
|
49
|
+
transparent,
|
|
50
|
+
...rest
|
|
51
|
+
} = props;
|
|
52
|
+
const canvasElm = (0, _react.useRef)();
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
const onResize = debounce(() => resizeCanvas(canvasElm.current ?? null), 100);
|
|
55
|
+
window.addEventListener("resize", onResize);
|
|
56
|
+
return () => {
|
|
57
|
+
window.removeEventListener("resize", onResize);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement("canvas", {
|
|
61
|
+
...rest,
|
|
62
|
+
id: (0, _utils.contextIdToId)(contextId),
|
|
63
|
+
style: {
|
|
64
|
+
...styles.view,
|
|
65
|
+
...styles.flex1,
|
|
66
|
+
...(transparent === false ? {
|
|
67
|
+
backgroundColor: "white"
|
|
68
|
+
} : {}),
|
|
69
|
+
...(typeof style === "object" ? style : {})
|
|
70
|
+
},
|
|
71
|
+
ref: ref => {
|
|
72
|
+
canvasElm.current = ref;
|
|
73
|
+
if (ref) {
|
|
74
|
+
resizeCanvas(ref);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const styles = _reactNative.StyleSheet.create({
|
|
80
|
+
flex1: {
|
|
81
|
+
flex: 1
|
|
82
|
+
},
|
|
83
|
+
view: {
|
|
84
|
+
alignItems: "stretch",
|
|
85
|
+
backgroundColor: "transparent",
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-expect-error
|
|
88
|
+
border: "0 solid black",
|
|
89
|
+
boxSizing: "border-box",
|
|
90
|
+
display: "flex",
|
|
91
|
+
flexBasis: "auto",
|
|
92
|
+
flexDirection: "column",
|
|
93
|
+
flexShrink: 0,
|
|
94
|
+
listStyle: "none",
|
|
95
|
+
margin: 0,
|
|
96
|
+
minHeight: 0,
|
|
97
|
+
minWidth: 0,
|
|
98
|
+
padding: 0,
|
|
99
|
+
position: "relative",
|
|
100
|
+
zIndex: 0
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=WebGPUViewNativeComponent.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","useRef","useEffect","onResize","current","addEventListener","removeEventListener","React","createElement","id","contextIdToId","styles","view","flex1","backgroundColor","ref","StyleSheet","create","flex","alignItems","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","zIndex"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,MAAA,GAAAF,OAAA;AAAwC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,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,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,GAAG;MACvB,IAAIA,GAAG,EAAE;QACP/B,YAAY,CAAC+B,GAAG,CAAC;MACnB;IACF;EACF,CAAC,CAAC;AACJ;AAEA,MAAMJ,MAAM,GAAGK,uBAAU,CAACC,MAAM,CAAC;EAC/BJ,KAAK,EAAE;IACLK,IAAI,EAAE;EACR,CAAC;EACDN,IAAI,EAAE;IACJO,UAAU,EAAE,SAAS;IACrBL,eAAe,EAAE,aAAa;IAC9B;IACA;IACAM,MAAM,EAAE,eAAe;IACvBC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,MAAM;IACfC,SAAS,EAAE,MAAM;IACjBC,aAAa,EAAE,QAAQ;IACvBC,UAAU,EAAE,CAAC;IACbC,SAAS,EAAE,MAAM;IACjBC,MAAM,EAAE,CAAC;IACTC,SAAS,EAAE,CAAC;IACZC,QAAQ,EAAE,CAAC;IACXC,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
const fabric = true;
|
|
5
|
+
function getNativeSurface(contextId) {
|
|
6
|
+
const canvas = document.getElementById((0, _utils.contextIdToId)(contextId));
|
|
7
|
+
const {
|
|
8
|
+
height,
|
|
9
|
+
width
|
|
10
|
+
} = canvas.getBoundingClientRect();
|
|
11
|
+
return {
|
|
12
|
+
surface: BigInt(contextId),
|
|
13
|
+
height,
|
|
14
|
+
width,
|
|
15
|
+
clientHeight: height,
|
|
16
|
+
clientWidth: width
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function makeWebGPUCanvasContext(contextId, width, height) {
|
|
20
|
+
const canvas = document.getElementById((0, _utils.contextIdToId)(contextId));
|
|
21
|
+
const dpr = window.devicePixelRatio || 1;
|
|
22
|
+
const pixelWidth = (width * dpr).toString();
|
|
23
|
+
const pixelHeight = (height * dpr).toString();
|
|
24
|
+
if (canvas.getAttribute("width") !== pixelWidth || canvas.getAttribute("height") !== pixelHeight) {
|
|
25
|
+
canvas.setAttribute("width", pixelWidth);
|
|
26
|
+
canvas.setAttribute("height", pixelHeight);
|
|
27
|
+
}
|
|
28
|
+
const context = canvas.getContext("webgpu");
|
|
29
|
+
return Object.assign(context, {
|
|
30
|
+
present: () => {}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// @ts-expect-error - polyfill for RNWebGPU native module
|
|
35
|
+
window.RNWebGPU = {
|
|
36
|
+
getNativeSurface,
|
|
37
|
+
MakeWebGPUCanvasContext: makeWebGPUCanvasContext,
|
|
38
|
+
fabric
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=WebPolyfillGPUModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","fabric","getNativeSurface","contextId","canvas","document","getElementById","contextIdToId","height","width","getBoundingClientRect","surface","BigInt","clientHeight","clientWidth","makeWebGPUCanvasContext","dpr","window","devicePixelRatio","pixelWidth","toString","pixelHeight","getAttribute","setAttribute","context","getContext","Object","assign","present","RNWebGPU","MakeWebGPUCanvasContext"],"sourceRoot":"../../src","sources":["WebPolyfillGPUModule.ts"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,MAAM,GAAG,IAAI;AAEnB,SAASC,gBAAgBA,CAACC,SAAiB,EAAE;EAC3C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpC,IAAAC,oBAAa,EAACJ,SAAS,CACzB,CAAsB;EAEtB,MAAM;IAAEK,MAAM;IAAEC;EAAM,CAAC,GAAGL,MAAM,CAACM,qBAAqB,CAAC,CAAE;EAEzD,OAAO;IACLC,OAAO,EAAEC,MAAM,CAACT,SAAS,CAAC;IAC1BK,MAAM;IACNC,KAAK;IACLI,YAAY,EAAEL,MAAM;IACpBM,WAAW,EAAEL;EACf,CAAC;AACH;AAEA,SAASM,uBAAuBA,CAC9BZ,SAAiB,EACjBM,KAAa,EACbD,MAAc,EACd;EACA,MAAMJ,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpC,IAAAC,oBAAa,EAACJ,SAAS,CACzB,CAAsB;EAEtB,MAAMa,GAAG,GAAGC,MAAM,CAACC,gBAAgB,IAAI,CAAC;EACxC,MAAMC,UAAU,GAAG,CAACV,KAAK,GAAGO,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAC3C,MAAMC,WAAW,GAAG,CAACb,MAAM,GAAGQ,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAE7C,IACEhB,MAAM,CAACkB,YAAY,CAAC,OAAO,CAAC,KAAKH,UAAU,IAC3Cf,MAAM,CAACkB,YAAY,CAAC,QAAQ,CAAC,KAAKD,WAAW,EAC7C;IACAjB,MAAM,CAACmB,YAAY,CAAC,OAAO,EAAEJ,UAAU,CAAC;IACxCf,MAAM,CAACmB,YAAY,CAAC,QAAQ,EAAEF,WAAW,CAAC;EAC5C;EAEA,MAAMG,OAAO,GAAGpB,MAAM,CAACqB,UAAU,CAAC,QAAQ,CAAE;EAC5C,OAAOC,MAAM,CAACC,MAAM,CAACH,OAAO,EAAE;IAC5BI,OAAO,EAAEA,CAAA,KAAM,CAAC;EAClB,CAAC,CAAC;AACJ;;AAEA;AACAX,MAAM,CAACY,QAAQ,GAAG;EAChB3B,gBAAgB;EAChB4B,uBAAuB,EAAEf,uBAAuB;EAChDd;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createModuleProxy = exports.OptionalDependencyNotInstalledError = void 0;
|
|
7
|
+
// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/src/dependencies/ModuleProxy.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a lazily-imported module proxy.
|
|
11
|
+
* This is useful for lazily requiring optional dependencies.
|
|
12
|
+
*/
|
|
13
|
+
const createModuleProxy = getModule => {
|
|
14
|
+
const holder = {
|
|
15
|
+
module: undefined
|
|
16
|
+
};
|
|
17
|
+
const proxy = new Proxy(holder, {
|
|
18
|
+
get: (target, property) => {
|
|
19
|
+
if (target.module == null) {
|
|
20
|
+
// lazy initialize module via require()
|
|
21
|
+
// caller needs to make sure the require() call is wrapped in a try/catch
|
|
22
|
+
target.module = getModule();
|
|
23
|
+
}
|
|
24
|
+
return target.module[property];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return proxy;
|
|
28
|
+
};
|
|
29
|
+
exports.createModuleProxy = createModuleProxy;
|
|
30
|
+
class OptionalDependencyNotInstalledError extends Error {
|
|
31
|
+
constructor(name) {
|
|
32
|
+
super(`${name} is not installed!`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.OptionalDependencyNotInstalledError = OptionalDependencyNotInstalledError;
|
|
36
|
+
//# sourceMappingURL=ModuleProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createModuleProxy","getModule","holder","module","undefined","proxy","Proxy","get","target","property","exports","OptionalDependencyNotInstalledError","Error","constructor","name"],"sourceRoot":"../../../src","sources":["external/ModuleProxy.ts"],"mappings":";;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAC5BC,SAA2B,IACf;EACZ,MAAMC,MAAuC,GAAG;IAAEC,MAAM,EAAEC;EAAU,CAAC;EAErE,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAACJ,MAAM,EAAE;IAC9BK,GAAG,EAAEA,CAACC,MAAM,EAAEC,QAAQ,KAAK;MACzB,IAAID,MAAM,CAACL,MAAM,IAAI,IAAI,EAAE;QACzB;QACA;QACAK,MAAM,CAACL,MAAM,GAAGF,SAAS,CAAC,CAAY;MACxC;MACA,OAAOO,MAAM,CAACL,MAAM,CAACM,QAAQ,CAA+B;IAC9D;EACF,CAAC,CAAC;EACF,OAAOJ,KAAK;AACd,CAAC;AAACK,OAAA,CAAAV,iBAAA,GAAAA,iBAAA;AAEK,MAAMW,mCAAmC,SAASC,KAAK,CAAC;EAC7DC,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK,CAAC,GAAGA,IAAI,oBAAoB,CAAC;EACpC;AACF;AAACJ,OAAA,CAAAC,mCAAA,GAAAA,mCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _reanimated = require("./reanimated");
|
|
7
|
+
Object.keys(_reanimated).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _reanimated[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _reanimated[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reanimated","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["external/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ModuleProxy = require("../ModuleProxy");
|
|
8
|
+
const Reanimated = (0, _ModuleProxy.createModuleProxy)(() => {
|
|
9
|
+
try {
|
|
10
|
+
return require("react-native-reanimated");
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw new _ModuleProxy.OptionalDependencyNotInstalledError("react-native-reanimated");
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line import/no-default-export
|
|
17
|
+
var _default = exports.default = Reanimated;
|
|
18
|
+
//# sourceMappingURL=ReanimatedProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ModuleProxy","require","Reanimated","createModuleProxy","e","OptionalDependencyNotInstalledError","_default","exports","default"],"sourceRoot":"../../../../src","sources":["external/reanimated/ReanimatedProxy.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAMC,UAAU,GAAG,IAAAC,8BAAiB,EAAc,MAAM;EACtD,IAAI;IACF,OAAOF,OAAO,CAAC,yBAAyB,CAAC;EAC3C,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,MAAM,IAAIC,gDAAmC,CAAC,yBAAyB,CAAC;EAC1E;AACF,CAAC,CAAC;;AAEF;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeN,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Reanimated", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ReanimatedProxy.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "registerWebGPUForReanimated", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _registerWebGPUForReanimated.registerWebGPUForReanimated;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _registerWebGPUForReanimated = require("./registerWebGPUForReanimated");
|
|
19
|
+
var _ReanimatedProxy = _interopRequireDefault(require("./ReanimatedProxy"));
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_registerWebGPUForReanimated","require","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default"],"sourceRoot":"../../../../src","sources":["external/reanimated/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,4BAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|