@100mslive/roomkit-react 0.3.15 → 0.3.16-alpha.1

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 (43) hide show
  1. package/dist/{HLSView-ICCDFOHV.js → HLSView-ERPYXVOY.js} +2 -2
  2. package/dist/{HLSView-SFAI4O64.css → HLSView-T2PXKR6I.css} +3 -3
  3. package/dist/{HLSView-SFAI4O64.css.map → HLSView-T2PXKR6I.css.map} +1 -1
  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-WKJZMVEX.js → chunk-NKC36NL4.js} +8533 -8150
  15. package/dist/chunk-NKC36NL4.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 +3921 -3481
  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 +1790 -1438
  24. package/dist/meta.esbuild.json +2330 -1978
  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/Footer/RoleAccordion.tsx +15 -1
  31. package/src/Prebuilt/components/Header/HeaderComponents.jsx +2 -3
  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/PIP/PIPChat.tsx +225 -0
  35. package/src/Prebuilt/components/PIP/PIPChatOption.tsx +18 -0
  36. package/src/Prebuilt/components/PIP/PIPProvider.tsx +56 -0
  37. package/src/Prebuilt/components/PIP/PIPWindow.tsx +13 -0
  38. package/src/Prebuilt/components/PIP/context.ts +10 -0
  39. package/src/Prebuilt/components/PIP/usePIPChat.tsx +103 -0
  40. package/src/Prebuilt/components/PIP/usePIPWindow.tsx +12 -0
  41. package/src/Prebuilt/components/hooks/useMetadata.tsx +2 -1
  42. package/dist/chunk-WKJZMVEX.js.map +0 -7
  43. /package/dist/{HLSView-ICCDFOHV.js.map → HLSView-ERPYXVOY.js.map} +0 -0
@@ -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
+ };
@@ -30,9 +30,10 @@ export const useMyMetadata = () => {
30
30
  const toggleHandRaise = useCallback(async () => {
31
31
  if (isHandRaised) {
32
32
  await hmsActions.lowerLocalPeerHand();
33
+ await update({ handRaisedAt: undefined });
33
34
  } else {
34
35
  await hmsActions.raiseLocalPeerHand();
35
- await update({ isBRBOn: false });
36
+ await update({ isBRBOn: false, handRaisedAt: Date.now() });
36
37
  }
37
38
  }, [isHandRaised]); //eslint-disable-line
38
39