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.
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/android/CMakeLists.txt +16 -0
- package/android/build.gradle +70 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/unzip/HybridUnzip.kt +29 -0
- package/android/src/main/java/com/margelo/nitro/unzip/HybridUnzipTask.kt +256 -0
- package/android/src/main/java/com/margelo/nitro/unzip/HybridZipTask.kt +157 -0
- package/ios/HybridUnzip.swift +33 -0
- package/ios/HybridUnzipTask.swift +238 -0
- package/ios/HybridZipTask.swift +266 -0
- package/lib/commonjs/index.js +31 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/Unzip.nitro.js +6 -0
- package/lib/commonjs/specs/Unzip.nitro.js.map +1 -0
- package/lib/module/index.js +27 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/Unzip.nitro.js +4 -0
- package/lib/module/specs/Unzip.nitro.js.map +1 -0
- package/lib/typescript/index.d.ts +24 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/Unzip.nitro.d.ts +170 -0
- package/lib/typescript/specs/Unzip.nitro.d.ts.map +1 -0
- package/nitro.json +26 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroUnzip+autolinking.cmake +85 -0
- package/nitrogen/generated/android/NitroUnzip+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroUnzipOnLoad.cpp +71 -0
- package/nitrogen/generated/android/NitroUnzipOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void_UnzipProgress.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_ZipProgress.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridUnzipSpec.cpp +82 -0
- package/nitrogen/generated/android/c++/JHybridUnzipSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridUnzipTaskSpec.cpp +94 -0
- package/nitrogen/generated/android/c++/JHybridUnzipTaskSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/JHybridZipTaskSpec.cpp +94 -0
- package/nitrogen/generated/android/c++/JHybridZipTaskSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/JUnzipProgress.hpp +73 -0
- package/nitrogen/generated/android/c++/JUnzipResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JZipProgress.hpp +69 -0
- package/nitrogen/generated/android/c++/JZipResult.hpp +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/Func_void_UnzipProgress.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/Func_void_ZipProgress.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridUnzipSpec.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridUnzipTaskSpec.kt +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/HybridZipTaskSpec.kt +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/NitroUnzipOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/UnzipProgress.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/UnzipResult.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/ZipProgress.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unzip/ZipResult.kt +50 -0
- package/nitrogen/generated/ios/NitroUnzip+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Bridge.cpp +107 -0
- package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Bridge.hpp +270 -0
- package/nitrogen/generated/ios/NitroUnzip-Swift-Cxx-Umbrella.hpp +68 -0
- package/nitrogen/generated/ios/NitroUnzipAutolinking.mm +49 -0
- package/nitrogen/generated/ios/NitroUnzipAutolinking.swift +50 -0
- package/nitrogen/generated/ios/c++/HybridUnzipSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridUnzipSpecSwift.hpp +112 -0
- package/nitrogen/generated/ios/c++/HybridUnzipTaskSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridUnzipTaskSpecSwift.hpp +104 -0
- package/nitrogen/generated/ios/c++/HybridZipTaskSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridZipTaskSpecSwift.hpp +104 -0
- package/nitrogen/generated/ios/swift/Func_void_UnzipProgress.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_UnzipResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ZipProgress.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ZipResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridUnzipSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridUnzipSpec_cxx.swift +186 -0
- package/nitrogen/generated/ios/swift/HybridUnzipTaskSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridUnzipTaskSpec_cxx.swift +177 -0
- package/nitrogen/generated/ios/swift/HybridZipTaskSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridZipTaskSpec_cxx.swift +177 -0
- package/nitrogen/generated/ios/swift/UnzipProgress.swift +49 -0
- package/nitrogen/generated/ios/swift/UnzipResult.swift +49 -0
- package/nitrogen/generated/ios/swift/ZipProgress.swift +44 -0
- package/nitrogen/generated/ios/swift/ZipResult.swift +49 -0
- package/nitrogen/generated/shared/c++/HybridUnzipSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridUnzipSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridUnzipTaskSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridUnzipTaskSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridZipTaskSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridZipTaskSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/UnzipProgress.hpp +99 -0
- package/nitrogen/generated/shared/c++/UnzipResult.hpp +99 -0
- package/nitrogen/generated/shared/c++/ZipProgress.hpp +95 -0
- package/nitrogen/generated/shared/c++/ZipResult.hpp +99 -0
- package/package.json +165 -0
- package/react-native-nitro-unzip.podspec +24 -0
- package/src/index.ts +36 -0
- package/src/specs/Unzip.nitro.ts +193 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// UnzipResult.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `UnzipResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias UnzipResult = margelo.nitro.unzip.UnzipResult
|
|
14
|
+
|
|
15
|
+
public extension UnzipResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.unzip.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `UnzipResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(success: Bool, extractedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
|
|
22
|
+
self.init(success, extractedFiles, duration, averageSpeed, totalBytes)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var success: Bool {
|
|
27
|
+
return self.__success
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var extractedFiles: Double {
|
|
32
|
+
return self.__extractedFiles
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var duration: Double {
|
|
37
|
+
return self.__duration
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var averageSpeed: Double {
|
|
42
|
+
return self.__averageSpeed
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var totalBytes: Double {
|
|
47
|
+
return self.__totalBytes
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ZipProgress.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `ZipProgress`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ZipProgress = margelo.nitro.unzip.ZipProgress
|
|
14
|
+
|
|
15
|
+
public extension ZipProgress {
|
|
16
|
+
private typealias bridge = margelo.nitro.unzip.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ZipProgress`.
|
|
20
|
+
*/
|
|
21
|
+
init(compressedFiles: Double, totalFiles: Double, progress: Double, speed: Double) {
|
|
22
|
+
self.init(compressedFiles, totalFiles, progress, speed)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var compressedFiles: Double {
|
|
27
|
+
return self.__compressedFiles
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var totalFiles: Double {
|
|
32
|
+
return self.__totalFiles
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var progress: Double {
|
|
37
|
+
return self.__progress
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var speed: Double {
|
|
42
|
+
return self.__speed
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ZipResult.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `ZipResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ZipResult = margelo.nitro.unzip.ZipResult
|
|
14
|
+
|
|
15
|
+
public extension ZipResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.unzip.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ZipResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(success: Bool, compressedFiles: Double, duration: Double, averageSpeed: Double, totalBytes: Double) {
|
|
22
|
+
self.init(success, compressedFiles, duration, averageSpeed, totalBytes)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var success: Bool {
|
|
27
|
+
return self.__success
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var compressedFiles: Double {
|
|
32
|
+
return self.__compressedFiles
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var duration: Double {
|
|
37
|
+
return self.__duration
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var averageSpeed: Double {
|
|
42
|
+
return self.__averageSpeed
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var totalBytes: Double {
|
|
47
|
+
return self.__totalBytes
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUnzipSpec.cpp
|
|
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
|
+
#include "HybridUnzipSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::unzip {
|
|
11
|
+
|
|
12
|
+
void HybridUnzipSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("extract", &HybridUnzipSpec::extract);
|
|
18
|
+
prototype.registerHybridMethod("extractWithPassword", &HybridUnzipSpec::extractWithPassword);
|
|
19
|
+
prototype.registerHybridMethod("zip", &HybridUnzipSpec::zip);
|
|
20
|
+
prototype.registerHybridMethod("zipWithPassword", &HybridUnzipSpec::zipWithPassword);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUnzipSpec.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/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
|
+
// Forward declaration of `HybridUnzipTaskSpec` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::unzip { class HybridUnzipTaskSpec; }
|
|
18
|
+
// Forward declaration of `HybridZipTaskSpec` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::unzip { class HybridZipTaskSpec; }
|
|
20
|
+
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include "HybridUnzipTaskSpec.hpp"
|
|
23
|
+
#include <string>
|
|
24
|
+
#include "HybridZipTaskSpec.hpp"
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::unzip {
|
|
27
|
+
|
|
28
|
+
using namespace margelo::nitro;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An abstract base class for `Unzip`
|
|
32
|
+
* Inherit this class to create instances of `HybridUnzipSpec` in C++.
|
|
33
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
34
|
+
* @example
|
|
35
|
+
* ```cpp
|
|
36
|
+
* class HybridUnzip: public HybridUnzipSpec {
|
|
37
|
+
* public:
|
|
38
|
+
* HybridUnzip(...): HybridObject(TAG) { ... }
|
|
39
|
+
* // ...
|
|
40
|
+
* };
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
class HybridUnzipSpec: public virtual HybridObject {
|
|
44
|
+
public:
|
|
45
|
+
// Constructor
|
|
46
|
+
explicit HybridUnzipSpec(): HybridObject(TAG) { }
|
|
47
|
+
|
|
48
|
+
// Destructor
|
|
49
|
+
~HybridUnzipSpec() override = default;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
virtual std::shared_ptr<HybridUnzipTaskSpec> extract(const std::string& zipPath, const std::string& destinationPath) = 0;
|
|
58
|
+
virtual std::shared_ptr<HybridUnzipTaskSpec> extractWithPassword(const std::string& zipPath, const std::string& destinationPath, const std::string& password) = 0;
|
|
59
|
+
virtual std::shared_ptr<HybridZipTaskSpec> zip(const std::string& sourcePath, const std::string& destinationZipPath) = 0;
|
|
60
|
+
virtual std::shared_ptr<HybridZipTaskSpec> zipWithPassword(const std::string& sourcePath, const std::string& destinationZipPath, const std::string& password) = 0;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Hybrid Setup
|
|
64
|
+
void loadHybridMethods() override;
|
|
65
|
+
|
|
66
|
+
protected:
|
|
67
|
+
// Tag for logging
|
|
68
|
+
static constexpr auto TAG = "Unzip";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUnzipTaskSpec.cpp
|
|
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
|
+
#include "HybridUnzipTaskSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::unzip {
|
|
11
|
+
|
|
12
|
+
void HybridUnzipTaskSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("taskId", &HybridUnzipTaskSpec::getTaskId);
|
|
18
|
+
prototype.registerHybridMethod("onProgress", &HybridUnzipTaskSpec::onProgress);
|
|
19
|
+
prototype.registerHybridMethod("cancel", &HybridUnzipTaskSpec::cancel);
|
|
20
|
+
prototype.registerHybridMethod("await", &HybridUnzipTaskSpec::await);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUnzipTaskSpec.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/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
|
+
// Forward declaration of `UnzipProgress` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::unzip { struct UnzipProgress; }
|
|
18
|
+
// Forward declaration of `UnzipResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::unzip { struct UnzipResult; }
|
|
20
|
+
|
|
21
|
+
#include <string>
|
|
22
|
+
#include "UnzipProgress.hpp"
|
|
23
|
+
#include <functional>
|
|
24
|
+
#include "UnzipResult.hpp"
|
|
25
|
+
#include <NitroModules/Promise.hpp>
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::unzip {
|
|
28
|
+
|
|
29
|
+
using namespace margelo::nitro;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An abstract base class for `UnzipTask`
|
|
33
|
+
* Inherit this class to create instances of `HybridUnzipTaskSpec` in C++.
|
|
34
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
35
|
+
* @example
|
|
36
|
+
* ```cpp
|
|
37
|
+
* class HybridUnzipTask: public HybridUnzipTaskSpec {
|
|
38
|
+
* public:
|
|
39
|
+
* HybridUnzipTask(...): HybridObject(TAG) { ... }
|
|
40
|
+
* // ...
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
class HybridUnzipTaskSpec: public virtual HybridObject {
|
|
45
|
+
public:
|
|
46
|
+
// Constructor
|
|
47
|
+
explicit HybridUnzipTaskSpec(): HybridObject(TAG) { }
|
|
48
|
+
|
|
49
|
+
// Destructor
|
|
50
|
+
~HybridUnzipTaskSpec() override = default;
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
virtual std::string getTaskId() = 0;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
virtual void onProgress(const std::function<void(const UnzipProgress& /* progress */)>& callback) = 0;
|
|
59
|
+
virtual void cancel() = 0;
|
|
60
|
+
virtual std::shared_ptr<Promise<UnzipResult>> await() = 0;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Hybrid Setup
|
|
64
|
+
void loadHybridMethods() override;
|
|
65
|
+
|
|
66
|
+
protected:
|
|
67
|
+
// Tag for logging
|
|
68
|
+
static constexpr auto TAG = "UnzipTask";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridZipTaskSpec.cpp
|
|
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
|
+
#include "HybridZipTaskSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::unzip {
|
|
11
|
+
|
|
12
|
+
void HybridZipTaskSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("taskId", &HybridZipTaskSpec::getTaskId);
|
|
18
|
+
prototype.registerHybridMethod("onProgress", &HybridZipTaskSpec::onProgress);
|
|
19
|
+
prototype.registerHybridMethod("cancel", &HybridZipTaskSpec::cancel);
|
|
20
|
+
prototype.registerHybridMethod("await", &HybridZipTaskSpec::await);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridZipTaskSpec.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/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
|
+
// Forward declaration of `ZipProgress` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::unzip { struct ZipProgress; }
|
|
18
|
+
// Forward declaration of `ZipResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::unzip { struct ZipResult; }
|
|
20
|
+
|
|
21
|
+
#include <string>
|
|
22
|
+
#include "ZipProgress.hpp"
|
|
23
|
+
#include <functional>
|
|
24
|
+
#include "ZipResult.hpp"
|
|
25
|
+
#include <NitroModules/Promise.hpp>
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::unzip {
|
|
28
|
+
|
|
29
|
+
using namespace margelo::nitro;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An abstract base class for `ZipTask`
|
|
33
|
+
* Inherit this class to create instances of `HybridZipTaskSpec` in C++.
|
|
34
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
35
|
+
* @example
|
|
36
|
+
* ```cpp
|
|
37
|
+
* class HybridZipTask: public HybridZipTaskSpec {
|
|
38
|
+
* public:
|
|
39
|
+
* HybridZipTask(...): HybridObject(TAG) { ... }
|
|
40
|
+
* // ...
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
class HybridZipTaskSpec: public virtual HybridObject {
|
|
45
|
+
public:
|
|
46
|
+
// Constructor
|
|
47
|
+
explicit HybridZipTaskSpec(): HybridObject(TAG) { }
|
|
48
|
+
|
|
49
|
+
// Destructor
|
|
50
|
+
~HybridZipTaskSpec() override = default;
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
virtual std::string getTaskId() = 0;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
virtual void onProgress(const std::function<void(const ZipProgress& /* progress */)>& callback) = 0;
|
|
59
|
+
virtual void cancel() = 0;
|
|
60
|
+
virtual std::shared_ptr<Promise<ZipResult>> await() = 0;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Hybrid Setup
|
|
64
|
+
void loadHybridMethods() override;
|
|
65
|
+
|
|
66
|
+
protected:
|
|
67
|
+
// Tag for logging
|
|
68
|
+
static constexpr auto TAG = "ZipTask";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::unzip
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// UnzipProgress.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 (UnzipProgress).
|
|
39
|
+
*/
|
|
40
|
+
struct UnzipProgress final {
|
|
41
|
+
public:
|
|
42
|
+
double extractedFiles SWIFT_PRIVATE;
|
|
43
|
+
double totalFiles SWIFT_PRIVATE;
|
|
44
|
+
double progress SWIFT_PRIVATE;
|
|
45
|
+
double speed SWIFT_PRIVATE;
|
|
46
|
+
double processedBytes SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
UnzipProgress() = default;
|
|
50
|
+
explicit UnzipProgress(double extractedFiles, double totalFiles, double progress, double speed, double processedBytes): extractedFiles(extractedFiles), totalFiles(totalFiles), progress(progress), speed(speed), processedBytes(processedBytes) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const UnzipProgress& lhs, const UnzipProgress& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::unzip
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ UnzipProgress <> JS UnzipProgress (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::unzip::UnzipProgress> final {
|
|
63
|
+
static inline margelo::nitro::unzip::UnzipProgress fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::unzip::UnzipProgress(
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "processedBytes")))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unzip::UnzipProgress& arg) {
|
|
74
|
+
jsi::Object obj(runtime);
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles"), JSIConverter<double>::toJSI(runtime, arg.extractedFiles));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalFiles"), JSIConverter<double>::toJSI(runtime, arg.totalFiles));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<double>::toJSI(runtime, arg.progress));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<double>::toJSI(runtime, arg.speed));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "processedBytes"), JSIConverter<double>::toJSI(runtime, arg.processedBytes));
|
|
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<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles")))) return false;
|
|
91
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFiles")))) return false;
|
|
92
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
|
|
93
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
|
|
94
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "processedBytes")))) return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// UnzipResult.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 (UnzipResult).
|
|
39
|
+
*/
|
|
40
|
+
struct UnzipResult final {
|
|
41
|
+
public:
|
|
42
|
+
bool success SWIFT_PRIVATE;
|
|
43
|
+
double extractedFiles SWIFT_PRIVATE;
|
|
44
|
+
double duration SWIFT_PRIVATE;
|
|
45
|
+
double averageSpeed SWIFT_PRIVATE;
|
|
46
|
+
double totalBytes SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
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
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const UnzipResult& lhs, const UnzipResult& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::unzip
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ UnzipResult <> JS UnzipResult (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::unzip::UnzipResult> final {
|
|
63
|
+
static inline margelo::nitro::unzip::UnzipResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::unzip::UnzipResult(
|
|
66
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extractedFiles"))),
|
|
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::UnzipResult& 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, "extractedFiles"), JSIConverter<double>::toJSI(runtime, arg.extractedFiles));
|
|
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, "extractedFiles")))) 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
|