@100mslive/roomkit-react 0.3.16-alpha.0 → 0.3.16-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-KOCGTP23.css → HLSView-LQNFHQLW.css} +3 -3
- package/dist/{HLSView-KOCGTP23.css.map → HLSView-LQNFHQLW.css.map} +1 -1
- package/dist/{HLSView-P7GF2RAU.js → HLSView-PTKFE7ET.js} +2 -2
- package/dist/Prebuilt/components/Chat/ChatBody.d.ts +887 -0
- package/dist/Prebuilt/components/Chat/ChatFooter.d.ts +1 -1
- package/dist/Prebuilt/components/Chat/utils.d.ts +2 -0
- package/dist/Prebuilt/components/PIP/PIPChat.d.ts +2 -0
- package/dist/Prebuilt/components/PIP/PIPChatOption.d.ts +5 -0
- package/dist/Prebuilt/components/PIP/PIPProvider.d.ts +6 -0
- package/dist/Prebuilt/components/PIP/PIPWindow.d.ts +7 -0
- package/dist/Prebuilt/components/PIP/context.d.ts +8 -0
- package/dist/Prebuilt/components/PIP/usePIPChat.d.ts +5 -0
- package/dist/Prebuilt/components/PIP/usePIPWindow.d.ts +2 -0
- package/dist/{chunk-DDB4BLHX.js → chunk-QGNIWXTH.js} +10176 -9767
- package/dist/chunk-QGNIWXTH.js.map +7 -0
- package/dist/index.cjs.css +2 -2
- package/dist/index.cjs.css.map +1 -1
- package/dist/index.cjs.js +3974 -3512
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +2275 -1908
- package/dist/meta.esbuild.json +2275 -1908
- package/package.json +8 -7
- package/src/Prebuilt/components/AudioVideoToggle.tsx +14 -7
- package/src/Prebuilt/components/Chat/ChatBody.tsx +4 -12
- package/src/Prebuilt/components/Chat/ChatFooter.tsx +2 -3
- package/src/Prebuilt/components/Chat/utils.ts +11 -0
- package/src/Prebuilt/components/ConferenceScreen.tsx +13 -1
- package/src/Prebuilt/components/Footer/ParticipantList.tsx +1 -4
- package/src/Prebuilt/components/MoreSettings/MoreSettings.tsx +4 -1
- package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx +13 -5
- package/src/Prebuilt/components/Notifications/HandRaisedNotifications.tsx +33 -0
- package/src/Prebuilt/components/PIP/PIPChat.tsx +225 -0
- package/src/Prebuilt/components/PIP/PIPChatOption.tsx +18 -0
- package/src/Prebuilt/components/PIP/PIPProvider.tsx +56 -0
- package/src/Prebuilt/components/PIP/PIPWindow.tsx +13 -0
- package/src/Prebuilt/components/PIP/context.ts +10 -0
- package/src/Prebuilt/components/PIP/usePIPChat.tsx +103 -0
- package/src/Prebuilt/components/PIP/usePIPWindow.tsx +12 -0
- package/src/Prebuilt/components/Preview/PreviewJoin.tsx +3 -1
- package/src/Prebuilt/components/Toast/ToastConfig.jsx +2 -2
- package/dist/chunk-DDB4BLHX.js.map +0 -7
- /package/dist/{HLSView-P7GF2RAU.js.map → HLSView-PTKFE7ET.js.map} +0 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
import { createContext } from 'react';
|
2
|
+
|
3
|
+
export type PIPContextType = {
|
4
|
+
isSupported: boolean;
|
5
|
+
pipWindow: Window | null;
|
6
|
+
requestPipWindow: (width: number, height: number) => Promise<void>;
|
7
|
+
closePipWindow: () => void;
|
8
|
+
};
|
9
|
+
|
10
|
+
export const PIPContext = createContext<PIPContextType | undefined>(undefined);
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { useHMSActions } from '@100mslive/react-sdk';
|
3
|
+
import { getCssText } from '../../../Theme';
|
4
|
+
import { usePIPWindow } from './usePIPWindow';
|
5
|
+
|
6
|
+
export const usePIPChat = () => {
|
7
|
+
const hmsActions = useHMSActions();
|
8
|
+
const { isSupported, requestPipWindow, pipWindow, closePipWindow } = usePIPWindow();
|
9
|
+
|
10
|
+
useEffect(() => {
|
11
|
+
if (document && pipWindow) {
|
12
|
+
const style = document.createElement('style');
|
13
|
+
style.id = 'stitches';
|
14
|
+
style.textContent = getCssText();
|
15
|
+
pipWindow.document.head.appendChild(style);
|
16
|
+
}
|
17
|
+
}, [pipWindow]);
|
18
|
+
|
19
|
+
// @ts-ignore
|
20
|
+
useEffect(() => {
|
21
|
+
if (pipWindow) {
|
22
|
+
const chatContainer = pipWindow.document.getElementById('chat-container');
|
23
|
+
const selector = pipWindow.document.getElementById('selector') as HTMLSelectElement;
|
24
|
+
const sendBtn = pipWindow.document.getElementById('send-btn');
|
25
|
+
const pipChatInput = pipWindow.document.getElementById('chat-input') as HTMLTextAreaElement;
|
26
|
+
const marker = pipWindow.document.getElementById('marker');
|
27
|
+
|
28
|
+
const observer = new IntersectionObserver(
|
29
|
+
entries => {
|
30
|
+
entries.forEach(entry => {
|
31
|
+
if (entry.isIntersecting && entry.target.id) {
|
32
|
+
hmsActions.setMessageRead(true, entry.target.id);
|
33
|
+
}
|
34
|
+
});
|
35
|
+
},
|
36
|
+
{
|
37
|
+
root: chatContainer,
|
38
|
+
threshold: 0.8,
|
39
|
+
},
|
40
|
+
);
|
41
|
+
|
42
|
+
const mutationObserver = new MutationObserver(mutations => {
|
43
|
+
mutations.forEach(mutation => {
|
44
|
+
if (mutation.addedNodes.length > 0) {
|
45
|
+
const newMessages = mutation.addedNodes;
|
46
|
+
newMessages.forEach(message => {
|
47
|
+
const messageId = (message as Element)?.id;
|
48
|
+
if (messageId === 'new-message-notif') {
|
49
|
+
message.addEventListener('click', () =>
|
50
|
+
setTimeout(() => marker?.scrollIntoView({ block: 'end', behavior: 'smooth' }), 0),
|
51
|
+
);
|
52
|
+
} else if (messageId) observer.observe(message as Element);
|
53
|
+
});
|
54
|
+
}
|
55
|
+
});
|
56
|
+
});
|
57
|
+
mutationObserver.observe(chatContainer as Node, {
|
58
|
+
childList: true,
|
59
|
+
});
|
60
|
+
|
61
|
+
const sendMessage = async () => {
|
62
|
+
const selection = selector?.value || 'Everyone';
|
63
|
+
if (selection === 'Everyone') {
|
64
|
+
await hmsActions.sendBroadcastMessage(pipChatInput.value.trim());
|
65
|
+
} else {
|
66
|
+
await hmsActions.sendGroupMessage(pipChatInput.value.trim(), [selection]);
|
67
|
+
}
|
68
|
+
pipChatInput.value = '';
|
69
|
+
setTimeout(() => marker?.scrollIntoView({ block: 'end', behavior: 'smooth' }), 0);
|
70
|
+
};
|
71
|
+
|
72
|
+
if (sendBtn && hmsActions && pipChatInput) {
|
73
|
+
const pipMessages = pipWindow.document.getElementsByClassName('pip-message');
|
74
|
+
// @ts-ignore
|
75
|
+
[...pipMessages].forEach(message => {
|
76
|
+
if (message.id) {
|
77
|
+
hmsActions.setMessageRead(true, message.id);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
// @ts-ignore
|
81
|
+
const sendOnEnter = e => {
|
82
|
+
if (e.key === 'Enter') sendMessage();
|
83
|
+
};
|
84
|
+
sendBtn.addEventListener('click', sendMessage);
|
85
|
+
pipChatInput.addEventListener('keypress', sendOnEnter);
|
86
|
+
return () => {
|
87
|
+
sendBtn.removeEventListener('click', sendMessage);
|
88
|
+
pipChatInput.removeEventListener('keypress', sendOnEnter);
|
89
|
+
mutationObserver.disconnect();
|
90
|
+
observer.disconnect();
|
91
|
+
};
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}, [pipWindow, hmsActions]);
|
95
|
+
|
96
|
+
useEffect(() => {
|
97
|
+
return () => {
|
98
|
+
pipWindow && closePipWindow();
|
99
|
+
};
|
100
|
+
}, [closePipWindow, pipWindow]);
|
101
|
+
|
102
|
+
return { isSupported, requestPipWindow, pipWindow };
|
103
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { useContext } from 'react';
|
2
|
+
import { PIPContext, PIPContextType } from './context';
|
3
|
+
|
4
|
+
export const usePIPWindow = (): PIPContextType => {
|
5
|
+
const context = useContext(PIPContext);
|
6
|
+
|
7
|
+
if (context === undefined) {
|
8
|
+
throw new Error('usePIPWindow must be used within a PIPContext');
|
9
|
+
}
|
10
|
+
|
11
|
+
return context;
|
12
|
+
};
|
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
selectRoomState,
|
9
9
|
selectVideoTrackByID,
|
10
10
|
useAVToggle,
|
11
|
+
useAwayNotifications,
|
11
12
|
useHMSStore,
|
12
13
|
useParticipants,
|
13
14
|
usePreviewJoin,
|
@@ -100,6 +101,7 @@ const PreviewJoin = ({
|
|
100
101
|
},
|
101
102
|
asRole,
|
102
103
|
});
|
104
|
+
const { requestPermission } = useAwayNotifications();
|
103
105
|
const roomState = useHMSStore(selectRoomState);
|
104
106
|
const savePreferenceAndJoin = useCallback(() => {
|
105
107
|
setPreviewPreference({
|
@@ -115,7 +117,7 @@ const PreviewJoin = ({
|
|
115
117
|
if (skipPreview) {
|
116
118
|
savePreferenceAndJoin();
|
117
119
|
} else {
|
118
|
-
preview();
|
120
|
+
preview().then(() => requestPermission());
|
119
121
|
}
|
120
122
|
}
|
121
123
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
@@ -111,7 +111,7 @@ export const ToastConfig = {
|
|
111
111
|
const count = new Set(notifications.map(notification => notification.data?.id)).size;
|
112
112
|
return {
|
113
113
|
title: `${notifications[notifications.length - 1].data?.name} ${
|
114
|
-
count > 1 ?
|
114
|
+
count > 1 ? `and ${count} others` : ''
|
115
115
|
} raised hand`,
|
116
116
|
icon: <HandIcon />,
|
117
117
|
};
|
@@ -129,7 +129,7 @@ export const ToastConfig = {
|
|
129
129
|
const count = new Set(notifications.map(notification => notification.data?.id)).size;
|
130
130
|
return {
|
131
131
|
title: `${notifications[notifications.length - 1].data?.name} ${
|
132
|
-
count > 1 ?
|
132
|
+
count > 1 ? `and ${count} others` : ''
|
133
133
|
} raised hand`,
|
134
134
|
icon: <HandIcon />,
|
135
135
|
action: <HandRaiseAction isSingleHandRaise={false} />,
|