@zip.js/zip.js 2.16.1 → 2.18.0
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/deno.json +1 -1
- package/dist/zip-core-external.js +211 -130
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +180 -117
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +223 -132
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +192 -119
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +223 -132
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +194 -121
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +224 -132
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +181 -118
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +182 -119
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +212 -130
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +194 -121
- package/index-native.min.js +1 -1
- package/index.cjs +224 -132
- package/index.d.cts +87 -24
- package/index.d.ts +87 -24
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +2 -0
- package/lib/core/codec-worker-web.js +16 -3
- package/lib/core/codec-worker.js +2 -1
- package/lib/core/streams/codec-stream.js +2 -0
- package/lib/core/streams/zip-entry-stream.js +123 -102
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams.js +31 -12
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +2 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +16 -3
- package/lib/core/zip-reader.js +40 -11
- package/lib/core/zip-writer.js +1 -0
- package/lib/zip-core-reader.js +1 -0
- package/package.json +1 -1
package/dist/zip-fs.js
CHANGED
|
@@ -445,7 +445,7 @@
|
|
|
445
445
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const n$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e$1=t=>t({workerURI:t=>{const e="text/javascript";let r='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:o,Error:r,Uint8Array:c,Uint16Array:s,Uint32Array:a,Int32Array:i,Map:f,DataView:u,Promise:w,TextEncoder:l,crypto:p,postMessage:d,TransformStream:h,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new c,C=[[],[],[],[],[],[],[],[]];for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,M,x,P,D,F,B]=C;class E{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let o=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),c=e-8;for(;o<=c;o+=8){const t=n^r.getInt32(o,!0),e=r.getInt32(o+4,!0);n=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^x[255&e]^M[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;o<e;o++)n=n>>>8^I[255&(n^t[o])];this.o=n}get(){return~this.o}}class R extends h{constructor(){let t;const n=new E;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new c(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function U(t,n){const e=new c(t.length+n.length);return e.set(t),e.set(n,t.length),e}function W(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const V=64,K=20,j=new c([128]),H=new c(1),O=new i([1732584193,4023233417,2562383102,271733878,3285377520]),T=new c(256),L=new i(256),N=new i(256),q=new i(256),G=new i(256);let J=!1;function Q(t,n){!function(){if(!J){let t=1,n=1;do{t=255&(t^t<<1^(128&t?27:0)),n=255&(n^n<<1),n=255&(n^n<<2),n=255&(n^n<<4),128&n&&(n^=9),T[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);T[0]=99;for(let t=0;t<256;t++){const n=T[t],e=$(n),o=e<<24|n<<16|n<<8|e^n;L[t]=o,N[t]=o>>>8|o<<24,q[t]=o>>>16|o<<16,G[t]=o>>>24|o<<8}J=!0}}();const e=new i(60),o=function(t,n){const e=t.length>>2,o=e+6,r=4*(o+1);let c=1;for(let o=0;o<e;o++)n[o]=t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3];for(let t=e;t<r;t++){let o=n[t-1];t%e==0?(o=Y(o<<8|o>>>24)^c<<24,c=$(c)):e>6&&t%e==4&&(o=Y(o)),n[t]=n[t-e]^o}return o}(t,e),r=new i(4),c=X(n);let s=0,a=0,f=0,w=0;return{process(t,n){n&&c.update(t,0,t.length),function(t){const n=new u(t.buffer,t.byteOffset,t.byteLength),e=t.length;let o=0;for(;o+16<=e;o+=16)l(),n.setInt32(o,n.getInt32(o)^r[0]),n.setInt32(o+4,n.getInt32(o+4)^r[1]),n.setInt32(o+8,n.getInt32(o+8)^r[2]),n.setInt32(o+12,n.getInt32(o+12)^r[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=r[n>>2]>>>24-8*(3&n)}}(t),n||c.update(t,0,t.length)},digest:()=>c.digest()};function l(){s=s+1|0,s||(a=a+1|0,a||(f=f+1|0,f||(w=w+1|0)));let t=Z(s)^e[0],n=Z(a)^e[1],c=Z(f)^e[2],i=Z(w)^e[3],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[4],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[5],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[6],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[7];t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[8],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[9],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[10],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[11],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[12],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[13],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[14],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[15],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[16],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[17],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[18],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[19],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[20],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[21],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[22],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[23],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[24],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[25],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[26],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[27],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[28],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[29],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[30],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[31],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[32],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[33],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[34],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[35],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[36],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[37],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[38],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[39];let h=40;o>10&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[40],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[41],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[42],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[43],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[44],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[45],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[46],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[47],h=48),o>12&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[48],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[49],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[50],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[51],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[52],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[53],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[54],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[55],h=56),r[0]=(T[u>>>24]<<24|T[l>>>16&255]<<16|T[p>>>8&255]<<8|T[255&d])^e[h],r[1]=(T[l>>>24]<<24|T[p>>>16&255]<<16|T[d>>>8&255]<<8|T[255&u])^e[h+1],r[2]=(T[p>>>24]<<24|T[d>>>16&255]<<16|T[u>>>8&255]<<8|T[255&l])^e[h+2],r[3]=(T[d>>>24]<<24|T[u>>>16&255]<<16|T[l>>>8&255]<<8|T[255&p])^e[h+3]}}function X(t){const n=function(){const t=new i(O),n=new i(16),e=new c(V),r=new u(e.buffer),s=new c(8);let a=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),r=n>>>0;for(w(j,0,1);56!=a;)w(H,0,1);s[0]=e>>>24,s[1]=e>>>16,s[2]=e>>>8,s[3]=e,s[4]=r>>>24,s[5]=r>>>16,s[6]=r>>>8,s[7]=r,w(s,0,8);const i=new c(K),l=new u(i.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(O),a=0,f=0,i}};function w(t,n,o){const c=n+o;if(f+=o,a){for(;n<c&&a<V;)e[a++]=t[n++];a==V&&(l(r,0),a=0)}if(n+V<=c){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+V<=c;n+=V)l(e,n)}for(;n<c;)e[a++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let r,c=t[0],s=t[1],a=t[2],i=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[t]|0,s=s<<30|s>>>2,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+n[t+1]|0,c=c<<30|c>>>2,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+n[t+2]|0,f=f<<30|f>>>2,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+n[t+3]|0,i=i<<30|i>>>2,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+n[t+4]|0,a=a<<30|a>>>2;f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[15]|0,s=s<<30|s>>>2,r=n[13]^n[8]^n[2]^n[0],r=r<<1|r>>>31,n[0]=r,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+r|0,c=c<<30|c>>>2,r=n[14]^n[9]^n[3]^n[1],r=r<<1|r>>>31,n[1]=r,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+r|0,f=f<<30|f>>>2,r=n[15]^n[10]^n[4]^n[2],r=r<<1|r>>>31,n[2]=r,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+r|0,i=i<<30|i>>>2,r=n[0]^n[11]^n[5]^n[3],r=r<<1|r>>>31,n[3]=r,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+r|0,a=a<<30|a>>>2;for(let t=20;t<40;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+1859775393+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+1859775393+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+1859775393+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+1859775393+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+1859775393+r|0,a=a<<30|a>>>2;for(let t=40;t<60;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s&a|(s|a)&i)+f+2400959708+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c&s|(c|s)&a)+i+2400959708+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f&c|(f|c)&s)+a+2400959708+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i&f|(i|f)&c)+s+2400959708+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a&i|(a|i)&f)+c+2400959708+r|0,a=a<<30|a>>>2;for(let t=60;t<80;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+3395469782+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+3395469782+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+3395469782+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+3395469782+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+3395469782+r|0,a=a<<30|a>>>2;t[0]=t[0]+c|0,t[1]=t[1]+s|0,t[2]=t[2]+a|0,t[3]=t[3]+i|0,t[4]=t[4]+f|0}}(),e=new c(V),r=new c(V);t.length>V&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<V;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,V),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,V),n.update(t,0,K);const o=n.digest();return n.update(e,0,V),o}}}function Y(t){return T[t>>>24]<<24|T[t>>>16&255]<<16|T[t>>>8&255]<<8|T[255&t]}function Z(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function $(t){return 255&(t<<1^27*(t>>7))}const _=typeof p!=b&&typeof p.getRandomValues==k,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if(_)return p.getRandomValues(t);throw new r("Crypto API not supported")}const ot={name:"PBKDF2"},rt=n.assign({hash:{name:"HMAC"}},ot),ct=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),st=["deriveBits"],at=[8,12,16],it=[16,24,32],ft=10,ut=typeof p!=b,wt=ut&&p.subtle;let lt=ut&&typeof wt!=b&&typeof wt.importKey==k&&typeof wt.deriveBits==k,pt=Q;class dt extends h{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:o,checkAuthenticationCode:s=!0}){const a={};super({start(){yt(a,t,n,e)},async transform(t,n){const{password:e,strength:s,l:i,ready:f}=a;if(e?(await async function(t,n,e,o){const c=await vt(t,n,e,kt(o,0,at[n])),s=kt(o,at[n]);if(c[0]!=s[0]||c[1]!=s[1])throw gt(t),new r(tt)}(a,s,e,kt(t,0,at[s]+2)),t=kt(t,at[s]+2),o?(gt(a),n.error(new r(nt))):i()):await f,a.h)return;const u=new c(t.length-ft-(t.length-ft)%16);n.enqueue(St(a,t,u,0,ft,!0))},async flush(t){const{m:n,S:e,ready:o}=a;if(n){if(await o,a.h)return;const i=kt(e,e.length-ft),f=new c(kt(e,0,e.length-ft));n.process(f,!0);const u=n.digest();let w=e.length<ft?1:0;for(let t=0;t<ft;t++)w|=u[t]^i[t];if(w&&s)return void t.error(new r("Invalid authentication code"));t.enqueue(f)}}}),mt(this,a)}}class ht extends h{constructor({password:t,rawPassword:n,encryptionStrength:e}){const o={};super({start(){yt(o,t,n,e)},async transform(t,n){const{password:e,strength:r,l:s,ready:a}=o;let i=z;if(e?(i=await async function(t,n,e){const o=et(new c(at[n]));return U(o,await vt(t,n,e,o))}(o,r,e),s()):await a,o.h)return;const f=new c(i.length+t.length-t.length%16);f.set(i,0),n.enqueue(St(o,t,f,i.length,0,!1))},async flush(t){const{m:n,S:e,ready:r}=o;if(n){if(await r,o.h)return;const s=new c(e);n.process(s,!1);const a=kt(n.digest(),0,ft);t.enqueue(U(s,a))}}}),mt(this,o)}}function yt(t,e,o,r){n.assign(t,{ready:new w(n=>t.l=n),password:bt(e,o),strength:r-1,S:z,h:!1})}function mt(t,e){const o=t.readable.getReader(),r=new y({async pull(t){try{const{value:n,done:e}=await o.read();e?t.close():t.enqueue(n)}catch(t){throw gt(e),o.cancel(t).catch(()=>{}),t}},cancel:t=>(gt(e),o.cancel(t))});n.defineProperty(t,"readable",{get:()=>r})}function St(t,n,e,o,r,s){const{m:a,S:i}=t;i.length&&(n=U(i,n));const f=n.length-r,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new c(n)).set(e,0)}return t}(e,o+u),u){const t=kt(e,o,o+u);t.set(kt(n,0,u)),a.process(t,s)}return t.S=kt(n,u),e}function gt(t){const{m:n}=t;t.h=!0,n&&n.dispose&&n.dispose()}async function vt(t,e,r,s){t.password=null;const a=it[e],i=await async function(t,e,r){if(lt)try{const o=await wt.importKey("raw",t,rt,!1,st);return new c(await wt.deriveBits(n.assign({salt:e},ct),o,8*r))}catch{lt=!1}return function(t,n,e,r){const s=X(t),a=new c(r),i=new c(n.length+4),f=new u(i.buffer);i.set(n);for(let t=1,e=0;e<r;t++,e+=K){f.setUint32(n.length,t),s.update(i,0,i.length);let c=s.digest();const u=c.slice();for(let t=1;t<1e3;t++){s.update(c,0,K),c=s.digest();for(let t=0;t<K;t++)u[t]^=c[t]}a.set(u.subarray(0,o.min(K,r-e)),e)}return a}(t,e,0,r)}(r,s,2*a+2);return t.m=pt(kt(i,0,a),kt(i,a,2*a)),t.h&>(t),kt(i,2*a)}function bt(t,n){return n===v?function(t){if(typeof l==b){t=unescape(encodeURIComponent(t));const n=new c(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new l).encode(t)}(t):n}function kt(t,n,e){return t.subarray(n,e)}class zt extends h{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:o}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=At(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(tt);t=t.subarray(12)}o?n.error(new r(nt)):n.enqueue(At(e,t))}})}}class Ct extends h{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;let o,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new c(12));n[11]=e.passwordVerification,o=new c(t.length+n.length),o.set(Mt(e,n),0),r=12}else o=new c(t.length),r=0;o.set(Mt(e,t),r),n.enqueue(o)}})}}function It(t,e,o,r){n.assign(t,{password:e,rawPassword:o,passwordVerification:r}),function(t,e,o){const r=[305419896,591751049,878082192];if(n.assign(t,{v:r,C:new E(r[0]),I:new E(r[2])}),o)for(let n=0;n<o.length;n++)xt(t,o[n]);else for(let n=0;n<e.length;n++)xt(t,e.charCodeAt(n))}(t,e,o)}function At(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,e[o]);return e}function Mt(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,n[o]);return e}function xt(t,n){let[,e]=t.v;t.C.append([n]);const r=~t.C.get();e=Ft(o.imul(Ft(e+Dt(r)),134775813)+1),t.I.append([e>>>24]);const c=~t.I.get();t.v=[r,e,c]}function Pt(t){const n=2|t.v[2];return Dt(o.imul(n,1^n)>>>8)}function Dt(t){return 255&t}function Ft(t){return 4294967295&t}function Bt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){throw n.cancel(t).catch(()=>{}),t}},cancel:t=>n.cancel(t)})}const Et=new f;function Rt(t){return Et.get(t)}const Ut="Invalid uncompressed size",Wt="Invalid CRC32",Vt="deflate-raw",Kt="gzip",jt=[31,139,8];class Ht extends h{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:r,encrypted:c,useCompressionStream:s,zipCrypto:a,computeCrc32:i,level:f,deflate64:w,format:l,compressionMethod:p,inputSize:d}=t,h=this;let y,m,S,g=super.readable;const v=l&&Rt(l),b=Gt(s,o,e),k=i&&r&&!w&&!v&&(!c||a)&&Boolean(b);if(c&&!a||!i||k||(y=new R,g=Qt(g,y)),r)if(v)g=Xt(g,qt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:p,uncompressedSize:d}));else if(k)S=new Ot,g=Xt(g,new b(Kt,{level:f,chunkSize:n})),g=Qt(g,S);else try{g=Jt(g,s,{level:f,chunkSize:n},o,e)}catch(t){if(!s&&e)throw t;let n;try{n=new o(Kt)}catch{throw t}g=Xt(g,n),g=Qt(g,new Ot)}c&&(a?g=Qt(g,new Ct(t)):(m=new ht(t),g=Qt(g,m))),Nt(h,g,()=>{c&&!a||!i||(h.crc32=k?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Ot extends h{constructor(){let t,n=10,e=new c(0);super({transform(t,r){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const c=e.length+t.length;if(c<=8)return void(e=U(e,t));const s=c-8,a=o.min(s,e.length);r.enqueue(U(e.subarray(0,a),t.subarray(0,s-a))),e=U(e.subarray(a),t.subarray(s-a))},flush(){const n=W(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Tt extends h{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:s,encrypted:a,checkCrc32:i,crc32:f,compressed:l,useCompressionStream:p,deflate64:d,format:h,compressionMethod:m,rawBitFlag:S,outputSize:g}=t;let b,k,z,C=super.readable;if(a&&(s?C=Qt(C,new zt(t)):(k=new dt(t),C=Qt(C,k))),l){const t=h&&Rt(h);if(t)C=Xt(C,qt(t.DecompressionStream,h,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}));else{let t;const s=Gt(p,o,e);if(i&&!d&&f!==v&&g!==v&&s)try{t=new s(Kt,{chunkSize:n})}catch{t=v}if(!t)try{C=Jt(C,p,{chunkSize:n,deflate64:d},o,e)}catch(n){if(d||g===v||!p&&e)throw n;try{t=new o(Kt)}catch{throw n}}t&&(z=!0,C=function(t,n,e,o){const s=n.writable.getWriter(),a=n.readable.getReader(),i=o===v?new E:v;let f,u,l=0,p=!1,d=!1,h=!1,m=0,S=!1;const g=new w((t,n)=>{f=t,u=n});return g.catch(()=>{}),async function(){const n=t.getReader();try{const t=new c(10);for(t.set(jt),await s.write(t);;){await s.ready;const{value:t,done:e}=await n.read();if(e)break;await s.write(t)}p=!0,i&&(S&&k(),await g);const r=new c(8),a=W(r);a.setUint32(0,i?i.get():o,!0),a.setUint32(4,e,!0),d=!0,await s.write(r),await s.close()}catch(t){await Yt(s,t),await Zt(n,t)}}(),new y({async pull(t){try{const{value:n,done:o}=await function(){m++,S=!0;const t=a.read();return t.then(b,b),p&&i&&k(),t}();if(o)t.close();else{if(l+=n.length,l>e)throw new r(Ut);i&&i.append(n),t.enqueue(n)}}catch(t){throw u(t),await Zt(a,t),d?function(t){const n=new r(l==e?Wt:Ut);return n.cause=t,n}(t):t}},cancel:t=>(u(t),a.cancel(t))});function b(){S=!1}async function k(){if(!h){h=!0;const t=m;await new w(t=>{const{port1:n,port2:e}=new MessageChannel;e.onmessage=()=>{n.close(),e.close(),t()},n.postMessage(v)}),h=!1,S&&(m==t?f():k())}}}(C,t,g,f))}C=function(t){const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){if(await Zt(n,t),t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}},cancel:t=>n.cancel(t)})}(C)}i&&!z&&(b=new R,C=Qt(C,b)),Nt(this,C,()=>{if(b){const t=new u(b.value.buffer).getUint32(0,!1);if(f!=t)throw new r(Wt)}})}}const Lt=new f;function Nt(t,e,o){e=Qt(e,new h({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function qt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Gt(t,n,e){return t&&n?n:e&&e.requiresModule?e:void 0}function Jt(t,n,e,o,r){const c=n&&o?o:r||o,s=e.deflate64?"deflate64-raw":Vt;let a;try{a=new c(s,e)}catch(t){if(!n||!r||c==r)throw t;a=new r(s,e)}return Xt(t,a)}function Qt(t,n){return Bt(t).pipeThrough(n)}function Xt(t,n){const e=n.writable.getWriter(),o=t.getReader();return async function(){try{for(;;){await e.ready;const t=await o.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await Yt(e,t),await Zt(o,t)}}(),n.readable}async function Yt(t,n){try{await t.abort(n)}catch{}}async function Zt(t,n){try{await t.cancel(n)}catch{}}const $t="data",_t="deflate";class tn extends h{constructor(t,e){super({});const o=this,{codecType:c}=t;let s;c.startsWith(_t)?s=Ht:c.startsWith("inflate")&&(s=Tt),o.outputSize=0;let a=0;const i=new s(t,e),f=super.readable,u=new h({transform(t,n){t&&t.length&&(a+=t.length,n.enqueue(t))},flush(){n.assign(o,{inputSize:a})}}),w=new h({transform(n,e){if(n&&n.length&&(e.enqueue(n),o.outputSize+=n.length,t.outputSize!==v&&o.outputSize>t.outputSize))throw new r(Ut)},flush(){const{crc32:t}=i;n.assign(o,{crc32:t,inputSize:a})}});n.defineProperty(o,"readable",{get:()=>f.pipeThrough(u).pipeThrough(i).pipeThrough(w)})}}class nn extends h{constructor(t){const o=[];let r=0,s=0;function a(){const n=new c(t);let e=0;for(;e<t;){const r=o[0],c=t-e;r.length<=c?(n.set(r,e),e+=r.length,o.shift()):(n.set(r.subarray(0,c),e),o[0]=r.subarray(c),e+=c)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.push(n),r+=n.length;r>t;)s+=t,e.enqueue(a())},flush(t){r&&(s+=r,t.enqueue(function(t,n){const e=new c(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,r)))}}),n.defineProperty(this,"outputSize",{get:()=>s})}}let en=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(en=navigator.hardwareConcurrency)}catch{}function on(t){return Boolean(t)&&"object"==typeof t}const rn=new f,cn=new f,sn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let an=0;async function fn(t){let n,c,s;try{const{options:a,config:i}=t;if(a.format)try{await async function(t,n){!Et.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:o}=n;if(typeof e!=k&&typeof o!=k)throw new r("Invalid codec module");Et.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(a.format,a.codecURI)}catch(t){if(on(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Lt.get(t);e||(e=new f,Lt.set(t,e));let o=e.get(n);if(o===v){try{new t(n),o=!0}catch{o=!1}e.set(n,o)}return o}(a.codecType.startsWith(_t)?i.CompressionStream:i.DecompressionStream,Vt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}if(a.encrypted&&!a.zipCrypto)try{await self.initModule(t.config)}catch{}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Bt(t.readable):new y({async pull(t){const n=new w(t=>rn.set(an,t));un({type:"pull",messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER;const{value:o,done:r}=await n;t.enqueue(o),r&&t.close()}},u);s=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const o=new w(t=>n=t);cn.set(an,n),un({type:$t,value:t,messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new tn(a,i),c=new nn(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?o.max(r,64):65536;var n,r}(i)),await l.pipeThrough(n).pipeThrough(c).pipeTo(s,{preventClose:!0,preventAbort:!0}),await s.getWriter().close();const{crc32:p,inputSize:d,outputSize:h}=n;un({type:"close",result:{crc32:p,inputSize:d,outputSize:h}})}catch(t){const n=c?c.outputSize:0;if(on(t))try{t.outputSize=n}catch{}if(s&&!s.locked)try{await s.getWriter().close()}catch{}wn(t,n)}}function un(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new c(e):e).buffer,d(t,[t.value])}catch{d(t)}else d(t);else d(t);var e}function wn(t,n){const{message:e,stack:o,code:c,name:s,outputSize:a,cause:i,codecImportFailed:f}=function(t=new r("Unknown error")){return on(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:c,name:s,outputSize:a===v?n:a};if(i&&(u.cause={name:i.name,message:i.message}),f&&(u.codecImportFailed=!0),sn)try{return void d({error:u,errorValue:{value:t}})}catch{}d({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:o,done:r}=t;try{if("start"==n&&fn(t),n==$t){const t=rn.get(e);rn.delete(e),t({value:o||new c,done:r})}if("ack"==n){const t=cn.get(e);cn.delete(e),t()}}catch(t){wn(t)}}),d({type:"ready"});const ln="deflate",pn="deflate-raw",dn="deflate64-raw",hn="gzip";let yn,mn,Sn,gn,vn;function bn(t,n,e={}){if(!yn){const t=new r("WASM module not loaded");throw t.cause=vn,t}const s="number"==typeof e.level?e.level:-1,a="number"==typeof e.outBuffer?e.outBuffer:65536,i="number"==typeof e.inBufferSize?e.inBufferSize:65536,f={A:0,in:0,inBufferSize:0,M:0};let u,l,p,d,h=!0,S=!1;return function(){try{let e;if(f.A=mn(a),f.in=mn(i),f.inBufferSize=i,!f.A||!f.in)throw new r("allocation failed");if(t?(f.P=yn.deflate_process,f.D=yn.deflate_last_consumed,f.F=yn.deflate_end,f.M=yn.deflate_new(),e=n===hn?yn.deflate_init_gzip(f.M,s):n===pn?yn.deflate_init_raw(f.M,s):yn.deflate_init(f.M,s)):n===dn?(f.P=yn.inflate9_process,f.D=yn.inflate9_last_consumed,f.F=yn.inflate9_end,f.M=yn.inflate9_new(),e=yn.inflate9_init_raw(f.M)):(f.P=yn.inflate_process,f.D=yn.inflate_last_consumed,f.F=yn.inflate_end,f.M=yn.inflate_new(),e=n===pn?yn.inflate_init_raw(f.M):n===hn?yn.inflate_init_gzip(f.M):yn.inflate_init(f.M)),0!==e)throw new r("init failed:"+e)}catch(t){throw b(f),t}}(),{readable:new y({start(t){u=t},pull(){h=!1,v()},cancel(t){S=!0,d=t,b(f),l.error(t),v()}},{highWaterMark:0}),writable:new m({start(t){l=t},async write(t){if(h&&await new w(t=>p=t),S)throw d;try{!function(t){const n=new c(gn.buffer),e=f.P,s=f.D,i=f.A;let u=0;for(;u<t.length;){const c=o.min(t.length-u,32768);if((!f.in||f.inBufferSize<c)&&(f.in&&Sn&&(Sn(f.in),f.in=0),f.in=mn(c),f.inBufferSize=c,!f.in))throw new r("allocation failed");n.set(t.subarray(u,u+c),f.in);const w=e(f.M,f.in,c,i,a,0),l=w>>24&255,p=128&l?l-256:l;if(p<0)throw new r("process error:"+p);const d=16777215&w;d&&g(n.slice(i,i+d));const h=s(f.M);if(0===h&&0===d)break;u+=h}}(t)}catch(t){throw b(f),u.error(t),t}},close(){if(S)return;try{!function(){const t=new c(gn.buffer),n=f.P,e=f.A;for(;;){const o=n(f.M,0,0,e,a,4),c=o>>24&255,s=128&c?c-256:c;if(s<0)throw new r("process error:"+s);const i=16777215&o;if(i&&g(t.slice(e,e+i)),1===c||0===i)break}}()}catch(t){throw b(f),u.error(t),t}const t=b(f);if(0!==t){const n=new r("end error:"+t);throw u.error(n),n}u.close()},abort(t){b(f),u.error(t)}},{highWaterMark:1})};function g(t){h=!0,u.enqueue(t)}function v(){if(p){const t=p;p=null,t()}}function b(t){let n=0;return t.M&&t.F&&(n=t.F(t.M)),t.M=0,t.in&&Sn&&Sn(t.in),t.in=0,t.A&&Sn&&Sn(t.A),t.A=0,n}}class kn{constructor(t=ln,n){return bn(!0,t,n)}}class zn{constructor(t=ln,n){return bn(!1,t,n)}}kn.requiresModule=!0,zn.requiresModule=!0,kn.supportedFormats=[ln,pn,hn],zn.supportedFormats=[ln,pn,hn,dn];const Cn=65536;let In,An;function Mn(t){return new c(t.memory.buffer)}let xn=!1;!function(t={}){const{init:n,B:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(pt=e||Q),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:kn,DecompressionStreamFallback:zn,B:function(t,n){const e=In;let o=e?function(t,n,e){An||(An=t.malloc(Cn));const o=An?t.aes_hmac_new():0;if(o){const r=Mn(t);if(r.set(n,An),r.set(e,An+n.length),t.aes_hmac_init(o,An,n.length,An+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return Q(t,n);const r=An;return{process(t,n){for(let c=0;c<t.length;c+=Cn){const s=t.subarray(c,c+Cn),a=Mn(e);a.set(s,r),e.aes_hmac_process(o,r,s.length,n?1:0),s.set(a.subarray(r,r+s.length))}},digest:()=>(e.aes_hmac_end(o,r),o=0,Mn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!xn)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const r=await fetch(o);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),o=e.length,r=new c(o);for(let t=0;t<o;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}const s=await WebAssembly.instantiate(e);var a;(function(t){if(yn=t,({malloc:mn,free:Sn,memory:gn}=yn),"function"!=typeof mn||"function"!=typeof Sn||!gn)throw yn=mn=Sn=gn=null,new r("Invalid WASM module")})(s.instance.exports),typeof(a=s.instance.exports).aes_hmac_new==k&&(In=a,An=0)}(t,n),xn=!0}catch(t){throw function(t){vn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const r=t.length;let o=0;for(;o+2<r;o+=3){const r=t[o]<<16|t[o+1]<<8|t[o+2];e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+n$1[63&r];}const s=r-o;if(1===s){const r=t[o]<<16;e+=n$1[r>>18&63]+n$1[r>>12&63]+"==";}else if(2===s){const r=t[o]<<16|t[o+1]<<8;e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+"=";}return e}(r)}});
|
|
448
|
+
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const n$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e$1=t=>t({workerURI:t=>{const e="text/javascript";let r='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:o,Error:r,Uint8Array:c,Uint16Array:s,Uint32Array:a,Int32Array:i,Map:f,DataView:u,Promise:w,TextEncoder:l,crypto:d,postMessage:p,TransformStream:h,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new c,C=[[],[],[],[],[],[],[],[]];for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,M,A,E,R,x,P,D]=C;class F{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let o=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),c=e-8;for(;o<=c;o+=8){const t=n^r.getInt32(o,!0),e=r.getInt32(o+4,!0);n=D[255&t]^P[t>>>8&255]^x[t>>>16&255]^R[t>>>24&255]^E[255&e]^A[e>>>8&255]^M[e>>>16&255]^I[e>>>24&255]}}for(;o<e;o++)n=n>>>8^I[255&(n^t[o])];this.o=n}get(){return~this.o}}class U extends h{constructor(){let t;const n=new F;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new c(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function B(t,n){const e=new c(t.length+n.length);return e.set(t),e.set(n,t.length),e}function W(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const O=64,V=20,K=new c([128]),T=new c(1),_=new i([1732584193,4023233417,2562383102,271733878,3285377520]),j=new c(256),H=new i(256),L=new i(256),Z=new i(256),N=new i(256);let q=!1;function G(t,n){!function(){if(!q){let t=1,n=1;do{t=255&(t^t<<1^(128&t?27:0)),n=255&(n^n<<1),n=255&(n^n<<2),n=255&(n^n<<4),128&n&&(n^=9),j[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);j[0]=99;for(let t=0;t<256;t++){const n=j[t],e=Y(n),o=e<<24|n<<16|n<<8|e^n;H[t]=o,L[t]=o>>>8|o<<24,Z[t]=o>>>16|o<<16,N[t]=o>>>24|o<<8}q=!0}}();const e=new i(60),o=function(t,n){const e=t.length>>2,o=e+6,r=4*(o+1);let c=1;for(let o=0;o<e;o++)n[o]=t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3];for(let t=e;t<r;t++){let o=n[t-1];t%e==0?(o=Q(o<<8|o>>>24)^c<<24,c=Y(c)):e>6&&t%e==4&&(o=Q(o)),n[t]=n[t-e]^o}return o}(t,e),r=new i(4),c=J(n);let s=0,a=0,f=0,w=0;return{process(t,n){n&&c.update(t,0,t.length),function(t){const n=new u(t.buffer,t.byteOffset,t.byteLength),e=t.length;let o=0;for(;o+16<=e;o+=16)l(),n.setInt32(o,n.getInt32(o)^r[0]),n.setInt32(o+4,n.getInt32(o+4)^r[1]),n.setInt32(o+8,n.getInt32(o+8)^r[2]),n.setInt32(o+12,n.getInt32(o+12)^r[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=r[n>>2]>>>24-8*(3&n)}}(t),n||c.update(t,0,t.length)},digest:()=>c.digest()};function l(){s=s+1|0,s||(a=a+1|0,a||(f=f+1|0,f||(w=w+1|0)));let t=X(s)^e[0],n=X(a)^e[1],c=X(f)^e[2],i=X(w)^e[3],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[4],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[5],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[6],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[7];t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[8],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[9],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[10],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[11],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[12],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[13],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[14],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[15],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[16],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[17],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[18],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[19],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[20],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[21],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[22],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[23],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[24],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[25],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[26],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[27],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[28],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[29],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[30],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[31],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[32],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[33],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[34],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[35],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[36],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[37],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[38],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[39];let h=40;o>10&&(t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[40],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[41],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[42],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[43],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[44],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[45],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[46],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[47],h=48),o>12&&(t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[48],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[49],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[50],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[51],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[52],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[53],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[54],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[55],h=56),r[0]=(j[u>>>24]<<24|j[l>>>16&255]<<16|j[d>>>8&255]<<8|j[255&p])^e[h],r[1]=(j[l>>>24]<<24|j[d>>>16&255]<<16|j[p>>>8&255]<<8|j[255&u])^e[h+1],r[2]=(j[d>>>24]<<24|j[p>>>16&255]<<16|j[u>>>8&255]<<8|j[255&l])^e[h+2],r[3]=(j[p>>>24]<<24|j[u>>>16&255]<<16|j[l>>>8&255]<<8|j[255&d])^e[h+3]}}function J(t){const n=function(){const t=new i(_),n=new i(16),e=new c(O),r=new u(e.buffer),s=new c(8);let a=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),r=n>>>0;for(w(K,0,1);56!=a;)w(T,0,1);s[0]=e>>>24,s[1]=e>>>16,s[2]=e>>>8,s[3]=e,s[4]=r>>>24,s[5]=r>>>16,s[6]=r>>>8,s[7]=r,w(s,0,8);const i=new c(V),l=new u(i.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(_),a=0,f=0,i}};function w(t,n,o){const c=n+o;if(f+=o,a){for(;n<c&&a<O;)e[a++]=t[n++];a==O&&(l(r,0),a=0)}if(n+O<=c){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+O<=c;n+=O)l(e,n)}for(;n<c;)e[a++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let r,c=t[0],s=t[1],a=t[2],i=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[t]|0,s=s<<30|s>>>2,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+n[t+1]|0,c=c<<30|c>>>2,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+n[t+2]|0,f=f<<30|f>>>2,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+n[t+3]|0,i=i<<30|i>>>2,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+n[t+4]|0,a=a<<30|a>>>2;f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[15]|0,s=s<<30|s>>>2,r=n[13]^n[8]^n[2]^n[0],r=r<<1|r>>>31,n[0]=r,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+r|0,c=c<<30|c>>>2,r=n[14]^n[9]^n[3]^n[1],r=r<<1|r>>>31,n[1]=r,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+r|0,f=f<<30|f>>>2,r=n[15]^n[10]^n[4]^n[2],r=r<<1|r>>>31,n[2]=r,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+r|0,i=i<<30|i>>>2,r=n[0]^n[11]^n[5]^n[3],r=r<<1|r>>>31,n[3]=r,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+r|0,a=a<<30|a>>>2;for(let t=20;t<40;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+1859775393+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+1859775393+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+1859775393+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+1859775393+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+1859775393+r|0,a=a<<30|a>>>2;for(let t=40;t<60;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s&a|(s|a)&i)+f+2400959708+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c&s|(c|s)&a)+i+2400959708+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f&c|(f|c)&s)+a+2400959708+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i&f|(i|f)&c)+s+2400959708+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a&i|(a|i)&f)+c+2400959708+r|0,a=a<<30|a>>>2;for(let t=60;t<80;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+3395469782+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+3395469782+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+3395469782+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+3395469782+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+3395469782+r|0,a=a<<30|a>>>2;t[0]=t[0]+c|0,t[1]=t[1]+s|0,t[2]=t[2]+a|0,t[3]=t[3]+i|0,t[4]=t[4]+f|0}}(),e=new c(O),r=new c(O);t.length>O&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<O;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,O),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,O),n.update(t,0,V);const o=n.digest();return n.update(e,0,O),o}}}function Q(t){return j[t>>>24]<<24|j[t>>>16&255]<<16|j[t>>>8&255]<<8|j[255&t]}function X(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function Y(t){return 255&(t<<1^27*(t>>7))}const $=typeof d!=b&&typeof d.getRandomValues==k,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if($)return d.getRandomValues(t);throw new r("Crypto API not supported")}const ot={name:"PBKDF2"},rt=n.assign({hash:{name:"HMAC"}},ot),ct=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),st=["deriveBits"],at=[8,12,16],it=[16,24,32],ft=10,ut=typeof d!=b,wt=ut&&d.subtle;let lt=ut&&typeof wt!=b&&typeof wt.importKey==k&&typeof wt.deriveBits==k,dt=G;class pt extends h{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:o,checkAuthenticationCode:s=!0}){const a={};super({start(){yt(a,t,n,e)},async transform(t,n){const{password:e,strength:s,l:i,ready:f}=a;if(e?(await async function(t,n,e,o){const c=await vt(t,n,e,kt(o,0,at[n])),s=kt(o,at[n]);if(c[0]!=s[0]||c[1]!=s[1])throw gt(t),new r(tt)}(a,s,e,kt(t,0,at[s]+2)),t=kt(t,at[s]+2),o?(gt(a),n.error(new r(nt))):i()):await f,a.h)return;const u=new c(t.length-ft-(t.length-ft)%16);n.enqueue(St(a,t,u,0,ft,!0))},async flush(t){const{m:n,S:e,ready:o}=a;if(n){if(await o,a.h)return;const i=kt(e,e.length-ft),f=new c(kt(e,0,e.length-ft));n.process(f,!0);const u=n.digest();let w=e.length<ft?1:0;for(let t=0;t<ft;t++)w|=u[t]^i[t];if(w&&s)return void t.error(new r("Invalid authentication code"));t.enqueue(f)}}}),mt(this,a)}}class ht extends h{constructor({password:t,rawPassword:n,encryptionStrength:e}){const o={};super({start(){yt(o,t,n,e)},async transform(t,n){const{password:e,strength:r,l:s,ready:a}=o;let i=z;if(e?(i=await async function(t,n,e){const o=et(new c(at[n]));return B(o,await vt(t,n,e,o))}(o,r,e),s()):await a,o.h)return;const f=new c(i.length+t.length-t.length%16);f.set(i,0),n.enqueue(St(o,t,f,i.length,0,!1))},async flush(t){const{m:n,S:e,ready:r}=o;if(n){if(await r,o.h)return;const s=new c(e);n.process(s,!1);const a=kt(n.digest(),0,ft);t.enqueue(B(s,a))}}}),mt(this,o)}}function yt(t,e,o,r){n.assign(t,{ready:new w(n=>t.l=n),password:bt(e,o),strength:r-1,S:z,h:!1})}function mt(t,e){const o=t.readable.getReader(),r=new y({async pull(t){try{const{value:n,done:e}=await o.read();e?t.close():t.enqueue(n)}catch(t){throw gt(e),o.cancel(t).catch(()=>{}),t}},cancel:t=>(gt(e),o.cancel(t))});n.defineProperty(t,"readable",{get:()=>r})}function St(t,n,e,o,r,s){const{m:a,S:i}=t;i.length&&(n=B(i,n));const f=n.length-r,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new c(n)).set(e,0)}return t}(e,o+u),u){const t=kt(e,o,o+u);t.set(kt(n,0,u)),a.process(t,s)}return t.S=kt(n,u),e}function gt(t){const{m:n}=t;t.h=!0,n&&n.dispose&&n.dispose()}async function vt(t,e,r,s){t.password=null;const a=it[e],i=await async function(t,e,r){if(lt)try{const o=await wt.importKey("raw",t,rt,!1,st);return new c(await wt.deriveBits(n.assign({salt:e},ct),o,8*r))}catch{lt=!1}return function(t,n,e,r){const s=J(t),a=new c(r),i=new c(n.length+4),f=new u(i.buffer);i.set(n);for(let t=1,e=0;e<r;t++,e+=V){f.setUint32(n.length,t),s.update(i,0,i.length);let c=s.digest();const u=c.slice();for(let t=1;t<1e3;t++){s.update(c,0,V),c=s.digest();for(let t=0;t<V;t++)u[t]^=c[t]}a.set(u.subarray(0,o.min(V,r-e)),e)}return a}(t,e,0,r)}(r,s,2*a+2);return t.m=dt(kt(i,0,a),kt(i,a,2*a)),t.h&>(t),kt(i,2*a)}function bt(t,n){return n===v?function(t){if(typeof l==b){t=unescape(encodeURIComponent(t));const n=new c(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new l).encode(t)}(t):n}function kt(t,n,e){return t.subarray(n,e)}class zt extends h{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:o}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=Mt(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(tt);t=t.subarray(12)}o?n.error(new r(nt)):n.enqueue(Mt(e,t))}})}}class Ct extends h{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;let o,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new c(12));n[11]=e.passwordVerification,o=new c(t.length+n.length),o.set(At(e,n),0),r=12}else o=new c(t.length),r=0;o.set(At(e,t),r),n.enqueue(o)}})}}function It(t,e,o,r){n.assign(t,{password:e,rawPassword:o,passwordVerification:r}),function(t,e,o){const r=[305419896,591751049,878082192];if(n.assign(t,{v:r,C:new F(r[0]),I:new F(r[2])}),o)for(let n=0;n<o.length;n++)Et(t,o[n]);else for(let n=0;n<e.length;n++)Et(t,e.charCodeAt(n))}(t,e,o)}function Mt(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Rt(t)^n[o],Et(t,e[o]);return e}function At(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Rt(t)^n[o],Et(t,n[o]);return e}function Et(t,n){let[,e]=t.v;t.C.append([n]);const r=~t.C.get();e=Pt(o.imul(Pt(e+xt(r)),134775813)+1),t.I.append([e>>>24]);const c=~t.I.get();t.v=[r,e,c]}function Rt(t){const n=2|t.v[2];return xt(o.imul(n,1^n)>>>8)}function xt(t){return 255&t}function Pt(t){return 4294967295&t}function Dt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){throw n.cancel(t).catch(()=>{}),t}},cancel:t=>n.cancel(t)})}function Ft(t){return Boolean(t)&&"object"==typeof t}const Ut=new f;function Bt(t){return Ut.get(t)}const Wt="Invalid uncompressed size",Ot="Codec out of memory",Vt="Invalid CRC32",Kt="deflate-raw",Tt="gzip",_t=[31,139,8];class jt extends h{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:r,encrypted:c,useCompressionStream:s,zipCrypto:a,computeCrc32:i,level:f,deflate64:w,format:l,compressionMethod:d,inputSize:p}=t,h=this;let y,m,S,g=super.readable;const v=l&&Bt(l),b=Gt(s,o,e),k=i&&r&&!w&&!v&&(!c||a)&&Boolean(b);if(c&&!a||!i||k||(y=new U,g=Qt(g,y)),r)if(v)g=Xt(g,qt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:d,uncompressedSize:p}));else if(k)S=new Ht,g=Xt(g,new b(Tt,{level:f,chunkSize:n})),g=Qt(g,S);else try{g=Jt(g,s,{level:f,chunkSize:n},o,e)}catch(t){if(!s&&e)throw en(t);let n;try{n=new o(Tt)}catch{throw en(t)}g=Xt(g,n),g=Qt(g,new Ht)}c&&(a?g=Qt(g,new Ct(t)):(m=new ht(t),g=Qt(g,m))),Nt(h,g,()=>{c&&!a||!i||(h.crc32=k?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Ht extends h{constructor(){let t,n=10,e=new c(0);super({transform(t,r){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const c=e.length+t.length;if(c<=8)return void(e=B(e,t));const s=c-8,a=o.min(s,e.length);r.enqueue(B(e.subarray(0,a),t.subarray(0,s-a))),e=B(e.subarray(a),t.subarray(s-a))},flush(){const n=W(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Lt extends h{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:s,encrypted:a,checkCrc32:i,crc32:f,compressed:l,useCompressionStream:d,deflate64:p,format:h,compressionMethod:m,rawBitFlag:S,outputSize:g}=t;let b,k,z,C=super.readable;if(a&&(s?C=Qt(C,new zt(t)):(k=new pt(t),C=Qt(C,k))),l){const t=new Set,s=h&&Bt(h);let a;if(s)C=Xt(C,qt(s.DecompressionStream,h,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}),t);else{const r=Gt(d,o,e);if(i&&!p&&f!==v&&g!==v&&r)try{a=new r(Tt,{chunkSize:n})}catch{a=v}if(!a)try{C=Jt(C,d,{chunkSize:n,deflate64:p},o,e,t)}catch(t){if(p||g===v||!d&&e)throw en(t);try{a=new o(Tt)}catch{throw en(t)}}}a?(z=!0,C=function(t,n,e,o,s){const a=n.writable.getWriter(),i=n.readable.getReader(),f=o===v?new F:v;let u,l,d=0,p=!1,h=!1;const m=new y({start(t){l=t},pull(){b()},cancel:t=>(h=!0,b(),i.cancel(t))});return async function(){const n=t.getReader();try{const t=new c(10);for(t.set(_t),await a.write(t);;){await g(),await a.ready;const{value:t,done:e}=await tn(n,s);if(e)break;await a.write(t)}f&&await a.write(new c(0));const r=new c(8),i=W(r);i.setUint32(0,f?f.get():o,!0),i.setUint32(4,e,!0),p=!0,await a.write(r),await a.close()}catch(t){await Yt(a,t),await $t(n,t)}}(),async function(){try{for(;;){const{value:t,done:n}=await S();if(n)break;if(d+=t.length,d>e)throw new r(Wt);f&&f.append(t),l.enqueue(t)}h||(h=!0,l.close())}catch(t){!function(t){h||(h=!0,l.error(t),b())}(t),await $t(i,t)}}(),m;function S(){return i.read().catch(t=>{if(p){if(!f)throw rn(t,Vt);if(d!=e)throw rn(t,Wt);return{done:!0}}throw nn(t,s)})}function g(){if(!h&&l.desiredSize<=0)return new w(t=>u=t)}function b(){if(u){const t=u;u=v,t()}}}(C,a,g,f,t)):C=function(t,n){const e=t.getReader();return new y({async pull(t){try{const{value:n,done:o}=await e.read();o?t.close():t.enqueue(n)}catch(t){throw await $t(e,t),nn(t,n)}},cancel:t=>e.cancel(t)})}(C,t)}i&&!z&&(b=new U,C=Qt(C,b)),Nt(this,C,()=>{if(b){const t=new u(b.value.buffer).getUint32(0,!1);if(f!=t)throw new r(Vt)}})}}const Zt=new f;function Nt(t,e,o){e=Qt(e,new h({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function qt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Gt(t,n,e){return t&&n?n:e&&e.requiresModule?e:void 0}function Jt(t,n,e,o,r,c){const s=n&&o?o:r||o,a=e.deflate64?"deflate64-raw":Kt;let i;try{i=new s(a,e)}catch(t){if(!n||!r||s==r)throw t;i=new r(a,e)}return Xt(t,i,c)}function Qt(t,n){return Dt(t).pipeThrough(n)}function Xt(t,n,e){const o=n.writable.getWriter(),r=t.getReader();return async function(){try{for(;;){await o.ready;const t=await tn(r,e);if(t.done){await o.close();break}await o.write(t.value)}}catch(t){await Yt(o,t),await $t(r,t)}}(),n.readable}async function Yt(t,n){try{await t.abort(n)}catch{}}async function $t(t,n){try{await t.cancel(n)}catch{}}function tn(t,n){const e=t.read();return n?e.catch(t=>{throw n.add(t),t}):e}function nn(t,n){return n.has(t)?t:rn(t,on(t)?Ot:"Invalid compressed data")}function en(t){return on(t)?rn(t,Ot):t}function on(t){return Ft(t)&&"Z_MEM_ERROR"==t.code}function rn(t,n){const e=new r(n);return e.cause=t,e}const cn="data",sn="deflate";class an extends h{constructor(t,e){super({});const o=this,{codecType:c}=t;let s;c.startsWith(sn)?s=jt:c.startsWith("inflate")&&(s=Lt),o.outputSize=0;let a=0;const i=new s(t,e),f=super.readable,u=new h({transform(t,n){t&&t.length&&(a+=t.length,n.enqueue(t))},flush(){n.assign(o,{inputSize:a})}}),w=new h({transform(n,e){if(n&&n.length&&(e.enqueue(n),o.outputSize+=n.length,t.outputSize!==v&&o.outputSize>t.outputSize))throw new r(Wt)},flush(){const{crc32:t}=i;n.assign(o,{crc32:t,inputSize:a})}});n.defineProperty(o,"readable",{get:()=>f.pipeThrough(u).pipeThrough(i).pipeThrough(w)})}}class fn extends h{constructor(t){const o=[];let r=0,s=0;function a(){const n=new c(t);let e=0;for(;e<t;){const r=o[0],c=t-e;r.length<=c?(n.set(r,e),e+=r.length,o.shift()):(n.set(r.subarray(0,c),e),o[0]=r.subarray(c),e+=c)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.push(n),r+=n.length;r>t;)s+=t,e.enqueue(a())},flush(t){r&&(s+=r,t.enqueue(function(t,n){const e=new c(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,r)))}}),n.defineProperty(this,"outputSize",{get:()=>s})}}let un=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(un=navigator.hardwareConcurrency)}catch{}const wn=new f,ln=new f,dn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let pn=0;async function hn(t){let n,c,s;try{const{options:a,config:i}=t;if(a.format)try{await async function(t,n){!Ut.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:o}=n;if(typeof e!=k&&typeof o!=k)throw new r("Invalid codec module");Ut.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(a.format,a.codecURI)}catch(t){if(Ft(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Zt.get(t);e||(e=new f,Zt.set(t,e));let o=e.get(n);if(o===v){try{new t(n),o=!0}catch{o=!1}e.set(n,o)}return o}(a.codecType.startsWith(sn)?i.CompressionStream:i.DecompressionStream,Kt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}if(a.encrypted&&!a.zipCrypto)try{await self.initModule(t.config)}catch{}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Dt(t.readable):new y({async pull(t){const n=new w(t=>wn.set(pn,t));yn({type:"pull",messageId:pn}),pn=(pn+1)%e.MAX_SAFE_INTEGER;const{value:o,done:r}=await n;t.enqueue(o),r&&t.close()}},u);s=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const o=new w(t=>n=t);ln.set(pn,n),yn({type:cn,value:t,messageId:pn}),pn=(pn+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new an(a,i),c=new fn(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?o.max(r,64):65536;var n,r}(i)),await l.pipeThrough(n).pipeThrough(c).pipeTo(s,{preventClose:!0,preventAbort:!0}),await s.getWriter().close();const{crc32:d,inputSize:p,outputSize:h}=n;yn({type:"close",result:{crc32:d,inputSize:p,outputSize:h}})}catch(t){const n=c?c.outputSize:0;if(Ft(t))try{t.outputSize=n}catch{}if(s&&!s.locked)try{await s.getWriter().close()}catch{}mn(t,n)}}function yn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new c(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function mn(t,n){const{message:e,stack:o,code:c,name:s,outputSize:a,cause:i,codecImportFailed:f}=function(t=new r("Unknown error")){return Ft(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:c,name:s,outputSize:a===v?n:a};if(Ft(i)&&(u.cause={name:i.name,message:i.message,code:i.code}),f&&(u.codecImportFailed=!0),dn)try{return void p({error:u,errorValue:{value:t}})}catch{}p({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:o,done:r}=t;try{if("start"==n&&hn(t),n==cn){const t=wn.get(e);wn.delete(e),t({value:o||new c,done:r})}if("ack"==n){const t=ln.get(e);ln.delete(e),t()}}catch(t){mn(t)}}),p({type:"ready"});const Sn="deflate",gn="deflate-raw",vn="deflate64-raw",bn="gzip",kn=[Sn,gn,bn],zn=[Sn,gn,bn,vn];let Cn,In,Mn,An,En;function Rn(t,n){return-4===n&&(t.code="Z_MEM_ERROR"),t}function xn(t,n,e={}){if(!(t?kn:zn).includes(n))throw new TypeError("Unsupported format: "+n);if(!Cn){const t=new r("WASM module not loaded");throw t.cause=En,t}const s="number"==typeof e.level?e.level:-1,a="number"==typeof e.outBuffer?e.outBuffer:65536,i="number"==typeof e.inBufferSize?e.inBufferSize:65536,f={M:0,in:0,inBufferSize:0,A:0,R:!1};let u,l,d,p,h=!0,S=!1;return function(){try{let e;if(f.M=In(a),f.in=In(i),f.inBufferSize=i,!f.M||!f.in)throw Rn(new r("allocation failed"),-4);if(t?(f.P=Cn.deflate_process,f.D=Cn.deflate_last_consumed,f.F=Cn.deflate_end,f.A=Cn.deflate_new(),e=n===bn?Cn.deflate_init_gzip(f.A,s):n===gn?Cn.deflate_init_raw(f.A,s):Cn.deflate_init(f.A,s)):n===vn?(f.P=Cn.inflate9_process,f.D=Cn.inflate9_last_consumed,f.F=Cn.inflate9_end,f.A=Cn.inflate9_new(),e=Cn.inflate9_init_raw(f.A)):(f.P=Cn.inflate_process,f.D=Cn.inflate_last_consumed,f.F=Cn.inflate_end,f.A=Cn.inflate_new(),e=n===gn?Cn.inflate_init_raw(f.A):n===bn?Cn.inflate_init_gzip(f.A):Cn.inflate_init(f.A)),0!==e)throw Rn(new r("init failed:"+e),e)}catch(t){throw b(f),t}}(),{readable:new y({start(t){u=t},pull(){h=!1,v()},cancel(t){S=!0,p=t,b(f),l.error(t),v()}},{highWaterMark:0}),writable:new m({start(t){l=t},async write(t){if(h&&await new w(t=>d=t),S)throw p;try{!function(t){const n=new c(An.buffer),e=f.P,s=f.D,i=f.M;let u=0;for(;u<t.length;){if(f.R)throw new r("trailing data after the end of the stream");const c=o.min(t.length-u,32768);if((!f.in||f.inBufferSize<c)&&(f.in&&Mn&&(Mn(f.in),f.in=0),f.in=In(c),f.inBufferSize=c,!f.in))throw Rn(new r("allocation failed"),-4);n.set(t.subarray(u,u+c),f.in);const w=e(f.A,f.in,c,i,a,0),l=w>>24&255,d=128&l?l-256:l;if(d<0)throw Rn(new r("process error:"+d),d);const p=16777215&w;p&&g(n.slice(i,i+p));const h=s(f.A);if(1===l)f.R=!0;else if(0===h&&0===p)break;u+=h}}(t)}catch(t){throw b(f),u.error(t),t}},close(){if(S)return;try{!function(){const t=new c(An.buffer),n=f.P,e=f.M;for(;;){const o=n(f.A,0,0,e,a,4),c=o>>24&255,s=128&c?c-256:c;if(s<0)throw Rn(new r("process error:"+s),s);const i=16777215&o;if(i&&g(t.slice(e,e+i)),1===c||0===i)break}}()}catch(t){throw b(f),u.error(t),t}const t=b(f);if(0!==t){const n=Rn(new r("end error:"+t),t);throw u.error(n),n}u.close()},abort(t){b(f),u.error(t)}},{highWaterMark:1})};function g(t){h=!0,u.enqueue(t)}function v(){if(d){const t=d;d=null,t()}}function b(t){let n=0;return t.A&&t.F&&(n=t.F(t.A)),t.A=0,t.in&&Mn&&Mn(t.in),t.in=0,t.M&&Mn&&Mn(t.M),t.M=0,n}}class Pn{constructor(t=Sn,n){return xn(!0,t,n)}}class Dn{constructor(t=Sn,n){return xn(!1,t,n)}}Pn.requiresModule=!0,Dn.requiresModule=!0,Pn.supportedFormats=kn,Dn.supportedFormats=zn;const Fn=65536;let Un,Bn;function Wn(t){return new c(t.memory.buffer)}let On=!1;!function(t={}){const{init:n,U:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(dt=e||G),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:Pn,DecompressionStreamFallback:Dn,U:function(t,n){const e=Un;let o=e?function(t,n,e){Bn||(Bn=t.malloc(Fn));const o=Bn?t.aes_hmac_new():0;if(o){const r=Wn(t);if(r.set(n,Bn),r.set(e,Bn+n.length),t.aes_hmac_init(o,Bn,n.length,Bn+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return G(t,n);const r=Bn;return{process(t,n){for(let c=0;c<t.length;c+=Fn){const s=t.subarray(c,c+Fn),a=Wn(e);a.set(s,r),e.aes_hmac_process(o,r,s.length,n?1:0),s.set(a.subarray(r,r+s.length))}},digest:()=>(e.aes_hmac_end(o,r),o=0,Wn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!On)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const r=await fetch(o);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),o=e.length,r=new c(o);for(let t=0;t<o;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}const s=await WebAssembly.instantiate(e);var a;(function(t){if(Cn=t,({malloc:In,free:Mn,memory:An}=Cn),"function"!=typeof In||"function"!=typeof Mn||!An)throw Cn=In=Mn=An=null,new r("Invalid WASM module")})(s.instance.exports),typeof(a=s.instance.exports).aes_hmac_new==k&&(Un=a,Bn=0)}(t,n),On=!0}catch(t){throw function(t){En=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const r=t.length;let o=0;for(;o+2<r;o+=3){const r=t[o]<<16|t[o+1]<<8|t[o+2];e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+n$1[63&r];}const s=r-o;if(1===s){const r=t[o]<<16;e+=n$1[r>>18&63]+n$1[r>>12&63]+"==";}else if(2===s){const r=t[o]<<16|t[o+1]<<8;e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+"=";}return e}(r)}});
|
|
449
449
|
|
|
450
450
|
/*
|
|
451
451
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -1906,7 +1906,9 @@
|
|
|
1906
1906
|
|
|
1907
1907
|
const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
|
|
1908
1908
|
const ERR_INVALID_COMPRESSED_DATA = "Invalid compressed data";
|
|
1909
|
+
const ERR_CODEC_OUT_OF_MEMORY = "Codec out of memory";
|
|
1909
1910
|
const ERR_INVALID_CRC32 = "Invalid CRC32";
|
|
1911
|
+
const Z_MEM_ERROR_CODE$1 = "Z_MEM_ERROR";
|
|
1910
1912
|
const FORMAT_DEFLATE_RAW$1 = "deflate-raw";
|
|
1911
1913
|
const FORMAT_DEFLATE64_RAW$1 = "deflate64-raw";
|
|
1912
1914
|
const FORMAT_GZIP$1 = "gzip";
|
|
@@ -1941,13 +1943,13 @@
|
|
|
1941
1943
|
readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamFallback);
|
|
1942
1944
|
} catch (error) {
|
|
1943
1945
|
if (!useCompressionStream && CompressionStreamFallback) {
|
|
1944
|
-
throw error;
|
|
1946
|
+
throw mapMemoryError(error);
|
|
1945
1947
|
}
|
|
1946
1948
|
let gzipStream;
|
|
1947
1949
|
try {
|
|
1948
1950
|
gzipStream = new CompressionStream(FORMAT_GZIP$1);
|
|
1949
1951
|
} catch {
|
|
1950
|
-
throw error;
|
|
1952
|
+
throw mapMemoryError(error);
|
|
1951
1953
|
}
|
|
1952
1954
|
readable = pipeThroughBackpressured(readable, gzipStream);
|
|
1953
1955
|
readable = pipeThrough(readable, new GzipToRawDeflateStream());
|
|
@@ -2011,50 +2013,30 @@
|
|
|
2011
2013
|
}
|
|
2012
2014
|
}
|
|
2013
2015
|
|
|
2014
|
-
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32) {
|
|
2016
|
+
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32, sourceErrors) {
|
|
2015
2017
|
const writer = gzipStream.writable.getWriter();
|
|
2016
2018
|
const reader = gzipStream.readable.getReader();
|
|
2017
2019
|
const outputCrc32 = crc32 === UNDEFINED_VALUE ? new Crc32() : UNDEFINED_VALUE;
|
|
2018
2020
|
let outputLength = 0;
|
|
2019
|
-
let inputDone = false;
|
|
2020
2021
|
let trailerWritten = false;
|
|
2021
|
-
let
|
|
2022
|
-
let
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
trailerReady.catch(() => { });
|
|
2030
|
-
pump();
|
|
2031
|
-
return new ReadableStream({
|
|
2032
|
-
async pull(controller) {
|
|
2033
|
-
try {
|
|
2034
|
-
const { value, done } = await read();
|
|
2035
|
-
if (done) {
|
|
2036
|
-
controller.close();
|
|
2037
|
-
} else {
|
|
2038
|
-
outputLength += value.length;
|
|
2039
|
-
if (outputLength > outputSize) {
|
|
2040
|
-
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2041
|
-
}
|
|
2042
|
-
if (outputCrc32) {
|
|
2043
|
-
outputCrc32.append(value);
|
|
2044
|
-
}
|
|
2045
|
-
controller.enqueue(value);
|
|
2046
|
-
}
|
|
2047
|
-
} catch (error) {
|
|
2048
|
-
rejectTrailerReady(error);
|
|
2049
|
-
await cancel(reader, error);
|
|
2050
|
-
throw trailerWritten ? getTrailerError(error) : error;
|
|
2051
|
-
}
|
|
2022
|
+
let settled = false;
|
|
2023
|
+
let resolvePull, controller;
|
|
2024
|
+
const output = new ReadableStream({
|
|
2025
|
+
start(streamController) {
|
|
2026
|
+
controller = streamController;
|
|
2027
|
+
},
|
|
2028
|
+
pull() {
|
|
2029
|
+
resumePump();
|
|
2052
2030
|
},
|
|
2053
2031
|
cancel(reason) {
|
|
2054
|
-
|
|
2032
|
+
settled = true;
|
|
2033
|
+
resumePump();
|
|
2055
2034
|
return reader.cancel(reason);
|
|
2056
2035
|
}
|
|
2057
2036
|
});
|
|
2037
|
+
pump();
|
|
2038
|
+
drain();
|
|
2039
|
+
return output;
|
|
2058
2040
|
|
|
2059
2041
|
async function pump() {
|
|
2060
2042
|
const inputReader = readable.getReader();
|
|
@@ -2063,19 +2045,16 @@
|
|
|
2063
2045
|
header.set(GZIP_HEADER_BYTES);
|
|
2064
2046
|
await writer.write(header);
|
|
2065
2047
|
for (; ;) {
|
|
2048
|
+
await outputCapacity();
|
|
2066
2049
|
await writer.ready;
|
|
2067
|
-
const { value, done } = await inputReader
|
|
2050
|
+
const { value, done } = await readSource(inputReader, sourceErrors);
|
|
2068
2051
|
if (done) {
|
|
2069
2052
|
break;
|
|
2070
2053
|
}
|
|
2071
2054
|
await writer.write(value);
|
|
2072
2055
|
}
|
|
2073
|
-
inputDone = true;
|
|
2074
2056
|
if (outputCrc32) {
|
|
2075
|
-
|
|
2076
|
-
armIdleCheck();
|
|
2077
|
-
}
|
|
2078
|
-
await trailerReady;
|
|
2057
|
+
await writer.write(new Uint8Array(0));
|
|
2079
2058
|
}
|
|
2080
2059
|
const trailer = new Uint8Array(GZIP_TRAILER_LENGTH);
|
|
2081
2060
|
const dataView = getDataView(trailer);
|
|
@@ -2090,54 +2069,68 @@
|
|
|
2090
2069
|
}
|
|
2091
2070
|
}
|
|
2092
2071
|
|
|
2093
|
-
function
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2072
|
+
async function drain() {
|
|
2073
|
+
try {
|
|
2074
|
+
for (; ;) {
|
|
2075
|
+
const { value, done } = await read();
|
|
2076
|
+
if (done) {
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
outputLength += value.length;
|
|
2080
|
+
if (outputLength > outputSize) {
|
|
2081
|
+
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2082
|
+
}
|
|
2083
|
+
if (outputCrc32) {
|
|
2084
|
+
outputCrc32.append(value);
|
|
2085
|
+
}
|
|
2086
|
+
controller.enqueue(value);
|
|
2087
|
+
}
|
|
2088
|
+
if (!settled) {
|
|
2089
|
+
settled = true;
|
|
2090
|
+
controller.close();
|
|
2091
|
+
}
|
|
2092
|
+
} catch (error) {
|
|
2093
|
+
fail(error);
|
|
2094
|
+
await cancel(reader, error);
|
|
2100
2095
|
}
|
|
2101
|
-
return result;
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
function onReadSettled() {
|
|
2105
|
-
readPending = false;
|
|
2106
2096
|
}
|
|
2107
2097
|
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
resolveTrailerReady();
|
|
2117
|
-
} else {
|
|
2118
|
-
armIdleCheck();
|
|
2098
|
+
function read() {
|
|
2099
|
+
return reader.read().catch(error => {
|
|
2100
|
+
if (trailerWritten) {
|
|
2101
|
+
if (!outputCrc32) {
|
|
2102
|
+
throw mapError(error, ERR_INVALID_CRC32);
|
|
2103
|
+
}
|
|
2104
|
+
if (outputLength != outputSize) {
|
|
2105
|
+
throw mapError(error, ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2119
2106
|
}
|
|
2107
|
+
return { done: true };
|
|
2120
2108
|
}
|
|
2121
|
-
|
|
2109
|
+
throw mapCodecError(error, sourceErrors);
|
|
2110
|
+
});
|
|
2122
2111
|
}
|
|
2123
2112
|
|
|
2124
|
-
function
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2113
|
+
function outputCapacity() {
|
|
2114
|
+
if (!settled && controller.desiredSize <= 0) {
|
|
2115
|
+
return new Promise(resolve => resolvePull = resolve);
|
|
2116
|
+
}
|
|
2128
2117
|
}
|
|
2129
|
-
}
|
|
2130
2118
|
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
port1.close();
|
|
2136
|
-
port2.close();
|
|
2119
|
+
function resumePump() {
|
|
2120
|
+
if (resolvePull) {
|
|
2121
|
+
const resolve = resolvePull;
|
|
2122
|
+
resolvePull = UNDEFINED_VALUE;
|
|
2137
2123
|
resolve();
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
function fail(error) {
|
|
2128
|
+
if (!settled) {
|
|
2129
|
+
settled = true;
|
|
2130
|
+
controller.error(error);
|
|
2131
|
+
resumePump();
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2141
2134
|
}
|
|
2142
2135
|
|
|
2143
2136
|
class InflateStream extends TransformStream {
|
|
@@ -2156,11 +2149,12 @@
|
|
|
2156
2149
|
}
|
|
2157
2150
|
}
|
|
2158
2151
|
if (compressed) {
|
|
2152
|
+
const sourceErrors = new Set();
|
|
2159
2153
|
const codecStreams = format && getCodecStreams(format);
|
|
2154
|
+
let gzipStream;
|
|
2160
2155
|
if (codecStreams) {
|
|
2161
|
-
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }));
|
|
2156
|
+
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }), sourceErrors);
|
|
2162
2157
|
} else {
|
|
2163
|
-
let gzipStream;
|
|
2164
2158
|
const GzipDecompressionStream = getGzipCodecStream(useCompressionStream, DecompressionStream, DecompressionStreamFallback);
|
|
2165
2159
|
if (checkCrc32 && !deflate64 && crc32 !== UNDEFINED_VALUE && outputSize !== UNDEFINED_VALUE && GzipDecompressionStream) {
|
|
2166
2160
|
try {
|
|
@@ -2171,24 +2165,25 @@
|
|
|
2171
2165
|
}
|
|
2172
2166
|
if (!gzipStream) {
|
|
2173
2167
|
try {
|
|
2174
|
-
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback);
|
|
2168
|
+
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback, sourceErrors);
|
|
2175
2169
|
} catch (error) {
|
|
2176
2170
|
if (deflate64 || outputSize === UNDEFINED_VALUE || (!useCompressionStream && DecompressionStreamFallback)) {
|
|
2177
|
-
throw error;
|
|
2171
|
+
throw mapMemoryError(error);
|
|
2178
2172
|
}
|
|
2179
2173
|
try {
|
|
2180
2174
|
gzipStream = new DecompressionStream(FORMAT_GZIP$1);
|
|
2181
2175
|
} catch {
|
|
2182
|
-
throw error;
|
|
2176
|
+
throw mapMemoryError(error);
|
|
2183
2177
|
}
|
|
2184
2178
|
}
|
|
2185
2179
|
}
|
|
2186
|
-
if (gzipStream) {
|
|
2187
|
-
gzipCrc32 = true;
|
|
2188
|
-
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32);
|
|
2189
|
-
}
|
|
2190
2180
|
}
|
|
2191
|
-
|
|
2181
|
+
if (gzipStream) {
|
|
2182
|
+
gzipCrc32 = true;
|
|
2183
|
+
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32, sourceErrors);
|
|
2184
|
+
} else {
|
|
2185
|
+
readable = mapInflateStreamError(readable, sourceErrors);
|
|
2186
|
+
}
|
|
2192
2187
|
}
|
|
2193
2188
|
if (checkCrc32 && !gzipCrc32) {
|
|
2194
2189
|
crc32Stream = new Crc32Stream();
|
|
@@ -2261,7 +2256,7 @@
|
|
|
2261
2256
|
}
|
|
2262
2257
|
}
|
|
2263
2258
|
|
|
2264
|
-
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback) {
|
|
2259
|
+
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback, sourceErrors) {
|
|
2265
2260
|
const Stream = useCompressionStream && CompressionStreamNative ?
|
|
2266
2261
|
CompressionStreamNative :
|
|
2267
2262
|
CompressionStreamFallback || CompressionStreamNative;
|
|
@@ -2276,14 +2271,14 @@
|
|
|
2276
2271
|
throw error;
|
|
2277
2272
|
}
|
|
2278
2273
|
}
|
|
2279
|
-
return pipeThroughBackpressured(readable, codecStream);
|
|
2274
|
+
return pipeThroughBackpressured(readable, codecStream, sourceErrors);
|
|
2280
2275
|
}
|
|
2281
2276
|
|
|
2282
2277
|
function pipeThrough(readable, transformStream) {
|
|
2283
2278
|
return toCompatibleReadable(readable).pipeThrough(transformStream);
|
|
2284
2279
|
}
|
|
2285
2280
|
|
|
2286
|
-
function pipeThroughBackpressured(readable, transformStream) {
|
|
2281
|
+
function pipeThroughBackpressured(readable, transformStream, sourceErrors) {
|
|
2287
2282
|
const writer = transformStream.writable.getWriter();
|
|
2288
2283
|
const reader = readable.getReader();
|
|
2289
2284
|
pump();
|
|
@@ -2293,7 +2288,7 @@
|
|
|
2293
2288
|
try {
|
|
2294
2289
|
for (; ;) {
|
|
2295
2290
|
await writer.ready;
|
|
2296
|
-
const result = await reader
|
|
2291
|
+
const result = await readSource(reader, sourceErrors);
|
|
2297
2292
|
if (result.done) {
|
|
2298
2293
|
await writer.close();
|
|
2299
2294
|
break;
|
|
@@ -2323,7 +2318,36 @@
|
|
|
2323
2318
|
}
|
|
2324
2319
|
}
|
|
2325
2320
|
|
|
2326
|
-
function
|
|
2321
|
+
function readSource(reader, sourceErrors) {
|
|
2322
|
+
const result = reader.read();
|
|
2323
|
+
return sourceErrors ? result.catch(error => {
|
|
2324
|
+
sourceErrors.add(error);
|
|
2325
|
+
throw error;
|
|
2326
|
+
}) : result;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function mapCodecError(error, sourceErrors) {
|
|
2330
|
+
if (sourceErrors.has(error)) {
|
|
2331
|
+
return error;
|
|
2332
|
+
}
|
|
2333
|
+
return mapError(error, isMemoryError(error) ? ERR_CODEC_OUT_OF_MEMORY : ERR_INVALID_COMPRESSED_DATA);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
function mapMemoryError(error) {
|
|
2337
|
+
return isMemoryError(error) ? mapError(error, ERR_CODEC_OUT_OF_MEMORY) : error;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
function isMemoryError(error) {
|
|
2341
|
+
return isErrorObject(error) && error.code == Z_MEM_ERROR_CODE$1;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
function mapError(error, message) {
|
|
2345
|
+
const mappedError = new Error(message);
|
|
2346
|
+
mappedError.cause = error;
|
|
2347
|
+
return mappedError;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
function mapInflateStreamError(readable, sourceErrors) {
|
|
2327
2351
|
const reader = readable.getReader();
|
|
2328
2352
|
return new ReadableStream({
|
|
2329
2353
|
async pull(controller) {
|
|
@@ -2336,12 +2360,7 @@
|
|
|
2336
2360
|
}
|
|
2337
2361
|
} catch (error) {
|
|
2338
2362
|
await cancel(reader, error);
|
|
2339
|
-
|
|
2340
|
-
throw error;
|
|
2341
|
-
}
|
|
2342
|
-
const mappedError = new Error(ERR_INVALID_COMPRESSED_DATA);
|
|
2343
|
-
mappedError.cause = error;
|
|
2344
|
-
throw mappedError;
|
|
2363
|
+
throw mapCodecError(error, sourceErrors);
|
|
2345
2364
|
}
|
|
2346
2365
|
},
|
|
2347
2366
|
cancel(reason) {
|
|
@@ -2709,10 +2728,11 @@
|
|
|
2709
2728
|
}
|
|
2710
2729
|
codecStream = new CodecStream(options, config);
|
|
2711
2730
|
chunkStream = new ChunkStream(getChunkSize(config));
|
|
2731
|
+
const { signal } = workerOptions.streamOptions;
|
|
2712
2732
|
await readable
|
|
2713
2733
|
.pipeThrough(codecStream)
|
|
2714
2734
|
.pipeThrough(chunkStream)
|
|
2715
|
-
.pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
2735
|
+
.pipeTo(writable, { preventClose: true, preventAbort: true, signal });
|
|
2716
2736
|
const {
|
|
2717
2737
|
crc32,
|
|
2718
2738
|
inputSize,
|
|
@@ -2780,6 +2800,7 @@
|
|
|
2780
2800
|
const MODULE_WORKER_OPTIONS = { type: "module" };
|
|
2781
2801
|
const ERROR_EVENT_TYPE = "error";
|
|
2782
2802
|
const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
2803
|
+
const ABORT_EVENT_TYPE = "abort";
|
|
2783
2804
|
|
|
2784
2805
|
let webWorkerSource, webWorkerURI, webWorkerOptions;
|
|
2785
2806
|
let transferStreamsSupported = true;
|
|
@@ -2956,6 +2977,13 @@
|
|
|
2956
2977
|
Object.assign(workerData, { destinationFailed: true, destinationError: error });
|
|
2957
2978
|
}
|
|
2958
2979
|
});
|
|
2980
|
+
const { signal } = workerData.workerOptions.streamOptions;
|
|
2981
|
+
if (signal) {
|
|
2982
|
+
const onAbort = () => abortController.abort(signal.reason);
|
|
2983
|
+
const removeAbortListener = () => signal.removeEventListener(ABORT_EVENT_TYPE, onAbort);
|
|
2984
|
+
signal.addEventListener(ABORT_EVENT_TYPE, onAbort);
|
|
2985
|
+
closed.then(removeAbortListener, removeAbortListener);
|
|
2986
|
+
}
|
|
2959
2987
|
return {
|
|
2960
2988
|
writable, closed, abortPipe: () => {
|
|
2961
2989
|
aborting = true;
|
|
@@ -3218,9 +3246,6 @@
|
|
|
3218
3246
|
responseError = errorValue.value;
|
|
3219
3247
|
} else {
|
|
3220
3248
|
responseError = Object.assign(new Error(message), { stack, code, name });
|
|
3221
|
-
if (cause) {
|
|
3222
|
-
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3223
|
-
}
|
|
3224
3249
|
}
|
|
3225
3250
|
if (isErrorObject(responseError)) {
|
|
3226
3251
|
try {
|
|
@@ -3230,6 +3255,14 @@
|
|
|
3230
3255
|
if (codecImportFailed) {
|
|
3231
3256
|
responseError.codecImportFailed = true;
|
|
3232
3257
|
}
|
|
3258
|
+
if (cause) {
|
|
3259
|
+
if (!isErrorObject(responseError.cause)) {
|
|
3260
|
+
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3261
|
+
}
|
|
3262
|
+
if (cause.code !== UNDEFINED_VALUE && responseError.cause.code !== cause.code) {
|
|
3263
|
+
responseError.cause.code = cause.code;
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3233
3266
|
if (errorValue) {
|
|
3234
3267
|
if (responseError.name !== name) {
|
|
3235
3268
|
responseError.name = name;
|
|
@@ -4820,7 +4853,7 @@
|
|
|
4820
4853
|
const CHARSET_UTF8 = "utf-8";
|
|
4821
4854
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4822
4855
|
const CHARSET_CP437 = "cp437";
|
|
4823
|
-
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG;
|
|
4856
|
+
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_STRONG_ENCRYPTION | BITFLAG_LANG_ENCODING_FLAG;
|
|
4824
4857
|
const VENDOR_VERSION_AE_1$1 = 1;
|
|
4825
4858
|
const ZIP64_PROPERTIES = [
|
|
4826
4859
|
[PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
|
|
@@ -5474,12 +5507,12 @@
|
|
|
5474
5507
|
fileEntry.gid = gid;
|
|
5475
5508
|
}
|
|
5476
5509
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5477
|
-
const encrypted = zipEntry.encrypted &&
|
|
5510
|
+
const encrypted = zipEntry.encrypted && (!passThroughEncryption || checkPasswordOnly);
|
|
5478
5511
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5479
5512
|
if (!passThroughEncryption) {
|
|
5480
5513
|
fileEntry.zipCrypto = zipCrypto;
|
|
5481
5514
|
}
|
|
5482
|
-
if (encrypted && (
|
|
5515
|
+
if (encrypted && (zipEntry.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
|
|
5483
5516
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
5484
5517
|
}
|
|
5485
5518
|
const registeredCodec = passThroughCompression ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -5572,6 +5605,7 @@
|
|
|
5572
5605
|
({ writable } = writer);
|
|
5573
5606
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5574
5607
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5608
|
+
throwIfAborted(signal);
|
|
5575
5609
|
if (writtenSize != outputSize) {
|
|
5576
5610
|
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
5577
5611
|
}
|
|
@@ -5718,8 +5752,16 @@
|
|
|
5718
5752
|
});
|
|
5719
5753
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5720
5754
|
if (extraFieldZip64) {
|
|
5721
|
-
readExtraFieldZip64(extraFieldZip64, directory)
|
|
5755
|
+
if (!readExtraFieldZip64(extraFieldZip64, directory, localDirectory)) {
|
|
5756
|
+
malformedExtraField = true;
|
|
5757
|
+
}
|
|
5722
5758
|
directory.extraFieldZip64 = extraFieldZip64;
|
|
5759
|
+
} else if (ZIP64_PROPERTIES.some(([propertyName, max]) => directory[propertyName] == max)) {
|
|
5760
|
+
if (localDirectory) {
|
|
5761
|
+
malformedExtraField = true;
|
|
5762
|
+
} else {
|
|
5763
|
+
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5764
|
+
}
|
|
5723
5765
|
}
|
|
5724
5766
|
const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
|
|
5725
5767
|
if (extraFieldUnicodePath) {
|
|
@@ -5732,10 +5774,13 @@
|
|
|
5732
5774
|
directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
|
|
5733
5775
|
}
|
|
5734
5776
|
const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
|
|
5735
|
-
if (extraFieldAES && extraFieldAES.data.length >= 7) {
|
|
5777
|
+
if (extraFieldAES && (compressionMethod == COMPRESSION_METHOD_AES || directory.encrypted) && extraFieldAES.data.length >= 7) {
|
|
5736
5778
|
readExtraFieldAES(extraFieldAES, directory, compressionMethod);
|
|
5737
5779
|
directory.extraFieldAES = extraFieldAES;
|
|
5738
5780
|
} else {
|
|
5781
|
+
if (extraFieldAES) {
|
|
5782
|
+
malformedExtraField = true;
|
|
5783
|
+
}
|
|
5739
5784
|
directory.compressionMethod = compressionMethod;
|
|
5740
5785
|
}
|
|
5741
5786
|
const extraFieldPkwareUnix = extraField.get(EXTRAFIELD_TYPE_PKWARE_UNIX);
|
|
@@ -5778,20 +5823,35 @@
|
|
|
5778
5823
|
return malformedExtraField;
|
|
5779
5824
|
}
|
|
5780
5825
|
|
|
5781
|
-
function readExtraFieldZip64(extraFieldZip64, directory) {
|
|
5826
|
+
function readExtraFieldZip64(extraFieldZip64, directory, localDirectory) {
|
|
5782
5827
|
directory.zip64 = true;
|
|
5783
5828
|
const extraFieldView = getDataView(extraFieldZip64.data);
|
|
5784
5829
|
const missingProperties = ZIP64_PROPERTIES.filter(([propertyName, max]) => directory[propertyName] == max);
|
|
5785
5830
|
const requiredLength = missingProperties.reduce((length, [, max]) => length + ZIP64_EXTRACTION[max].bytes, 0);
|
|
5786
5831
|
if (extraFieldZip64.data.length < requiredLength) {
|
|
5832
|
+
if (localDirectory) {
|
|
5833
|
+
return false;
|
|
5834
|
+
}
|
|
5787
5835
|
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5788
5836
|
}
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5837
|
+
const values = [];
|
|
5838
|
+
try {
|
|
5839
|
+
for (let indexMissingProperty = 0, offset = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) {
|
|
5840
|
+
const [, max] = missingProperties[indexMissingProperty];
|
|
5841
|
+
const extraction = ZIP64_EXTRACTION[max];
|
|
5842
|
+
values.push(extraction.getValue(extraFieldView, offset));
|
|
5843
|
+
offset += extraction.bytes;
|
|
5844
|
+
}
|
|
5845
|
+
} catch (error) {
|
|
5846
|
+
if (localDirectory) {
|
|
5847
|
+
return false;
|
|
5848
|
+
}
|
|
5849
|
+
throw error;
|
|
5794
5850
|
}
|
|
5851
|
+
missingProperties.forEach(([propertyName], indexMissingProperty) => {
|
|
5852
|
+
directory[propertyName] = extraFieldZip64[propertyName] = values[indexMissingProperty];
|
|
5853
|
+
});
|
|
5854
|
+
return true;
|
|
5795
5855
|
}
|
|
5796
5856
|
|
|
5797
5857
|
function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
|
|
@@ -6367,6 +6427,7 @@
|
|
|
6367
6427
|
ERR_AMBIGUOUS_ARCHIVE: ERR_AMBIGUOUS_ARCHIVE,
|
|
6368
6428
|
ERR_BAD_FORMAT: ERR_BAD_FORMAT,
|
|
6369
6429
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
6430
|
+
ERR_CODEC_OUT_OF_MEMORY: ERR_CODEC_OUT_OF_MEMORY,
|
|
6370
6431
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
6371
6432
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6372
6433
|
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
@@ -7814,6 +7875,7 @@
|
|
|
7814
7875
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
7815
7876
|
compressedSize = result.outputSize;
|
|
7816
7877
|
writer.size += compressedSize;
|
|
7878
|
+
throwIfAborted(signal);
|
|
7817
7879
|
if (!passThroughCompression) {
|
|
7818
7880
|
uncompressedSize = result.inputSize;
|
|
7819
7881
|
if (!encrypted || zipCrypto) {
|
|
@@ -8993,7 +9055,7 @@
|
|
|
8993
9055
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8994
9056
|
*/
|
|
8995
9057
|
|
|
8996
|
-
const VERSION = "2.
|
|
9058
|
+
const VERSION = "2.18.0";
|
|
8997
9059
|
|
|
8998
9060
|
/*
|
|
8999
9061
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9478,6 +9540,10 @@
|
|
|
9478
9540
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
9479
9541
|
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
9480
9542
|
const FORMAT_GZIP = "gzip";
|
|
9543
|
+
const Z_MEM_ERROR = -4;
|
|
9544
|
+
const Z_MEM_ERROR_CODE = "Z_MEM_ERROR";
|
|
9545
|
+
const COMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP];
|
|
9546
|
+
const DECOMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP, FORMAT_DEFLATE64_RAW];
|
|
9481
9547
|
|
|
9482
9548
|
let wasm$1, malloc, free, memory, initError;
|
|
9483
9549
|
|
|
@@ -9498,7 +9564,17 @@
|
|
|
9498
9564
|
wasm$1 = malloc = free = memory = initError = null;
|
|
9499
9565
|
}
|
|
9500
9566
|
|
|
9567
|
+
function setZlibCode(error, result) {
|
|
9568
|
+
if (result === Z_MEM_ERROR) {
|
|
9569
|
+
error.code = Z_MEM_ERROR_CODE;
|
|
9570
|
+
}
|
|
9571
|
+
return error;
|
|
9572
|
+
}
|
|
9573
|
+
|
|
9501
9574
|
function _make(isCompress, type, options = {}) {
|
|
9575
|
+
if (!(isCompress ? COMPRESSION_FORMATS : DECOMPRESSION_FORMATS).includes(type)) {
|
|
9576
|
+
throw new TypeError("Unsupported format: " + type);
|
|
9577
|
+
}
|
|
9502
9578
|
if (!wasm$1) {
|
|
9503
9579
|
const error = new Error("WASM module not loaded");
|
|
9504
9580
|
error.cause = initError;
|
|
@@ -9507,7 +9583,7 @@
|
|
|
9507
9583
|
const level = (typeof options.level === "number") ? options.level : -1;
|
|
9508
9584
|
const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
|
|
9509
9585
|
const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
|
|
9510
|
-
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0 };
|
|
9586
|
+
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0, streamEnded: false };
|
|
9511
9587
|
let readableController, writableController, resolveWrite, cancelReason;
|
|
9512
9588
|
let backpressure = true;
|
|
9513
9589
|
let cancelled = false;
|
|
@@ -9560,7 +9636,7 @@
|
|
|
9560
9636
|
}
|
|
9561
9637
|
const result = disposeStream(state);
|
|
9562
9638
|
if (result !== 0) {
|
|
9563
|
-
const error = new Error("end error:" + result);
|
|
9639
|
+
const error = setZlibCode(new Error("end error:" + result), result);
|
|
9564
9640
|
readableController.error(error);
|
|
9565
9641
|
throw error;
|
|
9566
9642
|
}
|
|
@@ -9580,7 +9656,7 @@
|
|
|
9580
9656
|
state.in = malloc(inBufferSize);
|
|
9581
9657
|
state.inBufferSize = inBufferSize;
|
|
9582
9658
|
if (!state.out || !state.in) {
|
|
9583
|
-
throw new Error("allocation failed");
|
|
9659
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9584
9660
|
}
|
|
9585
9661
|
if (isCompress) {
|
|
9586
9662
|
state._process = wasm$1.deflate_process;
|
|
@@ -9616,7 +9692,7 @@
|
|
|
9616
9692
|
}
|
|
9617
9693
|
}
|
|
9618
9694
|
if (result !== 0) {
|
|
9619
|
-
throw new Error("init failed:" + result);
|
|
9695
|
+
throw setZlibCode(new Error("init failed:" + result), result);
|
|
9620
9696
|
}
|
|
9621
9697
|
} catch (error) {
|
|
9622
9698
|
disposeStream(state);
|
|
@@ -9631,6 +9707,9 @@
|
|
|
9631
9707
|
const out = state.out;
|
|
9632
9708
|
let offset = 0;
|
|
9633
9709
|
while (offset < chunk.length) {
|
|
9710
|
+
if (state.streamEnded) {
|
|
9711
|
+
throw new Error("trailing data after the end of the stream");
|
|
9712
|
+
}
|
|
9634
9713
|
const toRead = Math.min(chunk.length - offset, 32 * 1024);
|
|
9635
9714
|
if (!state.in || state.inBufferSize < toRead) {
|
|
9636
9715
|
if (state.in && free) {
|
|
@@ -9640,7 +9719,7 @@
|
|
|
9640
9719
|
state.in = malloc(toRead);
|
|
9641
9720
|
state.inBufferSize = toRead;
|
|
9642
9721
|
if (!state.in) {
|
|
9643
|
-
throw new Error("allocation failed");
|
|
9722
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9644
9723
|
}
|
|
9645
9724
|
}
|
|
9646
9725
|
heap.set(chunk.subarray(offset, offset + toRead), state.in);
|
|
@@ -9649,14 +9728,16 @@
|
|
|
9649
9728
|
const code = (result >> 24) & 0xff;
|
|
9650
9729
|
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9651
9730
|
if (signedCode < 0) {
|
|
9652
|
-
throw new Error("process error:" + signedCode);
|
|
9731
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9653
9732
|
}
|
|
9654
9733
|
const prod = result & 0x00ffffff;
|
|
9655
9734
|
if (prod) {
|
|
9656
9735
|
enqueue(heap.slice(out, out + prod));
|
|
9657
9736
|
}
|
|
9658
9737
|
const consumed = last_consumed(state.streamHandle);
|
|
9659
|
-
if (
|
|
9738
|
+
if (code === 1) {
|
|
9739
|
+
state.streamEnded = true;
|
|
9740
|
+
} else if (consumed === 0 && prod === 0) {
|
|
9660
9741
|
break;
|
|
9661
9742
|
}
|
|
9662
9743
|
offset += consumed;
|
|
@@ -9672,7 +9753,7 @@
|
|
|
9672
9753
|
const code = (result >> 24) & 0xff;
|
|
9673
9754
|
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9674
9755
|
if (signedCode < 0) {
|
|
9675
|
-
throw new Error("process error:" + signedCode);
|
|
9756
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9676
9757
|
}
|
|
9677
9758
|
const produced = result & 0x00ffffff;
|
|
9678
9759
|
if (produced) {
|
|
@@ -9731,10 +9812,10 @@
|
|
|
9731
9812
|
CompressionStreamZlib.requiresModule = true;
|
|
9732
9813
|
DecompressionStreamZlib.requiresModule = true;
|
|
9733
9814
|
// Constructing these classes before the module is loaded throws, so capability probes cannot rely
|
|
9734
|
-
// on trying the constructor; the formats are declared instead,
|
|
9735
|
-
//
|
|
9736
|
-
CompressionStreamZlib.supportedFormats =
|
|
9737
|
-
DecompressionStreamZlib.supportedFormats =
|
|
9815
|
+
// on trying the constructor; the formats are declared instead, the lists _make() checks a format
|
|
9816
|
+
// against before anything else.
|
|
9817
|
+
CompressionStreamZlib.supportedFormats = COMPRESSION_FORMATS;
|
|
9818
|
+
DecompressionStreamZlib.supportedFormats = DECOMPRESSION_FORMATS;
|
|
9738
9819
|
|
|
9739
9820
|
/*
|
|
9740
9821
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -10056,6 +10137,7 @@
|
|
|
10056
10137
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
10057
10138
|
const ABORT_ERROR_NAME = "AbortError";
|
|
10058
10139
|
const EMPTY_RAW_PASSWORD = new Uint8Array(0);
|
|
10140
|
+
const FALSE_ACCEPT_ERRORS = new Set([ERR_INVALID_CRC32, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_COMPRESSED_DATA]);
|
|
10059
10141
|
|
|
10060
10142
|
class ZipEntry {
|
|
10061
10143
|
|
|
@@ -11043,7 +11125,12 @@
|
|
|
11043
11125
|
release();
|
|
11044
11126
|
}
|
|
11045
11127
|
}
|
|
11046
|
-
|
|
11128
|
+
if (!tried.size) {
|
|
11129
|
+
throw new Error(ERR_ENCRYPTED);
|
|
11130
|
+
}
|
|
11131
|
+
const passwordError = new Error(ERR_INVALID_PASSWORD);
|
|
11132
|
+
passwordError.cause = error;
|
|
11133
|
+
throw passwordError;
|
|
11047
11134
|
|
|
11048
11135
|
async function tryPasswordCandidate(candidate) {
|
|
11049
11136
|
tried.add(candidate.key);
|
|
@@ -11064,7 +11151,7 @@
|
|
|
11064
11151
|
rememberPassword(passwordState, candidate);
|
|
11065
11152
|
return { done: true, data };
|
|
11066
11153
|
} catch (readError) {
|
|
11067
|
-
if (isAbortError(readError, signal) ||
|
|
11154
|
+
if (isAbortError(readError, signal) || !isWrongPasswordError(readError, entry)) {
|
|
11068
11155
|
throw readError;
|
|
11069
11156
|
}
|
|
11070
11157
|
return { done: false, error: readError };
|
|
@@ -11076,6 +11163,10 @@
|
|
|
11076
11163
|
return isErrorObject(error) && error.message == ERR_INVALID_PASSWORD;
|
|
11077
11164
|
}
|
|
11078
11165
|
|
|
11166
|
+
function isWrongPasswordError(error, entry) {
|
|
11167
|
+
return isInvalidPasswordError(error) || (entry.zipCrypto && isErrorObject(error) && FALSE_ACCEPT_ERRORS.has(error.message));
|
|
11168
|
+
}
|
|
11169
|
+
|
|
11079
11170
|
function isAbortError(error, signal) {
|
|
11080
11171
|
return Boolean(signal && signal.aborted) || (isErrorObject(error) && error.name == ABORT_ERROR_NAME);
|
|
11081
11172
|
}
|
|
@@ -11600,6 +11691,7 @@
|
|
|
11600
11691
|
exports.ERR_ANCESTOR_ENTRY = ERR_ANCESTOR_ENTRY;
|
|
11601
11692
|
exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
|
|
11602
11693
|
exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
|
|
11694
|
+
exports.ERR_CODEC_OUT_OF_MEMORY = ERR_CODEC_OUT_OF_MEMORY;
|
|
11603
11695
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
11604
11696
|
exports.ERR_DUPLICATE_IMPORTED_ENTRY = ERR_DUPLICATE_IMPORTED_ENTRY;
|
|
11605
11697
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|