@likecoin/epub-ts 0.4.9 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotations.d.ts +0 -3
- package/dist/contents.d.ts +0 -12
- package/dist/epub.cjs +3 -3
- package/dist/epub.cjs.map +1 -1
- package/dist/epub.js +850 -895
- 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 +873 -921
- 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 +3 -1
- package/dist/managers/continuous/index.d.ts +3 -5
- package/dist/managers/default/index.d.ts +0 -9
- package/dist/rendition.d.ts +1 -1
- 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.node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DOMParser as
|
|
2
|
-
import
|
|
3
|
-
function A(
|
|
4
|
-
const t = typeof
|
|
1
|
+
import { DOMParser as Ut, parseHTML as jt } from "linkedom";
|
|
2
|
+
import Ft from "jszip";
|
|
3
|
+
function A(a) {
|
|
4
|
+
const t = typeof a == "function" ? a.prototype : a;
|
|
5
5
|
return t.on = function(e, i) {
|
|
6
6
|
return this.__listeners || (this.__listeners = {}), this.__listeners[e] || (this.__listeners[e] = []), this.__listeners[e].push(i), this;
|
|
7
7
|
}, t.off = function(e, i) {
|
|
@@ -13,70 +13,61 @@ function A(l) {
|
|
|
13
13
|
const s = this.__listeners[e].slice();
|
|
14
14
|
for (let n = 0; n < s.length; n++)
|
|
15
15
|
s[n](...i);
|
|
16
|
-
},
|
|
16
|
+
}, a;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
let
|
|
18
|
+
const _t = (a) => (Promise.resolve().then(() => a(performance.now())), 0), Vt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : _t, Ht = 1, Tt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
|
|
19
|
+
function kt() {
|
|
20
|
+
let a = (/* @__PURE__ */ new Date()).getTime();
|
|
21
21
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
22
|
-
const i = (
|
|
23
|
-
return
|
|
22
|
+
const i = (a + Math.random() * 16) % 16 | 0;
|
|
23
|
+
return a = Math.floor(a / 16), (e === "x" ? i : i & 7 | 8).toString(16);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return !!(
|
|
26
|
+
function Xt(a) {
|
|
27
|
+
return !!(a && a.nodeType === 1);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return !isNaN(parseFloat(
|
|
29
|
+
function E(a) {
|
|
30
|
+
return !isNaN(parseFloat(a)) && isFinite(a);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const t = parseFloat(
|
|
34
|
-
return
|
|
32
|
+
function Yt(a) {
|
|
33
|
+
const t = parseFloat(a);
|
|
34
|
+
return E(a) === !1 ? !1 : typeof a == "string" && a.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t = ["Webkit", "webkit", "Moz", "O", "ms"], e = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"], i = l.toLowerCase(), s = t.length;
|
|
38
|
-
if (typeof document > "u" || i in document.body.style)
|
|
39
|
-
return l;
|
|
40
|
-
for (let n = 0; n < s; n++)
|
|
41
|
-
if (e[n] + i in document.body.style)
|
|
42
|
-
return e[n] + i;
|
|
43
|
-
return l;
|
|
44
|
-
}
|
|
45
|
-
function Xt(l, ...t) {
|
|
36
|
+
function Gt(a, ...t) {
|
|
46
37
|
for (let e = 0; e < t.length; e++) {
|
|
47
38
|
const i = t[e];
|
|
48
39
|
for (const s in i)
|
|
49
|
-
|
|
40
|
+
a[s] === void 0 && (a[s] = i[s]);
|
|
50
41
|
}
|
|
51
|
-
return
|
|
42
|
+
return a;
|
|
52
43
|
}
|
|
53
|
-
function _(
|
|
44
|
+
function _(a, ...t) {
|
|
54
45
|
return t.forEach(function(e) {
|
|
55
46
|
e && Object.getOwnPropertyNames(e).forEach(function(i) {
|
|
56
|
-
Object.defineProperty(
|
|
47
|
+
Object.defineProperty(a, i, Object.getOwnPropertyDescriptor(e, i));
|
|
57
48
|
});
|
|
58
|
-
}),
|
|
49
|
+
}), a;
|
|
59
50
|
}
|
|
60
|
-
function $(
|
|
51
|
+
function $(a, t, e, i, s) {
|
|
61
52
|
const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
|
|
62
|
-
if (e || (e = function(
|
|
63
|
-
return
|
|
53
|
+
if (e || (e = function(l, c) {
|
|
54
|
+
return l > c ? 1 : l < c ? -1 : 0;
|
|
64
55
|
}), r - n <= 0)
|
|
65
56
|
return o;
|
|
66
|
-
const h = e(t[o],
|
|
67
|
-
return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? $(
|
|
57
|
+
const h = e(t[o], a);
|
|
58
|
+
return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? $(a, t, e, o, r) : $(a, t, e, n, o);
|
|
68
59
|
}
|
|
69
|
-
function ot(
|
|
60
|
+
function ot(a, t, e, i, s) {
|
|
70
61
|
const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
|
|
71
|
-
if (e || (e = function(
|
|
72
|
-
return
|
|
62
|
+
if (e || (e = function(l, c) {
|
|
63
|
+
return l > c ? 1 : l < c ? -1 : 0;
|
|
73
64
|
}), r - n <= 0)
|
|
74
65
|
return -1;
|
|
75
|
-
const h = e(t[o],
|
|
76
|
-
return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? ot(
|
|
66
|
+
const h = e(t[o], a);
|
|
67
|
+
return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? ot(a, t, e, o, r) : ot(a, t, e, n, o);
|
|
77
68
|
}
|
|
78
|
-
function
|
|
79
|
-
const t = window.getComputedStyle(
|
|
69
|
+
function J(a) {
|
|
70
|
+
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"];
|
|
80
71
|
let s = 0, n = 0;
|
|
81
72
|
return e.forEach(function(r) {
|
|
82
73
|
s += parseFloat(t.getPropertyValue(r)) || 0;
|
|
@@ -87,8 +78,8 @@ function tt(l) {
|
|
|
87
78
|
width: s
|
|
88
79
|
};
|
|
89
80
|
}
|
|
90
|
-
function ht(
|
|
91
|
-
const t = window.getComputedStyle(
|
|
81
|
+
function ht(a) {
|
|
82
|
+
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"];
|
|
92
83
|
let s = 0, n = 0;
|
|
93
84
|
return e.forEach(function(r) {
|
|
94
85
|
s += parseFloat(t.getPropertyValue(r)) || 0;
|
|
@@ -99,136 +90,144 @@ function ht(l) {
|
|
|
99
90
|
width: s
|
|
100
91
|
};
|
|
101
92
|
}
|
|
102
|
-
function
|
|
93
|
+
function gt(a) {
|
|
103
94
|
let t;
|
|
104
|
-
const e =
|
|
105
|
-
if (
|
|
95
|
+
const e = a.ownerDocument;
|
|
96
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
106
97
|
const i = e.createRange();
|
|
107
|
-
i.selectNodeContents(
|
|
98
|
+
i.selectNodeContents(a), t = i.getBoundingClientRect();
|
|
108
99
|
} else
|
|
109
|
-
t =
|
|
100
|
+
t = a.getBoundingClientRect();
|
|
110
101
|
return t;
|
|
111
102
|
}
|
|
112
|
-
function
|
|
113
|
-
const
|
|
103
|
+
function mt() {
|
|
104
|
+
const a = window.innerWidth, t = window.innerHeight;
|
|
114
105
|
return {
|
|
115
106
|
top: 0,
|
|
116
107
|
left: 0,
|
|
117
|
-
right:
|
|
108
|
+
right: a,
|
|
118
109
|
bottom: t,
|
|
119
|
-
width:
|
|
110
|
+
width: a,
|
|
120
111
|
height: t
|
|
121
112
|
};
|
|
122
113
|
}
|
|
123
|
-
function
|
|
124
|
-
const i =
|
|
114
|
+
function $t(a, t) {
|
|
115
|
+
const i = a.parentNode.childNodes;
|
|
125
116
|
let s, n = -1;
|
|
126
|
-
for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s
|
|
117
|
+
for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s !== a); r++)
|
|
127
118
|
;
|
|
128
119
|
return n;
|
|
129
120
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
121
|
+
function Kt(a) {
|
|
122
|
+
return $t(a, Ht);
|
|
123
|
+
}
|
|
124
|
+
function Lt(a) {
|
|
125
|
+
return ["xml", "opf", "ncx"].indexOf(a) > -1;
|
|
126
|
+
}
|
|
127
|
+
function Nt(a, t) {
|
|
128
|
+
return t === "json" ? JSON.parse(a) : t && Lt(t) ? W(a, "text/xml") : t === "xhtml" ? W(a, "application/xhtml+xml") : t === "html" || t === "htm" ? W(a, "text/html") : a;
|
|
132
129
|
}
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
class q extends Error {
|
|
131
|
+
constructor(t, e) {
|
|
132
|
+
super(t), this.name = "EpubError", this.status = e;
|
|
133
|
+
}
|
|
135
134
|
}
|
|
136
|
-
function
|
|
137
|
-
return new Blob([
|
|
135
|
+
function Zt(a, t) {
|
|
136
|
+
return new Blob([a], { type: t });
|
|
138
137
|
}
|
|
139
|
-
function at(
|
|
140
|
-
const e =
|
|
141
|
-
return
|
|
138
|
+
function at(a, t) {
|
|
139
|
+
const e = Zt(a, t);
|
|
140
|
+
return Tt.createObjectURL(e);
|
|
142
141
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
142
|
+
function Rt(a) {
|
|
143
|
+
return Tt.revokeObjectURL(a);
|
|
145
144
|
}
|
|
146
|
-
function
|
|
147
|
-
if (typeof
|
|
145
|
+
function vt(a, t) {
|
|
146
|
+
if (typeof a != "string")
|
|
148
147
|
return;
|
|
149
|
-
const e = btoa(
|
|
148
|
+
const e = btoa(a);
|
|
150
149
|
return "data:" + t + ";base64," + e;
|
|
151
150
|
}
|
|
152
|
-
function
|
|
153
|
-
return Object.prototype.toString.call(
|
|
151
|
+
function Qt(a) {
|
|
152
|
+
return Object.prototype.toString.call(a).slice(8, -1);
|
|
154
153
|
}
|
|
155
|
-
function
|
|
156
|
-
return
|
|
154
|
+
function W(a, t) {
|
|
155
|
+
return a.charCodeAt(0) === 65279 && (a = a.slice(1)), new DOMParser().parseFromString(a, t);
|
|
157
156
|
}
|
|
158
|
-
function
|
|
159
|
-
if (!
|
|
157
|
+
function w(a, t) {
|
|
158
|
+
if (!a)
|
|
160
159
|
throw new Error("No Element Provided");
|
|
161
|
-
return
|
|
160
|
+
return a.querySelector(t);
|
|
162
161
|
}
|
|
163
|
-
function
|
|
164
|
-
return
|
|
162
|
+
function B(a, t) {
|
|
163
|
+
return a.querySelectorAll(t);
|
|
165
164
|
}
|
|
166
|
-
function j(
|
|
165
|
+
function j(a, t, e) {
|
|
167
166
|
t += "[";
|
|
168
167
|
for (const i in e)
|
|
169
168
|
t += i + "~='" + e[i] + "'";
|
|
170
|
-
return t += "]",
|
|
169
|
+
return t += "]", a.querySelector(t) ?? void 0;
|
|
171
170
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
171
|
+
function lt(a, t) {
|
|
172
|
+
Jt(a, t, NodeFilter.SHOW_TEXT);
|
|
174
173
|
}
|
|
175
|
-
function
|
|
176
|
-
const i = document.createTreeWalker(
|
|
174
|
+
function Jt(a, t, e) {
|
|
175
|
+
const i = document.createTreeWalker(a, e, null);
|
|
177
176
|
let s;
|
|
178
177
|
for (; s = i.nextNode(); )
|
|
179
178
|
t(s);
|
|
180
179
|
}
|
|
181
|
-
function
|
|
180
|
+
function te(a) {
|
|
182
181
|
return new Promise(function(t, e) {
|
|
183
182
|
const i = new FileReader();
|
|
184
|
-
i.readAsDataURL(
|
|
183
|
+
i.readAsDataURL(a), i.onloadend = function() {
|
|
185
184
|
t(i.result);
|
|
186
185
|
};
|
|
187
186
|
});
|
|
188
187
|
}
|
|
189
|
-
class
|
|
188
|
+
class C {
|
|
190
189
|
constructor() {
|
|
191
|
-
this.
|
|
190
|
+
this.promise = new Promise((t, e) => {
|
|
192
191
|
this.resolve = t, this.reject = e;
|
|
193
|
-
})
|
|
192
|
+
});
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
function
|
|
195
|
+
function ct(a, t, e) {
|
|
197
196
|
let i = null;
|
|
198
197
|
try {
|
|
199
|
-
i =
|
|
198
|
+
i = a.querySelector(`${t}[*|type="${e}"]`);
|
|
200
199
|
} catch {
|
|
201
200
|
}
|
|
202
201
|
if (i)
|
|
203
202
|
return i;
|
|
204
|
-
const s =
|
|
203
|
+
const s = a.querySelectorAll(t);
|
|
205
204
|
for (let n = 0; n < s.length; n++)
|
|
206
205
|
if (s[n].getAttributeNS("http://www.idpf.org/2007/ops", "type") === e || s[n].getAttribute("epub:type") === e)
|
|
207
206
|
return s[n];
|
|
208
207
|
}
|
|
209
|
-
function
|
|
210
|
-
const t = [], e =
|
|
208
|
+
function yt(a) {
|
|
209
|
+
const t = [], e = a.childNodes;
|
|
211
210
|
for (let i = 0; i < e.length; i++) {
|
|
212
211
|
const s = e[i];
|
|
213
212
|
s.nodeType === 1 && t.push(s);
|
|
214
213
|
}
|
|
215
214
|
return t;
|
|
216
215
|
}
|
|
217
|
-
function
|
|
216
|
+
function wt(a) {
|
|
218
217
|
const t = [];
|
|
219
|
-
for (let e =
|
|
218
|
+
for (let e = a ?? null; e; e = e.parentNode)
|
|
220
219
|
t.unshift(e);
|
|
221
220
|
return t;
|
|
222
221
|
}
|
|
223
|
-
function F(
|
|
224
|
-
const i =
|
|
222
|
+
function F(a, t, e) {
|
|
223
|
+
const i = a.childNodes;
|
|
225
224
|
for (let s = 0; s < i.length; s++) {
|
|
226
225
|
const n = i[s];
|
|
227
226
|
if (n.nodeType === 1 && n.nodeName.toLowerCase() === t)
|
|
228
227
|
return n;
|
|
229
228
|
}
|
|
230
229
|
}
|
|
231
|
-
class
|
|
230
|
+
class ee {
|
|
232
231
|
constructor() {
|
|
233
232
|
this.collapsed = !1, this.commonAncestorContainer = void 0, this.endContainer = void 0, this.endOffset = void 0, this.startContainer = void 0, this.startOffset = void 0;
|
|
234
233
|
}
|
|
@@ -250,10 +249,10 @@ class Jt {
|
|
|
250
249
|
this.setStart(t, 0), this.setEnd(t, e);
|
|
251
250
|
}
|
|
252
251
|
_commonAncestorContainer(t, e) {
|
|
253
|
-
const i =
|
|
254
|
-
if (i[0]
|
|
252
|
+
const i = wt(t ?? this.startContainer), s = wt(e ?? this.endContainer);
|
|
253
|
+
if (i[0] === s[0]) {
|
|
255
254
|
for (let n = 0; n < i.length; n++)
|
|
256
|
-
if (i[n]
|
|
255
|
+
if (i[n] !== s[n])
|
|
257
256
|
return i[n - 1];
|
|
258
257
|
}
|
|
259
258
|
}
|
|
@@ -264,15 +263,15 @@ class Jt {
|
|
|
264
263
|
return "";
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
|
-
function
|
|
268
|
-
if (typeof
|
|
269
|
-
throw new TypeError("Path must be a string. Received " +
|
|
266
|
+
function U(a) {
|
|
267
|
+
if (typeof a != "string")
|
|
268
|
+
throw new TypeError("Path must be a string. Received " + a);
|
|
270
269
|
}
|
|
271
|
-
function
|
|
270
|
+
function ie(a, t) {
|
|
272
271
|
let e = "", i = -1, s = 0, n;
|
|
273
|
-
for (let r = 0; r <=
|
|
274
|
-
if (r <
|
|
275
|
-
n =
|
|
272
|
+
for (let r = 0; r <= a.length; ++r) {
|
|
273
|
+
if (r < a.length)
|
|
274
|
+
n = a.charCodeAt(r);
|
|
276
275
|
else {
|
|
277
276
|
if (n === 47)
|
|
278
277
|
break;
|
|
@@ -297,32 +296,32 @@ function te(l, t) {
|
|
|
297
296
|
}
|
|
298
297
|
t && (e.length > 0 ? e += "/.." : e = "..");
|
|
299
298
|
} else
|
|
300
|
-
e.length > 0 ? e += "/" +
|
|
299
|
+
e.length > 0 ? e += "/" + a.slice(i + 1, r) : e = a.slice(i + 1, r);
|
|
301
300
|
i = r, s = 0;
|
|
302
301
|
} else n === 46 && s !== -1 ? ++s : s = -1;
|
|
303
302
|
}
|
|
304
303
|
return e;
|
|
305
304
|
}
|
|
306
|
-
function
|
|
305
|
+
function dt(...a) {
|
|
307
306
|
let t = "", e = !1;
|
|
308
|
-
for (let i =
|
|
309
|
-
const s = i >= 0 ?
|
|
310
|
-
|
|
307
|
+
for (let i = a.length - 1; i >= -1 && !e; i--) {
|
|
308
|
+
const s = i >= 0 ? a[i] : "/";
|
|
309
|
+
U(s), s.length !== 0 && (t = s + "/" + t, e = s.charCodeAt(0) === 47);
|
|
311
310
|
}
|
|
312
|
-
return t =
|
|
311
|
+
return t = ie(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
|
|
313
312
|
}
|
|
314
|
-
function
|
|
315
|
-
if (
|
|
313
|
+
function se(a, t) {
|
|
314
|
+
if (U(a), U(t), a === t || (a = dt(a), t = dt(t), a === t))
|
|
316
315
|
return "";
|
|
317
316
|
let e = 1;
|
|
318
|
-
for (; e <
|
|
317
|
+
for (; e < a.length && a.charCodeAt(e) === 47; ++e)
|
|
319
318
|
;
|
|
320
|
-
const i =
|
|
319
|
+
const i = a.length, s = i - e;
|
|
321
320
|
let n = 1;
|
|
322
321
|
for (; n < t.length && t.charCodeAt(n) === 47; ++n)
|
|
323
322
|
;
|
|
324
323
|
const o = t.length - n, h = s < o ? s : o;
|
|
325
|
-
let
|
|
324
|
+
let l = -1, c = 0;
|
|
326
325
|
for (; c <= h; ++c) {
|
|
327
326
|
if (c === h) {
|
|
328
327
|
if (o > h) {
|
|
@@ -330,61 +329,61 @@ function ee(l, t) {
|
|
|
330
329
|
return t.slice(n + c + 1);
|
|
331
330
|
if (c === 0)
|
|
332
331
|
return t.slice(n + c);
|
|
333
|
-
} else s > h && (
|
|
332
|
+
} else s > h && (a.charCodeAt(e + c) === 47 ? l = c : c === 0 && (l = 0));
|
|
334
333
|
break;
|
|
335
334
|
}
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
335
|
+
const f = a.charCodeAt(e + c), p = t.charCodeAt(n + c);
|
|
336
|
+
if (f !== p)
|
|
338
337
|
break;
|
|
339
|
-
|
|
338
|
+
f === 47 && (l = c);
|
|
340
339
|
}
|
|
341
340
|
let d = "";
|
|
342
|
-
for (c = e +
|
|
343
|
-
(c === i ||
|
|
344
|
-
return d.length > 0 ? d + t.slice(n +
|
|
341
|
+
for (c = e + l + 1; c <= i; ++c)
|
|
342
|
+
(c === i || a.charCodeAt(c) === 47) && (d.length === 0 ? d += ".." : d += "/..");
|
|
343
|
+
return d.length > 0 ? d + t.slice(n + l) : (n += l, t.charCodeAt(n) === 47 && ++n, t.slice(n));
|
|
345
344
|
}
|
|
346
|
-
function
|
|
347
|
-
if (
|
|
345
|
+
function ne(a) {
|
|
346
|
+
if (U(a), a.length === 0)
|
|
348
347
|
return ".";
|
|
349
|
-
let t =
|
|
348
|
+
let t = a.charCodeAt(0);
|
|
350
349
|
const e = t === 47;
|
|
351
350
|
let i = -1, s = !0;
|
|
352
|
-
for (let n =
|
|
353
|
-
if (t =
|
|
351
|
+
for (let n = a.length - 1; n >= 1; --n)
|
|
352
|
+
if (t = a.charCodeAt(n), t === 47) {
|
|
354
353
|
if (!s) {
|
|
355
354
|
i = n;
|
|
356
355
|
break;
|
|
357
356
|
}
|
|
358
357
|
} else
|
|
359
358
|
s = !1;
|
|
360
|
-
return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" :
|
|
359
|
+
return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" : a.slice(0, i);
|
|
361
360
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
361
|
+
function re(a) {
|
|
362
|
+
return U(a), a.length > 0 && a.charCodeAt(0) === 47;
|
|
364
363
|
}
|
|
365
|
-
function
|
|
366
|
-
|
|
364
|
+
function oe(a) {
|
|
365
|
+
U(a);
|
|
367
366
|
const t = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
368
|
-
if (
|
|
367
|
+
if (a.length === 0)
|
|
369
368
|
return t;
|
|
370
|
-
let e =
|
|
369
|
+
let e = a.charCodeAt(0);
|
|
371
370
|
const i = e === 47;
|
|
372
371
|
let s;
|
|
373
372
|
i ? (t.root = "/", s = 1) : s = 0;
|
|
374
|
-
let n = -1, r = 0, o = -1, h = !0,
|
|
375
|
-
for (;
|
|
376
|
-
if (e =
|
|
373
|
+
let n = -1, r = 0, o = -1, h = !0, l = a.length - 1, c = 0;
|
|
374
|
+
for (; l >= s; --l) {
|
|
375
|
+
if (e = a.charCodeAt(l), e === 47) {
|
|
377
376
|
if (!h) {
|
|
378
|
-
r =
|
|
377
|
+
r = l + 1;
|
|
379
378
|
break;
|
|
380
379
|
}
|
|
381
380
|
continue;
|
|
382
381
|
}
|
|
383
|
-
o === -1 && (h = !1, o =
|
|
382
|
+
o === -1 && (h = !1, o = l + 1), e === 46 ? n === -1 ? n = l : c !== 1 && (c = 1) : n !== -1 && (c = -1);
|
|
384
383
|
}
|
|
385
|
-
return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === r + 1 ? o !== -1 && (r === 0 && i ? t.base = t.name =
|
|
384
|
+
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;
|
|
386
385
|
}
|
|
387
|
-
const
|
|
386
|
+
const z = { resolve: dt, relative: se, dirname: ne, isAbsolute: re, parse: oe };
|
|
388
387
|
class P {
|
|
389
388
|
constructor(t) {
|
|
390
389
|
t.indexOf("://") > -1 && (t = new URL(t).pathname);
|
|
@@ -397,14 +396,14 @@ class P {
|
|
|
397
396
|
* @returns {object}
|
|
398
397
|
*/
|
|
399
398
|
parse(t) {
|
|
400
|
-
return
|
|
399
|
+
return z.parse(t);
|
|
401
400
|
}
|
|
402
401
|
/**
|
|
403
402
|
* @param {string} what
|
|
404
403
|
* @returns {boolean}
|
|
405
404
|
*/
|
|
406
405
|
isAbsolute(t) {
|
|
407
|
-
return
|
|
406
|
+
return z.isAbsolute(t || this.path);
|
|
408
407
|
}
|
|
409
408
|
/**
|
|
410
409
|
* Check if path ends with a directory
|
|
@@ -422,7 +421,7 @@ class P {
|
|
|
422
421
|
* @returns {string} resolved
|
|
423
422
|
*/
|
|
424
423
|
resolve(t) {
|
|
425
|
-
return
|
|
424
|
+
return z.resolve(this.directory, t);
|
|
426
425
|
}
|
|
427
426
|
/**
|
|
428
427
|
* Resolve a path relative to the directory of the Path
|
|
@@ -432,7 +431,7 @@ class P {
|
|
|
432
431
|
* @returns {string} relative
|
|
433
432
|
*/
|
|
434
433
|
relative(t) {
|
|
435
|
-
return t && t.indexOf("://") > -1 ? t :
|
|
434
|
+
return t && t.indexOf("://") > -1 ? t : z.relative(this.directory, t);
|
|
436
435
|
}
|
|
437
436
|
/**
|
|
438
437
|
* Return the path string
|
|
@@ -442,7 +441,7 @@ class P {
|
|
|
442
441
|
return this.path;
|
|
443
442
|
}
|
|
444
443
|
}
|
|
445
|
-
class
|
|
444
|
+
class N {
|
|
446
445
|
constructor(t, e) {
|
|
447
446
|
const i = t.indexOf("://") > -1;
|
|
448
447
|
let s = t, n;
|
|
@@ -468,7 +467,7 @@ class R {
|
|
|
468
467
|
resolve(t) {
|
|
469
468
|
if (t.indexOf("://") > -1)
|
|
470
469
|
return t;
|
|
471
|
-
const i =
|
|
470
|
+
const i = z.resolve(this.directory, t);
|
|
472
471
|
return this.origin + i;
|
|
473
472
|
}
|
|
474
473
|
/**
|
|
@@ -477,7 +476,7 @@ class R {
|
|
|
477
476
|
* @returns {string} path
|
|
478
477
|
*/
|
|
479
478
|
relative(t) {
|
|
480
|
-
return
|
|
479
|
+
return z.relative(t, this.directory);
|
|
481
480
|
}
|
|
482
481
|
/**
|
|
483
482
|
* @returns {string}
|
|
@@ -486,7 +485,7 @@ class R {
|
|
|
486
485
|
return this.href;
|
|
487
486
|
}
|
|
488
487
|
}
|
|
489
|
-
const
|
|
488
|
+
const M = 1, k = 3, he = 9;
|
|
490
489
|
class m {
|
|
491
490
|
constructor(t, e, i) {
|
|
492
491
|
if (this.str = "", this.base = {}, this.spinePos = 0, this.range = !1, this.path = {}, this.start = null, this.end = null, !(this instanceof m))
|
|
@@ -510,7 +509,7 @@ class m {
|
|
|
510
509
|
* @private
|
|
511
510
|
*/
|
|
512
511
|
checkType(t) {
|
|
513
|
-
return this.isCfiString(t) ? "string" : t && typeof t == "object" && (
|
|
512
|
+
return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Qt(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof m ? "EpubCFI" : !1;
|
|
514
513
|
}
|
|
515
514
|
/**
|
|
516
515
|
* Parse a cfi string to a CFI object representation
|
|
@@ -565,7 +564,7 @@ class m {
|
|
|
565
564
|
parseTerminal(t) {
|
|
566
565
|
let e, i = null;
|
|
567
566
|
const s = t.match(/\[(.*)\]/);
|
|
568
|
-
return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t),
|
|
567
|
+
return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), E(e) || (e = null), {
|
|
569
568
|
offset: e,
|
|
570
569
|
assertion: i
|
|
571
570
|
};
|
|
@@ -617,12 +616,12 @@ class m {
|
|
|
617
616
|
if (t.spinePos < e.spinePos)
|
|
618
617
|
return -1;
|
|
619
618
|
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);
|
|
620
|
-
for (let
|
|
621
|
-
if (!i[
|
|
619
|
+
for (let l = 0; l < i.length; l++) {
|
|
620
|
+
if (!i[l])
|
|
622
621
|
return -1;
|
|
623
|
-
if (!s[
|
|
622
|
+
if (!s[l] || i[l].index > s[l].index)
|
|
624
623
|
return 1;
|
|
625
|
-
if (i[
|
|
624
|
+
if (i[l].index < s[l].index)
|
|
626
625
|
return -1;
|
|
627
626
|
}
|
|
628
627
|
if (i.length < s.length)
|
|
@@ -631,7 +630,7 @@ class m {
|
|
|
631
630
|
return o > h ? 1 : o < h ? -1 : 0;
|
|
632
631
|
}
|
|
633
632
|
step(t) {
|
|
634
|
-
const e = t.nodeType ===
|
|
633
|
+
const e = t.nodeType === k ? "text" : "element";
|
|
635
634
|
return {
|
|
636
635
|
id: t.id,
|
|
637
636
|
tagName: t.tagName,
|
|
@@ -643,7 +642,7 @@ class m {
|
|
|
643
642
|
const i = this.filter(t, e);
|
|
644
643
|
if (!i)
|
|
645
644
|
return;
|
|
646
|
-
const s = i.nodeType ===
|
|
645
|
+
const s = i.nodeType === k ? "text" : "element";
|
|
647
646
|
return {
|
|
648
647
|
id: i.id,
|
|
649
648
|
tagName: i.tagName,
|
|
@@ -660,9 +659,9 @@ class m {
|
|
|
660
659
|
}
|
|
661
660
|
};
|
|
662
661
|
let n = t, r;
|
|
663
|
-
for (; n && n.parentNode && n.parentNode.nodeType
|
|
662
|
+
for (; n && n.parentNode && n.parentNode.nodeType !== he; )
|
|
664
663
|
i ? r = this.filteredStep(n, i) : r = this.step(n), r && s.steps.unshift(r), n = n.parentNode;
|
|
665
|
-
return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type
|
|
664
|
+
return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type !== "text" && s.steps.push({
|
|
666
665
|
type: "text",
|
|
667
666
|
index: 0,
|
|
668
667
|
id: null,
|
|
@@ -688,11 +687,11 @@ class m {
|
|
|
688
687
|
end: null,
|
|
689
688
|
spinePos: 0
|
|
690
689
|
}, n = t.startContainer, r = t.endContainer;
|
|
691
|
-
let o = t.startOffset, h = t.endOffset,
|
|
692
|
-
if (i && (
|
|
693
|
-
|
|
690
|
+
let o = t.startOffset, h = t.endOffset, l = !1;
|
|
691
|
+
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)
|
|
692
|
+
l && (o = this.patchOffset(n, o, i)), s.path = this.pathTo(n, o, i);
|
|
694
693
|
else {
|
|
695
|
-
s.range = !0,
|
|
694
|
+
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 = {
|
|
696
695
|
steps: [],
|
|
697
696
|
terminal: { offset: null, assertion: null }
|
|
698
697
|
};
|
|
@@ -724,14 +723,14 @@ class m {
|
|
|
724
723
|
}
|
|
725
724
|
filter(t, e) {
|
|
726
725
|
let i, s, n, r, o, h = !1;
|
|
727
|
-
return t.nodeType ===
|
|
726
|
+
return t.nodeType === k ? (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 === k ? s = r : o && o.nodeType === k && (s = o), s || t) : i && !h ? !1 : t;
|
|
728
727
|
}
|
|
729
728
|
patchOffset(t, e, i) {
|
|
730
|
-
if (t.nodeType
|
|
729
|
+
if (t.nodeType !== k)
|
|
731
730
|
throw new Error("Anchor must be a text node");
|
|
732
731
|
let s = t, n = e;
|
|
733
732
|
for (t.parentNode.classList.contains(i) && (s = t.parentNode); s.previousSibling; ) {
|
|
734
|
-
if (s.previousSibling.nodeType ===
|
|
733
|
+
if (s.previousSibling.nodeType === M)
|
|
735
734
|
if (s.previousSibling.classList.contains(i))
|
|
736
735
|
n += (s.previousSibling.textContent ?? "").length;
|
|
737
736
|
else
|
|
@@ -746,18 +745,18 @@ class m {
|
|
|
746
745
|
const s = {};
|
|
747
746
|
let n = -1, r;
|
|
748
747
|
const o = t.length;
|
|
749
|
-
let h,
|
|
748
|
+
let h, l;
|
|
750
749
|
for (r = 0; r < o; r++)
|
|
751
|
-
h = t[r].nodeType, h ===
|
|
750
|
+
h = t[r].nodeType, h === M && t[r].classList.contains(i) && (h = k), r > 0 && h === k && l === k ? s[r] = n : e === h && (n = n + 1, s[r] = n), l = h;
|
|
752
751
|
return s;
|
|
753
752
|
}
|
|
754
753
|
position(t) {
|
|
755
754
|
let e, i;
|
|
756
|
-
return t.nodeType ===
|
|
755
|
+
return t.nodeType === M ? (e = t.parentNode.children, e || (e = yt(t.parentNode)), i = Array.from(e).indexOf(t)) : (e = this.textNodes(t.parentNode), i = e.indexOf(t)), i;
|
|
757
756
|
}
|
|
758
757
|
filteredPosition(t, e) {
|
|
759
758
|
let i, s;
|
|
760
|
-
t.nodeType ===
|
|
759
|
+
t.nodeType === M ? (i = t.parentNode.children, s = this.normalizedMap(i, M, e)) : (i = t.parentNode.childNodes, t.parentNode.classList.contains(e) && (t = t.parentNode, i = t.parentNode.childNodes), s = this.normalizedMap(i, k, e));
|
|
761
760
|
const n = Array.from(i).indexOf(t);
|
|
762
761
|
return s[n];
|
|
763
762
|
}
|
|
@@ -779,7 +778,7 @@ class m {
|
|
|
779
778
|
// Find the containing element
|
|
780
779
|
startContainerParent = doc.querySelector(query);
|
|
781
780
|
// Find the text node within that element
|
|
782
|
-
if(startContainerParent && lastStep.type
|
|
781
|
+
if(startContainerParent && lastStep.type === "text") {
|
|
783
782
|
container = startContainerParent.childNodes[lastStep.index];
|
|
784
783
|
}
|
|
785
784
|
*/
|
|
@@ -792,15 +791,15 @@ class m {
|
|
|
792
791
|
}
|
|
793
792
|
textNodes(t, e) {
|
|
794
793
|
return Array.from(t.childNodes).filter(function(i) {
|
|
795
|
-
return i.nodeType ===
|
|
794
|
+
return i.nodeType === k ? !0 : !!(e && i.classList.contains(e));
|
|
796
795
|
});
|
|
797
796
|
}
|
|
798
797
|
walkToNode(t, e, i) {
|
|
799
798
|
const s = e || document;
|
|
800
799
|
let n = s.documentElement, r, o;
|
|
801
800
|
const h = t.length;
|
|
802
|
-
let
|
|
803
|
-
for (
|
|
801
|
+
let l;
|
|
802
|
+
for (l = 0; l < h && (o = t[l], o.type === "element" ? o.id ? n = s.getElementById(o.id) : (r = n.children || yt(n), n = r[o.index]) : o.type === "text" && (n = this.textNodes(n, i)[o.index]), !!n); l++)
|
|
804
803
|
;
|
|
805
804
|
return n;
|
|
806
805
|
}
|
|
@@ -813,15 +812,15 @@ class m {
|
|
|
813
812
|
let n = this.findNode(t.slice(0, -1), i, s);
|
|
814
813
|
if (!n)
|
|
815
814
|
return { container: (i ?? document).documentElement, offset: 0 };
|
|
816
|
-
const r = n.childNodes, o = this.normalizedMap(r,
|
|
817
|
-
let h,
|
|
815
|
+
const r = n.childNodes, o = this.normalizedMap(r, k, s);
|
|
816
|
+
let h, l;
|
|
818
817
|
const c = t[t.length - 1].index;
|
|
819
818
|
for (const d in o)
|
|
820
819
|
if (o.hasOwnProperty(d) && o[d] === c)
|
|
821
|
-
if (h = r[d],
|
|
822
|
-
e = e -
|
|
820
|
+
if (h = r[d], l = (h.textContent ?? "").length, e > l)
|
|
821
|
+
e = e - l;
|
|
823
822
|
else {
|
|
824
|
-
h.nodeType ===
|
|
823
|
+
h.nodeType === M ? n = h.childNodes[0] ?? h : n = h;
|
|
825
824
|
break;
|
|
826
825
|
}
|
|
827
826
|
return {
|
|
@@ -838,15 +837,15 @@ class m {
|
|
|
838
837
|
toRange(t, e) {
|
|
839
838
|
const i = t || document;
|
|
840
839
|
let s, n, r, o, h;
|
|
841
|
-
const
|
|
840
|
+
const l = this;
|
|
842
841
|
let c, d;
|
|
843
|
-
const
|
|
842
|
+
const f = e ? i.querySelector("." + e) != null : !1;
|
|
844
843
|
let p;
|
|
845
|
-
if (typeof i.createRange < "u" ? s = i.createRange() : s = new
|
|
844
|
+
if (typeof i.createRange < "u" ? s = i.createRange() : s = new ee(), l.range ? (n = l.start, c = l.path.steps.concat(n.steps), o = this.findNode(c, i, f ? e : void 0), r = l.end, d = l.path.steps.concat(r.steps), h = this.findNode(d, i, f ? e : void 0)) : (n = l.path, c = l.path.steps, o = this.findNode(l.path.steps, i, f ? e : void 0)), o)
|
|
846
845
|
try {
|
|
847
846
|
n.terminal.offset != null ? s.setStart(o, n.terminal.offset) : s.setStart(o, 0);
|
|
848
847
|
} catch {
|
|
849
|
-
p = this.fixMiss(c, n.terminal.offset, i,
|
|
848
|
+
p = this.fixMiss(c, n.terminal.offset, i, f ? e : void 0), s.setStart(p.container, p.offset);
|
|
850
849
|
}
|
|
851
850
|
else
|
|
852
851
|
return console.log("No startContainer found for", this.toString()), null;
|
|
@@ -854,7 +853,7 @@ class m {
|
|
|
854
853
|
try {
|
|
855
854
|
r.terminal.offset != null ? s.setEnd(h, r.terminal.offset) : s.setEnd(h, 0);
|
|
856
855
|
} catch {
|
|
857
|
-
p = this.fixMiss(d,
|
|
856
|
+
p = this.fixMiss(d, l.end.terminal.offset, i, f ? e : void 0), s.setEnd(p.container, p.offset);
|
|
858
857
|
}
|
|
859
858
|
return s;
|
|
860
859
|
}
|
|
@@ -879,7 +878,7 @@ class m {
|
|
|
879
878
|
this.range && (this.range = !1, t ? (this.path.steps = this.path.steps.concat(this.start.steps), this.path.terminal = this.start.terminal) : (this.path.steps = this.path.steps.concat(this.end.steps), this.path.terminal = this.end.terminal));
|
|
880
879
|
}
|
|
881
880
|
}
|
|
882
|
-
class
|
|
881
|
+
class R {
|
|
883
882
|
constructor(t) {
|
|
884
883
|
this.context = t || this, this.hooks = [];
|
|
885
884
|
}
|
|
@@ -933,35 +932,35 @@ class N {
|
|
|
933
932
|
return this.hooks = [];
|
|
934
933
|
}
|
|
935
934
|
}
|
|
936
|
-
function
|
|
935
|
+
function At(a, t) {
|
|
937
936
|
let e, i = t.url;
|
|
938
937
|
const s = i.indexOf("://") > -1;
|
|
939
|
-
if (!
|
|
938
|
+
if (!a)
|
|
940
939
|
return;
|
|
941
|
-
const n =
|
|
942
|
-
e =
|
|
940
|
+
const n = w(a, "head");
|
|
941
|
+
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);
|
|
943
942
|
}
|
|
944
|
-
function
|
|
943
|
+
function ae(a, t) {
|
|
945
944
|
let e;
|
|
946
945
|
const i = t.canonical;
|
|
947
|
-
if (!
|
|
946
|
+
if (!a)
|
|
948
947
|
return;
|
|
949
|
-
const s =
|
|
950
|
-
e =
|
|
948
|
+
const s = w(a, "head");
|
|
949
|
+
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));
|
|
951
950
|
}
|
|
952
|
-
function
|
|
951
|
+
function le(a, t) {
|
|
953
952
|
let e;
|
|
954
953
|
const i = t.idref;
|
|
955
|
-
if (!
|
|
954
|
+
if (!a)
|
|
956
955
|
return;
|
|
957
|
-
const s =
|
|
958
|
-
e =
|
|
956
|
+
const s = w(a, "head");
|
|
957
|
+
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));
|
|
959
958
|
}
|
|
960
|
-
function
|
|
961
|
-
const e =
|
|
959
|
+
function ce(a, t) {
|
|
960
|
+
const e = a.querySelectorAll("a[href]");
|
|
962
961
|
if (!e.length)
|
|
963
962
|
return;
|
|
964
|
-
const i =
|
|
963
|
+
const i = w(a.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
|
|
965
964
|
const o = r.getAttribute("href") ?? "";
|
|
966
965
|
if (o.indexOf("mailto:") === 0)
|
|
967
966
|
return;
|
|
@@ -975,7 +974,7 @@ function le(l, t) {
|
|
|
975
974
|
else {
|
|
976
975
|
let c;
|
|
977
976
|
try {
|
|
978
|
-
c = new
|
|
977
|
+
c = new N(o, s);
|
|
979
978
|
} catch {
|
|
980
979
|
}
|
|
981
980
|
r.onclick = function() {
|
|
@@ -986,105 +985,86 @@ function le(l, t) {
|
|
|
986
985
|
for (let r = 0; r < e.length; r++)
|
|
987
986
|
n(e[r]);
|
|
988
987
|
}
|
|
989
|
-
function
|
|
988
|
+
function bt(a, t, e) {
|
|
990
989
|
const i = /* @__PURE__ */ new Map(), s = [], n = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
|
991
990
|
for (let o = 0; o < t.length; o++) {
|
|
992
|
-
const h = t[o],
|
|
993
|
-
if (!h || !
|
|
991
|
+
const h = t[o], l = e[o];
|
|
992
|
+
if (!h || !l) continue;
|
|
994
993
|
const c = h.replace(n, "\\$&");
|
|
995
|
-
i.set(h,
|
|
994
|
+
i.set(h, l), s.push(c);
|
|
996
995
|
try {
|
|
997
996
|
const d = decodeURIComponent(h);
|
|
998
997
|
if (d !== h) {
|
|
999
|
-
const
|
|
1000
|
-
i.set(d,
|
|
998
|
+
const f = d.replace(n, "\\$&");
|
|
999
|
+
i.set(d, l), s.push(f);
|
|
1001
1000
|
}
|
|
1002
1001
|
} catch {
|
|
1003
1002
|
}
|
|
1004
1003
|
}
|
|
1005
|
-
if (s.length === 0) return
|
|
1004
|
+
if (s.length === 0) return a;
|
|
1006
1005
|
s.sort((o, h) => h.length - o.length);
|
|
1007
1006
|
const r = new RegExp(s.join("|"), "g");
|
|
1008
|
-
return
|
|
1007
|
+
return a.replace(r, (o) => i.get(o) ?? o);
|
|
1009
1008
|
}
|
|
1010
|
-
function V(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
e && (
|
|
1014
|
-
|
|
1015
|
-
o.
|
|
1016
|
-
t == "json" && o.setRequestHeader("Accept", "application/json"), t || (t = new P(l).extension), t == "blob" && (o.responseType = n), K(t) && o.overrideMimeType("text/xml"), t == "binary" && (o.responseType = "arraybuffer"), o.send();
|
|
1017
|
-
function a(d) {
|
|
1018
|
-
r.reject(d);
|
|
1019
|
-
}
|
|
1020
|
-
function c() {
|
|
1021
|
-
if (o.readyState === XMLHttpRequest.DONE) {
|
|
1022
|
-
let d = !1;
|
|
1023
|
-
if ((o.responseType === "" || o.responseType === "document") && (d = o.responseXML), o.status === 200 || o.status === 0 || d) {
|
|
1024
|
-
let u;
|
|
1025
|
-
if (!o.response && !d)
|
|
1026
|
-
return r.reject({
|
|
1027
|
-
status: o.status,
|
|
1028
|
-
message: "Empty Response",
|
|
1029
|
-
stack: new Error().stack
|
|
1030
|
-
}), r.promise;
|
|
1031
|
-
if (o.status === 403)
|
|
1032
|
-
return r.reject({
|
|
1033
|
-
status: o.status,
|
|
1034
|
-
response: o.response,
|
|
1035
|
-
message: "Forbidden",
|
|
1036
|
-
stack: new Error().stack
|
|
1037
|
-
}), r.promise;
|
|
1038
|
-
d ? u = o.responseXML : K(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);
|
|
1039
|
-
} else
|
|
1040
|
-
r.reject({
|
|
1041
|
-
status: o.status,
|
|
1042
|
-
message: o.response,
|
|
1043
|
-
stack: new Error().stack
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1009
|
+
async function V(a, t, e, i) {
|
|
1010
|
+
t || (t = new P(a).extension);
|
|
1011
|
+
const s = {};
|
|
1012
|
+
if (e && (s.credentials = "include"), i || t === "json") {
|
|
1013
|
+
const o = new Headers(i);
|
|
1014
|
+
t === "json" && o.set("Accept", "application/json"), s.headers = o;
|
|
1046
1015
|
}
|
|
1047
|
-
|
|
1016
|
+
let n;
|
|
1017
|
+
try {
|
|
1018
|
+
n = await fetch(a, s);
|
|
1019
|
+
} catch (o) {
|
|
1020
|
+
throw new q(o.message || "Network Error", 0);
|
|
1021
|
+
}
|
|
1022
|
+
if (!n.ok) {
|
|
1023
|
+
const o = await n.text().catch(() => "");
|
|
1024
|
+
throw new q(o || n.statusText, n.status);
|
|
1025
|
+
}
|
|
1026
|
+
if (t === "blob") {
|
|
1027
|
+
const o = await n.blob();
|
|
1028
|
+
return o instanceof Blob ? o : new Blob([o], { type: o.type });
|
|
1029
|
+
}
|
|
1030
|
+
if (t === "binary")
|
|
1031
|
+
return n.arrayBuffer();
|
|
1032
|
+
if (t === "json")
|
|
1033
|
+
return n.json();
|
|
1034
|
+
const r = await n.text();
|
|
1035
|
+
return Lt(t) ? W(r, "text/xml") : t === "xhtml" ? W(r, "application/xhtml+xml") : t === "html" || t === "htm" ? W(r, "text/html") : r;
|
|
1048
1036
|
}
|
|
1049
|
-
class
|
|
1037
|
+
class de {
|
|
1050
1038
|
constructor(t, e) {
|
|
1051
|
-
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
|
|
1039
|
+
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 R(this), this.hooks.content = new R(this)), this.document = void 0, this.contents = void 0, this.output = void 0;
|
|
1052
1040
|
}
|
|
1053
1041
|
/**
|
|
1054
1042
|
* Load the section from its url
|
|
1055
1043
|
* @param {method} [_request] a request method to use for loading
|
|
1056
1044
|
* @return {document} a promise with the xml document
|
|
1057
1045
|
*/
|
|
1058
|
-
load(t) {
|
|
1059
|
-
const e = t || this.request || V
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}), s;
|
|
1046
|
+
async load(t) {
|
|
1047
|
+
const e = t || this.request || V;
|
|
1048
|
+
if (this.contents)
|
|
1049
|
+
return this.contents;
|
|
1050
|
+
const i = await e(this.url);
|
|
1051
|
+
return this.document = i, this.contents = i.documentElement, await this.hooks.content.trigger(this.document, this), this.contents;
|
|
1065
1052
|
}
|
|
1066
1053
|
/**
|
|
1067
1054
|
* Adds a base tag for resolving urls in the section
|
|
1068
1055
|
* @private
|
|
1069
1056
|
*/
|
|
1070
1057
|
base() {
|
|
1071
|
-
return
|
|
1058
|
+
return At(this.document, this);
|
|
1072
1059
|
}
|
|
1073
1060
|
/**
|
|
1074
1061
|
* Render the contents of a section
|
|
1075
1062
|
* @param {method} [_request] a request method to use for loading
|
|
1076
1063
|
* @return {string} output a serialized XML Document
|
|
1077
1064
|
*/
|
|
1078
|
-
render(t) {
|
|
1079
|
-
const e =
|
|
1080
|
-
return this.
|
|
1081
|
-
const n = new XMLSerializer();
|
|
1082
|
-
return this.output = n.serializeToString(s), this.output;
|
|
1083
|
-
}).then(() => this.hooks.serialize.trigger(this.output, this)).then(() => {
|
|
1084
|
-
e.resolve(this.output);
|
|
1085
|
-
}).catch(function(s) {
|
|
1086
|
-
e.reject(s);
|
|
1087
|
-
}), i;
|
|
1065
|
+
async render(t) {
|
|
1066
|
+
const e = await this.load(t), i = new XMLSerializer();
|
|
1067
|
+
return this.output = i.serializeToString(e), await this.hooks.serialize.trigger(this.output, this), this.output;
|
|
1088
1068
|
}
|
|
1089
1069
|
/**
|
|
1090
1070
|
* Find a string in a section
|
|
@@ -1094,15 +1074,15 @@ class ae {
|
|
|
1094
1074
|
find(t) {
|
|
1095
1075
|
const e = this, i = [], s = t.toLowerCase(), n = function(r) {
|
|
1096
1076
|
const o = r.textContent.toLowerCase();
|
|
1097
|
-
let h,
|
|
1077
|
+
let h, l, c, d = -1, f;
|
|
1098
1078
|
const p = 150;
|
|
1099
|
-
for (; c
|
|
1100
|
-
c = o.indexOf(s, d + 1), c
|
|
1101
|
-
cfi:
|
|
1102
|
-
excerpt:
|
|
1079
|
+
for (; c !== -1; )
|
|
1080
|
+
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 ? f = r.textContent : (f = r.textContent.substring(c - p / 2, c + p / 2), f = "..." + f + "..."), i.push({
|
|
1081
|
+
cfi: l,
|
|
1082
|
+
excerpt: f
|
|
1103
1083
|
})), d = c;
|
|
1104
1084
|
};
|
|
1105
|
-
return
|
|
1085
|
+
return lt(e.document, function(r) {
|
|
1106
1086
|
n(r);
|
|
1107
1087
|
}), i;
|
|
1108
1088
|
}
|
|
@@ -1114,29 +1094,29 @@ class ae {
|
|
|
1114
1094
|
*/
|
|
1115
1095
|
search(t, e = 5) {
|
|
1116
1096
|
const i = [], n = this, r = t.toLowerCase(), o = function(d) {
|
|
1117
|
-
const g = d.reduce((
|
|
1118
|
-
if (g
|
|
1119
|
-
const
|
|
1120
|
-
let
|
|
1097
|
+
const g = d.reduce((v, y) => v + (y.textContent ?? ""), "").toLowerCase().indexOf(r);
|
|
1098
|
+
if (g !== -1) {
|
|
1099
|
+
const y = g + r.length;
|
|
1100
|
+
let b = 0, T = 0;
|
|
1121
1101
|
if (g < d[0].length) {
|
|
1122
|
-
for (;
|
|
1123
|
-
|
|
1124
|
-
const
|
|
1125
|
-
I.setStart(
|
|
1126
|
-
const Y = d.slice(0,
|
|
1127
|
-
I.setEnd(
|
|
1128
|
-
const
|
|
1129
|
-
let
|
|
1130
|
-
|
|
1131
|
-
cfi:
|
|
1132
|
-
excerpt:
|
|
1102
|
+
for (; b < d.length - 1 && (T += d[b].length, !(y <= T)); )
|
|
1103
|
+
b += 1;
|
|
1104
|
+
const x = d[0], S = d[b], I = n.document.createRange();
|
|
1105
|
+
I.setStart(x, g);
|
|
1106
|
+
const Y = d.slice(0, b).reduce((Z, Q) => Z + (Q.textContent ?? "").length, 0);
|
|
1107
|
+
I.setEnd(S, Y > y ? y : y - Y);
|
|
1108
|
+
const D = n.cfiFromRange(I);
|
|
1109
|
+
let O = d.slice(0, b + 1).reduce((Z, Q) => Z + (Q.textContent ?? ""), "");
|
|
1110
|
+
O.length > 150 && (O = O.substring(g - 150 / 2, g + 150 / 2), O = "..." + O + "..."), i.push({
|
|
1111
|
+
cfi: D,
|
|
1112
|
+
excerpt: O
|
|
1133
1113
|
});
|
|
1134
1114
|
}
|
|
1135
1115
|
}
|
|
1136
1116
|
}, h = document.createTreeWalker(n.document, NodeFilter.SHOW_TEXT, null);
|
|
1137
|
-
let
|
|
1138
|
-
for (;
|
|
1139
|
-
c.push(
|
|
1117
|
+
let l, c = [];
|
|
1118
|
+
for (; l = h.nextNode(); )
|
|
1119
|
+
c.push(l), c.length === e && (o(c.slice(0, e)), c = c.slice(1, e));
|
|
1140
1120
|
return c.length > 0 && o(c), i;
|
|
1141
1121
|
}
|
|
1142
1122
|
/**
|
|
@@ -1154,7 +1134,7 @@ class ae {
|
|
|
1154
1134
|
return this.properties.forEach(function(i) {
|
|
1155
1135
|
const s = i.replace("rendition:", ""), n = s.indexOf("-");
|
|
1156
1136
|
let r, o;
|
|
1157
|
-
n
|
|
1137
|
+
n !== -1 && (r = s.slice(0, n), o = s.slice(n + 1), e[r] = o);
|
|
1158
1138
|
}), e;
|
|
1159
1139
|
}
|
|
1160
1140
|
/**
|
|
@@ -1183,9 +1163,9 @@ class ae {
|
|
|
1183
1163
|
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;
|
|
1184
1164
|
}
|
|
1185
1165
|
}
|
|
1186
|
-
class
|
|
1166
|
+
class ue {
|
|
1187
1167
|
constructor() {
|
|
1188
|
-
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new
|
|
1168
|
+
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new R(), this.hooks.content = new R(), this.hooks.content.register(At), this.hooks.content.register(ae), this.hooks.content.register(le), this.epubcfi = new m(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
|
|
1189
1169
|
}
|
|
1190
1170
|
/**
|
|
1191
1171
|
* Unpack items from a opf into spine items
|
|
@@ -1199,23 +1179,23 @@ class ce {
|
|
|
1199
1179
|
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 = () => {
|
|
1200
1180
|
let h = s.index;
|
|
1201
1181
|
for (; h > 0; ) {
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
return
|
|
1182
|
+
const l = this.get(h - 1);
|
|
1183
|
+
if (l && l.linear)
|
|
1184
|
+
return l;
|
|
1205
1185
|
h -= 1;
|
|
1206
1186
|
}
|
|
1207
1187
|
}, s.next = () => {
|
|
1208
1188
|
let h = s.index;
|
|
1209
1189
|
for (; h < this.spineItems.length - 1; ) {
|
|
1210
|
-
const
|
|
1211
|
-
if (
|
|
1212
|
-
return
|
|
1190
|
+
const l = this.get(h + 1);
|
|
1191
|
+
if (l && l.linear)
|
|
1192
|
+
return l;
|
|
1213
1193
|
h += 1;
|
|
1214
1194
|
}
|
|
1215
1195
|
}) : (s.prev = function() {
|
|
1216
1196
|
}, s.next = function() {
|
|
1217
1197
|
});
|
|
1218
|
-
const o = new
|
|
1198
|
+
const o = new de(s, this.hooks);
|
|
1219
1199
|
this.append(o);
|
|
1220
1200
|
}), this.loaded = !0;
|
|
1221
1201
|
}
|
|
@@ -1309,16 +1289,16 @@ class ce {
|
|
|
1309
1289
|
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;
|
|
1310
1290
|
}
|
|
1311
1291
|
}
|
|
1312
|
-
class
|
|
1292
|
+
class pt {
|
|
1313
1293
|
constructor(t) {
|
|
1314
|
-
this._q = [], this.context = t, this.tick =
|
|
1294
|
+
this._q = [], this.context = t, this.tick = Vt, this.running = !1, this.paused = !1;
|
|
1315
1295
|
}
|
|
1316
1296
|
enqueue(...t) {
|
|
1317
1297
|
let e, i, s;
|
|
1318
1298
|
const [n, ...r] = t;
|
|
1319
1299
|
if (!n)
|
|
1320
1300
|
throw new Error("No Task Provided");
|
|
1321
|
-
return typeof n == "function" ? (e = new
|
|
1301
|
+
return typeof n == "function" ? (e = new C(), i = e.promise, s = {
|
|
1322
1302
|
task: n,
|
|
1323
1303
|
args: r,
|
|
1324
1304
|
//"context" : context,
|
|
@@ -1327,7 +1307,7 @@ class mt {
|
|
|
1327
1307
|
}) : s = {
|
|
1328
1308
|
args: [],
|
|
1329
1309
|
promise: n
|
|
1330
|
-
}, this._q.push(s), this.paused
|
|
1310
|
+
}, this._q.push(s), !this.paused && !this.running && this.run(), s.promise;
|
|
1331
1311
|
}
|
|
1332
1312
|
/**
|
|
1333
1313
|
* Run one item
|
|
@@ -1351,13 +1331,13 @@ class mt {
|
|
|
1351
1331
|
* @return {Promise}
|
|
1352
1332
|
*/
|
|
1353
1333
|
run() {
|
|
1354
|
-
this.running || (this.running = !0, this.defered = new
|
|
1334
|
+
this.running || (this.running = !0, this.defered = new C());
|
|
1355
1335
|
const t = () => {
|
|
1356
1336
|
this._q.length ? this.dequeue()?.then(() => {
|
|
1357
1337
|
this.run();
|
|
1358
1338
|
}) : (this.defered.resolve(), this.running = void 0);
|
|
1359
1339
|
};
|
|
1360
|
-
return this.tick
|
|
1340
|
+
return this.tick(t), this.paused && (this.paused = !1), this.defered.promise;
|
|
1361
1341
|
}
|
|
1362
1342
|
/**
|
|
1363
1343
|
* Flush all, as quickly as possible
|
|
@@ -1395,7 +1375,7 @@ class mt {
|
|
|
1395
1375
|
this._q = [], this.running = !1, this.paused = !0;
|
|
1396
1376
|
}
|
|
1397
1377
|
}
|
|
1398
|
-
const
|
|
1378
|
+
const It = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], u = {
|
|
1399
1379
|
BOOK: {
|
|
1400
1380
|
OPEN_FAILED: "openFailed"
|
|
1401
1381
|
},
|
|
@@ -1452,9 +1432,9 @@ const Nt = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
|
|
|
1452
1432
|
DETACH: "detach"
|
|
1453
1433
|
}
|
|
1454
1434
|
};
|
|
1455
|
-
class
|
|
1435
|
+
class Pt {
|
|
1456
1436
|
constructor(t, e, i) {
|
|
1457
|
-
this.spine = t, this.request = e, this.pause = i || 0, this.q = new
|
|
1437
|
+
this.spine = t, this.request = e, this.pause = i || 0, this.q = new pt(this), this.q.tick = _t, this.epubcfi = new m(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
|
|
1458
1438
|
}
|
|
1459
1439
|
/**
|
|
1460
1440
|
* Load all of sections in the book to generate locations
|
|
@@ -1474,36 +1454,36 @@ class At {
|
|
|
1474
1454
|
endOffset: void 0
|
|
1475
1455
|
};
|
|
1476
1456
|
}
|
|
1477
|
-
process(t) {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1457
|
+
async process(t) {
|
|
1458
|
+
const e = await t.load(this.request), i = this.parse(e, t.cfiBase);
|
|
1459
|
+
return this._locations = this._locations.concat(i), t.unload(), new Promise((s) => {
|
|
1460
|
+
this.processingTimeout = setTimeout(() => s(i), this.pause);
|
|
1481
1461
|
});
|
|
1482
1462
|
}
|
|
1483
1463
|
parse(t, e, i) {
|
|
1484
1464
|
const s = [];
|
|
1485
1465
|
let n;
|
|
1486
|
-
const r = t.ownerDocument, o =
|
|
1487
|
-
let h = 0,
|
|
1466
|
+
const r = t.ownerDocument, o = w(r, "body");
|
|
1467
|
+
let h = 0, l;
|
|
1488
1468
|
const c = i || this.break;
|
|
1489
|
-
if (
|
|
1490
|
-
const p =
|
|
1491
|
-
let g,
|
|
1492
|
-
if ((
|
|
1493
|
-
return
|
|
1494
|
-
for (h === 0 && (n = this.createRange(), n.startContainer =
|
|
1495
|
-
if (g = c - h, h === 0 && (
|
|
1496
|
-
h += p -
|
|
1469
|
+
if (lt(o, (f) => {
|
|
1470
|
+
const p = f.length;
|
|
1471
|
+
let g, v = 0;
|
|
1472
|
+
if ((f.textContent ?? "").trim().length === 0)
|
|
1473
|
+
return l = f, !1;
|
|
1474
|
+
for (h === 0 && (n = this.createRange(), n.startContainer = f, n.startOffset = 0), g = c - h, g > p && (h += p, v = p); v < p; )
|
|
1475
|
+
if (g = c - h, h === 0 && (v += 1, n = this.createRange(), n.startContainer = f, n.startOffset = v), v + g >= p)
|
|
1476
|
+
h += p - v, v = p;
|
|
1497
1477
|
else {
|
|
1498
|
-
|
|
1499
|
-
const
|
|
1500
|
-
s.push(
|
|
1478
|
+
v += g, n.endContainer = f, n.endOffset = v;
|
|
1479
|
+
const y = new m(n, e).toString();
|
|
1480
|
+
s.push(y), h = 0;
|
|
1501
1481
|
}
|
|
1502
|
-
return
|
|
1503
|
-
}), n && n.startContainer &&
|
|
1504
|
-
n.endContainer =
|
|
1505
|
-
const
|
|
1506
|
-
s.push(
|
|
1482
|
+
return l = f, !1;
|
|
1483
|
+
}), n && n.startContainer && l) {
|
|
1484
|
+
n.endContainer = l, n.endOffset = l.length;
|
|
1485
|
+
const f = new m(n, e).toString();
|
|
1486
|
+
s.push(f), h = 0;
|
|
1507
1487
|
}
|
|
1508
1488
|
return s;
|
|
1509
1489
|
}
|
|
@@ -1517,13 +1497,15 @@ class At {
|
|
|
1517
1497
|
generateFromWords(t, e, i) {
|
|
1518
1498
|
const s = t ? new m(t) : void 0;
|
|
1519
1499
|
return this.q.pause(), this._locationsWords = [], this._wordCounter = 0, this.spine.each((n) => {
|
|
1520
|
-
n.linear && (s ? n.index >= s.spinePos && this.q.enqueue((r, o, h,
|
|
1500
|
+
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));
|
|
1521
1501
|
}), this.q.run().then(() => (this._currentCfi && (this.currentLocation = this._currentCfi), this._locationsWords));
|
|
1522
1502
|
}
|
|
1523
|
-
processWords(t, e, i, s) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1503
|
+
async processWords(t, e, i, s) {
|
|
1504
|
+
if (s && this._locationsWords.length >= s)
|
|
1505
|
+
return [];
|
|
1506
|
+
const n = await t.load(this.request), r = this.parseWords(n, t, e, i), o = s - this._locationsWords.length;
|
|
1507
|
+
return this._locationsWords = this._locationsWords.concat(r.length >= s ? r.slice(0, o) : r), t.unload(), new Promise((h) => {
|
|
1508
|
+
this.processingTimeout = setTimeout(() => h(r), this.pause);
|
|
1527
1509
|
});
|
|
1528
1510
|
}
|
|
1529
1511
|
//http://stackoverflow.com/questions/18679576/counting-words-in-string
|
|
@@ -1532,9 +1514,9 @@ class At {
|
|
|
1532
1514
|
`), t.split(" ").length;
|
|
1533
1515
|
}
|
|
1534
1516
|
parseWords(t, e, i, s) {
|
|
1535
|
-
const n = e.cfiBase, r = [], o = t.ownerDocument, h =
|
|
1517
|
+
const n = e.cfiBase, r = [], o = t.ownerDocument, h = w(o, "body"), l = i;
|
|
1536
1518
|
let c = s ? s.spinePos !== e.index : !0, d;
|
|
1537
|
-
return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)),
|
|
1519
|
+
return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), lt(h, (p) => {
|
|
1538
1520
|
if (!c)
|
|
1539
1521
|
if (p === d)
|
|
1540
1522
|
c = !0;
|
|
@@ -1543,16 +1525,16 @@ class At {
|
|
|
1543
1525
|
if ((p.textContent ?? "").length < 10 && (p.textContent ?? "").trim().length === 0)
|
|
1544
1526
|
return !1;
|
|
1545
1527
|
const g = this.countWords(p.textContent ?? "");
|
|
1546
|
-
let
|
|
1528
|
+
let v, y = 0;
|
|
1547
1529
|
if (g === 0)
|
|
1548
1530
|
return !1;
|
|
1549
|
-
for (
|
|
1550
|
-
if (
|
|
1551
|
-
this._wordCounter += g -
|
|
1531
|
+
for (v = l - this._wordCounter, v > g && (this._wordCounter += g, y = g); y < g; )
|
|
1532
|
+
if (v = l - this._wordCounter, y + v >= g)
|
|
1533
|
+
this._wordCounter += g - y, y = g;
|
|
1552
1534
|
else {
|
|
1553
|
-
|
|
1554
|
-
const
|
|
1555
|
-
r.push({ cfi:
|
|
1535
|
+
y += v;
|
|
1536
|
+
const b = new m(p, n);
|
|
1537
|
+
r.push({ cfi: b.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
|
|
1556
1538
|
}
|
|
1557
1539
|
return !1;
|
|
1558
1540
|
}), r;
|
|
@@ -1634,7 +1616,7 @@ class At {
|
|
|
1634
1616
|
this._current = t;
|
|
1635
1617
|
else
|
|
1636
1618
|
return;
|
|
1637
|
-
this._locations.length !== 0 && (typeof t == "string" ? (e = this.locationFromCfi(t), this._current = e) : e = t, this.emit(
|
|
1619
|
+
this._locations.length !== 0 && (typeof t == "string" ? (e = this.locationFromCfi(t), this._current = e) : e = t, this.emit(u.LOCATIONS.CHANGED, {
|
|
1638
1620
|
percentage: this.percentageFromLocation(e)
|
|
1639
1621
|
}));
|
|
1640
1622
|
}
|
|
@@ -1660,8 +1642,8 @@ class At {
|
|
|
1660
1642
|
this.spine = void 0, this.request = void 0, this.pause = void 0, this.q?.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);
|
|
1661
1643
|
}
|
|
1662
1644
|
}
|
|
1663
|
-
A(
|
|
1664
|
-
class
|
|
1645
|
+
A(Pt.prototype);
|
|
1646
|
+
class fe {
|
|
1665
1647
|
constructor(t) {
|
|
1666
1648
|
this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
|
|
1667
1649
|
}
|
|
@@ -1672,16 +1654,16 @@ class de {
|
|
|
1672
1654
|
parse(t) {
|
|
1673
1655
|
if (!t)
|
|
1674
1656
|
throw new Error("Container File Not Found");
|
|
1675
|
-
const e =
|
|
1657
|
+
const e = w(t, "rootfile");
|
|
1676
1658
|
if (!e)
|
|
1677
1659
|
throw new Error("No RootFile Found");
|
|
1678
|
-
this.packagePath = e.getAttribute("full-path") ?? "", this.directory =
|
|
1660
|
+
this.packagePath = e.getAttribute("full-path") ?? "", this.directory = z.dirname(this.packagePath), this.encoding = t.xmlEncoding;
|
|
1679
1661
|
}
|
|
1680
1662
|
destroy() {
|
|
1681
1663
|
this.packagePath = void 0, this.directory = void 0, this.encoding = void 0;
|
|
1682
1664
|
}
|
|
1683
1665
|
}
|
|
1684
|
-
class
|
|
1666
|
+
class xt {
|
|
1685
1667
|
constructor(t) {
|
|
1686
1668
|
this.manifest = {}, this.navPath = "", this.ncxPath = "", this.coverPath = "", this.spineNodeIndex = 0, this.spine = [], this.metadata = {}, t && this.parse(t);
|
|
1687
1669
|
}
|
|
@@ -1693,16 +1675,16 @@ class Et {
|
|
|
1693
1675
|
parse(t) {
|
|
1694
1676
|
if (!t)
|
|
1695
1677
|
throw new Error("Package File Not Found");
|
|
1696
|
-
const e =
|
|
1678
|
+
const e = w(t, "metadata");
|
|
1697
1679
|
if (!e)
|
|
1698
1680
|
throw new Error("No Metadata Found");
|
|
1699
|
-
const i =
|
|
1681
|
+
const i = w(t, "manifest");
|
|
1700
1682
|
if (!i)
|
|
1701
1683
|
throw new Error("No Manifest Found");
|
|
1702
|
-
const s =
|
|
1684
|
+
const s = w(t, "spine");
|
|
1703
1685
|
if (!s)
|
|
1704
1686
|
throw new Error("No Spine Found");
|
|
1705
|
-
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex =
|
|
1687
|
+
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Kt(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") ?? "", {
|
|
1706
1688
|
metadata: this.metadata,
|
|
1707
1689
|
spine: this.spine,
|
|
1708
1690
|
manifest: this.manifest,
|
|
@@ -1729,14 +1711,14 @@ class Et {
|
|
|
1729
1711
|
* @return {object} manifest
|
|
1730
1712
|
*/
|
|
1731
1713
|
parseManifest(t) {
|
|
1732
|
-
const e = {}, i =
|
|
1714
|
+
const e = {}, i = B(t, "item");
|
|
1733
1715
|
return Array.from(i).forEach(function(n) {
|
|
1734
|
-
const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "",
|
|
1716
|
+
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") || "";
|
|
1735
1717
|
e[r] = {
|
|
1736
1718
|
href: o,
|
|
1737
1719
|
// "url" : href,
|
|
1738
1720
|
type: h,
|
|
1739
|
-
overlay:
|
|
1721
|
+
overlay: l,
|
|
1740
1722
|
properties: c.length ? c.split(" ") : [],
|
|
1741
1723
|
fallback: d
|
|
1742
1724
|
};
|
|
@@ -1750,9 +1732,9 @@ class Et {
|
|
|
1750
1732
|
* @return {object} spine
|
|
1751
1733
|
*/
|
|
1752
1734
|
parseSpine(t, e) {
|
|
1753
|
-
const i = [], s =
|
|
1735
|
+
const i = [], s = B(t, "itemref");
|
|
1754
1736
|
return Array.from(s).forEach(function(r, o) {
|
|
1755
|
-
const h = r.getAttribute("idref"),
|
|
1737
|
+
const h = r.getAttribute("idref"), l = r.getAttribute("properties") || "", c = l.length ? l.split(" ") : [], d = {
|
|
1756
1738
|
id: r.getAttribute("id") ?? void 0,
|
|
1757
1739
|
idref: h,
|
|
1758
1740
|
linear: r.getAttribute("linear") || "yes",
|
|
@@ -1809,7 +1791,7 @@ class Et {
|
|
|
1809
1791
|
* @return {string} href
|
|
1810
1792
|
*/
|
|
1811
1793
|
findCoverPath(t) {
|
|
1812
|
-
|
|
1794
|
+
w(t, "package")?.getAttribute("version");
|
|
1813
1795
|
const i = j(t, "item", { properties: "cover-image" });
|
|
1814
1796
|
if (i) return i.getAttribute("href") ?? "";
|
|
1815
1797
|
const s = j(t, "meta", { name: "cover" });
|
|
@@ -1868,7 +1850,7 @@ class Et {
|
|
|
1868
1850
|
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;
|
|
1869
1851
|
}
|
|
1870
1852
|
}
|
|
1871
|
-
class
|
|
1853
|
+
class tt {
|
|
1872
1854
|
constructor(t) {
|
|
1873
1855
|
this.toc = [], this.tocByHref = {}, this.tocById = {}, this.landmarks = [], this.landmarksByType = {}, this.length = 0, t && this.parse(t);
|
|
1874
1856
|
}
|
|
@@ -1879,7 +1861,7 @@ class et {
|
|
|
1879
1861
|
parse(t) {
|
|
1880
1862
|
const e = t.nodeType;
|
|
1881
1863
|
let i, s;
|
|
1882
|
-
e && (i =
|
|
1864
|
+
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);
|
|
1883
1865
|
}
|
|
1884
1866
|
/**
|
|
1885
1867
|
* Unpack navigation items
|
|
@@ -1939,7 +1921,7 @@ class et {
|
|
|
1939
1921
|
* @return {array} navigation list
|
|
1940
1922
|
*/
|
|
1941
1923
|
parseNav(t) {
|
|
1942
|
-
const e =
|
|
1924
|
+
const e = ct(t, "nav", "toc");
|
|
1943
1925
|
let i = [];
|
|
1944
1926
|
if (!e) return i;
|
|
1945
1927
|
const s = F(e, "ol");
|
|
@@ -1991,7 +1973,7 @@ class et {
|
|
|
1991
1973
|
* @return {array} landmarks list
|
|
1992
1974
|
*/
|
|
1993
1975
|
parseLandmarks(t) {
|
|
1994
|
-
const e =
|
|
1976
|
+
const e = ct(t, "nav", "landmarks"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
1995
1977
|
let n;
|
|
1996
1978
|
const r = [];
|
|
1997
1979
|
let o;
|
|
@@ -2024,7 +2006,7 @@ class et {
|
|
|
2024
2006
|
* @return {array} navigation list
|
|
2025
2007
|
*/
|
|
2026
2008
|
parseNcx(t) {
|
|
2027
|
-
const e =
|
|
2009
|
+
const e = B(t, "navPoint"), i = e.length;
|
|
2028
2010
|
let s;
|
|
2029
2011
|
const n = {}, r = [];
|
|
2030
2012
|
let o, h;
|
|
@@ -2040,14 +2022,14 @@ class et {
|
|
|
2040
2022
|
* @return {object} ncxItem
|
|
2041
2023
|
*/
|
|
2042
2024
|
ncxItem(t) {
|
|
2043
|
-
const e = t.getAttribute("id") || "", i =
|
|
2044
|
-
let
|
|
2045
|
-
return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (
|
|
2025
|
+
const e = t.getAttribute("id") || "", i = w(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = w(t, "navLabel"), r = n?.textContent ? n.textContent : "", o = [], h = t.parentNode;
|
|
2026
|
+
let l;
|
|
2027
|
+
return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (l = h.getAttribute("id") ?? void 0), {
|
|
2046
2028
|
id: e,
|
|
2047
2029
|
href: s,
|
|
2048
2030
|
label: r,
|
|
2049
2031
|
subitems: o,
|
|
2050
|
-
parent:
|
|
2032
|
+
parent: l
|
|
2051
2033
|
};
|
|
2052
2034
|
}
|
|
2053
2035
|
/**
|
|
@@ -2070,7 +2052,7 @@ class et {
|
|
|
2070
2052
|
return this.toc.forEach(t);
|
|
2071
2053
|
}
|
|
2072
2054
|
}
|
|
2073
|
-
const
|
|
2055
|
+
const et = {
|
|
2074
2056
|
application: {
|
|
2075
2057
|
ecmascript: ["es", "ecma"],
|
|
2076
2058
|
javascript: "js",
|
|
@@ -2204,27 +2186,27 @@ const it = {
|
|
|
2204
2186
|
"x-ms-vob": "vob",
|
|
2205
2187
|
"x-smv": "smv"
|
|
2206
2188
|
}
|
|
2207
|
-
},
|
|
2208
|
-
let
|
|
2189
|
+
}, pe = (function() {
|
|
2190
|
+
let a, t, e, i;
|
|
2209
2191
|
const s = {};
|
|
2210
|
-
for (
|
|
2211
|
-
if (
|
|
2212
|
-
const n =
|
|
2192
|
+
for (a in et)
|
|
2193
|
+
if (et.hasOwnProperty(a)) {
|
|
2194
|
+
const n = et[a];
|
|
2213
2195
|
for (t in n)
|
|
2214
2196
|
if (n.hasOwnProperty(t))
|
|
2215
2197
|
if (e = n[t], typeof e == "string")
|
|
2216
|
-
s[e] =
|
|
2198
|
+
s[e] = a + "/" + t;
|
|
2217
2199
|
else
|
|
2218
2200
|
for (i = 0; i < e.length; i++)
|
|
2219
|
-
s[e[i]] =
|
|
2201
|
+
s[e[i]] = a + "/" + t;
|
|
2220
2202
|
}
|
|
2221
2203
|
return s;
|
|
2222
|
-
})(),
|
|
2223
|
-
function
|
|
2224
|
-
return
|
|
2204
|
+
})(), ge = "text/plain";
|
|
2205
|
+
function me(a) {
|
|
2206
|
+
return a && pe[a.split(".").pop().toLowerCase()] || ge;
|
|
2225
2207
|
}
|
|
2226
|
-
const H = { lookup:
|
|
2227
|
-
class
|
|
2208
|
+
const H = { lookup: me };
|
|
2209
|
+
class ve {
|
|
2228
2210
|
constructor(t, e) {
|
|
2229
2211
|
this.settings = {
|
|
2230
2212
|
replacements: e && e.replacements || "base64",
|
|
@@ -2270,8 +2252,8 @@ class ge {
|
|
|
2270
2252
|
* @return {Promise<string>} Promise resolves with url string
|
|
2271
2253
|
*/
|
|
2272
2254
|
createUrl(t) {
|
|
2273
|
-
const e = new
|
|
2274
|
-
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) =>
|
|
2255
|
+
const e = new N(t), i = H.lookup(e.filename);
|
|
2256
|
+
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) => te(s)).then((s) => vt(s, i)) : this.settings.request(t, "blob").then((s) => at(s, i));
|
|
2275
2257
|
}
|
|
2276
2258
|
/**
|
|
2277
2259
|
* Create blob urls for all the assets
|
|
@@ -2315,7 +2297,7 @@ class ge {
|
|
|
2315
2297
|
*/
|
|
2316
2298
|
createCssFile(t) {
|
|
2317
2299
|
let e;
|
|
2318
|
-
if (
|
|
2300
|
+
if (z.isAbsolute(t))
|
|
2319
2301
|
return new Promise(function(r) {
|
|
2320
2302
|
r();
|
|
2321
2303
|
});
|
|
@@ -2327,8 +2309,8 @@ class ge {
|
|
|
2327
2309
|
return new P(i).relative(o);
|
|
2328
2310
|
});
|
|
2329
2311
|
return s ? s.then((r) => {
|
|
2330
|
-
const o =
|
|
2331
|
-
return this.settings.replacements === "base64" ? e =
|
|
2312
|
+
const o = bt(r, n, this.replacementUrls);
|
|
2313
|
+
return this.settings.replacements === "base64" ? e = vt(o, "text/css") : e = at(o, "text/css"), e;
|
|
2332
2314
|
}, (r) => new Promise(function(o) {
|
|
2333
2315
|
o();
|
|
2334
2316
|
})) : new Promise(function(r) {
|
|
@@ -2368,15 +2350,15 @@ class ge {
|
|
|
2368
2350
|
*/
|
|
2369
2351
|
substitute(t, e) {
|
|
2370
2352
|
let i;
|
|
2371
|
-
return e ? i = this.relativeTo(e) : i = this.urls,
|
|
2353
|
+
return e ? i = this.relativeTo(e) : i = this.urls, bt(t, i, this.replacementUrls);
|
|
2372
2354
|
}
|
|
2373
2355
|
destroy() {
|
|
2374
2356
|
this.replacementUrls && this.replacementUrls.forEach((t) => {
|
|
2375
|
-
t &&
|
|
2357
|
+
t && Rt(t);
|
|
2376
2358
|
}), 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;
|
|
2377
2359
|
}
|
|
2378
2360
|
}
|
|
2379
|
-
class
|
|
2361
|
+
class it {
|
|
2380
2362
|
constructor(t) {
|
|
2381
2363
|
this.pages = [], this.locations = [], this.epubcfi = new m(), 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);
|
|
2382
2364
|
}
|
|
@@ -2385,7 +2367,7 @@ class st {
|
|
|
2385
2367
|
* @param {document} xml
|
|
2386
2368
|
*/
|
|
2387
2369
|
parse(t) {
|
|
2388
|
-
const e =
|
|
2370
|
+
const e = w(t, "html"), i = w(t, "ncx");
|
|
2389
2371
|
return e ? this.parseNav(t) : i ? this.parseNcx(t) : [];
|
|
2390
2372
|
}
|
|
2391
2373
|
/**
|
|
@@ -2395,7 +2377,7 @@ class st {
|
|
|
2395
2377
|
* @return {PageList.item[]} list
|
|
2396
2378
|
*/
|
|
2397
2379
|
parseNav(t) {
|
|
2398
|
-
const e =
|
|
2380
|
+
const e = ct(t, "nav", "page-list"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
|
|
2399
2381
|
let n;
|
|
2400
2382
|
const r = [];
|
|
2401
2383
|
let o;
|
|
@@ -2407,9 +2389,9 @@ class st {
|
|
|
2407
2389
|
parseNcx(t) {
|
|
2408
2390
|
const e = [];
|
|
2409
2391
|
let i = 0, s, n = 0;
|
|
2410
|
-
const r =
|
|
2392
|
+
const r = w(t, "pageList");
|
|
2411
2393
|
if (!r) return e;
|
|
2412
|
-
const o =
|
|
2394
|
+
const o = B(r, "pageTarget");
|
|
2413
2395
|
if (n = o.length, !o || o.length === 0)
|
|
2414
2396
|
return e;
|
|
2415
2397
|
for (i = 0; i < n; ++i)
|
|
@@ -2417,7 +2399,7 @@ class st {
|
|
|
2417
2399
|
return e;
|
|
2418
2400
|
}
|
|
2419
2401
|
ncxItem(t) {
|
|
2420
|
-
const e =
|
|
2402
|
+
const e = w(t, "navLabel"), s = w(e, "text").textContent ?? "", r = w(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
|
|
2421
2403
|
return {
|
|
2422
2404
|
href: r,
|
|
2423
2405
|
page: o
|
|
@@ -2430,10 +2412,10 @@ class st {
|
|
|
2430
2412
|
* @return {object} pageListItem
|
|
2431
2413
|
*/
|
|
2432
2414
|
item(t) {
|
|
2433
|
-
const e =
|
|
2434
|
-
let o, h,
|
|
2435
|
-
return r
|
|
2436
|
-
cfi:
|
|
2415
|
+
const e = w(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
|
|
2416
|
+
let o, h, l;
|
|
2417
|
+
return r !== -1 ? (o = i.split("#"), h = o[0], l = o.length > 1 ? o[1] : void 0, {
|
|
2418
|
+
cfi: l,
|
|
2437
2419
|
href: i,
|
|
2438
2420
|
packageUrl: h,
|
|
2439
2421
|
page: n
|
|
@@ -2462,7 +2444,7 @@ class st {
|
|
|
2462
2444
|
if (this.locations.length === 0)
|
|
2463
2445
|
return -1;
|
|
2464
2446
|
let i = ot(t, this.locations, this.epubcfi.compare);
|
|
2465
|
-
return i
|
|
2447
|
+
return i !== -1 ? e = this.pages[i] : (i = $(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
|
|
2466
2448
|
}
|
|
2467
2449
|
/**
|
|
2468
2450
|
* Get an EpubCFI from a Page List Item
|
|
@@ -2473,7 +2455,7 @@ class st {
|
|
|
2473
2455
|
let e = -1;
|
|
2474
2456
|
typeof t != "number" && (t = parseInt(t));
|
|
2475
2457
|
const i = this.pages.indexOf(t);
|
|
2476
|
-
return i
|
|
2458
|
+
return i !== -1 && i < this.locations.length && (e = this.locations[i]), e;
|
|
2477
2459
|
}
|
|
2478
2460
|
/**
|
|
2479
2461
|
* Get a Page from Book percentage
|
|
@@ -2508,7 +2490,7 @@ class st {
|
|
|
2508
2490
|
this.pages = void 0, this.locations = void 0, this.epubcfi = void 0, this.pageList = void 0, this.toc = void 0, this.ncx = void 0;
|
|
2509
2491
|
}
|
|
2510
2492
|
}
|
|
2511
|
-
class
|
|
2493
|
+
class Ot {
|
|
2512
2494
|
constructor(t) {
|
|
2513
2495
|
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 = {
|
|
2514
2496
|
name: this.name,
|
|
@@ -2550,16 +2532,16 @@ class It {
|
|
|
2550
2532
|
calculate(t, e, i) {
|
|
2551
2533
|
let s = 1, n = i || 0, r = t;
|
|
2552
2534
|
const o = e, h = Math.floor(r / 12);
|
|
2553
|
-
let
|
|
2554
|
-
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 ? (
|
|
2555
|
-
const d =
|
|
2556
|
-
this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta =
|
|
2535
|
+
let l, c;
|
|
2536
|
+
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);
|
|
2537
|
+
const d = l * s + n, f = r;
|
|
2538
|
+
this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta = f, this.columnWidth = l, this.gap = n, this.divisor = s, this.update({
|
|
2557
2539
|
width: r,
|
|
2558
2540
|
height: o,
|
|
2559
2541
|
spreadWidth: d,
|
|
2560
2542
|
pageWidth: c,
|
|
2561
|
-
delta:
|
|
2562
|
-
columnWidth:
|
|
2543
|
+
delta: f,
|
|
2544
|
+
columnWidth: l,
|
|
2563
2545
|
gap: n,
|
|
2564
2546
|
divisor: s
|
|
2565
2547
|
});
|
|
@@ -2597,12 +2579,12 @@ class It {
|
|
|
2597
2579
|
i[s] === e[s] && delete e[s];
|
|
2598
2580
|
}), Object.keys(e).length > 0) {
|
|
2599
2581
|
const s = _(this.props, t);
|
|
2600
|
-
this.emit(
|
|
2582
|
+
this.emit(u.LAYOUT.UPDATED, s, t);
|
|
2601
2583
|
}
|
|
2602
2584
|
}
|
|
2603
2585
|
}
|
|
2604
|
-
A(
|
|
2605
|
-
class
|
|
2586
|
+
A(Ot.prototype);
|
|
2587
|
+
class ye {
|
|
2606
2588
|
constructor(t) {
|
|
2607
2589
|
this.rendition = t, this._themes = {
|
|
2608
2590
|
default: {
|
|
@@ -2661,7 +2643,7 @@ class me {
|
|
|
2661
2643
|
* @param {string} css
|
|
2662
2644
|
*/
|
|
2663
2645
|
registerCss(t, e) {
|
|
2664
|
-
this._themes[t] = { serialized: e }, (this._injected[t] || t
|
|
2646
|
+
this._themes[t] = { serialized: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2665
2647
|
}
|
|
2666
2648
|
/**
|
|
2667
2649
|
* Register a url
|
|
@@ -2669,8 +2651,8 @@ class me {
|
|
|
2669
2651
|
* @param {string} input
|
|
2670
2652
|
*/
|
|
2671
2653
|
registerUrl(t, e) {
|
|
2672
|
-
const i = new
|
|
2673
|
-
this._themes[t] = { url: i.toString() }, (this._injected[t] || t
|
|
2654
|
+
const i = new N(e);
|
|
2655
|
+
this._themes[t] = { url: i.toString() }, (this._injected[t] || t === "default") && this.update(t);
|
|
2674
2656
|
}
|
|
2675
2657
|
/**
|
|
2676
2658
|
* Register rule
|
|
@@ -2678,7 +2660,7 @@ class me {
|
|
|
2678
2660
|
* @param {object} rules
|
|
2679
2661
|
*/
|
|
2680
2662
|
registerRules(t, e) {
|
|
2681
|
-
this._themes[t] = { rules: e }, (this._injected[t] || t
|
|
2663
|
+
this._themes[t] = { rules: e }, (this._injected[t] || t === "default") && this.update(t);
|
|
2682
2664
|
}
|
|
2683
2665
|
/**
|
|
2684
2666
|
* Select a theme
|
|
@@ -2708,7 +2690,7 @@ class me {
|
|
|
2708
2690
|
let s;
|
|
2709
2691
|
for (const n in i)
|
|
2710
2692
|
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));
|
|
2711
|
-
this._current
|
|
2693
|
+
this._current !== "default" && t.addClass(this._current);
|
|
2712
2694
|
}
|
|
2713
2695
|
/**
|
|
2714
2696
|
* Add Theme to contents
|
|
@@ -2767,7 +2749,7 @@ class me {
|
|
|
2767
2749
|
this.rendition = void 0, this._themes = void 0, this._overrides = void 0, this._current = void 0, this._injected = void 0;
|
|
2768
2750
|
}
|
|
2769
2751
|
}
|
|
2770
|
-
class
|
|
2752
|
+
class we {
|
|
2771
2753
|
constructor(t) {
|
|
2772
2754
|
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));
|
|
2773
2755
|
}
|
|
@@ -2782,17 +2764,17 @@ class ve {
|
|
|
2782
2764
|
* @returns {Annotation} annotation
|
|
2783
2765
|
*/
|
|
2784
2766
|
add(t, e, i, s, n, r) {
|
|
2785
|
-
const o = encodeURI(e + t),
|
|
2767
|
+
const o = encodeURI(e + t), l = new m(e).spinePos, c = new zt({
|
|
2786
2768
|
type: t,
|
|
2787
2769
|
cfiRange: e,
|
|
2788
2770
|
data: i,
|
|
2789
|
-
sectionIndex:
|
|
2771
|
+
sectionIndex: l,
|
|
2790
2772
|
cb: s,
|
|
2791
2773
|
className: n,
|
|
2792
2774
|
styles: r
|
|
2793
2775
|
});
|
|
2794
|
-
return this._annotations[o] = c,
|
|
2795
|
-
c.sectionIndex ===
|
|
2776
|
+
return this._annotations[o] = c, l in this._annotationsBySectionIndex ? this._annotationsBySectionIndex[l].push(o) : this._annotationsBySectionIndex[l] = [o], this.rendition.views().forEach((f) => {
|
|
2777
|
+
c.sectionIndex === f.index && c.attach(f);
|
|
2796
2778
|
}), c;
|
|
2797
2779
|
}
|
|
2798
2780
|
/**
|
|
@@ -2890,18 +2872,16 @@ class ve {
|
|
|
2890
2872
|
}
|
|
2891
2873
|
/**
|
|
2892
2874
|
* [Not Implemented] Show annotations
|
|
2893
|
-
* @TODO: needs implementation in View
|
|
2894
2875
|
*/
|
|
2895
2876
|
show() {
|
|
2896
2877
|
}
|
|
2897
2878
|
/**
|
|
2898
2879
|
* [Not Implemented] Hide annotations
|
|
2899
|
-
* @TODO: needs implementation in View
|
|
2900
2880
|
*/
|
|
2901
2881
|
hide() {
|
|
2902
2882
|
}
|
|
2903
2883
|
}
|
|
2904
|
-
class
|
|
2884
|
+
class zt {
|
|
2905
2885
|
constructor({
|
|
2906
2886
|
type: t,
|
|
2907
2887
|
cfiRange: e,
|
|
@@ -2926,8 +2906,8 @@ class Ot {
|
|
|
2926
2906
|
*/
|
|
2927
2907
|
attach(t) {
|
|
2928
2908
|
const { cfiRange: e, data: i, type: s, mark: n, cb: r, className: o, styles: h } = this;
|
|
2929
|
-
let
|
|
2930
|
-
return s === "highlight" ?
|
|
2909
|
+
let l;
|
|
2910
|
+
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(u.ANNOTATION.ATTACH, l), l;
|
|
2931
2911
|
}
|
|
2932
2912
|
/**
|
|
2933
2913
|
* Remove from a view
|
|
@@ -2935,17 +2915,16 @@ class Ot {
|
|
|
2935
2915
|
*/
|
|
2936
2916
|
detach(t) {
|
|
2937
2917
|
const { cfiRange: e, type: i } = this;
|
|
2938
|
-
t && (i === "highlight" ? t.unhighlight(e) : i === "underline" ? t.ununderline(e) : i === "mark" && t.unmark(e)), this.mark = void 0, this.emit(
|
|
2918
|
+
t && (i === "highlight" ? t.unhighlight(e) : i === "underline" ? t.ununderline(e) : i === "mark" && t.unmark(e)), this.mark = void 0, this.emit(u.ANNOTATION.DETACH);
|
|
2939
2919
|
}
|
|
2940
2920
|
/**
|
|
2941
2921
|
* [Not Implemented] Get text of an annotation
|
|
2942
|
-
* @TODO: needs implementation in contents
|
|
2943
2922
|
*/
|
|
2944
2923
|
text() {
|
|
2945
2924
|
}
|
|
2946
2925
|
}
|
|
2947
|
-
A(
|
|
2948
|
-
class
|
|
2926
|
+
A(zt.prototype);
|
|
2927
|
+
class ut {
|
|
2949
2928
|
constructor(t, e, i, s = !1) {
|
|
2950
2929
|
this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
|
|
2951
2930
|
}
|
|
@@ -2972,8 +2951,8 @@ class ft {
|
|
|
2972
2951
|
end: this.findEnd(n, i, s)
|
|
2973
2952
|
});
|
|
2974
2953
|
if (this._dev === !0) {
|
|
2975
|
-
const o = t.document, h = new m(r.start).toRange(o),
|
|
2976
|
-
c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(
|
|
2954
|
+
const o = t.document, h = new m(r.start).toRange(o), l = new m(r.end).toRange(o), c = o.defaultView.getSelection(), d = o.createRange();
|
|
2955
|
+
c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(l.endContainer, l.endOffset), c.addRange(d);
|
|
2977
2956
|
}
|
|
2978
2957
|
return r;
|
|
2979
2958
|
}
|
|
@@ -2997,11 +2976,11 @@ class ft {
|
|
|
2997
2976
|
}
|
|
2998
2977
|
findRanges(t) {
|
|
2999
2978
|
const e = [], i = t.contents.scrollWidth(), n = Math.ceil(i / this.layout.spreadWidth) * this.layout.divisor, r = this.layout.columnWidth, o = this.layout.gap;
|
|
3000
|
-
let h,
|
|
2979
|
+
let h, l;
|
|
3001
2980
|
for (let c = 0; c < n; c++)
|
|
3002
|
-
h = (r + o) * c,
|
|
3003
|
-
start: this.findStart(t.document.body, h,
|
|
3004
|
-
end: this.findEnd(t.document.body, h,
|
|
2981
|
+
h = (r + o) * c, l = r * (c + 1) + o * c, e.push({
|
|
2982
|
+
start: this.findStart(t.document.body, h, l),
|
|
2983
|
+
end: this.findEnd(t.document.body, h, l)
|
|
3005
2984
|
});
|
|
3006
2985
|
return e;
|
|
3007
2986
|
}
|
|
@@ -3018,24 +2997,24 @@ class ft {
|
|
|
3018
2997
|
let n, r, o = t;
|
|
3019
2998
|
for (; s.length; )
|
|
3020
2999
|
if (n = s.shift(), r = this.walk(n, (h) => {
|
|
3021
|
-
let
|
|
3022
|
-
const p =
|
|
3000
|
+
let l, c, d, f;
|
|
3001
|
+
const p = gt(h);
|
|
3023
3002
|
if (this.horizontal && this.direction === "ltr") {
|
|
3024
|
-
if (
|
|
3003
|
+
if (l = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, l >= e && l <= i)
|
|
3025
3004
|
return h;
|
|
3026
3005
|
if (c > e)
|
|
3027
3006
|
return h;
|
|
3028
3007
|
o = h, s.push(h);
|
|
3029
3008
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3030
|
-
if (
|
|
3009
|
+
if (l = p.left, c = p.right, c <= i && c >= e)
|
|
3031
3010
|
return h;
|
|
3032
|
-
if (
|
|
3011
|
+
if (l < i)
|
|
3033
3012
|
return h;
|
|
3034
3013
|
o = h, s.push(h);
|
|
3035
3014
|
} else {
|
|
3036
|
-
if (d = p.top,
|
|
3015
|
+
if (d = p.top, f = p.bottom, d >= e && d <= i)
|
|
3037
3016
|
return h;
|
|
3038
|
-
if (
|
|
3017
|
+
if (f > e)
|
|
3039
3018
|
return h;
|
|
3040
3019
|
o = h, s.push(h);
|
|
3041
3020
|
}
|
|
@@ -3056,24 +3035,24 @@ class ft {
|
|
|
3056
3035
|
let n, r = t, o;
|
|
3057
3036
|
for (; s.length; )
|
|
3058
3037
|
if (n = s.shift(), o = this.walk(n, (h) => {
|
|
3059
|
-
let
|
|
3060
|
-
const p =
|
|
3038
|
+
let l, c, d, f;
|
|
3039
|
+
const p = gt(h);
|
|
3061
3040
|
if (this.horizontal && this.direction === "ltr") {
|
|
3062
|
-
if (
|
|
3041
|
+
if (l = Math.round(p.left), c = Math.round(p.right), l > i && r)
|
|
3063
3042
|
return r;
|
|
3064
3043
|
if (c > i)
|
|
3065
3044
|
return h;
|
|
3066
3045
|
r = h, s.push(h);
|
|
3067
3046
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3068
|
-
if (
|
|
3047
|
+
if (l = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
|
|
3069
3048
|
return r;
|
|
3070
|
-
if (
|
|
3049
|
+
if (l < e)
|
|
3071
3050
|
return h;
|
|
3072
3051
|
r = h, s.push(h);
|
|
3073
3052
|
} else {
|
|
3074
|
-
if (d = Math.round(p.top),
|
|
3053
|
+
if (d = Math.round(p.top), f = Math.round(p.bottom), d > i && r)
|
|
3075
3054
|
return r;
|
|
3076
|
-
if (
|
|
3055
|
+
if (f > i)
|
|
3077
3056
|
return h;
|
|
3078
3057
|
r = h, s.push(h);
|
|
3079
3058
|
}
|
|
@@ -3091,13 +3070,13 @@ class ft {
|
|
|
3091
3070
|
*/
|
|
3092
3071
|
findTextStartRange(t, e, i) {
|
|
3093
3072
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3094
|
-
let n, r, o, h,
|
|
3073
|
+
let n, r, o, h, l;
|
|
3095
3074
|
for (let c = 0; c < s.length; c++)
|
|
3096
3075
|
if (n = s[c], r = n.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3097
3076
|
if (o = r.left, o >= e)
|
|
3098
3077
|
return n;
|
|
3099
3078
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3100
|
-
if (
|
|
3079
|
+
if (l = r.right, l <= i)
|
|
3101
3080
|
return n;
|
|
3102
3081
|
} else if (h = r.top, h >= e)
|
|
3103
3082
|
return n;
|
|
@@ -3113,15 +3092,15 @@ class ft {
|
|
|
3113
3092
|
*/
|
|
3114
3093
|
findTextEndRange(t, e, i) {
|
|
3115
3094
|
const s = this.splitTextNodeIntoRanges(t);
|
|
3116
|
-
let n, r, o, h,
|
|
3117
|
-
for (let
|
|
3118
|
-
if (r = s[
|
|
3119
|
-
if (h = o.left,
|
|
3095
|
+
let n, r, o, h, l, c, d;
|
|
3096
|
+
for (let f = 0; f < s.length; f++) {
|
|
3097
|
+
if (r = s[f], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
|
|
3098
|
+
if (h = o.left, l = o.right, h > i && n)
|
|
3120
3099
|
return n;
|
|
3121
|
-
if (
|
|
3100
|
+
if (l > i)
|
|
3122
3101
|
return r;
|
|
3123
3102
|
} else if (this.horizontal && this.direction === "rtl") {
|
|
3124
|
-
if (h = o.left,
|
|
3103
|
+
if (h = o.left, l = o.right, l < e && n)
|
|
3125
3104
|
return n;
|
|
3126
3105
|
if (h < e)
|
|
3127
3106
|
return r;
|
|
@@ -3146,11 +3125,11 @@ class ft {
|
|
|
3146
3125
|
const i = [], n = (t.textContent || "").trim();
|
|
3147
3126
|
let r;
|
|
3148
3127
|
const o = t.ownerDocument, h = e || " ";
|
|
3149
|
-
let
|
|
3150
|
-
if (
|
|
3128
|
+
let l = n.indexOf(h);
|
|
3129
|
+
if (l === -1 || t.nodeType !== Node.TEXT_NODE)
|
|
3151
3130
|
return r = o.createRange(), r.selectNodeContents(t), [r];
|
|
3152
|
-
for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t,
|
|
3153
|
-
|
|
3131
|
+
for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t, l), i.push(r), r = null; l !== -1; )
|
|
3132
|
+
l = n.indexOf(h, l + 1), l > 0 && (r && (r.setEnd(t, l), i.push(r)), r = o.createRange(), r.setStart(t, l + 1));
|
|
3154
3133
|
return r && (r.setEnd(t, n.length), i.push(r)), i;
|
|
3155
3134
|
}
|
|
3156
3135
|
/**
|
|
@@ -3185,13 +3164,13 @@ class ft {
|
|
|
3185
3164
|
return t && (this.horizontal = t === "horizontal"), this.horizontal;
|
|
3186
3165
|
}
|
|
3187
3166
|
}
|
|
3188
|
-
const
|
|
3189
|
-
class
|
|
3167
|
+
const be = typeof navigator < "u", Et = be && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), xe = 1;
|
|
3168
|
+
class Dt {
|
|
3190
3169
|
constructor(t, e, i, s) {
|
|
3191
3170
|
this.epubcfi = new m(), this.document = t, this.documentElement = this.document.documentElement, this.content = e || this.document.body, this.window = this.document.defaultView, this._size = {
|
|
3192
3171
|
width: 0,
|
|
3193
3172
|
height: 0
|
|
3194
|
-
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js",
|
|
3173
|
+
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js", It), this.called = 0, this.active = !0, this.listeners();
|
|
3195
3174
|
}
|
|
3196
3175
|
/**
|
|
3197
3176
|
* Get DOM events that are listened for and passed along
|
|
@@ -3206,7 +3185,7 @@ class zt {
|
|
|
3206
3185
|
*/
|
|
3207
3186
|
width(t) {
|
|
3208
3187
|
const e = this.content;
|
|
3209
|
-
return t &&
|
|
3188
|
+
return t && E(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3210
3189
|
}
|
|
3211
3190
|
/**
|
|
3212
3191
|
* Get or Set height
|
|
@@ -3215,7 +3194,7 @@ class zt {
|
|
|
3215
3194
|
*/
|
|
3216
3195
|
height(t) {
|
|
3217
3196
|
const e = this.content;
|
|
3218
|
-
return t &&
|
|
3197
|
+
return t && E(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3219
3198
|
}
|
|
3220
3199
|
/**
|
|
3221
3200
|
* Get or Set width of the contents
|
|
@@ -3224,7 +3203,7 @@ class zt {
|
|
|
3224
3203
|
*/
|
|
3225
3204
|
contentWidth(t) {
|
|
3226
3205
|
const e = this.content || this.document.body;
|
|
3227
|
-
return t &&
|
|
3206
|
+
return t && E(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
|
|
3228
3207
|
}
|
|
3229
3208
|
/**
|
|
3230
3209
|
* Get or Set height of the contents
|
|
@@ -3233,7 +3212,7 @@ class zt {
|
|
|
3233
3212
|
*/
|
|
3234
3213
|
contentHeight(t) {
|
|
3235
3214
|
const e = this.content || this.document.body;
|
|
3236
|
-
return t &&
|
|
3215
|
+
return t && E(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
|
|
3237
3216
|
}
|
|
3238
3217
|
/**
|
|
3239
3218
|
* Get the width of the text using Range
|
|
@@ -3332,34 +3311,34 @@ class zt {
|
|
|
3332
3311
|
}, s = [];
|
|
3333
3312
|
let n = {};
|
|
3334
3313
|
if (e && e.hasAttribute("content")) {
|
|
3335
|
-
const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/),
|
|
3336
|
-
o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]),
|
|
3314
|
+
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*([^,]*)/), f = r.match(/user-scalable\s*=\s*([^,]*)/);
|
|
3315
|
+
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]), f && f.length && typeof f[1] < "u" && (i.scalable = f[1]);
|
|
3337
3316
|
}
|
|
3338
|
-
return n =
|
|
3317
|
+
return n = Gt(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;
|
|
3339
3318
|
}
|
|
3340
3319
|
/**
|
|
3341
3320
|
* Event emitter for when the contents has expanded
|
|
3342
3321
|
* @private
|
|
3343
3322
|
*/
|
|
3344
3323
|
expand() {
|
|
3345
|
-
this.emit(
|
|
3324
|
+
this.emit(u.CONTENTS.EXPAND);
|
|
3346
3325
|
}
|
|
3347
3326
|
/**
|
|
3348
3327
|
* Add DOM listeners
|
|
3349
3328
|
* @private
|
|
3350
3329
|
*/
|
|
3351
3330
|
listeners() {
|
|
3352
|
-
this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(),
|
|
3331
|
+
this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(), this.resizeObservers(), this.linksHandler();
|
|
3353
3332
|
}
|
|
3354
3333
|
/**
|
|
3355
3334
|
* Remove DOM listeners
|
|
3356
3335
|
* @private
|
|
3357
3336
|
*/
|
|
3358
3337
|
removeListeners() {
|
|
3359
|
-
this.removeEventListeners(), this.removeSelectionListeners(), this.
|
|
3338
|
+
this.removeEventListeners(), this.removeSelectionListeners(), this._resizeCheck && (this.document.removeEventListener("transitionend", this._resizeCheck), this._resizeCheck = void 0);
|
|
3360
3339
|
for (const { mql: e, handler: i } of this._mediaQueryHandlers)
|
|
3361
3340
|
e.removeEventListener("change", i);
|
|
3362
|
-
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect()
|
|
3341
|
+
this._mediaQueryHandlers = [], this.observer && this.observer.disconnect();
|
|
3363
3342
|
const t = this.document.querySelectorAll("img");
|
|
3364
3343
|
for (let e = 0; e < t.length; e++)
|
|
3365
3344
|
t[e].onload = null;
|
|
@@ -3371,26 +3350,10 @@ class zt {
|
|
|
3371
3350
|
*/
|
|
3372
3351
|
resizeCheck() {
|
|
3373
3352
|
const t = this.textWidth(), e = this.textHeight();
|
|
3374
|
-
(t
|
|
3353
|
+
(t !== this._size.width || e !== this._size.height) && (this._size = {
|
|
3375
3354
|
width: t,
|
|
3376
3355
|
height: e
|
|
3377
|
-
}, this.onResize && this.onResize(this._size), this.emit(
|
|
3378
|
-
}
|
|
3379
|
-
/**
|
|
3380
|
-
* Poll for resize detection
|
|
3381
|
-
* @private
|
|
3382
|
-
*/
|
|
3383
|
-
resizeListeners() {
|
|
3384
|
-
clearTimeout(this.expanding), requestAnimationFrame(this.resizeCheck.bind(this)), this.expanding = setTimeout(this.resizeListeners.bind(this), 350);
|
|
3385
|
-
}
|
|
3386
|
-
/**
|
|
3387
|
-
* Listen for visibility of tab to change
|
|
3388
|
-
* @private
|
|
3389
|
-
*/
|
|
3390
|
-
visibilityListeners() {
|
|
3391
|
-
this._onVisibilityChange = () => {
|
|
3392
|
-
document.visibilityState === "visible" && this.active === !1 ? (this.active = !0, this.resizeListeners()) : (this.active = !1, clearTimeout(this.expanding));
|
|
3393
|
-
}, document.addEventListener("visibilitychange", this._onVisibilityChange);
|
|
3356
|
+
}, this.onResize && this.onResize(this._size), this.emit(u.CONTENTS.RESIZE, this._size));
|
|
3394
3357
|
}
|
|
3395
3358
|
/**
|
|
3396
3359
|
* Use css transitions to detect resize
|
|
@@ -3407,7 +3370,7 @@ class zt {
|
|
|
3407
3370
|
*/
|
|
3408
3371
|
mediaQueryListeners() {
|
|
3409
3372
|
const t = this.document.styleSheets, e = (i) => {
|
|
3410
|
-
i.matches && !this._expanding && setTimeout(this.expand
|
|
3373
|
+
i.matches && !this._expanding && setTimeout(() => this.expand(), 0);
|
|
3411
3374
|
};
|
|
3412
3375
|
for (let i = 0; i < t.length; i += 1) {
|
|
3413
3376
|
let s;
|
|
@@ -3484,19 +3447,19 @@ class zt {
|
|
|
3484
3447
|
const n = new m(t).toRange(this.document, e);
|
|
3485
3448
|
if (n) {
|
|
3486
3449
|
try {
|
|
3487
|
-
if (!n.endContainer || n.startContainer
|
|
3450
|
+
if (!n.endContainer || n.startContainer === n.endContainer && n.startOffset === n.endOffset) {
|
|
3488
3451
|
let r = (n.startContainer.textContent ?? "").indexOf(" ", n.startOffset);
|
|
3489
|
-
r
|
|
3452
|
+
r === -1 && (r = (n.startContainer.textContent ?? "").length), n.setEnd(n.startContainer, r);
|
|
3490
3453
|
}
|
|
3491
3454
|
} catch (r) {
|
|
3492
3455
|
console.error("setting end offset to start container length failed", r);
|
|
3493
3456
|
}
|
|
3494
3457
|
if (n.startContainer.nodeType === Node.ELEMENT_NODE)
|
|
3495
3458
|
i = n.startContainer.getBoundingClientRect(), s.left = i.left, s.top = i.top;
|
|
3496
|
-
else if (
|
|
3459
|
+
else if (Et) {
|
|
3497
3460
|
const r = n.startContainer, o = new Range();
|
|
3498
3461
|
try {
|
|
3499
|
-
r.nodeType ===
|
|
3462
|
+
r.nodeType === xe ? 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();
|
|
3500
3463
|
} catch (h) {
|
|
3501
3464
|
console.error(h, h instanceof Error ? h.stack : void 0);
|
|
3502
3465
|
}
|
|
@@ -3506,7 +3469,7 @@ class zt {
|
|
|
3506
3469
|
} else if (typeof t == "string" && t.indexOf("#") > -1) {
|
|
3507
3470
|
const n = t.substring(t.indexOf("#") + 1), r = this.document.getElementById(n);
|
|
3508
3471
|
if (r)
|
|
3509
|
-
if (
|
|
3472
|
+
if (Et) {
|
|
3510
3473
|
const o = new Range();
|
|
3511
3474
|
o.selectNode(r), i = o.getBoundingClientRect();
|
|
3512
3475
|
} else
|
|
@@ -3532,7 +3495,7 @@ class zt {
|
|
|
3532
3495
|
s = this.document.createElement("link"), s.type = "text/css", s.rel = "stylesheet", s.href = t, s.onload = () => {
|
|
3533
3496
|
n || (n = !0, setTimeout(() => {
|
|
3534
3497
|
e(!0);
|
|
3535
|
-
},
|
|
3498
|
+
}, 0));
|
|
3536
3499
|
}, this.document.head.appendChild(s);
|
|
3537
3500
|
});
|
|
3538
3501
|
}
|
|
@@ -3563,25 +3526,25 @@ class zt {
|
|
|
3563
3526
|
if (Array.isArray(t))
|
|
3564
3527
|
for (let s = 0, n = t.length; s < n; s++) {
|
|
3565
3528
|
let r = 1, o = t[s], h = "";
|
|
3566
|
-
const
|
|
3529
|
+
const l = t[s][0];
|
|
3567
3530
|
Array.isArray(o[1]?.[0]) && (o = o[1], r = 0);
|
|
3568
3531
|
for (let c = o.length; r < c; r++) {
|
|
3569
3532
|
const d = o[r];
|
|
3570
3533
|
h += d[0] + ":" + d[1] + (d[2] ? " !important" : "") + `;
|
|
3571
3534
|
`;
|
|
3572
3535
|
}
|
|
3573
|
-
i.insertRule(
|
|
3536
|
+
i.insertRule(l + "{" + h + "}", i.cssRules.length);
|
|
3574
3537
|
}
|
|
3575
3538
|
else
|
|
3576
3539
|
Object.keys(t).forEach((n) => {
|
|
3577
3540
|
const r = t[n];
|
|
3578
3541
|
if (Array.isArray(r))
|
|
3579
3542
|
r.forEach((o) => {
|
|
3580
|
-
const
|
|
3581
|
-
i.insertRule(`${n}{${
|
|
3543
|
+
const l = Object.keys(o).map((c) => `${c}:${o[c]}`).join(";");
|
|
3544
|
+
i.insertRule(`${n}{${l}}`, i.cssRules.length);
|
|
3582
3545
|
});
|
|
3583
3546
|
else {
|
|
3584
|
-
const h = Object.keys(r).map((
|
|
3547
|
+
const h = Object.keys(r).map((l) => `${l}:${r[l]}`).join(";");
|
|
3585
3548
|
i.insertRule(`${n}{${h}}`, i.cssRules.length);
|
|
3586
3549
|
}
|
|
3587
3550
|
});
|
|
@@ -3602,7 +3565,7 @@ class zt {
|
|
|
3602
3565
|
n.type = "text/javascript", n.async = !0, n.src = t, n.onload = () => {
|
|
3603
3566
|
s || (s = !0, setTimeout(() => {
|
|
3604
3567
|
e(!0);
|
|
3605
|
-
},
|
|
3568
|
+
}, 0));
|
|
3606
3569
|
}, this.document.head.appendChild(n);
|
|
3607
3570
|
});
|
|
3608
3571
|
}
|
|
@@ -3679,7 +3642,7 @@ class zt {
|
|
|
3679
3642
|
*/
|
|
3680
3643
|
triggerSelectedEvent(t) {
|
|
3681
3644
|
let e, i;
|
|
3682
|
-
t && t.rangeCount > 0 && (e = t.getRangeAt(0), e.collapsed || (i = new m(e, this.cfiBase).toString(), this.emit(
|
|
3645
|
+
t && t.rangeCount > 0 && (e = t.getRangeAt(0), e.collapsed || (i = new m(e, this.cfiBase).toString(), this.emit(u.CONTENTS.SELECTED, i), this.emit(u.CONTENTS.SELECTED_RANGE, e)));
|
|
3683
3646
|
}
|
|
3684
3647
|
/**
|
|
3685
3648
|
* Get a Dom Range from EpubCFI
|
|
@@ -3730,9 +3693,9 @@ class zt {
|
|
|
3730
3693
|
* @param {number} gap
|
|
3731
3694
|
*/
|
|
3732
3695
|
columns(t, e, i, s, n) {
|
|
3733
|
-
const r =
|
|
3696
|
+
const r = "-webkit-column-axis", o = "column-gap", h = "column-width", l = "column-fill", d = this.writingMode().indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
|
3734
3697
|
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" });
|
|
3735
|
-
const
|
|
3698
|
+
const f = [
|
|
3736
3699
|
// Fixes Safari column cut offs, but causes RTL issues.
|
|
3737
3700
|
// Required on iOS: block-level body in CSS columns triggers a
|
|
3738
3701
|
// WKWebView content-size expansion feedback loop where scrollWidth
|
|
@@ -3742,25 +3705,25 @@ class zt {
|
|
|
3742
3705
|
["overflow-y", "hidden"],
|
|
3743
3706
|
["margin", "0", !0]
|
|
3744
3707
|
];
|
|
3745
|
-
d === "vertical" ?
|
|
3708
|
+
d === "vertical" ? f.push(
|
|
3746
3709
|
["padding-top", s / 2 + "px", !0],
|
|
3747
3710
|
["padding-bottom", s / 2 + "px", !0],
|
|
3748
3711
|
["padding-left", "20px"],
|
|
3749
3712
|
["padding-right", "20px"],
|
|
3750
3713
|
[r, "vertical"]
|
|
3751
|
-
) :
|
|
3714
|
+
) : f.push(
|
|
3752
3715
|
["padding-top", "20px"],
|
|
3753
3716
|
["padding-bottom", "20px"],
|
|
3754
3717
|
["padding-left", s / 2 + "px", !0],
|
|
3755
3718
|
["padding-right", s / 2 + "px", !0],
|
|
3756
3719
|
[r, "horizontal"]
|
|
3757
|
-
),
|
|
3720
|
+
), f.push(
|
|
3758
3721
|
["box-sizing", "border-box"],
|
|
3759
3722
|
["max-width", "inherit"],
|
|
3760
|
-
[
|
|
3723
|
+
[l, "auto"],
|
|
3761
3724
|
[o, s + "px"],
|
|
3762
3725
|
[h, i + "px"]
|
|
3763
|
-
), this.cssBatch(
|
|
3726
|
+
), this.cssBatch(f);
|
|
3764
3727
|
}
|
|
3765
3728
|
/**
|
|
3766
3729
|
* Scale contents from center
|
|
@@ -3779,15 +3742,15 @@ class zt {
|
|
|
3779
3742
|
* @param {number} height
|
|
3780
3743
|
*/
|
|
3781
3744
|
fit(t, e, i) {
|
|
3782
|
-
const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r,
|
|
3783
|
-
this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(
|
|
3745
|
+
const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r, l = o < h ? o : h;
|
|
3746
|
+
this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(l, 0, 0);
|
|
3784
3747
|
const c = [
|
|
3785
3748
|
// background images are not scaled by transform
|
|
3786
|
-
["background-size", n *
|
|
3749
|
+
["background-size", n * l + "px " + r * l + "px"],
|
|
3787
3750
|
["background-color", "transparent"]
|
|
3788
3751
|
];
|
|
3789
3752
|
if (i && i.properties.includes("page-spread-left")) {
|
|
3790
|
-
const d = t - n *
|
|
3753
|
+
const d = t - n * l;
|
|
3791
3754
|
c.push(["margin-left", d + "px"]);
|
|
3792
3755
|
}
|
|
3793
3756
|
this.cssBatch(c);
|
|
@@ -3800,15 +3763,15 @@ class zt {
|
|
|
3800
3763
|
this.documentElement && (this.documentElement.style.direction = t);
|
|
3801
3764
|
}
|
|
3802
3765
|
mapPage(t, e, i, s, n) {
|
|
3803
|
-
return new
|
|
3766
|
+
return new ut(e, void 0, void 0, n).page(this, t, i, s);
|
|
3804
3767
|
}
|
|
3805
3768
|
/**
|
|
3806
3769
|
* Emit event when link in content is clicked
|
|
3807
3770
|
* @private
|
|
3808
3771
|
*/
|
|
3809
3772
|
linksHandler() {
|
|
3810
|
-
|
|
3811
|
-
this.emit(
|
|
3773
|
+
ce(this.content, (t) => {
|
|
3774
|
+
this.emit(u.CONTENTS.LINK_CLICKED, t);
|
|
3812
3775
|
});
|
|
3813
3776
|
}
|
|
3814
3777
|
/**
|
|
@@ -3816,8 +3779,7 @@ class zt {
|
|
|
3816
3779
|
* @param {string} [mode="horizontal-tb"] "horizontal-tb" | "vertical-rl" | "vertical-lr"
|
|
3817
3780
|
*/
|
|
3818
3781
|
writingMode(t) {
|
|
3819
|
-
|
|
3820
|
-
return t && this.documentElement && (this.documentElement.style[e] = t), this.window.getComputedStyle(this.documentElement)[e] || "";
|
|
3782
|
+
return t && this.documentElement && (this.documentElement.style.writingMode = t), this.window.getComputedStyle(this.documentElement).writingMode || "";
|
|
3821
3783
|
}
|
|
3822
3784
|
/**
|
|
3823
3785
|
* Set the layoutStyle of the content
|
|
@@ -3862,41 +3824,41 @@ class zt {
|
|
|
3862
3824
|
this.removeListeners(), this.__listeners = {};
|
|
3863
3825
|
}
|
|
3864
3826
|
}
|
|
3865
|
-
A(
|
|
3866
|
-
function X(
|
|
3867
|
-
return document.createElementNS("http://www.w3.org/2000/svg",
|
|
3827
|
+
A(Dt.prototype);
|
|
3828
|
+
function X(a) {
|
|
3829
|
+
return document.createElementNS("http://www.w3.org/2000/svg", a);
|
|
3868
3830
|
}
|
|
3869
|
-
function
|
|
3831
|
+
function Ee(a, t) {
|
|
3870
3832
|
function e(s) {
|
|
3871
3833
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
3872
3834
|
const r = t[n];
|
|
3873
3835
|
let o, h;
|
|
3874
|
-
if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!
|
|
3875
|
-
r.dispatchEvent(
|
|
3836
|
+
if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ce(r, a, o, h)) {
|
|
3837
|
+
r.dispatchEvent(Se(s));
|
|
3876
3838
|
break;
|
|
3877
3839
|
}
|
|
3878
3840
|
}
|
|
3879
3841
|
}
|
|
3880
3842
|
let i;
|
|
3881
|
-
if (
|
|
3843
|
+
if (a.nodeName === "iframe" || a.nodeName === "IFRAME")
|
|
3882
3844
|
try {
|
|
3883
|
-
i =
|
|
3845
|
+
i = a.contentDocument;
|
|
3884
3846
|
} catch {
|
|
3885
|
-
i =
|
|
3847
|
+
i = a;
|
|
3886
3848
|
}
|
|
3887
3849
|
else
|
|
3888
|
-
i =
|
|
3850
|
+
i = a;
|
|
3889
3851
|
for (const s of ["mouseup", "mousedown", "click", "touchstart"])
|
|
3890
3852
|
i.addEventListener(s, (n) => e(n), !1);
|
|
3891
3853
|
}
|
|
3892
|
-
function
|
|
3893
|
-
const t = Object.assign({},
|
|
3854
|
+
function Se(a) {
|
|
3855
|
+
const t = Object.assign({}, a, { bubbles: !1 });
|
|
3894
3856
|
try {
|
|
3895
|
-
return new MouseEvent(
|
|
3857
|
+
return new MouseEvent(a.type, t);
|
|
3896
3858
|
} catch {
|
|
3897
|
-
const i =
|
|
3859
|
+
const i = a, s = document.createEvent("MouseEvents");
|
|
3898
3860
|
return s.initMouseEvent(
|
|
3899
|
-
|
|
3861
|
+
a.type,
|
|
3900
3862
|
!1,
|
|
3901
3863
|
i.cancelable,
|
|
3902
3864
|
i.view,
|
|
@@ -3914,39 +3876,39 @@ function xe(l) {
|
|
|
3914
3876
|
), s;
|
|
3915
3877
|
}
|
|
3916
3878
|
}
|
|
3917
|
-
function
|
|
3879
|
+
function Ce(a, t, e, i) {
|
|
3918
3880
|
const s = t.getBoundingClientRect();
|
|
3919
|
-
function n(h,
|
|
3920
|
-
const d = h.top - s.top,
|
|
3921
|
-
return d <= c &&
|
|
3881
|
+
function n(h, l, c) {
|
|
3882
|
+
const d = h.top - s.top, f = h.left - s.left, p = d + h.height, g = f + h.width;
|
|
3883
|
+
return d <= c && f <= l && p > c && g > l;
|
|
3922
3884
|
}
|
|
3923
|
-
const r =
|
|
3885
|
+
const r = a.getBoundingClientRect();
|
|
3924
3886
|
if (!n(r, e, i))
|
|
3925
3887
|
return !1;
|
|
3926
|
-
const o =
|
|
3927
|
-
for (let h = 0,
|
|
3888
|
+
const o = a.getClientRects();
|
|
3889
|
+
for (let h = 0, l = o.length; h < l; h++)
|
|
3928
3890
|
if (n(o[h], e, i))
|
|
3929
3891
|
return !0;
|
|
3930
3892
|
return !1;
|
|
3931
3893
|
}
|
|
3932
|
-
function
|
|
3933
|
-
const e = t.getBoundingClientRect(), i =
|
|
3894
|
+
function _e(a, t) {
|
|
3895
|
+
const e = t.getBoundingClientRect(), i = a.getBoundingClientRect();
|
|
3934
3896
|
return {
|
|
3935
3897
|
top: i.top - e.top,
|
|
3936
3898
|
left: i.left - e.left,
|
|
3937
|
-
height:
|
|
3938
|
-
width:
|
|
3899
|
+
height: a.scrollHeight,
|
|
3900
|
+
width: a.scrollWidth
|
|
3939
3901
|
};
|
|
3940
3902
|
}
|
|
3941
|
-
function
|
|
3942
|
-
|
|
3903
|
+
function Te(a, t) {
|
|
3904
|
+
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");
|
|
3943
3905
|
}
|
|
3944
|
-
function
|
|
3945
|
-
return t.right <=
|
|
3906
|
+
function ke(a, t) {
|
|
3907
|
+
return t.right <= a.right && t.left >= a.left && t.top >= a.top && t.bottom <= a.bottom;
|
|
3946
3908
|
}
|
|
3947
|
-
class
|
|
3909
|
+
class St {
|
|
3948
3910
|
constructor(t, e = document.body) {
|
|
3949
|
-
this.target = t, this.element = X("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"),
|
|
3911
|
+
this.target = t, this.element = X("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), Ee(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
|
|
3950
3912
|
}
|
|
3951
3913
|
addMark(t) {
|
|
3952
3914
|
const e = X("g");
|
|
@@ -3960,12 +3922,12 @@ class Ct {
|
|
|
3960
3922
|
this.element.removeChild(i), this.marks.splice(e, 1);
|
|
3961
3923
|
}
|
|
3962
3924
|
render() {
|
|
3963
|
-
|
|
3925
|
+
Te(this.element, _e(this.target, this.container));
|
|
3964
3926
|
for (const t of this.marks)
|
|
3965
3927
|
t.render();
|
|
3966
3928
|
}
|
|
3967
3929
|
}
|
|
3968
|
-
class
|
|
3930
|
+
class Le {
|
|
3969
3931
|
constructor() {
|
|
3970
3932
|
this.element = null;
|
|
3971
3933
|
}
|
|
@@ -3997,14 +3959,14 @@ class Te {
|
|
|
3997
3959
|
for (let i = 0; i < t.length; i++) {
|
|
3998
3960
|
if (t[i] === e)
|
|
3999
3961
|
return !0;
|
|
4000
|
-
if (
|
|
3962
|
+
if (ke(t[i], e))
|
|
4001
3963
|
return !1;
|
|
4002
3964
|
}
|
|
4003
3965
|
return !0;
|
|
4004
3966
|
});
|
|
4005
3967
|
}
|
|
4006
3968
|
}
|
|
4007
|
-
class
|
|
3969
|
+
class Bt extends Le {
|
|
4008
3970
|
constructor(t, e, i, s) {
|
|
4009
3971
|
super(), this.range = t, this.className = e, this.data = i || {}, this.attributes = s || {};
|
|
4010
3972
|
}
|
|
@@ -4027,7 +3989,7 @@ class Dt extends Te {
|
|
|
4027
3989
|
this.element.appendChild(t);
|
|
4028
3990
|
}
|
|
4029
3991
|
}
|
|
4030
|
-
class
|
|
3992
|
+
class Ne extends Bt {
|
|
4031
3993
|
constructor(t, e, i, s) {
|
|
4032
3994
|
super(t, e, i, s);
|
|
4033
3995
|
}
|
|
@@ -4038,13 +4000,13 @@ class Le extends Dt {
|
|
|
4038
4000
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
4039
4001
|
const o = e[n], h = X("rect");
|
|
4040
4002
|
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");
|
|
4041
|
-
const
|
|
4042
|
-
|
|
4003
|
+
const l = X("line");
|
|
4004
|
+
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);
|
|
4043
4005
|
}
|
|
4044
4006
|
this.element.appendChild(t);
|
|
4045
4007
|
}
|
|
4046
4008
|
}
|
|
4047
|
-
class
|
|
4009
|
+
class Mt {
|
|
4048
4010
|
constructor(t, e) {
|
|
4049
4011
|
this.settings = _({
|
|
4050
4012
|
ignoreClass: "",
|
|
@@ -4059,26 +4021,26 @@ class Bt {
|
|
|
4059
4021
|
forceRight: !1,
|
|
4060
4022
|
allowScriptedContent: !1,
|
|
4061
4023
|
allowPopups: !1
|
|
4062
|
-
}, e || {}), this.id = "epubjs-view-" +
|
|
4024
|
+
}, e || {}), this.id = "epubjs-view-" + kt(), 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 m(), this.layout = this.settings.layout, this.pane = void 0, this.highlights = {}, this.underlines = {}, this.marks = {};
|
|
4063
4025
|
}
|
|
4064
4026
|
container(t) {
|
|
4065
4027
|
const e = document.createElement("div");
|
|
4066
|
-
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
|
|
4028
|
+
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;
|
|
4067
4029
|
}
|
|
4068
4030
|
create() {
|
|
4069
|
-
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 =
|
|
4031
|
+
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 = J(this.element), "srcdoc" in this.iframe ? this.supportsSrcdoc = !0 : this.supportsSrcdoc = !1, this.settings.method || (this.settings.method = this.supportsSrcdoc ? "srcdoc" : "write"), this.iframe);
|
|
4070
4032
|
}
|
|
4071
4033
|
render(t, e) {
|
|
4072
4034
|
return this.create(), this.size(), this.sectionRender || (this.sectionRender = this.section.render(t)), this.sectionRender.then((i) => this.load(i)).then(() => {
|
|
4073
4035
|
const i = this.contents.writingMode();
|
|
4074
4036
|
let s;
|
|
4075
|
-
return this.settings.flow === "scrolled" ? s = i.indexOf("vertical") === 0 ? "horizontal" : "vertical" : s = i.indexOf("vertical") === 0 ? "vertical" : "horizontal", i.indexOf("vertical") === 0 && this.settings.flow === "paginated" && (this.layout.delta = this.layout.height), this.setAxis(s), this.emit(
|
|
4037
|
+
return this.settings.flow === "scrolled" ? s = i.indexOf("vertical") === 0 ? "horizontal" : "vertical" : s = i.indexOf("vertical") === 0 ? "vertical" : "horizontal", i.indexOf("vertical") === 0 && this.settings.flow === "paginated" && (this.layout.delta = this.layout.height), this.setAxis(s), this.emit(u.VIEWS.AXIS, s), this.setWritingMode(i), this.emit(u.VIEWS.WRITING_MODE, i), this.layout.format(this.contents, this.section, this.axis), this.addListeners(), new Promise((n, r) => {
|
|
4076
4038
|
this.expand(), this.settings.forceRight && (this.element.style.marginLeft = this.width() + "px"), n();
|
|
4077
4039
|
});
|
|
4078
|
-
}, (i) => (this.emit(
|
|
4040
|
+
}, (i) => (this.emit(u.VIEWS.LOAD_ERROR, i), new Promise((s, n) => {
|
|
4079
4041
|
n(i);
|
|
4080
4042
|
}))).then(() => {
|
|
4081
|
-
this.emit(
|
|
4043
|
+
this.emit(u.VIEWS.RENDERED, this.section);
|
|
4082
4044
|
});
|
|
4083
4045
|
}
|
|
4084
4046
|
reset() {
|
|
@@ -4093,15 +4055,15 @@ class Bt {
|
|
|
4093
4055
|
lock(t, e, i) {
|
|
4094
4056
|
const s = ht(this.element);
|
|
4095
4057
|
let n;
|
|
4096
|
-
this.iframe ? n = ht(this.iframe) : n = { width: 0, height: 0 }, t
|
|
4058
|
+
this.iframe ? n = ht(this.iframe) : n = { width: 0, height: 0 }, t === "width" && E(e) && (this.lockedWidth = e - s.width - n.width), t === "height" && E(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && E(e) && E(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
|
|
4097
4059
|
}
|
|
4098
4060
|
// Resize a single axis based on content dimensions
|
|
4099
4061
|
expand(t) {
|
|
4100
4062
|
let e = this.lockedWidth, i = this.lockedHeight, s;
|
|
4101
|
-
!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
|
|
4063
|
+
!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);
|
|
4102
4064
|
}
|
|
4103
4065
|
reframe(t, e) {
|
|
4104
|
-
|
|
4066
|
+
E(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), E(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
|
|
4105
4067
|
const i = this.prevBounds ? t - this.prevBounds.width : t, s = this.prevBounds ? e - this.prevBounds.height : e, n = {
|
|
4106
4068
|
width: t,
|
|
4107
4069
|
height: e,
|
|
@@ -4112,10 +4074,10 @@ class Bt {
|
|
|
4112
4074
|
let r;
|
|
4113
4075
|
for (const o in this.marks)
|
|
4114
4076
|
this.marks.hasOwnProperty(o) && (r = this.marks[o], this.placeMark(r.element, r.range));
|
|
4115
|
-
}), this.onResize(this, n), this.emit(
|
|
4077
|
+
}), this.onResize(this, n), this.emit(u.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = J(this.element);
|
|
4116
4078
|
}
|
|
4117
4079
|
load(t) {
|
|
4118
|
-
const e = new
|
|
4080
|
+
const e = new C(), i = e.promise;
|
|
4119
4081
|
if (!this.iframe)
|
|
4120
4082
|
return e.reject(new Error("No Iframe Available")), i;
|
|
4121
4083
|
if (this.iframe.onload = (s) => {
|
|
@@ -4132,11 +4094,11 @@ class Bt {
|
|
|
4132
4094
|
return i;
|
|
4133
4095
|
}
|
|
4134
4096
|
onLoad(t, e) {
|
|
4135
|
-
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new
|
|
4097
|
+
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new Dt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
|
|
4136
4098
|
let i = this.document.querySelector("link[rel='canonical']");
|
|
4137
|
-
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(
|
|
4099
|
+
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(u.CONTENTS.EXPAND, () => {
|
|
4138
4100
|
this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
|
|
4139
|
-
}), this.contents.on(
|
|
4101
|
+
}), this.contents.on(u.CONTENTS.RESIZE, (s) => {
|
|
4140
4102
|
this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
|
|
4141
4103
|
}), e.resolve(this.contents);
|
|
4142
4104
|
}
|
|
@@ -4144,7 +4106,7 @@ class Bt {
|
|
|
4144
4106
|
this.layout = t, this.contents && (this.layout.format(this.contents), this.expand());
|
|
4145
4107
|
}
|
|
4146
4108
|
setAxis(t) {
|
|
4147
|
-
this.settings.axis = t, t
|
|
4109
|
+
this.settings.axis = t, t === "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
|
|
4148
4110
|
}
|
|
4149
4111
|
setWritingMode(t) {
|
|
4150
4112
|
this.writingMode = t;
|
|
@@ -4152,21 +4114,21 @@ class Bt {
|
|
|
4152
4114
|
addListeners() {
|
|
4153
4115
|
}
|
|
4154
4116
|
removeListeners() {
|
|
4155
|
-
this.contents && (this.contents.off(
|
|
4117
|
+
this.contents && (this.contents.off(u.CONTENTS.EXPAND), this.contents.off(u.CONTENTS.RESIZE));
|
|
4156
4118
|
}
|
|
4157
4119
|
display(t) {
|
|
4158
|
-
const e = new
|
|
4120
|
+
const e = new C();
|
|
4159
4121
|
return this.displayed ? e.resolve(this) : this.render(t).then(() => {
|
|
4160
|
-
this.emit(
|
|
4122
|
+
this.emit(u.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
|
|
4161
4123
|
}, (i) => {
|
|
4162
4124
|
e.reject(i);
|
|
4163
4125
|
}), e.promise;
|
|
4164
4126
|
}
|
|
4165
4127
|
show() {
|
|
4166
|
-
this.element.style.visibility = "visible", this.iframe && (this.iframe.style.visibility = "visible", this.iframe.style.transform = "translateZ(0)", this.iframe.offsetWidth, this.iframe.style.transform = ""), this.emit(
|
|
4128
|
+
this.element.style.visibility = "visible", this.iframe && (this.iframe.style.visibility = "visible", this.iframe.style.transform = "translateZ(0)", this.iframe.offsetWidth, this.iframe.style.transform = ""), this.emit(u.VIEWS.SHOWN, this);
|
|
4167
4129
|
}
|
|
4168
4130
|
hide() {
|
|
4169
|
-
this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.stopExpanding = !0, this.emit(
|
|
4131
|
+
this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.stopExpanding = !0, this.emit(u.VIEWS.HIDDEN, this);
|
|
4170
4132
|
}
|
|
4171
4133
|
offset() {
|
|
4172
4134
|
return {
|
|
@@ -4196,19 +4158,19 @@ class Bt {
|
|
|
4196
4158
|
onResize(t, e) {
|
|
4197
4159
|
}
|
|
4198
4160
|
bounds(t) {
|
|
4199
|
-
return (t || !this.elementBounds) && (this.elementBounds =
|
|
4161
|
+
return (t || !this.elementBounds) && (this.elementBounds = J(this.element)), this.elementBounds;
|
|
4200
4162
|
}
|
|
4201
4163
|
highlight(t, e = {}, i, s = "epubjs-hl", n = {}) {
|
|
4202
4164
|
if (!this.contents)
|
|
4203
4165
|
return;
|
|
4204
4166
|
const r = Object.assign({ fill: "yellow", "fill-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4205
|
-
this.emit(
|
|
4167
|
+
this.emit(u.VIEWS.MARK_CLICKED, t, e);
|
|
4206
4168
|
};
|
|
4207
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4208
|
-
const
|
|
4169
|
+
e.epubcfi = t, this.pane || (this.pane = new St(this.iframe, this.element));
|
|
4170
|
+
const l = new Bt(o, s, e, r);
|
|
4209
4171
|
let c;
|
|
4210
4172
|
try {
|
|
4211
|
-
c = this.pane.addMark(
|
|
4173
|
+
c = this.pane.addMark(l);
|
|
4212
4174
|
} catch (d) {
|
|
4213
4175
|
console.error("Failed to add highlight for", t, d);
|
|
4214
4176
|
return;
|
|
@@ -4219,13 +4181,13 @@ class Bt {
|
|
|
4219
4181
|
if (!this.contents)
|
|
4220
4182
|
return;
|
|
4221
4183
|
const r = Object.assign({ stroke: "black", "stroke-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
|
|
4222
|
-
this.emit(
|
|
4184
|
+
this.emit(u.VIEWS.MARK_CLICKED, t, e);
|
|
4223
4185
|
};
|
|
4224
|
-
e.epubcfi = t, this.pane || (this.pane = new
|
|
4225
|
-
const
|
|
4186
|
+
e.epubcfi = t, this.pane || (this.pane = new St(this.iframe, this.element));
|
|
4187
|
+
const l = new Ne(o, s, e, r);
|
|
4226
4188
|
let c;
|
|
4227
4189
|
try {
|
|
4228
|
-
c = this.pane.addMark(
|
|
4190
|
+
c = this.pane.addMark(l);
|
|
4229
4191
|
} catch (d) {
|
|
4230
4192
|
console.error("Failed to add underline for", t, d);
|
|
4231
4193
|
return;
|
|
@@ -4240,13 +4202,13 @@ class Bt {
|
|
|
4240
4202
|
let s = this.contents.range(t);
|
|
4241
4203
|
if (!s)
|
|
4242
4204
|
return;
|
|
4243
|
-
const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (
|
|
4244
|
-
this.emit(
|
|
4205
|
+
const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (l) => {
|
|
4206
|
+
this.emit(u.VIEWS.MARK_CLICKED, t, e);
|
|
4245
4207
|
};
|
|
4246
4208
|
s.collapsed && n.nodeType === 1 ? (s = new Range(), s.selectNodeContents(n)) : s.collapsed && (s = new Range(), s.selectNodeContents(r));
|
|
4247
4209
|
const h = this.document.createElement("a");
|
|
4248
|
-
return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((
|
|
4249
|
-
h.dataset[
|
|
4210
|
+
return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((l) => {
|
|
4211
|
+
h.dataset[l] = e[l];
|
|
4250
4212
|
}), 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;
|
|
4251
4213
|
}
|
|
4252
4214
|
placeMark(t, e) {
|
|
@@ -4257,7 +4219,7 @@ class Bt {
|
|
|
4257
4219
|
} else {
|
|
4258
4220
|
const r = e.getClientRects();
|
|
4259
4221
|
let o;
|
|
4260
|
-
for (let h = 0; h
|
|
4222
|
+
for (let h = 0; h !== r.length; h++)
|
|
4261
4223
|
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);
|
|
4262
4224
|
}
|
|
4263
4225
|
t.style.top = `${i}px`, t.style.left = `${s}px`;
|
|
@@ -4293,37 +4255,37 @@ class Bt {
|
|
|
4293
4255
|
this.ununderline(t);
|
|
4294
4256
|
for (const t in this.marks)
|
|
4295
4257
|
this.unmark(t);
|
|
4296
|
-
this.blobUrl &&
|
|
4258
|
+
this.blobUrl && Rt(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 = {};
|
|
4297
4259
|
}
|
|
4298
4260
|
}
|
|
4299
|
-
A(
|
|
4300
|
-
function ke() {
|
|
4301
|
-
let l = "reverse";
|
|
4302
|
-
const t = Re();
|
|
4303
|
-
return document.body.appendChild(t), t.scrollLeft > 0 ? l = "default" : typeof Element < "u" && typeof Element.prototype.scrollIntoView == "function" ? (t.children[0].children[1].scrollIntoView(), t.scrollLeft < 0 && (l = "negative")) : (t.scrollLeft = 1, t.scrollLeft === 0 && (l = "negative")), document.body.removeChild(t), l;
|
|
4304
|
-
}
|
|
4261
|
+
A(Mt.prototype);
|
|
4305
4262
|
function Re() {
|
|
4306
|
-
|
|
4307
|
-
|
|
4263
|
+
let a = "reverse";
|
|
4264
|
+
const t = Ae();
|
|
4265
|
+
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;
|
|
4266
|
+
}
|
|
4267
|
+
function Ae() {
|
|
4268
|
+
const a = document.createElement("div");
|
|
4269
|
+
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";
|
|
4308
4270
|
const t = document.createElement("div");
|
|
4309
4271
|
t.style.width = "2px";
|
|
4310
4272
|
const e = document.createElement("span");
|
|
4311
4273
|
e.style.width = "1px", e.style.display = "inline-block";
|
|
4312
4274
|
const i = document.createElement("span");
|
|
4313
|
-
return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i),
|
|
4275
|
+
return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i), a.appendChild(t), a;
|
|
4314
4276
|
}
|
|
4315
|
-
function
|
|
4277
|
+
function Ie(a, t) {
|
|
4316
4278
|
let e = null, i = 0;
|
|
4317
4279
|
return function(...s) {
|
|
4318
4280
|
const n = Date.now(), r = t - (n - i);
|
|
4319
|
-
r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n,
|
|
4320
|
-
i = Date.now(), e = null,
|
|
4281
|
+
r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n, a.call(this, ...s)) : e || (e = setTimeout(() => {
|
|
4282
|
+
i = Date.now(), e = null, a.call(this, ...s);
|
|
4321
4283
|
}, r));
|
|
4322
4284
|
};
|
|
4323
4285
|
}
|
|
4324
|
-
class
|
|
4286
|
+
class Pe {
|
|
4325
4287
|
constructor(t) {
|
|
4326
|
-
this.settings = t || {}, this.id = "epubjs-container-" +
|
|
4288
|
+
this.settings = t || {}, this.id = "epubjs-container-" + kt(), this.container = this.create(this.settings), this.settings.hidden && (this.wrapper = this.wrap(this.container));
|
|
4327
4289
|
}
|
|
4328
4290
|
/*
|
|
4329
4291
|
* Creates an element to render to.
|
|
@@ -4332,7 +4294,7 @@ class Ae {
|
|
|
4332
4294
|
create(t) {
|
|
4333
4295
|
let e = t.height, i = t.width;
|
|
4334
4296
|
const s = t.overflow || !1, n = t.axis || "vertical", r = t.direction;
|
|
4335
|
-
_(this.settings, t), t.height &&
|
|
4297
|
+
_(this.settings, t), t.height && E(t.height) && (e = t.height + "px"), t.width && E(t.width) && (i = t.width + "px");
|
|
4336
4298
|
const o = document.createElement("div");
|
|
4337
4299
|
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;
|
|
4338
4300
|
}
|
|
@@ -4342,7 +4304,7 @@ class Ae {
|
|
|
4342
4304
|
}
|
|
4343
4305
|
getElement(t) {
|
|
4344
4306
|
let e = null;
|
|
4345
|
-
if (
|
|
4307
|
+
if (Xt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
|
|
4346
4308
|
throw new Error("Not an Element");
|
|
4347
4309
|
return e;
|
|
4348
4310
|
}
|
|
@@ -4356,7 +4318,7 @@ class Ae {
|
|
|
4356
4318
|
return this.container;
|
|
4357
4319
|
}
|
|
4358
4320
|
onResize(t) {
|
|
4359
|
-
(!
|
|
4321
|
+
(!E(this.settings.width) || !E(this.settings.height)) && (this.resizeFunc = Ie(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
|
|
4360
4322
|
}
|
|
4361
4323
|
onOrientationChange(t) {
|
|
4362
4324
|
this.orientationChangeFunc = t, window.addEventListener("orientationchange", this.orientationChangeFunc, !1);
|
|
@@ -4364,13 +4326,13 @@ class Ae {
|
|
|
4364
4326
|
size(t, e) {
|
|
4365
4327
|
let i;
|
|
4366
4328
|
const s = t || this.settings.width, n = e || this.settings.height;
|
|
4367
|
-
t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) :
|
|
4329
|
+
t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : E(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")) : E(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), E(t) || (t = this.container.clientWidth), E(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
|
|
4368
4330
|
left: parseFloat(this.containerStyles.paddingLeft) || 0,
|
|
4369
4331
|
right: parseFloat(this.containerStyles.paddingRight) || 0,
|
|
4370
4332
|
top: parseFloat(this.containerStyles.paddingTop) || 0,
|
|
4371
4333
|
bottom: parseFloat(this.containerStyles.paddingBottom) || 0
|
|
4372
4334
|
};
|
|
4373
|
-
const r =
|
|
4335
|
+
const r = mt(), o = window.getComputedStyle(document.body), h = {
|
|
4374
4336
|
left: parseFloat(o.paddingLeft) || 0,
|
|
4375
4337
|
right: parseFloat(o.paddingRight) || 0,
|
|
4376
4338
|
top: parseFloat(o.paddingTop) || 0,
|
|
@@ -4383,7 +4345,7 @@ class Ae {
|
|
|
4383
4345
|
}
|
|
4384
4346
|
bounds() {
|
|
4385
4347
|
let t;
|
|
4386
|
-
return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ?
|
|
4348
|
+
return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ? mt() : t;
|
|
4387
4349
|
}
|
|
4388
4350
|
getSheet() {
|
|
4389
4351
|
const t = document.createElement("style");
|
|
@@ -4419,7 +4381,7 @@ class Ae {
|
|
|
4419
4381
|
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));
|
|
4420
4382
|
}
|
|
4421
4383
|
}
|
|
4422
|
-
class
|
|
4384
|
+
class Oe {
|
|
4423
4385
|
constructor(t) {
|
|
4424
4386
|
this.container = t, this._views = [], this.length = 0, this.hidden = !1;
|
|
4425
4387
|
}
|
|
@@ -4474,7 +4436,7 @@ class Ie {
|
|
|
4474
4436
|
let e;
|
|
4475
4437
|
const i = this.length;
|
|
4476
4438
|
for (let s = 0; s < i; s++)
|
|
4477
|
-
if (e = this._views[s], e.displayed && e.section.index
|
|
4439
|
+
if (e = this._views[s], e.displayed && e.section.index === t.index)
|
|
4478
4440
|
return e;
|
|
4479
4441
|
}
|
|
4480
4442
|
displayed() {
|
|
@@ -4500,9 +4462,9 @@ class Ie {
|
|
|
4500
4462
|
this.hidden = !0;
|
|
4501
4463
|
}
|
|
4502
4464
|
}
|
|
4503
|
-
class
|
|
4465
|
+
class K {
|
|
4504
4466
|
constructor(t) {
|
|
4505
|
-
this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new
|
|
4467
|
+
this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new pt(this), this.settings = _({}, {
|
|
4506
4468
|
infinite: !0,
|
|
4507
4469
|
hidden: !1,
|
|
4508
4470
|
width: void 0,
|
|
@@ -4530,7 +4492,7 @@ class Z {
|
|
|
4530
4492
|
}
|
|
4531
4493
|
render(t, e) {
|
|
4532
4494
|
const i = t.tagName;
|
|
4533
|
-
typeof this.settings.fullsize > "u" && i && (i.toLowerCase()
|
|
4495
|
+
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 = Re(), this.stage = new Pe({
|
|
4534
4496
|
width: e.width,
|
|
4535
4497
|
height: e.height,
|
|
4536
4498
|
overflow: this.overflow,
|
|
@@ -4538,7 +4500,7 @@ class Z {
|
|
|
4538
4500
|
axis: this.settings.axis,
|
|
4539
4501
|
fullsize: this.settings.fullsize,
|
|
4540
4502
|
direction: this.settings.direction
|
|
4541
|
-
}), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new
|
|
4503
|
+
}), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new Oe(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;
|
|
4542
4504
|
}
|
|
4543
4505
|
addEventListeners() {
|
|
4544
4506
|
let t;
|
|
@@ -4551,24 +4513,18 @@ class Z {
|
|
|
4551
4513
|
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;
|
|
4552
4514
|
}
|
|
4553
4515
|
destroy() {
|
|
4554
|
-
clearTimeout(this.
|
|
4516
|
+
clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
|
|
4555
4517
|
}
|
|
4556
4518
|
onOrientationChange(t) {
|
|
4557
4519
|
const { orientation: e } = window;
|
|
4558
|
-
this.optsSettings?.resizeOnOrientationChange && this.resize(),
|
|
4559
|
-
this.orientationTimeout = void 0, this.optsSettings?.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4560
|
-
}, 500);
|
|
4520
|
+
this.optsSettings?.resizeOnOrientationChange && this.resize(), this.emit(u.MANAGERS.ORIENTATION_CHANGE, e);
|
|
4561
4521
|
}
|
|
4562
4522
|
onResized(t) {
|
|
4563
4523
|
this.resize();
|
|
4564
4524
|
}
|
|
4565
4525
|
resize(t, e, i) {
|
|
4566
4526
|
const s = this.stage.size(t, e);
|
|
4567
|
-
|
|
4568
|
-
this._stageSize = void 0;
|
|
4569
|
-
return;
|
|
4570
|
-
}
|
|
4571
|
-
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, {
|
|
4527
|
+
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(u.MANAGERS.RESIZED, {
|
|
4572
4528
|
width: this._stageSize.width,
|
|
4573
4529
|
height: this._stageSize.height
|
|
4574
4530
|
}, i));
|
|
@@ -4586,8 +4542,8 @@ class Z {
|
|
|
4586
4542
|
}
|
|
4587
4543
|
}
|
|
4588
4544
|
display(t, e) {
|
|
4589
|
-
const i = new
|
|
4590
|
-
(e === t.href ||
|
|
4545
|
+
const i = new C(), s = i.promise;
|
|
4546
|
+
(e === t.href || E(e)) && (e = void 0);
|
|
4591
4547
|
const n = this.views.find(t);
|
|
4592
4548
|
if (n && t && this.layout.name !== "pre-paginated") {
|
|
4593
4549
|
const o = n.offset();
|
|
@@ -4598,8 +4554,8 @@ class Z {
|
|
|
4598
4554
|
this.scrollTo(o.left + h, o.top, !0);
|
|
4599
4555
|
}
|
|
4600
4556
|
if (e) {
|
|
4601
|
-
const h = n.locationOf(e),
|
|
4602
|
-
this.moveTo(h,
|
|
4557
|
+
const h = n.locationOf(e), l = n.width();
|
|
4558
|
+
this.moveTo(h, l);
|
|
4603
4559
|
}
|
|
4604
4560
|
return i.resolve(), s;
|
|
4605
4561
|
}
|
|
@@ -4607,8 +4563,8 @@ class Z {
|
|
|
4607
4563
|
let r = !1;
|
|
4608
4564
|
return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (r = !0), this.add(t, r).then((o) => {
|
|
4609
4565
|
if (e) {
|
|
4610
|
-
const h = o.locationOf(e),
|
|
4611
|
-
this.moveTo(h,
|
|
4566
|
+
const h = o.locationOf(e), l = o.width();
|
|
4567
|
+
this.moveTo(h, l);
|
|
4612
4568
|
}
|
|
4613
4569
|
}, (o) => {
|
|
4614
4570
|
i.reject(o);
|
|
@@ -4617,10 +4573,10 @@ class Z {
|
|
|
4617
4573
|
}), s;
|
|
4618
4574
|
}
|
|
4619
4575
|
afterDisplayed(t) {
|
|
4620
|
-
this.emit(
|
|
4576
|
+
this.emit(u.MANAGERS.ADDED, t);
|
|
4621
4577
|
}
|
|
4622
4578
|
afterResized(t) {
|
|
4623
|
-
this.emit(
|
|
4579
|
+
this.emit(u.MANAGERS.RESIZE, t.section);
|
|
4624
4580
|
}
|
|
4625
4581
|
moveTo(t, e) {
|
|
4626
4582
|
let i = 0, s = 0;
|
|
@@ -4628,27 +4584,27 @@ class Z {
|
|
|
4628
4584
|
}
|
|
4629
4585
|
add(t, e) {
|
|
4630
4586
|
const i = this.createView(t, e);
|
|
4631
|
-
return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(
|
|
4587
|
+
return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(u.VIEWS.AXIS, (s) => {
|
|
4632
4588
|
this.updateAxis(s);
|
|
4633
|
-
}), i.on(
|
|
4589
|
+
}), i.on(u.VIEWS.WRITING_MODE, (s) => {
|
|
4634
4590
|
this.updateWritingMode(s);
|
|
4635
4591
|
}), i.display(this.request);
|
|
4636
4592
|
}
|
|
4637
4593
|
append(t, e) {
|
|
4638
4594
|
const i = this.createView(t, e);
|
|
4639
|
-
return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(
|
|
4595
|
+
return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(u.VIEWS.AXIS, (s) => {
|
|
4640
4596
|
this.updateAxis(s);
|
|
4641
|
-
}), i.on(
|
|
4597
|
+
}), i.on(u.VIEWS.WRITING_MODE, (s) => {
|
|
4642
4598
|
this.updateWritingMode(s);
|
|
4643
4599
|
}), i.display(this.request);
|
|
4644
4600
|
}
|
|
4645
4601
|
prepend(t, e) {
|
|
4646
4602
|
const i = this.createView(t, e);
|
|
4647
|
-
return i.on(
|
|
4603
|
+
return i.on(u.VIEWS.RESIZED, (s) => {
|
|
4648
4604
|
this.counter(s);
|
|
4649
|
-
}), this.views.prepend(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(
|
|
4605
|
+
}), this.views.prepend(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(u.VIEWS.AXIS, (s) => {
|
|
4650
4606
|
this.updateAxis(s);
|
|
4651
|
-
}), i.on(
|
|
4607
|
+
}), i.on(u.VIEWS.WRITING_MODE, (s) => {
|
|
4652
4608
|
this.updateWritingMode(s);
|
|
4653
4609
|
}), i.display(this.request);
|
|
4654
4610
|
}
|
|
@@ -4771,25 +4727,25 @@ class Z {
|
|
|
4771
4727
|
this.settings.direction;
|
|
4772
4728
|
let r = 0;
|
|
4773
4729
|
const o = 0;
|
|
4774
|
-
return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((
|
|
4775
|
-
const c =
|
|
4776
|
-
let
|
|
4777
|
-
n ? (
|
|
4778
|
-
let
|
|
4730
|
+
return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((l) => {
|
|
4731
|
+
const c = l.section.index, d = l.section.href, f = l.position(), p = l.width(), g = l.height();
|
|
4732
|
+
let v, y, b, T;
|
|
4733
|
+
n ? (v = r + e.top - f.top + o, y = v + i - o, T = this.layout.count(g, i).pages, b = i) : (v = r + e.left - f.left + o, y = v + s - o, T = this.layout.count(p, s).pages, b = s);
|
|
4734
|
+
let x = Math.ceil(v / b), S = [], I = Math.ceil(y / b);
|
|
4779
4735
|
if (this.settings.direction === "rtl" && !n) {
|
|
4780
|
-
const
|
|
4781
|
-
|
|
4736
|
+
const D = x;
|
|
4737
|
+
x = T - I, I = T - D;
|
|
4782
4738
|
}
|
|
4783
|
-
|
|
4784
|
-
for (let
|
|
4785
|
-
const
|
|
4786
|
-
|
|
4739
|
+
S = [];
|
|
4740
|
+
for (let D = x; D <= I; D++) {
|
|
4741
|
+
const O = D + 1;
|
|
4742
|
+
S.push(O);
|
|
4787
4743
|
}
|
|
4788
|
-
const Y = this.mapping.page(
|
|
4744
|
+
const Y = this.mapping.page(l.contents, l.section.cfiBase, v, y);
|
|
4789
4745
|
return {
|
|
4790
4746
|
index: c,
|
|
4791
4747
|
href: d,
|
|
4792
|
-
pages:
|
|
4748
|
+
pages: S,
|
|
4793
4749
|
totalPages: T,
|
|
4794
4750
|
mapping: Y
|
|
4795
4751
|
};
|
|
@@ -4800,28 +4756,28 @@ class Z {
|
|
|
4800
4756
|
let i = 0, s = 0;
|
|
4801
4757
|
return this.settings.fullsize && (i = window.scrollX), t.map((r) => {
|
|
4802
4758
|
const o = r.section.index, h = r.section.href;
|
|
4803
|
-
let
|
|
4759
|
+
let l;
|
|
4804
4760
|
const c = r.position(), d = r.width();
|
|
4805
|
-
let
|
|
4806
|
-
this.settings.direction === "rtl" ? (
|
|
4807
|
-
const
|
|
4808
|
-
let
|
|
4761
|
+
let f, p, g;
|
|
4762
|
+
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, f = p - g) : (l = e.left + i, g = Math.min(c.right - l, this.layout.width) - s, f = l - c.left + s, p = f + g), s += g;
|
|
4763
|
+
const v = this.mapping.page(r.contents, r.section.cfiBase, f, p), y = this.layout.count(d).pages;
|
|
4764
|
+
let b = Math.floor(f / this.layout.pageWidth);
|
|
4809
4765
|
const T = [];
|
|
4810
|
-
let
|
|
4811
|
-
if (
|
|
4812
|
-
const
|
|
4813
|
-
|
|
4766
|
+
let x = Math.floor(p / this.layout.pageWidth);
|
|
4767
|
+
if (b < 0 && (b = 0, x = x + 1), this.settings.direction === "rtl") {
|
|
4768
|
+
const S = b;
|
|
4769
|
+
b = y - x, x = y - S;
|
|
4814
4770
|
}
|
|
4815
|
-
for (let
|
|
4816
|
-
const I =
|
|
4771
|
+
for (let S = b + 1; S <= x; S++) {
|
|
4772
|
+
const I = S;
|
|
4817
4773
|
T.push(I);
|
|
4818
4774
|
}
|
|
4819
4775
|
return {
|
|
4820
4776
|
index: o,
|
|
4821
4777
|
href: h,
|
|
4822
4778
|
pages: T,
|
|
4823
|
-
totalPages:
|
|
4824
|
-
mapping:
|
|
4779
|
+
totalPages: y,
|
|
4780
|
+
mapping: v
|
|
4825
4781
|
};
|
|
4826
4782
|
});
|
|
4827
4783
|
}
|
|
@@ -4845,11 +4801,11 @@ class Z {
|
|
|
4845
4801
|
}
|
|
4846
4802
|
onScroll() {
|
|
4847
4803
|
let t, e;
|
|
4848
|
-
this.settings.fullsize ? (t = window.scrollY, e = window.scrollX) : (t = this.container.scrollTop, e = this.container.scrollLeft), this.scrollTop = t, this.scrollLeft = e, this.ignore ? this.ignore = !1 : (this.emit(
|
|
4804
|
+
this.settings.fullsize ? (t = window.scrollY, e = window.scrollX) : (t = this.container.scrollTop, e = this.container.scrollLeft), this.scrollTop = t, this.scrollLeft = e, this.ignore ? this.ignore = !1 : (this.emit(u.MANAGERS.SCROLL, {
|
|
4849
4805
|
top: t,
|
|
4850
4806
|
left: e
|
|
4851
4807
|
}), clearTimeout(this.afterScrolled), this.afterScrolled = setTimeout(() => {
|
|
4852
|
-
this.emit(
|
|
4808
|
+
this.emit(u.MANAGERS.SCROLLED, {
|
|
4853
4809
|
top: this.scrollTop,
|
|
4854
4810
|
left: this.scrollLeft
|
|
4855
4811
|
});
|
|
@@ -4869,7 +4825,7 @@ class Z {
|
|
|
4869
4825
|
), 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));
|
|
4870
4826
|
}
|
|
4871
4827
|
setLayout(t) {
|
|
4872
|
-
this.viewSettings.layout = t, this.mapping = new
|
|
4828
|
+
this.viewSettings.layout = t, this.mapping = new ut(t.props, this.settings.direction, this.settings.axis), this.views && this.views.forEach((e) => {
|
|
4873
4829
|
e && e.setLayout(t);
|
|
4874
4830
|
});
|
|
4875
4831
|
}
|
|
@@ -4877,7 +4833,7 @@ class Z {
|
|
|
4877
4833
|
this.writingMode = t;
|
|
4878
4834
|
}
|
|
4879
4835
|
updateAxis(t, e) {
|
|
4880
|
-
!e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new
|
|
4836
|
+
!e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new ut(this.layout.props, this.settings.direction, this.settings.axis)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
|
|
4881
4837
|
}
|
|
4882
4838
|
updateFlow(t, e = "auto") {
|
|
4883
4839
|
const i = t === "paginated" || t === "auto";
|
|
@@ -4897,23 +4853,23 @@ class Z {
|
|
|
4897
4853
|
return this.rendered;
|
|
4898
4854
|
}
|
|
4899
4855
|
}
|
|
4900
|
-
A(
|
|
4901
|
-
const
|
|
4902
|
-
easeInCubic: function(
|
|
4903
|
-
return Math.pow(
|
|
4856
|
+
A(K.prototype);
|
|
4857
|
+
const ze = {
|
|
4858
|
+
easeInCubic: function(a) {
|
|
4859
|
+
return Math.pow(a, 3);
|
|
4904
4860
|
}
|
|
4905
4861
|
};
|
|
4906
|
-
class
|
|
4862
|
+
class ft {
|
|
4907
4863
|
constructor(t, e) {
|
|
4908
4864
|
this.settings = _({
|
|
4909
4865
|
duration: 80,
|
|
4910
4866
|
minVelocity: 0.2,
|
|
4911
4867
|
minDistance: 10,
|
|
4912
|
-
easing:
|
|
4868
|
+
easing: ze.easeInCubic
|
|
4913
4869
|
}, e || {}), this._supportsTouch = this.supportsTouch(), this._supportsTouch && this.setup(t);
|
|
4914
4870
|
}
|
|
4915
4871
|
setup(t) {
|
|
4916
|
-
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
|
|
4872
|
+
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());
|
|
4917
4873
|
}
|
|
4918
4874
|
supportsTouch() {
|
|
4919
4875
|
return "ontouchstart" in window || "DocumentTouch" in window;
|
|
@@ -4925,10 +4881,10 @@ class pt {
|
|
|
4925
4881
|
this.element.style.overflow = "";
|
|
4926
4882
|
}
|
|
4927
4883
|
addListeners() {
|
|
4928
|
-
this._onResize = this.onResize.bind(this), window.addEventListener("resize", this._onResize), this._onScroll = this.onScroll.bind(this), this.scroller.addEventListener("scroll", this._onScroll), this._onTouchStart = this.onTouchStart.bind(this), this.scroller.addEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.on("touchstart", this._onTouchStart), this._onTouchMove = this.onTouchMove.bind(this), this.scroller.addEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.on("touchmove", this._onTouchMove), this._onTouchEnd = this.onTouchEnd.bind(this), this.scroller.addEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.on("touchend", this._onTouchEnd), this._afterDisplayed = this.afterDisplayed.bind(this), this.manager.on(
|
|
4884
|
+
this._onResize = this.onResize.bind(this), window.addEventListener("resize", this._onResize), this._onScroll = this.onScroll.bind(this), this.scroller.addEventListener("scroll", this._onScroll), this._onTouchStart = this.onTouchStart.bind(this), this.scroller.addEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.on("touchstart", this._onTouchStart), this._onTouchMove = this.onTouchMove.bind(this), this.scroller.addEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.on("touchmove", this._onTouchMove), this._onTouchEnd = this.onTouchEnd.bind(this), this.scroller.addEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.on("touchend", this._onTouchEnd), this._afterDisplayed = this.afterDisplayed.bind(this), this.manager.on(u.MANAGERS.ADDED, this._afterDisplayed);
|
|
4929
4885
|
}
|
|
4930
4886
|
removeListeners() {
|
|
4931
|
-
window.removeEventListener("resize", this._onResize), this._onResize = void 0, this.scroller.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, this.scroller.removeEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.off("touchstart", this._onTouchStart), this._onTouchStart = void 0, this.scroller.removeEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.off("touchmove", this._onTouchMove), this._onTouchMove = void 0, this.scroller.removeEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.off("touchend", this._onTouchEnd), this._onTouchEnd = void 0, this.manager.off(
|
|
4887
|
+
window.removeEventListener("resize", this._onResize), this._onResize = void 0, this.scroller.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, this.scroller.removeEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.off("touchstart", this._onTouchStart), this._onTouchStart = void 0, this.scroller.removeEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.off("touchmove", this._onTouchMove), this._onTouchMove = void 0, this.scroller.removeEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.off("touchend", this._onTouchEnd), this._onTouchEnd = void 0, this.manager.off(u.MANAGERS.ADDED, this._afterDisplayed), this._afterDisplayed = void 0;
|
|
4932
4888
|
}
|
|
4933
4889
|
afterDisplayed(t) {
|
|
4934
4890
|
const e = t.contents;
|
|
@@ -4974,38 +4930,39 @@ class pt {
|
|
|
4974
4930
|
return t && (s += t * i), this.smoothScrollTo(s);
|
|
4975
4931
|
}
|
|
4976
4932
|
smoothScrollTo(t) {
|
|
4977
|
-
const e =
|
|
4978
|
-
this.snapping = !0
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4933
|
+
const e = this.scrollLeft, i = this.now(), s = this.settings.duration, n = this.settings.easing;
|
|
4934
|
+
return this.snapping = !0, new Promise((r) => {
|
|
4935
|
+
const o = () => {
|
|
4936
|
+
const h = this.now(), l = Math.min(1, (h - i) / s), c = n(l);
|
|
4937
|
+
if (this.touchCanceler || this.resizeCanceler) {
|
|
4938
|
+
this.resizeCanceler = !1, this.snapping = !1, r();
|
|
4939
|
+
return;
|
|
4940
|
+
}
|
|
4941
|
+
l < 1 ? (window.requestAnimationFrame(o), this.scrollTo(e + (t - e) * c, 0)) : (this.scrollTo(t, 0), this.snapping = !1, r());
|
|
4942
|
+
};
|
|
4943
|
+
o();
|
|
4944
|
+
});
|
|
4988
4945
|
}
|
|
4989
4946
|
scrollTo(t = 0, e = 0) {
|
|
4990
4947
|
this.fullsize ? window.scroll(t, e) : (this.scroller.scrollLeft = t, this.scroller.scrollTop = e);
|
|
4991
4948
|
}
|
|
4992
4949
|
now() {
|
|
4993
|
-
return
|
|
4950
|
+
return performance.now();
|
|
4994
4951
|
}
|
|
4995
4952
|
destroy() {
|
|
4996
4953
|
this.scroller && (this.fullsize && this.enableScroll(), this.removeListeners(), this.scroller = void 0);
|
|
4997
4954
|
}
|
|
4998
4955
|
}
|
|
4999
|
-
A(
|
|
5000
|
-
function
|
|
4956
|
+
A(ft.prototype);
|
|
4957
|
+
function De(a, t) {
|
|
5001
4958
|
let e;
|
|
5002
4959
|
return function(...i) {
|
|
5003
4960
|
clearTimeout(e), e = setTimeout(() => {
|
|
5004
|
-
|
|
4961
|
+
a.call(this, ...i);
|
|
5005
4962
|
}, t);
|
|
5006
4963
|
};
|
|
5007
4964
|
}
|
|
5008
|
-
class
|
|
4965
|
+
class Be extends K {
|
|
5009
4966
|
constructor(t) {
|
|
5010
4967
|
super(t), this.name = "continuous", this.settings = _({}, {
|
|
5011
4968
|
infinite: !0,
|
|
@@ -5036,20 +4993,19 @@ class ze extends Z {
|
|
|
5036
4993
|
}, this.scrollTop = 0, this.scrollLeft = 0;
|
|
5037
4994
|
}
|
|
5038
4995
|
display(t, e) {
|
|
5039
|
-
return
|
|
4996
|
+
return K.prototype.display.call(this, t, e).then(() => this.fill());
|
|
5040
4997
|
}
|
|
5041
|
-
fill(
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
}), e.promise;
|
|
4998
|
+
async fill() {
|
|
4999
|
+
let t = !0;
|
|
5000
|
+
for (; t; )
|
|
5001
|
+
t = await this.q.enqueue(() => this.check());
|
|
5046
5002
|
}
|
|
5047
5003
|
moveTo(t) {
|
|
5048
5004
|
let e = 0, i = 0;
|
|
5049
5005
|
this.isPaginated ? (e = Math.floor(t.left / this.layout.delta) * this.layout.delta, e + (this.settings.offsetDelta ?? 0)) : (i = t.top, t.top + (this.settings.offsetDelta ?? 0)), (e > 0 || i > 0) && this.scrollBy(e, i, !0);
|
|
5050
5006
|
}
|
|
5051
5007
|
afterResized(t) {
|
|
5052
|
-
this.emit(
|
|
5008
|
+
this.emit(u.MANAGERS.RESIZE, t.section);
|
|
5053
5009
|
}
|
|
5054
5010
|
// Remove Previous Listeners if present
|
|
5055
5011
|
removeShownListeners(t) {
|
|
@@ -5058,35 +5014,33 @@ class ze extends Z {
|
|
|
5058
5014
|
}
|
|
5059
5015
|
add(t) {
|
|
5060
5016
|
const e = this.createView(t);
|
|
5061
|
-
return this.views.append(e), e.on(
|
|
5017
|
+
return this.views.append(e), e.on(u.VIEWS.RESIZED, (i) => {
|
|
5062
5018
|
e.expanded = !0;
|
|
5063
|
-
}), e.on(
|
|
5019
|
+
}), e.on(u.VIEWS.AXIS, (i) => {
|
|
5064
5020
|
this.updateAxis(i);
|
|
5065
|
-
}), e.on(
|
|
5021
|
+
}), e.on(u.VIEWS.WRITING_MODE, (i) => {
|
|
5066
5022
|
this.updateWritingMode(i);
|
|
5067
5023
|
}), e.onDisplayed = (i) => this.afterDisplayed(i), e.onResize = (i) => this.afterResized(i), e.display(this.request);
|
|
5068
5024
|
}
|
|
5069
|
-
// @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
|
|
5070
5025
|
append(t) {
|
|
5071
5026
|
const e = this.createView(t);
|
|
5072
|
-
return e.on(
|
|
5027
|
+
return e.on(u.VIEWS.RESIZED, (i) => {
|
|
5073
5028
|
e.expanded = !0;
|
|
5074
|
-
}), e.on(
|
|
5029
|
+
}), e.on(u.VIEWS.AXIS, (i) => {
|
|
5075
5030
|
this.updateAxis(i);
|
|
5076
|
-
}), e.on(
|
|
5031
|
+
}), e.on(u.VIEWS.WRITING_MODE, (i) => {
|
|
5077
5032
|
this.updateWritingMode(i);
|
|
5078
|
-
}), this.views.append(e), e.onDisplayed = (i) => this.afterDisplayed(i), e;
|
|
5033
|
+
}), this.views.append(e), e.onDisplayed = (i) => this.afterDisplayed(i), Promise.resolve(e);
|
|
5079
5034
|
}
|
|
5080
|
-
// @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
|
|
5081
5035
|
prepend(t) {
|
|
5082
5036
|
const e = this.createView(t);
|
|
5083
|
-
return e.on(
|
|
5037
|
+
return e.on(u.VIEWS.RESIZED, (i) => {
|
|
5084
5038
|
this.counter(i), e.expanded = !0;
|
|
5085
|
-
}), e.on(
|
|
5039
|
+
}), e.on(u.VIEWS.AXIS, (i) => {
|
|
5086
5040
|
this.updateAxis(i);
|
|
5087
|
-
}), e.on(
|
|
5041
|
+
}), e.on(u.VIEWS.WRITING_MODE, (i) => {
|
|
5088
5042
|
this.updateWritingMode(i);
|
|
5089
|
-
}), this.views.prepend(e), e.onDisplayed = (i) => this.afterDisplayed(i), e;
|
|
5043
|
+
}), this.views.prepend(e), e.onDisplayed = (i) => this.afterDisplayed(i), Promise.resolve(e);
|
|
5090
5044
|
}
|
|
5091
5045
|
counter(t) {
|
|
5092
5046
|
this.settings.axis === "vertical" ? this.scrollBy(0, t.heightDelta, !0) : this.scrollBy(t.widthDelta, 0, !0);
|
|
@@ -5094,57 +5048,57 @@ class ze extends Z {
|
|
|
5094
5048
|
update(t) {
|
|
5095
5049
|
const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
|
|
5096
5050
|
let r, o;
|
|
5097
|
-
const h = new
|
|
5051
|
+
const h = new C(), l = [];
|
|
5098
5052
|
for (let c = 0; c < s; c++)
|
|
5099
5053
|
if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
|
|
5100
5054
|
if (o.displayed)
|
|
5101
5055
|
o.show();
|
|
5102
5056
|
else {
|
|
5103
|
-
const d = o.display(this.request).then(function(
|
|
5104
|
-
|
|
5105
|
-
}, (
|
|
5057
|
+
const d = o.display(this.request).then(function(f) {
|
|
5058
|
+
f.show();
|
|
5059
|
+
}, (f) => {
|
|
5106
5060
|
o.hide();
|
|
5107
5061
|
});
|
|
5108
|
-
|
|
5062
|
+
l.push(d);
|
|
5109
5063
|
}
|
|
5110
5064
|
else
|
|
5111
5065
|
this.q.enqueue(() => o.destroy()), clearTimeout(this.trimTimeout), this.trimTimeout = setTimeout(() => {
|
|
5112
5066
|
this.q.enqueue(() => this.trim());
|
|
5113
5067
|
}, 250);
|
|
5114
|
-
return
|
|
5068
|
+
return l.length ? Promise.all(l).catch((c) => {
|
|
5115
5069
|
h.reject(c);
|
|
5116
5070
|
}) : (h.resolve(), h.promise);
|
|
5117
5071
|
}
|
|
5118
5072
|
check(t, e) {
|
|
5119
|
-
const i = new
|
|
5073
|
+
const i = new C(), s = [], n = this.settings.axis === "horizontal";
|
|
5120
5074
|
let r = this.settings.offset || 0;
|
|
5121
5075
|
t && n && (r = t), e && !n && (r = e);
|
|
5122
5076
|
const o = this._bounds;
|
|
5123
5077
|
let h = n ? this.scrollLeft : this.scrollTop;
|
|
5124
|
-
const
|
|
5125
|
-
this.settings.fullsize ? (n && p &&
|
|
5078
|
+
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", f = this.settings.rtlScrollType, p = this.settings.direction === "rtl";
|
|
5079
|
+
this.settings.fullsize ? (n && p && f === "negative" || !n && p && f === "default") && (h = h * -1) : (p && f === "default" && d === "horizontal" && (h = c - l - h), p && f === "negative" && d === "horizontal" && (h = h * -1));
|
|
5126
5080
|
const g = () => {
|
|
5127
|
-
const
|
|
5128
|
-
|
|
5129
|
-
},
|
|
5130
|
-
const
|
|
5131
|
-
|
|
5132
|
-
},
|
|
5133
|
-
|
|
5134
|
-
const T = s.map((
|
|
5135
|
-
return s.length ? Promise.all(T).then(() => this.check()).then(() => this.update(r), (
|
|
5081
|
+
const x = this.views.first(), S = x && x.section.prev?.();
|
|
5082
|
+
S && s.push(this.prepend(S));
|
|
5083
|
+
}, v = () => {
|
|
5084
|
+
const x = this.views.last(), S = x && x.section.next?.();
|
|
5085
|
+
S && s.push(this.append(S));
|
|
5086
|
+
}, y = h + l + r, b = h - r;
|
|
5087
|
+
y >= c && v(), b < 0 && g();
|
|
5088
|
+
const T = s.map((x) => x.then((S) => S.display(this.request)));
|
|
5089
|
+
return s.length ? Promise.all(T).then(() => this.check()).then(() => this.update(r), (x) => x) : (this.q.enqueue(() => {
|
|
5136
5090
|
this.update();
|
|
5137
5091
|
}), i.resolve(!1), i.promise);
|
|
5138
5092
|
}
|
|
5139
5093
|
trim() {
|
|
5140
|
-
const t = new
|
|
5094
|
+
const t = new C(), e = this.views.displayed();
|
|
5141
5095
|
if (!e.length)
|
|
5142
5096
|
return t.resolve(), t.promise;
|
|
5143
5097
|
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);
|
|
5144
|
-
for (let
|
|
5145
|
-
this.erase(o[
|
|
5146
|
-
for (let
|
|
5147
|
-
this.erase(h[
|
|
5098
|
+
for (let l = 0; l < o.length - 1; l++)
|
|
5099
|
+
this.erase(o[l], o);
|
|
5100
|
+
for (let l = 1; l < h.length; l++)
|
|
5101
|
+
this.erase(h[l]);
|
|
5148
5102
|
return t.resolve(), t.promise;
|
|
5149
5103
|
}
|
|
5150
5104
|
erase(t, e) {
|
|
@@ -5156,13 +5110,12 @@ class ze extends Z {
|
|
|
5156
5110
|
addEventListeners(t) {
|
|
5157
5111
|
this._onUnload = (e) => {
|
|
5158
5112
|
this.ignore = !0, this.destroy();
|
|
5159
|
-
}, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new
|
|
5113
|
+
}, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new ft(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
|
|
5160
5114
|
}
|
|
5161
5115
|
addScrollListeners() {
|
|
5162
5116
|
let t;
|
|
5163
|
-
this.tick = Tt;
|
|
5164
5117
|
const e = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
|
|
5165
|
-
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 =
|
|
5118
|
+
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 = De(() => this.scrolled(), 30), this.didScroll = !1;
|
|
5166
5119
|
}
|
|
5167
5120
|
removeEventListeners() {
|
|
5168
5121
|
let t;
|
|
@@ -5176,11 +5129,11 @@ class ze extends Z {
|
|
|
5176
5129
|
}, 150), clearTimeout(this.afterScrolled), this.didScroll = !1;
|
|
5177
5130
|
}
|
|
5178
5131
|
scrolled() {
|
|
5179
|
-
this.q.enqueue(() => this.check()), this.emit(
|
|
5132
|
+
this.q.enqueue(() => this.check()), this.emit(u.MANAGERS.SCROLL, {
|
|
5180
5133
|
top: this.scrollTop,
|
|
5181
5134
|
left: this.scrollLeft
|
|
5182
5135
|
}), clearTimeout(this.afterScrolled), this.afterScrolled = setTimeout(() => {
|
|
5183
|
-
this.snapper && this.snapper.supportsTouch() && this.snapper.needsSnap() || this.emit(
|
|
5136
|
+
this.snapper && this.snapper.supportsTouch() && this.snapper.needsSnap() || this.emit(u.MANAGERS.SCROLLED, {
|
|
5184
5137
|
top: this.scrollTop,
|
|
5185
5138
|
left: this.scrollLeft
|
|
5186
5139
|
});
|
|
@@ -5195,13 +5148,13 @@ class ze extends Z {
|
|
|
5195
5148
|
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()));
|
|
5196
5149
|
}
|
|
5197
5150
|
updateFlow(t) {
|
|
5198
|
-
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
|
|
5151
|
+
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 ft(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
|
|
5199
5152
|
}
|
|
5200
5153
|
destroy() {
|
|
5201
5154
|
clearTimeout(this.scrollTimeout), clearTimeout(this.trimTimeout), super.destroy(), this.snapper && this.snapper.destroy();
|
|
5202
5155
|
}
|
|
5203
5156
|
}
|
|
5204
|
-
class
|
|
5157
|
+
class Wt {
|
|
5205
5158
|
constructor(t, e) {
|
|
5206
5159
|
this.settings = _({}, {
|
|
5207
5160
|
width: null,
|
|
@@ -5220,7 +5173,7 @@ class Mt {
|
|
|
5220
5173
|
defaultDirection: "ltr",
|
|
5221
5174
|
allowScriptedContent: !1,
|
|
5222
5175
|
allowPopups: !1
|
|
5223
|
-
}), _(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new
|
|
5176
|
+
}), _(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new R(this), this.hooks.serialize = new R(this), this.hooks.content = new R(this), this.hooks.unloaded = new R(this), this.hooks.layout = new R(this), this.hooks.render = new R(this), this.hooks.show = new R(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 ye(this), this.annotations = new we(this), this.epubcfi = new m(), this.q = new pt(this), this.location = void 0, this.q.enqueue(this.book.opened), this.starting = new C(), this.started = this.starting.promise, this.q.enqueue(this.start);
|
|
5224
5177
|
}
|
|
5225
5178
|
/**
|
|
5226
5179
|
* Set the manager function
|
|
@@ -5236,7 +5189,7 @@ class Mt {
|
|
|
5236
5189
|
*/
|
|
5237
5190
|
requireManager(t) {
|
|
5238
5191
|
let e;
|
|
5239
|
-
return typeof t == "string" && t === "default" ? e =
|
|
5192
|
+
return typeof t == "string" && t === "default" ? e = K : typeof t == "string" && t === "continuous" ? e = Be : e = t, e;
|
|
5240
5193
|
}
|
|
5241
5194
|
/**
|
|
5242
5195
|
* Require the view from passed string, or as a class function
|
|
@@ -5245,7 +5198,7 @@ class Mt {
|
|
|
5245
5198
|
*/
|
|
5246
5199
|
requireView(t) {
|
|
5247
5200
|
let e;
|
|
5248
|
-
return typeof t == "string" && t === "iframe" ? e =
|
|
5201
|
+
return typeof t == "string" && t === "iframe" ? e = Mt : e = t, e;
|
|
5249
5202
|
}
|
|
5250
5203
|
/**
|
|
5251
5204
|
* Start the rendering
|
|
@@ -5265,7 +5218,7 @@ class Mt {
|
|
|
5265
5218
|
queue: this.q,
|
|
5266
5219
|
request: this.book.load.bind(this.book),
|
|
5267
5220
|
settings: this.settings
|
|
5268
|
-
})), this.direction(this.book.package.metadata.direction || this.settings.defaultDirection), this.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata), this.flow(this.settings.globalLayoutProperties.flow), this.layout(this.settings.globalLayoutProperties), this.manager.on(
|
|
5221
|
+
})), this.direction(this.book.package.metadata.direction || this.settings.defaultDirection), this.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata), this.flow(this.settings.globalLayoutProperties.flow), this.layout(this.settings.globalLayoutProperties), this.manager.on(u.MANAGERS.ADDED, (t) => this.afterDisplayed(t)), this.manager.on(u.MANAGERS.REMOVED, (t) => this.afterRemoved(t)), this.manager.on(u.MANAGERS.RESIZED, (t, e) => this.onResized(t, e)), this.manager.on(u.MANAGERS.ORIENTATION_CHANGE, (t) => this.onOrientationChange(t)), this.manager.on(u.MANAGERS.SCROLLED, () => this.reportLocation()), this.emit(u.RENDITION.STARTED), this.starting.resolve();
|
|
5269
5222
|
}
|
|
5270
5223
|
/**
|
|
5271
5224
|
* Call to attach the container to an element in the dom
|
|
@@ -5278,7 +5231,7 @@ class Mt {
|
|
|
5278
5231
|
this.manager.render(t, {
|
|
5279
5232
|
width: this.settings.width,
|
|
5280
5233
|
height: this.settings.height
|
|
5281
|
-
}), this.emit(
|
|
5234
|
+
}), this.emit(u.RENDITION.ATTACHED);
|
|
5282
5235
|
});
|
|
5283
5236
|
}
|
|
5284
5237
|
/**
|
|
@@ -5302,13 +5255,13 @@ class Mt {
|
|
|
5302
5255
|
if (!this.book)
|
|
5303
5256
|
return;
|
|
5304
5257
|
this.epubcfi.isCfiString(t);
|
|
5305
|
-
const e = new
|
|
5306
|
-
this.displaying = e, this.book.locations.length() &&
|
|
5258
|
+
const e = new C(), i = e.promise;
|
|
5259
|
+
this.displaying = e, this.book.locations.length() && Yt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
|
|
5307
5260
|
const s = this.book.spine.get(t);
|
|
5308
5261
|
return s ? (this.manager.display(s, t).then(() => {
|
|
5309
|
-
e.resolve(s), this.displaying = void 0, this.emit(
|
|
5262
|
+
e.resolve(s), this.displaying = void 0, this.emit(u.RENDITION.DISPLAYED, s), this.reportLocation();
|
|
5310
5263
|
}, (n) => {
|
|
5311
|
-
this.emit(
|
|
5264
|
+
this.emit(u.RENDITION.DISPLAY_ERROR, n);
|
|
5312
5265
|
}), i) : (e.reject(new Error("No Section Found")), i);
|
|
5313
5266
|
}
|
|
5314
5267
|
/*
|
|
@@ -5361,12 +5314,12 @@ class Mt {
|
|
|
5361
5314
|
* @param {*} view
|
|
5362
5315
|
*/
|
|
5363
5316
|
afterDisplayed(t) {
|
|
5364
|
-
t.on(
|
|
5317
|
+
t.on(u.VIEWS.MARK_CLICKED, (e, i) => {
|
|
5365
5318
|
t.contents && this.triggerMarkEvent(e, i, t.contents);
|
|
5366
5319
|
}), this.hooks.render.trigger(t, this).then(() => {
|
|
5367
5320
|
t.contents ? this.hooks.content.trigger(t.contents, this).then(() => {
|
|
5368
|
-
this.emit(
|
|
5369
|
-
}) : this.emit(
|
|
5321
|
+
this.emit(u.RENDITION.RENDERED, t.section, t);
|
|
5322
|
+
}) : this.emit(u.RENDITION.RENDERED, t.section, t);
|
|
5370
5323
|
});
|
|
5371
5324
|
}
|
|
5372
5325
|
/**
|
|
@@ -5376,7 +5329,7 @@ class Mt {
|
|
|
5376
5329
|
*/
|
|
5377
5330
|
afterRemoved(t) {
|
|
5378
5331
|
this.hooks.unloaded.trigger(t, this).then(() => {
|
|
5379
|
-
this.emit(
|
|
5332
|
+
this.emit(u.RENDITION.REMOVED, t.section, t);
|
|
5380
5333
|
});
|
|
5381
5334
|
}
|
|
5382
5335
|
/**
|
|
@@ -5384,7 +5337,7 @@ class Mt {
|
|
|
5384
5337
|
* @private
|
|
5385
5338
|
*/
|
|
5386
5339
|
onResized(t, e) {
|
|
5387
|
-
this.emit(
|
|
5340
|
+
this.emit(u.RENDITION.RESIZED, {
|
|
5388
5341
|
width: t.width,
|
|
5389
5342
|
height: t.height
|
|
5390
5343
|
}, e), this.location && this.location.start && this.display(e || this.location.start.cfi);
|
|
@@ -5394,7 +5347,7 @@ class Mt {
|
|
|
5394
5347
|
* @private
|
|
5395
5348
|
*/
|
|
5396
5349
|
onOrientationChange(t) {
|
|
5397
|
-
this.emit(
|
|
5350
|
+
this.emit(u.RENDITION.ORIENTATION_CHANGE, t);
|
|
5398
5351
|
}
|
|
5399
5352
|
/**
|
|
5400
5353
|
* Move the Rendition to a specific offset
|
|
@@ -5466,13 +5419,13 @@ class Mt {
|
|
|
5466
5419
|
* @param {object} settings
|
|
5467
5420
|
*/
|
|
5468
5421
|
layout(t) {
|
|
5469
|
-
return t && (this._layout = new
|
|
5470
|
-
this.emit(
|
|
5422
|
+
return t && (this._layout = new Ot(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(u.LAYOUT.UPDATED, (e, i) => {
|
|
5423
|
+
this.emit(u.RENDITION.LAYOUT, e, i);
|
|
5471
5424
|
})), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
|
|
5472
5425
|
}
|
|
5473
5426
|
/**
|
|
5474
5427
|
* Adjust if the rendition uses spreads
|
|
5475
|
-
* @param {string} spread none | auto
|
|
5428
|
+
* @param {string} spread none | auto
|
|
5476
5429
|
* @param {int} [min] min width to use spreads at
|
|
5477
5430
|
*/
|
|
5478
5431
|
spread(t, e) {
|
|
@@ -5496,25 +5449,25 @@ class Mt {
|
|
|
5496
5449
|
if (t && "then" in t && typeof t.then == "function")
|
|
5497
5450
|
t.then((e) => {
|
|
5498
5451
|
const i = this.located(e);
|
|
5499
|
-
!i || !i.start || !i.end || (this.location = i, this.emit(
|
|
5452
|
+
!i || !i.start || !i.end || (this.location = i, this.emit(u.RENDITION.LOCATION_CHANGED, {
|
|
5500
5453
|
index: this.location.start.index,
|
|
5501
5454
|
href: this.location.start.href,
|
|
5502
5455
|
start: this.location.start.cfi,
|
|
5503
5456
|
end: this.location.end.cfi,
|
|
5504
5457
|
percentage: this.location.start.percentage
|
|
5505
|
-
}), this.emit(
|
|
5458
|
+
}), this.emit(u.RENDITION.RELOCATED, this.location));
|
|
5506
5459
|
});
|
|
5507
5460
|
else if (t) {
|
|
5508
5461
|
const e = this.located(t);
|
|
5509
5462
|
if (!e || !e.start || !e.end)
|
|
5510
5463
|
return;
|
|
5511
|
-
this.location = e, this.emit(
|
|
5464
|
+
this.location = e, this.emit(u.RENDITION.LOCATION_CHANGED, {
|
|
5512
5465
|
index: this.location.start.index,
|
|
5513
5466
|
href: this.location.start.href,
|
|
5514
5467
|
start: this.location.start.cfi,
|
|
5515
5468
|
end: this.location.end.cfi,
|
|
5516
5469
|
percentage: this.location.start.percentage
|
|
5517
|
-
}), this.emit(
|
|
5470
|
+
}), this.emit(u.RENDITION.RELOCATED, this.location);
|
|
5518
5471
|
}
|
|
5519
5472
|
});
|
|
5520
5473
|
});
|
|
@@ -5561,13 +5514,13 @@ class Mt {
|
|
|
5561
5514
|
}, n = this.book.locations.locationFromCfi(e.mapping.start), r = this.book.locations.locationFromCfi(i.mapping.end);
|
|
5562
5515
|
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));
|
|
5563
5516
|
const o = this.book.pageList.pageFromCfi(e.mapping.start), h = this.book.pageList.pageFromCfi(i.mapping.end);
|
|
5564
|
-
return o
|
|
5517
|
+
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;
|
|
5565
5518
|
}
|
|
5566
5519
|
/**
|
|
5567
5520
|
* Remove and Clean Up the Rendition
|
|
5568
5521
|
*/
|
|
5569
5522
|
destroy() {
|
|
5570
|
-
this.q.clear(), this.manager && (this.manager.off(
|
|
5523
|
+
this.q.clear(), this.manager && (this.manager.off(u.MANAGERS.ADDED), this.manager.off(u.MANAGERS.REMOVED), this.manager.off(u.MANAGERS.RESIZED), this.manager.off(u.MANAGERS.ORIENTATION_CHANGE), this.manager.off(u.MANAGERS.SCROLLED), this.manager.destroy(), this.manager = void 0), this.book = void 0, this.hooks.display.clear(), this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks.unloaded.clear(), this.hooks.layout.clear(), this.hooks.render.clear(), this.hooks.show.clear(), this.themes.destroy(), this._layout && this._layout.off(u.LAYOUT.UPDATED), this._layout = void 0, this.location = void 0;
|
|
5571
5524
|
}
|
|
5572
5525
|
/**
|
|
5573
5526
|
* Pass the events from a view's Contents
|
|
@@ -5577,7 +5530,7 @@ class Mt {
|
|
|
5577
5530
|
passEvents(t) {
|
|
5578
5531
|
G.forEach((e) => {
|
|
5579
5532
|
t.on(e, (i) => this.triggerViewEvent(i, t));
|
|
5580
|
-
}), t.on(
|
|
5533
|
+
}), t.on(u.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, t));
|
|
5581
5534
|
}
|
|
5582
5535
|
/**
|
|
5583
5536
|
* Emit events passed by a view
|
|
@@ -5593,7 +5546,7 @@ class Mt {
|
|
|
5593
5546
|
* @param {string} cfirange
|
|
5594
5547
|
*/
|
|
5595
5548
|
triggerSelectedEvent(t, e) {
|
|
5596
|
-
this.emit(
|
|
5549
|
+
this.emit(u.RENDITION.SELECTED, t, e);
|
|
5597
5550
|
}
|
|
5598
5551
|
/**
|
|
5599
5552
|
* Emit a markClicked event with the cfiRange and data from a mark
|
|
@@ -5601,7 +5554,7 @@ class Mt {
|
|
|
5601
5554
|
* @param {EpubCFI} cfirange
|
|
5602
5555
|
*/
|
|
5603
5556
|
triggerMarkEvent(t, e, i) {
|
|
5604
|
-
this.emit(
|
|
5557
|
+
this.emit(u.RENDITION.MARK_CLICKED, t, e, i);
|
|
5605
5558
|
}
|
|
5606
5559
|
/**
|
|
5607
5560
|
* Get a Range from a Visible CFI
|
|
@@ -5642,10 +5595,8 @@ class Mt {
|
|
|
5642
5595
|
"page-break-inside": "avoid",
|
|
5643
5596
|
"break-inside": "avoid"
|
|
5644
5597
|
}
|
|
5645
|
-
}), new Promise(function(n
|
|
5646
|
-
setTimeout(
|
|
5647
|
-
n();
|
|
5648
|
-
}, 1);
|
|
5598
|
+
}), new Promise(function(n) {
|
|
5599
|
+
setTimeout(n, 0);
|
|
5649
5600
|
});
|
|
5650
5601
|
}
|
|
5651
5602
|
/**
|
|
@@ -5668,7 +5619,7 @@ class Mt {
|
|
|
5668
5619
|
* @private
|
|
5669
5620
|
*/
|
|
5670
5621
|
handleLinks(t) {
|
|
5671
|
-
t && t.on(
|
|
5622
|
+
t && t.on(u.CONTENTS.LINK_CLICKED, (e) => {
|
|
5672
5623
|
const i = this.book.path.relative(e);
|
|
5673
5624
|
this.display(i);
|
|
5674
5625
|
});
|
|
@@ -5707,8 +5658,9 @@ class Mt {
|
|
|
5707
5658
|
s.setAttribute("name", "dc.relation.ispartof"), i && s.setAttribute("content", i), t.getElementsByTagName("head")[0].appendChild(s);
|
|
5708
5659
|
}
|
|
5709
5660
|
}
|
|
5710
|
-
A(
|
|
5711
|
-
|
|
5661
|
+
A(Wt.prototype);
|
|
5662
|
+
const st = typeof window < "u" ? window.URL : URL;
|
|
5663
|
+
class Me {
|
|
5712
5664
|
constructor() {
|
|
5713
5665
|
this.zip = void 0, this.urlCache = {}, this.checkRequirements();
|
|
5714
5666
|
}
|
|
@@ -5719,7 +5671,7 @@ class De {
|
|
|
5719
5671
|
*/
|
|
5720
5672
|
checkRequirements() {
|
|
5721
5673
|
try {
|
|
5722
|
-
this.zip = new
|
|
5674
|
+
this.zip = new Ft();
|
|
5723
5675
|
} catch {
|
|
5724
5676
|
throw new Error("JSZip lib not loaded");
|
|
5725
5677
|
}
|
|
@@ -5748,17 +5700,14 @@ class De {
|
|
|
5748
5700
|
* @param {string} [type] specify the type of the returned result
|
|
5749
5701
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
5750
5702
|
*/
|
|
5751
|
-
request(t, e) {
|
|
5752
|
-
const i = new
|
|
5753
|
-
|
|
5754
|
-
const
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
message: "File not found in the epub: " + t,
|
|
5760
|
-
stack: new Error().stack
|
|
5761
|
-
}), i.promise;
|
|
5703
|
+
async request(t, e) {
|
|
5704
|
+
const i = new P(t);
|
|
5705
|
+
e || (e = i.extension);
|
|
5706
|
+
const s = e === "blob" ? this.getBlob(t) : this.getText(t);
|
|
5707
|
+
if (!s)
|
|
5708
|
+
throw new q("File not found in the epub: " + t);
|
|
5709
|
+
const n = await s;
|
|
5710
|
+
return this.handleResponse(n, e);
|
|
5762
5711
|
}
|
|
5763
5712
|
/**
|
|
5764
5713
|
* Handle the response from request
|
|
@@ -5768,8 +5717,7 @@ class De {
|
|
|
5768
5717
|
* @return {any} the parsed result
|
|
5769
5718
|
*/
|
|
5770
5719
|
handleResponse(t, e) {
|
|
5771
|
-
|
|
5772
|
-
return e == "json" ? i = JSON.parse(t) : K(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;
|
|
5720
|
+
return Nt(t, e);
|
|
5773
5721
|
}
|
|
5774
5722
|
/**
|
|
5775
5723
|
* Get a Blob from Archive by Url
|
|
@@ -5816,46 +5764,50 @@ class De {
|
|
|
5816
5764
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
5817
5765
|
* @return {Promise} url promise with Url string
|
|
5818
5766
|
*/
|
|
5819
|
-
createUrl(t, e) {
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5767
|
+
async createUrl(t, e) {
|
|
5768
|
+
if (t in this.urlCache)
|
|
5769
|
+
return this.urlCache[t];
|
|
5770
|
+
if (e && e.base64) {
|
|
5771
|
+
const s = this.getBase64(t);
|
|
5772
|
+
if (s) {
|
|
5773
|
+
const n = await s;
|
|
5774
|
+
return this.urlCache[t] = n, n;
|
|
5775
|
+
}
|
|
5776
|
+
} else {
|
|
5777
|
+
const s = this.getBlob(t);
|
|
5778
|
+
if (s) {
|
|
5779
|
+
const n = await s, r = st.createObjectURL(n);
|
|
5780
|
+
return this.urlCache[t] = r, r;
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
throw new q("File not found in the epub: " + t);
|
|
5831
5784
|
}
|
|
5832
5785
|
/**
|
|
5833
5786
|
* Revoke Temp Url for a archive item
|
|
5834
5787
|
* @param {string} url url of the item in the archive
|
|
5835
5788
|
*/
|
|
5836
5789
|
revokeUrl(t) {
|
|
5837
|
-
const e =
|
|
5838
|
-
|
|
5790
|
+
const e = this.urlCache[t];
|
|
5791
|
+
e && st.revokeObjectURL(e);
|
|
5839
5792
|
}
|
|
5840
5793
|
destroy() {
|
|
5841
|
-
const t
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
i && t.revokeObjectURL(i);
|
|
5794
|
+
for (const t in this.urlCache) {
|
|
5795
|
+
const e = this.urlCache[t];
|
|
5796
|
+
e && st.revokeObjectURL(e);
|
|
5845
5797
|
}
|
|
5846
5798
|
this.zip = void 0, this.urlCache = {};
|
|
5847
5799
|
}
|
|
5848
5800
|
}
|
|
5849
|
-
function
|
|
5801
|
+
function We(a) {
|
|
5850
5802
|
return new Promise((t, e) => {
|
|
5851
|
-
const i = indexedDB.open(
|
|
5803
|
+
const i = indexedDB.open(a, 1);
|
|
5852
5804
|
i.onupgradeneeded = () => {
|
|
5853
5805
|
i.result.createObjectStore("data");
|
|
5854
5806
|
}, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
|
|
5855
5807
|
});
|
|
5856
5808
|
}
|
|
5857
|
-
function
|
|
5858
|
-
const t =
|
|
5809
|
+
function qe(a) {
|
|
5810
|
+
const t = We(a);
|
|
5859
5811
|
return {
|
|
5860
5812
|
getItem(e) {
|
|
5861
5813
|
return t.then((i) => new Promise((s, n) => {
|
|
@@ -5871,7 +5823,7 @@ function Me(l) {
|
|
|
5871
5823
|
}
|
|
5872
5824
|
};
|
|
5873
5825
|
}
|
|
5874
|
-
const nt = typeof window < "u" ? window.URL
|
|
5826
|
+
const nt = typeof window < "u" ? window.URL : void 0;
|
|
5875
5827
|
class qt {
|
|
5876
5828
|
constructor(t, e, i) {
|
|
5877
5829
|
this.urlCache = {}, this.name = t, this.requester = e || V, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
|
|
@@ -5884,7 +5836,7 @@ class qt {
|
|
|
5884
5836
|
try {
|
|
5885
5837
|
if (typeof indexedDB > "u")
|
|
5886
5838
|
throw new Error("IndexedDB not available");
|
|
5887
|
-
this.storage =
|
|
5839
|
+
this.storage = qe(this.name);
|
|
5888
5840
|
} catch {
|
|
5889
5841
|
throw new Error("IndexedDB not available");
|
|
5890
5842
|
}
|
|
@@ -5920,7 +5872,7 @@ class qt {
|
|
|
5920
5872
|
add(t, e) {
|
|
5921
5873
|
const i = t.resources.map((s) => {
|
|
5922
5874
|
const { href: n } = s, r = this.resolver(n), o = encodeURIComponent(r);
|
|
5923
|
-
return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((
|
|
5875
|
+
return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((l) => this.storage.setItem(o, l)) : h);
|
|
5924
5876
|
});
|
|
5925
5877
|
return Promise.all(i);
|
|
5926
5878
|
}
|
|
@@ -5952,17 +5904,13 @@ class qt {
|
|
|
5952
5904
|
* @param {string} [type] specify the type of the returned result
|
|
5953
5905
|
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
5954
5906
|
*/
|
|
5955
|
-
retrieve(t, e) {
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
message: "File not found in storage: " + t,
|
|
5963
|
-
stack: new Error().stack
|
|
5964
|
-
}), r.promise;
|
|
5965
|
-
});
|
|
5907
|
+
async retrieve(t, e) {
|
|
5908
|
+
const i = new P(t);
|
|
5909
|
+
e || (e = i.extension);
|
|
5910
|
+
const s = e === "blob" ? await this.getBlob(t) : await this.getText(t);
|
|
5911
|
+
if (s)
|
|
5912
|
+
return this.handleResponse(s, e);
|
|
5913
|
+
throw new q("File not found in storage: " + t);
|
|
5966
5914
|
}
|
|
5967
5915
|
/**
|
|
5968
5916
|
* Handle the response from request
|
|
@@ -5972,8 +5920,7 @@ class qt {
|
|
|
5972
5920
|
* @return {string | Document | Blob | object} the parsed result
|
|
5973
5921
|
*/
|
|
5974
5922
|
handleResponse(t, e) {
|
|
5975
|
-
|
|
5976
|
-
return e == "json" ? i = JSON.parse(t) : K(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;
|
|
5923
|
+
return Nt(t, e);
|
|
5977
5924
|
}
|
|
5978
5925
|
/**
|
|
5979
5926
|
* Get a Blob from Storage by Url
|
|
@@ -6006,15 +5953,17 @@ class qt {
|
|
|
6006
5953
|
* @param {string} [mimeType]
|
|
6007
5954
|
* @return {string} base64 encoded
|
|
6008
5955
|
*/
|
|
6009
|
-
getBase64(t, e) {
|
|
5956
|
+
async getBase64(t, e) {
|
|
6010
5957
|
const i = encodeURIComponent(t);
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
5958
|
+
e = e || H.lookup(t);
|
|
5959
|
+
const s = await this.storage.getItem(i);
|
|
5960
|
+
if (!s) return;
|
|
5961
|
+
const n = new Blob([s], { type: e });
|
|
5962
|
+
return new Promise((r) => {
|
|
5963
|
+
const o = new FileReader();
|
|
5964
|
+
o.addEventListener("loadend", () => {
|
|
5965
|
+
r(o.result);
|
|
5966
|
+
}), o.readAsDataURL(n);
|
|
6018
5967
|
});
|
|
6019
5968
|
}
|
|
6020
5969
|
/**
|
|
@@ -6023,18 +5972,21 @@ class qt {
|
|
|
6023
5972
|
* @param {object} [options.base64] use base64 encoding or blob url
|
|
6024
5973
|
* @return {Promise} url promise with Url string
|
|
6025
5974
|
*/
|
|
6026
|
-
createUrl(t, e) {
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
5975
|
+
async createUrl(t, e) {
|
|
5976
|
+
if (t in this.urlCache)
|
|
5977
|
+
return this.urlCache[t];
|
|
5978
|
+
if (e && e.base64) {
|
|
5979
|
+
const s = await this.getBase64(t);
|
|
5980
|
+
if (s)
|
|
5981
|
+
return this.urlCache[t] = s, s;
|
|
5982
|
+
} else {
|
|
5983
|
+
const s = await this.getBlob(t);
|
|
5984
|
+
if (s) {
|
|
5985
|
+
const n = nt.createObjectURL(s);
|
|
5986
|
+
return this.urlCache[t] = n, n;
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
throw new q("File not found in storage: " + t);
|
|
6038
5990
|
}
|
|
6039
5991
|
/**
|
|
6040
5992
|
* Revoke Temp Url for a archive item
|
|
@@ -6065,8 +6017,8 @@ class rt {
|
|
|
6065
6017
|
parse(t) {
|
|
6066
6018
|
if (!t)
|
|
6067
6019
|
return this;
|
|
6068
|
-
const e =
|
|
6069
|
-
return e ? (
|
|
6020
|
+
const e = w(t, "display_options");
|
|
6021
|
+
return e ? (B(e, "option").forEach((s) => {
|
|
6070
6022
|
let n = "";
|
|
6071
6023
|
switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
|
|
6072
6024
|
case "interactive":
|
|
@@ -6088,7 +6040,7 @@ class rt {
|
|
|
6088
6040
|
this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
|
|
6089
6041
|
}
|
|
6090
6042
|
}
|
|
6091
|
-
const
|
|
6043
|
+
const Ct = "META-INF/container.xml", Ue = "META-INF/com.apple.ibooks.display-options.xml", L = {
|
|
6092
6044
|
BINARY: "binary",
|
|
6093
6045
|
BASE64: "base64",
|
|
6094
6046
|
EPUB: "epub",
|
|
@@ -6096,7 +6048,7 @@ const _t = "META-INF/container.xml", qe = "META-INF/com.apple.ibooks.display-opt
|
|
|
6096
6048
|
MANIFEST: "json",
|
|
6097
6049
|
DIRECTORY: "directory"
|
|
6098
6050
|
};
|
|
6099
|
-
class
|
|
6051
|
+
class je {
|
|
6100
6052
|
constructor(t, e) {
|
|
6101
6053
|
typeof e > "u" && typeof t != "string" && !(t instanceof Blob) && !(t instanceof ArrayBuffer) && (e = t, t = void 0), this.settings = _({}, {
|
|
6102
6054
|
requestMethod: void 0,
|
|
@@ -6107,15 +6059,15 @@ class We {
|
|
|
6107
6059
|
canonical: void 0,
|
|
6108
6060
|
openAs: void 0,
|
|
6109
6061
|
store: void 0
|
|
6110
|
-
}), _(this.settings, e), this.opening = new
|
|
6111
|
-
manifest: new
|
|
6112
|
-
spine: new
|
|
6113
|
-
metadata: new
|
|
6114
|
-
cover: new
|
|
6115
|
-
navigation: new
|
|
6116
|
-
pageList: new
|
|
6117
|
-
resources: new
|
|
6118
|
-
displayOptions: new
|
|
6062
|
+
}), _(this.settings, e), this.opening = new C(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
|
|
6063
|
+
manifest: new C(),
|
|
6064
|
+
spine: new C(),
|
|
6065
|
+
metadata: new C(),
|
|
6066
|
+
cover: new C(),
|
|
6067
|
+
navigation: new C(),
|
|
6068
|
+
pageList: new C(),
|
|
6069
|
+
resources: new C(),
|
|
6070
|
+
displayOptions: new C()
|
|
6119
6071
|
}, this.loaded = {
|
|
6120
6072
|
manifest: this.loading.manifest.promise,
|
|
6121
6073
|
spine: this.loading.spine.promise,
|
|
@@ -6133,9 +6085,9 @@ class We {
|
|
|
6133
6085
|
this.loaded.navigation,
|
|
6134
6086
|
this.loaded.resources,
|
|
6135
6087
|
this.loaded.displayOptions
|
|
6136
|
-
]), this.isRendered = !1, this.request = this.settings.requestMethod || V, this.spine = new
|
|
6088
|
+
]), this.isRendered = !1, this.request = this.settings.requestMethod || V, this.spine = new ue(), this.locations = new Pt(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) => {
|
|
6137
6089
|
const s = new Error("Cannot load book at " + t);
|
|
6138
|
-
this.emit(
|
|
6090
|
+
this.emit(u.BOOK.OPEN_FAILED, s);
|
|
6139
6091
|
});
|
|
6140
6092
|
}
|
|
6141
6093
|
/**
|
|
@@ -6148,7 +6100,7 @@ class We {
|
|
|
6148
6100
|
open(t, e) {
|
|
6149
6101
|
let i;
|
|
6150
6102
|
const s = e || this.determineType(t);
|
|
6151
|
-
return s ===
|
|
6103
|
+
return s === L.BINARY ? (this.archived = !0, this.url = new N("/", ""), i = this.openEpub(t)) : s === L.BASE64 ? (this.archived = !0, this.url = new N("/", ""), i = this.openEpub(t, s)) : s === L.EPUB ? (this.archived = !0, this.url = new N("/", ""), i = this.request(t, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then((n) => this.openEpub(n))) : s === L.OPF ? (this.url = new N(t), i = this.openPackaging(this.url.Path.toString())) : s === L.MANIFEST ? (this.url = new N(t), i = this.openManifest(this.url.Path.toString())) : (this.url = new N(t), i = this.openContainer(Ct).then((n) => this.openPackaging(n))), i;
|
|
6152
6104
|
}
|
|
6153
6105
|
/**
|
|
6154
6106
|
* Open an archived epub
|
|
@@ -6158,7 +6110,7 @@ class We {
|
|
|
6158
6110
|
* @return {Promise}
|
|
6159
6111
|
*/
|
|
6160
6112
|
openEpub(t, e) {
|
|
6161
|
-
return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(
|
|
6113
|
+
return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(Ct)).then((i) => this.openPackaging(i));
|
|
6162
6114
|
}
|
|
6163
6115
|
/**
|
|
6164
6116
|
* Open the epub container
|
|
@@ -6167,7 +6119,7 @@ class We {
|
|
|
6167
6119
|
* @return {string} packagePath
|
|
6168
6120
|
*/
|
|
6169
6121
|
openContainer(t) {
|
|
6170
|
-
return this.load(t).then((e) => (this.container = new
|
|
6122
|
+
return this.load(t).then((e) => (this.container = new fe(e), this.resolve(this.container.packagePath)));
|
|
6171
6123
|
}
|
|
6172
6124
|
/**
|
|
6173
6125
|
* Open the Open Packaging Format Xml
|
|
@@ -6176,7 +6128,7 @@ class We {
|
|
|
6176
6128
|
* @return {Promise}
|
|
6177
6129
|
*/
|
|
6178
6130
|
openPackaging(t) {
|
|
6179
|
-
return this.path = new P(t), this.load(t).then((e) => (this.packaging = new
|
|
6131
|
+
return this.path = new P(t), this.load(t).then((e) => (this.packaging = new xt(e), this.unpack(this.packaging)));
|
|
6180
6132
|
}
|
|
6181
6133
|
/**
|
|
6182
6134
|
* Open the manifest JSON
|
|
@@ -6185,7 +6137,7 @@ class We {
|
|
|
6185
6137
|
* @return {Promise}
|
|
6186
6138
|
*/
|
|
6187
6139
|
openManifest(t) {
|
|
6188
|
-
return this.path = new P(t), this.load(t).then((e) => (this.packaging = new
|
|
6140
|
+
return this.path = new P(t), this.load(t).then((e) => (this.packaging = new xt(), this.packaging.load(e), this.unpack(this.packaging)));
|
|
6189
6141
|
}
|
|
6190
6142
|
/**
|
|
6191
6143
|
* Load a resource from the Book
|
|
@@ -6206,7 +6158,7 @@ class We {
|
|
|
6206
6158
|
if (!t)
|
|
6207
6159
|
return "";
|
|
6208
6160
|
let i = t;
|
|
6209
|
-
return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e
|
|
6161
|
+
return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e !== !1 && this.url && (i = this.url.resolve(i)), i);
|
|
6210
6162
|
}
|
|
6211
6163
|
/**
|
|
6212
6164
|
* Get a canonical link to a path
|
|
@@ -6226,17 +6178,17 @@ class We {
|
|
|
6226
6178
|
determineType(t) {
|
|
6227
6179
|
let e;
|
|
6228
6180
|
if (this.settings.encoding === "base64")
|
|
6229
|
-
return
|
|
6181
|
+
return L.BASE64;
|
|
6230
6182
|
if (typeof t != "string")
|
|
6231
|
-
return
|
|
6232
|
-
if (e = new
|
|
6233
|
-
return
|
|
6183
|
+
return L.BINARY;
|
|
6184
|
+
if (e = new N(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
|
|
6185
|
+
return L.DIRECTORY;
|
|
6234
6186
|
if (e === "epub")
|
|
6235
|
-
return
|
|
6187
|
+
return L.EPUB;
|
|
6236
6188
|
if (e === "opf")
|
|
6237
|
-
return
|
|
6189
|
+
return L.OPF;
|
|
6238
6190
|
if (e === "json")
|
|
6239
|
-
return
|
|
6191
|
+
return L.MANIFEST;
|
|
6240
6192
|
}
|
|
6241
6193
|
/**
|
|
6242
6194
|
* unpack the contents of the Books packaging
|
|
@@ -6244,11 +6196,11 @@ class We {
|
|
|
6244
6196
|
* @param {Packaging} packaging object
|
|
6245
6197
|
*/
|
|
6246
6198
|
unpack(t) {
|
|
6247
|
-
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(
|
|
6199
|
+
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(Ue)).then((i) => {
|
|
6248
6200
|
this.displayOptions = new rt(i), this.loading.displayOptions.resolve(this.displayOptions);
|
|
6249
6201
|
}).catch((i) => {
|
|
6250
6202
|
this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions);
|
|
6251
|
-
}) : (this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new
|
|
6203
|
+
}) : (this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new ve(this.packaging.manifest, {
|
|
6252
6204
|
archive: this.archive,
|
|
6253
6205
|
resolver: (i, s) => this.resolve(i, s),
|
|
6254
6206
|
request: (i, s) => this.request(i, s),
|
|
@@ -6269,9 +6221,9 @@ class We {
|
|
|
6269
6221
|
loadNavigation(t) {
|
|
6270
6222
|
const e = t.navPath || t.ncxPath, i = t.toc;
|
|
6271
6223
|
return i ? new Promise((s, n) => {
|
|
6272
|
-
this.navigation = new
|
|
6273
|
-
}) : e ? this.load(e, "xml").then((s) => (this.navigation = new
|
|
6274
|
-
this.navigation = new
|
|
6224
|
+
this.navigation = new tt(i), "pageList" in t && t.pageList && (this.pageList = new it(t.pageList)), s(this.navigation);
|
|
6225
|
+
}) : e ? this.load(e, "xml").then((s) => (this.navigation = new tt(s), this.pageList = new it(s), this.navigation)) : new Promise((s, n) => {
|
|
6226
|
+
this.navigation = new tt(), this.pageList = new it(), s(this.navigation);
|
|
6275
6227
|
});
|
|
6276
6228
|
}
|
|
6277
6229
|
/**
|
|
@@ -6290,7 +6242,7 @@ class We {
|
|
|
6290
6242
|
* @return {Rendition}
|
|
6291
6243
|
*/
|
|
6292
6244
|
renderTo(t, e) {
|
|
6293
|
-
return this.rendition = new
|
|
6245
|
+
return this.rendition = new Wt(this, e), this.rendition.attachTo(t), this.rendition;
|
|
6294
6246
|
}
|
|
6295
6247
|
/**
|
|
6296
6248
|
* Set if request should use withCredentials
|
|
@@ -6314,7 +6266,7 @@ class We {
|
|
|
6314
6266
|
* @return {Archive}
|
|
6315
6267
|
*/
|
|
6316
6268
|
unarchive(t, e) {
|
|
6317
|
-
return this.archive = new
|
|
6269
|
+
return this.archive = new Me(), this.archive.open(t, e === "base64");
|
|
6318
6270
|
}
|
|
6319
6271
|
/**
|
|
6320
6272
|
* Store the epubs contents
|
|
@@ -6331,7 +6283,7 @@ class We {
|
|
|
6331
6283
|
o.output = this.resources.substitute(r, o.url);
|
|
6332
6284
|
};
|
|
6333
6285
|
this.resources.settings.replacements = e || "blobUrl", this.resources.replacements().then(() => this.resources.replaceCss()), this.storage.on("offline", () => {
|
|
6334
|
-
this.url = new
|
|
6286
|
+
this.url = new N("/", ""), this.spine.hooks.serialize.register(n);
|
|
6335
6287
|
}), this.storage.on("online", () => {
|
|
6336
6288
|
this.url = i, this.spine.hooks.serialize.deregister(n);
|
|
6337
6289
|
});
|
|
@@ -6376,7 +6328,7 @@ class We {
|
|
|
6376
6328
|
*/
|
|
6377
6329
|
key(t) {
|
|
6378
6330
|
const e = t || this.packaging.metadata.identifier || this.url.filename;
|
|
6379
|
-
return `epubjs:${
|
|
6331
|
+
return `epubjs:${It}:${e}`;
|
|
6380
6332
|
}
|
|
6381
6333
|
/**
|
|
6382
6334
|
* Destroy the Book and all associated objects
|
|
@@ -6385,30 +6337,30 @@ class We {
|
|
|
6385
6337
|
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;
|
|
6386
6338
|
}
|
|
6387
6339
|
}
|
|
6388
|
-
A(
|
|
6389
|
-
typeof globalThis.DOMParser > "u" && (globalThis.DOMParser =
|
|
6340
|
+
A(je.prototype);
|
|
6341
|
+
typeof globalThis.DOMParser > "u" && (globalThis.DOMParser = Ut);
|
|
6390
6342
|
typeof globalThis.XMLSerializer > "u" && (globalThis.XMLSerializer = class {
|
|
6391
6343
|
serializeToString(t) {
|
|
6392
6344
|
return t.toString();
|
|
6393
6345
|
}
|
|
6394
6346
|
});
|
|
6395
6347
|
if (typeof globalThis.document > "u") {
|
|
6396
|
-
const { document:
|
|
6397
|
-
globalThis.document =
|
|
6348
|
+
const { document: a } = jt("<!DOCTYPE html><html><head></head><body></body></html>");
|
|
6349
|
+
globalThis.document = a;
|
|
6398
6350
|
}
|
|
6399
6351
|
export {
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6352
|
+
Me as Archive,
|
|
6353
|
+
je as Book,
|
|
6354
|
+
fe as Container,
|
|
6403
6355
|
rt as DisplayOptions,
|
|
6404
6356
|
m as EpubCFI,
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6357
|
+
Ot as Layout,
|
|
6358
|
+
Pt as Locations,
|
|
6359
|
+
tt as Navigation,
|
|
6360
|
+
xt as Packaging,
|
|
6361
|
+
it as PageList,
|
|
6362
|
+
ve as Resources,
|
|
6363
|
+
de as Section,
|
|
6364
|
+
ue as Spine
|
|
6413
6365
|
};
|
|
6414
6366
|
//# sourceMappingURL=epub.node.js.map
|