@livekit/react-native 2.2.0 → 2.3.0
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/README.md +14 -5
- package/android/build.gradle +1 -1
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/android/gradlew +29 -14
- package/android/gradlew.bat +19 -16
- package/android/src/main/java/com/livekit/reactnative/video/SimulcastVideoEncoderFactoryWrapper.kt +2 -2
- package/lib/commonjs/audio/AudioManager.js +4 -27
- package/lib/commonjs/audio/AudioManager.js.map +1 -1
- package/lib/commonjs/audio/AudioSession.js +55 -21
- package/lib/commonjs/audio/AudioSession.js.map +1 -1
- package/lib/commonjs/components/LiveKitRoom.js +3 -6
- package/lib/commonjs/components/LiveKitRoom.js.map +1 -1
- package/lib/commonjs/components/VideoTrack.js +30 -66
- package/lib/commonjs/components/VideoTrack.js.map +1 -1
- package/lib/commonjs/components/VideoView.js +32 -63
- package/lib/commonjs/components/VideoView.js.map +1 -1
- package/lib/commonjs/components/ViewPortDetector.js +15 -62
- package/lib/commonjs/components/ViewPortDetector.js.map +1 -1
- package/lib/commonjs/hooks.js +0 -63
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +9 -84
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/logger.js +4 -14
- package/lib/commonjs/logger.js.map +1 -1
- package/lib/commonjs/polyfills/EncoderDecoderTogether.min.js +16 -42
- package/lib/commonjs/polyfills/EncoderDecoderTogether.min.js.map +1 -1
- package/lib/commonjs/useParticipant.js +5 -13
- package/lib/commonjs/useParticipant.js.map +1 -1
- package/lib/commonjs/useRoom.js +17 -33
- package/lib/commonjs/useRoom.js.map +1 -1
- package/lib/module/audio/AudioManager.js +3 -17
- package/lib/module/audio/AudioManager.js.map +1 -1
- package/lib/module/audio/AudioSession.js +54 -14
- package/lib/module/audio/AudioSession.js.map +1 -1
- package/lib/module/components/LiveKitRoom.js +1 -0
- package/lib/module/components/LiveKitRoom.js.map +1 -1
- package/lib/module/components/VideoTrack.js +18 -44
- package/lib/module/components/VideoTrack.js.map +1 -1
- package/lib/module/components/VideoView.js +18 -42
- package/lib/module/components/VideoView.js.map +1 -1
- package/lib/module/components/ViewPortDetector.js +13 -54
- package/lib/module/components/ViewPortDetector.js.map +1 -1
- package/lib/module/hooks.js +1 -2
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +5 -23
- package/lib/module/index.js.map +1 -1
- package/lib/module/logger.js +2 -6
- package/lib/module/logger.js.map +1 -1
- package/lib/module/polyfills/EncoderDecoderTogether.min.js +16 -42
- package/lib/module/polyfills/EncoderDecoderTogether.min.js.map +1 -1
- package/lib/module/useParticipant.js +5 -11
- package/lib/module/useParticipant.js.map +1 -1
- package/lib/module/useRoom.js +17 -30
- package/lib/module/useRoom.js.map +1 -1
- package/lib/typescript/babel.config.d.ts +1 -0
- package/lib/typescript/docs/assets/icons.d.ts +0 -0
- package/lib/typescript/docs/assets/main.d.ts +0 -0
- package/lib/typescript/docs/assets/navigation.d.ts +0 -0
- package/lib/typescript/docs/assets/search.d.ts +0 -0
- package/lib/typescript/lib/commonjs/audio/AudioManager.d.ts +10 -0
- package/lib/typescript/lib/commonjs/audio/AudioSession.d.ts +33 -0
- package/lib/typescript/lib/commonjs/components/LiveKitRoom.d.ts +20 -0
- package/lib/typescript/lib/commonjs/components/VideoTrack.d.ts +8 -0
- package/lib/typescript/lib/commonjs/components/VideoView.d.ts +14 -0
- package/lib/typescript/lib/commonjs/components/ViewPortDetector.d.ts +30 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts +29 -0
- package/lib/typescript/lib/commonjs/index.d.ts +10 -0
- package/lib/typescript/lib/commonjs/logger.d.ts +8 -0
- package/lib/typescript/lib/commonjs/useParticipant.d.ts +14 -0
- package/lib/typescript/lib/commonjs/useRoom.d.ts +16 -0
- package/lib/typescript/lib/module/audio/AudioManager.d.ts +9 -0
- package/lib/typescript/lib/module/audio/AudioSession.d.ts +31 -0
- package/lib/typescript/lib/module/components/LiveKitRoom.d.ts +22 -0
- package/lib/typescript/lib/module/components/VideoTrack.d.ts +9 -0
- package/lib/typescript/lib/module/components/VideoView.d.ts +9 -0
- package/lib/typescript/lib/module/components/ViewPortDetector.d.ts +29 -0
- package/lib/typescript/lib/module/hooks.d.ts +1 -0
- package/lib/typescript/lib/module/index.d.ts +18 -0
- package/lib/typescript/lib/module/logger.d.ts +8 -0
- package/lib/typescript/lib/module/polyfills/EncoderDecoderTogether.min.d.ts +0 -0
- package/lib/typescript/lib/module/useParticipant.d.ts +13 -0
- package/lib/typescript/lib/module/useRoom.d.ts +15 -0
- package/lib/typescript/scripts/bootstrap.d.ts +1 -0
- package/lib/typescript/{audio → src/audio}/AudioSession.d.ts +7 -7
- package/lib/typescript/{components → src/components}/LiveKitRoom.d.ts +1 -1
- package/lib/typescript/{components → src/components}/VideoTrack.d.ts +2 -2
- package/lib/typescript/{components → src/components}/VideoView.d.ts +3 -3
- package/lib/typescript/{components → src/components}/ViewPortDetector.d.ts +3 -3
- package/lib/typescript/src/hooks.d.ts +3 -0
- package/lib/typescript/{index.d.ts → src/index.d.ts} +3 -2
- package/lib/typescript/{logger.d.ts → src/logger.d.ts} +2 -2
- package/lib/typescript/src/polyfills/EncoderDecoderTogether.min.d.ts +0 -0
- package/lib/typescript/{useRoom.d.ts → src/useRoom.d.ts} +1 -1
- package/package.json +22 -18
- package/src/components/LiveKitRoom.tsx +1 -1
- package/src/components/VideoTrack.tsx +7 -2
- package/src/components/VideoView.tsx +8 -3
- package/src/components/ViewPortDetector.tsx +4 -4
- package/src/hooks.ts +11 -9
- package/src/index.tsx +10 -8
- package/src/useRoom.ts +1 -1
- package/lib/typescript/hooks.d.ts +0 -2
- /package/lib/typescript/{audio → src/audio}/AudioManager.d.ts +0 -0
- /package/lib/typescript/{useParticipant.d.ts → src/useParticipant.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -295,11 +295,20 @@ Enabling screenshare requires extra installation steps:
|
|
|
295
295
|
|
|
296
296
|
Android screenshare requires a foreground service with type `mediaProjection` to be present.
|
|
297
297
|
|
|
298
|
-
The example app uses [@
|
|
299
|
-
|
|
298
|
+
The example app uses [@supersami/rn-foreground-service](https://github.com/Raja0sama/rn-foreground-service) for this.
|
|
299
|
+
|
|
300
|
+
Add the following permissions to your `AndroidManifest.xml` file:
|
|
301
|
+
|
|
302
|
+
```xml
|
|
303
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
304
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Declare the the service and ensure it's labelled a `mediaProjection` service like so:
|
|
300
308
|
|
|
301
309
|
```xml
|
|
302
|
-
<service android:name="com.
|
|
310
|
+
<service android:name="com.supersami.foregroundservice.ForegroundService" android:foregroundServiceType="mediaProjection" />
|
|
311
|
+
<service android:name="com.supersami.foregroundservice.ForegroundServiceTask" />
|
|
303
312
|
```
|
|
304
313
|
|
|
305
314
|
Once setup, start the foreground service prior to using screenshare.
|
|
@@ -370,8 +379,8 @@ Apache License 2.0
|
|
|
370
379
|
<br/><table>
|
|
371
380
|
<thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
|
|
372
381
|
<tbody>
|
|
373
|
-
<tr><td>Real-time SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <a href="https://github.com/livekit/client-sdk-js">
|
|
374
|
-
<tr><td>Server APIs</td><td><a href="https://github.com/livekit/
|
|
382
|
+
<tr><td>Real-time SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <a href="https://github.com/livekit/client-sdk-js">Browser</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <b>React Native</b> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
|
|
383
|
+
<tr><td>Server APIs</td><td><a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a></td></tr><tr></tr>
|
|
375
384
|
<tr><td>Agents Frameworks</td><td><a href="https://github.com/livekit/agents">Python</a> · <a href="https://github.com/livekit/agent-playground">Playground</a></td></tr><tr></tr>
|
|
376
385
|
<tr><td>Services</td><td><a href="https://github.com/livekit/livekit">Livekit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a> · <a href="https://github.com/livekit/sip">SIP</a></td></tr><tr></tr>
|
|
377
386
|
<tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/oss/deployment">Self-hosting</a> · <a href="https://github.com/livekit/livekit-cli">CLI</a></td></tr>
|
package/android/build.gradle
CHANGED
|
@@ -130,7 +130,7 @@ dependencies {
|
|
|
130
130
|
api 'com.facebook.react:react-native:+'
|
|
131
131
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
132
132
|
api 'com.github.davidliu:audioswitch:89582c47c9a04c62f90aa5e57251af4800a62c9a'
|
|
133
|
-
api 'io.github.webrtc-sdk:android:
|
|
133
|
+
api 'io.github.webrtc-sdk:android:125.6422.02'
|
|
134
134
|
implementation project(':livekit_react-native-webrtc')
|
|
135
135
|
implementation "androidx.annotation:annotation:1.4.0"
|
|
136
136
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
|
|
4
|
+
networkTimeout=10000
|
|
5
|
+
validateDistributionUrl=true
|
|
4
6
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
7
|
zipStorePath=wrapper/dists
|
package/android/gradlew
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
# Darwin, MinGW, and NonStop.
|
|
56
56
|
#
|
|
57
57
|
# (3) This script is generated from the Groovy template
|
|
58
|
-
# https://github.com/gradle/gradle/blob/
|
|
58
|
+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
59
59
|
# within the Gradle project.
|
|
60
60
|
#
|
|
61
61
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
@@ -80,13 +80,11 @@ do
|
|
|
80
80
|
esac
|
|
81
81
|
done
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
APP_NAME="Gradle"
|
|
83
|
+
# This is normally unused
|
|
84
|
+
# shellcheck disable=SC2034
|
|
86
85
|
APP_BASE_NAME=${0##*/}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
86
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
87
|
+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
|
90
88
|
|
|
91
89
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
90
|
MAX_FD=maximum
|
|
@@ -133,22 +131,29 @@ location of your Java installation."
|
|
|
133
131
|
fi
|
|
134
132
|
else
|
|
135
133
|
JAVACMD=java
|
|
136
|
-
|
|
134
|
+
if ! command -v java >/dev/null 2>&1
|
|
135
|
+
then
|
|
136
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
137
137
|
|
|
138
138
|
Please set the JAVA_HOME variable in your environment to match the
|
|
139
139
|
location of your Java installation."
|
|
140
|
+
fi
|
|
140
141
|
fi
|
|
141
142
|
|
|
142
143
|
# Increase the maximum file descriptors if we can.
|
|
143
144
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
144
145
|
case $MAX_FD in #(
|
|
145
146
|
max*)
|
|
147
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
148
|
+
# shellcheck disable=SC2039,SC3045
|
|
146
149
|
MAX_FD=$( ulimit -H -n ) ||
|
|
147
150
|
warn "Could not query maximum file descriptor limit"
|
|
148
151
|
esac
|
|
149
152
|
case $MAX_FD in #(
|
|
150
153
|
'' | soft) :;; #(
|
|
151
154
|
*)
|
|
155
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
156
|
+
# shellcheck disable=SC2039,SC3045
|
|
152
157
|
ulimit -n "$MAX_FD" ||
|
|
153
158
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
154
159
|
esac
|
|
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|
|
193
198
|
done
|
|
194
199
|
fi
|
|
195
200
|
|
|
196
|
-
|
|
197
|
-
#
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#
|
|
201
|
+
|
|
202
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
203
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
204
|
+
|
|
205
|
+
# Collect all arguments for the java command:
|
|
206
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
207
|
+
# and any embedded shellness will be escaped.
|
|
208
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
209
|
+
# treated as '${Hostname}' itself on the command line.
|
|
201
210
|
|
|
202
211
|
set -- \
|
|
203
212
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
@@ -205,6 +214,12 @@ set -- \
|
|
|
205
214
|
org.gradle.wrapper.GradleWrapperMain \
|
|
206
215
|
"$@"
|
|
207
216
|
|
|
217
|
+
# Stop when "xargs" is not available.
|
|
218
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
219
|
+
then
|
|
220
|
+
die "xargs is not available"
|
|
221
|
+
fi
|
|
222
|
+
|
|
208
223
|
# Use "xargs" to parse quoted args.
|
|
209
224
|
#
|
|
210
225
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
@@ -231,4 +246,4 @@ eval "set -- $(
|
|
|
231
246
|
tr '\n' ' '
|
|
232
247
|
)" '"$@"'
|
|
233
248
|
|
|
234
|
-
exec "$JAVACMD" "$@"
|
|
249
|
+
exec "$JAVACMD" "$@"
|
package/android/gradlew.bat
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
@rem limitations under the License.
|
|
15
15
|
@rem
|
|
16
16
|
|
|
17
|
-
@if "%DEBUG%"
|
|
17
|
+
@if "%DEBUG%"=="" @echo off
|
|
18
18
|
@rem ##########################################################################
|
|
19
19
|
@rem
|
|
20
20
|
@rem Gradle startup script for Windows
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
if "%OS%"=="Windows_NT" setlocal
|
|
26
26
|
|
|
27
27
|
set DIRNAME=%~dp0
|
|
28
|
-
if "%DIRNAME%"
|
|
28
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
29
|
+
@rem This is normally unused
|
|
29
30
|
set APP_BASE_NAME=%~n0
|
|
30
31
|
set APP_HOME=%DIRNAME%
|
|
31
32
|
|
|
@@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|
|
40
41
|
|
|
41
42
|
set JAVA_EXE=java.exe
|
|
42
43
|
%JAVA_EXE% -version >NUL 2>&1
|
|
43
|
-
if
|
|
44
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
44
45
|
|
|
45
|
-
echo.
|
|
46
|
-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
47
|
-
echo.
|
|
48
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
49
|
-
echo location of your Java installation.
|
|
46
|
+
echo. 1>&2
|
|
47
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
50
|
+
echo location of your Java installation. 1>&2
|
|
50
51
|
|
|
51
52
|
goto fail
|
|
52
53
|
|
|
@@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
|
56
57
|
|
|
57
58
|
if exist "%JAVA_EXE%" goto execute
|
|
58
59
|
|
|
59
|
-
echo.
|
|
60
|
-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
61
|
-
echo.
|
|
62
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
63
|
-
echo location of your Java installation.
|
|
60
|
+
echo. 1>&2
|
|
61
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
64
|
+
echo location of your Java installation. 1>&2
|
|
64
65
|
|
|
65
66
|
goto fail
|
|
66
67
|
|
|
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
|
75
76
|
|
|
76
77
|
:end
|
|
77
78
|
@rem End local scope for the variables with windows NT shell
|
|
78
|
-
if
|
|
79
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
79
80
|
|
|
80
81
|
:fail
|
|
81
82
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
82
83
|
rem the _cmd.exe /c_ return code!
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
85
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
86
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
87
|
+
exit /b %EXIT_CODE%
|
|
85
88
|
|
|
86
89
|
:mainEnd
|
|
87
90
|
if "%OS%"=="Windows_NT" endlocal
|
package/android/src/main/java/com/livekit/reactnative/video/SimulcastVideoEncoderFactoryWrapper.kt
CHANGED
|
@@ -181,8 +181,8 @@ open class SimulcastVideoEncoderFactoryWrapper(
|
|
|
181
181
|
return future.get()
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
override fun
|
|
185
|
-
val future = executor.submit(Callable { return@Callable encoder.
|
|
184
|
+
override fun createNative(webrtcEnvRef: Long): Long {
|
|
185
|
+
val future = executor.submit(Callable { return@Callable encoder.createNative(webrtcEnvRef) })
|
|
186
186
|
return future.get()
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useIOSAudioManagement = useIOSAudioManagement;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
9
|
var _livekitClient = require("livekit-client");
|
|
13
|
-
|
|
14
10
|
var _AudioSession = _interopRequireWildcard(require("./AudioSession"));
|
|
15
|
-
|
|
16
11
|
var _ = require("..");
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
14
|
/**
|
|
23
15
|
* Handles setting the appropriate AVAudioSession options automatically
|
|
24
16
|
* depending on the audio track states of the Room.
|
|
@@ -27,9 +19,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
19
|
* @param preferSpeakerOutput
|
|
28
20
|
* @param onConfigureNativeAudio A custom method for determining options used.
|
|
29
21
|
*/
|
|
30
|
-
function useIOSAudioManagement(room) {
|
|
31
|
-
let preferSpeakerOutput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
32
|
-
let onConfigureNativeAudio = arguments.length > 2 ? arguments[2] : undefined;
|
|
22
|
+
function useIOSAudioManagement(room, preferSpeakerOutput = true, onConfigureNativeAudio) {
|
|
33
23
|
const [localTrackCount, setLocalTrackCount] = (0, _react.useState)(0);
|
|
34
24
|
const [remoteTrackCount, setRemoteTrackCount] = (0, _react.useState)(0);
|
|
35
25
|
const trackState = (0, _react.useMemo)(() => computeAudioTrackState(localTrackCount, remoteTrackCount), [localTrackCount, remoteTrackCount]);
|
|
@@ -38,7 +28,6 @@ function useIOSAudioManagement(room) {
|
|
|
38
28
|
setLocalTrackCount(getLocalAudioTrackCount(room));
|
|
39
29
|
setRemoteTrackCount(getRemoteAudioTrackCount(room));
|
|
40
30
|
};
|
|
41
|
-
|
|
42
31
|
recalculateTrackCounts();
|
|
43
32
|
room.on(_livekitClient.RoomEvent.Connected, recalculateTrackCounts);
|
|
44
33
|
return () => {
|
|
@@ -49,31 +38,24 @@ function useIOSAudioManagement(room) {
|
|
|
49
38
|
if (_reactNative.Platform.OS !== 'ios') {
|
|
50
39
|
return () => {};
|
|
51
40
|
}
|
|
52
|
-
|
|
53
41
|
let onLocalPublished = () => {
|
|
54
42
|
setLocalTrackCount(localTrackCount + 1);
|
|
55
43
|
};
|
|
56
|
-
|
|
57
44
|
let onLocalUnpublished = () => {
|
|
58
45
|
if (localTrackCount - 1 < 0) {
|
|
59
46
|
_.log.warn('mismatched local audio track count! attempted to reduce track count below zero.');
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
setLocalTrackCount(Math.max(localTrackCount - 1, 0));
|
|
63
49
|
};
|
|
64
|
-
|
|
65
50
|
let onRemotePublished = () => {
|
|
66
51
|
setRemoteTrackCount(remoteTrackCount + 1);
|
|
67
52
|
};
|
|
68
|
-
|
|
69
53
|
let onRemoteUnpublished = () => {
|
|
70
54
|
if (remoteTrackCount - 1 < 0) {
|
|
71
55
|
_.log.warn('mismatched remote audio track count! attempted to reduce track count below zero.');
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
setRemoteTrackCount(Math.max(remoteTrackCount - 1, 0));
|
|
75
58
|
};
|
|
76
|
-
|
|
77
59
|
room.on(_livekitClient.RoomEvent.LocalTrackPublished, onLocalPublished).on(_livekitClient.RoomEvent.LocalTrackUnpublished, onLocalUnpublished).on(_livekitClient.RoomEvent.TrackPublished, onRemotePublished).on(_livekitClient.RoomEvent.TrackUnpublished, onRemoteUnpublished);
|
|
78
60
|
return () => {
|
|
79
61
|
room.off(_livekitClient.RoomEvent.LocalTrackPublished, onLocalPublished).off(_livekitClient.RoomEvent.LocalTrackUnpublished, onLocalUnpublished).off(_livekitClient.RoomEvent.TrackPublished, onRemotePublished).off(_livekitClient.RoomEvent.TrackUnpublished, onRemoteUnpublished);
|
|
@@ -83,14 +65,11 @@ function useIOSAudioManagement(room) {
|
|
|
83
65
|
if (_reactNative.Platform.OS !== 'ios') {
|
|
84
66
|
return;
|
|
85
67
|
}
|
|
86
|
-
|
|
87
|
-
let configFunc = onConfigureNativeAudio !== null && onConfigureNativeAudio !== void 0 ? onConfigureNativeAudio : _AudioSession.getDefaultAppleAudioConfigurationForMode;
|
|
68
|
+
let configFunc = onConfigureNativeAudio ?? _AudioSession.getDefaultAppleAudioConfigurationForMode;
|
|
88
69
|
let audioConfig = configFunc(trackState, preferSpeakerOutput);
|
|
89
|
-
|
|
90
70
|
_AudioSession.default.setAppleAudioConfiguration(audioConfig);
|
|
91
71
|
}, [trackState, onConfigureNativeAudio, preferSpeakerOutput]);
|
|
92
72
|
}
|
|
93
|
-
|
|
94
73
|
function computeAudioTrackState(localTracks, remoteTracks) {
|
|
95
74
|
if (localTracks > 0 && remoteTracks > 0) {
|
|
96
75
|
return 'localAndRemote';
|
|
@@ -102,11 +81,9 @@ function computeAudioTrackState(localTracks, remoteTracks) {
|
|
|
102
81
|
return 'none';
|
|
103
82
|
}
|
|
104
83
|
}
|
|
105
|
-
|
|
106
84
|
function getLocalAudioTrackCount(room) {
|
|
107
85
|
return room.localParticipant.audioTrackPublications.size;
|
|
108
86
|
}
|
|
109
|
-
|
|
110
87
|
function getRemoteAudioTrackCount(room) {
|
|
111
88
|
var audioTracks = 0;
|
|
112
89
|
room.remoteParticipants.forEach(participant => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_livekitClient","_AudioSession","_interopRequireWildcard","_","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useIOSAudioManagement","room","preferSpeakerOutput","onConfigureNativeAudio","localTrackCount","setLocalTrackCount","useState","remoteTrackCount","setRemoteTrackCount","trackState","useMemo","computeAudioTrackState","useEffect","recalculateTrackCounts","getLocalAudioTrackCount","getRemoteAudioTrackCount","on","RoomEvent","Connected","off","Platform","OS","onLocalPublished","onLocalUnpublished","log","warn","Math","max","onRemotePublished","onRemoteUnpublished","LocalTrackPublished","LocalTrackUnpublished","TrackPublished","TrackUnpublished","configFunc","getDefaultAppleAudioConfigurationForMode","audioConfig","AudioSession","setAppleAudioConfiguration","localTracks","remoteTracks","localParticipant","audioTrackPublications","size","audioTracks","remoteParticipants","forEach","participant"],"sources":["AudioManager.ts"],"sourcesContent":["import { useState, useEffect, useMemo } from 'react';\nimport { Platform } from 'react-native';\nimport { RoomEvent, Room } from 'livekit-client';\nimport AudioSession, {\n getDefaultAppleAudioConfigurationForMode,\n type AppleAudioConfiguration,\n type AudioTrackState,\n} from './AudioSession';\nimport { log } from '..';\n\n/**\n * Handles setting the appropriate AVAudioSession options automatically\n * depending on the audio track states of the Room.\n *\n * @param room\n * @param preferSpeakerOutput\n * @param onConfigureNativeAudio A custom method for determining options used.\n */\nexport function useIOSAudioManagement(\n room: Room,\n preferSpeakerOutput: boolean = true,\n onConfigureNativeAudio?: (\n trackState: AudioTrackState,\n preferSpeakerOutput: boolean\n ) => AppleAudioConfiguration\n) {\n const [localTrackCount, setLocalTrackCount] = useState(0);\n const [remoteTrackCount, setRemoteTrackCount] = useState(0);\n const trackState = useMemo(\n () => computeAudioTrackState(localTrackCount, remoteTrackCount),\n [localTrackCount, remoteTrackCount]\n );\n\n useEffect(() => {\n let recalculateTrackCounts = () => {\n setLocalTrackCount(getLocalAudioTrackCount(room));\n setRemoteTrackCount(getRemoteAudioTrackCount(room));\n };\n\n recalculateTrackCounts();\n\n room.on(RoomEvent.Connected, recalculateTrackCounts);\n\n return () => {\n room.off(RoomEvent.Connected, recalculateTrackCounts);\n };\n }, [room]);\n useEffect(() => {\n if (Platform.OS !== 'ios') {\n return () => {};\n }\n\n let onLocalPublished = () => {\n setLocalTrackCount(localTrackCount + 1);\n };\n let onLocalUnpublished = () => {\n if (localTrackCount - 1 < 0) {\n log.warn(\n 'mismatched local audio track count! attempted to reduce track count below zero.'\n );\n }\n setLocalTrackCount(Math.max(localTrackCount - 1, 0));\n };\n let onRemotePublished = () => {\n setRemoteTrackCount(remoteTrackCount + 1);\n };\n let onRemoteUnpublished = () => {\n if (remoteTrackCount - 1 < 0) {\n log.warn(\n 'mismatched remote audio track count! attempted to reduce track count below zero.'\n );\n }\n setRemoteTrackCount(Math.max(remoteTrackCount - 1, 0));\n };\n\n room\n .on(RoomEvent.LocalTrackPublished, onLocalPublished)\n .on(RoomEvent.LocalTrackUnpublished, onLocalUnpublished)\n .on(RoomEvent.TrackPublished, onRemotePublished)\n .on(RoomEvent.TrackUnpublished, onRemoteUnpublished);\n\n return () => {\n room\n .off(RoomEvent.LocalTrackPublished, onLocalPublished)\n .off(RoomEvent.LocalTrackUnpublished, onLocalUnpublished)\n .off(RoomEvent.TrackPublished, onRemotePublished)\n .off(RoomEvent.TrackUnpublished, onRemoteUnpublished);\n };\n }, [room, localTrackCount, remoteTrackCount]);\n\n useEffect(() => {\n if (Platform.OS !== 'ios') {\n return;\n }\n\n let configFunc =\n onConfigureNativeAudio ?? getDefaultAppleAudioConfigurationForMode;\n let audioConfig = configFunc(trackState, preferSpeakerOutput);\n AudioSession.setAppleAudioConfiguration(audioConfig);\n }, [trackState, onConfigureNativeAudio, preferSpeakerOutput]);\n}\n\nfunction computeAudioTrackState(\n localTracks: number,\n remoteTracks: number\n): AudioTrackState {\n if (localTracks > 0 && remoteTracks > 0) {\n return 'localAndRemote';\n } else if (localTracks > 0 && remoteTracks === 0) {\n return 'localOnly';\n } else if (localTracks === 0 && remoteTracks > 0) {\n return 'remoteOnly';\n } else {\n return 'none';\n }\n}\n\nfunction getLocalAudioTrackCount(room: Room): number {\n return room.localParticipant.audioTrackPublications.size;\n}\n\nfunction getRemoteAudioTrackCount(room: Room): number {\n var audioTracks = 0;\n room.remoteParticipants.forEach((participant) => {\n audioTracks += participant.audioTrackPublications.size;\n });\n\n return audioTracks;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAKA,IAAAK,CAAA,GAAAL,OAAA;AAAyB,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,o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,kBAAkB,CAACC,OAAO,CAAEC,WAAW,IAAK;IAC/CH,WAAW,IAAIG,WAAW,CAACL,sBAAsB,CAACC,IAAI;EACxD,CAAC,CAAC;EAEF,OAAOC,WAAW;AACpB","ignoreList":[]}
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.AndroidAudioTypePresets = void 0;
|
|
7
7
|
exports.getDefaultAppleAudioConfigurationForMode = getDefaultAppleAudioConfigurationForMode;
|
|
8
|
-
|
|
9
8
|
var _reactNative = require("react-native");
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
12
|
const LINKING_ERROR = `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
14
13
|
ios: "- You have run 'pod install'\n",
|
|
15
14
|
default: ''
|
|
@@ -18,8 +17,8 @@ const LivekitReactNative = _reactNative.NativeModules.LivekitReactNative ? _reac
|
|
|
18
17
|
get() {
|
|
19
18
|
throw new Error(LINKING_ERROR);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
});
|
|
21
|
+
|
|
23
22
|
/**
|
|
24
23
|
* Configuration for the underlying AudioSession.
|
|
25
24
|
*
|
|
@@ -48,7 +47,7 @@ const LivekitReactNative = _reactNative.NativeModules.LivekitReactNative ? _reac
|
|
|
48
47
|
* By default, this is set to `"speaker"`
|
|
49
48
|
*/
|
|
50
49
|
|
|
51
|
-
const AndroidAudioTypePresets = {
|
|
50
|
+
const AndroidAudioTypePresets = exports.AndroidAudioTypePresets = {
|
|
52
51
|
communication: {
|
|
53
52
|
manageAudioFocus: true,
|
|
54
53
|
audioMode: 'inCommunication',
|
|
@@ -66,11 +65,7 @@ const AndroidAudioTypePresets = {
|
|
|
66
65
|
audioAttributesContentType: 'unknown'
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
function getDefaultAppleAudioConfigurationForMode(mode) {
|
|
72
|
-
let preferSpeakerOutput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
73
|
-
|
|
68
|
+
function getDefaultAppleAudioConfigurationForMode(mode, preferSpeakerOutput = true) {
|
|
74
69
|
if (mode === 'remoteOnly') {
|
|
75
70
|
return {
|
|
76
71
|
audioCategory: 'playback',
|
|
@@ -84,30 +79,60 @@ function getDefaultAppleAudioConfigurationForMode(mode) {
|
|
|
84
79
|
audioMode: preferSpeakerOutput ? 'videoChat' : 'voiceChat'
|
|
85
80
|
};
|
|
86
81
|
}
|
|
87
|
-
|
|
88
82
|
return {
|
|
89
83
|
audioCategory: 'soloAmbient',
|
|
90
84
|
audioCategoryOptions: [],
|
|
91
85
|
audioMode: 'default'
|
|
92
86
|
};
|
|
93
87
|
}
|
|
94
|
-
|
|
95
88
|
class AudioSession {}
|
|
96
|
-
|
|
97
89
|
exports.default = AudioSession;
|
|
98
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Applies the provided audio configuration to the underlying AudioSession.
|
|
92
|
+
*
|
|
93
|
+
* Must be called prior to connecting to a Room for the configuration to apply correctly.
|
|
94
|
+
*
|
|
95
|
+
* See also useIOSAudioManagement for automatic configuration of iOS audio options.
|
|
96
|
+
*/
|
|
99
97
|
_defineProperty(AudioSession, "configureAudio", async config => {
|
|
100
98
|
await LivekitReactNative.configureAudio(config);
|
|
101
99
|
});
|
|
102
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Starts an AudioSession.
|
|
102
|
+
*/
|
|
103
103
|
_defineProperty(AudioSession, "startAudioSession", async () => {
|
|
104
104
|
await LivekitReactNative.startAudioSession();
|
|
105
105
|
});
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Stops the existing AudioSession.
|
|
108
|
+
*/
|
|
107
109
|
_defineProperty(AudioSession, "stopAudioSession", async () => {
|
|
108
110
|
await LivekitReactNative.stopAudioSession();
|
|
109
111
|
});
|
|
110
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Gets the available audio outputs for use with {@link selectAudioOutput}.
|
|
114
|
+
*
|
|
115
|
+
* {@link startAudioSession} must be called prior to using this method.
|
|
116
|
+
*
|
|
117
|
+
* For Android, will return if available:
|
|
118
|
+
* * "speaker"
|
|
119
|
+
* * "earpiece"
|
|
120
|
+
* * "headset"
|
|
121
|
+
* * "bluetooth"
|
|
122
|
+
*
|
|
123
|
+
* ----
|
|
124
|
+
*
|
|
125
|
+
* For iOS, due to OS limitations, the only available types are:
|
|
126
|
+
* * "default" - Use default iOS audio routing
|
|
127
|
+
* * "force_speaker" - Force audio output through speaker
|
|
128
|
+
*
|
|
129
|
+
* See also {@link showAudioRoutePicker} to display a route picker that
|
|
130
|
+
* can choose between other audio devices (i.e. headset/bluetooth/airplay),
|
|
131
|
+
* or use a library like `react-native-avroutepicker` for a native platform
|
|
132
|
+
* control.
|
|
133
|
+
*
|
|
134
|
+
* @returns the available audio output types
|
|
135
|
+
*/
|
|
111
136
|
_defineProperty(AudioSession, "getAudioOutputs", async () => {
|
|
112
137
|
if (_reactNative.Platform.OS === 'ios') {
|
|
113
138
|
return ['default', 'force_speaker'];
|
|
@@ -117,17 +142,26 @@ _defineProperty(AudioSession, "getAudioOutputs", async () => {
|
|
|
117
142
|
return [];
|
|
118
143
|
}
|
|
119
144
|
});
|
|
120
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Select the provided audio output if available.
|
|
147
|
+
*
|
|
148
|
+
* {@link startAudioSession} must be called prior to using this method.
|
|
149
|
+
*
|
|
150
|
+
* @param deviceId A deviceId retrieved from {@link getAudioOutputs}
|
|
151
|
+
*/
|
|
121
152
|
_defineProperty(AudioSession, "selectAudioOutput", async deviceId => {
|
|
122
153
|
await LivekitReactNative.selectAudioOutput(deviceId);
|
|
123
154
|
});
|
|
124
|
-
|
|
155
|
+
/**
|
|
156
|
+
* iOS only, requires iOS 11+.
|
|
157
|
+
*
|
|
158
|
+
* Displays an AVRoutePickerView for the user to choose their audio output.
|
|
159
|
+
*/
|
|
125
160
|
_defineProperty(AudioSession, "showAudioRoutePicker", async () => {
|
|
126
161
|
if (_reactNative.Platform.OS === 'ios') {
|
|
127
162
|
await LivekitReactNative.showAudioRoutePicker();
|
|
128
163
|
}
|
|
129
164
|
});
|
|
130
|
-
|
|
131
165
|
_defineProperty(AudioSession, "setAppleAudioConfiguration", async config => {
|
|
132
166
|
if (_reactNative.Platform.OS === 'ios') {
|
|
133
167
|
await LivekitReactNative.setAppleAudioConfiguration(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AudioSession.ts"],"names":["LINKING_ERROR","Platform","select","ios","default","LivekitReactNative","NativeModules","Proxy","get","Error","AndroidAudioTypePresets","communication","manageAudioFocus","audioMode","audioFocusMode","audioStreamType","audioAttributesUsageType","audioAttributesContentType","media","getDefaultAppleAudioConfigurationForMode","mode","preferSpeakerOutput","audioCategory","audioCategoryOptions","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker","setAppleAudioConfiguration"],"mappings":";;;;;;;;AAAA;;;;AACA,MAAMA,aAAa,GAChB,gFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,kBAAkB,GAAGC,2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R =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"bluetooth\"\n * 2. `\"headset\"``\n * 3. `\"speaker\"`\n * 4. `\"earpiece\"`\n *\n * * audioTypeOptions - An {@link AndroidAudioTypeOptions} object which provides the\n * audio options to use on Android.\n *\n * See {@link AndroidAudioTypePresets} for pre-configured values.\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioTypeOptions: AndroidAudioTypeOptions;\n };\n ios?: {\n defaultOutput?: 'speaker' | 'earpiece';\n };\n};\n\nexport type AndroidAudioTypeOptions = {\n /**\n * Whether LiveKit should handle managing the audio focus or not.\n *\n * Defaults to true.\n */\n manageAudioFocus?: boolean;\n\n /**\n * Corresponds to {@link https://developer.android.com/reference/android/media/AudioManager#setMode(int)}\n *\n * Defaults to 'inCommunication'.\n */\n audioMode?:\n | 'normal'\n | 'callScreening'\n | 'inCall'\n | 'inCommunication'\n | 'ringtone';\n\n /**\n * Corresponds to the duration hint when requesting audio focus.\n *\n * Defaults to 'gain'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioManager#AUDIOFOCUS_GAIN}\n */\n audioFocusMode?:\n | 'gain'\n | 'gainTransient'\n | 'gainTransientExclusive'\n | 'gainTransientMayDuck';\n\n /**\n * Corresponds to Android's AudioAttributes usage type.\n *\n * Defaults to 'voiceCommunication'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioAttributes}\n */\n audioAttributesUsageType?:\n | 'alarm'\n | 'assistanceAccessibility'\n | 'assistanceNavigationGuidance'\n | 'assistanceSonification'\n | 'assistant'\n | 'game'\n | 'media'\n | 'notification'\n | 'notificationEvent'\n | 'notificationRingtone'\n | 'unknown'\n | 'voiceCommunication'\n | 'voiceCommunicationSignalling';\n\n /**\n * Corresponds to Android's AndroidAttributes content type.\n *\n * Defaults to 'speech'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioAttributes}\n */\n audioAttributesContentType?:\n | 'movie'\n | 'music'\n | 'sonification'\n | 'speech'\n | 'unknown';\n\n /**\n * Corresponds to the stream type when requesting audio focus. Used on pre-O devices.\n *\n * Defaults to 'voiceCall'\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioManager#STREAM_VOICE_CALL}\n */\n audioStreamType?:\n | 'accessibility'\n | 'alarm'\n | 'dtmf'\n | 'music'\n | 'notification'\n | 'ring'\n | 'system'\n | 'voiceCall';\n\n /**\n * On certain Android devices, audio routing does not function properly and\n * bluetooth microphones will not work unless audio mode is set to\n * `inCommunication` or `inCall`. Audio routing is turned off those cases.\n *\n * If this set to true, will attempt to do audio routing regardless of audio mode.\n *\n * Defaults to false.\n */\n forceHandleAudioRouting?: boolean;\n};\n\nexport const AndroidAudioTypePresets: {\n /**\n * A pre-configured AndroidAudioConfiguration for voice communication.\n */\n communication: AndroidAudioTypeOptions;\n /**\n * A pre-configured AndroidAudioConfiguration for media playback.\n */\n media: AndroidAudioTypeOptions;\n} = {\n communication: {\n manageAudioFocus: true,\n audioMode: 'inCommunication',\n audioFocusMode: 'gain',\n audioStreamType: 'voiceCall',\n audioAttributesUsageType: 'voiceCommunication',\n audioAttributesContentType: 'speech',\n },\n media: {\n manageAudioFocus: true,\n audioMode: 'normal',\n audioFocusMode: 'gain',\n audioStreamType: 'music',\n audioAttributesUsageType: 'media',\n audioAttributesContentType: 'unknown',\n },\n} as const;\n\nexport type AppleAudioMode =\n | 'default'\n | 'gameChat'\n | 'measurement'\n | 'moviePlayback'\n | 'spokenAudio'\n | 'videoChat'\n | 'videoRecording'\n | 'voiceChat'\n | 'voicePrompt';\n\nexport type AppleAudioCategory =\n | 'soloAmbient'\n | 'playback'\n | 'record'\n | 'playAndRecord'\n | 'multiRoute';\n\nexport type AppleAudioCategoryOption =\n | 'mixWithOthers'\n | 'duckOthers'\n | 'interruptSpokenAudioAndMixWithOthers'\n | 'allowBluetooth'\n | 'allowBluetoothA2DP'\n | 'allowAirPlay'\n | 'defaultToSpeaker';\n\nexport type AppleAudioConfiguration = {\n audioCategory?: AppleAudioCategory;\n audioCategoryOptions?: AppleAudioCategoryOption[];\n audioMode?: AppleAudioMode;\n};\n\nexport type AudioTrackState =\n | 'none'\n | 'remoteOnly'\n | 'localOnly'\n | 'localAndRemote';\n\nexport function getDefaultAppleAudioConfigurationForMode(\n mode: AudioTrackState,\n preferSpeakerOutput: boolean = true\n): AppleAudioConfiguration {\n if (mode === 'remoteOnly') {\n return {\n audioCategory: 'playback',\n audioCategoryOptions: ['mixWithOthers'],\n audioMode: 'spokenAudio',\n };\n } else if (mode === 'localAndRemote' || mode === 'localOnly') {\n return {\n audioCategory: 'playAndRecord',\n audioCategoryOptions: ['allowBluetooth', 'mixWithOthers'],\n audioMode: preferSpeakerOutput ? 'videoChat' : 'voiceChat',\n };\n }\n\n return {\n audioCategory: 'soloAmbient',\n audioCategoryOptions: [],\n audioMode: 'default',\n };\n}\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n *\n * See also useIOSAudioManagement for automatic configuration of iOS audio options.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n\n static setAppleAudioConfiguration = async (\n config: AppleAudioConfiguration\n ) => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.setAppleAudioConfiguration(config);\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LINKING_ERROR","Platform","select","ios","default","LivekitReactNative","NativeModules","Proxy","get","Error","AndroidAudioTypePresets","exports","communication","manageAudioFocus","audioMode","audioFocusMode","audioStreamType","audioAttributesUsageType","audioAttributesContentType","media","getDefaultAppleAudioConfigurationForMode","mode","preferSpeakerOutput","audioCategory","audioCategoryOptions","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker","setAppleAudioConfiguration"],"sources":["AudioSession.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nconst LINKING_ERROR =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"bluetooth\"\n * 2. `\"headset\"``\n * 3. `\"speaker\"`\n * 4. `\"earpiece\"`\n *\n * * audioTypeOptions - An {@link AndroidAudioTypeOptions} object which provides the\n * audio options to use on Android.\n *\n * See {@link AndroidAudioTypePresets} for pre-configured values.\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioTypeOptions: AndroidAudioTypeOptions;\n };\n ios?: {\n defaultOutput?: 'speaker' | 'earpiece';\n };\n};\n\nexport type AndroidAudioTypeOptions = {\n /**\n * Whether LiveKit should handle managing the audio focus or not.\n *\n * Defaults to true.\n */\n manageAudioFocus?: boolean;\n\n /**\n * Corresponds to {@link https://developer.android.com/reference/android/media/AudioManager#setMode(int)}\n *\n * Defaults to 'inCommunication'.\n */\n audioMode?:\n | 'normal'\n | 'callScreening'\n | 'inCall'\n | 'inCommunication'\n | 'ringtone';\n\n /**\n * Corresponds to the duration hint when requesting audio focus.\n *\n * Defaults to 'gain'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioManager#AUDIOFOCUS_GAIN}\n */\n audioFocusMode?:\n | 'gain'\n | 'gainTransient'\n | 'gainTransientExclusive'\n | 'gainTransientMayDuck';\n\n /**\n * Corresponds to Android's AudioAttributes usage type.\n *\n * Defaults to 'voiceCommunication'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioAttributes}\n */\n audioAttributesUsageType?:\n | 'alarm'\n | 'assistanceAccessibility'\n | 'assistanceNavigationGuidance'\n | 'assistanceSonification'\n | 'assistant'\n | 'game'\n | 'media'\n | 'notification'\n | 'notificationEvent'\n | 'notificationRingtone'\n | 'unknown'\n | 'voiceCommunication'\n | 'voiceCommunicationSignalling';\n\n /**\n * Corresponds to Android's AndroidAttributes content type.\n *\n * Defaults to 'speech'.\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioAttributes}\n */\n audioAttributesContentType?:\n | 'movie'\n | 'music'\n | 'sonification'\n | 'speech'\n | 'unknown';\n\n /**\n * Corresponds to the stream type when requesting audio focus. Used on pre-O devices.\n *\n * Defaults to 'voiceCall'\n *\n * See also {@link https://developer.android.com/reference/android/media/AudioManager#STREAM_VOICE_CALL}\n */\n audioStreamType?:\n | 'accessibility'\n | 'alarm'\n | 'dtmf'\n | 'music'\n | 'notification'\n | 'ring'\n | 'system'\n | 'voiceCall';\n\n /**\n * On certain Android devices, audio routing does not function properly and\n * bluetooth microphones will not work unless audio mode is set to\n * `inCommunication` or `inCall`. Audio routing is turned off those cases.\n *\n * If this set to true, will attempt to do audio routing regardless of audio mode.\n *\n * Defaults to false.\n */\n forceHandleAudioRouting?: boolean;\n};\n\nexport const AndroidAudioTypePresets: {\n /**\n * A pre-configured AndroidAudioConfiguration for voice communication.\n */\n communication: AndroidAudioTypeOptions;\n /**\n * A pre-configured AndroidAudioConfiguration for media playback.\n */\n media: AndroidAudioTypeOptions;\n} = {\n communication: {\n manageAudioFocus: true,\n audioMode: 'inCommunication',\n audioFocusMode: 'gain',\n audioStreamType: 'voiceCall',\n audioAttributesUsageType: 'voiceCommunication',\n audioAttributesContentType: 'speech',\n },\n media: {\n manageAudioFocus: true,\n audioMode: 'normal',\n audioFocusMode: 'gain',\n audioStreamType: 'music',\n audioAttributesUsageType: 'media',\n audioAttributesContentType: 'unknown',\n },\n} as const;\n\nexport type AppleAudioMode =\n | 'default'\n | 'gameChat'\n | 'measurement'\n | 'moviePlayback'\n | 'spokenAudio'\n | 'videoChat'\n | 'videoRecording'\n | 'voiceChat'\n | 'voicePrompt';\n\nexport type AppleAudioCategory =\n | 'soloAmbient'\n | 'playback'\n | 'record'\n | 'playAndRecord'\n | 'multiRoute';\n\nexport type AppleAudioCategoryOption =\n | 'mixWithOthers'\n | 'duckOthers'\n | 'interruptSpokenAudioAndMixWithOthers'\n | 'allowBluetooth'\n | 'allowBluetoothA2DP'\n | 'allowAirPlay'\n | 'defaultToSpeaker';\n\nexport type AppleAudioConfiguration = {\n audioCategory?: AppleAudioCategory;\n audioCategoryOptions?: AppleAudioCategoryOption[];\n audioMode?: AppleAudioMode;\n};\n\nexport type AudioTrackState =\n | 'none'\n | 'remoteOnly'\n | 'localOnly'\n | 'localAndRemote';\n\nexport function getDefaultAppleAudioConfigurationForMode(\n mode: AudioTrackState,\n preferSpeakerOutput: boolean = true\n): AppleAudioConfiguration {\n if (mode === 'remoteOnly') {\n return {\n audioCategory: 'playback',\n audioCategoryOptions: ['mixWithOthers'],\n audioMode: 'spokenAudio',\n };\n } else if (mode === 'localAndRemote' || mode === 'localOnly') {\n return {\n audioCategory: 'playAndRecord',\n audioCategoryOptions: ['allowBluetooth', 'mixWithOthers'],\n audioMode: preferSpeakerOutput ? 'videoChat' : 'voiceChat',\n };\n }\n\n return {\n audioCategory: 'soloAmbient',\n audioCategoryOptions: [],\n audioMode: 'default',\n };\n}\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n *\n * See also useIOSAudioManagement for automatic configuration of iOS audio options.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n\n static setAppleAudioConfiguration = async (\n config: AppleAudioConfiguration\n ) => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.setAppleAudioConfiguration(config);\n }\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAuD,SAAAC,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AACvD,MAAMgB,aAAa,GACjB,gFAAgF,GAChFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,kBAAkB,GAAGC,0BAAa,CAACD,kBAAkB,GACvDC,0BAAa,CAACD,kBAAkB,GAChC,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,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,MAClCC,MAA+B,IAC5B;EACH,IAAIzB,qBAAQ,CAAC6B,EAAE,KAAK,KAAK,EAAE;IACzB,MAAMzB,kBAAkB,CAAC8B,0BAA0B,CAACT,MAAM,CAAC;EAC7D;AACF,CAAC","ignoreList":[]}
|
|
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.LiveKitRoom = LiveKitRoom;
|
|
7
|
-
|
|
8
7
|
var _componentsReact = require("@livekit/components-react");
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/** @public */
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* The `LiveKitRoom` component provides the room context to all its child components.
|