react-native-nitro-fetch 0.1.7 → 0.2.0

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 (154) hide show
  1. package/android/src/main/java/com/margelo/nitro/nitrofetch/AutoPrefetcher.kt +3 -1
  2. package/android/src/main/java/com/margelo/nitro/nitrofetch/CronetExtensions.kt +31 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroCronet.kt +89 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetchClient.kt +115 -28
  5. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroUrlRequest.kt +35 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroUrlRequestBuilder.kt +181 -0
  7. package/ios/HybridNitroCronet.swift +31 -0
  8. package/ios/HybridUrlRequest.swift +41 -0
  9. package/ios/HybridUrlRequestBuilder.swift +255 -0
  10. package/ios/NitroAutoPrefetcher.swift +3 -1
  11. package/ios/NitroFetchClient.swift +87 -5
  12. package/ios/URLSessionExtensions.swift +36 -0
  13. package/lib/module/NitroCronet.nitro.js +4 -0
  14. package/lib/module/NitroCronet.nitro.js.map +1 -0
  15. package/lib/module/NitroInstances.js +1 -0
  16. package/lib/module/NitroInstances.js.map +1 -1
  17. package/lib/module/fetch.js +179 -9
  18. package/lib/module/fetch.js.map +1 -1
  19. package/lib/typescript/src/NitroCronet.nitro.d.ts +53 -0
  20. package/lib/typescript/src/NitroCronet.nitro.d.ts.map +1 -0
  21. package/lib/typescript/src/NitroFetch.nitro.d.ts +10 -0
  22. package/lib/typescript/src/NitroFetch.nitro.d.ts.map +1 -1
  23. package/lib/typescript/src/NitroInstances.d.ts +3 -1
  24. package/lib/typescript/src/NitroInstances.d.ts.map +1 -1
  25. package/lib/typescript/src/fetch.d.ts +5 -2
  26. package/lib/typescript/src/fetch.d.ts.map +1 -1
  27. package/lib/typescript/src/index.d.ts +1 -1
  28. package/lib/typescript/src/index.d.ts.map +1 -1
  29. package/nitro.json +34 -6
  30. package/nitrogen/generated/android/c++/JFunc_void_UrlResponseInfo.hpp +82 -0
  31. package/nitrogen/generated/android/c++/JFunc_void_UrlResponseInfo_std__shared_ptr_ArrayBuffer__double.hpp +84 -0
  32. package/nitrogen/generated/android/c++/JFunc_void_UrlResponseInfo_std__string.hpp +82 -0
  33. package/nitrogen/generated/android/c++/JFunc_void_std__optional_UrlResponseInfo_.hpp +83 -0
  34. package/nitrogen/generated/android/c++/JFunc_void_std__optional_UrlResponseInfo__RequestException.hpp +85 -0
  35. package/nitrogen/generated/android/c++/JHttpHeader.hpp +61 -0
  36. package/nitrogen/generated/android/c++/JHybridNativeStorageSpec.cpp +23 -16
  37. package/nitrogen/generated/android/c++/JHybridNativeStorageSpec.hpp +20 -21
  38. package/nitrogen/generated/android/c++/JHybridNitroCronetSpec.cpp +57 -0
  39. package/nitrogen/generated/android/c++/JHybridNitroCronetSpec.hpp +63 -0
  40. package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.cpp +32 -16
  41. package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.hpp +21 -21
  42. package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.cpp +22 -15
  43. package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.hpp +20 -21
  44. package/nitrogen/generated/android/c++/JHybridUrlRequestBuilderSpec.cpp +123 -0
  45. package/nitrogen/generated/android/c++/JHybridUrlRequestBuilderSpec.hpp +73 -0
  46. package/nitrogen/generated/android/c++/JHybridUrlRequestSpec.cpp +69 -0
  47. package/nitrogen/generated/android/c++/JHybridUrlRequestSpec.hpp +67 -0
  48. package/nitrogen/generated/android/c++/JNitroFormDataPart.hpp +74 -0
  49. package/nitrogen/generated/android/c++/JNitroHeader.hpp +7 -3
  50. package/nitrogen/generated/android/c++/JNitroRequest.hpp +39 -6
  51. package/nitrogen/generated/android/c++/JNitroRequestMethod.hpp +9 -10
  52. package/nitrogen/generated/android/c++/JNitroResponse.hpp +9 -4
  53. package/nitrogen/generated/android/c++/JRequestException.hpp +57 -0
  54. package/nitrogen/generated/android/c++/JUrlResponseInfo.hpp +146 -0
  55. package/nitrogen/generated/android/c++/JVariant_ArrayBuffer_String.cpp +26 -0
  56. package/nitrogen/generated/android/c++/JVariant_ArrayBuffer_String.hpp +70 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Func_void_UrlResponseInfo.kt +80 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Func_void_UrlResponseInfo_std__shared_ptr_ArrayBuffer__double.kt +80 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Func_void_UrlResponseInfo_std__string.kt +80 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Func_void_std__optional_UrlResponseInfo_.kt +80 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Func_void_std__optional_UrlResponseInfo__RequestException.kt +80 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HttpHeader.kt +41 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNativeStorageSpec.kt +18 -16
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroCronetSpec.kt +54 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchClientSpec.kt +23 -16
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchSpec.kt +18 -16
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridUrlRequestBuilderSpec.kt +125 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridUrlRequestSpec.kt +70 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroFormDataPart.kt +50 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroHeader.kt +19 -10
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequest.kt +40 -25
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequestMethod.kt +3 -1
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroResponse.kt +39 -30
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/RequestException.kt +38 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/UrlResponseInfo.kt +65 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/Variant_ArrayBuffer_String.kt +53 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/nitrofetchOnLoad.kt +1 -1
  78. package/nitrogen/generated/android/nitrofetch+autolinking.cmake +8 -1
  79. package/nitrogen/generated/android/nitrofetch+autolinking.gradle +1 -1
  80. package/nitrogen/generated/android/nitrofetchOnLoad.cpp +85 -33
  81. package/nitrogen/generated/android/nitrofetchOnLoad.hpp +14 -5
  82. package/nitrogen/generated/ios/NitroFetch+autolinking.rb +2 -2
  83. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.cpp +102 -10
  84. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.hpp +359 -24
  85. package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Umbrella.hpp +32 -1
  86. package/nitrogen/generated/ios/NitroFetchAutolinking.mm +9 -1
  87. package/nitrogen/generated/ios/NitroFetchAutolinking.swift +29 -22
  88. package/nitrogen/generated/ios/c++/HybridNativeStorageSpecSwift.cpp +1 -1
  89. package/nitrogen/generated/ios/c++/HybridNativeStorageSpecSwift.hpp +10 -1
  90. package/nitrogen/generated/ios/c++/HybridNitroCronetSpecSwift.cpp +11 -0
  91. package/nitrogen/generated/ios/c++/HybridNitroCronetSpecSwift.hpp +85 -0
  92. package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.cpp +1 -1
  93. package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.hpp +22 -4
  94. package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.cpp +1 -1
  95. package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.hpp +10 -1
  96. package/nitrogen/generated/ios/c++/HybridUrlRequestBuilderSpecSwift.cpp +11 -0
  97. package/nitrogen/generated/ios/c++/HybridUrlRequestBuilderSpecSwift.hpp +163 -0
  98. package/nitrogen/generated/ios/c++/HybridUrlRequestSpecSwift.cpp +11 -0
  99. package/nitrogen/generated/ios/c++/HybridUrlRequestSpecSwift.hpp +106 -0
  100. package/nitrogen/generated/ios/swift/Func_void.swift +1 -2
  101. package/nitrogen/generated/ios/swift/Func_void_NitroResponse.swift +1 -2
  102. package/nitrogen/generated/ios/swift/Func_void_UrlResponseInfo.swift +46 -0
  103. package/nitrogen/generated/ios/swift/Func_void_UrlResponseInfo_std__shared_ptr_ArrayBuffer__double.swift +46 -0
  104. package/nitrogen/generated/ios/swift/Func_void_UrlResponseInfo_std__string.swift +46 -0
  105. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -2
  106. package/nitrogen/generated/ios/swift/Func_void_std__optional_UrlResponseInfo_.swift +46 -0
  107. package/nitrogen/generated/ios/swift/Func_void_std__optional_UrlResponseInfo__RequestException.swift +46 -0
  108. package/nitrogen/generated/ios/swift/HttpHeader.swift +34 -0
  109. package/nitrogen/generated/ios/swift/HybridNativeStorageSpec.swift +10 -4
  110. package/nitrogen/generated/ios/swift/HybridNativeStorageSpec_cxx.swift +18 -3
  111. package/nitrogen/generated/ios/swift/HybridNitroCronetSpec.swift +55 -0
  112. package/nitrogen/generated/ios/swift/HybridNitroCronetSpec_cxx.swift +141 -0
  113. package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec.swift +11 -4
  114. package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec_cxx.swift +29 -3
  115. package/nitrogen/generated/ios/swift/HybridNitroFetchSpec.swift +10 -4
  116. package/nitrogen/generated/ios/swift/HybridNitroFetchSpec_cxx.swift +18 -3
  117. package/nitrogen/generated/ios/swift/HybridUrlRequestBuilderSpec.swift +65 -0
  118. package/nitrogen/generated/ios/swift/HybridUrlRequestBuilderSpec_cxx.swift +305 -0
  119. package/nitrogen/generated/ios/swift/HybridUrlRequestSpec.swift +59 -0
  120. package/nitrogen/generated/ios/swift/HybridUrlRequestSpec_cxx.swift +182 -0
  121. package/nitrogen/generated/ios/swift/NitroFormDataPart.swift +101 -0
  122. package/nitrogen/generated/ios/swift/NitroHeader.swift +5 -17
  123. package/nitrogen/generated/ios/swift/NitroRequest.swift +111 -121
  124. package/nitrogen/generated/ios/swift/NitroRequestMethod.swift +1 -1
  125. package/nitrogen/generated/ios/swift/NitroResponse.swift +40 -97
  126. package/nitrogen/generated/ios/swift/RequestException.swift +29 -0
  127. package/nitrogen/generated/ios/swift/UrlResponseInfo.swift +118 -0
  128. package/nitrogen/generated/ios/swift/Variant_ArrayBuffer_String.swift +18 -0
  129. package/nitrogen/generated/shared/c++/HttpHeader.hpp +87 -0
  130. package/nitrogen/generated/shared/c++/HybridNativeStorageSpec.cpp +1 -1
  131. package/nitrogen/generated/shared/c++/HybridNativeStorageSpec.hpp +1 -1
  132. package/nitrogen/generated/shared/c++/HybridNitroCronetSpec.cpp +21 -0
  133. package/nitrogen/generated/shared/c++/HybridNitroCronetSpec.hpp +65 -0
  134. package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.cpp +2 -1
  135. package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.hpp +3 -1
  136. package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.cpp +1 -1
  137. package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.hpp +1 -1
  138. package/nitrogen/generated/shared/c++/HybridUrlRequestBuilderSpec.cpp +31 -0
  139. package/nitrogen/generated/shared/c++/HybridUrlRequestBuilderSpec.hpp +85 -0
  140. package/nitrogen/generated/shared/c++/HybridUrlRequestSpec.cpp +25 -0
  141. package/nitrogen/generated/shared/c++/HybridUrlRequestSpec.hpp +66 -0
  142. package/nitrogen/generated/shared/c++/NitroFormDataPart.hpp +100 -0
  143. package/nitrogen/generated/shared/c++/NitroHeader.hpp +24 -8
  144. package/nitrogen/generated/shared/c++/NitroRequest.hpp +51 -24
  145. package/nitrogen/generated/shared/c++/NitroRequestMethod.hpp +1 -1
  146. package/nitrogen/generated/shared/c++/NitroResponse.hpp +42 -26
  147. package/nitrogen/generated/shared/c++/RequestException.hpp +83 -0
  148. package/nitrogen/generated/shared/c++/UrlResponseInfo.hpp +123 -0
  149. package/package.json +10 -10
  150. package/src/NitroCronet.nitro.ts +72 -0
  151. package/src/NitroFetch.nitro.ts +28 -6
  152. package/src/NitroInstances.ts +4 -0
  153. package/src/fetch.ts +214 -13
  154. package/src/index.tsx +1 -1
