1 line
79 KiB
JavaScript
1 line
79 KiB
JavaScript
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("wasm-imagemagick",["exports"],t):t(e["wasm-imagemagick"]={})}(this,function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,o&&(a=2&n[0]?o.return:n[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,n[1])).done)return a;switch(o=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,o=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){u.label=n[1];break}if(6===n[0]&&u.label<a[1]){u.label=a[1],a=n;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],o=0}finally{i=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var i,o,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s}function i(e){return Object.keys(e).map(function(t){return e[t]})}function o(e){return e.reduce(function(e,t){return e.concat(t)})}function a(e){return e.map(function(e){return e+""}).map(function(e){return e.trim().match(/\s/)?"'"+e+"'":e}).map(function(e){return"("===e.trim()?"\\(":")"===e.trim()?"\\)":e}).join(" ")}function s(e){return("string"==typeof e[0]?[e]:e).map(a).join("\n")}function u(e){for(var t=!1,n=[0],r=0;r<e.length;r++){var i=e[r];i.match(/[\s]/im)&&!t&&n.push(r),"'"===i&&(t=!t)}return n.push(e.length),n.map(function(t,r){return e.substring(0===r?0:n[r-1],n[r]).trim()}).filter(function(e){return!!e}).map(function(e){return e.startsWith("'")?e.substring(1,e.length):e}).map(function(e){return e.endsWith("'")?e.substring(0,e.length-1):e}).map(function(e){return"\\("===e?"(":"\\)"===e?")":e})}function l(e){for(var t=e.split("\n").map(function(e){return e.trim()}).map(u).filter(function(e){return e&&e.length}),n=[],r=[],i=0;i<t.length;i++){var o=t[i];"\\"!==o[o.length-1]?(r=r.concat(o),n.push(r),r=[]):r=r.concat(o.slice(0,o.length-1))}return n}function c(e){return"string"==typeof e?c([e]):e[0]?"string"==typeof e[0]?o(e.map(function(e){return l(e)})):e:[]}function p(e){return new Promise(function(t){var n=new FileReader;n.onload=function(e){var n=e.target.result;t(new Uint8Array(n))},n.readAsArrayBuffer(e)})}function d(e){return new Promise(function(t){var n=new FileReader;n.addEventListener("loadend",function(e){var n=e.srcElement.result;t(n)}),n.readAsText(e)})}function m(e){return!!e.content}function f(e){return!!e.blob}function h(e,t){return void 0===t&&(t="utf-8"),new TextDecoder(t).decode(e)}function g(e){return n(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return m(e)?[2,h(e.content)]:f(e)?[4,d(e.blob)]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}})})}function v(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return n=U,i={},[4,w(e)];case 1:return[4,n.apply(void 0,[(i.inputFiles=[r.sent()],i.commands="identify "+e.name,i)])];case 2:return t=r.sent().exitCode,[2,0===t]}})})}function y(e,t){return void 0===t&&(t=I(e)),n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return[4,fetch(e)];case 1:return n=r.sent(),[4,n.arrayBuffer()];case 2:
|