@100mslive/roomkit-react 0.3.16-alpha.0 → 0.3.16-alpha.2

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.
Files changed (45) hide show
  1. package/dist/{HLSView-KOCGTP23.css → HLSView-LQNFHQLW.css} +3 -3
  2. package/dist/{HLSView-KOCGTP23.css.map → HLSView-LQNFHQLW.css.map} +1 -1
  3. package/dist/{HLSView-P7GF2RAU.js → HLSView-PTKFE7ET.js} +2 -2
  4. package/dist/Prebuilt/components/Chat/ChatBody.d.ts +887 -0
  5. package/dist/Prebuilt/components/Chat/ChatFooter.d.ts +1 -1
  6. package/dist/Prebuilt/components/Chat/utils.d.ts +2 -0
  7. package/dist/Prebuilt/components/PIP/PIPChat.d.ts +2 -0
  8. package/dist/Prebuilt/components/PIP/PIPChatOption.d.ts +5 -0
  9. package/dist/Prebuilt/components/PIP/PIPProvider.d.ts +6 -0
  10. package/dist/Prebuilt/components/PIP/PIPWindow.d.ts +7 -0
  11. package/dist/Prebuilt/components/PIP/context.d.ts +8 -0
  12. package/dist/Prebuilt/components/PIP/usePIPChat.d.ts +5 -0
  13. package/dist/Prebuilt/components/PIP/usePIPWindow.d.ts +2 -0
  14. package/dist/{chunk-DDB4BLHX.js → chunk-QGNIWXTH.js} +10176 -9767
  15. package/dist/chunk-QGNIWXTH.js.map +7 -0
  16. package/dist/index.cjs.css +2 -2
  17. package/dist/index.cjs.css.map +1 -1
  18. package/dist/index.cjs.js +3974 -3512
  19. package/dist/index.cjs.js.map +4 -4
  20. package/dist/index.css +2 -2
  21. package/dist/index.css.map +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/meta.cjs.json +2275 -1908
  24. package/dist/meta.esbuild.json +2275 -1908
  25. package/package.json +8 -7
  26. package/src/Prebuilt/components/AudioVideoToggle.tsx +14 -7
  27. package/src/Prebuilt/components/Chat/ChatBody.tsx +4 -12
  28. package/src/Prebuilt/components/Chat/ChatFooter.tsx +2 -3
  29. package/src/Prebuilt/components/Chat/utils.ts +11 -0
  30. package/src/Prebuilt/components/ConferenceScreen.tsx +13 -1
  31. package/src/Prebuilt/components/Footer/ParticipantList.tsx +1 -4
  32. package/src/Prebuilt/components/MoreSettings/MoreSettings.tsx +4 -1
  33. package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx +13 -5
  34. package/src/Prebuilt/components/Notifications/HandRaisedNotifications.tsx +33 -0
  35. package/src/Prebuilt/components/PIP/PIPChat.tsx +225 -0
  36. package/src/Prebuilt/components/PIP/PIPChatOption.tsx +18 -0
  37. package/src/Prebuilt/components/PIP/PIPProvider.tsx +56 -0
  38. package/src/Prebuilt/components/PIP/PIPWindow.tsx +13 -0
  39. package/src/Prebuilt/components/PIP/context.ts +10 -0
  40. package/src/Prebuilt/components/PIP/usePIPChat.tsx +103 -0
  41. package/src/Prebuilt/components/PIP/usePIPWindow.tsx +12 -0
  42. package/src/Prebuilt/components/Preview/PreviewJoin.tsx +3 -1
  43. package/src/Prebuilt/components/Toast/ToastConfig.jsx +2 -2
  44. package/dist/chunk-DDB4BLHX.js.map +0 -7
  45. /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 ? `${count} and others` : ''
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 ? `${count} and others` : ''
132
+ count > 1 ? `and ${count} others` : ''
133
133
  } raised hand`,
134
134
  icon: <HandIcon />,
135
135
  action: <HandRaiseAction isSingleHandRaise={false} />,