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