@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.
- package/CHANGELOG.md +21 -0
- package/dist/css/styles.css +3 -3
- package/dist/index.cjs.js +173 -123
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +174 -124
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/Button/CompositeButton.d.ts +1 -0
- package/dist/src/components/CallControls/CancelCallButton.d.ts +2 -1
- package/dist/src/components/CallControls/ScreenShareButton.d.ts +3 -2
- package/dist/src/components/CallControls/ToggleAudioButton.d.ts +3 -2
- package/dist/src/components/CallControls/ToggleVideoButton.d.ts +3 -2
- package/dist/src/components/Menu/MenuToggle.d.ts +2 -1
- package/dist/src/components/Tooltip/WithTooltip.d.ts +4 -2
- package/dist/src/utilities/callControlHandler.d.ts +16 -0
- package/package.json +4 -4
- package/src/components/Button/CompositeButton.tsx +3 -0
- package/src/components/CallControls/CallControls.tsx +3 -3
- package/src/components/CallControls/CancelCallButton.tsx +12 -8
- package/src/components/CallControls/ReactionsButton.tsx +14 -9
- package/src/components/CallControls/RecordCallButton.tsx +21 -15
- package/src/components/CallControls/ScreenShareButton.tsx +34 -26
- package/src/components/CallControls/ToggleAudioButton.tsx +84 -56
- package/src/components/CallControls/ToggleVideoButton.tsx +87 -59
- package/src/components/CallParticipantsList/CallParticipantListingItem.tsx +10 -9
- package/src/components/DeviceSettings/DeviceSelector.tsx +4 -0
- package/src/components/Menu/MenuToggle.tsx +9 -0
- package/src/components/Tooltip/WithTooltip.tsx +7 -2
- package/src/core/components/Audio/ParticipantsAudio.tsx +10 -13
- package/src/core/components/CallLayout/LivestreamLayout.tsx +5 -7
- package/src/core/components/CallLayout/SpeakerLayout.tsx +3 -5
- package/src/core/components/ParticipantView/DefaultParticipantViewUI.tsx +12 -12
- package/src/core/components/ParticipantView/ParticipantActionsContextMenu.tsx +16 -14
- package/src/core/components/ParticipantView/ParticipantView.tsx +12 -17
- package/src/core/components/Video/Video.tsx +4 -4
- 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
|
+
}
|