react-nitro-navigation 0.0.0-stage → 0.0.1-alpha.7

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/Package.swift +104 -0
  3. package/README.md +20 -2
  4. package/Sources/ReactNitroNavigation/HybridNavigationScreen.swift +27 -0
  5. package/Sources/ReactNitroNavigation/HybridNavigationStack.swift +103 -0
  6. package/Sources/ReactNitroNavigation/NavigationControllerDelegate.swift +11 -0
  7. package/nitrogen/generated/.gitattributes +1 -0
  8. package/nitrogen/generated/apple/ReactNitroNavigation-Swift-Cxx-Bridge.cpp +109 -0
  9. package/nitrogen/generated/apple/ReactNitroNavigationAppleCxx/ReactNitroNavigationAppleCxx.cpp +9 -0
  10. package/nitrogen/generated/apple/ReactNitroNavigationAppleCxx/include/ReactNitroNavigationAppleCxx/ReactNitroNavigationAppleCxx.h +120 -0
  11. package/nitrogen/generated/apple/ReactNitroNavigationAutolinking.cpp +22 -0
  12. package/nitrogen/generated/apple/ReactNitroNavigationAutolinking.mm +24 -0
  13. package/nitrogen/generated/apple/c++/HybridNavigationScreenSpecSwift.cpp +54 -0
  14. package/nitrogen/generated/apple/c++/HybridNavigationScreenSpec_cxx-Swift.cpp +28 -0
  15. package/nitrogen/generated/apple/c++/HybridNavigationStackSpecSwift.cpp +69 -0
  16. package/nitrogen/generated/apple/c++/HybridNavigationStackSpec_cxx-Swift.cpp +28 -0
  17. package/nitrogen/generated/apple/c++/ListenerSubscription-Swift.cpp +37 -0
  18. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/ReactNitroNavigationAutolinking.hpp +13 -0
  19. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/HybridNavigationScreenSpecSwift.hpp +75 -0
  20. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/HybridNavigationScreenSpec_cxx-Swift.hpp +23 -0
  21. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/HybridNavigationStackSpecSwift.hpp +75 -0
  22. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/HybridNavigationStackSpec_cxx-Swift.hpp +23 -0
  23. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/ListenerSubscription-Swift.hpp +23 -0
  24. package/nitrogen/generated/apple/c++/include/ReactNitroNavigation/private/ReactNitroNavigation-Swift-Cxx-Umbrella.hpp +48 -0
  25. package/nitrogen/generated/apple/c++/include/module.modulemap +12 -0
  26. package/nitrogen/generated/apple/swift/Callback_void.swift +60 -0
  27. package/nitrogen/generated/apple/swift/Callback_void_double.swift +60 -0
  28. package/nitrogen/generated/apple/swift/HybridNavigationScreenSpec.swift +68 -0
  29. package/nitrogen/generated/apple/swift/HybridNavigationScreenSpec_cxx.swift +163 -0
  30. package/nitrogen/generated/apple/swift/HybridNavigationStackSpec.swift +69 -0
  31. package/nitrogen/generated/apple/swift/HybridNavigationStackSpec_cxx.swift +177 -0
  32. package/nitrogen/generated/apple/swift/ListenerSubscription.swift +29 -0
  33. package/nitrogen/generated/apple/swift/Promise_void.swift +100 -0
  34. package/nitrogen/generated/hybrid-classes.json +21 -0
  35. package/nitrogen/generated/shared/c++/ReactNitroNavigationCxxModule.cpp +2 -0
  36. package/nitrogen/generated/shared/c++/include/ReactNitroNavigation/ReactNitroNavigationCxxModule.hpp +2 -0
  37. package/nitrogen/generated/shared/javascript/NavigationScreen.cjs +19 -0
  38. package/nitrogen/generated/shared/javascript/NavigationScreen.d.cts +9 -0
  39. package/nitrogen/generated/shared/javascript/NavigationStack.cjs +19 -0
  40. package/nitrogen/generated/shared/javascript/NavigationStack.d.cts +9 -0
  41. package/package.json +33 -4
  42. package/src/NativeScreenHost.ts +18 -0
  43. package/src/NativeStackHost.ts +14 -0
  44. package/src/StackNavigationOptions.ts +7 -0
  45. package/src/StackNavigationProp.ts +8 -0
  46. package/src/StackScreen.tsx +19 -0
  47. package/src/createStackNavigator.tsx +67 -0
  48. package/src/index.ts +4 -0
  49. package/src/specs/NavigationScreen.nitro.ts +17 -0
  50. package/src/specs/NavigationStack.nitro.ts +20 -0
