@zip.js/zip.js 2.8.39 → 2.8.42

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.
Files changed (52) hide show
  1. package/README.md +37 -0
  2. package/deno.json +6 -2
  3. package/dist/README.md +10 -1
  4. package/dist/zip-core-external.js +8180 -0
  5. package/dist/zip-core-external.min.js +1 -0
  6. package/dist/zip-core.js +168 -30
  7. package/dist/zip-core.min.js +1 -1
  8. package/dist/zip-fs-core-external.js +9196 -0
  9. package/dist/zip-fs-core-external.min.js +1 -0
  10. package/dist/zip-fs-core.js +168 -30
  11. package/dist/zip-fs-core.min.js +1 -1
  12. package/dist/zip-fs-external.js +10833 -0
  13. package/dist/zip-fs-external.min.js +1 -0
  14. package/dist/zip-fs-native.js +170 -32
  15. package/dist/zip-fs-native.min.js +1 -1
  16. package/dist/zip-fs.js +244 -51
  17. package/dist/zip-fs.min.js +1 -1
  18. package/dist/zip-legacy.js +170 -32
  19. package/dist/zip-legacy.min.js +1 -1
  20. package/dist/zip-native.js +170 -32
  21. package/dist/zip-native.min.js +1 -1
  22. package/dist/zip-web-worker-native.js +1 -1
  23. package/dist/zip-web-worker.js +1 -1
  24. package/dist/zip.js +244 -51
  25. package/dist/zip.min.js +1 -1
  26. package/index-native.cjs +170 -32
  27. package/index-native.min.js +1 -1
  28. package/index.cjs +244 -51
  29. package/index.d.cts +11 -2
  30. package/index.d.ts +11 -2
  31. package/index.min.js +1 -1
  32. package/lib/core/codec-registry.js +1 -1
  33. package/lib/core/codec-worker.js +4 -1
  34. package/lib/core/external-assets.js +42 -0
  35. package/lib/core/io.js +27 -11
  36. package/lib/core/streams/zip-entry-stream.js +57 -7
  37. package/lib/core/streams/zlib-wasm/zlib-streams-loader.js +27 -17
  38. package/lib/core/streams/zlib-wasm/zlib-streams.js +14 -1
  39. package/lib/core/util/compatible-streams.js +72 -0
  40. package/lib/core/web-worker-base.js +6 -2
  41. package/lib/core/web-worker-inline-native.js +1 -1
  42. package/lib/core/web-worker-inline-wasm.js +1 -1
  43. package/lib/core/zip-reader.js +12 -8
  44. package/lib/core/zip-writer.js +4 -2
  45. package/lib/zip-core-external.js +34 -0
  46. package/lib/zip-fs-core-external.js +30 -0
  47. package/lib/zip-fs-external.js +30 -0
  48. package/lib/zip-mime-types.js +29 -0
  49. package/lib/zip-module-wasm-base.js +64 -0
  50. package/lib/zip-module-wasm.js +1 -31
  51. package/package.json +65 -2
  52. package/worker-message-property-names.js +1 -1
package/index.cjs CHANGED
@@ -218,7 +218,7 @@ function resetConfiguration() {
218
218
  Object.assign(config, DEFAULT_CONFIGURATION);
219
219
  }
220
220
 
