@likecoin/epub-ts 0.4.9 → 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/contents.d.ts +0 -12
- package/dist/epub.cjs +3 -3
- package/dist/epub.cjs.map +1 -1
- package/dist/epub.js +846 -887
- 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 +865 -908
- 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/managers/continuous/index.d.ts +1 -3
- package/dist/managers/default/index.d.ts +0 -9
- 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 = V(
|
|
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 V(
|
|
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 ? V(
|
|
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);
|
|
138
|
+
}
|
|
139
|
+
function _t(a) {
|
|
140
|
+
return ["xml", "opf", "ncx"].indexOf(a) > -1;
|
|
144
141
|
}
|
|
145
|
-
function
|
|
146
|
-
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;
|
|
147
144
|
}
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
class q extends Error {
|
|
146
|
+
constructor(t, e) {
|
|
147
|
+
super(t), this.name = "EpubError", this.status = e;
|
|
148
|
+
}
|
|
150
149
|
}
|
|
151
|
-
function
|
|
152
|
-
return new Blob([
|
|
150
|
+
function jt(a, t) {
|
|
151
|
+
return new Blob([a], { type: t });
|
|
153
152
|
}
|
|
154
|
-
function
|
|
155
|
-
const e =
|
|
156
|
-
return
|
|
153
|
+
function tt(a, t) {
|
|
154
|
+
const e = jt(a, t);
|
|
155
|
+
return Bt.createObjectURL(e);
|
|
157
156
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
157
|
+
function Tt(a) {
|
|
158
|
+
return Bt.revokeObjectURL(a);
|
|
160
159
|
}
|
|
161
|
-
function
|
|
162
|
-
if (typeof
|
|
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:
|
|
328
|
+
indexOfTextNode: oe,
|
|
329
|
+
insert: re,
|
|
330
|
+
isElement: Mt,
|
|
331
|
+
isFloat: Wt,
|
|
332
|
+
isNumber: x,
|
|
333
|
+
isXml: _t,
|
|
333
334
|
locationOf: V,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
qs:
|
|
339
|
-
qsa:
|
|
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 H(
|
|
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 ?
|
|
393
|
+
for (let i = a.length - 1; i >= -1 && !e; i--) {
|
|
394
|
+
const s = i >= 0 ? a[i] : "/";
|
|
394
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 (H(
|
|
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 (H(
|
|
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 H(
|
|
447
|
+
function ue(a) {
|
|
448
|
+
return H(a), a.length > 0 && a.charCodeAt(0) === 47;
|
|
448
449
|
}
|
|
449
|
-
function
|
|
450
|
-
H(
|
|
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
|
|
@@ -526,7 +527,7 @@ class z {
|
|
|
526
527
|
return this.path;
|
|
527
528
|
}
|
|
528
529
|
}
|
|
529
|
-
class
|
|
530
|
+
class R {
|
|
530
531
|
constructor(t, e) {
|
|
531
532
|
const i = t.indexOf("://") > -1;
|
|
532
533
|
let s = t, n;
|
|
@@ -534,9 +535,9 @@ class N {
|
|
|
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 N {
|
|
|
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 N {
|
|
|
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 N {
|
|
|
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;
|
|
@@ -1059,7 +1060,7 @@ function ge(l, t) {
|
|
|
1059
1060
|
else {
|
|
1060
1061
|
let c;
|
|
1061
1062
|
try {
|
|
1062
|
-
c = new
|
|
1063
|
+
c = new R(o, s);
|
|
1063
1064
|
} catch {
|
|
1064
1065
|
}
|
|
1065
1066
|
r.onclick = function() {
|
|
@@ -1070,67 +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
|
+
function At(a, t, e) {
|
|
1074
1075
|
const i = /* @__PURE__ */ new Map(), s = [], n = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
|
1075
1076
|
for (let o = 0; o < t.length; o++) {
|
|
1076
|
-
const h = t[o],
|
|
1077
|
-
if (!h || !
|
|
1077
|
+
const h = t[o], l = e[o];
|
|
1078
|
+
if (!h || !l) continue;
|
|
1078
1079
|
const c = h.replace(n, "\\$&");
|
|
1079
|
-
i.set(h,
|
|
1080
|
+
i.set(h, l), s.push(c);
|
|
1080
1081
|
try {
|
|
1081
1082
|
const d = decodeURIComponent(h);
|
|
1082
1083
|
if (d !== h) {
|
|
1083
1084
|
const u = d.replace(n, "\\$&");
|
|
1084
|
-
i.set(d,
|
|
1085
|
+
i.set(d, l), s.push(u);
|
|
1085
1086
|
}
|
|
1086
1087
|
} catch {
|
|
1087
1088
|
}
|
|
1088
1089
|
}
|
|
1089
|
-
if (s.length === 0) return
|
|
1090
|
+
if (s.length === 0) return a;
|
|
1090
1091
|
s.sort((o, h) => h.length - o.length);
|
|
1091
1092
|
const r = new RegExp(s.join("|"), "g");
|
|
1092
|
-
return
|
|
1093
|
+
return a.replace(r, (o) => i.get(o) ?? o);
|
|
1093
1094
|
}
|
|
1094
|
-
function Y(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
e && (
|
|
1098
|
-
|
|
1099
|
-
o.
|
|
1100
|
-
t == "json" && o.setRequestHeader("Accept", "application/json"), t || (t = new z(l).extension), t == "blob" && (o.responseType = n), G(t) && o.overrideMimeType("text/xml"), t == "binary" && (o.responseType = "arraybuffer"), o.send();
|
|
1101
|
-
function a(d) {
|
|
1102
|
-
r.reject(d);
|
|
1103
|
-
}
|
|
1104
|
-
function c() {
|
|
1105
|
-
if (o.readyState === XMLHttpRequest.DONE) {
|
|
1106
|
-
let d = !1;
|
|
1107
|
-
if ((o.responseType === "" || o.responseType === "document") && (d = o.responseXML), o.status === 200 || o.status === 0 || d) {
|
|
1108
|
-
let u;
|
|
1109
|
-
if (!o.response && !d)
|
|
1110
|
-
return r.reject({
|
|
1111
|
-
status: o.status,
|
|
1112
|
-
message: "Empty Response",
|
|
1113
|
-
stack: new Error().stack
|
|
1114
|
-
}), r.promise;
|
|
1115
|
-
if (o.status === 403)
|
|
1116
|
-
return r.reject({
|
|
1117
|
-
status: o.status,
|
|
1118
|
-
response: o.response,
|
|
1119
|
-
message: "Forbidden",
|
|
1120
|
-
stack: new Error().stack
|
|
1121
|
-
}), r.promise;
|
|
1122
|
-
d ? u = o.responseXML : G(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);
|
|
1123
|
-
} else
|
|
1124
|
-
r.reject({
|
|
1125
|
-
status: o.status,
|
|
1126
|
-
message: o.response,
|
|
1127
|
-
stack: new Error().stack
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
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;
|
|
1130
1101
|
}
|
|
1131
|
-
|
|
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;
|
|
1132
1122
|
}
|
|
1133
|
-
class
|
|
1123
|
+
class ye {
|
|
1134
1124
|
constructor(t, e) {
|
|
1135
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;
|
|
1136
1126
|
}
|
|
@@ -1139,36 +1129,28 @@ class me {
|
|
|
1139
1129
|
* @param {method} [_request] a request method to use for loading
|
|
1140
1130
|
* @return {document} a promise with the xml document
|
|
1141
1131
|
*/
|
|
1142
|
-
load(t) {
|
|
1143
|
-
const e = t || this.request || Y
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
}), 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;
|
|
1149
1138
|
}
|
|
1150
1139
|
/**
|
|
1151
1140
|
* Adds a base tag for resolving urls in the section
|
|
1152
1141
|
* @private
|
|
1153
1142
|
*/
|
|
1154
1143
|
base() {
|
|
1155
|
-
return
|
|
1144
|
+
return Gt(this.document, this);
|
|
1156
1145
|
}
|
|
1157
1146
|
/**
|
|
1158
1147
|
* Render the contents of a section
|
|
1159
1148
|
* @param {method} [_request] a request method to use for loading
|
|
1160
1149
|
* @return {string} output a serialized XML Document
|
|
1161
1150
|
*/
|
|
1162
|
-
render(t) {
|
|
1163
|
-
const e =
|
|
1164
|
-
return this.
|
|
1165
|
-
const n = new XMLSerializer();
|
|
1166
|
-
return this.output = n.serializeToString(s), this.output;
|
|
1167
|
-
}).then(() => this.hooks.serialize.trigger(this.output, this)).then(() => {
|
|
1168
|
-
e.resolve(this.output);
|
|
1169
|
-
}).catch(function(s) {
|
|
1170
|
-
e.reject(s);
|
|
1171
|
-
}), 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;
|
|
1172
1154
|
}
|
|
1173
1155
|
/**
|
|
1174
1156
|
* Find a string in a section
|
|
@@ -1178,15 +1160,15 @@ class me {
|
|
|
1178
1160
|
find(t) {
|
|
1179
1161
|
const e = this, i = [], s = t.toLowerCase(), n = function(r) {
|
|
1180
1162
|
const o = r.textContent.toLowerCase();
|
|
1181
|
-
let h,
|
|
1163
|
+
let h, l, c, d = -1, u;
|
|
1182
1164
|
const p = 150;
|
|
1183
|
-
for (; c
|
|
1184
|
-
c = o.indexOf(s, d + 1), c
|
|
1185
|
-
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,
|
|
1186
1168
|
excerpt: u
|
|
1187
1169
|
})), d = c;
|
|
1188
1170
|
};
|
|
1189
|
-
return
|
|
1171
|
+
return et(e.document, function(r) {
|
|
1190
1172
|
n(r);
|
|
1191
1173
|
}), i;
|
|
1192
1174
|
}
|
|
@@ -1199,28 +1181,28 @@ class me {
|
|
|
1199
1181
|
search(t, e = 5) {
|
|
1200
1182
|
const i = [], n = this, r = t.toLowerCase(), o = function(d) {
|
|
1201
1183
|
const g = d.reduce((m, v) => m + (v.textContent ?? ""), "").toLowerCase().indexOf(r);
|
|
1202
|
-
if (g
|
|
1184
|
+
if (g !== -1) {
|
|
1203
1185
|
const v = g + r.length;
|
|
1204
|
-
let
|
|
1186
|
+
let b = 0, k = 0;
|
|
1205
1187
|
if (g < d[0].length) {
|
|
1206
|
-
for (;
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
T.setStart(
|
|
1210
|
-
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);
|
|
1211
1193
|
T.setEnd(_, I > v ? v : v - I);
|
|
1212
|
-
const
|
|
1213
|
-
let
|
|
1214
|
-
|
|
1215
|
-
cfi:
|
|
1216
|
-
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
|
|
1217
1199
|
});
|
|
1218
1200
|
}
|
|
1219
1201
|
}
|
|
1220
1202
|
}, h = document.createTreeWalker(n.document, NodeFilter.SHOW_TEXT, null);
|
|
1221
|
-
let
|
|
1222
|
-
for (;
|
|
1223
|
-
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));
|
|
1224
1206
|
return c.length > 0 && o(c), i;
|
|
1225
1207
|
}
|
|
1226
1208
|
/**
|
|
@@ -1238,7 +1220,7 @@ class me {
|
|
|
1238
1220
|
return this.properties.forEach(function(i) {
|
|
1239
1221
|
const s = i.replace("rendition:", ""), n = s.indexOf("-");
|
|
1240
1222
|
let r, o;
|
|
1241
|
-
n
|
|
1223
|
+
n !== -1 && (r = s.slice(0, n), o = s.slice(n + 1), e[r] = o);
|
|
1242
1224
|
}), e;
|
|
1243
1225
|
}
|
|
1244
1226
|
/**
|
|
@@ -1267,9 +1249,9 @@ class me {
|
|
|
1267
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;
|
|
1268
1250
|
}
|
|
1269
1251
|
}
|
|
1270
|
-
class
|
|
1252
|
+
class we {
|
|
1271
1253
|
constructor() {
|
|
1272
|
-
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;
|
|
1273
1255
|
}
|
|
1274
1256
|
/**
|
|
1275
1257
|
* Unpack items from a opf into spine items
|
|
@@ -1283,23 +1265,23 @@ class ve {
|
|
|
1283
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 = () => {
|
|
1284
1266
|
let h = s.index;
|
|
1285
1267
|
for (; h > 0; ) {
|
|
1286
|
-
const
|
|
1287
|
-
if (
|
|
1288
|
-
return
|
|
1268
|
+
const l = this.get(h - 1);
|
|
1269
|
+
if (l && l.linear)
|
|
1270
|
+
return l;
|
|
1289
1271
|
h -= 1;
|
|
1290
1272
|
}
|
|
1291
1273
|
}, s.next = () => {
|
|
1292
1274
|
let h = s.index;
|
|
1293
1275
|
for (; h < this.spineItems.length - 1; ) {
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1296
|
-
return
|
|
1276
|
+
const l = this.get(h + 1);
|
|
1277
|
+
if (l && l.linear)
|
|
1278
|
+
return l;
|
|
1297
1279
|
h += 1;
|
|
1298
1280
|
}
|
|
1299
1281
|
}) : (s.prev = function() {
|
|
1300
1282
|
}, s.next = function() {
|
|
1301
1283
|
});
|
|
1302
|
-
const o = new
|
|
1284
|
+
const o = new ye(s, this.hooks);
|
|
1303
1285
|
this.append(o);
|
|
1304
1286
|
}), this.loaded = !0;
|
|
1305
1287
|
}
|
|
@@ -1393,16 +1375,16 @@ class ve {
|
|
|
1393
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;
|
|
1394
1376
|
}
|
|
1395
1377
|
}
|
|
1396
|
-
class
|
|
1378
|
+
class kt {
|
|
1397
1379
|
constructor(t) {
|
|
1398
|
-
this._q = [], this.context = t, this.tick =
|
|
1380
|
+
this._q = [], this.context = t, this.tick = Dt, this.running = !1, this.paused = !1;
|
|
1399
1381
|
}
|
|
1400
1382
|
enqueue(...t) {
|
|
1401
1383
|
let e, i, s;
|
|
1402
1384
|
const [n, ...r] = t;
|
|
1403
1385
|
if (!n)
|
|
1404
1386
|
throw new Error("No Task Provided");
|
|
1405
|
-
return typeof n == "function" ? (e = new
|
|
1387
|
+
return typeof n == "function" ? (e = new S(), i = e.promise, s = {
|
|
1406
1388
|
task: n,
|
|
1407
1389
|
args: r,
|
|
1408
1390
|
//"context" : context,
|
|
@@ -1411,7 +1393,7 @@ class Ct {
|
|
|
1411
1393
|
}) : s = {
|
|
1412
1394
|
args: [],
|
|
1413
1395
|
promise: n
|
|
1414
|
-
}, this._q.push(s), this.paused
|
|
1396
|
+
}, this._q.push(s), !this.paused && !this.running && this.run(), s.promise;
|
|
1415
1397
|
}
|
|
1416
1398
|
/**
|
|
1417
1399
|
* Run one item
|
|
@@ -1435,14 +1417,14 @@ class Ct {
|
|
|
1435
1417
|
* @return {Promise}
|
|
1436
1418
|
*/
|
|
1437
1419
|
run() {
|
|
1438
|
-
this.running || (this.running = !0, this.defered = new
|
|
1420
|
+
this.running || (this.running = !0, this.defered = new S());
|
|
1439
1421
|
const t = () => {
|
|
1440
1422
|
var e;
|
|
1441
1423
|
this._q.length ? (e = this.dequeue()) == null || e.then(() => {
|
|
1442
1424
|
this.run();
|
|
1443
1425
|
}) : (this.defered.resolve(), this.running = void 0);
|
|
1444
1426
|
};
|
|
1445
|
-
return this.tick
|
|
1427
|
+
return this.tick(t), this.paused && (this.paused = !1), this.defered.promise;
|
|
1446
1428
|
}
|
|
1447
1429
|
/**
|
|
1448
1430
|
* Flush all, as quickly as possible
|
|
@@ -1481,7 +1463,7 @@ class Ct {
|
|
|
1481
1463
|
this._q = [], this.running = !1, this.paused = !0;
|
|
1482
1464
|
}
|
|
1483
1465
|
}
|
|
1484
|
-
const
|
|
1466
|
+
const nt = "0.3", Z = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], f = {
|
|
1485
1467
|
BOOK: {
|
|
1486
1468
|
OPEN_FAILED: "openFailed"
|
|
1487
1469
|
},
|
|
@@ -1538,9 +1520,9 @@ const ht = "0.3", J = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
|
|
|
1538
1520
|
DETACH: "detach"
|
|
1539
1521
|
}
|
|
1540
1522
|
};
|
|
1541
|
-
class
|
|
1523
|
+
class $t {
|
|
1542
1524
|
constructor(t, e, i) {
|
|
1543
|
-
this.spine = t, this.request = e, this.pause = i || 0, this.q = new
|
|
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;
|
|
1544
1526
|
}
|
|
1545
1527
|
/**
|
|
1546
1528
|
* Load all of sections in the book to generate locations
|
|
@@ -1560,23 +1542,23 @@ class Xt {
|
|
|
1560
1542
|
endOffset: void 0
|
|
1561
1543
|
};
|
|
1562
1544
|
}
|
|
1563
|
-
process(t) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
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);
|
|
1567
1549
|
});
|
|
1568
1550
|
}
|
|
1569
1551
|
parse(t, e, i) {
|
|
1570
1552
|
const s = [];
|
|
1571
1553
|
let n;
|
|
1572
|
-
const r = t.ownerDocument, o =
|
|
1573
|
-
let h = 0,
|
|
1554
|
+
const r = t.ownerDocument, o = w(r, "body");
|
|
1555
|
+
let h = 0, l;
|
|
1574
1556
|
const c = i || this.break;
|
|
1575
|
-
if (
|
|
1557
|
+
if (et(o, (u) => {
|
|
1576
1558
|
const p = u.length;
|
|
1577
1559
|
let g, m = 0;
|
|
1578
1560
|
if ((u.textContent ?? "").trim().length === 0)
|
|
1579
|
-
return
|
|
1561
|
+
return l = u, !1;
|
|
1580
1562
|
for (h === 0 && (n = this.createRange(), n.startContainer = u, n.startOffset = 0), g = c - h, g > p && (h += p, m = p); m < p; )
|
|
1581
1563
|
if (g = c - h, h === 0 && (m += 1, n = this.createRange(), n.startContainer = u, n.startOffset = m), m + g >= p)
|
|
1582
1564
|
h += p - m, m = p;
|
|
@@ -1585,9 +1567,9 @@ class Xt {
|
|
|
1585
1567
|
const v = new y(n, e).toString();
|
|
1586
1568
|
s.push(v), h = 0;
|
|
1587
1569
|
}
|
|
1588
|
-
return
|
|
1589
|
-
}), n && n.startContainer &&
|
|
1590
|
-
n.endContainer =
|
|
1570
|
+
return l = u, !1;
|
|
1571
|
+
}), n && n.startContainer && l) {
|
|
1572
|
+
n.endContainer = l, n.endOffset = l.length;
|
|
1591
1573
|
const u = new y(n, e).toString();
|
|
1592
1574
|
s.push(u), h = 0;
|
|
1593
1575
|
}
|
|
@@ -1603,13 +1585,15 @@ class Xt {
|
|
|
1603
1585
|
generateFromWords(t, e, i) {
|
|
1604
1586
|
const s = t ? new y(t) : void 0;
|
|
1605
1587
|
return this.q.pause(), this._locationsWords = [], this._wordCounter = 0, this.spine.each((n) => {
|
|
1606
|
-
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));
|
|
1607
1589
|
}), this.q.run().then(() => (this._currentCfi && (this.currentLocation = this._currentCfi), this._locationsWords));
|
|
1608
1590
|
}
|
|
1609
|
-
processWords(t, e, i, s) {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
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);
|
|
1613
1597
|
});
|
|
1614
1598
|
}
|
|
1615
1599
|
//http://stackoverflow.com/questions/18679576/counting-words-in-string
|
|
@@ -1618,9 +1602,9 @@ class Xt {
|
|
|
1618
1602
|
`), t.split(" ").length;
|
|
1619
1603
|
}
|
|
1620
1604
|
parseWords(t, e, i, s) {
|
|
1621
|
-
const n = e.cfiBase, r = [], o = t.ownerDocument, h =
|
|
1605
|
+
const n = e.cfiBase, r = [], o = t.ownerDocument, h = w(o, "body"), l = i;
|
|
1622
1606
|
let c = s ? s.spinePos !== e.index : !0, d;
|
|
1623
|
-
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) => {
|
|
1624
1608
|
if (!c)
|
|
1625
1609
|
if (p === d)
|
|
1626
1610
|
c = !0;
|
|
@@ -1632,13 +1616,13 @@ class Xt {
|
|
|
1632
1616
|
let m, v = 0;
|
|
1633
1617
|
if (g === 0)
|
|
1634
1618
|
return !1;
|
|
1635
|
-
for (m =
|
|
1636
|
-
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)
|
|
1637
1621
|
this._wordCounter += g - v, v = g;
|
|
1638
1622
|
else {
|
|
1639
1623
|
v += m;
|
|
1640
|
-
const
|
|
1641
|
-
r.push({ cfi:
|
|
1624
|
+
const b = new y(p, n);
|
|
1625
|
+
r.push({ cfi: b.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
|
|
1642
1626
|
}
|
|
1643
1627
|
return !1;
|
|
1644
1628
|
}), r;
|
|
@@ -1747,8 +1731,8 @@ class Xt {
|
|
|
1747
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);
|
|
1748
1732
|
}
|
|
1749
1733
|
}
|
|
1750
|
-
P(
|
|
1751
|
-
class
|
|
1734
|
+
P($t.prototype);
|
|
1735
|
+
class be {
|
|
1752
1736
|
constructor(t) {
|
|
1753
1737
|
this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
|
|
1754
1738
|
}
|
|
@@ -1759,16 +1743,16 @@ class ye {
|
|
|
1759
1743
|
parse(t) {
|
|
1760
1744
|
if (!t)
|
|
1761
1745
|
throw new Error("Container File Not Found");
|
|
1762
|
-
const e =
|
|
1746
|
+
const e = w(t, "rootfile");
|
|
1763
1747
|
if (!e)
|
|
1764
1748
|
throw new Error("No RootFile Found");
|
|
1765
|
-
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;
|
|
1766
1750
|
}
|
|
1767
1751
|
destroy() {
|
|
1768
1752
|
this.packagePath = void 0, this.directory = void 0, this.encoding = void 0;
|
|
1769
1753
|
}
|
|
1770
1754
|
}
|
|
1771
|
-
class
|
|
1755
|
+
class It {
|
|
1772
1756
|
constructor(t) {
|
|
1773
1757
|
this.manifest = {}, this.navPath = "", this.ncxPath = "", this.coverPath = "", this.spineNodeIndex = 0, this.spine = [], this.metadata = {}, t && this.parse(t);
|
|
1774
1758
|
}
|
|
@@ -1780,16 +1764,16 @@ class Nt {
|
|
|
1780
1764
|
parse(t) {
|
|
1781
1765
|
if (!t)
|
|
1782
1766
|
throw new Error("Package File Not Found");
|
|
1783
|
-
const e =
|
|
1767
|
+
const e = w(t, "metadata");
|
|
1784
1768
|
if (!e)
|
|
1785
1769
|
throw new Error("No Metadata Found");
|
|
1786
|
-
const i =
|
|
1770
|
+
const i = w(t, "manifest");
|
|
1787
1771
|
if (!i)
|
|
1788
1772
|
throw new Error("No Manifest Found");
|
|
1789
|
-
const s =
|
|
1773
|
+
const s = w(t, "spine");
|
|
1790
1774
|
if (!s)
|
|
1791
1775
|
throw new Error("No Spine Found");
|
|
1792
|
-
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") ?? "", {
|
|
1793
1777
|
metadata: this.metadata,
|
|
1794
1778
|
spine: this.spine,
|
|
1795
1779
|
manifest: this.manifest,
|
|
@@ -1816,14 +1800,14 @@ class Nt {
|
|
|
1816
1800
|
* @return {object} manifest
|
|
1817
1801
|
*/
|
|
1818
1802
|
parseManifest(t) {
|
|
1819
|
-
const e = {}, i =
|
|
1803
|
+
const e = {}, i = B(t, "item");
|
|
1820
1804
|
return Array.from(i).forEach(function(n) {
|
|
1821
|
-
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") || "";
|
|
1822
1806
|
e[r] = {
|
|
1823
1807
|
href: o,
|
|
1824
1808
|
// "url" : href,
|
|
1825
1809
|
type: h,
|
|
1826
|
-
overlay:
|
|
1810
|
+
overlay: l,
|
|
1827
1811
|
properties: c.length ? c.split(" ") : [],
|
|
1828
1812
|
fallback: d
|
|
1829
1813
|
};
|
|
@@ -1837,9 +1821,9 @@ class Nt {
|
|
|
1837
1821
|
* @return {object} spine
|
|
1838
1822
|
*/
|
|
1839
1823
|
parseSpine(t, e) {
|
|
1840
|
-
const i = [], s =
|
|
1824
|
+
const i = [], s = B(t, "itemref");
|
|
1841
1825
|
return Array.from(s).forEach(function(r, o) {
|
|
1842
|
-
const h = r.getAttribute("idref"),
|
|
1826
|
+
const h = r.getAttribute("idref"), l = r.getAttribute("properties") || "", c = l.length ? l.split(" ") : [], d = {
|
|
1843
1827
|
id: r.getAttribute("id") ?? void 0,
|
|
1844
1828
|
idref: h,
|
|
1845
1829
|
linear: r.getAttribute("linear") || "yes",
|
|
@@ -1896,7 +1880,7 @@ class Nt {
|
|
|
1896
1880
|
* @return {string} href
|
|
1897
1881
|
*/
|
|
1898
1882
|
findCoverPath(t) {
|
|
1899
|
-
const e =
|
|
1883
|
+
const e = w(t, "package");
|
|
1900
1884
|
e == null || e.getAttribute("version");
|
|
1901
1885
|
const i = j(t, "item", { properties: "cover-image" });
|
|
1902
1886
|
if (i) return i.getAttribute("href") ?? "";
|
|
@@ -1956,7 +1940,7 @@ class Nt {
|
|
|
1956
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;
|
|
1957
1941
|
}
|
|
1958
1942
|
}
|
|
1959
|
-
class
|
|
1943
|
+
class ht {
|
|
1960
1944
|
constructor(t) {
|
|
1961
1945
|
this.toc = [], this.tocByHref = {}, this.tocById = {}, this.landmarks = [], this.landmarksByType = {}, this.length = 0, t && this.parse(t);
|
|
1962
1946
|
}
|
|
@@ -1967,7 +1951,7 @@ class ct {
|
|
|
1967
1951
|
parse(t) {
|
|
1968
1952
|
const e = t.nodeType;
|
|
1969
1953
|
let i, s;
|
|
1970
|
-
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);
|
|
1971
1955
|
}
|
|
1972
1956
|
/**
|
|
1973
1957
|
* Unpack navigation items
|
|
@@ -2027,7 +2011,7 @@ class ct {
|
|
|
2027
2011
|
* @return {array} navigation list
|
|
2028
2012
|
*/
|
|
2029
2013
|
parseNav(t) {
|
|
2030
|
-
const e =
|
|
2014
|
+
const e = it(t, "nav", "toc");
|
|
2031
2015
|
let i = [];
|
|
2032
2016
|
if (!e) return i;
|
|
2033
2017
|
const s = F(e, "ol", !0);
|
|
@@ -2079,7 +2063,7 @@ class ct {
|
|
|
2079
2063
|
* @return {array} landmarks list
|
|
2080
2064
|
*/
|
|
2081
2065
|
parseLandmarks(t) {
|
|
2082
|
-
const e =
|
|
2066
|
+
const e = it(t, "nav", "landmarks"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
2083
2067
|
let n;
|
|
2084
2068
|
const r = [];
|
|
2085
2069
|
let o;
|
|
@@ -2112,7 +2096,7 @@ class ct {
|
|
|
2112
2096
|
* @return {array} navigation list
|
|
2113
2097
|
*/
|
|
2114
2098
|
parseNcx(t) {
|
|
2115
|
-
const e =
|
|
2099
|
+
const e = B(t, "navPoint"), i = e.length;
|
|
2116
2100
|
let s;
|
|
2117
2101
|
const n = {}, r = [];
|
|
2118
2102
|
let o, h;
|
|
@@ -2128,14 +2112,14 @@ class ct {
|
|
|
2128
2112
|
* @return {object} ncxItem
|
|
2129
2113
|
*/
|
|
2130
2114
|
ncxItem(t) {
|
|
2131
|
-
const e = t.getAttribute("id") || "", i =
|
|
2132
|
-
let
|
|
2133
|
-
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), {
|
|
2134
2118
|
id: e,
|
|
2135
2119
|
href: s,
|
|
2136
2120
|
label: r,
|
|
2137
2121
|
subitems: o,
|
|
2138
|
-
parent:
|
|
2122
|
+
parent: l
|
|
2139
2123
|
};
|
|
2140
2124
|
}
|
|
2141
2125
|
/**
|
|
@@ -2158,7 +2142,7 @@ class ct {
|
|
|
2158
2142
|
return this.toc.forEach(t);
|
|
2159
2143
|
}
|
|
2160
2144
|
}
|
|
2161
|
-
const
|
|
2145
|
+
const at = {
|
|
2162
2146
|
application: {
|
|
2163
2147
|
ecmascript: ["es", "ecma"],
|
|
2164
2148
|
javascript: "js",
|
|
@@ -2292,27 +2276,27 @@ const dt = {
|
|
|
2292
2276
|
"x-ms-vob": "vob",
|
|
2293
2277
|
"x-smv": "smv"
|
|
2294
2278
|
}
|
|
2295
|
-
},
|
|
2296
|
-
let
|
|
2279
|
+
}, xe = (function() {
|
|
2280
|
+
let a, t, e, i;
|
|
2297
2281
|
const s = {};
|
|
2298
|
-
for (
|
|
2299
|
-
if (
|
|
2300
|
-
const n =
|
|
2282
|
+
for (a in at)
|
|
2283
|
+
if (at.hasOwnProperty(a)) {
|
|
2284
|
+
const n = at[a];
|
|
2301
2285
|
for (t in n)
|
|
2302
2286
|
if (n.hasOwnProperty(t))
|
|
2303
2287
|
if (e = n[t], typeof e == "string")
|
|
2304
|
-
s[e] =
|
|
2288
|
+
s[e] = a + "/" + t;
|
|
2305
2289
|
else
|
|
2306
2290
|
for (i = 0; i < e.length; i++)
|
|
2307
|
-
s[e[i]] =
|
|
2291
|
+
s[e[i]] = a + "/" + t;
|
|
2308
2292
|
}
|
|
2309
2293
|
return s;
|
|
2310
|
-
})(),
|
|
2311
|
-
function
|
|
2312
|
-
return
|
|
2294
|
+
})(), Ee = "text/plain";
|
|
2295
|
+
function Se(a) {
|
|
2296
|
+
return a && xe[a.split(".").pop().toLowerCase()] || Ee;
|
|
2313
2297
|
}
|
|
2314
|
-
const
|
|
2315
|
-
class
|
|
2298
|
+
const G = { lookup: Se };
|
|
2299
|
+
class _e {
|
|
2316
2300
|
constructor(t, e) {
|
|
2317
2301
|
this.settings = {
|
|
2318
2302
|
replacements: e && e.replacements || "base64",
|
|
@@ -2358,8 +2342,8 @@ class Ee {
|
|
|
2358
2342
|
* @return {Promise<string>} Promise resolves with url string
|
|
2359
2343
|
*/
|
|
2360
2344
|
createUrl(t) {
|
|
2361
|
-
const e = new
|
|
2362
|
-
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));
|
|
2363
2347
|
}
|
|
2364
2348
|
/**
|
|
2365
2349
|
* Create blob urls for all the assets
|
|
@@ -2403,7 +2387,7 @@ class Ee {
|
|
|
2403
2387
|
*/
|
|
2404
2388
|
createCssFile(t) {
|
|
2405
2389
|
let e;
|
|
2406
|
-
if (
|
|
2390
|
+
if (D.isAbsolute(t))
|
|
2407
2391
|
return new Promise(function(r) {
|
|
2408
2392
|
r();
|
|
2409
2393
|
});
|
|
@@ -2412,11 +2396,11 @@ class Ee {
|
|
|
2412
2396
|
this.settings.archive ? s = this.settings.archive.getText(i) : s = this.settings.request(i, "text");
|
|
2413
2397
|
const n = this.urls.map((r) => {
|
|
2414
2398
|
const o = this.settings.resolver(r);
|
|
2415
|
-
return new
|
|
2399
|
+
return new O(i).relative(o);
|
|
2416
2400
|
});
|
|
2417
2401
|
return s ? s.then((r) => {
|
|
2418
|
-
const o =
|
|
2419
|
-
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;
|
|
2420
2404
|
}, (r) => new Promise(function(o) {
|
|
2421
2405
|
o();
|
|
2422
2406
|
})) : new Promise(function(r) {
|
|
@@ -2432,7 +2416,7 @@ class Ee {
|
|
|
2432
2416
|
relativeTo(t, e) {
|
|
2433
2417
|
return e = e || this.settings.resolver, this.urls.map((i) => {
|
|
2434
2418
|
const s = e(i);
|
|
2435
|
-
return new
|
|
2419
|
+
return new O(t).relative(s);
|
|
2436
2420
|
});
|
|
2437
2421
|
}
|
|
2438
2422
|
/**
|
|
@@ -2456,15 +2440,15 @@ class Ee {
|
|
|
2456
2440
|
*/
|
|
2457
2441
|
substitute(t, e) {
|
|
2458
2442
|
let i;
|
|
2459
|
-
return e ? i = this.relativeTo(e) : i = this.urls,
|
|
2443
|
+
return e ? i = this.relativeTo(e) : i = this.urls, At(t, i, this.replacementUrls);
|
|
2460
2444
|
}
|
|
2461
2445
|
destroy() {
|
|
2462
2446
|
this.replacementUrls && this.replacementUrls.forEach((t) => {
|
|
2463
|
-
t &&
|
|
2447
|
+
t && Tt(t);
|
|
2464
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;
|
|
2465
2449
|
}
|
|
2466
2450
|
}
|
|
2467
|
-
class
|
|
2451
|
+
class lt {
|
|
2468
2452
|
constructor(t) {
|
|
2469
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);
|
|
2470
2454
|
}
|
|
@@ -2473,7 +2457,7 @@ class ut {
|
|
|
2473
2457
|
* @param {document} xml
|
|
2474
2458
|
*/
|
|
2475
2459
|
parse(t) {
|
|
2476
|
-
const e =
|
|
2460
|
+
const e = w(t, "html"), i = w(t, "ncx");
|
|
2477
2461
|
return e ? this.parseNav(t) : i ? this.parseNcx(t) : [];
|
|
2478
2462
|
}
|
|
2479
2463
|
/**
|
|
@@ -2483,7 +2467,7 @@ class ut {
|
|
|
2483
2467
|
* @return {PageList.item[]} list
|
|
2484
2468
|
*/
|
|
2485
2469
|
parseNav(t) {
|
|
2486
|
-
const e =
|
|
2470
|
+
const e = it(t, "nav", "page-list"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
2487
2471
|
let n;
|
|
2488
2472
|
const r = [];
|
|
2489
2473
|
let o;
|
|
@@ -2495,9 +2479,9 @@ class ut {
|
|
|
2495
2479
|
parseNcx(t) {
|
|
2496
2480
|
const e = [];
|
|
2497
2481
|
let i = 0, s, n = 0;
|
|
2498
|
-
const r =
|
|
2482
|
+
const r = w(t, "pageList");
|
|
2499
2483
|
if (!r) return e;
|
|
2500
|
-
const o =
|
|
2484
|
+
const o = B(r, "pageTarget");
|
|
2501
2485
|
if (n = o.length, !o || o.length === 0)
|
|
2502
2486
|
return e;
|
|
2503
2487
|
for (i = 0; i < n; ++i)
|
|
@@ -2505,7 +2489,7 @@ class ut {
|
|
|
2505
2489
|
return e;
|
|
2506
2490
|
}
|
|
2507
2491
|
ncxItem(t) {
|
|
2508
|
-
const e =
|
|
2492
|
+
const e = w(t, "navLabel"), s = w(e, "text").textContent ?? "", r = w(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
|
|
2509
2493
|
return {
|
|
2510
2494
|
href: r,
|
|
2511
2495
|
page: o
|
|
@@ -2518,10 +2502,10 @@ class ut {
|
|
|
2518
2502
|
* @return {object} pageListItem
|
|
2519
2503
|
*/
|
|
2520
2504
|
item(t) {
|
|
2521
|
-
const e =
|
|
2522
|
-
let o, h,
|
|
2523
|
-
return r
|
|
2524
|
-
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,
|
|
2525
2509
|
href: i,
|
|
2526
2510
|
packageUrl: h,
|
|
2527
2511
|
page: n
|
|
@@ -2550,7 +2534,7 @@ class ut {
|
|
|
2550
2534
|
if (this.locations.length === 0)
|
|
2551
2535
|
return -1;
|
|
2552
2536
|
let i = Q(t, this.locations, this.epubcfi.compare);
|
|
2553
|
-
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;
|
|
2554
2538
|
}
|
|
2555
2539
|
/**
|
|
2556
2540
|
* Get an EpubCFI from a Page List Item
|
|
@@ -2561,7 +2545,7 @@ class ut {
|
|
|
2561
2545
|
let e = -1;
|
|
2562
2546
|
typeof t != "number" && (t = parseInt(t));
|
|
2563
2547
|
const i = this.pages.indexOf(t);
|
|
2564
|
-
return i
|
|
2548
|
+
return i !== -1 && i < this.locations.length && (e = this.locations[i]), e;
|
|
2565
2549
|
}
|
|
2566
2550
|
/**
|
|
2567
2551
|
* Get a Page from Book percentage
|
|
@@ -2596,7 +2580,7 @@ class ut {
|
|
|
2596
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;
|
|
2597
2581
|
}
|
|
2598
2582
|
}
|
|
2599
|
-
class
|
|
2583
|
+
class Kt {
|
|
2600
2584
|
constructor(t) {
|
|
2601
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 = {
|
|
2602
2586
|
name: this.name,
|
|
@@ -2638,16 +2622,16 @@ class Gt {
|
|
|
2638
2622
|
calculate(t, e, i) {
|
|
2639
2623
|
let s = 1, n = i || 0, r = t;
|
|
2640
2624
|
const o = e, h = Math.floor(r / 12);
|
|
2641
|
-
let
|
|
2642
|
-
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 ? (
|
|
2643
|
-
const d =
|
|
2644
|
-
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({
|
|
2645
2629
|
width: r,
|
|
2646
2630
|
height: o,
|
|
2647
2631
|
spreadWidth: d,
|
|
2648
2632
|
pageWidth: c,
|
|
2649
2633
|
delta: u,
|
|
2650
|
-
columnWidth:
|
|
2634
|
+
columnWidth: l,
|
|
2651
2635
|
gap: n,
|
|
2652
2636
|
divisor: s
|
|
2653
2637
|
});
|
|
@@ -2689,8 +2673,8 @@ class Gt {
|
|
|
2689
2673
|
}
|
|
2690
2674
|
}
|
|
2691
2675
|
}
|
|
2692
|
-
P(
|
|
2693
|
-
class
|
|
2676
|
+
P(Kt.prototype);
|
|
2677
|
+
class Ce {
|
|
2694
2678
|
constructor(t) {
|
|
2695
2679
|
this.rendition = t, this._themes = {
|
|
2696
2680
|
default: {
|
|
@@ -2749,7 +2733,7 @@ class Se {
|
|
|
2749
2733
|
* @param {string} css
|
|
2750
2734
|
*/
|
|
2751
2735
|
registerCss(t, e) {
|
|
2752
|
-
this._themes[t] = { serialized: e }, (this._injected[t] || t
|
|
2736
|
+
this._themes[t] = { serialized: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2753
2737
|
}
|
|
2754
2738
|
/**
|
|
2755
2739
|
* Register a url
|
|
@@ -2757,8 +2741,8 @@ class Se {
|
|
|
2757
2741
|
* @param {string} input
|
|
2758
2742
|
*/
|
|
2759
2743
|
registerUrl(t, e) {
|
|
2760
|
-
const i = new
|
|
2761
|
-
this._themes[t] = { url: i.toString() }, (this._injected[t] || t
|
|
2744
|
+
const i = new R(e);
|
|
2745
|
+
this._themes[t] = { url: i.toString() }, (this._injected[t] || t === "default") && this.update(t);
|
|
2762
2746
|
}
|
|
2763
2747
|
/**
|
|
2764
2748
|
* Register rule
|
|
@@ -2766,7 +2750,7 @@ class Se {
|
|
|
2766
2750
|
* @param {object} rules
|
|
2767
2751
|
*/
|
|
2768
2752
|
registerRules(t, e) {
|
|
2769
|
-
this._themes[t] = { rules: e }, (this._injected[t] || t
|
|
2753
|
+
this._themes[t] = { rules: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2770
2754
|
}
|
|
2771
2755
|
/**
|
|
2772
2756
|
* Select a theme
|
|
@@ -2796,7 +2780,7 @@ class Se {
|
|
|
2796
2780
|
let s;
|
|
2797
2781
|
for (const n in i)
|
|
2798
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));
|
|
2799
|
-
this._current
|
|
2783
|
+
this._current !== "default" && t.addClass(this._current);
|
|
2800
2784
|
}
|
|
2801
2785
|
/**
|
|
2802
2786
|
* Add Theme to contents
|
|
@@ -2855,7 +2839,7 @@ class Se {
|
|
|
2855
2839
|
this.rendition = void 0, this._themes = void 0, this._overrides = void 0, this._current = void 0, this._injected = void 0;
|
|
2856
2840
|
}
|
|
2857
2841
|
}
|
|
2858
|
-
class
|
|
2842
|
+
class Te {
|
|
2859
2843
|
constructor(t) {
|
|
2860
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));
|
|
2861
2845
|
}
|
|
@@ -2870,16 +2854,16 @@ class _e {
|
|
|
2870
2854
|
* @returns {Annotation} annotation
|
|
2871
2855
|
*/
|
|
2872
2856
|
add(t, e, i, s, n, r) {
|
|
2873
|
-
const o = encodeURI(e + t),
|
|
2857
|
+
const o = encodeURI(e + t), l = new y(e).spinePos, c = new Zt({
|
|
2874
2858
|
type: t,
|
|
2875
2859
|
cfiRange: e,
|
|
2876
2860
|
data: i,
|
|
2877
|
-
sectionIndex:
|
|
2861
|
+
sectionIndex: l,
|
|
2878
2862
|
cb: s,
|
|
2879
2863
|
className: n,
|
|
2880
2864
|
styles: r
|
|
2881
2865
|
});
|
|
2882
|
-
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) => {
|
|
2883
2867
|
c.sectionIndex === u.index && c.attach(u);
|
|
2884
2868
|
}), c;
|
|
2885
2869
|
}
|
|
@@ -2989,7 +2973,7 @@ class _e {
|
|
|
2989
2973
|
hide() {
|
|
2990
2974
|
}
|
|
2991
2975
|
}
|
|
2992
|
-
class
|
|
2976
|
+
class Zt {
|
|
2993
2977
|
constructor({
|
|
2994
2978
|
type: t,
|
|
2995
2979
|
cfiRange: e,
|
|
@@ -3014,8 +2998,8 @@ class Yt {
|
|
|
3014
2998
|
*/
|
|
3015
2999
|
attach(t) {
|
|
3016
3000
|
const { cfiRange: e, data: i, type: s, mark: n, cb: r, className: o, styles: h } = this;
|
|
3017
|
-
let
|
|
3018
|
-
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;
|
|
3019
3003
|
}
|
|
3020
3004
|
/**
|
|
3021
3005
|
* Remove from a view
|
|
@@ -3032,8 +3016,8 @@ class Yt {
|
|
|
3032
3016
|
text() {
|
|
3033
3017
|
}
|
|
3034
3018
|
}
|
|
3035
|
-
P(
|
|
3036
|
-
class
|
|
3019
|
+
P(Zt.prototype);
|
|
3020
|
+
class wt {
|
|
3037
3021
|
constructor(t, e, i, s = !1) {
|
|
3038
3022
|
this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
|
|
3039
3023
|
}
|
|
@@ -3060,8 +3044,8 @@ class bt {
|
|
|
3060
3044
|
end: this.findEnd(n, i, s)
|
|
3061
3045
|
});
|
|
3062
3046
|
if (this._dev === !0) {
|
|
3063
|
-
const o = t.document, h = new y(r.start).toRange(o),
|
|
3064
|
-
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);
|
|
3065
3049
|
}
|
|
3066
3050
|
return r;
|
|
3067
3051
|
}
|
|
@@ -3085,11 +3069,11 @@ class bt {
|
|
|
3085
3069
|
}
|
|
3086
3070
|
findRanges(t) {
|
|
3087
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;
|
|
3088
|
-
let h,
|
|
3072
|
+
let h, l;
|
|
3089
3073
|
for (let c = 0; c < n; c++)
|
|
3090
|
-
h = (r + o) * c,
|
|
3091
|
-
start: this.findStart(t.document.body, h,
|
|
3092
|
-
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)
|
|
3093
3077
|
});
|
|
3094
3078
|
return e;
|
|
3095
3079
|
}
|
|
@@ -3106,18 +3090,18 @@ class bt {
|
|
|
3106
3090
|
let n, r, o = t;
|
|
3107
3091
|
for (; s.length; )
|
|
3108
3092
|
if (n = s.shift(), r = this.walk(n, (h) => {
|
|
3109
|
-
let
|
|
3110
|
-
const p =
|
|
3093
|
+
let l, c, d, u;
|
|
3094
|
+
const p = ft(h);
|
|
3111
3095
|
if (this.horizontal && this.direction === "ltr") {
|
|
3112
|
-
if (
|
|
3096
|
+
if (l = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, l >= e && l <= i)
|
|
3113
3097
|
return h;
|
|
3114
3098
|
if (c > e)
|
|
3115
3099
|
return h;
|
|
3116
3100
|
o = h, s.push(h);
|
|
3117
3101
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3118
|
-
if (
|
|
3102
|
+
if (l = p.left, c = p.right, c <= i && c >= e)
|
|
3119
3103
|
return h;
|
|
3120
|
-
if (
|
|
3104
|
+
if (l < i)
|
|
3121
3105
|
return h;
|
|
3122
3106
|
o = h, s.push(h);
|
|
3123
3107
|
} else {
|
|
@@ -3144,18 +3128,18 @@ class bt {
|
|
|
3144
3128
|
let n, r = t, o;
|
|
3145
3129
|
for (; s.length; )
|
|
3146
3130
|
if (n = s.shift(), o = this.walk(n, (h) => {
|
|
3147
|
-
let
|
|
3148
|
-
const p =
|
|
3131
|
+
let l, c, d, u;
|
|
3132
|
+
const p = ft(h);
|
|
3149
3133
|
if (this.horizontal && this.direction === "ltr") {
|
|
3150
|
-
if (
|
|
3134
|
+
if (l = Math.round(p.left), c = Math.round(p.right), l > i && r)
|
|
3151
3135
|
return r;
|
|
3152
3136
|
if (c > i)
|
|
3153
3137
|
return h;
|
|
3154
3138
|
r = h, s.push(h);
|
|
3155
3139
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3156
|
-
if (
|
|
3140
|
+
if (l = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
|
|
3157
3141
|
return r;
|
|
3158
|
-
if (
|
|
3142
|
+
if (l < e)
|
|
3159
3143
|
return h;
|
|
3160
3144
|
r = h, s.push(h);
|
|
3161
3145
|
} else {
|
|
@@ -3179,13 +3163,13 @@ class bt {
|
|
|
3179
3163
|
*/
|
|
3180
3164
|
findTextStartRange(t, e, i) {
|
|
3181
3165
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3182
|
-
let n, r, o, h,
|
|
3166
|
+
let n, r, o, h, l;
|
|
3183
3167
|
for (let c = 0; c < s.length; c++)
|
|
3184
3168
|
if (n = s[c], r = n.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3185
3169
|
if (o = r.left, o >= e)
|
|
3186
3170
|
return n;
|
|
3187
3171
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3188
|
-
if (
|
|
3172
|
+
if (l = r.right, l <= i)
|
|
3189
3173
|
return n;
|
|
3190
3174
|
} else if (h = r.top, h >= e)
|
|
3191
3175
|
return n;
|
|
@@ -3201,15 +3185,15 @@ class bt {
|
|
|
3201
3185
|
*/
|
|
3202
3186
|
findTextEndRange(t, e, i) {
|
|
3203
3187
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3204
|
-
let n, r, o, h,
|
|
3188
|
+
let n, r, o, h, l, c, d;
|
|
3205
3189
|
for (let u = 0; u < s.length; u++) {
|
|
3206
3190
|
if (r = s[u], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3207
|
-
if (h = o.left,
|
|
3191
|
+
if (h = o.left, l = o.right, h > i && n)
|
|
3208
3192
|
return n;
|
|
3209
|
-
if (
|
|
3193
|
+
if (l > i)
|
|
3210
3194
|
return r;
|
|
3211
3195
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3212
|
-
if (h = o.left,
|
|
3196
|
+
if (h = o.left, l = o.right, l < e && n)
|
|
3213
3197
|
return n;
|
|
3214
3198
|
if (h < e)
|
|
3215
3199
|
return r;
|
|
@@ -3234,11 +3218,11 @@ class bt {
|
|
|
3234
3218
|
const i = [], n = (t.textContent || "").trim();
|
|
3235
3219
|
let r;
|
|
3236
3220
|
const o = t.ownerDocument, h = e || " ";
|
|
3237
|
-
let
|
|
3238
|
-
if (
|
|
3221
|
+
let l = n.indexOf(h);
|
|
3222
|
+
if (l === -1 || t.nodeType !== Node.TEXT_NODE)
|
|
3239
3223
|
return r = o.createRange(), r.selectNodeContents(t), [r];
|
|
3240
|
-
for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t,
|
|
3241
|
-
|
|
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));
|
|
3242
3226
|
return r && (r.setEnd(t, n.length), i.push(r)), i;
|
|
3243
3227
|
}
|
|
3244
3228
|
/**
|
|
@@ -3273,19 +3257,19 @@ class bt {
|
|
|
3273
3257
|
return t && (this.horizontal = t === "horizontal"), this.horizontal;
|
|
3274
3258
|
}
|
|
3275
3259
|
}
|
|
3276
|
-
const
|
|
3277
|
-
class
|
|
3260
|
+
const ke = typeof navigator < "u", Pt = ke && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), Ne = 1;
|
|
3261
|
+
class Nt {
|
|
3278
3262
|
constructor(t, e, i, s) {
|
|
3279
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 = {
|
|
3280
3264
|
width: 0,
|
|
3281
3265
|
height: 0
|
|
3282
|
-
}, 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();
|
|
3283
3267
|
}
|
|
3284
3268
|
/**
|
|
3285
3269
|
* Get DOM events that are listened for and passed along
|
|
3286
3270
|
*/
|
|
3287
3271
|
static get listenedEvents() {
|
|
3288
|
-
return
|
|
3272
|
+
return Z;
|
|
3289
3273
|
}
|
|
3290
3274
|
/**
|
|
3291
3275
|
* Get or Set width
|
|
@@ -3294,7 +3278,7 @@ class Tt {
|
|
|
3294
3278
|
*/
|
|
3295
3279
|
width(t) {
|
|
3296
3280
|
const e = this.content;
|
|
3297
|
-
return t &&
|
|
3281
|
+
return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3298
3282
|
}
|
|
3299
3283
|
/**
|
|
3300
3284
|
* Get or Set height
|
|
@@ -3303,7 +3287,7 @@ class Tt {
|
|
|
3303
3287
|
*/
|
|
3304
3288
|
height(t) {
|
|
3305
3289
|
const e = this.content;
|
|
3306
|
-
return t &&
|
|
3290
|
+
return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3307
3291
|
}
|
|
3308
3292
|
/**
|
|
3309
3293
|
* Get or Set width of the contents
|
|
@@ -3312,7 +3296,7 @@ class Tt {
|
|
|
3312
3296
|
*/
|
|
3313
3297
|
contentWidth(t) {
|
|
3314
3298
|
const e = this.content || this.document.body;
|
|
3315
|
-
return t &&
|
|
3299
|
+
return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3316
3300
|
}
|
|
3317
3301
|
/**
|
|
3318
3302
|
* Get or Set height of the contents
|
|
@@ -3321,7 +3305,7 @@ class Tt {
|
|
|
3321
3305
|
*/
|
|
3322
3306
|
contentHeight(t) {
|
|
3323
3307
|
const e = this.content || this.document.body;
|
|
3324
|
-
return t &&
|
|
3308
|
+
return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3325
3309
|
}
|
|
3326
3310
|
/**
|
|
3327
3311
|
* Get the width of the text using Range
|
|
@@ -3329,7 +3313,7 @@ class Tt {
|
|
|
3329
3313
|
*/
|
|
3330
3314
|
textWidth() {
|
|
3331
3315
|
let t;
|
|
3332
|
-
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);
|
|
3333
3317
|
return e.selectNodeContents(i), t = e.getBoundingClientRect().width, s && s.width && (t += s.width), Math.round(t);
|
|
3334
3318
|
}
|
|
3335
3319
|
/**
|
|
@@ -3420,10 +3404,10 @@ class Tt {
|
|
|
3420
3404
|
}, s = [];
|
|
3421
3405
|
let n = {};
|
|
3422
3406
|
if (e && e.hasAttribute("content")) {
|
|
3423
|
-
const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/),
|
|
3424
|
-
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]);
|
|
3425
3409
|
}
|
|
3426
|
-
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;
|
|
3427
3411
|
}
|
|
3428
3412
|
/**
|
|
3429
3413
|
* Event emitter for when the contents has expanded
|
|
@@ -3437,17 +3421,17 @@ class Tt {
|
|
|
3437
3421
|
* @private
|
|
3438
3422
|
*/
|
|
3439
3423
|
listeners() {
|
|
3440
|
-
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();
|
|
3441
3425
|
}
|
|
3442
3426
|
/**
|
|
3443
3427
|
* Remove DOM listeners
|
|
3444
3428
|
* @private
|
|
3445
3429
|
*/
|
|
3446
3430
|
removeListeners() {
|
|
3447
|
-
this.removeEventListeners(), this.removeSelectionListeners(), this.
|
|
3431
|
+
this.removeEventListeners(), this.removeSelectionListeners(), this._resizeCheck && (this.document.removeEventListener("transitionend", this._resizeCheck), this._resizeCheck = void 0);
|
|
3448
3432
|
for (const { mql: e, handler: i } of this._mediaQueryHandlers)
|
|
3449
3433
|
e.removeEventListener("change", i);
|
|
3450
|
-
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect()
|
|
3434
|
+
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect();
|
|
3451
3435
|
const t = this.document.querySelectorAll("img");
|
|
3452
3436
|
for (let e = 0; e < t.length; e++)
|
|
3453
3437
|
t[e].onload = null;
|
|
@@ -3459,27 +3443,11 @@ class Tt {
|
|
|
3459
3443
|
*/
|
|
3460
3444
|
resizeCheck() {
|
|
3461
3445
|
const t = this.textWidth(), e = this.textHeight();
|
|
3462
|
-
(t
|
|
3446
|
+
(t !== this._size.width || e !== this._size.height) && (this._size = {
|
|
3463
3447
|
width: t,
|
|
3464
3448
|
height: e
|
|
3465
3449
|
}, this.onResize && this.onResize(this._size), this.emit(f.CONTENTS.RESIZE, this._size));
|
|
3466
3450
|
}
|
|
3467
|
-
/**
|
|
3468
|
-
* Poll for resize detection
|
|
3469
|
-
* @private
|
|
3470
|
-
*/
|
|
3471
|
-
resizeListeners() {
|
|
3472
|
-
clearTimeout(this.expanding), requestAnimationFrame(this.resizeCheck.bind(this)), this.expanding = setTimeout(this.resizeListeners.bind(this), 350);
|
|
3473
|
-
}
|
|
3474
|
-
/**
|
|
3475
|
-
* Listen for visibility of tab to change
|
|
3476
|
-
* @private
|
|
3477
|
-
*/
|
|
3478
|
-
visibilityListeners() {
|
|
3479
|
-
this._onVisibilityChange = () => {
|
|
3480
|
-
document.visibilityState === "visible" && this.active === !1 ? (this.active = !0, this.resizeListeners()) : (this.active = !1, clearTimeout(this.expanding));
|
|
3481
|
-
}, document.addEventListener("visibilitychange", this._onVisibilityChange);
|
|
3482
|
-
}
|
|
3483
3451
|
/**
|
|
3484
3452
|
* Use css transitions to detect resize
|
|
3485
3453
|
* @private
|
|
@@ -3495,7 +3463,7 @@ class Tt {
|
|
|
3495
3463
|
*/
|
|
3496
3464
|
mediaQueryListeners() {
|
|
3497
3465
|
const t = this.document.styleSheets, e = (i) => {
|
|
3498
|
-
i.matches && !this._expanding && setTimeout(this.expand
|
|
3466
|
+
i.matches && !this._expanding && setTimeout(() => this.expand(), 0);
|
|
3499
3467
|
};
|
|
3500
3468
|
for (let i = 0; i < t.length; i += 1) {
|
|
3501
3469
|
let s;
|
|
@@ -3572,19 +3540,19 @@ class Tt {
|
|
|
3572
3540
|
const n = new y(t).toRange(this.document, e);
|
|
3573
3541
|
if (n) {
|
|
3574
3542
|
try {
|
|
3575
|
-
if (!n.endContainer || n.startContainer
|
|
3543
|
+
if (!n.endContainer || n.startContainer === n.endContainer && n.startOffset === n.endOffset) {
|
|
3576
3544
|
let r = (n.startContainer.textContent ?? "").indexOf(" ", n.startOffset);
|
|
3577
|
-
r
|
|
3545
|
+
r === -1 && (r = (n.startContainer.textContent ?? "").length), n.setEnd(n.startContainer, r);
|
|
3578
3546
|
}
|
|
3579
3547
|
} catch (r) {
|
|
3580
3548
|
console.error("setting end offset to start container length failed", r);
|
|
3581
3549
|
}
|
|
3582
3550
|
if (n.startContainer.nodeType === Node.ELEMENT_NODE)
|
|
3583
3551
|
i = n.startContainer.getBoundingClientRect(), s.left = i.left, s.top = i.top;
|
|
3584
|
-
else if (
|
|
3552
|
+
else if (Pt) {
|
|
3585
3553
|
const r = n.startContainer, o = new Range();
|
|
3586
3554
|
try {
|
|
3587
|
-
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();
|
|
3588
3556
|
} catch (h) {
|
|
3589
3557
|
console.error(h, h instanceof Error ? h.stack : void 0);
|
|
3590
3558
|
}
|
|
@@ -3594,7 +3562,7 @@ class Tt {
|
|
|
3594
3562
|
} else if (typeof t == "string" && t.indexOf("#") > -1) {
|
|
3595
3563
|
const n = t.substring(t.indexOf("#") + 1), r = this.document.getElementById(n);
|
|
3596
3564
|
if (r)
|
|
3597
|
-
if (
|
|
3565
|
+
if (Pt) {
|
|
3598
3566
|
const o = new Range();
|
|
3599
3567
|
o.selectNode(r), i = o.getBoundingClientRect();
|
|
3600
3568
|
} else
|
|
@@ -3620,7 +3588,7 @@ class Tt {
|
|
|
3620
3588
|
s = this.document.createElement("link"), s.type = "text/css", s.rel = "stylesheet", s.href = t, s.onload = () => {
|
|
3621
3589
|
n || (n = !0, setTimeout(() => {
|
|
3622
3590
|
e(!0);
|
|
3623
|
-
},
|
|
3591
|
+
}, 0));
|
|
3624
3592
|
}, this.document.head.appendChild(s);
|
|
3625
3593
|
});
|
|
3626
3594
|
}
|
|
@@ -3651,15 +3619,15 @@ class Tt {
|
|
|
3651
3619
|
const i = this._getStylesheetNode(e).sheet;
|
|
3652
3620
|
if (Array.isArray(t))
|
|
3653
3621
|
for (let n = 0, r = t.length; n < r; n++) {
|
|
3654
|
-
let o = 1, h = t[n],
|
|
3622
|
+
let o = 1, h = t[n], l = "";
|
|
3655
3623
|
const c = t[n][0];
|
|
3656
3624
|
Array.isArray((s = h[1]) == null ? void 0 : s[0]) && (h = h[1], o = 0);
|
|
3657
3625
|
for (let d = h.length; o < d; o++) {
|
|
3658
3626
|
const u = h[o];
|
|
3659
|
-
|
|
3627
|
+
l += u[0] + ":" + u[1] + (u[2] ? " !important" : "") + `;
|
|
3660
3628
|
`;
|
|
3661
3629
|
}
|
|
3662
|
-
i.insertRule(c + "{" +
|
|
3630
|
+
i.insertRule(c + "{" + l + "}", i.cssRules.length);
|
|
3663
3631
|
}
|
|
3664
3632
|
else
|
|
3665
3633
|
Object.keys(t).forEach((r) => {
|
|
@@ -3670,8 +3638,8 @@ class Tt {
|
|
|
3670
3638
|
i.insertRule(`${r}{${c}}`, i.cssRules.length);
|
|
3671
3639
|
});
|
|
3672
3640
|
else {
|
|
3673
|
-
const
|
|
3674
|
-
i.insertRule(`${r}{${
|
|
3641
|
+
const l = Object.keys(o).map((c) => `${c}:${o[c]}`).join(";");
|
|
3642
|
+
i.insertRule(`${r}{${l}}`, i.cssRules.length);
|
|
3675
3643
|
}
|
|
3676
3644
|
});
|
|
3677
3645
|
}
|
|
@@ -3691,7 +3659,7 @@ class Tt {
|
|
|
3691
3659
|
n.type = "text/javascript", n.async = !0, n.src = t, n.onload = () => {
|
|
3692
3660
|
s || (s = !0, setTimeout(() => {
|
|
3693
3661
|
e(!0);
|
|
3694
|
-
},
|
|
3662
|
+
}, 0));
|
|
3695
3663
|
}, this.document.head.appendChild(n);
|
|
3696
3664
|
});
|
|
3697
3665
|
}
|
|
@@ -3718,7 +3686,7 @@ class Tt {
|
|
|
3718
3686
|
* @private
|
|
3719
3687
|
*/
|
|
3720
3688
|
addEventListeners() {
|
|
3721
|
-
this.document && (this._triggerEvent = this.triggerEvent.bind(this),
|
|
3689
|
+
this.document && (this._triggerEvent = this.triggerEvent.bind(this), Z.forEach((t) => {
|
|
3722
3690
|
this.document.addEventListener(t, this._triggerEvent, { passive: !0 });
|
|
3723
3691
|
}));
|
|
3724
3692
|
}
|
|
@@ -3727,7 +3695,7 @@ class Tt {
|
|
|
3727
3695
|
* @private
|
|
3728
3696
|
*/
|
|
3729
3697
|
removeEventListeners() {
|
|
3730
|
-
this.document && (
|
|
3698
|
+
this.document && (Z.forEach((t) => {
|
|
3731
3699
|
this.document.removeEventListener(t, this._triggerEvent);
|
|
3732
3700
|
}), this._triggerEvent = void 0);
|
|
3733
3701
|
}
|
|
@@ -3819,7 +3787,7 @@ class Tt {
|
|
|
3819
3787
|
* @param {number} gap
|
|
3820
3788
|
*/
|
|
3821
3789
|
columns(t, e, i, s, n) {
|
|
3822
|
-
const r =
|
|
3790
|
+
const r = "-webkit-column-axis", o = "column-gap", h = "column-width", l = "column-fill", d = this.writingMode().indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
|
3823
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" });
|
|
3824
3792
|
const u = [
|
|
3825
3793
|
// Fixes Safari column cut offs, but causes RTL issues.
|
|
@@ -3846,7 +3814,7 @@ class Tt {
|
|
|
3846
3814
|
), u.push(
|
|
3847
3815
|
["box-sizing", "border-box"],
|
|
3848
3816
|
["max-width", "inherit"],
|
|
3849
|
-
[
|
|
3817
|
+
[l, "auto"],
|
|
3850
3818
|
[o, s + "px"],
|
|
3851
3819
|
[h, i + "px"]
|
|
3852
3820
|
), this.cssBatch(u);
|
|
@@ -3868,15 +3836,15 @@ class Tt {
|
|
|
3868
3836
|
* @param {number} height
|
|
3869
3837
|
*/
|
|
3870
3838
|
fit(t, e, i) {
|
|
3871
|
-
const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r,
|
|
3872
|
-
this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(
|
|
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);
|
|
3873
3841
|
const c = [
|
|
3874
3842
|
// background images are not scaled by transform
|
|
3875
|
-
["background-size", n *
|
|
3843
|
+
["background-size", n * l + "px " + r * l + "px"],
|
|
3876
3844
|
["background-color", "transparent"]
|
|
3877
3845
|
];
|
|
3878
3846
|
if (i && i.properties.includes("page-spread-left")) {
|
|
3879
|
-
const d = t - n *
|
|
3847
|
+
const d = t - n * l;
|
|
3880
3848
|
c.push(["margin-left", d + "px"]);
|
|
3881
3849
|
}
|
|
3882
3850
|
this.cssBatch(c);
|
|
@@ -3889,14 +3857,14 @@ class Tt {
|
|
|
3889
3857
|
this.documentElement && (this.documentElement.style.direction = t);
|
|
3890
3858
|
}
|
|
3891
3859
|
mapPage(t, e, i, s, n) {
|
|
3892
|
-
return new
|
|
3860
|
+
return new wt(e, void 0, void 0, n).page(this, t, i, s);
|
|
3893
3861
|
}
|
|
3894
3862
|
/**
|
|
3895
3863
|
* Emit event when link in content is clicked
|
|
3896
3864
|
* @private
|
|
3897
3865
|
*/
|
|
3898
3866
|
linksHandler() {
|
|
3899
|
-
|
|
3867
|
+
ve(this.content, (t) => {
|
|
3900
3868
|
this.emit(f.CONTENTS.LINK_CLICKED, t);
|
|
3901
3869
|
});
|
|
3902
3870
|
}
|
|
@@ -3905,8 +3873,7 @@ class Tt {
|
|
|
3905
3873
|
* @param {string} [mode="horizontal-tb"] "horizontal-tb" | "vertical-rl" | "vertical-lr"
|
|
3906
3874
|
*/
|
|
3907
3875
|
writingMode(t) {
|
|
3908
|
-
|
|
3909
|
-
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 || "";
|
|
3910
3877
|
}
|
|
3911
3878
|
/**
|
|
3912
3879
|
* Set the layoutStyle of the content
|
|
@@ -3951,41 +3918,41 @@ class Tt {
|
|
|
3951
3918
|
this.removeListeners(), this.__listeners = {};
|
|
3952
3919
|
}
|
|
3953
3920
|
}
|
|
3954
|
-
P(
|
|
3955
|
-
function
|
|
3956
|
-
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);
|
|
3957
3924
|
}
|
|
3958
|
-
function
|
|
3925
|
+
function Le(a, t) {
|
|
3959
3926
|
function e(s) {
|
|
3960
3927
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
3961
3928
|
const r = t[n];
|
|
3962
3929
|
let o, h;
|
|
3963
|
-
if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!
|
|
3964
|
-
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));
|
|
3965
3932
|
break;
|
|
3966
3933
|
}
|
|
3967
3934
|
}
|
|
3968
3935
|
}
|
|
3969
3936
|
let i;
|
|
3970
|
-
if (
|
|
3937
|
+
if (a.nodeName === "iframe" || a.nodeName === "IFRAME")
|
|
3971
3938
|
try {
|
|
3972
|
-
i =
|
|
3939
|
+
i = a.contentDocument;
|
|
3973
3940
|
} catch {
|
|
3974
|
-
i =
|
|
3941
|
+
i = a;
|
|
3975
3942
|
}
|
|
3976
3943
|
else
|
|
3977
|
-
i =
|
|
3944
|
+
i = a;
|
|
3978
3945
|
for (const s of ["mouseup", "mousedown", "click", "touchstart"])
|
|
3979
3946
|
i.addEventListener(s, (n) => e(n), !1);
|
|
3980
3947
|
}
|
|
3981
|
-
function
|
|
3982
|
-
const t = Object.assign({},
|
|
3948
|
+
function Re(a) {
|
|
3949
|
+
const t = Object.assign({}, a, { bubbles: !1 });
|
|
3983
3950
|
try {
|
|
3984
|
-
return new MouseEvent(
|
|
3951
|
+
return new MouseEvent(a.type, t);
|
|
3985
3952
|
} catch {
|
|
3986
|
-
const i =
|
|
3953
|
+
const i = a, s = document.createEvent("MouseEvents");
|
|
3987
3954
|
return s.initMouseEvent(
|
|
3988
|
-
|
|
3955
|
+
a.type,
|
|
3989
3956
|
!1,
|
|
3990
3957
|
i.cancelable,
|
|
3991
3958
|
i.view,
|
|
@@ -4003,42 +3970,42 @@ function Le(l) {
|
|
|
4003
3970
|
), s;
|
|
4004
3971
|
}
|
|
4005
3972
|
}
|
|
4006
|
-
function
|
|
3973
|
+
function Ae(a, t, e, i) {
|
|
4007
3974
|
const s = t.getBoundingClientRect();
|
|
4008
|
-
function n(h,
|
|
3975
|
+
function n(h, l, c) {
|
|
4009
3976
|
const d = h.top - s.top, u = h.left - s.left, p = d + h.height, g = u + h.width;
|
|
4010
|
-
return d <= c && u <=
|
|
3977
|
+
return d <= c && u <= l && p > c && g > l;
|
|
4011
3978
|
}
|
|
4012
|
-
const r =
|
|
3979
|
+
const r = a.getBoundingClientRect();
|
|
4013
3980
|
if (!n(r, e, i))
|
|
4014
3981
|
return !1;
|
|
4015
|
-
const o =
|
|
4016
|
-
for (let h = 0,
|
|
3982
|
+
const o = a.getClientRects();
|
|
3983
|
+
for (let h = 0, l = o.length; h < l; h++)
|
|
4017
3984
|
if (n(o[h], e, i))
|
|
4018
3985
|
return !0;
|
|
4019
3986
|
return !1;
|
|
4020
3987
|
}
|
|
4021
|
-
function
|
|
4022
|
-
const e = t.getBoundingClientRect(), i =
|
|
3988
|
+
function Ie(a, t) {
|
|
3989
|
+
const e = t.getBoundingClientRect(), i = a.getBoundingClientRect();
|
|
4023
3990
|
return {
|
|
4024
3991
|
top: i.top - e.top,
|
|
4025
3992
|
left: i.left - e.left,
|
|
4026
|
-
height:
|
|
4027
|
-
width:
|
|
3993
|
+
height: a.scrollHeight,
|
|
3994
|
+
width: a.scrollWidth
|
|
4028
3995
|
};
|
|
4029
3996
|
}
|
|
4030
|
-
function
|
|
4031
|
-
|
|
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");
|
|
4032
3999
|
}
|
|
4033
|
-
function
|
|
4034
|
-
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;
|
|
4035
4002
|
}
|
|
4036
|
-
class
|
|
4003
|
+
class Ot {
|
|
4037
4004
|
constructor(t, e = document.body) {
|
|
4038
|
-
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();
|
|
4039
4006
|
}
|
|
4040
4007
|
addMark(t) {
|
|
4041
|
-
const e =
|
|
4008
|
+
const e = $("g");
|
|
4042
4009
|
return this.element.appendChild(e), t.bind(e, this.container), this.marks.push(t), t.render(), t;
|
|
4043
4010
|
}
|
|
4044
4011
|
removeMark(t) {
|
|
@@ -4049,12 +4016,12 @@ class It {
|
|
|
4049
4016
|
this.element.removeChild(i), this.marks.splice(e, 1);
|
|
4050
4017
|
}
|
|
4051
4018
|
render() {
|
|
4052
|
-
|
|
4019
|
+
Pe(this.element, Ie(this.target, this.container));
|
|
4053
4020
|
for (const t of this.marks)
|
|
4054
4021
|
t.render();
|
|
4055
4022
|
}
|
|
4056
4023
|
}
|
|
4057
|
-
class
|
|
4024
|
+
class ze {
|
|
4058
4025
|
constructor() {
|
|
4059
4026
|
this.element = null;
|
|
4060
4027
|
}
|
|
@@ -4086,14 +4053,14 @@ class Oe {
|
|
|
4086
4053
|
for (let i = 0; i < t.length; i++) {
|
|
4087
4054
|
if (t[i] === e)
|
|
4088
4055
|
return !0;
|
|
4089
|
-
if (
|
|
4056
|
+
if (Oe(t[i], e))
|
|
4090
4057
|
return !1;
|
|
4091
4058
|
}
|
|
4092
4059
|
return !0;
|
|
4093
4060
|
});
|
|
4094
4061
|
}
|
|
4095
4062
|
}
|
|
4096
|
-
class
|
|
4063
|
+
class Qt extends ze {
|
|
4097
4064
|
constructor(t, e, i, s) {
|
|
4098
4065
|
super(), this.range = t, this.className = e, this.data = i || {}, this.attributes = s || {};
|
|
4099
4066
|
}
|
|
@@ -4110,13 +4077,13 @@ class Kt extends Oe {
|
|
|
4110
4077
|
this.element.removeChild(this.element.firstChild);
|
|
4111
4078
|
const t = this.element.ownerDocument.createDocumentFragment(), e = this.filteredRanges(), i = this.element.getBoundingClientRect(), s = this.container.getBoundingClientRect();
|
|
4112
4079
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
4113
|
-
const o = e[n], h =
|
|
4080
|
+
const o = e[n], h = $("rect");
|
|
4114
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);
|
|
4115
4082
|
}
|
|
4116
4083
|
this.element.appendChild(t);
|
|
4117
4084
|
}
|
|
4118
4085
|
}
|
|
4119
|
-
class
|
|
4086
|
+
class De extends Qt {
|
|
4120
4087
|
constructor(t, e, i, s) {
|
|
4121
4088
|
super(t, e, i, s);
|
|
4122
4089
|
}
|
|
@@ -4125,15 +4092,15 @@ class Pe extends Kt {
|
|
|
4125
4092
|
this.element.removeChild(this.element.firstChild);
|
|
4126
4093
|
const t = this.element.ownerDocument.createDocumentFragment(), e = this.filteredRanges(), i = this.element.getBoundingClientRect(), s = this.container.getBoundingClientRect();
|
|
4127
4094
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
4128
|
-
const o = e[n], h =
|
|
4095
|
+
const o = e[n], h = $("rect");
|
|
4129
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");
|
|
4130
|
-
const
|
|
4131
|
-
|
|
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);
|
|
4132
4099
|
}
|
|
4133
4100
|
this.element.appendChild(t);
|
|
4134
4101
|
}
|
|
4135
4102
|
}
|
|
4136
|
-
class
|
|
4103
|
+
class Jt {
|
|
4137
4104
|
constructor(t, e) {
|
|
4138
4105
|
this.settings = C({
|
|
4139
4106
|
ignoreClass: "",
|
|
@@ -4148,14 +4115,14 @@ class Zt {
|
|
|
4148
4115
|
forceRight: !1,
|
|
4149
4116
|
allowScriptedContent: !1,
|
|
4150
4117
|
allowPopups: !1
|
|
4151
|
-
}, 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 = {};
|
|
4152
4119
|
}
|
|
4153
4120
|
container(t) {
|
|
4154
4121
|
const e = document.createElement("div");
|
|
4155
|
-
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;
|
|
4156
4123
|
}
|
|
4157
4124
|
create() {
|
|
4158
|
-
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);
|
|
4159
4126
|
}
|
|
4160
4127
|
render(t, e) {
|
|
4161
4128
|
return this.create(), this.size(), this.sectionRender || (this.sectionRender = this.section.render(t)), this.sectionRender.then((i) => this.load(i)).then(() => {
|
|
@@ -4180,17 +4147,17 @@ class Zt {
|
|
|
4180
4147
|
}
|
|
4181
4148
|
// Lock an axis to element dimensions, taking borders into account
|
|
4182
4149
|
lock(t, e, i) {
|
|
4183
|
-
const s =
|
|
4150
|
+
const s = J(this.element);
|
|
4184
4151
|
let n;
|
|
4185
|
-
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();
|
|
4186
4153
|
}
|
|
4187
4154
|
// Resize a single axis based on content dimensions
|
|
4188
4155
|
expand(t) {
|
|
4189
4156
|
let e = this.lockedWidth, i = this.lockedHeight, s;
|
|
4190
|
-
!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);
|
|
4191
4158
|
}
|
|
4192
4159
|
reframe(t, e) {
|
|
4193
|
-
|
|
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);
|
|
4194
4161
|
const i = this.prevBounds ? t - this.prevBounds.width : t, s = this.prevBounds ? e - this.prevBounds.height : e, n = {
|
|
4195
4162
|
width: t,
|
|
4196
4163
|
height: e,
|
|
@@ -4201,16 +4168,16 @@ class Zt {
|
|
|
4201
4168
|
let r;
|
|
4202
4169
|
for (const o in this.marks)
|
|
4203
4170
|
this.marks.hasOwnProperty(o) && (r = this.marks[o], this.placeMark(r.element, r.range));
|
|
4204
|
-
}), 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);
|
|
4205
4172
|
}
|
|
4206
4173
|
load(t) {
|
|
4207
|
-
const e = new
|
|
4174
|
+
const e = new S(), i = e.promise;
|
|
4208
4175
|
if (!this.iframe)
|
|
4209
4176
|
return e.reject(new Error("No Iframe Available")), i;
|
|
4210
4177
|
if (this.iframe.onload = (s) => {
|
|
4211
4178
|
this.onLoad(s, e);
|
|
4212
4179
|
}, this.settings.method === "blobUrl")
|
|
4213
|
-
this.blobUrl =
|
|
4180
|
+
this.blobUrl = tt(t, "application/xhtml+xml"), this.iframe.src = this.blobUrl, this.element.appendChild(this.iframe);
|
|
4214
4181
|
else if (this.settings.method === "srcdoc")
|
|
4215
4182
|
this.iframe.srcdoc = t, this.element.appendChild(this.iframe);
|
|
4216
4183
|
else {
|
|
@@ -4221,7 +4188,7 @@ class Zt {
|
|
|
4221
4188
|
return i;
|
|
4222
4189
|
}
|
|
4223
4190
|
onLoad(t, e) {
|
|
4224
|
-
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;
|
|
4225
4192
|
let i = this.document.querySelector("link[rel='canonical']");
|
|
4226
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, () => {
|
|
4227
4194
|
this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
|
|
@@ -4233,7 +4200,7 @@ class Zt {
|
|
|
4233
4200
|
this.layout = t, this.contents && (this.layout.format(this.contents), this.expand());
|
|
4234
4201
|
}
|
|
4235
4202
|
setAxis(t) {
|
|
4236
|
-
this.settings.axis = t, t
|
|
4203
|
+
this.settings.axis = t, t === "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
|
|
4237
4204
|
}
|
|
4238
4205
|
setWritingMode(t) {
|
|
4239
4206
|
this.writingMode = t;
|
|
@@ -4244,7 +4211,7 @@ class Zt {
|
|
|
4244
4211
|
this.contents && (this.contents.off(f.CONTENTS.EXPAND), this.contents.off(f.CONTENTS.RESIZE));
|
|
4245
4212
|
}
|
|
4246
4213
|
display(t) {
|
|
4247
|
-
const e = new
|
|
4214
|
+
const e = new S();
|
|
4248
4215
|
return this.displayed ? e.resolve(this) : this.render(t).then(() => {
|
|
4249
4216
|
this.emit(f.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
|
|
4250
4217
|
}, (i) => {
|
|
@@ -4285,7 +4252,7 @@ class Zt {
|
|
|
4285
4252
|
onResize(t, e) {
|
|
4286
4253
|
}
|
|
4287
4254
|
bounds(t) {
|
|
4288
|
-
return (t || !this.elementBounds) && (this.elementBounds =
|
|
4255
|
+
return (t || !this.elementBounds) && (this.elementBounds = K(this.element)), this.elementBounds;
|
|
4289
4256
|
}
|
|
4290
4257
|
highlight(t, e = {}, i, s = "epubjs-hl", n = {}) {
|
|
4291
4258
|
if (!this.contents)
|
|
@@ -4293,11 +4260,11 @@ class Zt {
|
|
|
4293
4260
|
const r = Object.assign({ fill: "yellow", "fill-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4294
4261
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4295
4262
|
};
|
|
4296
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4297
|
-
const
|
|
4263
|
+
e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
|
|
4264
|
+
const l = new Qt(o, s, e, r);
|
|
4298
4265
|
let c;
|
|
4299
4266
|
try {
|
|
4300
|
-
c = this.pane.addMark(
|
|
4267
|
+
c = this.pane.addMark(l);
|
|
4301
4268
|
} catch (d) {
|
|
4302
4269
|
console.error("Failed to add highlight for", t, d);
|
|
4303
4270
|
return;
|
|
@@ -4310,11 +4277,11 @@ class Zt {
|
|
|
4310
4277
|
const r = Object.assign({ stroke: "black", "stroke-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4311
4278
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4312
4279
|
};
|
|
4313
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4314
|
-
const
|
|
4280
|
+
e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
|
|
4281
|
+
const l = new De(o, s, e, r);
|
|
4315
4282
|
let c;
|
|
4316
4283
|
try {
|
|
4317
|
-
c = this.pane.addMark(
|
|
4284
|
+
c = this.pane.addMark(l);
|
|
4318
4285
|
} catch (d) {
|
|
4319
4286
|
console.error("Failed to add underline for", t, d);
|
|
4320
4287
|
return;
|
|
@@ -4329,13 +4296,13 @@ class Zt {
|
|
|
4329
4296
|
let s = this.contents.range(t);
|
|
4330
4297
|
if (!s)
|
|
4331
4298
|
return;
|
|
4332
|
-
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) => {
|
|
4333
4300
|
this.emit(f.VIEWS.MARK_CLICKED, t, e);
|
|
4334
4301
|
};
|
|
4335
4302
|
s.collapsed && n.nodeType === 1 ? (s = new Range(), s.selectNodeContents(n)) : s.collapsed && (s = new Range(), s.selectNodeContents(r));
|
|
4336
4303
|
const h = this.document.createElement("a");
|
|
4337
|
-
return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((
|
|
4338
|
-
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];
|
|
4339
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;
|
|
4340
4307
|
}
|
|
4341
4308
|
placeMark(t, e) {
|
|
@@ -4346,7 +4313,7 @@ class Zt {
|
|
|
4346
4313
|
} else {
|
|
4347
4314
|
const r = e.getClientRects();
|
|
4348
4315
|
let o;
|
|
4349
|
-
for (let h = 0; h
|
|
4316
|
+
for (let h = 0; h !== r.length; h++)
|
|
4350
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);
|
|
4351
4318
|
}
|
|
4352
4319
|
t.style.top = `${i}px`, t.style.left = `${s}px`;
|
|
@@ -4382,37 +4349,37 @@ class Zt {
|
|
|
4382
4349
|
this.ununderline(t);
|
|
4383
4350
|
for (const t in this.marks)
|
|
4384
4351
|
this.unmark(t);
|
|
4385
|
-
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 = {};
|
|
4386
4353
|
}
|
|
4387
4354
|
}
|
|
4388
|
-
P(
|
|
4389
|
-
function
|
|
4390
|
-
let
|
|
4391
|
-
const t =
|
|
4392
|
-
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;
|
|
4393
4360
|
}
|
|
4394
|
-
function
|
|
4395
|
-
const
|
|
4396
|
-
|
|
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";
|
|
4397
4364
|
const t = document.createElement("div");
|
|
4398
4365
|
t.style.width = "2px";
|
|
4399
4366
|
const e = document.createElement("span");
|
|
4400
4367
|
e.style.width = "1px", e.style.display = "inline-block";
|
|
4401
4368
|
const i = document.createElement("span");
|
|
4402
|
-
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;
|
|
4403
4370
|
}
|
|
4404
|
-
function
|
|
4371
|
+
function We(a, t) {
|
|
4405
4372
|
let e = null, i = 0;
|
|
4406
4373
|
return function(...s) {
|
|
4407
4374
|
const n = Date.now(), r = t - (n - i);
|
|
4408
|
-
r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n,
|
|
4409
|
-
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);
|
|
4410
4377
|
}, r));
|
|
4411
4378
|
};
|
|
4412
4379
|
}
|
|
4413
|
-
class
|
|
4380
|
+
class qe {
|
|
4414
4381
|
constructor(t) {
|
|
4415
|
-
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));
|
|
4416
4383
|
}
|
|
4417
4384
|
/*
|
|
4418
4385
|
* Creates an element to render to.
|
|
@@ -4421,7 +4388,7 @@ class Me {
|
|
|
4421
4388
|
create(t) {
|
|
4422
4389
|
let e = t.height, i = t.width;
|
|
4423
4390
|
const s = t.overflow || !1, n = t.axis || "vertical", r = t.direction;
|
|
4424
|
-
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");
|
|
4425
4392
|
const o = document.createElement("div");
|
|
4426
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;
|
|
4427
4394
|
}
|
|
@@ -4431,7 +4398,7 @@ class Me {
|
|
|
4431
4398
|
}
|
|
4432
4399
|
getElement(t) {
|
|
4433
4400
|
let e = null;
|
|
4434
|
-
if (
|
|
4401
|
+
if (Mt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
|
|
4435
4402
|
throw new Error("Not an Element");
|
|
4436
4403
|
return e;
|
|
4437
4404
|
}
|
|
@@ -4445,7 +4412,7 @@ class Me {
|
|
|
4445
4412
|
return this.container;
|
|
4446
4413
|
}
|
|
4447
4414
|
onResize(t) {
|
|
4448
|
-
(!
|
|
4415
|
+
(!x(this.settings.width) || !x(this.settings.height)) && (this.resizeFunc = We(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
|
|
4449
4416
|
}
|
|
4450
4417
|
onOrientationChange(t) {
|
|
4451
4418
|
this.orientationChangeFunc = t, window.addEventListener("orientationchange", this.orientationChangeFunc, !1);
|
|
@@ -4453,13 +4420,13 @@ class Me {
|
|
|
4453
4420
|
size(t, e) {
|
|
4454
4421
|
let i;
|
|
4455
4422
|
const s = t || this.settings.width, n = e || this.settings.height;
|
|
4456
|
-
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 = {
|
|
4457
4424
|
left: parseFloat(this.containerStyles.paddingLeft) || 0,
|
|
4458
4425
|
right: parseFloat(this.containerStyles.paddingRight) || 0,
|
|
4459
4426
|
top: parseFloat(this.containerStyles.paddingTop) || 0,
|
|
4460
4427
|
bottom: parseFloat(this.containerStyles.paddingBottom) || 0
|
|
4461
4428
|
};
|
|
4462
|
-
const r =
|
|
4429
|
+
const r = pt(), o = window.getComputedStyle(document.body), h = {
|
|
4463
4430
|
left: parseFloat(o.paddingLeft) || 0,
|
|
4464
4431
|
right: parseFloat(o.paddingRight) || 0,
|
|
4465
4432
|
top: parseFloat(o.paddingTop) || 0,
|
|
@@ -4472,7 +4439,7 @@ class Me {
|
|
|
4472
4439
|
}
|
|
4473
4440
|
bounds() {
|
|
4474
4441
|
let t;
|
|
4475
|
-
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;
|
|
4476
4443
|
}
|
|
4477
4444
|
getSheet() {
|
|
4478
4445
|
const t = document.createElement("style");
|
|
@@ -4508,7 +4475,7 @@ class Me {
|
|
|
4508
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));
|
|
4509
4476
|
}
|
|
4510
4477
|
}
|
|
4511
|
-
class
|
|
4478
|
+
class Ue {
|
|
4512
4479
|
constructor(t) {
|
|
4513
4480
|
this.container = t, this._views = [], this.length = 0, this.hidden = !1;
|
|
4514
4481
|
}
|
|
@@ -4563,7 +4530,7 @@ class qe {
|
|
|
4563
4530
|
let e;
|
|
4564
4531
|
const i = this.length;
|
|
4565
4532
|
for (let s = 0; s < i; s++)
|
|
4566
|
-
if (e = this._views[s], e.displayed && e.section.index
|
|
4533
|
+
if (e = this._views[s], e.displayed && e.section.index === t.index)
|
|
4567
4534
|
return e;
|
|
4568
4535
|
}
|
|
4569
4536
|
displayed() {
|
|
@@ -4589,9 +4556,9 @@ class qe {
|
|
|
4589
4556
|
this.hidden = !0;
|
|
4590
4557
|
}
|
|
4591
4558
|
}
|
|
4592
|
-
class
|
|
4559
|
+
class st {
|
|
4593
4560
|
constructor(t) {
|
|
4594
|
-
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({}, {
|
|
4595
4562
|
infinite: !0,
|
|
4596
4563
|
hidden: !1,
|
|
4597
4564
|
width: void 0,
|
|
@@ -4619,7 +4586,7 @@ class rt {
|
|
|
4619
4586
|
}
|
|
4620
4587
|
render(t, e) {
|
|
4621
4588
|
const i = t.tagName;
|
|
4622
|
-
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({
|
|
4623
4590
|
width: e.width,
|
|
4624
4591
|
height: e.height,
|
|
4625
4592
|
overflow: this.overflow,
|
|
@@ -4627,7 +4594,7 @@ class rt {
|
|
|
4627
4594
|
axis: this.settings.axis,
|
|
4628
4595
|
fullsize: this.settings.fullsize,
|
|
4629
4596
|
direction: this.settings.direction
|
|
4630
|
-
}), 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;
|
|
4631
4598
|
}
|
|
4632
4599
|
addEventListeners() {
|
|
4633
4600
|
let t;
|
|
@@ -4640,25 +4607,18 @@ class rt {
|
|
|
4640
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;
|
|
4641
4608
|
}
|
|
4642
4609
|
destroy() {
|
|
4643
|
-
clearTimeout(this.
|
|
4610
|
+
clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
|
|
4644
4611
|
}
|
|
4645
4612
|
onOrientationChange(t) {
|
|
4646
4613
|
var i;
|
|
4647
4614
|
const { orientation: e } = window;
|
|
4648
|
-
(i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(),
|
|
4649
|
-
var s;
|
|
4650
|
-
this.orientationTimeout = void 0, (s = this.optsSettings) != null && s.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4651
|
-
}, 500);
|
|
4615
|
+
(i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4652
4616
|
}
|
|
4653
4617
|
onResized(t) {
|
|
4654
4618
|
this.resize();
|
|
4655
4619
|
}
|
|
4656
4620
|
resize(t, e, i) {
|
|
4657
4621
|
const s = this.stage.size(t, e);
|
|
4658
|
-
if (this.winBounds = et(), this.orientationTimeout && this.winBounds.width === this.winBounds.height) {
|
|
4659
|
-
this._stageSize = void 0;
|
|
4660
|
-
return;
|
|
4661
|
-
}
|
|
4662
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, {
|
|
4663
4623
|
width: this._stageSize.width,
|
|
4664
4624
|
height: this._stageSize.height
|
|
@@ -4678,8 +4638,8 @@ class rt {
|
|
|
4678
4638
|
}
|
|
4679
4639
|
}
|
|
4680
4640
|
display(t, e) {
|
|
4681
|
-
const i = new
|
|
4682
|
-
(e === t.href ||
|
|
4641
|
+
const i = new S(), s = i.promise;
|
|
4642
|
+
(e === t.href || x(e)) && (e = void 0);
|
|
4683
4643
|
const n = this.views.find(t);
|
|
4684
4644
|
if (n && t && this.layout.name !== "pre-paginated") {
|
|
4685
4645
|
const o = n.offset();
|
|
@@ -4690,8 +4650,8 @@ class rt {
|
|
|
4690
4650
|
this.scrollTo(o.left + h, o.top, !0);
|
|
4691
4651
|
}
|
|
4692
4652
|
if (e) {
|
|
4693
|
-
const h = n.locationOf(e),
|
|
4694
|
-
this.moveTo(h,
|
|
4653
|
+
const h = n.locationOf(e), l = n.width();
|
|
4654
|
+
this.moveTo(h, l);
|
|
4695
4655
|
}
|
|
4696
4656
|
return i.resolve(), s;
|
|
4697
4657
|
}
|
|
@@ -4699,8 +4659,8 @@ class rt {
|
|
|
4699
4659
|
let r = !1;
|
|
4700
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) => {
|
|
4701
4661
|
if (e) {
|
|
4702
|
-
const h = o.locationOf(e),
|
|
4703
|
-
this.moveTo(h,
|
|
4662
|
+
const h = o.locationOf(e), l = o.width();
|
|
4663
|
+
this.moveTo(h, l);
|
|
4704
4664
|
}
|
|
4705
4665
|
}, (o) => {
|
|
4706
4666
|
i.reject(o);
|
|
@@ -4757,7 +4717,7 @@ class rt {
|
|
|
4757
4717
|
//
|
|
4758
4718
|
// };
|
|
4759
4719
|
next() {
|
|
4760
|
-
var s, n, r, o, h,
|
|
4720
|
+
var s, n, r, o, h, l, c, d, u, p;
|
|
4761
4721
|
let t, e;
|
|
4762
4722
|
const i = this.settings.direction;
|
|
4763
4723
|
if (this.views.length) {
|
|
@@ -4780,7 +4740,7 @@ class rt {
|
|
|
4780
4740
|
this.scrollBy(this.layout.delta, 0, !0);
|
|
4781
4741
|
else {
|
|
4782
4742
|
const g = this.views.last();
|
|
4783
|
-
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);
|
|
4784
4744
|
}
|
|
4785
4745
|
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4786
4746
|
if (this.scrollTop = this.container.scrollTop, !(Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1))
|
|
@@ -4801,7 +4761,7 @@ class rt {
|
|
|
4801
4761
|
}
|
|
4802
4762
|
}
|
|
4803
4763
|
prev() {
|
|
4804
|
-
var s, n, r, o, h,
|
|
4764
|
+
var s, n, r, o, h, l, c, d, u, p, g;
|
|
4805
4765
|
let t, e;
|
|
4806
4766
|
const i = this.settings.direction;
|
|
4807
4767
|
if (this.views.length) {
|
|
@@ -4824,7 +4784,7 @@ class rt {
|
|
|
4824
4784
|
this.scrollBy(-this.layout.delta, 0, !0);
|
|
4825
4785
|
else {
|
|
4826
4786
|
const m = this.views.first();
|
|
4827
|
-
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);
|
|
4828
4788
|
}
|
|
4829
4789
|
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4830
4790
|
if (this.scrollTop = this.container.scrollTop, this.container.scrollTop > 0)
|
|
@@ -4841,9 +4801,9 @@ class rt {
|
|
|
4841
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(() => {
|
|
4842
4802
|
var v;
|
|
4843
4803
|
if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
|
|
4844
|
-
const
|
|
4845
|
-
if (
|
|
4846
|
-
return this.prepend(
|
|
4804
|
+
const b = (v = t.prev) == null ? void 0 : v.call(t);
|
|
4805
|
+
if (b)
|
|
4806
|
+
return this.prepend(b);
|
|
4847
4807
|
}
|
|
4848
4808
|
}, (v) => v).then(() => {
|
|
4849
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();
|
|
@@ -4866,21 +4826,21 @@ class rt {
|
|
|
4866
4826
|
this.settings.direction;
|
|
4867
4827
|
let r = 0;
|
|
4868
4828
|
const o = 0;
|
|
4869
|
-
return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((
|
|
4870
|
-
const c =
|
|
4871
|
-
let m, v,
|
|
4872
|
-
n ? (m = r + e.top - u.top + o, v = m + i - o, k = this.layout.count(g, i).pages,
|
|
4873
|
-
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);
|
|
4874
4834
|
if (this.settings.direction === "rtl" && !n) {
|
|
4875
|
-
const
|
|
4876
|
-
|
|
4835
|
+
const M = E;
|
|
4836
|
+
E = k - T, T = k - M;
|
|
4877
4837
|
}
|
|
4878
4838
|
_ = [];
|
|
4879
|
-
for (let
|
|
4880
|
-
const
|
|
4881
|
-
_.push(
|
|
4839
|
+
for (let M = E; M <= T; M++) {
|
|
4840
|
+
const z = M + 1;
|
|
4841
|
+
_.push(z);
|
|
4882
4842
|
}
|
|
4883
|
-
const I = this.mapping.page(
|
|
4843
|
+
const I = this.mapping.page(l.contents, l.section.cfiBase, m, v);
|
|
4884
4844
|
return {
|
|
4885
4845
|
index: c,
|
|
4886
4846
|
href: d,
|
|
@@ -4895,19 +4855,19 @@ class rt {
|
|
|
4895
4855
|
let i = 0, s = 0;
|
|
4896
4856
|
return this.settings.fullsize && (i = window.scrollX), t.map((r) => {
|
|
4897
4857
|
const o = r.section.index, h = r.section.href;
|
|
4898
|
-
let
|
|
4858
|
+
let l;
|
|
4899
4859
|
const c = r.position(), d = r.width();
|
|
4900
4860
|
let u, p, g;
|
|
4901
|
-
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;
|
|
4902
4862
|
const m = this.mapping.page(r.contents, r.section.cfiBase, u, p), v = this.layout.count(d).pages;
|
|
4903
|
-
let
|
|
4863
|
+
let b = Math.floor(u / this.layout.pageWidth);
|
|
4904
4864
|
const k = [];
|
|
4905
|
-
let
|
|
4906
|
-
if (
|
|
4907
|
-
const _ =
|
|
4908
|
-
|
|
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 - _;
|
|
4909
4869
|
}
|
|
4910
|
-
for (let _ =
|
|
4870
|
+
for (let _ = b + 1; _ <= E; _++) {
|
|
4911
4871
|
const T = _;
|
|
4912
4872
|
k.push(T);
|
|
4913
4873
|
}
|
|
@@ -4964,7 +4924,7 @@ class rt {
|
|
|
4964
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));
|
|
4965
4925
|
}
|
|
4966
4926
|
setLayout(t) {
|
|
4967
|
-
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) => {
|
|
4968
4928
|
e && e.setLayout(t);
|
|
4969
4929
|
});
|
|
4970
4930
|
}
|
|
@@ -4972,7 +4932,7 @@ class rt {
|
|
|
4972
4932
|
this.writingMode = t;
|
|
4973
4933
|
}
|
|
4974
4934
|
updateAxis(t, e) {
|
|
4975
|
-
!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)));
|
|
4976
4936
|
}
|
|
4977
4937
|
updateFlow(t, e = "auto") {
|
|
4978
4938
|
const i = t === "paginated" || t === "auto";
|
|
@@ -4992,23 +4952,23 @@ class rt {
|
|
|
4992
4952
|
return this.rendered;
|
|
4993
4953
|
}
|
|
4994
4954
|
}
|
|
4995
|
-
P(
|
|
4996
|
-
const
|
|
4997
|
-
easeInCubic: function(
|
|
4998
|
-
return Math.pow(
|
|
4955
|
+
P(st.prototype);
|
|
4956
|
+
const je = {
|
|
4957
|
+
easeInCubic: function(a) {
|
|
4958
|
+
return Math.pow(a, 3);
|
|
4999
4959
|
}
|
|
5000
4960
|
};
|
|
5001
|
-
class
|
|
4961
|
+
class bt {
|
|
5002
4962
|
constructor(t, e) {
|
|
5003
4963
|
this.settings = C({
|
|
5004
4964
|
duration: 80,
|
|
5005
4965
|
minVelocity: 0.2,
|
|
5006
4966
|
minDistance: 10,
|
|
5007
|
-
easing:
|
|
4967
|
+
easing: je.easeInCubic
|
|
5008
4968
|
}, e || {}), this._supportsTouch = this.supportsTouch(), this._supportsTouch && this.setup(t);
|
|
5009
4969
|
}
|
|
5010
4970
|
setup(t) {
|
|
5011
|
-
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());
|
|
5012
4972
|
}
|
|
5013
4973
|
supportsTouch() {
|
|
5014
4974
|
return "ontouchstart" in window || "DocumentTouch" in window;
|
|
@@ -5069,38 +5029,39 @@ class xt {
|
|
|
5069
5029
|
return t && (s += t * i), this.smoothScrollTo(s);
|
|
5070
5030
|
}
|
|
5071
5031
|
smoothScrollTo(t) {
|
|
5072
|
-
const e =
|
|
5073
|
-
this.snapping = !0
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
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
|
+
});
|
|
5083
5044
|
}
|
|
5084
5045
|
scrollTo(t = 0, e = 0) {
|
|
5085
5046
|
this.fullsize ? window.scroll(t, e) : (this.scroller.scrollLeft = t, this.scroller.scrollTop = e);
|
|
5086
5047
|
}
|
|
5087
5048
|
now() {
|
|
5088
|
-
return
|
|
5049
|
+
return performance.now();
|
|
5089
5050
|
}
|
|
5090
5051
|
destroy() {
|
|
5091
5052
|
this.scroller && (this.fullsize && this.enableScroll(), this.removeListeners(), this.scroller = void 0);
|
|
5092
5053
|
}
|
|
5093
5054
|
}
|
|
5094
|
-
P(
|
|
5095
|
-
function
|
|
5055
|
+
P(bt.prototype);
|
|
5056
|
+
function Fe(a, t) {
|
|
5096
5057
|
let e;
|
|
5097
5058
|
return function(...i) {
|
|
5098
5059
|
clearTimeout(e), e = setTimeout(() => {
|
|
5099
|
-
|
|
5060
|
+
a.call(this, ...i);
|
|
5100
5061
|
}, t);
|
|
5101
5062
|
};
|
|
5102
5063
|
}
|
|
5103
|
-
class
|
|
5064
|
+
class Ve extends st {
|
|
5104
5065
|
constructor(t) {
|
|
5105
5066
|
var i;
|
|
5106
5067
|
super(t), this.name = "continuous", this.settings = C({}, {
|
|
@@ -5132,13 +5093,12 @@ class je extends rt {
|
|
|
5132
5093
|
}, this.scrollTop = 0, this.scrollLeft = 0;
|
|
5133
5094
|
}
|
|
5134
5095
|
display(t, e) {
|
|
5135
|
-
return
|
|
5096
|
+
return st.prototype.display.call(this, t, e).then(() => this.fill());
|
|
5136
5097
|
}
|
|
5137
|
-
fill(
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
}), e.promise;
|
|
5098
|
+
async fill() {
|
|
5099
|
+
let t = !0;
|
|
5100
|
+
for (; t; )
|
|
5101
|
+
t = await this.q.enqueue(() => this.check());
|
|
5142
5102
|
}
|
|
5143
5103
|
moveTo(t) {
|
|
5144
5104
|
let e = 0, i = 0;
|
|
@@ -5190,7 +5150,7 @@ class je extends rt {
|
|
|
5190
5150
|
update(t) {
|
|
5191
5151
|
const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
|
|
5192
5152
|
let r, o;
|
|
5193
|
-
const h = new
|
|
5153
|
+
const h = new S(), l = [];
|
|
5194
5154
|
for (let c = 0; c < s; c++)
|
|
5195
5155
|
if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
|
|
5196
5156
|
if (o.displayed)
|
|
@@ -5201,48 +5161,48 @@ class je extends rt {
|
|
|
5201
5161
|
}, (u) => {
|
|
5202
5162
|
o.hide();
|
|
5203
5163
|
});
|
|
5204
|
-
|
|
5164
|
+
l.push(d);
|
|
5205
5165
|
}
|
|
5206
5166
|
else
|
|
5207
5167
|
this.q.enqueue(() => o.destroy()), clearTimeout(this.trimTimeout), this.trimTimeout = setTimeout(() => {
|
|
5208
5168
|
this.q.enqueue(() => this.trim());
|
|
5209
5169
|
}, 250);
|
|
5210
|
-
return
|
|
5170
|
+
return l.length ? Promise.all(l).catch((c) => {
|
|
5211
5171
|
h.reject(c);
|
|
5212
5172
|
}) : (h.resolve(), h.promise);
|
|
5213
5173
|
}
|
|
5214
5174
|
check(t, e) {
|
|
5215
|
-
const i = new
|
|
5175
|
+
const i = new S(), s = [], n = this.settings.axis === "horizontal";
|
|
5216
5176
|
let r = this.settings.offset || 0;
|
|
5217
5177
|
t && n && (r = t), e && !n && (r = e);
|
|
5218
5178
|
const o = this._bounds;
|
|
5219
5179
|
let h = n ? this.scrollLeft : this.scrollTop;
|
|
5220
|
-
const
|
|
5221
|
-
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));
|
|
5222
5182
|
const g = () => {
|
|
5223
5183
|
var T, I;
|
|
5224
|
-
const
|
|
5184
|
+
const E = this.views.first(), _ = E && ((I = (T = E.section).prev) == null ? void 0 : I.call(T));
|
|
5225
5185
|
_ && s.push(this.prepend(_));
|
|
5226
5186
|
}, m = () => {
|
|
5227
5187
|
var T, I;
|
|
5228
|
-
const
|
|
5188
|
+
const E = this.views.last(), _ = E && ((I = (T = E.section).next) == null ? void 0 : I.call(T));
|
|
5229
5189
|
_ && s.push(this.append(_));
|
|
5230
|
-
}, v = h +
|
|
5231
|
-
v >= c && m(),
|
|
5232
|
-
const k = s.map((
|
|
5233
|
-
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(() => {
|
|
5234
5194
|
this.update();
|
|
5235
5195
|
}), i.resolve(!1), i.promise);
|
|
5236
5196
|
}
|
|
5237
5197
|
trim() {
|
|
5238
|
-
const t = new
|
|
5198
|
+
const t = new S(), e = this.views.displayed();
|
|
5239
5199
|
if (!e.length)
|
|
5240
5200
|
return t.resolve(), t.promise;
|
|
5241
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);
|
|
5242
|
-
for (let
|
|
5243
|
-
this.erase(o[
|
|
5244
|
-
for (let
|
|
5245
|
-
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]);
|
|
5246
5206
|
return t.resolve(), t.promise;
|
|
5247
5207
|
}
|
|
5248
5208
|
erase(t, e) {
|
|
@@ -5254,13 +5214,12 @@ class je extends rt {
|
|
|
5254
5214
|
addEventListeners(t) {
|
|
5255
5215
|
this._onUnload = (e) => {
|
|
5256
5216
|
this.ignore = !0, this.destroy();
|
|
5257
|
-
}, 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));
|
|
5258
5218
|
}
|
|
5259
5219
|
addScrollListeners() {
|
|
5260
5220
|
let t;
|
|
5261
|
-
this.tick = Et;
|
|
5262
5221
|
const e = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
|
|
5263
|
-
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;
|
|
5264
5223
|
}
|
|
5265
5224
|
removeEventListeners() {
|
|
5266
5225
|
let t;
|
|
@@ -5293,13 +5252,13 @@ class je extends rt {
|
|
|
5293
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()));
|
|
5294
5253
|
}
|
|
5295
5254
|
updateFlow(t) {
|
|
5296
|
-
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));
|
|
5297
5256
|
}
|
|
5298
5257
|
destroy() {
|
|
5299
5258
|
clearTimeout(this.scrollTimeout), clearTimeout(this.trimTimeout), super.destroy(), this.snapper && this.snapper.destroy();
|
|
5300
5259
|
}
|
|
5301
5260
|
}
|
|
5302
|
-
class
|
|
5261
|
+
class Lt {
|
|
5303
5262
|
constructor(t, e) {
|
|
5304
5263
|
this.settings = C({}, {
|
|
5305
5264
|
width: null,
|
|
@@ -5318,7 +5277,7 @@ class kt {
|
|
|
5318
5277
|
defaultDirection: "ltr",
|
|
5319
5278
|
allowScriptedContent: !1,
|
|
5320
5279
|
allowPopups: !1
|
|
5321
|
-
}), 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);
|
|
5322
5281
|
}
|
|
5323
5282
|
/**
|
|
5324
5283
|
* Set the manager function
|
|
@@ -5334,7 +5293,7 @@ class kt {
|
|
|
5334
5293
|
*/
|
|
5335
5294
|
requireManager(t) {
|
|
5336
5295
|
let e;
|
|
5337
|
-
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;
|
|
5338
5297
|
}
|
|
5339
5298
|
/**
|
|
5340
5299
|
* Require the view from passed string, or as a class function
|
|
@@ -5343,7 +5302,7 @@ class kt {
|
|
|
5343
5302
|
*/
|
|
5344
5303
|
requireView(t) {
|
|
5345
5304
|
let e;
|
|
5346
|
-
return typeof t == "string" && t === "iframe" ? e =
|
|
5305
|
+
return typeof t == "string" && t === "iframe" ? e = Jt : e = t, e;
|
|
5347
5306
|
}
|
|
5348
5307
|
/**
|
|
5349
5308
|
* Start the rendering
|
|
@@ -5400,8 +5359,8 @@ class kt {
|
|
|
5400
5359
|
if (!this.book)
|
|
5401
5360
|
return;
|
|
5402
5361
|
this.epubcfi.isCfiString(t);
|
|
5403
|
-
const e = new
|
|
5404
|
-
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)));
|
|
5405
5364
|
const s = this.book.spine.get(t);
|
|
5406
5365
|
return s ? (this.manager.display(s, t).then(() => {
|
|
5407
5366
|
e.resolve(s), this.displaying = void 0, this.emit(f.RENDITION.DISPLAYED, s), this.reportLocation();
|
|
@@ -5564,7 +5523,7 @@ class kt {
|
|
|
5564
5523
|
* @param {object} settings
|
|
5565
5524
|
*/
|
|
5566
5525
|
layout(t) {
|
|
5567
|
-
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) => {
|
|
5568
5527
|
this.emit(f.RENDITION.LAYOUT, e, i);
|
|
5569
5528
|
})), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
|
|
5570
5529
|
}
|
|
@@ -5659,7 +5618,7 @@ class kt {
|
|
|
5659
5618
|
}, n = this.book.locations.locationFromCfi(e.mapping.start), r = this.book.locations.locationFromCfi(i.mapping.end);
|
|
5660
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));
|
|
5661
5620
|
const o = this.book.pageList.pageFromCfi(e.mapping.start), h = this.book.pageList.pageFromCfi(i.mapping.end);
|
|
5662
|
-
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;
|
|
5663
5622
|
}
|
|
5664
5623
|
/**
|
|
5665
5624
|
* Remove and Clean Up the Rendition
|
|
@@ -5673,7 +5632,7 @@ class kt {
|
|
|
5673
5632
|
* @param {Contents} view contents
|
|
5674
5633
|
*/
|
|
5675
5634
|
passEvents(t) {
|
|
5676
|
-
|
|
5635
|
+
Z.forEach((e) => {
|
|
5677
5636
|
t.on(e, (i) => this.triggerViewEvent(i, t));
|
|
5678
5637
|
}), t.on(f.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, t));
|
|
5679
5638
|
}
|
|
@@ -5740,10 +5699,8 @@ class kt {
|
|
|
5740
5699
|
"page-break-inside": "avoid",
|
|
5741
5700
|
"break-inside": "avoid"
|
|
5742
5701
|
}
|
|
5743
|
-
}), new Promise(function(n
|
|
5744
|
-
setTimeout(
|
|
5745
|
-
n();
|
|
5746
|
-
}, 1);
|
|
5702
|
+
}), new Promise(function(n) {
|
|
5703
|
+
setTimeout(n, 0);
|
|
5747
5704
|
});
|
|
5748
5705
|
}
|
|
5749
5706
|
/**
|
|
@@ -5805,8 +5762,9 @@ class kt {
|
|
|
5805
5762
|
s.setAttribute("name", "dc.relation.ispartof"), i && s.setAttribute("content", i), t.getElementsByTagName("head")[0].appendChild(s);
|
|
5806
5763
|
}
|
|
5807
5764
|
}
|
|
5808
|
-
P(
|
|
5809
|
-
|
|
5765
|
+
P(Lt.prototype);
|
|
5766
|
+
const ct = typeof window < "u" ? window.URL : URL;
|
|
5767
|
+
class He {
|
|
5810
5768
|
constructor() {
|
|
5811
5769
|
this.zip = void 0, this.urlCache = {}, this.checkRequirements();
|
|
5812
5770
|
}
|
|
@@ -5817,7 +5775,7 @@ class Fe {
|
|
|
5817
5775
|
*/
|
|
5818
5776
|
checkRequirements() {
|
|
5819
5777
|
try {
|
|
5820
|
-
this.zip = new
|
|
5778
|
+
this.zip = new ee();
|
|
5821
5779
|
} catch {
|
|
5822
5780
|
throw new Error("JSZip lib not loaded");
|
|
5823
5781
|
}
|
|
@@ -5846,17 +5804,14 @@ class Fe {
|
|
|
5846
5804
|
* @param {string} [type] specify the type of the returned result
|
|
5847
5805
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
5848
5806
|
*/
|
|
5849
|
-
request(t, e) {
|
|
5850
|
-
const i = new
|
|
5851
|
-
|
|
5852
|
-
const
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
message: "File not found in the epub: " + t,
|
|
5858
|
-
stack: new Error().stack
|
|
5859
|
-
}), 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);
|
|
5860
5815
|
}
|
|
5861
5816
|
/**
|
|
5862
5817
|
* Handle the response from request
|
|
@@ -5866,8 +5821,7 @@ class Fe {
|
|
|
5866
5821
|
* @return {any} the parsed result
|
|
5867
5822
|
*/
|
|
5868
5823
|
handleResponse(t, e) {
|
|
5869
|
-
|
|
5870
|
-
return e == "json" ? i = JSON.parse(t) : G(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);
|
|
5871
5825
|
}
|
|
5872
5826
|
/**
|
|
5873
5827
|
* Get a Blob from Archive by Url
|
|
@@ -5878,7 +5832,7 @@ class Fe {
|
|
|
5878
5832
|
getBlob(t, e) {
|
|
5879
5833
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5880
5834
|
if (s)
|
|
5881
|
-
return e = e ||
|
|
5835
|
+
return e = e || G.lookup(s.name), s.async("uint8array").then(function(n) {
|
|
5882
5836
|
return new Blob([n], { type: e });
|
|
5883
5837
|
});
|
|
5884
5838
|
}
|
|
@@ -5904,7 +5858,7 @@ class Fe {
|
|
|
5904
5858
|
getBase64(t, e) {
|
|
5905
5859
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5906
5860
|
if (s)
|
|
5907
|
-
return e = e ||
|
|
5861
|
+
return e = e || G.lookup(s.name), s.async("base64").then(function(n) {
|
|
5908
5862
|
return "data:" + e + ";base64," + n;
|
|
5909
5863
|
});
|
|
5910
5864
|
}
|
|
@@ -5914,46 +5868,50 @@ class Fe {
|
|
|
5914
5868
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
5915
5869
|
* @return {Promise} url promise with Url string
|
|
5916
5870
|
*/
|
|
5917
|
-
createUrl(t, e) {
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
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);
|
|
5929
5888
|
}
|
|
5930
5889
|
/**
|
|
5931
5890
|
* Revoke Temp Url for a archive item
|
|
5932
5891
|
* @param {string} url url of the item in the archive
|
|
5933
5892
|
*/
|
|
5934
5893
|
revokeUrl(t) {
|
|
5935
|
-
const e =
|
|
5936
|
-
|
|
5894
|
+
const e = this.urlCache[t];
|
|
5895
|
+
e && ct.revokeObjectURL(e);
|
|
5937
5896
|
}
|
|
5938
5897
|
destroy() {
|
|
5939
|
-
const t
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
i && t.revokeObjectURL(i);
|
|
5898
|
+
for (const t in this.urlCache) {
|
|
5899
|
+
const e = this.urlCache[t];
|
|
5900
|
+
e && ct.revokeObjectURL(e);
|
|
5943
5901
|
}
|
|
5944
5902
|
this.zip = void 0, this.urlCache = {};
|
|
5945
5903
|
}
|
|
5946
5904
|
}
|
|
5947
|
-
function
|
|
5905
|
+
function Xe(a) {
|
|
5948
5906
|
return new Promise((t, e) => {
|
|
5949
|
-
const i = indexedDB.open(
|
|
5907
|
+
const i = indexedDB.open(a, 1);
|
|
5950
5908
|
i.onupgradeneeded = () => {
|
|
5951
5909
|
i.result.createObjectStore("data");
|
|
5952
5910
|
}, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
|
|
5953
5911
|
});
|
|
5954
5912
|
}
|
|
5955
|
-
function
|
|
5956
|
-
const t =
|
|
5913
|
+
function Ye(a) {
|
|
5914
|
+
const t = Xe(a);
|
|
5957
5915
|
return {
|
|
5958
5916
|
getItem(e) {
|
|
5959
5917
|
return t.then((i) => new Promise((s, n) => {
|
|
@@ -5969,8 +5927,8 @@ function He(l) {
|
|
|
5969
5927
|
}
|
|
5970
5928
|
};
|
|
5971
5929
|
}
|
|
5972
|
-
const
|
|
5973
|
-
class
|
|
5930
|
+
const dt = typeof window < "u" ? window.URL : void 0;
|
|
5931
|
+
class te {
|
|
5974
5932
|
constructor(t, e, i) {
|
|
5975
5933
|
this.urlCache = {}, this.name = t, this.requester = e || Y, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
|
|
5976
5934
|
}
|
|
@@ -5982,7 +5940,7 @@ class Jt {
|
|
|
5982
5940
|
try {
|
|
5983
5941
|
if (typeof indexedDB > "u")
|
|
5984
5942
|
throw new Error("IndexedDB not available");
|
|
5985
|
-
this.storage =
|
|
5943
|
+
this.storage = Ye(this.name);
|
|
5986
5944
|
} catch {
|
|
5987
5945
|
throw new Error("IndexedDB not available");
|
|
5988
5946
|
}
|
|
@@ -6018,7 +5976,7 @@ class Jt {
|
|
|
6018
5976
|
add(t, e) {
|
|
6019
5977
|
const i = t.resources.map((s) => {
|
|
6020
5978
|
const { href: n } = s, r = this.resolver(n), o = encodeURIComponent(r);
|
|
6021
|
-
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);
|
|
6022
5980
|
});
|
|
6023
5981
|
return Promise.all(i);
|
|
6024
5982
|
}
|
|
@@ -6050,17 +6008,13 @@ class Jt {
|
|
|
6050
6008
|
* @param {string} [type] specify the type of the returned result
|
|
6051
6009
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
6052
6010
|
*/
|
|
6053
|
-
retrieve(t, e) {
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
message: "File not found in storage: " + t,
|
|
6061
|
-
stack: new Error().stack
|
|
6062
|
-
}), r.promise;
|
|
6063
|
-
});
|
|
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);
|
|
6064
6018
|
}
|
|
6065
6019
|
/**
|
|
6066
6020
|
* Handle the response from request
|
|
@@ -6070,8 +6024,7 @@ class Jt {
|
|
|
6070
6024
|
* @return {string | Document | Blob | object} the parsed result
|
|
6071
6025
|
*/
|
|
6072
6026
|
handleResponse(t, e) {
|
|
6073
|
-
|
|
6074
|
-
return e == "json" ? i = JSON.parse(t) : G(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);
|
|
6075
6028
|
}
|
|
6076
6029
|
/**
|
|
6077
6030
|
* Get a Blob from Storage by Url
|
|
@@ -6083,7 +6036,7 @@ class Jt {
|
|
|
6083
6036
|
const i = encodeURIComponent(t);
|
|
6084
6037
|
return this.storage.getItem(i).then(function(s) {
|
|
6085
6038
|
if (s)
|
|
6086
|
-
return e = e ||
|
|
6039
|
+
return e = e || G.lookup(t), new Blob([s], { type: e });
|
|
6087
6040
|
});
|
|
6088
6041
|
}
|
|
6089
6042
|
/**
|
|
@@ -6104,15 +6057,17 @@ class Jt {
|
|
|
6104
6057
|
* @param {string} [mimeType]
|
|
6105
6058
|
* @return {string} base64 encoded
|
|
6106
6059
|
*/
|
|
6107
|
-
getBase64(t, e) {
|
|
6060
|
+
async getBase64(t, e) {
|
|
6108
6061
|
const i = encodeURIComponent(t);
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
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);
|
|
6116
6071
|
});
|
|
6117
6072
|
}
|
|
6118
6073
|
/**
|
|
@@ -6121,18 +6076,21 @@ class Jt {
|
|
|
6121
6076
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
6122
6077
|
* @return {Promise} url promise with Url string
|
|
6123
6078
|
*/
|
|
6124
|
-
createUrl(t, e) {
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
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);
|
|
6136
6094
|
}
|
|
6137
6095
|
/**
|
|
6138
6096
|
* Revoke Temp Url for a archive item
|
|
@@ -6140,18 +6098,18 @@ class Jt {
|
|
|
6140
6098
|
*/
|
|
6141
6099
|
revokeUrl(t) {
|
|
6142
6100
|
const e = this.urlCache[t];
|
|
6143
|
-
e &&
|
|
6101
|
+
e && dt.revokeObjectURL(e);
|
|
6144
6102
|
}
|
|
6145
6103
|
destroy() {
|
|
6146
6104
|
for (const t in this.urlCache) {
|
|
6147
6105
|
const e = this.urlCache[t];
|
|
6148
|
-
e &&
|
|
6106
|
+
e && dt.revokeObjectURL(e);
|
|
6149
6107
|
}
|
|
6150
6108
|
this.urlCache = {}, this.removeListeners();
|
|
6151
6109
|
}
|
|
6152
6110
|
}
|
|
6153
|
-
P(
|
|
6154
|
-
class
|
|
6111
|
+
P(te.prototype);
|
|
6112
|
+
class ut {
|
|
6155
6113
|
constructor(t) {
|
|
6156
6114
|
this.interactive = "", this.fixedLayout = "", this.openToSpread = "", this.orientationLock = "", t && this.parse(t);
|
|
6157
6115
|
}
|
|
@@ -6163,8 +6121,8 @@ class pt {
|
|
|
6163
6121
|
parse(t) {
|
|
6164
6122
|
if (!t)
|
|
6165
6123
|
return this;
|
|
6166
|
-
const e =
|
|
6167
|
-
return e ? (
|
|
6124
|
+
const e = w(t, "display_options");
|
|
6125
|
+
return e ? (B(e, "option").forEach((s) => {
|
|
6168
6126
|
let n = "";
|
|
6169
6127
|
switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
|
|
6170
6128
|
case "interactive":
|
|
@@ -6186,7 +6144,7 @@ class pt {
|
|
|
6186
6144
|
this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
|
|
6187
6145
|
}
|
|
6188
6146
|
}
|
|
6189
|
-
const
|
|
6147
|
+
const zt = "META-INF/container.xml", Ge = "META-INF/com.apple.ibooks.display-options.xml", L = {
|
|
6190
6148
|
BINARY: "binary",
|
|
6191
6149
|
BASE64: "base64",
|
|
6192
6150
|
EPUB: "epub",
|
|
@@ -6194,7 +6152,7 @@ const Ot = "META-INF/container.xml", Xe = "META-INF/com.apple.ibooks.display-opt
|
|
|
6194
6152
|
MANIFEST: "json",
|
|
6195
6153
|
DIRECTORY: "directory"
|
|
6196
6154
|
};
|
|
6197
|
-
class
|
|
6155
|
+
class Rt {
|
|
6198
6156
|
constructor(t, e) {
|
|
6199
6157
|
typeof e > "u" && typeof t != "string" && !(t instanceof Blob) && !(t instanceof ArrayBuffer) && (e = t, t = void 0), this.settings = C({}, {
|
|
6200
6158
|
requestMethod: void 0,
|
|
@@ -6205,15 +6163,15 @@ class Lt {
|
|
|
6205
6163
|
canonical: void 0,
|
|
6206
6164
|
openAs: void 0,
|
|
6207
6165
|
store: void 0
|
|
6208
|
-
}), C(this.settings, e), this.opening = new
|
|
6209
|
-
manifest: new
|
|
6210
|
-
spine: new
|
|
6211
|
-
metadata: new
|
|
6212
|
-
cover: new
|
|
6213
|
-
navigation: new
|
|
6214
|
-
pageList: new
|
|
6215
|
-
resources: new
|
|
6216
|
-
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()
|
|
6217
6175
|
}, this.loaded = {
|
|
6218
6176
|
manifest: this.loading.manifest.promise,
|
|
6219
6177
|
spine: this.loading.spine.promise,
|
|
@@ -6231,7 +6189,7 @@ class Lt {
|
|
|
6231
6189
|
this.loaded.navigation,
|
|
6232
6190
|
this.loaded.resources,
|
|
6233
6191
|
this.loaded.displayOptions
|
|
6234
|
-
]), this.isRendered = !1, this.request = this.settings.requestMethod || Y, this.spine = new
|
|
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) => {
|
|
6235
6193
|
const s = new Error("Cannot load book at " + t);
|
|
6236
6194
|
this.emit(f.BOOK.OPEN_FAILED, s);
|
|
6237
6195
|
});
|
|
@@ -6246,7 +6204,7 @@ class Lt {
|
|
|
6246
6204
|
open(t, e) {
|
|
6247
6205
|
let i;
|
|
6248
6206
|
const s = e || this.determineType(t);
|
|
6249
|
-
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;
|
|
6250
6208
|
}
|
|
6251
6209
|
/**
|
|
6252
6210
|
* Open an archived epub
|
|
@@ -6256,7 +6214,7 @@ class Lt {
|
|
|
6256
6214
|
* @return {Promise}
|
|
6257
6215
|
*/
|
|
6258
6216
|
openEpub(t, e) {
|
|
6259
|
-
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));
|
|
6260
6218
|
}
|
|
6261
6219
|
/**
|
|
6262
6220
|
* Open the epub container
|
|
@@ -6265,7 +6223,7 @@ class Lt {
|
|
|
6265
6223
|
* @return {string} packagePath
|
|
6266
6224
|
*/
|
|
6267
6225
|
openContainer(t) {
|
|
6268
|
-
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)));
|
|
6269
6227
|
}
|
|
6270
6228
|
/**
|
|
6271
6229
|
* Open the Open Packaging Format Xml
|
|
@@ -6274,7 +6232,7 @@ class Lt {
|
|
|
6274
6232
|
* @return {Promise}
|
|
6275
6233
|
*/
|
|
6276
6234
|
openPackaging(t) {
|
|
6277
|
-
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)));
|
|
6278
6236
|
}
|
|
6279
6237
|
/**
|
|
6280
6238
|
* Open the manifest JSON
|
|
@@ -6283,7 +6241,7 @@ class Lt {
|
|
|
6283
6241
|
* @return {Promise}
|
|
6284
6242
|
*/
|
|
6285
6243
|
openManifest(t) {
|
|
6286
|
-
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)));
|
|
6287
6245
|
}
|
|
6288
6246
|
/**
|
|
6289
6247
|
* Load a resource from the Book
|
|
@@ -6304,7 +6262,7 @@ class Lt {
|
|
|
6304
6262
|
if (!t)
|
|
6305
6263
|
return "";
|
|
6306
6264
|
let i = t;
|
|
6307
|
-
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);
|
|
6308
6266
|
}
|
|
6309
6267
|
/**
|
|
6310
6268
|
* Get a canonical link to a path
|
|
@@ -6324,17 +6282,17 @@ class Lt {
|
|
|
6324
6282
|
determineType(t) {
|
|
6325
6283
|
let e;
|
|
6326
6284
|
if (this.settings.encoding === "base64")
|
|
6327
|
-
return
|
|
6285
|
+
return L.BASE64;
|
|
6328
6286
|
if (typeof t != "string")
|
|
6329
|
-
return
|
|
6330
|
-
if (e = new
|
|
6331
|
-
return
|
|
6287
|
+
return L.BINARY;
|
|
6288
|
+
if (e = new R(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
|
|
6289
|
+
return L.DIRECTORY;
|
|
6332
6290
|
if (e === "epub")
|
|
6333
|
-
return
|
|
6291
|
+
return L.EPUB;
|
|
6334
6292
|
if (e === "opf")
|
|
6335
|
-
return
|
|
6293
|
+
return L.OPF;
|
|
6336
6294
|
if (e === "json")
|
|
6337
|
-
return
|
|
6295
|
+
return L.MANIFEST;
|
|
6338
6296
|
}
|
|
6339
6297
|
/**
|
|
6340
6298
|
* unpack the contents of the Books packaging
|
|
@@ -6342,11 +6300,11 @@ class Lt {
|
|
|
6342
6300
|
* @param {Packaging} packaging object
|
|
6343
6301
|
*/
|
|
6344
6302
|
unpack(t) {
|
|
6345
|
-
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(
|
|
6346
|
-
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);
|
|
6347
6305
|
}).catch((i) => {
|
|
6348
|
-
this.displayOptions = new
|
|
6349
|
-
}) : (this.displayOptions = new
|
|
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, {
|
|
6350
6308
|
archive: this.archive,
|
|
6351
6309
|
resolver: (i, s) => this.resolve(i, s),
|
|
6352
6310
|
request: (i, s) => this.request(i, s),
|
|
@@ -6367,9 +6325,9 @@ class Lt {
|
|
|
6367
6325
|
loadNavigation(t) {
|
|
6368
6326
|
const e = t.navPath || t.ncxPath, i = t.toc;
|
|
6369
6327
|
return i ? new Promise((s, n) => {
|
|
6370
|
-
this.navigation = new
|
|
6371
|
-
}) : e ? this.load(e, "xml").then((s) => (this.navigation = new
|
|
6372
|
-
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);
|
|
6373
6331
|
});
|
|
6374
6332
|
}
|
|
6375
6333
|
/**
|
|
@@ -6388,7 +6346,7 @@ class Lt {
|
|
|
6388
6346
|
* @return {Rendition}
|
|
6389
6347
|
*/
|
|
6390
6348
|
renderTo(t, e) {
|
|
6391
|
-
return this.rendition = new
|
|
6349
|
+
return this.rendition = new Lt(this, e), this.rendition.attachTo(t), this.rendition;
|
|
6392
6350
|
}
|
|
6393
6351
|
/**
|
|
6394
6352
|
* Set if request should use withCredentials
|
|
@@ -6412,7 +6370,7 @@ class Lt {
|
|
|
6412
6370
|
* @return {Archive}
|
|
6413
6371
|
*/
|
|
6414
6372
|
unarchive(t, e) {
|
|
6415
|
-
return this.archive = new
|
|
6373
|
+
return this.archive = new He(), this.archive.open(t, e === "base64");
|
|
6416
6374
|
}
|
|
6417
6375
|
/**
|
|
6418
6376
|
* Store the epubs contents
|
|
@@ -6423,13 +6381,13 @@ class Lt {
|
|
|
6423
6381
|
*/
|
|
6424
6382
|
store(t) {
|
|
6425
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));
|
|
6426
|
-
return this.storage = new
|
|
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(() => {
|
|
6427
6385
|
this.archived && (this.storage.requester = (r, o) => this.archive.request(r, o));
|
|
6428
6386
|
const n = (r, o) => {
|
|
6429
6387
|
o.output = this.resources.substitute(r, o.url);
|
|
6430
6388
|
};
|
|
6431
6389
|
this.resources.settings.replacements = e || "blobUrl", this.resources.replacements().then(() => this.resources.replaceCss()), this.storage.on("offline", () => {
|
|
6432
|
-
this.url = new
|
|
6390
|
+
this.url = new R("/", ""), this.spine.hooks.serialize.register(n);
|
|
6433
6391
|
}), this.storage.on("online", () => {
|
|
6434
6392
|
this.url = i, this.spine.hooks.serialize.deregister(n);
|
|
6435
6393
|
});
|
|
@@ -6474,7 +6432,7 @@ class Lt {
|
|
|
6474
6432
|
*/
|
|
6475
6433
|
key(t) {
|
|
6476
6434
|
const e = t || this.packaging.metadata.identifier || this.url.filename;
|
|
6477
|
-
return `epubjs:${
|
|
6435
|
+
return `epubjs:${nt}:${e}`;
|
|
6478
6436
|
}
|
|
6479
6437
|
/**
|
|
6480
6438
|
* Destroy the Book and all associated objects
|
|
@@ -6483,36 +6441,37 @@ class Lt {
|
|
|
6483
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;
|
|
6484
6442
|
}
|
|
6485
6443
|
}
|
|
6486
|
-
P(
|
|
6487
|
-
function X(
|
|
6488
|
-
return new
|
|
6444
|
+
P(Rt.prototype);
|
|
6445
|
+
function X(a, t) {
|
|
6446
|
+
return new Rt(a, t);
|
|
6489
6447
|
}
|
|
6490
|
-
X.VERSION =
|
|
6491
|
-
typeof global < "u" && (globalThis.EPUBJS_VERSION =
|
|
6492
|
-
X.Book =
|
|
6493
|
-
X.Rendition =
|
|
6494
|
-
X.Contents =
|
|
6448
|
+
X.VERSION = nt;
|
|
6449
|
+
typeof global < "u" && (globalThis.EPUBJS_VERSION = nt);
|
|
6450
|
+
X.Book = Rt;
|
|
6451
|
+
X.Rendition = Lt;
|
|
6452
|
+
X.Contents = Nt;
|
|
6495
6453
|
X.CFI = y;
|
|
6496
|
-
X.utils =
|
|
6454
|
+
X.utils = ae;
|
|
6497
6455
|
export {
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6456
|
+
Te as Annotations,
|
|
6457
|
+
He as Archive,
|
|
6458
|
+
Rt as Book,
|
|
6459
|
+
Nt as Contents,
|
|
6460
|
+
ut as DisplayOptions,
|
|
6503
6461
|
y as EpubCFI,
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
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,
|
|
6516
6475
|
X as default
|
|
6517
6476
|
};
|
|
6518
6477
|
//# sourceMappingURL=epub.js.map
|