@@ -0,0 +1,163 @@
1
+ ///
2
+ /// HybridNavigationScreenSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+ internal import NitroModules
8
+ internal import CxxStdlib
9
+ internal import ReactNitroNavigationAppleCxx
10
+ public import ReactNitroRenderer
11
+
12
+ /**
13
+ * A class implementation that bridges HybridNavigationScreenSpec over to C++.
14
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
15
+ */
16
+ @_expose(Cxx)
17
+ public final class HybridNavigationScreenSpec_cxx: HybridViewSpec_cxx {
18
+ /**
19
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::navigation::swift_bridge`)
20
+ * from `ReactNitroNavigationAppleCxx/ReactNitroNavigationAppleCxx.h`.
21
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
22
+ */
23
+ public typealias bridge = margelo.nitro.navigation.swift_bridge
24
+
25
+ /**
26
+ * Holds the Swift implementation of `HybridNavigationScreenSpec`.
27
+ */
28
+ private let __implementation: HybridNavigationScreen
29
+
30
+ /**
31
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
32
+ */
33
+ private var __cxxPart: bridge.std__weak_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_ = .init()
34
+
35
+ /**
36
+ * Create a new `HybridNavigationScreenSpec_cxx` that wraps the given `HybridNavigationScreenSpec`.
37
+ */
38
+ public init(_ implementation: any HybridNavigationScreenSpec) {
39
+ guard let implementation = implementation as? HybridNavigationScreen else {
40
+ preconditionFailure("NavigationScreen selects HybridNavigationScreen as its Swift implementation. Every instance must inherit HybridNavigationScreen.")
41
+ }
42
+ self.__implementation = implementation
43
+ super.init(implementation)
44
+ }
45
+
46
+ /**
47
+ * Get the actual `HybridNavigationScreenSpec` instance this class wraps.
48
+ */
49
+ @inline(__always)
50
+ public func getHybridNavigationScreenSpec() -> any HybridNavigationScreenSpec {
51
+ return __implementation
52
+ }
53
+
54
+ /**
55
+ * Casts this instance to a retained unsafe raw pointer.
56
+ * This acquires one additional strong reference on the object!
57
+ */
58
+ public override func toUnsafe() -> UnsafeMutableRawPointer {
59
+ return Unmanaged.passRetained(self).toOpaque()
60
+ }
61
+
62
+ /**
63
+ * Casts an unsafe pointer to a `HybridNavigationScreenSpec_cxx`.
64
+ * The pointer has to be a retained opaque `Unmanaged<HybridNavigationScreenSpec_cxx>`.
65
+ * This removes one strong reference from the object!
66
+ */
67
+ public override class func fromUnsafe(pointer: UnsafeMutableRawPointer) -> HybridNavigationScreenSpec_cxx {
68
+ return Unmanaged<HybridNavigationScreenSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
69
+ }
70
+
71
+ /**
72
+ * Gets (or creates) the C++ part of this Hybrid Object.
73
+ * This handle keeps the original native object alive.
74
+ */
75
+ public func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_ {
76
+ let cached = __cxxPart.lock()
77
+ if cached.use_count() > 0 {
78
+ return cached
79
+ }
80
+ let value = bridge.create_std__shared_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_(self.toUnsafe())
81
+ __cxxPart = bridge.weakify_std__shared_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_(value)
82
+ return value
83
+ }
84
+
85
+ // Keep the base accessor in Swift to avoid exporting the same imported pointer
86
+ // metadata from two modules when the base belongs to an external module.
87
+ @_expose(!Cxx)
88
+ public override func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__renderer__HybridViewSpec_ {
89
+ let own: bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_ = getCxxPart()
90
+ return bridge.upcast_NavigationScreen_to_View(own)
91
+ }
92
+
93
+ // A static borrowing accessor lets C++ pass a const reference without copying it.
94
+ // TODO: Remove this adapter and call the instance method directly once
95
+ // https://github.com/swiftlang/swift/pull/92862 is merged and supported by our Swift toolchain.
96
+ @_spi(NitroCxx)
97
+ public static func getCxxPart(_ value: borrowing HybridNavigationScreenSpec_cxx) -> bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationScreenSpec_ {
98
+ return value.getCxxPart()
99
+ }
100
+
101
+ /**
102
+ * Get the memory size of the Swift class (plus size of any other allocations)
103
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
104
+ */
105
+ @inline(__always)
106
+ public override var memorySize: Int {
107
+ return MemoryHelper.getSizeOf(__implementation) + __implementation.memorySize
108
+ }
109
+
110
+ /**
111
+ * Compares this object with the given [other] object for reference equality.
112
+ */
113
+ @inline(__always)
114
+ public func equals(other: HybridNavigationScreenSpec_cxx) -> Bool {
115
+ return __implementation === other.__implementation
116
+ }
117
+
118
+ /**
119
+ * Call dispose() on the Swift class.
120
+ * This _may_ be called manually from JS.
121
+ */
122
+ @inline(__always)
123
+ public override func dispose() {
124
+ __implementation.dispose()
125
+ }
126
+
127
+ /**
128
+ * Call toString() on the Swift class.
129
+ */
130
+ @inline(__always)
131
+ public override func toString() -> String {
132
+ return __implementation.toString()
133
+ }
134
+
135
+ // Properties
136
+
137
+ public final func getViewController() -> HybridViewControllerSpec_cxx {
138
+ let value = __implementation.viewController
139
+ return value.getCxxWrapper()
140
+ }
141
+
142
+ public final func getTitle() -> String? {
143
+ let value = __implementation.title
144
+ return value
145
+ }
146
+
147
+ public final func setTitle(title: String?) -> Void {
148
+ __implementation.title = title
149
+ }
150
+
151
+ // Methods
152
+
153
+ // Constructor
154
+
155
+ public class func constructor() -> bridge.Result_void_ {
156
+ do {
157
+ let value = try HybridNavigationScreen()
158
+ return bridge.Result_void_.withValue(value.getCxxWrapper().toUnsafe())
159
+ } catch {
160
+ return bridge.Result_void_.withError(error.toCpp())
161
+ }
162
+ }
163
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HybridNavigationStackSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public import NitroModules
9
+ public import ReactNitroRenderer
10
+
11
+ /// See ``HybridNavigationStackSpec``
12
+ public protocol HybridNavigationStackSpec_protocol: HybridNavigationStackSpec_base, HybridObject, HybridViewSpec_protocol {
13
+ // Constructor
14
+ init() throws
15
+
16
+ // Properties
17
+
18
+
19
+ // Methods
20
+ func attachTo(parent: (any HybridViewControllerSpec)) throws -> Void
21
+ func removeFromParent() throws -> Void
22
+ func addOnPopListener(listener: any Callback<(/* count */ Double), Void>) throws -> ListenerSubscription
23
+
24
+ // Static Properties
25
+
26
+
27
+ // Static Methods
28
+
29
+ }
30
+
31
+ public extension HybridNavigationStackSpec_protocol {
32
+ /// Default implementation of ``HybridObject.toString``
33
+ func toString() -> String {
34
+ return "[HybridObject NavigationStack]"
35
+ }
36
+ }
37
+
38
+ /// See ``HybridNavigationStackSpec``
39
+ open class HybridNavigationStackSpec_base: HybridViewSpec_base {
40
+ private weak var cxxWrapper: HybridNavigationStackSpec_cxx? = nil
41
+ public override init() throws {
42
+ try super.init()
43
+ }
44
+ public final override func getCxxWrapper() -> HybridNavigationStackSpec_cxx {
45
+ #if DEBUG
46
+ guard self is any HybridNavigationStackSpec else {
47
+ fatalError("`self` is not a `HybridNavigationStackSpec`! Did you accidentally inherit from `HybridNavigationStackSpec_base` instead of `HybridNavigationStackSpec`?")
48
+ }
49
+ #endif
50
+ if let cxxWrapper = self.cxxWrapper {
51
+ return cxxWrapper
52
+ } else {
53
+ let cxxWrapper = HybridNavigationStackSpec_cxx(self as! any HybridNavigationStackSpec)
54
+ self.cxxWrapper = cxxWrapper
55
+ return cxxWrapper
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * A Swift base-protocol representing the NavigationStack HybridObject.
62
+ * Implement this protocol to create Swift-based instances of NavigationStack.
63
+ * ```swift
64
+ * class HybridNavigationStack : HybridNavigationStackSpec {
65
+ * // ...
66
+ * }
67
+ * ```
68
+ */
69
+ public typealias HybridNavigationStackSpec = HybridNavigationStackSpec_protocol & HybridNavigationStackSpec_base
@@ -0,0 +1,177 @@
1
+ ///
2
+ /// HybridNavigationStackSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+ internal import NitroModules
8
+ internal import CxxStdlib
9
+ internal import ReactNitroNavigationAppleCxx
10
+ public import ReactNitroRenderer
11
+
12
+ /**
13
+ * A class implementation that bridges HybridNavigationStackSpec over to C++.
14
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
15
+ */
16
+ @_expose(Cxx)
17
+ public final class HybridNavigationStackSpec_cxx: HybridViewSpec_cxx {
18
+ /**
19
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::navigation::swift_bridge`)
20
+ * from `ReactNitroNavigationAppleCxx/ReactNitroNavigationAppleCxx.h`.
21
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
22
+ */
23
+ public typealias bridge = margelo.nitro.navigation.swift_bridge
24
+
25
+ /**
26
+ * Holds the Swift implementation of `HybridNavigationStackSpec`.
27
+ */
28
+ private let __implementation: HybridNavigationStack
29
+
30
+ /**
31
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
32
+ */
33
+ private var __cxxPart: bridge.std__weak_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_ = .init()
34
+
35
+ /**
36
+ * Create a new `HybridNavigationStackSpec_cxx` that wraps the given `HybridNavigationStackSpec`.
37
+ */
38
+ public init(_ implementation: any HybridNavigationStackSpec) {
39
+ guard let implementation = implementation as? HybridNavigationStack else {
40
+ preconditionFailure("NavigationStack selects HybridNavigationStack as its Swift implementation. Every instance must inherit HybridNavigationStack.")
41
+ }
42
+ self.__implementation = implementation
43
+ super.init(implementation)
44
+ }
45
+
46
+ /**
47
+ * Get the actual `HybridNavigationStackSpec` instance this class wraps.
48
+ */
49
+ @inline(__always)
50
+ public func getHybridNavigationStackSpec() -> any HybridNavigationStackSpec {
51
+ return __implementation
52
+ }
53
+
54
+ /**
55
+ * Casts this instance to a retained unsafe raw pointer.
56
+ * This acquires one additional strong reference on the object!
57
+ */
58
+ public override func toUnsafe() -> UnsafeMutableRawPointer {
59
+ return Unmanaged.passRetained(self).toOpaque()
60
+ }
61
+
62
+ /**
63
+ * Casts an unsafe pointer to a `HybridNavigationStackSpec_cxx`.
64
+ * The pointer has to be a retained opaque `Unmanaged<HybridNavigationStackSpec_cxx>`.
65
+ * This removes one strong reference from the object!
66
+ */
67
+ public override class func fromUnsafe(pointer: UnsafeMutableRawPointer) -> HybridNavigationStackSpec_cxx {
68
+ return Unmanaged<HybridNavigationStackSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
69
+ }
70
+
71
+ /**
72
+ * Gets (or creates) the C++ part of this Hybrid Object.
73
+ * This handle keeps the original native object alive.
74
+ */
75
+ public func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_ {
76
+ let cached = __cxxPart.lock()
77
+ if cached.use_count() > 0 {
78
+ return cached
79
+ }
80
+ let value = bridge.create_std__shared_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_(self.toUnsafe())
81
+ __cxxPart = bridge.weakify_std__shared_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_(value)
82
+ return value
83
+ }
84
+
85
+ // Keep the base accessor in Swift to avoid exporting the same imported pointer
86
+ // metadata from two modules when the base belongs to an external module.
87
+ @_expose(!Cxx)
88
+ public override func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__renderer__HybridViewSpec_ {
89
+ let own: bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_ = getCxxPart()
90
+ return bridge.upcast_NavigationStack_to_View(own)
91
+ }
92
+
93
+ // A static borrowing accessor lets C++ pass a const reference without copying it.
94
+ // TODO: Remove this adapter and call the instance method directly once
95
+ // https://github.com/swiftlang/swift/pull/92862 is merged and supported by our Swift toolchain.
96
+ @_spi(NitroCxx)
97
+ public static func getCxxPart(_ value: borrowing HybridNavigationStackSpec_cxx) -> bridge.std__shared_ptr_margelo__nitro__navigation__HybridNavigationStackSpec_ {
98
+ return value.getCxxPart()
99
+ }
100
+
101
+ /**
102
+ * Get the memory size of the Swift class (plus size of any other allocations)
103
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
104
+ */
105
+ @inline(__always)
106
+ public override var memorySize: Int {
107
+ return MemoryHelper.getSizeOf(__implementation) + __implementation.memorySize
108
+ }
109
+
110
+ /**
111
+ * Compares this object with the given [other] object for reference equality.
112
+ */
113
+ @inline(__always)
114
+ public func equals(other: HybridNavigationStackSpec_cxx) -> Bool {
115
+ return __implementation === other.__implementation
116
+ }
117
+
118
+ /**
119
+ * Call dispose() on the Swift class.
120
+ * This _may_ be called manually from JS.
121
+ */
122
+ @inline(__always)
123
+ public override func dispose() {
124
+ __implementation.dispose()
125
+ }
126
+
127
+ /**
128
+ * Call toString() on the Swift class.
129
+ */
130
+ @inline(__always)
131
+ public override func toString() -> String {
132
+ return __implementation.toString()
133
+ }
134
+
135
+ // Properties
136
+
137
+ // Methods
138
+
139
+ public final func attachTo(parent: HybridViewControllerSpec_cxx) -> bridge.Result_void {
140
+ do {
141
+ try __implementation.attachTo(parent: parent.getHybridViewControllerSpec())
142
+ return bridge.Result_void.withValue()
143
+ } catch {
144
+ return bridge.Result_void.withError(error.toCpp())
145
+ }
146
+ }
147
+
148
+ public final func removeFromParent() -> bridge.Result_void {
149
+ do {
150
+ try __implementation.removeFromParent()
151
+ return bridge.Result_void.withValue()
152
+ } catch {
153
+ return bridge.Result_void.withError(error.toCpp())
154
+ }
155
+ }
156
+
157
+ public final func addOnPopListener(listener: UnsafeRawPointer, __outResult: UnsafeMutableRawPointer) -> bridge.Result_void {
158
+ do {
159
+ let value = try __implementation.addOnPopListener(listener: listener.load(as: margelo.nitro.navigation.swift_bridge.Callback_void_double.self))
160
+ __outResult.assumingMemoryBound(to: ListenerSubscription.self).initialize(to: value)
161
+ return bridge.Result_void.withValue()
162
+ } catch {
163
+ return bridge.Result_void.withError(error.toCpp())
164
+ }
165
+ }
166
+
167
+ // Constructor
168
+
169
+ public class func constructor() -> bridge.Result_void_ {
170
+ do {
171
+ let value = try HybridNavigationStack()
172
+ return bridge.Result_void_.withValue(value.getCxxWrapper().toUnsafe())
173
+ } catch {
174
+ return bridge.Result_void_.withError(error.toCpp())
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,29 @@
1
+ ///
2
+ /// ListenerSubscription.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public import NitroModules
9
+ internal import ReactNitroNavigationAppleCxx
10
+ internal import CxxStdlib
11
+
12
+ @_expose(Cxx)
13
+ public struct ListenerSubscription: Sendable {
14
+ public let remove: any Callback<(), Void>
15
+
16
+ public init(remove: any Callback<(), Void>) {
17
+ self.remove = remove
18
+ }
19
+
20
+ @_spi(NitroCxx)
21
+ public static func init_cxx(_ remove: UnsafeRawPointer) -> Self {
22
+ return Self(remove: remove.load(as: margelo.nitro.navigation.swift_bridge.Callback_void.self))
23
+ }
24
+
25
+ @_spi(NitroCxx)
26
+ public borrowing func getRemove_cxx(_ __outResult: UnsafeMutableRawPointer) -> Void {
27
+ __outResult.initializeMemory(as: margelo.nitro.navigation.swift_bridge.Callback_void.self, repeating: self.remove.toCpp(), count: 1)
28
+ }
29
+ }
@@ -0,0 +1,100 @@
1
+ ///
2
+ /// Promise_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public import NitroModules
9
+ internal import CxxStdlib
10
+ public import Dispatch
11
+ internal import ReactNitroNavigationAppleCxx
12
+
13
+ public typealias Promise_void = margelo.nitro.navigation.swift_bridge.Promise_void
14
+
15
+ extension Promise_void {
16
+ public typealias T = Void
17
+ private typealias bridge = margelo.nitro.navigation.swift_bridge
18
+
19
+ public func __nitroResolve(result: ()) {
20
+ resolve()
21
+ }
22
+ public func __nitroReject(error: any Error) {
23
+ reject(consuming: error.toCpp())
24
+ }
25
+
26
+ public func __nitroAddOnResolvedListener(_ listener: @escaping @Sendable (()) -> Void) {
27
+ addOnResolvedListener(.init { () -> Void in
28
+ listener(())
29
+ })
30
+ }
31
+ public func __nitroAddOnRejectedListener(_ listener: @escaping @Sendable (any Error) -> Void) {
32
+ addOnRejectedListener(.init { (exceptionPtr: std.exception_ptr) -> Void in
33
+ listener(RuntimeError.from(cppError: exceptionPtr))
34
+ })
35
+ }
36
+ }
37
+
38
+ extension Promise<Void> where Self == Promise_void {
39
+ public static func pending() -> Self {
40
+ return Promise_void.__pending()
41
+ }
42
+
43
+ public static func resolved() -> Self {
44
+ let promise = Promise_void.pending()
45
+ promise.resolve(result: ())
46
+ return promise
47
+ }
48
+ public static func rejected(with error: any Error) -> Self {
49
+ let promise = Promise_void.pending()
50
+ promise.reject(error: error)
51
+ return promise
52
+ }
53
+
54
+ public static func `async`(
55
+ _ priority: TaskPriority? = nil,
56
+ _ run: sending @escaping @isolated(any) () async throws -> sending Void
57
+ ) -> Self {
58
+ let promise = Promise_void.pending()
59
+ Task(priority: priority) { () async -> Void in
60
+ do {
61
+ promise.resolve(result: try await run())
62
+ } catch {
63
+ promise.reject(error: error)
64
+ }
65
+ }
66
+ return promise
67
+ }
68
+
69
+ public static func parallel(
70
+ _ queue: DispatchQueue = .global(),
71
+ _ run: @escaping @Sendable () throws -> Void
72
+ ) -> Self {
73
+ let promise = Promise_void.pending()
74
+ queue.async { () -> Void in
75
+ do {
76
+ promise.resolve(result: try run())
77
+ } catch {
78
+ promise.reject(error: error)
79
+ }
80
+ }
81
+ return promise
82
+ }
83
+ }
84
+
85
+ extension Promise<Void> {
86
+ func toCpp() -> Promise_void {
87
+ if let self = self as? Promise_void {
88
+ return self
89
+ } else {
90
+ let promise = Promise_void.pending()
91
+ self.addOnResolvedListener { (result: Void) -> Void in
92
+ promise.resolve(result: result)
93
+ }
94
+ self.addOnRejectedListener { (error: any Error) -> Void in
95
+ promise.reject(error: error)
96
+ }
97
+ return promise
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "version": 2,
3
+ "classes": {
4
+ "NavigationScreen": {
5
+ "apple": {
6
+ "implementation": {
7
+ "className": "HybridNavigationScreen"
8
+ },
9
+ "language": "swift"
10
+ }
11
+ },
12
+ "NavigationStack": {
13
+ "apple": {
14
+ "implementation": {
15
+ "className": "HybridNavigationStack"
16
+ },
17
+ "language": "swift"
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,2 @@
1
+ // Generated by nitrogen. Keeps the SwiftPM C++ module available to its Swift bridge.
2
+ #include <ReactNitroNavigation/ReactNitroNavigationCxxModule.hpp>
@@ -0,0 +1,2 @@
1
+ // Generated by nitrogen. Keeps the SwiftPM C++ module available to its Swift bridge.
2
+ #pragma once
@@ -0,0 +1,19 @@
1
+ ///
2
+ /// NavigationScreen.cjs
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ const { NitroModules } = require('nitro-core')
9
+
10
+ let hybridClass
11
+
12
+ module.exports = {
13
+ get NavigationScreen() {
14
+ if (hybridClass === undefined) {
15
+ hybridClass = NitroModules.getHybridClass('navigation.NavigationScreen')
16
+ }
17
+ return hybridClass
18
+ },
19
+ }
@@ -0,0 +1,9 @@
1
+ ///
2
+ /// NavigationScreen.d.cts
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ // The spec's `export declare class NavigationScreen` types this runtime export.
9
+ export {}
@@ -0,0 +1,19 @@
1
+ ///
2
+ /// NavigationStack.cjs
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ const { NitroModules } = require('nitro-core')
9
+
10
+ let hybridClass
11
+
12
+ module.exports = {
13
+ get NavigationStack() {
14
+ if (hybridClass === undefined) {
15
+ hybridClass = NitroModules.getHybridClass('navigation.NavigationStack')
16
+ }
17
+ return hybridClass
18
+ },
19
+ }
@@ -0,0 +1,9 @@
1
+ ///
2
+ /// NavigationStack.d.cts
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/margelo/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ // The spec's `export declare class NavigationStack` types this runtime export.
9
+ export {}
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "react-nitro-navigation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-alpha.7",
4
+ "dependencies": {
5
+ "@react-navigation/core": "7.24.0",
6
+ "@react-navigation/routers": "7.6.5",
7
+ "nitro-core": "1.0.0-alpha.nightly.105.g69d365fc9b18",
8
+ "react": "19.3.0",
9
+ "react-nitro-renderer": "0.0.1-alpha.7"
10
+ },
11
+ "publishConfig": {
12
+ "tag": "latest",
13
+ "access": "public"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": "./src/index.ts",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "imports": {
21
+ "#nitro/*": "./nitrogen/generated/shared/javascript/*.cjs"
22
+ },
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/margelo/react-nitro.git",
27
+ "directory": "packages/react-nitro-navigation"
28
+ },
29
+ "files": [
30
+ "src",
31
+ "Package.swift",
32
+ "Sources",
33
+ "nitrogen/generated"
34
+ ]
35
+ }
@@ -0,0 +1,18 @@
1
+ import { registerView, viewPropsSetters, type ViewProps } from 'react-nitro-renderer'
2
+ import type { NavigationScreen } from './specs/NavigationScreen.nitro'
3
+
4
+ interface NativeScreenHostProps extends ViewProps {
5
+ screen: NavigationScreen
6
+ title: string
7
+ }
8
+
9
+ declare module 'react-nitro-renderer' {
10
+ interface ViewDefinitionMap {
11
+ NavigationScreen: { view: NavigationScreen; props: NativeScreenHostProps }
12
+ }
13
+ }
14
+
15
+ export const NativeScreenHost = registerView('NavigationScreen', (props) => props.screen, {
16
+ ...viewPropsSetters,
17
+ title: (screen, title) => { screen.title = title },
18
+ })