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,186 @@
1
+ ///
2
+ /// HybridUnzipSpec_cxx.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
+ * A class implementation that bridges HybridUnzipSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridUnzipSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::unzip::bridge::swift`)
22
+ * from `NitroUnzip-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.unzip.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridUnzipSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridUnzipSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridUnzipSpec_
36
+
37
+ /**
38
+ * Create a new `HybridUnzipSpec_cxx` that wraps the given `HybridUnzipSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridUnzipSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridUnzipSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridUnzipSpec() -> any HybridUnzipSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridUnzipSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridUnzipSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridUnzipSpec_cxx {
69
+ return Unmanaged<HybridUnzipSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridUnzipSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridUnzipSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridUnzipSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridUnzipSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridUnzipSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func extract(zipPath: std.string, destinationPath: std.string) -> bridge.Result_std__shared_ptr_HybridUnzipTaskSpec__ {
129
+ do {
130
+ let __result = try self.__implementation.extract(zipPath: String(zipPath), destinationPath: String(destinationPath))
131
+ let __resultCpp = { () -> bridge.std__shared_ptr_HybridUnzipTaskSpec_ in
132
+ let __cxxWrapped = __result.getCxxWrapper()
133
+ return __cxxWrapped.getCxxPart()
134
+ }()
135
+ return bridge.create_Result_std__shared_ptr_HybridUnzipTaskSpec__(__resultCpp)
136
+ } catch (let __error) {
137
+ let __exceptionPtr = __error.toCpp()
138
+ return bridge.create_Result_std__shared_ptr_HybridUnzipTaskSpec__(__exceptionPtr)
139
+ }
140
+ }
141
+
142
+ @inline(__always)
143
+ public final func extractWithPassword(zipPath: std.string, destinationPath: std.string, password: std.string) -> bridge.Result_std__shared_ptr_HybridUnzipTaskSpec__ {
144
+ do {
145
+ let __result = try self.__implementation.extractWithPassword(zipPath: String(zipPath), destinationPath: String(destinationPath), password: String(password))
146
+ let __resultCpp = { () -> bridge.std__shared_ptr_HybridUnzipTaskSpec_ in
147
+ let __cxxWrapped = __result.getCxxWrapper()
148
+ return __cxxWrapped.getCxxPart()
149
+ }()
150
+ return bridge.create_Result_std__shared_ptr_HybridUnzipTaskSpec__(__resultCpp)
151
+ } catch (let __error) {
152
+ let __exceptionPtr = __error.toCpp()
153
+ return bridge.create_Result_std__shared_ptr_HybridUnzipTaskSpec__(__exceptionPtr)
154
+ }
155
+ }
156
+
157
+ @inline(__always)
158
+ public final func zip(sourcePath: std.string, destinationZipPath: std.string) -> bridge.Result_std__shared_ptr_HybridZipTaskSpec__ {
159
+ do {
160
+ let __result = try self.__implementation.zip(sourcePath: String(sourcePath), destinationZipPath: String(destinationZipPath))
161
+ let __resultCpp = { () -> bridge.std__shared_ptr_HybridZipTaskSpec_ in
162
+ let __cxxWrapped = __result.getCxxWrapper()
163
+ return __cxxWrapped.getCxxPart()
164
+ }()
165
+ return bridge.create_Result_std__shared_ptr_HybridZipTaskSpec__(__resultCpp)
166
+ } catch (let __error) {
167
+ let __exceptionPtr = __error.toCpp()
168
+ return bridge.create_Result_std__shared_ptr_HybridZipTaskSpec__(__exceptionPtr)
169
+ }
170
+ }
171
+
172
+ @inline(__always)
173
+ public final func zipWithPassword(sourcePath: std.string, destinationZipPath: std.string, password: std.string) -> bridge.Result_std__shared_ptr_HybridZipTaskSpec__ {
174
+ do {
175
+ let __result = try self.__implementation.zipWithPassword(sourcePath: String(sourcePath), destinationZipPath: String(destinationZipPath), password: String(password))
176
+ let __resultCpp = { () -> bridge.std__shared_ptr_HybridZipTaskSpec_ in
177
+ let __cxxWrapped = __result.getCxxWrapper()
178
+ return __cxxWrapped.getCxxPart()
179
+ }()
180
+ return bridge.create_Result_std__shared_ptr_HybridZipTaskSpec__(__resultCpp)
181
+ } catch (let __error) {
182
+ let __exceptionPtr = __error.toCpp()
183
+ return bridge.create_Result_std__shared_ptr_HybridZipTaskSpec__(__exceptionPtr)
184
+ }
185
+ }
186
+ }
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridUnzipTaskSpec.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
+ /// See ``HybridUnzipTaskSpec``
11
+ public protocol HybridUnzipTaskSpec_protocol: HybridObject {
12
+ // Properties
13
+ var taskId: String { get }
14
+
15
+ // Methods
16
+ func onProgress(callback: @escaping (_ progress: UnzipProgress) -> Void) throws -> Void
17
+ func cancel() throws -> Void
18
+ func await() throws -> Promise<UnzipResult>
19
+ }
20
+
21
+ public extension HybridUnzipTaskSpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject UnzipTask]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridUnzipTaskSpec``
29
+ open class HybridUnzipTaskSpec_base {
30
+ private weak var cxxWrapper: HybridUnzipTaskSpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridUnzipTaskSpec_cxx {
33
+ #if DEBUG
34
+ guard self is any HybridUnzipTaskSpec else {
35
+ fatalError("`self` is not a `HybridUnzipTaskSpec`! Did you accidentally inherit from `HybridUnzipTaskSpec_base` instead of `HybridUnzipTaskSpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridUnzipTaskSpec_cxx(self as! any HybridUnzipTaskSpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the UnzipTask HybridObject.
50
+ * Implement this protocol to create Swift-based instances of UnzipTask.
51
+ * ```swift
52
+ * class HybridUnzipTask : HybridUnzipTaskSpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridUnzipTaskSpec = HybridUnzipTaskSpec_protocol & HybridUnzipTaskSpec_base
@@ -0,0 +1,177 @@
1
+ ///
2
+ /// HybridUnzipTaskSpec_cxx.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
+ * A class implementation that bridges HybridUnzipTaskSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridUnzipTaskSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::unzip::bridge::swift`)
22
+ * from `NitroUnzip-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.unzip.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridUnzipTaskSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridUnzipTaskSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridUnzipTaskSpec_
36
+
37
+ /**
38
+ * Create a new `HybridUnzipTaskSpec_cxx` that wraps the given `HybridUnzipTaskSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridUnzipTaskSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridUnzipTaskSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridUnzipTaskSpec() -> any HybridUnzipTaskSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridUnzipTaskSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridUnzipTaskSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridUnzipTaskSpec_cxx {
69
+ return Unmanaged<HybridUnzipTaskSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridUnzipTaskSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridUnzipTaskSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridUnzipTaskSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridUnzipTaskSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridUnzipTaskSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+ public final var taskId: std.string {
125
+ @inline(__always)
126
+ get {
127
+ return std.string(self.__implementation.taskId)
128
+ }
129
+ }
130
+
131
+ // Methods
132
+ @inline(__always)
133
+ public final func onProgress(callback: bridge.Func_void_UnzipProgress) -> bridge.Result_void_ {
134
+ do {
135
+ try self.__implementation.onProgress(callback: { () -> (UnzipProgress) -> Void in
136
+ let __wrappedFunction = bridge.wrap_Func_void_UnzipProgress(callback)
137
+ return { (__progress: UnzipProgress) -> Void in
138
+ __wrappedFunction.call(__progress)
139
+ }
140
+ }())
141
+ return bridge.create_Result_void_()
142
+ } catch (let __error) {
143
+ let __exceptionPtr = __error.toCpp()
144
+ return bridge.create_Result_void_(__exceptionPtr)
145
+ }
146
+ }
147
+
148
+ @inline(__always)
149
+ public final func cancel() -> bridge.Result_void_ {
150
+ do {
151
+ try self.__implementation.cancel()
152
+ return bridge.create_Result_void_()
153
+ } catch (let __error) {
154
+ let __exceptionPtr = __error.toCpp()
155
+ return bridge.create_Result_void_(__exceptionPtr)
156
+ }
157
+ }
158
+
159
+ @inline(__always)
160
+ public final func await() -> bridge.Result_std__shared_ptr_Promise_UnzipResult___ {
161
+ do {
162
+ let __result = try self.__implementation.await()
163
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_UnzipResult__ in
164
+ let __promise = bridge.create_std__shared_ptr_Promise_UnzipResult__()
165
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_UnzipResult__(__promise)
166
+ __result
167
+ .then({ __result in __promiseHolder.resolve(__result) })
168
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
169
+ return __promise
170
+ }()
171
+ return bridge.create_Result_std__shared_ptr_Promise_UnzipResult___(__resultCpp)
172
+ } catch (let __error) {
173
+ let __exceptionPtr = __error.toCpp()
174
+ return bridge.create_Result_std__shared_ptr_Promise_UnzipResult___(__exceptionPtr)
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridZipTaskSpec.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
+ /// See ``HybridZipTaskSpec``
11
+ public protocol HybridZipTaskSpec_protocol: HybridObject {
12
+ // Properties
13
+ var taskId: String { get }
14
+
15
+ // Methods
16
+ func onProgress(callback: @escaping (_ progress: ZipProgress) -> Void) throws -> Void
17
+ func cancel() throws -> Void
18
+ func await() throws -> Promise<ZipResult>
19
+ }
20
+
21
+ public extension HybridZipTaskSpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject ZipTask]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridZipTaskSpec``
29
+ open class HybridZipTaskSpec_base {
30
+ private weak var cxxWrapper: HybridZipTaskSpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridZipTaskSpec_cxx {
33
+ #if DEBUG
34
+ guard self is any HybridZipTaskSpec else {
35
+ fatalError("`self` is not a `HybridZipTaskSpec`! Did you accidentally inherit from `HybridZipTaskSpec_base` instead of `HybridZipTaskSpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridZipTaskSpec_cxx(self as! any HybridZipTaskSpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the ZipTask HybridObject.
50
+ * Implement this protocol to create Swift-based instances of ZipTask.
51
+ * ```swift
52
+ * class HybridZipTask : HybridZipTaskSpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridZipTaskSpec = HybridZipTaskSpec_protocol & HybridZipTaskSpec_base
@@ -0,0 +1,177 @@
1
+ ///
2
+ /// HybridZipTaskSpec_cxx.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
+ * A class implementation that bridges HybridZipTaskSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridZipTaskSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::unzip::bridge::swift`)
22
+ * from `NitroUnzip-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.unzip.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridZipTaskSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridZipTaskSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridZipTaskSpec_
36
+
37
+ /**
38
+ * Create a new `HybridZipTaskSpec_cxx` that wraps the given `HybridZipTaskSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridZipTaskSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridZipTaskSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridZipTaskSpec() -> any HybridZipTaskSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridZipTaskSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridZipTaskSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridZipTaskSpec_cxx {
69
+ return Unmanaged<HybridZipTaskSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridZipTaskSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridZipTaskSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridZipTaskSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridZipTaskSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridZipTaskSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+ public final var taskId: std.string {
125
+ @inline(__always)
126
+ get {
127
+ return std.string(self.__implementation.taskId)
128
+ }
129
+ }
130
+
131
+ // Methods
132
+ @inline(__always)
133
+ public final func onProgress(callback: bridge.Func_void_ZipProgress) -> bridge.Result_void_ {
134
+ do {
135
+ try self.__implementation.onProgress(callback: { () -> (ZipProgress) -> Void in
136
+ let __wrappedFunction = bridge.wrap_Func_void_ZipProgress(callback)
137
+ return { (__progress: ZipProgress) -> Void in
138
+ __wrappedFunction.call(__progress)
139
+ }
140
+ }())
141
+ return bridge.create_Result_void_()
142
+ } catch (let __error) {
143
+ let __exceptionPtr = __error.toCpp()
144
+ return bridge.create_Result_void_(__exceptionPtr)
145
+ }
146
+ }
147
+
148
+ @inline(__always)
149
+ public final func cancel() -> bridge.Result_void_ {
150
+ do {
151
+ try self.__implementation.cancel()
152
+ return bridge.create_Result_void_()
153
+ } catch (let __error) {
154
+ let __exceptionPtr = __error.toCpp()
155
+ return bridge.create_Result_void_(__exceptionPtr)
156
+ }
157
+ }
158
+
159
+ @inline(__always)
160
+ public final func await() -> bridge.Result_std__shared_ptr_Promise_ZipResult___ {
161
+ do {
162
+ let __result = try self.__implementation.await()
163
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_ZipResult__ in
164
+ let __promise = bridge.create_std__shared_ptr_Promise_ZipResult__()
165
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_ZipResult__(__promise)
166
+ __result
167
+ .then({ __result in __promiseHolder.resolve(__result) })
168
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
169
+ return __promise
170
+ }()
171
+ return bridge.create_Result_std__shared_ptr_Promise_ZipResult___(__resultCpp)
172
+ } catch (let __error) {
173
+ let __exceptionPtr = __error.toCpp()
174
+ return bridge.create_Result_std__shared_ptr_Promise_ZipResult___(__exceptionPtr)
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// UnzipProgress.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 `UnzipProgress`, backed by a C++ struct.
12
+ */
13
+ public typealias UnzipProgress = margelo.nitro.unzip.UnzipProgress
14
+
15
+ public extension UnzipProgress {
16
+ private typealias bridge = margelo.nitro.unzip.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `UnzipProgress`.
20
+ */
21
+ init(extractedFiles: Double, totalFiles: Double, progress: Double, speed: Double, processedBytes: Double) {
22
+ self.init(extractedFiles, totalFiles, progress, speed, processedBytes)
23
+ }
24
+
25
+ @inline(__always)
26
+ var extractedFiles: Double {
27
+ return self.__extractedFiles
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
+
45
+ @inline(__always)
46
+ var processedBytes: Double {
47
+ return self.__processedBytes
48
+ }
49
+ }