@bluepic/embed 0.4.0-next.84 → 0.4.0-next.85
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/dist/bluepic-embed.iife.js +71 -71
- package/dist/bluepic-embed.umd.js +71 -71
- package/dist/index-CWm6zOv7.js +175 -0
- package/dist/index-DFXQWOGQ.cjs +1 -0
- package/dist/main.cjs +89 -89
- package/dist/main.mjs +17443 -18165
- package/dist/unzipit.module-4zGfAuq6.cjs +1 -0
- package/dist/unzipit.module-qN5XWVVT.js +649 -0
- package/package.json +4 -7
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"stream" in Blob.prototype || Object.defineProperty(Blob.prototype, "stream", { value() {
|
|
2
|
+
return new Response(this).body;
|
|
3
|
+
} }), "setBigUint64" in DataView.prototype || Object.defineProperty(DataView.prototype, "setBigUint64", { value(t, n, e) {
|
|
4
|
+
const i = Number(0xffffffffn & n), o = Number(n >> 32n);
|
|
5
|
+
this.setUint32(t + (e ? 0 : 4), i, e), this.setUint32(t + (e ? 4 : 0), o, e);
|
|
6
|
+
} });
|
|
7
|
+
var U = (t) => new DataView(new ArrayBuffer(t)), u = (t) => new Uint8Array(t.buffer || t), y = (t) => new TextEncoder().encode(String(t)), c = (t) => Math.min(4294967295, Number(t)), B = (t) => Math.min(65535, Number(t));
|
|
8
|
+
function D(t, n, e) {
|
|
9
|
+
n === void 0 || n instanceof Date || (n = new Date(n));
|
|
10
|
+
const i = t !== void 0;
|
|
11
|
+
if (e || (e = i ? 436 : 509), t instanceof File) return { isFile: i, t: n || new Date(t.lastModified), bytes: t.stream(), mode: e };
|
|
12
|
+
if (t instanceof Response) return { isFile: i, t: n || new Date(t.headers.get("Last-Modified") || Date.now()), bytes: t.body, mode: e };
|
|
13
|
+
if (n === void 0) n = /* @__PURE__ */ new Date();
|
|
14
|
+
else if (isNaN(n)) throw new Error("Invalid modification date.");
|
|
15
|
+
if (!i) return { isFile: i, t: n, mode: e };
|
|
16
|
+
if (typeof t == "string") return { isFile: i, t: n, bytes: y(t), mode: e };
|
|
17
|
+
if (t instanceof Blob) return { isFile: i, t: n, bytes: t.stream(), mode: e };
|
|
18
|
+
if (t instanceof Uint8Array || t instanceof ReadableStream) return { isFile: i, t: n, bytes: t, mode: e };
|
|
19
|
+
if (t instanceof ArrayBuffer || ArrayBuffer.isView(t)) return { isFile: i, t: n, bytes: u(t), mode: e };
|
|
20
|
+
if (Symbol.asyncIterator in t) return { isFile: i, t: n, bytes: v(t[Symbol.asyncIterator]()), mode: e };
|
|
21
|
+
throw new TypeError("Unsupported input format.");
|
|
22
|
+
}
|
|
23
|
+
function v(t, n = t) {
|
|
24
|
+
return new ReadableStream({ async pull(e) {
|
|
25
|
+
let i = 0;
|
|
26
|
+
for (; e.desiredSize > i; ) {
|
|
27
|
+
const o = await t.next();
|
|
28
|
+
if (!o.value) {
|
|
29
|
+
e.close();
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
{
|
|
33
|
+
const r = S(o.value);
|
|
34
|
+
e.enqueue(r), i += r.byteLength;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, cancel(e) {
|
|
38
|
+
var i;
|
|
39
|
+
(i = n.throw) == null || i.call(n, e);
|
|
40
|
+
} });
|
|
41
|
+
}
|
|
42
|
+
function S(t) {
|
|
43
|
+
return typeof t == "string" ? y(t) : t instanceof Uint8Array ? t : u(t);
|
|
44
|
+
}
|
|
45
|
+
function I(t, n, e) {
|
|
46
|
+
let [i, o] = function(r) {
|
|
47
|
+
return r ? r instanceof Uint8Array ? [r, 1] : ArrayBuffer.isView(r) || r instanceof ArrayBuffer ? [u(r), 1] : [y(r), 0] : [void 0, 0];
|
|
48
|
+
}(n);
|
|
49
|
+
if (t instanceof File) return { i: p(i || y(t.name)), o: BigInt(t.size), u: o };
|
|
50
|
+
if (t instanceof Response) {
|
|
51
|
+
const r = t.headers.get("content-disposition"), f = r && r.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i), a = f && f[1] || t.url && new URL(t.url).pathname.split("/").findLast(Boolean), l = a && decodeURIComponent(a), d = e || +t.headers.get("content-length");
|
|
52
|
+
return { i: p(i || y(l)), o: BigInt(d), u: o };
|
|
53
|
+
}
|
|
54
|
+
return i = p(i, t !== void 0 || e !== void 0), typeof t == "string" ? { i, o: BigInt(y(t).length), u: o } : t instanceof Blob ? { i, o: BigInt(t.size), u: o } : t instanceof ArrayBuffer || ArrayBuffer.isView(t) ? { i, o: BigInt(t.byteLength), u: o } : { i, o: R(t, e), u: o };
|
|
55
|
+
}
|
|
56
|
+
function R(t, n) {
|
|
57
|
+
return n > -1 ? BigInt(n) : t ? void 0 : 0n;
|
|
58
|
+
}
|
|
59
|
+
function p(t, n = 1) {
|
|
60
|
+
if (!t || t.every((e) => e === 47)) throw new Error("The file must have a name.");
|
|
61
|
+
if (n) for (; t[t.length - 1] === 47; ) t = t.subarray(0, -1);
|
|
62
|
+
else t[t.length - 1] !== 47 && (t = new Uint8Array([...t, 47]));
|
|
63
|
+
return t;
|
|
64
|
+
}
|
|
65
|
+
var F = new Uint32Array(256);
|
|
66
|
+
for (let t = 0; t < 256; ++t) {
|
|
67
|
+
let n = t;
|
|
68
|
+
for (let e = 0; e < 8; ++e) n = n >>> 1 ^ (1 & n && 3988292384);
|
|
69
|
+
F[t] = n;
|
|
70
|
+
}
|
|
71
|
+
function b(t, n = 0) {
|
|
72
|
+
n = ~n;
|
|
73
|
+
for (var e = 0, i = t.length; e < i; e++) n = n >>> 8 ^ F[255 & n ^ t[e]];
|
|
74
|
+
return ~n >>> 0;
|
|
75
|
+
}
|
|
76
|
+
function A(t, n, e = 0) {
|
|
77
|
+
const i = t.getSeconds() >> 1 | t.getMinutes() << 5 | t.getHours() << 11, o = t.getDate() | t.getMonth() + 1 << 5 | t.getFullYear() - 1980 << 9;
|
|
78
|
+
n.setUint16(e, i, 1), n.setUint16(e + 2, o, 1);
|
|
79
|
+
}
|
|
80
|
+
function L({ i: t, u: n }, e) {
|
|
81
|
+
return 8 * (!n || (e ?? function(i) {
|
|
82
|
+
try {
|
|
83
|
+
M.decode(i);
|
|
84
|
+
} catch {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
return 1;
|
|
88
|
+
}(t)));
|
|
89
|
+
}
|
|
90
|
+
var M = new TextDecoder("utf8", { fatal: 1 });
|
|
91
|
+
function N(t, n = 0) {
|
|
92
|
+
const e = U(30);
|
|
93
|
+
return e.setUint32(0, 1347093252), e.setUint32(4, 754976768 | n), A(t.t, e, 10), e.setUint16(26, t.i.length, 1), u(e);
|
|
94
|
+
}
|
|
95
|
+
async function* T(t) {
|
|
96
|
+
let { bytes: n } = t;
|
|
97
|
+
if ("then" in n && (n = await n), n instanceof Uint8Array) yield n, t.l = b(n, 0), t.o = BigInt(n.length);
|
|
98
|
+
else {
|
|
99
|
+
t.o = 0n;
|
|
100
|
+
const e = n.getReader();
|
|
101
|
+
for (; ; ) {
|
|
102
|
+
const { value: i, done: o } = await e.read();
|
|
103
|
+
if (o) break;
|
|
104
|
+
t.l = b(i, t.l), t.o += BigInt(i.length), yield i;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function E(t, n) {
|
|
109
|
+
const e = U(16 + (n ? 8 : 0));
|
|
110
|
+
return e.setUint32(0, 1347094280), e.setUint32(4, t.isFile ? t.l : 0, 1), n ? (e.setBigUint64(8, t.o, 1), e.setBigUint64(16, t.o, 1)) : (e.setUint32(8, c(t.o), 1), e.setUint32(12, c(t.o), 1)), u(e);
|
|
111
|
+
}
|
|
112
|
+
function z(t, n, e = 0, i = 0) {
|
|
113
|
+
const o = U(46);
|
|
114
|
+
return o.setUint32(0, 1347092738), o.setUint32(4, 755182848), o.setUint16(8, 2048 | e), A(t.t, o, 12), o.setUint32(16, t.isFile ? t.l : 0, 1), o.setUint32(20, c(t.o), 1), o.setUint32(24, c(t.o), 1), o.setUint16(28, t.i.length, 1), o.setUint16(30, i, 1), o.setUint16(40, t.mode | (t.isFile ? 32768 : 16384), 1), o.setUint32(42, c(n), 1), u(o);
|
|
115
|
+
}
|
|
116
|
+
function V(t, n, e) {
|
|
117
|
+
const i = U(e);
|
|
118
|
+
return i.setUint16(0, 1, 1), i.setUint16(2, e - 4, 1), 16 & e && (i.setBigUint64(4, t.o, 1), i.setBigUint64(12, t.o, 1)), i.setBigUint64(e - 8, n, 1), u(i);
|
|
119
|
+
}
|
|
120
|
+
function x(t) {
|
|
121
|
+
return t instanceof File || t instanceof Response ? [[t], [t]] : [[t.input, t.name, t.size], [t.input, t.lastModified, t.mode]];
|
|
122
|
+
}
|
|
123
|
+
var C = (t) => function(n) {
|
|
124
|
+
let e = BigInt(22), i = 0n, o = 0;
|
|
125
|
+
for (const r of n) {
|
|
126
|
+
if (!r.i) throw new Error("Every file must have a non-empty name.");
|
|
127
|
+
if (r.o === void 0) throw new Error(`Missing size for file "${new TextDecoder().decode(r.i)}".`);
|
|
128
|
+
const f = r.o >= 0xffffffffn, a = i >= 0xffffffffn;
|
|
129
|
+
i += BigInt(46 + r.i.length + (f && 8)) + r.o, e += BigInt(r.i.length + 46 + (12 * a | 28 * f)), o || (o = f);
|
|
130
|
+
}
|
|
131
|
+
return (o || i >= 0xffffffffn) && (e += BigInt(76)), e + i;
|
|
132
|
+
}(function* (n) {
|
|
133
|
+
for (const e of n) yield I(...x(e)[0]);
|
|
134
|
+
}(t));
|
|
135
|
+
function k(t, n = {}) {
|
|
136
|
+
const e = { "Content-Type": "application/zip", "Content-Disposition": "attachment" };
|
|
137
|
+
return (typeof n.length == "bigint" || Number.isInteger(n.length)) && n.length > 0 && (e["Content-Length"] = String(n.length)), n.metadata && (e["Content-Length"] = String(C(n.metadata))), new Response(j(t, n), { headers: e });
|
|
138
|
+
}
|
|
139
|
+
function j(t, n = {}) {
|
|
140
|
+
const e = function(i) {
|
|
141
|
+
var r;
|
|
142
|
+
const o = i[Symbol.iterator in i ? Symbol.iterator : Symbol.asyncIterator]();
|
|
143
|
+
return { async next() {
|
|
144
|
+
const f = await o.next();
|
|
145
|
+
if (f.done) return f;
|
|
146
|
+
const [a, l] = x(f.value);
|
|
147
|
+
return { done: 0, value: Object.assign(D(...l), I(...a)) };
|
|
148
|
+
}, throw: (r = o.throw) == null ? void 0 : r.bind(o), [Symbol.asyncIterator]() {
|
|
149
|
+
return this;
|
|
150
|
+
} };
|
|
151
|
+
}(t);
|
|
152
|
+
return v(async function* (i, o) {
|
|
153
|
+
const r = [];
|
|
154
|
+
let f = 0n, a = 0n, l = 0;
|
|
155
|
+
for await (const s of i) {
|
|
156
|
+
const w = L(s, o.buffersAreUTF8);
|
|
157
|
+
yield N(s, w), yield new Uint8Array(s.i), s.isFile && (yield* T(s));
|
|
158
|
+
const h = s.o >= 0xffffffffn, m = 12 * (f >= 0xffffffffn) | 28 * h;
|
|
159
|
+
yield E(s, h), r.push(z(s, f, w, m)), r.push(s.i), m && r.push(V(s, f, m)), h && (f += 8n), a++, f += BigInt(46 + s.i.length) + s.o, l || (l = h);
|
|
160
|
+
}
|
|
161
|
+
let d = 0n;
|
|
162
|
+
for (const s of r) yield s, d += BigInt(s.length);
|
|
163
|
+
if (l || f >= 0xffffffffn) {
|
|
164
|
+
const s = U(76);
|
|
165
|
+
s.setUint32(0, 1347094022), s.setBigUint64(4, BigInt(44), 1), s.setUint32(12, 755182848), s.setBigUint64(24, a, 1), s.setBigUint64(32, a, 1), s.setBigUint64(40, d, 1), s.setBigUint64(48, f, 1), s.setUint32(56, 1347094023), s.setBigUint64(64, f + d, 1), s.setUint32(72, 1, 1), yield u(s);
|
|
166
|
+
}
|
|
167
|
+
const g = U(22);
|
|
168
|
+
g.setUint32(0, 1347093766), g.setUint16(8, B(a), 1), g.setUint16(10, B(a), 1), g.setUint32(12, c(d), 1), g.setUint32(16, c(f), 1), yield u(g);
|
|
169
|
+
}(e, n), e);
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
k as downloadZip,
|
|
173
|
+
j as makeZip,
|
|
174
|
+
C as predictLength
|
|
175
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});"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(t,n,e){const i=Number(0xffffffffn&n),o=Number(n>>32n);this.setUint32(t+(e?0:4),i,e),this.setUint32(t+(e?4:0),o,e)}});var U=t=>new DataView(new ArrayBuffer(t)),u=t=>new Uint8Array(t.buffer||t),y=t=>new TextEncoder().encode(String(t)),c=t=>Math.min(4294967295,Number(t)),b=t=>Math.min(65535,Number(t));function R(t,n,e){n===void 0||n instanceof Date||(n=new Date(n));const i=t!==void 0;if(e||(e=i?436:509),t instanceof File)return{isFile:i,t:n||new Date(t.lastModified),bytes:t.stream(),mode:e};if(t instanceof Response)return{isFile:i,t:n||new Date(t.headers.get("Last-Modified")||Date.now()),bytes:t.body,mode:e};if(n===void 0)n=new Date;else if(isNaN(n))throw new Error("Invalid modification date.");if(!i)return{isFile:i,t:n,mode:e};if(typeof t=="string")return{isFile:i,t:n,bytes:y(t),mode:e};if(t instanceof Blob)return{isFile:i,t:n,bytes:t.stream(),mode:e};if(t instanceof Uint8Array||t instanceof ReadableStream)return{isFile:i,t:n,bytes:t,mode:e};if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return{isFile:i,t:n,bytes:u(t),mode:e};if(Symbol.asyncIterator in t)return{isFile:i,t:n,bytes:v(t[Symbol.asyncIterator]()),mode:e};throw new TypeError("Unsupported input format.")}function v(t,n=t){return new ReadableStream({async pull(e){let i=0;for(;e.desiredSize>i;){const o=await t.next();if(!o.value){e.close();break}{const r=M(o.value);e.enqueue(r),i+=r.byteLength}}},cancel(e){var i;(i=n.throw)==null||i.call(n,e)}})}function M(t){return typeof t=="string"?y(t):t instanceof Uint8Array?t:u(t)}function I(t,n,e){let[i,o]=function(r){return r?r instanceof Uint8Array?[r,1]:ArrayBuffer.isView(r)||r instanceof ArrayBuffer?[u(r),1]:[y(r),0]:[void 0,0]}(n);if(t instanceof File)return{i:p(i||y(t.name)),o:BigInt(t.size),u:o};if(t instanceof Response){const r=t.headers.get("content-disposition"),f=r&&r.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),a=f&&f[1]||t.url&&new URL(t.url).pathname.split("/").findLast(Boolean),l=a&&decodeURIComponent(a),d=e||+t.headers.get("content-length");return{i:p(i||y(l)),o:BigInt(d),u:o}}return i=p(i,t!==void 0||e!==void 0),typeof t=="string"?{i,o:BigInt(y(t).length),u:o}:t instanceof Blob?{i,o:BigInt(t.size),u:o}:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?{i,o:BigInt(t.byteLength),u:o}:{i,o:T(t,e),u:o}}function T(t,n){return n>-1?BigInt(n):t?void 0:0n}function p(t,n=1){if(!t||t.every(e=>e===47))throw new Error("The file must have a name.");if(n)for(;t[t.length-1]===47;)t=t.subarray(0,-1);else t[t.length-1]!==47&&(t=new Uint8Array([...t,47]));return t}var F=new Uint32Array(256);for(let t=0;t<256;++t){let n=t;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);F[t]=n}function B(t,n=0){n=~n;for(var e=0,i=t.length;e<i;e++)n=n>>>8^F[255&n^t[e]];return~n>>>0}function A(t,n,e=0){const i=t.getSeconds()>>1|t.getMinutes()<<5|t.getHours()<<11,o=t.getDate()|t.getMonth()+1<<5|t.getFullYear()-1980<<9;n.setUint16(e,i,1),n.setUint16(e+2,o,1)}function L({i:t,u:n},e){return 8*(!n||(e??function(i){try{N.decode(i)}catch{return 0}return 1}(t)))}var N=new TextDecoder("utf8",{fatal:1});function E(t,n=0){const e=U(30);return e.setUint32(0,1347093252),e.setUint32(4,754976768|n),A(t.t,e,10),e.setUint16(26,t.i.length,1),u(e)}async function*z(t){let{bytes:n}=t;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,t.l=B(n,0),t.o=BigInt(n.length);else{t.o=0n;const e=n.getReader();for(;;){const{value:i,done:o}=await e.read();if(o)break;t.l=B(i,t.l),t.o+=BigInt(i.length),yield i}}}function V(t,n){const e=U(16+(n?8:0));return e.setUint32(0,1347094280),e.setUint32(4,t.isFile?t.l:0,1),n?(e.setBigUint64(8,t.o,1),e.setBigUint64(16,t.o,1)):(e.setUint32(8,c(t.o),1),e.setUint32(12,c(t.o),1)),u(e)}function C(t,n,e=0,i=0){const o=U(46);return o.setUint32(0,1347092738),o.setUint32(4,755182848),o.setUint16(8,2048|e),A(t.t,o,12),o.setUint32(16,t.isFile?t.l:0,1),o.setUint32(20,c(t.o),1),o.setUint32(24,c(t.o),1),o.setUint16(28,t.i.length,1),o.setUint16(30,i,1),o.setUint16(40,t.mode|(t.isFile?32768:16384),1),o.setUint32(42,c(n),1),u(o)}function j(t,n,e){const i=U(e);return i.setUint16(0,1,1),i.setUint16(2,e-4,1),16&e&&(i.setBigUint64(4,t.o,1),i.setBigUint64(12,t.o,1)),i.setBigUint64(e-8,n,1),u(i)}function S(t){return t instanceof File||t instanceof Response?[[t],[t]]:[[t.input,t.name,t.size],[t.input,t.lastModified,t.mode]]}var D=t=>function(n){let e=BigInt(22),i=0n,o=0;for(const r of n){if(!r.i)throw new Error("Every file must have a non-empty name.");if(r.o===void 0)throw new Error(`Missing size for file "${new TextDecoder().decode(r.i)}".`);const f=r.o>=0xffffffffn,a=i>=0xffffffffn;i+=BigInt(46+r.i.length+(f&&8))+r.o,e+=BigInt(r.i.length+46+(12*a|28*f)),o||(o=f)}return(o||i>=0xffffffffn)&&(e+=BigInt(76)),e+i}(function*(n){for(const e of n)yield I(...S(e)[0])}(t));function O(t,n={}){const e={"Content-Type":"application/zip","Content-Disposition":"attachment"};return(typeof n.length=="bigint"||Number.isInteger(n.length))&&n.length>0&&(e["Content-Length"]=String(n.length)),n.metadata&&(e["Content-Length"]=String(D(n.metadata))),new Response(x(t,n),{headers:e})}function x(t,n={}){const e=function(i){var r;const o=i[Symbol.iterator in i?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const f=await o.next();if(f.done)return f;const[a,l]=S(f.value);return{done:0,value:Object.assign(R(...l),I(...a))}},throw:(r=o.throw)==null?void 0:r.bind(o),[Symbol.asyncIterator](){return this}}}(t);return v(async function*(i,o){const r=[];let f=0n,a=0n,l=0;for await(const s of i){const w=L(s,o.buffersAreUTF8);yield E(s,w),yield new Uint8Array(s.i),s.isFile&&(yield*z(s));const h=s.o>=0xffffffffn,m=12*(f>=0xffffffffn)|28*h;yield V(s,h),r.push(C(s,f,w,m)),r.push(s.i),m&&r.push(j(s,f,m)),h&&(f+=8n),a++,f+=BigInt(46+s.i.length)+s.o,l||(l=h)}let d=0n;for(const s of r)yield s,d+=BigInt(s.length);if(l||f>=0xffffffffn){const s=U(76);s.setUint32(0,1347094022),s.setBigUint64(4,BigInt(44),1),s.setUint32(12,755182848),s.setBigUint64(24,a,1),s.setBigUint64(32,a,1),s.setBigUint64(40,d,1),s.setBigUint64(48,f,1),s.setUint32(56,1347094023),s.setBigUint64(64,f+d,1),s.setUint32(72,1,1),yield u(s)}const g=U(22);g.setUint32(0,1347093766),g.setUint16(8,b(a),1),g.setUint16(10,b(a),1),g.setUint32(12,c(d),1),g.setUint32(16,c(f),1),yield u(g)}(e,n),e)}exports.downloadZip=O;exports.makeZip=x;exports.predictLength=D;
|