Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

mbook-ui

Packagembook-ui, the application called mbook; not published to crates.io
InstallersGitHub Releases: macOS on arm64 and x86-64, Windows on x86-64, Android on arm64
Sourcecrates/mbook-ui; the Android shell in crates/mbook-android
Builds onmbook; mbook-converter
Minimum Rust1.100
StatusA first version; see Status and verification

mbook-ui is a reading application built on mbook and mbook-converter. It has three screens:

ScreenWhat it doesBuilt on
LibraryShows the books the application keeps, as coversThe catalogue; BookReader::open and read_cover
ReaderShows a reflowable chapter with scrolling or paginationBookReader, read lazily
EditorChanges the metadata, chapters, landmarks and pictures of a bookBook, in memory

Opening a file that is not yet in the library adds it: an mbook file is copied, a file in any format that mbook-converter reads is converted first. Everything that reads a file runs on the background executor of GPUI; what decodes, parses, converts or encodes runs on a pool of rayon with half the threads of the system, which the executor awaits. The main thread only draws and reacts.

The interface is built with GPUI Kit: on the GPUI Fast engine on the desktop, and on gpui-pre with the platform of gpui-mobile on Android. Window width selects the compact, medium or expanded layout. The application has shells for the desktop and for Android (Android); there is no iOS shell.

A first version exists. What is implemented says what it does, where it differs from these pages, and what has not been tried outside of tests.

cargo run -p mbook-ui

The AVIF decoder needs NASM at build time on x86 and x86-64.

PageWhat it answers
Using the applicationWhat do the library, the reader, the editor and the settings do?
ArchitectureWhere does each piece of work run, what is stored where, and how do import, reading, editing and updates work?
Appearance and accessibilityWhich colours, type and motion does the interface use, and what does it promise to assistive technology?
AndroidHow is the APK built and released, and where does the Android application differ from the desktop?
Status and verificationWhat exists today, where does it fall short, and how was it checked?
DesignWhich decisions are confirmed, which crates are used, what does the design cost, and why does it look this way?

The three screens

flowchart LR
    file["A file:<br/>mbook, EPUB, FB2,<br/>PDF, CBZ, DOCX, …"] -- "open, drop" --> imp["Import"]
    imp -- "copy or convert" --> lib["Library"]
    lib -- "open" --> reader["Reader<br/>BookReader, lazy"]
    lib -- "edit" --> editor["Editor<br/>Book, in memory"]
    reader -- "edit this book" --> editor
    editor -- "save" --> lib

The model is Apple Books for the Mac: a quiet library where the covers carry the colour, and a reader whose controls step aside. What is taken from it and what is left out is listed under Prior art.

What it is for

The repository has a format, a library and a converter, and no way to look at a book. A reader is also the first real consumer of BookReader: the claims of RFC 0001 (a book opens without being read in full; only what is on screen is decoded) are only shown to hold by an application that depends on them.

TaskScreen
Keep books in one place and find oneLibrary
Open an EPUB, FB2 or PDF without thinking about formatsLibrary, through import
Read, and come back to the same placeReader
Correct a title, a cover or a typo after a conversionEditor

Goals

GoalHow the design meets it
The interface never waits for a bookNo call that touches a file or parses runs on the main thread (Threads).
One code base for desktop and mobileLayout depends on a size class of the window; platform code stays in a thin shell (Layout).
The library survives its indexThe mbook files hold the metadata; the catalogue can be rebuilt from them (The catalogue).
A failed import or save loses nothingA file enters the library, and replaces a book, only by a rename (Import, Editing).
Little own codeComponents, the Markdown view, the text editor, dialogs and lists come from GPUI Kit; paths, updates and the store from established crates.
What is read is what was editedThe editor's preview and the reader are the same view with the same style.
Usable without sight, without a pointer and without fine motor controlEvery screen meets WCAG 2.2 at level AA where it applies to an application (Accessibility).

Non-goals

  • A store, an account or synchronisation. The library is a folder on one device.
  • Two-page spreads. See Future possibilities.
  • Annotations: highlights, notes and bookmarks.
  • A streaming editor. mbook has none; a book is edited as a whole Book.
  • An iOS shell. The design keeps it possible; the application ships for the desktop and for Android.