rn-file-toolkit 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/FileToolkit.podspec +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +522 -0
  4. package/android/build.gradle +61 -0
  5. package/android/src/main/AndroidManifest.xml +13 -0
  6. package/android/src/main/java/com/filetoolkit/FileToolkitModule.kt +1204 -0
  7. package/android/src/main/java/com/filetoolkit/FileToolkitPackage.kt +31 -0
  8. package/android/src/main/res/xml/file_provider_paths.xml +14 -0
  9. package/app.plugin.js +49 -0
  10. package/ios/FileToolkit.h +6 -0
  11. package/ios/FileToolkit.mm +1468 -0
  12. package/lib/commonjs/NativeFileToolkit.js +9 -0
  13. package/lib/commonjs/NativeFileToolkit.js.map +1 -0
  14. package/lib/commonjs/index.js +941 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/module/NativeFileToolkit.js +5 -0
  18. package/lib/module/NativeFileToolkit.js.map +1 -0
  19. package/lib/module/index.js +905 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/package.json +1 -0
  22. package/lib/typescript/commonjs/package.json +1 -0
  23. package/lib/typescript/commonjs/src/NativeFileToolkit.d.ts +29 -0
  24. package/lib/typescript/commonjs/src/NativeFileToolkit.d.ts.map +1 -0
  25. package/lib/typescript/commonjs/src/index.d.ts +635 -0
  26. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  27. package/lib/typescript/module/package.json +1 -0
  28. package/lib/typescript/module/src/NativeFileToolkit.d.ts +29 -0
  29. package/lib/typescript/module/src/NativeFileToolkit.d.ts.map +1 -0
  30. package/lib/typescript/module/src/index.d.ts +635 -0
  31. package/lib/typescript/module/src/index.d.ts.map +1 -0
  32. package/package.json +232 -0
  33. package/src/NativeFileToolkit.ts +29 -0
  34. package/src/index.tsx +1293 -0
