@poolse/react-native 2.27.0 → 2.29.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/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, ReactElement, ComponentType } from 'react';
3
- import { Conversation, Uuid, Message, LiveCall, AttachmentUploadInput, Membership, Attachment, WebRtcAdapter, VoiceStatus, LiveKitModule, CallParticipant, CallMedia } from '@poolse/sdk';
2
+ import { ReactNode, ReactElement } from 'react';
3
+ import { Conversation, Uuid, Message, LiveCall, AttachmentUploadInput, Membership, Attachment } from '@poolse/sdk';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { UseCalls } from '@poolse/react';
6
- import { ViewStyle } from 'react-native';
7
5
 
8
6
  interface InboxUser {
9
7
  /** The user's external_id (the same id you mint JWTs with). */
@@ -1121,368 +1119,6 @@ declare const defaultDarkTheme: PoolseRNTheme;
1121
1119
  */
1122
1120
  declare function useAppStateLifecycle(): void;
1123
1121
 
1124
- /**
1125
- * React Native WebRTC binding, backed by `react-native-webrtc`.
1126
- *
1127
- * The module is passed IN rather than required here, and that is
1128
- * deliberate. Metro resolves dependencies statically, and this package
1129
- * is published through tsup, which rewrites a literal `require(...)`
1130
- * into a `__require(...)` call it cannot see — so bundling
1131
- * `react-native-webrtc` from inside this file never worked. It wasn't
1132
- * merely unavailable in Expo Go; it was absent from every bundle,
1133
- * development builds included, and surfaced as
1134
- * "Requiring unknown module react-native-webrtc" at runtime.
1135
- *
1136
- * Importing it in the app fixes that: Metro sees a static import in
1137
- * your source and bundles it. Optionality then lives where it belongs —
1138
- * an app that doesn't want voice simply never imports it, and never
1139
- * installs the native dependency.
1140
- *
1141
- * import * as webrtc from 'react-native-webrtc';
1142
- * <VoiceRoomBar conversationId={id} webrtc={webrtc} />
1143
- *
1144
- * Media streams on native aren't attached to an element the way they
1145
- * are on the web — audio-only calls route to the device's audio session
1146
- * once the peer connection is live, so the sink is a no-op. Video would
1147
- * render the stream through `<RTCView>` via the `toURL()` it exposes.
1148
- */
1149
-
1150
- /**
1151
- * The shape this binding needs from `react-native-webrtc`. The module's
1152
- * own namespace satisfies it, so `import * as webrtc` type-checks
1153
- * straight through.
1154
- */
1155
- interface NativeWebRtcModule {
1156
- RTCPeerConnection: new (...args: never[]) => unknown;
1157
- mediaDevices: {
1158
- getUserMedia: (...args: never[]) => Promise<unknown>;
1159
- };
1160
- }
1161
- /**
1162
- * True when `mod` looks like a usable `react-native-webrtc`.
1163
- *
1164
- * Guards against a half-linked native module: in a bare Expo Go client
1165
- * the JS may load while the native side is missing, leaving
1166
- * `RTCPeerConnection` undefined.
1167
- */
1168
- declare function isNativeWebRtcAvailable(mod: NativeWebRtcModule | null | undefined): boolean;
1169
- /**
1170
- * Adapter for `useVoiceRoom`'s `webrtc` option.
1171
- *
1172
- * @param mod the `react-native-webrtc` module, imported by your app.
1173
- * @throws when `mod` isn't a usable binding — check
1174
- * {@link isNativeWebRtcAvailable} first if that's reachable in
1175
- * your UI.
1176
- */
1177
- declare function createNativeWebRtcAdapter(mod: NativeWebRtcModule): WebRtcAdapter;
1178
-
1179
- interface VoiceRoomBarProps {
1180
- conversationId: string;
1181
- /**
1182
- * The `react-native-webrtc` module, imported by your app:
1183
- *
1184
- * import * as webrtc from 'react-native-webrtc';
1185
- *
1186
- * Required for audio. Metro only bundles what it can see statically,
1187
- * so this package cannot import it for you — see `voice/webrtc-native`.
1188
- * Omit it and the bar renders its unavailable state, which is what you
1189
- * want in Expo Go.
1190
- */
1191
- webrtc?: NativeWebRtcModule | null;
1192
- /**
1193
- * Called whenever the room's connection state changes.
1194
- *
1195
- * Audio routing is the app's job — speakerphone, the proximity sensor
1196
- * that blanks the screen at your ear, and holding the audio session
1197
- * open all need a native module this package deliberately doesn't
1198
- * depend on. Use this to start and stop it.
1199
- */
1200
- onStatusChange?: (status: VoiceStatus) => void;
1201
- /** Resolves a user id to a display label. Defaults to a short id. */
1202
- labelFor?: (userId: string) => string;
1203
- /**
1204
- * Rendered instead of the join button when `react-native-webrtc`
1205
- * isn't installed. Defaults to an inline explanation.
1206
- */
1207
- unavailableSlot?: React.ReactNode;
1208
- }
1209
- /**
1210
- * Discord-style voice bar: one "Join Voice" button that expands into a
1211
- * roster of who's in, with a ring around whoever is talking.
1212
- *
1213
- * Drop it above a `<ConversationView>` to give a conversation an
1214
- * always-on voice channel. For ringing a specific person, use
1215
- * `<IncomingCallSheet>` together with `useCalls`.
1216
- */
1217
- declare function VoiceRoomBar({ conversationId, labelFor, unavailableSlot, webrtc, onStatusChange, }: VoiceRoomBarProps): react_jsx_runtime.JSX.Element;
1218
-
1219
- /**
1220
- * The slice of `@livekit/react-native` this package uses.
1221
- *
1222
- * Passed in by the app rather than imported, for the same reason
1223
- * `react-native-webrtc` is: tsup rewrites `require()` into
1224
- * `__require()`, which Metro cannot follow, so anything this package
1225
- * imports for itself never reaches a React Native bundle.
1226
- *
1227
- * import * as livekitRN from '@livekit/react-native';
1228
- * <CallScreen livekitReactNative={livekitRN} … />
1229
- *
1230
- * Everything past `VideoTrack` is optional so an older version of the
1231
- * module still type-checks — the features degrade rather than failing
1232
- * to compile.
1233
- */
1234
-
1235
- /**
1236
- * The slice of `VideoTrack` actually rendered.
1237
- *
1238
- * `LiveKitReactNativeModule.VideoTrack` is `unknown` because React props
1239
- * are contravariant — declaring the narrow shape there means the real
1240
- * component is not assignable to it and no app can pass the module in.
1241
- * Narrowing happens at the point of use, through this.
1242
- */
1243
- type CheckedVideoTrack = ComponentType<{
1244
- trackRef: unknown;
1245
- style?: ViewStyle;
1246
- objectFit?: 'cover' | 'contain';
1247
- mirror?: boolean;
1248
- zOrder?: number;
1249
- }>;
1250
- /** What an audio route is, once its platform id has been read. */
1251
- type AudioRouteKind = 'speaker' | 'earpiece' | 'headset' | 'bluetooth' | 'auto';
1252
- interface AudioRoute {
1253
- /** Platform id, passed back to `selectAudioOutput`. */
1254
- id: string;
1255
- kind: AudioRouteKind;
1256
- /** Human label for a picker row. */
1257
- label: string;
1258
- }
1259
- /**
1260
- * LiveKit's audio session.
1261
- *
1262
- * The two platforms expose genuinely different things and the shape
1263
- * reflects that rather than papering over it:
1264
- *
1265
- * * **Android** enumerates real devices — `speaker`, `earpiece`,
1266
- * `headset`, `bluetooth` — and `selectAudioOutput` picks one.
1267
- * * **iOS** offers only `default` and `force_speaker`, because AVAudio
1268
- * does not let an app pick a route directly. Anything else (AirPods,
1269
- * a wired headset, AirPlay) goes through the system's own picker,
1270
- * which is what `showAudioRoutePicker` opens.
1271
- */
1272
- interface LiveKitAudioSession {
1273
- configureAudio(config: {
1274
- android?: {
1275
- preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];
1276
- audioTypeOptions?: unknown;
1277
- };
1278
- ios?: {
1279
- defaultOutput?: 'speaker' | 'earpiece';
1280
- };
1281
- }): Promise<void>;
1282
- startAudioSession(): Promise<void>;
1283
- stopAudioSession(): Promise<void>;
1284
- getAudioOutputs(): Promise<string[]>;
1285
- selectAudioOutput(deviceId: string): Promise<void>;
1286
- /** iOS 11+. Opens the system route picker (AirPods, AirPlay, …). */
1287
- showAudioRoutePicker?(): Promise<void>;
1288
- }
1289
- /** Fires when a headset or Bluetooth device appears or disappears. */
1290
- interface AudioDeviceModuleEvents {
1291
- addDevicesUpdatedListener(listener: () => void): void;
1292
- removeDevicesUpdatedListener(listener: () => void): void;
1293
- }
1294
- interface LiveKitReactNativeModule {
1295
- /**
1296
- * The module's `VideoTrack` component.
1297
- *
1298
- * Typed as `unknown` on purpose. Its real props are far more specific
1299
- * than what this renders with, and React component props are
1300
- * contravariant — declaring the narrow shape here means the real
1301
- * component is not assignable to it and no app can pass the module in.
1302
- * It is narrowed at the point of use.
1303
- */
1304
- VideoTrack: unknown;
1305
- AudioSession?: LiveKitAudioSession | undefined;
1306
- /**
1307
- * Installs LiveKit's iOS audio policy and returns a disposer.
1308
- *
1309
- * Must not be re-run mid-call: it abandons the session activation the
1310
- * previous handlers were holding, which kills audio outright. The
1311
- * speaker preference is therefore captured once, when the call
1312
- * starts, and later changes go through `selectAudioOutput` instead.
1313
- */
1314
- setupIOSAudioManagement?: ((preferSpeakerOutput?: boolean) => () => void) | undefined;
1315
- audioDeviceModuleEvents?: AudioDeviceModuleEvents | undefined;
1316
- }
1317
- /** Turn a platform output id into something renderable. */
1318
- declare function describeRoute(id: string): AudioRoute;
1319
-
1320
- interface CallScreenProps {
1321
- /** The signed-in user's id — the topic calls are delivered on. */
1322
- userId: string;
1323
- /** Resolves a user id to a display label. Defaults to a short id. */
1324
- labelFor?: (userId: string) => string;
1325
- /**
1326
- * Resolves a conversation id to a display name — the group being
1327
- * called. When it returns one, the call is titled by it ("Fix the
1328
- * boiler") and the people move to the subtitle, which is how a
1329
- * group call reads everywhere else. Return null/undefined to fall
1330
- * back to participant names.
1331
- */
1332
- conversationLabel?: (conversationId: string) => string | null | undefined;
1333
- /**
1334
- * Escape hatch for apps that already own a `useCalls` instance (for
1335
- * example to place calls from elsewhere in the UI). When omitted the
1336
- * component manages its own.
1337
- */
1338
- calls?: UseCalls;
1339
- /**
1340
- * The `react-native-webrtc` module (or `@livekit/react-native-webrtc`,
1341
- * which is API-compatible), imported by your app.
1342
- *
1343
- * Used for the peer-to-peer fallback when the deployment has no SFU.
1344
- * With an SFU configured, LiveKit owns the peer connection and this is
1345
- * only the safety net.
1346
- */
1347
- webrtc?: NativeWebRtcModule | null;
1348
- /**
1349
- * `livekit-client`, imported by your app. Enables SFU-backed calls,
1350
- * which is what makes video and the mid-call camera toggle possible.
1351
- * Omit it and calls fall back to the peer-to-peer mesh, audio only.
1352
- */
1353
- livekit?: LiveKitModule | null;
1354
- /**
1355
- * `@livekit/react-native`, imported by your app.
1356
- *
1357
- * Required to *render* video, and also carries `AudioSession`, which
1358
- * is what routes a call to the speaker, the earpiece or a headset.
1359
- * Without it a call still connects and carries audio, every tile
1360
- * shows an avatar, and routing falls to whatever the OS picks.
1361
- */
1362
- livekitReactNative?: LiveKitReactNativeModule | null;
1363
- /**
1364
- * Called whenever the call's media connection state changes.
1365
- */
1366
- onStatusChange?: (status: VoiceStatus) => void;
1367
- /**
1368
- * Called when the media transport changes: `'sfu'`, `'mesh'`, or
1369
- * `null` when no call is connected.
1370
- *
1371
- * This decides who owns the iOS audio session, and getting it wrong is
1372
- * silent. `@livekit/react-native`'s `registerGlobals()` configures and
1373
- * activates AVAudioSession natively as its audio engine changes state.
1374
- * An app that ALSO drives the session — `react-native-incall-manager`,
1375
- * typically — fights it: the microphone publishes nothing, and audio
1376
- * only starts working after some unrelated engine change (turning the
1377
- * camera on) makes LiveKit reapply its configuration.
1378
- *
1379
- * So drive InCallManager from this, and only for `'mesh'`. On the SFU
1380
- * path this component already owns the session, through LiveKit.
1381
- */
1382
- onTransportChange?: (transport: 'sfu' | 'mesh' | null) => void;
1383
- /** Called when the call's video state changes. */
1384
- onVideoChange?: (video: boolean) => void;
1385
- /**
1386
- * Called when the audio route changes: speaker on/off, or an
1387
- * external device (headset, Bluetooth) taking over. Hosts use this
1388
- * to drive the proximity sensor — the screen should only go dark
1389
- * near an ear when the sound is actually AT the ear.
1390
- */
1391
- onSpeakerChange?: (speakerOn: boolean, externalDevice: boolean) => void;
1392
- /**
1393
- * `react-native-incall-manager`, imported by your app.
1394
- *
1395
- * Only used here for the ring tones — the earpiece purr while an
1396
- * outbound call rings, and the ringtone for an inbound one. Without
1397
- * it a call is completely silent until somebody answers, which reads
1398
- * as the app having failed to place it at all.
1399
- *
1400
- * Injected rather than imported for the same reason every other
1401
- * native module is: Metro only bundles what it can see statically.
1402
- */
1403
- inCallManager?: RingToneModule | null;
1404
- /**
1405
- * Hide this screen while a call is merely ringing in.
1406
- *
1407
- * Set it when `useVoipCalls` is wired: CallKit already shows the
1408
- * system call UI on the lock screen and in the Dynamic Island, and a
1409
- * second in-app sheet on top of it means one tap of Call produces two
1410
- * competing rings. The screen still appears once the call connects, to
1411
- * carry the in-call controls.
1412
- */
1413
- nativeIncomingUi?: boolean;
1414
- }
1415
- /**
1416
- * The slice of `react-native-incall-manager` used for ring tones.
1417
- *
1418
- * Every method optional: older versions lack some, and a missing tone
1419
- * must never take a call down.
1420
- */
1421
- interface RingToneModule {
1422
- startRingback?: (...args: never[]) => void;
1423
- stopRingback?: (...args: never[]) => void;
1424
- startRingtone?: (...args: never[]) => void;
1425
- stopRingtone?: (...args: never[]) => void;
1426
- }
1427
- declare function CallScreen({ userId, labelFor, conversationLabel, calls: callsProp, webrtc, livekit, livekitReactNative, onStatusChange, onTransportChange, onVideoChange, onSpeakerChange, inCallManager, nativeIncomingUi, }: CallScreenProps): react_jsx_runtime.JSX.Element;
1428
-
1429
- interface CallVideoGridProps {
1430
- participants: CallParticipant[];
1431
- /** `@livekit/react-native`, imported by your app. */
1432
- livekitReactNative?: LiveKitReactNativeModule | null | undefined;
1433
- /** Resolves a user id to a display label. */
1434
- labelFor?: ((userId: string) => string) | undefined;
1435
- /**
1436
- * Tapping the local preview. Wired to the camera flip by
1437
- * `CallScreen`, which is where every other call app puts it.
1438
- */
1439
- onLocalPress?: (() => void) | undefined;
1440
- /**
1441
- * How much chrome sits over the bottom of the stage.
1442
- *
1443
- * Only used to keep the last row of a scrolling group grid clear of
1444
- * the control bar. It deliberately does NOT bound the floating
1445
- * preview — see {@link safeArea}.
1446
- */
1447
- chromeInsets?: {
1448
- top: number;
1449
- bottom: number;
1450
- } | undefined;
1451
- /**
1452
- * The screen's safe area, which is what the floating preview is
1453
- * bounded by.
1454
- *
1455
- * Separate from `chromeInsets` on purpose. Bounding the preview by the
1456
- * chrome kept it in a box well inside the screen, floating in the
1457
- * middle of nowhere rather than tucked into a corner — and on a
1458
- * connected video call the chrome is hidden most of the time anyway,
1459
- * so it was reserving space for something that was not there.
1460
- */
1461
- safeArea?: {
1462
- top: number;
1463
- bottom: number;
1464
- } | undefined;
1465
- }
1466
- /**
1467
- * The stage: everyone on the call, laid out for how many there are.
1468
- *
1469
- * Three layouts, because one grid cannot serve all of them:
1470
- *
1471
- * * **Alone** — you, filling the screen, while the far side connects.
1472
- * * **One other person** — them full-bleed, you in a draggable
1473
- * corner tile. A 1:1 call split into two half-height boxes wastes
1474
- * most of the screen on letterboxing, which is why no calling app
1475
- * does it.
1476
- * * **Three or more** — a real grid, two columns up to six people and
1477
- * three beyond that, scrolling once the tiles would be too small to
1478
- * make out a face.
1479
- *
1480
- * Audio calls land here too. Everyone simply has their camera off, so
1481
- * every tile draws an avatar, and the layout logic does not need to
1482
- * know whether video was ever on the table.
1483
- */
1484
- declare function CallVideoGrid({ participants, livekitReactNative, labelFor, onLocalPress, chromeInsets, safeArea, }: CallVideoGridProps): react_jsx_runtime.JSX.Element;
1485
-
1486
1122
  interface CallControlButtonProps {
1487
1123
  icon: IconName;
1488
1124
  /** Shown under the button. Omit for the hang-up / answer buttons. */
@@ -1515,29 +1151,6 @@ interface CallControlButtonProps {
1515
1151
  */
1516
1152
  declare function CallControlButton({ icon, label, active, tone, large, disabled, onPress, accessibilityLabel, }: CallControlButtonProps): react_jsx_runtime.JSX.Element;
1517
1153
 
1518
- interface CallParticipantTileProps {
1519
- participant: CallParticipant;
1520
- /** Narrowed `@livekit/react-native` VideoTrack, when the app supplied it. */
1521
- VideoTrack?: CheckedVideoTrack | undefined;
1522
- label: (userId: string) => string;
1523
- style?: ViewStyle | ViewStyle[];
1524
- /** Avatar diameter when the camera is off. */
1525
- avatarSize?: number;
1526
- /** Full-bleed tiles drop their rounding and their name chip shrinks. */
1527
- bleed?: boolean;
1528
- /** Hide the name chip — the spotlight draws identity in the header. */
1529
- hideName?: boolean;
1530
- }
1531
- /**
1532
- * One person on the call: their video, or their avatar when the camera
1533
- * is off.
1534
- *
1535
- * A camera-off participant still gets a tile. Dropping them would make
1536
- * a five-person call with four cameras off look like a one-person call,
1537
- * and hide the fact that they are there and can hear you.
1538
- */
1539
- declare function CallParticipantTile({ participant, VideoTrack, label, style, avatarSize, bleed, hideName, }: CallParticipantTileProps): react_jsx_runtime.JSX.Element;
1540
-
1541
1154
  interface CallAvatarProps {
1542
1155
  /** Display name; the first letters become the initials. */
1543
1156
  name: string;
@@ -1560,42 +1173,15 @@ interface CallAvatarProps {
1560
1173
  */
1561
1174
  declare function CallAvatar({ name, seed, size, speaking }: CallAvatarProps): react_jsx_runtime.JSX.Element;
1562
1175
 
1563
- interface LocalVideoPipProps {
1564
- participant: CallParticipant;
1565
- VideoTrack?: CheckedVideoTrack | undefined;
1566
- label: (userId: string) => string;
1567
- /** Area the tile may be dragged within, in pixels. */
1568
- bounds: {
1569
- width: number;
1570
- height: number;
1571
- };
1572
- /**
1573
- * Safe-area insets. The tile hugs the edges just inside these, so it
1574
- * clears the notch and the home indicator and nothing else.
1575
- */
1576
- insets?: {
1577
- top: number;
1578
- bottom: number;
1579
- };
1580
- /** Tap handler. Wired to the camera flip, matching every other call app. */
1581
- onPress?: (() => void) | undefined;
1176
+ type AudioRouteKind = 'speaker' | 'earpiece' | 'headset' | 'bluetooth' | 'auto';
1177
+ /** One place call audio can play — a row in the sheet. */
1178
+ interface AudioRoute {
1179
+ /** Platform id, passed back through `onSelect`. */
1180
+ id: string;
1181
+ kind: AudioRouteKind;
1182
+ /** Human label for the row. */
1183
+ label: string;
1582
1184
  }
1583
- /**
1584
- * The local camera preview, floating over the remote video.
1585
- *
1586
- * Draggable, and it snaps to the nearest corner on release rather than
1587
- * staying wherever the finger stopped. Free positioning sounds more
1588
- * flexible but reads as broken: a tile left at a slight angle to the
1589
- * edge looks dropped rather than placed, and it is the corners people
1590
- * actually want — they move it to uncover a face.
1591
- *
1592
- * Built on `Animated` + `PanResponder` from React Native itself. A
1593
- * gesture library would be smoother, but it would be a new native
1594
- * dependency for every app that installs this SDK, and a call preview
1595
- * is not worth that.
1596
- */
1597
- declare function LocalVideoPip({ participant, VideoTrack, label, bounds, insets, onPress, }: LocalVideoPipProps): react_jsx_runtime.JSX.Element;
1598
-
1599
1185
  interface AudioRouteSheetProps {
1600
1186
  visible: boolean;
1601
1187
  routes: AudioRoute[];
@@ -1607,10 +1193,9 @@ interface AudioRouteSheetProps {
1607
1193
  /**
1608
1194
  * Pick where call audio comes out.
1609
1195
  *
1610
- * Only worth showing when there is a real choice — on iOS there are
1611
- * exactly two entries and the system's own picker covers everything
1612
- * else, so `CallScreen` opens that instead. This is the Android
1613
- * surface, where LiveKit enumerates the actual devices.
1196
+ * Only worth showing when there is a real choice — more than the phone
1197
+ * and its speaker (AirPods, a car, a headset beside the speaker). With
1198
+ * just those two, a single speaker toggle is the better control.
1614
1199
  */
1615
1200
  declare function AudioRouteSheet({ visible, routes, selectedRouteId, onSelect, onClose, }: AudioRouteSheetProps): react_jsx_runtime.JSX.Element;
1616
1201
 
@@ -1674,231 +1259,4 @@ declare const callColors: {
1674
1259
  */
1675
1260
  declare function useCallDuration(connected: boolean): string | null;
1676
1261
 
1677
- interface UseCallAudioOptions {
1678
- /**
1679
- * True as soon as a call exists — ringing counts.
1680
- *
1681
- * Deliberately not "connected": the audio session has to be running
1682
- * before LiveKit's audio engine starts, not after. Start it late and
1683
- * the call connects, the roster is right, video flows, and no audio
1684
- * is published in either direction.
1685
- */
1686
- active: boolean;
1687
- /**
1688
- * Whether the call is carrying video.
1689
- *
1690
- * Decides where audio goes by default — nobody holds a phone to their
1691
- * ear while looking at the screen — and nothing else. Read once, when
1692
- * the call starts; see {@link LiveKitReactNativeModule.setupIOSAudioManagement}
1693
- * for why it cannot be re-applied mid-call.
1694
- */
1695
- video: boolean;
1696
- /** `@livekit/react-native`, imported by your app. */
1697
- livekitReactNative?: LiveKitReactNativeModule | null | undefined;
1698
- }
1699
- interface CallAudio {
1700
- /** Audio is coming out of the loudspeaker. */
1701
- speakerOn: boolean;
1702
- toggleSpeaker: () => void;
1703
- setSpeaker: (on: boolean) => void;
1704
- /** Every route that can be picked right now. */
1705
- routes: AudioRoute[];
1706
- /**
1707
- * The selected route's platform id, or `null` while routing is
1708
- * automatic — which is the normal state until the user picks
1709
- * something. Automatic means the OS follows the preference order the
1710
- * call was configured with, so plugging in a headset just works.
1711
- */
1712
- selectedRouteId: string | null;
1713
- selectRoute: (id: string) => void;
1714
- /**
1715
- * A headset, AirPods or car kit is connected.
1716
- *
1717
- * Worth surfacing because it changes what the speaker button means:
1718
- * with a headset attached, "off" routes to the headset rather than to
1719
- * the earpiece.
1720
- *
1721
- * Android only, and honestly so — iOS reports just `default` and
1722
- * `force_speaker` from `getAudioOutputs`, with no way to ask what
1723
- * `default` currently resolves to. On iOS this stays `false` and the
1724
- * system route picker is the way to see and change the real device.
1725
- */
1726
- externalDevice: boolean;
1727
- /**
1728
- * The system route picker can be opened. iOS only — Android
1729
- * enumerates its devices in {@link routes} instead.
1730
- */
1731
- canPickSystemRoute: boolean;
1732
- openSystemRoutePicker: () => void;
1733
- }
1734
- /**
1735
- * Owns the audio session for an SFU-backed call, and the routing on top
1736
- * of it.
1737
- *
1738
- * ## Why this is not `react-native-incall-manager`
1739
- *
1740
- * `registerGlobals()` from `@livekit/react-native` drives AVAudioSession
1741
- * natively off its own audio engine's state. Anything else driving the
1742
- * session at the same time fights it, and the symptom is brutal: the
1743
- * microphone captures nothing, and audio only starts working after some
1744
- * unrelated engine change — turning the camera on, say — makes LiveKit
1745
- * reapply its configuration. So InCallManager is reserved for the
1746
- * peer-to-peer mesh, which has no session management of its own.
1747
- *
1748
- * ## What "default" means on each platform
1749
- *
1750
- * Android is handed a `preferredOutputList` and picks the best
1751
- * available device itself, so a connected headset wins without the app
1752
- * detecting anything. iOS is given `defaultOutput`, which LiveKit
1753
- * documents as the output to use *when a wired headset or Bluetooth
1754
- * output is unavailable* — same effect, same reason: an app that forced
1755
- * the speaker on a video call would yank audio out of the user's
1756
- * AirPods every time.
1757
- */
1758
- declare function useCallAudio({ active, video, livekitReactNative, }: UseCallAudioOptions): CallAudio;
1759
-
1760
- /**
1761
- * Bridges iOS PushKit + CallKit to poolse calls, and owns the incoming
1762
- * call UI end to end.
1763
- *
1764
- * ## Why this coordinates rather than just forwards
1765
- *
1766
- * A call arrives by two routes: `call:incoming` over the WebSocket when
1767
- * the app is foregrounded, and a VoIP push when it isn't. The server
1768
- * fires both, always — deciding server-side whether a socket is really
1769
- * alive is a race it would lose.
1770
- *
1771
- * Reconciling them is therefore the client's job, and doing it badly is
1772
- * very visible: forward each route to its own UI and one tap of Call
1773
- * shows the callee two rings, an in-app sheet fighting a system call
1774
- * screen.
1775
- *
1776
- * So this hook is the single place a call becomes visible. Both routes
1777
- * feed one map keyed by `callId`, CallKit is the only ring UI, and the
1778
- * native call is torn down whenever the call reaches a terminal state —
1779
- * declined, cancelled, timed out, answered. Pass the same `calls` object
1780
- * to `<CallScreen>` and it stays out of the way while a ring is up.
1781
- *
1782
- * ## The rule Apple enforces
1783
- *
1784
- * Every delivered VoIP push MUST report an incoming call to CallKit,
1785
- * essentially immediately. Miss it and iOS terminates the app; do it
1786
- * repeatedly and the system stops delivering VoIP pushes at all.
1787
- *
1788
- * ## Dependencies
1789
- *
1790
- * `react-native-voip-push-notification` and `react-native-callkeep`,
1791
- * both native and both requiring a development build. Metro only bundles
1792
- * what it can see statically, so YOUR APP imports them and passes them
1793
- * in. The iOS AppDelegate also needs PushKit delegate methods, which
1794
- * Expo does not generate — see the sample's `plugins/withVoipPush.js`.
1795
- *
1796
- * useVoipCalls({
1797
- * voipPush: VoipPushNotification,
1798
- * callKeep: RNCallKeep,
1799
- * calls, // the same useCalls() the UI uses
1800
- * apnsEnvironment: 'sandbox',
1801
- * });
1802
- */
1803
- /** The slice of `react-native-voip-push-notification` used here. */
1804
- interface VoipPushModule {
1805
- addEventListener(event: string, handler: (payload: unknown) => void): void;
1806
- removeEventListener(event: string): void;
1807
- registerVoipToken(): void;
1808
- /**
1809
- * Releases the native PushKit completion handler for a push.
1810
- *
1811
- * iOS hands `didReceiveIncomingPushWith` a completion block and expects
1812
- * it back once the call has been reported. Never calling it leaves the
1813
- * app looking like it dropped the push, which is one of the ways iOS
1814
- * stops delivering VoIP pushes to an app entirely.
1815
- *
1816
- * Optional because older versions of the module don't expose it.
1817
- */
1818
- onVoipNotificationCompleted?(uuid: string): void;
1819
- }
1820
- /** The slice of `react-native-callkeep` used here. */
1821
- interface CallKeepModule {
1822
- setup(options: unknown): Promise<unknown>;
1823
- displayIncomingCall(uuid: string, handle: string, localizedCallerName?: string, handleType?: string, hasVideo?: boolean): unknown;
1824
- endCall(uuid: string): unknown;
1825
- /** Tell CallKit the call connected. Absent on older versions. */
1826
- setCurrentCallActive?(uuid: string): unknown;
1827
- addEventListener(event: string, handler: (payload: unknown) => void): void;
1828
- removeEventListener(event: string): void;
1829
- }
1830
- /** An inbound call, as it arrives inside a VoIP push payload. */
1831
- interface VoipIncomingCall {
1832
- callId: string;
1833
- conversationId: string;
1834
- callerUserId: string;
1835
- callerName: string;
1836
- /**
1837
- * The conversation's display name, when the server sent one. CallKit
1838
- * titles the ring and the Recents entry with this — a group call is
1839
- * a call FROM the group, not from whoever tapped the button.
1840
- */
1841
- conversationName?: string | null;
1842
- /**
1843
- * What the call opened as.
1844
- *
1845
- * Carried by the push because CallKit fixes the answer button when the
1846
- * call is reported and cannot change it afterwards — waiting for the
1847
- * socket would mean answering a video call through an audio UI.
1848
- */
1849
- media: CallMedia;
1850
- }
1851
- interface UseVoipCallsOptions {
1852
- voipPush: VoipPushModule;
1853
- callKeep: CallKeepModule;
1854
- /**
1855
- * The `useCalls(...)` instance driving this screen. Supplying it lets
1856
- * the hook answer, decline and dismiss through the same state machine
1857
- * the UI uses, rather than two halves disagreeing about what is
1858
- * happening.
1859
- */
1860
- calls?: UseCalls;
1861
- /** Called when the user answers from the native call UI. */
1862
- onAnswer?: (call: VoipIncomingCall) => void;
1863
- /** Called when the user declines from the native call UI. */
1864
- onDecline?: (call: VoipIncomingCall) => void;
1865
- /** CallKit display name for your app. Shown on the lock screen. */
1866
- appName?: string;
1867
- /**
1868
- * Which APNs environment issued this build's PushKit token — it must
1869
- * match the app's `aps-environment` entitlement.
1870
- *
1871
- * Pass it explicitly. The fallback guesses from `__DEV__`, which
1872
- * describes the JS bundle and NOT the entitlement: an ad-hoc or
1873
- * TestFlight build has `__DEV__ === false` while still carrying the
1874
- * `development` entitlement, so it receives a sandbox token and
1875
- * reports it as production. The server then pushes to the wrong
1876
- * environment, Apple answers BadDeviceToken, and the phone never
1877
- * rings — with nothing in the app to suggest why.
1878
- */
1879
- apnsEnvironment?: 'production' | 'sandbox';
1880
- /**
1881
- * How old a pushed call may be before it is reported and immediately
1882
- * ended, in ms. Defaults to a deliberately generous 120s.
1883
- *
1884
- * The tight value this once used made clock skew between server and
1885
- * handset enough to suppress live calls. The authoritative guard is
1886
- * server-side anyway — accepting an ended call is refused — so this is
1887
- * only here to spare the user a ring for something long dead.
1888
- *
1889
- * PushKit holds a push that lands before the JS bundle is up and
1890
- * replays it on launch, so opening the app can ring you for a call the
1891
- * caller hung up on minutes ago — a ring with nothing live to accept.
1892
- */
1893
- staleAfterMs?: number;
1894
- }
1895
- declare function isStalePush(sentAt: number | undefined, now: number, staleAfterMs: number): boolean;
1896
- /**
1897
- * Registers this device for VoIP pushes and drives the native call UI.
1898
- *
1899
- * Mount once, as high in the signed-in tree as possible. Does nothing on
1900
- * Android, which needs a separate FCM + ConnectionService integration.
1901
- */
1902
- declare function useVoipCalls({ voipPush, callKeep, calls, onAnswer, onDecline, appName, apnsEnvironment, staleAfterMs, }: UseVoipCallsOptions): void;
1903
-
1904
- export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, type AudioRoute, type AudioRouteKind, AudioRouteSheet, type AudioRouteSheetProps, Avatar, type AvatarProps, type CallAudio, CallAvatar, type CallAvatarProps, CallControlButton, type CallControlButtonProps, type CallKeepModule, CallLogRow, type CallLogRowProps, CallParticipantTile, type CallParticipantTileProps, CallScreen, type CallScreenProps, CallVideoGrid, type CallVideoGridProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, LiveCallBanner, type LiveCallBannerProps, type LiveKitAudioSession, type LiveKitReactNativeModule, LocalVideoPip, type LocalVideoPipProps, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, type NativeWebRtcModule, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type RingToneModule, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UseCallAudioOptions, type UseVoipCallsOptions, UserName, type UserNameProps, VoiceRoomBar, type VoiceRoomBarProps, type VoipIncomingCall, type VoipPushModule, callColors, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, describeRoute, isNativeWebRtcAvailable, isStalePush, useAppStateLifecycle, useCallAudio, useCallDuration, useDisplayName, usePoolseTheme, useVoipCalls };
1262
+ export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, type AudioRoute, type AudioRouteKind, AudioRouteSheet, type AudioRouteSheetProps, Avatar, type AvatarProps, CallAvatar, type CallAvatarProps, CallControlButton, type CallControlButtonProps, CallLogRow, type CallLogRowProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, LiveCallBanner, type LiveCallBannerProps, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, UserName, type UserNameProps, callColors, defaultDarkTheme, defaultLightTheme, useAppStateLifecycle, useCallDuration, useDisplayName, usePoolseTheme };