@readium/navigator 2.4.0-alpha.6 → 2.4.0-alpha.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/index.js
CHANGED
|
@@ -3622,7 +3622,7 @@ const _t = class _t extends ft {
|
|
|
3622
3622
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3623
3623
|
value: {
|
|
3624
3624
|
name: "readium-ts-toolkit",
|
|
3625
|
-
version: "2.4.0-alpha.
|
|
3625
|
+
version: "2.4.0-alpha.8",
|
|
3626
3626
|
hasFeature: (n, r = "") => {
|
|
3627
3627
|
switch (n) {
|
|
3628
3628
|
case "dom-manipulation":
|
|
@@ -6412,17 +6412,14 @@ class on {
|
|
|
6412
6412
|
}
|
|
6413
6413
|
async buildHtmlFrame(t = !1) {
|
|
6414
6414
|
if (!this.currentResource) throw new Error("No resource loaded");
|
|
6415
|
-
const e = await this.currentResource.link(), i = await this.currentResource.
|
|
6415
|
+
const e = await this.currentResource.link(), i = await this.currentResource.readAsXML();
|
|
6416
6416
|
if (!i) throw new Error(`Failed reading item ${e.href}`);
|
|
6417
|
-
const n =
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
if (r) {
|
|
6422
|
-
const o = r.querySelector("div");
|
|
6423
|
-
throw new Error(`Failed parsing item ${e.href}: ${o?.textContent || r.textContent}`);
|
|
6417
|
+
const n = i.querySelector("parsererror");
|
|
6418
|
+
if (n) {
|
|
6419
|
+
const r = n.querySelector("div");
|
|
6420
|
+
throw new Error(`Failed parsing item ${e.href}: ${r?.textContent || n.textContent}`);
|
|
6424
6421
|
}
|
|
6425
|
-
return this.injector && await this.injector.injectForDocument(
|
|
6422
|
+
return this.injector && await this.injector.injectForDocument(i, e), this.finalizeDOM(i, this.pub.baseURL, e.toURL(this.baseURL) || "", e.mediaType, t, this.cssProperties);
|
|
6426
6423
|
}
|
|
6427
6424
|
async buildImageFrame() {
|
|
6428
6425
|
if (!this.currentResource) throw new Error("No resource loaded");
|
|
@@ -6687,7 +6684,7 @@ class Dr {
|
|
|
6687
6684
|
}
|
|
6688
6685
|
class Ir {
|
|
6689
6686
|
constructor(t, e, i, n = {}, r = []) {
|
|
6690
|
-
this.frameIsAppended = !1, this.currModules = [], this.cachedPage = void 0, this.peripherals = t, this.debugHref = i, this.contentProtectionConfig = { ...n }, this.keyboardPeripheralsConfig = [...r], this.frame = document.createElement("iframe"), this.frame.sandbox.value = "allow-same-origin allow-scripts", this.frame.classList.add("readium-navigator-iframe"), this.frame.classList.add("blank"), this.frame.scrolling = "no", this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.display = "none", this.frame.style.position = "absolute", this.frame.style.pointerEvents = "none", this.frame.style.transformOrigin = "0 0", this.frame.style.transform = "scale(1)", this.frame.style.background = "#fff", this.frame.style.touchAction = "none", this.frame.dataset.originalHref = i, this.source = "about:blank", this.wrapper = document.createElement("div"), this.wrapper.style.position = "relative", this.wrapper.style.float = this.wrapper.style.cssFloat = e === F.rtl ? "right" : "left";
|
|
6687
|
+
this.frameIsAppended = !1, this.currModules = [], this.viewportSize = void 0, this.cachedPage = void 0, this.peripherals = t, this.debugHref = i, this.contentProtectionConfig = { ...n }, this.keyboardPeripheralsConfig = [...r], this.frame = document.createElement("iframe"), this.frame.sandbox.value = "allow-same-origin allow-scripts", this.frame.classList.add("readium-navigator-iframe"), this.frame.classList.add("blank"), this.frame.scrolling = "no", this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.display = "none", this.frame.style.position = "absolute", this.frame.style.pointerEvents = "none", this.frame.style.transformOrigin = "0 0", this.frame.style.transform = "scale(1)", this.frame.style.background = "#fff", this.frame.style.touchAction = "none", this.frame.dataset.originalHref = i, this.source = "about:blank", this.wrapper = document.createElement("div"), this.wrapper.style.position = "relative", this.wrapper.style.float = this.wrapper.style.cssFloat = e === F.rtl ? "right" : "left";
|
|
6691
6688
|
}
|
|
6692
6689
|
async load(t, e) {
|
|
6693
6690
|
return this.frameIsAppended || (this.wrapper.appendChild(this.frame), this.frameIsAppended = !0), this.source === e && this.loadPromise && [...this.currModules].sort().join("|") === [...t].sort().join("|") ? this.loadPromise : (this.loaded && this.source !== e && this.window.stop(), this.source = e, this.loadPromise = new Promise((i, n) => {
|
|
@@ -6724,6 +6721,7 @@ class Ir {
|
|
|
6724
6721
|
}
|
|
6725
6722
|
// Parses the page size from the viewport meta tag of the loaded resource.
|
|
6726
6723
|
loadPageSize() {
|
|
6724
|
+
if (this.viewportSize) return this.viewportSize;
|
|
6727
6725
|
const t = this.frame.contentWindow, e = t.document.head.querySelector(
|
|
6728
6726
|
"meta[name=viewport]"
|
|
6729
6727
|
);
|
|
@@ -6733,7 +6731,7 @@ class Ir {
|
|
|
6733
6731
|
for (; n = i.exec(e.content); )
|
|
6734
6732
|
n[1] === "width" ? r = Number.parseFloat(n[2]) : n[1] === "height" && (o = Number.parseFloat(n[2]));
|
|
6735
6733
|
if (r > 0 && o > 0)
|
|
6736
|
-
return { width: r, height: o };
|
|
6734
|
+
return this.viewportSize = { width: r, height: o }, this.viewportSize;
|
|
6737
6735
|
}
|
|
6738
6736
|
return {
|
|
6739
6737
|
width: t.document.body.scrollWidth,
|
|
@@ -7211,12 +7209,14 @@ class Zr {
|
|
|
7211
7209
|
*/
|
|
7212
7210
|
resizeHandler(t = !0, e = !0) {
|
|
7213
7211
|
this.currentSlide + this.perPage > this.length && (this.currentSlide = this.length <= this.perPage ? 0 : this.length - 1), this.containerHeightCached = this.container.clientHeight, this.orientationInternal = -1, this.updateSpineStyle(!0), t && (this.currentSlide = this.reAlign(), this.slideToCurrent(!e, e)), clearTimeout(this.resizeTimeout), this.resizeTimeout = window.setTimeout(() => {
|
|
7214
|
-
this.
|
|
7215
|
-
|
|
7216
|
-
const
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7212
|
+
const i = 100 / this.length, n = new Map(this.pub.readingOrder.items.map((r) => [r.href, r]));
|
|
7213
|
+
this.pool.forEach((r, o) => {
|
|
7214
|
+
const a = n.get(o);
|
|
7215
|
+
a && requestAnimationFrame(() => {
|
|
7216
|
+
if (r.width = i * (a.properties?.otherProperties.orientation === Pe.landscape || a.properties?.otherProperties.addBlank ? this.perPage : 1), r.height = this.height, !r.loaded) return;
|
|
7217
|
+
const l = this.spreader.findByLink(a);
|
|
7218
|
+
r.update(this.spreadPosition(l, a));
|
|
7219
|
+
});
|
|
7220
7220
|
});
|
|
7221
7221
|
}, Yr);
|
|
7222
7222
|
}
|