@readium/navigator-html-injectables 2.0.0-beta.1 → 2.0.0-beta.3
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 +187 -183
- package/dist/index.umd.cjs +7 -7
- package/package.json +1 -1
- package/src/helpers/document.ts +24 -7
- package/src/modules/Decorator.ts +2 -2
- package/types/src/helpers/document.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -172,22 +172,22 @@ class l {
|
|
|
172
172
|
} else
|
|
173
173
|
throw new Error("Invalid media type");
|
|
174
174
|
const o = {};
|
|
175
|
-
for (let
|
|
176
|
-
const f = s[
|
|
175
|
+
for (let d = 1; d < s.length; d++) {
|
|
176
|
+
const f = s[d].split("=");
|
|
177
177
|
if (f.length === 2) {
|
|
178
178
|
const g = f[0].toLocaleLowerCase(), m = g === "charset" ? f[1].toUpperCase() : f[1];
|
|
179
179
|
o[g] = m;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
const a = {},
|
|
183
|
-
|
|
184
|
-
let
|
|
185
|
-
for (const
|
|
186
|
-
const f = a[
|
|
187
|
-
|
|
182
|
+
const a = {}, c = Object.keys(o);
|
|
183
|
+
c.sort((d, f) => d.localeCompare(f)), c.forEach((d) => a[d] = o[d]);
|
|
184
|
+
let h = "";
|
|
185
|
+
for (const d in a) {
|
|
186
|
+
const f = a[d];
|
|
187
|
+
h += `;${d}=${f}`;
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
this.string =
|
|
189
|
+
const u = `${t}/${i}${h}`, p = a.encoding;
|
|
190
|
+
this.string = u, this.type = t, this.subtype = i, this.parameters = a, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
|
|
191
191
|
}
|
|
192
192
|
static parse(e) {
|
|
193
193
|
return new l(e);
|
|
@@ -683,8 +683,8 @@ class x {
|
|
|
683
683
|
"totalProgression",
|
|
684
684
|
"position"
|
|
685
685
|
]);
|
|
686
|
-
return Object.entries(e).forEach(([a,
|
|
687
|
-
o.has(a) || n.set(a,
|
|
686
|
+
return Object.entries(e).forEach(([a, c]) => {
|
|
687
|
+
o.has(a) || n.set(a, c);
|
|
688
688
|
}), new x({
|
|
689
689
|
fragments: We(e.fragments || e.fragment),
|
|
690
690
|
progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
|
|
@@ -791,8 +791,8 @@ class B {
|
|
|
791
791
|
duration: C(e.duration),
|
|
792
792
|
bitrate: C(e.bitrate),
|
|
793
793
|
languages: We(e.language),
|
|
794
|
-
alternates:
|
|
795
|
-
children:
|
|
794
|
+
alternates: V.deserialize(e.alternate),
|
|
795
|
+
children: V.deserialize(e.children)
|
|
796
796
|
});
|
|
797
797
|
}
|
|
798
798
|
/**
|
|
@@ -852,7 +852,7 @@ class B {
|
|
|
852
852
|
});
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
|
-
class
|
|
855
|
+
class V {
|
|
856
856
|
/**
|
|
857
857
|
* Creates a [Links].
|
|
858
858
|
*/
|
|
@@ -864,7 +864,7 @@ class q {
|
|
|
864
864
|
*/
|
|
865
865
|
static deserialize(e) {
|
|
866
866
|
if (e && e instanceof Array)
|
|
867
|
-
return new
|
|
867
|
+
return new V(
|
|
868
868
|
e.map((t) => B.deserialize(t)).filter((t) => t !== void 0)
|
|
869
869
|
);
|
|
870
870
|
}
|
|
@@ -946,7 +946,7 @@ class q {
|
|
|
946
946
|
return this.items.filter((e) => e.type);
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
class
|
|
949
|
+
class q {
|
|
950
950
|
/**
|
|
951
951
|
* Creates a [DomRange].
|
|
952
952
|
*/
|
|
@@ -963,7 +963,7 @@ class V {
|
|
|
963
963
|
if (t === void 0)
|
|
964
964
|
return;
|
|
965
965
|
let i = C(e.charOffset);
|
|
966
|
-
return i === void 0 && (i = C(e.offset)), new
|
|
966
|
+
return i === void 0 && (i = C(e.offset)), new q({
|
|
967
967
|
cssSelector: e.cssSelector,
|
|
968
968
|
textNodeIndex: t,
|
|
969
969
|
charOffset: i
|
|
@@ -993,11 +993,11 @@ class re {
|
|
|
993
993
|
static deserialize(e) {
|
|
994
994
|
if (!e)
|
|
995
995
|
return;
|
|
996
|
-
let t =
|
|
996
|
+
let t = q.deserialize(e.start);
|
|
997
997
|
if (t)
|
|
998
998
|
return new re({
|
|
999
999
|
start: t,
|
|
1000
|
-
end:
|
|
1000
|
+
end: q.deserialize(e.end)
|
|
1001
1001
|
});
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
@@ -1232,15 +1232,15 @@ function Ee(r = "unknown problem", ...e) {
|
|
|
1232
1232
|
console.warn(`${ct}: ${r}`, ...e);
|
|
1233
1233
|
}
|
|
1234
1234
|
P.id, P.class, P.tag, P.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
|
|
1235
|
-
function
|
|
1235
|
+
function ut(r) {
|
|
1236
1236
|
return r instanceof RegExp;
|
|
1237
1237
|
}
|
|
1238
|
-
function
|
|
1238
|
+
function dt(r) {
|
|
1239
1239
|
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1240
1240
|
}
|
|
1241
1241
|
function pt(r) {
|
|
1242
1242
|
const e = r.map((t) => {
|
|
1243
|
-
if (
|
|
1243
|
+
if (ut(t))
|
|
1244
1244
|
return (i) => t.test(i);
|
|
1245
1245
|
if (typeof t == "function")
|
|
1246
1246
|
return (i) => {
|
|
@@ -1248,7 +1248,7 @@ function pt(r) {
|
|
|
1248
1248
|
return typeof s != "boolean" ? (Ee("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
|
|
1249
1249
|
};
|
|
1250
1250
|
if (typeof t == "string") {
|
|
1251
|
-
const i = new RegExp("^" +
|
|
1251
|
+
const i = new RegExp("^" + dt(t) + "$");
|
|
1252
1252
|
return (s) => i.test(s);
|
|
1253
1253
|
}
|
|
1254
1254
|
return Ee("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
|
|
@@ -1274,7 +1274,7 @@ function yt(r, e, t) {
|
|
|
1274
1274
|
return t.map((s) => {
|
|
1275
1275
|
const n = Math.max(0, s.end - e.length - s.errors), o = be(r.slice(n, s.end));
|
|
1276
1276
|
return {
|
|
1277
|
-
start: Fe(o, i, s.errors).reduce((
|
|
1277
|
+
start: Fe(o, i, s.errors).reduce((c, h) => s.end - h.end < c ? s.end - h.end : c, s.end),
|
|
1278
1278
|
end: s.end,
|
|
1279
1279
|
errors: s.errors
|
|
1280
1280
|
};
|
|
@@ -1285,10 +1285,10 @@ function Z(r) {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
function xe(r, e, t, i) {
|
|
1287
1287
|
let s = r.P[t], n = r.M[t];
|
|
1288
|
-
const o = i >>> 31, a = e[t] | o,
|
|
1289
|
-
let
|
|
1290
|
-
const
|
|
1291
|
-
return
|
|
1288
|
+
const o = i >>> 31, a = e[t] | o, c = a | n, h = (a & s) + s ^ s | a;
|
|
1289
|
+
let u = n | ~(h | s), p = s & h;
|
|
1290
|
+
const d = Z(u & r.lastRowMask[t]) - Z(p & r.lastRowMask[t]);
|
|
1291
|
+
return u <<= 1, p <<= 1, p |= o, u |= Z(i) - o, s = p | ~(c | u), n = u & c, r.P[t] = s, r.M[t] = n, d;
|
|
1292
1292
|
}
|
|
1293
1293
|
function Fe(r, e, t) {
|
|
1294
1294
|
if (e.length === 0)
|
|
@@ -1300,15 +1300,15 @@ function Fe(r, e, t) {
|
|
|
1300
1300
|
lastRowMask: new Uint32Array(n + 1)
|
|
1301
1301
|
};
|
|
1302
1302
|
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
|
|
1303
|
-
const a = new Uint32Array(n + 1),
|
|
1304
|
-
for (let
|
|
1305
|
-
|
|
1306
|
-
for (let
|
|
1307
|
-
const f = e.charCodeAt(
|
|
1308
|
-
if (
|
|
1303
|
+
const a = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
|
|
1304
|
+
for (let d = 0; d < 256; d++)
|
|
1305
|
+
h.push(a);
|
|
1306
|
+
for (let d = 0; d < e.length; d += 1) {
|
|
1307
|
+
const f = e.charCodeAt(d);
|
|
1308
|
+
if (c.has(f))
|
|
1309
1309
|
continue;
|
|
1310
1310
|
const g = new Uint32Array(n + 1);
|
|
1311
|
-
|
|
1311
|
+
c.set(f, g), f < h.length && (h[f] = g);
|
|
1312
1312
|
for (let m = 0; m <= n; m += 1) {
|
|
1313
1313
|
g[m] = 0;
|
|
1314
1314
|
for (let v = 0; v < s; v += 1) {
|
|
@@ -1319,37 +1319,37 @@ function Fe(r, e, t) {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
let
|
|
1322
|
+
let u = Math.max(0, Math.ceil(t / s) - 1);
|
|
1323
1323
|
const p = new Uint32Array(n + 1);
|
|
1324
|
-
for (let
|
|
1325
|
-
p[
|
|
1324
|
+
for (let d = 0; d <= u; d += 1)
|
|
1325
|
+
p[d] = (d + 1) * s;
|
|
1326
1326
|
p[n] = e.length;
|
|
1327
|
-
for (let
|
|
1328
|
-
o.P[
|
|
1329
|
-
for (let
|
|
1330
|
-
const f = r.charCodeAt(
|
|
1327
|
+
for (let d = 0; d <= u; d += 1)
|
|
1328
|
+
o.P[d] = -1, o.M[d] = 0;
|
|
1329
|
+
for (let d = 0; d < r.length; d += 1) {
|
|
1330
|
+
const f = r.charCodeAt(d);
|
|
1331
1331
|
let g;
|
|
1332
|
-
f <
|
|
1332
|
+
f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = a));
|
|
1333
1333
|
let m = 0;
|
|
1334
|
-
for (let v = 0; v <=
|
|
1334
|
+
for (let v = 0; v <= u; v += 1)
|
|
1335
1335
|
m = xe(o, g, v, m), p[v] += m;
|
|
1336
|
-
if (p[
|
|
1337
|
-
|
|
1336
|
+
if (p[u] - m <= t && u < n && (g[u + 1] & 1 || m < 0)) {
|
|
1337
|
+
u += 1, o.P[u] = -1, o.M[u] = 0;
|
|
1338
1338
|
let v;
|
|
1339
|
-
if (
|
|
1339
|
+
if (u === n) {
|
|
1340
1340
|
const S = e.length % s;
|
|
1341
1341
|
v = S === 0 ? s : S;
|
|
1342
1342
|
} else
|
|
1343
1343
|
v = s;
|
|
1344
|
-
p[
|
|
1344
|
+
p[u] = p[u - 1] + v - m + xe(o, g, u, m);
|
|
1345
1345
|
} else
|
|
1346
|
-
for (;
|
|
1347
|
-
|
|
1348
|
-
|
|
1346
|
+
for (; u > 0 && p[u] >= t + s; )
|
|
1347
|
+
u -= 1;
|
|
1348
|
+
u === n && p[u] <= t && (p[u] < t && i.splice(0, i.length), i.push({
|
|
1349
1349
|
start: -1,
|
|
1350
|
-
end:
|
|
1351
|
-
errors: p[
|
|
1352
|
-
}), t = p[
|
|
1350
|
+
end: d + 1,
|
|
1351
|
+
errors: p[u]
|
|
1352
|
+
}), t = p[u]);
|
|
1353
1353
|
}
|
|
1354
1354
|
return i;
|
|
1355
1355
|
}
|
|
@@ -1378,7 +1378,7 @@ function Et(r, e, t = {}) {
|
|
|
1378
1378
|
if (s.length === 0)
|
|
1379
1379
|
return null;
|
|
1380
1380
|
const n = (a) => {
|
|
1381
|
-
const
|
|
1381
|
+
const d = 1 - a.errors / e.length, f = t.prefix ? Se(
|
|
1382
1382
|
r.slice(
|
|
1383
1383
|
Math.max(0, a.start - t.prefix.length),
|
|
1384
1384
|
a.start
|
|
@@ -1390,14 +1390,14 @@ function Et(r, e, t = {}) {
|
|
|
1390
1390
|
) : 1;
|
|
1391
1391
|
let m = 1;
|
|
1392
1392
|
typeof t.hint == "number" && (m = 1 - Math.abs(a.start - t.hint) / r.length);
|
|
1393
|
-
const v = 50 *
|
|
1393
|
+
const v = 50 * d + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
|
|
1394
1394
|
return v / S;
|
|
1395
1395
|
}, o = s.map((a) => ({
|
|
1396
1396
|
start: a.start,
|
|
1397
1397
|
end: a.end,
|
|
1398
1398
|
score: n(a)
|
|
1399
1399
|
}));
|
|
1400
|
-
return o.sort((a,
|
|
1400
|
+
return o.sort((a, c) => c.score - a.score), o[0];
|
|
1401
1401
|
}
|
|
1402
1402
|
function J(r, e, t) {
|
|
1403
1403
|
const i = t === 1 ? e : e - 1;
|
|
@@ -1409,7 +1409,7 @@ function J(r, e, t) {
|
|
|
1409
1409
|
const o = s.length - n.length;
|
|
1410
1410
|
return t === 2 ? e - o : e + o;
|
|
1411
1411
|
}
|
|
1412
|
-
function
|
|
1412
|
+
function we(r, e) {
|
|
1413
1413
|
const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1414
1414
|
r.commonAncestorContainer,
|
|
1415
1415
|
NodeFilter.SHOW_TEXT
|
|
@@ -1421,8 +1421,8 @@ function Te(r, e) {
|
|
|
1421
1421
|
let o = -1;
|
|
1422
1422
|
const a = () => {
|
|
1423
1423
|
if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
|
|
1424
|
-
const
|
|
1425
|
-
o = J(
|
|
1424
|
+
const c = n.textContent, h = e === 1 ? 0 : c.length;
|
|
1425
|
+
o = J(c, h, e);
|
|
1426
1426
|
}
|
|
1427
1427
|
};
|
|
1428
1428
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1457,7 +1457,7 @@ function bt(r) {
|
|
|
1457
1457
|
if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)
|
|
1458
1458
|
return e;
|
|
1459
1459
|
if (!t) {
|
|
1460
|
-
const { node: n, offset: o } =
|
|
1460
|
+
const { node: n, offset: o } = we(
|
|
1461
1461
|
e,
|
|
1462
1462
|
1
|
|
1463
1463
|
/* Forwards */
|
|
@@ -1465,7 +1465,7 @@ function bt(r) {
|
|
|
1465
1465
|
n && o >= 0 && e.setStart(n, o);
|
|
1466
1466
|
}
|
|
1467
1467
|
if (!i) {
|
|
1468
|
-
const { node: n, offset: o } =
|
|
1468
|
+
const { node: n, offset: o } = we(
|
|
1469
1469
|
e,
|
|
1470
1470
|
2
|
|
1471
1471
|
/* Backwards */
|
|
@@ -1484,7 +1484,7 @@ function Ue(r) {
|
|
|
1484
1484
|
return 0;
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1487
|
+
function Te(r) {
|
|
1488
1488
|
let e = r.previousSibling, t = 0;
|
|
1489
1489
|
for (; e; )
|
|
1490
1490
|
t += Ue(e), e = e.previousSibling;
|
|
@@ -1522,7 +1522,7 @@ class M {
|
|
|
1522
1522
|
throw new Error("Parent is not an ancestor of current element");
|
|
1523
1523
|
let t = this.element, i = this.offset;
|
|
1524
1524
|
for (; t !== e; )
|
|
1525
|
-
i +=
|
|
1525
|
+
i += Te(t), t = t.parentElement;
|
|
1526
1526
|
return new M(t, i);
|
|
1527
1527
|
}
|
|
1528
1528
|
/**
|
|
@@ -1587,7 +1587,7 @@ class M {
|
|
|
1587
1587
|
throw new Error("Text node offset is out of range");
|
|
1588
1588
|
if (!e.parentElement)
|
|
1589
1589
|
throw new Error("Text node has no parent");
|
|
1590
|
-
const i =
|
|
1590
|
+
const i = Te(e) + t;
|
|
1591
1591
|
return new M(e.parentElement, i);
|
|
1592
1592
|
}
|
|
1593
1593
|
case Node.ELEMENT_NODE: {
|
|
@@ -1782,25 +1782,25 @@ function St(r, e) {
|
|
|
1782
1782
|
let t = r.getClientRects();
|
|
1783
1783
|
t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
|
|
1784
1784
|
const i = 1, s = [];
|
|
1785
|
-
for (const
|
|
1785
|
+
for (const h of t)
|
|
1786
1786
|
s.push({
|
|
1787
|
-
bottom:
|
|
1788
|
-
height:
|
|
1789
|
-
left:
|
|
1790
|
-
right:
|
|
1791
|
-
top:
|
|
1792
|
-
width:
|
|
1787
|
+
bottom: h.bottom,
|
|
1788
|
+
height: h.height,
|
|
1789
|
+
left: h.left,
|
|
1790
|
+
right: h.right,
|
|
1791
|
+
top: h.top,
|
|
1792
|
+
width: h.width
|
|
1793
1793
|
});
|
|
1794
1794
|
const n = He(
|
|
1795
1795
|
s,
|
|
1796
1796
|
i,
|
|
1797
1797
|
e
|
|
1798
|
-
), o =
|
|
1799
|
-
for (let
|
|
1800
|
-
const
|
|
1801
|
-
if (!(
|
|
1798
|
+
), o = Tt(n, i), a = $e(o), c = 2 * 2;
|
|
1799
|
+
for (let h = a.length - 1; h >= 0; h--) {
|
|
1800
|
+
const u = a[h];
|
|
1801
|
+
if (!(u.width * u.height > c))
|
|
1802
1802
|
if (a.length > 1)
|
|
1803
|
-
a.splice(
|
|
1803
|
+
a.splice(h, 1);
|
|
1804
1804
|
else
|
|
1805
1805
|
break;
|
|
1806
1806
|
}
|
|
@@ -1812,11 +1812,11 @@ function He(r, e, t) {
|
|
|
1812
1812
|
const n = r[i], o = r[s];
|
|
1813
1813
|
if (n === o)
|
|
1814
1814
|
continue;
|
|
1815
|
-
const a = N(n.top, o.top, e) && N(n.bottom, o.bottom, e),
|
|
1816
|
-
if ((
|
|
1817
|
-
const
|
|
1818
|
-
return
|
|
1819
|
-
|
|
1815
|
+
const a = N(n.top, o.top, e) && N(n.bottom, o.bottom, e), c = N(n.left, o.left, e) && N(n.right, o.right, e);
|
|
1816
|
+
if ((c && !t || a && !c) && je(n, o, e)) {
|
|
1817
|
+
const d = r.filter((g) => g !== n && g !== o), f = wt(n, o);
|
|
1818
|
+
return d.push(f), He(
|
|
1819
|
+
d,
|
|
1820
1820
|
e,
|
|
1821
1821
|
t
|
|
1822
1822
|
);
|
|
@@ -1824,7 +1824,7 @@ function He(r, e, t) {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
return r;
|
|
1826
1826
|
}
|
|
1827
|
-
function
|
|
1827
|
+
function wt(r, e) {
|
|
1828
1828
|
const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);
|
|
1829
1829
|
return {
|
|
1830
1830
|
bottom: n,
|
|
@@ -1835,7 +1835,7 @@ function Tt(r, e) {
|
|
|
1835
1835
|
width: i - t
|
|
1836
1836
|
};
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1838
|
+
function Tt(r, e) {
|
|
1839
1839
|
const t = new Set(r);
|
|
1840
1840
|
for (const i of r) {
|
|
1841
1841
|
if (!(i.width > 1 && i.height > 1)) {
|
|
@@ -1866,11 +1866,11 @@ function $e(r) {
|
|
|
1866
1866
|
if (a.length === 1)
|
|
1867
1867
|
n = a, o = i;
|
|
1868
1868
|
else {
|
|
1869
|
-
const
|
|
1870
|
-
a.length <
|
|
1869
|
+
const h = Ce(s, i);
|
|
1870
|
+
a.length < h.length ? (n = a, o = i) : (n = h, o = s);
|
|
1871
1871
|
}
|
|
1872
|
-
const
|
|
1873
|
-
return Array.prototype.push.apply(
|
|
1872
|
+
const c = r.filter((h) => h !== o);
|
|
1873
|
+
return Array.prototype.push.apply(c, n), $e(c);
|
|
1874
1874
|
}
|
|
1875
1875
|
}
|
|
1876
1876
|
return r;
|
|
@@ -1943,14 +1943,14 @@ function je(r, e, t) {
|
|
|
1943
1943
|
function N(r, e, t) {
|
|
1944
1944
|
return Math.abs(r - e) <= t;
|
|
1945
1945
|
}
|
|
1946
|
-
function
|
|
1946
|
+
function Ve(r) {
|
|
1947
1947
|
const e = {}, t = r.document.documentElement.style;
|
|
1948
1948
|
for (const i in r.document.documentElement.style)
|
|
1949
1949
|
Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
|
|
1950
1950
|
return e;
|
|
1951
1951
|
}
|
|
1952
1952
|
function Nt(r, e) {
|
|
1953
|
-
const t =
|
|
1953
|
+
const t = Ve(r);
|
|
1954
1954
|
Object.keys(t).forEach((i) => {
|
|
1955
1955
|
e.hasOwnProperty(i) || he(r, i);
|
|
1956
1956
|
}), Object.entries(e).forEach(([i, s]) => {
|
|
@@ -1999,7 +1999,7 @@ const At = (r) => {
|
|
|
1999
1999
|
return Mt(e) < 128;
|
|
2000
2000
|
};
|
|
2001
2001
|
var It = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(It || {}), Lt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Lt || {});
|
|
2002
|
-
const Rt = "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2002
|
+
const Rt = () => "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2003
2003
|
class zt {
|
|
2004
2004
|
/**
|
|
2005
2005
|
* Creates a DecorationGroup object
|
|
@@ -2007,7 +2007,7 @@ class zt {
|
|
|
2007
2007
|
* @param name Human-readable name of the group
|
|
2008
2008
|
*/
|
|
2009
2009
|
constructor(e, t, i, s) {
|
|
2010
|
-
this.wnd = e, this.comms = t, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Rt && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2010
|
+
this.wnd = e, this.comms = t, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Rt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2011
2011
|
}
|
|
2012
2012
|
get activeable() {
|
|
2013
2013
|
return this.activateable;
|
|
@@ -2020,14 +2020,14 @@ class zt {
|
|
|
2020
2020
|
* @param decoration Decoration to add
|
|
2021
2021
|
*/
|
|
2022
2022
|
add(e) {
|
|
2023
|
-
var o, a,
|
|
2023
|
+
var o, a, c, h;
|
|
2024
2024
|
const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
|
|
2025
2025
|
if (!i) {
|
|
2026
2026
|
this.comms.log("Can't locate DOM range for decoration", e);
|
|
2027
2027
|
return;
|
|
2028
2028
|
}
|
|
2029
2029
|
const s = i.commonAncestorContainer;
|
|
2030
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((
|
|
2030
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((c = s.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(t, !0)));
|
|
2031
2031
|
const n = {
|
|
2032
2032
|
decoration: e,
|
|
2033
2033
|
id: t,
|
|
@@ -2095,30 +2095,30 @@ class zt {
|
|
|
2095
2095
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2096
2096
|
"column-count"
|
|
2097
2097
|
)
|
|
2098
|
-
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft,
|
|
2099
|
-
var ce,
|
|
2100
|
-
if (y.style.position = "absolute", ((
|
|
2098
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, h = (y, b, I) => {
|
|
2099
|
+
var ce, ue, de, pe, fe, me;
|
|
2100
|
+
if (y.style.position = "absolute", ((ue = (ce = e.decoration) == null ? void 0 : ce.style) == null ? void 0 : ue.width) === "viewport") {
|
|
2101
2101
|
y.style.width = `${i}px`, y.style.height = `${b.height}px`;
|
|
2102
2102
|
let K = Math.floor(b.left / i) * i;
|
|
2103
|
-
y.style.left = `${K + a}px`, y.style.top = `${b.top +
|
|
2104
|
-
} else if (((pe = (
|
|
2105
|
-
y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + a}px`, y.style.top = `${b.top +
|
|
2103
|
+
y.style.left = `${K + a}px`, y.style.top = `${b.top + c}px`;
|
|
2104
|
+
} else if (((pe = (de = e.decoration) == null ? void 0 : de.style) == null ? void 0 : pe.width) === "bounds")
|
|
2105
|
+
y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + a}px`, y.style.top = `${b.top + c}px`;
|
|
2106
2106
|
else if (((me = (fe = e.decoration) == null ? void 0 : fe.style) == null ? void 0 : me.width) === "page") {
|
|
2107
2107
|
y.style.width = `${n}px`, y.style.height = `${b.height}px`;
|
|
2108
2108
|
let K = Math.floor(b.left / n) * n;
|
|
2109
|
-
y.style.left = `${K + a}px`, y.style.top = `${b.top +
|
|
2109
|
+
y.style.left = `${K + a}px`, y.style.top = `${b.top + c}px`;
|
|
2110
2110
|
} else
|
|
2111
|
-
y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + a}px`, y.style.top = `${b.top +
|
|
2112
|
-
},
|
|
2111
|
+
y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + a}px`, y.style.top = `${b.top + c}px`;
|
|
2112
|
+
}, u = e.range.getBoundingClientRect();
|
|
2113
2113
|
let p = this.wnd.document.createElement("template");
|
|
2114
|
-
const
|
|
2114
|
+
const d = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
|
|
2115
2115
|
p.innerHTML = `
|
|
2116
2116
|
<div
|
|
2117
2117
|
class="r2-highlight-0"
|
|
2118
2118
|
style="${[
|
|
2119
2119
|
`background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
|
|
2120
2120
|
//"opacity: 0.3 !important",
|
|
2121
|
-
`mix-blend-mode: ${
|
|
2121
|
+
`mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
|
|
2122
2122
|
"opacity: 1 !important",
|
|
2123
2123
|
"box-sizing: border-box !important"
|
|
2124
2124
|
].join("; ")}"
|
|
@@ -2128,7 +2128,7 @@ class zt {
|
|
|
2128
2128
|
const f = p.content.firstElementChild;
|
|
2129
2129
|
if (((O = (S = e.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
|
|
2130
2130
|
const y = f.cloneNode(!0);
|
|
2131
|
-
y.style.setProperty("pointer-events", "none"),
|
|
2131
|
+
y.style.setProperty("pointer-events", "none"), h(y, u, u), t.append(y);
|
|
2132
2132
|
} else {
|
|
2133
2133
|
let y = St(
|
|
2134
2134
|
e.range,
|
|
@@ -2138,7 +2138,7 @@ class zt {
|
|
|
2138
2138
|
y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
|
|
2139
2139
|
for (let b of y) {
|
|
2140
2140
|
const I = f.cloneNode(!0);
|
|
2141
|
-
I.style.setProperty("pointer-events", "none"),
|
|
2141
|
+
I.style.setProperty("pointer-events", "none"), h(I, b, u), t.append(I);
|
|
2142
2142
|
}
|
|
2143
2143
|
}
|
|
2144
2144
|
e.container = t, e.clickableElements = Array.from(
|
|
@@ -2175,7 +2175,7 @@ class zt {
|
|
|
2175
2175
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
const
|
|
2178
|
+
const qe = class Q extends Y {
|
|
2179
2179
|
constructor() {
|
|
2180
2180
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2181
2181
|
}
|
|
@@ -2220,8 +2220,8 @@ const Ve = class Q extends Y {
|
|
|
2220
2220
|
return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
|
|
2221
2221
|
}
|
|
2222
2222
|
};
|
|
2223
|
-
|
|
2224
|
-
let Dt =
|
|
2223
|
+
qe.moduleName = "decorator";
|
|
2224
|
+
let Dt = qe;
|
|
2225
2225
|
const Ae = "readium-snapper-style", _e = class ee extends Y {
|
|
2226
2226
|
constructor() {
|
|
2227
2227
|
super(...arguments), this.protected = !1;
|
|
@@ -2263,20 +2263,24 @@ function Me(r) {
|
|
|
2263
2263
|
return r.clientHeight - t - i;
|
|
2264
2264
|
}
|
|
2265
2265
|
function Oe(r) {
|
|
2266
|
-
const e = r
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
const t =
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2266
|
+
const e = Ge(r);
|
|
2267
|
+
if (!e)
|
|
2268
|
+
return !1;
|
|
2269
|
+
const t = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2270
|
+
for (const h of t)
|
|
2271
|
+
h.remove();
|
|
2272
|
+
const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * e) % e, c = e === 1 || a === 0 ? 0 : e - a;
|
|
2273
|
+
if (c > 0)
|
|
2274
|
+
for (let h = 0; h < c; h++) {
|
|
2275
|
+
const u = r.document.createElement("div");
|
|
2276
|
+
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = Me(r.document.documentElement) + "px"), u.innerHTML = "​", r.document.body.appendChild(u);
|
|
2274
2277
|
}
|
|
2278
|
+
return i !== c;
|
|
2275
2279
|
}
|
|
2276
2280
|
function Wt(r) {
|
|
2277
2281
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2278
2282
|
}
|
|
2279
|
-
function
|
|
2283
|
+
function w(r) {
|
|
2280
2284
|
const e = r.getSelection();
|
|
2281
2285
|
e && e.removeAllRanges();
|
|
2282
2286
|
}
|
|
@@ -2344,7 +2348,7 @@ function kt(r) {
|
|
|
2344
2348
|
}
|
|
2345
2349
|
return !1;
|
|
2346
2350
|
}
|
|
2347
|
-
const Ie = "readium-column-snapper-style", Ht = 200, Je = class
|
|
2351
|
+
const Ie = "readium-column-snapper-style", Ht = 200, Je = class T extends Xe {
|
|
2348
2352
|
constructor() {
|
|
2349
2353
|
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);
|
|
2350
2354
|
}
|
|
@@ -2380,13 +2384,13 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2380
2384
|
}
|
|
2381
2385
|
// Snaps the current offset to the page width.
|
|
2382
2386
|
snapCurrentOffset(e = !1, t = !1) {
|
|
2383
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth),
|
|
2387
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), c = W(this.wnd) ? -1 : 1, h = (
|
|
2384
2388
|
// The hurdle to overcome in order to change pages
|
|
2385
|
-
|
|
2386
|
-
),
|
|
2387
|
-
if (e &&
|
|
2389
|
+
c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
|
|
2390
|
+
), u = this.snapOffset(a + h);
|
|
2391
|
+
if (e && u !== this.scrollOffset()) {
|
|
2388
2392
|
this.snappingCancelled = !1;
|
|
2389
|
-
const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O),
|
|
2393
|
+
const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O), d = (
|
|
2390
2394
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2391
2395
|
Ht * o
|
|
2392
2396
|
);
|
|
@@ -2395,13 +2399,13 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2395
2399
|
if (this.snappingCancelled)
|
|
2396
2400
|
return;
|
|
2397
2401
|
f || (f = m);
|
|
2398
|
-
const v = m - f, S = p(this.overscroll, 0, v,
|
|
2399
|
-
s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v <
|
|
2402
|
+
const v = m - f, S = p(this.overscroll, 0, v, d), O = p(i, u, v, d);
|
|
2403
|
+
s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, t || this.reportProgress());
|
|
2400
2404
|
};
|
|
2401
2405
|
this.wnd.requestAnimationFrame(g);
|
|
2402
2406
|
} else
|
|
2403
2407
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2404
|
-
s.scrollLeft =
|
|
2408
|
+
s.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
|
|
2405
2409
|
});
|
|
2406
2410
|
}
|
|
2407
2411
|
dragOffset() {
|
|
@@ -2437,7 +2441,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2437
2441
|
onTouchMove(e) {
|
|
2438
2442
|
if (this.touchState === 0)
|
|
2439
2443
|
return;
|
|
2440
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2444
|
+
this.touchState === 1 && (this.touchState = 2, w(this.wnd)), this.endingX = e.touches[0].clientX;
|
|
2441
2445
|
const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
|
|
2442
2446
|
i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
|
|
2443
2447
|
}
|
|
@@ -2487,8 +2491,8 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2487
2491
|
}), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2488
2492
|
for (const o of n)
|
|
2489
2493
|
if (o.target === this.wnd.document.documentElement) {
|
|
2490
|
-
const a = o.oldValue,
|
|
2491
|
-
(!
|
|
2494
|
+
const a = o.oldValue, c = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a == null ? void 0 : a.match(h), p = c == null ? void 0 : c.match(h);
|
|
2495
|
+
(!u && !p || u && !p || u && p && u[1] !== p[1]) && (e.requestAnimationFrame(() => {
|
|
2492
2496
|
e && Oe(e);
|
|
2493
2497
|
}), this.onWidthChange());
|
|
2494
2498
|
} else
|
|
@@ -2498,7 +2502,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2498
2502
|
const o = this.doc().scrollLeft;
|
|
2499
2503
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2500
2504
|
};
|
|
2501
|
-
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression",
|
|
2505
|
+
return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", T.moduleName, (n, o) => {
|
|
2502
2506
|
const a = n;
|
|
2503
2507
|
if (a < 0 || a > 1) {
|
|
2504
2508
|
t.send("error", {
|
|
@@ -2508,74 +2512,74 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2508
2512
|
}
|
|
2509
2513
|
this.wnd.requestAnimationFrame(() => {
|
|
2510
2514
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2511
|
-
const
|
|
2512
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2515
|
+
const c = this.cachedScrollWidth, h = W(e) ? -1 : 1, u = c * a * h;
|
|
2516
|
+
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), w(this.wnd), o(!0);
|
|
2513
2517
|
});
|
|
2514
|
-
}), t.register("go_id",
|
|
2518
|
+
}), t.register("go_id", T.moduleName, (n, o) => {
|
|
2515
2519
|
const a = e.document.getElementById(n);
|
|
2516
2520
|
if (!a) {
|
|
2517
2521
|
o(!1);
|
|
2518
2522
|
return;
|
|
2519
2523
|
}
|
|
2520
2524
|
this.wnd.requestAnimationFrame(() => {
|
|
2521
|
-
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(),
|
|
2525
|
+
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
|
|
2522
2526
|
});
|
|
2523
|
-
}), t.register("go_text",
|
|
2527
|
+
}), t.register("go_text", T.moduleName, (n, o) => {
|
|
2524
2528
|
let a;
|
|
2525
2529
|
Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
|
|
2526
|
-
const
|
|
2530
|
+
const c = U.deserialize(n), h = le(this.wnd.document, new D({
|
|
2527
2531
|
href: e.location.href,
|
|
2528
2532
|
type: "text/html",
|
|
2529
|
-
text:
|
|
2533
|
+
text: c,
|
|
2530
2534
|
locations: a ? new x({
|
|
2531
2535
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2532
2536
|
["cssSelector", a]
|
|
2533
2537
|
])
|
|
2534
2538
|
}) : void 0
|
|
2535
2539
|
}));
|
|
2536
|
-
if (!
|
|
2540
|
+
if (!h) {
|
|
2537
2541
|
o(!1);
|
|
2538
2542
|
return;
|
|
2539
2543
|
}
|
|
2540
2544
|
this.wnd.requestAnimationFrame(() => {
|
|
2541
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2545
|
+
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
|
|
2542
2546
|
});
|
|
2543
|
-
}), t.register("go_end",
|
|
2547
|
+
}), t.register("go_end", T.moduleName, (n, o) => {
|
|
2544
2548
|
const a = W(e) ? -1 : 1;
|
|
2545
2549
|
this.wnd.requestAnimationFrame(() => {
|
|
2546
2550
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2547
|
-
const
|
|
2548
|
-
if (this.doc().scrollLeft ===
|
|
2551
|
+
const c = this.cachedScrollWidth * a;
|
|
2552
|
+
if (this.doc().scrollLeft === c)
|
|
2549
2553
|
return o(!1);
|
|
2550
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2554
|
+
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), w(this.wnd), o(!0);
|
|
2551
2555
|
});
|
|
2552
|
-
}), t.register("go_start",
|
|
2556
|
+
}), t.register("go_start", T.moduleName, (n, o) => {
|
|
2553
2557
|
this.wnd.requestAnimationFrame(() => {
|
|
2554
2558
|
if (this.doc().scrollLeft === 0)
|
|
2555
2559
|
return o(!1);
|
|
2556
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2560
|
+
this.doc().scrollLeft = 0, this.reportProgress(), w(this.wnd), o(!0);
|
|
2557
2561
|
});
|
|
2558
|
-
}), t.register("go_prev",
|
|
2562
|
+
}), t.register("go_prev", T.moduleName, (n, o) => {
|
|
2559
2563
|
this.wnd.requestAnimationFrame(() => {
|
|
2560
2564
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2561
|
-
const a = e.scrollX - e.innerWidth,
|
|
2562
|
-
|
|
2565
|
+
const a = e.scrollX - e.innerWidth, c = W(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(a, c));
|
|
2566
|
+
h && (this.reportProgress(), w(this.wnd)), o(h);
|
|
2563
2567
|
});
|
|
2564
|
-
}), t.register("go_next",
|
|
2568
|
+
}), t.register("go_next", T.moduleName, (n, o) => {
|
|
2565
2569
|
this.wnd.requestAnimationFrame(() => {
|
|
2566
2570
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2567
|
-
const a = e.scrollX + e.innerWidth,
|
|
2568
|
-
|
|
2571
|
+
const a = e.scrollX + e.innerWidth, c = W(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(a, c));
|
|
2572
|
+
h && (this.reportProgress(), w(this.wnd)), o(h);
|
|
2569
2573
|
});
|
|
2570
|
-
}), t.register("unfocus",
|
|
2571
|
-
this.snappingCancelled = !0,
|
|
2572
|
-
}), t.register("shake",
|
|
2574
|
+
}), t.register("unfocus", T.moduleName, (n, o) => {
|
|
2575
|
+
this.snappingCancelled = !0, w(this.wnd), o(!0);
|
|
2576
|
+
}), t.register("shake", T.moduleName, (n, o) => {
|
|
2573
2577
|
this.shake(), o(!0);
|
|
2574
|
-
}), t.register("focus",
|
|
2578
|
+
}), t.register("focus", T.moduleName, (n, o) => {
|
|
2575
2579
|
this.wnd.requestAnimationFrame(() => {
|
|
2576
2580
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2577
2581
|
});
|
|
2578
|
-
}), t.register("first_visible_locator",
|
|
2582
|
+
}), t.register("first_visible_locator", T.moduleName, (n, o) => {
|
|
2579
2583
|
const a = Ke(e, !1);
|
|
2580
2584
|
this.comms.send("first_visible_locator", a.serialize()), o(!0);
|
|
2581
2585
|
}), 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", () => {
|
|
@@ -2583,7 +2587,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2583
2587
|
}
|
|
2584
2588
|
unmount(e, t) {
|
|
2585
2589
|
var i;
|
|
2586
|
-
return this.snappingCancelled = !0, t.unregisterAll(
|
|
2590
|
+
return this.snappingCancelled = !0, t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), (i = e.document.getElementById(Ie)) == null || i.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
|
|
2587
2591
|
}
|
|
2588
2592
|
};
|
|
2589
2593
|
Je.moduleName = "column_snapper";
|
|
@@ -2627,7 +2631,7 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
|
|
|
2627
2631
|
return;
|
|
2628
2632
|
}
|
|
2629
2633
|
this.wnd.requestAnimationFrame(() => {
|
|
2630
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }),
|
|
2634
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
|
|
2631
2635
|
});
|
|
2632
2636
|
}), t.register("go_id", A.moduleName, (s, n) => {
|
|
2633
2637
|
const o = e.document.getElementById(s);
|
|
@@ -2638,12 +2642,12 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
|
|
|
2638
2642
|
this.wnd.requestAnimationFrame(() => {
|
|
2639
2643
|
this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
|
|
2640
2644
|
const a = this.doc().scrollTop / this.doc().offsetHeight;
|
|
2641
|
-
this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }),
|
|
2645
|
+
this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
|
|
2642
2646
|
});
|
|
2643
2647
|
}), t.register("go_text", A.moduleName, (s, n) => {
|
|
2644
2648
|
let o;
|
|
2645
2649
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
2646
|
-
const a = U.deserialize(s),
|
|
2650
|
+
const a = U.deserialize(s), c = le(this.wnd.document, new D({
|
|
2647
2651
|
href: e.location.href,
|
|
2648
2652
|
type: "text/html",
|
|
2649
2653
|
text: a,
|
|
@@ -2653,14 +2657,14 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
|
|
|
2653
2657
|
])
|
|
2654
2658
|
}) : void 0
|
|
2655
2659
|
}));
|
|
2656
|
-
if (!
|
|
2660
|
+
if (!c) {
|
|
2657
2661
|
n(!1);
|
|
2658
2662
|
return;
|
|
2659
2663
|
}
|
|
2660
2664
|
this.wnd.requestAnimationFrame(() => {
|
|
2661
|
-
this.doc().scrollTop =
|
|
2662
|
-
const
|
|
2663
|
-
this.reportProgress({ progress:
|
|
2665
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
|
|
2666
|
+
const h = this.doc().scrollTop / this.doc().offsetHeight;
|
|
2667
|
+
this.reportProgress({ progress: h, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
|
|
2664
2668
|
});
|
|
2665
2669
|
}), t.register("go_start", A.moduleName, (s, n) => {
|
|
2666
2670
|
if (this.doc().scrollTop === 0)
|
|
@@ -2671,7 +2675,7 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
|
|
|
2671
2675
|
return n(!1);
|
|
2672
2676
|
this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
|
|
2673
2677
|
}), t.register("unfocus", A.moduleName, (s, n) => {
|
|
2674
|
-
|
|
2678
|
+
w(this.wnd), n(!0);
|
|
2675
2679
|
}), t.register([
|
|
2676
2680
|
"go_next",
|
|
2677
2681
|
"go_prev"
|
|
@@ -2695,18 +2699,18 @@ class et extends Y {
|
|
|
2695
2699
|
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);
|
|
2696
2700
|
}
|
|
2697
2701
|
onPointUp(e) {
|
|
2698
|
-
var s, n, o, a,
|
|
2702
|
+
var s, n, o, a, c;
|
|
2699
2703
|
const t = this.wnd.getSelection();
|
|
2700
2704
|
if (t && ((s = t.toString()) == null ? void 0 : s.length) > 0) {
|
|
2701
|
-
const
|
|
2702
|
-
if (!
|
|
2705
|
+
const h = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
|
|
2706
|
+
if (!h || h.length === 0)
|
|
2703
2707
|
return;
|
|
2704
|
-
const
|
|
2708
|
+
const u = h[0], p = {
|
|
2705
2709
|
text: t.toString(),
|
|
2706
|
-
x:
|
|
2707
|
-
y:
|
|
2708
|
-
width:
|
|
2709
|
-
height:
|
|
2710
|
+
x: u.x,
|
|
2711
|
+
y: u.y,
|
|
2712
|
+
width: u.width,
|
|
2713
|
+
height: u.height,
|
|
2710
2714
|
targetFrameSrc: (a = (o = this.wnd) == null ? void 0 : o.location) == null ? void 0 : a.href
|
|
2711
2715
|
};
|
|
2712
2716
|
this.comms.send("text_selected", p);
|
|
@@ -2724,7 +2728,7 @@ class et extends Y {
|
|
|
2724
2728
|
y: e.clientY * i,
|
|
2725
2729
|
targetFrameSrc: this.wnd.location.href,
|
|
2726
2730
|
targetElement: e.target.outerHTML,
|
|
2727
|
-
interactiveElement: (
|
|
2731
|
+
interactiveElement: (c = Ye(e.target)) == null ? void 0 : c.outerHTML,
|
|
2728
2732
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
|
|
2729
2733
|
}), this.pointerMoved = !1;
|
|
2730
2734
|
}
|
|
@@ -2815,7 +2819,7 @@ const tt = class te extends Y {
|
|
|
2815
2819
|
), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
|
|
2816
2820
|
value: {
|
|
2817
2821
|
name: "readium-ts-toolkit",
|
|
2818
|
-
version: "2.0.0-beta.
|
|
2822
|
+
version: "2.0.0-beta.3",
|
|
2819
2823
|
hasFeature: (s, n = "") => {
|
|
2820
2824
|
switch (s) {
|
|
2821
2825
|
case "dom-manipulation":
|
|
@@ -2879,7 +2883,7 @@ const Re = "readium-viewport", rt = class F extends it {
|
|
|
2879
2883
|
), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
2880
2884
|
target: e
|
|
2881
2885
|
}), t.register("get_properties", F.moduleName, (s, n) => {
|
|
2882
|
-
|
|
2886
|
+
Ve(e), n(!0);
|
|
2883
2887
|
}), t.register("update_properties", F.moduleName, (s, n) => {
|
|
2884
2888
|
s["--RS__viewportWidth"] = `${e.innerWidth}px`, Nt(e, s), n(!0);
|
|
2885
2889
|
}), t.register("set_property", F.moduleName, (s, n) => {
|
|
@@ -2897,7 +2901,7 @@ const Re = "readium-viewport", rt = class F extends it {
|
|
|
2897
2901
|
}
|
|
2898
2902
|
};
|
|
2899
2903
|
rt.moduleName = "reflowable_setup";
|
|
2900
|
-
let
|
|
2904
|
+
let Vt = rt;
|
|
2901
2905
|
const ze = "readium-fixed-style", st = class L extends it {
|
|
2902
2906
|
mount(e, t) {
|
|
2903
2907
|
if (!super.mount(e, t))
|
|
@@ -2922,7 +2926,7 @@ const ze = "readium-fixed-style", st = class L extends it {
|
|
|
2922
2926
|
}), t.register("remove_property", L.moduleName, (s, n) => {
|
|
2923
2927
|
he(e, s), n(!0);
|
|
2924
2928
|
}), t.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), t.register("unfocus", L.moduleName, (s, n) => {
|
|
2925
|
-
|
|
2929
|
+
w(e), n(!0);
|
|
2926
2930
|
}), t.register([
|
|
2927
2931
|
"focus",
|
|
2928
2932
|
"go_next",
|
|
@@ -2942,7 +2946,7 @@ const ze = "readium-fixed-style", st = class L extends it {
|
|
|
2942
2946
|
}
|
|
2943
2947
|
};
|
|
2944
2948
|
st.moduleName = "fixed_setup";
|
|
2945
|
-
let
|
|
2949
|
+
let qt = st;
|
|
2946
2950
|
const _t = [
|
|
2947
2951
|
"fixed_setup",
|
|
2948
2952
|
"decorator",
|
|
@@ -2955,8 +2959,8 @@ const _t = [
|
|
|
2955
2959
|
"scroll_snapper"
|
|
2956
2960
|
], De = new Map([
|
|
2957
2961
|
// All modules go here
|
|
2958
|
-
Vt,
|
|
2959
2962
|
qt,
|
|
2963
|
+
Vt,
|
|
2960
2964
|
et,
|
|
2961
2965
|
Dt,
|
|
2962
2966
|
$t,
|