@shopify/react-native-skia 2.12.0 → 2.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 (103) hide show
  1. package/LICENSE.md +2 -1
  2. package/Package.swift +4 -4
  3. package/android/CMakeLists.txt +22 -177
  4. package/android/build.gradle +40 -209
  5. package/android/cpp/jni/JniSkiaManager.cpp +3 -45
  6. package/android/cpp/jni/include/JniPlatformContext.h +1 -1
  7. package/android/cpp/jni/include/JniSkiaBaseView.h +18 -11
  8. package/android/cpp/jni/include/JniSkiaManager.h +3 -4
  9. package/android/cpp/jni/include/JniSkiaPictureView.h +5 -5
  10. package/android/cpp/rnskia-android/RNSkAndroidView.h +6 -6
  11. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +4 -4
  12. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  13. package/android/src/main/AndroidManifest.xml +1 -1
  14. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/PlatformContext.java +1 -1
  15. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/RNSkVideo.java +1 -1
  16. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/RNSkiaModule.java +1 -8
  17. package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +57 -0
  18. package/android/src/main/java/com/reactnative/skia/SkiaBaseView.java +185 -0
  19. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaBaseViewManager.java +20 -1
  20. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaManager.java +11 -6
  21. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaPictureView.java +3 -3
  22. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaPictureViewManager.java +1 -1
  23. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaSurfaceView.java +13 -3
  24. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaTextureView.java +5 -3
  25. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/SkiaViewAPI.java +1 -1
  26. package/android/src/main/java/com/{shopify/reactnative → reactnative}/skia/ViewScreenshotService.java +1 -1
  27. package/apple/MetalContext.mm +1 -1
  28. package/apple/RNSkiaModule.h +1 -10
  29. package/apple/RNSkiaModule.mm +2 -10
  30. package/apple/SkiaManager.h +0 -2
  31. package/apple/SkiaManager.mm +4 -6
  32. package/apple/SkiaPictureView.h +2 -2
  33. package/apple/SkiaPictureView.mm +0 -4
  34. package/apple/SkiaUIView.h +3 -18
  35. package/apple/SkiaUIView.mm +0 -30
  36. package/cpp/api/CustomBlendModes.h +17 -0
  37. package/cpp/api/JsiSkCanvas.h +19 -10
  38. package/cpp/jsi/ViewProperty.h +0 -4
  39. package/lib/commonjs/mock/index.js +0 -1
  40. package/lib/commonjs/mock/index.js.map +1 -1
  41. package/lib/commonjs/renderer/Canvas.d.ts +11 -3
  42. package/lib/commonjs/renderer/Canvas.js +8 -6
  43. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkCanvas.js +9 -4
  45. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  46. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  47. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  48. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +3 -1
  49. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +3 -0
  50. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +1 -1
  51. package/lib/commonjs/views/SkiaPictureView.js +2 -12
  52. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  53. package/lib/commonjs/views/types.d.ts +19 -8
  54. package/lib/commonjs/views/types.js.map +1 -1
  55. package/lib/module/mock/index.js +0 -1
  56. package/lib/module/mock/index.js.map +1 -1
  57. package/lib/module/renderer/Canvas.d.ts +11 -3
  58. package/lib/module/renderer/Canvas.js +7 -5
  59. package/lib/module/renderer/Canvas.js.map +1 -1
  60. package/lib/module/skia/web/JsiSkCanvas.js +9 -4
  61. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  62. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  63. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  64. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +3 -1
  65. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +3 -0
  66. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +1 -1
  67. package/lib/module/views/SkiaPictureView.js +2 -12
  68. package/lib/module/views/SkiaPictureView.js.map +1 -1
  69. package/lib/module/views/types.d.ts +19 -8
  70. package/lib/module/views/types.js.map +1 -1
  71. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  72. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +2 -2
  73. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +3 -1
  74. package/lib/typescript/lib/module/mock/index.d.ts +0 -1
  75. package/lib/typescript/lib/module/renderer/Canvas.d.ts +2 -2
  76. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +3 -1
  77. package/lib/typescript/src/renderer/Canvas.d.ts +11 -3
  78. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  79. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +3 -1
  80. package/lib/typescript/src/views/types.d.ts +19 -8
  81. package/package.json +3 -3
  82. package/react-native-skia.podspec +4 -10
  83. package/src/mock/index.ts +0 -1
  84. package/src/renderer/Canvas.tsx +23 -5
  85. package/src/skia/web/JsiSkCanvas.ts +14 -9
  86. package/src/specs/SkiaPictureViewNativeComponent.ts +5 -0
  87. package/src/specs/SkiaPictureViewNativeComponent.web.ts +5 -0
  88. package/src/views/SkiaPictureView.tsx +2 -10
  89. package/src/views/types.ts +23 -10
  90. package/android/src/latest/java/com/shopify/reactnative/skia/ReactNativeCompatible.java +0 -11
  91. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +0 -79
  92. package/android/src/main/java/com/shopify/reactnative/skia/SkiaAHBView.java +0 -113
  93. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +0 -136
  94. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +0 -41
  95. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerInterface.java +0 -20
  96. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +0 -35
  97. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +0 -17
  98. package/android/src/paper/java/com/shopify/reactnative/skia/NativeSkiaModuleSpec.java +0 -38
  99. package/android/src/reactnative74/java/com/shopify/reactnative/skia/ReactNativeCompatible.java +0 -14
  100. package/apple/SkiaPictureViewManager.h +0 -8
  101. package/apple/SkiaPictureViewManager.mm +0 -60
  102. package/apple/SkiaWebGPUView.h +0 -20
  103. package/apple/WebGPUMetalView.h +0 -12
