app.io

Browser file I/O utilities.

Contains side-effecting helpers for reading files from <input> elements and triggering downloads via the File System Access API or <a download> fallback. Used by toolbar (file loading) and export modules (saving).

read-file!

(read-file! js-event on-read-fn)

Reads a text file selected by the user via an <input type="file"> element.

Extracts the first file from the JS event’s target, reads it as text using a FileReader, and calls on-read-fn with the string content when loading completes. This is a side-effecting function (note the !).

save-blob!

(save-blob! blob filename)(save-blob! blob filename types)

Triggers a browser file save for the given Blob.

Attempts the File System Access API (showSaveFilePicker) first, which opens a native “Save as…” dialog. Falls back to a programmatic <a download> click for browsers that do not support it (Firefox, Safari).