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.
Files changed (78) hide show
  1. package/README.md +88 -13
  2. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +51 -20
  3. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/PipelineImageLoader.kt +47 -8
  4. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/FitGeometry.kt +104 -0
  5. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/PipelineRoundedCornersTransformation.kt +103 -0
  6. package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/ResizeTransformation.kt +69 -16
  7. package/ios/FitResizeProcessor.swift +127 -0
  8. package/ios/HybridNitroImagePipeline.swift +41 -15
  9. package/ios/PipelineImageLoader.swift +107 -17
  10. package/lib/commonjs/NativePipelineImage.js +18 -3
  11. package/lib/commonjs/NativePipelineImage.js.map +1 -1
  12. package/lib/commonjs/PipelineImage.js +13 -1
  13. package/lib/commonjs/PipelineImage.js.map +1 -1
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/resizeForStyle.js +3 -1
  16. package/lib/commonjs/resizeForStyle.js.map +1 -1
  17. package/lib/commonjs/useImage.js +6 -2
  18. package/lib/commonjs/useImage.js.map +1 -1
  19. package/lib/commonjs/usePipelineImageLoader.js +107 -9
  20. package/lib/commonjs/usePipelineImageLoader.js.map +1 -1
  21. package/lib/module/NativePipelineImage.js +18 -3
  22. package/lib/module/NativePipelineImage.js.map +1 -1
  23. package/lib/module/PipelineImage.js +13 -1
  24. package/lib/module/PipelineImage.js.map +1 -1
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/resizeForStyle.js +3 -1
  27. package/lib/module/resizeForStyle.js.map +1 -1
  28. package/lib/module/useImage.js +6 -2
  29. package/lib/module/useImage.js.map +1 -1
  30. package/lib/module/usePipelineImageLoader.js +108 -10
  31. package/lib/module/usePipelineImageLoader.js.map +1 -1
  32. package/lib/typescript/src/NativePipelineImage.d.ts +44 -3
  33. package/lib/typescript/src/NativePipelineImage.d.ts.map +1 -1
  34. package/lib/typescript/src/PipelineImage.d.ts +28 -1
  35. package/lib/typescript/src/PipelineImage.d.ts.map +1 -1
  36. package/lib/typescript/src/index.d.ts +1 -1
  37. package/lib/typescript/src/index.d.ts.map +1 -1
  38. package/lib/typescript/src/resizeForStyle.d.ts +3 -1
  39. package/lib/typescript/src/resizeForStyle.d.ts.map +1 -1
  40. package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +83 -8
  41. package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
  42. package/lib/typescript/src/useImage.d.ts +3 -2
  43. package/lib/typescript/src/useImage.d.ts.map +1 -1
  44. package/lib/typescript/src/usePipelineImageLoader.d.ts +3 -1
  45. package/lib/typescript/src/usePipelineImageLoader.d.ts.map +1 -1
  46. package/nitrogen/generated/android/NitroImagePipelineOnLoad.cpp +4 -0
  47. package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
  48. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  49. package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +8 -0
  50. package/nitrogen/generated/android/c++/JOptions.hpp +2 -0
  51. package/nitrogen/generated/android/c++/JResizeFit.hpp +64 -0
  52. package/nitrogen/generated/android/c++/JResizeOptions.hpp +14 -4
  53. package/nitrogen/generated/android/c++/JViewOptions.hpp +42 -3
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Func_void_double_double.kt +78 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Func_void_std__string.kt +78 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeFit.kt +25 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ResizeOptions.kt +14 -4
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ViewOptions.kt +29 -5
  59. package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.cpp +16 -0
  60. package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +107 -0
  61. package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +4 -0
  62. package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +4 -0
  63. package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
  64. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  65. package/nitrogen/generated/ios/swift/ResizeFit.swift +48 -0
  66. package/nitrogen/generated/ios/swift/ResizeOptions.swift +31 -2
  67. package/nitrogen/generated/ios/swift/ViewOptions.swift +82 -1
  68. package/nitrogen/generated/shared/c++/ResizeFit.hpp +84 -0
  69. package/nitrogen/generated/shared/c++/ResizeOptions.hpp +14 -4
  70. package/nitrogen/generated/shared/c++/ViewOptions.hpp +24 -3
  71. package/package.json +1 -1
  72. package/src/NativePipelineImage.tsx +67 -3
  73. package/src/PipelineImage.tsx +39 -1
  74. package/src/index.ts +1 -0
  75. package/src/resizeForStyle.ts +3 -1
  76. package/src/specs/nitro-image-toolkit.nitro.ts +84 -8
  77. package/src/useImage.ts +13 -3
  78. package/src/usePipelineImageLoader.ts +115 -8
