@stream-io/video-react-bindings 1.6.7 → 1.7.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.
- package/CHANGELOG.md +16 -0
- package/dist/index.cjs.js +28 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +29 -112
- package/dist/index.es.js.map +1 -1
- package/dist/src/contexts/StreamCallContext.d.ts +3 -0
- package/dist/src/contexts/StreamI18nContext.d.ts +11 -7
- package/dist/src/contexts/StreamVideoContext.d.ts +5 -8
- package/dist/src/hooks/callStateHooks.d.ts +0 -35
- package/dist/src/hooks/index.d.ts +0 -2
- package/dist/src/hooks/store.d.ts +0 -4
- package/dist/src/i18n/StreamI18n.d.ts +4 -10
- package/dist/src/i18n/types.d.ts +2 -3
- package/package.json +4 -4
- package/src/contexts/StreamCallContext.tsx +3 -0
- package/src/contexts/StreamI18nContext.tsx +22 -21
- package/src/contexts/StreamVideoContext.tsx +5 -8
- package/src/hooks/callStateHooks.ts +0 -35
- package/src/hooks/index.ts +0 -2
- package/src/hooks/store.ts +0 -4
- package/src/i18n/StreamI18n.ts +15 -77
- package/src/i18n/types.ts +2 -4
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { CallClosedCaption, CallIngressResponse, CallSessionResponse, CallSettingsResponse, CallState, CallStatsReport, Comparator, EgressResponse, InputDeviceStatus, MemberResponse, OwnCapability, StreamVideoParticipant, UserResponse } from '@stream-io/video-client';
|
|
2
2
|
/**
|
|
3
3
|
* Utility hook, which provides the current call's state.
|
|
4
|
-
*
|
|
5
|
-
* @category Call State
|
|
6
4
|
*/
|
|
7
5
|
export declare const useCallState: () => CallState;
|
|
8
6
|
/**
|
|
9
7
|
* Utility hook which provides information whether the current call is being recorded. It will return `true` if the call is being recorded.
|
|
10
|
-
*
|
|
11
|
-
* @category Call State
|
|
12
8
|
*/
|
|
13
9
|
export declare const useIsCallRecordingInProgress: () => boolean;
|
|
14
10
|
/**
|
|
15
11
|
* Utility hook which provides information whether the current call is broadcasting.
|
|
16
|
-
*
|
|
17
|
-
* @category Call State
|
|
18
12
|
*/
|
|
19
13
|
export declare const useIsCallHLSBroadcastingInProgress: () => boolean;
|
|
20
14
|
/**
|
|
21
15
|
* Utility hook which provides information whether the current call is live.
|
|
22
|
-
*
|
|
23
|
-
* @category Call State
|
|
24
16
|
*/
|
|
25
17
|
export declare const useIsCallLive: () => boolean;
|
|
26
18
|
/**
|
|
@@ -78,8 +70,6 @@ export declare const useCallEndedBy: () => UserResponse | undefined;
|
|
|
78
70
|
/**
|
|
79
71
|
* Utility hook which provides a boolean indicating whether there is
|
|
80
72
|
* a participant in the current call which shares their screen.
|
|
81
|
-
*
|
|
82
|
-
* @category Call State
|
|
83
73
|
*/
|
|
84
74
|
export declare const useHasOngoingScreenShare: () => boolean;
|
|
85
75
|
/**
|
|
@@ -91,40 +81,28 @@ export declare const useHasOngoingScreenShare: () => boolean;
|
|
|
91
81
|
*
|
|
92
82
|
* Consumers of this observable can implement their own batching logic
|
|
93
83
|
* in case they want to show historical stats data.
|
|
94
|
-
*
|
|
95
|
-
* @category Call State
|
|
96
84
|
*/
|
|
97
85
|
export declare const useCallStatsReport: () => CallStatsReport | undefined;
|
|
98
86
|
/**
|
|
99
87
|
* Utility hook which provides the dominant speaker of the current call.
|
|
100
|
-
*
|
|
101
|
-
* @category Call State
|
|
102
88
|
*/
|
|
103
89
|
export declare const useDominantSpeaker: () => StreamVideoParticipant | undefined;
|
|
104
90
|
/**
|
|
105
91
|
* Utility hook which provides a list of call members.
|
|
106
|
-
*
|
|
107
|
-
* @category Call State
|
|
108
92
|
*/
|
|
109
93
|
export declare const useCallMembers: () => MemberResponse[];
|
|
110
94
|
/**
|
|
111
95
|
* Utility hook providing the current calling state of the call. For example, `RINGING` or `JOINED`.
|
|
112
|
-
*
|
|
113
|
-
* @category Call State
|
|
114
96
|
*/
|
|
115
97
|
export declare const useCallCallingState: () => import("@stream-io/video-client").CallingState;
|
|
116
98
|
/**
|
|
117
99
|
* Utility hook providing the actual start time of the current session.
|
|
118
100
|
* Useful for calculating the call duration.
|
|
119
|
-
*
|
|
120
|
-
* @category Call State
|
|
121
101
|
*/
|
|
122
102
|
export declare const useCallStartedAt: () => Date | undefined;
|
|
123
103
|
/**
|
|
124
104
|
* A hook which provides a list of all participants that have joined an active call.
|
|
125
105
|
*
|
|
126
|
-
* @category Call State
|
|
127
|
-
*
|
|
128
106
|
* @param options.sortBy - A comparator function to sort the participants by.
|
|
129
107
|
* Make sure to memoize output of the `combineComparators` function
|
|
130
108
|
* (or keep it out of component's scope if possible) before passing it down to this property.
|
|
@@ -147,28 +125,20 @@ export declare const useRawParticipants: () => StreamVideoParticipant[];
|
|
|
147
125
|
/**
|
|
148
126
|
* A hook which provides a StreamVideoLocalParticipant object.
|
|
149
127
|
* It signals that I have joined a call.
|
|
150
|
-
*
|
|
151
|
-
* @category Call State
|
|
152
128
|
*/
|
|
153
129
|
export declare const useLocalParticipant: () => StreamVideoParticipant | undefined;
|
|
154
130
|
/**
|
|
155
131
|
* A hook which provides a list of all other participants than me that have joined an active call.
|
|
156
|
-
*
|
|
157
|
-
* @category Call State
|
|
158
132
|
*/
|
|
159
133
|
export declare const useRemoteParticipants: () => StreamVideoParticipant[];
|
|
160
134
|
/**
|
|
161
135
|
* Returns the approximate participant count of the active call.
|
|
162
136
|
* This includes the anonymous users as well, and it is computed on the server.
|
|
163
|
-
*
|
|
164
|
-
* @category Call State
|
|
165
137
|
*/
|
|
166
138
|
export declare const useParticipantCount: () => number;
|
|
167
139
|
/**
|
|
168
140
|
* Returns the approximate anonymous participant count of the active call.
|
|
169
141
|
* The regular participants are not included in this count. It is computed on the server.
|
|
170
|
-
*
|
|
171
|
-
* @category Call State
|
|
172
142
|
*/
|
|
173
143
|
export declare const useAnonymousParticipantCount: () => number;
|
|
174
144
|
/**
|
|
@@ -187,9 +157,6 @@ export declare const useOwnCapabilities: () => OwnCapability[] | undefined;
|
|
|
187
157
|
export declare const useHasPermissions: (...permissions: OwnCapability[]) => boolean;
|
|
188
158
|
/**
|
|
189
159
|
* Returns the camera state of the current call.
|
|
190
|
-
*
|
|
191
|
-
* @category Camera Manager State
|
|
192
|
-
*
|
|
193
160
|
*/
|
|
194
161
|
export declare const useCameraState: () => {
|
|
195
162
|
status: InputDeviceStatus;
|
|
@@ -208,8 +175,6 @@ export declare const useCameraState: () => {
|
|
|
208
175
|
};
|
|
209
176
|
/**
|
|
210
177
|
* Returns the microphone state of the current call.
|
|
211
|
-
*
|
|
212
|
-
* @category Microphone Manager State
|
|
213
178
|
*/
|
|
214
179
|
export declare const useMicrophoneState: () => {
|
|
215
180
|
status: InputDeviceStatus;
|
|
@@ -6,13 +6,9 @@ export declare const useStore: () => import("@stream-io/video-client").StreamVid
|
|
|
6
6
|
* Utility hook which provides a list of all notifications about created calls.
|
|
7
7
|
* In the ring call settings, these calls can be outgoing (I have called somebody)
|
|
8
8
|
* or incoming (somebody has called me).
|
|
9
|
-
*
|
|
10
|
-
* @category Client State
|
|
11
9
|
*/
|
|
12
10
|
export declare const useCalls: () => import("@stream-io/video-client").Call[];
|
|
13
11
|
/**
|
|
14
12
|
* Returns the current connected user.
|
|
15
|
-
*
|
|
16
|
-
* @category Client State
|
|
17
13
|
*/
|
|
18
14
|
export declare const useConnectedUser: () => import("@stream-io/video-client").OwnUserResponse | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslationLanguage,
|
|
1
|
+
import { TranslationLanguage, TranslationsMap, TranslatorFunction } from './types';
|
|
2
2
|
export declare const defaultTranslationFunction: (key: string) => string;
|
|
3
3
|
export type StreamI18nConstructor = {
|
|
4
4
|
/** Language into which the provided strings are translated */
|
|
@@ -15,15 +15,9 @@ export declare class StreamI18n {
|
|
|
15
15
|
i18nInstance: import("i18next").i18n;
|
|
16
16
|
/** Translator function that converts the provided string into its equivalent in the current language. */
|
|
17
17
|
t: TranslatorFunction;
|
|
18
|
-
|
|
19
|
-
constructor(options?: StreamI18nConstructor);
|
|
18
|
+
constructor({ debug, currentLanguage, fallbackLanguage, translationsOverrides, }?: StreamI18nConstructor);
|
|
20
19
|
get currentLanguage(): string;
|
|
21
20
|
get isInitialized(): boolean;
|
|
22
|
-
init: () => Promise<
|
|
23
|
-
changeLanguage: (language?: TranslationLanguage
|
|
24
|
-
registerTranslationsForLanguage: ({ lng, translations, }: {
|
|
25
|
-
lng: TranslationLanguage;
|
|
26
|
-
translations: TranslationSheet;
|
|
27
|
-
}) => void;
|
|
28
|
-
private _checkIsInitialized;
|
|
21
|
+
init: () => Promise<TranslatorFunction>;
|
|
22
|
+
changeLanguage: (language?: TranslationLanguage) => Promise<TranslatorFunction>;
|
|
29
23
|
}
|
package/dist/src/i18n/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export type TranslationLanguage = 'en' | string;
|
|
2
|
-
export type Namespace = string;
|
|
1
|
+
export type TranslationLanguage = 'en' | (string & {});
|
|
3
2
|
export type TranslationSheet = Record<string, string>;
|
|
4
|
-
export type TranslationsForLanguage = Record<
|
|
3
|
+
export type TranslationsForLanguage = Record<string, TranslationSheet>;
|
|
5
4
|
export type TranslationsMap = Record<TranslationLanguage, TranslationSheet>;
|
|
6
5
|
export type TranslationsRegistry = Record<TranslationLanguage | string, TranslationsForLanguage>;
|
|
7
6
|
export type TranslatorFunction = (key: string, options?: Record<string, unknown>) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-bindings",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"CHANGELOG.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"i18next": "^
|
|
24
|
+
"i18next": "^25.2.1",
|
|
25
25
|
"rxjs": "~7.8.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@stream-io/video-client": "^1.
|
|
28
|
+
"@stream-io/video-client": "^1.24.0",
|
|
29
29
|
"react": "^17 || ^18 || ^19"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
|
-
"@stream-io/video-client": "^1.
|
|
33
|
+
"@stream-io/video-client": "^1.24.0",
|
|
34
34
|
"@types/react": "^19.1.3",
|
|
35
35
|
"react": "19.0.0",
|
|
36
36
|
"rimraf": "^6.0.1",
|
|
@@ -7,6 +7,9 @@ const StreamCallContext = createContext<Call | undefined>(undefined);
|
|
|
7
7
|
* The props for the StreamCallProvider component.
|
|
8
8
|
*/
|
|
9
9
|
export interface StreamCallProviderProps {
|
|
10
|
+
/**
|
|
11
|
+
* The call instance to provide to the component tree.
|
|
12
|
+
*/
|
|
10
13
|
call?: Call;
|
|
11
14
|
}
|
|
12
15
|
|
|
@@ -3,11 +3,13 @@ import {
|
|
|
3
3
|
PropsWithChildren,
|
|
4
4
|
useContext,
|
|
5
5
|
useEffect,
|
|
6
|
+
useMemo,
|
|
6
7
|
useState,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
9
10
|
defaultTranslationFunction,
|
|
10
11
|
StreamI18n,
|
|
12
|
+
TranslationLanguage,
|
|
11
13
|
TranslationsMap,
|
|
12
14
|
} from '../i18n';
|
|
13
15
|
|
|
@@ -22,8 +24,8 @@ const StreamI18nContext = createContext<StreamI18nContextValue>({
|
|
|
22
24
|
|
|
23
25
|
type CreateI18nParams = {
|
|
24
26
|
i18nInstance?: StreamI18n;
|
|
25
|
-
language?:
|
|
26
|
-
fallbackLanguage?:
|
|
27
|
+
language?: TranslationLanguage;
|
|
28
|
+
fallbackLanguage?: TranslationLanguage;
|
|
27
29
|
translationsOverrides?: TranslationsMap;
|
|
28
30
|
};
|
|
29
31
|
|
|
@@ -33,16 +35,15 @@ export const StreamI18nProvider = ({
|
|
|
33
35
|
children,
|
|
34
36
|
...createI18nParams
|
|
35
37
|
}: PropsWithChildren<StreamI18nProviderProps>) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
+
const api = useCreateI18n(createI18nParams);
|
|
38
39
|
return (
|
|
39
|
-
<StreamI18nContext.Provider value={
|
|
40
|
+
<StreamI18nContext.Provider value={api}>
|
|
40
41
|
{children}
|
|
41
42
|
</StreamI18nContext.Provider>
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const useCreateI18n = ({
|
|
46
47
|
i18nInstance,
|
|
47
48
|
language,
|
|
48
49
|
fallbackLanguage,
|
|
@@ -57,24 +58,24 @@ export const useCreateI18n = ({
|
|
|
57
58
|
translationsOverrides,
|
|
58
59
|
}),
|
|
59
60
|
);
|
|
60
|
-
const [t, setTranslationFn] = useState<StreamI18n['t']>(
|
|
61
|
-
() => defaultTranslationFunction,
|
|
62
|
-
);
|
|
63
|
-
|
|
61
|
+
const [t, setTranslationFn] = useState<StreamI18n['t']>(() => i18n.t);
|
|
64
62
|
useEffect(() => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
if (language && i18n?.currentLanguage !== language) {
|
|
71
|
-
i18n.changeLanguage(language).catch((err) => {
|
|
72
|
-
console.log('Error while changing language', err);
|
|
73
|
-
});
|
|
63
|
+
if (!i18n.isInitialized) {
|
|
64
|
+
i18n.init().then(() => setTranslationFn(() => i18n.t));
|
|
65
|
+
} else if (i18n.currentLanguage !== language) {
|
|
66
|
+
i18n.changeLanguage(language).then(() => setTranslationFn(() => i18n.t));
|
|
74
67
|
}
|
|
75
|
-
}, [i18n,
|
|
68
|
+
}, [i18n, language]);
|
|
76
69
|
|
|
77
|
-
return { i18n, t };
|
|
70
|
+
return useMemo(() => ({ i18n, t }), [i18n, t]);
|
|
78
71
|
};
|
|
79
72
|
|
|
73
|
+
/**
|
|
74
|
+
* A hook to get the i18n instance and translation function from the closest provider.
|
|
75
|
+
*
|
|
76
|
+
* Example usage:
|
|
77
|
+
* const { t, i18n } = useI18n();
|
|
78
|
+
* const message = t('hello_world');
|
|
79
|
+
* console.log(message);
|
|
80
|
+
*/
|
|
80
81
|
export const useI18n = () => useContext(StreamI18nContext);
|
|
@@ -10,18 +10,18 @@ const StreamVideoContext = createContext<StreamVideoClient | undefined>(
|
|
|
10
10
|
);
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
13
|
+
* The props for the StreamVideoProvider component.
|
|
15
14
|
*/
|
|
16
15
|
export type StreamVideoProps = StreamI18nProviderProps & {
|
|
16
|
+
/**
|
|
17
|
+
* The client instance to provide to the component tree.
|
|
18
|
+
*/
|
|
17
19
|
client: StreamVideoClient;
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* StreamVideo is a provider component which should be used to wrap the entire application.
|
|
22
24
|
* It provides the client object to all children components and initializes the i18n instance.
|
|
23
|
-
* @param PropsWithChildren<StreamVideoProps>
|
|
24
|
-
* @category Client State
|
|
25
25
|
*/
|
|
26
26
|
export const StreamVideoProvider = ({
|
|
27
27
|
children,
|
|
@@ -44,10 +44,7 @@ export const StreamVideoProvider = ({
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @returns
|
|
49
|
-
*
|
|
50
|
-
* @category Client State
|
|
47
|
+
* Hook to access the nearest StreamVideo client instance.
|
|
51
48
|
*/
|
|
52
49
|
export const useStreamVideoClient = () => {
|
|
53
50
|
return useContext(StreamVideoContext);
|
|
@@ -27,8 +27,6 @@ const EMPTY_DEVICES_ARRAY = Object.freeze<MediaDeviceInfo[]>(
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Utility hook, which provides the current call's state.
|
|
30
|
-
*
|
|
31
|
-
* @category Call State
|
|
32
30
|
*/
|
|
33
31
|
export const useCallState = () => {
|
|
34
32
|
const call = useCall();
|
|
@@ -46,8 +44,6 @@ export const useCallState = () => {
|
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
46
|
* Utility hook which provides information whether the current call is being recorded. It will return `true` if the call is being recorded.
|
|
49
|
-
*
|
|
50
|
-
* @category Call State
|
|
51
47
|
*/
|
|
52
48
|
export const useIsCallRecordingInProgress = (): boolean => {
|
|
53
49
|
const { recording$ } = useCallState();
|
|
@@ -56,8 +52,6 @@ export const useIsCallRecordingInProgress = (): boolean => {
|
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* Utility hook which provides information whether the current call is broadcasting.
|
|
59
|
-
*
|
|
60
|
-
* @category Call State
|
|
61
55
|
*/
|
|
62
56
|
export const useIsCallHLSBroadcastingInProgress = (): boolean => {
|
|
63
57
|
const { egress$ } = useCallState();
|
|
@@ -68,8 +62,6 @@ export const useIsCallHLSBroadcastingInProgress = (): boolean => {
|
|
|
68
62
|
|
|
69
63
|
/**
|
|
70
64
|
* Utility hook which provides information whether the current call is live.
|
|
71
|
-
*
|
|
72
|
-
* @category Call State
|
|
73
65
|
*/
|
|
74
66
|
export const useIsCallLive = (): boolean => {
|
|
75
67
|
const { backstage$ } = useCallState();
|
|
@@ -184,8 +176,6 @@ export const useCallEndedBy = (): UserResponse | undefined => {
|
|
|
184
176
|
/**
|
|
185
177
|
* Utility hook which provides a boolean indicating whether there is
|
|
186
178
|
* a participant in the current call which shares their screen.
|
|
187
|
-
*
|
|
188
|
-
* @category Call State
|
|
189
179
|
*/
|
|
190
180
|
export const useHasOngoingScreenShare = (): boolean => {
|
|
191
181
|
const { hasOngoingScreenShare$ } = useCallState();
|
|
@@ -201,8 +191,6 @@ export const useHasOngoingScreenShare = (): boolean => {
|
|
|
201
191
|
*
|
|
202
192
|
* Consumers of this observable can implement their own batching logic
|
|
203
193
|
* in case they want to show historical stats data.
|
|
204
|
-
*
|
|
205
|
-
* @category Call State
|
|
206
194
|
*/
|
|
207
195
|
export const useCallStatsReport = (): CallStatsReport | undefined => {
|
|
208
196
|
const { callStatsReport$ } = useCallState();
|
|
@@ -211,8 +199,6 @@ export const useCallStatsReport = (): CallStatsReport | undefined => {
|
|
|
211
199
|
|
|
212
200
|
/**
|
|
213
201
|
* Utility hook which provides the dominant speaker of the current call.
|
|
214
|
-
*
|
|
215
|
-
* @category Call State
|
|
216
202
|
*/
|
|
217
203
|
export const useDominantSpeaker = (): StreamVideoParticipant | undefined => {
|
|
218
204
|
const { dominantSpeaker$ } = useCallState();
|
|
@@ -221,8 +207,6 @@ export const useDominantSpeaker = (): StreamVideoParticipant | undefined => {
|
|
|
221
207
|
|
|
222
208
|
/**
|
|
223
209
|
* Utility hook which provides a list of call members.
|
|
224
|
-
*
|
|
225
|
-
* @category Call State
|
|
226
210
|
*/
|
|
227
211
|
export const useCallMembers = (): MemberResponse[] => {
|
|
228
212
|
const { members$ } = useCallState();
|
|
@@ -231,8 +215,6 @@ export const useCallMembers = (): MemberResponse[] => {
|
|
|
231
215
|
|
|
232
216
|
/**
|
|
233
217
|
* Utility hook providing the current calling state of the call. For example, `RINGING` or `JOINED`.
|
|
234
|
-
*
|
|
235
|
-
* @category Call State
|
|
236
218
|
*/
|
|
237
219
|
export const useCallCallingState = () => {
|
|
238
220
|
const { callingState$ } = useCallState();
|
|
@@ -242,8 +224,6 @@ export const useCallCallingState = () => {
|
|
|
242
224
|
/**
|
|
243
225
|
* Utility hook providing the actual start time of the current session.
|
|
244
226
|
* Useful for calculating the call duration.
|
|
245
|
-
*
|
|
246
|
-
* @category Call State
|
|
247
227
|
*/
|
|
248
228
|
export const useCallStartedAt = () => {
|
|
249
229
|
const { startedAt$ } = useCallState();
|
|
@@ -253,8 +233,6 @@ export const useCallStartedAt = () => {
|
|
|
253
233
|
/**
|
|
254
234
|
* A hook which provides a list of all participants that have joined an active call.
|
|
255
235
|
*
|
|
256
|
-
* @category Call State
|
|
257
|
-
*
|
|
258
236
|
* @param options.sortBy - A comparator function to sort the participants by.
|
|
259
237
|
* Make sure to memoize output of the `combineComparators` function
|
|
260
238
|
* (or keep it out of component's scope if possible) before passing it down to this property.
|
|
@@ -294,8 +272,6 @@ export const useRawParticipants = () => {
|
|
|
294
272
|
/**
|
|
295
273
|
* A hook which provides a StreamVideoLocalParticipant object.
|
|
296
274
|
* It signals that I have joined a call.
|
|
297
|
-
*
|
|
298
|
-
* @category Call State
|
|
299
275
|
*/
|
|
300
276
|
export const useLocalParticipant = () => {
|
|
301
277
|
const { localParticipant$ } = useCallState();
|
|
@@ -304,8 +280,6 @@ export const useLocalParticipant = () => {
|
|
|
304
280
|
|
|
305
281
|
/**
|
|
306
282
|
* A hook which provides a list of all other participants than me that have joined an active call.
|
|
307
|
-
*
|
|
308
|
-
* @category Call State
|
|
309
283
|
*/
|
|
310
284
|
export const useRemoteParticipants = () => {
|
|
311
285
|
const { remoteParticipants$ } = useCallState();
|
|
@@ -315,8 +289,6 @@ export const useRemoteParticipants = () => {
|
|
|
315
289
|
/**
|
|
316
290
|
* Returns the approximate participant count of the active call.
|
|
317
291
|
* This includes the anonymous users as well, and it is computed on the server.
|
|
318
|
-
*
|
|
319
|
-
* @category Call State
|
|
320
292
|
*/
|
|
321
293
|
export const useParticipantCount = () => {
|
|
322
294
|
const { participantCount$ } = useCallState();
|
|
@@ -326,8 +298,6 @@ export const useParticipantCount = () => {
|
|
|
326
298
|
/**
|
|
327
299
|
* Returns the approximate anonymous participant count of the active call.
|
|
328
300
|
* The regular participants are not included in this count. It is computed on the server.
|
|
329
|
-
*
|
|
330
|
-
* @category Call State
|
|
331
301
|
*/
|
|
332
302
|
export const useAnonymousParticipantCount = () => {
|
|
333
303
|
const { anonymousParticipantCount$ } = useCallState();
|
|
@@ -362,9 +332,6 @@ export const useHasPermissions = (...permissions: OwnCapability[]): boolean => {
|
|
|
362
332
|
|
|
363
333
|
/**
|
|
364
334
|
* Returns the camera state of the current call.
|
|
365
|
-
*
|
|
366
|
-
* @category Camera Manager State
|
|
367
|
-
*
|
|
368
335
|
*/
|
|
369
336
|
export const useCameraState = () => {
|
|
370
337
|
const call = useCall();
|
|
@@ -399,8 +366,6 @@ export const useCameraState = () => {
|
|
|
399
366
|
|
|
400
367
|
/**
|
|
401
368
|
* Returns the microphone state of the current call.
|
|
402
|
-
*
|
|
403
|
-
* @category Microphone Manager State
|
|
404
369
|
*/
|
|
405
370
|
export const useMicrophoneState = () => {
|
|
406
371
|
const call = useCall();
|
package/src/hooks/index.ts
CHANGED
package/src/hooks/store.ts
CHANGED
|
@@ -18,8 +18,6 @@ export const useStore = () => {
|
|
|
18
18
|
* Utility hook which provides a list of all notifications about created calls.
|
|
19
19
|
* In the ring call settings, these calls can be outgoing (I have called somebody)
|
|
20
20
|
* or incoming (somebody has called me).
|
|
21
|
-
*
|
|
22
|
-
* @category Client State
|
|
23
21
|
*/
|
|
24
22
|
export const useCalls = () => {
|
|
25
23
|
const { calls$ } = useStore();
|
|
@@ -28,8 +26,6 @@ export const useCalls = () => {
|
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Returns the current connected user.
|
|
31
|
-
*
|
|
32
|
-
* @category Client State
|
|
33
29
|
*/
|
|
34
30
|
export const useConnectedUser = () => {
|
|
35
31
|
const { connectedUser$ } = useStore();
|
package/src/i18n/StreamI18n.ts
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
import i18next from 'i18next';
|
|
2
2
|
import {
|
|
3
3
|
TranslationLanguage,
|
|
4
|
-
TranslationSheet,
|
|
5
4
|
TranslationsMap,
|
|
6
5
|
TranslationsRegistry,
|
|
7
6
|
TranslatorFunction,
|
|
8
7
|
} from './types';
|
|
9
8
|
|
|
10
|
-
const DEFAULT_NAMESPACE = 'stream-video';
|
|
11
|
-
const DEFAULT_CONFIG = {
|
|
12
|
-
debug: false,
|
|
13
|
-
currentLanguage: 'en',
|
|
14
|
-
fallbackLanguage: false,
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
9
|
const mapToRegistry = (translationsMap: TranslationsMap, namespace: string) =>
|
|
18
10
|
Object.entries(translationsMap).reduce((acc, [lng, translations]) => {
|
|
19
11
|
acc[lng] = { [namespace]: translations };
|
|
20
12
|
return acc;
|
|
21
13
|
}, {} as TranslationsRegistry);
|
|
22
14
|
|
|
23
|
-
const DEFAULT_TRANSLATIONS_REGISTRY = mapToRegistry({}, DEFAULT_NAMESPACE);
|
|
24
|
-
|
|
25
15
|
export const defaultTranslationFunction = (key: string) => key;
|
|
26
16
|
|
|
27
17
|
export type StreamI18nConstructor = {
|
|
@@ -40,40 +30,28 @@ export class StreamI18n {
|
|
|
40
30
|
i18nInstance;
|
|
41
31
|
/** Translator function that converts the provided string into its equivalent in the current language. */
|
|
42
32
|
t: TranslatorFunction = defaultTranslationFunction;
|
|
43
|
-
/** Simple logger function */
|
|
44
|
-
constructor(options: StreamI18nConstructor = {}) {
|
|
45
|
-
const {
|
|
46
|
-
debug = DEFAULT_CONFIG.debug,
|
|
47
|
-
currentLanguage = DEFAULT_CONFIG.currentLanguage,
|
|
48
|
-
fallbackLanguage = DEFAULT_CONFIG.fallbackLanguage,
|
|
49
|
-
translationsOverrides,
|
|
50
|
-
} = options;
|
|
51
33
|
|
|
34
|
+
constructor({
|
|
35
|
+
debug = false,
|
|
36
|
+
currentLanguage = 'en',
|
|
37
|
+
fallbackLanguage,
|
|
38
|
+
translationsOverrides = { en: {} },
|
|
39
|
+
}: StreamI18nConstructor = {}) {
|
|
40
|
+
const ns = 'stream-video';
|
|
52
41
|
this.i18nInstance = i18next.createInstance({
|
|
53
42
|
debug,
|
|
54
|
-
defaultNS:
|
|
43
|
+
defaultNS: ns,
|
|
55
44
|
fallbackLng: fallbackLanguage,
|
|
56
45
|
interpolation: { escapeValue: false },
|
|
57
46
|
keySeparator: false,
|
|
58
47
|
lng: currentLanguage,
|
|
59
48
|
nsSeparator: false,
|
|
60
|
-
parseMissingKeyHandler:
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
resources: DEFAULT_TRANSLATIONS_REGISTRY,
|
|
49
|
+
parseMissingKeyHandler: defaultTranslationFunction,
|
|
50
|
+
resources: mapToRegistry(translationsOverrides, ns),
|
|
64
51
|
});
|
|
65
|
-
|
|
66
|
-
if (translationsOverrides) {
|
|
67
|
-
this.i18nInstance.on('initialized', () => {
|
|
68
|
-
Object.entries(translationsOverrides).forEach(([lng, translations]) => {
|
|
69
|
-
this.registerTranslationsForLanguage({ lng, translations });
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
52
|
}
|
|
74
53
|
|
|
75
54
|
get currentLanguage() {
|
|
76
|
-
this._checkIsInitialized();
|
|
77
55
|
return this.i18nInstance.language;
|
|
78
56
|
}
|
|
79
57
|
|
|
@@ -82,52 +60,12 @@ export class StreamI18n {
|
|
|
82
60
|
}
|
|
83
61
|
|
|
84
62
|
init = async () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} catch (e) {
|
|
88
|
-
console.error(`Failed to initialize translations: ${JSON.stringify(e)}`);
|
|
89
|
-
}
|
|
90
|
-
return this;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
changeLanguage = async (
|
|
94
|
-
language?: TranslationLanguage,
|
|
95
|
-
onChange?: (language: TranslationLanguage) => void,
|
|
96
|
-
) => {
|
|
97
|
-
if (!this._checkIsInitialized()) return;
|
|
98
|
-
// i18next detects the language, if none provided, but it is better
|
|
99
|
-
// to show this detection here explicitly
|
|
100
|
-
const browserLanguage =
|
|
101
|
-
typeof window !== 'undefined' && window.navigator
|
|
102
|
-
? window.navigator.language
|
|
103
|
-
: undefined;
|
|
104
|
-
await this.i18nInstance.changeLanguage(language || browserLanguage);
|
|
105
|
-
onChange?.(this.currentLanguage);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
registerTranslationsForLanguage = ({
|
|
109
|
-
lng,
|
|
110
|
-
translations,
|
|
111
|
-
}: {
|
|
112
|
-
lng: TranslationLanguage;
|
|
113
|
-
translations: TranslationSheet;
|
|
114
|
-
}) => {
|
|
115
|
-
if (!this._checkIsInitialized()) return;
|
|
116
|
-
this.i18nInstance.addResourceBundle(
|
|
117
|
-
lng,
|
|
118
|
-
DEFAULT_NAMESPACE,
|
|
119
|
-
translations,
|
|
120
|
-
true,
|
|
121
|
-
true,
|
|
122
|
-
);
|
|
63
|
+
this.t = await this.i18nInstance.init();
|
|
64
|
+
return this.t;
|
|
123
65
|
};
|
|
124
66
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
'I18n instance is not initialized. Call yourStreamI18nInstance.init().',
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
return this.i18nInstance.isInitialized;
|
|
67
|
+
changeLanguage = async (language?: TranslationLanguage) => {
|
|
68
|
+
this.t = await this.i18nInstance.changeLanguage(language);
|
|
69
|
+
return this.t;
|
|
132
70
|
};
|
|
133
71
|
}
|
package/src/i18n/types.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export type TranslationLanguage = 'en' | string;
|
|
2
|
-
|
|
3
|
-
export type Namespace = string;
|
|
1
|
+
export type TranslationLanguage = 'en' | (string & {});
|
|
4
2
|
|
|
5
3
|
export type TranslationSheet = Record<string, string>;
|
|
6
4
|
|
|
7
|
-
export type TranslationsForLanguage = Record<
|
|
5
|
+
export type TranslationsForLanguage = Record<string, TranslationSheet>;
|
|
8
6
|
|
|
9
7
|
export type TranslationsMap = Record<TranslationLanguage, TranslationSheet>;
|
|
10
8
|
|