@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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/ReactNativePerfStats.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 +8 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/PerfStatsInitProvider.kt +43 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/ReactNativePerfStats.kt +514 -0
  11. package/android/src/main/java/com/margelo/nitro/reactnativeperfstats/ReactNativePerfStatsPackage.kt +24 -0
  12. package/ios/ReactNativePerfStats.swift +391 -0
  13. package/lib/module/ReactNativePerfStats.nitro.js +4 -0
  14. package/lib/module/ReactNativePerfStats.nitro.js.map +1 -0
  15. package/lib/module/index.js +6 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/typescript/package.json +1 -0
  19. package/lib/typescript/src/ReactNativePerfStats.nitro.d.ts +51 -0
  20. package/lib/typescript/src/ReactNativePerfStats.nitro.d.ts.map +1 -0
  21. package/lib/typescript/src/index.d.ts +4 -0
  22. package/lib/typescript/src/index.d.ts.map +1 -0
  23. package/nitro.json +17 -0
  24. package/nitrogen/generated/android/c++/JHybridReactNativePerfStatsSpec.cpp +83 -0
  25. package/nitrogen/generated/android/c++/JHybridReactNativePerfStatsSpec.hpp +69 -0
  26. package/nitrogen/generated/android/c++/JPerfSample.hpp +65 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/HybridReactNativePerfStatsSpec.kt +74 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/PerfSample.kt +44 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfstats/reactnativeperfstatsOnLoad.kt +35 -0
  30. package/nitrogen/generated/android/reactnativeperfstats+autolinking.cmake +81 -0
  31. package/nitrogen/generated/android/reactnativeperfstats+autolinking.gradle +27 -0
  32. package/nitrogen/generated/android/reactnativeperfstatsOnLoad.cpp +44 -0
  33. package/nitrogen/generated/android/reactnativeperfstatsOnLoad.hpp +25 -0
  34. package/nitrogen/generated/ios/ReactNativePerfStats+autolinking.rb +60 -0
  35. package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Bridge.cpp +49 -0
  36. package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Bridge.hpp +122 -0
  37. package/nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Umbrella.hpp +47 -0
  38. package/nitrogen/generated/ios/ReactNativePerfStatsAutolinking.mm +33 -0
  39. package/nitrogen/generated/ios/ReactNativePerfStatsAutolinking.swift +25 -0
  40. package/nitrogen/generated/ios/c++/HybridReactNativePerfStatsSpecSwift.cpp +11 -0
  41. package/nitrogen/generated/ios/c++/HybridReactNativePerfStatsSpecSwift.hpp +102 -0
  42. package/nitrogen/generated/ios/swift/Func_void_PerfSample.swift +47 -0
  43. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  44. package/nitrogen/generated/ios/swift/HybridReactNativePerfStatsSpec.swift +60 -0
  45. package/nitrogen/generated/ios/swift/HybridReactNativePerfStatsSpec_cxx.swift +182 -0
  46. package/nitrogen/generated/ios/swift/PerfSample.swift +58 -0
  47. package/nitrogen/generated/shared/c++/HybridReactNativePerfStatsSpec.cpp +25 -0
  48. package/nitrogen/generated/shared/c++/HybridReactNativePerfStatsSpec.hpp +68 -0
  49. package/nitrogen/generated/shared/c++/PerfSample.hpp +83 -0
  50. package/package.json +169 -0
  51. package/src/ReactNativePerfStats.nitro.ts +54 -0
  52. package/src/index.tsx +8 -0
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// JPerfSample.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 <fbjni/fbjni.h>
11
+ #include "PerfSample.hpp"
12
+
13
+
14
+
15
+ namespace margelo::nitro::reactnativeperfstats {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "PerfSample" and the the Kotlin data class "PerfSample".
21
+ */
22
+ struct JPerfSample final: public jni::JavaClass<JPerfSample> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativeperfstats/PerfSample;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct PerfSample by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ PerfSample toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldCpu = clazz->getField<double>("cpu");
35
+ double cpu = this->getFieldValue(fieldCpu);
36
+ static const auto fieldRss = clazz->getField<double>("rss");
37
+ double rss = this->getFieldValue(fieldRss);
38
+ static const auto fieldTimestamp = clazz->getField<double>("timestamp");
39
+ double timestamp = this->getFieldValue(fieldTimestamp);
40
+ return PerfSample(
41
+ cpu,
42
+ rss,
43
+ timestamp
44
+ );
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
50
+ */
51
+ [[maybe_unused]]
52
+ static jni::local_ref<JPerfSample::javaobject> fromCpp(const PerfSample& value) {
53
+ using JSignature = JPerfSample(double, double, double);
54
+ static const auto clazz = javaClassStatic();
55
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
56
+ return create(
57
+ clazz,
58
+ value.cpu,
59
+ value.rss,
60
+ value.timestamp
61
+ );
62
+ }
63
+ };
64
+
65
+ } // namespace margelo::nitro::reactnativeperfstats
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// HybridReactNativePerfStatsSpec.kt
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
+ package com.margelo.nitro.reactnativeperfstats
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.HybridObject
15
+
16
+ /**
17
+ * A Kotlin class representing the ReactNativePerfStats HybridObject.
18
+ * Implement this abstract class to create Kotlin-based instances of ReactNativePerfStats.
19
+ */
20
+ @DoNotStrip
21
+ @Keep
22
+ @Suppress(
23
+ "KotlinJniMissingFunction", "unused",
24
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
25
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
+ )
27
+ abstract class HybridReactNativePerfStatsSpec: HybridObject() {
28
+ @DoNotStrip
29
+ private var mHybridData: HybridData = initHybrid()
30
+
31
+ init {
32
+ super.updateNative(mHybridData)
33
+ }
34
+
35
+ override fun updateNative(hybridData: HybridData) {
36
+ mHybridData = hybridData
37
+ super.updateNative(hybridData)
38
+ }
39
+
40
+ // Default implementation of `HybridObject.toString()`
41
+ override fun toString(): String {
42
+ return "[HybridObject ReactNativePerfStats]"
43
+ }
44
+
45
+ // Properties
46
+
47
+
48
+ // Methods
49
+ @DoNotStrip
50
+ @Keep
51
+ abstract fun start(intervalMs: Double): Unit
52
+
53
+ @DoNotStrip
54
+ @Keep
55
+ abstract fun stop(): Unit
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ abstract fun showOverlay(): Unit
60
+
61
+ @DoNotStrip
62
+ @Keep
63
+ abstract fun hideOverlay(): Unit
64
+
65
+ @DoNotStrip
66
+ @Keep
67
+ abstract fun sample(): Promise<PerfSample>
68
+
69
+ private external fun initHybrid(): HybridData
70
+
71
+ companion object {
72
+ protected const val TAG = "HybridReactNativePerfStatsSpec"
73
+ }
74
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// PerfSample.kt
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
+ package com.margelo.nitro.reactnativeperfstats
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "PerfSample".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class PerfSample(
20
+ @DoNotStrip
21
+ @Keep
22
+ val cpu: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val rss: Double,
26
+ @DoNotStrip
27
+ @Keep
28
+ val timestamp: Double
29
+ ) {
30
+ /* primary constructor */
31
+
32
+ private companion object {
33
+ /**
34
+ * Constructor called from C++
35
+ */
36
+ @DoNotStrip
37
+ @Keep
38
+ @Suppress("unused")
39
+ @JvmStatic
40
+ private fun fromCpp(cpu: Double, rss: Double, timestamp: Double): PerfSample {
41
+ return PerfSample(cpu, rss, timestamp)
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// reactnativeperfstatsOnLoad.kt
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
+ package com.margelo.nitro.reactnativeperfstats
9
+
10
+ import android.util.Log
11
+
12
+ internal class reactnativeperfstatsOnLoad {
13
+ companion object {
14
+ private const val TAG = "reactnativeperfstatsOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "reactnativeperfstats".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading reactnativeperfstats C++ library...")
25
+ System.loadLibrary("reactnativeperfstats")
26
+ Log.i(TAG, "Successfully loaded reactnativeperfstats C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load reactnativeperfstats C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ #
2
+ # reactnativeperfstats+autolinking.cmake
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
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/reactnativeperfstats+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_REACTNATIVEPERFSTATS_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ reactnativeperfstats PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/reactnativeperfstatsOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridReactNativePerfStatsSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridReactNativePerfStatsSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ reactnativeperfstats PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ reactnativeperfstats
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ reactnativeperfstats
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ reactnativeperfstats
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// reactnativeperfstats+autolinking.gradle
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
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/reactnativeperfstats+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 reactnativeperfstats is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// reactnativeperfstatsOnLoad.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
+ #ifndef BUILDING_REACTNATIVEPERFSTATS_WITH_GENERATED_CMAKE_PROJECT
9
+ #error reactnativeperfstatsOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "reactnativeperfstatsOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridReactNativePerfStatsSpec.hpp"
19
+ #include <NitroModules/DefaultConstructableObject.hpp>
20
+
21
+ namespace margelo::nitro::reactnativeperfstats {
22
+
23
+ int initialize(JavaVM* vm) {
24
+ using namespace margelo::nitro;
25
+ using namespace margelo::nitro::reactnativeperfstats;
26
+ using namespace facebook;
27
+
28
+ return facebook::jni::initialize(vm, [] {
29
+ // Register native JNI methods
30
+ margelo::nitro::reactnativeperfstats::JHybridReactNativePerfStatsSpec::registerNatives();
31
+
32
+ // Register Nitro Hybrid Objects
33
+ HybridObjectRegistry::registerHybridObjectConstructor(
34
+ "ReactNativePerfStats",
35
+ []() -> std::shared_ptr<HybridObject> {
36
+ static DefaultConstructableObject<JHybridReactNativePerfStatsSpec::javaobject> object("com/margelo/nitro/reactnativeperfstats/ReactNativePerfStats");
37
+ auto instance = object.create();
38
+ return instance->cthis()->shared();
39
+ }
40
+ );
41
+ });
42
+ }
43
+
44
+ } // namespace margelo::nitro::reactnativeperfstats
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// reactnativeperfstatsOnLoad.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
+ #include <jni.h>
9
+ #include <NitroModules/NitroDefines.hpp>
10
+
11
+ namespace margelo::nitro::reactnativeperfstats {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of reactnativeperfstats, and autolinks all Hybrid Objects.
15
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16
+ * Example:
17
+ * ```cpp (cpp-adapter.cpp)
18
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
+ * return margelo::nitro::reactnativeperfstats::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::reactnativeperfstats
@@ -0,0 +1,60 @@
1
+ #
2
+ # ReactNativePerfStats+autolinking.rb
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
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/ReactNativePerfStats+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 ReactNativePerfStats is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/ReactNativePerfStats-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only C)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// ReactNativePerfStats-Swift-Cxx-Bridge.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 "ReactNativePerfStats-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridReactNativePerfStatsSpecSwift.hpp"
12
+ #include "ReactNativePerfStats-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::reactnativeperfstats::bridge::swift {
16
+
17
+ // pragma MARK: std::function<void(const PerfSample& /* result */)>
18
+ Func_void_PerfSample create_Func_void_PerfSample(void* NON_NULL swiftClosureWrapper) noexcept {
19
+ auto swiftClosure = ReactNativePerfStats::Func_void_PerfSample::fromUnsafe(swiftClosureWrapper);
20
+ return [swiftClosure = std::move(swiftClosure)](const PerfSample& result) mutable -> void {
21
+ swiftClosure.call(result);
22
+ };
23
+ }
24
+
25
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
26
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = ReactNativePerfStats::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
29
+ swiftClosure.call(error);
30
+ };
31
+ }
32
+
33
+ // pragma MARK: std::shared_ptr<HybridReactNativePerfStatsSpec>
34
+ std::shared_ptr<HybridReactNativePerfStatsSpec> create_std__shared_ptr_HybridReactNativePerfStatsSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
35
+ ReactNativePerfStats::HybridReactNativePerfStatsSpec_cxx swiftPart = ReactNativePerfStats::HybridReactNativePerfStatsSpec_cxx::fromUnsafe(swiftUnsafePointer);
36
+ return std::make_shared<margelo::nitro::reactnativeperfstats::HybridReactNativePerfStatsSpecSwift>(swiftPart);
37
+ }
38
+ void* NON_NULL get_std__shared_ptr_HybridReactNativePerfStatsSpec_(std__shared_ptr_HybridReactNativePerfStatsSpec_ cppType) {
39
+ std::shared_ptr<margelo::nitro::reactnativeperfstats::HybridReactNativePerfStatsSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::reactnativeperfstats::HybridReactNativePerfStatsSpecSwift>(cppType);
40
+ #ifdef NITRO_DEBUG
41
+ if (swiftWrapper == nullptr) [[unlikely]] {
42
+ throw std::runtime_error("Class \"HybridReactNativePerfStatsSpec\" is not implemented in Swift!");
43
+ }
44
+ #endif
45
+ ReactNativePerfStats::HybridReactNativePerfStatsSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
46
+ return swiftPart.toUnsafe();
47
+ }
48
+
49
+ } // namespace margelo::nitro::reactnativeperfstats::bridge::swift
@@ -0,0 +1,122 @@
1
+ ///
2
+ /// ReactNativePerfStats-Swift-Cxx-Bridge.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
+ // Forward declarations of Swift defined types
17
+ // Forward declaration of `HybridReactNativePerfStatsSpec_cxx` to properly resolve imports.
18
+ namespace ReactNativePerfStats { class HybridReactNativePerfStatsSpec_cxx; }
19
+
20
+ // Include C++ defined types
21
+ #include "HybridReactNativePerfStatsSpec.hpp"
22
+ #include "PerfSample.hpp"
23
+ #include <NitroModules/Promise.hpp>
24
+ #include <NitroModules/PromiseHolder.hpp>
25
+ #include <NitroModules/Result.hpp>
26
+ #include <exception>
27
+ #include <functional>
28
+ #include <memory>
29
+
30
+ /**
31
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
32
+ * as well as helper functions to interact with those C++ types from Swift.
33
+ */
34
+ namespace margelo::nitro::reactnativeperfstats::bridge::swift {
35
+
36
+ // pragma MARK: std::shared_ptr<Promise<PerfSample>>
37
+ /**
38
+ * Specialized version of `std::shared_ptr<Promise<PerfSample>>`.
39
+ */
40
+ using std__shared_ptr_Promise_PerfSample__ = std::shared_ptr<Promise<PerfSample>>;
41
+ inline std::shared_ptr<Promise<PerfSample>> create_std__shared_ptr_Promise_PerfSample__() noexcept {
42
+ return Promise<PerfSample>::create();
43
+ }
44
+ inline PromiseHolder<PerfSample> wrap_std__shared_ptr_Promise_PerfSample__(std::shared_ptr<Promise<PerfSample>> promise) noexcept {
45
+ return PromiseHolder<PerfSample>(std::move(promise));
46
+ }
47
+
48
+ // pragma MARK: std::function<void(const PerfSample& /* result */)>
49
+ /**
50
+ * Specialized version of `std::function<void(const PerfSample&)>`.
51
+ */
52
+ using Func_void_PerfSample = std::function<void(const PerfSample& /* result */)>;
53
+ /**
54
+ * Wrapper class for a `std::function<void(const PerfSample& / * result * /)>`, this can be used from Swift.
55
+ */
56
+ class Func_void_PerfSample_Wrapper final {
57
+ public:
58
+ explicit Func_void_PerfSample_Wrapper(std::function<void(const PerfSample& /* result */)>&& func): _function(std::make_unique<std::function<void(const PerfSample& /* result */)>>(std::move(func))) {}
59
+ inline void call(PerfSample result) const noexcept {
60
+ _function->operator()(result);
61
+ }
62
+ private:
63
+ std::unique_ptr<std::function<void(const PerfSample& /* result */)>> _function;
64
+ } SWIFT_NONCOPYABLE;
65
+ Func_void_PerfSample create_Func_void_PerfSample(void* NON_NULL swiftClosureWrapper) noexcept;
66
+ inline Func_void_PerfSample_Wrapper wrap_Func_void_PerfSample(Func_void_PerfSample value) noexcept {
67
+ return Func_void_PerfSample_Wrapper(std::move(value));
68
+ }
69
+
70
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
71
+ /**
72
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
73
+ */
74
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
75
+ /**
76
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
77
+ */
78
+ class Func_void_std__exception_ptr_Wrapper final {
79
+ public:
80
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
81
+ inline void call(std::exception_ptr error) const noexcept {
82
+ _function->operator()(error);
83
+ }
84
+ private:
85
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
86
+ } SWIFT_NONCOPYABLE;
87
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
88
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
89
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
90
+ }
91
+
92
+ // pragma MARK: std::shared_ptr<HybridReactNativePerfStatsSpec>
93
+ /**
94
+ * Specialized version of `std::shared_ptr<HybridReactNativePerfStatsSpec>`.
95
+ */
96
+ using std__shared_ptr_HybridReactNativePerfStatsSpec_ = std::shared_ptr<HybridReactNativePerfStatsSpec>;
97
+ std::shared_ptr<HybridReactNativePerfStatsSpec> create_std__shared_ptr_HybridReactNativePerfStatsSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
98
+ void* NON_NULL get_std__shared_ptr_HybridReactNativePerfStatsSpec_(std__shared_ptr_HybridReactNativePerfStatsSpec_ cppType);
99
+
100
+ // pragma MARK: std::weak_ptr<HybridReactNativePerfStatsSpec>
101
+ using std__weak_ptr_HybridReactNativePerfStatsSpec_ = std::weak_ptr<HybridReactNativePerfStatsSpec>;
102
+ inline std__weak_ptr_HybridReactNativePerfStatsSpec_ weakify_std__shared_ptr_HybridReactNativePerfStatsSpec_(const std::shared_ptr<HybridReactNativePerfStatsSpec>& strong) noexcept { return strong; }
103
+
104
+ // pragma MARK: Result<void>
105
+ using Result_void_ = Result<void>;
106
+ inline Result_void_ create_Result_void_() noexcept {
107
+ return Result<void>::withValue();
108
+ }
109
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
110
+ return Result<void>::withError(error);
111
+ }
112
+
113
+ // pragma MARK: Result<std::shared_ptr<Promise<PerfSample>>>
114
+ using Result_std__shared_ptr_Promise_PerfSample___ = Result<std::shared_ptr<Promise<PerfSample>>>;
115
+ inline Result_std__shared_ptr_Promise_PerfSample___ create_Result_std__shared_ptr_Promise_PerfSample___(const std::shared_ptr<Promise<PerfSample>>& value) noexcept {
116
+ return Result<std::shared_ptr<Promise<PerfSample>>>::withValue(value);
117
+ }
118
+ inline Result_std__shared_ptr_Promise_PerfSample___ create_Result_std__shared_ptr_Promise_PerfSample___(const std::exception_ptr& error) noexcept {
119
+ return Result<std::shared_ptr<Promise<PerfSample>>>::withError(error);
120
+ }
121
+
122
+ } // namespace margelo::nitro::reactnativeperfstats::bridge::swift