@onekeyfe/react-native-perf-stats 3.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/ReactNativePerfStats.podspec +30 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +130 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/PerfStatsInitProvider.kt +43 -0
- package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/ReactNativePerfStats.kt +514 -0
- package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/ReactNativePerfStatsPackage.kt +24 -0
- package/ios/ReactNativePerfStats.swift +391 -0
- package/lib/module/ReactNativePerfStats.nitro.js +4 -0
- package/lib/module/ReactNativePerfStats.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativePerfStats.nitro.d.ts +51 -0
- package/lib/typescript/src/ReactNativePerfStats.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridReactNativePerfStatsSpec.cpp +83 -0
- package/nitrogen/generated/android/c++/JHybridReactNativePerfStatsSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JPerfSample.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/HybridReactNativePerfStatsSpec.kt +74 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/PerfSample.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/reactnativeperfstatsOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativeperfstats+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativeperfstats+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativeperfstatsOnLoad.cpp +44 -0
- package/nitrogen/generated/android/reactnativeperfstatsOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ReactNativePerfStats+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Bridge.hpp +122 -0
- package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Umbrella.hpp +47 -0
- package/nitrogen/generated/ios/ReactNativePerfStatsAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativePerfStatsAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridReactNativePerfStatsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativePerfStatsSpecSwift.hpp +102 -0
- package/nitrogen/generated/ios/swift/Func_void_PerfSample.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativePerfStatsSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridReactNativePerfStatsSpec_cxx.swift +182 -0
- package/nitrogen/generated/ios/swift/PerfSample.swift +58 -0
- package/nitrogen/generated/shared/c++/HybridReactNativePerfStatsSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridReactNativePerfStatsSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/PerfSample.hpp +83 -0
- package/package.json +169 -0
- package/src/ReactNativePerfStats.nitro.ts +54 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfStats-Swift-Cxx-Umbrella.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridReactNativePerfStatsSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::reactnativeperfstats { class HybridReactNativePerfStatsSpec; }
|
|
13
|
+
// Forward declaration of `PerfSample` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::reactnativeperfstats { struct PerfSample; }
|
|
15
|
+
|
|
16
|
+
// Include C++ defined types
|
|
17
|
+
#include "HybridReactNativePerfStatsSpec.hpp"
|
|
18
|
+
#include "PerfSample.hpp"
|
|
19
|
+
#include <NitroModules/Promise.hpp>
|
|
20
|
+
#include <NitroModules/Result.hpp>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <memory>
|
|
23
|
+
|
|
24
|
+
// C++ helpers for Swift
|
|
25
|
+
#include "ReactNativePerfStats-Swift-Cxx-Bridge.hpp"
|
|
26
|
+
|
|
27
|
+
// Common C++ types used in Swift
|
|
28
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
29
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
30
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
31
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
32
|
+
|
|
33
|
+
// Forward declarations of Swift defined types
|
|
34
|
+
// Forward declaration of `HybridReactNativePerfStatsSpec_cxx` to properly resolve imports.
|
|
35
|
+
namespace ReactNativePerfStats { class HybridReactNativePerfStatsSpec_cxx; }
|
|
36
|
+
|
|
37
|
+
// Include Swift defined types
|
|
38
|
+
#if __has_include("ReactNativePerfStats-Swift.h")
|
|
39
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
40
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "ReactNativePerfStats".
|
|
41
|
+
#include "ReactNativePerfStats-Swift.h"
|
|
42
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
43
|
+
#elif __has_include(<ReactNativePerfStats/ReactNativePerfStats-Swift.h>)
|
|
44
|
+
#include <ReactNativePerfStats/ReactNativePerfStats-Swift.h>
|
|
45
|
+
#else
|
|
46
|
+
#error ReactNativePerfStats's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ReactNativePerfStats", and try building the app first.
|
|
47
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfStatsAutolinking.mm
|
|
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/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "ReactNativePerfStats-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridReactNativePerfStatsSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface ReactNativePerfStatsAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation ReactNativePerfStatsAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::reactnativeperfstats;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"ReactNativePerfStats",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridReactNativePerfStatsSpec> hybridObject = ReactNativePerfStats::ReactNativePerfStatsAutolinking::createReactNativePerfStats();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfStatsAutolinking.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
|
+
public final class ReactNativePerfStatsAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.reactnativeperfstats.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridReactNativePerfStatsSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridReactNativePerfStatsSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `ReactNativePerfStats`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createReactNativePerfStats() -> bridge.std__shared_ptr_HybridReactNativePerfStatsSpec_ {
|
|
19
|
+
let hybridObject = ReactNativePerfStats()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridReactNativePerfStatsSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfStatsSpecSwift.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 "HybridReactNativePerfStatsSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::reactnativeperfstats {
|
|
11
|
+
} // namespace margelo::nitro::reactnativeperfstats
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfStatsSpecSwift.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 "HybridReactNativePerfStatsSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridReactNativePerfStatsSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace ReactNativePerfStats { class HybridReactNativePerfStatsSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `PerfSample` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::reactnativeperfstats { struct PerfSample; }
|
|
17
|
+
|
|
18
|
+
#include "PerfSample.hpp"
|
|
19
|
+
#include <NitroModules/Promise.hpp>
|
|
20
|
+
|
|
21
|
+
#include "ReactNativePerfStats-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::reactnativeperfstats {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridReactNativePerfStatsSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridReactNativePerfStatsSpecSwift (C++) accesses HybridReactNativePerfStatsSpec_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, HybridReactNativePerfStatsSpec_cxx can directly inherit from the C++ class HybridReactNativePerfStatsSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridReactNativePerfStatsSpecSwift: public virtual HybridReactNativePerfStatsSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridReactNativePerfStatsSpecSwift(const ReactNativePerfStats::HybridReactNativePerfStatsSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridReactNativePerfStatsSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline ReactNativePerfStats::HybridReactNativePerfStatsSpec_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 void start(double intervalMs) override {
|
|
66
|
+
auto __result = _swiftPart.start(std::forward<decltype(intervalMs)>(intervalMs));
|
|
67
|
+
if (__result.hasError()) [[unlikely]] {
|
|
68
|
+
std::rethrow_exception(__result.error());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
inline void stop() override {
|
|
72
|
+
auto __result = _swiftPart.stop();
|
|
73
|
+
if (__result.hasError()) [[unlikely]] {
|
|
74
|
+
std::rethrow_exception(__result.error());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
inline void showOverlay() override {
|
|
78
|
+
auto __result = _swiftPart.showOverlay();
|
|
79
|
+
if (__result.hasError()) [[unlikely]] {
|
|
80
|
+
std::rethrow_exception(__result.error());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
inline void hideOverlay() override {
|
|
84
|
+
auto __result = _swiftPart.hideOverlay();
|
|
85
|
+
if (__result.hasError()) [[unlikely]] {
|
|
86
|
+
std::rethrow_exception(__result.error());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
inline std::shared_ptr<Promise<PerfSample>> sample() override {
|
|
90
|
+
auto __result = _swiftPart.sample();
|
|
91
|
+
if (__result.hasError()) [[unlikely]] {
|
|
92
|
+
std::rethrow_exception(__result.error());
|
|
93
|
+
}
|
|
94
|
+
auto __value = std::move(__result.value());
|
|
95
|
+
return __value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private:
|
|
99
|
+
ReactNativePerfStats::HybridReactNativePerfStatsSpec_cxx _swiftPart;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
} // namespace margelo::nitro::reactnativeperfstats
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_PerfSample.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: PerfSample) -> 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_PerfSample {
|
|
16
|
+
public typealias bridge = margelo.nitro.reactnativeperfstats.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: PerfSample) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: PerfSample) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: PerfSample) -> 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_PerfSample`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_PerfSample>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PerfSample {
|
|
45
|
+
return Unmanaged<Func_void_PerfSample>.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.reactnativeperfstats.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,60 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfStatsSpec.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 ``HybridReactNativePerfStatsSpec``
|
|
12
|
+
public protocol HybridReactNativePerfStatsSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func start(intervalMs: Double) throws -> Void
|
|
18
|
+
func stop() throws -> Void
|
|
19
|
+
func showOverlay() throws -> Void
|
|
20
|
+
func hideOverlay() throws -> Void
|
|
21
|
+
func sample() throws -> Promise<PerfSample>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public extension HybridReactNativePerfStatsSpec_protocol {
|
|
25
|
+
/// Default implementation of ``HybridObject.toString``
|
|
26
|
+
func toString() -> String {
|
|
27
|
+
return "[HybridObject ReactNativePerfStats]"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// See ``HybridReactNativePerfStatsSpec``
|
|
32
|
+
open class HybridReactNativePerfStatsSpec_base {
|
|
33
|
+
private weak var cxxWrapper: HybridReactNativePerfStatsSpec_cxx? = nil
|
|
34
|
+
public init() { }
|
|
35
|
+
public func getCxxWrapper() -> HybridReactNativePerfStatsSpec_cxx {
|
|
36
|
+
#if DEBUG
|
|
37
|
+
guard self is HybridReactNativePerfStatsSpec else {
|
|
38
|
+
fatalError("`self` is not a `HybridReactNativePerfStatsSpec`! Did you accidentally inherit from `HybridReactNativePerfStatsSpec_base` instead of `HybridReactNativePerfStatsSpec`?")
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
} else {
|
|
44
|
+
let cxxWrapper = HybridReactNativePerfStatsSpec_cxx(self as! HybridReactNativePerfStatsSpec)
|
|
45
|
+
self.cxxWrapper = cxxWrapper
|
|
46
|
+
return cxxWrapper
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A Swift base-protocol representing the ReactNativePerfStats HybridObject.
|
|
53
|
+
* Implement this protocol to create Swift-based instances of ReactNativePerfStats.
|
|
54
|
+
* ```swift
|
|
55
|
+
* class HybridReactNativePerfStats : HybridReactNativePerfStatsSpec {
|
|
56
|
+
* // ...
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
public typealias HybridReactNativePerfStatsSpec = HybridReactNativePerfStatsSpec_protocol & HybridReactNativePerfStatsSpec_base
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfStatsSpec_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 HybridReactNativePerfStatsSpec 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 HybridReactNativePerfStatsSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativeperfstats::bridge::swift`)
|
|
23
|
+
* from `ReactNativePerfStats-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.reactnativeperfstats.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridReactNativePerfStatsSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridReactNativePerfStatsSpec
|
|
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_HybridReactNativePerfStatsSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridReactNativePerfStatsSpec_cxx` that wraps the given `HybridReactNativePerfStatsSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridReactNativePerfStatsSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridReactNativePerfStatsSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridReactNativePerfStatsSpec() -> any HybridReactNativePerfStatsSpec {
|
|
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 `HybridReactNativePerfStatsSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridReactNativePerfStatsSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridReactNativePerfStatsSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridReactNativePerfStatsSpec_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<HybridReactNativePerfStatsSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridReactNativePerfStatsSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridReactNativePerfStatsSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridReactNativePerfStatsSpec_(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 start(intervalMs: Double) -> bridge.Result_void_ {
|
|
122
|
+
do {
|
|
123
|
+
try self.__implementation.start(intervalMs: intervalMs)
|
|
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 stop() -> bridge.Result_void_ {
|
|
133
|
+
do {
|
|
134
|
+
try self.__implementation.stop()
|
|
135
|
+
return bridge.create_Result_void_()
|
|
136
|
+
} catch (let __error) {
|
|
137
|
+
let __exceptionPtr = __error.toCpp()
|
|
138
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@inline(__always)
|
|
143
|
+
public final func showOverlay() -> bridge.Result_void_ {
|
|
144
|
+
do {
|
|
145
|
+
try self.__implementation.showOverlay()
|
|
146
|
+
return bridge.create_Result_void_()
|
|
147
|
+
} catch (let __error) {
|
|
148
|
+
let __exceptionPtr = __error.toCpp()
|
|
149
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@inline(__always)
|
|
154
|
+
public final func hideOverlay() -> bridge.Result_void_ {
|
|
155
|
+
do {
|
|
156
|
+
try self.__implementation.hideOverlay()
|
|
157
|
+
return bridge.create_Result_void_()
|
|
158
|
+
} catch (let __error) {
|
|
159
|
+
let __exceptionPtr = __error.toCpp()
|
|
160
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@inline(__always)
|
|
165
|
+
public final func sample() -> bridge.Result_std__shared_ptr_Promise_PerfSample___ {
|
|
166
|
+
do {
|
|
167
|
+
let __result = try self.__implementation.sample()
|
|
168
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PerfSample__ in
|
|
169
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PerfSample__()
|
|
170
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PerfSample__(__promise)
|
|
171
|
+
__result
|
|
172
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
173
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
174
|
+
return __promise
|
|
175
|
+
}()
|
|
176
|
+
return bridge.create_Result_std__shared_ptr_Promise_PerfSample___(__resultCpp)
|
|
177
|
+
} catch (let __error) {
|
|
178
|
+
let __exceptionPtr = __error.toCpp()
|
|
179
|
+
return bridge.create_Result_std__shared_ptr_Promise_PerfSample___(__exceptionPtr)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PerfSample.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 `PerfSample`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias PerfSample = margelo.nitro.reactnativeperfstats.PerfSample
|
|
15
|
+
|
|
16
|
+
public extension PerfSample {
|
|
17
|
+
private typealias bridge = margelo.nitro.reactnativeperfstats.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `PerfSample`.
|
|
21
|
+
*/
|
|
22
|
+
init(cpu: Double, rss: Double, timestamp: Double) {
|
|
23
|
+
self.init(cpu, rss, timestamp)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var cpu: Double {
|
|
27
|
+
@inline(__always)
|
|
28
|
+
get {
|
|
29
|
+
return self.__cpu
|
|
30
|
+
}
|
|
31
|
+
@inline(__always)
|
|
32
|
+
set {
|
|
33
|
+
self.__cpu = newValue
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var rss: Double {
|
|
38
|
+
@inline(__always)
|
|
39
|
+
get {
|
|
40
|
+
return self.__rss
|
|
41
|
+
}
|
|
42
|
+
@inline(__always)
|
|
43
|
+
set {
|
|
44
|
+
self.__rss = newValue
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var timestamp: Double {
|
|
49
|
+
@inline(__always)
|
|
50
|
+
get {
|
|
51
|
+
return self.__timestamp
|
|
52
|
+
}
|
|
53
|
+
@inline(__always)
|
|
54
|
+
set {
|
|
55
|
+
self.__timestamp = newValue
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfStatsSpec.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 "HybridReactNativePerfStatsSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::reactnativeperfstats {
|
|
11
|
+
|
|
12
|
+
void HybridReactNativePerfStatsSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("start", &HybridReactNativePerfStatsSpec::start);
|
|
18
|
+
prototype.registerHybridMethod("stop", &HybridReactNativePerfStatsSpec::stop);
|
|
19
|
+
prototype.registerHybridMethod("showOverlay", &HybridReactNativePerfStatsSpec::showOverlay);
|
|
20
|
+
prototype.registerHybridMethod("hideOverlay", &HybridReactNativePerfStatsSpec::hideOverlay);
|
|
21
|
+
prototype.registerHybridMethod("sample", &HybridReactNativePerfStatsSpec::sample);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::reactnativeperfstats
|