@mapcatch/util 1.0.8-a → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -926,18 +926,20 @@ function Sy(t, n) {
926
926
  function Ay(t) {
927
927
  var n = new DataView(t);
928
928
  let i = {};
929
+ if (n.getUint8(0) != 255 || n.getUint8(1) != 216)
930
+ return !1;
929
931
  for (var a = 2, f = t.byteLength, s; a < f && n.getUint8(a) == 255; ) {
930
932
  if (s = n.getUint8(a + 1), s == 225) {
931
933
  i = Ty(n, a + 4, n.getUint16(a + 2) - 2);
932
- break;
934
+ let l = xy(new Uint8Array(t));
935
+ return Object.assign(i, {
936
+ PixelXDimension: l.width,
937
+ PixelYDimension: l.height
938
+ }), i;
933
939
  }
934
940
  a += 2 + n.getUint16(a + 2);
935
941
  }
936
- let l = xy(new Uint8Array(t));
937
- return Object.assign(i, {
938
- PixelXDimension: l.width,
939
- PixelYDimension: l.height
940
- }), i;
942
+ return i;
941
943
  }
942
944
  function Ty(t, n) {
943
945
  if (Nf.getStringFromDB(t, n, 4) != "Exif")
@@ -1,6 +1,6 @@
1
1
  (function(ir,di){typeof exports=="object"&&typeof module<"u"?di(exports):typeof define=="function"&&define.amd?define(["exports"],di):(ir=typeof globalThis<"u"?globalThis:ir||self,di(ir.catchUtil={}))})(this,function(ir){"use strict";const di={imageHasData(t){return!!t.exifdata},getStringFromDB(t,n,i){for(var a="",f=n;f<n+i;f++)a+=String.fromCharCode(t.getUint8(f));return a},xml2Object(t){try{var n={};if(t.children.length>0)for(var i=0;i<t.children.length;i++){var a=t.children.item(i),f=a.attributes;for(var s in f){var l=f[s],d=l.nodeName,v=l.nodeValue;d!==void 0&&(n[d]=v)}var I=a.nodeName;if(typeof n[I]>"u")n[I]=this.xml2json(a);else{if(typeof n[I].push>"u"){var B=n[I];n[I]=[],n[I].push(B)}n[I].push(this.xml2json(a))}}else n=t.textContent;return n}catch(p){console.log(p.message)}},xml2json(t){var n={};if(t.nodeType==1){if(t.attributes.length>0){n["@attributes"]={};for(var i=0;i<t.attributes.length;i++){var a=t.attributes.item(i);n["@attributes"][a.nodeName]=a.nodeValue}}}else if(t.nodeType==3)return t.nodeValue;if(t.hasChildNodes())for(var f=0;f<t.childNodes.length;f++){var s=t.childNodes.item(f),l=s.nodeName;if(n[l]==null)n[l]=this.xml2json(s);else{if(n[l].push==null){var d=n[l];n[l]=[],n[l].push(d)}n[l].push(this.xml2json(s))}}return n},objectURLToBlob(t,n){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=function(a){(this.status==200||this.status===0)&&n(this.response)},i.send()},base64ToArrayBuffer(t,n){n=n||t.match(/^data\:([^\;]+)\;base64,/mi)[1]||"",t=t.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var i=atob(t),a=i.length,f=new ArrayBuffer(a),s=new Uint8Array(f),l=0;l<a;l++)s[l]=i.charCodeAt(l);return f}},Z_={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},X_={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},zf={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}},q_={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},K_=new TextDecoder,$r=(t,n=0,i=t.length)=>K_.decode(t.slice(n,i)),Bs=(t,n=0,i=t.length)=>t.slice(n,i).reduce((a,f)=>a+("0"+f.toString(16)).slice(-2),""),S0=(t,n=0)=>{const i=t[n]+t[n+1]*256;return i|(i&2**15)*131070},su=(t,n=0)=>t[n]*2**8+t[n+1],ti=(t,n=0)=>t[n]+t[n+1]*2**8,A0=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16,j_=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16+(t[n+3]<<24),bn=(t,n=0)=>t[n]*2**24+t[n+1]*2**16+t[n+2]*2**8+t[n+3],Ko=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16+t[n+3]*2**24,Q_={readUInt16BE:su,readUInt16LE:ti,readUInt32BE:bn,readUInt32LE:Ko};function Ui(t,n,i,a){i=i||0;const f=a?"BE":"LE",s="readUInt"+n+f;return Q_[s](t,i)}function J_(t,n){if(t.length-n<4)return;const i=bn(t,n);if(!(t.length-n<i))return{name:$r(t,4+n,8+n),offset:n,size:i}}function jo(t,n,i){for(;i<t.length;){const a=J_(t,i);if(!a)break;if(a.name===n)return a;i+=a.size}}const ep={validate:t=>$r(t,0,2)==="BM",calculate:t=>({height:Math.abs(j_(t,22)),width:Ko(t,18)})},tp=1,rp=2+2+2,np=1+1+1+1+2+2+4+4;function T0(t,n){const i=t[n];return i===0?256:i}function E0(t,n){const i=rp+n*np;return{height:T0(t,i+1),width:T0(t,i)}}const D0={validate(t){const n=ti(t,0),i=ti(t,4);return n!==0||i===0?!1:ti(t,2)===tp},calculate(t){const n=ti(t,4),i=E0(t,0);if(n===1)return i;const a=[i];for(let f=1;f<n;f+=1)a.push(E0(t,f));return{height:i.height,images:a,width:i.width}}},ip=2,ap={validate(t){const n=ti(t,0),i=ti(t,4);return n!==0||i===0?!1:ti(t,2)===ip},calculate:t=>D0.calculate(t)},op={validate:t=>Ko(t,0)===542327876,calculate:t=>({height:Ko(t,12),width:Ko(t,16)})},sp=/^GIF8[79]a/,fp={validate:t=>sp.test($r(t,0,6)),calculate:t=>({height:ti(t,8),width:ti(t,6)})},lp={avif:"avif",mif1:"heif",msf1:"heif",heic:"heic",heix:"heic",hevc:"heic",hevx:"heic"},up={validate(t){const n=$r(t,4,8),i=$r(t,8,12);return n==="ftyp"&&i in lp},calculate(t){const n=jo(t,"meta",0),i=n&&jo(t,"iprp",n.offset+12),a=i&&jo(t,"ipco",i.offset+8),f=a&&jo(t,"ispe",a.offset+8);if(f)return{height:bn(t,f.offset+16),width:bn(t,f.offset+12),type:$r(t,8,12)};throw new TypeError("Invalid HEIF, no size found")}},cp=4+4,hp=4,dp=4,vp={ICON:32,"ICN#":32,"icm#":16,icm4:16,icm8:16,"ics#":16,ics4:16,ics8:16,is32:16,s8mk:16,icp4:16,icl4:32,icl8:32,il32:32,l8mk:32,icp5:32,ic11:32,ich4:48,ich8:48,ih32:48,h8mk:48,icp6:64,ic12:32,it32:128,t8mk:128,ic07:128,ic08:256,ic13:256,ic09:512,ic14:512,ic10:1024};function L0(t,n){const i=n+dp;return[$r(t,n,i),bn(t,i)]}function R0(t){const n=vp[t];return{width:n,height:n,type:t}}const _p={validate:t=>$r(t,0,4)==="icns",calculate(t){const n=t.length,i=bn(t,hp);let a=cp,f=L0(t,a),s=R0(f[0]);if(a+=f[1],a===i)return s;const l={height:s.height,images:[s],width:s.width};for(;a<i&&a<n;)f=L0(t,a),s=R0(f[0]),a+=f[1],l.images.push(s);return l}},pp={validate:t=>Bs(t,0,4)==="ff4fff51",calculate:t=>({height:bn(t,12),width:bn(t,8)})},mp={validate(t){if(bn(t,4)!==1783636e3||bn(t,0)<1)return!1;const n=jo(t,"ftyp",0);return n?bn(t,n.offset+4)===1718909296:!1},calculate(t){const n=jo(t,"jp2h",0),i=n&&jo(t,"ihdr",n.offset+8);if(i)return{height:bn(t,i.offset+8),width:bn(t,i.offset+12)};throw new TypeError("Unsupported JPEG 2000 format")}},gp="45786966",yp=2,Xc=6,xp=2,bp="4d4d",wp="4949",C0=12,Sp=2;function Ap(t){return Bs(t,2,6)===gp}function Tp(t,n){return{height:su(t,n),width:su(t,n+2)}}function Ep(t,n){const a=Xc+8,f=Ui(t,16,a,n);for(let s=0;s<f;s++){const l=a+Sp+s*C0,d=l+C0;if(l>t.length)return;const v=t.slice(l,d);if(Ui(v,16,0,n)===274)return Ui(v,16,2,n)!==3||Ui(v,32,4,n)!==1?void 0:Ui(v,16,8,n)}}function Dp(t,n){const i=t.slice(yp,n),a=Bs(i,Xc,Xc+xp),f=a===bp;if(f||a===wp)return Ep(i,f)}function Lp(t,n){if(n>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(t[n]!==255)throw new TypeError("Invalid JPG, marker table corrupted")}const Rp={validate:t=>Bs(t,0,2)==="ffd8",calculate(t){t=t.slice(4);let n,i;for(;t.length;){const a=su(t,0);if(Ap(t)&&(n=Dp(t,a)),Lp(t,a),i=t[a+1],i===192||i===193||i===194){const f=Tp(t,a+5);return n?{height:f.height,orientation:n,width:f.width}:f}t=t.slice(a+2)}throw new TypeError("Invalid JPG, no size found")}},Cp={validate:t=>{const n=$r(t,1,7);return["KTX 11","KTX 20"].includes(n)},calculate:t=>{const n=t[5]===49?"ktx":"ktx2",i=n==="ktx"?36:20;return{height:Ko(t,i+4),width:Ko(t,i),type:n}}},Op=`PNG\r
2
2
  
3
- `,Ip="IHDR",O0="CgBI",Mp={validate(t){if(Op===$r(t,1,8)){let n=$r(t,12,16);if(n===O0&&(n=$r(t,28,32)),n!==Ip)throw new TypeError("Invalid PNG");return!0}return!1},calculate(t){return $r(t,12,16)===O0?{height:bn(t,36),width:bn(t,32)}:{height:bn(t,20),width:bn(t,16)}}},I0={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"},M0={default:t=>{let n=[];for(;t.length>0;){const i=t.shift();if(i[0]!=="#"){n=i.split(" ");break}}if(n.length===2)return{height:parseInt(n[1],10),width:parseInt(n[0],10)};throw new TypeError("Invalid PNM")},pam:t=>{const n={};for(;t.length>0;){const i=t.shift();if(i.length>16||i.charCodeAt(0)>128)continue;const[a,f]=i.split(" ");if(a&&f&&(n[a.toLowerCase()]=parseInt(f,10)),n.height&&n.width)break}if(n.height&&n.width)return{height:n.height,width:n.width};throw new TypeError("Invalid PAM")}},Fp={validate:t=>$r(t,0,2)in I0,calculate(t){const n=$r(t,0,2),i=I0[n],a=$r(t,3).split(/[\r\n]+/);return(M0[i]||M0.default)(a)}},kp={validate:t=>$r(t,0,4)==="8BPS",calculate:t=>({height:bn(t,14),width:bn(t,18)})},F0=/<svg\s([^>"']|"[^"]*"|'[^']*')*>/,fu={height:/\sheight=(['"])([^%]+?)\1/,root:F0,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/},qc=2.54,k0={in:96,cm:96/qc,em:16,ex:8,m:96/qc*100,mm:96/qc/10,pc:96/72/12,pt:96/72,px:1},Pp=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(k0).join("|")})?$`);function lu(t){const n=Pp.exec(t);if(!!n)return Math.round(Number(n[1])*(k0[n[2]]||1))}function Np(t){const n=t.split(" ");return{height:lu(n[3]),width:lu(n[2])}}function Bp(t){const n=t.match(fu.width),i=t.match(fu.height),a=t.match(fu.viewbox);return{height:i&&lu(i[2]),viewbox:a&&Np(a[2]),width:n&&lu(n[2])}}function Gp(t){return{height:t.height,width:t.width}}function Up(t,n){const i=n.width/n.height;return t.width?{height:Math.floor(t.width/i),width:t.width}:t.height?{height:t.height,width:Math.floor(t.height*i)}:{height:n.height,width:n.width}}const Yp={validate:t=>F0.test($r(t,0,1e3)),calculate(t){const n=$r(t).match(fu.root);if(n){const i=Bp(n[0]);if(i.width&&i.height)return Gp(i);if(i.viewbox)return Up(i,i.viewbox)}throw new TypeError("Invalid SVG")}},Hp={validate(t){return ti(t,0)===0&&ti(t,4)===0},calculate(t){return{height:ti(t,14),width:ti(t,12)}}};function zp(t,n){const i=Ui(t,32,4,n);return t.slice(i+2)}function Wp(t,n){const i=Ui(t,16,8,n);return(Ui(t,16,10,n)<<16)+i}function Vp(t){if(t.length>24)return t.slice(12)}function $p(t,n){const i={};let a=t;for(;a&&a.length;){const f=Ui(a,16,0,n),s=Ui(a,16,2,n),l=Ui(a,32,4,n);if(f===0)break;l===1&&(s===3||s===4)&&(i[f]=Wp(a,n)),a=Vp(a)}return i}function Zp(t){const n=$r(t,0,2);if(n==="II")return"LE";if(n==="MM")return"BE"}const Xp=["49492a00","4d4d002a"],qp={validate:t=>Xp.includes(Bs(t,0,4)),calculate(t){const n=Zp(t)==="BE",i=zp(t,n),a=$p(i,n),f=a[256],s=a[257];if(!f||!s)throw new TypeError("Invalid Tiff. Missing tags");return{height:s,width:f}}};function Kp(t){return{height:1+A0(t,7),width:1+A0(t,4)}}function jp(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function Qp(t){return{height:S0(t,8)&16383,width:S0(t,6)&16383}}const Jp={validate(t){const n=$r(t,0,4)==="RIFF",i=$r(t,8,12)==="WEBP",a=$r(t,12,15)==="VP8";return n&&i&&a},calculate(t){const n=$r(t,12,16);if(t=t.slice(20,30),n==="VP8X"){const a=t[0],f=(a&192)===0,s=(a&1)===0;if(f&&s)return Kp(t);throw new TypeError("Invalid WebP")}if(n==="VP8 "&&t[0]!==47)return Qp(t);const i=Bs(t,3,6);if(n==="VP8L"&&i!=="9d012a")return jp(t);throw new TypeError("Invalid WebP")}},uu=new Map([["bmp",ep],["cur",ap],["dds",op],["gif",fp],["heif",up],["icns",_p],["ico",D0],["j2c",pp],["jp2",mp],["jpg",Rp],["ktx",Cp],["png",Mp],["pnm",Fp],["psd",kp],["svg",Yp],["tga",Hp],["tiff",qp],["webp",Jp]]),em=Array.from(uu.keys()),tm=new Map([[56,"psd"],[66,"bmp"],[68,"dds"],[71,"gif"],[73,"tiff"],[77,"tiff"],[82,"webp"],[105,"icns"],[137,"png"],[255,"jpg"]]);function rm(t){const n=t[0],i=tm.get(n);return i&&uu.get(i).validate(t)?i:em.find(a=>uu.get(a).validate(t))}const nm={disabledTypes:[]};function im(t){var i;const n=rm(t);if(typeof n<"u"){if(nm.disabledTypes.indexOf(n)>-1)throw new TypeError("disabled file type: "+n);const a=uu.get(n).calculate(t);if(a!==void 0)return a.type=(i=a.type)!=null?i:n,a}throw new TypeError("unsupported file type: "+n)}var am=!1;const om=function(t,n){return(self.Image&&t instanceof self.Image||self.HTMLImageElement&&t instanceof self.HTMLImageElement)&&!t.complete?(n(null,new Error("\u4E0D\u652F\u6301\u7684\u683C\u5F0F")),!1):(di.imageHasData(t)?n&&n(t):sm(t,n),!0)};function sm(t,n){function i(l){try{var d=fm(l);t.exifdata=d||{};var v;n&&n(t)}catch(I){n(null,I)}}if(t.src)if(/^data\:/i.test(t.src)){var a=di.base64ToArrayBuffer(t.src);i(a)}else if(/^blob\:/i.test(t.src)){var f=new FileReader;f.onload=function(l){i(l.target.result)},di.objectURLToBlob(t.src,function(l){f.readAsArrayBuffer(l)})}else{var s=new XMLHttpRequest;s.onload=function(){if(this.status==200||this.status===0)i(s.response);else throw"Could not load image";s=null},s.open("GET",t.src,!0),s.responseType="arraybuffer",s.send(null)}else if(self.FileReader&&(t instanceof self.Blob||t instanceof self.File)){var f=new FileReader;f.onload=function(d){i(d.target.result)},f.readAsArrayBuffer(t)}}function fm(t){var n=new DataView(t);let i={};for(var a=2,f=t.byteLength,s;a<f&&n.getUint8(a)==255;){if(s=n.getUint8(a+1),s==225){i=lm(n,a+4,n.getUint16(a+2)-2);break}a+=2+n.getUint16(a+2)}let l=im(new Uint8Array(t));return Object.assign(i,{PixelXDimension:l.width,PixelYDimension:l.height}),i}function JS(t){if("DOMParser"in self){var n=new DataView(t);if(n.getUint8(0)!=255||n.getUint8(1)!=216)return!1;for(var i=2,a=t.byteLength,f=new DOMParser;i<a-4;)if(di.getStringFromDB(n,i,4)=="http"){var s=i-1,l=n.getUint16(i-2)-1,d=di.getStringFromDB(n,s,l),v=d.indexOf("xmpmeta>")+8;d=d.substring(d.indexOf("<x:xmpmeta"),v);var I=d.indexOf("x:xmpmeta")+10;d=d.slice(0,I)+'xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" xmlns:ext="http://www.gettyimages.com/xsltExtension/1.0" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/" xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" '+d.slice(I);var B=f.parseFromString(d,"text/xml");return di.xml2Object(B)}else i++}}function lm(t,n){if(di.getStringFromDB(t,n,4)!="Exif")return!1;var i,a,f,s,l,d=n+6;if(t.getUint16(d)==18761)i=!1;else if(t.getUint16(d)==19789)i=!0;else return!1;if(t.getUint16(d+2,!i)!=42)return!1;var v=t.getUint32(d+4,!i);if(v<8)return!1;if(a=Kc(t,d,d+v,Z_,i),a.ExifIFDPointer){s=Kc(t,d,d+a.ExifIFDPointer,X_,i);for(f in s){switch(f){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":s[f]=zf[f][s[f]];break;case"ExifVersion":case"FlashpixVersion":s[f]=String.fromCharCode(s[f][0],s[f][1],s[f][2],s[f][3]);break;case"ComponentsConfiguration":s[f]=zf.Components[s[f][0]]+zf.Components[s[f][1]]+zf.Components[s[f][2]]+zf.Components[s[f][3]];break}a[f]=s[f]}}if(a.GPSInfoIFDPointer){l=Kc(t,d,d+a.GPSInfoIFDPointer,q_,i);for(f in l){switch(f){case"GPSVersionID":l[f]=l[f][0]+"."+l[f][1]+"."+l[f][2]+"."+l[f][3];break}a[f]=l[f]}}return a}function Kc(t,n,i,a,f){var s=t.getUint16(i,!f),l={},d,v,I;for(I=0;I<s;I++)d=i+I*12+2,v=a[t.getUint16(d,!f)],l[v]=um(t,d,n,i,f);return l}function um(t,n,i,a,f){var s=t.getUint16(n+2,!f),l=t.getUint32(n+4,!f),d=t.getUint32(n+8,!f)+i,v,I,B,p,U,q;switch(s){case 1:case 7:if(l==1)return t.getUint8(n+8,!f);for(v=l>4?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint8(v+p);return I;case 2:return v=l>4?d:n+8,di.getStringFromDB(t,v,l-1);case 3:if(l==1)return t.getUint16(n+8,!f);for(v=l>2?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint16(v+2*p,!f);return I;case 4:if(l==1)return t.getUint32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getUint32(d+4*p,!f);return I;case 5:if(l==1)return U=t.getUint32(d,!f),q=t.getUint32(d+4,!f),B=new Number(U/q),B.numerator=U,B.denominator=q,B;for(I=[],p=0;p<l;p++)U=t.getUint32(d+8*p,!f),q=t.getUint32(d+4+8*p,!f),I[p]=new Number(U/q),I[p].numerator=U,I[p].denominator=q;return I;case 9:if(l==1)return t.getInt32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+4*p,!f);return I;case 10:if(l==1)return t.getInt32(d,!f)/t.getInt32(d+4,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+8*p,!f)/t.getInt32(d+4+8*p,!f);return I}}const cm=function(t){if(!di.imageHasData(t))return{};var n,i=t.exifdata,a={};for(n in i)i.hasOwnProperty(n)&&(a[n]=i[n]);return a},jc=t=>new Promise((n,i)=>{om(t,function(a,f){if(f){i(f);return}let s=cm(a),l=JSON.parse(JSON.stringify(s).replaceAll("\\u0000",""))||{};n(l)})});let cu;const hm=new Uint8Array(16);function dm(){if(!cu&&(cu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!cu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cu(hm)}const Bn=[];for(let t=0;t<256;++t)Bn.push((t+256).toString(16).slice(1));function vm(t,n=0){return(Bn[t[n+0]]+Bn[t[n+1]]+Bn[t[n+2]]+Bn[t[n+3]]+"-"+Bn[t[n+4]]+Bn[t[n+5]]+"-"+Bn[t[n+6]]+Bn[t[n+7]]+"-"+Bn[t[n+8]]+Bn[t[n+9]]+"-"+Bn[t[n+10]]+Bn[t[n+11]]+Bn[t[n+12]]+Bn[t[n+13]]+Bn[t[n+14]]+Bn[t[n+15]]).toLowerCase()}const P0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _m(t,n,i){if(P0.randomUUID&&!n&&!t)return P0.randomUUID();t=t||{};const a=t.random||(t.rng||dm)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){i=i||0;for(let f=0;f<16;++f)n[i+f]=a[f];return n}return vm(a)}//! moment.js
3
+ `,Ip="IHDR",O0="CgBI",Mp={validate(t){if(Op===$r(t,1,8)){let n=$r(t,12,16);if(n===O0&&(n=$r(t,28,32)),n!==Ip)throw new TypeError("Invalid PNG");return!0}return!1},calculate(t){return $r(t,12,16)===O0?{height:bn(t,36),width:bn(t,32)}:{height:bn(t,20),width:bn(t,16)}}},I0={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"},M0={default:t=>{let n=[];for(;t.length>0;){const i=t.shift();if(i[0]!=="#"){n=i.split(" ");break}}if(n.length===2)return{height:parseInt(n[1],10),width:parseInt(n[0],10)};throw new TypeError("Invalid PNM")},pam:t=>{const n={};for(;t.length>0;){const i=t.shift();if(i.length>16||i.charCodeAt(0)>128)continue;const[a,f]=i.split(" ");if(a&&f&&(n[a.toLowerCase()]=parseInt(f,10)),n.height&&n.width)break}if(n.height&&n.width)return{height:n.height,width:n.width};throw new TypeError("Invalid PAM")}},Fp={validate:t=>$r(t,0,2)in I0,calculate(t){const n=$r(t,0,2),i=I0[n],a=$r(t,3).split(/[\r\n]+/);return(M0[i]||M0.default)(a)}},kp={validate:t=>$r(t,0,4)==="8BPS",calculate:t=>({height:bn(t,14),width:bn(t,18)})},F0=/<svg\s([^>"']|"[^"]*"|'[^']*')*>/,fu={height:/\sheight=(['"])([^%]+?)\1/,root:F0,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/},qc=2.54,k0={in:96,cm:96/qc,em:16,ex:8,m:96/qc*100,mm:96/qc/10,pc:96/72/12,pt:96/72,px:1},Pp=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(k0).join("|")})?$`);function lu(t){const n=Pp.exec(t);if(!!n)return Math.round(Number(n[1])*(k0[n[2]]||1))}function Np(t){const n=t.split(" ");return{height:lu(n[3]),width:lu(n[2])}}function Bp(t){const n=t.match(fu.width),i=t.match(fu.height),a=t.match(fu.viewbox);return{height:i&&lu(i[2]),viewbox:a&&Np(a[2]),width:n&&lu(n[2])}}function Gp(t){return{height:t.height,width:t.width}}function Up(t,n){const i=n.width/n.height;return t.width?{height:Math.floor(t.width/i),width:t.width}:t.height?{height:t.height,width:Math.floor(t.height*i)}:{height:n.height,width:n.width}}const Yp={validate:t=>F0.test($r(t,0,1e3)),calculate(t){const n=$r(t).match(fu.root);if(n){const i=Bp(n[0]);if(i.width&&i.height)return Gp(i);if(i.viewbox)return Up(i,i.viewbox)}throw new TypeError("Invalid SVG")}},Hp={validate(t){return ti(t,0)===0&&ti(t,4)===0},calculate(t){return{height:ti(t,14),width:ti(t,12)}}};function zp(t,n){const i=Ui(t,32,4,n);return t.slice(i+2)}function Wp(t,n){const i=Ui(t,16,8,n);return(Ui(t,16,10,n)<<16)+i}function Vp(t){if(t.length>24)return t.slice(12)}function $p(t,n){const i={};let a=t;for(;a&&a.length;){const f=Ui(a,16,0,n),s=Ui(a,16,2,n),l=Ui(a,32,4,n);if(f===0)break;l===1&&(s===3||s===4)&&(i[f]=Wp(a,n)),a=Vp(a)}return i}function Zp(t){const n=$r(t,0,2);if(n==="II")return"LE";if(n==="MM")return"BE"}const Xp=["49492a00","4d4d002a"],qp={validate:t=>Xp.includes(Bs(t,0,4)),calculate(t){const n=Zp(t)==="BE",i=zp(t,n),a=$p(i,n),f=a[256],s=a[257];if(!f||!s)throw new TypeError("Invalid Tiff. Missing tags");return{height:s,width:f}}};function Kp(t){return{height:1+A0(t,7),width:1+A0(t,4)}}function jp(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function Qp(t){return{height:S0(t,8)&16383,width:S0(t,6)&16383}}const Jp={validate(t){const n=$r(t,0,4)==="RIFF",i=$r(t,8,12)==="WEBP",a=$r(t,12,15)==="VP8";return n&&i&&a},calculate(t){const n=$r(t,12,16);if(t=t.slice(20,30),n==="VP8X"){const a=t[0],f=(a&192)===0,s=(a&1)===0;if(f&&s)return Kp(t);throw new TypeError("Invalid WebP")}if(n==="VP8 "&&t[0]!==47)return Qp(t);const i=Bs(t,3,6);if(n==="VP8L"&&i!=="9d012a")return jp(t);throw new TypeError("Invalid WebP")}},uu=new Map([["bmp",ep],["cur",ap],["dds",op],["gif",fp],["heif",up],["icns",_p],["ico",D0],["j2c",pp],["jp2",mp],["jpg",Rp],["ktx",Cp],["png",Mp],["pnm",Fp],["psd",kp],["svg",Yp],["tga",Hp],["tiff",qp],["webp",Jp]]),em=Array.from(uu.keys()),tm=new Map([[56,"psd"],[66,"bmp"],[68,"dds"],[71,"gif"],[73,"tiff"],[77,"tiff"],[82,"webp"],[105,"icns"],[137,"png"],[255,"jpg"]]);function rm(t){const n=t[0],i=tm.get(n);return i&&uu.get(i).validate(t)?i:em.find(a=>uu.get(a).validate(t))}const nm={disabledTypes:[]};function im(t){var i;const n=rm(t);if(typeof n<"u"){if(nm.disabledTypes.indexOf(n)>-1)throw new TypeError("disabled file type: "+n);const a=uu.get(n).calculate(t);if(a!==void 0)return a.type=(i=a.type)!=null?i:n,a}throw new TypeError("unsupported file type: "+n)}var am=!1;const om=function(t,n){return(self.Image&&t instanceof self.Image||self.HTMLImageElement&&t instanceof self.HTMLImageElement)&&!t.complete?(n(null,new Error("\u4E0D\u652F\u6301\u7684\u683C\u5F0F")),!1):(di.imageHasData(t)?n&&n(t):sm(t,n),!0)};function sm(t,n){function i(l){try{var d=fm(l);t.exifdata=d||{};var v;n&&n(t)}catch(I){n(null,I)}}if(t.src)if(/^data\:/i.test(t.src)){var a=di.base64ToArrayBuffer(t.src);i(a)}else if(/^blob\:/i.test(t.src)){var f=new FileReader;f.onload=function(l){i(l.target.result)},di.objectURLToBlob(t.src,function(l){f.readAsArrayBuffer(l)})}else{var s=new XMLHttpRequest;s.onload=function(){if(this.status==200||this.status===0)i(s.response);else throw"Could not load image";s=null},s.open("GET",t.src,!0),s.responseType="arraybuffer",s.send(null)}else if(self.FileReader&&(t instanceof self.Blob||t instanceof self.File)){var f=new FileReader;f.onload=function(d){i(d.target.result)},f.readAsArrayBuffer(t)}}function fm(t){var n=new DataView(t);let i={};if(n.getUint8(0)!=255||n.getUint8(1)!=216)return!1;for(var a=2,f=t.byteLength,s;a<f&&n.getUint8(a)==255;){if(s=n.getUint8(a+1),s==225){i=lm(n,a+4,n.getUint16(a+2)-2);let l=im(new Uint8Array(t));return Object.assign(i,{PixelXDimension:l.width,PixelYDimension:l.height}),i}a+=2+n.getUint16(a+2)}return i}function JS(t){if("DOMParser"in self){var n=new DataView(t);if(n.getUint8(0)!=255||n.getUint8(1)!=216)return!1;for(var i=2,a=t.byteLength,f=new DOMParser;i<a-4;)if(di.getStringFromDB(n,i,4)=="http"){var s=i-1,l=n.getUint16(i-2)-1,d=di.getStringFromDB(n,s,l),v=d.indexOf("xmpmeta>")+8;d=d.substring(d.indexOf("<x:xmpmeta"),v);var I=d.indexOf("x:xmpmeta")+10;d=d.slice(0,I)+'xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" xmlns:ext="http://www.gettyimages.com/xsltExtension/1.0" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/" xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" '+d.slice(I);var B=f.parseFromString(d,"text/xml");return di.xml2Object(B)}else i++}}function lm(t,n){if(di.getStringFromDB(t,n,4)!="Exif")return!1;var i,a,f,s,l,d=n+6;if(t.getUint16(d)==18761)i=!1;else if(t.getUint16(d)==19789)i=!0;else return!1;if(t.getUint16(d+2,!i)!=42)return!1;var v=t.getUint32(d+4,!i);if(v<8)return!1;if(a=Kc(t,d,d+v,Z_,i),a.ExifIFDPointer){s=Kc(t,d,d+a.ExifIFDPointer,X_,i);for(f in s){switch(f){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":s[f]=zf[f][s[f]];break;case"ExifVersion":case"FlashpixVersion":s[f]=String.fromCharCode(s[f][0],s[f][1],s[f][2],s[f][3]);break;case"ComponentsConfiguration":s[f]=zf.Components[s[f][0]]+zf.Components[s[f][1]]+zf.Components[s[f][2]]+zf.Components[s[f][3]];break}a[f]=s[f]}}if(a.GPSInfoIFDPointer){l=Kc(t,d,d+a.GPSInfoIFDPointer,q_,i);for(f in l){switch(f){case"GPSVersionID":l[f]=l[f][0]+"."+l[f][1]+"."+l[f][2]+"."+l[f][3];break}a[f]=l[f]}}return a}function Kc(t,n,i,a,f){var s=t.getUint16(i,!f),l={},d,v,I;for(I=0;I<s;I++)d=i+I*12+2,v=a[t.getUint16(d,!f)],l[v]=um(t,d,n,i,f);return l}function um(t,n,i,a,f){var s=t.getUint16(n+2,!f),l=t.getUint32(n+4,!f),d=t.getUint32(n+8,!f)+i,v,I,B,p,U,q;switch(s){case 1:case 7:if(l==1)return t.getUint8(n+8,!f);for(v=l>4?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint8(v+p);return I;case 2:return v=l>4?d:n+8,di.getStringFromDB(t,v,l-1);case 3:if(l==1)return t.getUint16(n+8,!f);for(v=l>2?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint16(v+2*p,!f);return I;case 4:if(l==1)return t.getUint32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getUint32(d+4*p,!f);return I;case 5:if(l==1)return U=t.getUint32(d,!f),q=t.getUint32(d+4,!f),B=new Number(U/q),B.numerator=U,B.denominator=q,B;for(I=[],p=0;p<l;p++)U=t.getUint32(d+8*p,!f),q=t.getUint32(d+4+8*p,!f),I[p]=new Number(U/q),I[p].numerator=U,I[p].denominator=q;return I;case 9:if(l==1)return t.getInt32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+4*p,!f);return I;case 10:if(l==1)return t.getInt32(d,!f)/t.getInt32(d+4,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+8*p,!f)/t.getInt32(d+4+8*p,!f);return I}}const cm=function(t){if(!di.imageHasData(t))return{};var n,i=t.exifdata,a={};for(n in i)i.hasOwnProperty(n)&&(a[n]=i[n]);return a},jc=t=>new Promise((n,i)=>{om(t,function(a,f){if(f){i(f);return}let s=cm(a),l=JSON.parse(JSON.stringify(s).replaceAll("\\u0000",""))||{};n(l)})});let cu;const hm=new Uint8Array(16);function dm(){if(!cu&&(cu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!cu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cu(hm)}const Bn=[];for(let t=0;t<256;++t)Bn.push((t+256).toString(16).slice(1));function vm(t,n=0){return(Bn[t[n+0]]+Bn[t[n+1]]+Bn[t[n+2]]+Bn[t[n+3]]+"-"+Bn[t[n+4]]+Bn[t[n+5]]+"-"+Bn[t[n+6]]+Bn[t[n+7]]+"-"+Bn[t[n+8]]+Bn[t[n+9]]+"-"+Bn[t[n+10]]+Bn[t[n+11]]+Bn[t[n+12]]+Bn[t[n+13]]+Bn[t[n+14]]+Bn[t[n+15]]).toLowerCase()}const P0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _m(t,n,i){if(P0.randomUUID&&!n&&!t)return P0.randomUUID();t=t||{};const a=t.random||(t.rng||dm)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){i=i||0;for(let f=0;f<16;++f)n[i+f]=a[f];return n}return vm(a)}//! moment.js
4
4
  //! version : 2.29.4
5
5
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
6
6
  //! license : MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcatch/util",
3
- "version": "1.0.8-a",
3
+ "version": "1.0.8",
4
4
  "main": "./dist/catchUtil.min.esm.js",
5
5
  "repository": "",
6
6
  "author": "wanyanyan",
@@ -87,6 +87,10 @@ function findEXIFinJPEG(file) {
87
87
  var dataView = new DataView(file);
88
88
  let exif = {}
89
89
 
90
+ if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
91
+ return false; // not a valid jpeg
92
+ }
93
+
90
94
  var offset = 2,
91
95
  length = file.byteLength,
92
96
  marker;
@@ -103,15 +107,15 @@ function findEXIFinJPEG(file) {
103
107
 
104
108
  if (marker == 225) {
105
109
  exif = readEXIFData(dataView, offset + 4, dataView.getUint16(offset + 2) - 2)
106
- break
110
+ let size = imageSize(new Uint8Array(file))
111
+ Object.assign(exif, {
112
+ PixelXDimension: size.width,
113
+ PixelYDimension: size.height
114
+ })
115
+ return exif
107
116
  }
108
117
  offset += 2 + dataView.getUint16(offset + 2);
109
118
  }
110
- let size = imageSize(new Uint8Array(file))
111
- Object.assign(exif, {
112
- PixelXDimension: size.width,
113
- PixelYDimension: size.height
114
- })
115
119
  return exif
116
120
 
117
121
  }