@@ -0,0 +1,85 @@
1
+ ///
2
+ /// HybridUrlRequestBuilderSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `UrlResponseInfo` to properly resolve imports.
17
+ namespace margelo::nitro::nitrofetch { struct UrlResponseInfo; }
18
+ // Forward declaration of `RequestException` to properly resolve imports.
19
+ namespace margelo::nitro::nitrofetch { struct RequestException; }
20
+ // Forward declaration of `HybridUrlRequestSpec` to properly resolve imports.
21
+ namespace margelo::nitro::nitrofetch { class HybridUrlRequestSpec; }
22
+
23
+ #include <string>
24
+ #include <NitroModules/ArrayBuffer.hpp>
25
+ #include <variant>
26
+ #include "UrlResponseInfo.hpp"
27
+ #include <functional>
28
+ #include <optional>
29
+ #include "RequestException.hpp"
30
+ #include <memory>
31
+ #include "HybridUrlRequestSpec.hpp"
32
+
33
+ namespace margelo::nitro::nitrofetch {
34
+
35
+ using namespace margelo::nitro;
36
+
37
+ /**
38
+ * An abstract base class for `UrlRequestBuilder`
39
+ * Inherit this class to create instances of `HybridUrlRequestBuilderSpec` in C++.
40
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
41
+ * @example
42
+ * ```cpp
43
+ * class HybridUrlRequestBuilder: public HybridUrlRequestBuilderSpec {
44
+ * public:
45
+ * HybridUrlRequestBuilder(...): HybridObject(TAG) { ... }
46
+ * // ...
47
+ * };
48
+ * ```
49
+ */
50
+ class HybridUrlRequestBuilderSpec: public virtual HybridObject {
51
+ public:
52
+ // Constructor
53
+ explicit HybridUrlRequestBuilderSpec(): HybridObject(TAG) { }
54
+
55
+ // Destructor
56
+ ~HybridUrlRequestBuilderSpec() override = default;
57
+
58
+ public:
59
+ // Properties
60
+
61
+
62
+ public:
63
+ // Methods
64
+ virtual void setHttpMethod(const std::string& httpMethod) = 0;
65
+ virtual void addHeader(const std::string& name, const std::string& value) = 0;
66
+ virtual void setUploadBody(const std::variant<std::shared_ptr<ArrayBuffer>, std::string>& body) = 0;
67
+ virtual void disableCache() = 0;
68
+ virtual void onSucceeded(const std::function<void(const UrlResponseInfo& /* info */)>& callback) = 0;
69
+ virtual void onFailed(const std::function<void(const std::optional<UrlResponseInfo>& /* info */, const RequestException& /* error */)>& callback) = 0;
70
+ virtual void onCanceled(const std::function<void(const std::optional<UrlResponseInfo>& /* info */)>& callback) = 0;
71
+ virtual void onRedirectReceived(const std::function<void(const UrlResponseInfo& /* info */, const std::string& /* newLocationUrl */)>& callback) = 0;
72
+ virtual void onResponseStarted(const std::function<void(const UrlResponseInfo& /* info */)>& callback) = 0;
73
+ virtual void onReadCompleted(const std::function<void(const UrlResponseInfo& /* info */, const std::shared_ptr<ArrayBuffer>& /* byteBuffer */, double /* bytesRead */)>& callback) = 0;
74
+ virtual std::shared_ptr<HybridUrlRequestSpec> build() = 0;
75
+
76
+ protected:
77
+ // Hybrid Setup
78
+ void loadHybridMethods() override;
79
+
80
+ protected:
81
+ // Tag for logging
82
+ static constexpr auto TAG = "UrlRequestBuilder";
83
+ };
84
+
85
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// HybridUrlRequestSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridUrlRequestSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitrofetch {
11
+
12
+ void HybridUrlRequestSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("start", &HybridUrlRequestSpec::start);
18
+ prototype.registerHybridMethod("followRedirect", &HybridUrlRequestSpec::followRedirect);
19
+ prototype.registerHybridMethod("read", &HybridUrlRequestSpec::read);
20
+ prototype.registerHybridMethod("cancel", &HybridUrlRequestSpec::cancel);
21
+ prototype.registerHybridMethod("isDone", &HybridUrlRequestSpec::isDone);
22
+ });
23
+ }
24
+
25
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// HybridUrlRequestSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+
19
+
20
+ namespace margelo::nitro::nitrofetch {
21
+
22
+ using namespace margelo::nitro;
23
+
24
+ /**
25
+ * An abstract base class for `UrlRequest`
26
+ * Inherit this class to create instances of `HybridUrlRequestSpec` in C++.
27
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
28
+ * @example
29
+ * ```cpp
30
+ * class HybridUrlRequest: public HybridUrlRequestSpec {
31
+ * public:
32
+ * HybridUrlRequest(...): HybridObject(TAG) { ... }
33
+ * // ...
34
+ * };
35
+ * ```
36
+ */
37
+ class HybridUrlRequestSpec: public virtual HybridObject {
38
+ public:
39
+ // Constructor
40
+ explicit HybridUrlRequestSpec(): HybridObject(TAG) { }
41
+
42
+ // Destructor
43
+ ~HybridUrlRequestSpec() override = default;
44
+
45
+ public:
46
+ // Properties
47
+
48
+
49
+ public:
50
+ // Methods
51
+ virtual void start() = 0;
52
+ virtual void followRedirect() = 0;
53
+ virtual void read() = 0;
54
+ virtual void cancel() = 0;
55
+ virtual bool isDone() = 0;
56
+
57
+ protected:
58
+ // Hybrid Setup
59
+ void loadHybridMethods() override;
60
+
61
+ protected:
62
+ // Tag for logging
63
+ static constexpr auto TAG = "UrlRequest";
64
+ };
65
+
66
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,100 @@
1
+ ///
2
+ /// NitroFormDataPart.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::nitrofetch {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (NitroFormDataPart).
40
+ */
41
+ struct NitroFormDataPart final {
42
+ public:
43
+ std::string name SWIFT_PRIVATE;
44
+ std::optional<std::string> value SWIFT_PRIVATE;
45
+ std::optional<std::string> fileUri SWIFT_PRIVATE;
46
+ std::optional<std::string> fileName SWIFT_PRIVATE;
47
+ std::optional<std::string> mimeType SWIFT_PRIVATE;
48
+
49
+ public:
50
+ NitroFormDataPart() = default;
51
+ explicit NitroFormDataPart(std::string name, std::optional<std::string> value, std::optional<std::string> fileUri, std::optional<std::string> fileName, std::optional<std::string> mimeType): name(name), value(value), fileUri(fileUri), fileName(fileName), mimeType(mimeType) {}
52
+
53
+ public:
54
+ friend bool operator==(const NitroFormDataPart& lhs, const NitroFormDataPart& rhs) = default;
55
+ };
56
+
57
+ } // namespace margelo::nitro::nitrofetch
58
+
59
+ namespace margelo::nitro {
60
+
61
+ // C++ NitroFormDataPart <> JS NitroFormDataPart (object)
62
+ template <>
63
+ struct JSIConverter<margelo::nitro::nitrofetch::NitroFormDataPart> final {
64
+ static inline margelo::nitro::nitrofetch::NitroFormDataPart fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
65
+ jsi::Object obj = arg.asObject(runtime);
66
+ return margelo::nitro::nitrofetch::NitroFormDataPart(
67
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
68
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
69
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileUri"))),
70
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName"))),
71
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))
72
+ );
73
+ }
74
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrofetch::NitroFormDataPart& arg) {
75
+ jsi::Object obj(runtime);
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.value));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.fileUri));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.fileName));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mimeType));
81
+ return obj;
82
+ }
83
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
84
+ if (!value.isObject()) {
85
+ return false;
86
+ }
87
+ jsi::Object obj = value.getObject(runtime);
88
+ if (!nitro::isPlainObject(runtime, obj)) {
89
+ return false;
90
+ }
91
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
92
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
93
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileUri")))) return false;
94
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName")))) return false;
95
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false;
96
+ return true;
97
+ }
98
+ };
99
+
100
+ } // namespace margelo::nitro
@@ -2,7 +2,7 @@
2
2
  /// NitroHeader.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -17,6 +17,16 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
