@100mslive/roomkit-react 0.1.8-alpha.0 → 0.1.9-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/dist/{HLSView-IQRPLYNH.js → HLSView-U53QN3AC.js} +3 -3
  2. package/dist/Modal/Dialog.d.ts +402 -1706
  3. package/dist/Prebuilt/App.d.ts +6 -0
  4. package/dist/Prebuilt/AppContext.d.ts +2 -0
  5. package/dist/Prebuilt/AppStateContext.d.ts +16 -0
  6. package/dist/Prebuilt/components/ConferenceScreen.d.ts +2 -0
  7. package/dist/Prebuilt/components/Footer/PaginatedParticipants.d.ts +5 -0
  8. package/dist/Prebuilt/components/Footer/PollsToggle.d.ts +2 -0
  9. package/dist/Prebuilt/components/Footer/RoleAccordion.d.ts +10 -3
  10. package/dist/Prebuilt/components/LeaveScreen.d.ts +2 -0
  11. package/dist/Prebuilt/components/MwebLandscapePrompt.d.ts +2 -0
  12. package/dist/Prebuilt/components/Notifications/AutoplayBlockedModal.d.ts +2 -0
  13. package/dist/Prebuilt/components/Notifications/HLSFailureModal.d.ts +2 -0
  14. package/dist/Prebuilt/components/Notifications/InitErrorModal.d.ts +2 -0
  15. package/dist/Prebuilt/components/Notifications/Notifications.d.ts +2 -0
  16. package/dist/Prebuilt/components/Notifications/PeerNotifications.d.ts +1 -0
  17. package/dist/Prebuilt/components/Notifications/PermissionErrorModal.d.ts +2 -0
  18. package/dist/Prebuilt/components/Notifications/ReconnectNotifications.d.ts +2 -0
  19. package/dist/Prebuilt/components/Notifications/TrackBulkUnmuteModal.d.ts +2 -0
  20. package/dist/Prebuilt/components/Notifications/TrackNotifications.d.ts +1 -0
  21. package/dist/Prebuilt/components/Notifications/TrackUnmuteModal.d.ts +2 -0
  22. package/dist/Prebuilt/components/Polls/Polls.d.ts +2 -0
  23. package/dist/Prebuilt/components/Preview/PreviewJoin.d.ts +1 -2
  24. package/dist/Prebuilt/components/Preview/PreviewScreen.d.ts +2 -0
  25. package/dist/Prebuilt/components/hooks/useRedirectToLeave.d.ts +1 -1
  26. package/dist/{VirtualBackground-GP4ATXD3.js → VirtualBackground-PMLQPJB6.js} +3 -5
  27. package/dist/{VirtualBackground-GP4ATXD3.js.map → VirtualBackground-PMLQPJB6.js.map} +1 -1
  28. package/dist/chunk-ANQRGVIX.js +14441 -0
  29. package/dist/chunk-ANQRGVIX.js.map +7 -0
  30. package/dist/{chunk-Z3O2WGWV.js → chunk-XQ2NRKIW.js} +66 -3
  31. package/dist/chunk-XQ2NRKIW.js.map +7 -0
  32. package/dist/context/DialogContext.d.ts +6 -0
  33. package/dist/hooks/useDialogContainerSelector.d.ts +1 -0
  34. package/dist/index.cjs.js +10956 -9818
  35. package/dist/index.cjs.js.map +4 -4
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +6 -2
  38. package/dist/meta.cjs.json +4076 -3201
  39. package/dist/meta.esbuild.json +4391 -3623
  40. package/dist/utils/animations.d.ts +11 -0
  41. package/package.json +6 -7
  42. package/src/AudioLevel/AudioLevel.tsx +1 -1
  43. package/src/Modal/Dialog.tsx +31 -3
  44. package/src/Prebuilt/App.tsx +49 -97
  45. package/src/Prebuilt/AppContext.tsx +6 -0
  46. package/src/Prebuilt/AppStateContext.tsx +71 -0
  47. package/src/Prebuilt/common/constants.js +36 -1
  48. package/src/Prebuilt/common/utils.js +47 -0
  49. package/src/Prebuilt/components/AppData/AppData.jsx +6 -1
  50. package/src/Prebuilt/components/AppData/useSidepane.js +23 -1
  51. package/src/Prebuilt/components/AppData/useUISettings.js +49 -5
  52. package/src/Prebuilt/components/Chip.tsx +6 -2
  53. package/src/Prebuilt/components/{conference.jsx → ConferenceScreen.tsx} +34 -46
  54. package/src/Prebuilt/components/Footer/Footer.tsx +5 -0
  55. package/src/Prebuilt/components/Footer/PaginatedParticipants.tsx +125 -0
  56. package/src/Prebuilt/components/Footer/ParticipantList.jsx +55 -24
  57. package/src/Prebuilt/components/Footer/PollsToggle.tsx +22 -0
  58. package/src/Prebuilt/components/Footer/RoleAccordion.tsx +87 -85
  59. package/src/Prebuilt/components/Footer/RoleOptions.tsx +1 -1
  60. package/src/Prebuilt/components/Header/StreamActions.tsx +5 -3
  61. package/src/Prebuilt/components/Leave/DesktopLeaveRoom.tsx +4 -5
  62. package/src/Prebuilt/components/Leave/LeaveRoom.tsx +0 -4
  63. package/src/Prebuilt/components/{PostLeave.jsx → LeaveScreen.tsx} +6 -13
  64. package/src/Prebuilt/components/MoreSettings/ChangeNameModal.jsx +2 -3
  65. package/src/Prebuilt/components/MoreSettings/EmbedUrl.jsx +2 -3
  66. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +18 -1
  67. package/src/Prebuilt/components/{MwebLandscapePrompt.jsx → MwebLandscapePrompt.tsx} +10 -11
  68. package/src/Prebuilt/components/Notifications/{AutoplayBlockedModal.jsx → AutoplayBlockedModal.tsx} +2 -1
  69. package/src/Prebuilt/components/Notifications/{HLSFailureModal.jsx → HLSFailureModal.tsx} +10 -8
  70. package/src/Prebuilt/components/Notifications/{InitErrorModal.jsx → InitErrorModal.tsx} +5 -2
  71. package/src/Prebuilt/components/Notifications/{Notifications.jsx → Notifications.tsx} +41 -27
  72. package/src/Prebuilt/components/Notifications/{PeerNotifications.jsx → PeerNotifications.tsx} +3 -0
  73. package/src/Prebuilt/components/Notifications/{PermissionErrorModal.jsx → PermissionErrorModal.tsx} +6 -4
  74. package/src/Prebuilt/components/Notifications/{ReconnectNotifications.jsx → ReconnectNotifications.tsx} +11 -6
  75. package/src/Prebuilt/components/Notifications/{TrackBulkUnmuteModal.jsx → TrackBulkUnmuteModal.tsx} +9 -3
  76. package/src/Prebuilt/components/Notifications/{TrackUnmuteModal.jsx → TrackUnmuteModal.tsx} +9 -3
  77. package/src/Prebuilt/components/Notifications/index.tsx +1 -0
  78. package/src/Prebuilt/components/Polls/CreatePollQuiz/PollsQuizMenu.jsx +229 -0
  79. package/src/Prebuilt/components/Polls/CreatePollQuiz/Timer.jsx +71 -0
  80. package/src/Prebuilt/components/Polls/CreateQuestions/CreateQuestions.jsx +132 -0
  81. package/src/Prebuilt/components/Polls/CreateQuestions/DeleteQuestionModal.jsx +66 -0
  82. package/src/Prebuilt/components/Polls/CreateQuestions/QuestionForm.jsx +251 -0
  83. package/src/Prebuilt/components/Polls/CreateQuestions/SavedQuestion.jsx +57 -0
  84. package/src/Prebuilt/components/Polls/Polls.tsx +28 -0
  85. package/src/Prebuilt/components/Polls/Voting/PollResultSummary.jsx +125 -0
  86. package/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx +249 -0
  87. package/src/Prebuilt/components/Polls/Voting/StandardVoting.jsx +40 -0
  88. package/src/Prebuilt/components/Polls/Voting/TimedVoting.jsx +36 -0
  89. package/src/Prebuilt/components/Polls/Voting/Voting.jsx +99 -0
  90. package/src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx +101 -0
  91. package/src/Prebuilt/components/Polls/common/OptionInputWithDelete.jsx +25 -0
  92. package/src/Prebuilt/components/Polls/common/SingleChoiceOptions.jsx +125 -0
  93. package/src/Prebuilt/components/Polls/common/StatusIndicator.jsx +47 -0
  94. package/src/Prebuilt/components/Polls/common/VoteCount.jsx +28 -0
  95. package/src/Prebuilt/components/Polls/common/VoteProgress.jsx +17 -0
  96. package/src/Prebuilt/components/Polls/common/VoterList.jsx +22 -0
  97. package/src/Prebuilt/components/Polls/common/Votes.jsx +72 -0
  98. package/src/Prebuilt/components/Preview/PreviewForm.tsx +3 -2
  99. package/src/Prebuilt/components/Preview/PreviewJoin.tsx +29 -21
  100. package/src/Prebuilt/components/Preview/{PreviewContainer.tsx → PreviewScreen.tsx} +2 -19
  101. package/src/Prebuilt/components/RaiseHand.jsx +1 -1
  102. package/src/Prebuilt/components/RoleChangeModal.jsx +2 -3
  103. package/src/Prebuilt/components/RoleChangeRequest/RequestPrompt.tsx +2 -3
  104. package/src/Prebuilt/components/Settings/SettingsModal.jsx +2 -3
  105. package/src/Prebuilt/components/Settings/StartRecording.jsx +15 -4
  106. package/src/Prebuilt/components/SidePaneTabs.tsx +32 -6
  107. package/src/Prebuilt/components/StatsForNerds.jsx +2 -3
  108. package/src/Prebuilt/components/Streaming/Common.jsx +31 -21
  109. package/src/Prebuilt/components/VideoLayouts/ScreenshareLayout.tsx +8 -9
  110. package/src/Prebuilt/components/VideoTile.jsx +28 -39
  111. package/src/Prebuilt/components/hooks/useAutoStartStreaming.tsx +3 -3
  112. package/src/Prebuilt/components/hooks/useDropdownSelection.jsx +1 -1
  113. package/src/Prebuilt/components/hooks/useRedirectToLeave.tsx +9 -17
  114. package/src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx +2 -3
  115. package/src/Prebuilt/components/pdfAnnotator/submitPdf.jsx +1 -1
  116. package/src/Prebuilt/components/pdfAnnotator/uploadedFile.jsx +2 -3
  117. package/src/Prebuilt/layouts/EmbedView.jsx +47 -60
  118. package/src/Prebuilt/layouts/PDFView.jsx +49 -99
  119. package/src/Prebuilt/layouts/SidePane.tsx +9 -4
  120. package/src/Prebuilt/layouts/VideoStreamingSection.tsx +2 -2
  121. package/src/Prebuilt/primitives/DialogContent.jsx +4 -5
  122. package/src/context/DialogContext.tsx +13 -0
  123. package/src/hooks/useDialogContainerSelector.tsx +7 -0
  124. package/src/index.ts +1 -0
  125. package/src/utils/animations.ts +6 -0
  126. package/dist/Prebuilt/components/PrebuiltDialogPortal.d.ts +0 -4
  127. package/dist/Prebuilt/components/Preview/PreviewContainer.d.ts +0 -3
  128. package/dist/chunk-2H5NIZB7.js +0 -70
  129. package/dist/chunk-2H5NIZB7.js.map +0 -7
  130. package/dist/chunk-GLYGPYNS.js +0 -7125
  131. package/dist/chunk-GLYGPYNS.js.map +0 -7
  132. package/dist/chunk-Z3O2WGWV.js.map +0 -7
  133. package/dist/conference-JD35TNH4.js +0 -6503
  134. package/dist/conference-JD35TNH4.js.map +0 -7
  135. package/src/Prebuilt/components/GoLiveButton.jsx +0 -42
  136. package/src/Prebuilt/components/PrebuiltDialogPortal.tsx +0 -6
  137. package/src/Prebuilt/components/Streaming/HLSStreaming.jsx +0 -220
  138. package/src/Prebuilt/components/Streaming/RTMPStreaming.jsx +0 -334
  139. package/src/Prebuilt/components/Streaming/StreamingLanding.jsx +0 -76
  140. /package/dist/{HLSView-IQRPLYNH.js.map → HLSView-U53QN3AC.js.map} +0 -0
  141. /package/{src/Prebuilt/components/Notifications/index.jsx → dist/Prebuilt/components/Notifications/index.d.ts} +0 -0
  142. /package/src/Prebuilt/components/Notifications/{TrackNotifications.jsx → TrackNotifications.tsx} +0 -0
