@mux/studio-embed
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,1 +0,1 @@ | ||
var muxStudioEmbed=(()=>{var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var v=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of f(e))!E.call(a,r)&&r!==t&&l(a,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return a};var g=a=>T(l({},"__esModule",{value:!0}),a);var N={};v(N,{PostMessageEvents:()=>s,createStudio:()=>b,eventNames:()=>i});var i=["ERROR","LIVESTREAM_STARTED","LIVESTREAM_ENDED","PARTICIPANT_JOINED","PARTICIPANT_LEFT","LOADING_STATUS_CHANGED","CAMERA_STARTED","CAMERA_STOPPED","MIC_STARTED","MIC_STOPPED","CONNECTION_QUALITY_CHANGED","HEIGHT_CHANGED"],s=(e=>(e.PORT_TRANSFER="PORT_TRANSFER",e))(s||{});var b=async(a,e,t)=>{if(typeof a!="string")throw new Error("Token must be provided and be a string");if(document.querySelector("#mux-studio-embed")!==null)throw new Error("Studio already embedded. Only one studio can be embedded at a time");let n=null;if(e instanceof HTMLElement?n=e:typeof e=="string"&&(n=document.querySelector(e)),!n)throw new Error("Invalid target element supplied");return new o(a,n,t!=null?t:{})},o=class{constructor(e,t,n){this.autoSize=!0;this._setupIframe=()=>{if(this.iframe===null)return;let e=this.iframe;e.title="Mux Studio Embed",e.id="mux-studio-embed",e.allowFullscreen=!0,e.allow="camera; microphone; fullscreen; display-capture; allow-same-origin; allow-presentation",this.autoSize&&(e.style.width="100%",e.style.height="768px"),e.style.display="block",e.style.border="none";let t=`https://0-3-0.studio.mux.dev/iframe?token=${this.token}`;this.background&&(t+=`&bg=${encodeURIComponent(this.background)}`),this.overlay&&(t+=`&ov=${encodeURIComponent(this.overlay)}`),t+=`&as=${this.autoSize?"1":"0"}`,e.src=t,e.onload=this._iframeLoaded.bind(this),this.target.appendChild(e)};this._iframeLoaded=()=>{var e;this.iframe!==null&&((e=this.iframe.contentWindow)==null||e.postMessage("PORT_TRANSFER","*",[this.channel.port2]),this.channel.port1.onmessage=this._onRecieveMessage)};this._onRecieveMessage=e=>{let{eventName:t,eventData:n}=e.data;t==="HEIGHT_CHANGED"&&this._updateIframeHeight(n.height),this.eventCallbacks[t].forEach(r=>r(n))};this._updateIframeHeight=e=>{this.iframe===null||!this.autoSize||(this.iframe.style.height=e.toString(10)+"px")};this.on=(e,t)=>{this.eventCallbacks[e].has(t)||this.eventCallbacks[e].add(t)};this.offAll=()=>{i.forEach(e=>this.eventCallbacks[e].clear())};this.remove=()=>{var e;this.offAll(),(e=this.iframe)==null||e.remove(),this.iframe=null};var m,u,h;this.token=e,this.target=t,this.iframe=document.createElement("iframe"),this.channel=new MessageChannel,this.background=(m=n==null?void 0:n.background)!=null?m:null,this.overlay=(u=n==null?void 0:n.overlay)!=null?u:null,this.autoSize=(h=n==null?void 0:n.autoSize)!=null?h:!0;let r=i.map(c=>[c,new Set]);this.eventCallbacks=Object.fromEntries(r),this._setupIframe()}off(e,t){t?this.eventCallbacks[e].delete(t):this.eventCallbacks[e].clear()}};return g(N);})(); | ||
var muxStudioEmbed=(()=>{var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var v=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of f(e))!E.call(a,r)&&r!==t&&l(a,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return a};var g=a=>T(l({},"__esModule",{value:!0}),a);var N={};v(N,{PostMessageEvents:()=>s,createStudio:()=>b,eventNames:()=>i});var i=["ERROR","LIVESTREAM_STARTED","LIVESTREAM_ENDED","PARTICIPANT_JOINED","PARTICIPANT_LEFT","LOADING_STATUS_CHANGED","CAMERA_STARTED","CAMERA_STOPPED","MIC_STARTED","MIC_STOPPED","CONNECTION_QUALITY_CHANGED","HEIGHT_CHANGED"],s=(e=>(e.PORT_TRANSFER="PORT_TRANSFER",e))(s||{});var b=async(a,e,t)=>{if(typeof a!="string")throw new Error("Token must be provided and be a string");if(document.querySelector("#mux-studio-embed")!==null)throw new Error("Studio already embedded. Only one studio can be embedded at a time");let n=null;if(e instanceof HTMLElement?n=e:typeof e=="string"&&(n=document.querySelector(e)),!n)throw new Error("Invalid target element supplied");return new o(a,n,t!=null?t:{})},o=class{constructor(e,t,n){this.autoSize=!0;this._setupIframe=()=>{if(this.iframe===null)return;let e=this.iframe;e.title="Mux Studio Embed",e.id="mux-studio-embed",e.allowFullscreen=!0,e.allow="camera; microphone; fullscreen; display-capture; allow-same-origin; allow-presentation",this.autoSize&&(e.style.width="100%",e.style.height="768px"),e.style.display="block",e.style.border="none";let t=`https://0-3-1.studio.mux.dev/iframe?token=${this.token}`;this.background&&(t+=`&bg=${encodeURIComponent(this.background)}`),this.overlay&&(t+=`&ov=${encodeURIComponent(this.overlay)}`),t+=`&as=${this.autoSize?"1":"0"}`,e.src=t,e.onload=this._iframeLoaded.bind(this),this.target.appendChild(e)};this._iframeLoaded=()=>{var e;this.iframe!==null&&((e=this.iframe.contentWindow)==null||e.postMessage("PORT_TRANSFER","*",[this.channel.port2]),this.channel.port1.onmessage=this._onRecieveMessage)};this._onRecieveMessage=e=>{let{eventName:t,eventData:n}=e.data;t==="HEIGHT_CHANGED"&&this._updateIframeHeight(n.height),this.eventCallbacks[t].forEach(r=>r(n))};this._updateIframeHeight=e=>{this.iframe===null||!this.autoSize||(this.iframe.style.height=e.toString(10)+"px")};this.on=(e,t)=>{this.eventCallbacks[e].has(t)||this.eventCallbacks[e].add(t)};this.offAll=()=>{i.forEach(e=>this.eventCallbacks[e].clear())};this.remove=()=>{var e;this.offAll(),(e=this.iframe)==null||e.remove(),this.iframe=null};var m,u,h;this.token=e,this.target=t,this.iframe=document.createElement("iframe"),this.channel=new MessageChannel,this.background=(m=n==null?void 0:n.background)!=null?m:null,this.overlay=(u=n==null?void 0:n.overlay)!=null?u:null,this.autoSize=(h=n==null?void 0:n.autoSize)!=null?h:!0;let r=i.map(c=>[c,new Set]);this.eventCallbacks=Object.fromEntries(r),this._setupIframe()}off(e,t){t?this.eventCallbacks[e].delete(t):this.eventCallbacks[e].clear()}};return g(N);})(); |
{ | ||
"name": "@mux/studio-embed", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
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 not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0