react-native-nitro-image-pipeline 1.5.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 +142 -18
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +72 -16
- 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 +88 -24
- package/ios/PipelineImageLoader.swift +108 -18
- package/lib/commonjs/NativePipelineImage.js +20 -4
- 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 +13 -0
- 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/resolveImageSource.js +89 -0
- package/lib/commonjs/resolveImageSource.js.map +1 -0
- package/lib/commonjs/useImage.js +14 -6
- package/lib/commonjs/useImage.js.map +1 -1
- package/lib/commonjs/usePipelineImageLoader.js +114 -11
- package/lib/commonjs/usePipelineImageLoader.js.map +1 -1
- package/lib/module/NativePipelineImage.js +20 -4
- 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 +1 -0
- 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/resolveImageSource.js +83 -0
- package/lib/module/resolveImageSource.js.map +1 -0
- package/lib/module/useImage.js +14 -6
- package/lib/module/useImage.js.map +1 -1
- package/lib/module/usePipelineImageLoader.js +115 -12
- package/lib/module/usePipelineImageLoader.js.map +1 -1
- package/lib/typescript/src/NativePipelineImage.d.ts +51 -5
- package/lib/typescript/src/NativePipelineImage.d.ts.map +1 -1
- package/lib/typescript/src/PipelineImage.d.ts +35 -3
- package/lib/typescript/src/PipelineImage.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -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/resolveImageSource.d.ts +56 -0
- package/lib/typescript/src/resolveImageSource.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +95 -8
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
- package/lib/typescript/src/useImage.d.ts +13 -6
- package/lib/typescript/src/useImage.d.ts.map +1 -1
- package/lib/typescript/src/usePipelineImageLoader.d.ts +7 -3
- 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 +75 -6
- package/src/PipelineImage.tsx +46 -3
- package/src/index.ts +6 -0
- package/src/resizeForStyle.ts +3 -1
- package/src/resolveImageSource.ts +83 -0
- package/src/specs/nitro-image-toolkit.nitro.ts +96 -8
- package/src/useImage.ts +38 -17
- package/src/usePipelineImageLoader.ts +126 -11
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);
|
|
@@ -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
|
}
|