@stream-io/video-react-sdk 0.4.2 → 0.4.4
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 +18 -0
- package/dist/index.cjs.js +35 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +35 -16
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -5
- package/src/components/CallControls/ScreenShareButton.tsx +8 -3
- package/src/components/VideoPreview/VideoPreview.tsx +10 -2
- package/src/hooks/usePersistedDevicePreferences.ts +28 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.4.4](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.4.3...@stream-io/video-react-sdk-0.4.4) (2023-11-01)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `@stream-io/video-client` updated to version `0.4.2`
|
|
10
|
+
* `@stream-io/video-react-bindings` updated to version `0.3.2`
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* respect server-side settings in the lobby ([#1175](https://github.com/GetStream/stream-video-js/issues/1175)) ([b722a0a](https://github.com/GetStream/stream-video-js/commit/b722a0a4f8fd4e4e56787db3d9a56e45ee195974))
|
|
15
|
+
|
|
16
|
+
### [0.4.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.4.2...@stream-io/video-react-sdk-0.4.3) (2023-10-30)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* add marker classes for the default `VideoPreview` components ([#1172](https://github.com/GetStream/stream-video-js/issues/1172)) ([7948cd8](https://github.com/GetStream/stream-video-js/commit/7948cd81a5ad6271872239a77b2a5ab8a856d231))
|
|
22
|
+
|
|
5
23
|
### [0.4.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.4.1...@stream-io/video-react-sdk-0.4.2) (2023-10-30)
|
|
6
24
|
|
|
7
25
|
### Dependency Updates
|
package/dist/index.cjs.js
CHANGED
|
@@ -252,21 +252,26 @@ const useFloatingUIPreset = ({ placement, strategy, }) => {
|
|
|
252
252
|
* @param key the key to use for local storage.
|
|
253
253
|
*/
|
|
254
254
|
const usePersistDevicePreferences = (key) => {
|
|
255
|
-
const { useMicrophoneState, useCameraState, useSpeakerState } = videoReactBindings.useCallStateHooks();
|
|
255
|
+
const { useMicrophoneState, useCameraState, useSpeakerState, useCallSettings, } = videoReactBindings.useCallStateHooks();
|
|
256
256
|
const mic = useMicrophoneState();
|
|
257
257
|
const camera = useCameraState();
|
|
258
258
|
const speaker = useSpeakerState();
|
|
259
|
+
const settings = useCallSettings();
|
|
259
260
|
react.useEffect(() => {
|
|
261
|
+
if (!settings)
|
|
262
|
+
return;
|
|
260
263
|
try {
|
|
264
|
+
const hasPreferences = !!window.localStorage.getItem(key);
|
|
265
|
+
const { audio, video } = settings;
|
|
261
266
|
const defaultDevice = 'default';
|
|
262
267
|
const preferences = {
|
|
263
268
|
mic: {
|
|
264
269
|
selectedDeviceId: mic.selectedDevice || defaultDevice,
|
|
265
|
-
muted: mic.isMute,
|
|
270
|
+
muted: hasPreferences ? mic.isMute : !audio.mic_default_on,
|
|
266
271
|
},
|
|
267
272
|
camera: {
|
|
268
273
|
selectedDeviceId: camera.selectedDevice || defaultDevice,
|
|
269
|
-
muted: camera.isMute,
|
|
274
|
+
muted: hasPreferences ? camera.isMute : !video.camera_default_on,
|
|
270
275
|
},
|
|
271
276
|
speaker: {
|
|
272
277
|
selectedDeviceId: speaker.selectedDevice || defaultDevice,
|
|
@@ -284,6 +289,7 @@ const usePersistDevicePreferences = (key) => {
|
|
|
284
289
|
key,
|
|
285
290
|
mic.isMute,
|
|
286
291
|
mic.selectedDevice,
|
|
292
|
+
settings,
|
|
287
293
|
speaker.selectedDevice,
|
|
288
294
|
]);
|
|
289
295
|
};
|
|
@@ -294,8 +300,10 @@ const usePersistDevicePreferences = (key) => {
|
|
|
294
300
|
*/
|
|
295
301
|
const useApplyDevicePreferences = (key) => {
|
|
296
302
|
const call = videoReactBindings.useCall();
|
|
303
|
+
const { useCallSettings } = videoReactBindings.useCallStateHooks();
|
|
304
|
+
const settings = useCallSettings();
|
|
297
305
|
react.useEffect(() => {
|
|
298
|
-
if (!call)
|
|
306
|
+
if (!call || !settings)
|
|
299
307
|
return;
|
|
300
308
|
const apply = async () => {
|
|
301
309
|
const initMic = async (setting) => {
|
|
@@ -319,22 +327,30 @@ const useApplyDevicePreferences = (key) => {
|
|
|
319
327
|
const initSpeaker = (setting) => {
|
|
320
328
|
call.speaker.select(setting.selectedDeviceId);
|
|
321
329
|
};
|
|
330
|
+
let preferences = null;
|
|
322
331
|
try {
|
|
323
|
-
|
|
324
|
-
if (preferences) {
|
|
325
|
-
await initMic(preferences.mic);
|
|
326
|
-
await initCamera(preferences.camera);
|
|
327
|
-
initSpeaker(preferences.speaker);
|
|
328
|
-
}
|
|
332
|
+
preferences = JSON.parse(window.localStorage.getItem(key));
|
|
329
333
|
}
|
|
330
334
|
catch (err) {
|
|
331
335
|
console.warn('Failed to load device preferences', err);
|
|
332
336
|
}
|
|
337
|
+
if (preferences) {
|
|
338
|
+
await initMic(preferences.mic);
|
|
339
|
+
await initCamera(preferences.camera);
|
|
340
|
+
initSpeaker(preferences.speaker);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
const { audio, video } = settings;
|
|
344
|
+
if (audio.mic_default_on)
|
|
345
|
+
await call.microphone.enable();
|
|
346
|
+
if (video.camera_default_on)
|
|
347
|
+
await call.camera.enable();
|
|
348
|
+
}
|
|
333
349
|
};
|
|
334
350
|
apply().catch((err) => {
|
|
335
351
|
console.warn('Failed to apply device preferences', err);
|
|
336
352
|
});
|
|
337
|
-
}, [call, key]);
|
|
353
|
+
}, [call, key, settings]);
|
|
338
354
|
};
|
|
339
355
|
/**
|
|
340
356
|
* This hook will apply and persist the device preferences from local storage.
|
|
@@ -816,8 +832,11 @@ const ScreenShareButton = (props) => {
|
|
|
816
832
|
const { useHasOngoingScreenShare, useScreenShareState } = videoReactBindings.useCallStateHooks();
|
|
817
833
|
const isSomeoneScreenSharing = useHasOngoingScreenShare();
|
|
818
834
|
const { hasPermission, requestPermission, isAwaitingPermission } = useRequestPermission(videoClient.OwnCapability.SCREENSHARE);
|
|
819
|
-
const { screenShare, isMute:
|
|
820
|
-
|
|
835
|
+
const { screenShare, isMute: amIScreenSharing } = useScreenShareState();
|
|
836
|
+
const disableScreenShareButton = amIScreenSharing
|
|
837
|
+
? isSomeoneScreenSharing
|
|
838
|
+
: false;
|
|
839
|
+
return (jsxRuntime.jsx(videoReactBindings.Restricted, { requiredGrants: [videoClient.OwnCapability.SCREENSHARE], children: jsxRuntime.jsx(PermissionNotification, { permission: videoClient.OwnCapability.SCREENSHARE, isAwaitingApproval: isAwaitingPermission, messageApproved: t('You can now share your screen.'), messageAwaitingApproval: t('Awaiting for an approval to share screen.'), messageRevoked: t('You can no longer share your screen.'), children: jsxRuntime.jsx(CompositeButton, { active: isSomeoneScreenSharing, caption: caption, children: jsxRuntime.jsx(IconButton, { icon: isSomeoneScreenSharing ? 'screen-share-on' : 'screen-share-off', title: t('Share screen'), disabled: disableScreenShareButton, onClick: async () => {
|
|
821
840
|
if (!hasPermission) {
|
|
822
841
|
await requestPermission();
|
|
823
842
|
}
|
|
@@ -1482,11 +1501,11 @@ const StreamTheme = ({ as: Component = 'div', className, children, ...props }) =
|
|
|
1482
1501
|
|
|
1483
1502
|
const DefaultDisabledVideoPreview = () => {
|
|
1484
1503
|
const { t } = videoReactBindings.useI18n();
|
|
1485
|
-
return jsxRuntime.jsx("div", { children: t('Video is disabled') });
|
|
1504
|
+
return (jsxRuntime.jsx("div", { className: "str_video__video-preview__disabled-video-preview", children: t('Video is disabled') }));
|
|
1486
1505
|
};
|
|
1487
1506
|
const DefaultNoCameraPreview = () => {
|
|
1488
1507
|
const { t } = videoReactBindings.useI18n();
|
|
1489
|
-
return jsxRuntime.jsx("div", { children: t('No camera found') });
|
|
1508
|
+
return (jsxRuntime.jsx("div", { className: "str_video__video-preview__no-camera-preview", children: t('No camera found') }));
|
|
1490
1509
|
};
|
|
1491
1510
|
const VideoPreview = ({ className, mirror = true, DisabledVideoPreview = DefaultDisabledVideoPreview, NoCameraPreview = DefaultNoCameraPreview, StartingCameraPreview = LoadingIndicator, }) => {
|
|
1492
1511
|
const { useCameraState } = videoReactBindings.useCallStateHooks();
|
|
@@ -2097,7 +2116,7 @@ const VerticalScrollButtons = ({ scrollWrapper, }) => {
|
|
|
2097
2116
|
};
|
|
2098
2117
|
const hasScreenShare = (p) => !!p?.publishedTracks.includes(videoClient.SfuModels.TrackType.SCREEN_SHARE);
|
|
2099
2118
|
|
|
2100
|
-
const [major, minor, patch] = ("0.4.
|
|
2119
|
+
const [major, minor, patch] = ("0.4.4" ).split('.');
|
|
2101
2120
|
videoClient.setSdkInfo({
|
|
2102
2121
|
type: videoClient.SfuModels.SdkType.REACT,
|
|
2103
2122
|
major,
|