@videosdk.live/react
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -1,605 +0,20 @@ | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var EventEmitter = _interopDefault(require('events')); | ||
var js = require('@videosdk.live/js'); | ||
var eventPrifix = 'zn-meeting-react-sdk'; | ||
var events = { | ||
'participant-joined': eventPrifix + "-participant-joined", | ||
'participant-left': eventPrifix + "-participant-left", | ||
'speaker-changed': eventPrifix + "-speaker-changed", | ||
'presenter-changed': eventPrifix + "-presenter-changed", | ||
'main-participant-changed': eventPrifix + "-main-participant-changed", | ||
'entry-requested': eventPrifix + "-entry-requested", | ||
'entry-responded': eventPrifix + "-entry-responded", | ||
'recording-started': eventPrifix + "-recording-started", | ||
'recording-stopped': eventPrifix + "-recording-stopped", | ||
'chat-message': eventPrifix + "-chat-message", | ||
'meeting-joined': eventPrifix + "-meeting-joined", | ||
'meeting-left': eventPrifix + "-meeting-left" | ||
var MeetingProvider1 = function MeetingProvider1() { | ||
return /*#__PURE__*/React.createElement(Fragment, null); | ||
}; | ||
var eventEmitter = new EventEmitter(); | ||
var MeetingProviderContex = React.createContext(); | ||
var useMeeting = function useMeeting(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$onParticipantJoi = _ref.onParticipantJoined, | ||
onParticipantJoined = _ref$onParticipantJoi === void 0 ? function () {} : _ref$onParticipantJoi, | ||
_ref$onParticipantLef = _ref.onParticipantLeft, | ||
onParticipantLeft = _ref$onParticipantLef === void 0 ? function () {} : _ref$onParticipantLef, | ||
_ref$onSpeakerChanged = _ref.onSpeakerChanged, | ||
onSpeakerChanged = _ref$onSpeakerChanged === void 0 ? function () {} : _ref$onSpeakerChanged, | ||
_ref$onPresenterChang = _ref.onPresenterChanged, | ||
onPresenterChanged = _ref$onPresenterChang === void 0 ? function () {} : _ref$onPresenterChang, | ||
_ref$onMainParticipan = _ref.onMainParticipantChanged, | ||
onMainParticipantChanged = _ref$onMainParticipan === void 0 ? function () {} : _ref$onMainParticipan, | ||
_ref$onEntryRequested = _ref.onEntryRequested, | ||
onEntryRequested = _ref$onEntryRequested === void 0 ? function () {} : _ref$onEntryRequested, | ||
_ref$onEntryResponded = _ref.onEntryResponded, | ||
onEntryResponded = _ref$onEntryResponded === void 0 ? function () {} : _ref$onEntryResponded, | ||
_ref$onRecordingStart = _ref.onRecordingStarted, | ||
onRecordingStarted = _ref$onRecordingStart === void 0 ? function () {} : _ref$onRecordingStart, | ||
_ref$onRecordingStopp = _ref.onRecordingStopped, | ||
onRecordingStopped = _ref$onRecordingStopp === void 0 ? function () {} : _ref$onRecordingStopp, | ||
_ref$onChatMessage = _ref.onChatMessage, | ||
onChatMessage = _ref$onChatMessage === void 0 ? function () {} : _ref$onChatMessage, | ||
_ref$onMeetingJoined = _ref.onMeetingJoined, | ||
onMeetingJoined = _ref$onMeetingJoined === void 0 ? function () {} : _ref$onMeetingJoined, | ||
_ref$onMeetingLeft = _ref.onMeetingLeft, | ||
onMeetingLeft = _ref$onMeetingLeft === void 0 ? function () {} : _ref$onMeetingLeft; | ||
React.useEffect(function () { | ||
eventEmitter.on(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.on(events['participant-left'], onParticipantLeft); | ||
eventEmitter.on(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.on(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.on(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.on(events['entry-requested'], onEntryRequested); | ||
eventEmitter.on(events['entry-responded'], onEntryResponded); | ||
eventEmitter.on(events['recording-started'], onRecordingStarted); | ||
eventEmitter.on(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.on(events['chat-message'], onChatMessage); | ||
eventEmitter.on(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.on(events['meeting-left'], onMeetingLeft); | ||
return function () { | ||
eventEmitter.off(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.off(events['participant-left'], onParticipantLeft); | ||
eventEmitter.off(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.off(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.off(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.off(events['entry-requested'], onEntryRequested); | ||
eventEmitter.off(events['entry-responded'], onEntryResponded); | ||
eventEmitter.off(events['recording-started'], onRecordingStarted); | ||
eventEmitter.off(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.off(events['chat-message'], onChatMessage); | ||
eventEmitter.off(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.off(events['meeting-left'], onMeetingLeft); | ||
}; | ||
}, []); | ||
return React.useContext(MeetingProviderContex); | ||
var useMeeting = function useMeeting() { | ||
return 'useMeeting'; | ||
}; | ||
var MeetingConsumer = function MeetingConsumer(_ref2) { | ||
var children = _ref2.children, | ||
_ref2$onParticipantJo = _ref2.onParticipantJoined, | ||
onParticipantJoined = _ref2$onParticipantJo === void 0 ? function () {} : _ref2$onParticipantJo, | ||
_ref2$onParticipantLe = _ref2.onParticipantLeft, | ||
onParticipantLeft = _ref2$onParticipantLe === void 0 ? function () {} : _ref2$onParticipantLe, | ||
_ref2$onSpeakerChange = _ref2.onSpeakerChanged, | ||
onSpeakerChanged = _ref2$onSpeakerChange === void 0 ? function () {} : _ref2$onSpeakerChange, | ||
_ref2$onPresenterChan = _ref2.onPresenterChanged, | ||
onPresenterChanged = _ref2$onPresenterChan === void 0 ? function () {} : _ref2$onPresenterChan, | ||
_ref2$onMainParticipa = _ref2.onMainParticipantChanged, | ||
onMainParticipantChanged = _ref2$onMainParticipa === void 0 ? function () {} : _ref2$onMainParticipa, | ||
_ref2$onEntryRequeste = _ref2.onEntryRequested, | ||
onEntryRequested = _ref2$onEntryRequeste === void 0 ? function () {} : _ref2$onEntryRequeste, | ||
_ref2$onEntryResponde = _ref2.onEntryResponded, | ||
onEntryResponded = _ref2$onEntryResponde === void 0 ? function () {} : _ref2$onEntryResponde, | ||
_ref2$onRecordingStar = _ref2.onRecordingStarted, | ||
onRecordingStarted = _ref2$onRecordingStar === void 0 ? function () {} : _ref2$onRecordingStar, | ||
_ref2$onRecordingStop = _ref2.onRecordingStopped, | ||
onRecordingStopped = _ref2$onRecordingStop === void 0 ? function () {} : _ref2$onRecordingStop, | ||
_ref2$onChatMessage = _ref2.onChatMessage, | ||
onChatMessage = _ref2$onChatMessage === void 0 ? function () {} : _ref2$onChatMessage, | ||
_ref2$onMeetingJoined = _ref2.onMeetingJoined, | ||
onMeetingJoined = _ref2$onMeetingJoined === void 0 ? function () {} : _ref2$onMeetingJoined, | ||
_ref2$onMeetingLeft = _ref2.onMeetingLeft, | ||
onMeetingLeft = _ref2$onMeetingLeft === void 0 ? function () {} : _ref2$onMeetingLeft; | ||
React.useEffect(function () { | ||
eventEmitter.on(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.on(events['participant-left'], onParticipantLeft); | ||
eventEmitter.on(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.on(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.on(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.on(events['entry-requested'], onEntryRequested); | ||
eventEmitter.on(events['entry-responded'], onEntryResponded); | ||
eventEmitter.on(events['recording-started'], onRecordingStarted); | ||
eventEmitter.on(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.on(events['chat-message'], onChatMessage); | ||
eventEmitter.on(events['chat-message'], onMeetingJoined); | ||
eventEmitter.on(events['chat-message'], onMeetingLeft); | ||
return function () { | ||
eventEmitter.off(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.off(events['participant-left'], onParticipantLeft); | ||
eventEmitter.off(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.off(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.off(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.off(events['entry-requested'], onEntryRequested); | ||
eventEmitter.off(events['entry-responded'], onEntryResponded); | ||
eventEmitter.off(events['recording-started'], onRecordingStarted); | ||
eventEmitter.off(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.off(events['chat-message'], onChatMessage); | ||
eventEmitter.off(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.off(events['meeting-left'], onMeetingLeft); | ||
}; | ||
}, []); | ||
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MeetingProviderContex.Consumer, null, children)); | ||
var MeetingConsumer = function MeetingConsumer() { | ||
return /*#__PURE__*/React.createElement(Fragment, null); | ||
}; | ||
var MeetingProvider = function MeetingProvider(_ref) { | ||
var children = _ref.children, | ||
config = _ref.config, | ||
token = _ref.token, | ||
joinWithoutUserInteraction = _ref.joinWithoutUserInteraction; | ||
var _useState = React.useState(null), | ||
meeting = _useState[0], | ||
setMeeting = _useState[1]; | ||
var _useState2 = React.useState(null), | ||
localParticipant = _useState2[0], | ||
setLocalParticipant = _useState2[1]; | ||
var _useState3 = React.useState(null), | ||
mainParticipant = _useState3[0], | ||
setMainParticipant = _useState3[1]; | ||
var _useState4 = React.useState(null), | ||
activeSpeakerId = _useState4[0], | ||
setActiveSpeakerId = _useState4[1]; | ||
var _useState5 = React.useState(new Map()), | ||
participants = _useState5[0], | ||
setParticipants = _useState5[1]; | ||
var _useState6 = React.useState(null), | ||
presenterId = _useState6[0], | ||
setPresenterId = _useState6[1]; | ||
var _useState7 = React.useState(false), | ||
localMicOn = _useState7[0], | ||
setLocalMicOn = _useState7[1]; | ||
var _useState8 = React.useState(false), | ||
localWebcamOn = _useState8[0], | ||
setLocalWebcamOn = _useState8[1]; | ||
var _useState9 = React.useState(false), | ||
localScreenShareOn = _useState9[0], | ||
setLocalScreenShareOn = _useState9[1]; | ||
var _useState10 = React.useState(false), | ||
isRecording = _useState10[0], | ||
setIsRecording = _useState10[1]; | ||
var _useState11 = React.useState([]), | ||
messages = _useState11[0], | ||
setMessages = _useState11[1]; | ||
var meetingRef = React.useRef(); | ||
var localMicOnRef = React.useRef(); | ||
var localWebcamOnRef = React.useRef(); | ||
var localScreenShareOnRef = React.useRef(); | ||
var isRecordingRef = React.useRef(); | ||
React.useEffect(function () { | ||
meetingRef.current = meeting; | ||
}, [meeting]); | ||
React.useEffect(function () { | ||
localMicOnRef.current = localMicOn; | ||
}, [localMicOn]); | ||
React.useEffect(function () { | ||
localWebcamOnRef.current = localWebcamOn; | ||
}, [localWebcamOn]); | ||
React.useEffect(function () { | ||
localScreenShareOnRef.current = localScreenShareOn; | ||
}, [localScreenShareOn]); | ||
React.useEffect(function () { | ||
isRecordingRef.current = isRecording; | ||
}, [isRecording]); | ||
var resetStates = function resetStates() { | ||
setMeeting(null); | ||
setLocalParticipant(null); | ||
setMainParticipant(null); | ||
setActiveSpeakerId(null); | ||
setParticipants(new Map()); | ||
setPresenterId(null); | ||
setLocalMicOn(false); | ||
setLocalWebcamOn(false); | ||
setLocalScreenShareOn(false); | ||
setIsRecording(false); | ||
setMessages([]); | ||
}; | ||
var _handle_participant_joined = function _handle_participant_joined(participant) { | ||
setParticipants(function (participants) { | ||
participants.set(participant.id, participant); | ||
var participantsToSet = new Map(participants); | ||
return participantsToSet; | ||
}); | ||
eventEmitter.emit(events['participant-joined'], participant); | ||
}; | ||
var _handle_participant_left = function _handle_participant_left(participant) { | ||
setParticipants(function (participants) { | ||
participants["delete"](participant.id); | ||
var newParticipants = new Map(participants); | ||
return newParticipants; | ||
}); | ||
eventEmitter.emit(events['participant-left'], participant); | ||
}; | ||
var _handle_presenter_changed = function _handle_presenter_changed(presenterId) { | ||
var _meetingRef$current, _meetingRef$current$l; | ||
setPresenterId(presenterId); | ||
setLocalScreenShareOn(presenterId === (meetingRef === null || meetingRef === void 0 ? void 0 : (_meetingRef$current = meetingRef.current) === null || _meetingRef$current === void 0 ? void 0 : (_meetingRef$current$l = _meetingRef$current.localParticipant) === null || _meetingRef$current$l === void 0 ? void 0 : _meetingRef$current$l.id)); | ||
eventEmitter.emit(events['presenter-changed'], presenterId); | ||
}; | ||
var _handle_main_participant_changed = function _handle_main_participant_changed(participant) { | ||
setMainParticipant(participant); | ||
eventEmitter.emit(events['main-participant-changed'], participant); | ||
}; | ||
var _handle_speaker_changed = function _handle_speaker_changed(activeSpeakerId) { | ||
setActiveSpeakerId(activeSpeakerId); | ||
eventEmitter.emit(events['speaker-changed'], activeSpeakerId); | ||
}; | ||
var _handle_chat_message = function _handle_chat_message(data) { | ||
eventEmitter.emit(events['chat-message'], data); | ||
setMessages(function (s) { | ||
return [].concat(s, [data]); | ||
}); | ||
}; | ||
var _handle_entry_requested = function _handle_entry_requested(participantId, name) { | ||
eventEmitter.emit(events['entry-requested'], participantId, name); | ||
}; | ||
var _handle_entry_responded = function _handle_entry_responded(participantId, name) { | ||
eventEmitter.emit(events['entry-responded'], participantId, name); | ||
}; | ||
var _handle_recording_started = function _handle_recording_started() { | ||
setIsRecording(true); | ||
eventEmitter.emit(events['recording-started']); | ||
}; | ||
var _handle_recording_stopped = function _handle_recording_stopped() { | ||
setIsRecording(false); | ||
eventEmitter.emit(events['recording-stopped']); | ||
}; | ||
var _handle_meeting_joined = function _handle_meeting_joined() { | ||
eventEmitter.emit(events['meeting-joined']); | ||
}; | ||
var _handle_meeting_left = function _handle_meeting_left() { | ||
eventEmitter.emit(events['meeting-left']); | ||
}; | ||
var _handle_localParticipant_stream_enabled = function _handle_localParticipant_stream_enabled(stream) { | ||
if (stream.track.readyState === 'live') { | ||
if (stream.kind === 'video') { | ||
setLocalWebcamOn(true); | ||
} else if (stream.kind === 'audio') { | ||
setLocalMicOn(true); | ||
} | ||
} | ||
}; | ||
var _handle_localParticipant_stream_disabled = function _handle_localParticipant_stream_disabled(stream) { | ||
if (stream.track.readyState === 'ended') { | ||
if (stream.kind === 'video') { | ||
setLocalWebcamOn(false); | ||
} else if (stream.kind === 'audio') { | ||
setLocalMicOn(false); | ||
} | ||
} | ||
}; | ||
var join = function join() { | ||
var meeting = js.ZujoSDK.initMeeting(config); | ||
setMeeting(meeting); | ||
var localParticipant = meeting.localParticipant, | ||
participants = meeting.participants, | ||
messages = meeting.messages; | ||
participants.set(localParticipant.id, localParticipant); | ||
setParticipants(participants); | ||
setLocalParticipant(localParticipant); | ||
setMessages(messages); | ||
meeting.on('participant-joined', _handle_participant_joined); | ||
meeting.on('participant-left', _handle_participant_left); | ||
meeting.on('presenter-changed', _handle_presenter_changed); | ||
meeting.on('main-participant-changed', _handle_main_participant_changed); | ||
meeting.on('speaker-changed', _handle_speaker_changed); | ||
meeting.on('entry-requested', _handle_entry_requested); | ||
meeting.on('entry-responded', _handle_entry_responded); | ||
meeting.on('chat-message', _handle_chat_message); | ||
meeting.on('recording-started', _handle_recording_started); | ||
meeting.on('recording-stopped', _handle_recording_stopped); | ||
meeting.on('meeting-joined', _handle_meeting_joined); | ||
meeting.on('meeting-left', _handle_meeting_left); | ||
meeting.localParticipant.on('stream-enabled', _handle_localParticipant_stream_enabled); | ||
meeting.localParticipant.on('stream-disabled', _handle_localParticipant_stream_disabled); | ||
meeting.join(); | ||
}; | ||
var leave = function leave() { | ||
var _meeting$localPartici; | ||
var meeting = meetingRef.current; | ||
if (typeof (meeting === null || meeting === void 0 ? void 0 : meeting.off) === 'function') { | ||
meeting.off('participant-joined', _handle_participant_joined); | ||
meeting.off('participant-left', _handle_participant_left); | ||
meeting.off('presenter-changed', _handle_presenter_changed); | ||
meeting.off('main-participant-changed', _handle_main_participant_changed); | ||
meeting.off('speaker-changed', _handle_speaker_changed); | ||
meeting.off('chat-message', _handle_chat_message); | ||
meeting.off('meeting-joined', _handle_meeting_joined); | ||
meeting.off('meeting-left', _handle_meeting_left); | ||
} | ||
if (typeof (meeting === null || meeting === void 0 ? void 0 : (_meeting$localPartici = meeting.localParticipant) === null || _meeting$localPartici === void 0 ? void 0 : _meeting$localPartici.off) === 'function') { | ||
meeting.localParticipant.off('stream-enabled', _handle_localParticipant_stream_enabled); | ||
meeting.localParticipant.off('stream-disabled', _handle_localParticipant_stream_disabled); | ||
} | ||
meeting.leave(); | ||
resetStates(); | ||
}; | ||
var startRecording = function startRecording(webhookUrl) { | ||
var meeting = meetingRef.current; | ||
meeting.startRecording(webhookUrl); | ||
}; | ||
var stopRecording = function stopRecording() { | ||
var meeting = meetingRef.current; | ||
var isRecording = isRecordingRef.current; | ||
if (isRecording) { | ||
meeting.stopRecording(); | ||
} | ||
}; | ||
var unmuteMic = function unmuteMic() { | ||
var meeting = meetingRef.current; | ||
meeting.unmuteMic(); | ||
}; | ||
var muteMic = function muteMic() { | ||
var meeting = meetingRef.current; | ||
meeting.muteMic(); | ||
}; | ||
var toggleMic = function toggleMic() { | ||
var localMicOn = localMicOnRef.current; | ||
if (localMicOn) { | ||
muteMic(); | ||
} else { | ||
unmuteMic(); | ||
} | ||
}; | ||
var disableWebcam = function disableWebcam() { | ||
var meeting = meetingRef.current; | ||
meeting.disableWebcam(); | ||
}; | ||
var enableWebcam = function enableWebcam() { | ||
var meeting = meetingRef.current; | ||
meeting.enableWebcam(); | ||
}; | ||
var toggleWebcam = function toggleWebcam() { | ||
var localWebcamOn = localWebcamOnRef.current; | ||
if (localWebcamOn) { | ||
disableWebcam(); | ||
} else { | ||
enableWebcam(); | ||
} | ||
}; | ||
var disableScreenShare = function disableScreenShare() { | ||
var meeting = meetingRef.current; | ||
meeting.disableScreenShare(); | ||
}; | ||
var enableScreenShare = function enableScreenShare() { | ||
var meeting = meetingRef.current; | ||
meeting.enableScreenShare(); | ||
}; | ||
var toggleScreenShare = function toggleScreenShare() { | ||
var localScreenShareOn = localScreenShareOnRef.current; | ||
if (localScreenShareOn) { | ||
disableScreenShare(); | ||
} else { | ||
enableScreenShare(); | ||
} | ||
}; | ||
var sendChatMessage = function sendChatMessage(text) { | ||
var meeting = meetingRef.current; | ||
meeting.sendChatMessage(text); | ||
}; | ||
var respondEntry = function respondEntry(participantId, decision) { | ||
var meeting = meetingRef.current; | ||
meeting.respondEntry(participantId, decision); | ||
}; | ||
var initSDK = function initSDK() { | ||
js.ZujoSDK.config(token); | ||
if (joinWithoutUserInteraction) { | ||
join(); | ||
} | ||
}; | ||
React.useEffect(function () { | ||
initSDK(); | ||
}, []); | ||
return /*#__PURE__*/React__default.createElement(MeetingProviderContex.Provider, { | ||
value: { | ||
meetingId: config.meetingId, | ||
meeting: meeting, | ||
localParticipant: localParticipant, | ||
mainParticipant: mainParticipant, | ||
activeSpeakerId: activeSpeakerId, | ||
participants: participants, | ||
presenterId: presenterId, | ||
localMicOn: localMicOn, | ||
localWebcamOn: localWebcamOn, | ||
localScreenShareOn: localScreenShareOn, | ||
messages: messages, | ||
join: join, | ||
leave: leave, | ||
startRecording: startRecording, | ||
stopRecording: stopRecording, | ||
sendChatMessage: sendChatMessage, | ||
respondEntry: respondEntry, | ||
muteMic: muteMic, | ||
unmuteMic: unmuteMic, | ||
toggleMic: toggleMic, | ||
disableWebcam: disableWebcam, | ||
enableWebcam: enableWebcam, | ||
toggleWebcam: toggleWebcam, | ||
disableScreenShare: disableScreenShare, | ||
enableScreenShare: enableScreenShare, | ||
toggleScreenShare: toggleScreenShare | ||
} | ||
}, children); | ||
var useParticipant1 = function useParticipant1() { | ||
return 'useParticipant1'; | ||
}; | ||
var useParticipant = function useParticipant(participantId, _temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$onStreamEnabled = _ref.onStreamEnabled, | ||
onStreamEnabled = _ref$onStreamEnabled === void 0 ? function () {} : _ref$onStreamEnabled, | ||
_ref$onStreamDisabled = _ref.onStreamDisabled, | ||
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled; | ||
var _useState = React.useState(null), | ||
webcamStream = _useState[0], | ||
setwebcamStream = _useState[1]; | ||
var _useState2 = React.useState(null), | ||
micStream = _useState2[0], | ||
setMicStream = _useState2[1]; | ||
var _useState3 = React.useState(null), | ||
screenShareStream = _useState3[0], | ||
setScreenShareStream = _useState3[1]; | ||
var meeting = useMeeting(); | ||
var participants = meeting === null || meeting === void 0 ? void 0 : meeting.participants; | ||
var localParticipant = meeting === null || meeting === void 0 ? void 0 : meeting.localParticipant; | ||
var activeSpeakerId = meeting === null || meeting === void 0 ? void 0 : meeting.activeSpeakerId; | ||
var mainParticipant = meeting === null || meeting === void 0 ? void 0 : meeting.mainParticipant; | ||
var participant = participants === null || participants === void 0 ? void 0 : participants.get(participantId); | ||
var unSetTrack = function unSetTrack(stream) { | ||
if (stream.track.readyState !== 'live') { | ||
switch (stream.kind) { | ||
case 'video': | ||
setwebcamStream(null); | ||
break; | ||
case 'audio': | ||
setMicStream(null); | ||
break; | ||
case 'share': | ||
setScreenShareStream(null); | ||
break; | ||
} | ||
} | ||
}; | ||
var _handleStreamEnabled = function _handleStreamEnabled(stream) { | ||
onStreamEnabled(stream); | ||
}; | ||
var _handleStreamDisabled = function _handleStreamDisabled(stream) { | ||
unSetTrack(stream); | ||
onStreamDisabled(stream); | ||
}; | ||
var setQuality = function setQuality(quality) { | ||
participant === null || participant === void 0 ? void 0 : participant.setQuality(quality); | ||
}; | ||
var enableMic = function enableMic() { | ||
participant === null || participant === void 0 ? void 0 : participant.enableMic(); | ||
}; | ||
var disableMic = function disableMic() { | ||
participant === null || participant === void 0 ? void 0 : participant.disableMic(); | ||
}; | ||
var enableWebcam = function enableWebcam() { | ||
participant === null || participant === void 0 ? void 0 : participant.enableWebcam(); | ||
}; | ||
var disableWebcam = function disableWebcam() { | ||
participant === null || participant === void 0 ? void 0 : participant.disableWebcam(); | ||
}; | ||
React.useEffect(function () { | ||
var streams = participant === null || participant === void 0 ? void 0 : participant.streams; | ||
if (streams) { | ||
streams.forEach(function (stream) { | ||
}); | ||
} | ||
participant === null || participant === void 0 ? void 0 : participant.on('stream-enabled', _handleStreamEnabled); | ||
participant === null || participant === void 0 ? void 0 : participant.on('stream-disabled', _handleStreamDisabled); | ||
return function () { | ||
participant === null || participant === void 0 ? void 0 : participant.off('stream-enabled', _handleStreamEnabled); | ||
participant === null || participant === void 0 ? void 0 : participant.off('stream-disabled', _handleStreamDisabled); | ||
}; | ||
}, [participant]); | ||
return { | ||
displayName: participant === null || participant === void 0 ? void 0 : participant.displayName, | ||
participant: participant, | ||
webcamStream: webcamStream, | ||
micStream: micStream, | ||
screenShareStream: screenShareStream, | ||
webcamOn: !!webcamStream, | ||
micOn: !!micStream, | ||
screenShareOn: !!screenShareStream, | ||
isLocal: (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.id) === participantId, | ||
isActiveSpeaker: activeSpeakerId === participantId, | ||
isMainParticipant: (mainParticipant === null || mainParticipant === void 0 ? void 0 : mainParticipant.id) === participantId, | ||
setQuality: setQuality, | ||
enableMic: enableMic, | ||
disableMic: disableMic, | ||
enableWebcam: enableWebcam, | ||
disableWebcam: disableWebcam | ||
}; | ||
}; | ||
exports.MeetingConsumer = MeetingConsumer; | ||
exports.MeetingProvider = MeetingProvider; | ||
exports.MeetingProvider = MeetingProvider1; | ||
exports.useMeeting = useMeeting; | ||
exports.useParticipant = useParticipant; | ||
exports.useParticipant = useParticipant1; | ||
//# sourceMappingURL=index.js.map |
@@ -1,599 +0,17 @@ | ||
import React, { createContext, useEffect, useContext, useState, useRef } from 'react'; | ||
import EventEmitter from 'events'; | ||
import { ZujoSDK } from '@videosdk.live/js'; | ||
var eventPrifix = 'zn-meeting-react-sdk'; | ||
var events = { | ||
'participant-joined': eventPrifix + "-participant-joined", | ||
'participant-left': eventPrifix + "-participant-left", | ||
'speaker-changed': eventPrifix + "-speaker-changed", | ||
'presenter-changed': eventPrifix + "-presenter-changed", | ||
'main-participant-changed': eventPrifix + "-main-participant-changed", | ||
'entry-requested': eventPrifix + "-entry-requested", | ||
'entry-responded': eventPrifix + "-entry-responded", | ||
'recording-started': eventPrifix + "-recording-started", | ||
'recording-stopped': eventPrifix + "-recording-stopped", | ||
'chat-message': eventPrifix + "-chat-message", | ||
'meeting-joined': eventPrifix + "-meeting-joined", | ||
'meeting-left': eventPrifix + "-meeting-left" | ||
var MeetingProvider1 = function MeetingProvider1() { | ||
return /*#__PURE__*/React.createElement(Fragment, null); | ||
}; | ||
var eventEmitter = new EventEmitter(); | ||
var MeetingProviderContex = createContext(); | ||
var useMeeting = function useMeeting(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$onParticipantJoi = _ref.onParticipantJoined, | ||
onParticipantJoined = _ref$onParticipantJoi === void 0 ? function () {} : _ref$onParticipantJoi, | ||
_ref$onParticipantLef = _ref.onParticipantLeft, | ||
onParticipantLeft = _ref$onParticipantLef === void 0 ? function () {} : _ref$onParticipantLef, | ||
_ref$onSpeakerChanged = _ref.onSpeakerChanged, | ||
onSpeakerChanged = _ref$onSpeakerChanged === void 0 ? function () {} : _ref$onSpeakerChanged, | ||
_ref$onPresenterChang = _ref.onPresenterChanged, | ||
onPresenterChanged = _ref$onPresenterChang === void 0 ? function () {} : _ref$onPresenterChang, | ||
_ref$onMainParticipan = _ref.onMainParticipantChanged, | ||
onMainParticipantChanged = _ref$onMainParticipan === void 0 ? function () {} : _ref$onMainParticipan, | ||
_ref$onEntryRequested = _ref.onEntryRequested, | ||
onEntryRequested = _ref$onEntryRequested === void 0 ? function () {} : _ref$onEntryRequested, | ||
_ref$onEntryResponded = _ref.onEntryResponded, | ||
onEntryResponded = _ref$onEntryResponded === void 0 ? function () {} : _ref$onEntryResponded, | ||
_ref$onRecordingStart = _ref.onRecordingStarted, | ||
onRecordingStarted = _ref$onRecordingStart === void 0 ? function () {} : _ref$onRecordingStart, | ||
_ref$onRecordingStopp = _ref.onRecordingStopped, | ||
onRecordingStopped = _ref$onRecordingStopp === void 0 ? function () {} : _ref$onRecordingStopp, | ||
_ref$onChatMessage = _ref.onChatMessage, | ||
onChatMessage = _ref$onChatMessage === void 0 ? function () {} : _ref$onChatMessage, | ||
_ref$onMeetingJoined = _ref.onMeetingJoined, | ||
onMeetingJoined = _ref$onMeetingJoined === void 0 ? function () {} : _ref$onMeetingJoined, | ||
_ref$onMeetingLeft = _ref.onMeetingLeft, | ||
onMeetingLeft = _ref$onMeetingLeft === void 0 ? function () {} : _ref$onMeetingLeft; | ||
useEffect(function () { | ||
eventEmitter.on(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.on(events['participant-left'], onParticipantLeft); | ||
eventEmitter.on(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.on(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.on(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.on(events['entry-requested'], onEntryRequested); | ||
eventEmitter.on(events['entry-responded'], onEntryResponded); | ||
eventEmitter.on(events['recording-started'], onRecordingStarted); | ||
eventEmitter.on(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.on(events['chat-message'], onChatMessage); | ||
eventEmitter.on(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.on(events['meeting-left'], onMeetingLeft); | ||
return function () { | ||
eventEmitter.off(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.off(events['participant-left'], onParticipantLeft); | ||
eventEmitter.off(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.off(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.off(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.off(events['entry-requested'], onEntryRequested); | ||
eventEmitter.off(events['entry-responded'], onEntryResponded); | ||
eventEmitter.off(events['recording-started'], onRecordingStarted); | ||
eventEmitter.off(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.off(events['chat-message'], onChatMessage); | ||
eventEmitter.off(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.off(events['meeting-left'], onMeetingLeft); | ||
}; | ||
}, []); | ||
return useContext(MeetingProviderContex); | ||
var useMeeting = function useMeeting() { | ||
return 'useMeeting'; | ||
}; | ||
var MeetingConsumer = function MeetingConsumer(_ref2) { | ||
var children = _ref2.children, | ||
_ref2$onParticipantJo = _ref2.onParticipantJoined, | ||
onParticipantJoined = _ref2$onParticipantJo === void 0 ? function () {} : _ref2$onParticipantJo, | ||
_ref2$onParticipantLe = _ref2.onParticipantLeft, | ||
onParticipantLeft = _ref2$onParticipantLe === void 0 ? function () {} : _ref2$onParticipantLe, | ||
_ref2$onSpeakerChange = _ref2.onSpeakerChanged, | ||
onSpeakerChanged = _ref2$onSpeakerChange === void 0 ? function () {} : _ref2$onSpeakerChange, | ||
_ref2$onPresenterChan = _ref2.onPresenterChanged, | ||
onPresenterChanged = _ref2$onPresenterChan === void 0 ? function () {} : _ref2$onPresenterChan, | ||
_ref2$onMainParticipa = _ref2.onMainParticipantChanged, | ||
onMainParticipantChanged = _ref2$onMainParticipa === void 0 ? function () {} : _ref2$onMainParticipa, | ||
_ref2$onEntryRequeste = _ref2.onEntryRequested, | ||
onEntryRequested = _ref2$onEntryRequeste === void 0 ? function () {} : _ref2$onEntryRequeste, | ||
_ref2$onEntryResponde = _ref2.onEntryResponded, | ||
onEntryResponded = _ref2$onEntryResponde === void 0 ? function () {} : _ref2$onEntryResponde, | ||
_ref2$onRecordingStar = _ref2.onRecordingStarted, | ||
onRecordingStarted = _ref2$onRecordingStar === void 0 ? function () {} : _ref2$onRecordingStar, | ||
_ref2$onRecordingStop = _ref2.onRecordingStopped, | ||
onRecordingStopped = _ref2$onRecordingStop === void 0 ? function () {} : _ref2$onRecordingStop, | ||
_ref2$onChatMessage = _ref2.onChatMessage, | ||
onChatMessage = _ref2$onChatMessage === void 0 ? function () {} : _ref2$onChatMessage, | ||
_ref2$onMeetingJoined = _ref2.onMeetingJoined, | ||
onMeetingJoined = _ref2$onMeetingJoined === void 0 ? function () {} : _ref2$onMeetingJoined, | ||
_ref2$onMeetingLeft = _ref2.onMeetingLeft, | ||
onMeetingLeft = _ref2$onMeetingLeft === void 0 ? function () {} : _ref2$onMeetingLeft; | ||
useEffect(function () { | ||
eventEmitter.on(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.on(events['participant-left'], onParticipantLeft); | ||
eventEmitter.on(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.on(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.on(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.on(events['entry-requested'], onEntryRequested); | ||
eventEmitter.on(events['entry-responded'], onEntryResponded); | ||
eventEmitter.on(events['recording-started'], onRecordingStarted); | ||
eventEmitter.on(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.on(events['chat-message'], onChatMessage); | ||
eventEmitter.on(events['chat-message'], onMeetingJoined); | ||
eventEmitter.on(events['chat-message'], onMeetingLeft); | ||
return function () { | ||
eventEmitter.off(events['participant-joined'], onParticipantJoined); | ||
eventEmitter.off(events['participant-left'], onParticipantLeft); | ||
eventEmitter.off(events['speaker-changed'], onSpeakerChanged); | ||
eventEmitter.off(events['presenter-changed'], onPresenterChanged); | ||
eventEmitter.off(events['main-participant-changed'], onMainParticipantChanged); | ||
eventEmitter.off(events['entry-requested'], onEntryRequested); | ||
eventEmitter.off(events['entry-responded'], onEntryResponded); | ||
eventEmitter.off(events['recording-started'], onRecordingStarted); | ||
eventEmitter.off(events['recording-stopped'], onRecordingStopped); | ||
eventEmitter.off(events['chat-message'], onChatMessage); | ||
eventEmitter.off(events['meeting-joined'], onMeetingJoined); | ||
eventEmitter.off(events['meeting-left'], onMeetingLeft); | ||
}; | ||
}, []); | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MeetingProviderContex.Consumer, null, children)); | ||
var MeetingConsumer = function MeetingConsumer() { | ||
return /*#__PURE__*/React.createElement(Fragment, null); | ||
}; | ||
var MeetingProvider = function MeetingProvider(_ref) { | ||
var children = _ref.children, | ||
config = _ref.config, | ||
token = _ref.token, | ||
joinWithoutUserInteraction = _ref.joinWithoutUserInteraction; | ||
var _useState = useState(null), | ||
meeting = _useState[0], | ||
setMeeting = _useState[1]; | ||
var _useState2 = useState(null), | ||
localParticipant = _useState2[0], | ||
setLocalParticipant = _useState2[1]; | ||
var _useState3 = useState(null), | ||
mainParticipant = _useState3[0], | ||
setMainParticipant = _useState3[1]; | ||
var _useState4 = useState(null), | ||
activeSpeakerId = _useState4[0], | ||
setActiveSpeakerId = _useState4[1]; | ||
var _useState5 = useState(new Map()), | ||
participants = _useState5[0], | ||
setParticipants = _useState5[1]; | ||
var _useState6 = useState(null), | ||
presenterId = _useState6[0], | ||
setPresenterId = _useState6[1]; | ||
var _useState7 = useState(false), | ||
localMicOn = _useState7[0], | ||
setLocalMicOn = _useState7[1]; | ||
var _useState8 = useState(false), | ||
localWebcamOn = _useState8[0], | ||
setLocalWebcamOn = _useState8[1]; | ||
var _useState9 = useState(false), | ||
localScreenShareOn = _useState9[0], | ||
setLocalScreenShareOn = _useState9[1]; | ||
var _useState10 = useState(false), | ||
isRecording = _useState10[0], | ||
setIsRecording = _useState10[1]; | ||
var _useState11 = useState([]), | ||
messages = _useState11[0], | ||
setMessages = _useState11[1]; | ||
var meetingRef = useRef(); | ||
var localMicOnRef = useRef(); | ||
var localWebcamOnRef = useRef(); | ||
var localScreenShareOnRef = useRef(); | ||
var isRecordingRef = useRef(); | ||
useEffect(function () { | ||
meetingRef.current = meeting; | ||
}, [meeting]); | ||
useEffect(function () { | ||
localMicOnRef.current = localMicOn; | ||
}, [localMicOn]); | ||
useEffect(function () { | ||
localWebcamOnRef.current = localWebcamOn; | ||
}, [localWebcamOn]); | ||
useEffect(function () { | ||
localScreenShareOnRef.current = localScreenShareOn; | ||
}, [localScreenShareOn]); | ||
useEffect(function () { | ||
isRecordingRef.current = isRecording; | ||
}, [isRecording]); | ||
var resetStates = function resetStates() { | ||
setMeeting(null); | ||
setLocalParticipant(null); | ||
setMainParticipant(null); | ||
setActiveSpeakerId(null); | ||
setParticipants(new Map()); | ||
setPresenterId(null); | ||
setLocalMicOn(false); | ||
setLocalWebcamOn(false); | ||
setLocalScreenShareOn(false); | ||
setIsRecording(false); | ||
setMessages([]); | ||
}; | ||
var _handle_participant_joined = function _handle_participant_joined(participant) { | ||
setParticipants(function (participants) { | ||
participants.set(participant.id, participant); | ||
var participantsToSet = new Map(participants); | ||
return participantsToSet; | ||
}); | ||
eventEmitter.emit(events['participant-joined'], participant); | ||
}; | ||
var _handle_participant_left = function _handle_participant_left(participant) { | ||
setParticipants(function (participants) { | ||
participants["delete"](participant.id); | ||
var newParticipants = new Map(participants); | ||
return newParticipants; | ||
}); | ||
eventEmitter.emit(events['participant-left'], participant); | ||
}; | ||
var _handle_presenter_changed = function _handle_presenter_changed(presenterId) { | ||
var _meetingRef$current, _meetingRef$current$l; | ||
setPresenterId(presenterId); | ||
setLocalScreenShareOn(presenterId === (meetingRef === null || meetingRef === void 0 ? void 0 : (_meetingRef$current = meetingRef.current) === null || _meetingRef$current === void 0 ? void 0 : (_meetingRef$current$l = _meetingRef$current.localParticipant) === null || _meetingRef$current$l === void 0 ? void 0 : _meetingRef$current$l.id)); | ||
eventEmitter.emit(events['presenter-changed'], presenterId); | ||
}; | ||
var _handle_main_participant_changed = function _handle_main_participant_changed(participant) { | ||
setMainParticipant(participant); | ||
eventEmitter.emit(events['main-participant-changed'], participant); | ||
}; | ||
var _handle_speaker_changed = function _handle_speaker_changed(activeSpeakerId) { | ||
setActiveSpeakerId(activeSpeakerId); | ||
eventEmitter.emit(events['speaker-changed'], activeSpeakerId); | ||
}; | ||
var _handle_chat_message = function _handle_chat_message(data) { | ||
eventEmitter.emit(events['chat-message'], data); | ||
setMessages(function (s) { | ||
return [].concat(s, [data]); | ||
}); | ||
}; | ||
var _handle_entry_requested = function _handle_entry_requested(participantId, name) { | ||
eventEmitter.emit(events['entry-requested'], participantId, name); | ||
}; | ||
var _handle_entry_responded = function _handle_entry_responded(participantId, name) { | ||
eventEmitter.emit(events['entry-responded'], participantId, name); | ||
}; | ||
var _handle_recording_started = function _handle_recording_started() { | ||
setIsRecording(true); | ||
eventEmitter.emit(events['recording-started']); | ||
}; | ||
var _handle_recording_stopped = function _handle_recording_stopped() { | ||
setIsRecording(false); | ||
eventEmitter.emit(events['recording-stopped']); | ||
}; | ||
var _handle_meeting_joined = function _handle_meeting_joined() { | ||
eventEmitter.emit(events['meeting-joined']); | ||
}; | ||
var _handle_meeting_left = function _handle_meeting_left() { | ||
eventEmitter.emit(events['meeting-left']); | ||
}; | ||
var _handle_localParticipant_stream_enabled = function _handle_localParticipant_stream_enabled(stream) { | ||
if (stream.track.readyState === 'live') { | ||
if (stream.kind === 'video') { | ||
setLocalWebcamOn(true); | ||
} else if (stream.kind === 'audio') { | ||
setLocalMicOn(true); | ||
} | ||
} | ||
}; | ||
var _handle_localParticipant_stream_disabled = function _handle_localParticipant_stream_disabled(stream) { | ||
if (stream.track.readyState === 'ended') { | ||
if (stream.kind === 'video') { | ||
setLocalWebcamOn(false); | ||
} else if (stream.kind === 'audio') { | ||
setLocalMicOn(false); | ||
} | ||
} | ||
}; | ||
var join = function join() { | ||
var meeting = ZujoSDK.initMeeting(config); | ||
setMeeting(meeting); | ||
var localParticipant = meeting.localParticipant, | ||
participants = meeting.participants, | ||
messages = meeting.messages; | ||
participants.set(localParticipant.id, localParticipant); | ||
setParticipants(participants); | ||
setLocalParticipant(localParticipant); | ||
setMessages(messages); | ||
meeting.on('participant-joined', _handle_participant_joined); | ||
meeting.on('participant-left', _handle_participant_left); | ||
meeting.on('presenter-changed', _handle_presenter_changed); | ||
meeting.on('main-participant-changed', _handle_main_participant_changed); | ||
meeting.on('speaker-changed', _handle_speaker_changed); | ||
meeting.on('entry-requested', _handle_entry_requested); | ||
meeting.on('entry-responded', _handle_entry_responded); | ||
meeting.on('chat-message', _handle_chat_message); | ||
meeting.on('recording-started', _handle_recording_started); | ||
meeting.on('recording-stopped', _handle_recording_stopped); | ||
meeting.on('meeting-joined', _handle_meeting_joined); | ||
meeting.on('meeting-left', _handle_meeting_left); | ||
meeting.localParticipant.on('stream-enabled', _handle_localParticipant_stream_enabled); | ||
meeting.localParticipant.on('stream-disabled', _handle_localParticipant_stream_disabled); | ||
meeting.join(); | ||
}; | ||
var leave = function leave() { | ||
var _meeting$localPartici; | ||
var meeting = meetingRef.current; | ||
if (typeof (meeting === null || meeting === void 0 ? void 0 : meeting.off) === 'function') { | ||
meeting.off('participant-joined', _handle_participant_joined); | ||
meeting.off('participant-left', _handle_participant_left); | ||
meeting.off('presenter-changed', _handle_presenter_changed); | ||
meeting.off('main-participant-changed', _handle_main_participant_changed); | ||
meeting.off('speaker-changed', _handle_speaker_changed); | ||
meeting.off('chat-message', _handle_chat_message); | ||
meeting.off('meeting-joined', _handle_meeting_joined); | ||
meeting.off('meeting-left', _handle_meeting_left); | ||
} | ||
if (typeof (meeting === null || meeting === void 0 ? void 0 : (_meeting$localPartici = meeting.localParticipant) === null || _meeting$localPartici === void 0 ? void 0 : _meeting$localPartici.off) === 'function') { | ||
meeting.localParticipant.off('stream-enabled', _handle_localParticipant_stream_enabled); | ||
meeting.localParticipant.off('stream-disabled', _handle_localParticipant_stream_disabled); | ||
} | ||
meeting.leave(); | ||
resetStates(); | ||
}; | ||
var startRecording = function startRecording(webhookUrl) { | ||
var meeting = meetingRef.current; | ||
meeting.startRecording(webhookUrl); | ||
}; | ||
var stopRecording = function stopRecording() { | ||
var meeting = meetingRef.current; | ||
var isRecording = isRecordingRef.current; | ||
if (isRecording) { | ||
meeting.stopRecording(); | ||
} | ||
}; | ||
var unmuteMic = function unmuteMic() { | ||
var meeting = meetingRef.current; | ||
meeting.unmuteMic(); | ||
}; | ||
var muteMic = function muteMic() { | ||
var meeting = meetingRef.current; | ||
meeting.muteMic(); | ||
}; | ||
var toggleMic = function toggleMic() { | ||
var localMicOn = localMicOnRef.current; | ||
if (localMicOn) { | ||
muteMic(); | ||
} else { | ||
unmuteMic(); | ||
} | ||
}; | ||
var disableWebcam = function disableWebcam() { | ||
var meeting = meetingRef.current; | ||
meeting.disableWebcam(); | ||
}; | ||
var enableWebcam = function enableWebcam() { | ||
var meeting = meetingRef.current; | ||
meeting.enableWebcam(); | ||
}; | ||
var toggleWebcam = function toggleWebcam() { | ||
var localWebcamOn = localWebcamOnRef.current; | ||
if (localWebcamOn) { | ||
disableWebcam(); | ||
} else { | ||
enableWebcam(); | ||
} | ||
}; | ||
var disableScreenShare = function disableScreenShare() { | ||
var meeting = meetingRef.current; | ||
meeting.disableScreenShare(); | ||
}; | ||
var enableScreenShare = function enableScreenShare() { | ||
var meeting = meetingRef.current; | ||
meeting.enableScreenShare(); | ||
}; | ||
var toggleScreenShare = function toggleScreenShare() { | ||
var localScreenShareOn = localScreenShareOnRef.current; | ||
if (localScreenShareOn) { | ||
disableScreenShare(); | ||
} else { | ||
enableScreenShare(); | ||
} | ||
}; | ||
var sendChatMessage = function sendChatMessage(text) { | ||
var meeting = meetingRef.current; | ||
meeting.sendChatMessage(text); | ||
}; | ||
var respondEntry = function respondEntry(participantId, decision) { | ||
var meeting = meetingRef.current; | ||
meeting.respondEntry(participantId, decision); | ||
}; | ||
var initSDK = function initSDK() { | ||
ZujoSDK.config(token); | ||
if (joinWithoutUserInteraction) { | ||
join(); | ||
} | ||
}; | ||
useEffect(function () { | ||
initSDK(); | ||
}, []); | ||
return /*#__PURE__*/React.createElement(MeetingProviderContex.Provider, { | ||
value: { | ||
meetingId: config.meetingId, | ||
meeting: meeting, | ||
localParticipant: localParticipant, | ||
mainParticipant: mainParticipant, | ||
activeSpeakerId: activeSpeakerId, | ||
participants: participants, | ||
presenterId: presenterId, | ||
localMicOn: localMicOn, | ||
localWebcamOn: localWebcamOn, | ||
localScreenShareOn: localScreenShareOn, | ||
messages: messages, | ||
join: join, | ||
leave: leave, | ||
startRecording: startRecording, | ||
stopRecording: stopRecording, | ||
sendChatMessage: sendChatMessage, | ||
respondEntry: respondEntry, | ||
muteMic: muteMic, | ||
unmuteMic: unmuteMic, | ||
toggleMic: toggleMic, | ||
disableWebcam: disableWebcam, | ||
enableWebcam: enableWebcam, | ||
toggleWebcam: toggleWebcam, | ||
disableScreenShare: disableScreenShare, | ||
enableScreenShare: enableScreenShare, | ||
toggleScreenShare: toggleScreenShare | ||
} | ||
}, children); | ||
var useParticipant1 = function useParticipant1() { | ||
return 'useParticipant1'; | ||
}; | ||
var useParticipant = function useParticipant(participantId, _temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$onStreamEnabled = _ref.onStreamEnabled, | ||
onStreamEnabled = _ref$onStreamEnabled === void 0 ? function () {} : _ref$onStreamEnabled, | ||
_ref$onStreamDisabled = _ref.onStreamDisabled, | ||
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled; | ||
var _useState = useState(null), | ||
webcamStream = _useState[0], | ||
setwebcamStream = _useState[1]; | ||
var _useState2 = useState(null), | ||
micStream = _useState2[0], | ||
setMicStream = _useState2[1]; | ||
var _useState3 = useState(null), | ||
screenShareStream = _useState3[0], | ||
setScreenShareStream = _useState3[1]; | ||
var meeting = useMeeting(); | ||
var participants = meeting === null || meeting === void 0 ? void 0 : meeting.participants; | ||
var localParticipant = meeting === null || meeting === void 0 ? void 0 : meeting.localParticipant; | ||
var activeSpeakerId = meeting === null || meeting === void 0 ? void 0 : meeting.activeSpeakerId; | ||
var mainParticipant = meeting === null || meeting === void 0 ? void 0 : meeting.mainParticipant; | ||
var participant = participants === null || participants === void 0 ? void 0 : participants.get(participantId); | ||
var unSetTrack = function unSetTrack(stream) { | ||
if (stream.track.readyState !== 'live') { | ||
switch (stream.kind) { | ||
case 'video': | ||
setwebcamStream(null); | ||
break; | ||
case 'audio': | ||
setMicStream(null); | ||
break; | ||
case 'share': | ||
setScreenShareStream(null); | ||
break; | ||
} | ||
} | ||
}; | ||
var _handleStreamEnabled = function _handleStreamEnabled(stream) { | ||
onStreamEnabled(stream); | ||
}; | ||
var _handleStreamDisabled = function _handleStreamDisabled(stream) { | ||
unSetTrack(stream); | ||
onStreamDisabled(stream); | ||
}; | ||
var setQuality = function setQuality(quality) { | ||
participant === null || participant === void 0 ? void 0 : participant.setQuality(quality); | ||
}; | ||
var enableMic = function enableMic() { | ||
participant === null || participant === void 0 ? void 0 : participant.enableMic(); | ||
}; | ||
var disableMic = function disableMic() { | ||
participant === null || participant === void 0 ? void 0 : participant.disableMic(); | ||
}; | ||
var enableWebcam = function enableWebcam() { | ||
participant === null || participant === void 0 ? void 0 : participant.enableWebcam(); | ||
}; | ||
var disableWebcam = function disableWebcam() { | ||
participant === null || participant === void 0 ? void 0 : participant.disableWebcam(); | ||
}; | ||
useEffect(function () { | ||
var streams = participant === null || participant === void 0 ? void 0 : participant.streams; | ||
if (streams) { | ||
streams.forEach(function (stream) { | ||
}); | ||
} | ||
participant === null || participant === void 0 ? void 0 : participant.on('stream-enabled', _handleStreamEnabled); | ||
participant === null || participant === void 0 ? void 0 : participant.on('stream-disabled', _handleStreamDisabled); | ||
return function () { | ||
participant === null || participant === void 0 ? void 0 : participant.off('stream-enabled', _handleStreamEnabled); | ||
participant === null || participant === void 0 ? void 0 : participant.off('stream-disabled', _handleStreamDisabled); | ||
}; | ||
}, [participant]); | ||
return { | ||
displayName: participant === null || participant === void 0 ? void 0 : participant.displayName, | ||
participant: participant, | ||
webcamStream: webcamStream, | ||
micStream: micStream, | ||
screenShareStream: screenShareStream, | ||
webcamOn: !!webcamStream, | ||
micOn: !!micStream, | ||
screenShareOn: !!screenShareStream, | ||
isLocal: (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.id) === participantId, | ||
isActiveSpeaker: activeSpeakerId === participantId, | ||
isMainParticipant: (mainParticipant === null || mainParticipant === void 0 ? void 0 : mainParticipant.id) === participantId, | ||
setQuality: setQuality, | ||
enableMic: enableMic, | ||
disableMic: disableMic, | ||
enableWebcam: enableWebcam, | ||
disableWebcam: disableWebcam | ||
}; | ||
}; | ||
export { MeetingConsumer, MeetingProvider, useMeeting, useParticipant }; | ||
export { MeetingConsumer, MeetingProvider1 as MeetingProvider, useMeeting, useParticipant1 as useParticipant }; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "@videosdk.live/react", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44133
31
1