@whereby.com/browser-sdk 3.2.1 → 3.2.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.
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Provider as Provider$1, useDispatch, useSelector } from 'react-redux';
3
- import { createServices, createStore, selectCurrentSpeakerDeviceId, debounce, doRtcReportStreamResolution, selectChatMessages, selectCloudRecordingRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, doAppStop, doSendChatMessage, doKnockRoom, doSetDisplayName, toggleCameraEnabled, toggleMicrophoneEnabled, toggleLowDataModeEnabled, doSetLocalStickyReaction, doRequestAudioEnable, doAcceptWaitingParticipant, doRejectWaitingParticipant, doStartCloudRecording, doStartScreenshare, doStopCloudRecording, doStopScreenshare, doAppStart, doLockRoom, doSpotlightParticipant, doRemoveSpotlight, doKickParticipant, doEndMeeting, selectCameraDeviceError, selectCameraDevices, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsLocalMediaStarting, selectMicrophoneDeviceError, selectMicrophoneDevices, selectSpeakerDevices, selectLocalMediaStartError, doStartLocalMedia, doStopLocalMedia, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, selectAllClientViews, selectNumParticipants } from '@whereby.com/core';
3
+ import { createServices, createStore, selectCurrentSpeakerDeviceId, debounce, doRtcReportStreamResolution, selectChatMessages, selectCloudRecordingRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, doAppStop, doSendChatMessage, doKnockRoom, toggleCameraEnabled, toggleMicrophoneEnabled, toggleLowDataModeEnabled, doSetLocalStickyReaction, doRequestAudioEnable, doAcceptWaitingParticipant, doRejectWaitingParticipant, doStartCloudRecording, doStartScreenshare, doStopCloudRecording, doStopScreenshare, doAppStart, doLockRoom, doSpotlightParticipant, doRemoveSpotlight, doKickParticipant, doEndMeeting, doSetDisplayName, selectCameraDeviceError, selectCameraDevices, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsLocalMediaStarting, selectMicrophoneDeviceError, selectMicrophoneDevices, selectSpeakerDevices, selectLocalMediaStartError, doStartLocalMedia, doStopLocalMedia, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, selectAllClientViews, selectNumParticipants } from '@whereby.com/core';
4
4
  import { createSelector } from '@reduxjs/toolkit';
5
5
  import runes from 'runes';
6
6
  import * as PopoverPrimitive from '@radix-ui/react-popover';
@@ -146,7 +146,7 @@ const selectRoomConnectionState = createSelector(selectChatMessages, selectCloud
146
146
  return state;
147
147
  });
148
148
 
149
- const browserSdkVersion = "3.2.1";
149
+ const browserSdkVersion = "3.2.2";
150
150
 
151
151
  const defaultRoomConnectionOptions = {
152
152
  localMediaOptions: {
@@ -175,30 +175,36 @@ function useRoomConnection(roomUrl, roomConnectionOptions = defaultRoomConnectio
175
175
  dispatch(doAppStop());
176
176
  };
177
177
  }, []);
178
- const sendChatMessage = React.useCallback((text) => dispatch(doSendChatMessage({ text })), [dispatch]);
178
+ const whenConnectedToRoom = React.useCallback((actionCreator) => {
179
+ if (roomConnectionState.connectionStatus === "connected") {
180
+ dispatch(actionCreator());
181
+ }
182
+ else {
183
+ console.warn("Action cannot be performed outside of a connected room");
184
+ }
185
+ }, [roomConnectionState.connectionStatus, dispatch]);
186
+ const sendChatMessage = React.useCallback((text) => whenConnectedToRoom(() => doSendChatMessage({ text })), [whenConnectedToRoom]);
179
187
  const knock = React.useCallback(() => dispatch(doKnockRoom()), [dispatch]);