221
- function t$1(t){const e='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:i,Uint32Array:c,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,P,D,R,U,M]=C;class _{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=M[255&t]^U[t>>>8&255]^R[t>>>16&255]^D[t>>>24&255]^P[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class B extends d{constructor(){let t;const e=new _;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function V(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}const W={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=W.l(n);return 32===s?t.concat(e):W.h(e,s,0|n,t.slice(0,t.length-1))},m(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+W.l(n)},S(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=W.v(e,t[n-1]&2147483648>>e-1,1)),t},v:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=W.l(r);return s.push(W.v(e+o&31,e+o>32?n:s.pop(),1)),s}},K={bytes:{C(t){const e=W.m(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},A(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(W.v(8*(3&n),s)),e}}},E=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.P=[1518500249,1859775393,2400959708,3395469782],t?(e.D=t.D.slice(0),e.R=t.R.slice(0),e.U=t.U):e.reset()}reset(){const t=this;return t.D=t.I.slice(0),t.R=[],t.U=0,t}update(t){const e=this;"string"==typeof t&&(t=K.M.A(t));const n=e.R=W.concat(e.R,t),s=e.U,o=e.U=s+W.m(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const i=new c(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e._(i.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}B(){const t=this;let e=t.R;const n=t.D;e=W.concat(e,[W.v(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.U/4294967296)),e.push(0|t.U);e.length;)t._(e.splice(0,16));return t.reset(),n}V(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}_(e){const n=this,r=n.D,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let i=r[0],c=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,i)+n.V(t,c,a,f)+l+o[t]+n.P[s.floor(t/20)]|0;l=f,f=a,a=n.W(30,c),c=i,i=e}r[0]=r[0]+i|0,r[1]=r[1]+c|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},L={importKey:t=>new L.K(K.bytes.A(t)),L(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let i,c,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=W;for(e=K.bytes.A(e),u=1;(o||1)>p;u++){for(i=c=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(c=t.encrypt(c),f=0;f<c.length;f++)i[f]^=c[f];for(a=0;(o||1)>p&&a<i.length;a++)h.setInt32(p,i[a]),p+=4}return w.slice(0,s/8)},K:class{constructor(t){const e=this,n=e.O=E,s=[[],[]];e.T=[new n,new n];const r=e.T[0].blockSize/32;t.length>r&&(t=(new n).update(t).B());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.T[0].update(s[0]),e.T[1].update(s[1]),e.j=new n(e.T[0])}reset(){const t=this;t.j=new t.O(t.T[0]),t.H=!1}update(t){this.H=!0,this.j.update(t)}digest(){const t=this,e=t.j.B(),n=new t.O(t.T[1]).update(e).B();return t.reset(),n}encrypt(t){if(this.H)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},O=typeof h!=b&&typeof h.getRandomValues==k,T="Invalid password",j="Invalid signature",H="zipjs-abort-check-password";function Z(t){if(O)return h.getRandomValues(t);throw new r("Crypto API not supported")}const F=16,N={name:"PBKDF2"},q=e.assign({hash:{name:"HMAC"}},N),G=e.assign({iterations:1e3,hash:{name:"SHA-1"}},N),J=["deriveBits"],Q=[8,12,16],X=[16,24,32],Y=10,$=[0,0,0,0],tt=typeof h!=b,et=tt&&h.subtle,nt=tt&&typeof et!=b,st=K.bytes,rt=class{constructor(t){const e=this;e.Z=[[[],[],[],[],[]],[[],[],[],[],[]]],e.Z[0][0][0]||e.F();const n=e.Z[0][4],s=e.Z[1],o=t.length;let i,c,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.P=[c=t.slice(0),a=[]],i=o;4*o+28>i;i++){let t=c[i-1];(i%o===0||8===o&&i%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),c[i]=c[i-o]^t}for(let t=0;i;t++,i--){const e=c[3&t?i:i-4];a[t]=4>=i||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}F(){const t=this.Z[0],e=this.Z[1],n=t[4],s=e[4],r=[],o=[];let i,c,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=i=0;!n[l];l^=c||1,i=o[i]||1){let o=i^i<<1^i<<2^i<<3^i<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[c=r[l]]];let u=16843009*f^65537*a^257*c^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.P[e],s=n.length/4-2,o=[0,0,0,0],i=this.Z[e],c=i[0],a=i[1],f=i[2],l=i[3],u=i[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)w=c[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&g]^n[S],h=c[y>>>24]^a[m>>16&255]^f[g>>8&255]^l[255&d]^n[S+1],p=c[m>>>24]^a[g>>16&255]^f[d>>8&255]^l[255&y]^n[S+2],g=c[g>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},ot=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}$(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}et(t){0===(t[0]=this.$(t[0]))&&(t[1]=this.$(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=W.m(e);for(let r=0;s>r;r+=4){this.et(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return W.S(e,r)}},it=L.K;let ct=tt&&nt&&typeof et.importKey==k,at=tt&&nt&&typeof et.deriveBits==k;class ft extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s}){super({start(){ut(this,t,e,n)},async transform(t,e){const n=this,{password:i,strength:c,nt:a,ready:f}=n;i?(await(async(t,e,n,s)=>{const o=await ht(t,e,n,dt(s,0,Q[e])),i=dt(s,Q[e]);if(o[0]!=i[0]||o[1]!=i[1])throw new r(T)})(n,c,i,dt(t,0,Q[c]+2)),t=dt(t,Q[c]+2),s?e.error(new r(H)):a()):await f;const l=new o(t.length-Y-(t.length-Y)%F);e.enqueue(wt(n,t,l,0,Y,!0))},async flush(t){const{st:e,ot:n,pending:s,ready:o}=this;if(n&&e){await o;const i=dt(s,0,s.length-Y),c=dt(s,s.length-Y);let a=z;if(i.length){const t=mt(st,i);n.update(t);const s=e.update(t);a=yt(st,s)}const f=dt(yt(st,n.digest()),0,Y);let l=s.length<Y?1:0;for(let t=0;Y>t;t++)l|=f[t]^c[t];if(l)throw new r(j);t.enqueue(a)}}})}}class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){let s;super({start(){ut(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,nt:i,ready:c}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=Z(new o(Q[e]));return V(s,await ht(t,e,n,s))})(n,r,s),i()):await c;const f=new o(a.length+t.length-t.length%F);f.set(a,0),e.enqueue(wt(n,t,f,a.length,0))},async flush(t){const{st:e,ot:n,pending:r,ready:o}=this;if(n&&e){await o;let i=z;if(r.length){const t=e.update(mt(st,r));n.update(t),i=yt(st,t)}s.signature=yt(st,n.digest()).slice(0,Y),t.enqueue(V(i,s.signature))}}}),s=this}}function ut(t,n,s,r){e.assign(t,{ready:new u(e=>t.nt=e),password:pt(n,s),strength:r-1,pending:z})}function wt(t,e,n,s,r,i){const{st:c,ot:a,pending:f}=t;f.length&&(e=V(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%F)),u=0;l-F>=u;u+=F){const t=mt(st,dt(e,u,u+F));i&&a.update(t);const r=c.update(t);i||a.update(r),n.set(yt(st,r),u+s)}return t.pending=dt(e,u),n}async function ht(n,s,r,i){n.password=null;const c=await(async(t,e,n,s,r)=>{if(!ct)return L.importKey(e);try{return await et.importKey("raw",e,n,!1,r)}catch{return ct=!1,L.importKey(e)}})(0,r,q,0,J),a=await(async(t,e,n)=>{if(!at)return L.L(e,t.salt,G.iterations,n);try{return await et.deriveBits(t,e,n)}catch{return at=!1,L.L(e,t.salt,G.iterations,n)}})(e.assign({salt:i},G),c,8*(2*X[s]+2)),f=new o(a),l=mt(st,dt(f,0,X[s])),u=mt(st,dt(f,X[s],2*X[s])),w=dt(f,2*X[s]);return e.assign(n,{keys:{key:l,it:u,passwordVerification:w},st:new ot(new rt(l),t.from($)),ot:new it(u)}),w}function pt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function dt(t,e,n){return t.subarray(e,n)}function yt(t,e){return t.C(e)}function mt(t,e){return t.A(e)}class gt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=bt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(T);t=t.subarray(12)}s?e.error(new r(H)):e.enqueue(bt(n,t))}})}}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=Z(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(kt(n,e),0),r=12}else s=new o(t.length),r=0;s.set(kt(n,t),r),e.enqueue(s)}})}}function vt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,ct:new _(r[0]),ft:new _(r[2])}),s)for(let e=0;e<s.length;e++)zt(t,s[e]);else for(let e=0;e<n.length;e++)zt(t,n.charCodeAt(e))})(t,n,s)}function bt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=Ct(t)^e[s],zt(t,n[s]);return n}function kt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=Ct(t)^e[s],zt(t,e[s]);return n}function zt(t,e){let[,n]=t.keys;t.ct.append([e]);const r=~t.ct.get();n=It(s.imul(It(n+At(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function Ct(t){const e=2|t.keys[2];return At(s.imul(e,1^e)>>>8)}function At(t){return 255&t}function It(t){return 4294967295&t}const xt=new f;function Pt(t){return xt.get(t)}const Dt="deflate-raw";class Rt extends d{constructor(t,{chunkSize:e,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:i,zipCrypto:c,signed:a,level:f,deflate64:u,format:w}=t,h=this;let p,d,y,m=super.readable;const g=w&&Pt(w),S=a&&r&&!u&&!g&&(!o||c)&&!(!i||!s);o&&!c||!a||S||(p=new B,m=Kt(m,p)),r&&(g?m=Et(m,Vt(g.CompressionStream,w,{level:f,chunkSize:e})):S?(y=new Ut,m=Et(m,new s("gzip")),m=Kt(m,y)):m=Wt(m,i,{level:f,chunkSize:e},s,n)),o&&(c?m=Kt(m,new St(t)):(d=new lt(t),m=Kt(m,d))),Bt(h,m,()=>{let t;o&&!c&&(t=d.signature),o&&!c||!a||(t=S?y.signature:new l(p.value.buffer).getUint32(0)),h.signature=t})}}class Ut extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=V(n,t));const i=o-8,c=s.min(i,n.length);r.enqueue(V(n.subarray(0,c),t.subarray(0,i-c))),n=V(n.subarray(c),t.subarray(i-c))},flush(){const e=new l((s=n).buffer,s.byteOffset,s.byteLength);var s;t.signature=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Mt extends d{constructor(t,{chunkSize:e,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:i,signed:c,signature:a,compressed:f,useCompressionStream:u,deflate64:w,format:h}=t;let p,d,m=super.readable;if(i&&(o?m=Kt(m,new gt(t)):(d=new ft(t),m=Kt(m,d))),f){const t=h&&Pt(h);m=t?Et(m,Vt(t.DecompressionStream,h,{chunkSize:e})):Wt(m,u,{chunkSize:e,deflate64:w},s,n),m=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(m)}i&&!o||!c||(p=new B,m=Kt(m,p)),Bt(this,m,()=>{if((!i||o)&&c){const t=new l(p.value.buffer);if(a!=t.getUint32(0,!1))throw new r(j)}})}}const _t=new f;function Bt(t,n,s){n=Kt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Vt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Wt(t,e,n,s,r){const o=e&&s?s:r||s,i=n.deflate64?"deflate64-raw":Dt;let c;try{c=new o(i,n)}catch(t){if(!e||!r||o==r)throw t;c=new r(i,n)}return Et(t,c)}function Kt(t,e){return t.pipeThrough(e)}function Et(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const Lt="data",Ot="close",Tt="deflate";class jt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let i;o.startsWith(Tt)?i=Rt:o.startsWith("inflate")&&(i=Mt),s.outputSize=0;let c=0;const a=new i(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(c+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:c})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:c})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class Ht extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Zt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Zt=navigator.hardwareConcurrency)}catch{}const Ft=new f,Nt=new f;let qt,Gt,Jt,Qt,Xt,Yt=0;async function $t(t){let e,o;try{const{options:i,config:c}=t;if(i.format&&await(async(t,e)=>{!xt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");xt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(i.format,i.codecURI),c.CompressionStream=self.CompressionStream,c.DecompressionStream=self.DecompressionStream,i.compressed&&!i.format)if(i.useCompressionStream){if(!(t=>{if(!t)return!1;let e=_t.get(t);if(e===v){try{new t(Dt),e=!0}catch{e=!1}_t.set(t,e)}return e})(i.codecType.startsWith(Tt)?c.CompressionStream:c.DecompressionStream))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{i.useCompressionStream=!0}const a={highWaterMark:1},f=t.readable||new y({async pull(t){const e=new u(t=>Ft.set(Yt,t));te({type:"pull",messageId:Yt}),Yt=(Yt+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new u(t=>e=t);Nt.set(Yt,e),te({type:Lt,value:t,messageId:Yt}),Yt=(Yt+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new jt(i,c),qt=new AbortController;const{signal:l}=qt;await f.pipeThrough(e).pipeThrough(new Ht((t=>s.max(t.chunkSize,64))(c))).pipeTo(o,{signal:l,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{signature:w,inputSize:h,outputSize:p}=e;te({type:Ot,result:{signature:w,inputSize:h,outputSize:p}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ee(t)}}function te(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ee(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:i}=t;p({error:{message:e,stack:n,code:s,name:o,outputSize:i}})}function ne(t,e,n={}){const i="number"==typeof n.level?n.level:-1,c="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=Jt(c),this.in=Jt(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(c),t?(this.wt=Gt.deflate_process,this.ht=Gt.deflate_last_consumed,this.yt=Gt.deflate_end,this.gt=Gt.deflate_new(),n="gzip"===e?Gt.deflate_init_gzip(this.gt,i):"deflate-raw"===e?Gt.deflate_init_raw(this.gt,i):Gt.deflate_init(this.gt,i)):"deflate64-raw"===e?(this.wt=Gt.inflate9_process,this.ht=Gt.inflate9_last_consumed,this.yt=Gt.inflate9_end,this.gt=Gt.inflate9_new(),n=Gt.inflate9_init_raw(this.gt)):(this.wt=Gt.inflate_process,this.ht=Gt.inflate_last_consumed,this.yt=Gt.inflate_end,this.gt=Gt.inflate_new(),n="deflate-raw"===e?Gt.inflate_init_raw(this.gt):"gzip"===e?Gt.inflate_init_gzip(this.gt):Gt.inflate_init(this.gt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const i=e,a=new o(Xt.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<i.length;){const e=s.min(i.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&Qt&&(Qt(this.in),this.in=0),this.in=Jt(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(i.subarray(h,h+e),this.in);const o=f(this.gt,this.in,e,u,c,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.gt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(Xt.buffer),s=this.wt,i=this.lt,a=this.ut;for(;;){const o=s(this.gt,0,0,i,c,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(i,i+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.gt&&t.yt&&(e=t.yt(t.gt)),t.gt=0,t.in&&Qt&&Qt(t.in),t.in=0,t.lt&&Qt&&Qt(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&$t(t),e==Lt){const t=Ft.get(n);Ft.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Nt.get(n);Nt.delete(n),t()}e==Ot&&qt.abort()}catch(t){ee(t)}}),p({type:"ready"});class se{constructor(t="deflate",e){return ne(!0,t,e)}}class re{constructor(t="deflate",e){return ne(!1,t,e)}}se.St=!0,re.St=!0;let oe=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!oe){let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(Gt=t,({malloc:Jt,free:Qt,memory:Xt}=Gt),"function"!=typeof Jt||"function"!=typeof Qt||!Xt)throw Gt=Jt=Qt=Xt=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),oe=!0}})(t.wasmURI,t);return t.CompressionStreamZlib=se,t.DecompressionStreamZlib=re,e}catch{}}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
221
+ function t$1(t){const e='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,b="undefined",z="function",k=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,M,P,B,D,R]=C;class U{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=R[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class W extends d{constructor(){let t;const e=new U;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function _(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function V(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const K={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=K.l(n);return 32===s?t.concat(e):K.h(e,s,0|n,t.slice(0,t.length-1))},m(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+K.l(n)},S(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=K.v(e,t[n-1]&2147483648>>e-1,1)),t},v:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=K.l(r);return s.push(K.v(e+o&31,e+o>32?n:s.pop(),1)),s}},E={bytes:{C(t){const e=K.m(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},A(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(K.v(8*(3&n),s)),e}}},F=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.M=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.B=t.B.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.B=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=E.R.A(t));const n=e.B=K.concat(e.B,t),s=e.D,o=e.D=s+K.m(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.U(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}W(){const t=this;let e=t.B;const n=t.P;e=K.concat(e,[K.v(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.U(e.splice(0,16));return t.reset(),n}_(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}V(t,e){return e<<t|e>>>32-t}U(e){const n=this,r=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.V(5,c)+n._(t,i,a,f)+l+o[t]+n.M[s.floor(t/20)]|0;l=f,f=a,a=n.V(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},L={importKey:t=>new L.K(E.bytes.A(t)),F(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=K;for(e=E.bytes.A(e),u=1;(o||1)>p;u++){for(c=i=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},K:class{constructor(t){const e=this,n=e.L=F,s=[[],[]];e.O=[new n,new n];const r=e.O[0].blockSize/32;t.length>r&&(t=(new n).update(t).W());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.O[0].update(s[0]),e.O[1].update(s[1]),e.T=new n(e.O[0])}reset(){const t=this;t.T=new t.L(t.O[0]),t.j=!1}update(t){this.j=!0,this.T.update(t)}digest(){const t=this,e=t.T.W(),n=new t.L(t.O[1]).update(e).W();return t.reset(),n}encrypt(t){if(this.j)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},O=typeof h!=b&&typeof h.getRandomValues==z,T="Invalid password",j="Invalid signature",H="zipjs-abort-check-password";function Z(t){if(O)return h.getRandomValues(t);throw new r("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=e.assign({hash:{name:"HMAC"}},q),J=e.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],$=10,tt=[0,0,0,0],et=typeof h!=b,nt=et&&h.subtle,st=et&&typeof nt!=b,rt=E.bytes,ot=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.Z();const n=e.H[0][4],s=e.H[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.M=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}Z(){const t=this.H[0],e=this.H[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let u=16843009*f^65537*a^257*i^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.M[e],s=n.length/4-2,o=[0,0,0,0],c=this.H[e],i=c[0],a=c[1],f=c[2],l=c[3],u=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&g]^n[S],h=i[y>>>24]^a[m>>16&255]^f[g>>8&255]^l[255&d]^n[S+1],p=i[m>>>24]^a[g>>16&255]^f[d>>8&255]^l[255&y]^n[S+2],g=i[g>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},ct=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}$(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}et(t){0===(t[0]=this.$(t[0]))&&(t[1]=this.$(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=K.m(e);for(let r=0;s>r;r+=4){this.et(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return K.S(e,r)}},it=L.K;let at=et&&st&&typeof nt.importKey==z,ft=et&&st&&typeof nt.deriveBits==z;class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s}){super({start(){wt(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,nt:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await pt(t,e,n,yt(s,0,X[e])),c=yt(s,X[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(T)})(n,i,c,yt(t,0,X[i]+2)),t=yt(t,X[i]+2),s?e.error(new r(H)):a()):await f;const l=new o(t.length-$-(t.length-$)%N);e.enqueue(ht(n,t,l,0,$,!0))},async flush(t){const{st:e,ot:n,pending:s,ready:o}=this;if(n&&e){await o;const c=yt(s,0,s.length-$),i=yt(s,s.length-$);let a=k;if(c.length){const t=gt(rt,c);n.update(t);const s=e.update(t);a=mt(rt,s)}const f=yt(mt(rt,n.digest()),0,$);let l=s.length<$?1:0;for(let t=0;$>t;t++)l|=f[t]^i[t];if(l)throw new r(j);t.enqueue(a)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){let s;super({start(){wt(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,nt:c,ready:i}=n;let a=k;s?(a=await(async(t,e,n)=>{const s=Z(new o(X[e]));return _(s,await pt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),e.enqueue(ht(n,t,f,a.length,0))},async flush(t){const{st:e,ot:n,pending:r,ready:o}=this;if(n&&e){await o;let c=k;if(r.length){const t=e.update(gt(rt,r));n.update(t),c=mt(rt,t)}s.signature=mt(rt,n.digest()).slice(0,$),t.enqueue(_(c,s.signature))}}}),s=this}}function wt(t,n,s,r){e.assign(t,{ready:new u(e=>t.nt=e),password:dt(n,s),strength:r-1,pending:k})}function ht(t,e,n,s,r,c){const{st:i,ot:a,pending:f}=t;f.length&&(e=_(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%N)),u=0;l-N>=u;u+=N){const t=gt(rt,yt(e,u,u+N));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(mt(rt,r),u+s)}return t.pending=yt(e,u),n}async function pt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!at)return L.importKey(e);try{return await nt.importKey("raw",e,n,!1,r)}catch{return at=!1,L.importKey(e)}})(0,r,G,0,Q),a=await(async(t,e,n)=>{if(!ft)return L.F(e,t.salt,J.iterations,n);try{return await nt.deriveBits(t,e,n)}catch{return ft=!1,L.F(e,t.salt,J.iterations,n)}})(e.assign({salt:c},J),i,8*(2*Y[s]+2)),f=new o(a),l=gt(rt,yt(f,0,Y[s])),u=gt(rt,yt(f,Y[s],2*Y[s])),w=yt(f,2*Y[s]);return e.assign(n,{keys:{key:l,ct:u,passwordVerification:w},st:new ct(new ot(l),t.from(tt)),ot:new it(u)}),w}function dt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function yt(t,e,n){return t.subarray(e,n)}function mt(t,e){return t.C(e)}function gt(t,e){return t.A(e)}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(T);t=t.subarray(12)}s?e.error(new r(H)):e.enqueue(zt(n,t))}})}}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=Z(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(kt(n,e),0),r=12}else s=new o(t.length),r=0;s.set(kt(n,t),r),e.enqueue(s)}})}}function bt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,it:new U(r[0]),ft:new U(r[2])}),s)for(let e=0;e<s.length;e++)Ct(t,s[e]);else for(let e=0;e<n.length;e++)Ct(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],Ct(t,n[s]);return n}function kt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],Ct(t,e[s]);return n}function Ct(t,e){let[,n]=t.keys;t.it.append([e]);const r=~t.it.get();n=xt(s.imul(xt(n+It(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function At(t){const e=2|t.keys[2];return It(s.imul(e,1^e)>>>8)}function It(t){return 255&t}function xt(t){return 4294967295&t}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="deflate-raw",Dt="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:e,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,signed:a,level:f,deflate64:u,format:w,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=w&&Pt(w),v=a&&r&&!u&&!S&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new W,g=Ot(g,d)),r)if(S)g=Tt(g,Ft(S.CompressionStream,w,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Wt,g=Tt(g,new s(Dt)),g=Ot(g,m);else try{g=Lt(g,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Dt)}catch{throw t}g=Tt(g,e),g=Ot(g,new Wt)}o&&(i?g=Ot(g,new vt(t)):(y=new ut(t),g=Ot(g,y))),Et(p,g,()=>{let t;o&&!i&&(t=y.signature),o&&!i||!a||(t=v?m.signature:new l(d.value.buffer).getUint32(0)),p.signature=t})}}class Wt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=_(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(_(n.subarray(0,i),t.subarray(0,c-i))),n=_(n.subarray(i),t.subarray(c-i))},flush(){const e=V(n);t.signature=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class _t extends d{constructor(t,e){super({start(t){const e=new o(10);e.set(Rt),t.enqueue(e)},transform(t,e){e.enqueue(t)},flush(n){const s=new o(8),r=V(s);r.setUint32(0,t,!0),r.setUint32(4,e,!0),n.enqueue(s)}})}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:c,signed:i,signature:a,compressed:f,useCompressionStream:u,deflate64:w,format:h,compressionMethod:p,rawBitFlag:d,outputSize:m}=t;let g,S,b=super.readable;if(c&&(o?b=Ot(b,new St(t)):(S=new lt(t),b=Ot(b,S))),f){const t=h&&Pt(h);if(t)b=Tt(b,Ft(t.DecompressionStream,h,{chunkSize:e,compressionMethod:p,rawBitFlag:d,uncompressedSize:m}));else try{b=Lt(b,u,{chunkSize:e,deflate64:w},s,n)}catch(t){if(w||c&&!o||a===v||m===v)throw t;let e;try{e=new s(Dt)}catch{throw t}b=Ot(b,new _t(a,m)),b=Tt(b,e)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(b)}c&&!o||!i||(g=new W,b=Ot(b,g)),Et(this,b,()=>{if((!c||o)&&i){const t=new l(g.value.buffer);if(a!=t.getUint32(0,!1))throw new r(j)}})}}const Kt=new f;function Et(t,n,s){n=Ot(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Ft(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Lt(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Bt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Tt(t,i)}function Ot(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Tt(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const jt="data",Ht="close",Zt="deflate";class Nt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Zt)?c=Ut:o.startsWith("inflate")&&(c=Vt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class qt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Gt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Gt=navigator.hardwareConcurrency)}catch{}const Jt=new f,Qt=new f;let Xt,Yt,$t,te,ee,ne,se=0;async function re(t){let e,o;try{const{options:c,config:i}=t;if(c.format&&await(async(t,e)=>{!Mt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=z&&typeof s!=z)throw new r("Invalid codec module");Mt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI),i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!(t=>{if(!t)return!1;let e=Kt.get(t);if(e===v){try{new t(Bt),e=!0}catch{e=!1}Kt.set(t,e)}return e})(c.codecType.startsWith(Zt)?i.CompressionStream:i.DecompressionStream))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}const a={highWaterMark:1},f=t.readable||new y({async pull(t){const e=new u(t=>Jt.set(se,t));oe({type:"pull",messageId:se}),se=(se+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new u(t=>e=t);Qt.set(se,e),oe({type:jt,value:t,messageId:se}),se=(se+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Nt(c,i),Xt=new AbortController;const{signal:l}=Xt;await f.pipeThrough(e).pipeThrough(new qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:l,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{signature:w,inputSize:h,outputSize:p}=e;oe({type:Ht,result:{signature:w,inputSize:h,outputSize:p}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ce(t)}}function oe(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ce(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i}=t,a={message:e,stack:n,code:s,name:o,outputSize:c};i&&(a.cause={name:i.name,message:i.message}),p({error:a})}function ie(t,e,n={}){if(!Yt){const t=new r("WASM module not loaded");throw t.cause=ne,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=$t(i),this.in=$t(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(i),t?(this.wt=Yt.deflate_process,this.ht=Yt.deflate_last_consumed,this.yt=Yt.deflate_end,this.gt=Yt.deflate_new(),n="gzip"===e?Yt.deflate_init_gzip(this.gt,c):"deflate-raw"===e?Yt.deflate_init_raw(this.gt,c):Yt.deflate_init(this.gt,c)):"deflate64-raw"===e?(this.wt=Yt.inflate9_process,this.ht=Yt.inflate9_last_consumed,this.yt=Yt.inflate9_end,this.gt=Yt.inflate9_new(),n=Yt.inflate9_init_raw(this.gt)):(this.wt=Yt.inflate_process,this.ht=Yt.inflate_last_consumed,this.yt=Yt.inflate_end,this.gt=Yt.inflate_new(),n="deflate-raw"===e?Yt.inflate_init_raw(this.gt):"gzip"===e?Yt.inflate_init_gzip(this.gt):Yt.inflate_init(this.gt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(ee.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&te&&(te(this.in),this.in=0),this.in=$t(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.gt,this.in,e,u,i,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.gt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(ee.buffer),s=this.wt,c=this.lt,a=this.ut;for(;;){const o=s(this.gt,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.gt&&t.yt&&(e=t.yt(t.gt)),t.gt=0,t.in&&te&&te(t.in),t.in=0,t.lt&&te&&te(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&re(t),e==jt){const t=Jt.get(n);Jt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Qt.get(n);Qt.delete(n),t()}e==Ht&&Xt.abort()}catch(t){ce(t)}}),p({type:"ready"});class ae{constructor(t="deflate",e){return ie(!0,t,e)}}class fe{constructor(t="deflate",e){return ie(!1,t,e)}}ae.St=!0,fe.St=!0;let le=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!le)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(Yt=t,({malloc:$t,free:te,memory:ee}=Yt),"function"!=typeof $t||"function"!=typeof te||!ee)throw Yt=$t=te=ee=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),le=!0}catch(t){throw(t=>{ne=t})(t),t}})(t.wasmURI,t);return t.CompressionStreamZlib=ae,t.DecompressionStreamZlib=fe,e}catch{}}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
222
222
 
223
223
  /*
224
224
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -313,7 +313,7 @@ function setCodecStreams(format, streams) {
313
313
 
314
314
  async function ensureCodecStreams(format, codecURI) {
315
315
  if (!codecStreams.has(format) && codecURI) {
316
- setCodecStreams(format, await import(codecURI));
316
+ setCodecStreams(format, await import(/* webpackIgnore: true */ /* @vite-ignore */ codecURI));
317
317
  }
