@poolse/react-ui 2.14.0 → 2.15.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/dist/index.cjs +271 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -5
- package/dist/index.d.ts +71 -5
- package/dist/index.js +272 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,34 @@ All notable changes to `@poolse/react-ui` are documented here. Format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
|
|
5
5
|
[semver](https://semver.org).
|
|
6
6
|
|
|
7
|
+
## [2.15.0] — 2026-08-23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`CallProvider` and `useCallInvite`** — the web counterpart to
|
|
12
|
+
`@poolse/react-native`'s `CallScreen`. Mount `CallProvider` once at
|
|
13
|
+
the root and it owns ringing, answering, media and the call UI;
|
|
14
|
+
buttons anywhere below reach it through `useCallInvite`.
|
|
15
|
+
|
|
16
|
+
This exists because the alternative kept going wrong: a call surface
|
|
17
|
+
mounted inside a conversation view means the app cannot be called at
|
|
18
|
+
all while no conversation is open, and unmounts the call state machine
|
|
19
|
+
if the user navigates back to the list mid-call. Both present as
|
|
20
|
+
calling being unreliable rather than as a mounting mistake.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- The camera control is disabled when the machine has no camera, instead
|
|
25
|
+
of being a button that reports an error each time it is pressed.
|
|
26
|
+
|
|
27
|
+
## [2.14.1] — 2026-08-23
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- `CallDeviceMenu` renders a single-entry list instead of hiding. One
|
|
32
|
+
entry answers "is my microphone even being seen?", which a hidden
|
|
33
|
+
control does not. Only an empty list renders nothing.
|
|
34
|
+
|
|
7
35
|
## [2.14.0] — 2026-08-23
|
|
8
36
|
|
|
9
37
|
### Fixed
|
package/dist/index.cjs
CHANGED
|
@@ -547,6 +547,275 @@ function kindLabel(kind) {
|
|
|
547
547
|
if (kind === "audioinput") return "Microphone";
|
|
548
548
|
return "Output";
|
|
549
549
|
}
|
|
550
|
+
var InviteContext = react.createContext(null);
|
|
551
|
+
function useCallInvite() {
|
|
552
|
+
return react.useContext(InviteContext) ?? {
|
|
553
|
+
placeCall: () => {
|
|
554
|
+
},
|
|
555
|
+
busy: true
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
var CHROME_IDLE_MS = 4500;
|
|
559
|
+
function CallProvider({ userId, livekit, labelFor, children }) {
|
|
560
|
+
const calls = react$1.useCalls(userId);
|
|
561
|
+
const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
|
|
562
|
+
const placeCall = react.useCallback(
|
|
563
|
+
(conversationId, media = "audio") => {
|
|
564
|
+
void calls.call(conversationId, media);
|
|
565
|
+
},
|
|
566
|
+
[calls]
|
|
567
|
+
);
|
|
568
|
+
const invite = { placeCall, busy: calls.phase !== "idle" };
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(InviteContext.Provider, { value: invite, children: [
|
|
570
|
+
children,
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsx(CallSurface, { calls, livekit, labelFor: label })
|
|
572
|
+
] });
|
|
573
|
+
}
|
|
574
|
+
function CallSurface({
|
|
575
|
+
calls,
|
|
576
|
+
livekit,
|
|
577
|
+
labelFor
|
|
578
|
+
}) {
|
|
579
|
+
const conversationInCall = calls.phase === "active" ? calls.activeConversationId : null;
|
|
580
|
+
const isVideoCall = calls.media === "video";
|
|
581
|
+
const sfu = react$1.useCallRoom(conversationInCall, { livekit, video: isVideoCall });
|
|
582
|
+
const voice = react$1.useVoiceRoom(conversationInCall);
|
|
583
|
+
const usingSfu = sfu.sfuAvailable === true;
|
|
584
|
+
const mediaStatus = usingSfu ? sfu.status : voice.status;
|
|
585
|
+
const connected = calls.phase === "active" && mediaStatus === "connected";
|
|
586
|
+
react.useEffect(() => {
|
|
587
|
+
if (calls.phase !== "active" || !conversationInCall) return;
|
|
588
|
+
let cancelled = false;
|
|
589
|
+
void (async () => {
|
|
590
|
+
const joined = await sfu.join();
|
|
591
|
+
if (cancelled || joined) return;
|
|
592
|
+
await voice.join();
|
|
593
|
+
})();
|
|
594
|
+
return () => {
|
|
595
|
+
cancelled = true;
|
|
596
|
+
};
|
|
597
|
+
}, [calls.phase, conversationInCall]);
|
|
598
|
+
const hangUp = react.useCallback(() => {
|
|
599
|
+
sfu.leave();
|
|
600
|
+
voice.leave();
|
|
601
|
+
void calls.hangUp();
|
|
602
|
+
}, [sfu, voice, calls]);
|
|
603
|
+
const alone = usingSfu ? sfu.alone : voice.alone;
|
|
604
|
+
const endedOnEmpty = react.useRef(false);
|
|
605
|
+
if (calls.phase !== "active") endedOnEmpty.current = false;
|
|
606
|
+
react.useEffect(() => {
|
|
607
|
+
if (!alone || calls.phase !== "active" || endedOnEmpty.current) return;
|
|
608
|
+
endedOnEmpty.current = true;
|
|
609
|
+
hangUp();
|
|
610
|
+
}, [alone, calls.phase, hangUp]);
|
|
611
|
+
const [chromeVisible, setChromeVisible] = react.useState(true);
|
|
612
|
+
const [lastWake, setLastWake] = react.useState(0);
|
|
613
|
+
const [menu, setMenu] = react.useState(null);
|
|
614
|
+
const chromeHides = connected && isVideoCall && menu === null;
|
|
615
|
+
react.useEffect(() => {
|
|
616
|
+
setChromeVisible(true);
|
|
617
|
+
if (!chromeHides) return;
|
|
618
|
+
const timer = setTimeout(() => setChromeVisible(false), CHROME_IDLE_MS);
|
|
619
|
+
return () => clearTimeout(timer);
|
|
620
|
+
}, [chromeHides, lastWake]);
|
|
621
|
+
const wake = react.useCallback(() => setLastWake(Date.now()), []);
|
|
622
|
+
const withWake = react.useCallback(
|
|
623
|
+
(fn) => () => {
|
|
624
|
+
wake();
|
|
625
|
+
fn();
|
|
626
|
+
},
|
|
627
|
+
[wake]
|
|
628
|
+
);
|
|
629
|
+
const micOn = usingSfu ? sfu.micEnabled : !voice.muted;
|
|
630
|
+
const toggleMic = react.useCallback(() => {
|
|
631
|
+
if (usingSfu) void sfu.toggleMic();
|
|
632
|
+
else voice.toggleMute();
|
|
633
|
+
}, [usingSfu, sfu, voice]);
|
|
634
|
+
const openMenu = react.useCallback(
|
|
635
|
+
(kind) => {
|
|
636
|
+
sfu.refreshDevices();
|
|
637
|
+
setMenu((current) => current === kind ? null : kind);
|
|
638
|
+
},
|
|
639
|
+
[sfu]
|
|
640
|
+
);
|
|
641
|
+
const duration = useCallDuration(connected);
|
|
642
|
+
if (calls.phase === "idle") return null;
|
|
643
|
+
const ringingIn = calls.phase === "ringing-in";
|
|
644
|
+
const ringingOut = calls.phase === "ringing-out";
|
|
645
|
+
const ended = calls.phase === "declined" || calls.phase === "busy" || calls.phase === "timed-out";
|
|
646
|
+
const others = usingSfu ? sfu.participants.filter((p) => !p.isSelf) : [];
|
|
647
|
+
const peerIds = ringingIn && calls.incoming ? [calls.incoming.callerUserId] : others.length > 0 ? others.map((p) => p.userId) : calls.outgoing?.calleeUserIds ?? [];
|
|
648
|
+
const who = peerIds.length === 0 ? "Call" : peerIds.length <= 2 ? peerIds.map(labelFor).join(", ") : `${labelFor(peerIds[0])} and ${peerIds.length - 1} others`;
|
|
649
|
+
const showStage = connected && usingSfu && sfu.participants.length > 0;
|
|
650
|
+
const error = calls.error ?? (usingSfu ? sfu.error : voice.error);
|
|
651
|
+
const isGroup = others.length > 1;
|
|
652
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
653
|
+
"div",
|
|
654
|
+
{
|
|
655
|
+
className: "callsheet",
|
|
656
|
+
role: "dialog",
|
|
657
|
+
"aria-modal": "true",
|
|
658
|
+
"aria-label": "Call",
|
|
659
|
+
onPointerMove: wake,
|
|
660
|
+
children: [
|
|
661
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "callsheet__stage", children: showStage ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
662
|
+
CallVideoGrid,
|
|
663
|
+
{
|
|
664
|
+
participants: sfu.participants,
|
|
665
|
+
labelFor,
|
|
666
|
+
onLocalClick: sfu.cameraEnabled ? () => void sfu.switchCamera() : void 0
|
|
667
|
+
}
|
|
668
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callsheet__identity", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "callsheet__avatar", "aria-hidden": "true", children: who.slice(0, 1).toUpperCase() }) }) }),
|
|
669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: `callsheet__header${chromeVisible ? "" : " callsheet__header--hidden"}`, children: [
|
|
670
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "callsheet__who", children: who }),
|
|
671
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "callsheet__state", children: [
|
|
672
|
+
isGroup && showStage ? `${sfu.participants.length} \xB7 ` : "",
|
|
673
|
+
duration ?? statusLine(calls.phase, mediaStatus)
|
|
674
|
+
] })
|
|
675
|
+
] }),
|
|
676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `callsheet__actions${chromeVisible ? "" : " callsheet__actions--hidden"}`, children: [
|
|
677
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "callsheet__error", children: error.message }),
|
|
678
|
+
ringingIn ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "callsheet__row", children: [
|
|
679
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
680
|
+
CallControlButton,
|
|
681
|
+
{
|
|
682
|
+
icon: "phone-off",
|
|
683
|
+
tone: "danger",
|
|
684
|
+
large: true,
|
|
685
|
+
label: "Decline",
|
|
686
|
+
onClick: () => void calls.decline()
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
690
|
+
CallControlButton,
|
|
691
|
+
{
|
|
692
|
+
icon: isVideoCall ? "video" : "phone",
|
|
693
|
+
tone: "accept",
|
|
694
|
+
large: true,
|
|
695
|
+
label: "Accept",
|
|
696
|
+
onClick: () => void calls.accept()
|
|
697
|
+
}
|
|
698
|
+
)
|
|
699
|
+
] }) : ended ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callsheet__row", children: /* @__PURE__ */ jsxRuntime.jsx(CallControlButton, { icon: "close", label: "Close", onClick: calls.reset }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "callsheet__row", children: [
|
|
700
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callsheet__control", children: [
|
|
701
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
702
|
+
CallControlButton,
|
|
703
|
+
{
|
|
704
|
+
icon: micOn ? "mic" : "mic-off",
|
|
705
|
+
active: !micOn,
|
|
706
|
+
label: micOn ? "Mute" : "Unmute",
|
|
707
|
+
onClick: withWake(toggleMic),
|
|
708
|
+
hasMenu: usingSfu && sfu.devices.audioinput.length > 0,
|
|
709
|
+
onMenuClick: withWake(() => openMenu("audioinput"))
|
|
710
|
+
}
|
|
711
|
+
),
|
|
712
|
+
menu === "audioinput" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
713
|
+
CallDeviceMenu,
|
|
714
|
+
{
|
|
715
|
+
title: "Microphone",
|
|
716
|
+
devices: sfu.devices.audioinput,
|
|
717
|
+
activeId: sfu.activeDevices.audioinput,
|
|
718
|
+
onSelect: (kind, id) => void sfu.selectDevice(kind, id),
|
|
719
|
+
onClose: () => setMenu(null)
|
|
720
|
+
}
|
|
721
|
+
)
|
|
722
|
+
] }),
|
|
723
|
+
usingSfu && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callsheet__control", children: [
|
|
724
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
+
CallControlButton,
|
|
726
|
+
{
|
|
727
|
+
icon: sfu.cameraEnabled ? "video" : "video-off",
|
|
728
|
+
active: !sfu.cameraEnabled,
|
|
729
|
+
label: "Camera",
|
|
730
|
+
onClick: withWake(() => void sfu.toggleCamera()),
|
|
731
|
+
disabled: sfu.devices.videoinput.length === 0,
|
|
732
|
+
hasMenu: sfu.devices.videoinput.length > 0,
|
|
733
|
+
onMenuClick: withWake(() => openMenu("videoinput"))
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
menu === "videoinput" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
+
CallDeviceMenu,
|
|
738
|
+
{
|
|
739
|
+
title: "Camera",
|
|
740
|
+
devices: sfu.devices.videoinput,
|
|
741
|
+
activeId: sfu.activeDevices.videoinput,
|
|
742
|
+
onSelect: (kind, id) => void sfu.selectDevice(kind, id),
|
|
743
|
+
onClose: () => setMenu(null)
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
] }),
|
|
747
|
+
usingSfu && sfu.devices.audiooutput.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callsheet__control", children: [
|
|
748
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
749
|
+
CallControlButton,
|
|
750
|
+
{
|
|
751
|
+
icon: "speaker",
|
|
752
|
+
label: "Output",
|
|
753
|
+
onClick: withWake(() => openMenu("audiooutput"))
|
|
754
|
+
}
|
|
755
|
+
),
|
|
756
|
+
menu === "audiooutput" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
757
|
+
CallDeviceMenu,
|
|
758
|
+
{
|
|
759
|
+
title: "Speaker",
|
|
760
|
+
devices: sfu.devices.audiooutput,
|
|
761
|
+
activeId: sfu.activeDevices.audiooutput,
|
|
762
|
+
onSelect: (kind, id) => void sfu.selectDevice(kind, id),
|
|
763
|
+
onClose: () => setMenu(null)
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] }),
|
|
767
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
768
|
+
CallControlButton,
|
|
769
|
+
{
|
|
770
|
+
icon: "phone-off",
|
|
771
|
+
tone: "danger",
|
|
772
|
+
large: true,
|
|
773
|
+
label: ringingOut ? "Cancel" : "Hang up",
|
|
774
|
+
onClick: ringingOut ? () => void calls.cancel() : hangUp
|
|
775
|
+
}
|
|
776
|
+
)
|
|
777
|
+
] })
|
|
778
|
+
] })
|
|
779
|
+
]
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
function useCallDuration(connected) {
|
|
784
|
+
const [startedAt, setStartedAt] = react.useState(null);
|
|
785
|
+
const [, tick] = react.useState(0);
|
|
786
|
+
react.useEffect(() => {
|
|
787
|
+
if (!connected) {
|
|
788
|
+
setStartedAt(null);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
setStartedAt(Date.now());
|
|
792
|
+
const id = setInterval(() => tick((n) => n + 1), 1e3);
|
|
793
|
+
return () => clearInterval(id);
|
|
794
|
+
}, [connected]);
|
|
795
|
+
if (!connected || startedAt === null) return null;
|
|
796
|
+
const total = Math.max(0, Math.floor((Date.now() - startedAt) / 1e3));
|
|
797
|
+
const minutes = Math.floor(total / 60);
|
|
798
|
+
const seconds = total % 60;
|
|
799
|
+
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
|
800
|
+
}
|
|
801
|
+
function statusLine(phase, mediaStatus) {
|
|
802
|
+
switch (phase) {
|
|
803
|
+
case "ringing-in":
|
|
804
|
+
return "Incoming call\u2026";
|
|
805
|
+
case "ringing-out":
|
|
806
|
+
return "Ringing\u2026";
|
|
807
|
+
case "declined":
|
|
808
|
+
return "Call declined";
|
|
809
|
+
case "busy":
|
|
810
|
+
return "Already on another call";
|
|
811
|
+
case "timed-out":
|
|
812
|
+
return "No answer";
|
|
813
|
+
case "active":
|
|
814
|
+
return mediaStatus === "connected" ? "Connected" : "Connecting\u2026";
|
|
815
|
+
default:
|
|
816
|
+
return "";
|
|
817
|
+
}
|
|
818
|
+
}
|
|
550
819
|
var FONT_HREF = "https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap";
|
|
551
820
|
var FONT_HREF_PRECONNECT_GOOGLE = "https://fonts.googleapis.com";
|
|
552
821
|
var FONT_HREF_PRECONNECT_STATIC = "https://fonts.gstatic.com";
|
|
@@ -3316,6 +3585,7 @@ exports.AttachmentPreview = AttachmentPreview;
|
|
|
3316
3585
|
exports.Avatar = Avatar;
|
|
3317
3586
|
exports.CallControlButton = CallControlButton;
|
|
3318
3587
|
exports.CallDeviceMenu = CallDeviceMenu;
|
|
3588
|
+
exports.CallProvider = CallProvider;
|
|
3319
3589
|
exports.CallVideoGrid = CallVideoGrid;
|
|
3320
3590
|
exports.ChatHeader = ChatHeader;
|
|
3321
3591
|
exports.ConversationList = ConversationList;
|
|
@@ -3338,6 +3608,7 @@ exports.TypingIndicator = TypingIndicator;
|
|
|
3338
3608
|
exports.UploadQueueStrip = UploadQueueStrip;
|
|
3339
3609
|
exports.UserName = UserName;
|
|
3340
3610
|
exports.UserPickerSheet = UserPickerSheet;
|
|
3611
|
+
exports.useCallInvite = useCallInvite;
|
|
3341
3612
|
exports.useDisplayName = useDisplayName;
|
|
3342
3613
|
exports.usePoolseFonts = usePoolseFonts;
|
|
3343
3614
|
//# sourceMappingURL=index.cjs.map
|