react-native-nitro-cookies 0.0.1

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 (56) hide show
  1. package/NitroCookies.podspec +30 -0
  2. package/android/CMakeLists.txt +24 -0
  3. package/android/build.gradle +128 -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/nitrocookies/NitroCookies.kt +340 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrocookies/NitroCookiesPackage.kt +22 -0
  9. package/ios/NitroCookies.swift +411 -0
  10. package/lib/module/NitroCookies.nitro.js +4 -0
  11. package/lib/module/NitroCookies.nitro.js.map +1 -0
  12. package/lib/module/index.js +264 -0
  13. package/lib/module/index.js.map +1 -0
  14. package/lib/module/package.json +1 -0
  15. package/lib/module/types.js +43 -0
  16. package/lib/module/types.js.map +1 -0
  17. package/lib/typescript/package.json +1 -0
  18. package/lib/typescript/src/NitroCookies.nitro.d.ts +89 -0
  19. package/lib/typescript/src/NitroCookies.nitro.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +229 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -0
  22. package/lib/typescript/src/types.d.ts +86 -0
  23. package/lib/typescript/src/types.d.ts.map +1 -0
  24. package/nitro.json +17 -0
  25. package/nitrogen/generated/android/c++/JCookie.hpp +86 -0
  26. package/nitrogen/generated/android/c++/JHybridNitroCookiesSpec.cpp +224 -0
  27. package/nitrogen/generated/android/c++/JHybridNitroCookiesSpec.hpp +73 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/Cookie.kt +59 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/HybridNitroCookiesSpec.kt +90 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/nitrocookiesOnLoad.kt +35 -0
  31. package/nitrogen/generated/android/nitrocookies+autolinking.cmake +81 -0
  32. package/nitrogen/generated/android/nitrocookies+autolinking.gradle +27 -0
  33. package/nitrogen/generated/android/nitrocookiesOnLoad.cpp +44 -0
  34. package/nitrogen/generated/android/nitrocookiesOnLoad.hpp +25 -0
  35. package/nitrogen/generated/ios/NitroCookies+autolinking.rb +60 -0
  36. package/nitrogen/generated/ios/NitroCookies-Swift-Cxx-Bridge.cpp +64 -0
  37. package/nitrogen/generated/ios/NitroCookies-Swift-Cxx-Bridge.hpp +243 -0
  38. package/nitrogen/generated/ios/NitroCookies-Swift-Cxx-Umbrella.hpp +50 -0
  39. package/nitrogen/generated/ios/NitroCookiesAutolinking.mm +33 -0
  40. package/nitrogen/generated/ios/NitroCookiesAutolinking.swift +25 -0
  41. package/nitrogen/generated/ios/c++/HybridNitroCookiesSpecSwift.cpp +11 -0
  42. package/nitrogen/generated/ios/c++/HybridNitroCookiesSpecSwift.hpp +145 -0
  43. package/nitrogen/generated/ios/swift/Cookie.swift +226 -0
  44. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  45. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  46. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  47. package/nitrogen/generated/ios/swift/Func_void_std__vector_Cookie_.swift +47 -0
  48. package/nitrogen/generated/ios/swift/HybridNitroCookiesSpec.swift +65 -0
  49. package/nitrogen/generated/ios/swift/HybridNitroCookiesSpec_cxx.swift +344 -0
  50. package/nitrogen/generated/shared/c++/Cookie.hpp +104 -0
  51. package/nitrogen/generated/shared/c++/HybridNitroCookiesSpec.cpp +29 -0
  52. package/nitrogen/generated/shared/c++/HybridNitroCookiesSpec.hpp +75 -0
  53. package/package.json +129 -0
  54. package/src/NitroCookies.nitro.ts +99 -0
  55. package/src/index.tsx +283 -0
  56. package/src/types.ts +99 -0
