@shipstatic/drop 0.1.2 → 0.1.4

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/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useState, useRef, useCallback } from 'react';
2
+ import { formatFileSize as formatFileSize$1, getValidFiles as getValidFiles$1, validateFiles } from '@shipstatic/ship';
2
3
 
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
@@ -11699,447 +11700,6 @@ var require_mime_db = __commonJS({
11699
11700
  }
11700
11701
  });
11701
11702
 
11702
- // node_modules/.pnpm/spark-md5@3.0.2/node_modules/spark-md5/spark-md5.js
11703
- var require_spark_md5 = __commonJS({
11704
- "node_modules/.pnpm/spark-md5@3.0.2/node_modules/spark-md5/spark-md5.js"(exports, module) {
11705
- (function(factory) {
11706
- if (typeof exports === "object") {
11707
- module.exports = factory();
11708
- } else if (typeof define === "function" && define.amd) {
11709
- define(factory);
11710
- } else {
11711
- var glob;
11712
- try {
11713
- glob = window;
11714
- } catch (e) {
11715
- glob = self;
11716
- }
11717
- glob.SparkMD5 = factory();
11718
- }
11719
- })(function(undefined2) {
11720
- var hex_chr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
11721
- function md5cycle(x, k) {
11722
- var a = x[0], b = x[1], c = x[2], d = x[3];
11723
- a += (b & c | ~b & d) + k[0] - 680876936 | 0;
11724
- a = (a << 7 | a >>> 25) + b | 0;
11725
- d += (a & b | ~a & c) + k[1] - 389564586 | 0;
11726
- d = (d << 12 | d >>> 20) + a | 0;
11727
- c += (d & a | ~d & b) + k[2] + 606105819 | 0;
11728
- c = (c << 17 | c >>> 15) + d | 0;
11729
- b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
11730
- b = (b << 22 | b >>> 10) + c | 0;
11731
- a += (b & c | ~b & d) + k[4] - 176418897 | 0;
11732
- a = (a << 7 | a >>> 25) + b | 0;
11733
- d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
11734
- d = (d << 12 | d >>> 20) + a | 0;
11735
- c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
11736
- c = (c << 17 | c >>> 15) + d | 0;
11737
- b += (c & d | ~c & a) + k[7] - 45705983 | 0;
11738
- b = (b << 22 | b >>> 10) + c | 0;
11739
- a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
11740
- a = (a << 7 | a >>> 25) + b | 0;
11741
- d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
11742
- d = (d << 12 | d >>> 20) + a | 0;
11743
- c += (d & a | ~d & b) + k[10] - 42063 | 0;
11744
- c = (c << 17 | c >>> 15) + d | 0;
11745
- b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
11746
- b = (b << 22 | b >>> 10) + c | 0;
11747
- a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
11748
- a = (a << 7 | a >>> 25) + b | 0;
11749
- d += (a & b | ~a & c) + k[13] - 40341101 | 0;
11750
- d = (d << 12 | d >>> 20) + a | 0;
11751
- c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
11752
- c = (c << 17 | c >>> 15) + d | 0;
11753
- b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
11754
- b = (b << 22 | b >>> 10) + c | 0;
11755
- a += (b & d | c & ~d) + k[1] - 165796510 | 0;
11756
- a = (a << 5 | a >>> 27) + b | 0;
11757
- d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
11758
- d = (d << 9 | d >>> 23) + a | 0;
11759
- c += (d & b | a & ~b) + k[11] + 643717713 | 0;
11760
- c = (c << 14 | c >>> 18) + d | 0;
11761
- b += (c & a | d & ~a) + k[0] - 373897302 | 0;
11762
- b = (b << 20 | b >>> 12) + c | 0;
11763
- a += (b & d | c & ~d) + k[5] - 701558691 | 0;
11764
- a = (a << 5 | a >>> 27) + b | 0;
11765
- d += (a & c | b & ~c) + k[10] + 38016083 | 0;
11766
- d = (d << 9 | d >>> 23) + a | 0;
11767
- c += (d & b | a & ~b) + k[15] - 660478335 | 0;
11768
- c = (c << 14 | c >>> 18) + d | 0;
11769
- b += (c & a | d & ~a) + k[4] - 405537848 | 0;
11770
- b = (b << 20 | b >>> 12) + c | 0;
11771
- a += (b & d | c & ~d) + k[9] + 568446438 | 0;
11772
- a = (a << 5 | a >>> 27) + b | 0;
11773
- d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
11774
- d = (d << 9 | d >>> 23) + a | 0;
11775
- c += (d & b | a & ~b) + k[3] - 187363961 | 0;
11776
- c = (c << 14 | c >>> 18) + d | 0;
11777
- b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
11778
- b = (b << 20 | b >>> 12) + c | 0;
11779
- a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
11780
- a = (a << 5 | a >>> 27) + b | 0;
11781
- d += (a & c | b & ~c) + k[2] - 51403784 | 0;
11782
- d = (d << 9 | d >>> 23) + a | 0;
11783
- c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
11784
- c = (c << 14 | c >>> 18) + d | 0;
11785
- b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
11786
- b = (b << 20 | b >>> 12) + c | 0;
11787
- a += (b ^ c ^ d) + k[5] - 378558 | 0;
11788
- a = (a << 4 | a >>> 28) + b | 0;
11789
- d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
11790
- d = (d << 11 | d >>> 21) + a | 0;
11791
- c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
11792
- c = (c << 16 | c >>> 16) + d | 0;
11793
- b += (c ^ d ^ a) + k[14] - 35309556 | 0;
11794
- b = (b << 23 | b >>> 9) + c | 0;
11795
- a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
11796
- a = (a << 4 | a >>> 28) + b | 0;
11797
- d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
11798
- d = (d << 11 | d >>> 21) + a | 0;
11799
- c += (d ^ a ^ b) + k[7] - 155497632 | 0;
11800
- c = (c << 16 | c >>> 16) + d | 0;
11801
- b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
11802
- b = (b << 23 | b >>> 9) + c | 0;
11803
- a += (b ^ c ^ d) + k[13] + 681279174 | 0;
11804
- a = (a << 4 | a >>> 28) + b | 0;
11805
- d += (a ^ b ^ c) + k[0] - 358537222 | 0;
11806
- d = (d << 11 | d >>> 21) + a | 0;
11807
- c += (d ^ a ^ b) + k[3] - 722521979 | 0;
11808
- c = (c << 16 | c >>> 16) + d | 0;
11809
- b += (c ^ d ^ a) + k[6] + 76029189 | 0;
11810
- b = (b << 23 | b >>> 9) + c | 0;
11811
- a += (b ^ c ^ d) + k[9] - 640364487 | 0;
11812
- a = (a << 4 | a >>> 28) + b | 0;
11813
- d += (a ^ b ^ c) + k[12] - 421815835 | 0;
11814
- d = (d << 11 | d >>> 21) + a | 0;
11815
- c += (d ^ a ^ b) + k[15] + 530742520 | 0;
11816
- c = (c << 16 | c >>> 16) + d | 0;
11817
- b += (c ^ d ^ a) + k[2] - 995338651 | 0;
11818
- b = (b << 23 | b >>> 9) + c | 0;
11819
- a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
11820
- a = (a << 6 | a >>> 26) + b | 0;
11821
- d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
11822
- d = (d << 10 | d >>> 22) + a | 0;
11823
- c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
11824
- c = (c << 15 | c >>> 17) + d | 0;
11825
- b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
11826
- b = (b << 21 | b >>> 11) + c | 0;
11827
- a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
11828
- a = (a << 6 | a >>> 26) + b | 0;
11829
- d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
11830
- d = (d << 10 | d >>> 22) + a | 0;
11831
- c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
11832
- c = (c << 15 | c >>> 17) + d | 0;
11833
- b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
11834
- b = (b << 21 | b >>> 11) + c | 0;
11835
- a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
11836
- a = (a << 6 | a >>> 26) + b | 0;
11837
- d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
11838
- d = (d << 10 | d >>> 22) + a | 0;
11839
- c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
11840
- c = (c << 15 | c >>> 17) + d | 0;
11841
- b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
11842
- b = (b << 21 | b >>> 11) + c | 0;
11843
- a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
11844
- a = (a << 6 | a >>> 26) + b | 0;
11845
- d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
11846
- d = (d << 10 | d >>> 22) + a | 0;
11847
- c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
11848
- c = (c << 15 | c >>> 17) + d | 0;
11849
- b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
11850
- b = (b << 21 | b >>> 11) + c | 0;
11851
- x[0] = a + x[0] | 0;
11852
- x[1] = b + x[1] | 0;
11853
- x[2] = c + x[2] | 0;
11854
- x[3] = d + x[3] | 0;
11855
- }
11856
- function md5blk(s) {
11857
- var md5blks = [], i;
11858
- for (i = 0; i < 64; i += 4) {
11859
- md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
11860
- }
11861
- return md5blks;
11862
- }
11863
- function md5blk_array(a) {
11864
- var md5blks = [], i;
11865
- for (i = 0; i < 64; i += 4) {
11866
- md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24);
11867
- }
11868
- return md5blks;
11869
- }
11870
- function md51(s) {
11871
- var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i, length, tail, tmp, lo, hi;
11872
- for (i = 64; i <= n; i += 64) {
11873
- md5cycle(state, md5blk(s.substring(i - 64, i)));
11874
- }
11875
- s = s.substring(i - 64);
11876
- length = s.length;
11877
- tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
11878
- for (i = 0; i < length; i += 1) {
11879
- tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
11880
- }
11881
- tail[i >> 2] |= 128 << (i % 4 << 3);
11882
- if (i > 55) {
11883
- md5cycle(state, tail);
11884
- for (i = 0; i < 16; i += 1) {
11885
- tail[i] = 0;
11886
- }
11887
- }
11888
- tmp = n * 8;
11889
- tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
11890
- lo = parseInt(tmp[2], 16);
11891
- hi = parseInt(tmp[1], 16) || 0;
11892
- tail[14] = lo;
11893
- tail[15] = hi;
11894
- md5cycle(state, tail);
11895
- return state;
11896
- }
11897
- function md51_array(a) {
11898
- var n = a.length, state = [1732584193, -271733879, -1732584194, 271733878], i, length, tail, tmp, lo, hi;
11899
- for (i = 64; i <= n; i += 64) {
11900
- md5cycle(state, md5blk_array(a.subarray(i - 64, i)));
11901
- }
11902
- a = i - 64 < n ? a.subarray(i - 64) : new Uint8Array(0);
11903
- length = a.length;
11904
- tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
11905
- for (i = 0; i < length; i += 1) {
11906
- tail[i >> 2] |= a[i] << (i % 4 << 3);
11907
- }
11908
- tail[i >> 2] |= 128 << (i % 4 << 3);
11909
- if (i > 55) {
11910
- md5cycle(state, tail);
11911
- for (i = 0; i < 16; i += 1) {
11912
- tail[i] = 0;
11913
- }
11914
- }
11915
- tmp = n * 8;
11916
- tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
11917
- lo = parseInt(tmp[2], 16);
11918
- hi = parseInt(tmp[1], 16) || 0;
11919
- tail[14] = lo;
11920
- tail[15] = hi;
11921
- md5cycle(state, tail);
11922
- return state;
11923
- }
11924
- function rhex(n) {
11925
- var s = "", j;
11926
- for (j = 0; j < 4; j += 1) {
11927
- s += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15];
11928
- }
11929
- return s;
11930
- }
11931
- function hex(x) {
11932
- var i;
11933
- for (i = 0; i < x.length; i += 1) {
11934
- x[i] = rhex(x[i]);
11935
- }
11936
- return x.join("");
11937
- }
11938
- if (hex(md51("hello")) !== "5d41402abc4b2a76b9719d911017c592") ;
11939
- if (typeof ArrayBuffer !== "undefined" && !ArrayBuffer.prototype.slice) {
11940
- (function() {
11941
- function clamp(val, length) {
11942
- val = val | 0 || 0;
11943
- if (val < 0) {
11944
- return Math.max(val + length, 0);
11945
- }
11946
- return Math.min(val, length);
11947
- }
11948
- ArrayBuffer.prototype.slice = function(from, to) {
11949
- var length = this.byteLength, begin = clamp(from, length), end = length, num, target, targetArray, sourceArray;
11950
- if (to !== undefined2) {
11951
- end = clamp(to, length);
11952
- }
11953
- if (begin > end) {
11954
- return new ArrayBuffer(0);
11955
- }
11956
- num = end - begin;
11957
- target = new ArrayBuffer(num);
11958
- targetArray = new Uint8Array(target);
11959
- sourceArray = new Uint8Array(this, begin, num);
11960
- targetArray.set(sourceArray);
11961
- return target;
11962
- };
11963
- })();
11964
- }
11965
- function toUtf8(str) {
11966
- if (/[\u0080-\uFFFF]/.test(str)) {
11967
- str = unescape(encodeURIComponent(str));
11968
- }
11969
- return str;
11970
- }
11971
- function utf8Str2ArrayBuffer(str, returnUInt8Array) {
11972
- var length = str.length, buff = new ArrayBuffer(length), arr = new Uint8Array(buff), i;
11973
- for (i = 0; i < length; i += 1) {
11974
- arr[i] = str.charCodeAt(i);
11975
- }
11976
- return returnUInt8Array ? arr : buff;
11977
- }
11978
- function arrayBuffer2Utf8Str(buff) {
11979
- return String.fromCharCode.apply(null, new Uint8Array(buff));
11980
- }
11981
- function concatenateArrayBuffers(first, second, returnUInt8Array) {
11982
- var result = new Uint8Array(first.byteLength + second.byteLength);
11983
- result.set(new Uint8Array(first));
11984
- result.set(new Uint8Array(second), first.byteLength);
11985
- return result ;
11986
- }
11987
- function hexToBinaryString(hex2) {
11988
- var bytes = [], length = hex2.length, x;
11989
- for (x = 0; x < length - 1; x += 2) {
11990
- bytes.push(parseInt(hex2.substr(x, 2), 16));
11991
- }
11992
- return String.fromCharCode.apply(String, bytes);
11993
- }
11994
- function SparkMD52() {
11995
- this.reset();
11996
- }
11997
- SparkMD52.prototype.append = function(str) {
11998
- this.appendBinary(toUtf8(str));
11999
- return this;
12000
- };
12001
- SparkMD52.prototype.appendBinary = function(contents) {
12002
- this._buff += contents;
12003
- this._length += contents.length;
12004
- var length = this._buff.length, i;
12005
- for (i = 64; i <= length; i += 64) {
12006
- md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)));
12007
- }
12008
- this._buff = this._buff.substring(i - 64);
12009
- return this;
12010
- };
12011
- SparkMD52.prototype.end = function(raw) {
12012
- var buff = this._buff, length = buff.length, i, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ret;
12013
- for (i = 0; i < length; i += 1) {
12014
- tail[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3);
12015
- }
12016
- this._finish(tail, length);
12017
- ret = hex(this._hash);
12018
- if (raw) {
12019
- ret = hexToBinaryString(ret);
12020
- }
12021
- this.reset();
12022
- return ret;
12023
- };
12024
- SparkMD52.prototype.reset = function() {
12025
- this._buff = "";
12026
- this._length = 0;
12027
- this._hash = [1732584193, -271733879, -1732584194, 271733878];
12028
- return this;
12029
- };
12030
- SparkMD52.prototype.getState = function() {
12031
- return {
12032
- buff: this._buff,
12033
- length: this._length,
12034
- hash: this._hash.slice()
12035
- };
12036
- };
12037
- SparkMD52.prototype.setState = function(state) {
12038
- this._buff = state.buff;
12039
- this._length = state.length;
12040
- this._hash = state.hash;
12041
- return this;
12042
- };
12043
- SparkMD52.prototype.destroy = function() {
12044
- delete this._hash;
12045
- delete this._buff;
12046
- delete this._length;
12047
- };
12048
- SparkMD52.prototype._finish = function(tail, length) {
12049
- var i = length, tmp, lo, hi;
12050
- tail[i >> 2] |= 128 << (i % 4 << 3);
12051
- if (i > 55) {
12052
- md5cycle(this._hash, tail);
12053
- for (i = 0; i < 16; i += 1) {
12054
- tail[i] = 0;
12055
- }
12056
- }
12057
- tmp = this._length * 8;
12058
- tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
12059
- lo = parseInt(tmp[2], 16);
12060
- hi = parseInt(tmp[1], 16) || 0;
12061
- tail[14] = lo;
12062
- tail[15] = hi;
12063
- md5cycle(this._hash, tail);
12064
- };
12065
- SparkMD52.hash = function(str, raw) {
12066
- return SparkMD52.hashBinary(toUtf8(str), raw);
12067
- };
12068
- SparkMD52.hashBinary = function(content, raw) {
12069
- var hash = md51(content), ret = hex(hash);
12070
- return raw ? hexToBinaryString(ret) : ret;
12071
- };
12072
- SparkMD52.ArrayBuffer = function() {
12073
- this.reset();
12074
- };
12075
- SparkMD52.ArrayBuffer.prototype.append = function(arr) {
12076
- var buff = concatenateArrayBuffers(this._buff.buffer, arr), length = buff.length, i;
12077
- this._length += arr.byteLength;
12078
- for (i = 64; i <= length; i += 64) {
12079
- md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)));
12080
- }
12081
- this._buff = i - 64 < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0);
12082
- return this;
12083
- };
12084
- SparkMD52.ArrayBuffer.prototype.end = function(raw) {
12085
- var buff = this._buff, length = buff.length, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], i, ret;
12086
- for (i = 0; i < length; i += 1) {
12087
- tail[i >> 2] |= buff[i] << (i % 4 << 3);
12088
- }
12089
- this._finish(tail, length);
12090
- ret = hex(this._hash);
12091
- if (raw) {
12092
- ret = hexToBinaryString(ret);
12093
- }
12094
- this.reset();
12095
- return ret;
12096
- };
12097
- SparkMD52.ArrayBuffer.prototype.reset = function() {
12098
- this._buff = new Uint8Array(0);
12099
- this._length = 0;
12100
- this._hash = [1732584193, -271733879, -1732584194, 271733878];
12101
- return this;
12102
- };
12103
- SparkMD52.ArrayBuffer.prototype.getState = function() {
12104
- var state = SparkMD52.prototype.getState.call(this);
12105
- state.buff = arrayBuffer2Utf8Str(state.buff);
12106
- return state;
12107
- };
12108
- SparkMD52.ArrayBuffer.prototype.setState = function(state) {
12109
- state.buff = utf8Str2ArrayBuffer(state.buff, true);
12110
- return SparkMD52.prototype.setState.call(this, state);
12111
- };
12112
- SparkMD52.ArrayBuffer.prototype.destroy = SparkMD52.prototype.destroy;
12113
- SparkMD52.ArrayBuffer.prototype._finish = SparkMD52.prototype._finish;
12114
- SparkMD52.ArrayBuffer.hash = function(arr, raw) {
12115
- var hash = md51_array(new Uint8Array(arr)), ret = hex(hash);
12116
- return raw ? hexToBinaryString(ret) : ret;
12117
- };
12118
- return SparkMD52;
12119
- });
12120
- }
12121
- });
12122
-
12123
- // src/types.ts
12124
- var FILE_STATUSES = {
12125
- PENDING: "pending",
12126
- PROCESSING: "processing",
12127
- VALIDATION_FAILED: "validation_failed",
12128
- PROCESSING_ERROR: "processing_error",
12129
- EMPTY_FILE: "empty_file",
12130
- READY: "ready",
12131
- UPLOADING: "uploading",
12132
- COMPLETE: "complete",
12133
- ERROR: "error"
12134
- };
12135
- var DEFAULT_VALIDATION = {
12136
- maxFileSize: 5 * 1024 * 1024,
12137
- // 5MB
12138
- maxTotalSize: 25 * 1024 * 1024,
12139
- // 25MB
12140
- maxFilesCount: 100
12141
- };
12142
-
12143
11703
  // src/utils/zipExtractor.ts