20
30
 
21
31
 
22
32
 
@@ -27,7 +37,7 @@ namespace margelo::nitro::nitrofetch {
27
37
  /**
28
38
  * A struct which can be represented as a JavaScript object (NitroHeader).
29
39
  */
30
- struct NitroHeader {
40
+ struct NitroHeader final {
31
41
  public:
32
42
  std::string key SWIFT_PRIVATE;
33
43
  std::string value SWIFT_PRIVATE;
@@ -35,6 +45,9 @@ namespace margelo::nitro::nitrofetch {
35
45
  public:
36
46
  NitroHeader() = default;
37
47
  explicit NitroHeader(std::string key, std::string value): key(key), value(value) {}
48
+
49
+ public:
50
+ friend bool operator==(const NitroHeader& lhs, const NitroHeader& rhs) = default;
38
51
  };
39
52
 
40
53
  } // namespace margelo::nitro::nitrofetch
@@ -47,14 +60,14 @@ namespace margelo::nitro {
47
60
  static inline margelo::nitro::nitrofetch::NitroHeader fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
61
  jsi::Object obj = arg.asObject(runtime);
49
62
  return margelo::nitro::nitrofetch::NitroHeader(
50
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "key")),
51
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "value"))
63
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key"))),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
52
65
  );
53
66
  }
