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