feat(docx): Word (.docx) support via mammoth (lazy npm dependency)

makeDocxBook: the docx blob goes straight to mammoth.convertToHtml
(mammoth unzips internally; the browser entry takes {arrayBuffer}, the
node entry {buffer}). Converted HTML is sectioned at block-element
boundaries into ~150KB chunks (string-level — no DOMParser), giving a
Part N TOC; images inline as data URIs by default.

makeBook: zip files whose entries contain word/document.xml route to
the docx branch before the EPUB fallback (previously they died inside
new EPUB(...) on the missing container.xml).

mammoth is the fork's first runtime dependency: updates and security
fixes flow via semver; the browser-field mappings swap its node unzip
for the browser one; the dynamic import keeps it out of every other
format's path.
This commit is contained in:
John O'Keefe committed 2026-10-01 14:17:38 -04:00
1 parent cd2fbf278e
commit 8e1d5fc8d6
5 files changed
+308 -10

No files matched your search

+5 -2
View File
@@ -1,6 +1,6 @@
{
"name": "foliate-js",
"version": "0.2.0",
"version": "0.3.0",
"description": "Render e-books in the browser",
"repository": {
"type": "git",
@@ -43,5 +43,8 @@
"dictd",
"stardict",
"opds"
]
],
"dependencies": {
"mammoth": "^1.13.0"
}
}