@@ -6,6 +6,17 @@ export declare const slideUp: (controller: string) => {
6
6
  (): string;
7
7
  name: string;
8
8
  };
9
+ export declare const translateAcross: ({ xFrom, yFrom, zFrom, xTo, yTo, zTo }: {
10
+ xFrom?: string | undefined;
11
+ yFrom?: string | undefined;
12
+ zFrom?: string | undefined;
13
+ xTo?: string | undefined;
14
+ yTo?: string | undefined;
15
+ zTo?: string | undefined;
16
+ }) => {
17
+ (): string;
18
+ name: string;
19
+ };
9
20
  export declare const dialogOpen: {
10
21
  (): string;
11
22
  name: string;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.1.8-alpha.0",
13
+ "version": "0.1.9-alpha.0",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "files": [
@@ -76,10 +76,10 @@
76
76
  "react": ">=17.0.2 <19.0.0"
77
77
  },
78
78
  "dependencies": {
79
- "@100mslive/hls-player": "0.1.17-alpha.0",
80
- "@100mslive/hms-virtual-background": "1.11.17-alpha.0",
81
- "@100mslive/react-icons": "0.8.17-alpha.0",
82
- "@100mslive/react-sdk": "0.8.17-alpha.0",
79
+ "@100mslive/hls-player": "0.1.18-alpha.0",
80
+ "@100mslive/hms-virtual-background": "1.11.18-alpha.0",
81
+ "@100mslive/react-icons": "0.8.18-alpha.0",
82
+ "@100mslive/react-sdk": "0.8.18-alpha.0",
83
83
  "@100mslive/types-prebuilt": "0.12.0",
84
84
  "@emoji-mart/data": "^1.0.6",
85
85
  "@emoji-mart/react": "^1.0.1",
@@ -106,7 +106,6 @@
106
106
  "qrcode.react": "^3.1.0",
107
107
  "react-draggable": "^4.4.5",
108
108
  "react-intersection-observer": "^9.4.3",
109
- "react-router-dom": "^6.3.0",
110
109
  "react-use": "^17.4.0",
111
110
  "react-virtualized-auto-sizer": "^1.0.7",
112
111
  "react-window": "^1.8.7",
@@ -115,5 +114,5 @@
115
114
  "uuid": "^8.3.2",
116
115
  "worker-timers": "^7.0.40"
117
116
  },
118
- "gitHead": "d6e072de081b508a297ebc1684a33a8e9db048ef"
117
+ "gitHead": "c8ed9e77d556152e44e6ecee18e13355695d18c5"
119
118
  }