@@ -20,6 +20,8 @@ namespace margelo::nitro::image { class HybridImageSpec; }
20
20
  namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpec; }
21
21
  // Forward declaration of `Options` to properly resolve imports.
22
22
  namespace margelo::nitro::nitroimagepipeline { struct Options; }
23
+ // Forward declaration of `ResizeFit` to properly resolve imports.
24
+ namespace margelo::nitro::nitroimagepipeline { enum class ResizeFit; }
23
25
  // Forward declaration of `ResizeOptions` to properly resolve imports.
24
26
  namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
25
27
  // Forward declaration of `ViewOptions` to properly resolve imports.
@@ -38,6 +40,7 @@ namespace NitroImagePipeline { class HybridNitroImagePipelineSpec_cxx; }
38
40
  #include "CornerRadii.hpp"
39
41
  #include "HybridNitroImagePipelineSpec.hpp"
40
42
  #include "Options.hpp"
43
+ #include "ResizeFit.hpp"
41
44
  #include "ResizeOptions.hpp"
42
45
  #include "ViewOptions.hpp"
43
46
  #include <NitroImage/HybridImageLoaderSpec.hpp>
@@ -201,6 +204,36 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
201
204
  return optional.value();
202
205
  }
203
206
 
207
+ // pragma MARK: std::optional<ResizeFit>
208
+ /**
209
+ * Specialized version of `std::optional<ResizeFit>`.
210
+ */
211
+ using std__optional_ResizeFit_ = std::optional<ResizeFit>;
212
+ inline std::optional<ResizeFit> create_std__optional_ResizeFit_(const ResizeFit& value) noexcept {
213
+ return std::optional<ResizeFit>(value);
214
+ }
215
+ inline bool has_value_std__optional_ResizeFit_(const std::optional<ResizeFit>& optional) noexcept {
216
+ return optional.has_value();
217
+ }
218
+ inline ResizeFit get_std__optional_ResizeFit_(const std::optional<ResizeFit>& optional) noexcept {
219
+ return optional.value();
220
+ }
221
+
222
+ // pragma MARK: std::optional<bool>
223
+ /**
224
+ * Specialized version of `std::optional<bool>`.
225
+ */
226
+ using std__optional_bool_ = std::optional<bool>;
227
+ inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
228
+ return std::optional<bool>(value);
229
+ }
230
+ inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
231
+ return optional.has_value();
232
+ }
233
+ inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
234
+ return optional.value();
235
+ }
236
+
204
237
  // pragma MARK: std::optional<ResizeOptions>
