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
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,cAOlB,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,eAAO,MAAM,MAAM,cAOlB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MASlE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.tsx"],"names":[],"mappings":"AAEA,KAAK,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAG7C,KAAK,qBAAqB,GAAG;IAE3B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,O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,eAAO,MAAM,gBAAgB,EAAE,GAM9B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,eAEzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,oBAE9B,CAAC;AAiBF,eAAO,MAAM,gBAAgB,EAAE,oBAG9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,wBAElC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAExB,CAAC;AAuCF,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,EAAE,YAAW,KAAK,GAAG,KAAa,KAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CA6BtG,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAElE,CAAC;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,81 @@
1
+ #
2
+ # NitroCompressor+autolinking.cmake
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 CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroCompressor+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITROCOMPRESSOR_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ NitroCompressor PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/NitroCompressorOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridCompressorSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridCompressorSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ NitroCompressor PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ NitroCompressor
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ NitroCompressor
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ NitroCompressor
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// NitroCompressor+autolinking.gradle
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 Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/NitroCompressor+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 NitroCompressor is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// NitroCompressorOnLoad.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
+ #ifndef BUILDING_NITROCOMPRESSOR_WITH_GENERATED_CMAKE_PROJECT
9
+ #error NitroCompressorOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "NitroCompressorOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridCompressorSpec.hpp"
19
+ #include "JFunc_void_double.hpp"
20
+ #include "JFunc_void.hpp"
21
+ #include "JFunc_void_double_double.hpp"
22
+ #include <NitroModules/DefaultConstructableObject.hpp>
23
+
24
+ namespace margelo::nitro::compressor {
25
+
26
+ int initialize(JavaVM* vm) {
27
+ return facebook::jni::initialize(vm, []() {
28
+ ::margelo::nitro::compressor::registerAllNatives();
29
+ });
30
+ }
31
+
32
+ struct JHybridCompressorSpecImpl: public jni::JavaClass<JHybridCompressorSpecImpl, JHybridCompressorSpec::JavaPart> {
33
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/HybridCompressor;";
34
+ static std::shared_ptr<JHybridCompressorSpec> create() {
35
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridCompressorSpecImpl::javaobject()>();
36
+ jni::local_ref<JHybridCompressorSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
37
+ return javaPart->getJHybridCompressorSpec();
38
+ }
39
+ };
40
+
41
+ void registerAllNatives() {
42
+ using namespace margelo::nitro;
43
+ using namespace margelo::nitro::compressor;
44
+
45
+ // Register native JNI methods
46
+ margelo::nitro::compressor::JHybridCompressorSpec::CxxPart::registerNatives();
47
+ margelo::nitro::compressor::JFunc_void_double_cxx::registerNatives();
48
+ margelo::nitro::compressor::JFunc_void_cxx::registerNatives();
49
+ margelo::nitro::compressor::JFunc_void_double_double_cxx::registerNatives();
50
+
51
+ // Register Nitro Hybrid Objects
52
+ HybridObjectRegistry::registerHybridObjectConstructor(
53
+ "Compressor",
54
+ []() -> std::shared_ptr<HybridObject> {
55
+ return JHybridCompressorSpecImpl::create();
56
+ }
57
+ );
58
+ }
59
+
60
+ } // namespace margelo::nitro::compressor
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// NitroCompressorOnLoad.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
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::compressor {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of NitroCompressor, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all NitroCompressor HybridObjects
26
+ * margelo::nitro::compressor::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::compressor
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void.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 <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::compressor {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `() -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void: public jni::JavaClass<JFunc_void> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void` instance holds through JNI.
31
+ */
32
+ void invoke() const {
33
+ static const auto method = javaClassStatic()->getMethod<void()>("invoke");
34
+ method(self());
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
42
+ public:
43
+ static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
44
+ return JFunc_void_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
50
+ */
51
+ void invoke_cxx() {
52
+ _func();
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void()>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void()> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::compressor
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double.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 <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::compressor {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(progress: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double: public jni::JavaClass<JFunc_void_double> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double` instance holds through JNI.
31
+ */
32
+ void invoke(double progress) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* progress */)>("invoke");
34
+ method(self(), progress);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_cxx final: public jni::HybridClass<JFunc_void_double_cxx, JFunc_void_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double::javaobject> fromCpp(const std::function<void(double /* progress */)>& func) {
44
+ return JFunc_void_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double progress) {
52
+ _func(progress);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* progress */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_cxx(const std::function<void(double /* progress */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* progress */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::compressor
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double_double.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 <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::compressor {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(written: Double, total: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double_double: public jni::JavaClass<JFunc_void_double_double> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void_double_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double_double` instance holds through JNI.
31
+ */
32
+ void invoke(double written, double total) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* written */, double /* total */)>("invoke");
34
+ method(self(), written, total);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_double_cxx final: public jni::HybridClass<JFunc_void_double_double_cxx, JFunc_void_double_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double_double::javaobject> fromCpp(const std::function<void(double /* written */, double /* total */)>& func) {
44
+ return JFunc_void_double_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double written, double total) {
52
+ _func(written, total);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* written */, double /* total */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/compressor/Func_void_double_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_double_cxx(const std::function<void(double /* written */, double /* total */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* written */, double /* total */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::compressor