react-native-webgpu 0.23.0 → 0.24.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/Package.swift +18 -129
- package/android/cpp/AndroidPlatformContext.h +10 -9
- package/android/src/main/java/com/webgpu/WebGPUModule.java +3 -3
- package/android/src/main/java/com/webgpu/WebGPUVideoPlayer.java +1 -1
- package/apple/ApplePlatformContext.h +2 -1
- package/apple/ApplePlatformContext.mm +2 -2
- package/binaries.json +53 -105
- package/cpp/dawn/common/ExternalTextureParams.h +3 -3
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +329 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +51 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +104 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +375 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +67 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +199 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu.h +5119 -0
- package/cpp/dawn/include/dawn/webgpu_cpp.h +10506 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2897 -0
- package/cpp/dawn/include/webgpu/webgpu.h +33 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +33 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_print.h +33 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +163 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/rnwgpu/PlatformContext.h +1 -1
- package/cpp/rnwgpu/SurfaceRegistry.h +2 -2
- package/cpp/rnwgpu/api/GPUAdapter.cpp +1 -1
- package/cpp/rnwgpu/api/RNWebGPU.h +5 -4
- package/lib/commonjs/video.js +8 -4
- package/lib/commonjs/video.js.map +1 -1
- package/lib/module/video.js +6 -2
- package/lib/module/video.js.map +1 -1
- package/lib/typescript/lib/commonjs/video.d.ts +6 -2
- package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
- package/lib/typescript/lib/module/video.d.ts +1 -1
- package/lib/typescript/lib/module/video.d.ts.map +1 -1
- package/lib/typescript/react-native.config.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +1 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/video.d.ts +7 -3
- package/lib/typescript/src/video.d.ts.map +1 -1
- package/package.json +10 -5
- package/react-native-webgpu.podspec +46 -78
- package/react-native.config.js +9 -6
- package/scripts/apple-binaries-utils.sh +280 -0
- package/scripts/prepare-apple-binaries.sh +309 -0
- package/scripts/spm-plugin.js +130 -0
- package/src/index.tsx +4 -4
- package/src/types.ts +1 -1
- package/src/video.ts +12 -5
|
@@ -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,mB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WAAW,EAAE,4BAA4B,EACzC,QAAQ,EAAE,iBAAiB,GAC1B,SAAS,CAAC;KACd;IAID,UAAU,mBAAmB;QAC3B,WAAW,CAAC,EAAE,wBAAwB,CAAC;QAOvC,6BAA6B,CAAC,EAAE,OAAO,CAAC;KACzC;IAMD,UAAU,4BAA4B;QACpC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IASD,UAAU,kBAAkB;QAC1B,OAAO,IAAI,IAAI,CAAC;KACjB;IAGD,SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,EACpC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
|
|
@@ -75,7 +75,7 @@ export interface GPUCopyExternalNativeFrameSourceInfo {
|
|
|
75
75
|
rotation?: 0 | 90 | 180 | 270;
|
|
76
76
|
mirrored?: boolean;
|
|
77
77
|
}
|
|
78
|
-
export interface
|
|
78
|
+
export interface CreateTestVideoPlayerOptions {
|
|
79
79
|
pixelFormat?: NativeBufferPixelFormat;
|
|
80
80
|
}
|
|
81
81
|
export type GPUDrawElementImageSourceView = number | {
|
|
@@ -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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{ CreateNativeBufferOptions, CreateTestVideoPlayerOptions, NativeBuffer, VideoPlayer } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Decodes a video into native frames the GPU samples without any copy.
|
|
4
4
|
*
|
|
5
|
+
* For tests and examples only: video decoding is out of the scope of this
|
|
6
|
+
* library. For video in an app, use a video library and wrap its frames with
|
|
7
|
+
* `createNativeBufferFromPointer()`.
|
|
8
|
+
*
|
|
5
9
|
* `source` is a URL (`http`, `https`, `file`) or a file path. Playback is
|
|
6
10
|
* controlled like an HTMLMediaElement (`play()`, `pause()`, `currentTime`,
|
|
7
11
|
* `loop`, `volume`); frames are pulled with `copyLatestFrame()` on every
|
|
@@ -9,7 +13,7 @@ import type { CreateNativeBufferOptions, CreateVideoPlayerOptions, NativeBuffer,
|
|
|
9
13
|
* `importSharedTextureMemory()`:
|
|
10
14
|
*
|
|
11
15
|
* ```ts
|
|
12
|
-
* const player =
|
|
16
|
+
* const player = createTestVideoPlayer(url);
|
|
13
17
|
* player.play();
|
|
14
18
|
* const render = () => {
|
|
15
19
|
* const frame = player.copyLatestFrame();
|
|
@@ -24,7 +28,7 @@ import type { CreateNativeBufferOptions, CreateVideoPlayerOptions, NativeBuffer,
|
|
|
24
28
|
* `{ pixelFormat: "nv12" }`. On Android they are always in the decoder's
|
|
25
29
|
* native YUV layout, for `importExternalTexture()`.
|
|
26
30
|
*/
|
|
27
|
-
export declare const
|
|
31
|
+
export declare const createTestVideoPlayer: (source: string, options?: CreateTestVideoPlayerOptions) => VideoPlayer;
|
|
28
32
|
/**
|
|
29
33
|
* Wraps a native buffer produced by another library (a `CVPixelBufferRef` on
|
|
30
34
|
* Apple platforms, an `AHardwareBuffer*` on Android, for instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,EACd,UAAU,4BAA4B,KACrC,WAIA,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,MAAM,KAAG,YAG7D,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,YACiE,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,UAAU,yBAAyB,KAClC,YACsE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"apple/**",
|
|
21
21
|
"*.podspec",
|
|
22
22
|
"Package.swift",
|
|
23
|
+
"scripts/apple-binaries-utils.sh",
|
|
24
|
+
"scripts/prepare-apple-binaries.sh",
|
|
25
|
+
"scripts/spm-plugin.js",
|
|
23
26
|
"binaries.json",
|
|
24
27
|
"react-native.config.js",
|
|
25
28
|
"app.plugin.js",
|
|
@@ -43,7 +46,8 @@
|
|
|
43
46
|
"clang-format-android": "find android/cpp/ -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
|
44
47
|
"clang-format-common": "find cpp/rnwgpu -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
|
45
48
|
"cpplint": "cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=android/.cxx --exclude=cpp/dawn --exclude=libs --exclude=android/build --exclude=node_modules --recursive .",
|
|
46
|
-
"check-dawn": "tsx scripts/check-dawn.ts"
|
|
49
|
+
"check-dawn": "tsx scripts/check-dawn.ts",
|
|
50
|
+
"copy-dawn-headers": "node scripts/prepare-dawn-headers.mjs"
|
|
47
51
|
},
|
|
48
52
|
"keywords": [
|
|
49
53
|
"react-native",
|
|
@@ -113,9 +117,6 @@
|
|
|
113
117
|
"wgpu-matrix": "^3.0.2",
|
|
114
118
|
"ws": "^8.18.0"
|
|
115
119
|
},
|
|
116
|
-
"dependencies": {
|
|
117
|
-
"react-native-webgpu-dawn": "158.0.0"
|
|
118
|
-
},
|
|
119
120
|
"peerDependencies": {
|
|
120
121
|
"react": "*",
|
|
121
122
|
"react-native": ">=0.81.0",
|
|
@@ -157,5 +158,9 @@
|
|
|
157
158
|
"WebGPUNativeBufferView": "WebGPUNativeBufferView"
|
|
158
159
|
}
|
|
159
160
|
}
|
|
161
|
+
},
|
|
162
|
+
"swiftpmConfig": {
|
|
163
|
+
"name": "ReactNativeWebGPU",
|
|
164
|
+
"autolinkingPlugin": "./scripts/spm-plugin.js"
|
|
160
165
|
}
|
|
161
166
|
}
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
require "json"
|
|
2
|
-
require "
|
|
2
|
+
require "open3"
|
|
3
3
|
|
|
4
4
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
5
|
-
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
6
5
|
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# Dawn, the WebGPU implementation, ships in the react-native-webgpu-dawn npm
|
|
18
|
-
# package this package depends on (react-native-skia's Graphite backend links
|
|
19
|
-
# the same one, so an app installing both contains exactly one Dawn). Its
|
|
20
|
-
# headers are used in place, but CocoaPods only vendors frameworks from inside
|
|
21
|
-
# the pod, so the xcframework is copied into libs/apple at `pod install` time.
|
|
22
|
-
# The copy is stamped with the package version and skipped when it already
|
|
23
|
-
# matches, which keeps CocoaPods' cache intact across installs.
|
|
24
|
-
dawn_dir = resolve_node_package.call('react-native-webgpu-dawn', __dir__)
|
|
25
|
-
if dawn_dir.nil?
|
|
26
|
-
raise "react-native-webgpu: the react-native-webgpu-dawn package was not found. " \
|
|
27
|
-
"It ships the Dawn binaries this package links against; make sure " \
|
|
28
|
-
"dependencies are installed (yarn install / npm install), then run `pod install` again."
|
|
29
|
-
end
|
|
30
|
-
dawn_version = JSON.parse(File.read(File.join(dawn_dir, 'package.json')))['version'].to_s
|
|
31
|
-
dawn_include = File.join(dawn_dir, 'include')
|
|
32
|
-
dawn_libs = File.join(__dir__, 'libs', 'apple')
|
|
33
|
-
dawn_marker = File.join(dawn_libs, '.version')
|
|
34
|
-
unless File.exist?(dawn_marker) && File.read(dawn_marker).strip == dawn_version
|
|
35
|
-
Pod::UI.puts "react-native-webgpu: installing Dawn (react-native-webgpu-dawn #{dawn_version})"
|
|
36
|
-
FileUtils.rm_rf(dawn_libs)
|
|
37
|
-
FileUtils.mkdir_p(dawn_libs)
|
|
38
|
-
FileUtils.cp_r(File.join(dawn_dir, 'libs', 'apple', 'libwebgpu_dawn.xcframework'), dawn_libs)
|
|
39
|
-
File.write(dawn_marker, dawn_version)
|
|
40
|
-
end
|
|
6
|
+
# Configuration reads the installed release pin only. SDK downloads wait for
|
|
7
|
+
# Xcode's platform/architecture settings; headers already ship in this package.
|
|
8
|
+
stdout, stderr, status = Open3.capture3(
|
|
9
|
+
'/bin/bash', File.join(__dir__, 'scripts', 'prepare-apple-binaries.sh'),
|
|
10
|
+
'--config'
|
|
11
|
+
)
|
|
12
|
+
raise "react-native-webgpu: #{stderr.strip}" unless status.success?
|
|
13
|
+
binary_config = JSON.parse(stdout)
|
|
14
|
+
binary_search_path = '$(inherited) "$(PODS_CONFIGURATION_BUILD_DIR)/ReactNativeWebGPUBinaries"'
|
|
41
15
|
|
|
42
16
|
Pod::Spec.new do |s|
|
|
43
17
|
s.name = "react-native-webgpu"
|
|
@@ -47,12 +21,8 @@ Pod::Spec.new do |s|
|
|
|
47
21
|
s.license = package["license"]
|
|
48
22
|
s.authors = package["author"]
|
|
49
23
|
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
# xcframework ships a slice for is listed. react-native-tvos keeps the tvOS
|
|
53
|
-
# floor equal to the iOS one (its min_supported_versions helper). visionOS
|
|
54
|
-
# is not listed: react-native-webgpu-dawn ships no xros slice, so a visionOS
|
|
55
|
-
# target would autolink the pod and then fail to link it.
|
|
24
|
+
# CocoaPods autolinks only declared native platforms. Knowing a release SDK
|
|
25
|
+
# in the preparer alone does not establish WebGPU runtime support there.
|
|
56
26
|
s.platforms = {
|
|
57
27
|
:ios => min_ios_version_supported,
|
|
58
28
|
:tvos => min_ios_version_supported,
|
|
@@ -60,21 +30,16 @@ Pod::Spec.new do |s|
|
|
|
60
30
|
}
|
|
61
31
|
s.source = { :git => "https://github.com/wcandillon/react-native-webgpu.git", :tag => "#{s.version}" }
|
|
62
32
|
|
|
63
|
-
# CocoaPods is the
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
# not compile or vendor anything itself or the app gets the native module
|
|
70
|
-
# twice.
|
|
33
|
+
# CocoaPods is the default. Package.swift (React Native 0.87.1+ SwiftPM
|
|
34
|
+
# autolinking) is additive: an app links through one or the other, never
|
|
35
|
+
# both. Set RNWGPU_USE_SPM=1 before `pod install` when the app links this
|
|
36
|
+
# package through SwiftPM but still runs CocoaPods for other pods: RN's
|
|
37
|
+
# autolinking and codegen key off this podspec, so it must exist, but it
|
|
38
|
+
# must not compile or link anything or the app gets the native module twice.
|
|
71
39
|
if ENV['RNWGPU_USE_SPM']
|
|
72
|
-
# The Swift package resolves React Native's headers from the
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
# paths exist and the package fails to compile with header-not-found
|
|
76
|
-
# errors that don't point back here. Refuse the combination up front.
|
|
77
|
-
# The React Native template drives `use_frameworks!` from USE_FRAMEWORKS.
|
|
40
|
+
# The Swift package resolves React Native's headers from the static-library
|
|
41
|
+
# Pods layout (Pods/Headers/Public); use_frameworks! keeps them inside each
|
|
42
|
+
# framework instead, which fails later with unrelated header errors.
|
|
78
43
|
if ENV['USE_FRAMEWORKS']
|
|
79
44
|
raise "react-native-webgpu: RNWGPU_USE_SPM needs the static-library Pods layout. " \
|
|
80
45
|
"Unset USE_FRAMEWORKS (or drop use_frameworks! from the Podfile) to link " \
|
|
@@ -86,8 +51,26 @@ Pod::Spec.new do |s|
|
|
|
86
51
|
"apple/**/*.{h,c,cc,cpp,m,mm,swift}",
|
|
87
52
|
"cpp/**/*.{h,cpp}"
|
|
88
53
|
]
|
|
54
|
+
# Dawn's headers are reached through HEADER_SEARCH_PATHS below, as before
|
|
55
|
+
# they shipped in this package. Keeping them out of the pod's public headers
|
|
56
|
+
# preserves the flat public header layout other pods include, and avoids
|
|
57
|
+
# basename collisions between Dawn's webgpu/ and dawn/ headers.
|
|
58
|
+
s.exclude_files = "cpp/dawn/include/**/*"
|
|
59
|
+
s.preserve_paths = ['scripts/*.{js,sh}', 'libs/apple/**/*', 'cpp/dawn/include/**/*']
|
|
89
60
|
|
|
90
|
-
s.
|
|
61
|
+
s.libraries = ['c++'] + binary_config['linkNames']
|
|
62
|
+
s.user_target_xcconfig = { 'LIBRARY_SEARCH_PATHS' => binary_search_path }
|
|
63
|
+
s.script_phase = {
|
|
64
|
+
:name => 'Prepare React Native WebGPU binaries',
|
|
65
|
+
:shell_path => '/bin/bash',
|
|
66
|
+
:execution_position => :before_compile,
|
|
67
|
+
:always_out_of_date => '1',
|
|
68
|
+
:script => <<-SCRIPT
|
|
69
|
+
/bin/bash "${PODS_TARGET_SRCROOT}/scripts/prepare-apple-binaries.sh" \
|
|
70
|
+
--output "${PODS_CONFIGURATION_BUILD_DIR}/ReactNativeWebGPUBinaries" \
|
|
71
|
+
--assembly-root "${OBJROOT}/ReactNativeWebGPUBinaries"
|
|
72
|
+
SCRIPT
|
|
73
|
+
}
|
|
91
74
|
|
|
92
75
|
# The VideoPlayer API uses AVFoundation / CoreMedia, and shared-texture
|
|
93
76
|
# surfaces use CoreVideo (CVPixelBuffer). Link them so their symbols resolve.
|
|
@@ -98,11 +81,14 @@ Pod::Spec.new do |s|
|
|
|
98
81
|
# Under use_frameworks!, bare includes across folders (e.g. "GPU.h")
|
|
99
82
|
# resolve only through these paths. Keep in sync with internalHeaderDirs
|
|
100
83
|
# in Package.swift.
|
|
101
|
-
header_dirs = %w[apple cpp cpp/jsi cpp/rnwgpu cpp/rnwgpu/api cpp/rnwgpu/api/descriptors cpp/rnwgpu/async]
|
|
84
|
+
header_dirs = %w[apple cpp cpp/jsi cpp/rnwgpu cpp/rnwgpu/api cpp/rnwgpu/api/descriptors cpp/rnwgpu/async cpp/dawn/include]
|
|
102
85
|
header_search_paths = header_dirs.map { |dir| "\"$(PODS_TARGET_SRCROOT)/#{dir}\"" }
|
|
103
86
|
|
|
104
87
|
s.pod_target_xcconfig = {
|
|
105
|
-
'HEADER_SEARCH_PATHS' =>
|
|
88
|
+
'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
|
|
89
|
+
# Preparation needs access to the shared release cache and build products.
|
|
90
|
+
'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO',
|
|
91
|
+
'LIBRARY_SEARCH_PATHS' => binary_search_path,
|
|
106
92
|
# Xcode's all-target headermaps let same-named headers leak across pods
|
|
107
93
|
# (e.g. @shopify/react-native-skia keeps a jsi/ helper layer with
|
|
108
94
|
# identical relative header paths). Resolve includes strictly through our
|
|
@@ -110,23 +96,5 @@ Pod::Spec.new do |s|
|
|
|
110
96
|
'USE_HEADERMAP' => 'NO',
|
|
111
97
|
}
|
|
112
98
|
|
|
113
|
-
|
|
114
|
-
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
115
|
-
if respond_to?(:install_modules_dependencies, true)
|
|
116
|
-
install_modules_dependencies(s)
|
|
117
|
-
else
|
|
118
|
-
s.dependency "React-Core"
|
|
119
|
-
s.compiler_flags = folly_compiler_flags
|
|
120
|
-
s.pod_target_xcconfig = {
|
|
121
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_TARGET_SRCROOT)/cpp\" \"#{dawn_include}\"",
|
|
122
|
-
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
123
|
-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
|
|
124
|
-
}
|
|
125
|
-
s.dependency "React-RCTFabric"
|
|
126
|
-
s.dependency "React-Codegen"
|
|
127
|
-
s.dependency "RCT-Folly"
|
|
128
|
-
s.dependency "RCTRequired"
|
|
129
|
-
s.dependency "RCTTypeSafety"
|
|
130
|
-
s.dependency "ReactCommon/turbomodule/core"
|
|
131
|
-
end
|
|
99
|
+
install_modules_dependencies(s)
|
|
132
100
|
end
|
package/react-native.config.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// RN 0.87.1 reads this block; RN 0.88+ also reads package.json swiftpmConfig.
|
|
2
|
+
// Keep the native product and hook identical in both discovery paths.
|
|
3
|
+
// The plugin registers the package/product and the Node-free Xcode phase.
|
|
4
|
+
module.exports = {
|
|
5
|
+
spm: {
|
|
6
|
+
name: "ReactNativeWebGPU",
|
|
7
|
+
autolinkingPlugin: "./scripts/spm-plugin.js",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Shared Apple preparation helpers. Bash 3.2 and macOS system tools only.
|
|
3
|
+
#
|
|
4
|
+
# Sourced by prepare-apple-binaries.sh; does not download or write files on load.
|
|
5
|
+
# The caller owns WORK_DIR, LOCKS, TEMP_PATHS, and cleanup traps. Helpers return
|
|
6
|
+
# resolved paths/metadata through globals so lock ownership stays in one shell.
|
|
7
|
+
|
|
8
|
+
# MARK: Supported SDKs and linked libraries
|
|
9
|
+
|
|
10
|
+
# The release metadata supplies architectures; SDK groups can change their archs
|
|
11
|
+
# without changing this list or hardcoding XCFramework slice identifiers.
|
|
12
|
+
RNWGPU_SDKS=(
|
|
13
|
+
iphoneos iphonesimulator maccatalyst
|
|
14
|
+
appletvos appletvsimulator macos
|
|
15
|
+
)
|
|
16
|
+
RNWGPU_DAWN_LIBRARY=libwebgpu_dawn.a
|
|
17
|
+
|
|
18
|
+
# MARK: Release and cache policy
|
|
19
|
+
|
|
20
|
+
# Cache path, asset layout and locks intentionally match react-native-skia.
|
|
21
|
+
# Overrides are resolved when loading the installed manifest, not while sourcing.
|
|
22
|
+
RNWGPU_RELEASE_BASE_URL=https://github.com/wcandillon/react-native-skia/releases/download
|
|
23
|
+
RNWGPU_LOCK_TIMEOUT_SECONDS=600
|
|
24
|
+
RNWGPU_LOCK_POLL_SECONDS=0.1
|
|
25
|
+
|
|
26
|
+
# Bound retries and transfer time so an unavailable mirror fails the build phase
|
|
27
|
+
# with a useful error. A failed transfer never replaces a verified cache entry.
|
|
28
|
+
RNWGPU_CURL_OPTIONS=(
|
|
29
|
+
--fail --location --silent --show-error
|
|
30
|
+
--retry 2 --retry-delay 1 --retry-max-time 300
|
|
31
|
+
--connect-timeout 20 --max-time 300
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# MARK: Diagnostics and metadata readers
|
|
35
|
+
|
|
36
|
+
# Diagnostics stay on stderr so --config can return machine-readable JSON.
|
|
37
|
+
# The marker suppresses a second generic diagnostic from the caller's ERR trap.
|
|
38
|
+
fail() {
|
|
39
|
+
printf 'error: [react-native-webgpu] %s\n' "$*" >&2
|
|
40
|
+
: > "$WORK_DIR/failed"
|
|
41
|
+
exit 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
note() {
|
|
45
|
+
printf 'note: [react-native-webgpu] %s\n' "$*" >&2
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Read typed JSON values without Node or an optional package such as jq.
|
|
49
|
+
json_string() {
|
|
50
|
+
if ! plutil -extract "$2" raw -expect string -o - "$1"; then
|
|
51
|
+
printf 'error: [react-native-webgpu] Cannot read string %s in %s. Check the package/SDK metadata.\n' "$2" "$1" >&2
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# json_strings FILE KEY: emit one array element per line, preserving JSON types.
|
|
57
|
+
json_strings() {
|
|
58
|
+
local file="$1" key="$2" count index
|
|
59
|
+
count=$(plutil -extract "$key" raw -expect array -o - "$file") || return 1
|
|
60
|
+
for ((index = 0; index < count; index++)); do
|
|
61
|
+
json_string "$file" "$key.$index" || return 1
|
|
62
|
+
done
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Hash downloaded archives and small manifests, not each large extracted library.
|
|
66
|
+
hash_file() {
|
|
67
|
+
shasum -a 256 "$1" | cut -d ' ' -f 1
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# MARK: Platform and dependency resolution
|
|
71
|
+
|
|
72
|
+
# PLATFORM_NAME=macosx needs its Catalyst variant to select iOS-compatible code.
|
|
73
|
+
# Each row is SDK|binary platform|variant|deployment setting.
|
|
74
|
+
sdk_descriptor() {
|
|
75
|
+
case "$1" in
|
|
76
|
+
iphoneos) echo 'iphoneos|ios||IPHONEOS_DEPLOYMENT_TARGET' ;;
|
|
77
|
+
iphonesimulator) echo 'iphonesimulator|ios|simulator|IPHONEOS_DEPLOYMENT_TARGET' ;;
|
|
78
|
+
maccatalyst) echo 'maccatalyst|ios|maccatalyst|IPHONEOS_DEPLOYMENT_TARGET' ;;
|
|
79
|
+
appletvos) echo 'appletvos|tvos||TVOS_DEPLOYMENT_TARGET' ;;
|
|
80
|
+
appletvsimulator) echo 'appletvsimulator|tvos|simulator|TVOS_DEPLOYMENT_TARGET' ;;
|
|
81
|
+
macos) echo 'macos|macos||MACOSX_DEPLOYMENT_TARGET' ;;
|
|
82
|
+
*) return 1 ;;
|
|
83
|
+
esac
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# The installed manifest pins immutable release assets; never fetch a remote pin.
|
|
87
|
+
# Sets MANIFEST, VERSION, RELEASE_TAG, CACHE_ROOT, and RELEASE_URL. Cache entries
|
|
88
|
+
# are shared across projects and isolated by release tag and pinned SHA-256.
|
|
89
|
+
load_release() {
|
|
90
|
+
MANIFEST="$PACKAGE_ROOT/binaries.json"
|
|
91
|
+
VERSION=$(json_string "$MANIFEST" version) || fail "Cannot read version from $MANIFEST. Reinstall the package."
|
|
92
|
+
RELEASE_TAG=$(json_string "$MANIFEST" tag) || fail "Cannot read tag from $MANIFEST. Reinstall the package."
|
|
93
|
+
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ && "$RELEASE_TAG" == "binaries-$VERSION" ]] ||
|
|
94
|
+
fail "Invalid version/tag in $MANIFEST. Refresh the release manifest."
|
|
95
|
+
CACHE_ROOT="${RNSKIA_CACHE_DIR:-$HOME/Library/Caches/react-native-skia}/$RELEASE_TAG"
|
|
96
|
+
[[ "$CACHE_ROOT" == /* ]] || fail 'RNSKIA_CACHE_DIR must be an absolute path.'
|
|
97
|
+
RELEASE_URL="${REACT_NATIVE_SKIA_BINARIES_URL:-$RNWGPU_RELEASE_BASE_URL}"
|
|
98
|
+
RELEASE_URL="${RELEASE_URL%/}/$RELEASE_TAG"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# MARK: Shared cache synchronization
|
|
102
|
+
|
|
103
|
+
# acquire_lock DIRECTORY: mkdir serializes writers across app/build processes.
|
|
104
|
+
# Locks cover writers only. Recover an owner terminated during another build.
|
|
105
|
+
# LOCKS is owned by the caller's EXIT trap, including interrupted downloads.
|
|
106
|
+
acquire_lock() {
|
|
107
|
+
local directory="$1" started=$SECONDS pid
|
|
108
|
+
mkdir -p "$(dirname "$directory")"
|
|
109
|
+
until mkdir "$directory" 2>/dev/null; do
|
|
110
|
+
pid=$(cat "$directory/pid" 2>/dev/null) || pid=''
|
|
111
|
+
if [[ "$pid" =~ ^[1-9][0-9]*$ ]] && ! kill -0 "$pid" 2>/dev/null; then
|
|
112
|
+
break_stale_lock "$directory" "$pid"
|
|
113
|
+
fi
|
|
114
|
+
(( SECONDS - started < RNWGPU_LOCK_TIMEOUT_SECONDS )) ||
|
|
115
|
+
fail "Timed out waiting for $directory. Check for another running build before removing this lock."
|
|
116
|
+
sleep "$RNWGPU_LOCK_POLL_SECONDS"
|
|
117
|
+
done
|
|
118
|
+
LOCKS+=("$directory")
|
|
119
|
+
printf '%s\n' "$$" > "$directory/pid"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# break_stale_lock DIRECTORY PID: remove a lock left by the dead PID. Several
|
|
123
|
+
# waiters can see the same dead owner; a guard serializes them, and the owner is
|
|
124
|
+
# read again inside it, so a waiter never removes a lock another one has just
|
|
125
|
+
# taken over. A guard left by a breaker killed mid-recovery is dropped after a
|
|
126
|
+
# minute (recovery itself takes milliseconds).
|
|
127
|
+
break_stale_lock() {
|
|
128
|
+
local directory="$1" stale="$2" guard="$1.break" owner
|
|
129
|
+
if ! mkdir "$guard" 2>/dev/null; then
|
|
130
|
+
if [[ -n "$(find "$guard" -maxdepth 0 -mmin +1 2>/dev/null || true)" ]]; then
|
|
131
|
+
rm -rf "$guard"
|
|
132
|
+
fi
|
|
133
|
+
return 0
|
|
134
|
+
fi
|
|
135
|
+
owner=$(cat "$directory/pid" 2>/dev/null) || owner=''
|
|
136
|
+
if [[ "$owner" == "$stale" ]]; then rm -rf "$directory"; fi
|
|
137
|
+
rmdir "$guard" 2>/dev/null || true
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# Completed writes release early; the caller's cleanup ignores locks now absent.
|
|
141
|
+
release_lock() {
|
|
142
|
+
rm -rf "$1"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# Keep a previous complete directory if replacing it fails.
|
|
146
|
+
replace_directory() {
|
|
147
|
+
local source="$1" destination="$2" backup="$2.previous-$$"
|
|
148
|
+
rm -rf "$backup"
|
|
149
|
+
if [[ -e "$destination" ]]; then mv "$destination" "$backup"; fi
|
|
150
|
+
if ! mv "$source" "$destination"; then
|
|
151
|
+
if [[ -e "$backup" ]]; then mv "$backup" "$destination"; fi
|
|
152
|
+
fail "Cannot replace $destination. Check build/cache permissions and free disk space."
|
|
153
|
+
fi
|
|
154
|
+
rm -rf "$backup"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
# MARK: Verified release downloads
|
|
158
|
+
|
|
159
|
+
# cached_asset NAME: resolve one pinned ZIP into ASSET_DIRECTORY and set its
|
|
160
|
+
# SHA-256 as SOURCE_SIGNATURE. Only that SDK/module is downloaded.
|
|
161
|
+
# Verify every reused ZIP. Downloads/extractions are staged before replacing cache
|
|
162
|
+
# entries; a failed network request or checksum cannot become a cache hit.
|
|
163
|
+
# Returns ASSET_DIRECTORY, without capturing lock state in a subshell.
|
|
164
|
+
cached_asset() {
|
|
165
|
+
local name="$1" expected escaped archive temporary marker entry actual
|
|
166
|
+
escaped=${name//./\\.}
|
|
167
|
+
expected=$(json_string "$MANIFEST" "assets.$escaped.sha256" 2>/dev/null) || expected=''
|
|
168
|
+
[[ "$expected" =~ ^[a-f0-9]{64}$ ]] ||
|
|
169
|
+
fail "Release $VERSION has no pinned asset '$name'. Publish/select SDK archives or build this SDK locally."
|
|
170
|
+
ASSET_DIRECTORY="$CACHE_ROOT/$expected/${name%.zip}"
|
|
171
|
+
archive="$ASSET_DIRECTORY.zip"
|
|
172
|
+
acquire_lock "$ASSET_DIRECTORY.lock"
|
|
173
|
+
actual=''
|
|
174
|
+
if [[ -f "$archive" ]]; then actual=$(hash_file "$archive"); fi
|
|
175
|
+
if [[ "$actual" != "$expected" ]]; then
|
|
176
|
+
temporary="$archive.$$.download"
|
|
177
|
+
TEMP_PATHS+=("$temporary")
|
|
178
|
+
note "Downloading $name ($VERSION)"
|
|
179
|
+
curl "${RNWGPU_CURL_OPTIONS[@]}" \
|
|
180
|
+
--output "$temporary" "$RELEASE_URL/$name" ||
|
|
181
|
+
fail "Cannot download $name. Check the release URL/network or REACT_NATIVE_SKIA_BINARIES_URL, then retry."
|
|
182
|
+
actual=$(hash_file "$temporary")
|
|
183
|
+
[[ "$actual" == "$expected" ]] ||
|
|
184
|
+
fail "SHA-256 mismatch for $name. Expected $expected; received $actual. Unverified data was discarded."
|
|
185
|
+
mv "$temporary" "$archive"
|
|
186
|
+
fi
|
|
187
|
+
marker="$ASSET_DIRECTORY/.verified"
|
|
188
|
+
# Reuse extracted files only after the ZIP passed verification above. The
|
|
189
|
+
# marker avoids extracting the same immutable archive on every app build.
|
|
190
|
+
if [[ ! -f "$marker" || "$(cat "$marker")" != "$expected" ]]; then
|
|
191
|
+
temporary="$ASSET_DIRECTORY.$$.extract"
|
|
192
|
+
TEMP_PATHS+=("$temporary")
|
|
193
|
+
mkdir -p "$temporary"
|
|
194
|
+
# Archive members must remain inside the extraction directory.
|
|
195
|
+
unzip -Z1 "$archive" > "$WORK_DIR/zip-entries"
|
|
196
|
+
while IFS= read -r entry; do
|
|
197
|
+
case "$entry" in
|
|
198
|
+
''|/*|*\\*|..|../*|*/../*|*/..) fail "Unsafe path in $name: $entry" ;;
|
|
199
|
+
esac
|
|
200
|
+
done < "$WORK_DIR/zip-entries"
|
|
201
|
+
unzip -q "$archive" -d "$temporary"
|
|
202
|
+
printf '%s\n' "$expected" > "$temporary/.verified"
|
|
203
|
+
replace_directory "$temporary" "$ASSET_DIRECTORY"
|
|
204
|
+
fi
|
|
205
|
+
release_lock "$ASSET_DIRECTORY.lock"
|
|
206
|
+
SOURCE_SIGNATURE="$expected"
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
# MARK: SDK metadata and local overrides
|
|
210
|
+
|
|
211
|
+
# validate_metadata DIRECTORY SDK: sets META_ARCHS and META_IDENTIFIER.
|
|
212
|
+
# Validate all requested architectures and every linked library against metadata.
|
|
213
|
+
# Metadata also determines future slice identifiers; no hardcoded arch sets.
|
|
214
|
+
# Release builds verify Mach-O members before publishing; consumers check the
|
|
215
|
+
# pinned archive and its descriptor without scanning every object at build time.
|
|
216
|
+
validate_metadata() {
|
|
217
|
+
local directory="$1" sdk="$2" file platform variant ignored deployment
|
|
218
|
+
local actual_sdk actual_platform actual_variant arch seen='' library libraries minimum
|
|
219
|
+
file="$directory/metadata.json"
|
|
220
|
+
[[ -f "$file" ]] || fail "Missing SDK metadata: $file. Rebuild local $MODULE '$sdk' or refresh the pinned SDK archive/cache."
|
|
221
|
+
IFS='|' read -r ignored platform variant deployment <<< "$(sdk_descriptor "$sdk")"
|
|
222
|
+
actual_sdk=$(json_string "$file" sdk)
|
|
223
|
+
actual_platform=$(json_string "$file" platform)
|
|
224
|
+
# Device/native macOS metadata omits variant. Catch absence inside the
|
|
225
|
+
# substitution so Bash 3.2 does not inherit ERR for this optional value.
|
|
226
|
+
actual_variant=$(json_string "$file" variant 2>/dev/null || true)
|
|
227
|
+
[[ "$actual_sdk" == "$sdk" && "$actual_platform" == "$platform" && "$actual_variant" == "$variant" ]] ||
|
|
228
|
+
fail "Incorrect SDK metadata in $directory; expected $sdk. Rebuild locally or refresh the pinned release."
|
|
229
|
+
META_ARCHS=$(json_strings "$file" architectures) || fail "Invalid architecture array in $file."
|
|
230
|
+
[[ -n "$META_ARCHS" ]] || fail "No architectures recorded in $file."
|
|
231
|
+
while IFS= read -r arch; do
|
|
232
|
+
[[ "$arch" =~ ^[A-Za-z0-9_]+$ && " $seen " != *" $arch "* ]] || fail "Invalid/duplicate architecture in $file: $arch"
|
|
233
|
+
seen="$seen $arch"
|
|
234
|
+
done <<< "$META_ARCHS"
|
|
235
|
+
for arch in "${REQUESTED_ARCHS[@]}"; do
|
|
236
|
+
[[ " $seen " == *" $arch "* ]] || fail "$sdk binaries in $directory do not contain $arch. Build that architecture or select a compatible release."
|
|
237
|
+
done
|
|
238
|
+
libraries=$(json_strings "$file" libraries) || fail "Invalid library array in $file."
|
|
239
|
+
for library in "${MODULE_LIBRARIES[@]}"; do
|
|
240
|
+
[[ -f "$directory/$library" ]] || fail "Incomplete $sdk binaries: $directory/$library is missing. Rebuild locally or remove the incomplete cache."
|
|
241
|
+
[[ $'\n'"$libraries"$'\n' == *$'\n'"$library"$'\n'* ]] || fail "$file does not declare $library."
|
|
242
|
+
done
|
|
243
|
+
# Optional: local Dawn builds may omit it. Catch absence as for variant above.
|
|
244
|
+
minimum=$(json_string "$file" minimumDeploymentTarget 2>/dev/null || true)
|
|
245
|
+
if [[ -n "$minimum" ]]; then
|
|
246
|
+
[[ "$minimum" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]] || fail "Invalid deployment target in $file: $minimum"
|
|
247
|
+
# Numeric comparison handles both major-only and dotted deployment versions.
|
|
248
|
+
if [[ -n "${!deployment:-}" ]] && ! awk -v actual="${!deployment}" -v minimum="$minimum" '
|
|
249
|
+
BEGIN { split(actual, a, "."); split(minimum, m, ".");
|
|
250
|
+
for (i = 1; i <= 3; i++) { if (a[i]+0 > m[i]+0) exit 0; if (a[i]+0 < m[i]+0) exit 1; } }'; then
|
|
251
|
+
fail "$sdk binaries require deployment target $minimum, but $deployment=${!deployment}. Raise the app deployment target."
|
|
252
|
+
fi
|
|
253
|
+
fi
|
|
254
|
+
META_IDENTIFIER="$platform-$(printf '%s\n' "$META_ARCHS" | LC_ALL=C sort | paste -sd _ -)${variant:+-$variant}"
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# An existing SDK tree is a read-only local override. Missing SDKs fail rather
|
|
258
|
+
# than mixing local and released Dawn. Symlink libs/apple to a local Skia Dawn
|
|
259
|
+
# build's libs/dawn/apple directory to consume those same SDK libraries.
|
|
260
|
+
resolve_libraries() {
|
|
261
|
+
local sdk="$1" local_root="$PACKAGE_ROOT/libs/apple" library
|
|
262
|
+
if [[ -d "$local_root" ]]; then
|
|
263
|
+
SOURCE_DIRECTORY="$local_root/$sdk"
|
|
264
|
+
[[ -f "$SOURCE_DIRECTORY/metadata.json" ]] ||
|
|
265
|
+
fail "Local Dawn overrides are enabled, but $SOURCE_DIRECTORY/metadata.json is missing. Build '$sdk' locally or remove that override directory."
|
|
266
|
+
note "Using local Dawn: $SOURCE_DIRECTORY"
|
|
267
|
+
validate_metadata "$SOURCE_DIRECTORY" "$sdk"
|
|
268
|
+
SOURCE_SIGNATURE=$({
|
|
269
|
+
cat "$SOURCE_DIRECTORY/metadata.json"
|
|
270
|
+
for library in "${MODULE_LIBRARIES[@]}"; do
|
|
271
|
+
# Detect rapid local rebuilds without hashing large archives each time.
|
|
272
|
+
stat -f '%N %z %.9Fm %.9Fc' "$SOURCE_DIRECTORY/$library"
|
|
273
|
+
done
|
|
274
|
+
} | shasum -a 256 | cut -d ' ' -f 1)
|
|
275
|
+
else
|
|
276
|
+
cached_asset "dawn-apple-$sdk.zip"
|
|
277
|
+
SOURCE_DIRECTORY="$ASSET_DIRECTORY"
|
|
278
|
+
validate_metadata "$SOURCE_DIRECTORY" "$sdk"
|
|
279
|
+
fi
|
|
280
|
+
}
|