318
318
  }
319
319
 
@@ -1822,6 +1822,73 @@ function getInt32(number) {
1822
1822
  return number & 0xFFFFFFFF;
1823
1823
  }
1824
1824
 
1825
+ /*
1826
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
1827
+
1828
+ Redistribution and use in source and binary forms, with or without
1829
+ modification, are permitted provided that the following conditions are met:
1830
+
1831
+ 1. Redistributions of source code must retain the above copyright notice,
1832
+ this list of conditions and the following disclaimer.
1833
+
1834
+ 2. Redistributions in binary form must reproduce the above copyright
1835
+ notice, this list of conditions and the following disclaimer in
1836
+ the documentation and/or other materials provided with the distribution.
1837
+
1838
+ 3. The names of the authors may not be used to endorse or promote products
1839
+ derived from this software without specific prior written permission.
1840
+
1841
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
1842
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1843
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
1844
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
1845
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1846
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
1847
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1848
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1849
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1850
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1851
+ */
1852
+
1853
+
1854
+ function toCompatibleReadable(readable) {
1855
+ if (readable instanceof ReadableStream) {
1856
+ return readable;
1857
+ }
1858
+ const reader = readable.getReader();
1859
+ return new ReadableStream({
1860
+ async pull(controller) {
1861
+ const { value, done } = await reader.read();
1862
+ if (done) {
1863
+ controller.close();
1864
+ } else {
1865
+ controller.enqueue(value);
1866
+ }
1867
+ },
1868
+ cancel(reason) {
1869
+ return reader.cancel(reason);
1870
+ }
1871
+ });
1872
+ }
1873
+
1874
+ function toCompatibleWritable(writable) {
1875
+ if (writable instanceof WritableStream) {
1876
+ return writable;
1877
+ }
1878
+ const writer = writable.getWriter();
1879
+ return new WritableStream({
1880
+ write(chunk) {
1881
+ return writer.write(chunk);
1882
+ },
1883
+ close() {
1884
+ return writer.close();
1885
+ },
1886
+ abort(reason) {
1887
+ return writer.abort(reason);
1888
+ }
1889
+ });
1890
+ }
1891
+
1825
1892
  /*
1826
1893
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
1827
1894
 
@@ -1859,12 +1926,13 @@ const FORMAT_DEFLATE64_RAW = "deflate64-raw";
1859
1926
  const FORMAT_GZIP = "gzip";
1860
1927
  const GZIP_HEADER_LENGTH = 10;
1861
1928
  const GZIP_TRAILER_LENGTH = 8;
1929
+ const GZIP_HEADER_BYTES = [0x1f, 0x8b, 0x08];
1862
1930
 
1863
1931
  class DeflateStream extends TransformStream {
1864
1932
 
1865
1933
  constructor(options, { chunkSize, CompressionStreamZlib, CompressionStream }) {
1866
1934
  super({});
1867
- const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level, deflate64, format } = options;
1935
+ const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level, deflate64, format, compressionMethod } = options;
1868
1936
  const stream = this;
1869
1937
  let crc32Stream, encryptionStream, gzipCrc32Stream;
1870
1938
  let readable = super.readable;
@@ -1877,13 +1945,24 @@ class DeflateStream extends TransformStream {
1877
1945
  }
1878
1946
  if (compressed) {
1879
1947
  if (codecStreams) {
1880
- readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize }));
1948
+ readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod }));
1881
1949
  } else if (useGzipCrc32) {
1882
1950
  gzipCrc32Stream = new GzipToRawDeflateStream();
1883
1951
  readable = pipeThroughBackpressured(readable, new CompressionStream(FORMAT_GZIP));
1884
1952
  readable = pipeThrough(readable, gzipCrc32Stream);
1885
1953
  } else {
1886
- readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamZlib);
1954
+ try {
1955
+ readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamZlib);
1956
+ } catch (error) {
1957
+ let gzipStream;
1958
+ try {
1959
+ gzipStream = new CompressionStream(FORMAT_GZIP);
1960
+ } catch {
1961
+ throw error;
1962
+ }
1963
+ readable = pipeThroughBackpressured(readable, gzipStream);
1964
+ readable = pipeThrough(readable, new GzipToRawDeflateStream());
1965
+ }
1887
1966
  }
1888
1967
  }
1889
1968
  if (encrypted) {
@@ -1948,11 +2027,34 @@ class GzipToRawDeflateStream extends TransformStream {
1948
2027
  }
1949
2028
  }
1950
2029
 
2030
+ class RawDeflateToGzipStream extends TransformStream {
2031
+
2032
+ constructor(signature, uncompressedSize) {
2033
+ super({
2034
+ start(controller) {
2035
+ const header = new Uint8Array(GZIP_HEADER_LENGTH);
2036
+ header.set(GZIP_HEADER_BYTES);
2037
+ controller.enqueue(header);
2038
+ },
2039
+ transform(chunk, controller) {
2040
+ controller.enqueue(chunk);
2041
+ },
2042
+ flush(controller) {
2043
+ const trailer = new Uint8Array(GZIP_TRAILER_LENGTH);
2044
+ const dataView = getDataView(trailer);
2045
+ dataView.setUint32(0, signature, true);
2046
+ dataView.setUint32(4, uncompressedSize, true);
2047
+ controller.enqueue(trailer);
2048
+ }
2049
+ });
2050
+ }
2051
+ }
2052
+
1951
2053
  class InflateStream extends TransformStream {
1952
2054
 
1953
2055
  constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
1954
2056
  super({});
1955
- const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64, format } = options;
2057
+ const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
1956
2058
  let crc32Stream, decryptionStream;
1957
2059
  let readable = super.readable;
1958
2060
  if (encrypted) {
@@ -1966,9 +2068,23 @@ class InflateStream extends TransformStream {
1966
2068
  if (compressed) {
1967
2069
  const codecStreams = format && getCodecStreams(format);
1968
2070
  if (codecStreams) {
1969
- readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize }));
2071
+ readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }));
1970
2072
  } else {
1971
- readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib);
2073
+ try {
2074
+ readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib);
2075
+ } catch (error) {
2076
+ if (deflate64 || (encrypted && !zipCrypto) || signature === UNDEFINED_VALUE || outputSize === UNDEFINED_VALUE) {
2077
+ throw error;
2078
+ }
2079
+ let gzipStream;
2080
+ try {
2081
+ gzipStream = new DecompressionStream(FORMAT_GZIP);
2082
+ } catch {
2083
+ throw error;
2084
+ }
2085
+ readable = pipeThrough(readable, new RawDeflateToGzipStream(signature, outputSize));
2086
+ readable = pipeThroughBackpressured(readable, gzipStream);
2087
+ }
1972
2088
  }
1973
2089
  readable = mapInflateStreamError(readable);
1974
2090
  }
@@ -2041,7 +2157,7 @@ function pipeThroughCompressionStream(readable, useCompressionStream, options, C
2041
2157
  }
2042
2158
 
2043
2159
  function pipeThrough(readable, transformStream) {
2044
- return readable.pipeThrough(transformStream);
2160
+ return toCompatibleReadable(readable).pipeThrough(transformStream);
2045
2161
  }
2046
2162
 
2047
2163
  function pipeThroughBackpressured(readable, transformStream) {
@@ -2757,9 +2873,12 @@ async function onMessage({ data }, workerData) {
2757
2873
  const stale = () => workerData.generation != generation;
2758
2874
  try {
2759
2875
  if (error) {
2760
- const { message, stack, code, name, outputSize } = error;
2876
+ const { message, stack, code, name, outputSize, cause } = error;
2761
2877
  const responseError = new Error(message);
2762
2878
  Object.assign(responseError, { stack, code, name, outputSize });
2879
+ if (cause) {
2880
+ responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
2881
+ }
2763
2882
  close(responseError);
2764
2883
  } else {
2765
2884
  if (type == MESSAGE_PULL) {
@@ -3186,10 +3305,10 @@ class BlobReader extends Reader {
3186
3305
  const { blob, size } = reader;
3187
3306
  const { offset = 0, size: readSize = size - offset } = options || {};
3188
3307
  if (!offset && readSize >= size) {
3189
- return blob.stream();
3308
+ return toCompatibleReadable(blob.stream());
3190
3309
  }
3191
3310
  if (blobSliceReliable) {
3192
- return blob.slice(offset, offset + readSize).stream();
3311
+ return toCompatibleReadable(blob.slice(offset, offset + readSize).stream());
3193
3312
  }
3194
3313
  return super.createReadable(options);
3195
3314
  }
@@ -3208,22 +3327,37 @@ class BlobReader extends Reader {
3208
3327
  }
3209
3328
  }
3210
3329
 
3330
+ function responseSupportsGlobalReadable() {
3331
+ return typeof Blob.prototype.stream != FUNCTION_TYPE || new Blob([]).stream() instanceof ReadableStream;
3332
+ }
3333
+
3211
3334
  class BlobWriter extends Stream {
3212
3335
 
3213
3336
  constructor(contentType) {
3214
3337
  super();
3215
3338
  const writer = this;
3216
3339
  const transformStream = new TransformStream();
3217
- const headers = [];
3218
- if (contentType) {
3219
- headers.push([HTTP_HEADER_CONTENT_TYPE, contentType]);
3220
- }
3221
3340
  Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
3222
3341
  get() {
3223
3342
  return transformStream.writable;
3224
3343
  }
3225
3344
  });
3226
- writer.blob = new Response(transformStream.readable, { headers }).blob();
3345
+ if (responseSupportsGlobalReadable()) {
3346
+ const headers = [];
3347
+ if (contentType) {
3348
+ headers.push([HTTP_HEADER_CONTENT_TYPE, contentType]);
3349
+ }
3350
+ writer.blob = new Response(transformStream.readable, { headers }).blob();
3351
+ } else {
3352
+ const chunks = [];
3353
+ writer.blob = transformStream.readable
3354
+ .pipeTo(new WritableStream({
3355
+ write(chunk) {
3356
+ chunks.push(chunk);
3357
+ }
3358
+ }))
3359
+ .then(() => new Blob(chunks, { type: contentType }));
3360
+ }
3227
3361
  writer.blob.catch(() => { });
3228
3362
  }
3229
3363
 
@@ -3875,9 +4009,9 @@ class GenericReader {
3875
4009
  if (Array.isArray(reader)) {
3876
4010
  reader = new SplitDataReader(reader);
3877
4011
  }
3878
- if (reader instanceof ReadableStream) {
4012
+ if (reader instanceof ReadableStream || typeof reader.getReader == FUNCTION_TYPE) {
3879
4013
  reader = {
3880
- readable: reader
4014
+ readable: toCompatibleReadable(reader)
3881
4015
  };
3882
4016
  }
3883
4017
  return reader;
@@ -3890,9 +4024,9 @@ class GenericWriter {
3890
4024
  if (writer.writable === UNDEFINED_VALUE && typeof writer.next == FUNCTION_TYPE) {
3891
4025
  writer = new SplitDataWriter(writer);
3892
4026
  }
3893
- if (writer instanceof WritableStream) {
4027
+ if (writer instanceof WritableStream || typeof writer.getWriter == FUNCTION_TYPE) {
3894
4028
  writer = {
3895
- writable: writer
4029
+ writable: toCompatibleWritable(writer)
3896
4030
  };
3897
4031
  }
3898
4032
  if (writer.size === UNDEFINED_VALUE) {
@@ -4639,6 +4773,7 @@ let ZipEntry$1 = class ZipEntry {
4639
4773
  compressionMethod,
4640
4774
  config,
4641
4775
  bitFlag,
4776
+ rawBitFlag,
4642
4777
  signature,
4643
4778
  rawLastModDate,
4644
4779
  uncompressedSize,
@@ -4661,10 +4796,6 @@ let ZipEntry$1 = class ZipEntry {
4661
4796
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
4662
4797
  }
4663
4798
  }
4664
- const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
4665
- if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec) && !passThrough) {
4666
- throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
4667
- }
4668
4799
  if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
4669
4800
  throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
4670
4801
  }
@@ -4700,10 +4831,14 @@ let ZipEntry$1 = class ZipEntry {
4700
4831
  if (!passThrough) {
4701
4832
  fileEntry.zipCrypto = zipCrypto;
4702
4833
  }
4834
+ if (encrypted && (localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
4835
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
4836
+ }
4837
+ const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
4838
+ if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThrough) {
4839
+ throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
4840
+ }
4703
4841
  if (encrypted) {
4704
- if ((localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
4705
- throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
4706
- }
4707
4842
  if (!zipCrypto && (extraFieldAES.strength < 1 || extraFieldAES.strength > 3)) {
4708
4843
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
4709
4844
  } else if (!password && !rawPassword) {
@@ -4712,7 +4847,7 @@ let ZipEntry$1 = class ZipEntry {
4712
4847
  }
4713
4848
  const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
4714
4849
  const size = compressedSize;
4715
- const readable = reader.createReadable({ offset: dataOffset, size });
4850
+ const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
4716
4851
  const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
4717
4852
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
4718
4853
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
@@ -4745,6 +4880,8 @@ let ZipEntry$1 = class ZipEntry {
4745
4880
  deflate64,
4746
4881
  format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
4747
4882
  codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
4883
+ compressionMethod,
4884
+ rawBitFlag,
4748
4885
  checkPasswordOnly
4749
4886
  },
4750
4887
  config,
@@ -6279,7 +6416,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
6279
6416
  }
6280
6417
  const { writable } = writer;
6281
6418
  if (reader) {
6282
- const readable = reader.createReadable ? reader.createReadable() : reader.readable;
6419
+ const readable = toCompatibleReadable(reader.createReadable ? reader.createReadable() : reader.readable);
6283
6420
  const size = reader.size;
6284
6421
  const workerOptions = {
6285
6422
  options: {
@@ -6297,7 +6434,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
6297
6434
  useCompressionStream,
6298
6435
  transferStreams,
6299
6436
  format,
6300
- codecURI
6437
+ codecURI,
6438
+ compressionMethod
6301
6439
  },
6302
6440
  config,
6303
6441
  streamOptions: { signal, size, onstart, onprogress, onend }
@@ -7639,7 +7777,7 @@ const n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,1
7639
7777
 
7640
7778
  /* global TransformStream */
