Skip to content

code/editor/fs-adapter

import { … } from 'zidane-ui/code/editor'ui/src/code/editor/fs-adapter.ts

Interfaces#

FileContentsInterface#

A file's text with the version it was read at.

TypeScript
interface FileContents extends FileVersion
FileContents properties
NameTypeDescription
contentsstring

The file's text.

versionfrom FileVersionnumber

Changes whenever the file does (an mtime, an etag, a content hash); saves compare it to spot conflicts.

ui/src/code/editor/fs-adapter.ts:20

FileSystemAdapterInterface#

The file operations an EditorColumn needs: list, read and write, plus optional change events and conflict checks.

TypeScript
interface FileSystemAdapter
FileSystemAdapter properties
NameTypeDescription
list(dir: string) => Promise<TreeEntry[]>

Every entry under dir ('': the root), recursively, as paths from the root.

read(path: string) => Promise<FileContents>

The file's text and current version; rejects when it cannot be read.

stat?(path: string) => Promise<FileVersion | null>

The file's version now; null when it is gone. Without it, saves never detect a conflict.

watch?(listener: (paths: readonly string[]) => void) => () => void

Paths that changed (written, created, removed) from anywhere; returns the unsubscribe.

write(path: string, text: string) => Promise<FileVersion>

Writes text (creating folders) and returns the file's new version.

ui/src/code/editor/fs-adapter.ts:26

FileVersionInterface#

A file's version stamp.

TypeScript
interface FileVersion
FileVersion properties
NameTypeDescription
versionnumber

Changes whenever the file does (an mtime, an etag, a content hash); saves compare it to spot conflicts.

ui/src/code/editor/fs-adapter.ts:14