@@ -27,7 +27,7 @@ const barAnimation = keyframes({
27
27
  to: {
28
28
  maskSize: '4em .8em',
29
29
  '-webkit-mask-position-y': '.1em',
30
- maskPosition: 'initial 0',
30
+ maskPosition: 'initial 0.1em',
31
31
  },
32
32
  });
33
33
 
@@ -1,5 +1,7 @@
1
+ import React, { ReactNode, useRef } from 'react';
1
2
  import { Root } from '@radix-ui/react-dialog';
2
3
  import { styled } from '@stitches/react';
4
+ import { CSS } from '../Theme';
3
5
  import {
4
6
  DialogClose,
5
7
  DialogDefaultCloseIcon,
@@ -10,17 +12,43 @@ import {
10
12
  StyledDialogPortal,
11
13
  StyledDialogTrigger,
12
14
  } from './DialogContent';
15
+ import { useDialogContainerSelector } from '../hooks/useDialogContainerSelector';
13
16
 
14
17
  const StyledDialog = styled(Root, {});
18
+ const CustomDialogContent = ({ children, props = {}, css = {} }: { children: ReactNode; props?: any; css?: CSS }) => (
19
+ <StyledDialogContent css={{ ...css, position: 'absolute' }} {...props}>
20
+ {children}
21
+ </StyledDialogContent>
22
+ );
23
+ const CustomDialogOverlay = ({ css = {} }: { css?: CSS }) => (
24
+ <StyledDialogOverlay css={{ ...css, position: 'absolute' }} />
25
+ );
26
+ const CustomDialogPortal = ({ children, container }: { children: ReactNode; container?: HTMLElement | null }) => {
27
+ const dialogContainerSelector = useDialogContainerSelector();
28
+ const containerRef = useRef<HTMLElement | null>(null);
29
+
30
+ if (container) {
31
+ containerRef.current = container;
32
+ } else if (dialogContainerSelector && !containerRef.current) {
33
+ containerRef.current = document.querySelector(dialogContainerSelector) as HTMLElement;
34
+ } else if (!containerRef.current) {
35
+ containerRef.current = document.body;
36
+ }
37
+ return (
38
+ <StyledDialogPortal container={containerRef.current}>
39
+ <>{children}</>
40
+ </StyledDialogPortal>
41
+ );
42
+ };
15
43
 
16
44
  export const Dialog = {
17
45
  Root: StyledDialog,
18
46
  Trigger: StyledDialogTrigger,
19
- Overlay: StyledDialogOverlay,
20
- Content: StyledDialogContent,
47
+ Overlay: CustomDialogOverlay,
48
+ Content: CustomDialogContent,
21
49
  Title: DialogTitle,
22
50
  Description: DialogDescription,
23
51
  Close: DialogClose,
24
52
  DefaultClose: DialogDefaultCloseIcon,
25
- Portal: StyledDialogPortal,
53
+ Portal: CustomDialogPortal,
26
54
  };
@@ -1,5 +1,4 @@
1
- import React, { MutableRefObject, ReactElement, Suspense, useEffect, useRef } from 'react';
2
- import { BrowserRouter, MemoryRouter, Navigate, Route, Routes, useParams } from 'react-router-dom';
1
+ import React, { MutableRefObject, useEffect, useRef } from 'react';
3
2
  import { HMSStatsStoreWrapper, HMSStoreWrapper, IHMSNotifications } from '@100mslive/hms-video-store';
4
3
  import { Layout, Logo, Screens, Theme, Typography } from '@100mslive/types-prebuilt';
5
4
  import {
@@ -14,26 +13,25 @@ import {
14
13
  import { AppData } from './components/AppData/AppData';
15
14
  // @ts-ignore: No implicit Any
16
15
  import AuthToken from './components/AuthToken';
16
+ import { ConferenceScreen } from './components/ConferenceScreen';
17
17
  // @ts-ignore: No implicit Any
18
18
  import { ErrorBoundary } from './components/ErrorBoundary';
19
19
  // @ts-ignore: No implicit Any
20
- import FullPageProgress from './components/FullPageProgress';
21
- // @ts-ignore: No implicit Any
22
20
  import { Init } from './components/init/Init';
23
21
  // @ts-ignore: No implicit Any
24
22
  import { KeyboardHandler } from './components/Input/KeyboardInputManager';
25
- // @ts-ignore: No implicit Any
23
+ import { LeaveScreen } from './components/LeaveScreen';
24
+ import { MwebLandscapePrompt } from './components/MwebLandscapePrompt';
26
25
  import { Notifications } from './components/Notifications';
27
- // @ts-ignore: No implicit Any
28
- import PostLeave from './components/PostLeave';
29
- // @ts-ignore: No implicit Any
30
- import PreviewContainer from './components/Preview/PreviewContainer';
26
+ import { PreviewScreen } from './components/Preview/PreviewScreen';
31
27
  // @ts-ignore: No implicit Any
32
28
  import { ToastContainer } from './components/Toast/ToastContainer';
33
29
  import { RoomLayoutContext, RoomLayoutProvider, useRoomLayout } from './provider/roomLayoutProvider';
30
+ import { DialogContainerProvider } from '../context/DialogContext';
34
31
  import { Box } from '../Layout';
35
32
  import { globalStyles, HMSThemeProvider } from '../Theme';
36
- import { HMSPrebuiltContext, useHMSPrebuiltContext } from './AppContext';
33
+ import { HMSPrebuiltContext } from './AppContext';
34
+ import { AppStateContext, PrebuiltStates, useAppStateManager } from './AppStateContext';
37
35
  // @ts-ignore: No implicit Any
38
36
  import { FlyingEmoji } from './plugins/FlyingEmoji';
39
37
  // @ts-ignore: No implicit Any
@@ -47,9 +45,8 @@ import {
47
45
  } from './provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
48
46
  // @ts-ignore: No implicit Any
49
47
  import { FeatureFlags } from './services/FeatureFlags';
50
-
51
48
  // @ts-ignore: No implicit Any
52
- const Conference = React.lazy(() => import('./components/conference'));
49
+ import { DEFAULT_PORTAL_CONTAINER } from './common/constants';
53
50
 
54
51
  export type HMSPrebuiltOptions = {
55
52
  userName?: string;
@@ -68,6 +65,12 @@ export type HMSPrebuiltProps = {
68
65
  roomId?: string;
69
66
  role?: string;
70
67
  onLeave?: () => void;
68
+ onJoin?: () => void;
69
+ /**
70
+ * @remarks
71
+ * Specify css selectors for the HTML element to be used as container for dialogs. Affects the positioning and focus of dialogs.
72
+ */
73
+ containerSelector?: string;
71
74
  };
72
75
 
73
76
  export type HMSPrebuiltRefType = {
@@ -84,12 +87,14 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
84
87
  authToken = '',
85
88
  roomId = '',
86
89
  role = '',
90
+ containerSelector = DEFAULT_PORTAL_CONTAINER,
87
91
  logo,
88
92
  typography,
89
93
  themes,
90
94
  options: { userName = '', userId = '', endpoints } = {},
91
95
  screens,
92
96
  onLeave,
97
+ onJoin,
93
98
  },
94
99
  ref,
95
100
  ) => {
@@ -171,7 +176,9 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
171
176
  roomCode,
172
177
  roomId,
173
178
  role,
179
+ containerSelector,
174
180
  onLeave,
181
+ onJoin,
175
182
  userName,
176
183
  userId,
177
184
  endpoints: {
@@ -217,17 +224,23 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
217
224
  >
218
225
  <AppData appDetails={metadata} tokenEndpoint={tokenByRoomIdRoleEndpoint} />
219
226
  <Init />
220
- <Box
221
- id="prebuilt-container"
222
- css={{
223
- bg: '$background_dim',
224
- size: '100%',
225
- lineHeight: '1.5',
226
- '-webkit-text-size-adjust': '100%',
227
- }}
228
- >
229
- <AppRoutes authTokenByRoomCodeEndpoint={tokenByRoomCodeEndpoint} defaultAuthToken={authToken} />
230
- </Box>
227
+ <DialogContainerProvider dialogContainerSelector={containerSelector}>
228
+ <Box
229
+ id={DEFAULT_PORTAL_CONTAINER.slice(1)} //Skips the #
230
+ css={{
231
+ bg: '$background_dim',
232
+ size: '100%',
233
+ lineHeight: '1.5',
234
+ '-webkit-text-size-adjust': '100%',
235
+ position: 'relative',
236
+ }}
237
+ >
238
+ <AppRoutes
239
+ authTokenByRoomCodeEndpoint={tokenByRoomCodeEndpoint}
240
+ defaultAuthToken={authToken}
241
+ />
242
+ </Box>
243
+ </DialogContainerProvider>
231
244
  </HMSThemeProvider>
232
245
  );
233
246
  }}
@@ -242,66 +255,17 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
242
255
 
243
256
  HMSPrebuilt.displayName = 'HMSPrebuilt';
244
257
 
245
- const Redirector = ({ showPreview }: { showPreview: boolean }) => {
246
- const { roomId, role } = useParams();
247
- return <Navigate to={`/${showPreview ? 'preview' : 'meeting'}/${roomId}/${role || ''}`} />;
248
- };
249
-
250
- const RouteList = () => {
258
+ const AppStates = ({ activeState }: { activeState: PrebuiltStates }) => {
251
259
  const { isPreviewScreenEnabled } = useRoomLayoutPreviewScreen();
252
260
  const { isLeaveScreenEnabled } = useRoomLayoutLeaveScreen();
253
261
  useAutoStartStreaming();
254
- return (
255
- <Routes>
256
- {isPreviewScreenEnabled ? (
257
- <Route path="preview">
258
- <Route
259
- path=":roomId/:role"
260
- element={
261
- <Suspense fallback={<FullPageProgress text="Loading preview..." />}>
262
- <PreviewContainer />
263
- </Suspense>
264
- }
265
- />
266
- <Route
267
- path=":roomId"
268
- element={
269
- <Suspense fallback={<FullPageProgress text="Loading preview..." />}>
270
- <PreviewContainer />
271
- </Suspense>
272
- }
273
- />
274
- </Route>
275
- ) : null}
276
- <Route path="meeting">
277
- <Route
278
- path=":roomId/:role"
279
- element={
280
- <Suspense fallback={<FullPageProgress text="Joining..." />}>
281
- <Conference />
282
- </Suspense>
283
- }
284
- />
285
- <Route
286
- path=":roomId"
287
- element={
288
- <Suspense fallback={<FullPageProgress text="Joining..." />}>
289
- <Conference />
290
- </Suspense>
291
- }
292
- />
293
- </Route>
294
- {isLeaveScreenEnabled ? (
295
- <Route path="leave">
296
- <Route path=":roomId/:role" element={<PostLeave />} />
297
- <Route path=":roomId" element={<PostLeave />} />
298
- </Route>
299
- ) : null}
300
262
 
301
- <Route path="/:roomId/:role" element={<Redirector showPreview={isPreviewScreenEnabled} />} />
302
- <Route path="/:roomId/" element={<Redirector showPreview={isPreviewScreenEnabled} />} />
303
- </Routes>
304
- );
263
+ if (activeState === PrebuiltStates.PREVIEW && isPreviewScreenEnabled) {
264
+ return <PreviewScreen />;
265
+ } else if (activeState === PrebuiltStates.LEAVE && isLeaveScreenEnabled) {
266
+ return <LeaveScreen />;
267
+ }
268
+ return <ConferenceScreen />;
305
269
  };
306
270
 
307
271
  const BackSwipe = () => {
@@ -321,17 +285,6 @@ const BackSwipe = () => {
321
285
  return null;
322
286
  };
323
287
 
324
- const Router = ({ children }: { children: ReactElement }) => {
325
- const { roomId, role, roomCode } = useHMSPrebuiltContext();
326
- return [roomId, role, roomCode].every(value => !value) ? (
327
- <BrowserRouter>{children}</BrowserRouter>
328
- ) : (
329
- <MemoryRouter initialEntries={[`/${roomCode ? roomCode : `${roomId}/${role || ''}`}`]} initialIndex={0}>
330
- {children}
331
- </MemoryRouter>
332
- );
333
- };
334
-
335
288
  function AppRoutes({
336
289
  authTokenByRoomCodeEndpoint,
337
290
  defaultAuthToken,
@@ -341,22 +294,21 @@ function AppRoutes({
341
294
  }) {
342
295
  const roomLayout = useRoomLayout();
343
296
  const isNotificationsDisabled = useIsNotificationDisabled();
297
+ const { activeState, rejoin } = useAppStateManager();
298
+
344
299
  return (
345
- <Router>
300
+ <AppStateContext.Provider value={{ rejoin }}>
346
301
  <>
347
302
  <ToastContainer />
348
303
  <Notifications />
304
+ <MwebLandscapePrompt />
349
305
  <BackSwipe />
350
306
  {!isNotificationsDisabled && <FlyingEmoji />}
351
307
  <RemoteStopScreenshare />
352
308
  <KeyboardHandler />
353
309
  <AuthToken authTokenByRoomCodeEndpoint={authTokenByRoomCodeEndpoint} defaultAuthToken={defaultAuthToken} />
354
- {roomLayout && (
355
- <Routes>
356
- <Route path="/*" element={<RouteList />} />
357
- </Routes>
358
- )}
310
+ {roomLayout && activeState && <AppStates activeState={activeState} />}
359
311
  </>
360
- </Router>
312
+ </AppStateContext.Provider>
361
313
  );
362
314
  }
@@ -1,4 +1,6 @@
1
1
  import React, { useContext } from 'react';
2
+ // @ts-ignore
3
+ import { DEFAULT_PORTAL_CONTAINER } from './common/constants';
2
4
 
3
5
  type HMSPrebuiltContextType = {
4
6
  roomCode: string;
@@ -6,16 +8,20 @@ type HMSPrebuiltContextType = {
6
8
  role?: string;
7
9
  userName?: string;
8
10
  userId?: string;
11
+ containerSelector: string;
9
12
  endpoints?: Record<string, string>;
10
13
  onLeave?: () => void;
14
+ onJoin?: () => void;
11
15
  };
12
16
 
13
17
  export const HMSPrebuiltContext = React.createContext<HMSPrebuiltContextType>({
14
18
  roomCode: '',
15
19
  userName: '',
16
20
  userId: '',
21
+ containerSelector: DEFAULT_PORTAL_CONTAINER,
17
22
  endpoints: {},
18
23
  onLeave: undefined,
24
+ onJoin: undefined,
19
25
  });
20
26
 
21
27
  HMSPrebuiltContext.displayName = 'HMSPrebuiltContext';
@@ -0,0 +1,71 @@
1
+ import React, { useContext, useEffect } from 'react';
2
+ import { usePreviousDistinct } from 'react-use';
3
+ import { HMSRoomState, selectRoomState, useHMSStore } from '@100mslive/react-sdk';
4
+ import { useRoomLayout } from './provider/roomLayoutProvider';
5
+ import { useRedirectToLeave } from './components/hooks/useRedirectToLeave';
6
+ import {
7
+ useRoomLayoutLeaveScreen,
8
+ useRoomLayoutPreviewScreen,
9
+ } from './provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
10
+
11
+ export enum PrebuiltStates {
12
+ MEETING = 'meeting',
13
+ PREVIEW = 'preview',
14
+ LEAVE = 'leave',
15
+ }
16
+
17
+ type AppStateContextType = {
18
+ rejoin: () => void;
19
+ };
20
+
21
+ export const AppStateContext = React.createContext<AppStateContextType>({
22
+ rejoin: () => {
23
+ console.log('Rejoin');
24
+ },
25
+ });
26
+
27
+ AppStateContext.displayName = 'AppStateContext';
28
+
29
+ export const useHMSAppStateContext = () => {
30
+ const context = useContext(AppStateContext);
31
+ if (!context) {
32
+ throw Error('Make sure AppStateContext.Provider is present at the top level of your application');
33
+ }
34
+ return context;
35
+ };
36
+
37
+ export const useAppStateManager = () => {
38
+ const roomLayout = useRoomLayout();
39
+ const [activeState, setActiveState] = React.useState<PrebuiltStates | undefined>();
40
+ const roomState = useHMSStore(selectRoomState);
41
+ const prevRoomState = usePreviousDistinct(roomState);
42
+ const { isLeaveScreenEnabled } = useRoomLayoutLeaveScreen();
43
+ const { isPreviewScreenEnabled } = useRoomLayoutPreviewScreen();
44
+ const { redirectToLeave } = useRedirectToLeave();
45
+
46
+ const rejoin = () => {
47
+ setActiveState(isPreviewScreenEnabled ? PrebuiltStates.PREVIEW : PrebuiltStates.MEETING);
48
+ };
49
+
50
+ useEffect(() => {
51
+ if (!roomLayout) {
52
+ return;
53
+ }
54
+ if (roomState === HMSRoomState.Connected) {
55
+ setActiveState(PrebuiltStates.MEETING);
56
+ } else if (
57
+ prevRoomState &&
58
+ [HMSRoomState.Reconnecting, HMSRoomState.Connected].includes(prevRoomState) &&
59
+ [HMSRoomState.Disconnecting, HMSRoomState.Disconnected].includes(roomState)
60
+ ) {
61
+ redirectToLeave().then(() => {
62
+ const goTo = isPreviewScreenEnabled ? PrebuiltStates.PREVIEW : PrebuiltStates.MEETING;
63
+ setActiveState(isLeaveScreenEnabled ? PrebuiltStates.LEAVE : goTo);
64
+ });
65
+ } else if (!prevRoomState && roomState === HMSRoomState.Disconnected) {
66
+ setActiveState(isPreviewScreenEnabled ? PrebuiltStates.PREVIEW : PrebuiltStates.MEETING);
67
+ }
68
+ }, [roomLayout, roomState, isLeaveScreenEnabled, isPreviewScreenEnabled, prevRoomState, redirectToLeave]);
69
+
70
+ return { activeState, rejoin };
71
+ };
@@ -44,7 +44,8 @@ export const APP_DATA = {
44
44
  pdfConfig: 'pdfConfig',
45
45
  minimiseInset: 'minimiseInset',
46
46
  activeScreensharePeerId: 'activeScreensharePeerId',
47
- disableNotificiations: 'disableNotificiations',
47
+ disableNotifications: 'disableNotifications',
48
+ pollState: 'pollState',
48
49
  };
49
50
  export const UI_SETTINGS = {
50
51
  isAudioOnly: 'isAudioOnly',
@@ -59,6 +60,19 @@ export const SIDE_PANE_OPTIONS = {
59
60
  PARTICIPANTS: 'Participants',
60
61
  CHAT: 'Chat',
61
62
  STREAMING: 'STREAMING',
63
+ POLLS: 'POLLS',
64
+ };
65
+
66
+ export const POLL_STATE = {
67
+ pollInView: 'pollInView',
68
+ view: 'view',
69
+ };
70
+
71
+ export const POLL_VIEWS = {
72
+ CREATE_POLL_QUIZ: 'CREATE_POLL_QUIZ',
73
+ CREATE_QUESTIONS: 'CREATE_QUESTIONS',
74
+ VOTE: 'VOTE',
75
+ RESULTS: 'RESULTS',
62
76
  };
63
77
 
64
78
  export const SUBSCRIBED_NOTIFICATIONS = {
@@ -93,4 +107,25 @@ export const SESSION_STORE_KEY = {
93
107
  SPOTLIGHT: 'spotlight',
94
108
  };
95
109
 
110
+ export const INTERACTION_TYPE = {
111
+ POLL: 'Poll',
112
+ QUIZ: 'Quiz',
113
+ };
114
+
115
+ export const QUESTION_TYPE_TITLE = {
116
+ 'single-choice': 'Single Choice',
117
+ 'multiple-choice': 'Multiple Choice',
118
+ // "short-answer": "Short Answer",
119
+ // "long-answer": "Long Answer",
120
+ };
121
+
122
+ export const QUESTION_TYPE = {
123
+ SINGLE_CHOICE: 'single-choice',
124
+ MULTIPLE_CHOICE: 'multiple-choice',
125
+ // SHORT_ANSWER: "short-answer",
126
+ // LONG_ANSWER: "long-answer",
127
+ };
128
+
96
129
  export const ROLE_CHANGE_DECLINED = 'role_change_declined';
130
+
131
+ export const DEFAULT_PORTAL_CONTAINER = '#prebuilt-container';
@@ -1,3 +1,5 @@
1
+ import { QUESTION_TYPE } from './constants';
2
+
1
3
  // eslint-disable-next-line complexity
2
4
  export function shadeColor(color, percent) {
3
5
  let R = parseInt(color.substring(1, 3), 16);
@@ -88,3 +90,48 @@ export const formatTime = timeInSeconds => {
88
90
  const hour = hours !== 0 ? `${hours < 10 ? '0' : ''}${hours}:` : '';
89
91
  return `${hour}${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
90
92
  };
93
+
94
+ const compareArrays = (a, b) => {
95
+ if (a.length !== b.length) return false;
96
+ else {
97
+ // Comparing each element of your array
98
+ for (var i = 0; i < a.length; i++) {
99
+ if (a[i] !== b[i]) {
100
+ return false;
101
+ }
102
+ }
103
+ return true;
104
+ }
105
+ };
106
+
107
+ export const checkCorrectAnswer = (answer, localPeerResponse, type) => {
108
+ if (type === QUESTION_TYPE.SINGLE_CHOICE) {
109
+ return answer?.option === localPeerResponse?.option;
110
+ } else if (type === QUESTION_TYPE.MULTIPLE_CHOICE) {
111
+ return answer?.options && localPeerResponse?.options && compareArrays(answer?.options, localPeerResponse?.options);
112
+ }
113
+ };
114
+
115
+ export const isValidTextInput = (text, minLength = 1, maxLength = 100) => {
116
+ return text && text.length >= minLength && text.length <= maxLength;
117
+ };
118
+
119
+ export const calculateAvatarAndAttribBoxSize = (calculatedWidth, calculatedHeight) => {
120
+ if (!calculatedWidth || !calculatedHeight) {
121
+ return [undefined, undefined];
122
+ }
123
+
124
+ let avatarSize = 'large';
125
+ if (calculatedWidth <= 150 || calculatedHeight <= 150) {
126
+ avatarSize = 'small';
127
+ } else if (calculatedWidth <= 300 || calculatedHeight <= 300) {
128
+ avatarSize = 'medium';
129
+ }
130
+
131
+ let attribBoxSize = 'medium';
132
+ if (calculatedWidth <= 180 || calculatedHeight <= 180) {
133
+ attribBoxSize = 'small';
134
+ }
135
+
136
+ return [avatarSize, attribBoxSize];
137
+ };
@@ -21,6 +21,7 @@ import {
21
21
  APP_DATA,
22
22
  CHAT_SELECTOR,
23
23
  DEFAULT_WAITING_VIEWER_ROLE,
24
+ POLL_STATE,
24
25
  SIDE_PANE_OPTIONS,
25
26
  UI_MODE_GRID,
26
27
  UI_SETTINGS,
@@ -65,7 +66,11 @@ const initialAppData = {
65
66
  [APP_DATA.authToken]: '',
66
67
  [APP_DATA.minimiseInset]: false,
67
68
  [APP_DATA.activeScreensharePeerId]: '',
68
- [APP_DATA.disableNotificiations]: false,
69
+ [APP_DATA.disableNotifications]: false,
70
+ [APP_DATA.pollState]: {
71
+ [POLL_STATE.pollInView]: '',
72
+ [POLL_STATE.view]: '',
73
+ },
69
74
  };
70
75
 
71
76
  export const AppData = React.memo(({ appDetails, tokenEndpoint }) => {
@@ -1,6 +1,7 @@
1
1
  import { useCallback } from 'react';
2
2
  import { selectAppData, useHMSActions, useHMSStore, useHMSVanillaStore } from '@100mslive/react-sdk';
3
- import { APP_DATA } from '../../common/constants';
3
+ import { usePollViewState } from './useUISettings';
4
+ import { APP_DATA, POLL_STATE, POLL_VIEWS, SIDE_PANE_OPTIONS } from '../../common/constants';
4
5
 
5
6
  /**
6
7
  * Gives a boolean value if the sidepaneType matches current sidepane value in store
@@ -37,6 +38,26 @@ export const useSidepaneToggle = sidepaneType => {
37
38
  return toggleSidepane;
38
39
  };
39
40
 
41
+ export const usePollViewToggle = () => {
42
+ const { view, setPollState } = usePollViewState();
43
+ const isOpen = useSidepaneState() === SIDE_PANE_OPTIONS.POLLS;
44
+ const toggleSidepane = useSidepaneToggle(SIDE_PANE_OPTIONS.POLLS);
45
+
46
+ const togglePollView = useCallback(
47
+ id => {
48
+ id = typeof id === 'string' ? id : undefined;
49
+ setPollState({
50
+ [POLL_STATE.pollInView]: id,
51
+ [POLL_STATE.view]: id ? POLL_VIEWS.VOTE : isOpen && view ? null : POLL_VIEWS.CREATE_POLL_QUIZ,
52
+ });
53
+ toggleSidepane();
54
+ },
55
+ [view, setPollState, isOpen, toggleSidepane],
56
+ );
57
+
58
+ return togglePollView;
59
+ };
60
+
40
61
  /**
41
62
  * reset's the sidepane value
42
63
  */
@@ -44,6 +65,7 @@ export const useSidepaneReset = () => {
44
65
  const hmsActions = useHMSActions();
45
66
  const resetSidepane = useCallback(() => {
46
67
  hmsActions.setAppData(APP_DATA.sidePane, '');
68
+ hmsActions.setAppData(APP_DATA.pollInView, '');
47
69
  }, [hmsActions]);
48
70
  return resetSidepane;
49
71
  };