@zip.js/zip.js 2.8.48 → 2.8.50
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 +351 -205
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +357 -205
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +438 -216
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +213 -435
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +438 -216
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +447 -219
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +445 -217
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +359 -207
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +360 -208
- 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 +358 -206
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +446 -218
- package/index-native.min.js +1 -1
- package/index.cjs +444 -216
- package/index.d.cts +124 -2
- package/index.d.ts +124 -2
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +1 -1
- package/lib/core/codec-registry.js +2 -2
- package/lib/core/codec-worker-web.js +436 -0
- package/lib/core/codec-worker.js +23 -388
- package/lib/core/constants.js +5 -1
- package/lib/core/io.js +2 -1
- package/lib/core/options.js +8 -0
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/web-worker-base.js +10 -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 +88 -12
- package/lib/core/zip-reader.js +90 -16
- package/lib/core/zip-writer.js +36 -13
- package/lib/zip-core-reader.js +6 -0
- package/lib/zip-core-writer.js +4 -0
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
package/index.cjs
CHANGED
|
@@ -111,6 +111,8 @@ const INFINITY_VALUE = Infinity;
|
|
|
111
111
|
const UNDEFINED_TYPE = "undefined";
|
|
112
112
|
const FUNCTION_TYPE = "function";
|
|
113
113
|
const OBJECT_TYPE = "object";
|
|
114
|
+
const STRING_TYPE = "string";
|
|
115
|
+
const NUMBER_TYPE = "number";
|
|
114
116
|
|
|
115
117
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
116
118
|
|
|
@@ -239,10 +241,10 @@ function resetConfiguration() {
|
|
|
239
241
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
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 e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(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:w,TextEncoder:u,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=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,M,P,D,B,F]=C;class R{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=F[255&t]^B[t>>>8&255]^D[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 U extends d{constructor(){let t;const e=new R;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 W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(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]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(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=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(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},C(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(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.A=[1732584193,4023233417,2562383102,271733878,3285377520],e.I=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.A.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.B.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(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.F(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(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.F(e.splice(0,16));return t.reset(),n}U(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}F(e){const n=this,r=n.M,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.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.I[s.floor(t/20)]|0;l=f,f=a,a=n.W(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}},E={importKey:t=>new E._(V.bytes.C(t)),T(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,w;const u=new ArrayBuffer(o),h=new l(u);let p=0;const d=T;for(e=V.bytes.C(e),w=1;(o||1)>p;w++){for(c=i=t.encrypt(d.concat(e,[w])),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 u.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[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.I=[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)}H(){const t=this.j[0],e=this.j[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 w=16843009*f^65537*a^257*i^16843008*l,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>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.I[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],w=c[4];let u,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)u=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&S]^n[g++],u=d,d=y,y=m,m=S,S=u;return o}},it=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)}Z(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}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(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 T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,pending:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let w=s.length<tt?1:0;for(let t=0;tt>t;t++)w|=l[t]^a[t];if(w&&c)throw new r(H);t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,pending:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new w(e=>t.et=e),password:yt(n,s),strength:r-1,pending:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,pending:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let w;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%G)),w=0;l-G>=w;w+=G){const t=gt(ot,mt(e,w,w+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),w+s)}return t.pending=mt(e,w),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),w=gt(ot,mt(f,$[s],2*$[s])),u=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ot:w,passwordVerification:u},nt:new it(new ct(l),t.from(et)),st:new at(w)}),u}function yt(t,e){return e===v?(t=>{if(typeof u==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 u).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(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(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(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=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(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(r[0]),it:new R(r[2])}),s)for(let e=0;e<s.length;e++)At(t,s[e]);else for(let e=0;e<n.length;e++)At(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]=It(t)^e[s],At(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,e[s]);return n}function At(t,e){let[,n]=t.keys;t.ct.append([e]);const r=~t.ct.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.it.append([n>>>24]);const o=~t.it.get();t.keys=[r,n,o]}function It(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}const Pt=new f;function Dt(t){return Pt.get(t)}const Bt="Invalid uncompressed size",Ft=j,Rt="deflate-raw",Ut="gzip",Wt=[31,139,8];class _t extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:w,format:u,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=u&&Dt(u),v=a&&r&&!w&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=jt(S,d)),r)if(g)S=Ht(S,Lt(g.CompressionStream,u,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Tt,S=Ht(S,new s(Ut)),S=jt(S,m);else try{S=Ot(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Ut)}catch{throw t}S=Ht(S,e),S=jt(S,new Tt)}o&&(i?S=jt(S,new bt(t)):(y=new ut(t),S=jt(S,y))),Et(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Tt 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=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:u,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=jt(C,new vt(t)):(z=new wt(t),C=jt(C,z))),u){const t=m&&Dt(m);if(t)C=Ht(C,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Ot(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Ut)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const u=new w((t,e)=>{i=t,a=e});u.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(Wt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await u}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=jt(t,h),jt(t=Ht(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(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)})})(C)}a&&(k=new U,C=jt(C,k)),Et(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Ft)}})}}const Kt=new f;function Et(t,n,s){n=jt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Ot(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Rt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Ht(t,i)}function jt(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 Ht(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 Nt="data",qt="close",Gt="deflate";class Jt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Gt)?c=_t: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})}}),w=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(Bt)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(w)})}}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 Xt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Xt=navigator.hardwareConcurrency)}catch{}const Yt=new f,Zt=new f;let $t,te,ee,ne,se,re,oe=0;async function ce(t){let e,o;try{const{options:c,config:i}=t;if(c.format&&await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Pt.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,e)=>{if(!t)return!1;let n=Kt.get(t);n||(n=new f,Kt.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Gt)?i.CompressionStream:i.DecompressionStream,Rt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable||new y({async pull(t){const e=new w(t=>Yt.set(oe,t));ie({type:"pull",messageId:oe}),oe=(oe+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 w(t=>e=t);Zt.set(oe,e),ie({type:Nt,value:t,messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Jt(c,i),$t=new AbortController;const{signal:u}=$t;await l.pipeThrough(e).pipeThrough(new Qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:u,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ie({type:qt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ae(t)}}function ie(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 ae(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 fe(t,e,n={}){if(!te){const t=new r("WASM module not loaded");throw t.cause=re,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.ft=ee(i),this.in=ee(a),this.inBufferSize=a,!this.ft||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=te.deflate_process,this.ut=te.deflate_last_consumed,this.ht=te.deflate_end,this.yt=te.deflate_new(),n="gzip"===e?te.deflate_init_gzip(this.yt,c):"deflate-raw"===e?te.deflate_init_raw(this.yt,c):te.deflate_init(this.yt,c)):"deflate64-raw"===e?(this.wt=te.inflate9_process,this.ut=te.inflate9_last_consumed,this.ht=te.inflate9_end,this.yt=te.inflate9_new(),n=te.inflate9_init_raw(this.yt)):(this.wt=te.inflate_process,this.ut=te.inflate_last_consumed,this.ht=te.inflate_end,this.yt=te.inflate_new(),n="deflate-raw"===e?te.inflate_init_raw(this.yt):"gzip"===e?te.inflate_init_gzip(this.yt):te.inflate_init(this.yt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(se.buffer),f=this.wt,l=this.ut,w=this.ft,u=this.lt;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&ne&&(ne(this.in),this.in=0),this.in=ee(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.yt,this.in,e,w,i,0),p=16777215&o;if(p&&(u.set(a.subarray(w,w+p),0),n.enqueue(u.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.yt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(se.buffer),s=this.wt,c=this.ft,a=this.lt;for(;;){const o=s(this.yt,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.yt&&t.ht&&(e=t.ht(t.yt)),t.yt=0,t.in&&ne&&ne(t.in),t.in=0,t.ft&&ne&&ne(t.ft),t.ft=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ce(t),e==Nt){const t=Yt.get(n);Yt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Zt.get(n);Zt.delete(n),t()}e==qt&&$t.abort()}catch(t){ae(t)}}),p({type:"ready"});class le{constructor(t="deflate",e){return fe(!0,t,e)}}class we{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,we.St=!0;let ue=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:le,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!ue)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(te=t,({malloc:ee,free:ne,memory:se}=te),"function"!=typeof ee||"function"!=typeof ne||!se)throw te=ee=ne=se=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),ue=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
|
|
244
|
+
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 e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(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:w,TextEncoder:u,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=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,M,P,D,F,B]=C;class R{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=B[255&t]^F[t>>>8&255]^D[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 U extends d{constructor(){let t;const e=new R;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 W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(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]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(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=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(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},C(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(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.A=[1732584193,4023233417,2562383102,271733878,3285377520],e.I=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.A.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.F.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(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.B(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(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.B(e.splice(0,16));return t.reset(),n}U(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}B(e){const n=this,r=n.M,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.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.I[s.floor(t/20)]|0;l=f,f=a,a=n.W(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}},E={importKey:t=>new E._(V.bytes.C(t)),T(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,w;const u=new ArrayBuffer(o),h=new l(u);let p=0;const d=T;for(e=V.bytes.C(e),w=1;(o||1)>p;w++){for(c=i=t.encrypt(d.concat(e,[w])),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 u.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[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.I=[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)}H(){const t=this.j[0],e=this.j[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 w=16843009*f^65537*a^257*i^16843008*l,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>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.I[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],w=c[4];let u,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)u=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&S]^n[g++],u=d,d=y,y=m,m=S,S=u;return o}},it=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)}Z(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}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(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 T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,pending:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let w=s.length<tt?1:0;for(let t=0;tt>t;t++)w|=l[t]^a[t];if(w&&c)throw new r(H);t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,pending:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new w(e=>t.et=e),password:yt(n,s),strength:r-1,pending:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,pending:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let w;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%G)),w=0;l-G>=w;w+=G){const t=gt(ot,mt(e,w,w+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),w+s)}return t.pending=mt(e,w),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),w=gt(ot,mt(f,$[s],2*$[s])),u=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ot:w,passwordVerification:u},nt:new it(new ct(l),t.from(et)),st:new at(w)}),u}function yt(t,e){return e===v?(t=>{if(typeof u==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 u).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(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(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(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=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(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(r[0]),it:new R(r[2])}),s)for(let e=0;e<s.length;e++)At(t,s[e]);else for(let e=0;e<n.length;e++)At(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]=It(t)^e[s],At(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,e[s]);return n}function At(t,e){let[,n]=t.keys;t.ct.append([e]);const r=~t.ct.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.it.append([n>>>24]);const o=~t.it.get();t.keys=[r,n,o]}function It(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}const Pt=new f;function Dt(t){return Pt.get(t)}const Ft="Invalid uncompressed size",Bt=j,Rt="deflate-raw",Ut="gzip",Wt=[31,139,8];class _t extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:w,format:u,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=u&&Dt(u),v=a&&r&&!w&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=jt(S,d)),r)if(g)S=Ht(S,Lt(g.CompressionStream,u,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Tt,S=Ht(S,new s(Ut)),S=jt(S,m);else try{S=Ot(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Ut)}catch{throw t}S=Ht(S,e),S=jt(S,new Tt)}o&&(i?S=jt(S,new bt(t)):(y=new ut(t),S=jt(S,y))),Et(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Tt 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=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:u,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=jt(C,new vt(t)):(z=new wt(t),C=jt(C,z))),u){const t=m&&Dt(m);if(t)C=Ht(C,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Ot(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Ut)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const u=new w((t,e)=>{i=t,a=e});u.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(Wt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await u}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=jt(t,h),jt(t=Ht(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Ft)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(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)})})(C)}a&&(k=new U,C=jt(C,k)),Et(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Bt)}})}}const Kt=new f;function Et(t,n,s){n=jt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Ot(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Rt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Ht(t,i)}function jt(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 Ht(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 Nt="data",qt="close",Gt="deflate";class Jt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Gt)?c=_t: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})}}),w=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(Ft)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(w)})}}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 Xt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Xt=navigator.hardwareConcurrency)}catch{}const Yt=new f,Zt=new f;let $t,te,ee,ne,se,re,oe=0;async function ce(t){let e,o;try{const{options:c,config:i}=t;if(c.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Kt.get(t);n||(n=new f,Kt.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Gt)?i.CompressionStream:i.DecompressionStream,Rt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable||new y({async pull(t){const e=new w(t=>Yt.set(oe,t));ie({type:"pull",messageId:oe}),oe=(oe+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 w(t=>e=t);Zt.set(oe,e),ie({type:Nt,value:t,messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Jt(c,i),$t=new AbortController;const{signal:u}=$t;await l.pipeThrough(e).pipeThrough(new Qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:u,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ie({type:qt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ae(t)}}function ie(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 ae(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:e,stack:n,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}function fe(t,e,n={}){if(!te){const t=new r("WASM module not loaded");throw t.cause=re,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.ft=ee(i),this.in=ee(a),this.inBufferSize=a,!this.ft||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=te.deflate_process,this.ut=te.deflate_last_consumed,this.ht=te.deflate_end,this.yt=te.deflate_new(),n="gzip"===e?te.deflate_init_gzip(this.yt,c):"deflate-raw"===e?te.deflate_init_raw(this.yt,c):te.deflate_init(this.yt,c)):"deflate64-raw"===e?(this.wt=te.inflate9_process,this.ut=te.inflate9_last_consumed,this.ht=te.inflate9_end,this.yt=te.inflate9_new(),n=te.inflate9_init_raw(this.yt)):(this.wt=te.inflate_process,this.ut=te.inflate_last_consumed,this.ht=te.inflate_end,this.yt=te.inflate_new(),n="deflate-raw"===e?te.inflate_init_raw(this.yt):"gzip"===e?te.inflate_init_gzip(this.yt):te.inflate_init(this.yt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(se.buffer),f=this.wt,l=this.ut,w=this.ft,u=this.lt;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&ne&&(ne(this.in),this.in=0),this.in=ee(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.yt,this.in,e,w,i,0),p=16777215&o;if(p&&(u.set(a.subarray(w,w+p),0),n.enqueue(u.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.yt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(se.buffer),s=this.wt,c=this.ft,a=this.lt;for(;;){const o=s(this.yt,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.yt&&t.ht&&(e=t.ht(t.yt)),t.yt=0,t.in&&ne&&ne(t.in),t.in=0,t.ft&&ne&&ne(t.ft),t.ft=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ce(t),e==Nt){const t=Yt.get(n);Yt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Zt.get(n);Zt.delete(n),t()}e==qt&&$t.abort()}catch(t){ae(t)}}),p({type:"ready"});class le{constructor(t="deflate",e){return fe(!0,t,e)}}class we{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,we.St=!0;let ue=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:le,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!ue)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(te=t,({malloc:ee,free:ne,memory:se}=te),"function"!=typeof ee||"function"!=typeof ne||!se)throw te=ee=ne=se=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),ue=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
|
|
243
245
|
|
|
244
246
|
/*
|
|
245
|
-
Copyright (c)
|
|
247
|
+
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
246
248
|
|
|
247
249
|
Redistribution and use in source and binary forms, with or without
|
|
248
250
|
modification, are permitted provided that the following conditions are met:
|
|
@@ -270,72 +272,19 @@ const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,2
|
|
|
270
272
|
*/
|
|
271
273
|
|
|
272
274
|
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const RESERVED_COMPRESSION_METHODS = [
|
|
279
|
-
COMPRESSION_METHOD_STORE,
|
|
280
|
-
COMPRESSION_METHOD_DEFLATE,
|
|
281
|
-
COMPRESSION_METHOD_DEFLATE_64,
|
|
282
|
-
COMPRESSION_METHOD_AES
|
|
283
|
-
];
|
|
284
|
-
|
|
285
|
-
const registeredCodecs = new Map();
|
|
286
|
-
const codecStreams = new Map();
|
|
287
|
-
|
|
288
|
-
function registerCodec(codec = {}) {
|
|
289
|
-
const { compressionMethod, format, codecURI, CompressionStream, DecompressionStream, versionNeeded } = codec;
|
|
290
|
-
if (!Number.isInteger(compressionMethod) || compressionMethod < 0 || compressionMethod > MAX_16_BITS ||
|
|
291
|
-
typeof format != STRING_TYPE || !format.length) {
|
|
292
|
-
throw new Error(ERR_INVALID_CODEC_DEFINITION);
|
|
293
|
-
}
|
|
294
|
-
if (RESERVED_COMPRESSION_METHODS.includes(compressionMethod)) {
|
|
295
|
-
throw new Error(ERR_RESERVED_COMPRESSION_METHOD);
|
|
296
|
-
}
|
|
297
|
-
const hasStreams = typeof CompressionStream == FUNCTION_TYPE || typeof DecompressionStream == FUNCTION_TYPE;
|
|
298
|
-
if (!hasStreams && (typeof codecURI != STRING_TYPE || !codecURI.length)) {
|
|
299
|
-
throw new Error(ERR_INVALID_CODEC_DEFINITION);
|
|
300
|
-
}
|
|
301
|
-
registeredCodecs.set(compressionMethod, { compressionMethod, format, codecURI, versionNeeded });
|
|
302
|
-
if (hasStreams) {
|
|
303
|
-
setCodecStreams(format, { CompressionStream, DecompressionStream });
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function unregisterCodec(compressionMethod) {
|
|
308
|
-
const codec = registeredCodecs.get(compressionMethod);
|
|
309
|
-
if (codec) {
|
|
310
|
-
registeredCodecs.delete(compressionMethod);
|
|
311
|
-
let formatUsed;
|
|
312
|
-
registeredCodecs.forEach(otherCodec => formatUsed = formatUsed || otherCodec.format == codec.format);
|
|
313
|
-
if (!formatUsed) {
|
|
314
|
-
codecStreams.delete(codec.format);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function getRegisteredCodec(compressionMethod) {
|
|
320
|
-
return registeredCodecs.get(compressionMethod);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function getCodecStreams(format) {
|
|
324
|
-
return codecStreams.get(format);
|
|
275
|
+
function concat(first, second) {
|
|
276
|
+
const result = new Uint8Array(first.length + second.length);
|
|
277
|
+
result.set(first);
|
|
278
|
+
result.set(second, first.length);
|
|
279
|
+
return result;
|
|
325
280
|
}
|
|
326
281
|
|
|
327
|
-
function
|
|
328
|
-
|
|
329
|
-
if (typeof CompressionStream != FUNCTION_TYPE && typeof DecompressionStream != FUNCTION_TYPE) {
|
|
330
|
-
throw new Error(ERR_INVALID_CODEC_MODULE);
|
|
331
|
-
}
|
|
332
|
-
codecStreams.set(format, { CompressionStream, DecompressionStream });
|
|
282
|
+
function toExactUint8Array(array) {
|
|
283
|
+
return array.byteOffset || array.byteLength != array.buffer.byteLength ? new Uint8Array(array) : array;
|
|
333
284
|
}
|
|
334
285
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
setCodecStreams(format, await import(/* webpackIgnore: true */ /* @vite-ignore */ codecURI));
|
|
338
|
-
}
|
|
286
|
+
function getDataView(array) {
|
|
287
|
+
return new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
339
288
|
}
|
|
340
289
|
|
|
341
290
|
/*
|
|
@@ -520,50 +469,6 @@ function encodeText(value) {
|
|
|
520
469
|
}
|
|
521
470
|
}
|
|
522
471
|
|
|
523
|
-
/*
|
|
524
|
-
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
525
|
-
|
|
526
|
-
Redistribution and use in source and binary forms, with or without
|
|
527
|
-
modification, are permitted provided that the following conditions are met:
|
|
528
|
-
|
|
529
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
530
|
-
this list of conditions and the following disclaimer.
|
|
531
|
-
|
|
532
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
533
|
-
notice, this list of conditions and the following disclaimer in
|
|
534
|
-
the documentation and/or other materials provided with the distribution.
|
|
535
|
-
|
|
536
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
537
|
-
derived from this software without specific prior written permission.
|
|
538
|
-
|
|
539
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
540
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
541
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
542
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
543
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
544
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
545
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
546
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
547
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
548
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
function concat(first, second) {
|
|
553
|
-
const result = new Uint8Array(first.length + second.length);
|
|
554
|
-
result.set(first);
|
|
555
|
-
result.set(second, first.length);
|
|
556
|
-
return result;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function toExactUint8Array(array) {
|
|
560
|
-
return array.byteOffset || array.byteLength != array.buffer.byteLength ? new Uint8Array(array) : array;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function getDataView(array) {
|
|
564
|
-
return new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
472
|
// Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
|
|
568
473
|
|
|
569
474
|
// deno-lint-ignore-file no-this-alias
|
|
@@ -1933,6 +1838,102 @@ function toCompatibleWritable(writable) {
|
|
|
1933
1838
|
});
|
|
1934
1839
|
}
|
|
1935
1840
|
|
|
1841
|
+
/*
|
|
1842
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
1843
|
+
|
|
1844
|
+
Redistribution and use in source and binary forms, with or without
|
|
1845
|
+
modification, are permitted provided that the following conditions are met:
|
|
1846
|
+
|
|
1847
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
1848
|
+
this list of conditions and the following disclaimer.
|
|
1849
|
+
|
|
1850
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
1851
|
+
notice, this list of conditions and the following disclaimer in
|
|
1852
|
+
the documentation and/or other materials provided with the distribution.
|
|
1853
|
+
|
|
1854
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
1855
|
+
derived from this software without specific prior written permission.
|
|
1856
|
+
|
|
1857
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
1858
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1859
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
1860
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
1861
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1862
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
1863
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
1864
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1865
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1866
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1867
|
+
*/
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
const ERR_INVALID_CODEC_DEFINITION = "Invalid codec definition";
|
|
1871
|
+
const ERR_RESERVED_COMPRESSION_METHOD = "Reserved compression method";
|
|
1872
|
+
const ERR_INVALID_CODEC_MODULE = "Invalid codec module";
|
|
1873
|
+
|
|
1874
|
+
const RESERVED_COMPRESSION_METHODS = [
|
|
1875
|
+
COMPRESSION_METHOD_STORE,
|
|
1876
|
+
COMPRESSION_METHOD_DEFLATE,
|
|
1877
|
+
COMPRESSION_METHOD_DEFLATE_64,
|
|
1878
|
+
COMPRESSION_METHOD_AES
|
|
1879
|
+
];
|
|
1880
|
+
|
|
1881
|
+
const registeredCodecs = new Map();
|
|
1882
|
+
const codecStreams = new Map();
|
|
1883
|
+
|
|
1884
|
+
function registerCodec(codec = {}) {
|
|
1885
|
+
const { compressionMethod, format, codecURI, CompressionStream, DecompressionStream, versionNeeded } = codec;
|
|
1886
|
+
if (!Number.isInteger(compressionMethod) || compressionMethod < 0 || compressionMethod > MAX_16_BITS ||
|
|
1887
|
+
typeof format != STRING_TYPE || !format.length) {
|
|
1888
|
+
throw new Error(ERR_INVALID_CODEC_DEFINITION);
|
|
1889
|
+
}
|
|
1890
|
+
if (RESERVED_COMPRESSION_METHODS.includes(compressionMethod)) {
|
|
1891
|
+
throw new Error(ERR_RESERVED_COMPRESSION_METHOD);
|
|
1892
|
+
}
|
|
1893
|
+
const hasStreams = typeof CompressionStream == FUNCTION_TYPE || typeof DecompressionStream == FUNCTION_TYPE;
|
|
1894
|
+
if (!hasStreams && (typeof codecURI != STRING_TYPE || !codecURI.length)) {
|
|
1895
|
+
throw new Error(ERR_INVALID_CODEC_DEFINITION);
|
|
1896
|
+
}
|
|
1897
|
+
registeredCodecs.set(compressionMethod, { compressionMethod, format, codecURI, versionNeeded });
|
|
1898
|
+
if (hasStreams) {
|
|
1899
|
+
setCodecStreams(format, { CompressionStream, DecompressionStream });
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
function unregisterCodec(compressionMethod) {
|
|
1904
|
+
const codec = registeredCodecs.get(compressionMethod);
|
|
1905
|
+
if (codec) {
|
|
1906
|
+
registeredCodecs.delete(compressionMethod);
|
|
1907
|
+
let formatUsed;
|
|
1908
|
+
registeredCodecs.forEach(otherCodec => formatUsed = formatUsed || otherCodec.format == codec.format);
|
|
1909
|
+
if (!formatUsed) {
|
|
1910
|
+
codecStreams.delete(codec.format);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
function getRegisteredCodec(compressionMethod) {
|
|
1916
|
+
return registeredCodecs.get(compressionMethod);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
function getCodecStreams(format) {
|
|
1920
|
+
return codecStreams.get(format);
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
function setCodecStreams(format, streams) {
|
|
1924
|
+
const { CompressionStream, DecompressionStream } = streams;
|
|
1925
|
+
if (typeof CompressionStream != FUNCTION_TYPE && typeof DecompressionStream != FUNCTION_TYPE) {
|
|
1926
|
+
throw new Error(ERR_INVALID_CODEC_MODULE);
|
|
1927
|
+
}
|
|
1928
|
+
codecStreams.set(format, { CompressionStream, DecompressionStream });
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
async function ensureCodecStreams(format, codecURI) {
|
|
1932
|
+
if (!codecStreams.has(format) && codecURI) {
|
|
1933
|
+
setCodecStreams(format, await import(/* webpackIgnore: true */ /* @vite-ignore */ codecURI));
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1936
1937
|
/*
|
|
1937
1938
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
1938
1939
|
|
|
@@ -2486,8 +2487,8 @@ class ChunkStream extends TransformStream {
|
|
|
2486
2487
|
1. Redistributions of source code must retain the above copyright notice,
|
|
2487
2488
|
this list of conditions and the following disclaimer.
|
|
2488
2489
|
|
|
2489
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
2490
|
-
notice, this list of conditions and the following disclaimer in
|
|
2490
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
2491
|
+
notice, this list of conditions and the following disclaimer in
|
|
2491
2492
|
the documentation and/or other materials provided with the distribution.
|
|
2492
2493
|
|
|
2493
2494
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -2506,24 +2507,19 @@ class ChunkStream extends TransformStream {
|
|
|
2506
2507
|
*/
|
|
2507
2508
|
|
|
2508
2509
|
|
|
2509
|
-
const MODULE_WORKER_OPTIONS = { type: "module" };
|
|
2510
|
-
const ERROR_EVENT_TYPE = "error";
|
|
2511
|
-
const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
2512
2510
|
const ERR_WORKER_STARTUP_TIMEOUT = "Worker startup timeout";
|
|
2513
2511
|
|
|
2514
|
-
let webWorkerSupported,
|
|
2515
|
-
let transferStreamsSupported = true;
|
|
2516
|
-
try {
|
|
2517
|
-
transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
|
|
2518
|
-
} catch {
|
|
2519
|
-
// ignored
|
|
2520
|
-
}
|
|
2512
|
+
let webWorkerSupported, createWorkerFailed, webWorkerBackend;
|
|
2521
2513
|
let initModule$1 = () => { };
|
|
2522
2514
|
|
|
2523
2515
|
function configureWorker({ initModule: initModuleFunction }) {
|
|
2524
2516
|
initModule$1 = initModuleFunction;
|
|
2525
2517
|
}
|
|
2526
2518
|
|
|
2519
|
+
function setWebWorkerBackend(backend) {
|
|
2520
|
+
webWorkerBackend = backend;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2527
2523
|
async function supportsDeflate(config) {
|
|
2528
2524
|
const { CompressionStream: NativeStream, CompressionStreamFallback: FallbackStream } = config;
|
|
2529
2525
|
if (FallbackStream && !FallbackStream.requiresModule) {
|
|
@@ -2548,6 +2544,14 @@ function resetWebWorkerSupport() {
|
|
|
2548
2544
|
createWorkerFailed = false;
|
|
2549
2545
|
}
|
|
2550
2546
|
|
|
2547
|
+
function disableWebWorker(workerData) {
|
|
2548
|
+
if (workerData.createWorker) {
|
|
2549
|
+
createWorkerFailed = true;
|
|
2550
|
+
} else {
|
|
2551
|
+
webWorkerSupported = false;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2551
2555
|
class CodecWorker {
|
|
2552
2556
|
|
|
2553
2557
|
constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI, createWorker }, onTaskFinished) {
|
|
@@ -2600,7 +2604,7 @@ class CodecWorker {
|
|
|
2600
2604
|
// deno-lint-ignore valid-typeof
|
|
2601
2605
|
webWorkerSupported = typeof Worker != UNDEFINED_TYPE;
|
|
2602
2606
|
}
|
|
2603
|
-
return (useWebWorkers && ((webWorkerSupported && workerURI) || createWorker) ?
|
|
2607
|
+
return (useWebWorkers && webWorkerBackend && ((webWorkerSupported && workerURI) || createWorker) ? webWorkerBackend : createWorkerInterface)(workerData, config);
|
|
2604
2608
|
}
|
|
2605
2609
|
}
|
|
2606
2610
|
|
|
@@ -2644,58 +2648,6 @@ function createWorkerInterface(workerData, config) {
|
|
|
2644
2648
|
};
|
|
2645
2649
|
}
|
|
2646
2650
|
|
|
2647
|
-
function createWebWorkerInterface(workerData, config) {
|
|
2648
|
-
const { baseURI, chunkSize, workerStartupTimeout } = config;
|
|
2649
|
-
let { wasmURI } = config;
|
|
2650
|
-
|
|
2651
|
-
if (!workerData.interface) {
|
|
2652
|
-
// deno-lint-ignore valid-typeof
|
|
2653
|
-
if (typeof wasmURI == FUNCTION_TYPE) {
|
|
2654
|
-
wasmURI = wasmURI();
|
|
2655
|
-
}
|
|
2656
|
-
let worker;
|
|
2657
|
-
try {
|
|
2658
|
-
worker = getWebWorker(workerData.workerURI, baseURI, workerData);
|
|
2659
|
-
} catch {
|
|
2660
|
-
if (workerData.createWorker) {
|
|
2661
|
-
createWorkerFailed = true;
|
|
2662
|
-
} else {
|
|
2663
|
-
webWorkerSupported = false;
|
|
2664
|
-
}
|
|
2665
|
-
return createWorkerInterface(workerData, config);
|
|
2666
|
-
}
|
|
2667
|
-
Object.assign(workerData, {
|
|
2668
|
-
worker,
|
|
2669
|
-
workerAlive: false,
|
|
2670
|
-
terminated: false,
|
|
2671
|
-
interface: {
|
|
2672
|
-
run: async () => {
|
|
2673
|
-
try {
|
|
2674
|
-
return await runWebWorker(workerData, { chunkSize, wasmURI, baseURI, workerStartupTimeout });
|
|
2675
|
-
} catch (error) {
|
|
2676
|
-
if (error && error.workerStartupFailed) {
|
|
2677
|
-
if (workerData.createWorker) {
|
|
2678
|
-
createWorkerFailed = true;
|
|
2679
|
-
} else {
|
|
2680
|
-
webWorkerSupported = false;
|
|
2681
|
-
}
|
|
2682
|
-
const { reader } = workerData;
|
|
2683
|
-
if (reader) {
|
|
2684
|
-
reader.releaseLock();
|
|
2685
|
-
}
|
|
2686
|
-
workerData.reader = null;
|
|
2687
|
-
workerData.writer = null;
|
|
2688
|
-
return runWorker$1(workerData, config);
|
|
2689
|
-
}
|
|
2690
|
-
throw error;
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
});
|
|
2695
|
-
}
|
|
2696
|
-
return workerData.interface;
|
|
2697
|
-
}
|
|
2698
|
-
|
|
2699
2651
|
async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
|
|
2700
2652
|
let codecStream;
|
|
2701
2653
|
try {
|
|
@@ -2744,6 +2696,95 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
|
|
|
2744
2696
|
}
|
|
2745
2697
|
}
|
|
2746
2698
|
|
|
2699
|
+
/*
|
|
2700
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
2701
|
+
|
|
2702
|
+
Redistribution and use in source and binary forms, with or without
|
|
2703
|
+
modification, are permitted provided that the following conditions are met:
|
|
2704
|
+
|
|
2705
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
2706
|
+
this list of conditions and the following disclaimer.
|
|
2707
|
+
|
|
2708
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
2709
|
+
notice, this list of conditions and the following disclaimer in
|
|
2710
|
+
the documentation and/or other materials provided with the distribution.
|
|
2711
|
+
|
|
2712
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
2713
|
+
derived from this software without specific prior written permission.
|
|
2714
|
+
|
|
2715
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
2716
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
2717
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
2718
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
2719
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
2720
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
2721
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
2722
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
2723
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
2724
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2725
|
+
*/
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
const MODULE_WORKER_OPTIONS = { type: "module" };
|
|
2729
|
+
const ERROR_EVENT_TYPE = "error";
|
|
2730
|
+
const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
2731
|
+
|
|
2732
|
+
let webWorkerSource, webWorkerURI, webWorkerOptions;
|
|
2733
|
+
let transferStreamsSupported = true;
|
|
2734
|
+
try {
|
|
2735
|
+
transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
|
|
2736
|
+
} catch {
|
|
2737
|
+
// ignored
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
setWebWorkerBackend(createWebWorkerInterface);
|
|
2741
|
+
|
|
2742
|
+
function createWebWorkerInterface(workerData, config) {
|
|
2743
|
+
const { baseURI, chunkSize, workerStartupTimeout } = config;
|
|
2744
|
+
let { wasmURI } = config;
|
|
2745
|
+
|
|
2746
|
+
if (!workerData.interface) {
|
|
2747
|
+
// deno-lint-ignore valid-typeof
|
|
2748
|
+
if (typeof wasmURI == FUNCTION_TYPE) {
|
|
2749
|
+
wasmURI = wasmURI();
|
|
2750
|
+
}
|
|
2751
|
+
let worker;
|
|
2752
|
+
try {
|
|
2753
|
+
worker = getWebWorker(workerData.workerURI, baseURI, workerData);
|
|
2754
|
+
} catch {
|
|
2755
|
+
disableWebWorker(workerData);
|
|
2756
|
+
return createWorkerInterface(workerData, config);
|
|
2757
|
+
}
|
|
2758
|
+
Object.assign(workerData, {
|
|
2759
|
+
worker,
|
|
2760
|
+
workerAlive: false,
|
|
2761
|
+
terminated: false,
|
|
2762
|
+
interface: {
|
|
2763
|
+
run: async () => {
|
|
2764
|
+
try {
|
|
2765
|
+
return await runWebWorker(workerData, { chunkSize, wasmURI, baseURI, workerStartupTimeout });
|
|
2766
|
+
} catch (error) {
|
|
2767
|
+
if (error && error.workerStartupFailed) {
|
|
2768
|
+
disableWebWorker(workerData);
|
|
2769
|
+
releaseWorkerStreams(workerData);
|
|
2770
|
+
return runWorker$1(workerData, config);
|
|
2771
|
+
}
|
|
2772
|
+
if (error && error.codecImportFailed) {
|
|
2773
|
+
if (workerData.reader) {
|
|
2774
|
+
releaseWorkerStreams(workerData);
|
|
2775
|
+
return runWorker$1(workerData, config);
|
|
2776
|
+
}
|
|
2777
|
+
workerData.onTaskFinished();
|
|
2778
|
+
}
|
|
2779
|
+
throw error;
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2785
|
+
return workerData.interface;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2747
2788
|
async function runWebWorker(workerData, config) {
|
|
2748
2789
|
let resolveResult, rejectResult;
|
|
2749
2790
|
const result = new Promise((resolve, reject) => {
|
|
@@ -2823,6 +2864,15 @@ function watchClosedStream(writableSource) {
|
|
|
2823
2864
|
return { writable, closed, abortPipe: () => abortController.abort() };
|
|
2824
2865
|
}
|
|
2825
2866
|
|
|
2867
|
+
function releaseWorkerStreams(workerData) {
|
|
2868
|
+
const { reader } = workerData;
|
|
2869
|
+
if (reader) {
|
|
2870
|
+
reader.releaseLock();
|
|
2871
|
+
}
|
|
2872
|
+
workerData.reader = null;
|
|
2873
|
+
workerData.writer = null;
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2826
2876
|
function terminateWorker$1(workerData) {
|
|
2827
2877
|
const { worker } = workerData;
|
|
2828
2878
|
if (worker) {
|
|
@@ -2890,7 +2940,7 @@ function getWebWorker(url, baseURI, workerData, isModuleType, useBlobURI = true)
|
|
|
2890
2940
|
try {
|
|
2891
2941
|
worker = new Worker(resolvedURI, resolvedOptions);
|
|
2892
2942
|
} catch (error) {
|
|
2893
|
-
if (
|
|
2943
|
+
if (isModuleType) {
|
|
2894
2944
|
return getWebWorker(url, baseURI, workerData, false, useBlobURI);
|
|
2895
2945
|
} else {
|
|
2896
2946
|
throw error;
|
|
@@ -3008,12 +3058,15 @@ async function onMessage({ data }, workerData) {
|
|
|
3008
3058
|
const stale = () => workerData.generation != generation;
|
|
3009
3059
|
try {
|
|
3010
3060
|
if (error) {
|
|
3011
|
-
const { message, stack, code, name, outputSize, cause } = error;
|
|
3061
|
+
const { message, stack, code, name, outputSize, cause, codecImportFailed } = error;
|
|
3012
3062
|
const responseError = new Error(message);
|
|
3013
3063
|
Object.assign(responseError, { stack, code, name, outputSize });
|
|
3014
3064
|
if (cause) {
|
|
3015
3065
|
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3016
3066
|
}
|
|
3067
|
+
if (codecImportFailed) {
|
|
3068
|
+
responseError.codecImportFailed = true;
|
|
3069
|
+
}
|
|
3017
3070
|
close(responseError);
|
|
3018
3071
|
} else {
|
|
3019
3072
|
if (type == MESSAGE_PULL) {
|
|
@@ -3052,7 +3105,9 @@ async function onMessage({ data }, workerData) {
|
|
|
3052
3105
|
if (writer) {
|
|
3053
3106
|
writer.releaseLock();
|
|
3054
3107
|
}
|
|
3055
|
-
|
|
3108
|
+
if (!(error && error.codecImportFailed)) {
|
|
3109
|
+
onTaskFinished();
|
|
3110
|
+
}
|
|
3056
3111
|
}
|
|
3057
3112
|
}
|
|
3058
3113
|
|
|
@@ -3102,7 +3157,7 @@ async function runWorker(stream, workerOptions) {
|
|
|
3102
3157
|
}
|
|
3103
3158
|
await ensureCodecStreams(format, options.codecURI);
|
|
3104
3159
|
}
|
|
3105
|
-
workerOptions.transferStreams = transferStreams || (transferStreams === UNDEFINED_VALUE && config.transferStreams);
|
|
3160
|
+
workerOptions.transferStreams = !format && (transferStreams || (transferStreams === UNDEFINED_VALUE && config.transferStreams));
|
|
3106
3161
|
const streamCopy = !compressed && !checkCrc32 && !computeCrc32 && !encrypted;
|
|
3107
3162
|
const workerSupported = format === UNDEFINED_VALUE || Boolean(options.codecURI);
|
|
3108
3163
|
workerOptions.useWebWorkers = !streamCopy && workerSupported && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
|
|
@@ -3606,7 +3661,7 @@ async function initHttpReader(httpReader, sendRequest, getRequestData) {
|
|
|
3606
3661
|
forceRangeRequests,
|
|
3607
3662
|
combineSizeEocd
|
|
3608
3663
|
} = httpReader;
|
|
3609
|
-
if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest ==
|
|
3664
|
+
if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == UNDEFINED_TYPE || preventHeadRequest)) {
|
|
3610
3665
|
const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -END_OF_CENTRAL_DIR_LENGTH : undefined));
|
|
3611
3666
|
const acceptRanges = response.headers.get(HTTP_HEADER_ACCEPT_RANGES);
|
|
3612
3667
|
if (!forceRangeRequests && (!acceptRanges || acceptRanges.toLowerCase() != HTTP_RANGE_UNIT)) {
|
|
@@ -4459,9 +4514,13 @@ const OPTION_USDZ = "usdz";
|
|
|
4459
4514
|
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4460
4515
|
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4461
4516
|
const OPTION_STRICTNESS = "strictness";
|
|
4517
|
+
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4518
|
+
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4462
4519
|
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4463
4520
|
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4464
4521
|
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4522
|
+
const TEXT_TYPE_FILENAME = "filename";
|
|
4523
|
+
const TEXT_TYPE_COMMENT = "comment";
|
|
4465
4524
|
const STRICTNESS_STRICT = "strict";
|
|
4466
4525
|
const STRICTNESS_BALANCED = "balanced";
|
|
4467
4526
|
const STRICTNESS_TOLERANT = "tolerant";
|
|
@@ -4508,6 +4567,11 @@ const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
|
4508
4567
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4509
4568
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4510
4569
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4570
|
+
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
4571
|
+
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4572
|
+
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4573
|
+
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4574
|
+
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4511
4575
|
const CHARSET_UTF8 = "utf-8";
|
|
4512
4576
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4513
4577
|
const CHARSET_CP437 = "cp437";
|
|
@@ -4529,6 +4593,10 @@ const ZIP64_EXTRACTION = {
|
|
|
4529
4593
|
bytes: 8
|
|
4530
4594
|
}
|
|
4531
4595
|
};
|
|
4596
|
+
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4597
|
+
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4598
|
+
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4599
|
+
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
4532
4600
|
|
|
4533
4601
|
class ZipReader {
|
|
4534
4602
|
|
|
@@ -4557,6 +4625,8 @@ class ZipReader {
|
|
|
4557
4625
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4558
4626
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4559
4627
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
4628
|
+
const filenameValidation = getFilenameValidation(getOptionValue$1(zipReader, options, OPTION_FILENAME_VALIDATION), strictness);
|
|
4629
|
+
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4560
4630
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4561
4631
|
if (!endOfDirectoryInfo) {
|
|
4562
4632
|
const signatureArray = await readUint8Array(reader, 0, 4);
|
|
@@ -4750,11 +4820,22 @@ class ZipReader {
|
|
|
4750
4820
|
const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4751
4821
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4752
4822
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4753
|
-
let filename = decode(rawFilename, rawFilenameEncoding);
|
|
4823
|
+
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
4754
4824
|
if (filename === UNDEFINED_VALUE) {
|
|
4755
4825
|
filename = decodeText(rawFilename, rawFilenameEncoding);
|
|
4756
4826
|
}
|
|
4757
|
-
|
|
4827
|
+
if (normalizeFilename) {
|
|
4828
|
+
const normalizedFilename = normalizeFilename(filename);
|
|
4829
|
+
if (normalizedFilename !== UNDEFINED_VALUE) {
|
|
4830
|
+
filename = normalizedFilename;
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
if (isUnsafeFilename(filename, filenameValidation)) {
|
|
4834
|
+
const error = new Error(ERR_UNSAFE_FILENAME);
|
|
4835
|
+
error.filename = filename;
|
|
4836
|
+
throw error;
|
|
4837
|
+
}
|
|
4838
|
+
let comment = decode(rawComment, rawCommentEncoding, TEXT_TYPE_COMMENT);
|
|
4758
4839
|
if (comment === UNDEFINED_VALUE) {
|
|
4759
4840
|
comment = decodeText(rawComment, rawCommentEncoding);
|
|
4760
4841
|
}
|
|
@@ -4815,10 +4896,10 @@ class ZipReader {
|
|
|
4815
4896
|
entry.getData = (writer, options) => fileEntry.getData(writer, entry, zipReader.readRanges, options);
|
|
4816
4897
|
entry.arrayBuffer = async options => {
|
|
4817
4898
|
const writer = new TransformStream();
|
|
4818
|
-
const
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
return
|
|
4899
|
+
const arrayBufferPromise = streamToBlob(writer.readable).then(blob => blob.arrayBuffer());
|
|
4900
|
+
arrayBufferPromise.catch(() => { });
|
|
4901
|
+
await fileEntry.getData(writer, entry, zipReader.readRanges, options);
|
|
4902
|
+
return arrayBufferPromise;
|
|
4822
4903
|
};
|
|
4823
4904
|
offset = endOffset;
|
|
4824
4905
|
const { onprogress } = options;
|
|
@@ -5069,7 +5150,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5069
5150
|
readRanges
|
|
5070
5151
|
});
|
|
5071
5152
|
}
|
|
5072
|
-
let writable;
|
|
5153
|
+
let writable, abortError;
|
|
5073
5154
|
try {
|
|
5074
5155
|
if (!checkOverlappingEntryOnly) {
|
|
5075
5156
|
if (checkPasswordOnly) {
|
|
@@ -5089,12 +5170,22 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5089
5170
|
writer.size += error.outputSize;
|
|
5090
5171
|
}
|
|
5091
5172
|
if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
5173
|
+
abortError = error;
|
|
5092
5174
|
throw error;
|
|
5093
5175
|
}
|
|
5094
5176
|
} finally {
|
|
5095
5177
|
const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5096
5178
|
if (!preventClose && writable && !writable.locked) {
|
|
5097
|
-
|
|
5179
|
+
const writableWriter = writable.getWriter();
|
|
5180
|
+
if (abortError) {
|
|
5181
|
+
try {
|
|
5182
|
+
await writableWriter.abort(abortError);
|
|
5183
|
+
} catch {
|
|
5184
|
+
// the error being propagated is more relevant; ignored
|
|
5185
|
+
}
|
|
5186
|
+
} else {
|
|
5187
|
+
await writableWriter.close();
|
|
5188
|
+
}
|
|
5098
5189
|
}
|
|
5099
5190
|
}
|
|
5100
5191
|
return checkPasswordOnly || checkOverlappingEntryOnly ? UNDEFINED_VALUE : writer.getData ? writer.getData() : writable;
|
|
@@ -5474,16 +5565,51 @@ function getDiskOffset$1(reader, diskNumber) {
|
|
|
5474
5565
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5475
5566
|
}
|
|
5476
5567
|
|
|
5568
|
+
function isStrictnessValue(value) {
|
|
5569
|
+
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5570
|
+
}
|
|
5571
|
+
|
|
5477
5572
|
function getStrictness(strictness, checkAmbiguity) {
|
|
5478
5573
|
if (strictness === UNDEFINED_VALUE) {
|
|
5479
5574
|
return checkAmbiguity ? STRICTNESS_STRICT : STRICTNESS_BALANCED;
|
|
5480
5575
|
}
|
|
5576
|
+
if (!isStrictnessValue(strictness)) {
|
|
5577
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5578
|
+
}
|
|
5481
5579
|
return strictness;
|
|
5482
5580
|
}
|
|
5483
5581
|
|
|
5582
|
+
function getFilenameValidation(filenameValidation, strictness) {
|
|
5583
|
+
if (filenameValidation === UNDEFINED_VALUE) {
|
|
5584
|
+
return strictness;
|
|
5585
|
+
}
|
|
5586
|
+
if (!isStrictnessValue(filenameValidation)) {
|
|
5587
|
+
throw new Error(ERR_INVALID_FILENAME_VALIDATION);
|
|
5588
|
+
}
|
|
5589
|
+
return filenameValidation;
|
|
5590
|
+
}
|
|
5591
|
+
|
|
5592
|
+
function isUnsafeFilename(filename, filenameValidation) {
|
|
5593
|
+
if (filenameValidation == STRICTNESS_TOLERANT) {
|
|
5594
|
+
return false;
|
|
5595
|
+
}
|
|
5596
|
+
const pathParts = filename.split("/");
|
|
5597
|
+
if (pathParts.length > 1 && pathParts[pathParts.length - 1] === "") {
|
|
5598
|
+
pathParts.pop();
|
|
5599
|
+
}
|
|
5600
|
+
if (pathParts.includes("..") || filename.startsWith("/") || filename.startsWith("\\\\") || DRIVE_LETTER_REGEXP.test(filename)) {
|
|
5601
|
+
return true;
|
|
5602
|
+
}
|
|
5603
|
+
return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes(""));
|
|
5604
|
+
}
|
|
5605
|
+
|
|
5484
5606
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5485
5607
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5486
|
-
|
|
5608
|
+
const size = toNumber$1(maxAppendedDataSize);
|
|
5609
|
+
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5610
|
+
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5611
|
+
}
|
|
5612
|
+
return size;
|
|
5487
5613
|
}
|
|
5488
5614
|
if (strictness == STRICTNESS_STRICT) {
|
|
5489
5615
|
return 0;
|
|
@@ -5494,12 +5620,6 @@ function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
|
5494
5620
|
return MAX_16_BITS;
|
|
5495
5621
|
}
|
|
5496
5622
|
|
|
5497
|
-
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
5498
|
-
|
|
5499
|
-
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
5500
|
-
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
5501
|
-
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
5502
|
-
|
|
5503
5623
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
5504
5624
|
const { size } = reader;
|
|
5505
5625
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
@@ -5635,6 +5755,10 @@ function getOptionValue$1(zipReader, options, name) {
|
|
|
5635
5755
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5636
5756
|
}
|
|
5637
5757
|
|
|
5758
|
+
function toNumber$1(value) {
|
|
5759
|
+
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
5760
|
+
}
|
|
5761
|
+
|
|
5638
5762
|
function getDate(timeRaw) {
|
|
5639
5763
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5640
5764
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5673,12 +5797,16 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5673
5797
|
ERR_INVALID_AUTHENTICATION_CODE: ERR_INVALID_AUTHENTICATION_CODE,
|
|
5674
5798
|
ERR_INVALID_COMPRESSED_DATA: ERR_INVALID_COMPRESSED_DATA,
|
|
5675
5799
|
ERR_INVALID_CRC32: ERR_INVALID_CRC32,
|
|
5800
|
+
ERR_INVALID_FILENAME_VALIDATION: ERR_INVALID_FILENAME_VALIDATION,
|
|
5801
|
+
ERR_INVALID_MAX_APPENDED_DATA_SIZE: ERR_INVALID_MAX_APPENDED_DATA_SIZE,
|
|
5676
5802
|
ERR_INVALID_PASSWORD: ERR_INVALID_PASSWORD,
|
|
5677
5803
|
ERR_INVALID_SIGNATURE: ERR_INVALID_SIGNATURE,
|
|
5804
|
+
ERR_INVALID_STRICTNESS: ERR_INVALID_STRICTNESS,
|
|
5678
5805
|
ERR_INVALID_UNCOMPRESSED_SIZE: ERR_INVALID_UNCOMPRESSED_SIZE,
|
|
5679
5806
|
ERR_LOCAL_FILE_HEADER_NOT_FOUND: ERR_LOCAL_FILE_HEADER_NOT_FOUND,
|
|
5680
5807
|
ERR_OVERLAPPING_ENTRY: ERR_OVERLAPPING_ENTRY,
|
|
5681
5808
|
ERR_SPLIT_ZIP_FILE: ERR_SPLIT_ZIP_FILE,
|
|
5809
|
+
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
5682
5810
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
5683
5811
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
5684
5812
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
@@ -5740,6 +5868,8 @@ const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = "Invalid unixExtraFieldType (must be '
|
|
|
5740
5868
|
const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldType 'unix' (use 'infozip' for larger ids)";
|
|
5741
5869
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
5742
5870
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
5871
|
+
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
5872
|
+
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
5743
5873
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
5744
5874
|
|
|
5745
5875
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -5747,6 +5877,7 @@ const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
|
5747
5877
|
const VENDOR_VERSION_AE_1 = 1;
|
|
5748
5878
|
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
5749
5879
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
5880
|
+
const MAX_LEVEL = 9;
|
|
5750
5881
|
|
|
5751
5882
|
let workers = 0;
|
|
5752
5883
|
const pendingEntries = [];
|
|
@@ -5909,7 +6040,8 @@ class ZipWriter {
|
|
|
5909
6040
|
|
|
5910
6041
|
remove(entry) {
|
|
5911
6042
|
const { filenames, files } = this;
|
|
5912
|
-
|
|
6043
|
+
// deno-lint-ignore valid-typeof
|
|
6044
|
+
if (typeof entry == STRING_TYPE) {
|
|
5913
6045
|
entry = files.get(entry);
|
|
5914
6046
|
}
|
|
5915
6047
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
@@ -6047,20 +6179,20 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6047
6179
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6048
6180
|
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
|
|
6049
6181
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6050
|
-
const uid =
|
|
6051
|
-
const gid =
|
|
6052
|
-
let unixMode =
|
|
6182
|
+
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6183
|
+
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
6184
|
+
let unixMode = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UNIX_MODE);
|
|
6053
6185
|
let unixExtraFieldType = getOptionValue(zipWriter, options, OPTION_UNIX_EXTRA_FIELD_TYPE);
|
|
6054
6186
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6055
6187
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6056
6188
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6057
|
-
if (uid !== UNDEFINED_VALUE && (uid < 0 || uid > MAX_32_BITS)) {
|
|
6189
|
+
if (uid !== UNDEFINED_VALUE && (!Number.isInteger(uid) || uid < 0 || uid > MAX_32_BITS)) {
|
|
6058
6190
|
throw new Error(ERR_INVALID_UID);
|
|
6059
6191
|
}
|
|
6060
|
-
if (gid !== UNDEFINED_VALUE && (gid < 0 || gid > MAX_32_BITS)) {
|
|
6192
|
+
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6061
6193
|
throw new Error(ERR_INVALID_GID);
|
|
6062
6194
|
}
|
|
6063
|
-
if (unixMode !== UNDEFINED_VALUE && (unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6195
|
+
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6064
6196
|
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6065
6197
|
}
|
|
6066
6198
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
@@ -6172,7 +6304,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6172
6304
|
|
|
6173
6305
|
function resolveMetadata(zipWriter, name, options) {
|
|
6174
6306
|
const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
|
|
6175
|
-
let rawFilename = encode(name);
|
|
6307
|
+
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6176
6308
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6177
6309
|
rawFilename = encodeText(name);
|
|
6178
6310
|
}
|
|
@@ -6180,7 +6312,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6180
6312
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6181
6313
|
}
|
|
6182
6314
|
const comment = options[PROPERTY_NAME_COMMENT] || "";
|
|
6183
|
-
let rawComment = encode(comment);
|
|
6315
|
+
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6184
6316
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6185
6317
|
rawComment = encodeText(comment);
|
|
6186
6318
|
}
|
|
@@ -6200,8 +6332,11 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6200
6332
|
if (!passThrough) {
|
|
6201
6333
|
password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6202
6334
|
rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6335
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6336
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6337
|
+
}
|
|
6203
6338
|
}
|
|
6204
|
-
const encryptionStrength =
|
|
6339
|
+
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6205
6340
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6206
6341
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
6207
6342
|
const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
|
|
@@ -6219,7 +6354,10 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6219
6354
|
compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
|
|
6220
6355
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6221
6356
|
}
|
|
6222
|
-
let level =
|
|
6357
|
+
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6358
|
+
if (level !== UNDEFINED_VALUE && (!Number.isInteger(level) || level < 0 || level > MAX_LEVEL)) {
|
|
6359
|
+
throw new Error(ERR_INVALID_LEVEL);
|
|
6360
|
+
}
|
|
6223
6361
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6224
6362
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6225
6363
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6240,7 +6378,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6240
6378
|
useCompressionStream = false;
|
|
6241
6379
|
}
|
|
6242
6380
|
const zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
6243
|
-
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
6381
|
+
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(Number.isInteger(encryptionStrength) && encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
6244
6382
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
6245
6383
|
}
|
|
6246
6384
|
const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
|
|
@@ -7434,6 +7572,14 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7434
7572
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7435
7573
|
}
|
|
7436
7574
|
|
|
7575
|
+
function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
7576
|
+
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7577
|
+
}
|
|
7578
|
+
|
|
7579
|
+
function toNumber(value) {
|
|
7580
|
+
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7581
|
+
}
|
|
7582
|
+
|
|
7437
7583
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7438
7584
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
7439
7585
|
}
|
|
@@ -8451,6 +8597,7 @@ U(setDefaultConfiguration);
|
|
|
8451
8597
|
|
|
8452
8598
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8453
8599
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8600
|
+
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
8454
8601
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
8455
8602
|
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
8456
8603
|
EXTRAFIELD_TYPE_ZIP64,
|
|
@@ -8559,8 +8706,9 @@ class ZipFileEntry extends ZipEntry {
|
|
|
8559
8706
|
const uncompressedSize = zipEntry.data ? zipEntry.data.uncompressedSize : reader.size;
|
|
8560
8707
|
await Promise.all([initStream(reader), initStream(writer, uncompressedSize)]);
|
|
8561
8708
|
const { readable } = reader;
|
|
8709
|
+
const { signal } = options;
|
|
8562
8710
|
zipEntry.uncompressedSize = reader.size;
|
|
8563
|
-
await toCompatibleReadable(readable).pipeTo(toCompatibleWritable(writer.writable));
|
|
8711
|
+
await toCompatibleReadable(readable).pipeTo(toCompatibleWritable(writer.writable), { signal });
|
|
8564
8712
|
return writer.getData ? writer.getData() : writer.writable;
|
|
8565
8713
|
}
|
|
8566
8714
|
}
|
|
@@ -8827,7 +8975,7 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
8827
8975
|
for (const entry of entries) {
|
|
8828
8976
|
let parent = this;
|
|
8829
8977
|
try {
|
|
8830
|
-
const path = entry.filename.split("/");
|
|
8978
|
+
const path = entry.filename.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
|
|
8831
8979
|
const name = path.pop();
|
|
8832
8980
|
path.forEach(pathPart => {
|
|
8833
8981
|
const previousParent = parent;
|
|
@@ -9202,6 +9350,39 @@ function detach(entry) {
|
|
|
9202
9350
|
}
|
|
9203
9351
|
}
|
|
9204
9352
|
|
|
9353
|
+
function forwardAbort(signal, abortController) {
|
|
9354
|
+
if (!signal) {
|
|
9355
|
+
return () => { };
|
|
9356
|
+
}
|
|
9357
|
+
if (signal.aborted) {
|
|
9358
|
+
abortController.abort(signal.reason);
|
|
9359
|
+
return () => { };
|
|
9360
|
+
}
|
|
9361
|
+
const abort = () => abortController.abort(signal.reason);
|
|
9362
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
9363
|
+
return () => signal.removeEventListener("abort", abort);
|
|
9364
|
+
}
|
|
9365
|
+
|
|
9366
|
+
function isExportAborted(error) {
|
|
9367
|
+
return Boolean(error) && error.message == ERR_ABORT_EXPORT;
|
|
9368
|
+
}
|
|
9369
|
+
|
|
9370
|
+
function aggregateEntryErrors(errors) {
|
|
9371
|
+
const [error] = errors;
|
|
9372
|
+
const otherErrors = errors
|
|
9373
|
+
.slice(1)
|
|
9374
|
+
.flatMap(otherError => [otherError, ...(otherError && otherError.entryErrors || [])])
|
|
9375
|
+
.filter(otherError => otherError !== error);
|
|
9376
|
+
if (otherErrors.length) {
|
|
9377
|
+
try {
|
|
9378
|
+
error.entryErrors = [...(error.entryErrors || []), ...otherErrors];
|
|
9379
|
+
} catch {
|
|
9380
|
+
// ignored
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
return error;
|
|
9384
|
+
}
|
|
9385
|
+
|
|
9205
9386
|
function getUserExtraField(extraField) {
|
|
9206
9387
|
if (extraField) {
|
|
9207
9388
|
const userExtraField = new Map();
|
|
@@ -9322,8 +9503,9 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
|
9322
9503
|
function addFileSystemHandle(zipEntry, handle, options) {
|
|
9323
9504
|
return addFile(zipEntry, handle, []);
|
|
9324
9505
|
|
|
9325
|
-
async function addFile(parentEntry, handle, addedEntries) {
|
|
9506
|
+
async function addFile(parentEntry, handle, addedEntries, parentName = "") {
|
|
9326
9507
|
if (handle) {
|
|
9508
|
+
const entryName = parentName ? parentName + "/" + handle.name : handle.name;
|
|
9327
9509
|
try {
|
|
9328
9510
|
if (handle.isFile || handle.isDirectory) {
|
|
9329
9511
|
handle = await transformToFileSystemhandle(handle);
|
|
@@ -9345,12 +9527,18 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
9345
9527
|
const directoryEntry = parentEntry.addDirectory(handle.name);
|
|
9346
9528
|
addedEntries.push(directoryEntry);
|
|
9347
9529
|
for await (const childHandle of handle.values()) {
|
|
9348
|
-
await addFile(directoryEntry, childHandle, addedEntries);
|
|
9530
|
+
await addFile(directoryEntry, childHandle, addedEntries, entryName);
|
|
9349
9531
|
}
|
|
9350
9532
|
}
|
|
9351
9533
|
} catch (error) {
|
|
9352
|
-
|
|
9353
|
-
|
|
9534
|
+
try {
|
|
9535
|
+
if (error.entryName === UNDEFINED_VALUE) {
|
|
9536
|
+
error.entryName = entryName;
|
|
9537
|
+
}
|
|
9538
|
+
} catch {
|
|
9539
|
+
// ignored
|
|
9540
|
+
}
|
|
9541
|
+
throw error;
|
|
9354
9542
|
}
|
|
9355
9543
|
}
|
|
9356
9544
|
return addedEntries;
|
|
@@ -9360,15 +9548,32 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
9360
9548
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
9361
9549
|
const totalSize = getTotalSize([zipEntry], "uncompressedSize");
|
|
9362
9550
|
const writtenSizes = new Map();
|
|
9363
|
-
|
|
9551
|
+
const abortController = new AbortController();
|
|
9552
|
+
const { signal } = abortController;
|
|
9553
|
+
const releaseSignal = forwardAbort(options.signal, abortController);
|
|
9554
|
+
const exportedEntryNames = [];
|
|
9555
|
+
try {
|
|
9556
|
+
await exportChildren(zipEntry, directoryHandle);
|
|
9557
|
+
} catch (error) {
|
|
9558
|
+
try {
|
|
9559
|
+
error.exportedEntryNames = exportedEntryNames;
|
|
9560
|
+
} catch {
|
|
9561
|
+
// ignored
|
|
9562
|
+
}
|
|
9563
|
+
throw error;
|
|
9564
|
+
} finally {
|
|
9565
|
+
releaseSignal();
|
|
9566
|
+
}
|
|
9364
9567
|
return directoryHandle;
|
|
9365
9568
|
|
|
9366
9569
|
async function exportChildren(entry, parentHandle) {
|
|
9367
9570
|
if (options.concurrent) {
|
|
9368
9571
|
const results = await Promise.allSettled(entry.children.map(child => exportChild(child, parentHandle)));
|
|
9369
|
-
const
|
|
9370
|
-
if (
|
|
9371
|
-
|
|
9572
|
+
const rejectedResults = results.filter(result => result.status == "rejected");
|
|
9573
|
+
if (rejectedResults.length) {
|
|
9574
|
+
const failedResults = rejectedResults.filter(result => !isExportAborted(result.reason));
|
|
9575
|
+
const reportedResults = failedResults.length ? failedResults : rejectedResults;
|
|
9576
|
+
throw aggregateEntryErrors(reportedResults.map(result => result.reason));
|
|
9372
9577
|
}
|
|
9373
9578
|
} else {
|
|
9374
9579
|
for (const child of entry.children) {
|
|
@@ -9378,6 +9583,12 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9378
9583
|
}
|
|
9379
9584
|
|
|
9380
9585
|
async function exportChild(child, parentHandle) {
|
|
9586
|
+
if (signal.aborted) {
|
|
9587
|
+
if (isExportAborted(signal.reason)) {
|
|
9588
|
+
return;
|
|
9589
|
+
}
|
|
9590
|
+
throw signal.reason;
|
|
9591
|
+
}
|
|
9381
9592
|
try {
|
|
9382
9593
|
if (child.directory) {
|
|
9383
9594
|
const childDirectoryHandle = await parentHandle.getDirectoryHandle(child.name, { create: true });
|
|
@@ -9386,6 +9597,7 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9386
9597
|
const fileHandle = await parentHandle.getFileHandle(child.name, { create: true });
|
|
9387
9598
|
const writable = await fileHandle.createWritable();
|
|
9388
9599
|
await child.getData({ writable }, Object.assign({}, options, {
|
|
9600
|
+
signal,
|
|
9389
9601
|
onprogress: async progress => {
|
|
9390
9602
|
if (options.onprogress) {
|
|
9391
9603
|
writtenSizes.set(child.id, progress);
|
|
@@ -9397,9 +9609,19 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9397
9609
|
}
|
|
9398
9610
|
}
|
|
9399
9611
|
}));
|
|
9612
|
+
exportedEntryNames.push(child.getRelativeName(zipEntry));
|
|
9400
9613
|
}
|
|
9401
9614
|
} catch (error) {
|
|
9402
|
-
|
|
9615
|
+
abortController.abort(new Error(ERR_ABORT_EXPORT));
|
|
9616
|
+
try {
|
|
9617
|
+
if (error.entryName === UNDEFINED_VALUE) {
|
|
9618
|
+
error.entryName = child.getRelativeName(zipEntry);
|
|
9619
|
+
error.entryId = child.id;
|
|
9620
|
+
}
|
|
9621
|
+
} catch {
|
|
9622
|
+
// ignored
|
|
9623
|
+
}
|
|
9624
|
+
throw error;
|
|
9403
9625
|
}
|
|
9404
9626
|
}
|
|
9405
9627
|
}
|
|
@@ -9602,12 +9824,17 @@ exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
|
9602
9824
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|
|
9603
9825
|
exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
|
|
9604
9826
|
exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
|
|
9827
|
+
exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
|
|
9605
9828
|
exports.ERR_INVALID_GID = ERR_INVALID_GID;
|
|
9829
|
+
exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
|
|
9830
|
+
exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
|
|
9606
9831
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
9607
9832
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
9608
9833
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
9834
|
+
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
9609
9835
|
exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
|
|
9610
9836
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
9837
|
+
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|
|
9611
9838
|
exports.ERR_INVALID_UID = ERR_INVALID_UID;
|
|
9612
9839
|
exports.ERR_INVALID_UNCOMPRESSED_SIZE = ERR_INVALID_UNCOMPRESSED_SIZE;
|
|
9613
9840
|
exports.ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = ERR_INVALID_UNIX_EXTRA_FIELD_TYPE;
|
|
@@ -9622,6 +9849,7 @@ exports.ERR_RESERVED_COMPRESSION_METHOD = ERR_RESERVED_COMPRESSION_METHOD;
|
|
|
9622
9849
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
9623
9850
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
9624
9851
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
9852
|
+
exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
|
|
9625
9853
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
|
|
9626
9854
|
exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
|
|
9627
9855
|
exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
|