UNPKG

@digital-blueprint/dispatch-app

Version:

[GitHub Repository](https://github.com/digital-blueprint/dispatch-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/dispatch-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/dispatch-app/) | [Dispatch Bundle](https://gi

1 lines 6.43 kB
var downloadZip=(()=>{"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}}),"setBigUint64"in DataView.prototype||Object.defineProperty(DataView.prototype,"setBigUint64",{value(e,n,t){const r=Number(0xffffffffn&n),i=Number(n>>32n);this.setUint32(e+(t?0:4),r,t),this.setUint32(e+(t?4:0),i,t)}});var o=e=>new DataView(new ArrayBuffer(e)),f=e=>new Uint8Array(e.buffer||e),a=e=>(new TextEncoder).encode(String(e)),s=e=>Math.min(4294967295,Number(e)),u=e=>Math.min(65535,Number(e));function d(e,n,t){void 0===n||n instanceof Date||(n=new Date(n));const r=void 0!==e;if(t||(t=r?436:509),e instanceof File)return{isFile:r,t:n||new Date(e.lastModified),bytes:e.stream(),mode:t};if(e instanceof Response)return{isFile:r,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(!r)return{isFile:r,t:n,mode:t};if("string"==typeof e)return{isFile:r,t:n,bytes:a(e),mode:t};if(e instanceof Blob)return{isFile:r,t:n,bytes:e.stream(),mode:t};if(e instanceof Uint8Array||e instanceof ReadableStream)return{isFile:r,t:n,bytes:e,mode:t};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{isFile:r,t:n,bytes:f(e),mode:t};if(Symbol.asyncIterator in e)return{isFile:r,t:n,bytes:l(e[Symbol.asyncIterator]()),mode:t};throw new TypeError("Unsupported input format.")}function l(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=y(r.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){n.throw?.(e)}})}function y(e){return"string"==typeof e?a(e):e instanceof Uint8Array?e:f(e)}function b(e,n,t){let[r,i]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[f(e),1]:[a(e),0]:[void 0,0]}(n);if(e instanceof File)return{i:B(r||a(e.name)),o:BigInt(e.size),u:i};if(e instanceof Response){const n=e.headers.get("content-disposition"),o=n&&n.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),f=o&&o[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),s=f&&decodeURIComponent(f),u=t||+e.headers.get("content-length");return{i:B(r||a(s)),o:BigInt(u),u:i}}return r=B(r,void 0!==e||void 0!==t),"string"==typeof e?{i:r,o:BigInt(a(e).length),u:i}:e instanceof Blob?{i:r,o:BigInt(e.size),u:i}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:r,o:BigInt(e.byteLength),u:i}:{i:r,o:w(e,t),u:i}}function w(e,n){return n>-1?BigInt(n):e?void 0:0n}function B(e,n=1){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");if(n)for(;47===e[e.length-1];)e=e.subarray(0,-1);else 47!==e[e.length-1]&&(e=new Uint8Array([...e,47]));return e}var p=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);p[e]=n}function g(e,n=0){n=~n;for(var t=0,r=e.length;t<r;t++)n=n>>>8^p[255&n^e[t]];return~n>>>0}function v(e,n,t=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,i=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,r,1),n.setUint16(t+2,i,1)}function I({i:e,u:n},t){return 8*(!n||(t??function(e){try{h.decode(e)}catch{return 0}return 1}(e)))}var h=new TextDecoder("utf8",{fatal:1});function D(e,n=0){const t=o(30);return t.setUint32(0,1347093252),t.setUint32(4,754976768|n),v(e.t,t,10),t.setUint16(26,e.i.length,1),f(t)}async function*S(e){let{bytes:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.l=g(n,0),e.o=BigInt(n.length);else{e.o=0n;const t=n.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e.l=g(n,e.l),e.o+=BigInt(n.length),yield n}}}function A(e,n){const t=o(16+(n?8:0));return t.setUint32(0,1347094280),t.setUint32(4,e.isFile?e.l:0,1),n?(t.setBigUint64(8,e.o,1),t.setBigUint64(16,e.o,1)):(t.setUint32(8,s(e.o),1),t.setUint32(12,s(e.o),1)),f(t)}function N(e,n,t=0,r=0){const i=o(46);return i.setUint32(0,1347092738),i.setUint32(4,755182848),i.setUint16(8,2048|t),v(e.t,i,12),i.setUint32(16,e.isFile?e.l:0,1),i.setUint32(20,s(e.o),1),i.setUint32(24,s(e.o),1),i.setUint16(28,e.i.length,1),i.setUint16(30,r,1),i.setUint16(40,e.mode|(e.isFile?32768:16384),1),i.setUint32(42,s(n),1),f(i)}function U(e,n,t){const r=o(t);return r.setUint16(0,1,1),r.setUint16(2,t-4,1),16&t&&(r.setBigUint64(4,e.o,1),r.setBigUint64(12,e.o,1)),r.setBigUint64(t-8,n,1),f(r)}function F(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified,e.mode]]}var x=e=>function(e){let n=BigInt(22),t=0n,r=0;for(const i of e){if(!i.i)throw new Error("Every file must have a non-empty name.");if(void 0===i.o)throw new Error(`Missing size for file "${(new TextDecoder).decode(i.i)}".`);const e=i.o>=0xffffffffn,o=t>=0xffffffffn;t+=BigInt(46+i.i.length+(e&&8))+i.o,n+=BigInt(i.i.length+46+(12*o|28*e)),r||(r=e)}return(r||t>=0xffffffffn)&&(n+=BigInt(76)),n+t}(function*(e){for(const n of e)yield b(...F(n)[0])}(e));return function(e,n={}){const t={"Content-Type":"application/zip","Content-Disposition":"attachment"};return("bigint"==typeof n.length||Number.isInteger(n.length))&&n.length>0&&(t["Content-Length"]=String(n.length)),n.metadata&&(t["Content-Length"]=String(x(n.metadata))),new Response(function(e,n={}){const t=function(e){const n=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await n.next();if(e.done)return e;const[t,r]=F(e.value);return{done:0,value:Object.assign(d(...r),b(...t))}},throw:n.throw?.bind(n),[Symbol.asyncIterator](){return this}}}(e);return l(async function*(e,n){const t=[];let r=0n,i=0n,a=0;for await(const o of e){const e=I(o,n.buffersAreUTF8);yield D(o,e),yield new Uint8Array(o.i),o.isFile&&(yield*S(o));const f=o.o>=0xffffffffn,s=12*(r>=0xffffffffn)|28*f;yield A(o,f),t.push(N(o,r,e,s)),t.push(o.i),s&&t.push(U(o,r,s)),f&&(r+=8n),i++,r+=BigInt(46+o.i.length)+o.o,a||(a=f)}let d=0n;for(const e of t)yield e,d+=BigInt(e.length);if(a||r>=0xffffffffn){const e=o(76);e.setUint32(0,1347094022),e.setBigUint64(4,BigInt(44),1),e.setUint32(12,755182848),e.setBigUint64(24,i,1),e.setBigUint64(32,i,1),e.setBigUint64(40,d,1),e.setBigUint64(48,r,1),e.setUint32(56,1347094023),e.setBigUint64(64,r+d,1),e.setUint32(72,1,1),yield f(e)}const l=o(22);l.setUint32(0,1347093766),l.setUint16(8,u(i),1),l.setUint16(10,u(i),1),l.setUint32(12,s(d),1),l.setUint32(16,s(r),1),yield f(l)}(t,n),t)}(e,n),{headers:t})}})();