UNPKG

@vime/core

Version:

Customizable, extensible, accessible and framework agnostic media player.

1 lines 12.1 kB
let e,t,l,n=!1,o=!1,s=!1,i=null,c=!1;const r="undefined"!=typeof window?window:{},f=r.document||{head:{}},a={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,l,n)=>e.addEventListener(t,l,n),rel:(e,t,l,n)=>e.removeEventListener(t,l,n),ce:(e,t)=>new CustomEvent(e,t)},u=e=>Promise.resolve(e),d=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),$=(e,t,l)=>{l&&l.map((([l,n,o])=>{const s=p(e,l),i=y(t,o),c=m(l);a.ael(s,n,i,c),(t.o=t.o||[]).push((()=>a.rel(s,n,i,c)))}))},y=(e,t)=>l=>{try{256&e.t?e.i[t](l):(e.u=e.u||[]).push([t,l])}catch(e){ye(e)}},p=(e,t)=>8&t?r:e,m=e=>0!=(2&e),h="http://www.w3.org/1999/xlink",b=new WeakMap,w=e=>"sc-"+e.$,v={},k=e=>"object"==(e=typeof e)||"function"===e,g=(e,t,...l)=>{let n=null,o=null,s=null,i=!1,c=!1,r=[];const f=t=>{for(let l=0;l<t.length;l++)n=t[l],Array.isArray(n)?f(n):null!=n&&"boolean"!=typeof n&&((i="function"!=typeof e&&!k(n))&&(n+=""),i&&c?r[r.length-1].p+=n:r.push(i?S(null,n):n),c=i)};if(f(l),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,r,C);const a=S(e,null);return a.m=t,r.length>0&&(a.h=r),a.v=o,a.k=s,a},S=(e,t)=>({t:0,g:e,p:t,S:null,h:null,m:null,v:null,k:null}),j={},C={forEach:(e,t)=>e.map(M).forEach(t),map:(e,t)=>e.map(M).map(t).map(O)},M=e=>({vattrs:e.m,vchildren:e.h,vkey:e.v,vname:e.k,vtag:e.g,vtext:e.p}),O=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),g(e.vtag,t,...e.vchildren||[])}const t=S(e.vtag,e.vtext);return t.m=e.vattrs,t.h=e.vchildren,t.v=e.vkey,t.k=e.vname,t},x=(e,t,l,n,o,s)=>{if(l!==n){let i=$e(e,t),c=t.toLowerCase();if("class"===t){const t=e.classList,o=P(l),s=P(n);t.remove(...o.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===t){for(const t in l)n&&null!=n[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in n)l&&n[t]===l[t]||(t.includes("-")?e.style.setProperty(t,n[t]):e.style[t]=n[t])}else if("key"===t);else if("ref"===t)n&&n(e);else if(i||"o"!==t[0]||"n"!==t[1]){const r=k(n);if((i||r&&null!==n)&&!o)try{if(e.tagName.includes("-"))e[t]=n;else{let o=null==n?"":n;"list"===t?i=!1:null!=l&&e[t]==o||(e[t]=o)}}catch(e){}let f=!1;c!==(c=c.replace(/^xlink\:?/,""))&&(t=c,f=!0),null==n||!1===n?!1===n&&""!==e.getAttribute(t)||(f?e.removeAttributeNS(h,t):e.removeAttribute(t)):(!i||4&s||o)&&!r&&(n=!0===n?"":n,f?e.setAttributeNS(h,t,n):e.setAttribute(t,n))}else t="-"===t[2]?t.slice(3):$e(r,c)?c.slice(2):c[2]+t.slice(3),l&&a.rel(e,t,l,!1),n&&a.ael(e,t,n,!1)}},R=/\s/,P=e=>e?e.split(R):[],T=(e,t,l,n)=>{const o=11===t.S.nodeType&&t.S.host?t.S.host:t.S,s=e&&e.m||v,i=t.m||v;for(n in s)n in i||x(o,n,s[n],void 0,l,t.t);for(n in i)x(o,n,s[n],i[n],l,t.t)},E=(o,i,c,r)=>{let a,u,d,$=i.h[c],y=0;if(n||(s=!0,"slot"===$.g&&(e&&r.classList.add(e+"-s"),$.t|=$.h?2:1)),null!==$.p)a=$.S=f.createTextNode($.p);else if(1&$.t)a=$.S=f.createTextNode("");else if(a=$.S=f.createElement(2&$.t?"slot-fb":$.g),T(null,$,!1),null!=e&&a["s-si"]!==e&&a.classList.add(a["s-si"]=e),$.h)for(y=0;y<$.h.length;++y)u=E(o,$,y,a),u&&a.appendChild(u);return a["s-hn"]=l,3&$.t&&(a["s-sr"]=!0,a["s-cr"]=t,a["s-sn"]=$.k||"",d=o&&o.h&&o.h[c],d&&d.g===$.g&&o.S&&L(o.S,!1)),a},L=(e,t)=>{a.t|=1;const n=e.childNodes;for(let e=n.length-1;e>=0;e--){const o=n[e];o["s-hn"]!==l&&o["s-ol"]&&(H(o).insertBefore(o,D(o)),o["s-ol"].remove(),o["s-ol"]=void 0,s=!0),t&&L(o,t)}a.t&=-2},F=(e,t,n,o,s,i)=>{let c,r=e["s-cr"]&&e["s-cr"].parentNode||e;for(r.shadowRoot&&r.tagName===l&&(r=r.shadowRoot);s<=i;++s)o[s]&&(c=E(null,n,s,e),c&&(o[s].S=c,r.insertBefore(c,D(t))))},W=(e,t,l,n,s)=>{for(;t<=l;++t)(n=e[t])&&(s=n.S,z(n),o=!0,s["s-ol"]?s["s-ol"].remove():L(s,!0),s.remove())},A=(e,t)=>e.g===t.g&&("slot"===e.g?e.k===t.k:e.v===t.v),D=e=>e&&e["s-ol"]||e,H=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,N=(e,t)=>{const l=t.S=e.S,n=e.h,o=t.h,s=t.p;let i;null===s?("slot"===t.g||T(e,t,!1),null!==n&&null!==o?((e,t,l,n)=>{let o,s,i=0,c=0,r=0,f=0,a=t.length-1,u=t[0],d=t[a],$=n.length-1,y=n[0],p=n[$];for(;i<=a&&c<=$;)if(null==u)u=t[++i];else if(null==d)d=t[--a];else if(null==y)y=n[++c];else if(null==p)p=n[--$];else if(A(u,y))N(u,y),u=t[++i],y=n[++c];else if(A(d,p))N(d,p),d=t[--a],p=n[--$];else if(A(u,p))"slot"!==u.g&&"slot"!==p.g||L(u.S.parentNode,!1),N(u,p),e.insertBefore(u.S,d.S.nextSibling),u=t[++i],p=n[--$];else if(A(d,y))"slot"!==u.g&&"slot"!==p.g||L(d.S.parentNode,!1),N(d,y),e.insertBefore(d.S,u.S),d=t[--a],y=n[++c];else{for(r=-1,f=i;f<=a;++f)if(t[f]&&null!==t[f].v&&t[f].v===y.v){r=f;break}r>=0?(s=t[r],s.g!==y.g?o=E(t&&t[c],l,r,e):(N(s,y),t[r]=void 0,o=s.S),y=n[++c]):(o=E(t&&t[c],l,c,e),y=n[++c]),o&&H(u.S).insertBefore(o,D(u.S))}i>a?F(e,null==n[$+1]?null:n[$+1].S,l,n,c,$):c>$&&W(t,i,a)})(l,n,t,o):null!==o?(null!==e.p&&(l.textContent=""),F(l,null,t,o,0,o.length-1)):null!==n&&W(n,0,n.length-1)):(i=l["s-cr"])?i.parentNode.textContent=s:e.p!==s&&(l.data=s)},U=e=>{let t,l,n,o,s,i,c=e.childNodes;for(l=0,n=c.length;l<n;l++)if(t=c[l],1===t.nodeType){if(t["s-sr"])for(s=t["s-sn"],t.hidden=!1,o=0;o<n;o++)if(i=c[o].nodeType,c[o]["s-hn"]!==t["s-hn"]||""!==s){if(1===i&&s===c[o].getAttribute("slot")){t.hidden=!0;break}}else if(1===i||3===i&&""!==c[o].textContent.trim()){t.hidden=!0;break}U(t)}},q=[],V=e=>{let t,l,n,s,i,c,r=0,f=e.childNodes,a=f.length;for(;r<a;r++){if(t=f[r],t["s-sr"]&&(l=t["s-cr"])&&l.parentNode)for(n=l.parentNode.childNodes,s=t["s-sn"],c=n.length-1;c>=0;c--)l=n[c],l["s-cn"]||l["s-nr"]||l["s-hn"]===t["s-hn"]||(_(l,s)?(i=q.find((e=>e.j===l)),o=!0,l["s-sn"]=l["s-sn"]||s,i?i.C=t:q.push({C:t,j:l}),l["s-sr"]&&q.map((e=>{_(e.j,l["s-sn"])&&(i=q.find((e=>e.j===l)),i&&!e.C&&(e.C=i.C))}))):q.some((e=>e.j===l))||q.push({j:l}));1===t.nodeType&&V(t)}},_=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,z=e=>{e.m&&e.m.ref&&e.m.ref(null),e.h&&e.h.map(z)},B=e=>ae(e).M,G=(e,t,l)=>{const n=B(e);return{emit:e=>I(n,t,{bubbles:!!(4&l),composed:!!(2&l),cancelable:!!(1&l),detail:e})}},I=(e,t,l)=>{const n=a.ce(t,l);return e.dispatchEvent(n),n},J=(e,t)=>{t&&!e.O&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.O=t)))},K=(e,t)=>{if(e.t|=16,!(4&e.t))return J(e,e.R),je((()=>Q(e,t)));e.t|=512},Q=(e,t)=>{const l=e.i;let n;return t&&(e.t|=256,e.u&&(e.u.map((([e,t])=>le(l,e,t))),e.u=null),n=le(l,"componentWillLoad")),ne(n,(()=>X(e,l,t)))},X=async(e,t,l)=>{const n=e.M,o=n["s-rc"];l&&(e=>{const t=e.P,l=e.M,n=t.t,o=((e,t)=>{let l=w(t),n=he.get(l);if(e=11===e.nodeType?e:f,n)if("string"==typeof n){let t,o=b.get(e=e.head||e);o||b.set(e,o=new Set),o.has(l)||(t=f.createElement("style"),t.innerHTML=n,e.insertBefore(t,e.querySelector("link")),o&&o.add(l))}else e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]);return l})(l.shadowRoot?l.shadowRoot:l.getRootNode(),t);10&n&&(l["s-sc"]=o,l.classList.add(o+"-h"),2&n&&l.classList.add(o+"-s"))})(e);Y(e,t),o&&(o.map((e=>e())),n["s-rc"]=void 0);{const t=n["s-p"],l=()=>ee(e);0===t.length?l():(Promise.all(t).then(l),e.t|=4,t.length=0)}},Y=(c,r)=>{try{i=r,r=r.render&&r.render(),c.t&=-17,c.t|=2,((i,c)=>{const r=i.M,u=i.P,d=i.T||S(null,null),$=(e=>e&&e.g===j)(c)?c:g(null,null,c);if(l=r.tagName,u.L&&($.m=$.m||{},u.L.map((([e,t])=>$.m[t]=r[e]))),$.g=null,$.t|=4,i.T=$,$.S=d.S=r.shadowRoot||r,e=r["s-sc"],t=r["s-cr"],n=0!=(1&u.t),o=!1,N(d,$),a.t|=1,s){let e,t,l,n,o,s;V($.S);let i=0;for(;i<q.length;i++)e=q[i],t=e.j,t["s-ol"]||(l=f.createTextNode(""),l["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=l,t));for(i=0;i<q.length;i++)if(e=q[i],t=e.j,e.C){for(n=e.C.parentNode,o=e.C.nextSibling,l=t["s-ol"];l=l.previousSibling;)if(s=l["s-nr"],s&&s["s-sn"]===t["s-sn"]&&n===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&n!==t.parentNode||t.nextSibling!==o)&&t!==o&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),n.insertBefore(t,o))}else 1===t.nodeType&&(t.hidden=!0)}o&&U($.S),a.t&=-2,q.length=0})(c,r)}catch(e){ye(e,c.M)}return i=null,null},Z=()=>i,ee=e=>{const t=e.M,l=e.i,n=e.R;le(l,"componentDidRender"),64&e.t||(e.t|=64,oe(t),le(l,"componentDidLoad"),e.F(t),n||te()),e.W(t),e.O&&(e.O(),e.O=void 0),512&e.t&&Se((()=>K(e,!1))),e.t&=-517},te=()=>{oe(f.documentElement),Se((()=>I(r,"appload",{detail:{namespace:"vime"}})))},le=(e,t,l)=>{if(e&&e[t])try{return e[t](l)}catch(e){ye(e)}},ne=(e,t)=>e&&e.then?e.then(t):t(),oe=e=>e.classList.add("hydrated"),se=(e,t,l)=>{if(t.A){e.watchers&&(t.D=e.watchers);const n=Object.entries(t.A),o=e.prototype;if(n.map((([e,[n]])=>{31&n||2&l&&32&n?Object.defineProperty(o,e,{get(){return((e,t)=>ae(this).H.get(t))(0,e)},set(l){((e,t,l,n)=>{const o=ae(e),s=o.M,i=o.H.get(t),c=o.t,r=o.i;if(l=((e,t)=>null==e||k(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(l,n.A[t][0]),!(8&c&&void 0!==i||l===i)&&(o.H.set(t,l),r)){if(n.D&&128&c){const e=n.D[t];e&&e.map((e=>{try{r[e](l,i,t)}catch(e){ye(e,s)}}))}2==(18&c)&&K(o,!1)}})(this,e,l,t)},configurable:!0,enumerable:!0}):1&l&&64&n&&Object.defineProperty(o,e,{value(...t){const l=ae(this);return l.N.then((()=>l.i[e](...t)))}})})),1&l){const l=new Map;o.attributeChangedCallback=function(e,t,n){a.jmp((()=>{const t=l.get(e);this[t]=(null!==n||"boolean"!=typeof this[t])&&n}))},e.observedAttributes=n.filter((([e,t])=>15&t[0])).map((([e,n])=>{const o=n[1]||e;return l.set(o,e),512&n[0]&&t.L.push([e,o]),o}))}}return e},ie=e=>{le(e,"connectedCallback")},ce=(e,t={})=>{const l=[],n=t.exclude||[],o=r.customElements,s=f.head,i=s.querySelector("meta[charset]"),c=f.createElement("style"),u=[];let y,p=!0;Object.assign(a,t),a.l=new URL(t.resourcesUrl||"./",f.baseURI).href,e.map((e=>e[1].map((t=>{const s={t:t[0],$:t[1],A:t[2],U:t[3]};s.A=t[2],s.U=t[3],s.L=[],s.D={};const i=s.$,c=class extends HTMLElement{constructor(e){super(e),de(e=this,s),1&s.t&&e.attachShadow({mode:"open"})}connectedCallback(){y&&(clearTimeout(y),y=null),p?u.push(this):a.jmp((()=>(e=>{if(0==(1&a.t)){const t=ae(e),l=t.P,n=()=>{};if(1&t.t)$(e,t,l.U),ie(t.i);else{t.t|=1,12&l.t&&(e=>{const t=e["s-cr"]=f.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)})(e);{let l=e;for(;l=l.parentNode||l.host;)if(l["s-p"]){J(t,t.R=l);break}}l.A&&Object.entries(l.A).map((([t,[l]])=>{if(31&l&&e.hasOwnProperty(t)){const l=e[t];delete e[t],e[t]=l}})),(async(e,t,l,n,o)=>{if(0==(32&t.t)){{if(t.t|=32,(o=me(l)).then){const e=()=>{};o=await o,e()}o.isProxied||(l.D=o.watchers,se(o,l,2),o.isProxied=!0);const e=()=>{};t.t|=8;try{new o(t)}catch(e){ye(e)}t.t&=-9,t.t|=128,e(),ie(t.i)}if(o.style){let e=o.style;const t=w(l);if(!he.has(t)){const n=()=>{};((e,t,l)=>{let n=he.get(e);d&&l?(n=n||new CSSStyleSheet,n.replace(t)):n=t,he.set(e,n)})(t,e,!!(1&l.t)),n()}}}const s=t.R,i=()=>K(t,!0);s&&s["s-rc"]?s["s-rc"].push(i):i()})(0,t,l)}n()}})(this)))}disconnectedCallback(){a.jmp((()=>(()=>{if(0==(1&a.t)){const e=ae(this),t=e.i;e.o&&(e.o.map((e=>e())),e.o=void 0),le(t,"disconnectedCallback")}})()))}componentOnReady(){return ae(this).q}};s.V=e[0],n.includes(i)||o.get(i)||(l.push(i),o.define(i,se(c,s,1)))})))),c.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",c.setAttribute("data-styles",""),s.insertBefore(c,i?i.nextSibling:s.firstChild),p=!1,u.length?u.map((e=>e.connectedCallback())):a.jmp((()=>y=setTimeout(te,30)))},re=(e,t)=>t,fe=new WeakMap,ae=e=>fe.get(e),ue=(e,t)=>fe.set(t.i=e,t),de=(e,t)=>{const l={t:0,M:e,P:t,H:new Map};return l.N=new Promise((e=>l.W=e)),l.q=new Promise((e=>l.F=e)),e["s-p"]=[],e["s-rc"]=[],$(e,l,t.U),fe.set(e,l)},$e=(e,t)=>t in e,ye=(e,t)=>(0,console.error)(e,t),pe=new Map,me=e=>{const t=e.$.replace(/-/g,"_"),l=e.V,n=pe.get(l);return n?n[t]:import(`./${l}.entry.js`).then((e=>(pe.set(l,e),e[t])),ye)},he=new Map,be=[],we=[],ve=(e,t)=>l=>{e.push(l),c||(c=!0,t&&4&a.t?Se(ge):a.raf(ge))},ke=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){ye(e)}e.length=0},ge=()=>{ke(be),ke(we),(c=be.length>0)&&a.raf(ge)},Se=e=>u().then(e),je=ve(we,!0);export{re as F,j as H,Z as a,ce as b,G as c,B as g,g as h,u as p,ue as r,je as w}