@onekeyfe/react-native-photo-library 0.0.0-stage → 3.0.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -2
  3. package/ReactNativePhotoLibrary.podspec +36 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +132 -0
  6. package/android/gradle.properties +4 -0
  7. package/android/src/main/AndroidManifest.xml +1 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativephotolibrary/ImagePhotoLibrary.kt +207 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativephotolibrary/PhotoLibraryException.kt +12 -0
  11. package/android/src/main/java/com/margelo/nitro/reactnativephotolibrary/ReactNativePhotoLibrary.kt +11 -0
  12. package/android/src/main/java/com/margelo/nitro/reactnativephotolibrary/ReactNativePhotoLibraryPackage.kt +22 -0
  13. package/docs/SPEC.md +108 -0
  14. package/ios/ImagePhotoLibrary.swift +80 -0
  15. package/ios/PhotoLibraryError.swift +11 -0
  16. package/ios/ReactNativePhotoLibrary.swift +15 -0
  17. package/ios/tests/ImagePhotoLibraryTests.swift +44 -0
  18. package/lib/module/ReactNativePhotoLibrary.nitro.js +4 -0
  19. package/lib/module/ReactNativePhotoLibrary.nitro.js.map +1 -0
  20. package/lib/module/index.js +52 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/typescript/package.json +1 -0
  24. package/lib/typescript/src/ReactNativePhotoLibrary.nitro.d.ts +15 -0
  25. package/lib/typescript/src/ReactNativePhotoLibrary.nitro.d.ts.map +1 -0
  26. package/lib/typescript/src/index.d.ts +18 -0
  27. package/lib/typescript/src/index.d.ts.map +1 -0
  28. package/nitro.json +17 -0
  29. package/nitrogen/generated/android/c++/JHybridReactNativePhotoLibrarySpec.cpp +105 -0
  30. package/nitrogen/generated/android/c++/JHybridReactNativePhotoLibrarySpec.hpp +65 -0
  31. package/nitrogen/generated/android/c++/JPhotoSavePermission.hpp +62 -0
  32. package/nitrogen/generated/android/c++/JPhotoSavePermissionStatus.hpp +61 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativephotolibrary/HybridReactNativePhotoLibrarySpec.kt +65 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativephotolibrary/PhotoSavePermission.kt +56 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativephotolibrary/PhotoSavePermissionStatus.kt +24 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativephotolibrary/reactnativephotolibraryOnLoad.kt +35 -0
  37. package/nitrogen/generated/android/reactnativephotolibrary+autolinking.cmake +81 -0
  38. package/nitrogen/generated/android/reactnativephotolibrary+autolinking.gradle +27 -0
  39. package/nitrogen/generated/android/reactnativephotolibraryOnLoad.cpp +54 -0
  40. package/nitrogen/generated/android/reactnativephotolibraryOnLoad.hpp +34 -0
  41. package/nitrogen/generated/ios/ReactNativePhotoLibrary+autolinking.rb +62 -0
  42. package/nitrogen/generated/ios/ReactNativePhotoLibrary-Swift-Cxx-Bridge.cpp +57 -0
  43. package/nitrogen/generated/ios/ReactNativePhotoLibrary-Swift-Cxx-Bridge.hpp +159 -0
  44. package/nitrogen/generated/ios/ReactNativePhotoLibrary-Swift-Cxx-Umbrella.hpp +51 -0
  45. package/nitrogen/generated/ios/ReactNativePhotoLibraryAutolinking.mm +33 -0
  46. package/nitrogen/generated/ios/ReactNativePhotoLibraryAutolinking.swift +26 -0
  47. package/nitrogen/generated/ios/c++/HybridReactNativePhotoLibrarySpecSwift.cpp +11 -0
  48. package/nitrogen/generated/ios/c++/HybridReactNativePhotoLibrarySpecSwift.hpp +104 -0
  49. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  50. package/nitrogen/generated/ios/swift/Func_void_PhotoSavePermission.swift +46 -0
  51. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  52. package/nitrogen/generated/ios/swift/HybridReactNativePhotoLibrarySpec.swift +57 -0
  53. package/nitrogen/generated/ios/swift/HybridReactNativePhotoLibrarySpec_cxx.swift +183 -0
  54. package/nitrogen/generated/ios/swift/PhotoSavePermission.swift +34 -0
  55. package/nitrogen/generated/ios/swift/PhotoSavePermissionStatus.swift +44 -0
  56. package/nitrogen/generated/shared/c++/HybridReactNativePhotoLibrarySpec.cpp +23 -0
  57. package/nitrogen/generated/shared/c++/HybridReactNativePhotoLibrarySpec.hpp +67 -0
  58. package/nitrogen/generated/shared/c++/PhotoSavePermission.hpp +88 -0
  59. package/nitrogen/generated/shared/c++/PhotoSavePermissionStatus.hpp +80 -0
  60. package/package.json +171 -4
  61. package/src/ReactNativePhotoLibrary.nitro.ts +15 -0
  62. package/src/index.tsx +79 -0
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// PhotoSavePermission.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.reactnativephotolibrary
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 "PhotoSavePermission".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PhotoSavePermission(
21
+ @DoNotStrip
22
+ @Keep
23
+ val status: PhotoSavePermissionStatus,
24
+ @DoNotStrip
25
+ @Keep
26
+ val canAskAgain: Boolean
27
+ ) {
28
+ /* primary constructor */
29
+
30
+ override fun equals(other: Any?): Boolean {
31
+ if (this === other) return true
32
+ if (other !is PhotoSavePermission) return false
33
+ return Objects.deepEquals(this.status, other.status)
34
+ && Objects.deepEquals(this.canAskAgain, other.canAskAgain)
35
+ }
36
+
37
+ override fun hashCode(): Int {
38
+ return arrayOf<Any?>(
39
+ status,
40
+ canAskAgain
41
+ ).contentDeepHashCode()
42
+ }
43
+
44
+ companion object {
45
+ /**
46
+ * Constructor called from C++
47
+ */
48
+ @DoNotStrip
49
+ @Keep
50
+ @Suppress("unused")
51
+ @JvmStatic
52
+ private fun fromCpp(status: PhotoSavePermissionStatus, canAskAgain: Boolean): PhotoSavePermission {
53
+ return PhotoSavePermission(status, canAskAgain)
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// PhotoSavePermissionStatus.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.reactnativephotolibrary
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "PhotoSavePermissionStatus".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class PhotoSavePermissionStatus(@DoNotStrip @Keep val value: Int) {
19
+ GRANTED(0),
20
+ DENIED(1),
21
+ UNDETERMINED(2);
22
+
23
+ companion object
24
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// reactnativephotolibraryOnLoad.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.reactnativephotolibrary
9
+
10
+ import android.util.Log
11
+
12
+ internal class reactnativephotolibraryOnLoad {
13
+ companion object {
14
+ private const val TAG = "reactnativephotolibraryOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "reactnativephotolibrary".
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 reactnativephotolibrary C++ library...")
25
+ System.loadLibrary("reactnativephotolibrary")
26
+ Log.i(TAG, "Successfully loaded reactnativephotolibrary C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load reactnativephotolibrary 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,81 @@
1
+ #
2
+ # reactnativephotolibrary+autolinking.cmake
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
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/reactnativephotolibrary+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_REACTNATIVEPHOTOLIBRARY_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ reactnativephotolibrary PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/reactnativephotolibraryOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridReactNativePhotoLibrarySpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridReactNativePhotoLibrarySpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ reactnativephotolibrary PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ reactnativephotolibrary
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ reactnativephotolibrary
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ reactnativephotolibrary
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// reactnativephotolibrary+autolinking.gradle
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
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/reactnativephotolibrary+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 reactnativephotolibrary is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,54 @@
1
+ ///
2
+ /// reactnativephotolibraryOnLoad.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #ifndef BUILDING_REACTNATIVEPHOTOLIBRARY_WITH_GENERATED_CMAKE_PROJECT
9
+ #error reactnativephotolibraryOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "reactnativephotolibraryOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridReactNativePhotoLibrarySpec.hpp"
19
+ #include <NitroModules/DefaultConstructableObject.hpp>
20
+
21
+ namespace margelo::nitro::reactnativephotolibrary {
22
+
23
+ int initialize(JavaVM* vm) {
24
+ return facebook::jni::initialize(vm, []() {
25
+ ::margelo::nitro::reactnativephotolibrary::registerAllNatives();
26
+ });
27
+ }
28
+
29
+ struct JHybridReactNativePhotoLibrarySpecImpl: public jni::JavaClass<JHybridReactNativePhotoLibrarySpecImpl, JHybridReactNativePhotoLibrarySpec::JavaPart> {
30
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativephotolibrary/ReactNativePhotoLibrary;";
31
+ static std::shared_ptr<JHybridReactNativePhotoLibrarySpec> create() {
32
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridReactNativePhotoLibrarySpecImpl::javaobject()>();
33
+ jni::local_ref<JHybridReactNativePhotoLibrarySpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
34
+ return javaPart->getJHybridReactNativePhotoLibrarySpec();
35
+ }
36
+ };
37
+
38
+ void registerAllNatives() {
39
+ using namespace margelo::nitro;
40
+ using namespace margelo::nitro::reactnativephotolibrary;
41
+
42
+ // Register native JNI methods
43
+ margelo::nitro::reactnativephotolibrary::JHybridReactNativePhotoLibrarySpec::CxxPart::registerNatives();
44
+
45
+ // Register Nitro Hybrid Objects
46
+ HybridObjectRegistry::registerHybridObjectConstructor(
47
+ "ReactNativePhotoLibrary",
48
+ []() -> std::shared_ptr<HybridObject> {
49
+ return JHybridReactNativePhotoLibrarySpecImpl::create();
50
+ }
51
+ );
52
+ }
53
+
54
+ } // namespace margelo::nitro::reactnativephotolibrary
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// reactnativephotolibraryOnLoad.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
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::reactnativephotolibrary {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of reactnativephotolibrary, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all reactnativephotolibrary HybridObjects
26
+ * margelo::nitro::reactnativephotolibrary::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::reactnativephotolibrary
@@ -0,0 +1,62 @@
1
+ #
2
+ # ReactNativePhotoLibrary+autolinking.rb
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
+ # 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/ReactNativePhotoLibrary+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 ReactNativePhotoLibrary 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/ReactNativePhotoLibrary-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 ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ # Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
60
+ "SWIFT_INSTALL_OBJC_HEADER" => "NO",
61
+ })
62
+ end
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// ReactNativePhotoLibrary-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "ReactNativePhotoLibrary-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridReactNativePhotoLibrarySpecSwift.hpp"
12
+ #include "ReactNativePhotoLibrary-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::reactnativephotolibrary::bridge::swift {
16
+
17
+ // pragma MARK: std::function<void(const PhotoSavePermission& /* result */)>
18
+ Func_void_PhotoSavePermission create_Func_void_PhotoSavePermission(void* NON_NULL swiftClosureWrapper) noexcept {
19
+ auto swiftClosure = ReactNativePhotoLibrary::Func_void_PhotoSavePermission::fromUnsafe(swiftClosureWrapper);
20
+ return [swiftClosure = std::move(swiftClosure)](const PhotoSavePermission& result) mutable -> void {
21
+ swiftClosure.call(result);
22
+ };
23
+ }
24
+
25
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
26
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = ReactNativePhotoLibrary::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
29
+ swiftClosure.call(error);
30
+ };
31
+ }
32
+
33
+ // pragma MARK: std::function<void()>
34
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
35
+ auto swiftClosure = ReactNativePhotoLibrary::Func_void::fromUnsafe(swiftClosureWrapper);
36
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
37
+ swiftClosure.call();
38
+ };
39
+ }
40
+
41
+ // pragma MARK: std::shared_ptr<HybridReactNativePhotoLibrarySpec>
42
+ std::shared_ptr<HybridReactNativePhotoLibrarySpec> create_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
+ ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx swiftPart = ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx::fromUnsafe(swiftUnsafePointer);
44
+ return std::make_shared<margelo::nitro::reactnativephotolibrary::HybridReactNativePhotoLibrarySpecSwift>(swiftPart);
45
+ }
46
+ void* NON_NULL get_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(std__shared_ptr_HybridReactNativePhotoLibrarySpec_ cppType) {
47
+ std::shared_ptr<margelo::nitro::reactnativephotolibrary::HybridReactNativePhotoLibrarySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::reactnativephotolibrary::HybridReactNativePhotoLibrarySpecSwift>(cppType);
48
+ #ifdef NITRO_DEBUG
49
+ if (swiftWrapper == nullptr) [[unlikely]] {
50
+ throw std::runtime_error("Class \"HybridReactNativePhotoLibrarySpec\" is not implemented in Swift!");
51
+ }
52
+ #endif
53
+ ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
54
+ return swiftPart.toUnsafe();
55
+ }
56
+
57
+ } // namespace margelo::nitro::reactnativephotolibrary::bridge::swift
@@ -0,0 +1,159 @@
1
+ ///
2
+ /// ReactNativePhotoLibrary-Swift-Cxx-Bridge.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridReactNativePhotoLibrarySpec` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativephotolibrary { class HybridReactNativePhotoLibrarySpec; }
13
+ // Forward declaration of `PhotoSavePermissionStatus` to properly resolve imports.
14
+ namespace margelo::nitro::reactnativephotolibrary { enum class PhotoSavePermissionStatus; }
15
+ // Forward declaration of `PhotoSavePermission` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativephotolibrary { struct PhotoSavePermission; }
17
+
18
+ // Forward declarations of Swift defined types
19
+ // Forward declaration of `HybridReactNativePhotoLibrarySpec_cxx` to properly resolve imports.
20
+ namespace ReactNativePhotoLibrary { class HybridReactNativePhotoLibrarySpec_cxx; }
21
+
22
+ // Include C++ defined types
23
+ #include "HybridReactNativePhotoLibrarySpec.hpp"
24
+ #include "PhotoSavePermission.hpp"
25
+ #include "PhotoSavePermissionStatus.hpp"
26
+ #include <NitroModules/Promise.hpp>
27
+ #include <NitroModules/PromiseHolder.hpp>
28
+ #include <NitroModules/Result.hpp>
29
+ #include <exception>
30
+ #include <functional>
31
+ #include <memory>
32
+
33
+ /**
34
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
35
+ * as well as helper functions to interact with those C++ types from Swift.
36
+ */
37
+ namespace margelo::nitro::reactnativephotolibrary::bridge::swift {
38
+
39
+ // pragma MARK: std::shared_ptr<Promise<PhotoSavePermission>>
40
+ /**
41
+ * Specialized version of `std::shared_ptr<Promise<PhotoSavePermission>>`.
42
+ */
43
+ using std__shared_ptr_Promise_PhotoSavePermission__ = std::shared_ptr<Promise<PhotoSavePermission>>;
44
+ inline std::shared_ptr<Promise<PhotoSavePermission>> create_std__shared_ptr_Promise_PhotoSavePermission__() noexcept {
45
+ return Promise<PhotoSavePermission>::create();
46
+ }
47
+ inline PromiseHolder<PhotoSavePermission> wrap_std__shared_ptr_Promise_PhotoSavePermission__(std::shared_ptr<Promise<PhotoSavePermission>> promise) noexcept {
48
+ return PromiseHolder<PhotoSavePermission>(std::move(promise));
49
+ }
50
+
51
+ // pragma MARK: std::function<void(const PhotoSavePermission& /* result */)>
52
+ /**
53
+ * Specialized version of `std::function<void(const PhotoSavePermission&)>`.
54
+ */
55
+ using Func_void_PhotoSavePermission = std::function<void(const PhotoSavePermission& /* result */)>;
56
+ /**
57
+ * Wrapper class for a `std::function<void(const PhotoSavePermission& / * result * /)>`, this can be used from Swift.
58
+ */
59
+ class Func_void_PhotoSavePermission_Wrapper final {
60
+ public:
61
+ explicit Func_void_PhotoSavePermission_Wrapper(std::function<void(const PhotoSavePermission& /* result */)>&& func): _function(std::make_unique<std::function<void(const PhotoSavePermission& /* result */)>>(std::move(func))) {}
62
+ inline void call(PhotoSavePermission result) const noexcept {
63
+ _function->operator()(result);
64
+ }
65
+ private:
66
+ std::unique_ptr<std::function<void(const PhotoSavePermission& /* result */)>> _function;
67
+ } SWIFT_NONCOPYABLE;
68
+ Func_void_PhotoSavePermission create_Func_void_PhotoSavePermission(void* NON_NULL swiftClosureWrapper) noexcept;
69
+ inline Func_void_PhotoSavePermission_Wrapper wrap_Func_void_PhotoSavePermission(Func_void_PhotoSavePermission value) noexcept {
70
+ return Func_void_PhotoSavePermission_Wrapper(std::move(value));
71
+ }
72
+
73
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
74
+ /**
75
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
76
+ */
77
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
78
+ /**
79
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
80
+ */
81
+ class Func_void_std__exception_ptr_Wrapper final {
82
+ public:
83
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
84
+ inline void call(std::exception_ptr error) const noexcept {
85
+ _function->operator()(error);
86
+ }
87
+ private:
88
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
89
+ } SWIFT_NONCOPYABLE;
90
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
91
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
92
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
93
+ }
94
+
95
+ // pragma MARK: std::shared_ptr<Promise<void>>
96
+ /**
97
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
98
+ */
99
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
100
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
101
+ return Promise<void>::create();
102
+ }
103
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
104
+ return PromiseHolder<void>(std::move(promise));
105
+ }
106
+
107
+ // pragma MARK: std::function<void()>
108
+ /**
109
+ * Specialized version of `std::function<void()>`.
110
+ */
111
+ using Func_void = std::function<void()>;
112
+ /**
113
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
114
+ */
115
+ class Func_void_Wrapper final {
116
+ public:
117
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
118
+ inline void call() const noexcept {
119
+ _function->operator()();
120
+ }
121
+ private:
122
+ std::unique_ptr<std::function<void()>> _function;
123
+ } SWIFT_NONCOPYABLE;
124
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
125
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
126
+ return Func_void_Wrapper(std::move(value));
127
+ }
128
+
129
+ // pragma MARK: std::shared_ptr<HybridReactNativePhotoLibrarySpec>
130
+ /**
131
+ * Specialized version of `std::shared_ptr<HybridReactNativePhotoLibrarySpec>`.
132
+ */
133
+ using std__shared_ptr_HybridReactNativePhotoLibrarySpec_ = std::shared_ptr<HybridReactNativePhotoLibrarySpec>;
134
+ std::shared_ptr<HybridReactNativePhotoLibrarySpec> create_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(void* NON_NULL swiftUnsafePointer) noexcept;
135
+ void* NON_NULL get_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(std__shared_ptr_HybridReactNativePhotoLibrarySpec_ cppType);
136
+
137
+ // pragma MARK: std::weak_ptr<HybridReactNativePhotoLibrarySpec>
138
+ using std__weak_ptr_HybridReactNativePhotoLibrarySpec_ = std::weak_ptr<HybridReactNativePhotoLibrarySpec>;
139
+ inline std__weak_ptr_HybridReactNativePhotoLibrarySpec_ weakify_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(const std::shared_ptr<HybridReactNativePhotoLibrarySpec>& strong) noexcept { return strong; }
140
+
141
+ // pragma MARK: Result<std::shared_ptr<Promise<PhotoSavePermission>>>
142
+ using Result_std__shared_ptr_Promise_PhotoSavePermission___ = Result<std::shared_ptr<Promise<PhotoSavePermission>>>;
143
+ inline Result_std__shared_ptr_Promise_PhotoSavePermission___ create_Result_std__shared_ptr_Promise_PhotoSavePermission___(const std::shared_ptr<Promise<PhotoSavePermission>>& value) noexcept {
144
+ return Result<std::shared_ptr<Promise<PhotoSavePermission>>>::withValue(value);
145
+ }
146
+ inline Result_std__shared_ptr_Promise_PhotoSavePermission___ create_Result_std__shared_ptr_Promise_PhotoSavePermission___(const std::exception_ptr& error) noexcept {
147
+ return Result<std::shared_ptr<Promise<PhotoSavePermission>>>::withError(error);
148
+ }
149
+
150
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
151
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
152
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
153
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
154
+ }
155
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
156
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
157
+ }
158
+
159
+ } // namespace margelo::nitro::reactnativephotolibrary::bridge::swift
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// ReactNativePhotoLibrary-Swift-Cxx-Umbrella.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridReactNativePhotoLibrarySpec` to properly resolve imports.
12
+ namespace margelo::nitro::reactnativephotolibrary { class HybridReactNativePhotoLibrarySpec; }
13
+ // Forward declaration of `PhotoSavePermissionStatus` to properly resolve imports.
14
+ namespace margelo::nitro::reactnativephotolibrary { enum class PhotoSavePermissionStatus; }
15
+ // Forward declaration of `PhotoSavePermission` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativephotolibrary { struct PhotoSavePermission; }
17
+
18
+ // Include C++ defined types
19
+ #include "HybridReactNativePhotoLibrarySpec.hpp"
20
+ #include "PhotoSavePermission.hpp"
21
+ #include "PhotoSavePermissionStatus.hpp"
22
+ #include <NitroModules/Promise.hpp>
23
+ #include <NitroModules/Result.hpp>
24
+ #include <exception>
25
+ #include <memory>
26
+ #include <string>
27
+
28
+ // C++ helpers for Swift
29
+ #include "ReactNativePhotoLibrary-Swift-Cxx-Bridge.hpp"
30
+
31
+ // Common C++ types used in Swift
32
+ #include <NitroModules/ArrayBufferHolder.hpp>
33
+ #include <NitroModules/AnyMapUtils.hpp>
34
+ #include <NitroModules/RuntimeError.hpp>
35
+ #include <NitroModules/DateToChronoDate.hpp>
36
+
37
+ // Forward declarations of Swift defined types
38
+ // Forward declaration of `HybridReactNativePhotoLibrarySpec_cxx` to properly resolve imports.
39
+ namespace ReactNativePhotoLibrary { class HybridReactNativePhotoLibrarySpec_cxx; }
40
+
41
+ // Include Swift defined types
42
+ #if __has_include("ReactNativePhotoLibrary-Swift.h")
43
+ // This header is generated by Xcode/Swift on every app build.
44
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "ReactNativePhotoLibrary".
45
+ #include "ReactNativePhotoLibrary-Swift.h"
46
+ // Same as above, but used when building with frameworks (`use_frameworks`)
47
+ #elif __has_include(<ReactNativePhotoLibrary/ReactNativePhotoLibrary-Swift.h>)
48
+ #include <ReactNativePhotoLibrary/ReactNativePhotoLibrary-Swift.h>
49
+ #else
50
+ #error ReactNativePhotoLibrary's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ReactNativePhotoLibrary", and try building the app first.
51
+ #endif