@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.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/ReactNativePerfMemory.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 +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/reactnativeperfmemory/ReactNativePerfMemory.kt +67 -0
- package/android/src/main/java/com/margelo/nitro/reactnativeperfmemory/ReactNativePerfMemoryPackage.kt +24 -0
- package/ios/ReactNativePerfMemory.swift +41 -0
- package/lib/module/ReactNativePerfMemory.nitro.js +4 -0
- package/lib/module/ReactNativePerfMemory.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/ReactNativePerfMemory.nitro.d.ts +11 -0
- package/lib/typescript/src/ReactNativePerfMemory.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++/JHybridReactNativePerfMemorySpec.cpp +67 -0
- package/nitrogen/generated/android/c++/JHybridReactNativePerfMemorySpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JMemoryUsage.hpp +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/HybridReactNativePerfMemorySpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/MemoryUsage.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/reactnativeperfmemoryOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativeperfmemory+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativeperfmemory+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativeperfmemoryOnLoad.cpp +44 -0
- package/nitrogen/generated/android/reactnativeperfmemoryOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ReactNativePerfMemory+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Bridge.hpp +113 -0
- package/nitrogen/generated/ios/ReactNativePerfMemory-Swift-Cxx-Umbrella.hpp +47 -0
- package/nitrogen/generated/ios/ReactNativePerfMemoryAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativePerfMemoryAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridReactNativePerfMemorySpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativePerfMemorySpecSwift.hpp +78 -0
- package/nitrogen/generated/ios/swift/Func_void_MemoryUsage.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativePerfMemorySpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridReactNativePerfMemorySpec_cxx.swift +138 -0
- package/nitrogen/generated/ios/swift/MemoryUsage.swift +36 -0
- package/nitrogen/generated/shared/c++/HybridReactNativePerfMemorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridReactNativePerfMemorySpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/MemoryUsage.hpp +75 -0
- package/package.json +169 -0
- package/src/ReactNativePerfMemory.nitro.ts +10 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfMemorySpec.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.reactnativeperfmemory
|
|
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 ReactNativePerfMemory HybridObject.
|
|
18
|
+
* Implement this abstract class to create Kotlin-based instances of ReactNativePerfMemory.
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress(
|
|
23
|
+
"KotlinJniMissingFunction", "unused",
|
|
24
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
+
)
|
|
27
|
+
abstract class HybridReactNativePerfMemorySpec: 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 ReactNativePerfMemory]"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Properties
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Methods
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
@Keep
|
|
51
|
+
abstract fun getMemoryUsage(): Promise<MemoryUsage>
|
|
52
|
+
|
|
53
|
+
private external fun initHybrid(): HybridData
|
|
54
|
+
|
|
55
|
+
companion object {
|
|
56
|
+
protected const val TAG = "HybridReactNativePerfMemorySpec"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeperfmemory/MemoryUsage.kt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MemoryUsage.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.reactnativeperfmemory
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "MemoryUsage".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class MemoryUsage(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val rss: Double
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
private companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(rss: Double): MemoryUsage {
|
|
35
|
+
return MemoryUsage(rss)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativeperfmemoryOnLoad.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.reactnativeperfmemory
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class reactnativeperfmemoryOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "reactnativeperfmemoryOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "reactnativeperfmemory".
|
|
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 reactnativeperfmemory C++ library...")
|
|
25
|
+
System.loadLibrary("reactnativeperfmemory")
|
|
26
|
+
Log.i(TAG, "Successfully loaded reactnativeperfmemory C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load reactnativeperfmemory 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
|
+
# reactnativeperfmemory+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/reactnativeperfmemory+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_REACTNATIVEPERFMEMORY_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
|
+
reactnativeperfmemory PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/reactnativeperfmemoryOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridReactNativePerfMemorySpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridReactNativePerfMemorySpec.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
|
+
reactnativeperfmemory 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
|
+
reactnativeperfmemory
|
|
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
|
+
reactnativeperfmemory
|
|
74
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
|
+
)
|
|
76
|
+
else()
|
|
77
|
+
target_link_libraries(
|
|
78
|
+
reactnativeperfmemory
|
|
79
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
|
+
)
|
|
81
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativeperfmemory+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/reactnativeperfmemory+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 reactnativeperfmemory 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
|
+
/// reactnativeperfmemoryOnLoad.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_REACTNATIVEPERFMEMORY_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error reactnativeperfmemoryOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "reactnativeperfmemoryOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridReactNativePerfMemorySpec.hpp"
|
|
19
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::reactnativeperfmemory {
|
|
22
|
+
|
|
23
|
+
int initialize(JavaVM* vm) {
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
using namespace margelo::nitro::reactnativeperfmemory;
|
|
26
|
+
using namespace facebook;
|
|
27
|
+
|
|
28
|
+
return facebook::jni::initialize(vm, [] {
|
|
29
|
+
// Register native JNI methods
|
|
30
|
+
margelo::nitro::reactnativeperfmemory::JHybridReactNativePerfMemorySpec::registerNatives();
|
|
31
|
+
|
|
32
|
+
// Register Nitro Hybrid Objects
|
|
33
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
34
|
+
"ReactNativePerfMemory",
|
|
35
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
36
|
+
static DefaultConstructableObject<JHybridReactNativePerfMemorySpec::javaobject> object("com/margelo/nitro/reactnativeperfmemory/ReactNativePerfMemory");
|
|
37
|
+
auto instance = object.create();
|
|
38
|
+
return instance->cthis()->shared();
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::reactnativeperfmemory
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// reactnativeperfmemoryOnLoad.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::reactnativeperfmemory {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of reactnativeperfmemory, 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::reactnativeperfmemory::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::reactnativeperfmemory
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ReactNativePerfMemory+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/ReactNativePerfMemory+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 ReactNativePerfMemory 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/ReactNativePerfMemory-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
|
+
/// ReactNativePerfMemory-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 "ReactNativePerfMemory-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridReactNativePerfMemorySpecSwift.hpp"
|
|
12
|
+
#include "ReactNativePerfMemory-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::reactnativeperfmemory::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::function<void(const MemoryUsage& /* result */)>
|
|
18
|
+
Func_void_MemoryUsage create_Func_void_MemoryUsage(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = ReactNativePerfMemory::Func_void_MemoryUsage::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)](const MemoryUsage& 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 = ReactNativePerfMemory::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<HybridReactNativePerfMemorySpec>
|
|
34
|
+
std::shared_ptr<HybridReactNativePerfMemorySpec> create_std__shared_ptr_HybridReactNativePerfMemorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
35
|
+
ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx swiftPart = ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
36
|
+
return std::make_shared<margelo::nitro::reactnativeperfmemory::HybridReactNativePerfMemorySpecSwift>(swiftPart);
|
|
37
|
+
}
|
|
38
|
+
void* NON_NULL get_std__shared_ptr_HybridReactNativePerfMemorySpec_(std__shared_ptr_HybridReactNativePerfMemorySpec_ cppType) {
|
|
39
|
+
std::shared_ptr<margelo::nitro::reactnativeperfmemory::HybridReactNativePerfMemorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::reactnativeperfmemory::HybridReactNativePerfMemorySpecSwift>(cppType);
|
|
40
|
+
#ifdef NITRO_DEBUG
|
|
41
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
42
|
+
throw std::runtime_error("Class \"HybridReactNativePerfMemorySpec\" is not implemented in Swift!");
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
45
|
+
ReactNativePerfMemory::HybridReactNativePerfMemorySpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
46
|
+
return swiftPart.toUnsafe();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::reactnativeperfmemory::bridge::swift
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfMemory-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 `HybridReactNativePerfMemorySpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::reactnativeperfmemory { class HybridReactNativePerfMemorySpec; }
|
|
13
|
+
// Forward declaration of `MemoryUsage` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::reactnativeperfmemory { struct MemoryUsage; }
|
|
15
|
+
|
|
16
|
+
// Forward declarations of Swift defined types
|
|
17
|
+
// Forward declaration of `HybridReactNativePerfMemorySpec_cxx` to properly resolve imports.
|
|
18
|
+
namespace ReactNativePerfMemory { class HybridReactNativePerfMemorySpec_cxx; }
|
|
19
|
+
|
|
20
|
+
// Include C++ defined types
|
|
21
|
+
#include "HybridReactNativePerfMemorySpec.hpp"
|
|
22
|
+
#include "MemoryUsage.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::reactnativeperfmemory::bridge::swift {
|
|
35
|
+
|
|
36
|
+
// pragma MARK: std::shared_ptr<Promise<MemoryUsage>>
|
|
37
|
+
/**
|
|
38
|
+
* Specialized version of `std::shared_ptr<Promise<MemoryUsage>>`.
|
|
39
|
+
*/
|
|
40
|
+
using std__shared_ptr_Promise_MemoryUsage__ = std::shared_ptr<Promise<MemoryUsage>>;
|
|
41
|
+
inline std::shared_ptr<Promise<MemoryUsage>> create_std__shared_ptr_Promise_MemoryUsage__() noexcept {
|
|
42
|
+
return Promise<MemoryUsage>::create();
|
|
43
|
+
}
|
|
44
|
+
inline PromiseHolder<MemoryUsage> wrap_std__shared_ptr_Promise_MemoryUsage__(std::shared_ptr<Promise<MemoryUsage>> promise) noexcept {
|
|
45
|
+
return PromiseHolder<MemoryUsage>(std::move(promise));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// pragma MARK: std::function<void(const MemoryUsage& /* result */)>
|
|
49
|
+
/**
|
|
50
|
+
* Specialized version of `std::function<void(const MemoryUsage&)>`.
|
|
51
|
+
*/
|
|
52
|
+
using Func_void_MemoryUsage = std::function<void(const MemoryUsage& /* result */)>;
|
|
53
|
+
/**
|
|
54
|
+
* Wrapper class for a `std::function<void(const MemoryUsage& / * result * /)>`, this can be used from Swift.
|
|
55
|
+
*/
|
|
56
|
+
class Func_void_MemoryUsage_Wrapper final {
|
|
57
|
+
public:
|
|
58
|
+
explicit Func_void_MemoryUsage_Wrapper(std::function<void(const MemoryUsage& /* result */)>&& func): _function(std::make_unique<std::function<void(const MemoryUsage& /* result */)>>(std::move(func))) {}
|
|
59
|
+
inline void call(MemoryUsage result) const noexcept {
|
|
60
|
+
_function->operator()(result);
|
|
61
|
+
}
|
|
62
|
+
private:
|
|
63
|
+
std::unique_ptr<std::function<void(const MemoryUsage& /* result */)>> _function;
|
|
64
|
+
} SWIFT_NONCOPYABLE;
|
|
65
|
+
Func_void_MemoryUsage create_Func_void_MemoryUsage(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
66
|
+
inline Func_void_MemoryUsage_Wrapper wrap_Func_void_MemoryUsage(Func_void_MemoryUsage value) noexcept {
|
|
67
|
+
return Func_void_MemoryUsage_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<HybridReactNativePerfMemorySpec>
|
|
93
|
+
/**
|
|
94
|
+
* Specialized version of `std::shared_ptr<HybridReactNativePerfMemorySpec>`.
|
|
95
|
+
*/
|
|
96
|
+
using std__shared_ptr_HybridReactNativePerfMemorySpec_ = std::shared_ptr<HybridReactNativePerfMemorySpec>;
|
|
97
|
+
std::shared_ptr<HybridReactNativePerfMemorySpec> create_std__shared_ptr_HybridReactNativePerfMemorySpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
98
|
+
void* NON_NULL get_std__shared_ptr_HybridReactNativePerfMemorySpec_(std__shared_ptr_HybridReactNativePerfMemorySpec_ cppType);
|
|
99
|
+
|
|
100
|
+
// pragma MARK: std::weak_ptr<HybridReactNativePerfMemorySpec>
|
|
101
|
+
using std__weak_ptr_HybridReactNativePerfMemorySpec_ = std::weak_ptr<HybridReactNativePerfMemorySpec>;
|
|
102
|
+
inline std__weak_ptr_HybridReactNativePerfMemorySpec_ weakify_std__shared_ptr_HybridReactNativePerfMemorySpec_(const std::shared_ptr<HybridReactNativePerfMemorySpec>& strong) noexcept { return strong; }
|
|
103
|
+
|
|
104
|
+
// pragma MARK: Result<std::shared_ptr<Promise<MemoryUsage>>>
|
|
105
|
+
using Result_std__shared_ptr_Promise_MemoryUsage___ = Result<std::shared_ptr<Promise<MemoryUsage>>>;
|
|
106
|
+
inline Result_std__shared_ptr_Promise_MemoryUsage___ create_Result_std__shared_ptr_Promise_MemoryUsage___(const std::shared_ptr<Promise<MemoryUsage>>& value) noexcept {
|
|
107
|
+
return Result<std::shared_ptr<Promise<MemoryUsage>>>::withValue(value);
|
|
108
|
+
}
|
|
109
|
+
inline Result_std__shared_ptr_Promise_MemoryUsage___ create_Result_std__shared_ptr_Promise_MemoryUsage___(const std::exception_ptr& error) noexcept {
|
|
110
|
+
return Result<std::shared_ptr<Promise<MemoryUsage>>>::withError(error);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} // namespace margelo::nitro::reactnativeperfmemory::bridge::swift
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfMemory-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 `HybridReactNativePerfMemorySpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::reactnativeperfmemory { class HybridReactNativePerfMemorySpec; }
|
|
13
|
+
// Forward declaration of `MemoryUsage` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::reactnativeperfmemory { struct MemoryUsage; }
|
|
15
|
+
|
|
16
|
+
// Include C++ defined types
|
|
17
|
+
#include "HybridReactNativePerfMemorySpec.hpp"
|
|
18
|
+
#include "MemoryUsage.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 "ReactNativePerfMemory-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 `HybridReactNativePerfMemorySpec_cxx` to properly resolve imports.
|
|
35
|
+
namespace ReactNativePerfMemory { class HybridReactNativePerfMemorySpec_cxx; }
|
|
36
|
+
|
|
37
|
+
// Include Swift defined types
|
|
38
|
+
#if __has_include("ReactNativePerfMemory-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 "ReactNativePerfMemory".
|
|
41
|
+
#include "ReactNativePerfMemory-Swift.h"
|
|
42
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
43
|
+
#elif __has_include(<ReactNativePerfMemory/ReactNativePerfMemory-Swift.h>)
|
|
44
|
+
#include <ReactNativePerfMemory/ReactNativePerfMemory-Swift.h>
|
|
45
|
+
#else
|
|
46
|
+
#error ReactNativePerfMemory's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ReactNativePerfMemory", and try building the app first.
|
|
47
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfMemoryAutolinking.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 "ReactNativePerfMemory-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridReactNativePerfMemorySpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface ReactNativePerfMemoryAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation ReactNativePerfMemoryAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::reactnativeperfmemory;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"ReactNativePerfMemory",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridReactNativePerfMemorySpec> hybridObject = ReactNativePerfMemory::ReactNativePerfMemoryAutolinking::createReactNativePerfMemory();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReactNativePerfMemoryAutolinking.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 ReactNativePerfMemoryAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.reactnativeperfmemory.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridReactNativePerfMemorySpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridReactNativePerfMemorySpec_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, `ReactNativePerfMemory`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createReactNativePerfMemory() -> bridge.std__shared_ptr_HybridReactNativePerfMemorySpec_ {
|
|
19
|
+
let hybridObject = ReactNativePerfMemory()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridReactNativePerfMemorySpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativePerfMemorySpecSwift.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 "HybridReactNativePerfMemorySpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::reactnativeperfmemory {
|
|
11
|
+
} // namespace margelo::nitro::reactnativeperfmemory
|