client-zip
Advanced tools
+4
-0
@@ -0,1 +1,5 @@ | ||
| ## 1.7.0: | ||
| * new: `mode` field in input objects can override the default POSIX file mode. | ||
| ## 1.6.5: | ||
@@ -2,0 +6,0 @@ |
+4
-4
@@ -6,12 +6,12 @@ type BufferLike = ArrayBuffer | string | ArrayBufferView | Blob | ||
| * extra arguments can be given to override the input’s metadata. */ | ||
| type InputWithMeta = File | Response | { input: File | Response, name?: any, lastModified?: any, size?: number } | ||
| type InputWithMeta = File | Response | { input: File | Response, name?: any, lastModified?: any, size?: number, mode?: number } | ||
| /** Intrinsic size, but the file name must be provided and modification date can’t be guessed. */ | ||
| type InputWithSizeMeta = { input: BufferLike, name: any, lastModified?: any, size?: number } | ||
| type InputWithSizeMeta = { input: BufferLike, name: any, lastModified?: any, size?: number, mode?: number } | ||
| /** The file name must be provided ; modification date and content length can’t be guessed. */ | ||
| type InputWithoutMeta = { input: StreamLike, name: any, lastModified?: any, size?: number } | ||
| type InputWithoutMeta = { input: StreamLike, name: any, lastModified?: any, size?: number, mode?: number } | ||
| /** Both filename and size must be provided ; input is not helpful here. */ | ||
| type JustMeta = { input?: StreamLike | undefined, name: any, lastModified?: any, size: number } | ||
| type JustMeta = { input?: StreamLike | undefined, name: any, lastModified?: any, size: number, mode?: number } | ||
@@ -18,0 +18,0 @@ type ForAwaitable<T> = AsyncIterable<T> | Iterable<T> |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var e=e=>new DataView(new ArrayBuffer(e)),n=e=>new Uint8Array(e.buffer||e),t=e=>(new TextEncoder).encode(String(e));function r(e,r){if(void 0===r||r instanceof Date||(r=new Date(r)),e instanceof File)return{t:r||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:r||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(void 0===r)r=new Date;else if(isNaN(r))throw new Error("Invalid modification date.");if("string"==typeof e)return{t:r,o:t(e)};if(e instanceof Blob)return{t:r,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t:r,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t:r,o:n(e)};if(Symbol.asyncIterator in e)return{t:r,o:o(e[Symbol.asyncIterator]())};throw new TypeError("Unsupported input format.")}function o(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const r=await e.next();if(!r.value){n.close();break}{const e=i(r.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){var t;null==(t=n.throw)||t.call(n,e)}})}function i(e){return"string"==typeof e?t(e):e instanceof Uint8Array?e:n(e)}function a(e,r,o){let[i,a]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[n(e),1]:[t(e),0]:[void 0,0]}(r);if(e instanceof File)return{i:s(i||t(e.name)),u:e.size,l:a};if(e instanceof Response){const n=e.headers.get("content-disposition"),r=n&&n.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),f=r&&r[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),u=f&&decodeURIComponent(f),d=o||+e.headers.get("content-length");return{i:s(i||t(u)),u:d,l:a}}return i=s(i),"string"==typeof e?{i,u:t(e).length,l:a}:e instanceof Blob?{i,u:e.size,l:a}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i,u:e.byteLength,l:a}:{i,u:f(e,o),l:a}}function f(e,n){return n>-1?n:e?void 0:0}function s(e){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");for(;47===e[e.length-1];)e=e.subarray(0,-1);return e}var u=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);u[e]=n}function d(e,n=0){n^=-1;for(var t=0,r=e.length;t<r;t++)n=n>>>8^u[255&n^e[t]];return(-1^n)>>>0}function l(e,n,t=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,o=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,r,1),n.setUint16(t+2,o,1)}function y({i:e,l:n},t){return 8*(!n||(null!=t?t:function(e){try{w.decode(e)}catch(e){return 0}return 1}(e)))}var w=new TextDecoder("utf8",{fatal:1});function p(t,r=0){const o=e(30);return o.setUint32(0,1347093252),o.setUint32(4,335546368|r),l(t.t,o,10),o.setUint16(26,t.i.length,1),n(o)}async function*b(e){let{o:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.m=d(n,0),e.u=n.length;else{e.u=0;const t=n.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e.m=d(n,e.m),e.u+=n.length,yield n}}}function v(t){const r=e(16);return r.setUint32(0,1347094280),r.setUint32(4,t.m,1),r.setUint32(8,t.u,1),r.setUint32(12,t.u,1),n(r)}function B(t,r,o=0){const i=e(46);return i.setUint32(0,1347092738),i.setUint32(4,352523264),i.setUint16(8,2048|o),l(t.t,i,12),i.setUint32(16,t.m,1),i.setUint32(20,t.u,1),i.setUint32(24,t.u,1),i.setUint16(28,t.i.length,1),i.setUint16(40,33204,1),i.setUint32(42,r,1),n(i)}function D(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}var h=e=>function(e){var n;let t=22;for(const r of e){if(!r.i)throw new Error("Every file must have a non-empty name.");if(isNaN(null!=(n=r.u)?n:NaN))throw new Error(`Missing size for file "${(new TextDecoder).decode(r.i)}".`);t+=2*r.i.length+r.u+92}return t}(function*(e){for(const n of e)yield a(...D(n)[0])}(e));function S(t,i={}){const f={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(i.length)&&i.length>0&&(f["Content-Length"]=i.length),i.metadata&&(f["Content-Length"]=h(i.metadata));const s=function(e){var n;const t=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await t.next();if(e.done)return e;const[n,o]=D(e.value);return{done:0,value:Object.assign(r(...o),a(...n))}},throw:null==(n=t.throw)?void 0:n.bind(t),[Symbol.asyncIterator](){return this}}}(t);return new Response(o(async function*(t,r){const o=[];let i=0,a=0;for await(const e of t){const n=y(e,r.buffersAreUTF8);yield p(e,n),yield new Uint8Array(e.i),yield*b(e),yield v(e),o.push(B(e,i,n)),o.push(e.i),a++,i+=46+e.i.length+e.u}let f=0;for(const e of o)yield e,f+=e.length;const s=e(22);s.setUint32(0,1347093766),s.setUint16(8,a,1),s.setUint16(10,a,1),s.setUint32(12,f,1),s.setUint32(16,i,1),yield n(s)}(s,i),s),{headers:f})}export{S as downloadZip,h as predictLength}; | ||
| "stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var e=e=>new DataView(new ArrayBuffer(e)),n=e=>new Uint8Array(e.buffer||e),t=e=>(new TextEncoder).encode(String(e));function r(e,r,i=436){if(void 0===r||r instanceof Date||(r=new Date(r)),e instanceof File)return{t:r||new Date(e.lastModified),bytes:e.stream(),mode:i};if(e instanceof Response)return{t:r||new Date(e.headers.get("Last-Modified")||Date.now()),bytes:e.body,mode:i};if(void 0===r)r=new Date;else if(isNaN(r))throw new Error("Invalid modification date.");if("string"==typeof e)return{t:r,bytes:t(e),mode:i};if(e instanceof Blob)return{t:r,bytes:e.stream(),mode:i};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t:r,bytes:e,mode:i};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t:r,bytes:n(e),mode:i};if(Symbol.asyncIterator in e)return{t:r,bytes:o(e[Symbol.asyncIterator]()),mode:i};throw new TypeError("Unsupported input format.")}function o(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const r=await e.next();if(!r.value){n.close();break}{const e=i(r.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){var t;null==(t=n.throw)||t.call(n,e)}})}function i(e){return"string"==typeof e?t(e):e instanceof Uint8Array?e:n(e)}function a(e,r,o){let[i,a]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[n(e),1]:[t(e),0]:[void 0,0]}(r);if(e instanceof File)return{o:s(i||t(e.name)),i:e.size,u:a};if(e instanceof Response){const n=e.headers.get("content-disposition"),r=n&&n.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),f=r&&r[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),u=f&&decodeURIComponent(f),d=o||+e.headers.get("content-length");return{o:s(i||t(u)),i:d,u:a}}return i=s(i),"string"==typeof e?{o:i,i:t(e).length,u:a}:e instanceof Blob?{o:i,i:e.size,u:a}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:i,i:e.byteLength,u:a}:{o:i,i:f(e,o),u:a}}function f(e,n){return n>-1?n:e?void 0:0}function s(e){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");for(;47===e[e.length-1];)e=e.subarray(0,-1);return e}var u=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);u[e]=n}function d(e,n=0){n=~n;for(var t=0,r=e.length;t<r;t++)n=n>>>8^u[255&n^e[t]];return~n>>>0}function l(e,n,t=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,o=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,r,1),n.setUint16(t+2,o,1)}function y({o:e,u:n},t){return 8*(!n||(null!=t?t:function(e){try{w.decode(e)}catch(e){return 0}return 1}(e)))}var w=new TextDecoder("utf8",{fatal:1});function p(t,r=0){const o=e(30);return o.setUint32(0,1347093252),o.setUint32(4,335546368|r),l(t.t,o,10),o.setUint16(26,t.o.length,1),n(o)}async function*b(e){let{bytes:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.l=d(n,0),e.i=n.length;else{e.i=0;const t=n.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e.l=d(n,e.l),e.i+=n.length,yield n}}}function v(t){const r=e(16);return r.setUint32(0,1347094280),r.setUint32(4,t.l,1),r.setUint32(8,t.i,1),r.setUint32(12,t.i,1),n(r)}function B(t,r,o=0){const i=e(46);return i.setUint32(0,1347092738),i.setUint32(4,352523264),i.setUint16(8,2048|o),l(t.t,i,12),i.setUint32(16,t.l,1),i.setUint32(20,t.i,1),i.setUint32(24,t.i,1),i.setUint16(28,t.o.length,1),i.setUint16(40,32768|t.mode,1),i.setUint32(42,r,1),n(i)}function D(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified,e.mode]]}var h=e=>function(e){var n;let t=22;for(const r of e){if(!r.o)throw new Error("Every file must have a non-empty name.");if(isNaN(null!=(n=r.i)?n:NaN))throw new Error(`Missing size for file "${(new TextDecoder).decode(r.o)}".`);t+=2*r.o.length+r.i+92}return t}(function*(e){for(const n of e)yield a(...D(n)[0])}(e));function S(t,i={}){const f={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(i.length)&&i.length>0&&(f["Content-Length"]=i.length),i.metadata&&(f["Content-Length"]=h(i.metadata));const s=function(e){var n;const t=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await t.next();if(e.done)return e;const[n,o]=D(e.value);return{done:0,value:Object.assign(r(...o),a(...n))}},throw:null==(n=t.throw)?void 0:n.bind(t),[Symbol.asyncIterator](){return this}}}(t);return new Response(o(async function*(t,r){const o=[];let i=0,a=0;for await(const e of t){const n=y(e,r.buffersAreUTF8);yield p(e,n),yield new Uint8Array(e.o),yield*b(e),yield v(e),o.push(B(e,i,n)),o.push(e.o),a++,i+=46+e.o.length+e.i}let f=0;for(const e of o)yield e,f+=e.length;const s=e(22);s.setUint32(0,1347093766),s.setUint16(8,a,1),s.setUint16(10,a,1),s.setUint32(12,f,1),s.setUint32(16,i,1),yield n(s)}(s,i),s),{headers:f})}export{S as downloadZip,h as predictLength}; |
+3
-3
| { | ||
| "name": "client-zip", | ||
| "version": "1.6.5", | ||
| "version": "1.7.0", | ||
| "description": "A tiny and fast client-side streaming ZIP generator", | ||
@@ -30,5 +30,5 @@ "browser": "index.js", | ||
| "devDependencies": { | ||
| "esbuild": "^0.17.19", | ||
| "terser": "~5.14" | ||
| "esbuild": "^0.25.1", | ||
| "terser": "~5.39" | ||
| } | ||
| } |
+6
-5
@@ -10,3 +10,3 @@  | ||
| `client-zip` is lightweight (4.8 kB minified, 2.1 kB gzipped), dependency-free, and 40 times faster than the old JSZip. | ||
| `client-zip` is lightweight (4.9 kB minified, 2.2 kB gzipped), dependency-free, and 40 times faster than the old JSZip. | ||
@@ -75,2 +75,3 @@ * [Quick Start](#Quick-Start) | ||
| - `input`: something that contains your data; it can be a `File`, a `Blob`, a `Response`, some kind of `ArrayView` or a raw `ArrayBuffer`, a `ReadableStream<Uint8Array>` (yes, only Uint8Arrays, but most APIs give you just that type anyway), an `AsyncIterable<ArrayBuffer | ArrayView | string>`, … or just a string. | ||
| - `mode`: override the POSIX file mode (by default, it will be `0o664`). Should be between `0` and `0o777` — disrespect that constraint at your own risk. | ||
@@ -153,6 +154,6 @@ The *options* argument currently supports three properties, `length`, `metadata` (see [Content-Length prediction](#content-length-prediction)) and `buffersAreUTF8` (see [Filename encoding](#filename-encoding)). | ||
| | | `client-zip`@1.6.5 | fflate@0.7.4 | zip.js@2.7.14 | conflux@4.0.3 | JSZip@3.10.1 | | ||
| | | `client-zip`@1.7.0 | fflate@0.7.4 | zip.js@2.7.14 | conflux@4.0.3 | JSZip@3.10.1 | | ||
| |--------------------|-------------------:|-------------:|--------------:|--------------:|--------------:| | ||
| | minified | 4.8 kB | 29.8 kB | 163.2 kB | 198.8 kB | 94.9 kB | | ||
| | minified + gzipped | 2.1 kB | 11 kB | 58 kB | 56.6 kB | 27.6 kB | | ||
| | minified | 4.9 kB | 29.8 kB | 163.2 kB | 198.8 kB | 94.9 kB | | ||
| | minified + gzipped | 2.2 kB | 11 kB | 58 kB | 56.6 kB | 27.6 kB | | ||
@@ -177,3 +178,3 @@ The datasets I used in the new tests are not public domain, but nothing sensitive either ; I can send them if you ask. | ||
| The UNIX permissions in external attributes (ignored by many readers, though) are hardcoded to 664, could be made configurable. | ||
| <del>Configurable UNIX permissions in external attributes.</del> The UNIX permissions are now configurable (since 1.7.0) via the `mode` field, set by default to 664 for files. | ||
@@ -180,0 +181,0 @@ ### ZIP64 |
+1
-1
@@ -1,1 +0,1 @@ | ||
| var downloadZip=(()=>{"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var i=e=>new DataView(new ArrayBuffer(e)),a=e=>new Uint8Array(e.buffer||e),f=e=>(new TextEncoder).encode(String(e));function s(e,n){if(void 0===n||n instanceof Date||(n=new Date(n)),e instanceof File)return{t:n||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:n||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(void 0===n)n=new Date;else if(isNaN(n))throw new Error("Invalid modification date.");if("string"==typeof e)return{t:n,o:f(e)};if(e instanceof Blob)return{t:n,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t:n,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t:n,o:a(e)};if(Symbol.asyncIterator in e)return{t:n,o:u(e[Symbol.asyncIterator]())};throw new TypeError("Unsupported input format.")}function u(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const r=await e.next();if(!r.value){n.close();break}{const e=l(r.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){var t;null==(t=n.throw)||t.call(n,e)}})}function l(e){return"string"==typeof e?f(e):e instanceof Uint8Array?e:a(e)}function d(e,n,t){let[r,o]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[a(e),1]:[f(e),0]:[void 0,0]}(n);if(e instanceof File)return{i:w(r||f(e.name)),u:e.size,l:o};if(e instanceof Response){const n=e.headers.get("content-disposition"),i=n&&n.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),a=i&&i[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),s=a&&decodeURIComponent(a),u=t||+e.headers.get("content-length");return{i:w(r||f(s)),u,l:o}}return r=w(r),"string"==typeof e?{i:r,u:f(e).length,l:o}:e instanceof Blob?{i:r,u:e.size,l:o}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:r,u:e.byteLength,l:o}:{i:r,u:y(e,t),l:o}}function y(e,n){return n>-1?n:e?void 0:0}function w(e){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");for(;47===e[e.length-1];)e=e.subarray(0,-1);return e}var b=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);b[e]=n}function p(e,n=0){n^=-1;for(var t=0,r=e.length;t<r;t++)n=n>>>8^b[255&n^e[t]];return(-1^n)>>>0}function v(e,n,t=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,o=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,r,1),n.setUint16(t+2,o,1)}function B({i:e,l:n},t){return 8*(!n||(null!=t?t:function(e){try{D.decode(e)}catch(e){return 0}return 1}(e)))}var D=new TextDecoder("utf8",{fatal:1});function h(e,n=0){const t=i(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368|n),v(e.t,t,10),t.setUint16(26,e.i.length,1),a(t)}async function*S(e){let{o:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.m=p(n,0),e.u=n.length;else{e.u=0;const t=n.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e.m=p(n,e.m),e.u+=n.length,yield n}}}function A(e){const n=i(16);return n.setUint32(0,1347094280),n.setUint32(4,e.m,1),n.setUint32(8,e.u,1),n.setUint32(12,e.u,1),a(n)}function N(e,n,t=0){const r=i(46);return r.setUint32(0,1347092738),r.setUint32(4,352523264),r.setUint16(8,2048|t),v(e.t,r,12),r.setUint32(16,e.m,1),r.setUint32(20,e.u,1),r.setUint32(24,e.u,1),r.setUint16(28,e.i.length,1),r.setUint16(40,33204,1),r.setUint32(42,n,1),a(r)}function U(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}var I=e=>function(e){var n;let t=22;for(const r of e){if(!r.i)throw new Error("Every file must have a non-empty name.");if(isNaN(null!=(n=r.u)?n:NaN))throw new Error(`Missing size for file "${(new TextDecoder).decode(r.i)}".`);t+=2*r.i.length+r.u+92}return t}(function*(e){for(const n of e)yield d(...U(n)[0])}(e));return function(e,n={}){const t={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(n.length)&&n.length>0&&(t["Content-Length"]=n.length),n.metadata&&(t["Content-Length"]=I(n.metadata));const r=function(e){var n;const t=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await t.next();if(e.done)return e;const[n,r]=U(e.value);return{done:0,value:Object.assign(s(...r),d(...n))}},throw:null==(n=t.throw)?void 0:n.bind(t),[Symbol.asyncIterator](){return this}}}(e);return new Response(u(async function*(e,n){const t=[];let r=0,o=0;for await(const i of e){const e=B(i,n.buffersAreUTF8);yield h(i,e),yield new Uint8Array(i.i),yield*S(i),yield A(i),t.push(N(i,r,e)),t.push(i.i),o++,r+=46+i.i.length+i.u}let f=0;for(const e of t)yield e,f+=e.length;const s=i(22);s.setUint32(0,1347093766),s.setUint16(8,o,1),s.setUint16(10,o,1),s.setUint32(12,f,1),s.setUint32(16,r,1),yield a(s)}(r,n),r),{headers:t})}})(); | ||
| var downloadZip=(()=>{"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var i=e=>new DataView(new ArrayBuffer(e)),a=e=>new Uint8Array(e.buffer||e),f=e=>(new TextEncoder).encode(String(e));function s(e,n,t=436){if(void 0===n||n instanceof Date||(n=new Date(n)),e instanceof File)return{t:n||new Date(e.lastModified),bytes:e.stream(),mode:t};if(e instanceof Response)return{t:n||new Date(e.headers.get("Last-Modified")||Date.now()),bytes:e.body,mode:t};if(void 0===n)n=new Date;else if(isNaN(n))throw new Error("Invalid modification date.");if("string"==typeof e)return{t:n,bytes:f(e),mode:t};if(e instanceof Blob)return{t:n,bytes:e.stream(),mode:t};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t:n,bytes:e,mode:t};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t:n,bytes:a(e),mode:t};if(Symbol.asyncIterator in e)return{t:n,bytes:u(e[Symbol.asyncIterator]()),mode:t};throw new TypeError("Unsupported input format.")}function u(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const r=await e.next();if(!r.value){n.close();break}{const e=d(r.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){var t;null==(t=n.throw)||t.call(n,e)}})}function d(e){return"string"==typeof e?f(e):e instanceof Uint8Array?e:a(e)}function l(e,n,t){let[r,o]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[a(e),1]:[f(e),0]:[void 0,0]}(n);if(e instanceof File)return{o:w(r||f(e.name)),i:e.size,u:o};if(e instanceof Response){const n=e.headers.get("content-disposition"),i=n&&n.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),a=i&&i[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),s=a&&decodeURIComponent(a),u=t||+e.headers.get("content-length");return{o:w(r||f(s)),i:u,u:o}}return r=w(r),"string"==typeof e?{o:r,i:f(e).length,u:o}:e instanceof Blob?{o:r,i:e.size,u:o}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:r,i:e.byteLength,u:o}:{o:r,i:y(e,t),u:o}}function y(e,n){return n>-1?n:e?void 0:0}function w(e){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");for(;47===e[e.length-1];)e=e.subarray(0,-1);return e}var b=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);b[e]=n}function p(e,n=0){n=~n;for(var t=0,r=e.length;t<r;t++)n=n>>>8^b[255&n^e[t]];return~n>>>0}function v(e,n,t=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,o=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,r,1),n.setUint16(t+2,o,1)}function B({o:e,u:n},t){return 8*(!n||(null!=t?t:function(e){try{D.decode(e)}catch(e){return 0}return 1}(e)))}var D=new TextDecoder("utf8",{fatal:1});function h(e,n=0){const t=i(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368|n),v(e.t,t,10),t.setUint16(26,e.o.length,1),a(t)}async function*S(e){let{bytes:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.l=p(n,0),e.i=n.length;else{e.i=0;const t=n.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e.l=p(n,e.l),e.i+=n.length,yield n}}}function A(e){const n=i(16);return n.setUint32(0,1347094280),n.setUint32(4,e.l,1),n.setUint32(8,e.i,1),n.setUint32(12,e.i,1),a(n)}function N(e,n,t=0){const r=i(46);return r.setUint32(0,1347092738),r.setUint32(4,352523264),r.setUint16(8,2048|t),v(e.t,r,12),r.setUint32(16,e.l,1),r.setUint32(20,e.i,1),r.setUint32(24,e.i,1),r.setUint16(28,e.o.length,1),r.setUint16(40,32768|e.mode,1),r.setUint32(42,n,1),a(r)}function U(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified,e.mode]]}var I=e=>function(e){var n;let t=22;for(const r of e){if(!r.o)throw new Error("Every file must have a non-empty name.");if(isNaN(null!=(n=r.i)?n:NaN))throw new Error(`Missing size for file "${(new TextDecoder).decode(r.o)}".`);t+=2*r.o.length+r.i+92}return t}(function*(e){for(const n of e)yield l(...U(n)[0])}(e));return function(e,n={}){const t={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(n.length)&&n.length>0&&(t["Content-Length"]=n.length),n.metadata&&(t["Content-Length"]=I(n.metadata));const r=function(e){var n;const t=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await t.next();if(e.done)return e;const[n,r]=U(e.value);return{done:0,value:Object.assign(s(...r),l(...n))}},throw:null==(n=t.throw)?void 0:n.bind(t),[Symbol.asyncIterator](){return this}}}(e);return new Response(u(async function*(e,n){const t=[];let r=0,o=0;for await(const i of e){const e=B(i,n.buffersAreUTF8);yield h(i,e),yield new Uint8Array(i.o),yield*S(i),yield A(i),t.push(N(i,r,e)),t.push(i.o),o++,r+=46+i.o.length+i.i}let f=0;for(const e of t)yield e,f+=e.length;const s=i(22);s.setUint32(0,1347093766),s.setUint16(8,o,1),s.setUint16(10,o,1),s.setUint32(12,f,1),s.setUint32(16,r,1),yield a(s)}(r,n),r),{headers:t})}})(); |
35853
1.58%206
0.49%