rn-file-toolkit 1.0.4 → 1.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.
Files changed (2) hide show
  1. package/README.md +79 -36
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -16,8 +16,10 @@
16
16
  ⭐ **Star this repo if you find it useful to help others discover it!**
17
17
 
18
18
  ## 📖 Table of Contents
19
+
19
20
  - [Why rn-file-toolkit?](#-why-rn-file-toolkit)
20
21
  - [Why not Expo FileSystem?](#-why-not-expo-filesystem)
22
+ - [Documentation Website](#-documentation-website)
21
23
  - [Installation](#-installation)
22
24
  - [Quick Start: `useDownload`](#-quick-start-usedownload)
23
25
  - [Core APIs](#-core-apis)
@@ -37,6 +39,7 @@
37
39
  Most React Native file solutions (`rn-fetch-blob`, `react-native-fs`) are fragmented, lightly maintained, or lack modern features. **rn-file-toolkit** gives you a unified, **TurboModule-compatible** API utilizing OS-native managers (`URLSession` on iOS, `DownloadManager` on Android) for reliable, battery-efficient operations.
38
40
 
39
41
  ### ✨ Highlights
42
+
40
43
  - 🪝 **Drop-in React Hooks:** Built-in state management (`useDownload`) for progress and controls.
41
44
  - 📥 **Background Ready:** Downloads and uploads survive app suspension with automatic re-attachment.
42
45
  - 🚦 **Smart Queueing:** Cap concurrency and set priorities without touching native code.
@@ -47,16 +50,34 @@ Most React Native file solutions (`rn-fetch-blob`, `react-native-fs`) are fragme
47
50
 
48
51
  ---
49
52
 
50
- ## 🤔 Why not Expo FileSystem?
53
+ ## 🥊 How does it compare?
54
+
55
+ If you've been working with React Native for a while, you've probably used `rn-fetch-blob` or `react-native-fs`. While they were fantastic tools back in the day, they haven't aged well and often struggle with modern requirements like seamless Expo integration or background persistence. You might have also tried `expo-file-system`, which is great for the basics but starts to fall short when you need smart queueing or multipart uploads.
56
+
57
+ We built **rn-file-toolkit** because we were tired of stitching together multiple unmaintained libraries just to download a file reliably in the background while keeping the UI updated.
58
+
59
+ Here's how it stacks up against the crowd:
60
+
61
+ | Feature | `rn-file-toolkit` | `react-native-fs` & `rn-fetch-blob` | `expo-file-system` |
62
+ | :--- | :---: | :---: | :---: |
63
+ | **Background Persistence** | ✅ Yes | ⚠️ Spotty / Legacy | ✅ Yes |
64
+ | **Smart Queueing & Concurrency** | ✅ Built-in | ❌ Write your own | ❌ Write your own |
65
+ | **React Hooks (`useDownload`)** | ✅ Out-of-the-box | ❌ Manual | ❌ Manual |
66
+ | **Auto-Retries & Resumption** | ✅ Yes | ❌ Manual | ⚠️ Basic resume only |
67
+ | **Multipart Uploads** | ✅ Yes (Memory efficient) | ⚠️ Basic support | ✅ Yes |
68
+ | **Expo Support (Custom Dev Client)**| ✅ Seamless | ❌ Requires heavy config | ✅ Seamless |
69
+ | **Zero 3rd-party Dependencies** | ✅ Yes | ❌ Varies | ✅ Yes |
70
+ | **Active Maintenance** | ✅ Yes | ❌ Largely unmaintained | ✅ Yes |
71
+
72
+ We hook directly into OS-level managers (`URLSession` on iOS, `DownloadManager` on Android) to provide maximum reliability, battery efficiency, and zero headaches.
73
+
74
+ ---
75
+
76
+ ## 🌐 Documentation Website
51
77
 
52
- Many developers looking for an **"expo-file-system alternative"** or a **"better react native download manager"** come here. While Expo FileSystem is a great tool for basic file operations, `rn-file-toolkit` is built specifically to handle complex, real-world file management scenarios:
78
+ Full docs are hosted on GitHub Pages:
53
79
 
54
- - **Queueing & Concurrency:** Built-in smart queueing allows you to cap concurrent downloads and set priorities without writing complex JavaScript wrappers.
55
- - **Native Download/Upload Managers:** We hook directly into OS-level managers (`URLSession` on iOS, `DownloadManager` on Android) for maximum reliability and battery efficiency.
56
- - **Auto-Retries & Resiliency:** Native implementations handle network drops with exponential backoff and HTTP resume automatically.
57
- - **Multipart Uploads:** Robust, memory-efficient multipart uploads for large media are built right in.
58
- - **Drop-in React Hooks:** Provides a `useDownload` hook out-of-the-box for instant progress tracking, speed, ETA, and state controls.
59
- - **Background Persistence:** Downloads and uploads survive app suspension and backgrounding, automatically re-attaching when the app resumes.
80
+ https://chavan-labs.github.io/rn-file-toolkit/
60
81
 
61
82
  ---
62
83
 
@@ -73,7 +94,7 @@ yarn add rn-file-toolkit
73
94
  pnpm add rn-file-toolkit
74
95
  ```
75
96
 
76
- *(Optional) If you are not using Expo or an auto-linking setup, run `pod install` in your `ios` directory.*
97
+ _(Optional) If you are not using Expo or an auto-linking setup, run `pod install` in your `ios` directory._
77
98
 
78
99
  ---
79
100
 
@@ -87,22 +108,27 @@ import { View, Text, Button } from 'react-native';
87
108
  import { useDownload } from 'rn-file-toolkit';
88
109
 
89
110
  export default function DownloadScreen() {
90
- const { start, pause, resume, cancel, status, progress, result } = useDownload();
111
+ const { start, pause, resume, cancel, status, progress, result } =
112
+ useDownload();
91
113
 
92
114
  return (
93
115
  <View style={{ padding: 20 }}>
94
- <Button
95
- title="Start Download"
96
- onPress={() => start({
97
- url: 'https://example.com/large-video.mp4',
98
- destination: 'documents'
99
- })}
116
+ <Button
117
+ title="Start Download"
118
+ onPress={() =>
119
+ start({
120
+ url: 'https://example.com/large-video.mp4',
121
+ destination: 'documents',
122
+ })
123
+ }
100
124
  />
101
125
 
102
126
  {status === 'downloading' && progress && (
103
127
  <View style={{ marginTop: 20 }}>
104
128
  <Text>Progress: {progress.percent.toFixed(1)}%</Text>
105
- <Text>Speed: {(progress.speedBps / 1024 / 1024).toFixed(2)} MB/s</Text>
129
+ <Text>
130
+ Speed: {(progress.speedBps / 1024 / 1024).toFixed(2)} MB/s
131
+ </Text>
106
132
  <Text>ETA: {progress.etaSeconds.toFixed(0)} seconds</Text>
107
133
  <View style={{ flexDirection: 'row', gap: 10, marginTop: 10 }}>
108
134
  <Button title="Pause" onPress={pause} />
@@ -112,8 +138,12 @@ export default function DownloadScreen() {
112
138
  )}
113
139
 
114
140
  {status === 'paused' && <Button title="Resume" onPress={resume} />}
115
- {status === 'done' && <Text style={{ color: 'green' }}>✅ Saved: {result?.filePath}</Text>}
116
- {status === 'error' && <Text style={{ color: 'red' }}>❌ Error: {result?.error}</Text>}
141
+ {status === 'done' && (
142
+ <Text style={{ color: 'green' }}>✅ Saved: {result?.filePath}</Text>
143
+ )}
144
+ {status === 'error' && (
145
+ <Text style={{ color: 'red' }}>❌ Error: {result?.error}</Text>
146
+ )}
117
147
  </View>
118
148
  );
119
149
  }
@@ -124,6 +154,7 @@ export default function DownloadScreen() {
124
154
  ## 🛠️ Core APIs
125
155
 
126
156
  ### Background Downloads
157
+
127
158
  For programmatic, queue-aware background downloads outside of React components.
128
159
 
129
160
  ```typescript
@@ -135,14 +166,15 @@ setQueueOptions({ maxConcurrent: 3 });
135
166
  const result = await download({
136
167
  url: 'https://example.com/file.pdf',
137
168
  destination: 'documents', // 'downloads' | 'cache' | 'documents'
138
- queue: true, // Join the managed queue
139
- priority: 'high', // 'high' | 'normal'
169
+ queue: true, // Join the managed queue
170
+ priority: 'high', // 'high' | 'normal'
140
171
  retry: { attempts: 3, delay: 1000 },
141
172
  onProgress: (p) => console.log(`${p.percent.toFixed(1)}% downloaded`),
142
173
  });
143
174
  ```
144
175
 
145
176
  ### Multipart Uploads
177
+
146
178
  Robust, memory-efficient multipart file uploading for large media or documents.
147
179
 
148
180
  ```typescript
@@ -158,6 +190,7 @@ const result = await upload({
158
190
  ```
159
191
 
160
192
  ### File System (FS)
193
+
161
194
  Perform native filesystem operations securely.
162
195
 
163
196
  ```typescript
@@ -180,6 +213,7 @@ await fs.deleteFile('/path/unwanted.txt');
180
213
  ```
181
214
 
182
215
  ### Zip & Unzip Archives
216
+
183
217
  Compress and extract archives directly on the device.
184
218
 
185
219
  ```typescript
@@ -193,16 +227,22 @@ await zip('/path/to/user-data-folder', '/path/to/backup.zip');
193
227
  ```
194
228
 
195
229
  ### Media & Utilities
230
+
196
231
  Helpful tools for sharing, opening, and encoding files.
197
232
 
198
233
  ```typescript
199
- import { saveBase64AsFile, urlToBase64, shareFile, openFile } from 'rn-file-toolkit';
234
+ import {
235
+ saveBase64AsFile,
236
+ urlToBase64,
237
+ shareFile,
238
+ openFile,
239
+ } from 'rn-file-toolkit';
200
240
 
201
241
  // Base64 to File
202
- await saveBase64AsFile({
203
- base64Data: 'data:image/png;base64,...',
242
+ await saveBase64AsFile({
243
+ base64Data: 'data:image/png;base64,...',
204
244
  destination: 'documents',
205
- fileName: 'image.png'
245
+ fileName: 'image.png',
206
246
  });
207
247
 
208
248
  // URL to Base64 (Great for caching small images)
@@ -212,28 +252,31 @@ const b64 = await urlToBase64({ url: 'https://example.com/icon.png' });
212
252
  await shareFile({ filePath: '/path/to/report.pdf' });
213
253
 
214
254
  // Open with default system app
215
- await openFile({ filePath: '/path/to/report.pdf', mimeType: 'application/pdf' });
255
+ await openFile({
256
+ filePath: '/path/to/report.pdf',
257
+ mimeType: 'application/pdf',
258
+ });
216
259
  ```
217
260
 
218
261
  ---
219
262
 
220
263
  ## 📚 API Reference
221
264
 
222
- | Interface | Key Properties | Description |
223
- | :--- | :--- | :--- |
224
- | `DownloadOptions` | `url`, `destination`, `queue`, `retry`, `onProgress` | Configuration for downloading a file. |
225
- | `UploadOptions` | `url`, `filePath`, `fieldName`, `parameters`, `onProgress` | Configuration for multipart uploads. |
226
- | `ProgressInfo` | `percent`, `bytesDownloaded`, `speedBps`, `etaSeconds` | Rich real-time progress payload. |
227
- | `UseDownloadReturn` | `start`, `pause`, `resume`, `cancel`, `status`, `progress` | Hook state and control methods. |
228
- | `FsStat` | `size`, `modified`, `isDir` | Output of the filesystem `stat` method. |
265
+ | Interface | Key Properties | Description |
266
+ | :------------------ | :--------------------------------------------------------- | :-------------------------------------- |
267
+ | `DownloadOptions` | `url`, `destination`, `queue`, `retry`, `onProgress` | Configuration for downloading a file. |
268
+ | `UploadOptions` | `url`, `filePath`, `fieldName`, `parameters`, `onProgress` | Configuration for multipart uploads. |
269
+ | `ProgressInfo` | `percent`, `bytesDownloaded`, `speedBps`, `etaSeconds` | Rich real-time progress payload. |
270
+ | `UseDownloadReturn` | `start`, `pause`, `resume`, `cancel`, `status`, `progress` | Hook state and control methods. |
271
+ | `FsStat` | `size`, `modified`, `isDir` | Output of the filesystem `stat` method. |
229
272
 
230
- *For advanced types and detailed parameter documentation, please refer to the source TypeScript definitions.*
273
+ _For advanced types and detailed parameter documentation, please refer to the source TypeScript definitions._
231
274
 
232
275
  ---
233
276
 
234
277
  ## 🎪 Expo Support
235
278
 
236
- **rn-file-toolkit** works seamlessly with Expo custom development clients (EAS Build / `npx expo run:android` / `npx expo run:ios`). Since it contains native code, it is not compatible with Expo Go.
279
+ **rn-file-toolkit** works seamlessly with Expo custom development clients (EAS Build / `npx expo run:android` / `npx expo run:ios`). Since it contains native code, it is not compatible with Expo Go.
237
280
 
238
281
  An Expo config plugin is included automatically. No extra configuration is needed in your `app.json` unless you want to customize permissions.
239
282
 
@@ -241,7 +284,7 @@ An Expo config plugin is included automatically. No extra configuration is neede
241
284
 
242
285
  ## 🤝 Contributing
243
286
 
244
- Contributions are welcome! If you find a bug or want to request a feature, please [open an issue](https://github.com/chavan-labs/rn-file-toolkit/issues).
287
+ Contributions are welcome! If you find a bug or want to request a feature, please [open an issue](https://github.com/chavan-labs/rn-file-toolkit/issues).
245
288
 
246
289
  1. Fork the repository
247
290
  2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-file-toolkit",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "The ultimate native file management toolkit for React Native. Features background downloads, resumable uploads, filesystem operations, queues, zip/unzip, and media utilities with zero third-party dependencies.",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -55,6 +55,7 @@
55
55
  "android",
56
56
  "download",
57
57
  "downloader",
58
+ "file-toolkit",
58
59
  "file-download",
59
60
  "background-download",
60
61
  "download-manager",
@@ -123,7 +124,7 @@
123
124
  "bugs": {
124
125
  "url": "https://github.com/chavan-labs/rn-file-toolkit/issues"
125
126
  },
126
- "homepage": "https://github.com/chavan-labs/rn-file-toolkit#readme",
127
+ "homepage": "https://chavan-labs.github.io/rn-file-toolkit/",
127
128
  "publishConfig": {
128
129
  "registry": "https://registry.npmjs.org/"
129
130
  },