@daily-co/daily-react
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js")),o=e(require("fast-deep-equal"));function u(e,n,t,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(i,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function o(e){u(a,i,r,o,c,"next",e)}function c(e){u(a,i,r,o,c,"throw",e)}o(void 0)}))}}function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}var f=n.createContext(null),p=function(){return n.useContext(f)},v=n.createContext({on:function(){},off:function(){}}),y=0,m=function(){return y++},g=function(e,t){var i=n.useContext(v),r=i.off,a=i.on,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),s=n.useMemo((function(){return m()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",t),void c(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,u,r,a])},k=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(v),o=a.off,u=a.on,c=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=m(),e}),{}):((n={})[e]=m(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return u(e,n,c[e])})):u(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,c[e])})):o(e,c[e])}}}),[s,e,c,o,u])},b=i.atom({key:"daily-react-active-id",default:null}),h=i.atom({key:"daily-react-local-id",default:""}),S=i.atom({key:"daily-react-participants-objects",default:[]}),R=i.selectorFamily({key:"daily-react-participant",get:function(e){return function(n){var t;return null!=(t=(0,n.get)(S).find((function(n){return n.session_id===e})))?t:null}}}),A=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i,r;return r=null!=(i=(0,e.get)(S).find((function(e){return e.session_id===n})))?i:null,t.map((function(e){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(r,e)}))}}}),C=i.atom({key:"daily-react-waiting-participants",default:[]}),E=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),w=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(C).map((function(e){return n(E(e))}))}}),I=function(e){var r=e.children,a=p(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(h,e.local.session_id),t(S,Object.values(e))}))}}),[]);n.useEffect((function(){if(a){var e=setInterval((function(){var n=a.participants();"local"in n&&(o(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,o]);var u=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&o(e)}}),[a,o]);return g("started-camera",u),g("access-state-updated",u),g("joining-meeting",u),g("joined-meeting",n.useCallback((function(e){o(e.participants)}),[o])),k(["active-speaker-change","left-meeting","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;i(b,n),i(S,(function(e){return[].concat(e).map((function(e){return e.session_id===n?l({},e,{last_active:new Date}):e}))}));break;case"participant-joined":i(S,(function(n){return[].concat(n,[e.participant]).filter((function(e,n,t){return t.findIndex((function(n){return n.session_id===e.session_id}))==n}))}));break;case"participant-updated":i(S,(function(n){return[].concat(n).map((function(n){return n.session_id===e.participant.session_id?l({},e.participant,{last_active:n.last_active}):n}))})),e.participant.local&&i(h,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));break;case"participant-left":i(S,(function(n){return[].concat(n).filter((function(n){return e.participant.session_id!==n.session_id}))}));break;case"left-meeting":t(h),t(S)}}))}))}}),[])),k(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":i(C,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),i(E(e.participant.id),e.participant);break;case"waiting-participant-updated":i(E(e.participant.id),e.participant);break;case"waiting-participant-removed":i(C,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(E(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,r)},x=function(){return i.useRecoilValue(h)},L=function(){return!0},P=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?L:r,o=t.ignoreLocal,u=void 0!==o&&o,c=x(),l=i.useRecoilValue(b),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){u&&l===c||(null==a?void 0:a(l))&&f(l)}),[a,c,u,l]),d},T=function(e){return["blocked","off"].includes(e.state)},_=Boolean,D=function(){return 0},M=function(e){var t=void 0===e?{filter:_,sort:D}:e,r=t.filter,a=void 0===r?_:r,o=t.onActiveSpeakerChange,u=t.onParticipantJoined,c=t.onParticipantLeft,l=t.onParticipantUpdated,s=t.sort,d=void 0===s?D:s,f=i.useRecoilValue(S),p=n.useMemo((function(){var e=_;switch(a){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return!T(e.tracks.screenAudio)||!T(e.tracks.screenVideo)};break;default:e=a}return e}),[a]),v=n.useMemo((function(){var e;switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[d],i=n[d];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=d}return e}),[d]),y=n.useMemo((function(){return f.filter(p).sort(v).map((function(e){return e.session_id})).filter(Boolean)}),[f,p,v]);return k(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&e.forEach((function(e){switch(e.action){case"participant-joined":null==u||u(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==c||c(e)}}))}),[o,u,c,l])),y},j=function(e){var t=void 0===e?{}:e,i=t.onLocalScreenShareStarted,r=t.onLocalScreenShareStopped,a=p(),o=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==a||a.startScreenShare.apply(a,n)}),[a]),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==a||a.stopScreenShare.apply(a,n)}),[a]);g("local-screen-share-started",n.useCallback((function(){return null==i?void 0:i()}),[i])),g("local-screen-share-stopped",n.useCallback((function(){return null==r?void 0:r()}),[r]));var c=M({filter:"screen"}),l=n.useMemo((function(){return c.map((function(e){var n,t=Object.values(null!=(n=null==a||null==a.participants?void 0:a.participants())?n:{}).find((function(n){return n.session_id===e}));if(t)return{local:t.local,screenAudio:t.tracks.screenAudio,screenVideo:t.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:u}},V=function(e,n){var t=i.useRecoilValue(A({id:e,properties:Array.isArray(n)?n:[n]}));return Array.isArray(n)?t:t[0]},O=function(e,n){void 0===n&&(n="video");var t=V(e,"tracks."+n);return t?l({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}};function F(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var i=t[n];"function"==typeof i?i(e):i&&"object"==typeof i&&(i.current=e)}}),t)}var B=n.memo(n.forwardRef((function(e,i){var r=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,c=s(e,["onPlayFailed","sessionId","type"]),l=n.useRef(null),d=O(a,u),f=F(l,i);return n.useEffect((function(){var e=l.current;if(e&&(null==d?void 0:d.persistentTrack)){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==r||r({sessionId:a,target:e,type:u}))}),1500)},i=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",i),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",i)}}}),[null==d?void 0:d.persistentTrack,r,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},c,{"data-session-id":a,"data-audio-type":u}))})));B.displayName="DailyAudioTrack";var U=n.memo(n.forwardRef((function(e,r){var a=e.maxSpeakers,o=e.onPlayFailed,u=e.playLocalScreenAudio,l=void 0!==u&&u,s=n.useState(new Array(void 0===a?5:a).fill("")),d=s[0],f=s[1],p=j().screens,v=x(),y=P({ignoreLocal:!0}),m=n.useRef(null);n.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=m.current)?void 0:n.querySelector('audio[data-session-id="'+y+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[y]);var g=M({filter:n.useCallback((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)}),[])}),b=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){if(g.includes(e)){var t=(yield n.getPromise(S)).filter((function(e){return g.includes(e.session_id)}));f((function(n){var i;if(n.includes(e))return n;var r=function(e){return!e||!g.includes(e)};if(n.some(r)){var a=n.findIndex(r);return n[a]=e,[].concat(n)}var o=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&T(n.tracks.audio)}))}));if(o>=0)return n[o]=e,[].concat(n);var u=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==y})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!u.length){var c=n.findIndex((function(e){return e!==y}));return n[c]=e,[].concat(n)}var l=n.indexOf(null==(i=u[0])?void 0:i.session_id);return n[l]=e,[].concat(n)}))}}));return function(n){return e.apply(this,arguments)}}()}),[y,g]),h=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);k(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===v)return;b(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&b(e.participant.session_id);break;case"participant-left":h(e.participant.session_id)}}))}),[b,v,h]));var R=M({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:m},d.map((function(e,n){return t.createElement(B,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})})),p.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(B,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})})),R.map((function(e){return t.createElement(B,{key:e+"-rmp",onPlayFailed:o,sessionId:e,type:"rmpAudio"})})))})));U.displayName="DailyAudio";var N=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,c=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,y=void 0===v?{}:v,m=e.type,g=void 0===m?"video":m,k=s(e,["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"]),b=x()===p,h="screenVideo"===g,S=b&&!h,R=n.useRef(null),A=F(R,i),C=O(p,g),E=C.persistentTrack,w=S||h||!C.isOff,I=V(p,"tracks."+g),L=null==I?void 0:I.subscribed,P=n.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!E)return S;var e=E.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[r,S,u,E]);return n.useEffect((function(){var e=R.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},i=function(){e.style.transform="scale(1)"},r=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",i),e.addEventListener("leavepictureinpicture",r),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",i),e.removeEventListener("leavepictureinpicture",r),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=R.current;if(e&&E)return e.srcObject=new MediaStream([E]),e.load(),function(){e.srcObject=null,e.load()}}),[E,null==E?void 0:E.id]),n.useEffect((function(){var e,n=R.current;if(c&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=R.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==c||c({aspectRatio:n/t,height:t,width:n}))}}))}}),[c]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:A,"data-local":b,"data-mirrored":P||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":L,"data-video-type":g,style:l({objectFit:o,transform:P?"scale(-1, 1)":""},y,w?f:{})},k))}));N.displayName="DailyVideo";var q=n.createContext({refreshDevices:function(){return Promise.resolve()}}),W=i.atom({key:"daily-react-general-camera-state",default:"idle"}),z=i.atom({key:"daily-react-general-microphone-state",default:"idle"}),H=i.atom({key:"daily-react-camera-devices",default:[]}),G=i.atom({key:"daily-react-microphone-devices",default:[]}),Q=i.atom({key:"daily-react-speaker-devices",default:[]}),J=i.atom({key:"daily-react-last-camera-error",default:null}),$=function(e){var r=e.children,a=p(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return c((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},y=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n((function(e){var n=e.set;n(H,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(y)})),n(G,(function(e){return c.filter(Boolean).map((function(n){return v(f,n,e)})).sort(y)})),n(Q,(function(e){return l.filter(Boolean).map((function(n){return v(p,n,e)})).sort(y)}))}))}catch(e){n((function(e){var n=e.set;n(W,"not-supported"),n(z,"not-supported")}))}}else n((function(e){var n=e.set;n(W,"not-supported"),n(z,"not-supported")}))}))}),[a]),u=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return c((function*(){var e,r,u,c,s,d,f,p,v,y,m,g,k,b;if(a){var h=yield t.getPromise(W),S=yield t.getPromise(z),R=a.participants();if(R.local){var A=R.local.tracks,C=["idle","pending"].includes(h)&&"interrupted"===A.video.state&&!A.video.persistentTrack,E=["idle","pending"].includes(h)&&!A.video.persistentTrack&&Boolean(null==(e=A.video.off)?void 0:e.byUser),w=["idle","pending"].includes(S)&&"interrupted"===A.audio.state&&!A.audio.persistentTrack,I=["idle","pending"].includes(S)&&!A.audio.persistentTrack&&Boolean(null==(r=A.audio.off)?void 0:r.byUser);(null==(u=A.audio)||null==(c=u.blocked)?void 0:c.byDeviceInUse)?i((function(e){var n=e.set;n(z,"in-use"),n(G,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):(null==(s=A.audio)||null==(d=s.blocked)?void 0:d.byDeviceMissing)?n(z,"not-found"):(null==(f=A.audio)||null==(p=f.blocked)?void 0:p.byPermissions)?n(z,"blocked"):w?n(z,"pending"):I?n(z,"idle"):i((function(e){var n=e.set;n(z,"granted"),n(G,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),(null==(v=A.video)||null==(y=v.blocked)?void 0:y.byDeviceInUse)?i((function(e){var n=e.set;n(W,"in-use"),n(H,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):(null==(m=A.video)||null==(g=m.blocked)?void 0:g.byDeviceMissing)?n(W,"not-found"):(null==(k=A.video)||null==(b=k.blocked)?void 0:b.byPermissions)?n(W,"blocked"):C?n(W,"pending"):E?n(W,"idle"):i((function(e){var n=e.set;n(W,"granted"),n(H,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return g("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),g("available-devices-updated",o),g("selected-devices-updated",o),g("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,u,c,l=n.set;switch(l(J,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(W,"in-use");break;case"mic-in-use":l(z,"in-use");break;case"cam-mic-in-use":l(W,"in-use"),l(z,"in-use");break;case"not-found":(null==(i=e.error)?void 0:i.missingMedia.includes("video"))&&l(W,"not-found"),(null==(r=e.error)?void 0:r.missingMedia.includes("audio"))&&l(z,"not-found");break;case"permissions":(null==(a=e.error)?void 0:a.blockedMedia.includes("video"))&&l(W,"blocked"),(null==(o=e.error)?void 0:o.blockedMedia.includes("audio"))&&l(z,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(l(W,"constraints-invalid"),l(z,"constraints-invalid")):"none-specified"===(null==(c=e.error)?void 0:c.reason)&&(l(W,"constraints-none-specified"),l(z,"constraints-none-specified"));break;case"undefined-mediadevices":l(W,"undefined-mediadevices"),l(z,"undefined-mediadevices");break;case"unknown":default:l(W,"unknown"),l(z,"unknown")}}))}}),[])),g("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(W,"granted"),n(z,"granted")})),u()}}),[u])),t.createElement(q.Provider,{value:{refreshDevices:o}},r)},K=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),X=function(e){var n=e.children;return g("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(K,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),g("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(K,(function(e){return l({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),g("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(K,(function(n){return l({},n,{errorMsg:e.errorMsg})}))}}),[])),t.createElement(t.Fragment,null,n)},Y=i.atom({key:"daily-react-meeting-state",default:"new"}),Z=function(e){var n=e.children,r=p(),a=i.useRecoilCallback((function(e){var n=e.set;return function(){if(r){var e=r.meetingState();return n(Y,e),e}}}),[r]);return g("loading",a),g("loaded",a),g("joining-meeting",a),g("joined-meeting",a),g("left-meeting",a),g("error",a),t.createElement(t.Fragment,null,n)},ee=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),ne=function(e){var r=e.children,a=i.useSetRecoilState(ee),o=x(),u=M({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return l({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),g("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;o&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==o&&(t=!1)}n(ee,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),g("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ee,(function(e){return l({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),g("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ee,(function(e){return l({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),t.createElement(t.Fragment,null,r)},te=function(){return i.useRecoilValue(Y)},ie=i.atom({key:"daily-react-room",default:null}),re=function(e){var n=e.children,r=p(),a=te(),o=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(r&&"left-meeting"!==a){var e=yield r.room();return e&&"id"in e&&n(ie,e),e}}))}),[r,a]);return g("access-state-updated",o),t.createElement(t.Fragment,null,n)},ae=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,u=i.useRecoilValue(R(e));return k(["participant-updated","participant-left"],n.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==a||a(e)}}))}),[a,o,e])),u},oe="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),ue=i.atom({key:"daily-react-input-settings",default:null}),ce=i.atom({key:"daily-react-input-settings-error",default:null}),le=i.atom({key:"daily-react-topology",default:"none"}),se=i.atom({key:"daily-react-networkQuality",default:100}),de=i.atom({key:"daily-react-networkThreshold",default:"good"}),fe=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),pe=function(){return i.useRecoilValue(ie)},ve=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}});exports.DailyAudio=U,exports.DailyAudioTrack=B,exports.DailyProvider=function(e){var r=e.children,u=e.recoilRootProps,p=void 0===u?{}:u,y=s(e,["children","recoilRootProps"]),m="callObject"in y?y.callObject:null,g=n.useState(m),k=g[0],b=g[1],h=n.useRef({});n.useEffect((function(){m&&(m?((null==k?void 0:k._callFrameId)!==(null==m?void 0:m._callFrameId)||!k&&m)&&b(m):b(null))}),[k,m]);var S=n.useCallback((function(e){if("action"in e)for(var n,t=function(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,void 0):void 0}}(e))){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(null!=(i=null==(r=h.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),R=n.useCallback((function(e){e&&Object.keys(h.current).forEach((function(n){e.off(n,S),e.isDestroyed()||e.on(n,S)}))}),[S]),A=n.useRef();n.useEffect((function(){if("callObject"in y)return b(y.callObject),void R(y.callObject);function e(){return(e=c((function*(e){yield e.destroy()}))).apply(this,arguments)}if(k)o(A.current,y)||function(n){e.apply(this,arguments)}(k);else{var n=a.getCallInstance();n||(n=a.createCallObject(l({},y)),A.current=y),b(n),R(n),n.once("call-instance-destroyed",(function(){b(null)}))}}),[k,R,y]);var C=n.useCallback((function(e,n,t){var i,r;h.current[e]||(h.current[e]=new Map,k&&(k.off(e,S),k.isDestroyed()||k.on(e,S))),(null==(i=h.current[e])?void 0:i.has(t))||null==(r=h.current[e])||r.set(t,n)}),[k,S]),E=n.useCallback((function(e,n){var t,i;null==(t=h.current[e])||t.delete(n),0===(null==(i=h.current[e])?void 0:i.size)&&(null==k||k.off(e,S),delete h.current[e])}),[k,S]);return t.createElement(i.RecoilRoot,Object.assign({},p),t.createElement(f.Provider,{value:k},t.createElement(v.Provider,{value:{on:C,off:E}},t.createElement(re,null,t.createElement(Z,null,t.createElement(I,null,t.createElement(ne,null,t.createElement(X,null,t.createElement($,null,r)))))))))},exports.DailyVideo=N,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=p(),c=i.useRecoilValue(b),l=n.useState(""),s=l[1],d=ae(l[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==n?void 0:n.session_id)||s(null!=c?c:"")}}),[u,a,c]),g("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},exports.useActiveSpeakerId=P,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=p(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return g("app-message",a),r},exports.useAudioLevel=function(e,t){var i=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){i.current||(i.current=new n);var r=i.current;if(r){var a,o=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{a=new AudioWorkletNode(r,"audiolevel")}catch(e){try{yield r.audioWorklet.addModule(oe),a=new AudioWorkletNode(r,"audiolevel")}catch(e){console.error(e)}}if(a){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)};try{o.connect(a).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==o||o.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return O(e,"audio")},exports.useDaily=p,exports.useDailyEvent=g,exports.useDevices=function(){var e=p(),t=i.useRecoilValue(W),r=i.useRecoilValue(z),a=i.useRecoilValue(H),o=i.useRecoilValue(G),u=i.useRecoilValue(Q),l=i.useRecoilValue(J),s=n.useContext(q).refreshDevices,d=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),y=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,hasCamError:y.includes(t),hasMicError:y.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:v,speakers:u}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(ue),u=i.useRecoilValue(ce),c=p(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ue,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),g("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),g("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(ce,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==c||c.updateInputSettings.apply(c,n)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=p(),c=i.useRecoilValue(K);return g("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),g("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),g("live-streaming-error",n.useCallback((function(e){null==r||r(e)}),[r])),l({},c,{startLiveStreaming:n.useCallback((function(){u&&u.startLiveStreaming.apply(u,arguments)}),[u]),stopLiveStreaming:n.useCallback((function(){u&&u.stopLiveStreaming.apply(u,arguments)}),[u]),updateLiveStreaming:n.useCallback((function(){u&&u.updateLiveStreaming.apply(u,arguments)}),[u])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(h);return ae(e)},exports.useLocalSessionId=x,exports.useMediaTrack=O,exports.useMeetingState=te,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=p(),u=i.useRecoilValue(le),l=i.useRecoilValue(se),s=i.useRecoilValue(de),d=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(le,e.topology)}}))}),[o]),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(le,"peer"),"sfu"===e.type&&t(le,"sfu")}})),null==r||r(e)}}),[r]),v=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(se,(function(n){return n!==e.quality?e.quality:n})),t(de,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return g("joined-meeting",d),g("network-connection",f),g("network-quality-change",v),n.useEffect((function(){o&&!u&&d()}),[o,d,u]),{getStats:n.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u}},exports.useParticipant=ae,exports.useParticipantIds=M,exports.useParticipantProperty=V,exports.usePermissions=function(){var e=x(),n=V(e,"permissions"),t="boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("audio"),i="boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("video");return{canSendAudio:t,canSendCustomAudio:"boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("customAudio"),canSendCustomVideo:"boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("customVideo"),canSendScreenAudio:"boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("screenAudio"),canSendScreenVideo:"boolean"==typeof(null==n?void 0:n.canSend)?null==n?void 0:n.canSend:null==n?void 0:n.canSend.has("screenVideo"),canSendVideo:i,hasPresence:null==n?void 0:n.hasPresence,permissions:n}},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,u=i.useRecoilValue(fe("base")),c=i.useRecoilValue(fe(a)),s=p(),d=te(),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=l({},e),o=0,u=Object.entries(r);o<u.length;o++){var c=u[o],s=c[1];i(fe(c[0]),s)}a in r||t(fe(a))}))}}),[a]);g("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var v=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]);return{receiveSettings:"base"===a||0===Object.keys(c).length?u:c,updateReceiveSettings:v}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,c=p(),s=i.useRecoilValue(ee);return g("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),g("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),g("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),g("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),l({},s,{startRecording:n.useCallback((function(){c&&c.startRecording.apply(c,arguments)}),[c]),stopRecording:n.useCallback((function(){c&&c.stopRecording.apply(c,arguments)}),[c]),updateRecording:n.useCallback((function(){c&&c.updateRecording.apply(c,arguments)}),[c])})},exports.useRoom=pe,exports.useScreenAudioTrack=function(e){return O(e,"screenAudio")},exports.useScreenShare=j,exports.useScreenVideoTrack=function(e){return O(e,"screenVideo")},exports.useThrottledDailyEvent=k,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,u=r.onTranscriptionStarted,c=r.onTranscriptionStopped,s=p(),d=i.useRecoilValue(ve),f=i.useSetRecoilState(ve),v=pe();return n.useEffect((function(){var e;(null==v||null==(e=v.domainConfig)?void 0:e.enable_transcription)&&f((function(e){return l({},e,{isTranscriptionEnabled:!0})}))}),[null==v||null==(t=v.domainConfig)?void 0:t.enable_transcription,f]),g("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ve,l({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==u||u(e)}}),[u])),g("transcription-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ve,(function(n){return l({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})})),null==c||c(e)}}),[c])),g("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ve,(function(e){return l({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),g("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&(null==e||null==(t=e.data)?void 0:t.is_final)&&(n(ve,(function(n){return l({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),l({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])})},exports.useVideoTrack=function(e){return O(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=p(),c=i.useRecoilValue(w),l=n.useCallback((function(e){null==r||r(e)}),[r]),s=n.useCallback((function(e){null==a||a(e)}),[a]),d=n.useCallback((function(e){null==o||o(e)}),[o]);g("waiting-participant-added",l),g("waiting-participant-removed",s),g("waiting-participant-updated",d);var f=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){f(e,!0)}),[f]),denyAccess:n.useCallback((function(e){f(e,!1)}),[f])}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js")),o=e(require("fast-deep-equal"));function u(e,n,t,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(i,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function o(e){u(a,i,r,o,c,"next",e)}function c(e){u(a,i,r,o,c,"throw",e)}o(void 0)}))}}function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}var f=n.createContext(null),p=function(){return n.useContext(f)},v=n.createContext({on:function(){},off:function(){}}),y=0,m=function(){return y++},g=function(e,t){var i=n.useContext(v),r=i.off,a=i.on,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),s=n.useMemo((function(){return m()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",t),void c(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,u,r,a])},k=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(v),o=a.off,u=a.on,c=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=m(),e}),{}):((n={})[e]=m(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return u(e,n,c[e])})):u(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,c[e])})):o(e,c[e])}}}),[s,e,c,o,u])},b=i.atom({key:"daily-react-active-id",default:null}),S=i.atom({key:"daily-react-local-id",default:""}),h=i.atom({key:"daily-react-participants-objects",default:[]}),R=i.selectorFamily({key:"daily-react-participant",get:function(e){return function(n){var t;return null!=(t=(0,n.get)(h).find((function(n){return n.session_id===e})))?t:null}}}),C=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i,r;return r=null!=(i=(0,e.get)(h).find((function(e){return e.session_id===n})))?i:null,t.map((function(e){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(r,e)}))}}}),A=i.atom({key:"daily-react-waiting-participants",default:[]}),E=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),w=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(A).map((function(e){return n(E(e))}))}}),I=function(e){var r=e.children,a=p(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(S,e.local.session_id),t(h,Object.values(e))}))}}),[]);n.useEffect((function(){if(a){var e=setInterval((function(){var n=a.participants();"local"in n&&(o(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,o]);var u=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&o(e)}}),[a,o]);return g("started-camera",u),g("access-state-updated",u),g("joining-meeting",u),g("joined-meeting",n.useCallback((function(e){o(e.participants)}),[o])),k(["active-speaker-change","left-meeting","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;i(b,n),i(h,(function(e){return[].concat(e).map((function(e){return e.session_id===n?l({},e,{last_active:new Date}):e}))}));break;case"participant-joined":i(h,(function(n){return[].concat(n,[e.participant]).filter((function(e,n,t){return t.findIndex((function(n){return n.session_id===e.session_id}))==n}))}));break;case"participant-updated":i(h,(function(n){return[].concat(n).map((function(n){return n.session_id===e.participant.session_id?l({},e.participant,{last_active:n.last_active}):n}))})),e.participant.local&&i(S,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));break;case"participant-left":i(h,(function(n){return[].concat(n).filter((function(n){return e.participant.session_id!==n.session_id}))}));break;case"left-meeting":t(S),t(h)}}))}))}}),[])),k(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":i(A,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),i(E(e.participant.id),e.participant);break;case"waiting-participant-updated":i(E(e.participant.id),e.participant);break;case"waiting-participant-removed":i(A,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(E(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,r)},x=function(){return i.useRecoilValue(S)},L=function(){return!0},P=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?L:r,o=t.ignoreLocal,u=void 0!==o&&o,c=x(),l=i.useRecoilValue(b),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){u&&l===c||(null==a?void 0:a(l))&&f(l)}),[a,c,u,l]),d},T=function(e){return["blocked","off"].includes(e.state)},_=Boolean,D=function(){return 0},M=function(e){var t=void 0===e?{filter:_,sort:D}:e,r=t.filter,a=void 0===r?_:r,o=t.onActiveSpeakerChange,u=t.onParticipantJoined,c=t.onParticipantLeft,l=t.onParticipantUpdated,s=t.sort,d=void 0===s?D:s,f=i.useRecoilValue(h),p=n.useMemo((function(){var e=_;switch(a){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return!T(e.tracks.screenAudio)||!T(e.tracks.screenVideo)};break;default:e=a}return e}),[a]),v=n.useMemo((function(){var e;switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[d],i=n[d];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=d}return e}),[d]),y=n.useMemo((function(){return f.filter(p).sort(v).map((function(e){return e.session_id})).filter(Boolean)}),[f,p,v]);return k(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&e.forEach((function(e){switch(e.action){case"participant-joined":null==u||u(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==c||c(e)}}))}),[o,u,c,l])),y},V=function(e){var t=void 0===e?{}:e,i=t.onLocalScreenShareStarted,r=t.onLocalScreenShareStopped,a=p(),o=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==a||a.startScreenShare.apply(a,n)}),[a]),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==a||a.stopScreenShare.apply(a,n)}),[a]);g("local-screen-share-started",n.useCallback((function(){return null==i?void 0:i()}),[i])),g("local-screen-share-stopped",n.useCallback((function(){return null==r?void 0:r()}),[r]));var c=M({filter:"screen"}),l=n.useMemo((function(){return c.map((function(e){var n,t=Object.values(null!=(n=null==a||null==a.participants?void 0:a.participants())?n:{}).find((function(n){return n.session_id===e}));if(t)return{local:t.local,screenAudio:t.tracks.screenAudio,screenVideo:t.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:u}},j=function(e,n){var t=i.useRecoilValue(C({id:e,properties:Array.isArray(n)?n:[n]}));return Array.isArray(n)?t:t[0]},O=function(e,n){void 0===n&&(n="video");var t=j(e,"tracks."+n);return t?l({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}};function F(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var i=t[n];"function"==typeof i?i(e):i&&"object"==typeof i&&(i.current=e)}}),t)}var B=n.memo(n.forwardRef((function(e,i){var r=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,c=s(e,["onPlayFailed","sessionId","type"]),l=n.useRef(null),d=O(a,u),f=F(l,i);return n.useEffect((function(){var e=l.current;if(e&&(null==d?void 0:d.persistentTrack)){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==r||r({sessionId:a,target:e,type:u}))}),1500)},i=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",i),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",i)}}}),[null==d?void 0:d.persistentTrack,r,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},c,{"data-session-id":a,"data-audio-type":u}))})));B.displayName="DailyAudioTrack";var U=n.memo(n.forwardRef((function(e,r){var a=e.maxSpeakers,o=e.onPlayFailed,u=e.playLocalScreenAudio,l=void 0!==u&&u,s=n.useState(new Array(void 0===a?5:a).fill("")),d=s[0],f=s[1],p=V().screens,v=x(),y=P({ignoreLocal:!0}),m=n.useRef(null);n.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=m.current)?void 0:n.querySelector('audio[data-session-id="'+y+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[y]);var g=M({filter:n.useCallback((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)}),[])}),b=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){if(g.includes(e)){var t=(yield n.getPromise(h)).filter((function(e){return g.includes(e.session_id)}));f((function(n){var i;if(n.includes(e))return n;var r=function(e){return!e||!g.includes(e)};if(n.some(r)){var a=n.findIndex(r);return n[a]=e,[].concat(n)}var o=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&T(n.tracks.audio)}))}));if(o>=0)return n[o]=e,[].concat(n);var u=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==y})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!u.length){var c=n.findIndex((function(e){return e!==y}));return n[c]=e,[].concat(n)}var l=n.indexOf(null==(i=u[0])?void 0:i.session_id);return n[l]=e,[].concat(n)}))}}));return function(n){return e.apply(this,arguments)}}()}),[y,g]),S=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);k(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===v)return;b(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&b(e.participant.session_id);break;case"participant-left":S(e.participant.session_id)}}))}),[b,v,S]));var R=M({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:m},d.map((function(e,n){return t.createElement(B,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})})),p.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(B,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})})),R.map((function(e){return t.createElement(B,{key:e+"-rmp",onPlayFailed:o,sessionId:e,type:"rmpAudio"})})))})));U.displayName="DailyAudio";var N=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,c=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,y=void 0===v?{}:v,m=e.type,g=void 0===m?"video":m,k=s(e,["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"]),b=x()===p,S="screenVideo"===g,h=b&&!S,R=n.useRef(null),C=F(R,i),A=O(p,g),E=A.persistentTrack,w=h||S||!A.isOff,I=j(p,"tracks."+g),L=null==I?void 0:I.subscribed,P=n.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!E)return h;var e=E.getSettings();return"facingMode"in e?h&&"user"===e.facingMode:h}),[r,h,u,E]);return n.useEffect((function(){var e=R.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},i=function(){e.style.transform="scale(1)"},r=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",i),e.addEventListener("leavepictureinpicture",r),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",i),e.removeEventListener("leavepictureinpicture",r),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=R.current;if(e&&E)return e.srcObject=new MediaStream([E]),e.load(),function(){e.srcObject=null,e.load()}}),[E,null==E?void 0:E.id]),n.useEffect((function(){var e,n=R.current;if(c&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=R.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==c||c({aspectRatio:n/t,height:t,width:n}))}}))}}),[c]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:C,"data-local":b,"data-mirrored":P||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":L,"data-video-type":g,style:l({objectFit:o,transform:P?"scale(-1, 1)":""},y,w?f:{})},k))}));N.displayName="DailyVideo";var q=n.createContext({refreshDevices:function(){return Promise.resolve()}}),W=i.atom({key:"daily-react-general-camera-state",default:"idle"}),z=i.atom({key:"daily-react-general-microphone-state",default:"idle"}),H=i.atom({key:"daily-react-camera-devices",default:[]}),G=i.atom({key:"daily-react-microphone-devices",default:[]}),Q=i.atom({key:"daily-react-speaker-devices",default:[]}),J=i.atom({key:"daily-react-last-camera-error",default:null}),$=function(e){var r=e.children,a=p(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return c((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},y=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n((function(e){var n=e.set;n(H,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(y)})),n(G,(function(e){return c.filter(Boolean).map((function(n){return v(f,n,e)})).sort(y)})),n(Q,(function(e){return l.filter(Boolean).map((function(n){return v(p,n,e)})).sort(y)}))}))}catch(e){n((function(e){var n=e.set;n(W,"not-supported"),n(z,"not-supported")}))}}else n((function(e){var n=e.set;n(W,"not-supported"),n(z,"not-supported")}))}))}),[a]),u=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return c((function*(){var e,r,u,c,s,d,f,p,v,y,m,g,k,b;if(a){var S=yield t.getPromise(W),h=yield t.getPromise(z),R=a.participants();if(R.local){var C=R.local.tracks,A=["idle","pending"].includes(S)&&"interrupted"===C.video.state&&!C.video.persistentTrack,E=["idle","pending"].includes(S)&&!C.video.persistentTrack&&Boolean(null==(e=C.video.off)?void 0:e.byUser),w=["idle","pending"].includes(h)&&"interrupted"===C.audio.state&&!C.audio.persistentTrack,I=["idle","pending"].includes(h)&&!C.audio.persistentTrack&&Boolean(null==(r=C.audio.off)?void 0:r.byUser);(null==(u=C.audio)||null==(c=u.blocked)?void 0:c.byDeviceInUse)?i((function(e){var n=e.set;n(z,"in-use"),n(G,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):(null==(s=C.audio)||null==(d=s.blocked)?void 0:d.byDeviceMissing)?n(z,"not-found"):(null==(f=C.audio)||null==(p=f.blocked)?void 0:p.byPermissions)?n(z,"blocked"):w?n(z,"pending"):I?n(z,"idle"):i((function(e){var n=e.set;n(z,"granted"),n(G,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),(null==(v=C.video)||null==(y=v.blocked)?void 0:y.byDeviceInUse)?i((function(e){var n=e.set;n(W,"in-use"),n(H,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):(null==(m=C.video)||null==(g=m.blocked)?void 0:g.byDeviceMissing)?n(W,"not-found"):(null==(k=C.video)||null==(b=k.blocked)?void 0:b.byPermissions)?n(W,"blocked"):A?n(W,"pending"):E?n(W,"idle"):i((function(e){var n=e.set;n(W,"granted"),n(H,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return g("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),g("available-devices-updated",o),g("selected-devices-updated",o),g("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,u,c,l=n.set;switch(l(J,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(W,"in-use");break;case"mic-in-use":l(z,"in-use");break;case"cam-mic-in-use":l(W,"in-use"),l(z,"in-use");break;case"not-found":(null==(i=e.error)?void 0:i.missingMedia.includes("video"))&&l(W,"not-found"),(null==(r=e.error)?void 0:r.missingMedia.includes("audio"))&&l(z,"not-found");break;case"permissions":(null==(a=e.error)?void 0:a.blockedMedia.includes("video"))&&l(W,"blocked"),(null==(o=e.error)?void 0:o.blockedMedia.includes("audio"))&&l(z,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(l(W,"constraints-invalid"),l(z,"constraints-invalid")):"none-specified"===(null==(c=e.error)?void 0:c.reason)&&(l(W,"constraints-none-specified"),l(z,"constraints-none-specified"));break;case"undefined-mediadevices":l(W,"undefined-mediadevices"),l(z,"undefined-mediadevices");break;case"unknown":default:l(W,"unknown"),l(z,"unknown")}}))}}),[])),g("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(W,"granted"),n(z,"granted")})),u()}}),[u])),t.createElement(q.Provider,{value:{refreshDevices:o}},r)},K=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),X=function(e){var n=e.children;return g("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(K,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),g("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(K,(function(e){return l({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),g("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(K,(function(n){return l({},n,{errorMsg:e.errorMsg})}))}}),[])),t.createElement(t.Fragment,null,n)},Y=i.atom({key:"daily-react-meeting-state",default:"new"}),Z=i.atom({key:"meeting-session-data",default:{data:void 0,topology:"none"}}),ee=function(e){var n=e.children,r=p(),a=i.useRecoilCallback((function(e){var n=e.set;return function(){if(r){var e=r.meetingState();return n(Y,e),e}}}),[r]);g("loading",a),g("loaded",a),g("joining-meeting",a),g("joined-meeting",a),g("left-meeting",a),g("error",a);var o=i.useRecoilCallback((function(e){var n=e.set;return function(){r&&n(Z,r.meetingSessionState())}}),[r]);return g("joined-meeting",o),g("meeting-session-state-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Z,e.meetingSessionState)}}),[])),g("left-meeting",i.useRecoilCallback((function(e){var n=e.reset;return function(){n(Z)}}),[])),t.createElement(t.Fragment,null,n)},ne=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),te=function(e){var r=e.children,a=i.useSetRecoilState(ne),o=x(),u=M({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return l({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),g("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;o&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==o&&(t=!1)}n(ne,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),g("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ne,(function(e){return l({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),g("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ne,(function(e){return l({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),t.createElement(t.Fragment,null,r)},ie=function(){return i.useRecoilValue(Y)},re=i.atom({key:"daily-react-room",default:null}),ae=function(e){var n=e.children,r=p(),a=ie(),o=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(r&&"left-meeting"!==a){var e=yield r.room();return e&&"id"in e&&n(re,e),e}}))}),[r,a]);return g("access-state-updated",o),t.createElement(t.Fragment,null,n)},oe=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,u=i.useRecoilValue(R(e));return k(["participant-updated","participant-left"],n.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==a||a(e)}}))}),[a,o,e])),u},ue="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),ce=i.atom({key:"daily-react-input-settings",default:null}),le=i.atom({key:"daily-react-input-settings-error",default:null}),se=i.atom({key:"daily-react-topology",default:"none"}),de=i.atom({key:"daily-react-networkQuality",default:100}),fe=i.atom({key:"daily-react-networkThreshold",default:"good"}),pe=i.atom({key:"daily-react-participant-counts",default:{hidden:0,present:0}}),ve=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),ye=function(){return i.useRecoilValue(re)},me=i.atom({key:"daily-react-send-settings",default:null}),ge=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}});exports.DailyAudio=U,exports.DailyAudioTrack=B,exports.DailyProvider=function(e){var r=e.children,u=e.recoilRootProps,p=void 0===u?{}:u,y=s(e,["children","recoilRootProps"]),m="callObject"in y?y.callObject:null,g=n.useState(m),k=g[0],b=g[1],S=n.useRef({});n.useEffect((function(){m&&(m?((null==k?void 0:k._callFrameId)!==(null==m?void 0:m._callFrameId)||!k&&m)&&b(m):b(null))}),[k,m]);var h=n.useCallback((function(e){if("action"in e)for(var n,t=function(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,void 0):void 0}}(e))){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(null!=(i=null==(r=S.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),R=n.useCallback((function(e){e&&Object.keys(S.current).forEach((function(n){e.off(n,h),e.isDestroyed()||e.on(n,h)}))}),[h]),C=n.useRef();n.useEffect((function(){if("callObject"in y)return b(y.callObject),void R(y.callObject);function e(){return(e=c((function*(e){yield e.destroy()}))).apply(this,arguments)}if(k)o(C.current,y)||function(n){e.apply(this,arguments)}(k);else{var n=a.getCallInstance();n||(n=a.createCallObject(l({},y)),C.current=y),b(n),R(n),n.once("call-instance-destroyed",(function(){b(null)}))}}),[k,R,y]);var A=n.useCallback((function(e,n,t){var i,r;S.current[e]||(S.current[e]=new Map,k&&(k.off(e,h),k.isDestroyed()||k.on(e,h))),(null==(i=S.current[e])?void 0:i.has(t))||null==(r=S.current[e])||r.set(t,n)}),[k,h]),E=n.useCallback((function(e,n){var t,i;null==(t=S.current[e])||t.delete(n),0===(null==(i=S.current[e])?void 0:i.size)&&(null==k||k.off(e,h),delete S.current[e])}),[k,h]);return t.createElement(i.RecoilRoot,Object.assign({},p),t.createElement(f.Provider,{value:k},t.createElement(v.Provider,{value:{on:A,off:E}},t.createElement(ae,null,t.createElement(ee,null,t.createElement(I,null,t.createElement(te,null,t.createElement(X,null,t.createElement($,null,r)))))))))},exports.DailyVideo=N,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=p(),c=i.useRecoilValue(b),l=n.useState(""),s=l[1],d=oe(l[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==n?void 0:n.session_id)||s(null!=c?c:"")}}),[u,a,c]),g("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},exports.useActiveSpeakerId=P,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=p(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return g("app-message",a),r},exports.useAudioLevel=function(e,t){var i=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){i.current||(i.current=new n);var r=i.current;if(r){var a,o=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{a=new AudioWorkletNode(r,"audiolevel")}catch(e){try{yield r.audioWorklet.addModule(ue),a=new AudioWorkletNode(r,"audiolevel")}catch(e){console.error(e)}}if(a){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)};try{o.connect(a).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==o||o.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return O(e,"audio")},exports.useDaily=p,exports.useDailyEvent=g,exports.useDevices=function(){var e=p(),t=i.useRecoilValue(W),r=i.useRecoilValue(z),a=i.useRecoilValue(H),o=i.useRecoilValue(G),u=i.useRecoilValue(Q),l=i.useRecoilValue(J),s=n.useContext(q).refreshDevices,d=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),y=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,currentCam:a.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:y.includes(t),hasMicError:y.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:v,speakers:u}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(ce),u=i.useRecoilValue(le),c=p(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ce,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),g("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),g("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(le,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==c||c.updateInputSettings.apply(c,n)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=p(),c=i.useRecoilValue(K);return g("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),g("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),g("live-streaming-error",n.useCallback((function(e){null==r||r(e)}),[r])),l({},c,{startLiveStreaming:n.useCallback((function(){u&&u.startLiveStreaming.apply(u,arguments)}),[u]),stopLiveStreaming:n.useCallback((function(){u&&u.stopLiveStreaming.apply(u,arguments)}),[u]),updateLiveStreaming:n.useCallback((function(){u&&u.updateLiveStreaming.apply(u,arguments)}),[u])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(S);return oe(e)},exports.useLocalSessionId=x,exports.useMediaTrack=O,exports.useMeetingSessionState=function(){var e=i.useRecoilValue(Z);return{data:null==e?void 0:e.data,topology:null==e?void 0:e.topology}},exports.useMeetingState=ie,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=p(),u=i.useRecoilValue(se),l=i.useRecoilValue(de),s=i.useRecoilValue(fe),d=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(se,e.topology)}}))}),[o]),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(se,"peer"),"sfu"===e.type&&t(se,"sfu")}})),null==r||r(e)}}),[r]),v=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(de,(function(n){return n!==e.quality?e.quality:n})),t(fe,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return g("joined-meeting",d),g("network-connection",f),g("network-quality-change",v),n.useEffect((function(){o&&!u&&d()}),[o,d,u]),{getStats:n.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u}},exports.useParticipant=oe,exports.useParticipantCounts=function(e){var t=(void 0===e?{}:e).onParticipantCountsUpdated,r=p(),a=i.useRecoilValue(pe),o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(pe,e)}}),[]);return g("participant-counts-updated",n.useCallback((function(e){o(e.participantCounts),null==t||t(e)}),[t,o])),n.useEffect((function(){r&&!r.isDestroyed()&&o(r.participantCounts())}),[r,o]),a},exports.useParticipantIds=M,exports.useParticipantProperty=j,exports.usePermissions=function(e){var n=x(),t=j(null!=e?e:n,"permissions"),i="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("audio"),r="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("video");return{canSendAudio:i,canSendCustomAudio:"boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customAudio"),canSendCustomVideo:"boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customVideo"),canSendScreenAudio:"boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenAudio"),canSendScreenVideo:"boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenVideo"),canSendVideo:r,hasPresence:null==t?void 0:t.hasPresence,permissions:t}},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,u=i.useRecoilValue(ve("base")),c=i.useRecoilValue(ve(a)),s=p(),d=ie(),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=l({},e),o=0,u=Object.entries(r);o<u.length;o++){var c=u[o],s=c[1];i(ve(c[0]),s)}a in r||t(ve(a))}))}}),[a]);g("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var v=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]);return{receiveSettings:"base"===a||0===Object.keys(c).length?u:c,updateReceiveSettings:v}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,c=p(),s=i.useRecoilValue(ne);return g("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),g("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),g("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),g("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),l({},s,{startRecording:n.useCallback((function(){c&&c.startRecording.apply(c,arguments)}),[c]),stopRecording:n.useCallback((function(){c&&c.stopRecording.apply(c,arguments)}),[c]),updateRecording:n.useCallback((function(){c&&c.updateRecording.apply(c,arguments)}),[c])})},exports.useRoom=ye,exports.useScreenAudioTrack=function(e){return O(e,"screenAudio")},exports.useScreenShare=V,exports.useScreenVideoTrack=function(e){return O(e,"screenVideo")},exports.useSendSettings=function(e){var t=(void 0===e?{}:e).onSendSettingsUpdated,r=p(),a=i.useRecoilValue(me);g("send-settings-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(me,e.sendSettings),null==t||t(e)}}),[t]));var o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(me,e)}}),[]);return n.useEffect((function(){r&&!r.isDestroyed()&&o(r.getSendSettings())}),[r,o]),{sendSettings:a,updateSendSettings:n.useCallback(c((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var i=yield null==r?void 0:r.updateSendSettings.apply(r,n);if(i)return o(i),i})),[r,o])}},exports.useThrottledDailyEvent=k,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,u=r.onTranscriptionStarted,c=r.onTranscriptionStopped,s=p(),d=i.useRecoilValue(ge),f=i.useSetRecoilState(ge),v=ye();return n.useEffect((function(){var e;(null==v||null==(e=v.domainConfig)?void 0:e.enable_transcription)&&f((function(e){return l({},e,{isTranscriptionEnabled:!0})}))}),[null==v||null==(t=v.domainConfig)?void 0:t.enable_transcription,f]),g("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ge,l({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==u||u(e)}}),[u])),g("transcription-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ge,(function(n){return l({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})})),null==c||c(e)}}),[c])),g("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ge,(function(e){return l({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),g("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&(null==e||null==(t=e.data)?void 0:t.is_final)&&(n(ge,(function(n){return l({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),l({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])})},exports.useVideoTrack=function(e){return O(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=p(),c=i.useRecoilValue(w),l=n.useCallback((function(e){null==r||r(e)}),[r]),s=n.useCallback((function(e){null==a||a(e)}),[a]),d=n.useCallback((function(e){null==o||o(e)}),[o]);g("waiting-participant-added",l),g("waiting-participant-removed",s),g("waiting-participant-updated",d);var f=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){f(e,!0)}),[f]),denyAccess:n.useCallback((function(e){f(e,!1)}),[f])}}; | ||
//# sourceMappingURL=daily-react.cjs.production.min.js.map |
@@ -1,4 +0,5 @@ | ||
import { DailyMeetingState } from '@daily-co/daily-js'; | ||
import { DailyMeetingSessionState, DailyMeetingState } from '@daily-co/daily-js'; | ||
import React from 'react'; | ||
export declare const meetingStateState: import("recoil").RecoilState<DailyMeetingState>; | ||
export declare const meetingSessionDataState: import("recoil").RecoilState<DailyMeetingSessionState>; | ||
export declare const DailyMeeting: React.FC<React.PropsWithChildren<{}>>; |
@@ -18,2 +18,14 @@ /** | ||
/** | ||
* Holds the currently selected camera. | ||
*/ | ||
currentCam: import("../DailyDevices").StatefulDevice | undefined; | ||
/** | ||
* Holds the currently selected microphone. | ||
*/ | ||
currentMic: import("../DailyDevices").StatefulDevice | undefined; | ||
/** | ||
* Holds the currently selected speaker. | ||
*/ | ||
currentSpeaker: import("../DailyDevices").StatefulDevice | undefined; | ||
/** | ||
* Indicates that there's an issue with camera devices. | ||
@@ -20,0 +32,0 @@ */ |
@@ -1,2 +0,7 @@ | ||
export declare const usePermissions: () => { | ||
/** | ||
* Returns parsed permissions for a given participant. | ||
* In case no `sessionId` is passed, the hook returns permissions for the local participant. | ||
* @param sessionId The participant's session_id (optional) | ||
*/ | ||
export declare const usePermissions: (sessionId?: string | undefined) => { | ||
canSendAudio: any; | ||
@@ -3,0 +8,0 @@ canSendCustomAudio: any; |
@@ -20,5 +20,7 @@ export { DailyAudio } from './components/DailyAudio'; | ||
export { useMediaTrack } from './hooks/useMediaTrack'; | ||
export { useMeetingSessionState } from './hooks/useMeetingSessionState'; | ||
export { useMeetingState } from './hooks/useMeetingState'; | ||
export { useNetwork } from './hooks/useNetwork'; | ||
export { useParticipant } from './hooks/useParticipant'; | ||
export { useParticipantCounts } from './hooks/useParticipantCounts'; | ||
export { useParticipantIds } from './hooks/useParticipantIds'; | ||
@@ -33,2 +35,3 @@ export { useParticipantProperty } from './hooks/useParticipantProperty'; | ||
export { useScreenVideoTrack } from './hooks/useScreenVideoTrack'; | ||
export { useSendSettings } from './hooks/useSendSettings'; | ||
export { useThrottledDailyEvent } from './hooks/useThrottledDailyEvent'; | ||
@@ -35,0 +38,0 @@ export { Transcription, useTranscription } from './hooks/useTranscription'; |
{ | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"license": "BSD-2-Clause", | ||
@@ -4,0 +4,0 @@ "keywords": [ |
@@ -92,2 +92,14 @@ import { useCallback, useContext } from 'react'; | ||
/** | ||
* Holds the currently selected camera. | ||
*/ | ||
currentCam: camDevices.find((cam) => cam.selected), | ||
/** | ||
* Holds the currently selected microphone. | ||
*/ | ||
currentMic: micDevices.find((mic) => mic.selected), | ||
/** | ||
* Holds the currently selected speaker. | ||
*/ | ||
currentSpeaker: speakerDevices.find((speaker) => speaker.selected), | ||
/** | ||
* Indicates that there's an issue with camera devices. | ||
@@ -94,0 +106,0 @@ */ |
import { useLocalSessionId } from './useLocalSessionId'; | ||
import { useParticipantProperty } from './useParticipantProperty'; | ||
export const usePermissions = () => { | ||
/** | ||
* Returns parsed permissions for a given participant. | ||
* In case no `sessionId` is passed, the hook returns permissions for the local participant. | ||
* @param sessionId The participant's session_id (optional) | ||
*/ | ||
export const usePermissions = (sessionId?: string) => { | ||
const localSessionId = useLocalSessionId(); | ||
const permissions = useParticipantProperty(localSessionId, 'permissions'); | ||
const permissions = useParticipantProperty( | ||
sessionId ?? localSessionId, | ||
'permissions' | ||
); | ||
@@ -8,0 +16,0 @@ const canSendAudio = |
@@ -20,5 +20,7 @@ export { DailyAudio } from './components/DailyAudio'; | ||
export { useMediaTrack } from './hooks/useMediaTrack'; | ||
export { useMeetingSessionState } from './hooks/useMeetingSessionState'; | ||
export { useMeetingState } from './hooks/useMeetingState'; | ||
export { useNetwork } from './hooks/useNetwork'; | ||
export { useParticipant } from './hooks/useParticipant'; | ||
export { useParticipantCounts } from './hooks/useParticipantCounts'; | ||
export { useParticipantIds } from './hooks/useParticipantIds'; | ||
@@ -33,2 +35,3 @@ export { useParticipantProperty } from './hooks/useParticipantProperty'; | ||
export { useScreenVideoTrack } from './hooks/useScreenVideoTrack'; | ||
export { useSendSettings } from './hooks/useSendSettings'; | ||
export { useThrottledDailyEvent } from './hooks/useThrottledDailyEvent'; | ||
@@ -35,0 +38,0 @@ export { Transcription, useTranscription } from './hooks/useTranscription'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
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
1002666
121
10041