@zinejs/core 0.7.4 → 0.8.2
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/controls/arrows.d.ts +2 -1
- package/dist/controls/controls.d.ts +1 -1
- package/dist/controls/outline.d.ts +4 -1
- package/dist/controls/search.d.ts +4 -1
- package/dist/controls/share.d.ts +2 -1
- package/dist/controls/sidebar.d.ts +30 -0
- package/dist/controls/styles.d.ts +10 -1
- package/dist/controls/thumbnails.d.ts +4 -1
- package/dist/controls/types.d.ts +31 -3
- package/dist/controls-DgEXR2zi.js +725 -0
- package/dist/controls-DgEXR2zi.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +221 -183
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +297 -59
- package/dist/index.umd.js.map +1 -1
- package/dist/loading/loading.d.ts +1 -1
- package/dist/{loading-C0qbANt2.js → loading-BBK6YbSW.js} +2 -2
- package/dist/loading-BBK6YbSW.js.map +1 -0
- package/dist/{share-CyrZiFqf.js → share-WXdscwp3.js} +73 -73
- package/dist/share-WXdscwp3.js.map +1 -0
- package/dist/styles-B8fFoYm_.js +40 -0
- package/dist/styles-B8fFoYm_.js.map +1 -0
- package/dist/zine.d.ts +20 -1
- package/package.json +1 -1
- package/dist/controls-Bj72hxVJ.js +0 -653
- package/dist/controls-Bj72hxVJ.js.map +0 -1
- package/dist/icons-D87p7JMP.js +0 -29
- package/dist/icons-D87p7JMP.js.map +0 -1
- package/dist/loading-C0qbANt2.js.map +0 -1
- package/dist/share-CyrZiFqf.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -284,25 +284,25 @@ var T = {
|
|
|
284
284
|
css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
|
|
285
285
|
webgl2: async () => new (await (import("./webglRenderer-nGRruZk2.js"))).WebglRenderer()
|
|
286
286
|
}, E = !0;
|
|
287
|
-
function
|
|
287
|
+
function D(e) {
|
|
288
288
|
return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function O(e) {
|
|
291
291
|
return e.gpu && E ? ["webgl2", "css"] : ["css"];
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
return { gpu:
|
|
293
|
+
function ee() {
|
|
294
|
+
return { gpu: te() };
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function te() {
|
|
297
297
|
try {
|
|
298
298
|
return !!document.createElement("canvas").getContext("webgl2");
|
|
299
299
|
} catch {
|
|
300
300
|
return !1;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
async function k(e = "auto", t =
|
|
304
|
-
if (
|
|
305
|
-
let n = Array.isArray(e) ? e : e === "auto" ?
|
|
303
|
+
async function k(e = "auto", t = ee()) {
|
|
304
|
+
if (D(e)) return e;
|
|
305
|
+
let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
|
|
306
306
|
for (let e of n) {
|
|
307
307
|
if (e === "webgl2" && !t.gpu) continue;
|
|
308
308
|
let n = T[e];
|
|
@@ -488,7 +488,7 @@ var J = class {
|
|
|
488
488
|
pages: t.pages
|
|
489
489
|
});
|
|
490
490
|
let n = t.direction ?? "ltr";
|
|
491
|
-
this.#a = n, this.#x = (t.deepLink ?? !0) && b(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ue = t.controls ?? !0, this.#fe = t.loading ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#
|
|
491
|
+
this.#a = n, this.#x = (t.deepLink ?? !0) && b(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ue = t.controls ?? !0, this.#fe = t.loading ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#Nt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
|
|
492
492
|
let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
|
|
493
493
|
1,
|
|
494
494
|
2,
|
|
@@ -496,7 +496,7 @@ var J = class {
|
|
|
496
496
|
]].sort((e, t) => e - t);
|
|
497
497
|
this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
|
|
498
498
|
let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
|
|
499
|
-
this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#ye = this.#
|
|
499
|
+
this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#ye = this.#et(t.renderer ?? "auto");
|
|
500
500
|
}
|
|
501
501
|
get ready() {
|
|
502
502
|
return this.#ye;
|
|
@@ -510,6 +510,9 @@ var J = class {
|
|
|
510
510
|
get container() {
|
|
511
511
|
return this.#e;
|
|
512
512
|
}
|
|
513
|
+
getPageBox() {
|
|
514
|
+
return this.#z?.measure().book ?? null;
|
|
515
|
+
}
|
|
513
516
|
getSpreads() {
|
|
514
517
|
return this.#T;
|
|
515
518
|
}
|
|
@@ -526,7 +529,7 @@ var J = class {
|
|
|
526
529
|
return this.#h;
|
|
527
530
|
}
|
|
528
531
|
setSpreadMode(e) {
|
|
529
|
-
e !== this.#o && (this.#o = e, this.#_ = !1, this.#
|
|
532
|
+
e !== this.#o && (this.#o = e, this.#_ = !1, this.#_t(), this.#vt());
|
|
530
533
|
}
|
|
531
534
|
toggleSpreadMode() {
|
|
532
535
|
this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
|
|
@@ -542,16 +545,16 @@ var J = class {
|
|
|
542
545
|
if (this.#v = e, e) {
|
|
543
546
|
let e = this.#z?.measure().containerWidth;
|
|
544
547
|
if (e === void 0) return;
|
|
545
|
-
this.#_ = !1, this.#
|
|
548
|
+
this.#_ = !1, this.#gt(e);
|
|
546
549
|
} else {
|
|
547
550
|
if (!this.#_) return;
|
|
548
|
-
this.#_ = !1, this.#
|
|
551
|
+
this.#_ = !1, this.#_t();
|
|
549
552
|
}
|
|
550
|
-
this.#
|
|
553
|
+
this.#vt();
|
|
551
554
|
}
|
|
552
555
|
}
|
|
553
556
|
getPageImage(e) {
|
|
554
|
-
return this.#
|
|
557
|
+
return this.#At(e);
|
|
555
558
|
}
|
|
556
559
|
canFlipNext() {
|
|
557
560
|
return this.#E + 1 < this.#T.length;
|
|
@@ -572,27 +575,27 @@ var J = class {
|
|
|
572
575
|
return typeof this.#t.getOutline == "function" || typeof this.#t.getText == "function";
|
|
573
576
|
}
|
|
574
577
|
canPrint() {
|
|
575
|
-
return typeof this.#t.getDownload == "function";
|
|
578
|
+
return typeof this.#t.getDownload == "function" && this.#e.ownerDocument?.defaultView?.navigator?.pdfViewerEnabled !== !1;
|
|
576
579
|
}
|
|
577
580
|
async print() {
|
|
578
581
|
let e = await this.getSourceFile(), t = this.#e.ownerDocument;
|
|
579
582
|
if (!e || !t) return !1;
|
|
580
|
-
let n = t.createElement("iframe");
|
|
581
|
-
return
|
|
582
|
-
let
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}, 6e4),
|
|
583
|
+
let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("iframe");
|
|
584
|
+
return i.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;", i.setAttribute("aria-hidden", "true"), i.src = n, new Promise((e) => {
|
|
585
|
+
let a = !1, o = (t) => {
|
|
586
|
+
a || (a = !0, setTimeout(() => {
|
|
587
|
+
i.remove(), r && URL.revokeObjectURL(n);
|
|
588
|
+
}, 6e4), e(t));
|
|
586
589
|
};
|
|
587
|
-
|
|
590
|
+
i.addEventListener("load", () => {
|
|
588
591
|
try {
|
|
589
|
-
let e =
|
|
590
|
-
if (!e) return
|
|
591
|
-
e.focus(), e.print(),
|
|
592
|
+
let e = i.contentWindow;
|
|
593
|
+
if (!e) return o(!1);
|
|
594
|
+
e.focus(), e.print(), o(!0);
|
|
592
595
|
} catch {
|
|
593
|
-
|
|
596
|
+
o(!1);
|
|
594
597
|
}
|
|
595
|
-
}),
|
|
598
|
+
}), i.addEventListener("error", () => o(!1)), t.body.appendChild(i);
|
|
596
599
|
});
|
|
597
600
|
}
|
|
598
601
|
canOutline() {
|
|
@@ -614,8 +617,35 @@ var J = class {
|
|
|
614
617
|
if (!e) return !1;
|
|
615
618
|
let t = this.#e.ownerDocument;
|
|
616
619
|
if (!t) return !1;
|
|
617
|
-
let n = t.createElement("a");
|
|
618
|
-
return
|
|
620
|
+
let { url: n, revoke: r } = await this.#be(e, t), i = t.createElement("a");
|
|
621
|
+
return i.href = n, i.download = e.filename, i.rel = "noopener", t.body.appendChild(i), i.click(), i.remove(), r && setTimeout(() => URL.revokeObjectURL(n), 1e4), !0;
|
|
622
|
+
}
|
|
623
|
+
async #be(e, t) {
|
|
624
|
+
if (e.revoke || !this.#xe(e.url, t)) return {
|
|
625
|
+
url: e.url,
|
|
626
|
+
revoke: e.revoke ?? !1
|
|
627
|
+
};
|
|
628
|
+
try {
|
|
629
|
+
let t = await (await fetch(e.url)).blob();
|
|
630
|
+
return {
|
|
631
|
+
url: URL.createObjectURL(t),
|
|
632
|
+
revoke: !0
|
|
633
|
+
};
|
|
634
|
+
} catch {
|
|
635
|
+
return {
|
|
636
|
+
url: e.url,
|
|
637
|
+
revoke: !1
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
#xe(e, t) {
|
|
642
|
+
let n = t.defaultView?.location?.href;
|
|
643
|
+
if (!n) return !1;
|
|
644
|
+
try {
|
|
645
|
+
return new URL(e, n).origin !== new URL(n).origin;
|
|
646
|
+
} catch {
|
|
647
|
+
return !1;
|
|
648
|
+
}
|
|
619
649
|
}
|
|
620
650
|
async search(e, t = {}) {
|
|
621
651
|
let n = this.#t.getText, r = e.trim().toLowerCase();
|
|
@@ -641,29 +671,29 @@ var J = class {
|
|
|
641
671
|
return a;
|
|
642
672
|
}
|
|
643
673
|
flipNext() {
|
|
644
|
-
this.#
|
|
674
|
+
this.#Se(1);
|
|
645
675
|
}
|
|
646
676
|
flipPrev() {
|
|
647
|
-
this.#
|
|
677
|
+
this.#Se(-1);
|
|
648
678
|
}
|
|
649
|
-
#
|
|
650
|
-
this.#
|
|
679
|
+
#Se(e) {
|
|
680
|
+
this.#Ce(() => this.#Oe(this.#E + e));
|
|
651
681
|
}
|
|
652
682
|
flipTo(e) {
|
|
653
683
|
let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
|
|
654
|
-
this.#
|
|
684
|
+
this.#Ce(() => this.#Oe(this.#Mt(t)));
|
|
655
685
|
}
|
|
656
|
-
#
|
|
657
|
-
this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#
|
|
686
|
+
#Ce(e) {
|
|
687
|
+
this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#we(), e()) : this.#q = e;
|
|
658
688
|
}
|
|
659
|
-
#
|
|
689
|
+
#we() {
|
|
660
690
|
let e = this.#J;
|
|
661
691
|
e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
|
|
662
692
|
}
|
|
663
|
-
#
|
|
693
|
+
#Te() {
|
|
664
694
|
let e = this.#q;
|
|
665
695
|
if (!e) {
|
|
666
|
-
this.#
|
|
696
|
+
this.#Et();
|
|
667
697
|
return;
|
|
668
698
|
}
|
|
669
699
|
this.#q = null, e();
|
|
@@ -680,15 +710,15 @@ var J = class {
|
|
|
680
710
|
x: r.containerWidth / 2,
|
|
681
711
|
y: r.containerHeight / 2
|
|
682
712
|
}, o = this.#I, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#L), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#R);
|
|
683
|
-
[s, c] = this.#
|
|
713
|
+
[s, c] = this.#De(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Ee(), this.#St(), this.#n.emit("zoomChanged", { scale: n });
|
|
684
714
|
}
|
|
685
715
|
resetZoom() {
|
|
686
716
|
this.setZoom(1);
|
|
687
717
|
}
|
|
688
|
-
#
|
|
718
|
+
#Ee() {
|
|
689
719
|
this.#e.style.touchAction = this.#I > 1 ? "none" : "pan-y";
|
|
690
720
|
}
|
|
691
|
-
#
|
|
721
|
+
#De(e, t, n, r, i) {
|
|
692
722
|
let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
|
|
693
723
|
x: 0,
|
|
694
724
|
y: 0,
|
|
@@ -701,29 +731,29 @@ var J = class {
|
|
|
701
731
|
return this.#n.on(e, t);
|
|
702
732
|
}
|
|
703
733
|
destroy() {
|
|
704
|
-
this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#
|
|
734
|
+
this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ge(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#it(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#ve !== null && clearTimeout(this.#ve), this.#_e++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
|
|
705
735
|
}
|
|
706
|
-
#
|
|
736
|
+
#Oe(e) {
|
|
707
737
|
if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
|
|
708
|
-
let t = e > this.#E ? "forward" : "backward", n = this.#
|
|
738
|
+
let t = e > this.#E ? "forward" : "backward", n = this.#Ne(e);
|
|
709
739
|
this.#n.emit("flipStart", {
|
|
710
740
|
from: this.#D,
|
|
711
741
|
to: n
|
|
712
|
-
}), this.#
|
|
742
|
+
}), this.#ke(e, t, n, ++this.#Y);
|
|
713
743
|
}
|
|
714
|
-
async #
|
|
715
|
-
let i = this.#T[e], a = i ? await this.#
|
|
744
|
+
async #ke(e, t, n, r) {
|
|
745
|
+
let i = this.#T[e], a = i ? await this.#kt(i) : {
|
|
716
746
|
left: null,
|
|
717
747
|
right: null
|
|
718
748
|
};
|
|
719
749
|
r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
|
|
720
750
|
fill: this.#h,
|
|
721
|
-
curl: this.#
|
|
751
|
+
curl: this.#mt(),
|
|
722
752
|
anchor: { y: this.#l }
|
|
723
|
-
}), this.#
|
|
753
|
+
}), this.#Ae(0, 1, t, () => this.#Me(e, n, a), () => this.#je(n)));
|
|
724
754
|
}
|
|
725
|
-
#
|
|
726
|
-
let a = this.#
|
|
755
|
+
#Ae(e, t, n, r, i) {
|
|
756
|
+
let a = this.#pt() * Math.abs(t - e);
|
|
727
757
|
if (a <= 0) {
|
|
728
758
|
this.#z?.setFlipProgress(t, n), r();
|
|
729
759
|
return;
|
|
@@ -741,22 +771,22 @@ var J = class {
|
|
|
741
771
|
};
|
|
742
772
|
this.#H = requestAnimationFrame(l);
|
|
743
773
|
}
|
|
744
|
-
#
|
|
745
|
-
this.#D !== e && (this.#D = e, this.#
|
|
774
|
+
#je(e) {
|
|
775
|
+
this.#D !== e && (this.#D = e, this.#ft(), this.#n.emit("pageChanged", { page: e }));
|
|
746
776
|
}
|
|
747
|
-
#
|
|
777
|
+
#Me(e, t, n) {
|
|
748
778
|
let r = this.#T[e];
|
|
749
|
-
this.#E = e, this.#O = n, r && this.#
|
|
779
|
+
this.#E = e, this.#O = n, r && this.#yt(r, n), this.#jt(), this.#i.send("settle"), this.#oe = performance.now(), this.#je(t), this.#n.emit("flipEnd", { page: t }), this.#Te();
|
|
750
780
|
}
|
|
751
|
-
#
|
|
781
|
+
#Ne(e) {
|
|
752
782
|
let t = this.#T[e];
|
|
753
783
|
if (!t) return this.#D;
|
|
754
784
|
let n = [t.left, t.right].filter((e) => e !== null);
|
|
755
785
|
return n.length > 0 ? Math.min(...n) : this.#D;
|
|
756
786
|
}
|
|
757
|
-
#
|
|
787
|
+
#Pe(e, t) {
|
|
758
788
|
if (this.#Z || !this.#z) return;
|
|
759
|
-
if (this.#
|
|
789
|
+
if (this.#Ge(), this.#I > 1) {
|
|
760
790
|
if (this.#i.send("panStart") === null) return;
|
|
761
791
|
this.#X = {
|
|
762
792
|
baseTx: this.#L,
|
|
@@ -764,7 +794,7 @@ var J = class {
|
|
|
764
794
|
};
|
|
765
795
|
return;
|
|
766
796
|
}
|
|
767
|
-
let n = this.#
|
|
797
|
+
let n = this.#Ve(), r = this.#He(e, t);
|
|
768
798
|
this.#G = r;
|
|
769
799
|
let i = Math.min(n.width, n.height) * N, a = r.x >= 0 && r.x <= n.width && r.y >= 0 && r.y <= n.height, o = r.x <= i || r.x >= n.width - i, s = a && o;
|
|
770
800
|
if (this.#i.state !== "idle") {
|
|
@@ -772,7 +802,7 @@ var J = class {
|
|
|
772
802
|
this.#W = null;
|
|
773
803
|
return;
|
|
774
804
|
}
|
|
775
|
-
this.#
|
|
805
|
+
this.#we();
|
|
776
806
|
}
|
|
777
807
|
if (!s) return;
|
|
778
808
|
this.#l = Y(r.y / n.height, 0, 1);
|
|
@@ -780,11 +810,11 @@ var J = class {
|
|
|
780
810
|
u < 0 || u >= this.#T.length || (this.#W = {
|
|
781
811
|
direction: l ? "forward" : "backward",
|
|
782
812
|
targetIndex: u,
|
|
783
|
-
toPage: this.#
|
|
813
|
+
toPage: this.#Ne(u),
|
|
784
814
|
width: n.width
|
|
785
815
|
});
|
|
786
816
|
}
|
|
787
|
-
#
|
|
817
|
+
#Fe() {
|
|
788
818
|
let e = this.#W;
|
|
789
819
|
e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
|
|
790
820
|
direction: e.direction,
|
|
@@ -799,32 +829,32 @@ var J = class {
|
|
|
799
829
|
}, this.#n.emit("flipStart", {
|
|
800
830
|
from: this.#D,
|
|
801
831
|
to: e.toPage
|
|
802
|
-
}), this.#
|
|
832
|
+
}), this.#Ie(e.targetIndex, e.direction)));
|
|
803
833
|
}
|
|
804
|
-
async #
|
|
805
|
-
let n = this.#T[e], r = n ? await this.#
|
|
834
|
+
async #Ie(e, t) {
|
|
835
|
+
let n = this.#T[e], r = n ? await this.#kt(n) : {
|
|
806
836
|
left: null,
|
|
807
837
|
right: null
|
|
808
838
|
};
|
|
809
839
|
this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
|
|
810
840
|
fill: this.#h,
|
|
811
|
-
curl: this.#
|
|
841
|
+
curl: this.#mt(),
|
|
812
842
|
anchor: { y: this.#l }
|
|
813
843
|
}), this.#z?.setFlipProgress(this.#U.t, t));
|
|
814
844
|
}
|
|
815
|
-
#
|
|
845
|
+
#Le(e, t) {
|
|
816
846
|
if (this.#Z) return;
|
|
817
847
|
if (this.#X) {
|
|
818
848
|
if (!this.#z) return;
|
|
819
|
-
let n = this.#z.measure(), [r, i] = this.#
|
|
820
|
-
this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#
|
|
849
|
+
let n = this.#z.measure(), [r, i] = this.#De(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
|
|
850
|
+
this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#St();
|
|
821
851
|
return;
|
|
822
852
|
}
|
|
823
|
-
this.#W && Math.hypot(e, t) > F && this.#
|
|
853
|
+
this.#W && Math.hypot(e, t) > F && this.#Fe();
|
|
824
854
|
let n = this.#U;
|
|
825
855
|
n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
|
|
826
856
|
}
|
|
827
|
-
#
|
|
857
|
+
#Re(e) {
|
|
828
858
|
if (this.#Z) return;
|
|
829
859
|
if (this.#X) {
|
|
830
860
|
this.#X = null, this.#i.send("panEnd");
|
|
@@ -832,35 +862,35 @@ var J = class {
|
|
|
832
862
|
}
|
|
833
863
|
let t = this.#U;
|
|
834
864
|
if (!t) {
|
|
835
|
-
this.#W = null, this.#
|
|
865
|
+
this.#W = null, this.#ze(e) || this.#Be(e);
|
|
836
866
|
return;
|
|
837
867
|
}
|
|
838
868
|
this.#U = null, this.#i.send("release");
|
|
839
869
|
let n = e.swipe && Math.abs(e.vx) > Math.abs(e.vy), r = t.direction === "forward" ? e.vx < 0 : e.vx > 0, i = n && r, a = n && !r;
|
|
840
|
-
i || t.t >= .5 && !a ? this.#
|
|
870
|
+
i || t.t >= .5 && !a ? this.#Ae(t.t, 1, t.direction, () => this.#Me(t.targetIndex, t.toPage, t.toContent), () => this.#je(t.toPage)) : this.#Ae(t.t, 0, t.direction, () => this.#Ke());
|
|
841
871
|
}
|
|
842
|
-
#
|
|
872
|
+
#ze(e) {
|
|
843
873
|
if (this.#I > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
|
|
844
874
|
let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
|
|
845
|
-
if (!this.#
|
|
875
|
+
if (!this.#We(n)) return !1;
|
|
846
876
|
let r = t ? 1 : -1;
|
|
847
|
-
return this.#
|
|
877
|
+
return this.#Ce(() => this.#Oe(this.#E + r)), !0;
|
|
848
878
|
}
|
|
849
|
-
#
|
|
879
|
+
#Be(e) {
|
|
850
880
|
if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
|
|
851
|
-
let t = this.#
|
|
852
|
-
if (!t || !this.#
|
|
853
|
-
this.#l = Y(this.#G.y / this.#
|
|
854
|
-
let n = t === "forward" ? 1 : -1, r = () => this.#
|
|
855
|
-
if (this.#
|
|
856
|
-
this.#
|
|
881
|
+
let t = this.#Ue(this.#G);
|
|
882
|
+
if (!t || !this.#We(t)) return;
|
|
883
|
+
this.#l = Y(this.#G.y / this.#Ve().height, 0, 1);
|
|
884
|
+
let n = t === "forward" ? 1 : -1, r = () => this.#Oe(this.#E + n);
|
|
885
|
+
if (this.#Ge(), this.#p <= 0) {
|
|
886
|
+
this.#Ce(r);
|
|
857
887
|
return;
|
|
858
888
|
}
|
|
859
889
|
this.#K = setTimeout(() => {
|
|
860
|
-
this.#K = null, this.#
|
|
890
|
+
this.#K = null, this.#Ce(r);
|
|
861
891
|
}, this.#p);
|
|
862
892
|
}
|
|
863
|
-
#
|
|
893
|
+
#Ve() {
|
|
864
894
|
let e = this.#z.measure();
|
|
865
895
|
return e.content ?? e.book ?? {
|
|
866
896
|
x: 0,
|
|
@@ -869,40 +899,40 @@ var J = class {
|
|
|
869
899
|
height: e.containerHeight
|
|
870
900
|
};
|
|
871
901
|
}
|
|
872
|
-
#
|
|
873
|
-
let n = this.#e.getBoundingClientRect(), r = this.#
|
|
902
|
+
#He(e, t) {
|
|
903
|
+
let n = this.#e.getBoundingClientRect(), r = this.#Ve();
|
|
874
904
|
return {
|
|
875
905
|
x: e - n.left - r.x,
|
|
876
906
|
y: t - n.top - r.y
|
|
877
907
|
};
|
|
878
908
|
}
|
|
879
|
-
#
|
|
909
|
+
#Ue(e) {
|
|
880
910
|
if (!this.#z) return null;
|
|
881
|
-
let t = this.#
|
|
911
|
+
let t = this.#Ve().width, n;
|
|
882
912
|
if (n = this.#u === "half" ? e.x > t / 2 ? "right" : "left" : e.x <= this.#d ? "left" : e.x >= t - this.#d ? "right" : null, !n) return null;
|
|
883
913
|
let r = this.#a === "rtl" ? "left" : "right";
|
|
884
914
|
return n === r ? "forward" : "backward";
|
|
885
915
|
}
|
|
886
|
-
#
|
|
916
|
+
#We(e) {
|
|
887
917
|
let t = this.#E + (e === "forward" ? 1 : -1);
|
|
888
918
|
return t >= 0 && t < this.#T.length;
|
|
889
919
|
}
|
|
890
|
-
#
|
|
920
|
+
#Ge() {
|
|
891
921
|
this.#K !== null && (clearTimeout(this.#K), this.#K = null);
|
|
892
922
|
}
|
|
893
|
-
#
|
|
923
|
+
#Ke() {
|
|
894
924
|
let e = this.#T[this.#E];
|
|
895
|
-
e && this.#
|
|
925
|
+
e && this.#yt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#Te();
|
|
896
926
|
}
|
|
897
|
-
#
|
|
898
|
-
if (this.#W = null, this.#
|
|
927
|
+
#qe() {
|
|
928
|
+
if (this.#W = null, this.#Ge(), this.#U) {
|
|
899
929
|
this.#U = null, this.#i.send("release"), this.#i.send("settle");
|
|
900
930
|
let e = this.#T[this.#E];
|
|
901
|
-
e && this.#
|
|
931
|
+
e && this.#yt(e, this.#O);
|
|
902
932
|
} else this.#X && (this.#X = null, this.#i.send("panEnd"));
|
|
903
933
|
this.#Z = !0, this.#Q = this.#I;
|
|
904
934
|
}
|
|
905
|
-
#
|
|
935
|
+
#Je(e, t, n) {
|
|
906
936
|
if (!this.#Z) return;
|
|
907
937
|
let r = this.#e.getBoundingClientRect();
|
|
908
938
|
this.setZoom(this.#Q * n, {
|
|
@@ -910,15 +940,15 @@ var J = class {
|
|
|
910
940
|
y: t - r.top
|
|
911
941
|
});
|
|
912
942
|
}
|
|
913
|
-
#
|
|
943
|
+
#Ye() {
|
|
914
944
|
this.#Z = !1;
|
|
915
945
|
}
|
|
916
|
-
#
|
|
946
|
+
#Xe() {
|
|
917
947
|
if (!this.#S) return;
|
|
918
948
|
let e = (e) => e.preventDefault();
|
|
919
949
|
this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
|
|
920
950
|
}
|
|
921
|
-
#
|
|
951
|
+
#Ze() {
|
|
922
952
|
let e = (e) => {
|
|
923
953
|
if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
|
|
924
954
|
e.preventDefault();
|
|
@@ -930,7 +960,7 @@ var J = class {
|
|
|
930
960
|
};
|
|
931
961
|
this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
|
|
932
962
|
}
|
|
933
|
-
#
|
|
963
|
+
#Qe() {
|
|
934
964
|
let e = (e) => {
|
|
935
965
|
let t = this.#M;
|
|
936
966
|
if (!this.#A || t === null || !this.#z) return;
|
|
@@ -943,72 +973,72 @@ var J = class {
|
|
|
943
973
|
};
|
|
944
974
|
return;
|
|
945
975
|
}
|
|
946
|
-
this.#ae = null, this
|
|
976
|
+
this.#ae = null, this.#$e(e.clientX, e.clientY, t);
|
|
947
977
|
};
|
|
948
978
|
this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
|
|
949
979
|
}
|
|
950
|
-
|
|
980
|
+
#$e(e, t, n) {
|
|
951
981
|
if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
|
|
952
|
-
let n = this.#
|
|
953
|
-
if (r !== null && this.#
|
|
982
|
+
let n = this.#He(e, t), r = this.#Ue(n);
|
|
983
|
+
if (r !== null && this.#We(r) || this.#i.state === "animating" || performance.now() - this.#oe <= R) return;
|
|
954
984
|
}
|
|
955
|
-
this.#
|
|
985
|
+
this.#Ge();
|
|
956
986
|
let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
|
|
957
987
|
this.setZoom(r, {
|
|
958
988
|
x: e - i.left,
|
|
959
989
|
y: t - i.top
|
|
960
990
|
});
|
|
961
991
|
}
|
|
962
|
-
async #
|
|
992
|
+
async #et(e) {
|
|
963
993
|
let t = k(e);
|
|
964
|
-
if (this.#t.onProgress?.((e) => this
|
|
965
|
-
this.#
|
|
994
|
+
if (this.#t.onProgress?.((e) => this.#tt(e)), typeof this.#t.open == "function") {
|
|
995
|
+
this.#nt();
|
|
966
996
|
try {
|
|
967
|
-
await this.#t.open(), this.#
|
|
997
|
+
await this.#t.open(), this.#Nt();
|
|
968
998
|
} catch (e) {
|
|
969
|
-
throw this.#
|
|
999
|
+
throw this.#it(), e;
|
|
970
1000
|
}
|
|
971
|
-
this.#
|
|
1001
|
+
this.#rt("preparing");
|
|
972
1002
|
}
|
|
973
1003
|
this.#t.prefetch([this.#D]);
|
|
974
|
-
let n = await t, r = await this.#
|
|
975
|
-
this.#z = r, this.#t.onPageUpdate?.((e) => this.#
|
|
1004
|
+
let n = await t, r = await this.#at(n);
|
|
1005
|
+
this.#z = r, this.#t.onPageUpdate?.((e) => this.#xt(e)), this.#gt(r.measure().containerWidth);
|
|
976
1006
|
let i = new m({
|
|
977
|
-
onStart: (e) => this.#
|
|
978
|
-
onMove: (e) => this.#
|
|
979
|
-
onEnd: (e) => this.#
|
|
1007
|
+
onStart: (e) => this.#Pe(e.x, e.y),
|
|
1008
|
+
onMove: (e) => this.#Le(e.dx, e.dy),
|
|
1009
|
+
onEnd: (e) => this.#Re(e)
|
|
980
1010
|
}), a = new _({
|
|
981
|
-
onPinchStart: () => this.#
|
|
982
|
-
onPinchMove: (e) => this.#
|
|
983
|
-
onPinchEnd: () => this.#
|
|
1011
|
+
onPinchStart: () => this.#qe(),
|
|
1012
|
+
onPinchMove: (e) => this.#Je(e.centerX, e.centerY, e.scale),
|
|
1013
|
+
onPinchEnd: () => this.#Ye()
|
|
984
1014
|
});
|
|
985
1015
|
this.#te = h(this.#e, {
|
|
986
1016
|
pointer: i,
|
|
987
1017
|
pinch: a
|
|
988
|
-
}), this.#
|
|
1018
|
+
}), this.#Ee(), this.#Ze(), this.#Qe(), this.#Xe(), this.#st(), this.#se = this.#ut(), await this.#vt(), this.#it(), this.#Dt(), this.#jt(), this.#ft(), this.#lt(), await this.#ct(), this.#n.emit("ready");
|
|
989
1019
|
}
|
|
990
|
-
|
|
1020
|
+
#tt(e) {
|
|
991
1021
|
this.#me = e, this.#n.emit("progress", e), this.#pe?.update(e);
|
|
992
1022
|
}
|
|
993
|
-
async #
|
|
1023
|
+
async #nt() {
|
|
994
1024
|
if (this.#fe === !1 || this.#V) return;
|
|
995
1025
|
let e = this.#e;
|
|
996
1026
|
if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
|
|
997
|
-
let { mountLoading: t } = await import("./loading-
|
|
1027
|
+
let { mountLoading: t } = await import("./loading-BBK6YbSW.js");
|
|
998
1028
|
if (this.#he === "done" || this.#V) return;
|
|
999
1029
|
this.#pe = t(e), this.#me && this.#pe.update(this.#me), this.#he === "preparing" && this.#pe.preparing();
|
|
1000
1030
|
} catch {}
|
|
1001
1031
|
}
|
|
1002
|
-
#
|
|
1032
|
+
#rt(e) {
|
|
1003
1033
|
this.#he !== "done" && (this.#he = e, this.#pe?.preparing());
|
|
1004
1034
|
}
|
|
1005
|
-
#
|
|
1035
|
+
#it() {
|
|
1006
1036
|
this.#he = "done", this.#pe?.destroy(), this.#pe = null;
|
|
1007
1037
|
}
|
|
1008
|
-
async #
|
|
1038
|
+
async #at(e) {
|
|
1009
1039
|
try {
|
|
1010
1040
|
return await e.mount(this.#e), e.onFatal?.(() => {
|
|
1011
|
-
this.#
|
|
1041
|
+
this.#ot();
|
|
1012
1042
|
}), e;
|
|
1013
1043
|
} catch {
|
|
1014
1044
|
e.destroy();
|
|
@@ -1019,7 +1049,7 @@ var J = class {
|
|
|
1019
1049
|
}), t;
|
|
1020
1050
|
}
|
|
1021
1051
|
}
|
|
1022
|
-
async #
|
|
1052
|
+
async #ot() {
|
|
1023
1053
|
if (this.#B || this.#V) return;
|
|
1024
1054
|
this.#B = !0, this.#z?.destroy(), this.#z = null;
|
|
1025
1055
|
let e = await k("css");
|
|
@@ -1027,29 +1057,29 @@ var J = class {
|
|
|
1027
1057
|
e.destroy();
|
|
1028
1058
|
return;
|
|
1029
1059
|
}
|
|
1030
|
-
await e.mount(this.#e), this.#z = e, this.#
|
|
1060
|
+
await e.mount(this.#e), this.#z = e, this.#gt(e.measure().containerWidth), await this.#vt(), this.#n.emit("rendererFallback", {
|
|
1031
1061
|
from: "webgl2",
|
|
1032
1062
|
to: "css"
|
|
1033
1063
|
});
|
|
1034
1064
|
}
|
|
1035
|
-
#
|
|
1065
|
+
#st() {
|
|
1036
1066
|
if (typeof matchMedia != "function") return;
|
|
1037
1067
|
let e = matchMedia("(prefers-reduced-motion: reduce)");
|
|
1038
1068
|
this.#$ = e.matches, e.addEventListener?.("change", (e) => {
|
|
1039
1069
|
this.#$ = e.matches;
|
|
1040
1070
|
});
|
|
1041
1071
|
}
|
|
1042
|
-
async #
|
|
1072
|
+
async #ct() {
|
|
1043
1073
|
if (this.#ue === !1 || this.#V) return;
|
|
1044
1074
|
let e = this.#e;
|
|
1045
1075
|
if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
|
|
1046
|
-
let { mountControls: t } = await import("./controls-
|
|
1076
|
+
let { mountControls: t } = await import("./controls-DgEXR2zi.js");
|
|
1047
1077
|
if (this.#V) return;
|
|
1048
1078
|
let n = this.#ue === !0 ? {} : this.#ue;
|
|
1049
1079
|
this.#de = t(this, e, n);
|
|
1050
1080
|
} catch {}
|
|
1051
1081
|
}
|
|
1052
|
-
#
|
|
1082
|
+
#lt() {
|
|
1053
1083
|
if (!this.#x || globalThis.location === void 0) return;
|
|
1054
1084
|
let e = globalThis;
|
|
1055
1085
|
this.#C = w(e, (e) => {
|
|
@@ -1064,18 +1094,18 @@ var J = class {
|
|
|
1064
1094
|
let n = new URL(t);
|
|
1065
1095
|
return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
|
|
1066
1096
|
}
|
|
1067
|
-
#
|
|
1097
|
+
#ut() {
|
|
1068
1098
|
let e = this.#e, t = e.ownerDocument;
|
|
1069
1099
|
if (!t || typeof e.setAttribute != "function") return null;
|
|
1070
1100
|
e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
|
|
1071
|
-
let n = (e) => this.#
|
|
1101
|
+
let n = (e) => this.#dt(e);
|
|
1072
1102
|
e.addEventListener("keydown", n);
|
|
1073
1103
|
let r = t.createElement("div");
|
|
1074
1104
|
return r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true"), r.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;", e.appendChild(r), this.#ee = r, () => {
|
|
1075
1105
|
e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
|
|
1076
1106
|
};
|
|
1077
1107
|
}
|
|
1078
|
-
#
|
|
1108
|
+
#dt(e) {
|
|
1079
1109
|
let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
1080
1110
|
switch (e.key) {
|
|
1081
1111
|
case "ArrowRight":
|
|
@@ -1091,70 +1121,70 @@ var J = class {
|
|
|
1091
1121
|
default: break;
|
|
1092
1122
|
}
|
|
1093
1123
|
}
|
|
1094
|
-
#
|
|
1124
|
+
#ft() {
|
|
1095
1125
|
this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
|
|
1096
1126
|
}
|
|
1097
|
-
#
|
|
1127
|
+
#pt() {
|
|
1098
1128
|
return this.#$ ? W : this.#k * (this.#h ? z : 1);
|
|
1099
1129
|
}
|
|
1100
|
-
#
|
|
1130
|
+
#mt() {
|
|
1101
1131
|
return this.#$ ? "simple" : this.#c;
|
|
1102
1132
|
}
|
|
1103
1133
|
update() {
|
|
1104
|
-
!this.#z || this.#i.state !== "idle" || (this.#
|
|
1134
|
+
!this.#z || this.#i.state !== "idle" || (this.#gt(this.#z.measure().containerWidth), this.#vt());
|
|
1105
1135
|
}
|
|
1106
|
-
#
|
|
1136
|
+
#ht() {
|
|
1107
1137
|
return this.#_ || this.#o === "single" ? "single" : this.#o;
|
|
1108
1138
|
}
|
|
1109
|
-
#
|
|
1139
|
+
#gt(e) {
|
|
1110
1140
|
let t = this.#v && o(e, this.#m);
|
|
1111
|
-
t !== this.#_ && (this.#_ = t, this.#
|
|
1141
|
+
t !== this.#_ && (this.#_ = t, this.#_t());
|
|
1112
1142
|
}
|
|
1113
|
-
#
|
|
1114
|
-
let e = this.#
|
|
1143
|
+
#_t() {
|
|
1144
|
+
let e = this.#ht(), t = e !== this.#g;
|
|
1115
1145
|
this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
|
|
1116
1146
|
direction: this.#a,
|
|
1117
1147
|
mode: e
|
|
1118
|
-
}), this.#E = this.#
|
|
1148
|
+
}), this.#E = this.#Mt(this.#D), t && this.#n.emit("spreadChanged", {
|
|
1119
1149
|
mode: e,
|
|
1120
1150
|
singlePage: this.#h
|
|
1121
1151
|
});
|
|
1122
1152
|
}
|
|
1123
|
-
async #
|
|
1153
|
+
async #vt() {
|
|
1124
1154
|
let e = this.#T[this.#E];
|
|
1125
|
-
!e || !this.#z || (this.#O = await this.#
|
|
1155
|
+
!e || !this.#z || (this.#O = await this.#kt(e), this.#yt(e, this.#O));
|
|
1126
1156
|
}
|
|
1127
|
-
#
|
|
1128
|
-
this.#z?.renderSpread(e, t, { fill: this.#h }), this.#
|
|
1157
|
+
#yt(e, t) {
|
|
1158
|
+
this.#z?.renderSpread(e, t, { fill: this.#h }), this.#bt(), this.#ge = 1, this.#St();
|
|
1129
1159
|
}
|
|
1130
|
-
#
|
|
1160
|
+
#bt() {
|
|
1131
1161
|
let e = this.#z?.measure().book;
|
|
1132
1162
|
if (!e || e.width <= 0 || e.height <= 0) return;
|
|
1133
1163
|
let t = (e.width / e.height).toFixed(4);
|
|
1134
1164
|
t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
|
|
1135
1165
|
}
|
|
1136
|
-
#
|
|
1166
|
+
#xt(e) {
|
|
1137
1167
|
if (this.#i.state !== "idle") {
|
|
1138
1168
|
this.#le.add(e);
|
|
1139
1169
|
return;
|
|
1140
1170
|
}
|
|
1141
1171
|
let t = this.#T[this.#E];
|
|
1142
|
-
t && (t.left === e || t.right === e) && this.#
|
|
1172
|
+
t && (t.left === e || t.right === e) && this.#vt();
|
|
1143
1173
|
}
|
|
1144
|
-
#
|
|
1174
|
+
#St() {
|
|
1145
1175
|
this.#ve !== null && clearTimeout(this.#ve);
|
|
1146
|
-
let e = this.#
|
|
1176
|
+
let e = this.#wt();
|
|
1147
1177
|
if (e !== this.#ge) {
|
|
1148
1178
|
if (e === 1) {
|
|
1149
|
-
this.#_e++, this.#ge = 1, this.#
|
|
1179
|
+
this.#_e++, this.#ge = 1, this.#vt();
|
|
1150
1180
|
return;
|
|
1151
1181
|
}
|
|
1152
1182
|
this.#ve = setTimeout(() => {
|
|
1153
|
-
this.#ve = null, this.#
|
|
1183
|
+
this.#ve = null, this.#Tt();
|
|
1154
1184
|
}, V);
|
|
1155
1185
|
}
|
|
1156
1186
|
}
|
|
1157
|
-
#
|
|
1187
|
+
#Ct() {
|
|
1158
1188
|
let e = this.#z?.measure(), t = e?.content ?? e?.book;
|
|
1159
1189
|
if (!t || t.width <= 0) return 1;
|
|
1160
1190
|
let n = this.#O, r = +!!n.left + +!!n.right;
|
|
@@ -1167,14 +1197,14 @@ var J = class {
|
|
|
1167
1197
|
}
|
|
1168
1198
|
return o === 0 ? 1 : o;
|
|
1169
1199
|
}
|
|
1170
|
-
#
|
|
1171
|
-
let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#
|
|
1200
|
+
#wt() {
|
|
1201
|
+
let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#Ct() * Math.max(t, e);
|
|
1172
1202
|
return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
|
|
1173
1203
|
}
|
|
1174
|
-
async #
|
|
1204
|
+
async #Tt() {
|
|
1175
1205
|
let e = this.#T[this.#E];
|
|
1176
1206
|
if (!this.#z || !e) return;
|
|
1177
|
-
let t = this.#
|
|
1207
|
+
let t = this.#wt();
|
|
1178
1208
|
if (t === 1 || t === this.#ge || this.#i.state !== "idle") return;
|
|
1179
1209
|
let n = ++this.#_e, r = {
|
|
1180
1210
|
x: 0,
|
|
@@ -1195,34 +1225,34 @@ var J = class {
|
|
|
1195
1225
|
}), null;
|
|
1196
1226
|
}
|
|
1197
1227
|
}));
|
|
1198
|
-
if (n !== this.#_e || this.#
|
|
1228
|
+
if (n !== this.#_e || this.#wt() !== t || this.#i.state !== "idle") return;
|
|
1199
1229
|
let a = i[0] ?? null, o = i[1] ?? null;
|
|
1200
1230
|
a === this.#O.left && o === this.#O.right || (this.#ge = t, this.#O = {
|
|
1201
1231
|
left: a,
|
|
1202
1232
|
right: o
|
|
1203
1233
|
}, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
|
|
1204
1234
|
}
|
|
1205
|
-
#
|
|
1235
|
+
#Et() {
|
|
1206
1236
|
if (this.#le.size === 0) return;
|
|
1207
1237
|
let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
|
|
1208
|
-
this.#le.clear(), t && this.#
|
|
1238
|
+
this.#le.clear(), t && this.#vt();
|
|
1209
1239
|
}
|
|
1210
|
-
#
|
|
1211
|
-
typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#
|
|
1240
|
+
#Dt() {
|
|
1241
|
+
typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Ot()), this.#P.observe(this.#e));
|
|
1212
1242
|
}
|
|
1213
|
-
#
|
|
1243
|
+
#Ot() {
|
|
1214
1244
|
this.#F || (this.#F = !0, requestAnimationFrame(() => {
|
|
1215
1245
|
this.#F = !1, this.update();
|
|
1216
1246
|
}));
|
|
1217
1247
|
}
|
|
1218
|
-
async #
|
|
1219
|
-
let [t, n] = await Promise.all([this.#
|
|
1248
|
+
async #kt(e) {
|
|
1249
|
+
let [t, n] = await Promise.all([this.#At(e.left), this.#At(e.right)]);
|
|
1220
1250
|
return {
|
|
1221
1251
|
left: t,
|
|
1222
1252
|
right: n
|
|
1223
1253
|
};
|
|
1224
1254
|
}
|
|
1225
|
-
async #
|
|
1255
|
+
async #At(e) {
|
|
1226
1256
|
if (e === null) return null;
|
|
1227
1257
|
try {
|
|
1228
1258
|
return await this.#t.get(e);
|
|
@@ -1233,7 +1263,7 @@ var J = class {
|
|
|
1233
1263
|
}), null;
|
|
1234
1264
|
}
|
|
1235
1265
|
}
|
|
1236
|
-
#
|
|
1266
|
+
#jt() {
|
|
1237
1267
|
let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
|
|
1238
1268
|
for (let n of e) {
|
|
1239
1269
|
let e = this.#T[n];
|
|
@@ -1241,22 +1271,22 @@ var J = class {
|
|
|
1241
1271
|
}
|
|
1242
1272
|
this.#t.prefetch(t);
|
|
1243
1273
|
}
|
|
1244
|
-
#
|
|
1274
|
+
#Mt(e) {
|
|
1245
1275
|
let t = this.#T.findIndex((t) => t.left === e || t.right === e);
|
|
1246
1276
|
return t === -1 ? 0 : t;
|
|
1247
1277
|
}
|
|
1248
|
-
#
|
|
1278
|
+
#Nt() {
|
|
1249
1279
|
let e = this.#t.pageCount;
|
|
1250
1280
|
if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
|
|
1251
1281
|
let t = this.#b;
|
|
1252
1282
|
if (t !== void 0 && (!Number.isInteger(t) || t < 0 || t >= e)) throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e - 1}).`);
|
|
1253
|
-
let n = this.#
|
|
1283
|
+
let n = this.#ht();
|
|
1254
1284
|
this.#h = n === "single", this.#T = a(e, {
|
|
1255
1285
|
direction: this.#a,
|
|
1256
1286
|
mode: n
|
|
1257
1287
|
});
|
|
1258
1288
|
let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
|
|
1259
|
-
this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#
|
|
1289
|
+
this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#Mt(this.#D);
|
|
1260
1290
|
}
|
|
1261
1291
|
};
|
|
1262
1292
|
function Y(e, t, n) {
|
|
@@ -1315,19 +1345,27 @@ function re(n, r) {
|
|
|
1315
1345
|
"left",
|
|
1316
1346
|
"right"
|
|
1317
1347
|
].includes(d)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(d)}.`);
|
|
1318
|
-
let f =
|
|
1348
|
+
let f = u?.colorScheme;
|
|
1319
1349
|
if (f !== void 0 && ![
|
|
1350
|
+
"light",
|
|
1351
|
+
"dark",
|
|
1352
|
+
"auto"
|
|
1353
|
+
].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
|
|
1354
|
+
let p = u?.arrows;
|
|
1355
|
+
if (p !== void 0 && typeof p != "boolean" && !["desktop", "mobile"].includes(p)) throw Error(`Zine: controls.arrows must be a boolean, 'desktop', or 'mobile'; got ${JSON.stringify(p)}.`);
|
|
1356
|
+
let m = i.spreadMode;
|
|
1357
|
+
if (m !== void 0 && ![
|
|
1320
1358
|
"double",
|
|
1321
1359
|
"single",
|
|
1322
1360
|
"cover",
|
|
1323
1361
|
"book"
|
|
1324
|
-
].includes(
|
|
1362
|
+
].includes(m)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(m)}.`);
|
|
1325
1363
|
for (let e of ["frontCover", "backCover"]) {
|
|
1326
1364
|
let t = i[e];
|
|
1327
1365
|
if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
|
|
1328
1366
|
}
|
|
1329
|
-
let
|
|
1330
|
-
if (
|
|
1367
|
+
let h = i.pages;
|
|
1368
|
+
if (h !== void 0 && (typeof h != "object" || !h || Array.isArray(h))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
|
|
1331
1369
|
$(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ie(i.zoom), ae(i.renderer);
|
|
1332
1370
|
}
|
|
1333
1371
|
function $(e, t, n) {
|