@life-palette/media 0.2.1

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.
@@ -0,0 +1,604 @@
1
+ import { t as __commonJSMin } from "./rolldown-runtime-BPOCksWG.mjs";
2
+ //#region ../../node_modules/spark-md5/spark-md5.js
3
+ var require_spark_md5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
+ (function(factory) {
5
+ if (typeof exports === "object") module.exports = factory();
6
+ else if (typeof define === "function" && define.amd) define(factory);
7
+ else {
8
+ var glob;
9
+ try {
10
+ glob = window;
11
+ } catch (e) {
12
+ glob = self;
13
+ }
14
+ glob.SparkMD5 = factory();
15
+ }
16
+ })(function(undefined) {
17
+ "use strict";
18
+ var hex_chr = [
19
+ "0",
20
+ "1",
21
+ "2",
22
+ "3",
23
+ "4",
24
+ "5",
25
+ "6",
26
+ "7",
27
+ "8",
28
+ "9",
29
+ "a",
30
+ "b",
31
+ "c",
32
+ "d",
33
+ "e",
34
+ "f"
35
+ ];
36
+ function md5cycle(x, k) {
37
+ var a = x[0], b = x[1], c = x[2], d = x[3];
38
+ a += (b & c | ~b & d) + k[0] - 680876936 | 0;
39
+ a = (a << 7 | a >>> 25) + b | 0;
40
+ d += (a & b | ~a & c) + k[1] - 389564586 | 0;
41
+ d = (d << 12 | d >>> 20) + a | 0;
42
+ c += (d & a | ~d & b) + k[2] + 606105819 | 0;
43
+ c = (c << 17 | c >>> 15) + d | 0;
44
+ b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
45
+ b = (b << 22 | b >>> 10) + c | 0;
46
+ a += (b & c | ~b & d) + k[4] - 176418897 | 0;
47
+ a = (a << 7 | a >>> 25) + b | 0;
48
+ d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
49
+ d = (d << 12 | d >>> 20) + a | 0;
50
+ c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
51
+ c = (c << 17 | c >>> 15) + d | 0;
52
+ b += (c & d | ~c & a) + k[7] - 45705983 | 0;
53
+ b = (b << 22 | b >>> 10) + c | 0;
54
+ a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
55
+ a = (a << 7 | a >>> 25) + b | 0;
56
+ d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
57
+ d = (d << 12 | d >>> 20) + a | 0;
58
+ c += (d & a | ~d & b) + k[10] - 42063 | 0;
59
+ c = (c << 17 | c >>> 15) + d | 0;
60
+ b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
61
+ b = (b << 22 | b >>> 10) + c | 0;
62
+ a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
63
+ a = (a << 7 | a >>> 25) + b | 0;
64
+ d += (a & b | ~a & c) + k[13] - 40341101 | 0;
65
+ d = (d << 12 | d >>> 20) + a | 0;
66
+ c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
67
+ c = (c << 17 | c >>> 15) + d | 0;
68
+ b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
69
+ b = (b << 22 | b >>> 10) + c | 0;
70
+ a += (b & d | c & ~d) + k[1] - 165796510 | 0;
71
+ a = (a << 5 | a >>> 27) + b | 0;
72
+ d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
73
+ d = (d << 9 | d >>> 23) + a | 0;
74
+ c += (d & b | a & ~b) + k[11] + 643717713 | 0;
75
+ c = (c << 14 | c >>> 18) + d | 0;
76
+ b += (c & a | d & ~a) + k[0] - 373897302 | 0;
77
+ b = (b << 20 | b >>> 12) + c | 0;
78
+ a += (b & d | c & ~d) + k[5] - 701558691 | 0;
79
+ a = (a << 5 | a >>> 27) + b | 0;
80
+ d += (a & c | b & ~c) + k[10] + 38016083 | 0;
81
+ d = (d << 9 | d >>> 23) + a | 0;
82
+ c += (d & b | a & ~b) + k[15] - 660478335 | 0;
83
+ c = (c << 14 | c >>> 18) + d | 0;
84
+ b += (c & a | d & ~a) + k[4] - 405537848 | 0;
85
+ b = (b << 20 | b >>> 12) + c | 0;
86
+ a += (b & d | c & ~d) + k[9] + 568446438 | 0;
87
+ a = (a << 5 | a >>> 27) + b | 0;
88
+ d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
89
+ d = (d << 9 | d >>> 23) + a | 0;
90
+ c += (d & b | a & ~b) + k[3] - 187363961 | 0;
91
+ c = (c << 14 | c >>> 18) + d | 0;
92
+ b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
93
+ b = (b << 20 | b >>> 12) + c | 0;
94
+ a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
95
+ a = (a << 5 | a >>> 27) + b | 0;
96
+ d += (a & c | b & ~c) + k[2] - 51403784 | 0;
97
+ d = (d << 9 | d >>> 23) + a | 0;
98
+ c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
99
+ c = (c << 14 | c >>> 18) + d | 0;
100
+ b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
101
+ b = (b << 20 | b >>> 12) + c | 0;
102
+ a += (b ^ c ^ d) + k[5] - 378558 | 0;
103
+ a = (a << 4 | a >>> 28) + b | 0;
104
+ d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
105
+ d = (d << 11 | d >>> 21) + a | 0;
106
+ c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
107
+ c = (c << 16 | c >>> 16) + d | 0;
108
+ b += (c ^ d ^ a) + k[14] - 35309556 | 0;
109
+ b = (b << 23 | b >>> 9) + c | 0;
110
+ a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
111
+ a = (a << 4 | a >>> 28) + b | 0;
112
+ d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
113
+ d = (d << 11 | d >>> 21) + a | 0;
114
+ c += (d ^ a ^ b) + k[7] - 155497632 | 0;
115
+ c = (c << 16 | c >>> 16) + d | 0;
116
+ b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
117
+ b = (b << 23 | b >>> 9) + c | 0;
118
+ a += (b ^ c ^ d) + k[13] + 681279174 | 0;
119
+ a = (a << 4 | a >>> 28) + b | 0;
120
+ d += (a ^ b ^ c) + k[0] - 358537222 | 0;
121
+ d = (d << 11 | d >>> 21) + a | 0;
122
+ c += (d ^ a ^ b) + k[3] - 722521979 | 0;
123
+ c = (c << 16 | c >>> 16) + d | 0;
124
+ b += (c ^ d ^ a) + k[6] + 76029189 | 0;
125
+ b = (b << 23 | b >>> 9) + c | 0;
126
+ a += (b ^ c ^ d) + k[9] - 640364487 | 0;
127
+ a = (a << 4 | a >>> 28) + b | 0;
128
+ d += (a ^ b ^ c) + k[12] - 421815835 | 0;
129
+ d = (d << 11 | d >>> 21) + a | 0;
130
+ c += (d ^ a ^ b) + k[15] + 530742520 | 0;
131
+ c = (c << 16 | c >>> 16) + d | 0;
132
+ b += (c ^ d ^ a) + k[2] - 995338651 | 0;
133
+ b = (b << 23 | b >>> 9) + c | 0;
134
+ a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
135
+ a = (a << 6 | a >>> 26) + b | 0;
136
+ d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
137
+ d = (d << 10 | d >>> 22) + a | 0;
138
+ c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
139
+ c = (c << 15 | c >>> 17) + d | 0;
140
+ b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
141
+ b = (b << 21 | b >>> 11) + c | 0;
142
+ a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
143
+ a = (a << 6 | a >>> 26) + b | 0;
144
+ d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
145
+ d = (d << 10 | d >>> 22) + a | 0;
146
+ c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
147
+ c = (c << 15 | c >>> 17) + d | 0;
148
+ b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
149
+ b = (b << 21 | b >>> 11) + c | 0;
150
+ a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
151
+ a = (a << 6 | a >>> 26) + b | 0;
152
+ d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
153
+ d = (d << 10 | d >>> 22) + a | 0;
154
+ c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
155
+ c = (c << 15 | c >>> 17) + d | 0;
156
+ b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
157
+ b = (b << 21 | b >>> 11) + c | 0;
158
+ a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
159
+ a = (a << 6 | a >>> 26) + b | 0;
160
+ d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
161
+ d = (d << 10 | d >>> 22) + a | 0;
162
+ c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
163
+ c = (c << 15 | c >>> 17) + d | 0;
164
+ b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
165
+ b = (b << 21 | b >>> 11) + c | 0;
166
+ x[0] = a + x[0] | 0;
167
+ x[1] = b + x[1] | 0;
168
+ x[2] = c + x[2] | 0;
169
+ x[3] = d + x[3] | 0;
170
+ }
171
+ function md5blk(s) {
172
+ var md5blks = [], i = 0;
173
+ for (; i < 64; i += 4) md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
174
+ return md5blks;
175
+ }
176
+ function md5blk_array(a) {
177
+ var md5blks = [], i = 0;
178
+ for (; i < 64; i += 4) md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24);
179
+ return md5blks;
180
+ }
181
+ function md51(s) {
182
+ var n = s.length, state = [
183
+ 1732584193,
184
+ -271733879,
185
+ -1732584194,
186
+ 271733878
187
+ ], i = 64, length, tail, tmp, lo, hi;
188
+ for (; i <= n; i += 64) md5cycle(state, md5blk(s.substring(i - 64, i)));
189
+ s = s.substring(i - 64);
190
+ length = s.length;
191
+ tail = [
192
+ 0,
193
+ 0,
194
+ 0,
195
+ 0,
196
+ 0,
197
+ 0,
198
+ 0,
199
+ 0,
200
+ 0,
201
+ 0,
202
+ 0,
203
+ 0,
204
+ 0,
205
+ 0,
206
+ 0,
207
+ 0
208
+ ];
209
+ for (i = 0; i < length; i += 1) tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
210
+ tail[i >> 2] |= 128 << (i % 4 << 3);
211
+ if (i > 55) {
212
+ md5cycle(state, tail);
213
+ for (i = 0; i < 16; i += 1) tail[i] = 0;
214
+ }
215
+ tmp = n * 8;
216
+ tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
217
+ lo = parseInt(tmp[2], 16);
218
+ hi = parseInt(tmp[1], 16) || 0;
219
+ tail[14] = lo;
220
+ tail[15] = hi;
221
+ md5cycle(state, tail);
222
+ return state;
223
+ }
224
+ function md51_array(a) {
225
+ var n = a.length, state = [
226
+ 1732584193,
227
+ -271733879,
228
+ -1732584194,
229
+ 271733878
230
+ ], i = 64, length, tail, tmp, lo, hi;
231
+ for (; i <= n; i += 64) md5cycle(state, md5blk_array(a.subarray(i - 64, i)));
232
+ a = i - 64 < n ? a.subarray(i - 64) : /* @__PURE__ */ new Uint8Array(0);
233
+ length = a.length;
234
+ tail = [
235
+ 0,
236
+ 0,
237
+ 0,
238
+ 0,
239
+ 0,
240
+ 0,
241
+ 0,
242
+ 0,
243
+ 0,
244
+ 0,
245
+ 0,
246
+ 0,
247
+ 0,
248
+ 0,
249
+ 0,
250
+ 0
251
+ ];
252
+ for (i = 0; i < length; i += 1) tail[i >> 2] |= a[i] << (i % 4 << 3);
253
+ tail[i >> 2] |= 128 << (i % 4 << 3);
254
+ if (i > 55) {
255
+ md5cycle(state, tail);
256
+ for (i = 0; i < 16; i += 1) tail[i] = 0;
257
+ }
258
+ tmp = n * 8;
259
+ tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
260
+ lo = parseInt(tmp[2], 16);
261
+ hi = parseInt(tmp[1], 16) || 0;
262
+ tail[14] = lo;
263
+ tail[15] = hi;
264
+ md5cycle(state, tail);
265
+ return state;
266
+ }
267
+ function rhex(n) {
268
+ var s = "", j = 0;
269
+ for (; j < 4; j += 1) s += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15];
270
+ return s;
271
+ }
272
+ function hex(x) {
273
+ var i = 0;
274
+ for (; i < x.length; i += 1) x[i] = rhex(x[i]);
275
+ return x.join("");
276
+ }
277
+ if (hex(md51("hello")) !== "5d41402abc4b2a76b9719d911017c592");
278
+ /**
279
+ * ArrayBuffer slice polyfill.
280
+ *
281
+ * @see https://github.com/ttaubert/node-arraybuffer-slice
282
+ */
283
+ if (typeof ArrayBuffer !== "undefined" && !ArrayBuffer.prototype.slice) (function() {
284
+ function clamp(val, length) {
285
+ val = val | 0 || 0;
286
+ if (val < 0) return Math.max(val + length, 0);
287
+ return Math.min(val, length);
288
+ }
289
+ ArrayBuffer.prototype.slice = function(from, to) {
290
+ var length = this.byteLength, begin = clamp(from, length), end = length, num, target, targetArray, sourceArray;
291
+ if (to !== undefined) end = clamp(to, length);
292
+ if (begin > end) return /* @__PURE__ */ new ArrayBuffer(0);
293
+ num = end - begin;
294
+ target = new ArrayBuffer(num);
295
+ targetArray = new Uint8Array(target);
296
+ sourceArray = new Uint8Array(this, begin, num);
297
+ targetArray.set(sourceArray);
298
+ return target;
299
+ };
300
+ })();
301
+ /**
302
+ * Helpers.
303
+ */
304
+ function toUtf8(str) {
305
+ if (/[\u0080-\uFFFF]/.test(str)) str = unescape(encodeURIComponent(str));
306
+ return str;
307
+ }
308
+ function utf8Str2ArrayBuffer(str, returnUInt8Array) {
309
+ var length = str.length, buff = new ArrayBuffer(length), arr = new Uint8Array(buff), i = 0;
310
+ for (; i < length; i += 1) arr[i] = str.charCodeAt(i);
311
+ return returnUInt8Array ? arr : buff;
312
+ }
313
+ function arrayBuffer2Utf8Str(buff) {
314
+ return String.fromCharCode.apply(null, new Uint8Array(buff));
315
+ }
316
+ function concatenateArrayBuffers(first, second, returnUInt8Array) {
317
+ var result = new Uint8Array(first.byteLength + second.byteLength);
318
+ result.set(new Uint8Array(first));
319
+ result.set(new Uint8Array(second), first.byteLength);
320
+ return returnUInt8Array ? result : result.buffer;
321
+ }
322
+ function hexToBinaryString(hex) {
323
+ var bytes = [], length = hex.length, x = 0;
324
+ for (; x < length - 1; x += 2) bytes.push(parseInt(hex.substr(x, 2), 16));
325
+ return String.fromCharCode.apply(String, bytes);
326
+ }
327
+ /**
328
+ * SparkMD5 OOP implementation.
329
+ *
330
+ * Use this class to perform an incremental md5, otherwise use the
331
+ * static methods instead.
332
+ */
333
+ function SparkMD5() {
334
+ this.reset();
335
+ }
336
+ /**
337
+ * Appends a string.
338
+ * A conversion will be applied if an utf8 string is detected.
339
+ *
340
+ * @param {String} str The string to be appended
341
+ *
342
+ * @return {SparkMD5} The instance itself
343
+ */
344
+ SparkMD5.prototype.append = function(str) {
345
+ this.appendBinary(toUtf8(str));
346
+ return this;
347
+ };
348
+ /**
349
+ * Appends a binary string.
350
+ *
351
+ * @param {String} contents The binary string to be appended
352
+ *
353
+ * @return {SparkMD5} The instance itself
354
+ */
355
+ SparkMD5.prototype.appendBinary = function(contents) {
356
+ this._buff += contents;
357
+ this._length += contents.length;
358
+ var length = this._buff.length, i = 64;
359
+ for (; i <= length; i += 64) md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)));
360
+ this._buff = this._buff.substring(i - 64);
361
+ return this;
362
+ };
363
+ /**
364
+ * Finishes the incremental computation, reseting the internal state and
365
+ * returning the result.
366
+ *
367
+ * @param {Boolean} raw True to get the raw string, false to get the hex string
368
+ *
369
+ * @return {String} The result
370
+ */
371
+ SparkMD5.prototype.end = function(raw) {
372
+ var buff = this._buff, length = buff.length, i, tail = [
373
+ 0,
374
+ 0,
375
+ 0,
376
+ 0,
377
+ 0,
378
+ 0,
379
+ 0,
380
+ 0,
381
+ 0,
382
+ 0,
383
+ 0,
384
+ 0,
385
+ 0,
386
+ 0,
387
+ 0,
388
+ 0
389
+ ], ret;
390
+ for (i = 0; i < length; i += 1) tail[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3);
391
+ this._finish(tail, length);
392
+ ret = hex(this._hash);
393
+ if (raw) ret = hexToBinaryString(ret);
394
+ this.reset();
395
+ return ret;
396
+ };
397
+ /**
398
+ * Resets the internal state of the computation.
399
+ *
400
+ * @return {SparkMD5} The instance itself
401
+ */
402
+ SparkMD5.prototype.reset = function() {
403
+ this._buff = "";
404
+ this._length = 0;
405
+ this._hash = [
406
+ 1732584193,
407
+ -271733879,
408
+ -1732584194,
409
+ 271733878
410
+ ];
411
+ return this;
412
+ };
413
+ /**
414
+ * Gets the internal state of the computation.
415
+ *
416
+ * @return {Object} The state
417
+ */
418
+ SparkMD5.prototype.getState = function() {
419
+ return {
420
+ buff: this._buff,
421
+ length: this._length,
422
+ hash: this._hash.slice()
423
+ };
424
+ };
425
+ /**
426
+ * Gets the internal state of the computation.
427
+ *
428
+ * @param {Object} state The state
429
+ *
430
+ * @return {SparkMD5} The instance itself
431
+ */
432
+ SparkMD5.prototype.setState = function(state) {
433
+ this._buff = state.buff;
434
+ this._length = state.length;
435
+ this._hash = state.hash;
436
+ return this;
437
+ };
438
+ /**
439
+ * Releases memory used by the incremental buffer and other additional
440
+ * resources. If you plan to use the instance again, use reset instead.
441
+ */
442
+ SparkMD5.prototype.destroy = function() {
443
+ delete this._hash;
444
+ delete this._buff;
445
+ delete this._length;
446
+ };
447
+ /**
448
+ * Finish the final calculation based on the tail.
449
+ *
450
+ * @param {Array} tail The tail (will be modified)
451
+ * @param {Number} length The length of the remaining buffer
452
+ */
453
+ SparkMD5.prototype._finish = function(tail, length) {
454
+ var i = length, tmp, lo, hi;
455
+ tail[i >> 2] |= 128 << (i % 4 << 3);
456
+ if (i > 55) {
457
+ md5cycle(this._hash, tail);
458
+ for (i = 0; i < 16; i += 1) tail[i] = 0;
459
+ }
460
+ tmp = this._length * 8;
461
+ tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
462
+ lo = parseInt(tmp[2], 16);
463
+ hi = parseInt(tmp[1], 16) || 0;
464
+ tail[14] = lo;
465
+ tail[15] = hi;
466
+ md5cycle(this._hash, tail);
467
+ };
468
+ /**
469
+ * Performs the md5 hash on a string.
470
+ * A conversion will be applied if utf8 string is detected.
471
+ *
472
+ * @param {String} str The string
473
+ * @param {Boolean} [raw] True to get the raw string, false to get the hex string
474
+ *
475
+ * @return {String} The result
476
+ */
477
+ SparkMD5.hash = function(str, raw) {
478
+ return SparkMD5.hashBinary(toUtf8(str), raw);
479
+ };
480
+ /**
481
+ * Performs the md5 hash on a binary string.
482
+ *
483
+ * @param {String} content The binary string
484
+ * @param {Boolean} [raw] True to get the raw string, false to get the hex string
485
+ *
486
+ * @return {String} The result
487
+ */
488
+ SparkMD5.hashBinary = function(content, raw) {
489
+ var ret = hex(md51(content));
490
+ return raw ? hexToBinaryString(ret) : ret;
491
+ };
492
+ /**
493
+ * SparkMD5 OOP implementation for array buffers.
494
+ *
495
+ * Use this class to perform an incremental md5 ONLY for array buffers.
496
+ */
497
+ SparkMD5.ArrayBuffer = function() {
498
+ this.reset();
499
+ };
500
+ /**
501
+ * Appends an array buffer.
502
+ *
503
+ * @param {ArrayBuffer} arr The array to be appended
504
+ *
505
+ * @return {SparkMD5.ArrayBuffer} The instance itself
506
+ */
507
+ SparkMD5.ArrayBuffer.prototype.append = function(arr) {
508
+ var buff = concatenateArrayBuffers(this._buff.buffer, arr, true), length = buff.length, i;
509
+ this._length += arr.byteLength;
510
+ for (i = 64; i <= length; i += 64) md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)));
511
+ this._buff = i - 64 < length ? new Uint8Array(buff.buffer.slice(i - 64)) : /* @__PURE__ */ new Uint8Array(0);
512
+ return this;
513
+ };
514
+ /**
515
+ * Finishes the incremental computation, reseting the internal state and
516
+ * returning the result.
517
+ *
518
+ * @param {Boolean} raw True to get the raw string, false to get the hex string
519
+ *
520
+ * @return {String} The result
521
+ */
522
+ SparkMD5.ArrayBuffer.prototype.end = function(raw) {
523
+ var buff = this._buff, length = buff.length, tail = [
524
+ 0,
525
+ 0,
526
+ 0,
527
+ 0,
528
+ 0,
529
+ 0,
530
+ 0,
531
+ 0,
532
+ 0,
533
+ 0,
534
+ 0,
535
+ 0,
536
+ 0,
537
+ 0,
538
+ 0,
539
+ 0
540
+ ], i = 0, ret;
541
+ for (; i < length; i += 1) tail[i >> 2] |= buff[i] << (i % 4 << 3);
542
+ this._finish(tail, length);
543
+ ret = hex(this._hash);
544
+ if (raw) ret = hexToBinaryString(ret);
545
+ this.reset();
546
+ return ret;
547
+ };
548
+ /**
549
+ * Resets the internal state of the computation.
550
+ *
551
+ * @return {SparkMD5.ArrayBuffer} The instance itself
552
+ */
553
+ SparkMD5.ArrayBuffer.prototype.reset = function() {
554
+ this._buff = /* @__PURE__ */ new Uint8Array(0);
555
+ this._length = 0;
556
+ this._hash = [
557
+ 1732584193,
558
+ -271733879,
559
+ -1732584194,
560
+ 271733878
561
+ ];
562
+ return this;
563
+ };
564
+ /**
565
+ * Gets the internal state of the computation.
566
+ *
567
+ * @return {Object} The state
568
+ */
569
+ SparkMD5.ArrayBuffer.prototype.getState = function() {
570
+ var state = SparkMD5.prototype.getState.call(this);
571
+ state.buff = arrayBuffer2Utf8Str(state.buff);
572
+ return state;
573
+ };
574
+ /**
575
+ * Gets the internal state of the computation.
576
+ *
577
+ * @param {Object} state The state
578
+ *
579
+ * @return {SparkMD5.ArrayBuffer} The instance itself
580
+ */
581
+ SparkMD5.ArrayBuffer.prototype.setState = function(state) {
582
+ state.buff = utf8Str2ArrayBuffer(state.buff, true);
583
+ return SparkMD5.prototype.setState.call(this, state);
584
+ };
585
+ SparkMD5.ArrayBuffer.prototype.destroy = SparkMD5.prototype.destroy;
586
+ SparkMD5.ArrayBuffer.prototype._finish = SparkMD5.prototype._finish;
587
+ /**
588
+ * Performs the md5 hash on an array buffer.
589
+ *
590
+ * @param {ArrayBuffer} arr The array buffer
591
+ * @param {Boolean} [raw] True to get the raw string, false to get the hex one
592
+ *
593
+ * @return {String} The result
594
+ */
595
+ SparkMD5.ArrayBuffer.hash = function(arr, raw) {
596
+ var ret = hex(md51_array(new Uint8Array(arr)));
597
+ return raw ? hexToBinaryString(ret) : ret;
598
+ };
599
+ return SparkMD5;
600
+ });
601
+ }));
602
+ //#endregion
603
+ export default require_spark_md5();
604
+ export {};
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@life-palette/media",
3
+ "version": "0.2.1",
4
+ "description": "Browser-side media analysis: blurhash, arthash, dominant colors, EXIF, video technical metadata. Runs in any modern browser.",
5
+ "homepage": "https://github.com/Life-Palette/packages/tree/main/packages/media#readme",
6
+ "bugs": "https://github.com/Life-Palette/packages/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Life-Palette/packages",
10
+ "directory": "packages/media"
11
+ },
12
+ "license": "MIT",
13
+ "sideEffects": false,
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/index.d.mts",
19
+ "default": "./dist/index.mjs"
20
+ },
21
+ "require": {
22
+ "types": "./dist/index.d.cts",
23
+ "default": "./dist/index.cjs"
24
+ }
25
+ }
26
+ },
27
+ "main": "./dist/index.cjs",
28
+ "module": "./dist/index.mjs",
29
+ "types": "./dist/index.d.mts",
30
+ "files": [
31
+ "dist",
32
+ "README.md"
33
+ ],
34
+ "dependencies": {
35
+ "arthash": "^0.5.0",
36
+ "blurhash": "^2.0.5",
37
+ "metaprobe": "^0.0.1",
38
+ "spark-md5": "^3.0.2"
39
+ },
40
+ "devDependencies": {
41
+ "@types/spark-md5": "^3.0.5",
42
+ "@vitest/browser": "^5.0.0",
43
+ "@vitest/coverage-v8": "^5.0.0",
44
+ "attw": "^1.0.0",
45
+ "publint": "^0.3.24",
46
+ "tsdown": "^0.23.0",
47
+ "vitest": "^5.0.0"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public",
51
+ "registry": "https://registry.npmjs.org/"
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown",
55
+ "dev": "vitest dev",
56
+ "test": "vitest run",
57
+ "test:browser": "vitest run --browser.headless"
58
+ }
59
+ }