@readium/navigator-html-injectables 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +754 -622
- package/dist/index.umd.cjs +7 -7
- package/package.json +1 -1
- package/src/helpers/dom.ts +1 -1
- package/src/modules/ModuleLibrary.ts +15 -1
- package/src/modules/setup/FixedSetup.ts +1 -1
- package/src/modules/setup/WebPubSetup.ts +44 -0
- package/src/modules/snapper/ColumnSnapper.ts +1 -1
- package/src/modules/snapper/ScrollSnapper.ts +1 -1
- package/src/modules/snapper/WebPubSnapper.ts +226 -0
- package/types/src/helpers/dom.d.ts +1 -1
- package/types/src/modules/ModuleLibrary.d.ts +2 -1
- package/types/src/modules/setup/WebPubSetup.d.ts +10 -0
- package/types/src/modules/snapper/WebPubSnapper.d.ts +20 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const Qe = Math.pow(2, 32), Ee = () => Math.round(Math.random() * Qe).toString(36), et = () => `${Math.round(performance.now())}-${Ee()}-${Ee()}`, U = 1;
|
|
2
|
+
class tt {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
@@ -10,8 +10,8 @@ class Ke {
|
|
|
10
10
|
if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
|
|
11
11
|
if (t.key === "_ping") {
|
|
12
12
|
if (!this.destination) {
|
|
13
|
-
if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !==
|
|
14
|
-
t._readium >
|
|
13
|
+
if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== U) {
|
|
14
|
+
t._readium > U ? this.send("error", `received comms version ${t._readium} higher than ${U}`) : this.send("error", `received comms version ${t._readium} lower than ${U}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
@@ -30,21 +30,21 @@ class Ke {
|
|
|
30
30
|
e.strict && this.send("_unhandled", e);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
t.forEach((i) => i.cb(e.data, (
|
|
34
|
-
this.send("_ack",
|
|
33
|
+
t.forEach((i) => i.cb(e.data, (s) => {
|
|
34
|
+
this.send("_ack", s, e.id);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
register(e, t, i) {
|
|
38
|
-
Array.isArray(e) || (e = [e]), e.forEach((
|
|
39
|
-
const n = this.registrar.get(
|
|
38
|
+
Array.isArray(e) || (e = [e]), e.forEach((s) => {
|
|
39
|
+
const n = this.registrar.get(s);
|
|
40
40
|
if (n && n.length >= 0) {
|
|
41
|
-
if (n.find((l) => l.module === t)) throw new Error(`Trying to register another callback for combination of event ${
|
|
41
|
+
if (n.find((l) => l.module === t)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);
|
|
42
42
|
n.push({
|
|
43
43
|
cb: i,
|
|
44
44
|
module: t
|
|
45
|
-
}), this.registrar.set(
|
|
45
|
+
}), this.registrar.set(s, n);
|
|
46
46
|
} else
|
|
47
|
-
this.registrar.set(
|
|
47
|
+
this.registrar.set(s, [{
|
|
48
48
|
cb: i,
|
|
49
49
|
module: t
|
|
50
50
|
}]);
|
|
@@ -52,12 +52,12 @@ class Ke {
|
|
|
52
52
|
}
|
|
53
53
|
unregister(e, t) {
|
|
54
54
|
Array.isArray(e) || (e = [e]), e.forEach((i) => {
|
|
55
|
-
const
|
|
56
|
-
!
|
|
55
|
+
const s = this.registrar.get(i);
|
|
56
|
+
!s || s.length === 0 || s.splice(s.findIndex((n) => n.module === t), 1);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
unregisterAll(e) {
|
|
60
|
-
this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((
|
|
60
|
+
this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((s) => s.module !== e)));
|
|
61
61
|
}
|
|
62
62
|
log(...e) {
|
|
63
63
|
this.destination ? this.send("log", e) : this.preLog.push(e);
|
|
@@ -68,12 +68,12 @@ class Ke {
|
|
|
68
68
|
destroy() {
|
|
69
69
|
this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
|
|
70
70
|
}
|
|
71
|
-
send(e, t, i = void 0,
|
|
71
|
+
send(e, t, i = void 0, s = []) {
|
|
72
72
|
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
73
|
const n = {
|
|
74
|
-
_readium:
|
|
74
|
+
_readium: U,
|
|
75
75
|
_channel: this.channelId,
|
|
76
|
-
id: i ??
|
|
76
|
+
id: i ?? et(),
|
|
77
77
|
// scrict,
|
|
78
78
|
key: e,
|
|
79
79
|
data: t
|
|
@@ -81,23 +81,23 @@ class Ke {
|
|
|
81
81
|
try {
|
|
82
82
|
this.destination.postMessage(n, {
|
|
83
83
|
targetOrigin: this.origin,
|
|
84
|
-
transfer:
|
|
84
|
+
transfer: s
|
|
85
85
|
});
|
|
86
86
|
} catch (o) {
|
|
87
|
-
if (
|
|
88
|
-
this.destination.postMessage(n, this.origin,
|
|
87
|
+
if (s.length > 0) throw o;
|
|
88
|
+
this.destination.postMessage(n, this.origin, s);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const N = class W {
|
|
93
93
|
constructor(e) {
|
|
94
94
|
if (typeof e == "string") {
|
|
95
|
-
if (!
|
|
95
|
+
if (!W.VALID_MODES.has(e.toLowerCase()))
|
|
96
96
|
return;
|
|
97
97
|
this.value = e.toLowerCase();
|
|
98
98
|
} else {
|
|
99
99
|
const t = e.filter(
|
|
100
|
-
(i) =>
|
|
100
|
+
(i) => W.VALID_MODES.has(i.toLowerCase())
|
|
101
101
|
);
|
|
102
102
|
if (t.length === 0)
|
|
103
103
|
return;
|
|
@@ -110,11 +110,11 @@ const M = class z {
|
|
|
110
110
|
static deserialize(e) {
|
|
111
111
|
if (!e) return;
|
|
112
112
|
if (typeof e == "string")
|
|
113
|
-
return new
|
|
113
|
+
return new W(e);
|
|
114
114
|
if (!Array.isArray(e)) return;
|
|
115
|
-
const t = e.filter((i) => i ?
|
|
115
|
+
const t = e.filter((i) => i ? W.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
116
116
|
if (t.length !== 0)
|
|
117
|
-
return new
|
|
117
|
+
return new W(t);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
@@ -123,8 +123,8 @@ const M = class z {
|
|
|
123
123
|
return this.value;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
|
|
127
|
-
class
|
|
126
|
+
N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
|
|
127
|
+
class ue {
|
|
128
128
|
/**
|
|
129
129
|
* Creates a [Encryption].
|
|
130
130
|
*/
|
|
@@ -136,7 +136,7 @@ class oe {
|
|
|
136
136
|
*/
|
|
137
137
|
static deserialize(e) {
|
|
138
138
|
if (e && e.algorithm)
|
|
139
|
-
return new
|
|
139
|
+
return new ue({
|
|
140
140
|
algorithm: e.algorithm,
|
|
141
141
|
compression: e.compression,
|
|
142
142
|
originalLength: e.originalLength,
|
|
@@ -152,7 +152,7 @@ class oe {
|
|
|
152
152
|
return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
class
|
|
155
|
+
class C {
|
|
156
156
|
constructor(e) {
|
|
157
157
|
this.otherProperties = e;
|
|
158
158
|
}
|
|
@@ -164,7 +164,7 @@ class S {
|
|
|
164
164
|
*/
|
|
165
165
|
static deserialize(e) {
|
|
166
166
|
if (e)
|
|
167
|
-
return new
|
|
167
|
+
return new C(e);
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -179,46 +179,46 @@ class S {
|
|
|
179
179
|
const t = Object.assign({}, this.otherProperties);
|
|
180
180
|
for (const i in e)
|
|
181
181
|
t[i] = e[i];
|
|
182
|
-
return new
|
|
182
|
+
return new C(t);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
Object.defineProperty(
|
|
185
|
+
Object.defineProperty(C.prototype, "encryption", {
|
|
186
186
|
get: function() {
|
|
187
|
-
return
|
|
187
|
+
return ue.deserialize(this.otherProperties.encrypted);
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
|
-
function
|
|
191
|
-
return
|
|
190
|
+
function it(r) {
|
|
191
|
+
return r && Array.isArray(r) ? r : void 0;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
193
|
+
function He(r) {
|
|
194
|
+
return r && typeof r == "string" ? [r] : it(r);
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
return typeof
|
|
196
|
+
function xe(r) {
|
|
197
|
+
return typeof r == "string" ? new Date(r) : void 0;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return isNaN(
|
|
199
|
+
function X(r) {
|
|
200
|
+
return isNaN(r) ? void 0 : r;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
return
|
|
202
|
+
function S(r) {
|
|
203
|
+
return X(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function st(r) {
|
|
206
206
|
const e = new Array();
|
|
207
|
-
return
|
|
207
|
+
return r.forEach((t) => e.push(t)), e;
|
|
208
208
|
}
|
|
209
209
|
class a {
|
|
210
210
|
/** Creates a MediaType object. */
|
|
211
211
|
constructor(e) {
|
|
212
|
-
let t, i,
|
|
213
|
-
const n =
|
|
212
|
+
let t, i, s = e.mediaType.replace(/\s/g, "").split(";");
|
|
213
|
+
const n = s[0].split("/");
|
|
214
214
|
if (n.length === 2) {
|
|
215
215
|
if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
|
|
216
216
|
throw new Error("Invalid media type");
|
|
217
217
|
} else
|
|
218
218
|
throw new Error("Invalid media type");
|
|
219
219
|
const o = {};
|
|
220
|
-
for (let p = 1; p <
|
|
221
|
-
const y =
|
|
220
|
+
for (let p = 1; p < s.length; p++) {
|
|
221
|
+
const y = s[p].split("=");
|
|
222
222
|
if (y.length === 2) {
|
|
223
223
|
const d = y[0].toLocaleLowerCase(), f = d === "charset" ? y[1].toUpperCase() : y[1];
|
|
224
224
|
o[d] = f;
|
|
@@ -270,11 +270,11 @@ class a {
|
|
|
270
270
|
return !1;
|
|
271
271
|
const i = new Set(
|
|
272
272
|
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
273
|
-
),
|
|
273
|
+
), s = new Set(
|
|
274
274
|
Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
|
|
275
275
|
);
|
|
276
276
|
for (const n of Array.from(i.values()))
|
|
277
|
-
if (!
|
|
277
|
+
if (!s.has(n))
|
|
278
278
|
return !1;
|
|
279
279
|
return !0;
|
|
280
280
|
}
|
|
@@ -661,7 +661,7 @@ class a {
|
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
|
-
class
|
|
664
|
+
class Te {
|
|
665
665
|
constructor(e) {
|
|
666
666
|
this.uri = e, this.parameters = this.getParameters(e);
|
|
667
667
|
}
|
|
@@ -671,7 +671,7 @@ class ye {
|
|
|
671
671
|
getParameters(e) {
|
|
672
672
|
const t = /\{\??([^}]+)\}/g, i = e.match(t);
|
|
673
673
|
return i ? new Set(
|
|
674
|
-
i.join(",").replace(t, "$1").split(",").map((
|
|
674
|
+
i.join(",").replace(t, "$1").split(",").map((s) => s.trim())
|
|
675
675
|
) : /* @__PURE__ */ new Set();
|
|
676
676
|
}
|
|
677
677
|
/** Expands the URI by replacing the template variables by the given parameters.
|
|
@@ -679,17 +679,17 @@ class ye {
|
|
|
679
679
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
680
680
|
*/
|
|
681
681
|
expand(e) {
|
|
682
|
-
const t = (
|
|
682
|
+
const t = (s) => s.split(",").map((n) => {
|
|
683
683
|
const o = e[n];
|
|
684
684
|
return o ? encodeURIComponent(o) : "";
|
|
685
|
-
}).join(","), i = (
|
|
685
|
+
}).join(","), i = (s) => "?" + s.split(",").map((n) => {
|
|
686
686
|
const o = n.split("=")[0], l = e[o];
|
|
687
687
|
return l ? `${o}=${encodeURIComponent(l)}` : "";
|
|
688
688
|
}).join("&");
|
|
689
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...
|
|
689
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
class
|
|
692
|
+
class b {
|
|
693
693
|
/**
|
|
694
694
|
* Creates a [Locations].
|
|
695
695
|
*/
|
|
@@ -701,7 +701,7 @@ class v {
|
|
|
701
701
|
*/
|
|
702
702
|
static deserialize(e) {
|
|
703
703
|
if (!e) return;
|
|
704
|
-
const t =
|
|
704
|
+
const t = X(e.progression), i = X(e.totalProgression), s = X(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
705
705
|
"fragment",
|
|
706
706
|
"fragments",
|
|
707
707
|
"progression",
|
|
@@ -710,11 +710,11 @@ class v {
|
|
|
710
710
|
]);
|
|
711
711
|
return Object.entries(e).forEach(([l, u]) => {
|
|
712
712
|
o.has(l) || n.set(l, u);
|
|
713
|
-
}), new
|
|
714
|
-
fragments:
|
|
713
|
+
}), new b({
|
|
714
|
+
fragments: He(e.fragments || e.fragment),
|
|
715
715
|
progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
|
|
716
716
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
717
|
-
position:
|
|
717
|
+
position: s !== void 0 && s > 0 ? s : void 0,
|
|
718
718
|
otherLocations: n.size === 0 ? void 0 : n
|
|
719
719
|
});
|
|
720
720
|
}
|
|
@@ -726,7 +726,7 @@ class v {
|
|
|
726
726
|
return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
class
|
|
729
|
+
class z {
|
|
730
730
|
/**
|
|
731
731
|
* Creates a [Text].
|
|
732
732
|
*/
|
|
@@ -738,7 +738,7 @@ class W {
|
|
|
738
738
|
*/
|
|
739
739
|
static deserialize(e) {
|
|
740
740
|
if (e)
|
|
741
|
-
return new
|
|
741
|
+
return new z({
|
|
742
742
|
after: e.after,
|
|
743
743
|
before: e.before,
|
|
744
744
|
highlight: e.highlight
|
|
@@ -757,7 +757,7 @@ class L {
|
|
|
757
757
|
* Creates a [Locator].
|
|
758
758
|
*/
|
|
759
759
|
constructor(e) {
|
|
760
|
-
this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new
|
|
760
|
+
this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new b({}), this.text = e.text;
|
|
761
761
|
}
|
|
762
762
|
/**
|
|
763
763
|
* Parses a [Link] from its RWPM JSON representation.
|
|
@@ -768,8 +768,8 @@ class L {
|
|
|
768
768
|
href: e.href,
|
|
769
769
|
type: e.type,
|
|
770
770
|
title: e.title,
|
|
771
|
-
locations:
|
|
772
|
-
text:
|
|
771
|
+
locations: b.deserialize(e.locations),
|
|
772
|
+
text: z.deserialize(e.text)
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
/**
|
|
@@ -788,11 +788,11 @@ class L {
|
|
|
788
788
|
type: this.type,
|
|
789
789
|
title: this.title,
|
|
790
790
|
text: this.text,
|
|
791
|
-
locations: new
|
|
791
|
+
locations: new b({ ...this.locations, ...e })
|
|
792
792
|
});
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
|
-
class
|
|
795
|
+
class F {
|
|
796
796
|
/**
|
|
797
797
|
* Creates a [Link].
|
|
798
798
|
*/
|
|
@@ -804,21 +804,21 @@ class D {
|
|
|
804
804
|
*/
|
|
805
805
|
static deserialize(e) {
|
|
806
806
|
if (!(!e || typeof e.href != "string"))
|
|
807
|
-
return new
|
|
807
|
+
return new F({
|
|
808
808
|
href: e.href,
|
|
809
809
|
templated: e.templated,
|
|
810
810
|
type: e.type,
|
|
811
811
|
title: e.title,
|
|
812
812
|
rels: e.rel ? Array.isArray(e.rel) ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
|
|
813
|
-
properties:
|
|
814
|
-
height:
|
|
815
|
-
width:
|
|
816
|
-
size:
|
|
817
|
-
duration:
|
|
818
|
-
bitrate:
|
|
819
|
-
languages:
|
|
820
|
-
alternates:
|
|
821
|
-
children:
|
|
813
|
+
properties: C.deserialize(e.properties),
|
|
814
|
+
height: S(e.height),
|
|
815
|
+
width: S(e.width),
|
|
816
|
+
size: S(e.size),
|
|
817
|
+
duration: S(e.duration),
|
|
818
|
+
bitrate: S(e.bitrate),
|
|
819
|
+
languages: He(e.language),
|
|
820
|
+
alternates: _.deserialize(e.alternate),
|
|
821
|
+
children: _.deserialize(e.children)
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
824
|
/**
|
|
@@ -826,7 +826,7 @@ class D {
|
|
|
826
826
|
*/
|
|
827
827
|
serialize() {
|
|
828
828
|
const e = { href: this.href };
|
|
829
|
-
return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel =
|
|
829
|
+
return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = st(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.size !== void 0 && (e.size = this.size), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;
|
|
830
830
|
}
|
|
831
831
|
/** MediaType of the linked resource. */
|
|
832
832
|
get mediaType() {
|
|
@@ -843,14 +843,14 @@ class D {
|
|
|
843
843
|
}
|
|
844
844
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
845
845
|
get templateParameters() {
|
|
846
|
-
return this.templated ? new
|
|
846
|
+
return this.templated ? new Te(this.href).parameters : /* @__PURE__ */ new Set();
|
|
847
847
|
}
|
|
848
848
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
849
849
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
850
850
|
*/
|
|
851
851
|
expandTemplate(e) {
|
|
852
|
-
return new
|
|
853
|
-
href: new
|
|
852
|
+
return new F({
|
|
853
|
+
href: new Te(this.href).expand(e),
|
|
854
854
|
templated: !1
|
|
855
855
|
});
|
|
856
856
|
}
|
|
@@ -858,8 +858,8 @@ class D {
|
|
|
858
858
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
859
859
|
*/
|
|
860
860
|
addProperties(e) {
|
|
861
|
-
const t =
|
|
862
|
-
return t.properties = t.properties ? t.properties?.add(e) : new
|
|
861
|
+
const t = F.deserialize(this.serialize());
|
|
862
|
+
return t.properties = t.properties ? t.properties?.add(e) : new C(e), t;
|
|
863
863
|
}
|
|
864
864
|
/**
|
|
865
865
|
* Creates a [Locator] from a reading order [Link].
|
|
@@ -870,13 +870,13 @@ class D {
|
|
|
870
870
|
href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
|
|
871
871
|
type: this.type ?? "",
|
|
872
872
|
title: this.title,
|
|
873
|
-
locations: new
|
|
873
|
+
locations: new b({
|
|
874
874
|
fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
|
|
875
875
|
})
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class _ {
|
|
880
880
|
/**
|
|
881
881
|
* Creates a [Links].
|
|
882
882
|
*/
|
|
@@ -888,8 +888,8 @@ class j {
|
|
|
888
888
|
*/
|
|
889
889
|
static deserialize(e) {
|
|
890
890
|
if (e && Array.isArray(e))
|
|
891
|
-
return new
|
|
892
|
-
e.map((t) =>
|
|
891
|
+
return new _(
|
|
892
|
+
e.map((t) => F.deserialize(t)).filter((t) => t !== void 0)
|
|
893
893
|
);
|
|
894
894
|
}
|
|
895
895
|
/**
|
|
@@ -931,8 +931,8 @@ class j {
|
|
|
931
931
|
/** Finds all the links matching any of the given media types. */
|
|
932
932
|
filterByMediaTypes(e) {
|
|
933
933
|
const t = (i) => {
|
|
934
|
-
for (const
|
|
935
|
-
if (i.mediaType.matches(
|
|
934
|
+
for (const s of e)
|
|
935
|
+
if (i.mediaType.matches(s))
|
|
936
936
|
return !0;
|
|
937
937
|
return !1;
|
|
938
938
|
};
|
|
@@ -970,10 +970,10 @@ class j {
|
|
|
970
970
|
return this.items.filter((e) => e.type);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
|
|
973
|
+
C.prototype.getContains = function() {
|
|
974
974
|
return new Set(this.otherProperties.contains || []);
|
|
975
975
|
};
|
|
976
|
-
class
|
|
976
|
+
class G {
|
|
977
977
|
/**
|
|
978
978
|
* Creates a [DomRange].
|
|
979
979
|
*/
|
|
@@ -985,10 +985,10 @@ class q {
|
|
|
985
985
|
*/
|
|
986
986
|
static deserialize(e) {
|
|
987
987
|
if (!(e && e.cssSelector)) return;
|
|
988
|
-
let t =
|
|
988
|
+
let t = S(e.textNodeIndex);
|
|
989
989
|
if (t === void 0) return;
|
|
990
|
-
let i =
|
|
991
|
-
return i === void 0 && (i =
|
|
990
|
+
let i = S(e.charOffset);
|
|
991
|
+
return i === void 0 && (i = S(e.offset)), new G({
|
|
992
992
|
cssSelector: e.cssSelector,
|
|
993
993
|
textNodeIndex: t,
|
|
994
994
|
charOffset: i
|
|
@@ -1005,7 +1005,7 @@ class q {
|
|
|
1005
1005
|
return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
-
class
|
|
1008
|
+
class de {
|
|
1009
1009
|
/**
|
|
1010
1010
|
* Creates a [DomRange].
|
|
1011
1011
|
*/
|
|
@@ -1017,11 +1017,11 @@ class ae {
|
|
|
1017
1017
|
*/
|
|
1018
1018
|
static deserialize(e) {
|
|
1019
1019
|
if (!e) return;
|
|
1020
|
-
let t =
|
|
1020
|
+
let t = G.deserialize(e.start);
|
|
1021
1021
|
if (t)
|
|
1022
|
-
return new
|
|
1022
|
+
return new de({
|
|
1023
1023
|
start: t,
|
|
1024
|
-
end:
|
|
1024
|
+
end: G.deserialize(e.end)
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
1027
1027
|
/**
|
|
@@ -1032,48 +1032,48 @@ class ae {
|
|
|
1032
1032
|
return this.end && (e.end = this.end.serialize()), e;
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
|
-
|
|
1035
|
+
b.prototype.getCssSelector = function() {
|
|
1036
1036
|
return this.otherLocations?.get("cssSelector");
|
|
1037
1037
|
};
|
|
1038
|
-
|
|
1038
|
+
b.prototype.getPartialCfi = function() {
|
|
1039
1039
|
return this.otherLocations?.get("partialCfi");
|
|
1040
1040
|
};
|
|
1041
|
-
|
|
1042
|
-
return
|
|
1041
|
+
b.prototype.getDomRange = function() {
|
|
1042
|
+
return de.deserialize(this.otherLocations?.get("domRange"));
|
|
1043
1043
|
};
|
|
1044
|
-
|
|
1044
|
+
b.prototype.fragmentParameters = function() {
|
|
1045
1045
|
return new Map(
|
|
1046
|
-
this.fragments.map((
|
|
1047
|
-
|
|
1048
|
-
|
|
1046
|
+
this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
|
|
1047
|
+
r[0].trim().toLowerCase(),
|
|
1048
|
+
r[1].trim()
|
|
1049
1049
|
])
|
|
1050
1050
|
);
|
|
1051
1051
|
};
|
|
1052
|
-
|
|
1052
|
+
b.prototype.htmlId = function() {
|
|
1053
1053
|
if (!this.fragments.length) return;
|
|
1054
|
-
let
|
|
1055
|
-
if (!
|
|
1054
|
+
let r = this.fragments.find((e) => e.length && !e.includes("="));
|
|
1055
|
+
if (!r) {
|
|
1056
1056
|
const e = this.fragmentParameters();
|
|
1057
|
-
e.has("id") ?
|
|
1057
|
+
e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));
|
|
1058
1058
|
}
|
|
1059
|
-
return
|
|
1059
|
+
return r?.startsWith("#") ? r.slice(1) : r;
|
|
1060
1060
|
};
|
|
1061
|
-
|
|
1062
|
-
const
|
|
1063
|
-
if (!isNaN(
|
|
1061
|
+
b.prototype.page = function() {
|
|
1062
|
+
const r = parseInt(this.fragmentParameters().get("page"));
|
|
1063
|
+
if (!isNaN(r) && r >= 0) return r;
|
|
1064
1064
|
};
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
if (!isNaN(
|
|
1065
|
+
b.prototype.time = function() {
|
|
1066
|
+
const r = parseInt(this.fragmentParameters().get("t"));
|
|
1067
|
+
if (!isNaN(r)) return r;
|
|
1068
1068
|
};
|
|
1069
|
-
|
|
1070
|
-
const
|
|
1071
|
-
if (!
|
|
1072
|
-
const e =
|
|
1069
|
+
b.prototype.space = function() {
|
|
1070
|
+
const r = this.fragmentParameters();
|
|
1071
|
+
if (!r.has("xywh")) return;
|
|
1072
|
+
const e = r.get("xywh").split(",").map((t) => parseInt(t));
|
|
1073
1073
|
if (e.length === 4 && !e.some(isNaN))
|
|
1074
1074
|
return e;
|
|
1075
1075
|
};
|
|
1076
|
-
class
|
|
1076
|
+
class pe {
|
|
1077
1077
|
/** Creates a [Price]. */
|
|
1078
1078
|
constructor(e) {
|
|
1079
1079
|
this.currency = e.currency, this.value = e.value;
|
|
@@ -1086,9 +1086,9 @@ class le {
|
|
|
1086
1086
|
let t = e.currency;
|
|
1087
1087
|
if (!(t && typeof t == "string" && t.length > 0))
|
|
1088
1088
|
return;
|
|
1089
|
-
let i =
|
|
1089
|
+
let i = S(e.value);
|
|
1090
1090
|
if (i !== void 0)
|
|
1091
|
-
return new
|
|
1091
|
+
return new pe({ currency: t, value: i });
|
|
1092
1092
|
}
|
|
1093
1093
|
/**
|
|
1094
1094
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1097,7 +1097,7 @@ class le {
|
|
|
1097
1097
|
return { currency: this.currency, value: this.value };
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
|
-
class
|
|
1100
|
+
class B {
|
|
1101
1101
|
/** Creates a [Acquisition]. */
|
|
1102
1102
|
constructor(e) {
|
|
1103
1103
|
this.type = e.type, this.children = e.children;
|
|
@@ -1107,14 +1107,14 @@ class U {
|
|
|
1107
1107
|
*/
|
|
1108
1108
|
static deserialize(e) {
|
|
1109
1109
|
if (e && e.type)
|
|
1110
|
-
return new
|
|
1110
|
+
return new B({
|
|
1111
1111
|
type: e.type,
|
|
1112
|
-
children:
|
|
1112
|
+
children: B.deserializeArray(e.children)
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
static deserializeArray(e) {
|
|
1116
1116
|
if (Array.isArray(e))
|
|
1117
|
-
return e.map((t) =>
|
|
1117
|
+
return e.map((t) => B.deserialize(t)).filter((t) => t !== void 0);
|
|
1118
1118
|
}
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1124,7 +1124,7 @@ class U {
|
|
|
1124
1124
|
return this.children && (e.children = this.children.map((t) => t.serialize())), e;
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
|
-
class
|
|
1127
|
+
class fe {
|
|
1128
1128
|
/** Creates a [Price]. */
|
|
1129
1129
|
constructor(e) {
|
|
1130
1130
|
this.total = e.total, this.position = e.position;
|
|
@@ -1134,9 +1134,9 @@ class he {
|
|
|
1134
1134
|
*/
|
|
1135
1135
|
static deserialize(e) {
|
|
1136
1136
|
if (e)
|
|
1137
|
-
return new
|
|
1138
|
-
total:
|
|
1139
|
-
position:
|
|
1137
|
+
return new fe({
|
|
1138
|
+
total: S(e.total),
|
|
1139
|
+
position: S(e.position)
|
|
1140
1140
|
});
|
|
1141
1141
|
}
|
|
1142
1142
|
/**
|
|
@@ -1147,7 +1147,7 @@ class he {
|
|
|
1147
1147
|
return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
|
-
class
|
|
1150
|
+
class me {
|
|
1151
1151
|
/** Creates a [Copies]. */
|
|
1152
1152
|
constructor(e) {
|
|
1153
1153
|
this.total = e.total, this.available = e.available;
|
|
@@ -1157,9 +1157,9 @@ class ce {
|
|
|
1157
1157
|
*/
|
|
1158
1158
|
static deserialize(e) {
|
|
1159
1159
|
if (e)
|
|
1160
|
-
return new
|
|
1161
|
-
total:
|
|
1162
|
-
available:
|
|
1160
|
+
return new me({
|
|
1161
|
+
total: S(e.total),
|
|
1162
|
+
available: S(e.available)
|
|
1163
1163
|
});
|
|
1164
1164
|
}
|
|
1165
1165
|
/**
|
|
@@ -1170,7 +1170,7 @@ class ce {
|
|
|
1170
1170
|
return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
class
|
|
1173
|
+
class ge {
|
|
1174
1174
|
/** Creates a [Availability]. */
|
|
1175
1175
|
constructor(e) {
|
|
1176
1176
|
this.state = e.state, this.since = e.since, this.until = e.until;
|
|
@@ -1180,10 +1180,10 @@ class ue {
|
|
|
1180
1180
|
*/
|
|
1181
1181
|
static deserialize(e) {
|
|
1182
1182
|
if (e && e.state)
|
|
1183
|
-
return new
|
|
1183
|
+
return new ge({
|
|
1184
1184
|
state: e.state,
|
|
1185
|
-
since:
|
|
1186
|
-
until:
|
|
1185
|
+
since: xe(e.since),
|
|
1186
|
+
until: xe(e.until)
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
1189
|
/**
|
|
@@ -1194,98 +1194,98 @@ class ue {
|
|
|
1194
1194
|
return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
|
|
1195
1195
|
}
|
|
1196
1196
|
}
|
|
1197
|
-
|
|
1198
|
-
return
|
|
1197
|
+
C.prototype.getNumberOfItems = function() {
|
|
1198
|
+
return S(this.otherProperties.numberOfItems);
|
|
1199
1199
|
};
|
|
1200
|
-
|
|
1201
|
-
return
|
|
1200
|
+
C.prototype.getPrice = function() {
|
|
1201
|
+
return pe.deserialize(this.otherProperties.price);
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1206
|
-
return
|
|
1203
|
+
C.prototype.getIndirectAcquisitions = function() {
|
|
1204
|
+
const r = this.otherProperties.indirectAcquisition;
|
|
1205
|
+
if (r && Array.isArray(r))
|
|
1206
|
+
return r.map((e) => B.deserialize(e)).filter((e) => e !== void 0);
|
|
1207
1207
|
};
|
|
1208
|
-
|
|
1209
|
-
return
|
|
1208
|
+
C.prototype.getHolds = function() {
|
|
1209
|
+
return fe.deserialize(this.otherProperties.holds);
|
|
1210
1210
|
};
|
|
1211
|
-
|
|
1212
|
-
return
|
|
1211
|
+
C.prototype.getCopies = function() {
|
|
1212
|
+
return me.deserialize(this.otherProperties.copies);
|
|
1213
1213
|
};
|
|
1214
|
-
|
|
1215
|
-
return
|
|
1214
|
+
C.prototype.getAvailability = function() {
|
|
1215
|
+
return ge.deserialize(this.otherProperties.availability);
|
|
1216
1216
|
};
|
|
1217
|
-
|
|
1218
|
-
return
|
|
1217
|
+
C.prototype.getAuthenticate = function() {
|
|
1218
|
+
return F.deserialize(this.otherProperties.authenticate);
|
|
1219
1219
|
};
|
|
1220
|
-
const
|
|
1221
|
-
function
|
|
1222
|
-
console.warn(`${
|
|
1220
|
+
const rt = "CssSelectorGenerator";
|
|
1221
|
+
function we(r = "unknown problem", ...e) {
|
|
1222
|
+
console.warn(`${rt}: ${r}`, ...e);
|
|
1223
1223
|
}
|
|
1224
|
-
function
|
|
1225
|
-
return
|
|
1224
|
+
function nt(r) {
|
|
1225
|
+
return r instanceof RegExp;
|
|
1226
1226
|
}
|
|
1227
|
-
function
|
|
1228
|
-
return
|
|
1227
|
+
function ot(r) {
|
|
1228
|
+
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1231
|
-
const e =
|
|
1232
|
-
if (
|
|
1230
|
+
function at(r) {
|
|
1231
|
+
const e = r.map((t) => {
|
|
1232
|
+
if (nt(t))
|
|
1233
1233
|
return (i) => t.test(i);
|
|
1234
1234
|
if (typeof t == "function")
|
|
1235
1235
|
return (i) => {
|
|
1236
|
-
const
|
|
1237
|
-
return typeof
|
|
1236
|
+
const s = t(i);
|
|
1237
|
+
return typeof s != "boolean" ? (we("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
|
|
1238
1238
|
};
|
|
1239
1239
|
if (typeof t == "string") {
|
|
1240
|
-
const i = new RegExp("^" +
|
|
1241
|
-
return (
|
|
1240
|
+
const i = new RegExp("^" + ot(t) + "$");
|
|
1241
|
+
return (s) => i.test(s);
|
|
1242
1242
|
}
|
|
1243
|
-
return
|
|
1243
|
+
return we("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
|
|
1244
1244
|
});
|
|
1245
1245
|
return (t) => e.some((i) => i(t));
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
at([
|
|
1248
1248
|
"class",
|
|
1249
1249
|
"id",
|
|
1250
1250
|
// Angular attributes
|
|
1251
1251
|
"ng-*"
|
|
1252
1252
|
]);
|
|
1253
|
-
class
|
|
1253
|
+
class j {
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1256
|
-
return
|
|
1255
|
+
function Se(r) {
|
|
1256
|
+
return r.split("").reverse().join("");
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1259
|
-
const i =
|
|
1260
|
-
return t.map((
|
|
1261
|
-
const n = Math.max(0,
|
|
1258
|
+
function lt(r, e, t) {
|
|
1259
|
+
const i = Se(e);
|
|
1260
|
+
return t.map((s) => {
|
|
1261
|
+
const n = Math.max(0, s.end - e.length - s.errors), o = Se(r.slice(n, s.end));
|
|
1262
1262
|
return {
|
|
1263
|
-
start:
|
|
1264
|
-
end:
|
|
1265
|
-
errors:
|
|
1263
|
+
start: $e(o, i, s.errors).reduce((u, h) => s.end - h.end < u ? s.end - h.end : u, s.end),
|
|
1264
|
+
end: s.end,
|
|
1265
|
+
errors: s.errors
|
|
1266
1266
|
};
|
|
1267
1267
|
});
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1270
|
-
return (
|
|
1269
|
+
function te(r) {
|
|
1270
|
+
return (r | -r) >> 31 & 1;
|
|
1271
1271
|
}
|
|
1272
|
-
function
|
|
1273
|
-
let
|
|
1274
|
-
const o = i >>> 31, l = e[t] | o, u = l | n, h = (l &
|
|
1275
|
-
let c = n | ~(h |
|
|
1276
|
-
const p =
|
|
1277
|
-
return c <<= 1, m <<= 1, m |= o, c |=
|
|
1272
|
+
function Ce(r, e, t, i) {
|
|
1273
|
+
let s = r.P[t], n = r.M[t];
|
|
1274
|
+
const o = i >>> 31, l = e[t] | o, u = l | n, h = (l & s) + s ^ s | l;
|
|
1275
|
+
let c = n | ~(h | s), m = s & h;
|
|
1276
|
+
const p = te(c & r.lastRowMask[t]) - te(m & r.lastRowMask[t]);
|
|
1277
|
+
return c <<= 1, m <<= 1, m |= o, c |= te(i) - o, s = m | ~(u | c), n = c & u, r.P[t] = s, r.M[t] = n, p;
|
|
1278
1278
|
}
|
|
1279
|
-
function
|
|
1279
|
+
function $e(r, e, t) {
|
|
1280
1280
|
if (e.length === 0)
|
|
1281
1281
|
return [];
|
|
1282
1282
|
t = Math.min(t, e.length);
|
|
1283
|
-
const i = [],
|
|
1283
|
+
const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {
|
|
1284
1284
|
P: new Uint32Array(n + 1),
|
|
1285
1285
|
M: new Uint32Array(n + 1),
|
|
1286
1286
|
lastRowMask: new Uint32Array(n + 1)
|
|
1287
1287
|
};
|
|
1288
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) %
|
|
1288
|
+
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
|
|
1289
1289
|
const l = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];
|
|
1290
1290
|
for (let p = 0; p < 256; p++)
|
|
1291
1291
|
h.push(l);
|
|
@@ -1297,39 +1297,39 @@ function We(s, e, t) {
|
|
|
1297
1297
|
u.set(y, d), y < h.length && (h[y] = d);
|
|
1298
1298
|
for (let f = 0; f <= n; f += 1) {
|
|
1299
1299
|
d[f] = 0;
|
|
1300
|
-
for (let g = 0; g <
|
|
1301
|
-
const E = f *
|
|
1300
|
+
for (let g = 0; g < s; g += 1) {
|
|
1301
|
+
const E = f * s + g;
|
|
1302
1302
|
if (E >= e.length)
|
|
1303
1303
|
continue;
|
|
1304
1304
|
e.charCodeAt(E) === y && (d[f] |= 1 << g);
|
|
1305
1305
|
}
|
|
1306
1306
|
}
|
|
1307
1307
|
}
|
|
1308
|
-
let c = Math.max(0, Math.ceil(t /
|
|
1308
|
+
let c = Math.max(0, Math.ceil(t / s) - 1);
|
|
1309
1309
|
const m = new Uint32Array(n + 1);
|
|
1310
1310
|
for (let p = 0; p <= c; p += 1)
|
|
1311
|
-
m[p] = (p + 1) *
|
|
1311
|
+
m[p] = (p + 1) * s;
|
|
1312
1312
|
m[n] = e.length;
|
|
1313
1313
|
for (let p = 0; p <= c; p += 1)
|
|
1314
1314
|
o.P[p] = -1, o.M[p] = 0;
|
|
1315
|
-
for (let p = 0; p <
|
|
1316
|
-
const y =
|
|
1315
|
+
for (let p = 0; p < r.length; p += 1) {
|
|
1316
|
+
const y = r.charCodeAt(p);
|
|
1317
1317
|
let d;
|
|
1318
1318
|
y < h.length ? d = h[y] : (d = u.get(y), typeof d > "u" && (d = l));
|
|
1319
1319
|
let f = 0;
|
|
1320
1320
|
for (let g = 0; g <= c; g += 1)
|
|
1321
|
-
f =
|
|
1321
|
+
f = Ce(o, d, g, f), m[g] += f;
|
|
1322
1322
|
if (m[c] - f <= t && c < n && (d[c + 1] & 1 || f < 0)) {
|
|
1323
1323
|
c += 1, o.P[c] = -1, o.M[c] = 0;
|
|
1324
1324
|
let g;
|
|
1325
1325
|
if (c === n) {
|
|
1326
|
-
const E = e.length %
|
|
1327
|
-
g = E === 0 ?
|
|
1326
|
+
const E = e.length % s;
|
|
1327
|
+
g = E === 0 ? s : E;
|
|
1328
1328
|
} else
|
|
1329
|
-
g =
|
|
1330
|
-
m[c] = m[c - 1] + g - f +
|
|
1329
|
+
g = s;
|
|
1330
|
+
m[c] = m[c - 1] + g - f + Ce(o, d, c, f);
|
|
1331
1331
|
} else
|
|
1332
|
-
for (; c > 0 && m[c] >= t +
|
|
1332
|
+
for (; c > 0 && m[c] >= t + s; )
|
|
1333
1333
|
c -= 1;
|
|
1334
1334
|
c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({
|
|
1335
1335
|
start: -1,
|
|
@@ -1339,65 +1339,65 @@ function We(s, e, t) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
return i;
|
|
1341
1341
|
}
|
|
1342
|
-
function
|
|
1343
|
-
const i =
|
|
1344
|
-
return
|
|
1342
|
+
function ht(r, e, t) {
|
|
1343
|
+
const i = $e(r, e, t);
|
|
1344
|
+
return lt(r, e, i);
|
|
1345
1345
|
}
|
|
1346
|
-
function
|
|
1346
|
+
function ke(r, e, t) {
|
|
1347
1347
|
let i = 0;
|
|
1348
|
-
const
|
|
1348
|
+
const s = [];
|
|
1349
1349
|
for (; i !== -1; )
|
|
1350
|
-
i =
|
|
1350
|
+
i = r.indexOf(e, i), i !== -1 && (s.push({
|
|
1351
1351
|
start: i,
|
|
1352
1352
|
end: i + e.length,
|
|
1353
1353
|
errors: 0
|
|
1354
1354
|
}), i += 1);
|
|
1355
|
-
return
|
|
1355
|
+
return s.length > 0 ? s : ht(r, e, t);
|
|
1356
1356
|
}
|
|
1357
|
-
function
|
|
1358
|
-
return e.length === 0 ||
|
|
1357
|
+
function Pe(r, e) {
|
|
1358
|
+
return e.length === 0 || r.length === 0 ? 0 : 1 - ke(r, e, e.length)[0].errors / e.length;
|
|
1359
1359
|
}
|
|
1360
|
-
function
|
|
1360
|
+
function ct(r, e, t = {}) {
|
|
1361
1361
|
if (e.length === 0)
|
|
1362
1362
|
return null;
|
|
1363
|
-
const i = Math.min(256, e.length / 2),
|
|
1364
|
-
if (
|
|
1363
|
+
const i = Math.min(256, e.length / 2), s = ke(r, e, i);
|
|
1364
|
+
if (s.length === 0)
|
|
1365
1365
|
return null;
|
|
1366
1366
|
const n = (l) => {
|
|
1367
|
-
const p = 1 - l.errors / e.length, y = t.prefix ?
|
|
1368
|
-
|
|
1367
|
+
const p = 1 - l.errors / e.length, y = t.prefix ? Pe(
|
|
1368
|
+
r.slice(
|
|
1369
1369
|
Math.max(0, l.start - t.prefix.length),
|
|
1370
1370
|
l.start
|
|
1371
1371
|
),
|
|
1372
1372
|
t.prefix
|
|
1373
|
-
) : 1, d = t.suffix ?
|
|
1374
|
-
|
|
1373
|
+
) : 1, d = t.suffix ? Pe(
|
|
1374
|
+
r.slice(l.end, l.end + t.suffix.length),
|
|
1375
1375
|
t.suffix
|
|
1376
1376
|
) : 1;
|
|
1377
1377
|
let f = 1;
|
|
1378
|
-
return typeof t.hint == "number" && (f = 1 - Math.abs(l.start - t.hint) /
|
|
1379
|
-
}, o =
|
|
1378
|
+
return typeof t.hint == "number" && (f = 1 - Math.abs(l.start - t.hint) / r.length), (50 * p + 20 * y + 20 * d + 2 * f) / 92;
|
|
1379
|
+
}, o = s.map((l) => ({
|
|
1380
1380
|
start: l.start,
|
|
1381
1381
|
end: l.end,
|
|
1382
1382
|
score: n(l)
|
|
1383
1383
|
}));
|
|
1384
1384
|
return o.sort((l, u) => u.score - l.score), o[0];
|
|
1385
1385
|
}
|
|
1386
|
-
function
|
|
1386
|
+
function ie(r, e, t) {
|
|
1387
1387
|
const i = t === 1 ? e : e - 1;
|
|
1388
|
-
if (
|
|
1388
|
+
if (r.charAt(i).trim() !== "")
|
|
1389
1389
|
return e;
|
|
1390
|
-
let
|
|
1391
|
-
if (t === 2 ? (
|
|
1390
|
+
let s, n;
|
|
1391
|
+
if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)
|
|
1392
1392
|
return -1;
|
|
1393
|
-
const o =
|
|
1393
|
+
const o = s.length - n.length;
|
|
1394
1394
|
return t === 2 ? e - o : e + o;
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1397
|
-
const t =
|
|
1398
|
-
|
|
1396
|
+
function Ae(r, e) {
|
|
1397
|
+
const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1398
|
+
r.commonAncestorContainer,
|
|
1399
1399
|
NodeFilter.SHOW_TEXT
|
|
1400
|
-
), i = e === 1 ?
|
|
1400
|
+
), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;
|
|
1401
1401
|
let n = t.nextNode();
|
|
1402
1402
|
for (; n && n !== i; )
|
|
1403
1403
|
n = t.nextNode();
|
|
@@ -1406,42 +1406,42 @@ function Te(s, e) {
|
|
|
1406
1406
|
const l = () => {
|
|
1407
1407
|
if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
|
|
1408
1408
|
const u = n.textContent, h = e === 1 ? 0 : u.length;
|
|
1409
|
-
o =
|
|
1409
|
+
o = ie(u, h, e);
|
|
1410
1410
|
}
|
|
1411
1411
|
};
|
|
1412
|
-
for (; n && o === -1 && n !==
|
|
1412
|
+
for (; n && o === -1 && n !== s; )
|
|
1413
1413
|
l();
|
|
1414
1414
|
if (n && o >= 0)
|
|
1415
1415
|
return { node: n, offset: o };
|
|
1416
1416
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1417
1417
|
}
|
|
1418
|
-
function
|
|
1419
|
-
if (!
|
|
1418
|
+
function ut(r) {
|
|
1419
|
+
if (!r.toString().trim().length)
|
|
1420
1420
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1421
|
-
if (
|
|
1421
|
+
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1422
1422
|
throw new RangeError("Range startContainer is not a text node");
|
|
1423
|
-
if (
|
|
1423
|
+
if (r.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1424
1424
|
throw new RangeError("Range endContainer is not a text node");
|
|
1425
|
-
const e =
|
|
1425
|
+
const e = r.cloneRange();
|
|
1426
1426
|
let t = !1, i = !1;
|
|
1427
|
-
const
|
|
1428
|
-
start:
|
|
1429
|
-
|
|
1430
|
-
|
|
1427
|
+
const s = {
|
|
1428
|
+
start: ie(
|
|
1429
|
+
r.startContainer.textContent,
|
|
1430
|
+
r.startOffset,
|
|
1431
1431
|
1
|
|
1432
1432
|
/* Forwards */
|
|
1433
1433
|
),
|
|
1434
|
-
end:
|
|
1435
|
-
|
|
1436
|
-
|
|
1434
|
+
end: ie(
|
|
1435
|
+
r.endContainer.textContent,
|
|
1436
|
+
r.endOffset,
|
|
1437
1437
|
2
|
|
1438
1438
|
/* Backwards */
|
|
1439
1439
|
)
|
|
1440
1440
|
};
|
|
1441
|
-
if (
|
|
1441
|
+
if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)
|
|
1442
1442
|
return e;
|
|
1443
1443
|
if (!t) {
|
|
1444
|
-
const { node: n, offset: o } =
|
|
1444
|
+
const { node: n, offset: o } = Ae(
|
|
1445
1445
|
e,
|
|
1446
1446
|
1
|
|
1447
1447
|
/* Forwards */
|
|
@@ -1449,7 +1449,7 @@ function ot(s) {
|
|
|
1449
1449
|
n && o >= 0 && e.setStart(n, o);
|
|
1450
1450
|
}
|
|
1451
1451
|
if (!i) {
|
|
1452
|
-
const { node: n, offset: o } =
|
|
1452
|
+
const { node: n, offset: o } = Ae(
|
|
1453
1453
|
e,
|
|
1454
1454
|
2
|
|
1455
1455
|
/* Backwards */
|
|
@@ -1458,37 +1458,37 @@ function ot(s) {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
return e;
|
|
1460
1460
|
}
|
|
1461
|
-
function
|
|
1462
|
-
switch (
|
|
1461
|
+
function Ve(r) {
|
|
1462
|
+
switch (r.nodeType) {
|
|
1463
1463
|
case Node.ELEMENT_NODE:
|
|
1464
1464
|
case Node.TEXT_NODE:
|
|
1465
|
-
return
|
|
1465
|
+
return r.textContent?.length ?? 0;
|
|
1466
1466
|
default:
|
|
1467
1467
|
return 0;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
|
-
function
|
|
1471
|
-
let e =
|
|
1470
|
+
function Me(r) {
|
|
1471
|
+
let e = r.previousSibling, t = 0;
|
|
1472
1472
|
for (; e; )
|
|
1473
|
-
t +=
|
|
1473
|
+
t += Ve(e), e = e.previousSibling;
|
|
1474
1474
|
return t;
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function je(r, ...e) {
|
|
1477
1477
|
let t = e.shift();
|
|
1478
|
-
const i =
|
|
1479
|
-
|
|
1478
|
+
const i = r.ownerDocument.createNodeIterator(
|
|
1479
|
+
r,
|
|
1480
1480
|
NodeFilter.SHOW_TEXT
|
|
1481
|
-
),
|
|
1481
|
+
), s = [];
|
|
1482
1482
|
let n = i.nextNode(), o, l = 0;
|
|
1483
1483
|
for (; t !== void 0 && n; )
|
|
1484
|
-
o = n, l + o.data.length > t ? (
|
|
1484
|
+
o = n, l + o.data.length > t ? (s.push({ node: o, offset: t - l }), t = e.shift()) : (n = i.nextNode(), l += o.data.length);
|
|
1485
1485
|
for (; t !== void 0 && o && l === t; )
|
|
1486
|
-
|
|
1486
|
+
s.push({ node: o, offset: o.data.length }), t = e.shift();
|
|
1487
1487
|
if (t !== void 0)
|
|
1488
1488
|
throw new RangeError("Offset exceeds text length");
|
|
1489
|
-
return
|
|
1489
|
+
return s;
|
|
1490
1490
|
}
|
|
1491
|
-
class
|
|
1491
|
+
class M {
|
|
1492
1492
|
constructor(e, t) {
|
|
1493
1493
|
if (t < 0)
|
|
1494
1494
|
throw new Error("Offset is invalid");
|
|
@@ -1505,8 +1505,8 @@ class A {
|
|
|
1505
1505
|
throw new Error("Parent is not an ancestor of current element");
|
|
1506
1506
|
let t = this.element, i = this.offset;
|
|
1507
1507
|
for (; t !== e; )
|
|
1508
|
-
i +=
|
|
1509
|
-
return new
|
|
1508
|
+
i += Me(t), t = t.parentElement;
|
|
1509
|
+
return new M(t, i);
|
|
1510
1510
|
}
|
|
1511
1511
|
/**
|
|
1512
1512
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1527,7 +1527,7 @@ class A {
|
|
|
1527
1527
|
*/
|
|
1528
1528
|
resolve(e = {}) {
|
|
1529
1529
|
try {
|
|
1530
|
-
return
|
|
1530
|
+
return je(this.element, this.offset)[0];
|
|
1531
1531
|
} catch (t) {
|
|
1532
1532
|
if (this.offset === 0 && e.direction !== void 0) {
|
|
1533
1533
|
const i = document.createTreeWalker(
|
|
@@ -1535,10 +1535,10 @@ class A {
|
|
|
1535
1535
|
NodeFilter.SHOW_TEXT
|
|
1536
1536
|
);
|
|
1537
1537
|
i.currentNode = this.element;
|
|
1538
|
-
const
|
|
1538
|
+
const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();
|
|
1539
1539
|
if (!n)
|
|
1540
1540
|
throw t;
|
|
1541
|
-
return { node: n, offset:
|
|
1541
|
+
return { node: n, offset: s ? 0 : n.data.length };
|
|
1542
1542
|
} else
|
|
1543
1543
|
throw t;
|
|
1544
1544
|
}
|
|
@@ -1550,9 +1550,9 @@ class A {
|
|
|
1550
1550
|
static fromCharOffset(e, t) {
|
|
1551
1551
|
switch (e.nodeType) {
|
|
1552
1552
|
case Node.TEXT_NODE:
|
|
1553
|
-
return
|
|
1553
|
+
return M.fromPoint(e, t);
|
|
1554
1554
|
case Node.ELEMENT_NODE:
|
|
1555
|
-
return new
|
|
1555
|
+
return new M(e, t);
|
|
1556
1556
|
default:
|
|
1557
1557
|
throw new Error("Node is not an element or text node");
|
|
1558
1558
|
}
|
|
@@ -1570,23 +1570,23 @@ class A {
|
|
|
1570
1570
|
throw new Error("Text node offset is out of range");
|
|
1571
1571
|
if (!e.parentElement)
|
|
1572
1572
|
throw new Error("Text node has no parent");
|
|
1573
|
-
const i =
|
|
1574
|
-
return new
|
|
1573
|
+
const i = Me(e) + t;
|
|
1574
|
+
return new M(e.parentElement, i);
|
|
1575
1575
|
}
|
|
1576
1576
|
case Node.ELEMENT_NODE: {
|
|
1577
1577
|
if (t < 0 || t > e.childNodes.length)
|
|
1578
1578
|
throw new Error("Child node offset is out of range");
|
|
1579
1579
|
let i = 0;
|
|
1580
|
-
for (let
|
|
1581
|
-
i +=
|
|
1582
|
-
return new
|
|
1580
|
+
for (let s = 0; s < t; s++)
|
|
1581
|
+
i += Ve(e.childNodes[s]);
|
|
1582
|
+
return new M(e, i);
|
|
1583
1583
|
}
|
|
1584
1584
|
default:
|
|
1585
1585
|
throw new Error("Point is not in an element or text node");
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
1588
|
}
|
|
1589
|
-
class
|
|
1589
|
+
class I {
|
|
1590
1590
|
constructor(e, t) {
|
|
1591
1591
|
this.start = e, this.end = t;
|
|
1592
1592
|
}
|
|
@@ -1596,7 +1596,7 @@ class O {
|
|
|
1596
1596
|
* `end.element`.
|
|
1597
1597
|
*/
|
|
1598
1598
|
relativeTo(e) {
|
|
1599
|
-
return new
|
|
1599
|
+
return new I(
|
|
1600
1600
|
this.start.relativeTo(e),
|
|
1601
1601
|
this.end.relativeTo(e)
|
|
1602
1602
|
);
|
|
@@ -1612,7 +1612,7 @@ class O {
|
|
|
1612
1612
|
*/
|
|
1613
1613
|
toRange() {
|
|
1614
1614
|
let e, t;
|
|
1615
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] =
|
|
1615
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = je(
|
|
1616
1616
|
this.start.element,
|
|
1617
1617
|
this.start.offset,
|
|
1618
1618
|
this.end.offset
|
|
@@ -1630,20 +1630,20 @@ class O {
|
|
|
1630
1630
|
* Create a TextRange from a (DOM) Range
|
|
1631
1631
|
*/
|
|
1632
1632
|
static fromRange(e) {
|
|
1633
|
-
const t =
|
|
1633
|
+
const t = M.fromPoint(
|
|
1634
1634
|
e.startContainer,
|
|
1635
1635
|
e.startOffset
|
|
1636
|
-
), i =
|
|
1637
|
-
return new
|
|
1636
|
+
), i = M.fromPoint(e.endContainer, e.endOffset);
|
|
1637
|
+
return new I(t, i);
|
|
1638
1638
|
}
|
|
1639
1639
|
/**
|
|
1640
1640
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1641
1641
|
* `root`
|
|
1642
1642
|
*/
|
|
1643
1643
|
static fromOffsets(e, t, i) {
|
|
1644
|
-
return new
|
|
1645
|
-
new
|
|
1646
|
-
new
|
|
1644
|
+
return new I(
|
|
1645
|
+
new M(e, t),
|
|
1646
|
+
new M(e, i)
|
|
1647
1647
|
);
|
|
1648
1648
|
}
|
|
1649
1649
|
/**
|
|
@@ -1651,23 +1651,23 @@ class O {
|
|
|
1651
1651
|
* whitespace
|
|
1652
1652
|
*/
|
|
1653
1653
|
static trimmedRange(e) {
|
|
1654
|
-
return
|
|
1654
|
+
return ut(I.fromRange(e).toRange());
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
|
-
class
|
|
1657
|
+
class Y {
|
|
1658
1658
|
constructor(e, t, i) {
|
|
1659
1659
|
this.root = e, this.start = t, this.end = i;
|
|
1660
1660
|
}
|
|
1661
1661
|
static fromRange(e, t) {
|
|
1662
|
-
const i =
|
|
1663
|
-
return new
|
|
1662
|
+
const i = I.fromRange(t).relativeTo(e);
|
|
1663
|
+
return new Y(
|
|
1664
1664
|
e,
|
|
1665
1665
|
i.start.offset,
|
|
1666
1666
|
i.end.offset
|
|
1667
1667
|
);
|
|
1668
1668
|
}
|
|
1669
1669
|
static fromSelector(e, t) {
|
|
1670
|
-
return new
|
|
1670
|
+
return new Y(e, t.start, t.end);
|
|
1671
1671
|
}
|
|
1672
1672
|
toSelector() {
|
|
1673
1673
|
return {
|
|
@@ -1677,10 +1677,10 @@ class X {
|
|
|
1677
1677
|
};
|
|
1678
1678
|
}
|
|
1679
1679
|
toRange() {
|
|
1680
|
-
return
|
|
1680
|
+
return I.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1681
1681
|
}
|
|
1682
1682
|
}
|
|
1683
|
-
class
|
|
1683
|
+
class K {
|
|
1684
1684
|
/**
|
|
1685
1685
|
* @param root - A root element from which to anchor.
|
|
1686
1686
|
*/
|
|
@@ -1693,15 +1693,15 @@ class G {
|
|
|
1693
1693
|
* Will throw if `range` does not contain any text nodes.
|
|
1694
1694
|
*/
|
|
1695
1695
|
static fromRange(e, t) {
|
|
1696
|
-
const i = e.textContent,
|
|
1697
|
-
return new
|
|
1696
|
+
const i = e.textContent, s = I.fromRange(t).relativeTo(e), n = s.start.offset, o = s.end.offset, l = 32;
|
|
1697
|
+
return new K(e, i.slice(n, o), {
|
|
1698
1698
|
prefix: i.slice(Math.max(0, n - l), n),
|
|
1699
1699
|
suffix: i.slice(o, Math.min(i.length, o + l))
|
|
1700
1700
|
});
|
|
1701
1701
|
}
|
|
1702
1702
|
static fromSelector(e, t) {
|
|
1703
|
-
const { prefix: i, suffix:
|
|
1704
|
-
return new
|
|
1703
|
+
const { prefix: i, suffix: s } = t;
|
|
1704
|
+
return new K(e, t.exact, { prefix: i, suffix: s });
|
|
1705
1705
|
}
|
|
1706
1706
|
toSelector() {
|
|
1707
1707
|
return {
|
|
@@ -1715,26 +1715,26 @@ class G {
|
|
|
1715
1715
|
return this.toPositionAnchor(e).toRange();
|
|
1716
1716
|
}
|
|
1717
1717
|
toPositionAnchor(e = {}) {
|
|
1718
|
-
const t = this.root.textContent, i =
|
|
1718
|
+
const t = this.root.textContent, i = ct(t, this.exact, {
|
|
1719
1719
|
...this.context,
|
|
1720
1720
|
hint: e.hint
|
|
1721
1721
|
});
|
|
1722
1722
|
if (!i)
|
|
1723
1723
|
throw new Error("Quote not found");
|
|
1724
|
-
return new
|
|
1724
|
+
return new Y(this.root, i.start, i.end);
|
|
1725
1725
|
}
|
|
1726
1726
|
}
|
|
1727
|
-
function
|
|
1728
|
-
const e =
|
|
1727
|
+
function dt(r) {
|
|
1728
|
+
const e = r.tagName.toUpperCase();
|
|
1729
1729
|
return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
|
|
1730
1730
|
}
|
|
1731
|
-
function
|
|
1731
|
+
function ee(r, e) {
|
|
1732
1732
|
try {
|
|
1733
1733
|
const t = e.locations, i = e.text;
|
|
1734
1734
|
if (i && i.highlight) {
|
|
1735
|
-
let
|
|
1736
|
-
t && t.getCssSelector() && (
|
|
1737
|
-
const n = new
|
|
1735
|
+
let s;
|
|
1736
|
+
t && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), s || (s = r.body);
|
|
1737
|
+
const n = new K(s, i.highlight, {
|
|
1738
1738
|
prefix: i.before,
|
|
1739
1739
|
suffix: i.after
|
|
1740
1740
|
});
|
|
@@ -1745,15 +1745,15 @@ function de(s, e) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
}
|
|
1747
1747
|
if (t) {
|
|
1748
|
-
let
|
|
1749
|
-
if (!
|
|
1748
|
+
let s = null;
|
|
1749
|
+
if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {
|
|
1750
1750
|
for (const n of t.fragments)
|
|
1751
|
-
if (
|
|
1751
|
+
if (s = r.getElementById(n), s)
|
|
1752
1752
|
break;
|
|
1753
1753
|
}
|
|
1754
|
-
if (
|
|
1755
|
-
const n =
|
|
1756
|
-
return
|
|
1754
|
+
if (s) {
|
|
1755
|
+
const n = r.createRange();
|
|
1756
|
+
return s.childNodes.length === 0 || dt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1757
1757
|
}
|
|
1758
1758
|
}
|
|
1759
1759
|
} catch (t) {
|
|
@@ -1761,12 +1761,12 @@ function de(s, e) {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
return null;
|
|
1763
1763
|
}
|
|
1764
|
-
function
|
|
1765
|
-
let t =
|
|
1766
|
-
t.length ||
|
|
1767
|
-
const i = 1,
|
|
1764
|
+
function pt(r, e) {
|
|
1765
|
+
let t = r.getClientRects();
|
|
1766
|
+
t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
|
|
1767
|
+
const i = 1, s = [];
|
|
1768
1768
|
for (const h of t)
|
|
1769
|
-
|
|
1769
|
+
s.push({
|
|
1770
1770
|
bottom: h.bottom,
|
|
1771
1771
|
height: h.height,
|
|
1772
1772
|
left: h.left,
|
|
@@ -1774,10 +1774,10 @@ function lt(s, e) {
|
|
|
1774
1774
|
top: h.top,
|
|
1775
1775
|
width: h.width
|
|
1776
1776
|
});
|
|
1777
|
-
const n =
|
|
1778
|
-
|
|
1777
|
+
const n = qe(
|
|
1778
|
+
s,
|
|
1779
1779
|
i
|
|
1780
|
-
), o =
|
|
1780
|
+
), o = mt(n, i), l = Xe(o), u = 4;
|
|
1781
1781
|
for (let h = l.length - 1; h >= 0; h--) {
|
|
1782
1782
|
const c = l[h];
|
|
1783
1783
|
if (!(c.width * c.height > u))
|
|
@@ -1788,168 +1788,168 @@ function lt(s, e) {
|
|
|
1788
1788
|
}
|
|
1789
1789
|
return l;
|
|
1790
1790
|
}
|
|
1791
|
-
function
|
|
1792
|
-
for (let i = 0; i <
|
|
1793
|
-
for (let
|
|
1794
|
-
const n =
|
|
1791
|
+
function qe(r, e, t) {
|
|
1792
|
+
for (let i = 0; i < r.length; i++)
|
|
1793
|
+
for (let s = i + 1; s < r.length; s++) {
|
|
1794
|
+
const n = r[i], o = r[s];
|
|
1795
1795
|
if (n === o)
|
|
1796
1796
|
continue;
|
|
1797
|
-
const l =
|
|
1798
|
-
if (l && !u &&
|
|
1799
|
-
const m =
|
|
1800
|
-
return m.push(p),
|
|
1797
|
+
const l = P(n.top, o.top, e) && P(n.bottom, o.bottom, e), u = P(n.left, o.left, e) && P(n.right, o.right, e);
|
|
1798
|
+
if (l && !u && _e(n, o, e)) {
|
|
1799
|
+
const m = r.filter((y) => y !== n && y !== o), p = ft(n, o);
|
|
1800
|
+
return m.push(p), qe(
|
|
1801
1801
|
m,
|
|
1802
1802
|
e
|
|
1803
1803
|
);
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
return
|
|
1806
|
+
return r;
|
|
1807
1807
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const t = Math.min(
|
|
1808
|
+
function ft(r, e) {
|
|
1809
|
+
const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);
|
|
1810
1810
|
return {
|
|
1811
1811
|
bottom: n,
|
|
1812
|
-
height: n -
|
|
1812
|
+
height: n - s,
|
|
1813
1813
|
left: t,
|
|
1814
1814
|
right: i,
|
|
1815
|
-
top:
|
|
1815
|
+
top: s,
|
|
1816
1816
|
width: i - t
|
|
1817
1817
|
};
|
|
1818
1818
|
}
|
|
1819
|
-
function
|
|
1820
|
-
const t = new Set(
|
|
1821
|
-
for (const i of
|
|
1819
|
+
function mt(r, e) {
|
|
1820
|
+
const t = new Set(r);
|
|
1821
|
+
for (const i of r) {
|
|
1822
1822
|
if (!(i.width > 1 && i.height > 1)) {
|
|
1823
1823
|
t.delete(i);
|
|
1824
1824
|
continue;
|
|
1825
1825
|
}
|
|
1826
|
-
for (const n of
|
|
1827
|
-
if (i !== n && t.has(n) &&
|
|
1826
|
+
for (const n of r)
|
|
1827
|
+
if (i !== n && t.has(n) && gt(n, i, e)) {
|
|
1828
1828
|
t.delete(i);
|
|
1829
1829
|
break;
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
1832
1832
|
return Array.from(t);
|
|
1833
1833
|
}
|
|
1834
|
-
function
|
|
1835
|
-
return
|
|
1834
|
+
function gt(r, e, t) {
|
|
1835
|
+
return q(r, e.left, e.top, t) && q(r, e.right, e.top, t) && q(r, e.left, e.bottom, t) && q(r, e.right, e.bottom, t);
|
|
1836
1836
|
}
|
|
1837
|
-
function
|
|
1838
|
-
return (
|
|
1837
|
+
function q(r, e, t, i) {
|
|
1838
|
+
return (r.left < e || P(r.left, e, i)) && (r.right > e || P(r.right, e, i)) && (r.top < t || P(r.top, t, i)) && (r.bottom > t || P(r.bottom, t, i));
|
|
1839
1839
|
}
|
|
1840
|
-
function
|
|
1841
|
-
for (let e = 0; e <
|
|
1842
|
-
for (let t = e + 1; t <
|
|
1843
|
-
const i =
|
|
1844
|
-
if (i !==
|
|
1840
|
+
function Xe(r) {
|
|
1841
|
+
for (let e = 0; e < r.length; e++)
|
|
1842
|
+
for (let t = e + 1; t < r.length; t++) {
|
|
1843
|
+
const i = r[e], s = r[t];
|
|
1844
|
+
if (i !== s && _e(i, s, -1)) {
|
|
1845
1845
|
let n = [], o;
|
|
1846
|
-
const l =
|
|
1846
|
+
const l = Ne(i, s);
|
|
1847
1847
|
if (l.length === 1)
|
|
1848
1848
|
n = l, o = i;
|
|
1849
1849
|
else {
|
|
1850
|
-
const h =
|
|
1851
|
-
l.length < h.length ? (n = l, o = i) : (n = h, o =
|
|
1850
|
+
const h = Ne(s, i);
|
|
1851
|
+
l.length < h.length ? (n = l, o = i) : (n = h, o = s);
|
|
1852
1852
|
}
|
|
1853
|
-
const u =
|
|
1854
|
-
return Array.prototype.push.apply(u, n),
|
|
1853
|
+
const u = r.filter((h) => h !== o);
|
|
1854
|
+
return Array.prototype.push.apply(u, n), Xe(u);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
|
-
return
|
|
1857
|
+
return r;
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
const t =
|
|
1859
|
+
function Ne(r, e) {
|
|
1860
|
+
const t = yt(e, r);
|
|
1861
1861
|
if (t.height === 0 || t.width === 0)
|
|
1862
|
-
return [
|
|
1862
|
+
return [r];
|
|
1863
1863
|
const i = [];
|
|
1864
1864
|
{
|
|
1865
|
-
const
|
|
1866
|
-
bottom:
|
|
1865
|
+
const s = {
|
|
1866
|
+
bottom: r.bottom,
|
|
1867
1867
|
height: 0,
|
|
1868
|
-
left:
|
|
1868
|
+
left: r.left,
|
|
1869
1869
|
right: t.left,
|
|
1870
|
-
top:
|
|
1870
|
+
top: r.top,
|
|
1871
1871
|
width: 0
|
|
1872
1872
|
};
|
|
1873
|
-
|
|
1873
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1874
1874
|
}
|
|
1875
1875
|
{
|
|
1876
|
-
const
|
|
1876
|
+
const s = {
|
|
1877
1877
|
bottom: t.top,
|
|
1878
1878
|
height: 0,
|
|
1879
1879
|
left: t.left,
|
|
1880
1880
|
right: t.right,
|
|
1881
|
-
top:
|
|
1881
|
+
top: r.top,
|
|
1882
1882
|
width: 0
|
|
1883
1883
|
};
|
|
1884
|
-
|
|
1884
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1885
1885
|
}
|
|
1886
1886
|
{
|
|
1887
|
-
const
|
|
1888
|
-
bottom:
|
|
1887
|
+
const s = {
|
|
1888
|
+
bottom: r.bottom,
|
|
1889
1889
|
height: 0,
|
|
1890
1890
|
left: t.left,
|
|
1891
1891
|
right: t.right,
|
|
1892
1892
|
top: t.bottom,
|
|
1893
1893
|
width: 0
|
|
1894
1894
|
};
|
|
1895
|
-
|
|
1895
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1896
1896
|
}
|
|
1897
1897
|
{
|
|
1898
|
-
const
|
|
1899
|
-
bottom:
|
|
1898
|
+
const s = {
|
|
1899
|
+
bottom: r.bottom,
|
|
1900
1900
|
height: 0,
|
|
1901
1901
|
left: t.right,
|
|
1902
|
-
right:
|
|
1903
|
-
top:
|
|
1902
|
+
right: r.right,
|
|
1903
|
+
top: r.top,
|
|
1904
1904
|
width: 0
|
|
1905
1905
|
};
|
|
1906
|
-
|
|
1906
|
+
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
1907
1907
|
}
|
|
1908
1908
|
return i;
|
|
1909
1909
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const t = Math.max(
|
|
1910
|
+
function yt(r, e) {
|
|
1911
|
+
const t = Math.max(r.left, e.left), i = Math.min(r.right, e.right), s = Math.max(r.top, e.top), n = Math.min(r.bottom, e.bottom);
|
|
1912
1912
|
return {
|
|
1913
1913
|
bottom: n,
|
|
1914
|
-
height: Math.max(0, n -
|
|
1914
|
+
height: Math.max(0, n - s),
|
|
1915
1915
|
left: t,
|
|
1916
1916
|
right: i,
|
|
1917
|
-
top:
|
|
1917
|
+
top: s,
|
|
1918
1918
|
width: Math.max(0, i - t)
|
|
1919
1919
|
};
|
|
1920
1920
|
}
|
|
1921
|
-
function
|
|
1922
|
-
return (
|
|
1921
|
+
function _e(r, e, t) {
|
|
1922
|
+
return (r.left < e.right || t >= 0 && P(r.left, e.right, t)) && (e.left < r.right || t >= 0 && P(e.left, r.right, t)) && (r.top < e.bottom || t >= 0 && P(r.top, e.bottom, t)) && (e.top < r.bottom || t >= 0 && P(e.top, r.bottom, t));
|
|
1923
1923
|
}
|
|
1924
|
-
function
|
|
1925
|
-
return Math.abs(
|
|
1924
|
+
function P(r, e, t) {
|
|
1925
|
+
return Math.abs(r - e) <= t;
|
|
1926
1926
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const e = {}, t =
|
|
1929
|
-
for (const i in
|
|
1927
|
+
function Ge(r) {
|
|
1928
|
+
const e = {}, t = r.document.documentElement.style;
|
|
1929
|
+
for (const i in r.document.documentElement.style)
|
|
1930
1930
|
Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
|
|
1931
1931
|
return e;
|
|
1932
1932
|
}
|
|
1933
|
-
function
|
|
1934
|
-
const t =
|
|
1933
|
+
function vt(r, e) {
|
|
1934
|
+
const t = Ge(r);
|
|
1935
1935
|
Object.keys(t).forEach((i) => {
|
|
1936
|
-
e.hasOwnProperty(i) ||
|
|
1937
|
-
}), Object.entries(e).forEach(([i,
|
|
1938
|
-
t[i] !==
|
|
1936
|
+
e.hasOwnProperty(i) || ye(r, i);
|
|
1937
|
+
}), Object.entries(e).forEach(([i, s]) => {
|
|
1938
|
+
t[i] !== s && Z(r, i, s);
|
|
1939
1939
|
});
|
|
1940
1940
|
}
|
|
1941
|
-
function
|
|
1942
|
-
return
|
|
1941
|
+
function Oe(r, e) {
|
|
1942
|
+
return r.document.documentElement.style.getPropertyValue(e);
|
|
1943
1943
|
}
|
|
1944
|
-
function
|
|
1945
|
-
|
|
1944
|
+
function Z(r, e, t) {
|
|
1945
|
+
r.document.documentElement.style.setProperty(e, t);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1948
|
-
|
|
1947
|
+
function ye(r, e) {
|
|
1948
|
+
r.document.documentElement.style.removeProperty(e);
|
|
1949
1949
|
}
|
|
1950
|
-
const
|
|
1951
|
-
if (
|
|
1952
|
-
const e =
|
|
1950
|
+
const bt = (r) => {
|
|
1951
|
+
if (r.startsWith("rgb")) {
|
|
1952
|
+
const e = r.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
|
|
1953
1953
|
if (e)
|
|
1954
1954
|
return {
|
|
1955
1955
|
r: parseInt(e[1], 10),
|
|
@@ -1957,8 +1957,8 @@ const ft = (s) => {
|
|
|
1957
1957
|
b: parseInt(e[3], 10),
|
|
1958
1958
|
a: e[4] ? parseInt(e[4], 10) / 255 : 1
|
|
1959
1959
|
};
|
|
1960
|
-
} else if (
|
|
1961
|
-
const e =
|
|
1960
|
+
} else if (r.startsWith("#")) {
|
|
1961
|
+
const e = r.slice(1);
|
|
1962
1962
|
if (e.length === 3 || e.length === 4)
|
|
1963
1963
|
return {
|
|
1964
1964
|
r: parseInt(e[0] + e[0], 16) / 255,
|
|
@@ -1975,20 +1975,20 @@ const ft = (s) => {
|
|
|
1975
1975
|
};
|
|
1976
1976
|
}
|
|
1977
1977
|
return { r: 0, g: 0, b: 0, a: 1 };
|
|
1978
|
-
},
|
|
1979
|
-
const e =
|
|
1980
|
-
return
|
|
1978
|
+
}, Et = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, xt = (r) => {
|
|
1979
|
+
const e = bt(r);
|
|
1980
|
+
return Et(e) < 128;
|
|
1981
1981
|
};
|
|
1982
|
-
var
|
|
1983
|
-
const
|
|
1984
|
-
class
|
|
1982
|
+
var Tt = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(Tt || {}), wt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(wt || {});
|
|
1983
|
+
const St = () => "Highlight" in window, Le = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
1984
|
+
class Ct {
|
|
1985
1985
|
/**
|
|
1986
1986
|
* Creates a DecorationGroup object
|
|
1987
1987
|
* @param id Unique HTML ID-adhering name of the group
|
|
1988
1988
|
* @param name Human-readable name of the group
|
|
1989
1989
|
*/
|
|
1990
|
-
constructor(e, t, i,
|
|
1991
|
-
this.wnd = e, this.comms = t, this.id = i, this.name =
|
|
1990
|
+
constructor(e, t, i, s) {
|
|
1991
|
+
this.wnd = e, this.comms = t, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, St() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
1992
1992
|
}
|
|
1993
1993
|
get activeable() {
|
|
1994
1994
|
return this.activateable;
|
|
@@ -2001,13 +2001,13 @@ class bt {
|
|
|
2001
2001
|
* @param decoration Decoration to add
|
|
2002
2002
|
*/
|
|
2003
2003
|
add(e) {
|
|
2004
|
-
const t = `${this.id}-${this.lastItemId++}`, i =
|
|
2004
|
+
const t = `${this.id}-${this.lastItemId++}`, i = ee(this.wnd.document, e.locator);
|
|
2005
2005
|
if (!i) {
|
|
2006
2006
|
this.comms.log("Can't locate DOM range for decoration", e);
|
|
2007
2007
|
return;
|
|
2008
2008
|
}
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2009
|
+
const s = i.commonAncestorContainer;
|
|
2010
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Le.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), s.querySelector(Le.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));
|
|
2011
2011
|
const n = {
|
|
2012
2012
|
decoration: e,
|
|
2013
2013
|
id: t,
|
|
@@ -2020,7 +2020,7 @@ class bt {
|
|
|
2020
2020
|
* @param identifier ID of item to remove
|
|
2021
2021
|
*/
|
|
2022
2022
|
remove(e) {
|
|
2023
|
-
const t = this.items.findIndex((
|
|
2023
|
+
const t = this.items.findIndex((s) => s.decoration.id === e);
|
|
2024
2024
|
if (t < 0) return;
|
|
2025
2025
|
const i = this.items[t];
|
|
2026
2026
|
this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
|
|
@@ -2062,11 +2062,11 @@ class bt {
|
|
|
2062
2062
|
return this.experimentalLayout(e);
|
|
2063
2063
|
const t = this.wnd.document.createElement("div");
|
|
2064
2064
|
t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
|
|
2065
|
-
const i = this.wnd.innerWidth,
|
|
2065
|
+
const i = this.wnd.innerWidth, s = parseInt(
|
|
2066
2066
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2067
2067
|
"column-count"
|
|
2068
2068
|
)
|
|
2069
|
-
), n = i / (
|
|
2069
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, u = o.scrollTop, h = (d, f, g) => {
|
|
2070
2070
|
if (d.style.position = "absolute", e.decoration?.style?.width === "viewport") {
|
|
2071
2071
|
d.style.width = `${i}px`, d.style.height = `${f.height}px`;
|
|
2072
2072
|
let E = Math.floor(f.left / i) * i;
|
|
@@ -2081,7 +2081,7 @@ class bt {
|
|
|
2081
2081
|
d.style.width = `${f.width}px`, d.style.height = `${f.height}px`, d.style.left = `${f.left + l}px`, d.style.top = `${f.top + u}px`;
|
|
2082
2082
|
}, c = e.range.getBoundingClientRect();
|
|
2083
2083
|
let m = this.wnd.document.createElement("template");
|
|
2084
|
-
const p =
|
|
2084
|
+
const p = Oe(this.wnd, "--USER__appearance") === "readium-night-on" || xt(Oe(this.wnd, "--USER__backgroundColor"));
|
|
2085
2085
|
m.innerHTML = `
|
|
2086
2086
|
<div
|
|
2087
2087
|
class="r2-highlight-0"
|
|
@@ -2100,7 +2100,7 @@ class bt {
|
|
|
2100
2100
|
const d = y.cloneNode(!0);
|
|
2101
2101
|
d.style.setProperty("pointer-events", "none"), h(d, c, c), t.append(d);
|
|
2102
2102
|
} else {
|
|
2103
|
-
let d =
|
|
2103
|
+
let d = pt(
|
|
2104
2104
|
e.range
|
|
2105
2105
|
);
|
|
2106
2106
|
d = d.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);
|
|
@@ -2139,7 +2139,7 @@ class bt {
|
|
|
2139
2139
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2140
2140
|
}
|
|
2141
2141
|
}
|
|
2142
|
-
const
|
|
2142
|
+
const H = class H extends j {
|
|
2143
2143
|
constructor() {
|
|
2144
2144
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2145
2145
|
}
|
|
@@ -2154,9 +2154,9 @@ const B = class B extends Z {
|
|
|
2154
2154
|
}, 50);
|
|
2155
2155
|
}
|
|
2156
2156
|
mount(e, t) {
|
|
2157
|
-
return this.wnd = e, t.register("decorate",
|
|
2157
|
+
return this.wnd = e, t.register("decorate", H.moduleName, (i, s) => {
|
|
2158
2158
|
const n = i;
|
|
2159
|
-
n.decoration && n.decoration.locator && (n.decoration.locator = L.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new
|
|
2159
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = L.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Ct(
|
|
2160
2160
|
e,
|
|
2161
2161
|
t,
|
|
2162
2162
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2177,16 +2177,16 @@ const B = class B extends Z {
|
|
|
2177
2177
|
o?.update(n.decoration);
|
|
2178
2178
|
break;
|
|
2179
2179
|
}
|
|
2180
|
-
|
|
2180
|
+
s(!0);
|
|
2181
2181
|
}), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), t.log("Decorator Mounted"), !0;
|
|
2182
2182
|
}
|
|
2183
2183
|
unmount(e, t) {
|
|
2184
|
-
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(
|
|
2184
|
+
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(H.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
|
|
2185
2185
|
}
|
|
2186
2186
|
};
|
|
2187
|
-
|
|
2188
|
-
let
|
|
2189
|
-
const
|
|
2187
|
+
H.moduleName = "decorator";
|
|
2188
|
+
let se = H;
|
|
2189
|
+
const Ie = "readium-snapper-style", $ = class $ extends j {
|
|
2190
2190
|
constructor() {
|
|
2191
2191
|
super(...arguments), this.protected = !1;
|
|
2192
2192
|
}
|
|
@@ -2199,59 +2199,59 @@ const Ae = "readium-snapper-style", k = class k extends Z {
|
|
|
2199
2199
|
}
|
|
2200
2200
|
mount(e, t) {
|
|
2201
2201
|
const i = e.document.createElement("style");
|
|
2202
|
-
return i.dataset.readium = "true", i.id =
|
|
2202
|
+
return i.dataset.readium = "true", i.id = Ie, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", $.moduleName, (s, n) => {
|
|
2203
2203
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2204
|
-
}), t.register("unprotect",
|
|
2204
|
+
}), t.register("unprotect", $.moduleName, (s, n) => {
|
|
2205
2205
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2206
2206
|
}), t.log("Snapper Mounted"), !0;
|
|
2207
2207
|
}
|
|
2208
2208
|
unmount(e, t) {
|
|
2209
|
-
return e.document.getElementById(
|
|
2209
|
+
return e.document.getElementById(Ie)?.remove(), t.log("Snapper Unmounted"), !0;
|
|
2210
2210
|
}
|
|
2211
2211
|
};
|
|
2212
|
-
|
|
2213
|
-
let
|
|
2214
|
-
function
|
|
2215
|
-
return
|
|
2212
|
+
$.moduleName = "snapper";
|
|
2213
|
+
let V = $;
|
|
2214
|
+
function R(r) {
|
|
2215
|
+
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2217
|
+
function Ye(r) {
|
|
2218
2218
|
return parseInt(
|
|
2219
|
-
|
|
2220
|
-
|
|
2219
|
+
r.getComputedStyle(
|
|
2220
|
+
r.document.documentElement
|
|
2221
2221
|
).getPropertyValue("column-count")
|
|
2222
2222
|
);
|
|
2223
2223
|
}
|
|
2224
|
-
function
|
|
2225
|
-
const e = getComputedStyle(
|
|
2226
|
-
return
|
|
2224
|
+
function Re(r) {
|
|
2225
|
+
const e = getComputedStyle(r), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
|
|
2226
|
+
return r.clientHeight - t - i;
|
|
2227
2227
|
}
|
|
2228
|
-
function
|
|
2229
|
-
const e =
|
|
2228
|
+
function ze(r) {
|
|
2229
|
+
const e = Ye(r);
|
|
2230
2230
|
if (!e)
|
|
2231
2231
|
return !1;
|
|
2232
|
-
const t =
|
|
2232
|
+
const t = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2233
2233
|
for (const h of t)
|
|
2234
2234
|
h.remove();
|
|
2235
|
-
const i = t.length,
|
|
2235
|
+
const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, l = Math.round(s / n * e) % e, u = e === 1 || l === 0 ? 0 : e - l;
|
|
2236
2236
|
if (u > 0)
|
|
2237
2237
|
for (let h = 0; h < u; h++) {
|
|
2238
|
-
const c =
|
|
2239
|
-
c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height =
|
|
2238
|
+
const c = r.document.createElement("div");
|
|
2239
|
+
c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = Re(r.document.documentElement) + "px"), c.innerHTML = "​", r.document.body.appendChild(c);
|
|
2240
2240
|
}
|
|
2241
2241
|
return i !== u;
|
|
2242
2242
|
}
|
|
2243
|
-
function
|
|
2244
|
-
const e =
|
|
2245
|
-
e.appendChild(
|
|
2243
|
+
function Ke(r) {
|
|
2244
|
+
const e = r.document.createElement("style");
|
|
2245
|
+
e.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(e), r.document.body.removeChild(e);
|
|
2246
2246
|
}
|
|
2247
|
-
function
|
|
2248
|
-
return
|
|
2247
|
+
function Pt(r) {
|
|
2248
|
+
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2249
2249
|
}
|
|
2250
|
-
function
|
|
2251
|
-
const e =
|
|
2250
|
+
function v(r) {
|
|
2251
|
+
const e = r.getSelection();
|
|
2252
2252
|
e && e.removeAllRanges();
|
|
2253
2253
|
}
|
|
2254
|
-
const
|
|
2254
|
+
const At = [
|
|
2255
2255
|
"a",
|
|
2256
2256
|
"audio",
|
|
2257
2257
|
"button",
|
|
@@ -2265,48 +2265,48 @@ const wt = [
|
|
|
2265
2265
|
"textarea",
|
|
2266
2266
|
"video"
|
|
2267
2267
|
];
|
|
2268
|
-
function
|
|
2269
|
-
return
|
|
2268
|
+
function Ze(r) {
|
|
2269
|
+
return At.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Ze(r.parentElement) : null;
|
|
2270
2270
|
}
|
|
2271
|
-
function
|
|
2272
|
-
const t =
|
|
2271
|
+
function ve(r, e) {
|
|
2272
|
+
const t = Je(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {
|
|
2273
2273
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2274
2274
|
});
|
|
2275
2275
|
return new L({
|
|
2276
2276
|
href: "#",
|
|
2277
2277
|
type: "application/xhtml+xml",
|
|
2278
|
-
locations: new
|
|
2278
|
+
locations: new b({
|
|
2279
2279
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2280
2280
|
["cssSelector", i]
|
|
2281
2281
|
])
|
|
2282
2282
|
}),
|
|
2283
|
-
text: new
|
|
2283
|
+
text: new z({
|
|
2284
2284
|
highlight: t.textContent || void 0
|
|
2285
2285
|
})
|
|
2286
2286
|
});
|
|
2287
2287
|
}
|
|
2288
|
-
function
|
|
2288
|
+
function Je(r, e, t) {
|
|
2289
2289
|
for (var i = 0; i < e.children.length; i++) {
|
|
2290
|
-
const
|
|
2291
|
-
if (!
|
|
2292
|
-
return
|
|
2290
|
+
const s = e.children[i];
|
|
2291
|
+
if (!Ot(s) && Mt(r, s, t))
|
|
2292
|
+
return Nt(r, s) ? s : Je(r, s, t);
|
|
2293
2293
|
}
|
|
2294
2294
|
return e;
|
|
2295
2295
|
}
|
|
2296
|
-
function
|
|
2296
|
+
function Mt(r, e, t) {
|
|
2297
2297
|
if (e === document.body || e === document.documentElement)
|
|
2298
2298
|
return !0;
|
|
2299
2299
|
if (!document || !document.documentElement || !document.body)
|
|
2300
2300
|
return !1;
|
|
2301
2301
|
const i = e.getBoundingClientRect();
|
|
2302
|
-
return t ? i.bottom > 0 && i.top <
|
|
2302
|
+
return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2303
2303
|
}
|
|
2304
|
-
function
|
|
2304
|
+
function Nt(r, e) {
|
|
2305
2305
|
const t = e.getBoundingClientRect();
|
|
2306
|
-
return t.top >= 0 && t.left >= 0 && t.bottom <=
|
|
2306
|
+
return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;
|
|
2307
2307
|
}
|
|
2308
|
-
function
|
|
2309
|
-
const e = getComputedStyle(
|
|
2308
|
+
function Ot(r) {
|
|
2309
|
+
const e = getComputedStyle(r);
|
|
2310
2310
|
if (e) {
|
|
2311
2311
|
const t = e.getPropertyValue("display");
|
|
2312
2312
|
if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
|
|
@@ -2314,7 +2314,7 @@ function Pt(s) {
|
|
|
2314
2314
|
}
|
|
2315
2315
|
return !1;
|
|
2316
2316
|
}
|
|
2317
|
-
const
|
|
2317
|
+
const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
2318
2318
|
constructor() {
|
|
2319
2319
|
super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2320
2320
|
}
|
|
@@ -2325,20 +2325,20 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2325
2325
|
return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
|
|
2326
2326
|
}
|
|
2327
2327
|
snapOffset(e) {
|
|
2328
|
-
const t = e + (
|
|
2328
|
+
const t = e + (R(this.wnd) ? -1 : 1);
|
|
2329
2329
|
return t - t % this.wnd.innerWidth;
|
|
2330
2330
|
}
|
|
2331
2331
|
reportProgress() {
|
|
2332
|
-
const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)),
|
|
2332
|
+
const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)), s = Math.max(0, Math.min(1, (e + this.wnd.innerWidth) / t));
|
|
2333
2333
|
this.comms.send("progress", {
|
|
2334
2334
|
start: i,
|
|
2335
|
-
end:
|
|
2335
|
+
end: s
|
|
2336
2336
|
});
|
|
2337
2337
|
}
|
|
2338
2338
|
shake() {
|
|
2339
2339
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2340
2340
|
const e = this.doc();
|
|
2341
|
-
e.classList.add(
|
|
2341
|
+
e.classList.add(R(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
|
|
2342
2342
|
const t = this.scrollOffset();
|
|
2343
2343
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2344
2344
|
e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
|
|
@@ -2352,27 +2352,27 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
// Snaps the current offset to the page width.
|
|
2354
2354
|
snapCurrentOffset(e = !1, t = !1) {
|
|
2355
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft,
|
|
2355
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ye(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), u = R(this.wnd) ? -1 : 1, h = (
|
|
2356
2356
|
// The hurdle to overcome in order to change pages
|
|
2357
2357
|
u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)
|
|
2358
2358
|
), c = this.snapOffset(l + h);
|
|
2359
2359
|
if (e && c !== this.scrollOffset()) {
|
|
2360
2360
|
this.snappingCancelled = !1;
|
|
2361
|
-
const m = (f, g, E,
|
|
2361
|
+
const m = (f, g, E, D) => E > D ? g : f + (g - f) * Pt(E / D), p = (
|
|
2362
2362
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2363
|
-
|
|
2363
|
+
Lt * o
|
|
2364
2364
|
);
|
|
2365
2365
|
let y;
|
|
2366
2366
|
const d = (f) => {
|
|
2367
2367
|
if (this.snappingCancelled) return;
|
|
2368
2368
|
y || (y = f);
|
|
2369
|
-
const g = f - y, E = m(this.overscroll, 0, g, p),
|
|
2370
|
-
|
|
2369
|
+
const g = f - y, E = m(this.overscroll, 0, g, p), D = m(i, c, g, p);
|
|
2370
|
+
s.scrollLeft = D, this.overscroll !== 0 && (s.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < p ? this.wnd.requestAnimationFrame(d) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = c, t || this.reportProgress());
|
|
2371
2371
|
};
|
|
2372
2372
|
this.wnd.requestAnimationFrame(d);
|
|
2373
2373
|
} else
|
|
2374
|
-
|
|
2375
|
-
|
|
2374
|
+
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2375
|
+
s.scrollLeft = c, this.clearTouches(), t || this.reportProgress();
|
|
2376
2376
|
});
|
|
2377
2377
|
}
|
|
2378
2378
|
dragOffset() {
|
|
@@ -2407,15 +2407,15 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
onTouchMove(e) {
|
|
2409
2409
|
if (this.touchState === 0) return;
|
|
2410
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2410
|
+
this.touchState === 1 && (this.touchState = 2, v(this.wnd)), this.endingX = e.touches[0].clientX;
|
|
2411
2411
|
const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
|
|
2412
2412
|
i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
|
|
2413
2413
|
}
|
|
2414
2414
|
mount(e, t) {
|
|
2415
2415
|
if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;
|
|
2416
|
-
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2416
|
+
e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2417
2417
|
const i = e.document.createElement("style");
|
|
2418
|
-
i.dataset.readium = "true", i.id =
|
|
2418
|
+
i.dataset.readium = "true", i.id = De, i.textContent = `
|
|
2419
2419
|
@keyframes readium-bounce-l-animation {
|
|
2420
2420
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2421
2421
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2451,23 +2451,23 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2451
2451
|
}
|
|
2452
2452
|
`, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2453
2453
|
e.requestAnimationFrame(() => {
|
|
2454
|
-
e &&
|
|
2454
|
+
e && ze(e);
|
|
2455
2455
|
}), this.onWidthChange();
|
|
2456
2456
|
}), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2457
2457
|
for (const o of n)
|
|
2458
2458
|
if (o.target === this.wnd.document.documentElement) {
|
|
2459
2459
|
const l = o.oldValue, u = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = l?.match(h), m = u?.match(h);
|
|
2460
2460
|
(!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {
|
|
2461
|
-
e &&
|
|
2461
|
+
e && ze(e);
|
|
2462
2462
|
}), this.onWidthChange());
|
|
2463
2463
|
} else
|
|
2464
2464
|
e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2465
2465
|
}), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
|
|
2466
|
-
const
|
|
2466
|
+
const s = (n) => {
|
|
2467
2467
|
const o = this.doc().scrollLeft;
|
|
2468
2468
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2469
2469
|
};
|
|
2470
|
-
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression",
|
|
2470
|
+
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", x.moduleName, (n, o) => {
|
|
2471
2471
|
const l = n;
|
|
2472
2472
|
if (l < 0 || l > 1) {
|
|
2473
2473
|
t.send("error", {
|
|
@@ -2477,26 +2477,26 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2477
2477
|
}
|
|
2478
2478
|
this.wnd.requestAnimationFrame(() => {
|
|
2479
2479
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2480
|
-
const u = this.cachedScrollWidth, h =
|
|
2481
|
-
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(),
|
|
2480
|
+
const u = this.cachedScrollWidth, h = R(e) ? -1 : 1, c = u * l * h;
|
|
2481
|
+
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), v(this.wnd), o(!0);
|
|
2482
2482
|
});
|
|
2483
|
-
}), t.register("go_id",
|
|
2483
|
+
}), t.register("go_id", x.moduleName, (n, o) => {
|
|
2484
2484
|
const l = e.document.getElementById(n);
|
|
2485
2485
|
if (!l) {
|
|
2486
2486
|
o(!1);
|
|
2487
2487
|
return;
|
|
2488
2488
|
}
|
|
2489
2489
|
this.wnd.requestAnimationFrame(() => {
|
|
2490
|
-
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(),
|
|
2490
|
+
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
|
|
2491
2491
|
});
|
|
2492
|
-
}), t.register("go_text",
|
|
2492
|
+
}), t.register("go_text", x.moduleName, (n, o) => {
|
|
2493
2493
|
let l;
|
|
2494
2494
|
Array.isArray(n) && (n.length > 1 && (l = n[1]), n = n[0]);
|
|
2495
|
-
const u =
|
|
2495
|
+
const u = z.deserialize(n), h = ee(this.wnd.document, new L({
|
|
2496
2496
|
href: e.location.href,
|
|
2497
2497
|
type: "text/html",
|
|
2498
2498
|
text: u,
|
|
2499
|
-
locations: l ? new
|
|
2499
|
+
locations: l ? new b({
|
|
2500
2500
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2501
2501
|
["cssSelector", l]
|
|
2502
2502
|
])
|
|
@@ -2507,54 +2507,54 @@ const Oe = "readium-column-snapper-style", At = 200, b = class b extends Y {
|
|
|
2507
2507
|
return;
|
|
2508
2508
|
}
|
|
2509
2509
|
this.wnd.requestAnimationFrame(() => {
|
|
2510
|
-
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(),
|
|
2510
|
+
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
|
|
2511
2511
|
});
|
|
2512
|
-
}), t.register("go_end",
|
|
2513
|
-
const l =
|
|
2512
|
+
}), t.register("go_end", x.moduleName, (n, o) => {
|
|
2513
|
+
const l = R(e) ? -1 : 1;
|
|
2514
2514
|
this.wnd.requestAnimationFrame(() => {
|
|
2515
2515
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2516
2516
|
const u = this.cachedScrollWidth * l;
|
|
2517
2517
|
if (this.doc().scrollLeft === u) return o(!1);
|
|
2518
|
-
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(),
|
|
2518
|
+
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), v(this.wnd), o(!0);
|
|
2519
2519
|
});
|
|
2520
|
-
}), t.register("go_start",
|
|
2520
|
+
}), t.register("go_start", x.moduleName, (n, o) => {
|
|
2521
2521
|
this.wnd.requestAnimationFrame(() => {
|
|
2522
2522
|
if (this.doc().scrollLeft === 0) return o(!1);
|
|
2523
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2523
|
+
this.doc().scrollLeft = 0, this.reportProgress(), v(this.wnd), o(!0);
|
|
2524
2524
|
});
|
|
2525
|
-
}), t.register("go_prev",
|
|
2525
|
+
}), t.register("go_prev", x.moduleName, (n, o) => {
|
|
2526
2526
|
this.wnd.requestAnimationFrame(() => {
|
|
2527
2527
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2528
|
-
const l = e.scrollX - e.innerWidth, u =
|
|
2529
|
-
h && (this.reportProgress(),
|
|
2528
|
+
const l = e.scrollX - e.innerWidth, u = R(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(l, u));
|
|
2529
|
+
h && (this.reportProgress(), v(this.wnd)), o(h);
|
|
2530
2530
|
});
|
|
2531
|
-
}), t.register("go_next",
|
|
2531
|
+
}), t.register("go_next", x.moduleName, (n, o) => {
|
|
2532
2532
|
this.wnd.requestAnimationFrame(() => {
|
|
2533
2533
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2534
|
-
const l = e.scrollX + e.innerWidth, u =
|
|
2535
|
-
h && (this.reportProgress(),
|
|
2534
|
+
const l = e.scrollX + e.innerWidth, u = R(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(l, u));
|
|
2535
|
+
h && (this.reportProgress(), v(this.wnd)), o(h);
|
|
2536
2536
|
});
|
|
2537
|
-
}), t.register("unfocus",
|
|
2538
|
-
this.snappingCancelled = !0,
|
|
2539
|
-
}), t.register("shake",
|
|
2537
|
+
}), t.register("unfocus", x.moduleName, (n, o) => {
|
|
2538
|
+
this.snappingCancelled = !0, v(this.wnd), o(!0);
|
|
2539
|
+
}), t.register("shake", x.moduleName, (n, o) => {
|
|
2540
2540
|
this.shake(), o(!0);
|
|
2541
|
-
}), t.register("focus",
|
|
2541
|
+
}), t.register("focus", x.moduleName, (n, o) => {
|
|
2542
2542
|
this.wnd.requestAnimationFrame(() => {
|
|
2543
2543
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2544
2544
|
});
|
|
2545
|
-
}), t.register("first_visible_locator",
|
|
2546
|
-
const l =
|
|
2545
|
+
}), t.register("first_visible_locator", x.moduleName, (n, o) => {
|
|
2546
|
+
const l = ve(e, !1);
|
|
2547
2547
|
this.comms.send("first_visible_locator", l.serialize()), o(!0);
|
|
2548
2548
|
}), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
|
|
2549
2549
|
}), t.log("ColumnSnapper Mounted"), !0;
|
|
2550
2550
|
}
|
|
2551
2551
|
unmount(e, t) {
|
|
2552
|
-
return this.snappingCancelled = !0, t.unregisterAll(
|
|
2552
|
+
return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(De)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
|
|
2553
2553
|
}
|
|
2554
2554
|
};
|
|
2555
|
-
|
|
2556
|
-
let
|
|
2557
|
-
const
|
|
2555
|
+
x.moduleName = "column_snapper";
|
|
2556
|
+
let re = x;
|
|
2557
|
+
const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
2558
2558
|
constructor() {
|
|
2559
2559
|
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2560
2560
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2575,16 +2575,16 @@ const Le = "readium-scroll-snapper-style", x = class x extends Y {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
reportProgress() {
|
|
2577
2577
|
if (!this.comms.ready) return;
|
|
2578
|
-
const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight,
|
|
2578
|
+
const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
|
|
2579
2579
|
this.comms.send("progress", {
|
|
2580
|
-
start:
|
|
2580
|
+
start: s,
|
|
2581
2581
|
end: n
|
|
2582
2582
|
});
|
|
2583
2583
|
}
|
|
2584
2584
|
mount(e, t) {
|
|
2585
|
-
this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem.layoutStyle = "scrolling";
|
|
2585
|
+
this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
2586
2586
|
const i = e.document.createElement("style");
|
|
2587
|
-
return i.dataset.readium = "true", i.id =
|
|
2587
|
+
return i.dataset.readium = "true", i.id = We, i.textContent = `
|
|
2588
2588
|
* {
|
|
2589
2589
|
scrollbar-width: none; /* for Firefox */
|
|
2590
2590
|
}
|
|
@@ -2596,12 +2596,12 @@ const Le = "readium-scroll-snapper-style", x = class x extends Y {
|
|
|
2596
2596
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2597
2597
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2598
2598
|
}, 50);
|
|
2599
|
-
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc",
|
|
2600
|
-
|
|
2601
|
-
const
|
|
2602
|
-
|
|
2603
|
-
}), t.register("go_progression",
|
|
2604
|
-
const o =
|
|
2599
|
+
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", T.moduleName, () => {
|
|
2600
|
+
Ke(this.wnd);
|
|
2601
|
+
const s = this.doc().scrollTop;
|
|
2602
|
+
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
2603
|
+
}), t.register("go_progression", T.moduleName, (s, n) => {
|
|
2604
|
+
const o = s;
|
|
2605
2605
|
if (o < 0 || o > 1) {
|
|
2606
2606
|
t.send("error", {
|
|
2607
2607
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
@@ -2609,25 +2609,25 @@ const Le = "readium-scroll-snapper-style", x = class x extends Y {
|
|
|
2609
2609
|
return;
|
|
2610
2610
|
}
|
|
2611
2611
|
this.wnd.requestAnimationFrame(() => {
|
|
2612
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(),
|
|
2612
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), v(this.wnd), n(!0);
|
|
2613
2613
|
});
|
|
2614
|
-
}), t.register("go_id",
|
|
2615
|
-
const o = e.document.getElementById(
|
|
2614
|
+
}), t.register("go_id", T.moduleName, (s, n) => {
|
|
2615
|
+
const o = e.document.getElementById(s);
|
|
2616
2616
|
if (!o) {
|
|
2617
2617
|
n(!1);
|
|
2618
2618
|
return;
|
|
2619
2619
|
}
|
|
2620
2620
|
this.wnd.requestAnimationFrame(() => {
|
|
2621
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(),
|
|
2621
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
|
|
2622
2622
|
});
|
|
2623
|
-
}), t.register("go_text",
|
|
2623
|
+
}), t.register("go_text", T.moduleName, (s, n) => {
|
|
2624
2624
|
let o;
|
|
2625
|
-
Array.isArray(
|
|
2626
|
-
const l =
|
|
2625
|
+
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
2626
|
+
const l = z.deserialize(s), u = ee(this.wnd.document, new L({
|
|
2627
2627
|
href: e.location.href,
|
|
2628
2628
|
type: "text/html",
|
|
2629
2629
|
text: l,
|
|
2630
|
-
locations: o ? new
|
|
2630
|
+
locations: o ? new b({
|
|
2631
2631
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2632
2632
|
["cssSelector", o]
|
|
2633
2633
|
])
|
|
@@ -2638,43 +2638,143 @@ const Le = "readium-scroll-snapper-style", x = class x extends Y {
|
|
|
2638
2638
|
return;
|
|
2639
2639
|
}
|
|
2640
2640
|
this.wnd.requestAnimationFrame(() => {
|
|
2641
|
-
this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(),
|
|
2641
|
+
this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
|
|
2642
2642
|
});
|
|
2643
|
-
}), t.register("go_start",
|
|
2643
|
+
}), t.register("go_start", T.moduleName, (s, n) => {
|
|
2644
2644
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
2645
2645
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
2646
|
-
}), t.register("go_end",
|
|
2646
|
+
}), t.register("go_end", T.moduleName, (s, n) => {
|
|
2647
2647
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
2648
2648
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
2649
|
-
}), t.register("unfocus",
|
|
2650
|
-
|
|
2649
|
+
}), t.register("unfocus", T.moduleName, (s, n) => {
|
|
2650
|
+
v(this.wnd), n(!0);
|
|
2651
2651
|
}), t.register([
|
|
2652
2652
|
"go_next",
|
|
2653
2653
|
"go_prev"
|
|
2654
|
-
],
|
|
2654
|
+
], T.moduleName, (s, n) => n(!1)), t.register("focus", T.moduleName, (s, n) => {
|
|
2655
2655
|
this.reportProgress(), n(!0);
|
|
2656
|
-
}), t.register("first_visible_locator",
|
|
2657
|
-
const o =
|
|
2656
|
+
}), t.register("first_visible_locator", T.moduleName, (s, n) => {
|
|
2657
|
+
const o = ve(e, !0);
|
|
2658
2658
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2659
2659
|
}), t.log("ScrollSnapper Mounted"), !0;
|
|
2660
2660
|
}
|
|
2661
2661
|
unmount(e, t) {
|
|
2662
|
-
return t.unregisterAll(
|
|
2662
|
+
return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(We)?.remove(), t.log("ScrollSnapper Unmounted"), !0;
|
|
2663
2663
|
}
|
|
2664
2664
|
};
|
|
2665
|
-
|
|
2666
|
-
let
|
|
2667
|
-
const
|
|
2665
|
+
T.moduleName = "scroll_snapper";
|
|
2666
|
+
let ne = T;
|
|
2667
|
+
const w = class w extends V {
|
|
2668
|
+
constructor() {
|
|
2669
|
+
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2670
|
+
if (this.comms.ready && !this.isResizing) {
|
|
2671
|
+
if (!this.initialScrollHandled) {
|
|
2672
|
+
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2675
|
+
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2676
|
+
this.reportProgress();
|
|
2677
|
+
const e = this.doc().scrollTop, t = e - this.lastScrollTop;
|
|
2678
|
+
this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
|
|
2679
|
+
}));
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
doc() {
|
|
2684
|
+
return this.wnd.document.scrollingElement;
|
|
2685
|
+
}
|
|
2686
|
+
reportProgress() {
|
|
2687
|
+
if (!this.comms.ready) return;
|
|
2688
|
+
const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
|
|
2689
|
+
this.comms.send("progress", {
|
|
2690
|
+
start: s,
|
|
2691
|
+
end: n
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
mount(e, t) {
|
|
2695
|
+
return this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
|
|
2696
|
+
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2697
|
+
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2698
|
+
}, 50);
|
|
2699
|
+
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", w.moduleName, () => {
|
|
2700
|
+
Ke(this.wnd);
|
|
2701
|
+
const i = this.doc().scrollTop;
|
|
2702
|
+
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
2703
|
+
}), t.register("go_progression", w.moduleName, (i, s) => {
|
|
2704
|
+
const n = i;
|
|
2705
|
+
if (n < 0 || n > 1) {
|
|
2706
|
+
t.send("error", {
|
|
2707
|
+
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2708
|
+
}), s(!1);
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
this.wnd.requestAnimationFrame(() => {
|
|
2712
|
+
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd), s(!0);
|
|
2713
|
+
});
|
|
2714
|
+
}), this.comms.register("go_id", w.moduleName, (i, s) => {
|
|
2715
|
+
const n = e.document.getElementById(i);
|
|
2716
|
+
if (!n) {
|
|
2717
|
+
s(!1);
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
this.wnd.requestAnimationFrame(() => {
|
|
2721
|
+
this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), s(!0);
|
|
2722
|
+
});
|
|
2723
|
+
}), t.register("go_text", w.moduleName, (i, s) => {
|
|
2724
|
+
let n;
|
|
2725
|
+
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
2726
|
+
const o = z.deserialize(i), l = ee(this.wnd.document, new L({
|
|
2727
|
+
href: e.location.href,
|
|
2728
|
+
type: "text/html",
|
|
2729
|
+
text: o,
|
|
2730
|
+
locations: n ? new b({
|
|
2731
|
+
otherLocations: /* @__PURE__ */ new Map([
|
|
2732
|
+
["cssSelector", n]
|
|
2733
|
+
])
|
|
2734
|
+
}) : void 0
|
|
2735
|
+
}));
|
|
2736
|
+
if (!l) {
|
|
2737
|
+
s(!1);
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
this.wnd.requestAnimationFrame(() => {
|
|
2741
|
+
this.doc().scrollTop = l.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), s(!0);
|
|
2742
|
+
});
|
|
2743
|
+
}), t.register("go_start", w.moduleName, (i, s) => {
|
|
2744
|
+
if (this.doc().scrollTop === 0) return s(!1);
|
|
2745
|
+
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
2746
|
+
}), t.register("go_end", w.moduleName, (i, s) => {
|
|
2747
|
+
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
2748
|
+
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
2749
|
+
}), t.register("unfocus", w.moduleName, (i, s) => {
|
|
2750
|
+
v(this.wnd), s(!0);
|
|
2751
|
+
}), t.register([
|
|
2752
|
+
"go_next",
|
|
2753
|
+
"go_prev"
|
|
2754
|
+
], w.moduleName, (i, s) => s(!1)), t.register("focus", w.moduleName, (i, s) => {
|
|
2755
|
+
this.reportProgress(), s(!0);
|
|
2756
|
+
}), t.register("first_visible_locator", w.moduleName, (i, s) => {
|
|
2757
|
+
const n = ve(e, !0);
|
|
2758
|
+
t.send("first_visible_locator", n.serialize()), s(!0);
|
|
2759
|
+
}), t.log("WebPubSnapper Mounted"), !0;
|
|
2760
|
+
}
|
|
2761
|
+
unmount(e, t) {
|
|
2762
|
+
return t.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), t.log("WebPubSnapper Unmounted"), !0;
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
w.moduleName = "webpub_snapper";
|
|
2766
|
+
let oe = w;
|
|
2767
|
+
const be = class be extends j {
|
|
2668
2768
|
constructor() {
|
|
2669
2769
|
super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
|
|
2670
2770
|
}
|
|
2671
2771
|
onPointUp(e) {
|
|
2672
2772
|
const t = this.wnd.getSelection();
|
|
2673
2773
|
if (t && t.toString()?.length > 0) {
|
|
2674
|
-
const
|
|
2675
|
-
if (!
|
|
2774
|
+
const s = t.getRangeAt(0)?.getClientRects();
|
|
2775
|
+
if (!s || s.length === 0)
|
|
2676
2776
|
return;
|
|
2677
|
-
const n =
|
|
2777
|
+
const n = s[0], o = {
|
|
2678
2778
|
text: t.toString(),
|
|
2679
2779
|
x: n.x,
|
|
2680
2780
|
y: n.y,
|
|
@@ -2696,7 +2796,7 @@ const fe = class fe extends Z {
|
|
|
2696
2796
|
y: e.clientY * i,
|
|
2697
2797
|
targetFrameSrc: this.wnd.location.href,
|
|
2698
2798
|
targetElement: e.target.outerHTML,
|
|
2699
|
-
interactiveElement:
|
|
2799
|
+
interactiveElement: Ze(e.target)?.outerHTML,
|
|
2700
2800
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
|
|
2701
2801
|
}), this.pointerMoved = !1;
|
|
2702
2802
|
}
|
|
@@ -2732,9 +2832,9 @@ const fe = class fe extends Z {
|
|
|
2732
2832
|
return e.document.removeEventListener("pointerdown", this.onPointerDown), e.document.removeEventListener("pointerup", this.onPointerUp), e.document.removeEventListener("contextmenu", this.onContextMenu), e.document.removeEventListener("pointermove", this.onPointerMove), e.document.removeEventListener("click", this.onClicker), t.log("Peripherals Unmounted"), !0;
|
|
2733
2833
|
}
|
|
2734
2834
|
};
|
|
2735
|
-
|
|
2736
|
-
let
|
|
2737
|
-
const
|
|
2835
|
+
be.moduleName = "peripherals";
|
|
2836
|
+
let ae = be;
|
|
2837
|
+
const k = class k extends j {
|
|
2738
2838
|
constructor() {
|
|
2739
2839
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
2740
2840
|
}
|
|
@@ -2754,13 +2854,13 @@ const $ = class $ extends Z {
|
|
|
2754
2854
|
Reflect.apply(t[1], t[2], t[3]);
|
|
2755
2855
|
break;
|
|
2756
2856
|
case 1:
|
|
2757
|
-
const i = t[1],
|
|
2857
|
+
const i = t[1], s = t[2];
|
|
2758
2858
|
e.removeEventListener(i.type, e._readium_eventBlocker, !0);
|
|
2759
2859
|
const n = new Event(i.type, {
|
|
2760
2860
|
bubbles: i.bubbles,
|
|
2761
2861
|
cancelable: i.cancelable
|
|
2762
2862
|
});
|
|
2763
|
-
|
|
2863
|
+
s ? s.dispatchEvent(n) : e.dispatchEvent(n);
|
|
2764
2864
|
break;
|
|
2765
2865
|
}
|
|
2766
2866
|
}
|
|
@@ -2784,9 +2884,9 @@ const $ = class $ extends Z {
|
|
|
2784
2884
|
), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
|
|
2785
2885
|
value: {
|
|
2786
2886
|
name: "readium-ts-toolkit",
|
|
2787
|
-
version: "2.
|
|
2788
|
-
hasFeature: (
|
|
2789
|
-
switch (
|
|
2887
|
+
version: "2.2.0",
|
|
2888
|
+
hasFeature: (s, n = "") => {
|
|
2889
|
+
switch (s) {
|
|
2790
2890
|
case "dom-manipulation":
|
|
2791
2891
|
return !0;
|
|
2792
2892
|
case "layout-changes":
|
|
@@ -2807,18 +2907,18 @@ const $ = class $ extends Z {
|
|
|
2807
2907
|
}
|
|
2808
2908
|
},
|
|
2809
2909
|
writable: !1
|
|
2810
|
-
}), "getAnimations" in e.document && e.document.getAnimations().forEach((
|
|
2811
|
-
|
|
2812
|
-
}), t.register("activate",
|
|
2910
|
+
}), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {
|
|
2911
|
+
s.cancel(), this.allAnimations.add(s);
|
|
2912
|
+
}), t.register("activate", k.moduleName, (s, n) => {
|
|
2813
2913
|
this.allAnimations.forEach((o) => {
|
|
2814
2914
|
o.cancel(), o.play();
|
|
2815
2915
|
}), n(!0);
|
|
2816
|
-
}), t.register("unfocus",
|
|
2916
|
+
}), t.register("unfocus", k.moduleName, (s, n) => {
|
|
2817
2917
|
this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
2818
2918
|
});
|
|
2819
2919
|
const i = e.document.querySelectorAll("audio,video");
|
|
2820
|
-
for (let
|
|
2821
|
-
const n = i[
|
|
2920
|
+
for (let s = 0; s < i.length; s++) {
|
|
2921
|
+
const n = i[s];
|
|
2822
2922
|
n.addEventListener("play", this.onMediaPlayEvent, {
|
|
2823
2923
|
passive: !0
|
|
2824
2924
|
}), n.addEventListener("pause", this.onMediaPauseEvent, {
|
|
@@ -2831,46 +2931,46 @@ const $ = class $ extends Z {
|
|
|
2831
2931
|
return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;
|
|
2832
2932
|
}
|
|
2833
2933
|
};
|
|
2834
|
-
|
|
2835
|
-
let
|
|
2836
|
-
const
|
|
2934
|
+
k.moduleName = "setup";
|
|
2935
|
+
let J = k;
|
|
2936
|
+
const Fe = "readium-viewport", O = class O extends J {
|
|
2837
2937
|
onViewportWidthChanged(e) {
|
|
2838
2938
|
const t = e.target;
|
|
2839
|
-
|
|
2939
|
+
Z(t, "--RS__viewportWidth", `${t.innerWidth}px`);
|
|
2840
2940
|
}
|
|
2841
2941
|
mount(e, t) {
|
|
2842
2942
|
if (!super.mount(e, t)) return !1;
|
|
2843
2943
|
const i = e.document.createElement("meta");
|
|
2844
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
2944
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Fe), i.setAttribute(
|
|
2845
2945
|
"content",
|
|
2846
2946
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
2847
2947
|
), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
2848
2948
|
target: e
|
|
2849
|
-
}), t.register("get_properties",
|
|
2850
|
-
|
|
2851
|
-
}), t.register("update_properties",
|
|
2852
|
-
|
|
2853
|
-
}), t.register("set_property",
|
|
2854
|
-
const o =
|
|
2855
|
-
|
|
2856
|
-
}), t.register("remove_property",
|
|
2857
|
-
|
|
2858
|
-
}), t.register("activate",
|
|
2949
|
+
}), t.register("get_properties", O.moduleName, (s, n) => {
|
|
2950
|
+
Ge(e), n(!0);
|
|
2951
|
+
}), t.register("update_properties", O.moduleName, (s, n) => {
|
|
2952
|
+
s["--RS__viewportWidth"] = `${e.innerWidth}px`, vt(e, s), n(!0);
|
|
2953
|
+
}), t.register("set_property", O.moduleName, (s, n) => {
|
|
2954
|
+
const o = s;
|
|
2955
|
+
Z(e, o[0], o[1]), n(!0);
|
|
2956
|
+
}), t.register("remove_property", O.moduleName, (s, n) => {
|
|
2957
|
+
ye(e, s), n(!0);
|
|
2958
|
+
}), t.register("activate", O.moduleName, (s, n) => {
|
|
2859
2959
|
this.unblock(e), n(!0);
|
|
2860
2960
|
}), t.log("ReflowableSetup Mounted"), !0;
|
|
2861
2961
|
}
|
|
2862
2962
|
unmount(e, t) {
|
|
2863
|
-
return t.unregisterAll(
|
|
2963
|
+
return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${Fe}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
|
|
2864
2964
|
}
|
|
2865
2965
|
};
|
|
2866
|
-
|
|
2867
|
-
let
|
|
2868
|
-
const
|
|
2966
|
+
O.moduleName = "reflowable_setup";
|
|
2967
|
+
let le = O;
|
|
2968
|
+
const Ue = "readium-fixed-style", A = class A extends J {
|
|
2869
2969
|
mount(e, t) {
|
|
2870
2970
|
if (!super.mount(e, t)) return !1;
|
|
2871
|
-
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2971
|
+
e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2872
2972
|
const i = e.document.createElement("style");
|
|
2873
|
-
return i.id =
|
|
2973
|
+
return i.id = Ue, i.dataset.readium = "true", i.textContent = `
|
|
2874
2974
|
html, body {
|
|
2875
2975
|
text-size-adjust: none;
|
|
2876
2976
|
-ms-text-size-adjust: none;
|
|
@@ -2882,13 +2982,13 @@ const Re = "readium-fixed-style", P = class P extends K {
|
|
|
2882
2982
|
min-height: 100%;
|
|
2883
2983
|
|
|
2884
2984
|
/*cursor: var() TODO*/
|
|
2885
|
-
}`, e.document.head.appendChild(i), t.register("set_property",
|
|
2886
|
-
const o =
|
|
2887
|
-
|
|
2888
|
-
}), t.register("remove_property",
|
|
2889
|
-
|
|
2890
|
-
}), t.register("first_visible_locator",
|
|
2891
|
-
|
|
2985
|
+
}`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (s, n) => {
|
|
2986
|
+
const o = s;
|
|
2987
|
+
Z(e, o[0], o[1]), n(!0);
|
|
2988
|
+
}), t.register("remove_property", A.moduleName, (s, n) => {
|
|
2989
|
+
ye(e, s), n(!0);
|
|
2990
|
+
}), t.register("first_visible_locator", A.moduleName, (s, n) => n(!1)), t.register("unfocus", A.moduleName, (s, n) => {
|
|
2991
|
+
v(e), n(!0);
|
|
2892
2992
|
}), t.register([
|
|
2893
2993
|
"focus",
|
|
2894
2994
|
"go_next",
|
|
@@ -2898,55 +2998,86 @@ const Re = "readium-fixed-style", P = class P extends K {
|
|
|
2898
2998
|
"go_start",
|
|
2899
2999
|
"go_text",
|
|
2900
3000
|
"go_progression"
|
|
2901
|
-
],
|
|
3001
|
+
], A.moduleName, (s, n) => n(!0)), t.register("activate", A.moduleName, (s, n) => {
|
|
2902
3002
|
this.unblock(e), n(!0);
|
|
2903
3003
|
}), t.log("FixedSetup Mounted"), !0;
|
|
2904
3004
|
}
|
|
2905
3005
|
unmount(e, t) {
|
|
2906
|
-
return t.unregisterAll(
|
|
3006
|
+
return t.unregisterAll(A.moduleName), e.document.getElementById(Ue)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
|
|
2907
3007
|
}
|
|
2908
3008
|
};
|
|
2909
|
-
|
|
2910
|
-
let
|
|
2911
|
-
const
|
|
3009
|
+
A.moduleName = "fixed_setup";
|
|
3010
|
+
let he = A;
|
|
3011
|
+
const Q = class Q extends j {
|
|
3012
|
+
wndOnErr(e) {
|
|
3013
|
+
this.comms?.send("error", {
|
|
3014
|
+
message: e.message,
|
|
3015
|
+
filename: e.filename,
|
|
3016
|
+
lineno: e.lineno,
|
|
3017
|
+
colno: e.colno
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
mount(e, t) {
|
|
3021
|
+
return this.comms = t, e.addEventListener(
|
|
3022
|
+
"error",
|
|
3023
|
+
this.wndOnErr,
|
|
3024
|
+
!1
|
|
3025
|
+
), t.register("activate", Q.moduleName, (i, s) => {
|
|
3026
|
+
s(!0);
|
|
3027
|
+
}), t.log("WebPubSetup Mounted"), !0;
|
|
3028
|
+
}
|
|
3029
|
+
unmount(e, t) {
|
|
3030
|
+
return e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
Q.moduleName = "webpub_setup";
|
|
3034
|
+
let ce = Q;
|
|
3035
|
+
const Rt = [
|
|
2912
3036
|
"fixed_setup",
|
|
2913
3037
|
"decorator",
|
|
2914
3038
|
"peripherals"
|
|
2915
|
-
],
|
|
3039
|
+
], zt = [
|
|
2916
3040
|
"reflowable_setup",
|
|
2917
3041
|
"decorator",
|
|
2918
3042
|
"peripherals",
|
|
2919
3043
|
"column_snapper",
|
|
2920
3044
|
"scroll_snapper"
|
|
2921
|
-
],
|
|
3045
|
+
], Dt = [
|
|
3046
|
+
"webpub_setup",
|
|
3047
|
+
"webpub_snapper",
|
|
3048
|
+
"decorator",
|
|
3049
|
+
"peripherals"
|
|
3050
|
+
], Be = new Map([
|
|
2922
3051
|
// All modules go here
|
|
2923
|
-
|
|
2924
|
-
|
|
3052
|
+
he,
|
|
3053
|
+
le,
|
|
3054
|
+
ce,
|
|
3055
|
+
oe,
|
|
3056
|
+
ae,
|
|
2925
3057
|
se,
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
class Lt {
|
|
3058
|
+
re,
|
|
3059
|
+
ne
|
|
3060
|
+
].map((r) => [r.moduleName, r]));
|
|
3061
|
+
class Wt {
|
|
2931
3062
|
/**
|
|
2932
3063
|
* @param wnd Window instance to operate on
|
|
2933
3064
|
* @param initialModules List of initial modules to load
|
|
2934
3065
|
*/
|
|
2935
3066
|
constructor(e = window, t = []) {
|
|
2936
|
-
this.loadedModules = [], this.wnd = e, this.comms = new
|
|
3067
|
+
this.loadedModules = [], this.wnd = e, this.comms = new tt(e);
|
|
2937
3068
|
const i = [...new Set(t)];
|
|
2938
3069
|
if (i.length) {
|
|
2939
3070
|
if (typeof e > "u")
|
|
2940
3071
|
throw Error("Loader is not in a web browser");
|
|
2941
|
-
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((
|
|
2942
|
-
const n = this.loadModule(
|
|
3072
|
+
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
|
|
3073
|
+
const n = this.loadModule(s);
|
|
2943
3074
|
if (n)
|
|
2944
3075
|
return n.mount(this.wnd, this.comms), n;
|
|
2945
|
-
}).filter((
|
|
3076
|
+
}).filter((s) => s !== void 0);
|
|
2946
3077
|
}
|
|
2947
3078
|
}
|
|
2948
3079
|
loadModule(e) {
|
|
2949
|
-
const t =
|
|
3080
|
+
const t = Be.get(e);
|
|
2950
3081
|
return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
|
|
2951
3082
|
}
|
|
2952
3083
|
/**
|
|
@@ -2964,10 +3095,10 @@ class Lt {
|
|
|
2964
3095
|
* @returns Success
|
|
2965
3096
|
*/
|
|
2966
3097
|
removeModule(e) {
|
|
2967
|
-
const t =
|
|
3098
|
+
const t = Be.get(e);
|
|
2968
3099
|
if (t === void 0)
|
|
2969
3100
|
return this.comms.log(`Module "${e}" does not exist in the library`), !1;
|
|
2970
|
-
const i = this.loadedModules.findIndex((
|
|
3101
|
+
const i = this.loadedModules.findIndex((s) => s instanceof t);
|
|
2971
3102
|
return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
|
|
2972
3103
|
}
|
|
2973
3104
|
/**
|
|
@@ -2978,16 +3109,17 @@ class Lt {
|
|
|
2978
3109
|
}
|
|
2979
3110
|
}
|
|
2980
3111
|
export {
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
3112
|
+
U as COMMS_VERSION,
|
|
3113
|
+
tt as Comms,
|
|
3114
|
+
se as Decorator,
|
|
3115
|
+
Rt as FXLModules,
|
|
3116
|
+
wt as Layout,
|
|
3117
|
+
Wt as Loader,
|
|
3118
|
+
j as Module,
|
|
3119
|
+
Be as ModuleLibrary,
|
|
3120
|
+
ae as Peripherals,
|
|
3121
|
+
zt as ReflowableModules,
|
|
3122
|
+
Dt as WebPubModules,
|
|
3123
|
+
Tt as Width,
|
|
3124
|
+
et as mid
|
|
2993
3125
|
};
|