@zinejs/core 0.8.2 → 0.9.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/LICENSE +73 -0
- package/README.md +27 -49
- package/dist/{bundled-Cp43MIt0.js → bundled-ESapkNsS.js} +34 -34
- package/dist/bundled-ESapkNsS.js.map +1 -0
- package/dist/controls/contextMenu.d.ts +16 -0
- package/dist/controls/controls.d.ts +10 -3
- package/dist/controls/icons.d.ts +6 -2
- package/dist/controls/menu.d.ts +68 -0
- package/dist/controls/search.d.ts +15 -2
- package/dist/controls/styles.d.ts +1 -1
- package/dist/controls/toolbar.d.ts +1 -1
- package/dist/controls/types.d.ts +6 -0
- package/dist/{controls-DgEXR2zi.js → controls-DzVdwPJB.js} +349 -196
- package/dist/controls-DzVdwPJB.js.map +1 -0
- package/dist/curls.js +1 -1
- package/dist/flipSound-BFXSkWBo.js +78 -0
- package/dist/flipSound-BFXSkWBo.js.map +1 -0
- package/dist/geometry/curls/cone.d.ts +4 -3
- package/dist/index.js +671 -440
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +26 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/loading/loading.d.ts +1 -1
- package/dist/loading-DF88K9yJ.js +45 -0
- package/dist/loading-DF88K9yJ.js.map +1 -0
- package/dist/renderer/gl/texture.d.ts +13 -2
- package/dist/renderer/types.d.ts +6 -0
- package/dist/renderer/webglRenderer.d.ts +1 -0
- package/dist/{share-WXdscwp3.js → share-Cq3RsjPr.js} +2 -2
- package/dist/{share-WXdscwp3.js.map → share-Cq3RsjPr.js.map} +1 -1
- package/dist/sound/clip.d.ts +9 -0
- package/dist/sound/flipSound.d.ts +30 -0
- package/dist/source/types.d.ts +5 -0
- package/dist/styles-C1Qp5pby.js +42 -0
- package/dist/styles-C1Qp5pby.js.map +1 -0
- package/dist/{webglRenderer-nGRruZk2.js → webglRenderer-CmQ_mUrX.js} +113 -101
- package/dist/webglRenderer-CmQ_mUrX.js.map +1 -0
- package/dist/zine.d.ts +75 -1
- package/options.schema.json +66 -0
- package/package.json +13 -11
- package/dist/bundled-Cp43MIt0.js.map +0 -1
- package/dist/controls-DgEXR2zi.js.map +0 -1
- package/dist/loading-BBK6YbSW.js +0 -45
- package/dist/loading-BBK6YbSW.js.map +0 -1
- package/dist/styles-B8fFoYm_.js +0 -40
- package/dist/styles-B8fFoYm_.js.map +0 -1
- package/dist/webglRenderer-nGRruZk2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -238,7 +238,7 @@ var _ = class {
|
|
|
238
238
|
}
|
|
239
239
|
#a() {
|
|
240
240
|
let e = [...this.#t.values()], t = e[0], n = e[1];
|
|
241
|
-
if (!t || !n) throw Error("pinch requires two active pointers");
|
|
241
|
+
if (!t || !n) throw Error("Zine: pinch requires two active pointers.");
|
|
242
242
|
return {
|
|
243
243
|
a: t,
|
|
244
244
|
b: n
|
|
@@ -261,7 +261,7 @@ function C(e, t) {
|
|
|
261
261
|
let n = new URLSearchParams(e.replace(/^#/, ""));
|
|
262
262
|
return n.set(v, String(t + 1)), `#${n.toString()}`;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function ee(e, t) {
|
|
265
265
|
let n = null, r = () => {
|
|
266
266
|
let r = S(e.location.hash);
|
|
267
267
|
r === null || r === n || (n = r, t(r));
|
|
@@ -280,49 +280,49 @@ function w(e, t) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/renderer/select.ts
|
|
283
|
-
var
|
|
283
|
+
var te = {
|
|
284
284
|
css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
|
|
285
|
-
webgl2: async () => new (await (import("./webglRenderer-
|
|
286
|
-
},
|
|
287
|
-
function
|
|
285
|
+
webgl2: async () => new (await (import("./webglRenderer-CmQ_mUrX.js"))).WebglRenderer()
|
|
286
|
+
}, ne = !0;
|
|
287
|
+
function w(e) {
|
|
288
288
|
return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
|
|
289
289
|
}
|
|
290
|
-
function
|
|
291
|
-
return e.gpu &&
|
|
290
|
+
function T(e) {
|
|
291
|
+
return e.gpu && ne ? ["webgl2", "css"] : ["css"];
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
return { gpu:
|
|
293
|
+
function E() {
|
|
294
|
+
return { gpu: D() };
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function D() {
|
|
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
|
|
304
|
-
if (
|
|
305
|
-
let n = Array.isArray(e) ? e : e === "auto" ?
|
|
303
|
+
async function O(e = "auto", t = E()) {
|
|
304
|
+
if (w(e)) return e;
|
|
305
|
+
let n = Array.isArray(e) ? e : e === "auto" ? T(t) : [e];
|
|
306
306
|
for (let e of n) {
|
|
307
307
|
if (e === "webgl2" && !t.gpu) continue;
|
|
308
|
-
let n =
|
|
308
|
+
let n = te[e];
|
|
309
309
|
if (n) return n();
|
|
310
310
|
}
|
|
311
311
|
throw n.length === 1 && n[0] === "webgl2" && !t.gpu ? Error("renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.") : Error(`renderer: none of [${n.join(", ")}] could be loaded — use 'css' or 'auto'.`);
|
|
312
312
|
}
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region src/source/compose.ts
|
|
315
|
-
function
|
|
315
|
+
function re(e, t) {
|
|
316
316
|
let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
|
|
317
|
-
return !n && !r && !i ? e : new
|
|
317
|
+
return !n && !r && !i ? e : new ae(e, t);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function ie(e) {
|
|
320
320
|
return fetch(e).then((t) => {
|
|
321
321
|
if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
|
|
322
322
|
return t.blob();
|
|
323
323
|
}).then((e) => createImageBitmap(e));
|
|
324
324
|
}
|
|
325
|
-
var
|
|
325
|
+
var ae = class {
|
|
326
326
|
#e;
|
|
327
327
|
#t;
|
|
328
328
|
#n;
|
|
@@ -391,16 +391,16 @@ var M = class {
|
|
|
391
391
|
}
|
|
392
392
|
#s(e) {
|
|
393
393
|
let t = this.#a.get(e);
|
|
394
|
-
return t === void 0 && (t =
|
|
394
|
+
return t === void 0 && (t = ie(e).catch((t) => {
|
|
395
395
|
throw this.#a.delete(e), t;
|
|
396
396
|
}), this.#a.set(e, t)), t;
|
|
397
397
|
}
|
|
398
|
-
},
|
|
399
|
-
function
|
|
400
|
-
let r = Math.max(0, t -
|
|
398
|
+
}, k = .25, A = .0015, j = 6, M = 250, N = 24, P = 2 * M, F = 1.2, I = 32, L = 60, R = 2.5, z = 1.5, B = 120, V = .85, H = .82, U = .12, oe = 360, W = 28, G = 260, K = 7e3, q = 2200, J = "zine:hints-learned", Y = "zine:sound-muted";
|
|
399
|
+
function se(e, t, n) {
|
|
400
|
+
let r = Math.max(0, t - I), i = Math.min(e.length, t + n + I), a = e.slice(r, i).replace(/\s+/g, " ").trim();
|
|
401
401
|
return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
|
|
402
402
|
}
|
|
403
|
-
var
|
|
403
|
+
var ce = class {
|
|
404
404
|
#e;
|
|
405
405
|
#t;
|
|
406
406
|
#n = new l();
|
|
@@ -414,110 +414,141 @@ var J = class {
|
|
|
414
414
|
#u;
|
|
415
415
|
#d;
|
|
416
416
|
#f;
|
|
417
|
-
#p;
|
|
418
|
-
#m;
|
|
419
|
-
#h
|
|
420
|
-
#g
|
|
421
|
-
#_
|
|
417
|
+
#p = null;
|
|
418
|
+
#m = null;
|
|
419
|
+
#h;
|
|
420
|
+
#g;
|
|
421
|
+
#_;
|
|
422
422
|
#v;
|
|
423
|
-
#y =
|
|
424
|
-
#b;
|
|
425
|
-
#x;
|
|
426
|
-
#S;
|
|
427
|
-
#C =
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
#D = 0;
|
|
432
|
-
#O = {
|
|
433
|
-
left: null,
|
|
434
|
-
right: null
|
|
423
|
+
#y = null;
|
|
424
|
+
#b = !1;
|
|
425
|
+
#x = !1;
|
|
426
|
+
#S = !1;
|
|
427
|
+
#C = {
|
|
428
|
+
turn: !1,
|
|
429
|
+
zoom: !1,
|
|
430
|
+
pan: !1
|
|
435
431
|
};
|
|
436
|
-
#
|
|
437
|
-
#
|
|
438
|
-
#
|
|
432
|
+
#w = null;
|
|
433
|
+
#T = null;
|
|
434
|
+
#E = null;
|
|
435
|
+
#D = null;
|
|
436
|
+
#O = null;
|
|
437
|
+
#k = null;
|
|
438
|
+
#A = !1;
|
|
439
|
+
#j = "";
|
|
439
440
|
#M;
|
|
440
441
|
#N;
|
|
441
|
-
#P
|
|
442
|
+
#P;
|
|
442
443
|
#F = !1;
|
|
443
|
-
#I =
|
|
444
|
-
#L =
|
|
445
|
-
#R
|
|
444
|
+
#I = null;
|
|
445
|
+
#L = !1;
|
|
446
|
+
#R;
|
|
446
447
|
#z = null;
|
|
447
|
-
#B
|
|
448
|
-
#V
|
|
449
|
-
#H
|
|
448
|
+
#B;
|
|
449
|
+
#V;
|
|
450
|
+
#H;
|
|
450
451
|
#U = null;
|
|
451
452
|
#W = null;
|
|
452
|
-
#G =
|
|
453
|
-
#K =
|
|
454
|
-
#q =
|
|
455
|
-
#J =
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
#
|
|
460
|
-
|
|
453
|
+
#G = [];
|
|
454
|
+
#K = 0;
|
|
455
|
+
#q = 0;
|
|
456
|
+
#J = {
|
|
457
|
+
left: null,
|
|
458
|
+
right: null
|
|
459
|
+
};
|
|
460
|
+
#Y;
|
|
461
|
+
#X;
|
|
462
|
+
#Z;
|
|
463
|
+
#Q;
|
|
464
|
+
#$;
|
|
461
465
|
#ee = null;
|
|
462
|
-
#te =
|
|
463
|
-
#ne =
|
|
464
|
-
#re =
|
|
465
|
-
#ie =
|
|
466
|
+
#te = !1;
|
|
467
|
+
#ne = 1;
|
|
468
|
+
#re = 0;
|
|
469
|
+
#ie = 0;
|
|
466
470
|
#ae = null;
|
|
467
|
-
#oe =
|
|
468
|
-
#se =
|
|
471
|
+
#oe = !1;
|
|
472
|
+
#se = !1;
|
|
469
473
|
#ce = null;
|
|
470
|
-
#le =
|
|
471
|
-
#ue;
|
|
474
|
+
#le = null;
|
|
475
|
+
#ue = null;
|
|
472
476
|
#de = null;
|
|
473
|
-
#fe;
|
|
477
|
+
#fe = null;
|
|
474
478
|
#pe = null;
|
|
475
479
|
#me = null;
|
|
476
|
-
#he =
|
|
477
|
-
#ge =
|
|
478
|
-
#_e =
|
|
479
|
-
#ve =
|
|
480
|
-
#ye;
|
|
480
|
+
#he = 0;
|
|
481
|
+
#ge = null;
|
|
482
|
+
#_e = !1;
|
|
483
|
+
#ve = 1;
|
|
484
|
+
#ye = !1;
|
|
485
|
+
#be = null;
|
|
486
|
+
#xe = null;
|
|
487
|
+
#Se = null;
|
|
488
|
+
#Ce = null;
|
|
489
|
+
#we = null;
|
|
490
|
+
#Te = null;
|
|
491
|
+
#Ee = -Infinity;
|
|
492
|
+
#De = null;
|
|
493
|
+
#Oe = null;
|
|
494
|
+
#ke = /* @__PURE__ */ new Set();
|
|
495
|
+
#Ae;
|
|
496
|
+
#je = null;
|
|
497
|
+
#Me;
|
|
498
|
+
#Ne = null;
|
|
499
|
+
#Pe;
|
|
500
|
+
#Fe;
|
|
501
|
+
#Ie = null;
|
|
502
|
+
#Le = null;
|
|
503
|
+
#Re = "download";
|
|
504
|
+
#ze = 1;
|
|
505
|
+
#Be = 0;
|
|
506
|
+
#Ve = null;
|
|
507
|
+
#He;
|
|
481
508
|
debug = { setFlipProgress: (e, t) => {
|
|
482
|
-
this.#
|
|
509
|
+
this.#ae?.setFlipProgress(e, t);
|
|
483
510
|
} };
|
|
484
511
|
constructor(e, t) {
|
|
485
|
-
|
|
512
|
+
ue(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = re(t.source, {
|
|
486
513
|
frontCover: t.frontCover,
|
|
487
514
|
backCover: t.backCover,
|
|
488
515
|
pages: t.pages
|
|
489
516
|
});
|
|
490
517
|
let n = t.direction ?? "ltr";
|
|
491
|
-
this.#a = n, this.#
|
|
492
|
-
let r = t.
|
|
518
|
+
this.#a = n, this.#V = (t.deepLink ?? !0) && b(), this.#H = 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.#f = t.cursorHints ?? !0;
|
|
519
|
+
let r = t.hints ?? !0;
|
|
520
|
+
this.#h = r === !0 || r !== !1 && (r.enabled ?? !0), this.#g = r !== !0 && r !== !1 && (r.persist ?? !1), this.#g && this.#yt();
|
|
521
|
+
let i = t.sound ?? !1;
|
|
522
|
+
this.#_ = i !== !1, this.#v = i === !0 || i === !1 ? {} : i, this.#b = typeof i == "object" && i ? i.muted ?? !1 : !1, this.#x = typeof i == "object" && i ? i.persist ?? !1 : !1, this.#_ && this.#x && this.#Ye(), this.#P = t.singlePageThreshold ?? 640, this.#R = t.responsiveSpread ?? !0, this.#Ae = t.controls ?? !0, this.#Me = t.contextMenu ?? !t.disableContextMenu, this.#Pe = new Set(t.hideControls ?? []), this.#Fe = t.loading ?? !0, this.#B = t.startPage, typeof this.#t.open != "function" && this.#wn(), this.#Y = t.flipDuration ?? 800, this.#X = t.zoom?.enabled ?? !0, this.#Z = t.zoom?.wheel ?? !0;
|
|
523
|
+
let a = t.zoom?.doubleClick, o = a === !1 ? [] : [...a ?? [
|
|
493
524
|
1,
|
|
494
525
|
2,
|
|
495
526
|
4
|
|
496
527
|
]].sort((e, t) => e - t);
|
|
497
|
-
this.#
|
|
498
|
-
let
|
|
499
|
-
this.#
|
|
528
|
+
this.#Q = o.length > 0 ? o : null, this.#$ = t.zoom?.max ?? 4;
|
|
529
|
+
let s = this.#X && this.#Q !== null, c = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
|
|
530
|
+
this.#M = this.#u !== "off" && s && c && t.clickFlipDelay !== 0, this.#N = this.#M ? t.clickFlipDelay ?? M : 0, this.#He = this.#Ut(t.renderer ?? "auto");
|
|
500
531
|
}
|
|
501
532
|
get ready() {
|
|
502
|
-
return this.#
|
|
533
|
+
return this.#He;
|
|
503
534
|
}
|
|
504
535
|
getPageCount() {
|
|
505
536
|
return this.#t.pageCount;
|
|
506
537
|
}
|
|
507
538
|
getPage() {
|
|
508
|
-
return this.#
|
|
539
|
+
return this.#q;
|
|
509
540
|
}
|
|
510
541
|
get container() {
|
|
511
542
|
return this.#e;
|
|
512
543
|
}
|
|
513
544
|
getPageBox() {
|
|
514
|
-
return this.#
|
|
545
|
+
return this.#ae?.measure().book ?? null;
|
|
515
546
|
}
|
|
516
547
|
getSpreads() {
|
|
517
|
-
return this.#
|
|
548
|
+
return this.#G;
|
|
518
549
|
}
|
|
519
550
|
getSpreadIndex() {
|
|
520
|
-
return this.#
|
|
551
|
+
return this.#K;
|
|
521
552
|
}
|
|
522
553
|
getDirection() {
|
|
523
554
|
return this.#a;
|
|
@@ -526,44 +557,44 @@ var J = class {
|
|
|
526
557
|
return this.#o;
|
|
527
558
|
}
|
|
528
559
|
isSinglePage() {
|
|
529
|
-
return this.#
|
|
560
|
+
return this.#F;
|
|
530
561
|
}
|
|
531
562
|
setSpreadMode(e) {
|
|
532
|
-
e !== this.#o && (this.#o = e, this.#
|
|
563
|
+
e !== this.#o && (this.#o = e, this.#L = !1, this.#cn(), this.#ln());
|
|
533
564
|
}
|
|
534
565
|
toggleSpreadMode() {
|
|
535
566
|
this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
|
|
536
567
|
}
|
|
537
568
|
getResponsiveSpread() {
|
|
538
|
-
return this.#
|
|
569
|
+
return this.#R;
|
|
539
570
|
}
|
|
540
571
|
isResponsiveSingle() {
|
|
541
|
-
return this.#
|
|
572
|
+
return this.#L && this.#o !== "single";
|
|
542
573
|
}
|
|
543
574
|
setResponsiveSpread(e) {
|
|
544
|
-
if (e !== this.#
|
|
545
|
-
if (this.#
|
|
546
|
-
let e = this.#
|
|
575
|
+
if (e !== this.#R) {
|
|
576
|
+
if (this.#R = e, e) {
|
|
577
|
+
let e = this.#ae?.measure().containerWidth;
|
|
547
578
|
if (e === void 0) return;
|
|
548
|
-
this.#
|
|
579
|
+
this.#L = !1, this.#sn(e);
|
|
549
580
|
} else {
|
|
550
|
-
if (!this.#
|
|
551
|
-
this.#
|
|
581
|
+
if (!this.#L) return;
|
|
582
|
+
this.#L = !1, this.#cn();
|
|
552
583
|
}
|
|
553
|
-
this.#
|
|
584
|
+
this.#ln();
|
|
554
585
|
}
|
|
555
586
|
}
|
|
556
587
|
getPageImage(e) {
|
|
557
|
-
return this.#
|
|
588
|
+
return this.#xn(e);
|
|
558
589
|
}
|
|
559
590
|
canFlipNext() {
|
|
560
|
-
return this.#
|
|
591
|
+
return this.#K + 1 < this.#G.length;
|
|
561
592
|
}
|
|
562
593
|
canFlipPrev() {
|
|
563
|
-
return this.#
|
|
594
|
+
return this.#K > 0;
|
|
564
595
|
}
|
|
565
596
|
getMaxZoom() {
|
|
566
|
-
return this
|
|
597
|
+
return this.#$;
|
|
567
598
|
}
|
|
568
599
|
canSearch() {
|
|
569
600
|
return typeof this.#t.getText == "function";
|
|
@@ -580,7 +611,7 @@ var J = class {
|
|
|
580
611
|
async print() {
|
|
581
612
|
let e = await this.getSourceFile(), t = this.#e.ownerDocument;
|
|
582
613
|
if (!e || !t) return !1;
|
|
583
|
-
let { url: n, revoke: r } = await this.#
|
|
614
|
+
let { url: n, revoke: r } = await this.#Ue(e, t), i = t.createElement("iframe");
|
|
584
615
|
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
616
|
let a = !1, o = (t) => {
|
|
586
617
|
a || (a = !0, setTimeout(() => {
|
|
@@ -602,11 +633,11 @@ var J = class {
|
|
|
602
633
|
return typeof this.#t.getOutline == "function";
|
|
603
634
|
}
|
|
604
635
|
getOutline() {
|
|
605
|
-
if (!this.#
|
|
636
|
+
if (!this.#Oe) {
|
|
606
637
|
let e = this.#t.getOutline;
|
|
607
|
-
this.#
|
|
638
|
+
this.#Oe = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
|
|
608
639
|
}
|
|
609
|
-
return this.#
|
|
640
|
+
return this.#Oe;
|
|
610
641
|
}
|
|
611
642
|
async getSourceFile() {
|
|
612
643
|
let e = this.#t.getDownload;
|
|
@@ -617,11 +648,11 @@ var J = class {
|
|
|
617
648
|
if (!e) return !1;
|
|
618
649
|
let t = this.#e.ownerDocument;
|
|
619
650
|
if (!t) return !1;
|
|
620
|
-
let { url: n, revoke: r } = await this.#
|
|
651
|
+
let { url: n, revoke: r } = await this.#Ue(e, t), i = t.createElement("a");
|
|
621
652
|
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
653
|
}
|
|
623
|
-
async #
|
|
624
|
-
if (e.revoke || !this.#
|
|
654
|
+
async #Ue(e, t) {
|
|
655
|
+
if (e.revoke || !this.#We(e.url, t)) return {
|
|
625
656
|
url: e.url,
|
|
626
657
|
revoke: e.revoke ?? !1
|
|
627
658
|
};
|
|
@@ -638,7 +669,7 @@ var J = class {
|
|
|
638
669
|
};
|
|
639
670
|
}
|
|
640
671
|
}
|
|
641
|
-
#
|
|
672
|
+
#We(e, t) {
|
|
642
673
|
let n = t.defaultView?.location?.href;
|
|
643
674
|
if (!n) return !1;
|
|
644
675
|
try {
|
|
@@ -665,97 +696,118 @@ var J = class {
|
|
|
665
696
|
let i = t.toLowerCase().indexOf(r);
|
|
666
697
|
i < 0 || a.push({
|
|
667
698
|
page: e,
|
|
668
|
-
excerpt:
|
|
699
|
+
excerpt: se(t, i, r.length)
|
|
669
700
|
});
|
|
670
701
|
}
|
|
671
702
|
return a;
|
|
672
703
|
}
|
|
673
704
|
flipNext() {
|
|
674
|
-
this.#
|
|
705
|
+
this.#Ge(1);
|
|
675
706
|
}
|
|
676
707
|
flipPrev() {
|
|
677
|
-
this.#
|
|
708
|
+
this.#Ge(-1);
|
|
678
709
|
}
|
|
679
|
-
#
|
|
680
|
-
this.#
|
|
710
|
+
#Ge(e) {
|
|
711
|
+
this.#Ke(() => this.#$e(this.#K + e));
|
|
681
712
|
}
|
|
682
713
|
flipTo(e) {
|
|
683
|
-
let t =
|
|
684
|
-
this.#
|
|
714
|
+
let t = X(e, 0, Math.max(0, this.#t.pageCount - 1));
|
|
715
|
+
this.#Ke(() => this.#$e(this.#Cn(t)));
|
|
685
716
|
}
|
|
686
|
-
#
|
|
687
|
-
this.#i.state === "idle" ? e() : this.#
|
|
717
|
+
#Ke(e) {
|
|
718
|
+
this.#i.state === "idle" ? e() : this.#me ? (this.#pe = null, this.#qe(), e()) : this.#pe = e;
|
|
688
719
|
}
|
|
689
|
-
#
|
|
690
|
-
let e = this.#
|
|
691
|
-
e && (this.#
|
|
720
|
+
#qe() {
|
|
721
|
+
let e = this.#me;
|
|
722
|
+
e && (this.#me = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#ae?.setFlipProgress(e.toT, e.direction), e.onDone());
|
|
692
723
|
}
|
|
693
|
-
#
|
|
694
|
-
let e = this.#
|
|
724
|
+
#Je() {
|
|
725
|
+
let e = this.#pe;
|
|
695
726
|
if (!e) {
|
|
696
|
-
this.#
|
|
727
|
+
this.#_n();
|
|
697
728
|
return;
|
|
698
729
|
}
|
|
699
|
-
this.#
|
|
730
|
+
this.#pe = null, e();
|
|
700
731
|
}
|
|
701
732
|
getZoom() {
|
|
702
|
-
return this.#
|
|
733
|
+
return this.#ne;
|
|
703
734
|
}
|
|
704
735
|
setZoom(e, t) {
|
|
705
|
-
if (!this.#
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
736
|
+
if (!this.#ae || !this.#X) return;
|
|
737
|
+
this.#wt(), this.#Dt();
|
|
738
|
+
let n = X(e, 1, this.#$), r = this.#ae.measure(), i = r.screenAt?.(this.#ne), a = t ?? (i ? {
|
|
739
|
+
x: i.x + this.#re + i.width / 2,
|
|
740
|
+
y: i.y + this.#ie + i.height / 2
|
|
709
741
|
} : null) ?? {
|
|
710
742
|
x: r.containerWidth / 2,
|
|
711
743
|
y: r.containerHeight / 2
|
|
712
|
-
}, o = this.#
|
|
713
|
-
[s, c] = this.#
|
|
744
|
+
}, o = this.#ne, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#re), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#ie);
|
|
745
|
+
[s, c] = this.#Qe(s, c, n, r.containerWidth, r.containerHeight), this.#ne = n, this.#re = s, this.#ie = c, this.#ae.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Ze(), this.#pn(), this.#_t(), o <= 1 && n > 1 && (this.#bt("zoom"), this.#Ot()), this.#n.emit("zoomChanged", { scale: n });
|
|
714
746
|
}
|
|
715
747
|
resetZoom() {
|
|
716
748
|
this.setZoom(1);
|
|
717
749
|
}
|
|
718
|
-
|
|
719
|
-
|
|
750
|
+
isSoundEnabled() {
|
|
751
|
+
return this.#_;
|
|
752
|
+
}
|
|
753
|
+
isSoundMuted() {
|
|
754
|
+
return this.#_ && this.#b;
|
|
755
|
+
}
|
|
756
|
+
setSoundMuted(e) {
|
|
757
|
+
this.#_ && (this.#b = e, this.#y?.setMuted(e), this.#x && this.#Xe(e), e || this.#Wt());
|
|
720
758
|
}
|
|
721
|
-
#
|
|
722
|
-
|
|
759
|
+
#Ye() {
|
|
760
|
+
try {
|
|
761
|
+
let e = localStorage.getItem(Y);
|
|
762
|
+
(e === "true" || e === "false") && (this.#b = e === "true");
|
|
763
|
+
} catch {}
|
|
764
|
+
}
|
|
765
|
+
#Xe(e) {
|
|
766
|
+
try {
|
|
767
|
+
localStorage.setItem(Y, String(e));
|
|
768
|
+
} catch {}
|
|
769
|
+
}
|
|
770
|
+
#Ze() {
|
|
771
|
+
this.#e.style.touchAction = this.#ne > 1 ? "none" : "pan-y";
|
|
772
|
+
}
|
|
773
|
+
#Qe(e, t, n, r, i) {
|
|
774
|
+
let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#ae?.measure().screenAt?.(n) ?? {
|
|
723
775
|
x: 0,
|
|
724
776
|
y: 0,
|
|
725
777
|
width: r * n,
|
|
726
778
|
height: i * n
|
|
727
|
-
}, [c, l] =
|
|
728
|
-
return [o(
|
|
779
|
+
}, [c, l] = Z(s.x, s.width, r), [u, d] = Z(s.y, s.height, i);
|
|
780
|
+
return [o(X(e, c, l)), o(X(t, u, d))];
|
|
729
781
|
}
|
|
730
782
|
on(e, t) {
|
|
731
783
|
return this.#n.on(e, t);
|
|
732
784
|
}
|
|
733
785
|
destroy() {
|
|
734
|
-
this.#
|
|
786
|
+
this.#se = !0, this.#ce !== null && cancelAnimationFrame(this.#ce), this.#me = null, this.#pe = null, this.#Pt(), this.#St(), this.#wt(), this.#Dt(), this.#Nt(), this.#At(), this.#y?.destroy(), this.#y = null, this.#ee?.disconnect(), this.#U?.stop(), this.#U = null, this.#W?.(), this.#V && x(), this.#je?.(), this.#Ne?.(), this.#Yt(), this.#De?.(), this.#Se?.(), this.#we?.(), this.#Ce?.(), this.#m?.(), this.#xe?.(), this.#Ve !== null && clearTimeout(this.#Ve), this.#Be++, this.#ae?.destroy(), this.#ae = null, this.#t.destroy(), this.#n.clear();
|
|
735
787
|
}
|
|
736
|
-
|
|
737
|
-
if (e < 0 || e >= this.#
|
|
738
|
-
let t = e > this.#
|
|
788
|
+
#$e(e) {
|
|
789
|
+
if (e < 0 || e >= this.#G.length || e === this.#K || (this.#wt(), this.#Dt(), this.#i.send("flip") === null)) return;
|
|
790
|
+
let t = e > this.#K ? "forward" : "backward", n = this.#it(e);
|
|
739
791
|
this.#n.emit("flipStart", {
|
|
740
|
-
from: this.#
|
|
792
|
+
from: this.#q,
|
|
741
793
|
to: n
|
|
742
|
-
}), this.#
|
|
794
|
+
}), this.#Gt(), this.#et(e, t, n, ++this.#he);
|
|
743
795
|
}
|
|
744
|
-
async #
|
|
745
|
-
let i = this.#
|
|
796
|
+
async #et(e, t, n, r) {
|
|
797
|
+
let i = this.#G[e], a = i ? await this.#bn(i) : {
|
|
746
798
|
left: null,
|
|
747
799
|
right: null
|
|
748
800
|
};
|
|
749
|
-
r === this.#
|
|
750
|
-
fill: this.#
|
|
751
|
-
curl: this.#
|
|
801
|
+
r === this.#he && (this.#ae?.beginFlip(this.#J, a, t, {
|
|
802
|
+
fill: this.#F,
|
|
803
|
+
curl: this.#an(),
|
|
752
804
|
anchor: { y: this.#l }
|
|
753
|
-
}), this.#
|
|
805
|
+
}), this.#tt(0, 1, t, () => this.#rt(e, n, a), () => this.#nt(n)));
|
|
754
806
|
}
|
|
755
|
-
#
|
|
756
|
-
let a = this.#
|
|
807
|
+
#tt(e, t, n, r, i) {
|
|
808
|
+
let a = this.#in() * Math.abs(t - e);
|
|
757
809
|
if (a <= 0) {
|
|
758
|
-
this.#
|
|
810
|
+
this.#ae?.setFlipProgress(t, n), r();
|
|
759
811
|
return;
|
|
760
812
|
}
|
|
761
813
|
let o = {
|
|
@@ -763,60 +815,60 @@ var J = class {
|
|
|
763
815
|
direction: n,
|
|
764
816
|
onDone: r
|
|
765
817
|
};
|
|
766
|
-
this.#
|
|
818
|
+
this.#me = o;
|
|
767
819
|
let s = performance.now(), c = !1, l = (u) => {
|
|
768
|
-
if (this.#
|
|
769
|
-
let d = Math.min(1, (u - s) / a), f =
|
|
770
|
-
i && !c && f >= (this.#
|
|
820
|
+
if (this.#me !== o) return;
|
|
821
|
+
let d = Math.min(1, (u - s) / a), f = le(d);
|
|
822
|
+
i && !c && f >= (this.#F ? H : V) && (c = !0, i()), d < 1 ? (this.#ae?.setFlipProgress(e + (t - e) * f, n), this.#ce = requestAnimationFrame(l)) : (this.#ae?.setFlipProgress(t, n), this.#ce = null, this.#me = null, r());
|
|
771
823
|
};
|
|
772
|
-
this.#
|
|
824
|
+
this.#ce = requestAnimationFrame(l);
|
|
773
825
|
}
|
|
774
|
-
#
|
|
775
|
-
this.#
|
|
826
|
+
#nt(e) {
|
|
827
|
+
this.#q !== e && (this.#q = e, this.#rn(), this.#n.emit("pageChanged", { page: e }));
|
|
776
828
|
}
|
|
777
|
-
#
|
|
778
|
-
let r = this.#
|
|
779
|
-
this.#
|
|
829
|
+
#rt(e, t, n) {
|
|
830
|
+
let r = this.#G[e];
|
|
831
|
+
this.#K = e, this.#J = n, r && this.#un(r, n), this.#Sn(), this.#i.send("settle"), this.#Ee = performance.now(), this.#nt(t), this.#bt("turn"), this.#_t(), this.#n.emit("flipEnd", { page: t }), this.#Je();
|
|
780
832
|
}
|
|
781
|
-
#
|
|
782
|
-
let t = this.#
|
|
783
|
-
if (!t) return this.#
|
|
833
|
+
#it(e) {
|
|
834
|
+
let t = this.#G[e];
|
|
835
|
+
if (!t) return this.#q;
|
|
784
836
|
let n = [t.left, t.right].filter((e) => e !== null);
|
|
785
|
-
return n.length > 0 ? Math.min(...n) : this.#
|
|
837
|
+
return n.length > 0 ? Math.min(...n) : this.#q;
|
|
786
838
|
}
|
|
787
|
-
#
|
|
788
|
-
if (this.#
|
|
789
|
-
if (this.#
|
|
839
|
+
#at(e, t) {
|
|
840
|
+
if (this.#_e || !this.#ae) return;
|
|
841
|
+
if (this.#Dt(), this.#Pt(), this.#ne > 1) {
|
|
790
842
|
if (this.#i.send("panStart") === null) return;
|
|
791
|
-
this.#
|
|
792
|
-
baseTx: this.#
|
|
793
|
-
baseTy: this.#
|
|
843
|
+
this.#ge = {
|
|
844
|
+
baseTx: this.#re,
|
|
845
|
+
baseTy: this.#ie
|
|
794
846
|
};
|
|
795
847
|
return;
|
|
796
848
|
}
|
|
797
|
-
let n = this.#
|
|
798
|
-
this.#
|
|
799
|
-
let i = Math.min(n.width, n.height) *
|
|
849
|
+
let n = this.#ft(), r = this.#pt(e, t);
|
|
850
|
+
this.#de = r;
|
|
851
|
+
let i = Math.min(n.width, n.height) * k, 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;
|
|
800
852
|
if (this.#i.state !== "idle") {
|
|
801
|
-
if (!this.#
|
|
802
|
-
this.#
|
|
853
|
+
if (!this.#me || !s) {
|
|
854
|
+
this.#ue = null;
|
|
803
855
|
return;
|
|
804
856
|
}
|
|
805
|
-
this.#
|
|
857
|
+
this.#qe();
|
|
806
858
|
}
|
|
807
859
|
if (!s) return;
|
|
808
|
-
this.#l =
|
|
809
|
-
let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#
|
|
810
|
-
u < 0 || u >= this.#
|
|
860
|
+
this.#l = X(r.y / n.height, 0, 1);
|
|
861
|
+
let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#K + (l ? 1 : -1);
|
|
862
|
+
u < 0 || u >= this.#G.length || (this.#ue = {
|
|
811
863
|
direction: l ? "forward" : "backward",
|
|
812
864
|
targetIndex: u,
|
|
813
|
-
toPage: this.#
|
|
865
|
+
toPage: this.#it(u),
|
|
814
866
|
width: n.width
|
|
815
867
|
});
|
|
816
868
|
}
|
|
817
|
-
#
|
|
818
|
-
let e = this.#
|
|
819
|
-
e && (this.#
|
|
869
|
+
#ot() {
|
|
870
|
+
let e = this.#ue;
|
|
871
|
+
e && (this.#ue = null, this.#i.send("grab") !== null && (this.#le = {
|
|
820
872
|
direction: e.direction,
|
|
821
873
|
targetIndex: e.targetIndex,
|
|
822
874
|
toPage: e.toPage,
|
|
@@ -827,71 +879,75 @@ var J = class {
|
|
|
827
879
|
width: e.width,
|
|
828
880
|
t: 0
|
|
829
881
|
}, this.#n.emit("flipStart", {
|
|
830
|
-
from: this.#
|
|
882
|
+
from: this.#q,
|
|
831
883
|
to: e.toPage
|
|
832
|
-
}), this.#
|
|
884
|
+
}), this.#st(e.targetIndex, e.direction)));
|
|
833
885
|
}
|
|
834
|
-
async #
|
|
835
|
-
let n = this.#
|
|
886
|
+
async #st(e, t) {
|
|
887
|
+
let n = this.#G[e], r = n ? await this.#bn(n) : {
|
|
836
888
|
left: null,
|
|
837
889
|
right: null
|
|
838
890
|
};
|
|
839
|
-
this.#
|
|
840
|
-
fill: this.#
|
|
841
|
-
curl: this.#
|
|
891
|
+
this.#le?.targetIndex === e && (this.#le.toContent = r, this.#ae?.beginFlip(this.#J, r, t, {
|
|
892
|
+
fill: this.#F,
|
|
893
|
+
curl: this.#an(),
|
|
842
894
|
anchor: { y: this.#l }
|
|
843
|
-
}), this.#
|
|
844
|
-
}
|
|
845
|
-
#
|
|
846
|
-
if (this.#
|
|
847
|
-
if (this.#
|
|
848
|
-
if (!this.#
|
|
849
|
-
let n = this.#
|
|
850
|
-
this.#
|
|
895
|
+
}), this.#ae?.setFlipProgress(this.#le.t, t));
|
|
896
|
+
}
|
|
897
|
+
#ct(e, t) {
|
|
898
|
+
if (this.#_e) return;
|
|
899
|
+
if (this.#ge) {
|
|
900
|
+
if (!this.#ae) return;
|
|
901
|
+
let n = this.#ae.measure(), [r, i] = this.#Qe(this.#ge.baseTx + e, this.#ge.baseTy + t, this.#ne, n.containerWidth, n.containerHeight);
|
|
902
|
+
this.#re = r, this.#ie = i, this.#ae.setViewTransform(this.#ne, r, i), this.#pn(), this.#bt("pan"), this.#At();
|
|
851
903
|
return;
|
|
852
904
|
}
|
|
853
|
-
this.#
|
|
854
|
-
let n = this.#
|
|
855
|
-
n && (n.t =
|
|
856
|
-
}
|
|
857
|
-
#
|
|
858
|
-
if (this.#
|
|
859
|
-
if (this.#
|
|
860
|
-
this.#
|
|
905
|
+
this.#ue && Math.hypot(e, t) > j && this.#ot();
|
|
906
|
+
let n = this.#le;
|
|
907
|
+
n && (n.t = X((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#ae?.setFlipProgress(n.t, n.direction));
|
|
908
|
+
}
|
|
909
|
+
#lt(e) {
|
|
910
|
+
if (this.#_e) return;
|
|
911
|
+
if (this.#ge) {
|
|
912
|
+
this.#ge = null, this.#i.send("panEnd"), this.#_t();
|
|
861
913
|
return;
|
|
862
914
|
}
|
|
863
|
-
let t = this.#
|
|
915
|
+
let t = this.#le;
|
|
864
916
|
if (!t) {
|
|
865
|
-
this.#
|
|
917
|
+
this.#ue = null, this.#ut(e) || this.#dt(e);
|
|
866
918
|
return;
|
|
867
919
|
}
|
|
868
|
-
this.#
|
|
920
|
+
this.#le = null, this.#i.send("release");
|
|
869
921
|
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;
|
|
870
|
-
i || t.t >= .5 && !a ? this.#
|
|
922
|
+
i || t.t >= .5 && !a ? (this.#Gt(), this.#tt(t.t, 1, t.direction, () => this.#rt(t.targetIndex, t.toPage, t.toContent), () => this.#nt(t.toPage))) : this.#tt(t.t, 0, t.direction, () => this.#Ft());
|
|
871
923
|
}
|
|
872
|
-
#
|
|
873
|
-
if (this.#
|
|
924
|
+
#ut(e) {
|
|
925
|
+
if (this.#ne > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
|
|
874
926
|
let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
|
|
875
|
-
if (!this.#
|
|
927
|
+
if (!this.#ht(n)) return this.#Et(n), !1;
|
|
876
928
|
let r = t ? 1 : -1;
|
|
877
|
-
return this.#
|
|
878
|
-
}
|
|
879
|
-
#
|
|
880
|
-
if (this.#u === "off" || this.#
|
|
881
|
-
let t = this.#
|
|
882
|
-
if (!t
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
if (this.#Ge(), this.#p <= 0) {
|
|
886
|
-
this.#Ce(r);
|
|
929
|
+
return this.#Ke(() => this.#$e(this.#K + r)), !0;
|
|
930
|
+
}
|
|
931
|
+
#dt(e) {
|
|
932
|
+
if (this.#u === "off" || this.#ne > 1 || !this.#de || Math.abs(e.dx) > j || Math.abs(e.dy) > j) return;
|
|
933
|
+
let t = this.#mt(this.#de);
|
|
934
|
+
if (!t) return;
|
|
935
|
+
if (!this.#ht(t)) {
|
|
936
|
+
this.#Et(t);
|
|
887
937
|
return;
|
|
888
938
|
}
|
|
889
|
-
this.#
|
|
890
|
-
|
|
891
|
-
|
|
939
|
+
this.#l = X(this.#de.y / this.#ft().height, 0, 1);
|
|
940
|
+
let n = t === "forward" ? 1 : -1, r = () => this.#$e(this.#K + n);
|
|
941
|
+
if (this.#Pt(), this.#N <= 0) {
|
|
942
|
+
this.#Ke(r);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
this.#fe = setTimeout(() => {
|
|
946
|
+
this.#fe = null, this.#Ke(r);
|
|
947
|
+
}, this.#N);
|
|
892
948
|
}
|
|
893
|
-
#
|
|
894
|
-
let e = this.#
|
|
949
|
+
#ft() {
|
|
950
|
+
let e = this.#ae.measure();
|
|
895
951
|
return e.content ?? e.book ?? {
|
|
896
952
|
x: 0,
|
|
897
953
|
y: 0,
|
|
@@ -899,213 +955,364 @@ var J = class {
|
|
|
899
955
|
height: e.containerHeight
|
|
900
956
|
};
|
|
901
957
|
}
|
|
902
|
-
#
|
|
903
|
-
let n = this.#e.getBoundingClientRect(), r = this.#
|
|
958
|
+
#pt(e, t) {
|
|
959
|
+
let n = this.#e.getBoundingClientRect(), r = this.#ft();
|
|
904
960
|
return {
|
|
905
961
|
x: e - n.left - r.x,
|
|
906
962
|
y: t - n.top - r.y
|
|
907
963
|
};
|
|
908
964
|
}
|
|
909
|
-
#
|
|
910
|
-
if (!this.#
|
|
911
|
-
let t = this.#
|
|
965
|
+
#mt(e) {
|
|
966
|
+
if (!this.#ae) return null;
|
|
967
|
+
let t = this.#ft().width, n;
|
|
912
968
|
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;
|
|
913
969
|
let r = this.#a === "rtl" ? "left" : "right";
|
|
914
970
|
return n === r ? "forward" : "backward";
|
|
915
971
|
}
|
|
916
|
-
#
|
|
917
|
-
let t = this.#
|
|
918
|
-
return t >= 0 && t < this.#
|
|
972
|
+
#ht(e) {
|
|
973
|
+
let t = this.#K + (e === "forward" ? 1 : -1);
|
|
974
|
+
return t >= 0 && t < this.#G.length;
|
|
919
975
|
}
|
|
920
|
-
#
|
|
921
|
-
|
|
976
|
+
#gt() {
|
|
977
|
+
let e = (e) => {
|
|
978
|
+
let t = e;
|
|
979
|
+
this.#p = {
|
|
980
|
+
x: t.clientX,
|
|
981
|
+
y: t.clientY
|
|
982
|
+
}, this.#_t();
|
|
983
|
+
}, t = () => {
|
|
984
|
+
this.#p = null, this.#_t();
|
|
985
|
+
};
|
|
986
|
+
this.#e.addEventListener("pointermove", e), this.#e.addEventListener("pointerleave", t), this.#m = () => {
|
|
987
|
+
this.#e.removeEventListener("pointermove", e), this.#e.removeEventListener("pointerleave", t);
|
|
988
|
+
};
|
|
922
989
|
}
|
|
923
|
-
#
|
|
924
|
-
|
|
925
|
-
|
|
990
|
+
#_t() {
|
|
991
|
+
if (!this.#f || !this.#ae) return;
|
|
992
|
+
let e = "";
|
|
993
|
+
this.#le || this.#ge ? e = "grabbing" : this.#p && (e = this.#vt(this.#p.x, this.#p.y)), this.#e.style.cursor = e;
|
|
994
|
+
}
|
|
995
|
+
#vt(e, t) {
|
|
996
|
+
if (!this.#ae) return "";
|
|
997
|
+
let n = this.#ft(), r = this.#pt(e, t);
|
|
998
|
+
if (r.x < 0 || r.y < 0 || r.x > n.width || r.y > n.height) return "";
|
|
999
|
+
if (this.#ne > 1) return "grab";
|
|
1000
|
+
let i = this.#mt(r);
|
|
1001
|
+
return i && this.#ht(i) ? "pointer" : this.#X && this.#Q !== null ? "zoom-in" : "";
|
|
1002
|
+
}
|
|
1003
|
+
#yt() {
|
|
1004
|
+
try {
|
|
1005
|
+
let e = localStorage.getItem(J);
|
|
1006
|
+
if (!e) return;
|
|
1007
|
+
let t = JSON.parse(e);
|
|
1008
|
+
this.#C = {
|
|
1009
|
+
turn: t.turn === !0,
|
|
1010
|
+
zoom: t.zoom === !0,
|
|
1011
|
+
pan: t.pan === !0
|
|
1012
|
+
};
|
|
1013
|
+
} catch {}
|
|
926
1014
|
}
|
|
927
|
-
#
|
|
928
|
-
if (this.#
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
this.#
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1015
|
+
#bt(e) {
|
|
1016
|
+
if (!this.#C[e] && (this.#C[e] = !0, e === "turn" && this.#St(), e === "zoom" && this.#Nt(), this.#g)) try {
|
|
1017
|
+
localStorage.setItem(J, JSON.stringify(this.#C));
|
|
1018
|
+
} catch {}
|
|
1019
|
+
}
|
|
1020
|
+
#xt() {
|
|
1021
|
+
!this.#h || this.#ye || this.#C.turn || (this.#St(), this.#w = setTimeout(() => {
|
|
1022
|
+
this.#w = null, this.#Ct();
|
|
1023
|
+
}, K));
|
|
1024
|
+
}
|
|
1025
|
+
#St() {
|
|
1026
|
+
this.#w !== null && (clearTimeout(this.#w), this.#w = null);
|
|
1027
|
+
}
|
|
1028
|
+
async #Ct() {
|
|
1029
|
+
if (!this.#h || this.#ye || this.#C.turn || !this.#ae || typeof requestAnimationFrame != "function" || this.#i.state !== "idle") return;
|
|
1030
|
+
let e = this.#K + 1, t = this.#G[e];
|
|
1031
|
+
if (!t) return;
|
|
1032
|
+
let n = await this.#bn(t);
|
|
1033
|
+
if (this.#se || this.#C.turn || this.#i.state !== "idle" || this.#T) return;
|
|
1034
|
+
this.#l = 1, this.#ae.beginFlip(this.#J, n, "forward", {
|
|
1035
|
+
fill: this.#F,
|
|
1036
|
+
curl: this.#an(),
|
|
1037
|
+
anchor: { y: this.#l }
|
|
1038
|
+
});
|
|
1039
|
+
let r = {};
|
|
1040
|
+
this.#T = r;
|
|
1041
|
+
let i = performance.now(), a = oe * 2, o = () => {
|
|
1042
|
+
if (this.#T !== r) return;
|
|
1043
|
+
let e = Math.min(1, (performance.now() - i) / a), t = U * Math.sin(e * Math.PI);
|
|
1044
|
+
this.#ae?.setFlipProgress(Math.max(0, t), "forward"), e < 1 ? this.#ce = requestAnimationFrame(o) : (this.#ce = null, this.#T = null, this.#Tt());
|
|
1045
|
+
};
|
|
1046
|
+
this.#ce = requestAnimationFrame(o);
|
|
1047
|
+
}
|
|
1048
|
+
#wt() {
|
|
1049
|
+
this.#T && (this.#T = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#Tt());
|
|
1050
|
+
}
|
|
1051
|
+
#Tt() {
|
|
1052
|
+
let e = this.#G[this.#K];
|
|
1053
|
+
e && this.#i.state === "idle" && this.#un(e, this.#J);
|
|
1054
|
+
}
|
|
1055
|
+
#Et(e) {
|
|
1056
|
+
if (!this.#ae || typeof requestAnimationFrame != "function" || this.#ye || this.#i.state !== "idle" || this.#ne > 1 || this.#E) return;
|
|
1057
|
+
let t = e === "forward", n = (this.#a === "rtl" ? !t : t) ? -1 : 1, r = {};
|
|
1058
|
+
this.#E = r;
|
|
1059
|
+
let i = performance.now(), a = () => {
|
|
1060
|
+
if (this.#E !== r) return;
|
|
1061
|
+
let e = Math.min(1, (performance.now() - i) / G), t = W * Math.sin(e * Math.PI);
|
|
1062
|
+
this.#ae?.setViewTransform(1, n * t, 0), e < 1 ? this.#ce = requestAnimationFrame(a) : (this.#ce = null, this.#E = null, this.#ae?.setViewTransform(1, 0, 0));
|
|
1063
|
+
};
|
|
1064
|
+
this.#ce = requestAnimationFrame(a);
|
|
1065
|
+
}
|
|
1066
|
+
#Dt() {
|
|
1067
|
+
this.#E && (this.#E = null, this.#ce !== null && (cancelAnimationFrame(this.#ce), this.#ce = null), this.#ae?.setViewTransform(1, 0, 0));
|
|
1068
|
+
}
|
|
1069
|
+
#Ot() {
|
|
1070
|
+
this.#C.pan || this.#kt("Drag to move");
|
|
1071
|
+
}
|
|
1072
|
+
#kt(e) {
|
|
1073
|
+
if (!this.#h) return;
|
|
1074
|
+
let t = this.#e.ownerDocument;
|
|
1075
|
+
if (!t || typeof this.#e.appendChild != "function") return;
|
|
1076
|
+
this.#At();
|
|
1077
|
+
let n = t.createElement("div");
|
|
1078
|
+
n.className = "zine-hint-caption", n.setAttribute("aria-hidden", "true"), n.textContent = e, n.style.cssText = "position:absolute;left:50%;bottom:16px;transform:translateX(-50%);z-index:3;pointer-events:none;padding:6px 12px;border-radius:999px;font:500 13px/1.2 system-ui,sans-serif;color:#fff;background:rgba(24,24,27,0.82);box-shadow:0 1px 4px rgba(0,0,0,0.35);white-space:nowrap;opacity:0;";
|
|
1079
|
+
let r = !this.#ye && typeof requestAnimationFrame == "function";
|
|
1080
|
+
r && (n.style.transition = "opacity 200ms ease"), this.#e.appendChild(n), this.#D = n, r ? requestAnimationFrame(() => {
|
|
1081
|
+
this.#D === n && (n.style.opacity = "1");
|
|
1082
|
+
}) : n.style.opacity = "1", this.#O = setTimeout(() => this.#At(), q);
|
|
1083
|
+
}
|
|
1084
|
+
#At() {
|
|
1085
|
+
this.#O !== null && (clearTimeout(this.#O), this.#O = null), this.#D?.remove(), this.#D = null;
|
|
1086
|
+
}
|
|
1087
|
+
#jt(e, t) {
|
|
1088
|
+
!this.#h || this.#C.zoom || this.#A || this.#j === "mouse" && this.#vt(e, t) === "zoom-in" && (this.#i.state === "animating" || performance.now() - this.#Ee <= P || (this.#Nt(), this.#k = setTimeout(() => {
|
|
1089
|
+
this.#k = null, !(this.#C.zoom || this.#A) && (this.#A = !0, this.#kt(this.#Mt()));
|
|
1090
|
+
}, M)));
|
|
1091
|
+
}
|
|
1092
|
+
#Mt() {
|
|
1093
|
+
let e = [];
|
|
1094
|
+
if (this.#Q !== null && e.push("Double-click"), this.#Z) {
|
|
1095
|
+
let t = this.#e.ownerDocument?.defaultView?.navigator, n = /Mac|iPhone|iPad/.test(t?.platform ?? "");
|
|
1096
|
+
e.push(`${n ? "⌘" : "Ctrl"}-scroll`);
|
|
1097
|
+
}
|
|
1098
|
+
return `${e.join(" or ")} to zoom`;
|
|
1099
|
+
}
|
|
1100
|
+
#Nt() {
|
|
1101
|
+
this.#k !== null && (clearTimeout(this.#k), this.#k = null);
|
|
1102
|
+
}
|
|
1103
|
+
#Pt() {
|
|
1104
|
+
this.#fe !== null && (clearTimeout(this.#fe), this.#fe = null);
|
|
1105
|
+
}
|
|
1106
|
+
#Ft() {
|
|
1107
|
+
let e = this.#G[this.#K];
|
|
1108
|
+
e && this.#un(e, this.#J), this.#i.send("settle"), this.#_t(), this.#n.emit("flipEnd", { page: this.#q }), this.#Je();
|
|
1109
|
+
}
|
|
1110
|
+
#It() {
|
|
1111
|
+
if (this.#ue = null, this.#Pt(), this.#le) {
|
|
1112
|
+
this.#le = null, this.#i.send("release"), this.#i.send("settle");
|
|
1113
|
+
let e = this.#G[this.#K];
|
|
1114
|
+
e && this.#un(e, this.#J);
|
|
1115
|
+
} else this.#ge && (this.#ge = null, this.#i.send("panEnd"));
|
|
1116
|
+
this.#_e = !0, this.#ve = this.#ne;
|
|
1117
|
+
}
|
|
1118
|
+
#Lt(e, t, n) {
|
|
1119
|
+
if (!this.#_e) return;
|
|
937
1120
|
let r = this.#e.getBoundingClientRect();
|
|
938
|
-
this.setZoom(this.#
|
|
1121
|
+
this.setZoom(this.#ve * n, {
|
|
939
1122
|
x: e - r.left,
|
|
940
1123
|
y: t - r.top
|
|
941
1124
|
});
|
|
942
1125
|
}
|
|
943
|
-
#
|
|
944
|
-
this.#
|
|
1126
|
+
#Rt() {
|
|
1127
|
+
this.#_e = !1;
|
|
945
1128
|
}
|
|
946
|
-
#
|
|
947
|
-
if (!this.#
|
|
1129
|
+
#zt() {
|
|
1130
|
+
if (!this.#H) return;
|
|
948
1131
|
let e = (e) => e.preventDefault();
|
|
949
|
-
this.#e.addEventListener("contextmenu", e), this.#
|
|
1132
|
+
this.#e.addEventListener("contextmenu", e), this.#Ce = () => this.#e.removeEventListener("contextmenu", e);
|
|
950
1133
|
}
|
|
951
|
-
#
|
|
1134
|
+
#Bt() {
|
|
952
1135
|
let e = (e) => {
|
|
953
|
-
if (!this.#
|
|
1136
|
+
if (!this.#Z || !this.#X || !(e.ctrlKey || e.metaKey)) return;
|
|
954
1137
|
e.preventDefault();
|
|
955
|
-
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY *
|
|
956
|
-
this.setZoom(this.#
|
|
1138
|
+
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * A);
|
|
1139
|
+
this.setZoom(this.#ne * n, {
|
|
957
1140
|
x: e.clientX - t.left,
|
|
958
1141
|
y: e.clientY - t.top
|
|
959
1142
|
});
|
|
960
1143
|
};
|
|
961
|
-
this.#e.addEventListener("wheel", e, { passive: !1 }), this.#
|
|
1144
|
+
this.#e.addEventListener("wheel", e, { passive: !1 }), this.#Se = () => this.#e.removeEventListener("wheel", e);
|
|
962
1145
|
}
|
|
963
|
-
#
|
|
1146
|
+
#Vt() {
|
|
964
1147
|
let e = (e) => {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
let
|
|
968
|
-
if (!
|
|
969
|
-
|
|
1148
|
+
this.#j = e.pointerType;
|
|
1149
|
+
}, t = (e) => {
|
|
1150
|
+
let t = this.#Q;
|
|
1151
|
+
if (!this.#X || t === null || !this.#ae) return;
|
|
1152
|
+
let n = performance.now(), r = this.#Te;
|
|
1153
|
+
if (!(r !== null && n - r.t <= M && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= N)) {
|
|
1154
|
+
this.#Te = {
|
|
970
1155
|
t: n,
|
|
971
1156
|
x: e.clientX,
|
|
972
1157
|
y: e.clientY
|
|
973
|
-
};
|
|
1158
|
+
}, this.#jt(e.clientX, e.clientY);
|
|
974
1159
|
return;
|
|
975
1160
|
}
|
|
976
|
-
this.#
|
|
1161
|
+
this.#Te = null, this.#Nt(), this.#Ht(e.clientX, e.clientY, t);
|
|
1162
|
+
};
|
|
1163
|
+
this.#e.addEventListener("pointerdown", e), this.#e.addEventListener("click", t), this.#we = () => {
|
|
1164
|
+
this.#e.removeEventListener("pointerdown", e), this.#e.removeEventListener("click", t);
|
|
977
1165
|
};
|
|
978
|
-
this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
|
|
979
1166
|
}
|
|
980
|
-
|
|
981
|
-
if (this.#
|
|
982
|
-
let n = this.#
|
|
983
|
-
if (r !== null && this.#
|
|
1167
|
+
#Ht(e, t, n) {
|
|
1168
|
+
if (this.#ne <= 1 && this.#u !== "off" && !this.#M) {
|
|
1169
|
+
let n = this.#pt(e, t), r = this.#mt(n);
|
|
1170
|
+
if (r !== null && this.#ht(r) || this.#i.state === "animating" || performance.now() - this.#Ee <= P) return;
|
|
984
1171
|
}
|
|
985
|
-
this.#
|
|
986
|
-
let r = n.find((e) => e > this.#
|
|
1172
|
+
this.#Pt();
|
|
1173
|
+
let r = n.find((e) => e > this.#ne + 1e-6) ?? n[0] ?? this.#ne, i = this.#e.getBoundingClientRect();
|
|
987
1174
|
this.setZoom(r, {
|
|
988
1175
|
x: e - i.left,
|
|
989
1176
|
y: t - i.top
|
|
990
1177
|
});
|
|
991
1178
|
}
|
|
992
|
-
async #
|
|
993
|
-
let t =
|
|
994
|
-
if (this.#t.onProgress?.((e) => this.#
|
|
995
|
-
this.#
|
|
1179
|
+
async #Ut(e) {
|
|
1180
|
+
let t = O(e);
|
|
1181
|
+
if (this.#t.onProgress?.((e) => this.#Kt(e)), typeof this.#t.open == "function") {
|
|
1182
|
+
this.#qt();
|
|
996
1183
|
try {
|
|
997
|
-
await this.#t.open(), this.#
|
|
1184
|
+
await this.#t.open(), this.#wn();
|
|
998
1185
|
} catch (e) {
|
|
999
|
-
throw this.#
|
|
1186
|
+
throw this.#Yt(), e;
|
|
1000
1187
|
}
|
|
1001
|
-
this.#
|
|
1188
|
+
this.#Jt("preparing");
|
|
1002
1189
|
}
|
|
1003
|
-
this.#t.prefetch([this.#
|
|
1004
|
-
let n = await t, r = await this.#
|
|
1005
|
-
this.#
|
|
1190
|
+
this.#t.prefetch([this.#q]);
|
|
1191
|
+
let n = await t, r = await this.#Xt(n);
|
|
1192
|
+
this.#ae = r, this.#t.onPageUpdate?.((e) => this.#fn(e)), this.#sn(r.measure().containerWidth);
|
|
1006
1193
|
let i = new m({
|
|
1007
|
-
onStart: (e) => this.#
|
|
1008
|
-
onMove: (e) => this.#
|
|
1009
|
-
onEnd: (e) => this.#
|
|
1194
|
+
onStart: (e) => this.#at(e.x, e.y),
|
|
1195
|
+
onMove: (e) => this.#ct(e.dx, e.dy),
|
|
1196
|
+
onEnd: (e) => this.#lt(e)
|
|
1010
1197
|
}), a = new _({
|
|
1011
|
-
onPinchStart: () => this.#
|
|
1012
|
-
onPinchMove: (e) => this.#
|
|
1013
|
-
onPinchEnd: () => this.#
|
|
1198
|
+
onPinchStart: () => this.#It(),
|
|
1199
|
+
onPinchMove: (e) => this.#Lt(e.centerX, e.centerY, e.scale),
|
|
1200
|
+
onPinchEnd: () => this.#Rt()
|
|
1014
1201
|
});
|
|
1015
|
-
this.#
|
|
1202
|
+
this.#xe = h(this.#e, {
|
|
1016
1203
|
pointer: i,
|
|
1017
1204
|
pinch: a
|
|
1018
|
-
}), this.#
|
|
1205
|
+
}), this.#Ze(), this.#Bt(), this.#Vt(), this.#zt(), this.#gt(), this.#Qt(), this.#De = this.#tn(), await this.#ln(), this.#Yt(), this.#vn(), this.#Sn(), this.#rn(), this.#en(), await this.#$t(), this.#Wt(), this.#n.emit("ready"), this.#Ct(), this.#xt();
|
|
1019
1206
|
}
|
|
1020
|
-
#
|
|
1021
|
-
this.#
|
|
1207
|
+
async #Wt() {
|
|
1208
|
+
if (!(!this.#_ || this.#b || this.#S || this.#se)) {
|
|
1209
|
+
this.#S = !0;
|
|
1210
|
+
try {
|
|
1211
|
+
let { FlipSound: e } = await import("./flipSound-BFXSkWBo.js");
|
|
1212
|
+
if (this.#se) return;
|
|
1213
|
+
this.#y = new e(this.#v), this.#y.setMuted(this.#b);
|
|
1214
|
+
} catch {}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
#Gt() {
|
|
1218
|
+
this.#y?.play();
|
|
1219
|
+
}
|
|
1220
|
+
#Kt(e) {
|
|
1221
|
+
this.#Le = e, this.#n.emit("progress", e), this.#Ie?.update(e);
|
|
1022
1222
|
}
|
|
1023
|
-
async #
|
|
1024
|
-
if (this.#
|
|
1223
|
+
async #qt() {
|
|
1224
|
+
if (this.#Fe === !1 || this.#se) return;
|
|
1025
1225
|
let e = this.#e;
|
|
1026
1226
|
if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
|
|
1027
|
-
let { mountLoading: t } = await import("./loading-
|
|
1028
|
-
if (this.#
|
|
1029
|
-
this.#
|
|
1227
|
+
let { mountLoading: t } = await import("./loading-DF88K9yJ.js");
|
|
1228
|
+
if (this.#Re === "done" || this.#se) return;
|
|
1229
|
+
this.#Ie = t(e), this.#Le && this.#Ie.update(this.#Le), this.#Re === "preparing" && this.#Ie.preparing();
|
|
1030
1230
|
} catch {}
|
|
1031
1231
|
}
|
|
1032
|
-
#
|
|
1033
|
-
this.#
|
|
1232
|
+
#Jt(e) {
|
|
1233
|
+
this.#Re !== "done" && (this.#Re = e, this.#Ie?.preparing());
|
|
1034
1234
|
}
|
|
1035
|
-
#
|
|
1036
|
-
this.#
|
|
1235
|
+
#Yt() {
|
|
1236
|
+
this.#Re = "done", this.#Ie?.destroy(), this.#Ie = null;
|
|
1037
1237
|
}
|
|
1038
|
-
async #
|
|
1238
|
+
async #Xt(e) {
|
|
1039
1239
|
try {
|
|
1040
1240
|
return await e.mount(this.#e), e.onFatal?.(() => {
|
|
1041
|
-
this.#
|
|
1241
|
+
this.#Zt();
|
|
1042
1242
|
}), e;
|
|
1043
1243
|
} catch {
|
|
1044
1244
|
e.destroy();
|
|
1045
|
-
let t = await
|
|
1046
|
-
return await t.mount(this.#e), this.#
|
|
1245
|
+
let t = await O("css");
|
|
1246
|
+
return await t.mount(this.#e), this.#oe = !0, this.#n.emit("rendererFallback", {
|
|
1047
1247
|
from: "webgl2",
|
|
1048
1248
|
to: "css"
|
|
1049
1249
|
}), t;
|
|
1050
1250
|
}
|
|
1051
1251
|
}
|
|
1052
|
-
async #
|
|
1053
|
-
if (this.#
|
|
1054
|
-
this.#
|
|
1055
|
-
let e = await
|
|
1056
|
-
if (this.#
|
|
1252
|
+
async #Zt() {
|
|
1253
|
+
if (this.#oe || this.#se) return;
|
|
1254
|
+
this.#oe = !0, this.#ae?.destroy(), this.#ae = null;
|
|
1255
|
+
let e = await O("css");
|
|
1256
|
+
if (this.#se) {
|
|
1057
1257
|
e.destroy();
|
|
1058
1258
|
return;
|
|
1059
1259
|
}
|
|
1060
|
-
await e.mount(this.#e), this.#
|
|
1260
|
+
await e.mount(this.#e), this.#ae = e, this.#sn(e.measure().containerWidth), await this.#ln(), this.#n.emit("rendererFallback", {
|
|
1061
1261
|
from: "webgl2",
|
|
1062
1262
|
to: "css"
|
|
1063
1263
|
});
|
|
1064
1264
|
}
|
|
1065
|
-
#
|
|
1265
|
+
#Qt() {
|
|
1066
1266
|
if (typeof matchMedia != "function") return;
|
|
1067
1267
|
let e = matchMedia("(prefers-reduced-motion: reduce)");
|
|
1068
|
-
this
|
|
1069
|
-
this
|
|
1268
|
+
this.#ye = e.matches, e.addEventListener?.("change", (e) => {
|
|
1269
|
+
this.#ye = e.matches;
|
|
1070
1270
|
});
|
|
1071
1271
|
}
|
|
1072
|
-
async
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1272
|
+
async #$t() {
|
|
1273
|
+
let e = this.#Ae !== !1, t = this.#Me !== !1;
|
|
1274
|
+
if (!e && !t || this.#se) return;
|
|
1275
|
+
let n = this.#e;
|
|
1276
|
+
if (!(!n.ownerDocument || typeof n.appendChild != "function")) try {
|
|
1277
|
+
let { mountControls: e, mountContextMenu: t } = await import("./controls-DzVdwPJB.js");
|
|
1278
|
+
if (this.#se) return;
|
|
1279
|
+
if (this.#Ae !== !1) {
|
|
1280
|
+
let t = this.#Ae === !0 ? {} : this.#Ae;
|
|
1281
|
+
this.#je = e(this, n, t, this.#Pe);
|
|
1282
|
+
}
|
|
1283
|
+
if (this.#Me !== !1) {
|
|
1284
|
+
let e = this.#Me === !0 ? {} : this.#Me;
|
|
1285
|
+
this.#Ne = t(this, n, e, this.#Pe);
|
|
1286
|
+
}
|
|
1080
1287
|
} catch {}
|
|
1081
1288
|
}
|
|
1082
|
-
#
|
|
1083
|
-
if (!this.#
|
|
1289
|
+
#en() {
|
|
1290
|
+
if (!this.#V || globalThis.location === void 0) return;
|
|
1084
1291
|
let e = globalThis;
|
|
1085
|
-
this.#
|
|
1086
|
-
e !== this.#
|
|
1087
|
-
}), this.#
|
|
1088
|
-
this.#
|
|
1292
|
+
this.#U = ee(e, (e) => {
|
|
1293
|
+
e !== this.#q && this.flipTo(e);
|
|
1294
|
+
}), this.#U.push(this.#q), this.#W = this.#n.on("pageChanged", ({ page: e }) => {
|
|
1295
|
+
this.#U?.push(e);
|
|
1089
1296
|
});
|
|
1090
1297
|
}
|
|
1091
|
-
pageLink(e = this.#
|
|
1298
|
+
pageLink(e = this.#q) {
|
|
1092
1299
|
let t = globalThis.location?.href ?? "";
|
|
1093
1300
|
if (!t) return "";
|
|
1094
1301
|
let n = new URL(t);
|
|
1095
|
-
return n.hash = C(n.hash,
|
|
1302
|
+
return n.hash = C(n.hash, X(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
|
|
1096
1303
|
}
|
|
1097
|
-
#
|
|
1304
|
+
#tn() {
|
|
1098
1305
|
let e = this.#e, t = e.ownerDocument;
|
|
1099
1306
|
if (!t || typeof e.setAttribute != "function") return null;
|
|
1100
1307
|
e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
|
|
1101
|
-
let n = (e) => this.#
|
|
1308
|
+
let n = (e) => this.#nn(e);
|
|
1102
1309
|
e.addEventListener("keydown", n);
|
|
1103
1310
|
let r = t.createElement("div");
|
|
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.#
|
|
1105
|
-
e.removeEventListener("keydown", n), r.remove(), this.#
|
|
1311
|
+
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.#be = r, () => {
|
|
1312
|
+
e.removeEventListener("keydown", n), r.remove(), this.#be = null;
|
|
1106
1313
|
};
|
|
1107
1314
|
}
|
|
1108
|
-
#
|
|
1315
|
+
#nn(e) {
|
|
1109
1316
|
let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
1110
1317
|
switch (e.key) {
|
|
1111
1318
|
case "ArrowRight":
|
|
@@ -1121,92 +1328,98 @@ var J = class {
|
|
|
1121
1328
|
default: break;
|
|
1122
1329
|
}
|
|
1123
1330
|
}
|
|
1124
|
-
#
|
|
1125
|
-
this.#
|
|
1331
|
+
#rn() {
|
|
1332
|
+
this.#be && (this.#be.textContent = `Page ${this.#q + 1} of ${this.#t.pageCount}`);
|
|
1126
1333
|
}
|
|
1127
|
-
#
|
|
1128
|
-
return this
|
|
1334
|
+
#in() {
|
|
1335
|
+
return this.#ye ? B : this.#Y * (this.#F ? F : 1);
|
|
1129
1336
|
}
|
|
1130
|
-
#
|
|
1131
|
-
return this
|
|
1337
|
+
#an() {
|
|
1338
|
+
return this.#ye ? "simple" : this.#c;
|
|
1132
1339
|
}
|
|
1133
1340
|
update() {
|
|
1134
|
-
!this.#
|
|
1341
|
+
!this.#ae || this.#i.state !== "idle" || (this.#sn(this.#ae.measure().containerWidth), this.#ln(), this.#_t());
|
|
1135
1342
|
}
|
|
1136
|
-
#
|
|
1137
|
-
return this.#
|
|
1343
|
+
#on() {
|
|
1344
|
+
return this.#L || this.#o === "single" ? "single" : this.#o;
|
|
1138
1345
|
}
|
|
1139
|
-
#
|
|
1140
|
-
let t = this.#
|
|
1141
|
-
t !== this.#
|
|
1346
|
+
#sn(e) {
|
|
1347
|
+
let t = this.#R && o(e, this.#P);
|
|
1348
|
+
t !== this.#L && (this.#L = t, this.#cn());
|
|
1142
1349
|
}
|
|
1143
|
-
#
|
|
1144
|
-
let e = this.#
|
|
1145
|
-
this.#
|
|
1350
|
+
#cn() {
|
|
1351
|
+
let e = this.#on(), t = e !== this.#I;
|
|
1352
|
+
this.#I = e, this.#F = e === "single", this.#G = a(this.#t.pageCount, {
|
|
1146
1353
|
direction: this.#a,
|
|
1147
1354
|
mode: e
|
|
1148
|
-
}), this.#
|
|
1355
|
+
}), this.#K = this.#Cn(this.#q), t && this.#n.emit("spreadChanged", {
|
|
1149
1356
|
mode: e,
|
|
1150
|
-
singlePage: this.#
|
|
1357
|
+
singlePage: this.#F
|
|
1151
1358
|
});
|
|
1152
1359
|
}
|
|
1153
|
-
async #
|
|
1154
|
-
let e = this.#
|
|
1155
|
-
!e || !this.#
|
|
1360
|
+
async #ln() {
|
|
1361
|
+
let e = this.#G[this.#K];
|
|
1362
|
+
!e || !this.#ae || (this.#J = await this.#bn(e), this.#un(e, this.#J));
|
|
1156
1363
|
}
|
|
1157
|
-
#
|
|
1158
|
-
this.#
|
|
1364
|
+
#un(e, t) {
|
|
1365
|
+
this.#ae?.renderSpread(e, t, { fill: this.#F }), this.#dn(), this.#ze = 1, this.#pn();
|
|
1159
1366
|
}
|
|
1160
|
-
#
|
|
1161
|
-
let e = this.#
|
|
1367
|
+
#dn() {
|
|
1368
|
+
let e = this.#ae?.measure().book;
|
|
1162
1369
|
if (!e || e.width <= 0 || e.height <= 0) return;
|
|
1163
|
-
let t =
|
|
1164
|
-
|
|
1370
|
+
let t = e.width / e.height;
|
|
1371
|
+
this.#z !== null && Math.abs(t - this.#z) < .005 || (this.#z = t, this.#e.style.aspectRatio = t.toFixed(4));
|
|
1165
1372
|
}
|
|
1166
|
-
#
|
|
1373
|
+
#fn(e) {
|
|
1167
1374
|
if (this.#i.state !== "idle") {
|
|
1168
|
-
this.#
|
|
1375
|
+
this.#ke.add(e);
|
|
1169
1376
|
return;
|
|
1170
1377
|
}
|
|
1171
|
-
let t = this.#
|
|
1172
|
-
t
|
|
1378
|
+
let t = this.#G[this.#K];
|
|
1379
|
+
if (!(!t || !(t.left === e || t.right === e))) {
|
|
1380
|
+
if (this.#ne > 1) {
|
|
1381
|
+
this.#pn();
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
this.#ln();
|
|
1385
|
+
}
|
|
1173
1386
|
}
|
|
1174
|
-
#
|
|
1175
|
-
this.#
|
|
1176
|
-
let e = this.#
|
|
1177
|
-
if (e !== this.#
|
|
1387
|
+
#pn() {
|
|
1388
|
+
this.#Ve !== null && clearTimeout(this.#Ve);
|
|
1389
|
+
let e = this.#hn();
|
|
1390
|
+
if (e !== this.#ze) {
|
|
1178
1391
|
if (e === 1) {
|
|
1179
|
-
this.#
|
|
1392
|
+
this.#Be++, this.#ze = 1, this.#ln();
|
|
1180
1393
|
return;
|
|
1181
1394
|
}
|
|
1182
|
-
this.#
|
|
1183
|
-
this.#
|
|
1184
|
-
},
|
|
1395
|
+
this.#Ve = setTimeout(() => {
|
|
1396
|
+
this.#Ve = null, this.#gn();
|
|
1397
|
+
}, L);
|
|
1185
1398
|
}
|
|
1186
1399
|
}
|
|
1187
|
-
#
|
|
1188
|
-
let e = this.#
|
|
1400
|
+
#mn() {
|
|
1401
|
+
let e = this.#ae?.measure(), t = e?.content ?? e?.book;
|
|
1189
1402
|
if (!t || t.width <= 0) return 1;
|
|
1190
|
-
let n = this.#
|
|
1403
|
+
let n = this.#J, r = +!!n.left + +!!n.right;
|
|
1191
1404
|
if (r === 0) return 1;
|
|
1192
1405
|
let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
|
|
1193
1406
|
for (let e of [n.left, n.right]) {
|
|
1194
1407
|
if (!e || e.width <= 0) continue;
|
|
1195
|
-
let t = e.width / this.#
|
|
1408
|
+
let t = e.width / this.#ze;
|
|
1196
1409
|
o = Math.max(o, i * a / t);
|
|
1197
1410
|
}
|
|
1198
1411
|
return o === 0 ? 1 : o;
|
|
1199
1412
|
}
|
|
1200
|
-
#
|
|
1201
|
-
let e = Math.max(1,
|
|
1202
|
-
return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2,
|
|
1203
|
-
}
|
|
1204
|
-
async #
|
|
1205
|
-
let e = this.#
|
|
1206
|
-
if (!this.#
|
|
1207
|
-
let t = this.#
|
|
1208
|
-
if (t === 1 || t === this.#
|
|
1209
|
-
let n = ++this.#
|
|
1413
|
+
#hn() {
|
|
1414
|
+
let e = Math.max(1, z / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#ne <= 1 ? 1 : this.#ne, n = this.#mn() * Math.max(t, e);
|
|
1415
|
+
return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, R);
|
|
1416
|
+
}
|
|
1417
|
+
async #gn() {
|
|
1418
|
+
let e = this.#G[this.#K];
|
|
1419
|
+
if (!this.#ae || !e) return;
|
|
1420
|
+
let t = this.#hn();
|
|
1421
|
+
if (t === 1 || t === this.#ze || this.#i.state !== "idle") return;
|
|
1422
|
+
let n = ++this.#Be, r = {
|
|
1210
1423
|
x: 0,
|
|
1211
1424
|
y: 0,
|
|
1212
1425
|
width: 1,
|
|
@@ -1216,7 +1429,8 @@ var J = class {
|
|
|
1216
1429
|
try {
|
|
1217
1430
|
return await this.#t.get(e, {
|
|
1218
1431
|
scale: t,
|
|
1219
|
-
region: r
|
|
1432
|
+
region: r,
|
|
1433
|
+
maxSize: this.#ae?.maxTextureSize
|
|
1220
1434
|
});
|
|
1221
1435
|
} catch (t) {
|
|
1222
1436
|
return this.#n.emit("sourceError", {
|
|
@@ -1225,34 +1439,34 @@ var J = class {
|
|
|
1225
1439
|
}), null;
|
|
1226
1440
|
}
|
|
1227
1441
|
}));
|
|
1228
|
-
if (n !== this.#
|
|
1229
|
-
let a = i[0] ??
|
|
1230
|
-
a === this.#
|
|
1442
|
+
if (n !== this.#Be || this.#hn() !== t || this.#i.state !== "idle") return;
|
|
1443
|
+
let a = i[0] ?? this.#J.left, o = i[1] ?? this.#J.right;
|
|
1444
|
+
a === this.#J.left && o === this.#J.right || (this.#ze = t, this.#J = {
|
|
1231
1445
|
left: a,
|
|
1232
1446
|
right: o
|
|
1233
|
-
}, this.#
|
|
1447
|
+
}, this.#ae.renderSpread(e, this.#J, { fill: this.#F }));
|
|
1234
1448
|
}
|
|
1235
|
-
#
|
|
1236
|
-
if (this.#
|
|
1237
|
-
let e = this.#
|
|
1238
|
-
this.#
|
|
1449
|
+
#_n() {
|
|
1450
|
+
if (this.#ke.size === 0) return;
|
|
1451
|
+
let e = this.#G[this.#K], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#ke.has(e));
|
|
1452
|
+
this.#ke.clear(), t && (this.#ne > 1 ? this.#pn() : this.#ln());
|
|
1239
1453
|
}
|
|
1240
|
-
#
|
|
1241
|
-
typeof ResizeObserver > "u" || (this.#
|
|
1454
|
+
#vn() {
|
|
1455
|
+
typeof ResizeObserver > "u" || (this.#ee = new ResizeObserver(() => this.#yn()), this.#ee.observe(this.#e));
|
|
1242
1456
|
}
|
|
1243
|
-
#
|
|
1244
|
-
this.#
|
|
1245
|
-
this.#
|
|
1457
|
+
#yn() {
|
|
1458
|
+
this.#te || (this.#te = !0, requestAnimationFrame(() => {
|
|
1459
|
+
this.#te = !1, this.update();
|
|
1246
1460
|
}));
|
|
1247
1461
|
}
|
|
1248
|
-
async #
|
|
1249
|
-
let [t, n] = await Promise.all([this.#
|
|
1462
|
+
async #bn(e) {
|
|
1463
|
+
let [t, n] = await Promise.all([this.#xn(e.left), this.#xn(e.right)]);
|
|
1250
1464
|
return {
|
|
1251
1465
|
left: t,
|
|
1252
1466
|
right: n
|
|
1253
1467
|
};
|
|
1254
1468
|
}
|
|
1255
|
-
async #
|
|
1469
|
+
async #xn(e) {
|
|
1256
1470
|
if (e === null) return null;
|
|
1257
1471
|
try {
|
|
1258
1472
|
return await this.#t.get(e);
|
|
@@ -1263,52 +1477,49 @@ var J = class {
|
|
|
1263
1477
|
}), null;
|
|
1264
1478
|
}
|
|
1265
1479
|
}
|
|
1266
|
-
#
|
|
1267
|
-
let { toMount: e } = this.#r.update(this.#
|
|
1480
|
+
#Sn() {
|
|
1481
|
+
let { toMount: e } = this.#r.update(this.#K, this.#G.length), t = [];
|
|
1268
1482
|
for (let n of e) {
|
|
1269
|
-
let e = this.#
|
|
1483
|
+
let e = this.#G[n];
|
|
1270
1484
|
e?.left != null && t.push(e.left), e?.right != null && t.push(e.right);
|
|
1271
1485
|
}
|
|
1272
1486
|
this.#t.prefetch(t);
|
|
1273
1487
|
}
|
|
1274
|
-
#
|
|
1275
|
-
let t = this.#
|
|
1488
|
+
#Cn(e) {
|
|
1489
|
+
let t = this.#G.findIndex((t) => t.left === e || t.right === e);
|
|
1276
1490
|
return t === -1 ? 0 : t;
|
|
1277
1491
|
}
|
|
1278
|
-
#
|
|
1492
|
+
#wn() {
|
|
1279
1493
|
let e = this.#t.pageCount;
|
|
1280
1494
|
if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
|
|
1281
|
-
let t = this.#
|
|
1495
|
+
let t = this.#B;
|
|
1282
1496
|
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}).`);
|
|
1283
|
-
let n = this.#
|
|
1284
|
-
this.#
|
|
1497
|
+
let n = this.#on();
|
|
1498
|
+
this.#F = n === "single", this.#G = a(e, {
|
|
1285
1499
|
direction: this.#a,
|
|
1286
1500
|
mode: n
|
|
1287
1501
|
});
|
|
1288
|
-
let r = this.#
|
|
1289
|
-
this.#
|
|
1502
|
+
let r = this.#V ? S(globalThis.location?.hash ?? "") : null;
|
|
1503
|
+
this.#q = X(r ?? t ?? 0, 0, e - 1), this.#K = this.#Cn(this.#q);
|
|
1290
1504
|
}
|
|
1291
1505
|
};
|
|
1292
|
-
function
|
|
1506
|
+
function X(e, t, n) {
|
|
1293
1507
|
return e < t ? t : e > n ? n : e;
|
|
1294
1508
|
}
|
|
1295
|
-
function
|
|
1509
|
+
function Z(e, t, n) {
|
|
1296
1510
|
if (t <= n) {
|
|
1297
1511
|
let r = (n - t) / 2 - e;
|
|
1298
1512
|
return [r, r];
|
|
1299
1513
|
}
|
|
1300
1514
|
return [n - (e + t), -e];
|
|
1301
1515
|
}
|
|
1302
|
-
function
|
|
1516
|
+
function le(e) {
|
|
1303
1517
|
return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
|
|
1304
1518
|
}
|
|
1305
|
-
function ne(e) {
|
|
1306
|
-
return 1 - (1 - Z(e)) ** 1.3;
|
|
1307
|
-
}
|
|
1308
1519
|
function Q(e) {
|
|
1309
1520
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1310
1521
|
}
|
|
1311
|
-
function
|
|
1522
|
+
function ue(n, r) {
|
|
1312
1523
|
if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Q(n)}.`);
|
|
1313
1524
|
if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
|
|
1314
1525
|
let i = r, a = i.source;
|
|
@@ -1353,25 +1564,45 @@ function re(n, r) {
|
|
|
1353
1564
|
].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
|
|
1354
1565
|
let p = u?.arrows;
|
|
1355
1566
|
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.
|
|
1357
|
-
if (m !== void 0 && !
|
|
1567
|
+
let m = i.contextMenu;
|
|
1568
|
+
if (m !== void 0 && typeof m != "boolean" && (typeof m != "object" || !m)) throw Error(`Zine: contextMenu must be a boolean or an options object; got ${Q(m)}.`);
|
|
1569
|
+
let h = m?.colorScheme;
|
|
1570
|
+
if (h !== void 0 && ![
|
|
1571
|
+
"light",
|
|
1572
|
+
"dark",
|
|
1573
|
+
"auto"
|
|
1574
|
+
].includes(h)) throw Error(`Zine: contextMenu.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(h)}.`);
|
|
1575
|
+
if (i.disableContextMenu === !0 && m !== void 0 && m !== !1) throw Error("Zine: disableContextMenu and contextMenu are mutually exclusive — one removes the browser's right-click menu, the other replaces it. Enable only one.");
|
|
1576
|
+
let g = i.hideControls;
|
|
1577
|
+
if (g !== void 0 && (!Array.isArray(g) || g.some((e) => typeof e != "string"))) throw Error(`Zine: hideControls must be an array of control-id strings; got ${Q(g)}.`);
|
|
1578
|
+
let _ = i.sound;
|
|
1579
|
+
if (_ !== void 0 && typeof _ != "boolean" && (typeof _ != "object" || !_)) throw Error(`Zine: sound must be a boolean or an options object; got ${Q(_)}.`);
|
|
1580
|
+
if (typeof _ == "object" && _) {
|
|
1581
|
+
let e = _;
|
|
1582
|
+
if (e.url !== void 0 && typeof e.url != "string") throw Error(`Zine: sound.url must be a string URL; got ${Q(e.url)}.`);
|
|
1583
|
+
if (e.volume !== void 0 && (typeof e.volume != "number" || e.volume < 0 || e.volume > 1)) throw Error(`Zine: sound.volume must be a number between 0 and 1; got ${JSON.stringify(e.volume)}.`);
|
|
1584
|
+
if (e.muted !== void 0 && typeof e.muted != "boolean") throw Error(`Zine: sound.muted must be a boolean; got ${Q(e.muted)}.`);
|
|
1585
|
+
if (e.persist !== void 0 && typeof e.persist != "boolean") throw Error(`Zine: sound.persist must be a boolean; got ${Q(e.persist)}.`);
|
|
1586
|
+
}
|
|
1587
|
+
let v = i.spreadMode;
|
|
1588
|
+
if (v !== void 0 && ![
|
|
1358
1589
|
"double",
|
|
1359
1590
|
"single",
|
|
1360
1591
|
"cover",
|
|
1361
1592
|
"book"
|
|
1362
|
-
].includes(
|
|
1593
|
+
].includes(v)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(v)}.`);
|
|
1363
1594
|
for (let e of ["frontCover", "backCover"]) {
|
|
1364
1595
|
let t = i[e];
|
|
1365
1596
|
if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
|
|
1366
1597
|
}
|
|
1367
|
-
let
|
|
1368
|
-
if (
|
|
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),
|
|
1598
|
+
let y = i.pages;
|
|
1599
|
+
if (y !== void 0 && (typeof y != "object" || !y || Array.isArray(y))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
|
|
1600
|
+
$(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), de(i.zoom), fe(i.renderer);
|
|
1370
1601
|
}
|
|
1371
1602
|
function $(e, t, n) {
|
|
1372
1603
|
if (e !== void 0 && (typeof e != "number" || !Number.isFinite(e) || e < n)) throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`);
|
|
1373
1604
|
}
|
|
1374
|
-
function
|
|
1605
|
+
function de(e) {
|
|
1375
1606
|
if (e === void 0) return;
|
|
1376
1607
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
|
|
1377
1608
|
let t = e;
|
|
@@ -1384,7 +1615,7 @@ function ie(e) {
|
|
|
1384
1615
|
}
|
|
1385
1616
|
$(t.max, "zoom.max", 1);
|
|
1386
1617
|
}
|
|
1387
|
-
function
|
|
1618
|
+
function fe(e) {
|
|
1388
1619
|
if (e !== void 0) {
|
|
1389
1620
|
if (typeof e == "string") {
|
|
1390
1621
|
if (e !== "auto" && e !== "css" && e !== "webgl2") throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);
|
|
@@ -1399,7 +1630,7 @@ function ae(e) {
|
|
|
1399
1630
|
}
|
|
1400
1631
|
//#endregion
|
|
1401
1632
|
//#region src/source/imageSource.ts
|
|
1402
|
-
var
|
|
1633
|
+
var pe = class {
|
|
1403
1634
|
pageCount;
|
|
1404
1635
|
fit;
|
|
1405
1636
|
#e;
|
|
@@ -1436,6 +1667,6 @@ var oe = class {
|
|
|
1436
1667
|
}
|
|
1437
1668
|
};
|
|
1438
1669
|
//#endregion
|
|
1439
|
-
export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS,
|
|
1670
|
+
export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, pe as ImageSource, ce as Zine, n as defineControl, r as getControl };
|
|
1440
1671
|
|
|
1441
1672
|
//# sourceMappingURL=index.js.map
|