Repository navigation
feat(storage): add FileSystemHandleStore - #460
jwindhager wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 9a1af2e The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note that the store in Vitessce (code, more code) also supports drag-and-drop (dropping a local folder onto a file input or dropzone), in addition to the directory picker. Does your implementation support this, or can it be updated to support this functionality? (it also was intended to support selection of multiple folders or files, including individual files such as zip files, although that is not fully implemented) |
|
Thanks! It should support drag-and-drop in Chromium: I'd rather keep this PR focused on Individual zip files should already work via |
|
Thanks! We actually dropped our support in Idetik, so I would definitely be happy to see this move forward. |
Adds
FileSystemHandleStoreto@zarrita/storage, a read/write store backed by aFileSystemDirectoryHandle. It works with the Origin Private File System (OPFS;navigator.storage.getDirectory(), all major browsers) and with directories from the File System Access API (showDirectoryPicker(), Chromium only).Motivation
This builds on #161, which was read-only and predates some later changes to the store interface. In https://github.com/orgs/zarr-developers/discussions/69, this was eventually considered resolved because it's easy to do in user-land. The basic version is short, but a correct one takes more work, and many projects have ended up writing their own against zarrita's store interface, e.g.:
chanzuckerberg/idetik: copy of feat(storage): Add WebFileSystemStore #161;dropped support, see feat(storage): add FileSystemHandleStore #460 (comment)getonly, returnsundefinedon errorgetRangeappears to read the whole fileget/set; workarounds for concurrent writes & missingcreateWritable()supportgetonly, returnsundefinedon any errorHaving one maintained implementation upstream therefore seems worth it.
What's included
get,getRange(offset/length and suffix, reading viaFile.slice), andset(creates missing directories)AbortSignalsupport on all methods. Aborting one caller doesn't affect others that share a cached directory lookupsetundefined, including when a path segment is a file or the key is a directory (NotFoundError/TypeMismatchError). Other errors are rethrown.setof the same new key can be affected)This store is currently in use with the development version of TissUUmaps 4 and the OpenSeadragon OMEZarrTileSource.
Developed with the help of AI (incl. tests). I closely supervised and thoroughly reviewed everything.