react-native-webgpu 0.12.0 → 0.13.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 (85) hide show
  1. package/Package.swift +86 -56
  2. package/android/CMakeLists.txt +10 -4
  3. package/android/build.gradle +23 -0
  4. package/cpp/rnwgpu/SurfaceRegistry.h +2 -2
  5. package/package.json +6 -8
  6. package/react-native-webgpu.podspec +38 -2
  7. package/cpp/webgpu/webgpu.h +0 -5063
  8. package/cpp/webgpu/webgpu_cpp.h +0 -10401
  9. package/cpp/webgpu/webgpu_cpp_chained_struct.h +0 -57
  10. package/cpp/webgpu/webgpu_cpp_print.h +0 -2868
  11. package/cpp/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  12. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  13. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  14. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  15. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  16. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +0 -65
  17. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/dawn_proc_table.h +0 -329
  18. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/DawnNative.h +0 -367
  19. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/NullBackend.h +0 -39
  20. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/OpenGLBackend.h +0 -89
  21. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/VulkanBackend.h +0 -183
  22. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/dawn_native_export.h +0 -49
  23. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu.h +0 -5063
  24. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu.ixx +0 -358
  25. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu_cpp.h +0 -10401
  26. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu_cpp_print.h +0 -2868
  27. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu.h +0 -369
  28. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  29. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  30. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu.h +0 -33
  31. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp.h +0 -33
  32. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  33. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp_print.h +0 -33
  34. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  35. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  36. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  37. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  38. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  39. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  40. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/dawn_proc_table.h +0 -329
  41. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/DawnNative.h +0 -367
  42. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/NullBackend.h +0 -39
  43. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/OpenGLBackend.h +0 -89
  44. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/VulkanBackend.h +0 -183
  45. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/dawn_native_export.h +0 -49
  46. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu.h +0 -5063
  47. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu.ixx +0 -358
  48. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu_cpp.h +0 -10401
  49. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu_cpp_print.h +0 -2868
  50. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu.h +0 -369
  51. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  52. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  53. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu.h +0 -33
  54. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp.h +0 -33
  55. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  56. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp_print.h +0 -33
  57. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  58. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  59. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  60. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  61. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  62. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -4
  63. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/dawn_proc_table.h +0 -329
  64. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/DawnNative.h +0 -367
  65. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/NullBackend.h +0 -39
  66. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/OpenGLBackend.h +0 -89
  67. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/VulkanBackend.h +0 -183
  68. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/dawn_native_export.h +0 -49
  69. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu.h +0 -5063
  70. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu.ixx +0 -358
  71. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu_cpp.h +0 -10401
  72. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu_cpp_print.h +0 -2868
  73. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu.h +0 -369
  74. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  75. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  76. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu.h +0 -33
  77. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp.h +0 -33
  78. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  79. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp_print.h +0 -33
  80. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  81. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  82. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  83. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  84. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  85. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -4
package/Package.swift CHANGED
@@ -1,6 +1,4 @@
1
1
  // swift-tools-version: 6.0
2
- // Generated by scripts/generate-package-swift.ts — do not edit by hand.
3
- // Re-run that script after a new Dawn release to update the URL/checksum below.
4
2
  //
5
3
  // SwiftPM manifest for react-native-webgpu. iOS only.
6
4
  // Additive: the CocoaPods podspec remains the supported default.
@@ -21,49 +19,94 @@ let packageRoot = URL(fileURLWithPath: Context.packageDirectory)
21
19
  let sibling = { (relative: String) -> String in
22
20
  URL(fileURLWithPath: "\(packageRoot)/\(relative)").standardized.path
23
21
  }
