@mux/playback-core
Advanced tools
Comparing version 0.9.1-canary.22-cf5ae56 to 0.9.1-canary.23-71d18a4
{ | ||
"inputs": { | ||
"../../shared/polyfills/window.js": { | ||
"bytes": 2035, | ||
"imports": [] | ||
}, | ||
"../../shared/polyfills/index.mjs": { | ||
"bytes": 204, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/window.js", | ||
"kind": "import-statement" | ||
} | ||
] | ||
}, | ||
"src/autoplay.ts": { | ||
@@ -33,9 +20,5 @@ "bytes": 4664, | ||
"src/index.ts": { | ||
"bytes": 16504, | ||
"bytes": 16479, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/index.mjs", | ||
"kind": "import-statement" | ||
}, | ||
{ | ||
"path": "src/autoplay.ts", | ||
@@ -64,3 +47,3 @@ "kind": "import-statement" | ||
"inputs": {}, | ||
"bytes": 39596 | ||
"bytes": 36678 | ||
}, | ||
@@ -73,7 +56,4 @@ "dist/index.cjs.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 5095 | ||
"bytesInOutput": 5074 | ||
}, | ||
"../../shared/polyfills/window.js": { | ||
"bytesInOutput": 930 | ||
}, | ||
"src/autoplay.ts": { | ||
@@ -92,5 +72,5 @@ "bytesInOutput": 1022 | ||
}, | ||
"bytes": 11022 | ||
"bytes": 9732 | ||
} | ||
} | ||
} |
{ | ||
"inputs": { | ||
"../../shared/polyfills/window.js": { | ||
"bytes": 2035, | ||
"imports": [] | ||
}, | ||
"../../shared/polyfills/index.mjs": { | ||
"bytes": 204, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/window.js", | ||
"kind": "import-statement" | ||
} | ||
] | ||
}, | ||
"src/autoplay.ts": { | ||
@@ -33,9 +20,5 @@ "bytes": 4664, | ||
"src/index.ts": { | ||
"bytes": 16504, | ||
"bytes": 16479, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/index.mjs", | ||
"kind": "import-statement" | ||
}, | ||
{ | ||
"path": "src/autoplay.ts", | ||
@@ -64,3 +47,3 @@ "kind": "import-statement" | ||
"inputs": {}, | ||
"bytes": 39568 | ||
"bytes": 36654 | ||
}, | ||
@@ -97,7 +80,4 @@ "dist/index.mjs": { | ||
"inputs": { | ||
"../../shared/polyfills/window.js": { | ||
"bytesInOutput": 930 | ||
}, | ||
"src/index.ts": { | ||
"bytesInOutput": 4507 | ||
"bytesInOutput": 4497 | ||
}, | ||
@@ -117,5 +97,5 @@ "src/autoplay.ts": { | ||
}, | ||
"bytes": 10217 | ||
"bytes": 8933 | ||
} | ||
} | ||
} |
{ | ||
"inputs": { | ||
"../../shared/polyfills/window.js": { | ||
"bytes": 2035, | ||
"imports": [] | ||
}, | ||
"../../shared/polyfills/index.mjs": { | ||
"bytes": 204, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/window.js", | ||
"kind": "import-statement" | ||
} | ||
] | ||
}, | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
@@ -51,9 +38,5 @@ "bytes": 105451, | ||
"src/index.ts": { | ||
"bytes": 16504, | ||
"bytes": 16479, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/index.mjs", | ||
"kind": "import-statement" | ||
}, | ||
{ | ||
"path": "../../node_modules/mux-embed/dist/mux.js", | ||
@@ -90,3 +73,3 @@ "kind": "import-statement" | ||
"inputs": {}, | ||
"bytes": 1496680 | ||
"bytes": 1493766 | ||
}, | ||
@@ -104,5 +87,2 @@ "dist/playback-core.js": { | ||
}, | ||
"../../shared/polyfills/window.js": { | ||
"bytesInOutput": 944 | ||
}, | ||
"src/index.ts": { | ||
@@ -124,5 +104,5 @@ "bytesInOutput": 4618 | ||
}, | ||
"bytes": 473438 | ||
"bytes": 472149 | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
var ie=Object.create;var h=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var K=e=>h(e,"__esModule",{value:!0});var pe=(e,t)=>{K(e);for(var r in t)h(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ue(t))!de.call(e,n)&&n!=="default"&&h(e,n,{get:()=>t[n],enumerable:!(r=ce(t,n))||r.enumerable});return e},P=e=>ye(K(h(e!=null?ie(le(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var B=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var F=(e,t,r)=>(B(e,t,"read from private field"),r?r.call(e):t.get(e)),q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Y=(e,t,r,n)=>(B(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);pe(exports,{ExtensionMimeTypeMap:()=>g,Hls:()=>T.default,MediaError:()=>u,MimeTypeShorthandMap:()=>R,StreamTypes:()=>k,addTextTrack:()=>C,allMediaTypes:()=>Me,generatePlayerInitTime:()=>Te,getError:()=>Ee,getStreamTypeConfig:()=>ee,getType:()=>N,inferMimeTypeFromURL:()=>j,initialize:()=>xe,isMuxVideoSrc:()=>ne,loadMedia:()=>ae,mux:()=>D.default,removeTextTrack:()=>J,setupAutoplay:()=>X,setupHls:()=>re,setupMux:()=>oe,shorthandKeys:()=>me,teardown:()=>te,toMuxVideoURL:()=>ge,toPlaybackIdParts:()=>Z});if(typeof DocumentFragment=="undefined"){class e{}globalThis.DocumentFragment=e}globalThis.customElements||(globalThis.customElements={get(e){},define(e,t,r){},upgrade(e){},whenDefined(e){return Promise.resolve(globalThis.HTMLElement)}});var _;if(!globalThis.CustomEvent){class e{constructor(r,n={}){q(this,_,void 0);Y(this,_,n==null?void 0:n.detail)}get detail(){F(this,_)}initCustomEvent(r,n,o,a){}}_=new WeakMap,globalThis.CustomEvent=e}if(!globalThis.EventTarget){class e{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}}globalThis.EventTarget=e}if(!globalThis.HTMLElement){class e extends EventTarget{}globalThis.HTMLElement=e}if(!globalThis.HTMLVideoElement){class e extends EventTarget{}globalThis.HTMLVideoElement=e}var $,z;if(!(($=globalThis.document)==null?void 0:$.createElement)){let e=(z=globalThis.document)!=null?z:{};e.createElement=function(r,n){return new HTMLElement},globalThis.document=e}var D=P(require("mux-embed")),T=P(require("hls.js"));var w=P(require("hls.js")),I={ANY:"any",MUTED:"muted"},fe=Object.values(I),W=e=>typeof e=="boolean"||typeof e=="string"&&fe.includes(e),X=(e,t,r)=>{let n=!1,o=!1,a=W(t)?t:!!t,c=()=>{e.addEventListener("playing",()=>{n=!0},{once:!0})};if(c(),e.addEventListener("loadstart",()=>{n=!1,c(),O(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),O(e,a)},{once:!0}),r&&r.once(w.default.Events.LEVEL_LOADED,(i,l)=>{var d;o=(d=l.details.live)!=null?d:!1}),!a){let i=()=>{!o||((r==null?void 0:r.liveSyncPosition)?e.currentTime=r.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};e.addEventListener("play",()=>{r&&e.preload==="metadata"?r.once(w.default.Events.LEVEL_UPDATED,i):r&&i()},{once:!0})}return i=>{n||(a=W(i)?i:!!i,O(e,a))}},O=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case I.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case I.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var E=class extends Error{constructor(t,r=E.MEDIA_ERR_CUSTOM,n){super(t);var o;this.name="MediaError",this.code=r,this.fatal=n!=null?n:r>=E.MEDIA_ERR_NETWORK&&r<=E.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(o=E.defaultMessages[this.code])!=null?o:"")}},u=E;u.MEDIA_ERR_ABORTED=1,u.MEDIA_ERR_NETWORK=2,u.MEDIA_ERR_DECODE=3,u.MEDIA_ERR_SRC_NOT_SUPPORTED=4,u.MEDIA_ERR_ENCRYPTED=5,u.MEDIA_ERR_CUSTOM=100,u.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var x=P(require("hls.js"));function G(e,t){t.on(x.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(c=>{var l;let s=(l=c.subtitleTrack)!=null?l:c.closedCaptions,i=t.subtitleTracks.findIndex(({lang:d,name:y,type:f})=>d==(s==null?void 0:s.lang)&&y===c.label&&f.toLowerCase()===c.kind);C(e,c.kind,c.label,s==null?void 0:s.lang,`${c.kind}${i}`)})});let r=()=>{var c;if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(s=>s.id&&s.mode==="showing"&&["subtitles","captions"].includes(s.kind)),a=`${(c=t.subtitleTracks[t.subtitleTrack])==null?void 0:c.type.toLowerCase()}${t.subtitleTrack}`;if(o&&(t.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let s=t.subtitleTracks.findIndex(({lang:i,name:l,type:d})=>i==o.language&&l===o.label&&d.toLowerCase()===o.kind);t.subtitleTrack=s}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(s=>{o.addCue(s)})};e.textTracks.addEventListener("change",r),t.on(x.default.Events.CUES_PARSED,(o,{track:a,type:c,cues:s})=>{let i=e.textTracks.getTrackById(a);if(!i)return;let l=i.mode==="disabled";l&&(i.mode="hidden"),s.forEach(d=>{var y;((y=i.cues)==null?void 0:y.getCueById(d.id))||i.addCue(d)}),l&&(i.mode="disabled")}),t.on(x.default.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,c;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)==null?void 0:a.length)){let s=e.querySelector('track[label="thumbnails"]'),i=(c=s==null?void 0:s.getAttribute("src"))!=null?c:"";s==null||s.removeAttribute("src"),setTimeout(()=>{s==null||s.setAttribute("src",i)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(x.default.Events.MANIFEST_LOADED,n),t.once(x.default.Events.MEDIA_ATTACHED,n)}function C(e,t,r,n,o){let a=document.createElement("track");return a.kind=t,a.label=r,n&&(a.srclang=n),o&&(a.id=o),a.track.mode="disabled",a.setAttribute("data-removeondestroy",""),e.append(a),a.track}function J(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}var V=(e,t)=>e in t;var Q="mux.com",Te=()=>D.default.utils.now(),k={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},g={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},R={HLS:g.M3U8},me=Object.keys(R),Me=[...Object.values(g),"hls","HLS"],Z=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},ge=(e,{domain:t=Q}={})=>{if(!e)return;let[r,n=""]=Z(e);return`https://stream.${t}/${r}.m3u8${n}`},j=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return V(o,g)?g[o]:""},N=e=>{let t=e.type;if(t){let n=t.toUpperCase();return V(n,R)?R[n]:t}let{src:r}=e;return r?j(r):""},ee=e=>{if([k.LIVE,k.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===k.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},H=new WeakMap,Ee=e=>{var t;return(t=H.get(e))==null?void 0:t.error},te=(e,t)=>{t&&(t.detachMedia(),t.destroy()),(e==null?void 0:e.mux)&&!e.mux.deleted&&(e.mux.destroy(),e.mux),e&&(e.removeEventListener("error",se),e.removeEventListener("error",U),H.delete(e))},re=(e,t)=>{var L,b,v;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=N(e),s=c===g.M3U8,i=!c||((L=t==null?void 0:t.canPlayType(c))!=null?L:!0),l=T.default.isSupported(),f=((v=(b=window==null?void 0:window.navigator)==null?void 0:b.userAgent)!=null?v:"").toLowerCase().indexOf("android")!==-1;if(s&&!(!s||i&&!((n||f)&&l))&&l){let M={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=ee(o);return new T.default({debug:r,startPosition:a,...M,...p})}},ne=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=new URL(t).hostname.toLocaleLowerCase();return n.includes(Q)||!!r&&n.includes(r.toLocaleLowerCase())},oe=(e,t,r)=>{let{envKey:n}=e,o=ne(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:l,debug:d}=e,y=f=>typeof f.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(f):f;D.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?T.default:void 0,automaticErrorTracking:!1,errorTranslator:y,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...l}})}},ae=(e,t,r)=>{var L,b,v;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=N(e),c=a===g.M3U8,s=!a||((L=t==null?void 0:t.canPlayType(a))!=null?L:!0),i=T.default.isSupported(),y=((v=(b=window==null?void 0:window.navigator)==null?void 0:b.userAgent)!=null?v:"").toLowerCase().indexOf("android")!==-1&&o===k.LL_LIVE,f=!c||s&&!((n||y)&&i),{src:m}=e;if(t&&s&&f){if(typeof m=="string"){let{startTime:M}=e;if(t.setAttribute("src",m),M){let p=({target:A})=>{A.currentTime=M,A.removeEventListener("loadedmetadata",p)};t.addEventListener("loadedmetadata",p)}}else t.removeAttribute("src");t.addEventListener("error",se),t.addEventListener("error",U)}else if(r&&m){switch(r.on(T.default.Events.ERROR,(M,p)=>{let A={[T.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[T.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},S=new u("",A[p.type]);S.fatal=p.fatal,S.data=p,t.dispatchEvent(new CustomEvent("error",{detail:S}))}),t.addEventListener("error",U),G(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(m),{once:!0});break;case"metadata":let M=r.config.maxBufferLength,p=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=M,r.config.maxBufferSize=p},{once:!0}),r.loadSource(m);break;default:r.loadSource(m)}r.attachMedia(t)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function se(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t==null?void 0:t.error))return;let{message:r,code:n}=t.error,o=new u(r,n);if(t.src&&(n!==u.MEDIA_ERR_DECODE||n!==void 0)){let{status:a}=await fetch(t.src);o.data={response:{code:a}}}t.dispatchEvent(new CustomEvent("error",{detail:o}))}function U(e){var o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;if(!r||!r.fatal)return;let n=H.get(t);n&&(n.error=r),(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message})}var xe=(e,t,r)=>{te(t,r),H.set(t,{});let n=re(e,t);return oe(e,t,n),ae(e,t,n),n}; | ||
var ee=Object.create;var _=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var U=e=>_(e,"__esModule",{value:!0});var ae=(e,t)=>{U(e);for(var r in t)_(e,r,{get:t[r],enumerable:!0})},se=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of re(t))!oe.call(e,n)&&n!=="default"&&_(e,n,{get:()=>t[n],enumerable:!(r=te(t,n))||r.enumerable});return e},P=e=>se(U(_(e!=null?ee(ne(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);ae(exports,{ExtensionMimeTypeMap:()=>x,Hls:()=>T.default,MediaError:()=>u,MimeTypeShorthandMap:()=>R,StreamTypes:()=>k,addTextTrack:()=>w,allMediaTypes:()=>pe,generatePlayerInitTime:()=>ce,getError:()=>le,getStreamTypeConfig:()=>W,getType:()=>V,inferMimeTypeFromURL:()=>z,initialize:()=>ye,isMuxVideoSrc:()=>J,loadMedia:()=>Z,mux:()=>D.default,removeTextTrack:()=>Y,setupAutoplay:()=>B,setupHls:()=>G,setupMux:()=>Q,shorthandKeys:()=>ue,teardown:()=>X,toMuxVideoURL:()=>de,toPlaybackIdParts:()=>F});var D=P(require("mux-embed")),T=P(require("hls.js"));var H=P(require("hls.js")),h={ANY:"any",MUTED:"muted"},ie=Object.values(h),K=e=>typeof e=="boolean"||typeof e=="string"&&ie.includes(e),B=(e,t,r)=>{let n=!1,o=!1,a=K(t)?t:!!t,c=()=>{e.addEventListener("playing",()=>{n=!0},{once:!0})};if(c(),e.addEventListener("loadstart",()=>{n=!1,c(),O(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),O(e,a)},{once:!0}),r&&r.once(H.default.Events.LEVEL_LOADED,(i,p)=>{var d;o=(d=p.details.live)!=null?d:!1}),!a){let i=()=>{!o||((r==null?void 0:r.liveSyncPosition)?e.currentTime=r.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};e.addEventListener("play",()=>{r&&e.preload==="metadata"?r.once(H.default.Events.LEVEL_UPDATED,i):r&&i()},{once:!0})}return i=>{n||(a=K(i)?i:!!i,O(e,a))}},O=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case h.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case h.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var g=class extends Error{constructor(t,r=g.MEDIA_ERR_CUSTOM,n){super(t);var o;this.name="MediaError",this.code=r,this.fatal=n!=null?n:r>=g.MEDIA_ERR_NETWORK&&r<=g.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(o=g.defaultMessages[this.code])!=null?o:"")}},u=g;u.MEDIA_ERR_ABORTED=1,u.MEDIA_ERR_NETWORK=2,u.MEDIA_ERR_DECODE=3,u.MEDIA_ERR_SRC_NOT_SUPPORTED=4,u.MEDIA_ERR_ENCRYPTED=5,u.MEDIA_ERR_CUSTOM=100,u.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var L=P(require("hls.js"));function q(e,t){t.on(L.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(c=>{var p;let s=(p=c.subtitleTrack)!=null?p:c.closedCaptions,i=t.subtitleTracks.findIndex(({lang:d,name:y,type:f})=>d==(s==null?void 0:s.lang)&&y===c.label&&f.toLowerCase()===c.kind);w(e,c.kind,c.label,s==null?void 0:s.lang,`${c.kind}${i}`)})});let r=()=>{var c;if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(s=>s.id&&s.mode==="showing"&&["subtitles","captions"].includes(s.kind)),a=`${(c=t.subtitleTracks[t.subtitleTrack])==null?void 0:c.type.toLowerCase()}${t.subtitleTrack}`;if(o&&(t.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let s=t.subtitleTracks.findIndex(({lang:i,name:p,type:d})=>i==o.language&&p===o.label&&d.toLowerCase()===o.kind);t.subtitleTrack=s}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(s=>{o.addCue(s)})};e.textTracks.addEventListener("change",r),t.on(L.default.Events.CUES_PARSED,(o,{track:a,type:c,cues:s})=>{let i=e.textTracks.getTrackById(a);if(!i)return;let p=i.mode==="disabled";p&&(i.mode="hidden"),s.forEach(d=>{var y;((y=i.cues)==null?void 0:y.getCueById(d.id))||i.addCue(d)}),p&&(i.mode="disabled")}),t.on(L.default.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,c;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)==null?void 0:a.length)){let s=e.querySelector('track[label="thumbnails"]'),i=(c=s==null?void 0:s.getAttribute("src"))!=null?c:"";s==null||s.removeAttribute("src"),setTimeout(()=>{s==null||s.setAttribute("src",i)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(L.default.Events.MANIFEST_LOADED,n),t.once(L.default.Events.MEDIA_ATTACHED,n)}function w(e,t,r,n,o){let a=document.createElement("track");return a.kind=t,a.label=r,n&&(a.srclang=n),o&&(a.id=o),a.track.mode="disabled",a.setAttribute("data-removeondestroy",""),e.append(a),a.track}function Y(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}var C=(e,t)=>e in t;var $="mux.com",ce=()=>D.default.utils.now(),k={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},x={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},R={HLS:x.M3U8},ue=Object.keys(R),pe=[...Object.values(x),"hls","HLS"],F=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},de=(e,{domain:t=$}={})=>{if(!e)return;let[r,n=""]=F(e);return`https://stream.${t}/${r}.m3u8${n}`},z=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return C(o,x)?x[o]:""},V=e=>{let t=e.type;if(t){let n=t.toUpperCase();return C(n,R)?R[n]:t}let{src:r}=e;return r?z(r):""},W=e=>{if([k.LIVE,k.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===k.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},S=new WeakMap,le=e=>{var t;return(t=S.get(e))==null?void 0:t.error},X=(e,t)=>{t&&(t.detachMedia(),t.destroy()),(e==null?void 0:e.mux)&&!e.mux.deleted&&(e.mux.destroy(),e.mux),e&&(e.removeEventListener("error",j),e.removeEventListener("error",N),S.delete(e))},G=(e,t)=>{var E,v,b;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=V(e),s=c===x.M3U8,i=!c||((E=t==null?void 0:t.canPlayType(c))!=null?E:!0),p=T.default.isSupported(),f=((b=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?b:"").toLowerCase().indexOf("android")!==-1;if(s&&!(!s||i&&!((n||f)&&p))&&p){let m={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},l=W(o);return new T.default({debug:r,startPosition:a,...m,...l})}},J=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=new URL(t).hostname.toLocaleLowerCase();return n.includes($)||!!r&&n.includes(r.toLocaleLowerCase())},Q=(e,t,r)=>{let{envKey:n}=e,o=J(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:p,debug:d}=e,y=f=>typeof f.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(f):f;D.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?T.default:void 0,automaticErrorTracking:!1,errorTranslator:y,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...p}})}},Z=(e,t,r)=>{var E,v,b;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=V(e),c=a===x.M3U8,s=!a||((E=t==null?void 0:t.canPlayType(a))!=null?E:!0),i=T.default.isSupported(),y=((b=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?b:"").toLowerCase().indexOf("android")!==-1&&o===k.LL_LIVE,f=!c||s&&!((n||y)&&i),{src:M}=e;if(t&&s&&f){if(typeof M=="string"){let{startTime:m}=e;if(t.setAttribute("src",M),m){let l=({target:A})=>{A.currentTime=m,A.removeEventListener("loadedmetadata",l)};t.addEventListener("loadedmetadata",l)}}else t.removeAttribute("src");t.addEventListener("error",j),t.addEventListener("error",N)}else if(r&&M){switch(r.on(T.default.Events.ERROR,(m,l)=>{let A={[T.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[T.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},I=new u("",A[l.type]);I.fatal=l.fatal,I.data=l,t.dispatchEvent(new CustomEvent("error",{detail:I}))}),t.addEventListener("error",N),q(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(M),{once:!0});break;case"metadata":let m=r.config.maxBufferLength,l=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=m,r.config.maxBufferSize=l},{once:!0}),r.loadSource(M);break;default:r.loadSource(M)}r.attachMedia(t)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function j(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t==null?void 0:t.error))return;let{message:r,code:n}=t.error,o=new u(r,n);if(t.src&&(n!==u.MEDIA_ERR_DECODE||n!==void 0)){let{status:a}=await fetch(t.src);o.data={response:{code:a}}}t.dispatchEvent(new CustomEvent("error",{detail:o}))}function N(e){var o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;if(!r||!r.fatal)return;let n=S.get(t);n&&(n.error=r),(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message})}var ye=(e,t,r)=>{X(t,r),S.set(t,{});let n=G(e,t);return Q(e,t,n),Z(e,t,n),n}; | ||
//# sourceMappingURL=index.cjs.js.map |
{ | ||
"inputs": { | ||
"../../shared/polyfills/window.js": { | ||
"bytes": 2035, | ||
"imports": [] | ||
}, | ||
"../../shared/polyfills/index.mjs": { | ||
"bytes": 204, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/window.js", | ||
"kind": "import-statement" | ||
} | ||
] | ||
}, | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
@@ -51,9 +38,5 @@ "bytes": 105451, | ||
"src/index.ts": { | ||
"bytes": 16504, | ||
"bytes": 16479, | ||
"imports": [ | ||
{ | ||
"path": "../../shared/polyfills/index.mjs", | ||
"kind": "import-statement" | ||
}, | ||
{ | ||
"path": "../../node_modules/mux-embed/dist/mux.js", | ||
@@ -90,3 +73,3 @@ "kind": "import-statement" | ||
"inputs": {}, | ||
"bytes": 1496680 | ||
"bytes": 1493766 | ||
}, | ||
@@ -129,5 +112,2 @@ "dist/playback-core.mjs": { | ||
}, | ||
"../../shared/polyfills/window.js": { | ||
"bytesInOutput": 944 | ||
}, | ||
"src/index.ts": { | ||
@@ -149,5 +129,5 @@ "bytesInOutput": 4618 | ||
}, | ||
"bytes": 473967 | ||
"bytes": 472678 | ||
} | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
import '@mux/polyfills'; | ||
import mux, { Options } from 'mux-embed'; | ||
@@ -3,0 +2,0 @@ import Hls, { HlsConfig } from 'hls.js'; |
@@ -1,2 +0,1 @@ | ||
import '@mux/polyfills'; | ||
import mux, { Options } from 'mux-embed'; | ||
@@ -3,0 +2,0 @@ import Hls, { HlsConfig } from 'hls.js'; |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.9.1-canary.22-cf5ae56", | ||
"version": "0.9.1-canary.23-71d18a4", | ||
"description": "Core library for media playback in the browser shared by mux elements", | ||
@@ -49,3 +49,3 @@ "main": "./dist/index.cjs.js", | ||
"dependencies": { | ||
"@mux/mux-elements-codemod": "1.1.2-canary.23-cf5ae56", | ||
"@mux/mux-elements-codemod": "1.1.2-canary.24-71d18a4", | ||
"hls.js": "1.1.5", | ||
@@ -56,6 +56,6 @@ "mux-embed": "^4.7.0" | ||
"@mux/open-process": "0.1.0", | ||
"@mux/polyfills": "0.1.0", | ||
"downlevel-dts": "^0.9.0", | ||
"esbuild": "^0.13.13", | ||
"npm-run-all": "^4.1.5", | ||
"shared-polyfills": "0.1.0", | ||
"shx": "^0.3.4", | ||
@@ -62,0 +62,0 @@ "typescript": "^4.5.2" |
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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4065840
4355
+ Added@mux/mux-elements-codemod@1.1.2-canary.24-71d18a4(transitive)
- Removed@mux/mux-elements-codemod@1.1.2-canary.23-cf5ae56(transitive)