54
67
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrofetch::NitroHeader& arg) {
55
68
  jsi::Object obj(runtime);
56
- obj.setProperty(runtime, "key", JSIConverter<std::string>::toJSI(runtime, arg.key));
57
- obj.setProperty(runtime, "value", JSIConverter<std::string>::toJSI(runtime, arg.value));
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "key"), JSIConverter<std::string>::toJSI(runtime, arg.key));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::string>::toJSI(runtime, arg.value));
58
71
  return obj;
59
72
  }
60
73
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -62,8 +75,11 @@ namespace margelo::nitro {
62
75
  return false;
63
76
  }
64
77
  jsi::Object obj = value.getObject(runtime);
65
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "key"))) return false;
66
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key")))) return false;
82
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
67
83
  return true;
68
84
  }
69
85
  };
@@ -2,7 +2,7 @@
2
2
  /// NitroRequest.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -17,36 +17,54 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
20
30
 
21
31
  // Forward declaration of `NitroRequestMethod` to properly resolve imports.
22
32
  namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
23
33
  // Forward declaration of `NitroHeader` to properly resolve imports.
24
34
  namespace margelo::nitro::nitrofetch { struct NitroHeader; }
35
+ // Forward declaration of `NitroFormDataPart` to properly resolve imports.
36
+ namespace margelo::nitro::nitrofetch { struct NitroFormDataPart; }
25
37
 
