react-native-nitro-image-pipeline 1.6.0 → 1.7.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/README.md +88 -13
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +51 -20
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/PipelineImageLoader.kt +47 -8
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/FitGeometry.kt +104 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/PipelineRoundedCornersTransformation.kt +103 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/ResizeTransformation.kt +69 -16
- package/ios/FitResizeProcessor.swift +127 -0
- package/ios/HybridNitroImagePipeline.swift +41 -15
- package/ios/PipelineImageLoader.swift +107 -17
- package/lib/commonjs/NativePipelineImage.js +18 -3
- package/lib/commonjs/NativePipelineImage.js.map +1 -1
- package/lib/commonjs/PipelineImage.js +13 -1
- package/lib/commonjs/PipelineImage.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/resizeForStyle.js +3 -1
- package/lib/commonjs/resizeForStyle.js.map +1 -1
- package/lib/commonjs/useImage.js +6 -2
- package/lib/commonjs/useImage.js.map +1 -1
- package/lib/commonjs/usePipelineImageLoader.js +107 -9
- package/lib/commonjs/usePipelineImageLoader.js.map +1 -1
- package/lib/module/NativePipelineImage.js +18 -3
- package/lib/module/NativePipelineImage.js.map +1 -1
- package/lib/module/PipelineImage.js +13 -1
- package/lib/module/PipelineImage.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/resizeForStyle.js +3 -1
- package/lib/module/resizeForStyle.js.map +1 -1
- package/lib/module/useImage.js +6 -2
- package/lib/module/useImage.js.map +1 -1
- package/lib/module/usePipelineImageLoader.js +108 -10
- package/lib/module/usePipelineImageLoader.js.map +1 -1
- package/lib/typescript/src/NativePipelineImage.d.ts +44 -3
- package/lib/typescript/src/NativePipelineImage.d.ts.map +1 -1
- package/lib/typescript/src/PipelineImage.d.ts +28 -1
- package/lib/typescript/src/PipelineImage.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/resizeForStyle.d.ts +3 -1
- package/lib/typescript/src/resizeForStyle.d.ts.map +1 -1
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +83 -8
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
- package/lib/typescript/src/useImage.d.ts +3 -2
- package/lib/typescript/src/useImage.d.ts.map +1 -1
- package/lib/typescript/src/usePipelineImageLoader.d.ts +3 -1
- package/lib/typescript/src/usePipelineImageLoader.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroImagePipelineOnLoad.cpp +4 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +8 -0
- package/nitrogen/generated/android/c++/JOptions.hpp +2 -0
- package/nitrogen/generated/android/c++/JResizeFit.hpp +64 -0
- package/nitrogen/generated/android/c++/JResizeOptions.hpp +14 -4
- package/nitrogen/generated/android/c++/JViewOptions.hpp +42 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Func_void_double_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Func_void_std__string.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeFit.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeOptions.kt +14 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ViewOptions.kt +29 -5
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +107 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +4 -0
- package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +4 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/ResizeFit.swift +48 -0
- package/nitrogen/generated/ios/swift/ResizeOptions.swift +31 -2
- package/nitrogen/generated/ios/swift/ViewOptions.swift +82 -1
- package/nitrogen/generated/shared/c++/ResizeFit.hpp +84 -0
- package/nitrogen/generated/shared/c++/ResizeOptions.hpp +14 -4
- package/nitrogen/generated/shared/c++/ViewOptions.hpp +24 -3
- package/package.json +1 -1
- package/src/NativePipelineImage.tsx +67 -3
- package/src/PipelineImage.tsx +39 -1
- package/src/index.ts +1 -0
- package/src/resizeForStyle.ts +3 -1
- package/src/specs/nitro-image-toolkit.nitro.ts +84 -8
- package/src/useImage.ts +13 -3
- package/src/usePipelineImageLoader.ts +115 -8
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_std__string.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 <string>
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents the Java/Kotlin callback `(message: String) -> Unit`.
|
|
23
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
24
|
+
*/
|
|
25
|
+
struct JFunc_void_std__string: public jni::JavaClass<JFunc_void_std__string> {
|
|
26
|
+
public:
|
|
27
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/Func_void_std__string;";
|
|
28
|
+
|
|
29
|
+
public:
|
|
30
|
+
/**
|
|
31
|
+
* Invokes the function this `JFunc_void_std__string` instance holds through JNI.
|
|
32
|
+
*/
|
|
33
|
+
void invoke(const std::string& message) const {
|
|
34
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* message */)>("invoke");
|
|
35
|
+
method(self(), jni::make_jstring(message));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`)
|
|
41
|
+
*/
|
|
42
|
+
class JFunc_void_std__string_cxx final: public jni::HybridClass<JFunc_void_std__string_cxx, JFunc_void_std__string> {
|
|
43
|
+
public:
|
|
44
|
+
static jni::local_ref<JFunc_void_std__string::javaobject> fromCpp(const std::function<void(const std::string& /* message */)>& func) {
|
|
45
|
+
return JFunc_void_std__string_cxx::newObjectCxxArgs(func);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
/**
|
|
50
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
|
|
51
|
+
*/
|
|
52
|
+
void invoke_cxx(jni::alias_ref<jni::JString> message) {
|
|
53
|
+
_func(message->toStdString());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
[[nodiscard]]
|
|
58
|
+
inline const std::function<void(const std::string& /* message */)>& getFunction() const {
|
|
59
|
+
return _func;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/Func_void_std__string_cxx;";
|
|
64
|
+
static void registerNatives() {
|
|
65
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
explicit JFunc_void_std__string_cxx(const std::function<void(const std::string& /* message */)>& func): _func(func) { }
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
friend HybridBase;
|
|
73
|
+
std::function<void(const std::string& /* message */)> _func;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -19,6 +19,8 @@ namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
|
19
19
|
namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
|
|
20
20
|
// Forward declaration of `ResizeOptions` to properly resolve imports.
|
|
21
21
|
namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
22
|
+
// Forward declaration of `ResizeFit` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline { enum class ResizeFit; }
|
|
22
24
|
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
23
25
|
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
24
26
|
|
|
@@ -42,8 +44,14 @@ namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
|
42
44
|
#include "JCornerRadii.hpp"
|
|
43
45
|
#include "ResizeOptions.hpp"
|
|
44
46
|
#include "JResizeOptions.hpp"
|
|
47
|
+
#include "ResizeFit.hpp"
|
|
48
|
+
#include "JResizeFit.hpp"
|
|
45
49
|
#include "ViewOptions.hpp"
|
|
46
50
|
#include "JViewOptions.hpp"
|
|
51
|
+
#include <functional>
|
|
52
|
+
#include "JFunc_void_double_double.hpp"
|
|
53
|
+
#include <NitroModules/JNICallable.hpp>
|
|
54
|
+
#include "JFunc_void_std__string.hpp"
|
|
47
55
|
#include <vector>
|
|
48
56
|
|
|
49
57
|
namespace margelo::nitro::nitroimagepipeline {
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
#include "CornerRadii.hpp"
|
|
15
15
|
#include "JCacheOption.hpp"
|
|
16
16
|
#include "JCornerRadii.hpp"
|
|
17
|
+
#include "JResizeFit.hpp"
|
|
17
18
|
#include "JResizeOptions.hpp"
|
|
18
19
|
#include "JVariant_Double_CornerRadii.hpp"
|
|
20
|
+
#include "ResizeFit.hpp"
|
|
19
21
|
#include "ResizeOptions.hpp"
|
|
20
22
|
#include <optional>
|
|
21
23
|
#include <variant>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JResizeFit.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 "ResizeFit.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "ResizeFit" and the Kotlin enum "ResizeFit".
|
|
19
|
+
*/
|
|
20
|
+
struct JResizeFit final: public jni::JavaClass<JResizeFit> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/ResizeFit;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum ResizeFit.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
ResizeFit toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<ResizeFit>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JResizeFit> fromCpp(ResizeFit value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case ResizeFit::COVER:
|
|
46
|
+
static const auto fieldCOVER = clazz->getStaticField<JResizeFit>("COVER");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldCOVER);
|
|
48
|
+
case ResizeFit::CONTAIN:
|
|
49
|
+
static const auto fieldCONTAIN = clazz->getStaticField<JResizeFit>("CONTAIN");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldCONTAIN);
|
|
51
|
+
case ResizeFit::STRETCH:
|
|
52
|
+
static const auto fieldSTRETCH = clazz->getStaticField<JResizeFit>("STRETCH");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldSTRETCH);
|
|
54
|
+
case ResizeFit::CENTER:
|
|
55
|
+
static const auto fieldCENTER = clazz->getStaticField<JResizeFit>("CENTER");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldCENTER);
|
|
57
|
+
default:
|
|
58
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
59
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
#include <fbjni/fbjni.h>
|
|
11
11
|
#include "ResizeOptions.hpp"
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
#include "JResizeFit.hpp"
|
|
14
|
+
#include "ResizeFit.hpp"
|
|
15
|
+
#include <optional>
|
|
14
16
|
|
|
15
17
|
namespace margelo::nitro::nitroimagepipeline {
|
|
16
18
|
|
|
@@ -35,9 +37,15 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
35
37
|
double width = this->getFieldValue(fieldWidth);
|
|
36
38
|
static const auto fieldHeight = clazz->getField<double>("height");
|
|
37
39
|
double height = this->getFieldValue(fieldHeight);
|
|
40
|
+
static const auto fieldFit = clazz->getField<JResizeFit>("fit");
|
|
41
|
+
jni::local_ref<JResizeFit> fit = this->getFieldValue(fieldFit);
|
|
42
|
+
static const auto fieldAllowUpscale = clazz->getField<jni::JBoolean>("allowUpscale");
|
|
43
|
+
jni::local_ref<jni::JBoolean> allowUpscale = this->getFieldValue(fieldAllowUpscale);
|
|
38
44
|
return ResizeOptions(
|
|
39
45
|
width,
|
|
40
|
-
height
|
|
46
|
+
height,
|
|
47
|
+
fit != nullptr ? std::make_optional(fit->toCpp()) : std::nullopt,
|
|
48
|
+
allowUpscale != nullptr ? std::make_optional(static_cast<bool>(allowUpscale->value())) : std::nullopt
|
|
41
49
|
);
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -47,13 +55,15 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
47
55
|
*/
|
|
48
56
|
[[maybe_unused]]
|
|
49
57
|
static jni::local_ref<JResizeOptions::javaobject> fromCpp(const ResizeOptions& value) {
|
|
50
|
-
using JSignature = JResizeOptions(double, double);
|
|
58
|
+
using JSignature = JResizeOptions(double, double, jni::alias_ref<JResizeFit>, jni::alias_ref<jni::JBoolean>);
|
|
51
59
|
static const auto clazz = javaClassStatic();
|
|
52
60
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
61
|
return create(
|
|
54
62
|
clazz,
|
|
55
63
|
value.width,
|
|
56
|
-
value.height
|
|
64
|
+
value.height,
|
|
65
|
+
value.fit.has_value() ? JResizeFit::fromCpp(value.fit.value()) : nullptr,
|
|
66
|
+
value.allowUpscale.has_value() ? jni::JBoolean::valueOf(value.allowUpscale.value()) : nullptr
|
|
57
67
|
);
|
|
58
68
|
}
|
|
59
69
|
};
|
|
@@ -14,10 +14,17 @@
|
|
|
14
14
|
#include "CornerRadii.hpp"
|
|
15
15
|
#include "JCacheOption.hpp"
|
|
16
16
|
#include "JCornerRadii.hpp"
|
|
17
|
+
#include "JFunc_void_double_double.hpp"
|
|
18
|
+
#include "JFunc_void_std__string.hpp"
|
|
19
|
+
#include "JResizeFit.hpp"
|
|
17
20
|
#include "JResizeOptions.hpp"
|
|
18
21
|
#include "JVariant_Double_CornerRadii.hpp"
|
|
22
|
+
#include "ResizeFit.hpp"
|
|
19
23
|
#include "ResizeOptions.hpp"
|
|
24
|
+
#include <NitroModules/JNICallable.hpp>
|
|
25
|
+
#include <functional>
|
|
20
26
|
#include <optional>
|
|
27
|
+
#include <string>
|
|
21
28
|
#include <variant>
|
|
22
29
|
|
|
23
30
|
namespace margelo::nitro::nitroimagepipeline {
|
|
@@ -47,11 +54,39 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
47
54
|
jni::local_ref<JVariant_Double_CornerRadii> cornerRadius = this->getFieldValue(fieldCornerRadius);
|
|
48
55
|
static const auto fieldResize = clazz->getField<JResizeOptions>("resize");
|
|
49
56
|
jni::local_ref<JResizeOptions> resize = this->getFieldValue(fieldResize);
|
|
57
|
+
static const auto fieldFit = clazz->getField<JResizeFit>("fit");
|
|
58
|
+
jni::local_ref<JResizeFit> fit = this->getFieldValue(fieldFit);
|
|
59
|
+
static const auto fieldAllowUpscale = clazz->getField<jni::JBoolean>("allowUpscale");
|
|
60
|
+
jni::local_ref<jni::JBoolean> allowUpscale = this->getFieldValue(fieldAllowUpscale);
|
|
61
|
+
static const auto fieldOnLoad = clazz->getField<JFunc_void_double_double::javaobject>("onLoad");
|
|
62
|
+
jni::local_ref<JFunc_void_double_double::javaobject> onLoad = this->getFieldValue(fieldOnLoad);
|
|
63
|
+
static const auto fieldOnError = clazz->getField<JFunc_void_std__string::javaobject>("onError");
|
|
64
|
+
jni::local_ref<JFunc_void_std__string::javaobject> onError = this->getFieldValue(fieldOnError);
|
|
50
65
|
return ViewOptions(
|
|
51
66
|
blur != nullptr ? std::make_optional(blur->value()) : std::nullopt,
|
|
52
67
|
cache != nullptr ? std::make_optional(cache->toCpp()) : std::nullopt,
|
|
53
68
|
cornerRadius != nullptr ? std::make_optional(cornerRadius->toCpp()) : std::nullopt,
|
|
54
|
-
resize != nullptr ? std::make_optional(resize->toCpp()) : std::nullopt
|
|
69
|
+
resize != nullptr ? std::make_optional(resize->toCpp()) : std::nullopt,
|
|
70
|
+
fit != nullptr ? std::make_optional(fit->toCpp()) : std::nullopt,
|
|
71
|
+
allowUpscale != nullptr ? std::make_optional(static_cast<bool>(allowUpscale->value())) : std::nullopt,
|
|
72
|
+
onLoad != nullptr ? std::make_optional([&]() -> std::function<void(double /* width */, double /* height */)> {
|
|
73
|
+
if (onLoad->isInstanceOf(JFunc_void_double_double_cxx::javaClassStatic())) [[likely]] {
|
|
74
|
+
auto downcast = jni::static_ref_cast<JFunc_void_double_double_cxx::javaobject>(onLoad);
|
|
75
|
+
return downcast->cthis()->getFunction();
|
|
76
|
+
} else {
|
|
77
|
+
auto onLoadRef = jni::make_global(onLoad);
|
|
78
|
+
return JNICallable<JFunc_void_double_double, void(double, double)>(std::move(onLoadRef));
|
|
79
|
+
}
|
|
80
|
+
}()) : std::nullopt,
|
|
81
|
+
onError != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* message */)> {
|
|
82
|
+
if (onError->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
83
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(onError);
|
|
84
|
+
return downcast->cthis()->getFunction();
|
|
85
|
+
} else {
|
|
86
|
+
auto onErrorRef = jni::make_global(onError);
|
|
87
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(onErrorRef));
|
|
88
|
+
}
|
|
89
|
+
}()) : std::nullopt
|
|
55
90
|
);
|
|
56
91
|
}
|
|
57
92
|
|
|
@@ -61,7 +96,7 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
61
96
|
*/
|
|
62
97
|
[[maybe_unused]]
|
|
63
98
|
static jni::local_ref<JViewOptions::javaobject> fromCpp(const ViewOptions& value) {
|
|
64
|
-
using JSignature = JViewOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<JVariant_Double_CornerRadii>, jni::alias_ref<JResizeOptions>);
|
|
99
|
+
using JSignature = JViewOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<JVariant_Double_CornerRadii>, jni::alias_ref<JResizeOptions>, jni::alias_ref<JResizeFit>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JFunc_void_double_double::javaobject>, jni::alias_ref<JFunc_void_std__string::javaobject>);
|
|
65
100
|
static const auto clazz = javaClassStatic();
|
|
66
101
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
67
102
|
return create(
|
|
@@ -69,7 +104,11 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
69
104
|
value.blur.has_value() ? jni::JDouble::valueOf(value.blur.value()) : nullptr,
|
|
70
105
|
value.cache.has_value() ? JCacheOption::fromCpp(value.cache.value()) : nullptr,
|
|
71
106
|
value.cornerRadius.has_value() ? JVariant_Double_CornerRadii::fromCpp(value.cornerRadius.value()) : nullptr,
|
|
72
|
-
value.resize.has_value() ? JResizeOptions::fromCpp(value.resize.value()) : nullptr
|
|
107
|
+
value.resize.has_value() ? JResizeOptions::fromCpp(value.resize.value()) : nullptr,
|
|
108
|
+
value.fit.has_value() ? JResizeFit::fromCpp(value.fit.value()) : nullptr,
|
|
109
|
+
value.allowUpscale.has_value() ? jni::JBoolean::valueOf(value.allowUpscale.value()) : nullptr,
|
|
110
|
+
value.onLoad.has_value() ? JFunc_void_double_double_cxx::fromCpp(value.onLoad.value()) : nullptr,
|
|
111
|
+
value.onError.has_value() ? JFunc_void_std__string_cxx::fromCpp(value.onError.value()) : nullptr
|
|
73
112
|
);
|
|
74
113
|
}
|
|
75
114
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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.nitroimagepipeline
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(width: number, height: number) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_double_double: (Double, Double) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(width: Double, height: Double): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(width: number, height: number) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_double_double_cxx: Func_void_double_double {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(width: Double, height: Double): Unit
|
|
59
|
+
= invoke_cxx(width,height)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(width: Double, height: Double): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(width: number, height: number) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(Double, Double) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_double_double_java(private val function: (Double, Double) -> Unit): Func_void_double_double {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(width: Double, height: Double): Unit {
|
|
76
|
+
return this.function(width, height)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.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.nitroimagepipeline
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_std__string: (String) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(message: String): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_std__string_cxx: Func_void_std__string {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(message: String): Unit
|
|
59
|
+
= invoke_cxx(message)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(message: String): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(String) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(message: String): Unit {
|
|
76
|
+
return this.function(message)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ResizeFit.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.nitroimagepipeline
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "ResizeFit".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class ResizeFit(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
COVER(0),
|
|
20
|
+
CONTAIN(1),
|
|
21
|
+
STRETCH(2),
|
|
22
|
+
CENTER(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeOptions.kt
CHANGED
|
@@ -23,7 +23,13 @@ data class ResizeOptions(
|
|
|
23
23
|
val width: Double,
|
|
24
24
|
@DoNotStrip
|
|
25
25
|
@Keep
|
|
26
|
-
val height: Double
|
|
26
|
+
val height: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val fit: ResizeFit?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val allowUpscale: Boolean?
|
|
27
33
|
) {
|
|
28
34
|
/* primary constructor */
|
|
29
35
|
|
|
@@ -32,12 +38,16 @@ data class ResizeOptions(
|
|
|
32
38
|
if (other !is ResizeOptions) return false
|
|
33
39
|
return Objects.deepEquals(this.width, other.width)
|
|
34
40
|
&& Objects.deepEquals(this.height, other.height)
|
|
41
|
+
&& Objects.deepEquals(this.fit, other.fit)
|
|
42
|
+
&& Objects.deepEquals(this.allowUpscale, other.allowUpscale)
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
override fun hashCode(): Int {
|
|
38
46
|
return arrayOf<Any?>(
|
|
39
47
|
width,
|
|
40
|
-
height
|
|
48
|
+
height,
|
|
49
|
+
fit,
|
|
50
|
+
allowUpscale
|
|
41
51
|
).contentDeepHashCode()
|
|
42
52
|
}
|
|
43
53
|
|
|
@@ -49,8 +59,8 @@ data class ResizeOptions(
|
|
|
49
59
|
@Keep
|
|
50
60
|
@Suppress("unused")
|
|
51
61
|
@JvmStatic
|
|
52
|
-
private fun fromCpp(width: Double, height: Double): ResizeOptions {
|
|
53
|
-
return ResizeOptions(width, height)
|
|
62
|
+
private fun fromCpp(width: Double, height: Double, fit: ResizeFit?, allowUpscale: Boolean?): ResizeOptions {
|
|
63
|
+
return ResizeOptions(width, height, fit, allowUpscale)
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ViewOptions.kt
CHANGED
|
@@ -29,9 +29,25 @@ data class ViewOptions(
|
|
|
29
29
|
val cornerRadius: Variant_Double_CornerRadii?,
|
|
30
30
|
@DoNotStrip
|
|
31
31
|
@Keep
|
|
32
|
-
val resize: ResizeOptions
|
|
32
|
+
val resize: ResizeOptions?,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val fit: ResizeFit?,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val allowUpscale: Boolean?,
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
val onLoad: Func_void_double_double?,
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
val onError: Func_void_std__string?
|
|
33
45
|
) {
|
|
34
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Create a new instance of ViewOptions from Kotlin
|
|
48
|
+
*/
|
|
49
|
+
constructor(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?, fit: ResizeFit?, allowUpscale: Boolean?, onLoad: ((width: Double, height: Double) -> Unit)?, onError: ((message: String) -> Unit)?):
|
|
50
|
+
this(blur, cache, cornerRadius, resize, fit, allowUpscale, onLoad?.let { Func_void_double_double_java(it) }, onError?.let { Func_void_std__string_java(it) })
|
|
35
51
|
|
|
36
52
|
override fun equals(other: Any?): Boolean {
|
|
37
53
|
if (this === other) return true
|
|
@@ -40,6 +56,10 @@ data class ViewOptions(
|
|
|
40
56
|
&& Objects.deepEquals(this.cache, other.cache)
|
|
41
57
|
&& Objects.deepEquals(this.cornerRadius, other.cornerRadius)
|
|
42
58
|
&& Objects.deepEquals(this.resize, other.resize)
|
|
59
|
+
&& Objects.deepEquals(this.fit, other.fit)
|
|
60
|
+
&& Objects.deepEquals(this.allowUpscale, other.allowUpscale)
|
|
61
|
+
&& Objects.deepEquals(this.onLoad, other.onLoad)
|
|
62
|
+
&& Objects.deepEquals(this.onError, other.onError)
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
override fun hashCode(): Int {
|
|
@@ -47,7 +67,11 @@ data class ViewOptions(
|
|
|
47
67
|
blur,
|
|
48
68
|
cache,
|
|
49
69
|
cornerRadius,
|
|
50
|
-
resize
|
|
70
|
+
resize,
|
|
71
|
+
fit,
|
|
72
|
+
allowUpscale,
|
|
73
|
+
onLoad,
|
|
74
|
+
onError
|
|
51
75
|
).contentDeepHashCode()
|
|
52
76
|
}
|
|
53
77
|
|
|
@@ -59,8 +83,8 @@ data class ViewOptions(
|
|
|
59
83
|
@Keep
|
|
60
84
|
@Suppress("unused")
|
|
61
85
|
@JvmStatic
|
|
62
|
-
private fun fromCpp(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?): ViewOptions {
|
|
63
|
-
return ViewOptions(blur, cache, cornerRadius, resize)
|
|
86
|
+
private fun fromCpp(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?, fit: ResizeFit?, allowUpscale: Boolean?, onLoad: Func_void_double_double?, onError: Func_void_std__string?): ViewOptions {
|
|
87
|
+
return ViewOptions(blur, cache, cornerRadius, resize, fit, allowUpscale, onLoad, onError)
|
|
64
88
|
}
|
|
65
89
|
}
|
|
66
90
|
}
|
|
@@ -51,6 +51,22 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
|
|
|
51
51
|
return margelo::nitro::image::bridge::swift::get_std__shared_ptr_HybridImageLoaderSpec_(cppType);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// pragma MARK: std::function<void(double /* width */, double /* height */)>
|
|
55
|
+
Func_void_double_double create_Func_void_double_double(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
56
|
+
auto swiftClosure = NitroImagePipeline::Func_void_double_double::fromUnsafe(swiftClosureWrapper);
|
|
57
|
+
return [swiftClosure = std::move(swiftClosure)](double width, double height) mutable -> void {
|
|
58
|
+
swiftClosure.call(width, height);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// pragma MARK: std::function<void(const std::string& /* message */)>
|
|
63
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
64
|
+
auto swiftClosure = NitroImagePipeline::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
|
|
65
|
+
return [swiftClosure = std::move(swiftClosure)](const std::string& message) mutable -> void {
|
|
66
|
+
swiftClosure.call(message);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
// pragma MARK: std::function<void()>
|
|
55
71
|
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
56
72
|
auto swiftClosure = NitroImagePipeline::Func_void::fromUnsafe(swiftClosureWrapper);
|