12144
11704
  var import_jszip = __toESM(require_jszip_min());
12145
11705
 
@@ -12222,45 +11782,31 @@ function isZipFile(file) {
12222
11782
  return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
12223
11783
  }
12224
11784
 
11785
+ // src/types.ts
11786
+ var FILE_STATUSES = {
11787
+ PENDING: "pending",
11788
+ PROCESSING: "processing",
11789
+ VALIDATION_FAILED: "validation_failed",
11790
+ PROCESSING_ERROR: "processing_error",
11791
+ EMPTY_FILE: "empty_file",
11792
+ READY: "ready",
11793
+ UPLOADING: "uploading",
11794
+ COMPLETE: "complete",
11795
+ ERROR: "error"
11796
+ };
11797
+
12225
11798
  // src/utils/fileProcessing.ts
12226
- var import_spark_md5 = __toESM(require_spark_md5());
12227
- async function calculateMD5(buffer) {
12228
- const spark = new import_spark_md5.default.ArrayBuffer();
12229
- spark.append(buffer);
12230
- return spark.end();
12231
- }
12232
- function formatFileSize(bytes, decimals = 1) {
12233
- if (bytes === 0) return "0 Bytes";
12234
- const k = 1024;
12235
- const sizes = ["Bytes", "KB", "MB", "GB"];
12236
- const i = Math.floor(Math.log(bytes) / Math.log(k));
12237
- return parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)) + " " + sizes[i];
12238
- }
11799
+ var formatFileSize = formatFileSize$1;
12239
11800
  async function createProcessedFile(file, options) {
12240
11801
  const webkitPath = file.webkitRelativePath || "";
12241
11802
  const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
12242
- const shouldCalculateMD5 = options?.calculateMD5 !== false;
12243
11803
  const type = file.type || getMimeType(path);
12244
- let md5;
12245
- let status = FILE_STATUSES.PENDING;
12246
- let statusMessage;
12247
- if (shouldCalculateMD5) {
12248
- try {
12249
- const buffer = await file.arrayBuffer();
12250
- md5 = await calculateMD5(buffer);
12251
- } catch (error) {
12252
- const errorMsg = error instanceof Error ? error.message : String(error);
12253
- console.error(`Error calculating MD5 for ${path}:`, error);
12254
- status = FILE_STATUSES.PROCESSING_ERROR;
12255
- statusMessage = `Failed to calculate checksum: ${errorMsg}`;
12256
- }
12257
- }
12258
11804
  return {
12259
11805
  // StaticFile properties (SDK compatibility)
11806
+ // Note: md5 is intentionally undefined - Ship SDK will calculate it during deployment
12260
11807
  content: file,
12261
11808
  path,
12262
11809
  size: file.size,
12263
- md5,
12264
11810
  // ProcessedFile-specific properties (UI functionality)
12265
11811
  id: crypto.randomUUID(),
12266
11812
  file,
@@ -12268,109 +11814,10 @@ async function createProcessedFile(file, options) {
12268
11814
  name: path.split("/").pop() || file.name,
12269
11815
  type,
12270
11816
  lastModified: file.lastModified,
12271
- status,
12272
- statusMessage
11817
+ status: FILE_STATUSES.PENDING
12273
11818
  };
12274
11819
  }
12275
- function validateFiles(files, config) {
12276
- const result = [];
12277
- const validFiles = [];
12278
- let error = null;
12279
- if (files.length > config.maxFilesCount) {
12280
- error = {
12281
- error: "File Count Exceeded",
12282
- details: `Number of files (${files.length}) exceeds the limit of ${config.maxFilesCount}.`,
12283
- isClientError: true
12284
- };
12285
- return {
12286
- files: files.map((f) => ({
12287
- ...f,
12288
- status: FILE_STATUSES.VALIDATION_FAILED,
12289
- statusMessage: error.details
12290
- })),
12291
- validFiles: [],
12292
- error
12293
- };
12294
- }
12295
- let totalSize = 0;
12296
- for (const file of files) {
12297
- if (file.status === FILE_STATUSES.PROCESSING_ERROR) {
12298
- result.push(file);
12299
- if (!error) {
12300
- error = {
12301
- error: "Processing Error",
12302
- details: file.statusMessage || "A file failed during processing.",
12303
- isClientError: true
12304
- };
12305
- }
12306
- continue;
12307
- }
12308
- if (file.size === 0) {
12309
- result.push({
12310
- ...file,
12311
- status: FILE_STATUSES.EMPTY_FILE,
12312
- statusMessage: "File is empty (0 bytes)"
12313
- });
12314
- if (!error) {
12315
- error = {
12316
- error: "Empty File",
12317
- details: `File ${file.name} is empty (0 bytes).`,
12318
- isClientError: true
12319
- };
12320
- }
12321
- continue;
12322
- }
12323
- if (file.size > config.maxFileSize) {
12324
- result.push({
12325
- ...file,
12326
- status: FILE_STATUSES.VALIDATION_FAILED,
12327
- statusMessage: `File size (${formatFileSize(file.size)}) exceeds limit of ${formatFileSize(config.maxFileSize)}`
12328
- });
12329
- if (!error) {
12330
- error = {
12331
- error: "File Too Large",
12332
- details: `File ${file.name} (${formatFileSize(file.size)}) exceeds individual file size limit of ${formatFileSize(config.maxFileSize)}.`,
12333
- isClientError: true
12334
- };
12335
- }
12336
- continue;
12337
- }
12338
- totalSize += file.size;
12339
- if (totalSize > config.maxTotalSize) {
12340
- result.push({
12341
- ...file,
12342
- status: FILE_STATUSES.VALIDATION_FAILED,
12343
- statusMessage: `Total size would exceed limit of ${formatFileSize(config.maxTotalSize)}`
12344
- });
12345
- if (!error) {
12346
- error = {
12347
- error: "Total Size Exceeded",
12348
- details: `Total size of files (${formatFileSize(totalSize)}) exceeds the limit of ${formatFileSize(config.maxTotalSize)}.`,
12349
- isClientError: true
12350
- };
12351
- }
12352
- continue;
12353
- }
12354
- const validFile = {
12355
- ...file,
12356
- status: FILE_STATUSES.READY,
12357
- statusMessage: "Ready for upload"
12358
- };
12359
- result.push(validFile);
12360
- validFiles.push(validFile);
12361
- }
12362
- return { files: result, validFiles, error };
12363
- }
12364
- function getValidFiles(files) {
12365
- return files.filter((f) => f.status === FILE_STATUSES.READY);
12366
- }
12367
- function allValidFilesHaveChecksums(files) {
12368
- const validFiles = getValidFiles(files);
12369
- if (validFiles.length === 0) {
12370
- return false;
12371
- }
12372
- return validFiles.every((f) => f.md5 !== void 0);
12373
- }
11820
+ var getValidFiles = getValidFiles$1;
12374
11821
  function stripCommonPrefix(files) {
12375
11822
  if (files.length === 0) return files;
12376
11823
  const paths = files.map((f) => f.path);
@@ -12391,17 +11838,15 @@ function stripCommonPrefix(files) {
12391
11838
  path: f.path.startsWith(prefix) ? f.path.slice(prefix.length) : f.path
12392
11839
  }));
12393
11840
  }
12394
-
12395
- // src/hooks/useDrop.ts
12396
- function useDrop(options = {}) {
11841
+ function useDrop(options) {
12397
11842
  const {
12398
- config: customConfig,
11843
+ ship,
12399
11844
  onValidationError,
12400
11845
  onFilesReady,
12401
11846
  stripPrefix = true
12402
11847
  } = options;
12403
- const validationConfig = { ...DEFAULT_VALIDATION, ...customConfig };
12404
11848
  const [files, setFiles] = useState([]);
11849
+ const [sourceName, setSourceName] = useState("");
12405
11850
  const [statusText, setStatusText] = useState("");
12406
11851
  const [isProcessing, setIsProcessing] = useState(false);
12407
11852
  const [validationError, setValidationError] = useState(null);
@@ -12421,6 +11866,18 @@ function useDrop(options = {}) {
12421
11866
  setValidationError(null);
12422
11867
  setStatusText("Processing files...");
12423
11868
  try {
11869
+ let detectedSourceName = "";
11870
+ if (newFiles.length === 1 && isZipFile(newFiles[0])) {
11871
+ detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
11872
+ } else if (newFiles.length > 0) {
11873
+ const firstPath = newFiles[0].webkitRelativePath || "";
11874
+ if (firstPath && firstPath.includes("/")) {
11875
+ detectedSourceName = firstPath.split("/")[0];
11876
+ } else {
11877
+ detectedSourceName = newFiles[0].name;
11878
+ }
11879
+ }
11880
+ setSourceName(detectedSourceName);
12424
11881
  const allFiles = [];
12425
11882
  const shouldExtractZip = newFiles.length === 1 && isZipFile(newFiles[0]);
12426
11883
  if (shouldExtractZip) {
@@ -12434,12 +11891,13 @@ function useDrop(options = {}) {
12434
11891
  } else {
12435
11892
  allFiles.push(...newFiles);
12436
11893
  }
12437
- setStatusText("Calculating checksums...");
11894
+ setStatusText("Processing files...");
12438
11895
  const processedFiles = await Promise.all(
12439
11896
  allFiles.map((file) => createProcessedFile(file))
12440
11897
  );
12441
11898
  const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
12442
- const validation = validateFiles(finalFiles, validationConfig);
11899
+ const config = await ship.getConfig();
11900
+ const validation = validateFiles(finalFiles, config);
12443
11901
  setFiles(validation.files);
12444
11902
  setValidationError(validation.error);
12445
11903
  if (validation.error) {
@@ -12471,12 +11929,10 @@ function useDrop(options = {}) {
12471
11929
  isProcessingRef.current = false;
12472
11930
  setIsProcessing(false);
12473
11931
  }
12474
- }, [validationConfig, onValidationError, onFilesReady, stripPrefix]);
12475
- const removeFile = useCallback((fileId) => {
12476
- setFiles((prev) => prev.filter((file) => file.id !== fileId));
12477
- }, []);
11932
+ }, [ship, onValidationError, onFilesReady, stripPrefix]);
12478
11933
  const clearAll = useCallback(() => {
12479
11934
  setFiles([]);
11935
+ setSourceName("");
12480
11936
  setStatusText("");
12481
11937
  setValidationError(null);
12482
11938
  isProcessingRef.current = false;
@@ -12490,15 +11946,13 @@ function useDrop(options = {}) {
12490
11946
  (file) => file.id === fileId ? { ...file, ...state } : file
12491
11947
  ));
12492
11948
  }, []);
12493
- const hasChecksums = allValidFilesHaveChecksums(files);
12494
11949
  return {
12495
11950
  files,
11951
+ sourceName,
12496
11952
  statusText,
12497
11953
  isProcessing,
12498
11954
  validationError,
12499
- hasChecksums,
12500
11955
  processFiles,
12501
- removeFile,
12502
11956
  clearAll,
12503
11957
  getValidFiles: getValidFilesCallback,
12504
11958
  updateFileStatus
@@ -12528,6 +11982,6 @@ mime-db/index.js:
12528
11982
  *)
12529
11983
  */
12530
11984
 
12531
- export { DEFAULT_VALIDATION, FILE_STATUSES, allValidFilesHaveChecksums, calculateMD5, createProcessedFile, extractZipToFiles, formatFileSize, getValidFiles, isJunkFile, isZipFile, normalizePath, stripCommonPrefix, useDrop, validateFiles };
11985
+ export { FILE_STATUSES, createProcessedFile, extractZipToFiles, formatFileSize, getValidFiles, isJunkFile, isZipFile, normalizePath, stripCommonPrefix, useDrop };
12532
11986
  //# sourceMappingURL=index.js.map
12533
11987
  //# sourceMappingURL=index.js.map