react-native-webgpu 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/android/build.gradle +11 -1
  2. package/android/src/main/java/com/webgpu/BackingViewKind.java +38 -0
  3. package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +19 -2
  4. package/android/src/main/java/com/webgpu/WebGPUView.java +115 -63
  5. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +13 -6
  6. package/cpp/jsi/NativeObject.h +84 -34
  7. package/cpp/rnwgpu/RNWebGPUManager.cpp +51 -48
  8. package/cpp/rnwgpu/RNWebGPUManager.h +10 -0
  9. package/cpp/rnwgpu/api/GPUFeatures.h +1 -0
  10. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.h +1 -0
  11. package/cpp/rnwgpu/api/VideoFrame.h +2 -2
  12. package/lib/commonjs/Canvas.js +105 -8
  13. package/lib/commonjs/Canvas.js.map +1 -1
  14. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -1
  15. package/lib/commonjs/WebGPUViewNativeComponent.web.js +3 -5
  16. package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -1
  17. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -1
  18. package/lib/commonjs/install.js +26 -7
  19. package/lib/commonjs/install.js.map +1 -1
  20. package/lib/commonjs/mock.js +0 -1
  21. package/lib/commonjs/mock.js.map +1 -1
  22. package/lib/module/Canvas.js +105 -8
  23. package/lib/module/Canvas.js.map +1 -1
  24. package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
  25. package/lib/module/WebGPUViewNativeComponent.web.js +3 -5
  26. package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -1
  27. package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -1
  28. package/lib/module/install.js +26 -7
  29. package/lib/module/install.js.map +1 -1
  30. package/lib/module/mock.js +0 -1
  31. package/lib/module/mock.js.map +1 -1
  32. package/lib/typescript/lib/commonjs/Canvas.d.ts +1 -2
  33. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
  34. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  35. package/lib/typescript/lib/commonjs/install.d.ts +10 -7
  36. package/lib/typescript/lib/commonjs/install.d.ts.map +1 -1
  37. package/lib/typescript/lib/commonjs/mock.d.ts +1 -2
  38. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  39. package/lib/typescript/lib/module/Canvas.d.ts +1 -2
  40. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  41. package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  42. package/lib/typescript/lib/module/install.d.ts.map +1 -1
  43. package/lib/typescript/lib/module/mock.d.ts +1 -2
  44. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  45. package/lib/typescript/src/Canvas.d.ts +62 -16
  46. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  47. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +3 -2
  48. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  49. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +3 -2
  50. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  51. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +1 -0
  52. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -1
  53. package/lib/typescript/src/install.d.ts +10 -7
  54. package/lib/typescript/src/install.d.ts.map +1 -1
  55. package/lib/typescript/src/mock.d.ts +2 -2
  56. package/lib/typescript/src/mock.d.ts.map +1 -1
  57. package/lib/typescript/src/types.d.ts +1 -1
  58. package/package.json +8 -7
  59. package/plugin/build/index.js +2 -1
  60. package/plugin/build/setMinSdkVersion.d.ts +9 -0
  61. package/plugin/build/setMinSdkVersion.js +25 -0
  62. package/plugin/build/withMinSdkVersion.d.ts +11 -0
  63. package/plugin/build/withMinSdkVersion.js +20 -0
  64. package/src/Canvas.tsx +176 -33
  65. package/src/WebGPUViewNativeComponent.ts +6 -4
  66. package/src/WebGPUViewNativeComponent.web.ts +7 -5
  67. package/src/external/reanimated/registerWebGPUForReanimated.ts +4 -0
  68. package/src/index.tsx +3 -3
  69. package/src/install.ts +26 -7
  70. package/src/mock.ts +5 -7
  71. package/src/types.ts +1 -1
