@uploadista/react-native-core 0.0.3 → 0.0.4

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.
@@ -0,0 +1,949 @@
1
+ import * as react0 from "react";
2
+ import { ReactNode } from "react";
3
+ import { UploadFile } from "@uploadista/core/types";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+ import * as _uploadista_client_core0 from "@uploadista/client-core";
6
+ import { Base64Service, ConnectionMetrics, ConnectionPoolConfig, ConnectionPoolConfig as ConnectionPoolConfig$1, DetailedConnectionMetrics, FileReaderService, HttpClient, IdGenerationService, ServiceContainer, ServiceContainer as ServiceContainer$1, StorageService, UploadistaClientOptions, UploadistaEvent } from "@uploadista/client-core";
7
+ import * as _uploadista_core0 from "@uploadista/core";
8
+
9
+ //#region src/types/types.d.ts
10
+ /**
11
+ * Core types for React Native Uploadista client
12
+ */
13
+ /**
14
+ * Options for file picker operations
15
+ */
16
+ interface PickerOptions {
17
+ /** Allowed file types/MIME types */
18
+ allowedTypes?: string[];
19
+ /** Allow multiple selection */
20
+ allowMultiple?: boolean;
21
+ /** Maximum file size in bytes */
22
+ maxSize?: number;
23
+ }
24
+ /**
25
+ * Options for camera operations
26
+ */
27
+ interface CameraOptions {
28
+ /** Camera to use: 'front' or 'back' */
29
+ cameraType?: "front" | "back";
30
+ /** Image quality (0-1) */
31
+ quality?: number;
32
+ /** Maximum width for captured image */
33
+ maxWidth?: number;
34
+ /** Maximum height for captured image */
35
+ maxHeight?: number;
36
+ }
37
+ /**
38
+ * Result from a file pick operation
39
+ */
40
+ interface FilePickResult {
41
+ /** URI to the file (platform-specific format) */
42
+ uri: string;
43
+ /** File name with extension */
44
+ name: string;
45
+ /** File size in bytes */
46
+ size: number;
47
+ /** MIME type of the file (if available) */
48
+ mimeType?: string;
49
+ /** Local file path (if available) */
50
+ localPath?: string;
51
+ }
52
+ /**
53
+ * Information about a file
54
+ */
55
+ interface FileInfo {
56
+ /** URI to the file */
57
+ uri: string;
58
+ /** File name */
59
+ name: string;
60
+ /** File size in bytes */
61
+ size: number;
62
+ /** MIME type (if available) */
63
+ mimeType?: string;
64
+ /** Last modified timestamp */
65
+ modificationTime?: number;
66
+ }
67
+ /**
68
+ * Interface for file system abstraction layer
69
+ * Provides pluggable access to file system APIs across different RN environments
70
+ */
71
+ interface FileSystemProvider {
72
+ /**
73
+ * Opens a document picker for selecting files
74
+ * @param options - Configuration for the picker
75
+ * @returns Promise resolving to picked file information
76
+ */
77
+ pickDocument(options?: PickerOptions): Promise<FilePickResult>;
78
+ /**
79
+ * Opens an image picker for selecting images from gallery
80
+ * @param options - Configuration for the picker
81
+ * @returns Promise resolving to picked image information
82
+ */
83
+ pickImage(options?: PickerOptions): Promise<FilePickResult>;
84
+ /**
85
+ * Opens a video picker for selecting videos from gallery
86
+ * @param options - Configuration for the picker
87
+ * @returns Promise resolving to picked video information
88
+ */
89
+ pickVideo(options?: PickerOptions): Promise<FilePickResult>;
90
+ /**
91
+ * Captures a photo using the device camera
92
+ * @param options - Configuration for camera
93
+ * @returns Promise resolving to captured photo information
94
+ */
95
+ pickCamera(options?: CameraOptions): Promise<FilePickResult>;
96
+ /**
97
+ * Gets a URI for a document that can be read
98
+ * @param filePath - Path to the document
99
+ * @returns Promise resolving to accessible URI
100
+ */
101
+ getDocumentUri(filePath: string): Promise<string>;
102
+ /**
103
+ * Reads file contents as ArrayBuffer
104
+ * @param uri - URI to read from
105
+ * @returns Promise resolving to file contents as ArrayBuffer
106
+ */
107
+ readFile(uri: string): Promise<ArrayBuffer>;
108
+ /**
109
+ * Gets information about a file
110
+ * @param uri - URI of the file
111
+ * @returns Promise resolving to file information
112
+ */
113
+ getFileInfo(uri: string): Promise<FileInfo>;
114
+ }
115
+ /**
116
+ * Configuration for file system provider
117
+ */
118
+ interface FileSystemProviderConfig {
119
+ /** Type of provider: 'expo' or 'native' */
120
+ type?: "expo" | "native";
121
+ /** Custom provider instance */
122
+ provider?: FileSystemProvider;
123
+ }
124
+ /**
125
+ * Upload state
126
+ */
127
+ type UploadState$1 = "idle" | "pending" | "uploading" | "success" | "error" | "cancelled";
128
+ /**
129
+ * Upload progress information
130
+ */
131
+ interface UploadProgress$1 {
132
+ /** Current state of upload */
133
+ state: UploadState$1;
134
+ /** Progress percentage (0-100) */
135
+ progress: number;
136
+ /** Bytes uploaded */
137
+ uploadedBytes: number;
138
+ /** Total bytes to upload */
139
+ totalBytes: number;
140
+ /** Upload speed in bytes per second */
141
+ uploadSpeed?: number;
142
+ /** Estimated time remaining in milliseconds */
143
+ timeRemaining?: number;
144
+ /** Error message if state is 'error' */
145
+ error?: Error;
146
+ }
147
+ /**
148
+ * Multi-file upload item
149
+ */
150
+ interface UploadItem {
151
+ /** Unique identifier for this upload */
152
+ id: string;
153
+ /** File information */
154
+ file: FilePickResult;
155
+ /** Upload progress */
156
+ progress: UploadProgress$1;
157
+ /** Result from server if successful */
158
+ result?: unknown;
159
+ }
160
+ /**
161
+ * Options for multi-upload hook
162
+ */
163
+ interface UseMultiUploadOptions {
164
+ /** Max concurrent uploads */
165
+ maxConcurrent?: number;
166
+ /** Additional form data for all uploads */
167
+ metadata?: Record<string, string>;
168
+ /** Called when a file upload succeeds */
169
+ onSuccess?: (result: unknown) => void;
170
+ /** Called when a file upload fails */
171
+ onError?: (error: Error) => void;
172
+ }
173
+ /**
174
+ * Options for flow upload hook
175
+ */
176
+ interface UseFlowUploadOptions {
177
+ /** Flow ID to execute */
178
+ flowId: string;
179
+ /** Storage ID for the upload */
180
+ storageId: string;
181
+ /** Output node ID for the flow */
182
+ outputNodeId?: string;
183
+ /** Metadata to pass to flow */
184
+ metadata?: Record<string, unknown>;
185
+ /** Called when upload succeeds */
186
+ onSuccess?: (result: unknown) => void;
187
+ /** Called when upload fails */
188
+ onError?: (error: Error) => void;
189
+ /** Called when upload progress updates */
190
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
191
+ /** Called when a chunk completes */
192
+ onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
193
+ }
194
+ /**
195
+ * Options for camera upload hook
196
+ */
197
+ interface UseCameraUploadOptions {
198
+ /** Flow ID to use */
199
+ flowId?: string;
200
+ /** Camera options */
201
+ cameraOptions?: CameraOptions;
202
+ /** Additional metadata */
203
+ metadata?: Record<string, string>;
204
+ /** Called when upload succeeds */
205
+ onSuccess?: (result: unknown) => void;
206
+ /** Called when upload fails */
207
+ onError?: (error: Error) => void;
208
+ /** Called when upload progress updates */
209
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
210
+ }
211
+ /**
212
+ * Options for gallery upload hook
213
+ */
214
+ interface UseGalleryUploadOptions {
215
+ /** Flow ID to use */
216
+ flowId?: string;
217
+ /** Allow multiple selection */
218
+ allowMultiple?: boolean;
219
+ /** Media type: 'photo', 'video', or 'mixed' */
220
+ mediaType?: "photo" | "video" | "mixed";
221
+ /** Additional metadata */
222
+ metadata?: Record<string, string>;
223
+ /** Called when upload succeeds */
224
+ onSuccess?: (result: unknown) => void;
225
+ /** Called when upload fails */
226
+ onError?: (error: Error) => void;
227
+ /** Called when upload progress updates */
228
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
229
+ }
230
+ /**
231
+ * Options for file upload hook
232
+ */
233
+ interface UseFileUploadOptions {
234
+ /** Flow ID to use */
235
+ flowId?: string;
236
+ /** Allowed file types */
237
+ allowedTypes?: string[];
238
+ /** Additional metadata */
239
+ metadata?: Record<string, string>;
240
+ /** Called when upload succeeds */
241
+ onSuccess?: (result: unknown) => void;
242
+ /** Called when upload fails */
243
+ onError?: (error: Error) => void;
244
+ /** Called when upload progress updates */
245
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
246
+ }
247
+ /**
248
+ * Metrics for upload performance
249
+ */
250
+ interface UploadMetrics {
251
+ /** Total bytes uploaded */
252
+ totalBytes: number;
253
+ /** Total upload duration in milliseconds */
254
+ durationMs: number;
255
+ /** Average upload speed in bytes/second */
256
+ avgSpeed: number;
257
+ /** Peak upload speed in bytes/second */
258
+ peakSpeed: number;
259
+ /** Number of retries */
260
+ retries: number;
261
+ }
262
+ //#endregion
263
+ //#region src/types/upload-input.d.ts
264
+ type ReactNativeUploadInput = Blob | File | string | {
265
+ uri: string;
266
+ };
267
+ //#endregion
268
+ //#region src/components/CameraUploadButton.d.ts
269
+ interface CameraUploadButtonProps {
270
+ /** Options for camera upload */
271
+ options?: UseCameraUploadOptions;
272
+ /** Button label text */
273
+ label?: string;
274
+ /** Custom button content */
275
+ children?: ReactNode;
276
+ /** Callback when upload completes successfully */
277
+ onSuccess?: (result: unknown) => void;
278
+ /** Callback when upload fails */
279
+ onError?: (error: Error) => void;
280
+ /** Callback when upload is cancelled */
281
+ onCancel?: () => void;
282
+ /** Whether to show progress inline */
283
+ showProgress?: boolean;
284
+ }
285
+ /**
286
+ * Button component for camera capture and upload
287
+ * Triggers camera on press and handles upload with progress display
288
+ */
289
+ declare function CameraUploadButton({
290
+ options,
291
+ label,
292
+ children,
293
+ onSuccess,
294
+ onError,
295
+ onCancel,
296
+ showProgress
297
+ }: CameraUploadButtonProps): react_jsx_runtime0.JSX.Element;
298
+ //#endregion
299
+ //#region src/components/FileUploadButton.d.ts
300
+ interface FileUploadButtonProps {
301
+ /** Options for file upload */
302
+ options?: UseFileUploadOptions;
303
+ /** Button label text */
304
+ label?: string;
305
+ /** Custom button content */
306
+ children?: ReactNode;
307
+ /** Callback when upload completes successfully */
308
+ onSuccess?: (result: unknown) => void;
309
+ /** Callback when upload fails */
310
+ onError?: (error: Error) => void;
311
+ /** Callback when upload is cancelled */
312
+ onCancel?: () => void;
313
+ /** Whether to show progress inline */
314
+ showProgress?: boolean;
315
+ }
316
+ /**
317
+ * Button component for document/file selection and upload
318
+ * Generic file picker with progress display
319
+ */
320
+ declare function FileUploadButton({
321
+ options,
322
+ label,
323
+ children,
324
+ onSuccess,
325
+ onError,
326
+ onCancel,
327
+ showProgress
328
+ }: FileUploadButtonProps): react_jsx_runtime0.JSX.Element;
329
+ //#endregion
330
+ //#region src/components/GalleryUploadButton.d.ts
331
+ interface GalleryUploadButtonProps {
332
+ /** Options for gallery upload */
333
+ options?: UseGalleryUploadOptions;
334
+ /** Button label text */
335
+ label?: string;
336
+ /** Custom button content */
337
+ children?: ReactNode;
338
+ /** Callback when all uploads complete successfully */
339
+ onSuccess?: (results: unknown[]) => void;
340
+ /** Callback when any upload fails */
341
+ onError?: (error: Error) => void;
342
+ /** Callback when upload is cancelled */
343
+ onCancel?: () => void;
344
+ /** Whether to show individual progress for each file */
345
+ showProgress?: boolean;
346
+ }
347
+ /**
348
+ * Button component for gallery selection and batch upload
349
+ * Triggers gallery picker on press and handles concurrent uploads
350
+ */
351
+ declare function GalleryUploadButton({
352
+ options,
353
+ label,
354
+ children,
355
+ onSuccess,
356
+ onError,
357
+ onCancel,
358
+ showProgress
359
+ }: GalleryUploadButtonProps): react_jsx_runtime0.JSX.Element;
360
+ //#endregion
361
+ //#region src/components/UploadList.d.ts
362
+ interface UploadListProps {
363
+ /** List of upload items to display */
364
+ items: UploadItem[];
365
+ /** Callback when remove item is pressed */
366
+ onRemove?: (id: string) => void;
367
+ /** Callback when item is pressed */
368
+ onItemPress?: (item: UploadItem) => void;
369
+ /** Whether to show remove button */
370
+ showRemoveButton?: boolean;
371
+ }
372
+ /**
373
+ * Component to display a list of upload items with individual progress
374
+ * Shows status indicators and allows removal of items
375
+ */
376
+ declare function UploadList({
377
+ items,
378
+ onRemove,
379
+ onItemPress,
380
+ showRemoveButton
381
+ }: UploadListProps): react_jsx_runtime0.JSX.Element;
382
+ //#endregion
383
+ //#region src/hooks/use-upload.d.ts
384
+ type UploadStatus = "idle" | "uploading" | "success" | "error" | "aborted";
385
+ interface UploadState {
386
+ status: UploadStatus;
387
+ progress: number;
388
+ bytesUploaded: number;
389
+ totalBytes: number | null;
390
+ error: Error | null;
391
+ result: UploadFile | null;
392
+ }
393
+ //#endregion
394
+ //#region src/components/UploadProgress.d.ts
395
+ interface UploadProgressProps {
396
+ /** Upload state information */
397
+ state: UploadState;
398
+ /** Optional custom label */
399
+ label?: string;
400
+ }
401
+ /**
402
+ * Component to display upload progress with percentage, size, and speed
403
+ */
404
+ declare function UploadProgress({
405
+ state,
406
+ label
407
+ }: UploadProgressProps): react_jsx_runtime0.JSX.Element;
408
+ //#endregion
409
+ //#region src/client/create-uploadista-client.d.ts
410
+ interface UploadistaClientOptions$1 extends Omit<UploadistaClientOptions<ReactNativeUploadInput>, "webSocketFactory" | "abortControllerFactory" | "generateId" | "clientStorage" | "logger" | "httpClient" | "fileReader" | "base64"> {
411
+ connectionPooling?: ConnectionPoolConfig$1;
412
+ /**
413
+ * Whether to use AsyncStorage for persistence
414
+ * If false, uses in-memory storage
415
+ * @default true
416
+ */
417
+ useAsyncStorage?: boolean;
418
+ }
419
+ /**
420
+ * Creates an upload client instance with React Native-specific service implementations
421
+ *
422
+ * @param options - Client configuration options
423
+ * @returns Configured UploadistaClient instance
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * import { createUploadistaClient } from '@uploadista/react-native'
428
+ *
429
+ * const client = createUploadistaClient({
430
+ * baseUrl: 'https://api.example.com',
431
+ * storageId: 'my-storage',
432
+ * chunkSize: 1024 * 1024, // 1MB
433
+ * useAsyncStorage: true,
434
+ * });
435
+ * ```
436
+ */
437
+ declare function createUploadistaClient(options: UploadistaClientOptions$1, services: ServiceContainer$1<ReactNativeUploadInput>): {
438
+ upload: (file: ReactNativeUploadInput, {
439
+ uploadLengthDeferred,
440
+ uploadSize,
441
+ onProgress,
442
+ onChunkComplete,
443
+ onSuccess,
444
+ onShouldRetry,
445
+ onError
446
+ }?: _uploadista_client_core0.UploadistaUploadOptions) => Promise<{
447
+ abort: () => void;
448
+ }>;
449
+ uploadWithFlow: (file: ReactNativeUploadInput, flowConfig: _uploadista_client_core0.FlowUploadConfig, {
450
+ onProgress,
451
+ onChunkComplete,
452
+ onSuccess,
453
+ onShouldRetry,
454
+ onJobStart,
455
+ onError
456
+ }?: Omit<_uploadista_client_core0.UploadistaUploadOptions, "uploadLengthDeferred" | "uploadSize" | "metadata">) => Promise<{
457
+ abort: () => void;
458
+ jobId: string;
459
+ }>;
460
+ abort: (params: Parameters<typeof void 0>[0]) => Promise<void>;
461
+ getFlow: (flowId: string) => Promise<{
462
+ status: number;
463
+ flow: _uploadista_core0.FlowData;
464
+ }>;
465
+ runFlow: ({
466
+ flowId,
467
+ inputs,
468
+ storageId: flowStorageId
469
+ }: {
470
+ flowId: string;
471
+ inputs: Record<string, unknown>;
472
+ storageId?: string;
473
+ }) => Promise<{
474
+ status: number;
475
+ job: _uploadista_core0.FlowJob;
476
+ }>;
477
+ continueFlow: ({
478
+ jobId,
479
+ nodeId,
480
+ newData,
481
+ contentType
482
+ }: {
483
+ jobId: string;
484
+ nodeId: string;
485
+ newData: unknown;
486
+ contentType?: "application/json" | "application/octet-stream";
487
+ }) => Promise<_uploadista_core0.FlowJob>;
488
+ getJobStatus: (jobId: string) => Promise<_uploadista_core0.FlowJob>;
489
+ openUploadWebSocket: (uploadId: string) => Promise<_uploadista_client_core0.WebSocketLike>;
490
+ openFlowWebSocket: (jobId: string) => Promise<_uploadista_client_core0.WebSocketLike>;
491
+ openWebSocket: (id: string) => Promise<_uploadista_client_core0.WebSocketLike>;
492
+ closeWebSocket: (id: string) => void;
493
+ closeAllWebSockets: () => void;
494
+ sendPing: (jobId: string) => boolean;
495
+ isWebSocketConnected: (id: string) => boolean;
496
+ getWebSocketConnectionCount: () => number;
497
+ getWebSocketConnectionCountByType: () => {
498
+ upload: number;
499
+ flow: number;
500
+ total: number;
501
+ };
502
+ getNetworkMetrics: () => _uploadista_client_core0.NetworkMetrics;
503
+ getNetworkCondition: () => _uploadista_client_core0.NetworkCondition;
504
+ getChunkingInsights: () => _uploadista_client_core0.PerformanceInsights;
505
+ exportMetrics: () => {
506
+ session: Partial<_uploadista_client_core0.UploadSessionMetrics>;
507
+ chunks: _uploadista_client_core0.ChunkMetrics[];
508
+ insights: _uploadista_client_core0.PerformanceInsights;
509
+ };
510
+ getConnectionMetrics: () => _uploadista_client_core0.ConnectionMetrics;
511
+ getDetailedConnectionMetrics: () => _uploadista_client_core0.DetailedConnectionMetrics;
512
+ warmupConnections: (urls: string[]) => Promise<void>;
513
+ getConnectionPoolingInsights: () => Promise<{
514
+ isOptimized: boolean;
515
+ reuseRate: number;
516
+ recommendedMinChunkSize: number;
517
+ connectionOverhead: number;
518
+ }>;
519
+ resetMetrics: () => Promise<void>;
520
+ validateConfiguration: (options: UploadistaClientOptions<ReactNativeUploadInput>) => {
521
+ valid: boolean;
522
+ errors: string[];
523
+ warnings: string[];
524
+ };
525
+ validateConfigurationAsync: (options: UploadistaClientOptions<ReactNativeUploadInput>) => Promise<{
526
+ valid: boolean;
527
+ errors: string[];
528
+ warnings: string[];
529
+ capabilities: _uploadista_core0.DataStoreCapabilities;
530
+ }>;
531
+ getCapabilities: () => Promise<_uploadista_core0.DataStoreCapabilities>;
532
+ };
533
+ //#endregion
534
+ //#region src/hooks/use-uploadista-client.d.ts
535
+ interface UseUploadistaClientOptions extends UploadistaClientOptions$1 {
536
+ /**
537
+ * Global event handler for all upload and flow events from this client
538
+ */
539
+ onEvent?: UploadistaClientOptions$1["onEvent"];
540
+ }
541
+ interface UseUploadistaClientReturn {
542
+ /**
543
+ * The uploadista client instance
544
+ */
545
+ client: ReturnType<typeof createUploadistaClient>;
546
+ /**
547
+ * Current configuration of the client
548
+ */
549
+ config: UseUploadistaClientOptions;
550
+ }
551
+ //#endregion
552
+ //#region src/hooks/uploadista-context.d.ts
553
+ interface UploadistaContextType extends UseUploadistaClientReturn {
554
+ fileSystemProvider: FileSystemProvider;
555
+ /**
556
+ * Subscribe to events (used internally by hooks)
557
+ * @internal
558
+ */
559
+ subscribeToEvents: (handler: (event: UploadistaEvent) => void) => () => void;
560
+ }
561
+ declare const UploadistaContext: react0.Context<UploadistaContextType | undefined>;
562
+ //#endregion
563
+ //#region src/hooks/use-camera-upload.d.ts
564
+ /**
565
+ * Hook for capturing photos and uploading them
566
+ * Handles camera permissions and capture flow
567
+ * @param options - Camera upload configuration
568
+ * @returns Upload state and camera capture/upload function
569
+ */
570
+ declare function useCameraUpload(options?: UseCameraUploadOptions): {
571
+ captureAndUpload: () => Promise<void>;
572
+ state: UploadState;
573
+ upload: (file: FilePickResult) => Promise<void>;
574
+ abort: () => void;
575
+ reset: () => void;
576
+ retry: () => void;
577
+ isUploading: boolean;
578
+ canRetry: boolean;
579
+ };
580
+ //#endregion
581
+ //#region src/hooks/use-file-upload.d.ts
582
+ /**
583
+ * Hook for selecting and uploading generic files (documents, etc.)
584
+ * @param options - File upload configuration
585
+ * @returns Upload state and file picker/upload function
586
+ */
587
+ declare function useFileUpload(options?: UseFileUploadOptions): {
588
+ pickAndUpload: () => Promise<void>;
589
+ state: UploadState;
590
+ upload: (file: FilePickResult) => Promise<void>;
591
+ abort: () => void;
592
+ reset: () => void;
593
+ retry: () => void;
594
+ isUploading: boolean;
595
+ canRetry: boolean;
596
+ };
597
+ //#endregion
598
+ //#region src/hooks/use-flow-upload.d.ts
599
+ type FlowUploadStatus = "idle" | "uploading" | "processing" | "success" | "error" | "aborted";
600
+ interface FlowUploadState {
601
+ status: FlowUploadStatus;
602
+ progress: number;
603
+ bytesUploaded: number;
604
+ totalBytes: number | null;
605
+ jobId: string | null;
606
+ error: Error | null;
607
+ result: unknown | null;
608
+ }
609
+ /**
610
+ * Hook for uploading files through a flow pipeline with full state management.
611
+ * Provides upload progress tracking, flow execution monitoring, error handling, and abort functionality.
612
+ *
613
+ * Must be used within an UploadistaProvider.
614
+ *
615
+ * @param options - Flow upload configuration
616
+ * @returns Flow upload state and control methods
617
+ *
618
+ * @example
619
+ * ```tsx
620
+ * function MyComponent() {
621
+ * const flowUpload = useFlowUpload({
622
+ * flowId: 'image-processing-flow',
623
+ * storageId: 'my-storage',
624
+ * onSuccess: (result) => console.log('Flow complete:', result),
625
+ * onError: (error) => console.error('Flow failed:', error),
626
+ * onProgress: (progress) => console.log('Progress:', progress + '%'),
627
+ * });
628
+ *
629
+ * const handlePickFile = async () => {
630
+ * const file = await fileSystemProvider.pickDocument();
631
+ * if (file) {
632
+ * await flowUpload.upload(file);
633
+ * }
634
+ * };
635
+ *
636
+ * return (
637
+ * <View>
638
+ * <Button title="Pick File" onPress={handlePickFile} />
639
+ * {flowUpload.isUploading && <Text>Progress: {flowUpload.state.progress}%</Text>}
640
+ * {flowUpload.state.jobId && <Text>Job ID: {flowUpload.state.jobId}</Text>}
641
+ * {flowUpload.state.error && <Text>Error: {flowUpload.state.error.message}</Text>}
642
+ * <Button title="Abort" onPress={flowUpload.abort} disabled={!flowUpload.isActive} />
643
+ * </View>
644
+ * );
645
+ * }
646
+ * ```
647
+ */
648
+ declare function useFlowUpload(options: UseFlowUploadOptions): {
649
+ state: FlowUploadState;
650
+ upload: (file: FilePickResult) => Promise<void>;
651
+ abort: () => void;
652
+ reset: () => void;
653
+ retry: () => void;
654
+ isActive: boolean;
655
+ canRetry: boolean;
656
+ };
657
+ //#endregion
658
+ //#region src/hooks/use-multi-upload.d.ts
659
+ interface UploadItemState {
660
+ id: string;
661
+ file: FilePickResult;
662
+ status: "idle" | "uploading" | "success" | "error" | "aborted";
663
+ progress: number;
664
+ bytesUploaded: number;
665
+ totalBytes: number;
666
+ error: Error | null;
667
+ result: UploadFile | null;
668
+ }
669
+ interface MultiUploadState {
670
+ items: UploadItemState[];
671
+ totalProgress: number;
672
+ totalUploaded: number;
673
+ totalBytes: number;
674
+ activeCount: number;
675
+ completedCount: number;
676
+ failedCount: number;
677
+ }
678
+ /**
679
+ * Hook for managing multiple concurrent file uploads with progress tracking.
680
+ * Each file is uploaded independently using the core upload client.
681
+ *
682
+ * Must be used within an UploadistaProvider.
683
+ *
684
+ * @param options - Multi-upload configuration options
685
+ * @returns Multi-upload state and control methods
686
+ *
687
+ * @example
688
+ * ```tsx
689
+ * function MyComponent() {
690
+ * const multiUpload = useMultiUpload({
691
+ * maxConcurrent: 3,
692
+ * onSuccess: (result) => console.log('File uploaded:', result),
693
+ * onError: (error) => console.error('Upload failed:', error),
694
+ * });
695
+ *
696
+ * const handlePickFiles = async () => {
697
+ * const files = await fileSystemProvider.pickImage({ allowMultiple: true });
698
+ * multiUpload.addFiles(files);
699
+ * await multiUpload.startUploads();
700
+ * };
701
+ *
702
+ * return (
703
+ * <View>
704
+ * <Button title="Pick Files" onPress={handlePickFiles} />
705
+ * <Text>Progress: {multiUpload.state.totalProgress}%</Text>
706
+ * <Text>Active: {multiUpload.state.activeCount}</Text>
707
+ * <Text>Completed: {multiUpload.state.completedCount}/{multiUpload.state.items.length}</Text>
708
+ * </View>
709
+ * );
710
+ * }
711
+ * ```
712
+ */
713
+ declare function useMultiUpload(options?: UseMultiUploadOptions): {
714
+ state: MultiUploadState;
715
+ addFiles: (files: FilePickResult[]) => string[];
716
+ startUploads: () => Promise<void>;
717
+ removeItem: (id: string) => void;
718
+ abortItem: (id: string) => void;
719
+ retryItem: (id: string) => Promise<void>;
720
+ clear: () => void;
721
+ };
722
+ //#endregion
723
+ //#region src/hooks/use-gallery-upload.d.ts
724
+ /**
725
+ * Hook for selecting and uploading photos/videos from gallery
726
+ * Handles batch selection and concurrent uploads
727
+ * @param options - Gallery upload configuration
728
+ * @returns Upload state and gallery selection/upload function
729
+ */
730
+ declare function useGalleryUpload(options?: UseGalleryUploadOptions): {
731
+ selectAndUpload: () => Promise<string[]>;
732
+ state: MultiUploadState;
733
+ addFiles: (files: FilePickResult[]) => string[];
734
+ startUploads: () => Promise<void>;
735
+ removeItem: (id: string) => void;
736
+ abortItem: (id: string) => void;
737
+ retryItem: (id: string) => Promise<void>;
738
+ clear: () => void;
739
+ };
740
+ //#endregion
741
+ //#region src/hooks/use-upload-metrics.d.ts
742
+ /**
743
+ * Hook for tracking upload performance metrics
744
+ * @returns Metrics object and methods to track uploads
745
+ */
746
+ declare function useUploadMetrics(): {
747
+ metrics: UploadMetrics;
748
+ start: () => void;
749
+ update: (uploadedBytes: number, _totalBytes: number, currentRetries?: number) => void;
750
+ end: () => UploadMetrics;
751
+ reset: () => void;
752
+ };
753
+ //#endregion
754
+ //#region src/hooks/use-uploadista-context.d.ts
755
+ /**
756
+ * Hook to access the Uploadista client instance
757
+ * Must be used within an UploadistaProvider
758
+ * @throws Error if used outside of UploadistaProvider
759
+ * @returns The Uploadista client and file system provider
760
+ */
761
+ declare function useUploadistaContext(): UploadistaContextType;
762
+ //#endregion
763
+ //#region src/utils/fileHelpers.d.ts
764
+ /**
765
+ * File utility functions for React Native uploads
766
+ */
767
+ /**
768
+ * Format file size to human readable string
769
+ * @param bytes - Size in bytes
770
+ * @returns Formatted size string (e.g., "1.5 MB")
771
+ */
772
+ declare function formatFileSize(bytes: number): string;
773
+ /**
774
+ * Get MIME type from file name
775
+ * @param fileName - File name with extension
776
+ * @returns MIME type or 'application/octet-stream' as fallback
777
+ */
778
+ declare function getMimeTypeFromFileName(fileName: string): string;
779
+ /**
780
+ * Check if file type is allowed
781
+ * @param fileName - File name to check
782
+ * @param allowedTypes - Array of allowed MIME types (e.g., ['image/jpeg', 'image/png'])
783
+ * @returns True if file type is allowed
784
+ */
785
+ declare function isFileTypeAllowed(fileName: string, allowedTypes: string[]): boolean;
786
+ /**
787
+ * Check if file size is within limits
788
+ * @param fileSize - File size in bytes
789
+ * @param maxSize - Maximum allowed size in bytes (optional)
790
+ * @param minSize - Minimum allowed size in bytes (optional)
791
+ * @returns True if file size is within limits
792
+ */
793
+ declare function isFileSizeValid(fileSize: number, maxSize?: number, minSize?: number): boolean;
794
+ /**
795
+ * Get file extension
796
+ * @param fileName - File name
797
+ * @returns File extension without dot (e.g., 'pdf' for 'document.pdf')
798
+ */
799
+ declare function getFileExtension(fileName: string): string;
800
+ /**
801
+ * Get file name without extension
802
+ * @param fileName - File name
803
+ * @returns File name without extension
804
+ */
805
+ declare function getFileNameWithoutExtension(fileName: string): string;
806
+ /**
807
+ * Check if file is an image
808
+ * @param fileName - File name
809
+ * @returns True if file is an image
810
+ */
811
+ declare function isImageFile(fileName: string): boolean;
812
+ /**
813
+ * Check if file is a video
814
+ * @param fileName - File name
815
+ * @returns True if file is a video
816
+ */
817
+ declare function isVideoFile(fileName: string): boolean;
818
+ /**
819
+ * Check if file is a document
820
+ * @param fileName - File name
821
+ * @returns True if file is a document
822
+ */
823
+ declare function isDocumentFile(fileName: string): boolean;
824
+ //#endregion
825
+ //#region src/utils/permissions.d.ts
826
+ /**
827
+ * Permission utility functions for React Native uploads
828
+ * Handles camera, gallery, and file access permissions
829
+ */
830
+ /**
831
+ * Permission types
832
+ */
833
+ declare enum PermissionType {
834
+ CAMERA = "CAMERA",
835
+ PHOTO_LIBRARY = "PHOTO_LIBRARY",
836
+ WRITE_STORAGE = "WRITE_STORAGE",
837
+ READ_STORAGE = "READ_STORAGE",
838
+ }
839
+ /**
840
+ * Permission status
841
+ */
842
+ declare enum PermissionStatus {
843
+ GRANTED = "granted",
844
+ DENIED = "denied",
845
+ NOT_DETERMINED = "not_determined",
846
+ RESTRICTED = "restricted",
847
+ }
848
+ /**
849
+ * Request camera permission
850
+ * This is primarily used to check if we should attempt camera operations
851
+ * Actual permission requests are handled by the file system providers
852
+ *
853
+ * @returns Promise resolving to true if permission is granted or already granted
854
+ */
855
+ declare function requestCameraPermission(): Promise<boolean>;
856
+ /**
857
+ * Request photo library permission
858
+ * @returns Promise resolving to true if permission is granted
859
+ */
860
+ declare function requestPhotoLibraryPermission(): Promise<boolean>;
861
+ /**
862
+ * Request storage read permission
863
+ * @returns Promise resolving to true if permission is granted
864
+ */
865
+ declare function requestStorageReadPermission(): Promise<boolean>;
866
+ /**
867
+ * Request storage write permission
868
+ * @returns Promise resolving to true if permission is granted
869
+ */
870
+ declare function requestStorageWritePermission(): Promise<boolean>;
871
+ /**
872
+ * Request multiple permissions at once
873
+ * @param permissions - Array of permission types to request
874
+ * @returns Promise resolving to true if all permissions are granted
875
+ */
876
+ declare function requestPermissions(permissions: PermissionType[]): Promise<boolean>;
877
+ /**
878
+ * Check if all required permissions are granted
879
+ * @param permissions - Array of permission types to check
880
+ * @returns Promise resolving to true if all permissions are granted
881
+ */
882
+ declare function hasPermissions(_permissions: PermissionType[]): Promise<boolean>;
883
+ /**
884
+ * Get permission status
885
+ * @param permission - Permission type to check
886
+ * @returns Promise resolving to permission status
887
+ */
888
+ declare function getPermissionStatus(_permission: PermissionType): Promise<PermissionStatus>;
889
+ /**
890
+ * Open app settings to request permissions
891
+ * Guides user to app settings where they can manually enable permissions
892
+ */
893
+ declare function openAppSettings(): void;
894
+ //#endregion
895
+ //#region src/utils/uriHelpers.d.ts
896
+ /**
897
+ * URI utility functions for React Native file handling
898
+ */
899
+ /**
900
+ * Extract file name from URI
901
+ * @param uri - File URI
902
+ * @returns File name extracted from URI
903
+ */
904
+ declare function getFileNameFromUri(uri: string): string;
905
+ /**
906
+ * Convert file path to file URI
907
+ * @param filePath - File path
908
+ * @returns File URI
909
+ */
910
+ declare function pathToUri(filePath: string): string;
911
+ /**
912
+ * Convert file URI to file path
913
+ * @param uri - File URI
914
+ * @returns File path
915
+ */
916
+ declare function uriToPath(uri: string): string;
917
+ /**
918
+ * Get directory from URI
919
+ * @param uri - File URI
920
+ * @returns Directory path
921
+ */
922
+ declare function getDirectoryFromUri(uri: string): string;
923
+ /**
924
+ * Check if URI is a content URI (Android specific)
925
+ * @param uri - URI to check
926
+ * @returns True if URI is a content URI
927
+ */
928
+ declare function isContentUri(uri: string): boolean;
929
+ /**
930
+ * Check if URI is a file URI
931
+ * @param uri - URI to check
932
+ * @returns True if URI is a file URI
933
+ */
934
+ declare function isFileUri(uri: string): boolean;
935
+ /**
936
+ * Normalize URI for cross-platform compatibility
937
+ * @param uri - URI to normalize
938
+ * @returns Normalized URI
939
+ */
940
+ declare function normalizeUri(uri: string): string;
941
+ /**
942
+ * Get MIME type hint from URI
943
+ * @param uri - File URI
944
+ * @returns MIME type hint based on file extension
945
+ */
946
+ declare function getMimeTypeFromUri(uri: string): string;
947
+ //#endregion
948
+ export { type Base64Service, type CameraOptions, CameraUploadButton, type CameraUploadButtonProps, type ConnectionMetrics, type ConnectionPoolConfig, type DetailedConnectionMetrics, type FileInfo, type FilePickResult, type FileReaderService, type FileSystemProvider, type FileSystemProviderConfig, FileUploadButton, type FileUploadButtonProps, type FlowUploadState, type FlowUploadStatus, GalleryUploadButton, type GalleryUploadButtonProps, type HttpClient, type IdGenerationService, type MultiUploadState, PermissionStatus, PermissionType, type PickerOptions, type ReactNativeUploadInput, type ServiceContainer, type StorageService, type UploadItemState, UploadList, type UploadListProps, type UploadMetrics, UploadProgress, type UploadProgressProps, type UploadState, type UploadStatus, UploadistaContext, type UploadistaContextType, type UseCameraUploadOptions, type UseFileUploadOptions, type UseFlowUploadOptions, type UseGalleryUploadOptions, type UseMultiUploadOptions, formatFileSize, getDirectoryFromUri, getFileExtension, getFileNameFromUri, getFileNameWithoutExtension, getMimeTypeFromFileName, getMimeTypeFromUri, getPermissionStatus, hasPermissions, isContentUri, isDocumentFile, isFileSizeValid, isFileTypeAllowed, isFileUri, isImageFile, isVideoFile, normalizeUri, openAppSettings, pathToUri, requestCameraPermission, requestPermissions, requestPhotoLibraryPermission, requestStorageReadPermission, requestStorageWritePermission, uriToPath, useCameraUpload, useFileUpload, useFlowUpload, useGalleryUpload, useMultiUpload, useUploadMetrics, useUploadistaContext };
949
+ //# sourceMappingURL=index.d.ts.map