@uploadista/react 0.0.20-beta.2 → 0.0.20-beta.3

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 (36) hide show
  1. package/dist/components/index.d.mts +3 -3
  2. package/dist/components/index.mjs +1 -1
  3. package/dist/flow-upload-list-SbpCaxRq.mjs +2 -0
  4. package/dist/flow-upload-list-SbpCaxRq.mjs.map +1 -0
  5. package/dist/hooks/index.d.mts +3 -3
  6. package/dist/hooks/index.mjs +1 -1
  7. package/dist/index.d.mts +6 -6
  8. package/dist/index.mjs +1 -1
  9. package/dist/{uploadista-provider-D-N-eL2l.d.mts → uploadista-provider-C1l0iBc9.d.mts} +512 -318
  10. package/dist/uploadista-provider-C1l0iBc9.d.mts.map +1 -0
  11. package/dist/use-upload-BvvGROMR.mjs +2 -0
  12. package/dist/use-upload-BvvGROMR.mjs.map +1 -0
  13. package/dist/{use-uploadista-client-m9nF-irM.d.mts → use-uploadista-client-DHbLSpIb.d.mts} +120 -286
  14. package/dist/use-uploadista-client-DHbLSpIb.d.mts.map +1 -0
  15. package/dist/use-uploadista-events-BwUD-2Ck.mjs +2 -0
  16. package/dist/use-uploadista-events-BwUD-2Ck.mjs.map +1 -0
  17. package/dist/{use-upload-metrics-DhzS4lhG.d.mts → use-uploadista-events-CtDXJYrR.d.mts} +169 -371
  18. package/dist/use-uploadista-events-CtDXJYrR.d.mts.map +1 -0
  19. package/package.json +6 -6
  20. package/src/components/flow-primitives.tsx +839 -0
  21. package/src/components/index.tsx +31 -13
  22. package/src/hooks/index.ts +25 -37
  23. package/src/index.ts +90 -81
  24. package/dist/upload-zone-BjWHuP7p.mjs +0 -6
  25. package/dist/upload-zone-BjWHuP7p.mjs.map +0 -1
  26. package/dist/uploadista-provider-D-N-eL2l.d.mts.map +0 -1
  27. package/dist/use-upload-BDHVhQsI.mjs +0 -2
  28. package/dist/use-upload-BDHVhQsI.mjs.map +0 -1
  29. package/dist/use-upload-metrics-Df90wIos.mjs +0 -2
  30. package/dist/use-upload-metrics-Df90wIos.mjs.map +0 -1
  31. package/dist/use-upload-metrics-DhzS4lhG.d.mts.map +0 -1
  32. package/dist/use-uploadista-client-m9nF-irM.d.mts.map +0 -1
  33. package/src/components/flow-input.tsx +0 -299
  34. package/src/components/flow-upload-zone.tsx +0 -441
  35. package/src/hooks/use-flow-execution.ts +0 -502
  36. package/src/hooks/use-flow-upload.ts +0 -299
@@ -1,209 +1,7 @@
1
+ import { FlowUploadState, FlowUploadStatus, InputExecutionState, UploadMetrics, UploadState, UploadStatus } from "@uploadista/client-core";
1
2
  import { UploadFile } from "@uploadista/core/types";
2
- import { FlowUploadState, FlowUploadState as FlowUploadState$1, FlowUploadStatus, InputExecutionState, UploadMetrics, UploadState, UploadStatus } from "@uploadista/client-core";
3
3
  import { BrowserUploadInput, FlowUploadOptions, UploadistaClientOptions, createUploadistaClient } from "@uploadista/client-browser";
4
4
 
5
- //#region src/hooks/use-flow.d.ts
6
-
7
- /**
8
- * Input metadata discovered from the flow
9
- */
10
- interface FlowInputMetadata {
11
- /** Input node ID */
12
- nodeId: string;
13
- /** Human-readable node name */
14
- nodeName: string;
15
- /** Node description explaining what input is needed */
16
- nodeDescription: string;
17
- /** Input type ID from inputTypeRegistry - describes how clients interact with this node */
18
- inputTypeId?: string;
19
- /** Whether this input is required */
20
- required: boolean;
21
- }
22
- /**
23
- * Return value from the useFlow hook with upload control methods and state.
24
- *
25
- * @property state - Complete flow upload state with progress and outputs
26
- * @property inputMetadata - Metadata about discovered input nodes (null until discovered)
27
- * @property inputStates - Per-input execution state for multi-input flows
28
- * @property inputs - Current input values set via setInput()
29
- * @property setInput - Set an input value for a specific node (for progressive provision)
30
- * @property execute - Execute the flow with current inputs (auto-detects types)
31
- * @property upload - Convenience method for single-file upload (same as execute with one file input)
32
- * @property abort - Cancel the current upload and flow execution
33
- * @property pause - Pause the current upload
34
- * @property reset - Reset state to idle (clears all data)
35
- * @property isUploading - True when upload or processing is active
36
- * @property isUploadingFile - True only during file upload phase
37
- * @property isProcessing - True only during flow processing phase
38
- * @property isDiscoveringInputs - True while discovering flow inputs
39
- */
40
- interface UseFlowReturn {
41
- /**
42
- * Current upload state
43
- */
44
- state: FlowUploadState$1;
45
- /**
46
- * Discovered input nodes metadata (null until discovery completes)
47
- */
48
- inputMetadata: FlowInputMetadata[] | null;
49
- /**
50
- * Per-input execution state for multi-input flows
51
- */
52
- inputStates: ReadonlyMap<string, InputExecutionState>;
53
- /**
54
- * Current inputs set via setInput()
55
- */
56
- inputs: Record<string, unknown>;
57
- /**
58
- * Set an input value for a specific node.
59
- * For progressive input provision before calling execute().
60
- *
61
- * @param nodeId - The input node ID
62
- * @param value - The input value (File, URL string, or structured data)
63
- */
64
- setInput: (nodeId: string, value: unknown) => void;
65
- /**
66
- * Execute the flow with current inputs.
67
- * Automatically detects input types and routes appropriately.
68
- * For single input, uses standard upload path.
69
- * For multiple inputs, requires multiInputUploadFn.
70
- */
71
- execute: () => Promise<void>;
72
- /**
73
- * Upload a single file through the flow (convenience method).
74
- * Equivalent to setInput(firstNodeId, file) + execute().
75
- *
76
- * @param file - File or Blob to upload
77
- */
78
- upload: (file: File | Blob) => Promise<void>;
79
- /**
80
- * Abort the current upload
81
- */
82
- abort: () => void;
83
- /**
84
- * Pause the current upload
85
- */
86
- pause: () => void;
87
- /**
88
- * Reset the upload state and clear all inputs
89
- */
90
- reset: () => void;
91
- /**
92
- * Whether an upload or flow execution is in progress (uploading OR processing)
93
- */
94
- isUploading: boolean;
95
- /**
96
- * Whether the file is currently being uploaded (chunks being sent)
97
- */
98
- isUploadingFile: boolean;
99
- /**
100
- * Whether the flow is currently processing (after upload completes)
101
- */
102
- isProcessing: boolean;
103
- /**
104
- * Whether the hook is discovering flow inputs
105
- */
106
- isDiscoveringInputs: boolean;
107
- }
108
- /**
109
- * React hook for executing flows with single or multiple inputs.
110
- * Automatically discovers input nodes and detects input types (File, URL, structured data).
111
- * Supports progressive input provision via setInput() and execute().
112
- *
113
- * This is the unified flow hook that replaces useFlowUpload for advanced use cases.
114
- * It provides:
115
- * - Auto-discovery of flow input nodes
116
- * - Automatic input type detection (file → upload, string → URL, object → data)
117
- * - Progressive input provision via setInput()
118
- * - Multi-input support with parallel coordination
119
- * - Per-input state tracking
120
- *
121
- * Must be used within FlowManagerProvider (which must be within UploadistaProvider).
122
- * Flow events are automatically routed by the provider to the appropriate manager.
123
- *
124
- * @param options - Flow upload configuration including flow ID and event handlers
125
- * @returns Flow upload state and control methods
126
- *
127
- * @example
128
- * ```tsx
129
- * // Single file upload (simple case)
130
- * function SingleFileUploader() {
131
- * const flow = useFlow({
132
- * flowConfig: {
133
- * flowId: "image-optimization",
134
- * storageId: "s3-images",
135
- * },
136
- * onSuccess: (outputs) => {
137
- * console.log("Flow outputs:", outputs);
138
- * },
139
- * });
140
- *
141
- * return (
142
- * <div>
143
- * <input
144
- * type="file"
145
- * onChange={(e) => {
146
- * const file = e.target.files?.[0];
147
- * if (file) flow.upload(file);
148
- * }}
149
- * />
150
- * {flow.isUploading && <div>Progress: {flow.state.progress}%</div>}
151
- * </div>
152
- * );
153
- * }
154
- *
155
- * // Multi-input with progressive provision
156
- * function MultiInputFlow() {
157
- * const flow = useFlow({
158
- * flowConfig: {
159
- * flowId: "multi-source-processing",
160
- * storageId: "default",
161
- * },
162
- * });
163
- *
164
- * return (
165
- * <div>
166
- * {flow.inputMetadata?.map((input) => (
167
- * <div key={input.nodeId}>
168
- * <label>{input.nodeId}</label>
169
- * {input.nodeType === "streaming-input-v1" ? (
170
- * <input
171
- * type="file"
172
- * onChange={(e) => {
173
- * const file = e.target.files?.[0];
174
- * if (file) flow.setInput(input.nodeId, file);
175
- * }}
176
- * />
177
- * ) : (
178
- * <input
179
- * type="url"
180
- * onChange={(e) => flow.setInput(input.nodeId, e.target.value)}
181
- * />
182
- * )}
183
- * </div>
184
- * ))}
185
- * <button onClick={flow.execute} disabled={flow.isUploading}>
186
- * Execute Flow
187
- * </button>
188
- *
189
- * {flow.isUploading && (
190
- * <div>
191
- * {Array.from(flow.inputStates.values()).map((inputState) => (
192
- * <div key={inputState.nodeId}>
193
- * {inputState.nodeId}: {inputState.status} ({inputState.progress}%)
194
- * </div>
195
- * ))}
196
- * </div>
197
- * )}
198
- * </div>
199
- * );
200
- * }
201
- * ```
202
- *
203
- * @see {@link useFlowUpload} for a simpler file-only upload hook
204
- */
205
- declare function useFlow(options: FlowUploadOptions): UseFlowReturn;
206
- //#endregion
207
5
  //#region src/hooks/use-drag-drop.d.ts