package/LICENSE.md CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2021-present, Shopify Inc.
1
+ Copyright 2026-present, William Candillon
2
+ Copyright 2021-2026, Shopify Inc.
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5
 
package/Package.swift CHANGED
@@ -86,10 +86,10 @@ let package = Package(
86
86
  .headerSearchPath("cpp/rnskia"), // apple/ uses bare "RNSkView.h"
87
87
  .headerSearchPath("cpp/utils"), // apple/ uses bare "RNSkLog.h"
88
88
 
89
- // CocoaPods forces both project-wide; the SwiftPM path defines neither.
90
- // Skia's Apple sources still gate on them: without them RNSkiaModule's
91
- // legacy branch fails to compile and -getTurboModule: is dropped, so
92
- // the JSI bindings never install.
89
+ // CocoaPods defines both project-wide for a New Architecture app; the
90
+ // SwiftPM path defines neither. Skia's own sources no longer gate on
91
+ // them, but React's headers do (RCT_REMOVE_LEGACY_ARCH hides the
92
+ // legacy bridge API), so mirror what CocoaPods does.
93
93
  .define("RCT_NEW_ARCH_ENABLED", to: "1"),
94
94
  .define("RCT_REMOVE_LEGACY_ARCH", to: "1"),
95
95
 
@@ -1,7 +1,6 @@
1
1
  project(RNSkia)
2
2
  cmake_minimum_required(VERSION 3.4.1)
3
3
 
4
- set (CMAKE_VERBOSE_MAKEFILE ON)
5
4
  set (CMAKE_CXX_STANDARD 20)
6
5
 
7
6
  # SKIA_LIBS_PATH is passed from Gradle (pointing at the prebuilt Skia binaries,
@@ -48,20 +47,7 @@ set (SKIA_SKSG_LIB "sksg")
48
47
  set (SKIA_JSONREADER_LIB "jsonreader")
49
48
 
50
49
 
51
- # Clear some variables
52
- unset(LIBRN_DIR CACHE)
53
- unset(libfbjni_link_DIRS CACHE)
54
- unset(libfbjni_include_DIRS CACHE)
55
-
56
- set(build_DIR ${CMAKE_SOURCE_DIR}/build)
57
- file(GLOB LIBRN_DIR "${PREBUILT_DIR}/${ANDROID_ABI}")
58
- file(GLOB libfbjni_link_DIRS "${build_DIR}/fbjni*.aar/jni/${ANDROID_ABI}")
59
- file(GLOB libfbjni_include_DIRS "${build_DIR}/fbjni-*-headers.jar/")
60
-
61
50
  message("-- ABI : " ${ANDROID_ABI})
62
- message("-- PREBUILT: " ${PREBUILT_DIR})
63
- message("-- BUILD : " ${build_DIR})
64
- message("-- LIBRN : " ${LIBRN_DIR})
65
51
 
66
52
  link_directories(${SKIA_LIBS_PATH}/)
67
53
 
@@ -80,14 +66,6 @@ else()
80
66
  )
