@likecoin/epub-ts 0.5.0 → 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/epub.cjs +3 -3
- package/dist/epub.cjs.map +1 -1
- package/dist/epub.js +5 -9
- package/dist/epub.js.map +1 -1
- package/dist/epub.node.cjs +2 -2
- package/dist/epub.node.cjs.map +1 -1
- package/dist/epub.node.js +38 -43
- package/dist/epub.node.js.map +1 -1
- package/dist/epub.umd.js +3 -3
- package/dist/epub.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/managers/continuous/index.d.ts +2 -2
- package/dist/rendition.d.ts +1 -1
- package/package.json +1 -1
package/dist/epub.node.js
CHANGED
|
@@ -185,7 +185,7 @@ function te(a) {
|
|
|
185
185
|
};
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
class
|
|
188
|
+
class C {
|
|
189
189
|
constructor() {
|
|
190
190
|
this.promise = new Promise((t, e) => {
|
|
191
191
|
this.resolve = t, this.reject = e;
|
|
@@ -1101,10 +1101,10 @@ class de {
|
|
|
1101
1101
|
if (g < d[0].length) {
|
|
1102
1102
|
for (; b < d.length - 1 && (T += d[b].length, !(y <= T)); )
|
|
1103
1103
|
b += 1;
|
|
1104
|
-
const x = d[0],
|
|
1104
|
+
const x = d[0], S = d[b], I = n.document.createRange();
|
|
1105
1105
|
I.setStart(x, g);
|
|
1106
1106
|
const Y = d.slice(0, b).reduce((Z, Q) => Z + (Q.textContent ?? "").length, 0);
|
|
1107
|
-
I.setEnd(
|
|
1107
|
+
I.setEnd(S, Y > y ? y : y - Y);
|
|
1108
1108
|
const D = n.cfiFromRange(I);
|
|
1109
1109
|
let O = d.slice(0, b + 1).reduce((Z, Q) => Z + (Q.textContent ?? ""), "");
|
|
1110
1110
|
O.length > 150 && (O = O.substring(g - 150 / 2, g + 150 / 2), O = "..." + O + "..."), i.push({
|
|
@@ -1298,7 +1298,7 @@ class pt {
|
|
|
1298
1298
|
const [n, ...r] = t;
|
|
1299
1299
|
if (!n)
|
|
1300
1300
|
throw new Error("No Task Provided");
|
|
1301
|
-
return typeof n == "function" ? (e = new
|
|
1301
|
+
return typeof n == "function" ? (e = new C(), i = e.promise, s = {
|
|
1302
1302
|
task: n,
|
|
1303
1303
|
args: r,
|
|
1304
1304
|
//"context" : context,
|
|
@@ -1331,7 +1331,7 @@ class pt {
|
|
|
1331
1331
|
* @return {Promise}
|
|
1332
1332
|
*/
|
|
1333
1333
|
run() {
|
|
1334
|
-
this.running || (this.running = !0, this.defered = new
|
|
1334
|
+
this.running || (this.running = !0, this.defered = new C());
|
|
1335
1335
|
const t = () => {
|
|
1336
1336
|
this._q.length ? this.dequeue()?.then(() => {
|
|
1337
1337
|
this.run();
|
|
@@ -2872,13 +2872,11 @@ class we {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
/**
|
|
2874
2874
|
* [Not Implemented] Show annotations
|
|
2875
|
-
* @TODO: needs implementation in View
|
|
2876
2875
|
*/
|
|
2877
2876
|
show() {
|
|
2878
2877
|
}
|
|
2879
2878
|
/**
|
|
2880
2879
|
* [Not Implemented] Hide annotations
|
|
2881
|
-
* @TODO: needs implementation in View
|
|
2882
2880
|
*/
|
|
2883
2881
|
hide() {
|
|
2884
2882
|
}
|
|
@@ -2921,7 +2919,6 @@ class zt {
|
|
|
2921
2919
|
}
|
|
2922
2920
|
/**
|
|
2923
2921
|
* [Not Implemented] Get text of an annotation
|
|
2924
|
-
* @TODO: needs implementation in contents
|
|
2925
2922
|
*/
|
|
2926
2923
|
text() {
|
|
2927
2924
|
}
|
|
@@ -4080,7 +4077,7 @@ class Mt {
|
|
|
4080
4077
|
}), this.onResize(this, n), this.emit(u.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = J(this.element);
|
|
4081
4078
|
}
|
|
4082
4079
|
load(t) {
|
|
4083
|
-
const e = new
|
|
4080
|
+
const e = new C(), i = e.promise;
|
|
4084
4081
|
if (!this.iframe)
|
|
4085
4082
|
return e.reject(new Error("No Iframe Available")), i;
|
|
4086
4083
|
if (this.iframe.onload = (s) => {
|
|
@@ -4120,7 +4117,7 @@ class Mt {
|
|
|
4120
4117
|
this.contents && (this.contents.off(u.CONTENTS.EXPAND), this.contents.off(u.CONTENTS.RESIZE));
|
|
4121
4118
|
}
|
|
4122
4119
|
display(t) {
|
|
4123
|
-
const e = new
|
|
4120
|
+
const e = new C();
|
|
4124
4121
|
return this.displayed ? e.resolve(this) : this.render(t).then(() => {
|
|
4125
4122
|
this.emit(u.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
|
|
4126
4123
|
}, (i) => {
|
|
@@ -4545,7 +4542,7 @@ class K {
|
|
|
4545
4542
|
}
|
|
4546
4543
|
}
|
|
4547
4544
|
display(t, e) {
|
|
4548
|
-
const i = new
|
|
4545
|
+
const i = new C(), s = i.promise;
|
|
4549
4546
|
(e === t.href || E(e)) && (e = void 0);
|
|
4550
4547
|
const n = this.views.find(t);
|
|
4551
4548
|
if (n && t && this.layout.name !== "pre-paginated") {
|
|
@@ -4734,21 +4731,21 @@ class K {
|
|
|
4734
4731
|
const c = l.section.index, d = l.section.href, f = l.position(), p = l.width(), g = l.height();
|
|
4735
4732
|
let v, y, b, T;
|
|
4736
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);
|
|
4737
|
-
let x = Math.ceil(v / b),
|
|
4734
|
+
let x = Math.ceil(v / b), S = [], I = Math.ceil(y / b);
|
|
4738
4735
|
if (this.settings.direction === "rtl" && !n) {
|
|
4739
4736
|
const D = x;
|
|
4740
4737
|
x = T - I, I = T - D;
|
|
4741
4738
|
}
|
|
4742
|
-
|
|
4739
|
+
S = [];
|
|
4743
4740
|
for (let D = x; D <= I; D++) {
|
|
4744
4741
|
const O = D + 1;
|
|
4745
|
-
|
|
4742
|
+
S.push(O);
|
|
4746
4743
|
}
|
|
4747
4744
|
const Y = this.mapping.page(l.contents, l.section.cfiBase, v, y);
|
|
4748
4745
|
return {
|
|
4749
4746
|
index: c,
|
|
4750
4747
|
href: d,
|
|
4751
|
-
pages:
|
|
4748
|
+
pages: S,
|
|
4752
4749
|
totalPages: T,
|
|
4753
4750
|
mapping: Y
|
|
4754
4751
|
};
|
|
@@ -4768,11 +4765,11 @@ class K {
|
|
|
4768
4765
|
const T = [];
|
|
4769
4766
|
let x = Math.floor(p / this.layout.pageWidth);
|
|
4770
4767
|
if (b < 0 && (b = 0, x = x + 1), this.settings.direction === "rtl") {
|
|
4771
|
-
const
|
|
4772
|
-
b = y - x, x = y -
|
|
4768
|
+
const S = b;
|
|
4769
|
+
b = y - x, x = y - S;
|
|
4773
4770
|
}
|
|
4774
|
-
for (let
|
|
4775
|
-
const I =
|
|
4771
|
+
for (let S = b + 1; S <= x; S++) {
|
|
4772
|
+
const I = S;
|
|
4776
4773
|
T.push(I);
|
|
4777
4774
|
}
|
|
4778
4775
|
return {
|
|
@@ -5025,7 +5022,6 @@ class Be extends K {
|
|
|
5025
5022
|
this.updateWritingMode(i);
|
|
5026
5023
|
}), e.onDisplayed = (i) => this.afterDisplayed(i), e.onResize = (i) => this.afterResized(i), e.display(this.request);
|
|
5027
5024
|
}
|
|
5028
|
-
// @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
|
|
5029
5025
|
append(t) {
|
|
5030
5026
|
const e = this.createView(t);
|
|
5031
5027
|
return e.on(u.VIEWS.RESIZED, (i) => {
|
|
@@ -5034,9 +5030,8 @@ class Be extends K {
|
|
|
5034
5030
|
this.updateAxis(i);
|
|
5035
5031
|
}), e.on(u.VIEWS.WRITING_MODE, (i) => {
|
|
5036
5032
|
this.updateWritingMode(i);
|
|
5037
|
-
}), 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);
|
|
5038
5034
|
}
|
|
5039
|
-
// @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
|
|
5040
5035
|
prepend(t) {
|
|
5041
5036
|
const e = this.createView(t);
|
|
5042
5037
|
return e.on(u.VIEWS.RESIZED, (i) => {
|
|
@@ -5045,7 +5040,7 @@ class Be extends K {
|
|
|
5045
5040
|
this.updateAxis(i);
|
|
5046
5041
|
}), e.on(u.VIEWS.WRITING_MODE, (i) => {
|
|
5047
5042
|
this.updateWritingMode(i);
|
|
5048
|
-
}), 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);
|
|
5049
5044
|
}
|
|
5050
5045
|
counter(t) {
|
|
5051
5046
|
this.settings.axis === "vertical" ? this.scrollBy(0, t.heightDelta, !0) : this.scrollBy(t.widthDelta, 0, !0);
|
|
@@ -5053,7 +5048,7 @@ class Be extends K {
|
|
|
5053
5048
|
update(t) {
|
|
5054
5049
|
const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
|
|
5055
5050
|
let r, o;
|
|
5056
|
-
const h = new
|
|
5051
|
+
const h = new C(), l = [];
|
|
5057
5052
|
for (let c = 0; c < s; c++)
|
|
5058
5053
|
if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
|
|
5059
5054
|
if (o.displayed)
|
|
@@ -5075,7 +5070,7 @@ class Be extends K {
|
|
|
5075
5070
|
}) : (h.resolve(), h.promise);
|
|
5076
5071
|
}
|
|
5077
5072
|
check(t, e) {
|
|
5078
|
-
const i = new
|
|
5073
|
+
const i = new C(), s = [], n = this.settings.axis === "horizontal";
|
|
5079
5074
|
let r = this.settings.offset || 0;
|
|
5080
5075
|
t && n && (r = t), e && !n && (r = e);
|
|
5081
5076
|
const o = this._bounds;
|
|
@@ -5083,20 +5078,20 @@ class Be extends K {
|
|
|
5083
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";
|
|
5084
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));
|
|
5085
5080
|
const g = () => {
|
|
5086
|
-
const x = this.views.first(),
|
|
5087
|
-
|
|
5081
|
+
const x = this.views.first(), S = x && x.section.prev?.();
|
|
5082
|
+
S && s.push(this.prepend(S));
|
|
5088
5083
|
}, v = () => {
|
|
5089
|
-
const x = this.views.last(),
|
|
5090
|
-
|
|
5084
|
+
const x = this.views.last(), S = x && x.section.next?.();
|
|
5085
|
+
S && s.push(this.append(S));
|
|
5091
5086
|
}, y = h + l + r, b = h - r;
|
|
5092
5087
|
y >= c && v(), b < 0 && g();
|
|
5093
|
-
const T = s.map((x) => x.display(this.request));
|
|
5088
|
+
const T = s.map((x) => x.then((S) => S.display(this.request)));
|
|
5094
5089
|
return s.length ? Promise.all(T).then(() => this.check()).then(() => this.update(r), (x) => x) : (this.q.enqueue(() => {
|
|
5095
5090
|
this.update();
|
|
5096
5091
|
}), i.resolve(!1), i.promise);
|
|
5097
5092
|
}
|
|
5098
5093
|
trim() {
|
|
5099
|
-
const t = new
|
|
5094
|
+
const t = new C(), e = this.views.displayed();
|
|
5100
5095
|
if (!e.length)
|
|
5101
5096
|
return t.resolve(), t.promise;
|
|
5102
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);
|
|
@@ -5178,7 +5173,7 @@ class Wt {
|
|
|
5178
5173
|
defaultDirection: "ltr",
|
|
5179
5174
|
allowScriptedContent: !1,
|
|
5180
5175
|
allowPopups: !1
|
|
5181
|
-
}), _(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
|
|
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);
|
|
5182
5177
|
}
|
|
5183
5178
|
/**
|
|
5184
5179
|
* Set the manager function
|
|
@@ -5260,7 +5255,7 @@ class Wt {
|
|
|
5260
5255
|
if (!this.book)
|
|
5261
5256
|
return;
|
|
5262
5257
|
this.epubcfi.isCfiString(t);
|
|
5263
|
-
const e = new
|
|
5258
|
+
const e = new C(), i = e.promise;
|
|
5264
5259
|
this.displaying = e, this.book.locations.length() && Yt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
|
|
5265
5260
|
const s = this.book.spine.get(t);
|
|
5266
5261
|
return s ? (this.manager.display(s, t).then(() => {
|
|
@@ -5430,7 +5425,7 @@ class Wt {
|
|
|
5430
5425
|
}
|
|
5431
5426
|
/**
|
|
5432
5427
|
* Adjust if the rendition uses spreads
|
|
5433
|
-
* @param {string} spread none | auto
|
|
5428
|
+
* @param {string} spread none | auto
|
|
5434
5429
|
* @param {int} [min] min width to use spreads at
|
|
5435
5430
|
*/
|
|
5436
5431
|
spread(t, e) {
|
|
@@ -6064,15 +6059,15 @@ class je {
|
|
|
6064
6059
|
canonical: void 0,
|
|
6065
6060
|
openAs: void 0,
|
|
6066
6061
|
store: void 0
|
|
6067
|
-
}), _(this.settings, e), this.opening = new
|
|
6068
|
-
manifest: new
|
|
6069
|
-
spine: new
|
|
6070
|
-
metadata: new
|
|
6071
|
-
cover: new
|
|
6072
|
-
navigation: new
|
|
6073
|
-
pageList: new
|
|
6074
|
-
resources: new
|
|
6075
|
-
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()
|
|
6076
6071
|
}, this.loaded = {
|
|
6077
6072
|
manifest: this.loading.manifest.promise,
|
|
6078
6073
|
spine: this.loading.spine.promise,
|