feat: add PostScript/EPS support via Riposte + bump deps

Render PostScript and EPS (.ps / .eps / .epsf). Riposte (pure-JS, zero-dep, MIT)
interprets each page and rasterizes it to a <canvas>; the new PostScriptRenderer
drives Riposte's engine and lays pages out as `.postscript-page`, matching the
PDF/DjVu/comic paged-canvas model. A per-page try/catch keeps an unsupported
operator from sinking the whole document.

- New src/renderers/postscript-renderer.js; wired into EXT_MAP (.ps/.eps/.epsf)
  + RENDERER_LOADERS, dropzone pill + toolbar badge (#880e4f), accept list, CSS
- riposte pinned as a git dep (no Vite alias needed — it declares no package exports)
- README / CREDITS / EMBEDDING updated (riposte is the 4th git-dep engine)
- Bump deps: mammoth 1.8->1.12, pdfjs-dist 6.0.227->6.1.200, vite 8.1.0->8.1.2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 20:44:27 +02:00
co-authored by Claude Opus 4.8
parent f6897f803e
commit 3df5627b9f
9 changed files with 119 additions and 27 deletions
+1
View File
@@ -27,6 +27,7 @@ dependencies** in anything that ships.
| [foliate-js](https://github.com/johnfactotum/foliate-js) | MIT | EPUB/MOBI/AZW3/FB2 |
| [mhtml-to-html](https://github.com/gildas-lormeau/mhtml-to-html) | MIT | MHTML/`.mht` web archives → HTML |
| [CHMate](https://github.com/Alpaq92/CHMate) | MIT | CHM (`.chm`) reading + rendering — pure-JS ITSF container + LZX, no WASM |
| [Riposte](https://github.com/Alpaq92/Riposte) | MIT | PostScript / EPS (`.ps`/`.eps`) interpreter + canvas renderer — pure-JS, zero-dep, no WASM |
| [UTIF.js](https://github.com/photopea/UTIF.js) | MIT | TIFF images |
| [exifr](https://github.com/MikeKovarik/exifr) | MIT | EXIF/GPS metadata |
| [Vite](https://github.com/vitejs/vite) | MIT | build tooling |
+1 -1
View File
@@ -148,5 +148,5 @@ theme + inline `style` attributes). No `'unsafe-eval'` is required.
- **Formats:** PDF, DjVu, ODF (ODT/ODS/ODP/ODG), RTF, DOC, DOCX, PPTX,
XLSX/XLS, CSV/TSV, Markdown, source code, images (+TIFF/EXIF),
comic archives (CBZ/CBR/CBT), e-books (EPUB/MOBI/AZW3/FB2),
web archives (MHTML), Compiled HTML Help (CHM), plain text.
web archives (MHTML), Compiled HTML Help (CHM), PostScript/EPS, plain text.
- See [CREDITS.md](CREDITS.md) — every bundled engine is permissively licensed.
+8 -5
View File
@@ -1,6 +1,6 @@
# ReaderJS — Universal Document Viewer
A browser-based document viewer that renders **PDF, ODF, RTF, DOC, DOCX, Markdown, plain text, images, comic-book archives, e-books (EPUB/MOBI), web archives (MHTML), and Compiled HTML Help (CHM)** natively in the browser — no server, no upload, no conversion. Everything runs client-side; your files never leave your machine.
A browser-based document viewer that renders **PDF, ODF, RTF, DOC, DOCX, Markdown, plain text, images, comic-book archives, e-books (EPUB/MOBI), web archives (MHTML), Compiled HTML Help (CHM), and PostScript/EPS** natively in the browser — no server, no upload, no conversion. Everything runs client-side; your files never leave your machine.
To give it a try without installing anything, visit the [live demo](https://alpaq92.github.io/ReaderJS/).
@@ -13,6 +13,7 @@ To give it a try without installing anything, visit the [live demo](https://alpa
| Format | Extension(s) | Engine |
|--------|-------------|--------|
| PDF | `.pdf` | PDF.js (Mozilla) |
| PostScript / EPS | `.ps` `.eps` `.epsf` | Riposte |
| DjVu | `.djvu` `.djv` | DejaView |
| ODF — Writer, Calc, Impress | `.odt` `.ods` `.odp` `.odg` | JSZip + DOMParser |
| Rich Text Format | `.rtf` | RTF.js |
@@ -83,6 +84,7 @@ ReaderJS is built on these open-source libraries:
| **[foliate-js](https://github.com/johnfactotum/foliate-js)** | John Factotum | EPUB / MOBI / KF8 (AZW3) / FB2 parsing and paginated rendering |
| **[mhtml-to-html](https://github.com/gildas-lormeau/mhtml-to-html)** | Gildas Lormeau | MHTML (`.mht` / `.mhtml`) web archives → one self-contained HTML document |
| **[CHMate](https://github.com/Alpaq92/CHMate)** | Alpaq92 | Pure-JS Microsoft Compiled HTML Help (`.chm`) reader — ITSF container + LZX decompression + sanitizing topic renderer, no WASM |
| **[Riposte](https://github.com/Alpaq92/Riposte)** | Alpaq92 | Pure-JS PostScript / EPS interpreter and renderer — rasterizes each page to `<canvas>`, zero runtime deps, no WASM |
| **[UTIF.js](https://github.com/photopea/UTIF.js)** | Photopea | TIFF image decoding |
| **[exifr](https://github.com/MikeKovarik/exifr)** | Mike Kovarik | EXIF / GPS metadata parsing for images |
| **[Vite](https://github.com/vitejs/vite)** | Evan You / Vite contributors | Build tooling and development server |
@@ -90,11 +92,12 @@ ReaderJS is built on these open-source libraries:
| **[Open-Color](https://github.com/yeun/open-color)** | Heeyeun Jeong | Colour palette for the compare / diff view |
Every library above is a normal **npm dependency** — `npm install` is all you
need, no git submodules. The three that aren't published to npm
need, no git submodules. The four that aren't published to npm
([foliate-js](https://github.com/johnfactotum/foliate-js) for e-books,
[DejaView](https://github.com/Alpaq92/dejaview) for DjVu, and
[CHMate](https://github.com/Alpaq92/CHMate) for CHM) are pinned to commits
as git dependencies in `package.json`. Every engine is permissively licensed
[DejaView](https://github.com/Alpaq92/dejaview) for DjVu,
[CHMate](https://github.com/Alpaq92/CHMate) for CHM, and
[Riposte](https://github.com/Alpaq92/Riposte) for PostScript) are pinned to
commits as git dependencies in `package.json`. Every engine is permissively licensed
(MIT / BSD / Apache-2.0 / 0BSD).
## Gallery
+2 -1
View File
@@ -120,7 +120,7 @@
</svg>
</label>
<input id="fileInput" type="file"
accept=".pdf,.djvu,.djv,.odt,.ods,.odp,.odg,.odm,.odf,.rtf,.doc,.docx,.mht,.mhtml,.chm,.pptx,.xlsx,.xls,.xlsm,.xlsb,.csv,.tsv,.js,.mjs,.cjs,.jsx,.ts,.tsx,.json,.jsonc,.xml,.html,.htm,.yaml,.yml,.css,.scss,.less,.py,.java,.c,.h,.cpp,.cc,.hpp,.cs,.go,.rs,.rb,.php,.sh,.bash,.sql,.kt,.swift,.toml,.ini,.diff,.md,.markdown,.txt,.text,.log,.png,.jpg,.jpeg,.gif,.webp,.avif,.bmp,.svg,.ico,.tif,.tiff,.cbz,.cbr,.cbt,.epub,.mobi,.azw3,.azw,.kf8,.fb2,.fbz"
accept=".pdf,.ps,.eps,.epsf,.djvu,.djv,.odt,.ods,.odp,.odg,.odm,.odf,.rtf,.doc,.docx,.mht,.mhtml,.chm,.pptx,.xlsx,.xls,.xlsm,.xlsb,.csv,.tsv,.js,.mjs,.cjs,.jsx,.ts,.tsx,.json,.jsonc,.xml,.html,.htm,.yaml,.yml,.css,.scss,.less,.py,.java,.c,.h,.cpp,.cc,.hpp,.cs,.go,.rs,.rb,.php,.sh,.bash,.sql,.kt,.swift,.toml,.ini,.diff,.md,.markdown,.txt,.text,.log,.png,.jpg,.jpeg,.gif,.webp,.avif,.bmp,.svg,.ico,.tif,.tiff,.cbz,.cbr,.cbt,.epub,.mobi,.azw3,.azw,.kf8,.fb2,.fbz"
aria-label="Open document file" data-i18n-aria="aria.openFile" />
<button id="compareBtn" class="toolbar-btn" title="Compare two files…" data-i18n-title="compare.openTwo">
@@ -166,6 +166,7 @@
<p><span data-i18n="dropzone.drop">Drop a file here, or</span> <label for="fileInput" data-i18n="dropzone.browse">browse</label></p>
<div class="format-tags">
<span class="format-tag tag-pdf">PDF</span>
<span class="format-tag tag-ps">PS</span>
<span class="format-tag tag-djvu">DJVU</span>
<span class="format-tag tag-odf">ODT</span>
<span class="format-tag tag-odf">ODS</span>
+27 -17
View File
@@ -17,18 +17,19 @@
"highlight.js": "^11.11.1",
"jszip": "^3.10.1",
"libarchive.js": "^2.0.2",
"mammoth": "^1.8.0",
"mammoth": "^1.12.0",
"marked": "^18.0.5",
"mhtml-to-html": "^2.0.1",
"papaparse": "^5.5.4",
"pdfjs-dist": "^6.0.227",
"pdfjs-dist": "^6.1.200",
"pptxviewjs": "^1.1.9",
"riposte": "github:Alpaq92/Riposte#307ef7dfd9c5e8c0c07a840874e013cf94a85ada",
"rtf.js": "^3.0.9",
"utif": "^3.1.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"vite": "^8.1.0"
"vite": "^8.1.2"
}
},
"node_modules/@emnapi/core": {
@@ -1372,9 +1373,9 @@
}
},
"node_modules/nanoid": {
"version": "3.3.14",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.14.tgz",
"integrity": "sha512-U9kYi5bpVMEI31yC8iw4bJJp0avcHXA0W8/wNfLfnvJYzihQo2ZRPYPvpAAd570HAcCBjCTN7vnr+v4StKl1IQ==",
"version": "3.3.15",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.15.tgz",
"integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==",
"dev": true,
"funding": [
{
@@ -1461,9 +1462,9 @@
}
},
"node_modules/pdfjs-dist": {
"version": "6.0.227",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-6.0.227.tgz",
"integrity": "sha512-/P6M4SXw+70waMVLUM7rdRtvo+dEzqE1t6W/zQNvBETo2MaRa5rrvCcAYdfWGiUzadTgM0lJmRApUrW0d9zgKg==",
"version": "6.1.200",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-6.1.200.tgz",
"integrity": "sha512-o8MolyzirkkLrcdsae/HEOiIcXWI7DS5zGpvqW8xTC2YUsW30rltFw2bDGvw/fskUdEMrQm2br68jzDS5BH2vw==",
"license": "Apache-2.0",
"engines": {
"node": ">=22.13.0 || >=24"
@@ -1493,9 +1494,9 @@
}
},
"node_modules/postcss": {
"version": "8.5.15",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz",
"integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==",
"version": "8.5.16",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.16.tgz",
"integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==",
"dev": true,
"funding": [
{
@@ -1563,6 +1564,15 @@
"util-deprecate": "~1.0.1"
}
},
"node_modules/riposte": {
"version": "0.0.0",
"resolved": "git+ssh://git@github.com/Alpaq92/Riposte.git#307ef7dfd9c5e8c0c07a840874e013cf94a85ada",
"integrity": "sha512-01aIXYGopr6kpf5VWtOJ/d+/WeI216/rLldNW4a1atwJc5ZdwBOtWfv28Kh6jwvRXiKg8wB/Sc0Umu7Xoh5Jpw==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/rolldown": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.3.tgz",
@@ -1723,16 +1733,16 @@
"license": "MIT"
},
"node_modules/vite": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.1.0.tgz",
"integrity": "sha512-BuJcQK/56NQTWDGn4ABea3q4SSBdNPWwNZKTkkUpcMPnLoquSYH8llRtSUIgoL1KSCpHt5eghLShn50mH36y7Q==",
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.1.2.tgz",
"integrity": "sha512-6YYPbRXTxx6bRXmOn7XdnQAy5DQNHhDgtjhDHI13oe4pY93kkcdGJWxpGwOm++/Wh0QpQhDrpIoVMrmrsI5AGQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"lightningcss": "^1.32.0",
"picomatch": "^4.0.4",
"postcss": "^8.5.15",
"rolldown": "~1.1.2",
"postcss": "^8.5.16",
"rolldown": "~1.1.3",
"tinyglobby": "^0.2.17"
},
"bin": {
+4 -3
View File
@@ -22,17 +22,18 @@
"highlight.js": "^11.11.1",
"jszip": "^3.10.1",
"libarchive.js": "^2.0.2",
"mammoth": "^1.8.0",
"mammoth": "^1.12.0",
"marked": "^18.0.5",
"mhtml-to-html": "^2.0.1",
"papaparse": "^5.5.4",
"pdfjs-dist": "^6.0.227",
"pdfjs-dist": "^6.1.200",
"pptxviewjs": "^1.1.9",
"riposte": "github:Alpaq92/Riposte#307ef7dfd9c5e8c0c07a840874e013cf94a85ada",
"rtf.js": "^3.0.9",
"utif": "^3.1.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"vite": "^8.1.0"
"vite": "^8.1.2"
}
}
+2
View File
@@ -22,6 +22,7 @@ const RENDERER_LOADERS = {
djvu: () => import('./renderers/djvu-renderer.js').then(m => new m.DjVuRenderer()),
mhtml: () => import('./renderers/mhtml-renderer.js').then(m => new m.MHTMLRenderer()),
chm: () => import('./renderers/chm-renderer.js').then(m => new m.CHMRenderer()),
ps: () => import('./renderers/postscript-renderer.js').then(m => new m.PostScriptRenderer()),
}
const CODE_EXTS = ['js','mjs','cjs','jsx','ts','tsx','json','jsonc','xml','html','htm',
@@ -30,6 +31,7 @@ const CODE_EXTS = ['js','mjs','cjs','jsx','ts','tsx','json','jsonc','xml','html'
const EXT_MAP = {
pdf: 'pdf',
ps: 'ps', eps: 'ps', epsf: 'ps',
djvu: 'djvu', djv: 'djvu',
odt: 'odf', ods: 'odf', odp: 'odf', odg: 'odf', odm: 'odf', odf: 'odf',
rtf: 'rtf',
+63
View File
@@ -0,0 +1,63 @@
import { BaseRenderer } from './base-renderer.js'
// PostScript / EPS (.ps / .eps) — interpreted and rasterized by Riposte, a
// pure-JS PostScript interpreter (MIT, zero runtime deps). Each page is rendered
// to a <canvas>, following the paged-canvas model the PDF / DjVu / comic
// renderers use (a `.postscript-page` per page, CSS `zoom` for scaling).
export class PostScriptRenderer extends BaseRenderer {
async load(buffer, container, viewer) {
await super.load(buffer, container, viewer)
const [{ loadDocument, pageSize, renderPageToDriver }, { CanvasDriver }] = await Promise.all([
import('riposte/engine/document.js'),
import('riposte/engine/graphics/canvas-driver.js'),
])
// PostScript is byte-oriented; decode as Latin-1 (1 byte = 1 code unit) so
// the source stays byte-exact for the interpreter.
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer)
let src = ''
for (let i = 0; i < bytes.length; i += 8192) {
src += String.fromCharCode.apply(null, bytes.subarray(i, i + 8192))
}
const doc = loadDocument(src)
container.innerHTML = ''
for (let i = 0; i < doc.pageCount; i++) {
const { width, height } = pageSize(doc, i)
const page = document.createElement('div')
page.className = 'postscript-page'
page.dataset.page = String(i + 1)
const canvas = document.createElement('canvas')
canvas.width = Math.max(1, Math.round(width)) // natural size; CSS zoom scales it
canvas.height = Math.max(1, Math.round(height))
const ctx = canvas.getContext('2d')
// An unsupported operator on one page must not sink the whole document:
// keep whatever rendered, warn, and move on to the remaining pages.
try {
if (ctx) renderPageToDriver(doc, i, new CanvasDriver(ctx))
} catch (e) {
console.warn(`[PostScript] page ${i + 1} render error:`, e?.message || e)
}
page.appendChild(canvas)
container.appendChild(page)
}
const first = doc.pageCount ? pageSize(doc, 0) : { width: 816, height: 1056 }
this._pageW = Math.round(first.width) || 816
this._pageH = Math.round(first.height) || 1056
this.numPages = doc.pageCount || 1
}
setScale(scale) {
this.scale = scale
this.container?.querySelectorAll('.postscript-page').forEach((el) => {
el.style.zoom = scale === 1 ? '' : scale
})
}
getPageWidth() { return this._pageW || 816 }
getPageHeight() { return this._pageH || null }
}
+11
View File
@@ -254,6 +254,7 @@ html, body {
#formatBadge.badge-djvu { background: #3949ab; color: #fff; }
#formatBadge.badge-mhtml { background: #8e24aa; color: #fff; }
#formatBadge.badge-chm { background: #006064; color: #fff; }
#formatBadge.badge-ps { background: #880e4f; color: #fff; }
/* File input — hidden, triggered by label */
#fileInput { display: none; }
@@ -389,6 +390,7 @@ html, body {
.tag-djvu { background: #3949ab; color: #fff; }
.tag-mhtml { background: #8e24aa; color: #fff; }
.tag-chm { background: #006064; color: #fff; }
.tag-ps { background: #880e4f; color: #fff; }
.powered-by {
margin-top: 22px;
@@ -419,6 +421,15 @@ html, body {
}
.pdf-page canvas { display: block; }
/* ── PostScript / EPS pages (Riposte) ──────────────────────────────────── */
.postscript-page {
background: #fff;
box-shadow: 0 2px 10px rgba(0,0,0,.5);
flex-shrink: 0;
line-height: 0;
}
.postscript-page canvas { display: block; }
/* ── DjVu pages (DejaView) ─────────────────────────────────────────────── */
.djvu-page {
background: #fff;