react-native-nitro-web-image 0.5.0-beta.5
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/NitroWebImage.podspec +33 -0
- package/android/CMakeLists.txt +31 -0
- package/android/build.gradle +145 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/web/image/AsyncImagePriority+toCoroutineContext.kt +15 -0
- package/android/src/main/java/com/margelo/nitro/web/image/HybridWebImageFactory.kt +32 -0
- package/android/src/main/java/com/margelo/nitro/web/image/HybridWebImageLoader.kt +32 -0
- package/android/src/main/java/com/margelo/nitro/web/image/ImageLoader+loadImageAsync.kt +37 -0
- package/android/src/main/java/com/margelo/nitro/web/image/ImageRequestBuilder+applyOptions.kt +58 -0
- package/android/src/main/java/com/margelo/nitro/web/image/NitroWebImagePackage.java +44 -0
- package/ios/AsyncImageLoadOptions+toSDWebImageOptions.swift +66 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridWebImageFactory.swift +32 -0
- package/ios/HybridWebImageLoader.swift +54 -0
- package/ios/SDWebImageManager+loadImage.swift +30 -0
- package/lib/commonjs/index.js +9 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/WebImageFactory.nitro.js +6 -0
- package/lib/commonjs/specs/WebImageFactory.nitro.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/WebImageFactory.nitro.js +4 -0
- package/lib/module/specs/WebImageFactory.nitro.js.map +1 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/WebImageFactory.nitro.d.ts +63 -0
- package/lib/typescript/specs/WebImageFactory.nitro.d.ts.map +1 -0
- package/nitro.json +18 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroWebImage+autolinking.cmake +78 -0
- package/nitrogen/generated/android/NitroWebImage+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroWebImageOnLoad.cpp +46 -0
- package/nitrogen/generated/android/NitroWebImageOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JAsyncImageLoadOptions.hpp +88 -0
- package/nitrogen/generated/android/c++/JAsyncImagePriority.hpp +62 -0
- package/nitrogen/generated/android/c++/JHybridWebImageFactorySpec.cpp +82 -0
- package/nitrogen/generated/android/c++/JHybridWebImageFactorySpec.hpp +64 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/AsyncImageLoadOptions.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/AsyncImagePriority.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/HybridWebImageFactorySpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/NitroWebImageOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroWebImage+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroWebImage-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/NitroWebImage-Swift-Cxx-Bridge.hpp +197 -0
- package/nitrogen/generated/ios/NitroWebImage-Swift-Cxx-Umbrella.hpp +62 -0
- package/nitrogen/generated/ios/NitroWebImageAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroWebImageAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridWebImageFactorySpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridWebImageFactorySpecSwift.hpp +95 -0
- package/nitrogen/generated/ios/swift/AsyncImageLoadOptions.swift +237 -0
- package/nitrogen/generated/ios/swift/AsyncImagePriority.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_.swift +51 -0
- package/nitrogen/generated/ios/swift/HybridWebImageFactorySpec.swift +51 -0
- package/nitrogen/generated/ios/swift/HybridWebImageFactorySpec_cxx.swift +161 -0
- package/nitrogen/generated/shared/c++/AsyncImageLoadOptions.hpp +104 -0
- package/nitrogen/generated/shared/c++/AsyncImagePriority.hpp +82 -0
- package/nitrogen/generated/shared/c++/HybridWebImageFactorySpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridWebImageFactorySpec.hpp +74 -0
- package/package.json +113 -0
- package/react-native.config.js +16 -0
- package/src/index.ts +5 -0
- package/src/specs/WebImageFactory.nitro.ts +76 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAsyncImageLoadOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "AsyncImageLoadOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "AsyncImagePriority.hpp"
|
|
14
|
+
#include "JAsyncImagePriority.hpp"
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include <string>
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::web::image {
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The C++ JNI bridge between the C++ struct "AsyncImageLoadOptions" and the the Kotlin data class "AsyncImageLoadOptions".
|
|
24
|
+
*/
|
|
25
|
+
struct JAsyncImageLoadOptions final: public jni::JavaClass<JAsyncImageLoadOptions> {
|
|
26
|
+
public:
|
|
27
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/web/image/AsyncImageLoadOptions;";
|
|
28
|
+
|
|
29
|
+
public:
|
|
30
|
+
/**
|
|
31
|
+
* Convert this Java/Kotlin-based struct to the C++ struct AsyncImageLoadOptions by copying all values to C++.
|
|
32
|
+
*/
|
|
33
|
+
[[maybe_unused]]
|
|
34
|
+
[[nodiscard]]
|
|
35
|
+
AsyncImageLoadOptions toCpp() const {
|
|
36
|
+
static const auto clazz = javaClassStatic();
|
|
37
|
+
static const auto fieldPriority = clazz->getField<JAsyncImagePriority>("priority");
|
|
38
|
+
jni::local_ref<JAsyncImagePriority> priority = this->getFieldValue(fieldPriority);
|
|
39
|
+
static const auto fieldForceRefresh = clazz->getField<jni::JBoolean>("forceRefresh");
|
|
40
|
+
jni::local_ref<jni::JBoolean> forceRefresh = this->getFieldValue(fieldForceRefresh);
|
|
41
|
+
static const auto fieldCacheKey = clazz->getField<jni::JString>("cacheKey");
|
|
42
|
+
jni::local_ref<jni::JString> cacheKey = this->getFieldValue(fieldCacheKey);
|
|
43
|
+
static const auto fieldContinueInBackground = clazz->getField<jni::JBoolean>("continueInBackground");
|
|
44
|
+
jni::local_ref<jni::JBoolean> continueInBackground = this->getFieldValue(fieldContinueInBackground);
|
|
45
|
+
static const auto fieldAllowInvalidSSLCertificates = clazz->getField<jni::JBoolean>("allowInvalidSSLCertificates");
|
|
46
|
+
jni::local_ref<jni::JBoolean> allowInvalidSSLCertificates = this->getFieldValue(fieldAllowInvalidSSLCertificates);
|
|
47
|
+
static const auto fieldScaleDownLargeImages = clazz->getField<jni::JBoolean>("scaleDownLargeImages");
|
|
48
|
+
jni::local_ref<jni::JBoolean> scaleDownLargeImages = this->getFieldValue(fieldScaleDownLargeImages);
|
|
49
|
+
static const auto fieldQueryMemoryDataSync = clazz->getField<jni::JBoolean>("queryMemoryDataSync");
|
|
50
|
+
jni::local_ref<jni::JBoolean> queryMemoryDataSync = this->getFieldValue(fieldQueryMemoryDataSync);
|
|
51
|
+
static const auto fieldQueryDiskDataSync = clazz->getField<jni::JBoolean>("queryDiskDataSync");
|
|
52
|
+
jni::local_ref<jni::JBoolean> queryDiskDataSync = this->getFieldValue(fieldQueryDiskDataSync);
|
|
53
|
+
static const auto fieldDecodeImage = clazz->getField<jni::JBoolean>("decodeImage");
|
|
54
|
+
jni::local_ref<jni::JBoolean> decodeImage = this->getFieldValue(fieldDecodeImage);
|
|
55
|
+
return AsyncImageLoadOptions(
|
|
56
|
+
priority != nullptr ? std::make_optional(priority->toCpp()) : std::nullopt,
|
|
57
|
+
forceRefresh != nullptr ? std::make_optional(static_cast<bool>(forceRefresh->value())) : std::nullopt,
|
|
58
|
+
cacheKey != nullptr ? std::make_optional(cacheKey->toStdString()) : std::nullopt,
|
|
59
|
+
continueInBackground != nullptr ? std::make_optional(static_cast<bool>(continueInBackground->value())) : std::nullopt,
|
|
60
|
+
allowInvalidSSLCertificates != nullptr ? std::make_optional(static_cast<bool>(allowInvalidSSLCertificates->value())) : std::nullopt,
|
|
61
|
+
scaleDownLargeImages != nullptr ? std::make_optional(static_cast<bool>(scaleDownLargeImages->value())) : std::nullopt,
|
|
62
|
+
queryMemoryDataSync != nullptr ? std::make_optional(static_cast<bool>(queryMemoryDataSync->value())) : std::nullopt,
|
|
63
|
+
queryDiskDataSync != nullptr ? std::make_optional(static_cast<bool>(queryDiskDataSync->value())) : std::nullopt,
|
|
64
|
+
decodeImage != nullptr ? std::make_optional(static_cast<bool>(decodeImage->value())) : std::nullopt
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
/**
|
|
70
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
71
|
+
*/
|
|
72
|
+
[[maybe_unused]]
|
|
73
|
+
static jni::local_ref<JAsyncImageLoadOptions::javaobject> fromCpp(const AsyncImageLoadOptions& value) {
|
|
74
|
+
return newInstance(
|
|
75
|
+
value.priority.has_value() ? JAsyncImagePriority::fromCpp(value.priority.value()) : nullptr,
|
|
76
|
+
value.forceRefresh.has_value() ? jni::JBoolean::valueOf(value.forceRefresh.value()) : nullptr,
|
|
77
|
+
value.cacheKey.has_value() ? jni::make_jstring(value.cacheKey.value()) : nullptr,
|
|
78
|
+
value.continueInBackground.has_value() ? jni::JBoolean::valueOf(value.continueInBackground.value()) : nullptr,
|
|
79
|
+
value.allowInvalidSSLCertificates.has_value() ? jni::JBoolean::valueOf(value.allowInvalidSSLCertificates.value()) : nullptr,
|
|
80
|
+
value.scaleDownLargeImages.has_value() ? jni::JBoolean::valueOf(value.scaleDownLargeImages.value()) : nullptr,
|
|
81
|
+
value.queryMemoryDataSync.has_value() ? jni::JBoolean::valueOf(value.queryMemoryDataSync.value()) : nullptr,
|
|
82
|
+
value.queryDiskDataSync.has_value() ? jni::JBoolean::valueOf(value.queryDiskDataSync.value()) : nullptr,
|
|
83
|
+
value.decodeImage.has_value() ? jni::JBoolean::valueOf(value.decodeImage.value()) : nullptr
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro::web::image
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAsyncImagePriority.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "AsyncImagePriority.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::web::image {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "AsyncImagePriority" and the the Kotlin enum "AsyncImagePriority".
|
|
19
|
+
*/
|
|
20
|
+
struct JAsyncImagePriority final: public jni::JavaClass<JAsyncImagePriority> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/web/image/AsyncImagePriority;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum AsyncImagePriority.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
AsyncImagePriority toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("_ordinal");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<AsyncImagePriority>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JAsyncImagePriority> fromCpp(AsyncImagePriority value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
static const auto fieldLOW = clazz->getStaticField<JAsyncImagePriority>("LOW");
|
|
45
|
+
static const auto fieldDEFAULT = clazz->getStaticField<JAsyncImagePriority>("DEFAULT");
|
|
46
|
+
static const auto fieldHIGH = clazz->getStaticField<JAsyncImagePriority>("HIGH");
|
|
47
|
+
|
|
48
|
+
switch (value) {
|
|
49
|
+
case AsyncImagePriority::LOW:
|
|
50
|
+
return clazz->getStaticFieldValue(fieldLOW);
|
|
51
|
+
case AsyncImagePriority::DEFAULT:
|
|
52
|
+
return clazz->getStaticFieldValue(fieldDEFAULT);
|
|
53
|
+
case AsyncImagePriority::HIGH:
|
|
54
|
+
return clazz->getStaticFieldValue(fieldHIGH);
|
|
55
|
+
default:
|
|
56
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
57
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::web::image
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridWebImageFactorySpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridWebImageFactorySpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
12
|
+
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
14
|
+
// Forward declaration of `AsyncImageLoadOptions` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::web::image { struct AsyncImageLoadOptions; }
|
|
16
|
+
// Forward declaration of `AsyncImagePriority` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::web::image { enum class AsyncImagePriority; }
|
|
18
|
+
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
21
|
+
#include <NitroImage/JHybridImageLoaderSpec.hpp>
|
|
22
|
+
#include <NitroModules/JNISharedPtr.hpp>
|
|
23
|
+
#include <NitroImage/HybridImageSpec.hpp>
|
|
24
|
+
#include <NitroModules/Promise.hpp>
|
|
25
|
+
#include <NitroModules/JPromise.hpp>
|
|
26
|
+
#include <NitroImage/JHybridImageSpec.hpp>
|
|
27
|
+
#include <string>
|
|
28
|
+
#include "AsyncImageLoadOptions.hpp"
|
|
29
|
+
#include <optional>
|
|
30
|
+
#include "JAsyncImageLoadOptions.hpp"
|
|
31
|
+
#include "AsyncImagePriority.hpp"
|
|
32
|
+
#include "JAsyncImagePriority.hpp"
|
|
33
|
+
|
|
34
|
+
namespace margelo::nitro::web::image {
|
|
35
|
+
|
|
36
|
+
jni::local_ref<JHybridWebImageFactorySpec::jhybriddata> JHybridWebImageFactorySpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
37
|
+
return makeCxxInstance(jThis);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void JHybridWebImageFactorySpec::registerNatives() {
|
|
41
|
+
registerHybrid({
|
|
42
|
+
makeNativeMethod("initHybrid", JHybridWebImageFactorySpec::initHybrid),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
size_t JHybridWebImageFactorySpec::getExternalMemorySize() noexcept {
|
|
47
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
48
|
+
return method(_javaPart);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void JHybridWebImageFactorySpec::dispose() noexcept {
|
|
52
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
53
|
+
method(_javaPart);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Properties
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// Methods
|
|
60
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> JHybridWebImageFactorySpec::createWebImageLoader(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) {
|
|
61
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<margelo::nitro::image::JHybridImageLoaderSpec::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JAsyncImageLoadOptions> /* options */)>("createWebImageLoader");
|
|
62
|
+
auto __result = method(_javaPart, jni::make_jstring(url), options.has_value() ? JAsyncImageLoadOptions::fromCpp(options.value()) : nullptr);
|
|
63
|
+
return JNISharedPtr::make_shared_from_jni<margelo::nitro::image::JHybridImageLoaderSpec>(jni::make_global(__result));
|
|
64
|
+
}
|
|
65
|
+
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> JHybridWebImageFactorySpec::loadFromURLAsync(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) {
|
|
66
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JAsyncImageLoadOptions> /* options */)>("loadFromURLAsync");
|
|
67
|
+
auto __result = method(_javaPart, jni::make_jstring(url), options.has_value() ? JAsyncImageLoadOptions::fromCpp(options.value()) : nullptr);
|
|
68
|
+
return [&]() {
|
|
69
|
+
auto __promise = Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>::create();
|
|
70
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
71
|
+
auto __result = jni::static_ref_cast<margelo::nitro::image::JHybridImageSpec::javaobject>(__boxedResult);
|
|
72
|
+
__promise->resolve(JNISharedPtr::make_shared_from_jni<margelo::nitro::image::JHybridImageSpec>(jni::make_global(__result)));
|
|
73
|
+
});
|
|
74
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
75
|
+
jni::JniException __jniError(__throwable);
|
|
76
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
77
|
+
});
|
|
78
|
+
return __promise;
|
|
79
|
+
}();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
} // namespace margelo::nitro::web::image
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridWebImageFactorySpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridWebImageFactorySpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::web::image {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridWebImageFactorySpec: public jni::HybridClass<JHybridWebImageFactorySpec, JHybridObject>,
|
|
22
|
+
public virtual HybridWebImageFactorySpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/web/image/HybridWebImageFactorySpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridWebImageFactorySpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridWebImageFactorySpec::TAG),
|
|
32
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
~JHybridWebImageFactorySpec() override {
|
|
36
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
37
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
size_t getExternalMemorySize() noexcept override;
|
|
42
|
+
void dispose() noexcept override;
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
inline const jni::global_ref<JHybridWebImageFactorySpec::javaobject>& getJavaPart() const noexcept {
|
|
46
|
+
return _javaPart;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
// Properties
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
// Methods
|
|
55
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createWebImageLoader(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) override;
|
|
56
|
+
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadFromURLAsync(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) override;
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
friend HybridBase;
|
|
60
|
+
using HybridBase::HybridBase;
|
|
61
|
+
jni::global_ref<JHybridWebImageFactorySpec::javaobject> _javaPart;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::web::image
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/AsyncImageLoadOptions.kt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AsyncImageLoadOptions.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.web.image
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "AsyncImageLoadOptions".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class AsyncImageLoadOptions
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
val priority: AsyncImagePriority?,
|
|
25
|
+
val forceRefresh: Boolean?,
|
|
26
|
+
val cacheKey: String?,
|
|
27
|
+
val continueInBackground: Boolean?,
|
|
28
|
+
val allowInvalidSSLCertificates: Boolean?,
|
|
29
|
+
val scaleDownLargeImages: Boolean?,
|
|
30
|
+
val queryMemoryDataSync: Boolean?,
|
|
31
|
+
val queryDiskDataSync: Boolean?,
|
|
32
|
+
val decodeImage: Boolean?
|
|
33
|
+
) {
|
|
34
|
+
/* main constructor */
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AsyncImagePriority.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.web.image
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "AsyncImagePriority".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class AsyncImagePriority {
|
|
19
|
+
LOW,
|
|
20
|
+
DEFAULT,
|
|
21
|
+
HIGH;
|
|
22
|
+
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
private val _ordinal = ordinal
|
|
26
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/web/image/HybridWebImageFactorySpec.kt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridWebImageFactorySpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.web.image
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.*
|
|
14
|
+
import com.margelo.nitro.image.HybridImageLoaderSpec
|
|
15
|
+
import com.margelo.nitro.image.HybridImageSpec
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the WebImageFactory HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of WebImageFactory.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridWebImageFactorySpec: HybridObject() {
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
private var mHybridData: HybridData = initHybrid()
|
|
31
|
+
|
|
32
|
+
init {
|
|
33
|
+
super.updateNative(mHybridData)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun updateNative(hybridData: HybridData) {
|
|
37
|
+
mHybridData = hybridData
|
|
38
|
+
super.updateNative(hybridData)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Properties
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// Methods
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
abstract fun createWebImageLoader(url: String, options: AsyncImageLoadOptions?): com.margelo.nitro.image.HybridImageLoaderSpec
|
|
48
|
+
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
@Keep
|
|
51
|
+
abstract fun loadFromURLAsync(url: String, options: AsyncImageLoadOptions?): Promise<com.margelo.nitro.image.HybridImageSpec>
|
|
52
|
+
|
|
53
|
+
private external fun initHybrid(): HybridData
|
|
54
|
+
|
|
55
|
+
companion object {
|
|
56
|
+
private const val TAG = "HybridWebImageFactorySpec"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroWebImageOnLoad.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.web.image
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroWebImageOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroWebImageOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroWebImage".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroWebImage C++ library...")
|
|
25
|
+
System.loadLibrary("NitroWebImage")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroWebImage C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroWebImage C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroWebImage+autolinking.rb
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/NitroWebImage+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 NitroWebImage is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/NitroWebImage-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only C)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroWebImage-Swift-Cxx-Bridge.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "NitroWebImage-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridWebImageFactorySpecSwift.hpp"
|
|
12
|
+
#include "NitroWebImage-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroImage/NitroImage-Swift-Cxx-Bridge.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::web::image::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>
|
|
18
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> create_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(void* _Nonnull swiftUnsafePointer) {
|
|
19
|
+
return margelo::nitro::image::bridge::swift::create_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(swiftUnsafePointer);
|
|
20
|
+
}
|
|
21
|
+
void* _Nonnull get_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ cppType) {
|
|
22
|
+
return margelo::nitro::image::bridge::swift::get_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(cppType);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::image::HybridImageSpec>
|
|
26
|
+
std::shared_ptr<margelo::nitro::image::HybridImageSpec> create_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(void* _Nonnull swiftUnsafePointer) {
|
|
27
|
+
return margelo::nitro::image::bridge::swift::create_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(swiftUnsafePointer);
|
|
28
|
+
}
|
|
29
|
+
void* _Nonnull get_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(std__shared_ptr_margelo__nitro__image__HybridImageSpec_ cppType) {
|
|
30
|
+
return margelo::nitro::image::bridge::swift::get_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(cppType);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// pragma MARK: std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& /* result */)>
|
|
34
|
+
Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_ create_Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(void* _Nonnull swiftClosureWrapper) {
|
|
35
|
+
auto swiftClosure = NitroWebImage::Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& result) mutable -> void {
|
|
37
|
+
swiftClosure.call(result);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
42
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) {
|
|
43
|
+
auto swiftClosure = NitroWebImage::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
44
|
+
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
45
|
+
swiftClosure.call(error);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::web::image::HybridWebImageFactorySpec>
|
|
50
|
+
std::shared_ptr<margelo::nitro::web::image::HybridWebImageFactorySpec> create_std__shared_ptr_margelo__nitro__web__image__HybridWebImageFactorySpec_(void* _Nonnull swiftUnsafePointer) {
|
|
51
|
+
NitroWebImage::HybridWebImageFactorySpec_cxx swiftPart = NitroWebImage::HybridWebImageFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
52
|
+
return std::make_shared<margelo::nitro::web::image::HybridWebImageFactorySpecSwift>(swiftPart);
|
|
53
|
+
}
|
|
54
|
+
void* _Nonnull get_std__shared_ptr_margelo__nitro__web__image__HybridWebImageFactorySpec_(std__shared_ptr_margelo__nitro__web__image__HybridWebImageFactorySpec_ cppType) {
|
|
55
|
+
std::shared_ptr<margelo::nitro::web::image::HybridWebImageFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::web::image::HybridWebImageFactorySpecSwift>(cppType);
|
|
56
|
+
#ifdef NITRO_DEBUG
|
|
57
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
58
|
+
throw std::runtime_error("Class \"HybridWebImageFactorySpec\" is not implemented in Swift!");
|
|
59
|
+
}
|
|
60
|
+
#endif
|
|
61
|
+
NitroWebImage::HybridWebImageFactorySpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
62
|
+
return swiftPart.toUnsafe();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::web::image::bridge::swift
|