@likecoin/epub-ts 0.4.6 → 0.4.8
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/epub.cjs +3 -3
- package/dist/epub.cjs.map +1 -1
- package/dist/epub.js +228 -160
- 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 +192 -124
- package/dist/epub.node.js.map +1 -1
- package/dist/epub.umd.js +3 -3
- package/dist/epub.umd.js.map +1 -1
- package/package.json +7 -3
package/dist/epub.node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DOMParser as qt, parseHTML as
|
|
2
|
-
import
|
|
1
|
+
import { DOMParser as qt, parseHTML as Ut } from "linkedom";
|
|
2
|
+
import jt from "jszip";
|
|
3
3
|
function A(l) {
|
|
4
4
|
const t = typeof l == "function" ? l.prototype : l;
|
|
5
5
|
return t.on = function(e, i) {
|
|
@@ -15,7 +15,7 @@ function A(l) {
|
|
|
15
15
|
s[n](...i);
|
|
16
16
|
}, l;
|
|
17
17
|
}
|
|
18
|
-
const Tt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : !1,
|
|
18
|
+
const Tt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : !1, Ft = 1, Lt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
|
|
19
19
|
function gt() {
|
|
20
20
|
let l = (/* @__PURE__ */ new Date()).getTime();
|
|
21
21
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
@@ -23,13 +23,13 @@ function gt() {
|
|
|
23
23
|
return l = Math.floor(l / 16), (e == "x" ? i : i & 7 | 8).toString(16);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Vt(l) {
|
|
27
27
|
return !!(l && l.nodeType == 1);
|
|
28
28
|
}
|
|
29
29
|
function S(l) {
|
|
30
30
|
return !isNaN(parseFloat(l)) && isFinite(l);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Ht(l) {
|
|
33
33
|
const t = parseFloat(l);
|
|
34
34
|
return S(l) === !1 ? !1 : typeof l == "string" && l.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
|
|
35
35
|
}
|
|
@@ -42,7 +42,7 @@ function j(l) {
|
|
|
42
42
|
return e[n] + i;
|
|
43
43
|
return l;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function Xt(l, ...t) {
|
|
46
46
|
for (let e = 0; e < t.length; e++) {
|
|
47
47
|
const i = t[e];
|
|
48
48
|
for (const s in i)
|
|
@@ -120,28 +120,28 @@ function lt() {
|
|
|
120
120
|
height: t
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Yt(l, t) {
|
|
124
124
|
const i = l.parentNode.childNodes;
|
|
125
125
|
let s, n = -1;
|
|
126
126
|
for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s != l); r++)
|
|
127
127
|
;
|
|
128
128
|
return n;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
130
|
+
function Gt(l) {
|
|
131
|
+
return Yt(l, Ft);
|
|
132
132
|
}
|
|
133
133
|
function K(l) {
|
|
134
134
|
return ["xml", "opf", "ncx"].indexOf(l) > -1;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function $t(l, t) {
|
|
137
137
|
return new Blob([l], { type: t });
|
|
138
138
|
}
|
|
139
139
|
function at(l, t) {
|
|
140
|
-
const e =
|
|
141
|
-
return
|
|
140
|
+
const e = $t(l, t);
|
|
141
|
+
return Lt.createObjectURL(e);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
143
|
+
function kt(l) {
|
|
144
|
+
return Lt.revokeObjectURL(l);
|
|
145
145
|
}
|
|
146
146
|
function yt(l, t) {
|
|
147
147
|
if (typeof l != "string")
|
|
@@ -160,7 +160,7 @@ function b(l, t) {
|
|
|
160
160
|
throw new Error("No Element Provided");
|
|
161
161
|
return l.querySelector(t);
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function M(l, t) {
|
|
164
164
|
return l.querySelectorAll(t);
|
|
165
165
|
}
|
|
166
166
|
function F(l, t, e) {
|
|
@@ -486,7 +486,7 @@ class R {
|
|
|
486
486
|
return this.href;
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
const
|
|
489
|
+
const W = 1, L = 3, re = 9;
|
|
490
490
|
class m {
|
|
491
491
|
constructor(t, e, i) {
|
|
492
492
|
if (this.str = "", this.base = {}, this.spinePos = 0, this.range = !1, this.path = {}, this.start = null, this.end = null, !(this instanceof m))
|
|
@@ -631,7 +631,7 @@ class m {
|
|
|
631
631
|
return o > h ? 1 : o < h ? -1 : 0;
|
|
632
632
|
}
|
|
633
633
|
step(t) {
|
|
634
|
-
const e = t.nodeType ===
|
|
634
|
+
const e = t.nodeType === L ? "text" : "element";
|
|
635
635
|
return {
|
|
636
636
|
id: t.id,
|
|
637
637
|
tagName: t.tagName,
|
|
@@ -643,7 +643,7 @@ class m {
|
|
|
643
643
|
const i = this.filter(t, e);
|
|
644
644
|
if (!i)
|
|
645
645
|
return;
|
|
646
|
-
const s = i.nodeType ===
|
|
646
|
+
const s = i.nodeType === L ? "text" : "element";
|
|
647
647
|
return {
|
|
648
648
|
id: i.id,
|
|
649
649
|
tagName: i.tagName,
|
|
@@ -724,14 +724,14 @@ class m {
|
|
|
724
724
|
}
|
|
725
725
|
filter(t, e) {
|
|
726
726
|
let i, s, n, r, o, h = !1;
|
|
727
|
-
return t.nodeType ===
|
|
727
|
+
return t.nodeType === L ? (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 === L ? s = r : o && o.nodeType === L && (s = o), s || t) : i && !h ? !1 : t;
|
|
728
728
|
}
|
|
729
729
|
patchOffset(t, e, i) {
|
|
730
|
-
if (t.nodeType !=
|
|
730
|
+
if (t.nodeType != L)
|
|
731
731
|
throw new Error("Anchor must be a text node");
|
|
732
732
|
let s = t, n = e;
|
|
733
733
|
for (t.parentNode.classList.contains(i) && (s = t.parentNode); s.previousSibling; ) {
|
|
734
|
-
if (s.previousSibling.nodeType ===
|
|
734
|
+
if (s.previousSibling.nodeType === W)
|
|
735
735
|
if (s.previousSibling.classList.contains(i))
|
|
736
736
|
n += (s.previousSibling.textContent ?? "").length;
|
|
737
737
|
else
|
|
@@ -748,16 +748,16 @@ class m {
|
|
|
748
748
|
const o = t.length;
|
|
749
749
|
let h, a;
|
|
750
750
|
for (r = 0; r < o; r++)
|
|
751
|
-
h = t[r].nodeType, h ===
|
|
751
|
+
h = t[r].nodeType, h === W && t[r].classList.contains(i) && (h = L), r > 0 && h === L && a === L ? s[r] = n : e === h && (n = n + 1, s[r] = n), a = h;
|
|
752
752
|
return s;
|
|
753
753
|
}
|
|
754
754
|
position(t) {
|
|
755
755
|
let e, i;
|
|
756
|
-
return t.nodeType ===
|
|
756
|
+
return t.nodeType === W ? (e = t.parentNode.children, e || (e = wt(t.parentNode)), i = Array.from(e).indexOf(t)) : (e = this.textNodes(t.parentNode), i = e.indexOf(t)), i;
|
|
757
757
|
}
|
|
758
758
|
filteredPosition(t, e) {
|
|
759
759
|
let i, s;
|
|
760
|
-
t.nodeType ===
|
|
760
|
+
t.nodeType === W ? (i = t.parentNode.children, s = this.normalizedMap(i, W, e)) : (i = t.parentNode.childNodes, t.parentNode.classList.contains(e) && (t = t.parentNode, i = t.parentNode.childNodes), s = this.normalizedMap(i, L, e));
|
|
761
761
|
const n = Array.from(i).indexOf(t);
|
|
762
762
|
return s[n];
|
|
763
763
|
}
|
|
@@ -792,7 +792,7 @@ class m {
|
|
|
792
792
|
}
|
|
793
793
|
textNodes(t, e) {
|
|
794
794
|
return Array.from(t.childNodes).filter(function(i) {
|
|
795
|
-
return i.nodeType ===
|
|
795
|
+
return i.nodeType === L ? !0 : !!(e && i.classList.contains(e));
|
|
796
796
|
});
|
|
797
797
|
}
|
|
798
798
|
walkToNode(t, e, i) {
|
|
@@ -813,7 +813,7 @@ class m {
|
|
|
813
813
|
let n = this.findNode(t.slice(0, -1), i, s);
|
|
814
814
|
if (!n)
|
|
815
815
|
return { container: (i ?? document).documentElement, offset: 0 };
|
|
816
|
-
const r = n.childNodes, o = this.normalizedMap(r,
|
|
816
|
+
const r = n.childNodes, o = this.normalizedMap(r, L, s);
|
|
817
817
|
let h, a;
|
|
818
818
|
const c = t[t.length - 1].index;
|
|
819
819
|
for (const d in o)
|
|
@@ -821,7 +821,7 @@ class m {
|
|
|
821
821
|
if (h = r[d], a = (h.textContent ?? "").length, e > a)
|
|
822
822
|
e = e - a;
|
|
823
823
|
else {
|
|
824
|
-
h.nodeType ===
|
|
824
|
+
h.nodeType === W ? n = h.childNodes[0] ?? h : n = h;
|
|
825
825
|
break;
|
|
826
826
|
}
|
|
827
827
|
return {
|
|
@@ -933,7 +933,7 @@ class N {
|
|
|
933
933
|
return this.hooks = [];
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function Rt(l, t) {
|
|
937
937
|
let e, i = t.url;
|
|
938
938
|
const s = i.indexOf("://") > -1;
|
|
939
939
|
if (!l)
|
|
@@ -1062,7 +1062,7 @@ class ae {
|
|
|
1062
1062
|
* @private
|
|
1063
1063
|
*/
|
|
1064
1064
|
base() {
|
|
1065
|
-
return
|
|
1065
|
+
return Rt(this.document, this);
|
|
1066
1066
|
}
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Render the contents of a section
|
|
@@ -1119,10 +1119,10 @@ class ae {
|
|
|
1119
1119
|
I.setStart(E, g);
|
|
1120
1120
|
const Y = d.slice(0, x).reduce((Q, J) => Q + (J.textContent ?? "").length, 0);
|
|
1121
1121
|
I.setEnd(C, Y > w ? w : w - Y);
|
|
1122
|
-
const
|
|
1122
|
+
const B = n.cfiFromRange(I);
|
|
1123
1123
|
let z = d.slice(0, x + 1).reduce((Q, J) => Q + (J.textContent ?? ""), "");
|
|
1124
1124
|
z.length > 150 && (z = z.substring(g - 150 / 2, g + 150 / 2), z = "..." + z + "..."), i.push({
|
|
1125
|
-
cfi:
|
|
1125
|
+
cfi: B,
|
|
1126
1126
|
excerpt: z
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
@@ -1179,7 +1179,7 @@ class ae {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
class ce {
|
|
1181
1181
|
constructor() {
|
|
1182
|
-
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new N(), this.hooks.content = new N(), this.hooks.content.register(
|
|
1182
|
+
this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new N(), this.hooks.content = new N(), this.hooks.content.register(Rt), this.hooks.content.register(oe), this.hooks.content.register(he), this.epubcfi = new m(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
|
|
1183
1183
|
}
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Unpack items from a opf into spine items
|
|
@@ -1387,7 +1387,7 @@ class mt {
|
|
|
1387
1387
|
this._q = [], this.running = !1, this.paused = !0;
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
|
-
const
|
|
1390
|
+
const Nt = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], u = {
|
|
1391
1391
|
BOOK: {
|
|
1392
1392
|
OPEN_FAILED: "openFailed"
|
|
1393
1393
|
},
|
|
@@ -1444,7 +1444,7 @@ const Rt = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
|
|
|
1444
1444
|
DETACH: "detach"
|
|
1445
1445
|
}
|
|
1446
1446
|
};
|
|
1447
|
-
class
|
|
1447
|
+
class At {
|
|
1448
1448
|
constructor(t, e, i) {
|
|
1449
1449
|
this.spine = t, this.request = e, this.pause = i || 100, this.q = new mt(this), 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;
|
|
1450
1450
|
}
|
|
@@ -1652,7 +1652,7 @@ class Nt {
|
|
|
1652
1652
|
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);
|
|
1653
1653
|
}
|
|
1654
1654
|
}
|
|
1655
|
-
A(
|
|
1655
|
+
A(At.prototype);
|
|
1656
1656
|
class de {
|
|
1657
1657
|
constructor(t) {
|
|
1658
1658
|
this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
|
|
@@ -1694,7 +1694,7 @@ class Et {
|
|
|
1694
1694
|
const s = b(t, "spine");
|
|
1695
1695
|
if (!s)
|
|
1696
1696
|
throw new Error("No Spine Found");
|
|
1697
|
-
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex =
|
|
1697
|
+
return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Gt(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") ?? "", {
|
|
1698
1698
|
metadata: this.metadata,
|
|
1699
1699
|
spine: this.spine,
|
|
1700
1700
|
manifest: this.manifest,
|
|
@@ -1721,7 +1721,7 @@ class Et {
|
|
|
1721
1721
|
* @return {object} manifest
|
|
1722
1722
|
*/
|
|
1723
1723
|
parseManifest(t) {
|
|
1724
|
-
const e = {}, i =
|
|
1724
|
+
const e = {}, i = M(t, "item");
|
|
1725
1725
|
return Array.from(i).forEach(function(n) {
|
|
1726
1726
|
const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "", a = n.getAttribute("media-overlay") || "", c = n.getAttribute("properties") || "", d = n.getAttribute("fallback") || "";
|
|
1727
1727
|
e[r] = {
|
|
@@ -1742,7 +1742,7 @@ class Et {
|
|
|
1742
1742
|
* @return {object} spine
|
|
1743
1743
|
*/
|
|
1744
1744
|
parseSpine(t, e) {
|
|
1745
|
-
const i = [], s =
|
|
1745
|
+
const i = [], s = M(t, "itemref");
|
|
1746
1746
|
return Array.from(s).forEach(function(r, o) {
|
|
1747
1747
|
const h = r.getAttribute("idref"), a = r.getAttribute("properties") || "", c = a.length ? a.split(" ") : [], d = {
|
|
1748
1748
|
id: r.getAttribute("id") ?? void 0,
|
|
@@ -1983,7 +1983,7 @@ class et {
|
|
|
1983
1983
|
* @return {array} landmarks list
|
|
1984
1984
|
*/
|
|
1985
1985
|
parseLandmarks(t) {
|
|
1986
|
-
const e = dt(t, "nav", "landmarks"), i = e ? Array.from(
|
|
1986
|
+
const e = dt(t, "nav", "landmarks"), i = e ? Array.from(M(e, "li")) : [], s = i.length;
|
|
1987
1987
|
let n;
|
|
1988
1988
|
const r = [];
|
|
1989
1989
|
let o;
|
|
@@ -2016,7 +2016,7 @@ class et {
|
|
|
2016
2016
|
* @return {array} navigation list
|
|
2017
2017
|
*/
|
|
2018
2018
|
parseNcx(t) {
|
|
2019
|
-
const e =
|
|
2019
|
+
const e = M(t, "navPoint"), i = e.length;
|
|
2020
2020
|
let s;
|
|
2021
2021
|
const n = {}, r = [];
|
|
2022
2022
|
let o, h;
|
|
@@ -2215,7 +2215,7 @@ const it = {
|
|
|
2215
2215
|
function pe(l) {
|
|
2216
2216
|
return l && ue[l.split(".").pop().toLowerCase()] || fe;
|
|
2217
2217
|
}
|
|
2218
|
-
const
|
|
2218
|
+
const q = { lookup: pe };
|
|
2219
2219
|
class ge {
|
|
2220
2220
|
constructor(t, e) {
|
|
2221
2221
|
this.settings = {
|
|
@@ -2262,7 +2262,7 @@ class ge {
|
|
|
2262
2262
|
* @return {Promise<string>} Promise resolves with url string
|
|
2263
2263
|
*/
|
|
2264
2264
|
createUrl(t) {
|
|
2265
|
-
const e = new R(t), i =
|
|
2265
|
+
const e = new R(t), i = q.lookup(e.filename);
|
|
2266
2266
|
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) => Qt(s)).then((s) => yt(s, i)) : this.settings.request(t, "blob").then((s) => at(s, i));
|
|
2267
2267
|
}
|
|
2268
2268
|
/**
|
|
@@ -2361,7 +2361,9 @@ class ge {
|
|
|
2361
2361
|
return e ? i = this.relativeTo(e) : i = this.urls, xt(t, i, this.replacementUrls);
|
|
2362
2362
|
}
|
|
2363
2363
|
destroy() {
|
|
2364
|
-
this.
|
|
2364
|
+
this.replacementUrls && this.replacementUrls.forEach((t) => {
|
|
2365
|
+
t && kt(t);
|
|
2366
|
+
}), 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;
|
|
2365
2367
|
}
|
|
2366
2368
|
}
|
|
2367
2369
|
class st {
|
|
@@ -2383,7 +2385,7 @@ class st {
|
|
|
2383
2385
|
* @return {PageList.item[]} list
|
|
2384
2386
|
*/
|
|
2385
2387
|
parseNav(t) {
|
|
2386
|
-
const e = dt(t, "nav", "page-list"), i = e ? Array.from(
|
|
2388
|
+
const e = dt(t, "nav", "page-list"), i = e ? Array.from(M(e, "li")) : [], s = i.length;
|
|
2387
2389
|
let n;
|
|
2388
2390
|
const r = [];
|
|
2389
2391
|
let o;
|
|
@@ -2397,7 +2399,7 @@ class st {
|
|
|
2397
2399
|
let i = 0, s, n = 0;
|
|
2398
2400
|
const r = b(t, "pageList");
|
|
2399
2401
|
if (!r) return e;
|
|
2400
|
-
const o =
|
|
2402
|
+
const o = M(r, "pageTarget");
|
|
2401
2403
|
if (n = o.length, !o || o.length === 0)
|
|
2402
2404
|
return e;
|
|
2403
2405
|
for (i = 0; i < n; ++i)
|
|
@@ -2496,7 +2498,7 @@ class st {
|
|
|
2496
2498
|
this.pages = void 0, this.locations = void 0, this.epubcfi = void 0, this.pageList = void 0, this.toc = void 0, this.ncx = void 0;
|
|
2497
2499
|
}
|
|
2498
2500
|
}
|
|
2499
|
-
class
|
|
2501
|
+
class It {
|
|
2500
2502
|
constructor(t) {
|
|
2501
2503
|
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 = {
|
|
2502
2504
|
name: this.name,
|
|
@@ -2589,7 +2591,7 @@ class At {
|
|
|
2589
2591
|
}
|
|
2590
2592
|
}
|
|
2591
2593
|
}
|
|
2592
|
-
A(
|
|
2594
|
+
A(It.prototype);
|
|
2593
2595
|
class me {
|
|
2594
2596
|
constructor(t) {
|
|
2595
2597
|
this.rendition = t, this._themes = {
|
|
@@ -2770,7 +2772,7 @@ class ve {
|
|
|
2770
2772
|
* @returns {Annotation} annotation
|
|
2771
2773
|
*/
|
|
2772
2774
|
add(t, e, i, s, n, r) {
|
|
2773
|
-
const o = encodeURI(e + t), a = new m(e).spinePos, c = new
|
|
2775
|
+
const o = encodeURI(e + t), a = new m(e).spinePos, c = new Ot({
|
|
2774
2776
|
type: t,
|
|
2775
2777
|
cfiRange: e,
|
|
2776
2778
|
data: i,
|
|
@@ -2889,7 +2891,7 @@ class ve {
|
|
|
2889
2891
|
hide() {
|
|
2890
2892
|
}
|
|
2891
2893
|
}
|
|
2892
|
-
class
|
|
2894
|
+
class Ot {
|
|
2893
2895
|
constructor({
|
|
2894
2896
|
type: t,
|
|
2895
2897
|
cfiRange: e,
|
|
@@ -2932,7 +2934,7 @@ class It {
|
|
|
2932
2934
|
text() {
|
|
2933
2935
|
}
|
|
2934
2936
|
}
|
|
2935
|
-
A(
|
|
2937
|
+
A(Ot.prototype);
|
|
2936
2938
|
class ft {
|
|
2937
2939
|
constructor(t, e, i, s = !1) {
|
|
2938
2940
|
this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
|
|
@@ -3173,13 +3175,13 @@ class ft {
|
|
|
3173
3175
|
return t && (this.horizontal = t === "horizontal"), this.horizontal;
|
|
3174
3176
|
}
|
|
3175
3177
|
}
|
|
3176
|
-
const
|
|
3177
|
-
class
|
|
3178
|
+
const Pt = typeof navigator < "u", ye = Pt && /Chrome/.test(navigator.userAgent), St = Pt && !ye && /AppleWebKit/.test(navigator.userAgent), we = 1;
|
|
3179
|
+
class zt {
|
|
3178
3180
|
constructor(t, e, i, s) {
|
|
3179
3181
|
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 = {
|
|
3180
3182
|
width: 0,
|
|
3181
3183
|
height: 0
|
|
3182
|
-
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js",
|
|
3184
|
+
}, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js", Nt), this.called = 0, this.active = !0, this.listeners();
|
|
3183
3185
|
}
|
|
3184
3186
|
/**
|
|
3185
3187
|
* Get DOM events that are listened for and passed along
|
|
@@ -3312,7 +3314,7 @@ class Pt {
|
|
|
3312
3314
|
const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/), a = 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*([^,]*)/);
|
|
3313
3315
|
o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]), a && a.length && typeof a[1] < "u" && (i.scale = a[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]);
|
|
3314
3316
|
}
|
|
3315
|
-
return n =
|
|
3317
|
+
return n = Xt(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;
|
|
3316
3318
|
}
|
|
3317
3319
|
/**
|
|
3318
3320
|
* Event emitter for when the contents has expanded
|
|
@@ -3326,7 +3328,7 @@ class Pt {
|
|
|
3326
3328
|
* @private
|
|
3327
3329
|
*/
|
|
3328
3330
|
listeners() {
|
|
3329
|
-
this.imageLoadListeners(), this.mediaQueryListeners(), this.addEventListeners(), this.addSelectionListeners(), typeof ResizeObserver > "u" ? (this.resizeListeners(), this.visibilityListeners()) : this.resizeObservers(), this.linksHandler();
|
|
3331
|
+
this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(), typeof ResizeObserver > "u" ? (this.resizeListeners(), this.visibilityListeners()) : this.resizeObservers(), this.linksHandler();
|
|
3330
3332
|
}
|
|
3331
3333
|
/**
|
|
3332
3334
|
* Remove DOM listeners
|
|
@@ -3798,7 +3800,7 @@ class Pt {
|
|
|
3798
3800
|
this.removeListeners(), this.__listeners = {};
|
|
3799
3801
|
}
|
|
3800
3802
|
}
|
|
3801
|
-
A(
|
|
3803
|
+
A(zt.prototype);
|
|
3802
3804
|
function X(l) {
|
|
3803
3805
|
return document.createElementNS("http://www.w3.org/2000/svg", l);
|
|
3804
3806
|
}
|
|
@@ -3940,7 +3942,7 @@ class Te {
|
|
|
3940
3942
|
});
|
|
3941
3943
|
}
|
|
3942
3944
|
}
|
|
3943
|
-
class
|
|
3945
|
+
class Dt extends Te {
|
|
3944
3946
|
constructor(t, e, i, s) {
|
|
3945
3947
|
super(), this.range = t, this.className = e, this.data = i || {}, this.attributes = s || {};
|
|
3946
3948
|
}
|
|
@@ -3963,7 +3965,7 @@ class zt extends Te {
|
|
|
3963
3965
|
this.element.appendChild(t);
|
|
3964
3966
|
}
|
|
3965
3967
|
}
|
|
3966
|
-
class
|
|
3968
|
+
class Le extends Dt {
|
|
3967
3969
|
constructor(t, e, i, s) {
|
|
3968
3970
|
super(t, e, i, s);
|
|
3969
3971
|
}
|
|
@@ -3980,7 +3982,7 @@ class ke extends zt {
|
|
|
3980
3982
|
this.element.appendChild(t);
|
|
3981
3983
|
}
|
|
3982
3984
|
}
|
|
3983
|
-
class
|
|
3985
|
+
class Bt {
|
|
3984
3986
|
constructor(t, e) {
|
|
3985
3987
|
this.settings = _({
|
|
3986
3988
|
ignoreClass: "",
|
|
@@ -4068,7 +4070,7 @@ class Dt {
|
|
|
4068
4070
|
return i;
|
|
4069
4071
|
}
|
|
4070
4072
|
onLoad(t, e) {
|
|
4071
|
-
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new
|
|
4073
|
+
this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new zt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
|
|
4072
4074
|
let i = this.document.querySelector("link[rel='canonical']");
|
|
4073
4075
|
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, () => {
|
|
4074
4076
|
this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
|
|
@@ -4141,7 +4143,7 @@ class Dt {
|
|
|
4141
4143
|
this.emit(u.VIEWS.MARK_CLICKED, t, e);
|
|
4142
4144
|
};
|
|
4143
4145
|
e.epubcfi = t, this.pane || (this.pane = new Ct(this.iframe, this.element));
|
|
4144
|
-
const a = new
|
|
4146
|
+
const a = new Dt(o, s, e, r);
|
|
4145
4147
|
let c;
|
|
4146
4148
|
try {
|
|
4147
4149
|
c = this.pane.addMark(a);
|
|
@@ -4158,7 +4160,7 @@ class Dt {
|
|
|
4158
4160
|
this.emit(u.VIEWS.MARK_CLICKED, t, e);
|
|
4159
4161
|
};
|
|
4160
4162
|
e.epubcfi = t, this.pane || (this.pane = new Ct(this.iframe, this.element));
|
|
4161
|
-
const a = new
|
|
4163
|
+
const a = new Le(o, s, e, r);
|
|
4162
4164
|
let c;
|
|
4163
4165
|
try {
|
|
4164
4166
|
c = this.pane.addMark(a);
|
|
@@ -4229,11 +4231,11 @@ class Dt {
|
|
|
4229
4231
|
this.ununderline(t);
|
|
4230
4232
|
for (const t in this.marks)
|
|
4231
4233
|
this.unmark(t);
|
|
4232
|
-
this.blobUrl &&
|
|
4234
|
+
this.blobUrl && kt(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 = {};
|
|
4233
4235
|
}
|
|
4234
4236
|
}
|
|
4235
|
-
A(
|
|
4236
|
-
function
|
|
4237
|
+
A(Bt.prototype);
|
|
4238
|
+
function ke() {
|
|
4237
4239
|
let l = "reverse";
|
|
4238
4240
|
const t = Re();
|
|
4239
4241
|
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;
|
|
@@ -4278,7 +4280,7 @@ class Ae {
|
|
|
4278
4280
|
}
|
|
4279
4281
|
getElement(t) {
|
|
4280
4282
|
let e = null;
|
|
4281
|
-
if (
|
|
4283
|
+
if (Vt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
|
|
4282
4284
|
throw new Error("Not an Element");
|
|
4283
4285
|
return e;
|
|
4284
4286
|
}
|
|
@@ -4466,7 +4468,7 @@ class Z {
|
|
|
4466
4468
|
}
|
|
4467
4469
|
render(t, e) {
|
|
4468
4470
|
const i = t.tagName;
|
|
4469
|
-
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 =
|
|
4471
|
+
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 = ke(), this.stage = new Ae({
|
|
4470
4472
|
width: e.width,
|
|
4471
4473
|
height: e.height,
|
|
4472
4474
|
overflow: this.overflow,
|
|
@@ -4603,29 +4605,93 @@ class Z {
|
|
|
4603
4605
|
next() {
|
|
4604
4606
|
let t, e;
|
|
4605
4607
|
const i = this.settings.direction;
|
|
4606
|
-
if (this.views.length
|
|
4607
|
-
this.
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4608
|
+
if (this.views.length) {
|
|
4609
|
+
if (this.isPaginated && this.settings.axis === "horizontal" && (!i || i === "ltr"))
|
|
4610
|
+
if (this.scrollLeft = this.container.scrollLeft, e = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta, e <= this.container.scrollWidth)
|
|
4611
|
+
this.scrollBy(this.layout.delta, 0, !0);
|
|
4612
|
+
else {
|
|
4613
|
+
const s = this.views.last();
|
|
4614
|
+
s && s.expand(), e = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta, e <= this.container.scrollWidth ? this.scrollBy(this.layout.delta, 0, !0) : t = s?.section.next?.();
|
|
4615
|
+
}
|
|
4616
|
+
else if (this.isPaginated && this.settings.axis === "horizontal" && i === "rtl")
|
|
4617
|
+
if (this.scrollLeft = this.container.scrollLeft, this.settings.rtlScrollType === "default")
|
|
4618
|
+
if (e = this.container.scrollLeft, e > 0)
|
|
4619
|
+
this.scrollBy(this.layout.delta, 0, !0);
|
|
4620
|
+
else {
|
|
4621
|
+
const s = this.views.last();
|
|
4622
|
+
s && s.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(this.layout.delta, 0, !0) : t = s?.section.next?.();
|
|
4623
|
+
}
|
|
4624
|
+
else if (e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1)
|
|
4625
|
+
this.scrollBy(this.layout.delta, 0, !0);
|
|
4626
|
+
else {
|
|
4627
|
+
const s = this.views.last();
|
|
4628
|
+
s && s.expand(), e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1 ? this.scrollBy(this.layout.delta, 0, !0) : t = s?.section.next?.();
|
|
4629
|
+
}
|
|
4630
|
+
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4631
|
+
if (this.scrollTop = this.container.scrollTop, !(Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1))
|
|
4632
|
+
this.scrollBy(0, this.layout.height, !0);
|
|
4633
|
+
else {
|
|
4634
|
+
const n = this.views.last();
|
|
4635
|
+
n && n.expand(), Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1 ? t = n?.section.next?.() : this.scrollBy(0, this.layout.height, !0);
|
|
4636
|
+
}
|
|
4637
|
+
else
|
|
4638
|
+
t = this.views.last().section.next?.();
|
|
4639
|
+
if (t) {
|
|
4640
|
+
this.clear(), this.updateLayout();
|
|
4641
|
+
let s = !1;
|
|
4642
|
+
return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (s = !0), this.append(t, s).then(() => this.handleNextPrePaginated(s, t, this.append), (n) => n).then(() => {
|
|
4643
|
+
!this.isPaginated && this.settings.axis === "horizontal" && this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" && this.scrollTo(this.container.scrollWidth, 0, !0), this.views.show();
|
|
4644
|
+
});
|
|
4645
|
+
}
|
|
4612
4646
|
}
|
|
4613
4647
|
}
|
|
4614
4648
|
prev() {
|
|
4615
4649
|
let t, e;
|
|
4616
4650
|
const i = this.settings.direction;
|
|
4617
|
-
if (this.views.length
|
|
4618
|
-
this.
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
const
|
|
4623
|
-
|
|
4624
|
-
return this.prepend(n);
|
|
4651
|
+
if (this.views.length) {
|
|
4652
|
+
if (this.isPaginated && this.settings.axis === "horizontal" && (!i || i === "ltr"))
|
|
4653
|
+
if (this.scrollLeft = this.container.scrollLeft, e = this.container.scrollLeft, e > 0)
|
|
4654
|
+
this.scrollBy(-this.layout.delta, 0, !0);
|
|
4655
|
+
else {
|
|
4656
|
+
const s = this.views.first();
|
|
4657
|
+
s && s.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = s?.section.prev?.();
|
|
4625
4658
|
}
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4659
|
+
else if (this.isPaginated && this.settings.axis === "horizontal" && i === "rtl")
|
|
4660
|
+
if (this.scrollLeft = this.container.scrollLeft, this.settings.rtlScrollType === "default")
|
|
4661
|
+
if (e = this.container.scrollLeft + this.container.offsetWidth, e < this.container.scrollWidth)
|
|
4662
|
+
this.scrollBy(-this.layout.delta, 0, !0);
|
|
4663
|
+
else {
|
|
4664
|
+
const s = this.views.first();
|
|
4665
|
+
s && s.expand(), e = this.container.scrollLeft + this.container.offsetWidth, e < this.container.scrollWidth ? this.scrollBy(-this.layout.delta, 0, !0) : t = s?.section.prev?.();
|
|
4666
|
+
}
|
|
4667
|
+
else if (e = this.container.scrollLeft, e < 0)
|
|
4668
|
+
this.scrollBy(-this.layout.delta, 0, !0);
|
|
4669
|
+
else {
|
|
4670
|
+
const s = this.views.first();
|
|
4671
|
+
s && s.expand(), e = this.container.scrollLeft, e < 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = s?.section.prev?.();
|
|
4672
|
+
}
|
|
4673
|
+
else if (this.isPaginated && this.settings.axis === "vertical")
|
|
4674
|
+
if (this.scrollTop = this.container.scrollTop, this.container.scrollTop > 0)
|
|
4675
|
+
this.scrollBy(0, -this.layout.height, !0);
|
|
4676
|
+
else {
|
|
4677
|
+
const n = this.views.first();
|
|
4678
|
+
n && n.expand(), this.container.scrollTop > 0 ? this.scrollBy(0, -this.layout.height, !0) : t = n?.section.prev?.();
|
|
4679
|
+
}
|
|
4680
|
+
else
|
|
4681
|
+
t = this.views.first().section.prev?.();
|
|
4682
|
+
if (t) {
|
|
4683
|
+
this.clear(), this.updateLayout();
|
|
4684
|
+
let s = !1;
|
|
4685
|
+
return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof t.prev?.() != "object" && (s = !0), this.prepend(t, s).then(() => {
|
|
4686
|
+
if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
|
|
4687
|
+
const n = t.prev?.();
|
|
4688
|
+
if (n)
|
|
4689
|
+
return this.prepend(n);
|
|
4690
|
+
}
|
|
4691
|
+
}, (n) => n).then(() => {
|
|
4692
|
+
this.isPaginated && this.settings.axis === "horizontal" && (this.settings.direction === "rtl" ? this.settings.rtlScrollType === "default" ? this.scrollTo(0, 0, !0) : this.scrollTo(this.container.scrollWidth * -1 + this.layout.delta, 0, !0) : this.scrollTo(this.container.scrollWidth - this.layout.delta, 0, !0)), this.views.show();
|
|
4693
|
+
});
|
|
4694
|
+
}
|
|
4629
4695
|
}
|
|
4630
4696
|
}
|
|
4631
4697
|
current() {
|
|
@@ -4649,12 +4715,12 @@ class Z {
|
|
|
4649
4715
|
n ? (y = r + e.top - f.top + o, w = y + i - o, T = this.layout.count(g, i).pages, x = i) : (y = r + e.left - f.left + o, w = y + s - o, T = this.layout.count(p, s).pages, x = s);
|
|
4650
4716
|
let E = Math.ceil(y / x), C = [], I = Math.ceil(w / x);
|
|
4651
4717
|
if (this.settings.direction === "rtl" && !n) {
|
|
4652
|
-
const
|
|
4653
|
-
E = T - I, I = T -
|
|
4718
|
+
const B = E;
|
|
4719
|
+
E = T - I, I = T - B;
|
|
4654
4720
|
}
|
|
4655
4721
|
C = [];
|
|
4656
|
-
for (let
|
|
4657
|
-
const z =
|
|
4722
|
+
for (let B = E; B <= I; B++) {
|
|
4723
|
+
const z = B + 1;
|
|
4658
4724
|
C.push(z);
|
|
4659
4725
|
}
|
|
4660
4726
|
const Y = this.mapping.page(a.contents, a.section.cfiBase, y, w);
|
|
@@ -5117,7 +5183,7 @@ class Mt {
|
|
|
5117
5183
|
*/
|
|
5118
5184
|
requireView(t) {
|
|
5119
5185
|
let e;
|
|
5120
|
-
return typeof t == "string" && t === "iframe" ? e =
|
|
5186
|
+
return typeof t == "string" && t === "iframe" ? e = Bt : e = t, e;
|
|
5121
5187
|
}
|
|
5122
5188
|
/**
|
|
5123
5189
|
* Start the rendering
|
|
@@ -5175,7 +5241,7 @@ class Mt {
|
|
|
5175
5241
|
return;
|
|
5176
5242
|
this.epubcfi.isCfiString(t);
|
|
5177
5243
|
const e = new v(), i = e.promise;
|
|
5178
|
-
this.displaying = e, this.book.locations.length() &&
|
|
5244
|
+
this.displaying = e, this.book.locations.length() && Ht(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
|
|
5179
5245
|
const s = this.book.spine.get(t);
|
|
5180
5246
|
return s ? (this.manager.display(s, t).then(() => {
|
|
5181
5247
|
e.resolve(s), this.displaying = void 0, this.emit(u.RENDITION.DISPLAYED, s), this.reportLocation();
|
|
@@ -5338,7 +5404,7 @@ class Mt {
|
|
|
5338
5404
|
* @param {object} settings
|
|
5339
5405
|
*/
|
|
5340
5406
|
layout(t) {
|
|
5341
|
-
return t && (this._layout = new
|
|
5407
|
+
return t && (this._layout = new It(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(u.LAYOUT.UPDATED, (e, i) => {
|
|
5342
5408
|
this.emit(u.RENDITION.LAYOUT, e, i);
|
|
5343
5409
|
})), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
|
|
5344
5410
|
}
|
|
@@ -5591,7 +5657,7 @@ class De {
|
|
|
5591
5657
|
*/
|
|
5592
5658
|
checkRequirements() {
|
|
5593
5659
|
try {
|
|
5594
|
-
this.zip = new
|
|
5660
|
+
this.zip = new jt();
|
|
5595
5661
|
} catch {
|
|
5596
5662
|
throw new Error("JSZip lib not loaded");
|
|
5597
5663
|
}
|
|
@@ -5652,7 +5718,7 @@ class De {
|
|
|
5652
5718
|
getBlob(t, e) {
|
|
5653
5719
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5654
5720
|
if (s)
|
|
5655
|
-
return e = e ||
|
|
5721
|
+
return e = e || q.lookup(s.name), s.async("uint8array").then(function(n) {
|
|
5656
5722
|
return new Blob([n], { type: e });
|
|
5657
5723
|
});
|
|
5658
5724
|
}
|
|
@@ -5678,7 +5744,7 @@ class De {
|
|
|
5678
5744
|
getBase64(t, e) {
|
|
5679
5745
|
const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
|
|
5680
5746
|
if (s)
|
|
5681
|
-
return e = e ||
|
|
5747
|
+
return e = e || q.lookup(s.name), s.async("base64").then(function(n) {
|
|
5682
5748
|
return "data:" + e + ";base64," + n;
|
|
5683
5749
|
});
|
|
5684
5750
|
}
|
|
@@ -5718,7 +5784,7 @@ class De {
|
|
|
5718
5784
|
this.zip = void 0, this.urlCache = {};
|
|
5719
5785
|
}
|
|
5720
5786
|
}
|
|
5721
|
-
function
|
|
5787
|
+
function Be(l) {
|
|
5722
5788
|
return new Promise((t, e) => {
|
|
5723
5789
|
const i = indexedDB.open(l, 1);
|
|
5724
5790
|
i.onupgradeneeded = () => {
|
|
@@ -5726,8 +5792,8 @@ function Me(l) {
|
|
|
5726
5792
|
}, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
|
|
5727
5793
|
});
|
|
5728
5794
|
}
|
|
5729
|
-
function
|
|
5730
|
-
const t =
|
|
5795
|
+
function Me(l) {
|
|
5796
|
+
const t = Be(l);
|
|
5731
5797
|
return {
|
|
5732
5798
|
getItem(e) {
|
|
5733
5799
|
return t.then((i) => new Promise((s, n) => {
|
|
@@ -5744,7 +5810,7 @@ function Be(l) {
|
|
|
5744
5810
|
};
|
|
5745
5811
|
}
|
|
5746
5812
|
const nt = typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : void 0;
|
|
5747
|
-
class
|
|
5813
|
+
class Wt {
|
|
5748
5814
|
constructor(t, e, i) {
|
|
5749
5815
|
this.urlCache = {}, this.name = t, this.requester = e || H, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
|
|
5750
5816
|
}
|
|
@@ -5756,7 +5822,7 @@ class Bt {
|
|
|
5756
5822
|
try {
|
|
5757
5823
|
if (typeof indexedDB > "u")
|
|
5758
5824
|
throw new Error("IndexedDB not available");
|
|
5759
|
-
this.storage =
|
|
5825
|
+
this.storage = Me(this.name);
|
|
5760
5826
|
} catch {
|
|
5761
5827
|
throw new Error("IndexedDB not available");
|
|
5762
5828
|
}
|
|
@@ -5857,7 +5923,7 @@ class Bt {
|
|
|
5857
5923
|
const i = encodeURIComponent(t);
|
|
5858
5924
|
return this.storage.getItem(i).then(function(s) {
|
|
5859
5925
|
if (s)
|
|
5860
|
-
return e = e ||
|
|
5926
|
+
return e = e || q.lookup(t), new Blob([s], { type: e });
|
|
5861
5927
|
});
|
|
5862
5928
|
}
|
|
5863
5929
|
/**
|
|
@@ -5868,7 +5934,7 @@ class Bt {
|
|
|
5868
5934
|
*/
|
|
5869
5935
|
getText(t, e) {
|
|
5870
5936
|
const i = encodeURIComponent(t);
|
|
5871
|
-
return e = e ||
|
|
5937
|
+
return e = e || q.lookup(t), this.storage.getItem(i).then(function(s) {
|
|
5872
5938
|
const n = new v(), r = new FileReader();
|
|
5873
5939
|
if (!s) return;
|
|
5874
5940
|
const o = new Blob([s], { type: e });
|
|
@@ -5885,7 +5951,7 @@ class Bt {
|
|
|
5885
5951
|
*/
|
|
5886
5952
|
getBase64(t, e) {
|
|
5887
5953
|
const i = encodeURIComponent(t);
|
|
5888
|
-
return e = e ||
|
|
5954
|
+
return e = e || q.lookup(t), this.storage.getItem(i).then((s) => {
|
|
5889
5955
|
const n = new v(), r = new FileReader();
|
|
5890
5956
|
if (!s) return;
|
|
5891
5957
|
const o = new Blob([s], { type: e });
|
|
@@ -5922,12 +5988,14 @@ class Bt {
|
|
|
5922
5988
|
e && nt.revokeObjectURL(e);
|
|
5923
5989
|
}
|
|
5924
5990
|
destroy() {
|
|
5925
|
-
for (const t in this.urlCache)
|
|
5926
|
-
|
|
5991
|
+
for (const t in this.urlCache) {
|
|
5992
|
+
const e = this.urlCache[t];
|
|
5993
|
+
e && nt.revokeObjectURL(e);
|
|
5994
|
+
}
|
|
5927
5995
|
this.urlCache = {}, this.removeListeners();
|
|
5928
5996
|
}
|
|
5929
5997
|
}
|
|
5930
|
-
A(
|
|
5998
|
+
A(Wt.prototype);
|
|
5931
5999
|
class rt {
|
|
5932
6000
|
constructor(t) {
|
|
5933
6001
|
this.interactive = "", this.fixedLayout = "", this.openToSpread = "", this.orientationLock = "", t && this.parse(t);
|
|
@@ -5941,7 +6009,7 @@ class rt {
|
|
|
5941
6009
|
if (!t)
|
|
5942
6010
|
return this;
|
|
5943
6011
|
const e = b(t, "display_options");
|
|
5944
|
-
return e ? (
|
|
6012
|
+
return e ? (M(e, "option").forEach((s) => {
|
|
5945
6013
|
let n = "";
|
|
5946
6014
|
switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
|
|
5947
6015
|
case "interactive":
|
|
@@ -5963,7 +6031,7 @@ class rt {
|
|
|
5963
6031
|
this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
|
|
5964
6032
|
}
|
|
5965
6033
|
}
|
|
5966
|
-
const _t = "META-INF/container.xml",
|
|
6034
|
+
const _t = "META-INF/container.xml", We = "META-INF/com.apple.ibooks.display-options.xml", k = {
|
|
5967
6035
|
BINARY: "binary",
|
|
5968
6036
|
BASE64: "base64",
|
|
5969
6037
|
EPUB: "epub",
|
|
@@ -5971,7 +6039,7 @@ const _t = "META-INF/container.xml", qe = "META-INF/com.apple.ibooks.display-opt
|
|
|
5971
6039
|
MANIFEST: "json",
|
|
5972
6040
|
DIRECTORY: "directory"
|
|
5973
6041
|
};
|
|
5974
|
-
class
|
|
6042
|
+
class qe {
|
|
5975
6043
|
constructor(t, e) {
|
|
5976
6044
|
typeof e > "u" && typeof t != "string" && !(t instanceof Blob) && !(t instanceof ArrayBuffer) && (e = t, t = void 0), this.settings = _({}, {
|
|
5977
6045
|
requestMethod: void 0,
|
|
@@ -6008,7 +6076,7 @@ class We {
|
|
|
6008
6076
|
this.loaded.navigation,
|
|
6009
6077
|
this.loaded.resources,
|
|
6010
6078
|
this.loaded.displayOptions
|
|
6011
|
-
]), this.isRendered = !1, this.request = this.settings.requestMethod || H, this.spine = new ce(), this.locations = new
|
|
6079
|
+
]), this.isRendered = !1, this.request = this.settings.requestMethod || H, this.spine = new ce(), this.locations = new At(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) => {
|
|
6012
6080
|
const s = new Error("Cannot load book at " + t);
|
|
6013
6081
|
this.emit(u.BOOK.OPEN_FAILED, s);
|
|
6014
6082
|
});
|
|
@@ -6023,7 +6091,7 @@ class We {
|
|
|
6023
6091
|
open(t, e) {
|
|
6024
6092
|
let i;
|
|
6025
6093
|
const s = e || this.determineType(t);
|
|
6026
|
-
return s ===
|
|
6094
|
+
return s === k.BINARY ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t)) : s === k.BASE64 ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t, s)) : s === k.EPUB ? (this.archived = !0, this.url = new R("/", ""), i = this.request(t, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then((n) => this.openEpub(n))) : s == k.OPF ? (this.url = new R(t), i = this.openPackaging(this.url.Path.toString())) : s == k.MANIFEST ? (this.url = new R(t), i = this.openManifest(this.url.Path.toString())) : (this.url = new R(t), i = this.openContainer(_t).then((n) => this.openPackaging(n))), i;
|
|
6027
6095
|
}
|
|
6028
6096
|
/**
|
|
6029
6097
|
* Open an archived epub
|
|
@@ -6101,17 +6169,17 @@ class We {
|
|
|
6101
6169
|
determineType(t) {
|
|
6102
6170
|
let e;
|
|
6103
6171
|
if (this.settings.encoding === "base64")
|
|
6104
|
-
return
|
|
6172
|
+
return k.BASE64;
|
|
6105
6173
|
if (typeof t != "string")
|
|
6106
|
-
return
|
|
6174
|
+
return k.BINARY;
|
|
6107
6175
|
if (e = new R(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
|
|
6108
|
-
return
|
|
6176
|
+
return k.DIRECTORY;
|
|
6109
6177
|
if (e === "epub")
|
|
6110
|
-
return
|
|
6178
|
+
return k.EPUB;
|
|
6111
6179
|
if (e === "opf")
|
|
6112
|
-
return
|
|
6180
|
+
return k.OPF;
|
|
6113
6181
|
if (e === "json")
|
|
6114
|
-
return
|
|
6182
|
+
return k.MANIFEST;
|
|
6115
6183
|
}
|
|
6116
6184
|
/**
|
|
6117
6185
|
* unpack the contents of the Books packaging
|
|
@@ -6119,7 +6187,7 @@ class We {
|
|
|
6119
6187
|
* @param {Packaging} packaging object
|
|
6120
6188
|
*/
|
|
6121
6189
|
unpack(t) {
|
|
6122
|
-
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(
|
|
6190
|
+
this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(We)).then((e) => {
|
|
6123
6191
|
this.displayOptions = new rt(e), this.loading.displayOptions.resolve(this.displayOptions);
|
|
6124
6192
|
}).catch((e) => {
|
|
6125
6193
|
this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions);
|
|
@@ -6206,7 +6274,7 @@ class We {
|
|
|
6206
6274
|
*/
|
|
6207
6275
|
store(t) {
|
|
6208
6276
|
const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) => H(n, r));
|
|
6209
|
-
return this.storage = new
|
|
6277
|
+
return this.storage = new Wt(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
|
|
6210
6278
|
this.archived && (this.storage.requester = (r, o) => this.archive.request(r, o));
|
|
6211
6279
|
const n = (r, o) => {
|
|
6212
6280
|
o.output = this.resources.substitute(r, o.url);
|
|
@@ -6256,7 +6324,7 @@ class We {
|
|
|
6256
6324
|
*/
|
|
6257
6325
|
key(t) {
|
|
6258
6326
|
const e = t || this.packaging.metadata.identifier || this.url.filename;
|
|
6259
|
-
return `epubjs:${
|
|
6327
|
+
return `epubjs:${Nt}:${e}`;
|
|
6260
6328
|
}
|
|
6261
6329
|
/**
|
|
6262
6330
|
* Destroy the Book and all associated objects
|
|
@@ -6265,7 +6333,7 @@ class We {
|
|
|
6265
6333
|
this.opened = void 0, this.loading = void 0, this.loaded = void 0, this.ready = void 0, this.isOpen = !1, this.isRendered = !1, this.spine && this.spine.destroy(), this.locations && this.locations.destroy(), this.pageList && this.pageList.destroy(), this.archive && this.archive.destroy(), this.resources && this.resources.destroy(), this.container && this.container.destroy(), this.packaging && this.packaging.destroy(), this.rendition && this.rendition.destroy(), this.displayOptions && this.displayOptions.destroy(), this.storage && (this.storage.destroy(), this.storage = void 0), this.spine = void 0, this.locations = void 0, this.pageList = void 0, this.archive = void 0, this.resources = void 0, this.container = void 0, this.packaging = void 0, this.rendition = void 0, this.navigation = void 0, this.url = void 0, this.path = void 0, this.archived = !1;
|
|
6266
6334
|
}
|
|
6267
6335
|
}
|
|
6268
|
-
A(
|
|
6336
|
+
A(qe.prototype);
|
|
6269
6337
|
typeof globalThis.DOMParser > "u" && (globalThis.DOMParser = qt);
|
|
6270
6338
|
typeof globalThis.XMLSerializer > "u" && (globalThis.XMLSerializer = class {
|
|
6271
6339
|
serializeToString(t) {
|
|
@@ -6273,17 +6341,17 @@ typeof globalThis.XMLSerializer > "u" && (globalThis.XMLSerializer = class {
|
|
|
6273
6341
|
}
|
|
6274
6342
|
});
|
|
6275
6343
|
if (typeof globalThis.document > "u") {
|
|
6276
|
-
const { document: l } =
|
|
6344
|
+
const { document: l } = Ut("<!DOCTYPE html><html><head></head><body></body></html>");
|
|
6277
6345
|
globalThis.document = l;
|
|
6278
6346
|
}
|
|
6279
6347
|
export {
|
|
6280
6348
|
De as Archive,
|
|
6281
|
-
|
|
6349
|
+
qe as Book,
|
|
6282
6350
|
de as Container,
|
|
6283
6351
|
rt as DisplayOptions,
|
|
6284
6352
|
m as EpubCFI,
|
|
6285
|
-
|
|
6286
|
-
|
|
6353
|
+
It as Layout,
|
|
6354
|
+
At as Locations,
|
|
6287
6355
|
et as Navigation,
|
|
6288
6356
|
Et as Packaging,
|
|
6289
6357
|
st as PageList,
|