@stream-io/video-react-native-sdk 1.29.4 → 1.30.0

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 (73) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/commonjs/components/Call/CallContent/CallContent.js +13 -7
  3. package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
  4. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +50 -14
  5. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  6. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +27 -0
  7. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  8. package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js +19 -10
  9. package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
  10. package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js +12 -9
  11. package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
  12. package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js +19 -4
  13. package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
  14. package/dist/commonjs/utils/hooks/index.js +0 -11
  15. package/dist/commonjs/utils/hooks/index.js.map +1 -1
  16. package/dist/commonjs/version.js +1 -1
  17. package/dist/module/components/Call/CallContent/CallContent.js +10 -4
  18. package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
  19. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +52 -16
  20. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  21. package/dist/module/components/Call/CallContent/RTCViewPipNative.js +27 -0
  22. package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  23. package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js +19 -10
  24. package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
  25. package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js +15 -12
  26. package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
  27. package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js +20 -5
  28. package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
  29. package/dist/module/utils/hooks/index.js +0 -1
  30. package/dist/module/utils/hooks/index.js.map +1 -1
  31. package/dist/module/version.js +1 -1
  32. package/dist/typescript/components/Call/CallContent/CallContent.d.ts.map +1 -1
  33. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
  34. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +18 -0
  35. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
  36. package/dist/typescript/components/Call/CallLayout/CallParticipantsGrid.d.ts.map +1 -1
  37. package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts.map +1 -1
  38. package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts.map +1 -1
  39. package/dist/typescript/utils/hooks/index.d.ts +0 -1
  40. package/dist/typescript/utils/hooks/index.d.ts.map +1 -1
  41. package/dist/typescript/version.d.ts +1 -1
  42. package/ios/PictureInPicture/PictureInPictureAvatarView.swift +273 -0
  43. package/ios/PictureInPicture/PictureInPictureConnectionQualityIndicator.swift +162 -0
  44. package/ios/PictureInPicture/PictureInPictureContent.swift +173 -0
  45. package/ios/PictureInPicture/PictureInPictureContentState.swift +123 -0
  46. package/ios/PictureInPicture/PictureInPictureDelegateProxy.swift +89 -0
  47. package/ios/PictureInPicture/PictureInPictureEnforcedStopAdapter.swift +166 -0
  48. package/ios/PictureInPicture/PictureInPictureLogger.swift +16 -0
  49. package/ios/PictureInPicture/PictureInPictureParticipantOverlayView.swift +217 -0
  50. package/ios/PictureInPicture/PictureInPictureReconnectionView.swift +193 -0
  51. package/ios/PictureInPicture/StreamAVPictureInPictureVideoCallViewController.swift +125 -7
  52. package/ios/PictureInPicture/StreamPictureInPictureController.swift +237 -63
  53. package/ios/PictureInPicture/StreamPictureInPictureControllerProtocol.swift +30 -0
  54. package/ios/PictureInPicture/StreamPictureInPictureVideoRenderer.swift +384 -12
  55. package/ios/RTCViewPip.swift +187 -21
  56. package/ios/RTCViewPipManager.mm +9 -0
  57. package/ios/RTCViewPipManager.swift +3 -3
  58. package/package.json +3 -3
  59. package/src/components/Call/CallContent/CallContent.tsx +16 -8
  60. package/src/components/Call/CallContent/RTCViewPipIOS.tsx +81 -15
  61. package/src/components/Call/CallContent/RTCViewPipNative.tsx +36 -0
  62. package/src/components/Call/CallLayout/CallParticipantsGrid.tsx +28 -14
  63. package/src/components/Call/CallLayout/CallParticipantsSpotlight.tsx +19 -10
  64. package/src/components/Call/CallParticipantsList/CallParticipantsList.tsx +20 -5
  65. package/src/utils/hooks/index.ts +0 -1
  66. package/src/version.ts +1 -1
  67. package/dist/commonjs/utils/hooks/useDebouncedValue.js +0 -24
  68. package/dist/commonjs/utils/hooks/useDebouncedValue.js.map +0 -1
  69. package/dist/module/utils/hooks/useDebouncedValue.js +0 -19
  70. package/dist/module/utils/hooks/useDebouncedValue.js.map +0 -1
  71. package/dist/typescript/utils/hooks/useDebouncedValue.d.ts +0 -8
  72. package/dist/typescript/utils/hooks/useDebouncedValue.d.ts.map +0 -1
  73. package/src/utils/hooks/useDebouncedValue.ts +0 -21
@@ -1,11 +1,11 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
3
  hasScreenShare,