26
38
  #include <string>
27
39
  #include "NitroRequestMethod.hpp"
28
40
  #include <optional>
29
41
  #include "NitroHeader.hpp"
30
42
  #include <vector>
43
+ #include "NitroFormDataPart.hpp"
31
44
 
32
45
  namespace margelo::nitro::nitrofetch {
33
46
 
34
47
  /**
35
48
  * A struct which can be represented as a JavaScript object (NitroRequest).
36
49
  */
37
- struct NitroRequest {
50
+ struct NitroRequest final {
38
51
  public:
39
52
  std::string url SWIFT_PRIVATE;
40
53
  std::optional<NitroRequestMethod> method SWIFT_PRIVATE;
41
54
  std::optional<std::vector<NitroHeader>> headers SWIFT_PRIVATE;
42
55
  std::optional<std::string> bodyString SWIFT_PRIVATE;
43
56
  std::optional<std::string> bodyBytes SWIFT_PRIVATE;
57
+ std::optional<std::vector<NitroFormDataPart>> bodyFormData SWIFT_PRIVATE;
44
58
  std::optional<double> timeoutMs SWIFT_PRIVATE;
45
59
  std::optional<bool> followRedirects SWIFT_PRIVATE;
60
+ std::optional<std::string> requestId SWIFT_PRIVATE;
46
61
 
47
62
  public:
48
63
  NitroRequest() = default;
49
- explicit NitroRequest(std::string url, std::optional<NitroRequestMethod> method, std::optional<std::vector<NitroHeader>> headers, std::optional<std::string> bodyString, std::optional<std::string> bodyBytes, std::optional<double> timeoutMs, std::optional<bool> followRedirects): url(url), method(method), headers(headers), bodyString(bodyString), bodyBytes(bodyBytes), timeoutMs(timeoutMs), followRedirects(followRedirects) {}
64
+ explicit NitroRequest(std::string url, std::optional<NitroRequestMethod> method, std::optional<std::vector<NitroHeader>> headers, std::optional<std::string> bodyString, std::optional<std::string> bodyBytes, std::optional<std::vector<NitroFormDataPart>> bodyFormData, std::optional<double> timeoutMs, std::optional<bool> followRedirects, std::optional<std::string> requestId): url(url), method(method), headers(headers), bodyString(bodyString), bodyBytes(bodyBytes), bodyFormData(bodyFormData), timeoutMs(timeoutMs), followRedirects(followRedirects), requestId(requestId) {}
65
+
66
+ public:
67
+ friend bool operator==(const NitroRequest& lhs, const NitroRequest& rhs) = default;
50
68
  };
51
69
 
52
70
  } // namespace margelo::nitro::nitrofetch
@@ -59,24 +77,28 @@ namespace margelo::nitro {
59
77
  static inline margelo::nitro::nitrofetch::NitroRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
60
78
  jsi::Object obj = arg.asObject(runtime);
61
79
  return margelo::nitro::nitrofetch::NitroRequest(
62
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "url")),
63
- JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::fromJSI(runtime, obj.getProperty(runtime, "method")),
64
- JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::fromJSI(runtime, obj.getProperty(runtime, "headers")),
65
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "bodyString")),
66
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "bodyBytes")),
67
- JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "timeoutMs")),
68
- JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "followRedirects"))
80
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url"))),
81
+ JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "method"))),
82
+ JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))),
83
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyString"))),
84
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes"))),
85
+ JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroFormDataPart>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyFormData"))),
86
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeoutMs"))),
87
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "followRedirects"))),
88
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requestId")))
69
89
  );
