-
-
Notifications
You must be signed in to change notification settings - Fork 13
Backends for the File and Directory Entries API and the File API #41
Description
Rationale
FileSystemAccess API is great but poor firefox users don't get it :(
In the past I built a web-editing experience where users can select a directory and have bi-directional syncing between content in the web editor and local content. This means user can edit in the web editor and their changes are periodically write-back to the disk, and if they edit the content on the disk, it's also periodically polled from the browser.
I ended up building 2 fallbacks in firefox: DataTransferItem.webkitGetAsEntry and the classic <input type="file" webkitdirectory="true">. The first implementation allows reading the latest content but does not allow writing. The <input> only allow stale content (as all of it is uploaded when selecting the directory). (BTW, the relevant code is here: https://github.com/Pistonite/pure/blob/main/OLD/fs/FsOpen.ts#L152C1-L153C1 )
This experience isn't optimal - firefox users get different behaviors if they drag'n'drop (supports polling but not write) vs. clicking an "open folder" icon (no polling or write). However it was still a little bit helpful in driving adoption compared to a "hey go download chrome" screen.
I found this project today and I think this is really cool - especially backends like SingleBuffer, InMemory, WebStorage which I think could really be helpful in some of my projects in the future. It would be nice to also be able to use the WebAccess backend for all browsers so I can use this library for all filesystem-in-browser needs
API Proposal
WebEntry backend which uses https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry
this backend will not support writing
WebFiles backend which uses https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
this backend will not support writing and read calls will not read the latest content from disk
(Also If I remember correctly, webkitGetAsEntry actually doesn't work in Chrome - maybe a isSupported API is needed, but that can also easily be done by downstream)
Additional context
No response