@embedpdf-editor/vue3-chapter-viewer 1.0.7-beta.1 → 1.0.7-beta.2
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +508 -447
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -42,16 +42,16 @@ function Me$1(e14) {
|
|
|
42
42
|
function xe$1(e14, t2, s2, n2, r9) {
|
|
43
43
|
const a2 = s2.forDocument(e14), i2 = n2.forDocument(e14);
|
|
44
44
|
if (!a2 || !i2) return false;
|
|
45
|
-
const o2 = "highlight" === t2 ? "highlight" : "underline" === t2 ? "underline" : "squiggly" === t2 ? "squiggly" : "strikeout",
|
|
46
|
-
if (!
|
|
47
|
-
const h2 =
|
|
45
|
+
const o2 = "highlight" === t2 ? "highlight" : "underline" === t2 ? "underline" : "squiggly" === t2 ? "squiggly" : "strikeout", l = s2.getTool(o2);
|
|
46
|
+
if (!l) return false;
|
|
47
|
+
const h2 = l.defaults, d2 = (function(e15, t3) {
|
|
48
48
|
return { ...ye$1[e15], ...null == t3 ? void 0 : t3[e15] };
|
|
49
49
|
})(t2, r9), c2 = i2.getFormattedSelection();
|
|
50
50
|
if (0 === c2.length) return false;
|
|
51
51
|
a2.setLocked({ type: LockModeType.Exclude, categories: ["markup", "shape"] });
|
|
52
52
|
for (const u2 of c2) {
|
|
53
|
-
const e15 = uuidV4(), s3 = d2.color ?? h2.color ?? h2.strokeColor, n3 = d2.opacity ?? h2.opacity, r10 = d2.thickness ?? h2.strokeWidth, i3 = d2.offsetY ?? 0, o3 = "underline" === t2 || "squiggly" === t2 || "strikeout" === t2 ? we$1(u2.segmentRects, i3) : u2.segmentRects,
|
|
54
|
-
a2.createAnnotation(u2.pageIndex, { id: e15, created: /* @__PURE__ */ new Date(), flags: ["print"], type: Se$1[t2], ..."highlight" === t2 ? { blendMode: PdfBlendMode.Multiply } : {}, strokeColor: s3, opacity: n3, ...null != r10 ? { strokeWidth: r10 } : {}, pageIndex: u2.pageIndex, rect:
|
|
53
|
+
const e15 = uuidV4(), s3 = d2.color ?? h2.color ?? h2.strokeColor, n3 = d2.opacity ?? h2.opacity, r10 = d2.thickness ?? h2.strokeWidth, i3 = d2.offsetY ?? 0, o3 = "underline" === t2 || "squiggly" === t2 || "strikeout" === t2 ? we$1(u2.segmentRects, i3) : u2.segmentRects, l2 = "underline" === t2 || "squiggly" === t2 || "strikeout" === t2 ? Me$1(o3) : u2.rect;
|
|
54
|
+
a2.createAnnotation(u2.pageIndex, { id: e15, created: /* @__PURE__ */ new Date(), flags: ["print"], type: Se$1[t2], ..."highlight" === t2 ? { blendMode: PdfBlendMode.Multiply } : {}, strokeColor: s3, opacity: n3, ...null != r10 ? { strokeWidth: r10 } : {}, pageIndex: u2.pageIndex, rect: l2, segmentRects: o3 });
|
|
55
55
|
}
|
|
56
56
|
return i2.clear(), true;
|
|
57
57
|
}
|
|
@@ -162,7 +162,7 @@ function Ye$1(e14) {
|
|
|
162
162
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
163
163
|
const o2 = Ke$1(a2, s2);
|
|
164
164
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
165
|
-
for (let
|
|
165
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
166
166
|
return n2;
|
|
167
167
|
}
|
|
168
168
|
const Qe$1 = { kind: "first-wins" };
|
|
@@ -238,7 +238,7 @@ function tt$1(e14, t2 = Qe$1) {
|
|
|
238
238
|
for (const o2 of r9) {
|
|
239
239
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
240
240
|
if (!t3) continue;
|
|
241
|
-
const [r10] = t3.globalPageRange, [
|
|
241
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
242
242
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
243
243
|
}
|
|
244
244
|
return new et$1(a2);
|
|
@@ -425,19 +425,19 @@ const nt$1 = class e extends BasePlugin {
|
|
|
425
425
|
});
|
|
426
426
|
}
|
|
427
427
|
if (0 === a2.size) return;
|
|
428
|
-
const
|
|
428
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
429
429
|
let h2 = 0;
|
|
430
430
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
431
431
|
if (d2) {
|
|
432
|
-
const e15 =
|
|
432
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
433
433
|
e15 >= 0 && (h2 = e15);
|
|
434
434
|
}
|
|
435
435
|
for (const c2 of a2) {
|
|
436
436
|
this.chapterLastUsed.set(c2, s2);
|
|
437
|
-
const e15 =
|
|
437
|
+
const e15 = l.indexOf(c2);
|
|
438
438
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
439
|
-
if (t3 < 0 || t3 >=
|
|
440
|
-
const e16 =
|
|
439
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
440
|
+
const e16 = l[t3];
|
|
441
441
|
this.chapterLastUsed.set(e16, s2);
|
|
442
442
|
const n3 = Math.abs(t3 - h2);
|
|
443
443
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -549,7 +549,11 @@ const nt$1 = class e extends BasePlugin {
|
|
|
549
549
|
const n3 = Ke$1(Ve$1(t2), a2);
|
|
550
550
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
551
551
|
const r10 = await this.resolveChapterUrls(t2);
|
|
552
|
-
|
|
552
|
+
if (r10.length !== n3) {
|
|
553
|
+
const [s3, i2] = t2.globalPageRange;
|
|
554
|
+
this.logger.warn(e.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
555
|
+
}
|
|
556
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
553
557
|
}
|
|
554
558
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
555
559
|
if (n2) {
|
|
@@ -573,12 +577,12 @@ const nt$1 = class e extends BasePlugin {
|
|
|
573
577
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
574
578
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
575
579
|
try {
|
|
576
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
580
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
577
581
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
578
582
|
});
|
|
579
583
|
return await new Promise((e15, t3) => {
|
|
580
584
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
581
|
-
}),
|
|
585
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
582
586
|
} catch (o2) {
|
|
583
587
|
const t3 = this.chapterStatus.get(r9);
|
|
584
588
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -612,8 +616,8 @@ const nt$1 = class e extends BasePlugin {
|
|
|
612
616
|
let o2 = null;
|
|
613
617
|
try {
|
|
614
618
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
615
|
-
} catch (
|
|
616
|
-
this.logger.error(e.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
619
|
+
} catch (l) {
|
|
620
|
+
this.logger.error(e.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
617
621
|
}
|
|
618
622
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
619
623
|
this.updateStatus(s2, "loading");
|
|
@@ -735,7 +739,7 @@ function Ct$1(e14) {
|
|
|
735
739
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
736
740
|
const o2 = vt$1(a2, s2);
|
|
737
741
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
738
|
-
for (let
|
|
742
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
739
743
|
return n2;
|
|
740
744
|
}
|
|
741
745
|
const yt$1 = { kind: "first-wins" };
|
|
@@ -811,7 +815,7 @@ function Mt$1(e14, t2 = yt$1) {
|
|
|
811
815
|
for (const o2 of r9) {
|
|
812
816
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
813
817
|
if (!t3) continue;
|
|
814
|
-
const [r10] = t3.globalPageRange, [
|
|
818
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
815
819
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
816
820
|
}
|
|
817
821
|
return new wt$1(a2);
|
|
@@ -998,19 +1002,19 @@ const Lt$1 = class e2 extends BasePlugin {
|
|
|
998
1002
|
});
|
|
999
1003
|
}
|
|
1000
1004
|
if (0 === a2.size) return;
|
|
1001
|
-
const
|
|
1005
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
1002
1006
|
let h2 = 0;
|
|
1003
1007
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
1004
1008
|
if (d2) {
|
|
1005
|
-
const e15 =
|
|
1009
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
1006
1010
|
e15 >= 0 && (h2 = e15);
|
|
1007
1011
|
}
|
|
1008
1012
|
for (const c2 of a2) {
|
|
1009
1013
|
this.chapterLastUsed.set(c2, s2);
|
|
1010
|
-
const e15 =
|
|
1014
|
+
const e15 = l.indexOf(c2);
|
|
1011
1015
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
1012
|
-
if (t3 < 0 || t3 >=
|
|
1013
|
-
const e16 =
|
|
1016
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
1017
|
+
const e16 = l[t3];
|
|
1014
1018
|
this.chapterLastUsed.set(e16, s2);
|
|
1015
1019
|
const n3 = Math.abs(t3 - h2);
|
|
1016
1020
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -1122,7 +1126,11 @@ const Lt$1 = class e2 extends BasePlugin {
|
|
|
1122
1126
|
const n3 = vt$1(ut(t2), a2);
|
|
1123
1127
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
1124
1128
|
const r10 = await this.resolveChapterUrls(t2);
|
|
1125
|
-
|
|
1129
|
+
if (r10.length !== n3) {
|
|
1130
|
+
const [s3, i2] = t2.globalPageRange;
|
|
1131
|
+
this.logger.warn(e2.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
1132
|
+
}
|
|
1133
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
1126
1134
|
}
|
|
1127
1135
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
1128
1136
|
if (n2) {
|
|
@@ -1146,12 +1154,12 @@ const Lt$1 = class e2 extends BasePlugin {
|
|
|
1146
1154
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
1147
1155
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
1148
1156
|
try {
|
|
1149
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
1157
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
1150
1158
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
1151
1159
|
});
|
|
1152
1160
|
return await new Promise((e15, t3) => {
|
|
1153
1161
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
1154
|
-
}),
|
|
1162
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
1155
1163
|
} catch (o2) {
|
|
1156
1164
|
const t3 = this.chapterStatus.get(r9);
|
|
1157
1165
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -1185,8 +1193,8 @@ const Lt$1 = class e2 extends BasePlugin {
|
|
|
1185
1193
|
let o2 = null;
|
|
1186
1194
|
try {
|
|
1187
1195
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
1188
|
-
} catch (
|
|
1189
|
-
this.logger.error(e2.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
1196
|
+
} catch (l) {
|
|
1197
|
+
this.logger.error(e2.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
1190
1198
|
}
|
|
1191
1199
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
1192
1200
|
this.updateStatus(s2, "loading");
|
|
@@ -1329,23 +1337,23 @@ const kt$1 = class kt extends BasePlugin {
|
|
|
1329
1337
|
if (!this.virtualPageMap) return;
|
|
1330
1338
|
const s2 = this.chapterManager.provides(), n2 = s2.getChapter(e14), r9 = this.virtualPageMap.pagesOfChapter(e14);
|
|
1331
1339
|
if (!n2 || 0 === r9.length) return;
|
|
1332
|
-
const a2 = ct(n2), i2 = this.documentManager.provides(), o2 = [],
|
|
1340
|
+
const a2 = ct(n2), i2 = this.documentManager.provides(), o2 = [], l = (e15, t3, s3, n3) => {
|
|
1333
1341
|
var r10;
|
|
1334
1342
|
const a3 = i2.getDocument(e15);
|
|
1335
1343
|
if (!(null == (r10 = null == a3 ? void 0 : a3.pages) ? void 0 : r10.length)) return false;
|
|
1336
|
-
const
|
|
1344
|
+
const l2 = this.getDocumentScale(e15);
|
|
1337
1345
|
for (let i3 = 0; i3 < n3; i3++) {
|
|
1338
1346
|
const e16 = a3.pages[s3 + i3];
|
|
1339
|
-
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width *
|
|
1347
|
+
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width * l2, height: e16.size.height * l2 });
|
|
1340
1348
|
}
|
|
1341
1349
|
return o2.length > 0;
|
|
1342
1350
|
};
|
|
1343
1351
|
if (a2) for (const h2 of a2.segments) {
|
|
1344
1352
|
if (!s2.isSegmentLoaded(e14, h2.index)) continue;
|
|
1345
1353
|
const t3 = h2.localPageEnd - h2.localPageStart + 1;
|
|
1346
|
-
|
|
1354
|
+
l(h2.documentId, h2.localPageStart, 0, t3);
|
|
1347
1355
|
}
|
|
1348
|
-
else s2.isSegmentLoaded(e14, 0) &&
|
|
1356
|
+
else s2.isSegmentLoaded(e14, 0) && l(e14, 0, 0, r9.length);
|
|
1349
1357
|
0 !== o2.length ? this.applyChapterPageSizes(e14, o2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
1350
1358
|
}
|
|
1351
1359
|
onScaleChanged(e14) {
|
|
@@ -1391,10 +1399,10 @@ const kt$1 = class kt extends BasePlugin {
|
|
|
1391
1399
|
}
|
|
1392
1400
|
const a2 = [];
|
|
1393
1401
|
let i2 = n2, o2 = -1;
|
|
1394
|
-
for (let
|
|
1395
|
-
a2.push(
|
|
1396
|
-
const e15 = this.offsets[
|
|
1397
|
-
r10 > o2 && (o2 = r10, i2 =
|
|
1402
|
+
for (let l = n2; l < r9; l++) {
|
|
1403
|
+
a2.push(l);
|
|
1404
|
+
const e15 = this.offsets[l], n3 = e15 + this.getPageSize(l).height, r10 = Math.max(0, Math.min(n3, s2) - Math.max(e15, t2));
|
|
1405
|
+
r10 > o2 && (o2 = r10, i2 = l);
|
|
1398
1406
|
}
|
|
1399
1407
|
this.currentVisible = a2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: i2 }), this.schedulePushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
1400
1408
|
}
|
|
@@ -1426,9 +1434,9 @@ const kt$1 = class kt extends BasePlugin {
|
|
|
1426
1434
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
1427
1435
|
const r9 = (null == s2 ? void 0 : s2.marginTop) ?? 80, a2 = this.virtualPageMap.atIndex(e14);
|
|
1428
1436
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
1429
|
-
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex),
|
|
1430
|
-
if (!i2 || !
|
|
1431
|
-
const h2 = i2.height /
|
|
1437
|
+
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), l = o2 ? null == (n2 = this.documentManager.provides().getDocument(o2.documentId)) ? void 0 : n2.pages[o2.pageIndex] : void 0;
|
|
1438
|
+
if (!i2 || !l) return void this.scrollToIndex(e14, s2);
|
|
1439
|
+
const h2 = i2.height / l.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * h2 - r9;
|
|
1432
1440
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
1433
1441
|
}
|
|
1434
1442
|
scrollToChapter(e14, t2) {
|
|
@@ -1450,18 +1458,18 @@ function Ot$1(e14) {
|
|
|
1450
1458
|
const [t2, s2] = e14.localPageRange;
|
|
1451
1459
|
return s2 - t2 + 1;
|
|
1452
1460
|
}
|
|
1453
|
-
function
|
|
1461
|
+
function Rt$1(e14) {
|
|
1454
1462
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
1455
1463
|
}
|
|
1456
|
-
function
|
|
1464
|
+
function At$1(e14) {
|
|
1457
1465
|
if (null != e14.segmentPageThreshold && e14.segmentPageThreshold > 0) return e14.segmentPageThreshold;
|
|
1458
1466
|
const t2 = e14.source;
|
|
1459
|
-
return
|
|
1467
|
+
return Rt$1(t2) ? t2.segmentPageThreshold : null;
|
|
1460
1468
|
}
|
|
1461
|
-
function
|
|
1469
|
+
function Nt$1(e14, t2) {
|
|
1462
1470
|
return `${e14}#s${t2}`;
|
|
1463
1471
|
}
|
|
1464
|
-
function
|
|
1472
|
+
function zt$1(e14) {
|
|
1465
1473
|
const t2 = e14.lastIndexOf("#s");
|
|
1466
1474
|
if (-1 === t2) return { chapterId: e14, segmentIndex: null };
|
|
1467
1475
|
const s2 = e14.slice(0, t2), n2 = Number.parseInt(e14.slice(t2 + 2), 10);
|
|
@@ -1471,13 +1479,13 @@ function _t$1(e14, t2) {
|
|
|
1471
1479
|
return e14 <= 0 || t2 <= 0 ? 0 : Math.ceil(e14 / t2);
|
|
1472
1480
|
}
|
|
1473
1481
|
function Gt$1(e14) {
|
|
1474
|
-
const t2 =
|
|
1482
|
+
const t2 = At$1(e14);
|
|
1475
1483
|
if (!t2) return null;
|
|
1476
|
-
const s2 = Ot$1(e14), n2 = _t$1(s2, t2), r9 =
|
|
1484
|
+
const s2 = Ot$1(e14), n2 = _t$1(s2, t2), r9 = Rt$1(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
1477
1485
|
for (let i2 = 0; i2 < n2; i2++) {
|
|
1478
1486
|
const n3 = i2 * t2, o2 = Math.min(n3 + t2 - 1, s2 - 1);
|
|
1479
1487
|
if (n3 >= s2) break;
|
|
1480
|
-
a2.push({ index: i2, url: (null == r9 ? void 0 : r9[i2]) ?? "", localPageStart: n3, localPageEnd: o2, documentId:
|
|
1488
|
+
a2.push({ index: i2, url: (null == r9 ? void 0 : r9[i2]) ?? "", localPageStart: n3, localPageEnd: o2, documentId: Nt$1(e14.chapterId, i2) });
|
|
1481
1489
|
}
|
|
1482
1490
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
1483
1491
|
}
|
|
@@ -1499,16 +1507,16 @@ function qt$1(e14, t2) {
|
|
|
1499
1507
|
}
|
|
1500
1508
|
function Ht$1(e14) {
|
|
1501
1509
|
var t2;
|
|
1502
|
-
const s2 =
|
|
1510
|
+
const s2 = At$1(e14);
|
|
1503
1511
|
if (!s2) return [];
|
|
1504
1512
|
const n2 = [], { chapterId: r9 } = e14, a2 = Ot$1(e14);
|
|
1505
1513
|
s2 <= 0 && n2.push(`${r9}: segmentPageThreshold must be > 0`);
|
|
1506
1514
|
const i2 = e14.source;
|
|
1507
|
-
if (!
|
|
1515
|
+
if (!Rt$1(i2)) return n2;
|
|
1508
1516
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
1509
1517
|
const o2 = _t$1(a2, s2);
|
|
1510
1518
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
1511
|
-
for (let
|
|
1519
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
1512
1520
|
return n2;
|
|
1513
1521
|
}
|
|
1514
1522
|
const Wt$1 = { kind: "first-wins" };
|
|
@@ -1584,7 +1592,7 @@ function jt$1(e14, t2 = Wt$1) {
|
|
|
1584
1592
|
for (const o2 of r9) {
|
|
1585
1593
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
1586
1594
|
if (!t3) continue;
|
|
1587
|
-
const [r10] = t3.globalPageRange, [
|
|
1595
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
1588
1596
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
1589
1597
|
}
|
|
1590
1598
|
return new Kt$1(a2);
|
|
@@ -1626,13 +1634,13 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1626
1634
|
}
|
|
1627
1635
|
async initialize(e14) {
|
|
1628
1636
|
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Wt$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
1629
|
-
const { chapterId: t2 } =
|
|
1637
|
+
const { chapterId: t2 } = zt$1(e15.id);
|
|
1630
1638
|
this.findChapter(t2) && (this.passwordAttempts.delete(t2), this.syncChapterStatusFromDocuments(t2));
|
|
1631
1639
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
1632
|
-
const { chapterId: t2 } =
|
|
1640
|
+
const { chapterId: t2 } = zt$1(e15);
|
|
1633
1641
|
this.findChapter(t2) && this.syncChapterStatusFromDocuments(t2);
|
|
1634
1642
|
}), this.documentManager.provides().onDocumentError((e15) => {
|
|
1635
|
-
const { chapterId: t2 } =
|
|
1643
|
+
const { chapterId: t2 } = zt$1(e15.documentId);
|
|
1636
1644
|
this.findChapter(t2) && this.handleDocumentError(e15.documentId, t2, e15.code, e15.message);
|
|
1637
1645
|
})), this.segmentScheduler = new Xt$1(e14.maxConcurrentSegmentLoads ?? 2, (e15, t2) => this.loadSegmentNow(e15, t2)), this.setManifestInternal(e14.manifest), e14.unloadTimeoutMs && e14.unloadTimeoutMs > 0) {
|
|
1638
1646
|
const t2 = Math.max(5e3, Math.floor(e14.unloadTimeoutMs / 4));
|
|
@@ -1771,19 +1779,19 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1771
1779
|
});
|
|
1772
1780
|
}
|
|
1773
1781
|
if (0 === a2.size) return;
|
|
1774
|
-
const
|
|
1782
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
1775
1783
|
let h2 = 0;
|
|
1776
1784
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
1777
1785
|
if (d2) {
|
|
1778
|
-
const e15 =
|
|
1786
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
1779
1787
|
e15 >= 0 && (h2 = e15);
|
|
1780
1788
|
}
|
|
1781
1789
|
for (const c2 of a2) {
|
|
1782
1790
|
this.chapterLastUsed.set(c2, s2);
|
|
1783
|
-
const e15 =
|
|
1791
|
+
const e15 = l.indexOf(c2);
|
|
1784
1792
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
1785
|
-
if (t3 < 0 || t3 >=
|
|
1786
|
-
const e16 =
|
|
1793
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
1794
|
+
const e16 = l[t3];
|
|
1787
1795
|
this.chapterLastUsed.set(e16, s2);
|
|
1788
1796
|
const n3 = Math.abs(t3 - h2);
|
|
1789
1797
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -1864,7 +1872,7 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1864
1872
|
if (n2) return n2;
|
|
1865
1873
|
const r9 = (async () => {
|
|
1866
1874
|
const s3 = e14.source;
|
|
1867
|
-
if (
|
|
1875
|
+
if (Rt$1(s3)) {
|
|
1868
1876
|
const e15 = [...s3.urls];
|
|
1869
1877
|
return this.chapterUrlsCache.set(t2, e15), e15;
|
|
1870
1878
|
}
|
|
@@ -1890,16 +1898,20 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1890
1898
|
return (null == r9 ? void 0 : r9.openPdf) ? r9.openPdf(a2) : { url: n2 };
|
|
1891
1899
|
}
|
|
1892
1900
|
async resolvePdfPayload(t2, s2) {
|
|
1893
|
-
const n2 = t2.source, r9 = this.config.chapterPdfLoader, a2 =
|
|
1901
|
+
const n2 = t2.source, r9 = this.config.chapterPdfLoader, a2 = At$1(t2);
|
|
1894
1902
|
if (a2) {
|
|
1895
1903
|
const n3 = _t$1(Ot$1(t2), a2);
|
|
1896
1904
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
1897
1905
|
const r10 = await this.resolveChapterUrls(t2);
|
|
1898
|
-
|
|
1906
|
+
if (r10.length !== n3) {
|
|
1907
|
+
const [s3, i2] = t2.globalPageRange;
|
|
1908
|
+
this.logger.warn(e3.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
1909
|
+
}
|
|
1910
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
1899
1911
|
}
|
|
1900
1912
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
1901
1913
|
if (n2) {
|
|
1902
|
-
if (
|
|
1914
|
+
if (Rt$1(n2)) {
|
|
1903
1915
|
const e14 = await this.resolveChapterUrls(t2);
|
|
1904
1916
|
return this.openPayloadFromUrl(t2, s2, e14);
|
|
1905
1917
|
}
|
|
@@ -1919,12 +1931,12 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1919
1931
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
1920
1932
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
1921
1933
|
try {
|
|
1922
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
1934
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
1923
1935
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
1924
1936
|
});
|
|
1925
1937
|
return await new Promise((e15, t3) => {
|
|
1926
1938
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
1927
|
-
}),
|
|
1939
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
1928
1940
|
} catch (o2) {
|
|
1929
1941
|
const t3 = this.chapterStatus.get(r9);
|
|
1930
1942
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -1947,7 +1959,7 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1947
1959
|
async handleDocumentError(t2, s2, n2, r9) {
|
|
1948
1960
|
if (this.pendingSegmentLoadPromises.has(t2)) return;
|
|
1949
1961
|
if (n2 !== PdfErrorCode.Password) {
|
|
1950
|
-
const e14 = this.getSegmentPlanForChapter(s2), { segmentIndex: n3 } =
|
|
1962
|
+
const e14 = this.getSegmentPlanForChapter(s2), { segmentIndex: n3 } = zt$1(t2);
|
|
1951
1963
|
return void (e14 && 0 !== n3 && null !== n3 || this.updateStatus(s2, "error"));
|
|
1952
1964
|
}
|
|
1953
1965
|
if (!this.passwordProvider) return void this.updateStatus(s2, "password-required");
|
|
@@ -1958,8 +1970,8 @@ const Zt$1 = class e3 extends BasePlugin {
|
|
|
1958
1970
|
let o2 = null;
|
|
1959
1971
|
try {
|
|
1960
1972
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
1961
|
-
} catch (
|
|
1962
|
-
this.logger.error(e3.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
1973
|
+
} catch (l) {
|
|
1974
|
+
this.logger.error(e3.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
1963
1975
|
}
|
|
1964
1976
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
1965
1977
|
this.updateStatus(s2, "loading");
|
|
@@ -2080,7 +2092,7 @@ function cs(e14) {
|
|
|
2080
2092
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
2081
2093
|
const o2 = os(a2, s2);
|
|
2082
2094
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
2083
|
-
for (let
|
|
2095
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
2084
2096
|
return n2;
|
|
2085
2097
|
}
|
|
2086
2098
|
const us = { kind: "first-wins" };
|
|
@@ -2156,7 +2168,7 @@ function ms$1(e14, t2 = us) {
|
|
|
2156
2168
|
for (const o2 of r9) {
|
|
2157
2169
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
2158
2170
|
if (!t3) continue;
|
|
2159
|
-
const [r10] = t3.globalPageRange, [
|
|
2171
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
2160
2172
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
2161
2173
|
}
|
|
2162
2174
|
return new gs$1(a2);
|
|
@@ -2343,19 +2355,19 @@ const vs = class e4 extends BasePlugin {
|
|
|
2343
2355
|
});
|
|
2344
2356
|
}
|
|
2345
2357
|
if (0 === a2.size) return;
|
|
2346
|
-
const
|
|
2358
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
2347
2359
|
let h2 = 0;
|
|
2348
2360
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
2349
2361
|
if (d2) {
|
|
2350
|
-
const e15 =
|
|
2362
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
2351
2363
|
e15 >= 0 && (h2 = e15);
|
|
2352
2364
|
}
|
|
2353
2365
|
for (const c2 of a2) {
|
|
2354
2366
|
this.chapterLastUsed.set(c2, s2);
|
|
2355
|
-
const e15 =
|
|
2367
|
+
const e15 = l.indexOf(c2);
|
|
2356
2368
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
2357
|
-
if (t3 < 0 || t3 >=
|
|
2358
|
-
const e16 =
|
|
2369
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
2370
|
+
const e16 = l[t3];
|
|
2359
2371
|
this.chapterLastUsed.set(e16, s2);
|
|
2360
2372
|
const n3 = Math.abs(t3 - h2);
|
|
2361
2373
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -2467,7 +2479,11 @@ const vs = class e4 extends BasePlugin {
|
|
|
2467
2479
|
const n3 = os(ss$1(t2), a2);
|
|
2468
2480
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
2469
2481
|
const r10 = await this.resolveChapterUrls(t2);
|
|
2470
|
-
|
|
2482
|
+
if (r10.length !== n3) {
|
|
2483
|
+
const [s3, i2] = t2.globalPageRange;
|
|
2484
|
+
this.logger.warn(e4.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
2485
|
+
}
|
|
2486
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
2471
2487
|
}
|
|
2472
2488
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
2473
2489
|
if (n2) {
|
|
@@ -2491,12 +2507,12 @@ const vs = class e4 extends BasePlugin {
|
|
|
2491
2507
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
2492
2508
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
2493
2509
|
try {
|
|
2494
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
2510
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
2495
2511
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
2496
2512
|
});
|
|
2497
2513
|
return await new Promise((e15, t3) => {
|
|
2498
2514
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
2499
|
-
}),
|
|
2515
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
2500
2516
|
} catch (o2) {
|
|
2501
2517
|
const t3 = this.chapterStatus.get(r9);
|
|
2502
2518
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -2530,8 +2546,8 @@ const vs = class e4 extends BasePlugin {
|
|
|
2530
2546
|
let o2 = null;
|
|
2531
2547
|
try {
|
|
2532
2548
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
2533
|
-
} catch (
|
|
2534
|
-
this.logger.error(e4.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
2549
|
+
} catch (l) {
|
|
2550
|
+
this.logger.error(e4.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
2535
2551
|
}
|
|
2536
2552
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
2537
2553
|
this.updateStatus(s2, "loading");
|
|
@@ -2674,23 +2690,23 @@ const bs$1 = class bs extends BasePlugin {
|
|
|
2674
2690
|
if (!this.virtualPageMap) return;
|
|
2675
2691
|
const s2 = this.chapterManager.provides(), n2 = s2.getChapter(e14), r9 = this.virtualPageMap.pagesOfChapter(e14);
|
|
2676
2692
|
if (!n2 || 0 === r9.length) return;
|
|
2677
|
-
const a2 = ts$1(n2), i2 = this.documentManager.provides(), o2 = [],
|
|
2693
|
+
const a2 = ts$1(n2), i2 = this.documentManager.provides(), o2 = [], l = (e15, t3, s3, n3) => {
|
|
2678
2694
|
var r10;
|
|
2679
2695
|
const a3 = i2.getDocument(e15);
|
|
2680
2696
|
if (!(null == (r10 = null == a3 ? void 0 : a3.pages) ? void 0 : r10.length)) return false;
|
|
2681
|
-
const
|
|
2697
|
+
const l2 = this.getDocumentScale(e15);
|
|
2682
2698
|
for (let i3 = 0; i3 < n3; i3++) {
|
|
2683
2699
|
const e16 = a3.pages[s3 + i3];
|
|
2684
|
-
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width *
|
|
2700
|
+
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width * l2, height: e16.size.height * l2 });
|
|
2685
2701
|
}
|
|
2686
2702
|
return o2.length > 0;
|
|
2687
2703
|
};
|
|
2688
2704
|
if (a2) for (const h2 of a2.segments) {
|
|
2689
2705
|
if (!s2.isSegmentLoaded(e14, h2.index)) continue;
|
|
2690
2706
|
const t3 = h2.localPageEnd - h2.localPageStart + 1;
|
|
2691
|
-
|
|
2707
|
+
l(h2.documentId, h2.localPageStart, 0, t3);
|
|
2692
2708
|
}
|
|
2693
|
-
else s2.isSegmentLoaded(e14, 0) &&
|
|
2709
|
+
else s2.isSegmentLoaded(e14, 0) && l(e14, 0, 0, r9.length);
|
|
2694
2710
|
0 !== o2.length ? this.applyChapterPageSizes(e14, o2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
2695
2711
|
}
|
|
2696
2712
|
onScaleChanged(e14) {
|
|
@@ -2736,10 +2752,10 @@ const bs$1 = class bs extends BasePlugin {
|
|
|
2736
2752
|
}
|
|
2737
2753
|
const a2 = [];
|
|
2738
2754
|
let i2 = n2, o2 = -1;
|
|
2739
|
-
for (let
|
|
2740
|
-
a2.push(
|
|
2741
|
-
const e15 = this.offsets[
|
|
2742
|
-
r10 > o2 && (o2 = r10, i2 =
|
|
2755
|
+
for (let l = n2; l < r9; l++) {
|
|
2756
|
+
a2.push(l);
|
|
2757
|
+
const e15 = this.offsets[l], n3 = e15 + this.getPageSize(l).height, r10 = Math.max(0, Math.min(n3, s2) - Math.max(e15, t2));
|
|
2758
|
+
r10 > o2 && (o2 = r10, i2 = l);
|
|
2743
2759
|
}
|
|
2744
2760
|
this.currentVisible = a2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: i2 }), this.schedulePushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
2745
2761
|
}
|
|
@@ -2771,9 +2787,9 @@ const bs$1 = class bs extends BasePlugin {
|
|
|
2771
2787
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
2772
2788
|
const r9 = (null == s2 ? void 0 : s2.marginTop) ?? 80, a2 = this.virtualPageMap.atIndex(e14);
|
|
2773
2789
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
2774
|
-
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex),
|
|
2775
|
-
if (!i2 || !
|
|
2776
|
-
const h2 = i2.height /
|
|
2790
|
+
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), l = o2 ? null == (n2 = this.documentManager.provides().getDocument(o2.documentId)) ? void 0 : n2.pages[o2.pageIndex] : void 0;
|
|
2791
|
+
if (!i2 || !l) return void this.scrollToIndex(e14, s2);
|
|
2792
|
+
const h2 = i2.height / l.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * h2 - r9;
|
|
2777
2793
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
2778
2794
|
}
|
|
2779
2795
|
scrollToChapter(e14, t2) {
|
|
@@ -2949,13 +2965,13 @@ function Os$1(e14, t2) {
|
|
|
2949
2965
|
}
|
|
2950
2966
|
return { documentId: n2.documentId, pageIndex: t2 - n2.localPageStart };
|
|
2951
2967
|
}
|
|
2952
|
-
function
|
|
2968
|
+
function Rs$1(e14, t2) {
|
|
2953
2969
|
const s2 = Us$1(e14);
|
|
2954
2970
|
if (!s2) return 0;
|
|
2955
2971
|
const n2 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
2956
2972
|
return (null == n2 ? void 0 : n2.index) ?? Math.floor(t2 / s2.threshold);
|
|
2957
2973
|
}
|
|
2958
|
-
function
|
|
2974
|
+
function As$1(e14) {
|
|
2959
2975
|
var t2;
|
|
2960
2976
|
const s2 = ks$1(e14);
|
|
2961
2977
|
if (!s2) return [];
|
|
@@ -2966,11 +2982,11 @@ function Ns$1(e14) {
|
|
|
2966
2982
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
2967
2983
|
const o2 = Fs$1(a2, s2);
|
|
2968
2984
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
2969
|
-
for (let
|
|
2985
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
2970
2986
|
return n2;
|
|
2971
2987
|
}
|
|
2972
|
-
const
|
|
2973
|
-
function
|
|
2988
|
+
const Ns$1 = { kind: "first-wins" };
|
|
2989
|
+
function zs$1(e14, t2, s2) {
|
|
2974
2990
|
if (1 === t2.length) return t2[0].chapterId;
|
|
2975
2991
|
switch (s2.kind) {
|
|
2976
2992
|
case "first-wins":
|
|
@@ -3022,8 +3038,8 @@ let _s$1 = class _s {
|
|
|
3022
3038
|
return s2 ? this._pages.indexOf(s2) : -1;
|
|
3023
3039
|
}
|
|
3024
3040
|
};
|
|
3025
|
-
function Gs$1(e14, t2 =
|
|
3026
|
-
const s2 = (function(e15, t3 =
|
|
3041
|
+
function Gs$1(e14, t2 = Ns$1) {
|
|
3042
|
+
const s2 = (function(e15, t3 = Ns$1) {
|
|
3027
3043
|
const s3 = /* @__PURE__ */ new Map();
|
|
3028
3044
|
for (const r10 of e15.chapters) {
|
|
3029
3045
|
const [e16, t4] = r10.globalPageRange;
|
|
@@ -3033,7 +3049,7 @@ function Gs$1(e14, t2 = zs$1) {
|
|
|
3033
3049
|
}
|
|
3034
3050
|
}
|
|
3035
3051
|
const n3 = /* @__PURE__ */ new Map();
|
|
3036
|
-
for (const [r10, a3] of s3) n3.set(r10,
|
|
3052
|
+
for (const [r10, a3] of s3) n3.set(r10, zs$1(r10, a3, t3));
|
|
3037
3053
|
return n3;
|
|
3038
3054
|
})(e14, t2), n2 = /* @__PURE__ */ new Map();
|
|
3039
3055
|
for (const o2 of e14.chapters) n2.set(o2.chapterId, o2);
|
|
@@ -3042,7 +3058,7 @@ function Gs$1(e14, t2 = zs$1) {
|
|
|
3042
3058
|
for (const o2 of r9) {
|
|
3043
3059
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
3044
3060
|
if (!t3) continue;
|
|
3045
|
-
const [r10] = t3.globalPageRange, [
|
|
3061
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
3046
3062
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
3047
3063
|
}
|
|
3048
3064
|
return new _s$1(a2);
|
|
@@ -3080,10 +3096,10 @@ let Vs$1 = class Vs {
|
|
|
3080
3096
|
};
|
|
3081
3097
|
const qs$1 = class e6 extends BasePlugin {
|
|
3082
3098
|
constructor(e14, t2) {
|
|
3083
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
3099
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Ns$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterErrorMessages = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingChapterLoadPromises = /* @__PURE__ */ new Map(), this.pendingSegmentLoadPromises = /* @__PURE__ */ new Map(), this.chapterUrlsCache = /* @__PURE__ */ new Map(), this.pendingChapterUrlsPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.SEG_PRIO_PREFETCH_NEXT = 120, this.SEG_PRIO_CHAPTER_PREFETCH_BASE = 3e3, this.lastVisibleIndicesKey = "", this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
3084
3100
|
}
|
|
3085
3101
|
async initialize(e14) {
|
|
3086
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
3102
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Ns$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
3087
3103
|
const { chapterId: t2 } = Ts(e15.id);
|
|
3088
3104
|
this.findChapter(t2) && (this.passwordAttempts.delete(t2), this.syncChapterStatusFromDocuments(t2));
|
|
3089
3105
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
@@ -3139,7 +3155,7 @@ const qs$1 = class e6 extends BasePlugin {
|
|
|
3139
3155
|
s3.has(n3.chapterId) && t3.push(`Duplicate chapterId: ${n3.chapterId}`), s3.add(n3.chapterId);
|
|
3140
3156
|
const [e15, r10] = n3.globalPageRange, [a3, i3] = n3.localPageRange;
|
|
3141
3157
|
if (e15 > r10 && t3.push(`${n3.chapterId}: invalid globalPageRange [${e15},${r10}]`), a3 > i3 && t3.push(`${n3.chapterId}: invalid localPageRange [${a3},${i3}]`), r10 - e15 !== i3 - a3 && t3.push(`${n3.chapterId}: page-count mismatch (global ${r10 - e15 + 1} vs local ${i3 - a3 + 1})`), n3.ownedGlobalPages) for (const s4 of n3.ownedGlobalPages) (s4 < e15 || s4 > r10) && t3.push(`${n3.chapterId}: ownedGlobalPages contains ${s4} outside range`);
|
|
3142
|
-
t3.push(...
|
|
3158
|
+
t3.push(...As$1(n3));
|
|
3143
3159
|
}
|
|
3144
3160
|
return t3;
|
|
3145
3161
|
})(n2);
|
|
@@ -3224,24 +3240,24 @@ const qs$1 = class e6 extends BasePlugin {
|
|
|
3224
3240
|
a2.add(e15.chapterId);
|
|
3225
3241
|
const t3 = this.findChapter(e15.chapterId);
|
|
3226
3242
|
if (!t3) continue;
|
|
3227
|
-
const s3 = Math.abs(c2 - r9), n3 =
|
|
3243
|
+
const s3 = Math.abs(c2 - r9), n3 = Rs$1(t3, e15.localPageIndex);
|
|
3228
3244
|
o2(e15.chapterId, n3, s3), o2(e15.chapterId, n3 + 1, s3 + this.SEG_PRIO_PREFETCH_NEXT), this.resolveChapterUrls(t3).catch(() => {
|
|
3229
3245
|
});
|
|
3230
3246
|
}
|
|
3231
3247
|
if (0 === a2.size) return;
|
|
3232
|
-
const
|
|
3248
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
3233
3249
|
let h2 = 0;
|
|
3234
3250
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
3235
3251
|
if (d2) {
|
|
3236
|
-
const e15 =
|
|
3252
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
3237
3253
|
e15 >= 0 && (h2 = e15);
|
|
3238
3254
|
}
|
|
3239
3255
|
for (const c2 of a2) {
|
|
3240
3256
|
this.chapterLastUsed.set(c2, s2);
|
|
3241
|
-
const e15 =
|
|
3257
|
+
const e15 = l.indexOf(c2);
|
|
3242
3258
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
3243
|
-
if (t3 < 0 || t3 >=
|
|
3244
|
-
const e16 =
|
|
3259
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
3260
|
+
const e16 = l[t3];
|
|
3245
3261
|
this.chapterLastUsed.set(e16, s2);
|
|
3246
3262
|
const n3 = Math.abs(t3 - h2);
|
|
3247
3263
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -3353,7 +3369,11 @@ const qs$1 = class e6 extends BasePlugin {
|
|
|
3353
3369
|
const n3 = Fs$1($s(t2), a2);
|
|
3354
3370
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
3355
3371
|
const r10 = await this.resolveChapterUrls(t2);
|
|
3356
|
-
|
|
3372
|
+
if (r10.length !== n3) {
|
|
3373
|
+
const [s3, i2] = t2.globalPageRange;
|
|
3374
|
+
this.logger.warn(e6.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
3375
|
+
}
|
|
3376
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
3357
3377
|
}
|
|
3358
3378
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
3359
3379
|
if (n2) {
|
|
@@ -3377,12 +3397,12 @@ const qs$1 = class e6 extends BasePlugin {
|
|
|
3377
3397
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
3378
3398
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
3379
3399
|
try {
|
|
3380
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
3400
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
3381
3401
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
3382
3402
|
});
|
|
3383
3403
|
return await new Promise((e15, t3) => {
|
|
3384
3404
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
3385
|
-
}),
|
|
3405
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
3386
3406
|
} catch (o2) {
|
|
3387
3407
|
const t3 = this.chapterStatus.get(r9);
|
|
3388
3408
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -3416,8 +3436,8 @@ const qs$1 = class e6 extends BasePlugin {
|
|
|
3416
3436
|
let o2 = null;
|
|
3417
3437
|
try {
|
|
3418
3438
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
3419
|
-
} catch (
|
|
3420
|
-
this.logger.error(e6.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
3439
|
+
} catch (l) {
|
|
3440
|
+
this.logger.error(e6.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
3421
3441
|
}
|
|
3422
3442
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
3423
3443
|
this.updateStatus(s2, "loading");
|
|
@@ -3538,7 +3558,7 @@ function rn(e14) {
|
|
|
3538
3558
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
3539
3559
|
const o2 = en(a2, s2);
|
|
3540
3560
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
3541
|
-
for (let
|
|
3561
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
3542
3562
|
return n2;
|
|
3543
3563
|
}
|
|
3544
3564
|
const an = { kind: "first-wins" };
|
|
@@ -3614,7 +3634,7 @@ function hn(e14, t2 = an) {
|
|
|
3614
3634
|
for (const o2 of r9) {
|
|
3615
3635
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
3616
3636
|
if (!t3) continue;
|
|
3617
|
-
const [r10] = t3.globalPageRange, [
|
|
3637
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
3618
3638
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
3619
3639
|
}
|
|
3620
3640
|
return new ln(a2);
|
|
@@ -3801,19 +3821,19 @@ const cn = class e7 extends BasePlugin {
|
|
|
3801
3821
|
});
|
|
3802
3822
|
}
|
|
3803
3823
|
if (0 === a2.size) return;
|
|
3804
|
-
const
|
|
3824
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
3805
3825
|
let h2 = 0;
|
|
3806
3826
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
3807
3827
|
if (d2) {
|
|
3808
|
-
const e15 =
|
|
3828
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
3809
3829
|
e15 >= 0 && (h2 = e15);
|
|
3810
3830
|
}
|
|
3811
3831
|
for (const c2 of a2) {
|
|
3812
3832
|
this.chapterLastUsed.set(c2, s2);
|
|
3813
|
-
const e15 =
|
|
3833
|
+
const e15 = l.indexOf(c2);
|
|
3814
3834
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
3815
|
-
if (t3 < 0 || t3 >=
|
|
3816
|
-
const e16 =
|
|
3835
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
3836
|
+
const e16 = l[t3];
|
|
3817
3837
|
this.chapterLastUsed.set(e16, s2);
|
|
3818
3838
|
const n3 = Math.abs(t3 - h2);
|
|
3819
3839
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -3925,7 +3945,11 @@ const cn = class e7 extends BasePlugin {
|
|
|
3925
3945
|
const n3 = en(Xs$1(t2), a2);
|
|
3926
3946
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
3927
3947
|
const r10 = await this.resolveChapterUrls(t2);
|
|
3928
|
-
|
|
3948
|
+
if (r10.length !== n3) {
|
|
3949
|
+
const [s3, i2] = t2.globalPageRange;
|
|
3950
|
+
this.logger.warn(e7.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
3951
|
+
}
|
|
3952
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
3929
3953
|
}
|
|
3930
3954
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
3931
3955
|
if (n2) {
|
|
@@ -3949,12 +3973,12 @@ const cn = class e7 extends BasePlugin {
|
|
|
3949
3973
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
3950
3974
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
3951
3975
|
try {
|
|
3952
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
3976
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
3953
3977
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
3954
3978
|
});
|
|
3955
3979
|
return await new Promise((e15, t3) => {
|
|
3956
3980
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
3957
|
-
}),
|
|
3981
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
3958
3982
|
} catch (o2) {
|
|
3959
3983
|
const t3 = this.chapterStatus.get(r9);
|
|
3960
3984
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -3988,8 +4012,8 @@ const cn = class e7 extends BasePlugin {
|
|
|
3988
4012
|
let o2 = null;
|
|
3989
4013
|
try {
|
|
3990
4014
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
3991
|
-
} catch (
|
|
3992
|
-
this.logger.error(e7.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
4015
|
+
} catch (l) {
|
|
4016
|
+
this.logger.error(e7.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
3993
4017
|
}
|
|
3994
4018
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
3995
4019
|
this.updateStatus(s2, "loading");
|
|
@@ -4132,23 +4156,23 @@ const gn = class extends BasePlugin {
|
|
|
4132
4156
|
if (!this.virtualPageMap) return;
|
|
4133
4157
|
const s2 = this.chapterManager.provides(), n2 = s2.getChapter(e14), r9 = this.virtualPageMap.pagesOfChapter(e14);
|
|
4134
4158
|
if (!n2 || 0 === r9.length) return;
|
|
4135
|
-
const a2 = js$1(n2), i2 = this.documentManager.provides(), o2 = [],
|
|
4159
|
+
const a2 = js$1(n2), i2 = this.documentManager.provides(), o2 = [], l = (e15, t3, s3, n3) => {
|
|
4136
4160
|
var r10;
|
|
4137
4161
|
const a3 = i2.getDocument(e15);
|
|
4138
4162
|
if (!(null == (r10 = null == a3 ? void 0 : a3.pages) ? void 0 : r10.length)) return false;
|
|
4139
|
-
const
|
|
4163
|
+
const l2 = this.getDocumentScale(e15);
|
|
4140
4164
|
for (let i3 = 0; i3 < n3; i3++) {
|
|
4141
4165
|
const e16 = a3.pages[s3 + i3];
|
|
4142
|
-
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width *
|
|
4166
|
+
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width * l2, height: e16.size.height * l2 });
|
|
4143
4167
|
}
|
|
4144
4168
|
return o2.length > 0;
|
|
4145
4169
|
};
|
|
4146
4170
|
if (a2) for (const h2 of a2.segments) {
|
|
4147
4171
|
if (!s2.isSegmentLoaded(e14, h2.index)) continue;
|
|
4148
4172
|
const t3 = h2.localPageEnd - h2.localPageStart + 1;
|
|
4149
|
-
|
|
4173
|
+
l(h2.documentId, h2.localPageStart, 0, t3);
|
|
4150
4174
|
}
|
|
4151
|
-
else s2.isSegmentLoaded(e14, 0) &&
|
|
4175
|
+
else s2.isSegmentLoaded(e14, 0) && l(e14, 0, 0, r9.length);
|
|
4152
4176
|
0 !== o2.length ? this.applyChapterPageSizes(e14, o2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
4153
4177
|
}
|
|
4154
4178
|
onScaleChanged(e14) {
|
|
@@ -4194,10 +4218,10 @@ const gn = class extends BasePlugin {
|
|
|
4194
4218
|
}
|
|
4195
4219
|
const a2 = [];
|
|
4196
4220
|
let i2 = n2, o2 = -1;
|
|
4197
|
-
for (let
|
|
4198
|
-
a2.push(
|
|
4199
|
-
const e15 = this.offsets[
|
|
4200
|
-
r10 > o2 && (o2 = r10, i2 =
|
|
4221
|
+
for (let l = n2; l < r9; l++) {
|
|
4222
|
+
a2.push(l);
|
|
4223
|
+
const e15 = this.offsets[l], n3 = e15 + this.getPageSize(l).height, r10 = Math.max(0, Math.min(n3, s2) - Math.max(e15, t2));
|
|
4224
|
+
r10 > o2 && (o2 = r10, i2 = l);
|
|
4201
4225
|
}
|
|
4202
4226
|
this.currentVisible = a2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: i2 }), this.schedulePushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
4203
4227
|
}
|
|
@@ -4229,9 +4253,9 @@ const gn = class extends BasePlugin {
|
|
|
4229
4253
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
4230
4254
|
const r9 = (null == s2 ? void 0 : s2.marginTop) ?? 80, a2 = this.virtualPageMap.atIndex(e14);
|
|
4231
4255
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
4232
|
-
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex),
|
|
4233
|
-
if (!i2 || !
|
|
4234
|
-
const h2 = i2.height /
|
|
4256
|
+
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), l = o2 ? null == (n2 = this.documentManager.provides().getDocument(o2.documentId)) ? void 0 : n2.pages[o2.pageIndex] : void 0;
|
|
4257
|
+
if (!i2 || !l) return void this.scrollToIndex(e14, s2);
|
|
4258
|
+
const h2 = i2.height / l.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * h2 - r9;
|
|
4235
4259
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
4236
4260
|
}
|
|
4237
4261
|
scrollToChapter(e14, t2) {
|
|
@@ -4267,10 +4291,10 @@ function In(e14, t2) {
|
|
|
4267
4291
|
if (e14.chapterId !== t2.chapterId || e14.localPageIndex !== t2.localPageIndex) return false;
|
|
4268
4292
|
const r9 = (null == (s2 = e14.rectsPdfCoord) ? void 0 : s2.length) ? e14.rectsPdfCoord : [e14.rectPdfCoord], a2 = (null == (n2 = t2.rectsPdfCoord) ? void 0 : n2.length) ? t2.rectsPdfCoord : [t2.rectPdfCoord], i2 = e14.markerAnchor ?? vn(r9), o2 = t2.markerAnchor ?? vn(a2);
|
|
4269
4293
|
if (Math.hypot(i2.x - o2.x, i2.y - o2.y) <= 6) return true;
|
|
4270
|
-
for (const
|
|
4271
|
-
if (Pn(
|
|
4272
|
-
const t3 = Math.max(
|
|
4273
|
-
if (Math.min(
|
|
4294
|
+
for (const l of r9) for (const e15 of a2) {
|
|
4295
|
+
if (Pn(l, e15) < 0.5) continue;
|
|
4296
|
+
const t3 = Math.max(l.origin.x, e15.origin.x);
|
|
4297
|
+
if (Math.min(l.origin.x + l.size.width, e15.origin.x + e15.size.width) - t3 > 0.25 * Math.min(l.size.width, e15.size.width)) return true;
|
|
4274
4298
|
}
|
|
4275
4299
|
return false;
|
|
4276
4300
|
}
|
|
@@ -4441,9 +4465,9 @@ function kn(e14) {
|
|
|
4441
4465
|
var _a2, _b, _c, _d, _e2, _f;
|
|
4442
4466
|
const t2 = e14.toolbar ?? {}, s2 = t2.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"], n2 = s2.length > 0, { schema: r9, operationRegistry: a2 } = (function(e15 = {}) {
|
|
4443
4467
|
var t3, s3, n3, r10, a3, i3;
|
|
4444
|
-
const o3 = new Set(e15.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"]),
|
|
4445
|
-
(null == (t3 = e15.customOperations) ? void 0 : t3.length) &&
|
|
4446
|
-
const h2 =
|
|
4468
|
+
const o3 = new Set(e15.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"]), l = new xn();
|
|
4469
|
+
(null == (t3 = e15.customOperations) ? void 0 : t3.length) && l.registerAll(e15.customOperations);
|
|
4470
|
+
const h2 = l.buildToolbars(), d2 = {};
|
|
4447
4471
|
for (const u2 of o3) {
|
|
4448
4472
|
if ("view" === u2) continue;
|
|
4449
4473
|
const e16 = $n[u2];
|
|
@@ -4454,7 +4478,7 @@ function kn(e14) {
|
|
|
4454
4478
|
const t4 = (e17, t5, s4) => ({ type: "command-button", id: `${e17}-mode`, commandId: s4, variant: "text", label: t5, categories: ["mode", e17] });
|
|
4455
4479
|
return { id: "chapter-editor-main-toolbar", position: { placement: "top", slot: "main", order: 0 }, permanent: true, items: [{ type: "spacer", id: "main-spacer-left", flex: true }, { type: "group", id: "mode-group", alignment: "start", gap: 2, items: [...e16.has("view") ? [t4("view", "View", "mode:view")] : [], ...e16.has("annotate") ? [t4("annotate", "Annotate", "mode:annotate")] : [], ...e16.has("shapes") ? [t4("shapes", "Shapes", "mode:shapes")] : [], ...e16.has("insert") ? [t4("insert", "Insert", "mode:insert")] : [], ...e16.has("form") ? [t4("form", "Form", "mode:form")] : [], ...e16.has("redact") ? [t4("redact", "Redact", "mode:redact")] : []] }, { type: "spacer", id: "main-spacer-right", flex: true }] };
|
|
4456
4480
|
})(o3);
|
|
4457
|
-
return c2 && (d2["chapter-editor-main-toolbar"] = c2), (null == (s3 = e15.extend) ? void 0 : s3.toolbars) && Object.assign(d2, e15.extend.toolbars), { schema: { id: "chapter-pdf-editor-ui", version: "1.0.0", toolbars: d2, menus: (null == (n3 = e15.extend) ? void 0 : n3.menus) ?? {}, sidebars: (null == (r10 = e15.extend) ? void 0 : r10.sidebars) ?? {}, modals: (null == (a3 = e15.extend) ? void 0 : a3.modals) ?? {}, selectionMenus: (null == (i3 = e15.extend) ? void 0 : i3.selectionMenus) ?? {} }, operationRegistry:
|
|
4481
|
+
return c2 && (d2["chapter-editor-main-toolbar"] = c2), (null == (s3 = e15.extend) ? void 0 : s3.toolbars) && Object.assign(d2, e15.extend.toolbars), { schema: { id: "chapter-pdf-editor-ui", version: "1.0.0", toolbars: d2, menus: (null == (n3 = e15.extend) ? void 0 : n3.menus) ?? {}, sidebars: (null == (r10 = e15.extend) ? void 0 : r10.sidebars) ?? {}, modals: (null == (a3 = e15.extend) ? void 0 : a3.modals) ?? {}, selectionMenus: (null == (i3 = e15.extend) ? void 0 : i3.selectionMenus) ?? {} }, operationRegistry: l };
|
|
4458
4482
|
})({ ...t2, enabledModes: s2 }), i2 = { ...n2 ? Dn() : {}, ...n2 ? En(a2.list()) : {}, ...e14.commands ?? {} }, o2 = [createPluginRegistration(DocumentManagerPluginPackage, { initialDocuments: [] }), createPluginRegistration(at$1, { manifest: e14.manifest, overlapStrategy: e14.overlapStrategy, passwordProvider: e14.passwordProvider, chapterPdfLoader: e14.chapterPdfLoader, prefetchChapters: e14.prefetchChapters, maxConcurrentSegmentLoads: e14.maxConcurrentSegmentLoads, unloadTimeoutMs: e14.unloadTimeoutMs }), createPluginRegistration(Tt$1, { placeholderPageHeight: e14.placeholderPageHeight, placeholderPageWidth: e14.placeholderPageWidth }), createPluginRegistration(InteractionManagerPluginPackage), createPluginRegistration(RenderPluginPackage), createPluginRegistration(RotatePluginPackage), createPluginRegistration(SelectionPluginPackage, { marquee: { enabled: false }, toleranceFactor: 1.2, minSelectionDragDistance: 4 }), createPluginRegistration(HistoryPluginPackage), createPluginRegistration(AnnotationPluginPackage), createPluginRegistration(RedactionPluginPackage), createPluginRegistration(FormPluginPackage), createPluginRegistration(StampPluginPackage, false === e14.loadDefaultStampLibrary ? { manifests: [] } : void 0), createPluginRegistration(SignaturePluginPackage), ...Object.keys(i2).length > 0 ? [createPluginRegistration(CommandsPluginPackage, { commands: i2 })] : [], ...n2 ? [createPluginRegistration(I18nPluginPackage), createPluginRegistration(UIPluginPackage, { schema: r9 })] : []];
|
|
4459
4483
|
return e14.notes && o2.push(createPluginRegistration(Ms, { callbacks: e14.notes.callbacks, ui: (_b = (_a2 = e14.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.marker })), e14.bookmarks && o2.push(createPluginRegistration(wn, { callbacks: e14.bookmarks.callbacks, ui: (_d = (_c = e14.features) == null ? void 0 : _c.bookmarks) == null ? void 0 : _d.marker, hover: (_f = (_e2 = e14.features) == null ? void 0 : _e2.bookmarks) == null ? void 0 : _f.hover })), { plugins: o2, uiSchema: r9, operationRegistry: a2 };
|
|
4460
4484
|
}
|
|
@@ -4471,20 +4495,20 @@ function Un(e14) {
|
|
|
4471
4495
|
return kn({ ...e14, toolbar: e14.toolbar ?? { enabledModes: [] }, features: De$1(e14.features) });
|
|
4472
4496
|
}
|
|
4473
4497
|
const On = { overlapStrategy: { kind: "first-wins" }, passwordProvider: new Ue$1(async () => null), prefetchChapters: 1, maxConcurrentSegmentLoads: 2, loadDefaultStampLibrary: false, unloadTimeoutMs: 12e4, toolbar: { enabledModes: [] } };
|
|
4474
|
-
function
|
|
4498
|
+
function Rn(e14) {
|
|
4475
4499
|
return (function(e15) {
|
|
4476
4500
|
return "callbacks" in e15.notes;
|
|
4477
4501
|
})(e14) ? { manifest: e14.manifest, chapterPdfLoader: e14.chapterPdfLoader, notes: e14.notes.callbacks, bookmarks: e14.bookmarks.callbacks } : e14;
|
|
4478
4502
|
}
|
|
4479
|
-
function
|
|
4503
|
+
function An(e14) {
|
|
4480
4504
|
return { ...On, manifest: e14.manifest, chapterPdfLoader: e14.chapterPdfLoader, overlapStrategy: e14.overlapStrategy ?? On.overlapStrategy, notes: { callbacks: e14.notes }, bookmarks: { callbacks: e14.bookmarks }, features: De$1(e14.features) };
|
|
4481
4505
|
}
|
|
4482
|
-
function
|
|
4483
|
-
const t2 =
|
|
4506
|
+
function Nn(e14) {
|
|
4507
|
+
const t2 = An(Rn(e14)), { plugins: s2 } = Un(t2);
|
|
4484
4508
|
return { plugins: s2, features: t2.features, editorOptions: t2 };
|
|
4485
4509
|
}
|
|
4486
|
-
function
|
|
4487
|
-
const { features: t2, ...s2 } =
|
|
4510
|
+
function zn(e14) {
|
|
4511
|
+
const { features: t2, ...s2 } = An(Rn(e14));
|
|
4488
4512
|
return s2;
|
|
4489
4513
|
}
|
|
4490
4514
|
function _n(e14, t2 = 0.5, s2 = 3) {
|
|
@@ -4525,10 +4549,10 @@ function Wn(e14) {
|
|
|
4525
4549
|
return e14 instanceof HTMLElement ? e14.clientWidth : 0;
|
|
4526
4550
|
}
|
|
4527
4551
|
function Bn(a2, i2, o2) {
|
|
4528
|
-
const
|
|
4552
|
+
const l = isRef(a2) ? a2 : computed(() => a2), { registry: h2 } = useRegistry(), { provides: d2 } = useCapability(DocumentManagerPlugin.id), { provides: c2 } = useCapability(rt$1.id), u2 = ref(P2()), p2 = ref(u2.value), g2 = ref(0), m2 = ref(false), f2 = () => {
|
|
4529
4553
|
var _a2;
|
|
4530
4554
|
return (_a2 = i2.value) == null ? void 0 : _a2.pageWidth;
|
|
4531
|
-
},
|
|
4555
|
+
}, v = () => (function(e14) {
|
|
4532
4556
|
return null != e14 && e14 > 0;
|
|
4533
4557
|
})(f2()), P2 = () => {
|
|
4534
4558
|
var _a2;
|
|
@@ -4542,7 +4566,7 @@ function Bn(a2, i2, o2) {
|
|
|
4542
4566
|
a3 = Math.min(a3, qn(e15, s2, n2, r9));
|
|
4543
4567
|
});
|
|
4544
4568
|
return a3;
|
|
4545
|
-
})(d2.value,
|
|
4569
|
+
})(d2.value, l.value, g2.value, f2(), ((_a2 = i2.value) == null ? void 0 : _a2.max) ?? 3);
|
|
4546
4570
|
}), b2 = computed(() => {
|
|
4547
4571
|
var _a2;
|
|
4548
4572
|
return Math.min(((_a2 = i2.value) == null ? void 0 : _a2.min) ?? 0.5, I2.value);
|
|
@@ -4560,7 +4584,7 @@ function Bn(a2, i2, o2) {
|
|
|
4560
4584
|
if (e16) for (const t4 of e16.segments) a3.getState().core.documents[t4.documentId] && a3.dispatchToCore(setScale(i3, t4.documentId));
|
|
4561
4585
|
else a3.getState().core.documents[o3.chapterId] && a3.dispatchToCore(setScale(i3, o3.chapterId));
|
|
4562
4586
|
}
|
|
4563
|
-
})(h2.value,
|
|
4587
|
+
})(h2.value, l.value, n2, s2, t2);
|
|
4564
4588
|
}
|
|
4565
4589
|
function S(e14) {
|
|
4566
4590
|
if (!d2.value || !c2.value) return;
|
|
@@ -4570,7 +4594,7 @@ function Bn(a2, i2, o2) {
|
|
|
4570
4594
|
n2 <= 0 || y(Gn(s2, n2));
|
|
4571
4595
|
}
|
|
4572
4596
|
function x(e14) {
|
|
4573
|
-
if (!m2.value) return
|
|
4597
|
+
if (!m2.value) return v() ? S(e14) : y(P2()), void (m2.value = true);
|
|
4574
4598
|
y(p2.value);
|
|
4575
4599
|
}
|
|
4576
4600
|
return watch(() => o2 == null ? void 0 : o2.value, (e14) => {
|
|
@@ -4594,14 +4618,14 @@ function Bn(a2, i2, o2) {
|
|
|
4594
4618
|
})(e14, (e15) => {
|
|
4595
4619
|
g2.value = e15;
|
|
4596
4620
|
}) : void 0;
|
|
4597
|
-
}, { immediate: true }), onBeforeUnmount(() => C2 == null ? void 0 : C2()), watch([h2, () => P2(), () =>
|
|
4598
|
-
h2.value && (
|
|
4621
|
+
}, { immediate: true }), onBeforeUnmount(() => C2 == null ? void 0 : C2()), watch([h2, () => P2(), () => v()], () => {
|
|
4622
|
+
h2.value && (v() || y(P2()));
|
|
4599
4623
|
}, { immediate: true }), watch(I2, (e14) => {
|
|
4600
4624
|
p2.value > e14 && y(e14);
|
|
4601
|
-
}), watch([c2,
|
|
4625
|
+
}), watch([c2, l, () => v(), () => P2()], () => {
|
|
4602
4626
|
const e14 = c2.value;
|
|
4603
4627
|
if (e14) {
|
|
4604
|
-
for (const t2 of
|
|
4628
|
+
for (const t2 of l.value.chapters) "loaded" === e14.getChapterStatus(t2.chapterId) && x(t2.chapterId);
|
|
4605
4629
|
return e14.onChapterStatusChange((e15) => {
|
|
4606
4630
|
"loaded" === e15.status && x(e15.chapterId);
|
|
4607
4631
|
});
|
|
@@ -4611,9 +4635,9 @@ function Bn(a2, i2, o2) {
|
|
|
4611
4635
|
s2(e14.onDocumentOpened(() => {
|
|
4612
4636
|
m2.value && y(p2.value);
|
|
4613
4637
|
}));
|
|
4614
|
-
}), watch([g2, () =>
|
|
4615
|
-
if (
|
|
4616
|
-
for (const e14 of
|
|
4638
|
+
}), watch([g2, () => v(), c2, l], () => {
|
|
4639
|
+
if (v() && !(g2.value <= 0) && c2.value && !m2.value) {
|
|
4640
|
+
for (const e14 of l.value.chapters) if ("loaded" === c2.value.getChapterStatus(e14.chapterId)) {
|
|
4617
4641
|
S(e14.chapterId), m2.value = true;
|
|
4618
4642
|
break;
|
|
4619
4643
|
}
|
|
@@ -4633,9 +4657,9 @@ function jn(e14, t2) {
|
|
|
4633
4657
|
const a2 = () => {
|
|
4634
4658
|
const n3 = e14.querySelector("[data-chapter-scroll-viewport]");
|
|
4635
4659
|
return !!n3 && (s2 == null ? void 0 : s2(), s2 = (function({ container: e15, getScale: t3, setScale: s3, minZoom: n4 = 0.5, maxZoom: r10 = 3 }) {
|
|
4636
|
-
let a3 = 0, i2 = 1, o2 = null,
|
|
4660
|
+
let a3 = 0, i2 = 1, o2 = null, l = 1, h2 = 1;
|
|
4637
4661
|
const d2 = (e16) => {
|
|
4638
|
-
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === o2 ? (h2 = t3(),
|
|
4662
|
+
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === o2 ? (h2 = t3(), l = 1) : clearTimeout(o2), l *= 1 - 0.01 * e16.deltaY, l = Kn(l, 0.1, 10), s3(Kn(h2 * l, n4, r10)), o2 = setTimeout(() => {
|
|
4639
4663
|
o2 = null;
|
|
4640
4664
|
}, 120));
|
|
4641
4665
|
}, c2 = /* @__PURE__ */ new Map(), u2 = (e16) => {
|
|
@@ -4646,8 +4670,8 @@ function jn(e14, t2) {
|
|
|
4646
4670
|
}, p2 = (e16) => {
|
|
4647
4671
|
if (c2.has(e16.pointerId) && (c2.set(e16.pointerId, { x: e16.clientX, y: e16.clientY }), 2 === c2.size && a3 > 0)) {
|
|
4648
4672
|
e16.preventDefault();
|
|
4649
|
-
const [t4, o3] = [...c2.values()],
|
|
4650
|
-
s3(Kn(i2 * (
|
|
4673
|
+
const [t4, o3] = [...c2.values()], l2 = Math.hypot(o3.x - t4.x, o3.y - t4.y);
|
|
4674
|
+
s3(Kn(i2 * (l2 / a3), n4, r10));
|
|
4651
4675
|
}
|
|
4652
4676
|
}, g2 = (e16) => {
|
|
4653
4677
|
c2.delete(e16.pointerId), c2.size < 2 && (a3 = 0);
|
|
@@ -4668,10 +4692,10 @@ function Zn(e14) {
|
|
|
4668
4692
|
const a2 = ref(null), { provides: i2 } = useCapability(rt$1.id), o2 = computed(() => {
|
|
4669
4693
|
var _a2;
|
|
4670
4694
|
return ((_a2 = i2.value) == null ? void 0 : _a2.getManifest()) ?? Xn;
|
|
4671
|
-
}),
|
|
4695
|
+
}), l = computed(() => {
|
|
4672
4696
|
var _a2;
|
|
4673
4697
|
return (_a2 = e14.value) == null ? void 0 : _a2.zoom;
|
|
4674
|
-
}), { scale: h2, setScale: d2, zoomEnabled: c2, minZoom: u2, maxZoom: p2 } = Bn(o2,
|
|
4698
|
+
}), { scale: h2, setScale: d2, zoomEnabled: c2, minZoom: u2, maxZoom: p2 } = Bn(o2, l, a2);
|
|
4675
4699
|
return (function(e15, t2) {
|
|
4676
4700
|
let s2 = null;
|
|
4677
4701
|
watch([e15, t2], () => {
|
|
@@ -4775,7 +4799,7 @@ function dr(e14) {
|
|
|
4775
4799
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
4776
4800
|
const o2 = ir(a2, s2);
|
|
4777
4801
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
4778
|
-
for (let
|
|
4802
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
4779
4803
|
return n2;
|
|
4780
4804
|
}
|
|
4781
4805
|
const cr = { kind: "first-wins" };
|
|
@@ -4851,7 +4875,7 @@ function gr(e14, t2 = cr) {
|
|
|
4851
4875
|
for (const o2 of r9) {
|
|
4852
4876
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
4853
4877
|
if (!t3) continue;
|
|
4854
|
-
const [r10] = t3.globalPageRange, [
|
|
4878
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
4855
4879
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
4856
4880
|
}
|
|
4857
4881
|
return new pr(a2);
|
|
@@ -5038,19 +5062,19 @@ const fr = class e9 extends BasePlugin {
|
|
|
5038
5062
|
});
|
|
5039
5063
|
}
|
|
5040
5064
|
if (0 === a2.size) return;
|
|
5041
|
-
const
|
|
5065
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
5042
5066
|
let h2 = 0;
|
|
5043
5067
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
5044
5068
|
if (d2) {
|
|
5045
|
-
const e15 =
|
|
5069
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
5046
5070
|
e15 >= 0 && (h2 = e15);
|
|
5047
5071
|
}
|
|
5048
5072
|
for (const c2 of a2) {
|
|
5049
5073
|
this.chapterLastUsed.set(c2, s2);
|
|
5050
|
-
const e15 =
|
|
5074
|
+
const e15 = l.indexOf(c2);
|
|
5051
5075
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
5052
|
-
if (t3 < 0 || t3 >=
|
|
5053
|
-
const e16 =
|
|
5076
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
5077
|
+
const e16 = l[t3];
|
|
5054
5078
|
this.chapterLastUsed.set(e16, s2);
|
|
5055
5079
|
const n3 = Math.abs(t3 - h2);
|
|
5056
5080
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -5162,7 +5186,11 @@ const fr = class e9 extends BasePlugin {
|
|
|
5162
5186
|
const n3 = ir(tr(t2), a2);
|
|
5163
5187
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
5164
5188
|
const r10 = await this.resolveChapterUrls(t2);
|
|
5165
|
-
|
|
5189
|
+
if (r10.length !== n3) {
|
|
5190
|
+
const [s3, i2] = t2.globalPageRange;
|
|
5191
|
+
this.logger.warn(e9.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
5192
|
+
}
|
|
5193
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
5166
5194
|
}
|
|
5167
5195
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
5168
5196
|
if (n2) {
|
|
@@ -5186,12 +5214,12 @@ const fr = class e9 extends BasePlugin {
|
|
|
5186
5214
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
5187
5215
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
5188
5216
|
try {
|
|
5189
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
5217
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
5190
5218
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
5191
5219
|
});
|
|
5192
5220
|
return await new Promise((e15, t3) => {
|
|
5193
5221
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
5194
|
-
}),
|
|
5222
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
5195
5223
|
} catch (o2) {
|
|
5196
5224
|
const t3 = this.chapterStatus.get(r9);
|
|
5197
5225
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -5225,8 +5253,8 @@ const fr = class e9 extends BasePlugin {
|
|
|
5225
5253
|
let o2 = null;
|
|
5226
5254
|
try {
|
|
5227
5255
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
5228
|
-
} catch (
|
|
5229
|
-
this.logger.error(e9.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
5256
|
+
} catch (l) {
|
|
5257
|
+
this.logger.error(e9.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
5230
5258
|
}
|
|
5231
5259
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
5232
5260
|
this.updateStatus(s2, "loading");
|
|
@@ -5369,23 +5397,23 @@ const Ir = class extends BasePlugin {
|
|
|
5369
5397
|
if (!this.virtualPageMap) return;
|
|
5370
5398
|
const s2 = this.chapterManager.provides(), n2 = s2.getChapter(e14), r9 = this.virtualPageMap.pagesOfChapter(e14);
|
|
5371
5399
|
if (!n2 || 0 === r9.length) return;
|
|
5372
|
-
const a2 = er(n2), i2 = this.documentManager.provides(), o2 = [],
|
|
5400
|
+
const a2 = er(n2), i2 = this.documentManager.provides(), o2 = [], l = (e15, t3, s3, n3) => {
|
|
5373
5401
|
var r10;
|
|
5374
5402
|
const a3 = i2.getDocument(e15);
|
|
5375
5403
|
if (!(null == (r10 = null == a3 ? void 0 : a3.pages) ? void 0 : r10.length)) return false;
|
|
5376
|
-
const
|
|
5404
|
+
const l2 = this.getDocumentScale(e15);
|
|
5377
5405
|
for (let i3 = 0; i3 < n3; i3++) {
|
|
5378
5406
|
const e16 = a3.pages[s3 + i3];
|
|
5379
|
-
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width *
|
|
5407
|
+
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width * l2, height: e16.size.height * l2 });
|
|
5380
5408
|
}
|
|
5381
5409
|
return o2.length > 0;
|
|
5382
5410
|
};
|
|
5383
5411
|
if (a2) for (const h2 of a2.segments) {
|
|
5384
5412
|
if (!s2.isSegmentLoaded(e14, h2.index)) continue;
|
|
5385
5413
|
const t3 = h2.localPageEnd - h2.localPageStart + 1;
|
|
5386
|
-
|
|
5414
|
+
l(h2.documentId, h2.localPageStart, 0, t3);
|
|
5387
5415
|
}
|
|
5388
|
-
else s2.isSegmentLoaded(e14, 0) &&
|
|
5416
|
+
else s2.isSegmentLoaded(e14, 0) && l(e14, 0, 0, r9.length);
|
|
5389
5417
|
0 !== o2.length ? this.applyChapterPageSizes(e14, o2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
5390
5418
|
}
|
|
5391
5419
|
onScaleChanged(e14) {
|
|
@@ -5431,10 +5459,10 @@ const Ir = class extends BasePlugin {
|
|
|
5431
5459
|
}
|
|
5432
5460
|
const a2 = [];
|
|
5433
5461
|
let i2 = n2, o2 = -1;
|
|
5434
|
-
for (let
|
|
5435
|
-
a2.push(
|
|
5436
|
-
const e15 = this.offsets[
|
|
5437
|
-
r10 > o2 && (o2 = r10, i2 =
|
|
5462
|
+
for (let l = n2; l < r9; l++) {
|
|
5463
|
+
a2.push(l);
|
|
5464
|
+
const e15 = this.offsets[l], n3 = e15 + this.getPageSize(l).height, r10 = Math.max(0, Math.min(n3, s2) - Math.max(e15, t2));
|
|
5465
|
+
r10 > o2 && (o2 = r10, i2 = l);
|
|
5438
5466
|
}
|
|
5439
5467
|
this.currentVisible = a2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: i2 }), this.schedulePushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
5440
5468
|
}
|
|
@@ -5466,9 +5494,9 @@ const Ir = class extends BasePlugin {
|
|
|
5466
5494
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
5467
5495
|
const r9 = (null == s2 ? void 0 : s2.marginTop) ?? 80, a2 = this.virtualPageMap.atIndex(e14);
|
|
5468
5496
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
5469
|
-
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex),
|
|
5470
|
-
if (!i2 || !
|
|
5471
|
-
const h2 = i2.height /
|
|
5497
|
+
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), l = o2 ? null == (n2 = this.documentManager.provides().getDocument(o2.documentId)) ? void 0 : n2.pages[o2.pageIndex] : void 0;
|
|
5498
|
+
if (!i2 || !l) return void this.scrollToIndex(e14, s2);
|
|
5499
|
+
const h2 = i2.height / l.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * h2 - r9;
|
|
5472
5500
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
5473
5501
|
}
|
|
5474
5502
|
scrollToChapter(e14, t2) {
|
|
@@ -5491,15 +5519,15 @@ const Cr = ["data-global-page-index", "data-chapter-id", "data-local-page-index"
|
|
|
5491
5519
|
})(/* @__PURE__ */ defineComponent({ __name: "ChapterScroller", props: { class: {}, style: {} }, setup(e14) {
|
|
5492
5520
|
const { provides: t2 } = useCapability(br.id), a2 = ref(null), m2 = ref(null);
|
|
5493
5521
|
let f2 = null;
|
|
5494
|
-
const
|
|
5522
|
+
const v = () => {
|
|
5495
5523
|
null == f2 || f2(), f2 = null, t2.value && (t2.value.registerViewport(a2.value), f2 = t2.value.onLayoutChange((e15) => {
|
|
5496
5524
|
m2.value = e15;
|
|
5497
5525
|
}));
|
|
5498
5526
|
};
|
|
5499
|
-
return onMounted(
|
|
5527
|
+
return onMounted(v), onBeforeUnmount(() => {
|
|
5500
5528
|
var e15;
|
|
5501
5529
|
null == f2 || f2(), null == (e15 = t2.value) || e15.registerViewport(null);
|
|
5502
|
-
}), watch(t2,
|
|
5530
|
+
}), watch(t2, v), (e15, t3) => {
|
|
5503
5531
|
var s2, n2, r9;
|
|
5504
5532
|
return openBlock(), createElementBlock("div", { ref_key: "containerRef", ref: a2, "data-chapter-scroll-viewport": "", class: normalizeClass(e15.$props.class), style: normalizeStyle({ overflow: "auto", overflowX: "hidden", position: "relative", width: "100%", height: "100%", ...e15.$props.style }) }, [createElementVNode("div", { style: normalizeStyle({ position: "relative", width: `${(null == (s2 = m2.value) ? void 0 : s2.totalWidth) ?? 0}px`, height: `${(null == (n2 = m2.value) ? void 0 : n2.totalHeight) ?? 0}px`, margin: "0 auto" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList((null == (r9 = m2.value) ? void 0 : r9.items) ?? [], (s3) => (openBlock(), createElementBlock("div", { key: s3.globalPageIndex, "data-global-page-index": s3.globalPageIndex, "data-chapter-id": s3.chapterId, "data-local-page-index": s3.localPageIndex, style: normalizeStyle({ position: "absolute", top: `${s3.offsetTop}px`, left: "50%", transform: "translateX(-50%)", width: `${s3.width}px`, height: `${s3.height}px`, backgroundColor: s3.isPlaceholder ? "#f3f4f6" : "#fff", boxShadow: "0 1px 4px rgba(0,0,0,0.08)" }) }, [s3.isPlaceholder ? renderSlot(e15.$slots, "placeholder", { key: 0, item: s3 }, () => [t3[0] || (t3[0] = createElementVNode("div", { class: "chapter-scroll-placeholder" }, "Loading chapter…", -1))], true) : renderSlot(e15.$slots, "page", { key: 1, item: s3 }, void 0, true)], 12, Cr))), 128))], 4)], 6);
|
|
5505
5533
|
};
|
|
@@ -5569,7 +5597,7 @@ function Fr(e14) {
|
|
|
5569
5597
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
5570
5598
|
const o2 = Dr(a2, s2);
|
|
5571
5599
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
5572
|
-
for (let
|
|
5600
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
5573
5601
|
return n2;
|
|
5574
5602
|
}
|
|
5575
5603
|
const Ur = { kind: "first-wins" };
|
|
@@ -5591,7 +5619,7 @@ function Or(e14, t2, s2) {
|
|
|
5591
5619
|
return s2.resolve(e14, t2);
|
|
5592
5620
|
}
|
|
5593
5621
|
}
|
|
5594
|
-
let
|
|
5622
|
+
let Rr = class {
|
|
5595
5623
|
constructor(e14) {
|
|
5596
5624
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
5597
5625
|
for (const t2 of e14) {
|
|
@@ -5625,7 +5653,7 @@ let Ar = class {
|
|
|
5625
5653
|
return s2 ? this._pages.indexOf(s2) : -1;
|
|
5626
5654
|
}
|
|
5627
5655
|
};
|
|
5628
|
-
function
|
|
5656
|
+
function Ar(e14, t2 = Ur) {
|
|
5629
5657
|
const s2 = (function(e15, t3 = Ur) {
|
|
5630
5658
|
const s3 = /* @__PURE__ */ new Map();
|
|
5631
5659
|
for (const r10 of e15.chapters) {
|
|
@@ -5645,12 +5673,12 @@ function Nr(e14, t2 = Ur) {
|
|
|
5645
5673
|
for (const o2 of r9) {
|
|
5646
5674
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
5647
5675
|
if (!t3) continue;
|
|
5648
|
-
const [r10] = t3.globalPageRange, [
|
|
5676
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
5649
5677
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
5650
5678
|
}
|
|
5651
|
-
return new
|
|
5679
|
+
return new Rr(a2);
|
|
5652
5680
|
}
|
|
5653
|
-
let
|
|
5681
|
+
let Nr = class {
|
|
5654
5682
|
constructor(e14, t2) {
|
|
5655
5683
|
this.maxConcurrent = e14, this.run = t2, this.queue = [], this.inFlight = /* @__PURE__ */ new Set();
|
|
5656
5684
|
}
|
|
@@ -5681,7 +5709,7 @@ let zr = class {
|
|
|
5681
5709
|
}
|
|
5682
5710
|
}
|
|
5683
5711
|
};
|
|
5684
|
-
const
|
|
5712
|
+
const zr = class e10 extends BasePlugin {
|
|
5685
5713
|
constructor(e14, t2) {
|
|
5686
5714
|
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Ur, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterErrorMessages = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingChapterLoadPromises = /* @__PURE__ */ new Map(), this.pendingSegmentLoadPromises = /* @__PURE__ */ new Map(), this.chapterUrlsCache = /* @__PURE__ */ new Map(), this.pendingChapterUrlsPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.SEG_PRIO_PREFETCH_NEXT = 120, this.SEG_PRIO_CHAPTER_PREFETCH_BASE = 3e3, this.lastVisibleIndicesKey = "", this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
5687
5715
|
}
|
|
@@ -5695,7 +5723,7 @@ const Rr = class e10 extends BasePlugin {
|
|
|
5695
5723
|
}), this.documentManager.provides().onDocumentError((e15) => {
|
|
5696
5724
|
const { chapterId: t2 } = $r(e15.documentId);
|
|
5697
5725
|
this.findChapter(t2) && this.handleDocumentError(e15.documentId, t2, e15.code, e15.message);
|
|
5698
|
-
})), this.segmentScheduler = new
|
|
5726
|
+
})), this.segmentScheduler = new Nr(e14.maxConcurrentSegmentLoads ?? 2, (e15, t2) => this.loadSegmentNow(e15, t2)), this.setManifestInternal(e14.manifest), e14.unloadTimeoutMs && e14.unloadTimeoutMs > 0) {
|
|
5699
5727
|
const t2 = Math.max(5e3, Math.floor(e14.unloadTimeoutMs / 4));
|
|
5700
5728
|
this.unloadTimer = setInterval(() => this.collectIdleChapters(), t2);
|
|
5701
5729
|
}
|
|
@@ -5750,7 +5778,7 @@ const Rr = class e10 extends BasePlugin {
|
|
|
5750
5778
|
const a2 = new Set(this.chapterStatus.keys()), i2 = new Set(n2.chapters.map((e14) => e14.chapterId));
|
|
5751
5779
|
for (const e14 of a2) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14), this.chapterErrorMessages.delete(e14), this.chapterUrlsCache.delete(e14), this.pendingChapterUrlsPromises.delete(e14));
|
|
5752
5780
|
for (const e14 of n2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
5753
|
-
this.manifest = n2, this.lastVisibleIndicesKey = "", null == (s2 = this.segmentScheduler) || s2.clear(), this.virtualPageMap =
|
|
5781
|
+
this.manifest = n2, this.lastVisibleIndicesKey = "", null == (s2 = this.segmentScheduler) || s2.clear(), this.virtualPageMap = Ar(n2, this.overlapStrategy), this.manifestChange$.emit({ manifest: n2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
5754
5782
|
}
|
|
5755
5783
|
eagerPrefetchFromManifest() {
|
|
5756
5784
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -5832,19 +5860,19 @@ const Rr = class e10 extends BasePlugin {
|
|
|
5832
5860
|
});
|
|
5833
5861
|
}
|
|
5834
5862
|
if (0 === a2.size) return;
|
|
5835
|
-
const
|
|
5863
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
5836
5864
|
let h2 = 0;
|
|
5837
5865
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
5838
5866
|
if (d2) {
|
|
5839
|
-
const e15 =
|
|
5867
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
5840
5868
|
e15 >= 0 && (h2 = e15);
|
|
5841
5869
|
}
|
|
5842
5870
|
for (const c2 of a2) {
|
|
5843
5871
|
this.chapterLastUsed.set(c2, s2);
|
|
5844
|
-
const e15 =
|
|
5872
|
+
const e15 = l.indexOf(c2);
|
|
5845
5873
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
5846
|
-
if (t3 < 0 || t3 >=
|
|
5847
|
-
const e16 =
|
|
5874
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
5875
|
+
const e16 = l[t3];
|
|
5848
5876
|
this.chapterLastUsed.set(e16, s2);
|
|
5849
5877
|
const n3 = Math.abs(t3 - h2);
|
|
5850
5878
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -5956,7 +5984,11 @@ const Rr = class e10 extends BasePlugin {
|
|
|
5956
5984
|
const n3 = Dr(wr(t2), a2);
|
|
5957
5985
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
5958
5986
|
const r10 = await this.resolveChapterUrls(t2);
|
|
5959
|
-
|
|
5987
|
+
if (r10.length !== n3) {
|
|
5988
|
+
const [s3, i2] = t2.globalPageRange;
|
|
5989
|
+
this.logger.warn(e10.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
5990
|
+
}
|
|
5991
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
5960
5992
|
}
|
|
5961
5993
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
5962
5994
|
if (n2) {
|
|
@@ -5980,12 +6012,12 @@ const Rr = class e10 extends BasePlugin {
|
|
|
5980
6012
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
5981
6013
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
5982
6014
|
try {
|
|
5983
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
6015
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
5984
6016
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
5985
6017
|
});
|
|
5986
6018
|
return await new Promise((e15, t3) => {
|
|
5987
6019
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
5988
|
-
}),
|
|
6020
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
5989
6021
|
} catch (o2) {
|
|
5990
6022
|
const t3 = this.chapterStatus.get(r9);
|
|
5991
6023
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -6019,8 +6051,8 @@ const Rr = class e10 extends BasePlugin {
|
|
|
6019
6051
|
let o2 = null;
|
|
6020
6052
|
try {
|
|
6021
6053
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
6022
|
-
} catch (
|
|
6023
|
-
this.logger.error(e10.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
6054
|
+
} catch (l) {
|
|
6055
|
+
this.logger.error(e10.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
6024
6056
|
}
|
|
6025
6057
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
6026
6058
|
this.updateStatus(s2, "loading");
|
|
@@ -6045,8 +6077,8 @@ const Rr = class e10 extends BasePlugin {
|
|
|
6045
6077
|
"error" === t2 && s2 ? this.chapterErrorMessages.set(e14, s2) : "loading" !== t2 && "loaded" !== t2 || this.chapterErrorMessages.delete(e14), n2 !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && s2 ? { error: { message: s2 } } : {} }));
|
|
6046
6078
|
}
|
|
6047
6079
|
};
|
|
6048
|
-
|
|
6049
|
-
let _r =
|
|
6080
|
+
zr.id = "chapter-manager";
|
|
6081
|
+
let _r = zr;
|
|
6050
6082
|
function Gr(e14) {
|
|
6051
6083
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
6052
6084
|
}
|
|
@@ -6141,7 +6173,7 @@ function ea(e14) {
|
|
|
6141
6173
|
0 === i2.urls.length && n2.push(`${r9}: source.urls must not be empty`);
|
|
6142
6174
|
const o2 = Zr(a2, s2);
|
|
6143
6175
|
i2.urls.length !== o2 && n2.push(`${r9}: source.urls.length (${i2.urls.length}) must equal ceil(pageCount/threshold) (${o2})`);
|
|
6144
|
-
for (let
|
|
6176
|
+
for (let l = 0; l < i2.urls.length; l++) (null == (t2 = i2.urls[l]) ? void 0 : t2.trim()) || n2.push(`${r9}: source.urls[${l}] is empty`);
|
|
6145
6177
|
return n2;
|
|
6146
6178
|
}
|
|
6147
6179
|
const ta = { kind: "first-wins" };
|
|
@@ -6217,7 +6249,7 @@ function ra(e14, t2 = ta) {
|
|
|
6217
6249
|
for (const o2 of r9) {
|
|
6218
6250
|
const e15 = s2.get(o2), t3 = n2.get(e15);
|
|
6219
6251
|
if (!t3) continue;
|
|
6220
|
-
const [r10] = t3.globalPageRange, [
|
|
6252
|
+
const [r10] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (o2 - r10);
|
|
6221
6253
|
a2.push({ globalPageIndex: i2++, globalPageNumber: o2, chapterId: e15, localPageIndex: h2 });
|
|
6222
6254
|
}
|
|
6223
6255
|
return new na(a2);
|
|
@@ -6404,19 +6436,19 @@ const ia = class e11 extends BasePlugin {
|
|
|
6404
6436
|
});
|
|
6405
6437
|
}
|
|
6406
6438
|
if (0 === a2.size) return;
|
|
6407
|
-
const
|
|
6439
|
+
const l = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
6408
6440
|
let h2 = 0;
|
|
6409
6441
|
const d2 = this.virtualPageMap.atIndex(r9);
|
|
6410
6442
|
if (d2) {
|
|
6411
|
-
const e15 =
|
|
6443
|
+
const e15 = l.indexOf(d2.chapterId);
|
|
6412
6444
|
e15 >= 0 && (h2 = e15);
|
|
6413
6445
|
}
|
|
6414
6446
|
for (const c2 of a2) {
|
|
6415
6447
|
this.chapterLastUsed.set(c2, s2);
|
|
6416
|
-
const e15 =
|
|
6448
|
+
const e15 = l.indexOf(c2);
|
|
6417
6449
|
if (-1 !== e15) for (let t3 = e15 - n2; t3 <= e15 + n2; t3++) {
|
|
6418
|
-
if (t3 < 0 || t3 >=
|
|
6419
|
-
const e16 =
|
|
6450
|
+
if (t3 < 0 || t3 >= l.length) continue;
|
|
6451
|
+
const e16 = l[t3];
|
|
6420
6452
|
this.chapterLastUsed.set(e16, s2);
|
|
6421
6453
|
const n3 = Math.abs(t3 - h2);
|
|
6422
6454
|
o2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * n3);
|
|
@@ -6528,7 +6560,11 @@ const ia = class e11 extends BasePlugin {
|
|
|
6528
6560
|
const n3 = Zr(Wr(t2), a2);
|
|
6529
6561
|
if (s2 < 0 || s2 >= n3) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${n3 - 1})`);
|
|
6530
6562
|
const r10 = await this.resolveChapterUrls(t2);
|
|
6531
|
-
|
|
6563
|
+
if (r10.length !== n3) {
|
|
6564
|
+
const [s3, i2] = t2.globalPageRange;
|
|
6565
|
+
this.logger.warn(e11.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" loadChapterUrls returned ${r10.length} URL(s), expected ${n3} (= ceil((${i2}-${s3}+1) / ${a2})). Check globalPageRange [${s3},${i2}] and segmentPageThreshold.`);
|
|
6566
|
+
}
|
|
6567
|
+
return this.openPayloadFromUrl(t2, s2, r10);
|
|
6532
6568
|
}
|
|
6533
6569
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
6534
6570
|
if (n2) {
|
|
@@ -6552,12 +6588,12 @@ const ia = class e11 extends BasePlugin {
|
|
|
6552
6588
|
const r9 = t2.chapterId, a2 = (null == s2 ? void 0 : s2.index) ?? 0, i2 = (null == s2 ? void 0 : s2.documentId) ?? r9;
|
|
6553
6589
|
this.chapterErrorMessages.delete(r9), this.anySegmentOpen(r9) || this.updateStatus(r9, "loading"), this.chapterLastUsed.set(r9, Date.now());
|
|
6554
6590
|
try {
|
|
6555
|
-
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2),
|
|
6591
|
+
const e14 = t2.encrypted && (null == (n2 = this.passwordProvider) ? void 0 : n2.getCachedPassword) ? this.passwordProvider.getCachedPassword(r9) : null, o2 = await this.resolvePdfPayload(t2, a2), l = this.documentManager.provides(), h2 = "url" in o2 ? l.openDocumentUrl({ documentId: i2, url: o2.url, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }) : l.openDocumentBuffer({ documentId: i2, buffer: o2.buffer, name: s2 ? `${t2.title} (${s2.index + 1})` : t2.title, password: e14 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
6556
6592
|
h2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
6557
6593
|
});
|
|
6558
6594
|
return await new Promise((e15, t3) => {
|
|
6559
6595
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
6560
|
-
}),
|
|
6596
|
+
}), l.isDocumentOpen(i2) && this.syncChapterStatusFromDocuments(r9), this.waitForTerminalStatus(r9);
|
|
6561
6597
|
} catch (o2) {
|
|
6562
6598
|
const t3 = this.chapterStatus.get(r9);
|
|
6563
6599
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
@@ -6591,8 +6627,8 @@ const ia = class e11 extends BasePlugin {
|
|
|
6591
6627
|
let o2 = null;
|
|
6592
6628
|
try {
|
|
6593
6629
|
o2 = await this.passwordProvider.resolvePassword(a2, i2 - 1);
|
|
6594
|
-
} catch (
|
|
6595
|
-
this.logger.error(e11.id, "PasswordProvider", `Provider rejected for ${s2}`,
|
|
6630
|
+
} catch (l) {
|
|
6631
|
+
this.logger.error(e11.id, "PasswordProvider", `Provider rejected for ${s2}`, l);
|
|
6596
6632
|
}
|
|
6597
6633
|
if (!o2) return void this.updateStatus(s2, "password-required");
|
|
6598
6634
|
this.updateStatus(s2, "loading");
|
|
@@ -6735,23 +6771,23 @@ const ha = class extends BasePlugin {
|
|
|
6735
6771
|
if (!this.virtualPageMap) return;
|
|
6736
6772
|
const s2 = this.chapterManager.provides(), n2 = s2.getChapter(e14), r9 = this.virtualPageMap.pagesOfChapter(e14);
|
|
6737
6773
|
if (!n2 || 0 === r9.length) return;
|
|
6738
|
-
const a2 = Hr(n2), i2 = this.documentManager.provides(), o2 = [],
|
|
6774
|
+
const a2 = Hr(n2), i2 = this.documentManager.provides(), o2 = [], l = (e15, t3, s3, n3) => {
|
|
6739
6775
|
var r10;
|
|
6740
6776
|
const a3 = i2.getDocument(e15);
|
|
6741
6777
|
if (!(null == (r10 = null == a3 ? void 0 : a3.pages) ? void 0 : r10.length)) return false;
|
|
6742
|
-
const
|
|
6778
|
+
const l2 = this.getDocumentScale(e15);
|
|
6743
6779
|
for (let i3 = 0; i3 < n3; i3++) {
|
|
6744
6780
|
const e16 = a3.pages[s3 + i3];
|
|
6745
|
-
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width *
|
|
6781
|
+
(null == e16 ? void 0 : e16.size) && o2.push({ localPageIndex: t3 + i3, width: e16.size.width * l2, height: e16.size.height * l2 });
|
|
6746
6782
|
}
|
|
6747
6783
|
return o2.length > 0;
|
|
6748
6784
|
};
|
|
6749
6785
|
if (a2) for (const h2 of a2.segments) {
|
|
6750
6786
|
if (!s2.isSegmentLoaded(e14, h2.index)) continue;
|
|
6751
6787
|
const t3 = h2.localPageEnd - h2.localPageStart + 1;
|
|
6752
|
-
|
|
6788
|
+
l(h2.documentId, h2.localPageStart, 0, t3);
|
|
6753
6789
|
}
|
|
6754
|
-
else s2.isSegmentLoaded(e14, 0) &&
|
|
6790
|
+
else s2.isSegmentLoaded(e14, 0) && l(e14, 0, 0, r9.length);
|
|
6755
6791
|
0 !== o2.length ? this.applyChapterPageSizes(e14, o2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
6756
6792
|
}
|
|
6757
6793
|
onScaleChanged(e14) {
|
|
@@ -6797,10 +6833,10 @@ const ha = class extends BasePlugin {
|
|
|
6797
6833
|
}
|
|
6798
6834
|
const a2 = [];
|
|
6799
6835
|
let i2 = n2, o2 = -1;
|
|
6800
|
-
for (let
|
|
6801
|
-
a2.push(
|
|
6802
|
-
const e15 = this.offsets[
|
|
6803
|
-
r10 > o2 && (o2 = r10, i2 =
|
|
6836
|
+
for (let l = n2; l < r9; l++) {
|
|
6837
|
+
a2.push(l);
|
|
6838
|
+
const e15 = this.offsets[l], n3 = e15 + this.getPageSize(l).height, r10 = Math.max(0, Math.min(n3, s2) - Math.max(e15, t2));
|
|
6839
|
+
r10 > o2 && (o2 = r10, i2 = l);
|
|
6804
6840
|
}
|
|
6805
6841
|
this.currentVisible = a2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: i2 }), this.schedulePushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
6806
6842
|
}
|
|
@@ -6832,9 +6868,9 @@ const ha = class extends BasePlugin {
|
|
|
6832
6868
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
6833
6869
|
const r9 = (null == s2 ? void 0 : s2.marginTop) ?? 80, a2 = this.virtualPageMap.atIndex(e14);
|
|
6834
6870
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
6835
|
-
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex),
|
|
6836
|
-
if (!i2 || !
|
|
6837
|
-
const h2 = i2.height /
|
|
6871
|
+
const i2 = this.pageSizes.get(e14), o2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), l = o2 ? null == (n2 = this.documentManager.provides().getDocument(o2.documentId)) ? void 0 : n2.pages[o2.pageIndex] : void 0;
|
|
6872
|
+
if (!i2 || !l) return void this.scrollToIndex(e14, s2);
|
|
6873
|
+
const h2 = i2.height / l.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * h2 - r9;
|
|
6838
6874
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
6839
6875
|
}
|
|
6840
6876
|
scrollToChapter(e14, t2) {
|
|
@@ -6965,9 +7001,9 @@ function pa(e14) {
|
|
|
6965
7001
|
return { x: t2.origin.x + t2.size.width, y: t2.origin.y + t2.size.height };
|
|
6966
7002
|
}
|
|
6967
7003
|
function ga(e14) {
|
|
6968
|
-
const { markerPdf: t2, lineRects: s2, sx: n2, sy: r9, cssPageWidth: a2, iconSize: i2, gapPx: o2 = 6 } = e14,
|
|
7004
|
+
const { markerPdf: t2, lineRects: s2, sx: n2, sy: r9, cssPageWidth: a2, iconSize: i2, gapPx: o2 = 6 } = e14, l = (s2 == null ? void 0 : s2.length) ? s2[s2.length - 1] : void 0;
|
|
6969
7005
|
let h2, d2;
|
|
6970
|
-
|
|
7006
|
+
l ? (h2 = (l.origin.x + l.size.width) * n2 + o2, d2 = l.origin.y * r9 + (l.size.height * r9 - i2) / 2) : (h2 = t2.x * n2 - i2 / 2, d2 = t2.y * r9 - i2 - o2);
|
|
6971
7007
|
const c2 = Math.max(0, a2 - i2 - 2);
|
|
6972
7008
|
return h2 > c2 && (h2 = c2), d2 < 0 && (d2 = 0), { left: h2, top: d2 };
|
|
6973
7009
|
}
|
|
@@ -7000,8 +7036,8 @@ const ma = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
|
|
|
7000
7036
|
let n3 = 1 / 0, r10 = 1 / 0, a3 = -1 / 0, i4 = -1 / 0;
|
|
7001
7037
|
for (const o3 of e16) n3 = Math.min(n3, o3.origin.x * t3), r10 = Math.min(r10, o3.origin.y * s3), a3 = Math.max(a3, (o3.origin.x + o3.size.width) * t3), i4 = Math.max(i4, (o3.origin.y + o3.size.height) * s3);
|
|
7002
7038
|
return { left: n3, top: r10, width: a3 - n3, height: i4 - r10 };
|
|
7003
|
-
})(e15.rectsPdfCoord, t2, s2),
|
|
7004
|
-
return { zoneLeft: h2, zoneTop: d3, zoneW: Math.min(a2.cssPageWidth, Math.max(o2.left + o2.width, r9 + n2) + 8) - h2, zoneH: Math.max(o2.top + o2.height, i3 + n2 + 6 +
|
|
7039
|
+
})(e15.rectsPdfCoord, t2, s2), l = m2.value === e15.noteId ? 72 : 0, h2 = Math.max(0, Math.min(o2.left, r9) - 8), d3 = Math.max(0, Math.min(o2.top, i3) - 8);
|
|
7040
|
+
return { zoneLeft: h2, zoneTop: d3, zoneW: Math.min(a2.cssPageWidth, Math.max(o2.left + o2.width, r9 + n2) + 8) - h2, zoneH: Math.max(o2.top + o2.height, i3 + n2 + 6 + l) + 8 - d3, iconLeft: r9, iconTop: i3, sx: t2, sy: s2 };
|
|
7005
7041
|
}
|
|
7006
7042
|
return (t2, s2) => unref(i2) && d2.value.length && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", ma, [(openBlock(true), createElementBlock(Fragment, null, renderList(d2.value, (e15) => (openBlock(), createElementBlock(Fragment, { key: e15.noteId }, [(openBlock(true), createElementBlock(Fragment, null, renderList(e15.rectsPdfCoord, (t3, s3) => (openBlock(), createElementBlock("div", { key: `${e15.noteId}-bg-${s3}`, style: normalizeStyle({ position: "absolute", left: t3.origin.x * y(e15).sx + "px", top: t3.origin.y * y(e15).sy + "px", width: t3.size.width * y(e15).sx + "px", height: t3.size.height * y(e15).sy + "px", background: C2.value, borderRadius: "2px", pointerEvents: "auto" }), onMouseenter: (t4) => g2.value = e15.noteId }, null, 44, fa))), 128)), g2.value === e15.noteId || m2.value === e15.noteId ? (openBlock(), createElementBlock("div", { key: 0, "data-note-marker-zone": e15.noteId, style: normalizeStyle({ position: "absolute", left: `${y(e15).zoneLeft}px`, top: `${y(e15).zoneTop}px`, width: `${y(e15).zoneW}px`, height: `${y(e15).zoneH}px`, pointerEvents: "auto", zIndex: 26 }), onMouseenter: (t3) => g2.value = e15.noteId, onMouseleave: (t3) => m2.value !== e15.noteId && (g2.value = null) }, [createElementVNode("button", { type: "button", title: "笔记", style: normalizeStyle({ position: "absolute", left: y(e15).iconLeft - y(e15).zoneLeft + "px", top: y(e15).iconTop - y(e15).zoneTop + "px", width: `${b2.value}px`, height: `${b2.value}px`, border: "none", borderRadius: "50%", background: "#f59e0b", color: "#fff", cursor: "pointer", fontSize: "11px", padding: 0 }), onMousedown: s2[0] || (s2[0] = withModifiers(() => {
|
|
7007
7043
|
}, ["stop"])), onClick: withModifiers((t3) => m2.value = m2.value === e15.noteId ? null : e15.noteId, ["stop"]) }, " 💬 ", 44, Pa), m2.value === e15.noteId ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: y(e15).iconLeft - y(e15).zoneLeft + "px", top: `${y(e15).iconTop - y(e15).zoneTop + b2.value + 4}px`, minWidth: "120px", padding: "6px", borderRadius: "8px", background: "#fff", border: "1px solid #e5e7eb", boxShadow: "0 4px 12px rgba(0,0,0,0.12)", zIndex: 30 }), onMousedown: s2[1] || (s2[1] = withModifiers(() => {
|
|
@@ -7086,8 +7122,8 @@ function Ta(e14, s2) {
|
|
|
7086
7122
|
return computed(() => {
|
|
7087
7123
|
const t2 = "string" == typeof e14 ? e14 : e14.value;
|
|
7088
7124
|
if (a2 && i2 && n2.value) return (e15) => {
|
|
7089
|
-
const { context: s3, rect: a3, placement: i3, menuWrapperProps: o2, selected:
|
|
7090
|
-
if (!
|
|
7125
|
+
const { context: s3, rect: a3, placement: i3, menuWrapperProps: o2, selected: l } = e15;
|
|
7126
|
+
if (!l || "annotation" !== s3.type) return h$1("span", o2);
|
|
7091
7127
|
if (s3.structurallyLocked) return h$1("span", o2);
|
|
7092
7128
|
if (h2 = s3.annotation.object.type, !Le$1.has(h2)) return h$1("span", o2);
|
|
7093
7129
|
var h2;
|
|
@@ -7106,7 +7142,7 @@ const Fa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
7106
7142
|
e16 && t3 && e16.isDocumentOpen(t3) && e16.setActiveDocument(t3);
|
|
7107
7143
|
}, { immediate: true });
|
|
7108
7144
|
})(r9);
|
|
7109
|
-
const { provides: i2 } = useCapability(DocumentManagerPlugin.id), { provides:
|
|
7145
|
+
const { provides: i2 } = useCapability(DocumentManagerPlugin.id), { provides: l } = useCapability(SelectionPlugin.id), d2 = computed(() => {
|
|
7110
7146
|
var _a2, _b;
|
|
7111
7147
|
return (_b = (_a2 = i2.value) == null ? void 0 : _a2.getDocument(r9.value)) == null ? void 0 : _b.pages[a2.value];
|
|
7112
7148
|
});
|
|
@@ -7117,9 +7153,9 @@ const Fa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
7117
7153
|
var _a3;
|
|
7118
7154
|
const r10 = { position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: ((_a3 = s3.placement) == null ? void 0 : _a3.suggestTop) ? -40 : s3.rect.size.height + 8 };
|
|
7119
7155
|
return h$1("div", s3.menuWrapperProps, [h$1("div", { style: r10 }, h$1("button", { type: "button", style: { padding: "6px 10px", fontSize: "12px", border: "1px solid #e2e8f0", borderRadius: "6px", background: "#fff", cursor: "pointer" }, onClick: () => {
|
|
7120
|
-
if (!
|
|
7121
|
-
const s4 =
|
|
7122
|
-
$a(
|
|
7156
|
+
if (!l.value) return;
|
|
7157
|
+
const s4 = l.value.getHighlightRectsForPage(La(e15), t2);
|
|
7158
|
+
$a(l.value.getSelectedText(t2), (t3) => {
|
|
7123
7159
|
n2((function(e16, t4, s5) {
|
|
7124
7160
|
return { chapterId: e16.chapterId, localPageIndex: e16.localPageIndex, globalPageIndex: e16.globalPageIndex, globalPageNumber: e16.globalPageNumber, rectsPdfCoord: t4, selectedText: s5 };
|
|
7125
7161
|
})(e15, s4, t3.join("\n")));
|
|
@@ -7134,7 +7170,7 @@ const Fa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
7134
7170
|
if (s3) return s3;
|
|
7135
7171
|
}
|
|
7136
7172
|
return t2.defaultMenu;
|
|
7137
|
-
}), p2 = Ta(r9, s2.features),
|
|
7173
|
+
}), p2 = Ta(r9, s2.features), v = computed(() => (function(e15, t2) {
|
|
7138
7174
|
if (e15 || t2) return (s3) => {
|
|
7139
7175
|
if (e15) {
|
|
7140
7176
|
const t3 = e15(s3);
|
|
@@ -7152,7 +7188,7 @@ const Fa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
7152
7188
|
if (t2) return { background: t2 };
|
|
7153
7189
|
})((_a2 = s2.features) == null ? void 0 : _a2.selectionToolbar);
|
|
7154
7190
|
});
|
|
7155
|
-
return (t2, s3) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id": r9.value }, { default: withCtx(() => [createVNode(unref(Rotate), { "document-id": r9.value, "page-index": a2.value, style: { backgroundColor: "#fff" } }, { default: withCtx(() => [createVNode(unref(PagePointerProvider), { "document-id": r9.value, "page-index": a2.value, style: normalizeStyle(unref(Ie)), onPointerdown: unref(be$1) }, { default: withCtx(() => [createVNode(unref(Sr), { "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-document-id": r9.value, "pdf-page-index": a2.value }, null, 8, ["chapter-id", "local-page-index", "pdf-document-id", "pdf-page-index"]), createVNode(unref(SelectionLayer), { "document-id": r9.value, "page-index": a2.value, "text-style": w2.value, "selection-menu": u2.value }, null, 8, ["document-id", "page-index", "text-style", "selection-menu"]), e14.showRedactionLayer ? (openBlock(), createBlock(unref(RedactionLayer), { key: 0, "document-id": r9.value, "page-index": a2.value, "selection-menu": e14.redactionSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"])) : createCommentVNode("", true), createVNode(unref(AnnotationLayer), { "document-id": r9.value, "page-index": a2.value, "selection-menu":
|
|
7191
|
+
return (t2, s3) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id": r9.value }, { default: withCtx(() => [createVNode(unref(Rotate), { "document-id": r9.value, "page-index": a2.value, style: { backgroundColor: "#fff" } }, { default: withCtx(() => [createVNode(unref(PagePointerProvider), { "document-id": r9.value, "page-index": a2.value, style: normalizeStyle(unref(Ie)), onPointerdown: unref(be$1) }, { default: withCtx(() => [createVNode(unref(Sr), { "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-document-id": r9.value, "pdf-page-index": a2.value }, null, 8, ["chapter-id", "local-page-index", "pdf-document-id", "pdf-page-index"]), createVNode(unref(SelectionLayer), { "document-id": r9.value, "page-index": a2.value, "text-style": w2.value, "selection-menu": u2.value }, null, 8, ["document-id", "page-index", "text-style", "selection-menu"]), e14.showRedactionLayer ? (openBlock(), createBlock(unref(RedactionLayer), { key: 0, "document-id": r9.value, "page-index": a2.value, "selection-menu": e14.redactionSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"])) : createCommentVNode("", true), createVNode(unref(AnnotationLayer), { "document-id": r9.value, "page-index": a2.value, "selection-menu": v.value }, null, 8, ["document-id", "page-index", "selection-menu"]), e14.showBookmarkMarkers && d2.value ? (openBlock(), createBlock(Ma, { key: 1, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.bookmarkMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), S.value ? (openBlock(), createBlock(resolveDynamicComponent(S.value), { key: 2 })) : createCommentVNode("", true), e14.showNoteMarkers && d2.value ? (openBlock(), createBlock(Ca, { key: 3, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.noteMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), renderSlot(t2.$slots, "default")]), _: 3 }, 8, ["document-id", "page-index", "style", "onPointerdown"])]), _: 3 }, 8, ["document-id", "page-index"])]), _: 3 }, 8, ["document-id"]));
|
|
7156
7192
|
} });
|
|
7157
7193
|
const Ua = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props: { item: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, hoverUi: {} }, setup(e14) {
|
|
7158
7194
|
const a2 = e14, i2 = computed(() => xa(a2.item)), { provides: d2 } = useCapability(SelectionPlugin.id), { provides: u2 } = useCapability(Sn.id), p2 = ref(null), g2 = ref(null), m2 = ref(null), I2 = ref(null), b2 = computed(() => {
|
|
@@ -7231,13 +7267,13 @@ const Ua = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
|
|
|
7231
7267
|
var _a2;
|
|
7232
7268
|
return unref(u2) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref: p2, style: { position: "absolute", inset: "0", zIndex: 14, pointerEvents: "none" } }, [k2.value && C2.value && !$2.value ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: `${k2.value.zoneLeft}px`, top: `${k2.value.zoneTop}px`, width: `${k2.value.size + 20}px`, height: `${(((_a2 = C2.value[C2.value.length - 1]) == null ? void 0 : _a2.size.height) ?? 0) * (e14.cssPageHeight / e14.pdfPageHeight) + k2.value.size + 12}px`, pointerEvents: "auto" }), onMouseenter: s2[0] || (s2[0] = (e15) => I2.value = C2.value), onMouseleave: s2[1] || (s2[1] = (e15) => I2.value = null) }, [createElementVNode("button", { type: "button", title: "添加书签", style: normalizeStyle({ position: "absolute", left: k2.value.iconLeft - k2.value.zoneLeft + "px", top: k2.value.iconTop - k2.value.zoneTop + "px", width: `${k2.value.size}px`, height: `${k2.value.size}px`, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", background: "#3b82f6", color: "#fff", border: "none", borderRadius: "4px", boxShadow: "0 2px 8px rgba(37, 99, 235, 0.45)", fontSize: "12px", padding: 0 }), onClick: withModifiers(D2, ["stop"]) }, " 🔖 ", 4)], 36)) : createCommentVNode("", true)], 512)) : createCommentVNode("", true);
|
|
7233
7269
|
};
|
|
7234
|
-
} }), Oa = { key: 0, width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" },
|
|
7235
|
-
const r9 = e14, a2 = n2, i2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }], d2 = computed(() => new Set(r9.hiddenBuiltinActions ?? [])), g2 = computed(() => !d2.value.has("copy")), f2 = computed(() => i2.filter((e15) => !d2.value.has(e15.id))),
|
|
7270
|
+
} }), Oa = { key: 0, width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, Ra = { key: 1, width: "24", height: "24", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "" }, Aa = { key: 0, x: "5", y: "4", width: "18", height: "20", rx: "3", fill: "#fde047" }, Na = { key: 1, d: "M6 22h16", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, za = { key: 2, d: "M6 22c2-2 3-2 5 0s3 2 5 0 3-2 5 0", stroke: "#dc2626", "stroke-width": "2", "stroke-linecap": "round", fill: "none" }, _a = { key: 3, d: "M5 14h18", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, Ga = { key: 2, width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, Va = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarIcons", props: { kind: {} }, setup: (e14) => (t2, s2) => "copy" === e14.kind ? (openBlock(), createElementBlock("svg", Oa, [...s2[0] || (s2[0] = [createElementVNode("rect", { x: "8.5", y: "8.5", width: "11", height: "13", rx: "2.25", fill: "#f1f5f9", stroke: "#94a3b8", "stroke-width": "1.35" }, null, -1), createElementVNode("rect", { x: "4.5", y: "3.5", width: "11", height: "13", rx: "2.25", fill: "#ffffff", stroke: "#334155", "stroke-width": "1.5" }, null, -1), createElementVNode("path", { d: "M7.5 7h5.5a1.5 1.5 0 0 1 1.5 1.5V14", stroke: "#64748b", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) : "note" !== e14.kind ? (openBlock(), createElementBlock("svg", Ra, ["highlight" === e14.kind ? (openBlock(), createElementBlock("rect", Aa)) : createCommentVNode("", true), s2[1] || (s2[1] = createElementVNode("text", { x: "14", y: "19", "text-anchor": "middle", "font-size": "15", "font-weight": "700", "font-family": "system-ui, -apple-system, sans-serif", fill: "#0f172a" }, " A ", -1)), "underline" === e14.kind ? (openBlock(), createElementBlock("path", Na)) : "squiggly" === e14.kind ? (openBlock(), createElementBlock("path", za)) : "strikeout" === e14.kind ? (openBlock(), createElementBlock("path", _a)) : createCommentVNode("", true)])) : (openBlock(), createElementBlock("svg", Ga, [...s2[2] || (s2[2] = [createElementVNode("path", { d: "M8 3h8l4 4v14H8V3z", fill: "#fef3c7", stroke: "#d97706", "stroke-width": "1.2", "stroke-linejoin": "round" }, null, -1), createElementVNode("path", { d: "M16 3v4h4", stroke: "#d97706", "stroke-width": "1.2" }, null, -1), createElementVNode("path", { d: "M10 12h6M10 16h4", stroke: "#92400e", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) }), qa = ["title", "aria-label", "onMouseenter", "onClick"], Ha = ["title", "onMouseenter", "onClick"], Wa = { style: { "font-size": "11px", "font-weight": "600" } }, Ba = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarCard", props: { placementAbove: { type: Boolean }, anchorHeight: {}, hiddenBuiltinActions: {}, extraActions: {}, renderCopyIcon: { type: Function } }, emits: ["action"], setup(e14, { emit: n2 }) {
|
|
7271
|
+
const r9 = e14, a2 = n2, i2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }], d2 = computed(() => new Set(r9.hiddenBuiltinActions ?? [])), g2 = computed(() => !d2.value.has("copy")), f2 = computed(() => i2.filter((e15) => !d2.value.has(e15.id))), v = computed(() => !d2.value.has("note")), I2 = computed(() => [...r9.extraActions ?? []].sort((e15, t2) => (e15.order ?? 0) - (t2.order ?? 0))), b2 = computed(() => f2.value.length > 0 || I2.value.length > 0), w2 = ref(null), M2 = computed(() => ({ position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: r9.placementAbove ? void 0 : `${r9.anchorHeight + 10}px`, bottom: r9.placementAbove ? `${r9.anchorHeight + 10}px` : void 0, display: "flex", alignItems: "center", gap: "2px", padding: "4px 6px", borderRadius: "12px", background: "rgba(255, 255, 255, 0.96)", border: "1px solid rgba(15, 23, 42, 0.06)", boxShadow: "0 2px 8px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.1)", backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)" }));
|
|
7236
7272
|
function x(e15, t2 = false) {
|
|
7237
7273
|
return { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px", padding: 0, margin: 0, border: "none", borderRadius: "8px", background: w2.value === e15 ? t2 ? "#fffbeb" : "#f1f5f9" : "transparent", color: t2 ? "#b45309" : "#334155", cursor: "pointer", flexShrink: 0, WebkitAppearance: "none", appearance: "none" };
|
|
7238
7274
|
}
|
|
7239
7275
|
const L2 = { width: "1px", height: "20px", margin: "0 4px", background: "rgba(15, 23, 42, 0.1)", flexShrink: 0 };
|
|
7240
|
-
return (t2, s2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(
|
|
7276
|
+
return (t2, s2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(M2.value) }, [g2.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("button", { type: "button", title: "复制", "aria-label": "复制", style: normalizeStyle(x("copy")), onMouseenter: s2[0] || (s2[0] = (e15) => w2.value = "copy"), onMouseleave: s2[1] || (s2[1] = (e15) => w2.value = null), onClick: s2[2] || (s2[2] = (e15) => a2("action", "copy")) }, [e14.renderCopyIcon ? (openBlock(), createBlock(resolveDynamicComponent(e14.renderCopyIcon), { key: 0 })) : (openBlock(), createBlock(Va, { key: 1, kind: "copy" }))], 36), b2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true)], 64)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(f2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, "aria-label": e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[3] || (s2[3] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createVNode(Va, { kind: e15.id }, null, 8, ["kind"])], 44, qa))), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(I2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[4] || (s2[4] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createElementVNode("span", Wa, toDisplayString(e15.label.slice(0, 2)), 1)], 44, Ha))), 128)), v.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [b2.value || g2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true), createElementVNode("button", { type: "button", title: "添加笔记", "aria-label": "添加笔记", style: normalizeStyle(x("note", true)), onMouseenter: s2[5] || (s2[5] = (e15) => w2.value = "note"), onMouseleave: s2[6] || (s2[6] = (e15) => w2.value = null), onClick: s2[7] || (s2[7] = (e15) => a2("action", "note")) }, [createVNode(Va, { kind: "note" })], 36)], 64)) : createCommentVNode("", true)], 4));
|
|
7241
7277
|
} }), Ka = { highlight: "highlight", underline: "underline", squiggly: "squiggly", strikeout: "strikeout" };
|
|
7242
7278
|
const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props: { className: {}, features: {}, buildSelectionMenu: {}, annotationSelectionMenu: {}, redactionSelectionMenu: {}, showNoteMarkers: { type: Boolean, default: true }, showBookmarkMarkers: { type: Boolean, default: true }, showRedactionLayer: { type: Boolean, default: false }, renderPageOverlay: {}, onExtraSelectionAction: {} }, setup(e14) {
|
|
7243
7279
|
const s2 = e14, n2 = computed(() => s2.features), { hostRef: r9 } = Zn(n2), a2 = computed(() => {
|
|
@@ -7268,7 +7304,7 @@ const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
7268
7304
|
}), m2 = computed(() => {
|
|
7269
7305
|
var _a2, _b;
|
|
7270
7306
|
return s2.showBookmarkMarkers && u2.value && false !== ((_b = (_a2 = s2.features) == null ? void 0 : _a2.bookmarks) == null ? void 0 : _b.enabled);
|
|
7271
|
-
}),
|
|
7307
|
+
}), v = computed(() => {
|
|
7272
7308
|
var _a2, _b;
|
|
7273
7309
|
return u2.value && false !== ((_b = (_a2 = s2.features) == null ? void 0 : _a2.bookmarks) == null ? void 0 : _b.enabled);
|
|
7274
7310
|
}), P2 = (function(e15, s3) {
|
|
@@ -7284,7 +7320,7 @@ const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
7284
7320
|
}), i3 = computed(() => {
|
|
7285
7321
|
var _a2, _b;
|
|
7286
7322
|
return !((_b = (_a2 = n3.value) == null ? void 0 : _a2.hiddenBuiltinActions) == null ? void 0 : _b.includes("copy"));
|
|
7287
|
-
}), { provides: o2 } = useCapability(SelectionPlugin.id), { provides:
|
|
7323
|
+
}), { provides: o2 } = useCapability(SelectionPlugin.id), { provides: l } = useCapability(AnnotationPlugin.id), { provides: h2 } = useCapability(Ss$1.id);
|
|
7288
7324
|
return computed(() => {
|
|
7289
7325
|
var _a2, _b, _c;
|
|
7290
7326
|
if (false !== ((_a2 = n3.value) == null ? void 0 : _a2.enabled) && (r10.value || a3.value || i3.value || ((_c = (_b = n3.value) == null ? void 0 : _b.extraActions) == null ? void 0 : _c.length))) return (t2) => {
|
|
@@ -7304,8 +7340,8 @@ const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
7304
7340
|
}
|
|
7305
7341
|
(_a4 = s3 == null ? void 0 : s3.onExtraAction) == null ? void 0 : _a4.call(s3, n4, t2);
|
|
7306
7342
|
} else {
|
|
7307
|
-
if (!o2.value || !
|
|
7308
|
-
xe$1(d2, Ka[n4],
|
|
7343
|
+
if (!o2.value || !l.value || !r10.value) return;
|
|
7344
|
+
xe$1(d2, Ka[n4], l.value, o2.value, (_c3 = (_b3 = e15()) == null ? void 0 : _b3.markup) == null ? void 0 : _c3.styles);
|
|
7309
7345
|
}
|
|
7310
7346
|
else {
|
|
7311
7347
|
if (!o2.value || !i3.value) return;
|
|
@@ -7326,7 +7362,7 @@ const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
7326
7362
|
function x(e15) {
|
|
7327
7363
|
var _a2;
|
|
7328
7364
|
const t2 = [];
|
|
7329
|
-
if (
|
|
7365
|
+
if (v.value) {
|
|
7330
7366
|
const n4 = (function(e16) {
|
|
7331
7367
|
var _a3, _b, _c, _d;
|
|
7332
7368
|
const t3 = xa(e16), n5 = La(e16), r10 = (_b = (_a3 = S.value) == null ? void 0 : _a3.getDocument(t3)) == null ? void 0 : _b.pages[n5];
|
|
@@ -7343,7 +7379,7 @@ const ja = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
7343
7379
|
}), _: 1 }, 8, ["class", "style"]), renderSlot(t2.$slots, "default")], 6));
|
|
7344
7380
|
} }), Xa = { key: 0, style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, width: "100%" } }, Za = /* @__PURE__ */ defineComponent({ __name: "ChapterPdfViewer", props: { engine: {}, options: {}, editorOptions: {}, features: {}, className: {}, viewportClassName: {}, onExtraSelectionAction: { type: Function } }, setup(e14) {
|
|
7345
7381
|
const s2 = e14, n2 = computed(() => (function(e15) {
|
|
7346
|
-
if (e15.options) return
|
|
7382
|
+
if (e15.options) return Nn(e15.options);
|
|
7347
7383
|
if (!e15.editorOptions) throw new Error("ChapterPdfViewer: 请传入 `options`(推荐),或同时传入 `editorOptions` 与 `features`");
|
|
7348
7384
|
const t2 = De$1(e15.features), { plugins: s3 } = Un({ ...e15.editorOptions, features: t2 });
|
|
7349
7385
|
return { plugins: s3, features: t2, editorOptions: { ...e15.editorOptions, features: t2 } };
|
|
@@ -7409,18 +7445,18 @@ function L(e14) {
|
|
|
7409
7445
|
const [t2, s2] = e14.localPageRange;
|
|
7410
7446
|
return s2 - t2 + 1;
|
|
7411
7447
|
}
|
|
7412
|
-
function
|
|
7448
|
+
function $$1(e14) {
|
|
7413
7449
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
7414
7450
|
}
|
|
7415
7451
|
function D(e14) {
|
|
7416
7452
|
if (null != e14.segmentPageThreshold && e14.segmentPageThreshold > 0) return e14.segmentPageThreshold;
|
|
7417
7453
|
const t2 = e14.source;
|
|
7418
|
-
return
|
|
7454
|
+
return $$1(t2) ? t2.segmentPageThreshold : null;
|
|
7419
7455
|
}
|
|
7420
7456
|
function E(e14, t2) {
|
|
7421
7457
|
return `${e14}#s${t2}`;
|
|
7422
7458
|
}
|
|
7423
|
-
function
|
|
7459
|
+
function U(e14) {
|
|
7424
7460
|
const t2 = e14.lastIndexOf("#s");
|
|
7425
7461
|
if (-1 === t2) return { chapterId: e14, segmentIndex: null };
|
|
7426
7462
|
const s2 = e14.slice(0, t2), r9 = Number.parseInt(e14.slice(t2 + 2), 10);
|
|
@@ -7429,10 +7465,10 @@ function F(e14) {
|
|
|
7429
7465
|
function T(e14, t2) {
|
|
7430
7466
|
return e14 <= 0 || t2 <= 0 ? 0 : Math.ceil(e14 / t2);
|
|
7431
7467
|
}
|
|
7432
|
-
function
|
|
7468
|
+
function F(e14) {
|
|
7433
7469
|
const t2 = D(e14);
|
|
7434
7470
|
if (!t2) return null;
|
|
7435
|
-
const s2 = L(e14), r9 = T(s2, t2), n2 =
|
|
7471
|
+
const s2 = L(e14), r9 = T(s2, t2), n2 = $$1(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
7436
7472
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
7437
7473
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
7438
7474
|
if (r10 >= s2) break;
|
|
@@ -7441,7 +7477,7 @@ function U(e14) {
|
|
|
7441
7477
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
7442
7478
|
}
|
|
7443
7479
|
function k(e14, t2) {
|
|
7444
|
-
const s2 =
|
|
7480
|
+
const s2 = F(e14);
|
|
7445
7481
|
if (!s2) return { documentId: e14.chapterId, pageIndex: t2 };
|
|
7446
7482
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
7447
7483
|
if (!r9) {
|
|
@@ -7451,7 +7487,7 @@ function k(e14, t2) {
|
|
|
7451
7487
|
return { documentId: r9.documentId, pageIndex: t2 - r9.localPageStart };
|
|
7452
7488
|
}
|
|
7453
7489
|
function O(e14, t2) {
|
|
7454
|
-
const s2 =
|
|
7490
|
+
const s2 = F(e14);
|
|
7455
7491
|
if (!s2) return 0;
|
|
7456
7492
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
7457
7493
|
return (null == r9 ? void 0 : r9.index) ?? Math.floor(t2 / s2.threshold);
|
|
@@ -7463,15 +7499,15 @@ function A(e14) {
|
|
|
7463
7499
|
const r9 = [], { chapterId: n2 } = e14, a2 = L(e14);
|
|
7464
7500
|
s2 <= 0 && r9.push(`${n2}: segmentPageThreshold must be > 0`);
|
|
7465
7501
|
const o2 = e14.source;
|
|
7466
|
-
if (
|
|
7502
|
+
if (!$$1(o2)) return r9;
|
|
7467
7503
|
0 === o2.urls.length && r9.push(`${n2}: source.urls must not be empty`);
|
|
7468
7504
|
const i2 = T(a2, s2);
|
|
7469
7505
|
o2.urls.length !== i2 && r9.push(`${n2}: source.urls.length (${o2.urls.length}) must equal ceil(pageCount/threshold) (${i2})`);
|
|
7470
7506
|
for (let h2 = 0; h2 < o2.urls.length; h2++) (null == (t2 = o2.urls[h2]) ? void 0 : t2.trim()) || r9.push(`${n2}: source.urls[${h2}] is empty`);
|
|
7471
7507
|
return r9;
|
|
7472
7508
|
}
|
|
7473
|
-
const
|
|
7474
|
-
function
|
|
7509
|
+
const R$1 = { kind: "first-wins" };
|
|
7510
|
+
function N(e14, t2, s2) {
|
|
7475
7511
|
if (1 === t2.length) return t2[0].chapterId;
|
|
7476
7512
|
switch (s2.kind) {
|
|
7477
7513
|
case "first-wins":
|
|
@@ -7523,8 +7559,8 @@ let G$1 = class G {
|
|
|
7523
7559
|
return s2 ? this._pages.indexOf(s2) : -1;
|
|
7524
7560
|
}
|
|
7525
7561
|
};
|
|
7526
|
-
function _$1(e14, t2 =
|
|
7527
|
-
const s2 = (function(e15, t3 =
|
|
7562
|
+
function _$1(e14, t2 = R$1) {
|
|
7563
|
+
const s2 = (function(e15, t3 = R$1) {
|
|
7528
7564
|
const s3 = /* @__PURE__ */ new Map();
|
|
7529
7565
|
for (const n3 of e15.chapters) {
|
|
7530
7566
|
const [e16, t4] = n3.globalPageRange;
|
|
@@ -7534,7 +7570,7 @@ function _$1(e14, t2 = N) {
|
|
|
7534
7570
|
}
|
|
7535
7571
|
}
|
|
7536
7572
|
const r10 = /* @__PURE__ */ new Map();
|
|
7537
|
-
for (const [n3, a3] of s3) r10.set(n3,
|
|
7573
|
+
for (const [n3, a3] of s3) r10.set(n3, N(n3, a3, t3));
|
|
7538
7574
|
return r10;
|
|
7539
7575
|
})(e14, t2), r9 = /* @__PURE__ */ new Map();
|
|
7540
7576
|
for (const i2 of e14.chapters) r9.set(i2.chapterId, i2);
|
|
@@ -7543,8 +7579,8 @@ function _$1(e14, t2 = N) {
|
|
|
7543
7579
|
for (const i2 of n2) {
|
|
7544
7580
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
7545
7581
|
if (!t3) continue;
|
|
7546
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
7547
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
7582
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
7583
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
7548
7584
|
}
|
|
7549
7585
|
return new G$1(a2);
|
|
7550
7586
|
}
|
|
@@ -7581,17 +7617,17 @@ let V = class {
|
|
|
7581
7617
|
};
|
|
7582
7618
|
const z = class r extends BasePlugin {
|
|
7583
7619
|
constructor(e14, r9) {
|
|
7584
|
-
super(e14, r9), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
7620
|
+
super(e14, r9), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = R$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterErrorMessages = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingChapterLoadPromises = /* @__PURE__ */ new Map(), this.pendingSegmentLoadPromises = /* @__PURE__ */ new Map(), this.chapterUrlsCache = /* @__PURE__ */ new Map(), this.pendingChapterUrlsPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.SEG_PRIO_PREFETCH_NEXT = 120, this.SEG_PRIO_CHAPTER_PREFETCH_BASE = 3e3, this.lastVisibleIndicesKey = "", this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
7585
7621
|
}
|
|
7586
7622
|
async initialize(e14) {
|
|
7587
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
7588
|
-
const { chapterId: t2 } =
|
|
7623
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? R$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
7624
|
+
const { chapterId: t2 } = U(e15.id);
|
|
7589
7625
|
this.findChapter(t2) && (this.passwordAttempts.delete(t2), this.syncChapterStatusFromDocuments(t2));
|
|
7590
7626
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
7591
|
-
const { chapterId: t2 } =
|
|
7627
|
+
const { chapterId: t2 } = U(e15);
|
|
7592
7628
|
this.findChapter(t2) && this.syncChapterStatusFromDocuments(t2);
|
|
7593
7629
|
}), this.documentManager.provides().onDocumentError((e15) => {
|
|
7594
|
-
const { chapterId: t2 } =
|
|
7630
|
+
const { chapterId: t2 } = U(e15.documentId);
|
|
7595
7631
|
this.findChapter(t2) && this.handleDocumentError(e15.documentId, t2, e15.code, e15.message);
|
|
7596
7632
|
})), this.segmentScheduler = new V(e14.maxConcurrentSegmentLoads ?? 2, (e15, t2) => this.loadSegmentNow(e15, t2)), this.setManifestInternal(e14.manifest), e14.unloadTimeoutMs && e14.unloadTimeoutMs > 0) {
|
|
7597
7633
|
const t2 = Math.max(5e3, Math.floor(e14.unloadTimeoutMs / 4));
|
|
@@ -7606,7 +7642,7 @@ const z = class r extends BasePlugin {
|
|
|
7606
7642
|
return s2 ? k(s2, t2) : null;
|
|
7607
7643
|
}, getSegmentPlan: (e14) => {
|
|
7608
7644
|
const t2 = this.findChapter(e14);
|
|
7609
|
-
return t2 ?
|
|
7645
|
+
return t2 ? F(t2) : null;
|
|
7610
7646
|
}, isSegmentLoaded: (e14, t2) => this.isSegmentDocumentOpen(e14, t2), isSegmentLoadPending: (e14, t2) => this.isSegmentLoadPending(e14, t2), getChapterErrorMessage: (e14) => this.chapterErrorMessages.get(e14), getChapterStatus: (e14) => this.chapterStatus.get(e14) ?? "idle", getChapter: (e14) => this.findChapter(e14), onChapterStatusChange: this.statusChange$.on, onManifestChange: this.manifestChange$.on };
|
|
7611
7647
|
}
|
|
7612
7648
|
destroy() {
|
|
@@ -7666,7 +7702,7 @@ const z = class r extends BasePlugin {
|
|
|
7666
7702
|
}
|
|
7667
7703
|
getSegmentPlanForChapter(e14) {
|
|
7668
7704
|
const t2 = this.findChapter(e14);
|
|
7669
|
-
return t2 ?
|
|
7705
|
+
return t2 ? F(t2) : null;
|
|
7670
7706
|
}
|
|
7671
7707
|
anySegmentOpen(e14) {
|
|
7672
7708
|
const t2 = this.getSegmentPlanForChapter(e14), s2 = this.documentManager.provides();
|
|
@@ -7714,7 +7750,7 @@ const z = class r extends BasePlugin {
|
|
|
7714
7750
|
if (t3 < 0) return;
|
|
7715
7751
|
const r10 = this.findChapter(e15);
|
|
7716
7752
|
if (!r10) return;
|
|
7717
|
-
const n3 =
|
|
7753
|
+
const n3 = F(r10);
|
|
7718
7754
|
if (n3 && t3 >= n3.segments.length) return;
|
|
7719
7755
|
const a3 = `${e15}:${t3}`, i3 = o2.get(a3);
|
|
7720
7756
|
(void 0 === i3 || s3 < i3) && o2.set(a3, s3);
|
|
@@ -7731,11 +7767,11 @@ const z = class r extends BasePlugin {
|
|
|
7731
7767
|
}
|
|
7732
7768
|
if (0 === a2.size) return;
|
|
7733
7769
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
7734
|
-
let
|
|
7770
|
+
let l = 0;
|
|
7735
7771
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
7736
7772
|
if (d2) {
|
|
7737
7773
|
const e15 = h2.indexOf(d2.chapterId);
|
|
7738
|
-
e15 >= 0 && (
|
|
7774
|
+
e15 >= 0 && (l = e15);
|
|
7739
7775
|
}
|
|
7740
7776
|
for (const c2 of a2) {
|
|
7741
7777
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -7744,7 +7780,7 @@ const z = class r extends BasePlugin {
|
|
|
7744
7780
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
7745
7781
|
const e16 = h2[t3];
|
|
7746
7782
|
this.chapterLastUsed.set(e16, s2);
|
|
7747
|
-
const r10 = Math.abs(t3 -
|
|
7783
|
+
const r10 = Math.abs(t3 - l);
|
|
7748
7784
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
7749
7785
|
const n3 = this.findChapter(e16);
|
|
7750
7786
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -7793,7 +7829,7 @@ const z = class r extends BasePlugin {
|
|
|
7793
7829
|
loadSegmentNow(e14, t2) {
|
|
7794
7830
|
const s2 = this.findChapter(e14);
|
|
7795
7831
|
if (!s2) return Promise.resolve("error");
|
|
7796
|
-
const r9 =
|
|
7832
|
+
const r9 = F(s2);
|
|
7797
7833
|
if (!r9) return 0 !== t2 ? Promise.resolve(this.isSegmentDocumentOpen(e14, 0) ? "loaded" : "error") : this.ensureSingleDocumentChapter(s2);
|
|
7798
7834
|
if (t2 < 0 || t2 >= r9.segments.length) return Promise.resolve("error");
|
|
7799
7835
|
const n2 = r9.segments[t2], a2 = n2.documentId;
|
|
@@ -7823,7 +7859,7 @@ const z = class r extends BasePlugin {
|
|
|
7823
7859
|
if (r9) return r9;
|
|
7824
7860
|
const n2 = (async () => {
|
|
7825
7861
|
const s3 = e14.source;
|
|
7826
|
-
if (
|
|
7862
|
+
if ($$1(s3)) {
|
|
7827
7863
|
const e15 = [...s3.urls];
|
|
7828
7864
|
return this.chapterUrlsCache.set(t2, e15), e15;
|
|
7829
7865
|
}
|
|
@@ -7854,11 +7890,15 @@ const z = class r extends BasePlugin {
|
|
|
7854
7890
|
const s3 = T(L(e14), a2);
|
|
7855
7891
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
7856
7892
|
const n3 = await this.resolveChapterUrls(e14);
|
|
7857
|
-
|
|
7893
|
+
if (n3.length !== s3) {
|
|
7894
|
+
const [t3, o2] = e14.globalPageRange;
|
|
7895
|
+
this.logger.warn(r.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
7896
|
+
}
|
|
7897
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
7858
7898
|
}
|
|
7859
7899
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
7860
7900
|
if (s2) {
|
|
7861
|
-
if (
|
|
7901
|
+
if ($$1(s2)) {
|
|
7862
7902
|
const s3 = await this.resolveChapterUrls(e14);
|
|
7863
7903
|
return this.openPayloadFromUrl(e14, t2, s3);
|
|
7864
7904
|
}
|
|
@@ -7878,8 +7918,8 @@ const z = class r extends BasePlugin {
|
|
|
7878
7918
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
7879
7919
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
7880
7920
|
try {
|
|
7881
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
7882
|
-
|
|
7921
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
7922
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
7883
7923
|
});
|
|
7884
7924
|
return await new Promise((e15, t3) => {
|
|
7885
7925
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -7906,7 +7946,7 @@ const z = class r extends BasePlugin {
|
|
|
7906
7946
|
async handleDocumentError(e14, t2, s2, n2) {
|
|
7907
7947
|
if (this.pendingSegmentLoadPromises.has(e14)) return;
|
|
7908
7948
|
if (s2 !== PdfErrorCode.Password) {
|
|
7909
|
-
const s3 = this.getSegmentPlanForChapter(t2), { segmentIndex: r9 } =
|
|
7949
|
+
const s3 = this.getSegmentPlanForChapter(t2), { segmentIndex: r9 } = U(e14);
|
|
7910
7950
|
return void (s3 && 0 !== r9 && null !== r9 || this.updateStatus(t2, "error"));
|
|
7911
7951
|
}
|
|
7912
7952
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
@@ -7927,7 +7967,7 @@ const z = class r extends BasePlugin {
|
|
|
7927
7967
|
});
|
|
7928
7968
|
}
|
|
7929
7969
|
closeChapter(e14) {
|
|
7930
|
-
const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), r9 = t2 ?
|
|
7970
|
+
const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), r9 = t2 ? F(t2) : null, n2 = (e15) => {
|
|
7931
7971
|
if (s2.isDocumentOpen(e15)) {
|
|
7932
7972
|
s2.closeDocument(e15).wait(() => {
|
|
7933
7973
|
}, () => {
|
|
@@ -8115,8 +8155,8 @@ function de(e14, t2 = ie) {
|
|
|
8115
8155
|
for (const i2 of n2) {
|
|
8116
8156
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
8117
8157
|
if (!t3) continue;
|
|
8118
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
8119
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
8158
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
8159
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
8120
8160
|
}
|
|
8121
8161
|
return new le(a2);
|
|
8122
8162
|
}
|
|
@@ -8303,11 +8343,11 @@ const ue = class r2 extends BasePlugin {
|
|
|
8303
8343
|
}
|
|
8304
8344
|
if (0 === a2.size) return;
|
|
8305
8345
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
8306
|
-
let
|
|
8346
|
+
let l = 0;
|
|
8307
8347
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
8308
8348
|
if (d2) {
|
|
8309
8349
|
const e15 = h2.indexOf(d2.chapterId);
|
|
8310
|
-
e15 >= 0 && (
|
|
8350
|
+
e15 >= 0 && (l = e15);
|
|
8311
8351
|
}
|
|
8312
8352
|
for (const c2 of a2) {
|
|
8313
8353
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -8316,7 +8356,7 @@ const ue = class r2 extends BasePlugin {
|
|
|
8316
8356
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
8317
8357
|
const e16 = h2[t3];
|
|
8318
8358
|
this.chapterLastUsed.set(e16, s2);
|
|
8319
|
-
const r10 = Math.abs(t3 -
|
|
8359
|
+
const r10 = Math.abs(t3 - l);
|
|
8320
8360
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
8321
8361
|
const n3 = this.findChapter(e16);
|
|
8322
8362
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -8426,7 +8466,11 @@ const ue = class r2 extends BasePlugin {
|
|
|
8426
8466
|
const s3 = se(Q(e14), a2);
|
|
8427
8467
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
8428
8468
|
const n3 = await this.resolveChapterUrls(e14);
|
|
8429
|
-
|
|
8469
|
+
if (n3.length !== s3) {
|
|
8470
|
+
const [t3, o2] = e14.globalPageRange;
|
|
8471
|
+
this.logger.warn(r2.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
8472
|
+
}
|
|
8473
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
8430
8474
|
}
|
|
8431
8475
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
8432
8476
|
if (s2) {
|
|
@@ -8450,8 +8494,8 @@ const ue = class r2 extends BasePlugin {
|
|
|
8450
8494
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
8451
8495
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
8452
8496
|
try {
|
|
8453
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
8454
|
-
|
|
8497
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
8498
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
8455
8499
|
});
|
|
8456
8500
|
return await new Promise((e15, t3) => {
|
|
8457
8501
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -8644,10 +8688,10 @@ const me = class extends BasePlugin {
|
|
|
8644
8688
|
}
|
|
8645
8689
|
return i2.length > 0;
|
|
8646
8690
|
};
|
|
8647
|
-
if (a2) for (const
|
|
8648
|
-
if (!s2.isSegmentLoaded(e14,
|
|
8649
|
-
const t3 =
|
|
8650
|
-
h2(
|
|
8691
|
+
if (a2) for (const l of a2.segments) {
|
|
8692
|
+
if (!s2.isSegmentLoaded(e14, l.index)) continue;
|
|
8693
|
+
const t3 = l.localPageEnd - l.localPageStart + 1;
|
|
8694
|
+
h2(l.documentId, l.localPageStart, 0, t3);
|
|
8651
8695
|
}
|
|
8652
8696
|
else s2.isSegmentLoaded(e14, 0) && h2(e14, 0, 0, n2.length);
|
|
8653
8697
|
0 !== i2.length ? this.applyChapterPageSizes(e14, i2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
@@ -8732,7 +8776,7 @@ const me = class extends BasePlugin {
|
|
|
8732
8776
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
8733
8777
|
const o2 = this.pageSizes.get(e14), i2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), h2 = i2 ? null == (r9 = this.documentManager.provides().getDocument(i2.documentId)) ? void 0 : r9.pages[i2.pageIndex] : void 0;
|
|
8734
8778
|
if (!o2 || !h2) return void this.scrollToIndex(e14, s2);
|
|
8735
|
-
const
|
|
8779
|
+
const l = o2.height / h2.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * l - n2;
|
|
8736
8780
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
8737
8781
|
}
|
|
8738
8782
|
scrollToChapter(e14, t2) {
|
|
@@ -8813,7 +8857,7 @@ function De(e14) {
|
|
|
8813
8857
|
return r9;
|
|
8814
8858
|
}
|
|
8815
8859
|
const Ee = { kind: "first-wins" };
|
|
8816
|
-
function
|
|
8860
|
+
function Ue2(e14, t2, s2) {
|
|
8817
8861
|
if (1 === t2.length) return t2[0].chapterId;
|
|
8818
8862
|
switch (s2.kind) {
|
|
8819
8863
|
case "first-wins":
|
|
@@ -8865,7 +8909,7 @@ let Te = class {
|
|
|
8865
8909
|
return s2 ? this._pages.indexOf(s2) : -1;
|
|
8866
8910
|
}
|
|
8867
8911
|
};
|
|
8868
|
-
function
|
|
8912
|
+
function Fe(e14, t2 = Ee) {
|
|
8869
8913
|
const s2 = (function(e15, t3 = Ee) {
|
|
8870
8914
|
const s3 = /* @__PURE__ */ new Map();
|
|
8871
8915
|
for (const n3 of e15.chapters) {
|
|
@@ -8876,7 +8920,7 @@ function Ue2(e14, t2 = Ee) {
|
|
|
8876
8920
|
}
|
|
8877
8921
|
}
|
|
8878
8922
|
const r10 = /* @__PURE__ */ new Map();
|
|
8879
|
-
for (const [n3, a3] of s3) r10.set(n3,
|
|
8923
|
+
for (const [n3, a3] of s3) r10.set(n3, Ue2(n3, a3, t3));
|
|
8880
8924
|
return r10;
|
|
8881
8925
|
})(e14, t2), r9 = /* @__PURE__ */ new Map();
|
|
8882
8926
|
for (const i2 of e14.chapters) r9.set(i2.chapterId, i2);
|
|
@@ -8885,8 +8929,8 @@ function Ue2(e14, t2 = Ee) {
|
|
|
8885
8929
|
for (const i2 of n2) {
|
|
8886
8930
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
8887
8931
|
if (!t3) continue;
|
|
8888
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
8889
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
8932
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
8933
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
8890
8934
|
}
|
|
8891
8935
|
return new Te(a2);
|
|
8892
8936
|
}
|
|
@@ -8990,7 +9034,7 @@ const Oe = class r3 extends BasePlugin {
|
|
|
8990
9034
|
const a2 = new Set(this.chapterStatus.keys()), o2 = new Set(s2.chapters.map((e15) => e15.chapterId));
|
|
8991
9035
|
for (const r9 of a2) o2.has(r9) || (this.closeChapter(r9), this.chapterStatus.delete(r9), this.chapterErrorMessages.delete(r9), this.chapterUrlsCache.delete(r9), this.pendingChapterUrlsPromises.delete(r9));
|
|
8992
9036
|
for (const r9 of s2.chapters) this.chapterStatus.has(r9.chapterId) || this.chapterStatus.set(r9.chapterId, "idle");
|
|
8993
|
-
this.manifest = s2, this.lastVisibleIndicesKey = "", null == (t2 = this.segmentScheduler) || t2.clear(), this.virtualPageMap =
|
|
9037
|
+
this.manifest = s2, this.lastVisibleIndicesKey = "", null == (t2 = this.segmentScheduler) || t2.clear(), this.virtualPageMap = Fe(s2, this.overlapStrategy), this.manifestChange$.emit({ manifest: s2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
8994
9038
|
}
|
|
8995
9039
|
eagerPrefetchFromManifest() {
|
|
8996
9040
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -9073,11 +9117,11 @@ const Oe = class r3 extends BasePlugin {
|
|
|
9073
9117
|
}
|
|
9074
9118
|
if (0 === a2.size) return;
|
|
9075
9119
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
9076
|
-
let
|
|
9120
|
+
let l = 0;
|
|
9077
9121
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
9078
9122
|
if (d2) {
|
|
9079
9123
|
const e15 = h2.indexOf(d2.chapterId);
|
|
9080
|
-
e15 >= 0 && (
|
|
9124
|
+
e15 >= 0 && (l = e15);
|
|
9081
9125
|
}
|
|
9082
9126
|
for (const c2 of a2) {
|
|
9083
9127
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -9086,7 +9130,7 @@ const Oe = class r3 extends BasePlugin {
|
|
|
9086
9130
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
9087
9131
|
const e16 = h2[t3];
|
|
9088
9132
|
this.chapterLastUsed.set(e16, s2);
|
|
9089
|
-
const r10 = Math.abs(t3 -
|
|
9133
|
+
const r10 = Math.abs(t3 - l);
|
|
9090
9134
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
9091
9135
|
const n3 = this.findChapter(e16);
|
|
9092
9136
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -9196,7 +9240,11 @@ const Oe = class r3 extends BasePlugin {
|
|
|
9196
9240
|
const s3 = Me(be(e14), a2);
|
|
9197
9241
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
9198
9242
|
const n3 = await this.resolveChapterUrls(e14);
|
|
9199
|
-
|
|
9243
|
+
if (n3.length !== s3) {
|
|
9244
|
+
const [t3, o2] = e14.globalPageRange;
|
|
9245
|
+
this.logger.warn(r3.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
9246
|
+
}
|
|
9247
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
9200
9248
|
}
|
|
9201
9249
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
9202
9250
|
if (s2) {
|
|
@@ -9220,8 +9268,8 @@ const Oe = class r3 extends BasePlugin {
|
|
|
9220
9268
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
9221
9269
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
9222
9270
|
try {
|
|
9223
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
9224
|
-
|
|
9271
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
9272
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
9225
9273
|
});
|
|
9226
9274
|
return await new Promise((e15, t3) => {
|
|
9227
9275
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -9287,10 +9335,10 @@ const Oe = class r3 extends BasePlugin {
|
|
|
9287
9335
|
};
|
|
9288
9336
|
Oe.id = "chapter-manager";
|
|
9289
9337
|
let Ae = Oe;
|
|
9290
|
-
function
|
|
9338
|
+
function Re(e14) {
|
|
9291
9339
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
9292
9340
|
}
|
|
9293
|
-
function
|
|
9341
|
+
function Ne(e14, t2) {
|
|
9294
9342
|
return `${e14}#s${t2}`;
|
|
9295
9343
|
}
|
|
9296
9344
|
function Ge(e14) {
|
|
@@ -9303,7 +9351,7 @@ function _e(e14) {
|
|
|
9303
9351
|
const t2 = (function(e15) {
|
|
9304
9352
|
if (null != e15.segmentPageThreshold && e15.segmentPageThreshold > 0) return e15.segmentPageThreshold;
|
|
9305
9353
|
const t3 = e15.source;
|
|
9306
|
-
return
|
|
9354
|
+
return Re(t3) ? t3.segmentPageThreshold : null;
|
|
9307
9355
|
})(e14);
|
|
9308
9356
|
if (!t2) return null;
|
|
9309
9357
|
const s2 = (function(e15) {
|
|
@@ -9311,11 +9359,11 @@ function _e(e14) {
|
|
|
9311
9359
|
return s3 - t3 + 1;
|
|
9312
9360
|
})(e14), r9 = (function(e15, t3) {
|
|
9313
9361
|
return e15 <= 0 || t3 <= 0 ? 0 : Math.ceil(e15 / t3);
|
|
9314
|
-
})(s2, t2), n2 =
|
|
9362
|
+
})(s2, t2), n2 = Re(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
9315
9363
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
9316
9364
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
9317
9365
|
if (r10 >= s2) break;
|
|
9318
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
9366
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Ne(e14.chapterId, o2) });
|
|
9319
9367
|
}
|
|
9320
9368
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
9321
9369
|
}
|
|
@@ -9457,8 +9505,8 @@ function et2(e14, t2 = Qe) {
|
|
|
9457
9505
|
for (const i2 of n2) {
|
|
9458
9506
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
9459
9507
|
if (!t3) continue;
|
|
9460
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
9461
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
9508
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
9509
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
9462
9510
|
}
|
|
9463
9511
|
return new Ze(a2);
|
|
9464
9512
|
}
|
|
@@ -9645,11 +9693,11 @@ const st2 = class r4 extends BasePlugin {
|
|
|
9645
9693
|
}
|
|
9646
9694
|
if (0 === a2.size) return;
|
|
9647
9695
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
9648
|
-
let
|
|
9696
|
+
let l = 0;
|
|
9649
9697
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
9650
9698
|
if (d2) {
|
|
9651
9699
|
const e15 = h2.indexOf(d2.chapterId);
|
|
9652
|
-
e15 >= 0 && (
|
|
9700
|
+
e15 >= 0 && (l = e15);
|
|
9653
9701
|
}
|
|
9654
9702
|
for (const c2 of a2) {
|
|
9655
9703
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -9658,7 +9706,7 @@ const st2 = class r4 extends BasePlugin {
|
|
|
9658
9706
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
9659
9707
|
const e16 = h2[t3];
|
|
9660
9708
|
this.chapterLastUsed.set(e16, s2);
|
|
9661
|
-
const r10 = Math.abs(t3 -
|
|
9709
|
+
const r10 = Math.abs(t3 - l);
|
|
9662
9710
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
9663
9711
|
const n3 = this.findChapter(e16);
|
|
9664
9712
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -9768,7 +9816,11 @@ const st2 = class r4 extends BasePlugin {
|
|
|
9768
9816
|
const s3 = Ke(Ve(e14), a2);
|
|
9769
9817
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
9770
9818
|
const n3 = await this.resolveChapterUrls(e14);
|
|
9771
|
-
|
|
9819
|
+
if (n3.length !== s3) {
|
|
9820
|
+
const [t3, o2] = e14.globalPageRange;
|
|
9821
|
+
this.logger.warn(r4.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
9822
|
+
}
|
|
9823
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
9772
9824
|
}
|
|
9773
9825
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
9774
9826
|
if (s2) {
|
|
@@ -9792,8 +9844,8 @@ const st2 = class r4 extends BasePlugin {
|
|
|
9792
9844
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
9793
9845
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
9794
9846
|
try {
|
|
9795
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
9796
|
-
|
|
9847
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
9848
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
9797
9849
|
});
|
|
9798
9850
|
return await new Promise((e15, t3) => {
|
|
9799
9851
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -9986,10 +10038,10 @@ const at = class extends BasePlugin {
|
|
|
9986
10038
|
}
|
|
9987
10039
|
return i2.length > 0;
|
|
9988
10040
|
};
|
|
9989
|
-
if (a2) for (const
|
|
9990
|
-
if (!s2.isSegmentLoaded(e14,
|
|
9991
|
-
const t3 =
|
|
9992
|
-
h2(
|
|
10041
|
+
if (a2) for (const l of a2.segments) {
|
|
10042
|
+
if (!s2.isSegmentLoaded(e14, l.index)) continue;
|
|
10043
|
+
const t3 = l.localPageEnd - l.localPageStart + 1;
|
|
10044
|
+
h2(l.documentId, l.localPageStart, 0, t3);
|
|
9993
10045
|
}
|
|
9994
10046
|
else s2.isSegmentLoaded(e14, 0) && h2(e14, 0, 0, n2.length);
|
|
9995
10047
|
0 !== i2.length ? this.applyChapterPageSizes(e14, i2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
@@ -10074,7 +10126,7 @@ const at = class extends BasePlugin {
|
|
|
10074
10126
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
10075
10127
|
const o2 = this.pageSizes.get(e14), i2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), h2 = i2 ? null == (r9 = this.documentManager.provides().getDocument(i2.documentId)) ? void 0 : r9.pages[i2.pageIndex] : void 0;
|
|
10076
10128
|
if (!o2 || !h2) return void this.scrollToIndex(e14, s2);
|
|
10077
|
-
const
|
|
10129
|
+
const l = o2.height / h2.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * l - n2;
|
|
10078
10130
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
10079
10131
|
}
|
|
10080
10132
|
scrollToChapter(e14, t2) {
|
|
@@ -10342,8 +10394,8 @@ function xt2(e14, t2 = yt) {
|
|
|
10342
10394
|
for (const i2 of n2) {
|
|
10343
10395
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
10344
10396
|
if (!t3) continue;
|
|
10345
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
10346
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
10397
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
10398
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
10347
10399
|
}
|
|
10348
10400
|
return new Mt(a2);
|
|
10349
10401
|
}
|
|
@@ -10530,11 +10582,11 @@ const $t = class r6 extends BasePlugin {
|
|
|
10530
10582
|
}
|
|
10531
10583
|
if (0 === a2.size) return;
|
|
10532
10584
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
10533
|
-
let
|
|
10585
|
+
let l = 0;
|
|
10534
10586
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
10535
10587
|
if (d2) {
|
|
10536
10588
|
const e15 = h2.indexOf(d2.chapterId);
|
|
10537
|
-
e15 >= 0 && (
|
|
10589
|
+
e15 >= 0 && (l = e15);
|
|
10538
10590
|
}
|
|
10539
10591
|
for (const c2 of a2) {
|
|
10540
10592
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -10543,7 +10595,7 @@ const $t = class r6 extends BasePlugin {
|
|
|
10543
10595
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
10544
10596
|
const e16 = h2[t3];
|
|
10545
10597
|
this.chapterLastUsed.set(e16, s2);
|
|
10546
|
-
const r10 = Math.abs(t3 -
|
|
10598
|
+
const r10 = Math.abs(t3 - l);
|
|
10547
10599
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
10548
10600
|
const n3 = this.findChapter(e16);
|
|
10549
10601
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -10653,7 +10705,11 @@ const $t = class r6 extends BasePlugin {
|
|
|
10653
10705
|
const s3 = vt(pt(e14), a2);
|
|
10654
10706
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
10655
10707
|
const n3 = await this.resolveChapterUrls(e14);
|
|
10656
|
-
|
|
10708
|
+
if (n3.length !== s3) {
|
|
10709
|
+
const [t3, o2] = e14.globalPageRange;
|
|
10710
|
+
this.logger.warn(r6.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
10711
|
+
}
|
|
10712
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
10657
10713
|
}
|
|
10658
10714
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
10659
10715
|
if (s2) {
|
|
@@ -10677,8 +10733,8 @@ const $t = class r6 extends BasePlugin {
|
|
|
10677
10733
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
10678
10734
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
10679
10735
|
try {
|
|
10680
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
10681
|
-
|
|
10736
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
10737
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
10682
10738
|
});
|
|
10683
10739
|
return await new Promise((e15, t3) => {
|
|
10684
10740
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -10747,7 +10803,7 @@ let Dt = $t;
|
|
|
10747
10803
|
function Et(e14) {
|
|
10748
10804
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
10749
10805
|
}
|
|
10750
|
-
function
|
|
10806
|
+
function Ut(e14, t2) {
|
|
10751
10807
|
return `${e14}#s${t2}`;
|
|
10752
10808
|
}
|
|
10753
10809
|
function Tt(e14) {
|
|
@@ -10756,7 +10812,7 @@ function Tt(e14) {
|
|
|
10756
10812
|
const s2 = e14.slice(0, t2), r9 = Number.parseInt(e14.slice(t2 + 2), 10);
|
|
10757
10813
|
return !Number.isFinite(r9) || r9 < 0 ? { chapterId: e14, segmentIndex: null } : { chapterId: s2, segmentIndex: r9 };
|
|
10758
10814
|
}
|
|
10759
|
-
function
|
|
10815
|
+
function Ft(e14) {
|
|
10760
10816
|
const t2 = (function(e15) {
|
|
10761
10817
|
if (null != e15.segmentPageThreshold && e15.segmentPageThreshold > 0) return e15.segmentPageThreshold;
|
|
10762
10818
|
const t3 = e15.source;
|
|
@@ -10772,7 +10828,7 @@ function Ut(e14) {
|
|
|
10772
10828
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
10773
10829
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
10774
10830
|
if (r10 >= s2) break;
|
|
10775
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
10831
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Ut(e14.chapterId, o2) });
|
|
10776
10832
|
}
|
|
10777
10833
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
10778
10834
|
}
|
|
@@ -10788,10 +10844,10 @@ function At(e14) {
|
|
|
10788
10844
|
const t2 = e14.source;
|
|
10789
10845
|
return Ot(t2) ? t2.segmentPageThreshold : null;
|
|
10790
10846
|
}
|
|
10791
|
-
function
|
|
10847
|
+
function Rt(e14, t2) {
|
|
10792
10848
|
return `${e14}#s${t2}`;
|
|
10793
10849
|
}
|
|
10794
|
-
function
|
|
10850
|
+
function Nt(e14) {
|
|
10795
10851
|
const t2 = e14.lastIndexOf("#s");
|
|
10796
10852
|
if (-1 === t2) return { chapterId: e14, segmentIndex: null };
|
|
10797
10853
|
const s2 = e14.slice(0, t2), r9 = Number.parseInt(e14.slice(t2 + 2), 10);
|
|
@@ -10807,7 +10863,7 @@ function _t(e14) {
|
|
|
10807
10863
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
10808
10864
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
10809
10865
|
if (r10 >= s2) break;
|
|
10810
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
10866
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Rt(e14.chapterId, o2) });
|
|
10811
10867
|
}
|
|
10812
10868
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
10813
10869
|
}
|
|
@@ -10914,8 +10970,8 @@ function Wt(e14, t2 = Ht) {
|
|
|
10914
10970
|
for (const i2 of n2) {
|
|
10915
10971
|
const e15 = s2.get(i2), t3 = r9.get(e15);
|
|
10916
10972
|
if (!t3) continue;
|
|
10917
|
-
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange,
|
|
10918
|
-
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex:
|
|
10973
|
+
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, l = h2 + (i2 - n3);
|
|
10974
|
+
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: l });
|
|
10919
10975
|
}
|
|
10920
10976
|
return new Kt2(a2);
|
|
10921
10977
|
}
|
|
@@ -10956,13 +11012,13 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
10956
11012
|
}
|
|
10957
11013
|
async initialize(e14) {
|
|
10958
11014
|
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Ht, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
10959
|
-
const { chapterId: t2 } =
|
|
11015
|
+
const { chapterId: t2 } = Nt(e15.id);
|
|
10960
11016
|
this.findChapter(t2) && (this.passwordAttempts.delete(t2), this.syncChapterStatusFromDocuments(t2));
|
|
10961
11017
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
10962
|
-
const { chapterId: t2 } =
|
|
11018
|
+
const { chapterId: t2 } = Nt(e15);
|
|
10963
11019
|
this.findChapter(t2) && this.syncChapterStatusFromDocuments(t2);
|
|
10964
11020
|
}), this.documentManager.provides().onDocumentError((e15) => {
|
|
10965
|
-
const { chapterId: t2 } =
|
|
11021
|
+
const { chapterId: t2 } = Nt(e15.documentId);
|
|
10966
11022
|
this.findChapter(t2) && this.handleDocumentError(e15.documentId, t2, e15.code, e15.message);
|
|
10967
11023
|
})), this.segmentScheduler = new jt(e14.maxConcurrentSegmentLoads ?? 2, (e15, t2) => this.loadSegmentNow(e15, t2)), this.setManifestInternal(e14.manifest), e14.unloadTimeoutMs && e14.unloadTimeoutMs > 0) {
|
|
10968
11024
|
const t2 = Math.max(5e3, Math.floor(e14.unloadTimeoutMs / 4));
|
|
@@ -11102,11 +11158,11 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
11102
11158
|
}
|
|
11103
11159
|
if (0 === a2.size) return;
|
|
11104
11160
|
const h2 = this.manifest.chapters.map((e15) => e15.chapterId);
|
|
11105
|
-
let
|
|
11161
|
+
let l = 0;
|
|
11106
11162
|
const d2 = this.virtualPageMap.atIndex(n2);
|
|
11107
11163
|
if (d2) {
|
|
11108
11164
|
const e15 = h2.indexOf(d2.chapterId);
|
|
11109
|
-
e15 >= 0 && (
|
|
11165
|
+
e15 >= 0 && (l = e15);
|
|
11110
11166
|
}
|
|
11111
11167
|
for (const c2 of a2) {
|
|
11112
11168
|
this.chapterLastUsed.set(c2, s2);
|
|
@@ -11115,7 +11171,7 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
11115
11171
|
if (t3 < 0 || t3 >= h2.length) continue;
|
|
11116
11172
|
const e16 = h2[t3];
|
|
11117
11173
|
this.chapterLastUsed.set(e16, s2);
|
|
11118
|
-
const r10 = Math.abs(t3 -
|
|
11174
|
+
const r10 = Math.abs(t3 - l);
|
|
11119
11175
|
i2(e16, 0, this.SEG_PRIO_CHAPTER_PREFETCH_BASE + 100 * r10);
|
|
11120
11176
|
const n3 = this.findChapter(e16);
|
|
11121
11177
|
n3 && this.resolveChapterUrls(n3).catch(() => {
|
|
@@ -11225,7 +11281,11 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
11225
11281
|
const s3 = Gt(kt2(e14), a2);
|
|
11226
11282
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
11227
11283
|
const n3 = await this.resolveChapterUrls(e14);
|
|
11228
|
-
|
|
11284
|
+
if (n3.length !== s3) {
|
|
11285
|
+
const [t3, o2] = e14.globalPageRange;
|
|
11286
|
+
this.logger.warn(r7.id, "SegmentUrlCount", `Chapter "${e14.chapterId}" loadChapterUrls returned ${n3.length} URL(s), expected ${s3} (= ceil((${o2}-${t3}+1) / ${a2})). Check globalPageRange [${t3},${o2}] and segmentPageThreshold.`);
|
|
11287
|
+
}
|
|
11288
|
+
return this.openPayloadFromUrl(e14, t2, n3);
|
|
11229
11289
|
}
|
|
11230
11290
|
if (0 !== t2) throw new Error(`Chapter "${e14.chapterId}" is not segmented`);
|
|
11231
11291
|
if (s2) {
|
|
@@ -11249,8 +11309,8 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
11249
11309
|
const n2 = e14.chapterId, a2 = (null == t2 ? void 0 : t2.index) ?? 0, o2 = (null == t2 ? void 0 : t2.documentId) ?? n2;
|
|
11250
11310
|
this.chapterErrorMessages.delete(n2), this.anySegmentOpen(n2) || this.updateStatus(n2, "loading"), this.chapterLastUsed.set(n2, Date.now());
|
|
11251
11311
|
try {
|
|
11252
|
-
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(),
|
|
11253
|
-
|
|
11312
|
+
const r9 = e14.encrypted && (null == (s2 = this.passwordProvider) ? void 0 : s2.getCachedPassword) ? this.passwordProvider.getCachedPassword(n2) : null, i2 = await this.resolvePdfPayload(e14, a2), h2 = this.documentManager.provides(), l = "url" in i2 ? h2.openDocumentUrl({ documentId: o2, url: i2.url, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }) : h2.openDocumentBuffer({ documentId: o2, buffer: i2.buffer, name: t2 ? `${e14.title} (${t2.index + 1})` : e14.title, password: r9 ?? void 0, autoActivate: false }), d2 = await new Promise((e15, t3) => {
|
|
11313
|
+
l.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
11254
11314
|
});
|
|
11255
11315
|
return await new Promise((e15, t3) => {
|
|
11256
11316
|
d2.task.wait(() => e15(), (e16) => t3(e16));
|
|
@@ -11277,7 +11337,7 @@ const Xt2 = class r7 extends BasePlugin {
|
|
|
11277
11337
|
async handleDocumentError(e14, t2, s2, n2) {
|
|
11278
11338
|
if (this.pendingSegmentLoadPromises.has(e14)) return;
|
|
11279
11339
|
if (s2 !== PdfErrorCode.Password) {
|
|
11280
|
-
const s3 = this.getSegmentPlanForChapter(t2), { segmentIndex: r9 } =
|
|
11340
|
+
const s3 = this.getSegmentPlanForChapter(t2), { segmentIndex: r9 } = Nt(e14);
|
|
11281
11341
|
return void (s3 && 0 !== r9 && null !== r9 || this.updateStatus(t2, "error"));
|
|
11282
11342
|
}
|
|
11283
11343
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
@@ -11343,7 +11403,7 @@ const Yt = class extends BasePlugin {
|
|
|
11343
11403
|
const s2 = this.chapterManager.provides(), r9 = s2.getChapter(e14);
|
|
11344
11404
|
if (!r9) return true;
|
|
11345
11405
|
const n2 = (function(e15, t3) {
|
|
11346
|
-
const s3 =
|
|
11406
|
+
const s3 = Ft(e15);
|
|
11347
11407
|
if (!s3) return 0;
|
|
11348
11408
|
const r10 = s3.segments.find((e16) => t3 >= e16.localPageStart && t3 <= e16.localPageEnd);
|
|
11349
11409
|
return (null == r10 ? void 0 : r10.index) ?? Math.floor(t3 / s3.threshold);
|
|
@@ -11432,7 +11492,7 @@ const Yt = class extends BasePlugin {
|
|
|
11432
11492
|
if (!this.virtualPageMap) return;
|
|
11433
11493
|
const s2 = this.chapterManager.provides(), r9 = s2.getChapter(e14), n2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
11434
11494
|
if (!r9 || 0 === n2.length) return;
|
|
11435
|
-
const a2 =
|
|
11495
|
+
const a2 = Ft(r9), o2 = this.documentManager.provides(), i2 = [], h2 = (e15, t3, s3, r10) => {
|
|
11436
11496
|
var n3;
|
|
11437
11497
|
const a3 = o2.getDocument(e15);
|
|
11438
11498
|
if (!(null == (n3 = null == a3 ? void 0 : a3.pages) ? void 0 : n3.length)) return false;
|
|
@@ -11443,10 +11503,10 @@ const Yt = class extends BasePlugin {
|
|
|
11443
11503
|
}
|
|
11444
11504
|
return i2.length > 0;
|
|
11445
11505
|
};
|
|
11446
|
-
if (a2) for (const
|
|
11447
|
-
if (!s2.isSegmentLoaded(e14,
|
|
11448
|
-
const t3 =
|
|
11449
|
-
h2(
|
|
11506
|
+
if (a2) for (const l of a2.segments) {
|
|
11507
|
+
if (!s2.isSegmentLoaded(e14, l.index)) continue;
|
|
11508
|
+
const t3 = l.localPageEnd - l.localPageStart + 1;
|
|
11509
|
+
h2(l.documentId, l.localPageStart, 0, t3);
|
|
11450
11510
|
}
|
|
11451
11511
|
else s2.isSegmentLoaded(e14, 0) && h2(e14, 0, 0, n2.length);
|
|
11452
11512
|
0 !== i2.length ? this.applyChapterPageSizes(e14, i2) : t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1));
|
|
@@ -11531,7 +11591,7 @@ const Yt = class extends BasePlugin {
|
|
|
11531
11591
|
if (!a2) return void this.scrollToIndex(e14, s2);
|
|
11532
11592
|
const o2 = this.pageSizes.get(e14), i2 = this.chapterManager.provides().resolvePageDocument(a2.chapterId, a2.localPageIndex), h2 = i2 ? null == (r9 = this.documentManager.provides().getDocument(i2.documentId)) ? void 0 : r9.pages[i2.pageIndex] : void 0;
|
|
11533
11593
|
if (!o2 || !h2) return void this.scrollToIndex(e14, s2);
|
|
11534
|
-
const
|
|
11594
|
+
const l = o2.height / h2.size.height, d2 = (this.offsets[e14] ?? 0) + t2 * l - n2;
|
|
11535
11595
|
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == s2 ? void 0 : s2.behavior) ?? "auto" });
|
|
11536
11596
|
}
|
|
11537
11597
|
scrollToChapter(e14, t2) {
|
|
@@ -11703,7 +11763,7 @@ function Ss(e14, t2) {
|
|
|
11703
11763
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
11704
11764
|
return (r9 == null ? void 0 : r9.index) ?? Math.floor(t2 / s2.threshold);
|
|
11705
11765
|
}
|
|
11706
|
-
async function
|
|
11766
|
+
async function Us(e14) {
|
|
11707
11767
|
var _a2;
|
|
11708
11768
|
const t2 = e14.trim();
|
|
11709
11769
|
if (!t2) return false;
|
|
@@ -11721,7 +11781,7 @@ async function Fs(e14) {
|
|
|
11721
11781
|
return false;
|
|
11722
11782
|
}
|
|
11723
11783
|
}
|
|
11724
|
-
const
|
|
11784
|
+
const Fs = 1;
|
|
11725
11785
|
function ks(e14) {
|
|
11726
11786
|
const t2 = new Uint8Array(e14);
|
|
11727
11787
|
let s2 = "";
|
|
@@ -11747,10 +11807,10 @@ function As(e14) {
|
|
|
11747
11807
|
return { annotation: e15.annotation, ctx: { data: t2, ...e15.ctx.mimeType ? { mimeType: e15.ctx.mimeType } : {} } };
|
|
11748
11808
|
});
|
|
11749
11809
|
}
|
|
11750
|
-
function
|
|
11810
|
+
function Rs(e14) {
|
|
11751
11811
|
return { bookmarks: false !== (e14 == null ? void 0 : e14.bookmarks), notes: false !== (e14 == null ? void 0 : e14.notes), markup: false !== (e14 == null ? void 0 : e14.markup) };
|
|
11752
11812
|
}
|
|
11753
|
-
function
|
|
11813
|
+
function Ns(e14) {
|
|
11754
11814
|
return new Promise((t2, s2) => {
|
|
11755
11815
|
e14.wait((e15) => t2(e15), (e15) => s2(e15));
|
|
11756
11816
|
});
|
|
@@ -11766,7 +11826,7 @@ async function _s2(e14, t2, s2) {
|
|
|
11766
11826
|
if ("loaded" !== r9) throw new Error(`章节 ${t2} 未加载成功(${r9}),无法导入/导出划线`);
|
|
11767
11827
|
}
|
|
11768
11828
|
async function Vs2(e14, t2, s2) {
|
|
11769
|
-
const r9 =
|
|
11829
|
+
const r9 = Rs(s2), { annotation: n2, note: a2, bookmark: o2, chapterManager: i2 } = Gs(e14), h2 = { chapterId: t2 };
|
|
11770
11830
|
if (r9.bookmarks) {
|
|
11771
11831
|
if (!o2) throw new Error("paragraph-bookmark 插件未注册");
|
|
11772
11832
|
h2.bookmarks = o2.listBookmarksForChapter(t2);
|
|
@@ -11780,11 +11840,11 @@ async function Vs2(e14, t2, s2) {
|
|
|
11780
11840
|
await _s2(i2, t2, false !== (s2 == null ? void 0 : s2.ensureChapterLoaded));
|
|
11781
11841
|
const e15 = await (async function(e16, t3, s3) {
|
|
11782
11842
|
const r10 = t3.getSegmentPlan(s3);
|
|
11783
|
-
if (!r10) return
|
|
11843
|
+
if (!r10) return Ns(e16.forDocument(s3).exportAnnotations());
|
|
11784
11844
|
const n3 = [];
|
|
11785
11845
|
for (const a3 of r10.segments) {
|
|
11786
11846
|
if (!t3.isSegmentLoaded(s3, a3.index)) continue;
|
|
11787
|
-
const r11 = await
|
|
11847
|
+
const r11 = await Ns(e16.forDocument(a3.documentId).exportAnnotations());
|
|
11788
11848
|
for (const e17 of r11) {
|
|
11789
11849
|
const t4 = e17.annotation.pageIndex;
|
|
11790
11850
|
n3.push({ ...e17, annotation: { ...e17.annotation, pageIndex: t4 + a3.localPageStart } });
|
|
@@ -11805,20 +11865,20 @@ async function zs(e14, t2, s2) {
|
|
|
11805
11865
|
return { version: 1, exportedAt: /* @__PURE__ */ (/* @__PURE__ */ new Date()).toISOString(), chapters: r9 };
|
|
11806
11866
|
}
|
|
11807
11867
|
async function qs(e14, t2, s2) {
|
|
11808
|
-
const r9 =
|
|
11868
|
+
const r9 = Rs(s2), n2 = (s2 == null ? void 0 : s2.mode) ?? "replace", { annotation: a2, note: o2, bookmark: i2, chapterManager: h2 } = Gs(e14), l = t2.chapterId;
|
|
11809
11869
|
if (r9.bookmarks && t2.bookmarks) {
|
|
11810
11870
|
if (!i2) throw new Error("paragraph-bookmark 插件未注册");
|
|
11811
|
-
if ("replace" === n2) i2.replaceBookmarksForChapter(
|
|
11871
|
+
if ("replace" === n2) i2.replaceBookmarksForChapter(l, t2.bookmarks);
|
|
11812
11872
|
else for (const e15 of t2.bookmarks) i2.addBookmark(e15);
|
|
11813
11873
|
}
|
|
11814
11874
|
if (r9.notes && t2.notes) {
|
|
11815
11875
|
if (!o2) throw new Error("note 插件未注册");
|
|
11816
|
-
if ("replace" === n2) o2.replaceNotesForChapter(
|
|
11876
|
+
if ("replace" === n2) o2.replaceNotesForChapter(l, t2.notes);
|
|
11817
11877
|
else for (const e15 of t2.notes) o2.registerNote(e15);
|
|
11818
11878
|
}
|
|
11819
11879
|
if (r9.markup && t2.markup) {
|
|
11820
11880
|
if (!a2) throw new Error("annotation 插件未注册");
|
|
11821
|
-
await _s2(h2,
|
|
11881
|
+
await _s2(h2, l, false !== (s2 == null ? void 0 : s2.ensureChapterLoaded));
|
|
11822
11882
|
!(function(e15, t3, s3, r10, n3) {
|
|
11823
11883
|
const a3 = t3.getSegmentPlan(s3);
|
|
11824
11884
|
if (!a3) {
|
|
@@ -11838,7 +11898,7 @@ async function qs(e14, t2, s2) {
|
|
|
11838
11898
|
const t4 = e15.forDocument(h3.documentId), s4 = i3.get(h3.index) ?? [];
|
|
11839
11899
|
"replace" === n3 && t4.deleteAllAnnotations(), s4.length > 0 && t4.importAnnotations(s4);
|
|
11840
11900
|
}
|
|
11841
|
-
})(a2, h2,
|
|
11901
|
+
})(a2, h2, l, As(t2.markup), n2);
|
|
11842
11902
|
}
|
|
11843
11903
|
(s2 == null ? void 0 : s2.persistNotes) && o2 && await s2.persistNotes(o2.listAllNotes()), (s2 == null ? void 0 : s2.persistBookmarks) && i2 && await s2.persistBookmarks(i2.listBookmarks());
|
|
11844
11904
|
}
|
|
@@ -11910,19 +11970,19 @@ function o(t2) {
|
|
|
11910
11970
|
function c(e22, t2) {
|
|
11911
11971
|
return e22 <= 0 || t2 <= 0 ? 0 : Math.ceil(e22 / t2);
|
|
11912
11972
|
}
|
|
11913
|
-
function
|
|
11973
|
+
function u(e22) {
|
|
11914
11974
|
const s2 = r8(e22);
|
|
11915
11975
|
if (!s2) return null;
|
|
11916
|
-
const o2 = t(e22),
|
|
11917
|
-
for (let t2 = 0; t2 <
|
|
11976
|
+
const o2 = t(e22), l = c(o2, s2), u2 = n(e22.source) ? e22.source.urls : void 0, h2 = [];
|
|
11977
|
+
for (let t2 = 0; t2 < l; t2++) {
|
|
11918
11978
|
const n2 = t2 * s2, r22 = Math.min(n2 + s2 - 1, o2 - 1);
|
|
11919
11979
|
if (n2 >= o2) break;
|
|
11920
11980
|
h2.push({ index: t2, url: (u2 == null ? void 0 : u2[t2]) ?? "", localPageStart: n2, localPageEnd: r22, documentId: a(e22.chapterId, t2) });
|
|
11921
11981
|
}
|
|
11922
11982
|
return { chapterId: e22.chapterId, threshold: s2, pageCount: o2, segments: h2 };
|
|
11923
11983
|
}
|
|
11924
|
-
function
|
|
11925
|
-
const n2 =
|
|
11984
|
+
function h(e22, t2) {
|
|
11985
|
+
const n2 = u(e22);
|
|
11926
11986
|
if (!n2) return { documentId: e22.chapterId, pageIndex: t2 };
|
|
11927
11987
|
const r22 = n2.segments.find((e32) => t2 >= e32.localPageStart && t2 <= e32.localPageEnd);
|
|
11928
11988
|
if (!r22) {
|
|
@@ -11931,37 +11991,37 @@ function u(e22, t2) {
|
|
|
11931
11991
|
}
|
|
11932
11992
|
return { documentId: r22.documentId, pageIndex: t2 - r22.localPageStart };
|
|
11933
11993
|
}
|
|
11934
|
-
function
|
|
11935
|
-
const n2 =
|
|
11994
|
+
function i(e22, t2) {
|
|
11995
|
+
const n2 = u(e22);
|
|
11936
11996
|
if (!n2) return 0;
|
|
11937
11997
|
const r22 = n2.segments.find((e32) => t2 >= e32.localPageStart && t2 <= e32.localPageEnd);
|
|
11938
11998
|
return (r22 == null ? void 0 : r22.index) ?? Math.floor(t2 / n2.threshold);
|
|
11939
11999
|
}
|
|
11940
|
-
function
|
|
12000
|
+
function g(e22) {
|
|
11941
12001
|
var _a2;
|
|
11942
12002
|
const s2 = r8(e22);
|
|
11943
12003
|
if (!s2) return [];
|
|
11944
|
-
const a2 = [], { chapterId: o2 } = e22,
|
|
12004
|
+
const a2 = [], { chapterId: o2 } = e22, l = t(e22);
|
|
11945
12005
|
s2 <= 0 && a2.push(`${o2}: segmentPageThreshold must be > 0`);
|
|
11946
12006
|
const u2 = e22.source;
|
|
11947
12007
|
if (!n(u2)) return a2;
|
|
11948
12008
|
0 === u2.urls.length && a2.push(`${o2}: source.urls must not be empty`);
|
|
11949
|
-
const h2 = c(
|
|
12009
|
+
const h2 = c(l, s2);
|
|
11950
12010
|
u2.urls.length !== h2 && a2.push(`${o2}: source.urls.length (${u2.urls.length}) must equal ceil(pageCount/threshold) (${h2})`);
|
|
11951
12011
|
for (let t2 = 0; t2 < u2.urls.length; t2++) ((_a2 = u2.urls[t2]) == null ? void 0 : _a2.trim()) || a2.push(`${o2}: source.urls[${t2}] is empty`);
|
|
11952
12012
|
return a2;
|
|
11953
12013
|
}
|
|
11954
|
-
function
|
|
12014
|
+
function d(e22) {
|
|
11955
12015
|
const t2 = [], n2 = /* @__PURE__ */ new Set();
|
|
11956
12016
|
for (const r22 of e22.chapters) {
|
|
11957
12017
|
n2.has(r22.chapterId) && t2.push(`Duplicate chapterId: ${r22.chapterId}`), n2.add(r22.chapterId);
|
|
11958
12018
|
const [e32, s2] = r22.globalPageRange, [a2, o2] = r22.localPageRange;
|
|
11959
12019
|
if (e32 > s2 && t2.push(`${r22.chapterId}: invalid globalPageRange [${e32},${s2}]`), a2 > o2 && t2.push(`${r22.chapterId}: invalid localPageRange [${a2},${o2}]`), s2 - e32 !== o2 - a2 && t2.push(`${r22.chapterId}: page-count mismatch (global ${s2 - e32 + 1} vs local ${o2 - a2 + 1})`), r22.ownedGlobalPages) for (const n3 of r22.ownedGlobalPages) (n3 < e32 || n3 > s2) && t2.push(`${r22.chapterId}: ownedGlobalPages contains ${n3} outside range`);
|
|
11960
|
-
t2.push(...
|
|
12020
|
+
t2.push(...g(r22));
|
|
11961
12021
|
}
|
|
11962
12022
|
return t2;
|
|
11963
12023
|
}
|
|
11964
|
-
function
|
|
12024
|
+
function p(e22) {
|
|
11965
12025
|
const t2 = [], n2 = (e32) => {
|
|
11966
12026
|
for (const r22 of e32) {
|
|
11967
12027
|
const { children: e42, ...s2 } = r22;
|
|
@@ -11970,17 +12030,17 @@ function d(e22) {
|
|
|
11970
12030
|
};
|
|
11971
12031
|
return n2(e22), t2;
|
|
11972
12032
|
}
|
|
11973
|
-
function
|
|
12033
|
+
function f(e22) {
|
|
11974
12034
|
var _a2;
|
|
11975
12035
|
for (const t2 of e22) if ((_a2 = t2.children) == null ? void 0 : _a2.length) return true;
|
|
11976
12036
|
return false;
|
|
11977
12037
|
}
|
|
11978
|
-
function
|
|
11979
|
-
const t2 =
|
|
12038
|
+
function P(e22) {
|
|
12039
|
+
const t2 = p(e22.chapters);
|
|
11980
12040
|
return t2.length === e22.chapters.length ? e22 : { ...e22, chapters: t2 };
|
|
11981
12041
|
}
|
|
11982
|
-
const
|
|
11983
|
-
function
|
|
12042
|
+
const m$1 = { kind: "first-wins" };
|
|
12043
|
+
function I(e22, t2 = m$1) {
|
|
11984
12044
|
const n2 = /* @__PURE__ */ new Map();
|
|
11985
12045
|
for (const s2 of e22.chapters) {
|
|
11986
12046
|
const [e32, t3] = s2.globalPageRange;
|
|
@@ -11990,10 +12050,10 @@ function m(e22, t2 = P$1) {
|
|
|
11990
12050
|
}
|
|
11991
12051
|
}
|
|
11992
12052
|
const r22 = /* @__PURE__ */ new Map();
|
|
11993
|
-
for (const [s2, a2] of n2) r22.set(s2,
|
|
12053
|
+
for (const [s2, a2] of n2) r22.set(s2, b(s2, a2, t2));
|
|
11994
12054
|
return r22;
|
|
11995
12055
|
}
|
|
11996
|
-
function
|
|
12056
|
+
function b(e22, t2, n2) {
|
|
11997
12057
|
if (1 === t2.length) return t2[0].chapterId;
|
|
11998
12058
|
switch (n2.kind) {
|
|
11999
12059
|
case "first-wins":
|
|
@@ -12011,7 +12071,7 @@ function I(e22, t2, n2) {
|
|
|
12011
12071
|
return n2.resolve(e22, t2);
|
|
12012
12072
|
}
|
|
12013
12073
|
}
|
|
12014
|
-
class
|
|
12074
|
+
class w {
|
|
12015
12075
|
constructor(e22) {
|
|
12016
12076
|
this._pages = e22, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
12017
12077
|
for (const t2 of e22) {
|
|
@@ -12045,18 +12105,18 @@ class b {
|
|
|
12045
12105
|
return t2 ? this._pages.indexOf(t2) : -1;
|
|
12046
12106
|
}
|
|
12047
12107
|
}
|
|
12048
|
-
function
|
|
12049
|
-
const n2 =
|
|
12108
|
+
function $(e22, t2 = m$1) {
|
|
12109
|
+
const n2 = I(e22, t2), r22 = /* @__PURE__ */ new Map();
|
|
12050
12110
|
for (const c2 of e22.chapters) r22.set(c2.chapterId, c2);
|
|
12051
12111
|
const s2 = Array.from(n2.keys()).sort((e32, t3) => e32 - t3), a2 = [];
|
|
12052
12112
|
let o2 = 0;
|
|
12053
12113
|
for (const c2 of s2) {
|
|
12054
12114
|
const e32 = n2.get(c2), t3 = r22.get(e32);
|
|
12055
12115
|
if (!t3) continue;
|
|
12056
|
-
const [s22] = t3.globalPageRange, [
|
|
12116
|
+
const [s22] = t3.globalPageRange, [l] = t3.localPageRange, u2 = l + (c2 - s22);
|
|
12057
12117
|
a2.push({ globalPageIndex: o2++, globalPageNumber: c2, chapterId: e32, localPageIndex: u2 });
|
|
12058
12118
|
}
|
|
12059
|
-
return new
|
|
12119
|
+
return new w(a2);
|
|
12060
12120
|
}
|
|
12061
12121
|
class SegmentLoadScheduler {
|
|
12062
12122
|
constructor(maxConcurrent, run) {
|
|
@@ -12113,7 +12173,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12113
12173
|
super(id, registry);
|
|
12114
12174
|
this.statusChange$ = createBehaviorEmitter();
|
|
12115
12175
|
this.manifestChange$ = createEmitter();
|
|
12116
|
-
this.overlapStrategy =
|
|
12176
|
+
this.overlapStrategy = m$1;
|
|
12117
12177
|
this.chapterStatus = /* @__PURE__ */ new Map();
|
|
12118
12178
|
this.chapterErrorMessages = /* @__PURE__ */ new Map();
|
|
12119
12179
|
this.chapterLastUsed = /* @__PURE__ */ new Map();
|
|
@@ -12132,7 +12192,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12132
12192
|
async initialize(config) {
|
|
12133
12193
|
this.config = config;
|
|
12134
12194
|
this.passwordProvider = config.passwordProvider;
|
|
12135
|
-
this.overlapStrategy = config.overlapStrategy ??
|
|
12195
|
+
this.overlapStrategy = config.overlapStrategy ?? m$1;
|
|
12136
12196
|
this.documentManagerUnsubs.push(
|
|
12137
12197
|
this.documentManager.provides().onDocumentOpened((docState) => {
|
|
12138
12198
|
const { chapterId } = o(docState.id);
|
|
@@ -12176,11 +12236,11 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12176
12236
|
resolvePageDocument: (chapterId, localPageIndex) => {
|
|
12177
12237
|
const chapter = this.findChapter(chapterId);
|
|
12178
12238
|
if (!chapter) return null;
|
|
12179
|
-
return
|
|
12239
|
+
return h(chapter, localPageIndex);
|
|
12180
12240
|
},
|
|
12181
12241
|
getSegmentPlan: (chapterId) => {
|
|
12182
12242
|
const chapter = this.findChapter(chapterId);
|
|
12183
|
-
return chapter ?
|
|
12243
|
+
return chapter ? u(chapter) : null;
|
|
12184
12244
|
},
|
|
12185
12245
|
isSegmentLoaded: (chapterId, segmentIndex) => this.isSegmentDocumentOpen(chapterId, segmentIndex),
|
|
12186
12246
|
isSegmentLoadPending: (chapterId, segmentIndex) => this.isSegmentLoadPending(chapterId, segmentIndex),
|
|
@@ -12204,15 +12264,15 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12204
12264
|
}
|
|
12205
12265
|
setManifestInternal(manifest2) {
|
|
12206
12266
|
var _a2;
|
|
12207
|
-
const normalizedManifest =
|
|
12208
|
-
if (
|
|
12267
|
+
const normalizedManifest = P(manifest2);
|
|
12268
|
+
if (f(manifest2.chapters)) {
|
|
12209
12269
|
this.logger.warn(
|
|
12210
12270
|
_ChapterManagerPlugin2.id,
|
|
12211
12271
|
"ManifestFlatten",
|
|
12212
12272
|
`manifest.chapters 含嵌套 children,已自动展开为 ${normalizedManifest.chapters.length} 条(顶层 ${manifest2.chapters.length} 条)。侧栏树请单独传入,勿依赖 children 渲染 PDF。`
|
|
12213
12273
|
);
|
|
12214
12274
|
}
|
|
12215
|
-
const issues =
|
|
12275
|
+
const issues = d(normalizedManifest);
|
|
12216
12276
|
if (issues.length > 0) {
|
|
12217
12277
|
this.logger.warn(
|
|
12218
12278
|
_ChapterManagerPlugin2.id,
|
|
@@ -12239,7 +12299,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12239
12299
|
this.manifest = normalizedManifest;
|
|
12240
12300
|
this.lastVisibleIndicesKey = "";
|
|
12241
12301
|
(_a2 = this.segmentScheduler) == null ? void 0 : _a2.clear();
|
|
12242
|
-
this.virtualPageMap =
|
|
12302
|
+
this.virtualPageMap = $(normalizedManifest, this.overlapStrategy);
|
|
12243
12303
|
this.manifestChange$.emit({ manifest: normalizedManifest, map: this.virtualPageMap });
|
|
12244
12304
|
this.eagerPrefetchFromManifest();
|
|
12245
12305
|
}
|
|
@@ -12262,7 +12322,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12262
12322
|
}
|
|
12263
12323
|
getSegmentPlanForChapter(chapterId) {
|
|
12264
12324
|
const chapter = this.findChapter(chapterId);
|
|
12265
|
-
return chapter ?
|
|
12325
|
+
return chapter ? u(chapter) : null;
|
|
12266
12326
|
}
|
|
12267
12327
|
anySegmentOpen(chapterId) {
|
|
12268
12328
|
const plan = this.getSegmentPlanForChapter(chapterId);
|
|
@@ -12341,7 +12401,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12341
12401
|
if (segmentIndex < 0) return;
|
|
12342
12402
|
const chapter = this.findChapter(chapterId);
|
|
12343
12403
|
if (!chapter) return;
|
|
12344
|
-
const plan =
|
|
12404
|
+
const plan = u(chapter);
|
|
12345
12405
|
if (plan && segmentIndex >= plan.segments.length) return;
|
|
12346
12406
|
const segKey = `${chapterId}:${segmentIndex}`;
|
|
12347
12407
|
const prev = segmentPriorities.get(segKey);
|
|
@@ -12354,7 +12414,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12354
12414
|
const chapter = this.findChapter(loc.chapterId);
|
|
12355
12415
|
if (!chapter) continue;
|
|
12356
12416
|
const dist = Math.abs(idx - focalIdx);
|
|
12357
|
-
const seg =
|
|
12417
|
+
const seg = i(chapter, loc.localPageIndex);
|
|
12358
12418
|
setSegPriority(loc.chapterId, seg, dist);
|
|
12359
12419
|
setSegPriority(loc.chapterId, seg + 1, dist + this.SEG_PRIO_PREFETCH_NEXT);
|
|
12360
12420
|
void this.resolveChapterUrls(chapter).catch(() => {
|
|
@@ -12396,7 +12456,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12396
12456
|
if (this.config.autoActivateOnLoad ?? true) {
|
|
12397
12457
|
const focusLoc = this.virtualPageMap.atIndex(focalIdx);
|
|
12398
12458
|
if (focusLoc) {
|
|
12399
|
-
const ref2 =
|
|
12459
|
+
const ref2 = h(
|
|
12400
12460
|
this.findChapter(focusLoc.chapterId),
|
|
12401
12461
|
focusLoc.localPageIndex
|
|
12402
12462
|
);
|
|
@@ -12442,7 +12502,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12442
12502
|
loadSegmentNow(chapterId, segmentIndex) {
|
|
12443
12503
|
const chapter = this.findChapter(chapterId);
|
|
12444
12504
|
if (!chapter) return Promise.resolve("error");
|
|
12445
|
-
const plan =
|
|
12505
|
+
const plan = u(chapter);
|
|
12446
12506
|
if (!plan) {
|
|
12447
12507
|
if (segmentIndex !== 0) {
|
|
12448
12508
|
return Promise.resolve(this.isSegmentDocumentOpen(chapterId, 0) ? "loaded" : "error");
|
|
@@ -12555,10 +12615,11 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12555
12615
|
}
|
|
12556
12616
|
const urls = await this.resolveChapterUrls(chapter);
|
|
12557
12617
|
if (urls.length !== segmentCount) {
|
|
12618
|
+
const [gLo, gHi] = chapter.globalPageRange;
|
|
12558
12619
|
this.logger.warn(
|
|
12559
12620
|
_ChapterManagerPlugin2.id,
|
|
12560
12621
|
"SegmentUrlCount",
|
|
12561
|
-
`Chapter "${chapter.chapterId}"
|
|
12622
|
+
`Chapter "${chapter.chapterId}" loadChapterUrls returned ${urls.length} URL(s), expected ${segmentCount} (= ceil((${gHi}-${gLo}+1) / ${threshold})). Check globalPageRange [${gLo},${gHi}] and segmentPageThreshold.`
|
|
12562
12623
|
);
|
|
12563
12624
|
}
|
|
12564
12625
|
return this.openPayloadFromUrl(chapter, segmentIndex, urls);
|
|
@@ -12704,7 +12765,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12704
12765
|
closeChapter(chapterId) {
|
|
12705
12766
|
const chapter = this.findChapter(chapterId);
|
|
12706
12767
|
const cap = this.documentManager.provides();
|
|
12707
|
-
const plan = chapter ?
|
|
12768
|
+
const plan = chapter ? u(chapter) : null;
|
|
12708
12769
|
const closeDoc = (documentId) => {
|
|
12709
12770
|
if (cap.isDocumentOpen(documentId)) {
|
|
12710
12771
|
const task = cap.closeDocument(documentId);
|
|
@@ -12746,32 +12807,32 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
12746
12807
|
};
|
|
12747
12808
|
_ChapterManagerPlugin.id = "chapter-manager";
|
|
12748
12809
|
let ChapterManagerPlugin = _ChapterManagerPlugin;
|
|
12749
|
-
const
|
|
12750
|
-
function
|
|
12810
|
+
const m = { kind: "first-wins" };
|
|
12811
|
+
function _(e14) {
|
|
12751
12812
|
return "last" === e14 ? { kind: "last-wins" } : { kind: "first-wins" };
|
|
12752
12813
|
}
|
|
12753
|
-
function
|
|
12814
|
+
function R(e14) {
|
|
12754
12815
|
const t2 = e14.endPage - e14.startPage + 1;
|
|
12755
12816
|
return { chapterId: e14.chapterId, title: e14.title, globalPageRange: [e14.startPage, e14.endPage], localPageRange: [0, t2 - 1], ...e14.source ? { source: e14.source } : {}, ...null != e14.segmentPageThreshold ? { segmentPageThreshold: e14.segmentPageThreshold } : {}, ...e14.encrypted ? { encrypted: e14.encrypted } : {} };
|
|
12756
12817
|
}
|
|
12757
|
-
function
|
|
12818
|
+
function C(e14) {
|
|
12758
12819
|
const t2 = [], n2 = (e15) => {
|
|
12759
12820
|
var _a2;
|
|
12760
|
-
for (const r9 of e15) t2.push(
|
|
12821
|
+
for (const r9 of e15) t2.push(R(r9)), ((_a2 = r9.children) == null ? void 0 : _a2.length) && n2(r9.children);
|
|
12761
12822
|
};
|
|
12762
12823
|
return n2(e14), t2;
|
|
12763
12824
|
}
|
|
12764
|
-
function
|
|
12825
|
+
function G2(e14) {
|
|
12765
12826
|
return e14.map((e15) => {
|
|
12766
12827
|
var _a2;
|
|
12767
|
-
return { id: e15.chapterId, title: e15.title, startPage: e15.startPage, endPage: e15.endPage, children: ((_a2 = e15.children) == null ? void 0 : _a2.length) ?
|
|
12828
|
+
return { id: e15.chapterId, title: e15.title, startPage: e15.startPage, endPage: e15.endPage, children: ((_a2 = e15.children) == null ? void 0 : _a2.length) ? G2(e15.children) : void 0 };
|
|
12768
12829
|
});
|
|
12769
12830
|
}
|
|
12770
|
-
function
|
|
12771
|
-
return { tree:
|
|
12831
|
+
function M(e14) {
|
|
12832
|
+
return { tree: G2(e14), manifest: { chapters: C(e14) } };
|
|
12772
12833
|
}
|
|
12773
12834
|
export {
|
|
12774
|
-
|
|
12835
|
+
Fs as CHAPTER_ANNOTATIONS_ARCHIVE_VERSION,
|
|
12775
12836
|
Ue$1 as CallbackPasswordProvider,
|
|
12776
12837
|
ChapterManagerPlugin,
|
|
12777
12838
|
_sfc_main as ChapterPdfViewer,
|
|
@@ -12782,29 +12843,29 @@ export {
|
|
|
12782
12843
|
EmbedPDF2 as EmbedPDF,
|
|
12783
12844
|
ja as PdfChapterViewport,
|
|
12784
12845
|
xe$1 as applySelectionMarkup,
|
|
12785
|
-
|
|
12846
|
+
M as buildChapterViewerCatalog,
|
|
12786
12847
|
bn as buildParagraphBookmarkAnchor,
|
|
12787
12848
|
Bs as chapterAnnotationsArchiveToJson,
|
|
12788
12849
|
Ws as chapterAnnotationsSnapshotToJson,
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12850
|
+
R as chapterDescriptorFromTreeNode,
|
|
12851
|
+
Us as copyTextToClipboard,
|
|
12852
|
+
Nn as createChapterViewerBundle,
|
|
12792
12853
|
Un as createChapterViewerEditor,
|
|
12793
|
-
|
|
12854
|
+
zn as createChapterViewerEditorOptions,
|
|
12794
12855
|
kn as createPdfChapterEditor,
|
|
12795
|
-
|
|
12856
|
+
m as defaultOverlapStrategy,
|
|
12796
12857
|
Js as downloadChapterAnnotationsArchive,
|
|
12797
12858
|
Qs as downloadChapterAnnotationsSnapshot,
|
|
12798
12859
|
Xs as downloadJsonFile,
|
|
12799
12860
|
zs as exportAllChapterAnnotations,
|
|
12800
12861
|
Vs2 as exportChapterAnnotations,
|
|
12801
|
-
|
|
12862
|
+
C as flattenChapterTree,
|
|
12802
12863
|
qs as importChapterAnnotations,
|
|
12803
12864
|
Hs as importChapterAnnotationsArchive,
|
|
12804
|
-
|
|
12865
|
+
_ as overlapStrategyForSamePageOwner,
|
|
12805
12866
|
Ks as parseChapterAnnotationsArchiveJson,
|
|
12806
12867
|
js as parseChapterAnnotationsSnapshotJson,
|
|
12807
|
-
|
|
12868
|
+
G2 as toChapterTreeNodes,
|
|
12808
12869
|
useCapability2 as useCapability,
|
|
12809
12870
|
usePdfiumEngine,
|
|
12810
12871
|
useRegistry2 as useRegistry
|