@uploadista/react 0.0.13 → 0.0.14

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 (25) hide show
  1. package/dist/components/index.d.mts +2 -2
  2. package/dist/components/index.mjs +1 -1
  3. package/dist/hooks/index.d.mts +2 -2
  4. package/dist/hooks/index.mjs +1 -1
  5. package/dist/index.d.mts +3 -3
  6. package/dist/index.mjs +1 -1
  7. package/dist/{upload-zone-CsaXN9yD.mjs → upload-zone-8khVLLYF.mjs} +2 -2
  8. package/dist/{upload-zone-CsaXN9yD.mjs.map → upload-zone-8khVLLYF.mjs.map} +1 -1
  9. package/dist/{uploadista-provider-Cj34PdHg.d.mts → uploadista-provider-CrS6TmpJ.d.mts} +2 -2
  10. package/dist/{uploadista-provider-Cj34PdHg.d.mts.map → uploadista-provider-CrS6TmpJ.d.mts.map} +1 -1
  11. package/dist/{use-upload-metrics-2HKWi6GZ.mjs → use-upload-metrics-BE7UcAaz.mjs} +2 -2
  12. package/dist/{use-upload-metrics-2HKWi6GZ.mjs.map → use-upload-metrics-BE7UcAaz.mjs.map} +1 -1
  13. package/dist/{use-upload-metrics-DESSCpN5.d.mts → use-upload-metrics-IXxUORce.d.mts} +10 -10
  14. package/dist/{use-upload-metrics-DESSCpN5.d.mts.map → use-upload-metrics-IXxUORce.d.mts.map} +1 -1
  15. package/dist/use-upload-xcqz090n.mjs +2 -0
  16. package/dist/use-upload-xcqz090n.mjs.map +1 -0
  17. package/dist/{use-uploadista-client-Dp8_ZO7d.d.mts → use-uploadista-client--ivZPO88.d.mts} +21 -110
  18. package/dist/use-uploadista-client--ivZPO88.d.mts.map +1 -0
  19. package/package.json +7 -7
  20. package/src/hooks/use-flow-upload.ts +84 -342
  21. package/src/hooks/use-multi-upload.ts +2 -6
  22. package/src/hooks/use-upload.ts +78 -239
  23. package/dist/use-upload-CvPqdohl.mjs +0 -2
  24. package/dist/use-upload-CvPqdohl.mjs.map +0 -1
  25. package/dist/use-uploadista-client-Dp8_ZO7d.d.mts.map +0 -1
@@ -1,4 +1,5 @@
1
- import { BrowserUploadInput, ChunkMetrics, FlowUploadOptions, PerformanceInsights, UploadSessionMetrics, UploadistaClientOptions, createUploadistaClient } from "@uploadista/client-browser";
1
+ import { BrowserUploadInput, FlowUploadOptions, UploadistaClientOptions, createUploadistaClient } from "@uploadista/client-browser";
2
+ import { FlowUploadState, FlowUploadStatus, UploadMetrics, UploadState, UploadStatus } from "@uploadista/client-core";
2
3
  import { UploadFile } from "@uploadista/core/types";
3
4
 
4
5
  //#region src/hooks/use-drag-drop.d.ts