@@ -22,14 +22,25 @@ const constants = {
22
22
  // runtime installs the GPU prototype there.
23
23
  const gpu = typeof RNWebGPU === "undefined" ? undefined : RNWebGPU.gpu;
24
24
 
25
+ // The native half of the worklet serializer (see registerWebGPUForReanimated),
26
+ // read from the main runtime like `gpu` above and captured into the worklet
27
+ // closure: worklets hands a HostObject to every runtime by reference, so it is
28
+ // callable on the target runtime without installing anything there. Its
29
+ // installConstructors() installs the WebGPU class constructors on the runtime
30
+ // that calls it. Undefined on web and node, where the native module is not
31
+ // installed.
32
+ const helpers = globalThis.__webgpuWorkletHelpers;
33
+
25
34
  /**
26
35
  * Install WebGPU on the runtime that calls it.
27
36
  *
28
37
  * The native module sets up WebGPU on the main JS runtime, but worklet
29
38
  * runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
30
- * processors) start without it: `navigator.gpu` and the flag constants
39
+ * processors) start without it: `navigator.gpu`, the flag constants
31
40
  * (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
32
- * `GPUMapMode`) are all `undefined` there.
41
+ * `GPUMapMode`) and the class constructors (`GPUBuffer`, `GPUTexture`,
42
+ * `GPURenderBundleEncoder`, ...) are all `undefined` there. Without the
43
+ * constructors, `instanceof` against a WebGPU class throws a ReferenceError.
33
44
  *
34
45
  * Call `installWebGPU()` once at the top of a worklet to make them available:
35
46
  *
@@ -58,12 +69,13 @@ const gpu = typeof RNWebGPU === "undefined" ? undefined : RNWebGPU.gpu;
58
69
  * Observe those on a device created on the main JS thread.
59
70
  *
60
71
  * Everything is captured into the worklet by closure: the constants like a
61
- * shader string would be, and the GPU object through the Worklets custom
72
+ * shader string would be, the GPU object through the Worklets custom
62
73
  * serializer, which installs the native prototypes on the target runtime when
63
- * it crosses. Promises returned by `requestAdapter`/`requestDevice` settle on
64
- * the calling runtime (each runtime gets its own async pump). Calling it on a
65
- * runtime that already has the globals (e.g. the main JS runtime) is a safe
66
- * no-op.
74
+ * it crosses, and the native helper that installs the class constructors,
75
+ * which worklets hands to every runtime by reference. Promises returned by
76
+ * `requestAdapter`/`requestDevice` settle on the calling runtime (each
77
+ * runtime gets its own async pump). Calling it on a runtime that already has
78
+ * the globals (e.g. the main JS runtime) is a safe no-op.
67
79
  */
68
80
  export const installWebGPU = () => {
69
81
  "worklet";
@@ -85,5 +97,12 @@ export const installWebGPU = () => {
85
97
  nav.gpu = gpu;
86
98
  }
87
99
  }
100
+ // The class constructors, so `instanceof` works against any WebGPU class on
101
+ // this runtime (three.js checks `pass instanceof GPURenderBundleEncoder` on
102
+ // every render, for instance). Unboxing an object installs only its own
103
+ // class; this installs the rest and skips the ones already there.
104
+ if (helpers !== undefined) {
105
+ helpers.installConstructors();
106
+ }
88
107
  };
