@rnpack/utils 0.1.4 → 0.1.6

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 (126) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +16 -26
  3. package/Utils.podspec +29 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/rnpack/utils/Utils.kt +10 -0
  10. package/android/src/main/java/com/margelo/nitro/rnpack/utils/UtilsPackage.kt +22 -0
  11. package/ios/Utils.swift +5 -0
  12. package/lib/module/Utils.nitro.js +4 -0
  13. package/lib/module/Utils.nitro.js.map +1 -0
  14. package/lib/module/constants/index.js +2 -0
  15. package/lib/module/constants/index.js.map +1 -1
  16. package/lib/module/constants/permissions.js +2 -0
  17. package/lib/module/constants/permissions.js.map +1 -1
  18. package/lib/module/constants/settings.js +2 -0
  19. package/lib/module/constants/settings.js.map +1 -1
  20. package/lib/module/hooks/index.js +2 -0
  21. package/lib/module/hooks/index.js.map +1 -1
  22. package/lib/module/hooks/usePagination.js +2 -0
  23. package/lib/module/hooks/usePagination.js.map +1 -1
  24. package/lib/module/hooks/useTimer.js +3 -1
  25. package/lib/module/hooks/useTimer.js.map +1 -1
  26. package/lib/module/index.js +7 -0
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/types/index.js +2 -1
  29. package/lib/module/types/index.js.map +1 -1
  30. package/lib/module/types/settings.js +1 -1
  31. package/lib/module/utils/index.js +2 -0
  32. package/lib/module/utils/index.js.map +1 -1
  33. package/lib/module/utils/object.js +2 -0
  34. package/lib/module/utils/object.js.map +1 -1
  35. package/lib/module/utils/permissions.js +2 -0
  36. package/lib/module/utils/permissions.js.map +1 -1
  37. package/lib/module/utils/responsive.js +5 -3
  38. package/lib/module/utils/responsive.js.map +1 -1
  39. package/lib/module/utils/settings.js +2 -0
  40. package/lib/module/utils/settings.js.map +1 -1
  41. package/lib/module/utils/string.js +2 -0
  42. package/lib/module/utils/string.js.map +1 -1
  43. package/lib/module/utils/utils.js +2 -0
  44. package/lib/module/utils/utils.js.map +1 -1
  45. package/lib/typescript/package.json +1 -0
  46. package/lib/typescript/src/Utils.nitro.d.ts +8 -0
  47. package/lib/typescript/src/Utils.nitro.d.ts.map +1 -0
  48. package/lib/typescript/src/constants/permissions.d.ts +4 -4
  49. package/lib/typescript/src/index.d.ts +1 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -1
  51. package/lib/typescript/src/types/index.d.ts +0 -1
  52. package/lib/typescript/src/types/index.d.ts.map +1 -1
  53. package/nitro.json +17 -0
  54. package/nitrogen/generated/android/c++/JHybridUtilsSpec.cpp +52 -0
  55. package/nitrogen/generated/android/c++/JHybridUtilsSpec.hpp +65 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/HybridUtilsSpec.kt +57 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/rnpack_utilsOnLoad.kt +35 -0
  58. package/nitrogen/generated/android/rnpack_utils+autolinking.cmake +81 -0
  59. package/nitrogen/generated/android/rnpack_utils+autolinking.gradle +27 -0
  60. package/nitrogen/generated/android/rnpack_utilsOnLoad.cpp +44 -0
  61. package/nitrogen/generated/android/rnpack_utilsOnLoad.hpp +25 -0
  62. package/nitrogen/generated/ios/Utils+autolinking.rb +60 -0
  63. package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.cpp +33 -0
  64. package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.hpp +51 -0
  65. package/nitrogen/generated/ios/Utils-Swift-Cxx-Umbrella.hpp +43 -0
  66. package/nitrogen/generated/ios/UtilsAutolinking.mm +33 -0
  67. package/nitrogen/generated/ios/UtilsAutolinking.swift +25 -0
  68. package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.cpp +11 -0
  69. package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.hpp +76 -0
  70. package/nitrogen/generated/ios/swift/HybridUtilsSpec.swift +56 -0
  71. package/nitrogen/generated/ios/swift/HybridUtilsSpec_cxx.swift +131 -0
  72. package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +21 -0
  73. package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +62 -0
  74. package/package.json +92 -99
  75. package/src/Utils.nitro.ts +6 -0
  76. package/src/hooks/useTimer.tsx +1 -1
  77. package/src/index.tsx +9 -0
  78. package/src/types/index.ts +0 -1
  79. package/src/utils/responsive.tsx +3 -3
  80. package/lib/commonjs/constants/index.js +0 -28
  81. package/lib/commonjs/constants/index.js.map +0 -1
  82. package/lib/commonjs/constants/permissions.js +0 -20
  83. package/lib/commonjs/constants/permissions.js.map +0 -1
  84. package/lib/commonjs/constants/settings.js +0 -17
  85. package/lib/commonjs/constants/settings.js.map +0 -1
  86. package/lib/commonjs/hooks/index.js +0 -28
  87. package/lib/commonjs/hooks/index.js.map +0 -1
  88. package/lib/commonjs/hooks/usePagination.js +0 -29
  89. package/lib/commonjs/hooks/usePagination.js.map +0 -1
  90. package/lib/commonjs/hooks/useTimer.js +0 -44
  91. package/lib/commonjs/hooks/useTimer.js.map +0 -1
  92. package/lib/commonjs/index.js +0 -50
  93. package/lib/commonjs/index.js.map +0 -1
  94. package/lib/commonjs/package.json +0 -1
  95. package/lib/commonjs/types/index.js +0 -28
  96. package/lib/commonjs/types/index.js.map +0 -1
  97. package/lib/commonjs/types/settings.js +0 -2
  98. package/lib/commonjs/types/settings.js.map +0 -1
  99. package/lib/commonjs/types/storage.js +0 -2
  100. package/lib/commonjs/types/storage.js.map +0 -1
  101. package/lib/commonjs/utils/index.js +0 -72
  102. package/lib/commonjs/utils/index.js.map +0 -1
  103. package/lib/commonjs/utils/object.js +0 -32
  104. package/lib/commonjs/utils/object.js.map +0 -1
  105. package/lib/commonjs/utils/permissions.js +0 -55
  106. package/lib/commonjs/utils/permissions.js.map +0 -1
  107. package/lib/commonjs/utils/responsive.js +0 -36
  108. package/lib/commonjs/utils/responsive.js.map +0 -1
  109. package/lib/commonjs/utils/settings.js +0 -100
  110. package/lib/commonjs/utils/settings.js.map +0 -1
  111. package/lib/commonjs/utils/storage.js +0 -36
  112. package/lib/commonjs/utils/storage.js.map +0 -1
  113. package/lib/commonjs/utils/string.js +0 -60
  114. package/lib/commonjs/utils/string.js.map +0 -1
  115. package/lib/commonjs/utils/utils.js +0 -23
  116. package/lib/commonjs/utils/utils.js.map +0 -1
  117. package/lib/module/types/storage.js +0 -2
  118. package/lib/module/types/storage.js.map +0 -1
  119. package/lib/module/utils/storage.js +0 -30
  120. package/lib/module/utils/storage.js.map +0 -1
  121. package/lib/typescript/src/types/storage.d.ts +0 -16
  122. package/lib/typescript/src/types/storage.d.ts.map +0 -1
  123. package/lib/typescript/src/utils/storage.d.ts +0 -15
  124. package/lib/typescript/src/utils/storage.d.ts.map +0 -1
  125. package/src/types/storage.ts +0 -24
  126. package/src/utils/storage.ts +0 -45