70
90
  }
71
91
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrofetch::NitroRequest& arg) {
72
92
  jsi::Object obj(runtime);
73
- obj.setProperty(runtime, "url", JSIConverter<std::string>::toJSI(runtime, arg.url));
74
- obj.setProperty(runtime, "method", JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::toJSI(runtime, arg.method));
75
- obj.setProperty(runtime, "headers", JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::toJSI(runtime, arg.headers));
76
- obj.setProperty(runtime, "bodyString", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyString));
77
- obj.setProperty(runtime, "bodyBytes", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyBytes));
78
- obj.setProperty(runtime, "timeoutMs", JSIConverter<std::optional<double>>::toJSI(runtime, arg.timeoutMs));
79
- obj.setProperty(runtime, "followRedirects", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.followRedirects));
93
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "url"), JSIConverter<std::string>::toJSI(runtime, arg.url));
94
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "method"), JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::toJSI(runtime, arg.method));
95
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::toJSI(runtime, arg.headers));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bodyString"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyString));
97
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyBytes));
98
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bodyFormData"), JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroFormDataPart>>>::toJSI(runtime, arg.bodyFormData));
99
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timeoutMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.timeoutMs));
100
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "followRedirects"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.followRedirects));
101
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "requestId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.requestId));
80
102
  return obj;
81
103
  }
82
104
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -84,13 +106,18 @@ namespace margelo::nitro {
84
106
  return false;
85
107
  }
86
108
  jsi::Object obj = value.getObject(runtime);
87
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "url"))) return false;
88
- if (!JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::canConvert(runtime, obj.getProperty(runtime, "method"))) return false;
89
- if (!JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::canConvert(runtime, obj.getProperty(runtime, "headers"))) return false;
90
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "bodyString"))) return false;
91
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "bodyBytes"))) return false;
92
- if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "timeoutMs"))) return false;
93
- if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "followRedirects"))) return false;
109
+ if (!nitro::isPlainObject(runtime, obj)) {
110
+ return false;
111
+ }
112
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url")))) return false;
113
+ if (!JSIConverter<std::optional<margelo::nitro::nitrofetch::NitroRequestMethod>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "method")))) return false;
114
+ if (!JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroHeader>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false;
115
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyString")))) return false;
116
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes")))) return false;
117
+ if (!JSIConverter<std::optional<std::vector<margelo::nitro::nitrofetch::NitroFormDataPart>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyFormData")))) return false;
118
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeoutMs")))) return false;
119
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "followRedirects")))) return false;
120
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requestId")))) return false;
94
121
  return true;
95
122
  }
96
123
  };
@@ -2,7 +2,7 @@
2
2
  /// NitroRequestMethod.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// NitroResponse.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -17,6 +17,16 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
20
30
 
21
31
  // Forward declaration of `NitroHeader` to properly resolve imports.
22
32
  namespace margelo::nitro::nitrofetch { struct NitroHeader; }