4
- speakerLayoutSortPreset,
4
+ type StreamVideoParticipant,
5
5
  } from '@stream-io/video-client';
6
- import { useCallStateHooks } from '@stream-io/video-react-bindings';
6
+ import { useCall } from '@stream-io/video-react-bindings';
7
7
  import { StyleSheet, View, type ViewStyle } from 'react-native';
8
- import { useDebouncedValue } from '../../../utils/hooks/useDebouncedValue';
8
+ import { debounceTime } from 'rxjs';
9
9
  import { ComponentTestIds } from '../../../constants/TestIds';
10
10
  import {
11
11
  CallParticipantsList as DefaultCallParticipantsList,
@@ -56,15 +56,24 @@ export const CallParticipantsSpotlight = ({
56
56
  theme: { callParticipantsSpotlight, variants },
57
57
  } = useTheme();
58
58
  const styles = useStyles();
59
- const { useParticipants } = useCallStateHooks();
60
- const _allParticipants = useParticipants({
61
- sortBy: speakerLayoutSortPreset,
62
- });
63
- const allParticipants = useDebouncedValue(_allParticipants, 300); // we debounce the participants to avoid unnecessary rerenders that happen when participant tracks are all subscribed simultaneously
59
+ const call = useCall();
60
+ const [allParticipants, setAllParticipants] = useState<
61
+ StreamVideoParticipant[]
62
+ >(() => call?.state.participants ?? []);
63
+ useEffect(() => {
64
+ if (!call) {
65
+ setAllParticipants([]);
66
+ return;
67
+ }
68
+ const sub = call.state.participants$
69
+ .pipe(debounceTime(300))
70
+ .subscribe(setAllParticipants);
71
+ return () => sub.unsubscribe();
72
+ }, [call]);
64
73
  const [participantInSpotlight, ...otherParticipants] = allParticipants;
65
74
  const isScreenShareOnSpotlight =
66
75
  participantInSpotlight && hasScreenShare(participantInSpotlight);
67
- const isUserAloneInCall = _allParticipants?.length === 1;
76
+ const isUserAloneInCall = allParticipants.length === 1;
68
77
 
69
78
  const isInPiP = useIsInPiPMode();
70
79
 
@@ -1,7 +1,7 @@
1
1
  import React, {
2
2
  useCallback,
3
+ useEffect,
3
4
  useMemo,
4
- useReducer,
5
5
  useRef,
6
6
  useState,
7
7
  } from 'react';
@@ -17,7 +17,7 @@ import {
17
17
  type StreamVideoParticipantPatches,
18
18
  VisibilityState,
19
19
  } from '@stream-io/video-client';
20
- import { useDebouncedValue } from '../../../utils/hooks/useDebouncedValue';
20
+ import { Subject, debounceTime } from 'rxjs';
21
21
  import { useCall } from '@stream-io/video-react-bindings';
22
22
  import { ComponentTestIds } from '../../../constants/TestIds';
23
23
  import {
@@ -104,9 +104,24 @@ export const CallParticipantsList = ({
104
104
  // we use a HashSet to track the currently viewable participants
105
105
  // and a separate force update state to rerender the component to inform that the HashSet has changed
106
106
  // NOTE: we use set instead of array or object for O(1) lookup, add and delete
107
- const viewableParticipantSessionIds = useRef<Set<string>>(new Set());
108
- const [_forceUpdateValue, forceUpdate] = useReducer((x) => x + 1, 0);
109
- const forceUpdateValue = useDebouncedValue(_forceUpdateValue, 500); // we debounce forced value to avoid multiple viewability change continuous rerenders due to callbacks that occurs simultaneously during a large list scroll or when scrolling is completed
107
+ // Lazy ref init: avoids recreating instances on every render (useRef doesn't support initializer fns)
108
+ const viewableParticipantSessionIds = useRef<Set<string>>(null!);
109
+ if (!viewableParticipantSessionIds.current) {
110
+ viewableParticipantSessionIds.current = new Set();
111
+ }
112
+ const forceUpdate$Ref = useRef<Subject<void>>(null!);
113
+ if (!forceUpdate$Ref.current) {
114
+ forceUpdate$Ref.current = new Subject<void>();
115
+ }
116
+ const forceUpdate$ = forceUpdate$Ref.current;
117
+ const [forceUpdateValue, setForceUpdateValue] = useState(0);
118
+ useEffect(() => {
119
+ const sub = forceUpdate$.pipe(debounceTime(500)).subscribe(() => {
120
+ setForceUpdateValue((v) => v + 1);
121
+ });
122
+ return () => sub.unsubscribe();
123
+ }, [forceUpdate$]);
124
+ const forceUpdate = useCallback(() => forceUpdate$.next(), [forceUpdate$]);
110
125
 
111
126
  // we use a ref to store the active call object
112
127
  // so that it can be used in the onViewableItemsChanged callback
@@ -1,2 +1 @@
1
- export * from './useDebouncedValue';
2
1
  export * from './usePrevious';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.29.4';
1
+ export const version = '1.30.0';
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDebouncedValue = useDebouncedValue;
7
- var _react = require("react");
8
- /**
9
- * this is a custom hook that takes a value and a delay and returns a debounced value
10
- * @param {T} value
11
- * @param {number} delay
12
- * @returns {T}
13
- */
14
- function useDebouncedValue(value, delay) {
15
- const [debouncedValue, setDebouncedValue] = (0, _react.useState)(value);
16
- (0, _react.useEffect)(() => {
17
- const timer = setTimeout(() => setDebouncedValue(value), delay);
18
- return () => {
19
- clearTimeout(timer);
20
- };
21
- }, [value, delay]);
22
- return debouncedValue;
23
- }
24
- //# sourceMappingURL=useDebouncedValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","useDebouncedValue","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","timer","setTimeout","clearTimeout"],"sourceRoot":"../../../../src","sources":["utils/hooks/useDebouncedValue.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAAIC,KAAQ,EAAEC,KAAa,EAAK;EAC/D,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAG,IAAAC,eAAQ,EAAIJ,KAAK,CAAC;EAE9D,IAAAK,gBAAS,EAAC,MAAM;IACd,MAAMC,KAAK,GAAGC,UAAU,CAAC,MAAMJ,iBAAiB,CAACH,KAAK,CAAC,EAAEC,KAAK,CAAC;IAE/D,OAAO,MAAM;MACXO,YAAY,CAACF,KAAK,CAAC;IACrB,CAAC;EACH,CAAC,EAAE,CAACN,KAAK,EAAEC,KAAK,CAAC,CAAC;EAElB,OAAOC,cAAc;AACvB","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- /**
4
- * this is a custom hook that takes a value and a delay and returns a debounced value
5
- * @param {T} value
6
- * @param {number} delay
7
- * @returns {T}
8
- */
9
- export function useDebouncedValue(value, delay) {
10
- const [debouncedValue, setDebouncedValue] = useState(value);
11
- useEffect(() => {
12
- const timer = setTimeout(() => setDebouncedValue(value), delay);
13
- return () => {
14
- clearTimeout(timer);
15
- };
16
- }, [value, delay]);
17
- return debouncedValue;
18
- }
19
- //# sourceMappingURL=useDebouncedValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useState","useDebouncedValue","value","delay","debouncedValue","setDebouncedValue","timer","setTimeout","clearTimeout"],"sourceRoot":"../../../../src","sources":["utils/hooks/useDebouncedValue.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAIC,KAAQ,EAAEC,KAAa,EAAK;EAC/D,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGL,QAAQ,CAAIE,KAAK,CAAC;EAE9DH,SAAS,CAAC,MAAM;IACd,MAAMO,KAAK,GAAGC,UAAU,CAAC,MAAMF,iBAAiB,CAACH,KAAK,CAAC,EAAEC,KAAK,CAAC;IAE/D,OAAO,MAAM;MACXK,YAAY,CAACF,KAAK,CAAC;IACrB,CAAC;EACH,CAAC,EAAE,CAACJ,KAAK,EAAEC,KAAK,CAAC,CAAC;EAElB,OAAOC,cAAc;AACvB","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- /**
2
- * this is a custom hook that takes a value and a delay and returns a debounced value
3
- * @param {T} value
4
- * @param {number} delay
5
- * @returns {T}
6
- */
7
- export declare function useDebouncedValue<T>(value: T, delay: number): T;
8
- //# sourceMappingURL=useDebouncedValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDebouncedValue.d.ts","sourceRoot":"","sources":["../../../../src/utils/hooks/useDebouncedValue.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAY/D"}
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- /**
4
- * this is a custom hook that takes a value and a delay and returns a debounced value
5
- * @param {T} value
6
- * @param {number} delay
7
- * @returns {T}
8
- */
9
- export function useDebouncedValue<T>(value: T, delay: number): T {
10
- const [debouncedValue, setDebouncedValue] = useState<T>(value);
11
-
12
- useEffect(() => {
13
- const timer = setTimeout(() => setDebouncedValue(value), delay);
14
-
15
- return () => {
16
- clearTimeout(timer);
17
- };
18
- }, [value, delay]);
19
-
20
- return debouncedValue;
21
- }