@onekeyfe/react-native-device-utils 1.1.11

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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/ReactNativeDeviceUtils.podspec +29 -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/reactnativedeviceutils/ReactNativeDeviceUtils.kt +343 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtilsPackage.kt +26 -0
  11. package/ios/ReactNativeDeviceUtils.swift +41 -0
  12. package/lib/module/ReactNativeDeviceUtils.nitro.js +4 -0
  13. package/lib/module/ReactNativeDeviceUtils.nitro.js.map +1 -0
  14. package/lib/module/index.js +6 -0
  15. package/lib/module/index.js.map +1 -0
  16. package/lib/module/package.json +1 -0
  17. package/lib/typescript/package.json +1 -0
  18. package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +21 -0
  19. package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +4 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -0
  22. package/nitro.json +17 -0
  23. package/nitrogen/generated/android/c++/JDualScreenInfoRect.hpp +69 -0
  24. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  25. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +123 -0
  26. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +72 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/DualScreenInfoRect.kt +47 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_bool.kt +80 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +91 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/reactnativedeviceutilsOnLoad.kt +35 -0
  31. package/nitrogen/generated/android/reactnativedeviceutils+autolinking.cmake +81 -0
  32. package/nitrogen/generated/android/reactnativedeviceutils+autolinking.gradle +27 -0
  33. package/nitrogen/generated/android/reactnativedeviceutilsOnLoad.cpp +46 -0
  34. package/nitrogen/generated/android/reactnativedeviceutilsOnLoad.hpp +25 -0
  35. package/nitrogen/generated/ios/ReactNativeDeviceUtils+autolinking.rb +60 -0
  36. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +65 -0
  37. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +217 -0
  38. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +49 -0
  39. package/nitrogen/generated/ios/ReactNativeDeviceUtilsAutolinking.mm +33 -0
  40. package/nitrogen/generated/ios/ReactNativeDeviceUtilsAutolinking.swift +25 -0
  41. package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.cpp +11 -0
  42. package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +130 -0
  43. package/nitrogen/generated/ios/swift/DualScreenInfoRect.swift +69 -0
  44. package/nitrogen/generated/ios/swift/Func_void_DualScreenInfoRect.swift +47 -0
  45. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  46. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  47. package/nitrogen/generated/ios/swift/Func_void_std__vector_DualScreenInfoRect_.swift +47 -0
  48. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +63 -0
  49. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +237 -0
  50. package/nitrogen/generated/shared/c++/DualScreenInfoRect.hpp +87 -0
  51. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +28 -0
  52. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +73 -0
  53. package/package.json +170 -0
  54. package/src/ReactNativeDeviceUtils.nitro.ts +21 -0
  55. package/src/index.tsx +8 -0
