@likecoin/epub-ts 0.4.8 → 0.5.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/dist/book.d.ts +6 -0
- package/dist/contents.d.ts +7 -12
- package/dist/epub.cjs +3 -3
- package/dist/epub.cjs.map +1 -1
- package/dist/epub.js +933 -922
- package/dist/epub.js.map +1 -1
- package/dist/epub.node.cjs +3 -3
- package/dist/epub.node.cjs.map +1 -1
- package/dist/epub.node.js +872 -863
- package/dist/epub.node.js.map +1 -1
- package/dist/epub.umd.js +3 -3
- package/dist/epub.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/locations.d.ts +1 -1
- package/dist/managers/continuous/index.d.ts +1 -3
- package/dist/managers/default/index.d.ts +0 -9
- package/dist/store.d.ts +1 -2
- package/dist/types.d.ts +0 -5
- package/dist/utils/core.d.ts +19 -9
- package/dist/utils/queue.d.ts +1 -1
- package/package.json +1 -1
package/dist/epub.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
function P(
|
|
3
|
-
const t = typeof
|
|
1
|
+
import ee from "jszip";
|
|
2
|
+
function P(a) {
|
|
3
|
+
const t = typeof a == "function" ? a.prototype : a;
|
|
4
4
|
return t.on = function(e, i) {
|
|
5
5
|
return this.__listeners || (this.__listeners = {}), this.__listeners[e] || (this.__listeners[e] = []), this.__listeners[e].push(i), this;
|
|
6
6
|
}, t.off = function(e, i) {
|
|
@@ -12,17 +12,17 @@ function P(l) {
|
|
|
12
12
|
const s = this.__listeners[e].slice();
|
|
13
13
|
for (let n = 0; n < s.length; n++)
|
|
14
14
|
s[n](...i);
|
|
15
|
-
},
|
|
15
|
+
}, a;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
let
|
|
17
|
+
const xt = (a) => (Promise.resolve().then(() => a(performance.now())), 0), Dt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : xt, ie = 1, se = 3, Bt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
|
|
18
|
+
function Et() {
|
|
19
|
+
let a = (/* @__PURE__ */ new Date()).getTime();
|
|
20
20
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
21
|
-
const i = (
|
|
22
|
-
return
|
|
21
|
+
const i = (a + Math.random() * 16) % 16 | 0;
|
|
22
|
+
return a = Math.floor(a / 16), (e === "x" ? i : i & 7 | 8).toString(16);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ne() {
|
|
26
26
|
return Math.max(
|
|
27
27
|
document.documentElement.clientHeight,
|
|
28
28
|
document.body.scrollHeight,
|
|
@@ -31,64 +31,55 @@ function ie() {
|
|
|
31
31
|
document.documentElement.offsetHeight
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return !!(
|
|
34
|
+
function Mt(a) {
|
|
35
|
+
return !!(a && a.nodeType === 1);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return !isNaN(parseFloat(
|
|
37
|
+
function x(a) {
|
|
38
|
+
return !isNaN(parseFloat(a)) && isFinite(a);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const t = parseFloat(
|
|
42
|
-
return
|
|
40
|
+
function Wt(a) {
|
|
41
|
+
const t = parseFloat(a);
|
|
42
|
+
return x(a) === !1 ? !1 : typeof a == "string" && a.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t = ["Webkit", "webkit", "Moz", "O", "ms"], e = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"], i = l.toLowerCase(), s = t.length;
|
|
46
|
-
if (typeof document > "u" || i in document.body.style)
|
|
47
|
-
return l;
|
|
48
|
-
for (let n = 0; n < s; n++)
|
|
49
|
-
if (e[n] + i in document.body.style)
|
|
50
|
-
return e[n] + i;
|
|
51
|
-
return l;
|
|
52
|
-
}
|
|
53
|
-
function Bt(l, ...t) {
|
|
44
|
+
function qt(a, ...t) {
|
|
54
45
|
for (let e = 0; e < t.length; e++) {
|
|
55
46
|
const i = t[e];
|
|
56
47
|
for (const s in i)
|
|
57
|
-
|
|
48
|
+
a[s] === void 0 && (a[s] = i[s]);
|
|
58
49
|
}
|
|
59
|
-
return
|
|
50
|
+
return a;
|
|
60
51
|
}
|
|
61
|
-
function C(
|
|
52
|
+
function C(a, ...t) {
|
|
62
53
|
return t.forEach(function(e) {
|
|
63
54
|
e && Object.getOwnPropertyNames(e).forEach(function(i) {
|
|
64
|
-
Object.defineProperty(
|
|
55
|
+
Object.defineProperty(a, i, Object.getOwnPropertyDescriptor(e, i));
|
|
65
56
|
});
|
|
66
|
-
}),
|
|
57
|
+
}), a;
|
|
67
58
|
}
|
|
68
|
-
function
|
|
69
|
-
const i =
|
|
70
|
-
return t.splice(i, 0,
|
|
59
|
+
function re(a, t, e) {
|
|
60
|
+
const i = V(a, t, e);
|
|
61
|
+
return t.splice(i, 0, a), i;
|
|
71
62
|
}
|
|
72
|
-
function
|
|
63
|
+
function V(a, t, e, i, s) {
|
|
73
64
|
const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
|
|
74
|
-
if (e || (e = function(
|
|
75
|
-
return
|
|
65
|
+
if (e || (e = function(l, c) {
|
|
66
|
+
return l > c ? 1 : l < c ? -1 : 0;
|
|
76
67
|
}), r - n <= 0)
|
|
77
68
|
return o;
|
|
78
|
-
const h = e(t[o],
|
|
79
|
-
return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ?
|
|
69
|
+
const h = e(t[o], a);
|
|
70
|
+
return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? V(a, t, e, o, r) : V(a, t, e, n, o);
|
|
80
71
|
}
|
|
81
|
-
function Q(
|
|
72
|
+
function Q(a, t, e, i, s) {
|
|
82
73
|
const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
|
|
83
|
-
if (e || (e = function(
|
|
84
|
-
return
|
|
74
|
+
if (e || (e = function(l, c) {
|
|
75
|
+
return l > c ? 1 : l < c ? -1 : 0;
|
|
85
76
|
}), r - n <= 0)
|
|
86
77
|
return -1;
|
|
87
|
-
const h = e(t[o],
|
|
88
|
-
return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? Q(
|
|
78
|
+
const h = e(t[o], a);
|
|
79
|
+
return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? Q(a, t, e, o, r) : Q(a, t, e, n, o);
|
|
89
80
|
}
|
|
90
|
-
function
|
|
91
|
-
const t = window.getComputedStyle(
|
|
81
|
+
function K(a) {
|
|
82
|
+
const t = window.getComputedStyle(a), e = ["width", "padding-right", "padding-left", "margin-right", "margin-left", "border-right-width", "border-left-width"], i = ["height", "padding-top", "padding-bottom", "margin-top", "margin-bottom", "border-top-width", "border-bottom-width"];
|
|
92
83
|
let s = 0, n = 0;
|
|
93
84
|
return e.forEach(function(r) {
|
|
94
85
|
s += parseFloat(t.getPropertyValue(r)) || 0;
|
|
@@ -99,8 +90,8 @@ function Z(l) {
|
|
|
99
90
|
width: s
|
|
100
91
|
};
|
|
101
92
|
}
|
|
102
|
-
function
|
|
103
|
-
const t = window.getComputedStyle(
|
|
93
|
+
function J(a) {
|
|
94
|
+
const t = window.getComputedStyle(a), e = ["padding-right", "padding-left", "margin-right", "margin-left", "border-right-width", "border-left-width"], i = ["padding-top", "padding-bottom", "margin-top", "margin-bottom", "border-top-width", "border-bottom-width"];
|
|
104
95
|
let s = 0, n = 0;
|
|
105
96
|
return e.forEach(function(r) {
|
|
106
97
|
s += parseFloat(t.getPropertyValue(r)) || 0;
|
|
@@ -111,143 +102,151 @@ function tt(l) {
|
|
|
111
102
|
width: s
|
|
112
103
|
};
|
|
113
104
|
}
|
|
114
|
-
function
|
|
105
|
+
function ft(a) {
|
|
115
106
|
let t;
|
|
116
|
-
const e =
|
|
117
|
-
if (
|
|
107
|
+
const e = a.ownerDocument;
|
|
108
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
118
109
|
const i = e.createRange();
|
|
119
|
-
i.selectNodeContents(
|
|
110
|
+
i.selectNodeContents(a), t = i.getBoundingClientRect();
|
|
120
111
|
} else
|
|
121
|
-
t =
|
|
112
|
+
t = a.getBoundingClientRect();
|
|
122
113
|
return t;
|
|
123
114
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
115
|
+
function pt() {
|
|
116
|
+
const a = window.innerWidth, t = window.innerHeight;
|
|
126
117
|
return {
|
|
127
118
|
top: 0,
|
|
128
119
|
left: 0,
|
|
129
|
-
right:
|
|
120
|
+
right: a,
|
|
130
121
|
bottom: t,
|
|
131
|
-
width:
|
|
122
|
+
width: a,
|
|
132
123
|
height: t
|
|
133
124
|
};
|
|
134
125
|
}
|
|
135
|
-
function St(
|
|
136
|
-
const i =
|
|
126
|
+
function St(a, t) {
|
|
127
|
+
const i = a.parentNode.childNodes;
|
|
137
128
|
let s, n = -1;
|
|
138
|
-
for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s
|
|
129
|
+
for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s !== a); r++)
|
|
139
130
|
;
|
|
140
131
|
return n;
|
|
141
132
|
}
|
|
142
|
-
function
|
|
143
|
-
return St(
|
|
133
|
+
function oe(a) {
|
|
134
|
+
return St(a, se);
|
|
135
|
+
}
|
|
136
|
+
function Ut(a) {
|
|
137
|
+
return St(a, ie);
|
|
144
138
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
139
|
+
function _t(a) {
|
|
140
|
+
return ["xml", "opf", "ncx"].indexOf(a) > -1;
|
|
147
141
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
142
|
+
function Ct(a, t) {
|
|
143
|
+
return t === "json" ? JSON.parse(a) : t && _t(t) ? W(a, "text/xml") : t === "xhtml" ? W(a, "application/xhtml+xml") : t === "html" || t === "htm" ? W(a, "text/html") : a;
|
|
150
144
|
}
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
class q extends Error {
|
|
146
|
+
constructor(t, e) {
|
|
147
|
+
super(t), this.name = "EpubError", this.status = e;
|
|
148
|
+
}
|
|
153
149
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
return Pt.createObjectURL(e);
|
|
150
|
+
function jt(a, t) {
|
|
151
|
+
return new Blob([a], { type: t });
|
|
157
152
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
153
|
+
function tt(a, t) {
|
|
154
|
+
const e = jt(a, t);
|
|
155
|
+
return Bt.createObjectURL(e);
|
|
160
156
|
}
|
|
161
|
-
function
|
|
162
|
-
|
|
157
|
+
function Tt(a) {
|
|
158
|
+
return Bt.revokeObjectURL(a);
|
|
159
|
+
}
|
|
160
|
+
function gt(a, t) {
|
|
161
|
+
if (typeof a != "string")
|
|
163
162
|
return;
|
|
164
|
-
const e = btoa(
|
|
163
|
+
const e = btoa(a);
|
|
165
164
|
return "data:" + t + ";base64," + e;
|
|
166
165
|
}
|
|
167
|
-
function
|
|
168
|
-
return Object.prototype.toString.call(
|
|
166
|
+
function Ft(a) {
|
|
167
|
+
return Object.prototype.toString.call(a).slice(8, -1);
|
|
169
168
|
}
|
|
170
|
-
function
|
|
171
|
-
return
|
|
169
|
+
function W(a, t) {
|
|
170
|
+
return a.charCodeAt(0) === 65279 && (a = a.slice(1)), new DOMParser().parseFromString(a, t);
|
|
172
171
|
}
|
|
173
|
-
function
|
|
174
|
-
if (!
|
|
172
|
+
function w(a, t) {
|
|
173
|
+
if (!a)
|
|
175
174
|
throw new Error("No Element Provided");
|
|
176
|
-
return
|
|
175
|
+
return a.querySelector(t);
|
|
177
176
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
177
|
+
function B(a, t) {
|
|
178
|
+
return a.querySelectorAll(t);
|
|
180
179
|
}
|
|
181
|
-
function j(
|
|
180
|
+
function j(a, t, e) {
|
|
182
181
|
t += "[";
|
|
183
182
|
for (const i in e)
|
|
184
183
|
t += i + "~='" + e[i] + "'";
|
|
185
|
-
return t += "]",
|
|
184
|
+
return t += "]", a.querySelector(t) ?? void 0;
|
|
186
185
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
186
|
+
function et(a, t) {
|
|
187
|
+
Vt(a, t, NodeFilter.SHOW_TEXT);
|
|
189
188
|
}
|
|
190
|
-
function
|
|
191
|
-
const i = document.createTreeWalker(
|
|
189
|
+
function Vt(a, t, e) {
|
|
190
|
+
const i = document.createTreeWalker(a, e, null);
|
|
192
191
|
let s;
|
|
193
192
|
for (; s = i.nextNode(); )
|
|
194
193
|
t(s);
|
|
195
194
|
}
|
|
196
|
-
function
|
|
197
|
-
if (t(
|
|
195
|
+
function Ht(a, t, e) {
|
|
196
|
+
if (t(a))
|
|
198
197
|
return !0;
|
|
199
|
-
let i =
|
|
198
|
+
let i = a.firstChild;
|
|
200
199
|
if (i)
|
|
201
200
|
do {
|
|
202
|
-
if (
|
|
201
|
+
if (Ht(i, t))
|
|
203
202
|
return !0;
|
|
204
203
|
i = i.nextSibling;
|
|
205
204
|
} while (i);
|
|
206
205
|
}
|
|
207
|
-
function
|
|
206
|
+
function Xt(a) {
|
|
208
207
|
return new Promise(function(t, e) {
|
|
209
208
|
const i = new FileReader();
|
|
210
|
-
i.readAsDataURL(
|
|
209
|
+
i.readAsDataURL(a), i.onloadend = function() {
|
|
211
210
|
t(i.result);
|
|
212
211
|
};
|
|
213
212
|
});
|
|
214
213
|
}
|
|
215
|
-
class
|
|
214
|
+
class S {
|
|
216
215
|
constructor() {
|
|
217
|
-
this.
|
|
216
|
+
this.promise = new Promise((t, e) => {
|
|
218
217
|
this.resolve = t, this.reject = e;
|
|
219
|
-
})
|
|
218
|
+
});
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
|
-
function
|
|
221
|
+
function it(a, t, e) {
|
|
223
222
|
let i = null;
|
|
224
223
|
try {
|
|
225
|
-
i =
|
|
224
|
+
i = a.querySelector(`${t}[*|type="${e}"]`);
|
|
226
225
|
} catch {
|
|
227
226
|
}
|
|
228
227
|
if (i)
|
|
229
228
|
return i;
|
|
230
|
-
const s =
|
|
229
|
+
const s = a.querySelectorAll(t);
|
|
231
230
|
for (let n = 0; n < s.length; n++)
|
|
232
231
|
if (s[n].getAttributeNS("http://www.idpf.org/2007/ops", "type") === e || s[n].getAttribute("epub:type") === e)
|
|
233
232
|
return s[n];
|
|
234
233
|
}
|
|
235
|
-
function
|
|
236
|
-
const t = [], e =
|
|
234
|
+
function mt(a) {
|
|
235
|
+
const t = [], e = a.childNodes;
|
|
237
236
|
for (let i = 0; i < e.length; i++) {
|
|
238
237
|
const s = e[i];
|
|
239
238
|
s.nodeType === 1 && t.push(s);
|
|
240
239
|
}
|
|
241
240
|
return t;
|
|
242
241
|
}
|
|
243
|
-
function
|
|
242
|
+
function vt(a) {
|
|
244
243
|
const t = [];
|
|
245
|
-
for (let e =
|
|
244
|
+
for (let e = a ?? null; e; e = e.parentNode)
|
|
246
245
|
t.unshift(e);
|
|
247
246
|
return t;
|
|
248
247
|
}
|
|
249
|
-
function F(
|
|
250
|
-
const i = [], s =
|
|
248
|
+
function F(a, t, e) {
|
|
249
|
+
const i = [], s = a.childNodes;
|
|
251
250
|
for (let n = 0; n < s.length; n++) {
|
|
252
251
|
const r = s[n];
|
|
253
252
|
if (r.nodeType === 1 && r.nodeName.toLowerCase() === t) {
|
|
@@ -259,16 +258,16 @@ function F(l, t, e) {
|
|
|
259
258
|
if (!e)
|
|
260
259
|
return i;
|
|
261
260
|
}
|
|
262
|
-
function
|
|
261
|
+
function he(a, t) {
|
|
263
262
|
let e;
|
|
264
|
-
if (!(
|
|
265
|
-
for (e =
|
|
263
|
+
if (!(a === null || t === ""))
|
|
264
|
+
for (e = a.parentNode; e && e.nodeType === 1; ) {
|
|
266
265
|
if (e.tagName.toLowerCase() === t)
|
|
267
266
|
return e;
|
|
268
267
|
e = e.parentNode;
|
|
269
268
|
}
|
|
270
269
|
}
|
|
271
|
-
class
|
|
270
|
+
class Yt {
|
|
272
271
|
constructor() {
|
|
273
272
|
this.collapsed = !1, this.commonAncestorContainer = void 0, this.endContainer = void 0, this.endOffset = void 0, this.startContainer = void 0, this.startOffset = void 0;
|
|
274
273
|
}
|
|
@@ -291,10 +290,10 @@ class Vt {
|
|
|
291
290
|
this.setStart(t, 0), this.setEnd(t, e);
|
|
292
291
|
}
|
|
293
292
|
_commonAncestorContainer(t, e) {
|
|
294
|
-
const i =
|
|
295
|
-
if (i[0]
|
|
293
|
+
const i = vt(t ?? this.startContainer), s = vt(e ?? this.endContainer);
|
|
294
|
+
if (i[0] === s[0]) {
|
|
296
295
|
for (let n = 0; n < i.length; n++)
|
|
297
|
-
if (i[n]
|
|
296
|
+
if (i[n] !== s[n])
|
|
298
297
|
return i[n - 1];
|
|
299
298
|
}
|
|
300
299
|
}
|
|
@@ -305,58 +304,60 @@ class Vt {
|
|
|
305
304
|
return "";
|
|
306
305
|
}
|
|
307
306
|
}
|
|
308
|
-
const
|
|
307
|
+
const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
309
308
|
__proto__: null,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
309
|
+
EpubError: q,
|
|
310
|
+
RangeObject: Yt,
|
|
311
|
+
blob2base64: Xt,
|
|
312
|
+
borders: J,
|
|
313
|
+
bounds: K,
|
|
314
|
+
createBase64Url: gt,
|
|
315
|
+
createBlob: jt,
|
|
316
|
+
createBlobUrl: tt,
|
|
317
|
+
defaults: qt,
|
|
318
|
+
defer: S,
|
|
319
|
+
documentHeight: ne,
|
|
320
320
|
extend: C,
|
|
321
321
|
filterChildren: F,
|
|
322
|
-
findChildren:
|
|
323
|
-
getParentByTagName:
|
|
324
|
-
|
|
322
|
+
findChildren: mt,
|
|
323
|
+
getParentByTagName: he,
|
|
324
|
+
handleResponse: Ct,
|
|
325
|
+
indexOfElementNode: Ut,
|
|
325
326
|
indexOfNode: St,
|
|
326
327
|
indexOfSorted: Q,
|
|
327
|
-
indexOfTextNode:
|
|
328
|
-
insert:
|
|
329
|
-
isElement:
|
|
330
|
-
isFloat:
|
|
331
|
-
isNumber:
|
|
332
|
-
isXml:
|
|
333
|
-
locationOf:
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
qs:
|
|
339
|
-
qsa:
|
|
328
|
+
indexOfTextNode: oe,
|
|
329
|
+
insert: re,
|
|
330
|
+
isElement: Mt,
|
|
331
|
+
isFloat: Wt,
|
|
332
|
+
isNumber: x,
|
|
333
|
+
isXml: _t,
|
|
334
|
+
locationOf: V,
|
|
335
|
+
microTick: xt,
|
|
336
|
+
nodeBounds: ft,
|
|
337
|
+
parents: vt,
|
|
338
|
+
parse: W,
|
|
339
|
+
qs: w,
|
|
340
|
+
qsa: B,
|
|
340
341
|
qsp: j,
|
|
341
|
-
querySelectorByType:
|
|
342
|
-
requestAnimationFrame:
|
|
343
|
-
revokeBlobUrl:
|
|
344
|
-
sprint:
|
|
345
|
-
treeWalker:
|
|
346
|
-
type:
|
|
347
|
-
uuid:
|
|
348
|
-
walk:
|
|
349
|
-
windowBounds:
|
|
342
|
+
querySelectorByType: it,
|
|
343
|
+
requestAnimationFrame: Dt,
|
|
344
|
+
revokeBlobUrl: Tt,
|
|
345
|
+
sprint: et,
|
|
346
|
+
treeWalker: Vt,
|
|
347
|
+
type: Ft,
|
|
348
|
+
uuid: Et,
|
|
349
|
+
walk: Ht,
|
|
350
|
+
windowBounds: pt
|
|
350
351
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
351
|
-
function
|
|
352
|
-
if (typeof
|
|
353
|
-
throw new TypeError("Path must be a string. Received " +
|
|
352
|
+
function H(a) {
|
|
353
|
+
if (typeof a != "string")
|
|
354
|
+
throw new TypeError("Path must be a string. Received " + a);
|
|
354
355
|
}
|
|
355
|
-
function
|
|
356
|
+
function le(a, t) {
|
|
356
357
|
let e = "", i = -1, s = 0, n;
|
|
357
|
-
for (let r = 0; r <=
|
|
358
|
-
if (r <
|
|
359
|
-
n =
|
|
358
|
+
for (let r = 0; r <= a.length; ++r) {
|
|
359
|
+
if (r < a.length)
|
|
360
|
+
n = a.charCodeAt(r);
|
|
360
361
|
else {
|
|
361
362
|
if (n === 47)
|
|
362
363
|
break;
|
|
@@ -381,32 +382,32 @@ function he(l, t) {
|
|
|
381
382
|
}
|
|
382
383
|
t && (e.length > 0 ? e += "/.." : e = "..");
|
|
383
384
|
} else
|
|
384
|
-
e.length > 0 ? e += "/" +
|
|
385
|
+
e.length > 0 ? e += "/" + a.slice(i + 1, r) : e = a.slice(i + 1, r);
|
|
385
386
|
i = r, s = 0;
|
|
386
387
|
} else n === 46 && s !== -1 ? ++s : s = -1;
|
|
387
388
|
}
|
|
388
389
|
return e;
|
|
389
390
|
}
|
|
390
|
-
function
|
|
391
|
+
function yt(...a) {
|
|
391
392
|
let t = "", e = !1;
|
|
392
|
-
for (let i =
|
|
393
|
-
const s = i >= 0 ?
|
|
394
|
-
|
|
393
|
+
for (let i = a.length - 1; i >= -1 && !e; i--) {
|
|
394
|
+
const s = i >= 0 ? a[i] : "/";
|
|
395
|
+
H(s), s.length !== 0 && (t = s + "/" + t, e = s.charCodeAt(0) === 47);
|
|
395
396
|
}
|
|
396
|
-
return t =
|
|
397
|
+
return t = le(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
|
|
397
398
|
}
|
|
398
|
-
function
|
|
399
|
-
if (
|
|
399
|
+
function ce(a, t) {
|
|
400
|
+
if (H(a), H(t), a === t || (a = yt(a), t = yt(t), a === t))
|
|
400
401
|
return "";
|
|
401
402
|
let e = 1;
|
|
402
|
-
for (; e <
|
|
403
|
+
for (; e < a.length && a.charCodeAt(e) === 47; ++e)
|
|
403
404
|
;
|
|
404
|
-
const i =
|
|
405
|
+
const i = a.length, s = i - e;
|
|
405
406
|
let n = 1;
|
|
406
407
|
for (; n < t.length && t.charCodeAt(n) === 47; ++n)
|
|
407
408
|
;
|
|
408
409
|
const o = t.length - n, h = s < o ? s : o;
|
|
409
|
-
let
|
|
410
|
+
let l = -1, c = 0;
|
|
410
411
|
for (; c <= h; ++c) {
|
|
411
412
|
if (c === h) {
|
|
412
413
|
if (o > h) {
|
|
@@ -414,62 +415,62 @@ function le(l, t) {
|
|
|
414
415
|
return t.slice(n + c + 1);
|
|
415
416
|
if (c === 0)
|
|
416
417
|
return t.slice(n + c);
|
|
417
|
-
} else s > h && (
|
|
418
|
+
} else s > h && (a.charCodeAt(e + c) === 47 ? l = c : c === 0 && (l = 0));
|
|
418
419
|
break;
|
|
419
420
|
}
|
|
420
|
-
const u =
|
|
421
|
+
const u = a.charCodeAt(e + c), p = t.charCodeAt(n + c);
|
|
421
422
|
if (u !== p)
|
|
422
423
|
break;
|
|
423
|
-
u === 47 && (
|
|
424
|
+
u === 47 && (l = c);
|
|
424
425
|
}
|
|
425
426
|
let d = "";
|
|
426
|
-
for (c = e +
|
|
427
|
-
(c === i ||
|
|
428
|
-
return d.length > 0 ? d + t.slice(n +
|
|
427
|
+
for (c = e + l + 1; c <= i; ++c)
|
|
428
|
+
(c === i || a.charCodeAt(c) === 47) && (d.length === 0 ? d += ".." : d += "/..");
|
|
429
|
+
return d.length > 0 ? d + t.slice(n + l) : (n += l, t.charCodeAt(n) === 47 && ++n, t.slice(n));
|
|
429
430
|
}
|
|
430
|
-
function
|
|
431
|
-
if (
|
|
431
|
+
function de(a) {
|
|
432
|
+
if (H(a), a.length === 0)
|
|
432
433
|
return ".";
|
|
433
|
-
let t =
|
|
434
|
+
let t = a.charCodeAt(0);
|
|
434
435
|
const e = t === 47;
|
|
435
436
|
let i = -1, s = !0;
|
|
436
|
-
for (let n =
|
|
437
|
-
if (t =
|
|
437
|
+
for (let n = a.length - 1; n >= 1; --n)
|
|
438
|
+
if (t = a.charCodeAt(n), t === 47) {
|
|
438
439
|
if (!s) {
|
|
439
440
|
i = n;
|
|
440
441
|
break;
|
|
441
442
|
}
|
|
442
443
|
} else
|
|
443
444
|
s = !1;
|
|
444
|
-
return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" :
|
|
445
|
+
return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" : a.slice(0, i);
|
|
445
446
|
}
|
|
446
|
-
function
|
|
447
|
-
return
|
|
447
|
+
function ue(a) {
|
|
448
|
+
return H(a), a.length > 0 && a.charCodeAt(0) === 47;
|
|
448
449
|
}
|
|
449
|
-
function
|
|
450
|
-
|
|
450
|
+
function fe(a) {
|
|
451
|
+
H(a);
|
|
451
452
|
const t = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
452
|
-
if (
|
|
453
|
+
if (a.length === 0)
|
|
453
454
|
return t;
|
|
454
|
-
let e =
|
|
455
|
+
let e = a.charCodeAt(0);
|
|
455
456
|
const i = e === 47;
|
|
456
457
|
let s;
|
|
457
458
|
i ? (t.root = "/", s = 1) : s = 0;
|
|
458
|
-
let n = -1, r = 0, o = -1, h = !0,
|
|
459
|
-
for (;
|
|
460
|
-
if (e =
|
|
459
|
+
let n = -1, r = 0, o = -1, h = !0, l = a.length - 1, c = 0;
|
|
460
|
+
for (; l >= s; --l) {
|
|
461
|
+
if (e = a.charCodeAt(l), e === 47) {
|
|
461
462
|
if (!h) {
|
|
462
|
-
r =
|
|
463
|
+
r = l + 1;
|
|
463
464
|
break;
|
|
464
465
|
}
|
|
465
466
|
continue;
|
|
466
467
|
}
|
|
467
|
-
o === -1 && (h = !1, o =
|
|
468
|
+
o === -1 && (h = !1, o = l + 1), e === 46 ? n === -1 ? n = l : c !== 1 && (c = 1) : n !== -1 && (c = -1);
|
|
468
469
|
}
|
|
469
|
-
return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === r + 1 ? o !== -1 && (r === 0 && i ? t.base = t.name =
|
|
470
|
+
return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === r + 1 ? o !== -1 && (r === 0 && i ? t.base = t.name = a.slice(1, o) : t.base = t.name = a.slice(r, o)) : (r === 0 && i ? (t.name = a.slice(1, n), t.base = a.slice(1, o)) : (t.name = a.slice(r, n), t.base = a.slice(r, o)), t.ext = a.slice(n, o)), r > 0 ? t.dir = a.slice(0, r - 1) : i && (t.dir = "/"), t;
|
|
470
471
|
}
|
|
471
|
-
const
|
|
472
|
-
class
|
|
472
|
+
const D = { resolve: yt, relative: ce, dirname: de, isAbsolute: ue, parse: fe };
|
|
473
|
+
class O {
|
|
473
474
|
constructor(t) {
|
|
474
475
|
t.indexOf("://") > -1 && (t = new URL(t).pathname);
|
|
475
476
|
const i = this.parse(t);
|
|
@@ -481,14 +482,14 @@ class z {
|
|
|
481
482
|
* @returns {object}
|
|
482
483
|
*/
|
|
483
484
|
parse(t) {
|
|
484
|
-
return
|
|
485
|
+
return D.parse(t);
|
|
485
486
|
}
|
|
486
487
|
/**
|
|
487
488
|
* @param {string} what
|
|
488
489
|
* @returns {boolean}
|
|
489
490
|
*/
|
|
490
491
|
isAbsolute(t) {
|
|
491
|
-
return
|
|
492
|
+
return D.isAbsolute(t || this.path);
|
|
492
493
|
}
|
|
493
494
|
/**
|
|
494
495
|
* Check if path ends with a directory
|
|
@@ -506,7 +507,7 @@ class z {
|
|
|
506
507
|
* @returns {string} resolved
|
|
507
508
|
*/
|
|
508
509
|
resolve(t) {
|
|
509
|
-
return
|
|
510
|
+
return D.resolve(this.directory, t);
|
|
510
511
|
}
|
|
511
512
|
/**
|
|
512
513
|
* Resolve a path relative to the directory of the Path
|
|
@@ -516,7 +517,7 @@ class z {
|
|
|
516
517
|
* @returns {string} relative
|
|
517
518
|
*/
|
|
518
519
|
relative(t) {
|
|
519
|
-
return t && t.indexOf("://") > -1 ? t :
|
|
520
|
+
return t && t.indexOf("://") > -1 ? t : D.relative(this.directory, t);
|
|
520
521
|
}
|
|
521
522
|
/**
|
|
522
523
|
* Return the path string
|
|
@@ -534,9 +535,9 @@ class R {
|
|
|
534
535
|
try {
|
|
535
536
|
this.base ? this.Url = new URL(t, this.base) : this.Url = new URL(t), this.href = this.Url.href, this.protocol = this.Url.protocol, this.origin = this.Url.origin, this.origin === "null" && this.protocol === "file:" && (this.origin = "file://"), this.hash = this.Url.hash, this.search = this.Url.search, s = this.Url.pathname + (this.Url.search ? this.Url.search : "");
|
|
536
537
|
} catch {
|
|
537
|
-
this.Url = void 0, this.base && (n = new
|
|
538
|
+
this.Url = void 0, this.base && (n = new O(this.base), s = n.resolve(s));
|
|
538
539
|
}
|
|
539
|
-
this.Path = new
|
|
540
|
+
this.Path = new O(s), this.directory = this.Path.directory, this.filename = this.Path.filename, this.extension = this.Path.extension;
|
|
540
541
|
}
|
|
541
542
|
/**
|
|
542
543
|
* @returns {Path}
|
|
@@ -552,7 +553,7 @@ class R {
|
|
|
552
553
|
resolve(t) {
|
|
553
554
|
if (t.indexOf("://") > -1)
|
|
554
555
|
return t;
|
|
555
|
-
const i =
|
|
556
|
+
const i = D.resolve(this.directory, t);
|
|
556
557
|
return this.origin + i;
|
|
557
558
|
}
|
|
558
559
|
/**
|
|
@@ -561,7 +562,7 @@ class R {
|
|
|
561
562
|
* @returns {string} path
|
|
562
563
|
*/
|
|
563
564
|
relative(t) {
|
|
564
|
-
return
|
|
565
|
+
return D.relative(t, this.directory);
|
|
565
566
|
}
|
|
566
567
|
/**
|
|
567
568
|
* @returns {string}
|
|
@@ -570,7 +571,7 @@ class R {
|
|
|
570
571
|
return this.href;
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
|
-
const
|
|
574
|
+
const U = 1, N = 3, pe = 9;
|
|
574
575
|
class y {
|
|
575
576
|
constructor(t, e, i) {
|
|
576
577
|
if (this.str = "", this.base = {}, this.spinePos = 0, this.range = !1, this.path = {}, this.start = null, this.end = null, !(this instanceof y))
|
|
@@ -594,7 +595,7 @@ class y {
|
|
|
594
595
|
* @private
|
|
595
596
|
*/
|
|
596
597
|
checkType(t) {
|
|
597
|
-
return this.isCfiString(t) ? "string" : t && typeof t == "object" && (
|
|
598
|
+
return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Ft(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof y ? "EpubCFI" : !1;
|
|
598
599
|
}
|
|
599
600
|
/**
|
|
600
601
|
* Parse a cfi string to a CFI object representation
|
|
@@ -649,7 +650,7 @@ class y {
|
|
|
649
650
|
parseTerminal(t) {
|
|
650
651
|
let e, i = null;
|
|
651
652
|
const s = t.match(/\[(.*)\]/);
|
|
652
|
-
return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t),
|
|
653
|
+
return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), x(e) || (e = null), {
|
|
653
654
|
offset: e,
|
|
654
655
|
assertion: i
|
|
655
656
|
};
|
|
@@ -701,12 +702,12 @@ class y {
|
|
|
701
702
|
if (t.spinePos < e.spinePos)
|
|
702
703
|
return -1;
|
|
703
704
|
t.range ? (i = t.path.steps.concat(t.start.steps), n = t.start.terminal) : (i = t.path.steps, n = t.path.terminal), e.range ? (s = e.path.steps.concat(e.start.steps), r = e.start.terminal) : (s = e.path.steps, r = e.path.terminal);
|
|
704
|
-
for (let
|
|
705
|
-
if (!i[
|
|
705
|
+
for (let l = 0; l < i.length; l++) {
|
|
706
|
+
if (!i[l])
|
|
706
707
|
return -1;
|
|
707
|
-
if (!s[
|
|
708
|
+
if (!s[l] || i[l].index > s[l].index)
|
|
708
709
|
return 1;
|
|
709
|
-
if (i[
|
|
710
|
+
if (i[l].index < s[l].index)
|
|
710
711
|
return -1;
|
|
711
712
|
}
|
|
712
713
|
if (i.length < s.length)
|
|
@@ -715,7 +716,7 @@ class y {
|
|
|
715
716
|
return o > h ? 1 : o < h ? -1 : 0;
|
|
716
717
|
}
|
|
717
718
|
step(t) {
|
|
718
|
-
const e = t.nodeType ===
|
|
719
|
+
const e = t.nodeType === N ? "text" : "element";
|
|
719
720
|
return {
|
|
720
721
|
id: t.id,
|
|
721
722
|
tagName: t.tagName,
|
|
@@ -727,7 +728,7 @@ class y {
|
|
|
727
728
|
const i = this.filter(t, e);
|
|
728
729
|
if (!i)
|
|
729
730
|
return;
|
|
730
|
-
const s = i.nodeType ===
|
|
731
|
+
const s = i.nodeType === N ? "text" : "element";
|
|
731
732
|
return {
|
|
732
733
|
id: i.id,
|
|
733
734
|
tagName: i.tagName,
|
|
@@ -744,9 +745,9 @@ class y {
|
|
|
744
745
|
}
|
|
745
746
|
};
|
|
746
747
|
let n = t, r;
|
|
747
|
-
for (; n && n.parentNode && n.parentNode.nodeType
|
|
748
|
+
for (; n && n.parentNode && n.parentNode.nodeType !== pe; )
|
|
748
749
|
i ? r = this.filteredStep(n, i) : r = this.step(n), r && s.steps.unshift(r), n = n.parentNode;
|
|
749
|
-
return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type
|
|
750
|
+
return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type !== "text" && s.steps.push({
|
|
750
751
|
type: "text",
|
|
751
752
|
index: 0,
|
|
752
753
|
id: null,
|
|
@@ -772,11 +773,11 @@ class y {
|
|
|
772
773
|
end: null,
|
|
773
774
|
spinePos: 0
|
|
774
775
|
}, n = t.startContainer, r = t.endContainer;
|
|
775
|
-
let o = t.startOffset, h = t.endOffset,
|
|
776
|
-
if (i && (
|
|
777
|
-
|
|
776
|
+
let o = t.startOffset, h = t.endOffset, l = !1;
|
|
777
|
+
if (i && (l = n.ownerDocument.querySelector("." + i) != null), typeof e == "string" ? (s.base = this.parseComponent(e), s.spinePos = s.base.steps[1].index) : typeof e == "object" && (s.base = e), t.collapsed)
|
|
778
|
+
l && (o = this.patchOffset(n, o, i)), s.path = this.pathTo(n, o, i);
|
|
778
779
|
else {
|
|
779
|
-
s.range = !0,
|
|
780
|
+
s.range = !0, l && (o = this.patchOffset(n, o, i)), s.start = this.pathTo(n, o, i), l && (h = this.patchOffset(r, h, i)), s.end = this.pathTo(r, h, i), s.path = {
|
|
780
781
|
steps: [],
|
|
781
782
|
terminal: { offset: null, assertion: null }
|
|
782
783
|
};
|
|
@@ -808,14 +809,14 @@ class y {
|
|
|
808
809
|
}
|
|
809
810
|
filter(t, e) {
|
|
810
811
|
let i, s, n, r, o, h = !1;
|
|
811
|
-
return t.nodeType ===
|
|
812
|
+
return t.nodeType === N ? (h = !0, n = t.parentNode, i = t.parentNode.classList.contains(e)) : (h = !1, i = t.classList.contains(e)), i && h ? (r = n.previousSibling, o = n.nextSibling, r && r.nodeType === N ? s = r : o && o.nodeType === N && (s = o), s || t) : i && !h ? !1 : t;
|
|
812
813
|
}
|
|
813
814
|
patchOffset(t, e, i) {
|
|
814
|
-
if (t.nodeType
|
|
815
|
+
if (t.nodeType !== N)
|
|
815
816
|
throw new Error("Anchor must be a text node");
|
|
816
817
|
let s = t, n = e;
|
|
817
818
|
for (t.parentNode.classList.contains(i) && (s = t.parentNode); s.previousSibling; ) {
|
|
818
|
-
if (s.previousSibling.nodeType ===
|
|
819
|
+
if (s.previousSibling.nodeType === U)
|
|
819
820
|
if (s.previousSibling.classList.contains(i))
|
|
820
821
|
n += (s.previousSibling.textContent ?? "").length;
|
|
821
822
|
else
|
|
@@ -830,18 +831,18 @@ class y {
|
|
|
830
831
|
const s = {};
|
|
831
832
|
let n = -1, r;
|
|
832
833
|
const o = t.length;
|
|
833
|
-
let h,
|
|
834
|
+
let h, l;
|
|
834
835
|
for (r = 0; r < o; r++)
|
|
835
|
-
h = t[r].nodeType, h ===
|
|
836
|
+
h = t[r].nodeType, h === U && t[r].classList.contains(i) && (h = N), r > 0 && h === N && l === N ? s[r] = n : e === h && (n = n + 1, s[r] = n), l = h;
|
|
836
837
|
return s;
|
|
837
838
|
}
|
|
838
839
|
position(t) {
|
|
839
840
|
let e, i;
|
|
840
|
-
return t.nodeType ===
|
|
841
|
+
return t.nodeType === U ? (e = t.parentNode.children, e || (e = mt(t.parentNode)), i = Array.from(e).indexOf(t)) : (e = this.textNodes(t.parentNode), i = e.indexOf(t)), i;
|
|
841
842
|
}
|
|
842
843
|
filteredPosition(t, e) {
|
|
843
844
|
let i, s;
|
|
844
|
-
t.nodeType ===
|
|
845
|
+
t.nodeType === U ? (i = t.parentNode.children, s = this.normalizedMap(i, U, e)) : (i = t.parentNode.childNodes, t.parentNode.classList.contains(e) && (t = t.parentNode, i = t.parentNode.childNodes), s = this.normalizedMap(i, N, e));
|
|
845
846
|
const n = Array.from(i).indexOf(t);
|
|
846
847
|
return s[n];
|
|
847
848
|
}
|
|
@@ -863,7 +864,7 @@ class y {
|
|
|
863
864
|
// Find the containing element
|
|
864
865
|
startContainerParent = doc.querySelector(query);
|
|
865
866
|
// Find the text node within that element
|
|
866
|
-
if(startContainerParent && lastStep.type
|
|
867
|
+
if(startContainerParent && lastStep.type === "text") {
|
|
867
868
|
container = startContainerParent.childNodes[lastStep.index];
|
|
868
869
|
}
|
|
869
870
|
*/
|
|
@@ -876,15 +877,15 @@ class y {
|
|
|
876
877
|
}
|
|
877
878
|
textNodes(t, e) {
|
|
878
879
|
return Array.from(t.childNodes).filter(function(i) {
|
|
879
|
-
return i.nodeType ===
|
|
880
|
+
return i.nodeType === N ? !0 : !!(e && i.classList.contains(e));
|
|
880
881
|
});
|
|
881
882
|
}
|
|
882
883
|
walkToNode(t, e, i) {
|
|
883
884
|
const s = e || document;
|
|
884
885
|
let n = s.documentElement, r, o;
|
|
885
886
|
const h = t.length;
|
|
886
|
-
let
|
|
887
|
-
for (
|
|
887
|
+
let l;
|
|
888
|
+
for (l = 0; l < h && (o = t[l], o.type === "element" ? o.id ? n = s.getElementById(o.id) : (r = n.children || mt(n), n = r[o.index]) : o.type === "text" && (n = this.textNodes(n, i)[o.index]), !!n); l++)
|
|
888
889
|
;
|
|
889
890
|
return n;
|
|
890
891
|
}
|
|
@@ -897,15 +898,15 @@ class y {
|
|
|
897
898
|
let n = this.findNode(t.slice(0, -1), i, s);
|
|
898
899
|
if (!n)
|
|
899
900
|
return { container: (i ?? document).documentElement, offset: 0 };
|
|
900
|
-
const r = n.childNodes, o = this.normalizedMap(r,
|
|
901
|
-
let h,
|
|
901
|
+
const r = n.childNodes, o = this.normalizedMap(r, N, s);
|
|
902
|
+
let h, l;
|
|
902
903
|
const c = t[t.length - 1].index;
|
|
903
904
|
for (const d in o)
|
|
904
905
|
if (o.hasOwnProperty(d) && o[d] === c)
|
|
905
|
-
if (h = r[d],
|
|
906
|
-
e = e -
|
|
906
|
+
if (h = r[d], l = (h.textContent ?? "").length, e > l)
|
|
907
|
+
e = e - l;
|
|
907
908
|
else {
|
|
908
|
-
h.nodeType ===
|
|
909
|
+
h.nodeType === U ? n = h.childNodes[0] ?? h : n = h;
|
|
909
910
|
break;
|
|
910
911
|
}
|
|
911
912
|
return {
|
|
@@ -922,11 +923,11 @@ class y {
|
|
|
922
923
|
toRange(t, e) {
|
|
923
924
|
const i = t || document;
|
|
924
925
|
let s, n, r, o, h;
|
|
925
|
-
const
|
|
926
|
+
const l = this;
|
|
926
927
|
let c, d;
|
|
927
928
|
const u = e ? i.querySelector("." + e) != null : !1;
|
|
928
929
|
let p;
|
|
929
|
-
if (typeof i.createRange < "u" ? s = i.createRange() : s = new
|
|
930
|
+
if (typeof i.createRange < "u" ? s = i.createRange() : s = new Yt(), l.range ? (n = l.start, c = l.path.steps.concat(n.steps), o = this.findNode(c, i, u ? e : void 0), r = l.end, d = l.path.steps.concat(r.steps), h = this.findNode(d, i, u ? e : void 0)) : (n = l.path, c = l.path.steps, o = this.findNode(l.path.steps, i, u ? e : void 0)), o)
|
|
930
931
|
try {
|
|
931
932
|
n.terminal.offset != null ? s.setStart(o, n.terminal.offset) : s.setStart(o, 0);
|
|
932
933
|
} catch {
|
|
@@ -938,7 +939,7 @@ class y {
|
|
|
938
939
|
try {
|
|
939
940
|
r.terminal.offset != null ? s.setEnd(h, r.terminal.offset) : s.setEnd(h, 0);
|
|
940
941
|
} catch {
|
|
941
|
-
p = this.fixMiss(d,
|
|
942
|
+
p = this.fixMiss(d, l.end.terminal.offset, i, u ? e : void 0), s.setEnd(p.container, p.offset);
|
|
942
943
|
}
|
|
943
944
|
return s;
|
|
944
945
|
}
|
|
@@ -1017,35 +1018,35 @@ class A {
|
|
|
1017
1018
|
return this.hooks = [];
|
|
1018
1019
|
}
|
|
1019
1020
|
}
|
|
1020
|
-
function
|
|
1021
|
+
function Gt(a, t) {
|
|
1021
1022
|
let e, i = t.url;
|
|
1022
1023
|
const s = i.indexOf("://") > -1;
|
|
1023
|
-
if (!
|
|
1024
|
+
if (!a)
|
|
1024
1025
|
return;
|
|
1025
|
-
const n =
|
|
1026
|
-
e =
|
|
1026
|
+
const n = w(a, "head");
|
|
1027
|
+
e = w(n, "base"), e || (e = a.createElement("base"), n.insertBefore(e, n.firstChild)), !s && typeof window < "u" && window.location && (i = window.location.origin + i), e.setAttribute("href", i);
|
|
1027
1028
|
}
|
|
1028
|
-
function
|
|
1029
|
+
function ge(a, t) {
|
|
1029
1030
|
let e;
|
|
1030
1031
|
const i = t.canonical;
|
|
1031
|
-
if (!
|
|
1032
|
+
if (!a)
|
|
1032
1033
|
return;
|
|
1033
|
-
const s =
|
|
1034
|
-
e =
|
|
1034
|
+
const s = w(a, "head");
|
|
1035
|
+
e = w(s, "link[rel='canonical']"), e ? e.setAttribute("href", i) : (e = a.createElement("link"), e.setAttribute("rel", "canonical"), e.setAttribute("href", i), s.appendChild(e));
|
|
1035
1036
|
}
|
|
1036
|
-
function
|
|
1037
|
+
function me(a, t) {
|
|
1037
1038
|
let e;
|
|
1038
1039
|
const i = t.idref;
|
|
1039
|
-
if (!
|
|
1040
|
+
if (!a)
|
|
1040
1041
|
return;
|
|
1041
|
-
const s =
|
|
1042
|
-
e =
|
|
1042
|
+
const s = w(a, "head");
|
|
1043
|
+
e = w(s, "link[property='dc.identifier']"), e ? e.setAttribute("content", i) : (e = a.createElement("meta"), e.setAttribute("name", "dc.identifier"), e.setAttribute("content", i), s.appendChild(e));
|
|
1043
1044
|
}
|
|
1044
|
-
function
|
|
1045
|
-
const e =
|
|
1045
|
+
function ve(a, t) {
|
|
1046
|
+
const e = a.querySelectorAll("a[href]");
|
|
1046
1047
|
if (!e.length)
|
|
1047
1048
|
return;
|
|
1048
|
-
const i =
|
|
1049
|
+
const i = w(a.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
|
|
1049
1050
|
const o = r.getAttribute("href") ?? "";
|
|
1050
1051
|
if (o.indexOf("mailto:") === 0)
|
|
1051
1052
|
return;
|
|
@@ -1070,61 +1071,56 @@ function ge(l, t) {
|
|
|
1070
1071
|
for (let r = 0; r < e.length; r++)
|
|
1071
1072
|
n(e[r]);
|
|
1072
1073
|
}
|
|
1073
|
-
function
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1074
|
+
function At(a, t, e) {
|
|
1075
|
+
const i = /* @__PURE__ */ new Map(), s = [], n = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
|
1076
|
+
for (let o = 0; o < t.length; o++) {
|
|
1077
|
+
const h = t[o], l = e[o];
|
|
1078
|
+
if (!h || !l) continue;
|
|
1079
|
+
const c = h.replace(n, "\\$&");
|
|
1080
|
+
i.set(h, l), s.push(c);
|
|
1081
|
+
try {
|
|
1082
|
+
const d = decodeURIComponent(h);
|
|
1083
|
+
if (d !== h) {
|
|
1084
|
+
const u = d.replace(n, "\\$&");
|
|
1085
|
+
i.set(d, l), s.push(u);
|
|
1083
1086
|
}
|
|
1084
|
-
|
|
1087
|
+
} catch {
|
|
1085
1088
|
}
|
|
1086
|
-
}
|
|
1089
|
+
}
|
|
1090
|
+
if (s.length === 0) return a;
|
|
1091
|
+
s.sort((o, h) => h.length - o.length);
|
|
1092
|
+
const r = new RegExp(s.join("|"), "g");
|
|
1093
|
+
return a.replace(r, (o) => i.get(o) ?? o);
|
|
1087
1094
|
}
|
|
1088
|
-
function
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
e && (
|
|
1092
|
-
|
|
1093
|
-
o.
|
|
1094
|
-
t == "json" && o.setRequestHeader("Accept", "application/json"), t || (t = new z(l).extension), t == "blob" && (o.responseType = n), Y(t) && o.overrideMimeType("text/xml"), t == "binary" && (o.responseType = "arraybuffer"), o.send();
|
|
1095
|
-
function a(d) {
|
|
1096
|
-
r.reject(d);
|
|
1097
|
-
}
|
|
1098
|
-
function c() {
|
|
1099
|
-
if (o.readyState === XMLHttpRequest.DONE) {
|
|
1100
|
-
let d = !1;
|
|
1101
|
-
if ((o.responseType === "" || o.responseType === "document") && (d = o.responseXML), o.status === 200 || o.status === 0 || d) {
|
|
1102
|
-
let u;
|
|
1103
|
-
if (!o.response && !d)
|
|
1104
|
-
return r.reject({
|
|
1105
|
-
status: o.status,
|
|
1106
|
-
message: "Empty Response",
|
|
1107
|
-
stack: new Error().stack
|
|
1108
|
-
}), r.promise;
|
|
1109
|
-
if (o.status === 403)
|
|
1110
|
-
return r.reject({
|
|
1111
|
-
status: o.status,
|
|
1112
|
-
response: o.response,
|
|
1113
|
-
message: "Forbidden",
|
|
1114
|
-
stack: new Error().stack
|
|
1115
|
-
}), r.promise;
|
|
1116
|
-
d ? u = o.responseXML : Y(t) ? u = O(o.response, "text/xml") : t == "xhtml" ? u = O(o.response, "application/xhtml+xml") : t == "html" || t == "htm" ? u = O(o.response, "text/html") : t == "json" ? u = JSON.parse(o.response) : t == "blob" ? s ? u = o.response : u = new Blob([o.response]) : u = o.response, r.resolve(u);
|
|
1117
|
-
} else
|
|
1118
|
-
r.reject({
|
|
1119
|
-
status: o.status,
|
|
1120
|
-
message: o.response,
|
|
1121
|
-
stack: new Error().stack
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1095
|
+
async function Y(a, t, e, i) {
|
|
1096
|
+
t || (t = new O(a).extension);
|
|
1097
|
+
const s = {};
|
|
1098
|
+
if (e && (s.credentials = "include"), i || t === "json") {
|
|
1099
|
+
const o = new Headers(i);
|
|
1100
|
+
t === "json" && o.set("Accept", "application/json"), s.headers = o;
|
|
1124
1101
|
}
|
|
1125
|
-
|
|
1102
|
+
let n;
|
|
1103
|
+
try {
|
|
1104
|
+
n = await fetch(a, s);
|
|
1105
|
+
} catch (o) {
|
|
1106
|
+
throw new q(o.message || "Network Error", 0);
|
|
1107
|
+
}
|
|
1108
|
+
if (!n.ok) {
|
|
1109
|
+
const o = await n.text().catch(() => "");
|
|
1110
|
+
throw new q(o || n.statusText, n.status);
|
|
1111
|
+
}
|
|
1112
|
+
if (t === "blob") {
|
|
1113
|
+
const o = await n.blob();
|
|
1114
|
+
return o instanceof Blob ? o : new Blob([o], { type: o.type });
|
|
1115
|
+
}
|
|
1116
|
+
if (t === "binary")
|
|
1117
|
+
return n.arrayBuffer();
|
|
1118
|
+
if (t === "json")
|
|
1119
|
+
return n.json();
|
|
1120
|
+
const r = await n.text();
|
|
1121
|
+
return _t(t) ? W(r, "text/xml") : t === "xhtml" ? W(r, "application/xhtml+xml") : t === "html" || t === "htm" ? W(r, "text/html") : r;
|
|
1126
1122
|
}
|
|
1127
|
-
class
|
|
1123
|
+
class ye {
|
|
1128
1124
|
constructor(t, e) {
|
|
1129
1125
|
this.idref = t.idref, this.linear = t.linear === "yes", this.properties = t.properties, this.index = t.index, this.href = t.href, this.url = t.url, this.canonical = t.canonical, this.next = t.next, this.prev = t.prev, this.cfiBase = t.cfiBase, e ? this.hooks = e : (this.hooks = {}, this.hooks.serialize = new A(this), this.hooks.content = new A(this)), this.document = void 0, this.contents = void 0, this.output = void 0;
|
|
1130
1126
|
}
|
|
@@ -1133,36 +1129,28 @@ class me {
|
|
|
1133
1129
|
* @param {method} [_request] a request method to use for loading
|
|
1134
1130
|
* @return {document} a promise with the xml document
|
|
1135
1131
|
*/
|
|
1136
|
-
load(t) {
|
|
1137
|
-
const e = t || this.request ||
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}), s;
|
|
1132
|
+
async load(t) {
|
|
1133
|
+
const e = t || this.request || Y;
|
|
1134
|
+
if (this.contents)
|
|
1135
|
+
return this.contents;
|
|
1136
|
+
const i = await e(this.url);
|
|
1137
|
+
return this.document = i, this.contents = i.documentElement, await this.hooks.content.trigger(this.document, this), this.contents;
|
|
1143
1138
|
}
|
|
1144
1139
|
/**
|
|
1145
1140
|
* Adds a base tag for resolving urls in the section
|
|
1146
1141
|
* @private
|
|
1147
1142
|
*/
|
|
1148
1143
|
base() {
|
|
1149
|
-
return
|
|
1144
|
+
return Gt(this.document, this);
|
|
1150
1145
|
}
|
|
1151
1146
|
/**
|
|
1152
1147
|
* Render the contents of a section
|
|
1153
1148
|
* @param {method} [_request] a request method to use for loading
|
|
1154
1149
|
* @return {string} output a serialized XML Document
|
|
1155
1150
|
*/
|
|
1156
|
-
render(t) {
|
|
1157
|
-
const e =
|
|
1158
|
-
return this.
|
|
1159
|
-
const n = new XMLSerializer();
|
|
1160
|
-
return this.output = n.serializeToString(s), this.output;
|
|
1161
|
-
}).then(() => this.hooks.serialize.trigger(this.output, this)).then(() => {
|
|
1162
|
-
e.resolve(this.output);
|
|
1163
|
-
}).catch(function(s) {
|
|
1164
|
-
e.reject(s);
|
|
1165
|
-
}), i;
|
|
1151
|
+
async render(t) {
|
|
1152
|
+
const e = await this.load(t), i = new XMLSerializer();
|
|
1153
|
+
return this.output = i.serializeToString(e), await this.hooks.serialize.trigger(this.output, this), this.output;
|
|
1166
1154
|
}
|
|
1167
1155
|
/**
|
|
1168
1156
|
* Find a string in a section
|
|
@@ -1172,15 +1160,15 @@ class me {
|
|
|
1172
1160
|
find(t) {
|
|
1173
1161
|
const e = this, i = [], s = t.toLowerCase(), n = function(r) {
|
|
1174
1162
|
const o = r.textContent.toLowerCase();
|
|
1175
|
-
let h,
|
|
1163
|
+
let h, l, c, d = -1, u;
|
|
1176
1164
|
const p = 150;
|
|
1177
|
-
for (; c
|
|
1178
|
-
c = o.indexOf(s, d + 1), c
|
|
1179
|
-
cfi:
|
|
1165
|
+
for (; c !== -1; )
|
|
1166
|
+
c = o.indexOf(s, d + 1), c !== -1 && (h = e.document.createRange(), h.setStart(r, c), h.setEnd(r, c + s.length), l = e.cfiFromRange(h), r.textContent.length < p ? u = r.textContent : (u = r.textContent.substring(c - p / 2, c + p / 2), u = "..." + u + "..."), i.push({
|
|
1167
|
+
cfi: l,
|
|
1180
1168
|
excerpt: u
|
|
1181
1169
|
})), d = c;
|
|
1182
1170
|
};
|
|
1183
|
-
return
|
|
1171
|
+
return et(e.document, function(r) {
|
|
1184
1172
|
n(r);
|
|
1185
1173
|
}), i;
|
|
1186
1174
|
}
|
|
@@ -1193,28 +1181,28 @@ class me {
|
|
|
1193
1181
|
search(t, e = 5) {
|
|
1194
1182
|
const i = [], n = this, r = t.toLowerCase(), o = function(d) {
|
|
1195
1183
|
const g = d.reduce((m, v) => m + (v.textContent ?? ""), "").toLowerCase().indexOf(r);
|
|
1196
|
-
if (g
|
|
1184
|
+
if (g !== -1) {
|
|
1197
1185
|
const v = g + r.length;
|
|
1198
|
-
let
|
|
1186
|
+
let b = 0, k = 0;
|
|
1199
1187
|
if (g < d[0].length) {
|
|
1200
|
-
for (;
|
|
1201
|
-
|
|
1202
|
-
const
|
|
1203
|
-
T.setStart(
|
|
1204
|
-
const I = d.slice(0,
|
|
1188
|
+
for (; b < d.length - 1 && (k += d[b].length, !(v <= k)); )
|
|
1189
|
+
b += 1;
|
|
1190
|
+
const E = d[0], _ = d[b], T = n.document.createRange();
|
|
1191
|
+
T.setStart(E, g);
|
|
1192
|
+
const I = d.slice(0, b).reduce((rt, ot) => rt + (ot.textContent ?? "").length, 0);
|
|
1205
1193
|
T.setEnd(_, I > v ? v : v - I);
|
|
1206
|
-
const
|
|
1207
|
-
let
|
|
1208
|
-
|
|
1209
|
-
cfi:
|
|
1210
|
-
excerpt:
|
|
1194
|
+
const M = n.cfiFromRange(T);
|
|
1195
|
+
let z = d.slice(0, b + 1).reduce((rt, ot) => rt + (ot.textContent ?? ""), "");
|
|
1196
|
+
z.length > 150 && (z = z.substring(g - 150 / 2, g + 150 / 2), z = "..." + z + "..."), i.push({
|
|
1197
|
+
cfi: M,
|
|
1198
|
+
excerpt: z
|
|
1211
1199
|
});
|
|
1212
1200
|
}
|
|
1213
1201
|
}
|
|
1214
1202
|
}, h = document.createTreeWalker(n.document, NodeFilter.SHOW_TEXT, null);
|
|
1215
|
-
let
|
|
1216
|
-
for (;
|
|
1217
|
-
c.push(
|
|
1203
|
+
let l, c = [];
|
|
1204
|
+
for (; l = h.nextNode(); )
|
|
1205
|
+
c.push(l), c.length === e && (o(c.slice(0, e)), c = c.slice(1, e));
|
|
1218
1206
|
return c.length > 0 && o(c), i;
|
|
1219
1207
|
}
|
|
1220
1208
|
/**
|
|
@@ -1232,7 +1220,7 @@ class me {
|
|
|
1232
1220
|
return this.properties.forEach(function(i) {
|
|
1233
1221
|
const s = i.replace("rendition:", ""), n = s.indexOf("-");
|
|
1234
1222
|
let r, o;
|
|
1235
|
-
n
|
|
1223
|
+
n !== -1 && (r = s.slice(0, n), o = s.slice(n + 1), e[r] = o);
|
|
1236
1224
|
}), e;
|
|
1237
1225
|
}
|
|
1238
1226
|
/**
|
|
@@ -1261,9 +1249,9 @@ class me {
|
|
|
1261
1249
|
this.unload(), this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks = void 0, this.idref = void 0, this.linear = void 0, this.properties = void 0, this.index = void 0, this.href = void 0, this.url = void 0, this.next = void 0, this.prev = void 0, this.cfiBase = void 0;
|
|
1262
1250
|
}
|
|
1263
1251
|
}
|
|
1264
|
-
class
|
|
1252
|
+
class we {
|
|
1265
1253
|
constructor() {
|
|
1266
|
-
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new A(), this.hooks.content = new A(), this.hooks.content.register(
|
|
1254
|
+
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new A(), this.hooks.content = new A(), this.hooks.content.register(Gt), this.hooks.content.register(ge), this.hooks.content.register(me), this.epubcfi = new y(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
|
|
1267
1255
|
}
|
|
1268
1256
|
/**
|
|
1269
1257
|
* Unpack items from a opf into spine items
|
|
@@ -1277,23 +1265,23 @@ class ve {
|
|
|
1277
1265
|
s.index = n, s.cfiBase = this.epubcfi.generateChapterComponent(this.spineNodeIndex, s.index, s.id), s.href && (s.url = e(s.href, !0), s.canonical = i(s.href)), r && (s.href = r.href, s.url = e(s.href, !0), s.canonical = i(s.href), r.properties.length && s.properties.push(...r.properties)), s.linear === "yes" ? (s.prev = () => {
|
|
1278
1266
|
let h = s.index;
|
|
1279
1267
|
for (; h > 0; ) {
|
|
1280
|
-
const
|
|
1281
|
-
if (
|
|
1282
|
-
return
|
|
1268
|
+
const l = this.get(h - 1);
|
|
1269
|
+
if (l && l.linear)
|
|
1270
|
+
return l;
|
|
1283
1271
|
h -= 1;
|
|
1284
1272
|
}
|
|
1285
1273
|
}, s.next = () => {
|
|
1286
1274
|
let h = s.index;
|
|
1287
1275
|
for (; h < this.spineItems.length - 1; ) {
|
|
1288
|
-
const
|
|
1289
|
-
if (
|
|
1290
|
-
return
|
|
1276
|
+
const l = this.get(h + 1);
|
|
1277
|
+
if (l && l.linear)
|
|
1278
|
+
return l;
|
|
1291
1279
|
h += 1;
|
|
1292
1280
|
}
|
|
1293
1281
|
}) : (s.prev = function() {
|
|
1294
1282
|
}, s.next = function() {
|
|
1295
1283
|
});
|
|
1296
|
-
const o = new
|
|
1284
|
+
const o = new ye(s, this.hooks);
|
|
1297
1285
|
this.append(o);
|
|
1298
1286
|
}), this.loaded = !0;
|
|
1299
1287
|
}
|
|
@@ -1387,16 +1375,16 @@ class ve {
|
|
|
1387
1375
|
this.each((t) => t.destroy()), this.spineItems = void 0, this.spineByHref = void 0, this.spineById = void 0, this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks = void 0, this.epubcfi = void 0, this.loaded = !1, this.items = void 0, this.manifest = void 0, this.spineNodeIndex = void 0, this.baseUrl = void 0, this.length = void 0;
|
|
1388
1376
|
}
|
|
1389
1377
|
}
|
|
1390
|
-
class
|
|
1378
|
+
class kt {
|
|
1391
1379
|
constructor(t) {
|
|
1392
|
-
this._q = [], this.context = t, this.tick =
|
|
1380
|
+
this._q = [], this.context = t, this.tick = Dt, this.running = !1, this.paused = !1;
|
|
1393
1381
|
}
|
|
1394
1382
|
enqueue(...t) {
|
|
1395
1383
|
let e, i, s;
|
|
1396
1384
|
const [n, ...r] = t;
|
|
1397
1385
|
if (!n)
|
|
1398
1386
|
throw new Error("No Task Provided");
|
|
1399
|
-
return typeof n == "function" ? (e = new
|
|
1387
|
+
return typeof n == "function" ? (e = new S(), i = e.promise, s = {
|
|
1400
1388
|
task: n,
|
|
1401
1389
|
args: r,
|
|
1402
1390
|
//"context" : context,
|
|
@@ -1405,7 +1393,7 @@ class Ct {
|
|
|
1405
1393
|
}) : s = {
|
|
1406
1394
|
args: [],
|
|
1407
1395
|
promise: n
|
|
1408
|
-
}, this._q.push(s), this.paused
|
|
1396
|
+
}, this._q.push(s), !this.paused && !this.running && this.run(), s.promise;
|
|
1409
1397
|
}
|
|
1410
1398
|
/**
|
|
1411
1399
|
* Run one item
|
|
@@ -1429,12 +1417,14 @@ class Ct {
|
|
|
1429
1417
|
* @return {Promise}
|
|
1430
1418
|
*/
|
|
1431
1419
|
run() {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1420
|
+
this.running || (this.running = !0, this.defered = new S());
|
|
1421
|
+
const t = () => {
|
|
1422
|
+
var e;
|
|
1423
|
+
this._q.length ? (e = this.dequeue()) == null || e.then(() => {
|
|
1435
1424
|
this.run();
|
|
1436
1425
|
}) : (this.defered.resolve(), this.running = void 0);
|
|
1437
|
-
}
|
|
1426
|
+
};
|
|
1427
|
+
return this.tick(t), this.paused && (this.paused = !1), this.defered.promise;
|
|
1438
1428
|
}
|
|
1439
1429
|
/**
|
|
1440
1430
|
* Flush all, as quickly as possible
|
|
@@ -1473,7 +1463,7 @@ class Ct {
|
|
|
1473
1463
|
this._q = [], this.running = !1, this.paused = !0;
|
|
1474
1464
|
}
|
|
1475
1465
|
}
|
|
1476
|
-
const
|
|
1466
|
+
const nt = "0.3", Z = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], f = {
|
|
1477
1467
|
BOOK: {
|
|
1478
1468
|
OPEN_FAILED: "openFailed"
|
|
1479
1469
|
},
|
|
@@ -1530,9 +1520,9 @@ const ht = "0.3", J = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
|
|
|
1530
1520
|
DETACH: "detach"
|
|
1531
1521
|
}
|
|
1532
1522
|
};
|
|
1533
|
-
class
|
|
1523
|
+
class $t {
|
|
1534
1524
|
constructor(t, e, i) {
|
|
1535
|
-
this.spine = t, this.request = e, this.pause = i ||
|
|
1525
|
+
this.spine = t, this.request = e, this.pause = i || 0, this.q = new kt(this), this.q.tick = xt, this.epubcfi = new y(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
|
|
1536
1526
|
}
|
|
1537
1527
|
/**
|
|
1538
1528
|
* Load all of sections in the book to generate locations
|
|
@@ -1552,23 +1542,23 @@ class Xt {
|
|
|
1552
1542
|
endOffset: void 0
|
|
1553
1543
|
};
|
|
1554
1544
|
}
|
|
1555
|
-
process(t) {
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1545
|
+
async process(t) {
|
|
1546
|
+
const e = await t.load(this.request), i = this.parse(e, t.cfiBase);
|
|
1547
|
+
return this._locations = this._locations.concat(i), t.unload(), new Promise((s) => {
|
|
1548
|
+
this.processingTimeout = setTimeout(() => s(i), this.pause);
|
|
1559
1549
|
});
|
|
1560
1550
|
}
|
|
1561
1551
|
parse(t, e, i) {
|
|
1562
1552
|
const s = [];
|
|
1563
1553
|
let n;
|
|
1564
|
-
const r = t.ownerDocument, o =
|
|
1565
|
-
let h = 0,
|
|
1554
|
+
const r = t.ownerDocument, o = w(r, "body");
|
|
1555
|
+
let h = 0, l;
|
|
1566
1556
|
const c = i || this.break;
|
|
1567
|
-
if (
|
|
1557
|
+
if (et(o, (u) => {
|
|
1568
1558
|
const p = u.length;
|
|
1569
1559
|
let g, m = 0;
|
|
1570
1560
|
if ((u.textContent ?? "").trim().length === 0)
|
|
1571
|
-
return
|
|
1561
|
+
return l = u, !1;
|
|
1572
1562
|
for (h === 0 && (n = this.createRange(), n.startContainer = u, n.startOffset = 0), g = c - h, g > p && (h += p, m = p); m < p; )
|
|
1573
1563
|
if (g = c - h, h === 0 && (m += 1, n = this.createRange(), n.startContainer = u, n.startOffset = m), m + g >= p)
|
|
1574
1564
|
h += p - m, m = p;
|
|
@@ -1577,9 +1567,9 @@ class Xt {
|
|
|
1577
1567
|
const v = new y(n, e).toString();
|
|
1578
1568
|
s.push(v), h = 0;
|
|
1579
1569
|
}
|
|
1580
|
-
return
|
|
1581
|
-
}), n && n.startContainer &&
|
|
1582
|
-
n.endContainer =
|
|
1570
|
+
return l = u, !1;
|
|
1571
|
+
}), n && n.startContainer && l) {
|
|
1572
|
+
n.endContainer = l, n.endOffset = l.length;
|
|
1583
1573
|
const u = new y(n, e).toString();
|
|
1584
1574
|
s.push(u), h = 0;
|
|
1585
1575
|
}
|
|
@@ -1595,13 +1585,15 @@ class Xt {
|
|
|
1595
1585
|
generateFromWords(t, e, i) {
|
|
1596
1586
|
const s = t ? new y(t) : void 0;
|
|
1597
1587
|
return this.q.pause(), this._locationsWords = [], this._wordCounter = 0, this.spine.each((n) => {
|
|
1598
|
-
n.linear && (s ? n.index >= s.spinePos && this.q.enqueue((r, o, h,
|
|
1588
|
+
n.linear && (s ? n.index >= s.spinePos && this.q.enqueue((r, o, h, l) => this.processWords(r, o, h, l), n, e, s, i) : this.q.enqueue((r, o, h, l) => this.processWords(r, o, h, l), n, e, s, i));
|
|
1599
1589
|
}), this.q.run().then(() => (this._currentCfi && (this.currentLocation = this._currentCfi), this._locationsWords));
|
|
1600
1590
|
}
|
|
1601
|
-
processWords(t, e, i, s) {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1591
|
+
async processWords(t, e, i, s) {
|
|
1592
|
+
if (s && this._locationsWords.length >= s)
|
|
1593
|
+
return [];
|
|
1594
|
+
const n = await t.load(this.request), r = this.parseWords(n, t, e, i), o = s - this._locationsWords.length;
|
|
1595
|
+
return this._locationsWords = this._locationsWords.concat(r.length >= s ? r.slice(0, o) : r), t.unload(), new Promise((h) => {
|
|
1596
|
+
this.processingTimeout = setTimeout(() => h(r), this.pause);
|
|
1605
1597
|
});
|
|
1606
1598
|
}
|
|
1607
1599
|
//http://stackoverflow.com/questions/18679576/counting-words-in-string
|
|
@@ -1610,9 +1602,9 @@ class Xt {
|
|
|
1610
1602
|
`), t.split(" ").length;
|
|
1611
1603
|
}
|
|
1612
1604
|
parseWords(t, e, i, s) {
|
|
1613
|
-
const n = e.cfiBase, r = [], o = t.ownerDocument, h =
|
|
1605
|
+
const n = e.cfiBase, r = [], o = t.ownerDocument, h = w(o, "body"), l = i;
|
|
1614
1606
|
let c = s ? s.spinePos !== e.index : !0, d;
|
|
1615
|
-
return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)),
|
|
1607
|
+
return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), et(h, (p) => {
|
|
1616
1608
|
if (!c)
|
|
1617
1609
|
if (p === d)
|
|
1618
1610
|
c = !0;
|
|
@@ -1624,13 +1616,13 @@ class Xt {
|
|
|
1624
1616
|
let m, v = 0;
|
|
1625
1617
|
if (g === 0)
|
|
1626
1618
|
return !1;
|
|
1627
|
-
for (m =
|
|
1628
|
-
if (m =
|
|
1619
|
+
for (m = l - this._wordCounter, m > g && (this._wordCounter += g, v = g); v < g; )
|
|
1620
|
+
if (m = l - this._wordCounter, v + m >= g)
|
|
1629
1621
|
this._wordCounter += g - v, v = g;
|
|
1630
1622
|
else {
|
|
1631
1623
|
v += m;
|
|
1632
|
-
const
|
|
1633
|
-
r.push({ cfi:
|
|
1624
|
+
const b = new y(p, n);
|
|
1625
|
+
r.push({ cfi: b.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
|
|
1634
1626
|
}
|
|
1635
1627
|
return !1;
|
|
1636
1628
|
}), r;
|
|
@@ -1643,7 +1635,7 @@ class Xt {
|
|
|
1643
1635
|
locationFromCfi(t) {
|
|
1644
1636
|
if (y.prototype.isCfiString(t) && (t = new y(t)), this._locations.length === 0)
|
|
1645
1637
|
return -1;
|
|
1646
|
-
const e =
|
|
1638
|
+
const e = V(t, this._locations, this.epubcfi.compare);
|
|
1647
1639
|
return e > this.total ? this.total : e;
|
|
1648
1640
|
}
|
|
1649
1641
|
/**
|
|
@@ -1739,8 +1731,8 @@ class Xt {
|
|
|
1739
1731
|
this.spine = void 0, this.request = void 0, this.pause = void 0, (t = this.q) == null || t.stop(), this.q = void 0, this.epubcfi = void 0, this._locations = void 0, this.total = void 0, this.break = void 0, this._current = void 0, this.currentLocation = void 0, this._currentCfi = void 0, clearTimeout(this.processingTimeout);
|
|
1740
1732
|
}
|
|
1741
1733
|
}
|
|
1742
|
-
P(
|
|
1743
|
-
class
|
|
1734
|
+
P($t.prototype);
|
|
1735
|
+
class be {
|
|
1744
1736
|
constructor(t) {
|
|
1745
1737
|
this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
|
|
1746
1738
|
}
|
|
@@ -1751,16 +1743,16 @@ class ye {
|
|
|
1751
1743
|
parse(t) {
|
|
1752
1744
|
if (!t)
|
|
1753
1745
|
throw new Error("Container File Not Found");
|
|
1754
|
-
const e =
|
|
1746
|
+
const e = w(t, "rootfile");
|
|
1755
1747
|
if (!e)
|
|
1756
1748
|
throw new Error("No RootFile Found");
|
|
1757
|
-
this.packagePath = e.getAttribute("full-path") ?? "", this.directory =
|
|
1749
|
+
this.packagePath = e.getAttribute("full-path") ?? "", this.directory = D.dirname(this.packagePath), this.encoding = t.xmlEncoding;
|
|
1758
1750
|
}
|
|
1759
1751
|
destroy() {
|
|
1760
1752
|
this.packagePath = void 0, this.directory = void 0, this.encoding = void 0;
|
|
1761
1753
|
}
|
|
1762
1754
|
}
|
|
1763
|
-
class
|
|
1755
|
+
class It {
|
|
1764
1756
|
constructor(t) {
|
|
1765
1757
|
this.manifest = {}, this.navPath = "", this.ncxPath = "", this.coverPath = "", this.spineNodeIndex = 0, this.spine = [], this.metadata = {}, t && this.parse(t);
|
|
1766
1758
|
}
|
|
@@ -1772,16 +1764,16 @@ class Rt {
|
|
|
1772
1764
|
parse(t) {
|
|
1773
1765
|
if (!t)
|
|
1774
1766
|
throw new Error("Package File Not Found");
|
|
1775
|
-
const e =
|
|
1767
|
+
const e = w(t, "metadata");
|
|
1776
1768
|
if (!e)
|
|
1777
1769
|
throw new Error("No Metadata Found");
|
|
1778
|
-
const i =
|
|
1770
|
+
const i = w(t, "manifest");
|
|
1779
1771
|
if (!i)
|
|
1780
1772
|
throw new Error("No Manifest Found");
|
|
1781
|
-
const s =
|
|
1773
|
+
const s = w(t, "spine");
|
|
1782
1774
|
if (!s)
|
|
1783
1775
|
throw new Error("No Spine Found");
|
|
1784
|
-
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex =
|
|
1776
|
+
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Ut(s), this.spine = this.parseSpine(s, this.manifest), this.uniqueIdentifier = this.findUniqueIdentifier(t), this.metadata = this.parseMetadata(e), this.metadata.direction = s.getAttribute("page-progression-direction") ?? "", {
|
|
1785
1777
|
metadata: this.metadata,
|
|
1786
1778
|
spine: this.spine,
|
|
1787
1779
|
manifest: this.manifest,
|
|
@@ -1808,14 +1800,14 @@ class Rt {
|
|
|
1808
1800
|
* @return {object} manifest
|
|
1809
1801
|
*/
|
|
1810
1802
|
parseManifest(t) {
|
|
1811
|
-
const e = {}, i =
|
|
1803
|
+
const e = {}, i = B(t, "item");
|
|
1812
1804
|
return Array.from(i).forEach(function(n) {
|
|
1813
|
-
const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "",
|
|
1805
|
+
const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "", l = n.getAttribute("media-overlay") || "", c = n.getAttribute("properties") || "", d = n.getAttribute("fallback") || "";
|
|
1814
1806
|
e[r] = {
|
|
1815
1807
|
href: o,
|
|
1816
1808
|
// "url" : href,
|
|
1817
1809
|
type: h,
|
|
1818
|
-
overlay:
|
|
1810
|
+
overlay: l,
|
|
1819
1811
|
properties: c.length ? c.split(" ") : [],
|
|
1820
1812
|
fallback: d
|
|
1821
1813
|
};
|
|
@@ -1829,9 +1821,9 @@ class Rt {
|
|
|
1829
1821
|
* @return {object} spine
|
|
1830
1822
|
*/
|
|
1831
1823
|
parseSpine(t, e) {
|
|
1832
|
-
const i = [], s =
|
|
1824
|
+
const i = [], s = B(t, "itemref");
|
|
1833
1825
|
return Array.from(s).forEach(function(r, o) {
|
|
1834
|
-
const h = r.getAttribute("idref"),
|
|
1826
|
+
const h = r.getAttribute("idref"), l = r.getAttribute("properties") || "", c = l.length ? l.split(" ") : [], d = {
|
|
1835
1827
|
id: r.getAttribute("id") ?? void 0,
|
|
1836
1828
|
idref: h,
|
|
1837
1829
|
linear: r.getAttribute("linear") || "yes",
|
|
@@ -1888,7 +1880,7 @@ class Rt {
|
|
|
1888
1880
|
* @return {string} href
|
|
1889
1881
|
*/
|
|
1890
1882
|
findCoverPath(t) {
|
|
1891
|
-
const e =
|
|
1883
|
+
const e = w(t, "package");
|
|
1892
1884
|
e == null || e.getAttribute("version");
|
|
1893
1885
|
const i = j(t, "item", { properties: "cover-image" });
|
|
1894
1886
|
if (i) return i.getAttribute("href") ?? "";
|
|
@@ -1948,7 +1940,7 @@ class Rt {
|
|
|
1948
1940
|
this.manifest = void 0, this.navPath = void 0, this.ncxPath = void 0, this.coverPath = void 0, this.spineNodeIndex = void 0, this.spine = void 0, this.metadata = void 0;
|
|
1949
1941
|
}
|
|
1950
1942
|
}
|
|
1951
|
-
class
|
|
1943
|
+
class ht {
|
|
1952
1944
|
constructor(t) {
|
|
1953
1945
|
this.toc = [], this.tocByHref = {}, this.tocById = {}, this.landmarks = [], this.landmarksByType = {}, this.length = 0, t && this.parse(t);
|
|
1954
1946
|
}
|
|
@@ -1959,7 +1951,7 @@ class ct {
|
|
|
1959
1951
|
parse(t) {
|
|
1960
1952
|
const e = t.nodeType;
|
|
1961
1953
|
let i, s;
|
|
1962
|
-
e && (i =
|
|
1954
|
+
e && (i = w(t, "html"), s = w(t, "ncx")), e ? i ? (this.toc = this.parseNav(t), this.landmarks = this.parseLandmarks(t)) : s && (this.toc = this.parseNcx(t)) : this.toc = this.load(t), this.length = 0, this.unpack(this.toc);
|
|
1963
1955
|
}
|
|
1964
1956
|
/**
|
|
1965
1957
|
* Unpack navigation items
|
|
@@ -2019,7 +2011,7 @@ class ct {
|
|
|
2019
2011
|
* @return {array} navigation list
|
|
2020
2012
|
*/
|
|
2021
2013
|
parseNav(t) {
|
|
2022
|
-
const e =
|
|
2014
|
+
const e = it(t, "nav", "toc");
|
|
2023
2015
|
let i = [];
|
|
2024
2016
|
if (!e) return i;
|
|
2025
2017
|
const s = F(e, "ol", !0);
|
|
@@ -2071,7 +2063,7 @@ class ct {
|
|
|
2071
2063
|
* @return {array} landmarks list
|
|
2072
2064
|
*/
|
|
2073
2065
|
parseLandmarks(t) {
|
|
2074
|
-
const e =
|
|
2066
|
+
const e = it(t, "nav", "landmarks"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
2075
2067
|
let n;
|
|
2076
2068
|
const r = [];
|
|
2077
2069
|
let o;
|
|
@@ -2104,7 +2096,7 @@ class ct {
|
|
|
2104
2096
|
* @return {array} navigation list
|
|
2105
2097
|
*/
|
|
2106
2098
|
parseNcx(t) {
|
|
2107
|
-
const e =
|
|
2099
|
+
const e = B(t, "navPoint"), i = e.length;
|
|
2108
2100
|
let s;
|
|
2109
2101
|
const n = {}, r = [];
|
|
2110
2102
|
let o, h;
|
|
@@ -2120,14 +2112,14 @@ class ct {
|
|
|
2120
2112
|
* @return {object} ncxItem
|
|
2121
2113
|
*/
|
|
2122
2114
|
ncxItem(t) {
|
|
2123
|
-
const e = t.getAttribute("id") || "", i =
|
|
2124
|
-
let
|
|
2125
|
-
return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (
|
|
2115
|
+
const e = t.getAttribute("id") || "", i = w(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = w(t, "navLabel"), r = n != null && n.textContent ? n.textContent : "", o = [], h = t.parentNode;
|
|
2116
|
+
let l;
|
|
2117
|
+
return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (l = h.getAttribute("id") ?? void 0), {
|
|
2126
2118
|
id: e,
|
|
2127
2119
|
href: s,
|
|
2128
2120
|
label: r,
|
|
2129
2121
|
subitems: o,
|
|
2130
|
-
parent:
|
|
2122
|
+
parent: l
|
|
2131
2123
|
};
|
|
2132
2124
|
}
|
|
2133
2125
|
/**
|
|
@@ -2150,7 +2142,7 @@ class ct {
|
|
|
2150
2142
|
return this.toc.forEach(t);
|
|
2151
2143
|
}
|
|
2152
2144
|
}
|
|
2153
|
-
const
|
|
2145
|
+
const at = {
|
|
2154
2146
|
application: {
|
|
2155
2147
|
ecmascript: ["es", "ecma"],
|
|
2156
2148
|
javascript: "js",
|
|
@@ -2284,27 +2276,27 @@ const dt = {
|
|
|
2284
2276
|
"x-ms-vob": "vob",
|
|
2285
2277
|
"x-smv": "smv"
|
|
2286
2278
|
}
|
|
2287
|
-
},
|
|
2288
|
-
let
|
|
2279
|
+
}, xe = (function() {
|
|
2280
|
+
let a, t, e, i;
|
|
2289
2281
|
const s = {};
|
|
2290
|
-
for (
|
|
2291
|
-
if (
|
|
2292
|
-
const n =
|
|
2282
|
+
for (a in at)
|
|
2283
|
+
if (at.hasOwnProperty(a)) {
|
|
2284
|
+
const n = at[a];
|
|
2293
2285
|
for (t in n)
|
|
2294
2286
|
if (n.hasOwnProperty(t))
|
|
2295
2287
|
if (e = n[t], typeof e == "string")
|
|
2296
|
-
s[e] =
|
|
2288
|
+
s[e] = a + "/" + t;
|
|
2297
2289
|
else
|
|
2298
2290
|
for (i = 0; i < e.length; i++)
|
|
2299
|
-
s[e[i]] =
|
|
2291
|
+
s[e[i]] = a + "/" + t;
|
|
2300
2292
|
}
|
|
2301
2293
|
return s;
|
|
2302
|
-
})(),
|
|
2303
|
-
function
|
|
2304
|
-
return
|
|
2294
|
+
})(), Ee = "text/plain";
|
|
2295
|
+
function Se(a) {
|
|
2296
|
+
return a && xe[a.split(".").pop().toLowerCase()] || Ee;
|
|
2305
2297
|
}
|
|
2306
|
-
const
|
|
2307
|
-
class
|
|
2298
|
+
const G = { lookup: Se };
|
|
2299
|
+
class _e {
|
|
2308
2300
|
constructor(t, e) {
|
|
2309
2301
|
this.settings = {
|
|
2310
2302
|
replacements: e && e.replacements || "base64",
|
|
@@ -2350,8 +2342,8 @@ class Ee {
|
|
|
2350
2342
|
* @return {Promise<string>} Promise resolves with url string
|
|
2351
2343
|
*/
|
|
2352
2344
|
createUrl(t) {
|
|
2353
|
-
const e = new R(t), i =
|
|
2354
|
-
return this.settings.archive ? this.settings.archive.createUrl(t, { base64: this.settings.replacements === "base64" }) : this.settings.replacements === "base64" ? this.settings.request(t, "blob").then((s) =>
|
|
2345
|
+
const e = new R(t), i = G.lookup(e.filename);
|
|
2346
|
+
return this.settings.archive ? this.settings.archive.createUrl(t, { base64: this.settings.replacements === "base64" }) : this.settings.replacements === "base64" ? this.settings.request(t, "blob").then((s) => Xt(s)).then((s) => gt(s, i)) : this.settings.request(t, "blob").then((s) => tt(s, i));
|
|
2355
2347
|
}
|
|
2356
2348
|
/**
|
|
2357
2349
|
* Create blob urls for all the assets
|
|
@@ -2376,6 +2368,8 @@ class Ee {
|
|
|
2376
2368
|
* @return {Promise}
|
|
2377
2369
|
*/
|
|
2378
2370
|
replaceCss(t, e) {
|
|
2371
|
+
if (this.settings.replacements === "none")
|
|
2372
|
+
return Promise.resolve([]);
|
|
2379
2373
|
const i = [];
|
|
2380
2374
|
return this.cssUrls.forEach((s) => {
|
|
2381
2375
|
const n = this.createCssFile(s).then((r) => {
|
|
@@ -2393,7 +2387,7 @@ class Ee {
|
|
|
2393
2387
|
*/
|
|
2394
2388
|
createCssFile(t) {
|
|
2395
2389
|
let e;
|
|
2396
|
-
if (
|
|
2390
|
+
if (D.isAbsolute(t))
|
|
2397
2391
|
return new Promise(function(r) {
|
|
2398
2392
|
r();
|
|
2399
2393
|
});
|
|
@@ -2402,11 +2396,11 @@ class Ee {
|
|
|
2402
2396
|
this.settings.archive ? s = this.settings.archive.getText(i) : s = this.settings.request(i, "text");
|
|
2403
2397
|
const n = this.urls.map((r) => {
|
|
2404
2398
|
const o = this.settings.resolver(r);
|
|
2405
|
-
return new
|
|
2399
|
+
return new O(i).relative(o);
|
|
2406
2400
|
});
|
|
2407
2401
|
return s ? s.then((r) => {
|
|
2408
|
-
const o =
|
|
2409
|
-
return this.settings.replacements === "base64" ? e =
|
|
2402
|
+
const o = At(r, n, this.replacementUrls);
|
|
2403
|
+
return this.settings.replacements === "base64" ? e = gt(o, "text/css") : e = tt(o, "text/css"), e;
|
|
2410
2404
|
}, (r) => new Promise(function(o) {
|
|
2411
2405
|
o();
|
|
2412
2406
|
})) : new Promise(function(r) {
|
|
@@ -2422,7 +2416,7 @@ class Ee {
|
|
|
2422
2416
|
relativeTo(t, e) {
|
|
2423
2417
|
return e = e || this.settings.resolver, this.urls.map((i) => {
|
|
2424
2418
|
const s = e(i);
|
|
2425
|
-
return new
|
|
2419
|
+
return new O(t).relative(s);
|
|
2426
2420
|
});
|
|
2427
2421
|
}
|
|
2428
2422
|
/**
|
|
@@ -2446,15 +2440,15 @@ class Ee {
|
|
|
2446
2440
|
*/
|
|
2447
2441
|
substitute(t, e) {
|
|
2448
2442
|
let i;
|
|
2449
|
-
return e ? i = this.relativeTo(e) : i = this.urls,
|
|
2443
|
+
return e ? i = this.relativeTo(e) : i = this.urls, At(t, i, this.replacementUrls);
|
|
2450
2444
|
}
|
|
2451
2445
|
destroy() {
|
|
2452
2446
|
this.replacementUrls && this.replacementUrls.forEach((t) => {
|
|
2453
|
-
t &&
|
|
2447
|
+
t && Tt(t);
|
|
2454
2448
|
}), this.settings = void 0, this.manifest = void 0, this.resources = void 0, this.replacementUrls = void 0, this.html = void 0, this.assets = void 0, this.css = void 0, this.urls = void 0, this.cssUrls = void 0;
|
|
2455
2449
|
}
|
|
2456
2450
|
}
|
|
2457
|
-
class
|
|
2451
|
+
class lt {
|
|
2458
2452
|
constructor(t) {
|
|
2459
2453
|
this.pages = [], this.locations = [], this.epubcfi = new y(), this.firstPage = 0, this.lastPage = 0, this.totalPages = 0, this.toc = void 0, this.ncx = void 0, t && (this.pageList = this.parse(t)), this.pageList && this.pageList.length && this.process(this.pageList);
|
|
2460
2454
|
}
|
|
@@ -2463,7 +2457,7 @@ class ut {
|
|
|
2463
2457
|
* @param {document} xml
|
|
2464
2458
|
*/
|
|
2465
2459
|
parse(t) {
|
|
2466
|
-
const e =
|
|
2460
|
+
const e = w(t, "html"), i = w(t, "ncx");
|
|
2467
2461
|
return e ? this.parseNav(t) : i ? this.parseNcx(t) : [];
|
|
2468
2462
|
}
|
|
2469
2463
|
/**
|
|
@@ -2473,7 +2467,7 @@ class ut {
|
|
|
2473
2467
|
* @return {PageList.item[]} list
|
|
2474
2468
|
*/
|
|
2475
2469
|
parseNav(t) {
|
|
2476
|
-
const e =
|
|
2470
|
+
const e = it(t, "nav", "page-list"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
2477
2471
|
let n;
|
|
2478
2472
|
const r = [];
|
|
2479
2473
|
let o;
|
|
@@ -2485,9 +2479,9 @@ class ut {
|
|
|
2485
2479
|
parseNcx(t) {
|
|
2486
2480
|
const e = [];
|
|
2487
2481
|
let i = 0, s, n = 0;
|
|
2488
|
-
const r =
|
|
2482
|
+
const r = w(t, "pageList");
|
|
2489
2483
|
if (!r) return e;
|
|
2490
|
-
const o =
|
|
2484
|
+
const o = B(r, "pageTarget");
|
|
2491
2485
|
if (n = o.length, !o || o.length === 0)
|
|
2492
2486
|
return e;
|
|
2493
2487
|
for (i = 0; i < n; ++i)
|
|
@@ -2495,7 +2489,7 @@ class ut {
|
|
|
2495
2489
|
return e;
|
|
2496
2490
|
}
|
|
2497
2491
|
ncxItem(t) {
|
|
2498
|
-
const e =
|
|
2492
|
+
const e = w(t, "navLabel"), s = w(e, "text").textContent ?? "", r = w(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
|
|
2499
2493
|
return {
|
|
2500
2494
|
href: r,
|
|
2501
2495
|
page: o
|
|
@@ -2508,10 +2502,10 @@ class ut {
|
|
|
2508
2502
|
* @return {object} pageListItem
|
|
2509
2503
|
*/
|
|
2510
2504
|
item(t) {
|
|
2511
|
-
const e =
|
|
2512
|
-
let o, h,
|
|
2513
|
-
return r
|
|
2514
|
-
cfi:
|
|
2505
|
+
const e = w(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
|
|
2506
|
+
let o, h, l;
|
|
2507
|
+
return r !== -1 ? (o = i.split("#"), h = o[0], l = o.length > 1 ? o[1] : void 0, {
|
|
2508
|
+
cfi: l,
|
|
2515
2509
|
href: i,
|
|
2516
2510
|
packageUrl: h,
|
|
2517
2511
|
page: n
|
|
@@ -2540,7 +2534,7 @@ class ut {
|
|
|
2540
2534
|
if (this.locations.length === 0)
|
|
2541
2535
|
return -1;
|
|
2542
2536
|
let i = Q(t, this.locations, this.epubcfi.compare);
|
|
2543
|
-
return i
|
|
2537
|
+
return i !== -1 ? e = this.pages[i] : (i = V(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
|
|
2544
2538
|
}
|
|
2545
2539
|
/**
|
|
2546
2540
|
* Get an EpubCFI from a Page List Item
|
|
@@ -2551,7 +2545,7 @@ class ut {
|
|
|
2551
2545
|
let e = -1;
|
|
2552
2546
|
typeof t != "number" && (t = parseInt(t));
|
|
2553
2547
|
const i = this.pages.indexOf(t);
|
|
2554
|
-
return i
|
|
2548
|
+
return i !== -1 && i < this.locations.length && (e = this.locations[i]), e;
|
|
2555
2549
|
}
|
|
2556
2550
|
/**
|
|
2557
2551
|
* Get a Page from Book percentage
|
|
@@ -2586,7 +2580,7 @@ class ut {
|
|
|
2586
2580
|
this.pages = void 0, this.locations = void 0, this.epubcfi = void 0, this.pageList = void 0, this.toc = void 0, this.ncx = void 0;
|
|
2587
2581
|
}
|
|
2588
2582
|
}
|
|
2589
|
-
class
|
|
2583
|
+
class Kt {
|
|
2590
2584
|
constructor(t) {
|
|
2591
2585
|
this.settings = t, this.name = t.layout || "reflowable", this._spread = t.spread !== "none", this._minSpreadWidth = t.minSpreadWidth || 800, this._evenSpreads = t.evenSpreads || !1, t.flow === "scrolled" || t.flow === "scrolled-continuous" || t.flow === "scrolled-doc" ? this._flow = "scrolled" : this._flow = "paginated", this.width = 0, this.height = 0, this.spreadWidth = 0, this.delta = 0, this.columnWidth = 0, this.gap = 0, this.divisor = 1, this.props = {
|
|
2592
2586
|
name: this.name,
|
|
@@ -2628,16 +2622,16 @@ class Gt {
|
|
|
2628
2622
|
calculate(t, e, i) {
|
|
2629
2623
|
let s = 1, n = i || 0, r = t;
|
|
2630
2624
|
const o = e, h = Math.floor(r / 12);
|
|
2631
|
-
let
|
|
2632
|
-
this._spread && r >= this._minSpreadWidth ? s = 2 : s = 1, this.name === "reflowable" && this._flow === "paginated" && !(i !== void 0 && i >= 0) && (n = h % 2 === 0 ? h : h - 1), this.name === "pre-paginated" && (n = 0), s > 1 ? (
|
|
2633
|
-
const d =
|
|
2634
|
-
this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta = u, this.columnWidth =
|
|
2625
|
+
let l, c;
|
|
2626
|
+
this._spread && r >= this._minSpreadWidth ? s = 2 : s = 1, this.name === "reflowable" && this._flow === "paginated" && !(i !== void 0 && i >= 0) && (n = h % 2 === 0 ? h : h - 1), this.name === "pre-paginated" && (n = 0), s > 1 ? (l = r / s - n, c = l + n) : (l = r, c = r), this.name === "pre-paginated" && s > 1 && (r = l);
|
|
2627
|
+
const d = l * s + n, u = r;
|
|
2628
|
+
this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta = u, this.columnWidth = l, this.gap = n, this.divisor = s, this.update({
|
|
2635
2629
|
width: r,
|
|
2636
2630
|
height: o,
|
|
2637
2631
|
spreadWidth: d,
|
|
2638
2632
|
pageWidth: c,
|
|
2639
2633
|
delta: u,
|
|
2640
|
-
columnWidth:
|
|
2634
|
+
columnWidth: l,
|
|
2641
2635
|
gap: n,
|
|
2642
2636
|
divisor: s
|
|
2643
2637
|
});
|
|
@@ -2679,8 +2673,8 @@ class Gt {
|
|
|
2679
2673
|
}
|
|
2680
2674
|
}
|
|
2681
2675
|
}
|
|
2682
|
-
P(
|
|
2683
|
-
class
|
|
2676
|
+
P(Kt.prototype);
|
|
2677
|
+
class Ce {
|
|
2684
2678
|
constructor(t) {
|
|
2685
2679
|
this.rendition = t, this._themes = {
|
|
2686
2680
|
default: {
|
|
@@ -2739,7 +2733,7 @@ class Se {
|
|
|
2739
2733
|
* @param {string} css
|
|
2740
2734
|
*/
|
|
2741
2735
|
registerCss(t, e) {
|
|
2742
|
-
this._themes[t] = { serialized: e }, (this._injected[t] || t
|
|
2736
|
+
this._themes[t] = { serialized: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2743
2737
|
}
|
|
2744
2738
|
/**
|
|
2745
2739
|
* Register a url
|
|
@@ -2748,7 +2742,7 @@ class Se {
|
|
|
2748
2742
|
*/
|
|
2749
2743
|
registerUrl(t, e) {
|
|
2750
2744
|
const i = new R(e);
|
|
2751
|
-
this._themes[t] = { url: i.toString() }, (this._injected[t] || t
|
|
2745
|
+
this._themes[t] = { url: i.toString() }, (this._injected[t] || t === "default") && this.update(t);
|
|
2752
2746
|
}
|
|
2753
2747
|
/**
|
|
2754
2748
|
* Register rule
|
|
@@ -2756,7 +2750,7 @@ class Se {
|
|
|
2756
2750
|
* @param {object} rules
|
|
2757
2751
|
*/
|
|
2758
2752
|
registerRules(t, e) {
|
|
2759
|
-
this._themes[t] = { rules: e }, (this._injected[t] || t
|
|
2753
|
+
this._themes[t] = { rules: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2760
2754
|
}
|
|
2761
2755
|
/**
|
|
2762
2756
|
* Select a theme
|
|
@@ -2786,7 +2780,7 @@ class Se {
|
|
|
2786
2780
|
let s;
|
|
2787
2781
|
for (const n in i)
|
|
2788
2782
|
i.hasOwnProperty(n) && (n === this._current || n === "default") && (s = i[n], (s.rules && Object.keys(s.rules).length > 0 || s.url && e.indexOf(s.url) === -1 || s.serialized) && this.add(n, t), this._injected.push(n));
|
|
2789
|
-
this._current
|
|
2783
|
+
this._current !== "default" && t.addClass(this._current);
|
|
2790
2784
|
}
|
|
2791
2785
|
/**
|
|
2792
2786
|
* Add Theme to contents
|
|
@@ -2845,7 +2839,7 @@ class Se {
|
|
|
2845
2839
|
this.rendition = void 0, this._themes = void 0, this._overrides = void 0, this._current = void 0, this._injected = void 0;
|
|
2846
2840
|
}
|
|
2847
2841
|
}
|
|
2848
|
-
class
|
|
2842
|
+
class Te {
|
|
2849
2843
|
constructor(t) {
|
|
2850
2844
|
this.rendition = t, this.highlights = [], this.underlines = [], this.marks = [], this._annotations = {}, this._annotationsBySectionIndex = {}, this.rendition.hooks.render.register((e) => this.inject(e)), this.rendition.hooks.unloaded.register((e) => this.clear(e));
|
|
2851
2845
|
}
|
|
@@ -2860,16 +2854,16 @@ class _e {
|
|
|
2860
2854
|
* @returns {Annotation} annotation
|
|
2861
2855
|
*/
|
|
2862
2856
|
add(t, e, i, s, n, r) {
|
|
2863
|
-
const o = encodeURI(e + t),
|
|
2857
|
+
const o = encodeURI(e + t), l = new y(e).spinePos, c = new Zt({
|
|
2864
2858
|
type: t,
|
|
2865
2859
|
cfiRange: e,
|
|
2866
2860
|
data: i,
|
|
2867
|
-
sectionIndex:
|
|
2861
|
+
sectionIndex: l,
|
|
2868
2862
|
cb: s,
|
|
2869
2863
|
className: n,
|
|
2870
2864
|
styles: r
|
|
2871
2865
|
});
|
|
2872
|
-
return this._annotations[o] = c,
|
|
2866
|
+
return this._annotations[o] = c, l in this._annotationsBySectionIndex ? this._annotationsBySectionIndex[l].push(o) : this._annotationsBySectionIndex[l] = [o], this.rendition.views().forEach((u) => {
|
|
2873
2867
|
c.sectionIndex === u.index && c.attach(u);
|
|
2874
2868
|
}), c;
|
|
2875
2869
|
}
|
|
@@ -2979,7 +2973,7 @@ class _e {
|
|
|
2979
2973
|
hide() {
|
|
2980
2974
|
}
|
|
2981
2975
|
}
|
|
2982
|
-
class
|
|
2976
|
+
class Zt {
|
|
2983
2977
|
constructor({
|
|
2984
2978
|
type: t,
|
|
2985
2979
|
cfiRange: e,
|
|
@@ -3004,8 +2998,8 @@ class Yt {
|
|
|
3004
2998
|
*/
|
|
3005
2999
|
attach(t) {
|
|
3006
3000
|
const { cfiRange: e, data: i, type: s, mark: n, cb: r, className: o, styles: h } = this;
|
|
3007
|
-
let
|
|
3008
|
-
return s === "highlight" ?
|
|
3001
|
+
let l;
|
|
3002
|
+
return s === "highlight" ? l = t.highlight(e, i, r, o, h) : s === "underline" ? l = t.underline(e, i, r, o, h) : s === "mark" && (l = t.mark(e, i, r)), this.mark = l, this.emit(f.ANNOTATION.ATTACH, l), l;
|
|
3009
3003
|
}
|
|
3010
3004
|
/**
|
|
3011
3005
|
* Remove from a view
|
|
@@ -3022,8 +3016,8 @@ class Yt {
|
|
|
3022
3016
|
text() {
|
|
3023
3017
|
}
|
|
3024
3018
|
}
|
|
3025
|
-
P(
|
|
3026
|
-
class
|
|
3019
|
+
P(Zt.prototype);
|
|
3020
|
+
class wt {
|
|
3027
3021
|
constructor(t, e, i, s = !1) {
|
|
3028
3022
|
this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
|
|
3029
3023
|
}
|
|
@@ -3050,8 +3044,8 @@ class bt {
|
|
|
3050
3044
|
end: this.findEnd(n, i, s)
|
|
3051
3045
|
});
|
|
3052
3046
|
if (this._dev === !0) {
|
|
3053
|
-
const o = t.document, h = new y(r.start).toRange(o),
|
|
3054
|
-
c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(
|
|
3047
|
+
const o = t.document, h = new y(r.start).toRange(o), l = new y(r.end).toRange(o), c = o.defaultView.getSelection(), d = o.createRange();
|
|
3048
|
+
c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(l.endContainer, l.endOffset), c.addRange(d);
|
|
3055
3049
|
}
|
|
3056
3050
|
return r;
|
|
3057
3051
|
}
|
|
@@ -3075,11 +3069,11 @@ class bt {
|
|
|
3075
3069
|
}
|
|
3076
3070
|
findRanges(t) {
|
|
3077
3071
|
const e = [], i = t.contents.scrollWidth(), n = Math.ceil(i / this.layout.spreadWidth) * this.layout.divisor, r = this.layout.columnWidth, o = this.layout.gap;
|
|
3078
|
-
let h,
|
|
3072
|
+
let h, l;
|
|
3079
3073
|
for (let c = 0; c < n; c++)
|
|
3080
|
-
h = (r + o) * c,
|
|
3081
|
-
start: this.findStart(t.document.body, h,
|
|
3082
|
-
end: this.findEnd(t.document.body, h,
|
|
3074
|
+
h = (r + o) * c, l = r * (c + 1) + o * c, e.push({
|
|
3075
|
+
start: this.findStart(t.document.body, h, l),
|
|
3076
|
+
end: this.findEnd(t.document.body, h, l)
|
|
3083
3077
|
});
|
|
3084
3078
|
return e;
|
|
3085
3079
|
}
|
|
@@ -3096,18 +3090,18 @@ class bt {
|
|
|
3096
3090
|
let n, r, o = t;
|
|
3097
3091
|
for (; s.length; )
|
|
3098
3092
|
if (n = s.shift(), r = this.walk(n, (h) => {
|
|
3099
|
-
let
|
|
3100
|
-
const p =
|
|
3093
|
+
let l, c, d, u;
|
|
3094
|
+
const p = ft(h);
|
|
3101
3095
|
if (this.horizontal && this.direction === "ltr") {
|
|
3102
|
-
if (
|
|
3096
|
+
if (l = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, l >= e && l <= i)
|
|
3103
3097
|
return h;
|
|
3104
3098
|
if (c > e)
|
|
3105
3099
|
return h;
|
|
3106
3100
|
o = h, s.push(h);
|
|
3107
3101
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3108
|
-
if (
|
|
3102
|
+
if (l = p.left, c = p.right, c <= i && c >= e)
|
|
3109
3103
|
return h;
|
|
3110
|
-
if (
|
|
3104
|
+
if (l < i)
|
|
3111
3105
|
return h;
|
|
3112
3106
|
o = h, s.push(h);
|
|
3113
3107
|
} else {
|
|
@@ -3134,18 +3128,18 @@ class bt {
|
|
|
3134
3128
|
let n, r = t, o;
|
|
3135
3129
|
for (; s.length; )
|
|
3136
3130
|
if (n = s.shift(), o = this.walk(n, (h) => {
|
|
3137
|
-
let
|
|
3138
|
-
const p =
|
|
3131
|
+
let l, c, d, u;
|
|
3132
|
+
const p = ft(h);
|
|
3139
3133
|
if (this.horizontal && this.direction === "ltr") {
|
|
3140
|
-
if (
|
|
3134
|
+
if (l = Math.round(p.left), c = Math.round(p.right), l > i && r)
|
|
3141
3135
|
return r;
|
|
3142
3136
|
if (c > i)
|
|
3143
3137
|
return h;
|
|
3144
3138
|
r = h, s.push(h);
|
|
3145
3139
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3146
|
-
if (
|
|
3140
|
+
if (l = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
|
|
3147
3141
|
return r;
|
|
3148
|
-
if (
|
|
3142
|
+
if (l < e)
|
|
3149
3143
|
return h;
|
|
3150
3144
|
r = h, s.push(h);
|
|
3151
3145
|
} else {
|
|
@@ -3169,13 +3163,13 @@ class bt {
|
|
|
3169
3163
|
*/
|
|
3170
3164
|
findTextStartRange(t, e, i) {
|
|
3171
3165
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3172
|
-
let n, r, o, h,
|
|
3166
|
+
let n, r, o, h, l;
|
|
3173
3167
|
for (let c = 0; c < s.length; c++)
|
|
3174
3168
|
if (n = s[c], r = n.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3175
3169
|
if (o = r.left, o >= e)
|
|
3176
3170
|
return n;
|
|
3177
3171
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3178
|
-
if (
|
|
3172
|
+
if (l = r.right, l <= i)
|
|
3179
3173
|
return n;
|
|
3180
3174
|
} else if (h = r.top, h >= e)
|
|
3181
3175
|
return n;
|
|
@@ -3191,15 +3185,15 @@ class bt {
|
|
|
3191
3185
|
*/
|
|
3192
3186
|
findTextEndRange(t, e, i) {
|
|
3193
3187
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3194
|
-
let n, r, o, h,
|
|
3188
|
+
let n, r, o, h, l, c, d;
|
|
3195
3189
|
for (let u = 0; u < s.length; u++) {
|
|
3196
3190
|
if (r = s[u], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3197
|
-
if (h = o.left,
|
|
3191
|
+
if (h = o.left, l = o.right, h > i && n)
|
|
3198
3192
|
return n;
|
|
3199
|
-
if (
|
|
3193
|
+
if (l > i)
|
|
3200
3194
|
return r;
|
|
3201
3195
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3202
|
-
if (h = o.left,
|
|
3196
|
+
if (h = o.left, l = o.right, l < e && n)
|
|
3203
3197
|
return n;
|
|
3204
3198
|
if (h < e)
|
|
3205
3199
|
return r;
|
|
@@ -3224,11 +3218,11 @@ class bt {
|
|
|
3224
3218
|
const i = [], n = (t.textContent || "").trim();
|
|
3225
3219
|
let r;
|
|
3226
3220
|
const o = t.ownerDocument, h = e || " ";
|
|
3227
|
-
let
|
|
3228
|
-
if (
|
|
3221
|
+
let l = n.indexOf(h);
|
|
3222
|
+
if (l === -1 || t.nodeType !== Node.TEXT_NODE)
|
|
3229
3223
|
return r = o.createRange(), r.selectNodeContents(t), [r];
|
|
3230
|
-
for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t,
|
|
3231
|
-
|
|
3224
|
+
for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t, l), i.push(r), r = null; l !== -1; )
|
|
3225
|
+
l = n.indexOf(h, l + 1), l > 0 && (r && (r.setEnd(t, l), i.push(r)), r = o.createRange(), r.setStart(t, l + 1));
|
|
3232
3226
|
return r && (r.setEnd(t, n.length), i.push(r)), i;
|
|
3233
3227
|
}
|
|
3234
3228
|
/**
|
|
@@ -3263,19 +3257,19 @@ class bt {
|
|
|
3263
3257
|
return t && (this.horizontal = t === "horizontal"), this.horizontal;
|
|
3264
3258
|
}
|
|
3265
3259
|
}
|
|
3266
|
-
const
|
|
3267
|
-
class
|
|
3260
|
+
const ke = typeof navigator < "u", Pt = ke && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), Ne = 1;
|
|
3261
|
+
class Nt {
|
|
3268
3262
|
constructor(t, e, i, s) {
|
|
3269
3263
|
this.epubcfi = new y(), this.document = t, this.documentElement = this.document.documentElement, this.content = e || this.document.body, this.window = this.document.defaultView, this._size = {
|
|
3270
3264
|
width: 0,
|
|
3271
3265
|
height: 0
|
|
3272
|
-
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js",
|
|
3266
|
+
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js", nt), this.called = 0, this.active = !0, this.listeners();
|
|
3273
3267
|
}
|
|
3274
3268
|
/**
|
|
3275
3269
|
* Get DOM events that are listened for and passed along
|
|
3276
3270
|
*/
|
|
3277
3271
|
static get listenedEvents() {
|
|
3278
|
-
return
|
|
3272
|
+
return Z;
|
|
3279
3273
|
}
|
|
3280
3274
|
/**
|
|
3281
3275
|
* Get or Set width
|
|
@@ -3284,7 +3278,7 @@ class Tt {
|
|
|
3284
3278
|
*/
|
|
3285
3279
|
width(t) {
|
|
3286
3280
|
const e = this.content;
|
|
3287
|
-
return t &&
|
|
3281
|
+
return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3288
3282
|
}
|
|
3289
3283
|
/**
|
|
3290
3284
|
* Get or Set height
|
|
@@ -3293,7 +3287,7 @@ class Tt {
|
|
|
3293
3287
|
*/
|
|
3294
3288
|
height(t) {
|
|
3295
3289
|
const e = this.content;
|
|
3296
|
-
return t &&
|
|
3290
|
+
return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3297
3291
|
}
|
|
3298
3292
|
/**
|
|
3299
3293
|
* Get or Set width of the contents
|
|
@@ -3302,7 +3296,7 @@ class Tt {
|
|
|
3302
3296
|
*/
|
|
3303
3297
|
contentWidth(t) {
|
|
3304
3298
|
const e = this.content || this.document.body;
|
|
3305
|
-
return t &&
|
|
3299
|
+
return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3306
3300
|
}
|
|
3307
3301
|
/**
|
|
3308
3302
|
* Get or Set height of the contents
|
|
@@ -3311,7 +3305,7 @@ class Tt {
|
|
|
3311
3305
|
*/
|
|
3312
3306
|
contentHeight(t) {
|
|
3313
3307
|
const e = this.content || this.document.body;
|
|
3314
|
-
return t &&
|
|
3308
|
+
return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3315
3309
|
}
|
|
3316
3310
|
/**
|
|
3317
3311
|
* Get the width of the text using Range
|
|
@@ -3319,7 +3313,7 @@ class Tt {
|
|
|
3319
3313
|
*/
|
|
3320
3314
|
textWidth() {
|
|
3321
3315
|
let t;
|
|
3322
|
-
const e = this.document.createRange(), i = this.content || this.document.body, s =
|
|
3316
|
+
const e = this.document.createRange(), i = this.content || this.document.body, s = J(i);
|
|
3323
3317
|
return e.selectNodeContents(i), t = e.getBoundingClientRect().width, s && s.width && (t += s.width), Math.round(t);
|
|
3324
3318
|
}
|
|
3325
3319
|
/**
|
|
@@ -3377,6 +3371,17 @@ class Tt {
|
|
|
3377
3371
|
const s = this.content || this.document.body;
|
|
3378
3372
|
return e ? s.style.setProperty(t, e, i ? "important" : "") : s.style.removeProperty(t), this.window.getComputedStyle(s)[t] ?? "";
|
|
3379
3373
|
}
|
|
3374
|
+
/**
|
|
3375
|
+
* Set multiple Css properties at once without triggering
|
|
3376
|
+
* intermediate getComputedStyle reads.
|
|
3377
|
+
* @param {Array<[string, string?, boolean?]>} properties
|
|
3378
|
+
* @private
|
|
3379
|
+
*/
|
|
3380
|
+
cssBatch(t) {
|
|
3381
|
+
const e = this.content || this.document.body;
|
|
3382
|
+
for (const [i, s, n] of t)
|
|
3383
|
+
s ? e.style.setProperty(i, s, n ? "important" : "") : e.style.removeProperty(i);
|
|
3384
|
+
}
|
|
3380
3385
|
/**
|
|
3381
3386
|
* Get or Set the viewport element
|
|
3382
3387
|
* @param {object} [options]
|
|
@@ -3399,10 +3404,10 @@ class Tt {
|
|
|
3399
3404
|
}, s = [];
|
|
3400
3405
|
let n = {};
|
|
3401
3406
|
if (e && e.hasAttribute("content")) {
|
|
3402
|
-
const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/),
|
|
3403
|
-
o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]),
|
|
3407
|
+
const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/), l = r.match(/initial-scale\s*=\s*([^,]*)/), c = r.match(/minimum-scale\s*=\s*([^,]*)/), d = r.match(/maximum-scale\s*=\s*([^,]*)/), u = r.match(/user-scalable\s*=\s*([^,]*)/);
|
|
3408
|
+
o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]), l && l.length && typeof l[1] < "u" && (i.scale = l[1]), c && c.length && typeof c[1] < "u" && (i.minimum = c[1]), d && d.length && typeof d[1] < "u" && (i.maximum = d[1]), u && u.length && typeof u[1] < "u" && (i.scalable = u[1]);
|
|
3404
3409
|
}
|
|
3405
|
-
return n =
|
|
3410
|
+
return n = qt(t ?? {}, i), t && (n.width && s.push("width=" + n.width), n.height && s.push("height=" + n.height), n.scale && s.push("initial-scale=" + n.scale), n.scalable === "no" ? (s.push("minimum-scale=" + n.scale), s.push("maximum-scale=" + n.scale), s.push("user-scalable=" + n.scalable)) : (n.scalable && s.push("user-scalable=" + n.scalable), n.minimum && s.push("minimum-scale=" + n.minimum), n.maximum && s.push("minimum-scale=" + n.maximum)), e || (e = this.document.createElement("meta"), e.setAttribute("name", "viewport"), this.document.querySelector("head").appendChild(e)), e.setAttribute("content", s.join(", ")), this.window.scrollTo(0, 0)), n;
|
|
3406
3411
|
}
|
|
3407
3412
|
/**
|
|
3408
3413
|
* Event emitter for when the contents has expanded
|
|
@@ -3416,17 +3421,17 @@ class Tt {
|
|
|
3416
3421
|
* @private
|
|
3417
3422
|
*/
|
|
3418
3423
|
listeners() {
|
|
3419
|
-
this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(),
|
|
3424
|
+
this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(), this.resizeObservers(), this.linksHandler();
|
|
3420
3425
|
}
|
|
3421
3426
|
/**
|
|
3422
3427
|
* Remove DOM listeners
|
|
3423
3428
|
* @private
|
|
3424
3429
|
*/
|
|
3425
3430
|
removeListeners() {
|
|
3426
|
-
this.removeEventListeners(), this.removeSelectionListeners(), this.
|
|
3431
|
+
this.removeEventListeners(), this.removeSelectionListeners(), this._resizeCheck && (this.document.removeEventListener("transitionend", this._resizeCheck), this._resizeCheck = void 0);
|
|
3427
3432
|
for (const { mql: e, handler: i } of this._mediaQueryHandlers)
|
|
3428
3433
|
e.removeEventListener("change", i);
|
|
3429
|
-
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect()
|
|
3434
|
+
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect();
|
|
3430
3435
|
const t = this.document.querySelectorAll("img");
|
|
3431
3436
|
for (let e = 0; e < t.length; e++)
|
|
3432
3437
|
t[e].onload = null;
|
|
@@ -3438,27 +3443,11 @@ class Tt {
|
|
|
3438
3443
|
*/
|
|
3439
3444
|
resizeCheck() {
|
|
3440
3445
|
const t = this.textWidth(), e = this.textHeight();
|
|
3441
|
-
(t
|
|
3446
|
+
(t !== this._size.width || e !== this._size.height) && (this._size = {
|
|
3442
3447
|
width: t,
|
|
3443
3448
|
height: e
|
|
3444
3449
|
}, this.onResize && this.onResize(this._size), this.emit(f.CONTENTS.RESIZE, this._size));
|
|
3445
3450
|
}
|
|
3446
|
-
/**
|
|
3447
|
-
* Poll for resize detection
|
|
3448
|
-
* @private
|
|
3449
|
-
*/
|
|
3450
|
-
resizeListeners() {
|
|
3451
|
-
clearTimeout(this.expanding), requestAnimationFrame(this.resizeCheck.bind(this)), this.expanding = setTimeout(this.resizeListeners.bind(this), 350);
|
|
3452
|
-
}
|
|
3453
|
-
/**
|
|
3454
|
-
* Listen for visibility of tab to change
|
|
3455
|
-
* @private
|
|
3456
|
-
*/
|
|
3457
|
-
visibilityListeners() {
|
|
3458
|
-
this._onVisibilityChange = () => {
|
|
3459
|
-
document.visibilityState === "visible" && this.active === !1 ? (this.active = !0, this.resizeListeners()) : (this.active = !1, clearTimeout(this.expanding));
|
|
3460
|
-
}, document.addEventListener("visibilitychange", this._onVisibilityChange);
|
|
3461
|
-
}
|
|
3462
3451
|
/**
|
|
3463
3452
|
* Use css transitions to detect resize
|
|
3464
3453
|
* @private
|
|
@@ -3474,7 +3463,7 @@ class Tt {
|
|
|
3474
3463
|
*/
|
|
3475
3464
|
mediaQueryListeners() {
|
|
3476
3465
|
const t = this.document.styleSheets, e = (i) => {
|
|
3477
|
-
i.matches && !this._expanding && setTimeout(this.expand
|
|
3466
|
+
i.matches && !this._expanding && setTimeout(() => this.expand(), 0);
|
|
3478
3467
|
};
|
|
3479
3468
|
for (let i = 0; i < t.length; i += 1) {
|
|
3480
3469
|
let s;
|
|
@@ -3551,19 +3540,19 @@ class Tt {
|
|
|
3551
3540
|
const n = new y(t).toRange(this.document, e);
|
|
3552
3541
|
if (n) {
|
|
3553
3542
|
try {
|
|
3554
|
-
if (!n.endContainer || n.startContainer
|
|
3543
|
+
if (!n.endContainer || n.startContainer === n.endContainer && n.startOffset === n.endOffset) {
|
|
3555
3544
|
let r = (n.startContainer.textContent ?? "").indexOf(" ", n.startOffset);
|
|
3556
|
-
r
|
|
3545
|
+
r === -1 && (r = (n.startContainer.textContent ?? "").length), n.setEnd(n.startContainer, r);
|
|
3557
3546
|
}
|
|
3558
3547
|
} catch (r) {
|
|
3559
3548
|
console.error("setting end offset to start container length failed", r);
|
|
3560
3549
|
}
|
|
3561
3550
|
if (n.startContainer.nodeType === Node.ELEMENT_NODE)
|
|
3562
3551
|
i = n.startContainer.getBoundingClientRect(), s.left = i.left, s.top = i.top;
|
|
3563
|
-
else if (
|
|
3552
|
+
else if (Pt) {
|
|
3564
3553
|
const r = n.startContainer, o = new Range();
|
|
3565
3554
|
try {
|
|
3566
|
-
r.nodeType ===
|
|
3555
|
+
r.nodeType === Ne ? i = r.getBoundingClientRect() : n.startOffset + 2 < r.length ? (o.setStart(r, n.startOffset), o.setEnd(r, n.startOffset + 2), i = o.getBoundingClientRect()) : n.startOffset - 2 > 0 ? (o.setStart(r, n.startOffset - 2), o.setEnd(r, n.startOffset), i = o.getBoundingClientRect()) : i = r.parentNode.getBoundingClientRect();
|
|
3567
3556
|
} catch (h) {
|
|
3568
3557
|
console.error(h, h instanceof Error ? h.stack : void 0);
|
|
3569
3558
|
}
|
|
@@ -3573,7 +3562,7 @@ class Tt {
|
|
|
3573
3562
|
} else if (typeof t == "string" && t.indexOf("#") > -1) {
|
|
3574
3563
|
const n = t.substring(t.indexOf("#") + 1), r = this.document.getElementById(n);
|
|
3575
3564
|
if (r)
|
|
3576
|
-
if (
|
|
3565
|
+
if (Pt) {
|
|
3577
3566
|
const o = new Range();
|
|
3578
3567
|
o.selectNode(r), i = o.getBoundingClientRect();
|
|
3579
3568
|
} else
|
|
@@ -3599,7 +3588,7 @@ class Tt {
|
|
|
3599
3588
|
s = this.document.createElement("link"), s.type = "text/css", s.rel = "stylesheet", s.href = t, s.onload = () => {
|
|
3600
3589
|
n || (n = !0, setTimeout(() => {
|
|
3601
3590
|
e(!0);
|
|
3602
|
-
},
|
|
3591
|
+
}, 0));
|
|
3603
3592
|
}, this.document.head.appendChild(s);
|
|
3604
3593
|
});
|
|
3605
3594
|
}
|
|
@@ -3630,15 +3619,15 @@ class Tt {
|
|
|
3630
3619
|
const i = this._getStylesheetNode(e).sheet;
|
|
3631
3620
|
if (Array.isArray(t))
|
|
3632
3621
|
for (let n = 0, r = t.length; n < r; n++) {
|
|
3633
|
-
let o = 1, h = t[n],
|
|
3622
|
+
let o = 1, h = t[n], l = "";
|
|
3634
3623
|
const c = t[n][0];
|
|
3635
3624
|
Array.isArray((s = h[1]) == null ? void 0 : s[0]) && (h = h[1], o = 0);
|
|
3636
3625
|
for (let d = h.length; o < d; o++) {
|
|
3637
3626
|
const u = h[o];
|
|
3638
|
-
|
|
3627
|
+
l += u[0] + ":" + u[1] + (u[2] ? " !important" : "") + `;
|
|
3639
3628
|
`;
|
|
3640
3629
|
}
|
|
3641
|
-
i.insertRule(c + "{" +
|
|
3630
|
+
i.insertRule(c + "{" + l + "}", i.cssRules.length);
|
|
3642
3631
|
}
|
|
3643
3632
|
else
|
|
3644
3633
|
Object.keys(t).forEach((r) => {
|
|
@@ -3649,8 +3638,8 @@ class Tt {
|
|
|
3649
3638
|
i.insertRule(`${r}{${c}}`, i.cssRules.length);
|
|
3650
3639
|
});
|
|
3651
3640
|
else {
|
|
3652
|
-
const
|
|
3653
|
-
i.insertRule(`${r}{${
|
|
3641
|
+
const l = Object.keys(o).map((c) => `${c}:${o[c]}`).join(";");
|
|
3642
|
+
i.insertRule(`${r}{${l}}`, i.cssRules.length);
|
|
3654
3643
|
}
|
|
3655
3644
|
});
|
|
3656
3645
|
}
|
|
@@ -3670,7 +3659,7 @@ class Tt {
|
|
|
3670
3659
|
n.type = "text/javascript", n.async = !0, n.src = t, n.onload = () => {
|
|
3671
3660
|
s || (s = !0, setTimeout(() => {
|
|
3672
3661
|
e(!0);
|
|
3673
|
-
},
|
|
3662
|
+
}, 0));
|
|
3674
3663
|
}, this.document.head.appendChild(n);
|
|
3675
3664
|
});
|
|
3676
3665
|
}
|
|
@@ -3697,7 +3686,7 @@ class Tt {
|
|
|
3697
3686
|
* @private
|
|
3698
3687
|
*/
|
|
3699
3688
|
addEventListeners() {
|
|
3700
|
-
this.document && (this._triggerEvent = this.triggerEvent.bind(this),
|
|
3689
|
+
this.document && (this._triggerEvent = this.triggerEvent.bind(this), Z.forEach((t) => {
|
|
3701
3690
|
this.document.addEventListener(t, this._triggerEvent, { passive: !0 });
|
|
3702
3691
|
}));
|
|
3703
3692
|
}
|
|
@@ -3706,7 +3695,7 @@ class Tt {
|
|
|
3706
3695
|
* @private
|
|
3707
3696
|
*/
|
|
3708
3697
|
removeEventListeners() {
|
|
3709
|
-
this.document && (
|
|
3698
|
+
this.document && (Z.forEach((t) => {
|
|
3710
3699
|
this.document.removeEventListener(t, this._triggerEvent);
|
|
3711
3700
|
}), this._triggerEvent = void 0);
|
|
3712
3701
|
}
|
|
@@ -3783,7 +3772,12 @@ class Tt {
|
|
|
3783
3772
|
*/
|
|
3784
3773
|
size(t, e) {
|
|
3785
3774
|
const i = { scale: 1, scalable: "no" };
|
|
3786
|
-
this.layoutStyle("scrolling")
|
|
3775
|
+
this.layoutStyle("scrolling");
|
|
3776
|
+
const s = [];
|
|
3777
|
+
t !== void 0 && t >= 0 && (this.width(t), i.width = t, s.push(["padding", "0 " + t / 12 + "px"])), e !== void 0 && e >= 0 && (this.height(e), i.height = e), s.push(
|
|
3778
|
+
["margin", "0"],
|
|
3779
|
+
["box-sizing", "border-box"]
|
|
3780
|
+
), this.cssBatch(s), this.viewport(i);
|
|
3787
3781
|
}
|
|
3788
3782
|
/**
|
|
3789
3783
|
* Apply columns to the contents for pagination
|
|
@@ -3793,8 +3787,37 @@ class Tt {
|
|
|
3793
3787
|
* @param {number} gap
|
|
3794
3788
|
*/
|
|
3795
3789
|
columns(t, e, i, s, n) {
|
|
3796
|
-
const r =
|
|
3797
|
-
this.layoutStyle("paginated"), n === "rtl" && d === "horizontal" && this.direction(n), this.width(t), this.height(e), this.viewport({ width: t, height: e, scale: 1, scalable: "no" })
|
|
3790
|
+
const r = "-webkit-column-axis", o = "column-gap", h = "column-width", l = "column-fill", d = this.writingMode().indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
|
3791
|
+
this.layoutStyle("paginated"), n === "rtl" && d === "horizontal" && this.direction(n), this.width(t), this.height(e), this.viewport({ width: t, height: e, scale: 1, scalable: "no" });
|
|
3792
|
+
const u = [
|
|
3793
|
+
// Fixes Safari column cut offs, but causes RTL issues.
|
|
3794
|
+
// Required on iOS: block-level body in CSS columns triggers a
|
|
3795
|
+
// WKWebView content-size expansion feedback loop where scrollWidth
|
|
3796
|
+
// grows toward infinity. inline-block shrink-wraps the body to
|
|
3797
|
+
// its explicit width, breaking the cycle.
|
|
3798
|
+
["display", "inline-block"],
|
|
3799
|
+
["overflow-y", "hidden"],
|
|
3800
|
+
["margin", "0", !0]
|
|
3801
|
+
];
|
|
3802
|
+
d === "vertical" ? u.push(
|
|
3803
|
+
["padding-top", s / 2 + "px", !0],
|
|
3804
|
+
["padding-bottom", s / 2 + "px", !0],
|
|
3805
|
+
["padding-left", "20px"],
|
|
3806
|
+
["padding-right", "20px"],
|
|
3807
|
+
[r, "vertical"]
|
|
3808
|
+
) : u.push(
|
|
3809
|
+
["padding-top", "20px"],
|
|
3810
|
+
["padding-bottom", "20px"],
|
|
3811
|
+
["padding-left", s / 2 + "px", !0],
|
|
3812
|
+
["padding-right", s / 2 + "px", !0],
|
|
3813
|
+
[r, "horizontal"]
|
|
3814
|
+
), u.push(
|
|
3815
|
+
["box-sizing", "border-box"],
|
|
3816
|
+
["max-width", "inherit"],
|
|
3817
|
+
[l, "auto"],
|
|
3818
|
+
[o, s + "px"],
|
|
3819
|
+
[h, i + "px"]
|
|
3820
|
+
), this.cssBatch(u);
|
|
3798
3821
|
}
|
|
3799
3822
|
/**
|
|
3800
3823
|
* Scale contents from center
|
|
@@ -3813,11 +3836,18 @@ class Tt {
|
|
|
3813
3836
|
* @param {number} height
|
|
3814
3837
|
*/
|
|
3815
3838
|
fit(t, e, i) {
|
|
3816
|
-
const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r,
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3839
|
+
const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r, l = o < h ? o : h;
|
|
3840
|
+
this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(l, 0, 0);
|
|
3841
|
+
const c = [
|
|
3842
|
+
// background images are not scaled by transform
|
|
3843
|
+
["background-size", n * l + "px " + r * l + "px"],
|
|
3844
|
+
["background-color", "transparent"]
|
|
3845
|
+
];
|
|
3846
|
+
if (i && i.properties.includes("page-spread-left")) {
|
|
3847
|
+
const d = t - n * l;
|
|
3848
|
+
c.push(["margin-left", d + "px"]);
|
|
3820
3849
|
}
|
|
3850
|
+
this.cssBatch(c);
|
|
3821
3851
|
}
|
|
3822
3852
|
/**
|
|
3823
3853
|
* Set the direction of the text
|
|
@@ -3827,14 +3857,14 @@ class Tt {
|
|
|
3827
3857
|
this.documentElement && (this.documentElement.style.direction = t);
|
|
3828
3858
|
}
|
|
3829
3859
|
mapPage(t, e, i, s, n) {
|
|
3830
|
-
return new
|
|
3860
|
+
return new wt(e, void 0, void 0, n).page(this, t, i, s);
|
|
3831
3861
|
}
|
|
3832
3862
|
/**
|
|
3833
3863
|
* Emit event when link in content is clicked
|
|
3834
3864
|
* @private
|
|
3835
3865
|
*/
|
|
3836
3866
|
linksHandler() {
|
|
3837
|
-
|
|
3867
|
+
ve(this.content, (t) => {
|
|
3838
3868
|
this.emit(f.CONTENTS.LINK_CLICKED, t);
|
|
3839
3869
|
});
|
|
3840
3870
|
}
|
|
@@ -3843,8 +3873,7 @@ class Tt {
|
|
|
3843
3873
|
* @param {string} [mode="horizontal-tb"] "horizontal-tb" | "vertical-rl" | "vertical-lr"
|
|
3844
3874
|
*/
|
|
3845
3875
|
writingMode(t) {
|
|
3846
|
-
|
|
3847
|
-
return t && this.documentElement && (this.documentElement.style[e] = t), this.window.getComputedStyle(this.documentElement)[e] || "";
|
|
3876
|
+
return t && this.documentElement && (this.documentElement.style.writingMode = t), this.window.getComputedStyle(this.documentElement).writingMode || "";
|
|
3848
3877
|
}
|
|
3849
3878
|
/**
|
|
3850
3879
|
* Set the layoutStyle of the content
|
|
@@ -3889,41 +3918,41 @@ class Tt {
|
|
|
3889
3918
|
this.removeListeners(), this.__listeners = {};
|
|
3890
3919
|
}
|
|
3891
3920
|
}
|
|
3892
|
-
P(
|
|
3893
|
-
function
|
|
3894
|
-
return document.createElementNS("http://www.w3.org/2000/svg",
|
|
3921
|
+
P(Nt.prototype);
|
|
3922
|
+
function $(a) {
|
|
3923
|
+
return document.createElementNS("http://www.w3.org/2000/svg", a);
|
|
3895
3924
|
}
|
|
3896
|
-
function
|
|
3925
|
+
function Le(a, t) {
|
|
3897
3926
|
function e(s) {
|
|
3898
3927
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
3899
3928
|
const r = t[n];
|
|
3900
3929
|
let o, h;
|
|
3901
|
-
if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!
|
|
3902
|
-
r.dispatchEvent(
|
|
3930
|
+
if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ae(r, a, o, h)) {
|
|
3931
|
+
r.dispatchEvent(Re(s));
|
|
3903
3932
|
break;
|
|
3904
3933
|
}
|
|
3905
3934
|
}
|
|
3906
3935
|
}
|
|
3907
3936
|
let i;
|
|
3908
|
-
if (
|
|
3937
|
+
if (a.nodeName === "iframe" || a.nodeName === "IFRAME")
|
|
3909
3938
|
try {
|
|
3910
|
-
i =
|
|
3939
|
+
i = a.contentDocument;
|
|
3911
3940
|
} catch {
|
|
3912
|
-
i =
|
|
3941
|
+
i = a;
|
|
3913
3942
|
}
|
|
3914
3943
|
else
|
|
3915
|
-
i =
|
|
3944
|
+
i = a;
|
|
3916
3945
|
for (const s of ["mouseup", "mousedown", "click", "touchstart"])
|
|
3917
3946
|
i.addEventListener(s, (n) => e(n), !1);
|
|
3918
3947
|
}
|
|
3919
|
-
function
|
|
3920
|
-
const t = Object.assign({},
|
|
3948
|
+
function Re(a) {
|
|
3949
|
+
const t = Object.assign({}, a, { bubbles: !1 });
|
|
3921
3950
|
try {
|
|
3922
|
-
return new MouseEvent(
|
|
3951
|
+
return new MouseEvent(a.type, t);
|
|
3923
3952
|
} catch {
|
|
3924
|
-
const i =
|
|
3953
|
+
const i = a, s = document.createEvent("MouseEvents");
|
|
3925
3954
|
return s.initMouseEvent(
|
|
3926
|
-
|
|
3955
|
+
a.type,
|
|
3927
3956
|
!1,
|
|
3928
3957
|
i.cancelable,
|
|
3929
3958
|
i.view,
|
|
@@ -3941,42 +3970,42 @@ function Le(l) {
|
|
|
3941
3970
|
), s;
|
|
3942
3971
|
}
|
|
3943
3972
|
}
|
|
3944
|
-
function
|
|
3973
|
+
function Ae(a, t, e, i) {
|
|
3945
3974
|
const s = t.getBoundingClientRect();
|
|
3946
|
-
function n(h,
|
|
3975
|
+
function n(h, l, c) {
|
|
3947
3976
|
const d = h.top - s.top, u = h.left - s.left, p = d + h.height, g = u + h.width;
|
|
3948
|
-
return d <= c && u <=
|
|
3977
|
+
return d <= c && u <= l && p > c && g > l;
|
|
3949
3978
|
}
|
|
3950
|
-
const r =
|
|
3979
|
+
const r = a.getBoundingClientRect();
|
|
3951
3980
|
if (!n(r, e, i))
|
|
3952
3981
|
return !1;
|
|
3953
|
-
const o =
|
|
3954
|
-
for (let h = 0,
|
|
3982
|
+
const o = a.getClientRects();
|
|
3983
|
+
for (let h = 0, l = o.length; h < l; h++)
|
|
3955
3984
|
if (n(o[h], e, i))
|
|
3956
3985
|
return !0;
|
|
3957
3986
|
return !1;
|
|
3958
3987
|
}
|
|
3959
|
-
function
|
|
3960
|
-
const e = t.getBoundingClientRect(), i =
|
|
3988
|
+
function Ie(a, t) {
|
|
3989
|
+
const e = t.getBoundingClientRect(), i = a.getBoundingClientRect();
|
|
3961
3990
|
return {
|
|
3962
3991
|
top: i.top - e.top,
|
|
3963
3992
|
left: i.left - e.left,
|
|
3964
|
-
height:
|
|
3965
|
-
width:
|
|
3993
|
+
height: a.scrollHeight,
|
|
3994
|
+
width: a.scrollWidth
|
|
3966
3995
|
};
|
|
3967
3996
|
}
|
|
3968
|
-
function
|
|
3969
|
-
|
|
3997
|
+
function Pe(a, t) {
|
|
3998
|
+
a.style.setProperty("top", `${t.top}px`, "important"), a.style.setProperty("left", `${t.left}px`, "important"), a.style.setProperty("height", `${t.height}px`, "important"), a.style.setProperty("width", `${t.width}px`, "important");
|
|
3970
3999
|
}
|
|
3971
|
-
function
|
|
3972
|
-
return t.right <=
|
|
4000
|
+
function Oe(a, t) {
|
|
4001
|
+
return t.right <= a.right && t.left >= a.left && t.top >= a.top && t.bottom <= a.bottom;
|
|
3973
4002
|
}
|
|
3974
|
-
class
|
|
4003
|
+
class Ot {
|
|
3975
4004
|
constructor(t, e = document.body) {
|
|
3976
|
-
this.target = t, this.element =
|
|
4005
|
+
this.target = t, this.element = $("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), Le(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
|
|
3977
4006
|
}
|
|
3978
4007
|
addMark(t) {
|
|
3979
|
-
const e =
|
|
4008
|
+
const e = $("g");
|
|
3980
4009
|
return this.element.appendChild(e), t.bind(e, this.container), this.marks.push(t), t.render(), t;
|
|
3981
4010
|
}
|
|
3982
4011
|
removeMark(t) {
|
|
@@ -3987,12 +4016,12 @@ class It {
|
|
|
3987
4016
|
this.element.removeChild(i), this.marks.splice(e, 1);
|
|
3988
4017
|
}
|
|
3989
4018
|
render() {
|
|
3990
|
-
|
|
4019
|
+
Pe(this.element, Ie(this.target, this.container));
|
|
3991
4020
|
for (const t of this.marks)
|
|
3992
4021
|
t.render();
|
|
3993
4022
|
}
|
|
3994
4023
|
}
|
|
3995
|
-
class
|
|
4024
|
+
class ze {
|
|
3996
4025
|
constructor() {
|
|
3997
4026
|
this.element = null;
|
|
3998
4027
|
}
|
|
@@ -4024,14 +4053,14 @@ class Oe {
|
|
|
4024
4053
|
for (let i = 0; i < t.length; i++) {
|
|
4025
4054
|
if (t[i] === e)
|
|
4026
4055
|
return !0;
|
|
4027
|
-
if (
|
|
4056
|
+
if (Oe(t[i], e))
|
|
4028
4057
|
return !1;
|
|
4029
4058
|
}
|
|
4030
4059
|
return !0;
|
|
4031
4060
|
});
|
|
4032
4061
|
}
|
|
4033
4062
|
}
|
|
4034
|
-
class
|
|
4063
|
+
class Qt extends ze {
|
|
4035
4064
|
constructor(t, e, i, s) {
|
|
4036
4065
|
super(), this.range = t, this.className = e, this.data = i || {}, this.attributes = s || {};
|
|
4037
4066
|
}
|
|
@@ -4048,13 +4077,13 @@ class Kt extends Oe {
|
|
|
4048
4077
|
this.element.removeChild(this.element.firstChild);
|
|
4049
4078
|
const t = this.element.ownerDocument.createDocumentFragment(), e = this.filteredRanges(), i = this.element.getBoundingClientRect(), s = this.container.getBoundingClientRect();
|
|
4050
4079
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
4051
|
-
const o = e[n], h =
|
|
4080
|
+
const o = e[n], h = $("rect");
|
|
4052
4081
|
h.setAttribute("x", String(o.left - i.left + s.left)), h.setAttribute("y", String(o.top - i.top + s.top)), h.setAttribute("height", String(o.height)), h.setAttribute("width", String(o.width)), t.appendChild(h);
|
|
4053
4082
|
}
|
|
4054
4083
|
this.element.appendChild(t);
|
|
4055
4084
|
}
|
|
4056
4085
|
}
|
|
4057
|
-
class
|
|
4086
|
+
class De extends Qt {
|
|
4058
4087
|
constructor(t, e, i, s) {
|
|
4059
4088
|
super(t, e, i, s);
|
|
4060
4089
|
}
|
|
@@ -4063,15 +4092,15 @@ class Pe extends Kt {
|
|
|
4063
4092
|
this.element.removeChild(this.element.firstChild);
|
|
4064
4093
|
const t = this.element.ownerDocument.createDocumentFragment(), e = this.filteredRanges(), i = this.element.getBoundingClientRect(), s = this.container.getBoundingClientRect();
|
|
4065
4094
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
4066
|
-
const o = e[n], h =
|
|
4095
|
+
const o = e[n], h = $("rect");
|
|
4067
4096
|
h.setAttribute("x", String(o.left - i.left + s.left)), h.setAttribute("y", String(o.top - i.top + s.top)), h.setAttribute("height", String(o.height)), h.setAttribute("width", String(o.width)), h.setAttribute("fill", "none");
|
|
4068
|
-
const
|
|
4069
|
-
|
|
4097
|
+
const l = $("line");
|
|
4098
|
+
l.setAttribute("x1", String(o.left - i.left + s.left)), l.setAttribute("x2", String(o.left - i.left + s.left + o.width)), l.setAttribute("y1", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("y2", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("stroke-width", "1"), l.setAttribute("stroke", "black"), l.setAttribute("stroke-linecap", "square"), t.appendChild(h), t.appendChild(l);
|
|
4070
4099
|
}
|
|
4071
4100
|
this.element.appendChild(t);
|
|
4072
4101
|
}
|
|
4073
4102
|
}
|
|
4074
|
-
class
|
|
4103
|
+
class Jt {
|
|
4075
4104
|
constructor(t, e) {
|
|
4076
4105
|
this.settings = C({
|
|
4077
4106
|
ignoreClass: "",
|
|
@@ -4086,14 +4115,14 @@ class Zt {
|
|
|
4086
4115
|
forceRight: !1,
|
|
4087
4116
|
allowScriptedContent: !1,
|
|
4088
4117
|
allowPopups: !1
|
|
4089
|
-
}, e || {}), this.id = "epubjs-view-" +
|
|
4118
|
+
}, e || {}), this.id = "epubjs-view-" + Et(), this.section = t, this.index = t.index, this.element = this.container(this.settings.axis), this.added = !1, this.displayed = !1, this.rendered = !1, this.fixedWidth = 0, this.fixedHeight = 0, this.epubcfi = new y(), this.layout = this.settings.layout, this.pane = void 0, this.highlights = {}, this.underlines = {}, this.marks = {};
|
|
4090
4119
|
}
|
|
4091
4120
|
container(t) {
|
|
4092
4121
|
const e = document.createElement("div");
|
|
4093
|
-
return e.classList.add("epub-view"), e.style.height = "0px", e.style.width = "0px", e.style.overflow = "hidden", e.style.position = "relative", e.style.display = "block", t && t
|
|
4122
|
+
return e.classList.add("epub-view"), e.style.height = "0px", e.style.width = "0px", e.style.overflow = "hidden", e.style.position = "relative", e.style.display = "block", t && t === "horizontal" ? e.style.flex = "none" : e.style.flex = "initial", e;
|
|
4094
4123
|
}
|
|
4095
4124
|
create() {
|
|
4096
|
-
return this.iframe ? this.iframe : (this.element || (this.element = this.container()), this.iframe = document.createElement("iframe"), this.iframe.id = this.id, this.iframe.scrolling = "no", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("seamless", "seamless"), this.iframe.style.border = "none", this.iframe.sandbox = "allow-same-origin", this.settings.allowScriptedContent && (this.iframe.sandbox += " allow-scripts"), this.settings.allowPopups && (this.iframe.sandbox += " allow-popups"), this.iframe.setAttribute("enable-annotation", "true"), this.resizing = !0, this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this.element.setAttribute("ref", String(this.index)), this.added = !0, this.elementBounds =
|
|
4125
|
+
return this.iframe ? this.iframe : (this.element || (this.element = this.container()), this.iframe = document.createElement("iframe"), this.iframe.id = this.id, this.iframe.scrolling = "no", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("seamless", "seamless"), this.iframe.style.border = "none", this.iframe.sandbox = "allow-same-origin", this.settings.allowScriptedContent && (this.iframe.sandbox += " allow-scripts"), this.settings.allowPopups && (this.iframe.sandbox += " allow-popups"), this.iframe.setAttribute("enable-annotation", "true"), this.resizing = !0, this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this.element.setAttribute("ref", String(this.index)), this.added = !0, this.elementBounds = K(this.element), "srcdoc" in this.iframe ? this.supportsSrcdoc = !0 : this.supportsSrcdoc = !1, this.settings.method || (this.settings.method = this.supportsSrcdoc ? "srcdoc" : "write"), this.iframe);
|
|
4097
4126
|
}
|
|
4098
4127
|
render(t, e) {
|
|
4099
4128
|
return this.create(), this.size(), this.sectionRender || (this.sectionRender = this.section.render(t)), this.sectionRender.then((i) => this.load(i)).then(() => {
|
|
@@ -4118,17 +4147,17 @@ class Zt {
|
|
|
4118
4147
|
}
|
|
4119
4148
|
// Lock an axis to element dimensions, taking borders into account
|
|
4120
4149
|
lock(t, e, i) {
|
|
4121
|
-
const s =
|
|
4150
|
+
const s = J(this.element);
|
|
4122
4151
|
let n;
|
|
4123
|
-
this.iframe ? n =
|
|
4152
|
+
this.iframe ? n = J(this.iframe) : n = { width: 0, height: 0 }, t === "width" && x(e) && (this.lockedWidth = e - s.width - n.width), t === "height" && x(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && x(e) && x(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
|
|
4124
4153
|
}
|
|
4125
4154
|
// Resize a single axis based on content dimensions
|
|
4126
4155
|
expand(t) {
|
|
4127
4156
|
let e = this.lockedWidth, i = this.lockedHeight, s;
|
|
4128
|
-
!this.iframe || this._expanding || (this._expanding = !0, this.layout.name === "pre-paginated" ? (e = this.layout.columnWidth, i = this.layout.height) : this.settings.axis === "horizontal" ? (e = this.contents.textWidth(), e % this.layout.pageWidth > 0 && (e = Math.ceil(e / this.layout.pageWidth) * this.layout.pageWidth), this.settings.forceEvenPages && (s = e / this.layout.pageWidth, this.layout.divisor > 1 && this.layout.name === "reflowable" && s % 2 > 0 && (e += this.layout.pageWidth))) : this.settings.axis === "vertical" && (i = this.contents.textHeight(), this.settings.flow === "paginated" && i % this.layout.height > 0 && (i = Math.ceil(i / this.layout.height) * this.layout.height)), (this._needsReframe || e
|
|
4157
|
+
!this.iframe || this._expanding || (this._expanding = !0, this.layout.name === "pre-paginated" ? (e = this.layout.columnWidth, i = this.layout.height) : this.settings.axis === "horizontal" ? (e = this.contents.textWidth(), e % this.layout.pageWidth > 0 && (e = Math.ceil(e / this.layout.pageWidth) * this.layout.pageWidth), this.settings.forceEvenPages && (s = e / this.layout.pageWidth, this.layout.divisor > 1 && this.layout.name === "reflowable" && s % 2 > 0 && (e += this.layout.pageWidth))) : this.settings.axis === "vertical" && (i = this.contents.textHeight(), this.settings.flow === "paginated" && i % this.layout.height > 0 && (i = Math.ceil(i / this.layout.height) * this.layout.height)), (this._needsReframe || e !== this._width || i !== this._height) && this.reframe(e, i), this._expanding = !1);
|
|
4129
4158
|
}
|
|
4130
4159
|
reframe(t, e) {
|
|
4131
|
-
|
|
4160
|
+
x(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), x(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
|
|
4132
4161
|
const i = this.prevBounds ? t - this.prevBounds.width : t, s = this.prevBounds ? e - this.prevBounds.height : e, n = {
|
|
4133
4162
|
width: t,
|
|
4134
4163
|
height: e,
|
|
@@ -4139,16 +4168,16 @@ class Zt {
|
|
|
4139
4168
|
let r;
|
|
4140
4169
|
for (const o in this.marks)
|
|
4141
4170
|
this.marks.hasOwnProperty(o) && (r = this.marks[o], this.placeMark(r.element, r.range));
|
|
4142
|
-
}), this.onResize(this, n), this.emit(f.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds =
|
|
4171
|
+
}), this.onResize(this, n), this.emit(f.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = K(this.element);
|
|
4143
4172
|
}
|
|
4144
4173
|
load(t) {
|
|
4145
|
-
const e = new
|
|
4174
|
+
const e = new S(), i = e.promise;
|
|
4146
4175
|
if (!this.iframe)
|
|
4147
4176
|
return e.reject(new Error("No Iframe Available")), i;
|
|
4148
4177
|
if (this.iframe.onload = (s) => {
|
|
4149
4178
|
this.onLoad(s, e);
|
|
4150
4179
|
}, this.settings.method === "blobUrl")
|
|
4151
|
-
this.blobUrl =
|
|
4180
|
+
this.blobUrl = tt(t, "application/xhtml+xml"), this.iframe.src = this.blobUrl, this.element.appendChild(this.iframe);
|
|
4152
4181
|
else if (this.settings.method === "srcdoc")
|
|
4153
4182
|
this.iframe.srcdoc = t, this.element.appendChild(this.iframe);
|
|
4154
4183
|
else {
|
|
@@ -4159,7 +4188,7 @@ class Zt {
|
|
|
4159
4188
|
return i;
|
|
4160
4189
|
}
|
|
4161
4190
|
onLoad(t, e) {
|
|
4162
|
-
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new
|
|
4191
|
+
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new Nt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
|
|
4163
4192
|
let i = this.document.querySelector("link[rel='canonical']");
|
|
4164
4193
|
i ? i.setAttribute("href", this.section.canonical) : (i = this.document.createElement("link"), i.setAttribute("rel", "canonical"), i.setAttribute("href", this.section.canonical), this.document.querySelector("head").appendChild(i)), this.contents.on(f.CONTENTS.EXPAND, () => {
|
|
4165
4194
|
this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
|
|
@@ -4171,7 +4200,7 @@ class Zt {
|
|
|
4171
4200
|
this.layout = t, this.contents && (this.layout.format(this.contents), this.expand());
|
|
4172
4201
|
}
|
|
4173
4202
|
setAxis(t) {
|
|
4174
|
-
this.settings.axis = t, t
|
|
4203
|
+
this.settings.axis = t, t === "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
|
|
4175
4204
|
}
|
|
4176
4205
|
setWritingMode(t) {
|
|
4177
4206
|
this.writingMode = t;
|
|
@@ -4182,7 +4211,7 @@ class Zt {
|
|
|
4182
4211
|
this.contents && (this.contents.off(f.CONTENTS.EXPAND), this.contents.off(f.CONTENTS.RESIZE));
|
|
4183
4212
|
}
|
|
4184
4213
|
display(t) {
|
|
4185
|
-
const e = new
|
|
4214
|
+
const e = new S();
|
|
4186
4215
|
return this.displayed ? e.resolve(this) : this.render(t).then(() => {
|
|
4187
4216
|
this.emit(f.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
|
|
4188
4217
|
}, (i) => {
|
|
@@ -4223,7 +4252,7 @@ class Zt {
|
|
|
4223
4252
|
onResize(t, e) {
|
|
4224
4253
|
}
|
|
4225
4254
|
bounds(t) {
|
|
4226
|
-
return (t || !this.elementBounds) && (this.elementBounds =
|
|
4255
|
+
return (t || !this.elementBounds) && (this.elementBounds = K(this.element)), this.elementBounds;
|
|
4227
4256
|
}
|
|
4228
4257
|
highlight(t, e = {}, i, s = "epubjs-hl", n = {}) {
|
|
4229
4258
|
if (!this.contents)
|
|
@@ -4231,11 +4260,11 @@ class Zt {
|
|
|
4231
4260
|
const r = Object.assign({ fill: "yellow", "fill-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4232
4261
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4233
4262
|
};
|
|
4234
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4235
|
-
const
|
|
4263
|
+
e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
|
|
4264
|
+
const l = new Qt(o, s, e, r);
|
|
4236
4265
|
let c;
|
|
4237
4266
|
try {
|
|
4238
|
-
c = this.pane.addMark(
|
|
4267
|
+
c = this.pane.addMark(l);
|
|
4239
4268
|
} catch (d) {
|
|
4240
4269
|
console.error("Failed to add highlight for", t, d);
|
|
4241
4270
|
return;
|
|
@@ -4248,11 +4277,11 @@ class Zt {
|
|
|
4248
4277
|
const r = Object.assign({ stroke: "black", "stroke-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4249
4278
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4250
4279
|
};
|
|
4251
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4252
|
-
const
|
|
4280
|
+
e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
|
|
4281
|
+
const l = new De(o, s, e, r);
|
|
4253
4282
|
let c;
|
|
4254
4283
|
try {
|
|
4255
|
-
c = this.pane.addMark(
|
|
4284
|
+
c = this.pane.addMark(l);
|
|
4256
4285
|
} catch (d) {
|
|
4257
4286
|
console.error("Failed to add underline for", t, d);
|
|
4258
4287
|
return;
|
|
@@ -4267,13 +4296,13 @@ class Zt {
|
|
|
4267
4296
|
let s = this.contents.range(t);
|
|
4268
4297
|
if (!s)
|
|
4269
4298
|
return;
|
|
4270
|
-
const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (
|
|
4299
|
+
const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (l) => {
|
|
4271
4300
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4272
4301
|
};
|
|
4273
4302
|
s.collapsed && n.nodeType === 1 ? (s = new Range(), s.selectNodeContents(n)) : s.collapsed && (s = new Range(), s.selectNodeContents(r));
|
|
4274
4303
|
const h = this.document.createElement("a");
|
|
4275
|
-
return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((
|
|
4276
|
-
h.dataset[
|
|
4304
|
+
return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((l) => {
|
|
4305
|
+
h.dataset[l] = e[l];
|
|
4277
4306
|
}), i && (h.addEventListener("click", i), h.addEventListener("touchstart", i)), h.addEventListener("click", o), h.addEventListener("touchstart", o), this.placeMark(h, s), this.element.appendChild(h), this.marks[t] = { element: h, range: s, listeners: [o, i] }, r;
|
|
4278
4307
|
}
|
|
4279
4308
|
placeMark(t, e) {
|
|
@@ -4284,7 +4313,7 @@ class Zt {
|
|
|
4284
4313
|
} else {
|
|
4285
4314
|
const r = e.getClientRects();
|
|
4286
4315
|
let o;
|
|
4287
|
-
for (let h = 0; h
|
|
4316
|
+
for (let h = 0; h !== r.length; h++)
|
|
4288
4317
|
o = r[h], (!n || o.left < n) && (n = o.left, s = Math.ceil(n / this.layout.props.pageWidth) * this.layout.props.pageWidth - this.layout.gap / 2, i = o.top);
|
|
4289
4318
|
}
|
|
4290
4319
|
t.style.top = `${i}px`, t.style.left = `${s}px`;
|
|
@@ -4320,37 +4349,37 @@ class Zt {
|
|
|
4320
4349
|
this.ununderline(t);
|
|
4321
4350
|
for (const t in this.marks)
|
|
4322
4351
|
this.unmark(t);
|
|
4323
|
-
this.blobUrl &&
|
|
4352
|
+
this.blobUrl && Tt(this.blobUrl), this.displayed && (this.displayed = !1, this.removeListeners(), this.contents.destroy(), this.stopExpanding = !0, this.iframe && (this.iframe.onload = null), this.element.removeChild(this.iframe), this.pane && (this.pane.element.remove(), this.pane = void 0), this.iframe = void 0, this.contents = void 0, this.section.unload(), this._textWidth = void 0, this._textHeight = void 0, this._width = void 0, this._height = void 0), this.__listeners = {};
|
|
4324
4353
|
}
|
|
4325
4354
|
}
|
|
4326
|
-
P(
|
|
4327
|
-
function
|
|
4328
|
-
let
|
|
4329
|
-
const t =
|
|
4330
|
-
return document.body.appendChild(t), t.scrollLeft > 0 ?
|
|
4355
|
+
P(Jt.prototype);
|
|
4356
|
+
function Be() {
|
|
4357
|
+
let a = "reverse";
|
|
4358
|
+
const t = Me();
|
|
4359
|
+
return document.body.appendChild(t), t.scrollLeft > 0 ? a = "default" : typeof Element < "u" && typeof Element.prototype.scrollIntoView == "function" ? (t.children[0].children[1].scrollIntoView(), t.scrollLeft < 0 && (a = "negative")) : (t.scrollLeft = 1, t.scrollLeft === 0 && (a = "negative")), document.body.removeChild(t), a;
|
|
4331
4360
|
}
|
|
4332
|
-
function
|
|
4333
|
-
const
|
|
4334
|
-
|
|
4361
|
+
function Me() {
|
|
4362
|
+
const a = document.createElement("div");
|
|
4363
|
+
a.dir = "rtl", a.style.position = "fixed", a.style.width = "1px", a.style.height = "1px", a.style.top = "0px", a.style.left = "0px", a.style.overflow = "hidden";
|
|
4335
4364
|
const t = document.createElement("div");
|
|
4336
4365
|
t.style.width = "2px";
|
|
4337
4366
|
const e = document.createElement("span");
|
|
4338
4367
|
e.style.width = "1px", e.style.display = "inline-block";
|
|
4339
4368
|
const i = document.createElement("span");
|
|
4340
|
-
return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i),
|
|
4369
|
+
return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i), a.appendChild(t), a;
|
|
4341
4370
|
}
|
|
4342
|
-
function
|
|
4371
|
+
function We(a, t) {
|
|
4343
4372
|
let e = null, i = 0;
|
|
4344
4373
|
return function(...s) {
|
|
4345
4374
|
const n = Date.now(), r = t - (n - i);
|
|
4346
|
-
r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n,
|
|
4347
|
-
i = Date.now(), e = null,
|
|
4375
|
+
r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n, a.call(this, ...s)) : e || (e = setTimeout(() => {
|
|
4376
|
+
i = Date.now(), e = null, a.call(this, ...s);
|
|
4348
4377
|
}, r));
|
|
4349
4378
|
};
|
|
4350
4379
|
}
|
|
4351
|
-
class
|
|
4380
|
+
class qe {
|
|
4352
4381
|
constructor(t) {
|
|
4353
|
-
this.settings = t || {}, this.id = "epubjs-container-" +
|
|
4382
|
+
this.settings = t || {}, this.id = "epubjs-container-" + Et(), this.container = this.create(this.settings), this.settings.hidden && (this.wrapper = this.wrap(this.container));
|
|
4354
4383
|
}
|
|
4355
4384
|
/*
|
|
4356
4385
|
* Creates an element to render to.
|
|
@@ -4359,7 +4388,7 @@ class Me {
|
|
|
4359
4388
|
create(t) {
|
|
4360
4389
|
let e = t.height, i = t.width;
|
|
4361
4390
|
const s = t.overflow || !1, n = t.axis || "vertical", r = t.direction;
|
|
4362
|
-
C(this.settings, t), t.height &&
|
|
4391
|
+
C(this.settings, t), t.height && x(t.height) && (e = t.height + "px"), t.width && x(t.width) && (i = t.width + "px");
|
|
4363
4392
|
const o = document.createElement("div");
|
|
4364
4393
|
return o.id = this.id, o.classList.add("epub-container"), o.style.wordSpacing = "0", o.style.lineHeight = "0", o.style.verticalAlign = "top", o.style.position = "relative", o.style.overflowAnchor = "none", n === "horizontal" && (o.style.display = "flex", o.style.flexDirection = "row", o.style.flexWrap = "nowrap"), i && (o.style.width = i), e && (o.style.height = e), s && (s === "scroll" && n === "vertical" ? (o.style.overflowY = s, o.style.overflowX = "hidden") : s === "scroll" && n === "horizontal" ? (o.style.overflowY = "hidden", o.style.overflowX = s) : o.style.overflow = s), r && (o.dir = r, o.style.direction = r), r && this.settings.fullsize && (document.body.style.direction = r), o;
|
|
4365
4394
|
}
|
|
@@ -4369,7 +4398,7 @@ class Me {
|
|
|
4369
4398
|
}
|
|
4370
4399
|
getElement(t) {
|
|
4371
4400
|
let e = null;
|
|
4372
|
-
if (
|
|
4401
|
+
if (Mt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
|
|
4373
4402
|
throw new Error("Not an Element");
|
|
4374
4403
|
return e;
|
|
4375
4404
|
}
|
|
@@ -4383,7 +4412,7 @@ class Me {
|
|
|
4383
4412
|
return this.container;
|
|
4384
4413
|
}
|
|
4385
4414
|
onResize(t) {
|
|
4386
|
-
(!
|
|
4415
|
+
(!x(this.settings.width) || !x(this.settings.height)) && (this.resizeFunc = We(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
|
|
4387
4416
|
}
|
|
4388
4417
|
onOrientationChange(t) {
|
|
4389
4418
|
this.orientationChangeFunc = t, window.addEventListener("orientationchange", this.orientationChangeFunc, !1);
|
|
@@ -4391,13 +4420,13 @@ class Me {
|
|
|
4391
4420
|
size(t, e) {
|
|
4392
4421
|
let i;
|
|
4393
4422
|
const s = t || this.settings.width, n = e || this.settings.height;
|
|
4394
|
-
t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) :
|
|
4423
|
+
t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : x(t) ? this.container.style.width = t + "px" : t && (this.container.style.width = t), e === null ? (i = i || this.element.getBoundingClientRect(), i.height && (e = i.height, this.container.style.height = e + "px")) : x(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), x(t) || (t = this.container.clientWidth), x(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
|
|
4395
4424
|
left: parseFloat(this.containerStyles.paddingLeft) || 0,
|
|
4396
4425
|
right: parseFloat(this.containerStyles.paddingRight) || 0,
|
|
4397
4426
|
top: parseFloat(this.containerStyles.paddingTop) || 0,
|
|
4398
4427
|
bottom: parseFloat(this.containerStyles.paddingBottom) || 0
|
|
4399
4428
|
};
|
|
4400
|
-
const r =
|
|
4429
|
+
const r = pt(), o = window.getComputedStyle(document.body), h = {
|
|
4401
4430
|
left: parseFloat(o.paddingLeft) || 0,
|
|
4402
4431
|
right: parseFloat(o.paddingRight) || 0,
|
|
4403
4432
|
top: parseFloat(o.paddingTop) || 0,
|
|
@@ -4410,7 +4439,7 @@ class Me {
|
|
|
4410
4439
|
}
|
|
4411
4440
|
bounds() {
|
|
4412
4441
|
let t;
|
|
4413
|
-
return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ?
|
|
4442
|
+
return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ? pt() : t;
|
|
4414
4443
|
}
|
|
4415
4444
|
getSheet() {
|
|
4416
4445
|
const t = document.createElement("style");
|
|
@@ -4446,7 +4475,7 @@ class Me {
|
|
|
4446
4475
|
this.element && (this.settings.hidden ? this.wrapper : this.container, this.element.contains(this.container) && this.element.removeChild(this.container), window.removeEventListener("resize", this.resizeFunc), window.removeEventListener("orientationchange", this.orientationChangeFunc));
|
|
4447
4476
|
}
|
|
4448
4477
|
}
|
|
4449
|
-
class
|
|
4478
|
+
class Ue {
|
|
4450
4479
|
constructor(t) {
|
|
4451
4480
|
this.container = t, this._views = [], this.length = 0, this.hidden = !1;
|
|
4452
4481
|
}
|
|
@@ -4501,7 +4530,7 @@ class qe {
|
|
|
4501
4530
|
let e;
|
|
4502
4531
|
const i = this.length;
|
|
4503
4532
|
for (let s = 0; s < i; s++)
|
|
4504
|
-
if (e = this._views[s], e.displayed && e.section.index
|
|
4533
|
+
if (e = this._views[s], e.displayed && e.section.index === t.index)
|
|
4505
4534
|
return e;
|
|
4506
4535
|
}
|
|
4507
4536
|
displayed() {
|
|
@@ -4527,9 +4556,9 @@ class qe {
|
|
|
4527
4556
|
this.hidden = !0;
|
|
4528
4557
|
}
|
|
4529
4558
|
}
|
|
4530
|
-
class
|
|
4559
|
+
class st {
|
|
4531
4560
|
constructor(t) {
|
|
4532
|
-
this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new
|
|
4561
|
+
this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new kt(this), this.settings = C({}, {
|
|
4533
4562
|
infinite: !0,
|
|
4534
4563
|
hidden: !1,
|
|
4535
4564
|
width: void 0,
|
|
@@ -4557,7 +4586,7 @@ class rt {
|
|
|
4557
4586
|
}
|
|
4558
4587
|
render(t, e) {
|
|
4559
4588
|
const i = t.tagName;
|
|
4560
|
-
typeof this.settings.fullsize > "u" && i && (i.toLowerCase()
|
|
4589
|
+
typeof this.settings.fullsize > "u" && i && (i.toLowerCase() === "body" || i.toLowerCase() === "html") && (this.settings.fullsize = !0), this.settings.fullsize && (this.settings.overflow = "visible", this.overflow = this.settings.overflow), this.settings.size = e, this.settings.rtlScrollType = Be(), this.stage = new qe({
|
|
4561
4590
|
width: e.width,
|
|
4562
4591
|
height: e.height,
|
|
4563
4592
|
overflow: this.overflow,
|
|
@@ -4565,7 +4594,7 @@ class rt {
|
|
|
4565
4594
|
axis: this.settings.axis,
|
|
4566
4595
|
fullsize: this.settings.fullsize,
|
|
4567
4596
|
direction: this.settings.direction
|
|
4568
|
-
}), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new
|
|
4597
|
+
}), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new Ue(this.container), this._bounds = this.bounds(), this._stageSize = this.stage.size(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.stage.onResize(() => this.onResized()), this.stage.onOrientationChange((s) => this.onOrientationChange(s)), this.addEventListeners(), this.layout && this.updateLayout(), this.rendered = !0;
|
|
4569
4598
|
}
|
|
4570
4599
|
addEventListeners() {
|
|
4571
4600
|
let t;
|
|
@@ -4578,25 +4607,18 @@ class rt {
|
|
|
4578
4607
|
this.settings.fullsize ? t = window : t = this.container, t.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, window.removeEventListener("unload", this._onUnload), this._onUnload = void 0;
|
|
4579
4608
|
}
|
|
4580
4609
|
destroy() {
|
|
4581
|
-
clearTimeout(this.
|
|
4610
|
+
clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
|
|
4582
4611
|
}
|
|
4583
4612
|
onOrientationChange(t) {
|
|
4584
4613
|
var i;
|
|
4585
4614
|
const { orientation: e } = window;
|
|
4586
|
-
(i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(),
|
|
4587
|
-
var s;
|
|
4588
|
-
this.orientationTimeout = void 0, (s = this.optsSettings) != null && s.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4589
|
-
}, 500);
|
|
4615
|
+
(i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4590
4616
|
}
|
|
4591
4617
|
onResized(t) {
|
|
4592
4618
|
this.resize();
|
|
4593
4619
|
}
|
|
4594
4620
|
resize(t, e, i) {
|
|
4595
4621
|
const s = this.stage.size(t, e);
|
|
4596
|
-
if (this.winBounds = et(), this.orientationTimeout && this.winBounds.width === this.winBounds.height) {
|
|
4597
|
-
this._stageSize = void 0;
|
|
4598
|
-
return;
|
|
4599
|
-
}
|
|
4600
4622
|
this._stageSize && this._stageSize.width === s.width && this._stageSize.height === s.height || (this._stageSize = s, this._bounds = this.bounds(), this.clear(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.updateLayout(), this.emit(f.MANAGERS.RESIZED, {
|
|
4601
4623
|
width: this._stageSize.width,
|
|
4602
4624
|
height: this._stageSize.height
|
|
@@ -4616,8 +4638,8 @@ class rt {
|
|
|
4616
4638
|
}
|
|
4617
4639
|
}
|
|
4618
4640
|
display(t, e) {
|
|
4619
|
-
const i = new
|
|
4620
|
-
(e === t.href ||
|
|
4641
|
+
const i = new S(), s = i.promise;
|
|
4642
|
+
(e === t.href || x(e)) && (e = void 0);
|
|
4621
4643
|
const n = this.views.find(t);
|
|
4622
4644
|
if (n && t && this.layout.name !== "pre-paginated") {
|
|
4623
4645
|
const o = n.offset();
|
|
@@ -4628,8 +4650,8 @@ class rt {
|
|
|
4628
4650
|
this.scrollTo(o.left + h, o.top, !0);
|
|
4629
4651
|
}
|
|
4630
4652
|
if (e) {
|
|
4631
|
-
const h = n.locationOf(e),
|
|
4632
|
-
this.moveTo(h,
|
|
4653
|
+
const h = n.locationOf(e), l = n.width();
|
|
4654
|
+
this.moveTo(h, l);
|
|
4633
4655
|
}
|
|
4634
4656
|
return i.resolve(), s;
|
|
4635
4657
|
}
|
|
@@ -4637,8 +4659,8 @@ class rt {
|
|
|
4637
4659
|
let r = !1;
|
|
4638
4660
|
return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (r = !0), this.add(t, r).then((o) => {
|
|
4639
4661
|
if (e) {
|
|
4640
|
-
const h = o.locationOf(e),
|
|
4641
|
-
this.moveTo(h,
|
|
4662
|
+
const h = o.locationOf(e), l = o.width();
|
|
4663
|
+
this.moveTo(h, l);
|
|
4642
4664
|
}
|
|
4643
4665
|
}, (o) => {
|
|
4644
4666
|
i.reject(o);
|
|
@@ -4695,7 +4717,7 @@ class rt {
|
|
|
4695
4717
|
//
|
|
4696
4718
|
// };
|
|
4697
4719
|
next() {
|
|
4698
|
-
var s, n, r, o, h,
|
|
4720
|
+
var s, n, r, o, h, l, c, d, u, p;
|
|
4699
4721
|
let t, e;
|
|
4700
4722
|
const i = this.settings.direction;
|
|
4701
4723
|
if (this.views.length) {
|
|
@@ -4718,7 +4740,7 @@ class rt {
|
|
|
4718
4740
|
this.scrollBy(this.layout.delta, 0, !0);
|
|
4719
4741
|
else {
|
|
4720
4742
|
const g = this.views.last();
|
|
4721
|
-
g && g.expand(), e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1 ? this.scrollBy(this.layout.delta, 0, !0) : t = (
|
|
4743
|
+
g && g.expand(), e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1 ? this.scrollBy(this.layout.delta, 0, !0) : t = (l = g == null ? void 0 : (h = g.section).next) == null ? void 0 : l.call(h);
|
|
4722
4744
|
}
|
|
4723
4745
|
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4724
4746
|
if (this.scrollTop = this.container.scrollTop, !(Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1))
|
|
@@ -4739,7 +4761,7 @@ class rt {
|
|
|
4739
4761
|
}
|
|
4740
4762
|
}
|
|
4741
4763
|
prev() {
|
|
4742
|
-
var s, n, r, o, h,
|
|
4764
|
+
var s, n, r, o, h, l, c, d, u, p, g;
|
|
4743
4765
|
let t, e;
|
|
4744
4766
|
const i = this.settings.direction;
|
|
4745
4767
|
if (this.views.length) {
|
|
@@ -4762,7 +4784,7 @@ class rt {
|
|
|
4762
4784
|
this.scrollBy(-this.layout.delta, 0, !0);
|
|
4763
4785
|
else {
|
|
4764
4786
|
const m = this.views.first();
|
|
4765
|
-
m && m.expand(), e = this.container.scrollLeft, e < 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (
|
|
4787
|
+
m && m.expand(), e = this.container.scrollLeft, e < 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (l = m == null ? void 0 : (h = m.section).prev) == null ? void 0 : l.call(h);
|
|
4766
4788
|
}
|
|
4767
4789
|
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4768
4790
|
if (this.scrollTop = this.container.scrollTop, this.container.scrollTop > 0)
|
|
@@ -4779,9 +4801,9 @@ class rt {
|
|
|
4779
4801
|
return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof ((g = t.prev) == null ? void 0 : g.call(t)) != "object" && (m = !0), this.prepend(t, m).then(() => {
|
|
4780
4802
|
var v;
|
|
4781
4803
|
if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
|
|
4782
|
-
const
|
|
4783
|
-
if (
|
|
4784
|
-
return this.prepend(
|
|
4804
|
+
const b = (v = t.prev) == null ? void 0 : v.call(t);
|
|
4805
|
+
if (b)
|
|
4806
|
+
return this.prepend(b);
|
|
4785
4807
|
}
|
|
4786
4808
|
}, (v) => v).then(() => {
|
|
4787
4809
|
this.isPaginated && this.settings.axis === "horizontal" && (this.settings.direction === "rtl" ? this.settings.rtlScrollType === "default" ? this.scrollTo(0, 0, !0) : this.scrollTo(this.container.scrollWidth * -1 + this.layout.delta, 0, !0) : this.scrollTo(this.container.scrollWidth - this.layout.delta, 0, !0)), this.views.show();
|
|
@@ -4804,21 +4826,21 @@ class rt {
|
|
|
4804
4826
|
this.settings.direction;
|
|
4805
4827
|
let r = 0;
|
|
4806
4828
|
const o = 0;
|
|
4807
|
-
return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((
|
|
4808
|
-
const c =
|
|
4809
|
-
let m, v,
|
|
4810
|
-
n ? (m = r + e.top - u.top + o, v = m + i - o, k = this.layout.count(g, i).pages,
|
|
4811
|
-
let
|
|
4829
|
+
return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((l) => {
|
|
4830
|
+
const c = l.section.index, d = l.section.href, u = l.position(), p = l.width(), g = l.height();
|
|
4831
|
+
let m, v, b, k;
|
|
4832
|
+
n ? (m = r + e.top - u.top + o, v = m + i - o, k = this.layout.count(g, i).pages, b = i) : (m = r + e.left - u.left + o, v = m + s - o, k = this.layout.count(p, s).pages, b = s);
|
|
4833
|
+
let E = Math.ceil(m / b), _ = [], T = Math.ceil(v / b);
|
|
4812
4834
|
if (this.settings.direction === "rtl" && !n) {
|
|
4813
|
-
const
|
|
4814
|
-
|
|
4835
|
+
const M = E;
|
|
4836
|
+
E = k - T, T = k - M;
|
|
4815
4837
|
}
|
|
4816
4838
|
_ = [];
|
|
4817
|
-
for (let
|
|
4818
|
-
const
|
|
4819
|
-
_.push(
|
|
4839
|
+
for (let M = E; M <= T; M++) {
|
|
4840
|
+
const z = M + 1;
|
|
4841
|
+
_.push(z);
|
|
4820
4842
|
}
|
|
4821
|
-
const I = this.mapping.page(
|
|
4843
|
+
const I = this.mapping.page(l.contents, l.section.cfiBase, m, v);
|
|
4822
4844
|
return {
|
|
4823
4845
|
index: c,
|
|
4824
4846
|
href: d,
|
|
@@ -4833,19 +4855,19 @@ class rt {
|
|
|
4833
4855
|
let i = 0, s = 0;
|
|
4834
4856
|
return this.settings.fullsize && (i = window.scrollX), t.map((r) => {
|
|
4835
4857
|
const o = r.section.index, h = r.section.href;
|
|
4836
|
-
let
|
|
4858
|
+
let l;
|
|
4837
4859
|
const c = r.position(), d = r.width();
|
|
4838
4860
|
let u, p, g;
|
|
4839
|
-
this.settings.direction === "rtl" ? (
|
|
4861
|
+
this.settings.direction === "rtl" ? (l = e.right - i, g = Math.min(Math.abs(l - c.left), this.layout.width) - s, p = c.width - (c.right - l) - s, u = p - g) : (l = e.left + i, g = Math.min(c.right - l, this.layout.width) - s, u = l - c.left + s, p = u + g), s += g;
|
|
4840
4862
|
const m = this.mapping.page(r.contents, r.section.cfiBase, u, p), v = this.layout.count(d).pages;
|
|
4841
|
-
let
|
|
4863
|
+
let b = Math.floor(u / this.layout.pageWidth);
|
|
4842
4864
|
const k = [];
|
|
4843
|
-
let
|
|
4844
|
-
if (
|
|
4845
|
-
const _ =
|
|
4846
|
-
|
|
4865
|
+
let E = Math.floor(p / this.layout.pageWidth);
|
|
4866
|
+
if (b < 0 && (b = 0, E = E + 1), this.settings.direction === "rtl") {
|
|
4867
|
+
const _ = b;
|
|
4868
|
+
b = v - E, E = v - _;
|
|
4847
4869
|
}
|
|
4848
|
-
for (let _ =
|
|
4870
|
+
for (let _ = b + 1; _ <= E; _++) {
|
|
4849
4871
|
const T = _;
|
|
4850
4872
|
k.push(T);
|
|
4851
4873
|
}
|
|
@@ -4902,7 +4924,7 @@ class rt {
|
|
|
4902
4924
|
), this.settings.offset = this.layout.delta / this.layout.divisor) : this.layout.calculate(this._stageSize.width, this._stageSize.height), this.viewSettings.width = this.layout.width, this.viewSettings.height = this.layout.height, this.setLayout(this.layout));
|
|
4903
4925
|
}
|
|
4904
4926
|
setLayout(t) {
|
|
4905
|
-
this.viewSettings.layout = t, this.mapping = new
|
|
4927
|
+
this.viewSettings.layout = t, this.mapping = new wt(t.props, this.settings.direction, this.settings.axis), this.views && this.views.forEach((e) => {
|
|
4906
4928
|
e && e.setLayout(t);
|
|
4907
4929
|
});
|
|
4908
4930
|
}
|
|
@@ -4910,7 +4932,7 @@ class rt {
|
|
|
4910
4932
|
this.writingMode = t;
|
|
4911
4933
|
}
|
|
4912
4934
|
updateAxis(t, e) {
|
|
4913
|
-
!e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new
|
|
4935
|
+
!e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new wt(this.layout.props, this.settings.direction, this.settings.axis)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
|
|
4914
4936
|
}
|
|
4915
4937
|
updateFlow(t, e = "auto") {
|
|
4916
4938
|
const i = t === "paginated" || t === "auto";
|
|
@@ -4930,23 +4952,23 @@ class rt {
|
|
|
4930
4952
|
return this.rendered;
|
|
4931
4953
|
}
|
|
4932
4954
|
}
|
|
4933
|
-
P(
|
|
4934
|
-
const
|
|
4935
|
-
easeInCubic: function(
|
|
4936
|
-
return Math.pow(
|
|
4955
|
+
P(st.prototype);
|
|
4956
|
+
const je = {
|
|
4957
|
+
easeInCubic: function(a) {
|
|
4958
|
+
return Math.pow(a, 3);
|
|
4937
4959
|
}
|
|
4938
4960
|
};
|
|
4939
|
-
class
|
|
4961
|
+
class bt {
|
|
4940
4962
|
constructor(t, e) {
|
|
4941
4963
|
this.settings = C({
|
|
4942
4964
|
duration: 80,
|
|
4943
4965
|
minVelocity: 0.2,
|
|
4944
4966
|
minDistance: 10,
|
|
4945
|
-
easing:
|
|
4967
|
+
easing: je.easeInCubic
|
|
4946
4968
|
}, e || {}), this._supportsTouch = this.supportsTouch(), this._supportsTouch && this.setup(t);
|
|
4947
4969
|
}
|
|
4948
4970
|
setup(t) {
|
|
4949
|
-
this.manager = t, this.layout = this.manager.layout, this.fullsize = this.manager.settings.fullsize ?? !1, this.fullsize ? (this.element = this.manager.stage.element, this.scroller = window, this.disableScroll()) : (this.element = this.manager.stage.container, this.scroller = this.element
|
|
4971
|
+
this.manager = t, this.layout = this.manager.layout, this.fullsize = this.manager.settings.fullsize ?? !1, this.fullsize ? (this.element = this.manager.stage.element, this.scroller = window, this.disableScroll()) : (this.element = this.manager.stage.container, this.scroller = this.element), this.manager.settings.offset = this.layout.width, this.manager.settings.afterScrolledTimeout = this.settings.duration * 2, this.isVertical = this.manager.settings.axis === "vertical", !(!this.manager.isPaginated || this.isVertical) && (this.touchCanceler = !1, this.resizeCanceler = !1, this.snapping = !1, this.scrollLeft, this.scrollTop, this.startTouchX = void 0, this.startTouchY = void 0, this.startTime = void 0, this.endTouchX = void 0, this.endTouchY = void 0, this.endTime = void 0, this.addListeners());
|
|
4950
4972
|
}
|
|
4951
4973
|
supportsTouch() {
|
|
4952
4974
|
return "ontouchstart" in window || "DocumentTouch" in window;
|
|
@@ -5007,38 +5029,39 @@ class xt {
|
|
|
5007
5029
|
return t && (s += t * i), this.smoothScrollTo(s);
|
|
5008
5030
|
}
|
|
5009
5031
|
smoothScrollTo(t) {
|
|
5010
|
-
const e =
|
|
5011
|
-
this.snapping = !0
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5032
|
+
const e = this.scrollLeft, i = this.now(), s = this.settings.duration, n = this.settings.easing;
|
|
5033
|
+
return this.snapping = !0, new Promise((r) => {
|
|
5034
|
+
const o = () => {
|
|
5035
|
+
const h = this.now(), l = Math.min(1, (h - i) / s), c = n(l);
|
|
5036
|
+
if (this.touchCanceler || this.resizeCanceler) {
|
|
5037
|
+
this.resizeCanceler = !1, this.snapping = !1, r();
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5040
|
+
l < 1 ? (window.requestAnimationFrame(o), this.scrollTo(e + (t - e) * c, 0)) : (this.scrollTo(t, 0), this.snapping = !1, r());
|
|
5041
|
+
};
|
|
5042
|
+
o();
|
|
5043
|
+
});
|
|
5021
5044
|
}
|
|
5022
5045
|
scrollTo(t = 0, e = 0) {
|
|
5023
5046
|
this.fullsize ? window.scroll(t, e) : (this.scroller.scrollLeft = t, this.scroller.scrollTop = e);
|
|
5024
5047
|
}
|
|
5025
5048
|
now() {
|
|
5026
|
-
return
|
|
5049
|
+
return performance.now();
|
|
5027
5050
|
}
|
|
5028
5051
|
destroy() {
|
|
5029
5052
|
this.scroller && (this.fullsize && this.enableScroll(), this.removeListeners(), this.scroller = void 0);
|
|
5030
5053
|
}
|
|
5031
5054
|
}
|
|
5032
|
-
P(
|
|
5033
|
-
function
|
|
5055
|
+
P(bt.prototype);
|
|
5056
|
+
function Fe(a, t) {
|
|
5034
5057
|
let e;
|
|
5035
5058
|
return function(...i) {
|
|
5036
5059
|
clearTimeout(e), e = setTimeout(() => {
|
|
5037
|
-
|
|
5060
|
+
a.call(this, ...i);
|
|
5038
5061
|
}, t);
|
|
5039
5062
|
};
|
|
5040
5063
|
}
|
|
5041
|
-
class
|
|
5064
|
+
class Ve extends st {
|
|
5042
5065
|
constructor(t) {
|
|
5043
5066
|
var i;
|
|
5044
5067
|
super(t), this.name = "continuous", this.settings = C({}, {
|
|
@@ -5070,13 +5093,12 @@ class je extends rt {
|
|
|
5070
5093
|
}, this.scrollTop = 0, this.scrollLeft = 0;
|
|
5071
5094
|
}
|
|
5072
5095
|
display(t, e) {
|
|
5073
|
-
return
|
|
5096
|
+
return st.prototype.display.call(this, t, e).then(() => this.fill());
|
|
5074
5097
|
}
|
|
5075
|
-
fill(
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
}), e.promise;
|
|
5098
|
+
async fill() {
|
|
5099
|
+
let t = !0;
|
|
5100
|
+
for (; t; )
|
|
5101
|
+
t = await this.q.enqueue(() => this.check());
|
|
5080
5102
|
}
|
|
5081
5103
|
moveTo(t) {
|
|
5082
5104
|
let e = 0, i = 0;
|
|
@@ -5128,7 +5150,7 @@ class je extends rt {
|
|
|
5128
5150
|
update(t) {
|
|
5129
5151
|
const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
|
|
5130
5152
|
let r, o;
|
|
5131
|
-
const h = new
|
|
5153
|
+
const h = new S(), l = [];
|
|
5132
5154
|
for (let c = 0; c < s; c++)
|
|
5133
5155
|
if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
|
|
5134
5156
|
if (o.displayed)
|
|
@@ -5139,48 +5161,48 @@ class je extends rt {
|
|
|
5139
5161
|
}, (u) => {
|
|
5140
5162
|
o.hide();
|
|
5141
5163
|
});
|
|
5142
|
-
|
|
5164
|
+
l.push(d);
|
|
5143
5165
|
}
|
|
5144
5166
|
else
|
|
5145
5167
|
this.q.enqueue(() => o.destroy()), clearTimeout(this.trimTimeout), this.trimTimeout = setTimeout(() => {
|
|
5146
5168
|
this.q.enqueue(() => this.trim());
|
|
5147
5169
|
}, 250);
|
|
5148
|
-
return
|
|
5170
|
+
return l.length ? Promise.all(l).catch((c) => {
|
|
5149
5171
|
h.reject(c);
|
|
5150
5172
|
}) : (h.resolve(), h.promise);
|
|
5151
5173
|
}
|
|
5152
5174
|
check(t, e) {
|
|
5153
|
-
const i = new
|
|
5175
|
+
const i = new S(), s = [], n = this.settings.axis === "horizontal";
|
|
5154
5176
|
let r = this.settings.offset || 0;
|
|
5155
5177
|
t && n && (r = t), e && !n && (r = e);
|
|
5156
5178
|
const o = this._bounds;
|
|
5157
5179
|
let h = n ? this.scrollLeft : this.scrollTop;
|
|
5158
|
-
const
|
|
5159
|
-
this.settings.fullsize ? (n && p && u === "negative" || !n && p && u === "default") && (h = h * -1) : (p && u === "default" && d === "horizontal" && (h = c -
|
|
5180
|
+
const l = n ? Math.floor(o.width) : o.height, c = n ? this.container.scrollWidth : this.container.scrollHeight, d = this.writingMode && this.writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal", u = this.settings.rtlScrollType, p = this.settings.direction === "rtl";
|
|
5181
|
+
this.settings.fullsize ? (n && p && u === "negative" || !n && p && u === "default") && (h = h * -1) : (p && u === "default" && d === "horizontal" && (h = c - l - h), p && u === "negative" && d === "horizontal" && (h = h * -1));
|
|
5160
5182
|
const g = () => {
|
|
5161
5183
|
var T, I;
|
|
5162
|
-
const
|
|
5184
|
+
const E = this.views.first(), _ = E && ((I = (T = E.section).prev) == null ? void 0 : I.call(T));
|
|
5163
5185
|
_ && s.push(this.prepend(_));
|
|
5164
5186
|
}, m = () => {
|
|
5165
5187
|
var T, I;
|
|
5166
|
-
const
|
|
5188
|
+
const E = this.views.last(), _ = E && ((I = (T = E.section).next) == null ? void 0 : I.call(T));
|
|
5167
5189
|
_ && s.push(this.append(_));
|
|
5168
|
-
}, v = h +
|
|
5169
|
-
v >= c && m(),
|
|
5170
|
-
const k = s.map((
|
|
5171
|
-
return s.length ? Promise.all(k).then(() => this.check()).then(() => this.update(r), (
|
|
5190
|
+
}, v = h + l + r, b = h - r;
|
|
5191
|
+
v >= c && m(), b < 0 && g();
|
|
5192
|
+
const k = s.map((E) => E.display(this.request));
|
|
5193
|
+
return s.length ? Promise.all(k).then(() => this.check()).then(() => this.update(r), (E) => E) : (this.q.enqueue(() => {
|
|
5172
5194
|
this.update();
|
|
5173
5195
|
}), i.resolve(!1), i.promise);
|
|
5174
5196
|
}
|
|
5175
5197
|
trim() {
|
|
5176
|
-
const t = new
|
|
5198
|
+
const t = new S(), e = this.views.displayed();
|
|
5177
5199
|
if (!e.length)
|
|
5178
5200
|
return t.resolve(), t.promise;
|
|
5179
5201
|
const i = e[0], s = e[e.length - 1], n = this.views.indexOf(i), r = this.views.indexOf(s), o = this.views.slice(0, n), h = this.views.slice(r + 1);
|
|
5180
|
-
for (let
|
|
5181
|
-
this.erase(o[
|
|
5182
|
-
for (let
|
|
5183
|
-
this.erase(h[
|
|
5202
|
+
for (let l = 0; l < o.length - 1; l++)
|
|
5203
|
+
this.erase(o[l], o);
|
|
5204
|
+
for (let l = 1; l < h.length; l++)
|
|
5205
|
+
this.erase(h[l]);
|
|
5184
5206
|
return t.resolve(), t.promise;
|
|
5185
5207
|
}
|
|
5186
5208
|
erase(t, e) {
|
|
@@ -5192,13 +5214,12 @@ class je extends rt {
|
|
|
5192
5214
|
addEventListeners(t) {
|
|
5193
5215
|
this._onUnload = (e) => {
|
|
5194
5216
|
this.ignore = !0, this.destroy();
|
|
5195
|
-
}, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new
|
|
5217
|
+
}, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new bt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
|
|
5196
5218
|
}
|
|
5197
5219
|
addScrollListeners() {
|
|
5198
5220
|
let t;
|
|
5199
|
-
this.tick = Et;
|
|
5200
5221
|
const e = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
|
|
5201
|
-
this.scrollDeltaVert = 0, this.scrollDeltaHorz = 0, this.settings.fullsize ? (t = window, this.scrollTop = window.scrollY * e, this.scrollLeft = window.scrollX * e) : (t = this.container, this.scrollTop = this.container.scrollTop, this.scrollLeft = this.container.scrollLeft), this._onScroll = this.onScroll.bind(this), t.addEventListener("scroll", this._onScroll), this._scrolled =
|
|
5222
|
+
this.scrollDeltaVert = 0, this.scrollDeltaHorz = 0, this.settings.fullsize ? (t = window, this.scrollTop = window.scrollY * e, this.scrollLeft = window.scrollX * e) : (t = this.container, this.scrollTop = this.container.scrollTop, this.scrollLeft = this.container.scrollLeft), this._onScroll = this.onScroll.bind(this), t.addEventListener("scroll", this._onScroll), this._scrolled = Fe(() => this.scrolled(), 30), this.didScroll = !1;
|
|
5202
5223
|
}
|
|
5203
5224
|
removeEventListeners() {
|
|
5204
5225
|
let t;
|
|
@@ -5231,13 +5252,13 @@ class je extends rt {
|
|
|
5231
5252
|
this.views.length && (this.isPaginated && this.settings.axis === "horizontal" ? this.scrollBy(-t, 0, !0) : this.scrollBy(0, -this.layout.height, !0), this.q.enqueue(() => this.check()));
|
|
5232
5253
|
}
|
|
5233
5254
|
updateFlow(t) {
|
|
5234
|
-
this.rendered && this.snapper && (this.snapper.destroy(), this.snapper = void 0), super.updateFlow(t, "scroll"), this.rendered && this.isPaginated && this.settings.snap && (this.snapper = new
|
|
5255
|
+
this.rendered && this.snapper && (this.snapper.destroy(), this.snapper = void 0), super.updateFlow(t, "scroll"), this.rendered && this.isPaginated && this.settings.snap && (this.snapper = new bt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
|
|
5235
5256
|
}
|
|
5236
5257
|
destroy() {
|
|
5237
5258
|
clearTimeout(this.scrollTimeout), clearTimeout(this.trimTimeout), super.destroy(), this.snapper && this.snapper.destroy();
|
|
5238
5259
|
}
|
|
5239
5260
|
}
|
|
5240
|
-
class
|
|
5261
|
+
class Lt {
|
|
5241
5262
|
constructor(t, e) {
|
|
5242
5263
|
this.settings = C({}, {
|
|
5243
5264
|
width: null,
|
|
@@ -5256,7 +5277,7 @@ class kt {
|
|
|
5256
5277
|
defaultDirection: "ltr",
|
|
5257
5278
|
allowScriptedContent: !1,
|
|
5258
5279
|
allowPopups: !1
|
|
5259
|
-
}), C(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new A(this), this.hooks.serialize = new A(this), this.hooks.content = new A(this), this.hooks.unloaded = new A(this), this.hooks.layout = new A(this), this.hooks.render = new A(this), this.hooks.show = new A(this), this.hooks.content.register((i) => this.handleLinks(i)), this.hooks.content.register((i) => this.passEvents(i)), this.hooks.content.register((i) => this.adjustImages(i)), this.book.spine.hooks.content.register((i, s) => this.injectIdentifier(i, s)), this.settings.stylesheet && this.book.spine.hooks.content.register((i, s) => this.injectStylesheet(i, s)), this.settings.script && this.book.spine.hooks.content.register((i, s) => this.injectScript(i, s)), this.themes = new
|
|
5280
|
+
}), C(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new A(this), this.hooks.serialize = new A(this), this.hooks.content = new A(this), this.hooks.unloaded = new A(this), this.hooks.layout = new A(this), this.hooks.render = new A(this), this.hooks.show = new A(this), this.hooks.content.register((i) => this.handleLinks(i)), this.hooks.content.register((i) => this.passEvents(i)), this.hooks.content.register((i) => this.adjustImages(i)), this.book.spine.hooks.content.register((i, s) => this.injectIdentifier(i, s)), this.settings.stylesheet && this.book.spine.hooks.content.register((i, s) => this.injectStylesheet(i, s)), this.settings.script && this.book.spine.hooks.content.register((i, s) => this.injectScript(i, s)), this.themes = new Ce(this), this.annotations = new Te(this), this.epubcfi = new y(), this.q = new kt(this), this.location = void 0, this.q.enqueue(this.book.opened), this.starting = new S(), this.started = this.starting.promise, this.q.enqueue(this.start);
|
|
5260
5281
|
}
|
|
5261
5282
|
/**
|
|
5262
5283
|
* Set the manager function
|
|
@@ -5272,7 +5293,7 @@ class kt {
|
|
|
5272
5293
|
*/
|
|
5273
5294
|
requireManager(t) {
|
|
5274
5295
|
let e;
|
|
5275
|
-
return typeof t == "string" && t === "default" ? e =
|
|
5296
|
+
return typeof t == "string" && t === "default" ? e = st : typeof t == "string" && t === "continuous" ? e = Ve : e = t, e;
|
|
5276
5297
|
}
|
|
5277
5298
|
/**
|
|
5278
5299
|
* Require the view from passed string, or as a class function
|
|
@@ -5281,7 +5302,7 @@ class kt {
|
|
|
5281
5302
|
*/
|
|
5282
5303
|
requireView(t) {
|
|
5283
5304
|
let e;
|
|
5284
|
-
return typeof t == "string" && t === "iframe" ? e =
|
|
5305
|
+
return typeof t == "string" && t === "iframe" ? e = Jt : e = t, e;
|
|
5285
5306
|
}
|
|
5286
5307
|
/**
|
|
5287
5308
|
* Start the rendering
|
|
@@ -5338,8 +5359,8 @@ class kt {
|
|
|
5338
5359
|
if (!this.book)
|
|
5339
5360
|
return;
|
|
5340
5361
|
this.epubcfi.isCfiString(t);
|
|
5341
|
-
const e = new
|
|
5342
|
-
this.displaying = e, this.book.locations.length() &&
|
|
5362
|
+
const e = new S(), i = e.promise;
|
|
5363
|
+
this.displaying = e, this.book.locations.length() && Wt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
|
|
5343
5364
|
const s = this.book.spine.get(t);
|
|
5344
5365
|
return s ? (this.manager.display(s, t).then(() => {
|
|
5345
5366
|
e.resolve(s), this.displaying = void 0, this.emit(f.RENDITION.DISPLAYED, s), this.reportLocation();
|
|
@@ -5502,7 +5523,7 @@ class kt {
|
|
|
5502
5523
|
* @param {object} settings
|
|
5503
5524
|
*/
|
|
5504
5525
|
layout(t) {
|
|
5505
|
-
return t && (this._layout = new
|
|
5526
|
+
return t && (this._layout = new Kt(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(f.LAYOUT.UPDATED, (e, i) => {
|
|
5506
5527
|
this.emit(f.RENDITION.LAYOUT, e, i);
|
|
5507
5528
|
})), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
|
|
5508
5529
|
}
|
|
@@ -5597,7 +5618,7 @@ class kt {
|
|
|
5597
5618
|
}, n = this.book.locations.locationFromCfi(e.mapping.start), r = this.book.locations.locationFromCfi(i.mapping.end);
|
|
5598
5619
|
n != null && (s.start.location = n, s.start.percentage = this.book.locations.percentageFromLocation(n)), r != null && (s.end.location = r, s.end.percentage = this.book.locations.percentageFromLocation(r));
|
|
5599
5620
|
const o = this.book.pageList.pageFromCfi(e.mapping.start), h = this.book.pageList.pageFromCfi(i.mapping.end);
|
|
5600
|
-
return o
|
|
5621
|
+
return o !== -1 && (s.start.page = o), h !== -1 && (s.end.page = h), i.index === this.book.spine.last().index && s.end.displayed.page >= s.end.displayed.total && (s.atEnd = !0), e.index === this.book.spine.first().index && s.start.displayed.page === 1 && (s.atStart = !0), s;
|
|
5601
5622
|
}
|
|
5602
5623
|
/**
|
|
5603
5624
|
* Remove and Clean Up the Rendition
|
|
@@ -5611,7 +5632,7 @@ class kt {
|
|
|
5611
5632
|
* @param {Contents} view contents
|
|
5612
5633
|
*/
|
|
5613
5634
|
passEvents(t) {
|
|
5614
|
-
|
|
5635
|
+
Z.forEach((e) => {
|
|
5615
5636
|
t.on(e, (i) => this.triggerViewEvent(i, t));
|
|
5616
5637
|
}), t.on(f.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, t));
|
|
5617
5638
|
}
|
|
@@ -5678,10 +5699,8 @@ class kt {
|
|
|
5678
5699
|
"page-break-inside": "avoid",
|
|
5679
5700
|
"break-inside": "avoid"
|
|
5680
5701
|
}
|
|
5681
|
-
}), new Promise(function(n
|
|
5682
|
-
setTimeout(
|
|
5683
|
-
n();
|
|
5684
|
-
}, 1);
|
|
5702
|
+
}), new Promise(function(n) {
|
|
5703
|
+
setTimeout(n, 0);
|
|
5685
5704
|
});
|
|
5686
5705
|
}
|
|
5687
5706
|
/**
|
|
@@ -5743,8 +5762,9 @@ class kt {
|
|
|
5743
5762
|
s.setAttribute("name", "dc.relation.ispartof"), i && s.setAttribute("content", i), t.getElementsByTagName("head")[0].appendChild(s);
|
|
5744
5763
|
}
|
|
5745
5764
|
}
|
|
5746
|
-
P(
|
|
5747
|
-
|
|
5765
|
+
P(Lt.prototype);
|
|
5766
|
+
const ct = typeof window < "u" ? window.URL : URL;
|
|
5767
|
+
class He {
|
|
5748
5768
|
constructor() {
|
|
5749
5769
|
this.zip = void 0, this.urlCache = {}, this.checkRequirements();
|
|
5750
5770
|
}
|
|
@@ -5755,7 +5775,7 @@ class Fe {
|
|
|
5755
5775
|
*/
|
|
5756
5776
|
checkRequirements() {
|
|
5757
5777
|
try {
|
|
5758
|
-
this.zip = new
|
|
5778
|
+
this.zip = new ee();
|
|
5759
5779
|
} catch {
|
|
5760
5780
|
throw new Error("JSZip lib not loaded");
|
|
5761
5781
|
}
|
|
@@ -5776,7 +5796,7 @@ class Fe {
|
|
|
5776
5796
|
* @return {Promise} zipfile
|
|
5777
5797
|
*/
|
|
5778
5798
|
openUrl(t, e) {
|
|
5779
|
-
return
|
|
5799
|
+
return Y(t, "binary").then((i) => this.zip.loadAsync(i, { base64: e }));
|
|
5780
5800
|
}
|
|
5781
5801
|
/**
|
|
5782
5802
|
* Request a url from the archive
|
|
@@ -5784,17 +5804,14 @@ class Fe {
|
|
|
5784
5804
|
* @param {string} [type] specify the type of the returned result
|
|
5785
5805
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
5786
5806
|
*/
|
|
5787
|
-
request(t, e) {
|
|
5788
|
-
const i = new
|
|
5789
|
-
|
|
5790
|
-
const
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
message: "File not found in the epub: " + t,
|
|
5796
|
-
stack: new Error().stack
|
|
5797
|
-
}), i.promise;
|
|
5807
|
+
async request(t, e) {
|
|
5808
|
+
const i = new O(t);
|
|
5809
|
+
e || (e = i.extension);
|
|
5810
|
+
const s = e === "blob" ? this.getBlob(t) : this.getText(t);
|
|
5811
|
+
if (!s)
|
|
5812
|
+
throw new q("File not found in the epub: " + t);
|
|
5813
|
+
const n = await s;
|
|
5814
|
+
return this.handleResponse(n, e);
|
|
5798
5815
|
}
|
|
5799
5816
|
/**
|
|
5800
5817
|
* Handle the response from request
|
|
@@ -5804,8 +5821,7 @@ class Fe {
|
|
|
5804
5821
|
* @return {any} the parsed result
|
|
5805
5822
|
*/
|
|
5806
5823
|
handleResponse(t, e) {
|
|
5807
|
-
|
|
5808
|
-
return e == "json" ? i = JSON.parse(t) : Y(e) ? i = O(t, "text/xml") : e == "xhtml" ? i = O(t, "application/xhtml+xml") : e == "html" || e == "htm" ? i = O(t, "text/html") : i = t, i;
|
|
5824
|
+
return Ct(t, e);
|
|
5809
5825
|
}
|
|
5810
5826
|
/**
|
|
5811
5827
|
* Get a Blob from Archive by Url
|
|
@@ -5816,7 +5832,7 @@ class Fe {
|
|
|
5816
5832
|
getBlob(t, e) {
|
|
5817
5833
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5818
5834
|
if (s)
|
|
5819
|
-
return e = e ||
|
|
5835
|
+
return e = e || G.lookup(s.name), s.async("uint8array").then(function(n) {
|
|
5820
5836
|
return new Blob([n], { type: e });
|
|
5821
5837
|
});
|
|
5822
5838
|
}
|
|
@@ -5842,7 +5858,7 @@ class Fe {
|
|
|
5842
5858
|
getBase64(t, e) {
|
|
5843
5859
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5844
5860
|
if (s)
|
|
5845
|
-
return e = e ||
|
|
5861
|
+
return e = e || G.lookup(s.name), s.async("base64").then(function(n) {
|
|
5846
5862
|
return "data:" + e + ";base64," + n;
|
|
5847
5863
|
});
|
|
5848
5864
|
}
|
|
@@ -5852,46 +5868,50 @@ class Fe {
|
|
|
5852
5868
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
5853
5869
|
* @return {Promise} url promise with Url string
|
|
5854
5870
|
*/
|
|
5855
|
-
createUrl(t, e) {
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5871
|
+
async createUrl(t, e) {
|
|
5872
|
+
if (t in this.urlCache)
|
|
5873
|
+
return this.urlCache[t];
|
|
5874
|
+
if (e && e.base64) {
|
|
5875
|
+
const s = this.getBase64(t);
|
|
5876
|
+
if (s) {
|
|
5877
|
+
const n = await s;
|
|
5878
|
+
return this.urlCache[t] = n, n;
|
|
5879
|
+
}
|
|
5880
|
+
} else {
|
|
5881
|
+
const s = this.getBlob(t);
|
|
5882
|
+
if (s) {
|
|
5883
|
+
const n = await s, r = ct.createObjectURL(n);
|
|
5884
|
+
return this.urlCache[t] = r, r;
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
throw new q("File not found in the epub: " + t);
|
|
5867
5888
|
}
|
|
5868
5889
|
/**
|
|
5869
5890
|
* Revoke Temp Url for a archive item
|
|
5870
5891
|
* @param {string} url url of the item in the archive
|
|
5871
5892
|
*/
|
|
5872
5893
|
revokeUrl(t) {
|
|
5873
|
-
const e =
|
|
5874
|
-
|
|
5894
|
+
const e = this.urlCache[t];
|
|
5895
|
+
e && ct.revokeObjectURL(e);
|
|
5875
5896
|
}
|
|
5876
5897
|
destroy() {
|
|
5877
|
-
const t
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
i && t.revokeObjectURL(i);
|
|
5898
|
+
for (const t in this.urlCache) {
|
|
5899
|
+
const e = this.urlCache[t];
|
|
5900
|
+
e && ct.revokeObjectURL(e);
|
|
5881
5901
|
}
|
|
5882
5902
|
this.zip = void 0, this.urlCache = {};
|
|
5883
5903
|
}
|
|
5884
5904
|
}
|
|
5885
|
-
function
|
|
5905
|
+
function Xe(a) {
|
|
5886
5906
|
return new Promise((t, e) => {
|
|
5887
|
-
const i = indexedDB.open(
|
|
5907
|
+
const i = indexedDB.open(a, 1);
|
|
5888
5908
|
i.onupgradeneeded = () => {
|
|
5889
5909
|
i.result.createObjectStore("data");
|
|
5890
5910
|
}, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
|
|
5891
5911
|
});
|
|
5892
5912
|
}
|
|
5893
|
-
function
|
|
5894
|
-
const t =
|
|
5913
|
+
function Ye(a) {
|
|
5914
|
+
const t = Xe(a);
|
|
5895
5915
|
return {
|
|
5896
5916
|
getItem(e) {
|
|
5897
5917
|
return t.then((i) => new Promise((s, n) => {
|
|
@@ -5907,10 +5927,10 @@ function He(l) {
|
|
|
5907
5927
|
}
|
|
5908
5928
|
};
|
|
5909
5929
|
}
|
|
5910
|
-
const
|
|
5911
|
-
class
|
|
5930
|
+
const dt = typeof window < "u" ? window.URL : void 0;
|
|
5931
|
+
class te {
|
|
5912
5932
|
constructor(t, e, i) {
|
|
5913
|
-
this.urlCache = {}, this.name = t, this.requester = e ||
|
|
5933
|
+
this.urlCache = {}, this.name = t, this.requester = e || Y, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
|
|
5914
5934
|
}
|
|
5915
5935
|
/**
|
|
5916
5936
|
* Checks that IndexedDB is available and creates the storage instance
|
|
@@ -5920,7 +5940,7 @@ class Jt {
|
|
|
5920
5940
|
try {
|
|
5921
5941
|
if (typeof indexedDB > "u")
|
|
5922
5942
|
throw new Error("IndexedDB not available");
|
|
5923
|
-
this.storage =
|
|
5943
|
+
this.storage = Ye(this.name);
|
|
5924
5944
|
} catch {
|
|
5925
5945
|
throw new Error("IndexedDB not available");
|
|
5926
5946
|
}
|
|
@@ -5956,7 +5976,7 @@ class Jt {
|
|
|
5956
5976
|
add(t, e) {
|
|
5957
5977
|
const i = t.resources.map((s) => {
|
|
5958
5978
|
const { href: n } = s, r = this.resolver(n), o = encodeURIComponent(r);
|
|
5959
|
-
return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((
|
|
5979
|
+
return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((l) => this.storage.setItem(o, l)) : h);
|
|
5960
5980
|
});
|
|
5961
5981
|
return Promise.all(i);
|
|
5962
5982
|
}
|
|
@@ -5988,17 +6008,13 @@ class Jt {
|
|
|
5988
6008
|
* @param {string} [type] specify the type of the returned result
|
|
5989
6009
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
5990
6010
|
*/
|
|
5991
|
-
retrieve(t, e) {
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
message: "File not found in storage: " + t,
|
|
5999
|
-
stack: new Error().stack
|
|
6000
|
-
}), r.promise;
|
|
6001
|
-
});
|
|
6011
|
+
async retrieve(t, e) {
|
|
6012
|
+
const i = new O(t);
|
|
6013
|
+
e || (e = i.extension);
|
|
6014
|
+
const s = e === "blob" ? await this.getBlob(t) : await this.getText(t);
|
|
6015
|
+
if (s)
|
|
6016
|
+
return this.handleResponse(s, e);
|
|
6017
|
+
throw new q("File not found in storage: " + t);
|
|
6002
6018
|
}
|
|
6003
6019
|
/**
|
|
6004
6020
|
* Handle the response from request
|
|
@@ -6008,8 +6024,7 @@ class Jt {
|
|
|
6008
6024
|
* @return {string | Document | Blob | object} the parsed result
|
|
6009
6025
|
*/
|
|
6010
6026
|
handleResponse(t, e) {
|
|
6011
|
-
|
|
6012
|
-
return e == "json" ? i = JSON.parse(t) : Y(e) ? i = O(t, "text/xml") : e == "xhtml" ? i = O(t, "application/xhtml+xml") : e == "html" || e == "htm" ? i = O(t, "text/html") : i = t, i;
|
|
6027
|
+
return Ct(t, e);
|
|
6013
6028
|
}
|
|
6014
6029
|
/**
|
|
6015
6030
|
* Get a Blob from Storage by Url
|
|
@@ -6021,24 +6036,19 @@ class Jt {
|
|
|
6021
6036
|
const i = encodeURIComponent(t);
|
|
6022
6037
|
return this.storage.getItem(i).then(function(s) {
|
|
6023
6038
|
if (s)
|
|
6024
|
-
return e = e ||
|
|
6039
|
+
return e = e || G.lookup(t), new Blob([s], { type: e });
|
|
6025
6040
|
});
|
|
6026
6041
|
}
|
|
6027
6042
|
/**
|
|
6028
6043
|
* Get Text from Storage by Url
|
|
6029
6044
|
* @param {string} url
|
|
6030
|
-
* @param {string} [mimeType]
|
|
6031
6045
|
* @return {string}
|
|
6032
6046
|
*/
|
|
6033
6047
|
getText(t, e) {
|
|
6034
6048
|
const i = encodeURIComponent(t);
|
|
6035
|
-
return
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
const o = new Blob([s], { type: e });
|
|
6039
|
-
return r.addEventListener("loadend", () => {
|
|
6040
|
-
n.resolve(r.result);
|
|
6041
|
-
}), r.readAsText(o, e), n.promise;
|
|
6049
|
+
return this.storage.getItem(i).then(function(s) {
|
|
6050
|
+
if (s)
|
|
6051
|
+
return new TextDecoder().decode(s);
|
|
6042
6052
|
});
|
|
6043
6053
|
}
|
|
6044
6054
|
/**
|
|
@@ -6047,15 +6057,17 @@ class Jt {
|
|
|
6047
6057
|
* @param {string} [mimeType]
|
|
6048
6058
|
* @return {string} base64 encoded
|
|
6049
6059
|
*/
|
|
6050
|
-
getBase64(t, e) {
|
|
6060
|
+
async getBase64(t, e) {
|
|
6051
6061
|
const i = encodeURIComponent(t);
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6062
|
+
e = e || G.lookup(t);
|
|
6063
|
+
const s = await this.storage.getItem(i);
|
|
6064
|
+
if (!s) return;
|
|
6065
|
+
const n = new Blob([s], { type: e });
|
|
6066
|
+
return new Promise((r) => {
|
|
6067
|
+
const o = new FileReader();
|
|
6068
|
+
o.addEventListener("loadend", () => {
|
|
6069
|
+
r(o.result);
|
|
6070
|
+
}), o.readAsDataURL(n);
|
|
6059
6071
|
});
|
|
6060
6072
|
}
|
|
6061
6073
|
/**
|
|
@@ -6064,18 +6076,21 @@ class Jt {
|
|
|
6064
6076
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
6065
6077
|
* @return {Promise} url promise with Url string
|
|
6066
6078
|
*/
|
|
6067
|
-
createUrl(t, e) {
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
+
async createUrl(t, e) {
|
|
6080
|
+
if (t in this.urlCache)
|
|
6081
|
+
return this.urlCache[t];
|
|
6082
|
+
if (e && e.base64) {
|
|
6083
|
+
const s = await this.getBase64(t);
|
|
6084
|
+
if (s)
|
|
6085
|
+
return this.urlCache[t] = s, s;
|
|
6086
|
+
} else {
|
|
6087
|
+
const s = await this.getBlob(t);
|
|
6088
|
+
if (s) {
|
|
6089
|
+
const n = dt.createObjectURL(s);
|
|
6090
|
+
return this.urlCache[t] = n, n;
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
throw new q("File not found in storage: " + t);
|
|
6079
6094
|
}
|
|
6080
6095
|
/**
|
|
6081
6096
|
* Revoke Temp Url for a archive item
|
|
@@ -6083,18 +6098,18 @@ class Jt {
|
|
|
6083
6098
|
*/
|
|
6084
6099
|
revokeUrl(t) {
|
|
6085
6100
|
const e = this.urlCache[t];
|
|
6086
|
-
e &&
|
|
6101
|
+
e && dt.revokeObjectURL(e);
|
|
6087
6102
|
}
|
|
6088
6103
|
destroy() {
|
|
6089
6104
|
for (const t in this.urlCache) {
|
|
6090
6105
|
const e = this.urlCache[t];
|
|
6091
|
-
e &&
|
|
6106
|
+
e && dt.revokeObjectURL(e);
|
|
6092
6107
|
}
|
|
6093
6108
|
this.urlCache = {}, this.removeListeners();
|
|
6094
6109
|
}
|
|
6095
6110
|
}
|
|
6096
|
-
P(
|
|
6097
|
-
class
|
|
6111
|
+
P(te.prototype);
|
|
6112
|
+
class ut {
|
|
6098
6113
|
constructor(t) {
|
|
6099
6114
|
this.interactive = "", this.fixedLayout = "", this.openToSpread = "", this.orientationLock = "", t && this.parse(t);
|
|
6100
6115
|
}
|
|
@@ -6106,8 +6121,8 @@ class pt {
|
|
|
6106
6121
|
parse(t) {
|
|
6107
6122
|
if (!t)
|
|
6108
6123
|
return this;
|
|
6109
|
-
const e =
|
|
6110
|
-
return e ? (
|
|
6124
|
+
const e = w(t, "display_options");
|
|
6125
|
+
return e ? (B(e, "option").forEach((s) => {
|
|
6111
6126
|
let n = "";
|
|
6112
6127
|
switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
|
|
6113
6128
|
case "interactive":
|
|
@@ -6129,7 +6144,7 @@ class pt {
|
|
|
6129
6144
|
this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
|
|
6130
6145
|
}
|
|
6131
6146
|
}
|
|
6132
|
-
const
|
|
6147
|
+
const zt = "META-INF/container.xml", Ge = "META-INF/com.apple.ibooks.display-options.xml", L = {
|
|
6133
6148
|
BINARY: "binary",
|
|
6134
6149
|
BASE64: "base64",
|
|
6135
6150
|
EPUB: "epub",
|
|
@@ -6137,7 +6152,7 @@ const Ot = "META-INF/container.xml", Xe = "META-INF/com.apple.ibooks.display-opt
|
|
|
6137
6152
|
MANIFEST: "json",
|
|
6138
6153
|
DIRECTORY: "directory"
|
|
6139
6154
|
};
|
|
6140
|
-
class
|
|
6155
|
+
class Rt {
|
|
6141
6156
|
constructor(t, e) {
|
|
6142
6157
|
typeof e > "u" && typeof t != "string" && !(t instanceof Blob) && !(t instanceof ArrayBuffer) && (e = t, t = void 0), this.settings = C({}, {
|
|
6143
6158
|
requestMethod: void 0,
|
|
@@ -6148,15 +6163,15 @@ class Lt {
|
|
|
6148
6163
|
canonical: void 0,
|
|
6149
6164
|
openAs: void 0,
|
|
6150
6165
|
store: void 0
|
|
6151
|
-
}), C(this.settings, e), this.opening = new
|
|
6152
|
-
manifest: new
|
|
6153
|
-
spine: new
|
|
6154
|
-
metadata: new
|
|
6155
|
-
cover: new
|
|
6156
|
-
navigation: new
|
|
6157
|
-
pageList: new
|
|
6158
|
-
resources: new
|
|
6159
|
-
displayOptions: new
|
|
6166
|
+
}), C(this.settings, e), this.opening = new S(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
|
|
6167
|
+
manifest: new S(),
|
|
6168
|
+
spine: new S(),
|
|
6169
|
+
metadata: new S(),
|
|
6170
|
+
cover: new S(),
|
|
6171
|
+
navigation: new S(),
|
|
6172
|
+
pageList: new S(),
|
|
6173
|
+
resources: new S(),
|
|
6174
|
+
displayOptions: new S()
|
|
6160
6175
|
}, this.loaded = {
|
|
6161
6176
|
manifest: this.loading.manifest.promise,
|
|
6162
6177
|
spine: this.loading.spine.promise,
|
|
@@ -6174,7 +6189,7 @@ class Lt {
|
|
|
6174
6189
|
this.loaded.navigation,
|
|
6175
6190
|
this.loaded.resources,
|
|
6176
6191
|
this.loaded.displayOptions
|
|
6177
|
-
]), this.isRendered = !1, this.request = this.settings.requestMethod ||
|
|
6192
|
+
]), this.isRendered = !1, this.request = this.settings.requestMethod || Y, this.spine = new we(), this.locations = new $t(this.spine, (i) => this.load(i)), this.navigation = void 0, this.pageList = void 0, this.url = void 0, this.path = void 0, this.archived = !1, this.archive = void 0, this.storage = void 0, this.resources = void 0, this.rendition = void 0, this.container = void 0, this.packaging = void 0, this.displayOptions = void 0, this.settings.store && this.store(this.settings.store), t && this.open(t, this.settings.openAs).catch((i) => {
|
|
6178
6193
|
const s = new Error("Cannot load book at " + t);
|
|
6179
6194
|
this.emit(f.BOOK.OPEN_FAILED, s);
|
|
6180
6195
|
});
|
|
@@ -6189,7 +6204,7 @@ class Lt {
|
|
|
6189
6204
|
open(t, e) {
|
|
6190
6205
|
let i;
|
|
6191
6206
|
const s = e || this.determineType(t);
|
|
6192
|
-
return s ===
|
|
6207
|
+
return s === L.BINARY ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t)) : s === L.BASE64 ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t, s)) : s === L.EPUB ? (this.archived = !0, this.url = new R("/", ""), i = this.request(t, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then((n) => this.openEpub(n))) : s === L.OPF ? (this.url = new R(t), i = this.openPackaging(this.url.Path.toString())) : s === L.MANIFEST ? (this.url = new R(t), i = this.openManifest(this.url.Path.toString())) : (this.url = new R(t), i = this.openContainer(zt).then((n) => this.openPackaging(n))), i;
|
|
6193
6208
|
}
|
|
6194
6209
|
/**
|
|
6195
6210
|
* Open an archived epub
|
|
@@ -6199,7 +6214,7 @@ class Lt {
|
|
|
6199
6214
|
* @return {Promise}
|
|
6200
6215
|
*/
|
|
6201
6216
|
openEpub(t, e) {
|
|
6202
|
-
return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(
|
|
6217
|
+
return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(zt)).then((i) => this.openPackaging(i));
|
|
6203
6218
|
}
|
|
6204
6219
|
/**
|
|
6205
6220
|
* Open the epub container
|
|
@@ -6208,7 +6223,7 @@ class Lt {
|
|
|
6208
6223
|
* @return {string} packagePath
|
|
6209
6224
|
*/
|
|
6210
6225
|
openContainer(t) {
|
|
6211
|
-
return this.load(t).then((e) => (this.container = new
|
|
6226
|
+
return this.load(t).then((e) => (this.container = new be(e), this.resolve(this.container.packagePath)));
|
|
6212
6227
|
}
|
|
6213
6228
|
/**
|
|
6214
6229
|
* Open the Open Packaging Format Xml
|
|
@@ -6217,7 +6232,7 @@ class Lt {
|
|
|
6217
6232
|
* @return {Promise}
|
|
6218
6233
|
*/
|
|
6219
6234
|
openPackaging(t) {
|
|
6220
|
-
return this.path = new
|
|
6235
|
+
return this.path = new O(t), this.load(t).then((e) => (this.packaging = new It(e), this.unpack(this.packaging)));
|
|
6221
6236
|
}
|
|
6222
6237
|
/**
|
|
6223
6238
|
* Open the manifest JSON
|
|
@@ -6226,7 +6241,7 @@ class Lt {
|
|
|
6226
6241
|
* @return {Promise}
|
|
6227
6242
|
*/
|
|
6228
6243
|
openManifest(t) {
|
|
6229
|
-
return this.path = new
|
|
6244
|
+
return this.path = new O(t), this.load(t).then((e) => (this.packaging = new It(), this.packaging.load(e), this.unpack(this.packaging)));
|
|
6230
6245
|
}
|
|
6231
6246
|
/**
|
|
6232
6247
|
* Load a resource from the Book
|
|
@@ -6247,7 +6262,7 @@ class Lt {
|
|
|
6247
6262
|
if (!t)
|
|
6248
6263
|
return "";
|
|
6249
6264
|
let i = t;
|
|
6250
|
-
return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e
|
|
6265
|
+
return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e !== !1 && this.url && (i = this.url.resolve(i)), i);
|
|
6251
6266
|
}
|
|
6252
6267
|
/**
|
|
6253
6268
|
* Get a canonical link to a path
|
|
@@ -6267,17 +6282,17 @@ class Lt {
|
|
|
6267
6282
|
determineType(t) {
|
|
6268
6283
|
let e;
|
|
6269
6284
|
if (this.settings.encoding === "base64")
|
|
6270
|
-
return
|
|
6285
|
+
return L.BASE64;
|
|
6271
6286
|
if (typeof t != "string")
|
|
6272
|
-
return
|
|
6287
|
+
return L.BINARY;
|
|
6273
6288
|
if (e = new R(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
|
|
6274
|
-
return
|
|
6289
|
+
return L.DIRECTORY;
|
|
6275
6290
|
if (e === "epub")
|
|
6276
|
-
return
|
|
6291
|
+
return L.EPUB;
|
|
6277
6292
|
if (e === "opf")
|
|
6278
|
-
return
|
|
6293
|
+
return L.OPF;
|
|
6279
6294
|
if (e === "json")
|
|
6280
|
-
return
|
|
6295
|
+
return L.MANIFEST;
|
|
6281
6296
|
}
|
|
6282
6297
|
/**
|
|
6283
6298
|
* unpack the contents of the Books packaging
|
|
@@ -6285,26 +6300,20 @@ class Lt {
|
|
|
6285
6300
|
* @param {Packaging} packaging object
|
|
6286
6301
|
*/
|
|
6287
6302
|
unpack(t) {
|
|
6288
|
-
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(
|
|
6289
|
-
this.displayOptions = new
|
|
6290
|
-
}).catch((
|
|
6291
|
-
this.displayOptions = new
|
|
6292
|
-
}) : (this.displayOptions = new
|
|
6303
|
+
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(Ge)).then((i) => {
|
|
6304
|
+
this.displayOptions = new ut(i), this.loading.displayOptions.resolve(this.displayOptions);
|
|
6305
|
+
}).catch((i) => {
|
|
6306
|
+
this.displayOptions = new ut(), this.loading.displayOptions.resolve(this.displayOptions);
|
|
6307
|
+
}) : (this.displayOptions = new ut(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new _e(this.packaging.manifest, {
|
|
6293
6308
|
archive: this.archive,
|
|
6294
|
-
resolver: (
|
|
6295
|
-
request: (
|
|
6309
|
+
resolver: (i, s) => this.resolve(i, s),
|
|
6310
|
+
request: (i, s) => this.request(i, s),
|
|
6296
6311
|
replacements: this.settings.replacements || (this.archived ? "blobUrl" : "base64")
|
|
6297
6312
|
}), this.loadNavigation(this.packaging).then(() => {
|
|
6298
6313
|
this.loading.navigation.resolve(this.navigation);
|
|
6299
|
-
}), this.packaging.coverPath && (this.cover = this.resolve(this.packaging.coverPath)), this.loading.manifest.resolve(this.packaging.manifest), this.loading.metadata.resolve(this.packaging.metadata), this.loading.spine.resolve(this.spine), this.loading.cover.resolve(this.cover), this.loading.resources.resolve(this.resources), this.loading.pageList.resolve(this.pageList), this.isOpen = !0, this.
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
});
|
|
6303
|
-
}).catch((e) => {
|
|
6304
|
-
console.error(e), this.loaded.displayOptions.then(() => {
|
|
6305
|
-
this.opening.resolve(this);
|
|
6306
|
-
});
|
|
6307
|
-
}) : this.loaded.displayOptions.then(() => {
|
|
6314
|
+
}), this.packaging.coverPath && (this.cover = this.resolve(this.packaging.coverPath)), this.loading.manifest.resolve(this.packaging.manifest), this.loading.metadata.resolve(this.packaging.metadata), this.loading.spine.resolve(this.spine), this.loading.cover.resolve(this.cover), this.loading.resources.resolve(this.resources), this.loading.pageList.resolve(this.pageList), this.isOpen = !0, (this.settings.replacements || (this.archived ? "blobUrl" : "none")) !== "none" && (this.replacementsReady = this.replacements().catch((i) => {
|
|
6315
|
+
console.error(i);
|
|
6316
|
+
})), Promise.all([this.loaded.displayOptions, this.loaded.navigation]).then(() => {
|
|
6308
6317
|
this.opening.resolve(this);
|
|
6309
6318
|
});
|
|
6310
6319
|
}
|
|
@@ -6316,9 +6325,9 @@ class Lt {
|
|
|
6316
6325
|
loadNavigation(t) {
|
|
6317
6326
|
const e = t.navPath || t.ncxPath, i = t.toc;
|
|
6318
6327
|
return i ? new Promise((s, n) => {
|
|
6319
|
-
this.navigation = new
|
|
6320
|
-
}) : e ? this.load(e, "xml").then((s) => (this.navigation = new
|
|
6321
|
-
this.navigation = new
|
|
6328
|
+
this.navigation = new ht(i), "pageList" in t && t.pageList && (this.pageList = new lt(t.pageList)), s(this.navigation);
|
|
6329
|
+
}) : e ? this.load(e, "xml").then((s) => (this.navigation = new ht(s), this.pageList = new lt(s), this.navigation)) : new Promise((s, n) => {
|
|
6330
|
+
this.navigation = new ht(), this.pageList = new lt(), s(this.navigation);
|
|
6322
6331
|
});
|
|
6323
6332
|
}
|
|
6324
6333
|
/**
|
|
@@ -6337,7 +6346,7 @@ class Lt {
|
|
|
6337
6346
|
* @return {Rendition}
|
|
6338
6347
|
*/
|
|
6339
6348
|
renderTo(t, e) {
|
|
6340
|
-
return this.rendition = new
|
|
6349
|
+
return this.rendition = new Lt(this, e), this.rendition.attachTo(t), this.rendition;
|
|
6341
6350
|
}
|
|
6342
6351
|
/**
|
|
6343
6352
|
* Set if request should use withCredentials
|
|
@@ -6361,7 +6370,7 @@ class Lt {
|
|
|
6361
6370
|
* @return {Archive}
|
|
6362
6371
|
*/
|
|
6363
6372
|
unarchive(t, e) {
|
|
6364
|
-
return this.archive = new
|
|
6373
|
+
return this.archive = new He(), this.archive.open(t, e === "base64");
|
|
6365
6374
|
}
|
|
6366
6375
|
/**
|
|
6367
6376
|
* Store the epubs contents
|
|
@@ -6371,8 +6380,8 @@ class Lt {
|
|
|
6371
6380
|
* @return {Store}
|
|
6372
6381
|
*/
|
|
6373
6382
|
store(t) {
|
|
6374
|
-
const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) =>
|
|
6375
|
-
return this.storage = new
|
|
6383
|
+
const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) => Y(n, r));
|
|
6384
|
+
return this.storage = new te(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
|
|
6376
6385
|
this.archived && (this.storage.requester = (r, o) => this.archive.request(r, o));
|
|
6377
6386
|
const n = (r, o) => {
|
|
6378
6387
|
o.output = this.resources.substitute(r, o.url);
|
|
@@ -6397,10 +6406,11 @@ class Lt {
|
|
|
6397
6406
|
* @return {Promise} completed loading urls
|
|
6398
6407
|
*/
|
|
6399
6408
|
replacements() {
|
|
6400
|
-
|
|
6401
|
-
e.output = this.resources.substitute(t, e.url);
|
|
6402
|
-
}), this.resources.replacements().then(() => this.resources.replaceCss()).then(() => {
|
|
6409
|
+
const t = this.resources.replacements().then(() => this.resources.replaceCss()).then(() => {
|
|
6403
6410
|
});
|
|
6411
|
+
return this.spine.hooks.serialize.register((e, i) => t.then(() => {
|
|
6412
|
+
i.output = this.resources.substitute(e, i.url);
|
|
6413
|
+
})), t;
|
|
6404
6414
|
}
|
|
6405
6415
|
/**
|
|
6406
6416
|
* Find a DOM Range for a given CFI Range
|
|
@@ -6422,45 +6432,46 @@ class Lt {
|
|
|
6422
6432
|
*/
|
|
6423
6433
|
key(t) {
|
|
6424
6434
|
const e = t || this.packaging.metadata.identifier || this.url.filename;
|
|
6425
|
-
return `epubjs:${
|
|
6435
|
+
return `epubjs:${nt}:${e}`;
|
|
6426
6436
|
}
|
|
6427
6437
|
/**
|
|
6428
6438
|
* Destroy the Book and all associated objects
|
|
6429
6439
|
*/
|
|
6430
6440
|
destroy() {
|
|
6431
|
-
this.opened = void 0, this.loading = void 0, this.loaded = void 0, this.ready = void 0, this.isOpen = !1, this.isRendered = !1, this.spine && this.spine.destroy(), this.locations && this.locations.destroy(), this.pageList && this.pageList.destroy(), this.archive && this.archive.destroy(), this.resources && this.resources.destroy(), this.container && this.container.destroy(), this.packaging && this.packaging.destroy(), this.rendition && this.rendition.destroy(), this.displayOptions && this.displayOptions.destroy(), this.storage && (this.storage.destroy(), this.storage = void 0), this.spine = void 0, this.locations = void 0, this.pageList = void 0, this.archive = void 0, this.resources = void 0, this.container = void 0, this.packaging = void 0, this.rendition = void 0, this.navigation = void 0, this.url = void 0, this.path = void 0, this.archived = !1;
|
|
6441
|
+
this.opened = void 0, this.loading = void 0, this.loaded = void 0, this.ready = void 0, this.replacementsReady = void 0, this.isOpen = !1, this.isRendered = !1, this.spine && this.spine.destroy(), this.locations && this.locations.destroy(), this.pageList && this.pageList.destroy(), this.archive && this.archive.destroy(), this.resources && this.resources.destroy(), this.container && this.container.destroy(), this.packaging && this.packaging.destroy(), this.rendition && this.rendition.destroy(), this.displayOptions && this.displayOptions.destroy(), this.storage && (this.storage.destroy(), this.storage = void 0), this.spine = void 0, this.locations = void 0, this.pageList = void 0, this.archive = void 0, this.resources = void 0, this.container = void 0, this.packaging = void 0, this.rendition = void 0, this.navigation = void 0, this.url = void 0, this.path = void 0, this.archived = !1;
|
|
6432
6442
|
}
|
|
6433
6443
|
}
|
|
6434
|
-
P(
|
|
6435
|
-
function
|
|
6436
|
-
return new
|
|
6444
|
+
P(Rt.prototype);
|
|
6445
|
+
function X(a, t) {
|
|
6446
|
+
return new Rt(a, t);
|
|
6437
6447
|
}
|
|
6438
|
-
|
|
6439
|
-
typeof global < "u" && (globalThis.EPUBJS_VERSION =
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6448
|
+
X.VERSION = nt;
|
|
6449
|
+
typeof global < "u" && (globalThis.EPUBJS_VERSION = nt);
|
|
6450
|
+
X.Book = Rt;
|
|
6451
|
+
X.Rendition = Lt;
|
|
6452
|
+
X.Contents = Nt;
|
|
6453
|
+
X.CFI = y;
|
|
6454
|
+
X.utils = ae;
|
|
6445
6455
|
export {
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6456
|
+
Te as Annotations,
|
|
6457
|
+
He as Archive,
|
|
6458
|
+
Rt as Book,
|
|
6459
|
+
Nt as Contents,
|
|
6460
|
+
ut as DisplayOptions,
|
|
6451
6461
|
y as EpubCFI,
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6462
|
+
q as EpubError,
|
|
6463
|
+
Kt as Layout,
|
|
6464
|
+
$t as Locations,
|
|
6465
|
+
wt as Mapping,
|
|
6466
|
+
ht as Navigation,
|
|
6467
|
+
It as Packaging,
|
|
6468
|
+
lt as PageList,
|
|
6469
|
+
Lt as Rendition,
|
|
6470
|
+
_e as Resources,
|
|
6471
|
+
ye as Section,
|
|
6472
|
+
we as Spine,
|
|
6473
|
+
te as Store,
|
|
6474
|
+
Ce as Themes,
|
|
6475
|
+
X as default
|
|
6465
6476
|
};
|
|
6466
6477
|
//# sourceMappingURL=epub.js.map
|