UNPKG

pushduck

Version:

The fastest way to add file uploads to any web application. Enterprise security, edge-ready. Works with 16+ frameworks and 5+ storage providers. No heavy AWS SDK required.

1 lines 1.02 kB
"use client";import{n as e,r as t,t as n}from"./use-upload-route-6uuBgBVq.mjs";import{useCallback as r}from"react";function i(e,n,i){let a=t(e,{endpoint:i?.endpoint||n.endpoint,onSuccess:i?.onSuccess||n.defaultOptions?.onSuccess,onError:i?.onError||n.defaultOptions?.onError,onProgress:i?.onProgress||n.defaultOptions?.onProgress}),o=r(async(e,t)=>(await a.uploadFiles(e,t),a.files.map(e=>({...e,metadata:t}))),[a.uploadFiles,a.files,e]);return{files:a.files,uploadFiles:o,reset:a.reset,isUploading:a.isUploading,errors:a.errors,routeName:e,progress:a.progress,uploadSpeed:a.uploadSpeed,eta:a.eta}}function a(e){return new Proxy({},{get(t,n){if(typeof n!=`string`)throw Error(`Invalid route access: Routes must be strings, got ${typeof n}`);return t=>i(n,e,t)},has(e,t){return typeof t==`string`},ownKeys(){return[]},getOwnPropertyDescriptor(e,t){if(typeof t==`string`)return{enumerable:!0,configurable:!0,get:()=>this.get(e,t,e)}}})}export{a as createUploadClient,n as formatETA,e as formatUploadSpeed,t as useUploadRoute};