react-native-webrtc-nitro 1.1.0 → 1.2.3

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 (100) hide show
  1. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/configuration.hpp +1 -1
  2. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/rtc.h +9 -1
  3. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/rtcpreceivingsession.hpp +26 -1
  4. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/rtp.hpp +1 -1
  5. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/rtppacketizationconfig.hpp +9 -0
  6. package/3rdparty/output/android/libdatachannel/arm64-v8a/include/rtc/version.h +3 -3
  7. package/3rdparty/output/android/libdatachannel/arm64-v8a/lib/libdatachannel.so +0 -0
  8. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/configuration.hpp +1 -1
  9. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/rtc.h +9 -1
  10. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/rtcpreceivingsession.hpp +26 -1
  11. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/rtp.hpp +1 -1
  12. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/rtppacketizationconfig.hpp +9 -0
  13. package/3rdparty/output/android/libdatachannel/armeabi-v7a/include/rtc/version.h +3 -3
  14. package/3rdparty/output/android/libdatachannel/armeabi-v7a/lib/libdatachannel.so +0 -0
  15. package/3rdparty/output/android/libdatachannel/x86/include/rtc/configuration.hpp +1 -1
  16. package/3rdparty/output/android/libdatachannel/x86/include/rtc/rtc.h +9 -1
  17. package/3rdparty/output/android/libdatachannel/x86/include/rtc/rtcpreceivingsession.hpp +26 -1
  18. package/3rdparty/output/android/libdatachannel/x86/include/rtc/rtp.hpp +1 -1
  19. package/3rdparty/output/android/libdatachannel/x86/include/rtc/rtppacketizationconfig.hpp +9 -0
  20. package/3rdparty/output/android/libdatachannel/x86/include/rtc/version.h +3 -3
  21. package/3rdparty/output/android/libdatachannel/x86/lib/libdatachannel.so +0 -0
  22. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/configuration.hpp +1 -1
  23. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/rtc.h +9 -1
  24. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/rtcpreceivingsession.hpp +26 -1
  25. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/rtp.hpp +1 -1
  26. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/rtppacketizationconfig.hpp +9 -0
  27. package/3rdparty/output/android/libdatachannel/x86_64/include/rtc/version.h +3 -3
  28. package/3rdparty/output/android/libdatachannel/x86_64/lib/libdatachannel.so +0 -0
  29. package/3rdparty/output/ios/ffmpeg.xcframework/ios-arm64/libffmpeg.a +0 -0
  30. package/3rdparty/output/ios/ffmpeg.xcframework/ios-arm64_x86_64-simulator/libffmpeg.a +0 -0
  31. package/3rdparty/output/ios/libdatachannel.xcframework/Info.plist +5 -5
  32. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/configuration.hpp +1 -1
  33. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/rtc.h +9 -1
  34. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/rtcpreceivingsession.hpp +26 -1
  35. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/rtp.hpp +1 -1
  36. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/rtppacketizationconfig.hpp +9 -0
  37. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/Headers/rtc/version.h +3 -3
  38. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64/libdatachannel.a +0 -0
  39. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/configuration.hpp +1 -1
  40. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/rtc.h +9 -1
  41. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/rtcpreceivingsession.hpp +26 -1
  42. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/rtp.hpp +1 -1
  43. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/rtppacketizationconfig.hpp +9 -0
  44. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/Headers/rtc/version.h +3 -3
  45. package/3rdparty/output/ios/libdatachannel.xcframework/ios-arm64_x86_64-simulator/libdatachannel.a +0 -0
  46. package/README.md +563 -13
  47. package/android/src/main/java/com/webrtc/HybridCamera.kt +0 -1
  48. package/android/src/main/java/com/webrtc/HybridMicrophone.kt +0 -1
  49. package/android/src/main/java/com/webrtc/HybridPermissions.kt +95 -0
  50. package/cpp/Hybrid/HybridMediaDevices.cpp +23 -19
  51. package/ios/HybridCamera.swift +1 -3
  52. package/ios/HybridMicrophone.swift +1 -3
  53. package/ios/HybridPermissions.swift +63 -0
  54. package/lib/commonjs/index.js +11 -0
  55. package/lib/commonjs/index.js.map +1 -1
  56. package/lib/commonjs/specs/Permissions.nitro.js +9 -0
  57. package/lib/commonjs/specs/Permissions.nitro.js.map +1 -0
  58. package/lib/module/index.js +1 -0
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/specs/Permissions.nitro.js +6 -0
  61. package/lib/module/specs/Permissions.nitro.js.map +1 -0
  62. package/lib/typescript/src/index.d.ts +1 -0
  63. package/lib/typescript/src/index.d.ts.map +1 -1
  64. package/lib/typescript/src/specs/Permissions.nitro.d.ts +17 -0
  65. package/lib/typescript/src/specs/Permissions.nitro.d.ts.map +1 -0
  66. package/nitro.json +4 -0
  67. package/nitrogen/generated/android/Webrtc+autolinking.cmake +2 -0
  68. package/nitrogen/generated/android/WebrtcOnLoad.cpp +10 -0
  69. package/nitrogen/generated/android/c++/JHybridPermissionsSpec.cpp +91 -0
  70. package/nitrogen/generated/android/c++/JHybridPermissionsSpec.hpp +66 -0
  71. package/nitrogen/generated/android/c++/JPermissionDescriptor.hpp +58 -0
  72. package/nitrogen/generated/android/c++/JPermissionName.hpp +59 -0
  73. package/nitrogen/generated/android/c++/JPermissionState.hpp +62 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/HybridPermissionsSpec.kt +62 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionDescriptor.kt +38 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionName.kt +21 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionState.kt +22 -0
  78. package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Bridge.cpp +25 -0
  79. package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Bridge.hpp +63 -0
  80. package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Umbrella.hpp +14 -0
  81. package/nitrogen/generated/ios/WebrtcAutolinking.mm +8 -0
  82. package/nitrogen/generated/ios/WebrtcAutolinking.swift +15 -0
  83. package/nitrogen/generated/ios/c++/HybridPermissionsSpecSwift.cpp +11 -0
  84. package/nitrogen/generated/ios/c++/HybridPermissionsSpecSwift.hpp +92 -0
  85. package/nitrogen/generated/ios/swift/Func_void_PermissionState.swift +47 -0
  86. package/nitrogen/generated/ios/swift/HybridPermissionsSpec.swift +57 -0
  87. package/nitrogen/generated/ios/swift/HybridPermissionsSpec_cxx.swift +157 -0
  88. package/nitrogen/generated/ios/swift/PermissionDescriptor.swift +36 -0
  89. package/nitrogen/generated/ios/swift/PermissionName.swift +40 -0
  90. package/nitrogen/generated/ios/swift/PermissionState.swift +44 -0
  91. package/nitrogen/generated/shared/c++/HybridPermissionsSpec.cpp +22 -0
  92. package/nitrogen/generated/shared/c++/HybridPermissionsSpec.hpp +68 -0
  93. package/nitrogen/generated/shared/c++/PermissionDescriptor.hpp +76 -0
  94. package/nitrogen/generated/shared/c++/PermissionName.hpp +76 -0
  95. package/nitrogen/generated/shared/c++/PermissionState.hpp +80 -0
  96. package/package.json +4 -5
  97. package/src/index.ts +1 -0
  98. package/src/specs/Permissions.nitro.ts +22 -0
  99. package/android/src/main/java/com/webrtc/Permission.kt +0 -58
  100. package/ios/Permission.swift +0 -26
