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