@stream-io/video-react-sdk 1.7.26 → 1.7.28
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 +17 -0
- package/dist/index.cjs.js +17 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +17 -26
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.d.ts +3 -4
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.d.ts +3 -4
- package/dist/src/utilities/callControlHandler.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/DeviceSettings/DeviceSelectorAudio.tsx +11 -18
- package/src/components/DeviceSettings/DeviceSelectorVideo.tsx +11 -16
- package/src/hooks/usePersistedDevicePreferences.ts +6 -21
- package/src/utilities/callControlHandler.ts +4 -4
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export type DeviceSelectorAudioInputProps = PropsWithErrorHandler<{
|
|
1
|
+
export type DeviceSelectorAudioInputProps = {
|
|
3
2
|
title?: string;
|
|
4
3
|
visualType?: 'list' | 'dropdown';
|
|
5
|
-
}
|
|
6
|
-
export declare const DeviceSelectorAudioInput: (
|
|
4
|
+
};
|
|
5
|
+
export declare const DeviceSelectorAudioInput: ({ title, visualType, }: DeviceSelectorAudioInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
6
|
export type DeviceSelectorAudioOutputProps = {
|
|
8
7
|
title?: string;
|
|
9
8
|
visualType?: 'list' | 'dropdown';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export type DeviceSelectorVideoProps = PropsWithErrorHandler<{
|
|
1
|
+
export type DeviceSelectorVideoProps = {
|
|
3
2
|
title?: string;
|
|
4
3
|
visualType?: 'list' | 'dropdown';
|
|
5
|
-
}
|
|
6
|
-
export declare const DeviceSelectorVideo: (
|
|
4
|
+
};
|
|
5
|
+
export declare const DeviceSelectorVideo: ({ title, visualType, }: DeviceSelectorVideoProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,4 +13,4 @@ export type PropsWithErrorHandler<T = unknown> = T & {
|
|
|
13
13
|
* @param props component props, including the onError callback
|
|
14
14
|
* @param handler event handler to wrap
|
|
15
15
|
*/
|
|
16
|
-
export declare const createCallControlHandler:
|
|
16
|
+
export declare const createCallControlHandler: (props: PropsWithErrorHandler, handler: () => Promise<void>) => (() => Promise<void>);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-sdk",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.28",
|
|
4
4
|
"packageManager": "yarn@3.2.4",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@floating-ui/react": "^0.26.24",
|
|
35
|
-
"@stream-io/video-client": "1.11.
|
|
35
|
+
"@stream-io/video-client": "1.11.12",
|
|
36
36
|
"@stream-io/video-filters-web": "0.1.6",
|
|
37
|
-
"@stream-io/video-react-bindings": "1.2.
|
|
37
|
+
"@stream-io/video-react-bindings": "1.2.6",
|
|
38
38
|
"chart.js": "^4.4.4",
|
|
39
39
|
"clsx": "^2.0.0",
|
|
40
40
|
"react-chartjs-2": "^5.2.0"
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
import { useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
2
2
|
import { DeviceSelector } from './DeviceSelector';
|
|
3
|
-
import {
|
|
4
|
-
createCallControlHandler,
|
|
5
|
-
PropsWithErrorHandler,
|
|
6
|
-
} from '../../utilities/callControlHandler';
|
|
7
3
|
|
|
8
|
-
export type DeviceSelectorAudioInputProps =
|
|
4
|
+
export type DeviceSelectorAudioInputProps = {
|
|
9
5
|
title?: string;
|
|
10
6
|
visualType?: 'list' | 'dropdown';
|
|
11
|
-
}
|
|
7
|
+
};
|
|
12
8
|
|
|
13
|
-
export const DeviceSelectorAudioInput = (
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const DeviceSelectorAudioInput = ({
|
|
10
|
+
title,
|
|
11
|
+
visualType,
|
|
12
|
+
}: DeviceSelectorAudioInputProps) => {
|
|
16
13
|
const { useMicrophoneState } = useCallStateHooks();
|
|
17
14
|
const { microphone, selectedDevice, devices } = useMicrophoneState();
|
|
18
|
-
const handleChange = createCallControlHandler(
|
|
19
|
-
props,
|
|
20
|
-
async (deviceId: string) => {
|
|
21
|
-
await microphone.select(deviceId);
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
15
|
|
|
25
16
|
return (
|
|
26
17
|
<DeviceSelector
|
|
27
18
|
devices={devices || []}
|
|
28
19
|
selectedDeviceId={selectedDevice}
|
|
29
20
|
type="audioinput"
|
|
30
|
-
onChange={
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
onChange={async (deviceId) => {
|
|
22
|
+
await microphone.select(deviceId);
|
|
23
|
+
}}
|
|
24
|
+
title={title}
|
|
25
|
+
visualType={visualType}
|
|
33
26
|
icon="mic"
|
|
34
27
|
/>
|
|
35
28
|
);
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createCallControlHandler,
|
|
3
|
-
PropsWithErrorHandler,
|
|
4
|
-
} from '../../utilities/callControlHandler';
|
|
5
1
|
import { DeviceSelector } from './DeviceSelector';
|
|
6
2
|
import { useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
7
3
|
|
|
8
|
-
export type DeviceSelectorVideoProps =
|
|
4
|
+
export type DeviceSelectorVideoProps = {
|
|
9
5
|
title?: string;
|
|
10
6
|
visualType?: 'list' | 'dropdown';
|
|
11
|
-
}
|
|
7
|
+
};
|
|
12
8
|
|
|
13
|
-
export const DeviceSelectorVideo = (
|
|
9
|
+
export const DeviceSelectorVideo = ({
|
|
10
|
+
title,
|
|
11
|
+
visualType,
|
|
12
|
+
}: DeviceSelectorVideoProps) => {
|
|
14
13
|
const { useCameraState } = useCallStateHooks();
|
|
15
14
|
const { camera, devices, selectedDevice } = useCameraState();
|
|
16
|
-
const handleChange = createCallControlHandler(
|
|
17
|
-
props,
|
|
18
|
-
async (deviceId: string) => {
|
|
19
|
-
await camera.select(deviceId);
|
|
20
|
-
},
|
|
21
|
-
);
|
|
22
15
|
|
|
23
16
|
return (
|
|
24
17
|
<DeviceSelector
|
|
25
18
|
devices={devices || []}
|
|
26
19
|
type="videoinput"
|
|
27
20
|
selectedDeviceId={selectedDevice}
|
|
28
|
-
onChange={
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
onChange={async (deviceId) => {
|
|
22
|
+
await camera.select(deviceId);
|
|
23
|
+
}}
|
|
24
|
+
title={title}
|
|
25
|
+
visualType={visualType}
|
|
31
26
|
icon="camera"
|
|
32
27
|
/>
|
|
33
28
|
);
|
|
@@ -68,14 +68,8 @@ const usePersistDevicePreferences = (
|
|
|
68
68
|
*
|
|
69
69
|
* @param key the key to use for local storage.
|
|
70
70
|
*/
|
|
71
|
-
const useApplyDevicePreferences = (
|
|
72
|
-
key: string,
|
|
73
|
-
onWillApply: () => void,
|
|
74
|
-
onApplied: () => void,
|
|
75
|
-
) => {
|
|
71
|
+
const useApplyDevicePreferences = (key: string, onApplied: () => void) => {
|
|
76
72
|
const call = useCall();
|
|
77
|
-
const onWillApplyRef = useRef(onWillApply);
|
|
78
|
-
onWillApplyRef.current = onWillApply;
|
|
79
73
|
const onAppliedRef = useRef(onApplied);
|
|
80
74
|
onAppliedRef.current = onApplied;
|
|
81
75
|
useEffect(() => {
|
|
@@ -121,22 +115,17 @@ const useApplyDevicePreferences = (
|
|
|
121
115
|
console.warn('Failed to load device preferences', err);
|
|
122
116
|
}
|
|
123
117
|
if (preferences) {
|
|
124
|
-
await initMic(preferences.mic)
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
await initCamera(preferences.camera).catch((err) => {
|
|
128
|
-
console.warn('Failed to apply camera preferences', err);
|
|
129
|
-
});
|
|
118
|
+
await initMic(preferences.mic);
|
|
119
|
+
await initCamera(preferences.camera);
|
|
130
120
|
initSpeaker(preferences.speaker);
|
|
131
121
|
}
|
|
132
122
|
};
|
|
133
123
|
|
|
134
|
-
onWillApplyRef.current();
|
|
135
124
|
apply()
|
|
125
|
+
.then(() => onAppliedRef.current())
|
|
136
126
|
.catch((err) => {
|
|
137
127
|
console.warn('Failed to apply device preferences', err);
|
|
138
|
-
})
|
|
139
|
-
.then(() => onAppliedRef.current());
|
|
128
|
+
});
|
|
140
129
|
|
|
141
130
|
return () => {
|
|
142
131
|
cancel = true;
|
|
@@ -153,11 +142,7 @@ export const usePersistedDevicePreferences = (
|
|
|
153
142
|
key: string = '@stream-io/device-preferences',
|
|
154
143
|
) => {
|
|
155
144
|
const shouldPersistRef = useRef(false);
|
|
156
|
-
useApplyDevicePreferences(
|
|
157
|
-
key,
|
|
158
|
-
() => (shouldPersistRef.current = false),
|
|
159
|
-
() => (shouldPersistRef.current = true),
|
|
160
|
-
);
|
|
145
|
+
useApplyDevicePreferences(key, () => (shouldPersistRef.current = true));
|
|
161
146
|
usePersistDevicePreferences(key, shouldPersistRef);
|
|
162
147
|
};
|
|
163
148
|
|
|
@@ -16,15 +16,15 @@ export type PropsWithErrorHandler<T = unknown> = T & {
|
|
|
16
16
|
* @param props component props, including the onError callback
|
|
17
17
|
* @param handler event handler to wrap
|
|
18
18
|
*/
|
|
19
|
-
export const createCallControlHandler =
|
|
19
|
+
export const createCallControlHandler = (
|
|
20
20
|
props: PropsWithErrorHandler,
|
|
21
|
-
handler: (
|
|
21
|
+
handler: () => Promise<void>,
|
|
22
22
|
): (() => Promise<void>) => {
|
|
23
23
|
const logger = getLogger(['react-sdk']);
|
|
24
24
|
|
|
25
|
-
return async (
|
|
25
|
+
return async () => {
|
|
26
26
|
try {
|
|
27
|
-
await handler(
|
|
27
|
+
await handler();
|
|
28
28
|
} catch (error) {
|
|
29
29
|
if (props.onError) {
|
|
30
30
|
props.onError(error);
|