@whereby.com/browser-sdk 3.12.23 → 3.13.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.
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var reactRedux = require('react-redux');
5
4
  var core = require('@whereby.com/core');
6
- var toolkit = require('@reduxjs/toolkit');
7
5
  var runes = require('runes');
8
6
  var PopoverPrimitive = require('@radix-ui/react-popover');
9
7
 
@@ -28,13 +26,14 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
28
26
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
29
27
 
30
28
  const WherebyContext = React__namespace.createContext(null);
31
- reactRedux.createStoreHook(WherebyContext);
32
- const useDispatch = reactRedux.createDispatchHook(WherebyContext);
33
- const useSelector = reactRedux.createSelectorHook(WherebyContext);
34
29
  function Provider({ children }) {
35
- const services = core.createServices();
36
- const store = core.createStore({ injectServices: services });
37
- return (React__namespace.createElement(reactRedux.Provider, { context: WherebyContext, store: store }, children));
30
+ const client = React__namespace.useMemo(() => new core.WherebyClient(), []);
31
+ React__namespace.useEffect(() => {
32
+ return () => {
33
+ client.destroy();
34
+ };
35
+ }, [client]);
36
+ return React__namespace.createElement(WherebyContext.Provider, { value: client }, children);
38
37
  }
39
38
 