22
+ // A node package next to this one: a sibling in the consumer's node_modules,
23
+ // or under this monorepo's root.
24
+ let nodePackage = { (name: String) -> String? in
25
+ ["../\(name)", "../../node_modules/\(name)"]
26
+ .map(sibling)
27
+ .first { FileManager.default.fileExists(atPath: "\($0)/package.json") }
28
+ }
29
+ let readJSON = { (path: String) -> [String: Any]? in
30
+ guard let data = FileManager.default.contents(atPath: path) else { return nil }
31
+ return try? JSONSerialization.jsonObject(with: data) as? [String: Any]
32
+ }
33
+
34
+ // Dawn, the WebGPU implementation, comes from the react-native-webgpu-dawn npm
35
+ // package this package depends on: an xcframework with the `webgpu/` and
36
+ // `dawn/` headers embedded in every slice, which SwiftPM exposes to dependents
37
+ // without any search path. react-native-skia's Graphite backend links the
38
+ // same package, so an app installing both contains exactly one Dawn.
39
+ guard let dawnPath = nodePackage("react-native-webgpu-dawn") else {
40
+ // Reached when the dependency was skipped at install time, which SwiftPM
41
+ // would otherwise report as an unresolvable dependency path.
42
+ fatalError(
43
+ """
44
+ react-native-webgpu-dawn was not found next to react-native-webgpu. It ships \
45
+ the Dawn binaries this package links against. Reinstall dependencies.
46
+ """)
47
+ }
48
+ let ownPackage = readJSON("\(packageRoot)/package.json") ?? [:]
49
+ let dawnVersion =
50
+ (readJSON("\(dawnPath)/package.json")?["version"] as? String) ?? "unknown"
24
51
 
25
52
  // Skia Graphite and WebGPU must link the exact same Dawn, or the pair links
26
53
  // fine and crashes at runtime. react-native-skia's podspec enforces this at
