@onekeyfe/react-native-zip-archive 3.0.38 → 3.0.39

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 (47) hide show
  1. package/{ZipArchive.podspec → ReactNativeZipArchive.podspec} +12 -3
  2. package/android/CMakeLists.txt +24 -0
  3. package/android/build.gradle +54 -3
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  7. package/android/src/main/java/com/margelo/nitro/reactnativeziparchive/ReactNativeZipArchive.kt +139 -0
  8. package/android/src/main/java/com/margelo/nitro/reactnativeziparchive/ReactNativeZipArchivePackage.kt +22 -0
  9. package/ios/ReactNativeZipArchive.swift +130 -0
  10. package/lib/module/ReactNativeZipArchive.nitro.js +4 -0
  11. package/lib/module/index.js +24 -3
  12. package/lib/typescript/src/{NativeZipArchive.d.ts → ReactNativeZipArchive.nitro.d.ts} +6 -5
  13. package/lib/typescript/src/index.d.ts +10 -2
  14. package/nitro.json +17 -0
  15. package/nitrogen/generated/android/c++/JHybridReactNativeZipArchiveSpec.cpp +155 -0
  16. package/nitrogen/generated/android/c++/JHybridReactNativeZipArchiveSpec.hpp +70 -0
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeziparchive/HybridReactNativeZipArchiveSpec.kt +78 -0
  18. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeziparchive/reactnativeziparchiveOnLoad.kt +35 -0
  19. package/nitrogen/generated/android/reactnativeziparchive+autolinking.cmake +81 -0
  20. package/nitrogen/generated/android/reactnativeziparchive+autolinking.gradle +27 -0
  21. package/nitrogen/generated/android/reactnativeziparchiveOnLoad.cpp +44 -0
  22. package/nitrogen/generated/android/reactnativeziparchiveOnLoad.hpp +25 -0
  23. package/nitrogen/generated/ios/ReactNativeZipArchive+autolinking.rb +60 -0
  24. package/nitrogen/generated/ios/ReactNativeZipArchive-Swift-Cxx-Bridge.cpp +65 -0
  25. package/nitrogen/generated/ios/ReactNativeZipArchive-Swift-Cxx-Bridge.hpp +209 -0
  26. package/nitrogen/generated/ios/ReactNativeZipArchive-Swift-Cxx-Umbrella.hpp +46 -0
  27. package/nitrogen/generated/ios/ReactNativeZipArchiveAutolinking.mm +33 -0
  28. package/nitrogen/generated/ios/ReactNativeZipArchiveAutolinking.swift +25 -0
  29. package/nitrogen/generated/ios/c++/HybridReactNativeZipArchiveSpecSwift.cpp +11 -0
  30. package/nitrogen/generated/ios/c++/HybridReactNativeZipArchiveSpecSwift.hpp +118 -0
  31. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  32. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  33. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  34. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  35. package/nitrogen/generated/ios/swift/HybridReactNativeZipArchiveSpec.swift +61 -0
  36. package/nitrogen/generated/ios/swift/HybridReactNativeZipArchiveSpec_cxx.swift +233 -0
  37. package/nitrogen/generated/shared/c++/HybridReactNativeZipArchiveSpec.cpp +26 -0
  38. package/nitrogen/generated/shared/c++/HybridReactNativeZipArchiveSpec.hpp +69 -0
  39. package/package.json +22 -17
  40. package/src/ReactNativeZipArchive.nitro.ts +26 -0
  41. package/src/index.tsx +47 -4
  42. package/android/src/main/java/com/rnziparchive/RNZipArchiveModule.kt +0 -158
  43. package/android/src/main/java/com/rnziparchive/RNZipArchivePackage.kt +0 -33
  44. package/ios/ZipArchive.h +0 -10
  45. package/ios/ZipArchive.mm +0 -182
  46. package/lib/module/NativeZipArchive.js +0 -5
  47. package/src/NativeZipArchive.ts +0 -13
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// HybridReactNativeZipArchiveSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridReactNativeZipArchiveSpec``
12
+ public protocol HybridReactNativeZipArchiveSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func isPasswordProtected(file: String) throws -> Promise<Bool>
18
+ func unzip(from: String, to: String) throws -> Promise<String>
19
+ func unzipWithPassword(from: String, to: String, password: String) throws -> Promise<String>
20
+ func zipFolder(from: String, to: String) throws -> Promise<String>
21
+ func zipFiles(files: [String], to: String) throws -> Promise<String>
22
+ func getUncompressedSize(path: String) throws -> Promise<Double>
23
+ }
24
+
25
+ public extension HybridReactNativeZipArchiveSpec_protocol {
26
+ /// Default implementation of ``HybridObject.toString``
27
+ func toString() -> String {
28
+ return "[HybridObject ReactNativeZipArchive]"
29
+ }
30
+ }
31
+
32
+ /// See ``HybridReactNativeZipArchiveSpec``
33
+ open class HybridReactNativeZipArchiveSpec_base {
34
+ private weak var cxxWrapper: HybridReactNativeZipArchiveSpec_cxx? = nil
35
+ public init() { }
36
+ public func getCxxWrapper() -> HybridReactNativeZipArchiveSpec_cxx {
37
+ #if DEBUG
38
+ guard self is HybridReactNativeZipArchiveSpec else {
39
+ fatalError("`self` is not a `HybridReactNativeZipArchiveSpec`! Did you accidentally inherit from `HybridReactNativeZipArchiveSpec_base` instead of `HybridReactNativeZipArchiveSpec`?")
40
+ }
41
+ #endif
42
+ if let cxxWrapper = self.cxxWrapper {
43
+ return cxxWrapper
44
+ } else {
45
+ let cxxWrapper = HybridReactNativeZipArchiveSpec_cxx(self as! HybridReactNativeZipArchiveSpec)
46
+ self.cxxWrapper = cxxWrapper
47
+ return cxxWrapper
48
+ }
49
+ }
50
+ }
51
+
52
+ /**
53
+ * A Swift base-protocol representing the ReactNativeZipArchive HybridObject.
54
+ * Implement this protocol to create Swift-based instances of ReactNativeZipArchive.
55
+ * ```swift
56
+ * class HybridReactNativeZipArchive : HybridReactNativeZipArchiveSpec {
57
+ * // ...
58
+ * }
59
+ * ```
60
+ */
61
+ public typealias HybridReactNativeZipArchiveSpec = HybridReactNativeZipArchiveSpec_protocol & HybridReactNativeZipArchiveSpec_base
@@ -0,0 +1,233 @@
1
+ ///
2
+ /// HybridReactNativeZipArchiveSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridReactNativeZipArchiveSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridReactNativeZipArchiveSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativeziparchive::bridge::swift`)
23
+ * from `ReactNativeZipArchive-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.reactnativeziparchive.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridReactNativeZipArchiveSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridReactNativeZipArchiveSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridReactNativeZipArchiveSpec_
37
+
38
+ /**
39
+ * Create a new `HybridReactNativeZipArchiveSpec_cxx` that wraps the given `HybridReactNativeZipArchiveSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridReactNativeZipArchiveSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridReactNativeZipArchiveSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridReactNativeZipArchiveSpec() -> any HybridReactNativeZipArchiveSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridReactNativeZipArchiveSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridReactNativeZipArchiveSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridReactNativeZipArchiveSpec_cxx {
70
+ return Unmanaged<HybridReactNativeZipArchiveSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridReactNativeZipArchiveSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridReactNativeZipArchiveSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridReactNativeZipArchiveSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridReactNativeZipArchiveSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ /**
109
+ * Call toString() on the Swift class.
110
+ */
111
+ @inline(__always)
112
+ public func toString() -> String {
113
+ return self.__implementation.toString()
114
+ }
115
+
116
+ // Properties
117
+
118
+
119
+ // Methods
120
+ @inline(__always)
121
+ public final func isPasswordProtected(file: std.string) -> bridge.Result_std__shared_ptr_Promise_bool___ {
122
+ do {
123
+ let __result = try self.__implementation.isPasswordProtected(file: String(file))
124
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
125
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
126
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
127
+ __result
128
+ .then({ __result in __promiseHolder.resolve(__result) })
129
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
130
+ return __promise
131
+ }()
132
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
136
+ }
137
+ }
138
+
139
+ @inline(__always)
140
+ public final func unzip(from: std.string, to: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
141
+ do {
142
+ let __result = try self.__implementation.unzip(from: String(from), to: String(to))
143
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
144
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
145
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
146
+ __result
147
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
148
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
149
+ return __promise
150
+ }()
151
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
152
+ } catch (let __error) {
153
+ let __exceptionPtr = __error.toCpp()
154
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
155
+ }
156
+ }
157
+
158
+ @inline(__always)
159
+ public final func unzipWithPassword(from: std.string, to: std.string, password: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
160
+ do {
161
+ let __result = try self.__implementation.unzipWithPassword(from: String(from), to: String(to), password: String(password))
162
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
163
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
164
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
165
+ __result
166
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
167
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
168
+ return __promise
169
+ }()
170
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
171
+ } catch (let __error) {
172
+ let __exceptionPtr = __error.toCpp()
173
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
174
+ }
175
+ }
176
+
177
+ @inline(__always)
178
+ public final func zipFolder(from: std.string, to: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
179
+ do {
180
+ let __result = try self.__implementation.zipFolder(from: String(from), to: String(to))
181
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
182
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
183
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
184
+ __result
185
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
186
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
187
+ return __promise
188
+ }()
189
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
190
+ } catch (let __error) {
191
+ let __exceptionPtr = __error.toCpp()
192
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
193
+ }
194
+ }
195
+
196
+ @inline(__always)
197
+ public final func zipFiles(files: bridge.std__vector_std__string_, to: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
198
+ do {
199
+ let __result = try self.__implementation.zipFiles(files: files.map({ __item in String(__item) }), to: String(to))
200
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
201
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
202
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
203
+ __result
204
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
205
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
206
+ return __promise
207
+ }()
208
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
209
+ } catch (let __error) {
210
+ let __exceptionPtr = __error.toCpp()
211
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
212
+ }
213
+ }
214
+
215
+ @inline(__always)
216
+ public final func getUncompressedSize(path: std.string) -> bridge.Result_std__shared_ptr_Promise_double___ {
217
+ do {
218
+ let __result = try self.__implementation.getUncompressedSize(path: String(path))
219
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_double__ in
220
+ let __promise = bridge.create_std__shared_ptr_Promise_double__()
221
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_double__(__promise)
222
+ __result
223
+ .then({ __result in __promiseHolder.resolve(__result) })
224
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
225
+ return __promise
226
+ }()
227
+ return bridge.create_Result_std__shared_ptr_Promise_double___(__resultCpp)
228
+ } catch (let __error) {
229
+ let __exceptionPtr = __error.toCpp()
230
+ return bridge.create_Result_std__shared_ptr_Promise_double___(__exceptionPtr)
231
+ }
232
+ }
233
+ }
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// HybridReactNativeZipArchiveSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridReactNativeZipArchiveSpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativeziparchive {
11
+
12
+ void HybridReactNativeZipArchiveSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("isPasswordProtected", &HybridReactNativeZipArchiveSpec::isPasswordProtected);
18
+ prototype.registerHybridMethod("unzip", &HybridReactNativeZipArchiveSpec::unzip);
19
+ prototype.registerHybridMethod("unzipWithPassword", &HybridReactNativeZipArchiveSpec::unzipWithPassword);
20
+ prototype.registerHybridMethod("zipFolder", &HybridReactNativeZipArchiveSpec::zipFolder);
21
+ prototype.registerHybridMethod("zipFiles", &HybridReactNativeZipArchiveSpec::zipFiles);
22
+ prototype.registerHybridMethod("getUncompressedSize", &HybridReactNativeZipArchiveSpec::getUncompressedSize);
23
+ });
24
+ }
25
+
26
+ } // namespace margelo::nitro::reactnativeziparchive
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HybridReactNativeZipArchiveSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+ #include <NitroModules/Promise.hpp>
19
+ #include <string>
20
+ #include <vector>
21
+
22
+ namespace margelo::nitro::reactnativeziparchive {
23
+
24
+ using namespace margelo::nitro;
25
+
26
+ /**
27
+ * An abstract base class for `ReactNativeZipArchive`
28
+ * Inherit this class to create instances of `HybridReactNativeZipArchiveSpec` in C++.
29
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
30
+ * @example
31
+ * ```cpp
32
+ * class HybridReactNativeZipArchive: public HybridReactNativeZipArchiveSpec {
33
+ * public:
34
+ * HybridReactNativeZipArchive(...): HybridObject(TAG) { ... }
35
+ * // ...
36
+ * };
37
+ * ```
38
+ */
39
+ class HybridReactNativeZipArchiveSpec: public virtual HybridObject {
40
+ public:
41
+ // Constructor
42
+ explicit HybridReactNativeZipArchiveSpec(): HybridObject(TAG) { }
43
+
44
+ // Destructor
45
+ ~HybridReactNativeZipArchiveSpec() override = default;
46
+
47
+ public:
48
+ // Properties
49
+
50
+
51
+ public:
52
+ // Methods
53
+ virtual std::shared_ptr<Promise<bool>> isPasswordProtected(const std::string& file) = 0;
54
+ virtual std::shared_ptr<Promise<std::string>> unzip(const std::string& from, const std::string& to) = 0;
55
+ virtual std::shared_ptr<Promise<std::string>> unzipWithPassword(const std::string& from, const std::string& to, const std::string& password) = 0;
56
+ virtual std::shared_ptr<Promise<std::string>> zipFolder(const std::string& from, const std::string& to) = 0;
57
+ virtual std::shared_ptr<Promise<std::string>> zipFiles(const std::vector<std::string>& files, const std::string& to) = 0;
58
+ virtual std::shared_ptr<Promise<double>> getUncompressedSize(const std::string& path) = 0;
59
+
60
+ protected:
61
+ // Hybrid Setup
62
+ void loadHybridMethods() override;
63
+
64
+ protected:
65
+ // Tag for logging
66
+ static constexpr auto TAG = "ReactNativeZipArchive";
67
+ };
68
+
69
+ } // namespace margelo::nitro::reactnativeziparchive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-zip-archive",
3
- "version": "3.0.38",
3
+ "version": "3.0.39",
4
4
  "description": "react-native-zip-archive TurboModule for OneKey",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -15,18 +15,26 @@
