@uploadista/react-native-core 0.0.3 → 0.0.6

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,969 @@
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<({
461
+ uploadId,
462
+ uploadIdStorageKey,
463
+ retryTimeout,
464
+ shouldTerminate,
465
+ abortController,
466
+ uploadistaApi,
467
+ platformService,
468
+ retryDelays,
469
+ clientStorage
470
+ }: {
471
+ uploadId: string;
472
+ uploadIdStorageKey: string | undefined;
473
+ retryTimeout: _uploadista_client_core0.Timeout | null;
474
+ shouldTerminate: boolean;
475
+ abortController: _uploadista_client_core0.AbortControllerLike;
476
+ uploadistaApi: _uploadista_client_core0.UploadistaApi;
477
+ platformService: _uploadista_client_core0.PlatformService;
478
+ retryDelays?: number[];
479
+ clientStorage: _uploadista_client_core0.ClientStorage;
480
+ }) => Promise<void>>[0]) => Promise<void>;
481
+ getFlow: (flowId: string) => Promise<{
482
+ status: number;
483
+ flow: _uploadista_core0.FlowData;
484
+ }>;
485
+ runFlow: ({
486
+ flowId,
487
+ inputs,
488
+ storageId: flowStorageId
489
+ }: {
490
+ flowId: string;
491
+ inputs: Record<string, unknown>;
492
+ storageId?: string;
493
+ }) => Promise<{
494
+ status: number;
495
+ job: _uploadista_core0.FlowJob;
496
+ }>;
497
+ continueFlow: ({
498
+ jobId,
499
+ nodeId,
500
+ newData,
501
+ contentType
502
+ }: {
503
+ jobId: string;
504
+ nodeId: string;
505
+ newData: unknown;
506
+ contentType?: "application/json" | "application/octet-stream";
507
+ }) => Promise<_uploadista_core0.FlowJob>;
508
+ getJobStatus: (jobId: string) => Promise<_uploadista_core0.FlowJob>;
509
+ openUploadWebSocket: (uploadId: string) => Promise<_uploadista_client_core0.WebSocketLike>;
510
+ openFlowWebSocket: (jobId: string) => Promise<_uploadista_client_core0.WebSocketLike>;
511
+ openWebSocket: (id: string) => Promise<_uploadista_client_core0.WebSocketLike>;
512
+ closeWebSocket: (id: string) => void;
513
+ closeAllWebSockets: () => void;
514
+ sendPing: (jobId: string) => boolean;
515
+ isWebSocketConnected: (id: string) => boolean;
516
+ getWebSocketConnectionCount: () => number;
517
+ getWebSocketConnectionCountByType: () => {
518
+ upload: number;
519
+ flow: number;
520
+ total: number;
521
+ };
522
+ getNetworkMetrics: () => _uploadista_client_core0.NetworkMetrics;
523
+ getNetworkCondition: () => _uploadista_client_core0.NetworkCondition;
524
+ getChunkingInsights: () => _uploadista_client_core0.PerformanceInsights;
525
+ exportMetrics: () => {
526
+ session: Partial<_uploadista_client_core0.UploadSessionMetrics>;
527
+ chunks: _uploadista_client_core0.ChunkMetrics[];
528
+ insights: _uploadista_client_core0.PerformanceInsights;
529
+ };
530
+ getConnectionMetrics: () => _uploadista_client_core0.ConnectionMetrics;
531
+ getDetailedConnectionMetrics: () => _uploadista_client_core0.DetailedConnectionMetrics;
532
+ warmupConnections: (urls: string[]) => Promise<void>;
533
+ getConnectionPoolingInsights: () => Promise<{
534
+ isOptimized: boolean;
535
+ reuseRate: number;
536
+ recommendedMinChunkSize: number;
537
+ connectionOverhead: number;
538
+ }>;
539
+ resetMetrics: () => Promise<void>;
540
+ validateConfiguration: (options: UploadistaClientOptions<ReactNativeUploadInput>) => {
541
+ valid: boolean;
542
+ errors: string[];
543
+ warnings: string[];
544
+ };
545
+ validateConfigurationAsync: (options: UploadistaClientOptions<ReactNativeUploadInput>) => Promise<{
546
+ valid: boolean;
547
+ errors: string[];
548
+ warnings: string[];
549
+ capabilities: _uploadista_core0.DataStoreCapabilities;
550
+ }>;
551
+ getCapabilities: () => Promise<_uploadista_core0.DataStoreCapabilities>;
552
+ };
553
+ //#endregion
554
+ //#region src/hooks/use-uploadista-client.d.ts
555
+ interface UseUploadistaClientOptions extends UploadistaClientOptions$1 {
556
+ /**
557
+ * Global event handler for all upload and flow events from this client
558
+ */
559
+ onEvent?: UploadistaClientOptions$1["onEvent"];
560
+ }
561
+ interface UseUploadistaClientReturn {
562
+ /**
563
+ * The uploadista client instance
564
+ */
565
+ client: ReturnType<typeof createUploadistaClient>;
566
+ /**
567
+ * Current configuration of the client
568
+ */
569
+ config: UseUploadistaClientOptions;
570
+ }
571
+ //#endregion
572
+ //#region src/hooks/uploadista-context.d.ts
573
+ interface UploadistaContextType extends UseUploadistaClientReturn {
574
+ fileSystemProvider: FileSystemProvider;
575
+ /**
576
+ * Subscribe to events (used internally by hooks)
577
+ * @internal
578
+ */
579
+ subscribeToEvents: (handler: (event: UploadistaEvent) => void) => () => void;
580
+ }
581
+ declare const UploadistaContext: react0.Context<UploadistaContextType | undefined>;
582
+ //#endregion
583
+ //#region src/hooks/use-camera-upload.d.ts
584
+ /**
585
+ * Hook for capturing photos and uploading them
586
+ * Handles camera permissions and capture flow
587
+ * @param options - Camera upload configuration
588
+ * @returns Upload state and camera capture/upload function
589
+ */
590
+ declare function useCameraUpload(options?: UseCameraUploadOptions): {
591
+ captureAndUpload: () => Promise<void>;
592
+ state: UploadState;
593
+ upload: (file: FilePickResult) => Promise<void>;
594
+ abort: () => void;
595
+ reset: () => void;
596
+ retry: () => void;
597
+ isUploading: boolean;
598
+ canRetry: boolean;
599
+ };
600
+ //#endregion
601
+ //#region src/hooks/use-file-upload.d.ts
602
+ /**
603
+ * Hook for selecting and uploading generic files (documents, etc.)
604
+ * @param options - File upload configuration
605
+ * @returns Upload state and file picker/upload function
606
+ */
607
+ declare function useFileUpload(options?: UseFileUploadOptions): {
608
+ pickAndUpload: () => Promise<void>;
609
+ state: UploadState;
610
+ upload: (file: FilePickResult) => Promise<void>;
611
+ abort: () => void;
612
+ reset: () => void;
613
+ retry: () => void;
614
+ isUploading: boolean;
615
+ canRetry: boolean;
616
+ };
617
+ //#endregion
618
+ //#region src/hooks/use-flow-upload.d.ts
619
+ type FlowUploadStatus = "idle" | "uploading" | "processing" | "success" | "error" | "aborted";
620
+ interface FlowUploadState {
621
+ status: FlowUploadStatus;
622
+ progress: number;
623
+ bytesUploaded: number;
624
+ totalBytes: number | null;
625
+ jobId: string | null;
626
+ error: Error | null;
627
+ result: unknown | null;
628
+ }
629
+ /**
630
+ * Hook for uploading files through a flow pipeline with full state management.
631
+ * Provides upload progress tracking, flow execution monitoring, error handling, and abort functionality.
632
+ *
633
+ * Must be used within an UploadistaProvider.
634
+ *
635
+ * @param options - Flow upload configuration
636
+ * @returns Flow upload state and control methods
637
+ *
638
+ * @example
639
+ * ```tsx
640
+ * function MyComponent() {
641
+ * const flowUpload = useFlowUpload({
642
+ * flowId: 'image-processing-flow',
643
+ * storageId: 'my-storage',
644
+ * onSuccess: (result) => console.log('Flow complete:', result),
645
+ * onError: (error) => console.error('Flow failed:', error),
646
+ * onProgress: (progress) => console.log('Progress:', progress + '%'),
647
+ * });
648
+ *
649
+ * const handlePickFile = async () => {
650
+ * const file = await fileSystemProvider.pickDocument();
651
+ * if (file) {
652
+ * await flowUpload.upload(file);
653
+ * }
654
+ * };
655
+ *
656
+ * return (
657
+ * <View>
658
+ * <Button title="Pick File" onPress={handlePickFile} />
659
+ * {flowUpload.isUploading && <Text>Progress: {flowUpload.state.progress}%</Text>}
660
+ * {flowUpload.state.jobId && <Text>Job ID: {flowUpload.state.jobId}</Text>}
661
+ * {flowUpload.state.error && <Text>Error: {flowUpload.state.error.message}</Text>}
662
+ * <Button title="Abort" onPress={flowUpload.abort} disabled={!flowUpload.isActive} />
663
+ * </View>
664
+ * );
665
+ * }
666
+ * ```
667
+ */
668
+ declare function useFlowUpload(options: UseFlowUploadOptions): {
669
+ state: FlowUploadState;
670
+ upload: (file: FilePickResult) => Promise<void>;
671
+ abort: () => void;
672
+ reset: () => void;
673
+ retry: () => void;
674
+ isActive: boolean;
675
+ canRetry: boolean;
676
+ };
677
+ //#endregion
678
+ //#region src/hooks/use-multi-upload.d.ts
679
+ interface UploadItemState {
680
+ id: string;
681
+ file: FilePickResult;
682
+ status: "idle" | "uploading" | "success" | "error" | "aborted";
683
+ progress: number;
684
+ bytesUploaded: number;
685
+ totalBytes: number;
686
+ error: Error | null;
687
+ result: UploadFile | null;
688
+ }
689
+ interface MultiUploadState {
690
+ items: UploadItemState[];
691
+ totalProgress: number;
692
+ totalUploaded: number;
693
+ totalBytes: number;
694
+ activeCount: number;
695
+ completedCount: number;
696
+ failedCount: number;
697
+ }
698
+ /**
699
+ * Hook for managing multiple concurrent file uploads with progress tracking.
700
+ * Each file is uploaded independently using the core upload client.
701
+ *
702
+ * Must be used within an UploadistaProvider.
703
+ *
704
+ * @param options - Multi-upload configuration options
705
+ * @returns Multi-upload state and control methods
706
+ *
707
+ * @example
708
+ * ```tsx
709
+ * function MyComponent() {
710
+ * const multiUpload = useMultiUpload({
711
+ * maxConcurrent: 3,
712
+ * onSuccess: (result) => console.log('File uploaded:', result),
713
+ * onError: (error) => console.error('Upload failed:', error),
714
+ * });
715
+ *
716
+ * const handlePickFiles = async () => {
717
+ * const files = await fileSystemProvider.pickImage({ allowMultiple: true });
718
+ * multiUpload.addFiles(files);
719
+ * await multiUpload.startUploads();
720
+ * };
721
+ *
722
+ * return (
723
+ * <View>
724
+ * <Button title="Pick Files" onPress={handlePickFiles} />
725
+ * <Text>Progress: {multiUpload.state.totalProgress}%</Text>
726
+ * <Text>Active: {multiUpload.state.activeCount}</Text>
727
+ * <Text>Completed: {multiUpload.state.completedCount}/{multiUpload.state.items.length}</Text>
728
+ * </View>
729
+ * );
730
+ * }
731
+ * ```
732
+ */
733
+ declare function useMultiUpload(options?: UseMultiUploadOptions): {
734
+ state: MultiUploadState;
735
+ addFiles: (files: FilePickResult[]) => string[];
736
+ startUploads: () => Promise<void>;
737
+ removeItem: (id: string) => void;
738
+ abortItem: (id: string) => void;
739
+ retryItem: (id: string) => Promise<void>;
740
+ clear: () => void;
741
+ };
742
+ //#endregion
743
+ //#region src/hooks/use-gallery-upload.d.ts
744
+ /**
745
+ * Hook for selecting and uploading photos/videos from gallery
746
+ * Handles batch selection and concurrent uploads
747
+ * @param options - Gallery upload configuration
748
+ * @returns Upload state and gallery selection/upload function
749
+ */
750
+ declare function useGalleryUpload(options?: UseGalleryUploadOptions): {
751
+ selectAndUpload: () => Promise<string[]>;
752
+ state: MultiUploadState;
753
+ addFiles: (files: FilePickResult[]) => string[];
754
+ startUploads: () => Promise<void>;
755
+ removeItem: (id: string) => void;
756
+ abortItem: (id: string) => void;
757
+ retryItem: (id: string) => Promise<void>;
758
+ clear: () => void;
759
+ };
760
+ //#endregion
761
+ //#region src/hooks/use-upload-metrics.d.ts
762
+ /**
763
+ * Hook for tracking upload performance metrics
764
+ * @returns Metrics object and methods to track uploads
765
+ */
766
+ declare function useUploadMetrics(): {
767
+ metrics: UploadMetrics;
768
+ start: () => void;
769
+ update: (uploadedBytes: number, _totalBytes: number, currentRetries?: number) => void;
770
+ end: () => UploadMetrics;
771
+ reset: () => void;
772
+ };
773
+ //#endregion
774
+ //#region src/hooks/use-uploadista-context.d.ts
775
+ /**
776
+ * Hook to access the Uploadista client instance
777
+ * Must be used within an UploadistaProvider
778
+ * @throws Error if used outside of UploadistaProvider
779
+ * @returns The Uploadista client and file system provider
780
+ */
781
+ declare function useUploadistaContext(): UploadistaContextType;
782
+ //#endregion
783
+ //#region src/utils/fileHelpers.d.ts
784
+ /**
785
+ * File utility functions for React Native uploads
786
+ */
787
+ /**
788
+ * Format file size to human readable string
789
+ * @param bytes - Size in bytes
790
+ * @returns Formatted size string (e.g., "1.5 MB")
791
+ */
792
+ declare function formatFileSize(bytes: number): string;
793
+ /**
794
+ * Get MIME type from file name
795
+ * @param fileName - File name with extension
796
+ * @returns MIME type or 'application/octet-stream' as fallback
797
+ */
798
+ declare function getMimeTypeFromFileName(fileName: string): string;
799
+ /**
800
+ * Check if file type is allowed
801
+ * @param fileName - File name to check
802
+ * @param allowedTypes - Array of allowed MIME types (e.g., ['image/jpeg', 'image/png'])
803
+ * @returns True if file type is allowed
804
+ */
805
+ declare function isFileTypeAllowed(fileName: string, allowedTypes: string[]): boolean;
806
+ /**
807
+ * Check if file size is within limits
808
+ * @param fileSize - File size in bytes
809
+ * @param maxSize - Maximum allowed size in bytes (optional)
810
+ * @param minSize - Minimum allowed size in bytes (optional)
811
+ * @returns True if file size is within limits
812
+ */
813
+ declare function isFileSizeValid(fileSize: number, maxSize?: number, minSize?: number): boolean;
814
+ /**
815
+ * Get file extension
816
+ * @param fileName - File name
817
+ * @returns File extension without dot (e.g., 'pdf' for 'document.pdf')
818
+ */
819
+ declare function getFileExtension(fileName: string): string;
820
+ /**
821
+ * Get file name without extension
822
+ * @param fileName - File name
823
+ * @returns File name without extension
824
+ */
825
+ declare function getFileNameWithoutExtension(fileName: string): string;
826
+ /**
827
+ * Check if file is an image
828
+ * @param fileName - File name
829
+ * @returns True if file is an image
830
+ */
831
+ declare function isImageFile(fileName: string): boolean;
832
+ /**
833
+ * Check if file is a video
834
+ * @param fileName - File name
835
+ * @returns True if file is a video
836
+ */
837
+ declare function isVideoFile(fileName: string): boolean;
838
+ /**
839
+ * Check if file is a document
840
+ * @param fileName - File name
841
+ * @returns True if file is a document
842
+ */
843
+ declare function isDocumentFile(fileName: string): boolean;
844
+ //#endregion
845
+ //#region src/utils/permissions.d.ts
846
+ /**
847
+ * Permission utility functions for React Native uploads
848
+ * Handles camera, gallery, and file access permissions
849
+ */
850
+ /**
851
+ * Permission types
852
+ */
853
+ declare enum PermissionType {
854
+ CAMERA = "CAMERA",
855
+ PHOTO_LIBRARY = "PHOTO_LIBRARY",
856
+ WRITE_STORAGE = "WRITE_STORAGE",
857
+ READ_STORAGE = "READ_STORAGE",
858
+ }
859
+ /**
860
+ * Permission status
861
+ */
862
+ declare enum PermissionStatus {
863
+ GRANTED = "granted",
864
+ DENIED = "denied",
865
+ NOT_DETERMINED = "not_determined",
866
+ RESTRICTED = "restricted",
867
+ }
868
+ /**
869
+ * Request camera permission
870
+ * This is primarily used to check if we should attempt camera operations
871
+ * Actual permission requests are handled by the file system providers
872
+ *
873
+ * @returns Promise resolving to true if permission is granted or already granted
874
+ */
875
+ declare function requestCameraPermission(): Promise<boolean>;
876
+ /**
877
+ * Request photo library permission
878
+ * @returns Promise resolving to true if permission is granted
879
+ */
880
+ declare function requestPhotoLibraryPermission(): Promise<boolean>;
881
+ /**
882
+ * Request storage read permission
883
+ * @returns Promise resolving to true if permission is granted
884
+ */
885
+ declare function requestStorageReadPermission(): Promise<boolean>;
886
+ /**
887
+ * Request storage write permission
888
+ * @returns Promise resolving to true if permission is granted
889
+ */
890
+ declare function requestStorageWritePermission(): Promise<boolean>;
891
+ /**
892
+ * Request multiple permissions at once
893
+ * @param permissions - Array of permission types to request
894
+ * @returns Promise resolving to true if all permissions are granted
895
+ */
896
+ declare function requestPermissions(permissions: PermissionType[]): Promise<boolean>;
897
+ /**
898
+ * Check if all required permissions are granted
899
+ * @param permissions - Array of permission types to check
900
+ * @returns Promise resolving to true if all permissions are granted
901
+ */
902
+ declare function hasPermissions(_permissions: PermissionType[]): Promise<boolean>;
903
+ /**
904
+ * Get permission status
905
+ * @param permission - Permission type to check
906
+ * @returns Promise resolving to permission status
907
+ */
908
+ declare function getPermissionStatus(_permission: PermissionType): Promise<PermissionStatus>;
909
+ /**
910
+ * Open app settings to request permissions
911
+ * Guides user to app settings where they can manually enable permissions
912
+ */
913
+ declare function openAppSettings(): void;
914
+ //#endregion
915
+ //#region src/utils/uriHelpers.d.ts
916
+ /**
917
+ * URI utility functions for React Native file handling
918
+ */
919
+ /**
920
+ * Extract file name from URI
921
+ * @param uri - File URI
922
+ * @returns File name extracted from URI
923
+ */
924
+ declare function getFileNameFromUri(uri: string): string;
925
+ /**
926
+ * Convert file path to file URI
927
+ * @param filePath - File path
928
+ * @returns File URI
929
+ */
930
+ declare function pathToUri(filePath: string): string;
931
+ /**
932
+ * Convert file URI to file path
933
+ * @param uri - File URI
934
+ * @returns File path
935
+ */
936
+ declare function uriToPath(uri: string): string;
937
+ /**
938
+ * Get directory from URI
939
+ * @param uri - File URI
940
+ * @returns Directory path
941
+ */
942
+ declare function getDirectoryFromUri(uri: string): string;
943
+ /**
944
+ * Check if URI is a content URI (Android specific)
945
+ * @param uri - URI to check
946
+ * @returns True if URI is a content URI
947
+ */
948
+ declare function isContentUri(uri: string): boolean;
949
+ /**
950
+ * Check if URI is a file URI
951
+ * @param uri - URI to check
952
+ * @returns True if URI is a file URI
953
+ */
954
+ declare function isFileUri(uri: string): boolean;
955
+ /**
956
+ * Normalize URI for cross-platform compatibility
957
+ * @param uri - URI to normalize
958
+ * @returns Normalized URI
959
+ */
960
+ declare function normalizeUri(uri: string): string;
961
+ /**
962
+ * Get MIME type hint from URI
963
+ * @param uri - File URI
964
+ * @returns MIME type hint based on file extension
965
+ */
966
+ declare function getMimeTypeFromUri(uri: string): string;
967
+ //#endregion
968
+ 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 };
969
+ //# sourceMappingURL=index.d.ts.map