@daily-co/daily-vcs-web
Advanced tools
Comparing version 0.0.1-alpha.10 to 0.0.2-alpha.2
@@ -1,1 +0,1 @@ | ||
"use strict";function t(t,e,i,s){return new(i||(i=Promise))((function(a,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function n(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,n)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const e=(t,e)=>{if(!t||!e||0===e)return{w:0,h:0};const{width:i,height:s}=t.getBoundingClientRect();return i/s>e?{w:Math.floor(s*e),h:s}:{w:i,h:Math.floor(i/e)}},i=t=>["off","blocked"].includes(t),s=(t,e="video")=>{var i,s,a,o,r,n;return{active:!0,id:null!==(o=null===(a=null===(s=null===(i=null==t?void 0:t.tracks)||void 0===i?void 0:i[e])||void 0===s?void 0:s.track)||void 0===a?void 0:a.id)&&void 0!==o?o:"",sessionId:t.session_id,displayName:"video"===e?t.user_name||"Guest":"",track:null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r[e])||void 0===n?void 0:n.persistentTrack,type:"video"===e?"camera":"screenshare"}},a=(t,e=!1)=>{var s,a,o,r,n,l,c,d,u,h,p,v,m,f,g,S,b,y;return{id:t.session_id,displayName:t.user_name||"Guest",video:{id:null!==(c=e?null===(o=null===(a=null===(s=null==t?void 0:t.tracks)||void 0===s?void 0:s.rmpVideo)||void 0===a?void 0:a.track)||void 0===o?void 0:o.id:null===(l=null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r.video)||void 0===n?void 0:n.track)||void 0===l?void 0:l.id)&&void 0!==c?c:"",paused:i(e?null!==(h=null===(u=null===(d=null==t?void 0:t.tracks)||void 0===d?void 0:d.rmpVideo)||void 0===u?void 0:u.state)&&void 0!==h?h:"off":null===(v=null===(p=null==t?void 0:t.tracks)||void 0===p?void 0:p.video)||void 0===v?void 0:v.state)},audio:{},screenshareVideo:{id:null!==(S=null===(g=null===(f=null===(m=null==t?void 0:t.tracks)||void 0===m?void 0:m.screenVideo)||void 0===f?void 0:f.track)||void 0===g?void 0:g.id)&&void 0!==S?S:"",paused:i(null===(y=null===(b=null==t?void 0:t.tracks)||void 0===b?void 0:b.screenVideo)||void 0===y?void 0:y.state)},screenshareAudio:{}}};exports.DailyVCSWebRenderer=class{constructor(t,i,s,a){var o,r;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=1.7777777777777777,this.vcsState="idle",t||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=t,i&&"function"==typeof i.startDOMOutputAsync){this.comp=i,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=s,this.viewportSize=null!==(r=null==a?void 0:a.viewportSize)&&void 0!==r?r:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=e(s,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.recomputeOutputScaleFactor();for(let t=0;t<this.maxVideoInputSlots;t++)this.setActiveVideoInput(t,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((t=>{t&&t.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const t=this.rootEl.clientWidth,e=this.rootEl.clientHeight;if(!t||!e)return;const i=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=i>=1?t/this.viewportSize.w:e/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return t(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(t,e){t.setAttribute("style","display: none;"),e&&t.setAttribute("data-video-remote-track-id",e),this.rootEl.appendChild(t)}handleParticipantsChange(){var t,e,o,r;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((t=>[t.session_id,t]))),l=Array.isArray(this.participantIds)?this.participantIds.map((t=>n[t])).filter(Boolean):Object.values(n),c=[],d=[],u=new Map;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(s(n,"rmpVideo")):(i(null===(e=null===(t=null==n?void 0:n.tracks)||void 0===t?void 0:t.video)||void 0===e?void 0:e.state)||c.push(s(n)),i(null===(r=null===(o=null==n?void 0:n.tracks)||void 0===o?void 0:o.screenVideo)||void 0===r?void 0:r.state)||d.push(s(n,"screenVideo"))),u.set(n.session_id,a(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(u)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){var e,i;return t(this,void 0,void 0,(function*(){this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(i=(e=this.callbacks).onStart)||void 0===i||i.call(e),this.startResizeObserver())}))}stop(){var t,e;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(e=(t=this.callbacks).onStop)||void 0===e||e.call(t),this.stopResizeObserver())}onError(t){var e,i;console.error("VCS composition error: ",t),this.vcsState="error",null===(i=(e=this.callbacks).onError)||void 0===i||i.call(e,t)}setActiveVideoInput(t,e,i="",s="",a=!1){this.activeVideoInputSlots[t]=!!e&&{id:i||"",type:a?"screenshare":"camera",displayName:a?"":s}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const t=[];for(const e of this.activeVideoInputSlots)"object"==typeof e?t.push(e):t.push(!1);this.vcsApi.setActiveVideoInputSlots(t)}sendParam(t,e){var i,s;this.vcsApi&&(this.vcsApi.setParamValue(t,e),null===(s=(i=this.callbacks).onParamsChanged)||void 0===s||s.call(i,this.paramValues)),this.paramValues[t]=e}sendParams(t,e="merge"){"replace"===e&&(this.paramValues={}),Object.entries(t).forEach((([t,e])=>this.sendParam(t,e)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(e={},i="replace"){return t(this,void 0,void 0,(function*(){const t=Object.entries(e).map((([t,e])=>new Promise(((i,s)=>{const a=new Image;a.onload=()=>i({name:t,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${t}`),s(new Error(`Image load failed, asset ${t}`))},a.src=e}))));try{const e=(yield Promise.all(t)).reduce(((t,e)=>(t[e.name]=e.image,t)),{});if("merge"===i)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),e);else{if("replace"!==i)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=e}this.sendUpdateImageSources()}catch(t){console.error(t)}}))}applyTracks(t){var e;if(!this.sources||!t)return;const i=this.sources.videoSlots,s=[];for(const a of t){if(!(null==a?void 0:a.track))continue;const t=i.find((t=>t.id===a.id));if(t&&(null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id)===a.track.id)s.push(Object.assign(Object.assign({},t),{displayName:a.displayName}));else{const e=new MediaStream([a.track]);let i;(null==t?void 0:t.element)?i=t.element:(i=document.createElement("video"),this.placeVideoSourceInDOM(i,a.track.id)),i.srcObject=e,i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("controls","false"),s.push({active:!0,id:a.track.id,element:i,track:a.track,sessionId:a.sessionId,displayName:a.displayName,type:a.type})}}i.filter((t=>s.every((e=>e.id!==t.id)))).forEach((t=>{var e,i;null===(i=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id}"]`))||void 0===i||i.remove()}));let a=s.length!==i.length;if(!a)for(let t=0;t<s.length;t++)if(s[t].id!==i[t].id){a=!0;break}if(a){this.sources.videoSlots=s,this.sendUpdateImageSources();for(let t=0;t<20;t++){const e=s[t];e?this.setActiveVideoInput(t,!0,e.id,e.displayName,"screenshare"===e.type):this.setActiveVideoInput(t,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(t){this.aspectRatio=t,this.viewportSize=e(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(t,e="replace"){this.participantIds="merge"===e?[...new Set([...this.participantIds,...t])]:t,"started"===this.vcsState&&this.handleParticipantsChange()}}; | ||
"use strict";function e(e,t,s,i){return new(s||(s=Promise))((function(a,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function n(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,n)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>{if(!e||!t||0===t)return{w:0,h:0};const{width:s,height:i}=e.getBoundingClientRect();return s/i>t?{w:Math.floor(i*t),h:i}:{w:s,h:Math.floor(s/t)}},s=e=>["off","blocked"].includes(e);function i(e,t){return`${e.session_id}${t?"_sshare":""}`}const a=(e,t="video")=>{var a,o,r;const n=null===(a=null==e?void 0:e.tracks)||void 0===a?void 0:a[t],l="screenVideo"===t;return{paused:!!n&&s(null==n?void 0:n.state),pausedByUser:null!==(r=null===(o=null==n?void 0:n.off)||void 0===o?void 0:o.byUser)&&void 0!==r&&r,id:i(e,l),displayName:l?"":e.user_name||"Guest",track:null==n?void 0:n.persistentTrack,type:l?"screenshare":"camera"}},o=(e,t=!1)=>{var a,o,r,n,l,c,d;return{id:e.session_id,displayName:e.user_name||"Guest",video:{id:i(e,!1),paused:s(t?null!==(r=null===(o=null===(a=null==e?void 0:e.tracks)||void 0===a?void 0:a.rmpVideo)||void 0===o?void 0:o.state)&&void 0!==r?r:"off":null===(l=null===(n=null==e?void 0:e.tracks)||void 0===n?void 0:n.video)||void 0===l?void 0:l.state)},audio:{},screenshareVideo:{id:i(e,!0),paused:s(null===(d=null===(c=null==e?void 0:e.tracks)||void 0===c?void 0:c.screenVideo)||void 0===d?void 0:d.state)},screenshareAudio:{}}},r=16/9;exports.DailyVCSWebRenderer=class{constructor(e,s,i,a){var o,n,l;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=r,this.includePausedVideo=!0,this.knownNonScreenshareVideoInputIds=new Set,this.vcsState="idle",e||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=e,s&&"function"==typeof s.startDOMOutputAsync){this.comp=s,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=i,this.viewportSize=null!==(n=null==a?void 0:a.viewportSize)&&void 0!==n?n:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=t(i,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.includePausedVideo=null===(l=null==a?void 0:a.includePausedVideo)||void 0===l||l,this.recomputeOutputScaleFactor();for(let e=0;e<this.maxVideoInputSlots;e++)this.setActiveVideoInput(e,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((e=>{e&&e.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const e=this.rootEl.clientWidth,t=this.rootEl.clientHeight;if(!e||!t)return;const s=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=s>=1?e/this.viewportSize.w:t/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return e(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(e,t){e.setAttribute("style","display: none;"),t&&e.setAttribute("data-video-remote-track-id",t),this.rootEl.appendChild(e)}handleParticipantsChange(){var e,t,i,r;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((e=>[e.session_id,e]))),l=Array.isArray(this.participantIds)?this.participantIds.map((e=>n[e])).filter(Boolean):Object.values(n),c=[],d=[],h=new Map,p=this.includePausedVideo;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(a(n,"rmpVideo")):(!p&&s(null===(t=null===(e=null==n?void 0:n.tracks)||void 0===e?void 0:e.video)||void 0===t?void 0:t.state)||c.push(a(n)),!p&&s(null===(r=null===(i=null==n?void 0:n.tracks)||void 0===i?void 0:i.screenVideo)||void 0===r?void 0:r.state)||d.push(a(n,"screenVideo"))),h.set(n.session_id,o(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(h)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){return e(this,void 0,void 0,(function*(){var e,t;this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(t=(e=this.callbacks).onStart)||void 0===t||t.call(e),this.startResizeObserver())}))}stop(){var e,t;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(t=(e=this.callbacks).onStop)||void 0===t||t.call(e),this.stopResizeObserver())}onError(e){var t,s;console.error("VCS composition error: ",e),this.vcsState="error",null===(s=(t=this.callbacks).onError)||void 0===s||s.call(t,e)}setActiveVideoInput(e,t,s="",i="",a=!1,o=!1){this.activeVideoInputSlots[e]=!!t&&{id:s||"",type:a?"screenshare":"camera",displayName:a?"":i,paused:o}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const e=[];for(const t of this.activeVideoInputSlots)"object"==typeof t?e.push(t):e.push(!1);console.log("sending video input slots: ",e),this.vcsApi.setActiveVideoInputSlots(e)}sendParam(e,t){var s,i;this.vcsApi&&(this.vcsApi.setParamValue(e,t),null===(i=(s=this.callbacks).onParamsChanged)||void 0===i||i.call(s,this.paramValues)),this.paramValues[e]=t}sendParams(e,t="merge"){"replace"===t&&(this.paramValues={}),Object.entries(e).forEach((([e,t])=>this.sendParam(e,t)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(){return e(this,arguments,void 0,(function*(e={},t="replace"){const s=Object.entries(e).map((([e,t])=>new Promise(((s,i)=>{const a=new Image;a.onload=()=>s({name:e,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${e}`),i(new Error(`Image load failed, asset ${e}`))},a.src=t}))));try{const e=(yield Promise.all(s)).reduce(((e,t)=>(e[t.name]=t.image,e)),{});if("merge"===t)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),e);else{if("replace"!==t)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=e}this.sendUpdateImageSources()}catch(e){console.error(e)}}))}applyTracks(e){var t,s,i,a;if(!this.sources||!e)return;console.log("applyTracks %d: ",e.length,e);const o=this.sources.videoSlots,r=[];for(const i of e){const a="screenshare"===i.type;if(!i.track){if(a||!this.knownNonScreenshareVideoInputIds.has(i.id)){console.log("skipping at %d: ",e.indexOf(i),i);continue}console.log("previously seen %s",i.id)}const n=o.find((e=>e.id===i.id));if(n&&(null===(t=n.track)||void 0===t?void 0:t.id)===(null===(s=i.track)||void 0===s?void 0:s.id))r.push(Object.assign(Object.assign({},n),{paused:i.paused,displayName:i.displayName}));else{let e;if(i.track){const t=new MediaStream([i.track]);(null==n?void 0:n.element)?e=n.element:(e=document.createElement("video"),this.placeVideoSourceInDOM(e,i.track.id)),e.srcObject=t,e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.setAttribute("controls","false")}r.push(Object.assign(Object.assign({},i),{element:e})),a||this.knownNonScreenshareVideoInputIds.add(i.id)}}o.filter((e=>r.every((t=>t.id!==e.id)))).forEach((e=>{var t,s;null===(s=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(t=null==e?void 0:e.track)||void 0===t?void 0:t.id}"]`))||void 0===s||s.remove()}));let n=r.length!==o.length;if(!n)for(let e=0;e<r.length;e++){const t=r[e],s=o[e];if(t.id!==s.id||t.paused!==s.paused||t.displayName!==s.displayName||(null===(i=t.track)||void 0===i?void 0:i.id)!==(null===(a=s.track)||void 0===a?void 0:a.id)){n=!0;break}}if(n){this.sources.videoSlots=r,this.sendUpdateImageSources();for(let e=0;e<20;e++){const t=r[e];t?this.setActiveVideoInput(e,!0,t.id,t.displayName,"screenshare"===t.type,t.paused):this.setActiveVideoInput(e,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(e){this.aspectRatio=e,this.viewportSize=t(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(e,t="replace"){this.participantIds="merge"===t?[...new Set([...this.participantIds,...e])]:e,"started"===this.vcsState&&this.handleParticipantsChange()}}; |
@@ -1,1 +0,1 @@ | ||
function t(t,e,i,s){return new(i||(i=Promise))((function(a,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function n(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,n)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const e=(t,e)=>{if(!t||!e||0===e)return{w:0,h:0};const{width:i,height:s}=t.getBoundingClientRect();return i/s>e?{w:Math.floor(s*e),h:s}:{w:i,h:Math.floor(i/e)}},i=t=>["off","blocked"].includes(t),s=(t,e="video")=>{var i,s,a,o,r,n;return{active:!0,id:null!==(o=null===(a=null===(s=null===(i=null==t?void 0:t.tracks)||void 0===i?void 0:i[e])||void 0===s?void 0:s.track)||void 0===a?void 0:a.id)&&void 0!==o?o:"",sessionId:t.session_id,displayName:"video"===e?t.user_name||"Guest":"",track:null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r[e])||void 0===n?void 0:n.persistentTrack,type:"video"===e?"camera":"screenshare"}},a=(t,e=!1)=>{var s,a,o,r,n,l,c,d,h,u,p,v,m,f,g,S,b,y;return{id:t.session_id,displayName:t.user_name||"Guest",video:{id:null!==(c=e?null===(o=null===(a=null===(s=null==t?void 0:t.tracks)||void 0===s?void 0:s.rmpVideo)||void 0===a?void 0:a.track)||void 0===o?void 0:o.id:null===(l=null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r.video)||void 0===n?void 0:n.track)||void 0===l?void 0:l.id)&&void 0!==c?c:"",paused:i(e?null!==(u=null===(h=null===(d=null==t?void 0:t.tracks)||void 0===d?void 0:d.rmpVideo)||void 0===h?void 0:h.state)&&void 0!==u?u:"off":null===(v=null===(p=null==t?void 0:t.tracks)||void 0===p?void 0:p.video)||void 0===v?void 0:v.state)},audio:{},screenshareVideo:{id:null!==(S=null===(g=null===(f=null===(m=null==t?void 0:t.tracks)||void 0===m?void 0:m.screenVideo)||void 0===f?void 0:f.track)||void 0===g?void 0:g.id)&&void 0!==S?S:"",paused:i(null===(y=null===(b=null==t?void 0:t.tracks)||void 0===b?void 0:b.screenVideo)||void 0===y?void 0:y.state)},screenshareAudio:{}}};class o{constructor(t,i,s,a){var o,r;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=1.7777777777777777,this.vcsState="idle",t||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=t,i&&"function"==typeof i.startDOMOutputAsync){this.comp=i,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=s,this.viewportSize=null!==(r=null==a?void 0:a.viewportSize)&&void 0!==r?r:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=e(s,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.recomputeOutputScaleFactor();for(let t=0;t<this.maxVideoInputSlots;t++)this.setActiveVideoInput(t,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((t=>{t&&t.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const t=this.rootEl.clientWidth,e=this.rootEl.clientHeight;if(!t||!e)return;const i=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=i>=1?t/this.viewportSize.w:e/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return t(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(t,e){t.setAttribute("style","display: none;"),e&&t.setAttribute("data-video-remote-track-id",e),this.rootEl.appendChild(t)}handleParticipantsChange(){var t,e,o,r;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((t=>[t.session_id,t]))),l=Array.isArray(this.participantIds)?this.participantIds.map((t=>n[t])).filter(Boolean):Object.values(n),c=[],d=[],h=new Map;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(s(n,"rmpVideo")):(i(null===(e=null===(t=null==n?void 0:n.tracks)||void 0===t?void 0:t.video)||void 0===e?void 0:e.state)||c.push(s(n)),i(null===(r=null===(o=null==n?void 0:n.tracks)||void 0===o?void 0:o.screenVideo)||void 0===r?void 0:r.state)||d.push(s(n,"screenVideo"))),h.set(n.session_id,a(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(h)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){var e,i;return t(this,void 0,void 0,(function*(){this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(i=(e=this.callbacks).onStart)||void 0===i||i.call(e),this.startResizeObserver())}))}stop(){var t,e;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(e=(t=this.callbacks).onStop)||void 0===e||e.call(t),this.stopResizeObserver())}onError(t){var e,i;console.error("VCS composition error: ",t),this.vcsState="error",null===(i=(e=this.callbacks).onError)||void 0===i||i.call(e,t)}setActiveVideoInput(t,e,i="",s="",a=!1){this.activeVideoInputSlots[t]=!!e&&{id:i||"",type:a?"screenshare":"camera",displayName:a?"":s}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const t=[];for(const e of this.activeVideoInputSlots)"object"==typeof e?t.push(e):t.push(!1);this.vcsApi.setActiveVideoInputSlots(t)}sendParam(t,e){var i,s;this.vcsApi&&(this.vcsApi.setParamValue(t,e),null===(s=(i=this.callbacks).onParamsChanged)||void 0===s||s.call(i,this.paramValues)),this.paramValues[t]=e}sendParams(t,e="merge"){"replace"===e&&(this.paramValues={}),Object.entries(t).forEach((([t,e])=>this.sendParam(t,e)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(e={},i="replace"){return t(this,void 0,void 0,(function*(){const t=Object.entries(e).map((([t,e])=>new Promise(((i,s)=>{const a=new Image;a.onload=()=>i({name:t,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${t}`),s(new Error(`Image load failed, asset ${t}`))},a.src=e}))));try{const e=(yield Promise.all(t)).reduce(((t,e)=>(t[e.name]=e.image,t)),{});if("merge"===i)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),e);else{if("replace"!==i)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=e}this.sendUpdateImageSources()}catch(t){console.error(t)}}))}applyTracks(t){var e;if(!this.sources||!t)return;const i=this.sources.videoSlots,s=[];for(const a of t){if(!(null==a?void 0:a.track))continue;const t=i.find((t=>t.id===a.id));if(t&&(null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id)===a.track.id)s.push(Object.assign(Object.assign({},t),{displayName:a.displayName}));else{const e=new MediaStream([a.track]);let i;(null==t?void 0:t.element)?i=t.element:(i=document.createElement("video"),this.placeVideoSourceInDOM(i,a.track.id)),i.srcObject=e,i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("controls","false"),s.push({active:!0,id:a.track.id,element:i,track:a.track,sessionId:a.sessionId,displayName:a.displayName,type:a.type})}}i.filter((t=>s.every((e=>e.id!==t.id)))).forEach((t=>{var e,i;null===(i=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id}"]`))||void 0===i||i.remove()}));let a=s.length!==i.length;if(!a)for(let t=0;t<s.length;t++)if(s[t].id!==i[t].id){a=!0;break}if(a){this.sources.videoSlots=s,this.sendUpdateImageSources();for(let t=0;t<20;t++){const e=s[t];e?this.setActiveVideoInput(t,!0,e.id,e.displayName,"screenshare"===e.type):this.setActiveVideoInput(t,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(t){this.aspectRatio=t,this.viewportSize=e(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(t,e="replace"){this.participantIds="merge"===e?[...new Set([...this.participantIds,...t])]:t,"started"===this.vcsState&&this.handleParticipantsChange()}}export{o as DailyVCSWebRenderer}; | ||
function e(e,t,s,i){return new(s||(s=Promise))((function(a,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function n(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,n)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>{if(!e||!t||0===t)return{w:0,h:0};const{width:s,height:i}=e.getBoundingClientRect();return s/i>t?{w:Math.floor(i*t),h:i}:{w:s,h:Math.floor(s/t)}},s=e=>["off","blocked"].includes(e);function i(e,t){return`${e.session_id}${t?"_sshare":""}`}const a=(e,t="video")=>{var a,o,r;const n=null===(a=null==e?void 0:e.tracks)||void 0===a?void 0:a[t],l="screenVideo"===t;return{paused:!!n&&s(null==n?void 0:n.state),pausedByUser:null!==(r=null===(o=null==n?void 0:n.off)||void 0===o?void 0:o.byUser)&&void 0!==r&&r,id:i(e,l),displayName:l?"":e.user_name||"Guest",track:null==n?void 0:n.persistentTrack,type:l?"screenshare":"camera"}},o=(e,t=!1)=>{var a,o,r,n,l,c,d;return{id:e.session_id,displayName:e.user_name||"Guest",video:{id:i(e,!1),paused:s(t?null!==(r=null===(o=null===(a=null==e?void 0:e.tracks)||void 0===a?void 0:a.rmpVideo)||void 0===o?void 0:o.state)&&void 0!==r?r:"off":null===(l=null===(n=null==e?void 0:e.tracks)||void 0===n?void 0:n.video)||void 0===l?void 0:l.state)},audio:{},screenshareVideo:{id:i(e,!0),paused:s(null===(d=null===(c=null==e?void 0:e.tracks)||void 0===c?void 0:c.screenVideo)||void 0===d?void 0:d.state)},screenshareAudio:{}}},r=16/9;class n{constructor(e,s,i,a){var o,n,l;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=r,this.includePausedVideo=!0,this.knownNonScreenshareVideoInputIds=new Set,this.vcsState="idle",e||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=e,s&&"function"==typeof s.startDOMOutputAsync){this.comp=s,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=i,this.viewportSize=null!==(n=null==a?void 0:a.viewportSize)&&void 0!==n?n:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=t(i,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.includePausedVideo=null===(l=null==a?void 0:a.includePausedVideo)||void 0===l||l,this.recomputeOutputScaleFactor();for(let e=0;e<this.maxVideoInputSlots;e++)this.setActiveVideoInput(e,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((e=>{e&&e.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const e=this.rootEl.clientWidth,t=this.rootEl.clientHeight;if(!e||!t)return;const s=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=s>=1?e/this.viewportSize.w:t/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return e(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(e,t){e.setAttribute("style","display: none;"),t&&e.setAttribute("data-video-remote-track-id",t),this.rootEl.appendChild(e)}handleParticipantsChange(){var e,t,i,r;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((e=>[e.session_id,e]))),l=Array.isArray(this.participantIds)?this.participantIds.map((e=>n[e])).filter(Boolean):Object.values(n),c=[],d=[],h=new Map,p=this.includePausedVideo;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(a(n,"rmpVideo")):(!p&&s(null===(t=null===(e=null==n?void 0:n.tracks)||void 0===e?void 0:e.video)||void 0===t?void 0:t.state)||c.push(a(n)),!p&&s(null===(r=null===(i=null==n?void 0:n.tracks)||void 0===i?void 0:i.screenVideo)||void 0===r?void 0:r.state)||d.push(a(n,"screenVideo"))),h.set(n.session_id,o(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(h)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){return e(this,void 0,void 0,(function*(){var e,t;this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(t=(e=this.callbacks).onStart)||void 0===t||t.call(e),this.startResizeObserver())}))}stop(){var e,t;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(t=(e=this.callbacks).onStop)||void 0===t||t.call(e),this.stopResizeObserver())}onError(e){var t,s;console.error("VCS composition error: ",e),this.vcsState="error",null===(s=(t=this.callbacks).onError)||void 0===s||s.call(t,e)}setActiveVideoInput(e,t,s="",i="",a=!1,o=!1){this.activeVideoInputSlots[e]=!!t&&{id:s||"",type:a?"screenshare":"camera",displayName:a?"":i,paused:o}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const e=[];for(const t of this.activeVideoInputSlots)"object"==typeof t?e.push(t):e.push(!1);console.log("sending video input slots: ",e),this.vcsApi.setActiveVideoInputSlots(e)}sendParam(e,t){var s,i;this.vcsApi&&(this.vcsApi.setParamValue(e,t),null===(i=(s=this.callbacks).onParamsChanged)||void 0===i||i.call(s,this.paramValues)),this.paramValues[e]=t}sendParams(e,t="merge"){"replace"===t&&(this.paramValues={}),Object.entries(e).forEach((([e,t])=>this.sendParam(e,t)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(){return e(this,arguments,void 0,(function*(e={},t="replace"){const s=Object.entries(e).map((([e,t])=>new Promise(((s,i)=>{const a=new Image;a.onload=()=>s({name:e,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${e}`),i(new Error(`Image load failed, asset ${e}`))},a.src=t}))));try{const e=(yield Promise.all(s)).reduce(((e,t)=>(e[t.name]=t.image,e)),{});if("merge"===t)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),e);else{if("replace"!==t)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=e}this.sendUpdateImageSources()}catch(e){console.error(e)}}))}applyTracks(e){var t,s,i,a;if(!this.sources||!e)return;console.log("applyTracks %d: ",e.length,e);const o=this.sources.videoSlots,r=[];for(const i of e){const a="screenshare"===i.type;if(!i.track){if(a||!this.knownNonScreenshareVideoInputIds.has(i.id)){console.log("skipping at %d: ",e.indexOf(i),i);continue}console.log("previously seen %s",i.id)}const n=o.find((e=>e.id===i.id));if(n&&(null===(t=n.track)||void 0===t?void 0:t.id)===(null===(s=i.track)||void 0===s?void 0:s.id))r.push(Object.assign(Object.assign({},n),{paused:i.paused,displayName:i.displayName}));else{let e;if(i.track){const t=new MediaStream([i.track]);(null==n?void 0:n.element)?e=n.element:(e=document.createElement("video"),this.placeVideoSourceInDOM(e,i.track.id)),e.srcObject=t,e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.setAttribute("controls","false")}r.push(Object.assign(Object.assign({},i),{element:e})),a||this.knownNonScreenshareVideoInputIds.add(i.id)}}o.filter((e=>r.every((t=>t.id!==e.id)))).forEach((e=>{var t,s;null===(s=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(t=null==e?void 0:e.track)||void 0===t?void 0:t.id}"]`))||void 0===s||s.remove()}));let n=r.length!==o.length;if(!n)for(let e=0;e<r.length;e++){const t=r[e],s=o[e];if(t.id!==s.id||t.paused!==s.paused||t.displayName!==s.displayName||(null===(i=t.track)||void 0===i?void 0:i.id)!==(null===(a=s.track)||void 0===a?void 0:a.id)){n=!0;break}}if(n){this.sources.videoSlots=r,this.sendUpdateImageSources();for(let e=0;e<20;e++){const t=r[e];t?this.setActiveVideoInput(e,!0,t.id,t.displayName,"screenshare"===t.type,t.paused):this.setActiveVideoInput(e,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(e){this.aspectRatio=e,this.viewportSize=t(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(e,t="replace"){this.participantIds="merge"===t?[...new Set([...this.participantIds,...e])]:e,"started"===this.vcsState&&this.handleParticipantsChange()}}export{n as DailyVCSWebRenderer}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).DailyVCSWebRenderer={})}(this,(function(t){"use strict";function e(t,e,i,s){return new(i||(i=Promise))((function(a,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function n(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,n)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=(t,e)=>{if(!t||!e||0===e)return{w:0,h:0};const{width:i,height:s}=t.getBoundingClientRect();return i/s>e?{w:Math.floor(s*e),h:s}:{w:i,h:Math.floor(i/e)}},s=t=>["off","blocked"].includes(t),a=(t,e="video")=>{var i,s,a,o,r,n;return{active:!0,id:null!==(o=null===(a=null===(s=null===(i=null==t?void 0:t.tracks)||void 0===i?void 0:i[e])||void 0===s?void 0:s.track)||void 0===a?void 0:a.id)&&void 0!==o?o:"",sessionId:t.session_id,displayName:"video"===e?t.user_name||"Guest":"",track:null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r[e])||void 0===n?void 0:n.persistentTrack,type:"video"===e?"camera":"screenshare"}},o=(t,e=!1)=>{var i,a,o,r,n,l,c,d,u,h,p,v,m,f,g,b,S,y;return{id:t.session_id,displayName:t.user_name||"Guest",video:{id:null!==(c=e?null===(o=null===(a=null===(i=null==t?void 0:t.tracks)||void 0===i?void 0:i.rmpVideo)||void 0===a?void 0:a.track)||void 0===o?void 0:o.id:null===(l=null===(n=null===(r=null==t?void 0:t.tracks)||void 0===r?void 0:r.video)||void 0===n?void 0:n.track)||void 0===l?void 0:l.id)&&void 0!==c?c:"",paused:s(e?null!==(h=null===(u=null===(d=null==t?void 0:t.tracks)||void 0===d?void 0:d.rmpVideo)||void 0===u?void 0:u.state)&&void 0!==h?h:"off":null===(v=null===(p=null==t?void 0:t.tracks)||void 0===p?void 0:p.video)||void 0===v?void 0:v.state)},audio:{},screenshareVideo:{id:null!==(b=null===(g=null===(f=null===(m=null==t?void 0:t.tracks)||void 0===m?void 0:m.screenVideo)||void 0===f?void 0:f.track)||void 0===g?void 0:g.id)&&void 0!==b?b:"",paused:s(null===(y=null===(S=null==t?void 0:t.tracks)||void 0===S?void 0:S.screenVideo)||void 0===y?void 0:y.state)},screenshareAudio:{}}};t.DailyVCSWebRenderer=class{constructor(t,e,s,a){var o,r;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=1.7777777777777777,this.vcsState="idle",t||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=t,e&&"function"==typeof e.startDOMOutputAsync){this.comp=e,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=s,this.viewportSize=null!==(r=null==a?void 0:a.viewportSize)&&void 0!==r?r:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=i(s,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.recomputeOutputScaleFactor();for(let t=0;t<this.maxVideoInputSlots;t++)this.setActiveVideoInput(t,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((t=>{t&&t.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const t=this.rootEl.clientWidth,e=this.rootEl.clientHeight;if(!t||!e)return;const i=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=i>=1?t/this.viewportSize.w:e/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return e(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(t,e){t.setAttribute("style","display: none;"),e&&t.setAttribute("data-video-remote-track-id",e),this.rootEl.appendChild(t)}handleParticipantsChange(){var t,e,i,r;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((t=>[t.session_id,t]))),l=Array.isArray(this.participantIds)?this.participantIds.map((t=>n[t])).filter(Boolean):Object.values(n),c=[],d=[],u=new Map;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(a(n,"rmpVideo")):(s(null===(e=null===(t=null==n?void 0:n.tracks)||void 0===t?void 0:t.video)||void 0===e?void 0:e.state)||c.push(a(n)),s(null===(r=null===(i=null==n?void 0:n.tracks)||void 0===i?void 0:i.screenVideo)||void 0===r?void 0:r.state)||d.push(a(n,"screenVideo"))),u.set(n.session_id,o(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(u)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){var t,i;return e(this,void 0,void 0,(function*(){this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(i=(t=this.callbacks).onStart)||void 0===i||i.call(t),this.startResizeObserver())}))}stop(){var t,e;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(e=(t=this.callbacks).onStop)||void 0===e||e.call(t),this.stopResizeObserver())}onError(t){var e,i;console.error("VCS composition error: ",t),this.vcsState="error",null===(i=(e=this.callbacks).onError)||void 0===i||i.call(e,t)}setActiveVideoInput(t,e,i="",s="",a=!1){this.activeVideoInputSlots[t]=!!e&&{id:i||"",type:a?"screenshare":"camera",displayName:a?"":s}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const t=[];for(const e of this.activeVideoInputSlots)"object"==typeof e?t.push(e):t.push(!1);this.vcsApi.setActiveVideoInputSlots(t)}sendParam(t,e){var i,s;this.vcsApi&&(this.vcsApi.setParamValue(t,e),null===(s=(i=this.callbacks).onParamsChanged)||void 0===s||s.call(i,this.paramValues)),this.paramValues[t]=e}sendParams(t,e="merge"){"replace"===e&&(this.paramValues={}),Object.entries(t).forEach((([t,e])=>this.sendParam(t,e)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(t={},i="replace"){return e(this,void 0,void 0,(function*(){const e=Object.entries(t).map((([t,e])=>new Promise(((i,s)=>{const a=new Image;a.onload=()=>i({name:t,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${t}`),s(new Error(`Image load failed, asset ${t}`))},a.src=e}))));try{const t=(yield Promise.all(e)).reduce(((t,e)=>(t[e.name]=e.image,t)),{});if("merge"===i)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),t);else{if("replace"!==i)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=t}this.sendUpdateImageSources()}catch(t){console.error(t)}}))}applyTracks(t){var e;if(!this.sources||!t)return;const i=this.sources.videoSlots,s=[];for(const a of t){if(!(null==a?void 0:a.track))continue;const t=i.find((t=>t.id===a.id));if(t&&(null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id)===a.track.id)s.push(Object.assign(Object.assign({},t),{displayName:a.displayName}));else{const e=new MediaStream([a.track]);let i;(null==t?void 0:t.element)?i=t.element:(i=document.createElement("video"),this.placeVideoSourceInDOM(i,a.track.id)),i.srcObject=e,i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("controls","false"),s.push({active:!0,id:a.track.id,element:i,track:a.track,sessionId:a.sessionId,displayName:a.displayName,type:a.type})}}i.filter((t=>s.every((e=>e.id!==t.id)))).forEach((t=>{var e,i;null===(i=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(e=null==t?void 0:t.track)||void 0===e?void 0:e.id}"]`))||void 0===i||i.remove()}));let a=s.length!==i.length;if(!a)for(let t=0;t<s.length;t++)if(s[t].id!==i[t].id){a=!0;break}if(a){this.sources.videoSlots=s,this.sendUpdateImageSources();for(let t=0;t<20;t++){const e=s[t];e?this.setActiveVideoInput(t,!0,e.id,e.displayName,"screenshare"===e.type):this.setActiveVideoInput(t,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(t){this.aspectRatio=t,this.viewportSize=i(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(t,e="replace"){this.participantIds="merge"===e?[...new Set([...this.participantIds,...t])]:t,"started"===this.vcsState&&this.handleParticipantsChange()}}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DailyVCSWebRenderer={})}(this,(function(e){"use strict";function t(e,t,s,i){return new(s||(s=Promise))((function(a,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function n(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,n)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s=(e,t)=>{if(!e||!t||0===t)return{w:0,h:0};const{width:s,height:i}=e.getBoundingClientRect();return s/i>t?{w:Math.floor(i*t),h:i}:{w:s,h:Math.floor(s/t)}},i=e=>["off","blocked"].includes(e);function a(e,t){return`${e.session_id}${t?"_sshare":""}`}const o=(e,t="video")=>{var s,o,r;const n=null===(s=null==e?void 0:e.tracks)||void 0===s?void 0:s[t],l="screenVideo"===t;return{paused:!!n&&i(null==n?void 0:n.state),pausedByUser:null!==(r=null===(o=null==n?void 0:n.off)||void 0===o?void 0:o.byUser)&&void 0!==r&&r,id:a(e,l),displayName:l?"":e.user_name||"Guest",track:null==n?void 0:n.persistentTrack,type:l?"screenshare":"camera"}},r=(e,t=!1)=>{var s,o,r,n,l,c,d;return{id:e.session_id,displayName:e.user_name||"Guest",video:{id:a(e,!1),paused:i(t?null!==(r=null===(o=null===(s=null==e?void 0:e.tracks)||void 0===s?void 0:s.rmpVideo)||void 0===o?void 0:o.state)&&void 0!==r?r:"off":null===(l=null===(n=null==e?void 0:e.tracks)||void 0===n?void 0:n.video)||void 0===l?void 0:l.state)},audio:{},screenshareVideo:{id:a(e,!0),paused:i(null===(d=null===(c=null==e?void 0:e.tracks)||void 0===c?void 0:c.screenVideo)||void 0===d?void 0:d.state)},screenshareAudio:{}}},n=16/9;e.DailyVCSWebRenderer=class{constructor(e,t,i,a){var o,r,l;if(this.fps=30,this.paramValues={},this.activeVideoInputSlots=[],this.sources={videoSlots:[],assetImages:{}},this.maxVideoInputSlots=20,this.callbacks={},this.aspectRatio=n,this.includePausedVideo=!0,this.knownNonScreenshareVideoInputIds=new Set,this.vcsState="idle",e||console.error("VCSMeetingRenderer constructor needs a Daily callObject"),this.callObject=e,t&&"function"==typeof t.startDOMOutputAsync){this.comp=t,this.getAssetUrlCb=null!==(o=null==a?void 0:a.getAssetUrlCb)&&void 0!==o?o:null,this.rootEl=i,this.viewportSize=null!==(r=null==a?void 0:a.viewportSize)&&void 0!==r?r:{w:1280,h:720},(null==a?void 0:a.aspectRatio)&&(this.aspectRatio=a.aspectRatio,this.viewportSize=s(i,this.aspectRatio)),(null==a?void 0:a.defaultParams)&&(this.defaultParams=a.defaultParams),(null==a?void 0:a.defaultAssets)&&(this.defaultAssets=a.defaultAssets,this.updateImageSources(this.defaultAssets)),(null==a?void 0:a.maxVideoInputSlots)&&(this.maxVideoInputSlots=a.maxVideoInputSlots),(null==a?void 0:a.fps)&&(this.fps=a.fps),(null==a?void 0:a.callbacks)&&(this.callbacks=a.callbacks),Array.isArray(null==a?void 0:a.participantIds)&&(this.participantIds=a.participantIds),this.includePausedVideo=null===(l=null==a?void 0:a.includePausedVideo)||void 0===l||l,this.recomputeOutputScaleFactor();for(let e=0;e<this.maxVideoInputSlots;e++)this.setActiveVideoInput(e,!1)}else console.error("VCSMeetingRenderer constructor needs a VCS composition")}startResizeObserver(){this.resizeObserver=new ResizeObserver((e=>{e&&e.length>0&&this.rootDisplaySizeChanged()})),this.resizeObserver.observe(this.rootEl)}stopResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}get rootElement(){return this.rootEl}get ratio(){return this.aspectRatio}get state(){return this.vcsState}get vcsApiInstance(){return this.vcsApi}get composition(){return this.comp}get participants(){return this.participantIds}get params(){return this.paramValues}get size(){return this.viewportSize}get imageSources(){return this.sources.assetImages}recomputeOutputScaleFactor(){const e=this.rootEl.clientWidth,t=this.rootEl.clientHeight;if(!e||!t)return;const s=this.viewportSize.w/this.viewportSize.h;this.scaleFactor=s>=1?e/this.viewportSize.w:t/this.viewportSize.h}rootDisplaySizeChanged(){this.recomputeOutputScaleFactor(),this.vcsApi&&this.vcsApi.setScaleFactor(this.scaleFactor)}setupDefaultSources(){return t(this,void 0,void 0,(function*(){this.sources={videoSlots:[],assetImages:{}}}))}placeVideoSourceInDOM(e,t){e.setAttribute("style","display: none;"),t&&e.setAttribute("data-video-remote-track-id",t),this.rootEl.appendChild(e)}handleParticipantsChange(){var e,t,s,a;const n=Object.fromEntries(Object.values(this.callObject.participants()).map((e=>[e.session_id,e]))),l=Array.isArray(this.participantIds)?this.participantIds.map((e=>n[e])).filter(Boolean):Object.values(n),c=[],d=[],p=new Map,u=this.includePausedVideo;for(const n of l)"remote-media-player"===(null==n?void 0:n.participantType)?c.push(o(n,"rmpVideo")):(!u&&i(null===(t=null===(e=null==n?void 0:n.tracks)||void 0===e?void 0:e.video)||void 0===t?void 0:t.state)||c.push(o(n)),!u&&i(null===(a=null===(s=null==n?void 0:n.tracks)||void 0===s?void 0:s.screenVideo)||void 0===a?void 0:a.state)||d.push(o(n,"screenVideo"))),p.set(n.session_id,r(n,"remote-media-player"===(null==n?void 0:n.participantType)));this.applyTracks([...c,...d]),this.vcsApi.setRoomPeerDescriptionsById(p)}setupEventListeners(){this.callObject.on("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.on("participant-left",this.handleParticipantsChange.bind(this))}removeEventListeners(){this.callObject.off("participant-joined",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-updated",this.handleParticipantsChange.bind(this)),this.callObject.off("participant-left",this.handleParticipantsChange.bind(this))}start(){return t(this,void 0,void 0,(function*(){var e,t;this.comp&&(this.sources||(yield this.setupDefaultSources()),this.vcsApi=yield this.comp.startDOMOutputAsync(this.rootEl,this.viewportSize.w,this.viewportSize.h,this.sources,{errorCb:this.onError.bind(this),getAssetUrlCb:this.getAssetUrlCb,fps:this.fps,scaleFactor:this.scaleFactor,enablePreload:!0}),this.vcsState="started",this.handleParticipantsChange(),this.setupEventListeners(),this.sendActiveVideoInputSlots(),this.sendParams(Object.assign(Object.assign({},this.paramValues),this.defaultParams)),this.rootDisplaySizeChanged(),null===(t=(e=this.callbacks).onStart)||void 0===t||t.call(e),this.startResizeObserver())}))}stop(){var e,t;this.vcsApi&&(this.removeEventListeners(),this.vcsApi.stop(),this.vcsState="stopped",null===(t=(e=this.callbacks).onStop)||void 0===t||t.call(e),this.stopResizeObserver())}onError(e){var t,s;console.error("VCS composition error: ",e),this.vcsState="error",null===(s=(t=this.callbacks).onError)||void 0===s||s.call(t,e)}setActiveVideoInput(e,t,s="",i="",a=!1,o=!1){this.activeVideoInputSlots[e]=!!t&&{id:s||"",type:a?"screenshare":"camera",displayName:a?"":i,paused:o}}sendActiveVideoInputSlots(){if(!this.vcsApi)return;const e=[];for(const t of this.activeVideoInputSlots)"object"==typeof t?e.push(t):e.push(!1);console.log("sending video input slots: ",e),this.vcsApi.setActiveVideoInputSlots(e)}sendParam(e,t){var s,i;this.vcsApi&&(this.vcsApi.setParamValue(e,t),null===(i=(s=this.callbacks).onParamsChanged)||void 0===i||i.call(s,this.paramValues)),this.paramValues[e]=t}sendParams(e,t="merge"){"replace"===t&&(this.paramValues={}),Object.entries(e).forEach((([e,t])=>this.sendParam(e,t)))}sendUpdateImageSources(){this.vcsApi&&this.vcsApi.updateImageSources(this.sources)}updateImageSources(){return t(this,arguments,void 0,(function*(e={},t="replace"){const s=Object.entries(e).map((([e,t])=>new Promise(((s,i)=>{const a=new Image;a.onload=()=>s({name:e,image:a}),a.onerror=()=>{console.error(`Image load failed, asset ${e}`),i(new Error(`Image load failed, asset ${e}`))},a.src=t}))));try{const e=(yield Promise.all(s)).reduce(((e,t)=>(e[t.name]=t.image,e)),{});if("merge"===t)this.sources.assetImages=Object.assign(Object.assign({},this.sources.assetImages),e);else{if("replace"!==t)return void console.error('Invalid mergeType. Please use either "merge" or "replace".');this.sources.assetImages=e}this.sendUpdateImageSources()}catch(e){console.error(e)}}))}applyTracks(e){var t,s,i,a;if(!this.sources||!e)return;console.log("applyTracks %d: ",e.length,e);const o=this.sources.videoSlots,r=[];for(const i of e){const a="screenshare"===i.type;if(!i.track){if(a||!this.knownNonScreenshareVideoInputIds.has(i.id)){console.log("skipping at %d: ",e.indexOf(i),i);continue}console.log("previously seen %s",i.id)}const n=o.find((e=>e.id===i.id));if(n&&(null===(t=n.track)||void 0===t?void 0:t.id)===(null===(s=i.track)||void 0===s?void 0:s.id))r.push(Object.assign(Object.assign({},n),{paused:i.paused,displayName:i.displayName}));else{let e;if(i.track){const t=new MediaStream([i.track]);(null==n?void 0:n.element)?e=n.element:(e=document.createElement("video"),this.placeVideoSourceInDOM(e,i.track.id)),e.srcObject=t,e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.setAttribute("controls","false")}r.push(Object.assign(Object.assign({},i),{element:e})),a||this.knownNonScreenshareVideoInputIds.add(i.id)}}o.filter((e=>r.every((t=>t.id!==e.id)))).forEach((e=>{var t,s;null===(s=this.rootEl.querySelector(`[data-video-remote-track-id="${null===(t=null==e?void 0:e.track)||void 0===t?void 0:t.id}"]`))||void 0===s||s.remove()}));let n=r.length!==o.length;if(!n)for(let e=0;e<r.length;e++){const t=r[e],s=o[e];if(t.id!==s.id||t.paused!==s.paused||t.displayName!==s.displayName||(null===(i=t.track)||void 0===i?void 0:i.id)!==(null===(a=s.track)||void 0===a?void 0:a.id)){n=!0;break}}if(n){this.sources.videoSlots=r,this.sendUpdateImageSources();for(let e=0;e<20;e++){const t=r[e];t?this.setActiveVideoInput(e,!0,t.id,t.displayName,"screenshare"===t.type,t.paused):this.setActiveVideoInput(e,!1)}this.sendActiveVideoInputSlots(),this.rootDisplaySizeChanged()}}updateAspectRatio(e){this.aspectRatio=e,this.viewportSize=s(this.rootEl,this.aspectRatio),"started"===this.vcsState&&(this.stop(),this.start())}updateParticipantIds(e,t="replace"){this.participantIds="merge"===t?[...new Set([...this.participantIds,...e])]:e,"started"===this.vcsState&&this.handleParticipantsChange()}}})); |
import { DailyParticipant } from '@daily-co/daily-js'; | ||
export declare const createTrackObject: (p: DailyParticipant, trackName?: 'video' | 'screenVideo' | 'rmpVideo') => { | ||
active: boolean; | ||
export declare const createVideoInputObject: (p: DailyParticipant, trackName?: 'video' | 'screenVideo' | 'rmpVideo') => { | ||
paused: boolean; | ||
pausedByUser: boolean; | ||
id: string; | ||
sessionId: string; | ||
displayName: string; | ||
track: MediaStreamTrack | undefined; | ||
type: "camera" | "screenshare"; | ||
type: "screenshare" | "camera"; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare const createPeerObject: (p: DailyParticipant, isRMP?: boolean) => { |
export type AssetType = 'font' | 'image'; | ||
export type Params = Record<string, string | number | boolean>; | ||
export interface ActiveVideoSlot { | ||
displayName?: string; | ||
dominant?: boolean; | ||
export type VcsVideoInputType = 'camera' | 'screenshare'; | ||
export interface VideoInput { | ||
id: string; | ||
type: VcsVideoInputType; | ||
displayName: string; | ||
paused?: boolean; | ||
type?: 'camera' | 'screenshare'; | ||
} | ||
export interface VideoInputSlot { | ||
active: boolean; | ||
displayName: string; | ||
pausedByUser?: boolean; | ||
element?: HTMLVideoElement; | ||
id: string; | ||
sessionId: string; | ||
track?: MediaStreamTrack; | ||
type: 'camera' | 'screenshare'; | ||
} | ||
export interface ActiveVideoSlot { | ||
id: string; | ||
type: VcsVideoInputType; | ||
displayName?: string; | ||
paused?: boolean; | ||
dominant?: boolean; | ||
} | ||
export interface VCSSources { | ||
videoSlots: (VideoInputSlot | boolean)[]; | ||
videoSlots: (VideoInput | boolean)[]; | ||
assetImages: Record<string, string>; | ||
@@ -76,4 +77,5 @@ } | ||
participantIds?: string[]; | ||
includePausedVideo?: boolean; | ||
} | ||
export type Merge = 'replace' | 'merge'; | ||
export type State = 'idle' | 'started' | 'stopped' | 'error'; |
@@ -72,2 +72,4 @@ import type { VCSComposition, VCSApi, ViewportSize, Options, Params, Merge, State } from './types'; | ||
private participantIds; | ||
private includePausedVideo; | ||
private knownNonScreenshareVideoInputIds; | ||
private resizeObserver; | ||
@@ -91,2 +93,3 @@ private vcsState; | ||
* @param opts.participantIds is an array of participantIds to render. | ||
* @param opts.includePausedVideo determines whether to include paused video tracks. | ||
*/ | ||
@@ -93,0 +96,0 @@ constructor(callObject: DailyCall, comp: VCSComposition, rootEl: HTMLElement, opts: Options); |
{ | ||
"name": "@daily-co/daily-vcs-web", | ||
"description": "This package enables developers to render a VCSComposition inside a given DOM element in the browser.", | ||
"version": "0.0.1-alpha.10", | ||
"version": "0.0.2-alpha.2", | ||
"license": "BSD-2-Clause", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.cjs.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
48647
426
1