15
15
  "files": [
16
16
  "src",
17
17
  "lib",
18
+ "android",
18
19
  "ios",
20
+ "nitrogen",
21
+ "nitro.json",
19
22
  "*.podspec",
20
23
  "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
21
29
  "!**/__tests__",
22
30
  "!**/__fixtures__",
23
31
  "!**/__mocks__",
24
32
  "!**/.*",
25
- "android",
26
33
  "!**/*.map"
27
34
  ],
28
35
  "scripts": {
29
36
  "prepare": "bob build",
37
+ "nitrogen": "nitrogen",
30
38
  "typecheck": "tsc",
31
39
  "release": "yarn prepare && npm whoami && npm publish --access public"
32
40
  },
@@ -50,19 +58,29 @@
50
58
  },
51
59
  "peerDependencies": {
52
60
  "react": "*",
53
- "react-native": "*"
61
+ "react-native": "*",
62
+ "react-native-nitro-modules": "0.33.2"
54
63
  },
55
64
  "devDependencies": {
56
65
  "@react-native/babel-preset": "0.83.0",
66
+ "nitrogen": "0.31.10",
57
67
  "react": "19.2.0",
58
- "react-native": "0.83.0",
68
+ "react-native": "patch:react-native@npm%3A0.83.0#~/.yarn/patches/react-native-npm-0.83.0-577d0f2d83.patch",
59
69
  "react-native-builder-bob": "^0.40.17",
70
+ "react-native-nitro-modules": "0.33.2",
60
71
  "typescript": "^5.9.2"
61
72
  },
