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.
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +56 -58
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +8 -0
- package/android/src/main/java/com/margelo/nitro/compressor/HybridCompressor.kt +213 -0
- package/android/src/main/java/com/reactnativecompressor/NitroCompressorPackage.kt +30 -0
- package/android/src/main/java/com/reactnativecompressor/NitroPromiseAdapter.kt +55 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/EventEmitterHandler.kt +49 -45
- package/android/src/main/java/com/reactnativecompressor/Utils/Utils.kt +1 -1
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/compressor/Compressor.kt +13 -22
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt +72 -0
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.kt +4 -1
- package/ios/Audio/FormatConverter/FormatConverter+Compressed.swift +1 -1
- package/ios/Audio/FormatConverter/FormatConverter+Utilities.swift +1 -1
- package/ios/Audio/FormatConverter/FormatConverter.swift +5 -3
- package/ios/HybridCompressor.swift +247 -0
- package/ios/Image/ImageCompressor.swift +8 -2
- package/ios/Utils/EventEmitterHandler.swift +56 -34
- package/ios/Video/NextLevelSessionExporter.swift +43 -8
- package/ios/Video/VideoMain.swift +17 -3
- package/lib/commonjs/Audio/index.js +1 -1
- package/lib/commonjs/Audio/index.js.map +1 -1
- package/lib/commonjs/Image/index.js +2 -22
- package/lib/commonjs/Image/index.js.map +1 -1
- package/lib/commonjs/Main.js +8 -8
- package/lib/commonjs/Main.js.map +1 -1
- package/lib/commonjs/Video/index.js +25 -65
- package/lib/commonjs/Video/index.js.map +1 -1
- package/lib/commonjs/specs/Compressor.nitro.js +6 -0
- package/lib/commonjs/specs/Compressor.nitro.js.map +1 -0
- package/lib/commonjs/utils/Downloader.js +8 -24
- package/lib/commonjs/utils/Downloader.js.map +1 -1
- package/lib/commonjs/utils/Uploader.js +3 -18
- package/lib/commonjs/utils/Uploader.js.map +1 -1
- package/lib/commonjs/utils/helpers.js +18 -1
- package/lib/commonjs/utils/helpers.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -13
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/Audio/index.js +2 -2
- package/lib/module/Audio/index.js.map +1 -1
- package/lib/module/Image/index.js +3 -23
- package/lib/module/Image/index.js.map +1 -1
- package/lib/module/Main.js +9 -9
- package/lib/module/Main.js.map +1 -1
- package/lib/module/Video/index.js +26 -66
- package/lib/module/Video/index.js.map +1 -1
- package/lib/module/specs/Compressor.nitro.js +4 -0
- package/lib/module/specs/Compressor.nitro.js.map +1 -0
- package/lib/module/utils/Downloader.js +10 -26
- package/lib/module/utils/Downloader.js.map +1 -1
- package/lib/module/utils/Uploader.js +5 -20
- package/lib/module/utils/Uploader.js.map +1 -1
- package/lib/module/utils/helpers.js +16 -0
- package/lib/module/utils/helpers.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/Image/index.d.ts.map +1 -1
- package/lib/typescript/src/Main.d.ts +2 -1
- package/lib/typescript/src/Main.d.ts.map +1 -1
- package/lib/typescript/src/Video/index.d.ts +1 -1
- package/lib/typescript/src/Video/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Compressor.nitro.d.ts +44 -0
- package/lib/typescript/src/specs/Compressor.nitro.d.ts.map +1 -0
- package/lib/typescript/src/utils/Downloader.d.ts.map +1 -1
- package/lib/typescript/src/utils/Uploader.d.ts.map +1 -1
- package/lib/typescript/src/utils/helpers.d.ts +7 -0
- package/lib/typescript/src/utils/helpers.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroCompressor+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroCompressor+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroCompressorOnLoad.cpp +60 -0
- package/nitrogen/generated/android/NitroCompressorOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridCompressorSpec.cpp +293 -0
- package/nitrogen/generated/android/c++/JHybridCompressorSpec.hpp +78 -0
- package/nitrogen/generated/android/c++/JVideoThumbnailResult.hpp +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/HybridCompressorSpec.kt +141 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/NitroCompressorOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/VideoThumbnailResult.kt +71 -0
- package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.hpp +204 -0
- package/nitrogen/generated/ios/react_native_compressor+autolinking.rb +62 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.cpp +89 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.hpp +337 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Umbrella.hpp +51 -0
- package/nitrogen/generated/ios/react_native_compressorAutolinking.mm +33 -0
- package/nitrogen/generated/ios/react_native_compressorAutolinking.swift +26 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_VideoThumbnailResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_AnyMap_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCompressorSpec.swift +70 -0
- package/nitrogen/generated/ios/swift/HybridCompressorSpec_cxx.swift +493 -0
- package/nitrogen/generated/ios/swift/VideoThumbnailResult.swift +49 -0
- package/nitrogen/generated/shared/c++/HybridCompressorSpec.cpp +36 -0
- package/nitrogen/generated/shared/c++/HybridCompressorSpec.hpp +83 -0
- package/nitrogen/generated/shared/c++/VideoThumbnailResult.hpp +99 -0
- package/package.json +8 -12
- package/react-native-compressor.podspec +6 -24
- package/src/Audio/index.tsx +2 -2
- package/src/Image/index.tsx +3 -26
- package/src/Main.tsx +14 -16
- package/src/Video/index.tsx +25 -77
- package/src/specs/Compressor.nitro.ts +56 -0
- package/src/utils/Downloader.tsx +8 -27
- package/src/utils/Uploader.tsx +12 -24
- package/src/utils/helpers.ts +18 -0
- package/src/utils/index.tsx +3 -2
- package/android/src/main/java/com/reactnativecompressor/CompressorModule.kt +0 -180
- package/android/src/main/java/com/reactnativecompressor/CompressorPackage.kt +0 -34
- package/android/src/newarch/CompressorSpec.kt +0 -5
- package/android/src/oldarch/CompressorSpec.kt +0 -36
- package/ios/Compressor-Bridging-Header.h +0 -6
- package/ios/Compressor.h +0 -5
- package/ios/Compressor.mm +0 -82
- package/ios/CompressorManager.swift +0 -117
- package/lib/commonjs/Spec/NativeCompressor.js +0 -9
- package/lib/commonjs/Spec/NativeCompressor.js.map +0 -1
- package/lib/module/Spec/NativeCompressor.js +0 -5
- package/lib/module/Spec/NativeCompressor.js.map +0 -1
- package/lib/typescript/src/Spec/NativeCompressor.d.ts +0 -30
- package/lib/typescript/src/Spec/NativeCompressor.d.ts.map +0 -1
- package/src/Spec/NativeCompressor.ts +0 -41
package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double_double.kt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_double_double.kt
|
|
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
|
+
package com.margelo.nitro.compressor
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(written: number, total: number) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_double_double: (Double, Double) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(written: Double, total: Double): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(written: number, total: number) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_double_double_cxx: Func_void_double_double {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(written: Double, total: Double): Unit
|
|
60
|
+
= invoke_cxx(written,total)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(written: Double, total: Double): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(written: number, total: number) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(Double, Double) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_double_double_java(private val function: (Double, Double) -> Unit): Func_void_double_double {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(written: Double, total: Double): Unit {
|
|
78
|
+
return this.function(written, total)
|
|
79
|
+
}
|
|
80
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/HybridCompressorSpec.kt
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCompressorSpec.kt
|
|
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
|
+
package com.margelo.nitro.compressor
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.Promise
|
|
14
|
+
import com.margelo.nitro.core.AnyMap
|
|
15
|
+
import com.margelo.nitro.core.HybridObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the Compressor HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of Compressor.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridCompressorSpec: HybridObject() {
|
|
29
|
+
// Properties
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Methods
|
|
33
|
+
abstract fun image_compress(imagePath: String, optionMap: AnyMap, onDownloadProgress: ((progress: Double) -> Unit)?): Promise<String>
|
|
34
|
+
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
37
|
+
private fun image_compress_cxx(imagePath: String, optionMap: AnyMap, onDownloadProgress: Func_void_double?): Promise<String> {
|
|
38
|
+
val __result = image_compress(imagePath, optionMap, onDownloadProgress?.let { it })
|
|
39
|
+
return __result
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
abstract fun getImageMetaData(filePath: String): Promise<AnyMap>
|
|
45
|
+
|
|
46
|
+
abstract fun compress(fileUrl: String, optionMap: AnyMap, onProgress: ((progress: Double) -> Unit)?, onDownloadProgress: ((progress: Double) -> Unit)?): Promise<String>
|
|
47
|
+
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
private fun compress_cxx(fileUrl: String, optionMap: AnyMap, onProgress: Func_void_double?, onDownloadProgress: Func_void_double?): Promise<String> {
|
|
51
|
+
val __result = compress(fileUrl, optionMap, onProgress?.let { it }, onDownloadProgress?.let { it })
|
|
52
|
+
return __result
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@DoNotStrip
|
|
56
|
+
@Keep
|
|
57
|
+
abstract fun cancelCompression(uuid: String): Unit
|
|
58
|
+
|
|
59
|
+
@DoNotStrip
|
|
60
|
+
@Keep
|
|
61
|
+
abstract fun getVideoMetaData(filePath: String): Promise<AnyMap>
|
|
62
|
+
|
|
63
|
+
abstract fun activateBackgroundTask(options: AnyMap, onExpired: (() -> Unit)?): Promise<String>
|
|
64
|
+
|
|
65
|
+
@DoNotStrip
|
|
66
|
+
@Keep
|
|
67
|
+
private fun activateBackgroundTask_cxx(options: AnyMap, onExpired: Func_void?): Promise<String> {
|
|
68
|
+
val __result = activateBackgroundTask(options, onExpired?.let { it })
|
|
69
|
+
return __result
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@DoNotStrip
|
|
73
|
+
@Keep
|
|
74
|
+
abstract fun deactivateBackgroundTask(options: AnyMap): Promise<String>
|
|
75
|
+
|
|
76
|
+
@DoNotStrip
|
|
77
|
+
@Keep
|
|
78
|
+
abstract fun compress_audio(fileUrl: String, optionMap: AnyMap): Promise<String>
|
|
79
|
+
|
|
80
|
+
abstract fun upload(fileUrl: String, options: AnyMap, onProgress: ((written: Double, total: Double) -> Unit)?): Promise<AnyMap>
|
|
81
|
+
|
|
82
|
+
@DoNotStrip
|
|
83
|
+
@Keep
|
|
84
|
+
private fun upload_cxx(fileUrl: String, options: AnyMap, onProgress: Func_void_double_double?): Promise<AnyMap> {
|
|
85
|
+
val __result = upload(fileUrl, options, onProgress?.let { it })
|
|
86
|
+
return __result
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@DoNotStrip
|
|
90
|
+
@Keep
|
|
91
|
+
abstract fun cancelUpload(uuid: String, shouldCancelAll: Boolean): Unit
|
|
92
|
+
|
|
93
|
+
abstract fun download(fileUrl: String, options: AnyMap, onProgress: ((progress: Double) -> Unit)?): Promise<String>
|
|
94
|
+
|
|
95
|
+
@DoNotStrip
|
|
96
|
+
@Keep
|
|
97
|
+
private fun download_cxx(fileUrl: String, options: AnyMap, onProgress: Func_void_double?): Promise<String> {
|
|
98
|
+
val __result = download(fileUrl, options, onProgress?.let { it })
|
|
99
|
+
return __result
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@DoNotStrip
|
|
103
|
+
@Keep
|
|
104
|
+
abstract fun generateFilePath(fileExtension: String): Promise<String>
|
|
105
|
+
|
|
106
|
+
@DoNotStrip
|
|
107
|
+
@Keep
|
|
108
|
+
abstract fun getRealPath(path: String, type: String): Promise<String>
|
|
109
|
+
|
|
110
|
+
@DoNotStrip
|
|
111
|
+
@Keep
|
|
112
|
+
abstract fun getFileSize(filePath: String): Promise<String>
|
|
113
|
+
|
|
114
|
+
@DoNotStrip
|
|
115
|
+
@Keep
|
|
116
|
+
abstract fun createVideoThumbnail(fileUrl: String, options: AnyMap): Promise<VideoThumbnailResult>
|
|
117
|
+
|
|
118
|
+
@DoNotStrip
|
|
119
|
+
@Keep
|
|
120
|
+
abstract fun clearCache(cacheDir: String?): Promise<String>
|
|
121
|
+
|
|
122
|
+
// Default implementation of `HybridObject.toString()`
|
|
123
|
+
override fun toString(): String {
|
|
124
|
+
return "[HybridObject Compressor]"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// C++ backing class
|
|
128
|
+
@DoNotStrip
|
|
129
|
+
@Keep
|
|
130
|
+
protected open class CxxPart(javaPart: HybridCompressorSpec): HybridObject.CxxPart(javaPart) {
|
|
131
|
+
// C++ JHybridCompressorSpec::CxxPart::initHybrid(...)
|
|
132
|
+
external override fun initHybrid(): HybridData
|
|
133
|
+
}
|
|
134
|
+
override fun createCxxPart(): CxxPart {
|
|
135
|
+
return CxxPart(this)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
companion object {
|
|
139
|
+
protected const val TAG = "HybridCompressorSpec"
|
|
140
|
+
}
|
|
141
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/NitroCompressorOnLoad.kt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroCompressorOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.compressor
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroCompressorOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroCompressorOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroCompressor".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroCompressor C++ library...")
|
|
25
|
+
System.loadLibrary("NitroCompressor")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroCompressor C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroCompressor C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/VideoThumbnailResult.kt
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VideoThumbnailResult.kt
|
|
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
|
+
package com.margelo.nitro.compressor
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "VideoThumbnailResult".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class VideoThumbnailResult(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val path: String,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val size: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val mime: String,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val width: Double,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val height: Double
|
|
36
|
+
) {
|
|
37
|
+
/* primary constructor */
|
|
38
|
+
|
|
39
|
+
override fun equals(other: Any?): Boolean {
|
|
40
|
+
if (this === other) return true
|
|
41
|
+
if (other !is VideoThumbnailResult) return false
|
|
42
|
+
return Objects.deepEquals(this.path, other.path)
|
|
43
|
+
&& Objects.deepEquals(this.size, other.size)
|
|
44
|
+
&& Objects.deepEquals(this.mime, other.mime)
|
|
45
|
+
&& Objects.deepEquals(this.width, other.width)
|
|
46
|
+
&& Objects.deepEquals(this.height, other.height)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun hashCode(): Int {
|
|
50
|
+
return arrayOf<Any?>(
|
|
51
|
+
path,
|
|
52
|
+
size,
|
|
53
|
+
mime,
|
|
54
|
+
width,
|
|
55
|
+
height
|
|
56
|
+
).contentDeepHashCode()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
companion object {
|
|
60
|
+
/**
|
|
61
|
+
* Constructor called from C++
|
|
62
|
+
*/
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
@Keep
|
|
65
|
+
@Suppress("unused")
|
|
66
|
+
@JvmStatic
|
|
67
|
+
private fun fromCpp(path: String, size: Double, mime: String, width: Double, height: Double): VideoThumbnailResult {
|
|
68
|
+
return VideoThumbnailResult(path, size, mime, width, height)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCompressorSpecSwift.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 "HybridCompressorSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::compressor {
|
|
11
|
+
} // namespace margelo::nitro::compressor
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCompressorSpecSwift.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
|
+
#include "HybridCompressorSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridCompressorSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace react_native_compressor { class HybridCompressorSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `VideoThumbnailResult` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::compressor { struct VideoThumbnailResult; }
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <NitroModules/Promise.hpp>
|
|
20
|
+
#include <NitroModules/AnyMap.hpp>
|
|
21
|
+
#include <functional>
|
|
22
|
+
#include <optional>
|
|
23
|
+
#include "VideoThumbnailResult.hpp"
|
|
24
|
+
|
|
25
|
+
#include "react_native_compressor-Swift-Cxx-Umbrella.hpp"
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::compressor {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The C++ part of HybridCompressorSpec_cxx.swift.
|
|
31
|
+
*
|
|
32
|
+
* HybridCompressorSpecSwift (C++) accesses HybridCompressorSpec_cxx (Swift), and might
|
|
33
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
34
|
+
*
|
|
35
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
36
|
+
* the future, HybridCompressorSpec_cxx can directly inherit from the C++ class HybridCompressorSpec
|
|
37
|
+
* to simplify the whole structure and memory management.
|
|
38
|
+
*/
|
|
39
|
+
class HybridCompressorSpecSwift: public virtual HybridCompressorSpec {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor from a Swift instance
|
|
42
|
+
explicit HybridCompressorSpecSwift(const react_native_compressor::HybridCompressorSpec_cxx& swiftPart):
|
|
43
|
+
HybridObject(HybridCompressorSpec::TAG),
|
|
44
|
+
_swiftPart(swiftPart) { }
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Get the Swift part
|
|
48
|
+
inline react_native_compressor::HybridCompressorSpec_cxx& getSwiftPart() noexcept {
|
|
49
|
+
return _swiftPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
54
|
+
return _swiftPart.getMemorySize();
|
|
55
|
+
}
|
|
56
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
57
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridCompressorSpecSwift>(other)) {
|
|
58
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
void dispose() noexcept override {
|
|
63
|
+
_swiftPart.dispose();
|
|
64
|
+
}
|
|
65
|
+
std::string toString() override {
|
|
66
|
+
return _swiftPart.toString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Properties
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
public:
|
|
74
|
+
// Methods
|
|
75
|
+
inline std::shared_ptr<Promise<std::string>> image_compress(const std::string& imagePath, const std::shared_ptr<AnyMap>& optionMap, const std::optional<std::function<void(double /* progress */)>>& onDownloadProgress) override {
|
|
76
|
+
auto __result = _swiftPart.image_compress(imagePath, optionMap, onDownloadProgress);
|
|
77
|
+
if (__result.hasError()) [[unlikely]] {
|
|
78
|
+
std::rethrow_exception(__result.error());
|
|
79
|
+
}
|
|
80
|
+
auto __value = std::move(__result.value());
|
|
81
|
+
return __value;
|
|
82
|
+
}
|
|
83
|
+
inline std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> getImageMetaData(const std::string& filePath) override {
|
|
84
|
+
auto __result = _swiftPart.getImageMetaData(filePath);
|
|
85
|
+
if (__result.hasError()) [[unlikely]] {
|
|
86
|
+
std::rethrow_exception(__result.error());
|
|
87
|
+
}
|
|
88
|
+
auto __value = std::move(__result.value());
|
|
89
|
+
return __value;
|
|
90
|
+
}
|
|
91
|
+
inline std::shared_ptr<Promise<std::string>> compress(const std::string& fileUrl, const std::shared_ptr<AnyMap>& optionMap, const std::optional<std::function<void(double /* progress */)>>& onProgress, const std::optional<std::function<void(double /* progress */)>>& onDownloadProgress) override {
|
|
92
|
+
auto __result = _swiftPart.compress(fileUrl, optionMap, onProgress, onDownloadProgress);
|
|
93
|
+
if (__result.hasError()) [[unlikely]] {
|
|
94
|
+
std::rethrow_exception(__result.error());
|
|
95
|
+
}
|
|
96
|
+
auto __value = std::move(__result.value());
|
|
97
|
+
return __value;
|
|
98
|
+
}
|
|
99
|
+
inline void cancelCompression(const std::string& uuid) override {
|
|
100
|
+
auto __result = _swiftPart.cancelCompression(uuid);
|
|
101
|
+
if (__result.hasError()) [[unlikely]] {
|
|
102
|
+
std::rethrow_exception(__result.error());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
inline std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> getVideoMetaData(const std::string& filePath) override {
|
|
106
|
+
auto __result = _swiftPart.getVideoMetaData(filePath);
|
|
107
|
+
if (__result.hasError()) [[unlikely]] {
|
|
108
|
+
std::rethrow_exception(__result.error());
|
|
109
|
+
}
|
|
110
|
+
auto __value = std::move(__result.value());
|
|
111
|
+
return __value;
|
|
112
|
+
}
|
|
113
|
+
inline std::shared_ptr<Promise<std::string>> activateBackgroundTask(const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void()>>& onExpired) override {
|
|
114
|
+
auto __result = _swiftPart.activateBackgroundTask(options, onExpired);
|
|
115
|
+
if (__result.hasError()) [[unlikely]] {
|
|
116
|
+
std::rethrow_exception(__result.error());
|
|
117
|
+
}
|
|
118
|
+
auto __value = std::move(__result.value());
|
|
119
|
+
return __value;
|
|
120
|
+
}
|
|
121
|
+
inline std::shared_ptr<Promise<std::string>> deactivateBackgroundTask(const std::shared_ptr<AnyMap>& options) override {
|
|
122
|
+
auto __result = _swiftPart.deactivateBackgroundTask(options);
|
|
123
|
+
if (__result.hasError()) [[unlikely]] {
|
|
124
|
+
std::rethrow_exception(__result.error());
|
|
125
|
+
}
|
|
126
|
+
auto __value = std::move(__result.value());
|
|
127
|
+
return __value;
|
|
128
|
+
}
|
|
129
|
+
inline std::shared_ptr<Promise<std::string>> compress_audio(const std::string& fileUrl, const std::shared_ptr<AnyMap>& optionMap) override {
|
|
130
|
+
auto __result = _swiftPart.compress_audio(fileUrl, optionMap);
|
|
131
|
+
if (__result.hasError()) [[unlikely]] {
|
|
132
|
+
std::rethrow_exception(__result.error());
|
|
133
|
+
}
|
|
134
|
+
auto __value = std::move(__result.value());
|
|
135
|
+
return __value;
|
|
136
|
+
}
|
|
137
|
+
inline std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> upload(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void(double /* written */, double /* total */)>>& onProgress) override {
|
|
138
|
+
auto __result = _swiftPart.upload(fileUrl, options, onProgress);
|
|
139
|
+
if (__result.hasError()) [[unlikely]] {
|
|
140
|
+
std::rethrow_exception(__result.error());
|
|
141
|
+
}
|
|
142
|
+
auto __value = std::move(__result.value());
|
|
143
|
+
return __value;
|
|
144
|
+
}
|
|
145
|
+
inline void cancelUpload(const std::string& uuid, bool shouldCancelAll) override {
|
|
146
|
+
auto __result = _swiftPart.cancelUpload(uuid, std::forward<decltype(shouldCancelAll)>(shouldCancelAll));
|
|
147
|
+
if (__result.hasError()) [[unlikely]] {
|
|
148
|
+
std::rethrow_exception(__result.error());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
inline std::shared_ptr<Promise<std::string>> download(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void(double /* progress */)>>& onProgress) override {
|
|
152
|
+
auto __result = _swiftPart.download(fileUrl, options, onProgress);
|
|
153
|
+
if (__result.hasError()) [[unlikely]] {
|
|
154
|
+
std::rethrow_exception(__result.error());
|
|
155
|
+
}
|
|
156
|
+
auto __value = std::move(__result.value());
|
|
157
|
+
return __value;
|
|
158
|
+
}
|
|
159
|
+
inline std::shared_ptr<Promise<std::string>> generateFilePath(const std::string& fileExtension) override {
|
|
160
|
+
auto __result = _swiftPart.generateFilePath(fileExtension);
|
|
161
|
+
if (__result.hasError()) [[unlikely]] {
|
|
162
|
+
std::rethrow_exception(__result.error());
|
|
163
|
+
}
|
|
164
|
+
auto __value = std::move(__result.value());
|
|
165
|
+
return __value;
|
|
166
|
+
}
|
|
167
|
+
inline std::shared_ptr<Promise<std::string>> getRealPath(const std::string& path, const std::string& type) override {
|
|
168
|
+
auto __result = _swiftPart.getRealPath(path, type);
|
|
169
|
+
if (__result.hasError()) [[unlikely]] {
|
|
170
|
+
std::rethrow_exception(__result.error());
|
|
171
|
+
}
|
|
172
|
+
auto __value = std::move(__result.value());
|
|
173
|
+
return __value;
|
|
174
|
+
}
|
|
175
|
+
inline std::shared_ptr<Promise<std::string>> getFileSize(const std::string& filePath) override {
|
|
176
|
+
auto __result = _swiftPart.getFileSize(filePath);
|
|
177
|
+
if (__result.hasError()) [[unlikely]] {
|
|
178
|
+
std::rethrow_exception(__result.error());
|
|
179
|
+
}
|
|
180
|
+
auto __value = std::move(__result.value());
|
|
181
|
+
return __value;
|
|
182
|
+
}
|
|
183
|
+
inline std::shared_ptr<Promise<VideoThumbnailResult>> createVideoThumbnail(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options) override {
|
|
184
|
+
auto __result = _swiftPart.createVideoThumbnail(fileUrl, options);
|
|
185
|
+
if (__result.hasError()) [[unlikely]] {
|
|
186
|
+
std::rethrow_exception(__result.error());
|
|
187
|
+
}
|
|
188
|
+
auto __value = std::move(__result.value());
|
|
189
|
+
return __value;
|
|
190
|
+
}
|
|
191
|
+
inline std::shared_ptr<Promise<std::string>> clearCache(const std::optional<std::string>& cacheDir) override {
|
|
192
|
+
auto __result = _swiftPart.clearCache(cacheDir);
|
|
193
|
+
if (__result.hasError()) [[unlikely]] {
|
|
194
|
+
std::rethrow_exception(__result.error());
|
|
195
|
+
}
|
|
196
|
+
auto __value = std::move(__result.value());
|
|
197
|
+
return __value;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
react_native_compressor::HybridCompressorSpec_cxx _swiftPart;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
} // namespace margelo::nitro::compressor
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# react_native_compressor+autolinking.rb
|
|
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
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/react_native_compressor+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 react_native_compressor is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
61
|
+
})
|
|
62
|
+
end
|