27
- // `pod install` time by comparing its libs/.dawn-version against this
28
- // package's `dawn` field. A Swift package has no install hook, so the same
29
- // check runs here, at manifest evaluation. SwiftPM caches evaluations, so
30
- // after changing either package's Dawn version reset the package caches
31
- // (File > Packages > Reset Package Caches) if this does not re-run.
32
- let dawnReleaseTag = "dawn-chrome-m154"
33
- // Only Graphite builds of react-native-skia carry this marker (Ganesh builds
34
- // do not link Dawn and impose no constraint). From v3 the Skia binaries ship
35
- // in react-native-skia-graphite-apple-ios, which records the tag at
36
- // libs/.dawn-version; react-native-skia's podspec copies it into its own
37
- // libs/ at `pod install`, which never runs here. The v2 Graphite previews
38
- // (e.g. @shopify/react-native-skia@2.12.0-next.1) keep it in their own libs/.
39
- // The graphite packages are normally hoisted next to this package, but may
40
- // be nested under react-native-skia when the package manager cannot hoist
41
- // them. Every marker found is checked.
42
- let skiaDawnMarkers = [
43
- "react-native-skia-graphite-apple-ios/libs/.dawn-version",
44
- "react-native-skia-graphite-apple-macos/libs/.dawn-version",
45
- "react-native-skia/node_modules/react-native-skia-graphite-apple-ios/libs/.dawn-version",
46
- "react-native-skia/node_modules/react-native-skia-graphite-apple-macos/libs/.dawn-version",
47
- "@shopify/react-native-skia/libs/.dawn-version",
48
- ].flatMap { marker in
49
- [
50
- sibling("../\(marker)"), // consumer: sibling in node_modules
51
- sibling("../../node_modules/\(marker)"), // this monorepo
52
- ]
53
- }
54
- for marker in skiaDawnMarkers {
55
- guard let data = FileManager.default.contents(atPath: marker),
56
- let skiaDawn = String(data: data, encoding: .utf8)?
57
- .trimmingCharacters(in: .whitespacesAndNewlines)
58
- else { continue }
59
- if skiaDawn != dawnReleaseTag {
54
+ // `pod install` time; a Swift package has no install hook, so the same check
55
+ // runs here, at manifest evaluation. SwiftPM caches evaluations, so after
56
+ // changing either package's Dawn reset the package caches (File > Packages >
57
+ // Reset Package Caches) if this does not re-run.
58
+ //
59
+ // A react-native-skia that depends on react-native-webgpu-dawn itself must pin
60
+ // the same version as this package. Older Graphite builds (react-native-skia
61
+ // 3.0.x) vendor their own Dawn and record its release tag at
62
+ // libs/.dawn-version in their binary packages; this package's `dawn` field
63
+ // names the release that Dawn is interchangeable with.
64
+ if let skiaPath = nodePackage("react-native-skia"),
65
+ let skiaPackage = readJSON("\(skiaPath)/package.json"),
66
+ let skiaDawn = (skiaPackage["dependencies"] as? [String: String])?["react-native-webgpu-dawn"]
67
+ {
68
+ if skiaDawn != dawnVersion {
60
69
  fatalError(
61
70
  """
62
- react-native-webgpu: Dawn version mismatch. This package links \(dawnReleaseTag) \
63
- but the react-native-skia Graphite binaries (\(marker)) link \(skiaDawn). \
64
- Align the two packages so the app contains exactly one Dawn.
71
+ react-native-webgpu: Dawn version mismatch. This package links \
72
+ react-native-webgpu-dawn \(dawnVersion) but react-native-skia depends on \
73
+ \(skiaDawn). Align the two packages so the app contains exactly one Dawn.
65
74
  """)
66
75
  }
76
+ } else {
77
+ let dawnReleaseTag =
78
+ "dawn-\((ownPackage["dawn"] as? String ?? "").replacingOccurrences(of: "/", with: "-"))"
79
+ // The graphite packages are normally hoisted next to this package, but may
80
+ // be nested under react-native-skia when the package manager cannot hoist
81
+ // them. The v2 Graphite previews (e.g. @shopify/react-native-skia@2.12.0-next.1)
82
+ // keep the marker in their own libs/. Every marker found is checked.
83
+ let skiaDawnMarkers = [
84
+ "react-native-skia-graphite-apple-ios/libs/.dawn-version",
85
+ "react-native-skia-graphite-apple-macos/libs/.dawn-version",
86
+ "react-native-skia/node_modules/react-native-skia-graphite-apple-ios/libs/.dawn-version",
87
+ "react-native-skia/node_modules/react-native-skia-graphite-apple-macos/libs/.dawn-version",
88
+ "@shopify/react-native-skia/libs/.dawn-version",
89
+ ].flatMap { marker in
90
+ [
91
+ sibling("../\(marker)"), // consumer: sibling in node_modules
92
+ sibling("../../node_modules/\(marker)"), // this monorepo
93
+ ]
94
+ }
95
+ for marker in skiaDawnMarkers {
96
+ guard let data = FileManager.default.contents(atPath: marker),
97
+ let skiaDawn = String(data: data, encoding: .utf8)?
98
+ .trimmingCharacters(in: .whitespacesAndNewlines)
99
+ else { continue }
100
+ if skiaDawn != dawnReleaseTag {
101
+ fatalError(
102
+ """
103
+ react-native-webgpu: Dawn version mismatch. This package links \
104
+ react-native-webgpu-dawn \(dawnVersion) (\(dawnReleaseTag)) but the \
105
+ react-native-skia Graphite binaries (\(marker)) link \(skiaDawn). Align \
106
+ the two packages so the app contains exactly one Dawn.
107
+ """)
108
+ }
109
+ }
67
110
  }
68
111
 
69
112
  // Unlike a native Xcode target, SwiftPM doesn't generate an implicit
@@ -71,15 +114,10 @@ for marker in skiaDawnMarkers {
71
114
  // including file's own directory. The sources use bare cross-directory
72
115
  // includes (e.g. apple/WebGPUModule.h includes "RNWebGPUManager.h" from
73
116
  // cpp/rnwgpu), so every directory that's the target of one of those bare
74
- // includes has to be listed explicitly here.
117
+ // includes has to be listed explicitly here. The "webgpu/..." and "dawn/..."
118
+ // includes resolve through the Dawn xcframework's embedded headers.
75
119
  let internalHeaderDirs = [
76
120
  "apple",
77
- // "cpp" itself resolves the "webgpu/..." and "dawn/..." namespaced
78
- // includes. Those two directories are only present locally when built via
79
- // `yarn install-dawn` (without the xcframework's embedded headers); a
80
- // remote binaryTarget's xcframework embeds them instead (see
81
- // build-dawn.yml's `-headers` flag), so "cpp" not containing them there
82
- // is fine — the xcframework's own headers cover it.
83
121
  "cpp",
84
122
  "cpp/jsi",
85
123
  "cpp/rnwgpu",
@@ -102,16 +140,9 @@ let package = Package(
102
140
  dependencies: [
103
141
  .package(name: "React-GeneratedCode", path: "../../../ios"),
104
142
  .package(name: "ReactNative", path: "../../../../xcframeworks"),
143
+ .package(path: dawnPath),
105
144
  ],
106
145
  targets: [
107
- // Dawn's compiled WebGPU implementation. The xcframework embeds the
108
- // `webgpu/` and `dawn/` C headers per-slice (built via `-headers` in
109
- // build-dawn.yml), so SPM exposes them to dependents automatically.
110
- .binaryTarget(
111
- name: "WebGPUDawn",
112
- url: "https://github.com/wcandillon/react-native-webgpu/releases/download/dawn-chrome-m154/dawn-apple-dawn-chrome-m154.xcframework.zip",
113
- checksum: "896575ffbc99610198a83d061f8c5a2789139b7f16c669fbf3a9f7a7ac9be123"
114
- ),
115
146
  .target(
116
147
  name: "ReactNativeWebGPU",
117
148
  dependencies: [
@@ -120,13 +151,12 @@ let package = Package(
120
151
  .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
121
152
  // RNWgpuViewSpec, generated by the app's codegen run.
122
153
  .product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
123
- "WebGPUDawn",
154
+ .product(name: "react-native-webgpu-dawn", package: "react-native-webgpu-dawn"),
124
155
  ],
125
156
  // apple/ and cpp/ have no common ancestor below the package root, and
126
157
  // .headerSearchPath cannot escape the target path.
127
158
  path: ".",
128
- // Explicit, so SwiftPM never walks node_modules, lib, android, or the
129
- // headers-only cpp/webgpu and cpp/dawn trees.
159
+ // Explicit, so SwiftPM never walks node_modules, lib or android.
130
160
  sources: ["apple", "cpp/jsi", "cpp/rnwgpu"],
131
161
  // SwiftPM requires a public headers directory inside the target and
132
162
  // defaults to "include", which this package does not have.
@@ -7,8 +7,6 @@ set (CMAKE_CXX_STANDARD_REQUIRED True)
7
7
 
8
8
  set (PACKAGE_NAME "react-native-webgpu")
9
9
 
10
- #link_directories(../libs/android/${ANDROID_ABI}/)
11
-
12
10
  if(CMAKE_BUILD_TYPE STREQUAL "Debug")
13
11
  add_definitions(-DDEBUG=1)
14
12
  endif()
@@ -19,7 +17,15 @@ else()
19
17
  add_definitions(-DRNF_ENABLE_LOGS=0)
20
18
  endif()
21
19
 
22
- set (WEBGPU_LIBS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../libs/android/${ANDROID_ABI}")
20
+ # Dawn comes from the react-native-webgpu-dawn npm package (DAWN_DIR is passed
21
+ # by build.gradle): the shared library per ABI and the headers.
22
+ if(NOT DAWN_DIR)
23
+ message(FATAL_ERROR "react-native-webgpu: DAWN_DIR is not set (the react-native-webgpu-dawn package directory)")
24
+ endif()
25
+ set (WEBGPU_LIBS_PATH "${DAWN_DIR}/libs/android/${ANDROID_ABI}")
26
+ if(NOT EXISTS "${WEBGPU_LIBS_PATH}/libwebgpu_dawn.so")
27
+ message(FATAL_ERROR "react-native-webgpu: libwebgpu_dawn.so not found at ${WEBGPU_LIBS_PATH}. Reinstall dependencies (yarn install / npm install).")
28
+ endif()
23
29
 
24
30
  find_package(ReactAndroid REQUIRED CONFIG)
25
31
  find_package(fbjni REQUIRED CONFIG)
@@ -72,8 +78,8 @@ target_include_directories(
72
78
  ../cpp/rnwgpu/api
73
79
  ../cpp/rnwgpu/api/descriptors
74
80
  ../cpp/jsi
75
- ../cpp/webgpu
76
81
  ../cpp/platform
82
+ "${DAWN_DIR}/include"
77
83
 
78
84
  ${libfbjni_include_DIRS}
79
85
  )
@@ -45,6 +45,28 @@ static def findNodeModules(baseDir) {
45
45
 
46
46
  def nodeModules = findNodeModules(projectDir)
47
47
 
48
+ // Resolve a node package directory using Node's own module resolution
49
+ // (mirrors `require.resolve(pkg/package.json)`).
50
+ static def resolveNodePackage(packageName, baseDir) {
51
+ def script = "process.stdout.write(require('path').dirname(require.resolve('${packageName}/package.json')))"
52
+ def proc = ["node", "-e", script].execute(null, baseDir)
53
+ proc.waitFor()
54
+ if (proc.exitValue() != 0) {
55
+ throw new GradleException(
56
+ "react-native-webgpu: Could not resolve the '${packageName}' package. " +
57
+ "Make sure dependencies are installed (yarn install / npm install).\n" + proc.err.text
58
+ )
59
+ }
60
+ return proc.text.trim()
61
+ }
62
+
63
+ // Dawn, the WebGPU implementation, ships in the react-native-webgpu-dawn npm
64
+ // package this package depends on: libs/android/<abi>/libwebgpu_dawn.so and
65
+ // the headers under include/. react-native-skia's Graphite backend links the
66
+ // same package, so an app installing both contains exactly one Dawn.
67
+ def dawnDir = resolveNodePackage('react-native-webgpu-dawn', projectDir)
68
+ logger.warn("react-native-webgpu: Dawn from ${dawnDir}")
69
+
48
70
  def getExtOrDefault(name) {
49
71
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Wgpu_" + name]
50
72
  }
@@ -75,6 +97,7 @@ android {
75
97
  abiFilters (*reactNativeArchitectures())
76
98
  arguments '-DANDROID_STL=c++_shared',
77
99
  "-DNODE_MODULES_DIR=${nodeModules}",
100
+ "-DDAWN_DIR=${dawnDir}",
78
101
  "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
79
102
  }
80
103
  }
@@ -401,8 +401,8 @@ public:
401
401
  // not touch the device, and this must not change behaviour there.
402
402
  //
403
403
  // Remove once the pinned Dawn contains the upstream fix; the check in
404
- // scripts/install-dawn.ts fails the install when the Dawn pin changes so
405
- // that decision is not forgotten.
404
+ // scripts/check-dawn.ts fails when the Dawn the react-native-webgpu-dawn
405
+ // package was built from changes, so that decision is not forgotten.
406
406
  void releaseSurfaceForDevice(const wgpu::Device &device) {
407
407
  #if defined(__ANDROID__)
408
408
  std::unique_lock<std::shared_mutex> lock(_mutex);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webgpu",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -18,15 +18,13 @@
18
18
  "android/src/**",
19
19
  "cpp/**/*.{h,cpp}",
20
20
  "apple/**",
21
- "libs/**",
22
21
  "*.podspec",
23
22
  "Package.swift",
24
23
  "react-native.config.js",
25
24
  "app.plugin.js",
26
25
  "plugin/build/**"
27
26
  ],
28
- "dawn": "chrome-m154",
29
- "dawnCommit": "3d786993a7ded64c4ebb4884b9b079db9ad0e580",
27
+ "dawn": "chrome-m154a",
30
28
  "scripts": {
31
29
  "test": "NODE_OPTIONS='--experimental-require-module' jest -i",
32
30
  "test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
@@ -37,15 +35,12 @@
37
35
  "build": "bob build && yarn build:plugin",
38
36
  "build:plugin": "tsc -p plugin/tsconfig.build.json",
39
37
  "release": "semantic-release",
40
- "build-dawn": "tsx scripts/build/dawn.ts",
41
- "clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out",
42
38
  "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
43
39
  "clang-format-ios": "find apple/ -iname \"*.h\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
44
40
  "clang-format-android": "find android/cpp/ -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
45
41
  "clang-format-common": "find cpp/rnwgpu -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
46
42
  "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=example --exclude=android/.cxx --exclude=cpp/webgpu --exclude=cpp/dawn --exclude=ios --exclude=android/build --exclude=node_modules --recursive .",
47
- "install-dawn": "tsx scripts/install-dawn.ts",
48
- "generate-package-swift": "tsx scripts/generate-package-swift.ts"
43
+ "check-dawn": "tsx scripts/check-dawn.ts"
49
44
  },
50
45
  "keywords": [
51
46
  "react-native",
@@ -114,6 +109,9 @@
114
109
  "ws": "^8.18.0",
115
110
  "yargs": "^17.7.2"
116
111
  },
112
+ "dependencies": {
113
+ "react-native-webgpu-dawn": "154.2.0"
114
+ },
117
115
  "peerDependencies": {
118
116
  "react": "*",
119
117
  "react-native": ">=0.81.0",
@@ -1,8 +1,44 @@
1
1
  require "json"
2
+ require "fileutils"
2
3
 
3
4
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
5
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
6
 
7
+ # Resolve a node package directory using Node's own module resolution
8
+ # (mirrors `require.resolve(pkg/package.json)`). A lambda rather than a `def`:
9
+ # CocoaPods evaluates the podspec inside the `Pod` module, where top-level
10
+ # methods are not reachable at the call site.
11
+ resolve_node_package = lambda do |name, base_dir|
12
+ script = "process.stdout.write(require('path').dirname(require.resolve('#{name}/package.json')))"
13
+ dir = Dir.chdir(base_dir) { `node -e "#{script}" 2>/dev/null`.strip }
14
+ dir.empty? ? nil : dir
15
+ end
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
41
+
6
42
  Pod::Spec.new do |s|
7
43
  s.name = "react-native-webgpu"
8
44
  s.version = package["version"]
@@ -50,7 +86,7 @@ Pod::Spec.new do |s|
50
86
  end
51
87
 
52
88
  s.pod_target_xcconfig = {
53
- 'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/cpp',
89
+ 'HEADER_SEARCH_PATHS' => "$(PODS_TARGET_SRCROOT)/cpp \"#{dawn_include}\"",
54
90
  # Xcode's all-target headermaps let same-named headers leak across pods
55
91
  # (e.g. @shopify/react-native-skia keeps a jsi/ helper layer with
56
92
  # identical relative header paths). Resolve includes strictly through our
@@ -66,7 +102,7 @@ Pod::Spec.new do |s|
66
102
  s.dependency "React-Core"
67
103
  s.compiler_flags = folly_compiler_flags
68
104
  s.pod_target_xcconfig = {
69
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_TARGET_SRCROOT)/cpp\"",
105
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_TARGET_SRCROOT)/cpp\" \"#{dawn_include}\"",
70
106
  "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
71
107
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
72
108
  }