Socket
Socket
Sign inDemoInstall

@mux/upchunk

Package Overview
Dependencies
Maintainers
37
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mux/upchunk - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

2

dist/upchunk.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UpChunk=t():e.UpChunk=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};t.__esModule=!0,t.createUpload=t.UpChunk=void 0;var o=n(1),i=n(2),s=[200,201,202,204,308],u=[408,502,503,504],a=function(){function e(e){var t=this;this.endpoint=e.endpoint,this.file=e.file,this.headers=e.headers||{},this.method=e.method||"PUT",this.chunkSize=e.chunkSize||30720,this.attempts=e.attempts||5,this.delayBeforeAttempt=e.delayBeforeAttempt||1,this.maxFileBytes=1024*(e.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new o.EventTarget,this.validateOptions(),this.getEndpoint().then((function(){return t.sendChunks()})),"undefined"!=typeof window&&(window.addEventListener("online",(function(){t.offline&&(t.offline=!1,t.dispatch("online"),t.sendChunks())})),window.addEventListener("offline",(function(){t.offline=!0,t.dispatch("offline")})))}return e.prototype.on=function(e,t){this.eventTarget.addEventListener(e,t)},e.prototype.abort=function(){var e;this.pause(),null===(e=this.currentXhr)||void 0===e||e.abort()},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},e.prototype.dispatch=function(e,t){var n=new CustomEvent(e,{detail:t});this.eventTarget.dispatchEvent(n)},e.prototype.validateOptions=function(){if(!this.endpoint||"function"!=typeof this.endpoint&&"string"!=typeof this.endpoint)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&&"object"!=typeof this.headers)throw new TypeError("headers must be null or an object");if(this.chunkSize&&("number"!=typeof this.chunkSize||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum ("+this.file.size+" > "+this.maxFileBytes+")");if(this.attempts&&("number"!=typeof this.attempts||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&("number"!=typeof this.delayBeforeAttempt||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},e.prototype.getEndpoint=function(){var e=this;return"string"==typeof this.endpoint?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then((function(t){return e.endpointValue=t,e.endpointValue}))},e.prototype.getChunk=function(){var e=this;return new Promise((function(t){var n=1===e.totalChunks?e.file.size:e.chunkByteSize,r=n*e.chunkCount;e.reader.onload=function(){null!==e.reader.result&&(e.chunk=new Blob([e.reader.result],{type:"application/octet-stream"})),t()},e.reader.readAsArrayBuffer(e.file.slice(r,r+n))}))},e.prototype.xhrPromise=function(e){var t=this,n=function(e){e.upload.onprogress=function(e){var n,r=100/t.totalChunks,o=r*t.file.size,i=r*t.chunkCount,s=e.loaded/(null!==(n=e.total)&&void 0!==n?n:o)*r;t.dispatch("progress",Math.min(i+s,100))}};return new Promise((function(o,s){t.currentXhr=i.default(r(r({},e),{beforeSend:n}),(function(e,n){return t.currentXhr=void 0,e?s(e):o(n)}))}))},e.prototype.sendChunk=function(){var e=this.chunkCount*this.chunkByteSize,t=e+this.chunk.size-1,n=r(r({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes "+e+"-"+t+"/"+this.file.size});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:n,url:this.endpointValue,method:this.method,body:this.chunk})},e.prototype.manageRetries=function(){var e=this;if(this.attemptCount<this.attempts)return setTimeout((function(){return e.sendChunks()}),1e3*this.delayBeforeAttempt),void 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});this.dispatch("error",{message:"An error occured uploading chunk "+this.chunkCount+". No more retries, stopping upload",chunk:this.chunkCount,attempts:this.attemptCount})},e.prototype.sendChunks=function(){var e=this;this.paused||this.offline||this.success||this.getChunk().then((function(){return e.attemptCount=e.attemptCount+1,e.sendChunk()})).then((function(t){if(s.includes(t.statusCode)){e.dispatch("chunkSuccess",{chunk:e.chunkCount,attempts:e.attemptCount,response:t}),e.attemptCount=0,e.chunkCount=e.chunkCount+1,e.chunkCount<e.totalChunks?e.sendChunks():(e.success=!0,e.dispatch("success"));var n=100*(e.chunkCount/e.totalChunks*e.file.size)/e.file.size;e.dispatch("progress",n)}else if(u.includes(t.statusCode)){if(e.paused||e.offline)return;e.manageRetries()}else{if(e.paused||e.offline)return;e.dispatch("error",{message:"Server responded with "+t.statusCode+". Stopping upload.",chunkNumber:e.chunkCount,attempts:e.attemptCount})}})).catch((function(t){e.paused||e.offline||e.manageRetries()}))},e}();t.UpChunk=a,t.createUpload=function(e){return new a(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=new WeakMap,o=new WeakMap;function i(e){const t=r.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function s(e){null==e.passiveListener?e.event.cancelable&&(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault()):"undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener)}function u(e,t){r.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=Object.keys(t);for(let e=0;e<n.length;++e){const t=n[e];t in this||Object.defineProperty(this,t,a(t))}}function a(e){return{get(){return i(this).event[e]},set(t){i(this).event[e]=t},configurable:!0,enumerable:!0}}function p(e){return{value(){const t=i(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function c(e){if(null==e||e===Object.prototype)return u;let t=o.get(e);return null==t&&(t=function(e,t){const n=Object.keys(t);if(0===n.length)return e;function r(t,n){e.call(this,t,n)}r.prototype=Object.create(e.prototype,{constructor:{value:r,configurable:!0,writable:!0}});for(let o=0;o<n.length;++o){const i=n[o];if(!(i in e.prototype)){const e="function"==typeof Object.getOwnPropertyDescriptor(t,i).value;Object.defineProperty(r.prototype,i,e?p(i):a(i))}}return r}(c(Object.getPrototypeOf(e)),e),o.set(e,t)),t}function l(e){return i(e).immediateStopped}function f(e,t){i(e).passiveListener=t}u.prototype={get type(){return i(this).event.type},get target(){return i(this).eventTarget},get currentTarget(){return i(this).currentTarget},composedPath(){const e=i(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return i(this).eventPhase},stopPropagation(){const e=i(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=i(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(i(this).event.bubbles)},get cancelable(){return Boolean(i(this).event.cancelable)},preventDefault(){s(i(this))},get defaultPrevented(){return i(this).canceled},get composed(){return Boolean(i(this).event.composed)},get timeStamp(){return i(this).timeStamp},get srcElement(){return i(this).eventTarget},get cancelBubble(){return i(this).stopped},set cancelBubble(e){if(!e)return;const t=i(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!i(this).canceled},set returnValue(e){e||s(i(this))},initEvent(){}},Object.defineProperty(u.prototype,"constructor",{value:u,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(u.prototype,window.Event.prototype),o.set(window.Event.prototype,u));const h=new WeakMap;function d(e){return null!==e&&"object"==typeof e}function y(e){const t=h.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function v(e,t){Object.defineProperty(e,"on"+t,function(e){return{get(){let t=y(this).get(e);for(;null!=t;){if(3===t.listenerType)return t.listener;t=t.next}return null},set(t){"function"==typeof t||d(t)||(t=null);const n=y(this);let r=null,o=n.get(e);for(;null!=o;)3===o.listenerType?null!==r?r.next=o.next:null!==o.next?n.set(e,o.next):n.delete(e):r=o,o=o.next;if(null!==t){const o={listener:t,listenerType:3,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function m(e){function t(){b.call(this)}t.prototype=Object.create(b.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)v(t.prototype,e[n]);return t}function b(){if(!(this instanceof b)){if(1===arguments.length&&Array.isArray(arguments[0]))return m(arguments[0]);if(arguments.length>0){const e=new Array(arguments.length);for(let t=0;t<arguments.length;++t)e[t]=arguments[t];return m(e)}throw new TypeError("Cannot call a class as a function")}h.set(this,new Map)}b.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!d(t))throw new TypeError("'listener' should be a function or an object.");const r=y(this),o=d(n),i=(o?Boolean(n.capture):Boolean(n))?1:2,s={listener:t,listenerType:i,passive:o&&Boolean(n.passive),once:o&&Boolean(n.once),next:null};let u=r.get(e);if(void 0===u)return void r.set(e,s);let a=null;for(;null!=u;){if(u.listener===t&&u.listenerType===i)return;a=u,u=u.next}a.next=s},removeEventListener(e,t,n){if(null==t)return;const r=y(this),o=(d(n)?Boolean(n.capture):Boolean(n))?1:2;let i=null,s=r.get(e);for(;null!=s;){if(s.listener===t&&s.listenerType===o)return void(null!==i?i.next=s.next:null!==s.next?r.set(e,s.next):r.delete(e));i=s,s=s.next}},dispatchEvent(e){if(null==e||"string"!=typeof e.type)throw new TypeError('"event.type" should be a string.');const t=y(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(c(Object.getPrototypeOf(t)))(e,t)}(this,e);let s=null;for(;null!=r;){if(r.once?null!==s?s.next=r.next:null!==r.next?t.set(n,r.next):t.delete(n):s=r,f(o,r.passive?r.listener:null),"function"==typeof r.listener)try{r.listener.call(this,o)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else 3!==r.listenerType&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(l(o))break;r=r.next}return f(o,null),function(e,t){i(e).eventPhase=t}(o,0),function(e,t){i(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(b.prototype,"constructor",{value:b,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(b.prototype,window.EventTarget.prototype),t.defineEventAttribute=v,t.EventTarget=b,t.default=b,e.exports=b,e.exports.EventTarget=e.exports.default=b,e.exports.defineEventAttribute=v},function(e,t,n){"use strict";var r=n(3),o=n(5),i=n(6),s=n(7);function u(e,t,n){var r=e;return o(t)?(n=t,"string"==typeof e&&(r={uri:e})):r=s(t,{uri:e}),r.callback=n,r}function a(e,t,n){return p(t=u(e,t,n))}function p(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,n=function(n,r,o){t||(t=!0,e.callback(n,r,o))};function r(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),m)try{e=JSON.parse(e)}catch(e){}return e}function o(e){return clearTimeout(l),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,n(e,b)}function s(){if(!p){var t;clearTimeout(l),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var o=b,s=null;return 0!==t?(o={body:r(),statusCode:t,method:h,headers:{},url:f,rawRequest:c},c.getAllResponseHeaders&&(o.headers=i(c.getAllResponseHeaders()))):s=new Error("Internal XMLHttpRequest Error"),n(s,o,o.body)}}var u,p,c=e.xhr||null;c||(c=e.cors||e.useXDR?new a.XDomainRequest:new a.XMLHttpRequest);var l,f=c.url=e.uri||e.url,h=c.method=e.method||"GET",d=e.body||e.data,y=c.headers=e.headers||{},v=!!e.sync,m=!1,b={body:void 0,headers:{},statusCode:0,method:h,url:f,rawRequest:c};if("json"in e&&!1!==e.json&&(m=!0,y.accept||y.Accept||(y.Accept="application/json"),"GET"!==h&&"HEAD"!==h&&(y["content-type"]||y["Content-Type"]||(y["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(s,0)},c.onload=s,c.onerror=o,c.onprogress=function(){},c.onabort=function(){p=!0},c.ontimeout=o,c.open(h,f,!v,e.username,e.password),v||(c.withCredentials=!!e.withCredentials),!v&&e.timeout>0&&(l=setTimeout((function(){if(!p){p=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",o(e)}}),e.timeout)),c.setRequestHeader)for(u in y)y.hasOwnProperty(u)&&c.setRequestHeader(u,y[u]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}e.exports=a,e.exports.default=a,a.XMLHttpRequest=r.XMLHttpRequest||function(){},a.XDomainRequest="withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:r.XDomainRequest,function(e,t){for(var n=0;n<e.length;n++)t(e[n])}(["get","put","post","patch","head","delete"],(function(e){a["delete"===e?"del":e]=function(t,n,r){return(n=u(t,n,r)).method=e.toUpperCase(),p(n)}}))},function(e,t,n){(function(t){var n;n="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=n}).call(this,n(4))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){if(!e)return!1;var t=n.call(e);return"[object Function]"===t||"function"==typeof e&&"[object RegExp]"!==t||"undefined"!=typeof window&&(e===window.setTimeout||e===window.alert||e===window.confirm||e===window.prompt)};var n=Object.prototype.toString},function(e,t){var n=function(e){return e.replace(/^\s+|\s+$/g,"")};e.exports=function(e){if(!e)return{};for(var t,r={},o=n(e).split("\n"),i=0;i<o.length;i++){var s=o[i],u=s.indexOf(":"),a=n(s.slice(0,u)).toLowerCase(),p=n(s.slice(u+1));void 0===r[a]?r[a]=p:(t=r[a],"[object Array]"===Object.prototype.toString.call(t)?r[a].push(p):r[a]=[r[a],p])}return r}},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)n.call(r,o)&&(e[o]=r[o])}return e};var n=Object.prototype.hasOwnProperty}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UpChunk=t():e.UpChunk=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};t.__esModule=!0,t.createUpload=t.UpChunk=void 0;var o=n(2),i=n(4),s=[200,201,202,204,308],a=[408,502,503,504],u=function(){function e(e){var t=this;this.endpoint=e.endpoint,this.file=e.file,this.headers=e.headers||{},this.method=e.method||"PUT",this.chunkSize=e.chunkSize||30720,this.attempts=e.attempts||5,this.delayBeforeAttempt=e.delayBeforeAttempt||1,this.maxFileBytes=1024*(e.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new o.EventTarget,this.validateOptions(),this.getEndpoint().then((function(){return t.sendChunks()})),"undefined"!=typeof window&&(window.addEventListener("online",(function(){t.offline&&(t.offline=!1,t.dispatch("online"),t.sendChunks())})),window.addEventListener("offline",(function(){t.offline=!0,t.dispatch("offline")})))}return e.prototype.on=function(e,t){this.eventTarget.addEventListener(e,t)},e.prototype.abort=function(){var e;this.pause(),null===(e=this.currentXhr)||void 0===e||e.abort()},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},e.prototype.dispatch=function(e,t){var n=new CustomEvent(e,{detail:t});this.eventTarget.dispatchEvent(n)},e.prototype.validateOptions=function(){if(!this.endpoint||"function"!=typeof this.endpoint&&"string"!=typeof this.endpoint)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&&"object"!=typeof this.headers)throw new TypeError("headers must be null or an object");if(this.chunkSize&&("number"!=typeof this.chunkSize||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&("number"!=typeof this.attempts||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&("number"!=typeof this.delayBeforeAttempt||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},e.prototype.getEndpoint=function(){var e=this;return"string"==typeof this.endpoint?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then((function(t){return e.endpointValue=t,e.endpointValue}))},e.prototype.getChunk=function(){var e=this;return new Promise((function(t){var n=1===e.totalChunks?e.file.size:e.chunkByteSize,r=n*e.chunkCount;e.reader.onload=function(){null!==e.reader.result&&(e.chunk=new Blob([e.reader.result],{type:"application/octet-stream"})),t()},e.reader.readAsArrayBuffer(e.file.slice(r,r+n))}))},e.prototype.xhrPromise=function(e){var t=this,n=function(e){e.upload.onprogress=function(e){var n,r=100/t.totalChunks,o=r*t.file.size,i=r*t.chunkCount,s=e.loaded/(null!==(n=e.total)&&void 0!==n?n:o)*r;t.dispatch("progress",Math.min(i+s,100))}};return new Promise((function(o,s){t.currentXhr=(0,i.default)(r(r({},e),{beforeSend:n}),(function(e,n){return t.currentXhr=void 0,e?s(e):o(n)}))}))},e.prototype.sendChunk=function(){var e=this.chunkCount*this.chunkByteSize,t=e+this.chunk.size-1,n=r(r({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(e,"-").concat(t,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:n,url:this.endpointValue,method:this.method,body:this.chunk})},e.prototype.manageRetries=function(){var e=this;if(this.attemptCount<this.attempts)return setTimeout((function(){return e.sendChunks()}),1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},e.prototype.sendChunks=function(){var e=this;this.paused||this.offline||this.success||this.getChunk().then((function(){return e.attemptCount=e.attemptCount+1,e.sendChunk()})).then((function(t){if(s.includes(t.statusCode)){e.dispatch("chunkSuccess",{chunk:e.chunkCount,attempts:e.attemptCount,response:t}),e.attemptCount=0,e.chunkCount=e.chunkCount+1,e.chunkCount<e.totalChunks?e.sendChunks():(e.success=!0,e.dispatch("success"));var n=100*(e.chunkCount/e.totalChunks*e.file.size)/e.file.size;e.dispatch("progress",n)}else if(a.includes(t.statusCode)){if(e.paused||e.offline)return;e.manageRetries()}else{if(e.paused||e.offline)return;e.dispatch("error",{message:"Server responded with ".concat(t.statusCode,". Stopping upload."),chunkNumber:e.chunkCount,attempts:e.attemptCount})}})).catch((function(t){e.paused||e.offline||e.manageRetries()}))},e}();t.UpChunk=u;t.createUpload=function(e){return new u(e)}},function(e,t,n){"use strict";(function(e,n){function r(e,t,...n){if(!e)throw new TypeError(o(t,n))}function o(e,t){let n=0;return e.replace(/%[os]/gu,()=>i(t[n++]))}function i(e){return"object"!=typeof e||null===e?String(e):Object.prototype.toString.call(e)}let s;Object.defineProperty(t,"__esModule",{value:!0});const a="undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0!==n?n:"undefined"!=typeof globalThis?globalThis:void 0;let u;class c{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(u)return void u({...this,args:e});const n=(null!==(t=(new Error).stack)&&void 0!==t?t:"").replace(/^(?:.+?\n){2}/gu,"\n");console.warn(this.message,...e,n)}catch(e){}}}const l=new c("W01","Unable to initialize event under dispatching."),p=new c("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),f=new c("W03","Assigning any truthy value to 'returnValue' property has no effect."),h=new c("W04","Unable to preventDefault on non-cancelable events."),d=new c("W05","Unable to preventDefault inside passive event listener invocation."),g=new c("W06","An event listener wasn't added because it has been added already: %o, %o"),b=new c("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),m=new c("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),y=new c("W09","Event attribute handler must be a function: %o");class v{static get NONE(){return E}static get CAPTURING_PHASE(){return w}static get AT_TARGET(){return T}static get BUBBLING_PHASE(){return R}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=null!=t?t:{};k.set(this,{type:String(e),bubbles:Boolean(n.bubbles),cancelable:Boolean(n.cancelable),composed:Boolean(n.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return C(this).type}get target(){return C(this).target}get srcElement(){return C(this).target}get currentTarget(){return C(this).currentTarget}composedPath(){const e=C(this).currentTarget;return e?[e]:[]}get NONE(){return E}get CAPTURING_PHASE(){return w}get AT_TARGET(){return T}get BUBBLING_PHASE(){return R}get eventPhase(){return C(this).dispatchFlag?2:0}stopPropagation(){C(this).stopPropagationFlag=!0}get cancelBubble(){return C(this).stopPropagationFlag}set cancelBubble(e){e?C(this).stopPropagationFlag=!0:p.warn()}stopImmediatePropagation(){const e=C(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return C(this).bubbles}get cancelable(){return C(this).cancelable}get returnValue(){return!C(this).canceledFlag}set returnValue(e){e?f.warn():O(C(this))}preventDefault(){O(C(this))}get defaultPrevented(){return C(this).canceledFlag}get composed(){return C(this).composed}get isTrusted(){return!1}get timeStamp(){return C(this).timeStamp}initEvent(e,t=!1,n=!1){const r=C(this);r.dispatchFlag?l.warn():k.set(this,{...r,type:String(e),bubbles:Boolean(t),cancelable:Boolean(n),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}const E=0,w=1,T=2,R=3,k=new WeakMap;function C(e,t="this"){const n=k.get(e);return r(null!=n,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),n}function O(e){e.inPassiveListenerFlag?d.warn():e.cancelable?e.canceledFlag=!0:h.warn()}Object.defineProperty(v,"NONE",{enumerable:!0}),Object.defineProperty(v,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(v,"AT_TARGET",{enumerable:!0}),Object.defineProperty(v,"BUBBLING_PHASE",{enumerable:!0});const P=Object.getOwnPropertyNames(v.prototype);for(let e=0;e<P.length;++e)"constructor"!==P[e]&&Object.defineProperty(v.prototype,P[e],{enumerable:!0});let S;void 0!==a&&void 0!==a.Event&&Object.setPrototypeOf(v.prototype,a.Event.prototype);const A={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 _(e){const t=Object.keys(A);for(let n=0;n<t.length;++n){const r=t[n],o=A[r];Object.defineProperty(e,r,{get:()=>o,configurable:!0,enumerable:!0})}}class j extends v{static wrap(e){return new(function e(t){const n=Object.getPrototypeOf(t);if(null==n)return j;let r=I.get(n);null==r&&(r=function(e,t){class n extends e{}const r=Object.keys(t);for(let e=0;e<r.length;++e)Object.defineProperty(n.prototype,r[e],N(t,r[e]));return n}(e(n),n),I.set(n,r));return r}(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),L.set(this,{original:e});const t=Object.keys(e);for(let n=0;n<t.length;++n){const r=t[n];r in this||Object.defineProperty(this,r,N(e,r))}}stopPropagation(){super.stopPropagation();const{original:e}=B(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;const{original:t}=B(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();const{original:e}=B(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;const{original:t}=B(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();const{original:e}=B(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){const{original:e}=B(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}}const L=new WeakMap;function B(e){const t=L.get(e);return r(null!=t,"'this' is expected an Event object, but got",e),t}const I=new WeakMap;function N(e,t){const n=Object.getOwnPropertyDescriptor(e,t);return{get(){const e=B(this).original,n=e[t];return"function"==typeof n?n.bind(e):n},set(e){B(this).original[t]=e},configurable:n.configurable,enumerable:n.enumerable}}function F(e){return 1==(1&e.flags)}function D(e){return 2==(2&e.flags)}function x(e){return 4==(4&e.flags)}function M(e){return 8==(8&e.flags)}function U({callback:t},n,r){try{"function"==typeof t?t.call(n,r):"function"==typeof t.handleEvent&&t.handleEvent(r)}catch(t){!function(t){try{const n=t instanceof Error?t:new Error(i(t));if(s)return void s(n);if("function"==typeof dispatchEvent&&"function"==typeof ErrorEvent)dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}));else if(void 0!==e&&"function"==typeof e.emit)return void e.emit("uncaughtException",n);console.error(n)}catch(e){}}(t)}}function H({listeners:e},t,n){for(let r=0;r<e.length;++r)if(e[r].callback===t&&F(e[r])===n)return r;return-1}function z(e,t,n,r,o,i){let s;i&&(s=X.bind(null,e,t,n),i.addEventListener("abort",s));const a=function(e,t,n,r,o,i){return{callback:e,flags:(t?1:0)|(n?2:0)|(r?4:0),signal:o,signalListener:i}}(t,n,r,o,i,s);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,a]):e.listeners.push(a),a}function X(e,t,n){const r=H(e,t,n);return-1!==r&&V(e,r)}function V(e,t,n=!1){const r=e.listeners[t];return function(e){e.flags|=8}(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),e.cow&&!n?(e.cow=!1,e.listeners=e.listeners.filter((e,n)=>n!==t),!1):(e.listeners.splice(t,1),!0)}function W(e,t){var n;return null!==(n=e[t])&&void 0!==n?n:e[t]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}I.set(Object.prototype,j),void 0!==a&&void 0!==a.Event&&I.set(a.Event.prototype,j);class q{constructor(){G.set(this,Object.create(null))}addEventListener(e,t,n){const r=Y(this),{callback:o,capture:i,once:s,passive:a,signal:u,type:c}=function(e,t,n){var r;if(J(t),"object"==typeof n&&null!==n)return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n.capture),passive:Boolean(n.passive),once:Boolean(n.once),signal:null!==(r=n.signal)&&void 0!==r?r:void 0};return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n),passive:!1,once:!1,signal:void 0}}(e,t,n);if(null==o||(null==u?void 0:u.aborted))return;const l=W(r,c),p=H(l,o,i);-1===p?z(l,o,i,a,s,u):function(e,t,n,r){g.warn(F(e)?"capture":"bubble",e.callback),D(e)!==t&&b.warn("passive");x(e)!==n&&b.warn("once");e.signal!==r&&b.warn("signal")}(l.listeners[p],a,s,u)}removeEventListener(e,t,n){const r=Y(this),{callback:o,capture:i,type:s}=function(e,t,n){if(J(t),"object"==typeof n&&null!==n)return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n.capture)};return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n)}}(e,t,n),a=r[s];null!=o&&a&&X(a,o,i)}dispatchEvent(e){const t=Y(this)[String(e.type)];if(null==t)return!0;const n=e instanceof v?e:j.wrap(e),r=C(n,"event");if(r.dispatchFlag)throw o="This event has been in dispatching.",a.DOMException?new a.DOMException(o,"InvalidStateError"):(null==S&&(S=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(S.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),_(S),_(S.prototype)),new S(o));var o;if(r.dispatchFlag=!0,r.target=r.currentTarget=this,!r.stopPropagationFlag){const{cow:e,listeners:o}=t;t.cow=!0;for(let i=0;i<o.length;++i){const s=o[i];if(!M(s)&&(x(s)&&V(t,i,!e)&&(i-=1),r.inPassiveListenerFlag=D(s),U(s,this,n),r.inPassiveListenerFlag=!1,r.stopImmediatePropagationFlag))break}e||(t.cow=!1)}return r.target=null,r.currentTarget=null,r.stopImmediatePropagationFlag=!1,r.stopPropagationFlag=!1,r.dispatchFlag=!1,!r.canceledFlag}}const G=new WeakMap;function Y(e,t="this"){const n=G.get(e);return r(null!=n,"'%s' must be an object that EventTarget constructor created, but got another one: %o",t,e),n}function J(e){if("function"!=typeof e&&("object"!=typeof e||null===e||"function"!=typeof e.handleEvent)){if(null!=e&&"object"!=typeof e)throw new TypeError(o(m.message,[e]));m.warn(e)}}const Q=Object.getOwnPropertyNames(q.prototype);for(let e=0;e<Q.length;++e)"constructor"!==Q[e]&&Object.defineProperty(q.prototype,Q[e],{enumerable:!0});function Z(e,t){var n,r;return null!==(r=null===(n=Y(e,"target")[t])||void 0===n?void 0:n.attrCallback)&&void 0!==r?r:null}function K(e,t,n){null!=n&&"function"!=typeof n&&y.warn(n),"function"==typeof n||"object"==typeof n&&null!==n?function(e,t,n){const r=W(Y(e,"target"),String(t));r.attrCallback=n,null==r.attrListener&&(r.attrListener=z(r,function(e){return function(t){const n=e.attrCallback;"function"==typeof n&&n.call(this,t)}}(r),!1,!1,!1,void 0))}(e,t,n):function(e,t){const n=Y(e,"target")[String(t)];n&&n.attrListener&&(X(n,n.attrListener.callback,!1),n.attrCallback=n.attrListener=void 0)}(e,t)}function $(e,t,n){Object.defineProperty(e,"on"+t,{get(){return Z(this,t)},set(e){K(this,t,e)},configurable:!0,enumerable:!0})}void 0!==a&&void 0!==a.EventTarget&&Object.setPrototypeOf(q.prototype,a.EventTarget.prototype),t.Event=v,t.EventTarget=q,t.default=q,t.defineCustomEventTarget=function(...e){class t extends q{}for(let n=0;n<e.length;++n)$(t.prototype,e[n]);return t},t.defineEventAttribute=$,t.getEventAttributeValue=Z,t.setErrorHandler=function(e){r("function"==typeof e||void 0===e,"The error handler must be a function or undefined, but got %o.",e),s=e},t.setEventAttributeValue=K,t.setWarningHandler=function(e){r("function"==typeof e||void 0===e,"The warning handler must be a function or undefined, but got %o.",e),u=e}}).call(this,n(3),n(0))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var u,c=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&h())}function h(){if(!l){var e=a(f);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p<t;)u&&u[p].run();p=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||l||a(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(5),o=n(6),i=n(7),s=n(8);function a(e,t,n){var r=e;return o(t)?(n=t,"string"==typeof e&&(r={uri:e})):r=s(t,{uri:e}),r.callback=n,r}function u(e,t,n){return c(t=a(e,t,n))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,n=function(n,r,o){t||(t=!0,e.callback(n,r,o))};function r(){var e=void 0;if(e=l.response?l.response:l.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(l),m)try{e=JSON.parse(e)}catch(e){}return e}function o(e){return clearTimeout(p),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,n(e,y)}function s(){if(!c){var t;clearTimeout(p),t=e.useXDR&&void 0===l.status?200:1223===l.status?204:l.status;var o=y,s=null;return 0!==t?(o={body:r(),statusCode:t,method:h,headers:{},url:f,rawRequest:l},l.getAllResponseHeaders&&(o.headers=i(l.getAllResponseHeaders()))):s=new Error("Internal XMLHttpRequest Error"),n(s,o,o.body)}}var a,c,l=e.xhr||null;l||(l=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var p,f=l.url=e.uri||e.url,h=l.method=e.method||"GET",d=e.body||e.data,g=l.headers=e.headers||{},b=!!e.sync,m=!1,y={body:void 0,headers:{},statusCode:0,method:h,url:f,rawRequest:l};if("json"in e&&!1!==e.json&&(m=!0,g.accept||g.Accept||(g.Accept="application/json"),"GET"!==h&&"HEAD"!==h&&(g["content-type"]||g["Content-Type"]||(g["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),l.onreadystatechange=function(){4===l.readyState&&setTimeout(s,0)},l.onload=s,l.onerror=o,l.onprogress=function(){},l.onabort=function(){c=!0},l.ontimeout=o,l.open(h,f,!b,e.username,e.password),b||(l.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(p=setTimeout((function(){if(!c){c=!0,l.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",o(e)}}),e.timeout)),l.setRequestHeader)for(a in g)g.hasOwnProperty(a)&&l.setRequestHeader(a,g[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(l.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(l),l.send(d||null),l}e.exports=u,e.exports.default=u,u.XMLHttpRequest=r.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:r.XDomainRequest,function(e,t){for(var n=0;n<e.length;n++)t(e[n])}(["get","put","post","patch","head","delete"],(function(e){u["delete"===e?"del":e]=function(t,n,r){return(n=a(t,n,r)).method=e.toUpperCase(),c(n)}}))},function(e,t,n){(function(t){var n;n="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=n}).call(this,n(0))},function(e,t){e.exports=function(e){if(!e)return!1;var t=n.call(e);return"[object Function]"===t||"function"==typeof e&&"[object RegExp]"!==t||"undefined"!=typeof window&&(e===window.setTimeout||e===window.alert||e===window.confirm||e===window.prompt)};var n=Object.prototype.toString},function(e,t){var n=function(e){return e.replace(/^\s+|\s+$/g,"")};e.exports=function(e){if(!e)return{};for(var t,r={},o=n(e).split("\n"),i=0;i<o.length;i++){var s=o[i],a=s.indexOf(":"),u=n(s.slice(0,a)).toLowerCase(),c=n(s.slice(a+1));void 0===r[u]?r[u]=c:(t=r[u],"[object Array]"===Object.prototype.toString.call(t)?r[u].push(c):r[u]=[r[u],c])}return r}},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)n.call(r,o)&&(e[o]=r[o])}return e};var n=Object.prototype.hasOwnProperty}])}));
//# sourceMappingURL=upchunk.js.map
{
"name": "@mux/upchunk",
"version": "2.3.0",
"version": "2.3.1",
"description": "Dead simple chunked file uploads using Fetch",

@@ -40,3 +40,3 @@ "main": "dist/upchunk.js",

"tslint-config-prettier": "^1.18.0",
"typescript": "^3.9.5",
"typescript": "^4.1.3",
"webpack": "^4.43.0",

@@ -48,3 +48,3 @@ "webpack-cli": "^3.3.11",

"dependencies": {
"event-target-shim": "^4.0.3",
"event-target-shim": "^6.0.2",
"xhr": "^2.6.0"

@@ -51,0 +51,0 @@ },

@@ -1,2 +0,2 @@

import { EventTarget } from 'event-target-shim';
import { EventTarget, Event } from 'event-target-shim';
import xhr, { XhrUrlConfig, XhrHeaders, XhrResponse } from 'xhr';

@@ -17,2 +17,6 @@

// NOTE: This and the EventTarget definition below could be more precise
// by e.g. typing the detail of the CustomEvent per EventName.
type UpchunkEvent = CustomEvent & Event<EventName>;
type AllowedMethods =

@@ -34,3 +38,3 @@ | 'PUT'

export class UpChunk {
export class UpChunk {
public endpoint: string | ((file?: File) => Promise<string>);

@@ -57,3 +61,3 @@ public file: File;

private reader: FileReader;
private eventTarget: EventTarget;
private eventTarget: EventTarget<Record<EventName,UpchunkEvent>>;

@@ -108,3 +112,3 @@ constructor(options: UpChunkOptions) {

public on(eventName: EventName, fn: (event: CustomEvent) => void) {
this.eventTarget.addEventListener(eventName, fn);
this.eventTarget.addEventListener(eventName, fn as EventListener);
}

@@ -133,3 +137,3 @@

private dispatch(eventName: EventName, detail?: any) {
const event = new CustomEvent(eventName, { detail });
const event: UpchunkEvent = new CustomEvent(eventName, { detail }) as UpchunkEvent;

@@ -206,3 +210,3 @@ this.eventTarget.dispatchEvent(event);

private getChunk() {
return new Promise((resolve) => {
return new Promise<void> ((resolve) => {
// Since we start with 0-chunkSize for the range, we need to subtract 1.

@@ -209,0 +213,0 @@ const length =

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc