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