Skip to content

feat(documents): EPUB Reader — read e-books in the browser - #144

Merged
slaveofcode merged 2 commits into
developfrom
feat/documents-epub-reader
Aug 2, 2026
Merged

feat(documents): EPUB Reader — read e-books in the browser#144
slaveofcode merged 2 commits into
developfrom
feat/documents-epub-reader

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

What

New EPUB Reader in the Documents category — opens .epub e-books entirely client-side (epub.js). Paginated reading view, table of contents (jump to any chapter), arrow-key page turning, adjustable text size (− / +). Nothing is uploaded.

Security

epub.js declares @xmldom/xmldom: ^0.7.5, which carries the <0.8.13 XML-serialization-injection + recursion-DoS advisories. Rather than the epubjs@0.4.2 "fix" (which regresses to the even older unscoped xmldom@^0.1.27), this pins the maintained scoped package to the patched 0.8.13 via an npm override. In the browser epub.js uses the native DOMParser, so xmldom isn't even on the runtime path — the override just clears the scanner. npm audit no longer flags epubjs/xmldom. Additionally, EPUB scripts are disabled (allowScriptedContent: false) and content renders in a sandboxed frame.

Bundle hygiene

epub.js bundles from its src (its module field), which Rollup would name index.* and precache. Added manualChunks to emit stable epubjs (~250KB) + shared jszip (~200KB) chunks, both excluded from the PWA precache (workbox globIgnore) and lazy-loaded on first use. Verified docx-viewer (also uses jszip) still builds.

Details

  • src/tools/documents/epub-toc.lib.ts — pure nested-TOC → depth-tagged flat list, 5 unit tests
  • src/islands/documents/EpubReader.tsx — thin island, dynamic-imports epubjs, full resource teardown (rendition/book destroy on unmount + reset)
  • Registered epub-reader (beta); EN + ID SEO + OG
  • 659 tests pass · 0 lint errors · build green (/tools/epub-reader + /id/...)

🤖 Generated with Claude Code

slaveofcode and others added 2 commits August 2, 2026 22:42
Promote to production: Spreadsheet Viewer
Open .epub e-books entirely client-side (epub.js): paginated reading view,
table of contents, arrow-key page turning and adjustable text size. Scripts
in the book are disabled and content renders in a sandboxed frame; nothing
is uploaded.

Security: epub.js pulls @xmldom/xmldom ^0.7.5 (the <0.8.13 XML-serialization
/ recursion-DoS advisories); pinned to the patched 0.8.13 via an npm override
(the browser uses native DOMParser, so xmldom isn't even on the runtime path —
this just clears the scanner). npm audit no longer flags epubjs/xmldom.

The ~250KB epub.js engine + shared jszip are named chunks (manualChunks) and
excluded from the PWA precache (workbox globIgnore), lazy-loaded on first use.
Pure TOC-flattening lib with 5 unit tests. Bilingual (EN + ID) UI, SEO, OG.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ubfx4XocHcECaL8twp9zsr
@slaveofcode
slaveofcode merged commit 1b50137 into develop Aug 2, 2026
1 of 2 checks passed
@slaveofcode
slaveofcode deleted the feat/documents-epub-reader branch August 2, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant