@onekeyfe/react-native-perf-memory 1.1.21

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/ReactNativePerfMemory.podspec +30 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +130 -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/reactnativeperfmemory/ReactNativePerfMemory.kt +67 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativeperfmemory/ReactNativePerfMemoryPackage.kt +24 -0
  11. package/ios/ReactNativePerfMemory.swift +41 -0
  12. package/lib/module/ReactNativePerfMemory.nitro.js +4 -0
  13. package/lib/module/ReactNativePerfMemory.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/ReactNativePerfMemory.nitro.d.ts +11 -0
  19. package/lib/typescript/src/ReactNativePerfMemory.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++/JHybridReactNativePerfMemorySpec.cpp +67 -0
  24. package/nitrogen/generated/android/c++/JHybridReactNativePerfMemorySpec.hpp +65 -0
  25. package/nitrogen/generated/android/c++/JMemoryUsage.hpp +57 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/HybridReactNativePerfMemorySpec.kt +58 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/MemoryUsage.kt +38 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/reactnativeperfmemoryOnLoad.kt +35 -0
  29. package/nitrogen/generated/android/reactnativeperfmemory+autolinking.cmake +81 -0
  30. package/nitrogen/generated/android/reactnativeperfmemory+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/reactnativeperfmemoryOnLoad.cpp +44 -0
  32. package/nitrogen/generated/android/reactnativeperfmemoryOnLoad.hpp +25 -0
  33. package/nitrogen/generated/ios/ReactNativePerfMemory+autolinking.rb +60 -0
  34. package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Bridge.cpp +49 -0
  35. package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Bridge.hpp +113 -0
  36. package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Umbrella.hpp +47 -0
  37. package/nitrogen/generated/ios/ReactNativePerfMemoryAutolinking.mm +33 -0
  38. package/nitrogen/generated/ios/ReactNativePerfMemoryAutolinking.swift +25 -0
  39. package/nitrogen/generated/ios/c++/HybridReactNativePerfMemorySpecSwift.cpp +11 -0
  40. package/nitrogen/generated/ios/c++/HybridReactNativePerfMemorySpecSwift.hpp +78 -0
  41. package/nitrogen/generated/ios/swift/Func_void_MemoryUsage.swift +47 -0
  42. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  43. package/nitrogen/generated/ios/swift/HybridReactNativePerfMemorySpec.swift +56 -0
  44. package/nitrogen/generated/ios/swift/HybridReactNativePerfMemorySpec_cxx.swift +138 -0
  45. package/nitrogen/generated/ios/swift/MemoryUsage.swift +36 -0
  46. package/nitrogen/generated/shared/c++/HybridReactNativePerfMemorySpec.cpp +21 -0
  47. package/nitrogen/generated/shared/c++/HybridReactNativePerfMemorySpec.hpp +64 -0
  48. package/nitrogen/generated/shared/c++/MemoryUsage.hpp +75 -0
  49. package/package.json +169 -0
  50. package/src/ReactNativePerfMemory.nitro.ts +10 -0
  51. package/src/index.tsx +8 -0
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// HybridReactNativePerfMemorySpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridReactNativePerfMemorySpec.hpp"
11
+
12
+ // Forward declaration of `HybridReactNativePerfMemorySpec_cxx` to properly resolve imports.
13
+ namespace ReactNativePerfMemory { class HybridReactNativePerfMemorySpec_cxx; }
14
+
15
+ // Forward declaration of `MemoryUsage` to properly resolve imports.
16
+ namespace margelo::nitro::reactnativeperfmemory { struct MemoryUsage; }
17
+
18
+ #include "MemoryUsage.hpp"
19
+ #include <NitroModules/Promise.hpp>
20
+
21
+ #include "ReactNativePerfMemory-Swift-Cxx-Umbrella.hpp"
22
+
23
+ namespace margelo::nitro::reactnativeperfmemory {
24
+
25
+ /**
26
+ * The C++ part of HybridReactNativePerfMemorySpec_cxx.swift.
27
+ *
28
+ * HybridReactNativePerfMemorySpecSwift (C++) accesses HybridReactNativePerfMemorySpec_cxx (Swift), and might
29
+ * contain some additional bridging code for C++ <> Swift interop.
30
+ *
31
+ * Since this obviously introduces an overhead, I hope at some point in
32
+ * the future, HybridReactNativePerfMemorySpec_cxx can directly inherit from the C++ class HybridReactNativePerfMemorySpec
33
+ * to simplify the whole structure and memory management.
34
+ */
35
+ class HybridReactNativePerfMemorySpecSwift: public virtual HybridReactNativePerfMemorySpec {
36
+ public:
37
+ // Constructor from a Swift instance
38
+ explicit HybridReactNativePerfMemorySpecSwift(const ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx& swiftPart):
39
+ HybridObject(HybridReactNativePerfMemorySpec::TAG),
40
+ _swiftPart(swiftPart) { }
41
+
42
+ public:
43
+ // Get the Swift part
44
+ inline ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx& getSwiftPart() noexcept {
45
+ return _swiftPart;
46
+ }
47
+
48
+ public:
49
+ inline size_t getExternalMemorySize() noexcept override {
50
+ return _swiftPart.getMemorySize();
51
+ }
52
+ void dispose() noexcept override {
53
+ _swiftPart.dispose();
54
+ }
55
+ std::string toString() override {
56
+ return _swiftPart.toString();
57
+ }
58
+
59
+ public:
60
+ // Properties
61
+
62
+
63
+ public:
64
+ // Methods
65
+ inline std::shared_ptr<Promise<MemoryUsage>> getMemoryUsage() override {
66
+ auto __result = _swiftPart.getMemoryUsage();
67
+ if (__result.hasError()) [[unlikely]] {
68
+ std::rethrow_exception(__result.error());
69
+ }
70
+ auto __value = std::move(__result.value());
71
+ return __value;
72
+ }
73
+
74
+ private:
75
+ ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx _swiftPart;
76
+ };
77
+
78
+ } // namespace margelo::nitro::reactnativeperfmemory
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_MemoryUsage.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: MemoryUsage) -> 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_MemoryUsage {
16
+ public typealias bridge = margelo.nitro.reactnativeperfmemory.bridge.swift
17
+
18
+ private let closure: (_ value: MemoryUsage) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: MemoryUsage) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: MemoryUsage) -> 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_MemoryUsage`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_MemoryUsage>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_MemoryUsage {
45
+ return Unmanaged<Func_void_MemoryUsage>.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 © 2026 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.reactnativeperfmemory.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,56 @@
1
+ ///
2
+ /// HybridReactNativePerfMemorySpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridReactNativePerfMemorySpec``
12
+ public protocol HybridReactNativePerfMemorySpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func getMemoryUsage() throws -> Promise<MemoryUsage>
18
+ }
19
+
20
+ public extension HybridReactNativePerfMemorySpec_protocol {
21
+ /// Default implementation of ``HybridObject.toString``
22
+ func toString() -> String {
23
+ return "[HybridObject ReactNativePerfMemory]"
24
+ }
25
+ }
26
+
27
+ /// See ``HybridReactNativePerfMemorySpec``
28
+ open class HybridReactNativePerfMemorySpec_base {
29
+ private weak var cxxWrapper: HybridReactNativePerfMemorySpec_cxx? = nil
30
+ public init() { }
31
+ public func getCxxWrapper() -> HybridReactNativePerfMemorySpec_cxx {
32
+ #if DEBUG
33
+ guard self is HybridReactNativePerfMemorySpec else {
34
+ fatalError("`self` is not a `HybridReactNativePerfMemorySpec`! Did you accidentally inherit from `HybridReactNativePerfMemorySpec_base` instead of `HybridReactNativePerfMemorySpec`?")
35
+ }
36
+ #endif
37
+ if let cxxWrapper = self.cxxWrapper {
38
+ return cxxWrapper
39
+ } else {
40
+ let cxxWrapper = HybridReactNativePerfMemorySpec_cxx(self as! HybridReactNativePerfMemorySpec)
41
+ self.cxxWrapper = cxxWrapper
42
+ return cxxWrapper
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * A Swift base-protocol representing the ReactNativePerfMemory HybridObject.
49
+ * Implement this protocol to create Swift-based instances of ReactNativePerfMemory.
50
+ * ```swift
51
+ * class HybridReactNativePerfMemory : HybridReactNativePerfMemorySpec {
52
+ * // ...
53
+ * }
54
+ * ```
55
+ */
56
+ public typealias HybridReactNativePerfMemorySpec = HybridReactNativePerfMemorySpec_protocol & HybridReactNativePerfMemorySpec_base
@@ -0,0 +1,138 @@
1
+ ///
2
+ /// HybridReactNativePerfMemorySpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridReactNativePerfMemorySpec 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 HybridReactNativePerfMemorySpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativeperfmemory::bridge::swift`)
23
+ * from `ReactNativePerfMemory-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.reactnativeperfmemory.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridReactNativePerfMemorySpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridReactNativePerfMemorySpec
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_HybridReactNativePerfMemorySpec_
37
+
38
+ /**
39
+ * Create a new `HybridReactNativePerfMemorySpec_cxx` that wraps the given `HybridReactNativePerfMemorySpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridReactNativePerfMemorySpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridReactNativePerfMemorySpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridReactNativePerfMemorySpec() -> any HybridReactNativePerfMemorySpec {
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 `HybridReactNativePerfMemorySpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridReactNativePerfMemorySpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridReactNativePerfMemorySpec_cxx {
70
+ return Unmanaged<HybridReactNativePerfMemorySpec_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<HybridReactNativePerfMemorySpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridReactNativePerfMemorySpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridReactNativePerfMemorySpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridReactNativePerfMemorySpec_(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 getMemoryUsage() -> bridge.Result_std__shared_ptr_Promise_MemoryUsage___ {
122
+ do {
123
+ let __result = try self.__implementation.getMemoryUsage()
124
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_MemoryUsage__ in
125
+ let __promise = bridge.create_std__shared_ptr_Promise_MemoryUsage__()
126
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_MemoryUsage__(__promise)
127
+ __result
128
+ .then({ __result in __promiseHolder.resolve(__result) })
129
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
130
+ return __promise
131
+ }()
132
+ return bridge.create_Result_std__shared_ptr_Promise_MemoryUsage___(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_std__shared_ptr_Promise_MemoryUsage___(__exceptionPtr)
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// MemoryUsage.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `MemoryUsage`, backed by a C++ struct.
13
+ */
14
+ public typealias MemoryUsage = margelo.nitro.reactnativeperfmemory.MemoryUsage
15
+
16
+ public extension MemoryUsage {
17
+ private typealias bridge = margelo.nitro.reactnativeperfmemory.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `MemoryUsage`.
21
+ */
22
+ init(rss: Double) {
23
+ self.init(rss)
24
+ }
25
+
26
+ var rss: Double {
27
+ @inline(__always)
28
+ get {
29
+ return self.__rss
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__rss = newValue
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridReactNativePerfMemorySpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridReactNativePerfMemorySpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativeperfmemory {
11
+
12
+ void HybridReactNativePerfMemorySpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("getMemoryUsage", &HybridReactNativePerfMemorySpec::getMemoryUsage);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::reactnativeperfmemory
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridReactNativePerfMemorySpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `MemoryUsage` to properly resolve imports.
17
+ namespace margelo::nitro::reactnativeperfmemory { struct MemoryUsage; }
18
+
19
+ #include "MemoryUsage.hpp"
20
+ #include <NitroModules/Promise.hpp>
21
+
22
+ namespace margelo::nitro::reactnativeperfmemory {
23
+
24
+ using namespace margelo::nitro;
25
+
26
+ /**
27
+ * An abstract base class for `ReactNativePerfMemory`
28
+ * Inherit this class to create instances of `HybridReactNativePerfMemorySpec` in C++.
29
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
30
+ * @example
31
+ * ```cpp
32
+ * class HybridReactNativePerfMemory: public HybridReactNativePerfMemorySpec {
33
+ * public:
34
+ * HybridReactNativePerfMemory(...): HybridObject(TAG) { ... }
35
+ * // ...
36
+ * };
37
+ * ```
38
+ */
39
+ class HybridReactNativePerfMemorySpec: public virtual HybridObject {
40
+ public:
41
+ // Constructor
42
+ explicit HybridReactNativePerfMemorySpec(): HybridObject(TAG) { }
43
+
44
+ // Destructor
45
+ ~HybridReactNativePerfMemorySpec() override = default;
46
+
47
+ public:
48
+ // Properties
49
+
50
+
51
+ public:
52
+ // Methods
53
+ virtual std::shared_ptr<Promise<MemoryUsage>> getMemoryUsage() = 0;
54
+
55
+ protected:
56
+ // Hybrid Setup
57
+ void loadHybridMethods() override;
58
+
59
+ protected:
60
+ // Tag for logging
61
+ static constexpr auto TAG = "ReactNativePerfMemory";
62
+ };
63
+
64
+ } // namespace margelo::nitro::reactnativeperfmemory
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// MemoryUsage.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+
27
+
28
+
29
+
30
+ namespace margelo::nitro::reactnativeperfmemory {
31
+
32
+ /**
33
+ * A struct which can be represented as a JavaScript object (MemoryUsage).
34
+ */
35
+ struct MemoryUsage {
36
+ public:
37
+ double rss SWIFT_PRIVATE;
38
+
39
+ public:
40
+ MemoryUsage() = default;
41
+ explicit MemoryUsage(double rss): rss(rss) {}
42
+ };
43
+
44
+ } // namespace margelo::nitro::reactnativeperfmemory
45
+
46
+ namespace margelo::nitro {
47
+
48
+ // C++ MemoryUsage <> JS MemoryUsage (object)
49
+ template <>
50
+ struct JSIConverter<margelo::nitro::reactnativeperfmemory::MemoryUsage> final {
51
+ static inline margelo::nitro::reactnativeperfmemory::MemoryUsage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
+ jsi::Object obj = arg.asObject(runtime);
53
+ return margelo::nitro::reactnativeperfmemory::MemoryUsage(
54
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "rss"))
55
+ );
56
+ }
57
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativeperfmemory::MemoryUsage& arg) {
58
+ jsi::Object obj(runtime);
59
+ obj.setProperty(runtime, "rss", JSIConverter<double>::toJSI(runtime, arg.rss));
60
+ return obj;
61
+ }
62
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
63
+ if (!value.isObject()) {
64
+ return false;
65
+ }
66
+ jsi::Object obj = value.getObject(runtime);
67
+ if (!nitro::isPlainObject(runtime, obj)) {
68
+ return false;
69
+ }
70
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "rss"))) return false;
71
+ return true;
72
+ }
73
+ };
74
+
75
+ } // namespace margelo::nitro