@zinejs/core 0.8.0 → 0.9.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/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 +2 -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 +13 -2
- package/dist/{controls-Djjk8Yac.js → controls-CcOu_19g.js} +355 -199
- package/dist/controls-CcOu_19g.js.map +1 -0
- package/dist/curls.js +1 -1
- package/dist/geometry/curls/cone.d.ts +4 -3
- package/dist/index.js +644 -450
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +61 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/loading/loading.d.ts +1 -1
- package/dist/{loading-C0qbANt2.js → loading-DF88K9yJ.js} +2 -2
- 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-DXAfK9rJ.js → share-BrQa6aYm.js} +2 -2
- package/dist/{share-DXAfK9rJ.js.map → share-BrQa6aYm.js.map} +1 -1
- package/dist/source/types.d.ts +5 -0
- package/dist/styles-D_zOGk2q.js +40 -0
- package/dist/styles-D_zOGk2q.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 +52 -1
- package/options.schema.json +49 -0
- package/package.json +2 -2
- package/dist/bundled-Cp43MIt0.js.map +0 -1
- package/dist/controls-Djjk8Yac.js.map +0 -1
- package/dist/loading-C0qbANt2.js.map +0 -1
- package/dist/styles-CgCzjFUk.js +0 -40
- package/dist/styles-CgCzjFUk.js.map +0 -1
- package/dist/webglRenderer-nGRruZk2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -245,32 +245,32 @@ var _ = class {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
}, v = "page", y = !1;
|
|
248
|
-
function
|
|
248
|
+
function ee() {
|
|
249
249
|
return y ? !1 : (y = !0, !0);
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function b() {
|
|
252
252
|
y = !1;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function x(e) {
|
|
255
255
|
let t = new URLSearchParams(e.replace(/^#/, "")).get(v);
|
|
256
256
|
if (t === null) return null;
|
|
257
257
|
let n = Number(t);
|
|
258
258
|
return Number.isInteger(n) && n >= 1 ? n - 1 : null;
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function S(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 C(e, t) {
|
|
265
265
|
let n = null, r = () => {
|
|
266
|
-
let r =
|
|
266
|
+
let r = x(e.location.hash);
|
|
267
267
|
r === null || r === n || (n = r, t(r));
|
|
268
268
|
};
|
|
269
269
|
return e.addEventListener("hashchange", r), {
|
|
270
270
|
push(t) {
|
|
271
271
|
if (t === n) return;
|
|
272
272
|
n = t;
|
|
273
|
-
let r =
|
|
273
|
+
let r = S(e.location.hash, t);
|
|
274
274
|
r !== e.location.hash && e.history?.replaceState?.(e.history.state, "", r);
|
|
275
275
|
},
|
|
276
276
|
stop() {
|
|
@@ -280,49 +280,49 @@ function w(e, t) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/renderer/select.ts
|
|
283
|
-
var
|
|
283
|
+
var w = {
|
|
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
|
+
}, T = !0;
|
|
287
|
+
function te(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 ne(e) {
|
|
291
|
+
return e.gpu && T ? ["webgl2", "css"] : ["css"];
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
return { gpu:
|
|
293
|
+
function re() {
|
|
294
|
+
return { gpu: ie() };
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function ie() {
|
|
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 E(e = "auto", t = re()) {
|
|
304
|
+
if (te(e)) return e;
|
|
305
|
+
let n = Array.isArray(e) ? e : e === "auto" ? ne(t) : [e];
|
|
306
306
|
for (let e of n) {
|
|
307
307
|
if (e === "webgl2" && !t.gpu) continue;
|
|
308
|
-
let n =
|
|
308
|
+
let n = w[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 ae(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 O(e, t);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function D(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 O = 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 = D(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, oe = .12, U = 360, W = 28, G = 260, K = 7e3, q = 2200, J = "zine:hints-learned";
|
|
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,133 @@ var J = class {
|
|
|
414
414
|
#u;
|
|
415
415
|
#d;
|
|
416
416
|
#f;
|
|
417
|
-
#p;
|
|
418
|
-
#m;
|
|
419
|
-
#h
|
|
420
|
-
#g
|
|
421
|
-
#_ =
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
#
|
|
417
|
+
#p = null;
|
|
418
|
+
#m = null;
|
|
419
|
+
#h;
|
|
420
|
+
#g;
|
|
421
|
+
#_ = {
|
|
422
|
+
turn: !1,
|
|
423
|
+
zoom: !1,
|
|
424
|
+
pan: !1
|
|
425
|
+
};
|
|
426
|
+
#v = null;
|
|
427
|
+
#y = null;
|
|
428
|
+
#b = null;
|
|
429
|
+
#x = null;
|
|
430
|
+
#S = null;
|
|
427
431
|
#C = null;
|
|
428
|
-
#w =
|
|
429
|
-
#T =
|
|
430
|
-
#E
|
|
431
|
-
#D
|
|
432
|
-
#O
|
|
432
|
+
#w = !1;
|
|
433
|
+
#T = "";
|
|
434
|
+
#E;
|
|
435
|
+
#D;
|
|
436
|
+
#O;
|
|
437
|
+
#k = !1;
|
|
438
|
+
#A = null;
|
|
439
|
+
#j = !1;
|
|
440
|
+
#M;
|
|
441
|
+
#N = "";
|
|
442
|
+
#P;
|
|
443
|
+
#F;
|
|
444
|
+
#I;
|
|
445
|
+
#L = null;
|
|
446
|
+
#R = null;
|
|
447
|
+
#z = [];
|
|
448
|
+
#B = 0;
|
|
449
|
+
#V = 0;
|
|
450
|
+
#H = {
|
|
433
451
|
left: null,
|
|
434
452
|
right: null
|
|
435
453
|
};
|
|
436
|
-
#
|
|
437
|
-
#
|
|
438
|
-
#
|
|
439
|
-
#
|
|
440
|
-
#
|
|
441
|
-
#P = null;
|
|
442
|
-
#F = !1;
|
|
443
|
-
#I = 1;
|
|
444
|
-
#L = 0;
|
|
445
|
-
#R = 0;
|
|
446
|
-
#z = null;
|
|
447
|
-
#B = !1;
|
|
448
|
-
#V = !1;
|
|
449
|
-
#H = null;
|
|
450
|
-
#U = null;
|
|
451
|
-
#W = null;
|
|
452
|
-
#G = null;
|
|
453
|
-
#K = null;
|
|
454
|
-
#q = null;
|
|
454
|
+
#U;
|
|
455
|
+
#W;
|
|
456
|
+
#G;
|
|
457
|
+
#K;
|
|
458
|
+
#q;
|
|
455
459
|
#J = null;
|
|
456
|
-
#Y =
|
|
457
|
-
#X =
|
|
458
|
-
#Z =
|
|
459
|
-
#Q =
|
|
460
|
-
#$ =
|
|
461
|
-
#ee =
|
|
462
|
-
#te =
|
|
460
|
+
#Y = !1;
|
|
461
|
+
#X = 1;
|
|
462
|
+
#Z = 0;
|
|
463
|
+
#Q = 0;
|
|
464
|
+
#$ = null;
|
|
465
|
+
#ee = !1;
|
|
466
|
+
#te = !1;
|
|
463
467
|
#ne = null;
|
|
464
468
|
#re = null;
|
|
465
469
|
#ie = null;
|
|
466
470
|
#ae = null;
|
|
467
|
-
#oe =
|
|
471
|
+
#oe = null;
|
|
468
472
|
#se = null;
|
|
469
473
|
#ce = null;
|
|
470
|
-
#le =
|
|
471
|
-
#ue;
|
|
472
|
-
#de =
|
|
473
|
-
#fe;
|
|
474
|
-
#pe =
|
|
474
|
+
#le = 0;
|
|
475
|
+
#ue = null;
|
|
476
|
+
#de = !1;
|
|
477
|
+
#fe = 1;
|
|
478
|
+
#pe = !1;
|
|
475
479
|
#me = null;
|
|
476
|
-
#he =
|
|
477
|
-
#ge =
|
|
478
|
-
#_e =
|
|
480
|
+
#he = null;
|
|
481
|
+
#ge = null;
|
|
482
|
+
#_e = null;
|
|
479
483
|
#ve = null;
|
|
480
|
-
#ye;
|
|
484
|
+
#ye = null;
|
|
485
|
+
#be = -Infinity;
|
|
486
|
+
#xe = null;
|
|
487
|
+
#Se = null;
|
|
488
|
+
#Ce = /* @__PURE__ */ new Set();
|
|
489
|
+
#we;
|
|
490
|
+
#Te = null;
|
|
491
|
+
#Ee;
|
|
492
|
+
#De = null;
|
|
493
|
+
#Oe;
|
|
494
|
+
#ke;
|
|
495
|
+
#Ae = null;
|
|
496
|
+
#je = null;
|
|
497
|
+
#Me = "download";
|
|
498
|
+
#Ne = 1;
|
|
499
|
+
#Pe = 0;
|
|
500
|
+
#Fe = null;
|
|
501
|
+
#Ie;
|
|
481
502
|
debug = { setFlipProgress: (e, t) => {
|
|
482
|
-
this
|
|
503
|
+
this.#$?.setFlipProgress(e, t);
|
|
483
504
|
} };
|
|
484
505
|
constructor(e, t) {
|
|
485
|
-
|
|
506
|
+
le(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 = ae(t.source, {
|
|
486
507
|
frontCover: t.frontCover,
|
|
487
508
|
backCover: t.backCover,
|
|
488
509
|
pages: t.pages
|
|
489
510
|
});
|
|
490
511
|
let n = t.direction ?? "ltr";
|
|
491
|
-
this.#a = n, this.#
|
|
492
|
-
let r = t.
|
|
512
|
+
this.#a = n, this.#F = (t.deepLink ?? !0) && ee(), this.#I = 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;
|
|
513
|
+
let r = t.hints ?? !0;
|
|
514
|
+
this.#h = r === !0 || r !== !1 && (r.enabled ?? !0), this.#g = r !== !0 && r !== !1 && (r.persist ?? !1), this.#g && this.#dt(), this.#O = t.singlePageThreshold ?? 640, this.#M = t.responsiveSpread ?? !0, this.#we = t.controls ?? !0, this.#Ee = t.contextMenu ?? !t.disableContextMenu, this.#Oe = new Set(t.hideControls ?? []), this.#ke = t.loading ?? !0, this.#P = t.startPage, typeof this.#t.open != "function" && this.#mn(), this.#U = t.flipDuration ?? 800, this.#W = t.zoom?.enabled ?? !0, this.#G = t.zoom?.wheel ?? !0;
|
|
515
|
+
let i = t.zoom?.doubleClick, a = i === !1 ? [] : [...i ?? [
|
|
493
516
|
1,
|
|
494
517
|
2,
|
|
495
518
|
4
|
|
496
519
|
]].sort((e, t) => e - t);
|
|
497
|
-
this.#
|
|
498
|
-
let
|
|
499
|
-
this.#
|
|
520
|
+
this.#K = a.length > 0 ? a : null, this.#q = t.zoom?.max ?? 4;
|
|
521
|
+
let o = this.#W && this.#K !== null, s = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
|
|
522
|
+
this.#E = this.#u !== "off" && o && s && t.clickFlipDelay !== 0, this.#D = this.#E ? t.clickFlipDelay ?? M : 0, this.#Ie = this.#Ft(t.renderer ?? "auto");
|
|
500
523
|
}
|
|
501
524
|
get ready() {
|
|
502
|
-
return this.#
|
|
525
|
+
return this.#Ie;
|
|
503
526
|
}
|
|
504
527
|
getPageCount() {
|
|
505
528
|
return this.#t.pageCount;
|
|
506
529
|
}
|
|
507
530
|
getPage() {
|
|
508
|
-
return this.#
|
|
531
|
+
return this.#V;
|
|
509
532
|
}
|
|
510
533
|
get container() {
|
|
511
534
|
return this.#e;
|
|
512
535
|
}
|
|
513
536
|
getPageBox() {
|
|
514
|
-
return this
|
|
537
|
+
return this.#$?.measure().book ?? null;
|
|
515
538
|
}
|
|
516
539
|
getSpreads() {
|
|
517
|
-
return this.#
|
|
540
|
+
return this.#z;
|
|
518
541
|
}
|
|
519
542
|
getSpreadIndex() {
|
|
520
|
-
return this.#
|
|
543
|
+
return this.#B;
|
|
521
544
|
}
|
|
522
545
|
getDirection() {
|
|
523
546
|
return this.#a;
|
|
@@ -526,44 +549,44 @@ var J = class {
|
|
|
526
549
|
return this.#o;
|
|
527
550
|
}
|
|
528
551
|
isSinglePage() {
|
|
529
|
-
return this.#
|
|
552
|
+
return this.#k;
|
|
530
553
|
}
|
|
531
554
|
setSpreadMode(e) {
|
|
532
|
-
e !== this.#o && (this.#o = e, this.#
|
|
555
|
+
e !== this.#o && (this.#o = e, this.#j = !1, this.#Qt(), this.#$t());
|
|
533
556
|
}
|
|
534
557
|
toggleSpreadMode() {
|
|
535
558
|
this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
|
|
536
559
|
}
|
|
537
560
|
getResponsiveSpread() {
|
|
538
|
-
return this.#
|
|
561
|
+
return this.#M;
|
|
539
562
|
}
|
|
540
563
|
isResponsiveSingle() {
|
|
541
|
-
return this.#
|
|
564
|
+
return this.#j && this.#o !== "single";
|
|
542
565
|
}
|
|
543
566
|
setResponsiveSpread(e) {
|
|
544
|
-
if (e !== this.#
|
|
545
|
-
if (this.#
|
|
546
|
-
let e = this
|
|
567
|
+
if (e !== this.#M) {
|
|
568
|
+
if (this.#M = e, e) {
|
|
569
|
+
let e = this.#$?.measure().containerWidth;
|
|
547
570
|
if (e === void 0) return;
|
|
548
|
-
this.#
|
|
571
|
+
this.#j = !1, this.#Zt(e);
|
|
549
572
|
} else {
|
|
550
|
-
if (!this.#
|
|
551
|
-
this.#
|
|
573
|
+
if (!this.#j) return;
|
|
574
|
+
this.#j = !1, this.#Qt();
|
|
552
575
|
}
|
|
553
|
-
this
|
|
576
|
+
this.#$t();
|
|
554
577
|
}
|
|
555
578
|
}
|
|
556
579
|
getPageImage(e) {
|
|
557
|
-
return this.#
|
|
580
|
+
return this.#dn(e);
|
|
558
581
|
}
|
|
559
582
|
canFlipNext() {
|
|
560
|
-
return this.#
|
|
583
|
+
return this.#B + 1 < this.#z.length;
|
|
561
584
|
}
|
|
562
585
|
canFlipPrev() {
|
|
563
|
-
return this.#
|
|
586
|
+
return this.#B > 0;
|
|
564
587
|
}
|
|
565
588
|
getMaxZoom() {
|
|
566
|
-
return this.#
|
|
589
|
+
return this.#q;
|
|
567
590
|
}
|
|
568
591
|
canSearch() {
|
|
569
592
|
return typeof this.#t.getText == "function";
|
|
@@ -580,33 +603,33 @@ var J = class {
|
|
|
580
603
|
async print() {
|
|
581
604
|
let e = await this.getSourceFile(), t = this.#e.ownerDocument;
|
|
582
605
|
if (!e || !t) return !1;
|
|
583
|
-
let n = t.createElement("iframe");
|
|
584
|
-
return
|
|
585
|
-
let
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}, 6e4),
|
|
606
|
+
let { url: n, revoke: r } = await this.#Le(e, t), i = t.createElement("iframe");
|
|
607
|
+
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) => {
|
|
608
|
+
let a = !1, o = (t) => {
|
|
609
|
+
a || (a = !0, setTimeout(() => {
|
|
610
|
+
i.remove(), r && URL.revokeObjectURL(n);
|
|
611
|
+
}, 6e4), e(t));
|
|
589
612
|
};
|
|
590
|
-
|
|
613
|
+
i.addEventListener("load", () => {
|
|
591
614
|
try {
|
|
592
|
-
let e =
|
|
593
|
-
if (!e) return
|
|
594
|
-
e.focus(), e.print(),
|
|
615
|
+
let e = i.contentWindow;
|
|
616
|
+
if (!e) return o(!1);
|
|
617
|
+
e.focus(), e.print(), o(!0);
|
|
595
618
|
} catch {
|
|
596
|
-
|
|
619
|
+
o(!1);
|
|
597
620
|
}
|
|
598
|
-
}),
|
|
621
|
+
}), i.addEventListener("error", () => o(!1)), t.body.appendChild(i);
|
|
599
622
|
});
|
|
600
623
|
}
|
|
601
624
|
canOutline() {
|
|
602
625
|
return typeof this.#t.getOutline == "function";
|
|
603
626
|
}
|
|
604
627
|
getOutline() {
|
|
605
|
-
if (!this.#
|
|
628
|
+
if (!this.#Se) {
|
|
606
629
|
let e = this.#t.getOutline;
|
|
607
|
-
this.#
|
|
630
|
+
this.#Se = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
|
|
608
631
|
}
|
|
609
|
-
return this.#
|
|
632
|
+
return this.#Se;
|
|
610
633
|
}
|
|
611
634
|
async getSourceFile() {
|
|
612
635
|
let e = this.#t.getDownload;
|
|
@@ -617,15 +640,28 @@ var J = class {
|
|
|
617
640
|
if (!e) return !1;
|
|
618
641
|
let t = this.#e.ownerDocument;
|
|
619
642
|
if (!t) return !1;
|
|
620
|
-
let n = e
|
|
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");
|
|
643
|
+
let { url: n, revoke: r } = await this.#Le(e, t), i = t.createElement("a");
|
|
626
644
|
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
645
|
}
|
|
628
|
-
#
|
|
646
|
+
async #Le(e, t) {
|
|
647
|
+
if (e.revoke || !this.#Re(e.url, t)) return {
|
|
648
|
+
url: e.url,
|
|
649
|
+
revoke: e.revoke ?? !1
|
|
650
|
+
};
|
|
651
|
+
try {
|
|
652
|
+
let t = await (await fetch(e.url)).blob();
|
|
653
|
+
return {
|
|
654
|
+
url: URL.createObjectURL(t),
|
|
655
|
+
revoke: !0
|
|
656
|
+
};
|
|
657
|
+
} catch {
|
|
658
|
+
return {
|
|
659
|
+
url: e.url,
|
|
660
|
+
revoke: !1
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
#Re(e, t) {
|
|
629
665
|
let n = t.defaultView?.location?.href;
|
|
630
666
|
if (!n) return !1;
|
|
631
667
|
try {
|
|
@@ -652,61 +688,62 @@ var J = class {
|
|
|
652
688
|
let i = t.toLowerCase().indexOf(r);
|
|
653
689
|
i < 0 || a.push({
|
|
654
690
|
page: e,
|
|
655
|
-
excerpt:
|
|
691
|
+
excerpt: se(t, i, r.length)
|
|
656
692
|
});
|
|
657
693
|
}
|
|
658
694
|
return a;
|
|
659
695
|
}
|
|
660
696
|
flipNext() {
|
|
661
|
-
this.#
|
|
697
|
+
this.#ze(1);
|
|
662
698
|
}
|
|
663
699
|
flipPrev() {
|
|
664
|
-
this.#
|
|
700
|
+
this.#ze(-1);
|
|
665
701
|
}
|
|
666
|
-
#
|
|
667
|
-
this.#
|
|
702
|
+
#ze(e) {
|
|
703
|
+
this.#Be(() => this.#Ge(this.#B + e));
|
|
668
704
|
}
|
|
669
705
|
flipTo(e) {
|
|
670
706
|
let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
|
|
671
|
-
this.#
|
|
707
|
+
this.#Be(() => this.#Ge(this.#pn(t)));
|
|
672
708
|
}
|
|
673
|
-
#
|
|
674
|
-
this.#i.state === "idle" ? e() : this.#
|
|
709
|
+
#Be(e) {
|
|
710
|
+
this.#i.state === "idle" ? e() : this.#ce ? (this.#se = null, this.#Ve(), e()) : this.#se = e;
|
|
675
711
|
}
|
|
676
|
-
#
|
|
677
|
-
let e = this.#
|
|
678
|
-
e && (this.#
|
|
712
|
+
#Ve() {
|
|
713
|
+
let e = this.#ce;
|
|
714
|
+
e && (this.#ce = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#$?.setFlipProgress(e.toT, e.direction), e.onDone());
|
|
679
715
|
}
|
|
680
|
-
#
|
|
681
|
-
let e = this.#
|
|
716
|
+
#He() {
|
|
717
|
+
let e = this.#se;
|
|
682
718
|
if (!e) {
|
|
683
|
-
this.#
|
|
719
|
+
this.#sn();
|
|
684
720
|
return;
|
|
685
721
|
}
|
|
686
|
-
this.#
|
|
722
|
+
this.#se = null, e();
|
|
687
723
|
}
|
|
688
724
|
getZoom() {
|
|
689
|
-
return this.#
|
|
725
|
+
return this.#X;
|
|
690
726
|
}
|
|
691
727
|
setZoom(e, t) {
|
|
692
|
-
if (!this
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
728
|
+
if (!this.#$ || !this.#W) return;
|
|
729
|
+
this.#gt(), this.#yt();
|
|
730
|
+
let n = Y(e, 1, this.#q), r = this.#$.measure(), i = r.screenAt?.(this.#X), a = t ?? (i ? {
|
|
731
|
+
x: i.x + this.#Z + i.width / 2,
|
|
732
|
+
y: i.y + this.#Q + i.height / 2
|
|
696
733
|
} : null) ?? {
|
|
697
734
|
x: r.containerWidth / 2,
|
|
698
735
|
y: r.containerHeight / 2
|
|
699
|
-
}, o = this.#
|
|
700
|
-
[s, c] = this.#
|
|
736
|
+
}, o = this.#X, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#Z), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#Q);
|
|
737
|
+
[s, c] = this.#We(s, c, n, r.containerWidth, r.containerHeight), this.#X = n, this.#Z = s, this.#Q = c, this.#$.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Ue(), this.#rn(), this.#lt(), o <= 1 && n > 1 && (this.#ft("zoom"), this.#bt()), this.#n.emit("zoomChanged", { scale: n });
|
|
701
738
|
}
|
|
702
739
|
resetZoom() {
|
|
703
740
|
this.setZoom(1);
|
|
704
741
|
}
|
|
705
|
-
#
|
|
706
|
-
this.#e.style.touchAction = this.#
|
|
742
|
+
#Ue() {
|
|
743
|
+
this.#e.style.touchAction = this.#X > 1 ? "none" : "pan-y";
|
|
707
744
|
}
|
|
708
|
-
#
|
|
709
|
-
let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this
|
|
745
|
+
#We(e, t, n, r, i) {
|
|
746
|
+
let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#$?.measure().screenAt?.(n) ?? {
|
|
710
747
|
x: 0,
|
|
711
748
|
y: 0,
|
|
712
749
|
width: r * n,
|
|
@@ -718,31 +755,31 @@ var J = class {
|
|
|
718
755
|
return this.#n.on(e, t);
|
|
719
756
|
}
|
|
720
757
|
destroy() {
|
|
721
|
-
this.#
|
|
758
|
+
this.#te = !0, this.#ne !== null && cancelAnimationFrame(this.#ne), this.#ce = null, this.#se = null, this.#Et(), this.#mt(), this.#gt(), this.#yt(), this.#Tt(), this.#St(), this.#J?.disconnect(), this.#L?.stop(), this.#L = null, this.#R?.(), this.#F && b(), this.#Te?.(), this.#De?.(), this.#zt(), this.#xe?.(), this.#ge?.(), this.#ve?.(), this.#_e?.(), this.#m?.(), this.#he?.(), this.#Fe !== null && clearTimeout(this.#Fe), this.#Pe++, this.#$?.destroy(), this.#$ = null, this.#t.destroy(), this.#n.clear();
|
|
722
759
|
}
|
|
723
|
-
#
|
|
724
|
-
if (e < 0 || e >= this.#
|
|
725
|
-
let t = e > this.#
|
|
760
|
+
#Ge(e) {
|
|
761
|
+
if (e < 0 || e >= this.#z.length || e === this.#B || (this.#gt(), this.#yt(), this.#i.send("flip") === null)) return;
|
|
762
|
+
let t = e > this.#B ? "forward" : "backward", n = this.#Xe(e);
|
|
726
763
|
this.#n.emit("flipStart", {
|
|
727
|
-
from: this.#
|
|
764
|
+
from: this.#V,
|
|
728
765
|
to: n
|
|
729
|
-
}), this.#
|
|
766
|
+
}), this.#Ke(e, t, n, ++this.#le);
|
|
730
767
|
}
|
|
731
|
-
async #
|
|
732
|
-
let i = this.#
|
|
768
|
+
async #Ke(e, t, n, r) {
|
|
769
|
+
let i = this.#z[e], a = i ? await this.#un(i) : {
|
|
733
770
|
left: null,
|
|
734
771
|
right: null
|
|
735
772
|
};
|
|
736
|
-
r === this.#
|
|
737
|
-
fill: this.#
|
|
738
|
-
curl: this.#
|
|
773
|
+
r === this.#le && (this.#$?.beginFlip(this.#H, a, t, {
|
|
774
|
+
fill: this.#k,
|
|
775
|
+
curl: this.#Yt(),
|
|
739
776
|
anchor: { y: this.#l }
|
|
740
|
-
}), this.#
|
|
777
|
+
}), this.#qe(0, 1, t, () => this.#Ye(e, n, a), () => this.#Je(n)));
|
|
741
778
|
}
|
|
742
|
-
#
|
|
743
|
-
let a = this.#
|
|
779
|
+
#qe(e, t, n, r, i) {
|
|
780
|
+
let a = this.#Jt() * Math.abs(t - e);
|
|
744
781
|
if (a <= 0) {
|
|
745
|
-
this
|
|
782
|
+
this.#$?.setFlipProgress(t, n), r();
|
|
746
783
|
return;
|
|
747
784
|
}
|
|
748
785
|
let o = {
|
|
@@ -750,60 +787,60 @@ var J = class {
|
|
|
750
787
|
direction: n,
|
|
751
788
|
onDone: r
|
|
752
789
|
};
|
|
753
|
-
this.#
|
|
790
|
+
this.#ce = o;
|
|
754
791
|
let s = performance.now(), c = !1, l = (u) => {
|
|
755
|
-
if (this.#
|
|
756
|
-
let d = Math.min(1, (u - s) / a), f =
|
|
757
|
-
i && !c && f >= (this.#
|
|
792
|
+
if (this.#ce !== o) return;
|
|
793
|
+
let d = Math.min(1, (u - s) / a), f = Z(d);
|
|
794
|
+
i && !c && f >= (this.#k ? H : V) && (c = !0, i()), d < 1 ? (this.#$?.setFlipProgress(e + (t - e) * f, n), this.#ne = requestAnimationFrame(l)) : (this.#$?.setFlipProgress(t, n), this.#ne = null, this.#ce = null, r());
|
|
758
795
|
};
|
|
759
|
-
this.#
|
|
796
|
+
this.#ne = requestAnimationFrame(l);
|
|
760
797
|
}
|
|
761
|
-
#
|
|
762
|
-
this.#
|
|
798
|
+
#Je(e) {
|
|
799
|
+
this.#V !== e && (this.#V = e, this.#qt(), this.#n.emit("pageChanged", { page: e }));
|
|
763
800
|
}
|
|
764
|
-
#
|
|
765
|
-
let r = this.#
|
|
766
|
-
this.#
|
|
801
|
+
#Ye(e, t, n) {
|
|
802
|
+
let r = this.#z[e];
|
|
803
|
+
this.#B = e, this.#H = n, r && this.#en(r, n), this.#fn(), this.#i.send("settle"), this.#be = performance.now(), this.#Je(t), this.#ft("turn"), this.#lt(), this.#n.emit("flipEnd", { page: t }), this.#He();
|
|
767
804
|
}
|
|
768
|
-
#
|
|
769
|
-
let t = this.#
|
|
770
|
-
if (!t) return this.#
|
|
805
|
+
#Xe(e) {
|
|
806
|
+
let t = this.#z[e];
|
|
807
|
+
if (!t) return this.#V;
|
|
771
808
|
let n = [t.left, t.right].filter((e) => e !== null);
|
|
772
|
-
return n.length > 0 ? Math.min(...n) : this.#
|
|
809
|
+
return n.length > 0 ? Math.min(...n) : this.#V;
|
|
773
810
|
}
|
|
774
|
-
#
|
|
775
|
-
if (this.#
|
|
776
|
-
if (this.#
|
|
811
|
+
#Ze(e, t) {
|
|
812
|
+
if (this.#de || !this.#$) return;
|
|
813
|
+
if (this.#yt(), this.#Et(), this.#X > 1) {
|
|
777
814
|
if (this.#i.send("panStart") === null) return;
|
|
778
|
-
this.#
|
|
779
|
-
baseTx: this.#
|
|
780
|
-
baseTy: this.#
|
|
815
|
+
this.#ue = {
|
|
816
|
+
baseTx: this.#Z,
|
|
817
|
+
baseTy: this.#Q
|
|
781
818
|
};
|
|
782
819
|
return;
|
|
783
820
|
}
|
|
784
|
-
let n = this.#
|
|
785
|
-
this.#
|
|
786
|
-
let i = Math.min(n.width, n.height) *
|
|
821
|
+
let n = this.#it(), r = this.#at(e, t);
|
|
822
|
+
this.#ae = r;
|
|
823
|
+
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;
|
|
787
824
|
if (this.#i.state !== "idle") {
|
|
788
|
-
if (!this.#
|
|
789
|
-
this.#
|
|
825
|
+
if (!this.#ce || !s) {
|
|
826
|
+
this.#ie = null;
|
|
790
827
|
return;
|
|
791
828
|
}
|
|
792
|
-
this.#
|
|
829
|
+
this.#Ve();
|
|
793
830
|
}
|
|
794
831
|
if (!s) return;
|
|
795
832
|
this.#l = Y(r.y / n.height, 0, 1);
|
|
796
|
-
let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#
|
|
797
|
-
u < 0 || u >= this.#
|
|
833
|
+
let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#B + (l ? 1 : -1);
|
|
834
|
+
u < 0 || u >= this.#z.length || (this.#ie = {
|
|
798
835
|
direction: l ? "forward" : "backward",
|
|
799
836
|
targetIndex: u,
|
|
800
|
-
toPage: this.#
|
|
837
|
+
toPage: this.#Xe(u),
|
|
801
838
|
width: n.width
|
|
802
839
|
});
|
|
803
840
|
}
|
|
804
|
-
#
|
|
805
|
-
let e = this.#
|
|
806
|
-
e && (this.#
|
|
841
|
+
#Qe() {
|
|
842
|
+
let e = this.#ie;
|
|
843
|
+
e && (this.#ie = null, this.#i.send("grab") !== null && (this.#re = {
|
|
807
844
|
direction: e.direction,
|
|
808
845
|
targetIndex: e.targetIndex,
|
|
809
846
|
toPage: e.toPage,
|
|
@@ -814,71 +851,75 @@ var J = class {
|
|
|
814
851
|
width: e.width,
|
|
815
852
|
t: 0
|
|
816
853
|
}, this.#n.emit("flipStart", {
|
|
817
|
-
from: this.#
|
|
854
|
+
from: this.#V,
|
|
818
855
|
to: e.toPage
|
|
819
|
-
}), this
|
|
856
|
+
}), this.#$e(e.targetIndex, e.direction)));
|
|
820
857
|
}
|
|
821
|
-
async
|
|
822
|
-
let n = this.#
|
|
858
|
+
async #$e(e, t) {
|
|
859
|
+
let n = this.#z[e], r = n ? await this.#un(n) : {
|
|
823
860
|
left: null,
|
|
824
861
|
right: null
|
|
825
862
|
};
|
|
826
|
-
this.#
|
|
827
|
-
fill: this.#
|
|
828
|
-
curl: this.#
|
|
863
|
+
this.#re?.targetIndex === e && (this.#re.toContent = r, this.#$?.beginFlip(this.#H, r, t, {
|
|
864
|
+
fill: this.#k,
|
|
865
|
+
curl: this.#Yt(),
|
|
829
866
|
anchor: { y: this.#l }
|
|
830
|
-
}), this
|
|
831
|
-
}
|
|
832
|
-
#
|
|
833
|
-
if (this.#
|
|
834
|
-
if (this.#
|
|
835
|
-
if (!this
|
|
836
|
-
let n = this
|
|
837
|
-
this.#
|
|
867
|
+
}), this.#$?.setFlipProgress(this.#re.t, t));
|
|
868
|
+
}
|
|
869
|
+
#et(e, t) {
|
|
870
|
+
if (this.#de) return;
|
|
871
|
+
if (this.#ue) {
|
|
872
|
+
if (!this.#$) return;
|
|
873
|
+
let n = this.#$.measure(), [r, i] = this.#We(this.#ue.baseTx + e, this.#ue.baseTy + t, this.#X, n.containerWidth, n.containerHeight);
|
|
874
|
+
this.#Z = r, this.#Q = i, this.#$.setViewTransform(this.#X, r, i), this.#rn(), this.#ft("pan"), this.#St();
|
|
838
875
|
return;
|
|
839
876
|
}
|
|
840
|
-
this.#
|
|
841
|
-
let n = this.#
|
|
842
|
-
n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this
|
|
843
|
-
}
|
|
844
|
-
#
|
|
845
|
-
if (this.#
|
|
846
|
-
if (this.#
|
|
847
|
-
this.#
|
|
877
|
+
this.#ie && Math.hypot(e, t) > j && this.#Qe();
|
|
878
|
+
let n = this.#re;
|
|
879
|
+
n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#$?.setFlipProgress(n.t, n.direction));
|
|
880
|
+
}
|
|
881
|
+
#tt(e) {
|
|
882
|
+
if (this.#de) return;
|
|
883
|
+
if (this.#ue) {
|
|
884
|
+
this.#ue = null, this.#i.send("panEnd"), this.#lt();
|
|
848
885
|
return;
|
|
849
886
|
}
|
|
850
|
-
let t = this.#
|
|
887
|
+
let t = this.#re;
|
|
851
888
|
if (!t) {
|
|
852
|
-
this.#
|
|
889
|
+
this.#ie = null, this.#nt(e) || this.#rt(e);
|
|
853
890
|
return;
|
|
854
891
|
}
|
|
855
|
-
this.#
|
|
892
|
+
this.#re = null, this.#i.send("release");
|
|
856
893
|
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.#
|
|
894
|
+
i || t.t >= .5 && !a ? this.#qe(t.t, 1, t.direction, () => this.#Ye(t.targetIndex, t.toPage, t.toContent), () => this.#Je(t.toPage)) : this.#qe(t.t, 0, t.direction, () => this.#Dt());
|
|
858
895
|
}
|
|
859
|
-
#
|
|
860
|
-
if (this.#
|
|
896
|
+
#nt(e) {
|
|
897
|
+
if (this.#X > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
|
|
861
898
|
let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
|
|
862
|
-
if (!this.#
|
|
899
|
+
if (!this.#st(n)) return this.#vt(n), !1;
|
|
863
900
|
let r = t ? 1 : -1;
|
|
864
|
-
return this.#
|
|
865
|
-
}
|
|
866
|
-
#
|
|
867
|
-
if (this.#u === "off" || this.#
|
|
868
|
-
let t = this.#
|
|
869
|
-
if (!t
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
901
|
+
return this.#Be(() => this.#Ge(this.#B + r)), !0;
|
|
902
|
+
}
|
|
903
|
+
#rt(e) {
|
|
904
|
+
if (this.#u === "off" || this.#X > 1 || !this.#ae || Math.abs(e.dx) > j || Math.abs(e.dy) > j) return;
|
|
905
|
+
let t = this.#ot(this.#ae);
|
|
906
|
+
if (!t) return;
|
|
907
|
+
if (!this.#st(t)) {
|
|
908
|
+
this.#vt(t);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
this.#l = Y(this.#ae.y / this.#it().height, 0, 1);
|
|
912
|
+
let n = t === "forward" ? 1 : -1, r = () => this.#Ge(this.#B + n);
|
|
913
|
+
if (this.#Et(), this.#D <= 0) {
|
|
914
|
+
this.#Be(r);
|
|
874
915
|
return;
|
|
875
916
|
}
|
|
876
|
-
this.#
|
|
877
|
-
this.#
|
|
878
|
-
}, this.#
|
|
917
|
+
this.#oe = setTimeout(() => {
|
|
918
|
+
this.#oe = null, this.#Be(r);
|
|
919
|
+
}, this.#D);
|
|
879
920
|
}
|
|
880
|
-
#
|
|
881
|
-
let e = this
|
|
921
|
+
#it() {
|
|
922
|
+
let e = this.#$.measure();
|
|
882
923
|
return e.content ?? e.book ?? {
|
|
883
924
|
x: 0,
|
|
884
925
|
y: 0,
|
|
@@ -886,213 +927,351 @@ var J = class {
|
|
|
886
927
|
height: e.containerHeight
|
|
887
928
|
};
|
|
888
929
|
}
|
|
889
|
-
#
|
|
890
|
-
let n = this.#e.getBoundingClientRect(), r = this.#
|
|
930
|
+
#at(e, t) {
|
|
931
|
+
let n = this.#e.getBoundingClientRect(), r = this.#it();
|
|
891
932
|
return {
|
|
892
933
|
x: e - n.left - r.x,
|
|
893
934
|
y: t - n.top - r.y
|
|
894
935
|
};
|
|
895
936
|
}
|
|
896
|
-
#
|
|
897
|
-
if (!this
|
|
898
|
-
let t = this.#
|
|
937
|
+
#ot(e) {
|
|
938
|
+
if (!this.#$) return null;
|
|
939
|
+
let t = this.#it().width, n;
|
|
899
940
|
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;
|
|
900
941
|
let r = this.#a === "rtl" ? "left" : "right";
|
|
901
942
|
return n === r ? "forward" : "backward";
|
|
902
943
|
}
|
|
903
|
-
#
|
|
904
|
-
let t = this.#
|
|
905
|
-
return t >= 0 && t < this.#
|
|
944
|
+
#st(e) {
|
|
945
|
+
let t = this.#B + (e === "forward" ? 1 : -1);
|
|
946
|
+
return t >= 0 && t < this.#z.length;
|
|
947
|
+
}
|
|
948
|
+
#ct() {
|
|
949
|
+
let e = (e) => {
|
|
950
|
+
let t = e;
|
|
951
|
+
this.#p = {
|
|
952
|
+
x: t.clientX,
|
|
953
|
+
y: t.clientY
|
|
954
|
+
}, this.#lt();
|
|
955
|
+
}, t = () => {
|
|
956
|
+
this.#p = null, this.#lt();
|
|
957
|
+
};
|
|
958
|
+
this.#e.addEventListener("pointermove", e), this.#e.addEventListener("pointerleave", t), this.#m = () => {
|
|
959
|
+
this.#e.removeEventListener("pointermove", e), this.#e.removeEventListener("pointerleave", t);
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
#lt() {
|
|
963
|
+
if (!this.#f || !this.#$) return;
|
|
964
|
+
let e = "";
|
|
965
|
+
this.#re || this.#ue ? e = "grabbing" : this.#p && (e = this.#ut(this.#p.x, this.#p.y)), this.#e.style.cursor = e;
|
|
966
|
+
}
|
|
967
|
+
#ut(e, t) {
|
|
968
|
+
if (!this.#$) return "";
|
|
969
|
+
let n = this.#it(), r = this.#at(e, t);
|
|
970
|
+
if (r.x < 0 || r.y < 0 || r.x > n.width || r.y > n.height) return "";
|
|
971
|
+
if (this.#X > 1) return "grab";
|
|
972
|
+
let i = this.#ot(r);
|
|
973
|
+
return i && this.#st(i) ? "pointer" : this.#W && this.#K !== null ? "zoom-in" : "";
|
|
974
|
+
}
|
|
975
|
+
#dt() {
|
|
976
|
+
try {
|
|
977
|
+
let e = localStorage.getItem(J);
|
|
978
|
+
if (!e) return;
|
|
979
|
+
let t = JSON.parse(e);
|
|
980
|
+
this.#_ = {
|
|
981
|
+
turn: t.turn === !0,
|
|
982
|
+
zoom: t.zoom === !0,
|
|
983
|
+
pan: t.pan === !0
|
|
984
|
+
};
|
|
985
|
+
} catch {}
|
|
906
986
|
}
|
|
907
|
-
#
|
|
908
|
-
this.#
|
|
987
|
+
#ft(e) {
|
|
988
|
+
if (!this.#_[e] && (this.#_[e] = !0, e === "turn" && this.#mt(), e === "zoom" && this.#Tt(), this.#g)) try {
|
|
989
|
+
localStorage.setItem(J, JSON.stringify(this.#_));
|
|
990
|
+
} catch {}
|
|
909
991
|
}
|
|
910
|
-
#
|
|
911
|
-
|
|
912
|
-
|
|
992
|
+
#pt() {
|
|
993
|
+
!this.#h || this.#pe || this.#_.turn || (this.#mt(), this.#v = setTimeout(() => {
|
|
994
|
+
this.#v = null, this.#ht();
|
|
995
|
+
}, K));
|
|
913
996
|
}
|
|
914
|
-
#
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
997
|
+
#mt() {
|
|
998
|
+
this.#v !== null && (clearTimeout(this.#v), this.#v = null);
|
|
999
|
+
}
|
|
1000
|
+
async #ht() {
|
|
1001
|
+
if (!this.#h || this.#pe || this.#_.turn || !this.#$ || typeof requestAnimationFrame != "function" || this.#i.state !== "idle") return;
|
|
1002
|
+
let e = this.#B + 1, t = this.#z[e];
|
|
1003
|
+
if (!t) return;
|
|
1004
|
+
let n = await this.#un(t);
|
|
1005
|
+
if (this.#te || this.#_.turn || this.#i.state !== "idle" || this.#y) return;
|
|
1006
|
+
this.#l = 1, this.#$.beginFlip(this.#H, n, "forward", {
|
|
1007
|
+
fill: this.#k,
|
|
1008
|
+
curl: this.#Yt(),
|
|
1009
|
+
anchor: { y: this.#l }
|
|
1010
|
+
});
|
|
1011
|
+
let r = {};
|
|
1012
|
+
this.#y = r;
|
|
1013
|
+
let i = performance.now(), a = U * 2, o = () => {
|
|
1014
|
+
if (this.#y !== r) return;
|
|
1015
|
+
let e = Math.min(1, (performance.now() - i) / a), t = oe * Math.sin(e * Math.PI);
|
|
1016
|
+
this.#$?.setFlipProgress(Math.max(0, t), "forward"), e < 1 ? this.#ne = requestAnimationFrame(o) : (this.#ne = null, this.#y = null, this.#_t());
|
|
1017
|
+
};
|
|
1018
|
+
this.#ne = requestAnimationFrame(o);
|
|
921
1019
|
}
|
|
922
|
-
#
|
|
923
|
-
|
|
1020
|
+
#gt() {
|
|
1021
|
+
this.#y && (this.#y = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#_t());
|
|
1022
|
+
}
|
|
1023
|
+
#_t() {
|
|
1024
|
+
let e = this.#z[this.#B];
|
|
1025
|
+
e && this.#i.state === "idle" && this.#en(e, this.#H);
|
|
1026
|
+
}
|
|
1027
|
+
#vt(e) {
|
|
1028
|
+
if (!this.#$ || typeof requestAnimationFrame != "function" || this.#pe || this.#i.state !== "idle" || this.#X > 1 || this.#b) return;
|
|
1029
|
+
let t = e === "forward", n = (this.#a === "rtl" ? !t : t) ? -1 : 1, r = {};
|
|
1030
|
+
this.#b = r;
|
|
1031
|
+
let i = performance.now(), a = () => {
|
|
1032
|
+
if (this.#b !== r) return;
|
|
1033
|
+
let e = Math.min(1, (performance.now() - i) / G), t = W * Math.sin(e * Math.PI);
|
|
1034
|
+
this.#$?.setViewTransform(1, n * t, 0), e < 1 ? this.#ne = requestAnimationFrame(a) : (this.#ne = null, this.#b = null, this.#$?.setViewTransform(1, 0, 0));
|
|
1035
|
+
};
|
|
1036
|
+
this.#ne = requestAnimationFrame(a);
|
|
1037
|
+
}
|
|
1038
|
+
#yt() {
|
|
1039
|
+
this.#b && (this.#b = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#$?.setViewTransform(1, 0, 0));
|
|
1040
|
+
}
|
|
1041
|
+
#bt() {
|
|
1042
|
+
this.#_.pan || this.#xt("Drag to move");
|
|
1043
|
+
}
|
|
1044
|
+
#xt(e) {
|
|
1045
|
+
if (!this.#h) return;
|
|
1046
|
+
let t = this.#e.ownerDocument;
|
|
1047
|
+
if (!t || typeof this.#e.appendChild != "function") return;
|
|
1048
|
+
this.#St();
|
|
1049
|
+
let n = t.createElement("div");
|
|
1050
|
+
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;";
|
|
1051
|
+
let r = !this.#pe && typeof requestAnimationFrame == "function";
|
|
1052
|
+
r && (n.style.transition = "opacity 200ms ease"), this.#e.appendChild(n), this.#x = n, r ? requestAnimationFrame(() => {
|
|
1053
|
+
this.#x === n && (n.style.opacity = "1");
|
|
1054
|
+
}) : n.style.opacity = "1", this.#S = setTimeout(() => this.#St(), q);
|
|
1055
|
+
}
|
|
1056
|
+
#St() {
|
|
1057
|
+
this.#S !== null && (clearTimeout(this.#S), this.#S = null), this.#x?.remove(), this.#x = null;
|
|
1058
|
+
}
|
|
1059
|
+
#Ct(e, t) {
|
|
1060
|
+
!this.#h || this.#_.zoom || this.#w || this.#T === "mouse" && this.#ut(e, t) === "zoom-in" && (this.#i.state === "animating" || performance.now() - this.#be <= P || (this.#Tt(), this.#C = setTimeout(() => {
|
|
1061
|
+
this.#C = null, !(this.#_.zoom || this.#w) && (this.#w = !0, this.#xt(this.#wt()));
|
|
1062
|
+
}, M)));
|
|
1063
|
+
}
|
|
1064
|
+
#wt() {
|
|
1065
|
+
let e = [];
|
|
1066
|
+
if (this.#K !== null && e.push("Double-click"), this.#G) {
|
|
1067
|
+
let t = this.#e.ownerDocument?.defaultView?.navigator, n = /Mac|iPhone|iPad/.test(t?.platform ?? "");
|
|
1068
|
+
e.push(`${n ? "⌘" : "Ctrl"}-scroll`);
|
|
1069
|
+
}
|
|
1070
|
+
return `${e.join(" or ")} to zoom`;
|
|
1071
|
+
}
|
|
1072
|
+
#Tt() {
|
|
1073
|
+
this.#C !== null && (clearTimeout(this.#C), this.#C = null);
|
|
1074
|
+
}
|
|
1075
|
+
#Et() {
|
|
1076
|
+
this.#oe !== null && (clearTimeout(this.#oe), this.#oe = null);
|
|
1077
|
+
}
|
|
1078
|
+
#Dt() {
|
|
1079
|
+
let e = this.#z[this.#B];
|
|
1080
|
+
e && this.#en(e, this.#H), this.#i.send("settle"), this.#lt(), this.#n.emit("flipEnd", { page: this.#V }), this.#He();
|
|
1081
|
+
}
|
|
1082
|
+
#Ot() {
|
|
1083
|
+
if (this.#ie = null, this.#Et(), this.#re) {
|
|
1084
|
+
this.#re = null, this.#i.send("release"), this.#i.send("settle");
|
|
1085
|
+
let e = this.#z[this.#B];
|
|
1086
|
+
e && this.#en(e, this.#H);
|
|
1087
|
+
} else this.#ue && (this.#ue = null, this.#i.send("panEnd"));
|
|
1088
|
+
this.#de = !0, this.#fe = this.#X;
|
|
1089
|
+
}
|
|
1090
|
+
#kt(e, t, n) {
|
|
1091
|
+
if (!this.#de) return;
|
|
924
1092
|
let r = this.#e.getBoundingClientRect();
|
|
925
|
-
this.setZoom(this.#
|
|
1093
|
+
this.setZoom(this.#fe * n, {
|
|
926
1094
|
x: e - r.left,
|
|
927
1095
|
y: t - r.top
|
|
928
1096
|
});
|
|
929
1097
|
}
|
|
930
|
-
#
|
|
931
|
-
this.#
|
|
1098
|
+
#At() {
|
|
1099
|
+
this.#de = !1;
|
|
932
1100
|
}
|
|
933
|
-
#
|
|
934
|
-
if (!this.#
|
|
1101
|
+
#jt() {
|
|
1102
|
+
if (!this.#I) return;
|
|
935
1103
|
let e = (e) => e.preventDefault();
|
|
936
|
-
this.#e.addEventListener("contextmenu", e), this.#
|
|
1104
|
+
this.#e.addEventListener("contextmenu", e), this.#_e = () => this.#e.removeEventListener("contextmenu", e);
|
|
937
1105
|
}
|
|
938
|
-
#
|
|
1106
|
+
#Mt() {
|
|
939
1107
|
let e = (e) => {
|
|
940
|
-
if (!this.#
|
|
1108
|
+
if (!this.#G || !this.#W || !(e.ctrlKey || e.metaKey)) return;
|
|
941
1109
|
e.preventDefault();
|
|
942
|
-
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY *
|
|
943
|
-
this.setZoom(this.#
|
|
1110
|
+
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * A);
|
|
1111
|
+
this.setZoom(this.#X * n, {
|
|
944
1112
|
x: e.clientX - t.left,
|
|
945
1113
|
y: e.clientY - t.top
|
|
946
1114
|
});
|
|
947
1115
|
};
|
|
948
|
-
this.#e.addEventListener("wheel", e, { passive: !1 }), this.#
|
|
1116
|
+
this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ge = () => this.#e.removeEventListener("wheel", e);
|
|
949
1117
|
}
|
|
950
|
-
#
|
|
1118
|
+
#Nt() {
|
|
951
1119
|
let e = (e) => {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
let
|
|
955
|
-
if (!
|
|
956
|
-
|
|
1120
|
+
this.#T = e.pointerType;
|
|
1121
|
+
}, t = (e) => {
|
|
1122
|
+
let t = this.#K;
|
|
1123
|
+
if (!this.#W || t === null || !this.#$) return;
|
|
1124
|
+
let n = performance.now(), r = this.#ye;
|
|
1125
|
+
if (!(r !== null && n - r.t <= M && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= N)) {
|
|
1126
|
+
this.#ye = {
|
|
957
1127
|
t: n,
|
|
958
1128
|
x: e.clientX,
|
|
959
1129
|
y: e.clientY
|
|
960
|
-
};
|
|
1130
|
+
}, this.#Ct(e.clientX, e.clientY);
|
|
961
1131
|
return;
|
|
962
1132
|
}
|
|
963
|
-
this.#
|
|
1133
|
+
this.#ye = null, this.#Tt(), this.#Pt(e.clientX, e.clientY, t);
|
|
1134
|
+
};
|
|
1135
|
+
this.#e.addEventListener("pointerdown", e), this.#e.addEventListener("click", t), this.#ve = () => {
|
|
1136
|
+
this.#e.removeEventListener("pointerdown", e), this.#e.removeEventListener("click", t);
|
|
964
1137
|
};
|
|
965
|
-
this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
|
|
966
1138
|
}
|
|
967
|
-
#
|
|
968
|
-
if (this.#
|
|
969
|
-
let n = this.#
|
|
970
|
-
if (r !== null && this.#
|
|
1139
|
+
#Pt(e, t, n) {
|
|
1140
|
+
if (this.#X <= 1 && this.#u !== "off" && !this.#E) {
|
|
1141
|
+
let n = this.#at(e, t), r = this.#ot(n);
|
|
1142
|
+
if (r !== null && this.#st(r) || this.#i.state === "animating" || performance.now() - this.#be <= P) return;
|
|
971
1143
|
}
|
|
972
|
-
this.#
|
|
973
|
-
let r = n.find((e) => e > this.#
|
|
1144
|
+
this.#Et();
|
|
1145
|
+
let r = n.find((e) => e > this.#X + 1e-6) ?? n[0] ?? this.#X, i = this.#e.getBoundingClientRect();
|
|
974
1146
|
this.setZoom(r, {
|
|
975
1147
|
x: e - i.left,
|
|
976
1148
|
y: t - i.top
|
|
977
1149
|
});
|
|
978
1150
|
}
|
|
979
|
-
async
|
|
980
|
-
let t =
|
|
981
|
-
if (this.#t.onProgress?.((e) => this.#
|
|
982
|
-
this.#
|
|
1151
|
+
async #Ft(e) {
|
|
1152
|
+
let t = E(e);
|
|
1153
|
+
if (this.#t.onProgress?.((e) => this.#It(e)), typeof this.#t.open == "function") {
|
|
1154
|
+
this.#Lt();
|
|
983
1155
|
try {
|
|
984
|
-
await this.#t.open(), this.#
|
|
1156
|
+
await this.#t.open(), this.#mn();
|
|
985
1157
|
} catch (e) {
|
|
986
|
-
throw this.#
|
|
1158
|
+
throw this.#zt(), e;
|
|
987
1159
|
}
|
|
988
|
-
this.#
|
|
1160
|
+
this.#Rt("preparing");
|
|
989
1161
|
}
|
|
990
|
-
this.#t.prefetch([this.#
|
|
991
|
-
let n = await t, r = await this.#
|
|
992
|
-
this
|
|
1162
|
+
this.#t.prefetch([this.#V]);
|
|
1163
|
+
let n = await t, r = await this.#Bt(n);
|
|
1164
|
+
this.#$ = r, this.#t.onPageUpdate?.((e) => this.#nn(e)), this.#Zt(r.measure().containerWidth);
|
|
993
1165
|
let i = new m({
|
|
994
|
-
onStart: (e) => this.#
|
|
995
|
-
onMove: (e) => this.#
|
|
996
|
-
onEnd: (e) => this.#
|
|
1166
|
+
onStart: (e) => this.#Ze(e.x, e.y),
|
|
1167
|
+
onMove: (e) => this.#et(e.dx, e.dy),
|
|
1168
|
+
onEnd: (e) => this.#tt(e)
|
|
997
1169
|
}), a = new _({
|
|
998
|
-
onPinchStart: () => this.#
|
|
999
|
-
onPinchMove: (e) => this.#
|
|
1000
|
-
onPinchEnd: () => this.#
|
|
1170
|
+
onPinchStart: () => this.#Ot(),
|
|
1171
|
+
onPinchMove: (e) => this.#kt(e.centerX, e.centerY, e.scale),
|
|
1172
|
+
onPinchEnd: () => this.#At()
|
|
1001
1173
|
});
|
|
1002
|
-
this.#
|
|
1174
|
+
this.#he = h(this.#e, {
|
|
1003
1175
|
pointer: i,
|
|
1004
1176
|
pinch: a
|
|
1005
|
-
}), this.#
|
|
1177
|
+
}), this.#Ue(), this.#Mt(), this.#Nt(), this.#jt(), this.#ct(), this.#Ht(), this.#xe = this.#Gt(), await this.#$t(), this.#zt(), this.#cn(), this.#fn(), this.#qt(), this.#Wt(), await this.#Ut(), this.#n.emit("ready"), this.#ht(), this.#pt();
|
|
1006
1178
|
}
|
|
1007
|
-
#
|
|
1008
|
-
this.#
|
|
1179
|
+
#It(e) {
|
|
1180
|
+
this.#je = e, this.#n.emit("progress", e), this.#Ae?.update(e);
|
|
1009
1181
|
}
|
|
1010
|
-
async #
|
|
1011
|
-
if (this.#
|
|
1182
|
+
async #Lt() {
|
|
1183
|
+
if (this.#ke === !1 || this.#te) return;
|
|
1012
1184
|
let e = this.#e;
|
|
1013
1185
|
if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
|
|
1014
|
-
let { mountLoading: t } = await import("./loading-
|
|
1015
|
-
if (this.#
|
|
1016
|
-
this.#
|
|
1186
|
+
let { mountLoading: t } = await import("./loading-DF88K9yJ.js");
|
|
1187
|
+
if (this.#Me === "done" || this.#te) return;
|
|
1188
|
+
this.#Ae = t(e), this.#je && this.#Ae.update(this.#je), this.#Me === "preparing" && this.#Ae.preparing();
|
|
1017
1189
|
} catch {}
|
|
1018
1190
|
}
|
|
1019
|
-
#
|
|
1020
|
-
this.#
|
|
1191
|
+
#Rt(e) {
|
|
1192
|
+
this.#Me !== "done" && (this.#Me = e, this.#Ae?.preparing());
|
|
1021
1193
|
}
|
|
1022
|
-
#
|
|
1023
|
-
this.#
|
|
1194
|
+
#zt() {
|
|
1195
|
+
this.#Me = "done", this.#Ae?.destroy(), this.#Ae = null;
|
|
1024
1196
|
}
|
|
1025
|
-
async #
|
|
1197
|
+
async #Bt(e) {
|
|
1026
1198
|
try {
|
|
1027
1199
|
return await e.mount(this.#e), e.onFatal?.(() => {
|
|
1028
|
-
this.#
|
|
1200
|
+
this.#Vt();
|
|
1029
1201
|
}), e;
|
|
1030
1202
|
} catch {
|
|
1031
1203
|
e.destroy();
|
|
1032
|
-
let t = await
|
|
1033
|
-
return await t.mount(this.#e), this.#
|
|
1204
|
+
let t = await E("css");
|
|
1205
|
+
return await t.mount(this.#e), this.#ee = !0, this.#n.emit("rendererFallback", {
|
|
1034
1206
|
from: "webgl2",
|
|
1035
1207
|
to: "css"
|
|
1036
1208
|
}), t;
|
|
1037
1209
|
}
|
|
1038
1210
|
}
|
|
1039
|
-
async #
|
|
1040
|
-
if (this.#
|
|
1041
|
-
this.#
|
|
1042
|
-
let e = await
|
|
1043
|
-
if (this.#
|
|
1211
|
+
async #Vt() {
|
|
1212
|
+
if (this.#ee || this.#te) return;
|
|
1213
|
+
this.#ee = !0, this.#$?.destroy(), this.#$ = null;
|
|
1214
|
+
let e = await E("css");
|
|
1215
|
+
if (this.#te) {
|
|
1044
1216
|
e.destroy();
|
|
1045
1217
|
return;
|
|
1046
1218
|
}
|
|
1047
|
-
await e.mount(this.#e), this
|
|
1219
|
+
await e.mount(this.#e), this.#$ = e, this.#Zt(e.measure().containerWidth), await this.#$t(), this.#n.emit("rendererFallback", {
|
|
1048
1220
|
from: "webgl2",
|
|
1049
1221
|
to: "css"
|
|
1050
1222
|
});
|
|
1051
1223
|
}
|
|
1052
|
-
#
|
|
1224
|
+
#Ht() {
|
|
1053
1225
|
if (typeof matchMedia != "function") return;
|
|
1054
1226
|
let e = matchMedia("(prefers-reduced-motion: reduce)");
|
|
1055
|
-
this
|
|
1056
|
-
this
|
|
1227
|
+
this.#pe = e.matches, e.addEventListener?.("change", (e) => {
|
|
1228
|
+
this.#pe = e.matches;
|
|
1057
1229
|
});
|
|
1058
1230
|
}
|
|
1059
|
-
async #
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1231
|
+
async #Ut() {
|
|
1232
|
+
let e = this.#we !== !1, t = this.#Ee !== !1;
|
|
1233
|
+
if (!e && !t || this.#te) return;
|
|
1234
|
+
let n = this.#e;
|
|
1235
|
+
if (!(!n.ownerDocument || typeof n.appendChild != "function")) try {
|
|
1236
|
+
let { mountControls: e, mountContextMenu: t } = await import("./controls-CcOu_19g.js");
|
|
1237
|
+
if (this.#te) return;
|
|
1238
|
+
if (this.#we !== !1) {
|
|
1239
|
+
let t = this.#we === !0 ? {} : this.#we;
|
|
1240
|
+
this.#Te = e(this, n, t, this.#Oe);
|
|
1241
|
+
}
|
|
1242
|
+
if (this.#Ee !== !1) {
|
|
1243
|
+
let e = this.#Ee === !0 ? {} : this.#Ee;
|
|
1244
|
+
this.#De = t(this, n, e, this.#Oe);
|
|
1245
|
+
}
|
|
1067
1246
|
} catch {}
|
|
1068
1247
|
}
|
|
1069
|
-
#
|
|
1070
|
-
if (!this.#
|
|
1248
|
+
#Wt() {
|
|
1249
|
+
if (!this.#F || globalThis.location === void 0) return;
|
|
1071
1250
|
let e = globalThis;
|
|
1072
|
-
this.#
|
|
1073
|
-
e !== this.#
|
|
1074
|
-
}), this.#
|
|
1075
|
-
this.#
|
|
1251
|
+
this.#L = C(e, (e) => {
|
|
1252
|
+
e !== this.#V && this.flipTo(e);
|
|
1253
|
+
}), this.#L.push(this.#V), this.#R = this.#n.on("pageChanged", ({ page: e }) => {
|
|
1254
|
+
this.#L?.push(e);
|
|
1076
1255
|
});
|
|
1077
1256
|
}
|
|
1078
|
-
pageLink(e = this.#
|
|
1257
|
+
pageLink(e = this.#V) {
|
|
1079
1258
|
let t = globalThis.location?.href ?? "";
|
|
1080
1259
|
if (!t) return "";
|
|
1081
1260
|
let n = new URL(t);
|
|
1082
|
-
return n.hash =
|
|
1261
|
+
return n.hash = S(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
|
|
1083
1262
|
}
|
|
1084
|
-
#
|
|
1263
|
+
#Gt() {
|
|
1085
1264
|
let e = this.#e, t = e.ownerDocument;
|
|
1086
1265
|
if (!t || typeof e.setAttribute != "function") return null;
|
|
1087
1266
|
e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
|
|
1088
|
-
let n = (e) => this.#
|
|
1267
|
+
let n = (e) => this.#Kt(e);
|
|
1089
1268
|
e.addEventListener("keydown", n);
|
|
1090
1269
|
let r = t.createElement("div");
|
|
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.#
|
|
1092
|
-
e.removeEventListener("keydown", n), r.remove(), this.#
|
|
1270
|
+
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.#me = r, () => {
|
|
1271
|
+
e.removeEventListener("keydown", n), r.remove(), this.#me = null;
|
|
1093
1272
|
};
|
|
1094
1273
|
}
|
|
1095
|
-
#
|
|
1274
|
+
#Kt(e) {
|
|
1096
1275
|
let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
1097
1276
|
switch (e.key) {
|
|
1098
1277
|
case "ArrowRight":
|
|
@@ -1108,92 +1287,98 @@ var J = class {
|
|
|
1108
1287
|
default: break;
|
|
1109
1288
|
}
|
|
1110
1289
|
}
|
|
1111
|
-
#
|
|
1112
|
-
this.#
|
|
1290
|
+
#qt() {
|
|
1291
|
+
this.#me && (this.#me.textContent = `Page ${this.#V + 1} of ${this.#t.pageCount}`);
|
|
1113
1292
|
}
|
|
1114
|
-
#
|
|
1115
|
-
return this
|
|
1293
|
+
#Jt() {
|
|
1294
|
+
return this.#pe ? B : this.#U * (this.#k ? F : 1);
|
|
1116
1295
|
}
|
|
1117
|
-
#
|
|
1118
|
-
return this
|
|
1296
|
+
#Yt() {
|
|
1297
|
+
return this.#pe ? "simple" : this.#c;
|
|
1119
1298
|
}
|
|
1120
1299
|
update() {
|
|
1121
|
-
!this
|
|
1300
|
+
!this.#$ || this.#i.state !== "idle" || (this.#Zt(this.#$.measure().containerWidth), this.#$t(), this.#lt());
|
|
1122
1301
|
}
|
|
1123
|
-
#
|
|
1124
|
-
return this.#
|
|
1302
|
+
#Xt() {
|
|
1303
|
+
return this.#j || this.#o === "single" ? "single" : this.#o;
|
|
1125
1304
|
}
|
|
1126
|
-
#
|
|
1127
|
-
let t = this.#
|
|
1128
|
-
t !== this.#
|
|
1305
|
+
#Zt(e) {
|
|
1306
|
+
let t = this.#M && o(e, this.#O);
|
|
1307
|
+
t !== this.#j && (this.#j = t, this.#Qt());
|
|
1129
1308
|
}
|
|
1130
|
-
#
|
|
1131
|
-
let e = this.#
|
|
1132
|
-
this.#
|
|
1309
|
+
#Qt() {
|
|
1310
|
+
let e = this.#Xt(), t = e !== this.#A;
|
|
1311
|
+
this.#A = e, this.#k = e === "single", this.#z = a(this.#t.pageCount, {
|
|
1133
1312
|
direction: this.#a,
|
|
1134
1313
|
mode: e
|
|
1135
|
-
}), this.#
|
|
1314
|
+
}), this.#B = this.#pn(this.#V), t && this.#n.emit("spreadChanged", {
|
|
1136
1315
|
mode: e,
|
|
1137
|
-
singlePage: this.#
|
|
1316
|
+
singlePage: this.#k
|
|
1138
1317
|
});
|
|
1139
1318
|
}
|
|
1140
|
-
async
|
|
1141
|
-
let e = this.#
|
|
1142
|
-
!e || !this
|
|
1319
|
+
async #$t() {
|
|
1320
|
+
let e = this.#z[this.#B];
|
|
1321
|
+
!e || !this.#$ || (this.#H = await this.#un(e), this.#en(e, this.#H));
|
|
1143
1322
|
}
|
|
1144
|
-
#
|
|
1145
|
-
this
|
|
1323
|
+
#en(e, t) {
|
|
1324
|
+
this.#$?.renderSpread(e, t, { fill: this.#k }), this.#tn(), this.#Ne = 1, this.#rn();
|
|
1146
1325
|
}
|
|
1147
|
-
#
|
|
1148
|
-
let e = this
|
|
1326
|
+
#tn() {
|
|
1327
|
+
let e = this.#$?.measure().book;
|
|
1149
1328
|
if (!e || e.width <= 0 || e.height <= 0) return;
|
|
1150
1329
|
let t = (e.width / e.height).toFixed(4);
|
|
1151
|
-
t !== this.#
|
|
1330
|
+
t !== this.#N && (this.#N = t, this.#e.style.aspectRatio = t);
|
|
1152
1331
|
}
|
|
1153
|
-
#
|
|
1332
|
+
#nn(e) {
|
|
1154
1333
|
if (this.#i.state !== "idle") {
|
|
1155
|
-
this.#
|
|
1334
|
+
this.#Ce.add(e);
|
|
1156
1335
|
return;
|
|
1157
1336
|
}
|
|
1158
|
-
let t = this.#
|
|
1159
|
-
t
|
|
1337
|
+
let t = this.#z[this.#B];
|
|
1338
|
+
if (!(!t || !(t.left === e || t.right === e))) {
|
|
1339
|
+
if (this.#X > 1) {
|
|
1340
|
+
this.#rn();
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
this.#$t();
|
|
1344
|
+
}
|
|
1160
1345
|
}
|
|
1161
|
-
#
|
|
1162
|
-
this.#
|
|
1163
|
-
let e = this.#
|
|
1164
|
-
if (e !== this.#
|
|
1346
|
+
#rn() {
|
|
1347
|
+
this.#Fe !== null && clearTimeout(this.#Fe);
|
|
1348
|
+
let e = this.#an();
|
|
1349
|
+
if (e !== this.#Ne) {
|
|
1165
1350
|
if (e === 1) {
|
|
1166
|
-
this.#
|
|
1351
|
+
this.#Pe++, this.#Ne = 1, this.#$t();
|
|
1167
1352
|
return;
|
|
1168
1353
|
}
|
|
1169
|
-
this.#
|
|
1170
|
-
this.#
|
|
1171
|
-
},
|
|
1354
|
+
this.#Fe = setTimeout(() => {
|
|
1355
|
+
this.#Fe = null, this.#on();
|
|
1356
|
+
}, L);
|
|
1172
1357
|
}
|
|
1173
1358
|
}
|
|
1174
|
-
#
|
|
1175
|
-
let e = this
|
|
1359
|
+
#in() {
|
|
1360
|
+
let e = this.#$?.measure(), t = e?.content ?? e?.book;
|
|
1176
1361
|
if (!t || t.width <= 0) return 1;
|
|
1177
|
-
let n = this.#
|
|
1362
|
+
let n = this.#H, r = +!!n.left + +!!n.right;
|
|
1178
1363
|
if (r === 0) return 1;
|
|
1179
1364
|
let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
|
|
1180
1365
|
for (let e of [n.left, n.right]) {
|
|
1181
1366
|
if (!e || e.width <= 0) continue;
|
|
1182
|
-
let t = e.width / this.#
|
|
1367
|
+
let t = e.width / this.#Ne;
|
|
1183
1368
|
o = Math.max(o, i * a / t);
|
|
1184
1369
|
}
|
|
1185
1370
|
return o === 0 ? 1 : o;
|
|
1186
1371
|
}
|
|
1187
|
-
#
|
|
1188
|
-
let e = Math.max(1,
|
|
1189
|
-
return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2,
|
|
1372
|
+
#an() {
|
|
1373
|
+
let e = Math.max(1, z / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#X <= 1 ? 1 : this.#X, n = this.#in() * Math.max(t, e);
|
|
1374
|
+
return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, R);
|
|
1190
1375
|
}
|
|
1191
|
-
async #
|
|
1192
|
-
let e = this.#
|
|
1193
|
-
if (!this
|
|
1194
|
-
let t = this.#
|
|
1195
|
-
if (t === 1 || t === this.#
|
|
1196
|
-
let n = ++this.#
|
|
1376
|
+
async #on() {
|
|
1377
|
+
let e = this.#z[this.#B];
|
|
1378
|
+
if (!this.#$ || !e) return;
|
|
1379
|
+
let t = this.#an();
|
|
1380
|
+
if (t === 1 || t === this.#Ne || this.#i.state !== "idle") return;
|
|
1381
|
+
let n = ++this.#Pe, r = {
|
|
1197
1382
|
x: 0,
|
|
1198
1383
|
y: 0,
|
|
1199
1384
|
width: 1,
|
|
@@ -1203,7 +1388,8 @@ var J = class {
|
|
|
1203
1388
|
try {
|
|
1204
1389
|
return await this.#t.get(e, {
|
|
1205
1390
|
scale: t,
|
|
1206
|
-
region: r
|
|
1391
|
+
region: r,
|
|
1392
|
+
maxSize: this.#$?.maxTextureSize
|
|
1207
1393
|
});
|
|
1208
1394
|
} catch (t) {
|
|
1209
1395
|
return this.#n.emit("sourceError", {
|
|
@@ -1212,34 +1398,34 @@ var J = class {
|
|
|
1212
1398
|
}), null;
|
|
1213
1399
|
}
|
|
1214
1400
|
}));
|
|
1215
|
-
if (n !== this.#
|
|
1216
|
-
let a = i[0] ??
|
|
1217
|
-
a === this.#
|
|
1401
|
+
if (n !== this.#Pe || this.#an() !== t || this.#i.state !== "idle") return;
|
|
1402
|
+
let a = i[0] ?? this.#H.left, o = i[1] ?? this.#H.right;
|
|
1403
|
+
a === this.#H.left && o === this.#H.right || (this.#Ne = t, this.#H = {
|
|
1218
1404
|
left: a,
|
|
1219
1405
|
right: o
|
|
1220
|
-
}, this
|
|
1406
|
+
}, this.#$.renderSpread(e, this.#H, { fill: this.#k }));
|
|
1221
1407
|
}
|
|
1222
|
-
#
|
|
1223
|
-
if (this.#
|
|
1224
|
-
let e = this.#
|
|
1225
|
-
this.#
|
|
1408
|
+
#sn() {
|
|
1409
|
+
if (this.#Ce.size === 0) return;
|
|
1410
|
+
let e = this.#z[this.#B], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#Ce.has(e));
|
|
1411
|
+
this.#Ce.clear(), t && (this.#X > 1 ? this.#rn() : this.#$t());
|
|
1226
1412
|
}
|
|
1227
|
-
#
|
|
1228
|
-
typeof ResizeObserver > "u" || (this.#
|
|
1413
|
+
#cn() {
|
|
1414
|
+
typeof ResizeObserver > "u" || (this.#J = new ResizeObserver(() => this.#ln()), this.#J.observe(this.#e));
|
|
1229
1415
|
}
|
|
1230
|
-
#
|
|
1231
|
-
this.#
|
|
1232
|
-
this.#
|
|
1416
|
+
#ln() {
|
|
1417
|
+
this.#Y || (this.#Y = !0, requestAnimationFrame(() => {
|
|
1418
|
+
this.#Y = !1, this.update();
|
|
1233
1419
|
}));
|
|
1234
1420
|
}
|
|
1235
|
-
async #
|
|
1236
|
-
let [t, n] = await Promise.all([this.#
|
|
1421
|
+
async #un(e) {
|
|
1422
|
+
let [t, n] = await Promise.all([this.#dn(e.left), this.#dn(e.right)]);
|
|
1237
1423
|
return {
|
|
1238
1424
|
left: t,
|
|
1239
1425
|
right: n
|
|
1240
1426
|
};
|
|
1241
1427
|
}
|
|
1242
|
-
async #
|
|
1428
|
+
async #dn(e) {
|
|
1243
1429
|
if (e === null) return null;
|
|
1244
1430
|
try {
|
|
1245
1431
|
return await this.#t.get(e);
|
|
@@ -1250,30 +1436,30 @@ var J = class {
|
|
|
1250
1436
|
}), null;
|
|
1251
1437
|
}
|
|
1252
1438
|
}
|
|
1253
|
-
#
|
|
1254
|
-
let { toMount: e } = this.#r.update(this.#
|
|
1439
|
+
#fn() {
|
|
1440
|
+
let { toMount: e } = this.#r.update(this.#B, this.#z.length), t = [];
|
|
1255
1441
|
for (let n of e) {
|
|
1256
|
-
let e = this.#
|
|
1442
|
+
let e = this.#z[n];
|
|
1257
1443
|
e?.left != null && t.push(e.left), e?.right != null && t.push(e.right);
|
|
1258
1444
|
}
|
|
1259
1445
|
this.#t.prefetch(t);
|
|
1260
1446
|
}
|
|
1261
|
-
#
|
|
1262
|
-
let t = this.#
|
|
1447
|
+
#pn(e) {
|
|
1448
|
+
let t = this.#z.findIndex((t) => t.left === e || t.right === e);
|
|
1263
1449
|
return t === -1 ? 0 : t;
|
|
1264
1450
|
}
|
|
1265
|
-
#
|
|
1451
|
+
#mn() {
|
|
1266
1452
|
let e = this.#t.pageCount;
|
|
1267
1453
|
if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
|
|
1268
|
-
let t = this.#
|
|
1454
|
+
let t = this.#P;
|
|
1269
1455
|
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}).`);
|
|
1270
|
-
let n = this.#
|
|
1271
|
-
this.#
|
|
1456
|
+
let n = this.#Xt();
|
|
1457
|
+
this.#k = n === "single", this.#z = a(e, {
|
|
1272
1458
|
direction: this.#a,
|
|
1273
1459
|
mode: n
|
|
1274
1460
|
});
|
|
1275
|
-
let r = this.#
|
|
1276
|
-
this.#
|
|
1461
|
+
let r = this.#F ? x(globalThis.location?.hash ?? "") : null;
|
|
1462
|
+
this.#V = Y(r ?? t ?? 0, 0, e - 1), this.#B = this.#pn(this.#V);
|
|
1277
1463
|
}
|
|
1278
1464
|
};
|
|
1279
1465
|
function Y(e, t, n) {
|
|
@@ -1289,13 +1475,10 @@ function X(e, t, n) {
|
|
|
1289
1475
|
function Z(e) {
|
|
1290
1476
|
return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
|
|
1291
1477
|
}
|
|
1292
|
-
function ne(e) {
|
|
1293
|
-
return 1 - (1 - Z(e)) ** 1.3;
|
|
1294
|
-
}
|
|
1295
1478
|
function Q(e) {
|
|
1296
1479
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1297
1480
|
}
|
|
1298
|
-
function
|
|
1481
|
+
function le(n, r) {
|
|
1299
1482
|
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)}.`);
|
|
1300
1483
|
if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
|
|
1301
1484
|
let i = r, a = i.source;
|
|
@@ -1340,25 +1523,36 @@ function re(n, r) {
|
|
|
1340
1523
|
].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
|
|
1341
1524
|
let p = u?.arrows;
|
|
1342
1525
|
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.
|
|
1344
|
-
if (m !== void 0 && !
|
|
1526
|
+
let m = i.contextMenu;
|
|
1527
|
+
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)}.`);
|
|
1528
|
+
let h = m?.colorScheme;
|
|
1529
|
+
if (h !== void 0 && ![
|
|
1530
|
+
"light",
|
|
1531
|
+
"dark",
|
|
1532
|
+
"auto"
|
|
1533
|
+
].includes(h)) throw Error(`Zine: contextMenu.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(h)}.`);
|
|
1534
|
+
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.");
|
|
1535
|
+
let g = i.hideControls;
|
|
1536
|
+
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)}.`);
|
|
1537
|
+
let _ = i.spreadMode;
|
|
1538
|
+
if (_ !== void 0 && ![
|
|
1345
1539
|
"double",
|
|
1346
1540
|
"single",
|
|
1347
1541
|
"cover",
|
|
1348
1542
|
"book"
|
|
1349
|
-
].includes(
|
|
1543
|
+
].includes(_)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(_)}.`);
|
|
1350
1544
|
for (let e of ["frontCover", "backCover"]) {
|
|
1351
1545
|
let t = i[e];
|
|
1352
1546
|
if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
|
|
1353
1547
|
}
|
|
1354
|
-
let
|
|
1355
|
-
if (
|
|
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),
|
|
1548
|
+
let v = i.pages;
|
|
1549
|
+
if (v !== void 0 && (typeof v != "object" || !v || Array.isArray(v))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
|
|
1550
|
+
$(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ue(i.zoom), de(i.renderer);
|
|
1357
1551
|
}
|
|
1358
1552
|
function $(e, t, n) {
|
|
1359
1553
|
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)}.`);
|
|
1360
1554
|
}
|
|
1361
|
-
function
|
|
1555
|
+
function ue(e) {
|
|
1362
1556
|
if (e === void 0) return;
|
|
1363
1557
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
|
|
1364
1558
|
let t = e;
|
|
@@ -1371,7 +1565,7 @@ function ie(e) {
|
|
|
1371
1565
|
}
|
|
1372
1566
|
$(t.max, "zoom.max", 1);
|
|
1373
1567
|
}
|
|
1374
|
-
function
|
|
1568
|
+
function de(e) {
|
|
1375
1569
|
if (e !== void 0) {
|
|
1376
1570
|
if (typeof e == "string") {
|
|
1377
1571
|
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.`);
|
|
@@ -1386,7 +1580,7 @@ function ae(e) {
|
|
|
1386
1580
|
}
|
|
1387
1581
|
//#endregion
|
|
1388
1582
|
//#region src/source/imageSource.ts
|
|
1389
|
-
var
|
|
1583
|
+
var fe = class {
|
|
1390
1584
|
pageCount;
|
|
1391
1585
|
fit;
|
|
1392
1586
|
#e;
|
|
@@ -1423,6 +1617,6 @@ var oe = class {
|
|
|
1423
1617
|
}
|
|
1424
1618
|
};
|
|
1425
1619
|
//#endregion
|
|
1426
|
-
export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS,
|
|
1620
|
+
export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, fe as ImageSource, ce as Zine, n as defineControl, r as getControl };
|
|
1427
1621
|
|
|
1428
1622
|
//# sourceMappingURL=index.js.map
|