-
Notifications
You must be signed in to change notification settings - Fork 3
Document Loading
林路 edited this page Aug 14, 2026
·
4 revisions
Leaf Reader supports PDF, EPUB, and DOCX.
Open file
-> Detect document kind
-> PDF: show with PDFKit -> prepare reusable text snapshot in background
-> EPUB: unpack EPUB cache -> build reader HTML -> render in WebKit
-> DOCX: unpack temp DOCX -> build reader HTML -> render in WebKit
-> ReaderWindowController
-
DocumentLoading.swift: document kind, shared readable document types, loader entry point. -
DocumentLoading+Archive.swift: unzip, EPUB cache root, archive entry reads. -
DocumentLoading+EPUB.swift: EPUB package loading, cover, TOC, resource lookup. -
DocumentLoading+DOCX.swift,DocumentLoading+DOCXStreaming.swift,DocumentLoading+DOCXCache.swift: cancellable DOCX streaming preparation and verified prepared-output caching. -
DocumentLoading+HTML.swift: HTML rewriting, page wrapper, regex helpers. -
PDFDocumentTextSnapshot.swift: content-addressed PDF text snapshot cache and cancellable extraction pacing. -
EPUBPackageParser.swift,EPUBPathResolver.swift,EPUBHTMLSanitizer.swift,EPUBTextDecoder.swift: focused EPUB logic helpers.
- EPUB unpacking is cached under the user cache directory.
- DOCX prepared output is cached by source-content fingerprint, verified before reuse, and published atomically.
- EPUB and DOCX are rendered through generated HTML in WebKit.
- PDF remains in PDFKit for page navigation and annotation support.
- PDF text extraction runs off the UI path, pauses briefly during reader interaction, and is shared by whole-document AI indexing.
mac-app/DocumentLoading.swiftmac-app/DocumentLoading+Archive.swiftmac-app/DocumentLoading+EPUB.swiftmac-app/DocumentLoading+DOCX.swiftmac-app/DocumentLoading+DOCXStreaming.swiftmac-app/DocumentLoading+DOCXCache.swiftmac-app/DocumentLoading+HTML.swiftmac-app/PDFDocumentTextSnapshot.swiftmac-app/ReaderDocumentKind.swiftmac-app/Resources/reader-web.js
Related: Home · Feature Map · Development Tasks · Code Map · Type Index
Maintained by ./scripts/update_wiki.sh.