@readium/navigator-html-injectables 2.4.2-beta.1 → 2.4.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -36,13 +36,13 @@ class Be {
|
|
|
36
36
|
}
|
|
37
37
|
register(t, e, i) {
|
|
38
38
|
Array.isArray(t) || (t = [t]), t.forEach((s) => {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
|
|
39
|
+
const r = this.registrar.get(s);
|
|
40
|
+
if (r && r.length >= 0) {
|
|
41
|
+
if (r.find((a) => a.module === e)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${e}`);
|
|
42
|
+
r.push({
|
|
43
43
|
cb: i,
|
|
44
44
|
module: e
|
|
45
|
-
}), this.registrar.set(s,
|
|
45
|
+
}), this.registrar.set(s, r);
|
|
46
46
|
} else
|
|
47
47
|
this.registrar.set(s, [{
|
|
48
48
|
cb: i,
|
|
@@ -53,7 +53,7 @@ class Be {
|
|
|
53
53
|
unregister(t, e) {
|
|
54
54
|
Array.isArray(t) || (t = [t]), t.forEach((i) => {
|
|
55
55
|
const s = this.registrar.get(i);
|
|
56
|
-
!s || s.length === 0 || s.splice(s.findIndex((
|
|
56
|
+
!s || s.length === 0 || s.splice(s.findIndex((r) => r.module === e), 1);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
unregisterAll(t) {
|
|
@@ -70,7 +70,7 @@ class Be {
|
|
|
70
70
|
}
|
|
71
71
|
send(t, e, i = void 0, s = []) {
|
|
72
72
|
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
|
-
const
|
|
73
|
+
const r = {
|
|
74
74
|
_readium: Z,
|
|
75
75
|
_channel: this.channelId,
|
|
76
76
|
id: i ?? Ue(),
|
|
@@ -79,13 +79,13 @@ class Be {
|
|
|
79
79
|
data: e
|
|
80
80
|
};
|
|
81
81
|
try {
|
|
82
|
-
this.destination.postMessage(
|
|
82
|
+
this.destination.postMessage(r, {
|
|
83
83
|
targetOrigin: this.origin,
|
|
84
84
|
transfer: s
|
|
85
85
|
});
|
|
86
86
|
} catch (o) {
|
|
87
87
|
if (s.length > 0) throw o;
|
|
88
|
-
this.destination.postMessage(
|
|
88
|
+
this.destination.postMessage(r, this.origin, s);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -316,10 +316,10 @@ class $ {
|
|
|
316
316
|
getNestedValue(t, e) {
|
|
317
317
|
const i = e.split(".");
|
|
318
318
|
let s = t;
|
|
319
|
-
for (const
|
|
319
|
+
for (const r of i) {
|
|
320
320
|
if (s == null)
|
|
321
321
|
return;
|
|
322
|
-
s = s[
|
|
322
|
+
s = s[r];
|
|
323
323
|
}
|
|
324
324
|
return s;
|
|
325
325
|
}
|
|
@@ -397,32 +397,32 @@ Object.defineProperty(R.prototype, "encryption", {
|
|
|
397
397
|
return kt.deserialize(this.otherProperties.encrypted);
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
|
-
function Ve(
|
|
401
|
-
return
|
|
400
|
+
function Ve(n) {
|
|
401
|
+
return n && Array.isArray(n) ? n : void 0;
|
|
402
402
|
}
|
|
403
|
-
function Ce(
|
|
404
|
-
return
|
|
403
|
+
function Ce(n) {
|
|
404
|
+
return n && typeof n == "string" ? [n] : Ve(n);
|
|
405
405
|
}
|
|
406
|
-
function ie(
|
|
407
|
-
return typeof
|
|
406
|
+
function ie(n) {
|
|
407
|
+
return typeof n == "string" ? new Date(n) : void 0;
|
|
408
408
|
}
|
|
409
|
-
function ht(
|
|
410
|
-
return isNaN(
|
|
409
|
+
function ht(n) {
|
|
410
|
+
return isNaN(n) ? void 0 : n;
|
|
411
411
|
}
|
|
412
|
-
function O(
|
|
413
|
-
return ht(
|
|
412
|
+
function O(n) {
|
|
413
|
+
return ht(n) !== void 0 && Math.sign(n) >= 0 ? n : void 0;
|
|
414
414
|
}
|
|
415
|
-
function Fe(
|
|
415
|
+
function Fe(n) {
|
|
416
416
|
const t = new Array();
|
|
417
|
-
return
|
|
417
|
+
return n.forEach((e) => t.push(e)), t;
|
|
418
418
|
}
|
|
419
|
-
class
|
|
419
|
+
class l {
|
|
420
420
|
/** Creates a MediaType object. */
|
|
421
421
|
constructor(t) {
|
|
422
422
|
let e, i, s = t.mediaType.replace(/\s/g, "").split(";");
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
if (e =
|
|
423
|
+
const r = s[0].split("/");
|
|
424
|
+
if (r.length === 2) {
|
|
425
|
+
if (e = r[0].toLowerCase().trim(), i = r[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
|
|
426
426
|
throw new Error("Invalid media type");
|
|
427
427
|
} else
|
|
428
428
|
throw new Error("Invalid media type");
|
|
@@ -434,8 +434,8 @@ class c {
|
|
|
434
434
|
o[g] = m;
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
const a = {},
|
|
438
|
-
|
|
437
|
+
const a = {}, c = Object.keys(o);
|
|
438
|
+
c.sort((p, v) => p.localeCompare(v)), c.forEach((p) => a[p] = o[p]);
|
|
439
439
|
let u = "";
|
|
440
440
|
for (const p in a) {
|
|
441
441
|
const v = a[p];
|
|
@@ -445,7 +445,7 @@ class c {
|
|
|
445
445
|
this.string = d, this.type = e, this.subtype = i, this.parameters = a, this.encoding = f, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
446
446
|
}
|
|
447
447
|
static parse(t) {
|
|
448
|
-
return new
|
|
448
|
+
return new l(t);
|
|
449
449
|
}
|
|
450
450
|
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
451
451
|
* Gives a hint on the underlying structure of this media type.
|
|
@@ -475,16 +475,16 @@ class c {
|
|
|
475
475
|
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
476
476
|
*/
|
|
477
477
|
contains(t) {
|
|
478
|
-
const e = typeof t == "string" ?
|
|
478
|
+
const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
|
|
479
479
|
if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
|
|
480
480
|
return !1;
|
|
481
481
|
const i = new Set(
|
|
482
|
-
Object.entries(this.parameters).map(([
|
|
482
|
+
Object.entries(this.parameters).map(([r, o]) => `${r}=${o}`)
|
|
483
483
|
), s = new Set(
|
|
484
|
-
Object.entries(e.parameters).map(([
|
|
484
|
+
Object.entries(e.parameters).map(([r, o]) => `${r}=${o}`)
|
|
485
485
|
);
|
|
486
|
-
for (const
|
|
487
|
-
if (!s.has(
|
|
486
|
+
for (const r of Array.from(i.values()))
|
|
487
|
+
if (!s.has(r))
|
|
488
488
|
return !1;
|
|
489
489
|
return !0;
|
|
490
490
|
}
|
|
@@ -494,7 +494,7 @@ class c {
|
|
|
494
494
|
* doesn't. This is basically like `contains`, but working in both direction.
|
|
495
495
|
*/
|
|
496
496
|
matches(t) {
|
|
497
|
-
const e = typeof t == "string" ?
|
|
497
|
+
const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
|
|
498
498
|
return this.contains(e) || e.contains(this);
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
@@ -513,39 +513,39 @@ class c {
|
|
|
513
513
|
/** Returns whether this media type is structured as a ZIP archive. */
|
|
514
514
|
get isZIP() {
|
|
515
515
|
return this.matchesAny(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
516
|
+
l.ZIP,
|
|
517
|
+
l.LCP_PROTECTED_AUDIOBOOK,
|
|
518
|
+
l.LCP_PROTECTED_PDF
|
|
519
519
|
) || this.structuredSyntaxSuffix === "+zip";
|
|
520
520
|
}
|
|
521
521
|
/** Returns whether this media type is structured as a JSON file. */
|
|
522
522
|
get isJSON() {
|
|
523
|
-
return this.matchesAny(
|
|
523
|
+
return this.matchesAny(l.JSON) || this.structuredSyntaxSuffix === "+json";
|
|
524
524
|
}
|
|
525
525
|
/** Returns whether this media type is of an OPDS feed. */
|
|
526
526
|
get isOPDS() {
|
|
527
527
|
return this.matchesAny(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
528
|
+
l.OPDS1,
|
|
529
|
+
l.OPDS1_ENTRY,
|
|
530
|
+
l.OPDS2,
|
|
531
|
+
l.OPDS2_PUBLICATION,
|
|
532
|
+
l.OPDS_AUTHENTICATION
|
|
533
533
|
) || this.structuredSyntaxSuffix === "+json";
|
|
534
534
|
}
|
|
535
535
|
/** Returns whether this media type is of an HTML document. */
|
|
536
536
|
get isHTML() {
|
|
537
|
-
return this.matchesAny(
|
|
537
|
+
return this.matchesAny(l.HTML, l.XHTML);
|
|
538
538
|
}
|
|
539
539
|
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
|
|
540
540
|
get isBitmap() {
|
|
541
541
|
return this.matchesAny(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
542
|
+
l.AVIF,
|
|
543
|
+
l.BMP,
|
|
544
|
+
l.GIF,
|
|
545
|
+
l.JPEG,
|
|
546
|
+
l.PNG,
|
|
547
|
+
l.TIFF,
|
|
548
|
+
l.WEBP
|
|
549
549
|
);
|
|
550
550
|
}
|
|
551
551
|
/** Returns whether this media type is of an audio clip. */
|
|
@@ -559,317 +559,317 @@ class c {
|
|
|
559
559
|
/** Returns whether this media type is of a Readium Web Publication Manifest. */
|
|
560
560
|
get isRWPM() {
|
|
561
561
|
return this.matchesAny(
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
562
|
+
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
563
|
+
l.DIVINA_MANIFEST,
|
|
564
|
+
l.READIUM_WEBPUB_MANIFEST
|
|
565
565
|
);
|
|
566
566
|
}
|
|
567
567
|
/** Returns whether this media type is of a publication file. */
|
|
568
568
|
get isPublication() {
|
|
569
569
|
return this.matchesAny(
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
570
|
+
l.READIUM_AUDIOBOOK,
|
|
571
|
+
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
572
|
+
l.CBZ,
|
|
573
|
+
l.DIVINA,
|
|
574
|
+
l.DIVINA_MANIFEST,
|
|
575
|
+
l.EPUB,
|
|
576
|
+
l.LCP_PROTECTED_AUDIOBOOK,
|
|
577
|
+
l.LCP_PROTECTED_PDF,
|
|
578
|
+
l.LPF,
|
|
579
|
+
l.PDF,
|
|
580
|
+
l.W3C_WPUB_MANIFEST,
|
|
581
|
+
l.READIUM_WEBPUB,
|
|
582
|
+
l.READIUM_WEBPUB_MANIFEST,
|
|
583
|
+
l.ZAB
|
|
584
584
|
);
|
|
585
585
|
}
|
|
586
586
|
// Known Media Types
|
|
587
587
|
static get AAC() {
|
|
588
|
-
return
|
|
588
|
+
return l.parse({ mediaType: "audio/aac", fileExtension: "aac" });
|
|
589
589
|
}
|
|
590
590
|
static get ACSM() {
|
|
591
|
-
return
|
|
591
|
+
return l.parse({
|
|
592
592
|
mediaType: "application/vnd.adobe.adept+xml",
|
|
593
593
|
name: "Adobe Content Server Message",
|
|
594
594
|
fileExtension: "acsm"
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
597
|
static get AIFF() {
|
|
598
|
-
return
|
|
598
|
+
return l.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });
|
|
599
599
|
}
|
|
600
600
|
static get AVI() {
|
|
601
|
-
return
|
|
601
|
+
return l.parse({
|
|
602
602
|
mediaType: "video/x-msvideo",
|
|
603
603
|
fileExtension: "avi"
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
606
|
static get AVIF() {
|
|
607
|
-
return
|
|
607
|
+
return l.parse({ mediaType: "image/avif", fileExtension: "avif" });
|
|
608
608
|
}
|
|
609
609
|
static get BINARY() {
|
|
610
|
-
return
|
|
610
|
+
return l.parse({ mediaType: "application/octet-stream" });
|
|
611
611
|
}
|
|
612
612
|
static get BMP() {
|
|
613
|
-
return
|
|
613
|
+
return l.parse({ mediaType: "image/bmp", fileExtension: "bmp" });
|
|
614
614
|
}
|
|
615
615
|
static get CBZ() {
|
|
616
|
-
return
|
|
616
|
+
return l.parse({
|
|
617
617
|
mediaType: "application/vnd.comicbook+zip",
|
|
618
618
|
name: "Comic Book Archive",
|
|
619
619
|
fileExtension: "cbz"
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
static get CSS() {
|
|
623
|
-
return
|
|
623
|
+
return l.parse({ mediaType: "text/css", fileExtension: "css" });
|
|
624
624
|
}
|
|
625
625
|
static get DIVINA() {
|
|
626
|
-
return
|
|
626
|
+
return l.parse({
|
|
627
627
|
mediaType: "application/divina+zip",
|
|
628
628
|
name: "Digital Visual Narratives",
|
|
629
629
|
fileExtension: "divina"
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
632
|
static get DIVINA_MANIFEST() {
|
|
633
|
-
return
|
|
633
|
+
return l.parse({
|
|
634
634
|
mediaType: "application/divina+json",
|
|
635
635
|
name: "Digital Visual Narratives",
|
|
636
636
|
fileExtension: "json"
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
639
|
static get EPUB() {
|
|
640
|
-
return
|
|
640
|
+
return l.parse({
|
|
641
641
|
mediaType: "application/epub+zip",
|
|
642
642
|
name: "EPUB",
|
|
643
643
|
fileExtension: "epub"
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
static get GIF() {
|
|
647
|
-
return
|
|
647
|
+
return l.parse({ mediaType: "image/gif", fileExtension: "gif" });
|
|
648
648
|
}
|
|
649
649
|
static get GZ() {
|
|
650
|
-
return
|
|
650
|
+
return l.parse({
|
|
651
651
|
mediaType: "application/gzip",
|
|
652
652
|
fileExtension: "gz"
|
|
653
653
|
});
|
|
654
654
|
}
|
|
655
655
|
static get HTML() {
|
|
656
|
-
return
|
|
656
|
+
return l.parse({ mediaType: "text/html", fileExtension: "html" });
|
|
657
657
|
}
|
|
658
658
|
static get JAVASCRIPT() {
|
|
659
|
-
return
|
|
659
|
+
return l.parse({
|
|
660
660
|
mediaType: "text/javascript",
|
|
661
661
|
fileExtension: "js"
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
static get JPEG() {
|
|
665
|
-
return
|
|
665
|
+
return l.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });
|
|
666
666
|
}
|
|
667
667
|
static get JSON() {
|
|
668
|
-
return
|
|
668
|
+
return l.parse({ mediaType: "application/json" });
|
|
669
669
|
}
|
|
670
670
|
static get LCP_LICENSE_DOCUMENT() {
|
|
671
|
-
return
|
|
671
|
+
return l.parse({
|
|
672
672
|
mediaType: "application/vnd.readium.lcp.license.v1.0+json",
|
|
673
673
|
name: "LCP License",
|
|
674
674
|
fileExtension: "lcpl"
|
|
675
675
|
});
|
|
676
676
|
}
|
|
677
677
|
static get LCP_PROTECTED_AUDIOBOOK() {
|
|
678
|
-
return
|
|
678
|
+
return l.parse({
|
|
679
679
|
mediaType: "application/audiobook+lcp",
|
|
680
680
|
name: "LCP Protected Audiobook",
|
|
681
681
|
fileExtension: "lcpa"
|
|
682
682
|
});
|
|
683
683
|
}
|
|
684
684
|
static get LCP_PROTECTED_PDF() {
|
|
685
|
-
return
|
|
685
|
+
return l.parse({
|
|
686
686
|
mediaType: "application/pdf+lcp",
|
|
687
687
|
name: "LCP Protected PDF",
|
|
688
688
|
fileExtension: "lcpdf"
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
691
|
static get LCP_STATUS_DOCUMENT() {
|
|
692
|
-
return
|
|
692
|
+
return l.parse({
|
|
693
693
|
mediaType: "application/vnd.readium.license.status.v1.0+json"
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
696
|
static get LPF() {
|
|
697
|
-
return
|
|
697
|
+
return l.parse({
|
|
698
698
|
mediaType: "application/lpf+zip",
|
|
699
699
|
fileExtension: "lpf"
|
|
700
700
|
});
|
|
701
701
|
}
|
|
702
702
|
static get MP3() {
|
|
703
|
-
return
|
|
703
|
+
return l.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });
|
|
704
704
|
}
|
|
705
705
|
static get MPEG() {
|
|
706
|
-
return
|
|
706
|
+
return l.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });
|
|
707
707
|
}
|
|
708
708
|
static get NCX() {
|
|
709
|
-
return
|
|
709
|
+
return l.parse({
|
|
710
710
|
mediaType: "application/x-dtbncx+xml",
|
|
711
711
|
fileExtension: "ncx"
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
714
|
static get OGG() {
|
|
715
|
-
return
|
|
715
|
+
return l.parse({ mediaType: "audio/ogg", fileExtension: "oga" });
|
|
716
716
|
}
|
|
717
717
|
static get OGV() {
|
|
718
|
-
return
|
|
718
|
+
return l.parse({ mediaType: "video/ogg", fileExtension: "ogv" });
|
|
719
719
|
}
|
|
720
720
|
static get OPDS1() {
|
|
721
|
-
return
|
|
721
|
+
return l.parse({
|
|
722
722
|
mediaType: "application/atom+xml;profile=opds-catalog"
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
725
|
static get OPDS1_ENTRY() {
|
|
726
|
-
return
|
|
726
|
+
return l.parse({
|
|
727
727
|
mediaType: "application/atom+xml;type=entry;profile=opds-catalog"
|
|
728
728
|
});
|
|
729
729
|
}
|
|
730
730
|
static get OPDS2() {
|
|
731
|
-
return
|
|
731
|
+
return l.parse({ mediaType: "application/opds+json" });
|
|
732
732
|
}
|
|
733
733
|
static get OPDS2_PUBLICATION() {
|
|
734
|
-
return
|
|
734
|
+
return l.parse({ mediaType: "application/opds-publication+json" });
|
|
735
735
|
}
|
|
736
736
|
static get OPDS_AUTHENTICATION() {
|
|
737
|
-
return
|
|
737
|
+
return l.parse({
|
|
738
738
|
mediaType: "application/opds-authentication+json"
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
static get OPUS() {
|
|
742
|
-
return
|
|
742
|
+
return l.parse({ mediaType: "audio/opus", fileExtension: "opus" });
|
|
743
743
|
}
|
|
744
744
|
static get OTF() {
|
|
745
|
-
return
|
|
745
|
+
return l.parse({ mediaType: "font/otf", fileExtension: "otf" });
|
|
746
746
|
}
|
|
747
747
|
static get PDF() {
|
|
748
|
-
return
|
|
748
|
+
return l.parse({
|
|
749
749
|
mediaType: "application/pdf",
|
|
750
750
|
name: "PDF",
|
|
751
751
|
fileExtension: "pdf"
|
|
752
752
|
});
|
|
753
753
|
}
|
|
754
754
|
static get PNG() {
|
|
755
|
-
return
|
|
755
|
+
return l.parse({ mediaType: "image/png", fileExtension: "png" });
|
|
756
756
|
}
|
|
757
757
|
static get READIUM_AUDIOBOOK() {
|
|
758
|
-
return
|
|
758
|
+
return l.parse({
|
|
759
759
|
mediaType: "application/audiobook+zip",
|
|
760
760
|
name: "Readium Audiobook",
|
|
761
761
|
fileExtension: "audiobook"
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
static get READIUM_AUDIOBOOK_MANIFEST() {
|
|
765
|
-
return
|
|
765
|
+
return l.parse({
|
|
766
766
|
mediaType: "application/audiobook+json",
|
|
767
767
|
name: "Readium Audiobook",
|
|
768
768
|
fileExtension: "json"
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
771
|
static get READIUM_CONTENT_DOCUMENT() {
|
|
772
|
-
return
|
|
772
|
+
return l.parse({
|
|
773
773
|
mediaType: "application/vnd.readium.content+json",
|
|
774
774
|
name: "Readium Content Document",
|
|
775
775
|
fileExtension: "json"
|
|
776
776
|
});
|
|
777
777
|
}
|
|
778
778
|
static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {
|
|
779
|
-
return
|
|
779
|
+
return l.parse({
|
|
780
780
|
mediaType: "application/guided-navigation+json",
|
|
781
781
|
name: "Readium Guided Navigation Document",
|
|
782
782
|
fileExtension: "json"
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
static get READIUM_POSITION_LIST() {
|
|
786
|
-
return
|
|
786
|
+
return l.parse({
|
|
787
787
|
mediaType: "application/vnd.readium.position-list+json",
|
|
788
788
|
name: "Readium Position List",
|
|
789
789
|
fileExtension: "json"
|
|
790
790
|
});
|
|
791
791
|
}
|
|
792
792
|
static get READIUM_WEBPUB() {
|
|
793
|
-
return
|
|
793
|
+
return l.parse({
|
|
794
794
|
mediaType: "application/webpub+zip",
|
|
795
795
|
name: "Readium Web Publication",
|
|
796
796
|
fileExtension: "webpub"
|
|
797
797
|
});
|
|
798
798
|
}
|
|
799
799
|
static get READIUM_WEBPUB_MANIFEST() {
|
|
800
|
-
return
|
|
800
|
+
return l.parse({
|
|
801
801
|
mediaType: "application/webpub+json",
|
|
802
802
|
name: "Readium Web Publication",
|
|
803
803
|
fileExtension: "json"
|
|
804
804
|
});
|
|
805
805
|
}
|
|
806
806
|
static get SMIL() {
|
|
807
|
-
return
|
|
807
|
+
return l.parse({
|
|
808
808
|
mediaType: "application/smil+xml",
|
|
809
809
|
fileExtension: "smil"
|
|
810
810
|
});
|
|
811
811
|
}
|
|
812
812
|
static get SVG() {
|
|
813
|
-
return
|
|
813
|
+
return l.parse({
|
|
814
814
|
mediaType: "image/svg+xml",
|
|
815
815
|
fileExtension: "svg"
|
|
816
816
|
});
|
|
817
817
|
}
|
|
818
818
|
static get TEXT() {
|
|
819
|
-
return
|
|
819
|
+
return l.parse({ mediaType: "text/plain", fileExtension: "txt" });
|
|
820
820
|
}
|
|
821
821
|
static get TIFF() {
|
|
822
|
-
return
|
|
822
|
+
return l.parse({ mediaType: "image/tiff", fileExtension: "tiff" });
|
|
823
823
|
}
|
|
824
824
|
static get TTF() {
|
|
825
|
-
return
|
|
825
|
+
return l.parse({ mediaType: "font/ttf", fileExtension: "ttf" });
|
|
826
826
|
}
|
|
827
827
|
static get W3C_WPUB_MANIFEST() {
|
|
828
|
-
return
|
|
828
|
+
return l.parse({
|
|
829
829
|
mediaType: "application/x.readium.w3c.wpub+json",
|
|
830
830
|
name: "Web Publication",
|
|
831
831
|
fileExtension: "json"
|
|
832
832
|
});
|
|
833
833
|
}
|
|
834
834
|
static get WAV() {
|
|
835
|
-
return
|
|
835
|
+
return l.parse({ mediaType: "audio/wav", fileExtension: "wav" });
|
|
836
836
|
}
|
|
837
837
|
static get WEBM_AUDIO() {
|
|
838
|
-
return
|
|
838
|
+
return l.parse({ mediaType: "audio/webm", fileExtension: "webm" });
|
|
839
839
|
}
|
|
840
840
|
static get WEBM_VIDEO() {
|
|
841
|
-
return
|
|
841
|
+
return l.parse({ mediaType: "video/webm", fileExtension: "webm" });
|
|
842
842
|
}
|
|
843
843
|
static get WEBP() {
|
|
844
|
-
return
|
|
844
|
+
return l.parse({ mediaType: "image/webp", fileExtension: "webp" });
|
|
845
845
|
}
|
|
846
846
|
static get WOFF() {
|
|
847
|
-
return
|
|
847
|
+
return l.parse({ mediaType: "font/woff", fileExtension: "woff" });
|
|
848
848
|
}
|
|
849
849
|
static get WOFF2() {
|
|
850
|
-
return
|
|
850
|
+
return l.parse({ mediaType: "font/woff2", fileExtension: "woff2" });
|
|
851
851
|
}
|
|
852
852
|
static get XHTML() {
|
|
853
|
-
return
|
|
853
|
+
return l.parse({
|
|
854
854
|
mediaType: "application/xhtml+xml",
|
|
855
855
|
fileExtension: "xhtml"
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
858
|
static get XML() {
|
|
859
|
-
return
|
|
859
|
+
return l.parse({
|
|
860
860
|
mediaType: "application/xml",
|
|
861
861
|
fileExtension: "xml"
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
static get ZAB() {
|
|
865
|
-
return
|
|
865
|
+
return l.parse({
|
|
866
866
|
mediaType: "application/x.readium.zab+zip",
|
|
867
867
|
name: "Zipped Audio Book",
|
|
868
868
|
fileExtension: "zab"
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
871
|
static get ZIP() {
|
|
872
|
-
return
|
|
872
|
+
return l.parse({
|
|
873
873
|
mediaType: "application/zip",
|
|
874
874
|
fileExtension: "zip"
|
|
875
875
|
});
|
|
@@ -893,11 +893,11 @@ class se {
|
|
|
893
893
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
894
894
|
*/
|
|
895
895
|
expand(t) {
|
|
896
|
-
const e = (s) => s.split(",").map((
|
|
897
|
-
const o = t[
|
|
896
|
+
const e = (s) => s.split(",").map((r) => {
|
|
897
|
+
const o = t[r];
|
|
898
898
|
return o ? encodeURIComponent(o) : "";
|
|
899
|
-
}).join(","), i = (s) => "?" + s.split(",").map((
|
|
900
|
-
const o =
|
|
899
|
+
}).join(","), i = (s) => "?" + s.split(",").map((r) => {
|
|
900
|
+
const o = r.split("=")[0], a = t[o];
|
|
901
901
|
return a ? `${o}=${encodeURIComponent(a)}` : "";
|
|
902
902
|
}).join("&");
|
|
903
903
|
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
|
|
@@ -915,21 +915,21 @@ class C {
|
|
|
915
915
|
*/
|
|
916
916
|
static deserialize(t) {
|
|
917
917
|
if (!t) return;
|
|
918
|
-
const e = ht(t.progression), i = ht(t.totalProgression), s = ht(t.position),
|
|
918
|
+
const e = ht(t.progression), i = ht(t.totalProgression), s = ht(t.position), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
919
919
|
"fragment",
|
|
920
920
|
"fragments",
|
|
921
921
|
"progression",
|
|
922
922
|
"totalProgression",
|
|
923
923
|
"position"
|
|
924
924
|
]);
|
|
925
|
-
return Object.entries(t).forEach(([a,
|
|
926
|
-
o.has(a) ||
|
|
925
|
+
return Object.entries(t).forEach(([a, c]) => {
|
|
926
|
+
o.has(a) || r.set(a, c);
|
|
927
927
|
}), new C({
|
|
928
928
|
fragments: Ce(t.fragments || t.fragment),
|
|
929
929
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
930
930
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
931
931
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
932
|
-
otherLocations:
|
|
932
|
+
otherLocations: r.size === 0 ? void 0 : r
|
|
933
933
|
});
|
|
934
934
|
}
|
|
935
935
|
/**
|
|
@@ -1044,7 +1044,7 @@ class q {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
/** MediaType of the linked resource. */
|
|
1046
1046
|
get mediaType() {
|
|
1047
|
-
return this.type !== void 0 ?
|
|
1047
|
+
return this.type !== void 0 ? l.parse({ mediaType: this.type }) : l.BINARY;
|
|
1048
1048
|
}
|
|
1049
1049
|
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
1050
1050
|
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
@@ -1257,33 +1257,33 @@ C.prototype.getDomRange = function() {
|
|
|
1257
1257
|
};
|
|
1258
1258
|
C.prototype.fragmentParameters = function() {
|
|
1259
1259
|
return new Map(
|
|
1260
|
-
this.fragments.map((
|
|
1261
|
-
|
|
1262
|
-
|
|
1260
|
+
this.fragments.map((n) => n.startsWith("#") ? n.slice(1) : n).join("&").split("&").filter((n) => !n.startsWith("#")).map((n) => n.split("=")).filter((n) => n.length === 2).map((n) => [
|
|
1261
|
+
n[0].trim().toLowerCase(),
|
|
1262
|
+
n[1].trim()
|
|
1263
1263
|
])
|
|
1264
1264
|
);
|
|
1265
1265
|
};
|
|
1266
1266
|
C.prototype.htmlId = function() {
|
|
1267
1267
|
if (!this.fragments.length) return;
|
|
1268
|
-
let
|
|
1269
|
-
if (!
|
|
1268
|
+
let n = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1269
|
+
if (!n) {
|
|
1270
1270
|
const t = this.fragmentParameters();
|
|
1271
|
-
t.has("id") ?
|
|
1271
|
+
t.has("id") ? n = t.get("id") : t.has("name") && (n = t.get("name"));
|
|
1272
1272
|
}
|
|
1273
|
-
return
|
|
1273
|
+
return n?.startsWith("#") ? n.slice(1) : n;
|
|
1274
1274
|
};
|
|
1275
1275
|
C.prototype.page = function() {
|
|
1276
|
-
const
|
|
1277
|
-
if (!isNaN(
|
|
1276
|
+
const n = parseInt(this.fragmentParameters().get("page"));
|
|
1277
|
+
if (!isNaN(n) && n >= 0) return n;
|
|
1278
1278
|
};
|
|
1279
1279
|
C.prototype.time = function() {
|
|
1280
|
-
const
|
|
1281
|
-
if (!isNaN(
|
|
1280
|
+
const n = parseInt(this.fragmentParameters().get("t"));
|
|
1281
|
+
if (!isNaN(n)) return n;
|
|
1282
1282
|
};
|
|
1283
1283
|
C.prototype.space = function() {
|
|
1284
|
-
const
|
|
1285
|
-
if (!
|
|
1286
|
-
const t =
|
|
1284
|
+
const n = this.fragmentParameters();
|
|
1285
|
+
if (!n.has("xywh")) return;
|
|
1286
|
+
const t = n.get("xywh").split(",").map((e) => parseInt(e));
|
|
1287
1287
|
if (t.length === 4 && !t.some(isNaN))
|
|
1288
1288
|
return t;
|
|
1289
1289
|
};
|
|
@@ -1415,9 +1415,9 @@ R.prototype.getPrice = function() {
|
|
|
1415
1415
|
return Ut.deserialize(this.otherProperties.price);
|
|
1416
1416
|
};
|
|
1417
1417
|
R.prototype.getIndirectAcquisitions = function() {
|
|
1418
|
-
const
|
|
1419
|
-
if (
|
|
1420
|
-
return
|
|
1418
|
+
const n = this.otherProperties.indirectAcquisition;
|
|
1419
|
+
if (n && Array.isArray(n))
|
|
1420
|
+
return n.map((t) => Q.deserialize(t)).filter((t) => t !== void 0);
|
|
1421
1421
|
};
|
|
1422
1422
|
R.prototype.getHolds = function() {
|
|
1423
1423
|
return Bt.deserialize(this.otherProperties.holds);
|
|
@@ -1432,29 +1432,29 @@ R.prototype.getAuthenticate = function() {
|
|
|
1432
1432
|
return q.deserialize(this.otherProperties.authenticate);
|
|
1433
1433
|
};
|
|
1434
1434
|
const Ge = "CssSelectorGenerator";
|
|
1435
|
-
function
|
|
1436
|
-
console.warn(`${Ge}: ${
|
|
1435
|
+
function re(n = "unknown problem", ...t) {
|
|
1436
|
+
console.warn(`${Ge}: ${n}`, ...t);
|
|
1437
1437
|
}
|
|
1438
|
-
function $e(
|
|
1439
|
-
return
|
|
1438
|
+
function $e(n) {
|
|
1439
|
+
return n instanceof RegExp;
|
|
1440
1440
|
}
|
|
1441
|
-
function Ye(
|
|
1442
|
-
return
|
|
1441
|
+
function Ye(n) {
|
|
1442
|
+
return n.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1443
1443
|
}
|
|
1444
|
-
function qe(
|
|
1445
|
-
const t =
|
|
1444
|
+
function qe(n) {
|
|
1445
|
+
const t = n.map((e) => {
|
|
1446
1446
|
if ($e(e))
|
|
1447
1447
|
return (i) => e.test(i);
|
|
1448
1448
|
if (typeof e == "function")
|
|
1449
1449
|
return (i) => {
|
|
1450
1450
|
const s = e(i);
|
|
1451
|
-
return typeof s != "boolean" ? (
|
|
1451
|
+
return typeof s != "boolean" ? (re("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
1452
1452
|
};
|
|
1453
1453
|
if (typeof e == "string") {
|
|
1454
1454
|
const i = new RegExp("^" + Ye(e) + "$");
|
|
1455
1455
|
return (s) => i.test(s);
|
|
1456
1456
|
}
|
|
1457
|
-
return
|
|
1457
|
+
return re("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1458
1458
|
});
|
|
1459
1459
|
return (e) => t.some((i) => i(e));
|
|
1460
1460
|
}
|
|
@@ -1466,50 +1466,50 @@ qe([
|
|
|
1466
1466
|
]);
|
|
1467
1467
|
class K {
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1470
|
-
return
|
|
1469
|
+
function ne(n) {
|
|
1470
|
+
return n.split("").reverse().join("");
|
|
1471
1471
|
}
|
|
1472
|
-
function Xe(
|
|
1473
|
-
const i =
|
|
1472
|
+
function Xe(n, t, e) {
|
|
1473
|
+
const i = ne(t);
|
|
1474
1474
|
return e.map((s) => {
|
|
1475
|
-
const
|
|
1475
|
+
const r = Math.max(0, s.end - t.length - s.errors), o = ne(n.slice(r, s.end));
|
|
1476
1476
|
return {
|
|
1477
|
-
start: xe(o, i, s.errors).reduce((
|
|
1477
|
+
start: xe(o, i, s.errors).reduce((c, u) => s.end - u.end < c ? s.end - u.end : c, s.end),
|
|
1478
1478
|
end: s.end,
|
|
1479
1479
|
errors: s.errors
|
|
1480
1480
|
};
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
1483
|
-
function vt(
|
|
1484
|
-
return (
|
|
1483
|
+
function vt(n) {
|
|
1484
|
+
return (n | -n) >> 31 & 1;
|
|
1485
1485
|
}
|
|
1486
|
-
function oe(
|
|
1487
|
-
let s =
|
|
1488
|
-
const o = i >>> 31, a = t[e] | o,
|
|
1489
|
-
let d =
|
|
1490
|
-
const p = vt(d &
|
|
1491
|
-
return d <<= 1, f <<= 1, f |= o, d |= vt(i) - o, s = f | ~(
|
|
1486
|
+
function oe(n, t, e, i) {
|
|
1487
|
+
let s = n.P[e], r = n.M[e];
|
|
1488
|
+
const o = i >>> 31, a = t[e] | o, c = a | r, u = (a & s) + s ^ s | a;
|
|
1489
|
+
let d = r | ~(u | s), f = s & u;
|
|
1490
|
+
const p = vt(d & n.lastRowMask[e]) - vt(f & n.lastRowMask[e]);
|
|
1491
|
+
return d <<= 1, f <<= 1, f |= o, d |= vt(i) - o, s = f | ~(c | d), r = d & c, n.P[e] = s, n.M[e] = r, p;
|
|
1492
1492
|
}
|
|
1493
|
-
function xe(
|
|
1493
|
+
function xe(n, t, e) {
|
|
1494
1494
|
if (t.length === 0)
|
|
1495
1495
|
return [];
|
|
1496
1496
|
e = Math.min(e, t.length);
|
|
1497
|
-
const i = [], s = 32,
|
|
1498
|
-
P: new Uint32Array(
|
|
1499
|
-
M: new Uint32Array(
|
|
1500
|
-
lastRowMask: new Uint32Array(
|
|
1497
|
+
const i = [], s = 32, r = Math.ceil(t.length / s) - 1, o = {
|
|
1498
|
+
P: new Uint32Array(r + 1),
|
|
1499
|
+
M: new Uint32Array(r + 1),
|
|
1500
|
+
lastRowMask: new Uint32Array(r + 1)
|
|
1501
1501
|
};
|
|
1502
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[
|
|
1503
|
-
const a = new Uint32Array(
|
|
1502
|
+
o.lastRowMask.fill(1 << 31), o.lastRowMask[r] = 1 << (t.length - 1) % s;
|
|
1503
|
+
const a = new Uint32Array(r + 1), c = /* @__PURE__ */ new Map(), u = [];
|
|
1504
1504
|
for (let p = 0; p < 256; p++)
|
|
1505
1505
|
u.push(a);
|
|
1506
1506
|
for (let p = 0; p < t.length; p += 1) {
|
|
1507
1507
|
const v = t.charCodeAt(p);
|
|
1508
|
-
if (
|
|
1508
|
+
if (c.has(v))
|
|
1509
1509
|
continue;
|
|
1510
|
-
const g = new Uint32Array(
|
|
1511
|
-
|
|
1512
|
-
for (let m = 0; m <=
|
|
1510
|
+
const g = new Uint32Array(r + 1);
|
|
1511
|
+
c.set(v, g), v < u.length && (u[v] = g);
|
|
1512
|
+
for (let m = 0; m <= r; m += 1) {
|
|
1513
1513
|
g[m] = 0;
|
|
1514
1514
|
for (let b = 0; b < s; b += 1) {
|
|
1515
1515
|
const D = m * s + b;
|
|
@@ -1520,23 +1520,23 @@ function xe(r, t, e) {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
1522
|
let d = Math.max(0, Math.ceil(e / s) - 1);
|
|
1523
|
-
const f = new Uint32Array(
|
|
1523
|
+
const f = new Uint32Array(r + 1);
|
|
1524
1524
|
for (let p = 0; p <= d; p += 1)
|
|
1525
1525
|
f[p] = (p + 1) * s;
|
|
1526
|
-
f[
|
|
1526
|
+
f[r] = t.length;
|
|
1527
1527
|
for (let p = 0; p <= d; p += 1)
|
|
1528
1528
|
o.P[p] = -1, o.M[p] = 0;
|
|
1529
|
-
for (let p = 0; p <
|
|
1530
|
-
const v =
|
|
1529
|
+
for (let p = 0; p < n.length; p += 1) {
|
|
1530
|
+
const v = n.charCodeAt(p);
|
|
1531
1531
|
let g;
|
|
1532
|
-
v < u.length ? g = u[v] : (g =
|
|
1532
|
+
v < u.length ? g = u[v] : (g = c.get(v), typeof g > "u" && (g = a));
|
|
1533
1533
|
let m = 0;
|
|
1534
1534
|
for (let b = 0; b <= d; b += 1)
|
|
1535
1535
|
m = oe(o, g, b, m), f[b] += m;
|
|
1536
|
-
if (f[d] - m <= e && d <
|
|
1536
|
+
if (f[d] - m <= e && d < r && (g[d + 1] & 1 || m < 0)) {
|
|
1537
1537
|
d += 1, o.P[d] = -1, o.M[d] = 0;
|
|
1538
1538
|
let b;
|
|
1539
|
-
if (d ===
|
|
1539
|
+
if (d === r) {
|
|
1540
1540
|
const D = t.length % s;
|
|
1541
1541
|
b = D === 0 ? s : D;
|
|
1542
1542
|
} else
|
|
@@ -1545,7 +1545,7 @@ function xe(r, t, e) {
|
|
|
1545
1545
|
} else
|
|
1546
1546
|
for (; d > 0 && f[d] >= e + s; )
|
|
1547
1547
|
d -= 1;
|
|
1548
|
-
d ===
|
|
1548
|
+
d === r && f[d] <= e && (f[d] < e && i.splice(0, i.length), i.push({
|
|
1549
1549
|
start: -1,
|
|
1550
1550
|
end: p + 1,
|
|
1551
1551
|
errors: f[d]
|
|
@@ -1553,149 +1553,149 @@ function xe(r, t, e) {
|
|
|
1553
1553
|
}
|
|
1554
1554
|
return i;
|
|
1555
1555
|
}
|
|
1556
|
-
function Ke(
|
|
1557
|
-
const i = xe(
|
|
1558
|
-
return Xe(
|
|
1556
|
+
function Ke(n, t, e) {
|
|
1557
|
+
const i = xe(n, t, e);
|
|
1558
|
+
return Xe(n, t, i);
|
|
1559
1559
|
}
|
|
1560
|
-
function Te(
|
|
1560
|
+
function Te(n, t, e) {
|
|
1561
1561
|
let i = 0;
|
|
1562
1562
|
const s = [];
|
|
1563
1563
|
for (; i !== -1; )
|
|
1564
|
-
i =
|
|
1564
|
+
i = n.indexOf(t, i), i !== -1 && (s.push({
|
|
1565
1565
|
start: i,
|
|
1566
1566
|
end: i + t.length,
|
|
1567
1567
|
errors: 0
|
|
1568
1568
|
}), i += 1);
|
|
1569
|
-
return s.length > 0 ? s : Ke(
|
|
1569
|
+
return s.length > 0 ? s : Ke(n, t, e);
|
|
1570
1570
|
}
|
|
1571
|
-
function ae(
|
|
1572
|
-
return t.length === 0 ||
|
|
1571
|
+
function ae(n, t) {
|
|
1572
|
+
return t.length === 0 || n.length === 0 ? 0 : 1 - Te(n, t, t.length)[0].errors / t.length;
|
|
1573
1573
|
}
|
|
1574
|
-
function Ze(
|
|
1574
|
+
function Ze(n, t, e = {}) {
|
|
1575
1575
|
if (t.length === 0)
|
|
1576
1576
|
return null;
|
|
1577
|
-
const i = Math.min(256, t.length / 2), s = Te(
|
|
1577
|
+
const i = Math.min(256, t.length / 2), s = Te(n, t, i);
|
|
1578
1578
|
if (s.length === 0)
|
|
1579
1579
|
return null;
|
|
1580
|
-
const
|
|
1580
|
+
const r = (a) => {
|
|
1581
1581
|
const p = 1 - a.errors / t.length, v = e.prefix ? ae(
|
|
1582
|
-
|
|
1582
|
+
n.slice(
|
|
1583
1583
|
Math.max(0, a.start - e.prefix.length),
|
|
1584
1584
|
a.start
|
|
1585
1585
|
),
|
|
1586
1586
|
e.prefix
|
|
1587
1587
|
) : 1, g = e.suffix ? ae(
|
|
1588
|
-
|
|
1588
|
+
n.slice(a.end, a.end + e.suffix.length),
|
|
1589
1589
|
e.suffix
|
|
1590
1590
|
) : 1;
|
|
1591
1591
|
let m = 1;
|
|
1592
|
-
return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) /
|
|
1592
|
+
return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) / n.length), (50 * p + 20 * v + 20 * g + 2 * m) / 92;
|
|
1593
1593
|
}, o = s.map((a) => ({
|
|
1594
1594
|
start: a.start,
|
|
1595
1595
|
end: a.end,
|
|
1596
|
-
score:
|
|
1596
|
+
score: r(a)
|
|
1597
1597
|
}));
|
|
1598
|
-
return o.sort((a,
|
|
1598
|
+
return o.sort((a, c) => c.score - a.score), o[0];
|
|
1599
1599
|
}
|
|
1600
|
-
function At(
|
|
1600
|
+
function At(n, t, e) {
|
|
1601
1601
|
const i = e === 1 ? t : t - 1;
|
|
1602
|
-
if (
|
|
1602
|
+
if (n.charAt(i).trim() !== "")
|
|
1603
1603
|
return t;
|
|
1604
|
-
let s,
|
|
1605
|
-
if (e === 2 ? (s =
|
|
1604
|
+
let s, r;
|
|
1605
|
+
if (e === 2 ? (s = n.substring(0, t), r = s.trimEnd()) : (s = n.substring(t), r = s.trimStart()), !r.length)
|
|
1606
1606
|
return -1;
|
|
1607
|
-
const o = s.length -
|
|
1607
|
+
const o = s.length - r.length;
|
|
1608
1608
|
return e === 2 ? t - o : t + o;
|
|
1609
1609
|
}
|
|
1610
|
-
function le(
|
|
1611
|
-
const e =
|
|
1612
|
-
|
|
1610
|
+
function le(n, t) {
|
|
1611
|
+
const e = n.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1612
|
+
n.commonAncestorContainer,
|
|
1613
1613
|
NodeFilter.SHOW_TEXT
|
|
1614
|
-
), i = t === 1 ?
|
|
1615
|
-
let
|
|
1616
|
-
for (;
|
|
1617
|
-
|
|
1618
|
-
t === 2 && (
|
|
1614
|
+
), i = t === 1 ? n.startContainer : n.endContainer, s = t === 1 ? n.endContainer : n.startContainer;
|
|
1615
|
+
let r = e.nextNode();
|
|
1616
|
+
for (; r && r !== i; )
|
|
1617
|
+
r = e.nextNode();
|
|
1618
|
+
t === 2 && (r = e.previousNode());
|
|
1619
1619
|
let o = -1;
|
|
1620
1620
|
const a = () => {
|
|
1621
|
-
if (
|
|
1622
|
-
const
|
|
1623
|
-
o = At(
|
|
1621
|
+
if (r = t === 1 ? e.nextNode() : e.previousNode(), r) {
|
|
1622
|
+
const c = r.textContent, u = t === 1 ? 0 : c.length;
|
|
1623
|
+
o = At(c, u, t);
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
1626
|
-
for (;
|
|
1626
|
+
for (; r && o === -1 && r !== s; )
|
|
1627
1627
|
a();
|
|
1628
|
-
if (
|
|
1629
|
-
return { node:
|
|
1628
|
+
if (r && o >= 0)
|
|
1629
|
+
return { node: r, offset: o };
|
|
1630
1630
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1631
1631
|
}
|
|
1632
|
-
function Je(
|
|
1633
|
-
if (!
|
|
1632
|
+
function Je(n) {
|
|
1633
|
+
if (!n.toString().trim().length)
|
|
1634
1634
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1635
|
-
if (
|
|
1635
|
+
if (n.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1636
1636
|
throw new RangeError("Range startContainer is not a text node");
|
|
1637
|
-
if (
|
|
1637
|
+
if (n.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1638
1638
|
throw new RangeError("Range endContainer is not a text node");
|
|
1639
|
-
const t =
|
|
1639
|
+
const t = n.cloneRange();
|
|
1640
1640
|
let e = !1, i = !1;
|
|
1641
1641
|
const s = {
|
|
1642
1642
|
start: At(
|
|
1643
|
-
|
|
1644
|
-
|
|
1643
|
+
n.startContainer.textContent,
|
|
1644
|
+
n.startOffset,
|
|
1645
1645
|
1
|
|
1646
1646
|
/* Forwards */
|
|
1647
1647
|
),
|
|
1648
1648
|
end: At(
|
|
1649
|
-
|
|
1650
|
-
|
|
1649
|
+
n.endContainer.textContent,
|
|
1650
|
+
n.endOffset,
|
|
1651
1651
|
2
|
|
1652
1652
|
/* Backwards */
|
|
1653
1653
|
)
|
|
1654
1654
|
};
|
|
1655
|
-
if (s.start >= 0 && (t.setStart(
|
|
1655
|
+
if (s.start >= 0 && (t.setStart(n.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(n.endContainer, s.end), i = !0), e && i)
|
|
1656
1656
|
return t;
|
|
1657
1657
|
if (!e) {
|
|
1658
|
-
const { node:
|
|
1658
|
+
const { node: r, offset: o } = le(
|
|
1659
1659
|
t,
|
|
1660
1660
|
1
|
|
1661
1661
|
/* Forwards */
|
|
1662
1662
|
);
|
|
1663
|
-
|
|
1663
|
+
r && o >= 0 && t.setStart(r, o);
|
|
1664
1664
|
}
|
|
1665
1665
|
if (!i) {
|
|
1666
|
-
const { node:
|
|
1666
|
+
const { node: r, offset: o } = le(
|
|
1667
1667
|
t,
|
|
1668
1668
|
2
|
|
1669
1669
|
/* Backwards */
|
|
1670
1670
|
);
|
|
1671
|
-
|
|
1671
|
+
r && o > 0 && t.setEnd(r, o);
|
|
1672
1672
|
}
|
|
1673
1673
|
return t;
|
|
1674
1674
|
}
|
|
1675
|
-
function Pe(
|
|
1676
|
-
switch (
|
|
1675
|
+
function Pe(n) {
|
|
1676
|
+
switch (n.nodeType) {
|
|
1677
1677
|
case Node.ELEMENT_NODE:
|
|
1678
1678
|
case Node.TEXT_NODE:
|
|
1679
|
-
return
|
|
1679
|
+
return n.textContent?.length ?? 0;
|
|
1680
1680
|
default:
|
|
1681
1681
|
return 0;
|
|
1682
1682
|
}
|
|
1683
1683
|
}
|
|
1684
|
-
function ce(
|
|
1685
|
-
let t =
|
|
1684
|
+
function ce(n) {
|
|
1685
|
+
let t = n.previousSibling, e = 0;
|
|
1686
1686
|
for (; t; )
|
|
1687
1687
|
e += Pe(t), t = t.previousSibling;
|
|
1688
1688
|
return e;
|
|
1689
1689
|
}
|
|
1690
|
-
function Ne(
|
|
1690
|
+
function Ne(n, ...t) {
|
|
1691
1691
|
let e = t.shift();
|
|
1692
|
-
const i =
|
|
1693
|
-
|
|
1692
|
+
const i = n.ownerDocument.createNodeIterator(
|
|
1693
|
+
n,
|
|
1694
1694
|
NodeFilter.SHOW_TEXT
|
|
1695
1695
|
), s = [];
|
|
1696
|
-
let
|
|
1697
|
-
for (; e !== void 0 &&
|
|
1698
|
-
o =
|
|
1696
|
+
let r = i.nextNode(), o, a = 0;
|
|
1697
|
+
for (; e !== void 0 && r; )
|
|
1698
|
+
o = r, a + o.data.length > e ? (s.push({ node: o, offset: e - a }), e = t.shift()) : (r = i.nextNode(), a += o.data.length);
|
|
1699
1699
|
for (; e !== void 0 && o && a === e; )
|
|
1700
1700
|
s.push({ node: o, offset: o.data.length }), e = t.shift();
|
|
1701
1701
|
if (e !== void 0)
|
|
@@ -1749,10 +1749,10 @@ class M {
|
|
|
1749
1749
|
NodeFilter.SHOW_TEXT
|
|
1750
1750
|
);
|
|
1751
1751
|
i.currentNode = this.element;
|
|
1752
|
-
const s = t.direction === 1,
|
|
1753
|
-
if (!
|
|
1752
|
+
const s = t.direction === 1, r = s ? i.nextNode() : i.previousNode();
|
|
1753
|
+
if (!r)
|
|
1754
1754
|
throw e;
|
|
1755
|
-
return { node:
|
|
1755
|
+
return { node: r, offset: s ? 0 : r.data.length };
|
|
1756
1756
|
} else
|
|
1757
1757
|
throw e;
|
|
1758
1758
|
}
|
|
@@ -1907,9 +1907,9 @@ class mt {
|
|
|
1907
1907
|
* Will throw if `range` does not contain any text nodes.
|
|
1908
1908
|
*/
|
|
1909
1909
|
static fromRange(t, e) {
|
|
1910
|
-
const i = t.textContent, s = B.fromRange(e).relativeTo(t),
|
|
1911
|
-
return new mt(t, i.slice(
|
|
1912
|
-
prefix: i.slice(Math.max(0,
|
|
1910
|
+
const i = t.textContent, s = B.fromRange(e).relativeTo(t), r = s.start.offset, o = s.end.offset, a = 32;
|
|
1911
|
+
return new mt(t, i.slice(r, o), {
|
|
1912
|
+
prefix: i.slice(Math.max(0, r - a), r),
|
|
1913
1913
|
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
@@ -1938,36 +1938,36 @@ class mt {
|
|
|
1938
1938
|
return new pt(this.root, i.start, i.end);
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
|
-
function Qe(
|
|
1942
|
-
const t =
|
|
1941
|
+
function Qe(n) {
|
|
1942
|
+
const t = n.tagName.toUpperCase();
|
|
1943
1943
|
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1944
1944
|
}
|
|
1945
|
-
function
|
|
1945
|
+
function rt(n, t) {
|
|
1946
1946
|
try {
|
|
1947
1947
|
const e = t.locations, i = t.text;
|
|
1948
1948
|
if (i && i.highlight) {
|
|
1949
1949
|
let s;
|
|
1950
|
-
e && e.getCssSelector() && (s =
|
|
1951
|
-
const
|
|
1950
|
+
e && e.getCssSelector() && (s = n.querySelector(e.getCssSelector())), s || (s = n.body);
|
|
1951
|
+
const r = new mt(s, i.highlight, {
|
|
1952
1952
|
prefix: i.before,
|
|
1953
1953
|
suffix: i.after
|
|
1954
1954
|
});
|
|
1955
1955
|
try {
|
|
1956
|
-
return
|
|
1956
|
+
return r.toRange();
|
|
1957
1957
|
} catch {
|
|
1958
|
-
return console.warn("Quote not found:",
|
|
1958
|
+
return console.warn("Quote not found:", r), null;
|
|
1959
1959
|
}
|
|
1960
1960
|
}
|
|
1961
1961
|
if (e) {
|
|
1962
1962
|
let s = null;
|
|
1963
|
-
if (!s && e.getCssSelector() && (s =
|
|
1964
|
-
for (const
|
|
1965
|
-
if (s =
|
|
1963
|
+
if (!s && e.getCssSelector() && (s = n.querySelector(e.getCssSelector())), !s && e.fragments) {
|
|
1964
|
+
for (const r of e.fragments)
|
|
1965
|
+
if (s = n.getElementById(r), s)
|
|
1966
1966
|
break;
|
|
1967
1967
|
}
|
|
1968
1968
|
if (s) {
|
|
1969
|
-
const
|
|
1970
|
-
return s.childNodes.length === 0 || Qe(s) ? (
|
|
1969
|
+
const r = n.createRange();
|
|
1970
|
+
return s.childNodes.length === 0 || Qe(s) ? (r.selectNode(s), r) : (r.setStartBefore(s), r.setEndAfter(s), r);
|
|
1971
1971
|
}
|
|
1972
1972
|
}
|
|
1973
1973
|
} catch (e) {
|
|
@@ -1975,9 +1975,9 @@ function nt(r, t) {
|
|
|
1975
1975
|
}
|
|
1976
1976
|
return null;
|
|
1977
1977
|
}
|
|
1978
|
-
function je(
|
|
1979
|
-
let e =
|
|
1980
|
-
e.length ||
|
|
1978
|
+
function je(n, t) {
|
|
1979
|
+
let e = n.getClientRects();
|
|
1980
|
+
e.length || n.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = n.commonAncestorContainer.getClientRects());
|
|
1981
1981
|
const i = 1, s = [];
|
|
1982
1982
|
for (const u of e)
|
|
1983
1983
|
s.push({
|
|
@@ -1988,13 +1988,13 @@ function je(r, t) {
|
|
|
1988
1988
|
top: u.top,
|
|
1989
1989
|
width: u.width
|
|
1990
1990
|
});
|
|
1991
|
-
const
|
|
1991
|
+
const r = Le(
|
|
1992
1992
|
s,
|
|
1993
1993
|
i
|
|
1994
|
-
), o = ei(
|
|
1994
|
+
), o = ei(r, i), a = Oe(o), c = 4;
|
|
1995
1995
|
for (let u = a.length - 1; u >= 0; u--) {
|
|
1996
1996
|
const d = a[u];
|
|
1997
|
-
if (!(d.width * d.height >
|
|
1997
|
+
if (!(d.width * d.height > c))
|
|
1998
1998
|
if (a.length > 1)
|
|
1999
1999
|
a.splice(u, 1);
|
|
2000
2000
|
else
|
|
@@ -2002,86 +2002,86 @@ function je(r, t) {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
return a;
|
|
2004
2004
|
}
|
|
2005
|
-
function Le(
|
|
2006
|
-
for (let i = 0; i <
|
|
2007
|
-
for (let s = i + 1; s <
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2005
|
+
function Le(n, t, e) {
|
|
2006
|
+
for (let i = 0; i < n.length; i++)
|
|
2007
|
+
for (let s = i + 1; s < n.length; s++) {
|
|
2008
|
+
const r = n[i], o = n[s];
|
|
2009
|
+
if (r === o)
|
|
2010
2010
|
continue;
|
|
2011
|
-
const a = I(
|
|
2012
|
-
if (a && !
|
|
2013
|
-
const f =
|
|
2011
|
+
const a = I(r.top, o.top, t) && I(r.bottom, o.bottom, t), c = I(r.left, o.left, t) && I(r.right, o.right, t);
|
|
2012
|
+
if (a && !c && Re(r, o, t)) {
|
|
2013
|
+
const f = n.filter((v) => v !== r && v !== o), p = ti(r, o);
|
|
2014
2014
|
return f.push(p), Le(
|
|
2015
2015
|
f,
|
|
2016
2016
|
t
|
|
2017
2017
|
);
|
|
2018
2018
|
}
|
|
2019
2019
|
}
|
|
2020
|
-
return
|
|
2020
|
+
return n;
|
|
2021
2021
|
}
|
|
2022
|
-
function ti(
|
|
2023
|
-
const e = Math.min(
|
|
2022
|
+
function ti(n, t) {
|
|
2023
|
+
const e = Math.min(n.left, t.left), i = Math.max(n.right, t.right), s = Math.min(n.top, t.top), r = Math.max(n.bottom, t.bottom);
|
|
2024
2024
|
return {
|
|
2025
|
-
bottom:
|
|
2026
|
-
height:
|
|
2025
|
+
bottom: r,
|
|
2026
|
+
height: r - s,
|
|
2027
2027
|
left: e,
|
|
2028
2028
|
right: i,
|
|
2029
2029
|
top: s,
|
|
2030
2030
|
width: i - e
|
|
2031
2031
|
};
|
|
2032
2032
|
}
|
|
2033
|
-
function ei(
|
|
2034
|
-
const e = new Set(
|
|
2035
|
-
for (const i of
|
|
2033
|
+
function ei(n, t) {
|
|
2034
|
+
const e = new Set(n);
|
|
2035
|
+
for (const i of n) {
|
|
2036
2036
|
if (!(i.width > 1 && i.height > 1)) {
|
|
2037
2037
|
e.delete(i);
|
|
2038
2038
|
continue;
|
|
2039
2039
|
}
|
|
2040
|
-
for (const
|
|
2041
|
-
if (i !==
|
|
2040
|
+
for (const r of n)
|
|
2041
|
+
if (i !== r && e.has(r) && ii(r, i, t)) {
|
|
2042
2042
|
e.delete(i);
|
|
2043
2043
|
break;
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
return Array.from(e);
|
|
2047
2047
|
}
|
|
2048
|
-
function ii(
|
|
2049
|
-
return at(
|
|
2048
|
+
function ii(n, t, e) {
|
|
2049
|
+
return at(n, t.left, t.top, e) && at(n, t.right, t.top, e) && at(n, t.left, t.bottom, e) && at(n, t.right, t.bottom, e);
|
|
2050
2050
|
}
|
|
2051
|
-
function at(
|
|
2052
|
-
return (
|
|
2051
|
+
function at(n, t, e, i) {
|
|
2052
|
+
return (n.left < t || I(n.left, t, i)) && (n.right > t || I(n.right, t, i)) && (n.top < e || I(n.top, e, i)) && (n.bottom > e || I(n.bottom, e, i));
|
|
2053
2053
|
}
|
|
2054
|
-
function Oe(
|
|
2055
|
-
for (let t = 0; t <
|
|
2056
|
-
for (let e = t + 1; e <
|
|
2057
|
-
const i =
|
|
2054
|
+
function Oe(n) {
|
|
2055
|
+
for (let t = 0; t < n.length; t++)
|
|
2056
|
+
for (let e = t + 1; e < n.length; e++) {
|
|
2057
|
+
const i = n[t], s = n[e];
|
|
2058
2058
|
if (i !== s && Re(i, s, -1)) {
|
|
2059
|
-
let
|
|
2059
|
+
let r = [], o;
|
|
2060
2060
|
const a = he(i, s);
|
|
2061
2061
|
if (a.length === 1)
|
|
2062
|
-
|
|
2062
|
+
r = a, o = i;
|
|
2063
2063
|
else {
|
|
2064
2064
|
const u = he(s, i);
|
|
2065
|
-
a.length < u.length ? (
|
|
2065
|
+
a.length < u.length ? (r = a, o = i) : (r = u, o = s);
|
|
2066
2066
|
}
|
|
2067
|
-
const
|
|
2068
|
-
return Array.prototype.push.apply(
|
|
2067
|
+
const c = n.filter((u) => u !== o);
|
|
2068
|
+
return Array.prototype.push.apply(c, r), Oe(c);
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
|
-
return
|
|
2071
|
+
return n;
|
|
2072
2072
|
}
|
|
2073
|
-
function he(
|
|
2074
|
-
const e = si(t,
|
|
2073
|
+
function he(n, t) {
|
|
2074
|
+
const e = si(t, n);
|
|
2075
2075
|
if (e.height === 0 || e.width === 0)
|
|
2076
|
-
return [
|
|
2076
|
+
return [n];
|
|
2077
2077
|
const i = [];
|
|
2078
2078
|
{
|
|
2079
2079
|
const s = {
|
|
2080
|
-
bottom:
|
|
2080
|
+
bottom: n.bottom,
|
|
2081
2081
|
height: 0,
|
|
2082
|
-
left:
|
|
2082
|
+
left: n.left,
|
|
2083
2083
|
right: e.left,
|
|
2084
|
-
top:
|
|
2084
|
+
top: n.top,
|
|
2085
2085
|
width: 0
|
|
2086
2086
|
};
|
|
2087
2087
|
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
@@ -2092,14 +2092,14 @@ function he(r, t) {
|
|
|
2092
2092
|
height: 0,
|
|
2093
2093
|
left: e.left,
|
|
2094
2094
|
right: e.right,
|
|
2095
|
-
top:
|
|
2095
|
+
top: n.top,
|
|
2096
2096
|
width: 0
|
|
2097
2097
|
};
|
|
2098
2098
|
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2099
2099
|
}
|
|
2100
2100
|
{
|
|
2101
2101
|
const s = {
|
|
2102
|
-
bottom:
|
|
2102
|
+
bottom: n.bottom,
|
|
2103
2103
|
height: 0,
|
|
2104
2104
|
left: e.left,
|
|
2105
2105
|
right: e.right,
|
|
@@ -2110,59 +2110,59 @@ function he(r, t) {
|
|
|
2110
2110
|
}
|
|
2111
2111
|
{
|
|
2112
2112
|
const s = {
|
|
2113
|
-
bottom:
|
|
2113
|
+
bottom: n.bottom,
|
|
2114
2114
|
height: 0,
|
|
2115
2115
|
left: e.right,
|
|
2116
|
-
right:
|
|
2117
|
-
top:
|
|
2116
|
+
right: n.right,
|
|
2117
|
+
top: n.top,
|
|
2118
2118
|
width: 0
|
|
2119
2119
|
};
|
|
2120
2120
|
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
2121
2121
|
}
|
|
2122
2122
|
return i;
|
|
2123
2123
|
}
|
|
2124
|
-
function si(
|
|
2125
|
-
const e = Math.max(
|
|
2124
|
+
function si(n, t) {
|
|
2125
|
+
const e = Math.max(n.left, t.left), i = Math.min(n.right, t.right), s = Math.max(n.top, t.top), r = Math.min(n.bottom, t.bottom);
|
|
2126
2126
|
return {
|
|
2127
|
-
bottom:
|
|
2128
|
-
height: Math.max(0,
|
|
2127
|
+
bottom: r,
|
|
2128
|
+
height: Math.max(0, r - s),
|
|
2129
2129
|
left: e,
|
|
2130
2130
|
right: i,
|
|
2131
2131
|
top: s,
|
|
2132
2132
|
width: Math.max(0, i - e)
|
|
2133
2133
|
};
|
|
2134
2134
|
}
|
|
2135
|
-
function Re(
|
|
2136
|
-
return (
|
|
2135
|
+
function Re(n, t, e) {
|
|
2136
|
+
return (n.left < t.right || e >= 0 && I(n.left, t.right, e)) && (t.left < n.right || e >= 0 && I(t.left, n.right, e)) && (n.top < t.bottom || e >= 0 && I(n.top, t.bottom, e)) && (t.top < n.bottom || e >= 0 && I(t.top, n.bottom, e));
|
|
2137
2137
|
}
|
|
2138
|
-
function I(
|
|
2139
|
-
return Math.abs(
|
|
2138
|
+
function I(n, t, e) {
|
|
2139
|
+
return Math.abs(n - t) <= e;
|
|
2140
2140
|
}
|
|
2141
|
-
function Vt(
|
|
2142
|
-
const t = {}, e =
|
|
2143
|
-
for (const i in
|
|
2141
|
+
function Vt(n) {
|
|
2142
|
+
const t = {}, e = n.document.documentElement.style;
|
|
2143
|
+
for (const i in n.document.documentElement.style)
|
|
2144
2144
|
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2145
2145
|
return t;
|
|
2146
2146
|
}
|
|
2147
|
-
function De(
|
|
2148
|
-
const e = Vt(
|
|
2147
|
+
function De(n, t) {
|
|
2148
|
+
const e = Vt(n);
|
|
2149
2149
|
Object.keys(e).forEach((i) => {
|
|
2150
|
-
t.hasOwnProperty(i) || gt(
|
|
2150
|
+
t.hasOwnProperty(i) || gt(n, i);
|
|
2151
2151
|
}), Object.entries(t).forEach(([i, s]) => {
|
|
2152
|
-
e[i] !== s && st(
|
|
2152
|
+
e[i] !== s && st(n, i, s);
|
|
2153
2153
|
});
|
|
2154
2154
|
}
|
|
2155
|
-
function wt(
|
|
2156
|
-
return
|
|
2155
|
+
function wt(n, t) {
|
|
2156
|
+
return n.document.documentElement.style.getPropertyValue(t);
|
|
2157
2157
|
}
|
|
2158
|
-
function st(
|
|
2159
|
-
|
|
2158
|
+
function st(n, t, e) {
|
|
2159
|
+
n.document.documentElement.style.setProperty(t, e);
|
|
2160
2160
|
}
|
|
2161
|
-
function gt(
|
|
2162
|
-
|
|
2161
|
+
function gt(n, t) {
|
|
2162
|
+
n.document.documentElement.style.removeProperty(t);
|
|
2163
2163
|
}
|
|
2164
2164
|
let lt = null, St = null, J = 0;
|
|
2165
|
-
const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(),
|
|
2165
|
+
const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ri = () => {
|
|
2166
2166
|
if (!lt)
|
|
2167
2167
|
if (typeof OffscreenCanvas < "u")
|
|
2168
2168
|
lt = new OffscreenCanvas(5, 5), St = lt.getContext("2d", {
|
|
@@ -2170,16 +2170,16 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ni =
|
|
|
2170
2170
|
desynchronized: !0
|
|
2171
2171
|
});
|
|
2172
2172
|
else {
|
|
2173
|
-
const
|
|
2174
|
-
|
|
2173
|
+
const n = document.createElement("canvas");
|
|
2174
|
+
n.width = 5, n.height = 5, lt = n, St = n.getContext("2d", {
|
|
2175
2175
|
willReadFrequently: !0,
|
|
2176
2176
|
desynchronized: !0
|
|
2177
2177
|
});
|
|
2178
2178
|
}
|
|
2179
2179
|
return St;
|
|
2180
|
-
},
|
|
2181
|
-
if (!
|
|
2182
|
-
const t =
|
|
2180
|
+
}, ni = (n) => {
|
|
2181
|
+
if (!n) return !0;
|
|
2182
|
+
const t = n.trim().toLowerCase();
|
|
2183
2183
|
return t.startsWith("var(") || [
|
|
2184
2184
|
"transparent",
|
|
2185
2185
|
"currentcolor",
|
|
@@ -2196,47 +2196,47 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ni =
|
|
|
2196
2196
|
"repeating-radial-gradient",
|
|
2197
2197
|
"repeating-conic-gradient"
|
|
2198
2198
|
].some((s) => t.includes(s));
|
|
2199
|
-
}, ct = (
|
|
2199
|
+
}, ct = (n, t) => {
|
|
2200
2200
|
console.warn(
|
|
2201
|
-
`[Decorator] Could not parse color: "${
|
|
2201
|
+
`[Decorator] Could not parse color: "${n}". ${t} Falling back to ${JSON.stringify(G)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
2202
2202
|
);
|
|
2203
|
-
}, Ct = (
|
|
2204
|
-
const e = t ? `${
|
|
2203
|
+
}, Ct = (n, t = null) => {
|
|
2204
|
+
const e = t ? `${n}|${t}` : n, i = F.get(e);
|
|
2205
2205
|
if (i !== void 0)
|
|
2206
2206
|
return i ?? G;
|
|
2207
|
-
if (
|
|
2208
|
-
return ct(
|
|
2209
|
-
const s =
|
|
2207
|
+
if (ni(n))
|
|
2208
|
+
return ct(n, "Unsupported color format or special value."), F.set(e, null), G;
|
|
2209
|
+
const s = ri();
|
|
2210
2210
|
if (!s)
|
|
2211
|
-
return ct(
|
|
2211
|
+
return ct(n, "Could not get canvas context."), F.set(e, null), G;
|
|
2212
2212
|
try {
|
|
2213
2213
|
J === 0 && s.clearRect(0, 0, 5, 5);
|
|
2214
|
-
const
|
|
2215
|
-
s.clearRect(
|
|
2216
|
-
const a = s.getImageData(
|
|
2214
|
+
const r = J % 5, o = Math.floor(J / 5);
|
|
2215
|
+
s.clearRect(r, o, 1, 1), t && (s.fillStyle = t, s.fillRect(r, o, 1, 1)), s.fillStyle = n, s.fillRect(r, o, 1, 1);
|
|
2216
|
+
const a = s.getImageData(r, o, 1, 1);
|
|
2217
2217
|
J = (J + 1) % 25;
|
|
2218
|
-
const [
|
|
2218
|
+
const [c, u, d, f] = a.data;
|
|
2219
2219
|
if (f === 0)
|
|
2220
|
-
return ct(
|
|
2221
|
-
const p = { r:
|
|
2220
|
+
return ct(n, "Fully transparent color."), F.set(e, null), G;
|
|
2221
|
+
const p = { r: c, g: u, b: d, a: f / 255 };
|
|
2222
2222
|
return F.set(e, p), p;
|
|
2223
|
-
} catch (
|
|
2224
|
-
return ct(
|
|
2223
|
+
} catch (r) {
|
|
2224
|
+
return ct(n, `Error: ${r instanceof Error ? r.message : String(r)}`), F.set(e, null), G;
|
|
2225
2225
|
}
|
|
2226
|
-
}, Et = (
|
|
2227
|
-
const t =
|
|
2226
|
+
}, Et = (n) => {
|
|
2227
|
+
const t = n / 255;
|
|
2228
2228
|
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2229
|
-
}, de = (
|
|
2230
|
-
const t = Et(
|
|
2229
|
+
}, de = (n) => {
|
|
2230
|
+
const t = Et(n.r), e = Et(n.g), i = Et(n.b);
|
|
2231
2231
|
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2232
|
-
}, ue = (
|
|
2233
|
-
const e = typeof
|
|
2232
|
+
}, ue = (n, t) => {
|
|
2233
|
+
const e = typeof n == "string" ? Ct(n) : n, i = typeof t == "string" ? Ct(t) : t, s = de(e), r = de(i), o = Math.max(s, r), a = Math.min(s, r);
|
|
2234
2234
|
return (o + 0.05) / (a + 0.05);
|
|
2235
|
-
}, xt = (
|
|
2236
|
-
const e = Ct(
|
|
2235
|
+
}, xt = (n, t = null) => {
|
|
2236
|
+
const e = Ct(n, t), i = ue(e, { r: 255, g: 255, b: 255, a: 1 }), s = ue(e, { r: 0, g: 0, b: 0, a: 1 });
|
|
2237
2237
|
return i > s;
|
|
2238
|
-
}, oi = (
|
|
2239
|
-
var ai = /* @__PURE__ */ ((
|
|
2238
|
+
}, oi = (n, t = null) => xt(n, t) ? "white" : "black", pe = "#FFFF00";
|
|
2239
|
+
var ai = /* @__PURE__ */ ((n) => (n.Wrap = "wrap", n.Viewport = "viewport", n.Bounds = "bounds", n.Page = "page", n))(ai || {}), li = /* @__PURE__ */ ((n) => (n.Boxes = "boxes", n.Bounds = "bounds", n))(li || {});
|
|
2240
2240
|
const ci = () => "Highlight" in window, me = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2241
2241
|
class hi {
|
|
2242
2242
|
/**
|
|
@@ -2258,19 +2258,19 @@ class hi {
|
|
|
2258
2258
|
* @param decoration Decoration to add
|
|
2259
2259
|
*/
|
|
2260
2260
|
add(t) {
|
|
2261
|
-
const e = `${this.id}-${this.lastItemId++}`, i =
|
|
2261
|
+
const e = `${this.id}-${this.lastItemId++}`, i = rt(this.wnd.document, t.locator);
|
|
2262
2262
|
if (!i) {
|
|
2263
2263
|
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2264
2264
|
return;
|
|
2265
2265
|
}
|
|
2266
2266
|
const s = i.commonAncestorContainer;
|
|
2267
2267
|
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (me.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(me.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
|
|
2268
|
-
const
|
|
2268
|
+
const r = {
|
|
2269
2269
|
decoration: t,
|
|
2270
2270
|
id: e,
|
|
2271
2271
|
range: i
|
|
2272
2272
|
};
|
|
2273
|
-
this.items.push(
|
|
2273
|
+
this.items.push(r), this.layout(r), this.renderLayout([r]);
|
|
2274
2274
|
}
|
|
2275
2275
|
/**
|
|
2276
2276
|
* Removes the decoration with given ID from the group.
|
|
@@ -2305,11 +2305,11 @@ class hi {
|
|
|
2305
2305
|
experimentalLayout(t) {
|
|
2306
2306
|
const [e, i] = this.requireContainer(!0);
|
|
2307
2307
|
i.add(t.range);
|
|
2308
|
-
const s = wt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"),
|
|
2308
|
+
const s = wt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), r = t.decoration?.style?.tint ?? pe;
|
|
2309
2309
|
e.innerHTML = `
|
|
2310
2310
|
::highlight(${this.id}) {
|
|
2311
|
-
color: ${oi(
|
|
2312
|
-
background-color: ${
|
|
2311
|
+
color: ${oi(r, s)};
|
|
2312
|
+
background-color: ${r};
|
|
2313
2313
|
}`;
|
|
2314
2314
|
}
|
|
2315
2315
|
/**
|
|
@@ -2325,19 +2325,19 @@ class hi {
|
|
|
2325
2325
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2326
2326
|
"column-count"
|
|
2327
2327
|
)
|
|
2328
|
-
),
|
|
2328
|
+
), r = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, u = (g, m, b) => {
|
|
2329
2329
|
if (g.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2330
2330
|
g.style.width = `${i}px`, g.style.height = `${m.height}px`;
|
|
2331
2331
|
let D = Math.floor(m.left / i) * i;
|
|
2332
|
-
g.style.left = `${D + a}px`, g.style.top = `${m.top +
|
|
2332
|
+
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2333
2333
|
} else if (t.decoration?.style?.width === "bounds")
|
|
2334
|
-
g.style.width = `${b.width}px`, g.style.height = `${m.height}px`, g.style.left = `${b.left + a}px`, g.style.top = `${m.top +
|
|
2334
|
+
g.style.width = `${b.width}px`, g.style.height = `${m.height}px`, g.style.left = `${b.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2335
2335
|
else if (t.decoration?.style?.width === "page") {
|
|
2336
|
-
g.style.width = `${
|
|
2337
|
-
let D = Math.floor(m.left /
|
|
2338
|
-
g.style.left = `${D + a}px`, g.style.top = `${m.top +
|
|
2336
|
+
g.style.width = `${r}px`, g.style.height = `${m.height}px`;
|
|
2337
|
+
let D = Math.floor(m.left / r) * r;
|
|
2338
|
+
g.style.left = `${D + a}px`, g.style.top = `${m.top + c}px`;
|
|
2339
2339
|
} else
|
|
2340
|
-
g.style.width = `${m.width}px`, g.style.height = `${m.height}px`, g.style.left = `${m.left + a}px`, g.style.top = `${m.top +
|
|
2340
|
+
g.style.width = `${m.width}px`, g.style.height = `${m.height}px`, g.style.left = `${m.left + a}px`, g.style.top = `${m.top + c}px`;
|
|
2341
2341
|
}, d = t.range.getBoundingClientRect();
|
|
2342
2342
|
let f = this.wnd.document.createElement("template");
|
|
2343
2343
|
const p = this.getCurrentDarkMode();
|
|
@@ -2428,33 +2428,33 @@ const j = class j extends K {
|
|
|
2428
2428
|
}
|
|
2429
2429
|
mount(t, e) {
|
|
2430
2430
|
return this.wnd = t, e.register("decorate", j.moduleName, (i, s) => {
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2431
|
+
const r = i;
|
|
2432
|
+
r.decoration && r.decoration.locator && (r.decoration.locator = k.deserialize(r.decoration.locator)), this.groups.has(r.group) || this.groups.set(r.group, new hi(
|
|
2433
2433
|
t,
|
|
2434
2434
|
e,
|
|
2435
2435
|
`readium-decoration-${this.lastGroupId++}`,
|
|
2436
|
-
|
|
2436
|
+
r.group
|
|
2437
2437
|
));
|
|
2438
|
-
const o = this.groups.get(
|
|
2439
|
-
switch (
|
|
2438
|
+
const o = this.groups.get(r.group);
|
|
2439
|
+
switch (r.action) {
|
|
2440
2440
|
case "add":
|
|
2441
|
-
o?.add(
|
|
2441
|
+
o?.add(r.decoration);
|
|
2442
2442
|
break;
|
|
2443
2443
|
case "remove":
|
|
2444
|
-
o?.remove(
|
|
2444
|
+
o?.remove(r.decoration.id);
|
|
2445
2445
|
break;
|
|
2446
2446
|
case "clear":
|
|
2447
2447
|
o?.clear();
|
|
2448
2448
|
break;
|
|
2449
2449
|
case "update":
|
|
2450
|
-
o?.update(
|
|
2450
|
+
o?.update(r.decoration);
|
|
2451
2451
|
break;
|
|
2452
2452
|
}
|
|
2453
2453
|
s(!0);
|
|
2454
2454
|
}), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
|
|
2455
|
-
i.some((
|
|
2456
|
-
if (
|
|
2457
|
-
const o =
|
|
2455
|
+
i.some((r) => {
|
|
2456
|
+
if (r.type === "attributes" && r.attributeName === "style") {
|
|
2457
|
+
const o = r.target, a = r.oldValue, c = o.getAttribute("style"), u = this.extractCustomProperty(a, "--USER__appearance"), d = this.extractCustomProperty(c, "--USER__appearance"), f = this.extractCustomProperty(a, "--USER__backgroundColor"), p = this.extractCustomProperty(c, "--USER__backgroundColor");
|
|
2458
2458
|
return u !== d || f !== p;
|
|
2459
2459
|
}
|
|
2460
2460
|
return !1;
|
|
@@ -2485,10 +2485,10 @@ const fe = "readium-snapper-style", tt = class tt extends K {
|
|
|
2485
2485
|
}
|
|
2486
2486
|
mount(t, e) {
|
|
2487
2487
|
const i = t.document.createElement("style");
|
|
2488
|
-
return i.dataset.readium = "true", i.id = fe, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", tt.moduleName, (s,
|
|
2489
|
-
this.protected = !0, i.textContent = this.buildStyles(),
|
|
2490
|
-
}), e.register("unprotect", tt.moduleName, (s,
|
|
2491
|
-
this.protected = !1, i.textContent = this.buildStyles(),
|
|
2488
|
+
return i.dataset.readium = "true", i.id = fe, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", tt.moduleName, (s, r) => {
|
|
2489
|
+
this.protected = !0, i.textContent = this.buildStyles(), r(!0);
|
|
2490
|
+
}), e.register("unprotect", tt.moduleName, (s, r) => {
|
|
2491
|
+
this.protected = !1, i.textContent = this.buildStyles(), r(!0);
|
|
2492
2492
|
}), e.log("Snapper Mounted"), !0;
|
|
2493
2493
|
}
|
|
2494
2494
|
unmount(t, e) {
|
|
@@ -2497,47 +2497,47 @@ const fe = "readium-snapper-style", tt = class tt extends K {
|
|
|
2497
2497
|
};
|
|
2498
2498
|
tt.moduleName = "snapper";
|
|
2499
2499
|
let X = tt;
|
|
2500
|
-
function di(
|
|
2501
|
-
return (
|
|
2500
|
+
function di(n) {
|
|
2501
|
+
return (n.document.documentElement.dir || n.document.body.dir).toLowerCase() === "rtl";
|
|
2502
2502
|
}
|
|
2503
|
-
function ui(
|
|
2504
|
-
return (
|
|
2503
|
+
function ui(n) {
|
|
2504
|
+
return (n.getComputedStyle(n.document.documentElement).writingMode || n.getComputedStyle(n.document.body).writingMode) === "vertical-lr";
|
|
2505
2505
|
}
|
|
2506
|
-
function Ie(
|
|
2506
|
+
function Ie(n) {
|
|
2507
2507
|
return parseInt(
|
|
2508
|
-
|
|
2509
|
-
|
|
2508
|
+
n.getComputedStyle(
|
|
2509
|
+
n.document.documentElement
|
|
2510
2510
|
).getPropertyValue("column-count")
|
|
2511
2511
|
);
|
|
2512
2512
|
}
|
|
2513
|
-
function ge(
|
|
2514
|
-
const t = getComputedStyle(
|
|
2515
|
-
return
|
|
2513
|
+
function ge(n) {
|
|
2514
|
+
const t = getComputedStyle(n), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2515
|
+
return n.clientHeight - e - i;
|
|
2516
2516
|
}
|
|
2517
|
-
function ye(
|
|
2518
|
-
const t = Ie(
|
|
2517
|
+
function ye(n) {
|
|
2518
|
+
const t = Ie(n);
|
|
2519
2519
|
if (!t)
|
|
2520
2520
|
return !1;
|
|
2521
|
-
const e =
|
|
2521
|
+
const e = n.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2522
2522
|
for (const u of e)
|
|
2523
2523
|
u.remove();
|
|
2524
|
-
const i = e.length, s =
|
|
2525
|
-
if (
|
|
2526
|
-
for (let u = 0; u <
|
|
2527
|
-
const d =
|
|
2528
|
-
d.setAttribute("id", `readium-virtual-page-${u}`), d.dataset.readium = "true", CSS.supports("break-before", "column") ? d.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (d.style.breakInside = "avoid-column"), d.style.height = ge(
|
|
2524
|
+
const i = e.length, s = n.document.scrollingElement.scrollWidth, r = n.visualViewport.width, a = Math.round(s / r * t) % t, c = t === 1 || a === 0 ? 0 : t - a;
|
|
2525
|
+
if (c > 0)
|
|
2526
|
+
for (let u = 0; u < c; u++) {
|
|
2527
|
+
const d = n.document.createElement("div");
|
|
2528
|
+
d.setAttribute("id", `readium-virtual-page-${u}`), d.dataset.readium = "true", CSS.supports("break-before", "column") ? d.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (d.style.breakInside = "avoid-column"), d.style.height = ge(n.document.documentElement) + "px"), d.innerHTML = "​", n.document.body.appendChild(d);
|
|
2529
2529
|
}
|
|
2530
|
-
return i !==
|
|
2530
|
+
return i !== c;
|
|
2531
2531
|
}
|
|
2532
|
-
function Ft(
|
|
2533
|
-
const t =
|
|
2534
|
-
t.appendChild(
|
|
2532
|
+
function Ft(n) {
|
|
2533
|
+
const t = n.document.createElement("style");
|
|
2534
|
+
t.appendChild(n.document.createTextNode("*{}")), n.document.body.appendChild(t), n.document.body.removeChild(t);
|
|
2535
2535
|
}
|
|
2536
|
-
function pi(
|
|
2537
|
-
return
|
|
2536
|
+
function pi(n) {
|
|
2537
|
+
return n < 0.5 ? 2 * n * n : -1 + (4 - 2 * n) * n;
|
|
2538
2538
|
}
|
|
2539
|
-
function A(
|
|
2540
|
-
const t =
|
|
2539
|
+
function A(n) {
|
|
2540
|
+
const t = n.getSelection();
|
|
2541
2541
|
t && t.removeAllRanges();
|
|
2542
2542
|
}
|
|
2543
2543
|
const mi = [
|
|
@@ -2555,17 +2555,17 @@ const mi = [
|
|
|
2555
2555
|
"textarea",
|
|
2556
2556
|
"video"
|
|
2557
2557
|
], fi = ["dialog", "radiogroup", "radio", "menu", "menuitem"];
|
|
2558
|
-
function Gt(
|
|
2559
|
-
return gi(
|
|
2558
|
+
function Gt(n) {
|
|
2559
|
+
return gi(n) ? null : ze(n) ? n : n.parentElement ? Gt(n.parentElement) : null;
|
|
2560
2560
|
}
|
|
2561
|
-
function gi(
|
|
2562
|
-
return
|
|
2561
|
+
function gi(n) {
|
|
2562
|
+
return n ? n.closest("[inert]") !== null || n.hasAttribute("disabled") : !0;
|
|
2563
2563
|
}
|
|
2564
|
-
function ze(
|
|
2565
|
-
return
|
|
2564
|
+
function ze(n) {
|
|
2565
|
+
return n ? n.role && fi.includes(n.role) || n.tabIndex >= 0 ? !0 : mi.includes(n.nodeName.toLowerCase()) || n.hasAttribute("contenteditable") && n.getAttribute("contenteditable")?.toLowerCase() !== "false" : !1;
|
|
2566
2566
|
}
|
|
2567
|
-
function yt(
|
|
2568
|
-
const e = Me(
|
|
2567
|
+
function yt(n, t) {
|
|
2568
|
+
const e = Me(n, n.document.body, t), i = n._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2569
2569
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2570
2570
|
});
|
|
2571
2571
|
return new k({
|
|
@@ -2581,28 +2581,28 @@ function yt(r, t) {
|
|
|
2581
2581
|
})
|
|
2582
2582
|
});
|
|
2583
2583
|
}
|
|
2584
|
-
function Me(
|
|
2584
|
+
function Me(n, t, e) {
|
|
2585
2585
|
for (var i = 0; i < t.children.length; i++) {
|
|
2586
2586
|
const s = t.children[i];
|
|
2587
|
-
if (!vi(s) && yi(
|
|
2588
|
-
return bi(
|
|
2587
|
+
if (!vi(s) && yi(n, s, e))
|
|
2588
|
+
return bi(n, s) ? s : Me(n, s, e);
|
|
2589
2589
|
}
|
|
2590
2590
|
return t;
|
|
2591
2591
|
}
|
|
2592
|
-
function yi(
|
|
2592
|
+
function yi(n, t, e) {
|
|
2593
2593
|
if (t === document.body || t === document.documentElement)
|
|
2594
2594
|
return !0;
|
|
2595
2595
|
if (!document || !document.documentElement || !document.body)
|
|
2596
2596
|
return !1;
|
|
2597
2597
|
const i = t.getBoundingClientRect();
|
|
2598
|
-
return e ? i.bottom > 0 && i.top <
|
|
2598
|
+
return e ? i.bottom > 0 && i.top < n.innerHeight : i.right > 0 && i.left < n.innerWidth;
|
|
2599
2599
|
}
|
|
2600
|
-
function bi(
|
|
2600
|
+
function bi(n, t) {
|
|
2601
2601
|
const e = t.getBoundingClientRect();
|
|
2602
|
-
return e.top >= 0 && e.left >= 0 && e.bottom <=
|
|
2602
|
+
return e.top >= 0 && e.left >= 0 && e.bottom <= n.innerHeight && e.right <= n.innerWidth;
|
|
2603
2603
|
}
|
|
2604
|
-
function vi(
|
|
2605
|
-
const t = getComputedStyle(
|
|
2604
|
+
function vi(n) {
|
|
2605
|
+
const t = getComputedStyle(n);
|
|
2606
2606
|
if (t) {
|
|
2607
2607
|
const e = t.getPropertyValue("display");
|
|
2608
2608
|
if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
|
|
@@ -2649,16 +2649,16 @@ class bt {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
analyze(t, e, i) {
|
|
2651
2651
|
if (i <= 0) return !1;
|
|
2652
|
-
const s = Math.abs(e) / i,
|
|
2652
|
+
const s = Math.abs(e) / i, r = Date.now();
|
|
2653
2653
|
if (this.history.push({
|
|
2654
|
-
timestamp:
|
|
2654
|
+
timestamp: r,
|
|
2655
2655
|
direction: t,
|
|
2656
2656
|
velocity: s,
|
|
2657
2657
|
distance: Math.abs(e)
|
|
2658
|
-
}), this.history = this.history.filter((m) =>
|
|
2658
|
+
}), this.history = this.history.filter((m) => r - m.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
|
|
2659
2659
|
if (s > this.options.maxVelocity)
|
|
2660
2660
|
return this.resetAfterDetection(), !0;
|
|
2661
|
-
const o = this.history.map((m) => m.velocity), a = this.history.map((m) => m.distance),
|
|
2661
|
+
const o = this.history.map((m) => m.velocity), a = this.history.map((m) => m.distance), c = o.reduce((m, b) => m + b, 0) / o.length, u = a.reduce((m, b) => m + b, 0) / a.length, d = o.reduce((m, b) => m + Math.pow(b - c, 2), 0) / o.length, f = a.reduce((m, b) => m + Math.pow(b - u, 2), 0) / a.length;
|
|
2662
2662
|
if (d < this.options.minVariance && f < u * 0.1) {
|
|
2663
2663
|
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2664
2664
|
return this.resetAfterDetection(), !0;
|
|
@@ -2709,9 +2709,9 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2709
2709
|
return this.rtl ? Math.abs(t) : Math.max(0, this.wnd.scrollX > 0 ? this.wnd.scrollX : t);
|
|
2710
2710
|
}
|
|
2711
2711
|
reportProgress() {
|
|
2712
|
-
const t = this.cachedScrollWidth, e = this.wnd.innerWidth, i = this.normScroll(), s = Math.max(1, t - e),
|
|
2712
|
+
const t = this.cachedScrollWidth, e = this.wnd.innerWidth, i = this.normScroll(), s = Math.max(1, t - e), r = Math.max(0, Math.min(1, i / s)), o = Math.max(0, Math.min(1, (i + e) / t));
|
|
2713
2713
|
this.comms.send("progress", {
|
|
2714
|
-
start:
|
|
2714
|
+
start: r,
|
|
2715
2715
|
end: o
|
|
2716
2716
|
});
|
|
2717
2717
|
}
|
|
@@ -2732,16 +2732,16 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2732
2732
|
}
|
|
2733
2733
|
// Snaps the current offset to the page width.
|
|
2734
2734
|
snapCurrentOffset(t = !1, e = !1) {
|
|
2735
|
-
const i = this.doc(), s = Ie(this.wnd),
|
|
2735
|
+
const i = this.doc(), s = Ie(this.wnd), r = this.cachedScrollWidth - this.wnd.innerWidth, o = Math.min(Math.max(0, this.normScroll()), r), a = this.dragOffset(), c = this.rtl ? -a : a, u = this.wnd.innerWidth / 3 * (c > 0 ? 2 : 1), d = Math.min(r, Math.max(0, this.snapNormOffset(o + u))), f = this.rtl ? -d : d, p = this.rtl ? -o : o, v = f > p ? "right" : "left";
|
|
2736
2736
|
if (this.checkSuspiciousSnap(v, Math.abs(f - p)), t && f !== p) {
|
|
2737
2737
|
this.snappingCancelled = !1;
|
|
2738
|
-
const g = (_, V,
|
|
2738
|
+
const g = (_, V, nt, ot) => nt > ot ? V : _ + (V - _) * pi(nt / ot), m = Ei * s;
|
|
2739
2739
|
let b;
|
|
2740
2740
|
const D = (_) => {
|
|
2741
2741
|
if (this.snappingCancelled) return;
|
|
2742
2742
|
b || (b = _);
|
|
2743
|
-
const V = _ - b,
|
|
2744
|
-
i.scrollLeft = ot, this.overscroll !== 0 && (i.style.transform = `translate3d(${-
|
|
2743
|
+
const V = _ - b, nt = g(this.overscroll, 0, V, m), ot = g(p, f, V, m);
|
|
2744
|
+
i.scrollLeft = ot, this.overscroll !== 0 && (i.style.transform = `translate3d(${-nt}px, 0px, 0px)`), V < m ? this.wnd.requestAnimationFrame(D) : (this.clearTouches(), i.style.removeProperty("transform"), i.scrollLeft = f, e || this.reportProgress());
|
|
2745
2745
|
};
|
|
2746
2746
|
this.wnd.requestAnimationFrame(D);
|
|
2747
2747
|
} else
|
|
@@ -2771,8 +2771,8 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2771
2771
|
}
|
|
2772
2772
|
onTouchEnd(t) {
|
|
2773
2773
|
if (this.touchState === 2) {
|
|
2774
|
-
const e = this.dragOffset(), i = this.normScroll(), s = this.cachedScrollWidth - this.wnd.innerWidth,
|
|
2775
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(),
|
|
2774
|
+
const e = this.dragOffset(), i = this.normScroll(), s = this.cachedScrollWidth - this.wnd.innerWidth, r = this.rtl ? -e : e;
|
|
2775
|
+
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), r > 5 && this.comms.send("no_more", void 0), r < -5 && this.comms.send("no_less", void 0)) : i < 5 && r < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : s - i < 5 && r > 5 && (this.alreadyScrollLeft = this.rtl ? -s : s, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
|
|
2776
2776
|
}
|
|
2777
2777
|
this.touchState = 0;
|
|
2778
2778
|
}
|
|
@@ -2782,8 +2782,8 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2782
2782
|
onTouchMove(t) {
|
|
2783
2783
|
if (this.touchState === 0) return;
|
|
2784
2784
|
this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2785
|
-
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, s = this.rtl ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0,
|
|
2786
|
-
i < s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i >
|
|
2785
|
+
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, s = this.rtl ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0, r = this.rtl ? 0 : this.cachedScrollWidth - this.wnd.innerWidth;
|
|
2786
|
+
i < s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i > r ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = i);
|
|
2787
2787
|
}
|
|
2788
2788
|
enableSnapProtection() {
|
|
2789
2789
|
this.patternAnalyzer || (this.patternAnalyzer = new bt({
|
|
@@ -2853,7 +2853,7 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2853
2853
|
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((o) => {
|
|
2854
2854
|
for (const a of o)
|
|
2855
2855
|
if (a.target === this.wnd.document.documentElement) {
|
|
2856
|
-
const
|
|
2856
|
+
const c = a.oldValue, u = a.target.getAttribute("style"), d = /transform\s*:\s*([^;]+)/, f = c?.match(d), p = u?.match(d);
|
|
2857
2857
|
(!f && !p || f && !p || f && p && f[1] !== p[1]) && (t.requestAnimationFrame(() => {
|
|
2858
2858
|
t && ye(t);
|
|
2859
2859
|
}), this.onWidthChange());
|
|
@@ -2865,13 +2865,13 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2865
2865
|
const s = (o) => {
|
|
2866
2866
|
const a = this.doc().scrollLeft;
|
|
2867
2867
|
return this.doc().scrollLeft = this.snapOffset(o), a !== this.doc().scrollLeft;
|
|
2868
|
-
},
|
|
2869
|
-
const a = this.doc().scrollLeft,
|
|
2870
|
-
return this.doc().scrollLeft = -
|
|
2868
|
+
}, r = (o) => {
|
|
2869
|
+
const a = this.doc().scrollLeft, c = this.snapNormOffset(Math.max(0, Math.min(this.cachedScrollWidth - t.innerWidth, o)));
|
|
2870
|
+
return this.doc().scrollLeft = -c, a !== this.doc().scrollLeft;
|
|
2871
2871
|
};
|
|
2872
2872
|
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", T.moduleName, (o, a) => {
|
|
2873
|
-
const
|
|
2874
|
-
if (
|
|
2873
|
+
const c = o;
|
|
2874
|
+
if (c < 0 || c > 1) {
|
|
2875
2875
|
e.send("error", {
|
|
2876
2876
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2877
2877
|
}), a(!1);
|
|
@@ -2879,28 +2879,28 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2879
2879
|
}
|
|
2880
2880
|
this.wnd.requestAnimationFrame(() => {
|
|
2881
2881
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2882
|
-
const d = (this.cachedScrollWidth - t.innerWidth) *
|
|
2882
|
+
const d = (this.cachedScrollWidth - t.innerWidth) * c;
|
|
2883
2883
|
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(d) : this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), A(this.wnd), a(!0);
|
|
2884
2884
|
});
|
|
2885
2885
|
}), e.register("go_id", T.moduleName, (o, a) => {
|
|
2886
|
-
const
|
|
2887
|
-
if (!
|
|
2886
|
+
const c = t.document.getElementById(o);
|
|
2887
|
+
if (!c) {
|
|
2888
2888
|
a(!1);
|
|
2889
2889
|
return;
|
|
2890
2890
|
}
|
|
2891
2891
|
this.wnd.requestAnimationFrame(() => {
|
|
2892
|
-
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(
|
|
2892
|
+
this.rtl ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2893
2893
|
});
|
|
2894
2894
|
}), e.register("go_text", T.moduleName, (o, a) => {
|
|
2895
|
-
let
|
|
2896
|
-
Array.isArray(o) && (o.length > 1 && (
|
|
2897
|
-
const u = H.deserialize(o), d =
|
|
2895
|
+
let c;
|
|
2896
|
+
Array.isArray(o) && (o.length > 1 && (c = o[1]), o = o[0]);
|
|
2897
|
+
const u = H.deserialize(o), d = rt(this.wnd.document, new k({
|
|
2898
2898
|
href: t.location.href,
|
|
2899
2899
|
type: "text/html",
|
|
2900
2900
|
text: u,
|
|
2901
|
-
locations:
|
|
2901
|
+
locations: c ? new C({
|
|
2902
2902
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2903
|
-
["cssSelector",
|
|
2903
|
+
["cssSelector", c]
|
|
2904
2904
|
])
|
|
2905
2905
|
}) : void 0
|
|
2906
2906
|
}));
|
|
@@ -2914,9 +2914,9 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2914
2914
|
}), e.register("go_end", T.moduleName, (o, a) => {
|
|
2915
2915
|
this.wnd.requestAnimationFrame(() => {
|
|
2916
2916
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2917
|
-
let
|
|
2918
|
-
if (this.rtl ?
|
|
2919
|
-
this.doc().scrollLeft =
|
|
2917
|
+
let c;
|
|
2918
|
+
if (this.rtl ? c = -this.snapNormOffset(this.cachedScrollWidth - t.innerWidth) : c = this.snapOffset(this.cachedScrollWidth), this.doc().scrollLeft === c) return a(!1);
|
|
2919
|
+
this.doc().scrollLeft = c, this.reportProgress(), A(this.wnd), a(!0);
|
|
2920
2920
|
});
|
|
2921
2921
|
}), e.register("go_start", T.moduleName, (o, a) => {
|
|
2922
2922
|
this.wnd.requestAnimationFrame(() => {
|
|
@@ -2926,14 +2926,14 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2926
2926
|
}), e.register("go_prev", T.moduleName, (o, a) => {
|
|
2927
2927
|
this.wnd.requestAnimationFrame(() => {
|
|
2928
2928
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2929
|
-
let
|
|
2930
|
-
this.rtl ?
|
|
2929
|
+
let c;
|
|
2930
|
+
this.rtl ? c = r(this.normScroll() - t.innerWidth) : c = s(t.scrollX - t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), a(c);
|
|
2931
2931
|
});
|
|
2932
2932
|
}), e.register("go_next", T.moduleName, (o, a) => {
|
|
2933
2933
|
this.wnd.requestAnimationFrame(() => {
|
|
2934
2934
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2935
|
-
let
|
|
2936
|
-
this.rtl ?
|
|
2935
|
+
let c;
|
|
2936
|
+
this.rtl ? c = r(this.normScroll() + t.innerWidth) : c = s(t.scrollX + t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), a(c);
|
|
2937
2937
|
});
|
|
2938
2938
|
}), e.register("unfocus", T.moduleName, (o, a) => {
|
|
2939
2939
|
this.snappingCancelled = !0, A(this.wnd), a(!0);
|
|
@@ -2944,8 +2944,8 @@ const be = "readium-column-snapper-style", Ei = 200, T = class T extends X {
|
|
|
2944
2944
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), a(!0);
|
|
2945
2945
|
});
|
|
2946
2946
|
}), e.register("first_visible_locator", T.moduleName, (o, a) => {
|
|
2947
|
-
const
|
|
2948
|
-
this.comms.send("first_visible_locator",
|
|
2947
|
+
const c = yt(t, !1);
|
|
2948
|
+
this.comms.send("first_visible_locator", c.serialize()), a(!0);
|
|
2949
2949
|
}), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
|
|
2950
2950
|
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2951
2951
|
}
|
|
@@ -2967,11 +2967,11 @@ const ve = "readium-scroll-snapper-style", P = class P extends X {
|
|
|
2967
2967
|
this.reportProgress();
|
|
2968
2968
|
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
2969
2969
|
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
2970
|
-
const s = Date.now(),
|
|
2970
|
+
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
2971
2971
|
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
2972
2972
|
i > 0 ? "down" : "up",
|
|
2973
2973
|
Math.abs(i),
|
|
2974
|
-
|
|
2974
|
+
r
|
|
2975
2975
|
)) {
|
|
2976
2976
|
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
2977
2977
|
this.comms?.send("content_protection", {
|
|
@@ -2994,10 +2994,10 @@ const ve = "readium-scroll-snapper-style", P = class P extends X {
|
|
|
2994
2994
|
}
|
|
2995
2995
|
reportProgress() {
|
|
2996
2996
|
if (!this.comms.ready) return;
|
|
2997
|
-
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)),
|
|
2997
|
+
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), r = Math.max(0, Math.min(1, (t + i) / e));
|
|
2998
2998
|
this.comms.send("progress", {
|
|
2999
2999
|
start: s,
|
|
3000
|
-
end:
|
|
3000
|
+
end: r
|
|
3001
3001
|
});
|
|
3002
3002
|
}
|
|
3003
3003
|
enableScrollProtection() {
|
|
@@ -3022,30 +3022,30 @@ const ve = "readium-scroll-snapper-style", P = class P extends X {
|
|
|
3022
3022
|
Ft(this.wnd);
|
|
3023
3023
|
const s = this.doc().scrollTop;
|
|
3024
3024
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
3025
|
-
}), e.register("go_progression", P.moduleName, (s,
|
|
3025
|
+
}), e.register("go_progression", P.moduleName, (s, r) => {
|
|
3026
3026
|
const o = s;
|
|
3027
3027
|
if (o < 0 || o > 1) {
|
|
3028
3028
|
e.send("error", {
|
|
3029
3029
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3030
|
-
}),
|
|
3030
|
+
}), r(!1);
|
|
3031
3031
|
return;
|
|
3032
3032
|
}
|
|
3033
3033
|
this.wnd.requestAnimationFrame(() => {
|
|
3034
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd),
|
|
3034
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), r(!0);
|
|
3035
3035
|
});
|
|
3036
|
-
}), e.register("go_id", P.moduleName, (s,
|
|
3036
|
+
}), e.register("go_id", P.moduleName, (s, r) => {
|
|
3037
3037
|
const o = t.document.getElementById(s);
|
|
3038
3038
|
if (!o) {
|
|
3039
|
-
|
|
3039
|
+
r(!1);
|
|
3040
3040
|
return;
|
|
3041
3041
|
}
|
|
3042
3042
|
this.wnd.requestAnimationFrame(() => {
|
|
3043
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd),
|
|
3043
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3044
3044
|
});
|
|
3045
|
-
}), e.register("go_text", P.moduleName, (s,
|
|
3045
|
+
}), e.register("go_text", P.moduleName, (s, r) => {
|
|
3046
3046
|
let o;
|
|
3047
3047
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3048
|
-
const a = H.deserialize(s),
|
|
3048
|
+
const a = H.deserialize(s), c = rt(this.wnd.document, new k({
|
|
3049
3049
|
href: t.location.href,
|
|
3050
3050
|
type: "text/html",
|
|
3051
3051
|
text: a,
|
|
@@ -3055,31 +3055,31 @@ const ve = "readium-scroll-snapper-style", P = class P extends X {
|
|
|
3055
3055
|
])
|
|
3056
3056
|
}) : void 0
|
|
3057
3057
|
}));
|
|
3058
|
-
if (!
|
|
3059
|
-
|
|
3058
|
+
if (!c) {
|
|
3059
|
+
r(!1);
|
|
3060
3060
|
return;
|
|
3061
3061
|
}
|
|
3062
3062
|
this.wnd.requestAnimationFrame(() => {
|
|
3063
|
-
this.doc().scrollTop =
|
|
3063
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3064
3064
|
});
|
|
3065
|
-
}), e.register("go_start", P.moduleName, (s,
|
|
3066
|
-
if (this.doc().scrollTop === 0) return
|
|
3067
|
-
this.doc().scrollTop = 0, this.reportProgress(),
|
|
3068
|
-
}), e.register("go_end", P.moduleName, (s,
|
|
3069
|
-
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return
|
|
3070
|
-
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(),
|
|
3071
|
-
}), e.register("unfocus", P.moduleName, (s,
|
|
3072
|
-
A(this.wnd),
|
|
3073
|
-
}), e.register("scroll_protection", P.moduleName, (s,
|
|
3074
|
-
this.enableScrollProtection(),
|
|
3065
|
+
}), e.register("go_start", P.moduleName, (s, r) => {
|
|
3066
|
+
if (this.doc().scrollTop === 0) return r(!1);
|
|
3067
|
+
this.doc().scrollTop = 0, this.reportProgress(), r(!0);
|
|
3068
|
+
}), e.register("go_end", P.moduleName, (s, r) => {
|
|
3069
|
+
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return r(!1);
|
|
3070
|
+
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), r(!0);
|
|
3071
|
+
}), e.register("unfocus", P.moduleName, (s, r) => {
|
|
3072
|
+
A(this.wnd), r(!0);
|
|
3073
|
+
}), e.register("scroll_protection", P.moduleName, (s, r) => {
|
|
3074
|
+
this.enableScrollProtection(), r(!0);
|
|
3075
3075
|
}), e.register([
|
|
3076
3076
|
"go_next",
|
|
3077
3077
|
"go_prev"
|
|
3078
|
-
], P.moduleName, (s,
|
|
3079
|
-
this.reportProgress(),
|
|
3080
|
-
}), e.register("first_visible_locator", P.moduleName, (s,
|
|
3078
|
+
], P.moduleName, (s, r) => r(!1)), e.register("focus", P.moduleName, (s, r) => {
|
|
3079
|
+
this.reportProgress(), r(!0);
|
|
3080
|
+
}), e.register("first_visible_locator", P.moduleName, (s, r) => {
|
|
3081
3081
|
const o = yt(t, !0);
|
|
3082
|
-
this.comms.send("first_visible_locator", o.serialize()),
|
|
3082
|
+
this.comms.send("first_visible_locator", o.serialize()), r(!0);
|
|
3083
3083
|
}), e.log("ScrollSnapper Mounted"), !0;
|
|
3084
3084
|
}
|
|
3085
3085
|
unmount(t, e) {
|
|
@@ -3100,11 +3100,11 @@ const N = class N extends X {
|
|
|
3100
3100
|
this.reportProgress();
|
|
3101
3101
|
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
3102
3102
|
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3103
|
-
const s = Date.now(),
|
|
3103
|
+
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
3104
3104
|
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3105
3105
|
i > 0 ? "down" : "up",
|
|
3106
3106
|
Math.abs(i),
|
|
3107
|
-
|
|
3107
|
+
r
|
|
3108
3108
|
)) {
|
|
3109
3109
|
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3110
3110
|
this.comms?.send("content_protection", {
|
|
@@ -3127,10 +3127,10 @@ const N = class N extends X {
|
|
|
3127
3127
|
}
|
|
3128
3128
|
reportProgress() {
|
|
3129
3129
|
if (!this.comms.ready) return;
|
|
3130
|
-
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)),
|
|
3130
|
+
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), r = Math.max(0, Math.min(1, (t + i) / e));
|
|
3131
3131
|
this.comms.send("progress", {
|
|
3132
3132
|
start: s,
|
|
3133
|
-
end:
|
|
3133
|
+
end: r
|
|
3134
3134
|
});
|
|
3135
3135
|
}
|
|
3136
3136
|
enableScrollProtection() {
|
|
@@ -3146,35 +3146,35 @@ const N = class N extends X {
|
|
|
3146
3146
|
const i = this.doc().scrollTop;
|
|
3147
3147
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
3148
3148
|
}), e.register("go_progression", N.moduleName, (i, s) => {
|
|
3149
|
-
const
|
|
3150
|
-
if (
|
|
3149
|
+
const r = i;
|
|
3150
|
+
if (r < 0 || r > 1) {
|
|
3151
3151
|
e.send("error", {
|
|
3152
3152
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3153
3153
|
}), s(!1);
|
|
3154
3154
|
return;
|
|
3155
3155
|
}
|
|
3156
3156
|
this.wnd.requestAnimationFrame(() => {
|
|
3157
|
-
this.doc().scrollTop = this.doc().offsetHeight *
|
|
3157
|
+
this.doc().scrollTop = this.doc().offsetHeight * r, this.reportProgress(), A(this.wnd), s(!0);
|
|
3158
3158
|
});
|
|
3159
3159
|
}), e.register("go_id", N.moduleName, (i, s) => {
|
|
3160
|
-
const
|
|
3161
|
-
if (!
|
|
3160
|
+
const r = t.document.getElementById(i);
|
|
3161
|
+
if (!r) {
|
|
3162
3162
|
s(!1);
|
|
3163
3163
|
return;
|
|
3164
3164
|
}
|
|
3165
3165
|
this.wnd.requestAnimationFrame(() => {
|
|
3166
|
-
this.doc().scrollTop =
|
|
3166
|
+
this.doc().scrollTop = r.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3167
3167
|
});
|
|
3168
3168
|
}), e.register("go_text", N.moduleName, (i, s) => {
|
|
3169
|
-
let
|
|
3170
|
-
Array.isArray(i) && (i.length > 1 && (
|
|
3171
|
-
const o = H.deserialize(i), a =
|
|
3169
|
+
let r;
|
|
3170
|
+
Array.isArray(i) && (i.length > 1 && (r = i[1]), i = i[0]);
|
|
3171
|
+
const o = H.deserialize(i), a = rt(this.wnd.document, new k({
|
|
3172
3172
|
href: t.location.href,
|
|
3173
3173
|
type: "text/html",
|
|
3174
3174
|
text: o,
|
|
3175
|
-
locations:
|
|
3175
|
+
locations: r ? new C({
|
|
3176
3176
|
otherLocations: /* @__PURE__ */ new Map([
|
|
3177
|
-
["cssSelector",
|
|
3177
|
+
["cssSelector", r]
|
|
3178
3178
|
])
|
|
3179
3179
|
}) : void 0
|
|
3180
3180
|
}));
|
|
@@ -3201,8 +3201,8 @@ const N = class N extends X {
|
|
|
3201
3201
|
], N.moduleName, (i, s) => s(!1)), e.register("focus", N.moduleName, (i, s) => {
|
|
3202
3202
|
this.reportProgress(), s(!0);
|
|
3203
3203
|
}), e.register("first_visible_locator", N.moduleName, (i, s) => {
|
|
3204
|
-
const
|
|
3205
|
-
e.send("first_visible_locator",
|
|
3204
|
+
const r = yt(t, !0);
|
|
3205
|
+
e.send("first_visible_locator", r.serialize()), s(!0);
|
|
3206
3206
|
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3207
3207
|
}
|
|
3208
3208
|
unmount(t, e) {
|
|
@@ -3224,23 +3224,23 @@ class Ai {
|
|
|
3224
3224
|
return this.copyHistory.length < 3 ? !1 : this.copyHistory.filter(
|
|
3225
3225
|
(s) => t - s.timestamp < 2e3
|
|
3226
3226
|
// Last 2 seconds
|
|
3227
|
-
).length >= 3 ? !0 : this.copyHistory.slice().sort((s,
|
|
3227
|
+
).length >= 3 ? !0 : this.copyHistory.slice().sort((s, r) => s.timestamp - r.timestamp).every((s, r, o) => r === 0 ? !0 : s.length > o[r - 1].length * 1.5);
|
|
3228
3228
|
}
|
|
3229
3229
|
shouldAllowCopy(t) {
|
|
3230
3230
|
if (!this.options.enabled) return !0;
|
|
3231
3231
|
const e = this.window.getSelection();
|
|
3232
3232
|
if (!e) return !0;
|
|
3233
|
-
const s = e.toString().length,
|
|
3233
|
+
const s = e.toString().length, r = this.window.document.body.innerText.length, o = Date.now();
|
|
3234
3234
|
if (this.cleanupOldHistory(o), s < this.options.minThreshold)
|
|
3235
3235
|
return this.copyHistory.push({
|
|
3236
3236
|
timestamp: o,
|
|
3237
3237
|
length: s,
|
|
3238
3238
|
wasBlocked: !1
|
|
3239
3239
|
}), !0;
|
|
3240
|
-
const
|
|
3241
|
-
|
|
3240
|
+
const c = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, u = Math.min(
|
|
3241
|
+
r * this.options.maxSelectionPercent,
|
|
3242
3242
|
this.options.absoluteMaxChars
|
|
3243
|
-
), d = this.isSuspiciousPattern(o), f = s > u ||
|
|
3243
|
+
), d = this.isSuspiciousPattern(o), f = s > u || c || d;
|
|
3244
3244
|
return this.copyHistory.push({
|
|
3245
3245
|
timestamp: o,
|
|
3246
3246
|
length: s,
|
|
@@ -3271,15 +3271,15 @@ class Ci {
|
|
|
3271
3271
|
if (i - this.selectionStartTime < 500)
|
|
3272
3272
|
return !1;
|
|
3273
3273
|
i - this.lastSelectionTime > 1e3 && (this.lastSelectionTime = i), this.selectionStartTime === 0 && (this.selectionStartTime = i), this.lastSelectedText = e;
|
|
3274
|
-
const
|
|
3275
|
-
return this.cleanup(i),
|
|
3274
|
+
const r = this.analyzeSelectionPattern(t, i);
|
|
3275
|
+
return this.cleanup(i), r;
|
|
3276
3276
|
}
|
|
3277
3277
|
analyzeSelectionPattern(t, e) {
|
|
3278
3278
|
if (!t.rangeCount) return !1;
|
|
3279
|
-
const i = t.getRangeAt(0), s = i.toString(),
|
|
3280
|
-
if (s.length / Math.max(1,
|
|
3281
|
-
const a = i.startOffset,
|
|
3282
|
-
return this.selectionPatterns.push(
|
|
3279
|
+
const i = t.getRangeAt(0), s = i.toString(), r = (e - this.selectionStartTime) / 1e3;
|
|
3280
|
+
if (s.length / Math.max(1, r) > this.options.maxSelectionsPerSecond) return !0;
|
|
3281
|
+
const a = i.startOffset, c = Math.abs(a - this.lastSelectionPosition);
|
|
3282
|
+
return this.selectionPatterns.push(c), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
|
|
3283
3283
|
}
|
|
3284
3284
|
calculateVariance(t) {
|
|
3285
3285
|
if (t.length === 0) return 0;
|
|
@@ -3298,13 +3298,17 @@ class xi {
|
|
|
3298
3298
|
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3299
3299
|
*/
|
|
3300
3300
|
match(t, e) {
|
|
3301
|
-
for (const i of e)
|
|
3302
|
-
|
|
3303
|
-
if (s && n && o && a && l)
|
|
3301
|
+
for (const i of e)
|
|
3302
|
+
if (this.matchesCombo(t, i))
|
|
3304
3303
|
return !0;
|
|
3305
|
-
}
|
|
3306
3304
|
return !1;
|
|
3307
3305
|
}
|
|
3306
|
+
matchesCombo(t, e) {
|
|
3307
|
+
return t.keyCode === e.keyCode && this.matchesModifier(t.ctrlKey, e.ctrl) && this.matchesModifier(t.shiftKey, e.shift) && this.matchesModifier(t.altKey, e.alt) && this.matchesModifier(t.metaKey, e.meta);
|
|
3308
|
+
}
|
|
3309
|
+
matchesModifier(t, e) {
|
|
3310
|
+
return e === void 0 ? !t : t === e;
|
|
3311
|
+
}
|
|
3308
3312
|
/**
|
|
3309
3313
|
* Creates an event handler that will call the provided handler when any of the key combinations match
|
|
3310
3314
|
*/
|
|
@@ -3317,11 +3321,11 @@ class xi {
|
|
|
3317
3321
|
* Creates a standardized activity event for keyboard shortcuts
|
|
3318
3322
|
*/
|
|
3319
3323
|
createActivityEvent(t, e, i, s) {
|
|
3320
|
-
let
|
|
3324
|
+
let r, o;
|
|
3321
3325
|
if (s) {
|
|
3322
|
-
const a = s.getSelection(),
|
|
3323
|
-
d &&
|
|
3324
|
-
text:
|
|
3326
|
+
const a = s.getSelection(), c = a?.toString() || "", d = (c && a?.rangeCount ? a.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3327
|
+
d && c && (r = {
|
|
3328
|
+
text: c,
|
|
3325
3329
|
x: d.x,
|
|
3326
3330
|
y: d.y,
|
|
3327
3331
|
width: d.width,
|
|
@@ -3341,7 +3345,7 @@ class xi {
|
|
|
3341
3345
|
shiftKey: t.shiftKey,
|
|
3342
3346
|
metaKey: t.metaKey,
|
|
3343
3347
|
targetFrameSrc: i,
|
|
3344
|
-
selectedText:
|
|
3348
|
+
selectedText: r,
|
|
3345
3349
|
interactiveElement: o
|
|
3346
3350
|
};
|
|
3347
3351
|
}
|
|
@@ -3349,29 +3353,29 @@ class xi {
|
|
|
3349
3353
|
* Creates handlers for keyboard shortcuts with centralized activity event dispatch
|
|
3350
3354
|
*/
|
|
3351
3355
|
createKeyboardHandlers(t, e, i, s) {
|
|
3352
|
-
const
|
|
3356
|
+
const r = [];
|
|
3353
3357
|
return e.forEach((o) => {
|
|
3354
|
-
|
|
3358
|
+
r.push(...o.keyCombos.map((a) => ({
|
|
3355
3359
|
...a,
|
|
3356
|
-
handler: (
|
|
3357
|
-
const u = o.type, d = this.createActivityEvent(
|
|
3360
|
+
handler: (c) => {
|
|
3361
|
+
const u = o.type, d = this.createActivityEvent(c, u, t, s);
|
|
3358
3362
|
i(d);
|
|
3359
3363
|
}
|
|
3360
3364
|
})));
|
|
3361
|
-
}),
|
|
3365
|
+
}), r;
|
|
3362
3366
|
}
|
|
3363
3367
|
/**
|
|
3364
3368
|
* Creates a unified keyboard event handler that processes all shortcuts
|
|
3365
3369
|
*/
|
|
3366
3370
|
createUnifiedHandler(t, e, i, s) {
|
|
3367
|
-
const
|
|
3371
|
+
const r = this.createKeyboardHandlers(t, e, i, s);
|
|
3368
3372
|
return (o) => {
|
|
3369
|
-
for (const a of
|
|
3373
|
+
for (const a of r)
|
|
3370
3374
|
if (this.match(o, [a])) {
|
|
3371
|
-
const
|
|
3372
|
-
if (
|
|
3373
|
-
const u = document.activeElement;
|
|
3374
|
-
if (Array.isArray(
|
|
3375
|
+
const c = a.suppressOnInteractiveElement;
|
|
3376
|
+
if (c) {
|
|
3377
|
+
const u = (s?.document ?? document).activeElement;
|
|
3378
|
+
if (Array.isArray(c) ? c.some((d) => u?.matches(d)) : ze(u)) return;
|
|
3375
3379
|
}
|
|
3376
3380
|
o.preventDefault(), o.stopPropagation(), a.handler(o);
|
|
3377
3381
|
return;
|
|
@@ -3386,16 +3390,16 @@ const Y = class Y extends K {
|
|
|
3386
3390
|
return !0;
|
|
3387
3391
|
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
3388
3392
|
t.preventDefault();
|
|
3389
|
-
const e = this.wnd.getSelection(), i = e?.toString() || "",
|
|
3393
|
+
const e = this.wnd.getSelection(), i = e?.toString() || "", r = (i ? e?.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3390
3394
|
type: "bulk_copy",
|
|
3391
3395
|
timestamp: Date.now(),
|
|
3392
3396
|
clipboardTypes: t.clipboardData?.types ? [...t.clipboardData.types] : [],
|
|
3393
|
-
selectedText:
|
|
3397
|
+
selectedText: r ? {
|
|
3394
3398
|
text: i,
|
|
3395
|
-
x:
|
|
3396
|
-
y:
|
|
3397
|
-
width:
|
|
3398
|
-
height:
|
|
3399
|
+
x: r.x,
|
|
3400
|
+
y: r.y,
|
|
3401
|
+
width: r.width,
|
|
3402
|
+
height: r.height
|
|
3399
3403
|
} : void 0,
|
|
3400
3404
|
selectionLength: i.length,
|
|
3401
3405
|
targetFrameSrc: this.wnd.location.href
|
|
@@ -3409,12 +3413,12 @@ const Y = class Y extends K {
|
|
|
3409
3413
|
const e = this.wnd.getSelection();
|
|
3410
3414
|
if (e) {
|
|
3411
3415
|
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3412
|
-
const s = this.wnd.getSelection(),
|
|
3416
|
+
const s = this.wnd.getSelection(), r = s?.toString() || "", a = (r && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], c = {
|
|
3413
3417
|
type: "suspicious_selection",
|
|
3414
3418
|
timestamp: Date.now(),
|
|
3415
|
-
selectionLength:
|
|
3419
|
+
selectionLength: r.length,
|
|
3416
3420
|
selectedText: {
|
|
3417
|
-
text:
|
|
3421
|
+
text: r,
|
|
3418
3422
|
x: a?.x ?? 0,
|
|
3419
3423
|
y: a?.y ?? 0,
|
|
3420
3424
|
width: a?.width ?? 0,
|
|
@@ -3423,7 +3427,7 @@ const Y = class Y extends K {
|
|
|
3423
3427
|
eventType: t?.type || "selectionchange",
|
|
3424
3428
|
targetFrameSrc: this.wnd.location.href
|
|
3425
3429
|
};
|
|
3426
|
-
this.comms?.send("content_protection",
|
|
3430
|
+
this.comms?.send("content_protection", c);
|
|
3427
3431
|
}
|
|
3428
3432
|
} else
|
|
3429
3433
|
this.currentSelection = null;
|
|
@@ -3457,17 +3461,17 @@ const Y = class Y extends K {
|
|
|
3457
3461
|
}, this.onContext = (t) => {
|
|
3458
3462
|
if (this.isContextMenuEnabled) {
|
|
3459
3463
|
t.preventDefault();
|
|
3460
|
-
const e = this.wnd.getSelection(), i = e?.toString() || "",
|
|
3464
|
+
const e = this.wnd.getSelection(), i = e?.toString() || "", r = (i && e?.rangeCount ? e.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3461
3465
|
timestamp: Date.now(),
|
|
3462
3466
|
clientX: t.clientX,
|
|
3463
3467
|
clientY: t.clientY,
|
|
3464
|
-
...
|
|
3468
|
+
...r && {
|
|
3465
3469
|
selectedText: {
|
|
3466
3470
|
text: i,
|
|
3467
|
-
x:
|
|
3468
|
-
y:
|
|
3469
|
-
width:
|
|
3470
|
-
height:
|
|
3471
|
+
x: r.x,
|
|
3472
|
+
y: r.y,
|
|
3473
|
+
width: r.width,
|
|
3474
|
+
height: r.height
|
|
3471
3475
|
}
|
|
3472
3476
|
},
|
|
3473
3477
|
targetFrameSrc: this.wnd.location.href
|
|
@@ -3524,12 +3528,12 @@ const Y = class Y extends K {
|
|
|
3524
3528
|
const s = e.getRangeAt(0)?.getClientRects();
|
|
3525
3529
|
if (!s || s.length === 0)
|
|
3526
3530
|
return;
|
|
3527
|
-
const
|
|
3531
|
+
const r = s[0], o = {
|
|
3528
3532
|
text: e.toString(),
|
|
3529
|
-
x:
|
|
3530
|
-
y:
|
|
3531
|
-
width:
|
|
3532
|
-
height:
|
|
3533
|
+
x: r.x,
|
|
3534
|
+
y: r.y,
|
|
3535
|
+
width: r.width,
|
|
3536
|
+
height: r.height,
|
|
3533
3537
|
targetFrameSrc: this.wnd?.location?.href
|
|
3534
3538
|
};
|
|
3535
3539
|
this.comms.send("text_selected", o);
|
|
@@ -3627,11 +3631,11 @@ const et = class et extends K {
|
|
|
3627
3631
|
case 1:
|
|
3628
3632
|
const i = e[1], s = e[2];
|
|
3629
3633
|
t.removeEventListener(i.type, t._readium_eventBlocker, !0);
|
|
3630
|
-
const
|
|
3634
|
+
const r = new Event(i.type, {
|
|
3631
3635
|
bubbles: i.bubbles,
|
|
3632
3636
|
cancelable: i.cancelable
|
|
3633
3637
|
});
|
|
3634
|
-
s ? s.dispatchEvent(
|
|
3638
|
+
s ? s.dispatchEvent(r) : t.dispatchEvent(r);
|
|
3635
3639
|
break;
|
|
3636
3640
|
}
|
|
3637
3641
|
}
|
|
@@ -3655,8 +3659,8 @@ const et = class et extends K {
|
|
|
3655
3659
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3656
3660
|
value: {
|
|
3657
3661
|
name: "readium-ts-toolkit",
|
|
3658
|
-
version: "2.4.2-beta.
|
|
3659
|
-
hasFeature: (s,
|
|
3662
|
+
version: "2.4.2-beta.3",
|
|
3663
|
+
hasFeature: (s, r = "") => {
|
|
3660
3664
|
switch (s) {
|
|
3661
3665
|
case "dom-manipulation":
|
|
3662
3666
|
return !0;
|
|
@@ -3680,19 +3684,19 @@ const et = class et extends K {
|
|
|
3680
3684
|
writable: !1
|
|
3681
3685
|
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3682
3686
|
s.cancel(), this.allAnimations.add(s);
|
|
3683
|
-
}), e.register("activate", et.moduleName, (s,
|
|
3687
|
+
}), e.register("activate", et.moduleName, (s, r) => {
|
|
3684
3688
|
this.allAnimations.forEach((o) => {
|
|
3685
3689
|
o.cancel(), o.play();
|
|
3686
|
-
}),
|
|
3687
|
-
}), e.register("unfocus", et.moduleName, (s,
|
|
3688
|
-
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()),
|
|
3690
|
+
}), r(!0);
|
|
3691
|
+
}), e.register("unfocus", et.moduleName, (s, r) => {
|
|
3692
|
+
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), r(!0);
|
|
3689
3693
|
});
|
|
3690
3694
|
const i = t.document.querySelectorAll("audio,video");
|
|
3691
3695
|
for (let s = 0; s < i.length; s++) {
|
|
3692
|
-
const
|
|
3693
|
-
|
|
3696
|
+
const r = i[s];
|
|
3697
|
+
r.addEventListener("play", this.onMediaPlayEvent, {
|
|
3694
3698
|
passive: !0
|
|
3695
|
-
}),
|
|
3699
|
+
}), r.addEventListener("pause", this.onMediaPauseEvent, {
|
|
3696
3700
|
passive: !0
|
|
3697
3701
|
});
|
|
3698
3702
|
}
|
|
@@ -3717,17 +3721,17 @@ const we = "readium-viewport", W = class W extends ft {
|
|
|
3717
3721
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3718
3722
|
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3719
3723
|
target: t
|
|
3720
|
-
}), e.register("get_properties", W.moduleName, (s,
|
|
3721
|
-
Vt(t),
|
|
3722
|
-
}), e.register("update_properties", W.moduleName, (s,
|
|
3723
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`, De(t, s),
|
|
3724
|
-
}), e.register("set_property", W.moduleName, (s,
|
|
3724
|
+
}), e.register("get_properties", W.moduleName, (s, r) => {
|
|
3725
|
+
Vt(t), r(!0);
|
|
3726
|
+
}), e.register("update_properties", W.moduleName, (s, r) => {
|
|
3727
|
+
s["--RS__viewportWidth"] = `${t.innerWidth}px`, De(t, s), r(!0);
|
|
3728
|
+
}), e.register("set_property", W.moduleName, (s, r) => {
|
|
3725
3729
|
const o = s;
|
|
3726
|
-
st(t, o[0], o[1]),
|
|
3727
|
-
}), e.register("remove_property", W.moduleName, (s,
|
|
3728
|
-
gt(t, s),
|
|
3729
|
-
}), e.register("activate", W.moduleName, (s,
|
|
3730
|
-
this.unblock(t),
|
|
3730
|
+
st(t, o[0], o[1]), r(!0);
|
|
3731
|
+
}), e.register("remove_property", W.moduleName, (s, r) => {
|
|
3732
|
+
gt(t, s), r(!0);
|
|
3733
|
+
}), e.register("activate", W.moduleName, (s, r) => {
|
|
3734
|
+
this.unblock(t), r(!0);
|
|
3731
3735
|
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3732
3736
|
}
|
|
3733
3737
|
unmount(t, e) {
|
|
@@ -3753,13 +3757,13 @@ const Se = "readium-fixed-style", z = class z extends ft {
|
|
|
3753
3757
|
min-height: 100%;
|
|
3754
3758
|
|
|
3755
3759
|
/*cursor: var() TODO*/
|
|
3756
|
-
}`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s,
|
|
3760
|
+
}`, t.document.head.appendChild(i), e.register("set_property", z.moduleName, (s, r) => {
|
|
3757
3761
|
const o = s;
|
|
3758
|
-
st(t, o[0], o[1]),
|
|
3759
|
-
}), e.register("remove_property", z.moduleName, (s,
|
|
3760
|
-
gt(t, s),
|
|
3761
|
-
}), e.register("first_visible_locator", z.moduleName, (s,
|
|
3762
|
-
A(t),
|
|
3762
|
+
st(t, o[0], o[1]), r(!0);
|
|
3763
|
+
}), e.register("remove_property", z.moduleName, (s, r) => {
|
|
3764
|
+
gt(t, s), r(!0);
|
|
3765
|
+
}), e.register("first_visible_locator", z.moduleName, (s, r) => r(!1)), e.register("unfocus", z.moduleName, (s, r) => {
|
|
3766
|
+
A(t), r(!0);
|
|
3763
3767
|
}), e.register([
|
|
3764
3768
|
"focus",
|
|
3765
3769
|
"go_next",
|
|
@@ -3769,8 +3773,8 @@ const Se = "readium-fixed-style", z = class z extends ft {
|
|
|
3769
3773
|
"go_start",
|
|
3770
3774
|
"go_text",
|
|
3771
3775
|
"go_progression"
|
|
3772
|
-
], z.moduleName, (s,
|
|
3773
|
-
this.unblock(t),
|
|
3776
|
+
], z.moduleName, (s, r) => r(!0)), e.register("activate", z.moduleName, (s, r) => {
|
|
3777
|
+
this.unblock(t), r(!0);
|
|
3774
3778
|
}), e.log("FixedSetup Mounted"), !0;
|
|
3775
3779
|
}
|
|
3776
3780
|
unmount(t, e) {
|
|
@@ -3798,8 +3802,8 @@ const U = class U extends K {
|
|
|
3798
3802
|
}), e.register("update_properties", U.moduleName, (i, s) => {
|
|
3799
3803
|
De(t, i), s(!0);
|
|
3800
3804
|
}), e.register("set_property", U.moduleName, (i, s) => {
|
|
3801
|
-
const
|
|
3802
|
-
st(t,
|
|
3805
|
+
const r = i;
|
|
3806
|
+
st(t, r[0], r[1]), s(!0);
|
|
3803
3807
|
}), e.register("remove_property", U.moduleName, (i, s) => {
|
|
3804
3808
|
gt(t, i), s(!0);
|
|
3805
3809
|
}), e.register("activate", U.moduleName, (i, s) => {
|
|
@@ -3862,13 +3866,13 @@ const Ee = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
|
3862
3866
|
this.reportProgress();
|
|
3863
3867
|
const e = Math.abs(this.doc().scrollLeft), i = e - this.lastScrollLeft;
|
|
3864
3868
|
if (this.lastScrollLeft = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3865
|
-
const s = Date.now(),
|
|
3869
|
+
const s = Date.now(), r = s - (this.lastScrollTime || s);
|
|
3866
3870
|
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3867
3871
|
// In vertical-rl, norm increases when scrolling forward (toward left/end),
|
|
3868
3872
|
// so deltaX > 0 = going forward.
|
|
3869
3873
|
i > 0 ? "down" : "up",
|
|
3870
3874
|
Math.abs(i),
|
|
3871
|
-
|
|
3875
|
+
r
|
|
3872
3876
|
)) {
|
|
3873
3877
|
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3874
3878
|
this.comms?.send("content_protection", {
|
|
@@ -3895,9 +3899,9 @@ const Ee = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
|
3895
3899
|
}
|
|
3896
3900
|
reportProgress() {
|
|
3897
3901
|
if (!this.comms.ready) return;
|
|
3898
|
-
const t = this.doc().scrollWidth, e = this.wnd.innerWidth, i = Math.max(1, t - e), s = Math.abs(this.doc().scrollLeft),
|
|
3902
|
+
const t = this.doc().scrollWidth, e = this.wnd.innerWidth, i = Math.max(1, t - e), s = Math.abs(this.doc().scrollLeft), r = Math.max(0, Math.min(1, s / i)), o = Math.max(0, Math.min(1, (s + e) / t));
|
|
3899
3903
|
this.comms.send("progress", {
|
|
3900
|
-
start:
|
|
3904
|
+
start: r,
|
|
3901
3905
|
end: o
|
|
3902
3906
|
});
|
|
3903
3907
|
}
|
|
@@ -3926,31 +3930,31 @@ const Ee = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
|
3926
3930
|
Ft(this.wnd);
|
|
3927
3931
|
const s = this.doc().scrollLeft;
|
|
3928
3932
|
this.verticalLR ? this.doc().scrollLeft = s > 1 ? s - 1 : s + 1 : this.doc().scrollLeft = s < -1 ? s + 1 : s - 1, this.doc().scrollLeft = s;
|
|
3929
|
-
}), e.register("go_progression", L.moduleName, (s,
|
|
3933
|
+
}), e.register("go_progression", L.moduleName, (s, r) => {
|
|
3930
3934
|
const o = s;
|
|
3931
3935
|
if (o < 0 || o > 1) {
|
|
3932
3936
|
e.send("error", {
|
|
3933
3937
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3934
|
-
}),
|
|
3938
|
+
}), r(!1);
|
|
3935
3939
|
return;
|
|
3936
3940
|
}
|
|
3937
3941
|
this.wnd.requestAnimationFrame(() => {
|
|
3938
3942
|
const a = this.scrollable() * o;
|
|
3939
|
-
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(), A(this.wnd),
|
|
3943
|
+
this.doc().scrollLeft = this.verticalLR ? a : -a, this.reportProgress(), A(this.wnd), r(!0);
|
|
3940
3944
|
});
|
|
3941
|
-
}), e.register("go_id", L.moduleName, (s,
|
|
3945
|
+
}), e.register("go_id", L.moduleName, (s, r) => {
|
|
3942
3946
|
const o = t.document.getElementById(s);
|
|
3943
3947
|
if (!o) {
|
|
3944
|
-
|
|
3948
|
+
r(!1);
|
|
3945
3949
|
return;
|
|
3946
3950
|
}
|
|
3947
3951
|
this.wnd.requestAnimationFrame(() => {
|
|
3948
|
-
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd),
|
|
3952
|
+
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3949
3953
|
});
|
|
3950
|
-
}), e.register("go_text", L.moduleName, (s,
|
|
3954
|
+
}), e.register("go_text", L.moduleName, (s, r) => {
|
|
3951
3955
|
let o;
|
|
3952
3956
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3953
|
-
const a = H.deserialize(s),
|
|
3957
|
+
const a = H.deserialize(s), c = rt(this.wnd.document, new k({
|
|
3954
3958
|
href: t.location.href,
|
|
3955
3959
|
type: "text/html",
|
|
3956
3960
|
text: a,
|
|
@@ -3958,31 +3962,31 @@ const Ee = "readium-cjk-vertical-snapper-style", L = class L extends X {
|
|
|
3958
3962
|
otherLocations: /* @__PURE__ */ new Map([["cssSelector", o]])
|
|
3959
3963
|
}) : void 0
|
|
3960
3964
|
}));
|
|
3961
|
-
if (!
|
|
3962
|
-
|
|
3965
|
+
if (!c) {
|
|
3966
|
+
r(!1);
|
|
3963
3967
|
return;
|
|
3964
3968
|
}
|
|
3965
3969
|
this.wnd.requestAnimationFrame(() => {
|
|
3966
|
-
this.doc().scrollLeft +=
|
|
3970
|
+
this.doc().scrollLeft += c.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), r(!0);
|
|
3967
3971
|
});
|
|
3968
|
-
}), e.register("go_start", L.moduleName, (s,
|
|
3969
|
-
if (this.doc().scrollLeft === 0) return
|
|
3970
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
3971
|
-
}), e.register("go_end", L.moduleName, (s,
|
|
3972
|
-
if (Math.abs(this.doc().scrollLeft) === this.scrollable()) return
|
|
3973
|
-
this.doc().scrollLeft = this.verticalLR ? this.scrollable() : -this.scrollable(), this.reportProgress(),
|
|
3972
|
+
}), e.register("go_start", L.moduleName, (s, r) => {
|
|
3973
|
+
if (this.doc().scrollLeft === 0) return r(!1);
|
|
3974
|
+
this.doc().scrollLeft = 0, this.reportProgress(), r(!0);
|
|
3975
|
+
}), e.register("go_end", L.moduleName, (s, r) => {
|
|
3976
|
+
if (Math.abs(this.doc().scrollLeft) === this.scrollable()) return r(!1);
|
|
3977
|
+
this.doc().scrollLeft = this.verticalLR ? this.scrollable() : -this.scrollable(), this.reportProgress(), r(!0);
|
|
3974
3978
|
}), e.register([
|
|
3975
3979
|
"go_next",
|
|
3976
3980
|
"go_prev"
|
|
3977
|
-
], L.moduleName, (s,
|
|
3978
|
-
A(this.wnd),
|
|
3979
|
-
}), e.register("scroll_protection", L.moduleName, (s,
|
|
3980
|
-
this.enableScrollProtection(),
|
|
3981
|
-
}), e.register("focus", L.moduleName, (s,
|
|
3982
|
-
this.reportProgress(),
|
|
3983
|
-
}), e.register("first_visible_locator", L.moduleName, (s,
|
|
3981
|
+
], L.moduleName, (s, r) => r(!1)), e.register("unfocus", L.moduleName, (s, r) => {
|
|
3982
|
+
A(this.wnd), r(!0);
|
|
3983
|
+
}), e.register("scroll_protection", L.moduleName, (s, r) => {
|
|
3984
|
+
this.enableScrollProtection(), r(!0);
|
|
3985
|
+
}), e.register("focus", L.moduleName, (s, r) => {
|
|
3986
|
+
this.reportProgress(), r(!0);
|
|
3987
|
+
}), e.register("first_visible_locator", L.moduleName, (s, r) => {
|
|
3984
3988
|
const o = yt(t, !0);
|
|
3985
|
-
this.comms.send("first_visible_locator", o.serialize()),
|
|
3989
|
+
this.comms.send("first_visible_locator", o.serialize()), r(!0);
|
|
3986
3990
|
}), e.log("CJKVerticalSnapper Mounted"), !0;
|
|
3987
3991
|
}
|
|
3988
3992
|
unmount(t, e) {
|
|
@@ -4022,7 +4026,7 @@ const Ti = [
|
|
|
4022
4026
|
Nt,
|
|
4023
4027
|
Mt,
|
|
4024
4028
|
zt
|
|
4025
|
-
].map((
|
|
4029
|
+
].map((n) => [n.moduleName, n]));
|
|
4026
4030
|
class Li {
|
|
4027
4031
|
/**
|
|
4028
4032
|
* @param wnd Window instance to operate on
|
|
@@ -4035,9 +4039,9 @@ class Li {
|
|
|
4035
4039
|
if (typeof t > "u")
|
|
4036
4040
|
throw Error("Loader is not in a web browser");
|
|
4037
4041
|
t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
|
|
4038
|
-
const
|
|
4039
|
-
if (
|
|
4040
|
-
return
|
|
4042
|
+
const r = this.loadModule(s);
|
|
4043
|
+
if (r)
|
|
4044
|
+
return r.mount(this.wnd, this.comms), r;
|
|
4041
4045
|
}).filter((s) => s !== void 0);
|
|
4042
4046
|
}
|
|
4043
4047
|
}
|