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