@videosdk.live/react-sdk 0.6.8 → 0.8.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/dist/index.js +191 -3
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +190 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/types/agentParticipant.d.ts +138 -0
- package/dist/types/index.d.ts +201 -2
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -456,7 +456,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
456
456
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MeetingProviderContex.Consumer, null, children));
|
|
457
457
|
};
|
|
458
458
|
|
|
459
|
-
var version = "0.
|
|
459
|
+
var version = "0.8.0";
|
|
460
460
|
|
|
461
461
|
var MeetingProvider = function MeetingProvider(_ref) {
|
|
462
462
|
var children = _ref.children,
|
|
@@ -1882,8 +1882,14 @@ var usePubSub = function usePubSub(topic, _temp) {
|
|
|
1882
1882
|
setMessages = _useState[1];
|
|
1883
1883
|
var isSubscribed = useRef(false);
|
|
1884
1884
|
var publish = function publish(message, options, payload) {
|
|
1885
|
-
|
|
1886
|
-
return
|
|
1885
|
+
try {
|
|
1886
|
+
return Promise.resolve(function () {
|
|
1887
|
+
if (meeting) {
|
|
1888
|
+
return Promise.resolve(meeting.pubSub.publish(topic, message, options, payload));
|
|
1889
|
+
}
|
|
1890
|
+
}());
|
|
1891
|
+
} catch (e) {
|
|
1892
|
+
return Promise.reject(e);
|
|
1887
1893
|
}
|
|
1888
1894
|
};
|
|
1889
1895
|
var _handlePubSub = function _handlePubSub(data) {
|
|
@@ -2497,6 +2503,180 @@ var useWhiteboard = function useWhiteboard() {
|
|
|
2497
2503
|
};
|
|
2498
2504
|
};
|
|
2499
2505
|
|
|
2506
|
+
var useAgentParticipant = function useAgentParticipant(participantId, _temp) {
|
|
2507
|
+
var _mMeeting$participant;
|
|
2508
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
2509
|
+
_ref$onAgentStateChan = _ref.onAgentStateChanged,
|
|
2510
|
+
onAgentStateChanged = _ref$onAgentStateChan === void 0 ? function () {} : _ref$onAgentStateChan,
|
|
2511
|
+
_ref$onAgentTranscrip = _ref.onAgentTranscriptionReceived,
|
|
2512
|
+
onAgentTranscriptionReceived = _ref$onAgentTranscrip === void 0 ? function () {} : _ref$onAgentTranscrip,
|
|
2513
|
+
_ref$onStreamEnabled = _ref.onStreamEnabled,
|
|
2514
|
+
onStreamEnabled = _ref$onStreamEnabled === void 0 ? function () {} : _ref$onStreamEnabled,
|
|
2515
|
+
_ref$onStreamDisabled = _ref.onStreamDisabled,
|
|
2516
|
+
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled,
|
|
2517
|
+
_ref$onMediaStatusCha = _ref.onMediaStatusChanged,
|
|
2518
|
+
onMediaStatusChanged = _ref$onMediaStatusCha === void 0 ? function () {} : _ref$onMediaStatusCha;
|
|
2519
|
+
var mMeeting = useMeeting();
|
|
2520
|
+
var _useState = useState(null),
|
|
2521
|
+
webcamStream = _useState[0],
|
|
2522
|
+
setWebcamStream = _useState[1];
|
|
2523
|
+
var _useState2 = useState(null),
|
|
2524
|
+
micStream = _useState2[0],
|
|
2525
|
+
setMicStream = _useState2[1];
|
|
2526
|
+
var _useState3 = useState(null),
|
|
2527
|
+
agentState = _useState3[0],
|
|
2528
|
+
setAgentState = _useState3[1];
|
|
2529
|
+
var _useState4 = useState(false),
|
|
2530
|
+
webcamOn = _useState4[0],
|
|
2531
|
+
setWebcamOn = _useState4[1];
|
|
2532
|
+
var _useState5 = useState(false),
|
|
2533
|
+
micOn = _useState5[0],
|
|
2534
|
+
setMicOn = _useState5[1];
|
|
2535
|
+
var _useState6 = useState((_mMeeting$participant = mMeeting.participants.get(participantId)) === null || _mMeeting$participant === void 0 ? void 0 : _mMeeting$participant.mode),
|
|
2536
|
+
mode = _useState6[0],
|
|
2537
|
+
setMode = _useState6[1];
|
|
2538
|
+
var _useMemo = useMemo(function () {
|
|
2539
|
+
var _mMeeting$pinnedParti;
|
|
2540
|
+
var participant = mMeeting.participants.get(participantId);
|
|
2541
|
+
if (participant && !participant.isAgent) {
|
|
2542
|
+
console.warn("useAgentParticipant: Participant " + participantId + " is not an agent participant.");
|
|
2543
|
+
}
|
|
2544
|
+
var pinState = (mMeeting === null || mMeeting === void 0 ? void 0 : (_mMeeting$pinnedParti = mMeeting.pinnedParticipants) === null || _mMeeting$pinnedParti === void 0 ? void 0 : _mMeeting$pinnedParti.get(participantId)) || {
|
|
2545
|
+
cam: false,
|
|
2546
|
+
share: false
|
|
2547
|
+
};
|
|
2548
|
+
return {
|
|
2549
|
+
agentParticipant: participant !== null && participant !== void 0 && participant.isAgent ? participant : null,
|
|
2550
|
+
activeSpeakerId: mMeeting.activeSpeakerId,
|
|
2551
|
+
pinState: pinState
|
|
2552
|
+
};
|
|
2553
|
+
}, [mMeeting.participants, mMeeting.pinnedParticipants, mMeeting.activeSpeakerId, participantId]),
|
|
2554
|
+
agentParticipant = _useMemo.agentParticipant,
|
|
2555
|
+
activeSpeakerId = _useMemo.activeSpeakerId,
|
|
2556
|
+
pinState = _useMemo.pinState;
|
|
2557
|
+
var setTrack = function setTrack(stream) {
|
|
2558
|
+
if (stream.track.readyState !== 'live') return;
|
|
2559
|
+
switch (stream.kind) {
|
|
2560
|
+
case 'video':
|
|
2561
|
+
setWebcamStream(stream);
|
|
2562
|
+
break;
|
|
2563
|
+
case 'audio':
|
|
2564
|
+
setMicStream(stream);
|
|
2565
|
+
break;
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
var unsetTrack = function unsetTrack(stream) {
|
|
2569
|
+
switch (stream.kind) {
|
|
2570
|
+
case 'video':
|
|
2571
|
+
setWebcamStream(null);
|
|
2572
|
+
break;
|
|
2573
|
+
case 'audio':
|
|
2574
|
+
setMicStream(null);
|
|
2575
|
+
break;
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
var _handleAgentStateChanged = function _handleAgentStateChanged(state) {
|
|
2579
|
+
setAgentState(state);
|
|
2580
|
+
onAgentStateChanged(state);
|
|
2581
|
+
};
|
|
2582
|
+
var _handleTranscriptionReceived = function _handleTranscriptionReceived(data) {
|
|
2583
|
+
onAgentTranscriptionReceived(data);
|
|
2584
|
+
};
|
|
2585
|
+
var _handleStreamEnabled = function _handleStreamEnabled(stream) {
|
|
2586
|
+
setTrack(stream);
|
|
2587
|
+
onStreamEnabled(stream);
|
|
2588
|
+
};
|
|
2589
|
+
var _handleMediaStatusChanged = function _handleMediaStatusChanged(data) {
|
|
2590
|
+
var kind = data.kind,
|
|
2591
|
+
peerId = data.peerId,
|
|
2592
|
+
newStatus = data.newStatus;
|
|
2593
|
+
if (kind == 'audio') {
|
|
2594
|
+
setMicOn(newStatus);
|
|
2595
|
+
} else if (kind == 'video') {
|
|
2596
|
+
setWebcamOn(newStatus);
|
|
2597
|
+
}
|
|
2598
|
+
onMediaStatusChanged({
|
|
2599
|
+
kind: kind,
|
|
2600
|
+
peerId: peerId,
|
|
2601
|
+
newStatus: newStatus
|
|
2602
|
+
});
|
|
2603
|
+
};
|
|
2604
|
+
var _handleStreamDisabled = function _handleStreamDisabled(stream) {
|
|
2605
|
+
unsetTrack(stream);
|
|
2606
|
+
onStreamDisabled(stream);
|
|
2607
|
+
};
|
|
2608
|
+
var _handleParticipantModeChanged = function _handleParticipantModeChanged(data) {
|
|
2609
|
+
if (participantId === data.participantId) {
|
|
2610
|
+
setMode(data.mode);
|
|
2611
|
+
}
|
|
2612
|
+
};
|
|
2613
|
+
var remove = function remove() {
|
|
2614
|
+
agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.remove();
|
|
2615
|
+
};
|
|
2616
|
+
var pin = function pin(data) {
|
|
2617
|
+
agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.pin(data);
|
|
2618
|
+
};
|
|
2619
|
+
var unpin = function unpin(data) {
|
|
2620
|
+
agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.unpin(data);
|
|
2621
|
+
};
|
|
2622
|
+
var getAudioStats = function getAudioStats() {
|
|
2623
|
+
return Promise.resolve(agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.getAudioStats());
|
|
2624
|
+
};
|
|
2625
|
+
var getVideoStats = function getVideoStats() {
|
|
2626
|
+
return Promise.resolve(agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.getVideoStats());
|
|
2627
|
+
};
|
|
2628
|
+
useEffect(function () {
|
|
2629
|
+
if (!agentParticipant) return;
|
|
2630
|
+
var streams = agentParticipant.streams;
|
|
2631
|
+
if (streams) {
|
|
2632
|
+
streams.forEach(function (stream) {
|
|
2633
|
+
return setTrack(stream);
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.micOn) {
|
|
2637
|
+
setMicOn(micOn);
|
|
2638
|
+
}
|
|
2639
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.webcamOn) {
|
|
2640
|
+
setWebcamOn(webcamOn);
|
|
2641
|
+
}
|
|
2642
|
+
setAgentState(agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.agentState);
|
|
2643
|
+
agentParticipant.on('agent-state-changed', _handleAgentStateChanged);
|
|
2644
|
+
agentParticipant.on('agent-transcription-received', _handleTranscriptionReceived);
|
|
2645
|
+
agentParticipant.on('stream-enabled', _handleStreamEnabled);
|
|
2646
|
+
agentParticipant.on('stream-disabled', _handleStreamDisabled);
|
|
2647
|
+
agentParticipant.on('media-status-changed', _handleMediaStatusChanged);
|
|
2648
|
+
eventEmitter.on(events['participant-mode-changed'], _handleParticipantModeChanged);
|
|
2649
|
+
return function () {
|
|
2650
|
+
agentParticipant.off('agent-state-changed', _handleAgentStateChanged);
|
|
2651
|
+
agentParticipant.off('agent-transcription-received', _handleTranscriptionReceived);
|
|
2652
|
+
agentParticipant.off('stream-enabled', _handleStreamEnabled);
|
|
2653
|
+
agentParticipant.off('stream-disabled', _handleStreamDisabled);
|
|
2654
|
+
agentParticipant.off('media-status-changed', _handleMediaStatusChanged);
|
|
2655
|
+
eventEmitter.off(events['participant-mode-changed'], _handleParticipantModeChanged);
|
|
2656
|
+
};
|
|
2657
|
+
}, [agentParticipant]);
|
|
2658
|
+
return {
|
|
2659
|
+
agentParticipant: agentParticipant,
|
|
2660
|
+
id: agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.id,
|
|
2661
|
+
displayName: agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.displayName,
|
|
2662
|
+
agentId: agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.agentId,
|
|
2663
|
+
agentState: agentState,
|
|
2664
|
+
webcamStream: webcamStream,
|
|
2665
|
+
micStream: micStream,
|
|
2666
|
+
webcamOn: webcamOn || !!webcamStream,
|
|
2667
|
+
micOn: micOn || !!micStream,
|
|
2668
|
+
mode: mode,
|
|
2669
|
+
metaData: agentParticipant === null || agentParticipant === void 0 ? void 0 : agentParticipant.metaData,
|
|
2670
|
+
pinState: pinState,
|
|
2671
|
+
isActiveSpeaker: activeSpeakerId === participantId,
|
|
2672
|
+
pin: pin,
|
|
2673
|
+
unpin: unpin,
|
|
2674
|
+
remove: remove,
|
|
2675
|
+
getAudioStats: getAudioStats,
|
|
2676
|
+
getVideoStats: getVideoStats
|
|
2677
|
+
};
|
|
2678
|
+
};
|
|
2679
|
+
|
|
2500
2680
|
var _excluded = ["participantId", "type"];
|
|
2501
2681
|
var Constants = VideoSDK.Constants;
|
|
2502
2682
|
var createCameraVideoTrack = function createCameraVideoTrack(_ref) {
|
|
@@ -2528,6 +2708,12 @@ var createCameraVideoTrack = function createCameraVideoTrack(_ref) {
|
|
|
2528
2708
|
return Promise.reject(e);
|
|
2529
2709
|
}
|
|
2530
2710
|
};
|
|
2711
|
+
var setLogLevel = function setLogLevel(logLevel) {
|
|
2712
|
+
if (logLevel === void 0) {
|
|
2713
|
+
logLevel = Constants.LogLevel.INFO;
|
|
2714
|
+
}
|
|
2715
|
+
VideoSDK.setLogLevel(logLevel);
|
|
2716
|
+
};
|
|
2531
2717
|
var createScreenShareVideoTrack = function createScreenShareVideoTrack(_ref2) {
|
|
2532
2718
|
var _ref2$encoderConfig = _ref2.encoderConfig,
|
|
2533
2719
|
encoderConfig = _ref2$encoderConfig === void 0 ? undefined : _ref2$encoderConfig,
|
|
@@ -2752,5 +2938,5 @@ var AudioPlayer = function AudioPlayer(_ref7) {
|
|
|
2752
2938
|
});
|
|
2753
2939
|
};
|
|
2754
2940
|
|
|
2755
|
-
export { AudioPlayer, Constants, MeetingConsumer, MeetingProvider, VideoPlayer, createCameraVideoTrack, createMicrophoneAudioTrack, createScreenShareVideoTrack, getNetworkStats, useCharacter, useConnection, useFile, useMediaDevice, useMeeting, useParticipant, usePubSub, useRealtimeStore, useStream, useTranscription, useTranslation, useWhiteboard, withAdaptiveObservers };
|
|
2941
|
+
export { AudioPlayer, Constants, MeetingConsumer, MeetingProvider, VideoPlayer, createCameraVideoTrack, createMicrophoneAudioTrack, createScreenShareVideoTrack, getNetworkStats, setLogLevel, useAgentParticipant, useCharacter, useConnection, useFile, useMediaDevice, useMeeting, useParticipant, usePubSub, useRealtimeStore, useStream, useTranscription, useTranslation, useWhiteboard, withAdaptiveObservers };
|
|
2756
2942
|
//# sourceMappingURL=index.modern.js.map
|