@stream-io/video-react-sdk 1.0.6 → 1.0.8

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 (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/css/styles.css +3 -3
  3. package/dist/index.cjs.js +173 -123
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.es.js +174 -124
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/components/Button/CompositeButton.d.ts +1 -0
  8. package/dist/src/components/CallControls/CancelCallButton.d.ts +2 -1
  9. package/dist/src/components/CallControls/ScreenShareButton.d.ts +3 -2
  10. package/dist/src/components/CallControls/ToggleAudioButton.d.ts +3 -2
  11. package/dist/src/components/CallControls/ToggleVideoButton.d.ts +3 -2
  12. package/dist/src/components/Menu/MenuToggle.d.ts +2 -1
  13. package/dist/src/components/Tooltip/WithTooltip.d.ts +4 -2
  14. package/dist/src/utilities/callControlHandler.d.ts +16 -0
  15. package/package.json +4 -4
  16. package/src/components/Button/CompositeButton.tsx +3 -0
  17. package/src/components/CallControls/CallControls.tsx +3 -3
  18. package/src/components/CallControls/CancelCallButton.tsx +12 -8
  19. package/src/components/CallControls/ReactionsButton.tsx +14 -9
  20. package/src/components/CallControls/RecordCallButton.tsx +21 -15
  21. package/src/components/CallControls/ScreenShareButton.tsx +34 -26
  22. package/src/components/CallControls/ToggleAudioButton.tsx +84 -56
  23. package/src/components/CallControls/ToggleVideoButton.tsx +87 -59
  24. package/src/components/CallParticipantsList/CallParticipantListingItem.tsx +10 -9
  25. package/src/components/DeviceSettings/DeviceSelector.tsx +4 -0
  26. package/src/components/Menu/MenuToggle.tsx +9 -0
  27. package/src/components/Tooltip/WithTooltip.tsx +7 -2
  28. package/src/core/components/Audio/ParticipantsAudio.tsx +10 -13
  29. package/src/core/components/CallLayout/LivestreamLayout.tsx +5 -7
  30. package/src/core/components/CallLayout/SpeakerLayout.tsx +3 -5
  31. package/src/core/components/ParticipantView/DefaultParticipantViewUI.tsx +12 -12
  32. package/src/core/components/ParticipantView/ParticipantActionsContextMenu.tsx +16 -14
  33. package/src/core/components/ParticipantView/ParticipantView.tsx +12 -17
  34. package/src/core/components/Video/Video.tsx +4 -4
  35. package/src/utilities/callControlHandler.ts +43 -0
@@ -0,0 +1,43 @@
1
+ import { getLogger } from '@stream-io/video-client';
2
+
3
+ export type PropsWithErrorHandler<T = unknown> = T & {
4
+ /**
5
+ * Will be called if the call control action failed with an error (e.g. user didn't grant a
6
+ * browser permission to enable a media device). If no callback is provided, just logs the error.
7
+ * @param error Exception which caused call control action to fail
8
+ */
9
+ onError?: (error: unknown) => void;
10
+ };
11
+
12
+ /**
13
+ * Wraps an event handler, silencing and logging exceptions (excluding the NotAllowedError
14
+ * DOMException, which is a normal situation handled by the SDK)
15
+ *
16
+ * @param props component props, including the onError callback
17
+ * @param handler event handler to wrap
18
+ */
19
+ export const createCallControlHandler = (
20
+ props: PropsWithErrorHandler,
21
+ handler: () => Promise<void>,
22
+ ): (() => Promise<void>) => {
23
+ const logger = getLogger(['react-sdk']);
24
+
25
+ return async () => {
26
+ try {
27
+ await handler();
28
+ } catch (error) {
29
+ if (props.onError) {
30
+ props.onError(error);
31
+ return;
32
+ }
33
+
34
+ if (!isNotAllowedError(error)) {
35
+ logger('error', 'Call control handler failed', error);
36
+ }
37
+ }
38
+ };
39
+ };
40
+
41
+ function isNotAllowedError(error: unknown): error is DOMException {
42
+ return error instanceof DOMException && error.name === 'NotAllowedError';
43
+ }