81
67
  endif()
82
68
 
83
- if(${REACT_NATIVE_VERSION} LESS 66)
84
- file(
85
- TO_CMAKE_PATH
86
- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
87
- INCLUDE_JSI_CPP
88
- )
89
- endif()
90
-
91
69
  add_library(
92
70
  ${PACKAGE_NAME}
93
71
  SHARED
@@ -145,8 +123,6 @@ target_include_directories(
145
123
 
146
124
  # Shared JSI infrastructure (cpp/jsi) via prefix-qualified includes
147
125
  ../cpp
148
-
149
- ${libfbjni_include_DIRS}
150
126
  )
151
127
 
152
128
  add_library(svg STATIC IMPORTED)
@@ -189,113 +165,9 @@ find_library(
189
165
  )
190
166
  message("-- LOG : " ${LOG_LIB})
191
167
 
192
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
193
- # We need to find packages since from RN 0.71 binaries are prebuilt
194
- find_package(fbjni REQUIRED CONFIG)
195
- find_package(ReactAndroid REQUIRED CONFIG)
196
- endif()
197
-
198
- unset(JSI_LIB CACHE)
199
- if(${REACT_NATIVE_VERSION} LESS 66)
200
- # JSI lib didn't exist on RN 0.65 and before. Simply omit it.
201
- set (JSI_LIB "")
202
- elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
203
- # RN 0.71 distributes prebuilt binaries.
204
- set (JSI_LIB ReactAndroid::jsi)
205
- else()
206
- # RN 0.66 distributes libjsi.so, can be used instead of compiling jsi.cpp manually.
207
- find_library(
208
- JSI_LIB
209
- jsi
210
- PATHS ${LIBRN_DIR}
211
- NO_CMAKE_FIND_ROOT_PATH
212
- )
213
- endif()
214
- message("-- JSI : " ${JSI_LIB})
215
-
216
- unset(REACT_LIB CACHE)
217
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
218
- # RN 0.76 packs react_nativemodule_core into ReactAndroid::reactnative
219
- set (REACT_LIB ReactAndroid::reactnative)
220
- elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
221
- # RN 0.71 distributes prebuilt binaries.
222
- set (REACT_LIB ReactAndroid::react_nativemodule_core)
223
- else()
224
- find_library(
225
- REACT_LIB
226
- react_nativemodule_core
227
- PATHS ${LIBRN_DIR}
228
- NO_CMAKE_FIND_ROOT_PATH
229
- )
230
- endif()
231
- message("-- REACT : " ${REACT_LIB})
232
-
233
- unset(FBJNI_LIBRARY CACHE)
234
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
235
- # RN 0.71 distributes prebuilt binaries.
236
- set (FBJNI_LIBRARY fbjni::fbjni)
237
- else()
238
- find_library(
239
- FBJNI_LIBRARY
240
- fbjni
241
- PATHS ${libfbjni_link_DIRS}
242
- NO_CMAKE_FIND_ROOT_PATH
243
- )
244
- endif()
245
- message("-- FBJNI : " ${FBJNI_LIBRARY})
246
-
247
- unset(REACTNATIVEJNI_LIB CACHE)
248
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
249
- # RN 0.76 doesn't have reactnativejni
250
- # DO NOTHING, we'll not link these libraries
251
- elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
252
- # RN 0.71 distributes prebuilt binaries.
253
- set (REACTNATIVEJNI_LIB "ReactAndroid::reactnativejni")
254
- else()
255
- find_library(
256
- REACTNATIVEJNI_LIB
257
- reactnativejni
258
- PATHS ${LIBRN_DIR}
259
- NO_CMAKE_FIND_ROOT_PATH
260
- )
261
- endif()
262
- message("-- REACTNATIVEJNI : " ${REACTNATIVEJNI_LIB})
263
-
264
- unset(RUNTIMEEXECUTOR_LIB CACHE)
265
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
266
- # RN 0.76 doesn't have runtimeexecutor
267
- # DO NOTHING, we'll not link these libraries
268
- elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
269
- # RN 0.71 distributes prebuilt binaries.
270
- set (RUNTIMEEXECUTOR_LIB "ReactAndroid::runtimeexecutor")
271
- else()
272
- find_library(
273
- RUNTIMEEXECUTOR_LIB
274
- runtimeexecutor
275
- PATHS ${LIBRN_DIR}
276
- NO_CMAKE_FIND_ROOT_PATH
277
- )
278
- endif()
279
- message("-- RUNTIMEEXECUTOR : " ${RUNTIMEEXECUTOR_LIB})
280
-
281
- unset(TURBOMODULES_LIB CACHE)
282
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
283
- # RN 0.76 doesn't have turbomodulejsijni
284
- # DO NOTHING, we'll not link these libraries
285
- elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
286
- # RN 0.71 distributes prebuilt binaries.
287
- set (TURBOMODULES_LIB "ReactAndroid::turbomodulejsijni")
288
- else()
289
- find_library(
290
- TURBOMODULES_LIB
291
- turbomodulejsijni
292
- PATHS ${LIBRN_DIR}
293
- NO_CMAKE_FIND_ROOT_PATH
294
- )
295
- endif()
296
- message("-- TURBO : " ${TURBOMODULES_LIB})
297
-
298
- add_definitions(-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION})
168
+ # React Native distributes prebuilt binaries via prefab.
169
+ find_package(fbjni REQUIRED CONFIG)
170
+ find_package(ReactAndroid REQUIRED CONFIG)
299
171
 