205
238
  /**
206
239
  * Specialized version of `std::optional<ResizeOptions>`.
@@ -243,6 +276,80 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
243
276
  using std__weak_ptr_margelo__nitro__image__HybridImageLoaderSpec_ = std::weak_ptr<margelo::nitro::image::HybridImageLoaderSpec>;
244
277
  inline std__weak_ptr_margelo__nitro__image__HybridImageLoaderSpec_ weakify_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(const std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>& strong) noexcept { return strong; }
245
278
 
279
+ // pragma MARK: std::function<void(double /* width */, double /* height */)>
280
+ /**
281
+ * Specialized version of `std::function<void(double, double)>`.
282
+ */
283
+ using Func_void_double_double = std::function<void(double /* width */, double /* height */)>;
284
+ /**
285
+ * Wrapper class for a `std::function<void(double / * width * /, double / * height * /)>`, this can be used from Swift.
286
+ */
287
+ class Func_void_double_double_Wrapper final {
288
+ public:
289
+ explicit Func_void_double_double_Wrapper(std::function<void(double /* width */, double /* height */)>&& func): _function(std::make_unique<std::function<void(double /* width */, double /* height */)>>(std::move(func))) {}
290
+ inline void call(double width, double height) const noexcept {
291
+ _function->operator()(width, height);
292
+ }
293
+ private:
294
+ std::unique_ptr<std::function<void(double /* width */, double /* height */)>> _function;
295
+ } SWIFT_NONCOPYABLE;
296
+ Func_void_double_double create_Func_void_double_double(void* NON_NULL swiftClosureWrapper) noexcept;
297
+ inline Func_void_double_double_Wrapper wrap_Func_void_double_double(Func_void_double_double value) noexcept {
298
+ return Func_void_double_double_Wrapper(std::move(value));
299
+ }
300
+
301
+ // pragma MARK: std::optional<std::function<void(double /* width */, double /* height */)>>
302
+ /**
303
+ * Specialized version of `std::optional<std::function<void(double / * width * /, double / * height * /)>>`.
304
+ */
305
+ using std__optional_std__function_void_double____width_____double____height______ = std::optional<std::function<void(double /* width */, double /* height */)>>;
306
+ inline std::optional<std::function<void(double /* width */, double /* height */)>> create_std__optional_std__function_void_double____width_____double____height______(const std::function<void(double /* width */, double /* height */)>& value) noexcept {
307
+ return std::optional<std::function<void(double /* width */, double /* height */)>>(value);
308
+ }
309
+ inline bool has_value_std__optional_std__function_void_double____width_____double____height______(const std::optional<std::function<void(double /* width */, double /* height */)>>& optional) noexcept {
310
+ return optional.has_value();
311
+ }
312
+ inline std::function<void(double /* width */, double /* height */)> get_std__optional_std__function_void_double____width_____double____height______(const std::optional<std::function<void(double /* width */, double /* height */)>>& optional) noexcept {
313
+ return optional.value();
314
+ }
315
+
316
+ // pragma MARK: std::function<void(const std::string& /* message */)>
317
+ /**
318
+ * Specialized version of `std::function<void(const std::string&)>`.
319
+ */
320
+ using Func_void_std__string = std::function<void(const std::string& /* message */)>;
321
+ /**
322
+ * Wrapper class for a `std::function<void(const std::string& / * message * /)>`, this can be used from Swift.
323
+ */
324
+ class Func_void_std__string_Wrapper final {
325
+ public:
326
+ explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* message */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* message */)>>(std::move(func))) {}
327
+ inline void call(std::string message) const noexcept {
328
+ _function->operator()(message);
329
+ }
330
+ private:
331
+ std::unique_ptr<std::function<void(const std::string& /* message */)>> _function;
332
+ } SWIFT_NONCOPYABLE;
333
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
334
+ inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
335
+ return Func_void_std__string_Wrapper(std::move(value));
336
+ }
337
+
338
+ // pragma MARK: std::optional<std::function<void(const std::string& /* message */)>>
339
+ /**
340
+ * Specialized version of `std::optional<std::function<void(const std::string& / * message * /)>>`.
341
+ */
342
+ using std__optional_std__function_void_const_std__string_____message______ = std::optional<std::function<void(const std::string& /* message */)>>;
343
+ inline std::optional<std::function<void(const std::string& /* message */)>> create_std__optional_std__function_void_const_std__string_____message______(const std::function<void(const std::string& /* message */)>& value) noexcept {
344
+ return std::optional<std::function<void(const std::string& /* message */)>>(value);
345
+ }
346
+ inline bool has_value_std__optional_std__function_void_const_std__string_____message______(const std::optional<std::function<void(const std::string& /* message */)>>& optional) noexcept {
347
+ return optional.has_value();
348
+ }
349
+ inline std::function<void(const std::string& /* message */)> get_std__optional_std__function_void_const_std__string_____message______(const std::optional<std::function<void(const std::string& /* message */)>>& optional) noexcept {
350
+ return optional.value();
351
+ }
352
+
246
353
  // pragma MARK: std::optional<ViewOptions>
