@readium/navigator-html-injectables 2.0.0-beta.6 → 2.0.0-beta.7
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 +1010 -1002
- package/dist/index.umd.cjs +8 -8
- package/package.json +1 -1
- package/src/comms/keys.ts +1 -0
- package/src/modules/snapper/ScrollSnapper.ts +57 -26
- package/types/src/comms/keys.d.ts +1 -1
- package/types/src/modules/snapper/ScrollSnapper.d.ts +5 -3
package/dist/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
3
|
-
constructor(
|
|
4
|
-
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd =
|
|
1
|
+
const nt = Math.pow(2, 32), ge = () => Math.round(Math.random() * nt).toString(36), ot = () => `${Math.round(performance.now())}-${ge()}-${ge()}`, k = 1;
|
|
2
|
+
class at {
|
|
3
|
+
constructor(e) {
|
|
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
|
}
|
|
6
|
-
receive(
|
|
7
|
-
if (
|
|
6
|
+
receive(e) {
|
|
7
|
+
if (e.source === null)
|
|
8
8
|
throw Error("Event source is null");
|
|
9
|
-
if (typeof
|
|
9
|
+
if (typeof e.data != "object")
|
|
10
10
|
return;
|
|
11
|
-
const
|
|
12
|
-
if (!(!("_readium" in
|
|
13
|
-
if (
|
|
11
|
+
const t = e.data;
|
|
12
|
+
if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
|
|
13
|
+
if (t.key === "_ping") {
|
|
14
14
|
if (!this.destination) {
|
|
15
|
-
if (this.destination =
|
|
16
|
-
|
|
15
|
+
if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== k) {
|
|
16
|
+
t._readium > k ? this.send("error", `received comms version ${t._readium} higher than ${k}`) : this.send("error", `received comms version ${t._readium} lower than ${k}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
20
20
|
}
|
|
21
21
|
return;
|
|
22
22
|
} else if (this.channelId) {
|
|
23
|
-
if (
|
|
23
|
+
if (t._channel !== this.channelId || e.origin !== this.origin)
|
|
24
24
|
return;
|
|
25
25
|
} else
|
|
26
26
|
return;
|
|
27
|
-
this.handle(
|
|
27
|
+
this.handle(t);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
handle(
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
|
|
30
|
+
handle(e) {
|
|
31
|
+
const t = this.registrar.get(e.key);
|
|
32
|
+
if (!t || t.length === 0) {
|
|
33
|
+
e.strict && this.send("_unhandled", e);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
this.send("_ack", s,
|
|
36
|
+
t.forEach((i) => i.cb(e.data, (s) => {
|
|
37
|
+
this.send("_ack", s, e.id);
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
register(
|
|
41
|
-
Array.isArray(
|
|
40
|
+
register(e, t, i) {
|
|
41
|
+
Array.isArray(e) || (e = [e]), e.forEach((s) => {
|
|
42
42
|
const n = this.registrar.get(s);
|
|
43
43
|
if (n && n.length >= 0) {
|
|
44
|
-
if (n.find((l) => l.module ===
|
|
45
|
-
throw new Error(`Trying to register another callback for combination of event ${s} and module ${
|
|
44
|
+
if (n.find((l) => l.module === t))
|
|
45
|
+
throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);
|
|
46
46
|
n.push({
|
|
47
47
|
cb: i,
|
|
48
|
-
module:
|
|
48
|
+
module: t
|
|
49
49
|
}), this.registrar.set(s, n);
|
|
50
50
|
} else
|
|
51
51
|
this.registrar.set(s, [{
|
|
52
52
|
cb: i,
|
|
53
|
-
module:
|
|
53
|
+
module: t
|
|
54
54
|
}]);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
unregister(
|
|
58
|
-
Array.isArray(
|
|
57
|
+
unregister(e, t) {
|
|
58
|
+
Array.isArray(e) || (e = [e]), e.forEach((i) => {
|
|
59
59
|
const s = this.registrar.get(i);
|
|
60
|
-
!s || s.length === 0 || s.splice(s.findIndex((n) => n.module ===
|
|
60
|
+
!s || s.length === 0 || s.splice(s.findIndex((n) => n.module === t), 1);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
unregisterAll(
|
|
64
|
-
this.registrar.forEach((
|
|
63
|
+
unregisterAll(e) {
|
|
64
|
+
this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((s) => s.module !== e)));
|
|
65
65
|
}
|
|
66
|
-
log(...
|
|
67
|
-
this.destination ? this.send("log",
|
|
66
|
+
log(...e) {
|
|
67
|
+
this.destination ? this.send("log", e) : this.preLog.push(e);
|
|
68
68
|
}
|
|
69
69
|
get ready() {
|
|
70
70
|
return !!this.destination;
|
|
@@ -72,16 +72,16 @@ class ae {
|
|
|
72
72
|
destroy() {
|
|
73
73
|
this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
|
|
74
74
|
}
|
|
75
|
-
send(
|
|
75
|
+
send(e, t, i = void 0, s = []) {
|
|
76
76
|
if (!this.destination)
|
|
77
77
|
throw Error("Attempted to send comms message before destination has been initialized");
|
|
78
78
|
const n = {
|
|
79
79
|
_readium: k,
|
|
80
80
|
_channel: this.channelId,
|
|
81
|
-
id: i ??
|
|
81
|
+
id: i ?? ot(),
|
|
82
82
|
// scrict,
|
|
83
|
-
key:
|
|
84
|
-
data:
|
|
83
|
+
key: e,
|
|
84
|
+
data: t
|
|
85
85
|
};
|
|
86
86
|
try {
|
|
87
87
|
this.destination.postMessage(n, {
|
|
@@ -95,44 +95,44 @@ class ae {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
class
|
|
98
|
+
class ie {
|
|
99
99
|
/**
|
|
100
100
|
* Creates a [Encryption].
|
|
101
101
|
*/
|
|
102
|
-
constructor(
|
|
103
|
-
this.algorithm =
|
|
102
|
+
constructor(e) {
|
|
103
|
+
this.algorithm = e.algorithm, this.compression = e.compression, this.originalLength = e.originalLength, this.profile = e.profile, this.scheme = e.scheme;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Parses a [Encryption] from its RWPM JSON representation.
|
|
107
107
|
*/
|
|
108
|
-
static deserialize(
|
|
109
|
-
if (
|
|
110
|
-
return new
|
|
111
|
-
algorithm:
|
|
112
|
-
compression:
|
|
113
|
-
originalLength:
|
|
114
|
-
profile:
|
|
115
|
-
scheme:
|
|
108
|
+
static deserialize(e) {
|
|
109
|
+
if (e && e.algorithm)
|
|
110
|
+
return new ie({
|
|
111
|
+
algorithm: e.algorithm,
|
|
112
|
+
compression: e.compression,
|
|
113
|
+
originalLength: e.originalLength,
|
|
114
|
+
profile: e.profile,
|
|
115
|
+
scheme: e.scheme
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Serializes a [Encryption] to its RWPM JSON representation.
|
|
120
120
|
*/
|
|
121
121
|
serialize() {
|
|
122
|
-
const
|
|
123
|
-
return this.compression !== void 0 && (
|
|
122
|
+
const e = { algorithm: this.algorithm };
|
|
123
|
+
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;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
127
|
-
constructor(
|
|
128
|
-
this.otherProperties =
|
|
126
|
+
class b {
|
|
127
|
+
constructor(e) {
|
|
128
|
+
this.otherProperties = e;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Creates a [Properties] from its RWPM JSON representation.
|
|
132
132
|
*/
|
|
133
|
-
static deserialize(
|
|
134
|
-
if (
|
|
135
|
-
return new
|
|
133
|
+
static deserialize(e) {
|
|
134
|
+
if (e)
|
|
135
|
+
return new b(e);
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -143,31 +143,31 @@ class E {
|
|
|
143
143
|
/**
|
|
144
144
|
* Makes a copy of this [Properties] after merging in the given additional other [properties].
|
|
145
145
|
*/
|
|
146
|
-
add(
|
|
147
|
-
const
|
|
148
|
-
for (const i in
|
|
149
|
-
|
|
150
|
-
return new
|
|
146
|
+
add(e) {
|
|
147
|
+
const t = Object.assign({}, this.otherProperties);
|
|
148
|
+
for (const i in e)
|
|
149
|
+
t[i] = e[i];
|
|
150
|
+
return new b(t);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
Object.defineProperty(
|
|
153
|
+
Object.defineProperty(b.prototype, "encryption", {
|
|
154
154
|
get: function() {
|
|
155
|
-
return
|
|
155
|
+
return ie.deserialize(this.otherProperties.encrypted);
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
b.prototype.getContains = function() {
|
|
159
159
|
return new Set(this.otherProperties.contains || []);
|
|
160
160
|
};
|
|
161
|
-
|
|
161
|
+
b.prototype.getLayout = function() {
|
|
162
162
|
return this.otherProperties.layout;
|
|
163
163
|
};
|
|
164
164
|
class a {
|
|
165
165
|
/** Creates a MediaType object. */
|
|
166
|
-
constructor(
|
|
167
|
-
let
|
|
166
|
+
constructor(e) {
|
|
167
|
+
let t, i, s = e.mediaType.replace(/\s/g, "").split(";");
|
|
168
168
|
const n = s[0].split("/");
|
|
169
169
|
if (n.length === 2) {
|
|
170
|
-
if (
|
|
170
|
+
if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
|
|
171
171
|
throw new Error("Invalid media type");
|
|
172
172
|
} else
|
|
173
173
|
throw new Error("Invalid media type");
|
|
@@ -186,19 +186,19 @@ class a {
|
|
|
186
186
|
const f = l[d];
|
|
187
187
|
h += `;${d}=${f}`;
|
|
188
188
|
}
|
|
189
|
-
const u = `${
|
|
190
|
-
this.string = u, this.type =
|
|
189
|
+
const u = `${t}/${i}${h}`, p = l.encoding;
|
|
190
|
+
this.string = u, this.type = t, this.subtype = i, this.parameters = l, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
|
|
191
191
|
}
|
|
192
|
-
static parse(
|
|
193
|
-
return new a(
|
|
192
|
+
static parse(e) {
|
|
193
|
+
return new a(e);
|
|
194
194
|
}
|
|
195
195
|
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
196
196
|
* Gives a hint on the underlying structure of this media type.
|
|
197
197
|
* See. https://tools.ietf.org/html/rfc6838#section-4.2.8
|
|
198
198
|
*/
|
|
199
199
|
get structuredSyntaxSuffix() {
|
|
200
|
-
const
|
|
201
|
-
return
|
|
200
|
+
const e = this.subtype.split("+");
|
|
201
|
+
return e.length > 1 ? `+${e[e.length - 1]}` : void 0;
|
|
202
202
|
}
|
|
203
203
|
/** Parameter values might or might not be case-sensitive, depending on the semantics of
|
|
204
204
|
* the parameter name.
|
|
@@ -219,14 +219,14 @@ class a {
|
|
|
219
219
|
* - Order of parameters is ignored.
|
|
220
220
|
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
221
221
|
*/
|
|
222
|
-
contains(
|
|
223
|
-
const
|
|
224
|
-
if (!((this.type === "*" || this.type ===
|
|
222
|
+
contains(e) {
|
|
223
|
+
const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;
|
|
224
|
+
if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
|
|
225
225
|
return !1;
|
|
226
226
|
const i = new Set(
|
|
227
227
|
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
228
228
|
), s = new Set(
|
|
229
|
-
Object.entries(
|
|
229
|
+
Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
|
|
230
230
|
);
|
|
231
231
|
for (const n of Array.from(i.values()))
|
|
232
232
|
if (!s.has(n))
|
|
@@ -238,22 +238,22 @@ class a {
|
|
|
238
238
|
* For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
|
|
239
239
|
* doesn't. This is basically like `contains`, but working in both direction.
|
|
240
240
|
*/
|
|
241
|
-
matches(
|
|
242
|
-
const
|
|
243
|
-
return this.contains(
|
|
241
|
+
matches(e) {
|
|
242
|
+
const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;
|
|
243
|
+
return this.contains(t) || t.contains(this);
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
246
|
* Returns whether this media type matches any of the [others] media types.
|
|
247
247
|
*/
|
|
248
|
-
matchesAny(...
|
|
249
|
-
for (const
|
|
250
|
-
if (this.matches(
|
|
248
|
+
matchesAny(...e) {
|
|
249
|
+
for (const t of e)
|
|
250
|
+
if (this.matches(t))
|
|
251
251
|
return !0;
|
|
252
252
|
return !1;
|
|
253
253
|
}
|
|
254
254
|
/** Checks the MediaType equals another one (comparing their string) */
|
|
255
|
-
equals(
|
|
256
|
-
return this.string ===
|
|
255
|
+
equals(e) {
|
|
256
|
+
return this.string === e.string;
|
|
257
257
|
}
|
|
258
258
|
/** Returns whether this media type is structured as a ZIP archive. */
|
|
259
259
|
get isZIP() {
|
|
@@ -616,41 +616,41 @@ class a {
|
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
class
|
|
620
|
-
constructor(
|
|
621
|
-
this.uri =
|
|
619
|
+
class ye {
|
|
620
|
+
constructor(e) {
|
|
621
|
+
this.uri = e, this.parameters = this.getParameters(e);
|
|
622
622
|
}
|
|
623
623
|
/**
|
|
624
624
|
* List of URI template parameter keys, if the [Link] is templated.
|
|
625
625
|
*/
|
|
626
|
-
getParameters(
|
|
627
|
-
const
|
|
626
|
+
getParameters(e) {
|
|
627
|
+
const t = /\{\??([^}]+)\}/g, i = e.match(t);
|
|
628
628
|
return i ? new Set(
|
|
629
|
-
i.join(",").replace(
|
|
629
|
+
i.join(",").replace(t, "$1").split(",").map((s) => s.trim())
|
|
630
630
|
) : /* @__PURE__ */ new Set();
|
|
631
631
|
}
|
|
632
632
|
/** Expands the URI by replacing the template variables by the given parameters.
|
|
633
633
|
* Any extra parameter is appended as query parameters.
|
|
634
634
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
635
635
|
*/
|
|
636
|
-
expand(
|
|
637
|
-
const
|
|
638
|
-
const o =
|
|
636
|
+
expand(e) {
|
|
637
|
+
const t = (s) => s.split(",").map((n) => {
|
|
638
|
+
const o = e[n];
|
|
639
639
|
return o ? encodeURIComponent(o) : "";
|
|
640
640
|
}).join(","), i = (s) => "?" + s.split(",").map((n) => {
|
|
641
|
-
const o = n.split("=")[0], l =
|
|
641
|
+
const o = n.split("=")[0], l = e[o];
|
|
642
642
|
return l ? `${o}=${encodeURIComponent(l)}` : "";
|
|
643
643
|
}).join("&");
|
|
644
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) :
|
|
644
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function lt(r) {
|
|
648
648
|
return r && r instanceof Array ? r : void 0;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
return r && typeof r == "string" ? [r] :
|
|
650
|
+
function We(r) {
|
|
651
|
+
return r && typeof r == "string" ? [r] : lt(r);
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function ve(r) {
|
|
654
654
|
return typeof r == "string" ? new Date(r) : void 0;
|
|
655
655
|
}
|
|
656
656
|
function j(r) {
|
|
@@ -659,35 +659,35 @@ function j(r) {
|
|
|
659
659
|
function C(r) {
|
|
660
660
|
return j(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
663
|
-
const
|
|
664
|
-
return r.forEach((
|
|
662
|
+
function ht(r) {
|
|
663
|
+
const e = new Array();
|
|
664
|
+
return r.forEach((t) => e.push(t)), e;
|
|
665
665
|
}
|
|
666
666
|
class x {
|
|
667
667
|
/**
|
|
668
668
|
* Creates a [Locations].
|
|
669
669
|
*/
|
|
670
|
-
constructor(
|
|
671
|
-
this.fragments =
|
|
670
|
+
constructor(e) {
|
|
671
|
+
this.fragments = e.fragments ? e.fragments : new Array(), this.progression = e.progression, this.totalProgression = e.totalProgression, this.position = e.position, this.otherLocations = e.otherLocations;
|
|
672
672
|
}
|
|
673
673
|
/**
|
|
674
674
|
* Parses a [Locations] from its RWPM JSON representation.
|
|
675
675
|
*/
|
|
676
|
-
static deserialize(
|
|
677
|
-
if (!
|
|
676
|
+
static deserialize(e) {
|
|
677
|
+
if (!e)
|
|
678
678
|
return;
|
|
679
|
-
const
|
|
679
|
+
const t = j(e.progression), i = j(e.totalProgression), s = j(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
680
680
|
"fragment",
|
|
681
681
|
"fragments",
|
|
682
682
|
"progression",
|
|
683
683
|
"totalProgression",
|
|
684
684
|
"position"
|
|
685
685
|
]);
|
|
686
|
-
return Object.entries(
|
|
686
|
+
return Object.entries(e).forEach(([l, c]) => {
|
|
687
687
|
o.has(l) || n.set(l, c);
|
|
688
688
|
}), new x({
|
|
689
|
-
fragments:
|
|
690
|
-
progression:
|
|
689
|
+
fragments: We(e.fragments || e.fragment),
|
|
690
|
+
progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
|
|
691
691
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
692
692
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
693
693
|
otherLocations: n.size === 0 ? void 0 : n
|
|
@@ -697,73 +697,73 @@ class x {
|
|
|
697
697
|
* Serializes a [Locations] to its RWPM JSON representation.
|
|
698
698
|
*/
|
|
699
699
|
serialize() {
|
|
700
|
-
const
|
|
701
|
-
return this.fragments && (
|
|
700
|
+
const e = {};
|
|
701
|
+
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;
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
class U {
|
|
705
705
|
/**
|
|
706
706
|
* Creates a [Text].
|
|
707
707
|
*/
|
|
708
|
-
constructor(
|
|
709
|
-
this.after =
|
|
708
|
+
constructor(e) {
|
|
709
|
+
this.after = e.after, this.before = e.before, this.highlight = e.highlight;
|
|
710
710
|
}
|
|
711
711
|
/**
|
|
712
712
|
* Parses a [Locations] from its RWPM JSON representation.
|
|
713
713
|
*/
|
|
714
|
-
static deserialize(
|
|
715
|
-
if (
|
|
714
|
+
static deserialize(e) {
|
|
715
|
+
if (e)
|
|
716
716
|
return new U({
|
|
717
|
-
after:
|
|
718
|
-
before:
|
|
719
|
-
highlight:
|
|
717
|
+
after: e.after,
|
|
718
|
+
before: e.before,
|
|
719
|
+
highlight: e.highlight
|
|
720
720
|
});
|
|
721
721
|
}
|
|
722
722
|
/**
|
|
723
723
|
* Serializes a [Locations] to its RWPM JSON representation.
|
|
724
724
|
*/
|
|
725
725
|
serialize() {
|
|
726
|
-
const
|
|
727
|
-
return this.after !== void 0 && (
|
|
726
|
+
const e = {};
|
|
727
|
+
return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
-
class
|
|
730
|
+
class D {
|
|
731
731
|
/**
|
|
732
732
|
* Creates a [Locator].
|
|
733
733
|
*/
|
|
734
|
-
constructor(
|
|
735
|
-
this.href =
|
|
734
|
+
constructor(e) {
|
|
735
|
+
this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new x({}), this.text = e.text;
|
|
736
736
|
}
|
|
737
737
|
/**
|
|
738
738
|
* Parses a [Link] from its RWPM JSON representation.
|
|
739
739
|
*/
|
|
740
|
-
static deserialize(
|
|
741
|
-
if (
|
|
742
|
-
return new
|
|
743
|
-
href:
|
|
744
|
-
type:
|
|
745
|
-
title:
|
|
746
|
-
locations: x.deserialize(
|
|
747
|
-
text: U.deserialize(
|
|
740
|
+
static deserialize(e) {
|
|
741
|
+
if (e && e.href && e.type)
|
|
742
|
+
return new D({
|
|
743
|
+
href: e.href,
|
|
744
|
+
type: e.type,
|
|
745
|
+
title: e.title,
|
|
746
|
+
locations: x.deserialize(e.locations),
|
|
747
|
+
text: U.deserialize(e.text)
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
751
|
* Serializes a [Link] to its RWPM JSON representation.
|
|
752
752
|
*/
|
|
753
753
|
serialize() {
|
|
754
|
-
const
|
|
755
|
-
return this.title !== void 0 && (
|
|
754
|
+
const e = { href: this.href, type: this.type };
|
|
755
|
+
return this.title !== void 0 && (e.title = this.title), this.locations && (e.locations = this.locations.serialize()), this.text && (e.text = this.text.serialize()), e;
|
|
756
756
|
}
|
|
757
757
|
/**
|
|
758
758
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
759
759
|
*/
|
|
760
|
-
copyWithLocations(
|
|
761
|
-
return new
|
|
760
|
+
copyWithLocations(e) {
|
|
761
|
+
return new D({
|
|
762
762
|
href: this.href,
|
|
763
763
|
type: this.type,
|
|
764
764
|
title: this.title,
|
|
765
765
|
text: this.text,
|
|
766
|
-
locations: new x({ ...this.locations, ...
|
|
766
|
+
locations: new x({ ...this.locations, ...e })
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
769
|
}
|
|
@@ -771,36 +771,36 @@ class B {
|
|
|
771
771
|
/**
|
|
772
772
|
* Creates a [Link].
|
|
773
773
|
*/
|
|
774
|
-
constructor(
|
|
775
|
-
this.href =
|
|
774
|
+
constructor(e) {
|
|
775
|
+
this.href = e.href, this.templated = e.templated, this.type = e.type, this.title = e.title, this.rels = e.rels, this.properties = e.properties, this.height = e.height, this.width = e.width, this.duration = e.duration, this.bitrate = e.bitrate, this.languages = e.languages, this.alternates = e.alternates, this.children = e.children;
|
|
776
776
|
}
|
|
777
777
|
/**
|
|
778
778
|
* Parses a [Link] from its RWPM JSON representation.
|
|
779
779
|
*/
|
|
780
|
-
static deserialize(
|
|
781
|
-
if (!(!
|
|
780
|
+
static deserialize(e) {
|
|
781
|
+
if (!(!e || typeof e.href != "string"))
|
|
782
782
|
return new B({
|
|
783
|
-
href:
|
|
784
|
-
templated:
|
|
785
|
-
type:
|
|
786
|
-
title:
|
|
787
|
-
rels:
|
|
788
|
-
properties:
|
|
789
|
-
height: C(
|
|
790
|
-
width: C(
|
|
791
|
-
duration: C(
|
|
792
|
-
bitrate: C(
|
|
793
|
-
languages:
|
|
794
|
-
alternates: V.deserialize(
|
|
795
|
-
children: V.deserialize(
|
|
783
|
+
href: e.href,
|
|
784
|
+
templated: e.templated,
|
|
785
|
+
type: e.type,
|
|
786
|
+
title: e.title,
|
|
787
|
+
rels: e.rel ? e.rel instanceof Array ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
|
|
788
|
+
properties: b.deserialize(e.properties),
|
|
789
|
+
height: C(e.height),
|
|
790
|
+
width: C(e.width),
|
|
791
|
+
duration: C(e.duration),
|
|
792
|
+
bitrate: C(e.bitrate),
|
|
793
|
+
languages: We(e.language),
|
|
794
|
+
alternates: V.deserialize(e.alternate),
|
|
795
|
+
children: V.deserialize(e.children)
|
|
796
796
|
});
|
|
797
797
|
}
|
|
798
798
|
/**
|
|
799
799
|
* Serializes a [Link] to its RWPM JSON representation.
|
|
800
800
|
*/
|
|
801
801
|
serialize() {
|
|
802
|
-
const
|
|
803
|
-
return this.templated !== void 0 && (
|
|
802
|
+
const e = { href: this.href };
|
|
803
|
+
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 = ht(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.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;
|
|
804
804
|
}
|
|
805
805
|
/** MediaType of the linked resource. */
|
|
806
806
|
get mediaType() {
|
|
@@ -809,45 +809,45 @@ class B {
|
|
|
809
809
|
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
810
810
|
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
811
811
|
*/
|
|
812
|
-
toURL(
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
812
|
+
toURL(e) {
|
|
813
|
+
const t = this.href.replace(/^(\/)/, "");
|
|
814
|
+
if (t.length === 0)
|
|
815
815
|
return;
|
|
816
|
-
let i =
|
|
817
|
-
return i.startsWith("/") && (i = "file://" + i), new URL(
|
|
816
|
+
let i = e || "/";
|
|
817
|
+
return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
|
|
818
818
|
}
|
|
819
819
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
820
820
|
get templateParameters() {
|
|
821
|
-
return this.templated ? new
|
|
821
|
+
return this.templated ? new ye(this.href).parameters : /* @__PURE__ */ new Set();
|
|
822
822
|
}
|
|
823
823
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
824
824
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
825
825
|
*/
|
|
826
|
-
expandTemplate(
|
|
826
|
+
expandTemplate(e) {
|
|
827
827
|
return new B({
|
|
828
|
-
href: new
|
|
828
|
+
href: new ye(this.href).expand(e),
|
|
829
829
|
templated: !1
|
|
830
830
|
});
|
|
831
831
|
}
|
|
832
832
|
/**
|
|
833
833
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
834
834
|
*/
|
|
835
|
-
addProperties(
|
|
836
|
-
var
|
|
835
|
+
addProperties(e) {
|
|
836
|
+
var t;
|
|
837
837
|
const i = B.deserialize(this.serialize());
|
|
838
|
-
return i.properties = i.properties ? (
|
|
838
|
+
return i.properties = i.properties ? (t = i.properties) == null ? void 0 : t.add(e) : new b(e), i;
|
|
839
839
|
}
|
|
840
840
|
/**
|
|
841
841
|
* Creates a [Locator] from a reading order [Link].
|
|
842
842
|
*/
|
|
843
843
|
get locator() {
|
|
844
|
-
let
|
|
845
|
-
return new
|
|
846
|
-
href:
|
|
844
|
+
let e = this.href.split("#");
|
|
845
|
+
return new D({
|
|
846
|
+
href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
|
|
847
847
|
type: this.type ?? "",
|
|
848
848
|
title: this.title,
|
|
849
849
|
locations: new x({
|
|
850
|
-
fragments:
|
|
850
|
+
fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
|
|
851
851
|
})
|
|
852
852
|
});
|
|
853
853
|
}
|
|
@@ -856,116 +856,116 @@ class V {
|
|
|
856
856
|
/**
|
|
857
857
|
* Creates a [Links].
|
|
858
858
|
*/
|
|
859
|
-
constructor(
|
|
860
|
-
this.items =
|
|
859
|
+
constructor(e) {
|
|
860
|
+
this.items = e;
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
863
863
|
* Creates a list of [Link] from its RWPM JSON representation.
|
|
864
864
|
*/
|
|
865
|
-
static deserialize(
|
|
866
|
-
if (
|
|
865
|
+
static deserialize(e) {
|
|
866
|
+
if (e && e instanceof Array)
|
|
867
867
|
return new V(
|
|
868
|
-
|
|
868
|
+
e.map((t) => B.deserialize(t)).filter((t) => t !== void 0)
|
|
869
869
|
);
|
|
870
870
|
}
|
|
871
871
|
/**
|
|
872
872
|
* Serializes an array of [Link] to its RWPM JSON representation.
|
|
873
873
|
*/
|
|
874
874
|
serialize() {
|
|
875
|
-
return this.items.map((
|
|
875
|
+
return this.items.map((e) => e.serialize());
|
|
876
876
|
}
|
|
877
877
|
/** Finds the first link with the given relation. */
|
|
878
|
-
findWithRel(
|
|
879
|
-
const
|
|
880
|
-
return this.items.find(
|
|
878
|
+
findWithRel(e) {
|
|
879
|
+
const t = (i) => i.rels && i.rels.has(e);
|
|
880
|
+
return this.items.find(t);
|
|
881
881
|
}
|
|
882
882
|
/** Finds all the links with the given relation. */
|
|
883
|
-
filterByRel(
|
|
884
|
-
const
|
|
885
|
-
return this.items.filter(
|
|
883
|
+
filterByRel(e) {
|
|
884
|
+
const t = (i) => i.rels && i.rels.has(e);
|
|
885
|
+
return this.items.filter(t);
|
|
886
886
|
}
|
|
887
887
|
/** Finds the first link matching the given HREF. */
|
|
888
|
-
findWithHref(
|
|
889
|
-
const
|
|
890
|
-
return this.items.find(
|
|
888
|
+
findWithHref(e) {
|
|
889
|
+
const t = (i) => i.href === e;
|
|
890
|
+
return this.items.find(t);
|
|
891
891
|
}
|
|
892
892
|
/** Finds the index of the first link matching the given HREF. */
|
|
893
|
-
findIndexWithHref(
|
|
894
|
-
const
|
|
895
|
-
return this.items.findIndex(
|
|
893
|
+
findIndexWithHref(e) {
|
|
894
|
+
const t = (i) => i.href === e;
|
|
895
|
+
return this.items.findIndex(t);
|
|
896
896
|
}
|
|
897
897
|
/** Finds the first link matching the given media type. */
|
|
898
|
-
findWithMediaType(
|
|
899
|
-
const
|
|
900
|
-
return this.items.find(
|
|
898
|
+
findWithMediaType(e) {
|
|
899
|
+
const t = (i) => i.mediaType.matches(e);
|
|
900
|
+
return this.items.find(t);
|
|
901
901
|
}
|
|
902
902
|
/** Finds all the links matching the given media type. */
|
|
903
|
-
filterByMediaType(
|
|
904
|
-
const
|
|
905
|
-
return this.items.filter(
|
|
903
|
+
filterByMediaType(e) {
|
|
904
|
+
const t = (i) => i.mediaType.matches(e);
|
|
905
|
+
return this.items.filter(t);
|
|
906
906
|
}
|
|
907
907
|
/** Finds all the links matching any of the given media types. */
|
|
908
|
-
filterByMediaTypes(
|
|
909
|
-
const
|
|
910
|
-
for (const s of
|
|
908
|
+
filterByMediaTypes(e) {
|
|
909
|
+
const t = (i) => {
|
|
910
|
+
for (const s of e)
|
|
911
911
|
if (i.mediaType.matches(s))
|
|
912
912
|
return !0;
|
|
913
913
|
return !1;
|
|
914
914
|
};
|
|
915
|
-
return this.items.filter(
|
|
915
|
+
return this.items.filter(t);
|
|
916
916
|
}
|
|
917
917
|
/** Returns whether all the resources in the collection are audio clips. */
|
|
918
918
|
everyIsAudio() {
|
|
919
|
-
const
|
|
920
|
-
return this.items.length > 0 && this.items.every(
|
|
919
|
+
const e = (t) => t.mediaType.isAudio;
|
|
920
|
+
return this.items.length > 0 && this.items.every(e);
|
|
921
921
|
}
|
|
922
922
|
/** Returns whether all the resources in the collection are bitmaps. */
|
|
923
923
|
everyIsBitmap() {
|
|
924
|
-
const
|
|
925
|
-
return this.items.length > 0 && this.items.every(
|
|
924
|
+
const e = (t) => t.mediaType.isBitmap;
|
|
925
|
+
return this.items.length > 0 && this.items.every(e);
|
|
926
926
|
}
|
|
927
927
|
/** Returns whether all the resources in the collection are HTML documents. */
|
|
928
928
|
everyIsHTML() {
|
|
929
|
-
const
|
|
930
|
-
return this.items.length > 0 && this.items.every(
|
|
929
|
+
const e = (t) => t.mediaType.isHTML;
|
|
930
|
+
return this.items.length > 0 && this.items.every(e);
|
|
931
931
|
}
|
|
932
932
|
/** Returns whether all the resources in the collection are video clips. */
|
|
933
933
|
everyIsVideo() {
|
|
934
|
-
const
|
|
935
|
-
return this.items.length > 0 && this.items.every(
|
|
934
|
+
const e = (t) => t.mediaType.isVideo;
|
|
935
|
+
return this.items.length > 0 && this.items.every(e);
|
|
936
936
|
}
|
|
937
937
|
/** Returns whether all the resources in the collection are matching any of the given media types. */
|
|
938
|
-
everyMatchesMediaType(
|
|
939
|
-
return Array.isArray(
|
|
940
|
-
for (const i of
|
|
941
|
-
return
|
|
938
|
+
everyMatchesMediaType(e) {
|
|
939
|
+
return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {
|
|
940
|
+
for (const i of e)
|
|
941
|
+
return t.mediaType.matches(i);
|
|
942
942
|
return !1;
|
|
943
|
-
}) : this.items.length > 0 && this.items.every((
|
|
943
|
+
}) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));
|
|
944
944
|
}
|
|
945
945
|
filterLinksHasType() {
|
|
946
|
-
return this.items.filter((
|
|
946
|
+
return this.items.filter((e) => e.type);
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
class
|
|
949
|
+
class q {
|
|
950
950
|
/**
|
|
951
951
|
* Creates a [DomRange].
|
|
952
952
|
*/
|
|
953
|
-
constructor(
|
|
954
|
-
this.cssSelector =
|
|
953
|
+
constructor(e) {
|
|
954
|
+
this.cssSelector = e.cssSelector, this.textNodeIndex = e.textNodeIndex, this.charOffset = e.charOffset;
|
|
955
955
|
}
|
|
956
956
|
/**
|
|
957
957
|
* Parses a [DomRangePoint] from its RWPM JSON representation.
|
|
958
958
|
*/
|
|
959
|
-
static deserialize(
|
|
960
|
-
if (!(
|
|
959
|
+
static deserialize(e) {
|
|
960
|
+
if (!(e && e.cssSelector))
|
|
961
961
|
return;
|
|
962
|
-
let
|
|
963
|
-
if (
|
|
962
|
+
let t = C(e.textNodeIndex);
|
|
963
|
+
if (t === void 0)
|
|
964
964
|
return;
|
|
965
|
-
let i = C(
|
|
966
|
-
return i === void 0 && (i = C(
|
|
967
|
-
cssSelector:
|
|
968
|
-
textNodeIndex:
|
|
965
|
+
let i = C(e.charOffset);
|
|
966
|
+
return i === void 0 && (i = C(e.offset)), new q({
|
|
967
|
+
cssSelector: e.cssSelector,
|
|
968
|
+
textNodeIndex: t,
|
|
969
969
|
charOffset: i
|
|
970
970
|
});
|
|
971
971
|
}
|
|
@@ -973,39 +973,39 @@ class _ {
|
|
|
973
973
|
* Serializes a [DomRangePoint] to its RWPM JSON representation.
|
|
974
974
|
*/
|
|
975
975
|
serialize() {
|
|
976
|
-
const
|
|
976
|
+
const e = {
|
|
977
977
|
cssSelector: this.cssSelector,
|
|
978
978
|
textNodeIndex: this.textNodeIndex
|
|
979
979
|
};
|
|
980
|
-
return this.charOffset !== void 0 && (
|
|
980
|
+
return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
class
|
|
983
|
+
class re {
|
|
984
984
|
/**
|
|
985
985
|
* Creates a [DomRange].
|
|
986
986
|
*/
|
|
987
|
-
constructor(
|
|
988
|
-
this.start =
|
|
987
|
+
constructor(e) {
|
|
988
|
+
this.start = e.start, this.end = e.end;
|
|
989
989
|
}
|
|
990
990
|
/**
|
|
991
991
|
* Parses a [DomRange] from its RWPM JSON representation.
|
|
992
992
|
*/
|
|
993
|
-
static deserialize(
|
|
994
|
-
if (!
|
|
993
|
+
static deserialize(e) {
|
|
994
|
+
if (!e)
|
|
995
995
|
return;
|
|
996
|
-
let
|
|
997
|
-
if (
|
|
998
|
-
return new
|
|
999
|
-
start:
|
|
1000
|
-
end:
|
|
996
|
+
let t = q.deserialize(e.start);
|
|
997
|
+
if (t)
|
|
998
|
+
return new re({
|
|
999
|
+
start: t,
|
|
1000
|
+
end: q.deserialize(e.end)
|
|
1001
1001
|
});
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
1004
1004
|
* Serializes a [DomRange] to its RWPM JSON representation.
|
|
1005
1005
|
*/
|
|
1006
1006
|
serialize() {
|
|
1007
|
-
const
|
|
1008
|
-
return this.end && (
|
|
1007
|
+
const e = { start: this.start.serialize() };
|
|
1008
|
+
return this.end && (e.end = this.end.serialize()), e;
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
1011
|
x.prototype.getCssSelector = function() {
|
|
@@ -1018,7 +1018,7 @@ x.prototype.getPartialCfi = function() {
|
|
|
1018
1018
|
};
|
|
1019
1019
|
x.prototype.getDomRange = function() {
|
|
1020
1020
|
var r;
|
|
1021
|
-
return
|
|
1021
|
+
return re.deserialize((r = this.otherLocations) == null ? void 0 : r.get("domRange"));
|
|
1022
1022
|
};
|
|
1023
1023
|
x.prototype.fragmentParameters = function() {
|
|
1024
1024
|
return new Map(
|
|
@@ -1031,10 +1031,10 @@ x.prototype.fragmentParameters = function() {
|
|
|
1031
1031
|
x.prototype.htmlId = function() {
|
|
1032
1032
|
if (!this.fragments.length)
|
|
1033
1033
|
return;
|
|
1034
|
-
let r = this.fragments.find((
|
|
1034
|
+
let r = this.fragments.find((e) => e.length && !e.includes("="));
|
|
1035
1035
|
if (!r) {
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1036
|
+
const e = this.fragmentParameters();
|
|
1037
|
+
e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));
|
|
1038
1038
|
}
|
|
1039
1039
|
return r != null && r.startsWith("#") ? r.slice(1) : r;
|
|
1040
1040
|
};
|
|
@@ -1052,27 +1052,27 @@ x.prototype.space = function() {
|
|
|
1052
1052
|
const r = this.fragmentParameters();
|
|
1053
1053
|
if (!r.has("xywh"))
|
|
1054
1054
|
return;
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
return
|
|
1055
|
+
const e = r.get("xywh").split(",").map((t) => parseInt(t));
|
|
1056
|
+
if (e.length === 4 && !e.some(isNaN))
|
|
1057
|
+
return e;
|
|
1058
1058
|
};
|
|
1059
|
-
class
|
|
1059
|
+
class se {
|
|
1060
1060
|
/** Creates a [Price]. */
|
|
1061
|
-
constructor(
|
|
1062
|
-
this.currency =
|
|
1061
|
+
constructor(e) {
|
|
1062
|
+
this.currency = e.currency, this.value = e.value;
|
|
1063
1063
|
}
|
|
1064
1064
|
/**
|
|
1065
1065
|
* Parses a [Price] from its RWPM JSON representation.
|
|
1066
1066
|
*/
|
|
1067
|
-
static deserialize(
|
|
1068
|
-
if (!
|
|
1067
|
+
static deserialize(e) {
|
|
1068
|
+
if (!e)
|
|
1069
1069
|
return;
|
|
1070
|
-
let
|
|
1071
|
-
if (!(
|
|
1070
|
+
let t = e.currency;
|
|
1071
|
+
if (!(t && typeof t == "string" && t.length > 0))
|
|
1072
1072
|
return;
|
|
1073
|
-
let i = C(
|
|
1073
|
+
let i = C(e.value);
|
|
1074
1074
|
if (i !== void 0)
|
|
1075
|
-
return new
|
|
1075
|
+
return new se({ currency: t, value: i });
|
|
1076
1076
|
}
|
|
1077
1077
|
/**
|
|
1078
1078
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1083,140 +1083,140 @@ class st {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
class $ {
|
|
1085
1085
|
/** Creates a [Acquisition]. */
|
|
1086
|
-
constructor(
|
|
1087
|
-
this.type =
|
|
1086
|
+
constructor(e) {
|
|
1087
|
+
this.type = e.type, this.children = e.children;
|
|
1088
1088
|
}
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Parses a [Acquisition] from its RWPM JSON representation.
|
|
1091
1091
|
*/
|
|
1092
|
-
static deserialize(
|
|
1093
|
-
if (
|
|
1092
|
+
static deserialize(e) {
|
|
1093
|
+
if (e && e.type)
|
|
1094
1094
|
return new $({
|
|
1095
|
-
type:
|
|
1096
|
-
children: $.deserializeArray(
|
|
1095
|
+
type: e.type,
|
|
1096
|
+
children: $.deserializeArray(e.children)
|
|
1097
1097
|
});
|
|
1098
1098
|
}
|
|
1099
|
-
static deserializeArray(
|
|
1100
|
-
if (
|
|
1101
|
-
return
|
|
1099
|
+
static deserializeArray(e) {
|
|
1100
|
+
if (e instanceof Array)
|
|
1101
|
+
return e.map((t) => $.deserialize(t)).filter((t) => t !== void 0);
|
|
1102
1102
|
}
|
|
1103
1103
|
/**
|
|
1104
1104
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
1105
1105
|
*/
|
|
1106
1106
|
serialize() {
|
|
1107
|
-
const
|
|
1108
|
-
return this.children && (
|
|
1107
|
+
const e = { type: this.type };
|
|
1108
|
+
return this.children && (e.children = this.children.map((t) => t.serialize())), e;
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
class
|
|
1111
|
+
class ne {
|
|
1112
1112
|
/** Creates a [Price]. */
|
|
1113
|
-
constructor(
|
|
1114
|
-
this.total =
|
|
1113
|
+
constructor(e) {
|
|
1114
|
+
this.total = e.total, this.position = e.position;
|
|
1115
1115
|
}
|
|
1116
1116
|
/**
|
|
1117
1117
|
* Parses a [Holds] from its RWPM JSON representation.
|
|
1118
1118
|
*/
|
|
1119
|
-
static deserialize(
|
|
1120
|
-
if (
|
|
1121
|
-
return new
|
|
1122
|
-
total: C(
|
|
1123
|
-
position: C(
|
|
1119
|
+
static deserialize(e) {
|
|
1120
|
+
if (e)
|
|
1121
|
+
return new ne({
|
|
1122
|
+
total: C(e.total),
|
|
1123
|
+
position: C(e.position)
|
|
1124
1124
|
});
|
|
1125
1125
|
}
|
|
1126
1126
|
/**
|
|
1127
1127
|
* Serializes a [Holds] to its RWPM JSON representation.
|
|
1128
1128
|
*/
|
|
1129
1129
|
serialize() {
|
|
1130
|
-
const
|
|
1131
|
-
return this.total !== void 0 && (
|
|
1130
|
+
const e = {};
|
|
1131
|
+
return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
class
|
|
1134
|
+
class oe {
|
|
1135
1135
|
/** Creates a [Copies]. */
|
|
1136
|
-
constructor(
|
|
1137
|
-
this.total =
|
|
1136
|
+
constructor(e) {
|
|
1137
|
+
this.total = e.total, this.available = e.available;
|
|
1138
1138
|
}
|
|
1139
1139
|
/**
|
|
1140
1140
|
* Parses a [Copies] from its RWPM JSON representation.
|
|
1141
1141
|
*/
|
|
1142
|
-
static deserialize(
|
|
1143
|
-
if (
|
|
1144
|
-
return new
|
|
1145
|
-
total: C(
|
|
1146
|
-
available: C(
|
|
1142
|
+
static deserialize(e) {
|
|
1143
|
+
if (e)
|
|
1144
|
+
return new oe({
|
|
1145
|
+
total: C(e.total),
|
|
1146
|
+
available: C(e.available)
|
|
1147
1147
|
});
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
1150
|
* Serializes a [Copies] to its RWPM JSON representation.
|
|
1151
1151
|
*/
|
|
1152
1152
|
serialize() {
|
|
1153
|
-
const
|
|
1154
|
-
return this.total !== void 0 && (
|
|
1153
|
+
const e = {};
|
|
1154
|
+
return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
|
-
class
|
|
1157
|
+
class ae {
|
|
1158
1158
|
/** Creates a [Availability]. */
|
|
1159
|
-
constructor(
|
|
1160
|
-
this.state =
|
|
1159
|
+
constructor(e) {
|
|
1160
|
+
this.state = e.state, this.since = e.since, this.until = e.until;
|
|
1161
1161
|
}
|
|
1162
1162
|
/**
|
|
1163
1163
|
* Parses a [Availability] from its RWPM JSON representation.
|
|
1164
1164
|
*/
|
|
1165
|
-
static deserialize(
|
|
1166
|
-
if (
|
|
1167
|
-
return new
|
|
1168
|
-
state:
|
|
1169
|
-
since:
|
|
1170
|
-
until:
|
|
1165
|
+
static deserialize(e) {
|
|
1166
|
+
if (e && e.state)
|
|
1167
|
+
return new ae({
|
|
1168
|
+
state: e.state,
|
|
1169
|
+
since: ve(e.since),
|
|
1170
|
+
until: ve(e.until)
|
|
1171
1171
|
});
|
|
1172
1172
|
}
|
|
1173
1173
|
/**
|
|
1174
1174
|
* Serializes a [Availability] to its RWPM JSON representation.
|
|
1175
1175
|
*/
|
|
1176
1176
|
serialize() {
|
|
1177
|
-
const
|
|
1178
|
-
return this.since !== void 0 && (
|
|
1177
|
+
const e = { state: this.state };
|
|
1178
|
+
return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
|
-
|
|
1181
|
+
b.prototype.getNumberOfItems = function() {
|
|
1182
1182
|
return C(this.otherProperties.numberOfItems);
|
|
1183
1183
|
};
|
|
1184
|
-
|
|
1185
|
-
return
|
|
1184
|
+
b.prototype.getPrice = function() {
|
|
1185
|
+
return se.deserialize(this.otherProperties.price);
|
|
1186
1186
|
};
|
|
1187
|
-
|
|
1187
|
+
b.prototype.getIndirectAcquisitions = function() {
|
|
1188
1188
|
const r = this.otherProperties.indirectAcquisition;
|
|
1189
1189
|
if (r && r instanceof Array)
|
|
1190
|
-
return r.map((
|
|
1190
|
+
return r.map((e) => $.deserialize(e)).filter((e) => e !== void 0);
|
|
1191
1191
|
};
|
|
1192
|
-
|
|
1193
|
-
return
|
|
1192
|
+
b.prototype.getHolds = function() {
|
|
1193
|
+
return ne.deserialize(this.otherProperties.holds);
|
|
1194
1194
|
};
|
|
1195
|
-
|
|
1196
|
-
return
|
|
1195
|
+
b.prototype.getCopies = function() {
|
|
1196
|
+
return oe.deserialize(this.otherProperties.copies);
|
|
1197
1197
|
};
|
|
1198
|
-
|
|
1199
|
-
return
|
|
1198
|
+
b.prototype.getAvailability = function() {
|
|
1199
|
+
return ae.deserialize(this.otherProperties.availability);
|
|
1200
1200
|
};
|
|
1201
|
-
|
|
1201
|
+
b.prototype.getAuthenticate = function() {
|
|
1202
1202
|
return B.deserialize(this.otherProperties.authenticate);
|
|
1203
1203
|
};
|
|
1204
|
-
|
|
1204
|
+
b.prototype.getClipped = function() {
|
|
1205
1205
|
return this.otherProperties.clipped;
|
|
1206
1206
|
};
|
|
1207
|
-
|
|
1207
|
+
b.prototype.getFit = function() {
|
|
1208
1208
|
return this.otherProperties.fit;
|
|
1209
1209
|
};
|
|
1210
|
-
|
|
1210
|
+
b.prototype.getOrientation = function() {
|
|
1211
1211
|
return this.otherProperties.orientation;
|
|
1212
1212
|
};
|
|
1213
|
-
|
|
1213
|
+
b.prototype.getOverflow = function() {
|
|
1214
1214
|
return this.otherProperties.overflow;
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1216
|
+
b.prototype.getPage = function() {
|
|
1217
1217
|
return this.otherProperties.page || void 0;
|
|
1218
1218
|
};
|
|
1219
|
-
|
|
1219
|
+
b.prototype.getSpread = function() {
|
|
1220
1220
|
return this.otherProperties.spread || void 0;
|
|
1221
1221
|
};
|
|
1222
1222
|
var R;
|
|
@@ -1227,38 +1227,38 @@ var N;
|
|
|
1227
1227
|
(function(r) {
|
|
1228
1228
|
r.id = "id", r.class = "class", r.tag = "tag", r.attribute = "attribute", r.nthchild = "nthchild", r.nthoftype = "nthoftype";
|
|
1229
1229
|
})(N || (N = {}));
|
|
1230
|
-
const
|
|
1231
|
-
function
|
|
1232
|
-
console.warn(`${
|
|
1230
|
+
const ct = "CssSelectorGenerator";
|
|
1231
|
+
function be(r = "unknown problem", ...e) {
|
|
1232
|
+
console.warn(`${ct}: ${r}`, ...e);
|
|
1233
1233
|
}
|
|
1234
1234
|
N.id, N.class, N.tag, N.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
|
|
1235
|
-
function
|
|
1235
|
+
function ut(r) {
|
|
1236
1236
|
return r instanceof RegExp;
|
|
1237
1237
|
}
|
|
1238
|
-
function
|
|
1238
|
+
function dt(r) {
|
|
1239
1239
|
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1240
1240
|
}
|
|
1241
|
-
function
|
|
1242
|
-
const
|
|
1243
|
-
if (
|
|
1244
|
-
return (i) =>
|
|
1245
|
-
if (typeof
|
|
1241
|
+
function pt(r) {
|
|
1242
|
+
const e = r.map((t) => {
|
|
1243
|
+
if (ut(t))
|
|
1244
|
+
return (i) => t.test(i);
|
|
1245
|
+
if (typeof t == "function")
|
|
1246
1246
|
return (i) => {
|
|
1247
|
-
const s =
|
|
1248
|
-
return typeof s != "boolean" ? (
|
|
1247
|
+
const s = t(i);
|
|
1248
|
+
return typeof s != "boolean" ? (be("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
|
|
1249
1249
|
};
|
|
1250
|
-
if (typeof
|
|
1251
|
-
const i = new RegExp("^" +
|
|
1250
|
+
if (typeof t == "string") {
|
|
1251
|
+
const i = new RegExp("^" + dt(t) + "$");
|
|
1252
1252
|
return (s) => i.test(s);
|
|
1253
1253
|
}
|
|
1254
|
-
return
|
|
1254
|
+
return be("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
|
|
1255
1255
|
});
|
|
1256
|
-
return (
|
|
1256
|
+
return (t) => e.some((i) => i(t));
|
|
1257
1257
|
}
|
|
1258
|
-
const
|
|
1258
|
+
const ft = "", mt = " > ", gt = " ";
|
|
1259
1259
|
R.NONE + "", R.NONE, R.DESCENDANT + "", R.DESCENDANT, R.CHILD + "", R.CHILD;
|
|
1260
1260
|
N.nthoftype, N.tag, N.id, N.class, N.attribute, N.nthchild;
|
|
1261
|
-
|
|
1261
|
+
pt([
|
|
1262
1262
|
"class",
|
|
1263
1263
|
"id",
|
|
1264
1264
|
// Angular attributes
|
|
@@ -1266,15 +1266,15 @@ pe([
|
|
|
1266
1266
|
]);
|
|
1267
1267
|
class Y {
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1269
|
+
function Ee(r) {
|
|
1270
1270
|
return r.split("").reverse().join("");
|
|
1271
1271
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const i =
|
|
1274
|
-
return
|
|
1275
|
-
const n = Math.max(0, s.end -
|
|
1272
|
+
function yt(r, e, t) {
|
|
1273
|
+
const i = Ee(e);
|
|
1274
|
+
return t.map((s) => {
|
|
1275
|
+
const n = Math.max(0, s.end - e.length - s.errors), o = Ee(r.slice(n, s.end));
|
|
1276
1276
|
return {
|
|
1277
|
-
start:
|
|
1277
|
+
start: Fe(o, i, s.errors).reduce((c, h) => s.end - h.end < c ? s.end - h.end : c, s.end),
|
|
1278
1278
|
end: s.end,
|
|
1279
1279
|
errors: s.errors
|
|
1280
1280
|
};
|
|
@@ -1283,28 +1283,28 @@ function ye(r, t, e) {
|
|
|
1283
1283
|
function Z(r) {
|
|
1284
1284
|
return (r | -r) >> 31 & 1;
|
|
1285
1285
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let s = r.P[
|
|
1288
|
-
const o = i >>> 31, l = t
|
|
1286
|
+
function xe(r, e, t, i) {
|
|
1287
|
+
let s = r.P[t], n = r.M[t];
|
|
1288
|
+
const o = i >>> 31, l = e[t] | o, c = l | n, h = (l & s) + s ^ s | l;
|
|
1289
1289
|
let u = n | ~(h | s), p = s & h;
|
|
1290
|
-
const d = Z(u & r.lastRowMask[
|
|
1291
|
-
return u <<= 1, p <<= 1, p |= o, u |= Z(i) - o, s = p | ~(c | u), n = u & c, r.P[
|
|
1290
|
+
const d = Z(u & r.lastRowMask[t]) - Z(p & r.lastRowMask[t]);
|
|
1291
|
+
return u <<= 1, p <<= 1, p |= o, u |= Z(i) - o, s = p | ~(c | u), n = u & c, r.P[t] = s, r.M[t] = n, d;
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1294
|
-
if (
|
|
1293
|
+
function Fe(r, e, t) {
|
|
1294
|
+
if (e.length === 0)
|
|
1295
1295
|
return [];
|
|
1296
|
-
|
|
1297
|
-
const i = [], s = 32, n = Math.ceil(
|
|
1296
|
+
t = Math.min(t, e.length);
|
|
1297
|
+
const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {
|
|
1298
1298
|
P: new Uint32Array(n + 1),
|
|
1299
1299
|
M: new Uint32Array(n + 1),
|
|
1300
1300
|
lastRowMask: new Uint32Array(n + 1)
|
|
1301
1301
|
};
|
|
1302
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (
|
|
1302
|
+
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
|
|
1303
1303
|
const l = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
|
|
1304
1304
|
for (let d = 0; d < 256; d++)
|
|
1305
1305
|
h.push(l);
|
|
1306
|
-
for (let d = 0; d <
|
|
1307
|
-
const f =
|
|
1306
|
+
for (let d = 0; d < e.length; d += 1) {
|
|
1307
|
+
const f = e.charCodeAt(d);
|
|
1308
1308
|
if (c.has(f))
|
|
1309
1309
|
continue;
|
|
1310
1310
|
const g = new Uint32Array(n + 1);
|
|
@@ -1313,17 +1313,17 @@ function Ft(r, t, e) {
|
|
|
1313
1313
|
g[m] = 0;
|
|
1314
1314
|
for (let v = 0; v < s; v += 1) {
|
|
1315
1315
|
const S = m * s + v;
|
|
1316
|
-
if (S >=
|
|
1316
|
+
if (S >= e.length)
|
|
1317
1317
|
continue;
|
|
1318
|
-
|
|
1318
|
+
e.charCodeAt(S) === f && (g[m] |= 1 << v);
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
let u = Math.max(0, Math.ceil(
|
|
1322
|
+
let u = Math.max(0, Math.ceil(t / s) - 1);
|
|
1323
1323
|
const p = new Uint32Array(n + 1);
|
|
1324
1324
|
for (let d = 0; d <= u; d += 1)
|
|
1325
1325
|
p[d] = (d + 1) * s;
|
|
1326
|
-
p[n] =
|
|
1326
|
+
p[n] = e.length;
|
|
1327
1327
|
for (let d = 0; d <= u; d += 1)
|
|
1328
1328
|
o.P[d] = -1, o.M[d] = 0;
|
|
1329
1329
|
for (let d = 0; d < r.length; d += 1) {
|
|
@@ -1332,64 +1332,64 @@ function Ft(r, t, e) {
|
|
|
1332
1332
|
f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = l));
|
|
1333
1333
|
let m = 0;
|
|
1334
1334
|
for (let v = 0; v <= u; v += 1)
|
|
1335
|
-
m =
|
|
1336
|
-
if (p[u] - m <=
|
|
1335
|
+
m = xe(o, g, v, m), p[v] += m;
|
|
1336
|
+
if (p[u] - m <= t && u < n && (g[u + 1] & 1 || m < 0)) {
|
|
1337
1337
|
u += 1, o.P[u] = -1, o.M[u] = 0;
|
|
1338
1338
|
let v;
|
|
1339
1339
|
if (u === n) {
|
|
1340
|
-
const S =
|
|
1340
|
+
const S = e.length % s;
|
|
1341
1341
|
v = S === 0 ? s : S;
|
|
1342
1342
|
} else
|
|
1343
1343
|
v = s;
|
|
1344
|
-
p[u] = p[u - 1] + v - m +
|
|
1344
|
+
p[u] = p[u - 1] + v - m + xe(o, g, u, m);
|
|
1345
1345
|
} else
|
|
1346
|
-
for (; u > 0 && p[u] >=
|
|
1346
|
+
for (; u > 0 && p[u] >= t + s; )
|
|
1347
1347
|
u -= 1;
|
|
1348
|
-
u === n && p[u] <=
|
|
1348
|
+
u === n && p[u] <= t && (p[u] < t && i.splice(0, i.length), i.push({
|
|
1349
1349
|
start: -1,
|
|
1350
1350
|
end: d + 1,
|
|
1351
1351
|
errors: p[u]
|
|
1352
|
-
}),
|
|
1352
|
+
}), t = p[u]);
|
|
1353
1353
|
}
|
|
1354
1354
|
return i;
|
|
1355
1355
|
}
|
|
1356
|
-
function
|
|
1357
|
-
const i =
|
|
1358
|
-
return
|
|
1356
|
+
function vt(r, e, t) {
|
|
1357
|
+
const i = Fe(r, e, t);
|
|
1358
|
+
return yt(r, e, i);
|
|
1359
1359
|
}
|
|
1360
|
-
function
|
|
1360
|
+
function Be(r, e, t) {
|
|
1361
1361
|
let i = 0;
|
|
1362
1362
|
const s = [];
|
|
1363
1363
|
for (; i !== -1; )
|
|
1364
|
-
i = r.indexOf(
|
|
1364
|
+
i = r.indexOf(e, i), i !== -1 && (s.push({
|
|
1365
1365
|
start: i,
|
|
1366
|
-
end: i +
|
|
1366
|
+
end: i + e.length,
|
|
1367
1367
|
errors: 0
|
|
1368
1368
|
}), i += 1);
|
|
1369
|
-
return s.length > 0 ? s :
|
|
1369
|
+
return s.length > 0 ? s : vt(r, e, t);
|
|
1370
1370
|
}
|
|
1371
|
-
function
|
|
1372
|
-
return
|
|
1371
|
+
function Se(r, e) {
|
|
1372
|
+
return e.length === 0 || r.length === 0 ? 0 : 1 - Be(r, e, e.length)[0].errors / e.length;
|
|
1373
1373
|
}
|
|
1374
|
-
function
|
|
1375
|
-
if (
|
|
1374
|
+
function bt(r, e, t = {}) {
|
|
1375
|
+
if (e.length === 0)
|
|
1376
1376
|
return null;
|
|
1377
|
-
const i = Math.min(256,
|
|
1377
|
+
const i = Math.min(256, e.length / 2), s = Be(r, e, i);
|
|
1378
1378
|
if (s.length === 0)
|
|
1379
1379
|
return null;
|
|
1380
1380
|
const n = (l) => {
|
|
1381
|
-
const d = 1 - l.errors /
|
|
1381
|
+
const d = 1 - l.errors / e.length, f = t.prefix ? Se(
|
|
1382
1382
|
r.slice(
|
|
1383
|
-
Math.max(0, l.start -
|
|
1383
|
+
Math.max(0, l.start - t.prefix.length),
|
|
1384
1384
|
l.start
|
|
1385
1385
|
),
|
|
1386
|
-
|
|
1387
|
-
) : 1, g =
|
|
1388
|
-
r.slice(l.end, l.end +
|
|
1389
|
-
|
|
1386
|
+
t.prefix
|
|
1387
|
+
) : 1, g = t.suffix ? Se(
|
|
1388
|
+
r.slice(l.end, l.end + t.suffix.length),
|
|
1389
|
+
t.suffix
|
|
1390
1390
|
) : 1;
|
|
1391
1391
|
let m = 1;
|
|
1392
|
-
typeof
|
|
1392
|
+
typeof t.hint == "number" && (m = 1 - Math.abs(l.start - t.hint) / r.length);
|
|
1393
1393
|
const v = 50 * d + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
|
|
1394
1394
|
return v / S;
|
|
1395
1395
|
}, o = s.map((l) => ({
|
|
@@ -1399,30 +1399,30 @@ function Ee(r, t, e = {}) {
|
|
|
1399
1399
|
}));
|
|
1400
1400
|
return o.sort((l, c) => c.score - l.score), o[0];
|
|
1401
1401
|
}
|
|
1402
|
-
function J(r,
|
|
1403
|
-
const i =
|
|
1402
|
+
function J(r, e, t) {
|
|
1403
|
+
const i = t === 1 ? e : e - 1;
|
|
1404
1404
|
if (r.charAt(i).trim() !== "")
|
|
1405
|
-
return
|
|
1405
|
+
return e;
|
|
1406
1406
|
let s, n;
|
|
1407
|
-
if (
|
|
1407
|
+
if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)
|
|
1408
1408
|
return -1;
|
|
1409
1409
|
const o = s.length - n.length;
|
|
1410
|
-
return
|
|
1410
|
+
return t === 2 ? e - o : e + o;
|
|
1411
1411
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const
|
|
1412
|
+
function Te(r, e) {
|
|
1413
|
+
const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1414
1414
|
r.commonAncestorContainer,
|
|
1415
1415
|
NodeFilter.SHOW_TEXT
|
|
1416
|
-
), i =
|
|
1417
|
-
let n =
|
|
1416
|
+
), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;
|
|
1417
|
+
let n = t.nextNode();
|
|
1418
1418
|
for (; n && n !== i; )
|
|
1419
|
-
n =
|
|
1420
|
-
|
|
1419
|
+
n = t.nextNode();
|
|
1420
|
+
e === 2 && (n = t.previousNode());
|
|
1421
1421
|
let o = -1;
|
|
1422
1422
|
const l = () => {
|
|
1423
|
-
if (n =
|
|
1424
|
-
const c = n.textContent, h =
|
|
1425
|
-
o = J(c, h,
|
|
1423
|
+
if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
|
|
1424
|
+
const c = n.textContent, h = e === 1 ? 0 : c.length;
|
|
1425
|
+
o = J(c, h, e);
|
|
1426
1426
|
}
|
|
1427
1427
|
};
|
|
1428
1428
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1431,15 +1431,15 @@ function Tt(r, t) {
|
|
|
1431
1431
|
return { node: n, offset: o };
|
|
1432
1432
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1433
1433
|
}
|
|
1434
|
-
function
|
|
1434
|
+
function Et(r) {
|
|
1435
1435
|
if (!r.toString().trim().length)
|
|
1436
1436
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1437
1437
|
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1438
1438
|
throw new RangeError("Range startContainer is not a text node");
|
|
1439
1439
|
if (r.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1440
1440
|
throw new RangeError("Range endContainer is not a text node");
|
|
1441
|
-
const
|
|
1442
|
-
let
|
|
1441
|
+
const e = r.cloneRange();
|
|
1442
|
+
let t = !1, i = !1;
|
|
1443
1443
|
const s = {
|
|
1444
1444
|
start: J(
|
|
1445
1445
|
r.startContainer.textContent,
|
|
@@ -1454,62 +1454,62 @@ function be(r) {
|
|
|
1454
1454
|
/* Backwards */
|
|
1455
1455
|
)
|
|
1456
1456
|
};
|
|
1457
|
-
if (s.start >= 0 && (
|
|
1458
|
-
return
|
|
1459
|
-
if (!
|
|
1460
|
-
const { node: n, offset: o } =
|
|
1461
|
-
|
|
1457
|
+
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)
|
|
1458
|
+
return e;
|
|
1459
|
+
if (!t) {
|
|
1460
|
+
const { node: n, offset: o } = Te(
|
|
1461
|
+
e,
|
|
1462
1462
|
1
|
|
1463
1463
|
/* Forwards */
|
|
1464
1464
|
);
|
|
1465
|
-
n && o >= 0 &&
|
|
1465
|
+
n && o >= 0 && e.setStart(n, o);
|
|
1466
1466
|
}
|
|
1467
1467
|
if (!i) {
|
|
1468
|
-
const { node: n, offset: o } =
|
|
1469
|
-
|
|
1468
|
+
const { node: n, offset: o } = Te(
|
|
1469
|
+
e,
|
|
1470
1470
|
2
|
|
1471
1471
|
/* Backwards */
|
|
1472
1472
|
);
|
|
1473
|
-
n && o > 0 &&
|
|
1473
|
+
n && o > 0 && e.setEnd(n, o);
|
|
1474
1474
|
}
|
|
1475
|
-
return
|
|
1475
|
+
return e;
|
|
1476
1476
|
}
|
|
1477
|
-
function
|
|
1478
|
-
var
|
|
1477
|
+
function Ue(r) {
|
|
1478
|
+
var e;
|
|
1479
1479
|
switch (r.nodeType) {
|
|
1480
1480
|
case Node.ELEMENT_NODE:
|
|
1481
1481
|
case Node.TEXT_NODE:
|
|
1482
|
-
return ((
|
|
1482
|
+
return ((e = r.textContent) == null ? void 0 : e.length) ?? 0;
|
|
1483
1483
|
default:
|
|
1484
1484
|
return 0;
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1488
|
-
let
|
|
1489
|
-
for (;
|
|
1490
|
-
|
|
1491
|
-
return
|
|
1487
|
+
function we(r) {
|
|
1488
|
+
let e = r.previousSibling, t = 0;
|
|
1489
|
+
for (; e; )
|
|
1490
|
+
t += Ue(e), e = e.previousSibling;
|
|
1491
|
+
return t;
|
|
1492
1492
|
}
|
|
1493
|
-
function
|
|
1494
|
-
let
|
|
1493
|
+
function ke(r, ...e) {
|
|
1494
|
+
let t = e.shift();
|
|
1495
1495
|
const i = r.ownerDocument.createNodeIterator(
|
|
1496
1496
|
r,
|
|
1497
1497
|
NodeFilter.SHOW_TEXT
|
|
1498
1498
|
), s = [];
|
|
1499
1499
|
let n = i.nextNode(), o, l = 0;
|
|
1500
|
-
for (;
|
|
1501
|
-
o = n, l + o.data.length >
|
|
1502
|
-
for (;
|
|
1503
|
-
s.push({ node: o, offset: o.data.length }),
|
|
1504
|
-
if (
|
|
1500
|
+
for (; t !== void 0 && n; )
|
|
1501
|
+
o = n, l + o.data.length > t ? (s.push({ node: o, offset: t - l }), t = e.shift()) : (n = i.nextNode(), l += o.data.length);
|
|
1502
|
+
for (; t !== void 0 && o && l === t; )
|
|
1503
|
+
s.push({ node: o, offset: o.data.length }), t = e.shift();
|
|
1504
|
+
if (t !== void 0)
|
|
1505
1505
|
throw new RangeError("Offset exceeds text length");
|
|
1506
1506
|
return s;
|
|
1507
1507
|
}
|
|
1508
1508
|
class A {
|
|
1509
|
-
constructor(
|
|
1510
|
-
if (
|
|
1509
|
+
constructor(e, t) {
|
|
1510
|
+
if (t < 0)
|
|
1511
1511
|
throw new Error("Offset is invalid");
|
|
1512
|
-
this.element =
|
|
1512
|
+
this.element = e, this.offset = t;
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* Return a copy of this position with offset relative to a given ancestor
|
|
@@ -1517,13 +1517,13 @@ class A {
|
|
|
1517
1517
|
*
|
|
1518
1518
|
* @param parent - Ancestor of `this.element`
|
|
1519
1519
|
*/
|
|
1520
|
-
relativeTo(
|
|
1521
|
-
if (!
|
|
1520
|
+
relativeTo(e) {
|
|
1521
|
+
if (!e.contains(this.element))
|
|
1522
1522
|
throw new Error("Parent is not an ancestor of current element");
|
|
1523
|
-
let
|
|
1524
|
-
for (;
|
|
1525
|
-
i +=
|
|
1526
|
-
return new A(
|
|
1523
|
+
let t = this.element, i = this.offset;
|
|
1524
|
+
for (; t !== e; )
|
|
1525
|
+
i += we(t), t = t.parentElement;
|
|
1526
|
+
return new A(t, i);
|
|
1527
1527
|
}
|
|
1528
1528
|
/**
|
|
1529
1529
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1542,34 +1542,34 @@ class A {
|
|
|
1542
1542
|
*
|
|
1543
1543
|
* @throws {RangeError}
|
|
1544
1544
|
*/
|
|
1545
|
-
resolve(
|
|
1545
|
+
resolve(e = {}) {
|
|
1546
1546
|
try {
|
|
1547
|
-
return
|
|
1548
|
-
} catch (
|
|
1549
|
-
if (this.offset === 0 &&
|
|
1547
|
+
return ke(this.element, this.offset)[0];
|
|
1548
|
+
} catch (t) {
|
|
1549
|
+
if (this.offset === 0 && e.direction !== void 0) {
|
|
1550
1550
|
const i = document.createTreeWalker(
|
|
1551
1551
|
this.element.getRootNode(),
|
|
1552
1552
|
NodeFilter.SHOW_TEXT
|
|
1553
1553
|
);
|
|
1554
1554
|
i.currentNode = this.element;
|
|
1555
|
-
const s =
|
|
1555
|
+
const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();
|
|
1556
1556
|
if (!n)
|
|
1557
|
-
throw
|
|
1557
|
+
throw t;
|
|
1558
1558
|
return { node: n, offset: s ? 0 : n.data.length };
|
|
1559
1559
|
} else
|
|
1560
|
-
throw
|
|
1560
|
+
throw t;
|
|
1561
1561
|
}
|
|
1562
1562
|
}
|
|
1563
1563
|
/**
|
|
1564
1564
|
* Construct a `TextPosition` that refers to the `offset`th character within
|
|
1565
1565
|
* `node`.
|
|
1566
1566
|
*/
|
|
1567
|
-
static fromCharOffset(
|
|
1568
|
-
switch (
|
|
1567
|
+
static fromCharOffset(e, t) {
|
|
1568
|
+
switch (e.nodeType) {
|
|
1569
1569
|
case Node.TEXT_NODE:
|
|
1570
|
-
return A.fromPoint(
|
|
1570
|
+
return A.fromPoint(e, t);
|
|
1571
1571
|
case Node.ELEMENT_NODE:
|
|
1572
|
-
return new A(
|
|
1572
|
+
return new A(e, t);
|
|
1573
1573
|
default:
|
|
1574
1574
|
throw new Error("Node is not an element or text node");
|
|
1575
1575
|
}
|
|
@@ -1580,42 +1580,42 @@ class A {
|
|
|
1580
1580
|
* @param node
|
|
1581
1581
|
* @param offset - Offset within the node
|
|
1582
1582
|
*/
|
|
1583
|
-
static fromPoint(
|
|
1584
|
-
switch (
|
|
1583
|
+
static fromPoint(e, t) {
|
|
1584
|
+
switch (e.nodeType) {
|
|
1585
1585
|
case Node.TEXT_NODE: {
|
|
1586
|
-
if (
|
|
1586
|
+
if (t < 0 || t > e.data.length)
|
|
1587
1587
|
throw new Error("Text node offset is out of range");
|
|
1588
|
-
if (!
|
|
1588
|
+
if (!e.parentElement)
|
|
1589
1589
|
throw new Error("Text node has no parent");
|
|
1590
|
-
const i =
|
|
1591
|
-
return new A(
|
|
1590
|
+
const i = we(e) + t;
|
|
1591
|
+
return new A(e.parentElement, i);
|
|
1592
1592
|
}
|
|
1593
1593
|
case Node.ELEMENT_NODE: {
|
|
1594
|
-
if (
|
|
1594
|
+
if (t < 0 || t > e.childNodes.length)
|
|
1595
1595
|
throw new Error("Child node offset is out of range");
|
|
1596
1596
|
let i = 0;
|
|
1597
|
-
for (let s = 0; s <
|
|
1598
|
-
i +=
|
|
1599
|
-
return new A(
|
|
1597
|
+
for (let s = 0; s < t; s++)
|
|
1598
|
+
i += Ue(e.childNodes[s]);
|
|
1599
|
+
return new A(e, i);
|
|
1600
1600
|
}
|
|
1601
1601
|
default:
|
|
1602
1602
|
throw new Error("Point is not in an element or text node");
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
1605
|
}
|
|
1606
|
-
class
|
|
1607
|
-
constructor(
|
|
1608
|
-
this.start =
|
|
1606
|
+
class z {
|
|
1607
|
+
constructor(e, t) {
|
|
1608
|
+
this.start = e, this.end = t;
|
|
1609
1609
|
}
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Create a new TextRange whose `start` and `end` are computed relative to
|
|
1612
1612
|
* `element`. `element` must be an ancestor of both `start.element` and
|
|
1613
1613
|
* `end.element`.
|
|
1614
1614
|
*/
|
|
1615
|
-
relativeTo(
|
|
1616
|
-
return new
|
|
1617
|
-
this.start.relativeTo(
|
|
1618
|
-
this.end.relativeTo(
|
|
1615
|
+
relativeTo(e) {
|
|
1616
|
+
return new z(
|
|
1617
|
+
this.start.relativeTo(e),
|
|
1618
|
+
this.end.relativeTo(e)
|
|
1619
1619
|
);
|
|
1620
1620
|
}
|
|
1621
1621
|
/**
|
|
@@ -1628,63 +1628,63 @@ class D {
|
|
|
1628
1628
|
* May throw if the `start` or `end` positions cannot be resolved to a range.
|
|
1629
1629
|
*/
|
|
1630
1630
|
toRange() {
|
|
1631
|
-
let
|
|
1632
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [
|
|
1631
|
+
let e, t;
|
|
1632
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ke(
|
|
1633
1633
|
this.start.element,
|
|
1634
1634
|
this.start.offset,
|
|
1635
1635
|
this.end.offset
|
|
1636
|
-
) : (
|
|
1636
|
+
) : (e = this.start.resolve({
|
|
1637
1637
|
direction: 1
|
|
1638
1638
|
/* FORWARDS */
|
|
1639
|
-
}),
|
|
1639
|
+
}), t = this.end.resolve({
|
|
1640
1640
|
direction: 2
|
|
1641
1641
|
/* BACKWARDS */
|
|
1642
1642
|
}));
|
|
1643
1643
|
const i = new Range();
|
|
1644
|
-
return i.setStart(
|
|
1644
|
+
return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
|
|
1645
1645
|
}
|
|
1646
1646
|
/**
|
|
1647
1647
|
* Create a TextRange from a (DOM) Range
|
|
1648
1648
|
*/
|
|
1649
|
-
static fromRange(
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
), i = A.fromPoint(
|
|
1654
|
-
return new
|
|
1649
|
+
static fromRange(e) {
|
|
1650
|
+
const t = A.fromPoint(
|
|
1651
|
+
e.startContainer,
|
|
1652
|
+
e.startOffset
|
|
1653
|
+
), i = A.fromPoint(e.endContainer, e.endOffset);
|
|
1654
|
+
return new z(t, i);
|
|
1655
1655
|
}
|
|
1656
1656
|
/**
|
|
1657
1657
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1658
1658
|
* `root`
|
|
1659
1659
|
*/
|
|
1660
|
-
static fromOffsets(
|
|
1661
|
-
return new
|
|
1662
|
-
new A(
|
|
1663
|
-
new A(
|
|
1660
|
+
static fromOffsets(e, t, i) {
|
|
1661
|
+
return new z(
|
|
1662
|
+
new A(e, t),
|
|
1663
|
+
new A(e, i)
|
|
1664
1664
|
);
|
|
1665
1665
|
}
|
|
1666
1666
|
/**
|
|
1667
1667
|
* Return a new Range representing `range` trimmed of any leading or trailing
|
|
1668
1668
|
* whitespace
|
|
1669
1669
|
*/
|
|
1670
|
-
static trimmedRange(
|
|
1671
|
-
return
|
|
1670
|
+
static trimmedRange(e) {
|
|
1671
|
+
return Et(z.fromRange(e).toRange());
|
|
1672
1672
|
}
|
|
1673
1673
|
}
|
|
1674
|
-
class
|
|
1675
|
-
constructor(
|
|
1676
|
-
this.root =
|
|
1674
|
+
class _ {
|
|
1675
|
+
constructor(e, t, i) {
|
|
1676
|
+
this.root = e, this.start = t, this.end = i;
|
|
1677
1677
|
}
|
|
1678
|
-
static fromRange(
|
|
1679
|
-
const i =
|
|
1680
|
-
return new
|
|
1681
|
-
|
|
1678
|
+
static fromRange(e, t) {
|
|
1679
|
+
const i = z.fromRange(t).relativeTo(e);
|
|
1680
|
+
return new _(
|
|
1681
|
+
e,
|
|
1682
1682
|
i.start.offset,
|
|
1683
1683
|
i.end.offset
|
|
1684
1684
|
);
|
|
1685
1685
|
}
|
|
1686
|
-
static fromSelector(
|
|
1687
|
-
return new
|
|
1686
|
+
static fromSelector(e, t) {
|
|
1687
|
+
return new _(e, t.start, t.end);
|
|
1688
1688
|
}
|
|
1689
1689
|
toSelector() {
|
|
1690
1690
|
return {
|
|
@@ -1694,31 +1694,31 @@ class q {
|
|
|
1694
1694
|
};
|
|
1695
1695
|
}
|
|
1696
1696
|
toRange() {
|
|
1697
|
-
return
|
|
1697
|
+
return z.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
1700
|
class X {
|
|
1701
1701
|
/**
|
|
1702
1702
|
* @param root - A root element from which to anchor.
|
|
1703
1703
|
*/
|
|
1704
|
-
constructor(
|
|
1705
|
-
this.root =
|
|
1704
|
+
constructor(e, t, i = {}) {
|
|
1705
|
+
this.root = e, this.exact = t, this.context = i;
|
|
1706
1706
|
}
|
|
1707
1707
|
/**
|
|
1708
1708
|
* Create a `TextQuoteAnchor` from a range.
|
|
1709
1709
|
*
|
|
1710
1710
|
* Will throw if `range` does not contain any text nodes.
|
|
1711
1711
|
*/
|
|
1712
|
-
static fromRange(
|
|
1713
|
-
const i =
|
|
1714
|
-
return new X(
|
|
1712
|
+
static fromRange(e, t) {
|
|
1713
|
+
const i = e.textContent, s = z.fromRange(t).relativeTo(e), n = s.start.offset, o = s.end.offset, l = 32;
|
|
1714
|
+
return new X(e, i.slice(n, o), {
|
|
1715
1715
|
prefix: i.slice(Math.max(0, n - l), n),
|
|
1716
1716
|
suffix: i.slice(o, Math.min(i.length, o + l))
|
|
1717
1717
|
});
|
|
1718
1718
|
}
|
|
1719
|
-
static fromSelector(
|
|
1720
|
-
const { prefix: i, suffix: s } =
|
|
1721
|
-
return new X(
|
|
1719
|
+
static fromSelector(e, t) {
|
|
1720
|
+
const { prefix: i, suffix: s } = t;
|
|
1721
|
+
return new X(e, t.exact, { prefix: i, suffix: s });
|
|
1722
1722
|
}
|
|
1723
1723
|
toSelector() {
|
|
1724
1724
|
return {
|
|
@@ -1728,29 +1728,29 @@ class X {
|
|
|
1728
1728
|
suffix: this.context.suffix
|
|
1729
1729
|
};
|
|
1730
1730
|
}
|
|
1731
|
-
toRange(
|
|
1732
|
-
return this.toPositionAnchor(
|
|
1731
|
+
toRange(e = {}) {
|
|
1732
|
+
return this.toPositionAnchor(e).toRange();
|
|
1733
1733
|
}
|
|
1734
|
-
toPositionAnchor(
|
|
1735
|
-
const
|
|
1734
|
+
toPositionAnchor(e = {}) {
|
|
1735
|
+
const t = this.root.textContent, i = bt(t, this.exact, {
|
|
1736
1736
|
...this.context,
|
|
1737
|
-
hint:
|
|
1737
|
+
hint: e.hint
|
|
1738
1738
|
});
|
|
1739
1739
|
if (!i)
|
|
1740
1740
|
throw new Error("Quote not found");
|
|
1741
|
-
return new
|
|
1741
|
+
return new _(this.root, i.start, i.end);
|
|
1742
1742
|
}
|
|
1743
1743
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const
|
|
1746
|
-
return
|
|
1744
|
+
function xt(r) {
|
|
1745
|
+
const e = r.tagName.toUpperCase();
|
|
1746
|
+
return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
|
|
1747
1747
|
}
|
|
1748
|
-
function
|
|
1748
|
+
function le(r, e) {
|
|
1749
1749
|
try {
|
|
1750
|
-
const
|
|
1750
|
+
const t = e.locations, i = e.text;
|
|
1751
1751
|
if (i && i.highlight) {
|
|
1752
1752
|
let s;
|
|
1753
|
-
|
|
1753
|
+
t && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), s || (s = r.body);
|
|
1754
1754
|
const n = new X(s, i.highlight, {
|
|
1755
1755
|
prefix: i.before,
|
|
1756
1756
|
suffix: i.after
|
|
@@ -1761,28 +1761,28 @@ function lt(r, t) {
|
|
|
1761
1761
|
return console.warn("Quote not found:", n), null;
|
|
1762
1762
|
}
|
|
1763
1763
|
}
|
|
1764
|
-
if (
|
|
1764
|
+
if (t) {
|
|
1765
1765
|
let s = null;
|
|
1766
|
-
if (!s &&
|
|
1767
|
-
for (const n of
|
|
1766
|
+
if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {
|
|
1767
|
+
for (const n of t.fragments)
|
|
1768
1768
|
if (s = r.getElementById(n), s)
|
|
1769
1769
|
break;
|
|
1770
1770
|
}
|
|
1771
1771
|
if (s) {
|
|
1772
1772
|
const n = r.createRange();
|
|
1773
|
-
return s.childNodes.length === 0 ||
|
|
1773
|
+
return s.childNodes.length === 0 || xt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
|
-
} catch (
|
|
1777
|
-
console.error(
|
|
1776
|
+
} catch (t) {
|
|
1777
|
+
console.error(t);
|
|
1778
1778
|
}
|
|
1779
1779
|
return null;
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1782
|
-
let
|
|
1783
|
-
|
|
1781
|
+
function St(r, e) {
|
|
1782
|
+
let t = r.getClientRects();
|
|
1783
|
+
t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
|
|
1784
1784
|
const i = 1, s = [];
|
|
1785
|
-
for (const h of
|
|
1785
|
+
for (const h of t)
|
|
1786
1786
|
s.push({
|
|
1787
1787
|
bottom: h.bottom,
|
|
1788
1788
|
height: h.height,
|
|
@@ -1791,11 +1791,11 @@ function Se(r, t) {
|
|
|
1791
1791
|
top: h.top,
|
|
1792
1792
|
width: h.width
|
|
1793
1793
|
});
|
|
1794
|
-
const n = $
|
|
1794
|
+
const n = $e(
|
|
1795
1795
|
s,
|
|
1796
1796
|
i,
|
|
1797
|
-
|
|
1798
|
-
), o =
|
|
1797
|
+
e
|
|
1798
|
+
), o = wt(n, i), l = He(o), c = 2 * 2;
|
|
1799
1799
|
for (let h = l.length - 1; h >= 0; h--) {
|
|
1800
1800
|
const u = l[h];
|
|
1801
1801
|
if (!(u.width * u.height > c))
|
|
@@ -1806,78 +1806,78 @@ function Se(r, t) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
return l;
|
|
1808
1808
|
}
|
|
1809
|
-
function $
|
|
1809
|
+
function $e(r, e, t) {
|
|
1810
1810
|
for (let i = 0; i < r.length; i++)
|
|
1811
1811
|
for (let s = i + 1; s < r.length; s++) {
|
|
1812
1812
|
const n = r[i], o = r[s];
|
|
1813
1813
|
if (n === o)
|
|
1814
1814
|
continue;
|
|
1815
|
-
const l = M(n.top, o.top,
|
|
1816
|
-
if ((c && !
|
|
1817
|
-
const d = r.filter((g) => g !== n && g !== o), f =
|
|
1818
|
-
return d.push(f), $
|
|
1815
|
+
const l = M(n.top, o.top, e) && M(n.bottom, o.bottom, e), c = M(n.left, o.left, e) && M(n.right, o.right, e);
|
|
1816
|
+
if ((c && !t || l && !c) && je(n, o, e)) {
|
|
1817
|
+
const d = r.filter((g) => g !== n && g !== o), f = Tt(n, o);
|
|
1818
|
+
return d.push(f), $e(
|
|
1819
1819
|
d,
|
|
1820
|
-
|
|
1821
|
-
|
|
1820
|
+
e,
|
|
1821
|
+
t
|
|
1822
1822
|
);
|
|
1823
1823
|
}
|
|
1824
1824
|
}
|
|
1825
1825
|
return r;
|
|
1826
1826
|
}
|
|
1827
|
-
function
|
|
1828
|
-
const
|
|
1827
|
+
function Tt(r, e) {
|
|
1828
|
+
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);
|
|
1829
1829
|
return {
|
|
1830
1830
|
bottom: n,
|
|
1831
1831
|
height: n - s,
|
|
1832
|
-
left:
|
|
1832
|
+
left: t,
|
|
1833
1833
|
right: i,
|
|
1834
1834
|
top: s,
|
|
1835
|
-
width: i -
|
|
1835
|
+
width: i - t
|
|
1836
1836
|
};
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const
|
|
1838
|
+
function wt(r, e) {
|
|
1839
|
+
const t = new Set(r);
|
|
1840
1840
|
for (const i of r) {
|
|
1841
1841
|
if (!(i.width > 1 && i.height > 1)) {
|
|
1842
|
-
|
|
1842
|
+
t.delete(i);
|
|
1843
1843
|
continue;
|
|
1844
1844
|
}
|
|
1845
1845
|
for (const n of r)
|
|
1846
|
-
if (i !== n &&
|
|
1847
|
-
|
|
1846
|
+
if (i !== n && t.has(n) && Ct(n, i, e)) {
|
|
1847
|
+
t.delete(i);
|
|
1848
1848
|
break;
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
|
-
return Array.from(
|
|
1851
|
+
return Array.from(t);
|
|
1852
1852
|
}
|
|
1853
|
-
function
|
|
1854
|
-
return H(r,
|
|
1853
|
+
function Ct(r, e, t) {
|
|
1854
|
+
return H(r, e.left, e.top, t) && H(r, e.right, e.top, t) && H(r, e.left, e.bottom, t) && H(r, e.right, e.bottom, t);
|
|
1855
1855
|
}
|
|
1856
|
-
function H(r,
|
|
1857
|
-
return (r.left <
|
|
1856
|
+
function H(r, e, t, i) {
|
|
1857
|
+
return (r.left < e || M(r.left, e, i)) && (r.right > e || M(r.right, e, i)) && (r.top < t || M(r.top, t, i)) && (r.bottom > t || M(r.bottom, t, i));
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
for (let
|
|
1861
|
-
for (let
|
|
1862
|
-
const i = r[
|
|
1863
|
-
if (i !== s &&
|
|
1859
|
+
function He(r) {
|
|
1860
|
+
for (let e = 0; e < r.length; e++)
|
|
1861
|
+
for (let t = e + 1; t < r.length; t++) {
|
|
1862
|
+
const i = r[e], s = r[t];
|
|
1863
|
+
if (i !== s && je(i, s, -1)) {
|
|
1864
1864
|
let n = [], o;
|
|
1865
|
-
const l =
|
|
1865
|
+
const l = Ce(i, s);
|
|
1866
1866
|
if (l.length === 1)
|
|
1867
1867
|
n = l, o = i;
|
|
1868
1868
|
else {
|
|
1869
|
-
const h =
|
|
1869
|
+
const h = Ce(s, i);
|
|
1870
1870
|
l.length < h.length ? (n = l, o = i) : (n = h, o = s);
|
|
1871
1871
|
}
|
|
1872
1872
|
const c = r.filter((h) => h !== o);
|
|
1873
|
-
return Array.prototype.push.apply(c, n),
|
|
1873
|
+
return Array.prototype.push.apply(c, n), He(c);
|
|
1874
1874
|
}
|
|
1875
1875
|
}
|
|
1876
1876
|
return r;
|
|
1877
1877
|
}
|
|
1878
|
-
function
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1878
|
+
function Ce(r, e) {
|
|
1879
|
+
const t = Pt(e, r);
|
|
1880
|
+
if (t.height === 0 || t.width === 0)
|
|
1881
1881
|
return [r];
|
|
1882
1882
|
const i = [];
|
|
1883
1883
|
{
|
|
@@ -1885,7 +1885,7 @@ function Ct(r, t) {
|
|
|
1885
1885
|
bottom: r.bottom,
|
|
1886
1886
|
height: 0,
|
|
1887
1887
|
left: r.left,
|
|
1888
|
-
right:
|
|
1888
|
+
right: t.left,
|
|
1889
1889
|
top: r.top,
|
|
1890
1890
|
width: 0
|
|
1891
1891
|
};
|
|
@@ -1893,10 +1893,10 @@ function Ct(r, t) {
|
|
|
1893
1893
|
}
|
|
1894
1894
|
{
|
|
1895
1895
|
const s = {
|
|
1896
|
-
bottom:
|
|
1896
|
+
bottom: t.top,
|
|
1897
1897
|
height: 0,
|
|
1898
|
-
left:
|
|
1899
|
-
right:
|
|
1898
|
+
left: t.left,
|
|
1899
|
+
right: t.right,
|
|
1900
1900
|
top: r.top,
|
|
1901
1901
|
width: 0
|
|
1902
1902
|
};
|
|
@@ -1906,9 +1906,9 @@ function Ct(r, t) {
|
|
|
1906
1906
|
const s = {
|
|
1907
1907
|
bottom: r.bottom,
|
|
1908
1908
|
height: 0,
|
|
1909
|
-
left:
|
|
1910
|
-
right:
|
|
1911
|
-
top:
|
|
1909
|
+
left: t.left,
|
|
1910
|
+
right: t.right,
|
|
1911
|
+
top: t.bottom,
|
|
1912
1912
|
width: 0
|
|
1913
1913
|
};
|
|
1914
1914
|
s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
|
|
@@ -1917,7 +1917,7 @@ function Ct(r, t) {
|
|
|
1917
1917
|
const s = {
|
|
1918
1918
|
bottom: r.bottom,
|
|
1919
1919
|
height: 0,
|
|
1920
|
-
left:
|
|
1920
|
+
left: t.right,
|
|
1921
1921
|
right: r.right,
|
|
1922
1922
|
top: r.top,
|
|
1923
1923
|
width: 0
|
|
@@ -1926,111 +1926,111 @@ function Ct(r, t) {
|
|
|
1926
1926
|
}
|
|
1927
1927
|
return i;
|
|
1928
1928
|
}
|
|
1929
|
-
function
|
|
1930
|
-
const
|
|
1929
|
+
function Pt(r, e) {
|
|
1930
|
+
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);
|
|
1931
1931
|
return {
|
|
1932
1932
|
bottom: n,
|
|
1933
1933
|
height: Math.max(0, n - s),
|
|
1934
|
-
left:
|
|
1934
|
+
left: t,
|
|
1935
1935
|
right: i,
|
|
1936
1936
|
top: s,
|
|
1937
|
-
width: Math.max(0, i -
|
|
1937
|
+
width: Math.max(0, i - t)
|
|
1938
1938
|
};
|
|
1939
1939
|
}
|
|
1940
|
-
function
|
|
1941
|
-
return (r.left <
|
|
1940
|
+
function je(r, e, t) {
|
|
1941
|
+
return (r.left < e.right || t >= 0 && M(r.left, e.right, t)) && (e.left < r.right || t >= 0 && M(e.left, r.right, t)) && (r.top < e.bottom || t >= 0 && M(r.top, e.bottom, t)) && (e.top < r.bottom || t >= 0 && M(e.top, r.bottom, t));
|
|
1942
1942
|
}
|
|
1943
|
-
function M(r,
|
|
1944
|
-
return Math.abs(r -
|
|
1943
|
+
function M(r, e, t) {
|
|
1944
|
+
return Math.abs(r - e) <= t;
|
|
1945
1945
|
}
|
|
1946
|
-
function
|
|
1947
|
-
const
|
|
1946
|
+
function Ve(r) {
|
|
1947
|
+
const e = {}, t = r.document.documentElement.style;
|
|
1948
1948
|
for (const i in r.document.documentElement.style)
|
|
1949
|
-
Object.hasOwn(
|
|
1950
|
-
return
|
|
1949
|
+
Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
|
|
1950
|
+
return e;
|
|
1951
1951
|
}
|
|
1952
|
-
function
|
|
1953
|
-
const
|
|
1954
|
-
Object.keys(
|
|
1955
|
-
|
|
1956
|
-
}), Object.entries(
|
|
1957
|
-
|
|
1952
|
+
function Nt(r, e) {
|
|
1953
|
+
const t = Ve(r);
|
|
1954
|
+
Object.keys(t).forEach((i) => {
|
|
1955
|
+
e.hasOwnProperty(i) || he(r, i);
|
|
1956
|
+
}), Object.entries(e).forEach(([i, s]) => {
|
|
1957
|
+
t[i] !== s && G(r, i, s);
|
|
1958
1958
|
});
|
|
1959
1959
|
}
|
|
1960
|
-
function
|
|
1961
|
-
return r.document.documentElement.style.getPropertyValue(
|
|
1960
|
+
function Pe(r, e) {
|
|
1961
|
+
return r.document.documentElement.style.getPropertyValue(e);
|
|
1962
1962
|
}
|
|
1963
|
-
function G(r,
|
|
1964
|
-
r.document.documentElement.style.setProperty(
|
|
1963
|
+
function G(r, e, t) {
|
|
1964
|
+
r.document.documentElement.style.setProperty(e, t);
|
|
1965
1965
|
}
|
|
1966
|
-
function
|
|
1967
|
-
r.document.documentElement.style.removeProperty(
|
|
1966
|
+
function he(r, e) {
|
|
1967
|
+
r.document.documentElement.style.removeProperty(e);
|
|
1968
1968
|
}
|
|
1969
|
-
const
|
|
1969
|
+
const Mt = (r) => {
|
|
1970
1970
|
if (r.startsWith("rgb")) {
|
|
1971
|
-
const
|
|
1972
|
-
if (
|
|
1971
|
+
const e = r.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
|
|
1972
|
+
if (e)
|
|
1973
1973
|
return {
|
|
1974
|
-
r: parseInt(
|
|
1975
|
-
g: parseInt(
|
|
1976
|
-
b: parseInt(
|
|
1977
|
-
a:
|
|
1974
|
+
r: parseInt(e[1], 10),
|
|
1975
|
+
g: parseInt(e[2], 10),
|
|
1976
|
+
b: parseInt(e[3], 10),
|
|
1977
|
+
a: e[4] ? parseInt(e[4], 10) / 255 : 1
|
|
1978
1978
|
};
|
|
1979
1979
|
} else if (r.startsWith("#")) {
|
|
1980
|
-
const
|
|
1981
|
-
if (
|
|
1980
|
+
const e = r.slice(1);
|
|
1981
|
+
if (e.length === 3 || e.length === 4)
|
|
1982
1982
|
return {
|
|
1983
|
-
r: parseInt(
|
|
1984
|
-
g: parseInt(
|
|
1985
|
-
b: parseInt(
|
|
1986
|
-
a:
|
|
1983
|
+
r: parseInt(e[0] + e[0], 16) / 255,
|
|
1984
|
+
g: parseInt(e[1] + e[1], 16) / 255,
|
|
1985
|
+
b: parseInt(e[2] + e[2], 16) / 255,
|
|
1986
|
+
a: e.length === 4 ? parseInt(e[3] + e[3], 16) / 255 : 1
|
|
1987
1987
|
};
|
|
1988
|
-
if (
|
|
1988
|
+
if (e.length === 6 || e.length === 8)
|
|
1989
1989
|
return {
|
|
1990
|
-
r: parseInt(
|
|
1991
|
-
g: parseInt(
|
|
1992
|
-
b: parseInt(
|
|
1993
|
-
a:
|
|
1990
|
+
r: parseInt(e[0] + e[1], 16) / 255,
|
|
1991
|
+
g: parseInt(e[2] + e[3], 16) / 255,
|
|
1992
|
+
b: parseInt(e[4] + e[5], 16) / 255,
|
|
1993
|
+
a: e.length === 8 ? parseInt(e[6] + e[7], 16) / 255 : 1
|
|
1994
1994
|
};
|
|
1995
1995
|
}
|
|
1996
1996
|
return { r: 0, g: 0, b: 0, a: 1 };
|
|
1997
|
-
},
|
|
1998
|
-
const
|
|
1999
|
-
return
|
|
1997
|
+
}, At = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, Ot = (r) => {
|
|
1998
|
+
const e = Mt(r);
|
|
1999
|
+
return At(e) < 128;
|
|
2000
2000
|
};
|
|
2001
|
-
var
|
|
2002
|
-
const
|
|
2003
|
-
class
|
|
2001
|
+
var It = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(It || {}), Lt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Lt || {});
|
|
2002
|
+
const Rt = () => "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2003
|
+
class zt {
|
|
2004
2004
|
/**
|
|
2005
2005
|
* Creates a DecorationGroup object
|
|
2006
2006
|
* @param id Unique HTML ID-adhering name of the group
|
|
2007
2007
|
* @param name Human-readable name of the group
|
|
2008
2008
|
*/
|
|
2009
|
-
constructor(
|
|
2010
|
-
this.wnd =
|
|
2009
|
+
constructor(e, t, i, s) {
|
|
2010
|
+
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, Rt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2011
2011
|
}
|
|
2012
2012
|
get activeable() {
|
|
2013
2013
|
return this.activateable;
|
|
2014
2014
|
}
|
|
2015
|
-
set activeable(
|
|
2016
|
-
this.activateable =
|
|
2015
|
+
set activeable(e) {
|
|
2016
|
+
this.activateable = e;
|
|
2017
2017
|
}
|
|
2018
2018
|
/**
|
|
2019
2019
|
* Adds a new decoration to the group.
|
|
2020
2020
|
* @param decoration Decoration to add
|
|
2021
2021
|
*/
|
|
2022
|
-
add(
|
|
2022
|
+
add(e) {
|
|
2023
2023
|
var o, l, c, h;
|
|
2024
|
-
const
|
|
2024
|
+
const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
|
|
2025
2025
|
if (!i) {
|
|
2026
|
-
this.comms.log("Can't locate DOM range for decoration",
|
|
2026
|
+
this.comms.log("Can't locate DOM range for decoration", e);
|
|
2027
2027
|
return;
|
|
2028
2028
|
}
|
|
2029
2029
|
const s = i.commonAncestorContainer;
|
|
2030
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (
|
|
2030
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((l = this.notTextFlag) == null || l.set(t, !0)), (((c = s.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(t, !0)));
|
|
2031
2031
|
const n = {
|
|
2032
|
-
decoration:
|
|
2033
|
-
id:
|
|
2032
|
+
decoration: e,
|
|
2033
|
+
id: t,
|
|
2034
2034
|
range: i
|
|
2035
2035
|
};
|
|
2036
2036
|
this.items.push(n), this.layout(n), this.renderLayout([n]);
|
|
@@ -2039,13 +2039,13 @@ class De {
|
|
|
2039
2039
|
* Removes the decoration with given ID from the group.
|
|
2040
2040
|
* @param identifier ID of item to remove
|
|
2041
2041
|
*/
|
|
2042
|
-
remove(
|
|
2042
|
+
remove(e) {
|
|
2043
2043
|
var s, n;
|
|
2044
|
-
const
|
|
2045
|
-
if (
|
|
2044
|
+
const t = this.items.findIndex((o) => o.decoration.id === e);
|
|
2045
|
+
if (t < 0)
|
|
2046
2046
|
return;
|
|
2047
|
-
const i = this.items[
|
|
2048
|
-
if (this.items.splice(
|
|
2047
|
+
const i = this.items[t];
|
|
2048
|
+
if (this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !((s = this.notTextFlag) != null && s.has(i.id))) {
|
|
2049
2049
|
const o = this.wnd.CSS.highlights.get(this.id);
|
|
2050
2050
|
o == null || o.delete(i.range);
|
|
2051
2051
|
}
|
|
@@ -2055,68 +2055,68 @@ class De {
|
|
|
2055
2055
|
* Notifies that the given decoration was modified and needs to be updated.
|
|
2056
2056
|
* @param decoration Decoration to update
|
|
2057
2057
|
*/
|
|
2058
|
-
update(
|
|
2059
|
-
this.remove(
|
|
2058
|
+
update(e) {
|
|
2059
|
+
this.remove(e.id), this.add(e);
|
|
2060
2060
|
}
|
|
2061
2061
|
/**
|
|
2062
2062
|
* Removes all decorations from this group.
|
|
2063
2063
|
*/
|
|
2064
2064
|
clear() {
|
|
2065
|
-
var
|
|
2066
|
-
this.clearContainer(), this.items.length = 0, (
|
|
2065
|
+
var e;
|
|
2066
|
+
this.clearContainer(), this.items.length = 0, (e = this.notTextFlag) == null || e.clear();
|
|
2067
2067
|
}
|
|
2068
2068
|
/**
|
|
2069
2069
|
* Recreates the decoration elements.
|
|
2070
2070
|
* To be called after reflowing the resource, for example.
|
|
2071
2071
|
*/
|
|
2072
2072
|
requestLayout() {
|
|
2073
|
-
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((
|
|
2073
|
+
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
|
|
2074
2074
|
}
|
|
2075
|
-
experimentalLayout(
|
|
2075
|
+
experimentalLayout(e) {
|
|
2076
2076
|
var s, n;
|
|
2077
|
-
const [
|
|
2078
|
-
i.add(
|
|
2077
|
+
const [t, i] = this.requireContainer(!0);
|
|
2078
|
+
i.add(e.range), t.innerHTML = `
|
|
2079
2079
|
::highlight(${this.id}) {
|
|
2080
2080
|
color: black;
|
|
2081
|
-
background-color: ${((n = (s =
|
|
2081
|
+
background-color: ${((n = (s = e.decoration) == null ? void 0 : s.style) == null ? void 0 : n.tint) ?? "yellow"};
|
|
2082
2082
|
}`;
|
|
2083
2083
|
}
|
|
2084
2084
|
/**
|
|
2085
2085
|
* Layouts a single DecorationItem.
|
|
2086
2086
|
* @param item
|
|
2087
2087
|
*/
|
|
2088
|
-
layout(
|
|
2088
|
+
layout(e) {
|
|
2089
2089
|
var g, m, v, S, O;
|
|
2090
|
-
if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(
|
|
2091
|
-
return this.experimentalLayout(
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2090
|
+
if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(e.id)))
|
|
2091
|
+
return this.experimentalLayout(e);
|
|
2092
|
+
const t = this.wnd.document.createElement("div");
|
|
2093
|
+
t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
|
|
2094
2094
|
const i = this.wnd.innerWidth, s = parseInt(
|
|
2095
2095
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2096
2096
|
"column-count"
|
|
2097
2097
|
)
|
|
2098
|
-
), n = i / (s || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, c = o.scrollTop, h = (y,
|
|
2099
|
-
var
|
|
2100
|
-
if (y.style.position = "absolute", ((
|
|
2101
|
-
y.style.width = `${i}px`, y.style.height = `${
|
|
2102
|
-
let K = Math.floor(
|
|
2103
|
-
y.style.left = `${K + l}px`, y.style.top = `${
|
|
2104
|
-
} else if (((
|
|
2105
|
-
y.style.width = `${I.width}px`, y.style.height = `${
|
|
2106
|
-
else if (((
|
|
2107
|
-
y.style.width = `${n}px`, y.style.height = `${
|
|
2108
|
-
let K = Math.floor(
|
|
2109
|
-
y.style.left = `${K + l}px`, y.style.top = `${
|
|
2098
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, c = o.scrollTop, h = (y, E, I) => {
|
|
2099
|
+
var ce, ue, de, pe, fe, me;
|
|
2100
|
+
if (y.style.position = "absolute", ((ue = (ce = e.decoration) == null ? void 0 : ce.style) == null ? void 0 : ue.width) === "viewport") {
|
|
2101
|
+
y.style.width = `${i}px`, y.style.height = `${E.height}px`;
|
|
2102
|
+
let K = Math.floor(E.left / i) * i;
|
|
2103
|
+
y.style.left = `${K + l}px`, y.style.top = `${E.top + c}px`;
|
|
2104
|
+
} else if (((pe = (de = e.decoration) == null ? void 0 : de.style) == null ? void 0 : pe.width) === "bounds")
|
|
2105
|
+
y.style.width = `${I.width}px`, y.style.height = `${E.height}px`, y.style.left = `${I.left + l}px`, y.style.top = `${E.top + c}px`;
|
|
2106
|
+
else if (((me = (fe = e.decoration) == null ? void 0 : fe.style) == null ? void 0 : me.width) === "page") {
|
|
2107
|
+
y.style.width = `${n}px`, y.style.height = `${E.height}px`;
|
|
2108
|
+
let K = Math.floor(E.left / n) * n;
|
|
2109
|
+
y.style.left = `${K + l}px`, y.style.top = `${E.top + c}px`;
|
|
2110
2110
|
} else
|
|
2111
|
-
y.style.width = `${
|
|
2112
|
-
}, u =
|
|
2111
|
+
y.style.width = `${E.width}px`, y.style.height = `${E.height}px`, y.style.left = `${E.left + l}px`, y.style.top = `${E.top + c}px`;
|
|
2112
|
+
}, u = e.range.getBoundingClientRect();
|
|
2113
2113
|
let p = this.wnd.document.createElement("template");
|
|
2114
|
-
const d =
|
|
2114
|
+
const d = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
|
|
2115
2115
|
p.innerHTML = `
|
|
2116
2116
|
<div
|
|
2117
2117
|
class="r2-highlight-0"
|
|
2118
2118
|
style="${[
|
|
2119
|
-
`background-color: ${((v = (m =
|
|
2119
|
+
`background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
|
|
2120
2120
|
//"opacity: 0.3 !important",
|
|
2121
2121
|
`mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
|
|
2122
2122
|
"opacity: 1 !important",
|
|
@@ -2126,45 +2126,45 @@ class De {
|
|
|
2126
2126
|
</div>
|
|
2127
2127
|
`.trim();
|
|
2128
2128
|
const f = p.content.firstElementChild;
|
|
2129
|
-
if (((O = (S =
|
|
2129
|
+
if (((O = (S = e.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
|
|
2130
2130
|
const y = f.cloneNode(!0);
|
|
2131
|
-
y.style.setProperty("pointer-events", "none"), h(y, u, u),
|
|
2131
|
+
y.style.setProperty("pointer-events", "none"), h(y, u, u), t.append(y);
|
|
2132
2132
|
} else {
|
|
2133
|
-
let y =
|
|
2134
|
-
|
|
2133
|
+
let y = St(
|
|
2134
|
+
e.range,
|
|
2135
2135
|
!0
|
|
2136
2136
|
// doNotMergeHorizontallyAlignedRects
|
|
2137
2137
|
);
|
|
2138
|
-
y = y.sort((
|
|
2139
|
-
for (let
|
|
2138
|
+
y = y.sort((E, I) => E.top < I.top ? -1 : E.top > I.top ? 1 : 0);
|
|
2139
|
+
for (let E of y) {
|
|
2140
2140
|
const I = f.cloneNode(!0);
|
|
2141
|
-
I.style.setProperty("pointer-events", "none"), h(I,
|
|
2141
|
+
I.style.setProperty("pointer-events", "none"), h(I, E, u), t.append(I);
|
|
2142
2142
|
}
|
|
2143
2143
|
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
),
|
|
2144
|
+
e.container = t, e.clickableElements = Array.from(
|
|
2145
|
+
t.querySelectorAll("[data-activable='1']")
|
|
2146
|
+
), e.clickableElements.length || (e.clickableElements = Array.from(t.children));
|
|
2147
2147
|
}
|
|
2148
|
-
renderLayout(
|
|
2148
|
+
renderLayout(e) {
|
|
2149
2149
|
this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
|
|
2150
|
-
if (
|
|
2150
|
+
if (e = e.filter((i) => {
|
|
2151
2151
|
var s;
|
|
2152
2152
|
return !this.experimentalHighlights || !!((s = this.notTextFlag) != null && s.has(i.id));
|
|
2153
|
-
}), !
|
|
2153
|
+
}), !e || e.length === 0)
|
|
2154
2154
|
return;
|
|
2155
|
-
this.requireContainer().append(...
|
|
2155
|
+
this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
|
|
2156
2156
|
});
|
|
2157
2157
|
}
|
|
2158
2158
|
/**
|
|
2159
2159
|
* Returns the group container element, after making sure it exists.
|
|
2160
2160
|
* @returns Group's container
|
|
2161
2161
|
*/
|
|
2162
|
-
requireContainer(
|
|
2163
|
-
if (
|
|
2164
|
-
let
|
|
2165
|
-
this.wnd.document.getElementById(`${this.id}-style`) ?
|
|
2162
|
+
requireContainer(e = !1) {
|
|
2163
|
+
if (e) {
|
|
2164
|
+
let t;
|
|
2165
|
+
this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));
|
|
2166
2166
|
let i;
|
|
2167
|
-
return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [
|
|
2167
|
+
return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];
|
|
2168
2168
|
}
|
|
2169
2169
|
return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
|
|
2170
2170
|
}
|
|
@@ -2175,26 +2175,26 @@ class De {
|
|
|
2175
2175
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
const
|
|
2178
|
+
const qe = class Q extends Y {
|
|
2179
2179
|
constructor() {
|
|
2180
2180
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2181
2181
|
}
|
|
2182
2182
|
cleanup() {
|
|
2183
|
-
this.groups.forEach((
|
|
2183
|
+
this.groups.forEach((e) => e.clear()), this.groups.clear();
|
|
2184
2184
|
}
|
|
2185
2185
|
handleResize() {
|
|
2186
2186
|
this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
|
|
2187
|
-
this.groups.forEach((
|
|
2188
|
-
|
|
2187
|
+
this.groups.forEach((e) => {
|
|
2188
|
+
e.experimentalHighlights || e.requestLayout();
|
|
2189
2189
|
});
|
|
2190
2190
|
}, 50);
|
|
2191
2191
|
}
|
|
2192
|
-
mount(
|
|
2193
|
-
return this.wnd =
|
|
2192
|
+
mount(e, t) {
|
|
2193
|
+
return this.wnd = e, t.register("decorate", Q.moduleName, (i, s) => {
|
|
2194
2194
|
const n = i;
|
|
2195
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
2196
|
-
t,
|
|
2195
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = D.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new zt(
|
|
2197
2196
|
e,
|
|
2197
|
+
t,
|
|
2198
2198
|
`readium-decoration-${this.lastGroupId++}`,
|
|
2199
2199
|
n.group
|
|
2200
2200
|
));
|
|
@@ -2214,15 +2214,15 @@ const _t = class Q extends Y {
|
|
|
2214
2214
|
break;
|
|
2215
2215
|
}
|
|
2216
2216
|
s(!0);
|
|
2217
|
-
}), this.resizeObserver = new ResizeObserver(() =>
|
|
2217
|
+
}), 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;
|
|
2218
2218
|
}
|
|
2219
|
-
unmount(
|
|
2220
|
-
return
|
|
2219
|
+
unmount(e, t) {
|
|
2220
|
+
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
|
|
2221
2221
|
}
|
|
2222
2222
|
};
|
|
2223
|
-
|
|
2224
|
-
let
|
|
2225
|
-
const
|
|
2223
|
+
qe.moduleName = "decorator";
|
|
2224
|
+
let Dt = qe;
|
|
2225
|
+
const Me = "readium-snapper-style", _e = class ee extends Y {
|
|
2226
2226
|
constructor() {
|
|
2227
2227
|
super(...arguments), this.protected = !1;
|
|
2228
2228
|
}
|
|
@@ -2233,62 +2233,62 @@ const Mt = "readium-snapper-style", qt = class tt extends Y {
|
|
|
2233
2233
|
user-select: ${this.protected ? "none" : "auto"};
|
|
2234
2234
|
}`;
|
|
2235
2235
|
}
|
|
2236
|
-
mount(
|
|
2237
|
-
const i =
|
|
2238
|
-
return i.dataset.readium = "true", i.id =
|
|
2236
|
+
mount(e, t) {
|
|
2237
|
+
const i = e.document.createElement("style");
|
|
2238
|
+
return i.dataset.readium = "true", i.id = Me, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", ee.moduleName, (s, n) => {
|
|
2239
2239
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2240
|
-
}),
|
|
2240
|
+
}), t.register("unprotect", ee.moduleName, (s, n) => {
|
|
2241
2241
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2242
|
-
}),
|
|
2242
|
+
}), t.log("Snapper Mounted"), !0;
|
|
2243
2243
|
}
|
|
2244
|
-
unmount(
|
|
2244
|
+
unmount(e, t) {
|
|
2245
2245
|
var i;
|
|
2246
|
-
return (i =
|
|
2246
|
+
return (i = e.document.getElementById(Me)) == null || i.remove(), t.log("Snapper Unmounted"), !0;
|
|
2247
2247
|
}
|
|
2248
2248
|
};
|
|
2249
|
-
|
|
2250
|
-
let
|
|
2249
|
+
_e.moduleName = "snapper";
|
|
2250
|
+
let Xe = _e;
|
|
2251
2251
|
function W(r) {
|
|
2252
2252
|
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2253
2253
|
}
|
|
2254
|
-
function
|
|
2254
|
+
function Ge(r) {
|
|
2255
2255
|
return parseInt(
|
|
2256
2256
|
r.getComputedStyle(
|
|
2257
2257
|
r.document.documentElement
|
|
2258
2258
|
).getPropertyValue("column-count")
|
|
2259
2259
|
);
|
|
2260
2260
|
}
|
|
2261
|
-
function
|
|
2262
|
-
const
|
|
2263
|
-
return r.clientHeight -
|
|
2261
|
+
function Ae(r) {
|
|
2262
|
+
const e = getComputedStyle(r), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
|
|
2263
|
+
return r.clientHeight - t - i;
|
|
2264
2264
|
}
|
|
2265
|
-
function
|
|
2266
|
-
const
|
|
2267
|
-
if (!
|
|
2265
|
+
function Oe(r) {
|
|
2266
|
+
const e = Ge(r);
|
|
2267
|
+
if (!e)
|
|
2268
2268
|
return !1;
|
|
2269
|
-
const
|
|
2270
|
-
for (const h of
|
|
2269
|
+
const t = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2270
|
+
for (const h of t)
|
|
2271
2271
|
h.remove();
|
|
2272
|
-
const i =
|
|
2272
|
+
const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, l = Math.round(s / n * e) % e, c = e === 1 || l === 0 ? 0 : e - l;
|
|
2273
2273
|
if (c > 0)
|
|
2274
2274
|
for (let h = 0; h < c; h++) {
|
|
2275
2275
|
const u = r.document.createElement("div");
|
|
2276
|
-
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height =
|
|
2276
|
+
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = Ae(r.document.documentElement) + "px"), u.innerHTML = "​", r.document.body.appendChild(u);
|
|
2277
2277
|
}
|
|
2278
2278
|
return i !== c;
|
|
2279
2279
|
}
|
|
2280
|
-
function
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2280
|
+
function Wt(r) {
|
|
2281
|
+
const e = r.document.createElement("style");
|
|
2282
|
+
e.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(e), r.document.body.removeChild(e);
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2284
|
+
function Ft(r) {
|
|
2285
2285
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2286
2286
|
}
|
|
2287
2287
|
function T(r) {
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2288
|
+
const e = r.getSelection();
|
|
2289
|
+
e && e.removeAllRanges();
|
|
2290
2290
|
}
|
|
2291
|
-
const
|
|
2291
|
+
const Bt = [
|
|
2292
2292
|
"a",
|
|
2293
2293
|
"audio",
|
|
2294
2294
|
"button",
|
|
@@ -2302,15 +2302,15 @@ const Be = [
|
|
|
2302
2302
|
"textarea",
|
|
2303
2303
|
"video"
|
|
2304
2304
|
];
|
|
2305
|
-
function
|
|
2306
|
-
var
|
|
2307
|
-
return
|
|
2305
|
+
function Ye(r) {
|
|
2306
|
+
var e;
|
|
2307
|
+
return Bt.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && ((e = r.getAttribute("contenteditable")) == null ? void 0 : e.toLowerCase()) !== "false" ? r : r.parentElement ? Ye(r.parentElement) : null;
|
|
2308
2308
|
}
|
|
2309
|
-
function
|
|
2310
|
-
const
|
|
2309
|
+
function Ke(r, e) {
|
|
2310
|
+
const t = Ze(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {
|
|
2311
2311
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2312
2312
|
});
|
|
2313
|
-
return new
|
|
2313
|
+
return new D({
|
|
2314
2314
|
href: "#",
|
|
2315
2315
|
type: "application/xhtml+xml",
|
|
2316
2316
|
locations: new x({
|
|
@@ -2319,40 +2319,40 @@ function Kt(r, t) {
|
|
|
2319
2319
|
])
|
|
2320
2320
|
}),
|
|
2321
2321
|
text: new U({
|
|
2322
|
-
highlight:
|
|
2322
|
+
highlight: t.textContent || void 0
|
|
2323
2323
|
})
|
|
2324
2324
|
});
|
|
2325
2325
|
}
|
|
2326
|
-
function
|
|
2327
|
-
for (var i = 0; i <
|
|
2328
|
-
const s =
|
|
2329
|
-
if (!$
|
|
2330
|
-
return
|
|
2326
|
+
function Ze(r, e, t) {
|
|
2327
|
+
for (var i = 0; i < e.children.length; i++) {
|
|
2328
|
+
const s = e.children[i];
|
|
2329
|
+
if (!$t(s) && Ut(r, s, t))
|
|
2330
|
+
return kt(r, s) ? s : Ze(r, s, t);
|
|
2331
2331
|
}
|
|
2332
|
-
return
|
|
2332
|
+
return e;
|
|
2333
2333
|
}
|
|
2334
|
-
function
|
|
2335
|
-
if (
|
|
2334
|
+
function Ut(r, e, t) {
|
|
2335
|
+
if (e === document.body || e === document.documentElement)
|
|
2336
2336
|
return !0;
|
|
2337
2337
|
if (!document || !document.documentElement || !document.body)
|
|
2338
2338
|
return !1;
|
|
2339
|
-
const i =
|
|
2340
|
-
return
|
|
2341
|
-
}
|
|
2342
|
-
function
|
|
2343
|
-
const
|
|
2344
|
-
return
|
|
2345
|
-
}
|
|
2346
|
-
function $
|
|
2347
|
-
const
|
|
2348
|
-
if (
|
|
2349
|
-
const
|
|
2350
|
-
if (
|
|
2339
|
+
const i = e.getBoundingClientRect();
|
|
2340
|
+
return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2341
|
+
}
|
|
2342
|
+
function kt(r, e) {
|
|
2343
|
+
const t = e.getBoundingClientRect();
|
|
2344
|
+
return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;
|
|
2345
|
+
}
|
|
2346
|
+
function $t(r) {
|
|
2347
|
+
const e = getComputedStyle(r);
|
|
2348
|
+
if (e) {
|
|
2349
|
+
const t = e.getPropertyValue("display");
|
|
2350
|
+
if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
|
|
2351
2351
|
return !0;
|
|
2352
2352
|
}
|
|
2353
2353
|
return !1;
|
|
2354
2354
|
}
|
|
2355
|
-
const
|
|
2355
|
+
const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
2356
2356
|
constructor() {
|
|
2357
2357
|
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);
|
|
2358
2358
|
}
|
|
@@ -2362,12 +2362,12 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2362
2362
|
scrollOffset() {
|
|
2363
2363
|
return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
|
|
2364
2364
|
}
|
|
2365
|
-
snapOffset(
|
|
2366
|
-
const
|
|
2367
|
-
return
|
|
2365
|
+
snapOffset(e) {
|
|
2366
|
+
const t = e + (W(this.wnd) ? -1 : 1);
|
|
2367
|
+
return t - t % this.wnd.innerWidth;
|
|
2368
2368
|
}
|
|
2369
2369
|
reportProgress() {
|
|
2370
|
-
const
|
|
2370
|
+
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));
|
|
2371
2371
|
this.comms.send("progress", {
|
|
2372
2372
|
start: i,
|
|
2373
2373
|
end: s
|
|
@@ -2376,31 +2376,31 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2376
2376
|
shake() {
|
|
2377
2377
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0)
|
|
2378
2378
|
return;
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
const
|
|
2379
|
+
const e = this.doc();
|
|
2380
|
+
e.classList.add(W(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
|
|
2381
|
+
const t = this.scrollOffset();
|
|
2382
2382
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2383
|
-
|
|
2383
|
+
e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
|
|
2384
2384
|
}, 150);
|
|
2385
2385
|
}
|
|
2386
2386
|
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
2387
2387
|
takeOverSnap() {
|
|
2388
|
-
var
|
|
2388
|
+
var t;
|
|
2389
2389
|
this.snappingCancelled = !0, this.clearTouches();
|
|
2390
|
-
const
|
|
2391
|
-
this.overscroll = ((
|
|
2390
|
+
const e = this.doc();
|
|
2391
|
+
this.overscroll = ((t = e.style.transform) == null ? void 0 : t.length) > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;
|
|
2392
2392
|
}
|
|
2393
2393
|
// Snaps the current offset to the page width.
|
|
2394
|
-
snapCurrentOffset(
|
|
2395
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o =
|
|
2394
|
+
snapCurrentOffset(e = !1, t = !1) {
|
|
2395
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), c = W(this.wnd) ? -1 : 1, h = (
|
|
2396
2396
|
// The hurdle to overcome in order to change pages
|
|
2397
2397
|
c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
|
|
2398
2398
|
), u = this.snapOffset(l + h);
|
|
2399
|
-
if (
|
|
2399
|
+
if (e && u !== this.scrollOffset()) {
|
|
2400
2400
|
this.snappingCancelled = !1;
|
|
2401
|
-
const p = (m, v, S, O) => S > O ? v : m + (v - m) *
|
|
2401
|
+
const p = (m, v, S, O) => S > O ? v : m + (v - m) * Ft(S / O), d = (
|
|
2402
2402
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2403
|
-
|
|
2403
|
+
Ht * o
|
|
2404
2404
|
);
|
|
2405
2405
|
let f;
|
|
2406
2406
|
const g = (m) => {
|
|
@@ -2408,12 +2408,12 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2408
2408
|
return;
|
|
2409
2409
|
f || (f = m);
|
|
2410
2410
|
const v = m - f, S = p(this.overscroll, 0, v, d), O = p(i, u, v, d);
|
|
2411
|
-
s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u,
|
|
2411
|
+
s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, t || this.reportProgress());
|
|
2412
2412
|
};
|
|
2413
2413
|
this.wnd.requestAnimationFrame(g);
|
|
2414
2414
|
} else
|
|
2415
2415
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2416
|
-
s.scrollLeft = u, this.clearTouches(),
|
|
2416
|
+
s.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
|
|
2417
2417
|
});
|
|
2418
2418
|
}
|
|
2419
2419
|
dragOffset() {
|
|
@@ -2422,43 +2422,43 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2422
2422
|
clearTouches() {
|
|
2423
2423
|
this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
|
|
2424
2424
|
}
|
|
2425
|
-
onTouchStart(
|
|
2426
|
-
switch (
|
|
2425
|
+
onTouchStart(e) {
|
|
2426
|
+
switch (e.stopPropagation(), this.takeOverSnap(), e.touches.length) {
|
|
2427
2427
|
case 1:
|
|
2428
2428
|
break;
|
|
2429
2429
|
case 2:
|
|
2430
|
-
this.onTouchEnd(
|
|
2430
|
+
this.onTouchEnd(e);
|
|
2431
2431
|
return;
|
|
2432
2432
|
default: {
|
|
2433
|
-
this.onTouchEnd(
|
|
2433
|
+
this.onTouchEnd(e), this.comms.send("tap_more", e.touches.length);
|
|
2434
2434
|
return;
|
|
2435
2435
|
}
|
|
2436
2436
|
}
|
|
2437
|
-
this.startingX =
|
|
2437
|
+
this.startingX = e.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
|
|
2438
2438
|
}
|
|
2439
|
-
onTouchEnd(
|
|
2439
|
+
onTouchEnd(e) {
|
|
2440
2440
|
if (this.touchState === 2) {
|
|
2441
|
-
const
|
|
2442
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(),
|
|
2441
|
+
const t = this.dragOffset(), i = this.scrollOffset();
|
|
2442
|
+
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
|
|
2443
2443
|
}
|
|
2444
2444
|
this.touchState = 0;
|
|
2445
2445
|
}
|
|
2446
2446
|
onWidthChange() {
|
|
2447
2447
|
this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
|
|
2448
2448
|
}
|
|
2449
|
-
onTouchMove(
|
|
2449
|
+
onTouchMove(e) {
|
|
2450
2450
|
if (this.touchState === 0)
|
|
2451
2451
|
return;
|
|
2452
|
-
this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX =
|
|
2453
|
-
const
|
|
2454
|
-
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 +
|
|
2452
|
+
this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = e.touches[0].clientX;
|
|
2453
|
+
const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
|
|
2454
|
+
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);
|
|
2455
2455
|
}
|
|
2456
|
-
mount(
|
|
2457
|
-
if (this.wnd =
|
|
2456
|
+
mount(e, t) {
|
|
2457
|
+
if (this.wnd = e, this.comms = t, !super.mount(e, t))
|
|
2458
2458
|
return !1;
|
|
2459
|
-
|
|
2460
|
-
const i =
|
|
2461
|
-
i.dataset.readium = "true", i.id =
|
|
2459
|
+
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2460
|
+
const i = e.document.createElement("style");
|
|
2461
|
+
i.dataset.readium = "true", i.id = Ie, i.textContent = `
|
|
2462
2462
|
@keyframes readium-bounce-l-animation {
|
|
2463
2463
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2464
2464
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2492,51 +2492,51 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2492
2492
|
body::-webkit-scrollbar {
|
|
2493
2493
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2494
2494
|
}
|
|
2495
|
-
`,
|
|
2496
|
-
|
|
2497
|
-
|
|
2495
|
+
`, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2496
|
+
e.requestAnimationFrame(() => {
|
|
2497
|
+
e && Oe(e);
|
|
2498
2498
|
}), this.onWidthChange();
|
|
2499
|
-
}), this.resizeObserver.observe(
|
|
2499
|
+
}), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2500
2500
|
for (const o of n)
|
|
2501
2501
|
if (o.target === this.wnd.document.documentElement) {
|
|
2502
2502
|
const l = o.oldValue, c = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = l == null ? void 0 : l.match(h), p = c == null ? void 0 : c.match(h);
|
|
2503
|
-
(!u && !p || u && !p || u && p && u[1] !== p[1]) && (
|
|
2504
|
-
|
|
2503
|
+
(!u && !p || u && !p || u && p && u[1] !== p[1]) && (e.requestAnimationFrame(() => {
|
|
2504
|
+
e && Oe(e);
|
|
2505
2505
|
}), this.onWidthChange());
|
|
2506
2506
|
} else
|
|
2507
|
-
|
|
2508
|
-
}),
|
|
2507
|
+
e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2508
|
+
}), 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"] });
|
|
2509
2509
|
const s = (n) => {
|
|
2510
2510
|
const o = this.doc().scrollLeft;
|
|
2511
2511
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2512
2512
|
};
|
|
2513
|
-
return
|
|
2513
|
+
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", w.moduleName, (n, o) => {
|
|
2514
2514
|
const l = n;
|
|
2515
2515
|
if (l < 0 || l > 1) {
|
|
2516
|
-
|
|
2516
|
+
t.send("error", {
|
|
2517
2517
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2518
2518
|
}), o(!1);
|
|
2519
2519
|
return;
|
|
2520
2520
|
}
|
|
2521
2521
|
this.wnd.requestAnimationFrame(() => {
|
|
2522
2522
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2523
|
-
const c = this.cachedScrollWidth, h = W(
|
|
2523
|
+
const c = this.cachedScrollWidth, h = W(e) ? -1 : 1, u = c * l * h;
|
|
2524
2524
|
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), T(this.wnd), o(!0);
|
|
2525
2525
|
});
|
|
2526
|
-
}),
|
|
2527
|
-
const l =
|
|
2526
|
+
}), t.register("go_id", w.moduleName, (n, o) => {
|
|
2527
|
+
const l = e.document.getElementById(n);
|
|
2528
2528
|
if (!l) {
|
|
2529
2529
|
o(!1);
|
|
2530
2530
|
return;
|
|
2531
2531
|
}
|
|
2532
2532
|
this.wnd.requestAnimationFrame(() => {
|
|
2533
|
-
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left +
|
|
2533
|
+
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
|
|
2534
2534
|
});
|
|
2535
|
-
}),
|
|
2535
|
+
}), t.register("go_text", w.moduleName, (n, o) => {
|
|
2536
2536
|
let l;
|
|
2537
2537
|
Array.isArray(n) && (n.length > 1 && (l = n[1]), n = n[0]);
|
|
2538
|
-
const c = U.deserialize(n), h =
|
|
2539
|
-
href:
|
|
2538
|
+
const c = U.deserialize(n), h = le(this.wnd.document, new D({
|
|
2539
|
+
href: e.location.href,
|
|
2540
2540
|
type: "text/html",
|
|
2541
2541
|
text: c,
|
|
2542
2542
|
locations: l ? new x({
|
|
@@ -2550,10 +2550,10 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2550
2550
|
return;
|
|
2551
2551
|
}
|
|
2552
2552
|
this.wnd.requestAnimationFrame(() => {
|
|
2553
|
-
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left +
|
|
2553
|
+
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
|
|
2554
2554
|
});
|
|
2555
|
-
}),
|
|
2556
|
-
const l = W(
|
|
2555
|
+
}), t.register("go_end", w.moduleName, (n, o) => {
|
|
2556
|
+
const l = W(e) ? -1 : 1;
|
|
2557
2557
|
this.wnd.requestAnimationFrame(() => {
|
|
2558
2558
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2559
2559
|
const c = this.cachedScrollWidth * l;
|
|
@@ -2561,69 +2561,77 @@ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
|
|
|
2561
2561
|
return o(!1);
|
|
2562
2562
|
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), T(this.wnd), o(!0);
|
|
2563
2563
|
});
|
|
2564
|
-
}),
|
|
2564
|
+
}), t.register("go_start", w.moduleName, (n, o) => {
|
|
2565
2565
|
this.wnd.requestAnimationFrame(() => {
|
|
2566
2566
|
if (this.doc().scrollLeft === 0)
|
|
2567
2567
|
return o(!1);
|
|
2568
2568
|
this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
|
|
2569
2569
|
});
|
|
2570
|
-
}),
|
|
2570
|
+
}), t.register("go_prev", w.moduleName, (n, o) => {
|
|
2571
2571
|
this.wnd.requestAnimationFrame(() => {
|
|
2572
2572
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2573
|
-
const l =
|
|
2573
|
+
const l = e.scrollX - e.innerWidth, c = W(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(l, c));
|
|
2574
2574
|
h && (this.reportProgress(), T(this.wnd)), o(h);
|
|
2575
2575
|
});
|
|
2576
|
-
}),
|
|
2576
|
+
}), t.register("go_next", w.moduleName, (n, o) => {
|
|
2577
2577
|
this.wnd.requestAnimationFrame(() => {
|
|
2578
2578
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2579
|
-
const l =
|
|
2579
|
+
const l = e.scrollX + e.innerWidth, c = W(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(l, c));
|
|
2580
2580
|
h && (this.reportProgress(), T(this.wnd)), o(h);
|
|
2581
2581
|
});
|
|
2582
|
-
}),
|
|
2582
|
+
}), t.register("unfocus", w.moduleName, (n, o) => {
|
|
2583
2583
|
this.snappingCancelled = !0, T(this.wnd), o(!0);
|
|
2584
|
-
}),
|
|
2584
|
+
}), t.register("shake", w.moduleName, (n, o) => {
|
|
2585
2585
|
this.shake(), o(!0);
|
|
2586
|
-
}),
|
|
2586
|
+
}), t.register("focus", w.moduleName, (n, o) => {
|
|
2587
2587
|
this.wnd.requestAnimationFrame(() => {
|
|
2588
2588
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2589
2589
|
});
|
|
2590
|
-
}),
|
|
2591
|
-
const l =
|
|
2590
|
+
}), t.register("first_visible_locator", w.moduleName, (n, o) => {
|
|
2591
|
+
const l = Ke(e, !1);
|
|
2592
2592
|
this.comms.send("first_visible_locator", l.serialize()), o(!0);
|
|
2593
|
-
}),
|
|
2594
|
-
}),
|
|
2593
|
+
}), 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", () => {
|
|
2594
|
+
}), t.log("ColumnSnapper Mounted"), !0;
|
|
2595
2595
|
}
|
|
2596
|
-
unmount(
|
|
2596
|
+
unmount(e, t) {
|
|
2597
2597
|
var i;
|
|
2598
|
-
return this.snappingCancelled = !0,
|
|
2598
|
+
return this.snappingCancelled = !0, t.unregisterAll(w.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), (i = e.document.getElementById(Ie)) == null || i.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
|
|
2599
2599
|
}
|
|
2600
2600
|
};
|
|
2601
|
-
|
|
2602
|
-
let
|
|
2603
|
-
const
|
|
2601
|
+
Je.moduleName = "column_snapper";
|
|
2602
|
+
let jt = Je;
|
|
2603
|
+
const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
|
|
2604
2604
|
constructor() {
|
|
2605
|
-
super(...arguments), this.
|
|
2606
|
-
|
|
2607
|
-
this.
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2605
|
+
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2606
|
+
if (this.comms.ready && !this.isResizing) {
|
|
2607
|
+
if (!this.initialScrollHandled) {
|
|
2608
|
+
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
2609
|
+
return;
|
|
2610
|
+
}
|
|
2611
|
+
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2612
|
+
this.reportProgress();
|
|
2613
|
+
const e = this.doc().scrollTop, t = e - this.lastScrollTop;
|
|
2614
|
+
this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
|
|
2615
|
+
}));
|
|
2616
|
+
}
|
|
2611
2617
|
};
|
|
2612
2618
|
}
|
|
2613
2619
|
doc() {
|
|
2614
2620
|
return this.wnd.document.scrollingElement;
|
|
2615
2621
|
}
|
|
2616
2622
|
reportProgress() {
|
|
2617
|
-
|
|
2623
|
+
if (!this.comms.ready)
|
|
2624
|
+
return;
|
|
2625
|
+
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));
|
|
2618
2626
|
this.comms.send("progress", {
|
|
2619
2627
|
start: s,
|
|
2620
2628
|
end: n
|
|
2621
2629
|
});
|
|
2622
2630
|
}
|
|
2623
|
-
mount(
|
|
2624
|
-
this.wnd =
|
|
2625
|
-
const i =
|
|
2626
|
-
return i.dataset.readium = "true", i.id =
|
|
2631
|
+
mount(e, t) {
|
|
2632
|
+
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";
|
|
2633
|
+
const i = e.document.createElement("style");
|
|
2634
|
+
return i.dataset.readium = "true", i.id = Le, i.textContent = `
|
|
2627
2635
|
* {
|
|
2628
2636
|
scrollbar-width: none; /* for Firefox */
|
|
2629
2637
|
}
|
|
@@ -2631,18 +2639,18 @@ const Lt = "readium-scroll-snapper-style", Qt = class P extends Xt {
|
|
|
2631
2639
|
body::-webkit-scrollbar {
|
|
2632
2640
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2633
2641
|
}
|
|
2634
|
-
`,
|
|
2635
|
-
this.
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
}), e.register("force_webkit_recalc", P.moduleName, () => {
|
|
2639
|
-
|
|
2642
|
+
`, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2643
|
+
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2644
|
+
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2645
|
+
}, 50);
|
|
2646
|
+
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", P.moduleName, () => {
|
|
2647
|
+
Wt(this.wnd);
|
|
2640
2648
|
const s = this.doc().scrollTop;
|
|
2641
2649
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
2642
|
-
}),
|
|
2650
|
+
}), t.register("go_progression", P.moduleName, (s, n) => {
|
|
2643
2651
|
const o = s;
|
|
2644
2652
|
if (o < 0 || o > 1) {
|
|
2645
|
-
|
|
2653
|
+
t.send("error", {
|
|
2646
2654
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2647
2655
|
}), n(!1);
|
|
2648
2656
|
return;
|
|
@@ -2650,20 +2658,20 @@ const Lt = "readium-scroll-snapper-style", Qt = class P extends Xt {
|
|
|
2650
2658
|
this.wnd.requestAnimationFrame(() => {
|
|
2651
2659
|
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), T(this.wnd), n(!0);
|
|
2652
2660
|
});
|
|
2653
|
-
}),
|
|
2654
|
-
const o =
|
|
2661
|
+
}), t.register("go_id", P.moduleName, (s, n) => {
|
|
2662
|
+
const o = e.document.getElementById(s);
|
|
2655
2663
|
if (!o) {
|
|
2656
2664
|
n(!1);
|
|
2657
2665
|
return;
|
|
2658
2666
|
}
|
|
2659
2667
|
this.wnd.requestAnimationFrame(() => {
|
|
2660
|
-
this.doc().scrollTop = o.getBoundingClientRect().top +
|
|
2668
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
|
|
2661
2669
|
});
|
|
2662
|
-
}),
|
|
2670
|
+
}), t.register("go_text", P.moduleName, (s, n) => {
|
|
2663
2671
|
let o;
|
|
2664
2672
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
2665
|
-
const l = U.deserialize(s), c =
|
|
2666
|
-
href:
|
|
2673
|
+
const l = U.deserialize(s), c = le(this.wnd.document, new D({
|
|
2674
|
+
href: e.location.href,
|
|
2667
2675
|
type: "text/html",
|
|
2668
2676
|
text: l,
|
|
2669
2677
|
locations: o ? new x({
|
|
@@ -2677,48 +2685,48 @@ const Lt = "readium-scroll-snapper-style", Qt = class P extends Xt {
|
|
|
2677
2685
|
return;
|
|
2678
2686
|
}
|
|
2679
2687
|
this.wnd.requestAnimationFrame(() => {
|
|
2680
|
-
this.doc().scrollTop = c.getBoundingClientRect().top +
|
|
2688
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
|
|
2681
2689
|
});
|
|
2682
|
-
}),
|
|
2690
|
+
}), t.register("go_start", P.moduleName, (s, n) => {
|
|
2683
2691
|
if (this.doc().scrollTop === 0)
|
|
2684
2692
|
return n(!1);
|
|
2685
2693
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
2686
|
-
}),
|
|
2694
|
+
}), t.register("go_end", P.moduleName, (s, n) => {
|
|
2687
2695
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight)
|
|
2688
2696
|
return n(!1);
|
|
2689
2697
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
2690
|
-
}),
|
|
2698
|
+
}), t.register("unfocus", P.moduleName, (s, n) => {
|
|
2691
2699
|
T(this.wnd), n(!0);
|
|
2692
|
-
}),
|
|
2700
|
+
}), t.register([
|
|
2693
2701
|
"go_next",
|
|
2694
2702
|
"go_prev"
|
|
2695
|
-
], P.moduleName, (s, n) => n(!1)),
|
|
2703
|
+
], P.moduleName, (s, n) => n(!1)), t.register("focus", P.moduleName, (s, n) => {
|
|
2696
2704
|
this.reportProgress(), n(!0);
|
|
2697
|
-
}),
|
|
2698
|
-
const o =
|
|
2705
|
+
}), t.register("first_visible_locator", P.moduleName, (s, n) => {
|
|
2706
|
+
const o = Ke(e, !0);
|
|
2699
2707
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2700
|
-
}),
|
|
2708
|
+
}), t.log("ScrollSnapper Mounted"), !0;
|
|
2701
2709
|
}
|
|
2702
|
-
unmount(
|
|
2710
|
+
unmount(e, t) {
|
|
2703
2711
|
var i;
|
|
2704
|
-
return
|
|
2712
|
+
return t.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), (i = e.document.getElementById(Le)) == null || i.remove(), t.log("ScrollSnapper Unmounted"), !0;
|
|
2705
2713
|
}
|
|
2706
2714
|
};
|
|
2707
|
-
|
|
2708
|
-
let
|
|
2709
|
-
class
|
|
2715
|
+
Qe.moduleName = "scroll_snapper";
|
|
2716
|
+
let Vt = Qe;
|
|
2717
|
+
class et extends Y {
|
|
2710
2718
|
constructor() {
|
|
2711
2719
|
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);
|
|
2712
2720
|
}
|
|
2713
|
-
onPointUp(
|
|
2721
|
+
onPointUp(e) {
|
|
2714
2722
|
var s, n, o, l, c;
|
|
2715
|
-
const
|
|
2716
|
-
if (
|
|
2717
|
-
const h = (n =
|
|
2723
|
+
const t = this.wnd.getSelection();
|
|
2724
|
+
if (t && ((s = t.toString()) == null ? void 0 : s.length) > 0) {
|
|
2725
|
+
const h = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
|
|
2718
2726
|
if (!h || h.length === 0)
|
|
2719
2727
|
return;
|
|
2720
2728
|
const u = h[0], p = {
|
|
2721
|
-
text:
|
|
2729
|
+
text: t.toString(),
|
|
2722
2730
|
x: u.x,
|
|
2723
2731
|
y: u.y,
|
|
2724
2732
|
width: u.width,
|
|
@@ -2731,22 +2739,22 @@ class te extends Y {
|
|
|
2731
2739
|
this.pointerMoved = !1;
|
|
2732
2740
|
return;
|
|
2733
2741
|
}
|
|
2734
|
-
if (!(
|
|
2742
|
+
if (!(t != null && t.isCollapsed) || !e.isPrimary)
|
|
2735
2743
|
return;
|
|
2736
2744
|
const i = this.wnd.devicePixelRatio;
|
|
2737
|
-
|
|
2738
|
-
defaultPrevented:
|
|
2739
|
-
x:
|
|
2740
|
-
y:
|
|
2745
|
+
e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
|
|
2746
|
+
defaultPrevented: e.defaultPrevented,
|
|
2747
|
+
x: e.clientX * i,
|
|
2748
|
+
y: e.clientY * i,
|
|
2741
2749
|
targetFrameSrc: this.wnd.location.href,
|
|
2742
|
-
targetElement:
|
|
2743
|
-
interactiveElement: (c =
|
|
2744
|
-
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(
|
|
2750
|
+
targetElement: e.target.outerHTML,
|
|
2751
|
+
interactiveElement: (c = Ye(e.target)) == null ? void 0 : c.outerHTML,
|
|
2752
|
+
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
|
|
2745
2753
|
}), this.pointerMoved = !1;
|
|
2746
2754
|
}
|
|
2747
|
-
onPointMove(
|
|
2748
|
-
if (
|
|
2749
|
-
(Math.abs(
|
|
2755
|
+
onPointMove(e) {
|
|
2756
|
+
if (e.movementY !== void 0 && e.movementX !== void 0) {
|
|
2757
|
+
(Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) && (this.pointerMoved = !0);
|
|
2750
2758
|
return;
|
|
2751
2759
|
}
|
|
2752
2760
|
this.pointerMoved = !0;
|
|
@@ -2754,84 +2762,84 @@ class te extends Y {
|
|
|
2754
2762
|
onPointDown() {
|
|
2755
2763
|
this.pointerMoved = !1;
|
|
2756
2764
|
}
|
|
2757
|
-
onContext(
|
|
2758
|
-
this.onPointUp(
|
|
2765
|
+
onContext(e) {
|
|
2766
|
+
this.onPointUp(e), this.pointerMoved = !1;
|
|
2759
2767
|
}
|
|
2760
|
-
onClick(
|
|
2761
|
-
if (
|
|
2762
|
-
const
|
|
2768
|
+
onClick(e) {
|
|
2769
|
+
if (e.preventDefault(), !e.isTrusted) {
|
|
2770
|
+
const t = new PointerEvent("pointerup", {
|
|
2763
2771
|
isPrimary: !0,
|
|
2764
2772
|
pointerType: "mouse",
|
|
2765
2773
|
// Not really a better choice than this
|
|
2766
|
-
clientX:
|
|
2767
|
-
clientY:
|
|
2774
|
+
clientX: e.clientX,
|
|
2775
|
+
clientY: e.clientY
|
|
2768
2776
|
});
|
|
2769
|
-
Object.defineProperty(
|
|
2777
|
+
Object.defineProperty(t, "target", { writable: !1, value: e.target }), Object.defineProperty(t, "defaultPrevented", { writable: !1, value: e.defaultPrevented }), this.onPointUp(t);
|
|
2770
2778
|
}
|
|
2771
2779
|
}
|
|
2772
|
-
mount(
|
|
2773
|
-
return this.wnd =
|
|
2780
|
+
mount(e, t) {
|
|
2781
|
+
return this.wnd = e, this.comms = t, e.document.addEventListener("pointerdown", this.onPointerDown), e.document.addEventListener("pointerup", this.onPointerUp), e.document.addEventListener("contextmenu", this.onContextMenu), e.document.addEventListener("pointermove", this.onPointerMove), e.document.addEventListener("click", this.onClicker), t.log("Peripherals Mounted"), !0;
|
|
2774
2782
|
}
|
|
2775
|
-
unmount(
|
|
2776
|
-
return
|
|
2783
|
+
unmount(e, t) {
|
|
2784
|
+
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;
|
|
2777
2785
|
}
|
|
2778
2786
|
}
|
|
2779
|
-
|
|
2780
|
-
const
|
|
2787
|
+
et.moduleName = "peripherals";
|
|
2788
|
+
const tt = class te extends Y {
|
|
2781
2789
|
constructor() {
|
|
2782
2790
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
2783
2791
|
}
|
|
2784
|
-
wndOnErr(
|
|
2785
|
-
var
|
|
2786
|
-
(
|
|
2787
|
-
message:
|
|
2788
|
-
filename:
|
|
2789
|
-
lineno:
|
|
2790
|
-
colno:
|
|
2792
|
+
wndOnErr(e) {
|
|
2793
|
+
var t;
|
|
2794
|
+
(t = this.comms) == null || t.send("error", {
|
|
2795
|
+
message: e.message,
|
|
2796
|
+
filename: e.filename,
|
|
2797
|
+
lineno: e.lineno,
|
|
2798
|
+
colno: e.colno
|
|
2791
2799
|
});
|
|
2792
2800
|
}
|
|
2793
|
-
unblock(
|
|
2794
|
-
var
|
|
2795
|
-
for (
|
|
2796
|
-
const i =
|
|
2801
|
+
unblock(e) {
|
|
2802
|
+
var t;
|
|
2803
|
+
for (e._readium_blockEvents = !1; ((t = e._readium_blockedEvents) == null ? void 0 : t.length) > 0; ) {
|
|
2804
|
+
const i = e._readium_blockedEvents.shift();
|
|
2797
2805
|
switch (i[0]) {
|
|
2798
2806
|
case 0:
|
|
2799
2807
|
Reflect.apply(i[1], i[2], i[3]);
|
|
2800
2808
|
break;
|
|
2801
2809
|
case 1:
|
|
2802
2810
|
const s = i[1], n = i[2];
|
|
2803
|
-
|
|
2811
|
+
e.removeEventListener(s.type, e._readium_eventBlocker, !0);
|
|
2804
2812
|
const o = new Event(s.type, {
|
|
2805
2813
|
bubbles: s.bubbles,
|
|
2806
2814
|
cancelable: s.cancelable
|
|
2807
2815
|
});
|
|
2808
|
-
n ? n.dispatchEvent(o) :
|
|
2816
|
+
n ? n.dispatchEvent(o) : e.dispatchEvent(o);
|
|
2809
2817
|
break;
|
|
2810
2818
|
}
|
|
2811
2819
|
}
|
|
2812
2820
|
}
|
|
2813
2821
|
onMediaPlayEvent() {
|
|
2814
|
-
var
|
|
2815
|
-
this.mediaPlayingCount++, (
|
|
2822
|
+
var e;
|
|
2823
|
+
this.mediaPlayingCount++, (e = this.comms) == null || e.send("media_play", this.mediaPlayingCount);
|
|
2816
2824
|
}
|
|
2817
2825
|
onMediaPauseEvent() {
|
|
2818
|
-
var
|
|
2819
|
-
this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (
|
|
2826
|
+
var e;
|
|
2827
|
+
this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (e = this.comms) == null || e.send("media_pause", this.mediaPlayingCount);
|
|
2820
2828
|
}
|
|
2821
|
-
pauseAllMedia(
|
|
2822
|
-
const
|
|
2823
|
-
for (let i = 0; i <
|
|
2824
|
-
|
|
2829
|
+
pauseAllMedia(e) {
|
|
2830
|
+
const t = e.document.querySelectorAll("audio,video");
|
|
2831
|
+
for (let i = 0; i < t.length; i++)
|
|
2832
|
+
t[i].pause();
|
|
2825
2833
|
}
|
|
2826
|
-
mount(
|
|
2827
|
-
this.comms =
|
|
2834
|
+
mount(e, t) {
|
|
2835
|
+
this.comms = t, e.addEventListener(
|
|
2828
2836
|
"error",
|
|
2829
2837
|
this.wndOnErr,
|
|
2830
2838
|
!1
|
|
2831
|
-
), Reflect.defineProperty(
|
|
2839
|
+
), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
|
|
2832
2840
|
value: {
|
|
2833
2841
|
name: "readium-ts-toolkit",
|
|
2834
|
-
version: "2.0.0-beta.
|
|
2842
|
+
version: "2.0.0-beta.7",
|
|
2835
2843
|
hasFeature: (s, n = "") => {
|
|
2836
2844
|
switch (s) {
|
|
2837
2845
|
case "dom-manipulation":
|
|
@@ -2854,16 +2862,16 @@ const ee = class et extends Y {
|
|
|
2854
2862
|
}
|
|
2855
2863
|
},
|
|
2856
2864
|
writable: !1
|
|
2857
|
-
}), "getAnimations" in
|
|
2865
|
+
}), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {
|
|
2858
2866
|
s.cancel(), this.allAnimations.add(s);
|
|
2859
|
-
}),
|
|
2867
|
+
}), t.register("activate", te.moduleName, (s, n) => {
|
|
2860
2868
|
this.allAnimations.forEach((o) => {
|
|
2861
2869
|
o.cancel(), o.play();
|
|
2862
2870
|
}), n(!0);
|
|
2863
|
-
}),
|
|
2864
|
-
this.pauseAllMedia(
|
|
2871
|
+
}), t.register("unfocus", te.moduleName, (s, n) => {
|
|
2872
|
+
this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
2865
2873
|
});
|
|
2866
|
-
const i =
|
|
2874
|
+
const i = e.document.querySelectorAll("audio,video");
|
|
2867
2875
|
for (let s = 0; s < i.length; s++) {
|
|
2868
2876
|
const n = i[s];
|
|
2869
2877
|
n.addEventListener("play", this.onMediaPlayEvent, {
|
|
@@ -2872,55 +2880,55 @@ const ee = class et extends Y {
|
|
|
2872
2880
|
passive: !0
|
|
2873
2881
|
});
|
|
2874
2882
|
}
|
|
2875
|
-
return
|
|
2883
|
+
return t.log("Setup Mounted"), !0;
|
|
2876
2884
|
}
|
|
2877
|
-
unmount(
|
|
2878
|
-
return
|
|
2885
|
+
unmount(e, t) {
|
|
2886
|
+
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;
|
|
2879
2887
|
}
|
|
2880
2888
|
};
|
|
2881
|
-
|
|
2882
|
-
let
|
|
2883
|
-
const
|
|
2884
|
-
onViewportWidthChanged(
|
|
2885
|
-
const
|
|
2886
|
-
G(
|
|
2887
|
-
}
|
|
2888
|
-
mount(
|
|
2889
|
-
if (!super.mount(
|
|
2889
|
+
tt.moduleName = "setup";
|
|
2890
|
+
let it = tt;
|
|
2891
|
+
const Re = "readium-viewport", rt = class F extends it {
|
|
2892
|
+
onViewportWidthChanged(e) {
|
|
2893
|
+
const t = e.target;
|
|
2894
|
+
G(t, "--RS__viewportWidth", `${t.innerWidth}px`);
|
|
2895
|
+
}
|
|
2896
|
+
mount(e, t) {
|
|
2897
|
+
if (!super.mount(e, t))
|
|
2890
2898
|
return !1;
|
|
2891
|
-
const i =
|
|
2892
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
2899
|
+
const i = e.document.createElement("meta");
|
|
2900
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Re), i.setAttribute(
|
|
2893
2901
|
"content",
|
|
2894
2902
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
2895
|
-
),
|
|
2896
|
-
target:
|
|
2897
|
-
}),
|
|
2898
|
-
|
|
2899
|
-
}),
|
|
2900
|
-
s["--RS__viewportWidth"] = `${
|
|
2901
|
-
}),
|
|
2903
|
+
), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
2904
|
+
target: e
|
|
2905
|
+
}), t.register("get_properties", F.moduleName, (s, n) => {
|
|
2906
|
+
Ve(e), n(!0);
|
|
2907
|
+
}), t.register("update_properties", F.moduleName, (s, n) => {
|
|
2908
|
+
s["--RS__viewportWidth"] = `${e.innerWidth}px`, Nt(e, s), n(!0);
|
|
2909
|
+
}), t.register("set_property", F.moduleName, (s, n) => {
|
|
2902
2910
|
const o = s;
|
|
2903
|
-
G(
|
|
2904
|
-
}),
|
|
2905
|
-
|
|
2906
|
-
}),
|
|
2907
|
-
this.unblock(
|
|
2908
|
-
}),
|
|
2909
|
-
}
|
|
2910
|
-
unmount(
|
|
2911
|
+
G(e, o[0], o[1]), n(!0);
|
|
2912
|
+
}), t.register("remove_property", F.moduleName, (s, n) => {
|
|
2913
|
+
he(e, s), n(!0);
|
|
2914
|
+
}), t.register("activate", F.moduleName, (s, n) => {
|
|
2915
|
+
this.unblock(e), n(!0);
|
|
2916
|
+
}), t.log("ReflowableSetup Mounted"), !0;
|
|
2917
|
+
}
|
|
2918
|
+
unmount(e, t) {
|
|
2911
2919
|
var i;
|
|
2912
|
-
return
|
|
2920
|
+
return t.unregisterAll(F.moduleName), (i = e.document.head.querySelector(`#${Re}`)) == null || i.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
|
|
2913
2921
|
}
|
|
2914
2922
|
};
|
|
2915
|
-
|
|
2916
|
-
let
|
|
2917
|
-
const
|
|
2918
|
-
mount(
|
|
2919
|
-
if (!super.mount(
|
|
2923
|
+
rt.moduleName = "reflowable_setup";
|
|
2924
|
+
let qt = rt;
|
|
2925
|
+
const ze = "readium-fixed-style", st = class L extends it {
|
|
2926
|
+
mount(e, t) {
|
|
2927
|
+
if (!super.mount(e, t))
|
|
2920
2928
|
return !1;
|
|
2921
|
-
|
|
2922
|
-
const i =
|
|
2923
|
-
return i.id =
|
|
2929
|
+
e.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2930
|
+
const i = e.document.createElement("style");
|
|
2931
|
+
return i.id = ze, i.dataset.readium = "true", i.textContent = `
|
|
2924
2932
|
html, body {
|
|
2925
2933
|
text-size-adjust: none;
|
|
2926
2934
|
-ms-text-size-adjust: none;
|
|
@@ -2932,14 +2940,14 @@ const Dt = "readium-fixed-style", se = class L extends ie {
|
|
|
2932
2940
|
min-height: 100%;
|
|
2933
2941
|
|
|
2934
2942
|
/*cursor: var() TODO*/
|
|
2935
|
-
}`,
|
|
2943
|
+
}`, e.document.head.appendChild(i), t.register("set_property", L.moduleName, (s, n) => {
|
|
2936
2944
|
const o = s;
|
|
2937
|
-
G(
|
|
2938
|
-
}),
|
|
2939
|
-
|
|
2940
|
-
}),
|
|
2941
|
-
T(
|
|
2942
|
-
}),
|
|
2945
|
+
G(e, o[0], o[1]), n(!0);
|
|
2946
|
+
}), t.register("remove_property", L.moduleName, (s, n) => {
|
|
2947
|
+
he(e, s), n(!0);
|
|
2948
|
+
}), t.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), t.register("unfocus", L.moduleName, (s, n) => {
|
|
2949
|
+
T(e), n(!0);
|
|
2950
|
+
}), t.register([
|
|
2943
2951
|
"focus",
|
|
2944
2952
|
"go_next",
|
|
2945
2953
|
"go_prev",
|
|
@@ -2948,97 +2956,97 @@ const Dt = "readium-fixed-style", se = class L extends ie {
|
|
|
2948
2956
|
"go_start",
|
|
2949
2957
|
"go_text",
|
|
2950
2958
|
"go_progression"
|
|
2951
|
-
], L.moduleName, (s, n) => n(!0)),
|
|
2952
|
-
this.unblock(
|
|
2953
|
-
}),
|
|
2959
|
+
], L.moduleName, (s, n) => n(!0)), t.register("activate", L.moduleName, (s, n) => {
|
|
2960
|
+
this.unblock(e), n(!0);
|
|
2961
|
+
}), t.log("FixedSetup Mounted"), !0;
|
|
2954
2962
|
}
|
|
2955
|
-
unmount(
|
|
2963
|
+
unmount(e, t) {
|
|
2956
2964
|
var i;
|
|
2957
|
-
return
|
|
2965
|
+
return t.unregisterAll(L.moduleName), (i = e.document.getElementById(ze)) == null || i.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
|
|
2958
2966
|
}
|
|
2959
2967
|
};
|
|
2960
|
-
|
|
2961
|
-
let
|
|
2962
|
-
const
|
|
2968
|
+
st.moduleName = "fixed_setup";
|
|
2969
|
+
let _t = st;
|
|
2970
|
+
const Xt = [
|
|
2963
2971
|
"fixed_setup",
|
|
2964
2972
|
"decorator",
|
|
2965
2973
|
"peripherals"
|
|
2966
|
-
],
|
|
2974
|
+
], Gt = [
|
|
2967
2975
|
"reflowable_setup",
|
|
2968
2976
|
"decorator",
|
|
2969
2977
|
"peripherals",
|
|
2970
2978
|
"column_snapper",
|
|
2971
2979
|
"scroll_snapper"
|
|
2972
|
-
],
|
|
2980
|
+
], De = new Map([
|
|
2973
2981
|
// All modules go here
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2982
|
+
_t,
|
|
2983
|
+
qt,
|
|
2984
|
+
et,
|
|
2985
|
+
Dt,
|
|
2986
|
+
jt,
|
|
2987
|
+
Vt
|
|
2980
2988
|
].map((r) => [r.moduleName, r]));
|
|
2981
|
-
class
|
|
2989
|
+
class Yt {
|
|
2982
2990
|
/**
|
|
2983
2991
|
* @param wnd Window instance to operate on
|
|
2984
2992
|
* @param initialModules List of initial modules to load
|
|
2985
2993
|
*/
|
|
2986
|
-
constructor(
|
|
2987
|
-
this.loadedModules = [], this.wnd =
|
|
2988
|
-
const i = [...new Set(
|
|
2994
|
+
constructor(e = window, t = []) {
|
|
2995
|
+
this.loadedModules = [], this.wnd = e, this.comms = new at(e);
|
|
2996
|
+
const i = [...new Set(t)];
|
|
2989
2997
|
if (i.length) {
|
|
2990
|
-
if (typeof
|
|
2998
|
+
if (typeof e > "u")
|
|
2991
2999
|
throw Error("Loader is not in a web browser");
|
|
2992
|
-
|
|
3000
|
+
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
|
|
2993
3001
|
const n = this.loadModule(s);
|
|
2994
3002
|
if (n)
|
|
2995
3003
|
return n.mount(this.wnd, this.comms), n;
|
|
2996
3004
|
}).filter((s) => s !== void 0);
|
|
2997
3005
|
}
|
|
2998
3006
|
}
|
|
2999
|
-
loadModule(
|
|
3000
|
-
const
|
|
3001
|
-
return
|
|
3007
|
+
loadModule(e) {
|
|
3008
|
+
const t = De.get(e);
|
|
3009
|
+
return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
|
|
3002
3010
|
}
|
|
3003
3011
|
/**
|
|
3004
3012
|
* Add a module by name
|
|
3005
3013
|
* @param moduleName Module name
|
|
3006
3014
|
* @returns Success
|
|
3007
3015
|
*/
|
|
3008
|
-
addModule(
|
|
3009
|
-
const
|
|
3010
|
-
return !
|
|
3016
|
+
addModule(e) {
|
|
3017
|
+
const t = this.loadModule(e);
|
|
3018
|
+
return !t || !t.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(t), !0);
|
|
3011
3019
|
}
|
|
3012
3020
|
/**
|
|
3013
3021
|
* Remove a module by name
|
|
3014
3022
|
* @param moduleName Module name
|
|
3015
3023
|
* @returns Success
|
|
3016
3024
|
*/
|
|
3017
|
-
removeModule(
|
|
3018
|
-
const
|
|
3019
|
-
if (
|
|
3020
|
-
return this.comms.log(`Module "${
|
|
3021
|
-
const i = this.loadedModules.findIndex((s) => s instanceof
|
|
3025
|
+
removeModule(e) {
|
|
3026
|
+
const t = De.get(e);
|
|
3027
|
+
if (t === void 0)
|
|
3028
|
+
return this.comms.log(`Module "${e}" does not exist in the library`), !1;
|
|
3029
|
+
const i = this.loadedModules.findIndex((s) => s instanceof t);
|
|
3022
3030
|
return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
|
|
3023
3031
|
}
|
|
3024
3032
|
/**
|
|
3025
3033
|
* Unmount and remove all modules
|
|
3026
3034
|
*/
|
|
3027
3035
|
destroy() {
|
|
3028
|
-
this.comms.destroy(), this.loadedModules.forEach((
|
|
3036
|
+
this.comms.destroy(), this.loadedModules.forEach((e) => e.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3029
3037
|
}
|
|
3030
3038
|
}
|
|
3031
3039
|
export {
|
|
3032
3040
|
k as COMMS_VERSION,
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3041
|
+
at as Comms,
|
|
3042
|
+
Dt as Decorator,
|
|
3043
|
+
Xt as FXLModules,
|
|
3044
|
+
Lt as Layout,
|
|
3045
|
+
Yt as Loader,
|
|
3038
3046
|
Y as Module,
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3047
|
+
De as ModuleLibrary,
|
|
3048
|
+
et as Peripherals,
|
|
3049
|
+
Gt as ReflowableModules,
|
|
3050
|
+
It as Width,
|
|
3051
|
+
ot as mid
|
|
3044
3052
|
};
|