89
108
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GPUBufferUsage","GPUColorWrite","GPUMapMode","GPUShaderStage","GPUTextureUsage","constants","gpu","RNWebGPU","undefined","installWebGPU","g","globalThis","key","value","Object","entries","nav","navigator","userAgent"],"sourceRoot":"../../src","sources":["install.ts"],"mappings":"AAAA;AACA,SACEA,cAAc,EACdC,aAAa,EACbC,UAAU,EACVC,cAAc,EACdC,eAAe,QACV,aAAa;;AAEpB;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG;EAChBL,cAAc;EACdI,eAAe;EACfD,cAAc;EACdF,aAAa;EACbC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,GAAoB,GACxB,OAAOC,QAAQ,KAAK,WAAW,GAAGC,SAAS,GAAGD,QAAQ,CAACD,GAAG;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,aAAa,GAAGA,CAAA,KAAM;EACjC,SAAS;;EACT,MAAMC,CAAC,GAAGC,UAAgD;EAC1D,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACV,SAAS,CAAC,EAAE;IACpD,IAAIK,CAAC,CAACE,GAAG,CAAC,KAAKJ,SAAS,EAAE;MACxBE,CAAC,CAACE,GAAG,CAAC,GAAGC,KAAK;IAChB;EACF;EACA,IAAIP,GAAG,KAAKE,SAAS,EAAE;IACrB,MAAMQ,GAAG,GAAGN,CAAC,CAACO,SAA0D;IACxE,IAAID,GAAG,KAAKR,SAAS,EAAE;MACrBE,CAAC,CAACO,SAAS,GAAG;QAAEX,GAAG;QAAEY,SAAS,EAAE;MAAe,CAAC;IAClD,CAAC,MAAM,IAAIF,GAAG,CAACV,GAAG,KAAKE,SAAS,EAAE;MAChCQ,GAAG,CAACV,GAAG,GAAGA,GAAG;IACf;EACF;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["GPUBufferUsage","GPUColorWrite","GPUMapMode","GPUShaderStage","GPUTextureUsage","constants","gpu","RNWebGPU","undefined","helpers","globalThis","__webgpuWorkletHelpers","installWebGPU","g","key","value","Object","entries","nav","navigator","userAgent","installConstructors"],"sourceRoot":"../../src","sources":["install.ts"],"mappings":"AAAA;AACA,SACEA,cAAc,EACdC,aAAa,EACbC,UAAU,EACVC,cAAc,EACdC,eAAe,QACV,aAAa;;AAEpB;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG;EAChBL,cAAc;EACdI,eAAe;EACfD,cAAc;EACdF,aAAa;EACbC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,GAAoB,GACxB,OAAOC,QAAQ,KAAK,WAAW,GAAGC,SAAS,GAAGD,QAAQ,CAACD,GAAG;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAGC,UAAU,CAACC,sBAAsB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,SAAS;;EACT,MAAMC,CAAC,GAAGH,UAAgD;EAC1D,KAAK,MAAM,CAACI,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACZ,SAAS,CAAC,EAAE;IACpD,IAAIQ,CAAC,CAACC,GAAG,CAAC,KAAKN,SAAS,EAAE;MACxBK,CAAC,CAACC,GAAG,CAAC,GAAGC,KAAK;IAChB;EACF;EACA,IAAIT,GAAG,KAAKE,SAAS,EAAE;IACrB,MAAMU,GAAG,GAAGL,CAAC,CAACM,SAA0D;IACxE,IAAID,GAAG,KAAKV,SAAS,EAAE;MACrBK,CAAC,CAACM,SAAS,GAAG;QAAEb,GAAG;QAAEc,SAAS,EAAE;MAAe,CAAC;IAClD,CAAC,MAAM,IAAIF,GAAG,CAACZ,GAAG,KAAKE,SAAS,EAAE;MAChCU,GAAG,CAACZ,GAAG,GAAGA,GAAG;IACf;EACF;EACA;EACA;EACA;EACA;EACA,IAAIG,OAAO,KAAKD,SAAS,EAAE;IACzBC,OAAO,CAACY,mBAAmB,CAAC,CAAC;EAC/B;AACF,CAAC","ignoreList":[]}
@@ -71,7 +71,6 @@ export const GPUMapMode = {
71
71
  const NOT_AVAILABLE_UNDER_JEST = "is not available under Jest - react-native-webgpu has no native implementation in tests (see react-native-webgpu/jestSetup.js)";
72
72
  // Strip the same props the real Canvas keeps off its outer View.
73
73
  export const Canvas = ({
74
- opaque: _opaque,
75
74
  android: _android,
76
75
  ref,
77
76
  ...props
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","GPUBufferUsage","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","INDEX","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE","GPUTextureUsage","TEXTURE_BINDING","STORAGE_BINDING","RENDER_ATTACHMENT","TRANSIENT_ATTACHMENT","GPUShaderStage","FRAGMENT","COMPUTE","GPUColorWrite","RED","GREEN","BLUE","ALPHA","ALL","GPUMapMode","READ","WRITE","g","globalThis","key","value","Object","entries","undefined","NOT_AVAILABLE_UNDER_JEST","Canvas","opaque","_opaque","android","_android","ref","props","useImperativeHandle","getContextId","getContext","_contextName","getNativeSurface","Error","createElement","useCanvasRef","useRef","useSurface","surface","warnIfNotHardwareAccelerated","useDevice","adapter","device","GPUDeviceProvider","children","useMainDevice","importDevice","_pointer","adoptTexture","installWebGPU","WebGPUModule","install"],"sourceRoot":"../../src","sources":["mock.ts"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,IAAI,QAAQ,cAAc;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,WAAW;;AAEzB;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAA8B,GAAG;EAC5CC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,MAAM;EACjBC,QAAQ,EAAE,MAAM;EAChBC,QAAQ,EAAE,MAAM;EAChBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAE,MAAM;EACfC,OAAO,EAAE,MAAM;EACfC,QAAQ,EAAE,MAAM;EAChBC,aAAa,EAAE;AACjB,C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X","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE","GPUTextureUsage","TEXTURE_BINDING","STORAGE_BINDING","RENDER_ATTACHMENT","TRANSIENT_ATTACHMENT","GPUShaderStage","FRAGMENT","COMPUTE","GPUColorWrite","RED","GREEN","BLUE","ALPHA","ALL","GPUMapMode","READ","WRITE","g","globalThis","key","value","Object","entries","undefined","NOT_AVAILABLE_UNDER_JEST","Canvas","android","_android","ref","props","useImperativeHandle","getContextId","getContext","_contextName","getNativeSurface","Error","createElement","useCanvasRef","useRef","useSurface","surface","warnIfNotHardwareAccelerated","useDevice","adapter","device","GPUDeviceProvider","children","useMainDevice","importDevice","_pointer","adoptTexture","installWebGPU","WebGPUModule","install"],"sourceRoot":"../../src","sources":["mock.ts"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,IAAI,QAAQ,cAAc;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,WAAW;;AAEzB;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAA8B,GAAG;EAC5CC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,MAAM;EACjBC,QAAQ,EAAE,MAAM;EAChBC,QAAQ,EAAE,MAAM;EAChBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAE,MAAM;EACfC,OAAO,EAAE,MAAM;EACfC,QAAQ,EAAE,MAAM;EAChBC,aAAa,EAAE;AACjB,CAAC;AAED,OAAO,MAAMC,eAAgC,GAAG;EAC9CR,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE,IAAI;EACdQ,eAAe,EAAE,IAAI;EACrBC,eAAe,EAAE,IAAI;EACrBC,iBAAiB,EAAE,IAAI;EACvBC,oBAAoB,EAAE;AACxB,CAAC;AAED,OAAO,MAAMC,cAA8B,GAAG;EAC5CV,MAAM,EAAE,GAAG;EACXW,QAAQ,EAAE,GAAG;EACbC,OAAO,EAAE;AACX,C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AM,CAAC,IAAI,CAAC;EAAEE,OAAO,EAAE;AAAK,CAAC,CAAC;AAC5E,OAAO,MAAMC,4BAA4B,GAAGA,CAAA,KAAMlB,SAAS;AAE3D,OAAO,MAAMmB,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE,IAAI;EAAEC,MAAM,EAAE;AAAK,CAAC,CAAC;AAEhE,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC;AAAmC,CAAC,KACtEA,QAAQ,IAAI,IAAI;AAElB,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAa;EACxC,MAAM,IAAIZ,KAAK,CAAC,mBAAmBX,wBAAwB,EAAE,CAAC;AAChE,CAAC;AAED,OAAO,MAAMwB,YAAY,GAAIC,QAAgB,IAAgB;EAC3D,MAAM,IAAId,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAM0B,YAAY,GAAID,QAAgB,IAAiB;EAC5D,MAAM,IAAId,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAM2B,aAAa,GAAGA,CAAA,KAAM5B,SAAS;AAE5C,OAAO,MAAM6B,YAAY,GAAG;EAAEC,OAAO,EAAEA,CAAA,KAAM;AAAM,CAAC","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  export const __esModule: boolean;
2
- export function Canvas({ opaque, android, ref, ...props }: {
2
+ export function Canvas({ android, ref, ...props }: {
3
3
  [x: string]: any;
4
- opaque?: boolean | undefined;
5
4
  android: any;
6
5
  ref: any;
7
6
  }): any;
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAiDA;;;;;QAiDC"}
1
+ {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAqJA;;;;QA8CC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../commonjs/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":";;AAWA,4DAyBC"}
1
+ {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../commonjs/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":";;AAWA,4DAuBC"}
@@ -4,9 +4,11 @@ export const __esModule: boolean;
4
4
  *
5
5
  * The native module sets up WebGPU on the main JS runtime, but worklet
6
6
  * runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
7
- * processors) start without it: `navigator.gpu` and the flag constants
7
+ * processors) start without it: `navigator.gpu`, the flag constants
8
8
  * (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
9
- * `GPUMapMode`) are all `undefined` there.
9
+ * `GPUMapMode`) and the class constructors (`GPUBuffer`, `GPUTexture`,
10
+ * `GPURenderBundleEncoder`, ...) are all `undefined` there. Without the
11
+ * constructors, `instanceof` against a WebGPU class throws a ReferenceError.
10
12
  *
11
13
  * Call `installWebGPU()` once at the top of a worklet to make them available:
12
14
  *
@@ -35,12 +37,13 @@ export const __esModule: boolean;
35
37
  * Observe those on a device created on the main JS thread.
36
38
  *
37
39
  * Everything is captured into the worklet by closure: the constants like a
38
- * shader string would be, and the GPU object through the Worklets custom
40
+ * shader string would be, the GPU object through the Worklets custom
39
41
  * serializer, which installs the native prototypes on the target runtime when
40
- * it crosses. Promises returned by `requestAdapter`/`requestDevice` settle on
41
- * the calling runtime (each runtime gets its own async pump). Calling it on a
42
- * runtime that already has the globals (e.g. the main JS runtime) is a safe
43
- * no-op.
42
+ * it crosses, and the native helper that installs the class constructors,
43
+ * which worklets hands to every runtime by reference. Promises returned by
44
+ * `requestAdapter`/`requestDevice` settle on the calling runtime (each
45
+ * runtime gets its own async pump). Calling it on a runtime that already has
46
+ * the globals (e.g. the main JS runtime) is a safe no-op.
44
47
  */
45
48
  export function installWebGPU(): void;
46
49
  //# sourceMappingURL=install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../commonjs/install.js"],"names":[],"mappings":";AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,sCAoBC"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../commonjs/install.js"],"names":[],"mappings":";AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,sCA2BC"}
@@ -41,9 +41,8 @@ export namespace GPUMapMode {
41
41
  export namespace WebGPUModule {
42
42
  function install(): boolean;
43
43
  }
44
- export function Canvas({ opaque: _opaque, android: _android, ref, ...props }: {
44
+ export function Canvas({ android: _android, ref, ...props }: {
45
45
  [x: string]: any;
46
- opaque: any;
47
46
  android: any;
48
47
  ref: any;
49
48
  }): any;
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6JW,4BAAW;;AAjDtB;;;;;QAcC;AAED,oCAAsD;AAEtD;;;EAGE;AAEF,0DAAoD;AAEpD;;;EAGE;AAEF;;QAEsB;AAEtB,uCAEC;AAED,mDAEC;AAED,mDAEC;AAED,2CAAqC"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4JW,4BAAW;;AAhDtB;;;;QAaC;AAED,oCAAsD;AAEtD;;;EAGE;AAEF,0DAAoD;AAEpD;;;EAGE;AAEF;;QAEsB;AAEtB,uCAEC;AAED,mDAEC;AAED,mDAEC;AAED,2CAAqC"}
@@ -1,6 +1,5 @@
1
- export function Canvas({ opaque, android, ref, ...props }: {
1
+ export function Canvas({ android, ref, ...props }: {
2
2
  [x: string]: any;
3
- opaque?: boolean | undefined;
4
3
  android: any;
5
4
  ref: any;
6
5
  }): React.CElement<import("react-native").ViewProps, View>;
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AAyCO;;;;;2DAiDN;qBAxF8B,cAAc;kBAD2B,OAAO"}
1
+ {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AA6IO;;;;2DA8CN;qBAzL8B,cAAc;kBAD2B,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../module/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":"AAIA,gHAyBC;kBA7BiB,OAAO"}
1
+ {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../module/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":"AAIA,gHAuBC;kBA3BiB,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../module/install.js"],"names":[],"mappings":"AAmEO,sCAoBN"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../module/install.js"],"names":[],"mappings":"AA+EO,sCA2BN"}
@@ -38,9 +38,8 @@ export namespace GPUMapMode {
38
38
  let READ: number;
39
39
  let WRITE: number;
40
40
  }
41
- export function Canvas({ opaque: _opaque, android: _android, ref, ...props }: {
41
+ export function Canvas({ android: _android, ref, ...props }: {
42
42
  [x: string]: any;
43
- opaque: any;
44
43
  android: any;
45
44
  ref: any;
46
45
  }): React.CElement<import("react-native").ViewProps, View>;
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../module/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEO;;;;;2DAcN;AACM,6DAA6C;AAC7C;;;EAGL;AACK,0DAAoD;AACpD;;;EAGL;AACK;;QAEe;AACf,uCAEN;AACM,mDAEN;AACM,mDAEN;AACM,2CAAqC;;IAEjC,4BAAW;;qBA7GD,cAAc;kBADjB,OAAO"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../module/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEO;;;;2DAaN;AACM,6DAA6C;AAC7C;;;EAGL;AACK,0DAAoD;AACpD;;;EAGL;AACK;;QAEe;AACf,uCAEN;AACM,mDAEN;AACM,mDAEN;AACM,2CAAqC;;IAEjC,4BAAW;;qBA5GD,cAAc;kBADjB,OAAO"}
@@ -2,32 +2,78 @@ import React from "react";
2
2
  import type { ViewProps } from "react-native";
3
3
  import type { CanvasRef } from "./types";
4
4
  export type { CanvasRef, NativeCanvas, RNCanvasContext } from "./types";
5
- export type AndroidSurfaceType = "SurfaceView" | "TextureView" | "HardwareBufferView";
6
- export interface AndroidCanvasProps {
5
+ /** The Android view a canvas draws into, see {@link AndroidCanvasProps}. */
6
+ export type AndroidBackingView = "TextureView" | "SurfaceView" | "HardwareBufferView";
7
+ /** The options of a canvas backed by a `TextureView`, the default. */
8
+ export interface AndroidTextureViewProps {
7
9
  /**
8
- * Backing view. Defaults to `SurfaceView` when the canvas is opaque and to
9
- * `TextureView` otherwise; both composite correctly in React Native
10
- * stacking order without further flags. `HardwareBufferView` (Android 10+,
11
- * a plain View that draws each frame's AHardwareBuffer inline with no extra
12
- * copy) is opt-in and experimental; on older devices it uses `TextureView`.
10
+ * A `TextureView`: a regular view, composited like any other (parent
11
+ * transforms, clipping, alpha and z-order apply), at the price of an extra
12
+ * texture copy and typically a frame of latency. The default.
13
13
  */
14
- surfaceType?: AndroidSurfaceType;
14
+ backingView?: "TextureView";
15
15
  /**
16
- * SurfaceView only: composite above every React Native view in the window,
17
- * ignoring `zIndex`. Ignored for TextureView. Defaults to false.
16
+ * Declares that the canvas covers every pixel of its bounds, so the UI
17
+ * toolkit skips blending the view. Defaults to false. Applied in place.
18
+ */
19
+ opaque?: boolean;
20
+ }
21
+ /** The options of a canvas backed by a `SurfaceView`. */
22
+ export interface AndroidSurfaceViewProps {
23
+ /**
24
+ * A `SurfaceView`: each frame goes to the system compositor as its own
25
+ * layer, the fastest path, with no extra copy. It is not view content:
26
+ * parent transforms, clipping, rounded corners and z-order with sibling
27
+ * views do not apply to it.
28
+ */
29
+ backingView: "SurfaceView";
30
+ /**
31
+ * Declares that the canvas covers every pixel of its bounds, so the
32
+ * compositor skips blending the layer and can show it through a hardware
33
+ * overlay. Defaults to true: a translucent `SurfaceView` blends against
34
+ * what is below the window, usually black, rather than the React Native
35
+ * views beneath it (pair it with `zOrderOnTop`). Applied in place.
36
+ */
37
+ opaque?: boolean;
38
+ /**
39
+ * Composite above every React Native view in the window, ignoring
40
+ * `zIndex`. Defaults to false. Applied in place on Android 11 and later;
41
+ * read once, at mount, before that.
18
42
  */
19
43
  zOrderOnTop?: boolean;
44
+ /**
45
+ * Composite above the other `SurfaceView`s below the window (video players,
46
+ * other canvases), while staying below the window itself. Defaults to
47
+ * false; `zOrderOnTop` takes precedence. Applied in place on Android 11 and
48
+ * later; read once, at mount, before that.
49
+ */
50
+ zOrderMediaOverlay?: boolean;
20
51
  }
52
+ /** The options of a canvas backed by a `HardwareBufferView`. */
53
+ export interface AndroidHardwareBufferViewProps {
54
+ /**
55
+ * A plain view drawing each frame's `AHardwareBuffer` inline: composited
56
+ * like a `TextureView`, without its extra copy. Opt-in and experimental,
57
+ * on Android 10 and later; below that the canvas uses a `TextureView`,
58
+ * with a warning in development. Always composites with alpha.
59
+ */
60
+ backingView: "HardwareBufferView";
61
+ }
62
+ /**
63
+ * Android-only rendering options: the native view behind the canvas and its
64
+ * options. The view is created when the canvas mounts and kept: a change of
65
+ * `backingView` is ignored, with a warning in development; remount the canvas
66
+ * (with a `key`) to change it. `opaque` applies in place, and so do the
67
+ * z-order options on Android 11 and later. Ignored on iOS and web.
68
+ */
69
+ export type AndroidCanvasProps = AndroidTextureViewProps | AndroidSurfaceViewProps | AndroidHardwareBufferViewProps;
21
70
  export interface CanvasProps extends ViewProps {
22
71
  /**
23
- * Defaults to true. Set to false to alpha-composite the canvas over the
24
- * views behind it (pair it with `alphaMode: "premultiplied"` and an alpha-0
25
- * clear color). Android and web only; on iOS `alphaMode` alone controls it.
72
+ * Android-only rendering options: the native view behind the canvas and its
73
+ * options, see {@link AndroidCanvasProps}. Ignored on iOS and web.
26
74
  */
27
- opaque?: boolean;
28
- /** Android-only rendering options. Ignored on iOS and web. */
29
75
  android?: AndroidCanvasProps;
30
76
  ref?: React.Ref<CanvasRef>;
31
77
  }
32
- export declare const Canvas: ({ opaque, android, ref, ...props }: CanvasProps) => React.JSX.Element;
78
+ export declare const Canvas: ({ android, ref, ...props }: CanvasProps) => React.JSX.Element;
33
79
  //# sourceMappingURL=Canvas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AAG1D,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAOxE,MAAM,MAAM,kBAAkB,GAC5B,aAAa,GAAG,aAAa,GAAG,oBAAoB,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,kBAAkB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AE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAgID,eAAO,MAAM,MAAM,GAAI,4BAA4B,WAAW,sBAmD7D,CAAC"}
@@ -2,9 +2,10 @@ import type { Int32, WithDefault } from "react-native/Libraries/Types/CodegenTyp
2
2
  import type { ViewProps } from "react-native";
3
3
  export interface NativeProps extends ViewProps {
4
4
  contextId: Int32;
5
- opaque?: WithDefault<boolean, true>;
6
- androidSurfaceType?: WithDefault<"auto" | "SurfaceView" | "TextureView" | "HardwareBufferView", "auto">;
5
+ androidBackingView?: WithDefault<"TextureView" | "SurfaceView" | "HardwareBufferView", "TextureView">;
6
+ androidOpaque?: WithDefault<boolean, false>;
7
7
  androidZOrderOnTop?: WithDefault<boolean, false>;
8
+ androidZOrderMediaOverlay?: WithDefault<boolean, false>;
8
9
  }
9
10
  declare const _default: import("react-native").HostComponent<NativeProps>;
10
11
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACZ,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,kBAAkB,CAAC,EAAE,WAAW,CAC9B,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,oBAAoB,EAC7D,MAAM,CACP,CAAC;IACF,kBAAkB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAClD;;AAGD,wBAAiE"}
1
+ {"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACZ,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,KAAK,CAAC;IAEjB,kBAAkB,CAAC,EAAE,WAAW,CAC9B,aAAa,GAAG,aAAa,GAAG,oBAAoB,EACpD,aAAa,CACd,CAAC;IACF,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,kBAAkB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACjD,yBAAyB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CACzD;;AAGD,wBAAiE"}
@@ -3,9 +3,10 @@ import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
3
3
  import type { ViewProps } from "react-native";
4
4
  export interface NativeProps extends ViewProps {
5
5
  contextId: Int32;
6
- opaque?: boolean;
7
- androidSurfaceType?: "auto" | "SurfaceView" | "TextureView";
6
+ androidBackingView?: "TextureView" | "SurfaceView" | "HardwareBufferView";
7
+ androidOpaque?: boolean;
8
8
  androidZOrderOnTop?: boolean;
9
+ androidZOrderMediaOverlay?: boolean;
9
10
  }
10
11
  export default function WebGPUViewNativeComponent(props: NativeProps): React.JSX.Element;
11
12
  //# sourceMappingURL=WebGPUViewNativeComponent.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC;IAC5D,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAGD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,KAAK,EAAE,WAAW,GACjB,KAAK,CAAC,GAAG,CAAC,OAAO,CAuBnB"}
1
+ {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,KAAK,CAAC;IAEjB,kBAAkB,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,oBAAoB,CAAC;IAC1E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAGD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,KAAK,EAAE,WAAW,GACjB,KAAK,CAAC,GAAG,CAAC,OAAO,CAuBnB"}
@@ -1,6 +1,7 @@
1
1
  interface WebGPUWorkletHelpers {
2
2
  isNativeObject: (value: unknown) => boolean;
3
3
  box: (value: object) => BoxedWebGPUObject;
4
+ installConstructors: () => void;
4
5
  }
5
6
  interface BoxedWebGPUObject {
6
7
  unbox: () => object;
@@ -1 +1 @@
1
- {"version":3,"file":"registerWebGPUForReanimated.d.ts","sourceRoot":"","sources":["../../../../../src/external/reanimated/registerWebGPUForReanimated.ts"],"names":[],"mappings":"AAMA,UAAU,oBAAoB;IAI5B,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAC5C,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,CAAC;CAC3C;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;CACrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,sBAAsB,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC9D;AAID;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAiCvC,CAAC"}
1
+ {"version":3,"file":"registerWebGPUForReanimated.d.ts","sourceRoot":"","sources":["../../../../../src/external/reanimated/registerWebGPUForReanimated.ts"],"names":[],"mappings":"AAMA,UAAU,oBAAoB;IAI5B,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAC5C,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,CAAC;IAI1C,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;CACrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,sBAAsB,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC9D;AAID;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAiCvC,CAAC"}
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * The native module sets up WebGPU on the main JS runtime, but worklet
5
5
  * runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
6
- * processors) start without it: `navigator.gpu` and the flag constants
6
+ * processors) start without it: `navigator.gpu`, the flag constants
7
7
  * (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
8
- * `GPUMapMode`) are all `undefined` there.
8
+ * `GPUMapMode`) and the class constructors (`GPUBuffer`, `GPUTexture`,
9
+ * `GPURenderBundleEncoder`, ...) are all `undefined` there. Without the
10
+ * constructors, `instanceof` against a WebGPU class throws a ReferenceError.
9
11
  *
10
12
  * Call `installWebGPU()` once at the top of a worklet to make them available:
11
13
  *
@@ -34,12 +36,13 @@
34
36
  * Observe those on a device created on the main JS thread.
35
37
  *
36
38
  * Everything is captured into the worklet by closure: the constants like a
37
- * shader string would be, and the GPU object through the Worklets custom
39
+ * shader string would be, the GPU object through the Worklets custom
38
40
  * serializer, which installs the native prototypes on the target runtime when
39
- * it crosses. Promises returned by `requestAdapter`/`requestDevice` settle on
40
- * the calling runtime (each runtime gets its own async pump). Calling it on a
41
- * runtime that already has the globals (e.g. the main JS runtime) is a safe
42
- * no-op.
41
+ * it crosses, and the native helper that installs the class constructors,
42
+ * which worklets hands to every runtime by reference. Promises returned by
43
+ * `requestAdapter`/`requestDevice` settle on the calling runtime (each
44
+ * runtime gets its own async pump). Calling it on a runtime that already has
45
+ * the globals (e.g. the main JS runtime) is a safe no-op.
43
46
  */
44
47
  export declare const installWebGPU: () => void;
45
48
  //# sourceMappingURL=install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/install.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,aAAa,YAgBzB,CAAC"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/install.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,aAAa,YAuBzB,CAAC"}
@@ -8,8 +8,8 @@ export declare const GPUTextureUsage: GPUTextureUsage;
8
8
  export declare const GPUShaderStage: GPUShaderStage;
9
9
  export declare const GPUColorWrite: GPUColorWrite;
10
10
  export declare const GPUMapMode: GPUMapMode;
11
- export type { AndroidCanvasProps, AndroidSurfaceType, CanvasProps, CanvasRef, NativeCanvas, RNCanvasContext, } from "./Canvas";
12
- export declare const Canvas: ({ opaque: _opaque, android: _android, ref, ...props }: CanvasProps) => React.CElement<import("react-native").ViewProps, View>;
11
+ export type { AndroidBackingView, AndroidCanvasProps, AndroidHardwareBufferViewProps, AndroidSurfaceViewProps, AndroidTextureViewProps, CanvasProps, CanvasRef, NativeCanvas, RNCanvasContext, } from "./Canvas";
12
+ export declare const Canvas: ({ android: _android, ref, ...props }: CanvasProps) => React.CElement<import("react-native").ViewProps, View>;
13
13
  export declare const useCanvasRef: () => React.MutableRefObject<null>;
14
14
  export declare const useSurface: () => {
15
15
  ref: React.MutableRefObject<null>;
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAiC,MAAM,UAAU,CAAC;AAa3E,cAAc,WAAW,CAAC;AAM1B,eAAO,MAAM,cAAc,EAAE,cAW5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAO7B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAI5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAM3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAGxB,CAAC;AAoBF,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,MAAM,GAAI,uDAKpB,WAAW,2DASb,CAAC;AAEF,eAAO,MAAM,YAAY,oCAA2B,CAAC;AACrD,eAAO,MAAM,UAAU;;;CAAqD,CAAC;AAC7E,eAAO,MAAM,4BAA4B,iBAAkB,CAAC;AAE5D,eAAO,MAAM,SAAS;;;CAA0C,CAAC;AA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eAAO,MAAM,iBAAiB,GAAI,cAAc;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,sIACtD,CAAC;AAEnB,eAAO,MAAM,aAAa,QAAO,KAEhC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,SAE/C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,UAE/C,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC;AAE7C,eAAO,MAAM,YAAY;;CAA2B,CAAC"}
@@ -17,7 +17,7 @@ export type RNCanvasContext = GPUCanvasContext & {
17
17
  *
18
18
  * Call this after `queue.submit()` on every runtime: the main JS runtime, the
19
19
  * Reanimated UI runtime, and dedicated worklet runtimes (e.g.
20
- * `createWorkletRuntime` / `runOnRuntime`, or a Vision Camera frame
20
+ * `createWorkletRuntime` / `scheduleOnRuntime`, or a Vision Camera frame
21
21
  * processor). It runs synchronously on the calling thread, so the frame is
22
22
  * presented from whichever thread did the rendering.
23
23
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webgpu",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -24,7 +24,8 @@
24
24
  "app.plugin.js",
25
25
  "plugin/build/**"
26
26
  ],
27
- "dawn": "chrome-m154a",
27
+ "dawn": "chrome-m157",
28
+ "androidMinSdkVersion": 26,
28
29
  "scripts": {
29
30
  "test": "NODE_OPTIONS='--experimental-require-module' jest -i",
30
31
  "test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
@@ -91,12 +92,12 @@
91
92
  "pngjs": "^7.0.0",
92
93
  "prettier": "^3.0.3",
93
94
  "puppeteer": "24.43.1",
94
- "react": "19.1.0",
95
- "react-native": "0.81.4",
95
+ "react": "19.2.3",
96
+ "react-native": "0.83.10",
96
97
  "react-native-builder-bob": "^0.23.2",
97
- "react-native-reanimated": "^4.2.1",
98
+ "react-native-reanimated": "4.6.0",
98
99
  "react-native-web": "^0.21.2",
99
- "react-native-worklets": "0.8.3",
100
+ "react-native-worklets": "0.12.2",
100
101
  "rimraf": "^5.0.7",
101
102
  "seedrandom": "^3.0.5",
102
103
  "semantic-release": "^25.0.9",
@@ -110,7 +111,7 @@
110
111
  "yargs": "^17.7.2"
111
112
  },
112
113
  "dependencies": {
113
- "react-native-webgpu-dawn": "154.3.0"
114
+ "react-native-webgpu-dawn": "157.0.0"
114
115
  },
115
116
  "peerDependencies": {
116
117
  "react": "*",
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_plugins_1 = require("@expo/config-plugins");
4
4
  const withMetalApiValidation_1 = require("./withMetalApiValidation");
5
+ const withMinSdkVersion_1 = require("./withMinSdkVersion");
5
6
  const pkg = require("../../package.json");
6
- const withWebGPU = (config) => (0, withMetalApiValidation_1.withMetalApiValidationDisabled)(config);
7
+ const withWebGPU = (config) => (0, withMinSdkVersion_1.withMinSdkVersion)((0, withMetalApiValidation_1.withMetalApiValidationDisabled)(config));
7
8
  // Expo resolves config plugins through their default export (re-exported by
8
9
  // app.plugin.js at the package root).
9
10
  // eslint-disable-next-line import/no-default-export
@@ -0,0 +1,9 @@
1
+ import type { AndroidConfig } from "@expo/config-plugins";
2
+ type PropertiesItem = AndroidConfig.Properties.PropertiesItem;
3
+ /**
4
+ * Raises the app's `android.minSdkVersion` Gradle property, which Expo reads
5
+ * for the app's minSdkVersion (24 when the property is unset), to at least
6
+ * `minimum`. A higher value is kept.
7
+ */
8
+ export declare const setMinSdkVersionAtLeast: (properties: PropertiesItem[], minimum: number) => PropertiesItem[];
9
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setMinSdkVersionAtLeast = void 0;
4
+ const MIN_SDK_VERSION_KEY = "android.minSdkVersion";
5
+ /**
6
+ * Raises the app's `android.minSdkVersion` Gradle property, which Expo reads
7
+ * for the app's minSdkVersion (24 when the property is unset), to at least
8
+ * `minimum`. A higher value is kept.
9
+ */
10
+ const setMinSdkVersionAtLeast = (properties, minimum) => {
11
+ const index = properties.findIndex((item) => item.type === "property" && item.key === MIN_SDK_VERSION_KEY);
12
+ const current = properties[index];
13
+ if ((current === null || current === void 0 ? void 0 : current.type) === "property" && Number(current.value) >= minimum) {
14
+ return properties;
15
+ }
16
+ const raised = {
17
+ type: "property",
18
+ key: MIN_SDK_VERSION_KEY,
19
+ value: String(minimum),
20
+ };
21
+ return index < 0
22
+ ? [...properties, raised]
23
+ : properties.map((item, itemIndex) => itemIndex === index ? raised : item);
24
+ };
25
+ exports.setMinSdkVersionAtLeast = setMinSdkVersionAtLeast;
@@ -0,0 +1,11 @@
1
+ import type { ConfigPlugin } from "@expo/config-plugins";
2
+ /**
3
+ * The lowest API level the library builds for, which android/build.gradle
4
+ * applies whatever the app's minSdkVersion is.
5
+ */
6
+ export declare const LIBRARY_MIN_SDK_VERSION: number;
7
+ /**
8
+ * Raises an Expo app's minSdkVersion to the library's: Expo's default, 24, is
9
+ * below Android 8 (API 26), whose AHardwareBuffer API the native code calls.
10
+ */
11
+ export declare const withMinSdkVersion: ConfigPlugin;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withMinSdkVersion = exports.LIBRARY_MIN_SDK_VERSION = void 0;
4
+ const config_plugins_1 = require("@expo/config-plugins");
5
+ const setMinSdkVersion_1 = require("./setMinSdkVersion");
6
+ const pkg = require("../../package.json");
7
+ /**
8
+ * The lowest API level the library builds for, which android/build.gradle
9
+ * applies whatever the app's minSdkVersion is.
10
+ */
11
+ exports.LIBRARY_MIN_SDK_VERSION = pkg.androidMinSdkVersion;
12
+ /**
13
+ * Raises an Expo app's minSdkVersion to the library's: Expo's default, 24, is
14
+ * below Android 8 (API 26), whose AHardwareBuffer API the native code calls.
15
+ */
16
+ const withMinSdkVersion = (config) => (0, config_plugins_1.withGradleProperties)(config, (cfg) => {
17
+ cfg.modResults = (0, setMinSdkVersion_1.setMinSdkVersionAtLeast)(cfg.modResults, exports.LIBRARY_MIN_SDK_VERSION);
18
+ return cfg;
19
+ });
20
+ exports.withMinSdkVersion = withMinSdkVersion;