62
73
  "react-native-builder-bob": {
63
74
  "source": "src",
64
75
  "output": "lib",
65
76
  "targets": [
77
+ [
78
+ "custom",
79
+ {
80
+ "script": "nitrogen",
81
+ "clean": "nitrogen/"
82
+ }
83
+ ],
66
84
  [
67
85
  "module",
68
86
  {
@@ -76,18 +94,5 @@
76
94
  }
77
95
  ]
78
96
  ]
79
- },
80
- "codegenConfig": {
81
- "name": "RNZipArchiveSpec",
82
- "type": "modules",
83
- "jsSrcsDir": "src",
84
- "android": {
85
- "javaPackageName": "com.rnziparchive"
86
- },
87
- "ios": {
88
- "modulesProvider": {
89
- "RNZipArchive": "ZipArchive"
90
- }
91
- }
92
97
  }
93
98
  }
@@ -0,0 +1,26 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface ReactNativeZipArchive
4
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
5
+ // Whether the archive at `file` is password protected.
6
+ isPasswordProtected(file: string): Promise<boolean>;
7
+
8
+ // Extract the archive at `from` into directory `to`. Resolves with `to`.
9
+ unzip(from: string, to: string): Promise<string>;
10
+
11
+ // Extract a password-protected archive at `from` into directory `to`.
12
+ unzipWithPassword(
13
+ from: string,
14
+ to: string,
15
+ password: string,
16
+ ): Promise<string>;
17
+
18
+ // Zip the contents of directory `from` into archive `to`. Resolves with `to`.
19
+ zipFolder(from: string, to: string): Promise<string>;
20
+
21
+ // Zip the given list of files into archive `to`. Resolves with `to`.
22
+ zipFiles(files: string[], to: string): Promise<string>;
23
+
24
+ // Total uncompressed size (bytes) of the archive at `path`. -1 on failure.
25
+ getUncompressedSize(path: string): Promise<number>;
26
+ }
package/src/index.tsx CHANGED
@@ -1,6 +1,49 @@
1
- import NativeZipArchive from './NativeZipArchive';
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
2
 
