@mux/studio-embed
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.muxStudioEmbed=t():e.muxStudioEmbed=t()}(this,(function(){return(()=>{"use strict";var e={330:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eventNames=void 0,t.eventNames=["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"]},920:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function a(e){try{l(i.next(e))}catch(e){s(e)}}function r(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,r)}l((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=n(330),s=n(173);class a{constructor(e,t,n){var i,a;this._setupIframe=()=>{if(null===this.iframe)return;const e=this.iframe;e.title="Mux Livestream Studio",e.id="mux-livestream-studio",e.allowFullscreen=!0,e.allow="camera; microphone; fullscreen; display-capture; allow-same-origin; allow-presentation",e.style.width="100%",e.style.height="768px",e.style.display="block",e.style.border="none";let t=`https://0-2-1.studio.mux.dev/iframe?token=${this.token}`;this.background&&(t+=`&bg=${encodeURIComponent(this.background)}`),this.overlay&&(t+=`&ov=${encodeURIComponent(this.overlay)}`),e.src=t,e.onload=this._iframeLoaded.bind(this),this.target.appendChild(e)},this._iframeLoaded=()=>{var e;null!==this.iframe&&(null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage(s.PostMessageEvents.PORT_TRANSFER,"*",[this.channel.port2]),this.channel.port1.onmessage=this._onRecieveMessage)},this._onRecieveMessage=e=>{const{eventName:t,eventData:n}=e.data;"HEIGHT_CHANGED"===t&&this.updateIframeHeight(n.height),this.eventCallbacks[t].forEach((e=>e(n)))},this.updateIframeHeight=e=>{null!==this.iframe&&(this.iframe.style.height=e.toString(10)+"px")},this.on=(e,t)=>{this.eventCallbacks[e].has(t)||this.eventCallbacks[e].add(t)},this.offAll=()=>{o.eventNames.forEach((e=>this.eventCallbacks[e].clear()))},this.remove=()=>{var e;this.offAll(),null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null},this.token=e,this.target=t,this.iframe=document.createElement("iframe"),this.channel=new MessageChannel,this.background=null!==(i=null==n?void 0:n.background)&&void 0!==i?i:null,this.overlay=null!==(a=null==n?void 0:n.overlay)&&void 0!==a?a:null;const r=o.eventNames.map((e=>[e,new Set]));this.eventCallbacks=Object.fromEntries(r),this._setupIframe()}off(e,t){t?this.eventCallbacks[e].delete(t):this.eventCallbacks[e].clear()}}const r={init:(e,t,n)=>i(void 0,void 0,void 0,(function*(){if("string"!=typeof e)throw new Error("Token must be provided and be a string");if(null!==document.querySelector("#mux-livestream-studio"))throw new Error("Studio already embedded. Only one studio can be embedded at a time");let i=null;if(t instanceof HTMLElement?i=t:"string"==typeof t&&(i=document.querySelector(t)),!i)throw new Error("Invalid target element supplied");return new a(e,i,null!=n?n:{})}))};t.default=r},173:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PostMessageEvents=void 0,(t.PostMessageEvents||(t.PostMessageEvents={})).PORT_TRANSFER="PORT_TRANSFER"}},t={},n=function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(920);return n.default})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.muxStudioEmbed=t():e.muxStudioEmbed=t()}(this,(function(){return(()=>{"use strict";var e={330:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eventNames=void 0,t.eventNames=["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"]},920:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function a(e){try{l(i.next(e))}catch(e){s(e)}}function r(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,r)}l((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=n(330),s=n(173);class a{constructor(e,t,n){var i,a;this._setupIframe=()=>{if(null===this.iframe)return;const e=this.iframe;e.title="Mux Livestream Studio",e.id="mux-livestream-studio",e.allowFullscreen=!0,e.allow="camera; microphone; fullscreen; display-capture; allow-same-origin; allow-presentation",e.style.width="100%",e.style.height="768px",e.style.display="block",e.style.border="none";let t=`https://0-2-2.studio.mux.dev/iframe?token=${this.token}`;this.background&&(t+=`&bg=${encodeURIComponent(this.background)}`),this.overlay&&(t+=`&ov=${encodeURIComponent(this.overlay)}`),e.src=t,e.onload=this._iframeLoaded.bind(this),this.target.appendChild(e)},this._iframeLoaded=()=>{var e;null!==this.iframe&&(null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage(s.PostMessageEvents.PORT_TRANSFER,"*",[this.channel.port2]),this.channel.port1.onmessage=this._onRecieveMessage)},this._onRecieveMessage=e=>{const{eventName:t,eventData:n}=e.data;"HEIGHT_CHANGED"===t&&this.updateIframeHeight(n.height),this.eventCallbacks[t].forEach((e=>e(n)))},this.updateIframeHeight=e=>{null!==this.iframe&&(this.iframe.style.height=e.toString(10)+"px")},this.on=(e,t)=>{this.eventCallbacks[e].has(t)||this.eventCallbacks[e].add(t)},this.offAll=()=>{o.eventNames.forEach((e=>this.eventCallbacks[e].clear()))},this.remove=()=>{var e;this.offAll(),null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null},this.token=e,this.target=t,this.iframe=document.createElement("iframe"),this.channel=new MessageChannel,this.background=null!==(i=null==n?void 0:n.background)&&void 0!==i?i:null,this.overlay=null!==(a=null==n?void 0:n.overlay)&&void 0!==a?a:null;const r=o.eventNames.map((e=>[e,new Set]));this.eventCallbacks=Object.fromEntries(r),this._setupIframe()}off(e,t){t?this.eventCallbacks[e].delete(t):this.eventCallbacks[e].clear()}}const r={init:(e,t,n)=>i(void 0,void 0,void 0,(function*(){if("string"!=typeof e)throw new Error("Token must be provided and be a string");if(null!==document.querySelector("#mux-livestream-studio"))throw new Error("Studio already embedded. Only one studio can be embedded at a time");let i=null;if(t instanceof HTMLElement?i=t:"string"==typeof t&&(i=document.querySelector(t)),!i)throw new Error("Invalid target element supplied");return new a(e,i,null!=n?n:{})}))};t.default=r},173:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PostMessageEvents=void 0,(t.PostMessageEvents||(t.PostMessageEvents={})).PORT_TRANSFER="PORT_TRANSFER"}},t={},n=function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(920);return n.default})()})); |
{ | ||
"name": "@mux/studio-embed", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "@types/jest": "^27.0.2", |