@stream-io/video-react-sdk 1.16.2 → 1.17.1
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 +19 -0
- package/dist/index.cjs.js +29 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +29 -22
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/NoiseCancellation/NoiseCancellationProvider.d.ts +7 -1
- package/package.json +4 -4
- package/src/components/BackgroundFilters/BackgroundFilters.tsx +1 -1
- package/src/components/NoiseCancellation/NoiseCancellationProvider.tsx +37 -28
|
@@ -20,11 +20,17 @@ export type NoiseCancellationAPI = {
|
|
|
20
20
|
*/
|
|
21
21
|
isEnabled: boolean;
|
|
22
22
|
/**
|
|
23
|
-
* Allows you to
|
|
23
|
+
* Allows you to temporarily enable or disable the Noise Cancellation filters.
|
|
24
24
|
*
|
|
25
25
|
* @param enabled a boolean or a setter.
|
|
26
26
|
*/
|
|
27
27
|
setEnabled: (enabled: boolean | ((value: boolean) => boolean)) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the noise suppression level (0-100).
|
|
30
|
+
*
|
|
31
|
+
* @param level 0 for no suppression, 100 for maximum suppression.
|
|
32
|
+
*/
|
|
33
|
+
setSuppressionLevel: (level: number) => void;
|
|
28
34
|
};
|
|
29
35
|
/**
|
|
30
36
|
* Exposes the NoiseCancellation API.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@floating-ui/react": "^0.27.6",
|
|
33
|
-
"@stream-io/video-client": "1.
|
|
33
|
+
"@stream-io/video-client": "1.23.1",
|
|
34
34
|
"@stream-io/video-filters-web": "0.2.1",
|
|
35
|
-
"@stream-io/video-react-bindings": "1.6.
|
|
35
|
+
"@stream-io/video-react-bindings": "1.6.4",
|
|
36
36
|
"chart.js": "^4.4.4",
|
|
37
37
|
"clsx": "^2.0.0",
|
|
38
38
|
"react-chartjs-2": "^5.3.0"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@rollup/plugin-json": "^6.1.0",
|
|
46
46
|
"@rollup/plugin-replace": "^6.0.2",
|
|
47
47
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
48
|
-
"@stream-io/audio-filters-web": "^0.
|
|
48
|
+
"@stream-io/audio-filters-web": "^0.4.0",
|
|
49
49
|
"@stream-io/video-styling": "^1.1.5",
|
|
50
50
|
"@types/react": "^19.1.3",
|
|
51
51
|
"@types/react-dom": "^19.1.3",
|
|
@@ -239,7 +239,7 @@ const BackgroundFilters = (props: { tfLite: TFLite }) => {
|
|
|
239
239
|
start(ms, (error) => handleErrorRef.current?.(error)),
|
|
240
240
|
);
|
|
241
241
|
return () => {
|
|
242
|
-
unregister();
|
|
242
|
+
unregister().catch((err) => console.warn(`Can't unregister filter`, err));
|
|
243
243
|
};
|
|
244
244
|
}, [backgroundFilter, call, start]);
|
|
245
245
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
PropsWithChildren,
|
|
4
4
|
useContext,
|
|
5
5
|
useEffect,
|
|
6
|
+
useMemo,
|
|
6
7
|
useRef,
|
|
7
8
|
useState,
|
|
8
9
|
} from 'react';
|
|
@@ -34,11 +35,18 @@ export type NoiseCancellationAPI = {
|
|
|
34
35
|
*/
|
|
35
36
|
isEnabled: boolean;
|
|
36
37
|
/**
|
|
37
|
-
* Allows you to
|
|
38
|
+
* Allows you to temporarily enable or disable the Noise Cancellation filters.
|
|
38
39
|
*
|
|
39
40
|
* @param enabled a boolean or a setter.
|
|
40
41
|
*/
|
|
41
42
|
setEnabled: (enabled: boolean | ((value: boolean) => boolean)) => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sets the noise suppression level (0-100).
|
|
46
|
+
*
|
|
47
|
+
* @param level 0 for no suppression, 100 for maximum suppression.
|
|
48
|
+
*/
|
|
49
|
+
setSuppressionLevel: (level: number) => void;
|
|
42
50
|
};
|
|
43
51
|
|
|
44
52
|
const NoiseCancellationContext = createContext<NoiseCancellationAPI | null>(
|
|
@@ -76,20 +84,14 @@ export const NoiseCancellationProvider = (
|
|
|
76
84
|
const hasCapability = useHasPermissions(
|
|
77
85
|
OwnCapability.ENABLE_NOISE_CANCELLATION,
|
|
78
86
|
);
|
|
79
|
-
const [isSupportedByBrowser, setIsSupportedByBrowser] = useState<
|
|
80
|
-
boolean | undefined
|
|
81
|
-
>(undefined);
|
|
82
|
-
|
|
87
|
+
const [isSupportedByBrowser, setIsSupportedByBrowser] = useState<boolean>();
|
|
83
88
|
useEffect(() => {
|
|
84
89
|
const result = noiseCancellation.isSupported();
|
|
85
|
-
|
|
86
90
|
if (typeof result === 'boolean') {
|
|
87
91
|
setIsSupportedByBrowser(result);
|
|
88
92
|
} else {
|
|
89
93
|
result
|
|
90
|
-
.then((
|
|
91
|
-
setIsSupportedByBrowser(_isSupportedByBrowser),
|
|
92
|
-
)
|
|
94
|
+
.then((s) => setIsSupportedByBrowser(s))
|
|
93
95
|
.catch((err) =>
|
|
94
96
|
console.error(
|
|
95
97
|
`Can't determine if noise cancellation is supported`,
|
|
@@ -106,11 +108,12 @@ export const NoiseCancellationProvider = (
|
|
|
106
108
|
const deinit = useRef<Promise<void>>(undefined);
|
|
107
109
|
useEffect(() => {
|
|
108
110
|
if (!call || !isSupported) return;
|
|
111
|
+
noiseCancellation.isEnabled().then((e) => setIsEnabled(e));
|
|
109
112
|
const unsubscribe = noiseCancellation.on('change', (v) => setIsEnabled(v));
|
|
110
113
|
const init = (deinit.current || Promise.resolve())
|
|
111
114
|
.then(() => noiseCancellation.init())
|
|
112
115
|
.then(() => call.microphone.enableNoiseCancellation(noiseCancellation))
|
|
113
|
-
.catch((
|
|
116
|
+
.catch((e) => console.error(`Can't initialize noise cancellation`, e));
|
|
114
117
|
|
|
115
118
|
return () => {
|
|
116
119
|
deinit.current = init
|
|
@@ -120,25 +123,31 @@ export const NoiseCancellationProvider = (
|
|
|
120
123
|
};
|
|
121
124
|
}, [call, isSupported, noiseCancellation]);
|
|
122
125
|
|
|
126
|
+
const contextValue = useMemo<NoiseCancellationAPI>(
|
|
127
|
+
() => ({
|
|
128
|
+
isSupported,
|
|
129
|
+
isEnabled,
|
|
130
|
+
setSuppressionLevel: (level) => {
|
|
131
|
+
if (!noiseCancellation) return;
|
|
132
|
+
noiseCancellation.setSuppressionLevel(level);
|
|
133
|
+
},
|
|
134
|
+
setEnabled: (enabledOrSetter) => {
|
|
135
|
+
if (!noiseCancellation) return;
|
|
136
|
+
const enable =
|
|
137
|
+
typeof enabledOrSetter === 'function'
|
|
138
|
+
? enabledOrSetter(isEnabled)
|
|
139
|
+
: enabledOrSetter;
|
|
140
|
+
if (enable) {
|
|
141
|
+
noiseCancellation.enable();
|
|
142
|
+
} else {
|
|
143
|
+
noiseCancellation.disable();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
[isEnabled, isSupported, noiseCancellation],
|
|
148
|
+
);
|
|
123
149
|
return (
|
|
124
|
-
<NoiseCancellationContext.Provider
|
|
125
|
-
value={{
|
|
126
|
-
isSupported,
|
|
127
|
-
isEnabled,
|
|
128
|
-
setEnabled: (enabledOrSetter) => {
|
|
129
|
-
if (!noiseCancellation) return;
|
|
130
|
-
const enable =
|
|
131
|
-
typeof enabledOrSetter === 'function'
|
|
132
|
-
? enabledOrSetter(isEnabled)
|
|
133
|
-
: enabledOrSetter;
|
|
134
|
-
if (enable) {
|
|
135
|
-
noiseCancellation.enable();
|
|
136
|
-
} else {
|
|
137
|
-
noiseCancellation.disable();
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
}}
|
|
141
|
-
>
|
|
150
|
+
<NoiseCancellationContext.Provider value={contextValue}>
|
|
142
151
|
{children}
|
|
143
152
|
</NoiseCancellationContext.Provider>
|
|
144
153
|
);
|