180
- const setDisplayName = React.useCallback((displayName) => dispatch(doSetDisplayName({ displayName })), [dispatch]);
181
- const toggleCamera = React.useCallback((enabled) => dispatch(toggleCameraEnabled({ enabled })), [dispatch]);
182
- const toggleMicrophone = React.useCallback((enabled) => dispatch(toggleMicrophoneEnabled({ enabled })), [dispatch]);
183
- const toggleLowDataMode = React.useCallback((enabled) => dispatch(toggleLowDataModeEnabled({ enabled })), [dispatch]);
184
- const toggleRaiseHand = React.useCallback((enabled) => dispatch(doSetLocalStickyReaction({ enabled })), [dispatch]);
185
- const askToSpeak = React.useCallback((participantId) => dispatch(doRequestAudioEnable({ clientIds: [participantId], enable: true })), [dispatch]);
186
- const acceptWaitingParticipant = React.useCallback((participantId) => dispatch(doAcceptWaitingParticipant({ participantId })), [dispatch]);
187
- const rejectWaitingParticipant = React.useCallback((participantId) => dispatch(doRejectWaitingParticipant({ participantId })), [dispatch]);
188
- const startCloudRecording = React.useCallback(() => dispatch(doStartCloudRecording()), [dispatch]);
189
- const startScreenshare = React.useCallback(() => dispatch(doStartScreenshare()), [dispatch]);
190
- const stopCloudRecording = React.useCallback(() => dispatch(doStopCloudRecording()), [dispatch]);
191
- const stopScreenshare = React.useCallback(() => dispatch(doStopScreenshare()), [dispatch]);
188
+ const setDisplayName = (displayName) => whenConnectedToRoom(() => doSetDisplayName({ displayName }));
189
+ const toggleCamera = React.useCallback((enabled) => whenConnectedToRoom(() => toggleCameraEnabled({ enabled })), [whenConnectedToRoom]);
190
+ const toggleMicrophone = React.useCallback((enabled) => whenConnectedToRoom(() => toggleMicrophoneEnabled({ enabled })), [whenConnectedToRoom]);
191
+ const toggleLowDataMode = React.useCallback((enabled) => whenConnectedToRoom(() => toggleLowDataModeEnabled({ enabled })), [whenConnectedToRoom]);
192
+ const toggleRaiseHand = React.useCallback((enabled) => whenConnectedToRoom(() => doSetLocalStickyReaction({ enabled })), [whenConnectedToRoom]);
193
+ const askToSpeak = React.useCallback((participantId) => whenConnectedToRoom(() => doRequestAudioEnable({ clientIds: [participantId], enable: true })), [whenConnectedToRoom]);
194
+ const acceptWaitingParticipant = React.useCallback((participantId) => whenConnectedToRoom(() => doAcceptWaitingParticipant({ participantId })), [whenConnectedToRoom]);
195
+ const rejectWaitingParticipant = React.useCallback((participantId) => whenConnectedToRoom(() => doRejectWaitingParticipant({ participantId })), [whenConnectedToRoom]);
196
+ const startCloudRecording = React.useCallback(() => whenConnectedToRoom(() => doStartCloudRecording()), [whenConnectedToRoom]);
197
+ const startScreenshare = React.useCallback(() => whenConnectedToRoom(() => doStartScreenshare()), [whenConnectedToRoom]);
198
+ const stopCloudRecording = React.useCallback(() => whenConnectedToRoom(() => doStopCloudRecording()), [whenConnectedToRoom]);
199
+ const stopScreenshare = React.useCallback(() => whenConnectedToRoom(() => doStopScreenshare()), [whenConnectedToRoom]);
192
200
  const joinRoom = React.useCallback(() => dispatch(doAppStart(roomConfig)), [dispatch]);
193
- const leaveRoom = React.useCallback(() => dispatch(doAppStop()), [dispatch]);
194
- const lockRoom = React.useCallback((locked) => dispatch(doLockRoom({ locked })), [dispatch]);
195
- const muteParticipants = React.useCallback((participantIds) => {
196
- dispatch(doRequestAudioEnable({ clientIds: participantIds, enable: false }));
197
- }, [dispatch]);
198
- const spotlightParticipant = React.useCallback((participantId) => dispatch(doSpotlightParticipant({ id: participantId })), [dispatch]);
199
- const removeSpotlight = React.useCallback((participantId) => dispatch(doRemoveSpotlight({ id: participantId })), [dispatch]);
200
- const kickParticipant = React.useCallback((participantId) => dispatch(doKickParticipant({ clientId: participantId })), [dispatch]);
201
- const endMeeting = React.useCallback((stayBehind) => dispatch(doEndMeeting({ stayBehind })), [dispatch]);
201
+ const leaveRoom = React.useCallback(() => whenConnectedToRoom(() => doAppStop()), [whenConnectedToRoom]);
202
+ const lockRoom = React.useCallback((locked) => whenConnectedToRoom(() => doLockRoom({ locked })), [whenConnectedToRoom]);
203
+ const muteParticipants = React.useCallback((participantIds) => whenConnectedToRoom(() => doRequestAudioEnable({ clientIds: participantIds, enable: false })), [whenConnectedToRoom]);
204
+ const spotlightParticipant = React.useCallback((participantId) => whenConnectedToRoom(() => doSpotlightParticipant({ id: participantId })), [whenConnectedToRoom]);
205
+ const removeSpotlight = React.useCallback((participantId) => whenConnectedToRoom(() => doRemoveSpotlight({ id: participantId })), [whenConnectedToRoom]);
206
+ const kickParticipant = React.useCallback((participantId) => whenConnectedToRoom(() => doKickParticipant({ clientId: participantId })), [whenConnectedToRoom]);
207
+ const endMeeting = React.useCallback((stayBehind) => whenConnectedToRoom(() => doEndMeeting({ stayBehind })), [whenConnectedToRoom]);
202
208
  const { events } = roomConnectionState, state = __rest(roomConnectionState, ["events"]);
203
209
  return {
204
210
  state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whereby.com/browser-sdk",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Modules for integration Whereby video in web apps",
5
5
  "author": "Whereby AS",
6
6
  "license": "MIT",