react-native-nitro-unzip 0.1.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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/android/CMakeLists.txt +16 -0
  4. package/android/build.gradle +70 -0
  5. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  6. package/android/src/main/java/com/margelo/nitro/unzip/HybridUnzip.kt +29 -0
  7. package/android/src/main/java/com/margelo/nitro/unzip/HybridUnzipTask.kt +256 -0
  8. package/android/src/main/java/com/margelo/nitro/unzip/HybridZipTask.kt +157 -0
  9. package/ios/HybridUnzip.swift +33 -0
  10. package/ios/HybridUnzipTask.swift +238 -0
  11. package/ios/HybridZipTask.swift +266 -0
  12. package/lib/commonjs/index.js +31 -0
  13. package/lib/commonjs/index.js.map +1 -0
  14. package/lib/commonjs/specs/Unzip.nitro.js +6 -0
  15. package/lib/commonjs/specs/Unzip.nitro.js.map +1 -0
  16. package/lib/module/index.js +27 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/module/specs/Unzip.nitro.js +4 -0
  20. package/lib/module/specs/Unzip.nitro.js.map +1 -0
  21. package/lib/typescript/index.d.ts +24 -0
  22. package/lib/typescript/index.d.ts.map +1 -0
  23. package/lib/typescript/specs/Unzip.nitro.d.ts +170 -0
  24. package/lib/typescript/specs/Unzip.nitro.d.ts.map +1 -0
  25. package/nitro.json +26 -0
  26. package/nitrogen/generated/.gitattributes +1 -0
  27. package/nitrogen/generated/android/NitroUnzip+autolinking.cmake +85 -0
  28. package/nitrogen/generated/android/NitroUnzip+autolinking.gradle +27 -0
  29. package/nitrogen/generated/android/NitroUnzipOnLoad.cpp +71 -0
  30. package/nitrogen/generated/android/NitroUnzipOnLoad.hpp +34 -0
  31. package/nitrogen/generated/android/c++/JFunc_void_UnzipProgress.hpp +77 -0
  32. package/nitrogen/generated/android/c++/JFunc_void_ZipProgress.hpp +77 -0
  33. package/nitrogen/generated/android/c++/JHybridUnzipSpec.cpp +82 -0
  34. package/nitrogen/generated/android/c++/JHybridUnzipSpec.hpp +69 -0
  35. package/nitrogen/generated/android/c++/JHybridUnzipTaskSpec.cpp +94 -0
  36. package/nitrogen/generated/android/c++/JHybridUnzipTaskSpec.hpp +68 -0
  37. package/nitrogen/generated/android/c++/JHybridZipTaskSpec.cpp +94 -0
  38. package/nitrogen/generated/android/c++/JHybridZipTaskSpec.hpp +68 -0
  39. package/nitrogen/generated/android/c++/JUnzipProgress.hpp +73 -0
  40. package/nitrogen/generated/android/c++/JUnzipResult.hpp +73 -0
  41. package/nitrogen/generated/android/c++/JZipProgress.hpp +69 -0
  42. package/nitrogen/generated/android/c++/JZipResult.hpp +73 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/Func_void_UnzipProgress.kt +80 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/Func_void_ZipProgress.kt +80 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridUnzipSpec.kt +69 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridUnzipTaskSpec.kt +73 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridZipTaskSpec.kt +73 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/NitroUnzipOnLoad.kt +35 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/UnzipProgress.kt +50 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/UnzipResult.kt +50 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/ZipProgress.kt +47 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/ZipResult.kt +50 -0
  53. package/nitrogen/generated/ios/NitroUnzip+autolinking.rb +60 -0
  54. package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Bridge.cpp +107 -0
  55. package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Bridge.hpp +270 -0
  56. package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Umbrella.hpp +68 -0
  57. package/nitrogen/generated/ios/NitroUnzipAutolinking.mm +49 -0
  58. package/nitrogen/generated/ios/NitroUnzipAutolinking.swift +50 -0
  59. package/nitrogen/generated/ios/c++/HybridUnzipSpecSwift.cpp +11 -0
  60. package/nitrogen/generated/ios/c++/HybridUnzipSpecSwift.hpp +112 -0
  61. package/nitrogen/generated/ios/c++/HybridUnzipTaskSpecSwift.cpp +11 -0
  62. package/nitrogen/generated/ios/c++/HybridUnzipTaskSpecSwift.hpp +104 -0
  63. package/nitrogen/generated/ios/c++/HybridZipTaskSpecSwift.cpp +11 -0
  64. package/nitrogen/generated/ios/c++/HybridZipTaskSpecSwift.hpp +104 -0
  65. package/nitrogen/generated/ios/swift/Func_void_UnzipProgress.swift +46 -0
  66. package/nitrogen/generated/ios/swift/Func_void_UnzipResult.swift +46 -0
  67. package/nitrogen/generated/ios/swift/Func_void_ZipProgress.swift +46 -0
  68. package/nitrogen/generated/ios/swift/Func_void_ZipResult.swift +46 -0
  69. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  70. package/nitrogen/generated/ios/swift/HybridUnzipSpec.swift +58 -0
  71. package/nitrogen/generated/ios/swift/HybridUnzipSpec_cxx.swift +186 -0
  72. package/nitrogen/generated/ios/swift/HybridUnzipTaskSpec.swift +57 -0
  73. package/nitrogen/generated/ios/swift/HybridUnzipTaskSpec_cxx.swift +177 -0
  74. package/nitrogen/generated/ios/swift/HybridZipTaskSpec.swift +57 -0
  75. package/nitrogen/generated/ios/swift/HybridZipTaskSpec_cxx.swift +177 -0
  76. package/nitrogen/generated/ios/swift/UnzipProgress.swift +49 -0
  77. package/nitrogen/generated/ios/swift/UnzipResult.swift +49 -0
  78. package/nitrogen/generated/ios/swift/ZipProgress.swift +44 -0
  79. package/nitrogen/generated/ios/swift/ZipResult.swift +49 -0
  80. package/nitrogen/generated/shared/c++/HybridUnzipSpec.cpp +24 -0
  81. package/nitrogen/generated/shared/c++/HybridUnzipSpec.hpp +71 -0
  82. package/nitrogen/generated/shared/c++/HybridUnzipTaskSpec.cpp +24 -0
  83. package/nitrogen/generated/shared/c++/HybridUnzipTaskSpec.hpp +71 -0
  84. package/nitrogen/generated/shared/c++/HybridZipTaskSpec.cpp +24 -0
  85. package/nitrogen/generated/shared/c++/HybridZipTaskSpec.hpp +71 -0
  86. package/nitrogen/generated/shared/c++/UnzipProgress.hpp +99 -0
  87. package/nitrogen/generated/shared/c++/UnzipResult.hpp +99 -0
  88. package/nitrogen/generated/shared/c++/ZipProgress.hpp +95 -0
  89. package/nitrogen/generated/shared/c++/ZipResult.hpp +99 -0
  90. package/package.json +165 -0
  91. package/react-native-nitro-unzip.podspec +24 -0
  92. package/src/index.ts +36 -0
  93. package/src/specs/Unzip.nitro.ts +193 -0
