Client-side writability hint for relPath (mount mode ∩ longest-matching rule),
so an app can hide an "edit" affordance instead of catching read-only
(EDITOR_FIRST_EDITING_SPEC §3). Re-evaluate on onMountsChange — a role downgrade
flips it. EROFS from the host stays authoritative.
OptionalrelPath: stringDoes relPath exist? Never throws on absence.
Create a directory (pass { recursive: true } to make parents).
Optionalopts: { recursive?: boolean }Subscribe to changes to files in this mount — the mount-scoped projection of
the host working-tree change stream (onFsChange), so a viewer re-reads an
affected file instead of polling (SDK_FS_SURFACE_SPEC §5). The callback gets
the changed paths RELATIVE to this mount (feed them straight back into
readFile/stat/…). Returns an unsubscribe fn.
Working-tree-only in v1 (an honest gap, O2): the host push channel carries
only working-tree changes, so onChange on a NON-working-tree mount (a space)
is an inert subscription that never fires until that channel lands. Like
onFsChange, origin-exclusion (ignoring the echo of your own write) is the
caller's responsibility.
Read a file's bytes as a Blob, tagged with a MIME type inferred from the
extension (mimeTypeFor) or opts.type when given (falls back to
application/octet-stream). The building block for downloads and object URLs.
Optionalopts: { type?: string }List a directory (the mount root when relPath is omitted).
OptionalrelPath: stringRead a file as UTF-8 text (encoding: 'utf8') or raw bytes (omit encoding).
Read a file into an object URL suitable for <img src> / <a href> — the
fix for "an opaque-origin iframe can't fetch a mount path". Returns the url
and a revoke() you MUST call when done (typically on unmount) or the URL
leaks. Prefer the useObjectUrl hook / MountImage component, which revoke
for you; reach for this directly only outside React.
Optionalopts: { type?: string }Rename/move within the mount.
Remove a file, or a directory with { recursive: true }.
Optionalopts: { recursive?: boolean }Write text or bytes, creating or truncating the file. Throws read-only on a ro mount.
A mount-anchored, typed filesystem view. All paths are RELATIVE to the mount root; the accessor resolves them under
mount.path. Async-only (ZenFS rides a MessagePort). Obtain one with openFs.