@stream-io/video-react-native-sdk 1.15.0 → 1.16.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 (61) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/commonjs/components/Call/Lobby/Lobby.js +0 -4
  3. package/dist/commonjs/components/Call/Lobby/Lobby.js.map +1 -1
  4. package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js +0 -4
  5. package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
  6. package/dist/commonjs/contexts/index.js +0 -11
  7. package/dist/commonjs/contexts/index.js.map +1 -1
  8. package/dist/commonjs/hooks/index.js +0 -11
  9. package/dist/commonjs/hooks/index.js.map +1 -1
  10. package/dist/commonjs/providers/StreamVideo.js +1 -2
  11. package/dist/commonjs/providers/StreamVideo.js.map +1 -1
  12. package/dist/commonjs/version.js +1 -1
  13. package/dist/module/components/Call/Lobby/Lobby.js +0 -4
  14. package/dist/module/components/Call/Lobby/Lobby.js.map +1 -1
  15. package/dist/module/components/Call/RingingCallContent/OutgoingCall.js +0 -4
  16. package/dist/module/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
  17. package/dist/module/contexts/index.js +0 -1
  18. package/dist/module/contexts/index.js.map +1 -1
  19. package/dist/module/hooks/index.js +0 -1
  20. package/dist/module/hooks/index.js.map +1 -1
  21. package/dist/module/providers/StreamVideo.js +1 -2
  22. package/dist/module/providers/StreamVideo.js.map +1 -1
  23. package/dist/module/version.js +1 -1
  24. package/dist/typescript/components/Call/Lobby/Lobby.d.ts.map +1 -1
  25. package/dist/typescript/components/Call/RingingCallContent/OutgoingCall.d.ts.map +1 -1
  26. package/dist/typescript/contexts/index.d.ts +0 -1
  27. package/dist/typescript/contexts/index.d.ts.map +1 -1
  28. package/dist/typescript/hooks/index.d.ts +0 -1
  29. package/dist/typescript/hooks/index.d.ts.map +1 -1
  30. package/dist/typescript/providers/StreamVideo.d.ts.map +1 -1
  31. package/dist/typescript/version.d.ts +1 -1
  32. package/expo-config-plugin/dist/withAndroidPermissions.js +4 -2
  33. package/expo-config-plugin/dist/withAppDelegate.js +8 -8
  34. package/package.json +4 -4
  35. package/src/components/Call/Lobby/Lobby.tsx +0 -5
  36. package/src/components/Call/RingingCallContent/OutgoingCall.tsx +0 -5
  37. package/src/contexts/index.ts +0 -1
  38. package/src/hooks/index.ts +0 -1
  39. package/src/providers/StreamVideo.tsx +4 -7
  40. package/src/version.ts +1 -1
  41. package/dist/commonjs/contexts/StreamVideoContext.js +0 -110
  42. package/dist/commonjs/contexts/StreamVideoContext.js.map +0 -1
  43. package/dist/commonjs/hooks/internal/useCallMediaStreamCleanup.js +0 -31
  44. package/dist/commonjs/hooks/internal/useCallMediaStreamCleanup.js.map +0 -1
  45. package/dist/commonjs/hooks/useApplyDefaultMediaStreamSettings.js +0 -52
  46. package/dist/commonjs/hooks/useApplyDefaultMediaStreamSettings.js.map +0 -1
  47. package/dist/module/contexts/StreamVideoContext.js +0 -101
  48. package/dist/module/contexts/StreamVideoContext.js.map +0 -1
  49. package/dist/module/hooks/internal/useCallMediaStreamCleanup.js +0 -25
  50. package/dist/module/hooks/internal/useCallMediaStreamCleanup.js.map +0 -1
  51. package/dist/module/hooks/useApplyDefaultMediaStreamSettings.js +0 -46
  52. package/dist/module/hooks/useApplyDefaultMediaStreamSettings.js.map +0 -1
  53. package/dist/typescript/contexts/StreamVideoContext.d.ts +0 -20
  54. package/dist/typescript/contexts/StreamVideoContext.d.ts.map +0 -1
  55. package/dist/typescript/hooks/internal/useCallMediaStreamCleanup.d.ts +0 -6
  56. package/dist/typescript/hooks/internal/useCallMediaStreamCleanup.d.ts.map +0 -1
  57. package/dist/typescript/hooks/useApplyDefaultMediaStreamSettings.d.ts +0 -5
  58. package/dist/typescript/hooks/useApplyDefaultMediaStreamSettings.d.ts.map +0 -1
  59. package/src/contexts/StreamVideoContext.tsx +0 -147
  60. package/src/hooks/internal/useCallMediaStreamCleanup.ts +0 -38
  61. package/src/hooks/useApplyDefaultMediaStreamSettings.tsx +0 -42
