react-native-webgpu 0.15.2 → 0.16.1
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/android/CMakeLists.txt +5 -0
- package/android/build.gradle +11 -1
- package/android/cpp/cpp-adapter.cpp +109 -11
- package/android/src/main/java/com/webgpu/SurfaceFrameRateVote.java +97 -85
- package/android/src/main/java/com/webgpu/WebGPUView.java +97 -42
- package/apple/ApplePlatformContext.h +1 -0
- package/cpp/jsi/JSICache.cpp +2 -0
- package/cpp/jsi/NativeObject.h +81 -17
- package/cpp/rnwgpu/RNWebGPUManager.cpp +51 -41
- package/cpp/rnwgpu/RNWebGPUManager.h +10 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +4 -4
- package/cpp/rnwgpu/api/GPUDevice.cpp +96 -0
- package/cpp/rnwgpu/api/GPUDevice.h +22 -0
- package/cpp/rnwgpu/api/GPUError.h +1 -0
- package/cpp/rnwgpu/api/GPUExtent2D.h +56 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.cpp +32 -408
- package/cpp/rnwgpu/api/GPUExternalTexture.h +12 -37
- package/cpp/rnwgpu/api/GPUInternalError.h +1 -0
- package/cpp/rnwgpu/api/GPUNativeBufferExternalTexture.h +60 -0
- package/cpp/rnwgpu/api/GPUNativeBufferTexture.h +52 -0
- package/cpp/rnwgpu/api/GPUNativeBufferWrapper.cpp +144 -0
- package/cpp/rnwgpu/api/GPUNativeBufferWrapper.h +143 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +1 -0
- package/cpp/rnwgpu/api/GPUQueue.h +1 -0
- package/cpp/rnwgpu/api/GPUSharedFence.h +1 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +12 -44
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +1 -0
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +1 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +1 -0
- package/cpp/rnwgpu/api/NativeFrameImport.cpp +638 -0
- package/cpp/rnwgpu/api/NativeFrameImport.h +86 -0
- package/cpp/rnwgpu/api/VideoFrame.h +21 -7
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +153 -1
- package/cpp/rnwgpu/api/descriptors/GPUNativeBufferTextureDescriptor.h +55 -0
- package/cpp/rnwgpu/async/RuntimeContext.cpp +1 -0
- package/lib/commonjs/Canvas.js +51 -0
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/install.js +26 -7
- package/lib/commonjs/install.js.map +1 -1
- package/lib/module/Canvas.js +51 -0
- package/lib/module/Canvas.js.map +1 -1
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/install.js +26 -7
- package/lib/module/install.js.map +1 -1
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/install.d.ts +10 -7
- package/lib/typescript/lib/commonjs/install.d.ts.map +1 -1
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- package/lib/typescript/lib/module/install.d.ts.map +1 -1
- package/lib/typescript/src/Canvas.d.ts +20 -35
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/install.d.ts +10 -7
- package/lib/typescript/src/install.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +34 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/plugin/build/index.js +2 -1
- package/plugin/build/setMinSdkVersion.d.ts +9 -0
- package/plugin/build/setMinSdkVersion.js +25 -0
- package/plugin/build/withMinSdkVersion.d.ts +11 -0
- package/plugin/build/withMinSdkVersion.js +20 -0
- package/src/Canvas.tsx +74 -40
- package/src/external/reanimated/registerWebGPUForReanimated.ts +4 -0
- package/src/index.tsx +24 -0
- package/src/install.ts +26 -7
- package/src/types.ts +98 -1
package/lib/module/Canvas.js
CHANGED
|
@@ -6,10 +6,57 @@ let CONTEXT_COUNTER = 1;
|
|
|
6
6
|
function generateContextId() {
|
|
7
7
|
return CONTEXT_COUNTER++;
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Android-only rendering options. They select the backing view, which is
|
|
12
|
+
* chosen when the canvas mounts and kept: a later change is ignored, with a
|
|
13
|
+
* warning in development. Remount the canvas, with a `key`, to change it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
9
16
|
// Anything else reaching the native component would hit the generated
|
|
10
17
|
// string-enum parser, which aborts on unknown values.
|
|
11
18
|
const resolveSurfaceType = surfaceType => surfaceType === "SurfaceView" || surfaceType === "TextureView" || surfaceType === "HardwareBufferView" ? surfaceType : "auto";
|
|
12
19
|
|
|
20
|
+
// The props the Android backing view is chosen from when the canvas mounts.
|
|
21
|
+
|
|
22
|
+
// The backing view the props select, see WebGPUView.resolveKind().
|
|
23
|
+
const resolveKind = ({
|
|
24
|
+
opaque,
|
|
25
|
+
android
|
|
26
|
+
}) => {
|
|
27
|
+
const surfaceType = resolveSurfaceType(android?.surfaceType);
|
|
28
|
+
if (surfaceType !== "auto") {
|
|
29
|
+
return surfaceType;
|
|
30
|
+
}
|
|
31
|
+
return opaque ? "SurfaceView" : "TextureView";
|
|
32
|
+
};
|
|
33
|
+
const warnIgnored = prop => console.warn(`Ignoring a change of ${prop} on a mounted canvas: the backing view is ` + "chosen when the canvas mounts. Remount the canvas (give it a new key) " + "to change it.");
|
|
34
|
+
|
|
35
|
+
// Warns, in development on Android, about a change of these props that the
|
|
36
|
+
// native view ignores: the backing view is chosen from them when the canvas
|
|
37
|
+
// mounts (see WebGPUView.java, whose setters these rules mirror). The native
|
|
38
|
+
// side only says so in logcat, which is not where a JS developer looks.
|
|
39
|
+
const useBackingViewWarning = props => {
|
|
40
|
+
const mount = useRef(props);
|
|
41
|
+
const prev = useRef(props);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (__DEV__ && Platform.OS === "android") {
|
|
44
|
+
const {
|
|
45
|
+
current: before
|
|
46
|
+
} = prev;
|
|
47
|
+
if (resolveSurfaceType(before.android?.surfaceType) !== resolveSurfaceType(props.android?.surfaceType)) {
|
|
48
|
+
warnIgnored("android.surfaceType");
|
|
49
|
+
}
|
|
50
|
+
// Only a SurfaceView has a z-order of its own, which Android 11 and
|
|
51
|
+
// later changes in place.
|
|
52
|
+
if (!!before.android?.zOrderOnTop !== !!props.android?.zOrderOnTop && resolveKind(mount.current) === "SurfaceView" && Number(Platform.Version) < 30) {
|
|
53
|
+
warnIgnored("android.zOrderOnTop");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
prev.current = props;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
13
60
|
// A view measured relative to itself gets its layout size, without the
|
|
14
61
|
// transforms getBoundingClientRect() includes; measureLayout() calls back
|
|
15
62
|
// synchronously on the new architecture. On the web react-native-web measures
|
|
@@ -47,6 +94,10 @@ export const Canvas = ({
|
|
|
47
94
|
}) => {
|
|
48
95
|
const viewRef = useRef(null);
|
|
49
96
|
const [contextId, _] = useState(() => generateContextId());
|
|
97
|
+
useBackingViewWarning({
|
|
98
|
+
opaque,
|
|
99
|
+
android
|
|
100
|
+
});
|
|
50
101
|
// Retire the native registry entry for this contextId on unmount. When a
|
|
51
102
|
// native surface is still attached, this is a no-op and the native view's
|
|
52
103
|
// own teardown retires the entry instead — which keeps StrictMode's
|
package/lib/module/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useImperativeHandle","useRef","useState","Platform","View","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","resolveSurfaceType","surfaceType","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useImperativeHandle","useRef","useState","Platform","View","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","resolveSurfaceType","surfaceType","resolveKind","opaque","android","warnIgnored","prop","console","warn","useBackingViewWarning","props","mount","prev","__DEV__","OS","current","before","zOrderOnTop","Number","Version","measureLayout","view","clientWidth","clientHeight","width","height","size","_left","_top","Canvas","ref","viewRef","contextId","_","RNWebGPU","destroyContext","getContextId","getNativeSurface","getContext","contextName","Error","MakeWebGPUCanvasContext","createElement","_extends","collapsable","style","flex","androidSurfaceType","androidZOrderOnTop"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE/E,SAASC,QAAQ,EAAEC,IAAI,QAAQ,cAAc;AAG7C,OAAOC,gBAAgB,MAAM,6BAA6B;AAI1D,IAAIC,eAAe,GAAG,CAAC;AACvB,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,eAAe,EAAE;AAC1B;;AAKA;AACA;AACA;AACA;AACA;;AAsCA;AACA;AACA,MAAME,kBAAkB,GACtBC,WAA2C,IAE3CA,WAAW,KAAK,aAAa,IAC7BA,WAAW,KAAK,aAAa,IAC7BA,WAAW,KAAK,oBAAoB,GAChCA,WAAW,GACX,MAAM;;AAEZ;;AAMA;AACA,MAAMC,WAAW,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAA0B,CAAC,KAAK;EAC7D,MAAMH,WAAW,GAAGD,kBAAkB,CAACI,OAAO,EAAEH,WAAW,CAAC;EAC5D,IAAIA,WAAW,KAAK,MAAM,EAAE;IAC1B,OAAOA,WAAW;EACpB;EACA,OAAOE,MAAM,GAAG,aAAa,GAAG,aAAa;AAC/C,CAAC;AAED,MAAME,WAAW,GAAIC,IAAY,IAC/BC,OAAO,CAACC,IAAI,CACV,wBAAw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B,CACrCT,SAAS,EACTN,IAAI,CAACF,KAAK,EACVE,IAAI,CAACD,MACP,CAAC;IACH;EACF,CAAC,CAAC,EACF,CAACO,SAAS,CACZ,CAAC;EAED,oBACE1C,KAAA,CAAAoD,aAAA,CAAC9C,IAAI,EAAA+C,QAAA;IAACC,WAAW,EAAE,KAAM;IAACd,GAAG,EAAEC;EAAQ,GAAKrB,KAAK,gBAC/CpB,KAAA,CAAAoD,aAAA,CAAC7C,gBAAgB;IACfgD,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBd,SAAS,EAAEA,SAAU;IACrB7B,MAAM,EAAEA,MAAO;IACf4C,kBAAkB,EAAE/C,kBAAkB,CAACI,OAAO,EAAEH,WAAW,CAAE;IAC7D+C,kBAAkB,EAAE,CAAC,CAAC5C,OAAO,EAAEa;EAAY,CAC5C,CACG,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isRegistered","registerWebGPUForReanimated","helpers","globalThis","__webgpuWorkletHelpers","undefined","registerCustomSerializable","require","name","determine","value","isNativeObject","pack","box","unpack","boxed","unbox"],"sourceRoot":"../../../../src","sources":["external/reanimated/registerWebGPUForReanimated.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["isRegistered","registerWebGPUForReanimated","helpers","globalThis","__webgpuWorkletHelpers","undefined","registerCustomSerializable","require","name","determine","value","isNativeObject","pack","box","unpack","boxed","unbox"],"sourceRoot":"../../../../src","sources":["external/reanimated/registerWebGPUForReanimated.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;;AAsBA,IAAIA,YAAY,GAAG,KAAK;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAAA,KAAM;EAC/C,IAAID,YAAY,EAAE;IAChB;EACF;EACAA,YAAY,GAAG,IAAI;EAEnB,MAAME,OAAO,GAAGC,UAAU,CAACC,sBAAsB;EACjD,IAAIF,OAAO,KAAKG,SAAS,EAAE;IACzB;IACA;EACF;EAEA,IAAI;IACF,MAAM;MAAEC;IAA2B,CAAC,GAAGC,OAAO,CAAC,uBAAuB,CAAC;IAEvED,0BAA0B,CAAC;MACzBE,IAAI,EAAE,QAAQ;MACdC,SAAS,EAAGC,KAAa,IAAsB;QAC7C,SAAS;;QACT,OAAOR,OAAO,CAACS,cAAc,CAACD,KAAK,CAAC;MACtC,CAAC;MACDE,IAAI,EAAGF,KAAa,IAAK;QACvB,SAAS;;QACT,OAAOR,OAAO,CAACW,GAAG,CAACH,KAAK,CAAC;MAC3B,CAAC;MACDI,MAAM,EAAGC,KAAwB,IAAK;QACpC,SAAS;;QACT,OAAOA,KAAK,CAACC,KAAK,CAAC,CAAC;MACtB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["installWebGPU"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,sBAAsB;
|
|
1
|
+
{"version":3,"names":["installWebGPU"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,sBAAsB;AAuB7B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,SAASA,aAAa,QAAQ,WAAW","ignoreList":[]}
|
package/lib/module/install.js
CHANGED
|
@@ -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
|
|
39
|
+
* processors) start without it: `navigator.gpu`, the flag constants
|
|
31
40
|
* (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
|
|
32
|
-
* `GPUMapMode`)
|
|
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,
|
|
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
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
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","
|
|
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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAgGA;;;;;QAqDC"}
|
|
@@ -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
|
|
7
|
+
* processors) start without it: `navigator.gpu`, the flag constants
|
|
8
8
|
* (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
|
|
9
|
-
* `GPUMapMode`)
|
|
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,
|
|
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
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
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":";
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../commonjs/install.js"],"names":[],"mappings":";AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,sCA2BC"}
|
|
@@ -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":"AAwFO;;;;;2DAqDN;qBA3I8B,cAAc;kBAD2B,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../module/install.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../module/install.js"],"names":[],"mappings":"AA+EO,sCA2BN"}
|
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ViewProps } from "react-native";
|
|
3
|
-
type
|
|
4
|
-
export
|
|
5
|
-
surface: SurfacePointer;
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
clientWidth: number;
|
|
9
|
-
clientHeight: number;
|
|
10
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
11
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
12
|
-
dispatchEvent(event: Event): void;
|
|
13
|
-
setPointerCapture(pointerId: number): void;
|
|
14
|
-
releasePointerCapture(pointerId: number): void;
|
|
15
|
-
}
|
|
16
|
-
export type RNCanvasContext = GPUCanvasContext & {
|
|
17
|
-
/**
|
|
18
|
-
* Present the current frame.
|
|
19
|
-
*
|
|
20
|
-
* Call this after `queue.submit()` on every runtime: the main JS runtime, the
|
|
21
|
-
* Reanimated UI runtime, and dedicated worklet runtimes (e.g.
|
|
22
|
-
* `createWorkletRuntime` / `runOnRuntime`, or a Vision Camera frame
|
|
23
|
-
* processor). It runs synchronously on the calling thread, so the frame is
|
|
24
|
-
* presented from whichever thread did the rendering.
|
|
25
|
-
*/
|
|
26
|
-
present: () => void;
|
|
27
|
-
};
|
|
28
|
-
export interface CanvasRef {
|
|
29
|
-
getContextId: () => number;
|
|
30
|
-
getContext(contextName: "webgpu"): RNCanvasContext | null;
|
|
31
|
-
getNativeSurface: () => NativeCanvas;
|
|
32
|
-
}
|
|
3
|
+
import type { CanvasRef } from "./types";
|
|
4
|
+
export type { CanvasRef, NativeCanvas, RNCanvasContext } from "./types";
|
|
33
5
|
export type AndroidSurfaceType = "SurfaceView" | "TextureView" | "HardwareBufferView";
|
|
6
|
+
/**
|
|
7
|
+
* Android-only rendering options. They select the backing view, which is
|
|
8
|
+
* chosen when the canvas mounts and kept: a later change is ignored, with a
|
|
9
|
+
* warning in development. Remount the canvas, with a `key`, to change it.
|
|
10
|
+
*/
|
|
34
11
|
export interface AndroidCanvasProps {
|
|
35
12
|
/**
|
|
36
|
-
* Backing view. Defaults to `SurfaceView` when the canvas
|
|
37
|
-
* `TextureView` otherwise; both composite correctly in React Native
|
|
13
|
+
* Backing view. Defaults to `SurfaceView` when the canvas mounts opaque and
|
|
14
|
+
* to `TextureView` otherwise; both composite correctly in React Native
|
|
38
15
|
* stacking order without further flags. `HardwareBufferView` (Android 10+,
|
|
39
16
|
* a plain View that draws each frame's AHardwareBuffer inline with no extra
|
|
40
17
|
* copy) is opt-in and experimental; on older devices it uses `TextureView`.
|
|
18
|
+
* Read once, at mount.
|
|
41
19
|
*/
|
|
42
20
|
surfaceType?: AndroidSurfaceType;
|
|
43
21
|
/**
|
|
44
22
|
* SurfaceView only: composite above every React Native view in the window,
|
|
45
|
-
* ignoring `zIndex`. Ignored for TextureView. Defaults to false.
|
|
23
|
+
* ignoring `zIndex`. Ignored for TextureView. Defaults to false. Applied in
|
|
24
|
+
* place on Android 11 and later; read once, at mount, before that.
|
|
46
25
|
*/
|
|
47
26
|
zOrderOnTop?: boolean;
|
|
48
27
|
}
|
|
@@ -51,12 +30,18 @@ export interface CanvasProps extends ViewProps {
|
|
|
51
30
|
* Defaults to true. Set to false to alpha-composite the canvas over the
|
|
52
31
|
* views behind it (pair it with `alphaMode: "premultiplied"` and an alpha-0
|
|
53
32
|
* clear color). Android and web only; on iOS `alphaMode` alone controls it.
|
|
33
|
+
* On Android the backing view is chosen from it when the canvas mounts; a
|
|
34
|
+
* later change updates that view in place.
|
|
54
35
|
*/
|
|
55
36
|
opaque?: boolean;
|
|
56
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Android-only rendering options. They select the backing view, which is
|
|
39
|
+
* chosen when the canvas mounts and kept: a later change is ignored, with a
|
|
40
|
+
* warning in development. Remount the canvas, with a `key`, to change it.
|
|
41
|
+
* Ignored on iOS and web.
|
|
42
|
+
*/
|
|
57
43
|
android?: AndroidCanvasProps;
|
|
58
44
|
ref?: React.Ref<CanvasRef>;
|
|
59
45
|
}
|
|
60
46
|
export declare const Canvas: ({ opaque, android, ref, ...props }: CanvasProps) => React.JSX.Element;
|
|
61
|
-
export {};
|
|
62
47
|
//# 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;
|
|
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;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAmFD,eAAO,MAAM,MAAM,GAAI,oCAKpB,WAAW,sBAqDb,CAAC"}
|
|
@@ -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;
|
|
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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./main/installNative";
|
|
2
|
-
import type { GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUCopyExternalNativeFrameSourceInfo, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
2
|
+
import type { GPUNativeBufferExternalTexture, GPUNativeBufferExternalTextureDescriptor, GPUNativeBufferTexture, GPUNativeBufferTextureDescriptor, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUCopyExternalNativeFrameSourceInfo, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
3
3
|
export * from "./main";
|
|
4
4
|
export * from "./constants";
|
|
5
5
|
export { installWebGPU } from "./install";
|
|
6
|
-
export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUCopyExternalNativeFrameSourceInfo, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUDrawElementImageSourceView, } from "./types";
|
|
6
|
+
export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUCopyExternalNativeFrameSourceInfo, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, NativeVideoFrameColorSpace, GPUExtent2D, GPUNativeBufferExternalTextureDescriptor, GPUNativeBufferTextureDescriptor, GPUNativeBufferWrapper, GPUNativeBufferTexture, GPUNativeBufferExternalTexture, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUDrawElementImageSourceView, } from "./types";
|
|
7
7
|
declare global {
|
|
8
8
|
interface Navigator {
|
|
9
9
|
gpu: GPU;
|
|
@@ -32,6 +32,8 @@ declare global {
|
|
|
32
32
|
importExternalTexture(descriptor: GPUNativeExternalTextureDescriptor): GPUExternalTexture;
|
|
33
33
|
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
34
34
|
importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
|
|
35
|
+
createNativeBufferTexture(source: NativeVideoFrame, descriptor?: GPUNativeBufferTextureDescriptor): GPUNativeBufferTexture;
|
|
36
|
+
createNativeBufferExternalTexture(source: NativeVideoFrame, descriptor?: GPUNativeBufferExternalTextureDescriptor): GPUNativeBufferExternalTexture;
|
|
35
37
|
}
|
|
36
38
|
interface GPUQueue {
|
|
37
39
|
drawElementImageToTexture(source: GPUDrawElementImageSource, destination: GPUDrawElementImageDestination): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,gCAAgC,EAChC,oCAAoC,EACpC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS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ebGPU 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
|
|
6
|
+
* processors) start without it: `navigator.gpu`, the flag constants
|
|
7
7
|
* (`GPUBufferUsage`, `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`,
|
|
8
|
-
* `GPUMapMode`)
|
|
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,
|
|
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
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/install.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,aAAa,YAuBzB,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` / `
|
|
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
|
*/
|
|
@@ -34,10 +34,43 @@ export interface NativeVideoFrame {
|
|
|
34
34
|
readonly width: number;
|
|
35
35
|
readonly height: number;
|
|
36
36
|
readonly pixelFormat: NativeVideoPixelFormat;
|
|
37
|
+
readonly acquireFenceFd: bigint | null;
|
|
37
38
|
release(): void;
|
|
38
39
|
}
|
|
40
|
+
export interface NativeVideoFrameColorSpace {
|
|
41
|
+
matrix?: "identity" | "rec601" | "rec709" | "rec2020";
|
|
42
|
+
range?: "identity" | "narrow" | "full";
|
|
43
|
+
primaries?: "srgb" | "rec709" | "rec601" | "rec2020" | "display-p3";
|
|
44
|
+
transfer?: "identity" | "srgb" | "display-p3" | "smpte-170m" | "hlg" | "pq" | "bt-1886";
|
|
45
|
+
}
|
|
46
|
+
export type GPUExtent2D = {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
} | [number, number];
|
|
39
50
|
export interface GPUNativeExternalTextureDescriptor extends Omit<GPUExternalTextureDescriptor, "source"> {
|
|
40
51
|
source: NativeVideoFrame;
|
|
52
|
+
sourceColorSpace?: NativeVideoFrameColorSpace;
|
|
53
|
+
cropOrigin?: GPUOrigin2D;
|
|
54
|
+
cropSize?: GPUExtent2D;
|
|
55
|
+
}
|
|
56
|
+
export type GPUNativeBufferExternalTextureDescriptor = Omit<GPUNativeExternalTextureDescriptor, "source">;
|
|
57
|
+
export interface GPUNativeBufferTextureDescriptor {
|
|
58
|
+
usage?: GPUTextureUsageFlags;
|
|
59
|
+
label?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface GPUNativeBufferWrapper {
|
|
62
|
+
label: string;
|
|
63
|
+
beginAccess(fences?: GPUSharedFenceState[]): void;
|
|
64
|
+
endAccess(): GPUSharedFenceState | null;
|
|
65
|
+
destroy(): void;
|
|
66
|
+
}
|
|
67
|
+
export interface GPUNativeBufferTexture extends GPUNativeBufferWrapper {
|
|
68
|
+
readonly __brand: "GPUNativeBufferTexture";
|
|
69
|
+
readonly texture: GPUTexture;
|
|
70
|
+
}
|
|
71
|
+
export interface GPUNativeBufferExternalTexture extends GPUNativeBufferWrapper {
|
|
72
|
+
readonly __brand: "GPUNativeBufferExternalTexture";
|
|
73
|
+
readonly externalTexture: GPUExternalTexture;
|
|
41
74
|
}
|
|
42
75
|
export interface VideoPlayer {
|
|
43
76
|
copyLatestFrame(): NativeVideoFrame | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,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;IAGrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9D,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACjE,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;I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AAM,IAAI,wBAAwB,CAAC;IAInC,OAAO,IAAI,IAAI,CAAC;CACjB;AAID,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAID,MAAM,WAAW,oCAAoC;IACnD,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAQD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAMD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,UAAU,CAAC;IAM7D,WAAW,CACT,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAC7B,IAAI,CAAC;IAGR,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,oCAAoC,CAAC;IAMrE,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"plugin/build/**"
|
|
26
26
|
],
|
|
27
27
|
"dawn": "chrome-m154a",
|
|
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.
|
|
95
|
-
"react-native": "0.
|
|
95
|
+
"react": "19.2.3",
|
|
96
|
+
"react-native": "0.83.10",
|
|
96
97
|
"react-native-builder-bob": "^0.23.2",
|
|
97
|
-
"react-native-reanimated": "
|
|
98
|
+
"react-native-reanimated": "4.6.0",
|
|
98
99
|
"react-native-web": "^0.21.2",
|
|
99
|
-
"react-native-worklets": "0.
|
|
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",
|
package/plugin/build/index.js
CHANGED
|
@@ -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;
|