You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-7Lines changed: 43 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# 🗂️ use-fs
2
2
3
-
A React hook for integrating with the [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API). Visit [**use-fs.com**](https://use-fs.com) to try it out.
3
+
A React hook for integrating with the [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API). Visit [**use-fs.com**](https://use-fs.com) to try it out in your browser.
4
4
5
5
The File System Access API enables web applications to seamlessly work with files on a user's local system. After a user grants permission, web apps can read, write, and manage files directly - eliminating the need for repeated file selection dialogs. This capability is ideal for creating powerful browser-based tools.
6
6
@@ -33,7 +33,10 @@ function App() {
33
33
onClear,
34
34
isProcessing,
35
35
writeFile,
36
-
deleteFile
36
+
deleteFile,
37
+
startPolling,
38
+
stopPolling,
39
+
isPolling
37
40
} =useFs({
38
41
// Optional array of filter functions to exclude files/directories. By default `commonFilters` is used to ignore .git, node_modules, etc.
@@ -133,10 +154,11 @@ The hook provides several key features:
133
154
1.**File System Access**: Prompts users to select a directory and maintains access to it.
134
155
2.**File Writing**: Allows writing content to files with options for truncation and creation.
135
156
3.**File Deletion**: Enables safe removal of files from the selected directory.
136
-
4.**File Watching**: Continuously monitors selected directory for changes.
137
-
5.**Content Management**: Provides access to file contents and updates in real-time.
138
-
6.**Filtering**: Built-in and custom filters to exclude unwanted files/directories.
139
-
7.**Performance Optimizations**:
157
+
4.**File Watching**: Continuously monitors selected directory for changes with automatic polling.
158
+
5.**Polling Control**: Manual control over when to start/stop monitoring for file changes.
159
+
6.**Content Management**: Provides access to file contents and updates in real-time.
160
+
7.**Filtering**: Built-in and custom filters to exclude unwanted files/directories.
161
+
8.**Performance Optimizations**:
140
162
- Batched file processing
141
163
- Content caching
142
164
- Debounced updates
@@ -161,4 +183,18 @@ The hook provides several key features:
161
183
-`isProcessing: boolean` - Whether files are being processed
162
184
-`isBrowserSupported: boolean` - Whether File System API is supported
163
185
-`writeFile: (path: string, data: string | ArrayBuffer | Blob, options?: FileWriteOptions) => Promise<void>` - Function to write to files
164
-
-`deleteFile: (path: string) => Promise<void>` - Function to delete files
186
+
-`deleteFile: (path: string) => Promise<void>` - Function to delete files
187
+
-`startPolling: () => void` - Function to manually start polling for file changes
188
+
-`stopPolling: () => void` - Function to manually stop polling for file changes
189
+
-`isPolling: boolean` - Whether the hook is actively polling for changes
190
+
191
+
192
+
## 📚 Contributing
193
+
194
+
1. Navigate to the `docs` directory
195
+
2. Run `pnpm install` to install the dependencies
196
+
3. Run `pnpm dev` to start the development server
197
+
3. Navigate to `http://localhost:3000` to view the demo.
198
+
5. Modify the `Demo.tsx` file to make your changes.
199
+
200
+
If you're making changes to the `use-fs` package, you can run `pnpm build` to build the package and then run `pnpm link use-fs` to link the package to the `docs` directory for local development and testing.
0 commit comments