@pigeonmal/react-native-nitro-fetch 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 (104) hide show
  1. package/NitroFetch.podspec +30 -0
  2. package/android/CMakeLists.txt +70 -0
  3. package/android/build.gradle +130 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  7. package/android/src/main/java/com/margelo/nitro/nitrofetch/AutoPrefetcher.kt +72 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrofetch/FetchCache.kt +58 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrofetch/NativeStorage.kt +102 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetch.kt +94 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetchClient.kt +331 -0
  12. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetchPackage.kt +22 -0
  13. package/ios/FetchCache.swift +56 -0
  14. package/ios/NativeStorage.swift +61 -0
  15. package/ios/NitroAutoPrefetcher.swift +45 -0
  16. package/ios/NitroBootstrap.mm +27 -0
  17. package/ios/NitroFetch.swift +9 -0
  18. package/ios/NitroFetchClient.swift +230 -0
  19. package/lib/module/NitroFetch.nitro.js +4 -0
  20. package/lib/module/NitroFetch.nitro.js.map +1 -0
  21. package/lib/module/NitroInstances.js +8 -0
  22. package/lib/module/NitroInstances.js.map +1 -0
  23. package/lib/module/fetch.js +522 -0
  24. package/lib/module/fetch.js.map +1 -0
  25. package/lib/module/index.js +12 -0
  26. package/lib/module/index.js.map +1 -0
  27. package/lib/module/package.json +1 -0
  28. package/lib/module/type.js +2 -0
  29. package/lib/module/type.js.map +1 -0
  30. package/lib/typescript/package.json +1 -0
  31. package/lib/typescript/src/NitroFetch.nitro.d.ts +48 -0
  32. package/lib/typescript/src/NitroFetch.nitro.d.ts.map +1 -0
  33. package/lib/typescript/src/NitroInstances.d.ts +5 -0
  34. package/lib/typescript/src/NitroInstances.d.ts.map +1 -0
  35. package/lib/typescript/src/fetch.d.ts +28 -0
  36. package/lib/typescript/src/fetch.d.ts.map +1 -0
  37. package/lib/typescript/src/index.d.ts +6 -0
  38. package/lib/typescript/src/index.d.ts.map +1 -0
  39. package/lib/typescript/src/type.d.ts +4 -0
  40. package/lib/typescript/src/type.d.ts.map +1 -0
  41. package/nitro.json +25 -0
  42. package/nitrogen/generated/android/c++/JHybridNativeStorageSpec.cpp +54 -0
  43. package/nitrogen/generated/android/c++/JHybridNativeStorageSpec.hpp +66 -0
  44. package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.cpp +96 -0
  45. package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.hpp +66 -0
  46. package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.cpp +49 -0
  47. package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.hpp +64 -0
  48. package/nitrogen/generated/android/c++/JNitroHeader.hpp +57 -0
  49. package/nitrogen/generated/android/c++/JNitroRequest.hpp +100 -0
  50. package/nitrogen/generated/android/c++/JNitroRequestMethod.hpp +74 -0
  51. package/nitrogen/generated/android/c++/JNitroResponse.hpp +102 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNativeStorageSpec.kt +60 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchClientSpec.kt +60 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchSpec.kt +52 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroHeader.kt +32 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequest.kt +47 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequestMethod.kt +26 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroResponse.kt +50 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/nitrofetchOnLoad.kt +35 -0
  60. package/nitrogen/generated/android/nitrofetch+autolinking.cmake +85 -0
  61. package/nitrogen/generated/android/nitrofetch+autolinking.gradle +27 -0
  62. package/nitrogen/generated/android/nitrofetchOnLoad.cpp +64 -0
  63. package/nitrogen/generated/android/nitrofetchOnLoad.hpp +25 -0
  64. package/nitrogen/generated/ios/NitroFetch+autolinking.rb +60 -0
  65. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.cpp +90 -0
  66. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.hpp +321 -0
  67. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Umbrella.hpp +69 -0
  68. package/nitrogen/generated/ios/NitroFetchAutolinking.mm +49 -0
  69. package/nitrogen/generated/ios/NitroFetchAutolinking.swift +55 -0
  70. package/nitrogen/generated/ios/c++/HybridNativeStorageSpecSwift.cpp +11 -0
  71. package/nitrogen/generated/ios/c++/HybridNativeStorageSpecSwift.hpp +85 -0
  72. package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.cpp +11 -0
  73. package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.hpp +103 -0
  74. package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.cpp +11 -0
  75. package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.hpp +75 -0
  76. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  77. package/nitrogen/generated/ios/swift/Func_void_NitroResponse.swift +47 -0
  78. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  79. package/nitrogen/generated/ios/swift/HybridNativeStorageSpec.swift +51 -0
  80. package/nitrogen/generated/ios/swift/HybridNativeStorageSpec_cxx.swift +145 -0
  81. package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec.swift +51 -0
  82. package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec_cxx.swift +161 -0
  83. package/nitrogen/generated/ios/swift/HybridNitroFetchSpec.swift +49 -0
  84. package/nitrogen/generated/ios/swift/HybridNitroFetchSpec_cxx.swift +126 -0
  85. package/nitrogen/generated/ios/swift/NitroHeader.swift +46 -0
  86. package/nitrogen/generated/ios/swift/NitroRequest.swift +206 -0
  87. package/nitrogen/generated/ios/swift/NitroRequestMethod.swift +60 -0
  88. package/nitrogen/generated/ios/swift/NitroResponse.swift +162 -0
  89. package/nitrogen/generated/shared/c++/HybridNativeStorageSpec.cpp +23 -0
  90. package/nitrogen/generated/shared/c++/HybridNativeStorageSpec.hpp +64 -0
  91. package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.cpp +23 -0
  92. package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.hpp +69 -0
  93. package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.cpp +21 -0
  94. package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.hpp +64 -0
  95. package/nitrogen/generated/shared/c++/NitroHeader.hpp +71 -0
  96. package/nitrogen/generated/shared/c++/NitroRequest.hpp +98 -0
  97. package/nitrogen/generated/shared/c++/NitroRequestMethod.hpp +96 -0
  98. package/nitrogen/generated/shared/c++/NitroResponse.hpp +99 -0
  99. package/package.json +162 -0
  100. package/src/NitroFetch.nitro.ts +67 -0
  101. package/src/NitroInstances.ts +14 -0
  102. package/src/fetch.ts +603 -0
  103. package/src/index.tsx +17 -0
  104. package/src/type.ts +3 -0
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// JNitroRequestMethod.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 <fbjni/fbjni.h>
11
+ #include "NitroRequestMethod.hpp"
12
+
13
+ namespace margelo::nitro::nitrofetch {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "NitroRequestMethod" and the the Kotlin enum "NitroRequestMethod".
19
+ */
20
+ struct JNitroRequestMethod final: public jni::JavaClass<JNitroRequestMethod> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NitroRequestMethod;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum NitroRequestMethod.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ NitroRequestMethod toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<NitroRequestMethod>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JNitroRequestMethod> fromCpp(NitroRequestMethod value) {
43
+ static const auto clazz = javaClassStatic();
44
+ static const auto fieldGET = clazz->getStaticField<JNitroRequestMethod>("GET");
45
+ static const auto fieldHEAD = clazz->getStaticField<JNitroRequestMethod>("HEAD");
46
+ static const auto fieldPOST = clazz->getStaticField<JNitroRequestMethod>("POST");
47
+ static const auto fieldPUT = clazz->getStaticField<JNitroRequestMethod>("PUT");
48
+ static const auto fieldPATCH = clazz->getStaticField<JNitroRequestMethod>("PATCH");
49
+ static const auto fieldDELETE = clazz->getStaticField<JNitroRequestMethod>("DELETE");
50
+ static const auto fieldOPTIONS = clazz->getStaticField<JNitroRequestMethod>("OPTIONS");
51
+
52
+ switch (value) {
53
+ case NitroRequestMethod::GET:
54
+ return clazz->getStaticFieldValue(fieldGET);
55
+ case NitroRequestMethod::HEAD:
56
+ return clazz->getStaticFieldValue(fieldHEAD);
57
+ case NitroRequestMethod::POST:
58
+ return clazz->getStaticFieldValue(fieldPOST);
59
+ case NitroRequestMethod::PUT:
60
+ return clazz->getStaticFieldValue(fieldPUT);
61
+ case NitroRequestMethod::PATCH:
62
+ return clazz->getStaticFieldValue(fieldPATCH);
63
+ case NitroRequestMethod::DELETE:
64
+ return clazz->getStaticFieldValue(fieldDELETE);
65
+ case NitroRequestMethod::OPTIONS:
66
+ return clazz->getStaticFieldValue(fieldOPTIONS);
67
+ default:
68
+ std::string stringValue = std::to_string(static_cast<int>(value));
69
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
70
+ }
71
+ }
72
+ };
73
+
74
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,102 @@
1
+ ///
2
+ /// JNitroResponse.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 <fbjni/fbjni.h>
11
+ #include "NitroResponse.hpp"
12
+
13
+ #include "JNitroHeader.hpp"
14
+ #include "NitroHeader.hpp"
15
+ #include <optional>
16
+ #include <string>
17
+ #include <vector>
18
+
19
+ namespace margelo::nitro::nitrofetch {
20
+
21
+ using namespace facebook;
22
+
23
+ /**
24
+ * The C++ JNI bridge between the C++ struct "NitroResponse" and the the Kotlin data class "NitroResponse".
25
+ */
26
+ struct JNitroResponse final: public jni::JavaClass<JNitroResponse> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NitroResponse;";
29
+
30
+ public:
31
+ /**
32
+ * Convert this Java/Kotlin-based struct to the C++ struct NitroResponse by copying all values to C++.
33
+ */
34
+ [[maybe_unused]]
35
+ [[nodiscard]]
36
+ NitroResponse toCpp() const {
37
+ static const auto clazz = javaClassStatic();
38
+ static const auto fieldUrl = clazz->getField<jni::JString>("url");
39
+ jni::local_ref<jni::JString> url = this->getFieldValue(fieldUrl);
40
+ static const auto fieldStatus = clazz->getField<double>("status");
41
+ double status = this->getFieldValue(fieldStatus);
42
+ static const auto fieldStatusText = clazz->getField<jni::JString>("statusText");
43
+ jni::local_ref<jni::JString> statusText = this->getFieldValue(fieldStatusText);
44
+ static const auto fieldOk = clazz->getField<jboolean>("ok");
45
+ jboolean ok = this->getFieldValue(fieldOk);
46
+ static const auto fieldRedirected = clazz->getField<jboolean>("redirected");
47
+ jboolean redirected = this->getFieldValue(fieldRedirected);
48
+ static const auto fieldHeaders = clazz->getField<jni::JArrayClass<JNitroHeader>>("headers");
49
+ jni::local_ref<jni::JArrayClass<JNitroHeader>> headers = this->getFieldValue(fieldHeaders);
50
+ static const auto fieldBodyString = clazz->getField<jni::JString>("bodyString");
51
+ jni::local_ref<jni::JString> bodyString = this->getFieldValue(fieldBodyString);
52
+ static const auto fieldBodyBytes = clazz->getField<jni::JString>("bodyBytes");
53
+ jni::local_ref<jni::JString> bodyBytes = this->getFieldValue(fieldBodyBytes);
54
+ return NitroResponse(
55
+ url->toStdString(),
56
+ status,
57
+ statusText->toStdString(),
58
+ static_cast<bool>(ok),
59
+ static_cast<bool>(redirected),
60
+ [&]() {
61
+ size_t __size = headers->size();
62
+ std::vector<NitroHeader> __vector;
63
+ __vector.reserve(__size);
64
+ for (size_t __i = 0; __i < __size; __i++) {
65
+ auto __element = headers->getElement(__i);
66
+ __vector.push_back(__element->toCpp());
67
+ }
68
+ return __vector;
69
+ }(),
70
+ bodyString != nullptr ? std::make_optional(bodyString->toStdString()) : std::nullopt,
71
+ bodyBytes != nullptr ? std::make_optional(bodyBytes->toStdString()) : std::nullopt
72
+ );
73
+ }
74
+
75
+ public:
76
+ /**
77
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
78
+ */
79
+ [[maybe_unused]]
80
+ static jni::local_ref<JNitroResponse::javaobject> fromCpp(const NitroResponse& value) {
81
+ return newInstance(
82
+ jni::make_jstring(value.url),
83
+ value.status,
84
+ jni::make_jstring(value.statusText),
85
+ value.ok,
86
+ value.redirected,
87
+ [&]() {
88
+ size_t __size = value.headers.size();
89
+ jni::local_ref<jni::JArrayClass<JNitroHeader>> __array = jni::JArrayClass<JNitroHeader>::newArray(__size);
90
+ for (size_t __i = 0; __i < __size; __i++) {
91
+ const auto& __element = value.headers[__i];
92
+ __array->setElement(__i, *JNitroHeader::fromCpp(__element));
93
+ }
94
+ return __array;
95
+ }(),
96
+ value.bodyString.has_value() ? jni::make_jstring(value.bodyString.value()) : nullptr,
97
+ value.bodyBytes.has_value() ? jni::make_jstring(value.bodyBytes.value()) : nullptr
98
+ );
99
+ }
100
+ };
101
+
102
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// HybridNativeStorageSpec.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.nitrofetch
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.*
14
+
15
+ /**
16
+ * A Kotlin class representing the NativeStorage HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of NativeStorage.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridNativeStorageSpec: 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
+ // Properties
40
+
41
+
42
+ // Methods
43
+ @DoNotStrip
44
+ @Keep
45
+ abstract fun getString(key: String): String
46
+
47
+ @DoNotStrip
48
+ @Keep
49
+ abstract fun setString(key: String, value: String): Unit
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ abstract fun removeString(key: String): Unit
54
+
55
+ private external fun initHybrid(): HybridData
56
+
57
+ companion object {
58
+ private const val TAG = "HybridNativeStorageSpec"
59
+ }
60
+ }
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// HybridNitroFetchClientSpec.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.nitrofetch
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.*
14
+
15
+ /**
16
+ * A Kotlin class representing the NitroFetchClient HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of NitroFetchClient.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridNitroFetchClientSpec: 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
+ // Properties
40
+
41
+
42
+ // Methods
43
+ @DoNotStrip
44
+ @Keep
45
+ abstract fun request(req: NitroRequest): Promise<NitroResponse>
46
+
47
+ @DoNotStrip
48
+ @Keep
49
+ abstract fun prefetch(req: NitroRequest): Promise<Unit>
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ abstract fun requestSync(req: NitroRequest): NitroResponse
54
+
55
+ private external fun initHybrid(): HybridData
56
+
57
+ companion object {
58
+ private const val TAG = "HybridNitroFetchClientSpec"
59
+ }
60
+ }
@@ -0,0 +1,52 @@
1
+ ///
2
+ /// HybridNitroFetchSpec.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.nitrofetch
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.*
14
+
15
+ /**
16
+ * A Kotlin class representing the NitroFetch HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of NitroFetch.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridNitroFetchSpec: 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
+ // Properties
40
+
41
+
42
+ // Methods
43
+ @DoNotStrip
44
+ @Keep
45
+ abstract fun createClient(): HybridNitroFetchClientSpec
46
+
47
+ private external fun initHybrid(): HybridData
48
+
49
+ companion object {
50
+ private const val TAG = "HybridNitroFetchSpec"
51
+ }
52
+ }
@@ -0,0 +1,32 @@
1
+ ///
2
+ /// NitroHeader.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.nitrofetch
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "NitroHeader".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class NitroHeader
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val key: String,
27
+ @DoNotStrip
28
+ @Keep
29
+ val value: String
30
+ ) {
31
+ /* main constructor */
32
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// NitroRequest.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.nitrofetch
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "NitroRequest".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class NitroRequest
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val url: String,
27
+ @DoNotStrip
28
+ @Keep
29
+ val method: NitroRequestMethod?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val headers: Array<NitroHeader>?,
33
+ @DoNotStrip
34
+ @Keep
35
+ val bodyString: String?,
36
+ @DoNotStrip
37
+ @Keep
38
+ val bodyBytes: String?,
39
+ @DoNotStrip
40
+ @Keep
41
+ val timeoutMs: Double?,
42
+ @DoNotStrip
43
+ @Keep
44
+ val followRedirects: Boolean?
45
+ ) {
46
+ /* main constructor */
47
+ }
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// NitroRequestMethod.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.nitrofetch
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "NitroRequestMethod".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class NitroRequestMethod(@DoNotStrip @Keep val value: Int) {
19
+ GET(0),
20
+ HEAD(1),
21
+ POST(2),
22
+ PUT(3),
23
+ PATCH(4),
24
+ DELETE(5),
25
+ OPTIONS(6);
26
+ }
@@ -0,0 +1,50 @@
1
+ ///
2
+ /// NitroResponse.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.nitrofetch
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "NitroResponse".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class NitroResponse
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val url: String,
27
+ @DoNotStrip
28
+ @Keep
29
+ val status: Double,
30
+ @DoNotStrip
31
+ @Keep
32
+ val statusText: String,
33
+ @DoNotStrip
34
+ @Keep
35
+ val ok: Boolean,
36
+ @DoNotStrip
37
+ @Keep
38
+ val redirected: Boolean,
39
+ @DoNotStrip
40
+ @Keep
41
+ val headers: Array<NitroHeader>,
42
+ @DoNotStrip
43
+ @Keep
44
+ val bodyString: String?,
45
+ @DoNotStrip
46
+ @Keep
47
+ val bodyBytes: String?
48
+ ) {
49
+ /* main constructor */
50
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// nitrofetchOnLoad.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.nitrofetch
9
+
10
+ import android.util.Log
11
+
12
+ internal class nitrofetchOnLoad {
13
+ companion object {
14
+ private const val TAG = "nitrofetchOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "nitrofetch".
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 nitrofetch C++ library...")
25
+ System.loadLibrary("nitrofetch")
26
+ Log.i(TAG, "Successfully loaded nitrofetch C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load nitrofetch 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,85 @@
1
+ #
2
+ # nitrofetch+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/nitrofetch+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITROFETCH_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
+ nitrofetch PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/nitrofetchOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.cpp
37
+ ../nitrogen/generated/shared/c++/HybridNitroFetchSpec.cpp
38
+ ../nitrogen/generated/shared/c++/HybridNativeStorageSpec.cpp
39
+ # Android-specific Nitrogen C++ sources
40
+ ../nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.cpp
41
+ ../nitrogen/generated/android/c++/JHybridNitroFetchSpec.cpp
42
+ ../nitrogen/generated/android/c++/JHybridNativeStorageSpec.cpp
43
+ )
44
+
45
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
46
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
47
+ target_compile_definitions(
48
+ nitrofetch PRIVATE
49
+ -DFOLLY_NO_CONFIG=1
50
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
51
+ -DFOLLY_USE_LIBCPP=1
52
+ -DFOLLY_CFG_NO_COROUTINES=1
53
+ -DFOLLY_MOBILE=1
54
+ -DFOLLY_HAVE_RECVMMSG=1
55
+ -DFOLLY_HAVE_PTHREAD=1
56
+ # Once we target android-23 above, we can comment
57
+ # the following line. NDK uses GNU style stderror_r() after API 23.
58
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
59
+ )
60
+
61
+ # Add all libraries required by the generated specs
62
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
63
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
64
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
65
+
66
+ # Link all libraries together
67
+ target_link_libraries(
68
+ nitrofetch
69
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
70
+ ReactAndroid::jsi # <-- RN: JSI
71
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
72
+ )
73
+
74
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
75
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
76
+ target_link_libraries(
77
+ nitrofetch
78
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
79
+ )
80
+ else()
81
+ target_link_libraries(
82
+ nitrofetch
83
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
84
+ )
85
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// nitrofetch+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/nitrofetch+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 nitrofetch 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
+ }