@@ -0,0 +1,95 @@
1
+ ///
2
+ /// ZipProgress.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::unzip {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (ZipProgress).
39
+ */
40
+ struct ZipProgress final {
41
+ public:
42
+ double compressedFiles SWIFT_PRIVATE;
43
+ double totalFiles SWIFT_PRIVATE;
44
+ double progress SWIFT_PRIVATE;
45
+ double speed SWIFT_PRIVATE;
46
+
47
+ public:
48
+ ZipProgress() = default;
49
+ explicit ZipProgress(double compressedFiles, double totalFiles, double progress, double speed): compressedFiles(compressedFiles), totalFiles(totalFiles), progress(progress), speed(speed) {}
50
+
51
+ public:
52
+ friend bool operator==(const ZipProgress& lhs, const ZipProgress& rhs) = default;
53
+ };
54
+
55
+ } // namespace margelo::nitro::unzip
56
+
57
+ namespace margelo::nitro {
58
+
59
+ // C++ ZipProgress <> JS ZipProgress (object)
60
+ template <>
61
+ struct JSIConverter<margelo::nitro::unzip::ZipProgress> final {
62
+ static inline margelo::nitro::unzip::ZipProgress fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
+ jsi::Object obj = arg.asObject(runtime);
64
+ return margelo::nitro::unzip::ZipProgress(
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"))),
67
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))
69
+ );
70
+ }
71
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unzip::ZipProgress& arg) {
72
+ jsi::Object obj(runtime);
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"), JSIConverter<double>::toJSI(runtime, arg.compressedFiles));
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"), JSIConverter<double>::toJSI(runtime, arg.totalFiles));
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<double>::toJSI(runtime, arg.progress));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<double>::toJSI(runtime, arg.speed));
77
+ return obj;
78
+ }
79
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
80
+ if (!value.isObject()) {
81
+ return false;
82
+ }
83
+ jsi::Object obj = value.getObject(runtime);
84
+ if (!nitro::isPlainObject(runtime, obj)) {
85
+ return false;
86
+ }
87
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles")))) return false;
88
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles")))) return false;
89
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
90
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
91
+ return true;
92
+ }
93
+ };
94
+
95
+ } // namespace margelo::nitro
@@ -0,0 +1,99 @@
1
+ ///
2
+ /// ZipResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::unzip {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (ZipResult).
39
+ */
40
+ struct ZipResult final {
41
+ public:
42
+ bool success SWIFT_PRIVATE;
43
+ double compressedFiles SWIFT_PRIVATE;
44
+ double duration SWIFT_PRIVATE;
45
+ double averageSpeed SWIFT_PRIVATE;
46
+ double totalBytes SWIFT_PRIVATE;
47
+
48
+ public:
49
+ 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
+
52
+ public:
53
+ friend bool operator==(const ZipResult& lhs, const ZipResult& rhs) = default;
54
+ };
55
+
56
+ } // namespace margelo::nitro::unzip
57
+
58
+ namespace margelo::nitro {
59
+
60
+ // C++ ZipResult <> JS ZipResult (object)
61
+ template <>
62
+ struct JSIConverter<margelo::nitro::unzip::ZipResult> final {
63
+ static inline margelo::nitro::unzip::ZipResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
64
+ jsi::Object obj = arg.asObject(runtime);
65
+ return margelo::nitro::unzip::ZipResult(
66
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
67
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"))),
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"))),
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))
71
+ );
72
+ }
73
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unzip::ZipResult& arg) {
74
+ jsi::Object obj(runtime);
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "success"), JSIConverter<bool>::toJSI(runtime, arg.success));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles"), JSIConverter<double>::toJSI(runtime, arg.compressedFiles));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<double>::toJSI(runtime, arg.duration));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed"), JSIConverter<double>::toJSI(runtime, arg.averageSpeed));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalBytes"), JSIConverter<double>::toJSI(runtime, arg.totalBytes));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success")))) return false;
91
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "compressedFiles")))) return false;
92
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
93
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeed")))) return false;
94
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalBytes")))) return false;
95
+ return true;
96
+ }
97
+ };
98
+
99
+ } // namespace margelo::nitro
package/package.json ADDED
@@ -0,0 +1,165 @@
1
+ {
2
+ "name": "react-native-nitro-unzip",
3
+ "version": "0.1.0",
4
+ "description": "High-performance ZIP extraction for React Native, powered by Nitro Modules",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "react-native": "src/index",
8
+ "types": "lib/typescript/index.d.ts",
9
+ "source": "src/index.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./lib/module/index.js",
13
+ "require": "./lib/commonjs/index.js",
14
+ "react-native": "./src/index.ts",
15
+ "types": "./lib/typescript/index.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "src",
20
+ "lib",
21
+ "ios",
22
+ "android",
23
+ "nitrogen",
24
+ "react-native-nitro-unzip.podspec",
25
+ "nitro.json",
26
+ "!**/__tests__",
27
+ "!**/__fixtures__",
28
+ "!**/__mocks__",
29
+ "!ios/build",
30
+ "!android/build"
31
+ ],
32
+ "scripts": {
33
+ "nitrogen": "nitrogen",
34
+ "typescript": "tsc --noEmit",
35
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
36
+ "lint-ci": "eslint \"src/**/*.{ts,tsx}\" --max-warnings 0",
37
+ "test": "jest",
38
+ "release": "release-it",
39
+ "clean": "rm -rf lib node_modules",
40
+ "prepare": "bob build",
41
+ "prepack": "bob build",
42
+ "prepublishOnly": "bob build"
43
+ },
44
+ "keywords": [
45
+ "react-native",
46
+ "nitro",
47
+ "nitro-modules",
48
+ "unzip",
49
+ "zip",
50
+ "archive",
51
+ "extraction",
52
+ "decompress",
53
+ "ios",
54
+ "android"
55
+ ],
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/isaacrowntree/react-native-nitro-unzip.git"
59
+ },
60
+ "author": "Isaac Rowntree",
61
+ "license": "MIT",
62
+ "bugs": {
63
+ "url": "https://github.com/isaacrowntree/react-native-nitro-unzip/issues"
64
+ },
65
+ "homepage": "https://github.com/isaacrowntree/react-native-nitro-unzip#readme",
66
+ "publishConfig": {
67
+ "registry": "https://registry.npmjs.org/"
68
+ },
69
+ "peerDependencies": {
70
+ "react": "*",
71
+ "react-native": "*",
72
+ "react-native-nitro-modules": ">=0.34.0"
73
+ },
74
+ "devDependencies": {
75
+ "@babel/preset-env": "^7.29.0",
76
+ "@babel/preset-typescript": "^7.28.5",
77
+ "@react-native/eslint-config": "^0.75.0",
78
+ "@release-it/conventional-changelog": "^10.0.0",
79
+ "@types/jest": "^29.5.0",
80
+ "babel-jest": "^30.2.0",
81
+ "eslint": "^8.57.0",
82
+ "eslint-config-prettier": "^10.0.0",
83
+ "eslint-plugin-prettier": "^5.0.0",
84
+ "jest": "^29.7.0",
85
+ "nitrogen": "^0.34.0",
86
+ "prettier": "^3.0.0",
87
+ "react-native-builder-bob": "^0.35.0",
88
+ "react-native-nitro-modules": "^0.34.0",
89
+ "release-it": "^18.0.0",
90
+ "typescript": "^5.0.0"
91
+ },
92
+ "eslintConfig": {
93
+ "root": true,
94
+ "extends": [
95
+ "@react-native",
96
+ "prettier"
97
+ ],
98
+ "rules": {
99
+ "prettier/prettier": "warn"
100
+ }
101
+ },
102
+ "prettier": {
103
+ "semi": true,
104
+ "singleQuote": true,
105
+ "trailingComma": "all",
106
+ "bracketSpacing": true,
107
+ "tabWidth": 2,
108
+ "useTabs": false
109
+ },
110
+ "jest": {
111
+ "transform": {
112
+ "^.+\\.tsx?$": [
113
+ "babel-jest",
114
+ {
115
+ "presets": [
116
+ [
117
+ "@babel/preset-env",
118
+ {
119
+ "targets": {
120
+ "node": "current"
121
+ }
122
+ }
123
+ ],
124
+ "@babel/preset-typescript"
125
+ ]
126
+ }
127
+ ]
128
+ },
129
+ "modulePathIgnorePatterns": [
130
+ "<rootDir>/example/",
131
+ "<rootDir>/lib/"
132
+ ]
133
+ },
134
+ "release-it": {
135
+ "git": {
136
+ "commitMessage": "chore: release ${version}",
137
+ "tagName": "v${version}"
138
+ },
139
+ "npm": {
140
+ "publish": true
141
+ },
142
+ "github": {
143
+ "release": true
144
+ },
145
+ "plugins": {
146
+ "@release-it/conventional-changelog": {
147
+ "preset": "angular"
148
+ }
149
+ }
150
+ },
151
+ "react-native-builder-bob": {
152
+ "source": "src",
153
+ "output": "lib",
154
+ "targets": [
155
+ [
156
+ "commonjs",
157
+ {
158
+ "esm": true
159
+ }
160
+ ],
161
+ "module",
162
+ "typescript"
163
+ ]
164
+ }
165
+ }
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'react-native-nitro-unzip'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.homepage = package['homepage']
10
+ s.license = package['license']
11
+ s.authors = package['author']
12
+ s.source = { git: package['repository']['url'], tag: s.version.to_s }
13
+ s.platforms = { ios: '13.0' }
14
+ s.swift_version = '5.9'
15
+
16
+ s.source_files = 'ios/**/*.{h,m,mm,swift,hpp,cpp}'
17
+
18
+ # SSZipArchive — C-based libz decompression for maximum performance
19
+ s.dependency 'SSZipArchive', '~> 2.5'
20
+
21
+ # Add Nitrogen generated files + NitroModules dependency
22
+ load 'nitrogen/generated/ios/NitroUnzip+autolinking.rb'
23
+ add_nitrogen_files(s)
24
+ end
package/src/index.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { NitroModules } from "react-native-nitro-modules";
2
+ import type { Unzip } from "./specs/Unzip.nitro";
3
+
4
+ export type {
5
+ UnzipProgress,
6
+ UnzipResult,
7
+ UnzipTask,
8
+ ZipProgress,
9
+ ZipResult,
10
+ ZipTask,
11
+ Unzip,
12
+ } from "./specs/Unzip.nitro";
13
+
14
+ /**
15
+ * Create an `Unzip` instance. Each instance is a factory for
16
+ * extraction and compression tasks.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { getUnzip } from 'react-native-nitro-unzip'
21
+ *
22
+ * const unzip = getUnzip()
23
+ *
24
+ * // Extract
25
+ * const task = unzip.extract('/path/to/archive.zip', '/output')
26
+ * task.onProgress((p) => console.log(`${(p.progress * 100).toFixed(0)}%`))
27
+ * const result = await task.await()
28
+ *
29
+ * // Zip
30
+ * const zipTask = unzip.zip('/path/to/folder', '/output.zip')
31
+ * const zipResult = await zipTask.await()
32
+ * ```
33
+ */
34
+ export function getUnzip(): Unzip {
35
+ return NitroModules.createHybridObject<Unzip>("Unzip");
36
+ }
@@ -0,0 +1,193 @@
1
+ import type { HybridObject } from "react-native-nitro-modules";
2
+
3
+ // ─── Extraction types ────────────────────────────────────────────────
4
+
5
+ /**
6
+ * Progress information for an active extraction.
7
+ */
8
+ export interface UnzipProgress {
9
+ /** Number of files extracted so far */
10
+ extractedFiles: number;
11
+ /** Total number of files in the archive */
12
+ totalFiles: number;
13
+ /** Extraction progress from 0.0 to 1.0 */
14
+ progress: number;
15
+ /** Current extraction speed in files per second */
16
+ speed: number;
17
+ /** Number of bytes processed so far */
18
+ processedBytes: number;
19
+ }
20
+
21
+ /**
22
+ * Result returned when an extraction completes successfully.
23
+ */
24
+ export interface UnzipResult {
25
+ /** Whether extraction completed successfully */
26
+ success: boolean;
27
+ /** Total number of files extracted */
28
+ extractedFiles: number;
29
+ /** Total extraction duration in milliseconds */
30
+ duration: number;
31
+ /** Average extraction speed in files per second */
32
+ averageSpeed: number;
33
+ /** Total bytes extracted */
34
+ totalBytes: number;
35
+ }
36
+
37
+ /**
38
+ * A single extraction operation. Each call to `Unzip.extract()` returns
39
+ * an `UnzipTask` instance that can be observed and cancelled independently.
40
+ *
41
+ * This is a proper HybridObject — a native instance you interact with
42
+ * directly, not an opaque task ID.
43
+ */
44
+ export interface UnzipTask
45
+ extends HybridObject<{ ios: "swift"; android: "kotlin" }> {
46
+ /** Unique identifier for this extraction task */
47
+ readonly taskId: string;
48
+
49
+ /**
50
+ * Register a callback to receive progress updates.
51
+ * Progress is throttled to ~1 update per second to avoid bridge overhead.
52
+ * The first file and final file always trigger a callback.
53
+ */
54
+ onProgress(callback: (progress: UnzipProgress) => void): void;
55
+
56
+ /** Cancel this extraction. Safe to call multiple times. */
57
+ cancel(): void;
58
+
59
+ /**
60
+ * Await the extraction result. Resolves when extraction completes,
61
+ * rejects if cancelled or an error occurs.
62
+ */
63
+ await(): Promise<UnzipResult>;
64
+ }
65
+
66
+ // ─── Compression types ───────────────────────────────────────────────
67
+
68
+ /**
69
+ * Progress information for an active zip creation.
70
+ */
71
+ export interface ZipProgress {
72
+ /** Number of files compressed so far */
73
+ compressedFiles: number;
74
+ /** Total number of files to compress */
75
+ totalFiles: number;
76
+ /** Compression progress from 0.0 to 1.0 */
77
+ progress: number;
78
+ /** Current compression speed in files per second */
79
+ speed: number;
80
+ }
81
+
82
+ /**
83
+ * Result returned when zip creation completes successfully.
84
+ */
85
+ export interface ZipResult {
86
+ /** Whether compression completed successfully */
87
+ success: boolean;
88
+ /** Total number of files compressed */
89
+ compressedFiles: number;
90
+ /** Total compression duration in milliseconds */
91
+ duration: number;
92
+ /** Average compression speed in files per second */
93
+ averageSpeed: number;
94
+ /** Total bytes written to the zip file */
95
+ totalBytes: number;
96
+ }
97
+
98
+ /**
99
+ * A single zip creation operation. Each call to `Unzip.zip()` returns
100
+ * a `ZipTask` instance that can be observed and cancelled independently.
101
+ */
102
+ export interface ZipTask
103
+ extends HybridObject<{ ios: "swift"; android: "kotlin" }> {
104
+ /** Unique identifier for this zip task */
105
+ readonly taskId: string;
106
+
107
+ /**
108
+ * Register a callback to receive progress updates.
109
+ * Progress is throttled to ~1 update per second.
110
+ */
111
+ onProgress(callback: (progress: ZipProgress) => void): void;
112
+
113
+ /** Cancel this zip creation. Safe to call multiple times. */
114
+ cancel(): void;
115
+
116
+ /**
117
+ * Await the zip result. Resolves when zip creation completes,
118
+ * rejects if cancelled or an error occurs.
119
+ */
120
+ await(): Promise<ZipResult>;
121
+ }
122
+
123
+ // ─── Factory ─────────────────────────────────────────────────────────
124
+
125
+ /**
126
+ * Factory for creating extraction and compression tasks.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * import { getUnzip } from 'react-native-nitro-unzip'
131
+ *
132
+ * const unzip = getUnzip()
133
+ *
134
+ * // Extract
135
+ * const task = unzip.extract('/path/to/archive.zip', '/path/to/output')
136
+ * task.onProgress((p) => console.log(`${(p.progress * 100).toFixed(0)}%`))
137
+ * const result = await task.await()
138
+ *
139
+ * // Extract with password
140
+ * const pwTask = unzip.extractWithPassword('/path/to/encrypted.zip', '/output', 'secret')
141
+ * const pwResult = await pwTask.await()
142
+ *
143
+ * // Create zip
144
+ * const zipTask = unzip.zip('/path/to/folder', '/path/to/output.zip')
145
+ * const zipResult = await zipTask.await()
146
+ * ```
147
+ */
148
+ export interface Unzip
149
+ extends HybridObject<{ ios: "swift"; android: "kotlin" }> {
150
+ /**
151
+ * Start extracting a ZIP archive to the given destination directory.
152
+ * Returns an `UnzipTask` instance for progress tracking and cancellation.
153
+ *
154
+ * @param zipPath - Absolute path to the ZIP file (file:// URIs accepted)
155
+ * @param destinationPath - Absolute path to extract into (created if missing)
156
+ */
157
+ extract(zipPath: string, destinationPath: string): UnzipTask;
158
+
159
+ /**
160
+ * Extract a password-protected ZIP archive.
161
+ *
162
+ * @param zipPath - Absolute path to the ZIP file
163
+ * @param destinationPath - Absolute path to extract into
164
+ * @param password - Password for the encrypted archive
165
+ */
166
+ extractWithPassword(
167
+ zipPath: string,
168
+ destinationPath: string,
169
+ password: string,
170
+ ): UnzipTask;
171
+
172
+ /**
173
+ * Create a ZIP archive from a directory.
174
+ *
175
+ * @param sourcePath - Absolute path to the directory to compress
176
+ * @param destinationZipPath - Absolute path for the output ZIP file
177
+ */
178
+ zip(sourcePath: string, destinationZipPath: string): ZipTask;
179
+
180
+ /**
181
+ * Create a password-protected ZIP archive from a directory.
182
+ * Uses AES-256 encryption on Android, standard zip encryption on iOS.
183
+ *
184
+ * @param sourcePath - Absolute path to the directory to compress
185
+ * @param destinationZipPath - Absolute path for the output ZIP file
186
+ * @param password - Password to protect the archive
187
+ */
188
+ zipWithPassword(
189
+ sourcePath: string,
190
+ destinationZipPath: string,
191
+ password: string,
192
+ ): ZipTask;
193
+ }