@@ -0,0 +1,226 @@
1
+ ///
2
+ /// Cookie.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 `Cookie`, backed by a C++ struct.
12
+ */
13
+ public typealias Cookie = margelo.nitro.nitrocookies.Cookie
14
+
15
+ public extension Cookie {
16
+ private typealias bridge = margelo.nitro.nitrocookies.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `Cookie`.
20
+ */
21
+ init(name: String, value: String, path: String?, domain: String?, version: String?, expires: String?, secure: Bool?, httpOnly: Bool?) {
22
+ self.init(std.string(name), std.string(value), { () -> bridge.std__optional_std__string_ in
23
+ if let __unwrappedValue = path {
24
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_std__string_ in
29
+ if let __unwrappedValue = domain {
30
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
31
+ } else {
32
+ return .init()
33
+ }
34
+ }(), { () -> bridge.std__optional_std__string_ in
35
+ if let __unwrappedValue = version {
36
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
37
+ } else {
38
+ return .init()
39
+ }
40
+ }(), { () -> bridge.std__optional_std__string_ in
41
+ if let __unwrappedValue = expires {
42
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
43
+ } else {
44
+ return .init()
45
+ }
46
+ }(), { () -> bridge.std__optional_bool_ in
47
+ if let __unwrappedValue = secure {
48
+ return bridge.create_std__optional_bool_(__unwrappedValue)
49
+ } else {
50
+ return .init()
51
+ }
52
+ }(), { () -> bridge.std__optional_bool_ in
53
+ if let __unwrappedValue = httpOnly {
54
+ return bridge.create_std__optional_bool_(__unwrappedValue)
55
+ } else {
56
+ return .init()
57
+ }
58
+ }())
59
+ }
60
+
61
+ var name: String {
62
+ @inline(__always)
63
+ get {
64
+ return String(self.__name)
65
+ }
66
+ @inline(__always)
67
+ set {
68
+ self.__name = std.string(newValue)
69
+ }
70
+ }
71
+
72
+ var value: String {
73
+ @inline(__always)
74
+ get {
75
+ return String(self.__value)
76
+ }
77
+ @inline(__always)
78
+ set {
79
+ self.__value = std.string(newValue)
80
+ }
81
+ }
82
+
83
+ var path: String? {
84
+ @inline(__always)
85
+ get {
86
+ return { () -> String? in
87
+ if bridge.has_value_std__optional_std__string_(self.__path) {
88
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__path)
89
+ return String(__unwrapped)
90
+ } else {
91
+ return nil
92
+ }
93
+ }()
94
+ }
95
+ @inline(__always)
96
+ set {
97
+ self.__path = { () -> bridge.std__optional_std__string_ in
98
+ if let __unwrappedValue = newValue {
99
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
100
+ } else {
101
+ return .init()
102
+ }
103
+ }()
104
+ }
105
+ }
106
+
107
+ var domain: String? {
108
+ @inline(__always)
109
+ get {
110
+ return { () -> String? in
111
+ if bridge.has_value_std__optional_std__string_(self.__domain) {
112
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__domain)
113
+ return String(__unwrapped)
114
+ } else {
115
+ return nil
116
+ }
117
+ }()
118
+ }
119
+ @inline(__always)
120
+ set {
121
+ self.__domain = { () -> bridge.std__optional_std__string_ in
122
+ if let __unwrappedValue = newValue {
123
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
124
+ } else {
125
+ return .init()
126
+ }
127
+ }()
128
+ }
129
+ }
130
+
131
+ var version: String? {
132
+ @inline(__always)
133
+ get {
134
+ return { () -> String? in
135
+ if bridge.has_value_std__optional_std__string_(self.__version) {
136
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__version)
137
+ return String(__unwrapped)
138
+ } else {
139
+ return nil
140
+ }
141
+ }()
142
+ }
143
+ @inline(__always)
144
+ set {
145
+ self.__version = { () -> bridge.std__optional_std__string_ in
146
+ if let __unwrappedValue = newValue {
147
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
148
+ } else {
149
+ return .init()
150
+ }
151
+ }()
152
+ }
153
+ }
154
+
155
+ var expires: String? {
156
+ @inline(__always)
157
+ get {
158
+ return { () -> String? in
159
+ if bridge.has_value_std__optional_std__string_(self.__expires) {
160
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__expires)
161
+ return String(__unwrapped)
162
+ } else {
163
+ return nil
164
+ }
165
+ }()
166
+ }
167
+ @inline(__always)
168
+ set {
169
+ self.__expires = { () -> bridge.std__optional_std__string_ in
170
+ if let __unwrappedValue = newValue {
171
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
172
+ } else {
173
+ return .init()
174
+ }
175
+ }()
176
+ }
177
+ }
178
+
179
+ var secure: Bool? {
180
+ @inline(__always)
181
+ get {
182
+ return { () -> Bool? in
183
+ if bridge.has_value_std__optional_bool_(self.__secure) {
184
+ let __unwrapped = bridge.get_std__optional_bool_(self.__secure)
185
+ return __unwrapped
186
+ } else {
187
+ return nil
188
+ }
189
+ }()
190
+ }
191
+ @inline(__always)
192
+ set {
193
+ self.__secure = { () -> bridge.std__optional_bool_ in
194
+ if let __unwrappedValue = newValue {
195
+ return bridge.create_std__optional_bool_(__unwrappedValue)
196
+ } else {
197
+ return .init()
198
+ }
199
+ }()
200
+ }
201
+ }
202
+
203
+ var httpOnly: Bool? {
204
+ @inline(__always)
205
+ get {
206
+ return { () -> Bool? in
207
+ if bridge.has_value_std__optional_bool_(self.__httpOnly) {
208
+ let __unwrapped = bridge.get_std__optional_bool_(self.__httpOnly)
209
+ return __unwrapped
210
+ } else {
211
+ return nil
212
+ }
213
+ }()
214
+ }
215
+ @inline(__always)
216
+ set {
217
+ self.__httpOnly = { () -> bridge.std__optional_bool_ in
218
+ if let __unwrappedValue = newValue {
219
+ return bridge.create_std__optional_bool_(__unwrappedValue)
220
+ } else {
221
+ return .init()
222
+ }
223
+ }()
224
+ }
225
+ }
226
+ }
@@ -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.nitrocookies.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_bool.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: Bool) -> 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_bool {
16
+ public typealias bridge = margelo.nitro.nitrocookies.bridge.swift
17
+
18
+ private let closure: (_ value: Bool) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: Bool) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: Bool) -> 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_bool`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
45
+ return Unmanaged<Func_void_bool>.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.nitrocookies.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,47 @@
1
+ ///
2
+ /// Func_void_std__vector_Cookie_.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: [Cookie]) -> 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__vector_Cookie_ {
16
+ public typealias bridge = margelo.nitro.nitrocookies.bridge.swift
17
+
18
+ private let closure: (_ value: [Cookie]) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: [Cookie]) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: bridge.std__vector_Cookie_) -> Void {
26
+ self.closure(value.map({ __item in __item }))
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__vector_Cookie_`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_Cookie_>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_Cookie_ {
45
+ return Unmanaged<Func_void_std__vector_Cookie_>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// HybridNitroCookiesSpec.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
+ import NitroModules
11
+
12
+ /// See ``HybridNitroCookiesSpec``
13
+ public protocol HybridNitroCookiesSpec_protocol: HybridObject {
14
+ // Properties
15
+
16
+
17
+ // Methods
18
+ func set(url: String, cookie: Cookie, useWebKit: Bool?) throws -> Promise<Bool>
19
+ func get(url: String, useWebKit: Bool?) throws -> Promise<[Cookie]>
20
+ func clearAll(useWebKit: Bool?) throws -> Promise<Bool>
21
+ func setFromResponse(url: String, value: String) throws -> Promise<Bool>
22
+ func getFromResponse(url: String) throws -> Promise<[Cookie]>
23
+ func getAll(useWebKit: Bool?) throws -> Promise<[Cookie]>
24
+ func clearByName(url: String, name: String, useWebKit: Bool?) throws -> Promise<Bool>
25
+ func flush() throws -> Promise<Void>
26
+ func removeSessionCookies() throws -> Promise<Bool>
27
+ }
28
+
29
+ public extension HybridNitroCookiesSpec_protocol {
30
+ /// Default implementation of ``HybridObject.toString``
31
+ func toString() -> String {
32
+ return "[HybridObject NitroCookies]"
33
+ }
34
+ }
35
+
36
+ /// See ``HybridNitroCookiesSpec``
37
+ open class HybridNitroCookiesSpec_base {
38
+ private weak var cxxWrapper: HybridNitroCookiesSpec_cxx? = nil
39
+ public init() { }
40
+ public func getCxxWrapper() -> HybridNitroCookiesSpec_cxx {
41
+ #if DEBUG
42
+ guard self is HybridNitroCookiesSpec else {
43
+ fatalError("`self` is not a `HybridNitroCookiesSpec`! Did you accidentally inherit from `HybridNitroCookiesSpec_base` instead of `HybridNitroCookiesSpec`?")
44
+ }
45
+ #endif
46
+ if let cxxWrapper = self.cxxWrapper {
47
+ return cxxWrapper
48
+ } else {
49
+ let cxxWrapper = HybridNitroCookiesSpec_cxx(self as! HybridNitroCookiesSpec)
50
+ self.cxxWrapper = cxxWrapper
51
+ return cxxWrapper
52
+ }
53
+ }
54
+ }
55
+
56
+ /**
57
+ * A Swift base-protocol representing the NitroCookies HybridObject.
58
+ * Implement this protocol to create Swift-based instances of NitroCookies.
59
+ * ```swift
60
+ * class HybridNitroCookies : HybridNitroCookiesSpec {
61
+ * // ...
62
+ * }
63
+ * ```
64
+ */
65
+ public typealias HybridNitroCookiesSpec = HybridNitroCookiesSpec_protocol & HybridNitroCookiesSpec_base