247
354
  /**
248
355
  * Specialized version of `std::optional<ViewOptions>`.
@@ -20,6 +20,8 @@ namespace margelo::nitro::image { class HybridImageSpec; }
20
20
  namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpec; }
21
21
  // Forward declaration of `Options` to properly resolve imports.
22
22
  namespace margelo::nitro::nitroimagepipeline { struct Options; }
23
+ // Forward declaration of `ResizeFit` to properly resolve imports.
24
+ namespace margelo::nitro::nitroimagepipeline { enum class ResizeFit; }
23
25
  // Forward declaration of `ResizeOptions` to properly resolve imports.
24
26
  namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
25
27
  // Forward declaration of `ViewOptions` to properly resolve imports.
@@ -30,6 +32,7 @@ namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
30
32
  #include "CornerRadii.hpp"
31
33
  #include "HybridNitroImagePipelineSpec.hpp"
32
34
  #include "Options.hpp"
35
+ #include "ResizeFit.hpp"
33
36
  #include "ResizeOptions.hpp"
34
37
  #include "ViewOptions.hpp"
35
38
  #include <NitroImage/HybridImageLoaderSpec.hpp>
@@ -37,6 +40,7 @@ namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
37
40
  #include <NitroModules/Promise.hpp>
38
41
  #include <NitroModules/Result.hpp>
39
42
  #include <exception>
43
+ #include <functional>
40
44
  #include <memory>
41
45
  #include <optional>
42
46
  #include <string>
@@ -22,6 +22,8 @@ namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
22
22
  namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
23
23
  // Forward declaration of `ResizeOptions` to properly resolve imports.
24
24
  namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
25
+ // Forward declaration of `ResizeFit` to properly resolve imports.
26
+ namespace margelo::nitro::nitroimagepipeline { enum class ResizeFit; }
25
27
  // Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
26
28
  namespace margelo::nitro::image { class HybridImageLoaderSpec; }
27
29
  // Forward declaration of `ViewOptions` to properly resolve imports.
@@ -37,8 +39,10 @@ namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
37
39
  #include "CornerRadii.hpp"
38
40
  #include <variant>
39
41
  #include "ResizeOptions.hpp"
42
+ #include "ResizeFit.hpp"
40
43
  #include <NitroImage/HybridImageLoaderSpec.hpp>
41
44
  #include "ViewOptions.hpp"
45
+ #include <functional>
42
46
  #include <vector>
43
47
 
44
48
  #include "NitroImagePipeline-Swift-Cxx-Umbrella.hpp"
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double_double.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ width: Double, _ height: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double_double {
15
+ public typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
16
+
17
+ private let closure: (_ width: Double, _ height: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ width: Double, _ height: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(width: Double, height: Double) -> Void {
25
+ self.closure(width, height)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double_double {
44
+ return Unmanaged<Func_void_double_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__string.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ message: String) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__string {
15
+ public typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
16
+
17
+ private let closure: (_ message: String) -> Void
18
+
19
+ public init(_ closure: @escaping (_ message: String) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(message: std.string) -> Void {
25
+ self.closure(String(message))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__string`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
44
+ return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// ResizeFit.swift
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
+ /**
9
+ * Represents the JS union `ResizeFit`, backed by a C++ enum.
10
+ */
11
+ public typealias ResizeFit = margelo.nitro.nitroimagepipeline.ResizeFit
12
+
13
+ public extension ResizeFit {
14
+ /**
15
+ * Get a ResizeFit for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "cover":
21
+ self = .cover
22
+ case "contain":
23
+ self = .contain
24
+ case "stretch":
25
+ self = .stretch
26
+ case "center":
27
+ self = .center
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this ResizeFit represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .cover:
39
+ return "cover"
40
+ case .contain:
41
+ return "contain"
42
+ case .stretch:
43
+ return "stretch"
44
+ case .center:
45
+ return "center"
46
+ }
47
+ }
48
+ }
@@ -18,8 +18,20 @@ public extension ResizeOptions {
18
18
  /**
19
19
  * Create a new instance of `ResizeOptions`.
20
20
  */
21
- init(width: Double, height: Double) {
22
- self.init(width, height)
21
+ init(width: Double, height: Double, fit: ResizeFit?, allowUpscale: Bool?) {
22
+ self.init(width, height, { () -> bridge.std__optional_ResizeFit_ in
23
+ if let __unwrappedValue = fit {
24
+ return bridge.create_std__optional_ResizeFit_(__unwrappedValue)
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_bool_ in
29
+ if let __unwrappedValue = allowUpscale {
30
+ return bridge.create_std__optional_bool_(__unwrappedValue)
31
+ } else {
32
+ return .init()
33
+ }
34
+ }())
23
35
  }
24
36
 
25
37
  @inline(__always)
@@ -31,4 +43,21 @@ public extension ResizeOptions {
31
43
  var height: Double {
32
44
  return self.__height
33
45
  }
46
+
47
+ @inline(__always)
48
+ var fit: ResizeFit? {
49
+ return self.__fit.value
50
+ }
51
+
52
+ @inline(__always)
53
+ var allowUpscale: Bool? {
54
+ return { () -> Bool? in
55
+ if bridge.has_value_std__optional_bool_(self.__allowUpscale) {
56
+ let __unwrapped = bridge.get_std__optional_bool_(self.__allowUpscale)
57
+ return __unwrapped
58
+ } else {
59
+ return nil
60
+ }
61
+ }()
62
+ }
34
63
  }
@@ -18,7 +18,7 @@ public extension ViewOptions {
18
18
  /**
19
19
  * Create a new instance of `ViewOptions`.
20
20
  */
21
- init(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?) {
21
+ init(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?, fit: ResizeFit?, allowUpscale: Bool?, onLoad: ((_ width: Double, _ height: Double) -> Void)?, onError: ((_ message: String) -> Void)?) {
22
22
  self.init({ () -> bridge.std__optional_double_ in
23
23
  if let __unwrappedValue = blur {
24
24
  return bridge.create_std__optional_double_(__unwrappedValue)
@@ -50,6 +50,36 @@ public extension ViewOptions {
50
50
  } else {
51
51
  return .init()
52
52
  }
53
+ }(), { () -> bridge.std__optional_ResizeFit_ in
54
+ if let __unwrappedValue = fit {
55
+ return bridge.create_std__optional_ResizeFit_(__unwrappedValue)
56
+ } else {
57
+ return .init()
58
+ }
59
+ }(), { () -> bridge.std__optional_bool_ in
60
+ if let __unwrappedValue = allowUpscale {
61
+ return bridge.create_std__optional_bool_(__unwrappedValue)
62
+ } else {
63
+ return .init()
64
+ }
65
+ }(), { () -> bridge.std__optional_std__function_void_double____width_____double____height______ in
66
+ if let __unwrappedValue = onLoad {
67
+ return bridge.create_std__optional_std__function_void_double____width_____double____height______({ () -> bridge.Func_void_double_double in
68
+ let __closureWrapper = Func_void_double_double(__unwrappedValue)
69
+ return bridge.create_Func_void_double_double(__closureWrapper.toUnsafe())
70
+ }())
71
+ } else {
72
+ return .init()
73
+ }
74
+ }(), { () -> bridge.std__optional_std__function_void_const_std__string_____message______ in
75
+ if let __unwrappedValue = onError {
76
+ return bridge.create_std__optional_std__function_void_const_std__string_____message______({ () -> bridge.Func_void_std__string in
77
+ let __closureWrapper = Func_void_std__string(__unwrappedValue)
78
+ return bridge.create_Func_void_std__string(__closureWrapper.toUnsafe())
79
+ }())
80
+ } else {
81
+ return .init()
82
+ }
53
83
  }())
54
84
  }
55
85
 
@@ -98,4 +128,55 @@ public extension ViewOptions {
98
128
  var resize: ResizeOptions? {
99
129
  return self.__resize.value
100
130
  }
131
+
132
+ @inline(__always)
133
+ var fit: ResizeFit? {
134
+ return self.__fit.value
135
+ }
136
+
137
+ @inline(__always)
138
+ var allowUpscale: Bool? {
139
+ return { () -> Bool? in
140
+ if bridge.has_value_std__optional_bool_(self.__allowUpscale) {
141
+ let __unwrapped = bridge.get_std__optional_bool_(self.__allowUpscale)
142
+ return __unwrapped
143
+ } else {
144
+ return nil
145
+ }
146
+ }()
147
+ }
148
+
149
+ @inline(__always)
150
+ var onLoad: ((_ width: Double, _ height: Double) -> Void)? {
151
+ return { () -> ((_ width: Double, _ height: Double) -> Void)? in
152
+ if bridge.has_value_std__optional_std__function_void_double____width_____double____height______(self.__onLoad) {
153
+ let __unwrapped = bridge.get_std__optional_std__function_void_double____width_____double____height______(self.__onLoad)
154
+ return { () -> (Double, Double) -> Void in
155
+ let __wrappedFunction = bridge.wrap_Func_void_double_double(__unwrapped)
156
+ return { (__width: Double, __height: Double) -> Void in
157
+ __wrappedFunction.call(__width, __height)
158
+ }
159
+ }()
160
+ } else {
161
+ return nil
162
+ }
163
+ }()
164
+ }
165
+
166
+ @inline(__always)
167
+ var onError: ((_ message: String) -> Void)? {
168
+ return { () -> ((_ message: String) -> Void)? in
169
+ if bridge.has_value_std__optional_std__function_void_const_std__string_____message______(self.__onError) {
170
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____message______(self.__onError)
171
+ return { () -> (String) -> Void in
172
+ let __wrappedFunction = bridge.wrap_Func_void_std__string(__unwrapped)
173
+ return { (__message: String) -> Void in
174
+ __wrappedFunction.call(std.string(__message))
175
+ }
176
+ }()
177
+ } else {
178
+ return nil
179
+ }
180
+ }()
181
+ }
101
182
  }
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// ResizeFit.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitroimagepipeline {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ResizeFit).
30
+ */
31
+ enum class ResizeFit {
32
+ COVER SWIFT_NAME(cover) = 0,
33
+ CONTAIN SWIFT_NAME(contain) = 1,
34
+ STRETCH SWIFT_NAME(stretch) = 2,
35
+ CENTER SWIFT_NAME(center) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::nitroimagepipeline
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ ResizeFit <> JS ResizeFit (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::nitroimagepipeline::ResizeFit> final {
45
+ static inline margelo::nitro::nitroimagepipeline::ResizeFit fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
48
+ case hashString("cover"): return margelo::nitro::nitroimagepipeline::ResizeFit::COVER;
49
+ case hashString("contain"): return margelo::nitro::nitroimagepipeline::ResizeFit::CONTAIN;
50
+ case hashString("stretch"): return margelo::nitro::nitroimagepipeline::ResizeFit::STRETCH;
51
+ case hashString("center"): return margelo::nitro::nitroimagepipeline::ResizeFit::CENTER;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ResizeFit - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroimagepipeline::ResizeFit arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::nitroimagepipeline::ResizeFit::COVER: return JSIConverter<std::string>::toJSI(runtime, "cover");
59
+ case margelo::nitro::nitroimagepipeline::ResizeFit::CONTAIN: return JSIConverter<std::string>::toJSI(runtime, "contain");
60
+ case margelo::nitro::nitroimagepipeline::ResizeFit::STRETCH: return JSIConverter<std::string>::toJSI(runtime, "stretch");
61
+ case margelo::nitro::nitroimagepipeline::ResizeFit::CENTER: return JSIConverter<std::string>::toJSI(runtime, "center");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert ResizeFit to JS - invalid value: "
64
+ + std::to_string(static_cast<int>(arg)) + "!");
65
+ }
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isString()) {
69
+ return false;
70
+ }
71
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
72
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
73
+ case hashString("cover"):
74
+ case hashString("contain"):
75
+ case hashString("stretch"):
76
+ case hashString("center"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -28,9 +28,11 @@
28
28
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
29
  #endif
30
30
 
31
+ // Forward declaration of `ResizeFit` to properly resolve imports.
32
+ namespace margelo::nitro::nitroimagepipeline { enum class ResizeFit; }
31
33
 
32
-
33
-
34
+ #include "ResizeFit.hpp"
35
+ #include <optional>
34
36
 
35
37
  namespace margelo::nitro::nitroimagepipeline {
36
38
 
@@ -41,10 +43,12 @@ namespace margelo::nitro::nitroimagepipeline {
41
43
  public:
42
44
  double width SWIFT_PRIVATE;
43
45
  double height SWIFT_PRIVATE;
46
+ std::optional<ResizeFit> fit SWIFT_PRIVATE;
47
+ std::optional<bool> allowUpscale SWIFT_PRIVATE;
44
48
 
45
49
  public:
46
50
  ResizeOptions() = default;
47
- explicit ResizeOptions(double width, double height): width(width), height(height) {}
51
+ explicit ResizeOptions(double width, double height, std::optional<ResizeFit> fit, std::optional<bool> allowUpscale): width(width), height(height), fit(fit), allowUpscale(allowUpscale) {}
48
52
 
49
53
  public:
50
54
  friend bool operator==(const ResizeOptions& lhs, const ResizeOptions& rhs) = default;
@@ -61,13 +65,17 @@ namespace margelo::nitro {
61
65
  jsi::Object obj = arg.asObject(runtime);
62
66
  return margelo::nitro::nitroimagepipeline::ResizeOptions(
63
67
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
64
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
69
+ JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::ResizeFit>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fit"))),
70
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowUpscale")))
65
71
  );
66
72
  }
67
73
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroimagepipeline::ResizeOptions& arg) {
68
74
  jsi::Object obj(runtime);
69
75
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
70
76
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fit"), JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::ResizeFit>>::toJSI(runtime, arg.fit));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowUpscale"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowUpscale));
71
79
  return obj;
72
80
  }
73
81
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -80,6 +88,8 @@ namespace margelo::nitro {
80
88
  }
81
89
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
82
90
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
91
+ if (!JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::ResizeFit>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fit")))) return false;
92
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowUpscale")))) return false;
83
93
  return true;
84
94
  }
85
95
  };