3
- export const ZipArchive = NativeZipArchive;
3
+ import type { ReactNativeZipArchive as ReactNativeZipArchiveType } from './ReactNativeZipArchive.nitro';
4
+
5
+ const ReactNativeZipArchiveHybridObject =
6
+ NitroModules.createHybridObject<ReactNativeZipArchiveType>(
7
+ 'ReactNativeZipArchive',
8
+ );
9
+
10
+ // Raw HybridObject. Kept exported for compatibility with the previous
11
+ // `export const ZipArchive = NativeZipArchive` shape.
12
+ export const ZipArchive = ReactNativeZipArchiveHybridObject;
13
+
14
+ // Backwards-compatible named function wrappers. These preserve the exact
15
+ // public API (names + signatures) of the previous TurboModule-based release so
16
+ // consumers (e.g. monorepo logger using `import { zip }`) require zero changes.
17
+
18
+ export const isPasswordProtected = (file: string): Promise<boolean> =>
19
+ ReactNativeZipArchiveHybridObject.isPasswordProtected(file);
20
+
21
+ export const unzip = (from: string, to: string): Promise<string> =>
22
+ ReactNativeZipArchiveHybridObject.unzip(from, to);
23
+
24
+ export const unzipWithPassword = (
25
+ from: string,
26
+ to: string,
27
+ password: string,
28
+ ): Promise<string> =>
29
+ ReactNativeZipArchiveHybridObject.unzipWithPassword(from, to, password);
30
+
31
+ export const zipFolder = (from: string, to: string): Promise<string> =>
32
+ ReactNativeZipArchiveHybridObject.zipFolder(from, to);
33
+
34
+ export const zipFiles = (files: string[], to: string): Promise<string> =>
35
+ ReactNativeZipArchiveHybridObject.zipFiles(files, to);
36
+
37
+ export const getUncompressedSize = (path: string): Promise<number> =>
38
+ ReactNativeZipArchiveHybridObject.getUncompressedSize(path);
39
+
40
+ // `zip` is an alias for `zipFolder` and matches the previous public signature
41
+ // `(source, target) => Promise<string>`. This is the only API the monorepo
42
+ // logger consumes.
4
43
  export const zip = (source: string, target: string): Promise<string> =>
5
- NativeZipArchive.zipFolder(source, target);
6
- export type { Spec as ZipArchiveSpec } from './NativeZipArchive';
44
+ ReactNativeZipArchiveHybridObject.zipFolder(source, target);
45
+
46
+ export type * from './ReactNativeZipArchive.nitro';
47
+
48
+ // Backwards-compatible alias for the previously exported `ZipArchiveSpec` type.
49
+ export type { ReactNativeZipArchive as ZipArchiveSpec } from './ReactNativeZipArchive.nitro';