@poolse/react-native 2.28.0 → 3.0.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/CHANGELOG.md +28 -0
- package/LICENSE +206 -21
- package/README.md +2 -2
- package/dist/index.cjs +131 -1526
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -656
- package/dist/index.d.ts +14 -656
- package/dist/index.js +123 -1506
- package/dist/index.js.map +1 -1
- package/package.json +16 -20
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useUser, useMe, useConversations, formatCallLogPreview, useAttachmentUpload, useConversation, useMembers, usePresence, receiptsOf, useMessages, useTyping, useRealtimeStatus, isMessageVisibleTo, computeGroupPosition, canEditOwnMessage, formatDayLabel, callLogDisplayFor, useLiveCall, sameDay, useReactions, useThread, useAttachmentUrl, usePoolse
|
|
1
|
+
import { useUser, useMe, useConversations, formatCallLogPreview, useAttachmentUpload, useConversation, useMembers, usePresence, receiptsOf, useMessages, useTyping, useRealtimeStatus, isMessageVisibleTo, computeGroupPosition, canEditOwnMessage, formatDayLabel, callLogDisplayFor, useLiveCall, sameDay, useReactions, useThread, useAttachmentUrl, usePoolse } from '@poolse/react';
|
|
2
2
|
import { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useCallback, useContext, createElement } from 'react';
|
|
3
|
-
import { StyleSheet, View, Pressable, TextInput, Text, useWindowDimensions, Animated, Easing, PanResponder, Image, Keyboard, Platform, ScrollView, ActivityIndicator, FlatList, AppState, KeyboardAvoidingView, Modal, Linking
|
|
3
|
+
import { StyleSheet, View, Pressable, TextInput, Text, useWindowDimensions, Animated, Easing, PanResponder, Image, Keyboard, Platform, ScrollView, ActivityIndicator, FlatList, AppState, KeyboardAvoidingView, Modal, Linking } from 'react-native';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import
|
|
6
|
-
import { useSafeAreaInsets
|
|
5
|
+
import { SvgXml, Svg, Path, Circle, G } from 'react-native-svg';
|
|
6
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
7
7
|
import * as ImagePicker from 'expo-image-picker';
|
|
8
8
|
import * as DocumentPicker from 'expo-document-picker';
|
|
9
9
|
import { manipulateAsync, SaveFormat } from 'expo-image-manipulator';
|
|
@@ -5431,176 +5431,6 @@ function useAppStateLifecycle() {
|
|
|
5431
5431
|
}, [poolse]);
|
|
5432
5432
|
}
|
|
5433
5433
|
|
|
5434
|
-
// src/voice/webrtc-native.ts
|
|
5435
|
-
function isNativeWebRtcAvailable(mod) {
|
|
5436
|
-
return typeof mod?.RTCPeerConnection === "function" && mod?.mediaDevices != null;
|
|
5437
|
-
}
|
|
5438
|
-
function createNativeWebRtcAdapter(mod) {
|
|
5439
|
-
if (!isNativeWebRtcAvailable(mod)) {
|
|
5440
|
-
throw new Error(
|
|
5441
|
-
"react-native-webrtc is missing or not linked. Install it and rebuild:\n npx expo install react-native-webrtc\nIt contains native code, so it needs a development build \u2014 it will not run in Expo Go."
|
|
5442
|
-
);
|
|
5443
|
-
}
|
|
5444
|
-
const rtc = mod;
|
|
5445
|
-
return {
|
|
5446
|
-
createPeerConnection(iceServers) {
|
|
5447
|
-
return new rtc.RTCPeerConnection({ iceServers });
|
|
5448
|
-
},
|
|
5449
|
-
getUserMedia() {
|
|
5450
|
-
return rtc.mediaDevices.getUserMedia({
|
|
5451
|
-
audio: { echoCancellation: true, noiseSuppression: true },
|
|
5452
|
-
video: false
|
|
5453
|
-
});
|
|
5454
|
-
},
|
|
5455
|
-
playRemoteStream() {
|
|
5456
|
-
return () => {
|
|
5457
|
-
};
|
|
5458
|
-
}
|
|
5459
|
-
};
|
|
5460
|
-
}
|
|
5461
|
-
function VoiceRoomBar({
|
|
5462
|
-
conversationId,
|
|
5463
|
-
labelFor,
|
|
5464
|
-
unavailableSlot,
|
|
5465
|
-
webrtc,
|
|
5466
|
-
onStatusChange
|
|
5467
|
-
}) {
|
|
5468
|
-
const theme = usePoolseTheme();
|
|
5469
|
-
const available = isNativeWebRtcAvailable(webrtc);
|
|
5470
|
-
const opts = useMemo(
|
|
5471
|
-
() => available && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {},
|
|
5472
|
-
[available, webrtc]
|
|
5473
|
-
);
|
|
5474
|
-
const { status, participants, muted, join, leave, toggleMute, error } = useVoiceRoom(
|
|
5475
|
-
available ? conversationId : null,
|
|
5476
|
-
opts
|
|
5477
|
-
);
|
|
5478
|
-
useEffect(() => {
|
|
5479
|
-
onStatusChange?.(status);
|
|
5480
|
-
}, [status, onStatusChange]);
|
|
5481
|
-
const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
|
|
5482
|
-
const connected = status === "connected";
|
|
5483
|
-
if (!available) {
|
|
5484
|
-
return /* @__PURE__ */ jsx(
|
|
5485
|
-
View,
|
|
5486
|
-
{
|
|
5487
|
-
style: [
|
|
5488
|
-
styles25.bar,
|
|
5489
|
-
{ backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border }
|
|
5490
|
-
],
|
|
5491
|
-
children: unavailableSlot ?? /* @__PURE__ */ jsx(Text, { style: [styles25.hint, { color: theme.colors.ink3 }], children: "Voice needs react-native-webrtc and a development build." })
|
|
5492
|
-
}
|
|
5493
|
-
);
|
|
5494
|
-
}
|
|
5495
|
-
return /* @__PURE__ */ jsxs(
|
|
5496
|
-
View,
|
|
5497
|
-
{
|
|
5498
|
-
style: [
|
|
5499
|
-
styles25.bar,
|
|
5500
|
-
{ backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border }
|
|
5501
|
-
],
|
|
5502
|
-
children: [
|
|
5503
|
-
/* @__PURE__ */ jsxs(View, { style: styles25.row, children: [
|
|
5504
|
-
/* @__PURE__ */ jsx(
|
|
5505
|
-
View,
|
|
5506
|
-
{
|
|
5507
|
-
style: [
|
|
5508
|
-
styles25.dot,
|
|
5509
|
-
{ backgroundColor: connected ? theme.colors.brand : theme.colors.ink3 }
|
|
5510
|
-
]
|
|
5511
|
-
}
|
|
5512
|
-
),
|
|
5513
|
-
connected ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5514
|
-
/* @__PURE__ */ jsx(View, { style: styles25.people, children: participants.length === 0 ? /* @__PURE__ */ jsx(Text, { style: [styles25.hint, { color: theme.colors.ink3 }], children: "Waiting for others\u2026" }) : participants.map((p) => /* @__PURE__ */ jsx(ParticipantChip, { participant: p, label: label(p.userId) }, p.userId)) }),
|
|
5515
|
-
/* @__PURE__ */ jsx(
|
|
5516
|
-
Pressable,
|
|
5517
|
-
{
|
|
5518
|
-
onPress: toggleMute,
|
|
5519
|
-
accessibilityRole: "button",
|
|
5520
|
-
accessibilityState: { selected: muted },
|
|
5521
|
-
style: [
|
|
5522
|
-
styles25.btn,
|
|
5523
|
-
{
|
|
5524
|
-
borderColor: muted ? theme.colors.brand : theme.colors.border,
|
|
5525
|
-
backgroundColor: muted ? theme.colors.brandSoft : theme.colors.paper
|
|
5526
|
-
}
|
|
5527
|
-
],
|
|
5528
|
-
children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.ink2 }, children: muted ? "Unmute" : "Mute" })
|
|
5529
|
-
}
|
|
5530
|
-
),
|
|
5531
|
-
/* @__PURE__ */ jsx(
|
|
5532
|
-
Pressable,
|
|
5533
|
-
{
|
|
5534
|
-
onPress: leave,
|
|
5535
|
-
accessibilityRole: "button",
|
|
5536
|
-
style: [styles25.btn, { borderColor: theme.colors.error }],
|
|
5537
|
-
children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.error }, children: "Leave" })
|
|
5538
|
-
}
|
|
5539
|
-
)
|
|
5540
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5541
|
-
/* @__PURE__ */ jsx(Text, { style: [styles25.hint, { color: theme.colors.ink3 }], children: status === "connecting" ? "Connecting\u2026" : "Talk to everyone here" }),
|
|
5542
|
-
/* @__PURE__ */ jsx(
|
|
5543
|
-
Pressable,
|
|
5544
|
-
{
|
|
5545
|
-
onPress: () => void join(),
|
|
5546
|
-
disabled: status === "connecting",
|
|
5547
|
-
accessibilityRole: "button",
|
|
5548
|
-
style: [styles25.btn, styles25.btnPrimary, { backgroundColor: theme.colors.brand }],
|
|
5549
|
-
children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.onBrand, fontWeight: "600" }, children: status === "connecting" ? "Joining\u2026" : "Join Voice" })
|
|
5550
|
-
}
|
|
5551
|
-
)
|
|
5552
|
-
] })
|
|
5553
|
-
] }),
|
|
5554
|
-
error && /* @__PURE__ */ jsx(Text, { style: [styles25.error, { color: theme.colors.error }], children: error.message })
|
|
5555
|
-
]
|
|
5556
|
-
}
|
|
5557
|
-
);
|
|
5558
|
-
}
|
|
5559
|
-
function ParticipantChip({ participant, label }) {
|
|
5560
|
-
const theme = usePoolseTheme();
|
|
5561
|
-
return /* @__PURE__ */ jsxs(
|
|
5562
|
-
View,
|
|
5563
|
-
{
|
|
5564
|
-
style: [
|
|
5565
|
-
styles25.chip,
|
|
5566
|
-
{
|
|
5567
|
-
backgroundColor: theme.colors.paper,
|
|
5568
|
-
// The speaking ring is a border colour swap rather than an
|
|
5569
|
-
// extra element, so the row never reflows mid-sentence.
|
|
5570
|
-
borderColor: participant.speaking ? theme.colors.brand : theme.colors.border,
|
|
5571
|
-
opacity: participant.muted ? 0.62 : 1
|
|
5572
|
-
}
|
|
5573
|
-
],
|
|
5574
|
-
children: [
|
|
5575
|
-
/* @__PURE__ */ jsxs(Text, { style: { color: theme.colors.ink2, fontSize: 13 }, numberOfLines: 1, children: [
|
|
5576
|
-
label,
|
|
5577
|
-
participant.isSelf ? " (you)" : ""
|
|
5578
|
-
] }),
|
|
5579
|
-
participant.muted && /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.error, fontSize: 11, fontWeight: "700" }, children: "\u2715" })
|
|
5580
|
-
]
|
|
5581
|
-
}
|
|
5582
|
-
);
|
|
5583
|
-
}
|
|
5584
|
-
var styles25 = StyleSheet.create({
|
|
5585
|
-
bar: { paddingHorizontal: 14, paddingVertical: 8, borderBottomWidth: StyleSheet.hairlineWidth },
|
|
5586
|
-
row: { flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" },
|
|
5587
|
-
dot: { width: 8, height: 8, borderRadius: 4 },
|
|
5588
|
-
people: { flexDirection: "row", alignItems: "center", gap: 6, flexShrink: 1, flexWrap: "wrap" },
|
|
5589
|
-
chip: {
|
|
5590
|
-
flexDirection: "row",
|
|
5591
|
-
alignItems: "center",
|
|
5592
|
-
gap: 5,
|
|
5593
|
-
paddingHorizontal: 10,
|
|
5594
|
-
paddingVertical: 4,
|
|
5595
|
-
borderRadius: 999,
|
|
5596
|
-
borderWidth: 1
|
|
5597
|
-
},
|
|
5598
|
-
btn: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 999, borderWidth: 1 },
|
|
5599
|
-
btnPrimary: { borderWidth: 0 },
|
|
5600
|
-
hint: { fontSize: 13, flexShrink: 1 },
|
|
5601
|
-
error: { fontSize: 12, marginTop: 6 }
|
|
5602
|
-
});
|
|
5603
|
-
|
|
5604
5434
|
// src/voice/callTheme.ts
|
|
5605
5435
|
var callColors = {
|
|
5606
5436
|
/** Behind everything. Near-black, cooled toward the brand. */
|
|
@@ -5636,6 +5466,106 @@ var callColors = {
|
|
|
5636
5466
|
};
|
|
5637
5467
|
var CONTROL_SIZE = 58;
|
|
5638
5468
|
var CONTROL_SIZE_LARGE = 68;
|
|
5469
|
+
function CallControlButton({
|
|
5470
|
+
icon,
|
|
5471
|
+
label,
|
|
5472
|
+
active = false,
|
|
5473
|
+
tone = "neutral",
|
|
5474
|
+
large = false,
|
|
5475
|
+
disabled = false,
|
|
5476
|
+
onPress,
|
|
5477
|
+
accessibilityLabel
|
|
5478
|
+
}) {
|
|
5479
|
+
const size = large ? CONTROL_SIZE_LARGE : CONTROL_SIZE;
|
|
5480
|
+
const background = tone === "danger" ? callColors.danger : tone === "accept" ? callColors.accept : active ? callColors.controlActive : callColors.control;
|
|
5481
|
+
const iconColor = tone === "neutral" && active ? callColors.controlActiveIcon : callColors.onAction;
|
|
5482
|
+
return /* @__PURE__ */ jsxs(View, { style: styles25.slot, children: [
|
|
5483
|
+
/* @__PURE__ */ jsx(
|
|
5484
|
+
Pressable,
|
|
5485
|
+
{
|
|
5486
|
+
onPress,
|
|
5487
|
+
disabled,
|
|
5488
|
+
accessibilityRole: "button",
|
|
5489
|
+
accessibilityState: { disabled, selected: active },
|
|
5490
|
+
accessibilityLabel: accessibilityLabel ?? label ?? icon,
|
|
5491
|
+
hitSlop: 8,
|
|
5492
|
+
style: ({ pressed }) => [
|
|
5493
|
+
styles25.button,
|
|
5494
|
+
{
|
|
5495
|
+
width: size,
|
|
5496
|
+
height: size,
|
|
5497
|
+
borderRadius: size / 2,
|
|
5498
|
+
backgroundColor: background,
|
|
5499
|
+
// Feedback without a layout shift — scaling a round button
|
|
5500
|
+
// inside a fixed slot keeps the row from twitching.
|
|
5501
|
+
opacity: disabled ? 0.4 : pressed ? 0.75 : 1
|
|
5502
|
+
}
|
|
5503
|
+
],
|
|
5504
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: large ? 30 : 25, color: iconColor, label: null })
|
|
5505
|
+
}
|
|
5506
|
+
),
|
|
5507
|
+
label ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles25.label, children: label }) : null
|
|
5508
|
+
] });
|
|
5509
|
+
}
|
|
5510
|
+
var styles25 = StyleSheet.create({
|
|
5511
|
+
// Fixed width so captions of different lengths cannot shift the row.
|
|
5512
|
+
slot: { width: 76, alignItems: "center", gap: 7 },
|
|
5513
|
+
button: { alignItems: "center", justifyContent: "center" },
|
|
5514
|
+
label: { color: callColors.textDim, fontSize: 11.5, fontWeight: "500" }
|
|
5515
|
+
});
|
|
5516
|
+
function CallAvatar({ name, seed, size, speaking = false }) {
|
|
5517
|
+
const ring = Math.max(2, Math.round(size * 0.045));
|
|
5518
|
+
const outer = size + ring * 4;
|
|
5519
|
+
return /* @__PURE__ */ jsx(
|
|
5520
|
+
View,
|
|
5521
|
+
{
|
|
5522
|
+
style: [
|
|
5523
|
+
styles26.ring,
|
|
5524
|
+
{
|
|
5525
|
+
width: outer,
|
|
5526
|
+
height: outer,
|
|
5527
|
+
borderRadius: outer / 2,
|
|
5528
|
+
borderWidth: ring,
|
|
5529
|
+
borderColor: speaking ? callColors.accept : "transparent"
|
|
5530
|
+
}
|
|
5531
|
+
],
|
|
5532
|
+
children: /* @__PURE__ */ jsx(
|
|
5533
|
+
View,
|
|
5534
|
+
{
|
|
5535
|
+
style: [
|
|
5536
|
+
styles26.circle,
|
|
5537
|
+
{
|
|
5538
|
+
width: size,
|
|
5539
|
+
height: size,
|
|
5540
|
+
borderRadius: size / 2,
|
|
5541
|
+
backgroundColor: userColor(seed)
|
|
5542
|
+
}
|
|
5543
|
+
],
|
|
5544
|
+
children: /* @__PURE__ */ jsx(
|
|
5545
|
+
Text,
|
|
5546
|
+
{
|
|
5547
|
+
style: [styles26.initials, { fontSize: Math.round(size * 0.38) }],
|
|
5548
|
+
numberOfLines: 1,
|
|
5549
|
+
allowFontScaling: false,
|
|
5550
|
+
children: initialsOf(name)
|
|
5551
|
+
}
|
|
5552
|
+
)
|
|
5553
|
+
}
|
|
5554
|
+
)
|
|
5555
|
+
}
|
|
5556
|
+
);
|
|
5557
|
+
}
|
|
5558
|
+
function initialsOf(name) {
|
|
5559
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
5560
|
+
if (parts.length === 0) return "?";
|
|
5561
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
5562
|
+
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
5563
|
+
}
|
|
5564
|
+
var styles26 = StyleSheet.create({
|
|
5565
|
+
ring: { alignItems: "center", justifyContent: "center" },
|
|
5566
|
+
circle: { alignItems: "center", justifyContent: "center" },
|
|
5567
|
+
initials: { color: "#ffffff", fontWeight: "600" }
|
|
5568
|
+
});
|
|
5639
5569
|
var ICONS2 = {
|
|
5640
5570
|
speaker: "speaker",
|
|
5641
5571
|
earpiece: "phone",
|
|
@@ -5659,15 +5589,15 @@ function AudioRouteSheet({
|
|
|
5659
5589
|
animationType: "fade",
|
|
5660
5590
|
onRequestClose: onClose,
|
|
5661
5591
|
...EDGE_TO_EDGE_MODAL,
|
|
5662
|
-
children: /* @__PURE__ */ jsx(Pressable, { style:
|
|
5592
|
+
children: /* @__PURE__ */ jsx(Pressable, { style: styles27.backdrop, onPress: onClose, accessibilityRole: "button", children: /* @__PURE__ */ jsxs(
|
|
5663
5593
|
Pressable,
|
|
5664
5594
|
{
|
|
5665
|
-
style: [
|
|
5595
|
+
style: [styles27.sheet, { paddingBottom: Math.max(34, insets.bottom + 16) }],
|
|
5666
5596
|
onPress: () => {
|
|
5667
5597
|
},
|
|
5668
5598
|
children: [
|
|
5669
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
5670
|
-
/* @__PURE__ */ jsx(Text, { style:
|
|
5599
|
+
/* @__PURE__ */ jsx(View, { style: styles27.grabber }),
|
|
5600
|
+
/* @__PURE__ */ jsx(Text, { style: styles27.title, children: "Audio output" }),
|
|
5671
5601
|
routes.map((route) => {
|
|
5672
5602
|
const selected = route.id === selectedRouteId;
|
|
5673
5603
|
return /* @__PURE__ */ jsxs(
|
|
@@ -5679,7 +5609,7 @@ function AudioRouteSheet({
|
|
|
5679
5609
|
},
|
|
5680
5610
|
accessibilityRole: "button",
|
|
5681
5611
|
accessibilityState: { selected },
|
|
5682
|
-
style: ({ pressed }) => [
|
|
5612
|
+
style: ({ pressed }) => [styles27.row, pressed && styles27.rowPressed],
|
|
5683
5613
|
children: [
|
|
5684
5614
|
/* @__PURE__ */ jsx(
|
|
5685
5615
|
PoolseIcon,
|
|
@@ -5690,7 +5620,7 @@ function AudioRouteSheet({
|
|
|
5690
5620
|
label: null
|
|
5691
5621
|
}
|
|
5692
5622
|
),
|
|
5693
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
5623
|
+
/* @__PURE__ */ jsx(Text, { style: [styles27.label, selected && styles27.labelSelected], children: route.label }),
|
|
5694
5624
|
selected && /* @__PURE__ */ jsx(PoolseIcon, { name: "check", size: 19, color: callColors.accept, label: "selected" })
|
|
5695
5625
|
]
|
|
5696
5626
|
},
|
|
@@ -5703,7 +5633,7 @@ function AudioRouteSheet({
|
|
|
5703
5633
|
}
|
|
5704
5634
|
);
|
|
5705
5635
|
}
|
|
5706
|
-
var
|
|
5636
|
+
var styles27 = StyleSheet.create({
|
|
5707
5637
|
backdrop: { flex: 1, backgroundColor: "rgba(0,0,0,0.55)", justifyContent: "flex-end" },
|
|
5708
5638
|
sheet: {
|
|
5709
5639
|
backgroundColor: callColors.tile,
|
|
@@ -5742,641 +5672,18 @@ var styles26 = StyleSheet.create({
|
|
|
5742
5672
|
label: { flex: 1, color: callColors.text, fontSize: 16, fontWeight: "500" },
|
|
5743
5673
|
labelSelected: { color: callColors.accept }
|
|
5744
5674
|
});
|
|
5745
|
-
function
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
/* @__PURE__ */ jsx(Stop, { offset: "0.55", stopColor: callColors.glow, stopOpacity: 0.16 }),
|
|
5751
|
-
/* @__PURE__ */ jsx(Stop, { offset: "1", stopColor: callColors.glow, stopOpacity: 0 })
|
|
5752
|
-
] }),
|
|
5753
|
-
/* @__PURE__ */ jsxs(RadialGradient, { id: "call-glow-low", cx: "12%", cy: "96%", r: "70%", children: [
|
|
5754
|
-
/* @__PURE__ */ jsx(Stop, { offset: "0", stopColor: callColors.glowWarm, stopOpacity: 0.2 }),
|
|
5755
|
-
/* @__PURE__ */ jsx(Stop, { offset: "1", stopColor: callColors.glowWarm, stopOpacity: 0 })
|
|
5756
|
-
] })
|
|
5757
|
-
] }),
|
|
5758
|
-
/* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: callColors.bg }),
|
|
5759
|
-
/* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: "url(#call-glow-top)" }),
|
|
5760
|
-
/* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: "url(#call-glow-low)" })
|
|
5761
|
-
] }) });
|
|
5762
|
-
}
|
|
5763
|
-
function PulseRings({ size, color }) {
|
|
5764
|
-
const phases = [useRef(new Animated.Value(0)), useRef(new Animated.Value(0)), useRef(new Animated.Value(0))];
|
|
5675
|
+
function useCallDuration(connected) {
|
|
5676
|
+
const startedAt = useRef(null);
|
|
5677
|
+
const [, tick] = useState(0);
|
|
5678
|
+
if (connected && startedAt.current === null) startedAt.current = Date.now();
|
|
5679
|
+
if (!connected && startedAt.current !== null) startedAt.current = null;
|
|
5765
5680
|
useEffect(() => {
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
toValue: 1,
|
|
5773
|
-
duration: 2100,
|
|
5774
|
-
easing: Easing.out(Easing.quad),
|
|
5775
|
-
useNativeDriver: true
|
|
5776
|
-
}),
|
|
5777
|
-
// Restart the stagger from zero so the rings stay evenly
|
|
5778
|
-
// spaced instead of bunching after the first cycle.
|
|
5779
|
-
Animated.timing(p.current, { toValue: 0, duration: 0, useNativeDriver: true })
|
|
5780
|
-
])
|
|
5781
|
-
);
|
|
5782
|
-
loop.start();
|
|
5783
|
-
return loop;
|
|
5784
|
-
});
|
|
5785
|
-
return () => loops.forEach((l) => l.stop());
|
|
5786
|
-
}, []);
|
|
5787
|
-
return /* @__PURE__ */ jsx(View, { style: [StyleSheet.absoluteFill, styles27.center], pointerEvents: "none", children: phases.map((p, i) => /* @__PURE__ */ jsx(
|
|
5788
|
-
Animated.View,
|
|
5789
|
-
{
|
|
5790
|
-
style: [
|
|
5791
|
-
styles27.ring,
|
|
5792
|
-
{
|
|
5793
|
-
width: size,
|
|
5794
|
-
height: size,
|
|
5795
|
-
borderRadius: size / 2,
|
|
5796
|
-
borderColor: color,
|
|
5797
|
-
opacity: p.current.interpolate({
|
|
5798
|
-
inputRange: [0, 0.15, 1],
|
|
5799
|
-
outputRange: [0, 0.45, 0]
|
|
5800
|
-
}),
|
|
5801
|
-
transform: [
|
|
5802
|
-
{
|
|
5803
|
-
scale: p.current.interpolate({ inputRange: [0, 1], outputRange: [1, 1.9] })
|
|
5804
|
-
}
|
|
5805
|
-
]
|
|
5806
|
-
}
|
|
5807
|
-
]
|
|
5808
|
-
},
|
|
5809
|
-
i
|
|
5810
|
-
)) });
|
|
5811
|
-
}
|
|
5812
|
-
var styles27 = StyleSheet.create({
|
|
5813
|
-
center: { alignItems: "center", justifyContent: "center" },
|
|
5814
|
-
ring: { position: "absolute", borderWidth: 1.5 }
|
|
5815
|
-
});
|
|
5816
|
-
function CallAvatar({ name, seed, size, speaking = false }) {
|
|
5817
|
-
const ring = Math.max(2, Math.round(size * 0.045));
|
|
5818
|
-
const outer = size + ring * 4;
|
|
5819
|
-
return /* @__PURE__ */ jsx(
|
|
5820
|
-
View,
|
|
5821
|
-
{
|
|
5822
|
-
style: [
|
|
5823
|
-
styles28.ring,
|
|
5824
|
-
{
|
|
5825
|
-
width: outer,
|
|
5826
|
-
height: outer,
|
|
5827
|
-
borderRadius: outer / 2,
|
|
5828
|
-
borderWidth: ring,
|
|
5829
|
-
borderColor: speaking ? callColors.accept : "transparent"
|
|
5830
|
-
}
|
|
5831
|
-
],
|
|
5832
|
-
children: /* @__PURE__ */ jsx(
|
|
5833
|
-
View,
|
|
5834
|
-
{
|
|
5835
|
-
style: [
|
|
5836
|
-
styles28.circle,
|
|
5837
|
-
{
|
|
5838
|
-
width: size,
|
|
5839
|
-
height: size,
|
|
5840
|
-
borderRadius: size / 2,
|
|
5841
|
-
backgroundColor: userColor(seed)
|
|
5842
|
-
}
|
|
5843
|
-
],
|
|
5844
|
-
children: /* @__PURE__ */ jsx(
|
|
5845
|
-
Text,
|
|
5846
|
-
{
|
|
5847
|
-
style: [styles28.initials, { fontSize: Math.round(size * 0.38) }],
|
|
5848
|
-
numberOfLines: 1,
|
|
5849
|
-
allowFontScaling: false,
|
|
5850
|
-
children: initialsOf(name)
|
|
5851
|
-
}
|
|
5852
|
-
)
|
|
5853
|
-
}
|
|
5854
|
-
)
|
|
5855
|
-
}
|
|
5856
|
-
);
|
|
5857
|
-
}
|
|
5858
|
-
function initialsOf(name) {
|
|
5859
|
-
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
5860
|
-
if (parts.length === 0) return "?";
|
|
5861
|
-
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
5862
|
-
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
5863
|
-
}
|
|
5864
|
-
var styles28 = StyleSheet.create({
|
|
5865
|
-
ring: { alignItems: "center", justifyContent: "center" },
|
|
5866
|
-
circle: { alignItems: "center", justifyContent: "center" },
|
|
5867
|
-
initials: { color: "#ffffff", fontWeight: "600" }
|
|
5868
|
-
});
|
|
5869
|
-
function CallControlButton({
|
|
5870
|
-
icon,
|
|
5871
|
-
label,
|
|
5872
|
-
active = false,
|
|
5873
|
-
tone = "neutral",
|
|
5874
|
-
large = false,
|
|
5875
|
-
disabled = false,
|
|
5876
|
-
onPress,
|
|
5877
|
-
accessibilityLabel
|
|
5878
|
-
}) {
|
|
5879
|
-
const size = large ? CONTROL_SIZE_LARGE : CONTROL_SIZE;
|
|
5880
|
-
const background = tone === "danger" ? callColors.danger : tone === "accept" ? callColors.accept : active ? callColors.controlActive : callColors.control;
|
|
5881
|
-
const iconColor = tone === "neutral" && active ? callColors.controlActiveIcon : callColors.onAction;
|
|
5882
|
-
return /* @__PURE__ */ jsxs(View, { style: styles29.slot, children: [
|
|
5883
|
-
/* @__PURE__ */ jsx(
|
|
5884
|
-
Pressable,
|
|
5885
|
-
{
|
|
5886
|
-
onPress,
|
|
5887
|
-
disabled,
|
|
5888
|
-
accessibilityRole: "button",
|
|
5889
|
-
accessibilityState: { disabled, selected: active },
|
|
5890
|
-
accessibilityLabel: accessibilityLabel ?? label ?? icon,
|
|
5891
|
-
hitSlop: 8,
|
|
5892
|
-
style: ({ pressed }) => [
|
|
5893
|
-
styles29.button,
|
|
5894
|
-
{
|
|
5895
|
-
width: size,
|
|
5896
|
-
height: size,
|
|
5897
|
-
borderRadius: size / 2,
|
|
5898
|
-
backgroundColor: background,
|
|
5899
|
-
// Feedback without a layout shift — scaling a round button
|
|
5900
|
-
// inside a fixed slot keeps the row from twitching.
|
|
5901
|
-
opacity: disabled ? 0.4 : pressed ? 0.75 : 1
|
|
5902
|
-
}
|
|
5903
|
-
],
|
|
5904
|
-
children: /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: large ? 30 : 25, color: iconColor, label: null })
|
|
5905
|
-
}
|
|
5906
|
-
),
|
|
5907
|
-
label ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles29.label, children: label }) : null
|
|
5908
|
-
] });
|
|
5909
|
-
}
|
|
5910
|
-
var styles29 = StyleSheet.create({
|
|
5911
|
-
// Fixed width so captions of different lengths cannot shift the row.
|
|
5912
|
-
slot: { width: 76, alignItems: "center", gap: 7 },
|
|
5913
|
-
button: { alignItems: "center", justifyContent: "center" },
|
|
5914
|
-
label: { color: callColors.textDim, fontSize: 11.5, fontWeight: "500" }
|
|
5915
|
-
});
|
|
5916
|
-
function CallParticipantTile({
|
|
5917
|
-
participant,
|
|
5918
|
-
VideoTrack,
|
|
5919
|
-
label,
|
|
5920
|
-
style,
|
|
5921
|
-
avatarSize = 72,
|
|
5922
|
-
bleed = false,
|
|
5923
|
-
hideName = false
|
|
5924
|
-
}) {
|
|
5925
|
-
const name = participant.isSelf ? "You" : participant.name ?? label(participant.userId);
|
|
5926
|
-
const hasVideo = Boolean(participant.videoTrackRef && VideoTrack);
|
|
5927
|
-
return /* @__PURE__ */ jsxs(
|
|
5928
|
-
View,
|
|
5929
|
-
{
|
|
5930
|
-
style: [
|
|
5931
|
-
styles30.tile,
|
|
5932
|
-
bleed ? styles30.bleed : styles30.rounded,
|
|
5933
|
-
{
|
|
5934
|
-
backgroundColor: callColors.tile,
|
|
5935
|
-
// A ring rather than a badge: it reads at a glance across a
|
|
5936
|
-
// grid, and it doesn't cover anyone's face.
|
|
5937
|
-
borderColor: participant.speaking ? callColors.accept : "transparent"
|
|
5938
|
-
},
|
|
5939
|
-
style
|
|
5940
|
-
],
|
|
5941
|
-
children: [
|
|
5942
|
-
hasVideo && VideoTrack ? /* @__PURE__ */ jsx(
|
|
5943
|
-
VideoTrack,
|
|
5944
|
-
{
|
|
5945
|
-
trackRef: participant.videoTrackRef,
|
|
5946
|
-
style: StyleSheet.absoluteFillObject,
|
|
5947
|
-
objectFit: "cover",
|
|
5948
|
-
mirror: participant.isSelf,
|
|
5949
|
-
zOrder: participant.isSelf ? 1 : 0
|
|
5950
|
-
}
|
|
5951
|
-
) : /* @__PURE__ */ jsx(View, { style: styles30.placeholder, children: /* @__PURE__ */ jsx(
|
|
5952
|
-
CallAvatar,
|
|
5953
|
-
{
|
|
5954
|
-
name,
|
|
5955
|
-
seed: participant.userId,
|
|
5956
|
-
size: avatarSize,
|
|
5957
|
-
speaking: participant.speaking
|
|
5958
|
-
}
|
|
5959
|
-
) }),
|
|
5960
|
-
!hideName && /* @__PURE__ */ jsxs(View, { style: [styles30.chip, bleed ? styles30.chipBleed : styles30.chipTile], children: [
|
|
5961
|
-
!participant.micEnabled && // Worth showing even for yourself — it is the answer to
|
|
5962
|
-
// "why can nobody hear me".
|
|
5963
|
-
/* @__PURE__ */ jsx(PoolseIcon, { name: "mic-off", size: 13, color: callColors.text, label: "muted" }),
|
|
5964
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles30.name, children: name })
|
|
5965
|
-
] })
|
|
5966
|
-
]
|
|
5967
|
-
}
|
|
5968
|
-
);
|
|
5969
|
-
}
|
|
5970
|
-
var styles30 = StyleSheet.create({
|
|
5971
|
-
tile: { overflow: "hidden", justifyContent: "flex-end", borderWidth: 2 },
|
|
5972
|
-
rounded: { borderRadius: 18 },
|
|
5973
|
-
bleed: { borderRadius: 0, borderWidth: 0 },
|
|
5974
|
-
placeholder: { ...StyleSheet.absoluteFillObject, alignItems: "center", justifyContent: "center" },
|
|
5975
|
-
chip: {
|
|
5976
|
-
flexDirection: "row",
|
|
5977
|
-
alignItems: "center",
|
|
5978
|
-
gap: 5,
|
|
5979
|
-
alignSelf: "flex-start",
|
|
5980
|
-
borderRadius: 999,
|
|
5981
|
-
// Legible over both a bright video frame and a flat placeholder.
|
|
5982
|
-
backgroundColor: "rgba(0,0,0,0.55)"
|
|
5983
|
-
},
|
|
5984
|
-
chipTile: { margin: 8, paddingHorizontal: 9, paddingVertical: 4.5, maxWidth: "92%" },
|
|
5985
|
-
chipBleed: { margin: 14, paddingHorizontal: 11, paddingVertical: 6, maxWidth: "80%" },
|
|
5986
|
-
name: { color: callColors.text, fontSize: 12.5, fontWeight: "600", flexShrink: 1 }
|
|
5987
|
-
});
|
|
5988
|
-
var PIP_WIDTH = 108;
|
|
5989
|
-
var PIP_HEIGHT = 152;
|
|
5990
|
-
var MARGIN = 12;
|
|
5991
|
-
function LocalVideoPip({
|
|
5992
|
-
participant,
|
|
5993
|
-
VideoTrack,
|
|
5994
|
-
label,
|
|
5995
|
-
bounds,
|
|
5996
|
-
insets,
|
|
5997
|
-
onPress
|
|
5998
|
-
}) {
|
|
5999
|
-
const top = insets?.top ?? 0;
|
|
6000
|
-
const bottom = insets?.bottom ?? 0;
|
|
6001
|
-
const corners = useMemo(() => {
|
|
6002
|
-
const right = Math.max(MARGIN, bounds.width - PIP_WIDTH - MARGIN);
|
|
6003
|
-
const low = Math.max(MARGIN, bounds.height - PIP_HEIGHT - bottom - MARGIN);
|
|
6004
|
-
const high = top + MARGIN;
|
|
6005
|
-
return [
|
|
6006
|
-
{ x: MARGIN, y: high },
|
|
6007
|
-
{ x: right, y: high },
|
|
6008
|
-
{ x: MARGIN, y: low },
|
|
6009
|
-
{ x: right, y: low }
|
|
6010
|
-
];
|
|
6011
|
-
}, [bounds.width, bounds.height, top, bottom]);
|
|
6012
|
-
const [corner, setCorner] = useState(1);
|
|
6013
|
-
const pan = useRef(new Animated.ValueXY(corners[1])).current;
|
|
6014
|
-
const cornersRef = useRef(corners);
|
|
6015
|
-
cornersRef.current = corners;
|
|
6016
|
-
const cornerRef = useRef(corner);
|
|
6017
|
-
cornerRef.current = corner;
|
|
6018
|
-
const dragged = useRef(false);
|
|
6019
|
-
useEffect(() => {
|
|
6020
|
-
if (dragged.current) return;
|
|
6021
|
-
const at = corners[corner];
|
|
6022
|
-
if (at) pan.setValue(at);
|
|
6023
|
-
}, [corners, corner, pan]);
|
|
6024
|
-
const responder = useMemo(
|
|
6025
|
-
() => PanResponder.create({
|
|
6026
|
-
// Claim the gesture only once it is clearly a drag. A lower
|
|
6027
|
-
// threshold would swallow the taps that flip the camera.
|
|
6028
|
-
onMoveShouldSetPanResponder: (_evt, g) => Math.abs(g.dx) > 4 || Math.abs(g.dy) > 4,
|
|
6029
|
-
onPanResponderGrant: () => {
|
|
6030
|
-
dragged.current = true;
|
|
6031
|
-
const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1];
|
|
6032
|
-
pan.setOffset({ x: at.x, y: at.y });
|
|
6033
|
-
pan.setValue({ x: 0, y: 0 });
|
|
6034
|
-
},
|
|
6035
|
-
onPanResponderMove: Animated.event([null, { dx: pan.x, dy: pan.y }], {
|
|
6036
|
-
useNativeDriver: false
|
|
6037
|
-
}),
|
|
6038
|
-
onPanResponderRelease: (_evt, g) => {
|
|
6039
|
-
pan.flattenOffset();
|
|
6040
|
-
const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1];
|
|
6041
|
-
const dropped = { x: at.x + g.dx, y: at.y + g.dy };
|
|
6042
|
-
let best = 0;
|
|
6043
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
6044
|
-
cornersRef.current.forEach((c, index) => {
|
|
6045
|
-
const distance = (c.x - dropped.x) ** 2 + (c.y - dropped.y) ** 2;
|
|
6046
|
-
if (distance < bestDistance) {
|
|
6047
|
-
bestDistance = distance;
|
|
6048
|
-
best = index;
|
|
6049
|
-
}
|
|
6050
|
-
});
|
|
6051
|
-
setCorner(best);
|
|
6052
|
-
Animated.spring(pan, {
|
|
6053
|
-
toValue: cornersRef.current[best],
|
|
6054
|
-
useNativeDriver: false,
|
|
6055
|
-
friction: 8,
|
|
6056
|
-
tension: 70
|
|
6057
|
-
}).start(() => {
|
|
6058
|
-
dragged.current = false;
|
|
6059
|
-
});
|
|
6060
|
-
}
|
|
6061
|
-
}),
|
|
6062
|
-
[pan]
|
|
6063
|
-
);
|
|
6064
|
-
return /* @__PURE__ */ jsx(
|
|
6065
|
-
Animated.View,
|
|
6066
|
-
{
|
|
6067
|
-
...responder.panHandlers,
|
|
6068
|
-
style: [styles31.pip, { transform: pan.getTranslateTransform() }],
|
|
6069
|
-
children: /* @__PURE__ */ jsx(
|
|
6070
|
-
Pressable,
|
|
6071
|
-
{
|
|
6072
|
-
onPress: () => {
|
|
6073
|
-
if (dragged.current) return;
|
|
6074
|
-
onPress?.();
|
|
6075
|
-
},
|
|
6076
|
-
accessibilityRole: "button",
|
|
6077
|
-
accessibilityLabel: "Your camera. Drag to move, tap to switch camera.",
|
|
6078
|
-
style: styles31.fill,
|
|
6079
|
-
children: /* @__PURE__ */ jsx(View, { style: styles31.fill, children: /* @__PURE__ */ jsx(
|
|
6080
|
-
CallParticipantTile,
|
|
6081
|
-
{
|
|
6082
|
-
participant,
|
|
6083
|
-
VideoTrack,
|
|
6084
|
-
label,
|
|
6085
|
-
avatarSize: 48,
|
|
6086
|
-
hideName: true,
|
|
6087
|
-
bleed: true,
|
|
6088
|
-
style: styles31.fill
|
|
6089
|
-
}
|
|
6090
|
-
) })
|
|
6091
|
-
}
|
|
6092
|
-
)
|
|
6093
|
-
}
|
|
6094
|
-
);
|
|
6095
|
-
}
|
|
6096
|
-
var styles31 = StyleSheet.create({
|
|
6097
|
-
pip: {
|
|
6098
|
-
position: "absolute",
|
|
6099
|
-
top: 0,
|
|
6100
|
-
left: 0,
|
|
6101
|
-
width: PIP_WIDTH,
|
|
6102
|
-
height: PIP_HEIGHT,
|
|
6103
|
-
// Generous enough to read as a bubble rather than a cropped
|
|
6104
|
-
// rectangle. The video is clipped to it, so this is the only
|
|
6105
|
-
// rounding in play.
|
|
6106
|
-
borderRadius: 22,
|
|
6107
|
-
overflow: "hidden",
|
|
6108
|
-
// Lifted off the video so it reads as floating rather than inset.
|
|
6109
|
-
shadowColor: "#000",
|
|
6110
|
-
shadowOpacity: 0.4,
|
|
6111
|
-
shadowRadius: 12,
|
|
6112
|
-
shadowOffset: { width: 0, height: 4 },
|
|
6113
|
-
elevation: 8
|
|
6114
|
-
},
|
|
6115
|
-
fill: { flex: 1 }
|
|
6116
|
-
});
|
|
6117
|
-
var GAP = 8;
|
|
6118
|
-
var MIN_TILE_HEIGHT = 132;
|
|
6119
|
-
function CallVideoGrid({
|
|
6120
|
-
participants,
|
|
6121
|
-
livekitReactNative,
|
|
6122
|
-
labelFor,
|
|
6123
|
-
onLocalPress,
|
|
6124
|
-
chromeInsets,
|
|
6125
|
-
safeArea
|
|
6126
|
-
}) {
|
|
6127
|
-
const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
|
|
6128
|
-
const VideoTrack = livekitReactNative?.VideoTrack;
|
|
6129
|
-
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
6130
|
-
const onLayout = (event) => {
|
|
6131
|
-
const { width: width2, height } = event.nativeEvent.layout;
|
|
6132
|
-
setSize(
|
|
6133
|
-
(current) => current.width === width2 && current.height === height ? current : { width: width2, height }
|
|
6134
|
-
);
|
|
6135
|
-
};
|
|
6136
|
-
const self = participants.find((p) => p.isSelf) ?? null;
|
|
6137
|
-
const others = useMemo(() => participants.filter((p) => !p.isSelf), [participants]);
|
|
6138
|
-
const columns = others.length + 1 <= 6 ? 2 : 3;
|
|
6139
|
-
const rows = Math.ceil((others.length + 1) / columns);
|
|
6140
|
-
const padTop = safeArea?.top ?? 0;
|
|
6141
|
-
const padBottom = safeArea?.bottom ?? 0;
|
|
6142
|
-
const availableHeight = size.height > 0 ? size.height - padTop - padBottom : 0;
|
|
6143
|
-
const tileHeight = availableHeight > 0 ? (availableHeight - GAP * (rows - 1)) / rows : 0;
|
|
6144
|
-
const scrolls = tileHeight > 0 && tileHeight < MIN_TILE_HEIGHT;
|
|
6145
|
-
if (participants.length === 0) return /* @__PURE__ */ jsx(View, { style: styles32.stage, onLayout });
|
|
6146
|
-
if (others.length <= 1) {
|
|
6147
|
-
const spotlight = others[0] ?? self;
|
|
6148
|
-
if (!spotlight) return /* @__PURE__ */ jsx(View, { style: styles32.stage, onLayout });
|
|
6149
|
-
return /* @__PURE__ */ jsxs(View, { style: styles32.stage, onLayout, children: [
|
|
6150
|
-
/* @__PURE__ */ jsx(
|
|
6151
|
-
CallParticipantTile,
|
|
6152
|
-
{
|
|
6153
|
-
participant: spotlight,
|
|
6154
|
-
VideoTrack,
|
|
6155
|
-
label,
|
|
6156
|
-
avatarSize: Math.min(148, Math.max(96, Math.round(size.width * 0.36))),
|
|
6157
|
-
bleed: true,
|
|
6158
|
-
hideName: others.length === 1,
|
|
6159
|
-
style: styles32.fill
|
|
6160
|
-
}
|
|
6161
|
-
),
|
|
6162
|
-
self && others.length === 1 && size.width > 0 && /* @__PURE__ */ jsx(
|
|
6163
|
-
LocalVideoPip,
|
|
6164
|
-
{
|
|
6165
|
-
participant: self,
|
|
6166
|
-
VideoTrack,
|
|
6167
|
-
label,
|
|
6168
|
-
bounds: size,
|
|
6169
|
-
insets: safeArea ?? { top: 0, bottom: 0 },
|
|
6170
|
-
onPress: onLocalPress
|
|
6171
|
-
}
|
|
6172
|
-
)
|
|
6173
|
-
] });
|
|
6174
|
-
}
|
|
6175
|
-
const tiles = [...others, ...self ? [self] : []];
|
|
6176
|
-
const width = size.width > 0 ? (size.width - GAP * (columns - 1)) / columns : 0;
|
|
6177
|
-
const grid = /* @__PURE__ */ jsx(View, { style: [styles32.grid, scrolls ? styles32.gridScrolling : styles32.gridFilling], children: tiles.map((participant) => /* @__PURE__ */ jsx(
|
|
6178
|
-
CallParticipantTile,
|
|
6179
|
-
{
|
|
6180
|
-
participant,
|
|
6181
|
-
VideoTrack,
|
|
6182
|
-
label,
|
|
6183
|
-
avatarSize: columns === 2 ? 66 : 46,
|
|
6184
|
-
style: {
|
|
6185
|
-
width: width || void 0,
|
|
6186
|
-
height: scrolls ? MIN_TILE_HEIGHT : tileHeight || void 0
|
|
6187
|
-
}
|
|
6188
|
-
},
|
|
6189
|
-
participant.userId
|
|
6190
|
-
)) });
|
|
6191
|
-
return /* @__PURE__ */ jsx(
|
|
6192
|
-
View,
|
|
6193
|
-
{
|
|
6194
|
-
style: [styles32.stage, { paddingTop: padTop, paddingBottom: padBottom }],
|
|
6195
|
-
onLayout,
|
|
6196
|
-
children: scrolls ? /* @__PURE__ */ jsx(
|
|
6197
|
-
ScrollView,
|
|
6198
|
-
{
|
|
6199
|
-
contentContainerStyle: [
|
|
6200
|
-
styles32.scroll,
|
|
6201
|
-
{ paddingBottom: (chromeInsets?.bottom ?? 0) + GAP }
|
|
6202
|
-
],
|
|
6203
|
-
showsVerticalScrollIndicator: false,
|
|
6204
|
-
children: grid
|
|
6205
|
-
}
|
|
6206
|
-
) : grid
|
|
6207
|
-
}
|
|
6208
|
-
);
|
|
6209
|
-
}
|
|
6210
|
-
var styles32 = StyleSheet.create({
|
|
6211
|
-
stage: { flex: 1, overflow: "hidden" },
|
|
6212
|
-
fill: { ...StyleSheet.absoluteFillObject },
|
|
6213
|
-
grid: { flexDirection: "row", flexWrap: "wrap", gap: GAP },
|
|
6214
|
-
gridFilling: { flex: 1, alignContent: "center" },
|
|
6215
|
-
gridScrolling: { alignContent: "flex-start" },
|
|
6216
|
-
scroll: { paddingVertical: GAP }
|
|
6217
|
-
});
|
|
6218
|
-
|
|
6219
|
-
// src/voice/livekit-rn.ts
|
|
6220
|
-
function describeRoute(id) {
|
|
6221
|
-
switch (id) {
|
|
6222
|
-
case "speaker":
|
|
6223
|
-
case "force_speaker":
|
|
6224
|
-
return { id, kind: "speaker", label: "Speaker" };
|
|
6225
|
-
case "earpiece":
|
|
6226
|
-
return { id, kind: "earpiece", label: "Phone" };
|
|
6227
|
-
case "headset":
|
|
6228
|
-
return { id, kind: "headset", label: "Headphones" };
|
|
6229
|
-
case "bluetooth":
|
|
6230
|
-
return { id, kind: "bluetooth", label: "Bluetooth" };
|
|
6231
|
-
case "default":
|
|
6232
|
-
return { id, kind: "auto", label: "iPhone" };
|
|
6233
|
-
default:
|
|
6234
|
-
return { id, kind: "auto", label: id };
|
|
6235
|
-
}
|
|
6236
|
-
}
|
|
6237
|
-
|
|
6238
|
-
// src/voice/useCallAudio.ts
|
|
6239
|
-
var IOS_AUTO = "default";
|
|
6240
|
-
var IOS_SPEAKER = "force_speaker";
|
|
6241
|
-
function useCallAudio({
|
|
6242
|
-
active,
|
|
6243
|
-
video,
|
|
6244
|
-
livekitReactNative
|
|
6245
|
-
}) {
|
|
6246
|
-
const session = livekitReactNative?.AudioSession;
|
|
6247
|
-
const ios = Platform.OS === "ios";
|
|
6248
|
-
const [routes, setRoutes] = useState([]);
|
|
6249
|
-
const [selectedRouteId, setSelectedRouteId] = useState(null);
|
|
6250
|
-
const preferSpeaker = useRef(video);
|
|
6251
|
-
if (!active) preferSpeaker.current = video;
|
|
6252
|
-
const userChose = useRef(false);
|
|
6253
|
-
if (!active) userChose.current = false;
|
|
6254
|
-
const refreshRoutes = useCallback(() => {
|
|
6255
|
-
if (!session) return;
|
|
6256
|
-
void session.getAudioOutputs().then((ids) => setRoutes(ids.map(describeRoute))).catch(() => {
|
|
6257
|
-
});
|
|
6258
|
-
}, [session]);
|
|
6259
|
-
useEffect(() => {
|
|
6260
|
-
if (!active || !session) return;
|
|
6261
|
-
const wantsSpeaker = preferSpeaker.current;
|
|
6262
|
-
let disposePolicy;
|
|
6263
|
-
let released = false;
|
|
6264
|
-
void (async () => {
|
|
6265
|
-
try {
|
|
6266
|
-
await session.configureAudio({
|
|
6267
|
-
android: {
|
|
6268
|
-
// Best device first. A headset or car kit outranks the
|
|
6269
|
-
// built-in outputs either way; the media type only decides
|
|
6270
|
-
// which built-in output wins when nothing is plugged in.
|
|
6271
|
-
preferredOutputList: wantsSpeaker ? ["bluetooth", "headset", "speaker", "earpiece"] : ["bluetooth", "headset", "earpiece", "speaker"]
|
|
6272
|
-
},
|
|
6273
|
-
ios: { defaultOutput: wantsSpeaker ? "speaker" : "earpiece" }
|
|
6274
|
-
});
|
|
6275
|
-
} catch {
|
|
6276
|
-
}
|
|
6277
|
-
if (released) return;
|
|
6278
|
-
disposePolicy = livekitReactNative?.setupIOSAudioManagement?.(wantsSpeaker);
|
|
6279
|
-
try {
|
|
6280
|
-
await session.startAudioSession();
|
|
6281
|
-
} catch {
|
|
6282
|
-
}
|
|
6283
|
-
if (released) {
|
|
6284
|
-
void session.stopAudioSession().catch(() => {
|
|
6285
|
-
});
|
|
6286
|
-
disposePolicy?.();
|
|
6287
|
-
return;
|
|
6288
|
-
}
|
|
6289
|
-
refreshRoutes();
|
|
6290
|
-
})();
|
|
6291
|
-
return () => {
|
|
6292
|
-
released = true;
|
|
6293
|
-
void session.stopAudioSession().catch(() => {
|
|
6294
|
-
});
|
|
6295
|
-
disposePolicy?.();
|
|
6296
|
-
};
|
|
6297
|
-
}, [active, session, livekitReactNative, refreshRoutes]);
|
|
6298
|
-
useEffect(() => {
|
|
6299
|
-
if (active) return;
|
|
6300
|
-
setSelectedRouteId(null);
|
|
6301
|
-
setRoutes([]);
|
|
6302
|
-
}, [active]);
|
|
6303
|
-
useEffect(() => {
|
|
6304
|
-
if (!active) return;
|
|
6305
|
-
const events = livekitReactNative?.audioDeviceModuleEvents;
|
|
6306
|
-
if (!events) return;
|
|
6307
|
-
const onChange = () => refreshRoutes();
|
|
6308
|
-
try {
|
|
6309
|
-
events.addDevicesUpdatedListener(onChange);
|
|
6310
|
-
} catch {
|
|
6311
|
-
return;
|
|
6312
|
-
}
|
|
6313
|
-
return () => {
|
|
6314
|
-
try {
|
|
6315
|
-
events.removeDevicesUpdatedListener(onChange);
|
|
6316
|
-
} catch {
|
|
6317
|
-
}
|
|
6318
|
-
};
|
|
6319
|
-
}, [active, livekitReactNative, refreshRoutes]);
|
|
6320
|
-
const selectRoute = useCallback(
|
|
6321
|
-
(id) => {
|
|
6322
|
-
userChose.current = true;
|
|
6323
|
-
setSelectedRouteId(id);
|
|
6324
|
-
if (!session) return;
|
|
6325
|
-
void session.selectAudioOutput(id).catch(() => {
|
|
6326
|
-
refreshRoutes();
|
|
6327
|
-
});
|
|
6328
|
-
},
|
|
6329
|
-
[session, refreshRoutes]
|
|
6330
|
-
);
|
|
6331
|
-
const externalDevice = useMemo(
|
|
6332
|
-
() => routes.some((r) => r.kind === "headset" || r.kind === "bluetooth"),
|
|
6333
|
-
[routes]
|
|
6334
|
-
);
|
|
6335
|
-
const speakerOn = selectedRouteId === null ? preferSpeaker.current && !externalDevice : ios ? selectedRouteId === IOS_SPEAKER : selectedRouteId === "speaker";
|
|
6336
|
-
const setSpeaker = useCallback(
|
|
6337
|
-
(on) => {
|
|
6338
|
-
if (ios) {
|
|
6339
|
-
selectRoute(on ? IOS_SPEAKER : IOS_AUTO);
|
|
6340
|
-
return;
|
|
6341
|
-
}
|
|
6342
|
-
if (on) {
|
|
6343
|
-
selectRoute("speaker");
|
|
6344
|
-
return;
|
|
6345
|
-
}
|
|
6346
|
-
const fallback = routes.find((r) => r.kind === "bluetooth") ?? routes.find((r) => r.kind === "headset") ?? routes.find((r) => r.kind === "earpiece");
|
|
6347
|
-
if (fallback) selectRoute(fallback.id);
|
|
6348
|
-
},
|
|
6349
|
-
[ios, routes, selectRoute]
|
|
6350
|
-
);
|
|
6351
|
-
const toggleSpeaker = useCallback(() => setSpeaker(!speakerOn), [setSpeaker, speakerOn]);
|
|
6352
|
-
const openSystemRoutePicker = useCallback(() => {
|
|
6353
|
-
void session?.showAudioRoutePicker?.().catch(() => {
|
|
6354
|
-
});
|
|
6355
|
-
}, [session]);
|
|
6356
|
-
return {
|
|
6357
|
-
speakerOn,
|
|
6358
|
-
toggleSpeaker,
|
|
6359
|
-
setSpeaker,
|
|
6360
|
-
routes,
|
|
6361
|
-
selectedRouteId,
|
|
6362
|
-
selectRoute,
|
|
6363
|
-
externalDevice,
|
|
6364
|
-
canPickSystemRoute: ios && typeof session?.showAudioRoutePicker === "function",
|
|
6365
|
-
openSystemRoutePicker
|
|
6366
|
-
};
|
|
6367
|
-
}
|
|
6368
|
-
function useCallDuration(connected) {
|
|
6369
|
-
const startedAt = useRef(null);
|
|
6370
|
-
const [, tick] = useState(0);
|
|
6371
|
-
if (connected && startedAt.current === null) startedAt.current = Date.now();
|
|
6372
|
-
if (!connected && startedAt.current !== null) startedAt.current = null;
|
|
6373
|
-
useEffect(() => {
|
|
6374
|
-
if (!connected) return;
|
|
6375
|
-
const id = setInterval(() => tick((n) => n + 1), 1e3);
|
|
6376
|
-
return () => clearInterval(id);
|
|
6377
|
-
}, [connected]);
|
|
6378
|
-
if (!connected || startedAt.current === null) return null;
|
|
6379
|
-
return format(Math.max(0, Math.floor((Date.now() - startedAt.current) / 1e3)));
|
|
5681
|
+
if (!connected) return;
|
|
5682
|
+
const id = setInterval(() => tick((n) => n + 1), 1e3);
|
|
5683
|
+
return () => clearInterval(id);
|
|
5684
|
+
}, [connected]);
|
|
5685
|
+
if (!connected || startedAt.current === null) return null;
|
|
5686
|
+
return format(Math.max(0, Math.floor((Date.now() - startedAt.current) / 1e3)));
|
|
6380
5687
|
}
|
|
6381
5688
|
function format(total) {
|
|
6382
5689
|
const hours = Math.floor(total / 3600);
|
|
@@ -6385,697 +5692,7 @@ function format(total) {
|
|
|
6385
5692
|
const mm = hours > 0 ? String(minutes).padStart(2, "0") : String(minutes);
|
|
6386
5693
|
return `${hours > 0 ? `${hours}:` : ""}${mm}:${String(seconds).padStart(2, "0")}`;
|
|
6387
5694
|
}
|
|
6388
|
-
var CHROME_IDLE_MS = 4500;
|
|
6389
|
-
var ENDED_LINGER_MS = 2500;
|
|
6390
|
-
function isOver(phase) {
|
|
6391
|
-
return phase === "declined" || phase === "busy" || phase === "timed-out";
|
|
6392
|
-
}
|
|
6393
|
-
function CallScreen({
|
|
6394
|
-
userId,
|
|
6395
|
-
labelFor,
|
|
6396
|
-
conversationLabel,
|
|
6397
|
-
calls: callsProp,
|
|
6398
|
-
webrtc,
|
|
6399
|
-
livekit,
|
|
6400
|
-
livekitReactNative,
|
|
6401
|
-
onStatusChange,
|
|
6402
|
-
onTransportChange,
|
|
6403
|
-
onVideoChange,
|
|
6404
|
-
onSpeakerChange,
|
|
6405
|
-
inCallManager,
|
|
6406
|
-
nativeIncomingUi
|
|
6407
|
-
}) {
|
|
6408
|
-
const [insets, setInsets] = useState({ top: 0, bottom: 0, left: 0, right: 0 });
|
|
6409
|
-
const ownCalls = useCalls(callsProp ? null : userId);
|
|
6410
|
-
const calls = callsProp ?? ownCalls;
|
|
6411
|
-
const meshAvailable = isNativeWebRtcAvailable(webrtc);
|
|
6412
|
-
const opts = useMemo(
|
|
6413
|
-
() => meshAvailable && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {},
|
|
6414
|
-
[meshAvailable, webrtc]
|
|
6415
|
-
);
|
|
6416
|
-
const conversationId = calls.phase === "active" ? calls.activeConversationId : calls.phase === "ringing-out" ? calls.outgoing?.conversationId ?? null : null;
|
|
6417
|
-
const isVideoCall = calls.media === "video";
|
|
6418
|
-
const sfu = useCallRoom(livekit ? conversationId : null, {
|
|
6419
|
-
livekit,
|
|
6420
|
-
video: isVideoCall
|
|
6421
|
-
});
|
|
6422
|
-
const mesh = useVoiceRoom(conversationId, opts);
|
|
6423
|
-
const usingSfu = sfu.sfuAvailable === true;
|
|
6424
|
-
const status = usingSfu ? toVoiceStatus(sfu.status) : mesh.status;
|
|
6425
|
-
const connected = calls.phase === "active" && status === "connected";
|
|
6426
|
-
useEffect(() => {
|
|
6427
|
-
const wants = calls.phase === "active" || calls.phase === "ringing-out";
|
|
6428
|
-
if (!wants || !conversationId) return;
|
|
6429
|
-
let cancelled = false;
|
|
6430
|
-
void (async () => {
|
|
6431
|
-
const joined = livekit ? await sfu.join() : false;
|
|
6432
|
-
if (cancelled || joined) return;
|
|
6433
|
-
if (meshAvailable) await mesh.join();
|
|
6434
|
-
})();
|
|
6435
|
-
return () => {
|
|
6436
|
-
cancelled = true;
|
|
6437
|
-
};
|
|
6438
|
-
}, [calls.phase, conversationId, livekit, meshAvailable]);
|
|
6439
|
-
useEffect(() => {
|
|
6440
|
-
onStatusChange?.(status);
|
|
6441
|
-
}, [status, onStatusChange]);
|
|
6442
|
-
const transport = status !== "connected" ? null : usingSfu ? "sfu" : "mesh";
|
|
6443
|
-
useEffect(() => {
|
|
6444
|
-
onTransportChange?.(transport);
|
|
6445
|
-
}, [transport, onTransportChange]);
|
|
6446
|
-
const videoOn = usingSfu && sfu.cameraEnabled;
|
|
6447
|
-
useEffect(() => {
|
|
6448
|
-
onVideoChange?.(videoOn);
|
|
6449
|
-
}, [videoOn, onVideoChange]);
|
|
6450
|
-
const audio = useCallAudio({
|
|
6451
|
-
active: calls.phase !== "idle" && transport !== "mesh",
|
|
6452
|
-
video: isVideoCall,
|
|
6453
|
-
livekitReactNative
|
|
6454
|
-
});
|
|
6455
|
-
const [routesOpen, setRoutesOpen] = useState(false);
|
|
6456
|
-
useEffect(() => {
|
|
6457
|
-
onSpeakerChange?.(audio.speakerOn, audio.externalDevice);
|
|
6458
|
-
}, [audio.speakerOn, audio.externalDevice, onSpeakerChange]);
|
|
6459
|
-
const showingIncoming = calls.phase === "ringing-in" && !nativeIncomingUi;
|
|
6460
|
-
useEffect(() => {
|
|
6461
|
-
const ringing = calls.phase === "ringing-out";
|
|
6462
|
-
if (!ringing && !showingIncoming) return;
|
|
6463
|
-
try {
|
|
6464
|
-
const start = ringing ? inCallManager?.startRingback : inCallManager?.startRingtone;
|
|
6465
|
-
start?.(ringing ? "_BUNDLE_" : "_DEFAULT_");
|
|
6466
|
-
} catch {
|
|
6467
|
-
}
|
|
6468
|
-
return () => {
|
|
6469
|
-
try {
|
|
6470
|
-
inCallManager?.stopRingback?.();
|
|
6471
|
-
inCallManager?.stopRingtone?.();
|
|
6472
|
-
} catch {
|
|
6473
|
-
}
|
|
6474
|
-
};
|
|
6475
|
-
}, [calls.phase, showingIncoming, inCallManager]);
|
|
6476
|
-
const [chromeVisible, setChromeVisible] = useState(true);
|
|
6477
|
-
const [lastWake, setLastWake] = useState(0);
|
|
6478
|
-
const chromeHides = connected && isVideoCall;
|
|
6479
|
-
useEffect(() => {
|
|
6480
|
-
setChromeVisible(true);
|
|
6481
|
-
if (!chromeHides) return;
|
|
6482
|
-
const timer = setTimeout(() => setChromeVisible(false), CHROME_IDLE_MS);
|
|
6483
|
-
return () => clearTimeout(timer);
|
|
6484
|
-
}, [chromeHides, lastWake]);
|
|
6485
|
-
const wakeChrome = useCallback(() => setLastWake(Date.now()), []);
|
|
6486
|
-
const toggleChrome = useCallback(() => {
|
|
6487
|
-
setChromeVisible((visible2) => {
|
|
6488
|
-
if (visible2) return false;
|
|
6489
|
-
setLastWake(Date.now());
|
|
6490
|
-
return true;
|
|
6491
|
-
});
|
|
6492
|
-
}, []);
|
|
6493
|
-
const withWake = useCallback(
|
|
6494
|
-
(fn) => () => {
|
|
6495
|
-
wakeChrome();
|
|
6496
|
-
fn();
|
|
6497
|
-
},
|
|
6498
|
-
[wakeChrome]
|
|
6499
|
-
);
|
|
6500
|
-
const hangUp = useCallback(() => {
|
|
6501
|
-
sfu.leave();
|
|
6502
|
-
mesh.leave();
|
|
6503
|
-
void calls.hangUp();
|
|
6504
|
-
}, [sfu, mesh, calls]);
|
|
6505
|
-
const othersNow = (usingSfu ? sfu.participants : mesh.participants).filter(
|
|
6506
|
-
(p) => !p.isSelf
|
|
6507
|
-
).length;
|
|
6508
|
-
useEffect(() => {
|
|
6509
|
-
calls.reportOthersOnCall?.(othersNow);
|
|
6510
|
-
}, [calls, othersNow]);
|
|
6511
|
-
const alone = usingSfu ? sfu.alone : mesh.alone;
|
|
6512
|
-
const endedOnEmpty = useRef(false);
|
|
6513
|
-
if (calls.phase !== "active") endedOnEmpty.current = false;
|
|
6514
|
-
useEffect(() => {
|
|
6515
|
-
if (!alone || calls.phase !== "active" || endedOnEmpty.current) return;
|
|
6516
|
-
endedOnEmpty.current = true;
|
|
6517
|
-
hangUp();
|
|
6518
|
-
}, [alone, calls.phase, hangUp]);
|
|
6519
|
-
useEffect(() => {
|
|
6520
|
-
if (!isOver(calls.phase)) return;
|
|
6521
|
-
const timer = setTimeout(calls.reset, ENDED_LINGER_MS);
|
|
6522
|
-
return () => clearTimeout(timer);
|
|
6523
|
-
}, [calls.phase, calls.reset]);
|
|
6524
|
-
const micOn = usingSfu ? sfu.micEnabled : !mesh.muted;
|
|
6525
|
-
const toggleMic = useCallback(() => {
|
|
6526
|
-
if (usingSfu) void sfu.toggleMic();
|
|
6527
|
-
else mesh.toggleMute();
|
|
6528
|
-
}, [usingSfu, sfu, mesh]);
|
|
6529
|
-
const onSpeakerPress = useCallback(() => {
|
|
6530
|
-
if (audio.routes.length > 2) setRoutesOpen(true);
|
|
6531
|
-
else if (audio.canPickSystemRoute && audio.externalDevice) audio.openSystemRoutePicker();
|
|
6532
|
-
else audio.toggleSpeaker();
|
|
6533
|
-
}, [audio]);
|
|
6534
|
-
const label = useMemo(() => labelFor ?? ((id) => `User ${id.slice(0, 6)}`), [labelFor]);
|
|
6535
|
-
const ringingIn = calls.phase === "ringing-in";
|
|
6536
|
-
const ringingOut = calls.phase === "ringing-out";
|
|
6537
|
-
const ended = isOver(calls.phase);
|
|
6538
|
-
const visible = calls.phase !== "idle" && !(nativeIncomingUi && ringingIn);
|
|
6539
|
-
const duration = useCallDuration(connected);
|
|
6540
|
-
const participants = usingSfu ? sfu.participants : [];
|
|
6541
|
-
const others = participants.filter((p) => !p.isSelf);
|
|
6542
|
-
const isGroup = others.length > 1 || (calls.outgoing?.calleeUserIds.length ?? 0) > 1;
|
|
6543
|
-
const peerIds = ringingIn && calls.incoming ? [calls.incoming.callerUserId] : others.length > 0 ? others.map((p) => p.userId) : calls.outgoing?.calleeUserIds ?? [];
|
|
6544
|
-
const peerTitle = peerIds.length === 0 ? "Call" : peerIds.length <= 2 ? peerIds.map(label).join(", ") : `${label(peerIds[0])} and ${peerIds.length - 1} others`;
|
|
6545
|
-
const titleConversationId = conversationId ?? (ringingIn ? calls.incoming?.conversationId ?? null : null);
|
|
6546
|
-
const convName = titleConversationId ? conversationLabel?.(titleConversationId) ?? null : null;
|
|
6547
|
-
const title = convName || peerTitle;
|
|
6548
|
-
const statusText = duration ?? statusLine(calls, status);
|
|
6549
|
-
const subtitle = convName && !duration && peerIds.length > 0 ? `${peerTitle} \xB7 ${statusText}` : statusText;
|
|
6550
|
-
const showStage = connected && usingSfu && participants.length > 0;
|
|
6551
|
-
const rawError = calls.error ?? (usingSfu ? sfu.error : mesh.error);
|
|
6552
|
-
const error = connected ? null : rawError;
|
|
6553
|
-
const chromeInsets = {
|
|
6554
|
-
top: insets.top + 72,
|
|
6555
|
-
bottom: insets.bottom + 236
|
|
6556
|
-
};
|
|
6557
|
-
return /* @__PURE__ */ jsxs(
|
|
6558
|
-
Modal,
|
|
6559
|
-
{
|
|
6560
|
-
visible,
|
|
6561
|
-
animationType: "slide",
|
|
6562
|
-
transparent: false,
|
|
6563
|
-
supportedOrientations: ["portrait", "landscape"],
|
|
6564
|
-
onRequestClose: hangUp,
|
|
6565
|
-
children: [
|
|
6566
|
-
/* @__PURE__ */ jsx(StatusBar, { barStyle: "light-content" }),
|
|
6567
|
-
/* @__PURE__ */ jsxs(SafeAreaProvider, { children: [
|
|
6568
|
-
/* @__PURE__ */ jsx(InsetsProbe, { onChange: setInsets }),
|
|
6569
|
-
/* @__PURE__ */ jsxs(Pressable, { style: styles33.screen, onPress: toggleChrome, accessible: false, children: [
|
|
6570
|
-
/* @__PURE__ */ jsx(CallBackdrop, {}),
|
|
6571
|
-
showStage ? /* @__PURE__ */ jsx(
|
|
6572
|
-
CallVideoGrid,
|
|
6573
|
-
{
|
|
6574
|
-
participants,
|
|
6575
|
-
livekitReactNative,
|
|
6576
|
-
labelFor: label,
|
|
6577
|
-
onLocalPress: () => void sfu.switchCamera(),
|
|
6578
|
-
chromeInsets,
|
|
6579
|
-
safeArea: { top: insets.top, bottom: insets.bottom }
|
|
6580
|
-
}
|
|
6581
|
-
) : (
|
|
6582
|
-
// Audio (and pre-media) calls carry their identity in the
|
|
6583
|
-
// middle of the scene — name under the avatar, status in a
|
|
6584
|
-
// pill — rather than a bar pinned to the top of a void.
|
|
6585
|
-
/* @__PURE__ */ jsxs(
|
|
6586
|
-
View,
|
|
6587
|
-
{
|
|
6588
|
-
style: [styles33.identity, { paddingBottom: insets.bottom + 160 }],
|
|
6589
|
-
pointerEvents: "none",
|
|
6590
|
-
children: [
|
|
6591
|
-
/* @__PURE__ */ jsxs(View, { style: styles33.avatarStage, children: [
|
|
6592
|
-
(ringingIn || ringingOut) && /* @__PURE__ */ jsx(PulseRings, { size: 132, color: callColors.glow }),
|
|
6593
|
-
/* @__PURE__ */ jsx(
|
|
6594
|
-
CallAvatar,
|
|
6595
|
-
{
|
|
6596
|
-
name: peerIds.length === 1 ? label(peerIds[0]) : title,
|
|
6597
|
-
seed: titleConversationId ?? peerIds[0] ?? "call",
|
|
6598
|
-
size: 132
|
|
6599
|
-
}
|
|
6600
|
-
)
|
|
6601
|
-
] }),
|
|
6602
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: styles33.identityTitle, children: title }),
|
|
6603
|
-
/* @__PURE__ */ jsxs(View, { style: styles33.statusPill, children: [
|
|
6604
|
-
connected && /* @__PURE__ */ jsx(View, { style: styles33.statusDot }),
|
|
6605
|
-
/* @__PURE__ */ jsx(Text, { style: styles33.statusText, children: subtitle })
|
|
6606
|
-
] })
|
|
6607
|
-
]
|
|
6608
|
-
}
|
|
6609
|
-
)
|
|
6610
|
-
),
|
|
6611
|
-
chromeVisible && showStage && /* @__PURE__ */ jsxs(View, { style: [styles33.header, { paddingTop: insets.top + 14 }], pointerEvents: "box-none", children: [
|
|
6612
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles33.title, children: title }),
|
|
6613
|
-
/* @__PURE__ */ jsxs(View, { style: styles33.subtitleRow, children: [
|
|
6614
|
-
isGroup && /* @__PURE__ */ jsx(PoolseIcon, { name: "users", size: 14, color: callColors.textDim, label: null }),
|
|
6615
|
-
/* @__PURE__ */ jsx(Text, { style: styles33.subtitle, children: isGroup ? `${participants.length} \xB7 ${subtitle}` : subtitle })
|
|
6616
|
-
] })
|
|
6617
|
-
] }),
|
|
6618
|
-
chromeVisible && /* @__PURE__ */ jsxs(
|
|
6619
|
-
View,
|
|
6620
|
-
{
|
|
6621
|
-
style: [styles33.controls, { paddingBottom: insets.bottom + 22 }],
|
|
6622
|
-
pointerEvents: "box-none",
|
|
6623
|
-
children: [
|
|
6624
|
-
error && /* @__PURE__ */ jsx(Text, { style: styles33.error, children: error.message }),
|
|
6625
|
-
!meshAvailable && !livekit && /* @__PURE__ */ jsx(Text, { style: styles33.error, children: "No WebRTC module supplied \u2014 this call has no audio." }),
|
|
6626
|
-
ringingIn ? /* @__PURE__ */ jsxs(View, { style: styles33.answerRow, children: [
|
|
6627
|
-
/* @__PURE__ */ jsx(
|
|
6628
|
-
CallControlButton,
|
|
6629
|
-
{
|
|
6630
|
-
icon: "phone-off",
|
|
6631
|
-
tone: "danger",
|
|
6632
|
-
large: true,
|
|
6633
|
-
label: "Decline",
|
|
6634
|
-
onPress: () => void calls.decline(),
|
|
6635
|
-
accessibilityLabel: "Decline call"
|
|
6636
|
-
}
|
|
6637
|
-
),
|
|
6638
|
-
/* @__PURE__ */ jsx(
|
|
6639
|
-
CallControlButton,
|
|
6640
|
-
{
|
|
6641
|
-
icon: isVideoCall ? "video" : "phone",
|
|
6642
|
-
tone: "accept",
|
|
6643
|
-
large: true,
|
|
6644
|
-
label: "Accept",
|
|
6645
|
-
onPress: () => void calls.accept(),
|
|
6646
|
-
accessibilityLabel: "Accept call"
|
|
6647
|
-
}
|
|
6648
|
-
)
|
|
6649
|
-
] }) : ended ? /* @__PURE__ */ jsx(View, { style: styles33.row, children: /* @__PURE__ */ jsx(
|
|
6650
|
-
CallControlButton,
|
|
6651
|
-
{
|
|
6652
|
-
icon: "close",
|
|
6653
|
-
onPress: calls.reset,
|
|
6654
|
-
label: "Close",
|
|
6655
|
-
accessibilityLabel: "Close"
|
|
6656
|
-
}
|
|
6657
|
-
) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6658
|
-
/* @__PURE__ */ jsxs(View, { style: styles33.dock, children: [
|
|
6659
|
-
/* @__PURE__ */ jsx(
|
|
6660
|
-
CallControlButton,
|
|
6661
|
-
{
|
|
6662
|
-
icon: micOn ? "mic" : "mic-off",
|
|
6663
|
-
label: micOn ? "Mute" : "Unmute",
|
|
6664
|
-
active: !micOn,
|
|
6665
|
-
onPress: withWake(toggleMic),
|
|
6666
|
-
accessibilityLabel: micOn ? "Mute microphone" : "Unmute microphone"
|
|
6667
|
-
}
|
|
6668
|
-
),
|
|
6669
|
-
/* @__PURE__ */ jsx(
|
|
6670
|
-
CallControlButton,
|
|
6671
|
-
{
|
|
6672
|
-
icon: speakerIcon(audio),
|
|
6673
|
-
label: speakerLabel(audio),
|
|
6674
|
-
active: audio.speakerOn,
|
|
6675
|
-
onPress: withWake(onSpeakerPress),
|
|
6676
|
-
accessibilityLabel: "Audio output"
|
|
6677
|
-
}
|
|
6678
|
-
),
|
|
6679
|
-
usingSfu && /* @__PURE__ */ jsx(
|
|
6680
|
-
CallControlButton,
|
|
6681
|
-
{
|
|
6682
|
-
icon: videoOn ? "video" : "video-off",
|
|
6683
|
-
label: "Camera",
|
|
6684
|
-
active: !videoOn,
|
|
6685
|
-
onPress: withWake(() => void sfu.toggleCamera()),
|
|
6686
|
-
accessibilityLabel: videoOn ? "Turn camera off" : "Turn camera on"
|
|
6687
|
-
}
|
|
6688
|
-
),
|
|
6689
|
-
usingSfu && videoOn && /* @__PURE__ */ jsx(
|
|
6690
|
-
CallControlButton,
|
|
6691
|
-
{
|
|
6692
|
-
icon: "camera-flip",
|
|
6693
|
-
label: "Flip",
|
|
6694
|
-
onPress: withWake(() => void sfu.switchCamera()),
|
|
6695
|
-
accessibilityLabel: "Switch camera"
|
|
6696
|
-
}
|
|
6697
|
-
)
|
|
6698
|
-
] }),
|
|
6699
|
-
/* @__PURE__ */ jsx(View, { style: styles33.hangUpRow, children: /* @__PURE__ */ jsx(
|
|
6700
|
-
CallControlButton,
|
|
6701
|
-
{
|
|
6702
|
-
icon: "phone-off",
|
|
6703
|
-
tone: "danger",
|
|
6704
|
-
large: true,
|
|
6705
|
-
onPress: ringingOut ? () => void calls.cancel() : hangUp,
|
|
6706
|
-
accessibilityLabel: ringingOut ? "Cancel call" : "Hang up"
|
|
6707
|
-
}
|
|
6708
|
-
) })
|
|
6709
|
-
] })
|
|
6710
|
-
]
|
|
6711
|
-
}
|
|
6712
|
-
),
|
|
6713
|
-
/* @__PURE__ */ jsx(
|
|
6714
|
-
AudioRouteSheet,
|
|
6715
|
-
{
|
|
6716
|
-
visible: routesOpen,
|
|
6717
|
-
routes: audio.routes,
|
|
6718
|
-
selectedRouteId: audio.selectedRouteId,
|
|
6719
|
-
onSelect: audio.selectRoute,
|
|
6720
|
-
onClose: () => setRoutesOpen(false)
|
|
6721
|
-
}
|
|
6722
|
-
)
|
|
6723
|
-
] })
|
|
6724
|
-
] })
|
|
6725
|
-
]
|
|
6726
|
-
}
|
|
6727
|
-
);
|
|
6728
|
-
}
|
|
6729
|
-
function InsetsProbe({
|
|
6730
|
-
onChange
|
|
6731
|
-
}) {
|
|
6732
|
-
const insets = useSafeAreaInsets();
|
|
6733
|
-
useEffect(() => {
|
|
6734
|
-
onChange({ top: insets.top, bottom: insets.bottom, left: insets.left, right: insets.right });
|
|
6735
|
-
}, [insets.top, insets.bottom, insets.left, insets.right, onChange]);
|
|
6736
|
-
return null;
|
|
6737
|
-
}
|
|
6738
|
-
function speakerIcon(audio) {
|
|
6739
|
-
if (audio.externalDevice) return "headphones";
|
|
6740
|
-
return audio.speakerOn ? "speaker" : "speaker-off";
|
|
6741
|
-
}
|
|
6742
|
-
function speakerLabel(audio) {
|
|
6743
|
-
return audio.externalDevice ? "Audio" : "Speaker";
|
|
6744
|
-
}
|
|
6745
|
-
function toVoiceStatus(status) {
|
|
6746
|
-
switch (status) {
|
|
6747
|
-
case "connecting":
|
|
6748
|
-
return "connecting";
|
|
6749
|
-
case "connected":
|
|
6750
|
-
return "connected";
|
|
6751
|
-
case "error":
|
|
6752
|
-
return "error";
|
|
6753
|
-
default:
|
|
6754
|
-
return "idle";
|
|
6755
|
-
}
|
|
6756
|
-
}
|
|
6757
|
-
function statusLine(calls, mediaStatus) {
|
|
6758
|
-
switch (calls.phase) {
|
|
6759
|
-
case "ringing-in":
|
|
6760
|
-
return calls.media === "video" ? "Incoming video call" : "Incoming call";
|
|
6761
|
-
case "ringing-out":
|
|
6762
|
-
return "Ringing\u2026";
|
|
6763
|
-
case "declined":
|
|
6764
|
-
return "Call declined";
|
|
6765
|
-
case "busy":
|
|
6766
|
-
return "Already on another call";
|
|
6767
|
-
case "timed-out":
|
|
6768
|
-
return "No answer";
|
|
6769
|
-
case "active":
|
|
6770
|
-
return mediaStatus === "connected" ? "Connected" : "Connecting\u2026";
|
|
6771
|
-
default:
|
|
6772
|
-
return "";
|
|
6773
|
-
}
|
|
6774
|
-
}
|
|
6775
|
-
var styles33 = StyleSheet.create({
|
|
6776
|
-
screen: { flex: 1, backgroundColor: callColors.bg },
|
|
6777
|
-
identity: {
|
|
6778
|
-
flex: 1,
|
|
6779
|
-
alignItems: "center",
|
|
6780
|
-
justifyContent: "center",
|
|
6781
|
-
paddingHorizontal: 32,
|
|
6782
|
-
gap: 18
|
|
6783
|
-
},
|
|
6784
|
-
avatarStage: {
|
|
6785
|
-
width: 132,
|
|
6786
|
-
height: 132,
|
|
6787
|
-
alignItems: "center",
|
|
6788
|
-
justifyContent: "center",
|
|
6789
|
-
marginBottom: 6
|
|
6790
|
-
},
|
|
6791
|
-
identityTitle: {
|
|
6792
|
-
color: callColors.text,
|
|
6793
|
-
fontSize: 30,
|
|
6794
|
-
fontWeight: "800",
|
|
6795
|
-
letterSpacing: -0.6,
|
|
6796
|
-
textAlign: "center"
|
|
6797
|
-
},
|
|
6798
|
-
statusPill: {
|
|
6799
|
-
flexDirection: "row",
|
|
6800
|
-
alignItems: "center",
|
|
6801
|
-
gap: 7,
|
|
6802
|
-
backgroundColor: callColors.glass,
|
|
6803
|
-
borderWidth: 1,
|
|
6804
|
-
borderColor: callColors.glassBorder,
|
|
6805
|
-
borderRadius: 999,
|
|
6806
|
-
paddingHorizontal: 14,
|
|
6807
|
-
paddingVertical: 7
|
|
6808
|
-
},
|
|
6809
|
-
statusDot: {
|
|
6810
|
-
width: 7,
|
|
6811
|
-
height: 7,
|
|
6812
|
-
borderRadius: 4,
|
|
6813
|
-
backgroundColor: callColors.accept
|
|
6814
|
-
},
|
|
6815
|
-
statusText: {
|
|
6816
|
-
color: callColors.textDim,
|
|
6817
|
-
fontSize: 13.5,
|
|
6818
|
-
fontWeight: "600",
|
|
6819
|
-
fontVariant: ["tabular-nums"]
|
|
6820
|
-
},
|
|
6821
|
-
header: {
|
|
6822
|
-
position: "absolute",
|
|
6823
|
-
top: 0,
|
|
6824
|
-
left: 0,
|
|
6825
|
-
right: 0,
|
|
6826
|
-
alignItems: "center",
|
|
6827
|
-
gap: 5,
|
|
6828
|
-
paddingHorizontal: 24,
|
|
6829
|
-
paddingBottom: 18,
|
|
6830
|
-
backgroundColor: callColors.scrim
|
|
6831
|
-
},
|
|
6832
|
-
title: { color: callColors.text, fontSize: 22, fontWeight: "700", textAlign: "center" },
|
|
6833
|
-
subtitleRow: { flexDirection: "row", alignItems: "center", gap: 6 },
|
|
6834
|
-
subtitle: { color: callColors.textDim, fontSize: 14.5 },
|
|
6835
|
-
controls: {
|
|
6836
|
-
position: "absolute",
|
|
6837
|
-
left: 0,
|
|
6838
|
-
right: 0,
|
|
6839
|
-
bottom: 0,
|
|
6840
|
-
alignItems: "center",
|
|
6841
|
-
gap: 18,
|
|
6842
|
-
paddingTop: 20
|
|
6843
|
-
},
|
|
6844
|
-
// The floating control dock: one glass card carrying the in-call
|
|
6845
|
-
// toggles, instead of loose buttons on a full-width scrim band.
|
|
6846
|
-
dock: {
|
|
6847
|
-
flexDirection: "row",
|
|
6848
|
-
justifyContent: "center",
|
|
6849
|
-
flexWrap: "wrap",
|
|
6850
|
-
rowGap: 16,
|
|
6851
|
-
backgroundColor: callColors.glass,
|
|
6852
|
-
borderWidth: 1,
|
|
6853
|
-
borderColor: callColors.glassBorder,
|
|
6854
|
-
borderRadius: 44,
|
|
6855
|
-
paddingVertical: 14,
|
|
6856
|
-
paddingHorizontal: 12,
|
|
6857
|
-
marginHorizontal: 24
|
|
6858
|
-
},
|
|
6859
|
-
row: { flexDirection: "row", justifyContent: "center", flexWrap: "wrap", rowGap: 16 },
|
|
6860
|
-
answerRow: { flexDirection: "row", justifyContent: "center", gap: 72 },
|
|
6861
|
-
hangUpRow: { flexDirection: "row", justifyContent: "center" },
|
|
6862
|
-
error: {
|
|
6863
|
-
color: callColors.danger,
|
|
6864
|
-
fontSize: 12.5,
|
|
6865
|
-
textAlign: "center",
|
|
6866
|
-
paddingHorizontal: 24
|
|
6867
|
-
}
|
|
6868
|
-
});
|
|
6869
|
-
function isCallOver(phase) {
|
|
6870
|
-
if (phase === void 0) return false;
|
|
6871
|
-
return phase !== "ringing-in" && phase !== "ringing-out" && phase !== "active";
|
|
6872
|
-
}
|
|
6873
|
-
function isStalePush(sentAt, now, staleAfterMs) {
|
|
6874
|
-
if (typeof sentAt !== "number" || !Number.isFinite(sentAt)) return false;
|
|
6875
|
-
const age = now - sentAt;
|
|
6876
|
-
if (age < 0) return false;
|
|
6877
|
-
return age > staleAfterMs;
|
|
6878
|
-
}
|
|
6879
|
-
function readPush(payload) {
|
|
6880
|
-
const callId = payload.call_id;
|
|
6881
|
-
if (!callId) return { kind: "ignore" };
|
|
6882
|
-
if (payload.event === "ended") return { kind: "teardown", callId };
|
|
6883
|
-
const conversationId = payload.conversation_id;
|
|
6884
|
-
if (!conversationId) return { kind: "ignore" };
|
|
6885
|
-
return {
|
|
6886
|
-
kind: "ring",
|
|
6887
|
-
sentAt: payload.sent_at,
|
|
6888
|
-
call: {
|
|
6889
|
-
callId,
|
|
6890
|
-
conversationId,
|
|
6891
|
-
callerUserId: payload.caller_user_id ?? "",
|
|
6892
|
-
callerName: payload.caller_name ?? "Incoming call",
|
|
6893
|
-
conversationName: payload.conversation_name ?? null,
|
|
6894
|
-
// `has_video` is what older servers sent; `media` supersedes it.
|
|
6895
|
-
// Either saying video means the system UI offers video.
|
|
6896
|
-
media: payload.media === "video" || payload.has_video ? "video" : "audio"
|
|
6897
|
-
}
|
|
6898
|
-
};
|
|
6899
|
-
}
|
|
6900
|
-
function useVoipCalls({
|
|
6901
|
-
voipPush,
|
|
6902
|
-
callKeep,
|
|
6903
|
-
calls,
|
|
6904
|
-
onAnswer,
|
|
6905
|
-
onDecline,
|
|
6906
|
-
appName = "poolse",
|
|
6907
|
-
apnsEnvironment,
|
|
6908
|
-
staleAfterMs = 12e4
|
|
6909
|
-
}) {
|
|
6910
|
-
const poolse = usePoolse();
|
|
6911
|
-
const shown = useRef(/* @__PURE__ */ new Map());
|
|
6912
|
-
const [voipToken, setVoipToken] = useState(null);
|
|
6913
|
-
const { me } = useMe();
|
|
6914
|
-
const registered = useRef(null);
|
|
6915
|
-
const handlers = useRef({ onAnswer, onDecline, calls });
|
|
6916
|
-
handlers.current = { onAnswer, onDecline, calls };
|
|
6917
|
-
const staleRef = useRef(staleAfterMs);
|
|
6918
|
-
staleRef.current = staleAfterMs;
|
|
6919
|
-
const ready = useRef(Promise.resolve());
|
|
6920
|
-
const answered = useRef(/* @__PURE__ */ new Set());
|
|
6921
|
-
const dismiss = useRef((callId) => {
|
|
6922
|
-
answered.current.delete(callId);
|
|
6923
|
-
if (!shown.current.has(callId)) return;
|
|
6924
|
-
shown.current.delete(callId);
|
|
6925
|
-
try {
|
|
6926
|
-
callKeep.endCall(callId);
|
|
6927
|
-
} catch {
|
|
6928
|
-
}
|
|
6929
|
-
});
|
|
6930
|
-
const present = useRef((call, sentAt) => {
|
|
6931
|
-
shown.current.set(call.callId, call);
|
|
6932
|
-
const show = () => {
|
|
6933
|
-
try {
|
|
6934
|
-
callKeep.displayIncomingCall(
|
|
6935
|
-
call.callId,
|
|
6936
|
-
call.callerUserId,
|
|
6937
|
-
call.conversationName || call.callerName,
|
|
6938
|
-
"generic",
|
|
6939
|
-
call.media === "video"
|
|
6940
|
-
);
|
|
6941
|
-
} catch {
|
|
6942
|
-
}
|
|
6943
|
-
};
|
|
6944
|
-
const done = () => {
|
|
6945
|
-
show();
|
|
6946
|
-
try {
|
|
6947
|
-
voipPush.onVoipNotificationCompleted?.(call.callId);
|
|
6948
|
-
} catch {
|
|
6949
|
-
}
|
|
6950
|
-
};
|
|
6951
|
-
void ready.current.then(done, done);
|
|
6952
|
-
if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);
|
|
6953
|
-
});
|
|
6954
|
-
useEffect(() => {
|
|
6955
|
-
const userId = me?.id;
|
|
6956
|
-
if (!voipToken || !userId) return;
|
|
6957
|
-
const pair = `${userId}:${voipToken}`;
|
|
6958
|
-
if (registered.current === pair) return;
|
|
6959
|
-
void poolse.devices.register({
|
|
6960
|
-
token: voipToken,
|
|
6961
|
-
platform: "ios",
|
|
6962
|
-
environment: apnsEnvironment ?? guessApnsEnvironment()
|
|
6963
|
-
}).then(() => {
|
|
6964
|
-
registered.current = pair;
|
|
6965
|
-
}).catch(() => {
|
|
6966
|
-
});
|
|
6967
|
-
}, [poolse, voipToken, me?.id, apnsEnvironment]);
|
|
6968
|
-
useEffect(() => {
|
|
6969
|
-
let cancelled = false;
|
|
6970
|
-
const fromPush = (payload) => {
|
|
6971
|
-
const intent = readPush(payload);
|
|
6972
|
-
if (intent.kind === "ignore") return;
|
|
6973
|
-
if (intent.kind === "teardown") {
|
|
6974
|
-
dismiss.current(intent.callId);
|
|
6975
|
-
handlers.current.calls?.dropped(intent.callId);
|
|
6976
|
-
return;
|
|
6977
|
-
}
|
|
6978
|
-
present.current(intent.call, intent.sentAt);
|
|
6979
|
-
handlers.current.calls?.ring({
|
|
6980
|
-
callId: intent.call.callId,
|
|
6981
|
-
conversationId: intent.call.conversationId,
|
|
6982
|
-
callerUserId: intent.call.callerUserId,
|
|
6983
|
-
media: intent.call.media
|
|
6984
|
-
});
|
|
6985
|
-
};
|
|
6986
|
-
ready.current = callKeep.setup({
|
|
6987
|
-
ios: { appName },
|
|
6988
|
-
android: {
|
|
6989
|
-
alertTitle: "Permissions required",
|
|
6990
|
-
alertDescription: "Allow calls from this app",
|
|
6991
|
-
cancelButton: "Cancel",
|
|
6992
|
-
okButton: "ok",
|
|
6993
|
-
additionalPermissions: []
|
|
6994
|
-
}
|
|
6995
|
-
}).catch(() => {
|
|
6996
|
-
});
|
|
6997
|
-
voipPush.addEventListener("register", ((token) => {
|
|
6998
|
-
if (cancelled || !token) return;
|
|
6999
|
-
setVoipToken(token);
|
|
7000
|
-
}));
|
|
7001
|
-
voipPush.addEventListener("notification", ((payload) => {
|
|
7002
|
-
fromPush(payload);
|
|
7003
|
-
}));
|
|
7004
|
-
voipPush.addEventListener("didLoadWithEvents", ((events) => {
|
|
7005
|
-
for (const event of events ?? []) {
|
|
7006
|
-
if (event.name === "RNVoipPushRemoteNotificationReceivedEvent") {
|
|
7007
|
-
fromPush(event.data);
|
|
7008
|
-
}
|
|
7009
|
-
}
|
|
7010
|
-
}));
|
|
7011
|
-
callKeep.addEventListener("answerCall", (({ callUUID }) => {
|
|
7012
|
-
const call = shown.current.get(callUUID);
|
|
7013
|
-
answered.current.add(callUUID);
|
|
7014
|
-
try {
|
|
7015
|
-
callKeep.setCurrentCallActive?.(callUUID);
|
|
7016
|
-
} catch {
|
|
7017
|
-
}
|
|
7018
|
-
if (!call) {
|
|
7019
|
-
void handlers.current.calls?.accept();
|
|
7020
|
-
return;
|
|
7021
|
-
}
|
|
7022
|
-
void handlers.current.calls?.accept({
|
|
7023
|
-
callId: call.callId,
|
|
7024
|
-
conversationId: call.conversationId,
|
|
7025
|
-
callerUserId: call.callerUserId,
|
|
7026
|
-
media: call.media
|
|
7027
|
-
});
|
|
7028
|
-
handlers.current.onAnswer?.(call);
|
|
7029
|
-
}));
|
|
7030
|
-
callKeep.addEventListener("endCall", (({ callUUID }) => {
|
|
7031
|
-
const call = shown.current.get(callUUID);
|
|
7032
|
-
const wasAnswered = answered.current.has(callUUID);
|
|
7033
|
-
shown.current.delete(callUUID);
|
|
7034
|
-
answered.current.delete(callUUID);
|
|
7035
|
-
if (!call || wasAnswered) {
|
|
7036
|
-
void handlers.current.calls?.hangUp();
|
|
7037
|
-
return;
|
|
7038
|
-
}
|
|
7039
|
-
void handlers.current.calls?.decline({
|
|
7040
|
-
callId: call.callId,
|
|
7041
|
-
conversationId: call.conversationId,
|
|
7042
|
-
callerUserId: call.callerUserId,
|
|
7043
|
-
media: call.media
|
|
7044
|
-
});
|
|
7045
|
-
handlers.current.onDecline?.(call);
|
|
7046
|
-
}));
|
|
7047
|
-
voipPush.registerVoipToken();
|
|
7048
|
-
return () => {
|
|
7049
|
-
cancelled = true;
|
|
7050
|
-
voipPush.removeEventListener("register");
|
|
7051
|
-
voipPush.removeEventListener("notification");
|
|
7052
|
-
voipPush.removeEventListener("didLoadWithEvents");
|
|
7053
|
-
callKeep.removeEventListener("answerCall");
|
|
7054
|
-
callKeep.removeEventListener("endCall");
|
|
7055
|
-
};
|
|
7056
|
-
}, [poolse, voipPush, callKeep, appName, apnsEnvironment]);
|
|
7057
|
-
const incoming = calls?.incoming ?? null;
|
|
7058
|
-
const phase = calls?.phase;
|
|
7059
|
-
useEffect(() => {
|
|
7060
|
-
if (phase === "ringing-in" && incoming) {
|
|
7061
|
-
present.current({
|
|
7062
|
-
callId: incoming.callId,
|
|
7063
|
-
conversationId: incoming.conversationId,
|
|
7064
|
-
callerUserId: incoming.callerUserId,
|
|
7065
|
-
callerName: incoming.callerUserId,
|
|
7066
|
-
media: incoming.media
|
|
7067
|
-
});
|
|
7068
|
-
}
|
|
7069
|
-
}, [phase, incoming]);
|
|
7070
|
-
useEffect(() => {
|
|
7071
|
-
if (!isCallOver(phase)) return;
|
|
7072
|
-
for (const callId of [...shown.current.keys()]) dismiss.current(callId);
|
|
7073
|
-
}, [phase]);
|
|
7074
|
-
}
|
|
7075
|
-
function guessApnsEnvironment() {
|
|
7076
|
-
return __DEV__ ? "sandbox" : "production";
|
|
7077
|
-
}
|
|
7078
5695
|
|
|
7079
|
-
export { AttachmentPicker, AttachmentPreview, AudioRouteSheet, Avatar, CallAvatar, CallControlButton, CallLogRow,
|
|
5696
|
+
export { AttachmentPicker, AttachmentPreview, AudioRouteSheet, Avatar, CallAvatar, CallControlButton, CallLogRow, ChatHeader, ConversationList, ConversationView, DaySeparator, GroupDetailsSheet, ImageMosaic, LiveCallBanner, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, MessageList, MessageRow, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, primitives as Primitives, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, callColors, defaultDarkTheme, defaultLightTheme, useAppStateLifecycle, useCallDuration, useDisplayName, usePoolseTheme };
|
|
7080
5697
|
//# sourceMappingURL=index.js.map
|
|
7081
5698
|
//# sourceMappingURL=index.js.map
|