react-native-nitro-image-pipeline 1.4.0 → 1.5.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 +72 -5
- package/android/CMakeLists.txt +4 -0
- package/android/src/main/cpp/GaussianBlur.cpp +165 -0
- package/android/src/main/cpp/GaussianBlur.hpp +52 -0
- package/android/src/main/cpp/GaussianBlurJni.cpp +50 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +141 -74
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/PipelineImageLoader.kt +177 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/BlurTransformation.kt +36 -81
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/HardwareBitmapTransformation.kt +45 -0
- package/ios/GaussianBlur.swift +48 -9
- package/ios/HybridNitroImagePipeline.swift +63 -33
- package/ios/PipelineImageLoader.swift +195 -0
- package/ios/RoundedCornersProcessor.swift +5 -0
- package/lib/commonjs/NativePipelineImage.js +71 -0
- package/lib/commonjs/NativePipelineImage.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/usePipelineImageLoader.js +69 -0
- package/lib/commonjs/usePipelineImageLoader.js.map +1 -0
- package/lib/module/NativePipelineImage.js +67 -0
- package/lib/module/NativePipelineImage.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/usePipelineImageLoader.js +65 -0
- package/lib/module/usePipelineImageLoader.js.map +1 -0
- package/lib/typescript/src/NativePipelineImage.d.ts +66 -0
- package/lib/typescript/src/NativePipelineImage.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +44 -1
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
- package/lib/typescript/src/usePipelineImageLoader.d.ts +15 -0
- package/lib/typescript/src/usePipelineImageLoader.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +13 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JViewOptions.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipelineSpec.kt +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ViewOptions.kt +66 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.cpp +10 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +44 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec_cxx.swift +15 -0
- package/nitrogen/generated/ios/swift/ViewOptions.swift +101 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.hpp +7 -0
- package/nitrogen/generated/shared/c++/ViewOptions.hpp +104 -0
- package/package.json +4 -3
- package/src/NativePipelineImage.tsx +103 -0
- package/src/index.ts +7 -0
- package/src/specs/nitro-image-toolkit.nitro.ts +45 -1
- package/src/usePipelineImageLoader.ts +82 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Image } from 'react-native-nitro-image';
|
|
1
|
+
import type { Image, ImageLoader } from 'react-native-nitro-image';
|
|
2
2
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
3
3
|
export type CacheOption = 'memory' | 'disk' | 'none';
|
|
4
4
|
/**
|
|
@@ -60,11 +60,54 @@ export type Options = {
|
|
|
60
60
|
*/
|
|
61
61
|
resize?: ResizeOptions;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for {@linkcode NitroImagePipeline.createImageLoader}. Unlike
|
|
65
|
+
* {@linkcode Options} (used by `loadImage`, where values are bitmap pixels),
|
|
66
|
+
* `blur` and `cornerRadius` here are in **points** (density-independent):
|
|
67
|
+
* the loader runs inside a view and converts to pixels natively with the
|
|
68
|
+
* screen scale. The one exception is {@linkcode resize}, which stays an
|
|
69
|
+
* explicit **pixel** size like everywhere else in the library.
|
|
70
|
+
*/
|
|
71
|
+
export type ViewOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* Gaussian blur sigma in **points**. Multiplied by the screen scale
|
|
74
|
+
* natively, so the same value looks the same on every device.
|
|
75
|
+
* @default 0 (no blur)
|
|
76
|
+
*/
|
|
77
|
+
blur?: number;
|
|
78
|
+
cache?: CacheOption;
|
|
79
|
+
/**
|
|
80
|
+
* Corner radius in **points**, uniform or per-corner. Converted to pixels
|
|
81
|
+
* with the screen scale and baked into the bitmap at the display size.
|
|
82
|
+
* @default 0 (square corners)
|
|
83
|
+
*/
|
|
84
|
+
cornerRadius?: number | CornerRadii;
|
|
85
|
+
/**
|
|
86
|
+
* Target bitmap size in **pixels**, overriding the size measured from the
|
|
87
|
+
* view. Rarely needed — without it the loader resizes to the view's
|
|
88
|
+
* laid-out size × screen scale, which is what you want in a UI.
|
|
89
|
+
* @default undefined (measure the view)
|
|
90
|
+
*/
|
|
91
|
+
resize?: ResizeOptions;
|
|
92
|
+
};
|
|
63
93
|
export interface NitroImagePipeline extends HybridObject<{
|
|
64
94
|
ios: 'swift';
|
|
65
95
|
android: 'kotlin';
|
|
66
96
|
}> {
|
|
67
97
|
loadImage(url: string, options?: Options): Promise<Image>;
|
|
98
|
+
/**
|
|
99
|
+
* Creates an {@linkcode ImageLoader} for `url` that a `<NativeNitroImage>`
|
|
100
|
+
* view drives entirely natively: the request starts when the view attaches
|
|
101
|
+
* to the window — at the view's own laid-out size, with no JS round trips —
|
|
102
|
+
* and is cancelled (and the bitmap released) when it detaches, so
|
|
103
|
+
* off-screen list cells stop costing memory. Loads go through the same
|
|
104
|
+
* pipeline and caches as {@linkcode loadImage}/{@linkcode preLoadImage}.
|
|
105
|
+
*
|
|
106
|
+
* `options` are in **points** (see {@linkcode ViewOptions}); the loader
|
|
107
|
+
* applies the screen scale natively. If the view has no size yet when it
|
|
108
|
+
* attaches, the load waits for its first layout.
|
|
109
|
+
*/
|
|
110
|
+
createImageLoader(url: string, options?: ViewOptions): ImageLoader;
|
|
68
111
|
preLoadImage(url: string): Promise<void>;
|
|
69
112
|
preLoadImages(urls: string[]): Promise<void>;
|
|
70
113
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-image-toolkit.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/nitro-image-toolkit.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"nitro-image-toolkit.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/nitro-image-toolkit.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,YAAY,CAAC;IACvD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACnE,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAG3D;;;;;;;;OAQG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ImageLoader } from 'react-native-nitro-image';
|
|
2
|
+
import type { ViewOptions } from './specs/nitro-image-toolkit.nitro';
|
|
3
|
+
/**
|
|
4
|
+
* Creates (and memoizes) an {@linkcode ImageLoader} for `url` to pass to
|
|
5
|
+
* `<NativeNitroImage image={...} />`. The view drives it entirely natively:
|
|
6
|
+
* the request starts when the view attaches — at the view's laid-out size,
|
|
7
|
+
* with no JS round trips — and is cancelled when it detaches. See
|
|
8
|
+
* {@linkcode NitroImagePipeline.createImageLoader}.
|
|
9
|
+
*
|
|
10
|
+
* `blur`/`cornerRadius` are in **points** (unlike `useImage`, where they are
|
|
11
|
+
* bitmap pixels); the screen scale is applied natively. Inline object
|
|
12
|
+
* literals are fine — options are compared by value, not identity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usePipelineImageLoader(url: string, options?: ViewOptions): ImageLoader;
|
|
15
|
+
//# sourceMappingURL=usePipelineImageLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePipelineImageLoader.d.ts","sourceRoot":"","sources":["../../../src/usePipelineImageLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,WAAW,CA0Db"}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
11
11
|
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
12
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
12
14
|
// Forward declaration of `Options` to properly resolve imports.
|
|
13
15
|
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
14
16
|
// Forward declaration of `CacheOption` to properly resolve imports.
|
|
@@ -17,12 +19,16 @@ namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
|
17
19
|
namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
|
|
18
20
|
// Forward declaration of `ResizeOptions` to properly resolve imports.
|
|
19
21
|
namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
22
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
20
24
|
|
|
21
25
|
#include <memory>
|
|
22
26
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
23
27
|
#include <NitroModules/Promise.hpp>
|
|
24
28
|
#include <NitroModules/JPromise.hpp>
|
|
25
29
|
#include <NitroImage/JHybridImageSpec.hpp>
|
|
30
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
31
|
+
#include <NitroImage/JHybridImageLoaderSpec.hpp>
|
|
26
32
|
#include <NitroModules/JUnit.hpp>
|
|
27
33
|
#include <string>
|
|
28
34
|
#include "Options.hpp"
|
|
@@ -36,6 +42,8 @@ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
|
36
42
|
#include "JCornerRadii.hpp"
|
|
37
43
|
#include "ResizeOptions.hpp"
|
|
38
44
|
#include "JResizeOptions.hpp"
|
|
45
|
+
#include "ViewOptions.hpp"
|
|
46
|
+
#include "JViewOptions.hpp"
|
|
39
47
|
#include <vector>
|
|
40
48
|
|
|
41
49
|
namespace margelo::nitro::nitroimagepipeline {
|
|
@@ -87,6 +95,11 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
87
95
|
return __promise;
|
|
88
96
|
}();
|
|
89
97
|
}
|
|
98
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> JHybridNitroImagePipelineSpec::createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) {
|
|
99
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<margelo::nitro::image::JHybridImageLoaderSpec::JavaPart>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JViewOptions> /* options */)>("createImageLoader");
|
|
100
|
+
auto __result = method(_javaPart, jni::make_jstring(url), options.has_value() ? JViewOptions::fromCpp(options.value()) : nullptr);
|
|
101
|
+
return __result->getJHybridImageLoaderSpec();
|
|
102
|
+
}
|
|
90
103
|
std::shared_ptr<Promise<void>> JHybridNitroImagePipelineSpec::preLoadImage(const std::string& url) {
|
|
91
104
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */)>("preLoadImage");
|
|
92
105
|
auto __result = method(_javaPart, jni::make_jstring(url));
|
|
@@ -55,6 +55,7 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
57
|
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadImage(const std::string& url, const std::optional<Options>& options) override;
|
|
58
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) override;
|
|
58
59
|
std::shared_ptr<Promise<void>> preLoadImage(const std::string& url) override;
|
|
59
60
|
std::shared_ptr<Promise<void>> preLoadImages(const std::vector<std::string>& urls) override;
|
|
60
61
|
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> gaussianBlur(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& image, double radius) override;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JViewOptions.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 "ViewOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "CacheOption.hpp"
|
|
14
|
+
#include "CornerRadii.hpp"
|
|
15
|
+
#include "JCacheOption.hpp"
|
|
16
|
+
#include "JCornerRadii.hpp"
|
|
17
|
+
#include "JResizeOptions.hpp"
|
|
18
|
+
#include "JVariant_Double_CornerRadii.hpp"
|
|
19
|
+
#include "ResizeOptions.hpp"
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <variant>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The C++ JNI bridge between the C++ struct "ViewOptions" and the Kotlin data class "ViewOptions".
|
|
29
|
+
*/
|
|
30
|
+
struct JViewOptions final: public jni::JavaClass<JViewOptions> {
|
|
31
|
+
public:
|
|
32
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/ViewOptions;";
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ViewOptions by copying all values to C++.
|
|
37
|
+
*/
|
|
38
|
+
[[maybe_unused]]
|
|
39
|
+
[[nodiscard]]
|
|
40
|
+
ViewOptions toCpp() const {
|
|
41
|
+
static const auto clazz = javaClassStatic();
|
|
42
|
+
static const auto fieldBlur = clazz->getField<jni::JDouble>("blur");
|
|
43
|
+
jni::local_ref<jni::JDouble> blur = this->getFieldValue(fieldBlur);
|
|
44
|
+
static const auto fieldCache = clazz->getField<JCacheOption>("cache");
|
|
45
|
+
jni::local_ref<JCacheOption> cache = this->getFieldValue(fieldCache);
|
|
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);
|
|
50
|
+
return ViewOptions(
|
|
51
|
+
blur != nullptr ? std::make_optional(blur->value()) : std::nullopt,
|
|
52
|
+
cache != nullptr ? std::make_optional(cache->toCpp()) : std::nullopt,
|
|
53
|
+
cornerRadius != nullptr ? std::make_optional(cornerRadius->toCpp()) : std::nullopt,
|
|
54
|
+
resize != nullptr ? std::make_optional(resize->toCpp()) : std::nullopt
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
/**
|
|
60
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
61
|
+
*/
|
|
62
|
+
[[maybe_unused]]
|
|
63
|
+
static jni::local_ref<JViewOptions::javaobject> fromCpp(const ViewOptions& value) {
|
|
64
|
+
using JSignature = JViewOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<JVariant_Double_CornerRadii>, jni::alias_ref<JResizeOptions>);
|
|
65
|
+
static const auto clazz = javaClassStatic();
|
|
66
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
67
|
+
return create(
|
|
68
|
+
clazz,
|
|
69
|
+
value.blur.has_value() ? jni::JDouble::valueOf(value.blur.value()) : nullptr,
|
|
70
|
+
value.cache.has_value() ? JCacheOption::fromCpp(value.cache.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
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -13,6 +13,7 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
13
13
|
import dalvik.annotation.optimization.FastNative
|
|
14
14
|
import com.margelo.nitro.image.HybridImageSpec
|
|
15
15
|
import com.margelo.nitro.core.Promise
|
|
16
|
+
import com.margelo.nitro.image.HybridImageLoaderSpec
|
|
16
17
|
import com.margelo.nitro.core.HybridObject
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -35,6 +36,10 @@ abstract class HybridNitroImagePipelineSpec: HybridObject() {
|
|
|
35
36
|
@Keep
|
|
36
37
|
abstract fun loadImage(url: String, options: Options?): Promise<com.margelo.nitro.image.HybridImageSpec>
|
|
37
38
|
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
abstract fun createImageLoader(url: String, options: ViewOptions?): com.margelo.nitro.image.HybridImageLoaderSpec
|
|
42
|
+
|
|
38
43
|
@DoNotStrip
|
|
39
44
|
@Keep
|
|
40
45
|
abstract fun preLoadImage(url: String): Promise<Unit>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ViewOptions.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 "ViewOptions".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class ViewOptions(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val blur: Double?,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val cache: CacheOption?,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val cornerRadius: Variant_Double_CornerRadii?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val resize: ResizeOptions?
|
|
33
|
+
) {
|
|
34
|
+
/* primary constructor */
|
|
35
|
+
|
|
36
|
+
override fun equals(other: Any?): Boolean {
|
|
37
|
+
if (this === other) return true
|
|
38
|
+
if (other !is ViewOptions) return false
|
|
39
|
+
return Objects.deepEquals(this.blur, other.blur)
|
|
40
|
+
&& Objects.deepEquals(this.cache, other.cache)
|
|
41
|
+
&& Objects.deepEquals(this.cornerRadius, other.cornerRadius)
|
|
42
|
+
&& Objects.deepEquals(this.resize, other.resize)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun hashCode(): Int {
|
|
46
|
+
return arrayOf<Any?>(
|
|
47
|
+
blur,
|
|
48
|
+
cache,
|
|
49
|
+
cornerRadius,
|
|
50
|
+
resize
|
|
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(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?): ViewOptions {
|
|
63
|
+
return ViewOptions(blur, cache, cornerRadius, resize)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -41,6 +41,16 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>
|
|
45
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> create_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
46
|
+
// Implemented in NitroImage
|
|
47
|
+
return margelo::nitro::image::bridge::swift::create_std__shared_ptr_HybridImageLoaderSpec_(swiftUnsafePointer);
|
|
48
|
+
}
|
|
49
|
+
void* NON_NULL get_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ cppType) {
|
|
50
|
+
// Implemented in NitroImage
|
|
51
|
+
return margelo::nitro::image::bridge::swift::get_std__shared_ptr_HybridImageLoaderSpec_(cppType);
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
// pragma MARK: std::function<void()>
|
|
45
55
|
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
46
56
|
auto swiftClosure = NitroImagePipeline::Func_void::fromUnsafe(swiftClosureWrapper);
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
13
13
|
// Forward declaration of `CornerRadii` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
|
|
15
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
15
17
|
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
17
19
|
// Forward declaration of `HybridNitroImagePipelineSpec` to properly resolve imports.
|
|
@@ -20,8 +22,12 @@ namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpe
|
|
|
20
22
|
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
21
23
|
// Forward declaration of `ResizeOptions` to properly resolve imports.
|
|
22
24
|
namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
25
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
23
27
|
|
|
24
28
|
// Forward declarations of Swift defined types
|
|
29
|
+
// Forward declaration of `HybridImageLoaderSpec_cxx` to properly resolve imports.
|
|
30
|
+
namespace NitroImage { class HybridImageLoaderSpec_cxx; }
|
|
25
31
|
// Forward declaration of `HybridImageSpec_cxx` to properly resolve imports.
|
|
26
32
|
namespace NitroImage { class HybridImageSpec_cxx; }
|
|
27
33
|
// Forward declaration of `HybridNitroImagePipelineSpec_cxx` to properly resolve imports.
|
|
@@ -33,6 +39,8 @@ namespace NitroImagePipeline { class HybridNitroImagePipelineSpec_cxx; }
|
|
|
33
39
|
#include "HybridNitroImagePipelineSpec.hpp"
|
|
34
40
|
#include "Options.hpp"
|
|
35
41
|
#include "ResizeOptions.hpp"
|
|
42
|
+
#include "ViewOptions.hpp"
|
|
43
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
36
44
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
37
45
|
#include <NitroModules/Promise.hpp>
|
|
38
46
|
#include <NitroModules/PromiseHolder.hpp>
|
|
@@ -223,6 +231,33 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
|
|
|
223
231
|
return optional.value();
|
|
224
232
|
}
|
|
225
233
|
|
|
234
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>
|
|
235
|
+
/**
|
|
236
|
+
* Specialized version of `std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>`.
|
|
237
|
+
*/
|
|
238
|
+
using std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ = std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>;
|
|
239
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> create_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
240
|
+
void* NON_NULL get_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ cppType);
|
|
241
|
+
|
|
242
|
+
// pragma MARK: std::weak_ptr<margelo::nitro::image::HybridImageLoaderSpec>
|
|
243
|
+
using std__weak_ptr_margelo__nitro__image__HybridImageLoaderSpec_ = std::weak_ptr<margelo::nitro::image::HybridImageLoaderSpec>;
|
|
244
|
+
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
|
+
|
|
246
|
+
// pragma MARK: std::optional<ViewOptions>
|
|
247
|
+
/**
|
|
248
|
+
* Specialized version of `std::optional<ViewOptions>`.
|
|
249
|
+
*/
|
|
250
|
+
using std__optional_ViewOptions_ = std::optional<ViewOptions>;
|
|
251
|
+
inline std::optional<ViewOptions> create_std__optional_ViewOptions_(const ViewOptions& value) noexcept {
|
|
252
|
+
return std::optional<ViewOptions>(value);
|
|
253
|
+
}
|
|
254
|
+
inline bool has_value_std__optional_ViewOptions_(const std::optional<ViewOptions>& optional) noexcept {
|
|
255
|
+
return optional.has_value();
|
|
256
|
+
}
|
|
257
|
+
inline ViewOptions get_std__optional_ViewOptions_(const std::optional<ViewOptions>& optional) noexcept {
|
|
258
|
+
return optional.value();
|
|
259
|
+
}
|
|
260
|
+
|
|
226
261
|
// pragma MARK: std::shared_ptr<Promise<void>>
|
|
227
262
|
/**
|
|
228
263
|
* Specialized version of `std::shared_ptr<Promise<void>>`.
|
|
@@ -289,6 +324,15 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
|
|
|
289
324
|
return Result<std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>>>::withError(error);
|
|
290
325
|
}
|
|
291
326
|
|
|
327
|
+
// pragma MARK: Result<std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>>
|
|
328
|
+
using Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__ = Result<std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>>;
|
|
329
|
+
inline Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__ create_Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__(const std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>& value) noexcept {
|
|
330
|
+
return Result<std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>>::withValue(value);
|
|
331
|
+
}
|
|
332
|
+
inline Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__ create_Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__(const std::exception_ptr& error) noexcept {
|
|
333
|
+
return Result<std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>>::withError(error);
|
|
334
|
+
}
|
|
335
|
+
|
|
292
336
|
// pragma MARK: Result<std::shared_ptr<Promise<void>>>
|
|
293
337
|
using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
|
|
294
338
|
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
13
13
|
// Forward declaration of `CornerRadii` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
|
|
15
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
15
17
|
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
17
19
|
// Forward declaration of `HybridNitroImagePipelineSpec` to properly resolve imports.
|
|
@@ -20,6 +22,8 @@ namespace margelo::nitro::nitroimagepipeline { class HybridNitroImagePipelineSpe
|
|
|
20
22
|
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
21
23
|
// Forward declaration of `ResizeOptions` to properly resolve imports.
|
|
22
24
|
namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
25
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
23
27
|
|
|
24
28
|
// Include C++ defined types
|
|
25
29
|
#include "CacheOption.hpp"
|
|
@@ -27,6 +31,8 @@ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
|
27
31
|
#include "HybridNitroImagePipelineSpec.hpp"
|
|
28
32
|
#include "Options.hpp"
|
|
29
33
|
#include "ResizeOptions.hpp"
|
|
34
|
+
#include "ViewOptions.hpp"
|
|
35
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
30
36
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
31
37
|
#include <NitroModules/Promise.hpp>
|
|
32
38
|
#include <NitroModules/Result.hpp>
|
|
@@ -47,6 +53,8 @@ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
|
47
53
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
48
54
|
|
|
49
55
|
// Forward declarations of Swift defined types
|
|
56
|
+
// Forward declaration of `HybridImageLoaderSpec_cxx` to properly resolve imports.
|
|
57
|
+
namespace NitroImage { class HybridImageLoaderSpec_cxx; }
|
|
50
58
|
// Forward declaration of `HybridImageSpec_cxx` to properly resolve imports.
|
|
51
59
|
namespace NitroImage { class HybridImageSpec_cxx; }
|
|
52
60
|
// Forward declaration of `HybridNitroImagePipelineSpec_cxx` to properly resolve imports.
|
|
@@ -22,6 +22,10 @@ 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 `HybridImageLoaderSpec` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
27
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
25
29
|
|
|
26
30
|
#include <memory>
|
|
27
31
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
@@ -33,6 +37,8 @@ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
|
33
37
|
#include "CornerRadii.hpp"
|
|
34
38
|
#include <variant>
|
|
35
39
|
#include "ResizeOptions.hpp"
|
|
40
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
41
|
+
#include "ViewOptions.hpp"
|
|
36
42
|
#include <vector>
|
|
37
43
|
|
|
38
44
|
#include "NitroImagePipeline-Swift-Cxx-Umbrella.hpp"
|
|
@@ -93,6 +99,14 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
93
99
|
auto __value = std::move(__result.value());
|
|
94
100
|
return __value;
|
|
95
101
|
}
|
|
102
|
+
inline std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) override {
|
|
103
|
+
auto __result = _swiftPart.createImageLoader(url, options);
|
|
104
|
+
if (__result.hasError()) [[unlikely]] {
|
|
105
|
+
std::rethrow_exception(__result.error());
|
|
106
|
+
}
|
|
107
|
+
auto __value = std::move(__result.value());
|
|
108
|
+
return __value;
|
|
109
|
+
}
|
|
96
110
|
inline std::shared_ptr<Promise<void>> preLoadImage(const std::string& url) override {
|
|
97
111
|
auto __result = _swiftPart.preLoadImage(url);
|
|
98
112
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -15,6 +15,7 @@ public protocol HybridNitroImagePipelineSpec_protocol: HybridObject {
|
|
|
15
15
|
|
|
16
16
|
// Methods
|
|
17
17
|
func loadImage(url: String, options: Options?) throws -> Promise<(any HybridImageSpec)>
|
|
18
|
+
func createImageLoader(url: String, options: ViewOptions?) throws -> (any HybridImageLoaderSpec)
|
|
18
19
|
func preLoadImage(url: String) throws -> Promise<Void>
|
|
19
20
|
func preLoadImages(urls: [String]) throws -> Promise<Void>
|
|
20
21
|
func gaussianBlur(image: (any HybridImageSpec), radius: Double) throws -> Promise<(any HybridImageSpec)>
|
|
@@ -147,6 +147,21 @@ open class HybridNitroImagePipelineSpec_cxx {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
@inline(__always)
|
|
151
|
+
public final func createImageLoader(url: std.string, options: bridge.std__optional_ViewOptions_) -> bridge.Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__ {
|
|
152
|
+
do {
|
|
153
|
+
let __result = try self.__implementation.createImageLoader(url: String(url), options: options.value)
|
|
154
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ in
|
|
155
|
+
let __cxxWrapped = __result.getCxxWrapper()
|
|
156
|
+
return __cxxWrapped.getCxxPart()
|
|
157
|
+
}()
|
|
158
|
+
return bridge.create_Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__(__resultCpp)
|
|
159
|
+
} catch (let __error) {
|
|
160
|
+
let __exceptionPtr = __error.toCpp()
|
|
161
|
+
return bridge.create_Result_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec__(__exceptionPtr)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
150
165
|
@inline(__always)
|
|
151
166
|
public final func preLoadImage(url: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
152
167
|
do {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ViewOptions.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
|
+
* Represents an instance of `ViewOptions`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ViewOptions = margelo.nitro.nitroimagepipeline.ViewOptions
|
|
14
|
+
|
|
15
|
+
public extension ViewOptions {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ViewOptions`.
|
|
20
|
+
*/
|
|
21
|
+
init(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = blur {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_CacheOption_ in
|
|
29
|
+
if let __unwrappedValue = cache {
|
|
30
|
+
return bridge.create_std__optional_CacheOption_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_std__variant_double__CornerRadii__ in
|
|
35
|
+
if let __unwrappedValue = cornerRadius {
|
|
36
|
+
return bridge.create_std__optional_std__variant_double__CornerRadii__({ () -> bridge.std__variant_double__CornerRadii_ in
|
|
37
|
+
switch __unwrappedValue {
|
|
38
|
+
case .first(let __value):
|
|
39
|
+
return bridge.create_std__variant_double__CornerRadii_(__value)
|
|
40
|
+
case .second(let __value):
|
|
41
|
+
return bridge.create_std__variant_double__CornerRadii_(__value)
|
|
42
|
+
}
|
|
43
|
+
}().variant)
|
|
44
|
+
} else {
|
|
45
|
+
return .init()
|
|
46
|
+
}
|
|
47
|
+
}(), { () -> bridge.std__optional_ResizeOptions_ in
|
|
48
|
+
if let __unwrappedValue = resize {
|
|
49
|
+
return bridge.create_std__optional_ResizeOptions_(__unwrappedValue)
|
|
50
|
+
} else {
|
|
51
|
+
return .init()
|
|
52
|
+
}
|
|
53
|
+
}())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@inline(__always)
|
|
57
|
+
var blur: Double? {
|
|
58
|
+
return { () -> Double? in
|
|
59
|
+
if bridge.has_value_std__optional_double_(self.__blur) {
|
|
60
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__blur)
|
|
61
|
+
return __unwrapped
|
|
62
|
+
} else {
|
|
63
|
+
return nil
|
|
64
|
+
}
|
|
65
|
+
}()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@inline(__always)
|
|
69
|
+
var cache: CacheOption? {
|
|
70
|
+
return self.__cache.value
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@inline(__always)
|
|
74
|
+
var cornerRadius: Variant_Double_CornerRadii? {
|
|
75
|
+
return { () -> Variant_Double_CornerRadii? in
|
|
76
|
+
if bridge.has_value_std__optional_std__variant_double__CornerRadii__(self.__cornerRadius) {
|
|
77
|
+
let __unwrapped = bridge.get_std__optional_std__variant_double__CornerRadii__(self.__cornerRadius)
|
|
78
|
+
return { () -> Variant_Double_CornerRadii in
|
|
79
|
+
let __variant = bridge.std__variant_double__CornerRadii_(__unwrapped)
|
|
80
|
+
switch __variant.index() {
|
|
81
|
+
case 0:
|
|
82
|
+
let __actual = __variant.get_0()
|
|
83
|
+
return .first(__actual)
|
|
84
|
+
case 1:
|
|
85
|
+
let __actual = __variant.get_1()
|
|
86
|
+
return .second(__actual)
|
|
87
|
+
default:
|
|
88
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
89
|
+
}
|
|
90
|
+
}()
|
|
91
|
+
} else {
|
|
92
|
+
return nil
|
|
93
|
+
}
|
|
94
|
+
}()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@inline(__always)
|
|
98
|
+
var resize: ResizeOptions? {
|
|
99
|
+
return self.__resize.value
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -15,6 +15,7 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("loadImage", &HybridNitroImagePipelineSpec::loadImage);
|
|
18
|
+
prototype.registerHybridMethod("createImageLoader", &HybridNitroImagePipelineSpec::createImageLoader);
|
|
18
19
|
prototype.registerHybridMethod("preLoadImage", &HybridNitroImagePipelineSpec::preLoadImage);
|
|
19
20
|
prototype.registerHybridMethod("preLoadImages", &HybridNitroImagePipelineSpec::preLoadImages);
|
|
20
21
|
prototype.registerHybridMethod("gaussianBlur", &HybridNitroImagePipelineSpec::gaussianBlur);
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
18
18
|
// Forward declaration of `Options` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
20
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
22
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
20
24
|
|
|
21
25
|
#include <memory>
|
|
22
26
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
@@ -24,6 +28,8 @@ namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
|
24
28
|
#include <string>
|
|
25
29
|
#include "Options.hpp"
|
|
26
30
|
#include <optional>
|
|
31
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
32
|
+
#include "ViewOptions.hpp"
|
|
27
33
|
#include <vector>
|
|
28
34
|
|
|
29
35
|
namespace margelo::nitro::nitroimagepipeline {
|
|
@@ -58,6 +64,7 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
58
64
|
public:
|
|
59
65
|
// Methods
|
|
60
66
|
virtual std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadImage(const std::string& url, const std::optional<Options>& options) = 0;
|
|
67
|
+
virtual std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) = 0;
|
|
61
68
|
virtual std::shared_ptr<Promise<void>> preLoadImage(const std::string& url) = 0;
|
|
62
69
|
virtual std::shared_ptr<Promise<void>> preLoadImages(const std::vector<std::string>& urls) = 0;
|
|
63
70
|
virtual std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> gaussianBlur(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& image, double radius) = 0;
|