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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridCompressorSpec.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 "JHybridCompressorSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `VideoThumbnailResult` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::compressor { struct VideoThumbnailResult; }
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <NitroModules/Promise.hpp>
|
|
15
|
+
#include <NitroModules/JPromise.hpp>
|
|
16
|
+
#include <NitroModules/AnyMap.hpp>
|
|
17
|
+
#include <NitroModules/JAnyMap.hpp>
|
|
18
|
+
#include "VideoThumbnailResult.hpp"
|
|
19
|
+
#include "JVideoThumbnailResult.hpp"
|
|
20
|
+
#include <functional>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include "JFunc_void_double.hpp"
|
|
23
|
+
#include <NitroModules/JNICallable.hpp>
|
|
24
|
+
#include "JFunc_void.hpp"
|
|
25
|
+
#include "JFunc_void_double_double.hpp"
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::compressor {
|
|
28
|
+
|
|
29
|
+
std::shared_ptr<JHybridCompressorSpec> JHybridCompressorSpec::JavaPart::getJHybridCompressorSpec() {
|
|
30
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
31
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridCompressorSpec>(hybridObject);
|
|
32
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
33
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridCompressorSpec!");
|
|
34
|
+
}
|
|
35
|
+
return castHybridObject;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
jni::local_ref<JHybridCompressorSpec::CxxPart::jhybriddata> JHybridCompressorSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
39
|
+
return makeCxxInstance(jThis);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
std::shared_ptr<JHybridObject> JHybridCompressorSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
43
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridCompressorSpec::JavaPart>(javaPart);
|
|
44
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
45
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridCompressorSpec::JavaPart!");
|
|
46
|
+
}
|
|
47
|
+
return std::make_shared<JHybridCompressorSpec>(castJavaPart);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void JHybridCompressorSpec::CxxPart::registerNatives() {
|
|
51
|
+
registerHybrid({
|
|
52
|
+
makeNativeMethod("initHybrid", JHybridCompressorSpec::CxxPart::initHybrid),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Properties
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// Methods
|
|
60
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::image_compress(const std::string& imagePath, const std::shared_ptr<AnyMap>& optionMap, const std::optional<std::function<void(double /* progress */)>>& onDownloadProgress) {
|
|
61
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* imagePath */, jni::alias_ref<JAnyMap::javaobject> /* optionMap */, jni::alias_ref<JFunc_void_double::javaobject> /* onDownloadProgress */)>("image_compress_cxx");
|
|
62
|
+
auto __result = method(_javaPart, jni::make_jstring(imagePath), JAnyMap::create(optionMap), onDownloadProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onDownloadProgress.value()) : nullptr);
|
|
63
|
+
return [&]() {
|
|
64
|
+
auto __promise = Promise<std::string>::create();
|
|
65
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
66
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
67
|
+
__promise->resolve(__result->toStdString());
|
|
68
|
+
});
|
|
69
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
70
|
+
jni::JniException __jniError(__throwable);
|
|
71
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
72
|
+
});
|
|
73
|
+
return __promise;
|
|
74
|
+
}();
|
|
75
|
+
}
|
|
76
|
+
std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> JHybridCompressorSpec::getImageMetaData(const std::string& filePath) {
|
|
77
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* filePath */)>("getImageMetaData");
|
|
78
|
+
auto __result = method(_javaPart, jni::make_jstring(filePath));
|
|
79
|
+
return [&]() {
|
|
80
|
+
auto __promise = Promise<std::shared_ptr<AnyMap>>::create();
|
|
81
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
82
|
+
auto __result = jni::static_ref_cast<JAnyMap::javaobject>(__boxedResult);
|
|
83
|
+
__promise->resolve(__result->cthis()->getMap());
|
|
84
|
+
});
|
|
85
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
86
|
+
jni::JniException __jniError(__throwable);
|
|
87
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
88
|
+
});
|
|
89
|
+
return __promise;
|
|
90
|
+
}();
|
|
91
|
+
}
|
|
92
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::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) {
|
|
93
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileUrl */, jni::alias_ref<JAnyMap::javaobject> /* optionMap */, jni::alias_ref<JFunc_void_double::javaobject> /* onProgress */, jni::alias_ref<JFunc_void_double::javaobject> /* onDownloadProgress */)>("compress_cxx");
|
|
94
|
+
auto __result = method(_javaPart, jni::make_jstring(fileUrl), JAnyMap::create(optionMap), onProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onProgress.value()) : nullptr, onDownloadProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onDownloadProgress.value()) : nullptr);
|
|
95
|
+
return [&]() {
|
|
96
|
+
auto __promise = Promise<std::string>::create();
|
|
97
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
98
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
99
|
+
__promise->resolve(__result->toStdString());
|
|
100
|
+
});
|
|
101
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
102
|
+
jni::JniException __jniError(__throwable);
|
|
103
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
104
|
+
});
|
|
105
|
+
return __promise;
|
|
106
|
+
}();
|
|
107
|
+
}
|
|
108
|
+
void JHybridCompressorSpec::cancelCompression(const std::string& uuid) {
|
|
109
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* uuid */)>("cancelCompression");
|
|
110
|
+
method(_javaPart, jni::make_jstring(uuid));
|
|
111
|
+
}
|
|
112
|
+
std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> JHybridCompressorSpec::getVideoMetaData(const std::string& filePath) {
|
|
113
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* filePath */)>("getVideoMetaData");
|
|
114
|
+
auto __result = method(_javaPart, jni::make_jstring(filePath));
|
|
115
|
+
return [&]() {
|
|
116
|
+
auto __promise = Promise<std::shared_ptr<AnyMap>>::create();
|
|
117
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
118
|
+
auto __result = jni::static_ref_cast<JAnyMap::javaobject>(__boxedResult);
|
|
119
|
+
__promise->resolve(__result->cthis()->getMap());
|
|
120
|
+
});
|
|
121
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
122
|
+
jni::JniException __jniError(__throwable);
|
|
123
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
124
|
+
});
|
|
125
|
+
return __promise;
|
|
126
|
+
}();
|
|
127
|
+
}
|
|
128
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::activateBackgroundTask(const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void()>>& onExpired) {
|
|
129
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JAnyMap::javaobject> /* options */, jni::alias_ref<JFunc_void::javaobject> /* onExpired */)>("activateBackgroundTask_cxx");
|
|
130
|
+
auto __result = method(_javaPart, JAnyMap::create(options), onExpired.has_value() ? JFunc_void_cxx::fromCpp(onExpired.value()) : nullptr);
|
|
131
|
+
return [&]() {
|
|
132
|
+
auto __promise = Promise<std::string>::create();
|
|
133
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
134
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
135
|
+
__promise->resolve(__result->toStdString());
|
|
136
|
+
});
|
|
137
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
138
|
+
jni::JniException __jniError(__throwable);
|
|
139
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
140
|
+
});
|
|
141
|
+
return __promise;
|
|
142
|
+
}();
|
|
143
|
+
}
|
|
144
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::deactivateBackgroundTask(const std::shared_ptr<AnyMap>& options) {
|
|
145
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JAnyMap::javaobject> /* options */)>("deactivateBackgroundTask");
|
|
146
|
+
auto __result = method(_javaPart, JAnyMap::create(options));
|
|
147
|
+
return [&]() {
|
|
148
|
+
auto __promise = Promise<std::string>::create();
|
|
149
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
150
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
151
|
+
__promise->resolve(__result->toStdString());
|
|
152
|
+
});
|
|
153
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
154
|
+
jni::JniException __jniError(__throwable);
|
|
155
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
156
|
+
});
|
|
157
|
+
return __promise;
|
|
158
|
+
}();
|
|
159
|
+
}
|
|
160
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::compress_audio(const std::string& fileUrl, const std::shared_ptr<AnyMap>& optionMap) {
|
|
161
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileUrl */, jni::alias_ref<JAnyMap::javaobject> /* optionMap */)>("compress_audio");
|
|
162
|
+
auto __result = method(_javaPart, jni::make_jstring(fileUrl), JAnyMap::create(optionMap));
|
|
163
|
+
return [&]() {
|
|
164
|
+
auto __promise = Promise<std::string>::create();
|
|
165
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
166
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
167
|
+
__promise->resolve(__result->toStdString());
|
|
168
|
+
});
|
|
169
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
170
|
+
jni::JniException __jniError(__throwable);
|
|
171
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
172
|
+
});
|
|
173
|
+
return __promise;
|
|
174
|
+
}();
|
|
175
|
+
}
|
|
176
|
+
std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> JHybridCompressorSpec::upload(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void(double /* written */, double /* total */)>>& onProgress) {
|
|
177
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileUrl */, jni::alias_ref<JAnyMap::javaobject> /* options */, jni::alias_ref<JFunc_void_double_double::javaobject> /* onProgress */)>("upload_cxx");
|
|
178
|
+
auto __result = method(_javaPart, jni::make_jstring(fileUrl), JAnyMap::create(options), onProgress.has_value() ? JFunc_void_double_double_cxx::fromCpp(onProgress.value()) : nullptr);
|
|
179
|
+
return [&]() {
|
|
180
|
+
auto __promise = Promise<std::shared_ptr<AnyMap>>::create();
|
|
181
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
182
|
+
auto __result = jni::static_ref_cast<JAnyMap::javaobject>(__boxedResult);
|
|
183
|
+
__promise->resolve(__result->cthis()->getMap());
|
|
184
|
+
});
|
|
185
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
186
|
+
jni::JniException __jniError(__throwable);
|
|
187
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
188
|
+
});
|
|
189
|
+
return __promise;
|
|
190
|
+
}();
|
|
191
|
+
}
|
|
192
|
+
void JHybridCompressorSpec::cancelUpload(const std::string& uuid, bool shouldCancelAll) {
|
|
193
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* uuid */, jboolean /* shouldCancelAll */)>("cancelUpload");
|
|
194
|
+
method(_javaPart, jni::make_jstring(uuid), shouldCancelAll);
|
|
195
|
+
}
|
|
196
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::download(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void(double /* progress */)>>& onProgress) {
|
|
197
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileUrl */, jni::alias_ref<JAnyMap::javaobject> /* options */, jni::alias_ref<JFunc_void_double::javaobject> /* onProgress */)>("download_cxx");
|
|
198
|
+
auto __result = method(_javaPart, jni::make_jstring(fileUrl), JAnyMap::create(options), onProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onProgress.value()) : nullptr);
|
|
199
|
+
return [&]() {
|
|
200
|
+
auto __promise = Promise<std::string>::create();
|
|
201
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
202
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
203
|
+
__promise->resolve(__result->toStdString());
|
|
204
|
+
});
|
|
205
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
206
|
+
jni::JniException __jniError(__throwable);
|
|
207
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
208
|
+
});
|
|
209
|
+
return __promise;
|
|
210
|
+
}();
|
|
211
|
+
}
|
|
212
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::generateFilePath(const std::string& fileExtension) {
|
|
213
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileExtension */)>("generateFilePath");
|
|
214
|
+
auto __result = method(_javaPart, jni::make_jstring(fileExtension));
|
|
215
|
+
return [&]() {
|
|
216
|
+
auto __promise = Promise<std::string>::create();
|
|
217
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
218
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
219
|
+
__promise->resolve(__result->toStdString());
|
|
220
|
+
});
|
|
221
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
222
|
+
jni::JniException __jniError(__throwable);
|
|
223
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
224
|
+
});
|
|
225
|
+
return __promise;
|
|
226
|
+
}();
|
|
227
|
+
}
|
|
228
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::getRealPath(const std::string& path, const std::string& type) {
|
|
229
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* path */, jni::alias_ref<jni::JString> /* type */)>("getRealPath");
|
|
230
|
+
auto __result = method(_javaPart, jni::make_jstring(path), jni::make_jstring(type));
|
|
231
|
+
return [&]() {
|
|
232
|
+
auto __promise = Promise<std::string>::create();
|
|
233
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
234
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
235
|
+
__promise->resolve(__result->toStdString());
|
|
236
|
+
});
|
|
237
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
238
|
+
jni::JniException __jniError(__throwable);
|
|
239
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
240
|
+
});
|
|
241
|
+
return __promise;
|
|
242
|
+
}();
|
|
243
|
+
}
|
|
244
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::getFileSize(const std::string& filePath) {
|
|
245
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* filePath */)>("getFileSize");
|
|
246
|
+
auto __result = method(_javaPart, jni::make_jstring(filePath));
|
|
247
|
+
return [&]() {
|
|
248
|
+
auto __promise = Promise<std::string>::create();
|
|
249
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
250
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
251
|
+
__promise->resolve(__result->toStdString());
|
|
252
|
+
});
|
|
253
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
254
|
+
jni::JniException __jniError(__throwable);
|
|
255
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
256
|
+
});
|
|
257
|
+
return __promise;
|
|
258
|
+
}();
|
|
259
|
+
}
|
|
260
|
+
std::shared_ptr<Promise<VideoThumbnailResult>> JHybridCompressorSpec::createVideoThumbnail(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options) {
|
|
261
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* fileUrl */, jni::alias_ref<JAnyMap::javaobject> /* options */)>("createVideoThumbnail");
|
|
262
|
+
auto __result = method(_javaPart, jni::make_jstring(fileUrl), JAnyMap::create(options));
|
|
263
|
+
return [&]() {
|
|
264
|
+
auto __promise = Promise<VideoThumbnailResult>::create();
|
|
265
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
266
|
+
auto __result = jni::static_ref_cast<JVideoThumbnailResult>(__boxedResult);
|
|
267
|
+
__promise->resolve(__result->toCpp());
|
|
268
|
+
});
|
|
269
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
270
|
+
jni::JniException __jniError(__throwable);
|
|
271
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
272
|
+
});
|
|
273
|
+
return __promise;
|
|
274
|
+
}();
|
|
275
|
+
}
|
|
276
|
+
std::shared_ptr<Promise<std::string>> JHybridCompressorSpec::clearCache(const std::optional<std::string>& cacheDir) {
|
|
277
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* cacheDir */)>("clearCache");
|
|
278
|
+
auto __result = method(_javaPart, cacheDir.has_value() ? jni::make_jstring(cacheDir.value()) : nullptr);
|
|
279
|
+
return [&]() {
|
|
280
|
+
auto __promise = Promise<std::string>::create();
|
|
281
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
282
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
283
|
+
__promise->resolve(__result->toStdString());
|
|
284
|
+
});
|
|
285
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
286
|
+
jni::JniException __jniError(__throwable);
|
|
287
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
288
|
+
});
|
|
289
|
+
return __promise;
|
|
290
|
+
}();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
} // namespace margelo::nitro::compressor
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCompressorSpec.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 <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridCompressorSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::compressor {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridCompressorSpec: public virtual HybridCompressorSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/HybridCompressorSpec;";
|
|
25
|
+
std::shared_ptr<JHybridCompressorSpec> getJHybridCompressorSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/HybridCompressorSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridCompressorSpec(const jni::local_ref<JHybridCompressorSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridCompressorSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridCompressorSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridCompressorSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
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;
|
|
58
|
+
std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> getImageMetaData(const std::string& filePath) override;
|
|
59
|
+
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;
|
|
60
|
+
void cancelCompression(const std::string& uuid) override;
|
|
61
|
+
std::shared_ptr<Promise<std::shared_ptr<AnyMap>>> getVideoMetaData(const std::string& filePath) override;
|
|
62
|
+
std::shared_ptr<Promise<std::string>> activateBackgroundTask(const std::shared_ptr<AnyMap>& options, const std::optional<std::function<void()>>& onExpired) override;
|
|
63
|
+
std::shared_ptr<Promise<std::string>> deactivateBackgroundTask(const std::shared_ptr<AnyMap>& options) override;
|
|
64
|
+
std::shared_ptr<Promise<std::string>> compress_audio(const std::string& fileUrl, const std::shared_ptr<AnyMap>& optionMap) override;
|
|
65
|
+
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;
|
|
66
|
+
void cancelUpload(const std::string& uuid, bool shouldCancelAll) override;
|
|
67
|
+
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;
|
|
68
|
+
std::shared_ptr<Promise<std::string>> generateFilePath(const std::string& fileExtension) override;
|
|
69
|
+
std::shared_ptr<Promise<std::string>> getRealPath(const std::string& path, const std::string& type) override;
|
|
70
|
+
std::shared_ptr<Promise<std::string>> getFileSize(const std::string& filePath) override;
|
|
71
|
+
std::shared_ptr<Promise<VideoThumbnailResult>> createVideoThumbnail(const std::string& fileUrl, const std::shared_ptr<AnyMap>& options) override;
|
|
72
|
+
std::shared_ptr<Promise<std::string>> clearCache(const std::optional<std::string>& cacheDir) override;
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
jni::global_ref<JHybridCompressorSpec::JavaPart> _javaPart;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro::compressor
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVideoThumbnailResult.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "VideoThumbnailResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::compressor {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "VideoThumbnailResult" and the the Kotlin data class "VideoThumbnailResult".
|
|
21
|
+
*/
|
|
22
|
+
struct JVideoThumbnailResult final: public jni::JavaClass<JVideoThumbnailResult> {
|
|
23
|
+
public:
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/VideoThumbnailResult;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct VideoThumbnailResult by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
VideoThumbnailResult toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldPath = clazz->getField<jni::JString>("path");
|
|
35
|
+
jni::local_ref<jni::JString> path = this->getFieldValue(fieldPath);
|
|
36
|
+
static const auto fieldSize = clazz->getField<double>("size");
|
|
37
|
+
double size = this->getFieldValue(fieldSize);
|
|
38
|
+
static const auto fieldMime = clazz->getField<jni::JString>("mime");
|
|
39
|
+
jni::local_ref<jni::JString> mime = this->getFieldValue(fieldMime);
|
|
40
|
+
static const auto fieldWidth = clazz->getField<double>("width");
|
|
41
|
+
double width = this->getFieldValue(fieldWidth);
|
|
42
|
+
static const auto fieldHeight = clazz->getField<double>("height");
|
|
43
|
+
double height = this->getFieldValue(fieldHeight);
|
|
44
|
+
return VideoThumbnailResult(
|
|
45
|
+
path->toStdString(),
|
|
46
|
+
size,
|
|
47
|
+
mime->toStdString(),
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
/**
|
|
55
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
56
|
+
*/
|
|
57
|
+
[[maybe_unused]]
|
|
58
|
+
static jni::local_ref<JVideoThumbnailResult::javaobject> fromCpp(const VideoThumbnailResult& value) {
|
|
59
|
+
using JSignature = JVideoThumbnailResult(jni::alias_ref<jni::JString>, double, jni::alias_ref<jni::JString>, double, double);
|
|
60
|
+
static const auto clazz = javaClassStatic();
|
|
61
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
62
|
+
return create(
|
|
63
|
+
clazz,
|
|
64
|
+
jni::make_jstring(value.path),
|
|
65
|
+
value.size,
|
|
66
|
+
jni::make_jstring(value.mime),
|
|
67
|
+
value.width,
|
|
68
|
+
value.height
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace margelo::nitro::compressor
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.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 `() => 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: () -> 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(): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `() => 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_cxx: Func_void {
|
|
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(): Unit
|
|
60
|
+
= invoke_cxx()
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `() => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `() -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_java(private val function: () -> Unit): Func_void {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(): Unit {
|
|
78
|
+
return this.function()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_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 `(progress: 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) -> 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(progress: Double): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(progress: 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_cxx: Func_void_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(progress: Double): Unit
|
|
60
|
+
= invoke_cxx(progress)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(progress: Double): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(progress: number) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(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_java(private val function: (Double) -> Unit): Func_void_double {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(progress: Double): Unit {
|
|
78
|
+
return this.function(progress)
|
|
79
|
+
}
|
|
80
|
+
}
|