@visulima/storage-client 1.0.0-alpha.14 → 1.0.0-alpha.16

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +23 -0
  3. package/dist/index.d.ts +24 -4
  4. package/dist/index.js +1 -1
  5. package/dist/packem_shared/MemoryUrlStorage-DEJTeeWV.js +1 -0
  6. package/dist/packem_shared/UploadControl-CKU7Tv3Q.js +1 -0
  7. package/dist/packem_shared/createChunkedRestAdapter-DwdZ3iXf.js +1 -0
  8. package/dist/packem_shared/createChunkedRestUpload-DZbjiORY.js +1 -0
  9. package/dist/packem_shared/createChunkedRestUpload-WgfiLIto.js +1 -0
  10. package/dist/packem_shared/createTusAdapter-DMWzJjQ2.js +1 -0
  11. package/dist/packem_shared/createTusUpload-Con3Nqu0.js +1 -0
  12. package/dist/packem_shared/createTusUpload-l00I3jXp.js +1 -0
  13. package/dist/packem_shared/{createUpload-BF6TujIH.js → createUpload-D3_GPTNX.js} +1 -1
  14. package/dist/packem_shared/{createUpload-0qE79TWD.js → createUpload-RIaQluah.js} +1 -1
  15. package/dist/packem_shared/defaultFingerprint-CI2Sdd2s.js +1 -0
  16. package/dist/packem_shared/uploader.d-B1FMsMcN.d.ts +381 -0
  17. package/dist/packem_shared/useChunkedRestUpload-BwOE2zhr.js +1 -0
  18. package/dist/packem_shared/useChunkedRestUpload-DNGNQIIx.js +1 -0
  19. package/dist/packem_shared/useTusUpload-Bz4XE_4p.js +1 -0
  20. package/dist/packem_shared/useTusUpload-Dsq9GGEt.js +1 -0
  21. package/dist/packem_shared/{useUpload-C5ZiPWFM.js → useUpload-B6rd2qkI.js} +1 -1
  22. package/dist/packem_shared/{useUpload-7OjscFW6.js → useUpload-BhLsUgVG.js} +1 -1
  23. package/dist/react/index.d.ts +17 -1
  24. package/dist/react/index.js +1 -1
  25. package/dist/solid/index.d.ts +13 -1
  26. package/dist/solid/index.js +1 -1
  27. package/dist/svelte/index.d.ts +13 -1
  28. package/dist/svelte/index.js +1 -1
  29. package/dist/vue/index.d.ts +13 -1
  30. package/dist/vue/index.js +1 -1
  31. package/package.json +2 -4
  32. package/dist/packem_shared/createChunkedRestAdapter-CWFhVX6x.js +0 -1
  33. package/dist/packem_shared/createChunkedRestUpload-BH_5ZAr2.js +0 -1
  34. package/dist/packem_shared/createChunkedRestUpload-DAoXFznW.js +0 -1
  35. package/dist/packem_shared/createTusAdapter-BbFsUNsP.js +0 -1
  36. package/dist/packem_shared/createTusUpload-DKIIHh2X.js +0 -1
  37. package/dist/packem_shared/createTusUpload-rZKMrL5n.js +0 -1
  38. package/dist/packem_shared/uploader.d-DsC50BbX.d.ts +0 -223
  39. package/dist/packem_shared/useChunkedRestUpload-C9RhEtUt.js +0 -1
  40. package/dist/packem_shared/useChunkedRestUpload-tirJ_5VX.js +0 -1
  41. package/dist/packem_shared/useTusUpload-B5KsdwDR.js +0 -1
  42. package/dist/packem_shared/useTusUpload-BwF0G1LE.js +0 -1
@@ -1,4 +1,4 @@
1
- import { c as UploadItem, B as BatchState, U as UploadResult, F as FileMeta, g as UploadMethod } from "../packem_shared/uploader.d-DsC50BbX.js";
1
+ import { k as UploadItem, B as BatchState, b as UploadResult, U as UploadControl, F as FingerprintFunction, a as UrlStorage, d as FileMeta, r as UploadMethod } from "../packem_shared/uploader.d-B1FMsMcN.js";
2
2
  import { Ref, MaybeRefOrGetter, ComputedRef } from 'vue';
