react-native-nitro-image-pipeline 1.0.0 → 1.2.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 (37) hide show
  1. package/README.md +21 -6
  2. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +34 -2
  3. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/ResizeTransformation.kt +59 -0
  4. package/ios/HybridNitroImagePipeline.swift +23 -2
  5. package/ios/RoundedCornersProcessor.swift +121 -0
  6. package/lib/commonjs/index.js +25 -2
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/module/index.js +25 -2
  9. package/lib/module/index.js.map +1 -1
  10. package/lib/typescript/src/index.d.ts +18 -6
  11. package/lib/typescript/src/index.d.ts.map +1 -1
  12. package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +46 -1
  13. package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
  14. package/nitrogen/generated/android/NitroImagePipeline+autolinking.cmake +1 -0
  15. package/nitrogen/generated/android/c++/JCornerRadii.hpp +69 -0
  16. package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +10 -0
  17. package/nitrogen/generated/android/c++/JOptions.hpp +15 -5
  18. package/nitrogen/generated/android/c++/JResizeOptions.hpp +61 -0
  19. package/nitrogen/generated/android/c++/JVariant_Double_CornerRadii.cpp +26 -0
  20. package/nitrogen/generated/android/c++/JVariant_Double_CornerRadii.hpp +70 -0
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/CornerRadii.kt +66 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Options.kt +9 -4
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeOptions.kt +56 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Variant_Double_CornerRadii.kt +62 -0
  25. package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +66 -0
  26. package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +7 -0
  27. package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +7 -0
  28. package/nitrogen/generated/ios/swift/CornerRadii.swift +96 -0
  29. package/nitrogen/generated/ios/swift/Options.swift +38 -8
  30. package/nitrogen/generated/ios/swift/ResizeOptions.swift +34 -0
  31. package/nitrogen/generated/ios/swift/Variant_Double_CornerRadii.swift +30 -0
  32. package/nitrogen/generated/shared/c++/CornerRadii.hpp +95 -0
  33. package/nitrogen/generated/shared/c++/Options.hpp +16 -5
  34. package/nitrogen/generated/shared/c++/ResizeOptions.hpp +87 -0
  35. package/package.json +1 -1
  36. package/src/index.ts +52 -6
  37. package/src/specs/nitro-image-toolkit.nitro.ts +49 -1
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// JCornerRadii.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 "CornerRadii.hpp"
12
+
13
+ #include <optional>
14
+
15
+ namespace margelo::nitro::nitroimagepipeline {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "CornerRadii" and the Kotlin data class "CornerRadii".
21
+ */
22
+ struct JCornerRadii final: public jni::JavaClass<JCornerRadii> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/CornerRadii;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct CornerRadii by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ CornerRadii toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldTopLeft = clazz->getField<jni::JDouble>("topLeft");
35
+ jni::local_ref<jni::JDouble> topLeft = this->getFieldValue(fieldTopLeft);
36
+ static const auto fieldTopRight = clazz->getField<jni::JDouble>("topRight");
37
+ jni::local_ref<jni::JDouble> topRight = this->getFieldValue(fieldTopRight);
38
+ static const auto fieldBottomLeft = clazz->getField<jni::JDouble>("bottomLeft");
39
+ jni::local_ref<jni::JDouble> bottomLeft = this->getFieldValue(fieldBottomLeft);
40
+ static const auto fieldBottomRight = clazz->getField<jni::JDouble>("bottomRight");
41
+ jni::local_ref<jni::JDouble> bottomRight = this->getFieldValue(fieldBottomRight);
42
+ return CornerRadii(
43
+ topLeft != nullptr ? std::make_optional(topLeft->value()) : std::nullopt,
44
+ topRight != nullptr ? std::make_optional(topRight->value()) : std::nullopt,
45
+ bottomLeft != nullptr ? std::make_optional(bottomLeft->value()) : std::nullopt,
46
+ bottomRight != nullptr ? std::make_optional(bottomRight->value()) : std::nullopt
47
+ );
48
+ }
49
+
50
+ public:
51
+ /**
52
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
53
+ */
54
+ [[maybe_unused]]
55
+ static jni::local_ref<JCornerRadii::javaobject> fromCpp(const CornerRadii& value) {
56
+ using JSignature = JCornerRadii(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
57
+ static const auto clazz = javaClassStatic();
58
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
59
+ return create(
60
+ clazz,
61
+ value.topLeft.has_value() ? jni::JDouble::valueOf(value.topLeft.value()) : nullptr,
62
+ value.topRight.has_value() ? jni::JDouble::valueOf(value.topRight.value()) : nullptr,
63
+ value.bottomLeft.has_value() ? jni::JDouble::valueOf(value.bottomLeft.value()) : nullptr,
64
+ value.bottomRight.has_value() ? jni::JDouble::valueOf(value.bottomRight.value()) : nullptr
65
+ );
66
+ }
67
+ };
68
+
69
+ } // namespace margelo::nitro::nitroimagepipeline
@@ -13,6 +13,10 @@ namespace margelo::nitro::image { class HybridImageSpec; }
13
13
  namespace margelo::nitro::nitroimagepipeline { struct Options; }