208
6
  interface DragDropOptions {
209
7
  /**
@@ -354,26 +152,77 @@ interface UseDragDropReturn {
354
152
  */
355
153
  declare function useDragDrop(options?: DragDropOptions): UseDragDropReturn;
356
154
  //#endregion
357
- //#region src/hooks/use-flow-upload.d.ts
155
+ //#region src/hooks/use-flow.d.ts
156
+ /**
157
+ * Input metadata discovered from the flow
158
+ */
159
+ interface FlowInputMetadata {
160
+ /** Input node ID */
161
+ nodeId: string;
162
+ /** Human-readable node name */
163
+ nodeName: string;
164
+ /** Node description explaining what input is needed */
165
+ nodeDescription: string;
166
+ /** Input type ID from inputTypeRegistry - describes how clients interact with this node */
167
+ inputTypeId?: string;
168
+ /** Whether this input is required */
169
+ required: boolean;
170
+ }
358
171
  /**
359
- * Return value from the useFlowUpload hook with upload control methods and state.
172
+ * Return value from the useFlow hook with upload control methods and state.
360
173
  *
361
174
  * @property state - Complete flow upload state with progress and outputs
362
- * @property upload - Function to initiate file upload through the flow
175
+ * @property inputMetadata - Metadata about discovered input nodes (null until discovered)
176
+ * @property inputStates - Per-input execution state for multi-input flows
177
+ * @property inputs - Current input values set via setInput()
178
+ * @property setInput - Set an input value for a specific node (for progressive provision)
179
+ * @property execute - Execute the flow with current inputs (auto-detects types)
180
+ * @property upload - Convenience method for single-file upload (same as execute with one file input)
363
181
  * @property abort - Cancel the current upload and flow execution
364
182
  * @property pause - Pause the current upload
365
183
  * @property reset - Reset state to idle (clears all data)
366
184
  * @property isUploading - True when upload or processing is active
367
185
  * @property isUploadingFile - True only during file upload phase
368
186
  * @property isProcessing - True only during flow processing phase
187
+ * @property isDiscoveringInputs - True while discovering flow inputs
369
188
  */
370
- interface UseFlowUploadReturn {
189
+ interface UseFlowReturn {
371
190
  /**
372
191
  * Current upload state
373
192
  */
374
193
  state: FlowUploadState;
375
194
  /**
376
- * Upload a file through the flow
195
+ * Discovered input nodes metadata (null until discovery completes)
196
+ */
197
+ inputMetadata: FlowInputMetadata[] | null;
198
+ /**
199
+ * Per-input execution state for multi-input flows
200
+ */
201
+ inputStates: ReadonlyMap<string, InputExecutionState>;
202
+ /**
203
+ * Current inputs set via setInput()
204
+ */
205
+ inputs: Record<string, unknown>;
206
+ /**
207
+ * Set an input value for a specific node.
208
+ * For progressive input provision before calling execute().
209
+ *
210
+ * @param nodeId - The input node ID
211
+ * @param value - The input value (File, URL string, or structured data)
212
+ */
213
+ setInput: (nodeId: string, value: unknown) => void;
214
+ /**
215
+ * Execute the flow with current inputs.
216
+ * Automatically detects input types and routes appropriately.
217
+ * For single input, uses standard upload path.
218
+ * For multiple inputs, requires multiInputUploadFn.
219
+ */
220
+ execute: () => Promise<void>;
221
+ /**
222
+ * Upload a single file through the flow (convenience method).
223
+ * Equivalent to setInput(firstNodeId, file) + execute().
224
+ *
225
+ * @param file - File or Blob to upload
377
226
  */
378
227
  upload: (file: File | Blob) => Promise<void>;
379
228
  /**
@@ -385,7 +234,7 @@ interface UseFlowUploadReturn {
385
234
  */
386
235
  pause: () => void;
387
236
  /**
388
- * Reset the upload state
237
+ * Reset the upload state and clear all inputs
389
238
  */
390
239
  reset: () => void;
391
240
  /**
@@ -400,18 +249,23 @@ interface UseFlowUploadReturn {
400
249
  * Whether the flow is currently processing (after upload completes)
401
250
  */
402
251
  isProcessing: boolean;
252
+ /**
253
+ * Whether the hook is discovering flow inputs
254
+ */
255
+ isDiscoveringInputs: boolean;
403
256
  }
404
257
  /**
405
- * React hook for uploading files through a flow with automatic flow execution.
406
- * Handles both the file upload phase and the flow processing phase, providing
407
- * real-time progress updates and flow node execution tracking.
408
- *
409
- * This is a convenience wrapper around the generic useFlowExecution hook,
410
- * specialized for the common case of file uploads. For more flexible input types
411
- * (URLs, structured data), use useFlowExecution directly with an inputBuilder.
258
+ * React hook for executing flows with single or multiple inputs.
259
+ * Automatically discovers input nodes and detects input types (File, URL, structured data).
260
+ * Supports progressive input provision via setInput() and execute().
412
261
  *
413
- * The flow engine processes the uploaded file through a DAG of nodes, which can
414
- * perform operations like image optimization, storage saving, webhooks, etc.
262
+ * This is the unified flow hook that replaces useFlowUpload for advanced use cases.
263
+ * It provides:
264
+ * - Auto-discovery of flow input nodes
265
+ * - Automatic input type detection (file → upload, string → URL, object → data)
266
+ * - Progressive input provision via setInput()
267
+ * - Multi-input support with parallel coordination
268
+ * - Per-input state tracking
415
269
  *
416
270
  * Must be used within FlowManagerProvider (which must be within UploadistaProvider).
417
271
  * Flow events are automatically routed by the provider to the appropriate manager.
@@ -419,46 +273,17 @@ interface UseFlowUploadReturn {
419
273
  * @param options - Flow upload configuration including flow ID and event handlers
420
274
  * @returns Flow upload state and control methods
421
275
  *
422
- * @remarks
423
- * **Future refactoring**: This hook could be implemented as a thin wrapper around
424
- * useFlowExecution with a file-specific inputBuilder:
425
- * ```typescript
426
- * return useFlowExecution<File | Blob>({
427
- * ...options,
428
- * inputBuilder: async (file) => {
429
- * const { inputNodes } = await client.findInputNode(options.flowConfig.flowId);
430
- * return {
431
- * [inputNodes[0].id]: {
432
- * operation: "init",
433
- * storageId: options.flowConfig.storageId,
434
- * metadata: { originalName: file.name, mimeType: file.type, size: file.size }
435
- * }
436
- * };
437
- * }
438
- * });
439
- * ```
440
- *
441
276
  * @example
442
277
  * ```tsx
443
- * // Basic flow upload with progress tracking
444
- * function ImageUploader() {
445
- * const flowUpload = useFlowUpload({
278
+ * // Single file upload (simple case)
279
+ * function SingleFileUploader() {
280
+ * const flow = useFlow({
446
281
  * flowConfig: {
447
- * flowId: "image-optimization-flow",
282
+ * flowId: "image-optimization",
448
283
  * storageId: "s3-images",
449
284
  * },
450
285
  * onSuccess: (outputs) => {
451
286
  * console.log("Flow outputs:", outputs);
452
- * // Access all outputs from the flow
453
- * for (const output of outputs) {
454
- * console.log(`${output.nodeId}:`, output.data);
455
- * }
456
- * },
457
- * onFlowComplete: (outputs) => {
458
- * console.log("All flow outputs:", outputs);
459
- * },
460
- * onError: (error) => {
461
- * console.error("Upload or processing failed:", error);
462
287
  * },
463
288
  * });
464
289
  *
@@ -466,58 +291,67 @@ interface UseFlowUploadReturn {
466
291
  * <div>
467
292
  * <input
468
293
  * type="file"
469
- * accept="image/*"
470
294
  * onChange={(e) => {
471
295
  * const file = e.target.files?.[0];
472
- * if (file) flowUpload.upload(file);
296
+ * if (file) flow.upload(file);
473
297
  * }}
474
298
  * />
299
+ * {flow.isUploading && <div>Progress: {flow.state.progress}%</div>}
300
+ * </div>
301
+ * );
302
+ * }
475
303
  *
476
- * {flowUpload.isUploadingFile && (
477
- * <div>Uploading... {flowUpload.state.progress}%</div>
478
- * )}
304
+ * // Multi-input with progressive provision
305
+ * function MultiInputFlow() {
306
+ * const flow = useFlow({
307
+ * flowConfig: {
308
+ * flowId: "multi-source-processing",
309
+ * storageId: "default",
310
+ * },
311
+ * });
479
312
  *
480
- * {flowUpload.isProcessing && (
481
- * <div>
482
- * Processing...
483
- * {flowUpload.state.currentNodeName && (
484
- * <span>Current step: {flowUpload.state.currentNodeName}</span>
313
+ * return (
314
+ * <div>
315
+ * {flow.inputMetadata?.map((input) => (
316
+ * <div key={input.nodeId}>
317
+ * <label>{input.nodeId}</label>
318
+ * {input.nodeType === "streaming-input-v1" ? (
319
+ * <input
320
+ * type="file"
321
+ * onChange={(e) => {
322
+ * const file = e.target.files?.[0];
323
+ * if (file) flow.setInput(input.nodeId, file);
324
+ * }}
325
+ * />
326
+ * ) : (
327
+ * <input
328
+ * type="url"
329
+ * onChange={(e) => flow.setInput(input.nodeId, e.target.value)}
330
+ * />
485
331
  * )}
486
332
  * </div>
487
- * )}
333
+ * ))}
334
+ * <button onClick={flow.execute} disabled={flow.isUploading}>
335
+ * Execute Flow
336
+ * </button>
488
337
  *
489
- * {flowUpload.state.status === "success" && (
338
+ * {flow.isUploading && (
490
339
  * <div>
491
- * <p>Upload complete!</p>
492
- * {flowUpload.state.flowOutputs && (
493
- * <div>
494
- * {flowUpload.state.flowOutputs.map((output) => (
495
- * <div key={output.nodeId}>{output.nodeId}: {JSON.stringify(output.data)}</div>
496
- * ))}
340
+ * {Array.from(flow.inputStates.values()).map((inputState) => (
341
+ * <div key={inputState.nodeId}>
342
+ * {inputState.nodeId}: {inputState.status} ({inputState.progress}%)
497
343
  * </div>
498
- * )}
499
- * </div>
500
- * )}
501
- *
502
- * {flowUpload.state.status === "error" && (
503
- * <div>
504
- * <p>Error: {flowUpload.state.error?.message}</p>
505
- * <button onClick={flowUpload.reset}>Try Again</button>
344
+ * ))}
506
345
  * </div>
507
346
  * )}
508
- *
509
- * {flowUpload.isUploading && (
510
- * <button onClick={flowUpload.abort}>Cancel</button>
511
- * )}
512
347
  * </div>
513
348
  * );
514
349
  * }
515
350
  * ```
516
351
  *
517
- * @see {@link useMultiFlowUpload} for uploading multiple files through a flow
518
- * @see {@link useUpload} for simple uploads without flow processing
352
+ * @see {@link useFlowUpload} for a simpler file-only upload hook
519
353
  */
520
- declare function useFlowUpload(options: FlowUploadOptions): UseFlowUploadReturn;
354
+ declare function useFlow(options: FlowUploadOptions): UseFlowReturn;
521
355
  //#endregion
522
356
  //#region src/hooks/use-upload.d.ts
523
357
  interface UseUploadOptions {
@@ -911,5 +745,5 @@ interface UseUploadistaClientReturn {
911
745
  */
912
746
  declare function useUploadistaClient(options: UseUploadistaClientOptions): UseUploadistaClientReturn;
913
747
  //#endregion
914
- export { InputExecutionState as C, FlowInputMetadata as S, useFlow as T, 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, UseFlowReturn as w, useDragDrop as x, DragDropState as y };
915
- //# sourceMappingURL=use-uploadista-client-m9nF-irM.d.mts.map
748
+ export { useDragDrop as C, UseDragDropReturn as S, InputExecutionState as _, MultiUploadState as a, DragDropOptions as b, useMultiUpload as c, UseUploadOptions as d, UseUploadReturn as f, FlowUploadStatus as g, FlowUploadState as h, MultiUploadOptions as i, UploadState as l, FlowInputMetadata as m, UseUploadistaClientReturn as n, UploadItem as o, useUpload as p, useUploadistaClient as r, UseMultiUploadReturn as s, UseUploadistaClientOptions as t, UploadStatus as u, UseFlowReturn as v, DragDropState as x, useFlow as y };
749
+ //# sourceMappingURL=use-uploadista-client-DHbLSpIb.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-uploadista-client-DHbLSpIb.d.mts","names":[],"sources":["../src/hooks/use-drag-drop.ts","../src/hooks/use-flow.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;EAuEZ;;;sBAlJM;ECRL;AA+BjB;;EASiB,eAAA,CAAA,EAAA,CAAA,KAAA,ED3BW,IC2BX,EAAA,EAAA,GAAA,IAAA;EAKkB;;;EAsBlB,iBAAA,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,EAAA,GAAA,IAAA;EAQA;;;EAAuB,iBAAA,CAAA,EAAA,CAAA,UAAA,EAAA,OAAA,EAAA,GAAA,IAAA;AAoJxC;UDrMiB,aAAA;;;AE9BjB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0 +1,2 @@
1
+ import{o as e}from"./use-upload-BvvGROMR.mjs";import t,{useCallback as n,useEffect as r,useRef as i,useState as a}from"react";import{EventType as o}from"@uploadista/core/flow";import{UploadEventType as s}from"@uploadista/core/types";function c(e){if(!(`eventType`in e))return!1;let t=e;return t.eventType===o.JobStart||t.eventType===o.JobEnd||t.eventType===o.FlowStart||t.eventType===o.FlowEnd||t.eventType===o.FlowError||t.eventType===o.FlowPause||t.eventType===o.FlowCancel||t.eventType===o.NodeStart||t.eventType===o.NodeEnd||t.eventType===o.NodePause||t.eventType===o.NodeResume||t.eventType===o.NodeError||t.eventType===o.NodeStream||t.eventType===o.NodeResponse}function l(e){if(!(`type`in e))return!1;let t=e;return t.type===s.UPLOAD_STARTED||t.type===s.UPLOAD_PROGRESS||t.type===s.UPLOAD_COMPLETE||t.type===s.UPLOAD_FAILED||t.type===s.UPLOAD_VALIDATION_SUCCESS||t.type===s.UPLOAD_VALIDATION_FAILED||t.type===s.UPLOAD_VALIDATION_WARNING}function u(t){let{subscribeToEvents:n}=e();r(()=>n(e=>{if(c(e))switch(e.eventType){case o.JobStart:t.onJobStart?.(e);break;case o.JobEnd:t.onJobEnd?.(e);break;case o.FlowStart:t.onFlowStart?.(e);break;case o.FlowEnd:t.onFlowEnd?.(e);break;case o.FlowError:t.onFlowError?.(e);break;case o.FlowPause:t.onFlowPause?.(e);break;case o.FlowCancel:t.onFlowCancel?.(e);break;case o.NodeStart:t.onNodeStart?.(e);break;case o.NodeEnd:t.onNodeEnd?.(e);break;case o.NodePause:t.onNodePause?.(e);break;case o.NodeResume:t.onNodeResume?.(e);break;case o.NodeError:t.onNodeError?.(e);break}}),[n,t])}function d(t){let{subscribeToEvents:n}=e();r(()=>n(e=>{if(!l(e))return;let n=`flow`in e?e.flow:void 0;switch(e.type){case s.UPLOAD_STARTED:t.onUploadStarted?.({...e.data,flow:n});break;case s.UPLOAD_PROGRESS:t.onUploadProgress?.({...e.data,flow:n});break;case s.UPLOAD_COMPLETE:t.onUploadComplete?.({...e.data,flow:n});break;case s.UPLOAD_FAILED:t.onUploadFailed?.({...e.data,flow:n});break;case s.UPLOAD_VALIDATION_SUCCESS:t.onUploadValidationSuccess?.({...e.data,flow:n});break;case s.UPLOAD_VALIDATION_FAILED:t.onUploadValidationFailed?.({...e.data,flow:n});break;case s.UPLOAD_VALIDATION_WARNING:t.onUploadValidationWarning?.({...e.data,flow:n});break}}),[n,t])}const f={totalBytesUploaded:0,totalBytes:0,averageSpeed:0,currentSpeed:0,estimatedTimeRemaining:null,totalFiles:0,completedFiles:0,activeUploads:0,progress:0,peakSpeed:0,startTime:null,endTime:null,totalDuration:null,insights:{overallEfficiency:0,chunkingEffectiveness:0,networkStability:0,recommendations:[],optimalChunkSizeRange:{min:256*1024,max:2*1024*1024}},sessionMetrics:[],chunkMetrics:[]};function p(r={}){let{speedCalculationInterval:o=1e3,speedSampleSize:s=10,onMetricsUpdate:c,onFileStart:l,onFileProgress:u,onFileComplete:d}=r,p=e(),[m,h]=a(f),[g,_]=a([]),v=i([]),y=i(0),b=i(null),x=n((e,t)=>{let n={time:e,bytes:t};v.current.push(n),v.current.length>s&&(v.current=v.current.slice(-s));let r=0;if(v.current.length>=2){let e=v.current[v.current.length-1],t=v.current[v.current.length-2];if(e&&t){let n=(e.time-t.time)/1e3,i=e.bytes-t.bytes;r=n>0?i/n:0}}let i=0;if(v.current.length>=2){let e=v.current[0],t=v.current[v.current.length-1];if(e&&t){let n=(t.time-e.time)/1e3,r=t.bytes-e.bytes;i=n>0?r/n:0}}return{currentSpeed:r,averageSpeed:i}},[s]),S=n(()=>{let e=Date.now(),t=g.reduce((e,t)=>e+t.size,0),n=g.reduce((e,t)=>e+t.bytesUploaded,0),r=g.filter(e=>e.isComplete).length,i=g.filter(e=>!e.isComplete&&e.bytesUploaded>0).length,{currentSpeed:a,averageSpeed:o}=x(e,n),s=t>0?Math.round(n/t*100):0,l=null;a>0&&(l=(t-n)/a*1e3);let u=g.filter(e=>e.startTime>0),d=u.length>0?Math.min(...u.map(e=>e.startTime)):null,f=g.filter(e=>e.endTime!==null),_=f.length>0&&r===g.length?Math.max(...f.map(e=>e.endTime).filter(e=>e!==null)):null,v=d&&_?_-d:null,y={totalBytesUploaded:n,totalBytes:t,averageSpeed:o,currentSpeed:a,estimatedTimeRemaining:l,totalFiles:g.length,completedFiles:r,activeUploads:i,progress:s,peakSpeed:Math.max(m.peakSpeed,a),startTime:d,endTime:_,totalDuration:v,insights:p.client.getChunkingInsights(),sessionMetrics:[p.client.exportMetrics().session],chunkMetrics:p.client.exportMetrics().chunks};h(y),c?.(y)},[g,m.peakSpeed,x,c,p.client]),C=n(()=>(b.current&&clearInterval(b.current),b.current=setInterval(()=>{g.some(e=>!e.isComplete&&e.bytesUploaded>0)&&S()},o),()=>{b.current&&=(clearInterval(b.current),null)}),[o,S,g]),w=n((e,t,n)=>{let r={id:e,filename:t,size:n,bytesUploaded:0,progress:0,speed:0,startTime:Date.now(),endTime:null,duration:null,isComplete:!1};_(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?r:t):[...t,r]),l?.(r),g.filter(e=>!e.isComplete).length===0&&C()},[g,l,C]),T=n((e,t)=>{let n=Date.now();_(r=>r.map(r=>{if(r.id!==e)return r;let i=(n-r.startTime)/1e3,a=i>0?t/i:0,o=r.size>0?Math.round(t/r.size*100):0,s={...r,bytesUploaded:t,progress:o,speed:a};return u?.(s),s})),setTimeout(S,0)},[u,S]),E=n(e=>{let t=Date.now();_(n=>n.map(n=>{if(n.id!==e)return n;let r=t-n.startTime,i=r>0?n.size/r*1e3:0,a={...n,bytesUploaded:n.size,progress:100,speed:i,endTime:t,duration:r,isComplete:!0};return d?.(a),a})),setTimeout(S,0)},[d,S]),D=n(e=>{_(t=>t.filter(t=>t.id!==e)),setTimeout(S,0)},[S]),O=n(()=>{b.current&&=(clearInterval(b.current),null),h(f),_([]),v.current=[],y.current=0},[]),k=n(e=>g.find(t=>t.id===e),[g]),A=n(()=>({overall:m,files:g,exportTime:Date.now()}),[m,g]);return t.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]),{metrics:m,fileMetrics:g,startFileUpload:w,updateFileProgress:T,completeFileUpload:E,removeFile:D,reset:O,getFileMetrics:k,exportMetrics:A}}function m(t){let{subscribeToEvents:n}=e();r(()=>n(t),[n,t])}export{c as a,u as i,p as n,l as o,d as r,m as t};
2
+ //# sourceMappingURL=use-uploadista-events-BwUD-2Ck.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-uploadista-events-BwUD-2Ck.mjs","names":["initialMetrics: UploadMetrics","estimatedTimeRemaining: number | null","newMetrics: UploadMetrics","fileMetric: FileUploadMetrics"],"sources":["../src/hooks/event-utils.ts","../src/hooks/use-flow-events.ts","../src/hooks/use-upload-events.ts","../src/hooks/use-upload-metrics.ts","../src/hooks/use-uploadista-events.ts"],"sourcesContent":["import type { UploadistaEvent } from \"@uploadista/client-browser\";\nimport { EventType, type FlowEvent } from \"@uploadista/core/flow\";\nimport { UploadEventType, type UploadEvent } from \"@uploadista/core/types\";\n\n/**\n * Type guard to check if an event is a flow event\n */\nexport function isFlowEvent(event: UploadistaEvent): event is FlowEvent {\n if (!(\"eventType\" in event)) return false;\n const e = event as { eventType: unknown };\n return (\n e.eventType === EventType.JobStart ||\n e.eventType === EventType.JobEnd ||\n e.eventType === EventType.FlowStart ||\n e.eventType === EventType.FlowEnd ||\n e.eventType === EventType.FlowError ||\n e.eventType === EventType.FlowPause ||\n e.eventType === EventType.FlowCancel ||\n e.eventType === EventType.NodeStart ||\n e.eventType === EventType.NodeEnd ||\n e.eventType === EventType.NodePause ||\n e.eventType === EventType.NodeResume ||\n e.eventType === EventType.NodeError ||\n e.eventType === EventType.NodeStream ||\n e.eventType === EventType.NodeResponse\n );\n}\n\n/**\n * Type guard to check if an event is an upload event\n */\nexport function isUploadEvent(event: UploadistaEvent): event is UploadEvent {\n if (!(\"type\" in event)) return false;\n const e = event as { type: unknown };\n return (\n e.type === UploadEventType.UPLOAD_STARTED ||\n e.type === UploadEventType.UPLOAD_PROGRESS ||\n e.type === UploadEventType.UPLOAD_COMPLETE ||\n e.type === UploadEventType.UPLOAD_FAILED ||\n e.type === UploadEventType.UPLOAD_VALIDATION_SUCCESS ||\n e.type === UploadEventType.UPLOAD_VALIDATION_FAILED ||\n e.type === UploadEventType.UPLOAD_VALIDATION_WARNING\n );\n}\n","import type {\n FlowEventFlowCancel,\n FlowEventFlowEnd,\n FlowEventFlowError,\n FlowEventFlowPause,\n FlowEventFlowStart,\n FlowEventJobEnd,\n FlowEventJobStart,\n FlowEventNodeEnd,\n FlowEventNodeError,\n FlowEventNodePause,\n FlowEventNodeResume,\n FlowEventNodeStart,\n} from \"@uploadista/core/flow\";\nimport { EventType } from \"@uploadista/core/flow\";\nimport { useEffect } from \"react\";\nimport { useUploadistaContext } from \"../components/uploadista-provider\";\nimport { isFlowEvent } from \"./event-utils\";\n\n/**\n * Options for handling flow execution events.\n *\n * All callbacks are optional - only provide handlers for events you care about.\n */\nexport interface UseFlowEventsOptions {\n /** Called when a job starts execution */\n onJobStart?: (event: FlowEventJobStart) => void;\n /** Called when a job completes (success or failure) */\n onJobEnd?: (event: FlowEventJobEnd) => void;\n /** Called when a flow begins execution */\n onFlowStart?: (event: FlowEventFlowStart) => void;\n /** Called when a flow completes successfully */\n onFlowEnd?: (event: FlowEventFlowEnd) => void;\n /** Called when a flow encounters an error */\n onFlowError?: (event: FlowEventFlowError) => void;\n /** Called when a flow is paused by user request */\n onFlowPause?: (event: FlowEventFlowPause) => void;\n /** Called when a flow is cancelled by user request */\n onFlowCancel?: (event: FlowEventFlowCancel) => void;\n /** Called when a node starts processing */\n onNodeStart?: (event: FlowEventNodeStart) => void;\n /** Called when a node completes successfully */\n onNodeEnd?: (event: FlowEventNodeEnd) => void;\n /** Called when a node pauses (waiting for additional data) */\n onNodePause?: (event: FlowEventNodePause) => void;\n /** Called when a paused node resumes execution */\n onNodeResume?: (event: FlowEventNodeResume) => void;\n /** Called when a node encounters an error */\n onNodeError?: (event: FlowEventNodeError) => void;\n}\n\n/**\n * Structured hook for handling flow execution events with type-safe callbacks.\n *\n * This hook provides a clean API for listening to specific flow events without\n * needing to manually filter events or use type guards.\n *\n * Must be used within UploadistaProvider.\n *\n * @param options - Object with optional callbacks for each flow event type\n *\n * @example\n * ```tsx\n * import { useFlowEvents } from '@uploadista/react';\n *\n * function FlowMonitor() {\n * useFlowEvents({\n * onFlowStart: (event) => {\n * console.log('Flow started:', event.flowId);\n * },\n * onNodeStart: (event) => {\n * console.log('Node started:', event.nodeName);\n * },\n * onNodeEnd: (event) => {\n * console.log('Node completed:', event.nodeName, event.result);\n * },\n * onFlowEnd: (event) => {\n * console.log('Flow completed with outputs:', event.outputs);\n * },\n * onFlowError: (event) => {\n * console.error('Flow failed:', event.error);\n * },\n * });\n *\n * return <div>Monitoring flow execution...</div>;\n * }\n * ```\n */\nexport function useFlowEvents(options: UseFlowEventsOptions): void {\n const { subscribeToEvents } = useUploadistaContext();\n\n useEffect(() => {\n const unsubscribe = subscribeToEvents((event) => {\n // Only handle flow events\n if (!isFlowEvent(event)) return;\n\n // Route to appropriate callback based on event type\n switch (event.eventType) {\n case EventType.JobStart:\n options.onJobStart?.(event);\n break;\n case EventType.JobEnd:\n options.onJobEnd?.(event);\n break;\n case EventType.FlowStart:\n options.onFlowStart?.(event);\n break;\n case EventType.FlowEnd:\n options.onFlowEnd?.(event);\n break;\n case EventType.FlowError:\n options.onFlowError?.(event);\n break;\n case EventType.FlowPause:\n options.onFlowPause?.(event);\n break;\n case EventType.FlowCancel:\n options.onFlowCancel?.(event);\n break;\n case EventType.NodeStart:\n options.onNodeStart?.(event);\n break;\n case EventType.NodeEnd:\n options.onNodeEnd?.(event);\n break;\n case EventType.NodePause:\n options.onNodePause?.(event);\n break;\n case EventType.NodeResume:\n options.onNodeResume?.(event);\n break;\n case EventType.NodeError:\n options.onNodeError?.(event);\n break;\n }\n });\n\n return unsubscribe;\n }, [subscribeToEvents, options]);\n}\n","import { UploadEventType, type UploadEvent } from \"@uploadista/core/types\";\nimport { useEffect } from \"react\";\nimport { useUploadistaContext } from \"../components/uploadista-provider\";\nimport { isUploadEvent } from \"./event-utils\";\n\n/**\n * Upload progress event data\n */\nexport interface UploadProgressEventData {\n id: string;\n progress: number;\n total: number;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Upload started/complete event data (contains full UploadFile)\n */\nexport interface UploadFileEventData {\n // This will contain the full UploadFile schema\n [key: string]: unknown;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Upload failed event data\n */\nexport interface UploadFailedEventData {\n id: string;\n error: string;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Upload validation success event data\n */\nexport interface UploadValidationSuccessEventData {\n id: string;\n validationType: \"checksum\" | \"mimetype\";\n algorithm?: string;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Upload validation failed event data\n */\nexport interface UploadValidationFailedEventData {\n id: string;\n reason: string;\n expected: string;\n actual: string;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Upload validation warning event data\n */\nexport interface UploadValidationWarningEventData {\n id: string;\n message: string;\n flow?: {\n flowId: string;\n nodeId: string;\n jobId: string;\n };\n}\n\n/**\n * Options for handling upload events.\n *\n * All callbacks are optional - only provide handlers for events you care about.\n */\nexport interface UseUploadEventsOptions {\n /** Called when an upload starts */\n onUploadStarted?: (data: UploadFileEventData) => void;\n /** Called with upload progress updates */\n onUploadProgress?: (data: UploadProgressEventData) => void;\n /** Called when an upload completes successfully */\n onUploadComplete?: (data: UploadFileEventData) => void;\n /** Called when an upload fails */\n onUploadFailed?: (data: UploadFailedEventData) => void;\n /** Called when upload validation succeeds */\n onUploadValidationSuccess?: (data: UploadValidationSuccessEventData) => void;\n /** Called when upload validation fails */\n onUploadValidationFailed?: (data: UploadValidationFailedEventData) => void;\n /** Called when upload validation produces a warning */\n onUploadValidationWarning?: (data: UploadValidationWarningEventData) => void;\n}\n\n/**\n * Structured hook for handling upload events with type-safe callbacks.\n *\n * This hook provides a clean API for listening to specific upload events without\n * needing to manually filter events or use type guards.\n *\n * Must be used within UploadistaProvider.\n *\n * @param options - Object with optional callbacks for each upload event type\n *\n * @example\n * ```tsx\n * import { useUploadEvents } from '@uploadista/react';\n *\n * function UploadMonitor() {\n * useUploadEvents({\n * onUploadStarted: (data) => {\n * console.log('Upload started:', data.id);\n * },\n * onUploadProgress: (data) => {\n * const percent = (data.progress / data.total) * 100;\n * console.log(`Upload progress: ${percent}%`);\n * },\n * onUploadComplete: (data) => {\n * console.log('Upload completed:', data);\n * },\n * onUploadFailed: (data) => {\n * console.error('Upload failed:', data.error);\n * },\n * });\n *\n * return <div>Monitoring uploads...</div>;\n * }\n * ```\n */\nexport function useUploadEvents(options: UseUploadEventsOptions): void {\n const { subscribeToEvents } = useUploadistaContext();\n\n useEffect(() => {\n const unsubscribe = subscribeToEvents((event) => {\n // Only handle upload events\n if (!isUploadEvent(event)) return;\n\n // Route to appropriate callback based on event type\n // Note: flow context is at the top level of the event, not inside data\n const flowContext = \"flow\" in event ? event.flow : undefined;\n\n switch (event.type) {\n case UploadEventType.UPLOAD_STARTED:\n options.onUploadStarted?.({\n ...(event.data as unknown as Omit<UploadFileEventData, \"flow\">),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_PROGRESS:\n options.onUploadProgress?.({\n ...(event.data as unknown as Omit<\n UploadProgressEventData,\n \"flow\"\n >),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_COMPLETE:\n options.onUploadComplete?.({\n ...(event.data as unknown as Omit<UploadFileEventData, \"flow\">),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_FAILED:\n options.onUploadFailed?.({\n ...(event.data as unknown as Omit<UploadFailedEventData, \"flow\">),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_VALIDATION_SUCCESS:\n options.onUploadValidationSuccess?.({\n ...(event.data as unknown as Omit<\n UploadValidationSuccessEventData,\n \"flow\"\n >),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_VALIDATION_FAILED:\n options.onUploadValidationFailed?.({\n ...(event.data as unknown as Omit<\n UploadValidationFailedEventData,\n \"flow\"\n >),\n flow: flowContext,\n });\n break;\n case UploadEventType.UPLOAD_VALIDATION_WARNING:\n options.onUploadValidationWarning?.({\n ...(event.data as unknown as Omit<\n UploadValidationWarningEventData,\n \"flow\"\n >),\n flow: flowContext,\n });\n break;\n }\n });\n\n return unsubscribe;\n }, [subscribeToEvents, options]);\n}\n","import type {\n ChunkMetrics,\n PerformanceInsights,\n UploadSessionMetrics,\n} from \"@uploadista/client-core\";\nimport React, { useCallback, useRef, useState } from \"react\";\nimport { useUploadistaContext } from \"../components/uploadista-provider\";\n\nexport type Timeout = ReturnType<typeof setInterval>;\n\nexport interface UploadMetrics {\n /**\n * Total bytes uploaded across all files\n */\n totalBytesUploaded: number;\n\n /**\n * Total bytes to upload across all files\n */\n totalBytes: number;\n\n /**\n * Overall upload speed in bytes per second\n */\n averageSpeed: number;\n\n /**\n * Current upload speed in bytes per second\n */\n currentSpeed: number;\n\n /**\n * Estimated time remaining in milliseconds\n */\n estimatedTimeRemaining: number | null;\n\n /**\n * Total number of files being tracked\n */\n totalFiles: number;\n\n /**\n * Number of files completed\n */\n completedFiles: number;\n\n /**\n * Number of files currently uploading\n */\n activeUploads: number;\n\n /**\n * Overall progress as percentage (0-100)\n */\n progress: number;\n\n /**\n * Peak upload speed achieved\n */\n peakSpeed: number;\n\n /**\n * Start time of the first upload\n */\n startTime: number | null;\n\n /**\n * End time of the last completed upload\n */\n endTime: number | null;\n\n /**\n * Total duration of all uploads\n */\n totalDuration: number | null;\n\n /**\n * Detailed performance insights from the upload client\n */\n insights: PerformanceInsights;\n\n /**\n * Session metrics for completed uploads\n */\n sessionMetrics: Partial<UploadSessionMetrics>[];\n\n /**\n * Detailed chunk metrics from recent uploads\n */\n chunkMetrics: ChunkMetrics[];\n}\n\nexport interface FileUploadMetrics {\n id: string;\n filename: string;\n size: number;\n bytesUploaded: number;\n progress: number;\n speed: number;\n startTime: number;\n endTime: number | null;\n duration: number | null;\n isComplete: boolean;\n}\n\nexport interface UseUploadMetricsOptions {\n /**\n * Interval for calculating current speed (in milliseconds)\n */\n speedCalculationInterval?: number;\n\n /**\n * Number of speed samples to keep for average calculation\n */\n speedSampleSize?: number;\n\n /**\n * Called when metrics are updated\n */\n onMetricsUpdate?: (metrics: UploadMetrics) => void;\n\n /**\n * Called when a file upload starts\n */\n onFileStart?: (fileMetrics: FileUploadMetrics) => void;\n\n /**\n * Called when a file upload progresses\n */\n onFileProgress?: (fileMetrics: FileUploadMetrics) => void;\n\n /**\n * Called when a file upload completes\n */\n onFileComplete?: (fileMetrics: FileUploadMetrics) => void;\n}\n\nexport interface UseUploadMetricsReturn {\n /**\n * Current overall metrics\n */\n metrics: UploadMetrics;\n\n /**\n * Individual file metrics\n */\n fileMetrics: FileUploadMetrics[];\n\n /**\n * Start tracking a new file upload\n */\n startFileUpload: (id: string, filename: string, size: number) => void;\n\n /**\n * Update progress for a file upload\n */\n updateFileProgress: (id: string, bytesUploaded: number) => void;\n\n /**\n * Mark a file upload as complete\n */\n completeFileUpload: (id: string) => void;\n\n /**\n * Remove a file from tracking\n */\n removeFile: (id: string) => void;\n\n /**\n * Reset all metrics\n */\n reset: () => void;\n\n /**\n * Get metrics for a specific file\n */\n getFileMetrics: (id: string) => FileUploadMetrics | undefined;\n\n /**\n * Export metrics as JSON\n */\n exportMetrics: () => {\n overall: UploadMetrics;\n files: FileUploadMetrics[];\n exportTime: number;\n };\n}\n\nconst initialMetrics: UploadMetrics = {\n totalBytesUploaded: 0,\n totalBytes: 0,\n averageSpeed: 0,\n currentSpeed: 0,\n estimatedTimeRemaining: null,\n totalFiles: 0,\n completedFiles: 0,\n activeUploads: 0,\n progress: 0,\n peakSpeed: 0,\n startTime: null,\n endTime: null,\n totalDuration: null,\n insights: {\n overallEfficiency: 0,\n chunkingEffectiveness: 0,\n networkStability: 0,\n recommendations: [],\n optimalChunkSizeRange: { min: 256 * 1024, max: 2 * 1024 * 1024 },\n },\n sessionMetrics: [],\n chunkMetrics: [],\n};\n\n/**\n * React hook for tracking detailed upload metrics and performance statistics.\n * Provides comprehensive monitoring of upload progress, speed, and timing data.\n *\n * @param options - Configuration and event handlers\n * @returns Upload metrics state and control methods\n *\n * @example\n * ```tsx\n * const uploadMetrics = useUploadMetrics({\n * speedCalculationInterval: 1000, // Update speed every second\n * speedSampleSize: 10, // Keep last 10 speed samples for average\n * onMetricsUpdate: (metrics) => {\n * console.log(`Overall progress: ${metrics.progress}%`);\n * console.log(`Speed: ${(metrics.currentSpeed / 1024).toFixed(1)} KB/s`);\n * console.log(`ETA: ${metrics.estimatedTimeRemaining}ms`);\n * },\n * onFileComplete: (fileMetrics) => {\n * console.log(`${fileMetrics.filename} completed in ${fileMetrics.duration}ms`);\n * },\n * });\n *\n * // Start tracking a file\n * const handleFileStart = (file: File) => {\n * uploadMetrics.startFileUpload(file.name, file.name, file.size);\n * };\n *\n * // Update progress during upload\n * const handleProgress = (fileId: string, bytesUploaded: number) => {\n * uploadMetrics.updateFileProgress(fileId, bytesUploaded);\n * };\n *\n * // Display metrics\n * return (\n * <div>\n * <div>Overall Progress: {uploadMetrics.metrics.progress}%</div>\n * <div>Speed: {(uploadMetrics.metrics.currentSpeed / 1024).toFixed(1)} KB/s</div>\n * <div>Files: {uploadMetrics.metrics.completedFiles}/{uploadMetrics.metrics.totalFiles}</div>\n *\n * {uploadMetrics.metrics.estimatedTimeRemaining && (\n * <div>ETA: {Math.round(uploadMetrics.metrics.estimatedTimeRemaining / 1000)}s</div>\n * )}\n *\n * {uploadMetrics.fileMetrics.map((file) => (\n * <div key={file.id}>\n * {file.filename}: {file.progress}% ({(file.speed / 1024).toFixed(1)} KB/s)\n * </div>\n * ))}\n * </div>\n * );\n * ```\n */\nexport function useUploadMetrics(\n options: UseUploadMetricsOptions = {},\n): UseUploadMetricsReturn {\n const {\n speedCalculationInterval = 1000,\n speedSampleSize = 10,\n onMetricsUpdate,\n onFileStart,\n onFileProgress,\n onFileComplete,\n } = options;\n\n const uploadClient = useUploadistaContext();\n\n const [metrics, setMetrics] = useState<UploadMetrics>(initialMetrics);\n const [fileMetrics, setFileMetrics] = useState<FileUploadMetrics[]>([]);\n\n const speedSamplesRef = useRef<Array<{ time: number; bytes: number }>>([]);\n const lastUpdateRef = useRef<number>(0);\n const intervalRef = useRef<Timeout | null>(null);\n\n const calculateSpeed = useCallback(\n (currentTime: number, totalBytesUploaded: number) => {\n const sample = { time: currentTime, bytes: totalBytesUploaded };\n speedSamplesRef.current.push(sample);\n\n // Keep only recent samples\n if (speedSamplesRef.current.length > speedSampleSize) {\n speedSamplesRef.current = speedSamplesRef.current.slice(\n -speedSampleSize,\n );\n }\n\n // Calculate current speed (bytes per second)\n let currentSpeed = 0;\n if (speedSamplesRef.current.length >= 2) {\n const recent =\n speedSamplesRef.current[speedSamplesRef.current.length - 1];\n const previous =\n speedSamplesRef.current[speedSamplesRef.current.length - 2];\n if (recent && previous) {\n const timeDiff = (recent.time - previous.time) / 1000; // Convert to seconds\n const bytesDiff = recent.bytes - previous.bytes;\n currentSpeed = timeDiff > 0 ? bytesDiff / timeDiff : 0;\n }\n }\n\n // Calculate average speed\n let averageSpeed = 0;\n if (speedSamplesRef.current.length >= 2) {\n const first = speedSamplesRef.current[0];\n const last =\n speedSamplesRef.current[speedSamplesRef.current.length - 1];\n if (first && last) {\n const totalTime = (last.time - first.time) / 1000; // Convert to seconds\n const totalBytes = last.bytes - first.bytes;\n averageSpeed = totalTime > 0 ? totalBytes / totalTime : 0;\n }\n }\n\n return { currentSpeed, averageSpeed };\n },\n [speedSampleSize],\n );\n\n const updateMetrics = useCallback(() => {\n const now = Date.now();\n\n // Calculate totals from file metrics\n const totalBytes = fileMetrics.reduce((sum, file) => sum + file.size, 0);\n const totalBytesUploaded = fileMetrics.reduce(\n (sum, file) => sum + file.bytesUploaded,\n 0,\n );\n const completedFiles = fileMetrics.filter((file) => file.isComplete).length;\n const activeUploads = fileMetrics.filter(\n (file) => !file.isComplete && file.bytesUploaded > 0,\n ).length;\n\n // Calculate speeds\n const { currentSpeed, averageSpeed } = calculateSpeed(\n now,\n totalBytesUploaded,\n );\n\n // Calculate progress\n const progress =\n totalBytes > 0 ? Math.round((totalBytesUploaded / totalBytes) * 100) : 0;\n\n // Calculate estimated time remaining\n let estimatedTimeRemaining: number | null = null;\n if (currentSpeed > 0) {\n const remainingBytes = totalBytes - totalBytesUploaded;\n estimatedTimeRemaining = (remainingBytes / currentSpeed) * 1000; // Convert to milliseconds\n }\n\n // Find start and end times\n const activeTimes = fileMetrics.filter((file) => file.startTime > 0);\n const startTime =\n activeTimes.length > 0\n ? Math.min(...activeTimes.map((file) => file.startTime))\n : null;\n\n const completedTimes = fileMetrics.filter((file) => file.endTime !== null);\n const endTime =\n completedTimes.length > 0 && completedFiles === fileMetrics.length\n ? Math.max(\n ...completedTimes\n .map((file) => file.endTime)\n .filter((time) => time !== null),\n )\n : null;\n\n const totalDuration = startTime && endTime ? endTime - startTime : null;\n\n const newMetrics: UploadMetrics = {\n totalBytesUploaded,\n totalBytes,\n averageSpeed,\n currentSpeed,\n estimatedTimeRemaining,\n totalFiles: fileMetrics.length,\n completedFiles,\n activeUploads,\n progress,\n peakSpeed: Math.max(metrics.peakSpeed, currentSpeed),\n startTime,\n endTime,\n totalDuration,\n insights: uploadClient.client.getChunkingInsights(),\n sessionMetrics: [uploadClient.client.exportMetrics().session],\n chunkMetrics: uploadClient.client.exportMetrics().chunks,\n };\n\n setMetrics(newMetrics);\n onMetricsUpdate?.(newMetrics);\n }, [\n fileMetrics,\n metrics.peakSpeed,\n calculateSpeed,\n onMetricsUpdate,\n uploadClient.client,\n ]);\n\n // Set up periodic speed calculations\n const setupSpeedCalculation = useCallback(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n\n intervalRef.current = setInterval(() => {\n if (\n fileMetrics.some((file) => !file.isComplete && file.bytesUploaded > 0)\n ) {\n updateMetrics();\n }\n }, speedCalculationInterval);\n\n return () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n };\n }, [speedCalculationInterval, updateMetrics, fileMetrics]);\n\n const startFileUpload = useCallback(\n (id: string, filename: string, size: number) => {\n const now = Date.now();\n\n const fileMetric: FileUploadMetrics = {\n id,\n filename,\n size,\n bytesUploaded: 0,\n progress: 0,\n speed: 0,\n startTime: now,\n endTime: null,\n duration: null,\n isComplete: false,\n };\n\n setFileMetrics((prev) => {\n const existing = prev.find((file) => file.id === id);\n if (existing) {\n return prev.map((file) => (file.id === id ? fileMetric : file));\n }\n return [...prev, fileMetric];\n });\n\n onFileStart?.(fileMetric);\n\n // Start speed calculation if this is the first active upload\n if (fileMetrics.filter((file) => !file.isComplete).length === 0) {\n setupSpeedCalculation();\n }\n },\n [fileMetrics, onFileStart, setupSpeedCalculation],\n );\n\n const updateFileProgress = useCallback(\n (id: string, bytesUploaded: number) => {\n const now = Date.now();\n\n setFileMetrics((prev) =>\n prev.map((file) => {\n if (file.id !== id) return file;\n\n const timeDiff = (now - file.startTime) / 1000; // seconds\n const speed = timeDiff > 0 ? bytesUploaded / timeDiff : 0;\n const progress =\n file.size > 0 ? Math.round((bytesUploaded / file.size) * 100) : 0;\n\n const updatedFile = {\n ...file,\n bytesUploaded,\n progress,\n speed,\n };\n\n onFileProgress?.(updatedFile);\n return updatedFile;\n }),\n );\n\n // Trigger metrics update\n setTimeout(updateMetrics, 0);\n },\n [onFileProgress, updateMetrics],\n );\n\n const completeFileUpload = useCallback(\n (id: string) => {\n const now = Date.now();\n\n setFileMetrics((prev) =>\n prev.map((file) => {\n if (file.id !== id) return file;\n\n const duration = now - file.startTime;\n const speed = duration > 0 ? (file.size / duration) * 1000 : 0; // bytes per second\n\n const completedFile = {\n ...file,\n bytesUploaded: file.size,\n progress: 100,\n speed,\n endTime: now,\n duration,\n isComplete: true,\n };\n\n onFileComplete?.(completedFile);\n return completedFile;\n }),\n );\n\n // Trigger metrics update\n setTimeout(updateMetrics, 0);\n },\n [onFileComplete, updateMetrics],\n );\n\n const removeFile = useCallback(\n (id: string) => {\n setFileMetrics((prev) => prev.filter((file) => file.id !== id));\n setTimeout(updateMetrics, 0);\n },\n [updateMetrics],\n );\n\n const reset = useCallback(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n\n setMetrics(initialMetrics);\n setFileMetrics([]);\n speedSamplesRef.current = [];\n lastUpdateRef.current = 0;\n }, []);\n\n const getFileMetrics = useCallback(\n (id: string) => {\n return fileMetrics.find((file) => file.id === id);\n },\n [fileMetrics],\n );\n\n const exportMetrics = useCallback(() => {\n return {\n overall: metrics,\n files: fileMetrics,\n exportTime: Date.now(),\n };\n }, [metrics, fileMetrics]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n };\n }, []);\n\n return {\n metrics,\n fileMetrics,\n startFileUpload,\n updateFileProgress,\n completeFileUpload,\n removeFile,\n reset,\n getFileMetrics,\n exportMetrics,\n };\n}\n","import type { UploadistaEvent } from \"@uploadista/client-core\";\nimport { useEffect } from \"react\";\nimport { useUploadistaContext } from \"../components/uploadista-provider\";\n\n/**\n * Simple hook that subscribes to all Uploadista events (both flow and upload events).\n *\n * This is a low-level hook that provides access to all events. For more structured\n * event handling, consider using `useFlowEvents` or `useUploadEvents` instead.\n *\n * Must be used within UploadistaProvider.\n *\n * @param callback - Function called for every event emitted by the Uploadista client\n *\n * @example\n * ```tsx\n * import { useUploadistaEvents, isFlowEvent, isUploadEvent } from '@uploadista/react';\n *\n * function MyComponent() {\n * useUploadistaEvents((event) => {\n * if (isFlowEvent(event)) {\n * console.log('Flow event:', event.eventType);\n * } else if (isUploadEvent(event)) {\n * console.log('Upload event:', event.type);\n * }\n * });\n *\n * return <div>Listening to all events...</div>;\n * }\n * ```\n */\nexport function useUploadistaEvents(\n callback: (event: UploadistaEvent) => void,\n): void {\n const { subscribeToEvents } = useUploadistaContext();\n\n useEffect(() => {\n const unsubscribe = subscribeToEvents(callback);\n return unsubscribe;\n }, [subscribeToEvents, callback]);\n}\n"],"mappings":"yOAOA,SAAgB,EAAY,EAA4C,CACtE,GAAI,EAAE,cAAe,GAAQ,MAAO,GACpC,IAAM,EAAI,EACV,OACE,EAAE,YAAc,EAAU,UAC1B,EAAE,YAAc,EAAU,QAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,SAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,YAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,SAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,YAC1B,EAAE,YAAc,EAAU,WAC1B,EAAE,YAAc,EAAU,YAC1B,EAAE,YAAc,EAAU,aAO9B,SAAgB,EAAc,EAA8C,CAC1E,GAAI,EAAE,SAAU,GAAQ,MAAO,GAC/B,IAAM,EAAI,EACV,OACE,EAAE,OAAS,EAAgB,gBAC3B,EAAE,OAAS,EAAgB,iBAC3B,EAAE,OAAS,EAAgB,iBAC3B,EAAE,OAAS,EAAgB,eAC3B,EAAE,OAAS,EAAgB,2BAC3B,EAAE,OAAS,EAAgB,0BAC3B,EAAE,OAAS,EAAgB,0BC+C/B,SAAgB,EAAc,EAAqC,CACjE,GAAM,CAAE,qBAAsB,GAAsB,CAEpD,MACsB,EAAmB,GAAU,CAE1C,KAAY,EAAM,CAGvB,OAAQ,EAAM,UAAd,CACE,KAAK,EAAU,SACb,EAAQ,aAAa,EAAM,CAC3B,MACF,KAAK,EAAU,OACb,EAAQ,WAAW,EAAM,CACzB,MACF,KAAK,EAAU,UACb,EAAQ,cAAc,EAAM,CAC5B,MACF,KAAK,EAAU,QAC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