@@ -0,0 +1,635 @@
1
+ /**
2
+ * Rich progress information emitted during a download.
3
+ * Replaces the plain `number` percent from earlier versions.
4
+ */
5
+ export interface ProgressInfo {
6
+ /** Download progress as a percentage (0–100) */
7
+ percent: number;
8
+ /** Number of bytes downloaded so far */
9
+ bytesDownloaded: number;
10
+ /** Total file size in bytes (0 if unknown) */
11
+ totalBytes: number;
12
+ /** Current download speed in bytes per second */
13
+ speedBps: number;
14
+ /** Estimated seconds remaining (0 if unknown) */
15
+ etaSeconds: number;
16
+ }
17
+ export interface DownloadOptions {
18
+ /** Remote URL to download from */
19
+ url: string;
20
+ /** Optional file name. Auto-detected from URL if not provided */
21
+ fileName?: string;
22
+ /**
23
+ * Run as a background download.
24
+ * - iOS: uses NSURLSession background configuration
25
+ * - Android: uses system DownloadManager
26
+ * Background downloads survive app suspension. Listen to `onDownloadComplete`
27
+ * and `onDownloadError` events instead of awaiting the promise.
28
+ */
29
+ background?: boolean;
30
+ /** Custom request headers (e.g. Authorization) */
31
+ headers?: Record<string, string>;
32
+ /**
33
+ * Destination directory for the downloaded file.
34
+ * - 'downloads': Public Downloads folder (default)
35
+ * - 'cache': App-private cache directory (cleared by OS when space is low)
36
+ * - 'documents': App-private documents directory (persisted)
37
+ */
38
+ destination?: 'downloads' | 'cache' | 'documents';
39
+ /** Android only: custom title for the system download notification */
40
+ notificationTitle?: string;
41
+ /** Android only: custom description for the system download notification */
42
+ notificationDescription?: string;
43
+ /** Optional checksum verification after download completes */
44
+ checksum?: {
45
+ hash: string;
46
+ algorithm: 'md5' | 'sha1' | 'sha256';
47
+ };
48
+ /** Called with rich progress info during foreground downloads */
49
+ onProgress?: (info: ProgressInfo) => void;
50
+ /**
51
+ * Join the managed download queue instead of starting immediately.
52
+ * Respects the `maxConcurrent` limit set via `setQueueOptions()`.
53
+ * Defaults to `false`.
54
+ */
55
+ queue?: boolean;
56
+ /**
57
+ * Priority inside the queue.
58
+ * - `'high'`: inserted at the front of the pending queue.
59
+ * - `'normal'` (default): appended to the back.
60
+ * Has no effect when `queue` is `false`.
61
+ */
62
+ priority?: 'high' | 'normal';
63
+ /**
64
+ * Auto-retry on network failure with exponential backoff.
65
+ * Only retries on network errors (timeouts, connection drops).
66
+ * Server errors (4xx/5xx) and checksum mismatches are NOT retried.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * download({
71
+ * url: '...',
72
+ * retry: {
73
+ * attempts: 3,
74
+ * delay: 1000, // 1s → 2s → 4s (doubles each time, capped at 30s)
75
+ * onRetry: (attempt, error) => console.log(`Retry #${attempt}: ${error}`),
76
+ * }
77
+ * })
78
+ * ```
79
+ */
80
+ retry?: {
81
+ /** Maximum number of retry attempts (default: 0 = no retry) */
82
+ attempts: number;
83
+ /** Base delay in ms between retries. Doubles each attempt (default: 1000) */
84
+ delay?: number;
85
+ /** Called just before each retry attempt */
86
+ onRetry?: (attempt: number, error: string) => void;
87
+ };
88
+ }
89
+ export interface UploadOptions {
90
+ /** Remote URL to upload to */
91
+ url: string;
92
+ /** Absolute local path of the file to upload */
93
+ filePath: string;
94
+ /** Multi-part field name for the file (default: 'file') */
95
+ fieldName?: string;
96
+ /** Custom request headers */
97
+ headers?: Record<string, string>;
98
+ /** Additional text parameters for the multi-part request */
99
+ parameters?: Record<string, string>;
100
+ /** Called with progress 0–100 during upload */
101
+ onProgress?: (percent: number) => void;
102
+ }
103
+ export interface DownloadResult {
104
+ success: boolean;
105
+ /** Local path of the saved file */
106
+ filePath?: string;
107
+ /** Unique ID for this download — use with pause/resume/cancel */
108
+ downloadId?: string;
109
+ /** Error message if success is false */
110
+ error?: string;
111
+ }
112
+ export interface UploadResult {
113
+ success: boolean;
114
+ /** HTTP response status code */
115
+ status?: number;
116
+ /** HTTP response body as string (if any) */
117
+ data?: string;
118
+ /** Error message if success is false */
119
+ error?: string;
120
+ }
121
+ export interface ActionResult {
122
+ success: boolean;
123
+ error?: string;
124
+ }
125
+ export interface CachedFile {
126
+ fileName: string;
127
+ filePath: string;
128
+ /** File size in bytes */
129
+ size: number;
130
+ /** Last-modified timestamp in milliseconds */
131
+ modifiedAt: number;
132
+ }
133
+ export interface CacheResult {
134
+ success: boolean;
135
+ files?: CachedFile[];
136
+ error?: string;
137
+ }
138
+ export interface SaveBase64Options {
139
+ /**
140
+ * Base64 string or data URI (e.g., "data:image/png;base64,iVBORw0...")
141
+ * If a data URI is provided, the base64 portion will be extracted automatically.
142
+ */
143
+ base64Data: string;
144
+ /** Optional file name. Auto-generated if not provided */
145
+ fileName?: string;
146
+ /**
147
+ * Destination directory for the saved file.
148
+ * - 'downloads': Public Downloads folder (default)
149
+ * - 'cache': App-private cache directory
150
+ * - 'documents': App-private documents directory
151
+ */
152
+ destination?: 'downloads' | 'cache' | 'documents';
153
+ }
154
+ export interface SaveBase64Result {
155
+ success: boolean;
156
+ /** Local path of the saved file */
157
+ filePath?: string;
158
+ /** Error message if success is false */
159
+ error?: string;
160
+ }
161
+ export interface UrlToBase64Options {
162
+ /** URL of the file to convert to base64 (image, video, gif, etc.) */
163
+ url: string;
164
+ /** Optional custom headers (e.g., Authorization) */
165
+ headers?: Record<string, string>;
166
+ }
167
+ export interface UrlToBase64Result {
168
+ success: boolean;
169
+ /** Base64-encoded string */
170
+ base64?: string;
171
+ /** MIME type detected from response (e.g., 'image/png') */
172
+ mimeType?: string;
173
+ /** Complete data URI (e.g., 'data:image/png;base64,...') */
174
+ dataUri?: string;
175
+ /** Error message if success is false */
176
+ error?: string;
177
+ }
178
+ export interface ShareFileOptions {
179
+ /** Absolute path to the file to share */
180
+ filePath: string;
181
+ /** Optional title for the share dialog (Android only) */
182
+ title?: string;
183
+ /** Optional subject for email sharing (Android only) */
184
+ subject?: string;
185
+ }
186
+ export interface OpenFileOptions {
187
+ /** Absolute path to the file to open */
188
+ filePath: string;
189
+ /** MIME type of the file (e.g., 'application/pdf', 'image/jpeg'). Auto-detected if not provided. */
190
+ mimeType?: string;
191
+ }
192
+ export interface ShareFileResult {
193
+ success: boolean;
194
+ /** Whether user completed the share action (iOS only) */
195
+ completed?: boolean;
196
+ /** Error message if success is false */
197
+ error?: string;
198
+ }
199
+ export interface OpenFileResult {
200
+ success: boolean;
201
+ /** Error message if success is false */
202
+ error?: string;
203
+ }
204
+ export type FsEncoding = 'utf8' | 'base64';
205
+ export interface FsStat {
206
+ /** Absolute path */
207
+ path: string;
208
+ /** Basename */
209
+ name: string;
210
+ /** Size in bytes (0 for directories) */
211
+ size: number;
212
+ /** Last modified timestamp in milliseconds */
213
+ modified: number;
214
+ /** Whether path is a directory */
215
+ isDir: boolean;
216
+ }
217
+ export interface FsApi {
218
+ exists: (filePath: string) => Promise<boolean>;
219
+ stat: (filePath: string) => Promise<FsStat>;
220
+ readFile: (filePath: string, encoding?: FsEncoding) => Promise<string>;
221
+ writeFile: (filePath: string, data: string, encoding?: FsEncoding) => Promise<void>;
222
+ copyFile: (fromPath: string, toPath: string) => Promise<void>;
223
+ moveFile: (fromPath: string, toPath: string) => Promise<void>;
224
+ deleteFile: (filePath: string) => Promise<void>;
225
+ mkdir: (dirPath: string) => Promise<void>;
226
+ ls: (dirPath: string) => Promise<string[]>;
227
+ }
228
+ export interface QueueOptions {
229
+ /**
230
+ * Maximum number of simultaneous downloads when using the managed queue.
231
+ * Defaults to `3`.
232
+ */
233
+ maxConcurrent?: number;
234
+ }
235
+ export interface QueueStatus {
236
+ /** Number of downloads actively running right now */
237
+ active: number;
238
+ /** Number of downloads waiting in the queue */
239
+ pending: number;
240
+ /** Current `maxConcurrent` setting */
241
+ maxConcurrent: number;
242
+ }
243
+ /**
244
+ * Configure the global managed download queue.
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * setQueueOptions({ maxConcurrent: 3 });
249
+ * ```
250
+ */
251
+ export declare function setQueueOptions(options: QueueOptions): void;
252
+ /**
253
+ * Get the current state of the managed download queue.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * const { active, pending, maxConcurrent } = getQueueStatus();
258
+ * ```
259
+ */
260
+ export declare function getQueueStatus(): QueueStatus;
261
+ /**
262
+ * Download a file.
263
+ *
264
+ * For **foreground** downloads the promise resolves when the file is saved.
265
+ * For **background** downloads the promise resolves immediately with a
266
+ * `downloadId`; listen to the `onDownloadComplete` / `onDownloadError`
267
+ * events for the final result.
268
+ *
269
+ * Pass `queue: true` to join the managed queue and respect the `maxConcurrent`
270
+ * limit configured via `setQueueOptions()`. Use `priority: 'high'` to jump
271
+ * ahead of other pending items in the queue.
272
+ *
273
+ * @example
274
+ * ```ts
275
+ * // Direct (unqueued) download
276
+ * const result = await download({ url: 'https://...' });
277
+ *
278
+ * // Queued download with high priority
279
+ * setQueueOptions({ maxConcurrent: 3 });
280
+ * const result = await download({
281
+ * url: 'https://...',
282
+ * queue: true,
283
+ * priority: 'high',
284
+ * });
285
+ * ```
286
+ */
287
+ export declare function download(options: DownloadOptions): Promise<DownloadResult>;
288
+ /**
289
+ * Upload a file using multipart/form-data.
290
+ */
291
+ export declare function upload(options: UploadOptions): Promise<UploadResult>;
292
+ /**
293
+ * Pause an active foreground download.
294
+ * On iOS the partial data is stored so it can be resumed.
295
+ * On Android the download thread is suspended.
296
+ */
297
+ export declare function pauseDownload(downloadId: string): Promise<ActionResult>;
298
+ /**
299
+ * Resume a previously paused download.
300
+ * On iOS resumes from partial data (HTTP Range). On Android unblocks the thread.
301
+ */
302
+ export declare function resumeDownload(downloadId: string): Promise<ActionResult>;
303
+ /**
304
+ * Cancel and discard a download (foreground or background).
305
+ * Any partially-downloaded file is deleted.
306
+ */
307
+ export declare function cancelDownload(downloadId: string): Promise<ActionResult>;
308
+ /**
309
+ * List all files in the app's cache directory.
310
+ */
311
+ export declare function getCachedFiles(): Promise<CacheResult>;
312
+ /**
313
+ * Delete a single file by its absolute path.
314
+ */
315
+ export declare function deleteFile(filePath: string): Promise<ActionResult>;
316
+ /**
317
+ * Delete all files in the app's cache directory.
318
+ */
319
+ export declare function clearCache(): Promise<ActionResult>;
320
+ /**
321
+ * Get all active background downloads.
322
+ * Use this after app restart to "re-attach" to ongoing downloads.
323
+ */
324
+ export declare function getBackgroundDownloads(): Promise<{
325
+ success: boolean;
326
+ downloads?: Array<{
327
+ downloadId: string;
328
+ url: string;
329
+ status: number;
330
+ progress: number;
331
+ }>;
332
+ error?: string;
333
+ }>;
334
+ /** Check whether a file or directory exists. */
335
+ export declare function exists(filePath: string): Promise<boolean>;
336
+ /** Get file or directory metadata. */
337
+ export declare function stat(filePath: string): Promise<FsStat>;
338
+ /** Read a file as utf8 (default) or base64 string. */
339
+ export declare function readFile(filePath: string, encoding?: FsEncoding): Promise<string>;
340
+ /** Write utf8 (default) or base64 data to a file. */
341
+ export declare function writeFile(filePath: string, data: string, encoding?: FsEncoding): Promise<void>;
342
+ /** Copy a file from source to destination. */
343
+ export declare function copyFile(fromPath: string, toPath: string): Promise<void>;
344
+ /** Move a file from source to destination. */
345
+ export declare function moveFile(fromPath: string, toPath: string): Promise<void>;
346
+ /** Create a directory recursively. */
347
+ export declare function mkdir(dirPath: string): Promise<void>;
348
+ /** List direct entries (names) in a directory. */
349
+ export declare function ls(dirPath: string): Promise<string[]>;
350
+ /**
351
+ * File system API namespace.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import { fs } from 'rn-file-toolkit';
356
+ *
357
+ * const ok = await fs.exists('/path/to/file.pdf');
358
+ * const meta = await fs.stat('/path/to/file.pdf');
359
+ * const text = await fs.readFile('/path/to/file.txt');
360
+ * ```
361
+ */
362
+ export declare const fs: FsApi;
363
+ /**
364
+ * Subscribe to background download completion events.
365
+ * Returns an unsubscribe function.
366
+ */
367
+ export declare function onDownloadComplete(callback: (result: DownloadResult) => void): () => void;
368
+ /**
369
+ * Subscribe to background download error events.
370
+ * Returns an unsubscribe function.
371
+ */
372
+ export declare function onDownloadError(callback: (result: DownloadResult) => void): () => void;
373
+ /**
374
+ * Subscribe to upload progress events.
375
+ * Returns an unsubscribe function.
376
+ */
377
+ export declare function onUploadProgress(callback: (result: {
378
+ url: string;
379
+ progress: number;
380
+ }) => void): () => void;
381
+ /**
382
+ * Subscribe to download retry events (fired before each retry attempt).
383
+ * Returns an unsubscribe function.
384
+ */
385
+ export declare function onDownloadRetry(callback: (result: {
386
+ downloadId: string;
387
+ url: string;
388
+ attempt: number;
389
+ }) => void): () => void;
390
+ /**
391
+ * Save a base64 string or data URI as a file.
392
+ * Supports data URIs (e.g., "data:image/png;base64,iVBORw0...") and plain base64 strings.
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * // From data URI
397
+ * const result = await saveBase64AsFile({
398
+ * base64Data: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
399
+ * fileName: 'photo.png',
400
+ * destination: 'documents'
401
+ * });
402
+ *
403
+ * // From plain base64
404
+ * const result = await saveBase64AsFile({
405
+ * base64Data: 'SGVsbG8gV29ybGQ=',
406
+ * fileName: 'hello.txt',
407
+ * destination: 'cache'
408
+ * });
409
+ * ```
410
+ */
411
+ export declare function saveBase64AsFile(options: SaveBase64Options): Promise<SaveBase64Result>;
412
+ /**
413
+ * Convert a web URL (image, video, gif, etc.) to base64 string.
414
+ * Downloads the file and returns both the base64 string and data URI format.
415
+ *
416
+ * @example
417
+ * ```typescript
418
+ * // Convert image to base64
419
+ * const result = await urlToBase64({
420
+ * url: 'https://example.com/photo.jpg',
421
+ * headers: { Authorization: 'Bearer token' }
422
+ * });
423
+ *
424
+ * if (result.success) {
425
+ * console.log('Base64:', result.base64);
426
+ * console.log('Data URI:', result.dataUri);
427
+ * console.log('MIME Type:', result.mimeType);
428
+ * }
429
+ * ```
430
+ */
431
+ export declare function urlToBase64(options: UrlToBase64Options): Promise<UrlToBase64Result>;
432
+ /**
433
+ * Share a file with other apps using the native share dialog.
434
+ * Opens the system share sheet on iOS and share chooser on Android.
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const result = await shareFile({
439
+ * filePath: '/path/to/document.pdf',
440
+ * title: 'Share Document',
441
+ * subject: 'Check out this file'
442
+ * });
443
+ *
444
+ * if (result.success) {
445
+ * console.log('File shared successfully');
446
+ * }
447
+ * ```
448
+ */
449
+ export declare function shareFile(options: ShareFileOptions): Promise<ShareFileResult>;
450
+ /**
451
+ * Open a file with the default app or app chooser.
452
+ * On iOS, displays a preview or shows apps that can handle the file.
453
+ * On Android, opens with the default app or shows app chooser.
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * const result = await openFile({
458
+ * filePath: '/path/to/document.pdf',
459
+ * mimeType: 'application/pdf' // optional, auto-detected if not provided
460
+ * });
461
+ *
462
+ * if (result.success) {
463
+ * console.log('File opened successfully');
464
+ * }
465
+ * ```
466
+ */
467
+ export declare function openFile(options: OpenFileOptions): Promise<OpenFileResult>;
468
+ export interface UnzipResult {
469
+ success: boolean;
470
+ /** Absolute path of the destination directory */
471
+ destDir?: string;
472
+ /** List of absolute paths of all extracted files */
473
+ files?: string[];
474
+ /** Error message if success is false */
475
+ error?: string;
476
+ }
477
+ export interface ZipResult {
478
+ success: boolean;
479
+ /** Absolute path of the created zip archive */
480
+ zipPath?: string;
481
+ /** Error message if success is false */
482
+ error?: string;
483
+ }
484
+ /**
485
+ * Extract a ZIP archive to a destination directory.
486
+ *
487
+ * Uses `java.util.zip` on Android and zlib (system framework) on iOS.
488
+ * No third-party dependency required.
489
+ *
490
+ * @param sourcePath Absolute path to the `.zip` file
491
+ * @param destDir Absolute path to the directory where files will be extracted.
492
+ * The directory is created automatically if it does not exist.
493
+ *
494
+ * @example
495
+ * ```ts
496
+ * const result = await unzip(
497
+ * '/path/to/archive.zip',
498
+ * '/path/to/output-folder'
499
+ * );
500
+ *
501
+ * if (result.success) {
502
+ * console.log('Extracted files:', result.files);
503
+ * }
504
+ * ```
505
+ */
506
+ export declare function unzip(sourcePath: string, destDir: string): Promise<UnzipResult>;
507
+ /**
508
+ * Create a ZIP archive from a file or directory.
509
+ *
510
+ * Uses `java.util.zip` on Android and zlib (system framework) on iOS.
511
+ * No third-party dependency required.
512
+ *
513
+ * @param sourcePath Absolute path to the file or directory to compress
514
+ * @param destPath Absolute path for the output `.zip` file.
515
+ * Parent directory is created automatically if needed.
516
+ *
517
+ * @example
518
+ * ```ts
519
+ * // Zip a single file
520
+ * const result = await zip(
521
+ * '/path/to/document.pdf',
522
+ * '/path/to/document.zip'
523
+ * );
524
+ *
525
+ * // Zip an entire directory
526
+ * const result = await zip(
527
+ * '/path/to/my-folder',
528
+ * '/path/to/my-folder.zip'
529
+ * );
530
+ *
531
+ * if (result.success) {
532
+ * console.log('Archive created at:', result.zipPath);
533
+ * }
534
+ * ```
535
+ */
536
+ export declare function zip(sourcePath: string, destPath: string): Promise<ZipResult>;
537
+ export type DownloadStatus = 'idle' | 'downloading' | 'paused' | 'done' | 'error';
538
+ export interface UseDownloadReturn {
539
+ /** Start a download. Resolves with the final result. */
540
+ start: (options: DownloadOptions) => Promise<DownloadResult>;
541
+ /** Pause the current download */
542
+ pause: () => Promise<void>;
543
+ /** Resume the current download */
544
+ resume: () => Promise<void>;
545
+ /** Cancel the current download */
546
+ cancel: () => Promise<void>;
547
+ /** Current status of the download */
548
+ status: DownloadStatus;
549
+ /** Rich progress information (null until first progress event) */
550
+ progress: ProgressInfo | null;
551
+ /** Final result once download completes or fails */
552
+ result: DownloadResult | null;
553
+ /** The active download ID (available after download starts) */
554
+ downloadId: string | null;
555
+ }
556
+ /**
557
+ * React hook for managing a single download with built-in state.
558
+ *
559
+ * Tracks status, rich progress (percent, speed, ETA), and the final result.
560
+ * Exposes `pause`, `resume`, and `cancel` controls tied to the active download.
561
+ *
562
+ * @example
563
+ * ```tsx
564
+ * function DownloadButton() {
565
+ * const { start, pause, resume, cancel, status, progress, result } = useDownload();
566
+ *
567
+ * return (
568
+ * <View>
569
+ * <Button
570
+ * title="Download"
571
+ * onPress={() => start({ url: 'https://example.com/file.zip' })}
572
+ * />
573
+ *
574
+ * {status === 'downloading' && progress && (
575
+ * <View>
576
+ * <Text>{progress.percent.toFixed(1)}%</Text>
577
+ * <Text>Speed: {(progress.speedBps / 1024).toFixed(1)} KB/s</Text>
578
+ * <Text>ETA: {progress.etaSeconds.toFixed(0)}s</Text>
579
+ * <ProgressBar value={progress.percent / 100} />
580
+ * <Button title="Pause" onPress={pause} />
581
+ * </View>
582
+ * )}
583
+ *
584
+ * {status === 'paused' && (
585
+ * <Button title="Resume" onPress={resume} />
586
+ * )}
587
+ *
588
+ * {status === 'done' && result?.success && (
589
+ * <Text>Saved to: {result.filePath}</Text>
590
+ * )}
591
+ *
592
+ * {status === 'error' && (
593
+ * <Text>Error: {result?.error}</Text>
594
+ * )}
595
+ * </View>
596
+ * );
597
+ * }
598
+ * ```
599
+ */
600
+ export declare function useDownload(): UseDownloadReturn;
601
+ declare const _default: {
602
+ download: typeof download;
603
+ upload: typeof upload;
604
+ pauseDownload: typeof pauseDownload;
605
+ resumeDownload: typeof resumeDownload;
606
+ cancelDownload: typeof cancelDownload;
607
+ getCachedFiles: typeof getCachedFiles;
608
+ deleteFile: typeof deleteFile;
609
+ clearCache: typeof clearCache;
610
+ getBackgroundDownloads: typeof getBackgroundDownloads;
611
+ saveBase64AsFile: typeof saveBase64AsFile;
612
+ urlToBase64: typeof urlToBase64;
613
+ shareFile: typeof shareFile;
614
+ openFile: typeof openFile;
615
+ onDownloadComplete: typeof onDownloadComplete;
616
+ onDownloadError: typeof onDownloadError;
617
+ onUploadProgress: typeof onUploadProgress;
618
+ onDownloadRetry: typeof onDownloadRetry;
619
+ setQueueOptions: typeof setQueueOptions;
620
+ getQueueStatus: typeof getQueueStatus;
621
+ exists: typeof exists;
622
+ stat: typeof stat;
623
+ readFile: typeof readFile;
624
+ writeFile: typeof writeFile;
625
+ copyFile: typeof copyFile;
626
+ moveFile: typeof moveFile;
627
+ mkdir: typeof mkdir;
628
+ ls: typeof ls;
629
+ fs: FsApi;
630
+ useDownload: typeof useDownload;
631
+ unzip: typeof unzip;
632
+ zip: typeof zip;
633
+ };
634
+ export default _default;
635
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AASA;;;GAGG;AACH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