Description
Hello,
I'd like to suggest the addition of a feature to the FileSystem API that would allow watching for changes in files and directories.
I've seen it mentioned many times in the comments for issues in this repository that are not directly related to this problem, but I did not find a specific issue specifically for that.
This ability is an essential component in many types of applications, including IDEs, file managers, photo/video editors, ML dataset managers, syncing apps, and any web app that uses its own type of file browser.
The lack of a file system API that includes watching capabilities can limit the effectiveness of native web apps, pushing developers towards heavier client applications or Electron-based solutions. Many projects could become PWAs instead of heavier client applications if this feature was implemented.
There are workaround solutions currently being used, such as maintaining a local list of files and checking that against the directory listing or recursively iterating over all files. However, these solutions can be resource-intensive and aren't as efficient or reliable as native events could be.
The need for this feature extends beyond web apps. For example, a i've seen expressed interest in being notified when a device like a USB hard disk or pen is plugged into the system. Additionally, this would significantly benefit browser-based debuggers.
Most OSes include their APIs for watching file changes, such as ReadDirectoryChangesW
and ReadDirectoryChangesExW
on Windows or the File System Events API
on MacOS. Leveraging these APIs could potentially reduce the time needed for implementation.
Thank you for considering this feature request. The addition of a file and directory watch functionality to the FileSystem API would undoubtedly empower developers to create more robust and efficient web apps.