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