react-book-reader 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -7
- package/lib/comic-book-D8f_Cc7Q.js +25 -0
- package/lib/epub-CiyU4mPz.js +681 -0
- package/lib/fb2-DCqZtzQ5.js +258 -0
- package/lib/fflate-CExlDunL.js +139 -0
- package/lib/fixed-layout-CMyaX9h8.js +195 -0
- package/lib/mobi-CikMBloG.js +960 -0
- package/lib/paginator-CpnI4Urk.js +748 -0
- package/lib/pdf-BboyxV4m.js +109 -0
- package/lib/react-book-reader.es.js +1757 -5
- package/lib/react-book-reader.umd.js +89 -692
- package/lib/search-aqQXTfxz.js +72 -0
- package/lib/tts-UQB-k9b_.js +212 -0
- package/lib/view-C6hqGjnD.js +774 -0
- package/lib/zip-Bw0cufIw.js +1509 -0
- package/package.json +16 -6
- package/lib/comic-book-D2H5riQt.js +0 -29
- package/lib/epub-Bp68GWU6.js +0 -737
- package/lib/fb2-DHUjllK8.js +0 -263
- package/lib/fflate-9VGFqnqw.js +0 -162
- package/lib/fixed-layout-DpOZsuor.js +0 -223
- package/lib/index-CFQ7Jj2W.js +0 -46367
- package/lib/mobi-Di0D6QEl.js +0 -1036
- package/lib/paginator-Czje3OX9.js +0 -736
- package/lib/pdf-CsfA1oys.js +0 -563
- package/lib/search-Dw1WQJVD.js +0 -78
- package/lib/tts-CuDZu6rz.js +0 -242
- package/lib/zip-BLPDOR3v.js +0 -1614
package/README.md
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img width=250 src="https://raw.githubusercontent.com/jinhuan138/react-book-reader/master/docs/public/logo.png" />
|
|
3
|
+
<h1>ReactReader</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://www.npmjs.com/package/react-book-reader" target="_blank">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/react-book-reader?style=flat-square" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/react-book-reader" target="_blank" >
|
|
11
|
+
<img src="https://img.shields.io/npm/dw/react-book-reader?style=flat-square" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="./LICENSE">
|
|
14
|
+
<img src="https://img.shields.io/npm/l/react-book-reader?style=flat-square" />
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<h2><a href="https://jinhuan138.github.io/react-book-reader/">📖Documentation</a></h2>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Introduction
|
|
23
|
+
|
|
24
|
+
react-book-reader is a react wrapper for [foliate-js](https://github.com/johnfactotum/foliate-js) - library for rendering e-books in the browser.
|
|
25
|
+
Supports EPUB, MOBI, KF8 (AZW3), FB2, CBZ, PDF (experimental; requires PDF.js), or add support for other formats yourself by implementing the book interface
|
|
26
|
+
|
|
27
|
+
## Basic usage
|
|
2
28
|
|
|
3
29
|
```bash
|
|
4
30
|
npm install react-book-reader --save
|
|
5
31
|
```
|
|
6
32
|
|
|
7
|
-
And in your
|
|
33
|
+
And in your react-component...
|
|
8
34
|
|
|
9
|
-
```
|
|
35
|
+
```jsx
|
|
10
36
|
import { ReactReader } from 'react-book-reader'
|
|
11
37
|
|
|
12
|
-
|
|
38
|
+
export default () => {
|
|
13
39
|
return (
|
|
14
40
|
<div style={{ height: '100vh' }}>
|
|
15
41
|
{/* Supports EPUB, MOBI, KF8 (AZW3), FB2, CBZ, PDF */}
|
|
16
|
-
<ReactReader url="/files/啼笑因缘.
|
|
42
|
+
<ReactReader url="/files/啼笑因缘.epub" />
|
|
17
43
|
</div>
|
|
18
44
|
)
|
|
19
45
|
}
|
|
20
|
-
|
|
21
|
-
export default App
|
|
22
46
|
```
|
|
23
47
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const h = ({ entries: i, loadBlob: a, getSize: l }, d) => {
|
|
2
|
+
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), f = async (e) => {
|
|
3
|
+
if (r.has(e)) return r.get(e);
|
|
4
|
+
const o = URL.createObjectURL(await a(e)), n = URL.createObjectURL(
|
|
5
|
+
new Blob([`<!DOCTYPE html><html><head><meta charset="utf-8"></head><body style="margin: 0"><img src="${o}"></body></html>`], { type: "text/html" })
|
|
6
|
+
);
|
|
7
|
+
return s.set(e, [o, n]), r.set(e, n), n;
|
|
8
|
+
}, p = (e) => {
|
|
9
|
+
s.get(e)?.forEach?.((o) => URL.revokeObjectURL(o)), s.delete(e), r.delete(e);
|
|
10
|
+
}, g = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".jxl", ".avif"], c = i.map((e) => e.filename).filter((e) => g.some((o) => e.endsWith(o))).sort();
|
|
11
|
+
if (!c.length) throw new Error("No supported image files in archive");
|
|
12
|
+
const t = {};
|
|
13
|
+
return t.getCover = () => a(c[0]), t.metadata = { title: d.name }, t.sections = c.map((e) => ({
|
|
14
|
+
id: e,
|
|
15
|
+
load: () => f(e),
|
|
16
|
+
unload: () => p(e),
|
|
17
|
+
size: l(e)
|
|
18
|
+
})), t.toc = c.map((e) => ({ label: e, href: e })), t.rendition = { layout: "pre-paginated" }, t.resolveHref = (e) => ({ index: t.sections.findIndex((o) => o.id === e) }), t.splitTOCHref = (e) => [e, null], t.getTOCFragment = (e) => e.documentElement, t.destroy = () => {
|
|
19
|
+
for (const e of s.values())
|
|
20
|
+
for (const o of e) URL.revokeObjectURL(o);
|
|
21
|
+
}, t;
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
h as makeComicBook
|
|
25
|
+
};
|