@100mslive/roomkit-react 0.1.19-alpha.1 → 0.1.19-alpha.2
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/dist/{HLSView-UBVLOPNY.js → HLSView-7X5BVAZE.js} +2 -2
- package/dist/Prebuilt/App.d.ts +1 -0
- package/dist/Prebuilt/common/constants.d.ts +1 -1
- package/dist/Prebuilt/components/Chat/EmptyChat.d.ts +2 -0
- package/dist/Prebuilt/components/Polls/Voting/{Leaderboard.d.ts → LeaderboardSummary.d.ts} +1 -1
- package/dist/Prebuilt/components/Polls/Voting/StatisticBox.d.ts +5 -0
- package/dist/Prebuilt/components/VirtualBackground/VBCollection.d.ts +3 -4
- package/dist/Prebuilt/components/VirtualBackground/VBHandler.d.ts +13 -0
- package/dist/Prebuilt/components/VirtualBackground/VBPicker.d.ts +1 -1
- package/dist/Prebuilt/components/VirtualBackground/constants.d.ts +0 -2
- package/dist/{chunk-VU2CQFCB.js → chunk-H3B4ARYV.js} +1396 -1294
- package/dist/chunk-H3B4ARYV.js.map +7 -0
- package/dist/index.cjs.js +1741 -1610
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +227 -90
- package/dist/meta.esbuild.json +234 -97
- package/package.json +6 -6
- package/src/Prebuilt/App.tsx +2 -1
- package/src/Prebuilt/common/constants.ts +1 -1
- package/src/Prebuilt/components/Chat/ChatActions.tsx +3 -3
- package/src/Prebuilt/components/Chat/ChatBody.tsx +28 -46
- package/src/Prebuilt/components/Chat/EmptyChat.tsx +51 -0
- package/src/Prebuilt/components/Footer/PollsToggle.tsx +7 -1
- package/src/Prebuilt/components/Notifications/Notifications.tsx +0 -29
- package/src/Prebuilt/components/Polls/Polls.tsx +2 -2
- package/src/Prebuilt/components/Polls/Voting/LeaderboardEntry.tsx +2 -2
- package/src/Prebuilt/components/Polls/Voting/LeaderboardSummary.tsx +162 -0
- package/src/Prebuilt/components/Polls/Voting/PeerParticipationSummary.tsx +2 -9
- package/src/Prebuilt/components/Polls/Voting/StatisticBox.tsx +15 -0
- package/src/Prebuilt/components/Polls/Voting/Voting.jsx +1 -17
- package/src/Prebuilt/components/TileMenu/TileMenuContent.tsx +1 -1
- package/src/Prebuilt/components/VirtualBackground/VBCollection.tsx +5 -11
- package/src/Prebuilt/components/VirtualBackground/VBHandler.tsx +72 -0
- package/src/Prebuilt/components/VirtualBackground/VBPicker.tsx +44 -81
- package/src/Prebuilt/components/VirtualBackground/constants.ts +0 -4
- package/src/Prebuilt/layouts/SidePane.tsx +6 -1
- package/src/Theme/stitches.config.ts +2 -10
- package/dist/chunk-VU2CQFCB.js.map +0 -7
- package/src/Prebuilt/components/Polls/Voting/Leaderboard.tsx +0 -123
- package/src/Prebuilt/components/Polls/Voting/PollResultSummary.jsx +0 -125
- /package/dist/{HLSView-UBVLOPNY.js.map → HLSView-7X5BVAZE.js.map} +0 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
|
2
|
+
|
3
|
+
export class VBPlugin {
|
4
|
+
private hmsPlugin?: HMSVBPlugin;
|
5
|
+
private effectsPlugin?: HMSEffectsPlugin | undefined;
|
6
|
+
|
7
|
+
initialisePlugin = (effectsSDKKey?: string) => {
|
8
|
+
if (this.getVBObject()) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
if (effectsSDKKey) {
|
12
|
+
this.effectsPlugin = new HMSEffectsPlugin(effectsSDKKey);
|
13
|
+
} else {
|
14
|
+
this.hmsPlugin = new HMSVBPlugin(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
|
18
|
+
getBackground = () => {
|
19
|
+
if (this.effectsPlugin) {
|
20
|
+
return this.effectsPlugin?.getBackground();
|
21
|
+
} else {
|
22
|
+
// @ts-ignore
|
23
|
+
return this.hmsPlugin?.background?.src || this.hmsPlugin?.background;
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
getVBObject = () => {
|
28
|
+
return this.effectsPlugin || this.hmsPlugin;
|
29
|
+
};
|
30
|
+
|
31
|
+
getName = () => {
|
32
|
+
return this.effectsPlugin ? this.effectsPlugin?.getName() : this.hmsPlugin?.getName();
|
33
|
+
};
|
34
|
+
|
35
|
+
setBlur = async (blurPower: number) => {
|
36
|
+
if (this.effectsPlugin) {
|
37
|
+
this.effectsPlugin?.setBlur(blurPower);
|
38
|
+
} else {
|
39
|
+
await this.hmsPlugin?.setBackground(HMSVirtualBackgroundTypes.BLUR, HMSVirtualBackgroundTypes.BLUR);
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
setBackground = async (mediaURL: string) => {
|
44
|
+
if (this.effectsPlugin) {
|
45
|
+
this.effectsPlugin?.setBackground(mediaURL);
|
46
|
+
} else {
|
47
|
+
const img = document.createElement('img');
|
48
|
+
let retries = 0;
|
49
|
+
const MAX_RETRIES = 3;
|
50
|
+
img.alt = 'VB';
|
51
|
+
img.src = mediaURL;
|
52
|
+
try {
|
53
|
+
await this.hmsPlugin?.setBackground(img, HMSVirtualBackgroundTypes.IMAGE);
|
54
|
+
} catch (e) {
|
55
|
+
console.error(e);
|
56
|
+
if (retries++ < MAX_RETRIES) {
|
57
|
+
await this.hmsPlugin?.setBackground(img, HMSVirtualBackgroundTypes.IMAGE);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
removeEffects = async () => {
|
64
|
+
if (this.effectsPlugin) {
|
65
|
+
this.effectsPlugin?.removeEffects();
|
66
|
+
} else {
|
67
|
+
await this.hmsPlugin?.setBackground(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);
|
68
|
+
}
|
69
|
+
};
|
70
|
+
}
|
71
|
+
|
72
|
+
export const VBHandler = new VBPlugin();
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import React, { useEffect,
|
2
|
-
import {
|
1
|
+
import React, { useEffect, useState } from 'react';
|
2
|
+
import { selectEffectsKey, selectIsEffectsEnabled, selectLocalPeerRole } from '@100mslive/hms-video-store';
|
3
|
+
import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
|
3
4
|
import { VirtualBackgroundMedia } from '@100mslive/types-prebuilt/elements/virtual_background';
|
4
5
|
import {
|
5
6
|
HMSRoomState,
|
6
7
|
selectIsLargeRoom,
|
7
8
|
selectIsLocalVideoEnabled,
|
9
|
+
selectIsLocalVideoPluginPresent,
|
8
10
|
selectLocalPeer,
|
9
|
-
selectLocalPeerRole,
|
10
|
-
selectLocalVideoTrackID,
|
11
11
|
selectRoomState,
|
12
12
|
selectVideoTrackByID,
|
13
13
|
useHMSActions,
|
@@ -17,96 +17,58 @@ import { BlurPersonHighIcon, CloseIcon, CrossCircleIcon } from '@100mslive/react
|
|
17
17
|
import { Box, Flex, Video } from '../../../index';
|
18
18
|
import { Text } from '../../../Text';
|
19
19
|
import { VBCollection } from './VBCollection';
|
20
|
+
import { VBHandler } from './VBHandler';
|
20
21
|
// @ts-ignore
|
21
22
|
import { useSidepaneToggle } from '../AppData/useSidepane';
|
22
23
|
// @ts-ignore
|
23
24
|
import { useUISettings } from '../AppData/useUISettings';
|
24
|
-
// @ts-ignore
|
25
25
|
import { SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
|
26
|
-
import { defaultMedia
|
26
|
+
import { defaultMedia } from './constants';
|
27
27
|
|
28
28
|
const iconDims = { height: '40px', width: '40px' };
|
29
|
-
const MAX_RETRIES = 2;
|
30
29
|
|
31
30
|
export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBackgroundMedia[] }) => {
|
32
31
|
const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
|
33
32
|
const hmsActions = useHMSActions();
|
34
|
-
const role = useHMSStore(selectLocalPeerRole);
|
35
|
-
const [isVBSupported, setIsVBSupported] = useState(false);
|
36
|
-
const localPeerVideoTrackID = useHMSStore(selectLocalVideoTrackID);
|
37
33
|
const localPeer = useHMSStore(selectLocalPeer);
|
38
|
-
|
39
|
-
const [background, setBackground] = useState(vbPlugin.background);
|
40
|
-
// @ts-ignore
|
41
|
-
const [backgroundType, setBackgroundType] = useState(vbPlugin.backgroundType);
|
34
|
+
const role = useHMSStore(selectLocalPeerRole);
|
42
35
|
const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
|
43
36
|
const mirrorLocalVideo = useUISettings(UI_SETTINGS.mirrorLocalVideo);
|
44
37
|
const trackSelector = selectVideoTrackByID(localPeer?.videoTrack);
|
45
38
|
const track = useHMSStore(trackSelector);
|
46
39
|
const roomState = useHMSStore(selectRoomState);
|
47
40
|
const isLargeRoom = useHMSStore(selectIsLargeRoom);
|
48
|
-
const
|
41
|
+
const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
|
42
|
+
const effectsKey = useHMSStore(selectEffectsKey);
|
43
|
+
const isPluginAdded = useHMSStore(selectIsLocalVideoPluginPresent(VBHandler?.getName() || ''));
|
44
|
+
const [activeBackground, setActiveBackground] = useState<string | HMSVirtualBackgroundTypes>(
|
45
|
+
(VBHandler?.getBackground() as string | HMSVirtualBackgroundTypes) || HMSVirtualBackgroundTypes.NONE,
|
46
|
+
);
|
49
47
|
const mediaList = backgroundMedia.length
|
50
|
-
? backgroundMedia.map((media: VirtualBackgroundMedia) => media
|
48
|
+
? backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '')
|
51
49
|
: defaultMedia;
|
52
50
|
|
53
51
|
const inPreview = roomState === HMSRoomState.Preview;
|
54
|
-
// Hidden in preview as the effect will be visible in the preview tile
|
52
|
+
// Hidden in preview as the effect will be visible in the preview tile
|
55
53
|
const showVideoTile = isVideoOn && isLargeRoom && !inPreview;
|
56
54
|
|
57
|
-
const clearVBState = () => {
|
58
|
-
setBackground(HMSVirtualBackgroundTypes.NONE);
|
59
|
-
setBackgroundType(HMSVirtualBackgroundTypes.NONE);
|
60
|
-
};
|
61
|
-
|
62
55
|
useEffect(() => {
|
63
|
-
if (!
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
async function disableEffects() {
|
75
|
-
if (vbPlugin) {
|
76
|
-
vbPlugin.setBackground(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);
|
77
|
-
clearVBState();
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
async function addPlugin({ mediaURL = '', blurPower = 0 }) {
|
82
|
-
let retries = 0;
|
83
|
-
try {
|
84
|
-
if (mediaURL) {
|
85
|
-
const img = document.createElement('img');
|
86
|
-
img.alt = 'VB';
|
87
|
-
img.src = mediaURL;
|
88
|
-
try {
|
89
|
-
await vbPlugin.setBackground(img, HMSVirtualBackgroundTypes.IMAGE);
|
90
|
-
} catch (e) {
|
91
|
-
console.error(e);
|
92
|
-
if (retries++ < MAX_RETRIES) {
|
93
|
-
await vbPlugin.setBackground(img, HMSVirtualBackgroundTypes.IMAGE);
|
56
|
+
if (!isPluginAdded) {
|
57
|
+
let vbObject = VBHandler.getVBObject();
|
58
|
+
if (!vbObject) {
|
59
|
+
VBHandler.initialisePlugin(isEffectsEnabled && effectsKey ? effectsKey : '');
|
60
|
+
vbObject = VBHandler.getVBObject();
|
61
|
+
if (isEffectsEnabled && effectsKey) {
|
62
|
+
hmsActions.addPluginsToVideoStream([vbObject as HMSEffectsPlugin]);
|
63
|
+
} else {
|
64
|
+
if (!role) {
|
65
|
+
return;
|
94
66
|
}
|
67
|
+
hmsActions.addPluginToVideoTrack(vbObject as HMSVBPlugin, Math.floor(role.publishParams.video.frameRate / 2));
|
95
68
|
}
|
96
|
-
} else if (blurPower) {
|
97
|
-
await vbPlugin.setBackground(HMSVirtualBackgroundTypes.BLUR, HMSVirtualBackgroundTypes.BLUR);
|
98
|
-
}
|
99
|
-
setBackground(mediaURL || HMSVirtualBackgroundTypes.BLUR);
|
100
|
-
setBackgroundType(mediaURL ? HMSVirtualBackgroundTypes.IMAGE : HMSVirtualBackgroundTypes.BLUR);
|
101
|
-
if (role && !addedPluginToVideoTrack.current) {
|
102
|
-
await hmsActions.addPluginToVideoTrack(vbPlugin, Math.floor(role.publishParams.video.frameRate / 2));
|
103
|
-
addedPluginToVideoTrack.current = true;
|
104
69
|
}
|
105
|
-
} catch (err) {
|
106
|
-
console.error('Failed to apply VB', err);
|
107
|
-
disableEffects();
|
108
70
|
}
|
109
|
-
}
|
71
|
+
}, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey]);
|
110
72
|
|
111
73
|
useEffect(() => {
|
112
74
|
if (!isVideoOn) {
|
@@ -114,10 +76,6 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
|
|
114
76
|
}
|
115
77
|
}, [isVideoOn, toggleVB]);
|
116
78
|
|
117
|
-
if (!isVBSupported) {
|
118
|
-
return null;
|
119
|
-
}
|
120
|
-
|
121
79
|
return (
|
122
80
|
<Flex css={{ pr: '$6', size: '100%' }} direction="column">
|
123
81
|
<Flex align="center" justify="between" css={{ w: '100%', background: '$surface_dim', pb: '$4' }}>
|
@@ -140,7 +98,6 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
|
|
140
98
|
css={{ width: '100%', height: '16rem' }}
|
141
99
|
/>
|
142
100
|
) : null}
|
143
|
-
|
144
101
|
<Box
|
145
102
|
css={{
|
146
103
|
mt: '$4',
|
@@ -156,30 +113,36 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
|
|
156
113
|
{
|
157
114
|
title: 'No effect',
|
158
115
|
icon: <CrossCircleIcon style={iconDims} />,
|
159
|
-
|
160
|
-
onClick: async () =>
|
116
|
+
value: HMSVirtualBackgroundTypes.NONE,
|
117
|
+
onClick: async () => {
|
118
|
+
await VBHandler.removeEffects();
|
119
|
+
setActiveBackground(HMSVirtualBackgroundTypes.NONE);
|
120
|
+
},
|
161
121
|
},
|
162
122
|
{
|
163
123
|
title: 'Blur',
|
164
124
|
icon: <BlurPersonHighIcon style={iconDims} />,
|
165
|
-
|
166
|
-
onClick: async () =>
|
125
|
+
value: HMSVirtualBackgroundTypes.BLUR,
|
126
|
+
onClick: async () => {
|
127
|
+
await VBHandler?.setBlur(0.5);
|
128
|
+
setActiveBackground(HMSVirtualBackgroundTypes.BLUR);
|
129
|
+
},
|
167
130
|
},
|
168
131
|
]}
|
169
|
-
|
170
|
-
// @ts-ignore
|
171
|
-
activeBackground={vbPlugin.background?.src || vbPlugin.background || HMSVirtualBackgroundTypes.NONE}
|
132
|
+
activeBackground={activeBackground}
|
172
133
|
/>
|
173
134
|
|
174
135
|
<VBCollection
|
175
136
|
title="Backgrounds"
|
176
137
|
options={mediaList.map(mediaURL => ({
|
177
|
-
type: HMSVirtualBackgroundTypes.IMAGE,
|
178
138
|
mediaURL,
|
179
|
-
|
139
|
+
value: mediaURL,
|
140
|
+
onClick: async () => {
|
141
|
+
await VBHandler?.setBackground(mediaURL);
|
142
|
+
setActiveBackground(mediaURL);
|
143
|
+
},
|
180
144
|
}))}
|
181
|
-
|
182
|
-
activeBackground={background?.src || background || HMSVirtualBackgroundTypes.NONE}
|
145
|
+
activeBackground={activeBackground}
|
183
146
|
/>
|
184
147
|
</Box>
|
185
148
|
</Flex>
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
|
2
|
-
|
3
1
|
export const defaultMedia = [
|
4
2
|
'https://assets.100ms.live/webapp/vb-mini/vb-1.jpg',
|
5
3
|
'https://assets.100ms.live/webapp/vb-mini/vb-2.jpg',
|
@@ -14,5 +12,3 @@ export const defaultMedia = [
|
|
14
12
|
'https://assets.100ms.live/webapp/vb-mini/vb-11.jpg',
|
15
13
|
'https://assets.100ms.live/webapp/vb-mini/vb-12.jpg',
|
16
14
|
];
|
17
|
-
|
18
|
-
export const vbPlugin = new HMSVBPlugin(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);
|
@@ -32,6 +32,11 @@ const SidePane = ({
|
|
32
32
|
const trackId = useHMSStore(selectVideoTrackByPeerID(activeScreensharePeerId))?.id;
|
33
33
|
const { elements } = useRoomLayoutConferencingScreen();
|
34
34
|
const { elements: preview_elements } = useRoomLayoutPreviewScreen();
|
35
|
+
|
36
|
+
const backgroundMedia = preview_elements?.virtual_background?.background_media?.length
|
37
|
+
? preview_elements?.virtual_background?.background_media
|
38
|
+
: elements?.virtual_background?.background_media || [];
|
39
|
+
|
35
40
|
const resetSidePane = useSidepaneReset();
|
36
41
|
let ViewComponent;
|
37
42
|
if (sidepane === SIDE_PANE_OPTIONS.POLLS) {
|
@@ -41,7 +46,7 @@ const SidePane = ({
|
|
41
46
|
ViewComponent = <SidePaneTabs hideControls={hideControls} active={sidepane} />;
|
42
47
|
}
|
43
48
|
if (sidepane === SIDE_PANE_OPTIONS.VB) {
|
44
|
-
ViewComponent = <VBPicker backgroundMedia={
|
49
|
+
ViewComponent = <VBPicker backgroundMedia={backgroundMedia} />;
|
45
50
|
}
|
46
51
|
|
47
52
|
useEffect(() => {
|
@@ -2,6 +2,7 @@ import type * as Stitches from '@stitches/react';
|
|
2
2
|
import { createStitches } from '@stitches/react';
|
3
3
|
import merge from 'lodash.merge';
|
4
4
|
import { baseConfig, defaultMedia, defaultThemeMap, defaultUtils } from './base.config';
|
5
|
+
import { DEFAULT_PORTAL_CONTAINER } from '../Prebuilt/common/constants';
|
5
6
|
|
6
7
|
const HmsStitches = createStitches({
|
7
8
|
prefix: 'hms-ui',
|
@@ -28,18 +29,9 @@ export const {
|
|
28
29
|
} = HmsStitches;
|
29
30
|
|
30
31
|
export const globalStyles = globalCss({
|
31
|
-
|
32
|
+
[`${DEFAULT_PORTAL_CONTAINER} *`]: {
|
32
33
|
fontFamily: '$sans',
|
33
34
|
boxSizing: 'border-box',
|
34
|
-
borderWidth: 0,
|
35
|
-
borderStyle: 'solid',
|
36
|
-
},
|
37
|
-
body: {
|
38
|
-
margin: 0,
|
39
|
-
},
|
40
|
-
'#root': {
|
41
|
-
height: '100%',
|
42
|
-
overscrollBehaviorY: 'none',
|
43
35
|
},
|
44
36
|
'::-webkit-scrollbar-track': {
|
45
37
|
WebkitBoxShadow: 'inset 0 0 6px rgba(0, 0, 0, 0.3)',
|