300
172
  # Set RN_SERIALIZABLE_STATE and C++ flags for React Native 0.81+
301
173
  if(${REACT_NATIVE_VERSION} GREATER_EQUAL 80)
@@ -307,50 +179,25 @@ else()
307
179
  endif()
308
180
 
309
181
  # Link
310
- if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
311
- set(COMMON_LIBS
312
- ${LOG_LIB}
313
- ${REACT_LIB}
314
- ${FBJNI_LIBRARY}
315
- ${JSI_LIB}
316
- ${SKIA_SVG_LIB}
317
- ${SKIA_SKSHAPER_LIB}
318
- ${SKIA_SKPARAGRAPH_LIB}
319
- ${SKIA_SKUNICODE_CORE_LIB}
320
- ${SKIA_SKUNICODE_ICU_LIB}
321
- ${SKIA_SKOTTIE_LIB}
322
- ${SKIA_SKSG_LIB}
323
- ${SKIA_JSONREADER_LIB}
324
- ${SKIA_LIB}
325
- -ljnigraphics
326
- -lGLESv2
327
- -lEGL
328
- -landroid
329
- )
330
- else()
331
- set(COMMON_LIBS
332
- ${LOG_LIB}
333
- ${FBJNI_LIBRARY}
334
- ${REACT_LIB}
335
- ${JSI_LIB}
336
- ${REACTNATIVEJNI_LIB}
337
- ${RUNTIMEEXECUTOR_LIB}
338
- ${TURBOMODULES_LIB}
339
- ${SKIA_SVG_LIB}
340
- ${SKIA_SKSHAPER_LIB}
341
- ${SKIA_SKPARAGRAPH_LIB}
342
- ${SKIA_SKUNICODE_CORE_LIB}
343
- ${SKIA_SKUNICODE_ICU_LIB}
344
- ${SKIA_SKOTTIE_LIB}
345
- ${SKIA_SKSG_LIB}
346
- ${SKIA_JSONREADER_LIB}
347
- ${SKIA_LIB}
348
- -ljnigraphics
349
- -lGLESv2
350
- -lEGL
351
- -landroid
352
- )
353
- endif()
182
+ set(COMMON_LIBS
183
+ ${LOG_LIB}
184
+ ReactAndroid::reactnative
185
+ fbjni::fbjni
186
+ ReactAndroid::jsi
187
+ ${SKIA_SVG_LIB}
188
+ ${SKIA_SKSHAPER_LIB}
189
+ ${SKIA_SKPARAGRAPH_LIB}
190
+ ${SKIA_SKUNICODE_CORE_LIB}
191
+ ${SKIA_SKUNICODE_ICU_LIB}
192
+ ${SKIA_SKOTTIE_LIB}
193
+ ${SKIA_SKSG_LIB}
194
+ ${SKIA_JSONREADER_LIB}
195
+ ${SKIA_LIB}
196
+ -ljnigraphics
197
+ -lGLESv2
198
+ -lEGL
199
+ -landroid
200
+ )
354
201
 
355
202
  if(SK_GRAPHITE)
