@prose-reader/koreader 25.0.1 → 26.0.0
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/digest.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +146 -133
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- /package/{LICENCE → LICENSE} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { generate as e, getEpubCfiSpineItemref as t, isIndirectionOnly as n, parse as r, resolve as i } from "@prose-reader/cfi";
|
|
2
|
+
import { md5HexDigest as a } from "@prose-reader/shared";
|
|
2
3
|
//#region src/crengine/elements.ts
|
|
3
|
-
var
|
|
4
|
+
var o = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.article.aside.audio.author.autoboxing.blockquote.body.book-name.book-title.canvas.caption.center.city.col.colgroup.coverpage.custom-info.date.dd.details.dialog.dir.div.dl.docfragment.document-info.dt.email.empty-line.epigraph.fictionbook.fieldset.figcaption.figure.floatbox.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.header.hgroup.history.home-page.hr.html.id.iframe.isbn.keygen.keywords.lang.legend.li.listing.main.map.menu.multicol.nav.nickname.noframes.noscript.ol.optgroup.output.p.part.plaintext.poem.pre.program-used.publish-info.publisher.search.section.select.sequence.source.src-lang.src-ocr.src-title-info.src-url.stanza.subtitle.summary.table.tabularbox.tbody.td.text-author.textarea.tfoot.th.thead.title-info.tr.track.ul.v.version.video.xmp.year".split(".")), s = /* @__PURE__ */ new Set([
|
|
4
5
|
"button",
|
|
5
6
|
"input",
|
|
6
7
|
"marquee"
|
|
7
|
-
]),
|
|
8
|
+
]), c = /* @__PURE__ */ new Set([
|
|
8
9
|
"area",
|
|
9
10
|
"base",
|
|
10
11
|
"basefont",
|
|
@@ -25,14 +26,14 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
25
26
|
"stylesheet",
|
|
26
27
|
"template",
|
|
27
28
|
"title"
|
|
28
|
-
]),
|
|
29
|
+
]), l = /* @__PURE__ */ new Set(/* @__PURE__ */ "annotation.applet.area.audio.author.base.basefont.bgsound.clonenode.col.colgroup.coverpage.description.docfragment.document-info.embed.empty-line.epigraph.fictionbook.head.html.image.img.input.keygen.link.meta.object.param.part.poem.pseudoelem.publish-info.source.src-title-info.stanza.svg.table.tbody.tfoot.thead.title-info.tr.track".split(".")), u = /* @__PURE__ */ new Set([
|
|
29
30
|
"listing",
|
|
30
31
|
"plaintext",
|
|
31
32
|
"pre",
|
|
32
33
|
"style",
|
|
33
34
|
"textarea",
|
|
34
35
|
"xmp"
|
|
35
|
-
]),
|
|
36
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
36
37
|
"desc",
|
|
37
38
|
"metadata",
|
|
38
39
|
"style",
|
|
@@ -48,7 +49,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
48
49
|
"mtext",
|
|
49
50
|
"mspace",
|
|
50
51
|
"ms"
|
|
51
|
-
]), p = /* @__PURE__ */ new Set(["script", "style"]),
|
|
52
|
+
]), p = /* @__PURE__ */ new Set(["script", "style"]), te = {
|
|
52
53
|
table: /* @__PURE__ */ new Set([
|
|
53
54
|
"caption",
|
|
54
55
|
"col",
|
|
@@ -62,12 +63,12 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
62
63
|
tfoot: /* @__PURE__ */ new Set(["tr"]),
|
|
63
64
|
thead: /* @__PURE__ */ new Set(["tr"]),
|
|
64
65
|
tr: /* @__PURE__ */ new Set(["td", "th"])
|
|
65
|
-
},
|
|
66
|
-
let t =
|
|
66
|
+
}, ne = (e) => {
|
|
67
|
+
let t = te[e.localName.toLowerCase()];
|
|
67
68
|
if (!t) return !1;
|
|
68
69
|
for (let n = e.firstElementChild; n; n = n.nextElementSibling) if (!t.has(n.localName.toLowerCase())) return !0;
|
|
69
70
|
return !1;
|
|
70
|
-
},
|
|
71
|
+
}, m = /* @__PURE__ */ new Set(["pre", "textarea"]), h = 1, g = (e) => e.nodeType === h, _ = (e, t) => t ? e.localName : e.localName.toLowerCase(), v = /* @__PURE__ */ new Set([
|
|
71
72
|
"col",
|
|
72
73
|
"colgroup",
|
|
73
74
|
"tbody",
|
|
@@ -76,17 +77,17 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
76
77
|
"th",
|
|
77
78
|
"thead",
|
|
78
79
|
"tr"
|
|
79
|
-
]),
|
|
80
|
+
]), y = (e) => c.has(e) ? "none" : o.has(e) ? "block" : s.has(e) ? "inlineBlock" : e === "ruby" ? "ruby" : "inline", b = (e) => {
|
|
80
81
|
let t = e.localName.toLowerCase();
|
|
81
|
-
return e.hasAttribute("hidden") && !
|
|
82
|
-
},
|
|
82
|
+
return e.hasAttribute("hidden") && !v.has(t) ? "none" : y(t);
|
|
83
|
+
}, x = (e) => {
|
|
83
84
|
let t = e.localName.toLowerCase(), n = !1, r = !1, i = t === "math";
|
|
84
|
-
for (let t = e.parentNode; t &&
|
|
85
|
+
for (let t = e.parentNode; t && g(t); t = t.parentNode) {
|
|
85
86
|
let e = t.localName.toLowerCase();
|
|
86
|
-
|
|
87
|
+
u.has(e) && (n = !0), e === "svg" && (r = !0), e === "math" && (i = !0);
|
|
87
88
|
}
|
|
88
89
|
if (r) {
|
|
89
|
-
let e =
|
|
90
|
+
let e = ee.has(t);
|
|
90
91
|
return {
|
|
91
92
|
display: "inline",
|
|
92
93
|
block: !1,
|
|
@@ -110,54 +111,54 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
110
111
|
opaque: !1,
|
|
111
112
|
insideSvg: !1
|
|
112
113
|
};
|
|
113
|
-
let a =
|
|
114
|
+
let a = b(e);
|
|
114
115
|
return {
|
|
115
116
|
display: a,
|
|
116
117
|
block: a === "block" || a === "inlineBlock",
|
|
117
|
-
allowsText: !
|
|
118
|
-
pre: n ||
|
|
119
|
-
stripsLeadingNewline:
|
|
118
|
+
allowsText: !l.has(t),
|
|
119
|
+
pre: n || u.has(t),
|
|
120
|
+
stripsLeadingNewline: m.has(t),
|
|
120
121
|
trimsText: !1,
|
|
121
122
|
restructured: a === "ruby",
|
|
122
123
|
opaque: p.has(t),
|
|
123
124
|
insideSvg: t === "svg"
|
|
124
125
|
};
|
|
125
|
-
},
|
|
126
|
+
}, re = 8192, S = 9, C = 10, w = 13, T = 32, E = (e) => e === T || e === w || e === C || e === S, D = (e) => {
|
|
126
127
|
for (let t = 0; t < e.length; t++) {
|
|
127
128
|
let n = e.charCodeAt(t);
|
|
128
|
-
if (n !==
|
|
129
|
+
if (n !== T && n !== w && n !== C && n !== S) return !1;
|
|
129
130
|
}
|
|
130
131
|
return !0;
|
|
131
|
-
},
|
|
132
|
+
}, O = (e) => e > 65535 ? 2 : 1, k = (e, t, n) => {
|
|
132
133
|
let r = 0;
|
|
133
134
|
if (!t.pre) {
|
|
134
135
|
let i = 0, a = 0, o = e.length;
|
|
135
|
-
if (t.trim) for (; o > 0 &&
|
|
136
|
+
if (t.trim) for (; o > 0 && E(e.charCodeAt(o - 1));) o--;
|
|
136
137
|
for (; r < e.length;) {
|
|
137
|
-
let s = e.codePointAt(r) ?? 0, c =
|
|
138
|
-
if (
|
|
138
|
+
let s = e.codePointAt(r) ?? 0, c = O(s), l = 1;
|
|
139
|
+
if (E(s) ? (l = +(i === 0), i++, t.trim && (a === 0 || r >= o) && (l = 0)) : i = 0, a += l, !n(r, c, l)) return;
|
|
139
140
|
r += c;
|
|
140
141
|
}
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
let i = 0, a = 0, o = t.stripsLeadingNewline;
|
|
144
145
|
for (; r < e.length;) {
|
|
145
|
-
let t = e.codePointAt(r) ?? 0, s =
|
|
146
|
-
if (t ===
|
|
146
|
+
let t = e.codePointAt(r) ?? 0, s = O(t), c = 1, l = !1;
|
|
147
|
+
if (t === w) {
|
|
147
148
|
let t = r + s < e.length ? e.codePointAt(r + s) : void 0;
|
|
148
|
-
(r === 0 || i !==
|
|
149
|
-
} else t ===
|
|
149
|
+
(r === 0 || i !== C) && t !== C ? (l = !0, i = C) : c = 0;
|
|
150
|
+
} else t === C ? (l = !0, i = C) : t === S ? (c = 8 - (a & 7), a += c, i = S) : (a++, i = t);
|
|
150
151
|
if (l && (a = 1), c > 0 && o && (o = !1, l && (c = 0)), !n(r, s, c)) return;
|
|
151
152
|
r += s;
|
|
152
153
|
}
|
|
153
|
-
},
|
|
154
|
+
}, ie = (e, t, n) => {
|
|
154
155
|
let r = 0;
|
|
155
|
-
return
|
|
156
|
-
},
|
|
156
|
+
return k(e, n, (e, n, i) => e + n > t ? !1 : (r += i, !0)), r;
|
|
157
|
+
}, ae = (e, t, n) => {
|
|
157
158
|
if (t < 0) return;
|
|
158
159
|
let r = 0, i;
|
|
159
|
-
return
|
|
160
|
-
},
|
|
160
|
+
return k(e, n, (e, n, a) => a === 0 ? !0 : r === t || r + a > t ? (i = e, !1) : (r += a, !0)), i === void 0 ? r === t ? e.length : void 0 : i;
|
|
161
|
+
}, oe = (e) => {
|
|
161
162
|
if (e.length < 8192) return [{
|
|
162
163
|
start: 0,
|
|
163
164
|
end: e.length
|
|
@@ -165,7 +166,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
165
166
|
let t = [], n = 0;
|
|
166
167
|
for (; n < e.length;) {
|
|
167
168
|
let r = n, i = 0;
|
|
168
|
-
for (; r < e.length && i < 8192;) r +=
|
|
169
|
+
for (; r < e.length && i < 8192;) r += O(e.codePointAt(r) ?? 0), i++;
|
|
169
170
|
if (i < 8192) {
|
|
170
171
|
t.push({
|
|
171
172
|
start: n,
|
|
@@ -176,13 +177,13 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
176
177
|
let a = r;
|
|
177
178
|
for (let t = r - 1; t >= n; t--) {
|
|
178
179
|
let n = e.charCodeAt(t);
|
|
179
|
-
if (n ===
|
|
180
|
+
if (n === T) {
|
|
180
181
|
a = t + 1;
|
|
181
182
|
break;
|
|
182
183
|
}
|
|
183
|
-
if (n ===
|
|
184
|
+
if (n === w || n === C) {
|
|
184
185
|
let i = t + 1 < r ? e.charCodeAt(t + 1) : 0;
|
|
185
|
-
if (n ===
|
|
186
|
+
if (n === w && i !== C || n === C && i !== w) {
|
|
186
187
|
a = t + 1;
|
|
187
188
|
break;
|
|
188
189
|
}
|
|
@@ -194,12 +195,12 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
194
195
|
}), n = a;
|
|
195
196
|
}
|
|
196
197
|
return t;
|
|
197
|
-
},
|
|
198
|
+
}, se = 3, ce = 4, A = (e) => e.nodeType === se || e.nodeType === ce, le = (e, t) => {
|
|
198
199
|
let n = [], r = 0;
|
|
199
200
|
if (t.opaque) return n;
|
|
200
201
|
for (let i = e.firstChild; i; i = i.nextSibling, r++) {
|
|
201
|
-
if (
|
|
202
|
-
let e = t.insideSvg ? "inline" :
|
|
202
|
+
if (g(i)) {
|
|
203
|
+
let e = t.insideSvg ? "inline" : b(i), a = e === "block" ? "block" : e === "none" ? "invisible" : "inline";
|
|
203
204
|
n.push({
|
|
204
205
|
node: i,
|
|
205
206
|
childIndex: r,
|
|
@@ -209,8 +210,8 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
209
210
|
});
|
|
210
211
|
continue;
|
|
211
212
|
}
|
|
212
|
-
if (!
|
|
213
|
-
let e =
|
|
213
|
+
if (!A(i) || !t.allowsText) continue;
|
|
214
|
+
let e = D(i.data);
|
|
214
215
|
e && (t.block && !t.pre && n.length === 0 || t.trimsText) || n.push({
|
|
215
216
|
node: i,
|
|
216
217
|
childIndex: r,
|
|
@@ -220,19 +221,19 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
220
221
|
});
|
|
221
222
|
}
|
|
222
223
|
return n;
|
|
223
|
-
},
|
|
224
|
+
}, j = (e) => e.role === "inline" || e.role === "text", M = (e) => e !== void 0 && e.role === "text" && e.whitespace, ue = (e, t) => {
|
|
224
225
|
let n = () => e.map((e) => ({
|
|
225
226
|
kind: "node",
|
|
226
227
|
child: e
|
|
227
228
|
}));
|
|
228
229
|
if (t.display === "block" || t.display === "inlineBlock") {
|
|
229
|
-
let r = e.some((e) => e.role === "block"), i = e.some(
|
|
230
|
+
let r = e.some((e) => e.role === "block"), i = e.some(j);
|
|
230
231
|
if (!r || !i) return n();
|
|
231
232
|
let a = [], o = 0;
|
|
232
233
|
for (; o < e.length;) {
|
|
233
234
|
let n = e[o];
|
|
234
235
|
if (!n) break;
|
|
235
|
-
if (!
|
|
236
|
+
if (!j(n)) {
|
|
236
237
|
a.push({
|
|
237
238
|
kind: "node",
|
|
238
239
|
child: n
|
|
@@ -242,14 +243,14 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
242
243
|
let r = o;
|
|
243
244
|
for (; r < e.length;) {
|
|
244
245
|
let t = e[r];
|
|
245
|
-
if (!t || !
|
|
246
|
+
if (!t || !j(t)) break;
|
|
246
247
|
r++;
|
|
247
248
|
}
|
|
248
249
|
let i = e.slice(o, r);
|
|
249
250
|
if (!t.pre) {
|
|
250
251
|
let e = 0;
|
|
251
|
-
for (; e < i.length &&
|
|
252
|
-
i = i.slice(e), i.length > 0 &&
|
|
252
|
+
for (; e < i.length && M(i[e]);) e++;
|
|
253
|
+
i = i.slice(e), i.length > 0 && M(i[i.length - 1]) && (i = i.slice(0, -1));
|
|
253
254
|
}
|
|
254
255
|
i.length > 0 && a.push({
|
|
255
256
|
kind: "box",
|
|
@@ -266,20 +267,20 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
266
267
|
return e.forEach((t, n) => {
|
|
267
268
|
if (t.role !== "block") return;
|
|
268
269
|
let r = e[n - 1], a = e[n + 1];
|
|
269
|
-
r &&
|
|
270
|
+
r && M(r) && i.add(r), a && M(a) && i.add(a);
|
|
270
271
|
}), e.filter((e) => !i.has(e)).map((e) => ({
|
|
271
272
|
kind: "node",
|
|
272
273
|
child: e
|
|
273
274
|
}));
|
|
274
275
|
}
|
|
275
276
|
return n();
|
|
276
|
-
},
|
|
277
|
-
if (
|
|
277
|
+
}, N = (e, t) => ue(le(e, t), t), P = (e, t, n) => {
|
|
278
|
+
if (g(e.node)) return n({
|
|
278
279
|
kind: "element",
|
|
279
280
|
node: e.node,
|
|
280
281
|
childIndex: e.childIndex
|
|
281
282
|
});
|
|
282
|
-
let r =
|
|
283
|
+
let r = oe(e.node.data);
|
|
283
284
|
for (let i = 0; i < r.length; i++) {
|
|
284
285
|
let a = r[i];
|
|
285
286
|
if (a && !n({
|
|
@@ -298,29 +299,25 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
298
299
|
})) return !1;
|
|
299
300
|
}
|
|
300
301
|
return !0;
|
|
301
|
-
},
|
|
302
|
-
for (let r of
|
|
302
|
+
}, F = (e, t, n = x(e)) => {
|
|
303
|
+
for (let r of N(e, n)) {
|
|
303
304
|
let e = r.kind === "box" ? r.children : [r.child];
|
|
304
|
-
for (let r of e) if (!
|
|
305
|
+
for (let r of e) if (!P(r, n, t)) return;
|
|
305
306
|
}
|
|
306
|
-
},
|
|
307
|
+
}, I = (e, t = x(e)) => {
|
|
307
308
|
let n = [];
|
|
308
|
-
for (let r of
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
e && i && F(e, t, (e) => (n.push({
|
|
312
|
-
child: e,
|
|
313
|
-
lastChildIndex: i.childIndex
|
|
314
|
-
}), !1));
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
F(r.child, t, (e) => (n.push({
|
|
309
|
+
for (let r of N(e, t)) if (r.kind === "box") {
|
|
310
|
+
let e = r.children[0], i = r.children[r.children.length - 1];
|
|
311
|
+
e && i && P(e, t, (e) => (n.push({
|
|
318
312
|
child: e,
|
|
319
|
-
lastChildIndex:
|
|
320
|
-
}), !
|
|
321
|
-
}
|
|
313
|
+
lastChildIndex: i.childIndex
|
|
314
|
+
}), !1));
|
|
315
|
+
} else P(r.child, t, (e) => (n.push({
|
|
316
|
+
child: e,
|
|
317
|
+
lastChildIndex: e.childIndex
|
|
318
|
+
}), !0));
|
|
322
319
|
return n;
|
|
323
|
-
},
|
|
320
|
+
}, L = (e) => e.body ?? void 0, R = (e) => {
|
|
324
321
|
let t = `/body/DocFragment[${e.spineItemIndex + 1}]/body`;
|
|
325
322
|
for (let n of e.steps) if (n.kind === "nodeIndex") t += `/${n.index}`;
|
|
326
323
|
else {
|
|
@@ -328,30 +325,30 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
328
325
|
t += n.index === void 0 ? `/${e}` : `/${e}[${n.index}]`;
|
|
329
326
|
}
|
|
330
327
|
return e.point === void 0 ? t : `${t}.${e.point}`;
|
|
331
|
-
},
|
|
332
|
-
let r =
|
|
333
|
-
if (
|
|
328
|
+
}, z = 9, B = (e) => e.nodeType === z, V = (e, t, n) => {
|
|
329
|
+
let r = _(t, n), i, a = 0;
|
|
330
|
+
if (F(e, (e) => e.kind !== "element" || _(e.node, n) !== r || (a++, e.node === t && (i = a), i === void 0 || a === 1)), i !== void 0) return {
|
|
334
331
|
kind: "element",
|
|
335
332
|
name: r,
|
|
336
333
|
index: a > 1 ? i : void 0
|
|
337
334
|
};
|
|
338
|
-
},
|
|
335
|
+
}, H = (e, t) => {
|
|
339
336
|
let n = [], r = e;
|
|
340
337
|
for (; r !== t;) {
|
|
341
|
-
if (!r || !
|
|
338
|
+
if (!r || !g(r)) return;
|
|
342
339
|
n.push(r), r = r.parentNode;
|
|
343
340
|
}
|
|
344
341
|
n.reverse();
|
|
345
342
|
let i = [], a = t, o = !1;
|
|
346
343
|
for (let e of n) {
|
|
347
|
-
let t =
|
|
344
|
+
let t = V(a, e, o);
|
|
348
345
|
if (!t) return;
|
|
349
346
|
i.push(t), e.localName.toLowerCase() === "svg" && (o = !0), a = e;
|
|
350
347
|
}
|
|
351
348
|
return i;
|
|
352
|
-
},
|
|
349
|
+
}, U = (e, t, n) => {
|
|
353
350
|
let r, i = 0, a = 0;
|
|
354
|
-
if (
|
|
351
|
+
if (F(e, (e) => {
|
|
355
352
|
if (e.kind !== "text") return !0;
|
|
356
353
|
if (a++, r === void 0 && e.node === t) {
|
|
357
354
|
let t = e.pieceIndex === e.pieceCount - 1;
|
|
@@ -363,42 +360,42 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
363
360
|
index: i,
|
|
364
361
|
count: a
|
|
365
362
|
};
|
|
366
|
-
},
|
|
367
|
-
let n =
|
|
368
|
-
for (let { child: i, lastChildIndex: a } of
|
|
363
|
+
}, de = (e, t) => {
|
|
364
|
+
let n = x(e), r = 0;
|
|
365
|
+
for (let { child: i, lastChildIndex: a } of I(e, n)) {
|
|
369
366
|
if (i.childIndex >= t || t <= a) break;
|
|
370
367
|
r++;
|
|
371
368
|
}
|
|
372
|
-
return (n.restructured ||
|
|
373
|
-
},
|
|
369
|
+
return (n.restructured || ne(e)) && r > 0 ? void 0 : r;
|
|
370
|
+
}, W = (e, t) => {
|
|
374
371
|
if (!Number.isInteger(t) || t < 0) return;
|
|
375
|
-
let { node: n, offset: r } = e, i =
|
|
372
|
+
let { node: n, offset: r } = e, i = B(n) ? n : n.ownerDocument;
|
|
376
373
|
if (!i) return;
|
|
377
|
-
let a =
|
|
374
|
+
let a = L(i), o = (e, n) => e === void 0 ? void 0 : R({
|
|
378
375
|
spineItemIndex: t,
|
|
379
376
|
steps: e,
|
|
380
377
|
point: n,
|
|
381
378
|
containsBoxingElements: !1
|
|
382
379
|
});
|
|
383
|
-
if (!a) return
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
380
|
+
if (!a) return B(n) || n === i.documentElement ? o([], void 0) : void 0;
|
|
381
|
+
if (B(n)) return;
|
|
382
|
+
if (A(n)) {
|
|
386
383
|
let e = n.parentNode, t = r ?? 0;
|
|
387
|
-
if (!e || !
|
|
388
|
-
let i =
|
|
384
|
+
if (!e || !g(e) || t < 0 || t > n.data.length) return;
|
|
385
|
+
let i = U(e, n, t);
|
|
389
386
|
if (!i) return;
|
|
390
|
-
let { piece: s } = i, c =
|
|
387
|
+
let { piece: s } = i, c = H(e, a);
|
|
391
388
|
return c ? (c.push({
|
|
392
389
|
kind: "text",
|
|
393
390
|
index: i.count > 1 ? i.index : void 0
|
|
394
|
-
}), o(c,
|
|
391
|
+
}), o(c, ie(n.data.slice(s.start, s.end), t - s.start, s.mode))) : void 0;
|
|
395
392
|
}
|
|
396
|
-
if (!
|
|
397
|
-
if (r === void 0) return o(
|
|
393
|
+
if (!g(n)) return;
|
|
394
|
+
if (r === void 0) return o(H(n, a), void 0);
|
|
398
395
|
if (r < 0 || r > n.childNodes.length) return;
|
|
399
|
-
let s =
|
|
400
|
-
return s === void 0 ? void 0 : o(
|
|
401
|
-
},
|
|
396
|
+
let s = de(n, r);
|
|
397
|
+
return s === void 0 ? void 0 : o(H(n, a), s);
|
|
398
|
+
}, G = [
|
|
402
399
|
"autoBoxing",
|
|
403
400
|
"tabularBox",
|
|
404
401
|
"rubyBox",
|
|
@@ -406,16 +403,16 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
406
403
|
"floatBox",
|
|
407
404
|
"inlineBox",
|
|
408
405
|
"pseudoElem"
|
|
409
|
-
],
|
|
406
|
+
], fe = new Set(G.map((e) => e.toLowerCase())), K = (e) => e >= 48 && e <= 57, pe = /^[A-Za-z_][A-Za-z0-9_:-]*$/, q = (e) => e === void 0 || e === "/" || e === ".", J = (e, t) => {
|
|
410
407
|
let n = t;
|
|
411
|
-
for (; n < e.length &&
|
|
408
|
+
for (; n < e.length && K(e.charCodeAt(n));) n++;
|
|
412
409
|
return n;
|
|
413
|
-
},
|
|
410
|
+
}, me = (e) => {
|
|
414
411
|
let t = [], n = 0;
|
|
415
412
|
for (; n < e.length;) {
|
|
416
413
|
let r = e[n];
|
|
417
414
|
if (r === ".") {
|
|
418
|
-
let r = n + 1, i =
|
|
415
|
+
let r = n + 1, i = J(e, r);
|
|
419
416
|
return i === r || i !== e.length ? void 0 : {
|
|
420
417
|
steps: t,
|
|
421
418
|
point: Number(e.slice(r, i))
|
|
@@ -423,9 +420,9 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
423
420
|
}
|
|
424
421
|
if (r !== "/") return;
|
|
425
422
|
let i = n + 1;
|
|
426
|
-
if (
|
|
427
|
-
let r =
|
|
428
|
-
if (!
|
|
423
|
+
if (K(e.charCodeAt(i))) {
|
|
424
|
+
let r = J(e, i);
|
|
425
|
+
if (!q(e[r])) return;
|
|
429
426
|
let a = Number(e.slice(i, r));
|
|
430
427
|
if (a < 1) return;
|
|
431
428
|
t.push({
|
|
@@ -442,15 +439,15 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
442
439
|
let t = e.indexOf("]", a + 1);
|
|
443
440
|
if (t === -1) return;
|
|
444
441
|
let n = e.slice(a + 1, t);
|
|
445
|
-
if (n.length === 0 ||
|
|
442
|
+
if (n.length === 0 || J(n, 0) !== n.length || (s = Number(n), s < 1)) return;
|
|
446
443
|
c = t + 1;
|
|
447
444
|
}
|
|
448
|
-
if (!
|
|
445
|
+
if (!q(e[c])) return;
|
|
449
446
|
if (o === "text()") t.push({
|
|
450
447
|
kind: "text",
|
|
451
448
|
index: s
|
|
452
449
|
});
|
|
453
|
-
else if (
|
|
450
|
+
else if (pe.test(o)) t.push({
|
|
454
451
|
kind: "element",
|
|
455
452
|
name: o,
|
|
456
453
|
index: s
|
|
@@ -462,11 +459,11 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
462
459
|
steps: t,
|
|
463
460
|
point: void 0
|
|
464
461
|
};
|
|
465
|
-
},
|
|
466
|
-
let t =
|
|
462
|
+
}, Y = (e, t) => e?.kind === "element" && e.name.toLowerCase() === t, X = (e) => {
|
|
463
|
+
let t = me(e);
|
|
467
464
|
if (!t) return;
|
|
468
465
|
let [n, r, i, ...a] = t.steps;
|
|
469
|
-
if (!
|
|
466
|
+
if (!Y(n, "body") || (n.index ?? 1) !== 1 || !Y(r, "docfragment")) return;
|
|
470
467
|
let o = (r.index ?? 1) - 1;
|
|
471
468
|
if (i === void 0) return {
|
|
472
469
|
spineItemIndex: o,
|
|
@@ -474,16 +471,16 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
474
471
|
point: void 0,
|
|
475
472
|
containsBoxingElements: !1
|
|
476
473
|
};
|
|
477
|
-
if (
|
|
474
|
+
if (Y(i, "body") && (i.index ?? 1) === 1) return {
|
|
478
475
|
spineItemIndex: o,
|
|
479
476
|
steps: a,
|
|
480
477
|
point: t.point,
|
|
481
|
-
containsBoxingElements: a.some((e) => e.kind === "element" &&
|
|
478
|
+
containsBoxingElements: a.some((e) => e.kind === "element" && fe.has(e.name.toLowerCase()))
|
|
482
479
|
};
|
|
483
|
-
},
|
|
480
|
+
}, he = (e, t) => {
|
|
484
481
|
let n = t.index ?? 1, r = t.kind === "element" ? t.name.toLowerCase() : void 0, i = 0, a;
|
|
485
|
-
return
|
|
486
|
-
},
|
|
482
|
+
return F(e, (e) => t.kind === "nodeIndex" || (t.kind === "text" ? e.kind === "text" : e.kind === "element" && e.node.localName.toLowerCase() === r) ? (i++, i !== n || (a = e, !1)) : !0), a;
|
|
483
|
+
}, Z = (e, t, n) => {
|
|
487
484
|
let r = t[n]?.child;
|
|
488
485
|
return r ? r.kind === "text" && r.pieceIndex > 0 ? {
|
|
489
486
|
node: r.node,
|
|
@@ -496,9 +493,9 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
496
493
|
offset: e.childNodes.length
|
|
497
494
|
};
|
|
498
495
|
}, Q = (e, t) => {
|
|
499
|
-
let n = typeof e == "string" ?
|
|
496
|
+
let n = typeof e == "string" ? X(e) : e;
|
|
500
497
|
if (!n || n.containsBoxingElements) return;
|
|
501
|
-
let r =
|
|
498
|
+
let r = L(t);
|
|
502
499
|
if (!r) return n.steps.length === 0 ? { node: t.documentElement } : void 0;
|
|
503
500
|
let i = {
|
|
504
501
|
kind: "parent",
|
|
@@ -506,7 +503,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
506
503
|
};
|
|
507
504
|
for (let e of n.steps) {
|
|
508
505
|
if (i.kind === "text") return;
|
|
509
|
-
let t =
|
|
506
|
+
let t = he(i.node, e);
|
|
510
507
|
if (!t) return;
|
|
511
508
|
i = t.kind === "element" ? {
|
|
512
509
|
kind: "parent",
|
|
@@ -518,7 +515,7 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
518
515
|
node: i.node,
|
|
519
516
|
offset: i.start
|
|
520
517
|
};
|
|
521
|
-
let e =
|
|
518
|
+
let e = ae(i.node.data.slice(i.start, i.end), n.point, i.mode);
|
|
522
519
|
return e === void 0 ? void 0 : {
|
|
523
520
|
node: i.node,
|
|
524
521
|
offset: i.start + e
|
|
@@ -526,24 +523,24 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
526
523
|
}
|
|
527
524
|
let a = i.node;
|
|
528
525
|
if (n.point === void 0) return { node: a };
|
|
529
|
-
let o =
|
|
530
|
-
if (!(n.point > o.length)) return
|
|
526
|
+
let o = I(a);
|
|
527
|
+
if (!(n.point > o.length)) return Z(a, o, n.point);
|
|
531
528
|
}, $ = (e) => {
|
|
532
529
|
let { node: t, offset: n } = e;
|
|
533
|
-
if (!
|
|
530
|
+
if (!g(t) || n === void 0) return e;
|
|
534
531
|
let r = t.childNodes[n];
|
|
535
|
-
if (r) return
|
|
532
|
+
if (r) return A(r) ? {
|
|
536
533
|
node: r,
|
|
537
534
|
offset: 0
|
|
538
535
|
} : { node: r };
|
|
539
536
|
let i = t.lastChild;
|
|
540
|
-
return i &&
|
|
537
|
+
return i && A(i) ? {
|
|
541
538
|
node: i,
|
|
542
539
|
offset: i.data.length
|
|
543
540
|
} : { node: t };
|
|
544
|
-
},
|
|
541
|
+
}, ge = (t, n) => {
|
|
545
542
|
try {
|
|
546
|
-
let r = typeof t == "string" ?
|
|
543
|
+
let r = typeof t == "string" ? X(t) : t;
|
|
547
544
|
if (!r) return;
|
|
548
545
|
let i = n(r.spineItemIndex);
|
|
549
546
|
if (!i) return;
|
|
@@ -552,21 +549,21 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
552
549
|
let { node: o, offset: s } = $(a);
|
|
553
550
|
return e({
|
|
554
551
|
node: o,
|
|
555
|
-
offset:
|
|
552
|
+
offset: A(o) ? s : void 0,
|
|
556
553
|
spineIndex: r.spineItemIndex,
|
|
557
554
|
spineId: i.id
|
|
558
555
|
});
|
|
559
556
|
} catch {
|
|
560
557
|
return;
|
|
561
558
|
}
|
|
562
|
-
},
|
|
559
|
+
}, _e = (e) => Array.isArray(e) ? e[0] : e, ve = (e, a) => {
|
|
563
560
|
try {
|
|
564
561
|
let o = t(e);
|
|
565
562
|
if (!o) return;
|
|
566
563
|
let { spineIndex: s } = o;
|
|
567
564
|
if (!Number.isInteger(s) || s < 0) return;
|
|
568
565
|
let c = r(e);
|
|
569
|
-
if (n(c)) return
|
|
566
|
+
if (n(c)) return R({
|
|
570
567
|
spineItemIndex: s,
|
|
571
568
|
steps: [],
|
|
572
569
|
point: void 0,
|
|
@@ -575,18 +572,34 @@ var a = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.annotation.applet.artic
|
|
|
575
572
|
let l = a(s);
|
|
576
573
|
if (!l) return;
|
|
577
574
|
let u = i(c, l.document);
|
|
578
|
-
return u.node ?
|
|
575
|
+
return u.node ? W(u.isRange ? {
|
|
579
576
|
node: u.node.startContainer,
|
|
580
577
|
offset: u.node.startOffset
|
|
581
578
|
} : {
|
|
582
579
|
node: u.node,
|
|
583
|
-
offset:
|
|
580
|
+
offset: A(u.node) ? _e(u.offset) ?? 0 : void 0
|
|
584
581
|
}, s) : void 0;
|
|
585
582
|
} catch {
|
|
586
583
|
return;
|
|
587
584
|
}
|
|
588
|
-
}
|
|
585
|
+
}, ye = 1024, be = [
|
|
586
|
+
0,
|
|
587
|
+
1024,
|
|
588
|
+
4096,
|
|
589
|
+
16384,
|
|
590
|
+
65536,
|
|
591
|
+
262144,
|
|
592
|
+
1048576,
|
|
593
|
+
4194304,
|
|
594
|
+
16777216,
|
|
595
|
+
67108864,
|
|
596
|
+
268435456,
|
|
597
|
+
1073741824
|
|
598
|
+
], xe = async (e) => {
|
|
599
|
+
let t = await Promise.all(be.filter((t) => t < e.size).map(async (t) => new Uint8Array(await e.slice(t, t + ye).arrayBuffer())));
|
|
600
|
+
return a(t);
|
|
601
|
+
}, Se = (e) => a([new TextEncoder().encode(e)]);
|
|
589
602
|
//#endregion
|
|
590
|
-
export {
|
|
603
|
+
export { re as CRENGINE_TEXT_SPLIT_SIZE, G as XPOINTER_BOXING_ELEMENT_NAMES, ve as cfiToXPointer, W as generateXPointer, xe as getKoreaderFileDigest, Se as getKoreaderFileNameDigest, X as parseXPointer, Q as resolveXPointer, R as serializeXPointer, $ as toCfiPosition, ge as xPointerToCfi };
|
|
591
604
|
|
|
592
605
|
//# sourceMappingURL=index.js.map
|