react-native-nitro-unzip 0.2.5 → 0.2.7

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.
@@ -18,6 +18,8 @@ apply plugin: 'kotlin-android'
18
18
 
19
19
  // Nitrogen autolinking — adds generated Kotlin sources
20
20
  apply from: '../nitrogen/generated/android/NitroUnzip+autolinking.gradle'
21
+ // Fix prefab discovery for sibling project dependencies (e.g. react-native-nitro-modules)
22
+ apply from: './fix-prefab.gradle'
21
23
 
22
24
  android {
23
25
  namespace "com.margelo.nitro.unzip"
@@ -30,6 +32,7 @@ android {
30
32
  externalNativeBuild {
31
33
  cmake {
32
34
  cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
35
+ arguments "-DANDROID_STL=c++_shared"
33
36
  abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
34
37
  }
35
38
  }
@@ -43,6 +46,29 @@ android {
43
46
  jvmTarget = '17'
44
47
  }
45
48
 
49
+ packagingOptions {
50
+ excludes = [
51
+ "META-INF",
52
+ "META-INF/**",
53
+ "**/libNitroModules.so",
54
+ "**/libc++_shared.so",
55
+ "**/libfbjni.so",
56
+ "**/libjsi.so",
57
+ "**/libfolly_json.so",
58
+ "**/libfolly_runtime.so",
59
+ "**/libglog.so",
60
+ "**/libhermes.so",
61
+ "**/libreactnative.so",
62
+ "**/libreactnativejni.so",
63
+ "**/libturbomodulejsijni.so",
64
+ "**/libreact_nativemodule_core.so",
65
+ ]
66
+ }
67
+
68
+ buildFeatures {
69
+ prefab true
70
+ }
71
+
46
72
  sourceSets {
47
73
  main {
48
74
  java.srcDirs += ['src/main/java']
@@ -64,6 +90,7 @@ repositories {
64
90
  dependencies {
65
91
  implementation "com.facebook.react:react-android:+"
66
92
  implementation "com.facebook.react:react-native:+"
93
+ implementation project(":react-native-nitro-modules")
67
94
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
68
95
  // zip4j — needed for password-protected zip/unzip (java.util.zip has no password API)
69
96
  implementation "net.lingala.zip4j:zip4j:2.11.5"
@@ -0,0 +1,54 @@
1
+ // Workaround for Android prefab + CMake discovery of sibling project .so files.
2
+ // Ensures that when react-native-nitro-modules is built as a local project dependency,
3
+ // its prefab_config.json is regenerated to include the .so file (not just headers).
4
+ // See: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt
5
+
6
+ tasks.configureEach { task ->
7
+ def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
8
+ def matcher = task.name =~ prefabConfigurePattern
9
+ if (matcher.matches()) {
10
+ def variantName = matcher[0][1]
11
+ task.outputs.upToDateWhen { false }
12
+ task.dependsOn("externalNativeBuild${variantName}")
13
+ }
14
+ }
15
+
16
+ afterEvaluate {
17
+ def abis = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
18
+ // Check if the root project overrides architectures
19
+ if (rootProject.hasProperty("reactNativeArchitectures")) {
20
+ abis = rootProject.getProperty("reactNativeArchitectures").split(",").toList()
21
+ }
22
+
23
+ rootProject.allprojects.each { proj ->
24
+ if (proj === rootProject) return
25
+
26
+ def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
27
+ config.dependencies.any { dep ->
28
+ dep.group == project.group && dep.name == project.name
29
+ }
30
+ }
31
+ if (!dependsOnThisLib && proj != project) return
32
+
33
+ if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
34
+ return
35
+ }
36
+
37
+ def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
38
+ variants.all { variant ->
39
+ def variantName = variant.name
40
+ abis.each { abi ->
41
+ def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
42
+ if (!searchDir.exists()) return
43
+ def matches = []
44
+ searchDir.eachDir { randomDir ->
45
+ def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
46
+ if (prefabFile.exists()) matches << prefabFile
47
+ }
48
+ matches.each { prefabConfig ->
49
+ prefabConfig.setLastModified(System.currentTimeMillis())
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -9,8 +9,6 @@ import com.facebook.proguard.annotations.DoNotStrip
9
9
  @DoNotStrip
10
10
  @Keep
11
11
  class HybridUnzip : HybridUnzipSpec() {
12
- override val memorySize: Long = 0L
13
-
14
12
  override fun extract(zipPath: String, destinationPath: String): HybridUnzipTaskSpec {
15
13
  return HybridUnzipTask(zipPath, destinationPath)
16
14
  }
@@ -29,8 +29,6 @@ class HybridUnzipTask(
29
29
  private val password: String? = null
30
30
  ) : HybridUnzipTaskSpec() {
31
31
 
32
- override val memorySize: Long = 0L
33
-
34
32
  override val taskId: String = "unzip_${System.nanoTime()}_${(Math.random() * 1e9).toLong()}"
35
33
 
36
34
  private var progressCallback: ((UnzipProgress) -> Unit)? = null
@@ -26,8 +26,6 @@ class HybridZipTask(
26
26
  private val password: String? = null
27
27
  ) : HybridZipTaskSpec() {
28
28
 
29
- override val memorySize: Long = 0L
30
-
31
29
  override val taskId: String = "zip_${System.nanoTime()}_${(Math.random() * 1e9).toLong()}"
32
30
 
33
31
  private var progressCallback: ((ZipProgress) -> Unit)? = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-unzip",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "High-performance ZIP extraction for React Native, powered by Nitro Modules",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",