vue-book-reader 1.0.9 → 1.1.1
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 -193
- package/lib/__vite-browser-external-DYxpcVy9.js +4 -0
- package/lib/{comic-book-D2H5riQt.js → comic-book-Ca6kYOxX.js} +12 -12
- package/lib/epub-CH-A6MLg.js +769 -0
- package/lib/fb2-DVOHQ19I.js +279 -0
- package/lib/fflate-x0QqQh-3.js +165 -0
- package/lib/fixed-layout-DBxRwLl0.js +219 -0
- package/lib/index-4W3UIPTc.js +1656 -0
- package/lib/mobi-DU7Vtu_y.js +1021 -0
- package/lib/paginator-C2tlv0vM.js +789 -0
- package/lib/pdf-7q5EPny6.js +13865 -0
- package/lib/search-CEqfrV9H.js +78 -0
- package/lib/tts-CgvtfEYe.js +228 -0
- package/lib/vue-book-reader.es.js +6 -4
- package/lib/vue-book-reader.umd.js +97 -571
- package/lib/{zip-FQL_v1pL.js → zip-eoP6P7MM.js} +294 -293
- package/package.json +8 -2
- package/lib/epub-TvZmxYCF.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-UYMDWtcl.js +0 -1185
- package/lib/mobi-BpkZoq9g.js +0 -1037
- 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/README.md
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img width=250 src="https://raw.githubusercontent.com/jinhuan138/vue--book-reader/master/public/logo.png" />
|
|
3
|
+
<h1>VueReader</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://www.npmjs.com/package/vue-book-reader" target="_blank">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/vue-book-reader?style=flat-square" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/vue-book-reader" target="_blank" >
|
|
11
|
+
<img src="https://img.shields.io/npm/dw/vue-book-reader?style=flat-square" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="./LICENSE">
|
|
14
|
+
<img src="https://img.shields.io/npm/l/vue-book-reader?style=flat-square" />
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<h2><a href="https://jinhuan138.github.io/vue-book-reader/">📖Documentation</a></h2>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Introduction
|
|
2
24
|
|
|
3
25
|
vue-book-reader is a vue wrapper for [foliate-js](https://github.com/johnfactotum/foliate-js) - library for rendering e-books in the browser.
|
|
4
26
|
Supports EPUB, MOBI, KF8 (AZW3), FB2, CBZ, PDF (experimental; requires PDF.js), or add support for other formats yourself by implementing the book interface
|
|
5
27
|
|
|
28
|
+
|
|
6
29
|
## Basic usage
|
|
7
30
|
|
|
8
31
|
```bash
|
|
@@ -36,198 +59,13 @@ import { VueReader } from 'vue-book-reader'
|
|
|
36
59
|
| **Name** | **Description** |
|
|
37
60
|
| -------- | ----------------------------------------------------------------------------------- |
|
|
38
61
|
| title | You have access to title by [slot](https://v3.vuejs.org/guide/component-slots.html) |
|
|
62
|
+
| loadingView | epub view loadingView |
|
|
39
63
|
|
|
40
|
-
##
|
|
41
|
-
|
|
42
|
-
## custom css
|
|
43
|
-
|
|
44
|
-
```vue
|
|
45
|
-
<template>
|
|
46
|
-
<vue-reader url="/files/梵高手稿.epub" :getRendition="getRendition">
|
|
47
|
-
</vue-reader>
|
|
48
|
-
</template>
|
|
49
|
-
|
|
50
|
-
<script setup>
|
|
51
|
-
import VueReader from 'vue-book-reader'
|
|
52
|
-
import { ref } from 'vue'
|
|
53
|
-
|
|
54
|
-
const getCSS = (style) => [
|
|
55
|
-
`
|
|
56
|
-
html {
|
|
57
|
-
background: #000;
|
|
58
|
-
color: #fff;
|
|
59
|
-
}`,
|
|
60
|
-
]
|
|
61
|
-
const getRendition = async (rendition) => {
|
|
62
|
-
const { book, renderer } = rendition
|
|
63
|
-
renderer.setStyles(getCSS())
|
|
64
|
-
}
|
|
65
|
-
</script>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Display a scrolled epub-view
|
|
69
|
-
|
|
70
|
-
```vue
|
|
71
|
-
<template>
|
|
72
|
-
<div style="height: 100vh">
|
|
73
|
-
<VueReader url="/files/啼笑因缘.mobi":getRendition="getRendition"/>
|
|
74
|
-
</div>
|
|
75
|
-
</template>
|
|
76
|
-
|
|
77
|
-
<script setup>
|
|
78
|
-
import VueReader from 'vue-book-reader'
|
|
79
|
-
|
|
80
|
-
const getRendition =(view)=>{
|
|
81
|
-
//scrolled or paginated
|
|
82
|
-
view?.renderer.setAttribute('flow', 'scrolled')
|
|
83
|
-
}
|
|
84
|
-
</script>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Import file
|
|
88
|
-
|
|
89
|
-
```vue
|
|
90
|
-
<template>
|
|
91
|
-
<div
|
|
92
|
-
style="height: 100vh; position: relative"
|
|
93
|
-
:style="{ height: url ? '100vh' : '50px' }"
|
|
94
|
-
>
|
|
95
|
-
<vue-reader v-if="url" :url="url" />
|
|
96
|
-
<input class="input" type="file" accept=".epub,.mobi,.azw3,.FB2,.CBZ,.PDF" @change="onchange" />
|
|
97
|
-
</div>
|
|
98
|
-
</template>
|
|
99
|
-
|
|
100
|
-
<script setup>
|
|
101
|
-
import VueReader from 'vue-book-reader'
|
|
102
|
-
import { ref } from 'vue'
|
|
103
|
-
|
|
104
|
-
const url = ref('')
|
|
105
|
-
const onchange = (e) => {
|
|
106
|
-
const file = e.target.files[0]
|
|
107
|
-
url.value = file
|
|
108
|
-
}
|
|
109
|
-
</script>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Current progress
|
|
113
|
-
|
|
114
|
-
```vue
|
|
115
|
-
<template>
|
|
116
|
-
<div style="height: 100vh; position: relative">
|
|
117
|
-
<vue-reader
|
|
118
|
-
url="/files/啼笑因缘.azw3"
|
|
119
|
-
:getRendition="getRendition"
|
|
120
|
-
@update:location="locationChange"
|
|
121
|
-
>
|
|
122
|
-
</vue-reader>
|
|
123
|
-
<div class="progress">
|
|
124
|
-
<input
|
|
125
|
-
type="number"
|
|
126
|
-
:value="current"
|
|
127
|
-
:min="0"
|
|
128
|
-
:max="100"
|
|
129
|
-
step="1"
|
|
130
|
-
@change="change"
|
|
131
|
-
/>%
|
|
132
|
-
<input
|
|
133
|
-
type="range"
|
|
134
|
-
:value="current"
|
|
135
|
-
:min="0"
|
|
136
|
-
:max="100"
|
|
137
|
-
:step="1"
|
|
138
|
-
@change="change"
|
|
139
|
-
/>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
</template>
|
|
143
|
-
|
|
144
|
-
<script setup>
|
|
145
|
-
import VueReader from 'vue-book-reader'
|
|
146
|
-
import { ref } from 'vue'
|
|
147
|
-
|
|
148
|
-
let view = null
|
|
149
|
-
const current = ref(0)
|
|
150
|
-
const change = (e) => {
|
|
151
|
-
const value = e.target.value
|
|
152
|
-
current.value = value
|
|
153
|
-
view.goToFraction(parseFloat(value / 100))
|
|
154
|
-
}
|
|
155
|
-
const getRendition = (val) => (view = val)
|
|
156
|
-
|
|
157
|
-
const locationChange = (detail) => {
|
|
158
|
-
const { fraction } = detail
|
|
159
|
-
const percent = Math.floor(fraction * 100)
|
|
160
|
-
current.value = percent
|
|
161
|
-
}
|
|
162
|
-
</script>
|
|
163
|
-
<style>
|
|
164
|
-
.progress {
|
|
165
|
-
position: absolute;
|
|
166
|
-
bottom: 1rem;
|
|
167
|
-
right: 1rem;
|
|
168
|
-
left: 1rem;
|
|
169
|
-
z-index: 1;
|
|
170
|
-
color: #000;
|
|
171
|
-
display: flex;
|
|
172
|
-
flex-wrap: wrap;
|
|
173
|
-
justify-content: center;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.progress > input[type='number'] {
|
|
177
|
-
text-align: center;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.progress > input[type='range'] {
|
|
181
|
-
width: 100%;
|
|
182
|
-
}
|
|
183
|
-
</style>
|
|
184
|
-
|
|
185
|
-
```
|
|
64
|
+
## EpubView Exposes
|
|
186
65
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
url="/files/啼笑因缘.azw3"
|
|
193
|
-
:getRendition="getRendition"
|
|
194
|
-
v-show="false"
|
|
195
|
-
>
|
|
196
|
-
</vue-reader>
|
|
197
|
-
<div v-if="information" style="color: #000">
|
|
198
|
-
<img
|
|
199
|
-
:src="information.cover"
|
|
200
|
-
:alt="information.title"
|
|
201
|
-
style="width: 100px"
|
|
202
|
-
/>
|
|
203
|
-
<p>标题:{{ information.title }}</p>
|
|
204
|
-
<p>作者:{{ information.author }}</p>
|
|
205
|
-
<p>出版社:{{ information.publisher }}</p>
|
|
206
|
-
<p>语言:{{ information.language }}</p>
|
|
207
|
-
<p>出版日期:{{ information.published }}</p>
|
|
208
|
-
<p>介绍:{{ information.description }}</p>
|
|
209
|
-
</div>
|
|
210
|
-
</template>
|
|
211
|
-
|
|
212
|
-
<script setup>
|
|
213
|
-
import VueReader from 'vue-book-reader'
|
|
214
|
-
import { ref } from 'vue'
|
|
215
|
-
|
|
216
|
-
const information = ref(null)
|
|
217
|
-
const getRendition = (rendition) => {
|
|
218
|
-
const { book } = rendition
|
|
219
|
-
const { author } = book.metadata
|
|
220
|
-
const bookAuthor =
|
|
221
|
-
typeof author === 'string'
|
|
222
|
-
? author
|
|
223
|
-
: author
|
|
224
|
-
?.map((author) => (typeof author === 'string' ? author : author.name))
|
|
225
|
-
?.join(', ') ?? ''
|
|
226
|
-
information.value = { ...book.metadata, author: bookAuthor }
|
|
227
|
-
book.getCover?.().then((blob) => {
|
|
228
|
-
information.value.cover = URL.createObjectURL(blob)
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
</script>
|
|
232
|
-
```
|
|
66
|
+
| **Name** | **Description** | **Type** |
|
|
67
|
+
| ----------- | ---------------------- | ---------------- |
|
|
68
|
+
| nextPage | display next page | `function` |
|
|
69
|
+
| prevPage | display previous page | `function` |
|
|
70
|
+
| setLocation | Set the page | `function(href)` |
|
|
233
71
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
const s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(),
|
|
1
|
+
const u = ({ entries: i, loadBlob: a, getSize: l }, d) => {
|
|
2
|
+
const s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = async (e) => {
|
|
3
3
|
if (s.has(e))
|
|
4
4
|
return s.get(e);
|
|
5
|
-
const t = URL.createObjectURL(await
|
|
6
|
-
new Blob([
|
|
5
|
+
const t = URL.createObjectURL(await a(e)), r = URL.createObjectURL(
|
|
6
|
+
new Blob([`<!DOCTYPE html><html><head><meta charset="utf-8"></head><body style="margin: 0"><img src="${t}"></body></html>`], { type: "text/html" })
|
|
7
7
|
);
|
|
8
8
|
return c.set(e, [t, r]), s.set(e, r), r;
|
|
9
|
-
},
|
|
9
|
+
}, p = (e) => {
|
|
10
10
|
var t, r;
|
|
11
|
-
(r = (t = c.get(e)) == null ? void 0 : t.forEach) == null || r.call(t, (
|
|
12
|
-
}, g = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".jxl", ".avif"], n =
|
|
11
|
+
(r = (t = c.get(e)) == null ? void 0 : t.forEach) == null || r.call(t, (h) => URL.revokeObjectURL(h)), c.delete(e), s.delete(e);
|
|
12
|
+
}, g = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".jxl", ".avif"], n = i.map((e) => e.filename).filter((e) => g.some((t) => e.endsWith(t))).sort();
|
|
13
13
|
if (!n.length)
|
|
14
14
|
throw new Error("No supported image files in archive");
|
|
15
15
|
const o = {};
|
|
16
|
-
return o.getCover = () =>
|
|
16
|
+
return o.getCover = () => a(n[0]), o.metadata = { title: d.name }, o.sections = n.map((e) => ({
|
|
17
17
|
id: e,
|
|
18
|
-
load: () =>
|
|
19
|
-
unload: () =>
|
|
20
|
-
size:
|
|
18
|
+
load: () => f(e),
|
|
19
|
+
unload: () => p(e),
|
|
20
|
+
size: l(e)
|
|
21
21
|
})), o.toc = n.map((e) => ({ label: e, href: e })), o.rendition = { layout: "pre-paginated" }, o.resolveHref = (e) => ({ index: o.sections.findIndex((t) => t.id === e) }), o.splitTOCHref = (e) => [e, null], o.getTOCFragment = (e) => e.documentElement, o.destroy = () => {
|
|
22
22
|
for (const e of c.values())
|
|
23
23
|
for (const t of e)
|
|
@@ -25,5 +25,5 @@ const h = ({ entries: l, loadBlob: i, getSize: a }, p) => {
|
|
|
25
25
|
}, o;
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
u as makeComicBook
|
|
29
29
|
};
|