3
3
  interface UseAbortAllOptions {
4
4
  /** Upload endpoint URL (used to create uploader instance) */
@@ -227,8 +227,12 @@ declare const useBatchUpload: (options: UseBatchUploadOptions) => UseBatchUpload
227
227
  interface UseChunkedRestUploadOptions {
228
228
  /** Chunk size for chunked REST uploads (default: 5MB) */
229
229
  chunkSize?: number;
230
+ /** Unified control handle. See `UploadControl`. */
231
+ control?: UploadControl;
230
232
  /** Chunked REST upload endpoint URL */
231
233
  endpoint: string;
234
+ /** Customise the resume fingerprint. */
235
+ fingerprint?: FingerprintFunction;
232
236
  /** Maximum number of retry attempts */
233
237
  maxRetries?: number;
234
238
  /** Additional metadata to include with the upload */
@@ -247,6 +251,8 @@ interface UseChunkedRestUploadOptions {
247
251
  onSuccess?: (file: UploadResult) => void;
248
252
  /** Enable automatic retry on failure */
249
253
  retry?: boolean;
254
+ /** Persistent storage for resume identifiers. */
255
+ urlStorage?: UrlStorage;
250
256
  }
251
257
  interface UseChunkedRestUploadReturn {
252
258
  /** Abort the current upload */
@@ -684,8 +690,12 @@ declare const useTransformMetadata: (options: UseTransformMetadataOptions) => Us
684
690
  interface UseTusUploadOptions {
685
691
  /** Chunk size for TUS uploads (default: 1MB) */
686
692
  chunkSize?: number;
693
+ /** Unified control handle. See `UploadControl`. */
694
+ control?: UploadControl;
687
695
  /** TUS upload endpoint URL */
688
696
  endpoint: string;
697
+ /** Customise the resume fingerprint. */
698
+ fingerprint?: FingerprintFunction;
689
699
  /** Maximum number of retry attempts */
690
700
  maxRetries?: number;
691
701
  /** Additional metadata to include with the upload */
@@ -704,6 +714,8 @@ interface UseTusUploadOptions {
704
714
  onSuccess?: (file: UploadResult) => void;
705
715
  /** Enable automatic retry on failure */
706
716
  retry?: boolean;
717
+ /** Persistent storage for resume URLs. */
718
+ urlStorage?: UrlStorage;
707
719
  }
708
720
  interface UseTusUploadReturn {
709
721
  /** Abort the current upload */
package/dist/vue/index.js CHANGED
@@ -1 +1 @@
1
- import{useAbortAll as o}from"../packem_shared/useAbortAll-DNzPcfOt.js";import{useAbortBatch as s}from"../packem_shared/useAbortBatch-Jb37hbXq.js";import{useAbortItem as u}from"../packem_shared/useAbortItem-DTFUUKVu.js";import{useAllAbortListener as f}from"../packem_shared/useAllAbortListener-BBw02ZoD.js";import{useBatchCancelledListener as a}from"../packem_shared/useBatchCancelledListener-C3IW43nC.js";import{useBatchDeleteFiles as i}from"../packem_shared/useBatchDeleteFiles-DmKXrcBR.js";import{useBatchErrorListener as h}from"../packem_shared/useBatchErrorListener-Ck1BwfZA.js";import{useBatchFinalizeListener as F}from"../packem_shared/useBatchFinalizeListener-D7TRElSE.js";import{useBatchFinishListener as B}from"../packem_shared/useBatchFinishListener-VdCzyg4J.js";import{useBatchProgressListener as A}from"../packem_shared/useBatchProgressListener-B08x2n9U.js";import{useBatchRetry as b}from"../packem_shared/useBatchRetry-DahiIOXJ.js";import{useBatchStartListener as R}from"../packem_shared/useBatchStartListener-DndF1z5v.js";import{useBatchUpload as C}from"../packem_shared/useBatchUpload-IZkU_Gop.js";import{useChunkedRestUpload as M}from"../packem_shared/useChunkedRestUpload-C9RhEtUt.js";import{useDeleteFile as k}from"../packem_shared/useDeleteFile-Dsw372GL.js";import{useFileInput as I}from"../packem_shared/useFileInput-BUPBo2m_.js";import{useGetFile as z}from"../packem_shared/useGetFile-BkmKk12o.js";import{useGetFileList as H}from"../packem_shared/useGetFileList-CkAmk7lP.js";import{useGetFileMeta as j}from"../packem_shared/useGetFileMeta-eKrJc2p1.js";import{useHeadFile as v}from"../packem_shared/useHeadFile-D5CQQnyf.js";import{useMultipartUpload as J}from"../packem_shared/useMultipartUpload-CbRSpnTb.js";import{usePasteUpload as N}from"../packem_shared/usePasteUpload-COdUC9xU.js";import{usePatchChunk as Q}from"../packem_shared/usePatchChunk-DqZtVBBl.js";import{usePutFile as W}from"../packem_shared/usePutFile-CFaBgDX4.js";import{useRetry as Y}from"../packem_shared/useRetry-DHjDuH0H.js";import{useRetryListener as _}from"../packem_shared/useRetryListener-CAIyK1_Q.js";import{useTransformFile as ee}from"../packem_shared/useTransformFile-BCyX-R_e.js";import{useTransformMetadata as oe}from"../packem_shared/useTransformMetadata-DjcVDZOc.js";import{useTusUpload as se}from"../packem_shared/useTusUpload-B5KsdwDR.js";import{useUpload as ue}from"../packem_shared/useUpload-7OjscFW6.js";export{o as useAbortAll,s as useAbortBatch,u as useAbortItem,f as useAllAbortListener,a as useBatchCancelledListener,i as useBatchDeleteFiles,h as useBatchErrorListener,F as useBatchFinalizeListener,B as useBatchFinishListener,A as useBatchProgressListener,b as useBatchRetry,R as useBatchStartListener,C as useBatchUpload,M as useChunkedRestUpload,k as useDeleteFile,I as useFileInput,z as useGetFile,H as useGetFileList,j as useGetFileMeta,v as useHeadFile,J as useMultipartUpload,N as usePasteUpload,Q as usePatchChunk,W as usePutFile,Y as useRetry,_ as useRetryListener,ee as useTransformFile,oe as useTransformMetadata,se as useTusUpload,ue as useUpload};
1
+ import{useAbortAll as o}from"../packem_shared/useAbortAll-DNzPcfOt.js";import{useAbortBatch as s}from"../packem_shared/useAbortBatch-Jb37hbXq.js";import{useAbortItem as u}from"../packem_shared/useAbortItem-DTFUUKVu.js";import{useAllAbortListener as f}from"../packem_shared/useAllAbortListener-BBw02ZoD.js";import{useBatchCancelledListener as a}from"../packem_shared/useBatchCancelledListener-C3IW43nC.js";import{useBatchDeleteFiles as i}from"../packem_shared/useBatchDeleteFiles-DmKXrcBR.js";import{useBatchErrorListener as h}from"../packem_shared/useBatchErrorListener-Ck1BwfZA.js";import{useBatchFinalizeListener as F}from"../packem_shared/useBatchFinalizeListener-D7TRElSE.js";import{useBatchFinishListener as B}from"../packem_shared/useBatchFinishListener-VdCzyg4J.js";import{useBatchProgressListener as A}from"../packem_shared/useBatchProgressListener-B08x2n9U.js";import{useBatchRetry as b}from"../packem_shared/useBatchRetry-DahiIOXJ.js";import{useBatchStartListener as R}from"../packem_shared/useBatchStartListener-DndF1z5v.js";import{useBatchUpload as C}from"../packem_shared/useBatchUpload-IZkU_Gop.js";import{useChunkedRestUpload as M}from"../packem_shared/useChunkedRestUpload-DNGNQIIx.js";import{useDeleteFile as k}from"../packem_shared/useDeleteFile-Dsw372GL.js";import{useFileInput as I}from"../packem_shared/useFileInput-BUPBo2m_.js";import{useGetFile as z}from"../packem_shared/useGetFile-BkmKk12o.js";import{useGetFileList as H}from"../packem_shared/useGetFileList-CkAmk7lP.js";import{useGetFileMeta as j}from"../packem_shared/useGetFileMeta-eKrJc2p1.js";import{useHeadFile as v}from"../packem_shared/useHeadFile-D5CQQnyf.js";import{useMultipartUpload as J}from"../packem_shared/useMultipartUpload-CbRSpnTb.js";import{usePasteUpload as N}from"../packem_shared/usePasteUpload-COdUC9xU.js";import{usePatchChunk as Q}from"../packem_shared/usePatchChunk-DqZtVBBl.js";import{usePutFile as W}from"../packem_shared/usePutFile-CFaBgDX4.js";import{useRetry as Y}from"../packem_shared/useRetry-DHjDuH0H.js";import{useRetryListener as _}from"../packem_shared/useRetryListener-CAIyK1_Q.js";import{useTransformFile as ee}from"../packem_shared/useTransformFile-BCyX-R_e.js";import{useTransformMetadata as oe}from"../packem_shared/useTransformMetadata-DjcVDZOc.js";import{useTusUpload as se}from"../packem_shared/useTusUpload-Bz4XE_4p.js";import{useUpload as ue}from"../packem_shared/useUpload-BhLsUgVG.js";export{o as useAbortAll,s as useAbortBatch,u as useAbortItem,f as useAllAbortListener,a as useBatchCancelledListener,i as useBatchDeleteFiles,h as useBatchErrorListener,F as useBatchFinalizeListener,B as useBatchFinishListener,A as useBatchProgressListener,b as useBatchRetry,R as useBatchStartListener,C as useBatchUpload,M as useChunkedRestUpload,k as useDeleteFile,I as useFileInput,z as useGetFile,H as useGetFileList,j as useGetFileMeta,v as useHeadFile,J as useMultipartUpload,N as usePasteUpload,Q as usePatchChunk,W as usePutFile,Y as useRetry,_ as useRetryListener,ee as useTransformFile,oe as useTransformMetadata,se as useTusUpload,ue as useUpload};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/storage-client",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.16",
4
4
  "description": "The upload client library. Simple and easy file uploads for React | Vue | Solid | Svelte.",
5
5
  "keywords": [
6
6
  "abort-upload",
@@ -28,9 +28,7 @@
28
28
  "vue-query"
29
29
  ],
30
30
  "homepage": "https://visulima.com/packages/storage-client",
31
- "bugs": {
32
- "url": "https://github.com/visulima/visulima/issues"
33
- },
31
+ "bugs": "https://github.com/visulima/visulima/issues",
34
32
  "repository": {
35
33
  "type": "git",
36
34
  "url": "git+https://github.com/visulima/visulima.git",
@@ -1 +0,0 @@
1
- var I=Object.defineProperty;var A=(m,h)=>I(m,"name",{value:h,configurable:!0});var N=Object.defineProperty,s=A((m,h)=>N(m,"name",{value:h,configurable:!0}),"s");const D=s(m=>{const{chunkSize:h=5242880,endpoint:f,maxRetries:y=3,metadata:S={},retry:E=!0}=m;let r={aborted:!1,paused:!1,totalSize:0,uploadedChunks:new Set},$,z,g,b;const O=s(async(t,e)=>{if(e?.aborted)throw new Error("Aborted");const a=100,n=Date.now();for(;Date.now()-n<t;){if(e?.aborted)throw new Error("Aborted");const i=t-(Date.now()-n),d=Math.min(a,i);await new Promise(u=>{setTimeout(()=>{u()},d)})}},"abortableDelay"),w=s(async(t,e,a=y)=>{try{const n=await fetch(t,e);if(!n.ok&&a>0&&E){const i=1e3*2**(y-a);return await O(i,e.signal),w(t,e,a-1)}return n}catch(n){if(e.signal?.aborted||n instanceof Error&&n.message==="Aborted")throw n;if(a>0&&E){const i=1e3*2**(y-a);return await O(i,e.signal),w(t,e,a-1)}throw n}},"fetchWithRetry"),U=s(async t=>{const e={"Content-Type":t.type||"application/octet-stream","X-Chunked-Upload":"true","X-Total-Size":String(t.size)};Object.keys(S).length>0&&(e["X-File-Metadata"]=JSON.stringify(S)),t.name&&(e["Content-Disposition"]=`attachment; filename="${t.name}"`);const a=await w(f,{body:new Uint8Array(0),headers:e,method:"POST"});if(!a.ok)throw new Error(`Failed to create upload session: ${String(a.status)} ${a.statusText}`);const n=a.headers.get("X-Upload-ID")??a.headers.get("Location")?.split("/").pop();if(!n)throw new Error("Failed to get upload ID from server");return n},"createUpload"),k=s(async t=>{const e=f.endsWith("/")?`${f}${t}`:`${f}/${t}`,a=await w(e,{method:"HEAD"});if(!a.ok)throw new Error(`Failed to get upload status: ${String(a.status)} ${a.statusText}`);const n=Number.parseInt(a.headers.get("X-Upload-Offset")??"0",10),i=a.headers.get("X-Received-Chunks");let d=[];if(i)try{const u=JSON.parse(i);Array.isArray(u)&&(d=u)}catch{}return{chunks:d,offset:n}},"getUploadStatus"),P=s(async(t,e,a,n,i)=>{const d=t.slice(a,n),u=n-a;if(r.uploadedChunks.has(a))return;const p=f.endsWith("/")?`${f}${e}`:`${f}/${e}`,c=await w(p,{body:d,headers:{"Content-Length":String(u),"Content-Type":"application/octet-stream","X-Chunk-Offset":String(a)},method:"PATCH",signal:i});if(!c.ok)throw new Error(`Failed to upload chunk: ${String(c.status)} ${c.statusText}`);r.uploadedChunks.add(a);const o=Number.parseInt(c.headers.get("X-Upload-Offset")??String(n),10),l=Math.round(o/t.size*100);z?.(l,o)},"uploadChunk"),T=s(async(t,e,a)=>{const n=Math.ceil(t.size/h),{chunks:i}=await k(e);for(const l of i)r.uploadedChunks.add(l.offset);const d=[];for(let l=0;l<n;l+=1){const C=l*h,v=Math.min(C+h,t.size);if(!r.uploadedChunks.has(C)){for(;r.paused&&!r.aborted;)await new Promise(F=>{setTimeout(()=>{F()},100)});if(r.aborted)throw new Error("Upload aborted");d.push(P(t,e,C,v,a))}}await Promise.all(d);const u=await k(e);if(u.offset<t.size)throw new Error(`Upload incomplete. Expected ${String(t.size)} bytes, got ${String(u.offset)}`);if(r.uploadedChunks.size<=0)throw new Error("No chunks were uploaded");const p=f.endsWith("/")?`${f}${e}`:`${f}/${e}`,c=await w(p,{method:"GET"});if(!c.ok)throw new Error(`Failed to get upload result: ${String(c.status)} ${c.statusText}`);const o=await c.json();return{bytesWritten:o.bytesWritten??Math.max(t.size,0),contentType:o.contentType??t.type,createdAt:o.createdAt,filename:o.originalName??t.name,id:o.id??e,metadata:o.metadata,name:o.name,originalName:o.originalName??t.name,size:o.size??t.size,status:o.status??"completed",url:o.url}},"performUpload");return{abort:s(()=>{r.aborted=!0,r.paused=!1,r.abortController?.abort()},"abort"),clear:s(()=>{r={abortController:void 0,aborted:!1,file:void 0,fileId:void 0,paused:!1,totalSize:0,uploadedChunks:new Set}},"clear"),getOffset:s(async()=>{if(!r.fileId)return 0;try{return(await k(r.fileId)).offset}catch{let t=0;for(const e of r.uploadedChunks){const a=Math.min(e+h,r.totalSize);t+=a-e}return t}},"getOffset"),isPaused:s(()=>r.paused,"isPaused"),pause:s(()=>{r.paused=!0},"pause"),resume:s(async()=>{if(!r.fileId||!r.file)throw new Error("No upload to resume");r.paused=!1;const t=new AbortController;r.abortController=t;try{const e=await T(r.file,r.fileId,t.signal);g?.(e)}catch(e){const a=e instanceof Error?e:new Error(String(e));throw b?.(a),a}},"resume"),setOnError:s(t=>{b=t},"setOnError"),setOnFinish:s(t=>{g=t},"setOnFinish"),setOnProgress:s(t=>{z=t},"setOnProgress"),setOnStart:s(t=>{$=t},"setOnStart"),upload:s(async t=>{let e=!1;const a=g,n=b;let i;const d=s(()=>{i&&(clearTimeout(i),i=void 0),g=a,b=n},"cleanupTimeout"),u=s(o=>{e||(e=!0,d(),a?.(o))},"internalFinishCallback"),p=s(o=>{e||(e=!0,d(),n?.(o))},"internalErrorCallback");g=u,b=p,r={aborted:!1,file:t,paused:!1,totalSize:t.size,uploadedChunks:new Set},$?.();const c=(async()=>{const o=new AbortController;r.abortController=o;const l=await U(t);return r.fileId=l,T(t,l,o.signal)})();i=setTimeout(()=>{e||(r.aborted=!0,d(),p(new Error("Upload timeout")))},3e5);try{const o=await c;return u(o),o}catch(o){const l=o instanceof Error?o:new Error(String(o));throw p(l),l}},"upload")}},"createChunkedRestAdapter");export{D as createChunkedRestAdapter};
@@ -1 +0,0 @@
1
- var R=Object.defineProperty;var h=(l,c)=>R(l,"name",{value:c,configurable:!0});import{onMount as k,onDestroy as U}from"svelte";import{writable as i}from"svelte/store";import{createChunkedRestAdapter as x}from"./createChunkedRestAdapter-CWFhVX6x.js";var C=Object.defineProperty,u=h((l,c)=>C(l,"name",{value:c,configurable:!0}),"n");const A=u(l=>{const{chunkSize:c,endpoint:v,maxRetries:O,metadata:g,onError:p,onPause:y,onProgress:E,onResume:P,onStart:S,onSuccess:b,retry:w}=l,d=i(0),s=i(!1),r=i(!1),o=i(),m=i(),f=i(0),t=x({chunkSize:c,endpoint:v,maxRetries:O,metadata:g,retry:w});return k(()=>{t.setOnStart(()=>{s.set(!0),r.set(!1),d.set(0),o.set(void 0),f.set(0),S?.()}),t.setOnProgress((e,n)=>{d.set(e),f.set(n),E?.(e,n)}),t.setOnFinish(e=>{d.set(100),m.set(e),s.set(!1),r.set(!1),b?.(e)}),t.setOnError(e=>{o.set(e),s.set(!1),p?.(e)});const a=setInterval(()=>{t.getOffset().then(e=>(f.set(e),e)).catch(()=>{}),r.set(t.isPaused())},100);U(()=>{clearInterval(a),t.setOnStart(void 0),t.setOnProgress(void 0),t.setOnFinish(void 0),t.setOnError(void 0)})}),{abort:u(()=>{t.abort(),s.set(!1),r.set(!1)},"abort"),error:o,isPaused:r,isUploading:s,offset:f,pause:u(()=>{t.pause(),r.set(!0),y?.()},"pause"),progress:d,reset:u(()=>{t.clear(),d.set(0),s.set(!1),r.set(!1),o.set(void 0),m.set(void 0),f.set(0)},"reset"),result:m,resume:u(async()=>{r.set(!1),s.set(!0),P?.();try{await t.resume()}catch(a){const e=a instanceof Error?a:new Error(String(a));throw o.set(e),s.set(!1),p?.(e),e}},"resume"),upload:u(async a=>{try{return await t.upload(a)}catch(e){const n=e instanceof Error?e:new Error(String(e));throw o.set(n),p?.(n),n}},"upload")}},"createChunkedRestUpload");export{A as createChunkedRestUpload};
@@ -1 +0,0 @@
1
- var z=Object.defineProperty;var h=(u,c)=>z(u,"name",{value:c,configurable:!0});import{createSignal as n,onMount as A,onCleanup as F}from"solid-js";import{createChunkedRestAdapter as j}from"./createChunkedRestAdapter-CWFhVX6x.js";var M=Object.defineProperty,i=h((u,c)=>M(u,"name",{value:c,configurable:!0}),"n");const G=i(u=>{const{chunkSize:c,endpoint:m,maxRetries:g,metadata:O,onError:p,onPause:S,onProgress:y,onResume:E,onStart:P,onSuccess:w,retry:R}=u,[b,d]=n(0),[k,t]=n(!1),[C,s]=n(!1),[U,l]=n(void 0),[x,v]=n(void 0),[I,f]=n(0),r=j({chunkSize:c,endpoint:m,maxRetries:g,metadata:O,retry:R});return A(()=>{r.setOnStart(()=>{t(!0),s(!1),d(0),l(void 0),f(0),P?.()}),r.setOnProgress((e,o)=>{d(e),f(o),y?.(e,o)}),r.setOnFinish(e=>{d(100),v(e),t(!1),s(!1),w?.(e)}),r.setOnError(e=>{l(e),t(!1),p?.(e)});const a=setInterval(()=>{r.getOffset().then(e=>f(e)).catch(()=>{}),s(r.isPaused())},100);F(()=>{clearInterval(a),r.setOnStart(void 0),r.setOnProgress(void 0),r.setOnFinish(void 0),r.setOnError(void 0)})}),{abort:i(()=>{r.abort(),t(!1),s(!1)},"abort"),error:U,isPaused:C,isUploading:k,offset:I,pause:i(()=>{r.pause(),s(!0),S?.()},"pause"),progress:b,reset:i(()=>{r.clear(),d(0),t(!1),s(!1),l(void 0),v(void 0),f(0)},"reset"),result:x,resume:i(async()=>{s(!1),t(!0),E?.();try{await r.resume()}catch(a){const e=a instanceof Error?a:new Error(String(a));throw l(e),t(!1),p?.(e),e}},"resume"),upload:i(async a=>{try{return await r.upload(a)}catch(e){const o=e instanceof Error?e:new Error(String(e));throw l(o),p?.(o),o}},"upload")}},"createChunkedRestUpload");export{G as createChunkedRestUpload};
@@ -1 +0,0 @@
1
- var N=Object.defineProperty;var S=(p,c)=>N(p,"name",{value:c,configurable:!0});var k=Object.defineProperty,a=S((p,c)=>k(p,"name",{value:c,configurable:!0}),"t");const E="1.0.0",x=a(p=>{const c=new TextEncoder().encode(p);let h="";for(const m of c)h+=String.fromCodePoint(m);return btoa(h)},"encodeBase64Utf8"),R=a(p=>{const c=atob(p),h=new Uint8Array(c.length);for(let m=0;m<c.length;m+=1)h[m]=c.codePointAt(m)??0;return new TextDecoder().decode(h)},"decodeBase64Utf8"),$=a(p=>Object.entries(p).map(([c,h])=>{const m=x(h);return`${c} ${m}`}).join(","),"encodeMetadata"),F=a(p=>{if(!p)return{};const c={};return p.split(",").forEach(h=>{const[m,...C]=h.trim().split(" "),b=C.join(" ");if(m&&b)try{c[m]=R(b)}catch{}}),c},"decodeMetadata"),j=a(p=>{const{chunkSize:c=1048576,endpoint:h,maxRetries:m=3,metadata:C={},retry:b=!0}=p;let o,y,z,U,T;const A=a(async t=>{const i={filename:t.name,filetype:t.type,...C},r=await fetch(h,{headers:{"Tus-Resumable":E,"Upload-Length":t.size.toString(),"Upload-Metadata":$(i)},method:"POST"});if(r.status!==201&&r.status!==200)throw new Error(`Failed to create upload: ${String(r.status)} ${r.statusText}`);const e=r.headers.get("Location");if(!e)throw new Error("No Location header in response");let n;if(e.startsWith("http"))n=e;else try{n=new URL(e,h).href}catch{const u="window"in globalThis?globalThis.location.origin:"http://localhost";n=new URL(e,u+h).href}const l=r.headers.get("Upload-Offset");return{initialOffset:l?Number.parseInt(l,10):0,uploadUrl:n}},"createUpload"),O=a(async(t,i)=>{const r=await fetch(t,{headers:{"Tus-Resumable":E},method:"HEAD",signal:i});if(!r.ok){if(r.status===404||r.status===410||r.status===403)return 0;throw new Error(`Failed to get upload offset: ${String(r.status)} ${r.statusText}`)}const e=r.headers.get("Upload-Offset");return e?Number.parseInt(e,10):0},"getUploadOffset"),v=a(async(t,i,r,e)=>{const n=Math.min(r+c,t.size),l=t.slice(r,n),u=await fetch(i,{body:l,headers:{"Content-Length":l.size.toString(),"Content-Type":"application/offset+octet-stream","Tus-Resumable":E,"Upload-Offset":r.toString()},method:"PATCH",signal:e});if(u.status!==204){if(u.status===409)return await O(i);throw u.status===404||u.status===410?new Error("Upload expired or not found"):u.status===415?new Error("Content-Type must be application/offset+octet-stream"):new Error(`Failed to upload chunk: ${String(u.status)} ${u.statusText}`)}const w=u.headers.get("Upload-Offset");if(!w)throw new Error("Missing Upload-Offset header in PATCH response");return Number.parseInt(w,10)},"uploadChunk"),M=a(async(t,i,r=0)=>{const e=o;if(!e)throw new Error("Upload state not initialized");const{abortController:n}=e;let l=r;try{for(;l<t.size;){if(n.signal.aborted)throw new Error("Upload aborted");if(e.isPaused&&await new Promise(f=>{const g=a(()=>{n.signal.aborted?f():e.isPaused?setTimeout(g,100):f()},"checkPause");g()}),n.signal.aborted)throw new Error("Upload aborted");try{l=await v(t,i,l,n.signal),e.offset=l;const f=Math.round(l/t.size*100);y?.(f,l)}catch(f){if(n.signal.aborted)throw new Error("Upload aborted");if(b&&e.retryCount<m){if(e.retryCount+=1,await new Promise(g=>setTimeout(g,1e3*e.retryCount)),n.signal.aborted)throw new Error("Upload aborted");l=await O(i,n.signal);continue}throw f}e.retryCount=0}if(n.signal.aborted)throw new Error("Upload aborted");const u=await fetch(i,{headers:{"Tus-Resumable":E},method:"HEAD",signal:n.signal}),w=u.headers.get("Location")??i,P=u.headers.get("Upload-Metadata"),s=F(P??void 0);let d={};try{d={contentType:u.headers.get("Content-Type")??s.filetype??t.type,id:i.split("/").pop()??"",metadata:s,originalName:s.filename??t.name,size:t.size,status:"completed"}}catch{}return{bytesWritten:l,contentType:d.contentType??t.type,createdAt:d.createdAt,filename:d.originalName??t.name,id:d.id??i.split("/").pop()??"",metadata:d.metadata??s,name:d.name,offset:l,originalName:d.originalName??t.name,size:d.size??t.size,status:d.status??"completed",url:w}}finally{o===e&&(o=void 0)}},"performUpload");return{abort:a(()=>{o&&o.abortController.abort()},"abort"),clear:a(()=>{o&&o.abortController.abort()},"clear"),getOffset:a(()=>o?.offset??0,"getOffset"),isPaused:a(()=>o?.isPaused??!1,"isPaused"),pause:a(()=>{o&&(o.isPaused=!0)},"pause"),resume:a(async()=>{if(!o?.uploadUrl)throw new Error("No upload to resume");o.isPaused=!1},"resume"),setOnError:a(t=>{T=t},"setOnError"),setOnFinish:a(t=>{U=t},"setOnFinish"),setOnProgress:a(t=>{y=t},"setOnProgress"),setOnStart:a(t=>{z=t},"setOnStart"),upload:a(async t=>{let i=!1;const r=U,e=T;let n;const l=a(()=>{n&&(clearTimeout(n),n=void 0),U=r,T=e},"cleanupTimeout"),u=a(s=>{i||(i=!0,l(),r?.(s))},"internalFinishCallback"),w=a(s=>{i||(i=!0,l(),e?.(s),o?.uploadUrl||(o=void 0))},"internalErrorCallback");U=u,T=w,o={abortController:new AbortController,file:t,isPaused:!1,offset:0,retryCount:0,uploadUrl:void 0};const P=(async()=>{z?.();const s=o;let d=s.uploadUrl;if(d===void 0){const{initialOffset:f,uploadUrl:g}=await A(t);d=g,s.uploadUrl=d,s.offset=f,f>0&&y?.(Math.round(f/t.size*100),f)}else{const f=await O(d,s.abortController.signal);f>0&&(s.offset=f,y?.(Math.round(f/t.size*100),f))}return M(t,d,s.offset)})();n=setTimeout(()=>{i||(i=!0,l(),o&&o.abortController.abort(),o&&!o.uploadUrl&&(o=void 0))},3e5);try{const s=await P;return u(s),s}catch(s){const d=s instanceof Error?s:new Error(String(s));throw w(d),d}},"upload")}},"createTusAdapter");export{j as createTusAdapter};
@@ -1 +0,0 @@
1
- var z=Object.defineProperty;var m=(i,u)=>z(i,"name",{value:u,configurable:!0});import{createSignal as o,onMount as A,onCleanup as F}from"solid-js";import{createTusAdapter as j}from"./createTusAdapter-BbFsUNsP.js";var C=Object.defineProperty,n=m((i,u)=>C(i,"name",{value:u,configurable:!0}),"n");const D=n(i=>{const{chunkSize:u,endpoint:g,maxRetries:O,metadata:S,onError:p,onPause:h,onProgress:y,onResume:E,onStart:P,onSuccess:w,retry:b}=i,[x,d]=o(0),[R,t]=o(!1),[T,s]=o(!1),[U,l]=o(void 0),[I,v]=o(void 0),[k,f]=o(0),r=j({chunkSize:u,endpoint:g,maxRetries:O,metadata:S,retry:b});return A(()=>{r.setOnStart(()=>{t(!0),s(!1),d(0),l(void 0),f(0),P?.()}),r.setOnProgress((e,c)=>{d(e),f(c),y?.(e)}),r.setOnFinish(e=>{d(100),v(e),t(!1),s(!1),w?.(e)}),r.setOnError(e=>{l(e),t(!1),p?.(e)});const a=setInterval(()=>{f(r.getOffset()),s(r.isPaused())},100);F(()=>{clearInterval(a),r.setOnStart(void 0),r.setOnProgress(void 0),r.setOnFinish(void 0),r.setOnError(void 0)})}),{abort:n(()=>{r.abort(),t(!1),s(!1)},"abort"),error:U,isPaused:T,isUploading:R,offset:k,pause:n(()=>{r.pause(),s(!0),h?.()},"pause"),progress:x,reset:n(()=>{r.clear(),d(0),t(!1),s(!1),l(void 0),v(void 0),f(0)},"reset"),result:I,resume:n(async()=>{s(!1),t(!0),E?.();try{await r.resume()}catch(a){const e=a instanceof Error?a:new Error(String(a));throw l(e),t(!1),p?.(e),e}},"resume"),upload:n(async a=>{try{return await r.upload(a)}catch(e){const c=e instanceof Error?e:new Error(String(e));throw l(c),p?.(c),c}},"upload")}},"createTusUpload");export{D as createTusUpload};
@@ -1 +0,0 @@
1
- var R=Object.defineProperty;var v=(u,l)=>R(u,"name",{value:l,configurable:!0});import{onMount as U,onDestroy as x}from"svelte";import{writable as n}from"svelte/store";import{createTusAdapter as T}from"./createTusAdapter-BbFsUNsP.js";var k=Object.defineProperty,i=v((u,l)=>k(u,"name",{value:l,configurable:!0}),"n");const A=i(u=>{const{chunkSize:l,endpoint:O,maxRetries:g,metadata:y,onError:p,onPause:S,onProgress:h,onResume:E,onStart:P,onSuccess:b,retry:w}=u,c=n(0),s=n(!1),r=n(!1),o=n(),m=n(),f=n(0),t=T({chunkSize:l,endpoint:O,maxRetries:g,metadata:y,retry:w});return U(()=>{t.setOnStart(()=>{s.set(!0),r.set(!1),c.set(0),o.set(void 0),f.set(0),P?.()}),t.setOnProgress((e,d)=>{c.set(e),f.set(d),h?.(e)}),t.setOnFinish(e=>{c.set(100),m.set(e),s.set(!1),r.set(!1),b?.(e)}),t.setOnError(e=>{o.set(e),s.set(!1),p?.(e)});const a=setInterval(()=>{f.set(t.getOffset()),r.set(t.isPaused())},100);x(()=>{clearInterval(a),t.setOnStart(void 0),t.setOnProgress(void 0),t.setOnFinish(void 0),t.setOnError(void 0)})}),{abort:i(()=>{t.abort(),s.set(!1),r.set(!1)},"abort"),error:o,isPaused:r,isUploading:s,offset:f,pause:i(()=>{t.pause(),r.set(!0),S?.()},"pause"),progress:c,reset:i(()=>{t.clear(),c.set(0),s.set(!1),r.set(!1),o.set(void 0),m.set(void 0),f.set(0)},"reset"),result:m,resume:i(async()=>{r.set(!1),s.set(!0),E?.();try{await t.resume()}catch(a){const e=a instanceof Error?a:new Error(String(a));throw o.set(e),s.set(!1),p?.(e),e}},"resume"),upload:i(async a=>{try{return await t.upload(a)}catch(e){const d=e instanceof Error?e:new Error(String(e));throw o.set(d),p?.(d),d}},"upload")}},"createTusUpload");export{A as createTusUpload};
@@ -1,223 +0,0 @@
1
- /**
2
- * Upload method type for useUpload hook
3
- */
4
- type UploadMethod = "auto" | "chunked-rest" | "multipart" | "tus";
5
- /**
6
- * File metadata returned from the server (matches OpenAPI FileMeta schema)
7
- */
8
- interface FileMeta {
9
- /** Bytes written to storage */
10
- bytesWritten?: number;
11
- /** Content type of the uploaded file */
12
- contentType?: string;
13
- /** File creation timestamp */
14
- createdAt?: string;
15
- /** Unique identifier for the uploaded file */
16
- id: string;
17
- /** Additional metadata associated with the file */
18
- metadata?: Record<string, unknown>;
19
- /** Storage name of the file */
20
- name?: string;
21
- /** Original filename of the uploaded file */
22
- originalName?: string;
23
- /** Size of the uploaded file in bytes */
24
- size?: number;
25
- /** Upload status: 'completed', 'part', 'deleted', or 'created' */
26
- status?: "completed" | "part" | "deleted" | "created";
27
- }
28
- /**
29
- * Result returned after a successful file upload
30
- * Extends FileMeta with additional client-side fields
31
- */
32
- interface UploadResult extends FileMeta {
33
- /** Original filename of the uploaded file (alias for originalName) */
34
- filename?: string;
35
- /** Current upload offset in bytes (TUS only) */
36
- offset?: number;
37
- /** URL to access the uploaded file */
38
- url?: string;
39
- }
40
- /**
41
- * Upload item state
42
- */
43
- interface UploadItem {
44
- /** Batch ID this item belongs to (if part of a batch) */
45
- batchId?: string;
46
- /** Upload progress percentage (0-100) */
47
- completed: number;
48
- /** Error message if upload failed */
49
- error?: string;
50
- /** The file being uploaded */
51
- file: File;
52
- /** Unique item ID */
53
- id: string;
54
- /** Bytes uploaded so far */
55
- loaded: number;
56
- /** Number of retry attempts */
57
- retryCount?: number;
58
- /** Total file size in bytes */
59
- size: number;
60
- /** Upload status */
61
- status: "pending" | "uploading" | "completed" | "error" | "aborted";
62
- /** Upload response data */
63
- uploadResponse?: {
64
- data?: unknown;
65
- response?: string;
66
- };
67
- /** File URL after upload */
68
- url?: string;
69
- }
70
- /**
71
- * Batch state information
72
- */
73
- interface BatchState {
74
- /** Number of completed items */
75
- completedCount: number;
76
- /** Number of failed items */
77
- errorCount: number;
78
- /** Batch ID */
79
- id: string;
80
- /** Item IDs in this batch */
81
- itemIds: string[];
82
- /** Aggregate progress (0-100) */
83
- progress: number;
84
- /** Batch status */
85
- status: "pending" | "uploading" | "completed" | "error" | "cancelled";
86
- /** Total number of items */
87
- totalCount: number;
88
- }
89
- /**
90
- * Uploader event types
91
- */
92
- type UploaderEventType = "BATCH_CANCELLED" | "BATCH_COMPLETE" | "BATCH_ERROR" | "BATCH_FINALIZE" | "BATCH_FINISH" | "BATCH_PROGRESS" | "BATCH_START" | "ITEM_ABORT" | "ITEM_ERROR" | "ITEM_FINISH" | "ITEM_PROGRESS" | "ITEM_START";
93
- /**
94
- * Event handler function type
95
- */
96
- type UploaderEventHandler<T = UploadItem | BatchState> = (item: T) => void;
97
- /**
98
- * Configuration options for the uploader.
99
- */
100
- interface UploaderOptions {
101
- /** Upload endpoint URL */
102
- endpoint: string;
103
- /** Maximum number of retry attempts */
104
- maxRetries?: number;
105
- /** Additional metadata to include with the upload */
106
- metadata?: Record<string, string>;
107
- /** Enable automatic retry on failure */
108
- retry?: boolean;
109
- }
110
- /**
111
- * Uploader class - event-driven file uploader inspired by rpldy design
112
- */
113
- declare class Uploader {
114
- private readonly options;
115
- /**
116
- * Creates FormData for visulima multipart handler.
117
- */
118
- private static createFormData;
119
- /**
120
- * Parses response as FileMeta.
121
- */
122
- private static parseResponse;
123
- private items;
124
- private batches;
125
- private eventHandlers;
126
- private activeUploads;
127
- private itemIdCounter;
128
- private batchIdCounter;
129
- constructor(options: UploaderOptions);
130
- /**
131
- * Subscribes to uploader events.
132
- */
133
- on(event: UploaderEventType, handler: UploaderEventHandler): void;
134
- /**
135
- * Unsubscribes from uploader events.
136
- */
137
- off(event: UploaderEventType, handler: UploaderEventHandler): void;
138
- /**
139
- * Adds a file to the upload queue.
140
- */
141
- add(file: File, batchId?: string): string;
142
- /**
143
- * Adds multiple files to the upload queue as a batch.
144
- */
145
- addBatch(files: File[]): string[];
146
- /**
147
- * Gets an item by ID.
148
- */
149
- getItem(id: string): UploadItem | undefined;
150
- /**
151
- * Aborts a specific upload.
152
- */
153
- abortItem(id: string): void;
154
- /**
155
- * Aborts all uploads in a batch.
156
- */
157
- abortBatch(batchId: string): void;
158
- /**
159
- * Aborts all uploads.
160
- */
161
- abort(): void;
162
- /**
163
- * Clears all items and aborts active uploads.
164
- */
165
- clear(): void;
166
- /**
167
- * Gets all items.
168
- */
169
- getItems(): UploadItem[];
170
- /**
171
- * Gets all items in a batch.
172
- */
173
- getBatchItems(batchId: string): UploadItem[];
174
- /**
175
- * Gets batch state by batch ID.
176
- */
177
- getBatch(batchId: string): BatchState | undefined;
178
- /**
179
- * Gets all batches.
180
- */
181
- getBatches(): BatchState[];
182
- /**
183
- * Retries a failed upload item.
184
- */
185
- retryItem(id: string): void;
186
- /**
187
- * Retries all failed items in a batch.
188
- */
189
- retryBatch(batchId: string): void;
190
- /**
191
- * Generates a unique item ID.
192
- */
193
- private generateItemId;
194
- /**
195
- * Generates a unique batch ID.
196
- */
197
- private generateBatchId;
198
- /**
199
- * Calculates aggregate progress for a batch.
200
- */
201
- private calculateBatchProgress;
202
- /**
203
- * Updates batch state and emits batch progress event.
204
- */
205
- private updateBatchProgress;
206
- /**
207
- * Emits a batch event to all registered handlers.
208
- */
209
- private emitBatch;
210
- /**
211
- * Emits an event to all registered handlers.
212
- */
213
- private emit;
214
- /**
215
- * Uploads a single file.
216
- */
217
- private uploadFile;
218
- }
219
- /**
220
- * Creates a new uploader instance.
221
- */
222
- declare const createUploader: (options: UploaderOptions) => Uploader;
223
- export { BatchState as B, FileMeta as F, UploadResult as U, Uploader as a, UploaderOptions as b, UploadItem as c, UploaderEventHandler as d, UploaderEventType as e, createUploader as f, UploadMethod as g };
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var m=(v,i)=>w(v,"name",{value:i,configurable:!0});import{ref as l,onMounted as k,onBeforeUnmount as U}from"vue";import{createChunkedRestAdapter as x}from"./createChunkedRestAdapter-CWFhVX6x.js";var C=Object.defineProperty,n=m((v,i)=>C(v,"name",{value:i,configurable:!0}),"t");const j=n(v=>{const{chunkSize:i,endpoint:h,maxRetries:O,metadata:g,onError:f,onPause:S,onProgress:E,onResume:P,onStart:y,onSuccess:R,retry:b}=v,d=l(0),r=l(!1),t=l(!1),o=l(void 0),p=l(void 0),c=l(0),a=x({chunkSize:i,endpoint:h,maxRetries:O,metadata:g,retry:b});return k(()=>{a.setOnStart(()=>{r.value=!0,t.value=!1,d.value=0,o.value=void 0,c.value=0,y?.()}),a.setOnProgress((e,u)=>{d.value=e,c.value=u,E?.(e,u)}),a.setOnFinish(e=>{d.value=100,p.value=e,r.value=!1,t.value=!1,R?.(e)}),a.setOnError(e=>{o.value=e,r.value=!1,f?.(e)});const s=setInterval(()=>{a.getOffset().then(e=>(c.value=e,e)).catch(()=>{}),t.value=a.isPaused()},100);U(()=>{clearInterval(s),a.setOnStart(void 0),a.setOnProgress(void 0),a.setOnFinish(void 0),a.setOnError(void 0)})}),{abort:n(()=>{a.abort(),r.value=!1,t.value=!1},"abort"),error:o,isPaused:t,isUploading:r,offset:c,pause:n(()=>{a.pause(),t.value=!0,S?.()},"pause"),progress:d,reset:n(()=>{a.clear(),d.value=0,r.value=!1,t.value=!1,o.value=void 0,p.value=void 0,c.value=0},"reset"),result:p,resume:n(async()=>{t.value=!1,r.value=!0,P?.();try{await a.resume()}catch(s){const e=s instanceof Error?s:new Error(String(s));throw o.value=e,r.value=!1,f?.(e),e}},"resume"),upload:n(async s=>{try{return await a.upload(s)}catch(e){const u=e instanceof Error?e:new Error(String(e));throw o.value=u,f?.(u),u}},"upload")}},"useChunkedRestUpload");export{j as useChunkedRestUpload};
@@ -1 +0,0 @@
1
- var _=Object.defineProperty;var k=(i,a)=>_(i,"name",{value:a,configurable:!0});import{useState as u,useMemo as D,useRef as G,useEffect as C,useCallback as l}from"react";import{createChunkedRestAdapter as H}from"./createChunkedRestAdapter-CWFhVX6x.js";var J=Object.defineProperty,K=k((i,a)=>J(i,"name",{value:a,configurable:!0}),"w");const V=K(i=>{const{chunkSize:a,endpoint:E,maxRetries:w,metadata:O,onError:m,onPause:h,onProgress:p,onResume:S,onStart:g,onSuccess:v,retry:R}=i,[x,d]=u(0),[U,t]=u(!1),[z,o]=u(!1),[F,P]=u(void 0),[I,b]=u(void 0),[T,f]=u(0),e=D(()=>H({chunkSize:a,endpoint:E,maxRetries:w,metadata:O,retry:R}),[a,E,w,O,R]),n=G({onError:m,onPause:h,onProgress:p,onResume:S,onStart:g,onSuccess:v});C(()=>{n.current={onError:m,onPause:h,onProgress:p,onResume:S,onStart:g,onSuccess:v}},[m,p,h,S,g,v]),C(()=>{e.setOnStart(()=>{t(!0),o(!1),d(0),P(void 0),f(0),n.current.onStart?.()}),e.setOnProgress((r,y)=>{d(r),f(y),n.current.onProgress?.(r,y)}),e.setOnFinish(r=>{d(100),b(r),t(!1),o(!1),n.current.onSuccess?.(r)}),e.setOnError(r=>{P(r),t(!1),n.current.onError?.(r)});let s=!0;const c=setInterval(()=>{!s||!("window"in globalThis)||(e.getOffset().then(r=>(!s||!("window"in globalThis)||f(r),r)).catch(()=>{}),o(e.isPaused()))},100);return()=>{s=!1,clearInterval(c),e.setOnStart(void 0),e.setOnProgress(void 0),e.setOnFinish(void 0),e.setOnError(void 0)}},[e]);const j=l(async s=>{try{return await e.upload(s)}catch(c){throw c instanceof Error?c:new Error(String(c))}},[e]),A=l(()=>{e.pause(),o(!0),n.current.onPause?.()},[e]),M=l(async()=>{o(!1),t(!0),n.current.onResume?.();try{await e.resume()}catch(s){throw t(!1),s instanceof Error?s:new Error(String(s))}},[e]),q=l(()=>{e.abort(),t(!1),o(!1)},[e]),B=l(()=>{e.clear(),d(0),t(!1),o(!1),P(void 0),b(void 0),f(0)},[e]);return{abort:q,error:F,isPaused:z,isUploading:U,offset:T,pause:A,progress:x,reset:B,result:I,resume:M,upload:j}},"useChunkedRestUpload");export{V as useChunkedRestUpload};
@@ -1 +0,0 @@
1
- var U=Object.defineProperty;var m=(n,v)=>U(n,"name",{value:v,configurable:!0});import{ref as u,onMounted as R,onBeforeUnmount as x}from"vue";import{createTusAdapter as T}from"./createTusAdapter-BbFsUNsP.js";var k=Object.defineProperty,l=m((n,v)=>k(n,"name",{value:v,configurable:!0}),"a");const j=l(n=>{const{chunkSize:v,endpoint:O,maxRetries:g,metadata:h,onError:c,onPause:S,onProgress:E,onResume:P,onStart:y,onSuccess:b,retry:w}=n,i=u(0),r=u(!1),t=u(!1),o=u(void 0),p=u(void 0),d=u(0),a=T({chunkSize:v,endpoint:O,maxRetries:g,metadata:h,retry:w});return R(()=>{a.setOnStart(()=>{r.value=!0,t.value=!1,i.value=0,o.value=void 0,d.value=0,y?.()}),a.setOnProgress((e,f)=>{i.value=e,d.value=f,E?.(e)}),a.setOnFinish(e=>{i.value=100,p.value=e,r.value=!1,t.value=!1,b?.(e)}),a.setOnError(e=>{o.value=e,r.value=!1,c?.(e)});const s=setInterval(()=>{d.value=a.getOffset(),t.value=a.isPaused()},100);x(()=>{clearInterval(s),a.setOnStart(void 0),a.setOnProgress(void 0),a.setOnFinish(void 0),a.setOnError(void 0)})}),{abort:l(()=>{a.abort(),r.value=!1,t.value=!1},"abort"),error:o,isPaused:t,isUploading:r,offset:d,pause:l(()=>{a.pause(),t.value=!0,S?.()},"pause"),progress:i,reset:l(()=>{a.clear(),i.value=0,r.value=!1,t.value=!1,o.value=void 0,p.value=void 0,d.value=0},"reset"),result:p,resume:l(async()=>{t.value=!1,r.value=!0,P?.();try{await a.resume()}catch(s){const e=s instanceof Error?s:new Error(String(s));throw o.value=e,r.value=!1,c?.(e),e}},"resume"),upload:l(async s=>{try{return await a.upload(s)}catch(e){const f=e instanceof Error?e:new Error(String(e));throw o.value=f,c?.(f),f}},"upload")}},"useTusUpload");export{j as useTusUpload};
@@ -1 +0,0 @@
1
- var _=Object.defineProperty;var T=(i,u)=>_(i,"name",{value:u,configurable:!0});import{useState as c,useMemo as D,useRef as y,useEffect as U,useCallback as f}from"react";import{createTusAdapter as G}from"./createTusAdapter-BbFsUNsP.js";var H=Object.defineProperty,K=T((i,u)=>H(i,"name",{value:u,configurable:!0}),"I");const W=K(i=>{const{chunkSize:u,endpoint:R,maxRetries:w,metadata:b,onError:m,onPause:S,onProgress:p,onResume:E,onStart:P,onSuccess:g,retry:k}=i,[x,d]=c(0),[z,o]=c(!1),[F,a]=c(!1),[j,l]=c(void 0),[A,I]=c(void 0),[C,v]=c(0),r=D(()=>G({chunkSize:u,endpoint:R,maxRetries:w,metadata:b,retry:k}),[u,R,w,b,k]),t=y({onError:m,onPause:S,onProgress:p,onResume:E,onStart:P,onSuccess:g}),n=y(void 0),O=y(!0);U(()=>{t.current={onError:m,onPause:S,onProgress:p,onResume:E,onStart:P,onSuccess:g}},[m,p,S,E,P,g]),U(()=>(O.current=!0,r.setOnStart(()=>{o(!0),a(!1),d(0),l(void 0),v(0),t.current.onStart?.()}),r.setOnProgress((e,s)=>{d(e),v(s),t.current.onProgress?.(e)}),r.setOnFinish(e=>{d(100),I(e),o(!1),a(!1),t.current.onSuccess?.(e)}),r.setOnError(e=>{l(e),o(!1),t.current.onError?.(e)}),n.current=setInterval(()=>{O.current&&n.current&&(v(r.getOffset()),a(r.isPaused()))},100),()=>{O.current=!1,n.current&&(clearInterval(n.current),n.current=void 0),r.setOnStart(void 0),r.setOnProgress(void 0),r.setOnFinish(void 0),r.setOnError(void 0)}),[r]);const M=f(async e=>{try{return await r.upload(e)}catch(s){const h=s instanceof Error?s:new Error(String(s));throw l(h),t.current.onError?.(h),h}},[r]),q=f(()=>{r.pause(),a(!0),t.current.onPause?.()},[r]),B=f(async()=>{a(!1),o(!0),t.current.onResume?.();try{await r.resume()}catch(e){const s=e instanceof Error?e:new Error(String(e));throw l(s),o(!1),t.current.onError?.(s),s}},[r]),J=f(()=>{n.current&&(clearInterval(n.current),n.current=void 0),r.abort(),o(!1),a(!1)},[r]),N=f(()=>{r.clear(),d(0),o(!1),a(!1),l(void 0),I(void 0),v(0)},[r]);return{abort:J,error:j,isPaused:F,isUploading:z,offset:C,pause:q,progress:x,reset:N,result:A,resume:B,upload:M}},"useTusUpload");export{W as useTusUpload};