@@ -1,12 +1,12 @@
1
1
  declare const permissions: {
2
2
  android: {
3
3
  bluetooth: {
4
- scan: import("react-native").Permission | undefined;
5
- connect: import("react-native").Permission | undefined;
4
+ scan: "android.permission.BLUETOOTH_SCAN";
5
+ connect: "android.permission.BLUETOOTH_CONNECT";
6
6
  };
7
7
  location: {
8
- fine: import("react-native").Permission | undefined;
9
- coarse: import("react-native").Permission | undefined;
8
+ fine: "android.permission.ACCESS_FINE_LOCATION";
9
+ coarse: "android.permission.ACCESS_COARSE_LOCATION";
10
10
  };
11
11
  };
12
12
  };
@@ -1,3 +1,4 @@
1
+ export declare function multiply(a: number, b: number): number;
1
2
  export * from './utils';
2
3
  export * from './hooks';
3
4
  export * from './constants';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export * from './settings';
2
- export * from './storage';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
package/nitro.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "cxxNamespace": ["rnpack_utils"],
3
+ "ios": {
4
+ "iosModuleName": "Utils"
5
+ },
6
+ "android": {
7
+ "androidNamespace": ["rnpack","utils"],
8
+ "androidCxxLibName": "rnpack_utils"
9
+ },
10
+ "autolinking": {
11
+ "Utils": {
12
+ "swift": "Utils",
13
+ "kotlin": "Utils"
14
+ }
15
+ },
16
+ "ignorePaths": ["node_modules"]
17
+ }
@@ -0,0 +1,52 @@
1
+ ///
2
+ /// JHybridUtilsSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "JHybridUtilsSpec.hpp"
9
+
10
+
11
+
12
+
13
+
14
+ namespace margelo::nitro::rnpack_utils {
15
+
16
+ jni::local_ref<JHybridUtilsSpec::jhybriddata> JHybridUtilsSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
17
+ return makeCxxInstance(jThis);
18
+ }
19
+
20
+ void JHybridUtilsSpec::registerNatives() {
21
+ registerHybrid({
22
+ makeNativeMethod("initHybrid", JHybridUtilsSpec::initHybrid),
23
+ });
24
+ }
25
+
26
+ size_t JHybridUtilsSpec::getExternalMemorySize() noexcept {
27
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
28
+ return method(_javaPart);
29
+ }
30
+
31
+ void JHybridUtilsSpec::dispose() noexcept {
32
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
33
+ method(_javaPart);
34
+ }
35
+
36
+ std::string JHybridUtilsSpec::toString() {
37
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
38
+ auto javaString = method(_javaPart);
39
+ return javaString->toStdString();
40
+ }
41
+
42
+ // Properties
43
+
44
+
45
+ // Methods
46
+ double JHybridUtilsSpec::multiply(double a, double b) {
47
+ static const auto method = javaClassStatic()->getMethod<double(double /* a */, double /* b */)>("multiply");
48
+ auto __result = method(_javaPart, a, b);
49
+ return __result;
50
+ }
51
+
52
+ } // namespace margelo::nitro::rnpack_utils
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// HybridUtilsSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridUtilsSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::rnpack_utils {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridUtilsSpec: public jni::HybridClass<JHybridUtilsSpec, JHybridObject>,
22
+ public virtual HybridUtilsSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rnpack/utils/HybridUtilsSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridUtilsSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridUtilsSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridUtilsSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
43
+ void dispose() noexcept override;
44
+ std::string toString() override;
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridUtilsSpec::javaobject>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ double multiply(double a, double b) override;
58
+
59
+ private:
60
+ friend HybridBase;
61
+ using HybridBase::HybridBase;
62
+ jni::global_ref<JHybridUtilsSpec::javaobject> _javaPart;
63
+ };
64
+
65
+ } // namespace margelo::nitro::rnpack_utils
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridUtilsSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.rnpack.utils
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.HybridObject
14
+
15
+ /**
16
+ * A Kotlin class representing the Utils HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of Utils.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridUtilsSpec: HybridObject() {
27
+ @DoNotStrip
28
+ private var mHybridData: HybridData = initHybrid()
29
+
30
+ init {
31
+ super.updateNative(mHybridData)
32
+ }
33
+
34
+ override fun updateNative(hybridData: HybridData) {
35
+ mHybridData = hybridData
36
+ super.updateNative(hybridData)
37
+ }
38
+
39
+ // Default implementation of `HybridObject.toString()`
40
+ override fun toString(): String {
41
+ return "[HybridObject Utils]"
42
+ }
43
+
44
+ // Properties
45
+
46
+
47
+ // Methods
48
+ @DoNotStrip
49
+ @Keep
50
+ abstract fun multiply(a: Double, b: Double): Double
51
+
52
+ private external fun initHybrid(): HybridData
53
+
54
+ companion object {
55
+ protected const val TAG = "HybridUtilsSpec"
56
+ }
57
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// rnpack_utilsOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.rnpack.utils
9
+
10
+ import android.util.Log
11
+
12
+ internal class rnpack_utilsOnLoad {
13
+ companion object {
14
+ private const val TAG = "rnpack_utilsOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "rnpack_utils".
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 rnpack_utils C++ library...")
25
+ System.loadLibrary("rnpack_utils")
26
+ Log.i(TAG, "Successfully loaded rnpack_utils C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load rnpack_utils 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
+ # rnpack_utils+autolinking.cmake
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # 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/rnpack_utils+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_RNPACKUTILS_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
+ rnpack_utils PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/rnpack_utilsOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridUtilsSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridUtilsSpec.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
+ rnpack_utils 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
+ rnpack_utils
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
+ rnpack_utils
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ rnpack_utils
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// rnpack_utils+autolinking.gradle
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /// 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/rnpack_utils+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 rnpack_utils 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
+ /// rnpack_utilsOnLoad.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #ifndef BUILDING_RNPACKUTILS_WITH_GENERATED_CMAKE_PROJECT
9
+ #error rnpack_utilsOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "rnpack_utilsOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridUtilsSpec.hpp"
19
+ #include <NitroModules/DefaultConstructableObject.hpp>
20
+
21
+ namespace margelo::nitro::rnpack_utils {
22
+
23
+ int initialize(JavaVM* vm) {
24
+ using namespace margelo::nitro;
25
+ using namespace margelo::nitro::rnpack_utils;
26
+ using namespace facebook;
27
+
28
+ return facebook::jni::initialize(vm, [] {
29
+ // Register native JNI methods
30
+ margelo::nitro::rnpack_utils::JHybridUtilsSpec::registerNatives();
31
+
32
+ // Register Nitro Hybrid Objects
33
+ HybridObjectRegistry::registerHybridObjectConstructor(
34
+ "Utils",
35
+ []() -> std::shared_ptr<HybridObject> {
36
+ static DefaultConstructableObject<JHybridUtilsSpec::javaobject> object("com/margelo/nitro/rnpack/utils/Utils");
37
+ auto instance = object.create();
38
+ return instance->cthis()->shared();
39
+ }
40
+ );
41
+ });
42
+ }
43
+
44
+ } // namespace margelo::nitro::rnpack_utils
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// rnpack_utilsOnLoad.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include <jni.h>
9
+ #include <NitroModules/NitroDefines.hpp>
10
+
11
+ namespace margelo::nitro::rnpack_utils {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of rnpack_utils, 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::rnpack_utils::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::rnpack_utils
@@ -0,0 +1,60 @@
1
+ #
2
+ # Utils+autolinking.rb
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # 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/Utils+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 Utils 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/Utils-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,33 @@
1
+ ///
2
+ /// Utils-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "Utils-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridUtilsSpecSwift.hpp"
12
+ #include "Utils-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::rnpack_utils::bridge::swift {
16
+
17
+ // pragma MARK: std::shared_ptr<HybridUtilsSpec>
18
+ std::shared_ptr<HybridUtilsSpec> create_std__shared_ptr_HybridUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
19
+ Utils::HybridUtilsSpec_cxx swiftPart = Utils::HybridUtilsSpec_cxx::fromUnsafe(swiftUnsafePointer);
20
+ return std::make_shared<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift>(swiftPart);
21
+ }
22
+ void* NON_NULL get_std__shared_ptr_HybridUtilsSpec_(std__shared_ptr_HybridUtilsSpec_ cppType) {
23
+ std::shared_ptr<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift>(cppType);
24
+ #ifdef NITRO_DEBUG
25
+ if (swiftWrapper == nullptr) [[unlikely]] {
26
+ throw std::runtime_error("Class \"HybridUtilsSpec\" is not implemented in Swift!");
27
+ }
28
+ #endif
29
+ Utils::HybridUtilsSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
30
+ return swiftPart.toUnsafe();
31
+ }
32
+
33
+ } // namespace margelo::nitro::rnpack_utils::bridge::swift
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// Utils-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridUtilsSpec` to properly resolve imports.
12
+ namespace margelo::nitro::rnpack_utils { class HybridUtilsSpec; }
13
+
14
+ // Forward declarations of Swift defined types
15
+ // Forward declaration of `HybridUtilsSpec_cxx` to properly resolve imports.
16
+ namespace Utils { class HybridUtilsSpec_cxx; }
17
+
18
+ // Include C++ defined types
19
+ #include "HybridUtilsSpec.hpp"
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
22
+ #include <memory>
23
+
24
+ /**
25
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
26
+ * as well as helper functions to interact with those C++ types from Swift.
27
+ */
28
+ namespace margelo::nitro::rnpack_utils::bridge::swift {
29
+
30
+ // pragma MARK: std::shared_ptr<HybridUtilsSpec>
31
+ /**
32
+ * Specialized version of `std::shared_ptr<HybridUtilsSpec>`.
33
+ */
34
+ using std__shared_ptr_HybridUtilsSpec_ = std::shared_ptr<HybridUtilsSpec>;
35
+ std::shared_ptr<HybridUtilsSpec> create_std__shared_ptr_HybridUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
36
+ void* NON_NULL get_std__shared_ptr_HybridUtilsSpec_(std__shared_ptr_HybridUtilsSpec_ cppType);
37
+
38
+ // pragma MARK: std::weak_ptr<HybridUtilsSpec>
39
+ using std__weak_ptr_HybridUtilsSpec_ = std::weak_ptr<HybridUtilsSpec>;
40
+ inline std__weak_ptr_HybridUtilsSpec_ weakify_std__shared_ptr_HybridUtilsSpec_(const std::shared_ptr<HybridUtilsSpec>& strong) noexcept { return strong; }
41
+
42
+ // pragma MARK: Result<double>
43
+ using Result_double_ = Result<double>;
44
+ inline Result_double_ create_Result_double_(double value) noexcept {
45
+ return Result<double>::withValue(std::move(value));
46
+ }
47
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
48
+ return Result<double>::withError(error);
49
+ }
50
+
51
+ } // namespace margelo::nitro::rnpack_utils::bridge::swift
@@ -0,0 +1,43 @@
1
+ ///
2
+ /// Utils-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridUtilsSpec` to properly resolve imports.
12
+ namespace margelo::nitro::rnpack_utils { class HybridUtilsSpec; }
13
+
14
+ // Include C++ defined types
15
+ #include "HybridUtilsSpec.hpp"
16
+ #include <NitroModules/Result.hpp>
17
+ #include <exception>
18
+ #include <memory>
19
+
20
+ // C++ helpers for Swift
21
+ #include "Utils-Swift-Cxx-Bridge.hpp"
22
+
23
+ // Common C++ types used in Swift
24
+ #include <NitroModules/ArrayBufferHolder.hpp>
25
+ #include <NitroModules/AnyMapUtils.hpp>
26
+ #include <NitroModules/RuntimeError.hpp>
27
+ #include <NitroModules/DateToChronoDate.hpp>
28
+
29
+ // Forward declarations of Swift defined types
30
+ // Forward declaration of `HybridUtilsSpec_cxx` to properly resolve imports.
31
+ namespace Utils { class HybridUtilsSpec_cxx; }
32
+
33
+ // Include Swift defined types
34
+ #if __has_include("Utils-Swift.h")
35
+ // This header is generated by Xcode/Swift on every app build.
36
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "Utils".
37
+ #include "Utils-Swift.h"
38
+ // Same as above, but used when building with frameworks (`use_frameworks`)
39
+ #elif __has_include(<Utils/Utils-Swift.h>)
40
+ #include <Utils/Utils-Swift.h>
41
+ #else
42
+ #error Utils's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "Utils", and try building the app first.
43
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// UtilsAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "Utils-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridUtilsSpecSwift.hpp"
14
+
15
+ @interface UtilsAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation UtilsAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::rnpack_utils;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "Utils",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridUtilsSpec> hybridObject = Utils::UtilsAutolinking::createUtils();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end