@readium/navigator-html-injectables 2.2.0 → 2.2.2
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 +858 -777
- package/dist/index.umd.cjs +12 -11
- package/package.json +3 -3
- package/src/helpers/color.ts +190 -99
- package/src/modules/Decorator.ts +70 -9
- package/src/modules/setup/WebPubSetup.ts +22 -2
- package/types/src/helpers/color.d.ts +16 -6
- package/types/src/modules/Decorator.d.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const dt = Math.pow(2, 32), Le = () => Math.round(Math.random() * dt).toString(36), pt = () => `${Math.round(performance.now())}-${Le()}-${Le()}`, k = 1;
|
|
2
|
+
class ft {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
@@ -10,8 +10,8 @@ class tt {
|
|
|
10
10
|
if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
|
|
11
11
|
if (t.key === "_ping") {
|
|
12
12
|
if (!this.destination) {
|
|
13
|
-
if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !==
|
|
14
|
-
t._readium >
|
|
13
|
+
if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== k) {
|
|
14
|
+
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 = "";
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
@@ -30,21 +30,21 @@ class tt {
|
|
|
30
30
|
e.strict && this.send("_unhandled", e);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
t.forEach((i) => i.cb(e.data, (
|
|
34
|
-
this.send("_ack",
|
|
33
|
+
t.forEach((i) => i.cb(e.data, (r) => {
|
|
34
|
+
this.send("_ack", r, e.id);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
register(e, t, i) {
|
|
38
|
-
Array.isArray(e) || (e = [e]), e.forEach((
|
|
39
|
-
const n = this.registrar.get(
|
|
38
|
+
Array.isArray(e) || (e = [e]), e.forEach((r) => {
|
|
39
|
+
const n = this.registrar.get(r);
|
|
40
40
|
if (n && n.length >= 0) {
|
|
41
|
-
if (n.find((
|
|
41
|
+
if (n.find((a) => a.module === t)) throw new Error(`Trying to register another callback for combination of event ${r} and module ${t}`);
|
|
42
42
|
n.push({
|
|
43
43
|
cb: i,
|
|
44
44
|
module: t
|
|
45
|
-
}), this.registrar.set(
|
|
45
|
+
}), this.registrar.set(r, n);
|
|
46
46
|
} else
|
|
47
|
-
this.registrar.set(
|
|
47
|
+
this.registrar.set(r, [{
|
|
48
48
|
cb: i,
|
|
49
49
|
module: t
|
|
50
50
|
}]);
|
|
@@ -52,12 +52,12 @@ class tt {
|
|
|
52
52
|
}
|
|
53
53
|
unregister(e, t) {
|
|
54
54
|
Array.isArray(e) || (e = [e]), e.forEach((i) => {
|
|
55
|
-
const
|
|
56
|
-
!
|
|
55
|
+
const r = this.registrar.get(i);
|
|
56
|
+
!r || r.length === 0 || r.splice(r.findIndex((n) => n.module === t), 1);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
unregisterAll(e) {
|
|
60
|
-
this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((
|
|
60
|
+
this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((r) => r.module !== e)));
|
|
61
61
|
}
|
|
62
62
|
log(...e) {
|
|
63
63
|
this.destination ? this.send("log", e) : this.preLog.push(e);
|
|
@@ -68,12 +68,12 @@ class tt {
|
|
|
68
68
|
destroy() {
|
|
69
69
|
this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
|
|
70
70
|
}
|
|
71
|
-
send(e, t, i = void 0,
|
|
71
|
+
send(e, t, i = void 0, r = []) {
|
|
72
72
|
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
73
|
const n = {
|
|
74
|
-
_readium:
|
|
74
|
+
_readium: k,
|
|
75
75
|
_channel: this.channelId,
|
|
76
|
-
id: i ??
|
|
76
|
+
id: i ?? pt(),
|
|
77
77
|
// scrict,
|
|
78
78
|
key: e,
|
|
79
79
|
data: t
|
|
@@ -81,23 +81,23 @@ class tt {
|
|
|
81
81
|
try {
|
|
82
82
|
this.destination.postMessage(n, {
|
|
83
83
|
targetOrigin: this.origin,
|
|
84
|
-
transfer:
|
|
84
|
+
transfer: r
|
|
85
85
|
});
|
|
86
86
|
} catch (o) {
|
|
87
|
-
if (
|
|
88
|
-
this.destination.postMessage(n, this.origin,
|
|
87
|
+
if (r.length > 0) throw o;
|
|
88
|
+
this.destination.postMessage(n, this.origin, r);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const N = class
|
|
92
|
+
const N = class U {
|
|
93
93
|
constructor(e) {
|
|
94
94
|
if (typeof e == "string") {
|
|
95
|
-
if (!
|
|
95
|
+
if (!U.VALID_MODES.has(e.toLowerCase()))
|
|
96
96
|
return;
|
|
97
97
|
this.value = e.toLowerCase();
|
|
98
98
|
} else {
|
|
99
99
|
const t = e.filter(
|
|
100
|
-
(i) =>
|
|
100
|
+
(i) => U.VALID_MODES.has(i.toLowerCase())
|
|
101
101
|
);
|
|
102
102
|
if (t.length === 0)
|
|
103
103
|
return;
|
|
@@ -110,11 +110,11 @@ const N = class W {
|
|
|
110
110
|
static deserialize(e) {
|
|
111
111
|
if (!e) return;
|
|
112
112
|
if (typeof e == "string")
|
|
113
|
-
return new
|
|
113
|
+
return new U(e);
|
|
114
114
|
if (!Array.isArray(e)) return;
|
|
115
|
-
const t = e.filter((i) => i ?
|
|
115
|
+
const t = e.filter((i) => i ? U.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
116
116
|
if (t.length !== 0)
|
|
117
|
-
return new
|
|
117
|
+
return new U(t);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
@@ -124,7 +124,7 @@ const N = class W {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
|
|
127
|
-
class
|
|
127
|
+
class Te {
|
|
128
128
|
/**
|
|
129
129
|
* Creates a [Encryption].
|
|
130
130
|
*/
|
|
@@ -136,7 +136,7 @@ class ue {
|
|
|
136
136
|
*/
|
|
137
137
|
static deserialize(e) {
|
|
138
138
|
if (e && e.algorithm)
|
|
139
|
-
return new
|
|
139
|
+
return new Te({
|
|
140
140
|
algorithm: e.algorithm,
|
|
141
141
|
compression: e.compression,
|
|
142
142
|
originalLength: e.originalLength,
|
|
@@ -184,58 +184,58 @@ class C {
|
|
|
184
184
|
}
|
|
185
185
|
Object.defineProperty(C.prototype, "encryption", {
|
|
186
186
|
get: function() {
|
|
187
|
-
return
|
|
187
|
+
return Te.deserialize(this.otherProperties.encrypted);
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
|
-
function
|
|
191
|
-
return
|
|
190
|
+
function mt(s) {
|
|
191
|
+
return s && Array.isArray(s) ? s : void 0;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
193
|
+
function Qe(s) {
|
|
194
|
+
return s && typeof s == "string" ? [s] : mt(s);
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
return typeof
|
|
196
|
+
function Re(s) {
|
|
197
|
+
return typeof s == "string" ? new Date(s) : void 0;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return isNaN(
|
|
199
|
+
function Q(s) {
|
|
200
|
+
return isNaN(s) ? void 0 : s;
|
|
201
201
|
}
|
|
202
|
-
function S(
|
|
203
|
-
return
|
|
202
|
+
function S(s) {
|
|
203
|
+
return Q(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function gt(s) {
|
|
206
206
|
const e = new Array();
|
|
207
|
-
return
|
|
207
|
+
return s.forEach((t) => e.push(t)), e;
|
|
208
208
|
}
|
|
209
|
-
class
|
|
209
|
+
class l {
|
|
210
210
|
/** Creates a MediaType object. */
|
|
211
211
|
constructor(e) {
|
|
212
|
-
let t, i,
|
|
213
|
-
const n =
|
|
212
|
+
let t, i, r = e.mediaType.replace(/\s/g, "").split(";");
|
|
213
|
+
const n = r[0].split("/");
|
|
214
214
|
if (n.length === 2) {
|
|
215
215
|
if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
|
|
216
216
|
throw new Error("Invalid media type");
|
|
217
217
|
} else
|
|
218
218
|
throw new Error("Invalid media type");
|
|
219
219
|
const o = {};
|
|
220
|
-
for (let
|
|
221
|
-
const y =
|
|
220
|
+
for (let d = 1; d < r.length; d++) {
|
|
221
|
+
const y = r[d].split("=");
|
|
222
222
|
if (y.length === 2) {
|
|
223
|
-
const
|
|
224
|
-
o[
|
|
223
|
+
const p = y[0].toLocaleLowerCase(), f = p === "charset" ? y[1].toUpperCase() : y[1];
|
|
224
|
+
o[p] = f;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
const
|
|
228
|
-
u.sort((
|
|
227
|
+
const a = {}, u = Object.keys(o);
|
|
228
|
+
u.sort((d, y) => d.localeCompare(y)), u.forEach((d) => a[d] = o[d]);
|
|
229
229
|
let h = "";
|
|
230
|
-
for (const
|
|
231
|
-
const y =
|
|
232
|
-
h += `;${
|
|
230
|
+
for (const d in a) {
|
|
231
|
+
const y = a[d];
|
|
232
|
+
h += `;${d}=${y}`;
|
|
233
233
|
}
|
|
234
|
-
const c = `${t}/${i}${h}`, m =
|
|
235
|
-
this.string = c, this.type = t, this.subtype = i, this.parameters =
|
|
234
|
+
const c = `${t}/${i}${h}`, m = a.encoding;
|
|
235
|
+
this.string = c, this.type = t, this.subtype = i, this.parameters = a, this.encoding = m, this.name = e.name, this.fileExtension = e.fileExtension;
|
|
236
236
|
}
|
|
237
237
|
static parse(e) {
|
|
238
|
-
return new
|
|
238
|
+
return new l(e);
|
|
239
239
|
}
|
|
240
240
|
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
241
241
|
* Gives a hint on the underlying structure of this media type.
|
|
@@ -265,16 +265,16 @@ class a {
|
|
|
265
265
|
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
266
266
|
*/
|
|
267
267
|
contains(e) {
|
|
268
|
-
const t = typeof e == "string" ?
|
|
268
|
+
const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
|
|
269
269
|
if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
|
|
270
270
|
return !1;
|
|
271
271
|
const i = new Set(
|
|
272
272
|
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
273
|
-
),
|
|
273
|
+
), r = new Set(
|
|
274
274
|
Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
|
|
275
275
|
);
|
|
276
276
|
for (const n of Array.from(i.values()))
|
|
277
|
-
if (!
|
|
277
|
+
if (!r.has(n))
|
|
278
278
|
return !1;
|
|
279
279
|
return !0;
|
|
280
280
|
}
|
|
@@ -284,7 +284,7 @@ class a {
|
|
|
284
284
|
* doesn't. This is basically like `contains`, but working in both direction.
|
|
285
285
|
*/
|
|
286
286
|
matches(e) {
|
|
287
|
-
const t = typeof e == "string" ?
|
|
287
|
+
const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
|
|
288
288
|
return this.contains(t) || t.contains(this);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -303,38 +303,38 @@ class a {
|
|
|
303
303
|
/** Returns whether this media type is structured as a ZIP archive. */
|
|
304
304
|
get isZIP() {
|
|
305
305
|
return this.matchesAny(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
l.ZIP,
|
|
307
|
+
l.LCP_PROTECTED_AUDIOBOOK,
|
|
308
|
+
l.LCP_PROTECTED_PDF
|
|
309
309
|
) || this.structuredSyntaxSuffix === "+zip";
|
|
310
310
|
}
|
|
311
311
|
/** Returns whether this media type is structured as a JSON file. */
|
|
312
312
|
get isJSON() {
|
|
313
|
-
return this.matchesAny(
|
|
313
|
+
return this.matchesAny(l.JSON) || this.structuredSyntaxSuffix === "+json";
|
|
314
314
|
}
|
|
315
315
|
/** Returns whether this media type is of an OPDS feed. */
|
|
316
316
|
get isOPDS() {
|
|
317
317
|
return this.matchesAny(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
318
|
+
l.OPDS1,
|
|
319
|
+
l.OPDS1_ENTRY,
|
|
320
|
+
l.OPDS2,
|
|
321
|
+
l.OPDS2_PUBLICATION,
|
|
322
|
+
l.OPDS_AUTHENTICATION
|
|
323
323
|
) || this.structuredSyntaxSuffix === "+json";
|
|
324
324
|
}
|
|
325
325
|
/** Returns whether this media type is of an HTML document. */
|
|
326
326
|
get isHTML() {
|
|
327
|
-
return this.matchesAny(
|
|
327
|
+
return this.matchesAny(l.HTML, l.XHTML);
|
|
328
328
|
}
|
|
329
329
|
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
|
|
330
330
|
get isBitmap() {
|
|
331
331
|
return this.matchesAny(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
l.BMP,
|
|
333
|
+
l.GIF,
|
|
334
|
+
l.JPEG,
|
|
335
|
+
l.PNG,
|
|
336
|
+
l.TIFF,
|
|
337
|
+
l.WEBP
|
|
338
338
|
);
|
|
339
339
|
}
|
|
340
340
|
/** Returns whether this media type is of an audio clip. */
|
|
@@ -348,320 +348,320 @@ class a {
|
|
|
348
348
|
/** Returns whether this media type is of a Readium Web Publication Manifest. */
|
|
349
349
|
get isRWPM() {
|
|
350
350
|
return this.matchesAny(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
352
|
+
l.DIVINA_MANIFEST,
|
|
353
|
+
l.READIUM_WEBPUB_MANIFEST
|
|
354
354
|
);
|
|
355
355
|
}
|
|
356
356
|
/** Returns whether this media type is of a publication file. */
|
|
357
357
|
get isPublication() {
|
|
358
358
|
return this.matchesAny(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
359
|
+
l.READIUM_AUDIOBOOK,
|
|
360
|
+
l.READIUM_AUDIOBOOK_MANIFEST,
|
|
361
|
+
l.CBZ,
|
|
362
|
+
l.DIVINA,
|
|
363
|
+
l.DIVINA_MANIFEST,
|
|
364
|
+
l.EPUB,
|
|
365
|
+
l.LCP_PROTECTED_AUDIOBOOK,
|
|
366
|
+
l.LCP_PROTECTED_PDF,
|
|
367
|
+
l.LPF,
|
|
368
|
+
l.PDF,
|
|
369
|
+
l.W3C_WPUB_MANIFEST,
|
|
370
|
+
l.READIUM_WEBPUB,
|
|
371
|
+
l.READIUM_WEBPUB_MANIFEST,
|
|
372
|
+
l.ZAB
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
375
|
// Known Media Types
|
|
376
376
|
static get AAC() {
|
|
377
|
-
return
|
|
377
|
+
return l.parse({ mediaType: "audio/aac", fileExtension: "aac" });
|
|
378
378
|
}
|
|
379
379
|
static get ACSM() {
|
|
380
|
-
return
|
|
380
|
+
return l.parse({
|
|
381
381
|
mediaType: "application/vnd.adobe.adept+xml",
|
|
382
382
|
name: "Adobe Content Server Message",
|
|
383
383
|
fileExtension: "acsm"
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
static get AIFF() {
|
|
387
|
-
return
|
|
387
|
+
return l.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });
|
|
388
388
|
}
|
|
389
389
|
static get AVI() {
|
|
390
|
-
return
|
|
390
|
+
return l.parse({
|
|
391
391
|
mediaType: "video/x-msvideo",
|
|
392
392
|
fileExtension: "avi"
|
|
393
393
|
});
|
|
394
394
|
}
|
|
395
395
|
static get BINARY() {
|
|
396
|
-
return
|
|
396
|
+
return l.parse({ mediaType: "application/octet-stream" });
|
|
397
397
|
}
|
|
398
398
|
static get BMP() {
|
|
399
|
-
return
|
|
399
|
+
return l.parse({ mediaType: "image/bmp", fileExtension: "bmp" });
|
|
400
400
|
}
|
|
401
401
|
static get CBZ() {
|
|
402
|
-
return
|
|
402
|
+
return l.parse({
|
|
403
403
|
mediaType: "application/vnd.comicbook+zip",
|
|
404
404
|
name: "Comic Book Archive",
|
|
405
405
|
fileExtension: "cbz"
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
408
|
static get CSS() {
|
|
409
|
-
return
|
|
409
|
+
return l.parse({ mediaType: "text/css", fileExtension: "css" });
|
|
410
410
|
}
|
|
411
411
|
static get DIVINA() {
|
|
412
|
-
return
|
|
412
|
+
return l.parse({
|
|
413
413
|
mediaType: "application/divina+zip",
|
|
414
414
|
name: "Digital Visual Narratives",
|
|
415
415
|
fileExtension: "divina"
|
|
416
416
|
});
|
|
417
417
|
}
|
|
418
418
|
static get DIVINA_MANIFEST() {
|
|
419
|
-
return
|
|
419
|
+
return l.parse({
|
|
420
420
|
mediaType: "application/divina+json",
|
|
421
421
|
name: "Digital Visual Narratives",
|
|
422
422
|
fileExtension: "json"
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
425
|
static get EPUB() {
|
|
426
|
-
return
|
|
426
|
+
return l.parse({
|
|
427
427
|
mediaType: "application/epub+zip",
|
|
428
428
|
name: "EPUB",
|
|
429
429
|
fileExtension: "epub"
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
432
|
static get GIF() {
|
|
433
|
-
return
|
|
433
|
+
return l.parse({ mediaType: "image/gif", fileExtension: "gif" });
|
|
434
434
|
}
|
|
435
435
|
static get GZ() {
|
|
436
|
-
return
|
|
436
|
+
return l.parse({
|
|
437
437
|
mediaType: "application/gzip",
|
|
438
438
|
fileExtension: "gz"
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
static get HTML() {
|
|
442
|
-
return
|
|
442
|
+
return l.parse({ mediaType: "text/html", fileExtension: "html" });
|
|
443
443
|
}
|
|
444
444
|
static get JAVASCRIPT() {
|
|
445
|
-
return
|
|
445
|
+
return l.parse({
|
|
446
446
|
mediaType: "text/javascript",
|
|
447
447
|
fileExtension: "js"
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
450
|
static get JPEG() {
|
|
451
|
-
return
|
|
451
|
+
return l.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });
|
|
452
452
|
}
|
|
453
453
|
static get JSON() {
|
|
454
|
-
return
|
|
454
|
+
return l.parse({ mediaType: "application/json" });
|
|
455
455
|
}
|
|
456
456
|
static get LCP_LICENSE_DOCUMENT() {
|
|
457
|
-
return
|
|
457
|
+
return l.parse({
|
|
458
458
|
mediaType: "application/vnd.readium.lcp.license.v1.0+json",
|
|
459
459
|
name: "LCP License",
|
|
460
460
|
fileExtension: "lcpl"
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
463
|
static get LCP_PROTECTED_AUDIOBOOK() {
|
|
464
|
-
return
|
|
464
|
+
return l.parse({
|
|
465
465
|
mediaType: "application/audiobook+lcp",
|
|
466
466
|
name: "LCP Protected Audiobook",
|
|
467
467
|
fileExtension: "lcpa"
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
static get LCP_PROTECTED_PDF() {
|
|
471
|
-
return
|
|
471
|
+
return l.parse({
|
|
472
472
|
mediaType: "application/pdf+lcp",
|
|
473
473
|
name: "LCP Protected PDF",
|
|
474
474
|
fileExtension: "lcpdf"
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
static get LCP_STATUS_DOCUMENT() {
|
|
478
|
-
return
|
|
478
|
+
return l.parse({
|
|
479
479
|
mediaType: "application/vnd.readium.license.status.v1.0+json"
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
static get LPF() {
|
|
483
|
-
return
|
|
483
|
+
return l.parse({
|
|
484
484
|
mediaType: "application/lpf+zip",
|
|
485
485
|
fileExtension: "lpf"
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
static get MP3() {
|
|
489
|
-
return
|
|
489
|
+
return l.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });
|
|
490
490
|
}
|
|
491
491
|
static get MPEG() {
|
|
492
|
-
return
|
|
492
|
+
return l.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });
|
|
493
493
|
}
|
|
494
494
|
static get NCX() {
|
|
495
|
-
return
|
|
495
|
+
return l.parse({
|
|
496
496
|
mediaType: "application/x-dtbncx+xml",
|
|
497
497
|
fileExtension: "ncx"
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
static get OGG() {
|
|
501
|
-
return
|
|
501
|
+
return l.parse({ mediaType: "audio/ogg", fileExtension: "oga" });
|
|
502
502
|
}
|
|
503
503
|
static get OGV() {
|
|
504
|
-
return
|
|
504
|
+
return l.parse({ mediaType: "video/ogg", fileExtension: "ogv" });
|
|
505
505
|
}
|
|
506
506
|
static get OPDS1() {
|
|
507
|
-
return
|
|
507
|
+
return l.parse({
|
|
508
508
|
mediaType: "application/atom+xml;profile=opds-catalog"
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
511
|
static get OPDS1_ENTRY() {
|
|
512
|
-
return
|
|
512
|
+
return l.parse({
|
|
513
513
|
mediaType: "application/atom+xml;type=entry;profile=opds-catalog"
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
static get OPDS2() {
|
|
517
|
-
return
|
|
517
|
+
return l.parse({ mediaType: "application/opds+json" });
|
|
518
518
|
}
|
|
519
519
|
static get OPDS2_PUBLICATION() {
|
|
520
|
-
return
|
|
520
|
+
return l.parse({ mediaType: "application/opds-publication+json" });
|
|
521
521
|
}
|
|
522
522
|
static get OPDS_AUTHENTICATION() {
|
|
523
|
-
return
|
|
523
|
+
return l.parse({
|
|
524
524
|
mediaType: "application/opds-authentication+json"
|
|
525
525
|
});
|
|
526
526
|
}
|
|
527
527
|
static get OPUS() {
|
|
528
|
-
return
|
|
528
|
+
return l.parse({ mediaType: "audio/opus", fileExtension: "opus" });
|
|
529
529
|
}
|
|
530
530
|
static get OTF() {
|
|
531
|
-
return
|
|
531
|
+
return l.parse({ mediaType: "font/otf", fileExtension: "otf" });
|
|
532
532
|
}
|
|
533
533
|
static get PDF() {
|
|
534
|
-
return
|
|
534
|
+
return l.parse({
|
|
535
535
|
mediaType: "application/pdf",
|
|
536
536
|
name: "PDF",
|
|
537
537
|
fileExtension: "pdf"
|
|
538
538
|
});
|
|
539
539
|
}
|
|
540
540
|
static get PNG() {
|
|
541
|
-
return
|
|
541
|
+
return l.parse({ mediaType: "image/png", fileExtension: "png" });
|
|
542
542
|
}
|
|
543
543
|
static get READIUM_AUDIOBOOK() {
|
|
544
|
-
return
|
|
544
|
+
return l.parse({
|
|
545
545
|
mediaType: "application/audiobook+zip",
|
|
546
546
|
name: "Readium Audiobook",
|
|
547
547
|
fileExtension: "audiobook"
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
550
|
static get READIUM_AUDIOBOOK_MANIFEST() {
|
|
551
|
-
return
|
|
551
|
+
return l.parse({
|
|
552
552
|
mediaType: "application/audiobook+json",
|
|
553
553
|
name: "Readium Audiobook",
|
|
554
554
|
fileExtension: "json"
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
557
|
static get READIUM_CONTENT_DOCUMENT() {
|
|
558
|
-
return
|
|
558
|
+
return l.parse({
|
|
559
559
|
mediaType: "application/vnd.readium.content+json",
|
|
560
560
|
name: "Readium Content Document",
|
|
561
561
|
fileExtension: "json"
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
564
|
static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {
|
|
565
|
-
return
|
|
565
|
+
return l.parse({
|
|
566
566
|
mediaType: "application/guided-navigation+json",
|
|
567
567
|
name: "Readium Guided Navigation Document",
|
|
568
568
|
fileExtension: "json"
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
static get READIUM_POSITION_LIST() {
|
|
572
|
-
return
|
|
572
|
+
return l.parse({
|
|
573
573
|
mediaType: "application/vnd.readium.position-list+json",
|
|
574
574
|
name: "Readium Position List",
|
|
575
575
|
fileExtension: "json"
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
578
|
static get READIUM_WEBPUB() {
|
|
579
|
-
return
|
|
579
|
+
return l.parse({
|
|
580
580
|
mediaType: "application/webpub+zip",
|
|
581
581
|
name: "Readium Web Publication",
|
|
582
582
|
fileExtension: "webpub"
|
|
583
583
|
});
|
|
584
584
|
}
|
|
585
585
|
static get READIUM_WEBPUB_MANIFEST() {
|
|
586
|
-
return
|
|
586
|
+
return l.parse({
|
|
587
587
|
mediaType: "application/webpub+json",
|
|
588
588
|
name: "Readium Web Publication",
|
|
589
589
|
fileExtension: "json"
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
592
|
static get SMIL() {
|
|
593
|
-
return
|
|
593
|
+
return l.parse({
|
|
594
594
|
mediaType: "application/smil+xml",
|
|
595
595
|
fileExtension: "smil"
|
|
596
596
|
});
|
|
597
597
|
}
|
|
598
598
|
static get SVG() {
|
|
599
|
-
return
|
|
599
|
+
return l.parse({
|
|
600
600
|
mediaType: "image/svg+xml",
|
|
601
601
|
fileExtension: "svg"
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
static get TEXT() {
|
|
605
|
-
return
|
|
605
|
+
return l.parse({ mediaType: "text/plain", fileExtension: "txt" });
|
|
606
606
|
}
|
|
607
607
|
static get TIFF() {
|
|
608
|
-
return
|
|
608
|
+
return l.parse({ mediaType: "image/tiff", fileExtension: "tiff" });
|
|
609
609
|
}
|
|
610
610
|
static get TTF() {
|
|
611
|
-
return
|
|
611
|
+
return l.parse({ mediaType: "font/ttf", fileExtension: "ttf" });
|
|
612
612
|
}
|
|
613
613
|
static get W3C_WPUB_MANIFEST() {
|
|
614
|
-
return
|
|
614
|
+
return l.parse({
|
|
615
615
|
mediaType: "application/x.readium.w3c.wpub+json",
|
|
616
616
|
name: "Web Publication",
|
|
617
617
|
fileExtension: "json"
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
620
|
static get WAV() {
|
|
621
|
-
return
|
|
621
|
+
return l.parse({ mediaType: "audio/wav", fileExtension: "wav" });
|
|
622
622
|
}
|
|
623
623
|
static get WEBM_AUDIO() {
|
|
624
|
-
return
|
|
624
|
+
return l.parse({ mediaType: "audio/webm", fileExtension: "webm" });
|
|
625
625
|
}
|
|
626
626
|
static get WEBM_VIDEO() {
|
|
627
|
-
return
|
|
627
|
+
return l.parse({ mediaType: "video/webm", fileExtension: "webm" });
|
|
628
628
|
}
|
|
629
629
|
static get WEBP() {
|
|
630
|
-
return
|
|
630
|
+
return l.parse({ mediaType: "image/webp", fileExtension: "webp" });
|
|
631
631
|
}
|
|
632
632
|
static get WOFF() {
|
|
633
|
-
return
|
|
633
|
+
return l.parse({ mediaType: "font/woff", fileExtension: "woff" });
|
|
634
634
|
}
|
|
635
635
|
static get WOFF2() {
|
|
636
|
-
return
|
|
636
|
+
return l.parse({ mediaType: "font/woff2", fileExtension: "woff2" });
|
|
637
637
|
}
|
|
638
638
|
static get XHTML() {
|
|
639
|
-
return
|
|
639
|
+
return l.parse({
|
|
640
640
|
mediaType: "application/xhtml+xml",
|
|
641
641
|
fileExtension: "xhtml"
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
644
|
static get XML() {
|
|
645
|
-
return
|
|
645
|
+
return l.parse({
|
|
646
646
|
mediaType: "application/xml",
|
|
647
647
|
fileExtension: "xml"
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
650
|
static get ZAB() {
|
|
651
|
-
return
|
|
651
|
+
return l.parse({
|
|
652
652
|
mediaType: "application/x.readium.zab+zip",
|
|
653
653
|
name: "Zipped Audio Book",
|
|
654
654
|
fileExtension: "zab"
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
static get ZIP() {
|
|
658
|
-
return
|
|
658
|
+
return l.parse({
|
|
659
659
|
mediaType: "application/zip",
|
|
660
660
|
fileExtension: "zip"
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
|
-
class
|
|
664
|
+
class Ie {
|
|
665
665
|
constructor(e) {
|
|
666
666
|
this.uri = e, this.parameters = this.getParameters(e);
|
|
667
667
|
}
|
|
@@ -671,7 +671,7 @@ class Te {
|
|
|
671
671
|
getParameters(e) {
|
|
672
672
|
const t = /\{\??([^}]+)\}/g, i = e.match(t);
|
|
673
673
|
return i ? new Set(
|
|
674
|
-
i.join(",").replace(t, "$1").split(",").map((
|
|
674
|
+
i.join(",").replace(t, "$1").split(",").map((r) => r.trim())
|
|
675
675
|
) : /* @__PURE__ */ new Set();
|
|
676
676
|
}
|
|
677
677
|
/** Expands the URI by replacing the template variables by the given parameters.
|
|
@@ -679,14 +679,14 @@ class Te {
|
|
|
679
679
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
680
680
|
*/
|
|
681
681
|
expand(e) {
|
|
682
|
-
const t = (
|
|
682
|
+
const t = (r) => r.split(",").map((n) => {
|
|
683
683
|
const o = e[n];
|
|
684
684
|
return o ? encodeURIComponent(o) : "";
|
|
685
|
-
}).join(","), i = (
|
|
686
|
-
const o = n.split("=")[0],
|
|
687
|
-
return
|
|
685
|
+
}).join(","), i = (r) => "?" + r.split(",").map((n) => {
|
|
686
|
+
const o = n.split("=")[0], a = e[o];
|
|
687
|
+
return a ? `${o}=${encodeURIComponent(a)}` : "";
|
|
688
688
|
}).join("&");
|
|
689
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...
|
|
689
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...r) => r[1] ? i(r[2]) : t(r[2]));
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
692
|
class b {
|
|
@@ -701,20 +701,20 @@ class b {
|
|
|
701
701
|
*/
|
|
702
702
|
static deserialize(e) {
|
|
703
703
|
if (!e) return;
|
|
704
|
-
const t =
|
|
704
|
+
const t = Q(e.progression), i = Q(e.totalProgression), r = Q(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
705
705
|
"fragment",
|
|
706
706
|
"fragments",
|
|
707
707
|
"progression",
|
|
708
708
|
"totalProgression",
|
|
709
709
|
"position"
|
|
710
710
|
]);
|
|
711
|
-
return Object.entries(e).forEach(([
|
|
712
|
-
o.has(
|
|
711
|
+
return Object.entries(e).forEach(([a, u]) => {
|
|
712
|
+
o.has(a) || n.set(a, u);
|
|
713
713
|
}), new b({
|
|
714
|
-
fragments:
|
|
714
|
+
fragments: Qe(e.fragments || e.fragment),
|
|
715
715
|
progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
|
|
716
716
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
717
|
-
position:
|
|
717
|
+
position: r !== void 0 && r > 0 ? r : void 0,
|
|
718
718
|
otherLocations: n.size === 0 ? void 0 : n
|
|
719
719
|
});
|
|
720
720
|
}
|
|
@@ -726,7 +726,7 @@ class b {
|
|
|
726
726
|
return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
class
|
|
729
|
+
class D {
|
|
730
730
|
/**
|
|
731
731
|
* Creates a [Text].
|
|
732
732
|
*/
|
|
@@ -738,7 +738,7 @@ class z {
|
|
|
738
738
|
*/
|
|
739
739
|
static deserialize(e) {
|
|
740
740
|
if (e)
|
|
741
|
-
return new
|
|
741
|
+
return new D({
|
|
742
742
|
after: e.after,
|
|
743
743
|
before: e.before,
|
|
744
744
|
highlight: e.highlight
|
|
@@ -752,7 +752,7 @@ class z {
|
|
|
752
752
|
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;
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
class
|
|
755
|
+
class R {
|
|
756
756
|
/**
|
|
757
757
|
* Creates a [Locator].
|
|
758
758
|
*/
|
|
@@ -764,12 +764,12 @@ class L {
|
|
|
764
764
|
*/
|
|
765
765
|
static deserialize(e) {
|
|
766
766
|
if (e && e.href && e.type)
|
|
767
|
-
return new
|
|
767
|
+
return new R({
|
|
768
768
|
href: e.href,
|
|
769
769
|
type: e.type,
|
|
770
770
|
title: e.title,
|
|
771
771
|
locations: b.deserialize(e.locations),
|
|
772
|
-
text:
|
|
772
|
+
text: D.deserialize(e.text)
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
/**
|
|
@@ -783,7 +783,7 @@ class L {
|
|
|
783
783
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
784
784
|
*/
|
|
785
785
|
copyWithLocations(e) {
|
|
786
|
-
return new
|
|
786
|
+
return new R({
|
|
787
787
|
href: this.href,
|
|
788
788
|
type: this.type,
|
|
789
789
|
title: this.title,
|
|
@@ -792,7 +792,7 @@ class L {
|
|
|
792
792
|
});
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
|
-
class
|
|
795
|
+
class H {
|
|
796
796
|
/**
|
|
797
797
|
* Creates a [Link].
|
|
798
798
|
*/
|
|
@@ -804,7 +804,7 @@ class F {
|
|
|
804
804
|
*/
|
|
805
805
|
static deserialize(e) {
|
|
806
806
|
if (!(!e || typeof e.href != "string"))
|
|
807
|
-
return new
|
|
807
|
+
return new H({
|
|
808
808
|
href: e.href,
|
|
809
809
|
templated: e.templated,
|
|
810
810
|
type: e.type,
|
|
@@ -816,9 +816,9 @@ class F {
|
|
|
816
816
|
size: S(e.size),
|
|
817
817
|
duration: S(e.duration),
|
|
818
818
|
bitrate: S(e.bitrate),
|
|
819
|
-
languages:
|
|
820
|
-
alternates:
|
|
821
|
-
children:
|
|
819
|
+
languages: Qe(e.language),
|
|
820
|
+
alternates: ee.deserialize(e.alternate),
|
|
821
|
+
children: ee.deserialize(e.children)
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
824
|
/**
|
|
@@ -826,11 +826,11 @@ class F {
|
|
|
826
826
|
*/
|
|
827
827
|
serialize() {
|
|
828
828
|
const e = { href: this.href };
|
|
829
|
-
return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel =
|
|
829
|
+
return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = gt(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.size !== void 0 && (e.size = this.size), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;
|
|
830
830
|
}
|
|
831
831
|
/** MediaType of the linked resource. */
|
|
832
832
|
get mediaType() {
|
|
833
|
-
return this.type !== void 0 ?
|
|
833
|
+
return this.type !== void 0 ? l.parse({ mediaType: this.type }) : l.BINARY;
|
|
834
834
|
}
|
|
835
835
|
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
836
836
|
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
@@ -843,14 +843,14 @@ class F {
|
|
|
843
843
|
}
|
|
844
844
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
845
845
|
get templateParameters() {
|
|
846
|
-
return this.templated ? new
|
|
846
|
+
return this.templated ? new Ie(this.href).parameters : /* @__PURE__ */ new Set();
|
|
847
847
|
}
|
|
848
848
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
849
849
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
850
850
|
*/
|
|
851
851
|
expandTemplate(e) {
|
|
852
|
-
return new
|
|
853
|
-
href: new
|
|
852
|
+
return new H({
|
|
853
|
+
href: new Ie(this.href).expand(e),
|
|
854
854
|
templated: !1
|
|
855
855
|
});
|
|
856
856
|
}
|
|
@@ -858,7 +858,7 @@ class F {
|
|
|
858
858
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
859
859
|
*/
|
|
860
860
|
addProperties(e) {
|
|
861
|
-
const t =
|
|
861
|
+
const t = H.deserialize(this.serialize());
|
|
862
862
|
return t.properties = t.properties ? t.properties?.add(e) : new C(e), t;
|
|
863
863
|
}
|
|
864
864
|
/**
|
|
@@ -866,7 +866,7 @@ class F {
|
|
|
866
866
|
*/
|
|
867
867
|
get locator() {
|
|
868
868
|
let e = this.href.split("#");
|
|
869
|
-
return new
|
|
869
|
+
return new R({
|
|
870
870
|
href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
|
|
871
871
|
type: this.type ?? "",
|
|
872
872
|
title: this.title,
|
|
@@ -876,7 +876,7 @@ class F {
|
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class ee {
|
|
880
880
|
/**
|
|
881
881
|
* Creates a [Links].
|
|
882
882
|
*/
|
|
@@ -888,8 +888,8 @@ class _ {
|
|
|
888
888
|
*/
|
|
889
889
|
static deserialize(e) {
|
|
890
890
|
if (e && Array.isArray(e))
|
|
891
|
-
return new
|
|
892
|
-
e.map((t) =>
|
|
891
|
+
return new ee(
|
|
892
|
+
e.map((t) => H.deserialize(t)).filter((t) => t !== void 0)
|
|
893
893
|
);
|
|
894
894
|
}
|
|
895
895
|
/**
|
|
@@ -931,8 +931,8 @@ class _ {
|
|
|
931
931
|
/** Finds all the links matching any of the given media types. */
|
|
932
932
|
filterByMediaTypes(e) {
|
|
933
933
|
const t = (i) => {
|
|
934
|
-
for (const
|
|
935
|
-
if (i.mediaType.matches(
|
|
934
|
+
for (const r of e)
|
|
935
|
+
if (i.mediaType.matches(r))
|
|
936
936
|
return !0;
|
|
937
937
|
return !1;
|
|
938
938
|
};
|
|
@@ -973,7 +973,7 @@ class _ {
|
|
|
973
973
|
C.prototype.getContains = function() {
|
|
974
974
|
return new Set(this.otherProperties.contains || []);
|
|
975
975
|
};
|
|
976
|
-
class
|
|
976
|
+
class te {
|
|
977
977
|
/**
|
|
978
978
|
* Creates a [DomRange].
|
|
979
979
|
*/
|
|
@@ -988,7 +988,7 @@ class G {
|
|
|
988
988
|
let t = S(e.textNodeIndex);
|
|
989
989
|
if (t === void 0) return;
|
|
990
990
|
let i = S(e.charOffset);
|
|
991
|
-
return i === void 0 && (i = S(e.offset)), new
|
|
991
|
+
return i === void 0 && (i = S(e.offset)), new te({
|
|
992
992
|
cssSelector: e.cssSelector,
|
|
993
993
|
textNodeIndex: t,
|
|
994
994
|
charOffset: i
|
|
@@ -1005,7 +1005,7 @@ class G {
|
|
|
1005
1005
|
return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
-
class
|
|
1008
|
+
class we {
|
|
1009
1009
|
/**
|
|
1010
1010
|
* Creates a [DomRange].
|
|
1011
1011
|
*/
|
|
@@ -1017,11 +1017,11 @@ class de {
|
|
|
1017
1017
|
*/
|
|
1018
1018
|
static deserialize(e) {
|
|
1019
1019
|
if (!e) return;
|
|
1020
|
-
let t =
|
|
1020
|
+
let t = te.deserialize(e.start);
|
|
1021
1021
|
if (t)
|
|
1022
|
-
return new
|
|
1022
|
+
return new we({
|
|
1023
1023
|
start: t,
|
|
1024
|
-
end:
|
|
1024
|
+
end: te.deserialize(e.end)
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
1027
1027
|
/**
|
|
@@ -1039,41 +1039,41 @@ b.prototype.getPartialCfi = function() {
|
|
|
1039
1039
|
return this.otherLocations?.get("partialCfi");
|
|
1040
1040
|
};
|
|
1041
1041
|
b.prototype.getDomRange = function() {
|
|
1042
|
-
return
|
|
1042
|
+
return we.deserialize(this.otherLocations?.get("domRange"));
|
|
1043
1043
|
};
|
|
1044
1044
|
b.prototype.fragmentParameters = function() {
|
|
1045
1045
|
return new Map(
|
|
1046
|
-
this.fragments.map((
|
|
1047
|
-
|
|
1048
|
-
|
|
1046
|
+
this.fragments.map((s) => s.startsWith("#") ? s.slice(1) : s).join("&").split("&").filter((s) => !s.startsWith("#")).map((s) => s.split("=")).filter((s) => s.length === 2).map((s) => [
|
|
1047
|
+
s[0].trim().toLowerCase(),
|
|
1048
|
+
s[1].trim()
|
|
1049
1049
|
])
|
|
1050
1050
|
);
|
|
1051
1051
|
};
|
|
1052
1052
|
b.prototype.htmlId = function() {
|
|
1053
1053
|
if (!this.fragments.length) return;
|
|
1054
|
-
let
|
|
1055
|
-
if (!
|
|
1054
|
+
let s = this.fragments.find((e) => e.length && !e.includes("="));
|
|
1055
|
+
if (!s) {
|
|
1056
1056
|
const e = this.fragmentParameters();
|
|
1057
|
-
e.has("id") ?
|
|
1057
|
+
e.has("id") ? s = e.get("id") : e.has("name") && (s = e.get("name"));
|
|
1058
1058
|
}
|
|
1059
|
-
return
|
|
1059
|
+
return s?.startsWith("#") ? s.slice(1) : s;
|
|
1060
1060
|
};
|
|
1061
1061
|
b.prototype.page = function() {
|
|
1062
|
-
const
|
|
1063
|
-
if (!isNaN(
|
|
1062
|
+
const s = parseInt(this.fragmentParameters().get("page"));
|
|
1063
|
+
if (!isNaN(s) && s >= 0) return s;
|
|
1064
1064
|
};
|
|
1065
1065
|
b.prototype.time = function() {
|
|
1066
|
-
const
|
|
1067
|
-
if (!isNaN(
|
|
1066
|
+
const s = parseInt(this.fragmentParameters().get("t"));
|
|
1067
|
+
if (!isNaN(s)) return s;
|
|
1068
1068
|
};
|
|
1069
1069
|
b.prototype.space = function() {
|
|
1070
|
-
const
|
|
1071
|
-
if (!
|
|
1072
|
-
const e =
|
|
1070
|
+
const s = this.fragmentParameters();
|
|
1071
|
+
if (!s.has("xywh")) return;
|
|
1072
|
+
const e = s.get("xywh").split(",").map((t) => parseInt(t));
|
|
1073
1073
|
if (e.length === 4 && !e.some(isNaN))
|
|
1074
1074
|
return e;
|
|
1075
1075
|
};
|
|
1076
|
-
class
|
|
1076
|
+
class Se {
|
|
1077
1077
|
/** Creates a [Price]. */
|
|
1078
1078
|
constructor(e) {
|
|
1079
1079
|
this.currency = e.currency, this.value = e.value;
|
|
@@ -1088,7 +1088,7 @@ class pe {
|
|
|
1088
1088
|
return;
|
|
1089
1089
|
let i = S(e.value);
|
|
1090
1090
|
if (i !== void 0)
|
|
1091
|
-
return new
|
|
1091
|
+
return new Se({ currency: t, value: i });
|
|
1092
1092
|
}
|
|
1093
1093
|
/**
|
|
1094
1094
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1097,7 +1097,7 @@ class pe {
|
|
|
1097
1097
|
return { currency: this.currency, value: this.value };
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
|
-
class
|
|
1100
|
+
class V {
|
|
1101
1101
|
/** Creates a [Acquisition]. */
|
|
1102
1102
|
constructor(e) {
|
|
1103
1103
|
this.type = e.type, this.children = e.children;
|
|
@@ -1107,14 +1107,14 @@ class B {
|
|
|
1107
1107
|
*/
|
|
1108
1108
|
static deserialize(e) {
|
|
1109
1109
|
if (e && e.type)
|
|
1110
|
-
return new
|
|
1110
|
+
return new V({
|
|
1111
1111
|
type: e.type,
|
|
1112
|
-
children:
|
|
1112
|
+
children: V.deserializeArray(e.children)
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
static deserializeArray(e) {
|
|
1116
1116
|
if (Array.isArray(e))
|
|
1117
|
-
return e.map((t) =>
|
|
1117
|
+
return e.map((t) => V.deserialize(t)).filter((t) => t !== void 0);
|
|
1118
1118
|
}
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1124,7 +1124,7 @@ class B {
|
|
|
1124
1124
|
return this.children && (e.children = this.children.map((t) => t.serialize())), e;
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
|
-
class
|
|
1127
|
+
class Ce {
|
|
1128
1128
|
/** Creates a [Price]. */
|
|
1129
1129
|
constructor(e) {
|
|
1130
1130
|
this.total = e.total, this.position = e.position;
|
|
@@ -1134,7 +1134,7 @@ class fe {
|
|
|
1134
1134
|
*/
|
|
1135
1135
|
static deserialize(e) {
|
|
1136
1136
|
if (e)
|
|
1137
|
-
return new
|
|
1137
|
+
return new Ce({
|
|
1138
1138
|
total: S(e.total),
|
|
1139
1139
|
position: S(e.position)
|
|
1140
1140
|
});
|
|
@@ -1147,7 +1147,7 @@ class fe {
|
|
|
1147
1147
|
return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
|
-
class
|
|
1150
|
+
class Pe {
|
|
1151
1151
|
/** Creates a [Copies]. */
|
|
1152
1152
|
constructor(e) {
|
|
1153
1153
|
this.total = e.total, this.available = e.available;
|
|
@@ -1157,7 +1157,7 @@ class me {
|
|
|
1157
1157
|
*/
|
|
1158
1158
|
static deserialize(e) {
|
|
1159
1159
|
if (e)
|
|
1160
|
-
return new
|
|
1160
|
+
return new Pe({
|
|
1161
1161
|
total: S(e.total),
|
|
1162
1162
|
available: S(e.available)
|
|
1163
1163
|
});
|
|
@@ -1170,7 +1170,7 @@ class me {
|
|
|
1170
1170
|
return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
class
|
|
1173
|
+
class Ae {
|
|
1174
1174
|
/** Creates a [Availability]. */
|
|
1175
1175
|
constructor(e) {
|
|
1176
1176
|
this.state = e.state, this.since = e.since, this.until = e.until;
|
|
@@ -1180,10 +1180,10 @@ class ge {
|
|
|
1180
1180
|
*/
|
|
1181
1181
|
static deserialize(e) {
|
|
1182
1182
|
if (e && e.state)
|
|
1183
|
-
return new
|
|
1183
|
+
return new Ae({
|
|
1184
1184
|
state: e.state,
|
|
1185
|
-
since:
|
|
1186
|
-
until:
|
|
1185
|
+
since: Re(e.since),
|
|
1186
|
+
until: Re(e.until)
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
1189
|
/**
|
|
@@ -1198,250 +1198,250 @@ C.prototype.getNumberOfItems = function() {
|
|
|
1198
1198
|
return S(this.otherProperties.numberOfItems);
|
|
1199
1199
|
};
|
|
1200
1200
|
C.prototype.getPrice = function() {
|
|
1201
|
-
return
|
|
1201
|
+
return Se.deserialize(this.otherProperties.price);
|
|
1202
1202
|
};
|
|
1203
1203
|
C.prototype.getIndirectAcquisitions = function() {
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1206
|
-
return
|
|
1204
|
+
const s = this.otherProperties.indirectAcquisition;
|
|
1205
|
+
if (s && Array.isArray(s))
|
|
1206
|
+
return s.map((e) => V.deserialize(e)).filter((e) => e !== void 0);
|
|
1207
1207
|
};
|
|
1208
1208
|
C.prototype.getHolds = function() {
|
|
1209
|
-
return
|
|
1209
|
+
return Ce.deserialize(this.otherProperties.holds);
|
|
1210
1210
|
};
|
|
1211
1211
|
C.prototype.getCopies = function() {
|
|
1212
|
-
return
|
|
1212
|
+
return Pe.deserialize(this.otherProperties.copies);
|
|
1213
1213
|
};
|
|
1214
1214
|
C.prototype.getAvailability = function() {
|
|
1215
|
-
return
|
|
1215
|
+
return Ae.deserialize(this.otherProperties.availability);
|
|
1216
1216
|
};
|
|
1217
1217
|
C.prototype.getAuthenticate = function() {
|
|
1218
|
-
return
|
|
1218
|
+
return H.deserialize(this.otherProperties.authenticate);
|
|
1219
1219
|
};
|
|
1220
|
-
const
|
|
1221
|
-
function
|
|
1222
|
-
console.warn(`${
|
|
1220
|
+
const yt = "CssSelectorGenerator";
|
|
1221
|
+
function ze(s = "unknown problem", ...e) {
|
|
1222
|
+
console.warn(`${yt}: ${s}`, ...e);
|
|
1223
1223
|
}
|
|
1224
|
-
function
|
|
1225
|
-
return
|
|
1224
|
+
function vt(s) {
|
|
1225
|
+
return s instanceof RegExp;
|
|
1226
1226
|
}
|
|
1227
|
-
function
|
|
1228
|
-
return
|
|
1227
|
+
function bt(s) {
|
|
1228
|
+
return s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1231
|
-
const e =
|
|
1232
|
-
if (
|
|
1230
|
+
function Et(s) {
|
|
1231
|
+
const e = s.map((t) => {
|
|
1232
|
+
if (vt(t))
|
|
1233
1233
|
return (i) => t.test(i);
|
|
1234
1234
|
if (typeof t == "function")
|
|
1235
1235
|
return (i) => {
|
|
1236
|
-
const
|
|
1237
|
-
return typeof
|
|
1236
|
+
const r = t(i);
|
|
1237
|
+
return typeof r != "boolean" ? (ze("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : r;
|
|
1238
1238
|
};
|
|
1239
1239
|
if (typeof t == "string") {
|
|
1240
|
-
const i = new RegExp("^" +
|
|
1241
|
-
return (
|
|
1240
|
+
const i = new RegExp("^" + bt(t) + "$");
|
|
1241
|
+
return (r) => i.test(r);
|
|
1242
1242
|
}
|
|
1243
|
-
return
|
|
1243
|
+
return ze("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
|
|
1244
1244
|
});
|
|
1245
1245
|
return (t) => e.some((i) => i(t));
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
Et([
|
|
1248
1248
|
"class",
|
|
1249
1249
|
"id",
|
|
1250
1250
|
// Angular attributes
|
|
1251
1251
|
"ng-*"
|
|
1252
1252
|
]);
|
|
1253
|
-
class
|
|
1253
|
+
class Y {
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1256
|
-
return
|
|
1255
|
+
function De(s) {
|
|
1256
|
+
return s.split("").reverse().join("");
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1259
|
-
const i =
|
|
1260
|
-
return t.map((
|
|
1261
|
-
const n = Math.max(0,
|
|
1258
|
+
function xt(s, e, t) {
|
|
1259
|
+
const i = De(e);
|
|
1260
|
+
return t.map((r) => {
|
|
1261
|
+
const n = Math.max(0, r.end - e.length - r.errors), o = De(s.slice(n, r.end));
|
|
1262
1262
|
return {
|
|
1263
|
-
start:
|
|
1264
|
-
end:
|
|
1265
|
-
errors:
|
|
1263
|
+
start: et(o, i, r.errors).reduce((u, h) => r.end - h.end < u ? r.end - h.end : u, r.end),
|
|
1264
|
+
end: r.end,
|
|
1265
|
+
errors: r.errors
|
|
1266
1266
|
};
|
|
1267
1267
|
});
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1270
|
-
return (
|
|
1269
|
+
function ae(s) {
|
|
1270
|
+
return (s | -s) >> 31 & 1;
|
|
1271
1271
|
}
|
|
1272
|
-
function
|
|
1273
|
-
let
|
|
1274
|
-
const o = i >>> 31,
|
|
1275
|
-
let c = n | ~(h |
|
|
1276
|
-
const
|
|
1277
|
-
return c <<= 1, m <<= 1, m |= o, c |=
|
|
1272
|
+
function We(s, e, t, i) {
|
|
1273
|
+
let r = s.P[t], n = s.M[t];
|
|
1274
|
+
const o = i >>> 31, a = e[t] | o, u = a | n, h = (a & r) + r ^ r | a;
|
|
1275
|
+
let c = n | ~(h | r), m = r & h;
|
|
1276
|
+
const d = ae(c & s.lastRowMask[t]) - ae(m & s.lastRowMask[t]);
|
|
1277
|
+
return c <<= 1, m <<= 1, m |= o, c |= ae(i) - o, r = m | ~(u | c), n = c & u, s.P[t] = r, s.M[t] = n, d;
|
|
1278
1278
|
}
|
|
1279
|
-
function
|
|
1279
|
+
function et(s, e, t) {
|
|
1280
1280
|
if (e.length === 0)
|
|
1281
1281
|
return [];
|
|
1282
1282
|
t = Math.min(t, e.length);
|
|
1283
|
-
const i = [],
|
|
1283
|
+
const i = [], r = 32, n = Math.ceil(e.length / r) - 1, o = {
|
|
1284
1284
|
P: new Uint32Array(n + 1),
|
|
1285
1285
|
M: new Uint32Array(n + 1),
|
|
1286
1286
|
lastRowMask: new Uint32Array(n + 1)
|
|
1287
1287
|
};
|
|
1288
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) %
|
|
1289
|
-
const
|
|
1290
|
-
for (let
|
|
1291
|
-
h.push(
|
|
1292
|
-
for (let
|
|
1293
|
-
const y = e.charCodeAt(
|
|
1288
|
+
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % r;
|
|
1289
|
+
const a = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];
|
|
1290
|
+
for (let d = 0; d < 256; d++)
|
|
1291
|
+
h.push(a);
|
|
1292
|
+
for (let d = 0; d < e.length; d += 1) {
|
|
1293
|
+
const y = e.charCodeAt(d);
|
|
1294
1294
|
if (u.has(y))
|
|
1295
1295
|
continue;
|
|
1296
|
-
const
|
|
1297
|
-
u.set(y,
|
|
1296
|
+
const p = new Uint32Array(n + 1);
|
|
1297
|
+
u.set(y, p), y < h.length && (h[y] = p);
|
|
1298
1298
|
for (let f = 0; f <= n; f += 1) {
|
|
1299
|
-
|
|
1300
|
-
for (let g = 0; g <
|
|
1301
|
-
const E = f *
|
|
1299
|
+
p[f] = 0;
|
|
1300
|
+
for (let g = 0; g < r; g += 1) {
|
|
1301
|
+
const E = f * r + g;
|
|
1302
1302
|
if (E >= e.length)
|
|
1303
1303
|
continue;
|
|
1304
|
-
e.charCodeAt(E) === y && (
|
|
1304
|
+
e.charCodeAt(E) === y && (p[f] |= 1 << g);
|
|
1305
1305
|
}
|
|
1306
1306
|
}
|
|
1307
1307
|
}
|
|
1308
|
-
let c = Math.max(0, Math.ceil(t /
|
|
1308
|
+
let c = Math.max(0, Math.ceil(t / r) - 1);
|
|
1309
1309
|
const m = new Uint32Array(n + 1);
|
|
1310
|
-
for (let
|
|
1311
|
-
m[
|
|
1310
|
+
for (let d = 0; d <= c; d += 1)
|
|
1311
|
+
m[d] = (d + 1) * r;
|
|
1312
1312
|
m[n] = e.length;
|
|
1313
|
-
for (let
|
|
1314
|
-
o.P[
|
|
1315
|
-
for (let
|
|
1316
|
-
const y =
|
|
1317
|
-
let
|
|
1318
|
-
y < h.length ?
|
|
1313
|
+
for (let d = 0; d <= c; d += 1)
|
|
1314
|
+
o.P[d] = -1, o.M[d] = 0;
|
|
1315
|
+
for (let d = 0; d < s.length; d += 1) {
|
|
1316
|
+
const y = s.charCodeAt(d);
|
|
1317
|
+
let p;
|
|
1318
|
+
y < h.length ? p = h[y] : (p = u.get(y), typeof p > "u" && (p = a));
|
|
1319
1319
|
let f = 0;
|
|
1320
1320
|
for (let g = 0; g <= c; g += 1)
|
|
1321
|
-
f =
|
|
1322
|
-
if (m[c] - f <= t && c < n && (
|
|
1321
|
+
f = We(o, p, g, f), m[g] += f;
|
|
1322
|
+
if (m[c] - f <= t && c < n && (p[c + 1] & 1 || f < 0)) {
|
|
1323
1323
|
c += 1, o.P[c] = -1, o.M[c] = 0;
|
|
1324
1324
|
let g;
|
|
1325
1325
|
if (c === n) {
|
|
1326
|
-
const E = e.length %
|
|
1327
|
-
g = E === 0 ?
|
|
1326
|
+
const E = e.length % r;
|
|
1327
|
+
g = E === 0 ? r : E;
|
|
1328
1328
|
} else
|
|
1329
|
-
g =
|
|
1330
|
-
m[c] = m[c - 1] + g - f +
|
|
1329
|
+
g = r;
|
|
1330
|
+
m[c] = m[c - 1] + g - f + We(o, p, c, f);
|
|
1331
1331
|
} else
|
|
1332
|
-
for (; c > 0 && m[c] >= t +
|
|
1332
|
+
for (; c > 0 && m[c] >= t + r; )
|
|
1333
1333
|
c -= 1;
|
|
1334
1334
|
c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({
|
|
1335
1335
|
start: -1,
|
|
1336
|
-
end:
|
|
1336
|
+
end: d + 1,
|
|
1337
1337
|
errors: m[c]
|
|
1338
1338
|
}), t = m[c]);
|
|
1339
1339
|
}
|
|
1340
1340
|
return i;
|
|
1341
1341
|
}
|
|
1342
|
-
function
|
|
1343
|
-
const i =
|
|
1344
|
-
return
|
|
1342
|
+
function Tt(s, e, t) {
|
|
1343
|
+
const i = et(s, e, t);
|
|
1344
|
+
return xt(s, e, i);
|
|
1345
1345
|
}
|
|
1346
|
-
function
|
|
1346
|
+
function tt(s, e, t) {
|
|
1347
1347
|
let i = 0;
|
|
1348
|
-
const
|
|
1348
|
+
const r = [];
|
|
1349
1349
|
for (; i !== -1; )
|
|
1350
|
-
i =
|
|
1350
|
+
i = s.indexOf(e, i), i !== -1 && (r.push({
|
|
1351
1351
|
start: i,
|
|
1352
1352
|
end: i + e.length,
|
|
1353
1353
|
errors: 0
|
|
1354
1354
|
}), i += 1);
|
|
1355
|
-
return
|
|
1355
|
+
return r.length > 0 ? r : Tt(s, e, t);
|
|
1356
1356
|
}
|
|
1357
|
-
function
|
|
1358
|
-
return e.length === 0 ||
|
|
1357
|
+
function Fe(s, e) {
|
|
1358
|
+
return e.length === 0 || s.length === 0 ? 0 : 1 - tt(s, e, e.length)[0].errors / e.length;
|
|
1359
1359
|
}
|
|
1360
|
-
function
|
|
1360
|
+
function wt(s, e, t = {}) {
|
|
1361
1361
|
if (e.length === 0)
|
|
1362
1362
|
return null;
|
|
1363
|
-
const i = Math.min(256, e.length / 2),
|
|
1364
|
-
if (
|
|
1363
|
+
const i = Math.min(256, e.length / 2), r = tt(s, e, i);
|
|
1364
|
+
if (r.length === 0)
|
|
1365
1365
|
return null;
|
|
1366
|
-
const n = (
|
|
1367
|
-
const
|
|
1368
|
-
|
|
1369
|
-
Math.max(0,
|
|
1370
|
-
|
|
1366
|
+
const n = (a) => {
|
|
1367
|
+
const d = 1 - a.errors / e.length, y = t.prefix ? Fe(
|
|
1368
|
+
s.slice(
|
|
1369
|
+
Math.max(0, a.start - t.prefix.length),
|
|
1370
|
+
a.start
|
|
1371
1371
|
),
|
|
1372
1372
|
t.prefix
|
|
1373
|
-
) : 1,
|
|
1374
|
-
|
|
1373
|
+
) : 1, p = t.suffix ? Fe(
|
|
1374
|
+
s.slice(a.end, a.end + t.suffix.length),
|
|
1375
1375
|
t.suffix
|
|
1376
1376
|
) : 1;
|
|
1377
1377
|
let f = 1;
|
|
1378
|
-
return typeof t.hint == "number" && (f = 1 - Math.abs(
|
|
1379
|
-
}, o =
|
|
1380
|
-
start:
|
|
1381
|
-
end:
|
|
1382
|
-
score: n(
|
|
1378
|
+
return typeof t.hint == "number" && (f = 1 - Math.abs(a.start - t.hint) / s.length), (50 * d + 20 * y + 20 * p + 2 * f) / 92;
|
|
1379
|
+
}, o = r.map((a) => ({
|
|
1380
|
+
start: a.start,
|
|
1381
|
+
end: a.end,
|
|
1382
|
+
score: n(a)
|
|
1383
1383
|
}));
|
|
1384
|
-
return o.sort((
|
|
1384
|
+
return o.sort((a, u) => u.score - a.score), o[0];
|
|
1385
1385
|
}
|
|
1386
|
-
function
|
|
1386
|
+
function ue(s, e, t) {
|
|
1387
1387
|
const i = t === 1 ? e : e - 1;
|
|
1388
|
-
if (
|
|
1388
|
+
if (s.charAt(i).trim() !== "")
|
|
1389
1389
|
return e;
|
|
1390
|
-
let
|
|
1391
|
-
if (t === 2 ? (
|
|
1390
|
+
let r, n;
|
|
1391
|
+
if (t === 2 ? (r = s.substring(0, e), n = r.trimEnd()) : (r = s.substring(e), n = r.trimStart()), !n.length)
|
|
1392
1392
|
return -1;
|
|
1393
|
-
const o =
|
|
1393
|
+
const o = r.length - n.length;
|
|
1394
1394
|
return t === 2 ? e - o : e + o;
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1397
|
-
const t =
|
|
1398
|
-
|
|
1396
|
+
function Ue(s, e) {
|
|
1397
|
+
const t = s.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1398
|
+
s.commonAncestorContainer,
|
|
1399
1399
|
NodeFilter.SHOW_TEXT
|
|
1400
|
-
), i = e === 1 ?
|
|
1400
|
+
), i = e === 1 ? s.startContainer : s.endContainer, r = e === 1 ? s.endContainer : s.startContainer;
|
|
1401
1401
|
let n = t.nextNode();
|
|
1402
1402
|
for (; n && n !== i; )
|
|
1403
1403
|
n = t.nextNode();
|
|
1404
1404
|
e === 2 && (n = t.previousNode());
|
|
1405
1405
|
let o = -1;
|
|
1406
|
-
const
|
|
1406
|
+
const a = () => {
|
|
1407
1407
|
if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
|
|
1408
1408
|
const u = n.textContent, h = e === 1 ? 0 : u.length;
|
|
1409
|
-
o =
|
|
1409
|
+
o = ue(u, h, e);
|
|
1410
1410
|
}
|
|
1411
1411
|
};
|
|
1412
|
-
for (; n && o === -1 && n !==
|
|
1413
|
-
|
|
1412
|
+
for (; n && o === -1 && n !== r; )
|
|
1413
|
+
a();
|
|
1414
1414
|
if (n && o >= 0)
|
|
1415
1415
|
return { node: n, offset: o };
|
|
1416
1416
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1417
1417
|
}
|
|
1418
|
-
function
|
|
1419
|
-
if (!
|
|
1418
|
+
function St(s) {
|
|
1419
|
+
if (!s.toString().trim().length)
|
|
1420
1420
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1421
|
-
if (
|
|
1421
|
+
if (s.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1422
1422
|
throw new RangeError("Range startContainer is not a text node");
|
|
1423
|
-
if (
|
|
1423
|
+
if (s.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1424
1424
|
throw new RangeError("Range endContainer is not a text node");
|
|
1425
|
-
const e =
|
|
1425
|
+
const e = s.cloneRange();
|
|
1426
1426
|
let t = !1, i = !1;
|
|
1427
|
-
const
|
|
1428
|
-
start:
|
|
1429
|
-
|
|
1430
|
-
|
|
1427
|
+
const r = {
|
|
1428
|
+
start: ue(
|
|
1429
|
+
s.startContainer.textContent,
|
|
1430
|
+
s.startOffset,
|
|
1431
1431
|
1
|
|
1432
1432
|
/* Forwards */
|
|
1433
1433
|
),
|
|
1434
|
-
end:
|
|
1435
|
-
|
|
1436
|
-
|
|
1434
|
+
end: ue(
|
|
1435
|
+
s.endContainer.textContent,
|
|
1436
|
+
s.endOffset,
|
|
1437
1437
|
2
|
|
1438
1438
|
/* Backwards */
|
|
1439
1439
|
)
|
|
1440
1440
|
};
|
|
1441
|
-
if (
|
|
1441
|
+
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)
|
|
1442
1442
|
return e;
|
|
1443
1443
|
if (!t) {
|
|
1444
|
-
const { node: n, offset: o } =
|
|
1444
|
+
const { node: n, offset: o } = Ue(
|
|
1445
1445
|
e,
|
|
1446
1446
|
1
|
|
1447
1447
|
/* Forwards */
|
|
@@ -1449,7 +1449,7 @@ function ut(r) {
|
|
|
1449
1449
|
n && o >= 0 && e.setStart(n, o);
|
|
1450
1450
|
}
|
|
1451
1451
|
if (!i) {
|
|
1452
|
-
const { node: n, offset: o } =
|
|
1452
|
+
const { node: n, offset: o } = Ue(
|
|
1453
1453
|
e,
|
|
1454
1454
|
2
|
|
1455
1455
|
/* Backwards */
|
|
@@ -1458,35 +1458,35 @@ function ut(r) {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
return e;
|
|
1460
1460
|
}
|
|
1461
|
-
function
|
|
1462
|
-
switch (
|
|
1461
|
+
function it(s) {
|
|
1462
|
+
switch (s.nodeType) {
|
|
1463
1463
|
case Node.ELEMENT_NODE:
|
|
1464
1464
|
case Node.TEXT_NODE:
|
|
1465
|
-
return
|
|
1465
|
+
return s.textContent?.length ?? 0;
|
|
1466
1466
|
default:
|
|
1467
1467
|
return 0;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
|
-
function
|
|
1471
|
-
let e =
|
|
1470
|
+
function Be(s) {
|
|
1471
|
+
let e = s.previousSibling, t = 0;
|
|
1472
1472
|
for (; e; )
|
|
1473
|
-
t +=
|
|
1473
|
+
t += it(e), e = e.previousSibling;
|
|
1474
1474
|
return t;
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function rt(s, ...e) {
|
|
1477
1477
|
let t = e.shift();
|
|
1478
|
-
const i =
|
|
1479
|
-
|
|
1478
|
+
const i = s.ownerDocument.createNodeIterator(
|
|
1479
|
+
s,
|
|
1480
1480
|
NodeFilter.SHOW_TEXT
|
|
1481
|
-
),
|
|
1482
|
-
let n = i.nextNode(), o,
|
|
1481
|
+
), r = [];
|
|
1482
|
+
let n = i.nextNode(), o, a = 0;
|
|
1483
1483
|
for (; t !== void 0 && n; )
|
|
1484
|
-
o = n,
|
|
1485
|
-
for (; t !== void 0 && o &&
|
|
1486
|
-
|
|
1484
|
+
o = n, a + o.data.length > t ? (r.push({ node: o, offset: t - a }), t = e.shift()) : (n = i.nextNode(), a += o.data.length);
|
|
1485
|
+
for (; t !== void 0 && o && a === t; )
|
|
1486
|
+
r.push({ node: o, offset: o.data.length }), t = e.shift();
|
|
1487
1487
|
if (t !== void 0)
|
|
1488
1488
|
throw new RangeError("Offset exceeds text length");
|
|
1489
|
-
return
|
|
1489
|
+
return r;
|
|
1490
1490
|
}
|
|
1491
1491
|
class M {
|
|
1492
1492
|
constructor(e, t) {
|
|
@@ -1505,7 +1505,7 @@ class M {
|
|
|
1505
1505
|
throw new Error("Parent is not an ancestor of current element");
|
|
1506
1506
|
let t = this.element, i = this.offset;
|
|
1507
1507
|
for (; t !== e; )
|
|
1508
|
-
i +=
|
|
1508
|
+
i += Be(t), t = t.parentElement;
|
|
1509
1509
|
return new M(t, i);
|
|
1510
1510
|
}
|
|
1511
1511
|
/**
|
|
@@ -1527,7 +1527,7 @@ class M {
|
|
|
1527
1527
|
*/
|
|
1528
1528
|
resolve(e = {}) {
|
|
1529
1529
|
try {
|
|
1530
|
-
return
|
|
1530
|
+
return rt(this.element, this.offset)[0];
|
|
1531
1531
|
} catch (t) {
|
|
1532
1532
|
if (this.offset === 0 && e.direction !== void 0) {
|
|
1533
1533
|
const i = document.createTreeWalker(
|
|
@@ -1535,10 +1535,10 @@ class M {
|
|
|
1535
1535
|
NodeFilter.SHOW_TEXT
|
|
1536
1536
|
);
|
|
1537
1537
|
i.currentNode = this.element;
|
|
1538
|
-
const
|
|
1538
|
+
const r = e.direction === 1, n = r ? i.nextNode() : i.previousNode();
|
|
1539
1539
|
if (!n)
|
|
1540
1540
|
throw t;
|
|
1541
|
-
return { node: n, offset:
|
|
1541
|
+
return { node: n, offset: r ? 0 : n.data.length };
|
|
1542
1542
|
} else
|
|
1543
1543
|
throw t;
|
|
1544
1544
|
}
|
|
@@ -1570,15 +1570,15 @@ class M {
|
|
|
1570
1570
|
throw new Error("Text node offset is out of range");
|
|
1571
1571
|
if (!e.parentElement)
|
|
1572
1572
|
throw new Error("Text node has no parent");
|
|
1573
|
-
const i =
|
|
1573
|
+
const i = Be(e) + t;
|
|
1574
1574
|
return new M(e.parentElement, i);
|
|
1575
1575
|
}
|
|
1576
1576
|
case Node.ELEMENT_NODE: {
|
|
1577
1577
|
if (t < 0 || t > e.childNodes.length)
|
|
1578
1578
|
throw new Error("Child node offset is out of range");
|
|
1579
1579
|
let i = 0;
|
|
1580
|
-
for (let
|
|
1581
|
-
i +=
|
|
1580
|
+
for (let r = 0; r < t; r++)
|
|
1581
|
+
i += it(e.childNodes[r]);
|
|
1582
1582
|
return new M(e, i);
|
|
1583
1583
|
}
|
|
1584
1584
|
default:
|
|
@@ -1612,7 +1612,7 @@ class I {
|
|
|
1612
1612
|
*/
|
|
1613
1613
|
toRange() {
|
|
1614
1614
|
let e, t;
|
|
1615
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] =
|
|
1615
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = rt(
|
|
1616
1616
|
this.start.element,
|
|
1617
1617
|
this.start.offset,
|
|
1618
1618
|
this.end.offset
|
|
@@ -1651,23 +1651,23 @@ class I {
|
|
|
1651
1651
|
* whitespace
|
|
1652
1652
|
*/
|
|
1653
1653
|
static trimmedRange(e) {
|
|
1654
|
-
return
|
|
1654
|
+
return St(I.fromRange(e).toRange());
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
|
-
class
|
|
1657
|
+
class ie {
|
|
1658
1658
|
constructor(e, t, i) {
|
|
1659
1659
|
this.root = e, this.start = t, this.end = i;
|
|
1660
1660
|
}
|
|
1661
1661
|
static fromRange(e, t) {
|
|
1662
1662
|
const i = I.fromRange(t).relativeTo(e);
|
|
1663
|
-
return new
|
|
1663
|
+
return new ie(
|
|
1664
1664
|
e,
|
|
1665
1665
|
i.start.offset,
|
|
1666
1666
|
i.end.offset
|
|
1667
1667
|
);
|
|
1668
1668
|
}
|
|
1669
1669
|
static fromSelector(e, t) {
|
|
1670
|
-
return new
|
|
1670
|
+
return new ie(e, t.start, t.end);
|
|
1671
1671
|
}
|
|
1672
1672
|
toSelector() {
|
|
1673
1673
|
return {
|
|
@@ -1680,7 +1680,7 @@ class Y {
|
|
|
1680
1680
|
return I.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1681
1681
|
}
|
|
1682
1682
|
}
|
|
1683
|
-
class
|
|
1683
|
+
class re {
|
|
1684
1684
|
/**
|
|
1685
1685
|
* @param root - A root element from which to anchor.
|
|
1686
1686
|
*/
|
|
@@ -1693,15 +1693,15 @@ class K {
|
|
|
1693
1693
|
* Will throw if `range` does not contain any text nodes.
|
|
1694
1694
|
*/
|
|
1695
1695
|
static fromRange(e, t) {
|
|
1696
|
-
const i = e.textContent,
|
|
1697
|
-
return new
|
|
1698
|
-
prefix: i.slice(Math.max(0, n -
|
|
1699
|
-
suffix: i.slice(o, Math.min(i.length, o +
|
|
1696
|
+
const i = e.textContent, r = I.fromRange(t).relativeTo(e), n = r.start.offset, o = r.end.offset, a = 32;
|
|
1697
|
+
return new re(e, i.slice(n, o), {
|
|
1698
|
+
prefix: i.slice(Math.max(0, n - a), n),
|
|
1699
|
+
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1700
1700
|
});
|
|
1701
1701
|
}
|
|
1702
1702
|
static fromSelector(e, t) {
|
|
1703
|
-
const { prefix: i, suffix:
|
|
1704
|
-
return new
|
|
1703
|
+
const { prefix: i, suffix: r } = t;
|
|
1704
|
+
return new re(e, t.exact, { prefix: i, suffix: r });
|
|
1705
1705
|
}
|
|
1706
1706
|
toSelector() {
|
|
1707
1707
|
return {
|
|
@@ -1715,26 +1715,26 @@ class K {
|
|
|
1715
1715
|
return this.toPositionAnchor(e).toRange();
|
|
1716
1716
|
}
|
|
1717
1717
|
toPositionAnchor(e = {}) {
|
|
1718
|
-
const t = this.root.textContent, i =
|
|
1718
|
+
const t = this.root.textContent, i = wt(t, this.exact, {
|
|
1719
1719
|
...this.context,
|
|
1720
1720
|
hint: e.hint
|
|
1721
1721
|
});
|
|
1722
1722
|
if (!i)
|
|
1723
1723
|
throw new Error("Quote not found");
|
|
1724
|
-
return new
|
|
1724
|
+
return new ie(this.root, i.start, i.end);
|
|
1725
1725
|
}
|
|
1726
1726
|
}
|
|
1727
|
-
function
|
|
1728
|
-
const e =
|
|
1727
|
+
function Ct(s) {
|
|
1728
|
+
const e = s.tagName.toUpperCase();
|
|
1729
1729
|
return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
|
|
1730
1730
|
}
|
|
1731
|
-
function
|
|
1731
|
+
function ne(s, e) {
|
|
1732
1732
|
try {
|
|
1733
1733
|
const t = e.locations, i = e.text;
|
|
1734
1734
|
if (i && i.highlight) {
|
|
1735
|
-
let
|
|
1736
|
-
t && t.getCssSelector() && (
|
|
1737
|
-
const n = new
|
|
1735
|
+
let r;
|
|
1736
|
+
t && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), r || (r = s.body);
|
|
1737
|
+
const n = new re(r, i.highlight, {
|
|
1738
1738
|
prefix: i.before,
|
|
1739
1739
|
suffix: i.after
|
|
1740
1740
|
});
|
|
@@ -1745,15 +1745,15 @@ function ee(r, e) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
}
|
|
1747
1747
|
if (t) {
|
|
1748
|
-
let
|
|
1749
|
-
if (!
|
|
1748
|
+
let r = null;
|
|
1749
|
+
if (!r && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), !r && t.fragments) {
|
|
1750
1750
|
for (const n of t.fragments)
|
|
1751
|
-
if (
|
|
1751
|
+
if (r = s.getElementById(n), r)
|
|
1752
1752
|
break;
|
|
1753
1753
|
}
|
|
1754
|
-
if (
|
|
1755
|
-
const n =
|
|
1756
|
-
return
|
|
1754
|
+
if (r) {
|
|
1755
|
+
const n = s.createRange();
|
|
1756
|
+
return r.childNodes.length === 0 || Ct(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
|
|
1757
1757
|
}
|
|
1758
1758
|
}
|
|
1759
1759
|
} catch (t) {
|
|
@@ -1761,12 +1761,12 @@ function ee(r, e) {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
return null;
|
|
1763
1763
|
}
|
|
1764
|
-
function
|
|
1765
|
-
let t =
|
|
1766
|
-
t.length ||
|
|
1767
|
-
const i = 1,
|
|
1764
|
+
function Pt(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
1768
|
for (const h of t)
|
|
1769
|
-
|
|
1769
|
+
r.push({
|
|
1770
1770
|
bottom: h.bottom,
|
|
1771
1771
|
height: h.height,
|
|
1772
1772
|
left: h.left,
|
|
@@ -1774,221 +1774,264 @@ function pt(r, e) {
|
|
|
1774
1774
|
top: h.top,
|
|
1775
1775
|
width: h.width
|
|
1776
1776
|
});
|
|
1777
|
-
const n =
|
|
1778
|
-
|
|
1777
|
+
const n = st(
|
|
1778
|
+
r,
|
|
1779
1779
|
i
|
|
1780
|
-
), o =
|
|
1781
|
-
for (let h =
|
|
1782
|
-
const c =
|
|
1780
|
+
), o = Mt(n, i), a = nt(o), u = 4;
|
|
1781
|
+
for (let h = a.length - 1; h >= 0; h--) {
|
|
1782
|
+
const c = a[h];
|
|
1783
1783
|
if (!(c.width * c.height > u))
|
|
1784
|
-
if (
|
|
1785
|
-
|
|
1784
|
+
if (a.length > 1)
|
|
1785
|
+
a.splice(h, 1);
|
|
1786
1786
|
else
|
|
1787
1787
|
break;
|
|
1788
1788
|
}
|
|
1789
|
-
return
|
|
1789
|
+
return a;
|
|
1790
1790
|
}
|
|
1791
|
-
function
|
|
1792
|
-
for (let i = 0; i <
|
|
1793
|
-
for (let
|
|
1794
|
-
const n =
|
|
1791
|
+
function st(s, e, t) {
|
|
1792
|
+
for (let i = 0; i < s.length; i++)
|
|
1793
|
+
for (let r = i + 1; r < s.length; r++) {
|
|
1794
|
+
const n = s[i], o = s[r];
|
|
1795
1795
|
if (n === o)
|
|
1796
1796
|
continue;
|
|
1797
|
-
const
|
|
1798
|
-
if (
|
|
1799
|
-
const m =
|
|
1800
|
-
return m.push(
|
|
1797
|
+
const a = P(n.top, o.top, e) && P(n.bottom, o.bottom, e), u = P(n.left, o.left, e) && P(n.right, o.right, e);
|
|
1798
|
+
if (a && !u && ot(n, o, e)) {
|
|
1799
|
+
const m = s.filter((y) => y !== n && y !== o), d = At(n, o);
|
|
1800
|
+
return m.push(d), st(
|
|
1801
1801
|
m,
|
|
1802
1802
|
e
|
|
1803
1803
|
);
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
return
|
|
1806
|
+
return s;
|
|
1807
1807
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const t = Math.min(
|
|
1808
|
+
function At(s, e) {
|
|
1809
|
+
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);
|
|
1810
1810
|
return {
|
|
1811
1811
|
bottom: n,
|
|
1812
|
-
height: n -
|
|
1812
|
+
height: n - r,
|
|
1813
1813
|
left: t,
|
|
1814
1814
|
right: i,
|
|
1815
|
-
top:
|
|
1815
|
+
top: r,
|
|
1816
1816
|
width: i - t
|
|
1817
1817
|
};
|
|
1818
1818
|
}
|
|
1819
|
-
function
|
|
1820
|
-
const t = new Set(
|
|
1821
|
-
for (const i of
|
|
1819
|
+
function Mt(s, e) {
|
|
1820
|
+
const t = new Set(s);
|
|
1821
|
+
for (const i of s) {
|
|
1822
1822
|
if (!(i.width > 1 && i.height > 1)) {
|
|
1823
1823
|
t.delete(i);
|
|
1824
1824
|
continue;
|
|
1825
1825
|
}
|
|
1826
|
-
for (const n of
|
|
1827
|
-
if (i !== n && t.has(n) &&
|
|
1826
|
+
for (const n of s)
|
|
1827
|
+
if (i !== n && t.has(n) && Nt(n, i, e)) {
|
|
1828
1828
|
t.delete(i);
|
|
1829
1829
|
break;
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
1832
1832
|
return Array.from(t);
|
|
1833
1833
|
}
|
|
1834
|
-
function
|
|
1835
|
-
return
|
|
1834
|
+
function Nt(s, e, t) {
|
|
1835
|
+
return K(s, e.left, e.top, t) && K(s, e.right, e.top, t) && K(s, e.left, e.bottom, t) && K(s, e.right, e.bottom, t);
|
|
1836
1836
|
}
|
|
1837
|
-
function
|
|
1838
|
-
return (
|
|
1837
|
+
function K(s, e, t, i) {
|
|
1838
|
+
return (s.left < e || P(s.left, e, i)) && (s.right > e || P(s.right, e, i)) && (s.top < t || P(s.top, t, i)) && (s.bottom > t || P(s.bottom, t, i));
|
|
1839
1839
|
}
|
|
1840
|
-
function
|
|
1841
|
-
for (let e = 0; e <
|
|
1842
|
-
for (let t = e + 1; t <
|
|
1843
|
-
const i =
|
|
1844
|
-
if (i !==
|
|
1840
|
+
function nt(s) {
|
|
1841
|
+
for (let e = 0; e < s.length; e++)
|
|
1842
|
+
for (let t = e + 1; t < s.length; t++) {
|
|
1843
|
+
const i = s[e], r = s[t];
|
|
1844
|
+
if (i !== r && ot(i, r, -1)) {
|
|
1845
1845
|
let n = [], o;
|
|
1846
|
-
const
|
|
1847
|
-
if (
|
|
1848
|
-
n =
|
|
1846
|
+
const a = He(i, r);
|
|
1847
|
+
if (a.length === 1)
|
|
1848
|
+
n = a, o = i;
|
|
1849
1849
|
else {
|
|
1850
|
-
const h =
|
|
1851
|
-
|
|
1850
|
+
const h = He(r, i);
|
|
1851
|
+
a.length < h.length ? (n = a, o = i) : (n = h, o = r);
|
|
1852
1852
|
}
|
|
1853
|
-
const u =
|
|
1854
|
-
return Array.prototype.push.apply(u, n),
|
|
1853
|
+
const u = s.filter((h) => h !== o);
|
|
1854
|
+
return Array.prototype.push.apply(u, n), nt(u);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
|
-
return
|
|
1857
|
+
return s;
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
const t =
|
|
1859
|
+
function He(s, e) {
|
|
1860
|
+
const t = Ot(e, s);
|
|
1861
1861
|
if (t.height === 0 || t.width === 0)
|
|
1862
|
-
return [
|
|
1862
|
+
return [s];
|
|
1863
1863
|
const i = [];
|
|
1864
1864
|
{
|
|
1865
|
-
const
|
|
1866
|
-
bottom:
|
|
1865
|
+
const r = {
|
|
1866
|
+
bottom: s.bottom,
|
|
1867
1867
|
height: 0,
|
|
1868
|
-
left:
|
|
1868
|
+
left: s.left,
|
|
1869
1869
|
right: t.left,
|
|
1870
|
-
top:
|
|
1870
|
+
top: s.top,
|
|
1871
1871
|
width: 0
|
|
1872
1872
|
};
|
|
1873
|
-
|
|
1873
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1874
1874
|
}
|
|
1875
1875
|
{
|
|
1876
|
-
const
|
|
1876
|
+
const r = {
|
|
1877
1877
|
bottom: t.top,
|
|
1878
1878
|
height: 0,
|
|
1879
1879
|
left: t.left,
|
|
1880
1880
|
right: t.right,
|
|
1881
|
-
top:
|
|
1881
|
+
top: s.top,
|
|
1882
1882
|
width: 0
|
|
1883
1883
|
};
|
|
1884
|
-
|
|
1884
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1885
1885
|
}
|
|
1886
1886
|
{
|
|
1887
|
-
const
|
|
1888
|
-
bottom:
|
|
1887
|
+
const r = {
|
|
1888
|
+
bottom: s.bottom,
|
|
1889
1889
|
height: 0,
|
|
1890
1890
|
left: t.left,
|
|
1891
1891
|
right: t.right,
|
|
1892
1892
|
top: t.bottom,
|
|
1893
1893
|
width: 0
|
|
1894
1894
|
};
|
|
1895
|
-
|
|
1895
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1896
1896
|
}
|
|
1897
1897
|
{
|
|
1898
|
-
const
|
|
1899
|
-
bottom:
|
|
1898
|
+
const r = {
|
|
1899
|
+
bottom: s.bottom,
|
|
1900
1900
|
height: 0,
|
|
1901
1901
|
left: t.right,
|
|
1902
|
-
right:
|
|
1903
|
-
top:
|
|
1902
|
+
right: s.right,
|
|
1903
|
+
top: s.top,
|
|
1904
1904
|
width: 0
|
|
1905
1905
|
};
|
|
1906
|
-
|
|
1906
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1907
1907
|
}
|
|
1908
1908
|
return i;
|
|
1909
1909
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const t = Math.max(
|
|
1910
|
+
function Ot(s, e) {
|
|
1911
|
+
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);
|
|
1912
1912
|
return {
|
|
1913
1913
|
bottom: n,
|
|
1914
|
-
height: Math.max(0, n -
|
|
1914
|
+
height: Math.max(0, n - r),
|
|
1915
1915
|
left: t,
|
|
1916
1916
|
right: i,
|
|
1917
|
-
top:
|
|
1917
|
+
top: r,
|
|
1918
1918
|
width: Math.max(0, i - t)
|
|
1919
1919
|
};
|
|
1920
1920
|
}
|
|
1921
|
-
function
|
|
1922
|
-
return (
|
|
1921
|
+
function ot(s, e, t) {
|
|
1922
|
+
return (s.left < e.right || t >= 0 && P(s.left, e.right, t)) && (e.left < s.right || t >= 0 && P(e.left, s.right, t)) && (s.top < e.bottom || t >= 0 && P(s.top, e.bottom, t)) && (e.top < s.bottom || t >= 0 && P(e.top, s.bottom, t));
|
|
1923
1923
|
}
|
|
1924
|
-
function P(
|
|
1925
|
-
return Math.abs(
|
|
1924
|
+
function P(s, e, t) {
|
|
1925
|
+
return Math.abs(s - e) <= t;
|
|
1926
1926
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const e = {}, t =
|
|
1929
|
-
for (const i in
|
|
1927
|
+
function Me(s) {
|
|
1928
|
+
const e = {}, t = s.document.documentElement.style;
|
|
1929
|
+
for (const i in s.document.documentElement.style)
|
|
1930
1930
|
Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
|
|
1931
1931
|
return e;
|
|
1932
1932
|
}
|
|
1933
|
-
function
|
|
1934
|
-
const t =
|
|
1933
|
+
function at(s, e) {
|
|
1934
|
+
const t = Me(s);
|
|
1935
1935
|
Object.keys(t).forEach((i) => {
|
|
1936
|
-
e.hasOwnProperty(i) ||
|
|
1937
|
-
}), Object.entries(e).forEach(([i,
|
|
1938
|
-
t[i] !==
|
|
1936
|
+
e.hasOwnProperty(i) || oe(s, i);
|
|
1937
|
+
}), Object.entries(e).forEach(([i, r]) => {
|
|
1938
|
+
t[i] !== r && X(s, i, r);
|
|
1939
1939
|
});
|
|
1940
1940
|
}
|
|
1941
|
-
function
|
|
1942
|
-
return
|
|
1941
|
+
function le(s, e) {
|
|
1942
|
+
return s.document.documentElement.style.getPropertyValue(e);
|
|
1943
1943
|
}
|
|
1944
|
-
function
|
|
1945
|
-
|
|
1944
|
+
function X(s, e, t) {
|
|
1945
|
+
s.document.documentElement.style.setProperty(e, t);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1948
|
-
|
|
1947
|
+
function oe(s, e) {
|
|
1948
|
+
s.document.documentElement.style.removeProperty(e);
|
|
1949
1949
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
if (
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1950
|
+
let Z = null, he = null, $ = 0;
|
|
1951
|
+
const B = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), Lt = () => {
|
|
1952
|
+
if (!Z)
|
|
1953
|
+
if (typeof OffscreenCanvas < "u")
|
|
1954
|
+
Z = new OffscreenCanvas(5, 5), he = Z.getContext("2d", {
|
|
1955
|
+
willReadFrequently: !0,
|
|
1956
|
+
desynchronized: !0
|
|
1957
|
+
});
|
|
1958
|
+
else {
|
|
1959
|
+
const s = document.createElement("canvas");
|
|
1960
|
+
s.width = 5, s.height = 5, Z = s, he = s.getContext("2d", {
|
|
1961
|
+
willReadFrequently: !0,
|
|
1962
|
+
desynchronized: !0
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
return he;
|
|
1966
|
+
}, Rt = (s) => {
|
|
1967
|
+
if (!s) return !0;
|
|
1968
|
+
const e = s.trim().toLowerCase();
|
|
1969
|
+
return e.startsWith("var(") || [
|
|
1970
|
+
"transparent",
|
|
1971
|
+
"currentcolor",
|
|
1972
|
+
"inherit",
|
|
1973
|
+
"initial",
|
|
1974
|
+
"revert",
|
|
1975
|
+
"unset",
|
|
1976
|
+
"revert-layer"
|
|
1977
|
+
].includes(e) ? !0 : [
|
|
1978
|
+
"linear-gradient",
|
|
1979
|
+
"radial-gradient",
|
|
1980
|
+
"conic-gradient",
|
|
1981
|
+
"repeating-linear-gradient",
|
|
1982
|
+
"repeating-radial-gradient",
|
|
1983
|
+
"repeating-conic-gradient"
|
|
1984
|
+
].some((r) => e.includes(r));
|
|
1985
|
+
}, J = (s, e) => {
|
|
1986
|
+
console.warn(
|
|
1987
|
+
`[Decorator] Could not parse color: "${s}". ${e} Falling back to ${JSON.stringify(B)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
1988
|
+
);
|
|
1989
|
+
}, de = (s, e = null) => {
|
|
1990
|
+
const t = e ? `${s}|${e}` : s, i = F.get(t);
|
|
1991
|
+
if (i !== void 0)
|
|
1992
|
+
return i ?? B;
|
|
1993
|
+
if (Rt(s))
|
|
1994
|
+
return J(s, "Unsupported color format or special value."), F.set(t, null), B;
|
|
1995
|
+
const r = Lt();
|
|
1996
|
+
if (!r)
|
|
1997
|
+
return J(s, "Could not get canvas context."), F.set(t, null), B;
|
|
1998
|
+
try {
|
|
1999
|
+
$ === 0 && r.clearRect(0, 0, 5, 5);
|
|
2000
|
+
const n = $ % 5, o = Math.floor($ / 5);
|
|
2001
|
+
r.clearRect(n, o, 1, 1), e && (r.fillStyle = e, r.fillRect(n, o, 1, 1)), r.fillStyle = s, r.fillRect(n, o, 1, 1);
|
|
2002
|
+
const a = r.getImageData(n, o, 1, 1);
|
|
2003
|
+
$ = ($ + 1) % 25;
|
|
2004
|
+
const [u, h, c, m] = a.data;
|
|
2005
|
+
if (m === 0)
|
|
2006
|
+
return J(s, "Fully transparent color."), F.set(t, null), B;
|
|
2007
|
+
const d = { r: u, g: h, b: c, a: m / 255 };
|
|
2008
|
+
return F.set(t, d), d;
|
|
2009
|
+
} catch (n) {
|
|
2010
|
+
return J(s, `Error: ${n instanceof Error ? n.message : String(n)}`), F.set(t, null), B;
|
|
2011
|
+
}
|
|
2012
|
+
}, ce = (s) => {
|
|
2013
|
+
const e = s / 255;
|
|
2014
|
+
return e <= 0.03928 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
|
|
2015
|
+
}, ke = (s) => {
|
|
2016
|
+
const e = ce(s.r), t = ce(s.g), i = ce(s.b);
|
|
2017
|
+
return 0.2126 * e + 0.7152 * t + 0.0722 * i;
|
|
2018
|
+
}, $e = (s, e) => {
|
|
2019
|
+
const t = typeof s == "string" ? de(s) : s, i = typeof e == "string" ? de(e) : e, r = ke(t), n = ke(i), o = Math.max(r, n), a = Math.min(r, n);
|
|
2020
|
+
return (o + 0.05) / (a + 0.05);
|
|
2021
|
+
}, pe = (s, e = null) => {
|
|
2022
|
+
const t = de(s, e), i = $e(t, { r: 255, g: 255, b: 255, a: 1 }), r = $e(t, { r: 0, g: 0, b: 0, a: 1 });
|
|
2023
|
+
return i > r;
|
|
2024
|
+
}, It = (s, e = null) => pe(s, e) ? "white" : "black", Ve = "#FFFF00";
|
|
2025
|
+
var zt = /* @__PURE__ */ ((s) => (s.Wrap = "wrap", s.Viewport = "viewport", s.Bounds = "bounds", s.Page = "page", s))(zt || {}), Dt = /* @__PURE__ */ ((s) => (s.Boxes = "boxes", s.Bounds = "bounds", s))(Dt || {});
|
|
2026
|
+
const Wt = () => "Highlight" in window, qe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2027
|
+
class Ft {
|
|
1985
2028
|
/**
|
|
1986
2029
|
* Creates a DecorationGroup object
|
|
1987
2030
|
* @param id Unique HTML ID-adhering name of the group
|
|
1988
2031
|
* @param name Human-readable name of the group
|
|
1989
2032
|
*/
|
|
1990
|
-
constructor(e, t, i,
|
|
1991
|
-
this.wnd = e, this.comms = t, this.id = i, this.name =
|
|
2033
|
+
constructor(e, t, i, r) {
|
|
2034
|
+
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, Wt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
1992
2035
|
}
|
|
1993
2036
|
get activeable() {
|
|
1994
2037
|
return this.activateable;
|
|
@@ -2001,13 +2044,13 @@ class Ct {
|
|
|
2001
2044
|
* @param decoration Decoration to add
|
|
2002
2045
|
*/
|
|
2003
2046
|
add(e) {
|
|
2004
|
-
const t = `${this.id}-${this.lastItemId++}`, i =
|
|
2047
|
+
const t = `${this.id}-${this.lastItemId++}`, i = ne(this.wnd.document, e.locator);
|
|
2005
2048
|
if (!i) {
|
|
2006
2049
|
this.comms.log("Can't locate DOM range for decoration", e);
|
|
2007
2050
|
return;
|
|
2008
2051
|
}
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2052
|
+
const r = i.commonAncestorContainer;
|
|
2053
|
+
r.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (qe.includes(r.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), i.cloneContents().querySelector(qe.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (r.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));
|
|
2011
2054
|
const n = {
|
|
2012
2055
|
decoration: e,
|
|
2013
2056
|
id: t,
|
|
@@ -2020,7 +2063,7 @@ class Ct {
|
|
|
2020
2063
|
* @param identifier ID of item to remove
|
|
2021
2064
|
*/
|
|
2022
2065
|
remove(e) {
|
|
2023
|
-
const t = this.items.findIndex((
|
|
2066
|
+
const t = this.items.findIndex((r) => r.decoration.id === e);
|
|
2024
2067
|
if (t < 0) return;
|
|
2025
2068
|
const i = this.items[t];
|
|
2026
2069
|
this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
|
|
@@ -2047,10 +2090,12 @@ class Ct {
|
|
|
2047
2090
|
}
|
|
2048
2091
|
experimentalLayout(e) {
|
|
2049
2092
|
const [t, i] = this.requireContainer(!0);
|
|
2050
|
-
i.add(e.range)
|
|
2093
|
+
i.add(e.range);
|
|
2094
|
+
const r = le(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = e.decoration?.style?.tint ?? Ve;
|
|
2095
|
+
t.innerHTML = `
|
|
2051
2096
|
::highlight(${this.id}) {
|
|
2052
|
-
color:
|
|
2053
|
-
background-color: ${
|
|
2097
|
+
color: ${It(n, r)};
|
|
2098
|
+
background-color: ${n};
|
|
2054
2099
|
}`;
|
|
2055
2100
|
}
|
|
2056
2101
|
/**
|
|
@@ -2062,33 +2107,34 @@ class Ct {
|
|
|
2062
2107
|
return this.experimentalLayout(e);
|
|
2063
2108
|
const t = this.wnd.document.createElement("div");
|
|
2064
2109
|
t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
|
|
2065
|
-
const i = this.wnd.innerWidth,
|
|
2110
|
+
const i = this.wnd.innerWidth, r = parseInt(
|
|
2066
2111
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2067
2112
|
"column-count"
|
|
2068
2113
|
)
|
|
2069
|
-
), n = i / (
|
|
2070
|
-
if (
|
|
2071
|
-
|
|
2114
|
+
), n = i / (r || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, u = o.scrollTop, h = (p, f, g) => {
|
|
2115
|
+
if (p.style.position = "absolute", e.decoration?.style?.width === "viewport") {
|
|
2116
|
+
p.style.width = `${i}px`, p.style.height = `${f.height}px`;
|
|
2072
2117
|
let E = Math.floor(f.left / i) * i;
|
|
2073
|
-
|
|
2118
|
+
p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
|
|
2074
2119
|
} else if (e.decoration?.style?.width === "bounds")
|
|
2075
|
-
|
|
2120
|
+
p.style.width = `${g.width}px`, p.style.height = `${f.height}px`, p.style.left = `${g.left + a}px`, p.style.top = `${f.top + u}px`;
|
|
2076
2121
|
else if (e.decoration?.style?.width === "page") {
|
|
2077
|
-
|
|
2122
|
+
p.style.width = `${n}px`, p.style.height = `${f.height}px`;
|
|
2078
2123
|
let E = Math.floor(f.left / n) * n;
|
|
2079
|
-
|
|
2124
|
+
p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
|
|
2080
2125
|
} else
|
|
2081
|
-
|
|
2126
|
+
p.style.width = `${f.width}px`, p.style.height = `${f.height}px`, p.style.left = `${f.left + a}px`, p.style.top = `${f.top + u}px`;
|
|
2082
2127
|
}, c = e.range.getBoundingClientRect();
|
|
2083
2128
|
let m = this.wnd.document.createElement("template");
|
|
2084
|
-
const
|
|
2129
|
+
const d = this.getCurrentDarkMode();
|
|
2085
2130
|
m.innerHTML = `
|
|
2086
2131
|
<div
|
|
2087
|
-
|
|
2132
|
+
data-readium="true"
|
|
2133
|
+
class="readium-highlight"
|
|
2088
2134
|
style="${[
|
|
2089
|
-
`background-color: ${e.decoration?.style?.tint ??
|
|
2135
|
+
`background-color: ${e.decoration?.style?.tint ?? Ve} !important`,
|
|
2090
2136
|
//"opacity: 0.3 !important",
|
|
2091
|
-
`mix-blend-mode: ${
|
|
2137
|
+
`mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
|
|
2092
2138
|
"opacity: 1 !important",
|
|
2093
2139
|
"box-sizing: border-box !important"
|
|
2094
2140
|
].join("; ")}"
|
|
@@ -2097,14 +2143,14 @@ class Ct {
|
|
|
2097
2143
|
`.trim();
|
|
2098
2144
|
const y = m.content.firstElementChild;
|
|
2099
2145
|
if (e.decoration?.style?.layout === "bounds") {
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2146
|
+
const p = y.cloneNode(!0);
|
|
2147
|
+
p.style.setProperty("pointer-events", "none"), h(p, c, c), t.append(p);
|
|
2102
2148
|
} else {
|
|
2103
|
-
let
|
|
2149
|
+
let p = Pt(
|
|
2104
2150
|
e.range
|
|
2105
2151
|
);
|
|
2106
|
-
|
|
2107
|
-
for (let f of
|
|
2152
|
+
p = p.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);
|
|
2153
|
+
for (let f of p) {
|
|
2108
2154
|
const g = y.cloneNode(!0);
|
|
2109
2155
|
g.style.setProperty("pointer-events", "none"), h(g, f, c), t.append(g);
|
|
2110
2156
|
}
|
|
@@ -2132,6 +2178,9 @@ class Ct {
|
|
|
2132
2178
|
}
|
|
2133
2179
|
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;
|
|
2134
2180
|
}
|
|
2181
|
+
getCurrentDarkMode() {
|
|
2182
|
+
return le(this.wnd, "--USER__appearance") === "readium-night-on" || pe(le(this.wnd, "--USER__backgroundColor")) || pe(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
|
|
2183
|
+
}
|
|
2135
2184
|
/**
|
|
2136
2185
|
* Removes the group container.
|
|
2137
2186
|
*/
|
|
@@ -2139,13 +2188,23 @@ class Ct {
|
|
|
2139
2188
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2140
2189
|
}
|
|
2141
2190
|
}
|
|
2142
|
-
const
|
|
2191
|
+
const q = class q extends Y {
|
|
2143
2192
|
constructor() {
|
|
2144
2193
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2145
2194
|
}
|
|
2146
2195
|
cleanup() {
|
|
2147
2196
|
this.groups.forEach((e) => e.clear()), this.groups.clear();
|
|
2148
2197
|
}
|
|
2198
|
+
updateHighlightStyles() {
|
|
2199
|
+
this.groups.forEach((e) => {
|
|
2200
|
+
e.requestLayout();
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
extractCustomProperty(e, t) {
|
|
2204
|
+
if (!e) return null;
|
|
2205
|
+
const i = e.match(new RegExp(`${t}:\\s*([^;]+)`));
|
|
2206
|
+
return i ? i[1].trim() : null;
|
|
2207
|
+
}
|
|
2149
2208
|
handleResize() {
|
|
2150
2209
|
this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
|
|
2151
2210
|
this.groups.forEach((e) => {
|
|
@@ -2154,9 +2213,9 @@ const H = class H extends j {
|
|
|
2154
2213
|
}, 50);
|
|
2155
2214
|
}
|
|
2156
2215
|
mount(e, t) {
|
|
2157
|
-
return this.wnd = e, t.register("decorate",
|
|
2216
|
+
return this.wnd = e, t.register("decorate", q.moduleName, (i, r) => {
|
|
2158
2217
|
const n = i;
|
|
2159
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
2218
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = R.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Ft(
|
|
2160
2219
|
e,
|
|
2161
2220
|
t,
|
|
2162
2221
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2177,16 +2236,29 @@ const H = class H extends j {
|
|
|
2177
2236
|
o?.update(n.decoration);
|
|
2178
2237
|
break;
|
|
2179
2238
|
}
|
|
2180
|
-
|
|
2181
|
-
}), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer),
|
|
2239
|
+
r(!0);
|
|
2240
|
+
}), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
|
|
2241
|
+
i.some((n) => {
|
|
2242
|
+
if (n.type === "attributes" && n.attributeName === "style") {
|
|
2243
|
+
const o = n.target, a = n.oldValue, u = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), c = this.extractCustomProperty(u, "--USER__appearance"), m = this.extractCustomProperty(a, "--USER__backgroundColor"), d = this.extractCustomProperty(u, "--USER__backgroundColor");
|
|
2244
|
+
return h !== c || m !== d;
|
|
2245
|
+
}
|
|
2246
|
+
return !1;
|
|
2247
|
+
}) && this.updateHighlightStyles();
|
|
2248
|
+
}), this.backgroundObserver.observe(e.document.documentElement, {
|
|
2249
|
+
attributes: !0,
|
|
2250
|
+
attributeFilter: ["style"],
|
|
2251
|
+
attributeOldValue: !0,
|
|
2252
|
+
subtree: !0
|
|
2253
|
+
}), t.log("Decorator Mounted"), !0;
|
|
2182
2254
|
}
|
|
2183
2255
|
unmount(e, t) {
|
|
2184
|
-
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(
|
|
2256
|
+
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
|
|
2185
2257
|
}
|
|
2186
2258
|
};
|
|
2187
|
-
|
|
2188
|
-
let
|
|
2189
|
-
const
|
|
2259
|
+
q.moduleName = "decorator";
|
|
2260
|
+
let fe = q;
|
|
2261
|
+
const je = "readium-snapper-style", j = class j extends Y {
|
|
2190
2262
|
constructor() {
|
|
2191
2263
|
super(...arguments), this.protected = !1;
|
|
2192
2264
|
}
|
|
@@ -2199,59 +2271,59 @@ const Ie = "readium-snapper-style", $ = class $ extends j {
|
|
|
2199
2271
|
}
|
|
2200
2272
|
mount(e, t) {
|
|
2201
2273
|
const i = e.document.createElement("style");
|
|
2202
|
-
return i.dataset.readium = "true", i.id =
|
|
2274
|
+
return i.dataset.readium = "true", i.id = je, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", j.moduleName, (r, n) => {
|
|
2203
2275
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2204
|
-
}), t.register("unprotect",
|
|
2276
|
+
}), t.register("unprotect", j.moduleName, (r, n) => {
|
|
2205
2277
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2206
2278
|
}), t.log("Snapper Mounted"), !0;
|
|
2207
2279
|
}
|
|
2208
2280
|
unmount(e, t) {
|
|
2209
|
-
return e.document.getElementById(
|
|
2281
|
+
return e.document.getElementById(je)?.remove(), t.log("Snapper Unmounted"), !0;
|
|
2210
2282
|
}
|
|
2211
2283
|
};
|
|
2212
|
-
|
|
2213
|
-
let
|
|
2214
|
-
function
|
|
2215
|
-
return
|
|
2284
|
+
j.moduleName = "snapper";
|
|
2285
|
+
let G = j;
|
|
2286
|
+
function z(s) {
|
|
2287
|
+
return s.document.body.dir.toLowerCase() === "rtl";
|
|
2216
2288
|
}
|
|
2217
|
-
function
|
|
2289
|
+
function lt(s) {
|
|
2218
2290
|
return parseInt(
|
|
2219
|
-
|
|
2220
|
-
|
|
2291
|
+
s.getComputedStyle(
|
|
2292
|
+
s.document.documentElement
|
|
2221
2293
|
).getPropertyValue("column-count")
|
|
2222
2294
|
);
|
|
2223
2295
|
}
|
|
2224
|
-
function
|
|
2225
|
-
const e = getComputedStyle(
|
|
2226
|
-
return
|
|
2296
|
+
function _e(s) {
|
|
2297
|
+
const e = getComputedStyle(s), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
|
|
2298
|
+
return s.clientHeight - t - i;
|
|
2227
2299
|
}
|
|
2228
|
-
function
|
|
2229
|
-
const e =
|
|
2300
|
+
function Xe(s) {
|
|
2301
|
+
const e = lt(s);
|
|
2230
2302
|
if (!e)
|
|
2231
2303
|
return !1;
|
|
2232
|
-
const t =
|
|
2304
|
+
const t = s.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2233
2305
|
for (const h of t)
|
|
2234
2306
|
h.remove();
|
|
2235
|
-
const i = t.length,
|
|
2307
|
+
const i = t.length, r = s.document.scrollingElement.scrollWidth, n = s.visualViewport.width, a = Math.round(r / n * e) % e, u = e === 1 || a === 0 ? 0 : e - a;
|
|
2236
2308
|
if (u > 0)
|
|
2237
2309
|
for (let h = 0; h < u; h++) {
|
|
2238
|
-
const c =
|
|
2239
|
-
c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height =
|
|
2310
|
+
const c = s.document.createElement("div");
|
|
2311
|
+
c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = _e(s.document.documentElement) + "px"), c.innerHTML = "​", s.document.body.appendChild(c);
|
|
2240
2312
|
}
|
|
2241
2313
|
return i !== u;
|
|
2242
2314
|
}
|
|
2243
|
-
function
|
|
2244
|
-
const e =
|
|
2245
|
-
e.appendChild(
|
|
2315
|
+
function ht(s) {
|
|
2316
|
+
const e = s.document.createElement("style");
|
|
2317
|
+
e.appendChild(s.document.createTextNode("*{}")), s.document.body.appendChild(e), s.document.body.removeChild(e);
|
|
2246
2318
|
}
|
|
2247
|
-
function
|
|
2248
|
-
return
|
|
2319
|
+
function Ut(s) {
|
|
2320
|
+
return s < 0.5 ? 2 * s * s : -1 + (4 - 2 * s) * s;
|
|
2249
2321
|
}
|
|
2250
|
-
function v(
|
|
2251
|
-
const e =
|
|
2322
|
+
function v(s) {
|
|
2323
|
+
const e = s.getSelection();
|
|
2252
2324
|
e && e.removeAllRanges();
|
|
2253
2325
|
}
|
|
2254
|
-
const
|
|
2326
|
+
const Bt = [
|
|
2255
2327
|
"a",
|
|
2256
2328
|
"audio",
|
|
2257
2329
|
"button",
|
|
@@ -2265,14 +2337,14 @@ const At = [
|
|
|
2265
2337
|
"textarea",
|
|
2266
2338
|
"video"
|
|
2267
2339
|
];
|
|
2268
|
-
function
|
|
2269
|
-
return
|
|
2340
|
+
function ct(s) {
|
|
2341
|
+
return Bt.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && s.getAttribute("contenteditable")?.toLowerCase() !== "false" ? s : s.parentElement ? ct(s.parentElement) : null;
|
|
2270
2342
|
}
|
|
2271
|
-
function
|
|
2272
|
-
const t =
|
|
2343
|
+
function Ne(s, e) {
|
|
2344
|
+
const t = ut(s, s.document.body, e), i = s._readium_cssSelectorGenerator.getCssSelector(t, {
|
|
2273
2345
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2274
2346
|
});
|
|
2275
|
-
return new
|
|
2347
|
+
return new R({
|
|
2276
2348
|
href: "#",
|
|
2277
2349
|
type: "application/xhtml+xml",
|
|
2278
2350
|
locations: new b({
|
|
@@ -2280,33 +2352,33 @@ function ve(r, e) {
|
|
|
2280
2352
|
["cssSelector", i]
|
|
2281
2353
|
])
|
|
2282
2354
|
}),
|
|
2283
|
-
text: new
|
|
2355
|
+
text: new D({
|
|
2284
2356
|
highlight: t.textContent || void 0
|
|
2285
2357
|
})
|
|
2286
2358
|
});
|
|
2287
2359
|
}
|
|
2288
|
-
function
|
|
2360
|
+
function ut(s, e, t) {
|
|
2289
2361
|
for (var i = 0; i < e.children.length; i++) {
|
|
2290
|
-
const
|
|
2291
|
-
if (
|
|
2292
|
-
return
|
|
2362
|
+
const r = e.children[i];
|
|
2363
|
+
if (!$t(r) && Ht(s, r, t))
|
|
2364
|
+
return kt(s, r) ? r : ut(s, r, t);
|
|
2293
2365
|
}
|
|
2294
2366
|
return e;
|
|
2295
2367
|
}
|
|
2296
|
-
function
|
|
2368
|
+
function Ht(s, e, t) {
|
|
2297
2369
|
if (e === document.body || e === document.documentElement)
|
|
2298
2370
|
return !0;
|
|
2299
2371
|
if (!document || !document.documentElement || !document.body)
|
|
2300
2372
|
return !1;
|
|
2301
2373
|
const i = e.getBoundingClientRect();
|
|
2302
|
-
return t ? i.bottom > 0 && i.top <
|
|
2374
|
+
return t ? i.bottom > 0 && i.top < s.innerHeight : i.right > 0 && i.left < s.innerWidth;
|
|
2303
2375
|
}
|
|
2304
|
-
function
|
|
2376
|
+
function kt(s, e) {
|
|
2305
2377
|
const t = e.getBoundingClientRect();
|
|
2306
|
-
return t.top >= 0 && t.left >= 0 && t.bottom <=
|
|
2378
|
+
return t.top >= 0 && t.left >= 0 && t.bottom <= s.innerHeight && t.right <= s.innerWidth;
|
|
2307
2379
|
}
|
|
2308
|
-
function
|
|
2309
|
-
const e = getComputedStyle(
|
|
2380
|
+
function $t(s) {
|
|
2381
|
+
const e = getComputedStyle(s);
|
|
2310
2382
|
if (e) {
|
|
2311
2383
|
const t = e.getPropertyValue("display");
|
|
2312
2384
|
if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
|
|
@@ -2314,7 +2386,7 @@ function Ot(r) {
|
|
|
2314
2386
|
}
|
|
2315
2387
|
return !1;
|
|
2316
2388
|
}
|
|
2317
|
-
const
|
|
2389
|
+
const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
|
|
2318
2390
|
constructor() {
|
|
2319
2391
|
super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2320
2392
|
}
|
|
@@ -2325,20 +2397,20 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2325
2397
|
return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
|
|
2326
2398
|
}
|
|
2327
2399
|
snapOffset(e) {
|
|
2328
|
-
const t = e + (
|
|
2400
|
+
const t = e + (z(this.wnd) ? -1 : 1);
|
|
2329
2401
|
return t - t % this.wnd.innerWidth;
|
|
2330
2402
|
}
|
|
2331
2403
|
reportProgress() {
|
|
2332
|
-
const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)),
|
|
2404
|
+
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));
|
|
2333
2405
|
this.comms.send("progress", {
|
|
2334
2406
|
start: i,
|
|
2335
|
-
end:
|
|
2407
|
+
end: r
|
|
2336
2408
|
});
|
|
2337
2409
|
}
|
|
2338
2410
|
shake() {
|
|
2339
2411
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2340
2412
|
const e = this.doc();
|
|
2341
|
-
e.classList.add(
|
|
2413
|
+
e.classList.add(z(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
|
|
2342
2414
|
const t = this.scrollOffset();
|
|
2343
2415
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2344
2416
|
e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
|
|
@@ -2352,27 +2424,27 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2352
2424
|
}
|
|
2353
2425
|
// Snaps the current offset to the page width.
|
|
2354
2426
|
snapCurrentOffset(e = !1, t = !1) {
|
|
2355
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft,
|
|
2427
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, r = this.doc(), n = this.dragOffset(), o = lt(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), u = z(this.wnd) ? -1 : 1, h = (
|
|
2356
2428
|
// The hurdle to overcome in order to change pages
|
|
2357
2429
|
u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)
|
|
2358
|
-
), c = this.snapOffset(
|
|
2430
|
+
), c = this.snapOffset(a + h);
|
|
2359
2431
|
if (e && c !== this.scrollOffset()) {
|
|
2360
2432
|
this.snappingCancelled = !1;
|
|
2361
|
-
const m = (f, g, E,
|
|
2433
|
+
const m = (f, g, E, W) => E > W ? g : f + (g - f) * Ut(E / W), d = (
|
|
2362
2434
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2363
|
-
|
|
2435
|
+
Vt * o
|
|
2364
2436
|
);
|
|
2365
2437
|
let y;
|
|
2366
|
-
const
|
|
2438
|
+
const p = (f) => {
|
|
2367
2439
|
if (this.snappingCancelled) return;
|
|
2368
2440
|
y || (y = f);
|
|
2369
|
-
const g = f - y, E = m(this.overscroll, 0, g,
|
|
2370
|
-
|
|
2441
|
+
const g = f - y, E = m(this.overscroll, 0, g, d), W = m(i, c, g, d);
|
|
2442
|
+
r.scrollLeft = W, this.overscroll !== 0 && (r.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < d ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), r.style.removeProperty("transform"), r.scrollLeft = c, t || this.reportProgress());
|
|
2371
2443
|
};
|
|
2372
|
-
this.wnd.requestAnimationFrame(
|
|
2444
|
+
this.wnd.requestAnimationFrame(p);
|
|
2373
2445
|
} else
|
|
2374
|
-
|
|
2375
|
-
|
|
2446
|
+
r.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2447
|
+
r.scrollLeft = c, this.clearTouches(), t || this.reportProgress();
|
|
2376
2448
|
});
|
|
2377
2449
|
}
|
|
2378
2450
|
dragOffset() {
|
|
@@ -2415,7 +2487,7 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2415
2487
|
if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;
|
|
2416
2488
|
e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2417
2489
|
const i = e.document.createElement("style");
|
|
2418
|
-
i.dataset.readium = "true", i.id =
|
|
2490
|
+
i.dataset.readium = "true", i.id = Ge, i.textContent = `
|
|
2419
2491
|
@keyframes readium-bounce-l-animation {
|
|
2420
2492
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2421
2493
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2451,25 +2523,25 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2451
2523
|
}
|
|
2452
2524
|
`, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2453
2525
|
e.requestAnimationFrame(() => {
|
|
2454
|
-
e &&
|
|
2526
|
+
e && Xe(e);
|
|
2455
2527
|
}), this.onWidthChange();
|
|
2456
2528
|
}), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2457
2529
|
for (const o of n)
|
|
2458
2530
|
if (o.target === this.wnd.document.documentElement) {
|
|
2459
|
-
const
|
|
2531
|
+
const a = o.oldValue, u = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = a?.match(h), m = u?.match(h);
|
|
2460
2532
|
(!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {
|
|
2461
|
-
e &&
|
|
2533
|
+
e && Xe(e);
|
|
2462
2534
|
}), this.onWidthChange());
|
|
2463
2535
|
} else
|
|
2464
2536
|
e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2465
2537
|
}), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
|
|
2466
|
-
const
|
|
2538
|
+
const r = (n) => {
|
|
2467
2539
|
const o = this.doc().scrollLeft;
|
|
2468
2540
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2469
2541
|
};
|
|
2470
2542
|
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", x.moduleName, (n, o) => {
|
|
2471
|
-
const
|
|
2472
|
-
if (
|
|
2543
|
+
const a = n;
|
|
2544
|
+
if (a < 0 || a > 1) {
|
|
2473
2545
|
t.send("error", {
|
|
2474
2546
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2475
2547
|
}), o(!1);
|
|
@@ -2477,28 +2549,28 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2477
2549
|
}
|
|
2478
2550
|
this.wnd.requestAnimationFrame(() => {
|
|
2479
2551
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2480
|
-
const u = this.cachedScrollWidth, h =
|
|
2552
|
+
const u = this.cachedScrollWidth, h = z(e) ? -1 : 1, c = u * a * h;
|
|
2481
2553
|
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), v(this.wnd), o(!0);
|
|
2482
2554
|
});
|
|
2483
2555
|
}), t.register("go_id", x.moduleName, (n, o) => {
|
|
2484
|
-
const
|
|
2485
|
-
if (!
|
|
2556
|
+
const a = e.document.getElementById(n);
|
|
2557
|
+
if (!a) {
|
|
2486
2558
|
o(!1);
|
|
2487
2559
|
return;
|
|
2488
2560
|
}
|
|
2489
2561
|
this.wnd.requestAnimationFrame(() => {
|
|
2490
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2562
|
+
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
|
|
2491
2563
|
});
|
|
2492
2564
|
}), t.register("go_text", x.moduleName, (n, o) => {
|
|
2493
|
-
let
|
|
2494
|
-
Array.isArray(n) && (n.length > 1 && (
|
|
2495
|
-
const u =
|
|
2565
|
+
let a;
|
|
2566
|
+
Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
|
|
2567
|
+
const u = D.deserialize(n), h = ne(this.wnd.document, new R({
|
|
2496
2568
|
href: e.location.href,
|
|
2497
2569
|
type: "text/html",
|
|
2498
2570
|
text: u,
|
|
2499
|
-
locations:
|
|
2571
|
+
locations: a ? new b({
|
|
2500
2572
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2501
|
-
["cssSelector",
|
|
2573
|
+
["cssSelector", a]
|
|
2502
2574
|
])
|
|
2503
2575
|
}) : void 0
|
|
2504
2576
|
}));
|
|
@@ -2510,10 +2582,10 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2510
2582
|
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
|
|
2511
2583
|
});
|
|
2512
2584
|
}), t.register("go_end", x.moduleName, (n, o) => {
|
|
2513
|
-
const
|
|
2585
|
+
const a = z(e) ? -1 : 1;
|
|
2514
2586
|
this.wnd.requestAnimationFrame(() => {
|
|
2515
2587
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2516
|
-
const u = this.cachedScrollWidth *
|
|
2588
|
+
const u = this.cachedScrollWidth * a;
|
|
2517
2589
|
if (this.doc().scrollLeft === u) return o(!1);
|
|
2518
2590
|
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), v(this.wnd), o(!0);
|
|
2519
2591
|
});
|
|
@@ -2525,13 +2597,13 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2525
2597
|
}), t.register("go_prev", x.moduleName, (n, o) => {
|
|
2526
2598
|
this.wnd.requestAnimationFrame(() => {
|
|
2527
2599
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2528
|
-
const
|
|
2600
|
+
const a = e.scrollX - e.innerWidth, u = z(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = r(Math.max(a, u));
|
|
2529
2601
|
h && (this.reportProgress(), v(this.wnd)), o(h);
|
|
2530
2602
|
});
|
|
2531
2603
|
}), t.register("go_next", x.moduleName, (n, o) => {
|
|
2532
2604
|
this.wnd.requestAnimationFrame(() => {
|
|
2533
2605
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2534
|
-
const
|
|
2606
|
+
const a = e.scrollX + e.innerWidth, u = z(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = r(Math.min(a, u));
|
|
2535
2607
|
h && (this.reportProgress(), v(this.wnd)), o(h);
|
|
2536
2608
|
});
|
|
2537
2609
|
}), t.register("unfocus", x.moduleName, (n, o) => {
|
|
@@ -2543,18 +2615,18 @@ const De = "readium-column-snapper-style", Lt = 200, x = class x extends V {
|
|
|
2543
2615
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2544
2616
|
});
|
|
2545
2617
|
}), t.register("first_visible_locator", x.moduleName, (n, o) => {
|
|
2546
|
-
const
|
|
2547
|
-
this.comms.send("first_visible_locator",
|
|
2618
|
+
const a = Ne(e, !1);
|
|
2619
|
+
this.comms.send("first_visible_locator", a.serialize()), o(!0);
|
|
2548
2620
|
}), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
|
|
2549
2621
|
}), t.log("ColumnSnapper Mounted"), !0;
|
|
2550
2622
|
}
|
|
2551
2623
|
unmount(e, t) {
|
|
2552
|
-
return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(
|
|
2624
|
+
return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(Ge)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
|
|
2553
2625
|
}
|
|
2554
2626
|
};
|
|
2555
2627
|
x.moduleName = "column_snapper";
|
|
2556
|
-
let
|
|
2557
|
-
const
|
|
2628
|
+
let me = x;
|
|
2629
|
+
const Ye = "readium-scroll-snapper-style", T = class T extends G {
|
|
2558
2630
|
constructor() {
|
|
2559
2631
|
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2560
2632
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2575,16 +2647,16 @@ const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
|
2575
2647
|
}
|
|
2576
2648
|
reportProgress() {
|
|
2577
2649
|
if (!this.comms.ready) return;
|
|
2578
|
-
const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight,
|
|
2650
|
+
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));
|
|
2579
2651
|
this.comms.send("progress", {
|
|
2580
|
-
start:
|
|
2652
|
+
start: r,
|
|
2581
2653
|
end: n
|
|
2582
2654
|
});
|
|
2583
2655
|
}
|
|
2584
2656
|
mount(e, t) {
|
|
2585
2657
|
this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
2586
2658
|
const i = e.document.createElement("style");
|
|
2587
|
-
return i.dataset.readium = "true", i.id =
|
|
2659
|
+
return i.dataset.readium = "true", i.id = Ye, i.textContent = `
|
|
2588
2660
|
* {
|
|
2589
2661
|
scrollbar-width: none; /* for Firefox */
|
|
2590
2662
|
}
|
|
@@ -2597,11 +2669,11 @@ const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
|
2597
2669
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2598
2670
|
}, 50);
|
|
2599
2671
|
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", T.moduleName, () => {
|
|
2600
|
-
|
|
2601
|
-
const
|
|
2602
|
-
|
|
2603
|
-
}), t.register("go_progression", T.moduleName, (
|
|
2604
|
-
const o =
|
|
2672
|
+
ht(this.wnd);
|
|
2673
|
+
const r = this.doc().scrollTop;
|
|
2674
|
+
r > 1 ? this.doc().scrollTop = r - 1 : this.doc().scrollTop = r + 1, this.doc().scrollTop = r;
|
|
2675
|
+
}), t.register("go_progression", T.moduleName, (r, n) => {
|
|
2676
|
+
const o = r;
|
|
2605
2677
|
if (o < 0 || o > 1) {
|
|
2606
2678
|
t.send("error", {
|
|
2607
2679
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
@@ -2611,8 +2683,8 @@ const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
|
2611
2683
|
this.wnd.requestAnimationFrame(() => {
|
|
2612
2684
|
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), v(this.wnd), n(!0);
|
|
2613
2685
|
});
|
|
2614
|
-
}), t.register("go_id", T.moduleName, (
|
|
2615
|
-
const o = e.document.getElementById(
|
|
2686
|
+
}), t.register("go_id", T.moduleName, (r, n) => {
|
|
2687
|
+
const o = e.document.getElementById(r);
|
|
2616
2688
|
if (!o) {
|
|
2617
2689
|
n(!1);
|
|
2618
2690
|
return;
|
|
@@ -2620,13 +2692,13 @@ const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
|
2620
2692
|
this.wnd.requestAnimationFrame(() => {
|
|
2621
2693
|
this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
|
|
2622
2694
|
});
|
|
2623
|
-
}), t.register("go_text", T.moduleName, (
|
|
2695
|
+
}), t.register("go_text", T.moduleName, (r, n) => {
|
|
2624
2696
|
let o;
|
|
2625
|
-
Array.isArray(
|
|
2626
|
-
const
|
|
2697
|
+
Array.isArray(r) && (r.length > 1 && (o = r[1]), r = r[0]);
|
|
2698
|
+
const a = D.deserialize(r), u = ne(this.wnd.document, new R({
|
|
2627
2699
|
href: e.location.href,
|
|
2628
2700
|
type: "text/html",
|
|
2629
|
-
text:
|
|
2701
|
+
text: a,
|
|
2630
2702
|
locations: o ? new b({
|
|
2631
2703
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2632
2704
|
["cssSelector", o]
|
|
@@ -2640,31 +2712,31 @@ const We = "readium-scroll-snapper-style", T = class T extends V {
|
|
|
2640
2712
|
this.wnd.requestAnimationFrame(() => {
|
|
2641
2713
|
this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
|
|
2642
2714
|
});
|
|
2643
|
-
}), t.register("go_start", T.moduleName, (
|
|
2715
|
+
}), t.register("go_start", T.moduleName, (r, n) => {
|
|
2644
2716
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
2645
2717
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
2646
|
-
}), t.register("go_end", T.moduleName, (
|
|
2718
|
+
}), t.register("go_end", T.moduleName, (r, n) => {
|
|
2647
2719
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
2648
2720
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
2649
|
-
}), t.register("unfocus", T.moduleName, (
|
|
2721
|
+
}), t.register("unfocus", T.moduleName, (r, n) => {
|
|
2650
2722
|
v(this.wnd), n(!0);
|
|
2651
2723
|
}), t.register([
|
|
2652
2724
|
"go_next",
|
|
2653
2725
|
"go_prev"
|
|
2654
|
-
], T.moduleName, (
|
|
2726
|
+
], T.moduleName, (r, n) => n(!1)), t.register("focus", T.moduleName, (r, n) => {
|
|
2655
2727
|
this.reportProgress(), n(!0);
|
|
2656
|
-
}), t.register("first_visible_locator", T.moduleName, (
|
|
2657
|
-
const o =
|
|
2728
|
+
}), t.register("first_visible_locator", T.moduleName, (r, n) => {
|
|
2729
|
+
const o = Ne(e, !0);
|
|
2658
2730
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2659
2731
|
}), t.log("ScrollSnapper Mounted"), !0;
|
|
2660
2732
|
}
|
|
2661
2733
|
unmount(e, t) {
|
|
2662
|
-
return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(
|
|
2734
|
+
return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(Ye)?.remove(), t.log("ScrollSnapper Unmounted"), !0;
|
|
2663
2735
|
}
|
|
2664
2736
|
};
|
|
2665
2737
|
T.moduleName = "scroll_snapper";
|
|
2666
|
-
let
|
|
2667
|
-
const w = class w extends
|
|
2738
|
+
let ge = T;
|
|
2739
|
+
const w = class w extends G {
|
|
2668
2740
|
constructor() {
|
|
2669
2741
|
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2670
2742
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2685,9 +2757,9 @@ const w = class w extends V {
|
|
|
2685
2757
|
}
|
|
2686
2758
|
reportProgress() {
|
|
2687
2759
|
if (!this.comms.ready) return;
|
|
2688
|
-
const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight,
|
|
2760
|
+
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));
|
|
2689
2761
|
this.comms.send("progress", {
|
|
2690
|
-
start:
|
|
2762
|
+
start: r,
|
|
2691
2763
|
end: n
|
|
2692
2764
|
});
|
|
2693
2765
|
}
|
|
@@ -2697,33 +2769,33 @@ const w = class w extends V {
|
|
|
2697
2769
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2698
2770
|
}, 50);
|
|
2699
2771
|
}), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", w.moduleName, () => {
|
|
2700
|
-
|
|
2772
|
+
ht(this.wnd);
|
|
2701
2773
|
const i = this.doc().scrollTop;
|
|
2702
2774
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
2703
|
-
}), t.register("go_progression", w.moduleName, (i,
|
|
2775
|
+
}), t.register("go_progression", w.moduleName, (i, r) => {
|
|
2704
2776
|
const n = i;
|
|
2705
2777
|
if (n < 0 || n > 1) {
|
|
2706
2778
|
t.send("error", {
|
|
2707
2779
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2708
|
-
}),
|
|
2780
|
+
}), r(!1);
|
|
2709
2781
|
return;
|
|
2710
2782
|
}
|
|
2711
2783
|
this.wnd.requestAnimationFrame(() => {
|
|
2712
|
-
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd),
|
|
2784
|
+
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd), r(!0);
|
|
2713
2785
|
});
|
|
2714
|
-
}), this.comms.register("go_id", w.moduleName, (i,
|
|
2786
|
+
}), this.comms.register("go_id", w.moduleName, (i, r) => {
|
|
2715
2787
|
const n = e.document.getElementById(i);
|
|
2716
2788
|
if (!n) {
|
|
2717
|
-
|
|
2789
|
+
r(!1);
|
|
2718
2790
|
return;
|
|
2719
2791
|
}
|
|
2720
2792
|
this.wnd.requestAnimationFrame(() => {
|
|
2721
|
-
this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd),
|
|
2793
|
+
this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
|
|
2722
2794
|
});
|
|
2723
|
-
}), t.register("go_text", w.moduleName, (i,
|
|
2795
|
+
}), t.register("go_text", w.moduleName, (i, r) => {
|
|
2724
2796
|
let n;
|
|
2725
2797
|
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
2726
|
-
const o =
|
|
2798
|
+
const o = D.deserialize(i), a = ne(this.wnd.document, new R({
|
|
2727
2799
|
href: e.location.href,
|
|
2728
2800
|
type: "text/html",
|
|
2729
2801
|
text: o,
|
|
@@ -2733,29 +2805,29 @@ const w = class w extends V {
|
|
|
2733
2805
|
])
|
|
2734
2806
|
}) : void 0
|
|
2735
2807
|
}));
|
|
2736
|
-
if (!
|
|
2737
|
-
|
|
2808
|
+
if (!a) {
|
|
2809
|
+
r(!1);
|
|
2738
2810
|
return;
|
|
2739
2811
|
}
|
|
2740
2812
|
this.wnd.requestAnimationFrame(() => {
|
|
2741
|
-
this.doc().scrollTop =
|
|
2813
|
+
this.doc().scrollTop = a.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
|
|
2742
2814
|
});
|
|
2743
|
-
}), t.register("go_start", w.moduleName, (i,
|
|
2744
|
-
if (this.doc().scrollTop === 0) return
|
|
2745
|
-
this.doc().scrollTop = 0, this.reportProgress(),
|
|
2746
|
-
}), t.register("go_end", w.moduleName, (i,
|
|
2747
|
-
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return
|
|
2748
|
-
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(),
|
|
2749
|
-
}), t.register("unfocus", w.moduleName, (i,
|
|
2750
|
-
v(this.wnd),
|
|
2815
|
+
}), t.register("go_start", w.moduleName, (i, r) => {
|
|
2816
|
+
if (this.doc().scrollTop === 0) return r(!1);
|
|
2817
|
+
this.doc().scrollTop = 0, this.reportProgress(), r(!0);
|
|
2818
|
+
}), t.register("go_end", w.moduleName, (i, r) => {
|
|
2819
|
+
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return r(!1);
|
|
2820
|
+
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), r(!0);
|
|
2821
|
+
}), t.register("unfocus", w.moduleName, (i, r) => {
|
|
2822
|
+
v(this.wnd), r(!0);
|
|
2751
2823
|
}), t.register([
|
|
2752
2824
|
"go_next",
|
|
2753
2825
|
"go_prev"
|
|
2754
|
-
], w.moduleName, (i,
|
|
2755
|
-
this.reportProgress(),
|
|
2756
|
-
}), t.register("first_visible_locator", w.moduleName, (i,
|
|
2757
|
-
const n =
|
|
2758
|
-
t.send("first_visible_locator", n.serialize()),
|
|
2826
|
+
], w.moduleName, (i, r) => r(!1)), t.register("focus", w.moduleName, (i, r) => {
|
|
2827
|
+
this.reportProgress(), r(!0);
|
|
2828
|
+
}), t.register("first_visible_locator", w.moduleName, (i, r) => {
|
|
2829
|
+
const n = Ne(e, !0);
|
|
2830
|
+
t.send("first_visible_locator", n.serialize()), r(!0);
|
|
2759
2831
|
}), t.log("WebPubSnapper Mounted"), !0;
|
|
2760
2832
|
}
|
|
2761
2833
|
unmount(e, t) {
|
|
@@ -2763,18 +2835,18 @@ const w = class w extends V {
|
|
|
2763
2835
|
}
|
|
2764
2836
|
};
|
|
2765
2837
|
w.moduleName = "webpub_snapper";
|
|
2766
|
-
let
|
|
2767
|
-
const
|
|
2838
|
+
let ye = w;
|
|
2839
|
+
const Oe = class Oe extends Y {
|
|
2768
2840
|
constructor() {
|
|
2769
2841
|
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);
|
|
2770
2842
|
}
|
|
2771
2843
|
onPointUp(e) {
|
|
2772
2844
|
const t = this.wnd.getSelection();
|
|
2773
2845
|
if (t && t.toString()?.length > 0) {
|
|
2774
|
-
const
|
|
2775
|
-
if (!
|
|
2846
|
+
const r = t.getRangeAt(0)?.getClientRects();
|
|
2847
|
+
if (!r || r.length === 0)
|
|
2776
2848
|
return;
|
|
2777
|
-
const n =
|
|
2849
|
+
const n = r[0], o = {
|
|
2778
2850
|
text: t.toString(),
|
|
2779
2851
|
x: n.x,
|
|
2780
2852
|
y: n.y,
|
|
@@ -2796,7 +2868,7 @@ const be = class be extends j {
|
|
|
2796
2868
|
y: e.clientY * i,
|
|
2797
2869
|
targetFrameSrc: this.wnd.location.href,
|
|
2798
2870
|
targetElement: e.target.outerHTML,
|
|
2799
|
-
interactiveElement:
|
|
2871
|
+
interactiveElement: ct(e.target)?.outerHTML,
|
|
2800
2872
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
|
|
2801
2873
|
}), this.pointerMoved = !1;
|
|
2802
2874
|
}
|
|
@@ -2832,9 +2904,9 @@ const be = class be extends j {
|
|
|
2832
2904
|
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;
|
|
2833
2905
|
}
|
|
2834
2906
|
};
|
|
2835
|
-
|
|
2836
|
-
let
|
|
2837
|
-
const
|
|
2907
|
+
Oe.moduleName = "peripherals";
|
|
2908
|
+
let ve = Oe;
|
|
2909
|
+
const _ = class _ extends Y {
|
|
2838
2910
|
constructor() {
|
|
2839
2911
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
2840
2912
|
}
|
|
@@ -2854,13 +2926,13 @@ const k = class k extends j {
|
|
|
2854
2926
|
Reflect.apply(t[1], t[2], t[3]);
|
|
2855
2927
|
break;
|
|
2856
2928
|
case 1:
|
|
2857
|
-
const i = t[1],
|
|
2929
|
+
const i = t[1], r = t[2];
|
|
2858
2930
|
e.removeEventListener(i.type, e._readium_eventBlocker, !0);
|
|
2859
2931
|
const n = new Event(i.type, {
|
|
2860
2932
|
bubbles: i.bubbles,
|
|
2861
2933
|
cancelable: i.cancelable
|
|
2862
2934
|
});
|
|
2863
|
-
|
|
2935
|
+
r ? r.dispatchEvent(n) : e.dispatchEvent(n);
|
|
2864
2936
|
break;
|
|
2865
2937
|
}
|
|
2866
2938
|
}
|
|
@@ -2884,9 +2956,9 @@ const k = class k extends j {
|
|
|
2884
2956
|
), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
|
|
2885
2957
|
value: {
|
|
2886
2958
|
name: "readium-ts-toolkit",
|
|
2887
|
-
version: "2.2.
|
|
2888
|
-
hasFeature: (
|
|
2889
|
-
switch (
|
|
2959
|
+
version: "2.2.2",
|
|
2960
|
+
hasFeature: (r, n = "") => {
|
|
2961
|
+
switch (r) {
|
|
2890
2962
|
case "dom-manipulation":
|
|
2891
2963
|
return !0;
|
|
2892
2964
|
case "layout-changes":
|
|
@@ -2907,18 +2979,18 @@ const k = class k extends j {
|
|
|
2907
2979
|
}
|
|
2908
2980
|
},
|
|
2909
2981
|
writable: !1
|
|
2910
|
-
}), "getAnimations" in e.document && e.document.getAnimations().forEach((
|
|
2911
|
-
|
|
2912
|
-
}), t.register("activate",
|
|
2982
|
+
}), "getAnimations" in e.document && e.document.getAnimations().forEach((r) => {
|
|
2983
|
+
r.cancel(), this.allAnimations.add(r);
|
|
2984
|
+
}), t.register("activate", _.moduleName, (r, n) => {
|
|
2913
2985
|
this.allAnimations.forEach((o) => {
|
|
2914
2986
|
o.cancel(), o.play();
|
|
2915
2987
|
}), n(!0);
|
|
2916
|
-
}), t.register("unfocus",
|
|
2988
|
+
}), t.register("unfocus", _.moduleName, (r, n) => {
|
|
2917
2989
|
this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
2918
2990
|
});
|
|
2919
2991
|
const i = e.document.querySelectorAll("audio,video");
|
|
2920
|
-
for (let
|
|
2921
|
-
const n = i[
|
|
2992
|
+
for (let r = 0; r < i.length; r++) {
|
|
2993
|
+
const n = i[r];
|
|
2922
2994
|
n.addEventListener("play", this.onMediaPlayEvent, {
|
|
2923
2995
|
passive: !0
|
|
2924
2996
|
}), n.addEventListener("pause", this.onMediaPauseEvent, {
|
|
@@ -2931,46 +3003,46 @@ const k = class k extends j {
|
|
|
2931
3003
|
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;
|
|
2932
3004
|
}
|
|
2933
3005
|
};
|
|
2934
|
-
|
|
2935
|
-
let
|
|
2936
|
-
const
|
|
3006
|
+
_.moduleName = "setup";
|
|
3007
|
+
let se = _;
|
|
3008
|
+
const Ke = "readium-viewport", O = class O extends se {
|
|
2937
3009
|
onViewportWidthChanged(e) {
|
|
2938
3010
|
const t = e.target;
|
|
2939
|
-
|
|
3011
|
+
X(t, "--RS__viewportWidth", `${t.innerWidth}px`);
|
|
2940
3012
|
}
|
|
2941
3013
|
mount(e, t) {
|
|
2942
3014
|
if (!super.mount(e, t)) return !1;
|
|
2943
3015
|
const i = e.document.createElement("meta");
|
|
2944
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
3016
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Ke), i.setAttribute(
|
|
2945
3017
|
"content",
|
|
2946
3018
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
2947
3019
|
), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
2948
3020
|
target: e
|
|
2949
|
-
}), t.register("get_properties", O.moduleName, (
|
|
2950
|
-
|
|
2951
|
-
}), t.register("update_properties", O.moduleName, (
|
|
2952
|
-
|
|
2953
|
-
}), t.register("set_property", O.moduleName, (
|
|
2954
|
-
const o =
|
|
2955
|
-
|
|
2956
|
-
}), t.register("remove_property", O.moduleName, (
|
|
2957
|
-
|
|
2958
|
-
}), t.register("activate", O.moduleName, (
|
|
3021
|
+
}), t.register("get_properties", O.moduleName, (r, n) => {
|
|
3022
|
+
Me(e), n(!0);
|
|
3023
|
+
}), t.register("update_properties", O.moduleName, (r, n) => {
|
|
3024
|
+
r["--RS__viewportWidth"] = `${e.innerWidth}px`, at(e, r), n(!0);
|
|
3025
|
+
}), t.register("set_property", O.moduleName, (r, n) => {
|
|
3026
|
+
const o = r;
|
|
3027
|
+
X(e, o[0], o[1]), n(!0);
|
|
3028
|
+
}), t.register("remove_property", O.moduleName, (r, n) => {
|
|
3029
|
+
oe(e, r), n(!0);
|
|
3030
|
+
}), t.register("activate", O.moduleName, (r, n) => {
|
|
2959
3031
|
this.unblock(e), n(!0);
|
|
2960
3032
|
}), t.log("ReflowableSetup Mounted"), !0;
|
|
2961
3033
|
}
|
|
2962
3034
|
unmount(e, t) {
|
|
2963
|
-
return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${
|
|
3035
|
+
return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${Ke}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
|
|
2964
3036
|
}
|
|
2965
3037
|
};
|
|
2966
3038
|
O.moduleName = "reflowable_setup";
|
|
2967
|
-
let
|
|
2968
|
-
const
|
|
3039
|
+
let be = O;
|
|
3040
|
+
const Ze = "readium-fixed-style", A = class A extends se {
|
|
2969
3041
|
mount(e, t) {
|
|
2970
3042
|
if (!super.mount(e, t)) return !1;
|
|
2971
3043
|
e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2972
3044
|
const i = e.document.createElement("style");
|
|
2973
|
-
return i.id =
|
|
3045
|
+
return i.id = Ze, i.dataset.readium = "true", i.textContent = `
|
|
2974
3046
|
html, body {
|
|
2975
3047
|
text-size-adjust: none;
|
|
2976
3048
|
-ms-text-size-adjust: none;
|
|
@@ -2982,12 +3054,12 @@ const Ue = "readium-fixed-style", A = class A extends J {
|
|
|
2982
3054
|
min-height: 100%;
|
|
2983
3055
|
|
|
2984
3056
|
/*cursor: var() TODO*/
|
|
2985
|
-
}`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (
|
|
2986
|
-
const o =
|
|
2987
|
-
|
|
2988
|
-
}), t.register("remove_property", A.moduleName, (
|
|
2989
|
-
|
|
2990
|
-
}), t.register("first_visible_locator", A.moduleName, (
|
|
3057
|
+
}`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (r, n) => {
|
|
3058
|
+
const o = r;
|
|
3059
|
+
X(e, o[0], o[1]), n(!0);
|
|
3060
|
+
}), t.register("remove_property", A.moduleName, (r, n) => {
|
|
3061
|
+
oe(e, r), n(!0);
|
|
3062
|
+
}), t.register("first_visible_locator", A.moduleName, (r, n) => n(!1)), t.register("unfocus", A.moduleName, (r, n) => {
|
|
2991
3063
|
v(e), n(!0);
|
|
2992
3064
|
}), t.register([
|
|
2993
3065
|
"focus",
|
|
@@ -2998,17 +3070,17 @@ const Ue = "readium-fixed-style", A = class A extends J {
|
|
|
2998
3070
|
"go_start",
|
|
2999
3071
|
"go_text",
|
|
3000
3072
|
"go_progression"
|
|
3001
|
-
], A.moduleName, (
|
|
3073
|
+
], A.moduleName, (r, n) => n(!0)), t.register("activate", A.moduleName, (r, n) => {
|
|
3002
3074
|
this.unblock(e), n(!0);
|
|
3003
3075
|
}), t.log("FixedSetup Mounted"), !0;
|
|
3004
3076
|
}
|
|
3005
3077
|
unmount(e, t) {
|
|
3006
|
-
return t.unregisterAll(A.moduleName), e.document.getElementById(
|
|
3078
|
+
return t.unregisterAll(A.moduleName), e.document.getElementById(Ze)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
|
|
3007
3079
|
}
|
|
3008
3080
|
};
|
|
3009
3081
|
A.moduleName = "fixed_setup";
|
|
3010
|
-
let
|
|
3011
|
-
const
|
|
3082
|
+
let Ee = A;
|
|
3083
|
+
const L = class L extends Y {
|
|
3012
3084
|
wndOnErr(e) {
|
|
3013
3085
|
this.comms?.send("error", {
|
|
3014
3086
|
message: e.message,
|
|
@@ -3022,62 +3094,71 @@ const Q = class Q extends j {
|
|
|
3022
3094
|
"error",
|
|
3023
3095
|
this.wndOnErr,
|
|
3024
3096
|
!1
|
|
3025
|
-
), t.register("
|
|
3026
|
-
|
|
3097
|
+
), t.register("get_properties", L.moduleName, (i, r) => {
|
|
3098
|
+
Me(e), r(!0);
|
|
3099
|
+
}), t.register("update_properties", L.moduleName, (i, r) => {
|
|
3100
|
+
at(e, i), r(!0);
|
|
3101
|
+
}), t.register("set_property", L.moduleName, (i, r) => {
|
|
3102
|
+
const n = i;
|
|
3103
|
+
X(e, n[0], n[1]), r(!0);
|
|
3104
|
+
}), t.register("remove_property", L.moduleName, (i, r) => {
|
|
3105
|
+
oe(e, i), r(!0);
|
|
3106
|
+
}), t.register("activate", L.moduleName, (i, r) => {
|
|
3107
|
+
r(!0);
|
|
3027
3108
|
}), t.log("WebPubSetup Mounted"), !0;
|
|
3028
3109
|
}
|
|
3029
3110
|
unmount(e, t) {
|
|
3030
|
-
return e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;
|
|
3111
|
+
return t.unregisterAll(L.moduleName), e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;
|
|
3031
3112
|
}
|
|
3032
3113
|
};
|
|
3033
|
-
|
|
3034
|
-
let
|
|
3035
|
-
const
|
|
3114
|
+
L.moduleName = "webpub_setup";
|
|
3115
|
+
let xe = L;
|
|
3116
|
+
const jt = [
|
|
3036
3117
|
"fixed_setup",
|
|
3037
3118
|
"decorator",
|
|
3038
3119
|
"peripherals"
|
|
3039
|
-
],
|
|
3120
|
+
], _t = [
|
|
3040
3121
|
"reflowable_setup",
|
|
3041
3122
|
"decorator",
|
|
3042
3123
|
"peripherals",
|
|
3043
3124
|
"column_snapper",
|
|
3044
3125
|
"scroll_snapper"
|
|
3045
|
-
],
|
|
3126
|
+
], Xt = [
|
|
3046
3127
|
"webpub_setup",
|
|
3047
3128
|
"webpub_snapper",
|
|
3048
3129
|
"decorator",
|
|
3049
3130
|
"peripherals"
|
|
3050
|
-
],
|
|
3131
|
+
], Je = new Map([
|
|
3051
3132
|
// All modules go here
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
].map((
|
|
3061
|
-
class
|
|
3133
|
+
Ee,
|
|
3134
|
+
be,
|
|
3135
|
+
xe,
|
|
3136
|
+
ye,
|
|
3137
|
+
ve,
|
|
3138
|
+
fe,
|
|
3139
|
+
me,
|
|
3140
|
+
ge
|
|
3141
|
+
].map((s) => [s.moduleName, s]));
|
|
3142
|
+
class Gt {
|
|
3062
3143
|
/**
|
|
3063
3144
|
* @param wnd Window instance to operate on
|
|
3064
3145
|
* @param initialModules List of initial modules to load
|
|
3065
3146
|
*/
|
|
3066
3147
|
constructor(e = window, t = []) {
|
|
3067
|
-
this.loadedModules = [], this.wnd = e, this.comms = new
|
|
3148
|
+
this.loadedModules = [], this.wnd = e, this.comms = new ft(e);
|
|
3068
3149
|
const i = [...new Set(t)];
|
|
3069
3150
|
if (i.length) {
|
|
3070
3151
|
if (typeof e > "u")
|
|
3071
3152
|
throw Error("Loader is not in a web browser");
|
|
3072
|
-
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((
|
|
3073
|
-
const n = this.loadModule(
|
|
3153
|
+
e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((r) => {
|
|
3154
|
+
const n = this.loadModule(r);
|
|
3074
3155
|
if (n)
|
|
3075
3156
|
return n.mount(this.wnd, this.comms), n;
|
|
3076
|
-
}).filter((
|
|
3157
|
+
}).filter((r) => r !== void 0);
|
|
3077
3158
|
}
|
|
3078
3159
|
}
|
|
3079
3160
|
loadModule(e) {
|
|
3080
|
-
const t =
|
|
3161
|
+
const t = Je.get(e);
|
|
3081
3162
|
return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
|
|
3082
3163
|
}
|
|
3083
3164
|
/**
|
|
@@ -3095,10 +3176,10 @@ class Wt {
|
|
|
3095
3176
|
* @returns Success
|
|
3096
3177
|
*/
|
|
3097
3178
|
removeModule(e) {
|
|
3098
|
-
const t =
|
|
3179
|
+
const t = Je.get(e);
|
|
3099
3180
|
if (t === void 0)
|
|
3100
3181
|
return this.comms.log(`Module "${e}" does not exist in the library`), !1;
|
|
3101
|
-
const i = this.loadedModules.findIndex((
|
|
3182
|
+
const i = this.loadedModules.findIndex((r) => r instanceof t);
|
|
3102
3183
|
return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
|
|
3103
3184
|
}
|
|
3104
3185
|
/**
|
|
@@ -3109,17 +3190,17 @@ class Wt {
|
|
|
3109
3190
|
}
|
|
3110
3191
|
}
|
|
3111
3192
|
export {
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3193
|
+
k as COMMS_VERSION,
|
|
3194
|
+
ft as Comms,
|
|
3195
|
+
fe as Decorator,
|
|
3196
|
+
jt as FXLModules,
|
|
3197
|
+
Dt as Layout,
|
|
3198
|
+
Gt as Loader,
|
|
3199
|
+
Y as Module,
|
|
3200
|
+
Je as ModuleLibrary,
|
|
3201
|
+
ve as Peripherals,
|
|
3202
|
+
_t as ReflowableModules,
|
|
3203
|
+
Xt as WebPubModules,
|
|
3204
|
+
zt as Width,
|
|
3205
|
+
pt as mid
|
|
3125
3206
|
};
|