1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
(()=>{var t={399:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.detector=void 0;const r=n(230);const i=Object.keys(r.typeHandlers);const s={56:"psd",66:"bmp",68:"dds",71:"gif",73:"tiff",77:"tiff",82:"webp",105:"icns",137:"png",255:"jpg"};function detector(t){const e=t[0];if(e in s){const n=s[e];if(n&&r.typeHandlers[n].validate(t)){return n}}const finder=e=>r.typeHandlers[e].validate(t);return i.find(finder)}e.detector=detector},501:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){function adopt(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function fulfilled(t){try{step(r.next(t))}catch(t){i(t)}}function rejected(t){try{step(r["throw"](t))}catch(t){i(t)}}function step(t){t.done?n(t.value):adopt(t.value).then(fulfilled,rejected)}step((r=r.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:true});e.types=e.setConcurrency=e.disableTypes=e.disableFS=e.imageSize=void 0;const i=n(147);const s=n(17);const o=n(927);const c=n(230);const a=n(399);const u=512*1024;const l=new o.default({concurrency:100,autostart:true});const d={disabledFS:false,disabledTypes:[]};function lookup(t,e){const n=a.detector(t);if(typeof n!=="undefined"){if(d.disabledTypes.indexOf(n)>-1){throw new TypeError("disabled file type: "+n)}if(n in c.typeHandlers){const r=c.typeHandlers[n].calculate(t,e);if(r!==undefined){r.type=n;return r}}}throw new TypeError("unsupported file type: "+n+" (file: "+e+")")}function asyncFileToBuffer(t){return r(this,void 0,void 0,(function*(){const e=yield i.promises.open(t,"r");const{size:n}=yield e.stat();if(n<=0){yield e.close();throw new Error("Empty file")}const r=Math.min(n,u);const s=Buffer.alloc(r);yield e.read(s,0,r,0);yield e.close();return s}))}function syncFileToBuffer(t){const e=i.openSync(t,"r");const{size:n}=i.fstatSync(e);if(n<=0){i.closeSync(e);throw new Error("Empty file")}const r=Math.min(n,u);const s=Buffer.alloc(r);i.readSync(e,s,0,r,0);i.closeSync(e);return s}t.exports=e=imageSize;e["default"]=imageSize;function imageSize(t,e){if(Buffer.isBuffer(t)){return lookup(t)}if(typeof t!=="string"||d.disabledFS){throw new TypeError("invalid invocation. input should be a Buffer")}const n=s.resolve(t);if(typeof e==="function"){l.push((()=>asyncFileToBuffer(n).then((t=>process.nextTick(e,null,lookup(t,n)))).catch(e)))}else{const t=syncFileToBuffer(n);return lookup(t,n)}}e.imageSize=imageSize;const disableFS=t=>{d.disabledFS=t};e.disableFS=disableFS;const disableTypes=t=>{d.disabledTypes=t};e.disableTypes=disableTypes;const setConcurrency=t=>{l.concurrency=t};e.setConcurrency=setConcurrency;e.types=Object.keys(c.typeHandlers)},326:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.readUInt=void 0;function readUInt(t,e,n,r){n=n||0;const i=r?"BE":"LE";const s="readUInt"+e+i;return t[s].call(t,n)}e.readUInt=readUInt},230:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.typeHandlers=void 0;const r=n(798);const i=n(925);const s=n(813);const o=n(259);const c=n(341);const a=n(541);const u=n(852);const l=n(182);const d=n(32);const h=n(707);const f=n(179);const p=n(457);const g=n(438);const y=n(12);const v=n(167);const w=n(185);e.typeHandlers={bmp:r.BMP,cur:i.CUR,dds:s.DDS,gif:o.GIF,icns:c.ICNS,ico:a.ICO,j2c:u.J2C,jp2:l.JP2,jpg:d.JPG,ktx:h.KTX,png:f.PNG,pnm:p.PNM,psd:g.PSD,svg:y.SVG,tiff:v.TIFF,webp:w.WEBP}},798:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.BMP=void 0;e.BMP={validate(t){return"BM"===t.toString("ascii",0,2)},calculate(t){return{height:Math.abs(t.readInt32LE(22)),width:t.readUInt32LE(18)}}}},925:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.CUR=void 0;const r=n(541);const i=2;e.CUR={validate(t){if(t.readUInt16LE(0)!==0){return false}return t.readUInt16LE(2)===i},calculate(t){return r.ICO.calculate(t)}}},813:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.DDS=void 0;e.DDS={validate(t){return t.readUInt32LE(0)===542327876},calculate(t){return{height:t.readUInt3
|