@livekit/react-native 2.9.1 → 2.9.2
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.
- package/android/build.gradle +1 -1
- package/android/consumer-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +0 -1
- package/ios/AudioUtils.swift +38 -3
- package/ios/LiveKitReactNativeModule.swift +76 -79
- package/ios/LivekitReactNativeModule.m +7 -3
- package/lib/commonjs/index.js +10 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +10 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/index.d.ts +3 -1
- package/lib/typescript/lib/module/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts +13 -1
- package/package.json +1 -1
- package/src/index.tsx +22 -2
package/android/build.gradle
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-keep class com.livekit.** { *; }
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
7
7
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
|
8
8
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
9
|
-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
10
9
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
11
10
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
12
11
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
package/ios/AudioUtils.swift
CHANGED
|
@@ -6,7 +6,11 @@ public class AudioUtils {
|
|
|
6
6
|
case "default_":
|
|
7
7
|
.default
|
|
8
8
|
case "voicePrompt":
|
|
9
|
-
.
|
|
9
|
+
if #available(iOS 12.0, *) {
|
|
10
|
+
.voicePrompt
|
|
11
|
+
} else {
|
|
12
|
+
.default
|
|
13
|
+
}
|
|
10
14
|
case "videoRecording":
|
|
11
15
|
.videoRecording
|
|
12
16
|
case "videoChat":
|
|
@@ -26,7 +30,7 @@ public class AudioUtils {
|
|
|
26
30
|
}
|
|
27
31
|
return retMode
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
|
|
30
34
|
public static func audioSessionCategoryFromString(_ category: String) -> AVAudioSession.Category {
|
|
31
35
|
let retCategory: AVAudioSession.Category = switch category {
|
|
32
36
|
case "ambient":
|
|
@@ -42,8 +46,39 @@ public class AudioUtils {
|
|
|
42
46
|
case "multiRoute":
|
|
43
47
|
.multiRoute
|
|
44
48
|
default:
|
|
45
|
-
.
|
|
49
|
+
.soloAmbient
|
|
46
50
|
}
|
|
47
51
|
return retCategory
|
|
48
52
|
}
|
|
53
|
+
|
|
54
|
+
public static func audioSessionCategoryOptionsFromStrings(_ options: [String]) -> AVAudioSession.CategoryOptions {
|
|
55
|
+
var categoryOptions: AVAudioSession.CategoryOptions = []
|
|
56
|
+
for option in options {
|
|
57
|
+
switch option {
|
|
58
|
+
case "mixWithOthers":
|
|
59
|
+
categoryOptions.insert(.mixWithOthers)
|
|
60
|
+
case "duckOthers":
|
|
61
|
+
categoryOptions.insert(.duckOthers)
|
|
62
|
+
case "allowBluetooth":
|
|
63
|
+
categoryOptions.insert(.allowBluetooth)
|
|
64
|
+
case "allowBluetoothA2DP":
|
|
65
|
+
categoryOptions.insert(.allowBluetoothA2DP)
|
|
66
|
+
case "allowAirPlay":
|
|
67
|
+
categoryOptions.insert(.allowAirPlay)
|
|
68
|
+
case "defaultToSpeaker":
|
|
69
|
+
categoryOptions.insert(.defaultToSpeaker)
|
|
70
|
+
case "interruptSpokenAudioAndMixWithOthers":
|
|
71
|
+
if #available(iOS 13.0, *) {
|
|
72
|
+
categoryOptions.insert(.interruptSpokenAudioAndMixWithOthers)
|
|
73
|
+
}
|
|
74
|
+
case "overrideMutedMicrophoneInterruption":
|
|
75
|
+
if #available(iOS 14.5, *) {
|
|
76
|
+
categoryOptions.insert(.overrideMutedMicrophoneInterruption)
|
|
77
|
+
}
|
|
78
|
+
default:
|
|
79
|
+
break
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return categoryOptions
|
|
83
|
+
}
|
|
49
84
|
}
|
|
@@ -11,7 +11,7 @@ struct LKEvents {
|
|
|
11
11
|
|
|
12
12
|
@objc(LivekitReactNativeModule)
|
|
13
13
|
public class LivekitReactNativeModule: RCTEventEmitter {
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
// This cannot be initialized in init as self.bridge is given afterwards.
|
|
16
16
|
private var _audioRendererManager: AudioRendererManager? = nil
|
|
17
17
|
public var audioRendererManager: AudioRendererManager {
|
|
@@ -19,11 +19,11 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
19
19
|
if _audioRendererManager == nil {
|
|
20
20
|
_audioRendererManager = AudioRendererManager(bridge: self.bridge)
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
return _audioRendererManager!
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
@objc
|
|
28
28
|
public override init() {
|
|
29
29
|
super.init()
|
|
@@ -31,10 +31,10 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
31
31
|
config.category = AVAudioSession.Category.playAndRecord.rawValue
|
|
32
32
|
config.categoryOptions = [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP, .defaultToSpeaker]
|
|
33
33
|
config.mode = AVAudioSession.Mode.videoChat.rawValue
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
RTCAudioSessionConfiguration.setWebRTC(config)
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
@objc
|
|
39
39
|
override public static func requiresMainQueueSetup() -> Bool {
|
|
40
40
|
return false
|
|
@@ -48,19 +48,19 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
48
48
|
options.videoEncoderFactory = simulcastVideoEncoderFactory
|
|
49
49
|
options.audioProcessingModule = LKAudioProcessingManager.sharedInstance().audioProcessingModule
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
@objc(configureAudio:)
|
|
53
53
|
public func configureAudio(_ config: NSDictionary) {
|
|
54
54
|
guard let iOSConfig = config["ios"] as? NSDictionary
|
|
55
55
|
else {
|
|
56
56
|
return
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
let defaultOutput = iOSConfig["defaultOutput"] as? String ?? "speaker"
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
let rtcConfig = RTCAudioSessionConfiguration()
|
|
62
62
|
rtcConfig.category = AVAudioSession.Category.playAndRecord.rawValue
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
if (defaultOutput == "earpiece") {
|
|
65
65
|
rtcConfig.categoryOptions = [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP];
|
|
66
66
|
rtcConfig.mode = AVAudioSession.Mode.voiceChat.rawValue
|
|
@@ -70,17 +70,39 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
70
70
|
}
|
|
71
71
|
RTCAudioSessionConfiguration.setWebRTC(rtcConfig)
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
@objc(startAudioSession)
|
|
75
|
-
public func startAudioSession() {
|
|
76
|
-
|
|
73
|
+
|
|
74
|
+
@objc(startAudioSession:withRejecter:)
|
|
75
|
+
public func startAudioSession(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
76
|
+
let session = RTCAudioSession.sharedInstance()
|
|
77
|
+
session.lockForConfiguration()
|
|
78
|
+
defer {
|
|
79
|
+
session.unlockForConfiguration()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
do {
|
|
83
|
+
try session.setActive(true)
|
|
84
|
+
resolve(nil)
|
|
85
|
+
} catch {
|
|
86
|
+
reject("startAudioSession", "Error activating audio session: \(error.localizedDescription)", error)
|
|
87
|
+
}
|
|
77
88
|
}
|
|
78
|
-
|
|
79
|
-
@objc(stopAudioSession)
|
|
80
|
-
public func stopAudioSession() {
|
|
81
|
-
|
|
89
|
+
|
|
90
|
+
@objc(stopAudioSession:withRejecter:)
|
|
91
|
+
public func stopAudioSession(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
92
|
+
let session = RTCAudioSession.sharedInstance()
|
|
93
|
+
session.lockForConfiguration()
|
|
94
|
+
defer {
|
|
95
|
+
session.unlockForConfiguration()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
do {
|
|
99
|
+
try session.setActive(false)
|
|
100
|
+
resolve(nil)
|
|
101
|
+
} catch {
|
|
102
|
+
reject("stopAudioSession", "Error deactivating audio session: \(error.localizedDescription)", error)
|
|
103
|
+
}
|
|
82
104
|
}
|
|
83
|
-
|
|
105
|
+
|
|
84
106
|
@objc(showAudioRoutePicker)
|
|
85
107
|
public func showAudioRoutePicker() {
|
|
86
108
|
if #available(iOS 11.0, *) {
|
|
@@ -95,12 +117,12 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
119
|
}
|
|
98
|
-
|
|
120
|
+
|
|
99
121
|
@objc(getAudioOutputsWithResolver:withRejecter:)
|
|
100
122
|
public func getAudioOutputs(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock){
|
|
101
123
|
resolve(["default", "force_speaker"])
|
|
102
124
|
}
|
|
103
|
-
|
|
125
|
+
|
|
104
126
|
@objc(selectAudioOutput:withResolver:withRejecter:)
|
|
105
127
|
public func selectAudioOutput(_ deviceId: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
106
128
|
let session = AVAudioSession.sharedInstance()
|
|
@@ -114,78 +136,53 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
114
136
|
reject("selectAudioOutput error", error.localizedDescription, error)
|
|
115
137
|
return
|
|
116
138
|
}
|
|
117
|
-
|
|
139
|
+
|
|
118
140
|
resolve(nil)
|
|
119
141
|
}
|
|
120
|
-
|
|
121
|
-
@objc(setAppleAudioConfiguration:)
|
|
122
|
-
public func setAppleAudioConfiguration(_ configuration: NSDictionary) {
|
|
142
|
+
|
|
143
|
+
@objc(setAppleAudioConfiguration:withResolver:withRejecter:)
|
|
144
|
+
public func setAppleAudioConfiguration(_ configuration: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
123
145
|
let session = RTCAudioSession.sharedInstance()
|
|
124
146
|
let config = RTCAudioSessionConfiguration.webRTC()
|
|
125
|
-
|
|
147
|
+
|
|
126
148
|
let appleAudioCategory = configuration["audioCategory"] as? String
|
|
127
149
|
let appleAudioCategoryOptions = configuration["audioCategoryOptions"] as? [String]
|
|
128
150
|
let appleAudioMode = configuration["audioMode"] as? String
|
|
129
|
-
|
|
151
|
+
|
|
130
152
|
session.lockForConfiguration()
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if let appleAudioCategoryOptions = appleAudioCategoryOptions {
|
|
135
|
-
categoryChanged = true
|
|
136
|
-
|
|
137
|
-
var newOptions: AVAudioSession.CategoryOptions = []
|
|
138
|
-
for option in appleAudioCategoryOptions {
|
|
139
|
-
if option == "mixWithOthers" {
|
|
140
|
-
newOptions.insert(.mixWithOthers)
|
|
141
|
-
} else if option == "duckOthers" {
|
|
142
|
-
newOptions.insert(.duckOthers)
|
|
143
|
-
} else if option == "allowBluetooth" {
|
|
144
|
-
newOptions.insert(.allowBluetooth)
|
|
145
|
-
} else if option == "allowBluetoothA2DP" {
|
|
146
|
-
newOptions.insert(.allowBluetoothA2DP)
|
|
147
|
-
} else if option == "allowAirPlay" {
|
|
148
|
-
newOptions.insert(.allowAirPlay)
|
|
149
|
-
} else if option == "defaultToSpeaker" {
|
|
150
|
-
newOptions.insert(.defaultToSpeaker)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
config.categoryOptions = newOptions
|
|
153
|
+
defer {
|
|
154
|
+
session.unlockForConfiguration()
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
|
|
156
157
|
if let appleAudioCategory = appleAudioCategory {
|
|
157
|
-
categoryChanged = true
|
|
158
158
|
config.category = AudioUtils.audioSessionCategoryFromString(appleAudioCategory).rawValue
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
if
|
|
162
|
-
|
|
163
|
-
try session.setCategory(AVAudioSession.Category(rawValue: config.category), with: config.categoryOptions)
|
|
164
|
-
} catch {
|
|
165
|
-
NSLog("Error setting category: %@", error.localizedDescription)
|
|
166
|
-
}
|
|
160
|
+
|
|
161
|
+
if let appleAudioCategoryOptions = appleAudioCategoryOptions {
|
|
162
|
+
config.categoryOptions = AudioUtils.audioSessionCategoryOptionsFromStrings(appleAudioCategoryOptions)
|
|
167
163
|
}
|
|
168
|
-
|
|
164
|
+
|
|
169
165
|
if let appleAudioMode = appleAudioMode {
|
|
170
|
-
|
|
171
|
-
config.mode = mode.rawValue
|
|
172
|
-
do {
|
|
173
|
-
try session.setMode(mode)
|
|
174
|
-
} catch {
|
|
175
|
-
NSLog("Error setting mode: %@", error.localizedDescription)
|
|
176
|
-
}
|
|
166
|
+
config.mode = AudioUtils.audioSessionModeFromString(appleAudioMode).rawValue
|
|
177
167
|
}
|
|
178
|
-
|
|
179
|
-
|
|
168
|
+
|
|
169
|
+
do {
|
|
170
|
+
try session.setConfiguration(config)
|
|
171
|
+
resolve(nil)
|
|
172
|
+
} catch {
|
|
173
|
+
reject("setAppleAudioConfiguration", "Error setting category: \(error.localizedDescription)", error)
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
180
177
|
}
|
|
181
|
-
|
|
178
|
+
|
|
182
179
|
@objc(createAudioSinkListener:trackId:)
|
|
183
180
|
public func createAudioSinkListener(_ pcId: NSNumber, trackId: String) -> String {
|
|
184
181
|
let renderer = AudioSinkRenderer(eventEmitter: self)
|
|
185
182
|
let reactTag = self.audioRendererManager.registerRenderer(renderer)
|
|
186
183
|
renderer.reactTag = reactTag
|
|
187
184
|
self.audioRendererManager.attach(renderer: renderer, pcId: pcId, trackId: trackId)
|
|
188
|
-
|
|
185
|
+
|
|
189
186
|
return reactTag
|
|
190
187
|
}
|
|
191
188
|
|
|
@@ -193,7 +190,7 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
193
190
|
public func deleteAudioSinkListener(_ reactTag: String, pcId: NSNumber, trackId: String) -> Any? {
|
|
194
191
|
self.audioRendererManager.detach(rendererByTag: reactTag, pcId: pcId, trackId: trackId)
|
|
195
192
|
self.audioRendererManager.unregisterRenderer(forReactTag: reactTag)
|
|
196
|
-
|
|
193
|
+
|
|
197
194
|
return nil
|
|
198
195
|
}
|
|
199
196
|
|
|
@@ -203,7 +200,7 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
203
200
|
let reactTag = self.audioRendererManager.registerRenderer(renderer)
|
|
204
201
|
renderer.reactTag = reactTag
|
|
205
202
|
self.audioRendererManager.attach(renderer: renderer, pcId: pcId, trackId: trackId)
|
|
206
|
-
|
|
203
|
+
|
|
207
204
|
return reactTag
|
|
208
205
|
}
|
|
209
206
|
|
|
@@ -211,7 +208,7 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
211
208
|
public func deleteVolumeProcessor(_ reactTag: String, pcId: NSNumber, trackId: String) -> Any? {
|
|
212
209
|
self.audioRendererManager.detach(rendererByTag: reactTag, pcId: pcId, trackId: trackId)
|
|
213
210
|
self.audioRendererManager.unregisterRenderer(forReactTag: reactTag)
|
|
214
|
-
|
|
211
|
+
|
|
215
212
|
return nil
|
|
216
213
|
}
|
|
217
214
|
|
|
@@ -221,7 +218,7 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
221
218
|
let minFrequency = (options["minFrequency"] as? NSNumber)?.floatValue ?? 1000
|
|
222
219
|
let maxFrequency = (options["maxFrequency"] as? NSNumber)?.floatValue ?? 8000
|
|
223
220
|
let intervalMs = (options["updateInterval"] as? NSNumber)?.floatValue ?? 40
|
|
224
|
-
|
|
221
|
+
|
|
225
222
|
let renderer = MultibandVolumeAudioRenderer(
|
|
226
223
|
bands: bands,
|
|
227
224
|
minFrequency: minFrequency,
|
|
@@ -232,18 +229,18 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
232
229
|
let reactTag = self.audioRendererManager.registerRenderer(renderer)
|
|
233
230
|
renderer.reactTag = reactTag
|
|
234
231
|
self.audioRendererManager.attach(renderer: renderer, pcId: pcId, trackId: trackId)
|
|
235
|
-
|
|
232
|
+
|
|
236
233
|
return reactTag
|
|
237
234
|
}
|
|
238
|
-
|
|
235
|
+
|
|
239
236
|
@objc(deleteMultibandVolumeProcessor:pcId:trackId:)
|
|
240
237
|
public func deleteMultibandVolumeProcessor(_ reactTag: String, pcId: NSNumber, trackId: String) -> Any? {
|
|
241
238
|
self.audioRendererManager.detach(rendererByTag: reactTag, pcId: pcId, trackId: trackId)
|
|
242
239
|
self.audioRendererManager.unregisterRenderer(forReactTag: reactTag)
|
|
243
|
-
|
|
240
|
+
|
|
244
241
|
return nil
|
|
245
242
|
}
|
|
246
|
-
|
|
243
|
+
|
|
247
244
|
@objc(setDefaultAudioTrackVolume:)
|
|
248
245
|
public func setDefaultAudioTrackVolume(_ volume: NSNumber) -> Any? {
|
|
249
246
|
let options = WebRTCModuleOptions.sharedInstance()
|
|
@@ -251,7 +248,7 @@ public class LivekitReactNativeModule: RCTEventEmitter {
|
|
|
251
248
|
|
|
252
249
|
return nil
|
|
253
250
|
}
|
|
254
|
-
|
|
251
|
+
|
|
255
252
|
override public func supportedEvents() -> [String]! {
|
|
256
253
|
return [
|
|
257
254
|
LKEvents.kEventVolumeProcessed,
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
@interface RCT_EXTERN_MODULE(LivekitReactNativeModule, RCTEventEmitter)
|
|
6
6
|
|
|
7
7
|
RCT_EXTERN_METHOD(configureAudio:(NSDictionary *) config)
|
|
8
|
-
RCT_EXTERN_METHOD(startAudioSession)
|
|
9
|
-
|
|
8
|
+
RCT_EXTERN_METHOD(startAudioSession:(RCTPromiseResolveBlock)resolve
|
|
9
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
10
|
+
RCT_EXTERN_METHOD(stopAudioSession:(RCTPromiseResolveBlock)resolve
|
|
11
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
10
12
|
|
|
11
13
|
RCT_EXTERN_METHOD(setDefaultAudioTrackVolume:(nonnull NSNumber *) volume)
|
|
12
14
|
|
|
@@ -19,7 +21,9 @@ RCT_EXTERN_METHOD(selectAudioOutput:(NSString *)deviceId
|
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
/// Configure audio config for WebRTC
|
|
22
|
-
RCT_EXTERN_METHOD(setAppleAudioConfiguration:(NSDictionary *)
|
|
24
|
+
RCT_EXTERN_METHOD(setAppleAudioConfiguration:(NSDictionary *)configuration
|
|
25
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
26
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
23
27
|
|
|
24
28
|
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(createAudioSinkListener:(nonnull NSNumber *)pcId
|
|
25
29
|
trackId:(nonnull NSString *)trackId)
|
package/lib/commonjs/index.js
CHANGED
|
@@ -170,10 +170,18 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
170
170
|
* Registers the required globals needed for LiveKit to work.
|
|
171
171
|
*
|
|
172
172
|
* Must be called before using LiveKit.
|
|
173
|
+
*
|
|
174
|
+
* @param options Optional configuration for global registration
|
|
173
175
|
*/
|
|
174
|
-
function registerGlobals() {
|
|
176
|
+
function registerGlobals(options) {
|
|
177
|
+
const opts = {
|
|
178
|
+
autoConfigureAudioSession: true,
|
|
179
|
+
...options
|
|
180
|
+
};
|
|
175
181
|
(0, _reactNativeWebrtc.registerGlobals)();
|
|
176
|
-
|
|
182
|
+
if (opts.autoConfigureAudioSession) {
|
|
183
|
+
iosCategoryEnforce();
|
|
184
|
+
}
|
|
177
185
|
livekitRegisterGlobals();
|
|
178
186
|
(0, _reactNativeUrlPolyfill.setupURLPolyfill)();
|
|
179
187
|
fixWebrtcAdapter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_reactNativeWebrtc","_reactNativeUrlPolyfill","_AudioSession","_interopRequireWildcard","_reactNative","_RNE2EEManager","_interopRequireDefault","_RNKeyProvider","_EventEmitter","_webStreamsPolyfill","_hooks","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_BarVisualizer","_LiveKitRoom","_VideoTrack","_VideoView","_useParticipant","_useRoom","_logger","_AudioManager","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","registerGlobals","webrtcRegisterGlobals","iosCategoryEnforce","livekitRegisterGlobals","setupURLPolyfill","fixWebrtcAdapter","shimPromiseAllSettled","shimArrayAt","shimCryptoUuid","shimWebstreams","setupNativeEvents","Platform","OS","getUserMediaFunc","global","navigator","mediaDevices","getUserMedia","constraints","audio","AudioSession","setAppleAudioConfiguration","audioCategory","lkGlobal","platform","devicePixelRatio","PixelRatio","LiveKitReactNativeGlobal","_window","window","undefined","userAgent","product","allSettled","shim","Array","at","_global$crypto","crypto","randomUUID","createRandomUUID","replace","c","Math","random","v","toString","WritableStream","ReadableStream"],"sources":["index.tsx"],"sourcesContent":["import 'well-known-symbols/Symbol.asyncIterator/auto';\nimport 'well-known-symbols/Symbol.iterator/auto';\nimport './polyfills/MediaRecorderShim';\nimport 'react-native-quick-base64';\nimport { registerGlobals as webrtcRegisterGlobals } from '@livekit/react-native-webrtc';\nimport { setupURLPolyfill } from 'react-native-url-polyfill';\nimport './polyfills/EncoderDecoderTogether.min.js';\nimport AudioSession, {\n AndroidAudioTypePresets,\n type AndroidAudioTypeOptions,\n type AppleAudioCategory,\n type AppleAudioCategoryOption,\n type AppleAudioConfiguration,\n type AppleAudioMode,\n type AudioTrackState,\n getDefaultAppleAudioConfigurationForMode,\n} from './audio/AudioSession';\nimport type { AudioConfiguration } from './audio/AudioSession';\nimport { PixelRatio, Platform } from 'react-native';\nimport { type LiveKitReactNativeInfo } from 'livekit-client';\nimport type { LogLevel, SetLogLevelOptions } from './logger';\nimport RNE2EEManager from './e2ee/RNE2EEManager';\nimport RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';\nimport { setupNativeEvents } from './events/EventEmitter';\nimport { ReadableStream, WritableStream } from 'web-streams-polyfill';\n\n/**\n * Registers the required globals needed for LiveKit to work.\n *\n * Must be called before using LiveKit.\n */\nexport function registerGlobals() {\n webrtcRegisterGlobals();\n iosCategoryEnforce();\n livekitRegisterGlobals();\n setupURLPolyfill();\n fixWebrtcAdapter();\n shimPromiseAllSettled();\n shimArrayAt();\n shimCryptoUuid();\n shimWebstreams();\n setupNativeEvents();\n}\n\n/**\n * Enforces changing to playAndRecord category prior to obtaining microphone.\n */\nfunction iosCategoryEnforce() {\n if (Platform.OS === 'ios') {\n // @ts-ignore\n let getUserMediaFunc = global.navigator.mediaDevices.getUserMedia;\n // @ts-ignore\n global.navigator.mediaDevices.getUserMedia = async (constraints: any) => {\n if (constraints.audio) {\n await AudioSession.setAppleAudioConfiguration({\n audioCategory: 'playAndRecord',\n });\n }\n\n return await getUserMediaFunc(constraints);\n };\n }\n}\n\nfunction livekitRegisterGlobals() {\n let lkGlobal: LiveKitReactNativeInfo = {\n platform: Platform.OS,\n devicePixelRatio: PixelRatio.get(),\n };\n\n // @ts-ignore\n global.LiveKitReactNativeGlobal = lkGlobal;\n}\n\nfunction fixWebrtcAdapter() {\n // @ts-ignore\n if (window?.navigator !== undefined) {\n // @ts-ignore\n const { navigator } = window;\n if (navigator.userAgent === undefined) {\n navigator.userAgent = navigator.product ?? 'Unknown';\n }\n }\n}\n\nfunction shimPromiseAllSettled() {\n var allSettled = require('promise.allsettled');\n allSettled.shim();\n}\n\nfunction shimArrayAt() {\n // Some versions of RN don't have Array.prototype.at, which is used by sdp-transform\n if (!Array.prototype.at) {\n var at = require('array.prototype.at');\n at.shim();\n }\n}\n\nfunction shimCryptoUuid() {\n let crypto = global.crypto;\n if (typeof global.crypto?.randomUUID !== 'function') {\n let createRandomUUID = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }\n ) as `${string}-${string}-${string}-${string}-${string}`;\n };\n\n if (!crypto) {\n crypto = {} as typeof global.crypto;\n global.crypto = crypto;\n }\n crypto.randomUUID = createRandomUUID;\n }\n}\n\nfunction shimWebstreams() {\n // @ts-expect-error: global.WritableStream isn't typed here.\n if (typeof global.WritableStream === 'undefined') {\n // @ts-expect-error\n global.WritableStream = WritableStream;\n }\n\n // @ts-expect-error: global.ReadableStream isn't typed here.\n if (typeof global.ReadableStream === 'undefined') {\n // @ts-expect-error\n global.ReadableStream = ReadableStream;\n }\n}\n\nexport * from './hooks';\nexport * from './components/BarVisualizer';\nexport * from './components/LiveKitRoom';\nexport * from './components/VideoTrack';\nexport * from './components/VideoView'; // deprecated\nexport * from './useParticipant'; // deprecated\nexport * from './useRoom'; // deprecated\nexport * from './logger';\nexport * from './audio/AudioManager';\n\nexport {\n AudioSession,\n RNE2EEManager,\n RNKeyProvider,\n AndroidAudioTypePresets,\n getDefaultAppleAudioConfigurationForMode,\n};\nexport type {\n AudioConfiguration,\n AndroidAudioTypeOptions,\n AppleAudioCategory,\n AppleAudioCategoryOption,\n AppleAudioConfiguration,\n AppleAudioMode,\n AudioTrackState,\n LogLevel,\n SetLogLevelOptions,\n RNKeyProviderOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAA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AAK,UAAU,EAAE;IACnD,IAAIC,gBAAgB,GAAGA,CAAA,KAAM;MAC3B,OAAO,sCAAsC,CAACC,OAAO,CACnD,OAAO,EACP,UAAUC,CAAC,EAAE;QACX;QACA,MAAMpD,CAAC,GAAIqD,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;QAClC,MAAMC,CAAC,GAAGH,CAAC,KAAK,GAAG,GAAGpD,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG;QACzC,OAAOuD,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC;MACvB,CACF,CAAC;IACH,CAAC;IAED,IAAI,CAACR,MAAM,EAAE;MACXA,MAAM,GAAG,CAAC,CAAyB;MACnCxB,MAAM,CAACwB,MAAM,GAAGA,MAAM;IACxB;IACAA,MAAM,CAACC,UAAU,GAAGC,gBAAgB;EACtC;AACF;AAEA,SAAS/B,cAAcA,CAAA,EAAG;EACxB;EACA,IAAI,OAAOK,MAAM,CAACiC,cAAc,KAAK,WAAW,EAAE;IAChD;IACAjC,MAAM,CAACiC,cAAc,GAAGA,kCAAc;EACxC;;EAEA;EACA,IAAI,OAAOjC,MAAM,CAACkC,cAAc,KAAK,WAAW,EAAE;IAChD;IACAlC,MAAM,CAACkC,cAAc,GAAGA,kCAAc;EACxC;AACF;;AAMwC;AACN;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["require","_reactNativeWebrtc","_reactNativeUrlPolyfill","_AudioSession","_interopRequireWildcard","_reactNative","_RNE2EEManager","_interopRequireDefault","_RNKeyProvider","_EventEmitter","_webStreamsPolyfill","_hooks","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_BarVisualizer","_LiveKitRoom","_VideoTrack","_VideoView","_useParticipant","_useRoom","_logger","_AudioManager","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","registerGlobals","options","opts","autoConfigureAudioSession","webrtcRegisterGlobals","iosCategoryEnforce","livekitRegisterGlobals","setupURLPolyfill","fixWebrtcAdapter","shimPromiseAllSettled","shimArrayAt","shimCryptoUuid","shimWebstreams","setupNativeEvents","Platform","OS","getUserMediaFunc","global","navigator","mediaDevices","getUserMedia","constraints","audio","AudioSession","setAppleAudioConfiguration","audioCategory","lkGlobal","platform","devicePixelRatio","PixelRatio","LiveKitReactNativeGlobal","_window","window","undefined","userAgent","product","allSettled","shim","Array","at","_global$crypto","crypto","randomUUID","createRandomUUID","replace","c","Math","random","v","toString","WritableStream","ReadableStream"],"sources":["index.tsx"],"sourcesContent":["import 'well-known-symbols/Symbol.asyncIterator/auto';\nimport 'well-known-symbols/Symbol.iterator/auto';\nimport './polyfills/MediaRecorderShim';\nimport 'react-native-quick-base64';\nimport { registerGlobals as webrtcRegisterGlobals } from '@livekit/react-native-webrtc';\nimport { setupURLPolyfill } from 'react-native-url-polyfill';\nimport './polyfills/EncoderDecoderTogether.min.js';\nimport AudioSession, {\n AndroidAudioTypePresets,\n type AndroidAudioTypeOptions,\n type AppleAudioCategory,\n type AppleAudioCategoryOption,\n type AppleAudioConfiguration,\n type AppleAudioMode,\n type AudioTrackState,\n getDefaultAppleAudioConfigurationForMode,\n} from './audio/AudioSession';\nimport type { AudioConfiguration } from './audio/AudioSession';\nimport { PixelRatio, Platform } from 'react-native';\nimport { type LiveKitReactNativeInfo } from 'livekit-client';\nimport type { LogLevel, SetLogLevelOptions } from './logger';\nimport RNE2EEManager from './e2ee/RNE2EEManager';\nimport RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';\nimport { setupNativeEvents } from './events/EventEmitter';\nimport { ReadableStream, WritableStream } from 'web-streams-polyfill';\n\nexport interface RegisterGlobalsOptions {\n /**\n * Automatically configure audio session before accessing microphone.\n * When enabled, sets the iOS audio category to 'playAndRecord' before getUserMedia.\n *\n * @default true\n * @platform ios\n */\n autoConfigureAudioSession?: boolean;\n}\n\n/**\n * Registers the required globals needed for LiveKit to work.\n *\n * Must be called before using LiveKit.\n *\n * @param options Optional configuration for global registration\n */\nexport function registerGlobals(options?: RegisterGlobalsOptions) {\n const opts = {\n autoConfigureAudioSession: true,\n ...options,\n };\n\n webrtcRegisterGlobals();\n if (opts.autoConfigureAudioSession) {\n iosCategoryEnforce();\n }\n livekitRegisterGlobals();\n setupURLPolyfill();\n fixWebrtcAdapter();\n shimPromiseAllSettled();\n shimArrayAt();\n shimCryptoUuid();\n shimWebstreams();\n setupNativeEvents();\n}\n\n/**\n * Enforces changing to playAndRecord category prior to obtaining microphone.\n */\nfunction iosCategoryEnforce() {\n if (Platform.OS === 'ios') {\n // @ts-ignore\n let getUserMediaFunc = global.navigator.mediaDevices.getUserMedia;\n // @ts-ignore\n global.navigator.mediaDevices.getUserMedia = async (constraints: any) => {\n if (constraints.audio) {\n await AudioSession.setAppleAudioConfiguration({\n audioCategory: 'playAndRecord',\n });\n }\n\n return await getUserMediaFunc(constraints);\n };\n }\n}\n\nfunction livekitRegisterGlobals() {\n let lkGlobal: LiveKitReactNativeInfo = {\n platform: Platform.OS,\n devicePixelRatio: PixelRatio.get(),\n };\n\n // @ts-ignore\n global.LiveKitReactNativeGlobal = lkGlobal;\n}\n\nfunction fixWebrtcAdapter() {\n // @ts-ignore\n if (window?.navigator !== undefined) {\n // @ts-ignore\n const { navigator } = window;\n if (navigator.userAgent === undefined) {\n navigator.userAgent = navigator.product ?? 'Unknown';\n }\n }\n}\n\nfunction shimPromiseAllSettled() {\n var allSettled = require('promise.allsettled');\n allSettled.shim();\n}\n\nfunction shimArrayAt() {\n // Some versions of RN don't have Array.prototype.at, which is used by sdp-transform\n if (!Array.prototype.at) {\n var at = require('array.prototype.at');\n at.shim();\n }\n}\n\nfunction shimCryptoUuid() {\n let crypto = global.crypto;\n if (typeof global.crypto?.randomUUID !== 'function') {\n let createRandomUUID = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }\n ) as `${string}-${string}-${string}-${string}-${string}`;\n };\n\n if (!crypto) {\n crypto = {} as typeof global.crypto;\n global.crypto = crypto;\n }\n crypto.randomUUID = createRandomUUID;\n }\n}\n\nfunction shimWebstreams() {\n // @ts-expect-error: global.WritableStream isn't typed here.\n if (typeof global.WritableStream === 'undefined') {\n // @ts-expect-error\n global.WritableStream = WritableStream;\n }\n\n // @ts-expect-error: global.ReadableStream isn't typed here.\n if (typeof global.ReadableStream === 'undefined') {\n // @ts-expect-error\n global.ReadableStream = ReadableStream;\n }\n}\n\nexport * from './hooks';\nexport * from './components/BarVisualizer';\nexport * from './components/LiveKitRoom';\nexport * from './components/VideoTrack';\nexport * from './components/VideoView'; // deprecated\nexport * from './useParticipant'; // deprecated\nexport * from './useRoom'; // deprecated\nexport * from './logger';\nexport * from './audio/AudioManager';\n\nexport {\n AudioSession,\n RNE2EEManager,\n RNKeyProvider,\n AndroidAudioTypePresets,\n getDefaultAppleAudioConfigurationForMode,\n};\nexport type {\n AudioConfiguration,\n AndroidAudioTypeOptions,\n AppleAudioCategory,\n AppleAudioCategoryOption,\n AppleAudioConfiguration,\n AppleAudioMode,\n AudioTrackState,\n LogLevel,\n SetLogLevelOptions,\n RNKeyProviderOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AACAA,OAAA;AACA,IAAAG,aAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAWA,IAAAK,YAAA,GAAAL,OAAA;AAGA,IAAAM,cAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,cAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAA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MAC3B,OAAO,sCAAsC,CAACC,OAAO,CACnD,OAAO,EACP,UAAUC,CAAC,EAAE;QACX;QACA,MAAMvD,CAAC,GAAIwD,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;QAClC,MAAMC,CAAC,GAAGH,CAAC,KAAK,GAAG,GAAGvD,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG;QACzC,OAAO0D,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC;MACvB,CACF,CAAC;IACH,CAAC;IAED,IAAI,CAACR,MAAM,EAAE;MACXA,MAAM,GAAG,CAAC,CAAyB;MACnCxB,MAAM,CAACwB,MAAM,GAAGA,MAAM;IACxB;IACAA,MAAM,CAACC,UAAU,GAAGC,gBAAgB;EACtC;AACF;AAEA,SAAS/B,cAAcA,CAAA,EAAG;EACxB;EACA,IAAI,OAAOK,MAAM,CAACiC,cAAc,KAAK,WAAW,EAAE;IAChD;IACAjC,MAAM,CAACiC,cAAc,GAAGA,kCAAc;EACxC;;EAEA;EACA,IAAI,OAAOjC,MAAM,CAACkC,cAAc,KAAK,WAAW,EAAE;IAChD;IACAlC,MAAM,CAACkC,cAAc,GAAGA,kCAAc;EACxC;AACF;;AAMwC;AACN;AACP","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -11,15 +11,22 @@ import RNE2EEManager from './e2ee/RNE2EEManager';
|
|
|
11
11
|
import RNKeyProvider from './e2ee/RNKeyProvider';
|
|
12
12
|
import { setupNativeEvents } from './events/EventEmitter';
|
|
13
13
|
import { ReadableStream, WritableStream } from 'web-streams-polyfill';
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
15
|
* Registers the required globals needed for LiveKit to work.
|
|
17
16
|
*
|
|
18
17
|
* Must be called before using LiveKit.
|
|
18
|
+
*
|
|
19
|
+
* @param options Optional configuration for global registration
|
|
19
20
|
*/
|
|
20
|
-
export function registerGlobals() {
|
|
21
|
+
export function registerGlobals(options) {
|
|
22
|
+
const opts = {
|
|
23
|
+
autoConfigureAudioSession: true,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
21
26
|
webrtcRegisterGlobals();
|
|
22
|
-
|
|
27
|
+
if (opts.autoConfigureAudioSession) {
|
|
28
|
+
iosCategoryEnforce();
|
|
29
|
+
}
|
|
23
30
|
livekitRegisterGlobals();
|
|
24
31
|
setupURLPolyfill();
|
|
25
32
|
fixWebrtcAdapter();
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerGlobals","webrtcRegisterGlobals","setupURLPolyfill","AudioSession","AndroidAudioTypePresets","getDefaultAppleAudioConfigurationForMode","PixelRatio","Platform","RNE2EEManager","RNKeyProvider","setupNativeEvents","ReadableStream","WritableStream","iosCategoryEnforce","livekitRegisterGlobals","fixWebrtcAdapter","shimPromiseAllSettled","shimArrayAt","shimCryptoUuid","shimWebstreams","OS","getUserMediaFunc","global","navigator","mediaDevices","getUserMedia","constraints","audio","setAppleAudioConfiguration","audioCategory","lkGlobal","platform","devicePixelRatio","get","LiveKitReactNativeGlobal","_window","window","undefined","userAgent","product","allSettled","require","shim","Array","prototype","at","_global$crypto","crypto","randomUUID","createRandomUUID","replace","c","r","Math","random","v","toString"],"sources":["index.tsx"],"sourcesContent":["import 'well-known-symbols/Symbol.asyncIterator/auto';\nimport 'well-known-symbols/Symbol.iterator/auto';\nimport './polyfills/MediaRecorderShim';\nimport 'react-native-quick-base64';\nimport { registerGlobals as webrtcRegisterGlobals } from '@livekit/react-native-webrtc';\nimport { setupURLPolyfill } from 'react-native-url-polyfill';\nimport './polyfills/EncoderDecoderTogether.min.js';\nimport AudioSession, {\n AndroidAudioTypePresets,\n type AndroidAudioTypeOptions,\n type AppleAudioCategory,\n type AppleAudioCategoryOption,\n type AppleAudioConfiguration,\n type AppleAudioMode,\n type AudioTrackState,\n getDefaultAppleAudioConfigurationForMode,\n} from './audio/AudioSession';\nimport type { AudioConfiguration } from './audio/AudioSession';\nimport { PixelRatio, Platform } from 'react-native';\nimport { type LiveKitReactNativeInfo } from 'livekit-client';\nimport type { LogLevel, SetLogLevelOptions } from './logger';\nimport RNE2EEManager from './e2ee/RNE2EEManager';\nimport RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';\nimport { setupNativeEvents } from './events/EventEmitter';\nimport { ReadableStream, WritableStream } from 'web-streams-polyfill';\n\n/**\n * Registers the required globals needed for LiveKit to work.\n *\n * Must be called before using LiveKit.\n */\nexport function registerGlobals() {\n webrtcRegisterGlobals();\n iosCategoryEnforce();\n livekitRegisterGlobals();\n setupURLPolyfill();\n fixWebrtcAdapter();\n shimPromiseAllSettled();\n shimArrayAt();\n shimCryptoUuid();\n shimWebstreams();\n setupNativeEvents();\n}\n\n/**\n * Enforces changing to playAndRecord category prior to obtaining microphone.\n */\nfunction iosCategoryEnforce() {\n if (Platform.OS === 'ios') {\n // @ts-ignore\n let getUserMediaFunc = global.navigator.mediaDevices.getUserMedia;\n // @ts-ignore\n global.navigator.mediaDevices.getUserMedia = async (constraints: any) => {\n if (constraints.audio) {\n await AudioSession.setAppleAudioConfiguration({\n audioCategory: 'playAndRecord',\n });\n }\n\n return await getUserMediaFunc(constraints);\n };\n }\n}\n\nfunction livekitRegisterGlobals() {\n let lkGlobal: LiveKitReactNativeInfo = {\n platform: Platform.OS,\n devicePixelRatio: PixelRatio.get(),\n };\n\n // @ts-ignore\n global.LiveKitReactNativeGlobal = lkGlobal;\n}\n\nfunction fixWebrtcAdapter() {\n // @ts-ignore\n if (window?.navigator !== undefined) {\n // @ts-ignore\n const { navigator } = window;\n if (navigator.userAgent === undefined) {\n navigator.userAgent = navigator.product ?? 'Unknown';\n }\n }\n}\n\nfunction shimPromiseAllSettled() {\n var allSettled = require('promise.allsettled');\n allSettled.shim();\n}\n\nfunction shimArrayAt() {\n // Some versions of RN don't have Array.prototype.at, which is used by sdp-transform\n if (!Array.prototype.at) {\n var at = require('array.prototype.at');\n at.shim();\n }\n}\n\nfunction shimCryptoUuid() {\n let crypto = global.crypto;\n if (typeof global.crypto?.randomUUID !== 'function') {\n let createRandomUUID = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }\n ) as `${string}-${string}-${string}-${string}-${string}`;\n };\n\n if (!crypto) {\n crypto = {} as typeof global.crypto;\n global.crypto = crypto;\n }\n crypto.randomUUID = createRandomUUID;\n }\n}\n\nfunction shimWebstreams() {\n // @ts-expect-error: global.WritableStream isn't typed here.\n if (typeof global.WritableStream === 'undefined') {\n // @ts-expect-error\n global.WritableStream = WritableStream;\n }\n\n // @ts-expect-error: global.ReadableStream isn't typed here.\n if (typeof global.ReadableStream === 'undefined') {\n // @ts-expect-error\n global.ReadableStream = ReadableStream;\n }\n}\n\nexport * from './hooks';\nexport * from './components/BarVisualizer';\nexport * from './components/LiveKitRoom';\nexport * from './components/VideoTrack';\nexport * from './components/VideoView'; // deprecated\nexport * from './useParticipant'; // deprecated\nexport * from './useRoom'; // deprecated\nexport * from './logger';\nexport * from './audio/AudioManager';\n\nexport {\n AudioSession,\n RNE2EEManager,\n RNKeyProvider,\n AndroidAudioTypePresets,\n getDefaultAppleAudioConfigurationForMode,\n};\nexport type {\n AudioConfiguration,\n AndroidAudioTypeOptions,\n AppleAudioCategory,\n AppleAudioCategoryOption,\n AppleAudioConfiguration,\n AppleAudioMode,\n AudioTrackState,\n LogLevel,\n SetLogLevelOptions,\n RNKeyProviderOptions,\n};\n"],"mappings":"AAAA,OAAO,8CAA8C;AACrD,OAAO,yCAAyC;AAChD,OAAO,+BAA+B;AACtC,OAAO,2BAA2B;AAClC,SAASA,eAAe,IAAIC,qBAAqB,QAAQ,8BAA8B;AACvF,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAO,2CAA2C;AAClD,OAAOC,YAAY,IACjBC,uBAAuB,EAOvBC,wCAAwC,QACnC,sBAAsB;AAE7B,SAASC,UAAU,EAAEC,QAAQ,QAAQ,cAAc;AAGnD,OAAOC,aAAa,MAAM,sBAAsB;AAChD,OAAOC,aAAa,MAAqC,sBAAsB;AAC/E,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,cAAc,EAAEC,cAAc,QAAQ,sBAAsB
|
|
1
|
+
{"version":3,"names":["registerGlobals","webrtcRegisterGlobals","setupURLPolyfill","AudioSession","AndroidAudioTypePresets","getDefaultAppleAudioConfigurationForMode","PixelRatio","Platform","RNE2EEManager","RNKeyProvider","setupNativeEvents","ReadableStream","WritableStream","options","opts","autoConfigureAudioSession","iosCategoryEnforce","livekitRegisterGlobals","fixWebrtcAdapter","shimPromiseAllSettled","shimArrayAt","shimCryptoUuid","shimWebstreams","OS","getUserMediaFunc","global","navigator","mediaDevices","getUserMedia","constraints","audio","setAppleAudioConfiguration","audioCategory","lkGlobal","platform","devicePixelRatio","get","LiveKitReactNativeGlobal","_window","window","undefined","userAgent","product","allSettled","require","shim","Array","prototype","at","_global$crypto","crypto","randomUUID","createRandomUUID","replace","c","r","Math","random","v","toString"],"sources":["index.tsx"],"sourcesContent":["import 'well-known-symbols/Symbol.asyncIterator/auto';\nimport 'well-known-symbols/Symbol.iterator/auto';\nimport './polyfills/MediaRecorderShim';\nimport 'react-native-quick-base64';\nimport { registerGlobals as webrtcRegisterGlobals } from '@livekit/react-native-webrtc';\nimport { setupURLPolyfill } from 'react-native-url-polyfill';\nimport './polyfills/EncoderDecoderTogether.min.js';\nimport AudioSession, {\n AndroidAudioTypePresets,\n type AndroidAudioTypeOptions,\n type AppleAudioCategory,\n type AppleAudioCategoryOption,\n type AppleAudioConfiguration,\n type AppleAudioMode,\n type AudioTrackState,\n getDefaultAppleAudioConfigurationForMode,\n} from './audio/AudioSession';\nimport type { AudioConfiguration } from './audio/AudioSession';\nimport { PixelRatio, Platform } from 'react-native';\nimport { type LiveKitReactNativeInfo } from 'livekit-client';\nimport type { LogLevel, SetLogLevelOptions } from './logger';\nimport RNE2EEManager from './e2ee/RNE2EEManager';\nimport RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';\nimport { setupNativeEvents } from './events/EventEmitter';\nimport { ReadableStream, WritableStream } from 'web-streams-polyfill';\n\nexport interface RegisterGlobalsOptions {\n /**\n * Automatically configure audio session before accessing microphone.\n * When enabled, sets the iOS audio category to 'playAndRecord' before getUserMedia.\n *\n * @default true\n * @platform ios\n */\n autoConfigureAudioSession?: boolean;\n}\n\n/**\n * Registers the required globals needed for LiveKit to work.\n *\n * Must be called before using LiveKit.\n *\n * @param options Optional configuration for global registration\n */\nexport function registerGlobals(options?: RegisterGlobalsOptions) {\n const opts = {\n autoConfigureAudioSession: true,\n ...options,\n };\n\n webrtcRegisterGlobals();\n if (opts.autoConfigureAudioSession) {\n iosCategoryEnforce();\n }\n livekitRegisterGlobals();\n setupURLPolyfill();\n fixWebrtcAdapter();\n shimPromiseAllSettled();\n shimArrayAt();\n shimCryptoUuid();\n shimWebstreams();\n setupNativeEvents();\n}\n\n/**\n * Enforces changing to playAndRecord category prior to obtaining microphone.\n */\nfunction iosCategoryEnforce() {\n if (Platform.OS === 'ios') {\n // @ts-ignore\n let getUserMediaFunc = global.navigator.mediaDevices.getUserMedia;\n // @ts-ignore\n global.navigator.mediaDevices.getUserMedia = async (constraints: any) => {\n if (constraints.audio) {\n await AudioSession.setAppleAudioConfiguration({\n audioCategory: 'playAndRecord',\n });\n }\n\n return await getUserMediaFunc(constraints);\n };\n }\n}\n\nfunction livekitRegisterGlobals() {\n let lkGlobal: LiveKitReactNativeInfo = {\n platform: Platform.OS,\n devicePixelRatio: PixelRatio.get(),\n };\n\n // @ts-ignore\n global.LiveKitReactNativeGlobal = lkGlobal;\n}\n\nfunction fixWebrtcAdapter() {\n // @ts-ignore\n if (window?.navigator !== undefined) {\n // @ts-ignore\n const { navigator } = window;\n if (navigator.userAgent === undefined) {\n navigator.userAgent = navigator.product ?? 'Unknown';\n }\n }\n}\n\nfunction shimPromiseAllSettled() {\n var allSettled = require('promise.allsettled');\n allSettled.shim();\n}\n\nfunction shimArrayAt() {\n // Some versions of RN don't have Array.prototype.at, which is used by sdp-transform\n if (!Array.prototype.at) {\n var at = require('array.prototype.at');\n at.shim();\n }\n}\n\nfunction shimCryptoUuid() {\n let crypto = global.crypto;\n if (typeof global.crypto?.randomUUID !== 'function') {\n let createRandomUUID = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }\n ) as `${string}-${string}-${string}-${string}-${string}`;\n };\n\n if (!crypto) {\n crypto = {} as typeof global.crypto;\n global.crypto = crypto;\n }\n crypto.randomUUID = createRandomUUID;\n }\n}\n\nfunction shimWebstreams() {\n // @ts-expect-error: global.WritableStream isn't typed here.\n if (typeof global.WritableStream === 'undefined') {\n // @ts-expect-error\n global.WritableStream = WritableStream;\n }\n\n // @ts-expect-error: global.ReadableStream isn't typed here.\n if (typeof global.ReadableStream === 'undefined') {\n // @ts-expect-error\n global.ReadableStream = ReadableStream;\n }\n}\n\nexport * from './hooks';\nexport * from './components/BarVisualizer';\nexport * from './components/LiveKitRoom';\nexport * from './components/VideoTrack';\nexport * from './components/VideoView'; // deprecated\nexport * from './useParticipant'; // deprecated\nexport * from './useRoom'; // deprecated\nexport * from './logger';\nexport * from './audio/AudioManager';\n\nexport {\n AudioSession,\n RNE2EEManager,\n RNKeyProvider,\n AndroidAudioTypePresets,\n getDefaultAppleAudioConfigurationForMode,\n};\nexport type {\n AudioConfiguration,\n AndroidAudioTypeOptions,\n AppleAudioCategory,\n AppleAudioCategoryOption,\n AppleAudioConfiguration,\n AppleAudioMode,\n AudioTrackState,\n LogLevel,\n SetLogLevelOptions,\n RNKeyProviderOpt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,uBAAbA,cAAA,CAAeE,UAAU,MAAK,UAAU,EAAE;IACnD,IAAIC,gBAAgB,GAAGA,CAAA,KAAM;MAC3B,OAAO,sCAAsC,CAACC,OAAO,CACnD,OAAO,EACP,UAAUC,CAAC,EAAE;QACX;QACA,MAAMC,CAAC,GAAIC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;QAClC,MAAMC,CAAC,GAAGJ,CAAC,KAAK,GAAG,GAAGC,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG;QACzC,OAAOG,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC;MACvB,CACF,CAAC;IACH,CAAC;IAED,IAAI,CAACT,MAAM,EAAE;MACXA,MAAM,GAAG,CAAC,CAAyB;MACnCzB,MAAM,CAACyB,MAAM,GAAGA,MAAM;IACxB;IACAA,MAAM,CAACC,UAAU,GAAGC,gBAAgB;EACtC;AACF;AAEA,SAAS9B,cAAcA,CAAA,EAAG;EACxB;EACA,IAAI,OAAOG,MAAM,CAACb,cAAc,KAAK,WAAW,EAAE;IAChD;IACAa,MAAM,CAACb,cAAc,GAAGA,cAAc;EACxC;;EAEA;EACA,IAAI,OAAOa,MAAM,CAACd,cAAc,KAAK,WAAW,EAAE;IAChD;IACAc,MAAM,CAACd,cAAc,GAAGA,cAAc;EACxC;AACF;AAEA,cAAc,SAAS;AACvB,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,wBAAwB,CAAC,CAAC;AACxC,cAAc,kBAAkB,CAAC,CAAC;AAClC,cAAc,WAAW,CAAC,CAAC;AAC3B,cAAc,UAAU;AACxB,cAAc,sBAAsB;AAEpC,SACER,YAAY,EACZK,aAAa,EACbC,aAAa,EACbL,uBAAuB,EACvBC,wCAAwC","ignoreList":[]}
|
|
@@ -8,5 +8,7 @@ export const getDefaultAppleAudioConfigurationForMode: any;
|
|
|
8
8
|
* Registers the required globals needed for LiveKit to work.
|
|
9
9
|
*
|
|
10
10
|
* Must be called before using LiveKit.
|
|
11
|
+
*
|
|
12
|
+
* @param options Optional configuration for global registration
|
|
11
13
|
*/
|
|
12
|
-
export function registerGlobals(): void;
|
|
14
|
+
export function registerGlobals(options: any): void;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Registers the required globals needed for LiveKit to work.
|
|
3
3
|
*
|
|
4
4
|
* Must be called before using LiveKit.
|
|
5
|
+
*
|
|
6
|
+
* @param options Optional configuration for global registration
|
|
5
7
|
*/
|
|
6
|
-
export function registerGlobals(): void;
|
|
8
|
+
export function registerGlobals(options: any): void;
|
|
7
9
|
export * from "./hooks";
|
|
8
10
|
export * from "./components/BarVisualizer";
|
|
9
11
|
export * from "./components/LiveKitRoom";
|
|
@@ -8,12 +8,24 @@ import type { AudioConfiguration } from './audio/AudioSession';
|
|
|
8
8
|
import type { LogLevel, SetLogLevelOptions } from './logger';
|
|
9
9
|
import RNE2EEManager from './e2ee/RNE2EEManager';
|
|
10
10
|
import RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';
|
|
11
|
+
export interface RegisterGlobalsOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Automatically configure audio session before accessing microphone.
|
|
14
|
+
* When enabled, sets the iOS audio category to 'playAndRecord' before getUserMedia.
|
|
15
|
+
*
|
|
16
|
+
* @default true
|
|
17
|
+
* @platform ios
|
|
18
|
+
*/
|
|
19
|
+
autoConfigureAudioSession?: boolean;
|
|
20
|
+
}
|
|
11
21
|
/**
|
|
12
22
|
* Registers the required globals needed for LiveKit to work.
|
|
13
23
|
*
|
|
14
24
|
* Must be called before using LiveKit.
|
|
25
|
+
*
|
|
26
|
+
* @param options Optional configuration for global registration
|
|
15
27
|
*/
|
|
16
|
-
export declare function registerGlobals(): void;
|
|
28
|
+
export declare function registerGlobals(options?: RegisterGlobalsOptions): void;
|
|
17
29
|
export * from './hooks';
|
|
18
30
|
export * from './components/BarVisualizer';
|
|
19
31
|
export * from './components/LiveKitRoom';
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -24,14 +24,34 @@ import RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';
|
|
|
24
24
|
import { setupNativeEvents } from './events/EventEmitter';
|
|
25
25
|
import { ReadableStream, WritableStream } from 'web-streams-polyfill';
|
|
26
26
|
|
|
27
|
+
export interface RegisterGlobalsOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Automatically configure audio session before accessing microphone.
|
|
30
|
+
* When enabled, sets the iOS audio category to 'playAndRecord' before getUserMedia.
|
|
31
|
+
*
|
|
32
|
+
* @default true
|
|
33
|
+
* @platform ios
|
|
34
|
+
*/
|
|
35
|
+
autoConfigureAudioSession?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* Registers the required globals needed for LiveKit to work.
|
|
29
40
|
*
|
|
30
41
|
* Must be called before using LiveKit.
|
|
42
|
+
*
|
|
43
|
+
* @param options Optional configuration for global registration
|
|
31
44
|
*/
|
|
32
|
-
export function registerGlobals() {
|
|
45
|
+
export function registerGlobals(options?: RegisterGlobalsOptions) {
|
|
46
|
+
const opts = {
|
|
47
|
+
autoConfigureAudioSession: true,
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
|
|
33
51
|
webrtcRegisterGlobals();
|
|
34
|
-
|
|
52
|
+
if (opts.autoConfigureAudioSession) {
|
|
53
|
+
iosCategoryEnforce();
|
|
54
|
+
}
|
|
35
55
|
livekitRegisterGlobals();
|
|
36
56
|
setupURLPolyfill();
|
|
37
57
|
fixWebrtcAdapter();
|