react-native-nitro-unzip 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,19 @@
1
1
  # react-native-nitro-unzip
2
2
 
3
- High-performance ZIP extraction for React Native, powered by [Nitro Modules](https://nitro.margelo.com/).
3
+ [![npm](https://img.shields.io/npm/v/react-native-nitro-unzip)](https://www.npmjs.com/package/react-native-nitro-unzip)
4
+ [![license](https://img.shields.io/npm/l/react-native-nitro-unzip)](https://github.com/isaacrowntree/react-native-nitro-unzip/blob/main/LICENSE)
5
+ [![CI](https://github.com/isaacrowntree/react-native-nitro-unzip/actions/workflows/lint-typescript.yml/badge.svg)](https://github.com/isaacrowntree/react-native-nitro-unzip/actions/workflows/lint-typescript.yml)
6
+
7
+ High-performance ZIP operations for React Native, powered by [Nitro Modules](https://nitro.margelo.com/).
4
8
 
5
9
  - **iOS**: SSZipArchive (C-based libz) — ~500 files/sec
6
10
  - **Android**: Optimized ZipInputStream with 64KB buffers — ~474 files/sec
7
- - **Zero bridge overhead** for progress callbacks (JSI-based)
8
- - **Proper object instances** — each extraction is an `UnzipTask` you can observe and cancel
9
- - **Concurrent extractions** supported out of the box
10
- - **iOS background task** management for continued extraction when app is backgrounded
11
+ - **Zero bridge overhead** progress callbacks via JSI, no serialization
12
+ - **Object instances** — each task is an observable, cancellable `UnzipTask` or `ZipTask`
13
+ - **Concurrent operations** supported out of the box
14
+ - **Password support** AES-256 encrypted archives (zip4j on Android, SSZipArchive on iOS)
15
+ - **Zip creation** — compress files and directories with optional password protection
16
+ - **Background tasks** — iOS background task management for continued extraction
11
17
 
12
18
  ## Installation
13
19
 
@@ -16,26 +22,61 @@ npm install react-native-nitro-unzip react-native-nitro-modules
16
22
  cd ios && pod install
17
23
  ```
18
24
 
25
+ > Requires React Native 0.75+ and [Nitro Modules](https://nitro.margelo.com/) 0.34+
26
+
19
27
  ## Usage
20
28
 
29
+ ### Extract a ZIP archive
30
+
21
31
  ```typescript
22
- import { getUnzip } from 'react-native-nitro-unzip'
32
+ import { getUnzip } from 'react-native-nitro-unzip';
23
33
 
24
- const unzip = getUnzip()
25
- const task = unzip.extract('/path/to/archive.zip', '/path/to/output')
34
+ const unzip = getUnzip();
35
+ const task = unzip.extract('/path/to/archive.zip', '/path/to/output');
26
36
 
27
- // Track progress
28
37
  task.onProgress((p) => {
29
- console.log(`${(p.progress * 100).toFixed(0)}% — ${p.extractedFiles}/${p.totalFiles} files`)
30
- console.log(`Speed: ${p.speed.toFixed(0)} files/sec`)
31
- })
38
+ console.log(`${(p.progress * 100).toFixed(0)}% — ${p.extractedFiles}/${p.totalFiles} files`);
39
+ console.log(`Speed: ${p.speed.toFixed(0)} files/sec`);
40
+ });
32
41
 
33
- // Await result
34
- const result = await task.await()
35
- console.log(`Extracted ${result.extractedFiles} files in ${result.duration}ms`)
42
+ const result = await task.await();
43
+ console.log(`Extracted ${result.extractedFiles} files in ${result.duration}ms`);
44
+ ```
45
+
46
+ ### Extract with password
36
47
 
37
- // Or cancel
38
- task.cancel()
48
+ ```typescript
49
+ const task = unzip.extractWithPassword('/path/to/encrypted.zip', '/output', 'secret');
50
+ const result = await task.await();
51
+ ```
52
+
53
+ ### Create a ZIP archive
54
+
55
+ ```typescript
56
+ const task = unzip.zip('/path/to/folder', '/output/archive.zip');
57
+
58
+ task.onProgress((p) => {
59
+ console.log(`${(p.progress * 100).toFixed(0)}% — ${p.compressedFiles}/${p.totalFiles}`);
60
+ });
61
+
62
+ const result = await task.await();
63
+ console.log(`Compressed ${result.compressedFiles} files`);
64
+ ```
65
+
66
+ ### Create with password (AES-256)
67
+
68
+ ```typescript
69
+ const task = unzip.zipWithPassword('/path/to/folder', '/output/secure.zip', 'secret');
70
+ const result = await task.await();
71
+ ```
72
+
73
+ ### Cancel an operation
74
+
75
+ ```typescript
76
+ const task = unzip.extract('/path/to/large.zip', '/output');
77
+
78
+ // Cancel at any time — synchronous via JSI
79
+ task.cancel();
39
80
  ```
40
81
 
41
82
  ## API
@@ -44,21 +85,28 @@ task.cancel()
44
85
 
45
86
  Creates an `Unzip` factory instance.
46
87
 
47
- ### `Unzip.extract(zipPath, destinationPath): UnzipTask`
88
+ ### Extraction
48
89
 
49
- Starts extracting a ZIP archive. Returns an `UnzipTask` instance immediately.
90
+ | Method | Returns | Description |
91
+ |---|---|---|
92
+ | `extract(zipPath, destPath)` | `UnzipTask` | Extract a ZIP archive |
93
+ | `extractWithPassword(zipPath, destPath, password)` | `UnzipTask` | Extract a password-protected archive |
50
94
 
51
- - `zipPath` — absolute path to the ZIP file (`file://` URIs accepted)
52
- - `destinationPath` — absolute path to extract into (created if missing)
95
+ ### Compression
53
96
 
54
- ### `UnzipTask`
97
+ | Method | Returns | Description |
98
+ |---|---|---|
99
+ | `zip(sourcePath, destZipPath)` | `ZipTask` | Create a ZIP archive from a directory |
100
+ | `zipWithPassword(sourcePath, destZipPath, password)` | `ZipTask` | Create a password-protected ZIP (AES-256) |
101
+
102
+ ### `UnzipTask` / `ZipTask`
55
103
 
56
104
  | Property/Method | Type | Description |
57
105
  |---|---|---|
58
- | `taskId` | `string` | Unique identifier for this extraction |
59
- | `onProgress(callback)` | `(progress: UnzipProgress) => void` | Register a progress callback (throttled to ~1/sec) |
60
- | `cancel()` | `void` | Cancel this extraction |
61
- | `await()` | `Promise<UnzipResult>` | Await the extraction result |
106
+ | `taskId` | `string` | Unique identifier for this operation |
107
+ | `onProgress(callback)` | `void` | Register a progress callback (throttled ~1/sec) |
108
+ | `cancel()` | `void` | Cancel the operation (synchronous via JSI) |
109
+ | `await()` | `Promise<Result>` | Await the operation result |
62
110
 
63
111
  ### `UnzipProgress`
64
112
 
@@ -76,9 +124,30 @@ Starts extracting a ZIP archive. Returns an `UnzipTask` instance immediately.
76
124
  |---|---|---|
77
125
  | `success` | `boolean` | Whether extraction completed |
78
126
  | `extractedFiles` | `number` | Total files extracted |
127
+ | `totalFiles` | `number` | Total files in the archive |
128
+ | `duration` | `number` | Duration in milliseconds |
129
+ | `averageSpeed` | `number` | Average files per second |
130
+ | `totalBytes` | `number` | Size of the ZIP file in bytes |
131
+
132
+ ### `ZipProgress`
133
+
134
+ | Field | Type | Description |
135
+ |---|---|---|
136
+ | `compressedFiles` | `number` | Files compressed so far |
137
+ | `totalFiles` | `number` | Total files to compress |
138
+ | `progress` | `number` | 0.0 to 1.0 |
139
+ | `speed` | `number` | Files per second |
140
+
141
+ ### `ZipResult`
142
+
143
+ | Field | Type | Description |
144
+ |---|---|---|
145
+ | `success` | `boolean` | Whether compression completed |
146
+ | `compressedFiles` | `number` | Total files compressed |
147
+ | `totalFiles` | `number` | Total files to compress |
79
148
  | `duration` | `number` | Duration in milliseconds |
80
149
  | `averageSpeed` | `number` | Average files per second |
81
- | `totalBytes` | `number` | Total bytes extracted |
150
+ | `totalBytes` | `number` | Total bytes written |
82
151
 
83
152
  ## Performance
84
153
 
@@ -97,10 +166,20 @@ Benchmarked on a 350MB archive with 10,432 small files (map tiles):
97
166
 
98
167
  ## Requirements
99
168
 
100
- - React Native 0.75+
101
- - Nitro Modules 0.34+
102
- - iOS 13+
103
- - Android SDK 21+
169
+ | Requirement | Version |
170
+ |---|---|
171
+ | React Native | 0.75+ |
172
+ | Nitro Modules | 0.34+ |
173
+ | iOS | 13+ |
174
+ | Android SDK | 21+ |
175
+
176
+ ## Example
177
+
178
+ See the [example app](./example) for a working demo of extraction, zip creation, password support, and cancellation.
179
+
180
+ ## Contributing
181
+
182
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
104
183
 
105
184
  ## License
106
185
 
@@ -163,13 +163,15 @@ class HybridUnzipTask(
163
163
 
164
164
  val durationMs = (System.currentTimeMillis() - startTime).toDouble()
165
165
  val avgSpeed = if (durationMs > 0) extractedCount / (durationMs / 1000.0) else 0.0
166
+ val zipFileSize = sourceFile.length().toDouble()
166
167
 
167
168
  UnzipResult(
168
169
  success = true,
169
170
  extractedFiles = extractedCount.toDouble(),
171
+ totalFiles = totalEntries.toDouble(),
170
172
  duration = durationMs,
171
173
  averageSpeed = avgSpeed,
172
- totalBytes = 0.0
174
+ totalBytes = zipFileSize
173
175
  )
174
176
  }
175
177
 
@@ -239,13 +241,15 @@ class HybridUnzipTask(
239
241
 
240
242
  val durationMs = (System.currentTimeMillis() - startTime).toDouble()
241
243
  val avgSpeed = if (durationMs > 0) extractedCount / (durationMs / 1000.0) else 0.0
244
+ val zipFileSize = sourceFile.length().toDouble()
242
245
 
243
246
  UnzipResult(
244
247
  success = true,
245
248
  extractedFiles = extractedCount.toDouble(),
249
+ totalFiles = totalEntries.toDouble(),
246
250
  duration = durationMs,
247
251
  averageSpeed = avgSpeed,
248
- totalBytes = 0.0
252
+ totalBytes = zipFileSize
249
253
  )
250
254
  }
251
255
 
@@ -145,6 +145,7 @@ class HybridZipTask(
145
145
  ZipResult(
146
146
  success = true,
147
147
  compressedFiles = compressedCount.toDouble(),
148
+ totalFiles = totalFiles.toDouble(),
148
149
  duration = durationMs,
149
150
  averageSpeed = avgSpeed,
150
151
  totalBytes = totalBytes
@@ -130,10 +130,11 @@ class HybridUnzipTask: HybridUnzipTaskSpec {
130
130
  }
131
131
 
132
132
  var extractedFiles = 0
133
+ var totalFileCount = 0
133
134
  var lastProgressUpdate = Date()
134
135
 
135
136
  // SSZipArchive progress handler — called per file
136
- let progressHandler: (String, unz_file_info, Int, Int) -> Void = { [weak self] _, _, entryNumber, total in
137
+ let progressHandler: (String, unz_file_info, Int, Int) -> Void = { [weak self] _, fileInfo, entryNumber, total in
137
138
  guard let self = self else { return }
138
139
 
139
140
  // Check cancellation
@@ -144,6 +145,7 @@ class HybridUnzipTask: HybridUnzipTaskSpec {
144
145
  if cancelled { return }
145
146
 
146
147
  extractedFiles = entryNumber
148
+ totalFileCount = total
147
149
 
148
150
  // Throttle progress updates
149
151
  let now = Date()
@@ -161,7 +163,7 @@ class HybridUnzipTask: HybridUnzipTaskSpec {
161
163
  totalFiles: Double(total),
162
164
  progress: progress,
163
165
  speed: speed,
164
- processedBytes: 0
166
+ processedBytes: Double(fileInfo.uncompressed_size)
165
167
  ))
166
168
  lastProgressUpdate = now
167
169
  }
@@ -202,12 +204,22 @@ class HybridUnzipTask: HybridUnzipTaskSpec {
202
204
  let finalCount = extractedFiles
203
205
  let averageSpeed = duration > 0 ? Double(finalCount) / (duration / 1000) : 0
204
206
 
207
+ // Calculate total bytes from extracted files
208
+ let totalBytes: Double
209
+ if let attrs = try? fileManager.attributesOfItem(atPath: cleanZip),
210
+ let fileSize = attrs[.size] as? UInt64 {
211
+ totalBytes = Double(fileSize)
212
+ } else {
213
+ totalBytes = 0
214
+ }
215
+
205
216
  return UnzipResult(
206
217
  success: true,
207
218
  extractedFiles: Double(finalCount),
219
+ totalFiles: Double(totalFileCount),
208
220
  duration: duration,
209
221
  averageSpeed: averageSpeed,
210
- totalBytes: 0
222
+ totalBytes: totalBytes
211
223
  )
212
224
  }
213
225
 
@@ -198,6 +198,7 @@ class HybridZipTask: HybridZipTaskSpec {
198
198
  return ZipResult(
199
199
  success: true,
200
200
  compressedFiles: Double(finalCount),
201
+ totalFiles: Double(totalFiles),
201
202
  duration: duration,
202
203
  averageSpeed: averageSpeed,
203
204
  totalBytes: totalBytes
@@ -22,6 +22,8 @@ export interface UnzipResult {
22
22
  success: boolean;
23
23
  /** Total number of files extracted */
24
24
  extractedFiles: number;
25
+ /** Total number of files in the archive */
26
+ totalFiles: number;
25
27
  /** Total extraction duration in milliseconds */
26
28
  duration: number;
27
29
  /** Average extraction speed in files per second */
@@ -77,6 +79,8 @@ export interface ZipResult {
77
79
  success: boolean;
78
80
  /** Total number of files compressed */
79
81
  compressedFiles: number;
82
+ /** Total number of files to compress */
83
+ totalFiles: number;
80
84
  /** Total compression duration in milliseconds */
81
85
  duration: number;
82
86
  /** Average compression speed in files per second */
@@ -1 +1 @@
1
- {"version":3,"file":"Unzip.nitro.d.ts","sourceRoot":"","sources":["../../../src/specs/Unzip.nitro.ts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CAAC;IAEb;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7D;;;;;;;OAOG;IACH,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;CACZ"}
@@ -35,6 +35,8 @@ namespace margelo::nitro::unzip {
35
35
  jboolean success = this->getFieldValue(fieldSuccess);
36
36
  static const auto fieldExtractedFiles = clazz->getField<double>("extractedFiles");
37
37
  double extractedFiles = this->getFieldValue(fieldExtractedFiles);
38
+ static const auto fieldTotalFiles = clazz->getField<double>("totalFiles");
39
+ double totalFiles = this->getFieldValue(fieldTotalFiles);
38
40
  static const auto fieldDuration = clazz->getField<double>("duration");
39
41
  double duration = this->getFieldValue(fieldDuration);
40
42
  static const auto fieldAverageSpeed = clazz->getField<double>("averageSpeed");
@@ -44,6 +46,7 @@ namespace margelo::nitro::unzip {
44
46
  return UnzipResult(
45
47
  static_cast<bool>(success),
46
48
  extractedFiles,
49
+ totalFiles,
47
50
  duration,
48
51
  averageSpeed,
49
52
  totalBytes
@@ -56,13 +59,14 @@ namespace margelo::nitro::unzip {
56
59
  */
57
60
  [[maybe_unused]]
58
61
  static jni::local_ref<JUnzipResult::javaobject> fromCpp(const UnzipResult& value) {
59
- using JSignature = JUnzipResult(jboolean, double, double, double, double);
62
+ using JSignature = JUnzipResult(jboolean, double, double, double, double, double);
60
63
  static const auto clazz = javaClassStatic();
61
64
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
62
65
  return create(
63
66
  clazz,
64
67
  value.success,
65
68
  value.extractedFiles,
69
+ value.totalFiles,
66
70
  value.duration,
67
71
  value.averageSpeed,
68
72
  value.totalBytes
@@ -35,6 +35,8 @@ namespace margelo::nitro::unzip {
35
35
  jboolean success = this->getFieldValue(fieldSuccess);
36
36
  static const auto fieldCompressedFiles = clazz->getField<double>("compressedFiles");
37
37
  double compressedFiles = this->getFieldValue(fieldCompressedFiles);
38
+ static const auto fieldTotalFiles = clazz->getField<double>("totalFiles");
39
+ double totalFiles = this->getFieldValue(fieldTotalFiles);
38
40
  static const auto fieldDuration = clazz->getField<double>("duration");
39
41
  double duration = this->getFieldValue(fieldDuration);
40
42
  static const auto fieldAverageSpeed = clazz->getField<double>("averageSpeed");
@@ -44,6 +46,7 @@ namespace margelo::nitro::unzip {
44
46
  return ZipResult(
45
47
  static_cast<bool>(success),
46
48
  compressedFiles,
49
+ totalFiles,
47
50
  duration,
48
51
  averageSpeed,
49
52
  totalBytes
@@ -56,13 +59,14 @@ namespace margelo::nitro::unzip {
56
59
  */
57
60
  [[maybe_unused]]
58
61
  static jni::local_ref<JZipResult::javaobject> fromCpp(const ZipResult& value) {
59
- using JSignature = JZipResult(jboolean, double, double, double, double);
62
+ using JSignature = JZipResult(jboolean, double, double, double, double, double);
60
63
  static const auto clazz = javaClassStatic();
61
64
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
62
65
  return create(
63
66
  clazz,
64
67
  value.success,
65
68
  value.compressedFiles,
69
+ value.totalFiles,
66
70
  value.duration,
67
71
  value.averageSpeed,
68
72
  value.totalBytes
@@ -25,6 +25,9 @@ data class UnzipResult(
25
25
  val extractedFiles: Double,
26
26
  @DoNotStrip
27
27
  @Keep
28
+ val totalFiles: Double,
29
+ @DoNotStrip
30
+ @Keep
28
31
  val duration: Double,
29
32
  @DoNotStrip
30
33
  @Keep
@@ -43,8 +46,8 @@ data class UnzipResult(
43
46
  @Keep
44
47
  @Suppress("unused")
45
48
  @JvmStatic
46
- private fun fromCpp(success: Boolean, extractedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double): UnzipResult {
47
- return UnzipResult(success, extractedFiles, duration, averageSpeed, totalBytes)
49
+ private fun fromCpp(success: Boolean, extractedFiles: Double, totalFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double): UnzipResult {
50
+ return UnzipResult(success, extractedFiles, totalFiles, duration, averageSpeed, totalBytes)
48
51
  }
49
52
  }
50
53
  }
@@ -25,6 +25,9 @@ data class ZipResult(
25
25
  val compressedFiles: Double,
26
26
  @DoNotStrip
27
27
  @Keep
28
+ val totalFiles: Double,
29
+ @DoNotStrip
30
+ @Keep
28
31
  val duration: Double,
29
32
  @DoNotStrip
30
33
  @Keep
@@ -43,8 +46,8 @@ data class ZipResult(
43
46
  @Keep
44
47
  @Suppress("unused")
45
48
  @JvmStatic
46
- private fun fromCpp(success: Boolean, compressedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double): ZipResult {
47
- return ZipResult(success, compressedFiles, duration, averageSpeed, totalBytes)
49
+ private fun fromCpp(success: Boolean, compressedFiles: Double, totalFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double): ZipResult {
50
+ return ZipResult(success, compressedFiles, totalFiles, duration, averageSpeed, totalBytes)
48
51
  }
49
52
  }
50
53
  }
@@ -18,8 +18,8 @@ public extension UnzipResult {
18
18
  /**
19
19
  * Create a new instance of `UnzipResult`.
20
20
  */
21
- init(success: Bool, extractedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
22
- self.init(success, extractedFiles, duration, averageSpeed, totalBytes)
21
+ init(success: Bool, extractedFiles: Double, totalFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
22
+ self.init(success, extractedFiles, totalFiles, duration, averageSpeed, totalBytes)
23
23
  }
24
24
 
25
25
  @inline(__always)
@@ -32,6 +32,11 @@ public extension UnzipResult {
32
32
  return self.__extractedFiles
33
33
  }
34
34
 
35
+ @inline(__always)
36
+ var totalFiles: Double {
37
+ return self.__totalFiles
38
+ }
39
+
35
40
  @inline(__always)
36
41
  var duration: Double {
37
42
  return self.__duration
@@ -18,8 +18,8 @@ public extension ZipResult {
18
18
  /**
19
19
  * Create a new instance of `ZipResult`.
20
20
  */
21
- init(success: Bool, compressedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
22
- self.init(success, compressedFiles, duration, averageSpeed, totalBytes)
21
+ init(success: Bool, compressedFiles: Double, totalFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
22
+ self.init(success, compressedFiles, totalFiles, duration, averageSpeed, totalBytes)
23
23
  }
24
24
 
25
25
  @inline(__always)
@@ -32,6 +32,11 @@ public extension ZipResult {
32
32
  return self.__compressedFiles
33
33
  }
34
34
 
35
+ @inline(__always)
36
+ var totalFiles: Double {
37
+ return self.__totalFiles
38
+ }
39
+
35
40
  @inline(__always)
36
41
  var duration: Double {
37
42
  return self.__duration
@@ -41,13 +41,14 @@ namespace margelo::nitro::unzip {
41
41
  public:
42
42
  bool success SWIFT_PRIVATE;
43
43
  double extractedFiles SWIFT_PRIVATE;
44
+ double totalFiles SWIFT_PRIVATE;
44
45
  double duration SWIFT_PRIVATE;
45
46
  double averageSpeed SWIFT_PRIVATE;
46
47
  double totalBytes SWIFT_PRIVATE;
47
48
 
48
49
  public:
49
50
  UnzipResult() = default;
50
- explicit UnzipResult(bool success, double extractedFiles, double duration, double averageSpeed, double totalBytes): success(success), extractedFiles(extractedFiles), duration(duration), averageSpeed(averageSpeed), totalBytes(totalBytes) {}
51
+ explicit UnzipResult(bool success, double extractedFiles, double totalFiles, double duration, double averageSpeed, double totalBytes): success(success), extractedFiles(extractedFiles), totalFiles(totalFiles), duration(duration), averageSpeed(averageSpeed), totalBytes(totalBytes) {}
51
52
 
52
53
  public:
53
54
  friend bool operator==(const UnzipResult& lhs, const UnzipResult& rhs) = default;
@@ -65,6 +66,7 @@ namespace margelo::nitro {
65
66
  return margelo::nitro::unzip::UnzipResult(
66
67
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
67
68
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"))),
68
70
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
69
71
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"))),
70
72
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))
@@ -74,6 +76,7 @@ namespace margelo::nitro {
74
76
  jsi::Object obj(runtime);
75
77
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "success"), JSIConverter<bool>::toJSI(runtime, arg.success));
76
78
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles"), JSIConverter<double>::toJSI(runtime, arg.extractedFiles));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"), JSIConverter<double>::toJSI(runtime, arg.totalFiles));
77
80
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<double>::toJSI(runtime, arg.duration));
78
81
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"), JSIConverter<double>::toJSI(runtime, arg.averageSpeed));
79
82
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalBytes"), JSIConverter<double>::toJSI(runtime, arg.totalBytes));
@@ -89,6 +92,7 @@ namespace margelo::nitro {
89
92
  }
90
93
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success")))) return false;
91
94
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles")))) return false;
95
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles")))) return false;
92
96
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
93
97
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed")))) return false;
94
98
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))) return false;
@@ -41,13 +41,14 @@ namespace margelo::nitro::unzip {
41
41
  public:
42
42
  bool success SWIFT_PRIVATE;
43
43
  double compressedFiles SWIFT_PRIVATE;
44
+ double totalFiles SWIFT_PRIVATE;
44
45
  double duration SWIFT_PRIVATE;
45
46
  double averageSpeed SWIFT_PRIVATE;
46
47
  double totalBytes SWIFT_PRIVATE;
47
48
 
48
49
  public:
49
50
  ZipResult() = default;
50
- explicit ZipResult(bool success, double compressedFiles, double duration, double averageSpeed, double totalBytes): success(success), compressedFiles(compressedFiles), duration(duration), averageSpeed(averageSpeed), totalBytes(totalBytes) {}
51
+ explicit ZipResult(bool success, double compressedFiles, double totalFiles, double duration, double averageSpeed, double totalBytes): success(success), compressedFiles(compressedFiles), totalFiles(totalFiles), duration(duration), averageSpeed(averageSpeed), totalBytes(totalBytes) {}
51
52
 
52
53
  public:
53
54
  friend bool operator==(const ZipResult& lhs, const ZipResult& rhs) = default;
@@ -65,6 +66,7 @@ namespace margelo::nitro {
65
66
  return margelo::nitro::unzip::ZipResult(
66
67
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
67
68
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"))),
68
70
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
69
71
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"))),
70
72
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))
@@ -74,6 +76,7 @@ namespace margelo::nitro {
74
76
  jsi::Object obj(runtime);
75
77
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "success"), JSIConverter<bool>::toJSI(runtime, arg.success));
76
78
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"), JSIConverter<double>::toJSI(runtime, arg.compressedFiles));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"), JSIConverter<double>::toJSI(runtime, arg.totalFiles));
77
80
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<double>::toJSI(runtime, arg.duration));
78
81
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"), JSIConverter<double>::toJSI(runtime, arg.averageSpeed));
79
82
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalBytes"), JSIConverter<double>::toJSI(runtime, arg.totalBytes));
@@ -89,6 +92,7 @@ namespace margelo::nitro {
89
92
  }
90
93
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success")))) return false;
91
94
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles")))) return false;
95
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles")))) return false;
92
96
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
93
97
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed")))) return false;
94
98
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-unzip",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
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",
@@ -26,6 +26,8 @@ export interface UnzipResult {
26
26
  success: boolean;
27
27
  /** Total number of files extracted */
28
28
  extractedFiles: number;
29
+ /** Total number of files in the archive */
30
+ totalFiles: number;
29
31
  /** Total extraction duration in milliseconds */
30
32
  duration: number;
31
33
  /** Average extraction speed in files per second */
@@ -87,6 +89,8 @@ export interface ZipResult {
87
89
  success: boolean;
88
90
  /** Total number of files compressed */
89
91
  compressedFiles: number;
92
+ /** Total number of files to compress */
93
+ totalFiles: number;
90
94
  /** Total compression duration in milliseconds */
91
95
  duration: number;
92
96
  /** Average compression speed in files per second */