14
14
  // Forward declaration of `CacheOption` to properly resolve imports.
15
15
  namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
16
+ // Forward declaration of `CornerRadii` to properly resolve imports.
17
+ namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
18
+ // Forward declaration of `ResizeOptions` to properly resolve imports.
19
+ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
16
20
 
17
21
  #include <memory>
18
22
  #include <NitroImage/HybridImageSpec.hpp>
@@ -26,6 +30,12 @@ namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
26
30
  #include "JOptions.hpp"
27
31
  #include "CacheOption.hpp"
28
32
  #include "JCacheOption.hpp"
33
+ #include "CornerRadii.hpp"
34
+ #include <variant>
35
+ #include "JVariant_Double_CornerRadii.hpp"
36
+ #include "JCornerRadii.hpp"
37
+ #include "ResizeOptions.hpp"
38
+ #include "JResizeOptions.hpp"
29
39
  #include <vector>
30
40
 
31
41
  namespace margelo::nitro::nitroimagepipeline {
@@ -11,8 +11,14 @@
11
11
  #include "Options.hpp"
12
12
 
13
13
  #include "CacheOption.hpp"
14
+ #include "CornerRadii.hpp"
14
15
  #include "JCacheOption.hpp"
16
+ #include "JCornerRadii.hpp"
17
+ #include "JResizeOptions.hpp"
18
+ #include "JVariant_Double_CornerRadii.hpp"
19
+ #include "ResizeOptions.hpp"
15
20
  #include <optional>
21
+ #include <variant>
16
22
 
17
23
  namespace margelo::nitro::nitroimagepipeline {
18
24
 
@@ -37,12 +43,15 @@ namespace margelo::nitro::nitroimagepipeline {
37
43
  jni::local_ref<jni::JDouble> blur = this->getFieldValue(fieldBlur);
38
44
  static const auto fieldCache = clazz->getField<JCacheOption>("cache");
39
45
  jni::local_ref<JCacheOption> cache = this->getFieldValue(fieldCache);
40
- static const auto fieldCornerRadius = clazz->getField<jni::JDouble>("cornerRadius");
41
- jni::local_ref<jni::JDouble> cornerRadius = this->getFieldValue(fieldCornerRadius);
46
+ static const auto fieldCornerRadius = clazz->getField<JVariant_Double_CornerRadii>("cornerRadius");
47
+ jni::local_ref<JVariant_Double_CornerRadii> cornerRadius = this->getFieldValue(fieldCornerRadius);
48
+ static const auto fieldResize = clazz->getField<JResizeOptions>("resize");
49
+ jni::local_ref<JResizeOptions> resize = this->getFieldValue(fieldResize);
42
50
  return Options(
43
51
  blur != nullptr ? std::make_optional(blur->value()) : std::nullopt,
44
52
  cache != nullptr ? std::make_optional(cache->toCpp()) : std::nullopt,
45
- cornerRadius != nullptr ? std::make_optional(cornerRadius->value()) : std::nullopt
53
+ cornerRadius != nullptr ? std::make_optional(cornerRadius->toCpp()) : std::nullopt,
54
+ resize != nullptr ? std::make_optional(resize->toCpp()) : std::nullopt
46
55
  );
47
56
  }
48
57
 
@@ -52,14 +61,15 @@ namespace margelo::nitro::nitroimagepipeline {
52
61
  */
53
62
  [[maybe_unused]]
54
63
  static jni::local_ref<JOptions::javaobject> fromCpp(const Options& value) {
55
- using JSignature = JOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<jni::JDouble>);
64
+ using JSignature = JOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<JVariant_Double_CornerRadii>, jni::alias_ref<JResizeOptions>);
56
65
  static const auto clazz = javaClassStatic();
57
66
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
58
67
  return create(
59
68
  clazz,
60
69
  value.blur.has_value() ? jni::JDouble::valueOf(value.blur.value()) : nullptr,
61
70
  value.cache.has_value() ? JCacheOption::fromCpp(value.cache.value()) : nullptr,
62
- value.cornerRadius.has_value() ? jni::JDouble::valueOf(value.cornerRadius.value()) : nullptr
71
+ value.cornerRadius.has_value() ? JVariant_Double_CornerRadii::fromCpp(value.cornerRadius.value()) : nullptr,
72
+ value.resize.has_value() ? JResizeOptions::fromCpp(value.resize.value()) : nullptr
63
73
  );
64
74
  }
65
75
  };
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JResizeOptions.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 "ResizeOptions.hpp"
12
+
13
+
14
+
15
+ namespace margelo::nitro::nitroimagepipeline {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "ResizeOptions" and the Kotlin data class "ResizeOptions".
21
+ */
22
+ struct JResizeOptions final: public jni::JavaClass<JResizeOptions> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/ResizeOptions;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct ResizeOptions by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ ResizeOptions toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldWidth = clazz->getField<double>("width");
35
+ double width = this->getFieldValue(fieldWidth);
36
+ static const auto fieldHeight = clazz->getField<double>("height");
37
+ double height = this->getFieldValue(fieldHeight);
38
+ return ResizeOptions(
39
+ width,
40
+ height
41
+ );
42
+ }
43
+
44
+ public:
45
+ /**
46
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
47
+ */
48
+ [[maybe_unused]]
49
+ static jni::local_ref<JResizeOptions::javaobject> fromCpp(const ResizeOptions& value) {
50
+ using JSignature = JResizeOptions(double, double);
51
+ static const auto clazz = javaClassStatic();
52
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
53
+ return create(
54
+ clazz,
55
+ value.width,
56
+ value.height
57
+ );
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::nitroimagepipeline
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// JVariant_Double_CornerRadii.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 "JVariant_Double_CornerRadii.hpp"
9
+
10
+ namespace margelo::nitro::nitroimagepipeline {
11
+ /**
12
+ * Converts JVariant_Double_CornerRadii to std::variant<double, CornerRadii>
13
+ */
14
+ std::variant<double, CornerRadii> JVariant_Double_CornerRadii::toCpp() const {
15
+ if (isInstanceOf(JVariant_Double_CornerRadii_impl::First::javaClassStatic())) {
16
+ // It's a `double`
17
+ auto jniValue = static_cast<const JVariant_Double_CornerRadii_impl::First*>(this)->getValue();
18
+ return jniValue;
19
+ } else if (isInstanceOf(JVariant_Double_CornerRadii_impl::Second::javaClassStatic())) {
20
+ // It's a `CornerRadii`
21
+ auto jniValue = static_cast<const JVariant_Double_CornerRadii_impl::Second*>(this)->getValue();
22
+ return jniValue->toCpp();
23
+ }
24
+ throw std::invalid_argument("Variant is unknown Kotlin instance!");
25
+ }
26
+ } // namespace margelo::nitro::nitroimagepipeline
@@ -0,0 +1,70 @@
1
+ ///
2
+ /// JVariant_Double_CornerRadii.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 <variant>
12
+
13
+ #include "CornerRadii.hpp"
14
+ #include <variant>
15
+ #include "JCornerRadii.hpp"
16
+ #include <optional>
17
+
18
+ namespace margelo::nitro::nitroimagepipeline {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_Double_CornerRadii".
24
+ */
25
+ class JVariant_Double_CornerRadii: public jni::JavaClass<JVariant_Double_CornerRadii> {
26
+ public:
27
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/Variant_Double_CornerRadii;";
28
+
29
+ static jni::local_ref<JVariant_Double_CornerRadii> create_0(double value) {
30
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_Double_CornerRadii(double)>("create");
31
+ return method(javaClassStatic(), value);
32
+ }
33
+ static jni::local_ref<JVariant_Double_CornerRadii> create_1(jni::alias_ref<JCornerRadii> value) {
34
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_Double_CornerRadii(jni::alias_ref<JCornerRadii>)>("create");
35
+ return method(javaClassStatic(), value);
36
+ }
37
+
38
+ static jni::local_ref<JVariant_Double_CornerRadii> fromCpp(const std::variant<double, CornerRadii>& variant) {
39
+ switch (variant.index()) {
40
+ case 0: return create_0(std::get<0>(variant));
41
+ case 1: return create_1(JCornerRadii::fromCpp(std::get<1>(variant)));
42
+ default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
43
+ }
44
+ }
45
+
46
+ [[nodiscard]] std::variant<double, CornerRadii> toCpp() const;
47
+ };
48
+
49
+ namespace JVariant_Double_CornerRadii_impl {
50
+ class First final: public jni::JavaClass<First, JVariant_Double_CornerRadii> {
51
+ public:
52
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/Variant_Double_CornerRadii$First;";
53
+
54
+ [[nodiscard]] double getValue() const {
55
+ static const auto field = javaClassStatic()->getField<double>("value");
56
+ return getFieldValue(field);
57
+ }
58
+ };
59
+
60
+ class Second final: public jni::JavaClass<Second, JVariant_Double_CornerRadii> {
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/Variant_Double_CornerRadii$Second;";
63
+
64
+ [[nodiscard]] jni::local_ref<JCornerRadii> getValue() const {
65
+ static const auto field = javaClassStatic()->getField<JCornerRadii>("value");
66
+ return getFieldValue(field);
67
+ }
68
+ };
69
+ } // namespace JVariant_Double_CornerRadii_impl
70
+ } // namespace margelo::nitro::nitroimagepipeline
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// CornerRadii.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
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "CornerRadii".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class CornerRadii(
21
+ @DoNotStrip
22
+ @Keep
23
+ val topLeft: Double?,
24
+ @DoNotStrip
25
+ @Keep
26
+ val topRight: Double?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val bottomLeft: Double?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val bottomRight: Double?
33
+ ) {
34
+ /* primary constructor */
35
+
36
+ override fun equals(other: Any?): Boolean {
37
+ if (this === other) return true
38
+ if (other !is CornerRadii) return false
39
+ return Objects.deepEquals(this.topLeft, other.topLeft)
40
+ && Objects.deepEquals(this.topRight, other.topRight)
41
+ && Objects.deepEquals(this.bottomLeft, other.bottomLeft)
42
+ && Objects.deepEquals(this.bottomRight, other.bottomRight)
43
+ }
44
+
45
+ override fun hashCode(): Int {
46
+ return arrayOf<Any?>(
47
+ topLeft,
48
+ topRight,
49
+ bottomLeft,
50
+ bottomRight
51
+ ).contentDeepHashCode()
52
+ }
53
+
54
+ companion object {
55
+ /**
56
+ * Constructor called from C++
57
+ */
58
+ @DoNotStrip
59
+ @Keep
60
+ @Suppress("unused")
61
+ @JvmStatic
62
+ private fun fromCpp(topLeft: Double?, topRight: Double?, bottomLeft: Double?, bottomRight: Double?): CornerRadii {
63
+ return CornerRadii(topLeft, topRight, bottomLeft, bottomRight)
64
+ }
65
+ }
66
+ }
@@ -26,7 +26,10 @@ data class Options(
26
26
  val cache: CacheOption?,
27
27
  @DoNotStrip
28
28
  @Keep
29
- val cornerRadius: Double?
29
+ val cornerRadius: Variant_Double_CornerRadii?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val resize: ResizeOptions?
30
33
  ) {
31
34
  /* primary constructor */
32
35
 
@@ -36,13 +39,15 @@ data class Options(
36
39
  return Objects.deepEquals(this.blur, other.blur)
37
40
  && Objects.deepEquals(this.cache, other.cache)
38
41
  && Objects.deepEquals(this.cornerRadius, other.cornerRadius)
42
+ && Objects.deepEquals(this.resize, other.resize)
39
43
  }
40
44
 
41
45
  override fun hashCode(): Int {
42
46
  return arrayOf<Any?>(
43
47
  blur,
44
48
  cache,
45
- cornerRadius
49
+ cornerRadius,
50
+ resize
46
51
  ).contentDeepHashCode()
47
52
  }
48
53
 
@@ -54,8 +59,8 @@ data class Options(
54
59
  @Keep
55
60
  @Suppress("unused")
56
61
  @JvmStatic
57
- private fun fromCpp(blur: Double?, cache: CacheOption?, cornerRadius: Double?): Options {
58
- return Options(blur, cache, cornerRadius)
62
+ private fun fromCpp(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?): Options {
63
+ return Options(blur, cache, cornerRadius, resize)
59
64
  }
60
65
  }
61
66
  }
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// ResizeOptions.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
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "ResizeOptions".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class ResizeOptions(
21
+ @DoNotStrip
22
+ @Keep
23
+ val width: Double,
24
+ @DoNotStrip
25
+ @Keep
26
+ val height: Double
27
+ ) {
28
+ /* primary constructor */
29
+
30
+ override fun equals(other: Any?): Boolean {
31
+ if (this === other) return true
32
+ if (other !is ResizeOptions) return false
33
+ return Objects.deepEquals(this.width, other.width)
34
+ && Objects.deepEquals(this.height, other.height)
35
+ }
36
+
37
+ override fun hashCode(): Int {
38
+ return arrayOf<Any?>(
39
+ width,
40
+ height
41
+ ).contentDeepHashCode()
42
+ }
43
+
44
+ companion object {
45
+ /**
46
+ * Constructor called from C++
47
+ */
48
+ @DoNotStrip
49
+ @Keep
50
+ @Suppress("unused")
51
+ @JvmStatic
52
+ private fun fromCpp(width: Double, height: Double): ResizeOptions {
53
+ return ResizeOptions(width, height)
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,62 @@
1
+ ///
2
+ /// Variant_Double_CornerRadii.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 com.facebook.proguard.annotations.DoNotStrip
11
+
12
+
13
+ /**
14
+ * Represents the TypeScript variant "Double | CornerRadii".
15
+ */
16
+ @Suppress("ClassName")
17
+ @DoNotStrip
18
+ sealed class Variant_Double_CornerRadii {
19
+ @DoNotStrip
20
+ data class First(@DoNotStrip val value: Double): Variant_Double_CornerRadii()
21
+ @DoNotStrip
22
+ data class Second(@DoNotStrip val value: CornerRadii): Variant_Double_CornerRadii()
23
+
24
+ inline fun <reified T> asType(): T? {
25
+ return when (this) {
26
+ is First -> (value) as? T
27
+ is Second -> (value) as? T
28
+ }
29
+ }
30
+ inline fun <reified T> isType(): Boolean {
31
+ return asType<T>() != null
32
+ }
33
+ inline fun <R> match(first: (Double) -> R, second: (CornerRadii) -> R): R {
34
+ return when (this) {
35
+ is First -> first(value)
36
+ is Second -> second(value)
37
+ }
38
+ }
39
+
40
+ val isFirst: Boolean
41
+ get() = this is First
42
+ val isSecond: Boolean
43
+ get() = this is Second
44
+
45
+ fun asFirstOrNull(): Double? {
46
+ val value = (this as? First)?.value ?: return null
47
+ return value
48
+ }
49
+ fun asSecondOrNull(): CornerRadii? {
50
+ val value = (this as? Second)?.value ?: return null
51
+ return value
52
+ }
53
+
54
+ companion object {
55
+ @JvmStatic
56
+ @DoNotStrip
57
+ fun create(value: Double): Variant_Double_CornerRadii = First(value)
58
+ @JvmStatic
59
+ @DoNotStrip
60
+ fun create(value: CornerRadii): Variant_Double_CornerRadii = Second(value)
61
+ }
62
+ }
@@ -10,12 +10,16 @@
10
10
  // Forward declarations of C++ defined types
11
11
  // Forward declaration of `CacheOption` to properly resolve imports.
12
12
  namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
13
+ // Forward declaration of `CornerRadii` to properly resolve imports.
14
+ namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
13
15
  // Forward declaration of `HybridImageSpec` to properly resolve imports.
14
16
  namespace margelo::nitro::image { class HybridImageSpec; }
15
17
  // Forward declaration of `HybridNitroImagePipelineSpec` to properly resolve imports.
16
18
  namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpec; }
17
19
  // Forward declaration of `Options` to properly resolve imports.
18
20
  namespace margelo::nitro::nitroimagepipeline { struct Options; }
21
+ // Forward declaration of `ResizeOptions` to properly resolve imports.
22
+ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
19
23
 
20
24
  // Forward declarations of Swift defined types
21
25
  // Forward declaration of `HybridImageSpec_cxx` to properly resolve imports.
@@ -25,8 +29,10 @@ namespace NitroImagePipeline { class HybridNitroImagePipelineSpec_cxx; }
25
29
 
26
30
  // Include C++ defined types
27
31
  #include "CacheOption.hpp"
32
+ #include "CornerRadii.hpp"
28
33
  #include "HybridNitroImagePipelineSpec.hpp"
29
34
  #include "Options.hpp"
35
+ #include "ResizeOptions.hpp"
30
36
  #include <NitroImage/HybridImageSpec.hpp>
31
37
  #include <NitroModules/Promise.hpp>
32
38
  #include <NitroModules/PromiseHolder.hpp>
@@ -36,6 +42,7 @@ namespace NitroImagePipeline { class HybridNitroImagePipelineSpec_cxx; }
36
42
  #include <memory>
37
43
  #include <optional>
38
44
  #include <string>
45
+ #include <variant>
39
46
  #include <vector>
40
47
 
41
48
  /**
@@ -142,6 +149,65 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
142
149
  return optional.value();
143
150
  }
144
151
 
152
+ // pragma MARK: std::variant<double, CornerRadii>
153
+ /**
154
+ * Wrapper struct for `std::variant<double, CornerRadii>`.
155
+ * std::variant cannot be used in Swift because of a Swift bug.
156
+ * Not even specializing it works. So we create a wrapper struct.
157
+ */
158
+ struct std__variant_double__CornerRadii_ final {
159
+ std::variant<double, CornerRadii> variant;
160
+ std__variant_double__CornerRadii_(std::variant<double, CornerRadii> variant): variant(variant) { }
161
+ operator std::variant<double, CornerRadii>() const noexcept {
162
+ return variant;
163
+ }
164
+ inline size_t index() const noexcept {
165
+ return variant.index();
166
+ }
167
+ inline double get_0() const noexcept {
168
+ return std::get<0>(variant);
169
+ }
170
+ inline CornerRadii get_1() const noexcept {
171
+ return std::get<1>(variant);
172
+ }
173
+ };
174
+ inline std__variant_double__CornerRadii_ create_std__variant_double__CornerRadii_(double value) noexcept {
175
+ return std__variant_double__CornerRadii_(value);
176
+ }
177
+ inline std__variant_double__CornerRadii_ create_std__variant_double__CornerRadii_(const CornerRadii& value) noexcept {
178
+ return std__variant_double__CornerRadii_(value);
179
+ }
180
+
181
+ // pragma MARK: std::optional<std::variant<double, CornerRadii>>
182
+ /**
183
+ * Specialized version of `std::optional<std::variant<double, CornerRadii>>`.
184
+ */
185
+ using std__optional_std__variant_double__CornerRadii__ = std::optional<std::variant<double, CornerRadii>>;
186
+ inline std::optional<std::variant<double, CornerRadii>> create_std__optional_std__variant_double__CornerRadii__(const std::variant<double, CornerRadii>& value) noexcept {
187
+ return std::optional<std::variant<double, CornerRadii>>(value);
188
+ }
189
+ inline bool has_value_std__optional_std__variant_double__CornerRadii__(const std::optional<std::variant<double, CornerRadii>>& optional) noexcept {
190
+ return optional.has_value();
191
+ }
192
+ inline std::variant<double, CornerRadii> get_std__optional_std__variant_double__CornerRadii__(const std::optional<std::variant<double, CornerRadii>>& optional) noexcept {
193
+ return optional.value();
194
+ }
195
+
196
+ // pragma MARK: std::optional<ResizeOptions>
197
+ /**
198
+ * Specialized version of `std::optional<ResizeOptions>`.
199
+ */
200
+ using std__optional_ResizeOptions_ = std::optional<ResizeOptions>;
201
+ inline std::optional<ResizeOptions> create_std__optional_ResizeOptions_(const ResizeOptions& value) noexcept {
202
+ return std::optional<ResizeOptions>(value);
203
+ }
204
+ inline bool has_value_std__optional_ResizeOptions_(const std::optional<ResizeOptions>& optional) noexcept {
205
+ return optional.has_value();
206
+ }
207
+ inline ResizeOptions get_std__optional_ResizeOptions_(const std::optional<ResizeOptions>& optional) noexcept {
208
+ return optional.value();
209
+ }
210
+
145
211
  // pragma MARK: std::optional<Options>
146
212
  /**
147
213
  * Specialized version of `std::optional<Options>`.
@@ -10,17 +10,23 @@
10
10
  // Forward declarations of C++ defined types
11
11
  // Forward declaration of `CacheOption` to properly resolve imports.
12
12
  namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
13
+ // Forward declaration of `CornerRadii` to properly resolve imports.
14
+ namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
13
15
  // Forward declaration of `HybridImageSpec` to properly resolve imports.
14
16
  namespace margelo::nitro::image { class HybridImageSpec; }
15
17
  // Forward declaration of `HybridNitroImagePipelineSpec` to properly resolve imports.
16
18
  namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpec; }
17
19
  // Forward declaration of `Options` to properly resolve imports.
18
20
  namespace margelo::nitro::nitroimagepipeline { struct Options; }
21
+ // Forward declaration of `ResizeOptions` to properly resolve imports.
22
+ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
19
23
 
20
24
  // Include C++ defined types
21
25
  #include "CacheOption.hpp"
26
+ #include "CornerRadii.hpp"
22
27
  #include "HybridNitroImagePipelineSpec.hpp"
23
28
  #include "Options.hpp"
29
+ #include "ResizeOptions.hpp"
24
30
  #include <NitroImage/HybridImageSpec.hpp>
25
31
  #include <NitroModules/Promise.hpp>
26
32
  #include <NitroModules/Result.hpp>
@@ -28,6 +34,7 @@ namespace margelo::nitro::nitroimagepipeline { struct Options; }
28
34
  #include <memory>
29
35
  #include <optional>
30
36
  #include <string>
37
+ #include <variant>
31
38
  #include <vector>
32
39
 
33
40
  // C++ helpers for Swift