@mux/mux-uploader
Advanced tools
Comparing version 1.0.1 to 1.0.2-canary.0-1088443
@@ -1,2 +0,2 @@ | ||
"use strict";var G=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var J=(r,o)=>{for(var e in o)G(r,e,{get:o[e],enumerable:!0})},Me=(r,o,e,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Le(o))!ke.call(r,i)&&i!==e&&G(r,i,{get:()=>o[i],enumerable:!(s=Ae(o,i))||s.enumerable});return r};var Ce=r=>Me(G({},"__esModule",{value:!0}),r);var Q=(r,o,e)=>{if(!o.has(r))throw TypeError("Cannot "+e)};var t=(r,o,e)=>(Q(r,o,"read from private field"),e?e.call(r):o.get(r)),u=(r,o,e)=>{if(o.has(r))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(r):o.set(r,e)},d=(r,o,e,s)=>(Q(r,o,"write to private field"),s?s.call(r,e):o.set(r,e),e);var Pe={};J(Pe,{MuxUploaderDropElement:()=>se,MuxUploaderFileSelectElement:()=>ce,MuxUploaderPauseElement:()=>pe,MuxUploaderProgressElement:()=>ie,MuxUploaderRetryElement:()=>ue,MuxUploaderSrTextElement:()=>Ee,MuxUploaderStatusElement:()=>ae,constants:()=>D,default:()=>Re});module.exports=Ce(Pe);var D={};J(D,{ProgressTypes:()=>x});var x={BAR:"bar",RADIAL:"radial",PERCENTAGE:"percentage"};var L=class{addEventListener(){}removeEventListener(){}dispatchEvent(o){return!0}};if(typeof DocumentFragment=="undefined"){class r extends L{}globalThis.DocumentFragment=r}var R=class extends L{},W=class extends L{},Te={get(r){},define(r,o,e){},upgrade(r){},whenDefined(r){return Promise.resolve(R)}},P,q=class{constructor(o,e={}){u(this,P,void 0);d(this,P,e==null?void 0:e.detail)}get detail(){return t(this,P)}initCustomEvent(){}};P=new WeakMap;function we(r,o){return new R}var Z={document:{createElement:we},DocumentFragment,customElements:Te,CustomEvent:q,EventTarget:L,HTMLElement:R,HTMLVideoElement:W},V=typeof window=="undefined"||typeof globalThis.customElements=="undefined",a=V?Z:globalThis,h=V?Z.document:globalThis.document;var me=require("@mux/upchunk");var ee=(r,o)=>{if(!r)return null;let e=r.closest(o);return e||ee(r.getRootNode().host,o)},c=r=>{let o=r.getAttribute("mux-uploader");return o?document.getElementById(o):ee(r,"mux-uploader")};var te=h.createElement("template");te.innerHTML=` | ||
"use strict";var G=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var J=(r,o)=>{for(var e in o)G(r,e,{get:o[e],enumerable:!0})},Me=(r,o,e,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Le(o))!ke.call(r,i)&&i!==e&&G(r,i,{get:()=>o[i],enumerable:!(s=Ae(o,i))||s.enumerable});return r};var Ce=r=>Me(G({},"__esModule",{value:!0}),r);var Q=(r,o,e)=>{if(!o.has(r))throw TypeError("Cannot "+e)};var t=(r,o,e)=>(Q(r,o,"read from private field"),e?e.call(r):o.get(r)),u=(r,o,e)=>{if(o.has(r))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(r):o.set(r,e)},d=(r,o,e,s)=>(Q(r,o,"write to private field"),s?s.call(r,e):o.set(r,e),e);var Pe={};J(Pe,{MuxUploaderDropElement:()=>se,MuxUploaderFileSelectElement:()=>ce,MuxUploaderPauseElement:()=>pe,MuxUploaderProgressElement:()=>ie,MuxUploaderRetryElement:()=>ue,MuxUploaderSrTextElement:()=>Ee,MuxUploaderStatusElement:()=>ae,constants:()=>D,default:()=>Re});module.exports=Ce(Pe);var D={};J(D,{ProgressTypes:()=>x});var x={BAR:"bar",RADIAL:"radial",PERCENTAGE:"percentage"};var L=class{addEventListener(){}removeEventListener(){}dispatchEvent(o){return!0}};if(typeof DocumentFragment=="undefined"){class r extends L{}globalThis.DocumentFragment=r}var R=class extends L{},W=class extends L{},Te={get(r){},define(r,o,e){},getName(r){return null},upgrade(r){},whenDefined(r){return Promise.resolve(R)}},P,q=class{constructor(o,e={}){u(this,P,void 0);d(this,P,e==null?void 0:e.detail)}get detail(){return t(this,P)}initCustomEvent(){}};P=new WeakMap;function we(r,o){return new R}var Z={document:{createElement:we},DocumentFragment,customElements:Te,CustomEvent:q,EventTarget:L,HTMLElement:R,HTMLVideoElement:W},V=typeof window=="undefined"||typeof globalThis.customElements=="undefined",a=V?Z:globalThis,h=V?Z.document:globalThis.document;var me=require("@mux/upchunk");var ee=(r,o)=>{if(!r)return null;let e=r.closest(o);return e||ee(r.getRootNode().host,o)},c=r=>{let o=r.getAttribute("mux-uploader");return o?document.getElementById(o):ee(r,"mux-uploader")};var te=h.createElement("template");te.innerHTML=` | ||
<style> | ||
@@ -3,0 +3,0 @@ :host { |
@@ -1,2 +0,2 @@ | ||
"use strict";(()=>{var Mt=Object.defineProperty;var zt=(e,r)=>{for(var t in r)Mt(e,t,{get:r[t],enumerable:!0})};var Ne=(e,r,t)=>{if(!r.has(e))throw TypeError("Cannot "+t)};var i=(e,r,t)=>(Ne(e,r,"read from private field"),t?t.call(e):r.get(e)),c=(e,r,t)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,t)},f=(e,r,t,n)=>(Ne(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t);var we={};zt(we,{ProgressTypes:()=>F});var F={BAR:"bar",RADIAL:"radial",PERCENTAGE:"percentage"};var H=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class e extends H{}globalThis.DocumentFragment=e}var K=class extends H{},xe=class extends H{},Pt={get(e){},define(e,r,t){},upgrade(e){},whenDefined(e){return Promise.resolve(K)}},Y,Ae=class{constructor(r,t={}){c(this,Y,void 0);f(this,Y,t==null?void 0:t.detail)}get detail(){return i(this,Y)}initCustomEvent(){}};Y=new WeakMap;function Ot(e,r){return new K}var je={document:{createElement:Ot},DocumentFragment,customElements:Pt,CustomEvent:Ae,EventTarget:H,HTMLElement:K,HTMLVideoElement:xe},$e=typeof window=="undefined"||typeof globalThis.customElements=="undefined",d=$e?je:globalThis,v=$e?je.document:globalThis.document;var Ut=Object.create,et=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,tt=Object.getOwnPropertyNames,It=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty,Q=(e,r)=>function(){return r||(0,e[tt(e)[0]])((r={exports:{}}).exports,r),r.exports},Ft=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of tt(r))!Dt.call(e,s)&&s!==t&&et(e,s,{get:()=>r[s],enumerable:!(n=Bt(r,s))||n.enumerable});return e},Ht=(e,r,t)=>(t=e!=null?Ut(It(e)):{},Ft(r||!e||!e.__esModule?et(t,"default",{value:e,enumerable:!0}):t,e)),Nt=Q({"node_modules/global/window.js"(e,r){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},r.exports=t}}),jt=Q({"node_modules/is-function/index.js"(e,r){r.exports=n;var t=Object.prototype.toString;function n(s){if(!s)return!1;var o=t.call(s);return o==="[object Function]"||typeof s=="function"&&o!=="[object RegExp]"||typeof window!="undefined"&&(s===window.setTimeout||s===window.alert||s===window.confirm||s===window.prompt)}}}),$t=Q({"node_modules/parse-headers/parse-headers.js"(e,r){var t=function(s){return s.replace(/^\s+|\s+$/g,"")},n=function(s){return Object.prototype.toString.call(s)==="[object Array]"};r.exports=function(s){if(!s)return{};for(var o={},a=t(s).split(` | ||
"use strict";(()=>{var Mt=Object.defineProperty;var zt=(e,r)=>{for(var t in r)Mt(e,t,{get:r[t],enumerable:!0})};var Ne=(e,r,t)=>{if(!r.has(e))throw TypeError("Cannot "+t)};var i=(e,r,t)=>(Ne(e,r,"read from private field"),t?t.call(e):r.get(e)),c=(e,r,t)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,t)},f=(e,r,t,n)=>(Ne(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t);var we={};zt(we,{ProgressTypes:()=>F});var F={BAR:"bar",RADIAL:"radial",PERCENTAGE:"percentage"};var H=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class e extends H{}globalThis.DocumentFragment=e}var K=class extends H{},xe=class extends H{},Pt={get(e){},define(e,r,t){},getName(e){return null},upgrade(e){},whenDefined(e){return Promise.resolve(K)}},Y,Ae=class{constructor(r,t={}){c(this,Y,void 0);f(this,Y,t==null?void 0:t.detail)}get detail(){return i(this,Y)}initCustomEvent(){}};Y=new WeakMap;function Ot(e,r){return new K}var je={document:{createElement:Ot},DocumentFragment,customElements:Pt,CustomEvent:Ae,EventTarget:H,HTMLElement:K,HTMLVideoElement:xe},$e=typeof window=="undefined"||typeof globalThis.customElements=="undefined",d=$e?je:globalThis,v=$e?je.document:globalThis.document;var Ut=Object.create,et=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,tt=Object.getOwnPropertyNames,It=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty,Q=(e,r)=>function(){return r||(0,e[tt(e)[0]])((r={exports:{}}).exports,r),r.exports},Ft=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of tt(r))!Dt.call(e,s)&&s!==t&&et(e,s,{get:()=>r[s],enumerable:!(n=Bt(r,s))||n.enumerable});return e},Ht=(e,r,t)=>(t=e!=null?Ut(It(e)):{},Ft(r||!e||!e.__esModule?et(t,"default",{value:e,enumerable:!0}):t,e)),Nt=Q({"node_modules/global/window.js"(e,r){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},r.exports=t}}),jt=Q({"node_modules/is-function/index.js"(e,r){r.exports=n;var t=Object.prototype.toString;function n(s){if(!s)return!1;var o=t.call(s);return o==="[object Function]"||typeof s=="function"&&o!=="[object RegExp]"||typeof window!="undefined"&&(s===window.setTimeout||s===window.alert||s===window.confirm||s===window.prompt)}}}),$t=Q({"node_modules/parse-headers/parse-headers.js"(e,r){var t=function(s){return s.replace(/^\s+|\s+$/g,"")},n=function(s){return Object.prototype.toString.call(s)==="[object Array]"};r.exports=function(s){if(!s)return{};for(var o={},a=t(s).split(` | ||
`),u=0;u<a.length;u++){var p=a[u],y=p.indexOf(":"),E=t(p.slice(0,y)).toLowerCase(),S=t(p.slice(y+1));typeof o[E]=="undefined"?o[E]=S:n(o[E])?o[E].push(S):o[E]=[o[E],S]}return o}}}),Wt=Q({"node_modules/xtend/immutable.js"(e,r){r.exports=n;var t=Object.prototype.hasOwnProperty;function n(){for(var s={},o=0;o<arguments.length;o++){var a=arguments[o];for(var u in a)t.call(a,u)&&(s[u]=a[u])}return s}}}),Xt=Q({"node_modules/xhr/index.js"(e,r){"use strict";var t=Nt(),n=jt(),s=$t(),o=Wt();r.exports=y,r.exports.default=y,y.XMLHttpRequest=t.XMLHttpRequest||ye,y.XDomainRequest="withCredentials"in new y.XMLHttpRequest?y.XMLHttpRequest:t.XDomainRequest,a(["get","put","post","patch","head","delete"],function(l){y[l==="delete"?"del":l]=function(k,C,U){return C=p(k,C,U),C.method=l.toUpperCase(),E(C)}});function a(l,k){for(var C=0;C<l.length;C++)k(l[C])}function u(l){for(var k in l)if(l.hasOwnProperty(k))return!1;return!0}function p(l,k,C){var U=l;return n(k)?(C=k,typeof l=="string"&&(U={uri:l})):U=o(k,{uri:l}),U.callback=C,U}function y(l,k,C){return k=p(l,k,C),E(k)}function E(l){if(typeof l.callback=="undefined")throw new Error("callback argument missing");var k=!1,C=function(D,ae,_t){k||(k=!0,l.callback(D,ae,_t))};function U(){h.readyState===4&&setTimeout(De,0)}function Rt(){var g=void 0;if(h.response?g=h.response:g=h.responseText||S(h),Fe)try{g=JSON.parse(g)}catch{}return g}function Ee(g){return clearTimeout(Se),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,C(g,He)}function De(){if(!oe){var g;clearTimeout(Se),l.useXDR&&h.status===void 0?g=200:g=h.status===1223?204:h.status;var D=He,ae=null;return g!==0?(D={body:Rt(),statusCode:g,method:V,headers:{},url:ve,rawRequest:h},h.getAllResponseHeaders&&(D.headers=s(h.getAllResponseHeaders()))):ae=new Error("Internal XMLHttpRequest Error"),C(ae,D,D.body)}}var h=l.xhr||null;h||(l.cors||l.useXDR?h=new y.XDomainRequest:h=new y.XMLHttpRequest);var ie,oe,ve=h.url=l.uri||l.url,V=h.method=l.method||"GET",ke=l.body||l.data,M=h.headers=l.headers||{},Ce=!!l.sync,Fe=!1,Se,He={body:void 0,headers:{},statusCode:0,method:V,url:ve,rawRequest:h};if("json"in l&&l.json!==!1&&(Fe=!0,M.accept||M.Accept||(M.Accept="application/json"),V!=="GET"&&V!=="HEAD"&&(M["content-type"]||M["Content-Type"]||(M["Content-Type"]="application/json"),ke=JSON.stringify(l.json===!0?ke:l.json))),h.onreadystatechange=U,h.onload=De,h.onerror=Ee,h.onprogress=function(){},h.onabort=function(){oe=!0},h.ontimeout=Ee,h.open(V,ve,!Ce,l.username,l.password),Ce||(h.withCredentials=!!l.withCredentials),!Ce&&l.timeout>0&&(Se=setTimeout(function(){if(!oe){oe=!0,h.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",Ee(g)}},l.timeout)),h.setRequestHeader)for(ie in M)M.hasOwnProperty(ie)&&h.setRequestHeader(ie,M[ie]);else if(l.headers&&!u(l.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in l&&(h.responseType=l.responseType),"beforeSend"in l&&typeof l.beforeSend=="function"&&l.beforeSend(h),h.send(ke||null),h}function S(l){try{if(l.responseType==="document")return l.responseXML;var k=l.responseXML&&l.responseXML.documentElement.nodeName==="parsererror";if(l.responseType===""&&!k)return l.responseXML}catch{}return null}function ye(){}}});function ze(e,r,...t){if(!e)throw new TypeError(rt(r,t))}function rt(e,r){let t=0;return e.replace(/%[os]/gu,()=>nt(r[t++]))}function nt(e){return typeof e!="object"||e===null?String(e):Object.prototype.toString.call(e)}var We;function qt(e){try{let r=e instanceof Error?e:new Error(nt(e));if(We){We(r);return}if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:r,message:r.message}));else if(typeof process!="undefined"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)}catch{}}var L=typeof window!="undefined"?window:typeof self!="undefined"?self:typeof global!="undefined"?global:typeof globalThis!="undefined"?globalThis:void 0,Xe,z=class{constructor(e,r){this.code=e,this.message=r}warn(...e){var r;try{if(Xe){Xe({...this,args:e});return}let t=((r=new Error().stack)!==null&&r!==void 0?r:"").replace(/^(?:.+?\n){2}/gu,` | ||
@@ -3,0 +3,0 @@ `);console.warn(this.message,...e,t)}catch{}}},Gt=new z("W01","Unable to initialize event under dispatching."),Vt=new z("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),Kt=new z("W03","Assigning any truthy value to 'returnValue' property has no effect."),Yt=new z("W04","Unable to preventDefault on non-cancelable events."),Zt=new z("W05","Unable to preventDefault inside passive event listener invocation."),Jt=new z("W06","An event listener wasn't added because it has been added already: %o, %o"),Te=new z("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),qe=new z("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),Mr=new z("W09","Event attribute handler must be a function: %o"),P=class{static get NONE(){return Ge}static get CAPTURING_PHASE(){return Ve}static get AT_TARGET(){return Ke}static get BUBBLING_PHASE(){return Ye}constructor(e,r){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let t=r!=null?r:{};Me.set(this,{type:String(e),bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return m(this).type}get target(){return m(this).target}get srcElement(){return m(this).target}get currentTarget(){return m(this).currentTarget}composedPath(){let e=m(this).currentTarget;return e?[e]:[]}get NONE(){return Ge}get CAPTURING_PHASE(){return Ve}get AT_TARGET(){return Ke}get BUBBLING_PHASE(){return Ye}get eventPhase(){return m(this).dispatchFlag?2:0}stopPropagation(){m(this).stopPropagationFlag=!0}get cancelBubble(){return m(this).stopPropagationFlag}set cancelBubble(e){e?m(this).stopPropagationFlag=!0:Vt.warn()}stopImmediatePropagation(){let e=m(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return m(this).bubbles}get cancelable(){return m(this).cancelable}get returnValue(){return!m(this).canceledFlag}set returnValue(e){e?Kt.warn():Ze(m(this))}preventDefault(){Ze(m(this))}get defaultPrevented(){return m(this).canceledFlag}get composed(){return m(this).composed}get isTrusted(){return!1}get timeStamp(){return m(this).timeStamp}initEvent(e,r=!1,t=!1){let n=m(this);if(n.dispatchFlag){Gt.warn();return}Me.set(this,{...n,type:String(e),bubbles:!!r,cancelable:!!t,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},Ge=0,Ve=1,Ke=2,Ye=3,Me=new WeakMap;function m(e,r="this"){let t=Me.get(e);return ze(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",r,e),t}function Ze(e){if(e.inPassiveListenerFlag){Zt.warn();return}if(!e.cancelable){Yt.warn();return}e.canceledFlag=!0}Object.defineProperty(P,"NONE",{enumerable:!0});Object.defineProperty(P,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(P,"AT_TARGET",{enumerable:!0});Object.defineProperty(P,"BUBBLING_PHASE",{enumerable:!0});var Le=Object.getOwnPropertyNames(P.prototype);for(let e=0;e<Le.length;++e)Le[e]!=="constructor"&&Object.defineProperty(P.prototype,Le[e],{enumerable:!0});typeof L!="undefined"&&typeof L.Event!="undefined"&&Object.setPrototypeOf(P.prototype,L.Event.prototype);function Qt(e){return L.DOMException?new L.DOMException(e,"InvalidStateError"):(N==null&&(N=class st extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,st)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(N.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),Qe(N),Qe(N.prototype)),new N(e))}var N,Je={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function Qe(e){let r=Object.keys(Je);for(let t=0;t<r.length;++t){let n=r[t],s=Je[n];Object.defineProperty(e,n,{get(){return s},configurable:!0,enumerable:!0})}}var ue=class extends P{static wrap(e){return new(ot(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),it.set(this,{original:e});let r=Object.keys(e);for(let t=0;t<r.length;++t){let n=r[t];n in this||Object.defineProperty(this,n,at(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=B(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:r}=B(this);"cancelBubble"in r&&(r.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=B(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:r}=B(this);"returnValue"in r&&(r.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=B(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=B(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},it=new WeakMap;function B(e){let r=it.get(e);return ze(r!=null,"'this' is expected an Event object, but got",e),r}var le=new WeakMap;le.set(Object.prototype,ue);typeof L!="undefined"&&typeof L.Event!="undefined"&&le.set(L.Event.prototype,ue);function ot(e){let r=Object.getPrototypeOf(e);if(r==null)return ue;let t=le.get(r);return t==null&&(t=er(ot(r),r),le.set(r,t)),t}function er(e,r){class t extends e{}let n=Object.keys(r);for(let s=0;s<n.length;++s)Object.defineProperty(t.prototype,n[s],at(r,n[s]));return t}function at(e,r){let t=Object.getOwnPropertyDescriptor(e,r);return{get(){let n=B(this).original,s=n[r];return typeof s=="function"?s.bind(n):s},set(n){let s=B(this).original;s[r]=n},configurable:t.configurable,enumerable:t.enumerable}}function tr(e,r,t,n,s,o){return{callback:e,flags:(r?1:0)|(t?2:0)|(n?4:0),signal:s,signalListener:o}}function rr(e){e.flags|=8}function lt(e){return(e.flags&1)===1}function ut(e){return(e.flags&2)===2}function dt(e){return(e.flags&4)===4}function nr(e){return(e.flags&8)===8}function sr({callback:e},r,t){try{typeof e=="function"?e.call(r,t):typeof e.handleEvent=="function"&&e.handleEvent(t)}catch(n){qt(n)}}function ht({listeners:e},r,t){for(let n=0;n<e.length;++n)if(e[n].callback===r&<(e[n])===t)return n;return-1}function ir(e,r,t,n,s,o){let a;o&&(a=pt.bind(null,e,r,t),o.addEventListener("abort",a));let u=tr(r,t,n,s,o,a);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,u]):e.listeners.push(u),u}function pt(e,r,t){let n=ht(e,r,t);return n!==-1?ct(e,n):!1}function ct(e,r,t=!1){let n=e.listeners[r];return rr(n),n.signal&&n.signal.removeEventListener("abort",n.signalListener),e.cow&&!t?(e.cow=!1,e.listeners=e.listeners.filter((s,o)=>o!==r),!1):(e.listeners.splice(r,1),!0)}function or(){return Object.create(null)}function ar(e,r){var t;return(t=e[r])!==null&&t!==void 0?t:e[r]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var de=class{constructor(){ft.set(this,or())}addEventListener(e,r,t){let n=Re(this),{callback:s,capture:o,once:a,passive:u,signal:p,type:y}=lr(e,r,t);if(s==null||p!=null&&p.aborted)return;let E=ar(n,y),S=ht(E,s,o);if(S!==-1){dr(E.listeners[S],u,a,p);return}ir(E,s,o,u,a,p)}removeEventListener(e,r,t){let n=Re(this),{callback:s,capture:o,type:a}=ur(e,r,t),u=n[a];s!=null&&u&&pt(u,s,o)}dispatchEvent(e){let r=Re(this)[String(e.type)];if(r==null)return!0;let t=e instanceof P?e:ue.wrap(e),n=m(t,"event");if(n.dispatchFlag)throw Qt("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:s,listeners:o}=r;r.cow=!0;for(let a=0;a<o.length;++a){let u=o[a];if(!nr(u)&&(dt(u)&&ct(r,a,!s)&&(a-=1),n.inPassiveListenerFlag=ut(u),sr(u,this,t),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}s||(r.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},ft=new WeakMap;function Re(e,r="this"){let t=ft.get(e);return ze(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",r,e),t}function lr(e,r,t){var n;return gt(r),typeof t=="object"&&t!==null?{type:String(e),callback:r!=null?r:void 0,capture:!!t.capture,passive:!!t.passive,once:!!t.once,signal:(n=t.signal)!==null&&n!==void 0?n:void 0}:{type:String(e),callback:r!=null?r:void 0,capture:!!t,passive:!1,once:!1,signal:void 0}}function ur(e,r,t){return gt(r),typeof t=="object"&&t!==null?{type:String(e),callback:r!=null?r:void 0,capture:!!t.capture}:{type:String(e),callback:r!=null?r:void 0,capture:!!t}}function gt(e){if(!(typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.handleEvent=="function")){if(e==null||typeof e=="object"){qe.warn(e);return}throw new TypeError(rt(qe.message,[e]))}}function dr(e,r,t,n){Jt.warn(lt(e)?"capture":"bubble",e.callback),ut(e)!==r&&Te.warn("passive"),dt(e)!==t&&Te.warn("once"),e.signal!==n&&Te.warn("signal")}var _e=Object.getOwnPropertyNames(de.prototype);for(let e=0;e<_e.length;++e)_e[e]!=="constructor"&&Object.defineProperty(de.prototype,_e[e],{enumerable:!0});typeof L!="undefined"&&typeof L.EventTarget!="undefined"&&Object.setPrototypeOf(de.prototype,L.EventTarget.prototype);var hr=Ht(Xt()),Pe=30720,ee=512e3,te=256,Z=(e,{minChunkSize:r=te,maxChunkSize:t=ee}={})=>e==null||typeof e=="number"&&e>=256&&e%256===0&&e>=r&&e<=t,J=(e,{minChunkSize:r=te,maxChunkSize:t=ee}={})=>new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${r} and ${t}`),pr=class{constructor(e,r={}){this.readableStream=e;var t,n,s;if(!Z(r.defaultChunkSize,r))throw J(r.defaultChunkSize,r);this.defaultChunkSize=(t=r.defaultChunkSize)!=null?t:Pe,this.minChunkSize=(n=r.minChunkSize)!=null?n:te,this.maxChunkSize=(s=r.maxChunkSize)!=null?s:ee}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!Z(e,this))throw J(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}get error(){return this._error}async*[Symbol.asyncIterator](){let e,r=this.readableStream.getReader();try{for(;;){let{done:t,value:n}=await r.read();if(t){if(e){let o=e;e=void 0,yield o}break}let s=n instanceof Uint8Array?new Blob([n],{type:"application/octet-stream"}):n;for(e=e?new Blob([e,s]):s;e;)if(e.size===this.chunkByteSize){let o=e;e=void 0,yield o;break}else{if(e.size<this.chunkByteSize)break;{let o=e.slice(0,this.chunkByteSize);e=e.slice(this.chunkByteSize),yield o}}}}catch(t){this._error=t}finally{if(e){let t=e;e=void 0,yield t}r.releaseLock();return}}},cr=class{constructor(e,r={}){this.file=e;var t,n,s;if(!Z(r.defaultChunkSize,r))throw J(r.defaultChunkSize,r);this.defaultChunkSize=(t=r.defaultChunkSize)!=null?t:Pe,this.minChunkSize=(n=r.minChunkSize)!=null?n:te,this.maxChunkSize=(s=r.maxChunkSize)!=null?s:ee}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!Z(e,this))throw J(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}get error(){return this._error}async*[Symbol.asyncIterator](){let e=new FileReader,r=0,t=()=>new Promise(n=>{if(r>=this.file.size){n(void 0);return}let s=Math.min(this.chunkByteSize,this.file.size-r);e.onload=()=>{e.result!==null?n(new Blob([e.result],{type:"application/octet-stream"})):n(void 0)},e.readAsArrayBuffer(this.file.slice(r,r+s))});try{for(;;){let n=await t();if(n)r+=n.size,yield n;else break}}catch(n){this._error=n}}},fr=[200,201,202,204,308],mt=[408,502,503,504],gr=[308],bt=(e,r)=>!!e&&fr.includes(e.statusCode),mr=(e,{retryCodes:r=mt})=>!e||r.includes(e.statusCode),br=(e,r)=>r.attemptCount>=r.attempts||!(bt(e)||mr(e,r)),yr=(e,r)=>{var t;if(!e||!gr.includes(e.statusCode)||!((t=e.headers)!=null&&t.range))return!1;let n=e.headers.range.match(/bytes=(\d+)-(\d+)/);return n?parseInt(n[2],10)!==r.currentChunkEndByte:!1},Oe=class{static createUpload(e){return new Oe(e)}constructor(e){if(this.eventTarget=new de,this.endpoint=e.endpoint,this.file=e.file,this.headers=e.headers||{},this.method=e.method||"PUT",this.attempts=e.attempts||5,this.delayBeforeAttempt=e.delayBeforeAttempt||1,this.retryCodes=e.retryCodes||mt,this.dynamicChunkSize=e.dynamicChunkSize||!1,this.maxFileBytes=(e.maxFileSize||0)*1024,this.chunkCount=0,this.attemptCount=0,this._offline=typeof window!="undefined"&&!window.navigator.onLine,this._paused=!1,this.success=!1,this.nextChunkRangeStart=0,e.useLargeFileWorkaround){let r=t=>{this.chunkedIterable.error&&(console.warn(`Unable to read file of size ${this.file.size} bytes via a ReadableStream. Falling back to in-memory FileReader!`),t.stopImmediatePropagation(),this.chunkedIterable=new cr(this.file,{...e,defaultChunkSize:e.chunkSize}),this.chunkedIterator=this.chunkedIterable[Symbol.asyncIterator](),this.getEndpoint().then(()=>{this.sendChunks()}),this.off("error",r))};this.on("error",r)}this.chunkedIterable=new pr(this.file.stream(),{...e,defaultChunkSize:e.chunkSize}),this.chunkedIterator=this.chunkedIterable[Symbol.asyncIterator](),this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.validateOptions(),this.getEndpoint().then(()=>this.sendChunks()),typeof window!="undefined"&&(window.addEventListener("online",()=>{this.offline&&(this._offline=!1,this.dispatch("online"),this.sendChunks())}),window.addEventListener("offline",()=>{this.offline||(this._offline=!0,this.dispatch("offline"))}))}get maxChunkSize(){var e,r;return(r=(e=this.chunkedIterable)==null?void 0:e.maxChunkSize)!=null?r:ee}get minChunkSize(){var e,r;return(r=(e=this.chunkedIterable)==null?void 0:e.minChunkSize)!=null?r:te}get chunkSize(){var e,r;return(r=(e=this.chunkedIterable)==null?void 0:e.chunkSize)!=null?r:Pe}set chunkSize(e){this.chunkedIterable.chunkSize=e}get chunkByteSize(){return this.chunkedIterable.chunkByteSize}get totalChunkSize(){return Math.ceil(this.file.size/this.chunkByteSize)}on(e,r){this.eventTarget.addEventListener(e,r)}once(e,r){this.eventTarget.addEventListener(e,r,{once:!0})}off(e,r){this.eventTarget.removeEventListener(e,r)}get offline(){return this._offline}get paused(){return this._paused}abort(){var e;this.pause(),(e=this.currentXhr)==null||e.abort()}pause(){this._paused=!0}resume(){this._paused&&(this._paused=!1,this.sendChunks())}get successfulPercentage(){return this.nextChunkRangeStart/this.file.size}dispatch(e,r){let t=new CustomEvent(e,{detail:r});this.eventTarget.dispatchEvent(t)}validateOptions(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="function"&&typeof this.headers!="object")throw new TypeError("headers must be null, an object, or a function that returns an object or a promise");if(!Z(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize}))throw J(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize});if(this.maxChunkSize&&(typeof this.maxChunkSize!="number"||this.maxChunkSize<256||this.maxChunkSize%256!==0||this.maxChunkSize<this.chunkSize||this.maxChunkSize<this.minChunkSize))throw new TypeError(`maxChunkSize must be a positive number in multiples of 256, and larger than or equal to both ${this.minChunkSize} and ${this.chunkSize}`);if(this.minChunkSize&&(typeof this.minChunkSize!="number"||this.minChunkSize<256||this.minChunkSize%256!==0||this.minChunkSize>this.chunkSize||this.minChunkSize>this.maxChunkSize))throw new TypeError(`minChunkSize must be a positive number in multiples of 256, and smaller than ${this.chunkSize} and ${this.maxChunkSize}`);if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error(`file size exceeds maximum (${this.file.size} > ${this.maxFileBytes})`);if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")}getEndpoint(){return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(e=>(this.endpointValue=e,this.endpointValue))}xhrPromise(e){let r=t=>{t.upload.onprogress=n=>{var s;let o=this.totalChunks-this.chunkCount,a=(this.file.size-this.nextChunkRangeStart)/this.file.size/o,p=n.loaded/((s=n.total)!=null?s:this.chunkByteSize)*a;this.dispatch("progress",Math.min((this.successfulPercentage+p)*100,100))}};return new Promise((t,n)=>{this.currentXhr=(0,hr.default)({...e,beforeSend:r},(s,o)=>(this.currentXhr=void 0,s?n(s):t(o)))})}async sendChunk(e){let r=this.nextChunkRangeStart,t=r+e.size-1,s={...await(typeof this.headers=="function"?this.headers():this.headers),"Content-Type":this.file.type,"Content-Range":`bytes ${r}-${t}/${this.file.size}`};return this.dispatch("attempt",{chunkNumber:this.chunkCount,totalChunks:this.totalChunks,chunkSize:this.chunkSize}),this.xhrPromise({headers:s,url:this.endpointValue,method:this.method,body:e})}async sendChunkWithRetries(e){let r=async(a,u)=>{var p;let E=(new Date().getTime()-this.lastChunkStart.getTime())/1e3;if(this.dispatch("chunkSuccess",{chunk:this.chunkCount,chunkSize:this.chunkSize,attempts:this.attemptCount,timeInterval:E,response:a}),this.attemptCount=0,this.chunkCount=((p=this.chunkCount)!=null?p:0)+1,this.nextChunkRangeStart=this.nextChunkRangeStart+this.chunkByteSize,this.dynamicChunkSize){let S=this.chunkSize;E<10?S=Math.min(this.chunkSize*2,this.maxChunkSize):E>30&&(S=Math.max(this.chunkSize/2,this.minChunkSize)),this.chunkSize=Math.ceil(S/256)*256;let ye=(this.file.size-this.nextChunkRangeStart)/this.chunkByteSize;this.totalChunks=Math.ceil(this.chunkCount+ye)}return!0},t=async(a,u)=>(this.dispatch("progress",Math.min(this.successfulPercentage*100,100)),this.dispatch("error",{message:`Server responded with ${a.statusCode}. Stopping upload.`,chunk:this.chunkCount,attempts:this.attemptCount,response:a}),!1),n=async(a,u)=>(this.dispatch("attemptFailure",{message:`An error occured uploading chunk ${this.chunkCount}. ${this.attempts-this.attemptCount} retries left.`,chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount,response:a}),new Promise(p=>{setTimeout(async()=>{if(this._paused||this.offline){this.pendingChunk=e,p(!1);return}let y=await this.sendChunkWithRetries(e);p(y)},this.delayBeforeAttempt*1e3)})),s;try{this.attemptCount=this.attemptCount+1,this.lastChunkStart=new Date,s=await this.sendChunk(e)}catch(a){typeof(a==null?void 0:a.statusCode)=="number"&&(s=a)}let o={retryCodes:this.retryCodes,attemptCount:this.attemptCount,attempts:this.attempts,currentChunkEndByte:this.nextChunkRangeStart+e.size-1};return yr(s,o)?n(s,e):bt(s,o)?r(s,e):br(s,o)?t(s,e):n(s,e)}async sendChunks(){if(this.pendingChunk&&!(this._paused||this.offline)){let e=this.pendingChunk;this.pendingChunk=void 0;let r=await this.sendChunkWithRetries(e);this.success&&r&&this.dispatch("success")}for(;!(this.success||this._paused||this.offline);){let{value:e,done:r}=await this.chunkedIterator.next(),t=!e&&r;if(e&&(t=await this.sendChunkWithRetries(e)),this.chunkedIterable.error){t=!1,this.dispatch("error",{message:`Unable to read file of size ${this.file.size} bytes. Try loading from another browser.`});return}if(this.success=!!r,this.success&&t&&this.dispatch("success"),!t)return}}};var yt=(e,r)=>{if(!e)return null;let t=e.closest(r);return t||yt(e.getRootNode().host,r)},w=e=>{let r=e.getAttribute("mux-uploader");return r?document.getElementById(r):yt(e,"mux-uploader")};var Et=v.createElement("template");Et.innerHTML=` |
@@ -10,3 +10,3 @@ import { globalThis } from './polyfills'; | ||
clearStatusMessage: () => void; | ||
onUploadError: (e: MuxUploaderElementEventMap['uploaderror']) => void; | ||
onUploadError: (e: MuxUploaderElementEventMap["uploaderror"]) => void; | ||
onSuccess: () => void; | ||
@@ -13,0 +13,0 @@ onOffline: () => void; |
@@ -10,3 +10,3 @@ import { globalThis } from './polyfills'; | ||
clearStatusMessage: () => void; | ||
onUploadError: (e: MuxUploaderElementEventMap['uploaderror']) => void; | ||
onUploadError: (e: MuxUploaderElementEventMap["uploaderror"]) => void; | ||
onSuccess: () => void; | ||
@@ -13,0 +13,0 @@ onOffline: () => void; |
{ | ||
"name": "@mux/mux-uploader", | ||
"version": "1.0.1", | ||
"version": "1.0.2-canary.0-1088443", | ||
"description": "An uploader elements to be used with Mux Direct Uploads", | ||
@@ -76,2 +76,3 @@ "keywords": [ | ||
"@web/dev-server-import-maps": "^0.2.1", | ||
"@web/test-runner": "^0.18.2", | ||
"copyfiles": "^2.4.1", | ||
@@ -84,5 +85,4 @@ "downlevel-dts": "^0.11.0", | ||
"sinon": "^15.0.1", | ||
"typescript": "^4.9.4" | ||
}, | ||
"gitHead": "31bf5057d37d4e57b630012fc09d52daedb2973a" | ||
"typescript": "^5.5.4" | ||
} | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
785314
44
3479
12
3