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