@onekeyfe/react-native-zip-archive 1.1.57
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/ZipArchive.podspec +21 -0
- package/android/build.gradle +77 -0
- package/android/src/main/java/com/rnziparchive/RNZipArchiveModule.kt +158 -0
- package/android/src/main/java/com/rnziparchive/RNZipArchivePackage.kt +33 -0
- package/ios/ZipArchive.h +10 -0
- package/ios/ZipArchive.mm +182 -0
- package/lib/module/NativeZipArchive.js +5 -0
- package/lib/module/NativeZipArchive.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeZipArchive.d.ts +12 -0
- package/lib/typescript/src/NativeZipArchive.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +87 -0
- package/src/NativeZipArchive.ts +13 -0
- package/src/index.tsx +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
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 = "ZipArchive"
|
|
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
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/OneKeyHQ/app-modules/react-native-zip-archive.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
+
|
|
18
|
+
s.dependency 'SSZipArchive'
|
|
19
|
+
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNZipArchive_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNZipArchive_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
android {
|
|
29
|
+
namespace "com.rnziparchive"
|
|
30
|
+
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
+
|
|
33
|
+
defaultConfig {
|
|
34
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buildTypes {
|
|
43
|
+
release {
|
|
44
|
+
minifyEnabled false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
lintOptions {
|
|
49
|
+
disable "GradleCompatible"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
compileOptions {
|
|
53
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
java.srcDirs += [
|
|
60
|
+
"generated/java",
|
|
61
|
+
"generated/jni"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
repositories {
|
|
68
|
+
mavenCentral()
|
|
69
|
+
google()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
73
|
+
|
|
74
|
+
dependencies {
|
|
75
|
+
implementation "com.facebook.react:react-android"
|
|
76
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
package com.rnziparchive
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableArray
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import java.io.BufferedInputStream
|
|
8
|
+
import java.io.BufferedOutputStream
|
|
9
|
+
import java.io.File
|
|
10
|
+
import java.io.FileInputStream
|
|
11
|
+
import java.io.FileOutputStream
|
|
12
|
+
import java.util.zip.ZipEntry
|
|
13
|
+
import java.util.zip.ZipFile
|
|
14
|
+
import java.util.zip.ZipInputStream
|
|
15
|
+
import java.util.zip.ZipOutputStream
|
|
16
|
+
|
|
17
|
+
@ReactModule(name = RNZipArchiveModule.NAME)
|
|
18
|
+
class RNZipArchiveModule(reactContext: ReactApplicationContext) :
|
|
19
|
+
NativeRNZipArchiveSpec(reactContext) {
|
|
20
|
+
|
|
21
|
+
companion object {
|
|
22
|
+
const val NAME = "RNZipArchive"
|
|
23
|
+
private const val BUFFER_SIZE = 8192
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getName(): String = NAME
|
|
27
|
+
|
|
28
|
+
override fun isPasswordProtected(file: String, promise: Promise) {
|
|
29
|
+
Thread {
|
|
30
|
+
try {
|
|
31
|
+
// java.util.zip does not support password-protected zips natively
|
|
32
|
+
// Return false as a safe default
|
|
33
|
+
promise.resolve(false)
|
|
34
|
+
} catch (e: Exception) {
|
|
35
|
+
promise.reject("ZIP_ERROR", e.message, e)
|
|
36
|
+
}
|
|
37
|
+
}.start()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun unzip(from: String, to: String, promise: Promise) {
|
|
41
|
+
Thread {
|
|
42
|
+
try {
|
|
43
|
+
val destDir = File(to)
|
|
44
|
+
if (!destDir.exists()) destDir.mkdirs()
|
|
45
|
+
|
|
46
|
+
ZipInputStream(BufferedInputStream(FileInputStream(from))).use { zis ->
|
|
47
|
+
var entry: ZipEntry? = zis.nextEntry
|
|
48
|
+
while (entry != null) {
|
|
49
|
+
val outFile = File(destDir, entry.name)
|
|
50
|
+
if (entry.isDirectory) {
|
|
51
|
+
outFile.mkdirs()
|
|
52
|
+
} else {
|
|
53
|
+
outFile.parentFile?.mkdirs()
|
|
54
|
+
FileOutputStream(outFile).use { fos ->
|
|
55
|
+
val buffer = ByteArray(BUFFER_SIZE)
|
|
56
|
+
var len: Int
|
|
57
|
+
while (zis.read(buffer).also { len = it } > 0) {
|
|
58
|
+
fos.write(buffer, 0, len)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
zis.closeEntry()
|
|
63
|
+
entry = zis.nextEntry
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
promise.resolve(to)
|
|
67
|
+
} catch (e: Exception) {
|
|
68
|
+
promise.reject("ZIP_ERROR", e.message, e)
|
|
69
|
+
}
|
|
70
|
+
}.start()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override fun unzipWithPassword(from: String, to: String, password: String, promise: Promise) {
|
|
74
|
+
Thread {
|
|
75
|
+
// java.util.zip does not support password-protected zip extraction
|
|
76
|
+
promise.reject("ZIP_ERROR", "Password-protected zip extraction is not supported on Android")
|
|
77
|
+
}.start()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
override fun zipFolder(from: String, to: String, promise: Promise) {
|
|
81
|
+
Thread {
|
|
82
|
+
try {
|
|
83
|
+
val sourceDir = File(from)
|
|
84
|
+
FileOutputStream(to).use { fos ->
|
|
85
|
+
ZipOutputStream(BufferedOutputStream(fos)).use { zos ->
|
|
86
|
+
zipDirectory(sourceDir, sourceDir.name, zos)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
promise.resolve(to)
|
|
90
|
+
} catch (e: Exception) {
|
|
91
|
+
promise.reject("ZIP_ERROR", e.message, e)
|
|
92
|
+
}
|
|
93
|
+
}.start()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override fun zipFiles(files: ReadableArray, to: String, promise: Promise) {
|
|
97
|
+
Thread {
|
|
98
|
+
try {
|
|
99
|
+
FileOutputStream(to).use { fos ->
|
|
100
|
+
ZipOutputStream(BufferedOutputStream(fos)).use { zos ->
|
|
101
|
+
for (i in 0 until files.size()) {
|
|
102
|
+
val filePath = files.getString(i)
|
|
103
|
+
val file = File(filePath)
|
|
104
|
+
if (file.exists()) {
|
|
105
|
+
addFileToZip(file, file.name, zos)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
promise.resolve(to)
|
|
111
|
+
} catch (e: Exception) {
|
|
112
|
+
promise.reject("ZIP_ERROR", e.message, e)
|
|
113
|
+
}
|
|
114
|
+
}.start()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override fun getUncompressedSize(path: String, promise: Promise) {
|
|
118
|
+
Thread {
|
|
119
|
+
try {
|
|
120
|
+
var totalSize = 0L
|
|
121
|
+
ZipFile(path).use { zipFile ->
|
|
122
|
+
val entries = zipFile.entries()
|
|
123
|
+
while (entries.hasMoreElements()) {
|
|
124
|
+
totalSize += entries.nextElement().size
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
promise.resolve(totalSize.toDouble())
|
|
128
|
+
} catch (e: Exception) {
|
|
129
|
+
promise.reject("ZIP_ERROR", e.message, e)
|
|
130
|
+
}
|
|
131
|
+
}.start()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private fun zipDirectory(dir: File, baseName: String, zos: ZipOutputStream) {
|
|
135
|
+
val files = dir.listFiles() ?: return
|
|
136
|
+
for (file in files) {
|
|
137
|
+
val entryName = "$baseName/${file.name}"
|
|
138
|
+
if (file.isDirectory) {
|
|
139
|
+
zipDirectory(file, entryName, zos)
|
|
140
|
+
} else {
|
|
141
|
+
addFileToZip(file, entryName, zos)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private fun addFileToZip(file: File, entryName: String, zos: ZipOutputStream) {
|
|
147
|
+
val entry = ZipEntry(entryName)
|
|
148
|
+
zos.putNextEntry(entry)
|
|
149
|
+
FileInputStream(file).use { fis ->
|
|
150
|
+
val buffer = ByteArray(BUFFER_SIZE)
|
|
151
|
+
var len: Int
|
|
152
|
+
while (fis.read(buffer).also { len = it } > 0) {
|
|
153
|
+
zos.write(buffer, 0, len)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
zos.closeEntry()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.rnziparchive
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class RNZipArchivePackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == RNZipArchiveModule.NAME) {
|
|
13
|
+
RNZipArchiveModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[RNZipArchiveModule.NAME] = ReactModuleInfo(
|
|
23
|
+
RNZipArchiveModule.NAME,
|
|
24
|
+
RNZipArchiveModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/ios/ZipArchive.h
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <RNZipArchiveSpec/RNZipArchiveSpec.h>
|
|
2
|
+
#import <SSZipArchive/SSZipArchive.h>
|
|
3
|
+
|
|
4
|
+
@interface ZipArchive : NativeRNZipArchiveSpecBase <NativeRNZipArchiveSpec, SSZipArchiveDelegate>
|
|
5
|
+
|
|
6
|
+
@property (nonatomic) NSString *processedFilePath;
|
|
7
|
+
@property (nonatomic) float progress;
|
|
8
|
+
@property (nonatomic, copy) void (^progressHandler)(NSUInteger entryNumber, NSUInteger total);
|
|
9
|
+
|
|
10
|
+
@end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#import "ZipArchive.h"
|
|
2
|
+
|
|
3
|
+
@implementation ZipArchive
|
|
4
|
+
{
|
|
5
|
+
bool hasListeners;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
9
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
10
|
+
{
|
|
11
|
+
return std::make_shared<facebook::react::NativeRNZipArchiveSpecJSI>(params);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
+ (NSString *)moduleName
|
|
15
|
+
{
|
|
16
|
+
return @"RNZipArchive";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
+ (BOOL)requiresMainQueueSetup
|
|
20
|
+
{
|
|
21
|
+
return NO;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (dispatch_queue_t)methodQueue
|
|
25
|
+
{
|
|
26
|
+
return dispatch_queue_create("com.onekey.ZipArchiveQueue", DISPATCH_QUEUE_SERIAL);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// MARK: - isPasswordProtected
|
|
30
|
+
|
|
31
|
+
- (void)isPasswordProtected:(NSString *)file
|
|
32
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
33
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
34
|
+
{
|
|
35
|
+
BOOL isPasswordProtected = [SSZipArchive isFilePasswordProtectedAtPath:file];
|
|
36
|
+
resolve([NSNumber numberWithBool:isPasswordProtected]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// MARK: - unzip
|
|
40
|
+
|
|
41
|
+
- (void)unzip:(NSString *)from
|
|
42
|
+
to:(NSString *)to
|
|
43
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
44
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
45
|
+
{
|
|
46
|
+
self.progress = 0.0;
|
|
47
|
+
self.processedFilePath = @"";
|
|
48
|
+
|
|
49
|
+
NSError *error = nil;
|
|
50
|
+
BOOL success = [SSZipArchive unzipFileAtPath:from
|
|
51
|
+
toDestination:to
|
|
52
|
+
preserveAttributes:NO
|
|
53
|
+
overwrite:YES
|
|
54
|
+
password:nil
|
|
55
|
+
error:&error
|
|
56
|
+
delegate:self];
|
|
57
|
+
|
|
58
|
+
self.progress = 1.0;
|
|
59
|
+
|
|
60
|
+
if (success) {
|
|
61
|
+
resolve(to);
|
|
62
|
+
} else {
|
|
63
|
+
reject(@"unzip_error", [error localizedDescription], error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// MARK: - unzipWithPassword
|
|
68
|
+
|
|
69
|
+
- (void)unzipWithPassword:(NSString *)from
|
|
70
|
+
to:(NSString *)to
|
|
71
|
+
password:(NSString *)password
|
|
72
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
73
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
74
|
+
{
|
|
75
|
+
self.progress = 0.0;
|
|
76
|
+
self.processedFilePath = @"";
|
|
77
|
+
|
|
78
|
+
NSError *error = nil;
|
|
79
|
+
BOOL success = [SSZipArchive unzipFileAtPath:from
|
|
80
|
+
toDestination:to
|
|
81
|
+
preserveAttributes:NO
|
|
82
|
+
overwrite:YES
|
|
83
|
+
password:password
|
|
84
|
+
error:&error
|
|
85
|
+
delegate:self];
|
|
86
|
+
|
|
87
|
+
self.progress = 1.0;
|
|
88
|
+
|
|
89
|
+
if (success) {
|
|
90
|
+
resolve(to);
|
|
91
|
+
} else {
|
|
92
|
+
reject(@"unzip_error", @"unable to unzip", error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// MARK: - zipFolder
|
|
97
|
+
|
|
98
|
+
- (void)zipFolder:(NSString *)from
|
|
99
|
+
to:(NSString *)to
|
|
100
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
101
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
102
|
+
{
|
|
103
|
+
self.progress = 0.0;
|
|
104
|
+
self.processedFilePath = @"";
|
|
105
|
+
[self setProgressHandler];
|
|
106
|
+
|
|
107
|
+
BOOL success = [SSZipArchive createZipFileAtPath:to
|
|
108
|
+
withContentsOfDirectory:from
|
|
109
|
+
keepParentDirectory:NO
|
|
110
|
+
withPassword:nil
|
|
111
|
+
andProgressHandler:self.progressHandler];
|
|
112
|
+
|
|
113
|
+
self.progress = 1.0;
|
|
114
|
+
|
|
115
|
+
if (success) {
|
|
116
|
+
resolve(to);
|
|
117
|
+
} else {
|
|
118
|
+
reject(@"zip_error", @"unable to zip", nil);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// MARK: - zipFiles
|
|
123
|
+
|
|
124
|
+
- (void)zipFiles:(NSArray *)files
|
|
125
|
+
to:(NSString *)to
|
|
126
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
127
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
128
|
+
{
|
|
129
|
+
self.progress = 0.0;
|
|
130
|
+
self.processedFilePath = @"";
|
|
131
|
+
[self setProgressHandler];
|
|
132
|
+
|
|
133
|
+
BOOL success = [SSZipArchive createZipFileAtPath:to withFilesAtPaths:files];
|
|
134
|
+
|
|
135
|
+
self.progress = 1.0;
|
|
136
|
+
|
|
137
|
+
if (success) {
|
|
138
|
+
resolve(to);
|
|
139
|
+
} else {
|
|
140
|
+
reject(@"zip_error", @"unable to zip", nil);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// MARK: - getUncompressedSize
|
|
145
|
+
|
|
146
|
+
- (void)getUncompressedSize:(NSString *)path
|
|
147
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
148
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
149
|
+
{
|
|
150
|
+
NSError *error = nil;
|
|
151
|
+
NSNumber *wantedFileSize = [SSZipArchive payloadSizeForArchiveAtPath:path error:&error];
|
|
152
|
+
|
|
153
|
+
if (error == nil) {
|
|
154
|
+
resolve(wantedFileSize);
|
|
155
|
+
} else {
|
|
156
|
+
resolve(@-1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// MARK: - SSZipArchiveDelegate
|
|
161
|
+
|
|
162
|
+
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex
|
|
163
|
+
totalFiles:(NSInteger)totalFiles
|
|
164
|
+
archivePath:(NSString *)archivePath
|
|
165
|
+
unzippedFilePath:(NSString *)processedFilePath
|
|
166
|
+
{
|
|
167
|
+
self.processedFilePath = processedFilePath;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// MARK: - Progress helper
|
|
171
|
+
|
|
172
|
+
- (void)setProgressHandler
|
|
173
|
+
{
|
|
174
|
+
__weak ZipArchive *weakSelf = self;
|
|
175
|
+
self.progressHandler = ^(NSUInteger entryNumber, NSUInteger total) {
|
|
176
|
+
if (total > 0) {
|
|
177
|
+
weakSelf.progress = (float)entryNumber / (float)total;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeZipArchive.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAYlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeZipArchive","ZipArchive"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,gBAAgB,MAAM,uBAAoB;AAEjD,OAAO,MAAMC,UAAU,GAAGD,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
isPasswordProtected(file: string): Promise<boolean>;
|
|
4
|
+
unzip(from: string, to: string): Promise<string>;
|
|
5
|
+
unzipWithPassword(from: string, to: string, password: string): Promise<string>;
|
|
6
|
+
zipFolder(from: string, to: string): Promise<string>;
|
|
7
|
+
zipFiles(files: string[], to: string): Promise<string>;
|
|
8
|
+
getUncompressedSize(path: string): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: Spec;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=NativeZipArchive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeZipArchive.d.ts","sourceRoot":"","sources":["../../../src/NativeZipArchive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/E,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpD;;AAED,wBAAsE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,mCAAmB,CAAC;AAC3C,YAAY,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-zip-archive",
|
|
3
|
+
"version": "1.1.57",
|
|
4
|
+
"description": "react-native-zip-archive TurboModule for OneKey",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"ios",
|
|
19
|
+
"*.podspec",
|
|
20
|
+
"!ios/build",
|
|
21
|
+
"!**/__tests__",
|
|
22
|
+
"!**/__fixtures__",
|
|
23
|
+
"!**/__mocks__",
|
|
24
|
+
"!**/.*",
|
|
25
|
+
"android"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepare": "bob build",
|
|
29
|
+
"typecheck": "tsc",
|
|
30
|
+
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react-native",
|
|
34
|
+
"ios",
|
|
35
|
+
"android"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules/react-native-zip-archive.git"
|
|
40
|
+
},
|
|
41
|
+
"author": "@onekeyhq <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/OneKeyHQ/app-modules/react-native-zip-archive/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules/react-native-zip-archive#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react": "*",
|
|
52
|
+
"react-native": "*"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@react-native/babel-preset": "0.83.0",
|
|
56
|
+
"react": "19.2.0",
|
|
57
|
+
"react-native": "0.83.0",
|
|
58
|
+
"react-native-builder-bob": "^0.40.17",
|
|
59
|
+
"typescript": "^5.9.2"
|
|
60
|
+
},
|
|
61
|
+
"react-native-builder-bob": {
|
|
62
|
+
"source": "src",
|
|
63
|
+
"output": "lib",
|
|
64
|
+
"targets": [
|
|
65
|
+
[
|
|
66
|
+
"module",
|
|
67
|
+
{
|
|
68
|
+
"esm": true
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"typescript",
|
|
73
|
+
{
|
|
74
|
+
"project": "tsconfig.build.json"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"codegenConfig": {
|
|
80
|
+
"name": "RNZipArchiveSpec",
|
|
81
|
+
"type": "modules",
|
|
82
|
+
"jsSrcsDir": "src",
|
|
83
|
+
"android": {
|
|
84
|
+
"javaPackageName": "com.rnziparchive"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
isPasswordProtected(file: string): Promise<boolean>;
|
|
6
|
+
unzip(from: string, to: string): Promise<string>;
|
|
7
|
+
unzipWithPassword(from: string, to: string, password: string): Promise<string>;
|
|
8
|
+
zipFolder(from: string, to: string): Promise<string>;
|
|
9
|
+
zipFiles(files: string[], to: string): Promise<string>;
|
|
10
|
+
getUncompressedSize(path: string): Promise<number>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNZipArchive');
|
package/src/index.tsx
ADDED