@@ -1,147 +0,0 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useEffect,
5
- useRef,
6
- useState,
7
- } from 'react';
8
-
9
- /**
10
- * Creates a Atomic store context with a provider and hooks to access the store
11
- * Atomic means that each value in the store updates state separately using useStoreValue hook
12
- * Extremely minimalistic implementation of Jotai's store context
13
- * @param initialState - the initial state of the store
14
- * @returns - {Provider, useStoreValue, useStoreSetState}
15
- */
16
- function createStoreContext<StoreType extends object>(initialState: StoreType) {
17
- type SetStateFuncType = (
18
- partialStateOrFunc:
19
- | Partial<StoreType>
20
- | ((prevState: StoreType) => Partial<StoreType>),
21
- ) => void;
22
-
23
- // returns unsubscribe function
24
- type SubscribeFunc = (callback: () => void) => () => void;
25
-
26
- function useStoreData(): {
27
- getSnapshot: () => StoreType;
28
- setState: SetStateFuncType;
29
- subscribe: SubscribeFunc;
30
- } {
31
- const storeRef = useRef<StoreType>(initialState);
32
-
33
- const getSnapshot = useRef(() => storeRef.current).current;
34
-
35
- const subscribersRef = useRef<(() => void)[]>([]);
36
-
37
- const setState = useRef<SetStateFuncType>((partialStateOrFunc) => {
38
- if (typeof partialStateOrFunc === 'function') {
39
- const value = partialStateOrFunc(storeRef.current);
40
- storeRef.current = {
41
- ...storeRef.current,
42
- ...value,
43
- };
44
- } else {
45
- storeRef.current = { ...storeRef.current, ...partialStateOrFunc };
46
- }
47
- subscribersRef.current.forEach((callback) => callback());
48
- }).current;
49
-
50
- const subscribe = useRef((callback: () => void) => {
51
- subscribersRef.current.push(callback);
52
- return () => subscribersRef.current.filter((cb) => cb !== callback);
53
- }).current;
54
-
55
- return {
56
- getSnapshot,
57
- setState,
58
- subscribe,
59
- };
60
- }
61
-
62
- type HookReturnType = ReturnType<typeof useStoreData>;
63
-
64
- const StoreContext = createContext<HookReturnType | null>(null);
65
-
66
- function Provider(props: React.PropsWithChildren<{}>) {
67
- const value = useStoreData();
68
- return (
69
- <StoreContext.Provider value={value}>
70
- {props.children}
71
- </StoreContext.Provider>
72
- );
73
- }
74
-
75
- /**
76
- * @param selector
77
- * @returns
78
- *
79
- * @category Client State
80
- */
81
- function useStoreValue<SelectorOutput extends StoreType[keyof StoreType]>(
82
- selector: (store: StoreType) => SelectorOutput,
83
- ): SelectorOutput {
84
- const store = useContext(StoreContext);
85
- if (!store) {
86
- throw new Error('Store not found');
87
- }
88
-
89
- const [state, setState] = useState(selector(store.getSnapshot()));
90
- useEffect(
91
- () => store.subscribe(() => setState(selector(store.getSnapshot()))),
92
- [selector, store],
93
- );
94
-
95
- return state;
96
- }
97
-
98
- /**
99
- *
100
- * @returns
101
- *
102
- * @category Client State
103
- */
104
- function useStoreSetState() {
105
- const store = useContext(StoreContext);
106
- if (!store) {
107
- throw new Error('Store not found');
108
- }
109
- return store.setState;
110
- }
111
-
112
- return {
113
- Provider,
114
- useStoreValue,
115
- useStoreSetState,
116
- };
117
- }
118
-
119
- export type MediaDeviceInfo = {
120
- deviceId: string;
121
- facing?: 'environment' | 'front';
122
- groupId: string;
123
- kind: 'videoinput' | 'audioinput';
124
- label: string;
125
- };
126
-
127
- /**
128
- * Exclude types from documentation site, but we should still add doc comments
129
- * @internal
130
- */
131
- export interface SDKStreamVideoStore {
132
- currentAudioDevice?: MediaDeviceInfo;
133
- currentVideoDevice?: MediaDeviceInfo;
134
- audioDevices: MediaDeviceInfo[];
135
- videoDevices: MediaDeviceInfo[];
136
- }
137
-
138
- export const {
139
- Provider: StreamVideoStoreProvider,
140
- useStoreValue: useStreamVideoStoreValue,
141
- useStoreSetState: useStreamVideoStoreSetState,
142
- } = createStoreContext<SDKStreamVideoStore>({
143
- videoDevices: [],
144
- audioDevices: [],
145
- currentVideoDevice: undefined,
146
- currentAudioDevice: undefined,
147
- });
@@ -1,38 +0,0 @@
1
- import {
2
- CallingState,
3
- disposeOfMediaStream,
4
- getLogger,
5
- } from '@stream-io/video-client';
6
- import { useCall } from '@stream-io/video-react-bindings';
7
- import { useEffect, useRef } from 'react';
8
-
9
- /**
10
- * This hook is meant to be used in Lobby view or equivalent.
11
- * It will cleanup the media stream on unmount if call is not meant to be joined.
12
- */
13
- export const useCallMediaStreamCleanup = () => {
14
- const call = useCall();
15
- // keeping a reference of call to handle cleanup media stream only on unmount
16
- const callRef = useRef(call);
17
- callRef.current = call;
18
-
19
- useEffect(() => {
20
- return () => {
21
- const mediaStream = callRef.current?.camera.state.mediaStream;
22
- if (
23
- mediaStream &&
24
- !(
25
- callRef.current?.state.callingState === CallingState.JOINED ||
26
- callRef.current?.state.callingState === CallingState.JOINING
27
- )
28
- ) {
29
- getLogger(['useCallMediaStreamCleanup'])(
30
- 'debug',
31
- 'Cleaning up camera media stream',
32
- );
33
- // we cleanup media stream only if call is not joined or joining
34
- disposeOfMediaStream(mediaStream);
35
- }
36
- };
37
- }, []);
38
- };
@@ -1,42 +0,0 @@
1
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
- import { useEffect, useMemo } from 'react';
3
-
4
- /**
5
- * Hook when used applies the default call media stream audio/video settings.
6
- */
7
- export const useApplyDefaultMediaStreamSettings = () => {
8
- const { useCallSettings } = useCallStateHooks();
9
- const settings = useCallSettings();
10
- const call = useCall();
11
-
12
- /*
13
- * This is the object is used to track the initial audio/video enablement
14
- * Uses backend settings or the Prop to set initial audio/video enabled
15
- * Backend settings is applied only if the prop was undefined -- meaning user did not provide any value
16
- * Memoization is needed to avoid unnecessary useEffect triggers
17
- */
18
- const { initialAudioEnabled, initialVideoEnabled } = useMemo(() => {
19
- return {
20
- initialAudioEnabled: settings?.audio.mic_default_on,
21
- initialVideoEnabled: settings?.video.camera_default_on,
22
- };
23
- }, [settings?.audio.mic_default_on, settings?.video.camera_default_on]);
24
-
25
- useEffect(() => {
26
- if (initialAudioEnabled !== undefined) {
27
- if (initialAudioEnabled) {
28
- call?.microphone.enable();
29
- } else {
30
- call?.microphone.disable();
31
- }
32
- }
33
-
34
- if (initialVideoEnabled !== undefined) {
35
- if (initialVideoEnabled) {
36
- call?.camera.enable();
37
- } else {
38
- call?.camera.disable();
39
- }
40
- }
41
- }, [call, initialAudioEnabled, initialVideoEnabled]);
42
- };