356
203
  target_link_libraries(${PACKAGE_NAME}
@@ -360,8 +207,6 @@ if(SK_GRAPHITE)
360
207
  else()
361
208
  target_link_libraries(${PACKAGE_NAME}
362
209
  ${COMMON_LIBS}
363
- -lGLESv2
364
- -lEGL
365
210
  )
366
211
  endif()
367
212
 
@@ -2,39 +2,23 @@ import java.nio.file.Paths
2
2
 
3
3
  // android/build.gradle
4
4
 
5
- // based on:
6
- //
7
- // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
8
- // previous location:
9
- // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
10
- //
11
- // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
12
- // previous location:
13
- // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
14
-
15
5
  // FBJNI build is based on:
16
6
  // https://github.com/facebookincubator/fbjni/blob/main/docs/android_setup.md
17
7
 
18
8
  // These defaults should reflect the SDK versions used by
19
- // the minimum React Native version supported.
20
- def DEFAULT_COMPILE_SDK_VERSION = 28
21
- def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
22
- def DEFAULT_MIN_SDK_VERSION = 21
23
- def DEFAULT_TARGET_SDK_VERSION = 28
9
+ // the minimum React Native version supported (0.78).
10
+ def DEFAULT_COMPILE_SDK_VERSION = 35
11
+ def DEFAULT_BUILD_TOOLS_VERSION = '35.0.0'
12
+ def DEFAULT_MIN_SDK_VERSION = 24
13
+ def DEFAULT_TARGET_SDK_VERSION = 34
24
14
 
25
15
  def safeExtGet(prop, fallback) {
26
16
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
27
17
  }
28
18
 
29
- def isNewArchitectureEnabled() {
30
- // To opt-in for the New Architecture, you can either:
31
- // - Set `newArchEnabled` to true inside the `gradle.properties` file
32
- // - Invoke gradle with `-newArchEnabled=true`
33
- // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
34
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
35
- }
36
-
37
19
  apply plugin: 'com.android.library'
20
+ // Runs codegen for the TurboModule spec and the Fabric component (src/specs).
21
+ apply plugin: 'com.facebook.react'
38
22
 
39
23
  def reactNativeArchitectures() {
40
24
  def value = project.getProperties().get("reactNativeArchitectures")
@@ -128,10 +112,6 @@ logger.warn("react-native-skia: node_modules/ found at: ${nodeModules}")
128
112
  def sourceBuild = false
129
113
  def defaultDir
130
114
 
131
- if (isNewArchitectureEnabled()) {
132
- apply plugin: "com.facebook.react"
133
- }
134
-
135
115
  if (rootProject.ext.has('reactNativeAndroidRoot')) {
136
116
  defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
137
117
  } else if (findProject(':ReactAndroid') != null) {
@@ -147,54 +127,18 @@ if (!defaultDir.exists()) {
147
127
  )
148
128
  }
149
129
 
150
- def prebuiltDir = sourceBuild
151
- ? "$nodeModules/react-native/ReactAndroid/src/main/jni/prebuilt/lib"
152
- : "$buildDir/react-native-0*/jni"
153
-
154
-
155
- def buildType = "debug"
156
- if (gradle.startParameter.taskRequests.args[0].toString().contains("Release")) {
157
- buildType = "release"
158
- } else if (gradle.startParameter.taskRequests.args[0].toString().contains("Debug")) {
159
- buildType = "debug"
160
- }
161
-
162
130
  def reactProperties = new Properties()
163
131
  file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
164
132
  def FULL_RN_VERSION = (System.getenv("REACT_NATIVE_OVERRIDE_VERSION") ?: reactProperties.getProperty("VERSION_NAME"))
165
133
  def REACT_NATIVE_VERSION = FULL_RN_VERSION.split("\\.")[1].toInteger()
166
- def ENABLE_PREFAB = REACT_NATIVE_VERSION > 68
167
134
 
168
135
  logger.warn("react-native-skia: RN Version: ${REACT_NATIVE_VERSION} / ${FULL_RN_VERSION}")
169
136
  logger.warn("react-native-skia: isSourceBuild: ${sourceBuild}")
170
- logger.warn("react-native-skia: PrebuiltDir: ${prebuiltDir}")
171
- logger.warn("react-native-skia: buildType: ${buildType}")
172
137
  logger.warn("react-native-skia: buildDir: ${buildDir}")
173
138
  logger.warn("react-native-skia: node_modules: ${nodeModules}")
174
- logger.warn("react-native-skia: Enable Prefab: ${ENABLE_PREFAB}")
175
-
176
- buildscript {
177
- // The Android Gradle plugin is only required when opening the android folder stand-alone.
178
- // This avoids unnecessary downloads and potential conflicts when the library is included as a
179
- // module dependency in an application project.
180
- // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
181
- if (project == rootProject) {
182
- repositories {
183
- google()
184
- }
185
- dependencies {
186
- // This should reflect the Gradle plugin version used by
187
- // the minimum React Native version supported.
188
- classpath 'com.android.tools.build:gradle:3.4.1'
189
- }
190
- }
191
- }
192
139
 
193
140
  android {
194
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
195
- if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
196
- namespace "com.shopify.reactnative.skia"
197
- }
141
+ namespace "com.reactnative.skia"
198
142
 
199
143
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
200
144
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
@@ -213,17 +157,15 @@ android {
213
157
  targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
214
158
  versionCode 1
215
159
  versionName "1.0"
216
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
217
160
 
218
161
  externalNativeBuild {
219
162
  cmake {
220
- cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
163
+ cppFlags "-fexceptions", "-frtti"
221
164
  abiFilters (*reactNativeArchitectures())
222
165
  arguments '-DANDROID_STL=c++_shared',
223
166
  "-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION}",
224
167
  "-DREACT_NATIVE_DIR=${defaultDir}",
225
168
  "-DNODE_MODULES_DIR=${nodeModules}",
226
- "-DPREBUILT_DIR=${prebuiltDir}",
227
169
  "-DSKIA_LIBS_PATH=${skiaLibsPath}",
228
170
  "-DSK_GRAPHITE=${useGraphite ? 'ON' : 'OFF'}",
229
171
  "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
@@ -245,25 +187,6 @@ android {
245
187
  jniLibs {
246
188
  srcDirs += [skiaLibsPath]
247
189
  }
248
- java {
249
- if (!isNewArchitectureEnabled()) {
250
- srcDirs += [
251
- "src/paper/java",
252
- ]
253
- }
254
-
255
- if (REACT_NATIVE_VERSION == 74) {
256
- srcDirs += [
257
- "src/reactnative74/java"
258
- ]
259
- } else {
260
- // the name latest here might be confusing as it applies for versions
261
- // below 74 as well
262
- srcDirs += [
263
- "src/latest/java"
264
- ]
265
- }
266
- }
267
190
  }
268
191
 
269
192
  externalNativeBuild {
@@ -277,45 +200,23 @@ android {
277
200
  "**/libc++_shared.so",
278
201
  "**/libfbjni.so",
279
202
  "**/libjsi.so",
280
- "**/libreact_nativemodule_core.so",
281
- "**/libreactnativejni.so",
282
- "**/libruntimeexecutor.so",
283
- "**/libturbomodulejsijni.so",
284
203
  "**/libreactnative.so",
285
204
  "META-INF/**"
286
205
  ]
287
206
  }
288
207
 
289
- if (ENABLE_PREFAB) {
290
- buildFeatures {
291
- prefab true
292
- prefabPublishing true
293
- }
294
- prefab {
295
- rnskia {
296
- headers "${project.buildDir}/headers/rnskia/"
297
- }
298
- }
208
+ buildFeatures {
209
+ prefab true
210
+ prefabPublishing true
299
211
  }
300
-
301
- // Create new configurations that can be referred to in dependencies.
302
- // The Android Gradle Plugin 3.* does not allow hooking into existing
303
- // configurations like `implementation`.
304
- configurations {
305
- extractHeaders
306
- extractJNI
212
+ prefab {
213
+ rnskia {
214
+ headers "${project.buildDir}/headers/rnskia/"
215
+ }
307
216
  }
308
217
  }
309
218
 
310
219
  repositories {
311
- maven {
312
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
313
- url("$rootDir/../node_modules/react-native/android")
314
- }
315
- maven {
316
- // Android JSC is installed from npm
317
- url("$rootDir/../node_modules/jsc-android/dist")
318
- }
319
220
  mavenCentral {
320
221
  // We don't want to fetch react-native from Maven Central as there are
321
222
  // older versions over there.
@@ -329,102 +230,32 @@ repositories {
329
230
  dependencies {
330
231
  //noinspection GradleDynamicVersion
331
232
  implementation 'com.facebook.react:react-native:+' // From node_modules
332
-
333
- if (REACT_NATIVE_VERSION < 71) {
334
- logger.warn("react-native-skia: Extracting files from AAR (pre RN 0.71)")
335
- //noinspection GradleDynamicVersion
336
- extractHeaders("com.facebook.fbjni:fbjni:0.2.2:headers")
337
- //noinspection GradleDynamicVersion
338
- extractJNI("com.facebook.fbjni:fbjni:0.2.2")
339
- }
340
-
341
- if (!sourceBuild) {
342
- def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
343
- if (REACT_NATIVE_VERSION < 69) {
344
- logger.warn("react-native-skia: aar state pre 69. match **/**/*.aar")
345
- rnAarMatcher = "**/**/*.aar"
346
- } else if (REACT_NATIVE_VERSION >= 71) {
347
- logger.warn("react-native-skia: aar state post 70, do nothing")
348
- return
349
- }
350
- def rnAAR = fileTree("${nodeModules}/react-native/android").matching({ it.include rnAarMatcher }).singleFile
351
- logger.warn("react-native-skia: Extracting JNI files (pre RN 0.71) ${rnAAR}")
352
- extractJNI(files(rnAAR))
353
- }
354
233
  }
355
234
 
356
- def localBuildDir = buildDir
357
- def headersConfiguration = configurations.extractHeaders
358
- def jniConfiguration = configurations.extractJNI
359
-
360
- task extractAARHeaders {
361
- doLast {
362
- headersConfiguration.files.each { file ->
363
- def absFile = file.absoluteFile
364
- project.copy {
365
- from project.zipTree(absFile)
366
- into "${localBuildDir}/${absFile.name}"
367
- include "**/*.h"
368
- }
235
+ // Package all the cpp code in a flattened directory structure
236
+ task prepareHeaders(type: Copy) {
237
+ from("../cpp")
238
+ from("./cpp")
239
+ into "${project.buildDir}/headers/rnskia/react-native-skia"
240
+ includeEmptyDirs = false
241
+ include "**/*.h"
242
+ eachFile {
243
+ String path = it.path
244
+
245
+ if (path.contains("api/third_party")) {
246
+ // Skip flattening third_party dir
247
+ path = path.substring("api/".length())
248
+ } else if (path.contains("skia/include") || path.contains("skia/modules") || path.contains("skia/src")) {
249
+ // Skip flattening Skia dir
250
+ path = path.substring("skia/".length())
251
+ } else if (path.startsWith("dawn/include/")) {
252
+ // Flatten dawn/include/dawn and dawn/include/webgpu
253
+ path = path.substring("dawn/include/".length())
254
+ } else {
255
+ // flatten anything else
256
+ path = path.substring(path.lastIndexOf("/") + 1)
369
257
  }
258
+ it.path = path
370
259
  }
371
260
  }
372
-
373
- task extractJNIFiles {
374
- doLast {
375
- jniConfiguration.files.each { file ->
376
- def absFile = file.absoluteFile
377
- project.copy {
378
- from project.zipTree(absFile)
379
- into "${localBuildDir}/${absFile.name}"
380
- include "jni/**/*"
381
- }
382
- }
383
- }
384
- }
385
-
386
- extractJNIFiles.mustRunAfter extractAARHeaders
387
-
388
- if (ENABLE_PREFAB) {
389
- // Package all the cpp code in a flattened directory structure
390
- task prepareHeaders(type: Copy) {
391
- from("../cpp")
392
- from("./cpp")
393
- into "${project.buildDir}/headers/rnskia/react-native-skia"
394
- includeEmptyDirs = false
395
- include "**/*.h"
396
- eachFile {
397
- String path = it.path
398
-
399
- if (path.contains("api/third_party")) {
400
- // Skip flattening third_party dir
401
- path = path.substring("api/".length())
402
- } else if (path.contains("skia/include") || path.contains("skia/modules") || path.contains("skia/src")) {
403
- // Skip flattening Skia dir
404
- path = path.substring("skia/".length())
405
- } else if (path.startsWith("dawn/include/")) {
406
- // Flatten dawn/include/dawn and dawn/include/webgpu
407
- path = path.substring("dawn/include/".length())
408
- } else {
409
- // flatten anything else
410
- path = path.substring(path.lastIndexOf("/") + 1)
411
- }
412
- it.path = path
413
- }
414
- }
415
- preBuild.dependsOn(prepareHeaders)
416
- }
417
-
418
- def nativeBuildDependsOn(dependsOnTask, variant) {
419
- def buildTasks = tasks.findAll({ task ->
420
- !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
421
- if (variant != null) {
422
- buildTasks = buildTasks.findAll({ task -> task.name.contains(variant) })
423
- }
424
- buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
425
- }
426
-
427
- afterEvaluate {
428
- nativeBuildDependsOn(extractAARHeaders, null)
429
- nativeBuildDependsOn(extractJNIFiles, null)
430
- }
261
+ preBuild.dependsOn(prepareHeaders)
@@ -7,47 +7,6 @@
7
7
 
8
8
  #include "RNSkManager.h"
9
9
 
10
- namespace {
11
-
12
- #if REACT_NATIVE_VERSION >= 75
13
- using CallFuncType = facebook::react::CallFunc;
14
- #else
15
- using CallFuncType = std::function<void()>;
16
- #endif
17
-
18
- // For bridgeless mode, currently we don't have a way to get the JSCallInvoker
19
- // from Java. Workaround to use RuntimeExecutor to simulate the behavior of
20
- // JSCallInvoker. In the future when bridgeless mode is a standard and no more
21
- // backward compatible to be considered, we could just use RuntimeExecutor to
22
- // run task on JS thread.
23
- class BridgelessJSCallInvoker : public facebook::react::CallInvoker {
24
- public:
25
- explicit BridgelessJSCallInvoker(
26
- facebook::react::RuntimeExecutor runtimeExecutor)
27
- : runtimeExecutor_(std::move(runtimeExecutor)) {}
28
-
29
- void invokeAsync(CallFuncType &&func) noexcept override {
30
- runtimeExecutor_([func = std::move(func)](facebook::jsi::Runtime &runtime) {
31
- #if REACT_NATIVE_VERSION >= 75
32
- func(runtime);
33
- #else
34
- func();
35
- #endif
36
- });
37
- }
38
-
39
- void invokeSync(CallFuncType &&func) override {
40
- throw std::runtime_error(
41
- "Synchronous native -> JS calls are currently not supported.");
42
- }
43
-
44
- private:
45
- facebook::react::RuntimeExecutor runtimeExecutor_;
46
-
47
- }; // class BridgelessJSCallInvoker
48
-
49
- } // namespace
50
-
51
10
  namespace RNSkia {
52
11
 
53
12
  namespace jsi = facebook::jsi;
@@ -65,12 +24,11 @@ void JniSkiaManager::registerNatives() {
65
24
  jni::local_ref<jni::HybridClass<JniSkiaManager>::jhybriddata>
66
25
  JniSkiaManager::initHybrid(
67
26
  jni::alias_ref<jhybridobject> jThis, jlong jsContext,
68
- jni::alias_ref<facebook::react::JRuntimeExecutor::javaobject>
69
- jRuntimeExecutor,
27
+ jni::alias_ref<facebook::react::CallInvokerHolder::javaobject>
28
+ jsCallInvokerHolder,
70
29
  JavaPlatformContext skiaContext) {
71
30
 
72
- auto jsCallInvoker = std::make_shared<BridgelessJSCallInvoker>(
73
- jRuntimeExecutor->cthis()->get());
31
+ auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
74
32
  // cast from JNI hybrid objects to C++ instances
75
33
  return makeCxxInstance(jThis, reinterpret_cast<jsi::Runtime *>(jsContext),
76
34
  jsCallInvoker, skiaContext->cthis());
@@ -21,7 +21,7 @@ namespace jni = facebook::jni;
21
21
  class JniPlatformContext : public jni::HybridClass<JniPlatformContext> {
22
22
  public:
23
23
  static auto constexpr kJavaDescriptor =
24
- "Lcom/shopify/reactnative/skia/PlatformContext;";
24
+ "Lcom/reactnative/skia/PlatformContext;";
25
25
 
26
26
  static jni::local_ref<jhybriddata>
27
27
  initHybrid(jni::alias_ref<jhybridobject> jThis, const float);