mediasfu-shared 1.0.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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/index.cjs +7707 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7285 -0
- package/dist/index.js +7690 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
- package/src/ProducerClient/producerClientEmits/createDeviceClient.ts +68 -0
- package/src/consumers/addVideosGrid.ts +18 -0
- package/src/consumers/autoAdjust.ts +100 -0
- package/src/consumers/calculateRowsAndColumns.ts +51 -0
- package/src/consumers/changeVids.ts +753 -0
- package/src/consumers/checkGrid.ts +100 -0
- package/src/consumers/checkPermission.ts +89 -0
- package/src/consumers/checkScreenShare.ts +114 -0
- package/src/consumers/closeAndResize.ts +401 -0
- package/src/consumers/compareActiveNames.ts +122 -0
- package/src/consumers/compareScreenStates.ts +117 -0
- package/src/consumers/connectIps.ts +175 -0
- package/src/consumers/connectLocalIps.ts +103 -0
- package/src/consumers/connectRecvTransport.ts +158 -0
- package/src/consumers/connectSendTransport.ts +150 -0
- package/src/consumers/connectSendTransportAudio.ts +161 -0
- package/src/consumers/connectSendTransportScreen.ts +169 -0
- package/src/consumers/connectSendTransportVideo.ts +149 -0
- package/src/consumers/consumerResume.ts +25 -0
- package/src/consumers/controlMedia.ts +118 -0
- package/src/consumers/createSendTransport.ts +312 -0
- package/src/consumers/disconnectSendTransportAudio.ts +170 -0
- package/src/consumers/disconnectSendTransportScreen.ts +130 -0
- package/src/consumers/disconnectSendTransportVideo.ts +161 -0
- package/src/consumers/dispStreams.ts +694 -0
- package/src/consumers/generatePageContent.ts +118 -0
- package/src/consumers/getEstimate.ts +124 -0
- package/src/consumers/getPipedProducersAlt.ts +96 -0
- package/src/consumers/getProducersPiped.ts +89 -0
- package/src/consumers/getVideos.ts +107 -0
- package/src/consumers/mixStreams.ts +97 -0
- package/src/consumers/onScreenChanges.ts +106 -0
- package/src/consumers/prepopulateUserMedia.ts +18 -0
- package/src/consumers/processConsumerTransports.ts +157 -0
- package/src/consumers/processConsumerTransportsAudio.ts +121 -0
- package/src/consumers/rePort.ts +123 -0
- package/src/consumers/reUpdateInter.ts +289 -0
- package/src/consumers/readjust.ts +170 -0
- package/src/consumers/receiveAllPipedTransports.ts +77 -0
- package/src/consumers/receiveRoomMessages.ts +55 -0
- package/src/consumers/reorderStreams.ts +246 -0
- package/src/consumers/requestScreenShare.ts +103 -0
- package/src/consumers/resumePauseAudioStreams.ts +174 -0
- package/src/consumers/resumePauseStreams.ts +110 -0
- package/src/consumers/resumeSendTransportAudio.ts +143 -0
- package/src/consumers/signalNewConsumerTransport.ts +179 -0
- package/src/consumers/socketReceiveMethods/joinConsumeRoom.ts +130 -0
- package/src/consumers/socketReceiveMethods/newPipeProducer.ts +138 -0
- package/src/consumers/socketReceiveMethods/producerClosed.ts +102 -0
- package/src/consumers/startShareScreen.ts +124 -0
- package/src/consumers/stopShareScreen.ts +241 -0
- package/src/consumers/streamSuccessAudio.ts +297 -0
- package/src/consumers/streamSuccessAudioSwitch.ts +315 -0
- package/src/consumers/streamSuccessScreen.ts +255 -0
- package/src/consumers/streamSuccessVideo.ts +373 -0
- package/src/consumers/switchUserAudio.ts +140 -0
- package/src/consumers/switchUserVideo.ts +201 -0
- package/src/consumers/switchUserVideoAlt.ts +331 -0
- package/src/consumers/trigger.ts +250 -0
- package/src/consumers/updateMiniCardsGrid.ts +150 -0
- package/src/consumers/updateParticipantAudioDecibels.ts +56 -0
- package/src/index.ts +119 -0
- package/src/methods/background/launchBackground.ts +16 -0
- package/src/methods/breakoutRooms/breakoutRoomUpdated.ts +161 -0
- package/src/methods/breakoutRooms/handleStartBreakout.ts +96 -0
- package/src/methods/breakoutRooms/handleStopBreakout.ts +72 -0
- package/src/methods/breakoutRooms/index.ts +4 -0
- package/src/methods/breakoutRooms/launchBreakoutRooms.ts +31 -0
- package/src/methods/coHost/launchCoHost.ts +28 -0
- package/src/methods/coHostMethods/index.ts +2 -0
- package/src/methods/coHostMethods/modifyCoHostSettings.ts +94 -0
- package/src/methods/displaySettings/index.ts +1 -0
- package/src/methods/displaySettings/launchDisplaySettings.ts +31 -0
- package/src/methods/displaySettings/modifyDisplaySettings.ts +242 -0
- package/src/methods/exit/confirmExit.ts +60 -0
- package/src/methods/exit/index.ts +2 -0
- package/src/methods/exit/launchConfirmExit.ts +29 -0
- package/src/methods/index.ts +5 -0
- package/src/methods/mediaSettings/launchMediaSettings.ts +61 -0
- package/src/methods/menu/launchMenuModal.ts +28 -0
- package/src/methods/message/index.ts +1 -0
- package/src/methods/message/launchMessages.ts +27 -0
- package/src/methods/message/sendMessage.ts +175 -0
- package/src/methods/participants/index.ts +3 -0
- package/src/methods/participants/launchParticipants.ts +25 -0
- package/src/methods/participants/messageParticipants.ts +78 -0
- package/src/methods/participants/muteParticipants.ts +79 -0
- package/src/methods/participants/removeParticipants.ts +97 -0
- package/src/methods/polls/handleCreatePoll.ts +66 -0
- package/src/methods/polls/handleEndPoll.ts +64 -0
- package/src/methods/polls/handleVotePoll.ts +76 -0
- package/src/methods/polls/index.ts +3 -0
- package/src/methods/polls/launchPoll.ts +25 -0
- package/src/methods/prejoin/handleCreateRoom.ts +441 -0
- package/src/methods/prejoin/handleJoinRoom.ts +153 -0
- package/src/methods/prejoin/index.ts +14 -0
- package/src/methods/recording/checkPauseState.ts +57 -0
- package/src/methods/recording/checkResumeState.ts +42 -0
- package/src/methods/recording/confirmRecording.ts +241 -0
- package/src/methods/recording/launchRecording.ts +114 -0
- package/src/methods/recording/recordPauseTimer.ts +52 -0
- package/src/methods/recording/recordResumeTimer.ts +92 -0
- package/src/methods/recording/recordStartTimer.ts +106 -0
- package/src/methods/recording/recordUpdateTimer.ts +49 -0
- package/src/methods/recording/startRecording.ts +268 -0
- package/src/methods/recording/stopRecording.ts +124 -0
- package/src/methods/recording/updateRecording.ts +245 -0
- package/src/methods/requests/index.ts +1 -0
- package/src/methods/requests/launchRequests.ts +25 -0
- package/src/methods/requests/respondToRequests.ts +108 -0
- package/src/methods/settings/index.ts +2 -0
- package/src/methods/settings/launchSettings.ts +25 -0
- package/src/methods/settings/modifySettings.ts +99 -0
- package/src/methods/stream/clickVideo.ts +337 -0
- package/src/methods/stream/index.ts +3 -0
- package/src/methods/stream/switchAudio.ts +73 -0
- package/src/methods/stream/switchVideo.ts +148 -0
- package/src/methods/stream/switchVideoAlt.ts +152 -0
- package/src/methods/utils/checkLimitsAndMakeRequest.ts +103 -0
- package/src/methods/utils/validateAlphanumeric.ts +41 -0
- package/src/methods/waiting/index.ts +1 -0
- package/src/methods/waiting/launchWaiting.ts +26 -0
- package/src/methods/waiting/respondToWaiting.ts +82 -0
- package/src/methods/welcome/handleWelcomeRequest.ts +189 -0
- package/src/methods/welcome/index.ts +5 -0
- package/src/methods/whiteboard/handleStartWhiteboard.ts +65 -0
- package/src/methods/whiteboard/handleStopWhiteboard.ts +48 -0
- package/src/methods/whiteboard/index.ts +4 -0
- package/src/methods/whiteboard/launchConfigureWhiteboard.ts +29 -0
- package/src/producers/producerEmits/joinConRoom.ts +153 -0
- package/src/sockets/SocketManager.ts +232 -0
- package/src/types/shared-base-types.ts +752 -0
- package/src/types/types.ts +84 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
import { Participant, AutoAdjustType, ScreenState, EventType } from "../types/types";
|
|
3
|
+
|
|
4
|
+
export interface TriggerParameters {
|
|
5
|
+
socket: Socket;
|
|
6
|
+
localSocket?: Socket;
|
|
7
|
+
roomName: string;
|
|
8
|
+
screenStates: ScreenState[];
|
|
9
|
+
participants: Participant[];
|
|
10
|
+
updateDateState?: number | null;
|
|
11
|
+
lastUpdate: number | null;
|
|
12
|
+
nForReadjust: number | null;
|
|
13
|
+
eventType: EventType;
|
|
14
|
+
shared: boolean;
|
|
15
|
+
shareScreenStarted: boolean;
|
|
16
|
+
whiteboardStarted: boolean;
|
|
17
|
+
whiteboardEnded: boolean;
|
|
18
|
+
updateUpdateDateState: (timestamp: number | null) => void;
|
|
19
|
+
updateLastUpdate: (lastUpdate: number | null) => void;
|
|
20
|
+
updateNForReadjust: (nForReadjust: number) => void;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// mediasfu functions
|
|
24
|
+
autoAdjust: AutoAdjustType;
|
|
25
|
+
|
|
26
|
+
getUpdatedAllParams: () => TriggerParameters;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TriggerOptions {
|
|
31
|
+
ref_ActiveNames: string[];
|
|
32
|
+
parameters: TriggerParameters;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Export the type definition for the function
|
|
36
|
+
export type TriggerType = (options: TriggerOptions) => Promise<void>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Triggers an update to the screen client based on the provided parameters.
|
|
40
|
+
*
|
|
41
|
+
* @param {TriggerOptions} options - The options for triggering the update.
|
|
42
|
+
* @param {string[]} options.ref_ActiveNames - Reference to the active names.
|
|
43
|
+
* @param {TriggerParameters} options.parameters - The parameters for the trigger.
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<void>} A promise that resolves when the trigger is complete.
|
|
46
|
+
*
|
|
47
|
+
* @throws Will throw an error if the updateScreenClient operation fails.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* This function handles various conditions to determine the main screen person,
|
|
51
|
+
* adjusts the screen states, and emits an update to the screen client via socket.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* await trigger({
|
|
56
|
+
* ref_ActiveNames: ["user1", "user2"],
|
|
57
|
+
* parameters: {
|
|
58
|
+
* socket: socketInstance,
|
|
59
|
+
* localSocket: localSocketInstance,
|
|
60
|
+
* roomName: "room1",
|
|
61
|
+
* screenStates: [{ mainScreenPerson: "user1", mainScreenFilled: true, adminOnMainScreen: false }],
|
|
62
|
+
* participants: [{ name: "admin", islevel: "2" }],
|
|
63
|
+
* updateDateState: 0,
|
|
64
|
+
* lastUpdate: null,
|
|
65
|
+
* nForReadjust: 0,
|
|
66
|
+
* eventType: "conference",
|
|
67
|
+
* shared: false,
|
|
68
|
+
* shareScreenStarted: false,
|
|
69
|
+
* whiteboardStarted: false,
|
|
70
|
+
* whiteboardEnded: false,
|
|
71
|
+
* updateUpdateDateState: (date) => {},
|
|
72
|
+
* updateLastUpdate: (date) => {},
|
|
73
|
+
* updateNForReadjust: (n) => {},
|
|
74
|
+
* autoAdjust: async ({ n, parameters }) => [n, 0],
|
|
75
|
+
* },
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
export async function trigger({
|
|
81
|
+
ref_ActiveNames,
|
|
82
|
+
parameters,
|
|
83
|
+
}: TriggerOptions): Promise<void> {
|
|
84
|
+
try {
|
|
85
|
+
parameters = parameters.getUpdatedAllParams();
|
|
86
|
+
|
|
87
|
+
let {
|
|
88
|
+
socket,
|
|
89
|
+
localSocket,
|
|
90
|
+
roomName,
|
|
91
|
+
screenStates,
|
|
92
|
+
participants,
|
|
93
|
+
updateDateState,
|
|
94
|
+
lastUpdate,
|
|
95
|
+
nForReadjust,
|
|
96
|
+
eventType,
|
|
97
|
+
shared,
|
|
98
|
+
shareScreenStarted,
|
|
99
|
+
whiteboardStarted,
|
|
100
|
+
whiteboardEnded,
|
|
101
|
+
updateUpdateDateState,
|
|
102
|
+
updateLastUpdate,
|
|
103
|
+
updateNForReadjust,
|
|
104
|
+
|
|
105
|
+
//mediasfu functions
|
|
106
|
+
autoAdjust,
|
|
107
|
+
} = parameters;
|
|
108
|
+
|
|
109
|
+
let socketRef = socket;
|
|
110
|
+
if (localSocket && localSocket.id) {
|
|
111
|
+
socketRef = localSocket;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let personOnMainScreen = screenStates[0].mainScreenPerson;
|
|
115
|
+
let adminName = "";
|
|
116
|
+
const admin = participants.filter(
|
|
117
|
+
(participant) => participant.islevel == "2"
|
|
118
|
+
);
|
|
119
|
+
if (admin.length > 0) {
|
|
120
|
+
adminName = admin[0].name || "";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (personOnMainScreen === "WhiteboardActive") {
|
|
124
|
+
personOnMainScreen = adminName;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let mainfilled = screenStates[0].mainScreenFilled;
|
|
128
|
+
let adminOnMain = screenStates[0].adminOnMainScreen;
|
|
129
|
+
let nForReadjust_: number;
|
|
130
|
+
let val1: number;
|
|
131
|
+
|
|
132
|
+
let noww = new Date().getTime();
|
|
133
|
+
//get now in seconds
|
|
134
|
+
let timestamp = Math.floor(noww / 1000);
|
|
135
|
+
|
|
136
|
+
let eventPass = false;
|
|
137
|
+
|
|
138
|
+
if (eventType == "conference" && !(shared || shareScreenStarted)) {
|
|
139
|
+
eventPass = true;
|
|
140
|
+
personOnMainScreen = adminName;
|
|
141
|
+
|
|
142
|
+
if (!ref_ActiveNames.includes(adminName)) {
|
|
143
|
+
ref_ActiveNames.unshift(adminName);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if ((mainfilled && personOnMainScreen != null && adminOnMain) || eventPass) {
|
|
148
|
+
if (eventType == "conference") {
|
|
149
|
+
nForReadjust = nForReadjust! + 1;
|
|
150
|
+
updateNForReadjust(nForReadjust);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!ref_ActiveNames.includes(adminName) && whiteboardStarted && !whiteboardEnded) {
|
|
154
|
+
ref_ActiveNames.unshift(adminName);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
nForReadjust_ = ref_ActiveNames.length;
|
|
158
|
+
|
|
159
|
+
if (nForReadjust_ == 0 && eventType == "webinar") {
|
|
160
|
+
val1 = 0;
|
|
161
|
+
} else {
|
|
162
|
+
const [val11, ] = await autoAdjust({
|
|
163
|
+
n: nForReadjust_,
|
|
164
|
+
eventType,
|
|
165
|
+
shared,
|
|
166
|
+
shareScreenStarted,
|
|
167
|
+
});
|
|
168
|
+
val1 = val11;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let calc1 = Math.floor((val1 / 12) * 100);
|
|
172
|
+
let calc2 = (100) - calc1;
|
|
173
|
+
|
|
174
|
+
//check if lastUpdate is not null and at least same seconds
|
|
175
|
+
if (lastUpdate == null || updateDateState != timestamp) {
|
|
176
|
+
let now = new Date();
|
|
177
|
+
|
|
178
|
+
socketRef.emit(
|
|
179
|
+
"updateScreenClient",
|
|
180
|
+
{
|
|
181
|
+
roomName,
|
|
182
|
+
names: ref_ActiveNames,
|
|
183
|
+
mainPercent: calc2,
|
|
184
|
+
mainScreenPerson: personOnMainScreen,
|
|
185
|
+
viewType: eventType,
|
|
186
|
+
},
|
|
187
|
+
({ success, reason }: { success: boolean; reason: string; }) => {
|
|
188
|
+
updateDateState = timestamp;
|
|
189
|
+
updateUpdateDateState(updateDateState);
|
|
190
|
+
lastUpdate = Math.floor(now.getTime() / 1000);
|
|
191
|
+
updateLastUpdate(lastUpdate);
|
|
192
|
+
if (!success) {
|
|
193
|
+
console.log(reason, "updateScreenClient failed");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
} else if (mainfilled && personOnMainScreen != null && !adminOnMain) {
|
|
199
|
+
//check if the person on main screen is still in the room
|
|
200
|
+
// ss = true
|
|
201
|
+
|
|
202
|
+
nForReadjust_ = ref_ActiveNames.length;
|
|
203
|
+
|
|
204
|
+
if (!ref_ActiveNames.includes(adminName)) {
|
|
205
|
+
ref_ActiveNames.unshift(adminName);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const [val11, ] = await autoAdjust({
|
|
209
|
+
n: nForReadjust_,
|
|
210
|
+
eventType,
|
|
211
|
+
shared,
|
|
212
|
+
shareScreenStarted,
|
|
213
|
+
});
|
|
214
|
+
val1 = val11;
|
|
215
|
+
|
|
216
|
+
const calc1 = Math.floor((val1 / 12) * 100);
|
|
217
|
+
const calc2 = 100 - calc1;
|
|
218
|
+
|
|
219
|
+
if (lastUpdate == null || updateDateState !== timestamp) {
|
|
220
|
+
let now = new Date();
|
|
221
|
+
|
|
222
|
+
socketRef.emit(
|
|
223
|
+
"updateScreenClient",
|
|
224
|
+
{
|
|
225
|
+
roomName,
|
|
226
|
+
names: ref_ActiveNames,
|
|
227
|
+
mainPercent: calc2,
|
|
228
|
+
mainScreenPerson: personOnMainScreen,
|
|
229
|
+
viewType: eventType,
|
|
230
|
+
},
|
|
231
|
+
({ success, reason }: { success: boolean; reason: string; }) => {
|
|
232
|
+
updateDateState = timestamp;
|
|
233
|
+
updateUpdateDateState(updateDateState);
|
|
234
|
+
lastUpdate = Math.floor(now.getTime() / 1000);
|
|
235
|
+
updateLastUpdate(lastUpdate);
|
|
236
|
+
if (!success) {
|
|
237
|
+
console.log(reason, "updateScreenClient failed");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
//stop recording
|
|
244
|
+
console.log("trigger stopRecording");
|
|
245
|
+
}
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.log("Error triggering updateScreen:", error);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { GridSizes, ComponentSizes, EventType } from "../types/types";
|
|
2
|
+
export interface UpdateMiniCardsGridParameters {
|
|
3
|
+
updateGridRows: (rows: number) => void;
|
|
4
|
+
updateGridCols: (cols: number) => void;
|
|
5
|
+
updateAltGridRows: (rows: number) => void;
|
|
6
|
+
updateAltGridCols: (cols: number) => void;
|
|
7
|
+
updateGridSizes: (gridSizes: GridSizes) => void;
|
|
8
|
+
gridSizes: GridSizes;
|
|
9
|
+
paginationDirection: string;
|
|
10
|
+
paginationHeightWidth: number;
|
|
11
|
+
doPaginate: boolean;
|
|
12
|
+
componentSizes: ComponentSizes;
|
|
13
|
+
eventType: EventType;
|
|
14
|
+
|
|
15
|
+
getUpdatedAllParams: () => UpdateMiniCardsGridParameters;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UpdateMiniCardsGridOptions {
|
|
20
|
+
rows: number;
|
|
21
|
+
cols: number;
|
|
22
|
+
defal?: boolean;
|
|
23
|
+
actualRows?: number;
|
|
24
|
+
parameters: UpdateMiniCardsGridParameters;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Export the type definition for the function
|
|
28
|
+
export type UpdateMiniCardsGridType = (options: UpdateMiniCardsGridOptions) => Promise<void>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Updates the mini cards grid based on the specified rows and columns.
|
|
32
|
+
*
|
|
33
|
+
* @param {UpdateMiniCardsGridOptions} options - The function parameters.
|
|
34
|
+
* @param {number} options.rows - The number of rows in the grid.
|
|
35
|
+
* @param {number} options.cols - The number of columns in the grid.
|
|
36
|
+
* @param {boolean} [options.defal] - Flag indicating whether to update the default grid or an alternative grid.
|
|
37
|
+
* @param {number} [options.actualRows] - The actual number of rows in the grid.
|
|
38
|
+
* @param {UpdateMiniCardsGridParameters} options.parameters - Additional parameters needed for the function.
|
|
39
|
+
* @returns {Promise<void>} A promise that resolves when the mini cards grid is updated.
|
|
40
|
+
*
|
|
41
|
+
* @throws Will throw an error if the update operation fails.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const options = {
|
|
46
|
+
* rows: 2,
|
|
47
|
+
* cols: 3,
|
|
48
|
+
* defal: true,
|
|
49
|
+
* actualRows: 2,
|
|
50
|
+
* parameters: {
|
|
51
|
+
* updateGridRows: updateGridRowsFunction,
|
|
52
|
+
* updateGridCols: updateGridColsFunction,
|
|
53
|
+
* updateAltGridRows: updateAltGridRowsFunction,
|
|
54
|
+
* updateAltGridCols: updateAltGridColsFunction,
|
|
55
|
+
* updateGridSizes: updateGridSizesFunction,
|
|
56
|
+
* gridSizes: { gridWidth: 100, gridHeight: 100 },
|
|
57
|
+
* paginationDirection: 'horizontal',
|
|
58
|
+
* paginationHeightWidth: 50,
|
|
59
|
+
* doPaginate: true,
|
|
60
|
+
* componentSizes: { otherWidth: 300, otherHeight: 200 },
|
|
61
|
+
* eventType: 'chat',
|
|
62
|
+
* getUpdatedAllParams: getUpdatedAllParamsFunction,
|
|
63
|
+
* },
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* await updateMiniCardsGrid(options);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export async function updateMiniCardsGrid({
|
|
72
|
+
rows,
|
|
73
|
+
cols,
|
|
74
|
+
defal = true,
|
|
75
|
+
actualRows = 2,
|
|
76
|
+
parameters,
|
|
77
|
+
}: UpdateMiniCardsGridOptions): Promise<void> {
|
|
78
|
+
let { getUpdatedAllParams } = parameters;
|
|
79
|
+
|
|
80
|
+
parameters = getUpdatedAllParams();
|
|
81
|
+
|
|
82
|
+
let {
|
|
83
|
+
updateGridRows,
|
|
84
|
+
updateGridCols,
|
|
85
|
+
updateAltGridRows,
|
|
86
|
+
updateAltGridCols,
|
|
87
|
+
updateGridSizes,
|
|
88
|
+
|
|
89
|
+
gridSizes,
|
|
90
|
+
paginationDirection,
|
|
91
|
+
paginationHeightWidth,
|
|
92
|
+
doPaginate,
|
|
93
|
+
componentSizes,
|
|
94
|
+
eventType,
|
|
95
|
+
} = parameters;
|
|
96
|
+
|
|
97
|
+
let containerWidth = componentSizes.otherWidth;
|
|
98
|
+
let containerHeight = componentSizes.otherHeight;
|
|
99
|
+
|
|
100
|
+
if (doPaginate) {
|
|
101
|
+
// Adjust container size based on pagination
|
|
102
|
+
if (paginationDirection === "horizontal") {
|
|
103
|
+
containerHeight -= paginationHeightWidth;
|
|
104
|
+
} else {
|
|
105
|
+
containerWidth -= paginationHeightWidth;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let cardSpacing = 3; // 3px margin between cards
|
|
110
|
+
if (eventType === "chat") {
|
|
111
|
+
cardSpacing = 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let totalSpacingHorizontal = (cols - 1) * cardSpacing;
|
|
115
|
+
let totalSpacingVertical = (actualRows - 1) * cardSpacing;
|
|
116
|
+
|
|
117
|
+
let cardWidth: number;
|
|
118
|
+
let cardHeight: number;
|
|
119
|
+
|
|
120
|
+
if (cols === 0 || actualRows === 0) {
|
|
121
|
+
cardWidth = 0;
|
|
122
|
+
cardHeight = 0;
|
|
123
|
+
} else {
|
|
124
|
+
cardWidth = Math.floor(
|
|
125
|
+
(containerWidth - totalSpacingHorizontal) / cols
|
|
126
|
+
);
|
|
127
|
+
cardHeight = Math.floor(
|
|
128
|
+
(containerHeight - totalSpacingVertical) / actualRows
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (defal) {
|
|
133
|
+
updateGridRows(rows);
|
|
134
|
+
updateGridCols(cols);
|
|
135
|
+
|
|
136
|
+
gridSizes = { ...gridSizes, gridWidth: cardWidth, gridHeight: cardHeight };
|
|
137
|
+
updateGridSizes(gridSizes);
|
|
138
|
+
} else {
|
|
139
|
+
updateAltGridRows(rows);
|
|
140
|
+
updateAltGridCols(cols);
|
|
141
|
+
|
|
142
|
+
gridSizes = {
|
|
143
|
+
...gridSizes,
|
|
144
|
+
altGridWidth: cardWidth,
|
|
145
|
+
altGridHeight: cardHeight,
|
|
146
|
+
};
|
|
147
|
+
updateGridSizes(gridSizes);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AudioDecibels } from "../types/types";
|
|
2
|
+
export interface UpdateParticipantAudioDecibelsOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
averageLoudness: number;
|
|
5
|
+
audioDecibels: AudioDecibels[];
|
|
6
|
+
updateAudioDecibels: (audioDecibels: AudioDecibels[]) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Export the type definition for the function
|
|
10
|
+
export type UpdateParticipantAudioDecibelsType = (options: UpdateParticipantAudioDecibelsOptions) => void;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Updates the audio decibels for a participant.
|
|
15
|
+
*
|
|
16
|
+
* @param {UpdateParticipantAudioDecibelsOptions} options - The options for updating participant audio decibels.
|
|
17
|
+
* @param {string} options.name - The name of the participant.
|
|
18
|
+
* @param {number} options.averageLoudness - The average loudness of the participant.
|
|
19
|
+
* @param {Array<AudioDecibels>} options.audioDecibels - The array of audio decibels entries.
|
|
20
|
+
* @param {Function} options.updateAudioDecibels - The function to update the audio decibels array.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const options = {
|
|
26
|
+
* name: 'participant1',
|
|
27
|
+
* averageLoudness: 50,
|
|
28
|
+
* audioDecibels: [{ name: 'participant1', averageLoudness: 50 }],
|
|
29
|
+
* updateAudioDecibels: updateAudioDecibelsFunction,
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* updateParticipantAudioDecibels(options);
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export function updateParticipantAudioDecibels({
|
|
36
|
+
name,
|
|
37
|
+
averageLoudness,
|
|
38
|
+
audioDecibels,
|
|
39
|
+
updateAudioDecibels,
|
|
40
|
+
}: UpdateParticipantAudioDecibelsOptions): void {
|
|
41
|
+
|
|
42
|
+
// Function to update the audioDecibels array
|
|
43
|
+
// Check if the entry already exists in audioDecibels
|
|
44
|
+
const existingEntry = audioDecibels.find((entry) => entry.name === name);
|
|
45
|
+
|
|
46
|
+
if (existingEntry) {
|
|
47
|
+
// Entry exists, update the averageLoudness
|
|
48
|
+
existingEntry.averageLoudness = averageLoudness;
|
|
49
|
+
} else {
|
|
50
|
+
// Entry doesn't exist, add a new entry to audioDecibels
|
|
51
|
+
audioDecibels.push({ name, averageLoudness });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Update the audioDecibels array
|
|
55
|
+
updateAudioDecibels(audioDecibels);
|
|
56
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Re-export all types
|
|
2
|
+
export * from './types/types';
|
|
3
|
+
|
|
4
|
+
// Export all consumers
|
|
5
|
+
export * from './consumers/autoAdjust';
|
|
6
|
+
export * from './consumers/calculateRowsAndColumns';
|
|
7
|
+
export * from './consumers/changeVids';
|
|
8
|
+
export * from './consumers/checkGrid';
|
|
9
|
+
export * from './consumers/checkPermission';
|
|
10
|
+
export * from './consumers/checkScreenShare';
|
|
11
|
+
export * from './consumers/closeAndResize';
|
|
12
|
+
export * from './consumers/compareActiveNames';
|
|
13
|
+
export * from './consumers/compareScreenStates';
|
|
14
|
+
export * from './consumers/connectIps';
|
|
15
|
+
export * from './consumers/connectLocalIps';
|
|
16
|
+
export * from './consumers/connectRecvTransport';
|
|
17
|
+
export * from './consumers/connectSendTransport';
|
|
18
|
+
export * from './consumers/connectSendTransportAudio';
|
|
19
|
+
export * from './consumers/connectSendTransportScreen';
|
|
20
|
+
export * from './consumers/connectSendTransportVideo';
|
|
21
|
+
export * from './consumers/controlMedia';
|
|
22
|
+
export * from './consumers/createSendTransport';
|
|
23
|
+
export * from './consumers/disconnectSendTransportAudio';
|
|
24
|
+
export * from './consumers/disconnectSendTransportScreen';
|
|
25
|
+
export * from './consumers/disconnectSendTransportVideo';
|
|
26
|
+
export * from './consumers/dispStreams';
|
|
27
|
+
export * from './consumers/generatePageContent';
|
|
28
|
+
export * from './consumers/getEstimate';
|
|
29
|
+
export * from './consumers/getPipedProducersAlt';
|
|
30
|
+
export * from './consumers/getProducersPiped';
|
|
31
|
+
export * from './consumers/getVideos';
|
|
32
|
+
export * from './consumers/mixStreams';
|
|
33
|
+
export * from './consumers/onScreenChanges';
|
|
34
|
+
export * from './consumers/processConsumerTransports';
|
|
35
|
+
export * from './consumers/processConsumerTransportsAudio';
|
|
36
|
+
export * from './consumers/readjust';
|
|
37
|
+
export * from './consumers/receiveAllPipedTransports';
|
|
38
|
+
export * from './consumers/receiveRoomMessages';
|
|
39
|
+
export * from './consumers/reorderStreams';
|
|
40
|
+
export * from './consumers/rePort';
|
|
41
|
+
export * from './consumers/requestScreenShare';
|
|
42
|
+
export * from './consumers/resumePauseAudioStreams';
|
|
43
|
+
export * from './consumers/resumePauseStreams';
|
|
44
|
+
export * from './consumers/resumeSendTransportAudio';
|
|
45
|
+
export * from './consumers/reUpdateInter';
|
|
46
|
+
export * from './consumers/signalNewConsumerTransport';
|
|
47
|
+
export * from './consumers/socketReceiveMethods/joinConsumeRoom';
|
|
48
|
+
export * from './consumers/socketReceiveMethods/newPipeProducer';
|
|
49
|
+
export * from './consumers/socketReceiveMethods/producerClosed';
|
|
50
|
+
export * from './consumers/startShareScreen';
|
|
51
|
+
export * from './consumers/stopShareScreen';
|
|
52
|
+
export * from './consumers/streamSuccessAudio';
|
|
53
|
+
export * from './consumers/streamSuccessAudioSwitch';
|
|
54
|
+
export * from './consumers/streamSuccessScreen';
|
|
55
|
+
export * from './consumers/streamSuccessVideo';
|
|
56
|
+
export * from './consumers/switchUserAudio';
|
|
57
|
+
export * from './consumers/switchUserVideo';
|
|
58
|
+
export * from './consumers/switchUserVideoAlt';
|
|
59
|
+
export * from './consumers/trigger';
|
|
60
|
+
export * from './consumers/updateMiniCardsGrid';
|
|
61
|
+
export * from './consumers/updateParticipantAudioDecibels';
|
|
62
|
+
// Export all methods
|
|
63
|
+
export * from './methods/background/launchBackground';
|
|
64
|
+
export * from './methods/breakoutRooms/breakoutRoomUpdated';
|
|
65
|
+
export * from './methods/breakoutRooms/handleStartBreakout';
|
|
66
|
+
export * from './methods/breakoutRooms/handleStopBreakout';
|
|
67
|
+
export * from './methods/breakoutRooms/launchBreakoutRooms';
|
|
68
|
+
export * from './methods/coHost/launchCoHost';
|
|
69
|
+
export * from './methods/coHostMethods/modifyCoHostSettings';
|
|
70
|
+
export * from './methods/displaySettings/launchDisplaySettings';
|
|
71
|
+
export * from './methods/displaySettings/modifyDisplaySettings';
|
|
72
|
+
export * from './methods/exit/confirmExit';
|
|
73
|
+
export * from './methods/exit/launchConfirmExit';
|
|
74
|
+
export * from './methods/mediaSettings/launchMediaSettings';
|
|
75
|
+
export * from './methods/menu/launchMenuModal';
|
|
76
|
+
export * from './methods/message/launchMessages';
|
|
77
|
+
export * from './methods/message/sendMessage';
|
|
78
|
+
export * from './methods/participants/launchParticipants';
|
|
79
|
+
export * from './methods/participants/messageParticipants';
|
|
80
|
+
export * from './methods/participants/muteParticipants';
|
|
81
|
+
export * from './methods/participants/removeParticipants';
|
|
82
|
+
export * from './methods/polls/handleCreatePoll';
|
|
83
|
+
export * from './methods/polls/handleEndPoll';
|
|
84
|
+
export * from './methods/polls/handleVotePoll';
|
|
85
|
+
export * from './methods/polls/launchPoll';
|
|
86
|
+
export * from './methods/prejoin/handleCreateRoom';
|
|
87
|
+
export * from './methods/prejoin/handleJoinRoom';
|
|
88
|
+
export * from './methods/recording/checkPauseState';
|
|
89
|
+
export * from './methods/recording/checkResumeState';
|
|
90
|
+
export * from './methods/recording/confirmRecording';
|
|
91
|
+
export * from './methods/recording/launchRecording';
|
|
92
|
+
export * from './methods/recording/recordPauseTimer';
|
|
93
|
+
export * from './methods/recording/recordResumeTimer';
|
|
94
|
+
export * from './methods/recording/recordStartTimer';
|
|
95
|
+
export * from './methods/recording/recordUpdateTimer';
|
|
96
|
+
export * from './methods/recording/startRecording';
|
|
97
|
+
export * from './methods/recording/stopRecording';
|
|
98
|
+
export * from './methods/recording/updateRecording';
|
|
99
|
+
export * from './methods/requests/launchRequests';
|
|
100
|
+
export * from './methods/requests/respondToRequests';
|
|
101
|
+
export * from './methods/settings/launchSettings';
|
|
102
|
+
export * from './methods/settings/modifySettings';
|
|
103
|
+
export * from './methods/stream/switchAudio';
|
|
104
|
+
export * from './methods/stream/switchVideo';
|
|
105
|
+
export * from './methods/stream/switchVideoAlt';
|
|
106
|
+
export * from './methods/waiting/launchWaiting';
|
|
107
|
+
export * from './methods/waiting/respondToWaiting';
|
|
108
|
+
export * from './methods/welcome/handleWelcomeRequest';
|
|
109
|
+
export * from './methods/whiteboard/handleStartWhiteboard';
|
|
110
|
+
export * from './methods/whiteboard/handleStopWhiteboard';
|
|
111
|
+
export * from './methods/whiteboard/launchConfigureWhiteboard';
|
|
112
|
+
// ProducerClient exports
|
|
113
|
+
export * from './ProducerClient/producerClientEmits/createDeviceClient';
|
|
114
|
+
// Producers exports
|
|
115
|
+
export * from './producers/producerEmits/joinConRoom';
|
|
116
|
+
// Socket exports
|
|
117
|
+
export * from './sockets/SocketManager';
|
|
118
|
+
// Stream method exports (clickVideo)
|
|
119
|
+
export * from './methods/stream/clickVideo';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface LaunchBackgroundOptions {
|
|
2
|
+
updateIsBackgroundModalVisible: (isVisible: boolean) => void
|
|
3
|
+
isBackgroundModalVisible: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type LaunchBackgroundType = (options: LaunchBackgroundOptions) => void
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Toggles the visibility of the background modal.
|
|
10
|
+
*/
|
|
11
|
+
export const launchBackground: LaunchBackgroundType = ({
|
|
12
|
+
updateIsBackgroundModalVisible,
|
|
13
|
+
isBackgroundModalVisible,
|
|
14
|
+
}: LaunchBackgroundOptions): void => {
|
|
15
|
+
updateIsBackgroundModalVisible(!isBackgroundModalVisible)
|
|
16
|
+
}
|