react-native-compressor 1.19.0 → 2.0.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 (133) hide show
  1. package/android/CMakeLists.txt +27 -0
  2. package/android/build.gradle +56 -58
  3. package/android/gradle.properties +5 -5
  4. package/android/src/main/AndroidManifestNew.xml +3 -0
  5. package/android/src/main/cpp/cpp-adapter.cpp +8 -0
  6. package/android/src/main/java/com/margelo/nitro/compressor/HybridCompressor.kt +213 -0
  7. package/android/src/main/java/com/reactnativecompressor/NitroCompressorPackage.kt +30 -0
  8. package/android/src/main/java/com/reactnativecompressor/NitroPromiseAdapter.kt +55 -0
  9. package/android/src/main/java/com/reactnativecompressor/Utils/EventEmitterHandler.kt +49 -45
  10. package/android/src/main/java/com/reactnativecompressor/Utils/Utils.kt +1 -1
  11. package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/compressor/Compressor.kt +13 -22
  12. package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt +72 -0
  13. package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.kt +4 -1
  14. package/ios/Audio/FormatConverter/FormatConverter+Compressed.swift +1 -1
  15. package/ios/Audio/FormatConverter/FormatConverter+Utilities.swift +1 -1
  16. package/ios/Audio/FormatConverter/FormatConverter.swift +5 -3
  17. package/ios/HybridCompressor.swift +247 -0
  18. package/ios/Image/ImageCompressor.swift +8 -2
  19. package/ios/Utils/EventEmitterHandler.swift +56 -34
  20. package/ios/Video/NextLevelSessionExporter.swift +43 -8
  21. package/ios/Video/VideoMain.swift +17 -3
  22. package/lib/commonjs/Audio/index.js +1 -1
  23. package/lib/commonjs/Audio/index.js.map +1 -1
  24. package/lib/commonjs/Image/index.js +2 -22
  25. package/lib/commonjs/Image/index.js.map +1 -1
  26. package/lib/commonjs/Main.js +8 -8
  27. package/lib/commonjs/Main.js.map +1 -1
  28. package/lib/commonjs/Video/index.js +25 -65
  29. package/lib/commonjs/Video/index.js.map +1 -1
  30. package/lib/commonjs/specs/Compressor.nitro.js +6 -0
  31. package/lib/commonjs/specs/Compressor.nitro.js.map +1 -0
  32. package/lib/commonjs/utils/Downloader.js +8 -24
  33. package/lib/commonjs/utils/Downloader.js.map +1 -1
  34. package/lib/commonjs/utils/Uploader.js +3 -18
  35. package/lib/commonjs/utils/Uploader.js.map +1 -1
  36. package/lib/commonjs/utils/helpers.js +18 -1
  37. package/lib/commonjs/utils/helpers.js.map +1 -1
  38. package/lib/commonjs/utils/index.js +13 -13
  39. package/lib/commonjs/utils/index.js.map +1 -1
  40. package/lib/module/Audio/index.js +2 -2
  41. package/lib/module/Audio/index.js.map +1 -1
  42. package/lib/module/Image/index.js +3 -23
  43. package/lib/module/Image/index.js.map +1 -1
  44. package/lib/module/Main.js +9 -9
  45. package/lib/module/Main.js.map +1 -1
  46. package/lib/module/Video/index.js +26 -66
  47. package/lib/module/Video/index.js.map +1 -1
  48. package/lib/module/specs/Compressor.nitro.js +4 -0
  49. package/lib/module/specs/Compressor.nitro.js.map +1 -0
  50. package/lib/module/utils/Downloader.js +10 -26
  51. package/lib/module/utils/Downloader.js.map +1 -1
  52. package/lib/module/utils/Uploader.js +5 -20
  53. package/lib/module/utils/Uploader.js.map +1 -1
  54. package/lib/module/utils/helpers.js +16 -0
  55. package/lib/module/utils/helpers.js.map +1 -1
  56. package/lib/module/utils/index.js +2 -1
  57. package/lib/module/utils/index.js.map +1 -1
  58. package/lib/typescript/src/Image/index.d.ts.map +1 -1
  59. package/lib/typescript/src/Main.d.ts +2 -1
  60. package/lib/typescript/src/Main.d.ts.map +1 -1
  61. package/lib/typescript/src/Video/index.d.ts +1 -1
  62. package/lib/typescript/src/Video/index.d.ts.map +1 -1
  63. package/lib/typescript/src/index.d.ts.map +1 -1
  64. package/lib/typescript/src/specs/Compressor.nitro.d.ts +44 -0
  65. package/lib/typescript/src/specs/Compressor.nitro.d.ts.map +1 -0
  66. package/lib/typescript/src/utils/Downloader.d.ts.map +1 -1
  67. package/lib/typescript/src/utils/Uploader.d.ts.map +1 -1
  68. package/lib/typescript/src/utils/helpers.d.ts +7 -0
  69. package/lib/typescript/src/utils/helpers.d.ts.map +1 -1
  70. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  71. package/nitrogen/generated/android/NitroCompressor+autolinking.cmake +81 -0
  72. package/nitrogen/generated/android/NitroCompressor+autolinking.gradle +27 -0
  73. package/nitrogen/generated/android/NitroCompressorOnLoad.cpp +60 -0
  74. package/nitrogen/generated/android/NitroCompressorOnLoad.hpp +34 -0
  75. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  76. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  77. package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
  78. package/nitrogen/generated/android/c++/JHybridCompressorSpec.cpp +293 -0
  79. package/nitrogen/generated/android/c++/JHybridCompressorSpec.hpp +78 -0
  80. package/nitrogen/generated/android/c++/JVideoThumbnailResult.hpp +73 -0
  81. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void.kt +80 -0
  82. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double.kt +80 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double_double.kt +80 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/HybridCompressorSpec.kt +141 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/NitroCompressorOnLoad.kt +35 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/VideoThumbnailResult.kt +71 -0
  87. package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.cpp +11 -0
  88. package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.hpp +204 -0
  89. package/nitrogen/generated/ios/react_native_compressor+autolinking.rb +62 -0
  90. package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.cpp +89 -0
  91. package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.hpp +337 -0
  92. package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Umbrella.hpp +51 -0
  93. package/nitrogen/generated/ios/react_native_compressorAutolinking.mm +33 -0
  94. package/nitrogen/generated/ios/react_native_compressorAutolinking.swift +26 -0
  95. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  96. package/nitrogen/generated/ios/swift/Func_void_VideoThumbnailResult.swift +46 -0
  97. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  98. package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
  99. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  100. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_AnyMap_.swift +46 -0
  101. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  102. package/nitrogen/generated/ios/swift/HybridCompressorSpec.swift +70 -0
  103. package/nitrogen/generated/ios/swift/HybridCompressorSpec_cxx.swift +493 -0
  104. package/nitrogen/generated/ios/swift/VideoThumbnailResult.swift +49 -0
  105. package/nitrogen/generated/shared/c++/HybridCompressorSpec.cpp +36 -0
  106. package/nitrogen/generated/shared/c++/HybridCompressorSpec.hpp +83 -0
  107. package/nitrogen/generated/shared/c++/VideoThumbnailResult.hpp +99 -0
  108. package/package.json +8 -12
  109. package/react-native-compressor.podspec +6 -24
  110. package/src/Audio/index.tsx +2 -2
  111. package/src/Image/index.tsx +3 -26
  112. package/src/Main.tsx +14 -16
  113. package/src/Video/index.tsx +25 -77
  114. package/src/specs/Compressor.nitro.ts +56 -0
  115. package/src/utils/Downloader.tsx +8 -27
  116. package/src/utils/Uploader.tsx +12 -24
  117. package/src/utils/helpers.ts +18 -0
  118. package/src/utils/index.tsx +3 -2
  119. package/android/src/main/java/com/reactnativecompressor/CompressorModule.kt +0 -180
  120. package/android/src/main/java/com/reactnativecompressor/CompressorPackage.kt +0 -34
  121. package/android/src/newarch/CompressorSpec.kt +0 -5
  122. package/android/src/oldarch/CompressorSpec.kt +0 -36
  123. package/ios/Compressor-Bridging-Header.h +0 -6
  124. package/ios/Compressor.h +0 -5
  125. package/ios/Compressor.mm +0 -82
  126. package/ios/CompressorManager.swift +0 -117
  127. package/lib/commonjs/Spec/NativeCompressor.js +0 -9
  128. package/lib/commonjs/Spec/NativeCompressor.js.map +0 -1
  129. package/lib/module/Spec/NativeCompressor.js +0 -5
  130. package/lib/module/Spec/NativeCompressor.js.map +0 -1
  131. package/lib/typescript/src/Spec/NativeCompressor.d.ts +0 -30
  132. package/lib/typescript/src/Spec/NativeCompressor.d.ts.map +0 -1
  133. package/src/Spec/NativeCompressor.ts +0 -41
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double.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
+ * Wraps a Swift `(_ progress: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double {
15
+ public typealias bridge = margelo.nitro.compressor.bridge.swift
16
+
17
+ private let closure: (_ progress: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ progress: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(progress: Double) -> Void {
25
+ self.closure(progress)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double {
44
+ return Unmanaged<Func_void_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double_double.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
+ * Wraps a Swift `(_ written: Double, _ total: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double_double {
15
+ public typealias bridge = margelo.nitro.compressor.bridge.swift
16
+
17
+ private let closure: (_ written: Double, _ total: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ written: Double, _ total: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(written: Double, total: Double) -> Void {
25
+ self.closure(written, total)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double_double {
44
+ return Unmanaged<Func_void_double_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.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
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.compressor.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__shared_ptr_AnyMap_.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
+ * Wraps a Swift `(_ value: AnyMap) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__shared_ptr_AnyMap_ {
15
+ public typealias bridge = margelo.nitro.compressor.bridge.swift
16
+
17
+ private let closure: (_ value: AnyMap) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: AnyMap) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: margelo.nitro.SharedAnyMap) -> Void {
25
+ self.closure(AnyMap(withCppPart: value))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__shared_ptr_AnyMap_`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_AnyMap_>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_AnyMap_ {
44
+ return Unmanaged<Func_void_std__shared_ptr_AnyMap_>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__string.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
+ * Wraps a Swift `(_ value: String) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__string {
15
+ public typealias bridge = margelo.nitro.compressor.bridge.swift
16
+
17
+ private let closure: (_ value: String) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: String) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: std.string) -> Void {
25
+ self.closure(String(value))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__string`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
44
+ return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,70 @@
1
+ ///
2
+ /// HybridCompressorSpec.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 ``HybridCompressorSpec``
11
+ public protocol HybridCompressorSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func image_compress(imagePath: String, optionMap: AnyMap, onDownloadProgress: ((_ progress: Double) -> Void)?) throws -> Promise<String>
17
+ func getImageMetaData(filePath: String) throws -> Promise<AnyMap>
18
+ func compress(fileUrl: String, optionMap: AnyMap, onProgress: ((_ progress: Double) -> Void)?, onDownloadProgress: ((_ progress: Double) -> Void)?) throws -> Promise<String>
19
+ func cancelCompression(uuid: String) throws -> Void
20
+ func getVideoMetaData(filePath: String) throws -> Promise<AnyMap>
21
+ func activateBackgroundTask(options: AnyMap, onExpired: (() -> Void)?) throws -> Promise<String>
22
+ func deactivateBackgroundTask(options: AnyMap) throws -> Promise<String>
23
+ func compress_audio(fileUrl: String, optionMap: AnyMap) throws -> Promise<String>
24
+ func upload(fileUrl: String, options: AnyMap, onProgress: ((_ written: Double, _ total: Double) -> Void)?) throws -> Promise<AnyMap>
25
+ func cancelUpload(uuid: String, shouldCancelAll: Bool) throws -> Void
26
+ func download(fileUrl: String, options: AnyMap, onProgress: ((_ progress: Double) -> Void)?) throws -> Promise<String>
27
+ func generateFilePath(fileExtension: String) throws -> Promise<String>
28
+ func getRealPath(path: String, type: String) throws -> Promise<String>
29
+ func getFileSize(filePath: String) throws -> Promise<String>
30
+ func createVideoThumbnail(fileUrl: String, options: AnyMap) throws -> Promise<VideoThumbnailResult>
31
+ func clearCache(cacheDir: String?) throws -> Promise<String>
32
+ }
33
+
34
+ public extension HybridCompressorSpec_protocol {
35
+ /// Default implementation of ``HybridObject.toString``
36
+ func toString() -> String {
37
+ return "[HybridObject Compressor]"
38
+ }
39
+ }
40
+
41
+ /// See ``HybridCompressorSpec``
42
+ open class HybridCompressorSpec_base {
43
+ private weak var cxxWrapper: HybridCompressorSpec_cxx? = nil
44
+ public init() { }
45
+ public func getCxxWrapper() -> HybridCompressorSpec_cxx {
46
+ #if DEBUG
47
+ guard self is any HybridCompressorSpec else {
48
+ fatalError("`self` is not a `HybridCompressorSpec`! Did you accidentally inherit from `HybridCompressorSpec_base` instead of `HybridCompressorSpec`?")
49
+ }
50
+ #endif
51
+ if let cxxWrapper = self.cxxWrapper {
52
+ return cxxWrapper
53
+ } else {
54
+ let cxxWrapper = HybridCompressorSpec_cxx(self as! any HybridCompressorSpec)
55
+ self.cxxWrapper = cxxWrapper
56
+ return cxxWrapper
57
+ }
58
+ }
59
+ }
60
+
61
+ /**
62
+ * A Swift base-protocol representing the Compressor HybridObject.
63
+ * Implement this protocol to create Swift-based instances of Compressor.
64
+ * ```swift
65
+ * class HybridCompressor : HybridCompressorSpec {
66
+ * // ...
67
+ * }
68
+ * ```
69
+ */
70
+ public typealias HybridCompressorSpec = HybridCompressorSpec_protocol & HybridCompressorSpec_base