7641
7779
 
7642
- let wasm, malloc, free, memory;
7780
+ let wasm, malloc, free, memory, initError;
7643
7781
 
7644
7782
  function setWasmExports(wasmAPI) {
7645
7783
  wasm = wasmAPI;
@@ -7650,7 +7788,20 @@ function setWasmExports(wasmAPI) {
7650
7788
  }
7651
7789
  }
7652
7790
 
7791
+ function setInitError(error) {
7792
+ initError = error;
7793
+ }
7794
+
7795
+ function resetWasmExports() {
7796
+ wasm = malloc = free = memory = initError = null;
7797
+ }
7798
+
7653
7799
  function _make(isCompress, type, options = {}) {
7800
+ if (!wasm) {
7801
+ const error = new Error("WASM module not loaded");
7802
+ error.cause = initError;
7803
+ throw error;
7804
+ }
7654
7805
  const level = (typeof options.level === "number") ? options.level : -1;
7655
7806
  const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
7656
7807
  const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
@@ -7861,30 +8012,40 @@ let initializedModule = false;
7861
8012
 
7862
8013
  async function initModule(wasmURI, { baseURI }) {
7863
8014
  if (!initializedModule) {
7864
- let arrayBuffer, uri;
7865
8015
  try {
7866
- try {
7867
- uri = new URL(wasmURI, baseURI);
7868
- } catch {
7869
- // ignored
7870
- }
7871
- const response = await fetch(uri);
7872
- arrayBuffer = await response.arrayBuffer();
8016
+ await instantiateModule(wasmURI, baseURI);
8017
+ initializedModule = true;
7873
8018
  } catch (error) {
7874
- if (wasmURI.startsWith("data:application/wasm;base64,")) {
7875
- arrayBuffer = arrayBufferFromDataURI(wasmURI);
7876
- } else {
7877
- throw error;
7878
- }
8019
+ setInitError(error);
8020
+ throw error;
7879
8021
  }
7880
- const wasmInstance = await WebAssembly.instantiate(arrayBuffer);
7881
- setWasmExports(wasmInstance.instance.exports);
7882
- initializedModule = true;
7883
8022
  }
7884
8023
  }
7885
8024
 
8025
+ async function instantiateModule(wasmURI, baseURI) {
8026
+ let arrayBuffer, uri;
8027
+ try {
8028
+ try {
8029
+ uri = new URL(wasmURI, baseURI);
8030
+ } catch {
8031
+ // ignored
8032
+ }
8033
+ const response = await fetch(uri);
8034
+ arrayBuffer = await response.arrayBuffer();
8035
+ } catch (error) {
8036
+ if (wasmURI.startsWith("data:application/wasm;base64,")) {
8037
+ arrayBuffer = arrayBufferFromDataURI(wasmURI);
8038
+ } else {
8039
+ throw error;
8040
+ }
8041
+ }
8042
+ const wasmInstance = await WebAssembly.instantiate(arrayBuffer);
8043
+ setWasmExports(wasmInstance.instance.exports);
8044
+ }
8045
+
7886
8046
  function resetWasmModule() {
7887
8047
  initializedModule = false;
8048
+ resetWasmExports();
7888
8049
  }
7889
8050
 
7890
8051
  function arrayBufferFromDataURI(dataURI) {
@@ -7929,7 +8090,6 @@ function arrayBufferFromDataURI(dataURI) {
7929
8090
 
7930
8091
  let modulePromise;
7931
8092
 
7932
- U(setDefaultConfiguration);
7933
8093
  configureWorker({
7934
8094
  initModule: config => {
7935
8095
  if (!modulePromise) {
@@ -7938,8 +8098,10 @@ configureWorker({
7938
8098
  if (typeof wasmURI == FUNCTION_TYPE) {
7939
8099
  wasmURI = wasmURI();
7940
8100
  }
7941
- modulePromise = initModule(wasmURI, config);
7942
-
8101
+ modulePromise = initModule(wasmURI, config).catch(error => {
8102
+ modulePromise = null;
8103
+ throw error;
8104
+ });
7943
8105
  }
7944
8106
  return modulePromise;
7945
8107
  }
@@ -7955,6 +8117,37 @@ function terminateWorkersAndModule() {
7955
8117
  resetWasmModule();
7956
8118
  }
7957
8119
 
8120
+ /*
8121
+ Copyright (c) 2025 Gildas Lormeau. All rights reserved.
8122
+
8123
+ Redistribution and use in source and binary forms, with or without
8124
+ modification, are permitted provided that the following conditions are met:
8125
+
8126
+ 1. Redistributions of source code must retain the above copyright notice,
8127
+ this list of conditions and the following disclaimer.
8128
+
8129
+ 2. Redistributions in binary form must reproduce the above copyright
8130
+ notice, this list of conditions and the following disclaimer in
8131
+ the documentation and/or other materials provided with the distribution.
8132
+
8133
+ 3. The names of the authors may not be used to endorse or promote products
8134
+ derived from this software without specific prior written permission.
8135
+
8136
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
8137
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
8138
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
8139
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
8140
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8141
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
8142
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
8143
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
8144
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
8145
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8146
+ */
8147
+
8148
+
8149
+ U(setDefaultConfiguration);
8150
+
7958
8151
  /*
7959
8152
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
7960
8153
 
package/index.d.cts CHANGED
@@ -242,11 +242,20 @@ export interface CodecDefinition {
242
242
  */
243
243
  codecURI?: string;
244
244
  /**
245
- * The stream implementation used to compress data, constructed with `(format, { level, chunkSize })`.
245
+ * The stream implementation used to compress data, constructed with
246
+ * `(format, { level, chunkSize, compressionMethod })`.
246
247
  */
247
248
  CompressionStream?: typeof TransformStreamLike;
248
249
  /**
249
- * The stream implementation used to decompress data, constructed with `(format, { chunkSize })`.
250
+ * The stream implementation used to decompress data, constructed with
251
+ * `(format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize })`.
252
+ *
253
+ * `compressionMethod` allows codecs registered for multiple methods with the same format to
254
+ * distinguish them (e.g. Reduce, methods 2 to 5). `rawBitFlag` exposes the general purpose bit
255
+ * flag of the entry, which some methods need to decode the data (e.g. the dictionary size and
256
+ * number of trees of Implode, or the end-of-stream marker presence of LZMA). `uncompressedSize`
257
+ * allows size-driven decoders (e.g. Shrink, Reduce, Implode, LZMA without end-of-stream marker)
258
+ * to stop at the exact output size instead of decoding trailing padding bits.
250
259
  */
251
260
  DecompressionStream?: typeof TransformStreamLike;
252
261
  /**
package/index.d.ts CHANGED
@@ -242,11 +242,20 @@ export interface CodecDefinition {
242
242
  */
243
243
  codecURI?: string;
244
244
  /**
245
- * The stream implementation used to compress data, constructed with `(format, { level, chunkSize })`.
245
+ * The stream implementation used to compress data, constructed with
246
+ * `(format, { level, chunkSize, compressionMethod })`.
246
247
  */
247
248
  CompressionStream?: typeof TransformStreamLike;
248
249
  /**
249
- * The stream implementation used to decompress data, constructed with `(format, { chunkSize })`.
250
+ * The stream implementation used to decompress data, constructed with
251
+ * `(format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize })`.
252
+ *
253
+ * `compressionMethod` allows codecs registered for multiple methods with the same format to
254
+ * distinguish them (e.g. Reduce, methods 2 to 5). `rawBitFlag` exposes the general purpose bit
255
+ * flag of the entry, which some methods need to decode the data (e.g. the dictionary size and
256
+ * number of trees of Implode, or the end-of-stream marker presence of LZMA). `uncompressedSize`
257
+ * allows size-driven decoders (e.g. Shrink, Reduce, Implode, LZMA without end-of-stream marker)
258
+ * to stop at the exact output size instead of decoding trailing padding bits.
250
259
  */
251
260
  DecompressionStream?: typeof TransformStreamLike;
252
261
  /**