@@ -152,42 +153,6 @@ interface UseDragDropReturn {
152
153
  declare function useDragDrop(options?: DragDropOptions): UseDragDropReturn;
153
154
  //#endregion
154
155
  //#region src/hooks/use-flow-upload.d.ts
155
- /**
156
- * Possible states for a flow upload lifecycle.
157
- * Flow uploads progress through: idle → uploading → processing → success/error/aborted
158
- */
159
- type FlowUploadStatus = "idle" | "uploading" | "processing" | "success" | "error" | "aborted";
160
- /**
161
- * Complete state information for a flow upload operation.
162
- * Tracks both the upload phase (file transfer) and processing phase (flow execution).
163
- *
164
- * @template TOutput - Type of the final output from the flow (defaults to UploadFile)
165
- *
166
- * @property status - Current upload status (idle, uploading, processing, success, error, aborted)
167
- * @property progress - Upload progress percentage (0-100)
168
- * @property bytesUploaded - Number of bytes successfully uploaded
169
- * @property totalBytes - Total file size in bytes (null if unknown)
170
- * @property error - Error object if upload or processing failed
171
- * @property result - Final output from the flow (available when status is "success")
172
- * @property jobId - Unique identifier for the flow execution job
173
- * @property flowStarted - Whether the flow processing has started
174
- * @property currentNodeName - Name of the currently executing flow node
175
- * @property currentNodeType - Type of the currently executing flow node
176
- * @property flowOutputs - Complete outputs from all output nodes in the flow
177
- */
178
- interface FlowUploadState<TOutput = UploadFile> {
179
- status: FlowUploadStatus;
180
- progress: number;
181
- bytesUploaded: number;
182
- totalBytes: number | null;
183
- error: Error | null;
184
- result: TOutput | null;
185
- jobId: string | null;
186
- flowStarted: boolean;
187
- currentNodeName: string | null;
188
- currentNodeType: string | null;
189
- flowOutputs: Record<string, unknown> | null;
190
- }
191
156
  /**
192
157
  * Return value from the useFlowUpload hook with upload control methods and state.
193
158
  *
@@ -196,6 +161,7 @@ interface FlowUploadState<TOutput = UploadFile> {
196
161
  * @property state - Complete flow upload state with progress and outputs
197
162
  * @property upload - Function to initiate file upload through the flow
198
163
  * @property abort - Cancel the current upload and flow execution
164
+ * @property pause - Pause the current upload
199
165
  * @property reset - Reset state to idle (clears all data)
200
166
  * @property isUploading - True when upload or processing is active
201
167
  * @property isUploadingFile - True only during file upload phase
@@ -326,15 +292,6 @@ interface UseFlowUploadReturn<TOutput = UploadFile> {
326
292
  declare function useFlowUpload<TOutput = UploadFile>(options: FlowUploadOptions<TOutput>): UseFlowUploadReturn<TOutput>;
327
293
  //#endregion
328
294
  //#region src/hooks/use-upload.d.ts
329
- type UploadStatus = "idle" | "uploading" | "success" | "error" | "aborted";
330
- interface UploadState {
331
- status: UploadStatus;
332
- progress: number;
333
- bytesUploaded: number;
334
- totalBytes: number | null;
335
- error: Error | null;
336
- result: UploadFile | null;
337
- }
338
295
  interface UseUploadOptions {
339
296
  /**
340
297
  * Upload metadata to attach to the file
@@ -350,18 +307,30 @@ interface UseUploadOptions {
350
307
  uploadSize?: number;
351
308
  /**
352
309
  * Called when upload progress updates
310
+ *
311
+ * @param uploadId - The unique identifier for this upload
312
+ * @param bytesUploaded - Number of bytes uploaded
313
+ * @param totalBytes - Total bytes to upload, null if unknown
353
314
  */
354
- onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
315
+ onProgress?: (uploadId: string, bytesUploaded: number, totalBytes: number | null) => void;
355
316
  /**
356
317
  * Called when a chunk completes
318
+ *
319
+ * @param chunkSize - Size of the completed chunk
320
+ * @param bytesAccepted - Total bytes accepted so far
321
+ * @param bytesTotal - Total bytes to upload, null if unknown
357
322
  */
358
323
  onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
359
324
  /**
360
325
  * Called when upload succeeds
326
+ *
327
+ * @param result - The uploaded file result
361
328
  */
362
329
  onSuccess?: (result: UploadFile) => void;
363
330
  /**
364
331
  * Called when upload fails
332
+ *
333
+ * @param error - The error that caused the failure
365
334
  */
366
335
  onError?: (error: Error) => void;
367
336
  /**
@@ -370,35 +339,13 @@ interface UseUploadOptions {
370
339
  onAbort?: () => void;
371
340
  /**
372
341
  * Custom retry logic
342
+ *
343
+ * @param error - The error that triggered the retry check
344
+ * @param retryAttempt - The current retry attempt number
345
+ * @returns true to retry, false to fail
373
346
  */
374
347
  onShouldRetry?: (error: Error, retryAttempt: number) => boolean;
375
348
  }
376
- interface UploadMetrics {
377
- /**
378
- * Get performance insights from the upload client
379
- */
380
- getInsights: () => PerformanceInsights;
381
- /**
382
- * Export detailed metrics from the upload client
383
- */
384
- exportMetrics: () => {
385
- session: Partial<UploadSessionMetrics>;
386
- chunks: ChunkMetrics[];
387
- insights: PerformanceInsights;
388
- };
389
- /**
390
- * Get current network metrics
391
- */
392
- getNetworkMetrics: () => unknown;
393
- /**
394
- * Get current network condition
395
- */
396
- getNetworkCondition: () => unknown;
397
- /**
398
- * Reset all metrics
399
- */
400
- resetMetrics: () => void;
401
- }
402
349
  interface UseUploadReturn {
403
350
  /**
404
351
  * Current upload state
@@ -433,42 +380,6 @@ interface UseUploadReturn {
433
380
  */
434
381
  metrics: UploadMetrics;
435
382
  }
