@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,49 @@
1
+ ///
2
+ /// NitroFetchAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroFetch-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridNitroFetchSpecSwift.hpp"
14
+ #include "HybridNitroFetchClientSpecSwift.hpp"
15
+ #include "HybridNativeStorageSpecSwift.hpp"
16
+
17
+ @interface NitroFetchAutolinking : NSObject
18
+ @end
19
+
20
+ @implementation NitroFetchAutolinking
21
+
22
+ + (void) load {
23
+ using namespace margelo::nitro;
24
+ using namespace margelo::nitro::nitrofetch;
25
+
26
+ HybridObjectRegistry::registerHybridObjectConstructor(
27
+ "NitroFetch",
28
+ []() -> std::shared_ptr<HybridObject> {
29
+ std::shared_ptr<HybridNitroFetchSpec> hybridObject = NitroFetch::NitroFetchAutolinking::createNitroFetch();
30
+ return hybridObject;
31
+ }
32
+ );
33
+ HybridObjectRegistry::registerHybridObjectConstructor(
34
+ "NitroFetchClient",
35
+ []() -> std::shared_ptr<HybridObject> {
36
+ std::shared_ptr<HybridNitroFetchClientSpec> hybridObject = NitroFetch::NitroFetchAutolinking::createNitroFetchClient();
37
+ return hybridObject;
38
+ }
39
+ );
40
+ HybridObjectRegistry::registerHybridObjectConstructor(
41
+ "NativeStorage",
42
+ []() -> std::shared_ptr<HybridObject> {
43
+ std::shared_ptr<HybridNativeStorageSpec> hybridObject = NitroFetch::NitroFetchAutolinking::createNativeStorage();
44
+ return hybridObject;
45
+ }
46
+ );
47
+ }
48
+
49
+ @end
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// NitroFetchAutolinking.swift
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
+ public final class NitroFetchAutolinking {
9
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridNitroFetchSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridNitroFetchSpec_cxx`)
14
+ *
15
+ * This is generated by Nitrogen and will initialize the class specified
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `NitroFetch`).
17
+ */
18
+ public static func createNitroFetch() -> bridge.std__shared_ptr_HybridNitroFetchSpec_ {
19
+ let hybridObject = NitroFetch()
20
+ return { () -> bridge.std__shared_ptr_HybridNitroFetchSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+
26
+ /**
27
+ * Creates an instance of a Swift class that implements `HybridNitroFetchClientSpec`,
28
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridNitroFetchClientSpec_cxx`)
29
+ *
30
+ * This is generated by Nitrogen and will initialize the class specified
31
+ * in the `"autolinking"` property of `nitro.json` (in this case, `NitroFetchClient`).
32
+ */
33
+ public static func createNitroFetchClient() -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ {
34
+ let hybridObject = NitroFetchClient()
35
+ return { () -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ in
36
+ let __cxxWrapped = hybridObject.getCxxWrapper()
37
+ return __cxxWrapped.getCxxPart()
38
+ }()
39
+ }
40
+
41
+ /**
42
+ * Creates an instance of a Swift class that implements `HybridNativeStorageSpec`,
43
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridNativeStorageSpec_cxx`)
44
+ *
45
+ * This is generated by Nitrogen and will initialize the class specified
46
+ * in the `"autolinking"` property of `nitro.json` (in this case, `NativeStorage`).
47
+ */
48
+ public static func createNativeStorage() -> bridge.std__shared_ptr_HybridNativeStorageSpec_ {
49
+ let hybridObject = NativeStorage()
50
+ return { () -> bridge.std__shared_ptr_HybridNativeStorageSpec_ in
51
+ let __cxxWrapped = hybridObject.getCxxWrapper()
52
+ return __cxxWrapped.getCxxPart()
53
+ }()
54
+ }
55
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridNativeStorageSpecSwift.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 "HybridNativeStorageSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitrofetch {
11
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,85 @@
1
+ ///
2
+ /// HybridNativeStorageSpecSwift.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 "HybridNativeStorageSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNativeStorageSpec_cxx` to properly resolve imports.
13
+ namespace NitroFetch { class HybridNativeStorageSpec_cxx; }
14
+
15
+
16
+
17
+ #include <string>
18
+
19
+ #include "NitroFetch-Swift-Cxx-Umbrella.hpp"
20
+
21
+ namespace margelo::nitro::nitrofetch {
22
+
23
+ /**
24
+ * The C++ part of HybridNativeStorageSpec_cxx.swift.
25
+ *
26
+ * HybridNativeStorageSpecSwift (C++) accesses HybridNativeStorageSpec_cxx (Swift), and might
27
+ * contain some additional bridging code for C++ <> Swift interop.
28
+ *
29
+ * Since this obviously introduces an overhead, I hope at some point in
30
+ * the future, HybridNativeStorageSpec_cxx can directly inherit from the C++ class HybridNativeStorageSpec
31
+ * to simplify the whole structure and memory management.
32
+ */
33
+ class HybridNativeStorageSpecSwift: public virtual HybridNativeStorageSpec {
34
+ public:
35
+ // Constructor from a Swift instance
36
+ explicit HybridNativeStorageSpecSwift(const NitroFetch::HybridNativeStorageSpec_cxx& swiftPart):
37
+ HybridObject(HybridNativeStorageSpec::TAG),
38
+ _swiftPart(swiftPart) { }
39
+
40
+ public:
41
+ // Get the Swift part
42
+ inline NitroFetch::HybridNativeStorageSpec_cxx& getSwiftPart() noexcept {
43
+ return _swiftPart;
44
+ }
45
+
46
+ public:
47
+ inline size_t getExternalMemorySize() noexcept override {
48
+ return _swiftPart.getMemorySize();
49
+ }
50
+ void dispose() noexcept override {
51
+ _swiftPart.dispose();
52
+ }
53
+
54
+ public:
55
+ // Properties
56
+
57
+
58
+ public:
59
+ // Methods
60
+ inline std::string getString(const std::string& key) override {
61
+ auto __result = _swiftPart.getString(key);
62
+ if (__result.hasError()) [[unlikely]] {
63
+ std::rethrow_exception(__result.error());
64
+ }
65
+ auto __value = std::move(__result.value());
66
+ return __value;
67
+ }
68
+ inline void setString(const std::string& key, const std::string& value) override {
69
+ auto __result = _swiftPart.setString(key, value);
70
+ if (__result.hasError()) [[unlikely]] {
71
+ std::rethrow_exception(__result.error());
72
+ }
73
+ }
74
+ inline void removeString(const std::string& key) override {
75
+ auto __result = _swiftPart.removeString(key);
76
+ if (__result.hasError()) [[unlikely]] {
77
+ std::rethrow_exception(__result.error());
78
+ }
79
+ }
80
+
81
+ private:
82
+ NitroFetch::HybridNativeStorageSpec_cxx _swiftPart;
83
+ };
84
+
85
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridNitroFetchClientSpecSwift.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 "HybridNitroFetchClientSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitrofetch {
11
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,103 @@
1
+ ///
2
+ /// HybridNitroFetchClientSpecSwift.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 "HybridNitroFetchClientSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
13
+ namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
14
+
15
+ // Forward declaration of `NitroResponse` to properly resolve imports.
16
+ namespace margelo::nitro::nitrofetch { struct NitroResponse; }
17
+ // Forward declaration of `NitroHeader` to properly resolve imports.
18
+ namespace margelo::nitro::nitrofetch { struct NitroHeader; }
19
+ // Forward declaration of `NitroRequest` to properly resolve imports.
20
+ namespace margelo::nitro::nitrofetch { struct NitroRequest; }
21
+ // Forward declaration of `NitroRequestMethod` to properly resolve imports.
22
+ namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
23
+
24
+ #include "NitroResponse.hpp"
25
+ #include <NitroModules/Promise.hpp>
26
+ #include <string>
27
+ #include "NitroHeader.hpp"
28
+ #include <vector>
29
+ #include <optional>
30
+ #include "NitroRequest.hpp"
31
+ #include "NitroRequestMethod.hpp"
32
+
33
+ #include "NitroFetch-Swift-Cxx-Umbrella.hpp"
34
+
35
+ namespace margelo::nitro::nitrofetch {
36
+
37
+ /**
38
+ * The C++ part of HybridNitroFetchClientSpec_cxx.swift.
39
+ *
40
+ * HybridNitroFetchClientSpecSwift (C++) accesses HybridNitroFetchClientSpec_cxx (Swift), and might
41
+ * contain some additional bridging code for C++ <> Swift interop.
42
+ *
43
+ * Since this obviously introduces an overhead, I hope at some point in
44
+ * the future, HybridNitroFetchClientSpec_cxx can directly inherit from the C++ class HybridNitroFetchClientSpec
45
+ * to simplify the whole structure and memory management.
46
+ */
47
+ class HybridNitroFetchClientSpecSwift: public virtual HybridNitroFetchClientSpec {
48
+ public:
49
+ // Constructor from a Swift instance
50
+ explicit HybridNitroFetchClientSpecSwift(const NitroFetch::HybridNitroFetchClientSpec_cxx& swiftPart):
51
+ HybridObject(HybridNitroFetchClientSpec::TAG),
52
+ _swiftPart(swiftPart) { }
53
+
54
+ public:
55
+ // Get the Swift part
56
+ inline NitroFetch::HybridNitroFetchClientSpec_cxx& getSwiftPart() noexcept {
57
+ return _swiftPart;
58
+ }
59
+
60
+ public:
61
+ inline size_t getExternalMemorySize() noexcept override {
62
+ return _swiftPart.getMemorySize();
63
+ }
64
+ void dispose() noexcept override {
65
+ _swiftPart.dispose();
66
+ }
67
+
68
+ public:
69
+ // Properties
70
+
71
+
72
+ public:
73
+ // Methods
74
+ inline std::shared_ptr<Promise<NitroResponse>> request(const NitroRequest& req) override {
75
+ auto __result = _swiftPart.request(req);
76
+ if (__result.hasError()) [[unlikely]] {
77
+ std::rethrow_exception(__result.error());
78
+ }
79
+ auto __value = std::move(__result.value());
80
+ return __value;
81
+ }
82
+ inline std::shared_ptr<Promise<void>> prefetch(const NitroRequest& req) override {
83
+ auto __result = _swiftPart.prefetch(req);
84
+ if (__result.hasError()) [[unlikely]] {
85
+ std::rethrow_exception(__result.error());
86
+ }
87
+ auto __value = std::move(__result.value());
88
+ return __value;
89
+ }
90
+ inline NitroResponse requestSync(const NitroRequest& req) override {
91
+ auto __result = _swiftPart.requestSync(req);
92
+ if (__result.hasError()) [[unlikely]] {
93
+ std::rethrow_exception(__result.error());
94
+ }
95
+ auto __value = std::move(__result.value());
96
+ return __value;
97
+ }
98
+
99
+ private:
100
+ NitroFetch::HybridNitroFetchClientSpec_cxx _swiftPart;
101
+ };
102
+
103
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridNitroFetchSpecSwift.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 "HybridNitroFetchSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitrofetch {
11
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// HybridNitroFetchSpecSwift.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 "HybridNitroFetchSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
13
+ namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
14
+
15
+ // Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
16
+ namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
17
+
18
+ #include <memory>
19
+ #include "HybridNitroFetchClientSpec.hpp"
20
+
21
+ #include "NitroFetch-Swift-Cxx-Umbrella.hpp"
22
+
23
+ namespace margelo::nitro::nitrofetch {
24
+
25
+ /**
26
+ * The C++ part of HybridNitroFetchSpec_cxx.swift.
27
+ *
28
+ * HybridNitroFetchSpecSwift (C++) accesses HybridNitroFetchSpec_cxx (Swift), and might
29
+ * contain some additional bridging code for C++ <> Swift interop.
30
+ *
31
+ * Since this obviously introduces an overhead, I hope at some point in
32
+ * the future, HybridNitroFetchSpec_cxx can directly inherit from the C++ class HybridNitroFetchSpec
33
+ * to simplify the whole structure and memory management.
34
+ */
35
+ class HybridNitroFetchSpecSwift: public virtual HybridNitroFetchSpec {
36
+ public:
37
+ // Constructor from a Swift instance
38
+ explicit HybridNitroFetchSpecSwift(const NitroFetch::HybridNitroFetchSpec_cxx& swiftPart):
39
+ HybridObject(HybridNitroFetchSpec::TAG),
40
+ _swiftPart(swiftPart) { }
41
+
42
+ public:
43
+ // Get the Swift part
44
+ inline NitroFetch::HybridNitroFetchSpec_cxx& getSwiftPart() noexcept {
45
+ return _swiftPart;
46
+ }
47
+
48
+ public:
49
+ inline size_t getExternalMemorySize() noexcept override {
50
+ return _swiftPart.getMemorySize();
51
+ }
52
+ void dispose() noexcept override {
53
+ _swiftPart.dispose();
54
+ }
55
+
56
+ public:
57
+ // Properties
58
+
59
+
60
+ public:
61
+ // Methods
62
+ inline std::shared_ptr<HybridNitroFetchClientSpec> createClient() override {
63
+ auto __result = _swiftPart.createClient();
64
+ if (__result.hasError()) [[unlikely]] {
65
+ std::rethrow_exception(__result.error());
66
+ }
67
+ auto __value = std::move(__result.value());
68
+ return __value;
69
+ }
70
+
71
+ private:
72
+ NitroFetch::HybridNitroFetchSpec_cxx _swiftPart;
73
+ };
74
+
75
+ } // namespace margelo::nitro::nitrofetch
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `() -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void {
16
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
17
+
18
+ private let closure: () -> Void
19
+
20
+ public init(_ closure: @escaping () -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call() -> Void {
26
+ self.closure()
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
45
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_NitroResponse.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: NitroResponse) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_NitroResponse {
16
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
17
+
18
+ private let closure: (_ value: NitroResponse) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: NitroResponse) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: NitroResponse) -> Void {
26
+ self.closure(value)
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_NitroResponse`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_NitroResponse>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_NitroResponse {
45
+ return Unmanaged<Func_void_NitroResponse>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__exception_ptr {
16
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
17
+
18
+ private let closure: (_ error: Error) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: std.exception_ptr) -> Void {
26
+ self.closure(RuntimeError.from(cppError: error))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
45
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// HybridNativeStorageSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridNativeStorageSpec``
12
+ public protocol HybridNativeStorageSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func getString(key: String) throws -> String
18
+ func setString(key: String, value: String) throws -> Void
19
+ func removeString(key: String) throws -> Void
20
+ }
21
+
22
+ /// See ``HybridNativeStorageSpec``
23
+ open class HybridNativeStorageSpec_base {
24
+ private weak var cxxWrapper: HybridNativeStorageSpec_cxx? = nil
25
+ public init() { }
26
+ public func getCxxWrapper() -> HybridNativeStorageSpec_cxx {
27
+ #if DEBUG
28
+ guard self is HybridNativeStorageSpec else {
29
+ fatalError("`self` is not a `HybridNativeStorageSpec`! Did you accidentally inherit from `HybridNativeStorageSpec_base` instead of `HybridNativeStorageSpec`?")
30
+ }
31
+ #endif
32
+ if let cxxWrapper = self.cxxWrapper {
33
+ return cxxWrapper
34
+ } else {
35
+ let cxxWrapper = HybridNativeStorageSpec_cxx(self as! HybridNativeStorageSpec)
36
+ self.cxxWrapper = cxxWrapper
37
+ return cxxWrapper
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * A Swift base-protocol representing the NativeStorage HybridObject.
44
+ * Implement this protocol to create Swift-based instances of NativeStorage.
45
+ * ```swift
46
+ * class HybridNativeStorage : HybridNativeStorageSpec {
47
+ * // ...
48
+ * }
49
+ * ```
50
+ */
51
+ public typealias HybridNativeStorageSpec = HybridNativeStorageSpec_protocol & HybridNativeStorageSpec_base