react-native-wgpu 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -14
- package/android/CMakeLists.txt +3 -3
- package/cpp/jsi/{RNFEnumMapper.h → EnumMapper.h} +2 -6
- package/cpp/jsi/{RNFJSIConverter.h → JSIConverter.h} +27 -110
- package/cpp/jsi/NativeObject.h +607 -0
- package/cpp/jsi/{RNFPromise.cpp → Promise.cpp} +3 -6
- package/cpp/jsi/{RNFPromise.h → Promise.h} +2 -5
- 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 +8 -12
- package/cpp/rnwgpu/RNWebGPUManager.cpp +187 -28
- package/cpp/rnwgpu/RNWebGPUManager.h +7 -0
- package/cpp/rnwgpu/api/Canvas.h +14 -12
- package/cpp/rnwgpu/api/GPU.cpp +4 -6
- package/cpp/rnwgpu/api/GPU.h +13 -11
- package/cpp/rnwgpu/api/GPUAdapter.cpp +9 -9
- package/cpp/rnwgpu/api/GPUAdapter.h +14 -11
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +17 -15
- package/cpp/rnwgpu/api/GPUBindGroup.h +11 -10
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +12 -11
- package/cpp/rnwgpu/api/GPUBuffer.h +19 -16
- package/cpp/rnwgpu/api/GPUCanvasContext.h +17 -13
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +12 -10
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +35 -32
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +19 -19
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +10 -7
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +28 -27
- package/cpp/rnwgpu/api/GPUComputePipeline.h +14 -13
- package/cpp/rnwgpu/api/GPUDevice.cpp +111 -95
- package/cpp/rnwgpu/api/GPUDevice.h +51 -43
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +12 -10
- package/cpp/rnwgpu/api/GPUError.h +19 -29
- package/cpp/rnwgpu/api/GPUExtent3D.h +7 -10
- package/cpp/rnwgpu/api/GPUExternalTexture.h +12 -11
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +6 -10
- package/cpp/rnwgpu/api/GPUOrigin3D.h +6 -10
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +12 -10
- package/cpp/rnwgpu/api/GPUQuerySet.h +14 -12
- package/cpp/rnwgpu/api/GPUQueue.h +18 -17
- package/cpp/rnwgpu/api/GPURenderBundle.h +11 -10
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +36 -33
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +49 -47
- package/cpp/rnwgpu/api/GPURenderPipeline.h +14 -12
- package/cpp/rnwgpu/api/GPUSampler.h +11 -10
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +7 -8
- package/cpp/rnwgpu/api/GPUShaderModule.h +13 -12
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +73 -93
- package/cpp/rnwgpu/api/GPUTexture.h +24 -20
- package/cpp/rnwgpu/api/GPUTextureView.h +11 -10
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +10 -6
- package/cpp/rnwgpu/api/RNWebGPU.h +21 -21
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +7 -11
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +28 -32
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +18 -20
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +11 -14
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +14 -16
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +18 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/Unions.h +3 -3
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +10 -10
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +2 -2
- package/lib/commonjs/Canvas.js +9 -14
- package/lib/commonjs/Canvas.js.map +1 -1
- 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 +50 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/commonjs/main/index.js +2 -142
- package/lib/commonjs/main/index.js.map +1 -1
- package/lib/module/Canvas.js +10 -16
- package/lib/module/Canvas.js.map +1 -1
- 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 +43 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/module/main/index.js +2 -141
- package/lib/module/main/index.js.map +1 -1
- package/lib/typescript/babel.config.d.ts +1 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts +5 -1
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
- 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/module/Canvas.d.ts +6 -1
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- 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/src/Canvas.d.ts +4 -2
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- 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/package.json +15 -2
- package/src/Canvas.tsx +16 -22
- 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/main/index.tsx +3 -170
- package/cpp/jsi/RNFHybridObject.cpp +0 -150
- package/cpp/jsi/RNFHybridObject.h +0 -181
- package/cpp/jsi/RNFJSIHelper.h +0 -51
- package/cpp/jsi/RNFPointerHolder.h +0 -95
- package/cpp/jsi/RNFRuntimeState.cpp +0 -18
- package/cpp/jsi/RNFRuntimeState.h +0 -106
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function Canvas({ transparent, ref, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
transparent: any;
|
|
4
|
+
ref: any;
|
|
5
|
+
}): React.CElement<import("react-native").ViewProps, View>;
|
|
6
|
+
import { View } from "react-native";
|
|
2
7
|
import React from "react";
|
|
3
8
|
//# sourceMappingURL=Canvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AAQO;;;;2DAoCN;qBA1CoB,cAAc;kBAD0B,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleProxy.d.ts","sourceRoot":"","sources":["../../../../module/external/ModuleProxy.js"],"names":[],"mappings":"AAMO;;EAeN;AACD;IACE,uBAEC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../module/external/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReanimatedProxy.d.ts","sourceRoot":"","sources":["../../../../../module/external/reanimated/ReanimatedProxy.js"],"names":[],"mappings":";AACA;;EAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../module/external/reanimated/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWebGPUForReanimated.d.ts","sourceRoot":"","sources":["../../../../../module/external/reanimated/registerWebGPUForReanimated.js"],"names":[],"mappings":"AAUO,oDA+BN"}
|
|
@@ -26,8 +26,10 @@ export interface CanvasRef {
|
|
|
26
26
|
getContext(contextName: "webgpu"): RNCanvasContext | null;
|
|
27
27
|
getNativeSurface: () => NativeCanvas;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
interface CanvasProps extends ViewProps {
|
|
30
30
|
transparent?: boolean;
|
|
31
|
-
|
|
31
|
+
ref?: React.Ref<CanvasRef>;
|
|
32
|
+
}
|
|
33
|
+
export declare const Canvas: ({ transparent, ref, ...props }: CanvasProps) => React.JSX.Element;
|
|
32
34
|
export {};
|
|
33
35
|
//# sourceMappingURL=Canvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,QAAQ,EAAE;QACZ,GAAG,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,CAAC;QACtD,uBAAuB,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,eAAe,CAAC;QACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,GAAG,WAAW,KAAK,MAAM,CAAC;QACvE,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;KAC7C,CAAC;CACH;AAED,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACtC;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,MAAM,GAAI,gCAAgC,WAAW,sBAuCjE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ImportType = ReturnType<typeof require>;
|
|
2
|
+
/**
|
|
3
|
+
* Create a lazily-imported module proxy.
|
|
4
|
+
* This is useful for lazily requiring optional dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createModuleProxy: <TModule>(getModule: () => ImportType) => TModule;
|
|
7
|
+
export declare class OptionalDependencyNotInstalledError extends Error {
|
|
8
|
+
constructor(name: string);
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ModuleProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleProxy.d.ts","sourceRoot":"","sources":["../../../../src/external/ModuleProxy.ts"],"names":[],"mappings":"AACA,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,EACvC,WAAW,MAAM,UAAU,KAC1B,OAcF,CAAC;AAEF,qBAAa,mCAAoC,SAAQ,KAAK;gBAChD,IAAI,EAAE,MAAM;CAGzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/external/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReanimatedProxy.d.ts","sourceRoot":"","sources":["../../../../../src/external/reanimated/ReanimatedProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAS5D,QAAA,MAAM,UAAU,oBAMd,CAAC;AAGH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/external/reanimated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register WebGPU objects for Worklets serialization.
|
|
3
|
+
* This allows GPUDevice, GPUCanvasContext, etc. to be passed to worklets.
|
|
4
|
+
*
|
|
5
|
+
* This is called automatically when the module loads if react-native-worklets is installed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const registerWebGPUForReanimated: () => void;
|
|
8
|
+
//# sourceMappingURL=registerWebGPUForReanimated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWebGPUForReanimated.d.ts","sourceRoot":"","sources":["../../../../../src/external/reanimated/registerWebGPUForReanimated.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YA4BvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@types/seedrandom": "^3.0.8",
|
|
66
66
|
"@types/ws": "^8.5.10",
|
|
67
67
|
"@webgpu/types": "0.1.65",
|
|
68
|
+
"baseline-browser-mapping": "^2.9.14",
|
|
68
69
|
"clang-format": "^1.8.0",
|
|
69
70
|
"del-cli": "^5.1.0",
|
|
70
71
|
"eslint": "9.35.0",
|
|
@@ -81,7 +82,9 @@
|
|
|
81
82
|
"react": "19.1.0",
|
|
82
83
|
"react-native": "0.81.4",
|
|
83
84
|
"react-native-builder-bob": "^0.23.2",
|
|
85
|
+
"react-native-reanimated": "^3.16.0",
|
|
84
86
|
"react-native-web": "^0.21.2",
|
|
87
|
+
"react-native-worklets": "^0.7.0",
|
|
85
88
|
"rimraf": "^5.0.7",
|
|
86
89
|
"seedrandom": "^3.0.5",
|
|
87
90
|
"teapot": "^1.0.0",
|
|
@@ -94,7 +97,17 @@
|
|
|
94
97
|
},
|
|
95
98
|
"peerDependencies": {
|
|
96
99
|
"react": "*",
|
|
97
|
-
"react-native": "*"
|
|
100
|
+
"react-native": "*",
|
|
101
|
+
"react-native-reanimated": ">=3.16.0",
|
|
102
|
+
"react-native-worklets": ">=0.7.0"
|
|
103
|
+
},
|
|
104
|
+
"peerDependenciesMeta": {
|
|
105
|
+
"react-native-reanimated": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"react-native-worklets": {
|
|
109
|
+
"optional": true
|
|
110
|
+
}
|
|
98
111
|
},
|
|
99
112
|
"react-native-builder-bob": {
|
|
100
113
|
"source": "src",
|
package/src/Canvas.tsx
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useImperativeHandle,
|
|
4
|
-
useRef,
|
|
5
|
-
useState,
|
|
6
|
-
} from "react";
|
|
1
|
+
import React, { useImperativeHandle, useRef, useState } from "react";
|
|
7
2
|
import type { ViewProps } from "react-native";
|
|
8
|
-
import {
|
|
3
|
+
import { View } from "react-native";
|
|
9
4
|
|
|
10
5
|
import WebGPUNativeView from "./WebGPUViewNativeComponent";
|
|
11
6
|
|
|
@@ -49,10 +44,12 @@ export interface CanvasRef {
|
|
|
49
44
|
getNativeSurface: () => NativeCanvas;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
interface CanvasProps extends ViewProps {
|
|
48
|
+
transparent?: boolean;
|
|
49
|
+
ref?: React.Ref<CanvasRef>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const Canvas = ({ transparent, ref, ...props }: CanvasProps) => {
|
|
56
53
|
const viewRef = useRef(null);
|
|
57
54
|
const [contextId, _] = useState(() => generateContextId());
|
|
58
55
|
useImperativeHandle(ref, () => ({
|
|
@@ -67,16 +64,13 @@ export const Canvas = forwardRef<
|
|
|
67
64
|
if (!viewRef.current) {
|
|
68
65
|
throw new Error("[WebGPU] Cannot get context before mount");
|
|
69
66
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// @ts-expect-error
|
|
78
|
-
size = viewRef.current.unstable_getBoundingClientRect();
|
|
79
|
-
}
|
|
67
|
+
// getBoundingClientRect became stable in RN 0.83
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
const view = viewRef.current as any;
|
|
70
|
+
const size =
|
|
71
|
+
"getBoundingClientRect" in view
|
|
72
|
+
? view.getBoundingClientRect()
|
|
73
|
+
: view.unstable_getBoundingClientRect();
|
|
80
74
|
return RNWebGPU.MakeWebGPUCanvasContext(
|
|
81
75
|
contextId,
|
|
82
76
|
size.width,
|
|
@@ -94,4 +88,4 @@ export const Canvas = forwardRef<
|
|
|
94
88
|
/>
|
|
95
89
|
</View>
|
|
96
90
|
);
|
|
97
|
-
}
|
|
91
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/src/dependencies/ModuleProxy.ts
|
|
2
|
+
type ImportType = ReturnType<typeof require>;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a lazily-imported module proxy.
|
|
6
|
+
* This is useful for lazily requiring optional dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export const createModuleProxy = <TModule>(
|
|
9
|
+
getModule: () => ImportType
|
|
10
|
+
): TModule => {
|
|
11
|
+
const holder: { module: TModule | undefined } = { module: undefined };
|
|
12
|
+
|
|
13
|
+
const proxy = new Proxy(holder, {
|
|
14
|
+
get: (target, property) => {
|
|
15
|
+
if (target.module == null) {
|
|
16
|
+
// lazy initialize module via require()
|
|
17
|
+
// caller needs to make sure the require() call is wrapped in a try/catch
|
|
18
|
+
target.module = getModule() as TModule;
|
|
19
|
+
}
|
|
20
|
+
return target.module[property as keyof typeof holder.module];
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return proxy as unknown as TModule;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export class OptionalDependencyNotInstalledError extends Error {
|
|
27
|
+
constructor(name: string) {
|
|
28
|
+
super(`${name} is not installed!`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./reanimated";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as ReanimatedT from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
OptionalDependencyNotInstalledError,
|
|
5
|
+
createModuleProxy,
|
|
6
|
+
} from "../ModuleProxy";
|
|
7
|
+
|
|
8
|
+
type TReanimated = typeof ReanimatedT;
|
|
9
|
+
|
|
10
|
+
const Reanimated = createModuleProxy<TReanimated>(() => {
|
|
11
|
+
try {
|
|
12
|
+
return require("react-native-reanimated");
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw new OptionalDependencyNotInstalledError("react-native-reanimated");
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line import/no-default-export
|
|
19
|
+
export default Reanimated;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Declare global WebGPU worklet helper functions (installed by native module)
|
|
2
|
+
declare function __webgpuIsWebGPUObject(obj: unknown): boolean;
|
|
3
|
+
declare function __webgpuBox(
|
|
4
|
+
obj: object
|
|
5
|
+
): { unbox: () => object; __boxedWebGPU: true };
|
|
6
|
+
|
|
7
|
+
let isRegistered = false;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Register WebGPU objects for Worklets serialization.
|
|
11
|
+
* This allows GPUDevice, GPUCanvasContext, etc. to be passed to worklets.
|
|
12
|
+
*
|
|
13
|
+
* This is called automatically when the module loads if react-native-worklets is installed.
|
|
14
|
+
*/
|
|
15
|
+
export const registerWebGPUForReanimated = () => {
|
|
16
|
+
if (isRegistered) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
isRegistered = true;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
23
|
+
const { registerCustomSerializable } = require("react-native-worklets");
|
|
24
|
+
|
|
25
|
+
registerCustomSerializable({
|
|
26
|
+
name: "WebGPU",
|
|
27
|
+
determine: (value: object): value is object => {
|
|
28
|
+
"worklet";
|
|
29
|
+
return __webgpuIsWebGPUObject(value);
|
|
30
|
+
},
|
|
31
|
+
pack: (value: object) => {
|
|
32
|
+
"worklet";
|
|
33
|
+
return __webgpuBox(value);
|
|
34
|
+
},
|
|
35
|
+
unpack: (boxed: { unbox: () => object }) => {
|
|
36
|
+
"worklet";
|
|
37
|
+
return boxed.unbox();
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
// react-native-worklets not installed, skip registration
|
|
42
|
+
}
|
|
43
|
+
};
|
package/src/main/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { registerWebGPUForReanimated } from "../external";
|
|
2
2
|
import WebGPUModule from "../NativeWebGPUModule";
|
|
3
3
|
|
|
4
4
|
export * from "../Canvas";
|
|
@@ -8,177 +8,10 @@ export * from "../hooks";
|
|
|
8
8
|
|
|
9
9
|
export { default as WebGPUModule } from "../NativeWebGPUModule";
|
|
10
10
|
|
|
11
|
-
const GPU: any = {};
|
|
12
|
-
GPU[Symbol.hasInstance] = function (instance: object) {
|
|
13
|
-
return "__brand" in instance && instance.__brand === "GPU";
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const GPUAdapter: any = {};
|
|
17
|
-
GPUAdapter[Symbol.hasInstance] = function (instance: object) {
|
|
18
|
-
return "__brand" in instance && instance.__brand === "GPUAdapter";
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const GPUAdapterInfo: any = {};
|
|
22
|
-
GPUAdapterInfo[Symbol.hasInstance] = function (instance: object) {
|
|
23
|
-
return "__brand" in instance && instance.__brand === "GPUAdapterInfo";
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const GPUBindGroup: any = {};
|
|
27
|
-
GPUBindGroup[Symbol.hasInstance] = function (instance: object) {
|
|
28
|
-
return "__brand" in instance && instance.__brand === "GPUBindGroup";
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const GPUBindGroupLayout: any = {};
|
|
32
|
-
GPUBindGroupLayout[Symbol.hasInstance] = function (instance: object) {
|
|
33
|
-
return "__brand" in instance && instance.__brand === "GPUBindGroupLayout";
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const GPUBuffer: any = {};
|
|
37
|
-
GPUBuffer[Symbol.hasInstance] = function (instance: object) {
|
|
38
|
-
return "__brand" in instance && instance.__brand === "GPUBuffer";
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const GPUCanvasContext: any = {};
|
|
42
|
-
GPUCanvasContext[Symbol.hasInstance] = function (instance: object) {
|
|
43
|
-
return "__brand" in instance && instance.__brand === "GPUCanvasContext";
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const GPUCommandBuffer: any = {};
|
|
47
|
-
GPUCommandBuffer[Symbol.hasInstance] = function (instance: object) {
|
|
48
|
-
return "__brand" in instance && instance.__brand === "GPUCommandBuffer";
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const GPUCommandEncoder: any = {};
|
|
52
|
-
GPUCommandEncoder[Symbol.hasInstance] = function (instance: object) {
|
|
53
|
-
return "__brand" in instance && instance.__brand === "GPUCommandEncoder";
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const GPUCompilationInfo: any = {};
|
|
57
|
-
GPUCompilationInfo[Symbol.hasInstance] = function (instance: object) {
|
|
58
|
-
return "__brand" in instance && instance.__brand === "GPUCompilationInfo";
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const GPUCompilationMessage: any = {};
|
|
62
|
-
GPUCompilationMessage[Symbol.hasInstance] = function (instance: object) {
|
|
63
|
-
return "__brand" in instance && instance.__brand === "GPUCompilationMessage";
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const GPUComputePassEncoder: any = {};
|
|
67
|
-
GPUComputePassEncoder[Symbol.hasInstance] = function (instance: object) {
|
|
68
|
-
return "__brand" in instance && instance.__brand === "GPUComputePassEncoder";
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const GPUComputePipeline: any = {};
|
|
72
|
-
GPUComputePipeline[Symbol.hasInstance] = function (instance: object) {
|
|
73
|
-
return "__brand" in instance && instance.__brand === "GPUComputePipeline";
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const GPUDevice: any = {};
|
|
77
|
-
GPUDevice[Symbol.hasInstance] = function (instance: object) {
|
|
78
|
-
return "__brand" in instance && instance.__brand === "GPUDevice";
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const GPUDeviceLostInfo: any = {};
|
|
82
|
-
GPUDeviceLostInfo[Symbol.hasInstance] = function (instance: object) {
|
|
83
|
-
return "__brand" in instance && instance.__brand === "GPUDeviceLostInfo";
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const GPUError: any = {};
|
|
87
|
-
GPUError[Symbol.hasInstance] = function (instance: object) {
|
|
88
|
-
return "__brand" in instance && instance.__brand === "GPUError";
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const GPUExternalTexture: any = {};
|
|
92
|
-
GPUExternalTexture[Symbol.hasInstance] = function (instance: object) {
|
|
93
|
-
return "__brand" in instance && instance.__brand === "GPUExternalTexture";
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const GPUPipelineLayout: any = {};
|
|
97
|
-
GPUPipelineLayout[Symbol.hasInstance] = function (instance: object) {
|
|
98
|
-
return "__brand" in instance && instance.__brand === "GPUPipelineLayout";
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const GPUQuerySet: any = {};
|
|
102
|
-
GPUQuerySet[Symbol.hasInstance] = function (instance: object) {
|
|
103
|
-
return "__brand" in instance && instance.__brand === "GPUQuerySet";
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const GPUQueue: any = {};
|
|
107
|
-
GPUQueue[Symbol.hasInstance] = function (instance: object) {
|
|
108
|
-
return "__brand" in instance && instance.__brand === "GPUQueue";
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const GPURenderBundle: any = {};
|
|
112
|
-
GPURenderBundle[Symbol.hasInstance] = function (instance: object) {
|
|
113
|
-
return "__brand" in instance && instance.__brand === "GPURenderBundle";
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const GPURenderBundleEncoder: any = {};
|
|
117
|
-
GPURenderBundleEncoder[Symbol.hasInstance] = function (instance: object) {
|
|
118
|
-
return "__brand" in instance && instance.__brand === "GPURenderBundleEncoder";
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const GPURenderPassEncoder: any = {};
|
|
122
|
-
GPURenderPassEncoder[Symbol.hasInstance] = function (instance: object) {
|
|
123
|
-
return "__brand" in instance && instance.__brand === "GPURenderPassEncoder";
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const GPURenderPipeline: any = {};
|
|
127
|
-
GPURenderPipeline[Symbol.hasInstance] = function (instance: object) {
|
|
128
|
-
return "__brand" in instance && instance.__brand === "GPURenderPipeline";
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const GPUSampler: any = {};
|
|
132
|
-
GPUSampler[Symbol.hasInstance] = function (instance: object) {
|
|
133
|
-
return "__brand" in instance && instance.__brand === "GPUSampler";
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const GPUShaderModule: any = {};
|
|
137
|
-
GPUShaderModule[Symbol.hasInstance] = function (instance: object) {
|
|
138
|
-
return "__brand" in instance && instance.__brand === "GPUShaderModule";
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const GPUTexture: any = {};
|
|
142
|
-
GPUTexture[Symbol.hasInstance] = function (instance: object) {
|
|
143
|
-
return "__brand" in instance && instance.__brand === "GPUTexture";
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const GPUTextureView: any = {};
|
|
147
|
-
GPUTextureView[Symbol.hasInstance] = function (instance: object) {
|
|
148
|
-
return "__brand" in instance && instance.__brand === "GPUTextureView";
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
global.GPU = GPU;
|
|
152
|
-
global.GPUAdapter = GPUAdapter;
|
|
153
|
-
global.GPUAdapterInfo = GPUAdapterInfo;
|
|
154
|
-
global.GPUBindGroup = GPUBindGroup;
|
|
155
|
-
global.GPUBindGroupLayout = GPUBindGroupLayout;
|
|
156
|
-
global.GPUBuffer = GPUBuffer;
|
|
157
|
-
global.GPUCanvasContext = GPUCanvasContext;
|
|
158
|
-
global.GPUCommandBuffer = GPUCommandBuffer;
|
|
159
|
-
global.GPUCommandEncoder = GPUCommandEncoder;
|
|
160
|
-
global.GPUCompilationInfo = GPUCompilationInfo;
|
|
161
|
-
global.GPUCompilationMessage = GPUCompilationMessage;
|
|
162
|
-
global.GPUComputePassEncoder = GPUComputePassEncoder;
|
|
163
|
-
global.GPUComputePipeline = GPUComputePipeline;
|
|
164
|
-
global.GPUDevice = GPUDevice;
|
|
165
|
-
global.GPUDeviceLostInfo = GPUDeviceLostInfo;
|
|
166
|
-
global.GPUError = GPUError;
|
|
167
|
-
global.GPUExternalTexture = GPUExternalTexture;
|
|
168
|
-
global.GPUPipelineLayout = GPUPipelineLayout;
|
|
169
|
-
global.GPUQuerySet = GPUQuerySet;
|
|
170
|
-
global.GPUQueue = GPUQueue;
|
|
171
|
-
global.GPURenderBundle = GPURenderBundle;
|
|
172
|
-
global.GPURenderBundleEncoder = GPURenderBundleEncoder;
|
|
173
|
-
global.GPURenderPassEncoder = GPURenderPassEncoder;
|
|
174
|
-
global.GPURenderPipeline = GPURenderPipeline;
|
|
175
|
-
global.GPUSampler = GPUSampler;
|
|
176
|
-
global.GPUShaderModule = GPUShaderModule;
|
|
177
|
-
global.GPUTexture = GPUTexture;
|
|
178
|
-
global.GPUTextureView = GPUTextureView;
|
|
179
|
-
|
|
180
11
|
WebGPUModule.install();
|
|
181
12
|
|
|
13
|
+
registerWebGPUForReanimated();
|
|
14
|
+
|
|
182
15
|
if (!navigator) {
|
|
183
16
|
// @ts-expect-error Navigation object is more complex than this, setting it to an empty object to add gpu property
|
|
184
17
|
navigator = {
|