# Vendored foliate-js

Do not edit these files. They are copied verbatim from upstream by
`frontend/scripts/vendor-foliate.sh`; local changes are lost on the next run.

| | |
| --- | --- |
| Upstream | <https://github.com/readest/foliate-js> (Readest's fork of johnfactotum/foliate-js) |
| Pinned commit | `63a2eb1fc1e4813c4e849ccdb3d4be2c54a35869` |
| Licence | MIT — see `LICENSE` |

Readest's fork is used rather than upstream for its paginator work: touch/swipe
turn handling, fixed-layout spread centring, and a malformed-XHTML fallback in
`loadDocument`.

## What is here

Only the import closure reachable from `view.js`. Not vendored, because nothing
reaches them: `dict.js`, `opds.js`, `footnotes.js`, `quote-image.js`,
`uri-template.js`, `reader.js` (upstream's demo), and the build configs.

## pdf.js is ours, not upstream's

`pdf.js` in this directory is a **stub that throws**. Upstream's version imports
`@pdfjs/pdf.min.mjs` — a bare specifier backed by a 12 MB vendored pdf.js build —
and `view.js` reaches it through `await import('./pdf.js')`, which Rollup resolves
at build time even though Chitai never takes that path. Chitai serves PDFs from
`static/pdfjs/web/viewer.html` instead.

To enable foliate's PDF backend, add `pdf.js` and `vendor/pdfjs/` to the file list
in the vendor script and drop the stub.

## Updating

Bump `FOLIATE_SHA` in `frontend/scripts/vendor-foliate.sh`, re-run it, review the
diff, and smoke-test the reader — `paginator.js` is ~3800 lines of gesture and
animation code and this fork is pushed to frequently.
