smart-dropzone-react
Version:
🚀 A production-ready React dropzone component with smart defaults, drag & drop reordering, chunked uploads, resume functionality, and comprehensive provider support (Cloudinary, AWS S3, Supabase)
2 lines • 2.84 kB
JavaScript
var chunkBYLIBOAU_cjs=require('./chunk-BYLIBOAU.cjs');var o=class o{constructor(){chunkBYLIBOAU_cjs.a(this,"events",[]);chunkBYLIBOAU_cjs.a(this,"startTime",performance.now());chunkBYLIBOAU_cjs.a(this,"renderStartTime",0);chunkBYLIBOAU_cjs.a(this,"uploadStartTimes",new Map);}static getInstance(){return o.instance||(o.instance=new o),o.instance}startRender(){this.renderStartTime=performance.now();}endRender(){let e=performance.now()-this.renderStartTime;return this.events.push({type:"render",timestamp:Date.now(),duration:e}),e}startUpload(e){this.uploadStartTimes.set(e,performance.now());}endUpload(e,t){let r=this.uploadStartTimes.get(e);if(!r)return 0;let n=performance.now()-r;return this.uploadStartTimes.delete(e),this.events.push({type:t?"success":"error",timestamp:Date.now(),duration:n,metadata:{fileId:e,success:t}}),n}recordEvent(e,t){this.events.push({type:e,timestamp:Date.now(),metadata:t});}getMetrics(){let e=this.events.filter(i=>i.type==="render"),t=this.events.filter(i=>i.type==="success"),r=this.events.filter(i=>i.type==="error"),n=e.length>0?e.reduce((i,d)=>i+(d.duration||0),0)/e.length:0,s=t.length>0?t.reduce((i,d)=>i+(d.duration||0),0)/t.length:0,a=s>0?1e3/s:0,u=this.events.length>0?r.length/this.events.length:0,c=this.events.length>0?t.length/this.events.length:0;return {bundleSize:{raw:this.getBundleSize(),gzipped:this.getBundleSize()*.3,minified:this.getBundleSize()*.7},runtime:{renderTime:n,uploadSpeed:a,memoryUsage:this.getMemoryUsage(),cpuUsage:this.getCpuUsage()},userExperience:{timeToInteractive:this.getTimeToInteractive(),firstUploadTime:this.getFirstUploadTime(),errorRate:u,successRate:c}}}getBundleSize(){return 40*1024}getMemoryUsage(){if("memory"in performance){let e=performance.memory;return e.usedJSHeapSize/e.jsHeapSizeLimit}return 0}getCpuUsage(){return 0}getTimeToInteractive(){let e=this.events.find(t=>t.type==="render");return e?e.timestamp-this.startTime:0}getFirstUploadTime(){let e=this.events.find(t=>t.type==="success");return e?e.timestamp-this.startTime:0}reset(){this.events=[],this.startTime=performance.now(),this.uploadStartTimes.clear();}exportData(){return [...this.events]}};chunkBYLIBOAU_cjs.a(o,"instance");var p=o,l=class{static debounce(e,t){let r;return (...n)=>{clearTimeout(r),r=setTimeout(()=>e(...n),t);}}static throttle(e,t){let r;return (...n)=>{r||(e(...n),r=true,setTimeout(()=>r=false,t));}}static memoize(e,t){let r=new Map;return((...n)=>{let s=t?t(...n):JSON.stringify(n);if(r.has(s))return r.get(s);let a=e(...n);return r.set(s,a),a})}static async retry(e,t={}){let{maxAttempts:r=3,delay:n=1e3}=t,s;for(let a=0;a<r;a++)try{return await e()}catch(u){s=u,a<r-1&&await new Promise(c=>setTimeout(c,n*Math.pow(2,a)));}throw s}};exports.a=p;exports.b=l;//# sourceMappingURL=chunk-GUDLRPF5.cjs.map
//# sourceMappingURL=chunk-GUDLRPF5.cjs.map
;