@stream-io/video-react-sdk 1.28.1 → 1.29.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 +23 -0
- package/dist/background-filters-89nRJ8Uk.cjs.js +352 -0
- package/dist/background-filters-89nRJ8Uk.cjs.js.map +1 -0
- package/dist/background-filters-B5aRj_vl.es.js +350 -0
- package/dist/background-filters-B5aRj_vl.es.js.map +1 -0
- package/dist/index.cjs.js +123 -342
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +125 -344
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/BackgroundFilters/BackgroundFilters.d.ts +5 -144
- package/dist/src/components/BackgroundFilters/BackgroundFiltersProvider.d.ts +15 -0
- package/dist/src/components/BackgroundFilters/index.d.ts +2 -1
- package/dist/src/components/BackgroundFilters/types.d.ts +135 -0
- package/dist/src/core/components/CallLayout/SpeakerLayout.d.ts +6 -1
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/useDragToScroll.d.ts +18 -0
- package/package.json +4 -4
- package/src/components/BackgroundFilters/BackgroundFilters.tsx +50 -219
- package/src/components/BackgroundFilters/BackgroundFiltersProvider.tsx +60 -0
- package/src/components/BackgroundFilters/index.ts +4 -1
- package/src/components/BackgroundFilters/types.ts +162 -0
- package/src/core/components/CallLayout/SpeakerLayout.tsx +11 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDragToScroll.ts +162 -0
|
@@ -1,150 +1,11 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for performance metric thresholds.
|
|
5
|
-
*/
|
|
6
|
-
export type BackgroundFiltersPerformanceThresholds = {
|
|
7
|
-
/**
|
|
8
|
-
* The lower FPS threshold for triggering a performance warning.
|
|
9
|
-
* When the EMA FPS falls below this value, a warning is shown.
|
|
10
|
-
* @default 23
|
|
11
|
-
*/
|
|
12
|
-
fpsWarningThresholdLower?: number;
|
|
13
|
-
/**
|
|
14
|
-
* The upper FPS threshold for clearing a performance warning.
|
|
15
|
-
* When the EMA FPS rises above this value, the warning is cleared.
|
|
16
|
-
* @default 25
|
|
17
|
-
*/
|
|
18
|
-
fpsWarningThresholdUpper?: number;
|
|
19
|
-
/**
|
|
20
|
-
* The default FPS value used as the initial value for the EMA (Exponential Moving Average)
|
|
21
|
-
* calculation and when stats are unavailable or when resetting the filter.
|
|
22
|
-
* @default 30
|
|
23
|
-
*/
|
|
24
|
-
defaultFps?: number;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Represents the possible reasons for background filter performance degradation.
|
|
28
|
-
*/
|
|
29
|
-
export declare enum PerformanceDegradationReason {
|
|
30
|
-
FRAME_DROP = "frame-drop",
|
|
31
|
-
CPU_THROTTLING = "cpu-throttling"
|
|
32
|
-
}
|
|
33
|
-
export type BackgroundFiltersProps = PlatformSupportFlags & {
|
|
34
|
-
/**
|
|
35
|
-
* A list of URLs to use as background images.
|
|
36
|
-
*/
|
|
37
|
-
backgroundImages?: string[];
|
|
38
|
-
/**
|
|
39
|
-
* The background filter to apply to the video (by default).
|
|
40
|
-
* @default undefined no filter applied
|
|
41
|
-
*/
|
|
42
|
-
backgroundFilter?: BackgroundFilter;
|
|
43
|
-
/**
|
|
44
|
-
* The URL of the image to use as the background (by default).
|
|
45
|
-
*/
|
|
46
|
-
backgroundImage?: string;
|
|
47
|
-
/**
|
|
48
|
-
* The level of blur to apply to the background (by default).
|
|
49
|
-
* @default 'high'.
|
|
50
|
-
*/
|
|
51
|
-
backgroundBlurLevel?: BackgroundBlurLevel;
|
|
52
|
-
/**
|
|
53
|
-
* The base path for the TensorFlow Lite files.
|
|
54
|
-
* @default 'https://unpkg.com/@stream-io/video-filters-web/mediapipe'.
|
|
55
|
-
*/
|
|
56
|
-
basePath?: string;
|
|
57
|
-
/**
|
|
58
|
-
* The path to the TensorFlow Lite WebAssembly file.
|
|
59
|
-
*
|
|
60
|
-
* Override this prop to use a custom path to the TensorFlow Lite WebAssembly file
|
|
61
|
-
* (e.g., if you choose to host it yourself).
|
|
62
|
-
*/
|
|
63
|
-
tfFilePath?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The path to the MediaPipe model file.
|
|
66
|
-
* Override this prop to use a custom path to the MediaPipe model file
|
|
67
|
-
* (e.g., if you choose to host it yourself).
|
|
68
|
-
*/
|
|
69
|
-
modelFilePath?: string;
|
|
70
|
-
/**
|
|
71
|
-
* When true, the filter uses the legacy TensorFlow-based segmentation model.
|
|
72
|
-
* When false, it uses the default MediaPipe Tasks Vision model.
|
|
73
|
-
*
|
|
74
|
-
* Only enable this if you need to mimic the behavior of older SDK versions.
|
|
75
|
-
*/
|
|
76
|
-
useLegacyFilter?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* When a started filter encounters an error, this callback will be executed.
|
|
79
|
-
* The default behavior (not overridable) is unregistering a failed filter.
|
|
80
|
-
* Use this callback to display UI error message, disable the corresponding stream,
|
|
81
|
-
* or to try registering the filter again.
|
|
82
|
-
*/
|
|
83
|
-
onError?: (error: any) => void;
|
|
84
|
-
/**
|
|
85
|
-
* Configuration for performance metric thresholds.
|
|
86
|
-
* Use this to customize when performance warnings are triggered.
|
|
87
|
-
*/
|
|
88
|
-
performanceThresholds?: BackgroundFiltersPerformanceThresholds;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Performance degradation information for background filters.
|
|
92
|
-
*
|
|
93
|
-
* Performance is calculated using an Exponential Moving Average (EMA) of FPS values
|
|
94
|
-
* to smooth out quick spikes and provide stable performance warnings.
|
|
95
|
-
*/
|
|
96
|
-
export type BackgroundFiltersPerformance = {
|
|
97
|
-
/**
|
|
98
|
-
* Whether performance is currently degraded.
|
|
99
|
-
*/
|
|
100
|
-
degraded: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Reasons for performance degradation.
|
|
103
|
-
*/
|
|
104
|
-
reason?: Array<PerformanceDegradationReason>;
|
|
105
|
-
};
|
|
106
|
-
export type BackgroundFiltersAPI = {
|
|
107
|
-
/**
|
|
108
|
-
* Whether the current platform supports the background filters.
|
|
109
|
-
*/
|
|
110
|
-
isSupported: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Indicates whether the background filters engine is loaded and ready.
|
|
113
|
-
*/
|
|
114
|
-
isReady: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Performance information for background filters.
|
|
117
|
-
*/
|
|
118
|
-
performance: BackgroundFiltersPerformance;
|
|
119
|
-
/**
|
|
120
|
-
* Disables all background filters applied to the video.
|
|
121
|
-
*/
|
|
122
|
-
disableBackgroundFilter: () => void;
|
|
123
|
-
/**
|
|
124
|
-
* Applies a background blur filter to the video.
|
|
125
|
-
*
|
|
126
|
-
* @param blurLevel the level of blur to apply to the background.
|
|
127
|
-
*/
|
|
128
|
-
applyBackgroundBlurFilter: (blurLevel: BackgroundBlurLevel) => void;
|
|
129
|
-
/**
|
|
130
|
-
* Applies a background image filter to the video.
|
|
131
|
-
*
|
|
132
|
-
* @param imageUrl the URL of the image to use as the background.
|
|
133
|
-
*/
|
|
134
|
-
applyBackgroundImageFilter: (imageUrl: string) => void;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* The context value for the background filters context.
|
|
138
|
-
*/
|
|
139
|
-
export type BackgroundFiltersContextValue = BackgroundFiltersProps & BackgroundFiltersAPI;
|
|
140
|
-
/**
|
|
141
|
-
* A hook to access the background filters context API.
|
|
142
|
-
*/
|
|
143
|
-
export declare const useBackgroundFilters: () => BackgroundFiltersContextValue;
|
|
1
|
+
import { Context, PropsWithChildren } from 'react';
|
|
2
|
+
import type { BackgroundFiltersProps, BackgroundFiltersContextValue } from './types';
|
|
144
3
|
/**
|
|
145
4
|
* A provider component that enables the use of background filters in your app.
|
|
146
5
|
*
|
|
147
6
|
* Please make sure you have the `@stream-io/video-filters-web` package installed
|
|
148
7
|
* in your project before using this component.
|
|
149
8
|
*/
|
|
150
|
-
export declare const BackgroundFiltersProvider: (props: PropsWithChildren<BackgroundFiltersProps>
|
|
9
|
+
export declare const BackgroundFiltersProvider: (props: PropsWithChildren<BackgroundFiltersProps> & {
|
|
10
|
+
ContextProvider: Context<BackgroundFiltersContextValue | undefined>;
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { BackgroundFiltersProps, BackgroundFiltersContextValue } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A hook to access the background filters context API.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useBackgroundFilters: () => BackgroundFiltersContextValue;
|
|
7
|
+
/**
|
|
8
|
+
* A provider component that enables the use of background filters in your app.
|
|
9
|
+
*
|
|
10
|
+
* Please make sure you have the `@stream-io/video-filters-web` package installed
|
|
11
|
+
* in your project before using this component.
|
|
12
|
+
*/
|
|
13
|
+
export declare const BackgroundFiltersProvider: (props: PropsWithChildren<BackgroundFiltersProps> & {
|
|
14
|
+
SuspenseFallback?: ReactNode;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './BackgroundFiltersProvider';
|
|
2
|
+
export * from './types';
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { BackgroundBlurLevel, BackgroundFilter, PlatformSupportFlags } from '@stream-io/video-filters-web';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for performance metric thresholds.
|
|
4
|
+
*/
|
|
5
|
+
export type BackgroundFiltersPerformanceThresholds = {
|
|
6
|
+
/**
|
|
7
|
+
* The lower FPS threshold for triggering a performance warning.
|
|
8
|
+
* When the EMA FPS falls below this value, a warning is shown.
|
|
9
|
+
* @default 23
|
|
10
|
+
*/
|
|
11
|
+
fpsWarningThresholdLower?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The upper FPS threshold for clearing a performance warning.
|
|
14
|
+
* When the EMA FPS rises above this value, the warning is cleared.
|
|
15
|
+
* @default 25
|
|
16
|
+
*/
|
|
17
|
+
fpsWarningThresholdUpper?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The default FPS value used as the initial value for the EMA (Exponential Moving Average)
|
|
20
|
+
* calculation and when stats are unavailable or when resetting the filter.
|
|
21
|
+
* @default 30
|
|
22
|
+
*/
|
|
23
|
+
defaultFps?: number;
|
|
24
|
+
};
|
|
25
|
+
export type BackgroundFiltersProps = PlatformSupportFlags & {
|
|
26
|
+
/**
|
|
27
|
+
* A list of URLs to use as background images.
|
|
28
|
+
*/
|
|
29
|
+
backgroundImages?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The background filter to apply to the video (by default).
|
|
32
|
+
* @default undefined no filter applied
|
|
33
|
+
*/
|
|
34
|
+
backgroundFilter?: BackgroundFilter;
|
|
35
|
+
/**
|
|
36
|
+
* The URL of the image to use as the background (by default).
|
|
37
|
+
*/
|
|
38
|
+
backgroundImage?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The level of blur to apply to the background (by default).
|
|
41
|
+
* @default 'high'.
|
|
42
|
+
*/
|
|
43
|
+
backgroundBlurLevel?: BackgroundBlurLevel;
|
|
44
|
+
/**
|
|
45
|
+
* The base path for the TensorFlow Lite files.
|
|
46
|
+
* @default 'https://unpkg.com/@stream-io/video-filters-web/mediapipe'.
|
|
47
|
+
*/
|
|
48
|
+
basePath?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The path to the TensorFlow Lite WebAssembly file.
|
|
51
|
+
*
|
|
52
|
+
* Override this prop to use a custom path to the TensorFlow Lite WebAssembly file
|
|
53
|
+
* (e.g., if you choose to host it yourself).
|
|
54
|
+
*/
|
|
55
|
+
tfFilePath?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The path to the MediaPipe model file.
|
|
58
|
+
* Override this prop to use a custom path to the MediaPipe model file
|
|
59
|
+
* (e.g., if you choose to host it yourself).
|
|
60
|
+
*/
|
|
61
|
+
modelFilePath?: string;
|
|
62
|
+
/**
|
|
63
|
+
* When true, the filter uses the legacy TensorFlow-based segmentation model.
|
|
64
|
+
* When false, it uses the default MediaPipe Tasks Vision model.
|
|
65
|
+
*
|
|
66
|
+
* Only enable this if you need to mimic the behavior of older SDK versions.
|
|
67
|
+
*/
|
|
68
|
+
useLegacyFilter?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* When a started filter encounters an error, this callback will be executed.
|
|
71
|
+
* The default behavior (not overridable) is unregistering a failed filter.
|
|
72
|
+
* Use this callback to display UI error message, disable the corresponding stream,
|
|
73
|
+
* or to try registering the filter again.
|
|
74
|
+
*/
|
|
75
|
+
onError?: (error: any) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for performance metric thresholds.
|
|
78
|
+
* Use this to customize when performance warnings are triggered.
|
|
79
|
+
*/
|
|
80
|
+
performanceThresholds?: BackgroundFiltersPerformanceThresholds;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Represents the possible reasons for background filter performance degradation.
|
|
84
|
+
*/
|
|
85
|
+
export type PerformanceDegradationReason = 'frame-drop' | 'cpu-throttling';
|
|
86
|
+
/**
|
|
87
|
+
* Performance degradation information for background filters.
|
|
88
|
+
*
|
|
89
|
+
* Performance is calculated using an Exponential Moving Average (EMA) of FPS values
|
|
90
|
+
* to smooth out quick spikes and provide stable performance warnings.
|
|
91
|
+
*/
|
|
92
|
+
export type BackgroundFiltersPerformance = {
|
|
93
|
+
/**
|
|
94
|
+
* Whether performance is currently degraded.
|
|
95
|
+
*/
|
|
96
|
+
degraded: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Reasons for performance degradation.
|
|
99
|
+
*/
|
|
100
|
+
reason?: Array<PerformanceDegradationReason>;
|
|
101
|
+
};
|
|
102
|
+
export type BackgroundFiltersAPI = {
|
|
103
|
+
/**
|
|
104
|
+
* Whether the current platform supports the background filters.
|
|
105
|
+
*/
|
|
106
|
+
isSupported: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Indicates whether the background filters engine is loaded and ready.
|
|
109
|
+
*/
|
|
110
|
+
isReady: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Performance information for background filters.
|
|
113
|
+
*/
|
|
114
|
+
performance: BackgroundFiltersPerformance;
|
|
115
|
+
/**
|
|
116
|
+
* Disables all background filters applied to the video.
|
|
117
|
+
*/
|
|
118
|
+
disableBackgroundFilter: () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Applies a background blur filter to the video.
|
|
121
|
+
*
|
|
122
|
+
* @param blurLevel the level of blur to apply to the background.
|
|
123
|
+
*/
|
|
124
|
+
applyBackgroundBlurFilter: (blurLevel: BackgroundBlurLevel) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Applies a background image filter to the video.
|
|
127
|
+
*
|
|
128
|
+
* @param imageUrl the URL of the image to use as the background.
|
|
129
|
+
*/
|
|
130
|
+
applyBackgroundImageFilter: (imageUrl: string) => void;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The context value for the background filters context.
|
|
134
|
+
*/
|
|
135
|
+
export type BackgroundFiltersContextValue = BackgroundFiltersProps & BackgroundFiltersAPI;
|
|
@@ -57,8 +57,13 @@ export type SpeakerLayoutProps = {
|
|
|
57
57
|
* Whether the layout is muted. Defaults to `false`.
|
|
58
58
|
*/
|
|
59
59
|
muted?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to enable drag-to-scroll functionality on the participants bar.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
enableDragToScroll?: boolean;
|
|
60
65
|
} & Pick<ParticipantViewProps, 'VideoPlaceholder' | 'PictureInPicturePlaceholder'>;
|
|
61
66
|
export declare const SpeakerLayout: {
|
|
62
|
-
({ ParticipantViewUIBar, ParticipantViewUISpotlight, VideoPlaceholder, PictureInPicturePlaceholder, participantsBarPosition, participantsBarLimit, mirrorLocalParticipantVideo, excludeLocalParticipant, filterParticipants, pageArrowsVisible, muted, }: SpeakerLayoutProps): import("react/jsx-runtime").JSX.Element | null;
|
|
67
|
+
({ ParticipantViewUIBar, ParticipantViewUISpotlight, VideoPlaceholder, PictureInPicturePlaceholder, participantsBarPosition, participantsBarLimit, mirrorLocalParticipantVideo, excludeLocalParticipant, filterParticipants, pageArrowsVisible, muted, enableDragToScroll, }: SpeakerLayoutProps): import("react/jsx-runtime").JSX.Element | null;
|
|
63
68
|
displayName: string;
|
|
64
69
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface DragToScrollOptions {
|
|
2
|
+
decay?: number;
|
|
3
|
+
minVelocity?: number;
|
|
4
|
+
dragThreshold?: number;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Enables drag-to-scroll functionality with momentum scrolling on a scrollable element.
|
|
9
|
+
*
|
|
10
|
+
* This hook allows users to click and drag to scroll an element, with momentum scrolling
|
|
11
|
+
* that continues after the drag ends. The drag only activates after moving beyond a threshold
|
|
12
|
+
* distance, which prevents accidental drags from clicks.
|
|
13
|
+
*
|
|
14
|
+
* @param element - The HTML element to enable drag to scroll on.
|
|
15
|
+
* @param options - Options for customizing the drag-to-scroll behavior.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useDragToScroll(element: HTMLElement | null, options?: DragToScrollOptions): void;
|
|
18
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@floating-ui/react": "^0.27.6",
|
|
34
|
-
"@stream-io/video-client": "1.
|
|
34
|
+
"@stream-io/video-client": "1.39.0",
|
|
35
35
|
"@stream-io/video-filters-web": "0.6.0",
|
|
36
|
-
"@stream-io/video-react-bindings": "1.12.
|
|
36
|
+
"@stream-io/video-react-bindings": "1.12.3",
|
|
37
37
|
"chart.js": "^4.4.4",
|
|
38
38
|
"clsx": "^2.0.0",
|
|
39
39
|
"react-chartjs-2": "^5.3.0"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@rollup/plugin-json": "^6.1.0",
|
|
47
47
|
"@rollup/plugin-replace": "^6.0.2",
|
|
48
48
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
49
|
-
"@stream-io/audio-filters-web": "^0.
|
|
49
|
+
"@stream-io/audio-filters-web": "^0.7.0",
|
|
50
50
|
"@stream-io/video-styling": "^1.9.0",
|
|
51
51
|
"@types/react": "~19.1.17",
|
|
52
52
|
"@types/react-dom": "~19.1.11",
|