@@ -0,0 +1,157 @@
1
+ ///
2
+ /// HybridPermissionsSpec_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 HybridPermissionsSpec 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 HybridPermissionsSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::webrtc::bridge::swift`)
23
+ * from `Webrtc-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.webrtc.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridPermissionsSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridPermissionsSpec
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_HybridPermissionsSpec_
37
+
38
+ /**
39
+ * Create a new `HybridPermissionsSpec_cxx` that wraps the given `HybridPermissionsSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridPermissionsSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridPermissionsSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridPermissionsSpec() -> any HybridPermissionsSpec {
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 `HybridPermissionsSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridPermissionsSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridPermissionsSpec_cxx {
70
+ return Unmanaged<HybridPermissionsSpec_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<HybridPermissionsSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridPermissionsSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridPermissionsSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridPermissionsSpec_(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
+ /**
109
+ * Call toString() on the Swift class.
110
+ */
111
+ @inline(__always)
112
+ public func toString() -> String {
113
+ return self.__implementation.toString()
114
+ }
115
+
116
+ // Properties
117
+
118
+
119
+ // Methods
120
+ @inline(__always)
121
+ public final func query(permissionDesc: PermissionDescriptor) -> bridge.Result_std__shared_ptr_Promise_PermissionState___ {
122
+ do {
123
+ let __result = try self.__implementation.query(permissionDesc: permissionDesc)
124
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionState__ in
125
+ let __promise = bridge.create_std__shared_ptr_Promise_PermissionState__()
126
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionState__(__promise)
127
+ __result
128
+ .then({ __result in __promiseHolder.resolve(__result) })
129
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
130
+ return __promise
131
+ }()
132
+ return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__exceptionPtr)
136
+ }
137
+ }
138
+
139
+ @inline(__always)
140
+ public final func request(permissionDesc: PermissionDescriptor) -> bridge.Result_std__shared_ptr_Promise_PermissionState___ {
141
+ do {
142
+ let __result = try self.__implementation.request(permissionDesc: permissionDesc)
143
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionState__ in
144
+ let __promise = bridge.create_std__shared_ptr_Promise_PermissionState__()
145
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionState__(__promise)
146
+ __result
147
+ .then({ __result in __promiseHolder.resolve(__result) })
148
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
149
+ return __promise
150
+ }()
151
+ return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__resultCpp)
152
+ } catch (let __error) {
153
+ let __exceptionPtr = __error.toCpp()
154
+ return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__exceptionPtr)
155
+ }
156
+ }
157
+ }
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// PermissionDescriptor.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
+ * Represents an instance of `PermissionDescriptor`, backed by a C++ struct.
13
+ */
14
+ public typealias PermissionDescriptor = margelo.nitro.webrtc.PermissionDescriptor
15
+
16
+ public extension PermissionDescriptor {
17
+ private typealias bridge = margelo.nitro.webrtc.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `PermissionDescriptor`.
21
+ */
22
+ init(name: PermissionName) {
23
+ self.init(name)
24
+ }
25
+
26
+ var name: PermissionName {
27
+ @inline(__always)
28
+ get {
29
+ return self.__name
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__name = newValue
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// PermissionName.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
+ /**
9
+ * Represents the JS union `PermissionName`, backed by a C++ enum.
10
+ */
11
+ public typealias PermissionName = margelo.nitro.webrtc.PermissionName
12
+
13
+ public extension PermissionName {
14
+ /**
15
+ * Get a PermissionName for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "camera":
21
+ self = .camera
22
+ case "microphone":
23
+ self = .microphone
24
+ default:
25
+ return nil
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Get the String value this PermissionName represents.
31
+ */
32
+ var stringValue: String {
33
+ switch self {
34
+ case .camera:
35
+ return "camera"
36
+ case .microphone:
37
+ return "microphone"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// PermissionState.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
+ /**
9
+ * Represents the JS union `PermissionState`, backed by a C++ enum.
10
+ */
11
+ public typealias PermissionState = margelo.nitro.webrtc.PermissionState
12
+
13
+ public extension PermissionState {
14
+ /**
15
+ * Get a PermissionState for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "denied":
21
+ self = .denied
22
+ case "granted":
23
+ self = .granted
24
+ case "prompt":
25
+ self = .prompt
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this PermissionState represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .denied:
37
+ return "denied"
38
+ case .granted:
39
+ return "granted"
40
+ case .prompt:
41
+ return "prompt"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridPermissionsSpec.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 "HybridPermissionsSpec.hpp"
9
+
10
+ namespace margelo::nitro::webrtc {
11
+
12
+ void HybridPermissionsSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("query", &HybridPermissionsSpec::query);
18
+ prototype.registerHybridMethod("request", &HybridPermissionsSpec::request);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::webrtc
@@ -0,0 +1,68 @@
1
+ ///
2
+ /// HybridPermissionsSpec.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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `PermissionState` to properly resolve imports.
17
+ namespace margelo::nitro::webrtc { enum class PermissionState; }
18
+ // Forward declaration of `PermissionDescriptor` to properly resolve imports.
19
+ namespace margelo::nitro::webrtc { struct PermissionDescriptor; }
20
+
21
+ #include "PermissionState.hpp"
22
+ #include <NitroModules/Promise.hpp>
23
+ #include "PermissionDescriptor.hpp"
24
+
25
+ namespace margelo::nitro::webrtc {
26
+
27
+ using namespace margelo::nitro;
28
+
29
+ /**
30
+ * An abstract base class for `Permissions`
31
+ * Inherit this class to create instances of `HybridPermissionsSpec` in C++.
32
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
33
+ * @example
34
+ * ```cpp
35
+ * class HybridPermissions: public HybridPermissionsSpec {
36
+ * public:
37
+ * HybridPermissions(...): HybridObject(TAG) { ... }
38
+ * // ...
39
+ * };
40
+ * ```
41
+ */
42
+ class HybridPermissionsSpec: public virtual HybridObject {
43
+ public:
44
+ // Constructor
45
+ explicit HybridPermissionsSpec(): HybridObject(TAG) { }
46
+
47
+ // Destructor
48
+ ~HybridPermissionsSpec() override = default;
49
+
50
+ public:
51
+ // Properties
52
+
53
+
54
+ public:
55
+ // Methods
56
+ virtual std::shared_ptr<Promise<PermissionState>> query(const PermissionDescriptor& permissionDesc) = 0;
57
+ virtual std::shared_ptr<Promise<PermissionState>> request(const PermissionDescriptor& permissionDesc) = 0;
58
+
59
+ protected:
60
+ // Hybrid Setup
61
+ void loadHybridMethods() override;
62
+
63
+ protected:
64
+ // Tag for logging
65
+ static constexpr auto TAG = "Permissions";
66
+ };
67
+
68
+ } // namespace margelo::nitro::webrtc
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// PermissionDescriptor.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ // Forward declaration of `PermissionName` to properly resolve imports.
27
+ namespace margelo::nitro::webrtc { enum class PermissionName; }
28
+
29
+ #include "PermissionName.hpp"
30
+
31
+ namespace margelo::nitro::webrtc {
32
+
33
+ /**
34
+ * A struct which can be represented as a JavaScript object (PermissionDescriptor).
35
+ */
36
+ struct PermissionDescriptor {
37
+ public:
38
+ PermissionName name SWIFT_PRIVATE;
39
+
40
+ public:
41
+ PermissionDescriptor() = default;
42
+ explicit PermissionDescriptor(PermissionName name): name(name) {}
43
+ };
44
+
45
+ } // namespace margelo::nitro::webrtc
46
+
47
+ namespace margelo::nitro {
48
+
49
+ // C++ PermissionDescriptor <> JS PermissionDescriptor (object)
50
+ template <>
51
+ struct JSIConverter<margelo::nitro::webrtc::PermissionDescriptor> final {
52
+ static inline margelo::nitro::webrtc::PermissionDescriptor fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
53
+ jsi::Object obj = arg.asObject(runtime);
54
+ return margelo::nitro::webrtc::PermissionDescriptor(
55
+ JSIConverter<margelo::nitro::webrtc::PermissionName>::fromJSI(runtime, obj.getProperty(runtime, "name"))
56
+ );
57
+ }
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::webrtc::PermissionDescriptor& arg) {
59
+ jsi::Object obj(runtime);
60
+ obj.setProperty(runtime, "name", JSIConverter<margelo::nitro::webrtc::PermissionName>::toJSI(runtime, arg.name));
61
+ return obj;
62
+ }
63
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
64
+ if (!value.isObject()) {
65
+ return false;
66
+ }
67
+ jsi::Object obj = value.getObject(runtime);
68
+ if (!nitro::isPlainObject(runtime, obj)) {
69
+ return false;
70
+ }
71
+ if (!JSIConverter<margelo::nitro::webrtc::PermissionName>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
72
+ return true;
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// PermissionName.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::webrtc {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PermissionName).
30
+ */
31
+ enum class PermissionName {
32
+ CAMERA SWIFT_NAME(camera) = 0,
33
+ MICROPHONE SWIFT_NAME(microphone) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::webrtc
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ PermissionName <> JS PermissionName (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::webrtc::PermissionName> final {
43
+ static inline margelo::nitro::webrtc::PermissionName fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("camera"): return margelo::nitro::webrtc::PermissionName::CAMERA;
47
+ case hashString("microphone"): return margelo::nitro::webrtc::PermissionName::MICROPHONE;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PermissionName - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::webrtc::PermissionName arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::webrtc::PermissionName::CAMERA: return JSIConverter<std::string>::toJSI(runtime, "camera");
55
+ case margelo::nitro::webrtc::PermissionName::MICROPHONE: return JSIConverter<std::string>::toJSI(runtime, "microphone");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert PermissionName to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("camera"):
68
+ case hashString("microphone"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// PermissionState.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::webrtc {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PermissionState).
30
+ */
31
+ enum class PermissionState {
32
+ DENIED SWIFT_NAME(denied) = 0,
33
+ GRANTED SWIFT_NAME(granted) = 1,
34
+ PROMPT SWIFT_NAME(prompt) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::webrtc
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ PermissionState <> JS PermissionState (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::webrtc::PermissionState> final {
44
+ static inline margelo::nitro::webrtc::PermissionState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("denied"): return margelo::nitro::webrtc::PermissionState::DENIED;
48
+ case hashString("granted"): return margelo::nitro::webrtc::PermissionState::GRANTED;
49
+ case hashString("prompt"): return margelo::nitro::webrtc::PermissionState::PROMPT;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PermissionState - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::webrtc::PermissionState arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::webrtc::PermissionState::DENIED: return JSIConverter<std::string>::toJSI(runtime, "denied");
57
+ case margelo::nitro::webrtc::PermissionState::GRANTED: return JSIConverter<std::string>::toJSI(runtime, "granted");
58
+ case margelo::nitro::webrtc::PermissionState::PROMPT: return JSIConverter<std::string>::toJSI(runtime, "prompt");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert PermissionState to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("denied"):
71
+ case hashString("granted"):
72
+ case hashString("prompt"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webrtc-nitro",
3
- "version": "1.1.0",
3
+ "version": "1.2.3",
4
4
  "description": "Nitro WebRTC module for React Native",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -14,8 +14,7 @@
14
14
  "build": "pnpm run typecheck && bob build",
15
15
  "codegen": "nitrogen --logLevel=\"debug\" && pnpm run build && node post-script.js",
16
16
  "lint": "pnpm run lint:cpp",
17
- "lint:cpp": "find cpp -path cpp/__tests__/build -prune -o \\( -name \"*.cpp\" -o -name \"*.h\" -o -name \"*.hpp\" \\) -type f -print0 | xargs -0 clang-format -n --Werror -style=file",
18
- "outtt": "which clang-format"
17
+ "lint:cpp": "find cpp -path cpp/__tests__/build -prune -o \\( -name \"*.cpp\" -o -name \"*.h\" -o -name \"*.hpp\" \\) -type f -print0 | xargs -0 clang-format -n --Werror -style=file"
19
18
  },
20
19
  "keywords": [
21
20
  "react-native",
@@ -61,8 +60,8 @@
61
60
  "clang-format-node": "^2.0.5",
62
61
  "conventional-changelog-conventionalcommits": "^9.1.0",
63
62
  "nitrogen": "0.31.10",
64
- "react": "19.2.0",
65
- "react-native": "0.83.0-rc.3",
63
+ "react": "19.1.1",
64
+ "react-native": "0.82.1",
66
65
  "react-native-builder-bob": "^0.40.16",
67
66
  "react-native-nitro-modules": "0.31.10",
68
67
  "semantic-release": "^25.0.2",
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './views/WebrtcView'
2
+ export * from './specs/Permissions.nitro'
2
3
  export * from './specs/MediaDevices.nitro'
3
4
  export * from './specs/MediaStream.nitro'
4
5
  export * from './specs/MediaStreamTrack.nitro'
@@ -0,0 +1,22 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules'
2
+ import { NitroModules } from 'react-native-nitro-modules'
3
+
4
+ export type PermissionState = 'denied' | 'granted' | 'prompt'
5
+ type PermissionName = 'camera' | 'microphone'
6
+
7
+ export interface PermissionDescriptor {
8
+ name: PermissionName
9
+ }
10
+
11
+ interface Permissions extends HybridObject<{
12
+ ios: 'swift'
13
+ android: 'kotlin'
14
+ }> {
15
+ query(permissionDesc: PermissionDescriptor): Promise<PermissionState>
16
+ request(permissionDesc: PermissionDescriptor): Promise<PermissionState>
17
+ }
18
+
19
+ const PermissionsExport =
20
+ NitroModules.createHybridObject<Permissions>('Permissions')
21
+ type PermissionsExport = Permissions
22
+ export { PermissionsExport as Permissions }