UNPKG

10.8 kBJavaScriptView Raw
1!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.blobUtil=e()}}(function(){return function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){(function(e){function n(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.buffer instanceof ArrayBuffer){var r=n.buffer;if(n.byteLength!==r.byteLength){var o=new Uint8Array(n.byteLength);o.set(new Uint8Array(r,n.byteOffset,n.byteLength)),r=o.buffer}e[t]=r}}}function r(e,t){t=t||{};var r=new i;n(e);for(var o=0;o<e.length;o++)r.append(e[o]);return t.type?r.getBlob(t.type):r.getBlob()}function o(e,t){return n(e),new Blob(e,t||{})}var i=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,u=function(){try{var e=new Blob(["hi"]);return 2===e.size}catch(t){return!1}}(),f=u&&function(){try{var e=new Blob([new Uint8Array([1,2])]);return 2===e.size}catch(t){return!1}}(),c=i&&i.prototype.append&&i.prototype.getBlob;t.exports=function(){return u?f?e.Blob:o:c?r:void 0}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";function r(){f=!1,c&&c.length?d=c.concat(d):l=-1,d.length&&o()}function o(){p=!1,f=!0;for(var e=d.length,t=setTimeout(r);e;){for(c=d,d=[];++l<e;)c[l].run();l=-1,e=d.length}l=-1,f=!1,clearTimeout(t)}function i(e,t){this.fun=e,this.array=t}function u(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];d.push(new i(e,t)),p||f||(p=!0,a())}for(var f,c,a,s=[e(5),e(4),e(3),e(6),e(7)],l=-1,d=[],p=!1,h=-1,v=s.length;++h<v;)if(s[h]&&s[h].test&&s[h].test()){a=s[h].install(o);break}i.prototype.run=function(){this.fun.apply(null,this.array)},t.exports=u},{3:3,4:4,5:5,6:6,7:7}],3:[function(e,t,n){(function(e){"use strict";n.test=function(){return e.setImmediate?!1:"undefined"!=typeof e.MessageChannel},n.install=function(t){var n=new e.MessageChannel;return n.port1.onmessage=t,function(){n.port2.postMessage(0)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){(function(e){"use strict";var t=e.MutationObserver||e.WebKitMutationObserver;n.test=function(){return t},n.install=function(n){var r=0,o=new t(n),i=e.document.createTextNode("");return o.observe(i,{characterData:!0}),function(){i.data=r=++r%2}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(e,t,n){(function(e){"use strict";n.test=function(){return"undefined"!=typeof e&&!e.browser},n.install=function(t){return function(){e.nextTick(t)}}}).call(this,e(21))},{21:21}],6:[function(e,t,n){(function(e){"use strict";n.test=function(){return"document"in e&&"onreadystatechange"in e.document.createElement("script")},n.install=function(t){return function(){var n=e.document.createElement("script");return n.onreadystatechange=function(){t(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n),t}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(e,t,n){"use strict";n.test=function(){return!0},n.install=function(e){return function(){setTimeout(e,0)}}},{}],8:[function(e,t,n){"use strict";function r(){}t.exports=r},{}],9:[function(e,t,n){"use strict";var r=e(12),o=e(14),i=e(15),u=e(8),f=e(10),c=o(new TypeError("must be an array"));t.exports=function(e){function t(e,t){function r(e){a[t]=e,++s===n&!o&&(o=!0,f.resolve(d,a))}i(e).then(r,function(e){o||(o=!0,f.reject(d,e))})}if("[object Array]"!==Object.prototype.toString.call(e))return c;var n=e.length,o=!1;if(!n)return i([]);for(var a=new Array(n),s=0,l=-1,d=new r(u);++l<n;)t(e[l],l);return d}},{10:10,12:12,14:14,15:15,8:8}],10:[function(e,t,n){"use strict";function r(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}var o=e(18),i=e(16),u=e(17);n.resolve=function(e,t){var f=o(r,t);if("error"===f.status)return n.reject(e,f.value);var c=f.value;if(c)i.safely(e,c);else{e.state=u.FULFILLED,e.outcome=t;for(var a=-1,s=e.queue.length;++a<s;)e.queue[a].callFulfilled(t)}return e},n.reject=function(e,t){e.state=u.REJECTED,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e}},{16:16,17:17,18:18}],11:[function(e,t,n){t.exports=n=e(12),n.resolve=e(15),n.reject=e(14),n.all=e(9)},{12:12,14:14,15:15,9:9}],12:[function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);if("function"!=typeof e)throw new TypeError("reslover must be a function");this.state=f.PENDING,this.queue=[],this.outcome=void 0,e!==i&&u.safely(this,e)}var o=e(19),i=e(8),u=e(16),f=e(17),c=e(13);t.exports=r,r.prototype["catch"]=function(e){return this.then(null,e)},r.prototype.then=function(e,t){if("function"!=typeof e&&this.state===f.FULFILLED||"function"!=typeof t&&this.state===f.REJECTED)return this;var n=new r(i);if(this.state!==f.PENDING){var u=this.state===f.FULFILLED?e:t;o(n,u,this.outcome)}else this.queue.push(new c(n,e,t));return n}},{13:13,16:16,17:17,19:19,8:8}],13:[function(e,t,n){"use strict";function r(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}var o=e(10),i=e(19);t.exports=r,r.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},r.prototype.otherCallFulfilled=function(e){i(this.promise,this.onFulfilled,e)},r.prototype.callRejected=function(e){o.reject(this.promise,e)},r.prototype.otherCallRejected=function(e){i(this.promise,this.onRejected,e)}},{10:10,19:19}],14:[function(e,t,n){"use strict";function r(e){var t=new o(i);return u.reject(t,e)}var o=e(12),i=e(8),u=e(10);t.exports=r},{10:10,12:12,8:8}],15:[function(e,t,n){"use strict";function r(e){if(e)return e instanceof o?e:u.resolve(new o(i),e);var t=typeof e;switch(t){case"boolean":return f;case"undefined":return a;case"object":return c;case"number":return s;case"string":return l}}var o=e(12),i=e(8),u=e(10);t.exports=r;var f=u.resolve(new o(i),!1),c=u.resolve(new o(i),null),a=u.resolve(new o(i),void 0),s=u.resolve(new o(i),0),l=u.resolve(new o(i),"")},{10:10,12:12,8:8}],16:[function(e,t,n){"use strict";function r(e,t){function n(t){f||(f=!0,o.reject(e,t))}function r(t){f||(f=!0,o.resolve(e,t))}function u(){t(r,n)}var f=!1,c=i(u);"error"===c.status&&n(c.value)}var o=e(10),i=e(18);n.safely=r},{10:10,18:18}],17:[function(e,t,n){n.REJECTED=["REJECTED"],n.FULFILLED=["FULFILLED"],n.PENDING=["PENDING"]},{}],18:[function(e,t,n){"use strict";function r(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}t.exports=r},{}],19:[function(e,t,n){"use strict";function r(e,t,n){o(function(){var r;try{r=t(n)}catch(o){return i.reject(e,o)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}var o=e(2),i=e(10);t.exports=r},{10:10,2:2}],20:[function(e,t,n){(function(n){"function"==typeof n.Promise?t.exports=n.Promise:t.exports=e(11)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{11:11}],21:[function(e,t,n){function r(){if(!f){f=!0;for(var e,t=u.length;t;){e=u,u=[];for(var n=-1;++n<t;)e[n]();t=u.length}f=!1}}function o(){}var i=t.exports={},u=[],f=!1;i.nextTick=function(e){u.push(e),f||setTimeout(r,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=o,i.addListener=o,i.once=o,i.off=o,i.removeListener=o,i.removeAllListeners=o,i.emit=o,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],22:[function(e,t,n){"use strict";function r(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=-1;++o<t;)r[o]=e.charCodeAt(o);return n}function o(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=-1;++o<r;)t+=String.fromCharCode(n[o]);return t}function i(e,t){return new L(function(n,r){var o=new Image;t&&(o.crossOrigin=t),o.onload=function(){n(o)},o.onerror=r,o.src=e})}function u(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height),t}function f(e,t){return t=t||{},"string"==typeof t&&(t={type:t}),new m(e,t)}function c(e){return(window.URL||window.webkitURL).createObjectURL(e)}function a(e){return(window.URL||window.webkitURL).revokeObjectURL(e)}function s(e){return new L(function(t,n){var r=new FileReader,i="function"==typeof r.readAsBinaryString;r.onloadend=function(e){var n=e.target.result||"";return i?t(n):void t(o(n))},r.onerror=n,i?r.readAsBinaryString(e):r.readAsArrayBuffer(e)})}function l(e,t){return L.resolve().then(function(){var n=[r(atob(e))];return t?f(n,{type:t}):f(n)})}function d(e,t){return L.resolve().then(function(){return l(btoa(e),t)})}function p(e){return s(e).then(function(e){return btoa(e)})}function h(e){return L.resolve().then(function(){var t=e.match(/data:([^;]+)/)[1],n=e.replace(/^[^,]+,/,""),o=r(atob(n));return f([o],{type:t})})}function v(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return e.toDataURL(t,r)})}function y(e,t,n){return L.resolve().then(function(){return"function"==typeof e.toBlob?new L(function(r){e.toBlob(r,t,n)}):h(e.toDataURL(t,n))})}function w(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return y(e,t,r)})}function b(e,t){return L.resolve().then(function(){return f([e],t)})}function g(e){return new L(function(t,n){var r=new FileReader;r.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},r.onerror=n,r.readAsArrayBuffer(e)})}var m=e(1),L=e(20);t.exports={createBlob:f,createObjectURL:c,revokeObjectURL:a,imgSrcToBlob:w,imgSrcToDataURL:v,canvasToBlob:y,dataURLToBlob:h,blobToBase64String:p,base64StringToBlob:l,binaryStringToBlob:d,blobToBinaryString:s,arrayBufferToBlob:b,blobToArrayBuffer:g}},{1:1,20:20}]},{},[22])(22)});