@@ -31,7 +41,7 @@ namespace margelo::nitro::nitrofetch {
31
41
  /**
32
42
  * A struct which can be represented as a JavaScript object (NitroResponse).
33
43
  */
34
- struct NitroResponse {
44
+ struct NitroResponse final {
35
45
  public:
36
46
  std::string url SWIFT_PRIVATE;
37
47
  double status SWIFT_PRIVATE;
@@ -45,6 +55,9 @@ namespace margelo::nitro::nitrofetch {
45
55
  public:
46
56
  NitroResponse() = default;
47
57
  explicit NitroResponse(std::string url, double status, std::string statusText, bool ok, bool redirected, std::vector<NitroHeader> headers, std::optional<std::string> bodyString, std::optional<std::string> bodyBytes): url(url), status(status), statusText(statusText), ok(ok), redirected(redirected), headers(headers), bodyString(bodyString), bodyBytes(bodyBytes) {}
58
+
59
+ public:
60
+ friend bool operator==(const NitroResponse& lhs, const NitroResponse& rhs) = default;
48
61
  };
49
62
 
50
63
  } // namespace margelo::nitro::nitrofetch
@@ -57,26 +70,26 @@ namespace margelo::nitro {
57
70
  static inline margelo::nitro::nitrofetch::NitroResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
58
71
  jsi::Object obj = arg.asObject(runtime);
59
72
  return margelo::nitro::nitrofetch::NitroResponse(
60
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "url")),
61
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "status")),
62
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "statusText")),
63
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "ok")),
64
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "redirected")),
65
- JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::fromJSI(runtime, obj.getProperty(runtime, "headers")),
66
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "bodyString")),
67
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "bodyBytes"))
73
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url"))),
74
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "status"))),
75
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "statusText"))),
76
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ok"))),
77
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "redirected"))),
78
+ JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))),
79
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyString"))),
80
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes")))
68
81
  );
69
82
  }
70
83
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrofetch::NitroResponse& arg) {
71
84
  jsi::Object obj(runtime);
72
- obj.setProperty(runtime, "url", JSIConverter<std::string>::toJSI(runtime, arg.url));
73
- obj.setProperty(runtime, "status", JSIConverter<double>::toJSI(runtime, arg.status));
74
- obj.setProperty(runtime, "statusText", JSIConverter<std::string>::toJSI(runtime, arg.statusText));
75
- obj.setProperty(runtime, "ok", JSIConverter<bool>::toJSI(runtime, arg.ok));
76
- obj.setProperty(runtime, "redirected", JSIConverter<bool>::toJSI(runtime, arg.redirected));
77
- obj.setProperty(runtime, "headers", JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::toJSI(runtime, arg.headers));
78
- obj.setProperty(runtime, "bodyString", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyString));
79
- obj.setProperty(runtime, "bodyBytes", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyBytes));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "url"), JSIConverter<std::string>::toJSI(runtime, arg.url));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "status"), JSIConverter<double>::toJSI(runtime, arg.status));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "statusText"), JSIConverter<std::string>::toJSI(runtime, arg.statusText));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ok"), JSIConverter<bool>::toJSI(runtime, arg.ok));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "redirected"), JSIConverter<bool>::toJSI(runtime, arg.redirected));
90
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::toJSI(runtime, arg.headers));
91
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bodyString"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyString));
92
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bodyBytes));
80
93
  return obj;
81
94
  }
82
95
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -84,14 +97,17 @@ namespace margelo::nitro {
84
97
  return false;
85
98
  }
86
99
  jsi::Object obj = value.getObject(runtime);
87
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "url"))) return false;
88
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "status"))) return false;
89
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "statusText"))) return false;
90
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "ok"))) return false;
91
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "redirected"))) return false;
92
- if (!JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::canConvert(runtime, obj.getProperty(runtime, "headers"))) return false;
93
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "bodyString"))) return false;
94
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "bodyBytes"))) return false;
100
+ if (!nitro::isPlainObject(runtime, obj)) {
101
+ return false;
102
+ }
103
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url")))) return false;
104
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "status")))) return false;
105
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "statusText")))) return false;
106
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ok")))) return false;
107
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "redirected")))) return false;
108
+ if (!JSIConverter<std::vector<margelo::nitro::nitrofetch::NitroHeader>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false;
109
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyString")))) return false;
110
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bodyBytes")))) return false;
95
111
  return true;
96
112
  }
97
113
  };