@@ -0,0 +1,130 @@
1
+ ///
2
+ /// HybridReactNativeDeviceUtilsSpecSwift.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 "HybridReactNativeDeviceUtilsSpec.hpp"
11
+
12
+ // Forward declaration of `HybridReactNativeDeviceUtilsSpec_cxx` to properly resolve imports.
13
+ namespace ReactNativeDeviceUtils { class HybridReactNativeDeviceUtilsSpec_cxx; }
14
+
15
+ // Forward declaration of `DualScreenInfoRect` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
17
+
18
+ #include "DualScreenInfoRect.hpp"
19
+ #include <vector>
20
+ #include <NitroModules/Promise.hpp>
21
+ #include <functional>
22
+
23
+ #include "ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp"
24
+
25
+ namespace margelo::nitro::reactnativedeviceutils {
26
+
27
+ /**
28
+ * The C++ part of HybridReactNativeDeviceUtilsSpec_cxx.swift.
29
+ *
30
+ * HybridReactNativeDeviceUtilsSpecSwift (C++) accesses HybridReactNativeDeviceUtilsSpec_cxx (Swift), and might
31
+ * contain some additional bridging code for C++ <> Swift interop.
32
+ *
33
+ * Since this obviously introduces an overhead, I hope at some point in
34
+ * the future, HybridReactNativeDeviceUtilsSpec_cxx can directly inherit from the C++ class HybridReactNativeDeviceUtilsSpec
35
+ * to simplify the whole structure and memory management.
36
+ */
37
+ class HybridReactNativeDeviceUtilsSpecSwift: public virtual HybridReactNativeDeviceUtilsSpec {
38
+ public:
39
+ // Constructor from a Swift instance
40
+ explicit HybridReactNativeDeviceUtilsSpecSwift(const ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx& swiftPart):
41
+ HybridObject(HybridReactNativeDeviceUtilsSpec::TAG),
42
+ _swiftPart(swiftPart) { }
43
+
44
+ public:
45
+ // Get the Swift part
46
+ inline ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx& getSwiftPart() noexcept {
47
+ return _swiftPart;
48
+ }
49
+
50
+ public:
51
+ inline size_t getExternalMemorySize() noexcept override {
52
+ return _swiftPart.getMemorySize();
53
+ }
54
+ void dispose() noexcept override {
55
+ _swiftPart.dispose();
56
+ }
57
+ std::string toString() override {
58
+ return _swiftPart.toString();
59
+ }
60
+
61
+ public:
62
+ // Properties
63
+
64
+
65
+ public:
66
+ // Methods
67
+ inline void initEventListeners() override {
68
+ auto __result = _swiftPart.initEventListeners();
69
+ if (__result.hasError()) [[unlikely]] {
70
+ std::rethrow_exception(__result.error());
71
+ }
72
+ }
73
+ inline bool isDualScreenDevice() override {
74
+ auto __result = _swiftPart.isDualScreenDevice();
75
+ if (__result.hasError()) [[unlikely]] {
76
+ std::rethrow_exception(__result.error());
77
+ }
78
+ auto __value = std::move(__result.value());
79
+ return __value;
80
+ }
81
+ inline bool isSpanning() override {
82
+ auto __result = _swiftPart.isSpanning();
83
+ if (__result.hasError()) [[unlikely]] {
84
+ std::rethrow_exception(__result.error());
85
+ }
86
+ auto __value = std::move(__result.value());
87
+ return __value;
88
+ }
89
+ inline std::shared_ptr<Promise<std::vector<DualScreenInfoRect>>> getWindowRects() override {
90
+ auto __result = _swiftPart.getWindowRects();
91
+ if (__result.hasError()) [[unlikely]] {
92
+ std::rethrow_exception(__result.error());
93
+ }
94
+ auto __value = std::move(__result.value());
95
+ return __value;
96
+ }
97
+ inline std::shared_ptr<Promise<DualScreenInfoRect>> getHingeBounds() override {
98
+ auto __result = _swiftPart.getHingeBounds();
99
+ if (__result.hasError()) [[unlikely]] {
100
+ std::rethrow_exception(__result.error());
101
+ }
102
+ auto __value = std::move(__result.value());
103
+ return __value;
104
+ }
105
+ inline void changeBackgroundColor(double r, double g, double b, double a) override {
106
+ auto __result = _swiftPart.changeBackgroundColor(std::forward<decltype(r)>(r), std::forward<decltype(g)>(g), std::forward<decltype(b)>(b), std::forward<decltype(a)>(a));
107
+ if (__result.hasError()) [[unlikely]] {
108
+ std::rethrow_exception(__result.error());
109
+ }
110
+ }
111
+ inline double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) override {
112
+ auto __result = _swiftPart.addSpanningChangedListener(callback);
113
+ if (__result.hasError()) [[unlikely]] {
114
+ std::rethrow_exception(__result.error());
115
+ }
116
+ auto __value = std::move(__result.value());
117
+ return __value;
118
+ }
119
+ inline void removeSpanningChangedListener(double id) override {
120
+ auto __result = _swiftPart.removeSpanningChangedListener(std::forward<decltype(id)>(id));
121
+ if (__result.hasError()) [[unlikely]] {
122
+ std::rethrow_exception(__result.error());
123
+ }
124
+ }
125
+
126
+ private:
127
+ ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx _swiftPart;
128
+ };
129
+
130
+ } // namespace margelo::nitro::reactnativedeviceutils
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// DualScreenInfoRect.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `DualScreenInfoRect`, backed by a C++ struct.
13
+ */
14
+ public typealias DualScreenInfoRect = margelo.nitro.reactnativedeviceutils.DualScreenInfoRect
15
+
16
+ public extension DualScreenInfoRect {
17
+ private typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `DualScreenInfoRect`.
21
+ */
22
+ init(x: Double, y: Double, width: Double, height: Double) {
23
+ self.init(x, y, width, height)
24
+ }
25
+
26
+ var x: Double {
27
+ @inline(__always)
28
+ get {
29
+ return self.__x
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__x = newValue
34
+ }
35
+ }
36
+
37
+ var y: Double {
38
+ @inline(__always)
39
+ get {
40
+ return self.__y
41
+ }
42
+ @inline(__always)
43
+ set {
44
+ self.__y = newValue
45
+ }
46
+ }
47
+
48
+ var width: Double {
49
+ @inline(__always)
50
+ get {
51
+ return self.__width
52
+ }
53
+ @inline(__always)
54
+ set {
55
+ self.__width = newValue
56
+ }
57
+ }
58
+
59
+ var height: Double {
60
+ @inline(__always)
61
+ get {
62
+ return self.__height
63
+ }
64
+ @inline(__always)
65
+ set {
66
+ self.__height = newValue
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_DualScreenInfoRect.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: DualScreenInfoRect) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_DualScreenInfoRect {
16
+ public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
17
+
18
+ private let closure: (_ value: DualScreenInfoRect) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: DualScreenInfoRect) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: DualScreenInfoRect) -> Void {
26
+ self.closure(value)
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_DualScreenInfoRect`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_DualScreenInfoRect>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_DualScreenInfoRect {
45
+ return Unmanaged<Func_void_DualScreenInfoRect>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_bool.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ isSpanning: Bool) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_bool {
16
+ public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
17
+
18
+ private let closure: (_ isSpanning: Bool) -> Void
19
+
20
+ public init(_ closure: @escaping (_ isSpanning: Bool) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(isSpanning: Bool) -> Void {
26
+ self.closure(isSpanning)
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_bool`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
45
+ return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
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 © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__exception_ptr {
16
+ public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
17
+
18
+ private let closure: (_ error: Error) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: std.exception_ptr) -> Void {
26
+ self.closure(RuntimeError.from(cppError: error))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
45
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_std__vector_DualScreenInfoRect_.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: [DualScreenInfoRect]) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__vector_DualScreenInfoRect_ {
16
+ public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
17
+
18
+ private let closure: (_ value: [DualScreenInfoRect]) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: [DualScreenInfoRect]) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: bridge.std__vector_DualScreenInfoRect_) -> Void {
26
+ self.closure(value.map({ __item in __item }))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__vector_DualScreenInfoRect_`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_DualScreenInfoRect_>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_DualScreenInfoRect_ {
45
+ return Unmanaged<Func_void_std__vector_DualScreenInfoRect_>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridReactNativeDeviceUtilsSpec.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridReactNativeDeviceUtilsSpec``
12
+ public protocol HybridReactNativeDeviceUtilsSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func initEventListeners() throws -> Void
18
+ func isDualScreenDevice() throws -> Bool
19
+ func isSpanning() throws -> Bool
20
+ func getWindowRects() throws -> Promise<[DualScreenInfoRect]>
21
+ func getHingeBounds() throws -> Promise<DualScreenInfoRect>
22
+ func changeBackgroundColor(r: Double, g: Double, b: Double, a: Double) throws -> Void
23
+ func addSpanningChangedListener(callback: @escaping (_ isSpanning: Bool) -> Void) throws -> Double
24
+ func removeSpanningChangedListener(id: Double) throws -> Void
25
+ }
26
+
27
+ public extension HybridReactNativeDeviceUtilsSpec_protocol {
28
+ /// Default implementation of ``HybridObject.toString``
29
+ func toString() -> String {
30
+ return "[HybridObject ReactNativeDeviceUtils]"
31
+ }
32
+ }
33
+
34
+ /// See ``HybridReactNativeDeviceUtilsSpec``
35
+ open class HybridReactNativeDeviceUtilsSpec_base {
36
+ private weak var cxxWrapper: HybridReactNativeDeviceUtilsSpec_cxx? = nil
37
+ public init() { }
38
+ public func getCxxWrapper() -> HybridReactNativeDeviceUtilsSpec_cxx {
39
+ #if DEBUG
40
+ guard self is HybridReactNativeDeviceUtilsSpec else {
41
+ fatalError("`self` is not a `HybridReactNativeDeviceUtilsSpec`! Did you accidentally inherit from `HybridReactNativeDeviceUtilsSpec_base` instead of `HybridReactNativeDeviceUtilsSpec`?")
42
+ }
43
+ #endif
44
+ if let cxxWrapper = self.cxxWrapper {
45
+ return cxxWrapper
46
+ } else {
47
+ let cxxWrapper = HybridReactNativeDeviceUtilsSpec_cxx(self as! HybridReactNativeDeviceUtilsSpec)
48
+ self.cxxWrapper = cxxWrapper
49
+ return cxxWrapper
50
+ }
51
+ }
52
+ }
53
+
54
+ /**
55
+ * A Swift base-protocol representing the ReactNativeDeviceUtils HybridObject.
56
+ * Implement this protocol to create Swift-based instances of ReactNativeDeviceUtils.
57
+ * ```swift
58
+ * class HybridReactNativeDeviceUtils : HybridReactNativeDeviceUtilsSpec {
59
+ * // ...
60
+ * }
61
+ * ```
62
+ */
63
+ public typealias HybridReactNativeDeviceUtilsSpec = HybridReactNativeDeviceUtilsSpec_protocol & HybridReactNativeDeviceUtilsSpec_base
@@ -0,0 +1,237 @@
1
+ ///
2
+ /// HybridReactNativeDeviceUtilsSpec_cxx.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridReactNativeDeviceUtilsSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridReactNativeDeviceUtilsSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativedeviceutils::bridge::swift`)
23
+ * from `ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridReactNativeDeviceUtilsSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridReactNativeDeviceUtilsSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridReactNativeDeviceUtilsSpec_
37
+
38
+ /**
39
+ * Create a new `HybridReactNativeDeviceUtilsSpec_cxx` that wraps the given `HybridReactNativeDeviceUtilsSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridReactNativeDeviceUtilsSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridReactNativeDeviceUtilsSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridReactNativeDeviceUtilsSpec() -> any HybridReactNativeDeviceUtilsSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridReactNativeDeviceUtilsSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridReactNativeDeviceUtilsSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridReactNativeDeviceUtilsSpec_cxx {
70
+ return Unmanaged<HybridReactNativeDeviceUtilsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridReactNativeDeviceUtilsSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridReactNativeDeviceUtilsSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridReactNativeDeviceUtilsSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridReactNativeDeviceUtilsSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ /**
109
+ * Call toString() on the Swift class.
110
+ */
111
+ @inline(__always)
112
+ public func toString() -> String {
113
+ return self.__implementation.toString()
114
+ }
115
+
116
+ // Properties
117
+
118
+
119
+ // Methods
120
+ @inline(__always)
121
+ public final func initEventListeners() -> bridge.Result_void_ {
122
+ do {
123
+ try self.__implementation.initEventListeners()
124
+ return bridge.create_Result_void_()
125
+ } catch (let __error) {
126
+ let __exceptionPtr = __error.toCpp()
127
+ return bridge.create_Result_void_(__exceptionPtr)
128
+ }
129
+ }
130
+
131
+ @inline(__always)
132
+ public final func isDualScreenDevice() -> bridge.Result_bool_ {
133
+ do {
134
+ let __result = try self.__implementation.isDualScreenDevice()
135
+ let __resultCpp = __result
136
+ return bridge.create_Result_bool_(__resultCpp)
137
+ } catch (let __error) {
138
+ let __exceptionPtr = __error.toCpp()
139
+ return bridge.create_Result_bool_(__exceptionPtr)
140
+ }
141
+ }
142
+
143
+ @inline(__always)
144
+ public final func isSpanning() -> bridge.Result_bool_ {
145
+ do {
146
+ let __result = try self.__implementation.isSpanning()
147
+ let __resultCpp = __result
148
+ return bridge.create_Result_bool_(__resultCpp)
149
+ } catch (let __error) {
150
+ let __exceptionPtr = __error.toCpp()
151
+ return bridge.create_Result_bool_(__exceptionPtr)
152
+ }
153
+ }
154
+
155
+ @inline(__always)
156
+ public final func getWindowRects() -> bridge.Result_std__shared_ptr_Promise_std__vector_DualScreenInfoRect____ {
157
+ do {
158
+ let __result = try self.__implementation.getWindowRects()
159
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__vector_DualScreenInfoRect___ in
160
+ let __promise = bridge.create_std__shared_ptr_Promise_std__vector_DualScreenInfoRect___()
161
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__vector_DualScreenInfoRect___(__promise)
162
+ __result
163
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__vector_DualScreenInfoRect_ in
164
+ var __vector = bridge.create_std__vector_DualScreenInfoRect_(__result.count)
165
+ for __item in __result {
166
+ __vector.push_back(__item)
167
+ }
168
+ return __vector
169
+ }()) })
170
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
171
+ return __promise
172
+ }()
173
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_DualScreenInfoRect____(__resultCpp)
174
+ } catch (let __error) {
175
+ let __exceptionPtr = __error.toCpp()
176
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_DualScreenInfoRect____(__exceptionPtr)
177
+ }
178
+ }
179
+
180
+ @inline(__always)
181
+ public final func getHingeBounds() -> bridge.Result_std__shared_ptr_Promise_DualScreenInfoRect___ {
182
+ do {
183
+ let __result = try self.__implementation.getHingeBounds()
184
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_DualScreenInfoRect__ in
185
+ let __promise = bridge.create_std__shared_ptr_Promise_DualScreenInfoRect__()
186
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_DualScreenInfoRect__(__promise)
187
+ __result
188
+ .then({ __result in __promiseHolder.resolve(__result) })
189
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
190
+ return __promise
191
+ }()
192
+ return bridge.create_Result_std__shared_ptr_Promise_DualScreenInfoRect___(__resultCpp)
193
+ } catch (let __error) {
194
+ let __exceptionPtr = __error.toCpp()
195
+ return bridge.create_Result_std__shared_ptr_Promise_DualScreenInfoRect___(__exceptionPtr)
196
+ }
197
+ }
198
+
199
+ @inline(__always)
200
+ public final func changeBackgroundColor(r: Double, g: Double, b: Double, a: Double) -> bridge.Result_void_ {
201
+ do {
202
+ try self.__implementation.changeBackgroundColor(r: r, g: g, b: b, a: a)
203
+ return bridge.create_Result_void_()
204
+ } catch (let __error) {
205
+ let __exceptionPtr = __error.toCpp()
206
+ return bridge.create_Result_void_(__exceptionPtr)
207
+ }
208
+ }
209
+
210
+ @inline(__always)
211
+ public final func addSpanningChangedListener(callback: bridge.Func_void_bool) -> bridge.Result_double_ {
212
+ do {
213
+ let __result = try self.__implementation.addSpanningChangedListener(callback: { () -> (Bool) -> Void in
214
+ let __wrappedFunction = bridge.wrap_Func_void_bool(callback)
215
+ return { (__isSpanning: Bool) -> Void in
216
+ __wrappedFunction.call(__isSpanning)
217
+ }
218
+ }())
219
+ let __resultCpp = __result
220
+ return bridge.create_Result_double_(__resultCpp)
221
+ } catch (let __error) {
222
+ let __exceptionPtr = __error.toCpp()
223
+ return bridge.create_Result_double_(__exceptionPtr)
224
+ }
225
+ }
226
+
227
+ @inline(__always)
228
+ public final func removeSpanningChangedListener(id: Double) -> bridge.Result_void_ {
229
+ do {
230
+ try self.__implementation.removeSpanningChangedListener(id: id)
231
+ return bridge.create_Result_void_()
232
+ } catch (let __error) {
233
+ let __exceptionPtr = __error.toCpp()
234
+ return bridge.create_Result_void_(__exceptionPtr)
235
+ }
236
+ }
237
+ }