@mux/mux-player 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var Ce=(t,a,e)=>{if(!a.has(t))throw TypeError("Cannot "+e)};var u=(t,a,e)=>(Ce(t,a,"read from private field"),e?e.call(t):a.get(t)),h=(t,a,e)=>{if(a.has(t))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(t):a.set(t,e)},C=(t,a,e,i)=>(Ce(t,a,"write to private field"),i?i.call(t,e):a.set(t,e),e);var g=(t,a,e)=>(Ce(t,a,"access private method"),e);var W=class{addEventListener(){}removeEventListener(){}dispatchEvent(a){return!0}};if(typeof DocumentFragment=="undefined"){class t extends W{}globalThis.DocumentFragment=t}var z=class extends W{},xe=class extends W{},Bt={get(t){},define(t,a,e){},upgrade(t){},whenDefined(t){return Promise.resolve(z)}},X,Le=class{constructor(a,e={}){h(this,X,void 0);C(this,X,e==null?void 0:e.detail)}get detail(){return u(this,X)}initCustomEvent(){}};X=new WeakMap;function Ut(t,a){return new z}var rt={document:{createElement:Ut},DocumentFragment,customElements:Bt,CustomEvent:Le,EventTarget:W,HTMLElement:z,HTMLVideoElement:xe},ot=typeof window=="undefined"||typeof globalThis.customElements=="undefined",c=ot?rt:globalThis,T=ot?rt.document:globalThis.document;import{MediaController as ha}from"media-chrome";import{Attributes as He}from"media-chrome/dist/media-container.js";import{MediaUIAttributes as Mt}from"media-chrome/dist/constants.js";import"media-chrome/dist/experimental/index.js";import ga,{MediaError as fe,Attributes as d}from"@mux/mux-video";import{StreamTypes as w,PlaybackTypes as ye,addTextTrack as fa,removeTextTrack as ya,CmcdTypeValues as St}from"@mux/playback-core";import{VideoEvents as Zt}from"@mux/mux-video";var $t="en",B={code:$t};var nt="en";function l(t,a=!0){var r,o;let e=a&&(o=(r=B)==null?void 0:r[t])!=null?o:t,i=a?B.code:nt;return new Re(e,i)}var Re=class{constructor(a,e=(i=>(i=B.code)!=null?i:nt)()){this.message=a,this.locale=e}format(a){return this.message.replace(/\{(\w+)\}/g,(e,i)=>{var r;return(r=a[i])!=null?r:""})}toString(){return this.message}};function st(t){let a="";return Object.entries(t).forEach(([e,i])=>{i!=null&&(a+=`${se(e)}: ${i}; `)}),a?a.trim():void 0}function se(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function de(t){return t.replace(/[-_]([a-z])/g,(a,e)=>e.toUpperCase())}function R(t){if(t==null)return;let a=+t;return Number.isNaN(a)?void 0:a}function we(t){let a=Kt(t).toString();return a?"?"+a:""}function Kt(t){let a={};for(let e in t)t[e]!=null&&(a[e]=t[e]);return new URLSearchParams(a)}function P(t){let a=(t!=null?t:"").split(".")[1];if(!a)return{};let e=a.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(e).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}var Oe=(t,a)=>!t||!a?!1:t.contains(a)?!0:Oe(t,a.getRootNode().host);import{StreamTypes as Me}from"@mux/playback-core";var dt="mux.com",Ft=()=>{try{return"2.3.2"}catch{}return"UNKNOWN"},Yt=Ft(),me=()=>Yt,lt=(t,{token:a,customDomain:e=dt,thumbnailTime:i}={})=>{let r=a==null?i:void 0,{aud:o}=P(a);if(!(a&&o!=="t"))return`https://image.${e}/${t}/thumbnail.webp${we({token:a,time:r})}`},mt=(t,{token:a,customDomain:e=dt}={})=>{let{aud:i}=P(a);if(!(a&&i!=="s"))return`https://image.${e}/${t}/storyboard.vtt${we({token:a,format:"webp"})}`},J=t=>{if(t){if([Me.LIVE,Me.ON_DEMAND].includes(t))return t;if(t!=null&&t.includes("live"))return Me.LIVE}};var Wt={crossorigin:"crossOrigin",playsinline:"playsInline"};function ut(t){var a;return(a=Wt[t])!=null?a:de(t)}var U,$,E,le=class{constructor(a,e){h(this,U,void 0);h(this,$,void 0);h(this,E,[]);C(this,U,a),C(this,$,e)}[Symbol.iterator](){return u(this,E).values()}get length(){return u(this,E).length}get value(){var a;return(a=u(this,E).join(" "))!=null?a:""}set value(a){var e;a!==this.value&&(C(this,E,[]),this.add(...(e=a==null?void 0:a.split(" "))!=null?e:[]))}toString(){return this.value}item(a){return u(this,E)[a]}values(){return u(this,E).values()}keys(){return u(this,E).keys()}forEach(a){u(this,E).forEach(a)}add(...a){var e,i;a.forEach(r=>{this.contains(r)||u(this,E).push(r)}),!(this.value===""&&!((e=u(this,U))!=null&&e.hasAttribute(`${u(this,$)}`)))&&((i=u(this,U))==null||i.setAttribute(`${u(this,$)}`,`${this.value}`))}remove(...a){var e;a.forEach(i=>{u(this,E).splice(u(this,E).indexOf(i),1)}),(e=u(this,U))==null||e.setAttribute(`${u(this,$)}`,`${this.value}`)}contains(a){return u(this,E).includes(a)}toggle(a,e){return typeof e!="undefined"?e?(this.add(a),!0):(this.remove(a),!1):this.contains(a)?(this.remove(a),!1):(this.add(a),!0)}replace(a,e){this.remove(a),this.add(e)}};U=new WeakMap,$=new WeakMap,E=new WeakMap;var ct=`[mux-player ${me()}]`;function N(...t){console.warn(ct,...t)}function x(...t){console.error(ct,...t)}function Se(t){var e;let a=(e=t.message)!=null?e:"";if(t.context&&(a+=` ${t.context}`),t.file){let i="https://github.com/muxinc/elements/blob/main/errors/";a+=` ${l("Read more: ")}
1
+ var Ce=(t,a,e)=>{if(!a.has(t))throw TypeError("Cannot "+e)};var u=(t,a,e)=>(Ce(t,a,"read from private field"),e?e.call(t):a.get(t)),h=(t,a,e)=>{if(a.has(t))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(t):a.set(t,e)},C=(t,a,e,i)=>(Ce(t,a,"write to private field"),i?i.call(t,e):a.set(t,e),e);var g=(t,a,e)=>(Ce(t,a,"access private method"),e);var W=class{addEventListener(){}removeEventListener(){}dispatchEvent(a){return!0}};if(typeof DocumentFragment=="undefined"){class t extends W{}globalThis.DocumentFragment=t}var z=class extends W{},xe=class extends W{},Bt={get(t){},define(t,a,e){},upgrade(t){},whenDefined(t){return Promise.resolve(z)}},X,Le=class{constructor(a,e={}){h(this,X,void 0);C(this,X,e==null?void 0:e.detail)}get detail(){return u(this,X)}initCustomEvent(){}};X=new WeakMap;function Ut(t,a){return new z}var rt={document:{createElement:Ut},DocumentFragment,customElements:Bt,CustomEvent:Le,EventTarget:W,HTMLElement:z,HTMLVideoElement:xe},ot=typeof window=="undefined"||typeof globalThis.customElements=="undefined",c=ot?rt:globalThis,T=ot?rt.document:globalThis.document;import{MediaController as ha}from"media-chrome";import{Attributes as He}from"media-chrome/dist/media-container.js";import{MediaUIAttributes as Mt}from"media-chrome/dist/constants.js";import"media-chrome/dist/experimental/index.js";import ga,{MediaError as fe,Attributes as d}from"@mux/mux-video";import{StreamTypes as w,PlaybackTypes as ye,addTextTrack as fa,removeTextTrack as ya,CmcdTypeValues as St}from"@mux/playback-core";import{VideoEvents as Zt}from"@mux/mux-video";var $t="en",B={code:$t};var nt="en";function l(t,a=!0){var r,o;let e=a&&(o=(r=B)==null?void 0:r[t])!=null?o:t,i=a?B.code:nt;return new Re(e,i)}var Re=class{constructor(a,e=(i=>(i=B.code)!=null?i:nt)()){this.message=a,this.locale=e}format(a){return this.message.replace(/\{(\w+)\}/g,(e,i)=>{var r;return(r=a[i])!=null?r:""})}toString(){return this.message}};function st(t){let a="";return Object.entries(t).forEach(([e,i])=>{i!=null&&(a+=`${se(e)}: ${i}; `)}),a?a.trim():void 0}function se(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function de(t){return t.replace(/[-_]([a-z])/g,(a,e)=>e.toUpperCase())}function R(t){if(t==null)return;let a=+t;return Number.isNaN(a)?void 0:a}function we(t){let a=Kt(t).toString();return a?"?"+a:""}function Kt(t){let a={};for(let e in t)t[e]!=null&&(a[e]=t[e]);return new URLSearchParams(a)}function P(t){let a=(t!=null?t:"").split(".")[1];if(!a)return{};let e=a.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(e).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}var Oe=(t,a)=>!t||!a?!1:t.contains(a)?!0:Oe(t,a.getRootNode().host);import{StreamTypes as Me}from"@mux/playback-core";var dt="mux.com",Ft=()=>{try{return"2.3.3"}catch{}return"UNKNOWN"},Yt=Ft(),me=()=>Yt,lt=(t,{token:a,customDomain:e=dt,thumbnailTime:i}={})=>{let r=a==null?i:void 0,{aud:o}=P(a);if(!(a&&o!=="t"))return`https://image.${e}/${t}/thumbnail.webp${we({token:a,time:r})}`},mt=(t,{token:a,customDomain:e=dt}={})=>{let{aud:i}=P(a);if(!(a&&i!=="s"))return`https://image.${e}/${t}/storyboard.vtt${we({token:a,format:"webp"})}`},J=t=>{if(t){if([Me.LIVE,Me.ON_DEMAND].includes(t))return t;if(t!=null&&t.includes("live"))return Me.LIVE}};var Wt={crossorigin:"crossOrigin",playsinline:"playsInline"};function ut(t){var a;return(a=Wt[t])!=null?a:de(t)}var U,$,E,le=class{constructor(a,e){h(this,U,void 0);h(this,$,void 0);h(this,E,[]);C(this,U,a),C(this,$,e)}[Symbol.iterator](){return u(this,E).values()}get length(){return u(this,E).length}get value(){var a;return(a=u(this,E).join(" "))!=null?a:""}set value(a){var e;a!==this.value&&(C(this,E,[]),this.add(...(e=a==null?void 0:a.split(" "))!=null?e:[]))}toString(){return this.value}item(a){return u(this,E)[a]}values(){return u(this,E).values()}keys(){return u(this,E).keys()}forEach(a){u(this,E).forEach(a)}add(...a){var e,i;a.forEach(r=>{this.contains(r)||u(this,E).push(r)}),!(this.value===""&&!((e=u(this,U))!=null&&e.hasAttribute(`${u(this,$)}`)))&&((i=u(this,U))==null||i.setAttribute(`${u(this,$)}`,`${this.value}`))}remove(...a){var e;a.forEach(i=>{u(this,E).splice(u(this,E).indexOf(i),1)}),(e=u(this,U))==null||e.setAttribute(`${u(this,$)}`,`${this.value}`)}contains(a){return u(this,E).includes(a)}toggle(a,e){return typeof e!="undefined"?e?(this.add(a),!0):(this.remove(a),!1):this.contains(a)?(this.remove(a),!1):(this.add(a),!0)}replace(a,e){this.remove(a),this.add(e)}};U=new WeakMap,$=new WeakMap,E=new WeakMap;var ct=`[mux-player ${me()}]`;function N(...t){console.warn(ct,...t)}function x(...t){console.error(ct,...t)}function Se(t){var e;let a=(e=t.message)!=null?e:"";if(t.context&&(a+=` ${t.context}`),t.file){let i="https://github.com/muxinc/elements/blob/main/errors/";a+=` ${l("Read more: ")}
2
2
  ${i}${t.file}`}N(a)}var y={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},K={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},bt=Object.freeze({length:0,start(t){let a=t>>>0;if(a>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${a}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(t){let a=t>>>0;if(a>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${a}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),jt=Zt.filter(t=>t!=="error"),Gt=Object.values(y).filter(t=>![y.PLAYSINLINE].includes(t)),qt=Object.values(K);function ht(t){t.querySelectorAll(":scope > track").forEach(a=>{var e;(e=t.media)==null||e.append(a.cloneNode())}),jt.forEach(a=>{var e;(e=t.media)==null||e.addEventListener(a,i=>{t.dispatchEvent(new Event(i.type))})})}var _e=class extends c.HTMLElement{static get observedAttributes(){return[...Gt,...qt]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(i=>{var r;(r=this.media)==null||r.append(i.cloneNode())});let a=i=>{for(let r of i)r.type==="childList"&&(r.removedNodes.forEach(o=>{var m,p;let s=(m=this.media)==null?void 0:m.querySelector(`track[src="${o.src}"]`);s&&((p=this.media)==null||p.removeChild(s))}),r.addedNodes.forEach(o=>{var s;(s=this.media)==null||s.append(o.cloneNode())}))};new MutationObserver(a).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(a,e,i){var r,o;switch(a){case K.MUTED:{this.media&&(this.media.muted=i!=null,this.media.defaultMuted=i!=null);return}case K.VOLUME:{let s=(r=R(i))!=null?r:1;this.media&&(this.media.volume=s);return}case K.PLAYBACKRATE:{let s=(o=R(i))!=null?o:1;this.media&&(this.media.playbackRate=s,this.media.defaultPlaybackRate=s);return}}}play(){var a,e;return(e=(a=this.media)==null?void 0:a.play())!=null?e:Promise.reject()}pause(){var a;(a=this.media)==null||a.pause()}requestCast(a){var e;return(e=this.media)==null?void 0:e.requestCast(a)}get media(){var a;return(a=this.shadowRoot)==null?void 0:a.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var a,e;return(e=(a=this.media)==null?void 0:a.paused)!=null?e:!0}get duration(){var a,e;return(e=(a=this.media)==null?void 0:a.duration)!=null?e:NaN}get ended(){var a,e;return(e=(a=this.media)==null?void 0:a.ended)!=null?e:!1}get buffered(){var a,e;return(e=(a=this.media)==null?void 0:a.buffered)!=null?e:bt}get seekable(){var a,e;return(e=(a=this.media)==null?void 0:a.seekable)!=null?e:bt}get readyState(){var a,e;return(e=(a=this.media)==null?void 0:a.readyState)!=null?e:0}get videoWidth(){var a,e;return(e=(a=this.media)==null?void 0:a.videoWidth)!=null?e:0}get videoHeight(){var a,e;return(e=(a=this.media)==null?void 0:a.videoHeight)!=null?e:0}get currentTime(){var a,e;return(e=(a=this.media)==null?void 0:a.currentTime)!=null?e:0}set currentTime(a){this.media&&(this.media.currentTime=Number(a))}get volume(){var a,e;return(e=(a=this.media)==null?void 0:a.volume)!=null?e:1}set volume(a){this.media&&(this.media.volume=Number(a))}get playbackRate(){var a,e;return(e=(a=this.media)==null?void 0:a.playbackRate)!=null?e:1}set playbackRate(a){this.media&&(this.media.playbackRate=Number(a))}get defaultPlaybackRate(){var a;return(a=R(this.getAttribute(K.PLAYBACKRATE)))!=null?a:1}set defaultPlaybackRate(a){a!=null?this.setAttribute(K.PLAYBACKRATE,`${a}`):this.removeAttribute(K.PLAYBACKRATE)}get crossOrigin(){return Q(this,y.CROSSORIGIN)}set crossOrigin(a){this.setAttribute(y.CROSSORIGIN,`${a}`)}get autoplay(){return Q(this,y.AUTOPLAY)!=null}set autoplay(a){a?this.setAttribute(y.AUTOPLAY,typeof a=="string"?a:""):this.removeAttribute(y.AUTOPLAY)}get loop(){return Q(this,y.LOOP)!=null}set loop(a){a?this.setAttribute(y.LOOP,""):this.removeAttribute(y.LOOP)}get muted(){var a,e;return(e=(a=this.media)==null?void 0:a.muted)!=null?e:!1}set muted(a){this.media&&(this.media.muted=!!a)}get defaultMuted(){return Q(this,y.MUTED)!=null}set defaultMuted(a){a?this.setAttribute(y.MUTED,""):this.removeAttribute(y.MUTED)}get playsInline(){return Q(this,y.PLAYSINLINE)!=null}set playsInline(a){x("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(a){["","none","metadata","auto"].includes(a)?this.setAttribute(y.PRELOAD,a):this.removeAttribute(y.PRELOAD)}};function Q(t,a){return t.media?t.media.getAttribute(a):t.getAttribute(a)}var Pe=_e;import"media-chrome/dist/media-theme-element.js";var gt=`:host {
3
3
  --media-control-display: var(--controls);
4
4
  --media-loading-indicator-display: var(--loading-indicator);