40
39
  /******************************************************************************
@@ -71,13 +70,21 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
71
70
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
72
71
  };
73
72
 
74
- const useAppDispatch = useDispatch.withTypes();
75
- const useAppSelector = useSelector.withTypes();
76
-
77
73
  const useAudioElement = ({ stream, muted }) => {
78
- const audioEl = React.useRef(null);
79
- const currentSpeakerId = useAppSelector(core.selectCurrentSpeakerDeviceId);
80
- React.useEffect(() => {
74
+ var _a;
75
+ const audioEl = React__namespace.useRef(null);
76
+ const client = (_a = React__namespace.useContext(WherebyContext)) === null || _a === void 0 ? void 0 : _a.getLocalMedia();
77
+ const [currentSpeakerId, setCurrentSpeakerId] = React__namespace.useState();
78
+ const listener = React__namespace.useCallback((speakerId) => {
79
+ setCurrentSpeakerId(speakerId);
80
+ }, []);
81
+ React__namespace.useEffect(() => {
82
+ client === null || client === void 0 ? void 0 : client.addListener(core.CURRENT_SPEAKER_CHANGED, listener);
83
+ return () => {
84
+ client === null || client === void 0 ? void 0 : client.removeListener(core.CURRENT_SPEAKER_CHANGED, listener);
85
+ };
86
+ }, [client]);
87
+ React__namespace.useEffect(() => {
81
88
  if (!audioEl.current || muted || !stream || !currentSpeakerId) {
82
89
  return;
83
90
  }
@@ -92,8 +99,9 @@ const useAudioElement = ({ stream, muted }) => {
92
99
  };
93
100
 
94
101
  const VideoView = React__namespace.forwardRef((_a, ref) => {
102
+ var _b;
95
103
  var { muted, mirror = false, stream, onVideoResize } = _a, rest = __rest(_a, ["muted", "mirror", "stream", "onVideoResize"]);
96
- const dispatch = useAppDispatch();
104
+ const client = (_b = React__namespace.useContext(WherebyContext)) === null || _b === void 0 ? void 0 : _b.getRoomConnection();
97
105
  const videoEl = React__namespace.useRef(null);
98
106
  const audioEl = useAudioElement({ muted, stream });
99
107
  React__namespace.useImperativeHandle(ref, () => {
@@ -119,11 +127,7 @@ const VideoView = React__namespace.forwardRef((_a, ref) => {
119
127
  if (videoEl.current && (stream === null || stream === void 0 ? void 0 : stream.id)) {
120
128
  const width = videoEl.current.clientWidth;
121
129
  const height = videoEl.current.clientHeight;
122
- dispatch(core.doRtcReportStreamResolution({
123
- streamId: stream.id,
124
- width,
125
- height,
126
- }));
130
+ client === null || client === void 0 ? void 0 : client.reportStreamResolution(stream.id, width, height);
127
131
  if (onVideoResize) {
128
132
  onVideoResize({
129
133
  width,
@@ -155,35 +159,24 @@ const VideoView = React__namespace.forwardRef((_a, ref) => {
155
159
  });
156
160
  VideoView.displayName = "VideoView";
157
161
 
158
- const selectRoomConnectionState = toolkit.createSelector(core.selectChatMessages, core.selectCloudRecordingRaw, core.selectBreakoutCurrentGroup, core.selectBreakoutActive, core.selectBreakoutGroupedParticipants, core.selectAllClientViewsInCurrentGroup, core.selectLocalParticipantRaw, core.selectLocalMediaStream, core.selectRemoteParticipants, core.selectScreenshares, core.selectRoomConnectionStatus, core.selectStreamingRaw, core.selectWaitingParticipants, core.selectNotificationsEmitter, core.selectSpotlightedClientViews, (chatMessages, cloudRecording, breakoutCurrentGroup, breakoutActive, breakoutGroupedParticipants, clientViewsInCurrentGroup, localParticipant, localMediaStream, remoteParticipants, screenshares, connectionStatus, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews) => {
159
- const state = {
160
- chatMessages,
161
- cloudRecording: cloudRecording.isRecording ? { status: "recording" } : undefined,
162
- breakout: {
163
- isActive: breakoutActive,
164
- currentGroup: breakoutCurrentGroup,
165
- groupedParticipants: breakoutGroupedParticipants,
166
- participantsInCurrentGroup: clientViewsInCurrentGroup,
167
- },
168
- connectionStatus,
169
- events: notificationsEmitter,
170
- liveStream: streaming.isStreaming
171
- ? {
172
- status: "streaming",
173
- startedAt: streaming.startedAt,
174
- }
175
- : undefined,
176
- localScreenshareStatus: localParticipant.isScreenSharing ? "active" : undefined,
177
- localParticipant: Object.assign(Object.assign({}, localParticipant), { stream: localMediaStream }),
178
- remoteParticipants,
179
- screenshares,
180
- waitingParticipants,
181
- spotlightedParticipants: spotlightedClientViews,
182
- };
183
- return state;
184
- });
162
+ const browserSdkVersion = "3.13.0";
185
163
 
186
- const browserSdkVersion = "3.12.23";
164
+ const initialState$1 = {
165
+ chatMessages: [],
166
+ cloudRecording: undefined,
167
+ breakout: {
168
+ isActive: false,
169
+ currentGroup: null,
170
+ groupedParticipants: [],
171
+ participantsInCurrentGroup: [],
172
+ },
173
+ localParticipant: undefined,
174
+ remoteParticipants: [],
175
+ screenshares: [],
176
+ connectionStatus: "ready",
177
+ waitingParticipants: [],
178
+ spotlightedParticipants: [],
179
+ };
187
180
 
188
181
  const defaultRoomConnectionOptions = {
189
182
  localMediaOptions: {
@@ -192,8 +185,12 @@ const defaultRoomConnectionOptions = {
192
185
  },
193
186
  };
194
187
  function useRoomConnection(roomUrl, roomConnectionOptions = defaultRoomConnectionOptions) {
195
- const dispatch = useAppDispatch();
196
- const roomConnectionState = useAppSelector(selectRoomConnectionState);
188
+ var _a;
189
+ const client = (_a = React__namespace.useContext(WherebyContext)) === null || _a === void 0 ? void 0 : _a.getRoomConnection();
190
+ const [roomConnectionState, setRoomConnectionState] = React__namespace.useState(() => initialState$1);
191
+ if (!client) {
192
+ throw new Error("WherebyClient is not initialized. Please wrap your component with WherebyProvider.");
193
+ }
197
194
  const roomConfig = React__namespace.useMemo(() => {
198
195
  const url = new URL(roomUrl);
199
196
  const searchParams = new URLSearchParams(url.search);
@@ -208,36 +205,45 @@ function useRoomConnection(roomUrl, roomConnectionOptions = defaultRoomConnectio
208
205
  };
209
206
  }, [roomUrl, roomConnectionOptions]);
210
207
  React__namespace.useEffect(() => {
208
+ const unsubscribe = client.subscribe((state) => {
209
+ setRoomConnectionState((prev) => (Object.assign(Object.assign({}, prev), state)));
210
+ });
211
+ const eventEmitter = client.getNotificationsEventEmitter();
212
+ setRoomConnectionState((prev) => (Object.assign(Object.assign({}, prev), { events: eventEmitter })));
211
213
  return () => {
212
- dispatch(core.doAppStop());
214
+ unsubscribe();
215
+ client.leaveRoom();
213
216
  };
214
217
  }, []);
215
- const sendChatMessage = React__namespace.useCallback((text) => dispatch(core.doSendChatMessage({ text })), [dispatch]);
216
- const knock = React__namespace.useCallback(() => dispatch(core.doKnockRoom()), [dispatch]);
217
- const setDisplayName = React__namespace.useCallback((displayName) => dispatch(core.doSetDisplayName({ displayName })), [dispatch]);
218
- const toggleCamera = React__namespace.useCallback((enabled) => dispatch(core.toggleCameraEnabled({ enabled })), [dispatch]);
219
- const toggleMicrophone = React__namespace.useCallback((enabled) => dispatch(core.toggleMicrophoneEnabled({ enabled })), [dispatch]);
220
- const toggleLowDataMode = React__namespace.useCallback((enabled) => dispatch(core.toggleLowDataModeEnabled({ enabled })), [dispatch]);
221
- const toggleRaiseHand = React__namespace.useCallback((enabled) => dispatch(core.doSetLocalStickyReaction({ enabled })), [dispatch]);
222
- const askToSpeak = React__namespace.useCallback((participantId) => dispatch(core.doRequestAudioEnable({ clientIds: [participantId], enable: true })), [dispatch]);
223
- const askToTurnOnCamera = React__namespace.useCallback((participantId) => dispatch(core.doRequestVideoEnable({ clientIds: [participantId], enable: true })), [dispatch]);
224
- const acceptWaitingParticipant = React__namespace.useCallback((participantId) => dispatch(core.doAcceptWaitingParticipant({ participantId })), [dispatch]);
225
- const rejectWaitingParticipant = React__namespace.useCallback((participantId) => dispatch(core.doRejectWaitingParticipant({ participantId })), [dispatch]);
226
- const startCloudRecording = React__namespace.useCallback(() => dispatch(core.doStartCloudRecording()), [dispatch]);
227
- const startScreenshare = React__namespace.useCallback(() => dispatch(core.doStartScreenshare()), [dispatch]);
228
- const stopCloudRecording = React__namespace.useCallback(() => dispatch(core.doStopCloudRecording()), [dispatch]);
229
- const stopScreenshare = React__namespace.useCallback(() => dispatch(core.doStopScreenshare()), [dispatch]);
230
- const joinRoom = React__namespace.useCallback(() => dispatch(core.doAppStart(roomConfig)), [dispatch]);
231
- const leaveRoom = React__namespace.useCallback(() => dispatch(core.doAppStop()), [dispatch]);
232
- const lockRoom = React__namespace.useCallback((locked) => dispatch(core.doLockRoom({ locked })), [dispatch]);
233
- const muteParticipants = React__namespace.useCallback((participantIds) => dispatch(core.doRequestAudioEnable({ clientIds: participantIds, enable: false })), [dispatch]);
234
- const turnOffParticipantCameras = React__namespace.useCallback((participantIds) => dispatch(core.doRequestVideoEnable({ clientIds: participantIds, enable: false })), [dispatch]);
235
- const spotlightParticipant = React__namespace.useCallback((participantId) => dispatch(core.doSpotlightParticipant({ id: participantId })), [dispatch]);
236
- const removeSpotlight = React__namespace.useCallback((participantId) => dispatch(core.doRemoveSpotlight({ id: participantId })), [dispatch]);
237
- const kickParticipant = React__namespace.useCallback((participantId) => dispatch(core.doKickParticipant({ clientId: participantId })), [dispatch]);
238
- const endMeeting = React__namespace.useCallback((stayBehind) => dispatch(core.doEndMeeting({ stayBehind })), [dispatch]);
239
- const joinBreakoutGroup = React__namespace.useCallback((group) => dispatch(core.doBreakoutJoin({ group })), [dispatch]);
240
- const joinBreakoutMainRoom = React__namespace.useCallback(() => dispatch(core.doBreakoutJoin({ group: "" })), [dispatch]);
218
+ const joinRoom = React__namespace.useCallback(() => {
219
+ client.initialize(roomConfig);
220
+ client.joinRoom();
221
+ }, [client]);
222
+ const sendChatMessage = React__namespace.useCallback((text) => client.sendChatMessage(text), [client]);
223
+ const knock = React__namespace.useCallback(() => client.knock(), [client]);
224
+ const setDisplayName = React__namespace.useCallback((displayName) => client.setDisplayName(displayName), [client]);
225
+ const toggleCamera = React__namespace.useCallback((enabled) => client.toggleCamera(enabled), [client]);
226
+ const toggleMicrophone = React__namespace.useCallback((enabled) => client.toggleMicrophone(enabled), [client]);
227
+ const toggleLowDataMode = React__namespace.useCallback((enabled) => client.toggleLowDataMode(enabled), [client]);
228
+ const toggleRaiseHand = React__namespace.useCallback((enabled) => client.toggleRaiseHand(enabled), [client]);
229
+ const askToSpeak = React__namespace.useCallback((participantId) => client.askToSpeak(participantId), [client]);
230
+ const askToTurnOnCamera = React__namespace.useCallback((participantId) => client.askToTurnOnCamera(participantId), [client]);
231
+ const acceptWaitingParticipant = React__namespace.useCallback((participantId) => client.acceptWaitingParticipant(participantId), [client]);
232
+ const rejectWaitingParticipant = React__namespace.useCallback((participantId) => client.rejectWaitingParticipant(participantId), [client]);
233
+ const startCloudRecording = React__namespace.useCallback(() => client.startCloudRecording(), [client]);
234
+ const startScreenshare = React__namespace.useCallback(() => client.startScreenshare(), [client]);
235
+ const stopCloudRecording = React__namespace.useCallback(() => client.stopCloudRecording(), [client]);
236
+ const stopScreenshare = React__namespace.useCallback(() => client.stopScreenshare(), [client]);
237
+ const leaveRoom = React__namespace.useCallback(() => client.leaveRoom(), [client]);
238
+ const lockRoom = React__namespace.useCallback((locked) => client.lockRoom(locked), [client]);
239
+ const muteParticipants = React__namespace.useCallback((participantIds) => client.muteParticipants(participantIds), [client]);
240
+ const turnOffParticipantCameras = React__namespace.useCallback((participantIds) => client.turnOffParticipantCameras(participantIds), [client]);
241
+ const spotlightParticipant = React__namespace.useCallback((participantId) => client.spotlightParticipant(participantId), [client]);
242
+ const removeSpotlight = React__namespace.useCallback((participantId) => client.removeSpotlight(participantId), [client]);
243
+ const kickParticipant = React__namespace.useCallback((participantId) => client.kickParticipant(participantId), [client]);
244
+ const endMeeting = React__namespace.useCallback((stayBehind) => client.endMeeting(stayBehind), [client]);
245
+ const joinBreakoutGroup = React__namespace.useCallback((group) => client.joinBreakoutGroup(group), [client]);
246
+ const joinBreakoutMainRoom = React__namespace.useCallback(() => client.joinBreakoutMainRoom(), [client]);
241
247
  const { events } = roomConnectionState, state = __rest(roomConnectionState, ["events"]);
242
248
  return {
243
249
  state,
@@ -273,40 +279,41 @@ function useRoomConnection(roomUrl, roomConnectionOptions = defaultRoomConnectio
273
279
  };
274
280
  }
275
281
 
276
- const selectLocalMediaState = toolkit.createSelector(core.selectCameraDeviceError, core.selectCameraDevices, core.selectCurrentCameraDeviceId, core.selectCurrentMicrophoneDeviceId, core.selectCurrentSpeakerDeviceId, core.selectIsSettingCameraDevice, core.selectIsSettingMicrophoneDevice, core.selectIsLocalMediaStarting, core.selectLocalMediaStream, core.selectMicrophoneDeviceError, core.selectMicrophoneDevices, core.selectSpeakerDevices, core.selectLocalMediaStartError, (cameraDeviceError, cameraDevices, currentCameraDeviceId, currentMicrophoneDeviceId, currentSpeakerDeviceId, isSettingCameraDevice, isSettingMicrophoneDevice, isStarting, localStream, microphoneDeviceError, microphoneDevices, speakerDevices, startError) => {
277
- const state = {
278
- cameraDeviceError,
279
- cameraDevices,
280
- currentCameraDeviceId,
281
- currentMicrophoneDeviceId,
282
- currentSpeakerDeviceId,
283
- isSettingCameraDevice,
284
- isSettingMicrophoneDevice,
285
- isStarting,
286
- localStream,
287
- microphoneDeviceError,
288
- microphoneDevices,
289
- speakerDevices,
290
- startError,
291
- };
292
- return state;
293
- });
282
+ const initialState = {
283
+ cameraDeviceError: null,
284
+ isStarting: false,
285
+ isSettingCameraDevice: false,
286
+ isSettingMicrophoneDevice: false,
287
+ microphoneDeviceError: null,
288
+ startError: null,
289
+ cameraDevices: [],
290
+ microphoneDevices: [],
291
+ speakerDevices: [],
292
+ };
294
293
 
295
294
  function useLocalMedia(optionsOrStream = { audio: true, video: true }) {
296
- const dispatch = useAppDispatch();
297
- const localMediaState = useAppSelector(selectLocalMediaState);
295
+ var _a;
296
+ const client = (_a = React__namespace.useContext(WherebyContext)) === null || _a === void 0 ? void 0 : _a.getLocalMedia();
297
+ const [localMediaState, setLocalMediaState] = React__namespace.useState(() => initialState);
298
+ if (!client) {
299
+ throw new Error("WherebyClient is not initialized. Please wrap your component with WherebyProvider.");
300
+ }
298
301
  React__namespace.useEffect(() => {
299
- dispatch(core.doStartLocalMedia(optionsOrStream));
302
+ client.startMedia(optionsOrStream);
303
+ const unsubscribe = client.subscribe((state) => {
304
+ setLocalMediaState((prevState) => (Object.assign(Object.assign({}, prevState), state)));
305
+ });
300
306
  return () => {
301
- dispatch(core.doStopLocalMedia());
307
+ unsubscribe();
308
+ client.stopMedia();
302
309
  };
303
310
  }, []);
304
- const setCameraDevice = React__namespace.useCallback((deviceId) => dispatch(core.setCurrentCameraDeviceId({ deviceId })), [dispatch]);
305
- const setMicrophoneDevice = React__namespace.useCallback((deviceId) => dispatch(core.setCurrentMicrophoneDeviceId({ deviceId })), [dispatch]);
306
- const setSpeakerDevice = React__namespace.useCallback((deviceId) => dispatch(core.setCurrentSpeakerDeviceId({ deviceId })), [dispatch]);
307
- const toggleCamera = React__namespace.useCallback((enabled) => dispatch(core.toggleCameraEnabled({ enabled })), [dispatch]);
308
- const toggleMicrophone = React__namespace.useCallback((enabled) => dispatch(core.toggleMicrophoneEnabled({ enabled })), [dispatch]);
309
- const toggleLowDataMode = React__namespace.useCallback((enabled) => dispatch(core.toggleLowDataModeEnabled({ enabled })), [dispatch]);
311
+ const setCameraDevice = React__namespace.useCallback((deviceId) => client.setCameraDevice(deviceId), [client]);
312
+ const setMicrophoneDevice = React__namespace.useCallback((deviceId) => client.setMicrophoneDevice(deviceId), [client]);
313
+ const setSpeakerDevice = React__namespace.useCallback((deviceId) => client.setSpeakerDevice(deviceId), [client]);
314
+ const toggleCamera = React__namespace.useCallback((enabled) => client.toggleCamera(enabled), [client]);
315
+ const toggleMicrophone = React__namespace.useCallback((enabled) => client.toggleMicrophone(enabled), [client]);
316
+ const toggleLowDataMode = React__namespace.useCallback((enabled) => client.toggleLowDataMode(enabled), [client]);
310
317
  return {
311
318
  state: localMediaState,
312
319
  actions: {
@@ -1745,9 +1752,38 @@ function calculateSubgridViews({ clientViews, activeVideosSubgridTrigger, should
1745
1752
  return noVideoViews;
1746
1753
  }
1747
1754
  function useGridParticipants({ activeVideosSubgridTrigger = ACTIVE_VIDEO_SUBGRID_TRIGGER, stageParticipantLimit = STAGE_PARTICIPANT_LIMIT, forceSubgrid = true, enableSubgrid = true, maximizedParticipant, floatingParticipant, isConstrained = false, } = {}) {
1748
- const allClientViews = useAppSelector(core.selectAllClientViews);
1749
- const spotlightedParticipants = useAppSelector(core.selectSpotlightedClientViews);
1750
- const numParticipants = useAppSelector(core.selectNumParticipants);
1755
+ var _a;
1756
+ const [state, setState] = React__namespace.useState({
1757
+ allClientViews: [],
1758
+ spotlightedParticipants: [],
1759
+ numParticipants: 0,
1760
+ });
1761
+ const client = (_a = React__namespace.useContext(WherebyContext)) === null || _a === void 0 ? void 0 : _a.getGrid();
1762
+ if (!client) {
1763
+ throw new Error("useGridParticipants must be used within a WherebyProvider");
1764
+ }
1765
+ const handleClientViewChanged = React__namespace.useCallback((clientViews) => {
1766
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { allClientViews: clientViews })));
1767
+ }, [setState]);
1768
+ const handleSpotlightedParticipantsChanged = React__namespace.useCallback((spotlighted) => {
1769
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { spotlightedParticipants: spotlighted })));
1770
+ }, [setState]);
1771
+ const handleNumParticipantsChanged = React__namespace.useCallback((num) => {
1772
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { numParticipants: num })));
1773
+ }, [setState]);
1774
+ React__namespace.useEffect(() => {
1775
+ const unsubscribeClientViews = client.subscribeClientViews(handleClientViewChanged);
1776
+ const unsubscribeSpotlighted = client.subscribeSpotlightedParticipants(handleSpotlightedParticipantsChanged);
1777
+ const unsubscribeNumParticipants = client.subscribeNumberOfClientViews(handleNumParticipantsChanged);
1778
+ return () => {
1779
+ unsubscribeClientViews();
1780
+ unsubscribeSpotlighted();
1781
+ unsubscribeNumParticipants();
1782
+ };
1783
+ }, [client]);
1784
+ const allClientViews = React__namespace.useMemo(() => state.allClientViews, [state.allClientViews]);
1785
+ const spotlightedParticipants = React__namespace.useMemo(() => state.spotlightedParticipants, [state.spotlightedParticipants]);
1786
+ const numParticipants = React__namespace.useMemo(() => state.numParticipants, [state.numParticipants]);
1751
1787
  const floatingClientView = React__namespace.useMemo(() => {
1752
1788
  return floatingParticipant;
1753
1789
  }, [floatingParticipant]);
@@ -1790,6 +1826,7 @@ function useGridParticipants({ activeVideosSubgridTrigger = ACTIVE_VIDEO_SUBGRID
1790
1826
  clientViewsInGrid,
1791
1827
  clientViewsInPresentationGrid,
1792
1828
  clientViewsInSubgrid,
1829
+ spotlightedParticipants,
1793
1830
  };
1794
1831
  }
1795
1832
 
@@ -2006,10 +2043,11 @@ const ParticipantMenuTrigger = React__namespace.forwardRef((_a, ref) => {
2006
2043
  });
2007
2044
  ParticipantMenuTrigger.displayName = PopoverTrigger.displayName;
2008
2045
  const ParticipantMenuItem = React__namespace.forwardRef((_a, ref) => {
2046
+ var _b;
2009
2047
  var { children, style, participantAction } = _a, props = __rest(_a, ["children", "style", "participantAction"]);
2010
2048
  const { participant, setOpen, maximizedParticipant, setMaximizedParticipant, setFloatingParticipant, floatingParticipant, } = useParticipantMenu();
2011
- const dispatch = useAppDispatch();
2012
- const spotlightedParticipants = useAppSelector(core.selectSpotlightedClientViews);
2049
+ const client = (_b = React__namespace.useContext(WherebyContext)) === null || _b === void 0 ? void 0 : _b.getGrid();
2050
+ const { spotlightedParticipants } = useGridParticipants();
2013
2051
  const isSpotlighted = spotlightedParticipants.find((p) => p.id === participant.id);
2014
2052
  const isMaximized = (maximizedParticipant === null || maximizedParticipant === void 0 ? void 0 : maximizedParticipant.id) === participant.id;
2015
2053
  const isFloating = (floatingParticipant === null || floatingParticipant === void 0 ? void 0 : floatingParticipant.id) === participant.id;
@@ -2029,10 +2067,10 @@ const ParticipantMenuItem = React__namespace.forwardRef((_a, ref) => {
2029
2067
  case "spotlight":
2030
2068
  onClick = () => {
2031
2069
  if (isSpotlighted) {
2032
- dispatch(core.doRemoveSpotlight({ id: participant.id }));
2070
+ client === null || client === void 0 ? void 0 : client.removeSpotlight(participant.id);
2033
2071
  }
2034
2072
  else {
2035
- dispatch(core.doSpotlightParticipant({ id: participant.id }));
2073
+ client === null || client === void 0 ? void 0 : client.spotlightParticipant(participant.id);
2036
2074
  }
2037
2075
  setOpen(false);
2038
2076
  };
@@ -2082,7 +2120,7 @@ function PopInIcon(props) {
2082
2120
  }
2083
2121
 
2084
2122
  function DefaultParticipantMenu({ participant }) {
2085
- const spotlightedParticipants = useAppSelector(core.selectSpotlightedClientViews);
2123
+ const { spotlightedParticipants } = useGridParticipants();
2086
2124
  const isSpotlighted = spotlightedParticipants.find((p) => p.id === participant.id);
2087
2125
  const { isHovered, maximizedParticipant, floatingParticipant } = useGridCell();
2088
2126
  const isMaximized = (maximizedParticipant === null || maximizedParticipant === void 0 ? void 0 : maximizedParticipant.id) === participant.id;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { LocalMediaOptions, ConnectionStatus, ChatMessage as ChatMessage$1, ClientView, NotificationsEventEmitter, LocalParticipant, RemoteParticipant, Screenshare } from '@whereby.com/core';
3
- import { RoleName } from '@whereby.com/media';
2
+ import { LocalMediaState, LocalMediaOptions, RoomConnectionState, NotificationsEventEmitter, ClientView } from '@whereby.com/core';
3
+ export { BreakoutState as Breakout, ChatMessageState as ChatMessage, CloudRecordingState as CloudRecording, LiveStreamState as LiveStreaming, LocalParticipantState as LocalParticipant, RemoteParticipantState as RemoteParticipant, RoomConnectionState as RoomConnection, ScreenshareState as Screenshare, WaitingParticipantState as WaitingParticipant } from '@whereby.com/core';
4
4
  import * as _radix_ui_react_popover from '@radix-ui/react-popover';
5
5
  import { PopoverProps } from '@radix-ui/react-popover';
6
6
 
@@ -31,21 +31,6 @@ type WherebyVideoElement = HTMLVideoElement & {
31
31
  type VideoViewProps = VideoViewSelfProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<WherebyVideoElement>, WherebyVideoElement>;
32
32
  declare const VideoView: React.ForwardRefExoticComponent<Omit<VideoViewProps, "ref"> & React.RefAttributes<WherebyVideoElement>>;
33
33
 
34
- interface LocalMediaState {
35
- currentCameraDeviceId?: string;
36
- currentMicrophoneDeviceId?: string;
37
- currentSpeakerDeviceId?: string;
38
- cameraDeviceError: unknown;
39
- cameraDevices: MediaDeviceInfo[];
40
- isSettingCameraDevice: boolean;
41
- isSettingMicrophoneDevice: boolean;
42
- isStarting: boolean;
43
- localStream?: MediaStream;
44
- microphoneDeviceError: unknown;
45
- microphoneDevices: MediaDeviceInfo[];
46
- speakerDevices: MediaDeviceInfo[];
47
- startError: unknown;
48
- }
49
34
  interface LocalMediaActions {
50
35
  setCameraDevice: (deviceId: string) => void;
51
36
  setMicrophoneDevice: (deviceId: string) => void;
@@ -60,62 +45,6 @@ type UseLocalMediaResult = {
60
45
  };
61
46
  type UseLocalMediaOptions = LocalMediaOptions;
62
47
 
63
- type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
64
- interface LocalParticipantState extends LocalParticipant {
65
- isScreenSharing: boolean;
66
- roleName: RoleName;
67
- clientClaim?: string;
68
- }
69
- interface WaitingParticipantState {
70
- id: string;
71
- displayName: string | null;
72
- }
73
- interface ChatMessageState {
74
- senderId: string;
75
- timestamp: string;
76
- text: string;
77
- }
78
- type ScreenshareState = Screenshare;
79
- type LocalScreenshareStatus = "starting" | "active";
80
- type ChatMessage = Pick<ChatMessage$1, "senderId" | "timestamp" | "text">;
81
- type CloudRecordingState = {
82
- error?: string;
83
- status: "recording" | "requested" | "error";
84
- startedAt?: number;
85
- };
86
- type LiveStreamState = {
87
- status: "streaming";
88
- startedAt?: number;
89
- };
90
- type BreakoutState = {
91
- isActive: boolean;
92
- currentGroup: {
93
- id: string | null;
94
- name: string;
95
- } | null;
96
- groupedParticipants: {
97
- clients: ClientView[];
98
- group: {
99
- id: string;
100
- name: string;
101
- } | null;
102
- }[];
103
- participantsInCurrentGroup: ClientView[];
104
- };
105
- interface RoomConnectionState {
106
- connectionStatus: ConnectionStatus;
107
- chatMessages: ChatMessage[];
108
- cloudRecording?: CloudRecordingState;
109
- breakout: BreakoutState;
110
- events?: NotificationsEventEmitter;
111
- liveStream?: LiveStreamState;
112
- localScreenshareStatus?: LocalScreenshareStatus;
113
- localParticipant?: LocalParticipantState;
114
- remoteParticipants: RemoteParticipantState[];
115
- screenshares: Screenshare[];
116
- waitingParticipants: WaitingParticipantState[];
117
- spotlightedParticipants: ClientView[];
118
- }
119
48
  interface RoomConnectionOptions {
120
49
  displayName?: string;
121
50
  localMediaOptions?: LocalMediaOptions;
@@ -196,4 +125,4 @@ declare const ParticipantMenuItem: React.ForwardRefExoticComponent<Omit<React.De
196
125
  } & React.RefAttributes<HTMLButtonElement>>;
197
126
 
198
127
  export { GridCell, GridVideoView, ParticipantMenu, ParticipantMenuContent, ParticipantMenuItem, ParticipantMenuTrigger, Grid as VideoGrid, VideoView, Provider as WherebyProvider, useLocalMedia, useRoomConnection };
199
- export type { BreakoutState as Breakout, ChatMessageState as ChatMessage, CloudRecordingState as CloudRecording, LiveStreamState as LiveStreaming, LocalParticipantState as LocalParticipant, RemoteParticipantState as RemoteParticipant, RoomConnectionState as RoomConnection, RoomConnectionActions, RoomConnectionOptions, ScreenshareState as Screenshare, UseLocalMediaResult, WaitingParticipantState as WaitingParticipant };
128
+ export type { RoomConnectionActions, RoomConnectionOptions, UseLocalMediaResult };