@videosdk.live/react-sdk 0.1.42 → 0.1.45
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/connection/useConnection.d.ts +43 -0
- package/dist/connection/useConnection.d.ts.map +1 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -10
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +93 -10
- package/dist/index.modern.js.map +1 -1
- package/dist/meeting/MeetingProvider.d.ts +44 -0
- package/dist/meeting/MeetingProvider.d.ts.map +1 -0
- package/dist/meeting/meetingProviderContextDef.d.ts +149 -0
- package/dist/meeting/meetingProviderContextDef.d.ts.map +1 -0
- package/dist/participant/useParticipant.d.ts +112 -0
- package/dist/participant/useParticipant.d.ts.map +1 -0
- package/dist/pubSub/usePubSub.d.ts +37 -0
- package/dist/pubSub/usePubSub.d.ts.map +1 -0
- package/dist/utils.d.ts +32 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +6 -4
package/dist/index.modern.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import '@videosdk.live/js-sdk/connection';
|
|
2
|
+
import '@videosdk.live/js-sdk/meeting';
|
|
3
|
+
import '@videosdk.live/js-sdk/participant';
|
|
1
4
|
import React, { createContext, useEffect, useContext, useState, useRef, useMemo } from 'react';
|
|
2
5
|
import EventEmitter from 'events';
|
|
3
6
|
import { VideoSDK } from '@videosdk.live/js-sdk';
|
|
7
|
+
import '@videosdk.live/js-sdk/connectionParticipant';
|
|
4
8
|
|
|
5
9
|
var eventPrifix = 'videosdk-live-react-sdk';
|
|
6
10
|
var events = {
|
|
@@ -30,7 +34,8 @@ var events = {
|
|
|
30
34
|
'hls-started': eventPrifix + "-hls-started",
|
|
31
35
|
'hls-stopped': eventPrifix + "-hls-stopped",
|
|
32
36
|
'recording-state-changed': eventPrifix + "-recording-state-changed",
|
|
33
|
-
'livestream-state-changed': eventPrifix + "-livestream-state-changed"
|
|
37
|
+
'livestream-state-changed': eventPrifix + "-livestream-state-changed",
|
|
38
|
+
'meeting-state-changed': eventPrifix + "-meeting-state-changed"
|
|
34
39
|
};
|
|
35
40
|
var eventEmitter = new EventEmitter();
|
|
36
41
|
eventEmitter.setMaxListeners(9999);
|
|
@@ -91,7 +96,9 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
91
96
|
_ref$onRecordingState = _ref.onRecordingStateChanged,
|
|
92
97
|
onRecordingStateChanged = _ref$onRecordingState === void 0 ? function () {} : _ref$onRecordingState,
|
|
93
98
|
_ref$onLivestreamStat = _ref.onLivestreamStateChanged,
|
|
94
|
-
onLivestreamStateChanged = _ref$onLivestreamStat === void 0 ? function () {} : _ref$onLivestreamStat
|
|
99
|
+
onLivestreamStateChanged = _ref$onLivestreamStat === void 0 ? function () {} : _ref$onLivestreamStat,
|
|
100
|
+
_ref$onMeetingStateCh = _ref.onMeetingStateChanged,
|
|
101
|
+
onMeetingStateChanged = _ref$onMeetingStateCh === void 0 ? function () {} : _ref$onMeetingStateCh;
|
|
95
102
|
|
|
96
103
|
useEffect(function () {
|
|
97
104
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
@@ -121,7 +128,9 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
121
128
|
eventEmitter.on(events['hls-stopped'], onHlsStopped);
|
|
122
129
|
eventEmitter.on(events['recording-state-changed'], onRecordingStateChanged);
|
|
123
130
|
eventEmitter.on(events['livestream-state-changed'], onLivestreamStateChanged);
|
|
131
|
+
eventEmitter.on(events['meeting-state-changed'], onMeetingStateChanged);
|
|
124
132
|
return function () {
|
|
133
|
+
eventEmitter.off(events['meeting-state-changed'], onMeetingStateChanged);
|
|
125
134
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
126
135
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
127
136
|
eventEmitter.off(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -208,8 +217,11 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
208
217
|
_ref2$onRecordingStat = _ref2.onRecordingStateChanged,
|
|
209
218
|
onRecordingStateChanged = _ref2$onRecordingStat === void 0 ? function () {} : _ref2$onRecordingStat,
|
|
210
219
|
_ref2$onLivestreamSta = _ref2.onLivestreamStateChanged,
|
|
211
|
-
onLivestreamStateChanged = _ref2$onLivestreamSta === void 0 ? function () {} : _ref2$onLivestreamSta
|
|
220
|
+
onLivestreamStateChanged = _ref2$onLivestreamSta === void 0 ? function () {} : _ref2$onLivestreamSta,
|
|
221
|
+
_ref2$onMeetingStateC = _ref2.onMeetingStateChanged,
|
|
222
|
+
onMeetingStateChanged = _ref2$onMeetingStateC === void 0 ? function () {} : _ref2$onMeetingStateC;
|
|
212
223
|
useEffect(function () {
|
|
224
|
+
eventEmitter.on(events['meeting-state-changed'], onMeetingStateChanged);
|
|
213
225
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
214
226
|
eventEmitter.on(events['participant-left'], onParticipantLeft);
|
|
215
227
|
eventEmitter.on(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -238,6 +250,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
238
250
|
eventEmitter.on(events['recording-state-changed'], onRecordingStateChanged);
|
|
239
251
|
eventEmitter.on(events['livestream-state-changed'], onLivestreamStateChanged);
|
|
240
252
|
return function () {
|
|
253
|
+
eventEmitter.off(events['meeting-state-changed'], onMeetingStateChanged);
|
|
241
254
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
242
255
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
243
256
|
eventEmitter.off(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -270,7 +283,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
270
283
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MeetingProviderContex.Consumer, null, children));
|
|
271
284
|
};
|
|
272
285
|
|
|
273
|
-
var version = "0.1.
|
|
286
|
+
var version = "0.1.43";
|
|
274
287
|
|
|
275
288
|
var MeetingProvider = function MeetingProvider(_ref) {
|
|
276
289
|
var children = _ref.children,
|
|
@@ -544,6 +557,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
544
557
|
var _meeting$localPartici;
|
|
545
558
|
|
|
546
559
|
if (typeof (meeting === null || meeting === void 0 ? void 0 : meeting.off) === 'function') {
|
|
560
|
+
meeting.off('meeting-state-changed', _handle_meeting_state_changed);
|
|
547
561
|
meeting.off('participant-joined', _handle_participant_joined);
|
|
548
562
|
meeting.off('participant-left', _handle_participant_left);
|
|
549
563
|
meeting.off('presenter-changed', _handle_presenter_changed);
|
|
@@ -639,6 +653,10 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
639
653
|
eventEmitter.emit(events['livestream-state-changed'], data);
|
|
640
654
|
};
|
|
641
655
|
|
|
656
|
+
var _handle_meeting_state_changed = function _handle_meeting_state_changed(data) {
|
|
657
|
+
eventEmitter.emit(events['meeting-state-changed'], data);
|
|
658
|
+
};
|
|
659
|
+
|
|
642
660
|
var join = function join() {
|
|
643
661
|
var meeting = VideoSDK && VideoSDK.initMeeting(configRef.current);
|
|
644
662
|
setMeeting(meeting);
|
|
@@ -647,6 +665,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
647
665
|
participants.set(localParticipant.id, localParticipant);
|
|
648
666
|
setParticipants(participants);
|
|
649
667
|
setLocalParticipant(localParticipant);
|
|
668
|
+
meeting.on('meeting-state-changed', _handle_meeting_state_changed);
|
|
650
669
|
meeting.on('participant-joined', _handle_participant_joined);
|
|
651
670
|
meeting.on('participant-left', _handle_participant_left);
|
|
652
671
|
meeting.on('presenter-changed', _handle_presenter_changed);
|
|
@@ -1066,7 +1085,9 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1066
1085
|
_ref$onStreamEnabled = _ref.onStreamEnabled,
|
|
1067
1086
|
onStreamEnabled = _ref$onStreamEnabled === void 0 ? function () {} : _ref$onStreamEnabled,
|
|
1068
1087
|
_ref$onStreamDisabled = _ref.onStreamDisabled,
|
|
1069
|
-
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled
|
|
1088
|
+
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled,
|
|
1089
|
+
_ref$onMediaStatusCha = _ref.onMediaStatusChanged,
|
|
1090
|
+
onMediaStatusChanged = _ref$onMediaStatusCha === void 0 ? function () {} : _ref$onMediaStatusCha;
|
|
1070
1091
|
|
|
1071
1092
|
var _useState = useState(null),
|
|
1072
1093
|
webcamStream = _useState[0],
|
|
@@ -1080,6 +1101,10 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1080
1101
|
screenShareStream = _useState3[0],
|
|
1081
1102
|
setScreenShareStream = _useState3[1];
|
|
1082
1103
|
|
|
1104
|
+
var _useState4 = useState(null),
|
|
1105
|
+
screenShareAudioStream = _useState4[0],
|
|
1106
|
+
setScreenShareAudioStream = _useState4[1];
|
|
1107
|
+
|
|
1083
1108
|
var meeting = useMeeting();
|
|
1084
1109
|
|
|
1085
1110
|
var _useMemo = useMemo(function () {
|
|
@@ -1109,6 +1134,14 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1109
1134
|
|
|
1110
1135
|
var participant = participants === null || participants === void 0 ? void 0 : participants.get(participantId);
|
|
1111
1136
|
|
|
1137
|
+
var _useState5 = useState(participant === null || participant === void 0 ? void 0 : participant.webcamOn),
|
|
1138
|
+
webcamOn = _useState5[0],
|
|
1139
|
+
setWebcamOn = _useState5[1];
|
|
1140
|
+
|
|
1141
|
+
var _useState6 = useState(participant === null || participant === void 0 ? void 0 : participant.micOn),
|
|
1142
|
+
micOn = _useState6[0],
|
|
1143
|
+
setMicOn = _useState6[1];
|
|
1144
|
+
|
|
1112
1145
|
var setTrack = function setTrack(stream) {
|
|
1113
1146
|
if (stream.track.readyState === 'live') {
|
|
1114
1147
|
switch (stream.kind) {
|
|
@@ -1123,6 +1156,10 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1123
1156
|
case 'share':
|
|
1124
1157
|
setScreenShareStream(stream);
|
|
1125
1158
|
break;
|
|
1159
|
+
|
|
1160
|
+
case 'shareAudio':
|
|
1161
|
+
setScreenShareAudioStream(stream);
|
|
1162
|
+
break;
|
|
1126
1163
|
}
|
|
1127
1164
|
}
|
|
1128
1165
|
};
|
|
@@ -1141,6 +1178,10 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1141
1178
|
case 'share':
|
|
1142
1179
|
setScreenShareStream(null);
|
|
1143
1180
|
break;
|
|
1181
|
+
|
|
1182
|
+
case 'shareAudio':
|
|
1183
|
+
setScreenShareAudioStream(null);
|
|
1184
|
+
break;
|
|
1144
1185
|
}
|
|
1145
1186
|
}
|
|
1146
1187
|
};
|
|
@@ -1155,6 +1196,24 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1155
1196
|
onStreamDisabled(stream);
|
|
1156
1197
|
};
|
|
1157
1198
|
|
|
1199
|
+
var _handleMediaStatusChanged = function _handleMediaStatusChanged(data) {
|
|
1200
|
+
var kind = data.kind,
|
|
1201
|
+
peerId = data.peerId,
|
|
1202
|
+
newStatus = data.newStatus;
|
|
1203
|
+
|
|
1204
|
+
if (kind == 'audio') {
|
|
1205
|
+
setMicOn(newStatus);
|
|
1206
|
+
} else if (kind == 'video') {
|
|
1207
|
+
setWebcamOn(newStatus);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
onMediaStatusChanged({
|
|
1211
|
+
kind: kind,
|
|
1212
|
+
peerId: peerId,
|
|
1213
|
+
newStatus: newStatus
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1158
1217
|
var setQuality = function setQuality(quality) {
|
|
1159
1218
|
participant === null || participant === void 0 ? void 0 : participant.setQuality(quality);
|
|
1160
1219
|
};
|
|
@@ -1187,6 +1246,14 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1187
1246
|
participant === null || participant === void 0 ? void 0 : participant.unpin(data);
|
|
1188
1247
|
};
|
|
1189
1248
|
|
|
1249
|
+
var getAudioStats = function getAudioStats() {
|
|
1250
|
+
return Promise.resolve(participant === null || participant === void 0 ? void 0 : participant.getAudioStats());
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
var getVideoStats = function getVideoStats() {
|
|
1254
|
+
return Promise.resolve(participant === null || participant === void 0 ? void 0 : participant.getVideoStats());
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1190
1257
|
var consumeWebcamStreams = function consumeWebcamStreams() {
|
|
1191
1258
|
participant === null || participant === void 0 ? void 0 : participant.consumeWebcamStreams();
|
|
1192
1259
|
};
|
|
@@ -1216,11 +1283,21 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1216
1283
|
});
|
|
1217
1284
|
}
|
|
1218
1285
|
|
|
1286
|
+
if (participant !== null && participant !== void 0 && participant.micOn) {
|
|
1287
|
+
setMicOn(micOn);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (participant !== null && participant !== void 0 && participant.webcamOn) {
|
|
1291
|
+
setWebcamOn(webcamOn);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1219
1294
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-enabled', _handleStreamEnabled);
|
|
1220
1295
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-disabled', _handleStreamDisabled);
|
|
1296
|
+
participant === null || participant === void 0 ? void 0 : participant.on('media-status-changed', _handleMediaStatusChanged);
|
|
1221
1297
|
return function () {
|
|
1222
1298
|
participant === null || participant === void 0 ? void 0 : participant.off('stream-enabled', _handleStreamEnabled);
|
|
1223
1299
|
participant === null || participant === void 0 ? void 0 : participant.off('stream-disabled', _handleStreamDisabled);
|
|
1300
|
+
participant === null || participant === void 0 ? void 0 : participant.off('media-status-changed', _handleMediaStatusChanged);
|
|
1224
1301
|
};
|
|
1225
1302
|
}, [participant]);
|
|
1226
1303
|
return {
|
|
@@ -1229,8 +1306,9 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1229
1306
|
webcamStream: webcamStream,
|
|
1230
1307
|
micStream: micStream,
|
|
1231
1308
|
screenShareStream: screenShareStream,
|
|
1232
|
-
|
|
1233
|
-
|
|
1309
|
+
screenShareAudioStream: screenShareAudioStream,
|
|
1310
|
+
webcamOn: webcamOn,
|
|
1311
|
+
micOn: micOn,
|
|
1234
1312
|
screenShareOn: !!screenShareStream,
|
|
1235
1313
|
isLocal: (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.id) === participantId,
|
|
1236
1314
|
isActiveSpeaker: activeSpeakerId === participantId,
|
|
@@ -1248,7 +1326,9 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1248
1326
|
disableWebcam: disableWebcam,
|
|
1249
1327
|
pin: pin,
|
|
1250
1328
|
unpin: unpin,
|
|
1251
|
-
switchTo: switchTo
|
|
1329
|
+
switchTo: switchTo,
|
|
1330
|
+
getAudioStats: getAudioStats,
|
|
1331
|
+
getVideoStats: getVideoStats
|
|
1252
1332
|
};
|
|
1253
1333
|
};
|
|
1254
1334
|
|
|
@@ -1424,12 +1504,15 @@ var createScreenShareVideoTrack = function createScreenShareVideoTrack(_ref2) {
|
|
|
1424
1504
|
var _ref2$encoderConfig = _ref2.encoderConfig,
|
|
1425
1505
|
encoderConfig = _ref2$encoderConfig === void 0 ? undefined : _ref2$encoderConfig,
|
|
1426
1506
|
_ref2$optimizationMod = _ref2.optimizationMode,
|
|
1427
|
-
optimizationMode = _ref2$optimizationMod === void 0 ? undefined : _ref2$optimizationMod
|
|
1507
|
+
optimizationMode = _ref2$optimizationMod === void 0 ? undefined : _ref2$optimizationMod,
|
|
1508
|
+
_ref2$withAudio = _ref2.withAudio,
|
|
1509
|
+
withAudio = _ref2$withAudio === void 0 ? 'enable' : _ref2$withAudio;
|
|
1428
1510
|
|
|
1429
1511
|
try {
|
|
1430
1512
|
return Promise.resolve(VideoSDK.createScreenShareVideoTrack({
|
|
1431
1513
|
encoderConfig: encoderConfig,
|
|
1432
|
-
optimizationMode: optimizationMode
|
|
1514
|
+
optimizationMode: optimizationMode,
|
|
1515
|
+
withAudio: withAudio
|
|
1433
1516
|
}));
|
|
1434
1517
|
} catch (e) {
|
|
1435
1518
|
return Promise.reject(e);
|