@uploadista/react 0.0.20-beta.1 → 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.
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +1 -1
- package/dist/flow-upload-list-SbpCaxRq.mjs +2 -0
- package/dist/flow-upload-list-SbpCaxRq.mjs.map +1 -0
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/{uploadista-provider-CM48PPSp.d.mts → uploadista-provider-C1l0iBc9.d.mts} +503 -309
- package/dist/uploadista-provider-C1l0iBc9.d.mts.map +1 -0
- package/dist/use-upload-BvvGROMR.mjs +2 -0
- package/dist/use-upload-BvvGROMR.mjs.map +1 -0
- package/dist/{use-uploadista-client-m9nF-irM.d.mts → use-uploadista-client-DHbLSpIb.d.mts} +120 -286
- package/dist/use-uploadista-client-DHbLSpIb.d.mts.map +1 -0
- package/dist/use-uploadista-events-BwUD-2Ck.mjs +2 -0
- package/dist/use-uploadista-events-BwUD-2Ck.mjs.map +1 -0
- package/dist/{use-upload-metrics-DhzS4lhG.d.mts → use-uploadista-events-CtDXJYrR.d.mts} +169 -371
- package/dist/use-uploadista-events-CtDXJYrR.d.mts.map +1 -0
- package/package.json +6 -6
- package/src/components/flow-primitives.tsx +839 -0
- package/src/components/index.tsx +31 -13
- package/src/hooks/index.ts +25 -37
- package/src/index.ts +90 -81
- package/dist/upload-zone-BjWHuP7p.mjs +0 -6
- package/dist/upload-zone-BjWHuP7p.mjs.map +0 -1
- package/dist/uploadista-provider-CM48PPSp.d.mts.map +0 -1
- package/dist/use-upload-BDHVhQsI.mjs +0 -2
- package/dist/use-upload-BDHVhQsI.mjs.map +0 -1
- package/dist/use-upload-metrics-Df90wIos.mjs +0 -2
- package/dist/use-upload-metrics-Df90wIos.mjs.map +0 -1
- package/dist/use-upload-metrics-DhzS4lhG.d.mts.map +0 -1
- package/dist/use-uploadista-client-m9nF-irM.d.mts.map +0 -1
- package/src/components/flow-input.tsx +0 -299
- package/src/components/flow-upload-zone.tsx +0 -441
- package/src/hooks/use-flow-execution.ts +0 -502
- package/src/hooks/use-flow-upload.ts +0 -299
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChunkMetrics, PerformanceInsights, UploadSessionMetrics, UploadistaEvent } from "@uploadista/client-core";
|
|
2
|
+
import { FlowEvent, FlowEventFlowCancel, FlowEventFlowEnd, FlowEventFlowError, FlowEventFlowPause, FlowEventFlowStart, FlowEventJobEnd, FlowEventJobStart, FlowEventNodeEnd, FlowEventNodeError, FlowEventNodePause, FlowEventNodeResume, FlowEventNodeStart } from "@uploadista/core/flow";
|
|
2
3
|
import { UploadEvent } from "@uploadista/core/types";
|
|
3
|
-
import {
|
|
4
|
-
import { BrowserUploadInput, FlowUploadOptions, MultiFlowUploadOptions, MultiFlowUploadState, UploadistaEvent as UploadistaEvent$1 } from "@uploadista/client-browser";
|
|
4
|
+
import { BrowserUploadInput, MultiFlowUploadOptions, MultiFlowUploadState, UploadistaEvent as UploadistaEvent$1 } from "@uploadista/client-browser";
|
|
5
5
|
|
|
6
6
|
//#region src/hooks/event-utils.d.ts
|
|
7
7
|
/**
|
|
@@ -13,36 +13,6 @@ declare function isFlowEvent(event: UploadistaEvent$1): event is FlowEvent;
|
|
|
13
13
|
*/
|
|
14
14
|
declare function isUploadEvent(event: UploadistaEvent$1): event is UploadEvent;
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region src/hooks/use-uploadista-events.d.ts
|
|
17
|
-
/**
|
|
18
|
-
* Simple hook that subscribes to all Uploadista events (both flow and upload events).
|
|
19
|
-
*
|
|
20
|
-
* This is a low-level hook that provides access to all events. For more structured
|
|
21
|
-
* event handling, consider using `useFlowEvents` or `useUploadEvents` instead.
|
|
22
|
-
*
|
|
23
|
-
* Must be used within UploadistaProvider.
|
|
24
|
-
*
|
|
25
|
-
* @param callback - Function called for every event emitted by the Uploadista client
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* import { useUploadistaEvents, isFlowEvent, isUploadEvent } from '@uploadista/react';
|
|
30
|
-
*
|
|
31
|
-
* function MyComponent() {
|
|
32
|
-
* useUploadistaEvents((event) => {
|
|
33
|
-
* if (isFlowEvent(event)) {
|
|
34
|
-
* console.log('Flow event:', event.eventType);
|
|
35
|
-
* } else if (isUploadEvent(event)) {
|
|
36
|
-
* console.log('Upload event:', event.type);
|
|
37
|
-
* }
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* return <div>Listening to all events...</div>;
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare function useUploadistaEvents(callback: (event: UploadistaEvent) => void): void;
|
|
45
|
-
//#endregion
|
|
46
16
|
//#region src/hooks/use-flow-events.d.ts
|
|
47
17
|
/**
|
|
48
18
|
* Options for handling flow execution events.
|
|
@@ -114,342 +84,6 @@ interface UseFlowEventsOptions {
|
|
|
114
84
|
*/
|
|
115
85
|
declare function useFlowEvents(options: UseFlowEventsOptions): void;
|
|
116
86
|
//#endregion
|
|
117
|
-
//#region src/hooks/use-upload-events.d.ts
|
|
118
|
-
/**
|
|
119
|
-
* Upload progress event data
|
|
120
|
-
*/
|
|
121
|
-
interface UploadProgressEventData {
|
|
122
|
-
id: string;
|
|
123
|
-
progress: number;
|
|
124
|
-
total: number;
|
|
125
|
-
flow?: {
|
|
126
|
-
flowId: string;
|
|
127
|
-
nodeId: string;
|
|
128
|
-
jobId: string;
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Upload started/complete event data (contains full UploadFile)
|
|
133
|
-
*/
|
|
134
|
-
interface UploadFileEventData {
|
|
135
|
-
[key: string]: unknown;
|
|
136
|
-
flow?: {
|
|
137
|
-
flowId: string;
|
|
138
|
-
nodeId: string;
|
|
139
|
-
jobId: string;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Upload failed event data
|
|
144
|
-
*/
|
|
145
|
-
interface UploadFailedEventData {
|
|
146
|
-
id: string;
|
|
147
|
-
error: string;
|
|
148
|
-
flow?: {
|
|
149
|
-
flowId: string;
|
|
150
|
-
nodeId: string;
|
|
151
|
-
jobId: string;
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Upload validation success event data
|
|
156
|
-
*/
|
|
157
|
-
interface UploadValidationSuccessEventData {
|
|
158
|
-
id: string;
|
|
159
|
-
validationType: "checksum" | "mimetype";
|
|
160
|
-
algorithm?: string;
|
|
161
|
-
flow?: {
|
|
162
|
-
flowId: string;
|
|
163
|
-
nodeId: string;
|
|
164
|
-
jobId: string;
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Upload validation failed event data
|
|
169
|
-
*/
|
|
170
|
-
interface UploadValidationFailedEventData {
|
|
171
|
-
id: string;
|
|
172
|
-
reason: string;
|
|
173
|
-
expected: string;
|
|
174
|
-
actual: string;
|
|
175
|
-
flow?: {
|
|
176
|
-
flowId: string;
|
|
177
|
-
nodeId: string;
|
|
178
|
-
jobId: string;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Upload validation warning event data
|
|
183
|
-
*/
|
|
184
|
-
interface UploadValidationWarningEventData {
|
|
185
|
-
id: string;
|
|
186
|
-
message: string;
|
|
187
|
-
flow?: {
|
|
188
|
-
flowId: string;
|
|
189
|
-
nodeId: string;
|
|
190
|
-
jobId: string;
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Options for handling upload events.
|
|
195
|
-
*
|
|
196
|
-
* All callbacks are optional - only provide handlers for events you care about.
|
|
197
|
-
*/
|
|
198
|
-
interface UseUploadEventsOptions {
|
|
199
|
-
/** Called when an upload starts */
|
|
200
|
-
onUploadStarted?: (data: UploadFileEventData) => void;
|
|
201
|
-
/** Called with upload progress updates */
|
|
202
|
-
onUploadProgress?: (data: UploadProgressEventData) => void;
|
|
203
|
-
/** Called when an upload completes successfully */
|
|
204
|
-
onUploadComplete?: (data: UploadFileEventData) => void;
|
|
205
|
-
/** Called when an upload fails */
|
|
206
|
-
onUploadFailed?: (data: UploadFailedEventData) => void;
|
|
207
|
-
/** Called when upload validation succeeds */
|
|
208
|
-
onUploadValidationSuccess?: (data: UploadValidationSuccessEventData) => void;
|
|
209
|
-
/** Called when upload validation fails */
|
|
210
|
-
onUploadValidationFailed?: (data: UploadValidationFailedEventData) => void;
|
|
211
|
-
/** Called when upload validation produces a warning */
|
|
212
|
-
onUploadValidationWarning?: (data: UploadValidationWarningEventData) => void;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Structured hook for handling upload events with type-safe callbacks.
|
|
216
|
-
*
|
|
217
|
-
* This hook provides a clean API for listening to specific upload events without
|
|
218
|
-
* needing to manually filter events or use type guards.
|
|
219
|
-
*
|
|
220
|
-
* Must be used within UploadistaProvider.
|
|
221
|
-
*
|
|
222
|
-
* @param options - Object with optional callbacks for each upload event type
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```tsx
|
|
226
|
-
* import { useUploadEvents } from '@uploadista/react';
|
|
227
|
-
*
|
|
228
|
-
* function UploadMonitor() {
|
|
229
|
-
* useUploadEvents({
|
|
230
|
-
* onUploadStarted: (data) => {
|
|
231
|
-
* console.log('Upload started:', data.id);
|
|
232
|
-
* },
|
|
233
|
-
* onUploadProgress: (data) => {
|
|
234
|
-
* const percent = (data.progress / data.total) * 100;
|
|
235
|
-
* console.log(`Upload progress: ${percent}%`);
|
|
236
|
-
* },
|
|
237
|
-
* onUploadComplete: (data) => {
|
|
238
|
-
* console.log('Upload completed:', data);
|
|
239
|
-
* },
|
|
240
|
-
* onUploadFailed: (data) => {
|
|
241
|
-
* console.error('Upload failed:', data.error);
|
|
242
|
-
* },
|
|
243
|
-
* });
|
|
244
|
-
*
|
|
245
|
-
* return <div>Monitoring uploads...</div>;
|
|
246
|
-
* }
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
declare function useUploadEvents(options: UseUploadEventsOptions): void;
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/hooks/use-flow-execution.d.ts
|
|
252
|
-
/**
|
|
253
|
-
* Input builder function that transforms trigger data into flow inputs.
|
|
254
|
-
*
|
|
255
|
-
* The builder receives the trigger data passed to execute() and returns
|
|
256
|
-
* a FlowInputs object mapping node IDs to their input data.
|
|
257
|
-
*
|
|
258
|
-
* @template TTrigger - The type of data passed to execute()
|
|
259
|
-
* @param trigger - The trigger data (e.g., File, URL string, structured data)
|
|
260
|
-
* @returns Promise resolving to FlowInputs mapping or the mapping directly
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```typescript
|
|
264
|
-
* // File upload builder
|
|
265
|
-
* const fileBuilder: InputBuilder<File> = async (file) => ({
|
|
266
|
-
* "input-node": {
|
|
267
|
-
* operation: "init",
|
|
268
|
-
* storageId: "s3",
|
|
269
|
-
* metadata: { originalName: file.name, size: file.size }
|
|
270
|
-
* }
|
|
271
|
-
* });
|
|
272
|
-
*
|
|
273
|
-
* // URL fetch builder
|
|
274
|
-
* const urlBuilder: InputBuilder<string> = (url) => ({
|
|
275
|
-
* "input-node": {
|
|
276
|
-
* operation: "url",
|
|
277
|
-
* url,
|
|
278
|
-
* metadata: { source: "external" }
|
|
279
|
-
* }
|
|
280
|
-
* });
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
type InputBuilder<TTrigger = unknown> = (trigger: TTrigger) => Promise<FlowInputs> | FlowInputs;
|
|
284
|
-
/**
|
|
285
|
-
* Options for the useFlowExecution hook.
|
|
286
|
-
*
|
|
287
|
-
* @template TTrigger - The type of trigger data passed to execute()
|
|
288
|
-
* @template TOutput - The expected output type from the flow
|
|
289
|
-
*
|
|
290
|
-
* @property flowConfig - Flow configuration (flowId, storageId, etc.)
|
|
291
|
-
* @property inputBuilder - Function to build flow inputs from trigger data
|
|
292
|
-
* @property onJobStart - Called when flow job is created
|
|
293
|
-
* @property onProgress - Called during upload progress (if applicable)
|
|
294
|
-
* @property onChunkComplete - Called when upload chunk completes (if applicable)
|
|
295
|
-
* @property onSuccess - Called with typed outputs when flow succeeds
|
|
296
|
-
* @property onFlowComplete - Called with all outputs when flow completes
|
|
297
|
-
* @property onError - Called when execution fails
|
|
298
|
-
* @property onAbort - Called when execution is aborted
|
|
299
|
-
* @property onShouldRetry - Custom retry logic (if applicable)
|
|
300
|
-
*/
|
|
301
|
-
interface UseFlowExecutionOptions<TTrigger = unknown, TOutput = TypedOutput[]> {
|
|
302
|
-
/**
|
|
303
|
-
* Flow configuration
|
|
304
|
-
*/
|
|
305
|
-
flowConfig: FlowUploadOptions["flowConfig"];
|
|
306
|
-
/**
|
|
307
|
-
* Function to build flow inputs from trigger data.
|
|
308
|
-
* Can be async to perform validation, API calls, etc.
|
|
309
|
-
*/
|
|
310
|
-
inputBuilder: InputBuilder<TTrigger>;
|
|
311
|
-
/**
|
|
312
|
-
* Called when the flow job starts
|
|
313
|
-
*/
|
|
314
|
-
onJobStart?: (jobId: string) => void;
|
|
315
|
-
/**
|
|
316
|
-
* Called during upload progress (for file uploads)
|
|
317
|
-
*/
|
|
318
|
-
onProgress?: (uploadId: string, bytesUploaded: number, totalBytes: number | null) => void;
|
|
319
|
-
/**
|
|
320
|
-
* Called when an upload chunk completes (for file uploads)
|
|
321
|
-
*/
|
|
322
|
-
onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
|
|
323
|
-
/**
|
|
324
|
-
* Called when flow execution succeeds with final outputs
|
|
325
|
-
*/
|
|
326
|
-
onSuccess?: (outputs: TOutput) => void;
|
|
327
|
-
/**
|
|
328
|
-
* Called when flow completes (alternative to onSuccess)
|
|
329
|
-
*/
|
|
330
|
-
onFlowComplete?: (outputs: TypedOutput[]) => void;
|
|
331
|
-
/**
|
|
332
|
-
* Called when execution fails
|
|
333
|
-
*/
|
|
334
|
-
onError?: (error: Error) => void;
|
|
335
|
-
/**
|
|
336
|
-
* Called when execution is aborted
|
|
337
|
-
*/
|
|
338
|
-
onAbort?: () => void;
|
|
339
|
-
/**
|
|
340
|
-
* Custom retry logic (for file uploads)
|
|
341
|
-
*/
|
|
342
|
-
onShouldRetry?: (error: Error, retryAttempt: number) => boolean;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Return value from useFlowExecution hook.
|
|
346
|
-
*
|
|
347
|
-
* @template TTrigger - The type of trigger data passed to execute()
|
|
348
|
-
*
|
|
349
|
-
* @property state - Current execution state with progress and outputs
|
|
350
|
-
* @property execute - Function to trigger flow execution
|
|
351
|
-
* @property abort - Cancel the current execution
|
|
352
|
-
* @property pause - Pause the current execution (for file uploads)
|
|
353
|
-
* @property reset - Reset state to idle
|
|
354
|
-
* @property isExecuting - True when execution is active
|
|
355
|
-
* @property isUploadingFile - True during file upload phase
|
|
356
|
-
* @property isProcessing - True during flow processing phase
|
|
357
|
-
*/
|
|
358
|
-
interface UseFlowExecutionReturn<TTrigger = unknown> {
|
|
359
|
-
/**
|
|
360
|
-
* Current execution state
|
|
361
|
-
*/
|
|
362
|
-
state: FlowUploadState;
|
|
363
|
-
/**
|
|
364
|
-
* Execute the flow with trigger data
|
|
365
|
-
*/
|
|
366
|
-
execute: (trigger: TTrigger) => Promise<void>;
|
|
367
|
-
/**
|
|
368
|
-
* Abort the current execution
|
|
369
|
-
*/
|
|
370
|
-
abort: () => void;
|
|
371
|
-
/**
|
|
372
|
-
* Pause the current execution (if supported by input type)
|
|
373
|
-
*/
|
|
374
|
-
pause: () => void;
|
|
375
|
-
/**
|
|
376
|
-
* Reset the execution state
|
|
377
|
-
*/
|
|
378
|
-
reset: () => void;
|
|
379
|
-
/**
|
|
380
|
-
* Whether execution is active (uploading OR processing)
|
|
381
|
-
*/
|
|
382
|
-
isExecuting: boolean;
|
|
383
|
-
/**
|
|
384
|
-
* Whether file upload is in progress
|
|
385
|
-
*/
|
|
386
|
-
isUploadingFile: boolean;
|
|
387
|
-
/**
|
|
388
|
-
* Whether flow processing is in progress
|
|
389
|
-
*/
|
|
390
|
-
isProcessing: boolean;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Generic React hook for flexible flow execution.
|
|
394
|
-
*
|
|
395
|
-
* Provides a flexible interface for executing flows with arbitrary input types
|
|
396
|
-
* through an inputBuilder pattern. The builder transforms trigger data into
|
|
397
|
-
* flow inputs, enabling support for files, URLs, structured data, and more.
|
|
398
|
-
*
|
|
399
|
-
* Must be used within FlowManagerProvider (which must be within UploadistaProvider).
|
|
400
|
-
*
|
|
401
|
-
* @template TTrigger - The type of trigger data passed to execute()
|
|
402
|
-
* @template TOutput - The expected output type from the flow
|
|
403
|
-
*
|
|
404
|
-
* @param options - Flow execution configuration with inputBuilder
|
|
405
|
-
* @returns Execution state and control methods
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```tsx
|
|
409
|
-
* // URL-based image processing
|
|
410
|
-
* const urlExecution = useFlowExecution<string>({
|
|
411
|
-
* flowConfig: { flowId: "optimize", storageId: "s3" },
|
|
412
|
-
* inputBuilder: async (url) => {
|
|
413
|
-
* const { inputNodes } = await client.findInputNode("optimize");
|
|
414
|
-
* return {
|
|
415
|
-
* [inputNodes[0].id]: {
|
|
416
|
-
* operation: "url",
|
|
417
|
-
* url,
|
|
418
|
-
* metadata: { source: "external" }
|
|
419
|
-
* }
|
|
420
|
-
* };
|
|
421
|
-
* },
|
|
422
|
-
* onSuccess: (outputs) => console.log("Processed:", outputs)
|
|
423
|
-
* });
|
|
424
|
-
*
|
|
425
|
-
* // Execute with URL
|
|
426
|
-
* await urlExecution.execute("https://example.com/image.jpg");
|
|
427
|
-
*
|
|
428
|
-
* // File upload (traditional pattern)
|
|
429
|
-
* const fileExecution = useFlowExecution<File>({
|
|
430
|
-
* flowConfig: { flowId: "optimize", storageId: "s3" },
|
|
431
|
-
* inputBuilder: async (file) => {
|
|
432
|
-
* const { inputNodes } = await client.findInputNode("optimize");
|
|
433
|
-
* return {
|
|
434
|
-
* [inputNodes[0].id]: {
|
|
435
|
-
* operation: "init",
|
|
436
|
-
* storageId: "s3",
|
|
437
|
-
* metadata: {
|
|
438
|
-
* originalName: file.name,
|
|
439
|
-
* mimeType: file.type,
|
|
440
|
-
* size: file.size
|
|
441
|
-
* }
|
|
442
|
-
* }
|
|
443
|
-
* };
|
|
444
|
-
* }
|
|
445
|
-
* });
|
|
446
|
-
*
|
|
447
|
-
* // Execute with file
|
|
448
|
-
* await fileExecution.execute(myFile);
|
|
449
|
-
* ```
|
|
450
|
-
*/
|
|
451
|
-
declare function useFlowExecution<TTrigger = unknown, TOutput = TypedOutput[]>(options: UseFlowExecutionOptions<TTrigger, TOutput>): UseFlowExecutionReturn<TTrigger>;
|
|
452
|
-
//#endregion
|
|
453
87
|
//#region src/hooks/use-multi-flow-upload.d.ts
|
|
454
88
|
/**
|
|
455
89
|
* Return value from the useMultiFlowUpload hook with batch upload control methods.
|
|
@@ -625,6 +259,140 @@ interface UseMultiFlowUploadReturn {
|
|
|
625
259
|
*/
|
|
626
260
|
declare function useMultiFlowUpload(options: MultiFlowUploadOptions<BrowserUploadInput>): UseMultiFlowUploadReturn;
|
|
627
261
|
//#endregion
|
|
262
|
+
//#region src/hooks/use-upload-events.d.ts
|
|
263
|
+
/**
|
|
264
|
+
* Upload progress event data
|
|
265
|
+
*/
|
|
266
|
+
interface UploadProgressEventData {
|
|
267
|
+
id: string;
|
|
268
|
+
progress: number;
|
|
269
|
+
total: number;
|
|
270
|
+
flow?: {
|
|
271
|
+
flowId: string;
|
|
272
|
+
nodeId: string;
|
|
273
|
+
jobId: string;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Upload started/complete event data (contains full UploadFile)
|
|
278
|
+
*/
|
|
279
|
+
interface UploadFileEventData {
|
|
280
|
+
[key: string]: unknown;
|
|
281
|
+
flow?: {
|
|
282
|
+
flowId: string;
|
|
283
|
+
nodeId: string;
|
|
284
|
+
jobId: string;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Upload failed event data
|
|
289
|
+
*/
|
|
290
|
+
interface UploadFailedEventData {
|
|
291
|
+
id: string;
|
|
292
|
+
error: string;
|
|
293
|
+
flow?: {
|
|
294
|
+
flowId: string;
|
|
295
|
+
nodeId: string;
|
|
296
|
+
jobId: string;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Upload validation success event data
|
|
301
|
+
*/
|
|
302
|
+
interface UploadValidationSuccessEventData {
|
|
303
|
+
id: string;
|
|
304
|
+
validationType: "checksum" | "mimetype";
|
|
305
|
+
algorithm?: string;
|
|
306
|
+
flow?: {
|
|
307
|
+
flowId: string;
|
|
308
|
+
nodeId: string;
|
|
309
|
+
jobId: string;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Upload validation failed event data
|
|
314
|
+
*/
|
|
315
|
+
interface UploadValidationFailedEventData {
|
|
316
|
+
id: string;
|
|
317
|
+
reason: string;
|
|
318
|
+
expected: string;
|
|
319
|
+
actual: string;
|
|
320
|
+
flow?: {
|
|
321
|
+
flowId: string;
|
|
322
|
+
nodeId: string;
|
|
323
|
+
jobId: string;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Upload validation warning event data
|
|
328
|
+
*/
|
|
329
|
+
interface UploadValidationWarningEventData {
|
|
330
|
+
id: string;
|
|
331
|
+
message: string;
|
|
332
|
+
flow?: {
|
|
333
|
+
flowId: string;
|
|
334
|
+
nodeId: string;
|
|
335
|
+
jobId: string;
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Options for handling upload events.
|
|
340
|
+
*
|
|
341
|
+
* All callbacks are optional - only provide handlers for events you care about.
|
|
342
|
+
*/
|
|
343
|
+
interface UseUploadEventsOptions {
|
|
344
|
+
/** Called when an upload starts */
|
|
345
|
+
onUploadStarted?: (data: UploadFileEventData) => void;
|
|
346
|
+
/** Called with upload progress updates */
|
|
347
|
+
onUploadProgress?: (data: UploadProgressEventData) => void;
|
|
348
|
+
/** Called when an upload completes successfully */
|
|
349
|
+
onUploadComplete?: (data: UploadFileEventData) => void;
|
|
350
|
+
/** Called when an upload fails */
|
|
351
|
+
onUploadFailed?: (data: UploadFailedEventData) => void;
|
|
352
|
+
/** Called when upload validation succeeds */
|
|
353
|
+
onUploadValidationSuccess?: (data: UploadValidationSuccessEventData) => void;
|
|
354
|
+
/** Called when upload validation fails */
|
|
355
|
+
onUploadValidationFailed?: (data: UploadValidationFailedEventData) => void;
|
|
356
|
+
/** Called when upload validation produces a warning */
|
|
357
|
+
onUploadValidationWarning?: (data: UploadValidationWarningEventData) => void;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Structured hook for handling upload events with type-safe callbacks.
|
|
361
|
+
*
|
|
362
|
+
* This hook provides a clean API for listening to specific upload events without
|
|
363
|
+
* needing to manually filter events or use type guards.
|
|
364
|
+
*
|
|
365
|
+
* Must be used within UploadistaProvider.
|
|
366
|
+
*
|
|
367
|
+
* @param options - Object with optional callbacks for each upload event type
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```tsx
|
|
371
|
+
* import { useUploadEvents } from '@uploadista/react';
|
|
372
|
+
*
|
|
373
|
+
* function UploadMonitor() {
|
|
374
|
+
* useUploadEvents({
|
|
375
|
+
* onUploadStarted: (data) => {
|
|
376
|
+
* console.log('Upload started:', data.id);
|
|
377
|
+
* },
|
|
378
|
+
* onUploadProgress: (data) => {
|
|
379
|
+
* const percent = (data.progress / data.total) * 100;
|
|
380
|
+
* console.log(`Upload progress: ${percent}%`);
|
|
381
|
+
* },
|
|
382
|
+
* onUploadComplete: (data) => {
|
|
383
|
+
* console.log('Upload completed:', data);
|
|
384
|
+
* },
|
|
385
|
+
* onUploadFailed: (data) => {
|
|
386
|
+
* console.error('Upload failed:', data.error);
|
|
387
|
+
* },
|
|
388
|
+
* });
|
|
389
|
+
*
|
|
390
|
+
* return <div>Monitoring uploads...</div>;
|
|
391
|
+
* }
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function useUploadEvents(options: UseUploadEventsOptions): void;
|
|
395
|
+
//#endregion
|
|
628
396
|
//#region src/hooks/use-upload-metrics.d.ts
|
|
629
397
|
interface UploadMetrics$1 {
|
|
630
398
|
/**
|
|
@@ -826,5 +594,35 @@ interface UseUploadMetricsReturn {
|
|
|
826
594
|
*/
|
|
827
595
|
declare function useUploadMetrics(options?: UseUploadMetricsOptions): UseUploadMetricsReturn;
|
|
828
596
|
//#endregion
|
|
829
|
-
|
|
830
|
-
|
|
597
|
+
//#region src/hooks/use-uploadista-events.d.ts
|
|
598
|
+
/**
|
|
599
|
+
* Simple hook that subscribes to all Uploadista events (both flow and upload events).
|
|
600
|
+
*
|
|
601
|
+
* This is a low-level hook that provides access to all events. For more structured
|
|
602
|
+
* event handling, consider using `useFlowEvents` or `useUploadEvents` instead.
|
|
603
|
+
*
|
|
604
|
+
* Must be used within UploadistaProvider.
|
|
605
|
+
*
|
|
606
|
+
* @param callback - Function called for every event emitted by the Uploadista client
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```tsx
|
|
610
|
+
* import { useUploadistaEvents, isFlowEvent, isUploadEvent } from '@uploadista/react';
|
|
611
|
+
*
|
|
612
|
+
* function MyComponent() {
|
|
613
|
+
* useUploadistaEvents((event) => {
|
|
614
|
+
* if (isFlowEvent(event)) {
|
|
615
|
+
* console.log('Flow event:', event.eventType);
|
|
616
|
+
* } else if (isUploadEvent(event)) {
|
|
617
|
+
* console.log('Upload event:', event.type);
|
|
618
|
+
* }
|
|
619
|
+
* });
|
|
620
|
+
*
|
|
621
|
+
* return <div>Listening to all events...</div>;
|
|
622
|
+
* }
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
declare function useUploadistaEvents(callback: (event: UploadistaEvent) => void): void;
|
|
626
|
+
//#endregion
|
|
627
|
+
export { UseFlowEventsOptions as _, UseUploadMetricsReturn as a, isUploadEvent as b, UploadFileEventData as c, UploadValidationSuccessEventData as d, UploadValidationWarningEventData as f, useMultiFlowUpload as g, UseMultiFlowUploadReturn as h, UseUploadMetricsOptions as i, UploadProgressEventData as l, useUploadEvents as m, FileUploadMetrics as n, useUploadMetrics as o, UseUploadEventsOptions as p, UploadMetrics$1 as r, UploadFailedEventData as s, useUploadistaEvents as t, UploadValidationFailedEventData as u, useFlowEvents as v, isFlowEvent as y };
|
|
628
|
+
//# sourceMappingURL=use-uploadista-events-CtDXJYrR.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-uploadista-events-CtDXJYrR.d.mts","names":[],"sources":["../src/hooks/event-utils.ts","../src/hooks/use-flow-events.ts","../src/hooks/use-multi-flow-upload.ts","../src/hooks/use-upload-events.ts","../src/hooks/use-upload-metrics.ts","../src/hooks/use-uploadista-events.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOgB,iBAAA,WAAA,CAAmB,KAAA,EAAA,iBAA2B,CAAS,EAAA,KAAA,IAAT,SAAS;AAwBvE;;;iBAAgB,aAAA,QAAqB,6BAA2B;;;;;;;;AAxBhD,UCiBC,oBAAA,CDjBkB;EAwBnB;uBCLO;;qBAEF;EAJJ;EAEM,WAAA,CAAA,EAAA,CAAA,KAAA,EAIC,kBAJD,EAAA,GAAA,IAAA;EAEF;EAEG,SAAA,CAAA,EAAA,CAAA,KAAA,EAEF,gBAFE,EAAA,GAAA,IAAA;EAEF;EAEE,WAAA,CAAA,EAAA,CAAA,KAAA,EAAA,kBAAA,EAAA,GAAA,IAAA;EAEA;EAEC,WAAA,CAAA,EAAA,CAAA,KAAA,EAFD,kBAEC,EAAA,GAAA,IAAA;EAED;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;;;;;;;AJpQH;AAwBA;;;;ACPA;;;;;;;;;;;;;;AAgEA;;;iBIzDgB,mBAAA,mBACI"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.20-beta.
|
|
4
|
+
"version": "0.0.20-beta.3",
|
|
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.1",
|
|
24
24
|
"react-dom": "19.2.1",
|
|
25
|
-
"@uploadista/core": "0.0.20-beta.
|
|
26
|
-
"@uploadista/client-
|
|
27
|
-
"@uploadista/
|
|
25
|
+
"@uploadista/client-core": "0.0.20-beta.3",
|
|
26
|
+
"@uploadista/client-browser": "0.0.20-beta.3",
|
|
27
|
+
"@uploadista/core": "0.0.20-beta.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/react": "19.2.7",
|
|
31
31
|
"@types/react-dom": "19.2.3",
|
|
32
|
-
"tsdown": "0.17.
|
|
32
|
+
"tsdown": "0.17.2",
|
|
33
33
|
"vitest": "4.0.15",
|
|
34
|
-
"@uploadista/typescript-config": "0.0.20-beta.
|
|
34
|
+
"@uploadista/typescript-config": "0.0.20-beta.3"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsdown",
|