@100mslive/react-sdk 0.0.2-alpha → 0.0.3-alpha.3
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/hooks/HmsRoomProvider.d.ts +6 -4
- package/dist/hooks/store.d.ts +4 -2
- package/dist/hooks/types.d.ts +3 -3
- package/dist/hooks/useAudioLevel.d.ts +1 -0
- package/dist/hooks/usePreview.d.ts +1 -0
- package/dist/hooks/useVideo.d.ts +1 -1
- package/dist/hooks/useVideoList.d.ts +3 -3
- package/dist/hooks/useVideoTile.d.ts +3 -3
- package/dist/index.cjs.js +44 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -0
- package/package.json +37 -34
- package/dist/hooks/useVideoListLayout.d.ts +0 -26
- package/dist/node_modules/react-intersection-observer/react-intersection-observer.m.js +0 -244
- package/dist/node_modules/zustand/esm/shallow.js +0 -1
- package/dist/packages/react-sdk/src/hooks/HmsRoomProvider.js +0 -131
- package/dist/packages/react-sdk/src/hooks/store.js +0 -25
- package/dist/packages/react-sdk/src/hooks/useAVToggle.js +0 -35
- package/dist/packages/react-sdk/src/hooks/useAudioLevel.js +0 -24
- package/dist/packages/react-sdk/src/hooks/useDevices.js +0 -62
- package/dist/packages/react-sdk/src/hooks/usePreview.js +0 -40
- package/dist/packages/react-sdk/src/hooks/useVideo.js +0 -44
- package/dist/packages/react-sdk/src/hooks/useVideoListLayout.js +0 -65
- package/dist/packages/react-sdk/src/hooks/useVideoTile.js +0 -36
- package/dist/packages/react-sdk/src/index.js +0 -9
- package/dist/packages/react-sdk/src/utils/isBrowser.js +0 -2
- package/dist/packages/react-sdk/src/utils/layout.js +0 -434
- package/dist/packages/react-sdk/src/utils/logger.js +0 -74
- package/dist/src/hooks/HmsRoomProvider.js +0 -1
- package/dist/src/hooks/store.js +0 -1
- package/dist/src/hooks/useAVToggle.js +0 -1
- package/dist/src/hooks/useAudioLevel.js +0 -1
- package/dist/src/hooks/useDevices.js +0 -1
- package/dist/src/hooks/usePreview.js +0 -1
- package/dist/src/hooks/useVideo.js +0 -1
- package/dist/src/hooks/useVideoList.js +0 -1
- package/dist/src/hooks/useVideoListLayout.js +0 -65
- package/dist/src/hooks/useVideoTile.js +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/utils/isBrowser.js +0 -1
- package/dist/src/utils/layout.js +0 -1
- package/dist/src/utils/logger.js +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { selectVideoTrackByPeerID, selectIsPeerAudioEnabled, selectIsPeerVideoEnabled, selectPeerAudioByID } from '@100mslive/hms-video-store';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { useHMSActions, useHMSStore } from './HmsRoomProvider.js';
|
|
4
|
-
|
|
5
|
-
const useVideoTile = peer => {
|
|
6
|
-
const actions = useHMSActions();
|
|
7
|
-
const videoRef = useRef(null);
|
|
8
|
-
const videoTrack = useHMSStore(selectVideoTrackByPeerID(peer.id));
|
|
9
|
-
const isAudioOn = useHMSStore(selectIsPeerAudioEnabled(peer.id));
|
|
10
|
-
const isVideoOn = useHMSStore(selectIsPeerVideoEnabled(peer.id));
|
|
11
|
-
const {
|
|
12
|
-
isLocal,
|
|
13
|
-
name
|
|
14
|
-
} = peer;
|
|
15
|
-
const audioLevel = useHMSStore(selectPeerAudioByID(peer.id)) > 0;
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (videoRef.current && videoTrack) {
|
|
18
|
-
if (videoTrack.enabled) {
|
|
19
|
-
actions.attachVideo(videoTrack.id, videoRef.current);
|
|
20
|
-
} else {
|
|
21
|
-
actions.detachVideo(videoTrack.id, videoRef.current);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}, [videoTrack, actions]);
|
|
25
|
-
return {
|
|
26
|
-
videoRef,
|
|
27
|
-
isAudioOn,
|
|
28
|
-
isVideoOn,
|
|
29
|
-
actions,
|
|
30
|
-
isLocal,
|
|
31
|
-
name,
|
|
32
|
-
audioLevel
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { useVideoTile };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { HMSRoomProvider, useHMSActions, useHMSNotifications, useHMSStore, useHMSVanillaStore } from './hooks/HmsRoomProvider.js';
|
|
2
|
-
export { calculateLayoutSizes, chunkElements, getModeAspectRatio } from './utils/layout.js';
|
|
3
|
-
export { usePreview } from './hooks/usePreview.js';
|
|
4
|
-
export { useVideoTile } from './hooks/useVideoTile.js';
|
|
5
|
-
export { useVideoList } from './hooks/useVideoListLayout.js';
|
|
6
|
-
export { useAVToggle } from './hooks/useAVToggle.js';
|
|
7
|
-
export { useDevices } from './hooks/useDevices.js';
|
|
8
|
-
export { useVideo } from './hooks/useVideo.js';
|
|
9
|
-
export { useAudioLevel } from './hooks/useAudioLevel.js';
|
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
const chunk = (elements, chunkSize, onlyOnePage) => elements.reduce((resultArray, tile, index) => {
|
|
4
|
-
const chunkIndex = Math.floor(index / chunkSize);
|
|
5
|
-
|
|
6
|
-
if (chunkIndex > 0 && onlyOnePage) {
|
|
7
|
-
return resultArray;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!resultArray[chunkIndex]) {
|
|
11
|
-
resultArray[chunkIndex] = []; // start a new chunk
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
resultArray[chunkIndex].push(tile);
|
|
15
|
-
return resultArray;
|
|
16
|
-
}, []);
|
|
17
|
-
/**
|
|
18
|
-
* Given a list of tracks/elements and some constraints, group the tracks in separate pages.
|
|
19
|
-
* @return 2D list for every page which has the original element and height and width
|
|
20
|
-
* for its tile.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const chunkElements = ({
|
|
25
|
-
elements,
|
|
26
|
-
tilesInFirstPage,
|
|
27
|
-
onlyOnePage,
|
|
28
|
-
isLastPageDifferentFromFirstPage,
|
|
29
|
-
defaultWidth,
|
|
30
|
-
defaultHeight,
|
|
31
|
-
lastPageWidth,
|
|
32
|
-
lastPageHeight
|
|
33
|
-
}) => {
|
|
34
|
-
const chunks = chunk(elements, tilesInFirstPage, onlyOnePage);
|
|
35
|
-
return chunks.map((ch, page) => ch.map(element => {
|
|
36
|
-
const isLastPage = page === chunks.length - 1;
|
|
37
|
-
const width = isLastPageDifferentFromFirstPage && isLastPage ? lastPageWidth : defaultWidth;
|
|
38
|
-
const height = isLastPageDifferentFromFirstPage && isLastPage ? lastPageHeight : defaultHeight;
|
|
39
|
-
return _extends({}, element, {
|
|
40
|
-
height,
|
|
41
|
-
width
|
|
42
|
-
});
|
|
43
|
-
}));
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Mathematical mode - the element with the highest occurrence in an array
|
|
47
|
-
* @param array
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function mode(array) {
|
|
52
|
-
if (array.length === 0) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const modeMap = {};
|
|
57
|
-
let maxEl = array[0];
|
|
58
|
-
let maxCount = 1;
|
|
59
|
-
|
|
60
|
-
for (let i = 0; i < array.length; i++) {
|
|
61
|
-
const el = array[i];
|
|
62
|
-
|
|
63
|
-
if (modeMap[el] === null) {
|
|
64
|
-
modeMap[el] = 1;
|
|
65
|
-
} else {
|
|
66
|
-
modeMap[el]++;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (modeMap[el] > maxCount) {
|
|
70
|
-
maxEl = el;
|
|
71
|
-
maxCount = modeMap[el];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return maxEl;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* get the aspect ration occurring with the highest frequency
|
|
79
|
-
* @param tracks - video tracks to infer aspect ratios from
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const getModeAspectRatio = tracks => mode(tracks.filter(track => {
|
|
84
|
-
var _track$track, _track$track2;
|
|
85
|
-
|
|
86
|
-
return ((_track$track = track.track) == null ? void 0 : _track$track.width) && ((_track$track2 = track.track) == null ? void 0 : _track$track2.height);
|
|
87
|
-
}).map(track => {
|
|
88
|
-
var _track$track3, _track$track4;
|
|
89
|
-
|
|
90
|
-
const width = (_track$track3 = track.track) == null ? void 0 : _track$track3.width;
|
|
91
|
-
const height = (_track$track4 = track.track) == null ? void 0 : _track$track4.height; // Default to 1 if there are no video tracks
|
|
92
|
-
|
|
93
|
-
return (width || 1) / (height || 1);
|
|
94
|
-
}));
|
|
95
|
-
/**
|
|
96
|
-
* Finds the largest rectangle area when trying to place N rectangle into a containing
|
|
97
|
-
* rectangle without rotation.
|
|
98
|
-
*
|
|
99
|
-
* @param {Number} containerWidth The width of the container.
|
|
100
|
-
* @param {Number} containerHeight The height of the container.
|
|
101
|
-
* @param {Number} numRects How many rectangles must fit within.
|
|
102
|
-
* @param {Number} width The unscaled width of the rectangles to be placed.
|
|
103
|
-
* @param {Number} height The unscaled height of the rectangles to be placed.
|
|
104
|
-
* @return {Object} The area and number of rows and columns that fit.
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const largestRect = (containerWidth, containerHeight, numRects, width, height) => {
|
|
109
|
-
if (containerWidth < 0 || containerHeight < 0) {
|
|
110
|
-
throw new Error('Container must have a non-negative area');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (numRects < 1 || !Number.isInteger(numRects)) {
|
|
114
|
-
throw new Error('Number of shapes to place must be a positive integer');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const aspectRatio = width && height && width / height;
|
|
118
|
-
|
|
119
|
-
if (aspectRatio !== undefined && isNaN(aspectRatio)) {
|
|
120
|
-
throw new Error('Aspect ratio must be a number');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
let best = {
|
|
124
|
-
area: 0,
|
|
125
|
-
cols: 0,
|
|
126
|
-
rows: 0,
|
|
127
|
-
width: 0,
|
|
128
|
-
height: 0
|
|
129
|
-
}; // TODO: Don't start with obviously-`ba`d candidates.
|
|
130
|
-
|
|
131
|
-
const startCols = numRects;
|
|
132
|
-
const colDelta = -1; // For each combination of rows + cols that can fit the number of rectangles,
|
|
133
|
-
// place them and see the area.
|
|
134
|
-
|
|
135
|
-
if (aspectRatio !== undefined) {
|
|
136
|
-
for (let cols = startCols; cols > 0; cols += colDelta) {
|
|
137
|
-
const rows = Math.ceil(numRects / cols);
|
|
138
|
-
const hScale = containerWidth / (cols * aspectRatio);
|
|
139
|
-
const vScale = containerHeight / rows;
|
|
140
|
-
|
|
141
|
-
let _width;
|
|
142
|
-
|
|
143
|
-
let _height; // Determine which axis is the constraint.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (hScale <= vScale) {
|
|
147
|
-
_width = containerWidth / cols;
|
|
148
|
-
_height = _width / aspectRatio;
|
|
149
|
-
} else {
|
|
150
|
-
_height = containerHeight / rows;
|
|
151
|
-
_width = _height * aspectRatio;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const area = _width * _height;
|
|
155
|
-
|
|
156
|
-
if (area > best.area) {
|
|
157
|
-
best = {
|
|
158
|
-
area,
|
|
159
|
-
width: _width,
|
|
160
|
-
height: _height,
|
|
161
|
-
rows,
|
|
162
|
-
cols
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return best;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const getTileSizesWithColConstraint = ({
|
|
172
|
-
parentWidth,
|
|
173
|
-
parentHeight,
|
|
174
|
-
count,
|
|
175
|
-
maxCount,
|
|
176
|
-
aspectRatio
|
|
177
|
-
}) => {
|
|
178
|
-
let defaultWidth = 0;
|
|
179
|
-
let defaultHeight = 0;
|
|
180
|
-
let lastPageWidth = 0;
|
|
181
|
-
let lastPageHeight = 0;
|
|
182
|
-
let isLastPageDifferentFromFirstPage = false;
|
|
183
|
-
let tilesInFirstPage = 0;
|
|
184
|
-
let tilesinLastPage = 0;
|
|
185
|
-
const cols = Math.min(Math.ceil(Math.sqrt(count * (parentWidth / parentHeight) / (aspectRatio.width / aspectRatio.height))), maxCount);
|
|
186
|
-
const width = parentWidth / cols;
|
|
187
|
-
const height = width / (aspectRatio.width / aspectRatio.height);
|
|
188
|
-
const rows = Math.floor(parentHeight / height);
|
|
189
|
-
defaultHeight = height;
|
|
190
|
-
defaultWidth = width;
|
|
191
|
-
tilesInFirstPage = Math.min(count, rows * cols);
|
|
192
|
-
tilesinLastPage = count % (rows * cols);
|
|
193
|
-
isLastPageDifferentFromFirstPage = tilesinLastPage > 0 && count > rows * cols;
|
|
194
|
-
|
|
195
|
-
if (isLastPageDifferentFromFirstPage) {
|
|
196
|
-
const _cols = Math.min(Math.ceil(Math.sqrt(tilesinLastPage * (parentWidth / parentHeight) / (aspectRatio.width / aspectRatio.height))), maxCount);
|
|
197
|
-
|
|
198
|
-
const _width2 = parentWidth / _cols;
|
|
199
|
-
|
|
200
|
-
const _height2 = _width2 / (aspectRatio.width / aspectRatio.height);
|
|
201
|
-
|
|
202
|
-
lastPageHeight = _height2;
|
|
203
|
-
lastPageWidth = _width2;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
tilesInFirstPage,
|
|
208
|
-
defaultWidth,
|
|
209
|
-
defaultHeight,
|
|
210
|
-
lastPageWidth,
|
|
211
|
-
lastPageHeight,
|
|
212
|
-
isLastPageDifferentFromFirstPage
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const getTileSizesWithPageConstraint = ({
|
|
217
|
-
parentWidth,
|
|
218
|
-
parentHeight,
|
|
219
|
-
count,
|
|
220
|
-
maxCount,
|
|
221
|
-
aspectRatio
|
|
222
|
-
}) => {
|
|
223
|
-
let defaultWidth = 0;
|
|
224
|
-
let defaultHeight = 0;
|
|
225
|
-
let lastPageWidth = 0;
|
|
226
|
-
let lastPageHeight = 0;
|
|
227
|
-
let isLastPageDifferentFromFirstPage = false;
|
|
228
|
-
let tilesInFirstPage = 0;
|
|
229
|
-
let tilesinLastPage = 0;
|
|
230
|
-
const {
|
|
231
|
-
width: initialWidth,
|
|
232
|
-
height: initialHeight
|
|
233
|
-
} = largestRect(parentWidth, parentHeight, Math.min(count, maxCount), aspectRatio.width, aspectRatio.height);
|
|
234
|
-
defaultWidth = initialWidth;
|
|
235
|
-
defaultHeight = initialHeight;
|
|
236
|
-
tilesInFirstPage = Math.min(count, maxCount);
|
|
237
|
-
tilesinLastPage = count % maxCount;
|
|
238
|
-
isLastPageDifferentFromFirstPage = tilesinLastPage > 0 && count > maxCount;
|
|
239
|
-
|
|
240
|
-
if (isLastPageDifferentFromFirstPage) {
|
|
241
|
-
const {
|
|
242
|
-
width: remWidth,
|
|
243
|
-
height: remHeight
|
|
244
|
-
} = largestRect(parentWidth, parentHeight, tilesinLastPage, aspectRatio.width, aspectRatio.height);
|
|
245
|
-
lastPageWidth = remWidth;
|
|
246
|
-
lastPageHeight = remHeight;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
tilesInFirstPage,
|
|
251
|
-
defaultWidth,
|
|
252
|
-
defaultHeight,
|
|
253
|
-
lastPageWidth,
|
|
254
|
-
lastPageHeight,
|
|
255
|
-
isLastPageDifferentFromFirstPage
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const getTileSizesWithRowConstraint = ({
|
|
260
|
-
parentWidth,
|
|
261
|
-
parentHeight,
|
|
262
|
-
count,
|
|
263
|
-
maxCount,
|
|
264
|
-
aspectRatio
|
|
265
|
-
}) => {
|
|
266
|
-
let defaultWidth = 0;
|
|
267
|
-
let defaultHeight = 0;
|
|
268
|
-
let lastPageWidth = 0;
|
|
269
|
-
let lastPageHeight = 0;
|
|
270
|
-
let isLastPageDifferentFromFirstPage = false;
|
|
271
|
-
let tilesInFirstPage = 0;
|
|
272
|
-
let tilesinLastPage = 0;
|
|
273
|
-
const rows = Math.min(Math.ceil(Math.sqrt(count * (aspectRatio.width / aspectRatio.height) / (parentWidth / parentHeight))), maxCount);
|
|
274
|
-
const height = parentHeight / rows;
|
|
275
|
-
const width = height * (aspectRatio.width / aspectRatio.height);
|
|
276
|
-
const cols = Math.floor(parentWidth / width);
|
|
277
|
-
defaultWidth = width;
|
|
278
|
-
defaultHeight = height;
|
|
279
|
-
tilesInFirstPage = Math.min(count, rows * cols);
|
|
280
|
-
tilesinLastPage = count % (rows * cols);
|
|
281
|
-
isLastPageDifferentFromFirstPage = tilesinLastPage > 0 && count > rows * cols;
|
|
282
|
-
|
|
283
|
-
if (isLastPageDifferentFromFirstPage) {
|
|
284
|
-
const _rows = Math.min(Math.ceil(Math.sqrt(tilesinLastPage * (aspectRatio.width / aspectRatio.height) / (parentWidth / parentHeight))), maxCount);
|
|
285
|
-
|
|
286
|
-
const _height3 = parentHeight / _rows;
|
|
287
|
-
|
|
288
|
-
const _width3 = _height3 * (aspectRatio.width / aspectRatio.height);
|
|
289
|
-
|
|
290
|
-
lastPageHeight = _height3;
|
|
291
|
-
lastPageWidth = _width3;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return {
|
|
295
|
-
tilesInFirstPage,
|
|
296
|
-
defaultWidth,
|
|
297
|
-
defaultHeight,
|
|
298
|
-
lastPageWidth,
|
|
299
|
-
lastPageHeight,
|
|
300
|
-
isLastPageDifferentFromFirstPage
|
|
301
|
-
};
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
function calculateLayoutSizes({
|
|
305
|
-
count,
|
|
306
|
-
parentWidth,
|
|
307
|
-
parentHeight,
|
|
308
|
-
maxTileCount,
|
|
309
|
-
maxRowCount,
|
|
310
|
-
maxColCount,
|
|
311
|
-
aspectRatio
|
|
312
|
-
}) {
|
|
313
|
-
let defaultWidth = 0;
|
|
314
|
-
let defaultHeight = 0;
|
|
315
|
-
let lastPageWidth = 0;
|
|
316
|
-
let lastPageHeight = 0;
|
|
317
|
-
let isLastPageDifferentFromFirstPage = false;
|
|
318
|
-
let tilesInFirstPage = 0;
|
|
319
|
-
|
|
320
|
-
if (count === 0) {
|
|
321
|
-
// no tracks to show
|
|
322
|
-
return {
|
|
323
|
-
tilesInFirstPage,
|
|
324
|
-
defaultWidth,
|
|
325
|
-
defaultHeight,
|
|
326
|
-
lastPageWidth,
|
|
327
|
-
lastPageHeight,
|
|
328
|
-
isLastPageDifferentFromFirstPage
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (maxTileCount) {
|
|
333
|
-
({
|
|
334
|
-
tilesInFirstPage,
|
|
335
|
-
defaultWidth,
|
|
336
|
-
defaultHeight,
|
|
337
|
-
lastPageWidth,
|
|
338
|
-
lastPageHeight,
|
|
339
|
-
isLastPageDifferentFromFirstPage
|
|
340
|
-
} = getTileSizesWithPageConstraint({
|
|
341
|
-
parentWidth,
|
|
342
|
-
parentHeight,
|
|
343
|
-
count,
|
|
344
|
-
maxCount: maxTileCount,
|
|
345
|
-
aspectRatio
|
|
346
|
-
}));
|
|
347
|
-
} else if (maxRowCount) {
|
|
348
|
-
({
|
|
349
|
-
tilesInFirstPage,
|
|
350
|
-
defaultWidth,
|
|
351
|
-
defaultHeight,
|
|
352
|
-
lastPageWidth,
|
|
353
|
-
lastPageHeight,
|
|
354
|
-
isLastPageDifferentFromFirstPage
|
|
355
|
-
} = getTileSizesWithRowConstraint({
|
|
356
|
-
parentWidth,
|
|
357
|
-
parentHeight,
|
|
358
|
-
count,
|
|
359
|
-
maxCount: maxRowCount,
|
|
360
|
-
aspectRatio
|
|
361
|
-
}));
|
|
362
|
-
} else if (maxColCount) {
|
|
363
|
-
({
|
|
364
|
-
tilesInFirstPage,
|
|
365
|
-
defaultWidth,
|
|
366
|
-
defaultHeight,
|
|
367
|
-
lastPageWidth,
|
|
368
|
-
lastPageHeight,
|
|
369
|
-
isLastPageDifferentFromFirstPage
|
|
370
|
-
} = getTileSizesWithColConstraint({
|
|
371
|
-
parentWidth,
|
|
372
|
-
parentHeight,
|
|
373
|
-
count,
|
|
374
|
-
maxCount: maxColCount,
|
|
375
|
-
aspectRatio
|
|
376
|
-
}));
|
|
377
|
-
} else {
|
|
378
|
-
const {
|
|
379
|
-
width,
|
|
380
|
-
height
|
|
381
|
-
} = largestRect(parentWidth, parentHeight, count, aspectRatio.width, aspectRatio.height);
|
|
382
|
-
defaultWidth = width;
|
|
383
|
-
defaultHeight = height;
|
|
384
|
-
tilesInFirstPage = count;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return {
|
|
388
|
-
tilesInFirstPage,
|
|
389
|
-
defaultWidth,
|
|
390
|
-
defaultHeight,
|
|
391
|
-
lastPageWidth,
|
|
392
|
-
lastPageHeight,
|
|
393
|
-
isLastPageDifferentFromFirstPage
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const getVideoTracksFromPeers = (peers, tracks, showScreenFn) => {
|
|
398
|
-
if (!peers || !tracks || !showScreenFn) {
|
|
399
|
-
return [];
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
const videoTracks = [];
|
|
403
|
-
|
|
404
|
-
for (const peer of peers) {
|
|
405
|
-
if (peer.videoTrack === undefined && peer.audioTrack && tracks[peer.audioTrack]) {
|
|
406
|
-
videoTracks.push({
|
|
407
|
-
peer
|
|
408
|
-
});
|
|
409
|
-
} else if (peer.videoTrack && tracks[peer.videoTrack]) {
|
|
410
|
-
videoTracks.push({
|
|
411
|
-
track: tracks[peer.videoTrack],
|
|
412
|
-
peer
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (showScreenFn(peer) && peer.auxiliaryTracks.length > 0) {
|
|
417
|
-
const screenShareTrackID = peer.auxiliaryTracks.find(trackID => {
|
|
418
|
-
const track = tracks[trackID];
|
|
419
|
-
return (track == null ? void 0 : track.type) === 'video' && (track == null ? void 0 : track.source) === 'screen';
|
|
420
|
-
}); // Don't show tile if screenshare only has audio
|
|
421
|
-
|
|
422
|
-
if (screenShareTrackID) {
|
|
423
|
-
videoTracks.push({
|
|
424
|
-
track: tracks[screenShareTrackID],
|
|
425
|
-
peer
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return videoTracks;
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
export { calculateLayoutSizes, chunk, chunkElements, getModeAspectRatio, getTileSizesWithColConstraint, getTileSizesWithPageConstraint, getTileSizesWithRowConstraint, getVideoTracksFromPeers, largestRect, mode };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var HMSLogLevel;
|
|
2
|
-
|
|
3
|
-
(function (HMSLogLevel) {
|
|
4
|
-
HMSLogLevel[HMSLogLevel["VERBOSE"] = 0] = "VERBOSE";
|
|
5
|
-
HMSLogLevel[HMSLogLevel["DEBUG"] = 1] = "DEBUG";
|
|
6
|
-
HMSLogLevel[HMSLogLevel["INFO"] = 2] = "INFO";
|
|
7
|
-
HMSLogLevel[HMSLogLevel["WARN"] = 3] = "WARN";
|
|
8
|
-
HMSLogLevel[HMSLogLevel["ERROR"] = 4] = "ERROR";
|
|
9
|
-
HMSLogLevel[HMSLogLevel["NONE"] = 5] = "NONE";
|
|
10
|
-
})(HMSLogLevel || (HMSLogLevel = {}));
|
|
11
|
-
|
|
12
|
-
class HMSLogger {
|
|
13
|
-
static v(tag, ...data) {
|
|
14
|
-
this.log(HMSLogLevel.VERBOSE, tag, ...data);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static d(tag, ...data) {
|
|
18
|
-
this.log(HMSLogLevel.DEBUG, tag, ...data);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static i(tag, ...data) {
|
|
22
|
-
this.log(HMSLogLevel.INFO, tag, ...data);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static w(tag, ...data) {
|
|
26
|
-
this.log(HMSLogLevel.WARN, tag, ...data);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static e(tag, ...data) {
|
|
30
|
-
this.log(HMSLogLevel.ERROR, tag, ...data);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static log(level, tag, ...data) {
|
|
34
|
-
if (this.level.valueOf() > level.valueOf()) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
switch (level) {
|
|
39
|
-
case HMSLogLevel.VERBOSE:
|
|
40
|
-
{
|
|
41
|
-
console.log('HMSui-components: ', tag, ...data);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
case HMSLogLevel.DEBUG:
|
|
46
|
-
{
|
|
47
|
-
console.debug('HMSui-components: ', tag, ...data);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
case HMSLogLevel.INFO:
|
|
52
|
-
{
|
|
53
|
-
console.info('HMSui-components: ', tag, ...data);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
case HMSLogLevel.WARN:
|
|
58
|
-
{
|
|
59
|
-
console.warn('HMSui-components: ', tag, ...data);
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
case HMSLogLevel.ERROR:
|
|
64
|
-
{
|
|
65
|
-
console.error('HMSui-components: ', tag, ...data);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
HMSLogger.level = HMSLogLevel.VERBOSE;
|
|
74
|
-
export { HMSLogLevel, HMSLogger as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(){return t=Object.assign||function(t){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},t.apply(this,arguments)}import o,{createContext as r,useEffect as n,useContext as i,useState as e}from"react";import{HMSReactiveStore as s}from"@100mslive/hms-video-store";import c from"zustand";import{makeHMSStoreHook as a,hooksErrorMessage as f}from"./store.js";import{isBrowser as l}from"../utils/isBrowser.js";const u=r(null);let m;const w=({children:r,actions:i,store:e,notifications:a})=>{if(!m)if(i&&e)m={actions:i,store:e},a&&(m.notifications=a);else{const o=new s,r=()=>{throw new Error("modifying store is not allowed")};m={actions:o.getHMSActions(),store:c(t({},o.getStore(),{setState:r,destroy:r})),notifications:o.getNotifications()}}return n((()=>{l&&(window.onunload=()=>{m.actions.leave()})}),[]),o.createElement(u.Provider,{value:m},r)},p=a(u),d=()=>{const t=i(u);if(!t)throw new Error(f);return t.store},h=()=>{const t=i(u);if(!t)throw new Error(f);return t.actions},v=()=>{const t=i(u),[o,r]=e(null);if(!t)throw new Error(f);return n((()=>{if(!t.notifications)return;const o=t.notifications.onNotification((t=>r(t)));return o}),[t.notifications]),o};export{w as HMSRoomProvider,h as useHMSActions,v as useHMSNotifications,p as useHMSStore,d as useHMSVanillaStore};
|
package/dist/src/hooks/store.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useContext as o}from"react";import e from"../../node_modules/zustand/esm/shallow.js";import t from"../utils/logger.js";const r="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function s(s){return(i,n=e)=>{i||t.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const a=o(s);if(!a)throw new Error(r);return(0,a.store)(i,n)}}export{r as hooksErrorMessage,s as makeHMSStoreHook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{selectIsLocalAudioEnabled as o,selectIsLocalVideoEnabled as e,selectIsAllowedToPublish as t}from"@100mslive/hms-video-store";import{useCallback as r}from"react";import{useHMSStore as a,useHMSActions as i}from"./HmsRoomProvider.js";const l=()=>{const l=a(o),s=a(e),c=a(t),d=i(),n=r((async()=>{try{await d.setLocalAudioEnabled(!l)}catch(o){console.error("Cannot toggle audio",o)}}),[l]),m=r((async()=>{try{await d.setLocalVideoEnabled(!s)}catch(o){console.error("Cannot toggle video",o)}}),[s]);return{isLocalAudioEnabled:l,isLocalVideoEnabled:s,toggleAudio:n,toggleVideo:m,isAllowedToPublish:c}};export{l as useAVToggle};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useEffect as r}from"react";import{selectTrackAudioByID as o}from"@100mslive/hms-video-store";import{useHMSVanillaStore as t}from"./HmsRoomProvider.js";function e({trackId:e,getStyle:s,ref:c}){const i=t();r((()=>i.subscribe((r=>{if(!c.current)return;const o=s(r);console.log(o,r);for(const r in o)c.current.style[r]=o[r]}),o(e))),[e])}export{e as useAudioLevel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{selectDevices as e,selectLocalMediaSettings as t,selectIsAllowedToPublish as i,selectIsAllowedToSubscribe as o}from"@100mslive/hms-video-store";import{useHMSActions as u,useHMSStore as d}from"./HmsRoomProvider.js";const s=()=>{const s=u(),n=d(e),r=d(t),{video:a,audio:c}=d(i),v=d(o),p=n.videoInput||[],I=n.audioInput||[],m=n.audioOutput||[];return[a,c,v].some((e=>!!e))?{showVideo:a,videoInput:p,showAudio:c,audioInput:I,audioOutput:m,isSubscribing:v,selectedDevices:r,handleInputChange:e=>{const t=e.currentTarget.value,{name:i}=e.currentTarget;if(t!==r[i])switch(i){case"audioInputDeviceId":s.setAudioSettings({deviceId:t});break;case"videoInputDeviceId":s.setVideoSettings({deviceId:t});break;case"audioOutputDeviceId":s.setAudioOutputDevice(t)}}}:null};export{s as useDevices};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isBrowser as e}from"@100mslive/hms-video";import{selectLocalPeer as o,selectRoomState as r,selectIsLocalAudioEnabled as i,selectIsLocalVideoDisplayEnabled as s,selectIsAllowedToPublish as m,HMSRoomState as t}from"@100mslive/hms-video-store";import{useState as n,useEffect as a}from"react";import{useHMSActions as d,useHMSStore as l}from"./HmsRoomProvider.js";const v=(v,c="preview")=>{const[p,u]=n(!1),w=d(),P=l(o),b=l(r),f=l(i),h=l(s),E=l(m),T=p||b!==t.Preview;return a((()=>{b===t.Disconnected&&w.preview({userName:c,authToken:v}),e&&(window.onunload=()=>w.leave())}),[b,w,v]),{localPeer:P,roomState:b,audioEnabled:f,videoEnabled:h,isAllowedToPublish:E,disableJoin:T,actions:w,setInProgress:u}};export{v as usePreview};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{selectTrackByID as o}from"@100mslive/hms-video-store";import{useRef as e,useCallback as r,useEffect as i}from"react";import{useInView as t}from"react-intersection-observer";import{useHMSActions as n,useHMSStore as l}from"./HmsRoomProvider.js";const d=d=>{const c=n(),s=e(null),{ref:a,inView:m}=t({threshold:.5}),u=r((o=>{s.current=o,a(o)}),[a]),v=l(o(d));return i((()=>{(async()=>{s.current&&v&&(m&&v.enabled?(console.log("****** ENABLE VIDEO *******"),await c.attachVideo(v.id,s.current)):(console.log("****** DETACH VIDEO *******"),await c.detachVideo(v.id,s.current)))})()}),[m,s,null==v?void 0:v.id,null==v?void 0:v.enabled,null==v?void 0:v.deviceID,null==v?void 0:v.plugins]),u};export{d as useVideo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{selectTracksMap as t}from"@100mslive/hms-video-store";import{useMemo as e}from"react";import{getVideoTracksFromPeers as o,getModeAspectRatio as a,calculateLayoutSizes as i,chunkElements as r}from"../utils/layout.js";import{useHMSVanillaStore as s}from"./HmsRoomProvider.js";const n=({maxTileCount:n,maxColCount:l,maxRowCount:h,width:m,height:g,showScreenFn:u=(()=>!1),peers:d,overflow:f="scroll-x",aspectRatio:P})=>{const c=s().getState(t),p=o(d,c,u),x=e((()=>{if(P)return P;return{width:a(p)||1,height:1}}),[P,p]),C=p.length,{tilesInFirstPage:F,defaultWidth:w,defaultHeight:H,lastPageWidth:W,lastPageHeight:R,isLastPageDifferentFromFirstPage:v}=e((()=>i({count:C,parentWidth:Math.floor(m),parentHeight:Math.floor(g),maxTileCount:n,maxRowCount:h,maxColCount:l,aspectRatio:x})),[C,m,g,n,h,l,x]);return{chunkedTracksWithPeer:e((()=>r({elements:p,tilesInFirstPage:F,onlyOnePage:"hidden"===f,isLastPageDifferentFromFirstPage:v,defaultWidth:w,defaultHeight:H,lastPageWidth:W,lastPageHeight:R})),[p,F,f,v,w,H,W,R])}};export{n as useVideoList};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { selectTracksMap } from '@100mslive/hms-video-store';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { getVideoTracksFromPeers, getModeAspectRatio, calculateLayoutSizes, chunkElements } from '../utils/layout.js';
|
|
4
|
-
import { useHMSVanillaStore } from './HmsRoomProvider.js';
|
|
5
|
-
|
|
6
|
-
const useVideoList = ({
|
|
7
|
-
maxTileCount,
|
|
8
|
-
maxColCount,
|
|
9
|
-
maxRowCount,
|
|
10
|
-
width,
|
|
11
|
-
height,
|
|
12
|
-
showScreenFn,
|
|
13
|
-
peers,
|
|
14
|
-
overflow,
|
|
15
|
-
aspectRatio
|
|
16
|
-
}) => {
|
|
17
|
-
const store = useHMSVanillaStore();
|
|
18
|
-
const tracksMap = store.getState(selectTracksMap);
|
|
19
|
-
const tracksWithPeer = getVideoTracksFromPeers(peers, tracksMap, showScreenFn);
|
|
20
|
-
const finalAspectRatio = useMemo(() => {
|
|
21
|
-
if (aspectRatio) {
|
|
22
|
-
return aspectRatio;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const modeAspectRatio = getModeAspectRatio(tracksWithPeer); // Default to 1 if there are no video tracks
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
width: modeAspectRatio || 1,
|
|
29
|
-
height: 1
|
|
30
|
-
};
|
|
31
|
-
}, [aspectRatio, tracksWithPeer]);
|
|
32
|
-
const count = tracksWithPeer.length;
|
|
33
|
-
const {
|
|
34
|
-
tilesInFirstPage,
|
|
35
|
-
defaultWidth,
|
|
36
|
-
defaultHeight,
|
|
37
|
-
lastPageWidth,
|
|
38
|
-
lastPageHeight,
|
|
39
|
-
isLastPageDifferentFromFirstPage
|
|
40
|
-
} = useMemo(() => // Flooring since there's a bug in react-slick where it converts widdh into a number
|
|
41
|
-
calculateLayoutSizes({
|
|
42
|
-
count,
|
|
43
|
-
parentWidth: Math.floor(width),
|
|
44
|
-
parentHeight: Math.floor(height),
|
|
45
|
-
maxTileCount,
|
|
46
|
-
maxRowCount,
|
|
47
|
-
maxColCount,
|
|
48
|
-
aspectRatio: finalAspectRatio
|
|
49
|
-
}), [count, width, height, maxTileCount, maxRowCount, maxColCount, finalAspectRatio]);
|
|
50
|
-
const chunkedTracksWithPeer = useMemo(() => chunkElements({
|
|
51
|
-
elements: tracksWithPeer,
|
|
52
|
-
tilesInFirstPage,
|
|
53
|
-
onlyOnePage: overflow === 'hidden',
|
|
54
|
-
isLastPageDifferentFromFirstPage,
|
|
55
|
-
defaultWidth,
|
|
56
|
-
defaultHeight,
|
|
57
|
-
lastPageWidth,
|
|
58
|
-
lastPageHeight
|
|
59
|
-
}), [tracksWithPeer, tilesInFirstPage, overflow, isLastPageDifferentFromFirstPage, defaultWidth, defaultHeight, lastPageWidth, lastPageHeight]);
|
|
60
|
-
return {
|
|
61
|
-
chunkedTracksWithPeer
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export { useVideoList };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{selectVideoTrackByPeerID as i,selectIsPeerAudioEnabled as o,selectIsPeerVideoEnabled as e,selectPeerAudioByID as r}from"@100mslive/hms-video-store";import{useRef as d,useEffect as t}from"react";import{useHMSActions as n,useHMSStore as m}from"./HmsRoomProvider.js";const s=s=>{const a=n(),c=d(null),l=m(i(s.id)),u=m(o(s.id)),v=m(e(s.id)),{isLocal:f,name:p}=s,h=m(r(s.id))>0;return t((()=>{c.current&&l&&(l.enabled?a.attachVideo(l.id,c.current):a.detachVideo(l.id,c.current))}),[l,a]),{videoRef:c,isAudioOn:u,isVideoOn:v,actions:a,isLocal:f,name:p,audioLevel:h}};export{s as useVideoTile};
|
package/dist/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{HMSRoomProvider,useHMSActions,useHMSNotifications,useHMSStore,useHMSVanillaStore}from"./hooks/HmsRoomProvider.js";export{calculateLayoutSizes,chunkElements,getModeAspectRatio}from"./utils/layout.js";export{usePreview}from"./hooks/usePreview.js";export{useVideoTile}from"./hooks/useVideoTile.js";export{useVideoList}from"./hooks/useVideoList.js";export{useAVToggle}from"./hooks/useAVToggle.js";export{useDevices}from"./hooks/useDevices.js";export{useVideo}from"./hooks/useVideo.js";export{useAudioLevel}from"./hooks/useAudioLevel.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e="undefined"!=typeof window;export{e as isBrowser};
|
package/dist/src/utils/layout.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},t.apply(this,arguments)}const e=(t,e,i)=>t.reduce(((t,a,r)=>{const h=Math.floor(r/e);return h>0&&i||(t[h]||(t[h]=[]),t[h].push(a)),t}),[]),i=({elements:i,tilesInFirstPage:a,onlyOnePage:r,isLastPageDifferentFromFirstPage:h,defaultWidth:n,defaultHeight:s,lastPageWidth:o,lastPageHeight:g})=>{const l=e(i,a,r);return l.map(((e,i)=>e.map((e=>{const a=i===l.length-1;return t({},e,{height:h&&a?g:s,width:h&&a?o:n})}))))};function a(t){if(0===t.length)return null;const e={};let i=t[0],a=1;for(let r=0;r<t.length;r++){const h=t[r];null===e[h]?e[h]=1:e[h]++,e[h]>a&&(i=h,a=e[h])}return i}const r=t=>a(t.filter((t=>{var e,i;return(null==(e=t.track)?void 0:e.width)&&(null==(i=t.track)?void 0:i.height)})).map((t=>{var e,i;return((null==(e=t.track)?void 0:e.width)||1)/((null==(i=t.track)?void 0:i.height)||1)}))),h=(t,e,i,a,r)=>{if(t<0||e<0)throw new Error("Container must have a non-negative area");if(i<1||!Number.isInteger(i))throw new Error("Number of shapes to place must be a positive integer");const h=a&&r&&a/r;if(void 0!==h&&isNaN(h))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0};if(void 0!==h)for(let a=i;a>0;a+=-1){const r=Math.ceil(i/a);let s,o;t/(a*h)<=e/r?(s=t/a,o=s/h):(o=e/r,s=o*h);const g=s*o;g>n.area&&(n={area:g,width:s,height:o,rows:r,cols:a})}return n},n=({parentWidth:t,parentHeight:e,count:i,maxCount:a,aspectRatio:r})=>{let h=0,n=0,s=0,o=0,g=!1,l=0,d=0;const u=Math.min(Math.ceil(Math.sqrt(i*(t/e)/(r.width/r.height))),a),c=t/u,f=c/(r.width/r.height),P=Math.floor(e/f);if(n=f,h=c,l=Math.min(i,P*u),d=i%(P*u),g=d>0&&i>P*u,g){const i=t/Math.min(Math.ceil(Math.sqrt(d*(t/e)/(r.width/r.height))),a);o=i/(r.width/r.height),s=i}return{tilesInFirstPage:l,defaultWidth:h,defaultHeight:n,lastPageWidth:s,lastPageHeight:o,isLastPageDifferentFromFirstPage:g}},s=({parentWidth:t,parentHeight:e,count:i,maxCount:a,aspectRatio:r})=>{let n=0,s=0,o=0,g=0,l=!1,d=0,u=0;const{width:c,height:f}=h(t,e,Math.min(i,a),r.width,r.height);if(n=c,s=f,d=Math.min(i,a),u=i%a,l=u>0&&i>a,l){const{width:i,height:a}=h(t,e,u,r.width,r.height);o=i,g=a}return{tilesInFirstPage:d,defaultWidth:n,defaultHeight:s,lastPageWidth:o,lastPageHeight:g,isLastPageDifferentFromFirstPage:l}},o=({parentWidth:t,parentHeight:e,count:i,maxCount:a,aspectRatio:r})=>{let h=0,n=0,s=0,o=0,g=!1,l=0,d=0;const u=Math.min(Math.ceil(Math.sqrt(i*(r.width/r.height)/(t/e))),a),c=e/u,f=c*(r.width/r.height),P=Math.floor(t/f);if(h=f,n=c,l=Math.min(i,u*P),d=i%(u*P),g=d>0&&i>u*P,g){const i=e/Math.min(Math.ceil(Math.sqrt(d*(r.width/r.height)/(t/e))),a);o=i,s=i*(r.width/r.height)}return{tilesInFirstPage:l,defaultWidth:h,defaultHeight:n,lastPageWidth:s,lastPageHeight:o,isLastPageDifferentFromFirstPage:g}};function g({count:t,parentWidth:e,parentHeight:i,maxTileCount:a,maxRowCount:r,maxColCount:g,aspectRatio:l}){let d=0,u=0,c=0,f=0,P=!1,p=0;if(0===t)return{tilesInFirstPage:p,defaultWidth:d,defaultHeight:u,lastPageWidth:c,lastPageHeight:f,isLastPageDifferentFromFirstPage:P};if(a)({tilesInFirstPage:p,defaultWidth:d,defaultHeight:u,lastPageWidth:c,lastPageHeight:f,isLastPageDifferentFromFirstPage:P}=s({parentWidth:e,parentHeight:i,count:t,maxCount:a,aspectRatio:l}));else if(r)({tilesInFirstPage:p,defaultWidth:d,defaultHeight:u,lastPageWidth:c,lastPageHeight:f,isLastPageDifferentFromFirstPage:P}=o({parentWidth:e,parentHeight:i,count:t,maxCount:r,aspectRatio:l}));else if(g)({tilesInFirstPage:p,defaultWidth:d,defaultHeight:u,lastPageWidth:c,lastPageHeight:f,isLastPageDifferentFromFirstPage:P}=n({parentWidth:e,parentHeight:i,count:t,maxCount:g,aspectRatio:l}));else{const{width:a,height:r}=h(e,i,t,l.width,l.height);d=a,u=r,p=t}return{tilesInFirstPage:p,defaultWidth:d,defaultHeight:u,lastPageWidth:c,lastPageHeight:f,isLastPageDifferentFromFirstPage:P}}const l=(t,e,i)=>{if(!t||!e||!i)return[];const a=[];for(const r of t)if(void 0===r.videoTrack&&r.audioTrack&&e[r.audioTrack]?a.push({peer:r}):r.videoTrack&&e[r.videoTrack]&&a.push({track:e[r.videoTrack],peer:r}),i(r)&&r.auxiliaryTracks.length>0){const t=r.auxiliaryTracks.find((t=>{const i=e[t];return"video"===(null==i?void 0:i.type)&&"screen"===(null==i?void 0:i.source)}));t&&a.push({track:e[t],peer:r})}return a};export{g as calculateLayoutSizes,e as chunk,i as chunkElements,r as getModeAspectRatio,n as getTileSizesWithColConstraint,s as getTileSizesWithPageConstraint,o as getTileSizesWithRowConstraint,l as getVideoTracksFromPeers,h as largestRect,a as mode};
|
package/dist/src/utils/logger.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o;!function(o){o[o.VERBOSE=0]="VERBOSE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.ERROR=4]="ERROR",o[o.NONE=5]="NONE"}(o||(o={}));class s{static v(s,...e){this.log(o.VERBOSE,s,...e)}static d(s,...e){this.log(o.DEBUG,s,...e)}static i(s,...e){this.log(o.INFO,s,...e)}static w(s,...e){this.log(o.WARN,s,...e)}static e(s,...e){this.log(o.ERROR,s,...e)}static log(s,e,...t){if(!(this.level.valueOf()>s.valueOf()))switch(s){case o.VERBOSE:console.log("HMSui-components: ",e,...t);break;case o.DEBUG:console.debug("HMSui-components: ",e,...t);break;case o.INFO:console.info("HMSui-components: ",e,...t);break;case o.WARN:console.warn("HMSui-components: ",e,...t);break;case o.ERROR:console.error("HMSui-components: ",e,...t)}}}s.level=o.VERBOSE;export{o as HMSLogLevel,s as default};
|