@kaeawc/auto-mobile 0.0.87 → 0.0.88
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.
- package/README.md +3 -3
- package/README.md.backup +3 -3
- package/dist/build-info.json +10 -10
- package/dist/schemas/test-plan.schema.json +256 -0
- package/dist/src/index.js +1147 -1066
- package/dist/src/utils/workers/iosBundleExtractWorker.js +3 -3
- package/node_modules/strtok3/README.md +161 -10
- package/node_modules/strtok3/lib/BufferTokenizer.js +1 -1
- package/node_modules/strtok3/lib/FileTokenizer.js +8 -2
- package/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
- package/node_modules/strtok3/lib/ReadStreamTokenizer.js +7 -2
- package/node_modules/strtok3/lib/TokenizerBoundaryError.js +10 -0
- package/node_modules/strtok3/lib/TokenizerView.js +184 -0
- package/node_modules/strtok3/lib/core.js +5 -18
- package/node_modules/strtok3/lib/index.js +1 -0
- package/node_modules/strtok3/lib/isRandomAccessTokenizer.js +10 -0
- package/node_modules/strtok3/package.json +10 -8
- package/package.json +11 -11
- package/schemas/test-plan.schema.json +256 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`).slice(0,3).join(" \u2190 "),X="cause"in q&&q.cause!==void 0?Iq(q.cause):"";return[Q||"Error",J,X?`cause=${X}`:""].filter(Boolean).join(" | ")}if(q===null||q===void 0)return String(q);if(typeof q==="object"){if(Object.keys(q).length===0)return`${Object.prototype.toString.call(q)} (no enumerable keys)`;return Wq(()=>JSON.stringify(q),()=>Object.prototype.toString.call(q))}return String(q)}function a(q){return Wq(()=>{if(q instanceof Error)return q.message;return String(q)},()=>Wq(()=>Object.prototype.toString.call(q),()=>"Unknown error"))}var Xq=()=>{};function rW(q,Q){if(q instanceof c)return q;let J=a(q);return new c(`${Q}: ${J}`,{cause:q})}function aW(q,Q){return new c(`${Q} is not supported on platform '${q}'. Supported platforms: android, ios.`)}var c;var jq=r(()=>{Xq();c=class c extends Error{constructor(q,Q){super(q,Q);let J=Q?.containerFailure??(Q?.cause instanceof c?Q.cause.containerFailure:void 0);if(J)this.containerFailure=J}}});import*as Fq from"path";function Yq(q,Q,J={}){let X=J.paths??Fq,G=X.resolve(q),Z=X.resolve(G,Q),Y=X.relative(G,Z);if(Y==="")return J.allowEqual??!0;return!(Y===".."||Y.startsWith(`..${X.sep}`)||X.isAbsolute(Y))}function tW(q,Q,J,X={}){if(!Yq(q,Q,X))throw J();let G=X.paths??Fq;return G.resolve(G.resolve(q),Q)}var Oq=()=>{};import*as Sq from"path";function wq(q,Q,J="CtrlProxy bundle"){let X=Sq.resolve(Q);for(let G of q.getEntries())if(!Yq(X,G.entryName))throw new c(`Refusing to extract ${J}: entry "${G.entryName}" resolves outside the extraction directory ${X} (zip-slip / path traversal).`)}var Dq=r(()=>{jq();Oq()});var $q=_((X0,Bq)=>{Bq.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var e=_((Nq)=>{var Lq={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",MAX_OUTPUT_EXCEEDED:"Decompressed data exceeds the declared uncompressed size",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DUPLICATE_ENTRY:"Duplicate entry name {0}",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",ZIP64_VALUE_TOO_LARGE:"Zip64 value exceeds the maximum safe integer",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function AW(q){return function(...Q){if(Q.length)q=q.replace(/\{(\d)\}/g,(J,X)=>Q[X]||"");return Error("ADM-ZIP: "+q)}}for(let q of Object.keys(Lq))Nq[q]=AW(Lq[q])});var zq=_(($0,Eq)=>{var IW=d("fs"),C=d("path"),xq=$q(),Gq=e(),jW=typeof process==="object"&&process.platform==="win32",Uq=(q)=>typeof q==="object"&&q!==null,Hq=new Uint32Array(256).map((q,Q)=>{for(let J=0;J<8;J++)if((Q&1)!==0)Q=3988292384^Q>>>1;else Q>>>=1;return Q>>>0});function g(q){if(this.sep=C.sep,this.fs=IW,Uq(q)){if(Uq(q.fs)&&typeof q.fs.statSync==="function")this.fs=q.fs}}Eq.exports=g;g.prototype.makeDir=function(q){let Q=this;function J(X){let G=X.split(Q.sep)[0];X.split(Q.sep).forEach(function(Z){if(!Z||Z.substr(-1,1)===":")return;G+=Q.sep+Z;var Y;try{Y=Q.fs.statSync(G)}catch(A){if(A.message&&A.message.startsWith("ENOENT"))Q.fs.mkdirSync(G);else throw A}if(Y&&Y.isFile())throw Gq.FILE_IN_THE_WAY(`"${G}"`)})}J(q)};g.prototype.writeFileTo=function(q,Q,J,X){let G=this;if(G.fs.existsSync(q)){if(!J)return!1;var Z=G.fs.statSync(q);if(Z.isDirectory())return!1}var Y=C.dirname(q);if(!G.fs.existsSync(Y))G.makeDir(Y);var A;try{A=G.fs.openSync(q,"w",438)}catch(L){G.fs.chmodSync(q,438),A=G.fs.openSync(q,"w",438)}if(A)try{G.fs.writeSync(A,Q,0,Q.length,0)}finally{G.fs.closeSync(A)}return G.fs.chmodSync(q,X||438),!0};g.prototype.writeFileToAsync=function(q,Q,J,X,G){if(typeof X==="function")G=X,X=void 0;let Z=this;Z.fs.exists(q,function(Y){if(Y&&!J)return G(!1);Z.fs.stat(q,function(A,L){if(Y&&L&&L.isDirectory())return G(!1);var N=C.dirname(q);Z.fs.exists(N,function(D){if(!D)try{Z.makeDir(N)}catch(x){return G(!1)}let B=function(x){Z.fs.write(x,Q,0,Q.length,0,function(U){Z.fs.close(x,function(){if(U)return G(!1);Z.fs.chmod(q,X||438,function(){G(!0)})})})};Z.fs.open(q,"w",438,function(x,U){if(x)Z.fs.chmod(q,438,function(){Z.fs.open(q,"w",438,function($,M){if($||!M)return G(!1);B(M)})});else if(U)B(U);else G(!1)})})})})};g.prototype.assertPathSafe=function(q,Q){let J=this;if(typeof J.fs.lstatSync!=="function")return;let X=C.resolve(q),G=C.resolve(Q);if(G===X)return;let Z=C.relative(X,G);if(!Z||Z===".."||Z.startsWith(".."+C.sep)||C.isAbsolute(Z))return;let Y=X;for(let A of Z.split(C.sep)){if(!A||A===".")continue;Y=C.join(Y,A);let L;try{L=J.fs.lstatSync(Y)}catch(N){break}if(L.isSymbolicLink())throw Gq.FILE_IN_THE_WAY(`"${Y}"`)}};g.prototype.findFiles=function(q){let Q=this,J=typeof Q.fs.lstatSync==="function",X=Q.fs.realpathSync(q);function G(Y){if(!J)return!1;if(!Q.fs.lstatSync(Y).isSymbolicLink())return!1;let A;try{A=Q.fs.realpathSync(Y)}catch(L){return!0}return!(A===X||A.startsWith(X+C.sep))}function Z(Y,A,L,N){if(typeof A==="boolean")L=A,A=void 0;let D=[];return Q.fs.readdirSync(Y).forEach(function(B){let x=C.join(Y,B);if(G(x))return;let U=Q.fs.statSync(x);if(!A||A.test(x))D.push(C.normalize(x)+(U.isDirectory()?Q.sep:""));if(U.isDirectory()&&L){let $=Q.fs.realpathSync(x);if(!N.has($))N.add($),D=D.concat(Z(x,A,L,N))}}),D}return Z(q,void 0,!0,new Set([X]))};g.prototype.findFilesAsync=function(q,Q){let J=this,X=[],G=!1,Z=function(D){if(G)return;G=!0,Q(D,D?void 0:X)},Y=typeof J.fs.lstat==="function",A=null,L=function(D,B){if(!Y)return B(null,!1);J.fs.lstat(D,function(x,U){if(x)return B(x);if(!U||!U.isSymbolicLink())return B(null,!1);J.fs.realpath(D,function($,M){if($)return B(null,!0);B(null,!(M===A||M.startsWith(A+C.sep)))})})},N=function(D,B,x){J.fs.readdir(D,function(U,$){if(U)return x(U);let M=$.length;if(!M)return x();$.forEach(function(K){let T=C.join(D,K);L(T,function(R,W){if(R)return x(R);if(W){if(!--M)x();return}J.fs.stat(T,function(V,j){if(V)return x(V);if(!j){if(!--M)x();return}if(X.push(C.normalize(T)+(j.isDirectory()?J.sep:"")),!j.isDirectory()){if(!--M)x();return}J.fs.realpath(T,function(O,F){if(O)return x(O);if(B.has(F)){if(!--M)x();return}B.add(F),N(T,B,function(S){if(S)return x(S);if(!--M)x()})})})})})})};J.fs.realpath(q,function(D,B){if(D)return Z(D);A=B,N(q,new Set([B]),Z)})};g.prototype.getAttributes=function(){};g.prototype.setAttributes=function(){};g.crc32update=function(q,Q){return Hq[(q^Q)&255]^q>>>8};g.crc32=function(q){if(typeof q==="string")q=Buffer.from(q,"utf8");let Q=q.length,J=-1;for(let X=0;X<Q;)J=g.crc32update(J,q[X++]);return~J>>>0};g.methodToString=function(q){switch(q){case xq.STORED:return"STORED ("+q+")";case xq.DEFLATED:return"DEFLATED ("+q+")";default:return"UNSUPPORTED ("+q+")"}};g.canonical=function(q){if(!q)return"";let Q=C.posix.normalize("/"+q.split("\\").join("/"));return C.join(".",Q)};g.zipnamefix=function(q){if(!q)return"";let Q=C.posix.normalize("/"+q.split("\\").join("/"));return C.posix.join(".",Q)};g.findLast=function(q,Q){if(!Array.isArray(q))throw TypeError("arr is not array");let J=q.length>>>0;for(let X=J-1;X>=0;X--)if(Q(q[X],X,q))return q[X];return};g.sanitize=function(q,Q){q=C.resolve(C.normalize(q));var J=Q.split("/");for(var X=0,G=J.length;X<G;X++){var Z=C.normalize(C.join(q,J.slice(X,G).join(C.sep)));if(Z===q||Z.startsWith(q+C.sep))return Z}return C.normalize(C.join(q,C.basename(Q)))};g.toBuffer=function(Q,J){if(Buffer.isBuffer(Q))return Q;else if(Q instanceof Uint8Array)return Buffer.from(Q);else return typeof Q==="string"?J(Q):Buffer.alloc(0)};g.readBigUInt64LE=function(q,Q){let J=q.readUInt32LE(Q),G=q.readUInt32LE(Q+4)*4294967296+J;if(G>Number.MAX_SAFE_INTEGER)throw Gq.ZIP64_VALUE_TOO_LARGE();return G};g.writeBigUInt64LE=function(q,Q,J){let X=Q>>>0,G=Math.floor(Q/4294967296)>>>0;q.writeUInt32LE(X,J),q.writeUInt32LE(G,J+4)};g.fromDOS2Date=function(q){return new Date((q>>25&127)+1980,Math.max((q>>21&15)-1,0),Math.max(q>>16&31,1),q>>11&31,q>>5&63,(q&31)<<1)};g.fromDate2DOS=function(q){let Q=0,J=0;if(q.getFullYear()>1979)Q=(q.getFullYear()-1980&127)<<9|q.getMonth()+1<<5|q.getDate(),J=q.getHours()<<11|q.getMinutes()<<5|q.getSeconds()>>1;return Q<<16|J};g.isWin=jW;g.crcTable=Hq});var Pq=_((G0,Cq)=>{var FW=d("path");Cq.exports=function(q,{fs:Q}){var J=q||"",X=Z(),G=null;function Z(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(J&&Q.existsSync(J))G=Q.statSync(J),X.directory=G.isDirectory(),X.mtime=G.mtime,X.atime=G.atime,X.executable=(73&G.mode)!==0,X.readonly=(128&G.mode)===0,X.hidden=FW.basename(J)[0]===".";else console.warn("Invalid path: "+J);return{get directory(){return X.directory},get readOnly(){return X.readonly},get hidden(){return X.hidden},get mtime(){return X.mtime},get atime(){return X.atime},get executable(){return X.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:J,isDirectory:X.directory,isReadOnly:X.readonly,isHidden:X.hidden,isExecutable:X.executable,mTime:X.mtime,aTime:X.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var kq=_((M0,gq)=>{gq.exports={efs:!0,encode:(q)=>Buffer.from(q,"utf8"),decode:(q)=>q.toString("utf8")}});var s=_((K0,i)=>{i.exports=zq();i.exports.Constants=$q();i.exports.Errors=e();i.exports.FileAttr=Pq();i.exports.decoder=kq()});var bq=_((V0,vq)=>{var f=s(),I=f.Constants;vq.exports=function(){var q=20,Q=10,J=0,X=0,G=0,Z=0,Y=0,A=0,L=0,N=0,D=0,B=0,x=0,U=0,$=0;q|=f.isWin?2560:768,J|=I.FLG_EFS;let M={extraLen:0},K=(W)=>Math.max(0,W)>>>0,T=(W)=>Math.max(0,W)&65535,R=(W)=>Math.max(0,W)&255;return G=f.fromDate2DOS(new Date),{get made(){return q},set made(W){q=W},get version(){return Q},set version(W){Q=W},get flags(){return J},set flags(W){J=W},get flags_efs(){return(J&I.FLG_EFS)>0},set flags_efs(W){if(W)J|=I.FLG_EFS;else J&=~I.FLG_EFS},get flags_desc(){return(J&I.FLG_DESC)>0},set flags_desc(W){if(W)J|=I.FLG_DESC;else J&=~I.FLG_DESC},get method(){return X},set method(W){switch(W){case I.STORED:this.version=10;break;case I.DEFLATED:default:this.version=20}X=W},get time(){return f.fromDOS2Date(this.timeval)},set time(W){W=new Date(W),this.timeval=f.fromDate2DOS(W)},get timeval(){return G},set timeval(W){G=K(W)},get timeHighByte(){return R(G>>>8)},get crc(){return Z},set crc(W){Z=K(W)},get compressedSize(){return Y},set compressedSize(W){Y=K(W)},get size(){return A},set size(W){A=K(W)},get fileNameLength(){return L},set fileNameLength(W){L=W},get extraLength(){return N},set extraLength(W){N=W},get extraLocalLength(){return M.extraLen},set extraLocalLength(W){M.extraLen=W},get commentLength(){return D},set commentLength(W){D=W},get diskNumStart(){return B},set diskNumStart(W){B=K(W)},get inAttr(){return x},set inAttr(W){x=K(W)},get attr(){return U},set attr(W){U=K(W)},get fileAttr(){return(U||0)>>16&511},get offset(){return $},set offset(W){$=K(W)},get encrypted(){return(J&I.FLG_ENC)===I.FLG_ENC},get centralHeaderSize(){return I.CENHDR+L+N+D},get realDataOffset(){return $+I.LOCHDR+M.fnameLen+M.extraLen},get localHeader(){return M},loadLocalHeaderFromBinary:function(W){if($<0||$+I.LOCHDR>W.length)throw f.Errors.INVALID_LOC();var V=W.slice($,$+I.LOCHDR);if(V.readUInt32LE(0)!==I.LOCSIG)throw f.Errors.INVALID_LOC();M.version=V.readUInt16LE(I.LOCVER),M.flags=V.readUInt16LE(I.LOCFLG),M.flags_desc=(M.flags&I.FLG_DESC)>0,M.method=V.readUInt16LE(I.LOCHOW),M.time=V.readUInt32LE(I.LOCTIM),M.crc=V.readUInt32LE(I.LOCCRC),M.compressedSize=V.readUInt32LE(I.LOCSIZ),M.size=V.readUInt32LE(I.LOCLEN),M.fnameLen=V.readUInt16LE(I.LOCNAM),M.extraLen=V.readUInt16LE(I.LOCEXT);let j=$+I.LOCHDR+M.fnameLen,O=j+M.extraLen;return W.slice(j,O)},loadFromBinary:function(W){if(W.length!==I.CENHDR||W.readUInt32LE(0)!==I.CENSIG)throw f.Errors.INVALID_CEN();q=W.readUInt16LE(I.CENVEM),Q=W.readUInt16LE(I.CENVER),J=W.readUInt16LE(I.CENFLG),X=W.readUInt16LE(I.CENHOW),G=W.readUInt32LE(I.CENTIM),Z=W.readUInt32LE(I.CENCRC),Y=W.readUInt32LE(I.CENSIZ),A=W.readUInt32LE(I.CENLEN),L=W.readUInt16LE(I.CENNAM),N=W.readUInt16LE(I.CENEXT),D=W.readUInt16LE(I.CENCOM),B=W.readUInt16LE(I.CENDSK),x=W.readUInt16LE(I.CENATT),U=W.readUInt32LE(I.CENATX),$=W.readUInt32LE(I.CENOFF)},localHeaderToBinary:function(){var W=Buffer.alloc(I.LOCHDR);return W.writeUInt32LE(I.LOCSIG,0),W.writeUInt16LE(Q,I.LOCVER),W.writeUInt16LE(J&~I.FLG_DESC,I.LOCFLG),W.writeUInt16LE(X,I.LOCHOW),W.writeUInt32LE(G,I.LOCTIM),W.writeUInt32LE(Z,I.LOCCRC),W.writeUInt32LE(Y,I.LOCSIZ),W.writeUInt32LE(A,I.LOCLEN),W.writeUInt16LE(L,I.LOCNAM),W.writeUInt16LE(M.extraLen,I.LOCEXT),W},centralHeaderToBinary:function(){var W=Buffer.alloc(I.CENHDR+L+N+D);return W.writeUInt32LE(I.CENSIG,0),W.writeUInt16LE(q,I.CENVEM),W.writeUInt16LE(Q,I.CENVER),W.writeUInt16LE(J&~I.FLG_DESC,I.CENFLG),W.writeUInt16LE(X,I.CENHOW),W.writeUInt32LE(G,I.CENTIM),W.writeUInt32LE(Z,I.CENCRC),W.writeUInt32LE(Y,I.CENSIZ),W.writeUInt32LE(A,I.CENLEN),W.writeUInt16LE(L,I.CENNAM),W.writeUInt16LE(N,I.CENEXT),W.writeUInt16LE(D,I.CENCOM),W.writeUInt16LE(B,I.CENDSK),W.writeUInt16LE(x,I.CENATT),W.writeUInt32LE(U,I.CENATX),W.writeUInt32LE($,I.CENOFF),W},toJSON:function(){let W=function(V){return V+" bytes"};return{made:q,version:Q,flags:J,method:f.methodToString(X),time:this.time,crc:"0x"+Z.toString(16).toUpperCase(),compressedSize:W(Y),size:W(A),fileNameLength:W(L),extraLength:W(N),commentLength:W(D),diskNumStart:B,inAttr:x,attr:U,offset:$,centralHeaderSize:W(I.CENHDR+L+N+D)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var _q=_((T0,uq)=>{var m=s(),w=m.Constants;uq.exports=function(){var q=0,Q=0,J=0,X=0,G=0;let Z=()=>q>w.EF_ZIP64_OR_16||Q>w.EF_ZIP64_OR_16||J>w.EF_ZIP64_OR_32||X>w.EF_ZIP64_OR_32;return{get diskEntries(){return q},set diskEntries(Y){q=Q=Y},get totalEntries(){return Q},set totalEntries(Y){Q=q=Y},get size(){return J},set size(Y){J=Y},get offset(){return X},set offset(Y){X=Y},get commentLength(){return G},set commentLength(Y){G=Y},get mainHeaderSize(){return(Z()?w.ZIP64HDR+w.END64HDR:0)+w.ENDHDR+G},loadFromBinary:function(Y){if((Y.length!==w.ENDHDR||Y.readUInt32LE(0)!==w.ENDSIG)&&(Y.length<w.ZIP64HDR||Y.readUInt32LE(0)!==w.ZIP64SIG))throw m.Errors.INVALID_END();if(Y.readUInt32LE(0)===w.ENDSIG)q=Y.readUInt16LE(w.ENDSUB),Q=Y.readUInt16LE(w.ENDTOT),J=Y.readUInt32LE(w.ENDSIZ),X=Y.readUInt32LE(w.ENDOFF),G=Y.readUInt16LE(w.ENDCOM);else q=m.readBigUInt64LE(Y,w.ZIP64SUB),Q=m.readBigUInt64LE(Y,w.ZIP64TOT),J=m.readBigUInt64LE(Y,w.ZIP64SIZB),X=m.readBigUInt64LE(Y,w.ZIP64OFF),G=0},toBinary:function(){if(!Z()){var Y=Buffer.alloc(w.ENDHDR+G);return Y.writeUInt32LE(w.ENDSIG,0),Y.writeUInt32LE(0,4),Y.writeUInt16LE(q,w.ENDSUB),Y.writeUInt16LE(Q,w.ENDTOT),Y.writeUInt32LE(J,w.ENDSIZ),Y.writeUInt32LE(X,w.ENDOFF),Y.writeUInt16LE(G,w.ENDCOM),Y.fill(" ",w.ENDHDR),Y}var Y=Buffer.alloc(this.mainHeaderSize);let A=0;Y.writeUInt32LE(w.ZIP64SIG,A),m.writeBigUInt64LE(Y,w.ZIP64HDR-w.ZIP64LEAD,A+w.ZIP64SIZE),Y.writeUInt16LE(45,A+w.ZIP64VEM),Y.writeUInt16LE(45,A+w.ZIP64VER),Y.writeUInt32LE(0,A+w.ZIP64DSK),Y.writeUInt32LE(0,A+w.ZIP64DSKDIR),m.writeBigUInt64LE(Y,q,A+w.ZIP64SUB),m.writeBigUInt64LE(Y,Q,A+w.ZIP64TOT),m.writeBigUInt64LE(Y,J,A+w.ZIP64SIZB),m.writeBigUInt64LE(Y,X,A+w.ZIP64OFF);let L=X+J;return A+=w.ZIP64HDR,Y.writeUInt32LE(w.END64SIG,A),Y.writeUInt32LE(0,A+w.END64START),m.writeBigUInt64LE(Y,L,A+w.END64OFF),Y.writeUInt32LE(1,A+w.END64NUMDISKS),A+=w.END64HDR,Y.writeUInt32LE(w.ENDSIG,A),Y.writeUInt32LE(0,A+4),Y.writeUInt16LE(Math.min(q,w.EF_ZIP64_OR_16),A+w.ENDSUB),Y.writeUInt16LE(Math.min(Q,w.EF_ZIP64_OR_16),A+w.ENDTOT),Y.writeUInt32LE(Math.min(J,w.EF_ZIP64_OR_32),A+w.ENDSIZ),Y.writeUInt32LE(Math.min(X,w.EF_ZIP64_OR_32),A+w.ENDOFF),Y.writeUInt16LE(G,A+w.ENDCOM),Y.fill(" ",A+w.ENDHDR),Y},toJSON:function(){let Y=function(A,L){let N=A.toString(16).toUpperCase();while(N.length<L)N="0"+N;return"0x"+N};return{diskEntries:q,totalEntries:Q,size:J+" bytes",offset:Y(X,4),commentLength:G}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Mq=_((OW)=>{OW.EntryHeader=bq();OW.MainHeader=_q()});var hq=_((R0,yq)=>{yq.exports=function(q){var Q=d("zlib"),J={chunkSize:(parseInt(q.length/1024)+1)*1024};return{deflate:function(){return Q.deflateRawSync(q,J)},deflateAsync:function(X){var G=Q.createDeflateRaw(J),Z=[],Y=0;G.on("data",function(A){Z.push(A),Y+=A.length}),G.on("end",function(){var A=Buffer.alloc(Y),L=0;A.fill(0);for(var N=0;N<Z.length;N++){var D=Z[N];D.copy(A,L),L+=D.length}X&&X(A)}),G.end(q)}}}});var fq=_((A0,mq)=>{var DW=+(process?.versions?.node??"").split(".")[0]||0,BW=e();mq.exports=function(q,Q){var J=d("zlib");let X=Q>0?Q:1,G=DW>=15?{maxOutputLength:X}:{};return{inflate:function(){return J.inflateRawSync(q,G)},inflateAsync:function(Z){var Y=J.createInflateRaw(G),A=[],L=0,N=!1;let D=function(B){if(N)return;N=!0,Y.destroy(),Z&&Z(Buffer.alloc(0),B)};Y.on("error",function(B){D(B)}),Y.on("data",function(B){if(N)return;if(L+=B.length,L>X)return D(BW.MAX_OUTPUT_EXCEEDED());A.push(B)}),Y.on("end",function(){if(N)return;N=!0;var B=Buffer.alloc(L),x=0;B.fill(0);for(var U=0;U<A.length;U++){var $=A[U];$.copy(B,x),x+=$.length}Z&&Z(B)}),Y.end(q)}}}});var iq=_((I0,oq)=>{var{randomFillSync:pq}=d("crypto"),LW=e(),NW=new Uint32Array(256).map((q,Q)=>{for(let J=0;J<8;J++)if((Q&1)!==0)Q=Q>>>1^3988292384;else Q>>>=1;return Q>>>0}),cq=(q,Q)=>Math.imul(q,Q)>>>0,dq=(q,Q)=>{return NW[(q^Q)&255]^q>>>8},t=()=>{if(typeof pq==="function")return pq(Buffer.alloc(12));else return t.node()};t.node=()=>{let q=Buffer.alloc(12),Q=q.length;for(let J=0;J<Q;J++)q[J]=Math.random()*256&255;return q};var Jq={genSalt:t};function Qq(q){let Q=Buffer.isBuffer(q)?q:Buffer.from(q);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let J=0;J<Q.length;J++)this.updateKeys(Q[J])}Qq.prototype.updateKeys=function(q){let Q=this.keys;return Q[0]=dq(Q[0],q),Q[1]+=Q[0]&255,Q[1]=cq(Q[1],134775813)+1,Q[2]=dq(Q[2],Q[1]>>>24),q};Qq.prototype.next=function(){let q=(this.keys[2]|2)>>>0;return cq(q,q^1)>>8&255};function xW(q){let Q=new Qq(q);return function(J){let X=Buffer.alloc(J.length),G=0;for(let Z of J)X[G++]=Q.updateKeys(Z^Q.next());return X}}function UW(q){let Q=new Qq(q);return function(J,X,G=0){if(!X)X=Buffer.alloc(J.length);for(let Z of J){let Y=Q.next();X[G++]=Z^Y,Q.updateKeys(Z)}return X}}function HW(q,Q,J){if(!q||!Buffer.isBuffer(q)||q.length<12)return Buffer.alloc(0);let X=xW(J),G=X(q.slice(0,12)),Z=(Q.flags&8)===8?Q.timeHighByte:Q.crc>>>24;if(G[11]!==Z)throw LW.WRONG_PASSWORD();return X(q.slice(12))}function EW(q){if(Buffer.isBuffer(q)&&q.length>=12)Jq.genSalt=function(){return q.slice(0,12)};else if(q==="node")Jq.genSalt=t.node;else Jq.genSalt=t}function zW(q,Q,J,X=!1){if(q==null)q=Buffer.alloc(0);if(!Buffer.isBuffer(q))q=Buffer.from(q.toString());let G=UW(J),Z=Jq.genSalt();if(Z[11]=Q.crc>>>24&255,X)Z[10]=Q.crc>>>16&255;let Y=Buffer.alloc(q.length+12);return G(Z,Y),G(q,Y,12)}oq.exports={decrypt:HW,encrypt:zW,_salter:EW}});var sq=_((CW)=>{CW.Deflater=hq();CW.Inflater=fq();CW.ZipCrypto=iq()});var Vq=_((F0,lq)=>{var P=s(),vW=Mq(),h=P.Constants,Kq=sq();lq.exports=function(q,Q){var J=new vW.EntryHeader,X=Buffer.alloc(0),G=Buffer.alloc(0),Z=!1,Y=null,A=Buffer.alloc(0),L=Buffer.alloc(0),N=!0;let D=q,B=typeof D.decoder==="object"?D.decoder:P.decoder;N=B.hasOwnProperty("efs")?B.efs:!1;function x(){if(!Q||!(Q instanceof Uint8Array))return Buffer.alloc(0);L=J.loadLocalHeaderFromBinary(Q);let W=J.realDataOffset,V=W+J.compressedSize;if(W<0||V<W||V>Q.length)throw P.Errors.INVALID_LOC();return Q.slice(W,V)}function U(W){let V=J.flags_desc||J.localHeader.flags_desc?J.crc:J.localHeader.crc;return P.crc32(W)===V}function $(W,V,j){if(typeof V>"u"&&typeof W==="string")j=W,W=void 0;if(Z){if(W&&V)V(Buffer.alloc(0),P.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var O;try{if(O=x(),O.length===0){if(W&&V)V(O);return O}if(J.encrypted){if(typeof j!=="string"&&!Buffer.isBuffer(j))throw P.Errors.INVALID_PASS_PARAM();O=Kq.ZipCrypto.decrypt(O,J,j)}}catch(H){if(W&&V)return V(Buffer.alloc(0),H),Buffer.alloc(0);throw H}var F;switch(J.method){case P.Constants.STORED:if(F=Buffer.alloc(O.length),O.copy(F),!U(F)){if(W&&V)V(F,P.Errors.BAD_CRC());throw P.Errors.BAD_CRC()}else{if(W&&V)V(F);return F}case P.Constants.DEFLATED:var S=new Kq.Inflater(O,J.size);if(!W){if(F=S.inflate(),!U(F))throw P.Errors.BAD_CRC(`"${B.decode(X)}"`);return F}else S.inflateAsync(function(H,E){if(!V)return;if(E)V(Buffer.alloc(0),E);else if(!U(H))V(H,P.Errors.BAD_CRC());else V(H)});break;default:if(W&&V)V(Buffer.alloc(0),P.Errors.UNKNOWN_METHOD());throw P.Errors.UNKNOWN_METHOD()}}function M(W,V){if((!Y||!Y.length)&&Buffer.isBuffer(Q)){if(W&&V)V(x());return x()}if(Y.length&&!Z){var j;switch(J.method){case P.Constants.STORED:if(J.compressedSize=J.size,j=Buffer.alloc(Y.length),Y.copy(j),W&&V)V(j);return j;default:case P.Constants.DEFLATED:var O=new Kq.Deflater(Y);if(!W){var F=O.deflate();return J.compressedSize=F.length,F}else O.deflateAsync(function(S){j=Buffer.alloc(S.length),J.compressedSize=S.length,S.copy(j),V&&V(j)});O=null;break}}else if(W&&V)V(Buffer.alloc(0));else return Buffer.alloc(0)}function K(W,V){return P.readBigUInt64LE(W,V)}function T(W){try{var V=0,j,O,F;while(V+4<W.length)if(j=W.readUInt16LE(V),V+=2,O=W.readUInt16LE(V),V+=2,F=W.slice(V,V+O),V+=O,h.ID_ZIP64===j)R(F)}catch(S){throw P.Errors.EXTRA_FIELD_PARSE_ERROR()}}function R(W){var V,j,O,F;if(W.length>=h.EF_ZIP64_SCOMP){if(V=K(W,h.EF_ZIP64_SUNCOMP),J.size===h.EF_ZIP64_OR_32)J.size=V}if(W.length>=h.EF_ZIP64_RHO){if(j=K(W,h.EF_ZIP64_SCOMP),J.compressedSize===h.EF_ZIP64_OR_32)J.compressedSize=j}if(W.length>=h.EF_ZIP64_DSN){if(O=K(W,h.EF_ZIP64_RHO),J.offset===h.EF_ZIP64_OR_32)J.offset=O}if(W.length>=h.EF_ZIP64_DSN+4){if(F=W.readUInt32LE(h.EF_ZIP64_DSN),J.diskNumStart===h.EF_ZIP64_OR_16)J.diskNumStart=F}}return{get entryName(){return B.decode(X)},get rawEntryName(){return X},set entryName(W){X=P.toBuffer(W,B.encode);var V=X[X.length-1];Z=V===47||V===92,J.fileNameLength=X.length},get efs(){if(typeof N==="function")return N(this.entryName);else return N},get extra(){return A},set extra(W){A=W,J.extraLength=W.length,T(W)},get comment(){return B.decode(G)},set comment(W){if(G=P.toBuffer(W,B.encode),J.commentLength=G.length,G.length>65535)throw P.Errors.COMMENT_TOO_LONG()},get name(){let W=B.decode(X);return Z?W.replace(/[/\\]$/,"").split("/").pop():W.split("/").pop()},get isDirectory(){return Z},getCompressedData:function(){return M(!1,null)},getCompressedDataAsync:function(W){M(!0,W)},setData:function(W){if(Y=P.toBuffer(W,P.decoder.encode),!Z&&Y.length)J.size=Y.length,J.method=P.Constants.DEFLATED,J.crc=P.crc32(W),J.changed=!0;else J.method=P.Constants.STORED},getData:function(W){if(J.changed)return Y;else return $(!1,null,W)},getDataAsync:function(W,V){if(J.changed)W(Y);else $(!0,W,V)},set attr(W){J.attr=W},get attr(){return J.attr},set header(W){J.loadFromBinary(W)},get header(){return J},packCentralHeader:function(){J.flags_efs=this.efs,J.extraLength=A.length;var W=J.centralHeaderToBinary(),V=P.Constants.CENHDR;return X.copy(W,V),V+=X.length,A.copy(W,V),V+=J.extraLength,G.copy(W,V),W},packLocalHeader:function(){let W=0;J.flags_efs=this.efs,J.extraLocalLength=L.length;let V=J.localHeaderToBinary(),j=Buffer.alloc(V.length+X.length+J.extraLocalLength);return V.copy(j,W),W+=V.length,X.copy(j,W),W+=X.length,L.copy(j,W),W+=L.length,j},toJSON:function(){let W=function(V){return"<"+(V&&V.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:J.toJSON(),compressedData:W(Q),data:W(Y)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var aq=_((O0,rq)=>{var nq=Vq(),bW=Mq(),y=s();rq.exports=function(q,Q){var J=[],X=Object.create(null),G=Buffer.alloc(0),Z=new bW.MainHeader,Y=!1,A=null;let L=new Set,N=Q,{noSort:D,decoder:B}=N;if(q)$(N.readEntries);else Y=!0;function x(){let K=new Set;for(let T of Object.keys(X)){let R=T.split("/");if(R.pop(),!R.length)continue;for(let W=0;W<R.length;W++){let V=R.slice(0,W+1).join("/")+"/";K.add(V)}}for(let T of K)if(!(T in X)){let R=new nq(N);R.entryName=T,R.attr=16,R.temporary=!0,J.push(R),X[R.entryName]=R,L.add(R)}}function U(){if(Y=!0,X=Object.create(null),Z.diskEntries>(q.length-Z.offset)/y.Constants.CENHDR)throw y.Errors.DISK_ENTRY_TOO_LARGE();J=Array(Z.diskEntries);var K=Z.offset;for(var T=0;T<J.length;T++){var R=K,W=new nq(N,q);if(W.header=q.slice(R,R+=y.Constants.CENHDR),W.entryName=q.slice(R,R+=W.header.fileNameLength),W.header.extraLength)W.extra=q.slice(R,R+=W.header.extraLength);if(W.header.commentLength)W.comment=q.slice(R,R+W.header.commentLength);if(K+=W.header.centralHeaderSize,W.entryName in X)throw y.Errors.DUPLICATE_ENTRY(`"${W.entryName}"`);J[T]=W,X[W.entryName]=W}L.clear(),x()}function $(K){var T=q.length-y.Constants.ENDHDR,R=Math.max(0,T-65535),W=R,V=q.length,j=-1,O=0;if(typeof N.trailingSpace==="boolean"?N.trailingSpace:!1)R=0;for(T;T>=W;T--){if(q[T]!==80)continue;if(q.readUInt32LE(T)===y.Constants.ENDSIG){j=T,O=T,V=T+y.Constants.ENDHDR,W=T-y.Constants.END64HDR;continue}if(q.readUInt32LE(T)===y.Constants.END64SIG){W=R;continue}if(q.readUInt32LE(T)===y.Constants.ZIP64SIG){j=T,V=T+y.readBigUInt64LE(q,T+y.Constants.ZIP64SIZE)+y.Constants.ZIP64LEAD;break}}if(j==-1)throw y.Errors.INVALID_FORMAT();if(Z.loadFromBinary(q.slice(j,V)),Z.commentLength)G=q.slice(O+y.Constants.ENDHDR);if(K)U()}function M(){if(J.length>1&&!D)J=J.map((K)=>({entry:K,key:K.entryName.toLowerCase()})).sort((K,T)=>K.key.localeCompare(T.key)).map((K)=>K.entry)}return{get entries(){if(!Y)U();return J.filter((K)=>!L.has(K))},get comment(){return B.decode(G)},set comment(K){G=y.toBuffer(K,B.encode),Z.commentLength=G.length},getEntryCount:function(){if(!Y)return Z.diskEntries;return J.length},forEach:function(K){this.entries.forEach(K)},getEntry:function(K){if(!Y)U();return X[K]||null},setEntry:function(K){if(!Y)U();J.push(K),X[K.entryName]=K,Z.totalEntries=J.length},deleteFile:function(K,T=!0){if(!Y)U();let R=X[K];this.getEntryChildren(R,T).map((V)=>V.entryName).forEach(this.deleteEntry)},deleteEntry:function(K){if(!Y)U();let T=X[K],R=J.indexOf(T);if(R>=0)J.splice(R,1),delete X[K],Z.totalEntries=J.length},getEntryChildren:function(K,T=!0){if(!Y)U();if(typeof K==="object")if(K.isDirectory&&T){let R=[],W=K.entryName;for(let V of J)if(V.entryName.startsWith(W))R.push(V);return R}else return[K];return[]},getChildCount:function(K){if(K&&K.isDirectory){let T=this.getEntryChildren(K);return T.includes(K)?T.length-1:T.length}return 0},compressToBuffer:function(){if(!Y)U();M();let K=[],T=[],R=0,W=0;Z.size=0,Z.offset=0;let V=0;for(let F of this.entries){let S=F.getCompressedData();F.header.offset=W;let H=F.packLocalHeader(),E=H.length+S.length;W+=E,K.push(H),K.push(S);let z=F.packCentralHeader();T.push(z),Z.size+=z.length,R+=E+z.length,V++}R+=Z.mainHeaderSize,Z.offset=W,Z.totalEntries=V,W=0;let j=Buffer.alloc(R);for(let F of K)F.copy(j,W),W+=F.length;for(let F of T)F.copy(j,W),W+=F.length;let O=Z.toBinary();if(G)G.copy(O,O.length-G.length);return O.copy(j,W),q=j,Y=!1,j},toAsyncBuffer:function(K,T,R,W){try{if(!Y)U();M();let V=[],j=[],O=0,F=0,S=0;Z.size=0,Z.offset=0;let H=function(E){if(E.length>0){let z=E.shift(),b=z.entryName+z.extra.toString();if(R)R(b);z.getCompressedDataAsync(function(u){if(W)W(b);z.header.offset=F;let p=z.packLocalHeader(),qq=p.length+u.length;F+=qq,V.push(p),V.push(u);let l=z.packCentralHeader();j.push(l),Z.size+=l.length,O+=qq+l.length,S++,H(E)})}else{O+=Z.mainHeaderSize,Z.offset=F,Z.totalEntries=S,F=0;let z=Buffer.alloc(O);V.forEach(function(u){u.copy(z,F),F+=u.length}),j.forEach(function(u){u.copy(z,F),F+=u.length});let b=Z.toBinary();if(G)G.copy(b,b.length-G.length);b.copy(z,F),q=z,Y=!1,K(z)}};H(Array.from(this.entries))}catch(V){T(V)}}}}});var qW=_((S0,tq)=>{var v=s(),k=d("path"),uW=Vq(),_W=aq(),o=(...q)=>v.findLast(q,(Q)=>typeof Q==="boolean"),eq=(...q)=>v.findLast(q,(Q)=>typeof Q==="string"),yW=(...q)=>v.findLast(q,(Q)=>typeof Q==="function"),hW={noSort:!1,readEntries:!1,method:v.Constants.NONE,fs:null};tq.exports=function(q,Q){let J=null,X=Object.assign(Object.create(null),hW);if(q&&typeof q==="object"){if(!(q instanceof Uint8Array)){if(Object.assign(X,q),q=X.input?X.input:void 0,X.input)delete X.input}if(Buffer.isBuffer(q))J=q,X.method=v.Constants.BUFFER,q=void 0}Object.assign(X,Q);let G=new v(X),Z=($)=>{$.filter((M)=>M.attr).sort((M,K)=>K.path.length-M.path.length).forEach((M)=>G.fs.chmodSync(M.path,M.attr))};if(typeof X.decoder!=="object"||typeof X.decoder.encode!=="function"||typeof X.decoder.decode!=="function")X.decoder=v.decoder;if(q&&typeof q==="string")if(G.fs.existsSync(q))X.method=v.Constants.FILE,X.filename=q,J=G.fs.readFileSync(q);else throw v.Errors.INVALID_FILENAME();let Y=new _W(J,X),{canonical:A,sanitize:L,zipnamefix:N}=v;function D($){if($&&Y){var M;if(typeof $==="string")M=Y.getEntry(k.posix.normalize($));if(typeof $==="object"&&typeof $.entryName<"u"&&typeof $.header<"u")M=Y.getEntry($.entryName);if(M)return M}return null}function B($){let{join:M,normalize:K,sep:T}=k.posix;return M(k.isAbsolute($)?"/":".",K(T+$.split("\\").join(T)+T))}function x($){if($ instanceof RegExp)return function(M){return function(K){return M.test(K)}}($);else if(typeof $!=="function")return()=>!0;return $}let U=($,M)=>{let K=M.slice(-1);return K=K===G.sep?G.sep:"",k.relative($,M)+K};return{readFile:function($,M){var K=D($);return K&&K.getData(M)||null},childCount:function($){let M=D($);if(M)return Y.getChildCount(M)},readFileAsync:function($,M){var K=D($);if(K)K.getDataAsync(M);else M(null,"getEntry failed for:"+$)},readAsText:function($,M){var K=D($);if(K){var T=K.getData();if(T&&T.length)return T.toString(M||"utf8")}return""},readAsTextAsync:function($,M,K){var T=D($);if(T)T.getDataAsync(function(R,W){if(W){M(R,W);return}if(R&&R.length)M(R.toString(K||"utf8"));else M("")});else M("")},deleteFile:function($,M=!0){var K=D($);if(K)Y.deleteFile(K.entryName,M)},deleteEntry:function($){var M=D($);if(M)Y.deleteEntry(M.entryName)},addZipComment:function($){Y.comment=$},getZipComment:function(){return Y.comment||""},addZipEntryComment:function($,M){var K=D($);if(K)K.comment=M},getZipEntryComment:function($){var M=D($);if(M)return M.comment||"";return""},updateFile:function($,M){var K=D($);if(K)K.setData(M)},addLocalFile:function($,M,K,T){if(G.fs.existsSync($)){M=M?B(M):"";let R=k.win32.basename(k.win32.normalize($));M+=K?K:R;let W=G.fs.statSync($),V=W.isFile()?G.fs.readFileSync($):Buffer.alloc(0);if(W.isDirectory())M+=G.sep;this.addFile(M,V,T,W)}else throw v.Errors.FILE_NOT_FOUND($)},addLocalFileAsync:function($,M){$=typeof $==="object"?$:{localPath:$};let K=k.resolve($.localPath),{comment:T}=$,{zipPath:R,zipName:W}=$,V=this;G.fs.stat(K,function(j,O){if(j)return M(j,!1);R=R?B(R):"";let F=k.win32.basename(k.win32.normalize(K));if(R+=W?W:F,O.isFile())G.fs.readFile(K,function(S,H){if(S)return M(S,!1);return V.addFile(R,H,T,O),setImmediate(M,void 0,!0)});else if(O.isDirectory())return R+=G.sep,V.addFile(R,Buffer.alloc(0),T,O),setImmediate(M,void 0,!0)})},addLocalFolder:function($,M,K){if(K=x(K),M=M?B(M):"",$=k.normalize($),G.fs.existsSync($)){let T=G.findFiles($),R=this;if(T.length)for(let W of T){let V=k.join(M,U($,W));if(K(V))R.addLocalFile(W,k.dirname(V))}}else throw v.Errors.FILE_NOT_FOUND($)},addLocalFolderAsync:function($,M,K,T){T=x(T),K=K?B(K):"",$=k.normalize($);var R=this;G.fs.open($,"r",function(W){if(W&&W.code==="ENOENT")M(void 0,v.Errors.FILE_NOT_FOUND($));else if(W)M(void 0,W);else{var V=G.findFiles($),j=-1,O=function(){if(j+=1,j<V.length){var F=V[j],S=U($,F).split("\\").join("/");if(S=S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),T(S))G.fs.stat(F,function(H,E){if(H)M(void 0,H);if(E.isFile())G.fs.readFile(F,function(z,b){if(z)M(void 0,z);else R.addFile(K+S,b,"",E),O()});else R.addFile(K+S+"/",Buffer.alloc(0),"",E),O()});else process.nextTick(()=>{O()})}else M(!0,void 0)};O()}})},addLocalFolderAsync2:function($,M){let K=this;$=typeof $==="object"?$:{localPath:$};let T=k.resolve($.localPath),{zipPath:R,filter:W,namefix:V}=$;if(W instanceof RegExp)W=function(F){return function(S){return F.test(S)}}(W);else if(typeof W!=="function")W=function(){return!0};if(R=R?B(R):"",V==="latin1")V=(F)=>F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof V!=="function")V=(F)=>F;let j=(F)=>k.join(R,V(U(T,F))),O=(F)=>k.win32.basename(k.win32.normalize(V(F)));G.fs.open(T,"r",function(F){if(F&&F.code==="ENOENT")M(v.Errors.FILE_NOT_FOUND(T),!1);else if(F)M(F,!1);else G.findFilesAsync(T,function(S,H){if(S)return M(S,!1);if(H=H.filter((E)=>W(j(E))),!H.length)return M(void 0,!0);setImmediate(H.reverse().reduce(function(E,z){return function(b,u){if(b||u===!1)return setImmediate(E,b,!1);K.addLocalFileAsync({localPath:z,zipPath:k.dirname(j(z)),zipName:O(z)},E)}},M))})})},addLocalFolderPromise:function($,M){return new Promise((K,T)=>{this.addLocalFolderAsync2(Object.assign({localPath:$},M),(R,W)=>{if(R)return T(R);if(W)K(this)})})},addFile:function($,M,K,T){$=N($);let R=D($),W=R!=null;if(!W)R=new uW(X),R.entryName=$;R.comment=K||"";let V=typeof T==="object"&&T instanceof G.fs.Stats;if(V)R.header.time=T.mtime;var j=R.isDirectory?16:0;let O=R.isDirectory?16384:32768;if(V)O|=4095&T.mode;else if(typeof T==="number")O|=4095&T;else O|=R.isDirectory?493:420;if(j=(j|O<<16)>>>0,R.attr=j,R.setData(M),!W)Y.setEntry(R);return R},getEntries:function($){return Y.password=$,Y?Y.entries:[]},getEntry:function($){return D($)},getEntryCount:function(){return Y.getEntryCount()},forEach:function($){return Y.forEach($)},extractEntryTo:function($,M,K,T,R,W){T=o(!1,T),R=o(!1,R),K=o(!0,K),W=eq(R,W);var V=D($);if(!V)throw v.Errors.NO_ENTRY();var j=A(V.entryName),O=L(M,W&&!V.isDirectory?A(W):K?j:k.basename(j));if(V.isDirectory){var F=Y.getEntryChildren(V);return F.forEach(function(E){if(E.isDirectory)return;var z=E.getData();if(!z)throw v.Errors.CANT_EXTRACT_FILE();var b=A(K?E.entryName:E.entryName.substring(V.entryName.length)),u=L(M,b);G.assertPathSafe(M,u);let p=R?E.header.fileAttr:void 0;G.writeFileTo(u,z,T,p)}),!0}var S=V.getData(Y.password);if(!S)throw v.Errors.CANT_EXTRACT_FILE();if(G.assertPathSafe(M,O),G.fs.existsSync(O)&&!T)throw v.Errors.CANT_OVERRIDE();let H=R?$.header.fileAttr:void 0;return G.writeFileTo(O,S,T,H),!0},test:function($){if(!Y)return!1;for(var M of Y.entries)try{if(M.isDirectory)continue;var K=M.getData($);if(!K)return!1}catch(T){return!1}return!0},extractAllTo:function($,M,K,T){if(K=o(!1,K),T=eq(K,T),M=o(!1,M),!Y)throw v.Errors.NO_ZIP();let R=[];Y.entries.forEach(function(W){var V=L($,A(W.entryName));if(G.assertPathSafe($,V),W.isDirectory){if(G.makeDir(V),K)R.push({path:V,attr:W.header.fileAttr});return}var j=W.getData(T);if(!j)throw v.Errors.CANT_EXTRACT_FILE();let O=K?W.header.fileAttr:void 0;G.writeFileTo(V,j,M,O);try{G.fs.utimesSync(V,W.header.time,W.header.time)}catch(F){}}),Z(R)},extractAllToAsync:function($,M,K,T){if(T=yW(M,K,T),K=o(!1,K),M=o(!1,M),!T)return new Promise((S,H)=>{this.extractAllToAsync($,M,K,function(E){if(E)H(E);else S(this)})});if(!Y){T(v.Errors.NO_ZIP());return}$=k.resolve($);let R=(S)=>L($,k.normalize(A(S.entryName))),W=(S,H)=>Error(S+': "'+H+'"'),V=[],j=[];Y.entries.forEach((S)=>{if(S.isDirectory)V.push(S);else j.push(S)});let O=[];for(let S of V){let H=R(S),E=K?S.header.fileAttr:void 0;try{G.assertPathSafe($,H),G.makeDir(H)}catch(z){T(W("Unable to create folder",H));continue}if(E)O.push({path:H,attr:E});try{G.fs.utimesSync(H,S.header.time,S.header.time)}catch(z){}}let F=(S)=>{if(!S)try{Z(O)}catch(H){return T(W("Unable to set folder permissions",H.path||""))}T(S)};j.reverse().reduce(function(S,H){return function(E){if(E)S(E);else{let z=k.normalize(A(H.entryName)),b=L($,z);try{G.assertPathSafe($,b)}catch(u){return S(u)}H.getDataAsync(function(u,p){if(p)S(p);else if(!u)S(v.Errors.CANT_EXTRACT_FILE());else{let qq=K?H.header.fileAttr:void 0;G.writeFileToAsync(b,u,M,qq,function(l){if(!l)return S(W("Unable to write file",b));G.fs.utimes(b,H.header.time,H.header.time,function(){S()})})}})}}},F)()},writeZip:function($,M){if(arguments.length===1){if(typeof $==="function")M=$,$=""}if(!$&&X.filename)$=X.filename;if(!$)return;var K=Y.compressToBuffer();if(K){var T=G.writeFileTo($,K,!0);if(typeof M==="function")M(!T?Error("failed"):null,"")}},writeZipPromise:function($,M){let{overwrite:K,perm:T}=Object.assign({overwrite:!0},M);return new Promise((R,W)=>{if(!$&&X.filename)$=X.filename;if(!$)W("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((V)=>{let j=(O)=>O?R(O):W("ADM-ZIP: Wasn't able to write zip file");G.writeFileToAsync($,V,K,T,j)},W)})},toBufferPromise:function(){return new Promise(($,M)=>{Y.toAsyncBuffer($,M)})},toBuffer:function($,M,K,T){if(typeof $==="function")return Y.toAsyncBuffer($,M,K,T),null;return Y.compressToBuffer()}}}});var WW=r(()=>{Xq()});Dq();WW();var XW=VW(qW(),1);import{parentPort as JW,workerData as mW}from"worker_threads";import*as QW from"path";function fW(){let{bundlePath:q,destination:Q}=mW;try{let J=new XW.default(q);wq(J,Q),J.extractAllTo(QW.resolve(Q),!0);let X={ok:!0};JW?.postMessage(X)}catch(J){let X={ok:!1,message:a(J),stack:J instanceof Error?J.stack:void 0};JW?.postMessage(X)}}fW();
|
|
2
|
+
var ut=Object.create;var{getPrototypeOf:lt,defineProperty:Y,getOwnPropertyNames:he,getOwnPropertyDescriptor:Et}=Object,fe=Object.prototype.hasOwnProperty;function Ie(e){return this[e]}var dt,mt,ht=(e,r,n)=>{var o=e!=null&&typeof e==="object";if(o){var f=r?dt??=new WeakMap:mt??=new WeakMap,E=f.get(e);if(E)return E}n=e!=null?ut(lt(e)):{};let i=r||!e||!e.__esModule||!fe.call(e,"default")?Y(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let m of he(e))if(!fe.call(i,m))Y(i,m,{get:Ie.bind(e,m),enumerable:!0})}if(o)f.set(e,i);return i},jt=(e)=>{var r=(me??=new WeakMap).get(e),n;if(r)return r;if(r=Y({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var o of he(e))if(!fe.call(r,o))Y(r,o,{get:Ie.bind(e,o),enumerable:!(n=Et(e,o))||n.enumerable})}return me.set(e,r),r},me,H=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var It=(e)=>e;function gt(e,r){this[e]=It.bind(null,r)}var Vt=(e,r)=>{for(var n in r)Y(e,n,{get:r[n],enumerable:!0,configurable:!0,set:gt.bind(r,n)})};var J=(e,r,n)=>()=>{if(e)try{r=e(e=0)}catch(o){n=[o]}if(n)throw n[0];return r};var j=import.meta.require;function re(e,r){try{return e()}catch(n){return r(n)}}async function qt(e,r){try{return await e()}catch(n){return r(n)}}function ge(e){if(e instanceof Error){let r=[e.name,e.message].filter(Boolean).join(": "),n=e.stack?.split(`
|
|
3
|
+
`).slice(0,3).join(" \u2190 "),o="cause"in e&&e.cause!==void 0?ge(e.cause):"";return[r||"Error",n,o?`cause=${o}`:""].filter(Boolean).join(" | ")}if(e===null||e===void 0)return String(e);if(typeof e==="object"){if(Object.keys(e).length===0)return`${Object.prototype.toString.call(e)} (no enumerable keys)`;return re(()=>JSON.stringify(e),()=>Object.prototype.toString.call(e))}return String(e)}function Q(e){return re(()=>{if(e instanceof Error)return e.message;return String(e)},()=>re(()=>Object.prototype.toString.call(e),()=>"Unknown error"))}var ce=()=>{};function $t(e,r){if(e instanceof V)return e;let n=Q(e);return new V(`${r}: ${n}`,{cause:e})}function Jt(e,r){return new V(`${r} is not supported on platform '${e}'. Supported platforms: android, ios.`)}var V;var Le=J(()=>{ce();V=class V extends Error{constructor(e,r){super(e,r);let n=r?.containerFailure??(r?.cause instanceof V?r.cause.containerFailure:void 0);if(n)this.containerFailure=n}}});import*as pe from"path";function ae(e,r,n={}){let o=n.paths??pe,f=o.resolve(e),E=o.resolve(f,r),i=o.relative(f,E);if(i==="")return n.allowEqual??!0;return!(i===".."||i.startsWith(`..${o.sep}`)||o.isAbsolute(i))}function en(e,r,n,o={}){if(!ae(e,r,o))throw n();let f=o.paths??pe;return f.resolve(f.resolve(e),r)}var De=()=>{};import*as ye from"path";function Ne(e,r,n="CtrlProxy bundle"){let o=ye.resolve(r);for(let f of e.getEntries())if(!ae(o,f.entryName))throw new V(`Refusing to extract ${n}: entry "${f.entryName}" resolves outside the extraction directory ${o} (zip-slip / path traversal).`)}var _e=J(()=>{Le();De()});var ue=H(function(sn,Ce){Ce.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var ee=H(function(Oe){var Se={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",MAX_OUTPUT_EXCEEDED:"Decompressed data exceeds the declared uncompressed size",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DUPLICATE_ENTRY:"Duplicate entry name {0}",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",ZIP64_VALUE_TOO_LARGE:"Zip64 value exceeds the maximum safe integer",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function pt(e){return function(...r){if(r.length)e=e.replace(/\{(\d)\}/g,(n,o)=>r[o]||"");return Error("ADM-ZIP: "+e)}}for(let e of Object.keys(Se))Oe[e]=pt(Se[e])});var Fe=H(function(cn,xe){var Dt=j("fs"),D=j("path"),oe=ue(),q=ee(),yt=typeof process==="object"&&process.platform==="win32",Te=(e)=>typeof e==="object"&&e!==null,Ae=new Uint32Array(256).map((e,r)=>{for(let n=0;n<8;n++)if((r&1)!==0)r=3988292384^r>>>1;else r>>>=1;return r>>>0});function Z(e){if(this.sep=D.sep,this.fs=Dt,Te(e)){if(Te(e.fs)&&typeof e.fs.statSync==="function")this.fs=e.fs}}xe.exports=Z;Z.prototype.makeDir=function(e){let r=this;function n(o){let f=o.split(r.sep)[0];o.split(r.sep).forEach(function(E){if(!E||E.substr(-1,1)===":")return;f+=r.sep+E;var i;try{i=r.fs.statSync(f)}catch(m){if(m.message&&m.message.startsWith("ENOENT"))r.fs.mkdirSync(f);else throw m}if(i&&i.isFile())throw q.FILE_IN_THE_WAY(`"${f}"`)})}n(e)};Z.prototype.writeFileTo=function(e,r,n,o){let f=this;if(f.fs.existsSync(e)){if(!n)return!1;var E=f.fs.statSync(e);if(E.isDirectory())return!1}var i=D.dirname(e);if(!f.fs.existsSync(i))f.makeDir(i);var m;try{m=f.fs.openSync(e,"w",438)}catch(C){f.fs.chmodSync(e,438),m=f.fs.openSync(e,"w",438)}if(m)try{f.fs.writeSync(m,r,0,r.length,0)}finally{f.fs.closeSync(m)}return f.fs.chmodSync(e,o||438),!0};Z.prototype.writeFileToAsync=function(e,r,n,o,f){if(typeof o==="function")f=o,o=void 0;let E=this;E.fs.exists(e,function(i){if(i&&!n)return f(!1);E.fs.stat(e,function(m,C){if(i&&C&&C.isDirectory())return f(!1);var S=D.dirname(e);E.fs.exists(S,function(N){if(!N)try{E.makeDir(S)}catch(O){return f(!1)}let _=function(O){E.fs.write(O,r,0,r.length,0,function(A){E.fs.close(O,function(){if(A)return f(!1);E.fs.chmod(e,o||438,function(){f(!0)})})})};E.fs.open(e,"w",438,function(O,A){if(O)E.fs.chmod(e,438,function(){E.fs.open(e,"w",438,function(s,c){if(s||!c)return f(!1);_(c)})});else if(A)_(A);else f(!1)})})})})};Z.prototype.assertPathSafe=function(e,r){let n=this;if(typeof n.fs.lstatSync!=="function")return;let o=D.resolve(e),f=D.resolve(r);if(f===o)return;let E=D.relative(o,f);if(!E||E===".."||E.startsWith(".."+D.sep)||D.isAbsolute(E))return;let i=o;for(let m of E.split(D.sep)){if(!m||m===".")continue;i=D.join(i,m);let C;try{C=n.fs.lstatSync(i)}catch(S){break}if(C.isSymbolicLink())throw q.FILE_IN_THE_WAY(`"${i}"`)}};Z.prototype.findFiles=function(e){let r=this,n=typeof r.fs.lstatSync==="function",o=r.fs.realpathSync(e);function f(i){if(!n)return!1;if(!r.fs.lstatSync(i).isSymbolicLink())return!1;let m;try{m=r.fs.realpathSync(i)}catch(C){return!0}return!(m===o||m.startsWith(o+D.sep))}function E(i,m,C,S){if(typeof m==="boolean")C=m,m=void 0;let N=[];return r.fs.readdirSync(i).forEach(function(_){let O=D.join(i,_);if(f(O))return;let A=r.fs.statSync(O);if(!m||m.test(O))N.push(D.normalize(O)+(A.isDirectory()?r.sep:""));if(A.isDirectory()&&C){let s=r.fs.realpathSync(O);if(!S.has(s))S.add(s),N=N.concat(E(O,m,C,S))}}),N}return E(e,void 0,!0,new Set([o]))};Z.prototype.findFilesAsync=function(e,r){let n=this,o=[],f=!1,E=function(N){if(f)return;f=!0,r(N,N?void 0:o)},i=typeof n.fs.lstat==="function",m=null,C=function(N,_){if(!i)return _(null,!1);n.fs.lstat(N,function(O,A){if(O)return _(O);if(!A||!A.isSymbolicLink())return _(null,!1);n.fs.realpath(N,function(s,c){if(s)return _(null,!0);_(null,!(c===m||c.startsWith(m+D.sep)))})})},S=function(N,_,O){n.fs.readdir(N,function(A,s){if(A)return O(A);let c=s.length;if(!c)return O();s.forEach(function(a){let l=D.join(N,a);C(l,function(d,t){if(d)return O(d);if(t){if(!--c)O();return}n.fs.stat(l,function(u,I){if(u)return O(u);if(!I){if(!--c)O();return}if(o.push(D.normalize(l)+(I.isDirectory()?n.sep:"")),!I.isDirectory()){if(!--c)O();return}n.fs.realpath(l,function(L,g){if(L)return O(L);if(_.has(g)){if(!--c)O();return}_.add(g),S(l,_,function(p){if(p)return O(p);if(!--c)O()})})})})})})};n.fs.realpath(e,function(N,_){if(N)return E(N);m=_,S(e,new Set([_]),E)})};Z.prototype.getAttributes=function(){};Z.prototype.setAttributes=function(){};Z.crc32update=function(e,r){return Ae[(e^r)&255]^e>>>8};Z.crc32=function(e){if(typeof e==="string")e=Buffer.from(e,"utf8");let r=e.length,n=-1;for(let o=0;o<r;)n=Z.crc32update(n,e[o++]);return~n>>>0};Z.methodToString=function(e){switch(e){case oe.STORED:return"STORED ("+e+")";case oe.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};Z.canonical=function(e){if(!e)return"";let r=D.posix.normalize("/"+e.split("\\").join("/"));return D.join(".",r)};Z.zipnamefix=function(e){if(!e)return"";let r=D.posix.normalize("/"+e.split("\\").join("/"));return D.posix.join(".",r)};Z.findLast=function(e,r){if(!Array.isArray(e))throw TypeError("arr is not array");let n=e.length>>>0;for(let o=n-1;o>=0;o--)if(r(e[o],o,e))return e[o];return};Z.sanitize=function(e,r){e=D.resolve(D.normalize(e));var n=r.split("/");for(var o=0,f=n.length;o<f;o++){var E=D.normalize(D.join(e,n.slice(o,f).join(D.sep)));if(E===e||E.startsWith(e+D.sep))return E}return D.normalize(D.join(e,D.basename(r)))};Z.toBuffer=function(r,n){if(Buffer.isBuffer(r))return r;else if(r instanceof Uint8Array)return Buffer.from(r);else return typeof r==="string"?n(r):Buffer.alloc(0)};Z.readBigUInt64LE=function(e,r){let n=e.readUInt32LE(r),f=e.readUInt32LE(r+4)*4294967296+n;if(f>Number.MAX_SAFE_INTEGER)throw q.ZIP64_VALUE_TOO_LARGE();return f};Z.writeBigUInt64LE=function(e,r,n){let o=r>>>0,f=Math.floor(r/4294967296)>>>0;e.writeUInt32LE(o,n),e.writeUInt32LE(f,n+4)};Z.fromDOS2Date=function(e){return new Date((e>>25&127)+1980,Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(e&31)<<1)};Z.fromDate2DOS=function(e){let r=0,n=0;if(e.getFullYear()>1979)r=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),n=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1;return r<<16|n};Z.isWin=yt;Z.crcTable=Ae});var Ue=H(function(an,Re){var we=j("path");Re.exports=function(e,{fs:r}){var n=e||"",o=E(),f=null;function E(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(n&&r.existsSync(n))f=r.statSync(n),o.directory=f.isDirectory(),o.mtime=f.mtime,o.atime=f.atime,o.executable=(73&f.mode)!==0,o.readonly=(128&f.mode)===0,o.hidden=we.basename(n)[0]===".";else console.warn("Invalid path: "+n);return{get directory(){return o.directory},get readOnly(){return o.readonly},get hidden(){return o.hidden},get mtime(){return o.mtime},get atime(){return o.atime},get executable(){return o.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:o.directory,isReadOnly:o.readonly,isHidden:o.hidden,isExecutable:o.executable,mTime:o.mtime,aTime:o.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Ze=H(function(un,Be){Be.exports={efs:!0,encode:(e)=>Buffer.from(e,"utf8"),decode:(e)=>e.toString("utf8")}});var K=H(function(ln,X){X.exports=Fe();X.exports.Constants=ue();X.exports.Errors=ee();X.exports.FileAttr=Ue();X.exports.decoder=Ze()});var ve=H(function(En,Pe){var G=K(),h=G.Constants;Pe.exports=function(){var e=20,r=10,n=0,o=0,f=0,E=0,i=0,m=0,C=0,S=0,N=0,_=0,O=0,A=0,s=0;e|=G.isWin?2560:768,n|=h.FLG_EFS;let c={extraLen:0},a=(t)=>Math.max(0,t)>>>0,l=(t)=>Math.max(0,t)&65535,d=(t)=>Math.max(0,t)&255;return f=G.fromDate2DOS(new Date),{get made(){return e},set made(t){e=t},get version(){return r},set version(t){r=t},get flags(){return n},set flags(t){n=t},get flags_efs(){return(n&h.FLG_EFS)>0},set flags_efs(t){if(t)n|=h.FLG_EFS;else n&=~h.FLG_EFS},get flags_desc(){return(n&h.FLG_DESC)>0},set flags_desc(t){if(t)n|=h.FLG_DESC;else n&=~h.FLG_DESC},get method(){return o},set method(t){switch(t){case h.STORED:this.version=10;break;case h.DEFLATED:default:this.version=20}o=t},get time(){return G.fromDOS2Date(this.timeval)},set time(t){t=new Date(t),this.timeval=G.fromDate2DOS(t)},get timeval(){return f},set timeval(t){f=a(t)},get timeHighByte(){return d(f>>>8)},get crc(){return E},set crc(t){E=a(t)},get compressedSize(){return i},set compressedSize(t){i=a(t)},get size(){return m},set size(t){m=a(t)},get fileNameLength(){return C},set fileNameLength(t){C=t},get extraLength(){return S},set extraLength(t){S=t},get extraLocalLength(){return c.extraLen},set extraLocalLength(t){c.extraLen=t},get commentLength(){return N},set commentLength(t){N=t},get diskNumStart(){return _},set diskNumStart(t){_=a(t)},get inAttr(){return O},set inAttr(t){O=a(t)},get attr(){return A},set attr(t){A=a(t)},get fileAttr(){return(A||0)>>16&511},get offset(){return s},set offset(t){s=a(t)},get encrypted(){return(n&h.FLG_ENC)===h.FLG_ENC},get centralHeaderSize(){return h.CENHDR+C+S+N},get realDataOffset(){return s+h.LOCHDR+c.fnameLen+c.extraLen},get localHeader(){return c},loadLocalHeaderFromBinary:function(t){if(s<0||s+h.LOCHDR>t.length)throw G.Errors.INVALID_LOC();var u=t.slice(s,s+h.LOCHDR);if(u.readUInt32LE(0)!==h.LOCSIG)throw G.Errors.INVALID_LOC();c.version=u.readUInt16LE(h.LOCVER),c.flags=u.readUInt16LE(h.LOCFLG),c.flags_desc=(c.flags&h.FLG_DESC)>0,c.method=u.readUInt16LE(h.LOCHOW),c.time=u.readUInt32LE(h.LOCTIM),c.crc=u.readUInt32LE(h.LOCCRC),c.compressedSize=u.readUInt32LE(h.LOCSIZ),c.size=u.readUInt32LE(h.LOCLEN),c.fnameLen=u.readUInt16LE(h.LOCNAM),c.extraLen=u.readUInt16LE(h.LOCEXT);let I=s+h.LOCHDR+c.fnameLen,L=I+c.extraLen;return t.slice(I,L)},loadFromBinary:function(t){if(t.length!==h.CENHDR||t.readUInt32LE(0)!==h.CENSIG)throw G.Errors.INVALID_CEN();e=t.readUInt16LE(h.CENVEM),r=t.readUInt16LE(h.CENVER),n=t.readUInt16LE(h.CENFLG),o=t.readUInt16LE(h.CENHOW),f=t.readUInt32LE(h.CENTIM),E=t.readUInt32LE(h.CENCRC),i=t.readUInt32LE(h.CENSIZ),m=t.readUInt32LE(h.CENLEN),C=t.readUInt16LE(h.CENNAM),S=t.readUInt16LE(h.CENEXT),N=t.readUInt16LE(h.CENCOM),_=t.readUInt16LE(h.CENDSK),O=t.readUInt16LE(h.CENATT),A=t.readUInt32LE(h.CENATX),s=t.readUInt32LE(h.CENOFF)},localHeaderToBinary:function(){var t=Buffer.alloc(h.LOCHDR);return t.writeUInt32LE(h.LOCSIG,0),t.writeUInt16LE(r,h.LOCVER),t.writeUInt16LE(n&~h.FLG_DESC,h.LOCFLG),t.writeUInt16LE(o,h.LOCHOW),t.writeUInt32LE(f,h.LOCTIM),t.writeUInt32LE(E,h.LOCCRC),t.writeUInt32LE(i,h.LOCSIZ),t.writeUInt32LE(m,h.LOCLEN),t.writeUInt16LE(C,h.LOCNAM),t.writeUInt16LE(c.extraLen,h.LOCEXT),t},centralHeaderToBinary:function(){var t=Buffer.alloc(h.CENHDR+C+S+N);return t.writeUInt32LE(h.CENSIG,0),t.writeUInt16LE(e,h.CENVEM),t.writeUInt16LE(r,h.CENVER),t.writeUInt16LE(n&~h.FLG_DESC,h.CENFLG),t.writeUInt16LE(o,h.CENHOW),t.writeUInt32LE(f,h.CENTIM),t.writeUInt32LE(E,h.CENCRC),t.writeUInt32LE(i,h.CENSIZ),t.writeUInt32LE(m,h.CENLEN),t.writeUInt16LE(C,h.CENNAM),t.writeUInt16LE(S,h.CENEXT),t.writeUInt16LE(N,h.CENCOM),t.writeUInt16LE(_,h.CENDSK),t.writeUInt16LE(O,h.CENATT),t.writeUInt32LE(A,h.CENATX),t.writeUInt32LE(s,h.CENOFF),t},toJSON:function(){let t=function(u){return u+" bytes"};return{made:e,version:r,flags:n,method:G.methodToString(o),time:this.time,crc:"0x"+E.toString(16).toUpperCase(),compressedSize:t(i),size:t(m),fileNameLength:t(C),extraLength:t(S),commentLength:t(N),diskNumStart:_,inAttr:O,attr:A,offset:s,centralHeaderSize:t(h.CENHDR+C+S+N)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Me=H(function(dn,He){var z=K(),y=z.Constants;He.exports=function(){var e=0,r=0,n=0,o=0,f=0;let E=()=>e>y.EF_ZIP64_OR_16||r>y.EF_ZIP64_OR_16||n>y.EF_ZIP64_OR_32||o>y.EF_ZIP64_OR_32;return{get diskEntries(){return e},set diskEntries(i){e=r=i},get totalEntries(){return r},set totalEntries(i){r=e=i},get size(){return n},set size(i){n=i},get offset(){return o},set offset(i){o=i},get commentLength(){return f},set commentLength(i){f=i},get mainHeaderSize(){return(E()?y.ZIP64HDR+y.END64HDR:0)+y.ENDHDR+f},loadFromBinary:function(i){if((i.length!==y.ENDHDR||i.readUInt32LE(0)!==y.ENDSIG)&&(i.length<y.ZIP64HDR||i.readUInt32LE(0)!==y.ZIP64SIG))throw z.Errors.INVALID_END();if(i.readUInt32LE(0)===y.ENDSIG)e=i.readUInt16LE(y.ENDSUB),r=i.readUInt16LE(y.ENDTOT),n=i.readUInt32LE(y.ENDSIZ),o=i.readUInt32LE(y.ENDOFF),f=i.readUInt16LE(y.ENDCOM);else e=z.readBigUInt64LE(i,y.ZIP64SUB),r=z.readBigUInt64LE(i,y.ZIP64TOT),n=z.readBigUInt64LE(i,y.ZIP64SIZB),o=z.readBigUInt64LE(i,y.ZIP64OFF),f=0},toBinary:function(){if(!E()){var i=Buffer.alloc(y.ENDHDR+f);return i.writeUInt32LE(y.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(e,y.ENDSUB),i.writeUInt16LE(r,y.ENDTOT),i.writeUInt32LE(n,y.ENDSIZ),i.writeUInt32LE(o,y.ENDOFF),i.writeUInt16LE(f,y.ENDCOM),i.fill(" ",y.ENDHDR),i}var i=Buffer.alloc(this.mainHeaderSize);let m=0;i.writeUInt32LE(y.ZIP64SIG,m),z.writeBigUInt64LE(i,y.ZIP64HDR-y.ZIP64LEAD,m+y.ZIP64SIZE),i.writeUInt16LE(45,m+y.ZIP64VEM),i.writeUInt16LE(45,m+y.ZIP64VER),i.writeUInt32LE(0,m+y.ZIP64DSK),i.writeUInt32LE(0,m+y.ZIP64DSKDIR),z.writeBigUInt64LE(i,e,m+y.ZIP64SUB),z.writeBigUInt64LE(i,r,m+y.ZIP64TOT),z.writeBigUInt64LE(i,n,m+y.ZIP64SIZB),z.writeBigUInt64LE(i,o,m+y.ZIP64OFF);let C=o+n;return m+=y.ZIP64HDR,i.writeUInt32LE(y.END64SIG,m),i.writeUInt32LE(0,m+y.END64START),z.writeBigUInt64LE(i,C,m+y.END64OFF),i.writeUInt32LE(1,m+y.END64NUMDISKS),m+=y.END64HDR,i.writeUInt32LE(y.ENDSIG,m),i.writeUInt32LE(0,m+4),i.writeUInt16LE(Math.min(e,y.EF_ZIP64_OR_16),m+y.ENDSUB),i.writeUInt16LE(Math.min(r,y.EF_ZIP64_OR_16),m+y.ENDTOT),i.writeUInt32LE(Math.min(n,y.EF_ZIP64_OR_32),m+y.ENDSIZ),i.writeUInt32LE(Math.min(o,y.EF_ZIP64_OR_32),m+y.ENDOFF),i.writeUInt16LE(f,m+y.ENDCOM),i.fill(" ",m+y.ENDHDR),i},toJSON:function(){let i=function(m,C){let S=m.toString(16).toUpperCase();while(S.length<C)S="0"+S;return"0x"+S};return{diskEntries:e,totalEntries:r,size:n+" bytes",offset:i(o,4),commentLength:f}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var le=H(function(Nt){Nt.EntryHeader=ve();Nt.MainHeader=Me()});var Ge=H(function(hn,ze){ze.exports=function(e){var r=j("zlib"),n={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:function(){return r.deflateRawSync(e,n)},deflateAsync:function(o){var f=r.createDeflateRaw(n),E=[],i=0;f.on("data",function(m){E.push(m),i+=m.length}),f.on("end",function(){var m=Buffer.alloc(i),C=0;m.fill(0);for(var S=0;S<E.length;S++){var N=E[S];N.copy(m,C),C+=N.length}o&&o(m)}),f.end(e)}}}});var Ve=H(function(In,je){var St=+(process?.versions?.node??"").split(".")[0]||0,be=ee();je.exports=function(e,r){var n=j("zlib");let o=r>0?r:1,f=St>=15?{maxOutputLength:o}:{};return{inflate:function(){return n.inflateRawSync(e,f)},inflateAsync:function(E){var i=n.createInflateRaw(f),m=[],C=0,S=!1;let N=function(_){if(S)return;S=!0,i.destroy(),E&&E(Buffer.alloc(0),_)};i.on("error",function(_){N(_)}),i.on("data",function(_){if(S)return;if(C+=_.length,C>o)return N(be.MAX_OUTPUT_EXCEEDED());m.push(_)}),i.on("end",function(){if(S)return;S=!0;var _=Buffer.alloc(C),O=0;_.fill(0);for(var A=0;A<m.length;A++){var s=m[A];s.copy(_,O),O+=s.length}E&&E(_)}),i.end(e)}}}});var Ye=H(function(gn,ke){var{randomFillSync:We}=j("crypto"),Xe=ee(),Ot=new Uint32Array(256).map((e,r)=>{for(let n=0;n<8;n++)if((r&1)!==0)r=r>>>1^3988292384;else r>>>=1;return r>>>0}),Ke=(e,r)=>Math.imul(e,r)>>>0,qe=(e,r)=>Ot[(e^r)&255]^e>>>8,te=()=>{if(typeof We==="function")return We(Buffer.alloc(12));else return te.node()};te.node=()=>{let e=Buffer.alloc(12),r=e.length;for(let n=0;n<r;n++)e[n]=Math.random()*256&255;return e};var ie={genSalt:te};function se(e){let r=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<r.length;n++)this.updateKeys(r[n])}se.prototype.updateKeys=function(e){let r=this.keys;return r[0]=qe(r[0],e),r[1]+=r[0]&255,r[1]=Ke(r[1],134775813)+1,r[2]=qe(r[2],r[1]>>>24),e};se.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return Ke(e,e^1)>>8&255};function Tt(e){let r=new se(e);return function(n){let o=Buffer.alloc(n.length),f=0;for(let E of n)o[f++]=r.updateKeys(E^r.next());return o}}function At(e){let r=new se(e);return function(n,o,f=0){if(!o)o=Buffer.alloc(n.length);for(let E of n){let i=r.next();o[f++]=E^i,r.updateKeys(E)}return o}}function xt(e,r,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let o=Tt(n),f=o(e.slice(0,12)),E=(r.flags&8)===8?r.timeHighByte:r.crc>>>24;if(f[11]!==E)throw Xe.WRONG_PASSWORD();return o(e.slice(12))}function Ft(e){if(Buffer.isBuffer(e)&&e.length>=12)ie.genSalt=function(){return e.slice(0,12)};else if(e==="node")ie.genSalt=te.node;else ie.genSalt=te}function wt(e,r,n,o=!1){if(e==null)e=Buffer.alloc(0);if(!Buffer.isBuffer(e))e=Buffer.from(e.toString());let f=At(n),E=ie.genSalt();if(E[11]=r.crc>>>24&255,o)E[10]=r.crc>>>16&255;let i=Buffer.alloc(e.length+12);return f(E,i),f(e,i,12)}ke.exports={decrypt:xt,encrypt:wt,_salter:Ft}});var $e=H(function(Rt){Rt.Deflater=Ge();Rt.Inflater=Ve();Rt.ZipCrypto=Ye()});var de=H(function(pn,Je){var B=K(),Pt=le(),M=B.Constants,Ee=$e();Je.exports=function(e,r){var n=new Pt.EntryHeader,o=Buffer.alloc(0),f=Buffer.alloc(0),E=!1,i=null,m=Buffer.alloc(0),C=Buffer.alloc(0),S=!0;let N=e,_=typeof N.decoder==="object"?N.decoder:B.decoder;S=_.hasOwnProperty("efs")?_.efs:!1;function O(){if(!r||!(r instanceof Uint8Array))return Buffer.alloc(0);C=n.loadLocalHeaderFromBinary(r);let t=n.realDataOffset,u=t+n.compressedSize;if(t<0||u<t||u>r.length)throw B.Errors.INVALID_LOC();return r.slice(t,u)}function A(t){let u=n.flags_desc||n.localHeader.flags_desc?n.crc:n.localHeader.crc;return B.crc32(t)===u}function s(t,u,I){if(typeof u>"u"&&typeof t==="string")I=t,t=void 0;if(E){if(t&&u)u(Buffer.alloc(0),B.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var L;try{if(L=O(),L.length===0){if(t&&u)u(L);return L}if(n.encrypted){if(typeof I!=="string"&&!Buffer.isBuffer(I))throw B.Errors.INVALID_PASS_PARAM();L=Ee.ZipCrypto.decrypt(L,n,I)}}catch(x){if(t&&u)return u(Buffer.alloc(0),x),Buffer.alloc(0);throw x}var g;switch(n.method){case B.Constants.STORED:if(g=Buffer.alloc(L.length),L.copy(g),!A(g)){if(t&&u)u(g,B.Errors.BAD_CRC());throw B.Errors.BAD_CRC()}else{if(t&&u)u(g);return g}case B.Constants.DEFLATED:var p=new Ee.Inflater(L,n.size);if(!t){if(g=p.inflate(),!A(g))throw B.Errors.BAD_CRC(`"${_.decode(o)}"`);return g}else p.inflateAsync(function(x,w){if(!u)return;if(w)u(Buffer.alloc(0),w);else if(!A(x))u(x,B.Errors.BAD_CRC());else u(x)});break;default:if(t&&u)u(Buffer.alloc(0),B.Errors.UNKNOWN_METHOD());throw B.Errors.UNKNOWN_METHOD()}}function c(t,u){if((!i||!i.length)&&Buffer.isBuffer(r)){if(t&&u)u(O());return O()}if(i.length&&!E){var I;switch(n.method){case B.Constants.STORED:if(n.compressedSize=n.size,I=Buffer.alloc(i.length),i.copy(I),t&&u)u(I);return I;default:case B.Constants.DEFLATED:var L=new Ee.Deflater(i);if(!t){var g=L.deflate();return n.compressedSize=g.length,g}else L.deflateAsync(function(p){I=Buffer.alloc(p.length),n.compressedSize=p.length,p.copy(I),u&&u(I)});L=null;break}}else if(t&&u)u(Buffer.alloc(0));else return Buffer.alloc(0)}function a(t,u){return B.readBigUInt64LE(t,u)}function l(t){try{var u=0,I,L,g;while(u+4<t.length)if(I=t.readUInt16LE(u),u+=2,L=t.readUInt16LE(u),u+=2,g=t.slice(u,u+L),u+=L,M.ID_ZIP64===I)d(g)}catch(p){throw B.Errors.EXTRA_FIELD_PARSE_ERROR()}}function d(t){var u,I,L,g;if(t.length>=M.EF_ZIP64_SCOMP){if(u=a(t,M.EF_ZIP64_SUNCOMP),n.size===M.EF_ZIP64_OR_32)n.size=u}if(t.length>=M.EF_ZIP64_RHO){if(I=a(t,M.EF_ZIP64_SCOMP),n.compressedSize===M.EF_ZIP64_OR_32)n.compressedSize=I}if(t.length>=M.EF_ZIP64_DSN){if(L=a(t,M.EF_ZIP64_RHO),n.offset===M.EF_ZIP64_OR_32)n.offset=L}if(t.length>=M.EF_ZIP64_DSN+4){if(g=t.readUInt32LE(M.EF_ZIP64_DSN),n.diskNumStart===M.EF_ZIP64_OR_16)n.diskNumStart=g}}return{get entryName(){return _.decode(o)},get rawEntryName(){return o},set entryName(t){o=B.toBuffer(t,_.encode);var u=o[o.length-1];E=u===47||u===92,n.fileNameLength=o.length},get efs(){if(typeof S==="function")return S(this.entryName);else return S},get extra(){return m},set extra(t){m=t,n.extraLength=t.length,l(t)},get comment(){return _.decode(f)},set comment(t){if(f=B.toBuffer(t,_.encode),n.commentLength=f.length,f.length>65535)throw B.Errors.COMMENT_TOO_LONG()},get name(){let t=_.decode(o);return E?t.replace(/[/\\]$/,"").split("/").pop():t.split("/").pop()},get isDirectory(){return E},getCompressedData:function(){return c(!1,null)},getCompressedDataAsync:function(t){c(!0,t)},setData:function(t){if(i=B.toBuffer(t,B.decoder.encode),!E&&i.length)n.size=i.length,n.method=B.Constants.DEFLATED,n.crc=B.crc32(t),n.changed=!0;else n.method=B.Constants.STORED},getData:function(t){if(n.changed)return i;else return s(!1,null,t)},getDataAsync:function(t,u){if(n.changed)t(i);else s(!0,t,u)},set attr(t){n.attr=t},get attr(){return n.attr},set header(t){n.loadFromBinary(t)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=m.length;var t=n.centralHeaderToBinary(),u=B.Constants.CENHDR;return o.copy(t,u),u+=o.length,m.copy(t,u),u+=n.extraLength,f.copy(t,u),t},packLocalHeader:function(){let t=0;n.flags_efs=this.efs,n.extraLocalLength=C.length;let u=n.localHeaderToBinary(),I=Buffer.alloc(u.length+o.length+n.extraLocalLength);return u.copy(I,t),t+=u.length,o.copy(I,t),t+=o.length,C.copy(I,t),t+=C.length,I},toJSON:function(){let t=function(u){return"<"+(u&&u.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:t(r),data:t(i)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var nt=H(function(Dn,tt){var Qe=de(),et=le(),R=K();tt.exports=function(e,r){var n=[],o=Object.create(null),f=Buffer.alloc(0),E=new et.MainHeader,i=!1,m=null;let C=new Set,S=r,{noSort:N,decoder:_}=S;if(e)s(S.readEntries);else i=!0;function O(){let a=new Set;for(let l of Object.keys(o)){let d=l.split("/");if(d.pop(),!d.length)continue;for(let t=0;t<d.length;t++){let u=d.slice(0,t+1).join("/")+"/";a.add(u)}}for(let l of a)if(!(l in o)){let d=new Qe(S);d.entryName=l,d.attr=16,d.temporary=!0,n.push(d),o[d.entryName]=d,C.add(d)}}function A(){if(i=!0,o=Object.create(null),E.diskEntries>(e.length-E.offset)/R.Constants.CENHDR)throw R.Errors.DISK_ENTRY_TOO_LARGE();n=Array(E.diskEntries);var a=E.offset;for(var l=0;l<n.length;l++){var d=a,t=new Qe(S,e);if(t.header=e.slice(d,d+=R.Constants.CENHDR),t.entryName=e.slice(d,d+=t.header.fileNameLength),t.header.extraLength)t.extra=e.slice(d,d+=t.header.extraLength);if(t.header.commentLength)t.comment=e.slice(d,d+t.header.commentLength);if(a+=t.header.centralHeaderSize,t.entryName in o)throw R.Errors.DUPLICATE_ENTRY(`"${t.entryName}"`);n[l]=t,o[t.entryName]=t}C.clear(),O()}function s(a){var l=e.length-R.Constants.ENDHDR,d=Math.max(0,l-65535),t=d,u=e.length,I=-1,L=0;if(typeof S.trailingSpace==="boolean"?S.trailingSpace:!1)d=0;for(l;l>=t;l--){if(e[l]!==80)continue;if(e.readUInt32LE(l)===R.Constants.ENDSIG){I=l,L=l,u=l+R.Constants.ENDHDR,t=l-R.Constants.END64HDR;continue}if(e.readUInt32LE(l)===R.Constants.END64SIG){t=d;continue}if(e.readUInt32LE(l)===R.Constants.ZIP64SIG){I=l,u=l+R.readBigUInt64LE(e,l+R.Constants.ZIP64SIZE)+R.Constants.ZIP64LEAD;break}}if(I==-1)throw R.Errors.INVALID_FORMAT();if(E.loadFromBinary(e.slice(I,u)),E.commentLength)f=e.slice(L+R.Constants.ENDHDR);if(a)A()}function c(){if(n.length>1&&!N)n=n.map((a)=>({entry:a,key:a.entryName.toLowerCase()})).sort((a,l)=>a.key.localeCompare(l.key)).map((a)=>a.entry)}return{get entries(){if(!i)A();return n.filter((a)=>!C.has(a))},get comment(){return _.decode(f)},set comment(a){f=R.toBuffer(a,_.encode),E.commentLength=f.length},getEntryCount:function(){if(!i)return E.diskEntries;return n.length},forEach:function(a){this.entries.forEach(a)},getEntry:function(a){if(!i)A();return o[a]||null},setEntry:function(a){if(!i)A();n.push(a),o[a.entryName]=a,E.totalEntries=n.length},deleteFile:function(a,l=!0){if(!i)A();let d=o[a];this.getEntryChildren(d,l).map((u)=>u.entryName).forEach(this.deleteEntry)},deleteEntry:function(a){if(!i)A();let l=o[a],d=n.indexOf(l);if(d>=0)n.splice(d,1),delete o[a],E.totalEntries=n.length},getEntryChildren:function(a,l=!0){if(!i)A();if(typeof a==="object")if(a.isDirectory&&l){let d=[],t=a.entryName;for(let u of n)if(u.entryName.startsWith(t))d.push(u);return d}else return[a];return[]},getChildCount:function(a){if(a&&a.isDirectory){let l=this.getEntryChildren(a);return l.includes(a)?l.length-1:l.length}return 0},compressToBuffer:function(){if(!i)A();c();let a=[],l=[],d=0,t=0;E.size=0,E.offset=0;let u=0;for(let g of this.entries){let p=g.getCompressedData();g.header.offset=t;let x=g.packLocalHeader(),w=x.length+p.length;t+=w,a.push(x),a.push(p);let U=g.packCentralHeader();l.push(U),E.size+=U.length,d+=w+U.length,u++}d+=E.mainHeaderSize,E.offset=t,E.totalEntries=u,t=0;let I=Buffer.alloc(d);for(let g of a)g.copy(I,t),t+=g.length;for(let g of l)g.copy(I,t),t+=g.length;let L=E.toBinary();if(f)f.copy(L,L.length-f.length);return L.copy(I,t),e=I,i=!1,I},toAsyncBuffer:function(a,l,d,t){try{if(!i)A();c();let u=[],I=[],L=0,g=0,p=0;E.size=0,E.offset=0;let x=function(w){if(w.length>0){let U=w.shift(),P=U.entryName+U.extra.toString();if(d)d(P);U.getCompressedDataAsync(function(v){if(t)t(P);U.header.offset=g;let b=U.packLocalHeader(),ne=b.length+v.length;g+=ne,u.push(b),u.push(v);let k=U.packCentralHeader();I.push(k),E.size+=k.length,L+=ne+k.length,p++,x(w)})}else{L+=E.mainHeaderSize,E.offset=g,E.totalEntries=p,g=0;let U=Buffer.alloc(L);u.forEach(function(v){v.copy(U,g),g+=v.length}),I.forEach(function(v){v.copy(U,g),g+=v.length});let P=E.toBinary();if(f)f.copy(P,P.length-f.length);P.copy(U,g),e=U,i=!1,a(U)}};x(Array.from(this.entries))}catch(u){l(u)}}}}});var it=H(function(yn,ot){var F=K(),T=j("path"),vt=de(),Ht=nt(),W=(...e)=>F.findLast(e,(r)=>typeof r==="boolean"),rt=(...e)=>F.findLast(e,(r)=>typeof r==="string"),Mt=(...e)=>F.findLast(e,(r)=>typeof r==="function"),zt={noSort:!1,readEntries:!1,method:F.Constants.NONE,fs:null};ot.exports=function(e,r){let n=null,o=Object.assign(Object.create(null),zt);if(e&&typeof e==="object"){if(!(e instanceof Uint8Array)){if(Object.assign(o,e),e=o.input?o.input:void 0,o.input)delete o.input}if(Buffer.isBuffer(e))n=e,o.method=F.Constants.BUFFER,e=void 0}Object.assign(o,r);let f=new F(o),E=(s)=>{s.filter((c)=>c.attr).sort((c,a)=>a.path.length-c.path.length).forEach((c)=>f.fs.chmodSync(c.path,c.attr))};if(typeof o.decoder!=="object"||typeof o.decoder.encode!=="function"||typeof o.decoder.decode!=="function")o.decoder=F.decoder;if(e&&typeof e==="string")if(f.fs.existsSync(e))o.method=F.Constants.FILE,o.filename=e,n=f.fs.readFileSync(e);else throw F.Errors.INVALID_FILENAME();let i=new Ht(n,o),{canonical:m,sanitize:C,zipnamefix:S}=F;function N(s){if(s&&i){var c;if(typeof s==="string")c=i.getEntry(T.posix.normalize(s));if(typeof s==="object"&&typeof s.entryName<"u"&&typeof s.header<"u")c=i.getEntry(s.entryName);if(c)return c}return null}function _(s){let{join:c,normalize:a,sep:l}=T.posix;return c(T.isAbsolute(s)?"/":".",a(l+s.split("\\").join(l)+l))}function O(s){if(s instanceof RegExp)return function(c){return function(a){return c.test(a)}}(s);else if(typeof s!=="function")return()=>!0;return s}let A=(s,c)=>{let a=c.slice(-1);return a=a===f.sep?f.sep:"",T.relative(s,c)+a};return{readFile:function(s,c){var a=N(s);return a&&a.getData(c)||null},childCount:function(s){let c=N(s);if(c)return i.getChildCount(c)},readFileAsync:function(s,c){var a=N(s);if(a)a.getDataAsync(c);else c(null,"getEntry failed for:"+s)},readAsText:function(s,c){var a=N(s);if(a){var l=a.getData();if(l&&l.length)return l.toString(c||"utf8")}return""},readAsTextAsync:function(s,c,a){var l=N(s);if(l)l.getDataAsync(function(d,t){if(t){c(d,t);return}if(d&&d.length)c(d.toString(a||"utf8"));else c("")});else c("")},deleteFile:function(s,c=!0){var a=N(s);if(a)i.deleteFile(a.entryName,c)},deleteEntry:function(s){var c=N(s);if(c)i.deleteEntry(c.entryName)},addZipComment:function(s){i.comment=s},getZipComment:function(){return i.comment||""},addZipEntryComment:function(s,c){var a=N(s);if(a)a.comment=c},getZipEntryComment:function(s){var c=N(s);if(c)return c.comment||"";return""},updateFile:function(s,c){var a=N(s);if(a)a.setData(c)},addLocalFile:function(s,c,a,l){if(f.fs.existsSync(s)){c=c?_(c):"";let d=T.win32.basename(T.win32.normalize(s));c+=a?a:d;let t=f.fs.statSync(s),u=t.isFile()?f.fs.readFileSync(s):Buffer.alloc(0);if(t.isDirectory())c+=f.sep;this.addFile(c,u,l,t)}else throw F.Errors.FILE_NOT_FOUND(s)},addLocalFileAsync:function(s,c){s=typeof s==="object"?s:{localPath:s};let a=T.resolve(s.localPath),{comment:l}=s,{zipPath:d,zipName:t}=s,u=this;f.fs.stat(a,function(I,L){if(I)return c(I,!1);d=d?_(d):"";let g=T.win32.basename(T.win32.normalize(a));if(d+=t?t:g,L.isFile())f.fs.readFile(a,function(p,x){if(p)return c(p,!1);return u.addFile(d,x,l,L),setImmediate(c,void 0,!0)});else if(L.isDirectory())return d+=f.sep,u.addFile(d,Buffer.alloc(0),l,L),setImmediate(c,void 0,!0)})},addLocalFolder:function(s,c,a){if(a=O(a),c=c?_(c):"",s=T.normalize(s),f.fs.existsSync(s)){let l=f.findFiles(s),d=this;if(l.length)for(let t of l){let u=T.join(c,A(s,t));if(a(u))d.addLocalFile(t,T.dirname(u))}}else throw F.Errors.FILE_NOT_FOUND(s)},addLocalFolderAsync:function(s,c,a,l){l=O(l),a=a?_(a):"",s=T.normalize(s);var d=this;f.fs.open(s,"r",function(t){if(t&&t.code==="ENOENT")c(void 0,F.Errors.FILE_NOT_FOUND(s));else if(t)c(void 0,t);else{var u=f.findFiles(s),I=-1,L=function(){if(I+=1,I<u.length){var g=u[I],p=A(s,g).split("\\").join("/");if(p=p.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),l(p))f.fs.stat(g,function(x,w){if(x)c(void 0,x);if(w.isFile())f.fs.readFile(g,function(U,P){if(U)c(void 0,U);else d.addFile(a+p,P,"",w),L()});else d.addFile(a+p+"/",Buffer.alloc(0),"",w),L()});else process.nextTick(()=>{L()})}else c(!0,void 0)};L()}})},addLocalFolderAsync2:function(s,c){let a=this;s=typeof s==="object"?s:{localPath:s};let l=T.resolve(s.localPath),{zipPath:d,filter:t,namefix:u}=s;if(t instanceof RegExp)t=function(g){return function(p){return g.test(p)}}(t);else if(typeof t!=="function")t=function(){return!0};if(d=d?_(d):"",u==="latin1")u=(g)=>g.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof u!=="function")u=(g)=>g;let I=(g)=>T.join(d,u(A(l,g))),L=(g)=>T.win32.basename(T.win32.normalize(u(g)));f.fs.open(l,"r",function(g){if(g&&g.code==="ENOENT")c(F.Errors.FILE_NOT_FOUND(l),!1);else if(g)c(g,!1);else f.findFilesAsync(l,function(p,x){if(p)return c(p,!1);if(x=x.filter((w)=>t(I(w))),!x.length)return c(void 0,!0);setImmediate(x.reverse().reduce(function(w,U){return function(P,v){if(P||v===!1)return setImmediate(w,P,!1);a.addLocalFileAsync({localPath:U,zipPath:T.dirname(I(U)),zipName:L(U)},w)}},c))})})},addLocalFolderPromise:function(s,c){return new Promise((a,l)=>{this.addLocalFolderAsync2(Object.assign({localPath:s},c),(d,t)=>{if(d)return l(d);if(t)a(this)})})},addFile:function(s,c,a,l){s=S(s);let d=N(s),t=d!=null;if(!t)d=new vt(o),d.entryName=s;d.comment=a||"";let u=typeof l==="object"&&l instanceof f.fs.Stats;if(u)d.header.time=l.mtime;var I=d.isDirectory?16:0;let L=d.isDirectory?16384:32768;if(u)L|=4095&l.mode;else if(typeof l==="number")L|=4095&l;else L|=d.isDirectory?493:420;if(I=(I|L<<16)>>>0,d.attr=I,d.setData(c),!t)i.setEntry(d);return d},getEntries:function(s){return i.password=s,i?i.entries:[]},getEntry:function(s){return N(s)},getEntryCount:function(){return i.getEntryCount()},forEach:function(s){return i.forEach(s)},extractEntryTo:function(s,c,a,l,d,t){l=W(!1,l),d=W(!1,d),a=W(!0,a),t=rt(d,t);var u=N(s);if(!u)throw F.Errors.NO_ENTRY();var I=m(u.entryName),L=C(c,t&&!u.isDirectory?m(t):a?I:T.basename(I));if(u.isDirectory){var g=i.getEntryChildren(u);return g.forEach(function(w){if(w.isDirectory)return;var U=w.getData();if(!U)throw F.Errors.CANT_EXTRACT_FILE();var P=m(a?w.entryName:w.entryName.substring(u.entryName.length)),v=C(c,P);f.assertPathSafe(c,v);let b=d?w.header.fileAttr:void 0;f.writeFileTo(v,U,l,b)}),!0}var p=u.getData(i.password);if(!p)throw F.Errors.CANT_EXTRACT_FILE();if(f.assertPathSafe(c,L),f.fs.existsSync(L)&&!l)throw F.Errors.CANT_OVERRIDE();let x=d?s.header.fileAttr:void 0;return f.writeFileTo(L,p,l,x),!0},test:function(s){if(!i)return!1;for(var c of i.entries)try{if(c.isDirectory)continue;var a=c.getData(s);if(!a)return!1}catch(l){return!1}return!0},extractAllTo:function(s,c,a,l){if(a=W(!1,a),l=rt(a,l),c=W(!1,c),!i)throw F.Errors.NO_ZIP();let d=[];i.entries.forEach(function(t){var u=C(s,m(t.entryName));if(f.assertPathSafe(s,u),t.isDirectory){if(f.makeDir(u),a)d.push({path:u,attr:t.header.fileAttr});return}var I=t.getData(l);if(!I)throw F.Errors.CANT_EXTRACT_FILE();let L=a?t.header.fileAttr:void 0;f.writeFileTo(u,I,c,L);try{f.fs.utimesSync(u,t.header.time,t.header.time)}catch(g){}}),E(d)},extractAllToAsync:function(s,c,a,l){if(l=Mt(c,a,l),a=W(!1,a),c=W(!1,c),!l)return new Promise((p,x)=>{this.extractAllToAsync(s,c,a,function(w){if(w)x(w);else p(this)})});if(!i){l(F.Errors.NO_ZIP());return}s=T.resolve(s);let d=(p)=>C(s,T.normalize(m(p.entryName))),t=(p,x)=>Error(p+': "'+x+'"'),u=[],I=[];i.entries.forEach((p)=>{if(p.isDirectory)u.push(p);else I.push(p)});let L=[];for(let p of u){let x=d(p),w=a?p.header.fileAttr:void 0;try{f.assertPathSafe(s,x),f.makeDir(x)}catch(U){l(t("Unable to create folder",x));continue}if(w)L.push({path:x,attr:w});try{f.fs.utimesSync(x,p.header.time,p.header.time)}catch(U){}}let g=(p)=>{if(!p)try{E(L)}catch(x){return l(t("Unable to set folder permissions",x.path||""))}l(p)};I.reverse().reduce(function(p,x){return function(w){if(w)p(w);else{let U=T.normalize(m(x.entryName)),P=C(s,U);try{f.assertPathSafe(s,P)}catch(v){return p(v)}x.getDataAsync(function(v,b){if(b)p(b);else if(!v)p(F.Errors.CANT_EXTRACT_FILE());else{let ne=a?x.header.fileAttr:void 0;f.writeFileToAsync(P,v,c,ne,function(k){if(!k)return p(t("Unable to write file",P));f.fs.utimes(P,x.header.time,x.header.time,function(){p()})})}})}}},g)()},writeZip:function(s,c){if(arguments.length===1){if(typeof s==="function")c=s,s=""}if(!s&&o.filename)s=o.filename;if(!s)return;var a=i.compressToBuffer();if(a){var l=f.writeFileTo(s,a,!0);if(typeof c==="function")c(!l?Error("failed"):null,"")}},writeZipPromise:function(s,c){let{overwrite:a,perm:l}=Object.assign({overwrite:!0},c);return new Promise((d,t)=>{if(!s&&o.filename)s=o.filename;if(!s)t("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((u)=>{let I=(L)=>L?d(L):t("ADM-ZIP: Wasn't able to write zip file");f.writeFileToAsync(s,u,a,l,I)},t)})},toBufferPromise:function(){return new Promise((s,c)=>{i.toAsyncBuffer(s,c)})},toBuffer:function(s,c,a,l){if(typeof s==="function")return i.toAsyncBuffer(s,c,a,l),null;return i.compressToBuffer()}}}});var st=J(()=>{ce()});_e();st();var at=ht(it());import{parentPort as ft,workerData as Gt}from"worker_threads";import*as ct from"path";function bt(){let{bundlePath:e,destination:r}=Gt;try{let n=new at.default(e);Ne(n,r),n.extractAllTo(ct.resolve(r),!0);let o={ok:!0};ft?.postMessage(o)}catch(n){let o={ok:!1,message:Q(n),stack:n instanceof Error?n.stack:void 0};ft?.postMessage(o)}}bt();
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=5BF042EC4119BFCA64756E2164756E21
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[](https://deepscan.io/dashboard#view=project&tid=5165&pid=8526&bid=103329)
|
|
6
6
|
[](https://snyk.io/test/github/Borewit/strtok3?targetFile=package.json)
|
|
7
7
|
[](https://www.codacy.com/app/Borewit/strtok3?utm_source=github.com&utm_medium=referral&utm_content=Borewit/strtok3&utm_campaign=Badge_Grade)
|
|
8
|
+
[](https://codecov.io/gh/Borewit/strtok3)
|
|
8
9
|
# strtok3
|
|
9
10
|
|
|
10
11
|
A promise-based streaming [*tokenizer*](#tokenizer-object) for [Node.js](https://nodejs.org) and browsers.
|
|
@@ -45,7 +46,7 @@ For TypeScript CommonJS backward compatibility, you can use [load-esm](https://g
|
|
|
45
46
|
Use Node.js 24 LTS to build the project and install development dependencies.
|
|
46
47
|
This build requirement is separate from the Node.js ≥ 18 runtime requirement in `package.json`.
|
|
47
48
|
CI builds once with Node.js 24, then runs the compiled JavaScript unit tests across the Node.js compatibility matrix and Bun 1.2.x, 1.3.x, and 1.4.x.
|
|
48
|
-
Coverage is collected in a separate Node.js 24 job.
|
|
49
|
+
Coverage is collected in a separate Node.js 24 job and uploaded to Codecov.
|
|
49
50
|
|
|
50
51
|
For local development, running the TypeScript tests with `tsx` requires Node.js 18.19+ (18.x) or Node.js ≥ 20.6.0.
|
|
51
52
|
|
|
@@ -65,15 +66,18 @@ If you find this project useful and would like to support its development, consi
|
|
|
65
66
|
Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer-object):
|
|
66
67
|
- [fromBlob](#fromblob-function)
|
|
67
68
|
- [fromBuffer](#frombuffer-function)
|
|
68
|
-
- [fromFile](#fromfile-function)
|
|
69
|
-
- [fromStream](#fromstream-function)
|
|
69
|
+
- [fromFile](#fromfile-function)
|
|
70
|
+
- [fromStream](#fromstream-function)
|
|
70
71
|
- [fromWebStream](#fromwebstream-function)
|
|
72
|
+
- [createTokenizerView](#createtokenizerview-function)
|
|
71
73
|
|
|
72
74
|
> [!NOTE]
|
|
73
75
|
> `fromFile` requires Node.js file-system APIs, and `fromStream` requires a Node.js readable stream.
|
|
74
76
|
> In browsers, use `fromBlob`, `fromBuffer`, or `fromWebStream`.
|
|
75
77
|
|
|
76
78
|
All methods return a [`Tokenizer`](#tokenizer-object), either directly or via a promise.
|
|
79
|
+
The `strtok3/core` entry point exports all factories except `fromFile` and can be used
|
|
80
|
+
without Node.js file-system APIs. In browsers, `strtok3` resolves to this core entry point.
|
|
77
81
|
|
|
78
82
|
#### `fromBlob()` function
|
|
79
83
|
|
|
@@ -141,13 +145,13 @@ parse();
|
|
|
141
145
|
Creates a [*tokenizer*](#tokenizer-object) from a local file.
|
|
142
146
|
|
|
143
147
|
```ts
|
|
144
|
-
function fromFile(sourceFilePath: string, options?:
|
|
148
|
+
function fromFile(sourceFilePath: string, options?: IFromFileOptions): Promise<FileTokenizer>
|
|
145
149
|
```
|
|
146
150
|
|
|
147
151
|
| Parameter | Type | Description |
|
|
148
152
|
|----------------|----------|----------------------------|
|
|
149
153
|
| sourceFilePath | `string` | Path to file to read from |
|
|
150
|
-
| options | [
|
|
154
|
+
| options | [IFromFileOptions](#ifromfileoptions-interface) | Optional file tokenizer options |
|
|
151
155
|
|
|
152
156
|
> [!NOTE]
|
|
153
157
|
> - Only available for Node.js engines
|
|
@@ -248,6 +252,83 @@ async function parse() {
|
|
|
248
252
|
parse();
|
|
249
253
|
```
|
|
250
254
|
|
|
255
|
+
#### `createTokenizerView()` function
|
|
256
|
+
|
|
257
|
+
Borrow a finite range of an existing tokenizer without buffering it or taking
|
|
258
|
+
ownership of its input. Available from both `strtok3` and `strtok3/core`.
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
function createTokenizerView(source: ITokenizer, length: number): ITokenizerView
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The view starts at `source.position`, with local `position` zero and
|
|
265
|
+
`fileInfo.size` equal to `length`. Creation does not read or skip bytes. The size
|
|
266
|
+
is the declared range, so it can exceed the actual remaining input. The outer
|
|
267
|
+
file's MIME type, path, and URL are not copied to the view.
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
import { createTokenizerView, fromBuffer } from 'strtok3';
|
|
271
|
+
import { UINT8 } from 'token-types';
|
|
272
|
+
|
|
273
|
+
const source = fromBuffer(new Uint8Array([10, 20, 30, 40, 50]));
|
|
274
|
+
await source.ignore(1);
|
|
275
|
+
const chunk = createTokenizerView(source, 3); // source bytes [20, 30, 40]
|
|
276
|
+
|
|
277
|
+
console.log(await chunk.readToken(UINT8)); // 20; chunk.position = 1
|
|
278
|
+
const child = chunk.createView(1); // same as createTokenizerView(chunk, 1)
|
|
279
|
+
console.log(await child.readToken(UINT8)); // 30; chunk.position = 2
|
|
280
|
+
await child.close(); // source stays open, at position 3
|
|
281
|
+
|
|
282
|
+
console.log(chunk.remaining); // 1
|
|
283
|
+
await chunk.consumeRemainder(); // exactly consume 40, or throw on truncation
|
|
284
|
+
await chunk.close();
|
|
285
|
+
console.log(await source.readToken(UINT8)); // 50
|
|
286
|
+
await source.close();
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
All read and peek positions, including explicit offsets and `setPosition()`, are
|
|
290
|
+
relative to the view's start. Nested views must fit inside their parent's
|
|
291
|
+
remaining range. A view exposes `setPosition()` and reports random access only
|
|
292
|
+
when its source supports it; a stream with a known size remains forward-only.
|
|
293
|
+
The overload for an `IRandomAccessTokenizer` returns an
|
|
294
|
+
`IRandomAccessTokenizerView`, including for nested `createView()` calls.
|
|
295
|
+
|
|
296
|
+
A request crossing the declared boundary rejects with `TokenizerBoundaryError`,
|
|
297
|
+
a `RangeError` with `position`, `length`, and `size` properties. This applies to
|
|
298
|
+
reads, peeks, tokens, and skips, even with `mayBeLess: true`. Invalid lengths,
|
|
299
|
+
offsets, and unsafe offset arithmetic reject before allocating token buffers or
|
|
300
|
+
consuming input. The source's token allocation and stream lookahead limits still
|
|
301
|
+
apply through nested views.
|
|
302
|
+
|
|
303
|
+
A request inside the view that encounters truncated underlying input rejects
|
|
304
|
+
with `EndOfStreamError`. Buffer reads and peeks with `mayBeLess: true` may return
|
|
305
|
+
fewer bytes within the requested range; token reads and peeks always require a
|
|
306
|
+
complete token. A failed exact read may have consumed part of the input; the
|
|
307
|
+
shared cursor reflects the bytes consumed. Peeks do not advance that cursor.
|
|
308
|
+
|
|
309
|
+
`ignore()` preserves the source's skip behavior, which may return a shorter
|
|
310
|
+
count or reject at EOF. Use `consumeRemainder()` when the entire declared
|
|
311
|
+
remainder must exist: it returns the number consumed, or rejects with
|
|
312
|
+
`EndOfStreamError`. On random-access sources it verifies the final byte and
|
|
313
|
+
advances the cursor without reading the whole remainder. On streams it drains
|
|
314
|
+
the remainder using the source's bounded skip buffers.
|
|
315
|
+
|
|
316
|
+
The source, parent, child, and sibling views share one cursor. Use them
|
|
317
|
+
sequentially, and close a child before resuming its parent. `close()` is
|
|
318
|
+
idempotent, does not drain the remainder, and never closes or aborts the source.
|
|
319
|
+
After a partially consumed child closes, the parent resumes at that same byte,
|
|
320
|
+
not at the child's declared end. Call `child.consumeRemainder()` before closing
|
|
321
|
+
when the parent should resume after the entire child range. Closed views reject
|
|
322
|
+
further operations and keep their last local position; closing a parent view
|
|
323
|
+
also prevents its children from being used.
|
|
324
|
+
|
|
325
|
+
Overlapping operations through a view or its parent/child chain are rejected;
|
|
326
|
+
`close()` also rejects while that view has an active operation. Direct operations
|
|
327
|
+
on the original source, or separate views created from it, cannot be coordinated
|
|
328
|
+
by a view, so callers must keep those sequential too. Explicit `abort()`
|
|
329
|
+
propagates to the shared source to cancel pending input and affects its other
|
|
330
|
+
users; it also closes the view.
|
|
331
|
+
|
|
251
332
|
### `Tokenizer` object
|
|
252
333
|
The *tokenizer* is an abstraction of a [stream](https://nodejs.org/api/stream.html), file or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), allowing _reading_ or _peeking_ from the stream.
|
|
253
334
|
It can also be translated in chunked reads, as done in [@tokenizer/http](https://github.com/Borewit/tokenizer-http);
|
|
@@ -264,9 +345,18 @@ It can also be translated in chunked reads, as done in [@tokenizer/http](https:/
|
|
|
264
345
|
_Read_ methods advance the stream pointer, while _peek_ methods do not.
|
|
265
346
|
|
|
266
347
|
There are two kinds of functions:
|
|
267
|
-
1. *read* methods: used to read a *token* or bytes into a buffer from the [*tokenizer*](#tokenizer-object).
|
|
348
|
+
1. *read* methods: used to read a *token* or bytes into a buffer from the [*tokenizer*](#tokenizer-object). After a successful read, `tokenizer.position` is the starting position of the read plus the number of bytes read. An explicit position can skip ahead or, for random-access tokenizers, move backwards.
|
|
268
349
|
2. *peek* methods: same as the read, but it will *not* advance the pointer. It allows to read (peek) ahead.
|
|
269
350
|
|
|
351
|
+
Reads and peeks require the full requested length unless `mayBeLess: true` is passed to
|
|
352
|
+
`readBuffer` or `peekBuffer`. Otherwise, insufficient input rejects with the exported
|
|
353
|
+
`EndOfStreamError`. Token methods always require the full token.
|
|
354
|
+
|
|
355
|
+
A failed exact stream read can consume partial input and advance `tokenizer.position`
|
|
356
|
+
by the number of bytes consumed. A failed exact stream peek leaves `tokenizer.position`
|
|
357
|
+
unchanged and retains the partial bytes for subsequent reads. Caller-provided buffers
|
|
358
|
+
may contain partial data even when the operation rejects.
|
|
359
|
+
|
|
270
360
|
#### `readBuffer` function
|
|
271
361
|
|
|
272
362
|
Read data from the _tokenizer_ into provided "buffer" (`Uint8Array`).
|
|
@@ -342,6 +432,8 @@ readNumber(token: IToken<number>): Promise<number>
|
|
|
342
432
|
| token | [IToken<number>](#token-object) | Numeric token to read from the tokenizer-stream. |
|
|
343
433
|
|
|
344
434
|
A promise resolving to a numeric value read and decoded from the *tokenizer-stream*.
|
|
435
|
+
Uses a reusable 8-byte buffer, so `token.len` must be at most 8 bytes.
|
|
436
|
+
For larger tokens or values such as `bigint`, use `readToken` instead.
|
|
345
437
|
|
|
346
438
|
#### `peekNumber` function
|
|
347
439
|
|
|
@@ -353,10 +445,11 @@ peekNumber(token: IToken<number>): Promise<number>
|
|
|
353
445
|
|
|
354
446
|
Returns a promise resolving to the decoded numeric value.
|
|
355
447
|
Like `readNumber`, rejects with `EndOfStreamError` if the token cannot be read in full.
|
|
448
|
+
The same 8-byte token limit applies; use `peekToken` for larger tokens or values such as `bigint`.
|
|
356
449
|
|
|
357
450
|
#### `ignore` function
|
|
358
451
|
|
|
359
|
-
Advance the offset pointer
|
|
452
|
+
Advance the offset pointer by the given number of bytes.
|
|
360
453
|
|
|
361
454
|
```ts
|
|
362
455
|
ignore(length: number): Promise<number>
|
|
@@ -364,7 +457,7 @@ ignore(length: number): Promise<number>
|
|
|
364
457
|
|
|
365
458
|
| Parameter | Type | Description |
|
|
366
459
|
|------------|--------|------------------------------------------------------------------|
|
|
367
|
-
| length | number | Non-negative number of bytes to ignore. Advances `tokenizer.position`. |
|
|
460
|
+
| length | number | Non-negative safe integer number of bytes to ignore. Advances `tokenizer.position`. |
|
|
368
461
|
|
|
369
462
|
Returns a promise resolving to the number of bytes ignored.
|
|
370
463
|
Buffer, blob, and file tokenizers stop at the known file size. Stream tokenizers reject with `EndOfStreamError` if the requested bytes are unavailable.
|
|
@@ -390,6 +483,10 @@ abort(): Promise<void>
|
|
|
390
483
|
|
|
391
484
|
This is a no-op for buffer, blob, and file tokenizers.
|
|
392
485
|
|
|
486
|
+
For Node.js streams, pending reads reject with the exported `AbortError`, and buffered
|
|
487
|
+
peek data is discarded. The underlying stream is not destroyed. Calling `close()` or
|
|
488
|
+
aborting the configured `AbortSignal` has the same effect on pending Node.js stream reads.
|
|
489
|
+
|
|
393
490
|
For Web streams, `abort()` releases a BYOB reader's lock without cancelling the source. A default reader cancels the source but keeps its lock until `close()` is called. An `AbortSignal` invokes the same abort behavior.
|
|
394
491
|
|
|
395
492
|
#### `supportsRandomAccess` function
|
|
@@ -401,6 +498,25 @@ supportsRandomAccess(): boolean
|
|
|
401
498
|
Returns `true` for buffer, blob, and file tokenizers, and `false` for stream tokenizers.
|
|
402
499
|
When random access is supported, read and peek methods can use positions before `tokenizer.position`.
|
|
403
500
|
|
|
501
|
+
#### `isRandomAccessTokenizer` helper
|
|
502
|
+
|
|
503
|
+
Exported from both `strtok3` and `strtok3/core`:
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
import { isRandomAccessTokenizer, type ITokenizer } from 'strtok3';
|
|
507
|
+
|
|
508
|
+
function skipToEnd(tokenizer: ITokenizer): void {
|
|
509
|
+
if (isRandomAccessTokenizer(tokenizer)) {
|
|
510
|
+
tokenizer.setPosition(tokenizer.fileInfo.size);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
Narrows `ITokenizer` to `IRandomAccessTokenizer` by checking `supportsRandomAccess()`,
|
|
516
|
+
a callable `setPosition`, and a numeric file size. A known size alone does not imply
|
|
517
|
+
random access. Existing third-party implementations can keep returning a boolean
|
|
518
|
+
from `supportsRandomAccess()` without changing their interface.
|
|
519
|
+
|
|
404
520
|
#### `setPosition` function
|
|
405
521
|
|
|
406
522
|
Available on buffer, blob, and file tokenizers (`IRandomAccessTokenizer`).
|
|
@@ -471,16 +587,51 @@ try {
|
|
|
471
587
|
}
|
|
472
588
|
```
|
|
473
589
|
|
|
590
|
+
### `IFromFileOptions` interface
|
|
591
|
+
|
|
592
|
+
Extends [ITokenizerOptions](#itokenizeroptions-interface) for `fromFile()`.
|
|
593
|
+
|
|
594
|
+
| Attribute | Type | Description |
|
|
595
|
+
|-----------|------|-------------|
|
|
596
|
+
| regularFileOnly | `boolean` | When `true`, opens with `O_RDONLY \| O_NONBLOCK` and checks that the opened handle refers to a regular file. Defaults to `false`, preserving existing behavior. |
|
|
597
|
+
|
|
598
|
+
Use this option when non-regular inputs, such as FIFOs, should be rejected without waiting for a writer. Validation uses the opened handle, so replacing the pathname before opening does not bypass the check. Symbolic links to regular files are accepted.
|
|
599
|
+
|
|
600
|
+
If an opened handle is not a regular file, `fromFile()` closes it and rejects with the exported `NotRegularFileError`. Its `path` property identifies the requested path. Opening errors, stat errors, and abort errors continue to propagate; any handle acquired by the factory is closed if setup fails. After success, the caller must close the tokenizer.
|
|
601
|
+
|
|
602
|
+
```js
|
|
603
|
+
import { fromFile, NotRegularFileError } from 'strtok3';
|
|
604
|
+
|
|
605
|
+
try {
|
|
606
|
+
const tokenizer = await fromFile('somefile.bin', { regularFileOnly: true });
|
|
607
|
+
try {
|
|
608
|
+
// Parse the regular file.
|
|
609
|
+
} finally {
|
|
610
|
+
await tokenizer.close();
|
|
611
|
+
}
|
|
612
|
+
} catch (error) {
|
|
613
|
+
if (!(error instanceof NotRegularFileError)) {
|
|
614
|
+
throw error;
|
|
615
|
+
}
|
|
616
|
+
// Handle an input that is not a regular file.
|
|
617
|
+
}
|
|
618
|
+
```
|
|
619
|
+
|
|
474
620
|
### `IReadChunkOptions` interface
|
|
475
621
|
|
|
476
622
|
Each attribute is optional:
|
|
477
623
|
|
|
478
624
|
| Attribute | Type | Description |
|
|
479
625
|
|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
480
|
-
| length | number | Requested number of bytes to read or peek. Defaults to the target buffer length. |
|
|
481
|
-
| position | number | Byte offset to read or peek from. Defaults to [tokenizer.position](#tokenizer-attributes) when omitted. Earlier positions require random access. |
|
|
626
|
+
| length | number | Requested number of bytes to read or peek. Must be a non-negative safe integer no larger than the target buffer length. Defaults to the target buffer length. |
|
|
627
|
+
| position | number | Byte offset to read or peek from. Must be a non-negative safe integer. Defaults to [tokenizer.position](#tokenizer-attributes) when omitted. Earlier positions require random access. |
|
|
482
628
|
| mayBeLess | boolean | If `true`, allows fewer than the requested number of bytes to be read or peeked instead of throwing `EndOfStreamError`. Defaults to `false`. |
|
|
483
629
|
|
|
630
|
+
Invalid lengths or positions, including a `position + length` that exceeds the safe
|
|
631
|
+
integer range, reject with `RangeError`. Requesting an earlier position on a tokenizer
|
|
632
|
+
without random access rejects with `Error`. Data is written starting at index 0 of the
|
|
633
|
+
target buffer. To write at an offset, pass `buffer.subarray(offset)` as the target buffer.
|
|
634
|
+
|
|
484
635
|
Example usage:
|
|
485
636
|
```js
|
|
486
637
|
const bytesPeeked = await tokenizer.peekBuffer(buffer, {mayBeLess: true});
|
|
@@ -31,7 +31,7 @@ export class BufferTokenizer extends AbstractTokenizer {
|
|
|
31
31
|
*/
|
|
32
32
|
async peekBuffer(uint8Array, options) {
|
|
33
33
|
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
34
|
-
const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length);
|
|
34
|
+
const bytes2read = Math.max(0, Math.min(this.uint8Array.length - normOptions.position, normOptions.length));
|
|
35
35
|
if (!normOptions.mayBeLess && bytes2read < normOptions.length) {
|
|
36
36
|
throw new EndOfStreamError();
|
|
37
37
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import fs, {} from 'node:fs/promises';
|
|
2
3
|
import { throwIfAborted } from './AbortSignal.js';
|
|
3
4
|
import { AbstractTokenizer } from './AbstractTokenizer.js';
|
|
4
5
|
import { getMaxBufferSize } from './BufferSizeError.js';
|
|
6
|
+
import { NotRegularFileError } from './NotRegularFileError.js';
|
|
5
7
|
import { EndOfStreamError } from './stream/index.js';
|
|
6
8
|
export class FileTokenizer extends AbstractTokenizer {
|
|
7
9
|
/**
|
|
@@ -12,9 +14,13 @@ export class FileTokenizer extends AbstractTokenizer {
|
|
|
12
14
|
static async fromFile(sourceFilePath, options) {
|
|
13
15
|
getMaxBufferSize(options);
|
|
14
16
|
throwIfAborted(options?.abortSignal);
|
|
15
|
-
const
|
|
17
|
+
const flags = options?.regularFileOnly ? constants.O_RDONLY | constants.O_NONBLOCK : 'r';
|
|
18
|
+
const fileHandle = await fs.open(sourceFilePath, flags);
|
|
16
19
|
try {
|
|
17
20
|
const stat = await fileHandle.stat();
|
|
21
|
+
if (options?.regularFileOnly && !stat.isFile()) {
|
|
22
|
+
throw new NotRegularFileError(sourceFilePath);
|
|
23
|
+
}
|
|
18
24
|
return new FileTokenizer(fileHandle, {
|
|
19
25
|
...options,
|
|
20
26
|
fileInfo: { ...options?.fileInfo, path: sourceFilePath, size: stat.size }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Thrown when regularFileOnly is enabled and the opened handle is not a regular file. */
|
|
2
|
+
export class NotRegularFileError extends Error {
|
|
3
|
+
constructor(path) {
|
|
4
|
+
super(`Not a regular file: ${path}`);
|
|
5
|
+
this.path = path;
|
|
6
|
+
this.name = 'NotRegularFileError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -32,9 +32,10 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
32
32
|
return 0;
|
|
33
33
|
}
|
|
34
34
|
let bytesRead = 0;
|
|
35
|
+
// Account for partial input before reporting an exact-read failure.
|
|
35
36
|
while (bytesRead < normOptions.length) {
|
|
36
37
|
const chunkLength = Math.min(this.maxBufferSize, normOptions.length - bytesRead);
|
|
37
|
-
const count = await this.streamReader.read(uint8Array.subarray(bytesRead, bytesRead + chunkLength),
|
|
38
|
+
const count = await this.streamReader.read(uint8Array.subarray(bytesRead, bytesRead + chunkLength), true);
|
|
38
39
|
bytesRead += count;
|
|
39
40
|
this.position += count;
|
|
40
41
|
if (count < chunkLength) {
|
|
@@ -75,7 +76,11 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
75
76
|
}
|
|
76
77
|
if (normOptions.length > 0) {
|
|
77
78
|
try {
|
|
78
|
-
|
|
79
|
+
// The reader retains this buffer. Keep it independent of caller-owned memory,
|
|
80
|
+
// including partial bytes retained when an exact peek encounters truncation.
|
|
81
|
+
const peekBuffer = new Uint8Array(normOptions.length);
|
|
82
|
+
bytesRead = await this.streamReader.peek(peekBuffer, true);
|
|
83
|
+
uint8Array.set(peekBuffer.subarray(0, bytesRead));
|
|
79
84
|
}
|
|
80
85
|
catch (err) {
|
|
81
86
|
if (options?.mayBeLess && err instanceof EndOfStreamError) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A request exceeds a tokenizer view, rather than encountering truncated input. */
|
|
2
|
+
export class TokenizerBoundaryError extends RangeError {
|
|
3
|
+
constructor(position, length, size) {
|
|
4
|
+
super(`Range at position ${position} with length ${length} exceeds tokenizer view size ${size}`);
|
|
5
|
+
this.position = position;
|
|
6
|
+
this.length = length;
|
|
7
|
+
this.size = size;
|
|
8
|
+
this.name = 'TokenizerBoundaryError';
|
|
9
|
+
}
|
|
10
|
+
}
|