@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,145 @@
1
+ ///
2
+ /// HybridNativeStorageSpec_cxx.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
+ /**
12
+ * A class implementation that bridges HybridNativeStorageSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridNativeStorageSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrofetch::bridge::swift`)
23
+ * from `NitroFetch-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridNativeStorageSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridNativeStorageSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridNativeStorageSpec_
37
+
38
+ /**
39
+ * Create a new `HybridNativeStorageSpec_cxx` that wraps the given `HybridNativeStorageSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridNativeStorageSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridNativeStorageSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridNativeStorageSpec() -> any HybridNativeStorageSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridNativeStorageSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridNativeStorageSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNativeStorageSpec_cxx {
70
+ return Unmanaged<HybridNativeStorageSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridNativeStorageSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNativeStorageSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNativeStorageSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNativeStorageSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+
110
+
111
+ // Methods
112
+ @inline(__always)
113
+ public final func getString(key: std.string) -> bridge.Result_std__string_ {
114
+ do {
115
+ let __result = try self.__implementation.getString(key: String(key))
116
+ let __resultCpp = std.string(__result)
117
+ return bridge.create_Result_std__string_(__resultCpp)
118
+ } catch (let __error) {
119
+ let __exceptionPtr = __error.toCpp()
120
+ return bridge.create_Result_std__string_(__exceptionPtr)
121
+ }
122
+ }
123
+
124
+ @inline(__always)
125
+ public final func setString(key: std.string, value: std.string) -> bridge.Result_void_ {
126
+ do {
127
+ try self.__implementation.setString(key: String(key), value: String(value))
128
+ return bridge.create_Result_void_()
129
+ } catch (let __error) {
130
+ let __exceptionPtr = __error.toCpp()
131
+ return bridge.create_Result_void_(__exceptionPtr)
132
+ }
133
+ }
134
+
135
+ @inline(__always)
136
+ public final func removeString(key: std.string) -> bridge.Result_void_ {
137
+ do {
138
+ try self.__implementation.removeString(key: String(key))
139
+ return bridge.create_Result_void_()
140
+ } catch (let __error) {
141
+ let __exceptionPtr = __error.toCpp()
142
+ return bridge.create_Result_void_(__exceptionPtr)
143
+ }
144
+ }
145
+ }
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// HybridNitroFetchClientSpec.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 ``HybridNitroFetchClientSpec``
12
+ public protocol HybridNitroFetchClientSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func request(req: NitroRequest) throws -> Promise<NitroResponse>
18
+ func prefetch(req: NitroRequest) throws -> Promise<Void>
19
+ func requestSync(req: NitroRequest) throws -> NitroResponse
20
+ }
21
+
22
+ /// See ``HybridNitroFetchClientSpec``
23
+ open class HybridNitroFetchClientSpec_base {
24
+ private weak var cxxWrapper: HybridNitroFetchClientSpec_cxx? = nil
25
+ public init() { }
26
+ public func getCxxWrapper() -> HybridNitroFetchClientSpec_cxx {
27
+ #if DEBUG
28
+ guard self is HybridNitroFetchClientSpec else {
29
+ fatalError("`self` is not a `HybridNitroFetchClientSpec`! Did you accidentally inherit from `HybridNitroFetchClientSpec_base` instead of `HybridNitroFetchClientSpec`?")
30
+ }
31
+ #endif
32
+ if let cxxWrapper = self.cxxWrapper {
33
+ return cxxWrapper
34
+ } else {
35
+ let cxxWrapper = HybridNitroFetchClientSpec_cxx(self as! HybridNitroFetchClientSpec)
36
+ self.cxxWrapper = cxxWrapper
37
+ return cxxWrapper
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * A Swift base-protocol representing the NitroFetchClient HybridObject.
44
+ * Implement this protocol to create Swift-based instances of NitroFetchClient.
45
+ * ```swift
46
+ * class HybridNitroFetchClient : HybridNitroFetchClientSpec {
47
+ * // ...
48
+ * }
49
+ * ```
50
+ */
51
+ public typealias HybridNitroFetchClientSpec = HybridNitroFetchClientSpec_protocol & HybridNitroFetchClientSpec_base
@@ -0,0 +1,161 @@
1
+ ///
2
+ /// HybridNitroFetchClientSpec_cxx.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
+ /**
12
+ * A class implementation that bridges HybridNitroFetchClientSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridNitroFetchClientSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrofetch::bridge::swift`)
23
+ * from `NitroFetch-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridNitroFetchClientSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridNitroFetchClientSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroFetchClientSpec_
37
+
38
+ /**
39
+ * Create a new `HybridNitroFetchClientSpec_cxx` that wraps the given `HybridNitroFetchClientSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridNitroFetchClientSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridNitroFetchClientSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridNitroFetchClientSpec() -> any HybridNitroFetchClientSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridNitroFetchClientSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroFetchClientSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroFetchClientSpec_cxx {
70
+ return Unmanaged<HybridNitroFetchClientSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridNitroFetchClientSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroFetchClientSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroFetchClientSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+
110
+
111
+ // Methods
112
+ @inline(__always)
113
+ public final func request(req: NitroRequest) -> bridge.Result_std__shared_ptr_Promise_NitroResponse___ {
114
+ do {
115
+ let __result = try self.__implementation.request(req: req)
116
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_NitroResponse__ in
117
+ let __promise = bridge.create_std__shared_ptr_Promise_NitroResponse__()
118
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_NitroResponse__(__promise)
119
+ __result
120
+ .then({ __result in __promiseHolder.resolve(__result) })
121
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
122
+ return __promise
123
+ }()
124
+ return bridge.create_Result_std__shared_ptr_Promise_NitroResponse___(__resultCpp)
125
+ } catch (let __error) {
126
+ let __exceptionPtr = __error.toCpp()
127
+ return bridge.create_Result_std__shared_ptr_Promise_NitroResponse___(__exceptionPtr)
128
+ }
129
+ }
130
+
131
+ @inline(__always)
132
+ public final func prefetch(req: NitroRequest) -> bridge.Result_std__shared_ptr_Promise_void___ {
133
+ do {
134
+ let __result = try self.__implementation.prefetch(req: req)
135
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
136
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
137
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
138
+ __result
139
+ .then({ __result in __promiseHolder.resolve() })
140
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
141
+ return __promise
142
+ }()
143
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
144
+ } catch (let __error) {
145
+ let __exceptionPtr = __error.toCpp()
146
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
147
+ }
148
+ }
149
+
150
+ @inline(__always)
151
+ public final func requestSync(req: NitroRequest) -> bridge.Result_NitroResponse_ {
152
+ do {
153
+ let __result = try self.__implementation.requestSync(req: req)
154
+ let __resultCpp = __result
155
+ return bridge.create_Result_NitroResponse_(__resultCpp)
156
+ } catch (let __error) {
157
+ let __exceptionPtr = __error.toCpp()
158
+ return bridge.create_Result_NitroResponse_(__exceptionPtr)
159
+ }
160
+ }
161
+ }
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// HybridNitroFetchSpec.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 ``HybridNitroFetchSpec``
12
+ public protocol HybridNitroFetchSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func createClient() throws -> (any HybridNitroFetchClientSpec)
18
+ }
19
+
20
+ /// See ``HybridNitroFetchSpec``
21
+ open class HybridNitroFetchSpec_base {
22
+ private weak var cxxWrapper: HybridNitroFetchSpec_cxx? = nil
23
+ public init() { }
24
+ public func getCxxWrapper() -> HybridNitroFetchSpec_cxx {
25
+ #if DEBUG
26
+ guard self is HybridNitroFetchSpec else {
27
+ fatalError("`self` is not a `HybridNitroFetchSpec`! Did you accidentally inherit from `HybridNitroFetchSpec_base` instead of `HybridNitroFetchSpec`?")
28
+ }
29
+ #endif
30
+ if let cxxWrapper = self.cxxWrapper {
31
+ return cxxWrapper
32
+ } else {
33
+ let cxxWrapper = HybridNitroFetchSpec_cxx(self as! HybridNitroFetchSpec)
34
+ self.cxxWrapper = cxxWrapper
35
+ return cxxWrapper
36
+ }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * A Swift base-protocol representing the NitroFetch HybridObject.
42
+ * Implement this protocol to create Swift-based instances of NitroFetch.
43
+ * ```swift
44
+ * class HybridNitroFetch : HybridNitroFetchSpec {
45
+ * // ...
46
+ * }
47
+ * ```
48
+ */
49
+ public typealias HybridNitroFetchSpec = HybridNitroFetchSpec_protocol & HybridNitroFetchSpec_base
@@ -0,0 +1,126 @@
1
+ ///
2
+ /// HybridNitroFetchSpec_cxx.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
+ /**
12
+ * A class implementation that bridges HybridNitroFetchSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridNitroFetchSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrofetch::bridge::swift`)
23
+ * from `NitroFetch-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridNitroFetchSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridNitroFetchSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroFetchSpec_
37
+
38
+ /**
39
+ * Create a new `HybridNitroFetchSpec_cxx` that wraps the given `HybridNitroFetchSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridNitroFetchSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridNitroFetchSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridNitroFetchSpec() -> any HybridNitroFetchSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridNitroFetchSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroFetchSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroFetchSpec_cxx {
70
+ return Unmanaged<HybridNitroFetchSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridNitroFetchSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroFetchSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroFetchSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroFetchSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+
110
+
111
+ // Methods
112
+ @inline(__always)
113
+ public final func createClient() -> bridge.Result_std__shared_ptr_HybridNitroFetchClientSpec__ {
114
+ do {
115
+ let __result = try self.__implementation.createClient()
116
+ let __resultCpp = { () -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ in
117
+ let __cxxWrapped = __result.getCxxWrapper()
118
+ return __cxxWrapped.getCxxPart()
119
+ }()
120
+ return bridge.create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(__resultCpp)
121
+ } catch (let __error) {
122
+ let __exceptionPtr = __error.toCpp()
123
+ return bridge.create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(__exceptionPtr)
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// NitroHeader.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
+ * Represents an instance of `NitroHeader`, backed by a C++ struct.
12
+ */
13
+ public typealias NitroHeader = margelo.nitro.nitrofetch.NitroHeader
14
+
15
+ public extension NitroHeader {
16
+ private typealias bridge = margelo.nitro.nitrofetch.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `NitroHeader`.
20
+ */
21
+ init(key: String, value: String) {
22
+ self.init(std.string(key), std.string(value))
23
+ }
24
+
25
+ var key: String {
26
+ @inline(__always)
27
+ get {
28
+ return String(self.__key)
29
+ }
30
+ @inline(__always)
31
+ set {
32
+ self.__key = std.string(newValue)
33
+ }
34
+ }
35
+
36
+ var value: String {
37
+ @inline(__always)
38
+ get {
39
+ return String(self.__value)
40
+ }
41
+ @inline(__always)
42
+ set {
43
+ self.__value = std.string(newValue)
44
+ }
45
+ }
46
+ }