@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,64 @@
1
+ ///
2
+ /// nitrofetchOnLoad.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_NITROFETCH_WITH_GENERATED_CMAKE_PROJECT
9
+ #error nitrofetchOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "nitrofetchOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridNitroFetchClientSpec.hpp"
19
+ #include "JHybridNitroFetchSpec.hpp"
20
+ #include "JHybridNativeStorageSpec.hpp"
21
+ #include <NitroModules/DefaultConstructableObject.hpp>
22
+
23
+ namespace margelo::nitro::nitrofetch {
24
+
25
+ int initialize(JavaVM* vm) {
26
+ using namespace margelo::nitro;
27
+ using namespace margelo::nitro::nitrofetch;
28
+ using namespace facebook;
29
+
30
+ return facebook::jni::initialize(vm, [] {
31
+ // Register native JNI methods
32
+ margelo::nitro::nitrofetch::JHybridNitroFetchClientSpec::registerNatives();
33
+ margelo::nitro::nitrofetch::JHybridNitroFetchSpec::registerNatives();
34
+ margelo::nitro::nitrofetch::JHybridNativeStorageSpec::registerNatives();
35
+
36
+ // Register Nitro Hybrid Objects
37
+ HybridObjectRegistry::registerHybridObjectConstructor(
38
+ "NitroFetch",
39
+ []() -> std::shared_ptr<HybridObject> {
40
+ static DefaultConstructableObject<JHybridNitroFetchSpec::javaobject> object("com/margelo/nitro/nitrofetch/NitroFetch");
41
+ auto instance = object.create();
42
+ return instance->cthis()->shared();
43
+ }
44
+ );
45
+ HybridObjectRegistry::registerHybridObjectConstructor(
46
+ "NitroFetchClient",
47
+ []() -> std::shared_ptr<HybridObject> {
48
+ static DefaultConstructableObject<JHybridNitroFetchClientSpec::javaobject> object("com/margelo/nitro/nitrofetch/NitroFetchClient");
49
+ auto instance = object.create();
50
+ return instance->cthis()->shared();
51
+ }
52
+ );
53
+ HybridObjectRegistry::registerHybridObjectConstructor(
54
+ "NativeStorage",
55
+ []() -> std::shared_ptr<HybridObject> {
56
+ static DefaultConstructableObject<JHybridNativeStorageSpec::javaobject> object("com/margelo/nitro/nitrofetch/NativeStorage");
57
+ auto instance = object.create();
58
+ return instance->cthis()->shared();
59
+ }
60
+ );
61
+ });
62
+ }
63
+
64
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// nitrofetchOnLoad.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::nitrofetch {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of nitrofetch, 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::nitrofetch::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,60 @@
1
+ #
2
+ # NitroFetch+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/NitroFetch+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 NitroFetch 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/NitroFetch-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,90 @@
1
+ ///
2
+ /// NitroFetch-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 "NitroFetch-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridNativeStorageSpecSwift.hpp"
12
+ #include "HybridNitroFetchClientSpecSwift.hpp"
13
+ #include "HybridNitroFetchSpecSwift.hpp"
14
+ #include "NitroFetch-Swift-Cxx-Umbrella.hpp"
15
+
16
+ namespace margelo::nitro::nitrofetch::bridge::swift {
17
+
18
+ // pragma MARK: std::function<void(const NitroResponse& /* result */)>
19
+ Func_void_NitroResponse create_Func_void_NitroResponse(void* _Nonnull swiftClosureWrapper) noexcept {
20
+ auto swiftClosure = NitroFetch::Func_void_NitroResponse::fromUnsafe(swiftClosureWrapper);
21
+ return [swiftClosure = std::move(swiftClosure)](const NitroResponse& result) mutable -> void {
22
+ swiftClosure.call(result);
23
+ };
24
+ }
25
+
26
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
27
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) noexcept {
28
+ auto swiftClosure = NitroFetch::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
29
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
30
+ swiftClosure.call(error);
31
+ };
32
+ }
33
+
34
+ // pragma MARK: std::function<void()>
35
+ Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) noexcept {
36
+ auto swiftClosure = NitroFetch::Func_void::fromUnsafe(swiftClosureWrapper);
37
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
38
+ swiftClosure.call();
39
+ };
40
+ }
41
+
42
+ // pragma MARK: std::shared_ptr<HybridNitroFetchClientSpec>
43
+ std::shared_ptr<HybridNitroFetchClientSpec> create_std__shared_ptr_HybridNitroFetchClientSpec_(void* _Nonnull swiftUnsafePointer) noexcept {
44
+ NitroFetch::HybridNitroFetchClientSpec_cxx swiftPart = NitroFetch::HybridNitroFetchClientSpec_cxx::fromUnsafe(swiftUnsafePointer);
45
+ return std::make_shared<margelo::nitro::nitrofetch::HybridNitroFetchClientSpecSwift>(swiftPart);
46
+ }
47
+ void* _Nonnull get_std__shared_ptr_HybridNitroFetchClientSpec_(std__shared_ptr_HybridNitroFetchClientSpec_ cppType) noexcept {
48
+ std::shared_ptr<margelo::nitro::nitrofetch::HybridNitroFetchClientSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrofetch::HybridNitroFetchClientSpecSwift>(cppType);
49
+ #ifdef NITRO_DEBUG
50
+ if (swiftWrapper == nullptr) [[unlikely]] {
51
+ throw std::runtime_error("Class \"HybridNitroFetchClientSpec\" is not implemented in Swift!");
52
+ }
53
+ #endif
54
+ NitroFetch::HybridNitroFetchClientSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
55
+ return swiftPart.toUnsafe();
56
+ }
57
+
58
+ // pragma MARK: std::shared_ptr<HybridNitroFetchSpec>
59
+ std::shared_ptr<HybridNitroFetchSpec> create_std__shared_ptr_HybridNitroFetchSpec_(void* _Nonnull swiftUnsafePointer) noexcept {
60
+ NitroFetch::HybridNitroFetchSpec_cxx swiftPart = NitroFetch::HybridNitroFetchSpec_cxx::fromUnsafe(swiftUnsafePointer);
61
+ return std::make_shared<margelo::nitro::nitrofetch::HybridNitroFetchSpecSwift>(swiftPart);
62
+ }
63
+ void* _Nonnull get_std__shared_ptr_HybridNitroFetchSpec_(std__shared_ptr_HybridNitroFetchSpec_ cppType) noexcept {
64
+ std::shared_ptr<margelo::nitro::nitrofetch::HybridNitroFetchSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrofetch::HybridNitroFetchSpecSwift>(cppType);
65
+ #ifdef NITRO_DEBUG
66
+ if (swiftWrapper == nullptr) [[unlikely]] {
67
+ throw std::runtime_error("Class \"HybridNitroFetchSpec\" is not implemented in Swift!");
68
+ }
69
+ #endif
70
+ NitroFetch::HybridNitroFetchSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
71
+ return swiftPart.toUnsafe();
72
+ }
73
+
74
+ // pragma MARK: std::shared_ptr<HybridNativeStorageSpec>
75
+ std::shared_ptr<HybridNativeStorageSpec> create_std__shared_ptr_HybridNativeStorageSpec_(void* _Nonnull swiftUnsafePointer) noexcept {
76
+ NitroFetch::HybridNativeStorageSpec_cxx swiftPart = NitroFetch::HybridNativeStorageSpec_cxx::fromUnsafe(swiftUnsafePointer);
77
+ return std::make_shared<margelo::nitro::nitrofetch::HybridNativeStorageSpecSwift>(swiftPart);
78
+ }
79
+ void* _Nonnull get_std__shared_ptr_HybridNativeStorageSpec_(std__shared_ptr_HybridNativeStorageSpec_ cppType) noexcept {
80
+ std::shared_ptr<margelo::nitro::nitrofetch::HybridNativeStorageSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrofetch::HybridNativeStorageSpecSwift>(cppType);
81
+ #ifdef NITRO_DEBUG
82
+ if (swiftWrapper == nullptr) [[unlikely]] {
83
+ throw std::runtime_error("Class \"HybridNativeStorageSpec\" is not implemented in Swift!");
84
+ }
85
+ #endif
86
+ NitroFetch::HybridNativeStorageSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
87
+ return swiftPart.toUnsafe();
88
+ }
89
+
90
+ } // namespace margelo::nitro::nitrofetch::bridge::swift
@@ -0,0 +1,321 @@
1
+ ///
2
+ /// NitroFetch-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 `HybridNativeStorageSpec` to properly resolve imports.
12
+ namespace margelo::nitro::nitrofetch { class HybridNativeStorageSpec; }
13
+ // Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
14
+ namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
15
+ // Forward declaration of `HybridNitroFetchSpec` to properly resolve imports.
16
+ namespace margelo::nitro::nitrofetch { class HybridNitroFetchSpec; }
17
+ // Forward declaration of `NitroHeader` to properly resolve imports.
18
+ namespace margelo::nitro::nitrofetch { struct NitroHeader; }
19
+ // Forward declaration of `NitroRequestMethod` to properly resolve imports.
20
+ namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
21
+ // Forward declaration of `NitroResponse` to properly resolve imports.
22
+ namespace margelo::nitro::nitrofetch { struct NitroResponse; }
23
+
24
+ // Forward declarations of Swift defined types
25
+ // Forward declaration of `HybridNativeStorageSpec_cxx` to properly resolve imports.
26
+ namespace NitroFetch { class HybridNativeStorageSpec_cxx; }
27
+ // Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
28
+ namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
29
+ // Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
30
+ namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
31
+
32
+ // Include C++ defined types
33
+ #include "HybridNativeStorageSpec.hpp"
34
+ #include "HybridNitroFetchClientSpec.hpp"
35
+ #include "HybridNitroFetchSpec.hpp"
36
+ #include "NitroHeader.hpp"
37
+ #include "NitroRequestMethod.hpp"
38
+ #include "NitroResponse.hpp"
39
+ #include <NitroModules/Promise.hpp>
40
+ #include <NitroModules/PromiseHolder.hpp>
41
+ #include <NitroModules/Result.hpp>
42
+ #include <exception>
43
+ #include <functional>
44
+ #include <memory>
45
+ #include <optional>
46
+ #include <string>
47
+ #include <vector>
48
+
49
+ /**
50
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
51
+ * as well as helper functions to interact with those C++ types from Swift.
52
+ */
53
+ namespace margelo::nitro::nitrofetch::bridge::swift {
54
+
55
+ // pragma MARK: std::vector<NitroHeader>
56
+ /**
57
+ * Specialized version of `std::vector<NitroHeader>`.
58
+ */
59
+ using std__vector_NitroHeader_ = std::vector<NitroHeader>;
60
+ inline std::vector<NitroHeader> create_std__vector_NitroHeader_(size_t size) noexcept {
61
+ std::vector<NitroHeader> vector;
62
+ vector.reserve(size);
63
+ return vector;
64
+ }
65
+
66
+ // pragma MARK: std::optional<std::string>
67
+ /**
68
+ * Specialized version of `std::optional<std::string>`.
69
+ */
70
+ using std__optional_std__string_ = std::optional<std::string>;
71
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
72
+ return std::optional<std::string>(value);
73
+ }
74
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
75
+ return optional.has_value();
76
+ }
77
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
78
+ return *optional;
79
+ }
80
+
81
+ // pragma MARK: std::shared_ptr<Promise<NitroResponse>>
82
+ /**
83
+ * Specialized version of `std::shared_ptr<Promise<NitroResponse>>`.
84
+ */
85
+ using std__shared_ptr_Promise_NitroResponse__ = std::shared_ptr<Promise<NitroResponse>>;
86
+ inline std::shared_ptr<Promise<NitroResponse>> create_std__shared_ptr_Promise_NitroResponse__() noexcept {
87
+ return Promise<NitroResponse>::create();
88
+ }
89
+ inline PromiseHolder<NitroResponse> wrap_std__shared_ptr_Promise_NitroResponse__(std::shared_ptr<Promise<NitroResponse>> promise) noexcept {
90
+ return PromiseHolder<NitroResponse>(std::move(promise));
91
+ }
92
+
93
+ // pragma MARK: std::function<void(const NitroResponse& /* result */)>
94
+ /**
95
+ * Specialized version of `std::function<void(const NitroResponse&)>`.
96
+ */
97
+ using Func_void_NitroResponse = std::function<void(const NitroResponse& /* result */)>;
98
+ /**
99
+ * Wrapper class for a `std::function<void(const NitroResponse& / * result * /)>`, this can be used from Swift.
100
+ */
101
+ class Func_void_NitroResponse_Wrapper final {
102
+ public:
103
+ explicit Func_void_NitroResponse_Wrapper(std::function<void(const NitroResponse& /* result */)>&& func): _function(std::make_unique<std::function<void(const NitroResponse& /* result */)>>(std::move(func))) {}
104
+ inline void call(NitroResponse result) const noexcept {
105
+ _function->operator()(result);
106
+ }
107
+ private:
108
+ std::unique_ptr<std::function<void(const NitroResponse& /* result */)>> _function;
109
+ } SWIFT_NONCOPYABLE;
110
+ Func_void_NitroResponse create_Func_void_NitroResponse(void* _Nonnull swiftClosureWrapper) noexcept;
111
+ inline Func_void_NitroResponse_Wrapper wrap_Func_void_NitroResponse(Func_void_NitroResponse value) noexcept {
112
+ return Func_void_NitroResponse_Wrapper(std::move(value));
113
+ }
114
+
115
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
116
+ /**
117
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
118
+ */
119
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
120
+ /**
121
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
122
+ */
123
+ class Func_void_std__exception_ptr_Wrapper final {
124
+ public:
125
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
126
+ inline void call(std::exception_ptr error) const noexcept {
127
+ _function->operator()(error);
128
+ }
129
+ private:
130
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
131
+ } SWIFT_NONCOPYABLE;
132
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) noexcept;
133
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
134
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
135
+ }
136
+
137
+ // pragma MARK: std::optional<NitroRequestMethod>
138
+ /**
139
+ * Specialized version of `std::optional<NitroRequestMethod>`.
140
+ */
141
+ using std__optional_NitroRequestMethod_ = std::optional<NitroRequestMethod>;
142
+ inline std::optional<NitroRequestMethod> create_std__optional_NitroRequestMethod_(const NitroRequestMethod& value) noexcept {
143
+ return std::optional<NitroRequestMethod>(value);
144
+ }
145
+ inline bool has_value_std__optional_NitroRequestMethod_(const std::optional<NitroRequestMethod>& optional) noexcept {
146
+ return optional.has_value();
147
+ }
148
+ inline NitroRequestMethod get_std__optional_NitroRequestMethod_(const std::optional<NitroRequestMethod>& optional) noexcept {
149
+ return *optional;
150
+ }
151
+
152
+ // pragma MARK: std::optional<std::vector<NitroHeader>>
153
+ /**
154
+ * Specialized version of `std::optional<std::vector<NitroHeader>>`.
155
+ */
156
+ using std__optional_std__vector_NitroHeader__ = std::optional<std::vector<NitroHeader>>;
157
+ inline std::optional<std::vector<NitroHeader>> create_std__optional_std__vector_NitroHeader__(const std::vector<NitroHeader>& value) noexcept {
158
+ return std::optional<std::vector<NitroHeader>>(value);
159
+ }
160
+ inline bool has_value_std__optional_std__vector_NitroHeader__(const std::optional<std::vector<NitroHeader>>& optional) noexcept {
161
+ return optional.has_value();
162
+ }
163
+ inline std::vector<NitroHeader> get_std__optional_std__vector_NitroHeader__(const std::optional<std::vector<NitroHeader>>& optional) noexcept {
164
+ return *optional;
165
+ }
166
+
167
+ // pragma MARK: std::optional<double>
168
+ /**
169
+ * Specialized version of `std::optional<double>`.
170
+ */
171
+ using std__optional_double_ = std::optional<double>;
172
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
173
+ return std::optional<double>(value);
174
+ }
175
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
176
+ return optional.has_value();
177
+ }
178
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
179
+ return *optional;
180
+ }
181
+
182
+ // pragma MARK: std::optional<bool>
183
+ /**
184
+ * Specialized version of `std::optional<bool>`.
185
+ */
186
+ using std__optional_bool_ = std::optional<bool>;
187
+ inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
188
+ return std::optional<bool>(value);
189
+ }
190
+ inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
191
+ return optional.has_value();
192
+ }
193
+ inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
194
+ return *optional;
195
+ }
196
+
197
+ // pragma MARK: std::shared_ptr<Promise<void>>
198
+ /**
199
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
200
+ */
201
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
202
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
203
+ return Promise<void>::create();
204
+ }
205
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
206
+ return PromiseHolder<void>(std::move(promise));
207
+ }
208
+
209
+ // pragma MARK: std::function<void()>
210
+ /**
211
+ * Specialized version of `std::function<void()>`.
212
+ */
213
+ using Func_void = std::function<void()>;
214
+ /**
215
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
216
+ */
217
+ class Func_void_Wrapper final {
218
+ public:
219
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
220
+ inline void call() const noexcept {
221
+ _function->operator()();
222
+ }
223
+ private:
224
+ std::unique_ptr<std::function<void()>> _function;
225
+ } SWIFT_NONCOPYABLE;
226
+ Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) noexcept;
227
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
228
+ return Func_void_Wrapper(std::move(value));
229
+ }
230
+
231
+ // pragma MARK: std::shared_ptr<HybridNitroFetchClientSpec>
232
+ /**
233
+ * Specialized version of `std::shared_ptr<HybridNitroFetchClientSpec>`.
234
+ */
235
+ using std__shared_ptr_HybridNitroFetchClientSpec_ = std::shared_ptr<HybridNitroFetchClientSpec>;
236
+ std::shared_ptr<HybridNitroFetchClientSpec> create_std__shared_ptr_HybridNitroFetchClientSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
237
+ void* _Nonnull get_std__shared_ptr_HybridNitroFetchClientSpec_(std__shared_ptr_HybridNitroFetchClientSpec_ cppType) noexcept;
238
+
239
+ // pragma MARK: std::weak_ptr<HybridNitroFetchClientSpec>
240
+ using std__weak_ptr_HybridNitroFetchClientSpec_ = std::weak_ptr<HybridNitroFetchClientSpec>;
241
+ inline std__weak_ptr_HybridNitroFetchClientSpec_ weakify_std__shared_ptr_HybridNitroFetchClientSpec_(const std::shared_ptr<HybridNitroFetchClientSpec>& strong) noexcept { return strong; }
242
+
243
+ // pragma MARK: Result<std::shared_ptr<Promise<NitroResponse>>>
244
+ using Result_std__shared_ptr_Promise_NitroResponse___ = Result<std::shared_ptr<Promise<NitroResponse>>>;
245
+ inline Result_std__shared_ptr_Promise_NitroResponse___ create_Result_std__shared_ptr_Promise_NitroResponse___(const std::shared_ptr<Promise<NitroResponse>>& value) noexcept {
246
+ return Result<std::shared_ptr<Promise<NitroResponse>>>::withValue(value);
247
+ }
248
+ inline Result_std__shared_ptr_Promise_NitroResponse___ create_Result_std__shared_ptr_Promise_NitroResponse___(const std::exception_ptr& error) noexcept {
249
+ return Result<std::shared_ptr<Promise<NitroResponse>>>::withError(error);
250
+ }
251
+
252
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
253
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
254
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
255
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
256
+ }
257
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
258
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
259
+ }
260
+
261
+ // pragma MARK: Result<NitroResponse>
262
+ using Result_NitroResponse_ = Result<NitroResponse>;
263
+ inline Result_NitroResponse_ create_Result_NitroResponse_(const NitroResponse& value) noexcept {
264
+ return Result<NitroResponse>::withValue(value);
265
+ }
266
+ inline Result_NitroResponse_ create_Result_NitroResponse_(const std::exception_ptr& error) noexcept {
267
+ return Result<NitroResponse>::withError(error);
268
+ }
269
+
270
+ // pragma MARK: std::shared_ptr<HybridNitroFetchSpec>
271
+ /**
272
+ * Specialized version of `std::shared_ptr<HybridNitroFetchSpec>`.
273
+ */
274
+ using std__shared_ptr_HybridNitroFetchSpec_ = std::shared_ptr<HybridNitroFetchSpec>;
275
+ std::shared_ptr<HybridNitroFetchSpec> create_std__shared_ptr_HybridNitroFetchSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
276
+ void* _Nonnull get_std__shared_ptr_HybridNitroFetchSpec_(std__shared_ptr_HybridNitroFetchSpec_ cppType) noexcept;
277
+
278
+ // pragma MARK: std::weak_ptr<HybridNitroFetchSpec>
279
+ using std__weak_ptr_HybridNitroFetchSpec_ = std::weak_ptr<HybridNitroFetchSpec>;
280
+ inline std__weak_ptr_HybridNitroFetchSpec_ weakify_std__shared_ptr_HybridNitroFetchSpec_(const std::shared_ptr<HybridNitroFetchSpec>& strong) noexcept { return strong; }
281
+
282
+ // pragma MARK: Result<std::shared_ptr<HybridNitroFetchClientSpec>>
283
+ using Result_std__shared_ptr_HybridNitroFetchClientSpec__ = Result<std::shared_ptr<HybridNitroFetchClientSpec>>;
284
+ inline Result_std__shared_ptr_HybridNitroFetchClientSpec__ create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(const std::shared_ptr<HybridNitroFetchClientSpec>& value) noexcept {
285
+ return Result<std::shared_ptr<HybridNitroFetchClientSpec>>::withValue(value);
286
+ }
287
+ inline Result_std__shared_ptr_HybridNitroFetchClientSpec__ create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(const std::exception_ptr& error) noexcept {
288
+ return Result<std::shared_ptr<HybridNitroFetchClientSpec>>::withError(error);
289
+ }
290
+
291
+ // pragma MARK: std::shared_ptr<HybridNativeStorageSpec>
292
+ /**
293
+ * Specialized version of `std::shared_ptr<HybridNativeStorageSpec>`.
294
+ */
295
+ using std__shared_ptr_HybridNativeStorageSpec_ = std::shared_ptr<HybridNativeStorageSpec>;
296
+ std::shared_ptr<HybridNativeStorageSpec> create_std__shared_ptr_HybridNativeStorageSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
297
+ void* _Nonnull get_std__shared_ptr_HybridNativeStorageSpec_(std__shared_ptr_HybridNativeStorageSpec_ cppType) noexcept;
298
+
299
+ // pragma MARK: std::weak_ptr<HybridNativeStorageSpec>
300
+ using std__weak_ptr_HybridNativeStorageSpec_ = std::weak_ptr<HybridNativeStorageSpec>;
301
+ inline std__weak_ptr_HybridNativeStorageSpec_ weakify_std__shared_ptr_HybridNativeStorageSpec_(const std::shared_ptr<HybridNativeStorageSpec>& strong) noexcept { return strong; }
302
+
303
+ // pragma MARK: Result<std::string>
304
+ using Result_std__string_ = Result<std::string>;
305
+ inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
306
+ return Result<std::string>::withValue(value);
307
+ }
308
+ inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
309
+ return Result<std::string>::withError(error);
310
+ }
311
+
312
+ // pragma MARK: Result<void>
313
+ using Result_void_ = Result<void>;
314
+ inline Result_void_ create_Result_void_() noexcept {
315
+ return Result<void>::withValue();
316
+ }
317
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
318
+ return Result<void>::withError(error);
319
+ }
320
+
321
+ } // namespace margelo::nitro::nitrofetch::bridge::swift
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// NitroFetch-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 `HybridNativeStorageSpec` to properly resolve imports.
12
+ namespace margelo::nitro::nitrofetch { class HybridNativeStorageSpec; }
13
+ // Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
14
+ namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
15
+ // Forward declaration of `HybridNitroFetchSpec` to properly resolve imports.
16
+ namespace margelo::nitro::nitrofetch { class HybridNitroFetchSpec; }
17
+ // Forward declaration of `NitroHeader` to properly resolve imports.
18
+ namespace margelo::nitro::nitrofetch { struct NitroHeader; }
19
+ // Forward declaration of `NitroRequestMethod` to properly resolve imports.
20
+ namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
21
+ // Forward declaration of `NitroRequest` to properly resolve imports.
22
+ namespace margelo::nitro::nitrofetch { struct NitroRequest; }
23
+ // Forward declaration of `NitroResponse` to properly resolve imports.
24
+ namespace margelo::nitro::nitrofetch { struct NitroResponse; }
25
+
26
+ // Include C++ defined types
27
+ #include "HybridNativeStorageSpec.hpp"
28
+ #include "HybridNitroFetchClientSpec.hpp"
29
+ #include "HybridNitroFetchSpec.hpp"
30
+ #include "NitroHeader.hpp"
31
+ #include "NitroRequest.hpp"
32
+ #include "NitroRequestMethod.hpp"
33
+ #include "NitroResponse.hpp"
34
+ #include <NitroModules/Promise.hpp>
35
+ #include <NitroModules/Result.hpp>
36
+ #include <exception>
37
+ #include <memory>
38
+ #include <optional>
39
+ #include <string>
40
+ #include <vector>
41
+
42
+ // C++ helpers for Swift
43
+ #include "NitroFetch-Swift-Cxx-Bridge.hpp"
44
+
45
+ // Common C++ types used in Swift
46
+ #include <NitroModules/ArrayBufferHolder.hpp>
47
+ #include <NitroModules/AnyMapUtils.hpp>
48
+ #include <NitroModules/RuntimeError.hpp>
49
+ #include <NitroModules/DateToChronoDate.hpp>
50
+
51
+ // Forward declarations of Swift defined types
52
+ // Forward declaration of `HybridNativeStorageSpec_cxx` to properly resolve imports.
53
+ namespace NitroFetch { class HybridNativeStorageSpec_cxx; }
54
+ // Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
55
+ namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
56
+ // Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
57
+ namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
58
+
59
+ // Include Swift defined types
60
+ #if __has_include("NitroFetch-Swift.h")
61
+ // This header is generated by Xcode/Swift on every app build.
62
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroFetch".
63
+ #include "NitroFetch-Swift.h"
64
+ // Same as above, but used when building with frameworks (`use_frameworks`)
65
+ #elif __has_include(<NitroFetch/NitroFetch-Swift.h>)
66
+ #include <NitroFetch/NitroFetch-Swift.h>
67
+ #else
68
+ #error NitroFetch's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroFetch", and try building the app first.
69
+ #endif