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

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,33 @@
1
+ ///
2
+ /// ReactNativePhotoLibraryAutolinking.mm
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 <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "ReactNativePhotoLibrary-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridReactNativePhotoLibrarySpecSwift.hpp"
14
+
15
+ @interface ReactNativePhotoLibraryAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation ReactNativePhotoLibraryAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::reactnativephotolibrary;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "ReactNativePhotoLibrary",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridReactNativePhotoLibrarySpec> hybridObject = ReactNativePhotoLibrary::ReactNativePhotoLibraryAutolinking::createReactNativePhotoLibrary();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// ReactNativePhotoLibraryAutolinking.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
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class ReactNativePhotoLibraryAutolinking {
13
+ public typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
14
+
15
+ public static func createReactNativePhotoLibrary() -> bridge.std__shared_ptr_HybridReactNativePhotoLibrarySpec_ {
16
+ let hybridObject = ReactNativePhotoLibrary()
17
+ return { () -> bridge.std__shared_ptr_HybridReactNativePhotoLibrarySpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isReactNativePhotoLibraryRecyclable() -> Bool {
24
+ return ReactNativePhotoLibrary.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridReactNativePhotoLibrarySpecSwift.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 "HybridReactNativePhotoLibrarySpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::reactnativephotolibrary {
11
+ } // namespace margelo::nitro::reactnativephotolibrary
@@ -0,0 +1,104 @@
1
+ ///
2
+ /// HybridReactNativePhotoLibrarySpecSwift.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 "HybridReactNativePhotoLibrarySpec.hpp"
11
+
12
+ // Forward declaration of `HybridReactNativePhotoLibrarySpec_cxx` to properly resolve imports.
13
+ namespace ReactNativePhotoLibrary { class HybridReactNativePhotoLibrarySpec_cxx; }
14
+
15
+ // Forward declaration of `PhotoSavePermission` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativephotolibrary { struct PhotoSavePermission; }
17
+ // Forward declaration of `PhotoSavePermissionStatus` to properly resolve imports.
18
+ namespace margelo::nitro::reactnativephotolibrary { enum class PhotoSavePermissionStatus; }
19
+
20
+ #include "PhotoSavePermission.hpp"
21
+ #include <NitroModules/Promise.hpp>
22
+ #include "PhotoSavePermissionStatus.hpp"
23
+ #include <string>
24
+
25
+ #include "ReactNativePhotoLibrary-Swift-Cxx-Umbrella.hpp"
26
+
27
+ namespace margelo::nitro::reactnativephotolibrary {
28
+
29
+ /**
30
+ * The C++ part of HybridReactNativePhotoLibrarySpec_cxx.swift.
31
+ *
32
+ * HybridReactNativePhotoLibrarySpecSwift (C++) accesses HybridReactNativePhotoLibrarySpec_cxx (Swift), and might
33
+ * contain some additional bridging code for C++ <> Swift interop.
34
+ *
35
+ * Since this obviously introduces an overhead, I hope at some point in
36
+ * the future, HybridReactNativePhotoLibrarySpec_cxx can directly inherit from the C++ class HybridReactNativePhotoLibrarySpec
37
+ * to simplify the whole structure and memory management.
38
+ */
39
+ class HybridReactNativePhotoLibrarySpecSwift: public virtual HybridReactNativePhotoLibrarySpec {
40
+ public:
41
+ // Constructor from a Swift instance
42
+ explicit HybridReactNativePhotoLibrarySpecSwift(const ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx& swiftPart):
43
+ HybridObject(HybridReactNativePhotoLibrarySpec::TAG),
44
+ _swiftPart(swiftPart) { }
45
+
46
+ public:
47
+ // Get the Swift part
48
+ inline ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx& getSwiftPart() noexcept {
49
+ return _swiftPart;
50
+ }
51
+
52
+ public:
53
+ inline size_t getExternalMemorySize() noexcept override {
54
+ return _swiftPart.getMemorySize();
55
+ }
56
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
57
+ if (auto otherCast = std::dynamic_pointer_cast<HybridReactNativePhotoLibrarySpecSwift>(other)) {
58
+ return _swiftPart.equals(otherCast->_swiftPart);
59
+ }
60
+ return false;
61
+ }
62
+ void dispose() noexcept override {
63
+ _swiftPart.dispose();
64
+ }
65
+ std::string toString() override {
66
+ return _swiftPart.toString();
67
+ }
68
+
69
+ public:
70
+ // Properties
71
+
72
+
73
+ public:
74
+ // Methods
75
+ inline std::shared_ptr<Promise<PhotoSavePermission>> getSavePermission() override {
76
+ auto __result = _swiftPart.getSavePermission();
77
+ if (__result.hasError()) [[unlikely]] {
78
+ std::rethrow_exception(__result.error());
79
+ }
80
+ auto __value = std::move(__result.value());
81
+ return __value;
82
+ }
83
+ inline std::shared_ptr<Promise<PhotoSavePermission>> requestSavePermission() override {
84
+ auto __result = _swiftPart.requestSavePermission();
85
+ if (__result.hasError()) [[unlikely]] {
86
+ std::rethrow_exception(__result.error());
87
+ }
88
+ auto __value = std::move(__result.value());
89
+ return __value;
90
+ }
91
+ inline std::shared_ptr<Promise<void>> saveToLibrary(const std::string& path) override {
92
+ auto __result = _swiftPart.saveToLibrary(path);
93
+ if (__result.hasError()) [[unlikely]] {
94
+ std::rethrow_exception(__result.error());
95
+ }
96
+ auto __value = std::move(__result.value());
97
+ return __value;
98
+ }
99
+
100
+ private:
101
+ ReactNativePhotoLibrary::HybridReactNativePhotoLibrarySpec_cxx _swiftPart;
102
+ };
103
+
104
+ } // namespace margelo::nitro::reactnativephotolibrary
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `() -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void {
15
+ public typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
16
+
17
+ private let closure: () -> Void
18
+
19
+ public init(_ closure: @escaping () -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call() -> Void {
25
+ self.closure()
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
44
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_PhotoSavePermission.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ value: PhotoSavePermission) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_PhotoSavePermission {
15
+ public typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
16
+
17
+ private let closure: (_ value: PhotoSavePermission) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: PhotoSavePermission) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: PhotoSavePermission) -> Void {
25
+ self.closure(value)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_PhotoSavePermission`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_PhotoSavePermission>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PhotoSavePermission {
44
+ return Unmanaged<Func_void_PhotoSavePermission>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridReactNativePhotoLibrarySpec.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
+ /// See ``HybridReactNativePhotoLibrarySpec``
11
+ public protocol HybridReactNativePhotoLibrarySpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func getSavePermission() throws -> Promise<PhotoSavePermission>
17
+ func requestSavePermission() throws -> Promise<PhotoSavePermission>
18
+ func saveToLibrary(path: String) throws -> Promise<Void>
19
+ }
20
+
21
+ public extension HybridReactNativePhotoLibrarySpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject ReactNativePhotoLibrary]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridReactNativePhotoLibrarySpec``
29
+ open class HybridReactNativePhotoLibrarySpec_base {
30
+ private weak var cxxWrapper: HybridReactNativePhotoLibrarySpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridReactNativePhotoLibrarySpec_cxx {
33
+ #if DEBUG
34
+ guard self is any HybridReactNativePhotoLibrarySpec else {
35
+ fatalError("`self` is not a `HybridReactNativePhotoLibrarySpec`! Did you accidentally inherit from `HybridReactNativePhotoLibrarySpec_base` instead of `HybridReactNativePhotoLibrarySpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridReactNativePhotoLibrarySpec_cxx(self as! any HybridReactNativePhotoLibrarySpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the ReactNativePhotoLibrary HybridObject.
50
+ * Implement this protocol to create Swift-based instances of ReactNativePhotoLibrary.
51
+ * ```swift
52
+ * class HybridReactNativePhotoLibrary : HybridReactNativePhotoLibrarySpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridReactNativePhotoLibrarySpec = HybridReactNativePhotoLibrarySpec_protocol & HybridReactNativePhotoLibrarySpec_base
@@ -0,0 +1,183 @@
1
+ ///
2
+ /// HybridReactNativePhotoLibrarySpec_cxx.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
+ * A class implementation that bridges HybridReactNativePhotoLibrarySpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridReactNativePhotoLibrarySpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativephotolibrary::bridge::swift`)
22
+ * from `ReactNativePhotoLibrary-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridReactNativePhotoLibrarySpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridReactNativePhotoLibrarySpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridReactNativePhotoLibrarySpec_
36
+
37
+ /**
38
+ * Create a new `HybridReactNativePhotoLibrarySpec_cxx` that wraps the given `HybridReactNativePhotoLibrarySpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridReactNativePhotoLibrarySpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridReactNativePhotoLibrarySpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridReactNativePhotoLibrarySpec() -> any HybridReactNativePhotoLibrarySpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridReactNativePhotoLibrarySpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridReactNativePhotoLibrarySpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridReactNativePhotoLibrarySpec_cxx {
69
+ return Unmanaged<HybridReactNativePhotoLibrarySpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridReactNativePhotoLibrarySpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridReactNativePhotoLibrarySpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridReactNativePhotoLibrarySpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridReactNativePhotoLibrarySpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func getSavePermission() -> bridge.Result_std__shared_ptr_Promise_PhotoSavePermission___ {
129
+ do {
130
+ let __result = try self.__implementation.getSavePermission()
131
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PhotoSavePermission__ in
132
+ let __promise = bridge.create_std__shared_ptr_Promise_PhotoSavePermission__()
133
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PhotoSavePermission__(__promise)
134
+ __result
135
+ .then({ __result in __promiseHolder.resolve(__result) })
136
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
137
+ return __promise
138
+ }()
139
+ return bridge.create_Result_std__shared_ptr_Promise_PhotoSavePermission___(__resultCpp)
140
+ } catch (let __error) {
141
+ let __exceptionPtr = __error.toCpp()
142
+ return bridge.create_Result_std__shared_ptr_Promise_PhotoSavePermission___(__exceptionPtr)
143
+ }
144
+ }
145
+
146
+ @inline(__always)
147
+ public final func requestSavePermission() -> bridge.Result_std__shared_ptr_Promise_PhotoSavePermission___ {
148
+ do {
149
+ let __result = try self.__implementation.requestSavePermission()
150
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PhotoSavePermission__ in
151
+ let __promise = bridge.create_std__shared_ptr_Promise_PhotoSavePermission__()
152
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PhotoSavePermission__(__promise)
153
+ __result
154
+ .then({ __result in __promiseHolder.resolve(__result) })
155
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
156
+ return __promise
157
+ }()
158
+ return bridge.create_Result_std__shared_ptr_Promise_PhotoSavePermission___(__resultCpp)
159
+ } catch (let __error) {
160
+ let __exceptionPtr = __error.toCpp()
161
+ return bridge.create_Result_std__shared_ptr_Promise_PhotoSavePermission___(__exceptionPtr)
162
+ }
163
+ }
164
+
165
+ @inline(__always)
166
+ public final func saveToLibrary(path: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
167
+ do {
168
+ let __result = try self.__implementation.saveToLibrary(path: String(path))
169
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
170
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
171
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
172
+ __result
173
+ .then({ __result in __promiseHolder.resolve() })
174
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
175
+ return __promise
176
+ }()
177
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
178
+ } catch (let __error) {
179
+ let __exceptionPtr = __error.toCpp()
180
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
181
+ }
182
+ }
183
+ }
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// PhotoSavePermission.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 `PhotoSavePermission`, backed by a C++ struct.
12
+ */
13
+ public typealias PhotoSavePermission = margelo.nitro.reactnativephotolibrary.PhotoSavePermission
14
+
15
+ public extension PhotoSavePermission {
16
+ private typealias bridge = margelo.nitro.reactnativephotolibrary.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `PhotoSavePermission`.
20
+ */
21
+ init(status: PhotoSavePermissionStatus, canAskAgain: Bool) {
22
+ self.init(status, canAskAgain)
23
+ }
24
+
25
+ @inline(__always)
26
+ var status: PhotoSavePermissionStatus {
27
+ return self.__status
28
+ }
29
+
30
+ @inline(__always)
31
+ var canAskAgain: Bool {
32
+ return self.__canAskAgain
33
+ }
34
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// PhotoSavePermissionStatus.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `PhotoSavePermissionStatus`, backed by a C++ enum.
10
+ */
11
+ public typealias PhotoSavePermissionStatus = margelo.nitro.reactnativephotolibrary.PhotoSavePermissionStatus
12
+
13
+ public extension PhotoSavePermissionStatus {
14
+ /**
15
+ * Get a PhotoSavePermissionStatus for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "granted":
21
+ self = .granted
22
+ case "denied":
23
+ self = .denied
24
+ case "undetermined":
25
+ self = .undetermined
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this PhotoSavePermissionStatus represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .granted:
37
+ return "granted"
38
+ case .denied:
39
+ return "denied"
40
+ case .undetermined:
41
+ return "undetermined"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// HybridReactNativePhotoLibrarySpec.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 "HybridReactNativePhotoLibrarySpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativephotolibrary {
11
+
12
+ void HybridReactNativePhotoLibrarySpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("getSavePermission", &HybridReactNativePhotoLibrarySpec::getSavePermission);
18
+ prototype.registerHybridMethod("requestSavePermission", &HybridReactNativePhotoLibrarySpec::requestSavePermission);
19
+ prototype.registerHybridMethod("saveToLibrary", &HybridReactNativePhotoLibrarySpec::saveToLibrary);
20
+ });
21
+ }
22
+
23
+ } // namespace margelo::nitro::reactnativephotolibrary