436
- /**
437
- * React hook for managing individual file uploads with full state management.
438
- * Provides upload progress tracking, error handling, abort functionality, and retry logic.
439
- *
440
- * Must be used within an UploadistaProvider.
441
- *
442
- * @param options - Upload configuration and event handlers
443
- * @returns Upload state and control methods
444
- *
445
- * @example
446
- * ```tsx
447
- * function MyComponent() {
448
- * const upload = useUpload({
449
- * onSuccess: (result) => console.log('Upload complete:', result),
450
- * onError: (error) => console.error('Upload failed:', error),
451
- * onProgress: (progress) => console.log('Progress:', progress + '%'),
452
- * });
453
- *
454
- * return (
455
- * <div>
456
- * <input
457
- * type="file"
458
- * onChange={(e) => {
459
- * const file = e.target.files?.[0];
460
- * if (file) upload.upload(file);
461
- * }}
462
- * />
463
- * {upload.isUploading && <div>Progress: {upload.state.progress}%</div>}
464
- * {upload.state.error && <div>Error: {upload.state.error.message}</div>}
465
- * {upload.canRetry && <button onClick={upload.retry}>Retry</button>}
466
- * <button onClick={upload.abort} disabled={!upload.isUploading}>Abort</button>
467
- * </div>
468
- * );
469
- * }
470
- * ```
471
- */
472
383
  declare function useUpload(options?: UseUploadOptions): UseUploadReturn;
473
384
  //#endregion
474
385
  //#region src/hooks/use-multi-upload.d.ts
@@ -773,4 +684,4 @@ interface UseUploadistaClientReturn {
773
684
  declare function useUploadistaClient(options: UseUploadistaClientOptions): UseUploadistaClientReturn;
774
685
  //#endregion
775
686
  export { useFlowUpload as _, MultiUploadState as a, UseDragDropReturn as b, useMultiUpload as c, UseUploadOptions as d, UseUploadReturn as f, UseFlowUploadReturn as g, FlowUploadStatus as h, MultiUploadOptions as i, UploadState as l, FlowUploadState as m, UseUploadistaClientReturn as n, UploadItem as o, useUpload as p, useUploadistaClient as r, UseMultiUploadReturn as s, UseUploadistaClientOptions as t, UploadStatus as u, DragDropOptions as v, useDragDrop as x, DragDropState as y };
776
- //# sourceMappingURL=use-uploadista-client-Dp8_ZO7d.d.mts.map
687
+ //# sourceMappingURL=use-uploadista-client--ivZPO88.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-uploadista-client--ivZPO88.d.mts","names":[],"sources":["../src/hooks/use-drag-drop.ts","../src/hooks/use-flow-upload.ts","../src/hooks/use-upload.ts","../src/hooks/use-multi-upload.ts","../src/hooks/use-uploadista-client.ts"],"sourcesContent":[],"mappings":";;;;;UAEiB,eAAA;;;;;EAAA;AA0CjB;AAsBA;EAIS,QAAA,CAAA,EAAA,MAAA;EAMgB;;;EAGL,WAAM,CAAA,EAAA,MAAA;EAUc;;;EAYZ,QAAA,CAAA,EAAA,OAAA;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AAgB,mBAAA,UACL,6BACR"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/react",
3
3
  "type": "module",
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "description": "React client for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -22,16 +22,16 @@
22
22
  "dependencies": {
23
23
  "react": "19.2.0",
24
24
  "react-dom": "19.2.0",
25
- "@uploadista/core": "0.0.13",
26
- "@uploadista/client-core": "0.0.13",
27
- "@uploadista/client-browser": "0.0.13"
25
+ "@uploadista/core": "0.0.14",
26
+ "@uploadista/client-core": "0.0.14",
27
+ "@uploadista/client-browser": "0.0.14"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/react": "19.2.3",
30
+ "@types/react": "19.2.4",
31
31
  "@types/react-dom": "19.2.3",
32
- "tsdown": "0.16.3",
32
+ "tsdown": "0.16.4",
33
33
  "vitest": "4.0.8",
34
- "@uploadista/typescript-config": "0.0.13"
34
+ "@uploadista/typescript-config": "0.0.14"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsdown",