@embedpdf-editor/vue3-chapter-viewer 1.0.5 → 1.0.6
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.d.ts +4 -1
- package/dist/index.js +209 -105
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ let Fe$1 = class Fe {
|
|
|
99
99
|
return this.cb(e14, t2);
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
const
|
|
102
|
+
const Ve$1 = "chapter-manager", Re$1 = { id: Ve$1, name: "Chapter Manager Plugin", version: "0.1.0", provides: ["chapter-manager"], requires: ["document-manager"], optional: [], defaultConfig: { manifest: { chapters: [] }, prefetchChapters: 1, unloadTimeoutMs: 6e4, autoActivateOnLoad: true } };
|
|
103
103
|
function _e$1(e14) {
|
|
104
104
|
const [t2, s2] = e14.localPageRange;
|
|
105
105
|
return s2 - t2 + 1;
|
|
@@ -574,7 +574,7 @@ const st$1 = class e extends BasePlugin {
|
|
|
574
574
|
};
|
|
575
575
|
st$1.id = "chapter-manager";
|
|
576
576
|
let rt$1 = st$1;
|
|
577
|
-
const nt$1 = { manifest:
|
|
577
|
+
const nt$1 = { manifest: Re$1, create: (e14) => new rt$1(Ve$1, e14), reducer: (e14) => e14, initialState: {} }, at$1 = "chapter-scroll", ot = { id: at$1, name: "Chapter Scroll Plugin", version: "0.1.0", provides: ["chapter-scroll"], requires: ["chapter-manager"], optional: [], defaultConfig: { placeholderPageHeight: 1200, placeholderPageWidth: 900, bufferSize: 2, pageGap: 20 } };
|
|
578
578
|
function it(e14) {
|
|
579
579
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
580
580
|
}
|
|
@@ -1116,7 +1116,12 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
1116
1116
|
return !s2.isSegmentLoaded(e14, n2);
|
|
1117
1117
|
}
|
|
1118
1118
|
refreshLayout() {
|
|
1119
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
1119
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
1120
|
+
}
|
|
1121
|
+
pushVisibleLoads() {
|
|
1122
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
1123
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
1124
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
1120
1125
|
}
|
|
1121
1126
|
syncReadyChapterSizes() {
|
|
1122
1127
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -1226,6 +1231,12 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
1226
1231
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
1227
1232
|
});
|
|
1228
1233
|
}
|
|
1234
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
1235
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
1236
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
1237
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
1238
|
+
return a2;
|
|
1239
|
+
}
|
|
1229
1240
|
recomputeVisible() {
|
|
1230
1241
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
1231
1242
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -1233,7 +1244,9 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
1233
1244
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
1234
1245
|
let n2 = r9;
|
|
1235
1246
|
for (; n2 < e14; ) {
|
|
1236
|
-
const e15 = this.getPageSize(n2)
|
|
1247
|
+
const e15 = this.getPageSize(n2);
|
|
1248
|
+
if (e15.height <= 0) break;
|
|
1249
|
+
const t3 = this.offsets[n2];
|
|
1237
1250
|
if (e15.height, t3 >= s2) break;
|
|
1238
1251
|
n2++;
|
|
1239
1252
|
}
|
|
@@ -1244,7 +1257,7 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
1244
1257
|
const e15 = this.offsets[l2], r10 = e15 + this.getPageSize(l2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
1245
1258
|
n3 > i2 && (i2 = n3, o2 = l2);
|
|
1246
1259
|
}
|
|
1247
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
1260
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
1248
1261
|
}
|
|
1249
1262
|
findFirstVisibleIndex(e14) {
|
|
1250
1263
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -1329,7 +1342,7 @@ function Gt$1(e14) {
|
|
|
1329
1342
|
}
|
|
1330
1343
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
1331
1344
|
}
|
|
1332
|
-
function
|
|
1345
|
+
function Vt$1(e14, t2) {
|
|
1333
1346
|
const s2 = Gt$1(e14);
|
|
1334
1347
|
if (!s2) return { documentId: e14.chapterId, pageIndex: t2 };
|
|
1335
1348
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
@@ -1339,7 +1352,7 @@ function Rt$1(e14, t2) {
|
|
|
1339
1352
|
}
|
|
1340
1353
|
return { documentId: r9.documentId, pageIndex: t2 - r9.localPageStart };
|
|
1341
1354
|
}
|
|
1342
|
-
function
|
|
1355
|
+
function Rt$1(e14, t2) {
|
|
1343
1356
|
const s2 = Gt$1(e14);
|
|
1344
1357
|
if (!s2) return 0;
|
|
1345
1358
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
@@ -1461,7 +1474,7 @@ const jt$1 = class e3 extends BasePlugin {
|
|
|
1461
1474
|
t2 && (this.overlapStrategy = t2), this.setManifestInternal(e14);
|
|
1462
1475
|
}, getManifest: () => this.manifest, getVirtualPageMap: () => this.virtualPageMap, setVisibleGlobalPages: (e14) => this.handleVisibleChange(e14), ensureChapterLoaded: (e14) => this.ensureChapterLoaded(e14), ensureSegmentLoaded: (e14, t2) => this.ensureSegmentLoaded(e14, t2), ensureAllSegmentsLoaded: (e14) => this.ensureAllSegmentsLoaded(e14), resolvePageDocument: (e14, t2) => {
|
|
1463
1476
|
const s2 = this.findChapter(e14);
|
|
1464
|
-
return s2 ?
|
|
1477
|
+
return s2 ? Vt$1(s2, t2) : null;
|
|
1465
1478
|
}, getSegmentPlan: (e14) => {
|
|
1466
1479
|
const t2 = this.findChapter(e14);
|
|
1467
1480
|
return t2 ? Gt$1(t2) : null;
|
|
@@ -1564,7 +1577,7 @@ const jt$1 = class e3 extends BasePlugin {
|
|
|
1564
1577
|
r9.add(e15.chapterId);
|
|
1565
1578
|
const t3 = this.findChapter(e15.chapterId);
|
|
1566
1579
|
if (!t3) continue;
|
|
1567
|
-
const s3 =
|
|
1580
|
+
const s3 = Rt$1(t3, e15.localPageIndex);
|
|
1568
1581
|
n2.add(`${e15.chapterId}:${s3}`), n2.add(`${e15.chapterId}:${s3 + 1}`);
|
|
1569
1582
|
}
|
|
1570
1583
|
if (0 === r9.size) return;
|
|
@@ -1584,7 +1597,7 @@ const jt$1 = class e3 extends BasePlugin {
|
|
|
1584
1597
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
1585
1598
|
const t3 = e14[0], s3 = null != t3 ? this.virtualPageMap.atIndex(t3) : null;
|
|
1586
1599
|
if (s3) {
|
|
1587
|
-
const e15 =
|
|
1600
|
+
const e15 = Vt$1(this.findChapter(s3.chapterId), s3.localPageIndex);
|
|
1588
1601
|
if (this.documentManager.provides().isDocumentOpen(e15.documentId)) {
|
|
1589
1602
|
this.documentManager.provides().getActiveDocumentId() !== e15.documentId && this.documentManager.provides().setActiveDocument(e15.documentId);
|
|
1590
1603
|
}
|
|
@@ -2309,7 +2322,12 @@ const fs$1 = class fs extends BasePlugin {
|
|
|
2309
2322
|
return !s2.isSegmentLoaded(e14, n2);
|
|
2310
2323
|
}
|
|
2311
2324
|
refreshLayout() {
|
|
2312
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
2325
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
2326
|
+
}
|
|
2327
|
+
pushVisibleLoads() {
|
|
2328
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
2329
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
2330
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
2313
2331
|
}
|
|
2314
2332
|
syncReadyChapterSizes() {
|
|
2315
2333
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -2419,6 +2437,12 @@ const fs$1 = class fs extends BasePlugin {
|
|
|
2419
2437
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
2420
2438
|
});
|
|
2421
2439
|
}
|
|
2440
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
2441
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
2442
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
2443
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
2444
|
+
return a2;
|
|
2445
|
+
}
|
|
2422
2446
|
recomputeVisible() {
|
|
2423
2447
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
2424
2448
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -2426,7 +2450,9 @@ const fs$1 = class fs extends BasePlugin {
|
|
|
2426
2450
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
2427
2451
|
let n2 = r9;
|
|
2428
2452
|
for (; n2 < e14; ) {
|
|
2429
|
-
const e15 = this.getPageSize(n2)
|
|
2453
|
+
const e15 = this.getPageSize(n2);
|
|
2454
|
+
if (e15.height <= 0) break;
|
|
2455
|
+
const t3 = this.offsets[n2];
|
|
2430
2456
|
if (e15.height, t3 >= s2) break;
|
|
2431
2457
|
n2++;
|
|
2432
2458
|
}
|
|
@@ -2437,7 +2463,7 @@ const fs$1 = class fs extends BasePlugin {
|
|
|
2437
2463
|
const e15 = this.offsets[l2], r10 = e15 + this.getPageSize(l2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
2438
2464
|
n3 > i2 && (i2 = n3, o2 = l2);
|
|
2439
2465
|
}
|
|
2440
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
2466
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
2441
2467
|
}
|
|
2442
2468
|
findFirstVisibleIndex(e14) {
|
|
2443
2469
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -3074,10 +3100,10 @@ const Ns$1 = class e6 extends BasePlugin {
|
|
|
3074
3100
|
};
|
|
3075
3101
|
Ns$1.id = "chapter-manager";
|
|
3076
3102
|
let Gs$1 = Ns$1;
|
|
3077
|
-
function
|
|
3103
|
+
function Vs$1(e14) {
|
|
3078
3104
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
3079
3105
|
}
|
|
3080
|
-
function
|
|
3106
|
+
function Rs$1(e14, t2) {
|
|
3081
3107
|
return `${e14}#s${t2}`;
|
|
3082
3108
|
}
|
|
3083
3109
|
function _s$1(e14) {
|
|
@@ -3090,7 +3116,7 @@ function qs$1(e14) {
|
|
|
3090
3116
|
const t2 = (function(e15) {
|
|
3091
3117
|
if (null != e15.segmentPageThreshold && e15.segmentPageThreshold > 0) return e15.segmentPageThreshold;
|
|
3092
3118
|
const t3 = e15.source;
|
|
3093
|
-
return
|
|
3119
|
+
return Vs$1(t3) ? t3.segmentPageThreshold : null;
|
|
3094
3120
|
})(e14);
|
|
3095
3121
|
if (!t2) return null;
|
|
3096
3122
|
const s2 = (function(e15) {
|
|
@@ -3098,25 +3124,25 @@ function qs$1(e14) {
|
|
|
3098
3124
|
return s3 - t3 + 1;
|
|
3099
3125
|
})(e14), r9 = (function(e15, t3) {
|
|
3100
3126
|
return e15 <= 0 || t3 <= 0 ? 0 : Math.ceil(e15 / t3);
|
|
3101
|
-
})(s2, t2), n2 =
|
|
3127
|
+
})(s2, t2), n2 = Vs$1(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
3102
3128
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
3103
3129
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
3104
3130
|
if (r10 >= s2) break;
|
|
3105
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
3131
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Rs$1(e14.chapterId, o2) });
|
|
3106
3132
|
}
|
|
3107
3133
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
3108
3134
|
}
|
|
3109
|
-
function Ws(e14) {
|
|
3135
|
+
function Ws$1(e14) {
|
|
3110
3136
|
const [t2, s2] = e14.localPageRange;
|
|
3111
3137
|
return s2 - t2 + 1;
|
|
3112
3138
|
}
|
|
3113
|
-
function Hs
|
|
3139
|
+
function Hs(e14) {
|
|
3114
3140
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
3115
3141
|
}
|
|
3116
3142
|
function Bs$1(e14) {
|
|
3117
3143
|
if (null != e14.segmentPageThreshold && e14.segmentPageThreshold > 0) return e14.segmentPageThreshold;
|
|
3118
3144
|
const t2 = e14.source;
|
|
3119
|
-
return Hs
|
|
3145
|
+
return Hs(t2) ? t2.segmentPageThreshold : null;
|
|
3120
3146
|
}
|
|
3121
3147
|
function js(e14, t2) {
|
|
3122
3148
|
return `${e14}#s${t2}`;
|
|
@@ -3133,7 +3159,7 @@ function Ys(e14, t2) {
|
|
|
3133
3159
|
function Xs(e14) {
|
|
3134
3160
|
const t2 = Bs$1(e14);
|
|
3135
3161
|
if (!t2) return null;
|
|
3136
|
-
const s2 = Ws(e14), r9 = Ys(s2, t2), n2 = Hs
|
|
3162
|
+
const s2 = Ws$1(e14), r9 = Ys(s2, t2), n2 = Hs(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
3137
3163
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
3138
3164
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
3139
3165
|
if (r10 >= s2) break;
|
|
@@ -3161,10 +3187,10 @@ function Js(e14) {
|
|
|
3161
3187
|
var t2;
|
|
3162
3188
|
const s2 = Bs$1(e14);
|
|
3163
3189
|
if (!s2) return [];
|
|
3164
|
-
const r9 = [], { chapterId: n2 } = e14, a2 = Ws(e14);
|
|
3190
|
+
const r9 = [], { chapterId: n2 } = e14, a2 = Ws$1(e14);
|
|
3165
3191
|
s2 <= 0 && r9.push(`${n2}: segmentPageThreshold must be > 0`);
|
|
3166
3192
|
const o2 = e14.source;
|
|
3167
|
-
if (!Hs
|
|
3193
|
+
if (!Hs(o2)) return r9;
|
|
3168
3194
|
0 === o2.urls.length && r9.push(`${n2}: source.urls must not be empty`);
|
|
3169
3195
|
const i2 = Ys(a2, s2);
|
|
3170
3196
|
o2.urls.length !== i2 && r9.push(`${n2}: source.urls.length (${o2.urls.length}) must equal ceil(pageCount/threshold) (${i2})`);
|
|
@@ -3458,7 +3484,7 @@ const nr = class e7 extends BasePlugin {
|
|
|
3458
3484
|
if (r9) return r9;
|
|
3459
3485
|
const n2 = (async () => {
|
|
3460
3486
|
const s3 = e14.source;
|
|
3461
|
-
if (Hs
|
|
3487
|
+
if (Hs(s3)) {
|
|
3462
3488
|
const e15 = [...s3.urls];
|
|
3463
3489
|
return this.chapterUrlsCache.set(t2, e15), e15;
|
|
3464
3490
|
}
|
|
@@ -3486,14 +3512,14 @@ const nr = class e7 extends BasePlugin {
|
|
|
3486
3512
|
async resolvePdfPayload(t2, s2) {
|
|
3487
3513
|
const r9 = t2.source, n2 = this.config.chapterPdfLoader, a2 = Bs$1(t2);
|
|
3488
3514
|
if (a2) {
|
|
3489
|
-
const r10 = Ys(Ws(t2), a2);
|
|
3515
|
+
const r10 = Ys(Ws$1(t2), a2);
|
|
3490
3516
|
if (s2 < 0 || s2 >= r10) throw new Error(`Chapter "${t2.chapterId}" invalid segmentIndex ${s2} (expected 0..${r10 - 1})`);
|
|
3491
3517
|
const n3 = await this.resolveChapterUrls(t2);
|
|
3492
3518
|
return n3.length !== r10 && this.logger.warn(e7.id, "SegmentUrlCount", `Chapter "${t2.chapterId}" urls.length (${n3.length}) != expected (${r10})`), this.openPayloadFromUrl(t2, s2, n3);
|
|
3493
3519
|
}
|
|
3494
3520
|
if (0 !== s2) throw new Error(`Chapter "${t2.chapterId}" is not segmented`);
|
|
3495
3521
|
if (r9) {
|
|
3496
|
-
if (Hs
|
|
3522
|
+
if (Hs(r9)) {
|
|
3497
3523
|
const e14 = await this.resolveChapterUrls(t2);
|
|
3498
3524
|
return this.openPayloadFromUrl(t2, s2, e14);
|
|
3499
3525
|
}
|
|
@@ -3615,7 +3641,12 @@ const ir = class extends BasePlugin {
|
|
|
3615
3641
|
return !s2.isSegmentLoaded(e14, n2);
|
|
3616
3642
|
}
|
|
3617
3643
|
refreshLayout() {
|
|
3618
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
3644
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
3645
|
+
}
|
|
3646
|
+
pushVisibleLoads() {
|
|
3647
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
3648
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
3649
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
3619
3650
|
}
|
|
3620
3651
|
syncReadyChapterSizes() {
|
|
3621
3652
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -3725,6 +3756,12 @@ const ir = class extends BasePlugin {
|
|
|
3725
3756
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
3726
3757
|
});
|
|
3727
3758
|
}
|
|
3759
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
3760
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
3761
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
3762
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
3763
|
+
return a2;
|
|
3764
|
+
}
|
|
3728
3765
|
recomputeVisible() {
|
|
3729
3766
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
3730
3767
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -3732,7 +3769,9 @@ const ir = class extends BasePlugin {
|
|
|
3732
3769
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
3733
3770
|
let n2 = r9;
|
|
3734
3771
|
for (; n2 < e14; ) {
|
|
3735
|
-
const e15 = this.getPageSize(n2)
|
|
3772
|
+
const e15 = this.getPageSize(n2);
|
|
3773
|
+
if (e15.height <= 0) break;
|
|
3774
|
+
const t3 = this.offsets[n2];
|
|
3736
3775
|
if (e15.height, t3 >= s2) break;
|
|
3737
3776
|
n2++;
|
|
3738
3777
|
}
|
|
@@ -3743,7 +3782,7 @@ const ir = class extends BasePlugin {
|
|
|
3743
3782
|
const e15 = this.offsets[l2], r10 = e15 + this.getPageSize(l2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
3744
3783
|
n3 > i2 && (i2 = n3, o2 = l2);
|
|
3745
3784
|
}
|
|
3746
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
3785
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
3747
3786
|
}
|
|
3748
3787
|
findFirstVisibleIndex(e14) {
|
|
3749
3788
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -4167,10 +4206,10 @@ function Gr(a2, o2, i2) {
|
|
|
4167
4206
|
return false !== ((_a2 = o2.value) == null ? void 0 : _a2.enabled);
|
|
4168
4207
|
}, minZoom: b2, maxZoom: I2 };
|
|
4169
4208
|
}
|
|
4170
|
-
function
|
|
4209
|
+
function Vr(e14, t2, s2) {
|
|
4171
4210
|
return Math.min(s2, Math.max(t2, e14));
|
|
4172
4211
|
}
|
|
4173
|
-
function
|
|
4212
|
+
function Rr(e14, t2) {
|
|
4174
4213
|
if (!e14 || false === t2.enabled) return () => {
|
|
4175
4214
|
};
|
|
4176
4215
|
let s2 = null, r9 = null, n2 = 0;
|
|
@@ -4179,7 +4218,7 @@ function Vr(e14, t2) {
|
|
|
4179
4218
|
return !!r10 && (s2 == null ? void 0 : s2(), s2 = (function({ container: e15, getScale: t3, setScale: s3, minZoom: r11 = 0.5, maxZoom: n3 = 3 }) {
|
|
4180
4219
|
let a3 = 0, o2 = 1, i2 = null, l2 = 1, h2 = 1;
|
|
4181
4220
|
const d2 = (e16) => {
|
|
4182
|
-
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === i2 ? (h2 = t3(), l2 = 1) : clearTimeout(i2), l2 *= 1 - 0.01 * e16.deltaY, l2 =
|
|
4221
|
+
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === i2 ? (h2 = t3(), l2 = 1) : clearTimeout(i2), l2 *= 1 - 0.01 * e16.deltaY, l2 = Vr(l2, 0.1, 10), s3(Vr(h2 * l2, r11, n3)), i2 = setTimeout(() => {
|
|
4183
4222
|
i2 = null;
|
|
4184
4223
|
}, 120));
|
|
4185
4224
|
}, c2 = /* @__PURE__ */ new Map(), u2 = (e16) => {
|
|
@@ -4191,7 +4230,7 @@ function Vr(e14, t2) {
|
|
|
4191
4230
|
if (c2.has(e16.pointerId) && (c2.set(e16.pointerId, { x: e16.clientX, y: e16.clientY }), 2 === c2.size && a3 > 0)) {
|
|
4192
4231
|
e16.preventDefault();
|
|
4193
4232
|
const [t4, i3] = [...c2.values()], l3 = Math.hypot(i3.x - t4.x, i3.y - t4.y);
|
|
4194
|
-
s3(
|
|
4233
|
+
s3(Vr(o2 * (l3 / a3), r11, n3));
|
|
4195
4234
|
}
|
|
4196
4235
|
}, g2 = (e16) => {
|
|
4197
4236
|
c2.delete(e16.pointerId), c2.size < 2 && (a3 = 0);
|
|
@@ -4221,7 +4260,7 @@ function qr(e14) {
|
|
|
4221
4260
|
watch([e15, t2], () => {
|
|
4222
4261
|
s2 == null ? void 0 : s2();
|
|
4223
4262
|
const r9 = t2.value;
|
|
4224
|
-
s2 =
|
|
4263
|
+
s2 = Rr(e15.value ?? null, { enabled: r9.enabled, getScale: r9.getScale, setScale: r9.setScale, minZoom: r9.minZoom, maxZoom: r9.maxZoom });
|
|
4225
4264
|
}, { deep: true, flush: "post" }), onBeforeUnmount(() => s2 == null ? void 0 : s2());
|
|
4226
4265
|
})(a2, computed(() => ({ enabled: c2(), getScale: () => h2.value, setScale: d2, minZoom: u2.value, maxZoom: p2.value }))), { hostRef: a2, scale: h2, setScale: d2, zoomEnabled: c2 };
|
|
4227
4266
|
}
|
|
@@ -4766,7 +4805,12 @@ const un = class extends BasePlugin {
|
|
|
4766
4805
|
return !s2.isSegmentLoaded(e14, n2);
|
|
4767
4806
|
}
|
|
4768
4807
|
refreshLayout() {
|
|
4769
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
4808
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
4809
|
+
}
|
|
4810
|
+
pushVisibleLoads() {
|
|
4811
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
4812
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
4813
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
4770
4814
|
}
|
|
4771
4815
|
syncReadyChapterSizes() {
|
|
4772
4816
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -4876,6 +4920,12 @@ const un = class extends BasePlugin {
|
|
|
4876
4920
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
4877
4921
|
});
|
|
4878
4922
|
}
|
|
4923
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
4924
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
4925
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
4926
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
4927
|
+
return a2;
|
|
4928
|
+
}
|
|
4879
4929
|
recomputeVisible() {
|
|
4880
4930
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
4881
4931
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -4883,7 +4933,9 @@ const un = class extends BasePlugin {
|
|
|
4883
4933
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
4884
4934
|
let n2 = r9;
|
|
4885
4935
|
for (; n2 < e14; ) {
|
|
4886
|
-
const e15 = this.getPageSize(n2)
|
|
4936
|
+
const e15 = this.getPageSize(n2);
|
|
4937
|
+
if (e15.height <= 0) break;
|
|
4938
|
+
const t3 = this.offsets[n2];
|
|
4887
4939
|
if (e15.height, t3 >= s2) break;
|
|
4888
4940
|
n2++;
|
|
4889
4941
|
}
|
|
@@ -4894,7 +4946,7 @@ const un = class extends BasePlugin {
|
|
|
4894
4946
|
const e15 = this.offsets[l2], r10 = e15 + this.getPageSize(l2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
4895
4947
|
n3 > i2 && (i2 = n3, o2 = l2);
|
|
4896
4948
|
}
|
|
4897
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
4949
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
4898
4950
|
}
|
|
4899
4951
|
findFirstVisibleIndex(e14) {
|
|
4900
4952
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -5483,10 +5535,10 @@ function Gn(e14) {
|
|
|
5483
5535
|
const t2 = e14.source;
|
|
5484
5536
|
return Nn(t2) ? t2.segmentPageThreshold : null;
|
|
5485
5537
|
}
|
|
5486
|
-
function
|
|
5538
|
+
function Vn(e14, t2) {
|
|
5487
5539
|
return `${e14}#s${t2}`;
|
|
5488
5540
|
}
|
|
5489
|
-
function
|
|
5541
|
+
function Rn(e14) {
|
|
5490
5542
|
const t2 = e14.lastIndexOf("#s");
|
|
5491
5543
|
if (-1 === t2) return { chapterId: e14, segmentIndex: null };
|
|
5492
5544
|
const s2 = e14.slice(0, t2), r9 = Number.parseInt(e14.slice(t2 + 2), 10);
|
|
@@ -5502,7 +5554,7 @@ function qn(e14) {
|
|
|
5502
5554
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
5503
5555
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
5504
5556
|
if (r10 >= s2) break;
|
|
5505
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
5557
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Vn(e14.chapterId, o2) });
|
|
5506
5558
|
}
|
|
5507
5559
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
5508
5560
|
}
|
|
@@ -5620,13 +5672,13 @@ const Kn = class e11 extends BasePlugin {
|
|
|
5620
5672
|
}
|
|
5621
5673
|
async initialize(e14) {
|
|
5622
5674
|
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? jn, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
5623
|
-
const { chapterId: t2 } =
|
|
5675
|
+
const { chapterId: t2 } = Rn(e15.id);
|
|
5624
5676
|
this.findChapter(t2) && (this.passwordAttempts.delete(t2), this.syncChapterStatusFromDocuments(t2));
|
|
5625
5677
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
5626
|
-
const { chapterId: t2 } =
|
|
5678
|
+
const { chapterId: t2 } = Rn(e15);
|
|
5627
5679
|
this.findChapter(t2) && this.syncChapterStatusFromDocuments(t2);
|
|
5628
5680
|
}), this.documentManager.provides().onDocumentError((e15) => {
|
|
5629
|
-
const { chapterId: t2 } =
|
|
5681
|
+
const { chapterId: t2 } = Rn(e15.documentId);
|
|
5630
5682
|
this.findChapter(t2) && this.handleDocumentError(e15.documentId, t2, e15.code, e15.message);
|
|
5631
5683
|
})), this.setManifestInternal(e14.manifest), e14.unloadTimeoutMs && e14.unloadTimeoutMs > 0) {
|
|
5632
5684
|
const t2 = Math.max(5e3, Math.floor(e14.unloadTimeoutMs / 4));
|
|
@@ -5906,7 +5958,7 @@ const Kn = class e11 extends BasePlugin {
|
|
|
5906
5958
|
async handleDocumentError(t2, s2, r9, n2) {
|
|
5907
5959
|
if (this.pendingSegmentLoadPromises.has(t2)) return;
|
|
5908
5960
|
if (r9 !== PdfErrorCode.Password) {
|
|
5909
|
-
const e14 = this.getSegmentPlanForChapter(s2), { segmentIndex: r10 } =
|
|
5961
|
+
const e14 = this.getSegmentPlanForChapter(s2), { segmentIndex: r10 } = Rn(t2);
|
|
5910
5962
|
return void (e14 && 0 !== r10 && null !== r10 || this.updateStatus(s2, "error"));
|
|
5911
5963
|
}
|
|
5912
5964
|
if (!this.passwordProvider) return void this.updateStatus(s2, "password-required");
|
|
@@ -5980,7 +6032,12 @@ const ea = class extends BasePlugin {
|
|
|
5980
6032
|
return !s2.isSegmentLoaded(e14, n2);
|
|
5981
6033
|
}
|
|
5982
6034
|
refreshLayout() {
|
|
5983
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
6035
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
6036
|
+
}
|
|
6037
|
+
pushVisibleLoads() {
|
|
6038
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
6039
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
6040
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
5984
6041
|
}
|
|
5985
6042
|
syncReadyChapterSizes() {
|
|
5986
6043
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -6090,6 +6147,12 @@ const ea = class extends BasePlugin {
|
|
|
6090
6147
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
6091
6148
|
});
|
|
6092
6149
|
}
|
|
6150
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
6151
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
6152
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
6153
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
6154
|
+
return a2;
|
|
6155
|
+
}
|
|
6093
6156
|
recomputeVisible() {
|
|
6094
6157
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
6095
6158
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -6097,7 +6160,9 @@ const ea = class extends BasePlugin {
|
|
|
6097
6160
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
6098
6161
|
let n2 = r9;
|
|
6099
6162
|
for (; n2 < e14; ) {
|
|
6100
|
-
const e15 = this.getPageSize(n2)
|
|
6163
|
+
const e15 = this.getPageSize(n2);
|
|
6164
|
+
if (e15.height <= 0) break;
|
|
6165
|
+
const t3 = this.offsets[n2];
|
|
6101
6166
|
if (e15.height, t3 >= s2) break;
|
|
6102
6167
|
n2++;
|
|
6103
6168
|
}
|
|
@@ -6108,7 +6173,7 @@ const ea = class extends BasePlugin {
|
|
|
6108
6173
|
const e15 = this.offsets[l2], r10 = e15 + this.getPageSize(l2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
6109
6174
|
n3 > i2 && (i2 = n3, o2 = l2);
|
|
6110
6175
|
}
|
|
6111
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
6176
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
6112
6177
|
}
|
|
6113
6178
|
findFirstVisibleIndex(e14) {
|
|
6114
6179
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -6647,14 +6712,14 @@ const Ga = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
6647
6712
|
var _a2, _b, _c, _d;
|
|
6648
6713
|
return [createVNode(ya, { item: t3, features: e14.features, "show-note-markers": p2.value, "show-bookmark-markers": m2.value, "show-redaction-layer": e14.showRedactionLayer, "note-marker-ui": (_b = (_a2 = e14.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.marker, "bookmark-marker-ui": (_d = (_c = e14.features) == null ? void 0 : _c.bookmarks) == null ? void 0 : _d.marker, "build-selection-menu": w2.value, "create-note": unref(o2), "annotation-selection-menu": e14.annotationSelectionMenu, "redaction-selection-menu": e14.redactionSelectionMenu, "render-page-overlay": x }, null, 8, ["item", "features", "show-note-markers", "show-bookmark-markers", "show-redaction-layer", "note-marker-ui", "bookmark-marker-ui", "build-selection-menu", "create-note", "annotation-selection-menu", "redaction-selection-menu"])];
|
|
6649
6714
|
}), _: 1 }, 8, ["class", "style"]), renderSlot(t2.$slots, "default")], 6));
|
|
6650
|
-
} }),
|
|
6715
|
+
} }), Va = { key: 0, style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, width: "100%" } }, Ra = /* @__PURE__ */ defineComponent({ __name: "ChapterPdfViewer", props: { engine: {}, options: {}, editorOptions: {}, features: {}, className: {}, viewportClassName: {}, onExtraSelectionAction: { type: Function } }, setup(e14) {
|
|
6651
6716
|
const s2 = e14, r9 = computed(() => (function(e15) {
|
|
6652
6717
|
if (e15.options) return Ur(e15.options);
|
|
6653
6718
|
if (!e15.editorOptions) throw new Error("ChapterPdfViewer: 请传入 `options`(推荐),或同时传入 `editorOptions` 与 `features`");
|
|
6654
6719
|
const t2 = De$1(e15.features), { plugins: s3 } = Lr({ ...e15.editorOptions, features: t2 });
|
|
6655
6720
|
return { plugins: s3, features: t2, editorOptions: { ...e15.editorOptions, features: t2 } };
|
|
6656
6721
|
})({ engine: s2.engine, options: s2.options, editorOptions: s2.editorOptions, features: s2.features }));
|
|
6657
|
-
return (t2, s3) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Pe$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: r9.value.plugins }, { default: withCtx(({ pluginsReady: s4 }) => [s4 ? (openBlock(), createElementBlock("div",
|
|
6722
|
+
return (t2, s3) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Pe$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: r9.value.plugins }, { default: withCtx(({ pluginsReady: s4 }) => [s4 ? (openBlock(), createElementBlock("div", Va, [renderSlot(t2.$slots, "prepend"), createVNode(Ga, { class: normalizeClass(e14.viewportClassName), style: { flex: 1, minHeight: 0 }, features: r9.value.features, "on-extra-selection-action": e14.onExtraSelectionAction }, null, 8, ["class", "features", "on-extra-selection-action"]), renderSlot(t2.$slots, "default")])) : createCommentVNode("", true)]), _: 3 }, 8, ["engine", "plugins"])], 6));
|
|
6658
6723
|
} }), _a = { class: "chapter-tree-row" }, qa = ["aria-expanded"], Wa = { key: 1, class: "chapter-tree-toggle-spacer", "aria-hidden": "" }, Ha = { class: "chapter-tree-label" }, Ba = { class: "chapter-tree-meta" }, ja = { key: 0 }, Za = (e14, t2) => {
|
|
6659
6724
|
const s2 = e14.__vccOpts || e14;
|
|
6660
6725
|
for (const [r9, n2] of t2) s2[r9] = n2;
|
|
@@ -6694,7 +6759,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
6694
6759
|
},
|
|
6695
6760
|
setup(__props) {
|
|
6696
6761
|
return (_ctx, _cache) => {
|
|
6697
|
-
return openBlock(), createBlock(unref(
|
|
6762
|
+
return openBlock(), createBlock(unref(Ra), normalizeProps(guardReactiveProps(_ctx.$props)), createSlots({
|
|
6698
6763
|
default: withCtx(() => [
|
|
6699
6764
|
renderSlot(_ctx.$slots, "default")
|
|
6700
6765
|
]),
|
|
@@ -6829,7 +6894,7 @@ let z = class {
|
|
|
6829
6894
|
return s2 ? this._pages.indexOf(s2) : -1;
|
|
6830
6895
|
}
|
|
6831
6896
|
};
|
|
6832
|
-
function
|
|
6897
|
+
function V(e14, t2 = N) {
|
|
6833
6898
|
const s2 = (function(e15, t3 = N) {
|
|
6834
6899
|
const s3 = /* @__PURE__ */ new Map();
|
|
6835
6900
|
for (const n3 of e15.chapters) {
|
|
@@ -6854,7 +6919,7 @@ function R$1(e14, t2 = N) {
|
|
|
6854
6919
|
}
|
|
6855
6920
|
return new z(a2);
|
|
6856
6921
|
}
|
|
6857
|
-
const
|
|
6922
|
+
const R$1 = class r extends BasePlugin {
|
|
6858
6923
|
constructor(e14, r9) {
|
|
6859
6924
|
super(e14, r9), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = N, 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.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
6860
6925
|
}
|
|
@@ -6921,7 +6986,7 @@ const V = class r extends BasePlugin {
|
|
|
6921
6986
|
const n2 = new Set(this.chapterStatus.keys()), a2 = new Set(t2.chapters.map((e15) => e15.chapterId));
|
|
6922
6987
|
for (const r9 of n2) a2.has(r9) || (this.closeChapter(r9), this.chapterStatus.delete(r9), this.chapterErrorMessages.delete(r9), this.chapterUrlsCache.delete(r9), this.pendingChapterUrlsPromises.delete(r9));
|
|
6923
6988
|
for (const r9 of t2.chapters) this.chapterStatus.has(r9.chapterId) || this.chapterStatus.set(r9.chapterId, "idle");
|
|
6924
|
-
this.manifest = t2, this.virtualPageMap =
|
|
6989
|
+
this.manifest = t2, this.virtualPageMap = V(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
6925
6990
|
}
|
|
6926
6991
|
eagerPrefetchFromManifest() {
|
|
6927
6992
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -7183,9 +7248,9 @@ const V = class r extends BasePlugin {
|
|
|
7183
7248
|
"error" === t2 && s2 ? this.chapterErrorMessages.set(e14, s2) : "loading" !== t2 && "loaded" !== t2 || this.chapterErrorMessages.delete(e14), r9 !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && s2 ? { error: { message: s2 } } : {} }));
|
|
7184
7249
|
}
|
|
7185
7250
|
};
|
|
7186
|
-
|
|
7187
|
-
let _$1 =
|
|
7188
|
-
function
|
|
7251
|
+
R$1.id = "chapter-manager";
|
|
7252
|
+
let _$1 = R$1;
|
|
7253
|
+
function H(e14) {
|
|
7189
7254
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
7190
7255
|
}
|
|
7191
7256
|
function j(e14, t2) {
|
|
@@ -7201,7 +7266,7 @@ function J(e14) {
|
|
|
7201
7266
|
const t2 = (function(e15) {
|
|
7202
7267
|
if (null != e15.segmentPageThreshold && e15.segmentPageThreshold > 0) return e15.segmentPageThreshold;
|
|
7203
7268
|
const t3 = e15.source;
|
|
7204
|
-
return
|
|
7269
|
+
return H(t3) ? t3.segmentPageThreshold : null;
|
|
7205
7270
|
})(e14);
|
|
7206
7271
|
if (!t2) return null;
|
|
7207
7272
|
const s2 = (function(e15) {
|
|
@@ -7209,7 +7274,7 @@ function J(e14) {
|
|
|
7209
7274
|
return s3 - t3 + 1;
|
|
7210
7275
|
})(e14), r9 = (function(e15, t3) {
|
|
7211
7276
|
return e15 <= 0 || t3 <= 0 ? 0 : Math.ceil(e15 / t3);
|
|
7212
|
-
})(s2, t2), n2 =
|
|
7277
|
+
})(s2, t2), n2 = H(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
7213
7278
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
7214
7279
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
7215
7280
|
if (r10 >= s2) break;
|
|
@@ -7726,7 +7791,12 @@ const pe = class extends BasePlugin {
|
|
|
7726
7791
|
return !s2.isSegmentLoaded(e14, n2);
|
|
7727
7792
|
}
|
|
7728
7793
|
refreshLayout() {
|
|
7729
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
7794
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
7795
|
+
}
|
|
7796
|
+
pushVisibleLoads() {
|
|
7797
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
7798
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
7799
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
7730
7800
|
}
|
|
7731
7801
|
syncReadyChapterSizes() {
|
|
7732
7802
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -7836,6 +7906,12 @@ const pe = class extends BasePlugin {
|
|
|
7836
7906
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
7837
7907
|
});
|
|
7838
7908
|
}
|
|
7909
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
7910
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
7911
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
7912
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
7913
|
+
return a2;
|
|
7914
|
+
}
|
|
7839
7915
|
recomputeVisible() {
|
|
7840
7916
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
7841
7917
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -7843,7 +7919,9 @@ const pe = class extends BasePlugin {
|
|
|
7843
7919
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
7844
7920
|
let n2 = r9;
|
|
7845
7921
|
for (; n2 < e14; ) {
|
|
7846
|
-
const e15 = this.getPageSize(n2)
|
|
7922
|
+
const e15 = this.getPageSize(n2);
|
|
7923
|
+
if (e15.height <= 0) break;
|
|
7924
|
+
const t3 = this.offsets[n2];
|
|
7847
7925
|
if (e15.height, t3 >= s2) break;
|
|
7848
7926
|
n2++;
|
|
7849
7927
|
}
|
|
@@ -7854,7 +7932,7 @@ const pe = class extends BasePlugin {
|
|
|
7854
7932
|
const e15 = this.offsets[h2], r10 = e15 + this.getPageSize(h2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
7855
7933
|
n3 > i2 && (i2 = n3, o2 = h2);
|
|
7856
7934
|
}
|
|
7857
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
7935
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
7858
7936
|
}
|
|
7859
7937
|
findFirstVisibleIndex(e14) {
|
|
7860
7938
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -8414,12 +8492,12 @@ function Ge(e14) {
|
|
|
8414
8492
|
function ze(e14) {
|
|
8415
8493
|
return !!e14 && "urls" in e14 && Array.isArray(e14.urls);
|
|
8416
8494
|
}
|
|
8417
|
-
function
|
|
8495
|
+
function Ve(e14) {
|
|
8418
8496
|
if (null != e14.segmentPageThreshold && e14.segmentPageThreshold > 0) return e14.segmentPageThreshold;
|
|
8419
8497
|
const t2 = e14.source;
|
|
8420
8498
|
return ze(t2) ? t2.segmentPageThreshold : null;
|
|
8421
8499
|
}
|
|
8422
|
-
function
|
|
8500
|
+
function Re(e14, t2) {
|
|
8423
8501
|
return `${e14}#s${t2}`;
|
|
8424
8502
|
}
|
|
8425
8503
|
function _e(e14) {
|
|
@@ -8431,19 +8509,19 @@ function _e(e14) {
|
|
|
8431
8509
|
function qe(e14, t2) {
|
|
8432
8510
|
return e14 <= 0 || t2 <= 0 ? 0 : Math.ceil(e14 / t2);
|
|
8433
8511
|
}
|
|
8434
|
-
function
|
|
8435
|
-
const t2 =
|
|
8512
|
+
function Be(e14) {
|
|
8513
|
+
const t2 = Ve(e14);
|
|
8436
8514
|
if (!t2) return null;
|
|
8437
8515
|
const s2 = Ge(e14), r9 = qe(s2, t2), n2 = ze(e14.source) ? e14.source.urls : void 0, a2 = [];
|
|
8438
8516
|
for (let o2 = 0; o2 < r9; o2++) {
|
|
8439
8517
|
const r10 = o2 * t2, i2 = Math.min(r10 + t2 - 1, s2 - 1);
|
|
8440
8518
|
if (r10 >= s2) break;
|
|
8441
|
-
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId:
|
|
8519
|
+
a2.push({ index: o2, url: (null == n2 ? void 0 : n2[o2]) ?? "", localPageStart: r10, localPageEnd: i2, documentId: Re(e14.chapterId, o2) });
|
|
8442
8520
|
}
|
|
8443
8521
|
return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
|
|
8444
8522
|
}
|
|
8445
|
-
function
|
|
8446
|
-
const s2 =
|
|
8523
|
+
function We(e14, t2) {
|
|
8524
|
+
const s2 = Be(e14);
|
|
8447
8525
|
if (!s2) return { documentId: e14.chapterId, pageIndex: t2 };
|
|
8448
8526
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
8449
8527
|
if (!r9) {
|
|
@@ -8452,15 +8530,15 @@ function Be(e14, t2) {
|
|
|
8452
8530
|
}
|
|
8453
8531
|
return { documentId: r9.documentId, pageIndex: t2 - r9.localPageStart };
|
|
8454
8532
|
}
|
|
8455
|
-
function
|
|
8456
|
-
const s2 =
|
|
8533
|
+
function He(e14, t2) {
|
|
8534
|
+
const s2 = Be(e14);
|
|
8457
8535
|
if (!s2) return 0;
|
|
8458
8536
|
const r9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
|
|
8459
8537
|
return (null == r9 ? void 0 : r9.index) ?? Math.floor(t2 / s2.threshold);
|
|
8460
8538
|
}
|
|
8461
8539
|
function je(e14) {
|
|
8462
8540
|
var t2;
|
|
8463
|
-
const s2 =
|
|
8541
|
+
const s2 = Ve(e14);
|
|
8464
8542
|
if (!s2) return [];
|
|
8465
8543
|
const r9 = [], { chapterId: n2 } = e14, a2 = Ge(e14);
|
|
8466
8544
|
s2 <= 0 && r9.push(`${n2}: segmentPageThreshold must be > 0`);
|
|
@@ -8574,10 +8652,10 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8574
8652
|
t2 && (this.overlapStrategy = t2), this.setManifestInternal(e14);
|
|
8575
8653
|
}, getManifest: () => this.manifest, getVirtualPageMap: () => this.virtualPageMap, setVisibleGlobalPages: (e14) => this.handleVisibleChange(e14), ensureChapterLoaded: (e14) => this.ensureChapterLoaded(e14), ensureSegmentLoaded: (e14, t2) => this.ensureSegmentLoaded(e14, t2), ensureAllSegmentsLoaded: (e14) => this.ensureAllSegmentsLoaded(e14), resolvePageDocument: (e14, t2) => {
|
|
8576
8654
|
const s2 = this.findChapter(e14);
|
|
8577
|
-
return s2 ?
|
|
8655
|
+
return s2 ? We(s2, t2) : null;
|
|
8578
8656
|
}, getSegmentPlan: (e14) => {
|
|
8579
8657
|
const t2 = this.findChapter(e14);
|
|
8580
|
-
return t2 ?
|
|
8658
|
+
return t2 ? Be(t2) : null;
|
|
8581
8659
|
}, 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 };
|
|
8582
8660
|
}
|
|
8583
8661
|
destroy() {
|
|
@@ -8635,7 +8713,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8635
8713
|
}
|
|
8636
8714
|
getSegmentPlanForChapter(e14) {
|
|
8637
8715
|
const t2 = this.findChapter(e14);
|
|
8638
|
-
return t2 ?
|
|
8716
|
+
return t2 ? Be(t2) : null;
|
|
8639
8717
|
}
|
|
8640
8718
|
isSegmentDocumentOpen(e14, t2) {
|
|
8641
8719
|
const s2 = this.getSegmentPlanForChapter(e14), r9 = this.documentManager.provides();
|
|
@@ -8677,7 +8755,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8677
8755
|
r9.add(e15.chapterId);
|
|
8678
8756
|
const t3 = this.findChapter(e15.chapterId);
|
|
8679
8757
|
if (!t3) continue;
|
|
8680
|
-
const s3 =
|
|
8758
|
+
const s3 = He(t3, e15.localPageIndex);
|
|
8681
8759
|
n2.add(`${e15.chapterId}:${s3}`), n2.add(`${e15.chapterId}:${s3 + 1}`);
|
|
8682
8760
|
}
|
|
8683
8761
|
if (0 === r9.size) return;
|
|
@@ -8697,7 +8775,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8697
8775
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
8698
8776
|
const t3 = e14[0], s3 = null != t3 ? this.virtualPageMap.atIndex(t3) : null;
|
|
8699
8777
|
if (s3) {
|
|
8700
|
-
const e15 =
|
|
8778
|
+
const e15 = We(this.findChapter(s3.chapterId), s3.localPageIndex);
|
|
8701
8779
|
if (this.documentManager.provides().isDocumentOpen(e15.documentId)) {
|
|
8702
8780
|
this.documentManager.provides().getActiveDocumentId() !== e15.documentId && this.documentManager.provides().setActiveDocument(e15.documentId);
|
|
8703
8781
|
}
|
|
@@ -8729,7 +8807,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8729
8807
|
ensureSegmentLoaded(e14, t2) {
|
|
8730
8808
|
const s2 = this.findChapter(e14);
|
|
8731
8809
|
if (!s2) return Promise.resolve("error");
|
|
8732
|
-
const r9 =
|
|
8810
|
+
const r9 = Be(s2);
|
|
8733
8811
|
if (!r9) return 0 !== t2 ? Promise.resolve(this.isSegmentDocumentOpen(e14, 0) ? "loaded" : "error") : this.ensureSingleDocumentChapter(s2);
|
|
8734
8812
|
if (t2 < 0 || t2 >= r9.segments.length) return Promise.resolve("error");
|
|
8735
8813
|
const n2 = r9.segments[t2], a2 = n2.documentId;
|
|
@@ -8785,7 +8863,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8785
8863
|
return (null == n2 ? void 0 : n2.openPdf) ? n2.openPdf(a2) : { url: r9 };
|
|
8786
8864
|
}
|
|
8787
8865
|
async resolvePdfPayload(e14, t2) {
|
|
8788
|
-
const s2 = e14.source, n2 = this.config.chapterPdfLoader, a2 =
|
|
8866
|
+
const s2 = e14.source, n2 = this.config.chapterPdfLoader, a2 = Ve(e14);
|
|
8789
8867
|
if (a2) {
|
|
8790
8868
|
const s3 = qe(Ge(e14), a2);
|
|
8791
8869
|
if (t2 < 0 || t2 >= s3) throw new Error(`Chapter "${e14.chapterId}" invalid segmentIndex ${t2} (expected 0..${s3 - 1})`);
|
|
@@ -8863,7 +8941,7 @@ const Xe = class r4 extends BasePlugin {
|
|
|
8863
8941
|
});
|
|
8864
8942
|
}
|
|
8865
8943
|
closeChapter(e14) {
|
|
8866
|
-
const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), r9 = t2 ?
|
|
8944
|
+
const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), r9 = t2 ? Be(t2) : null, n2 = (e15) => {
|
|
8867
8945
|
if (s2.isDocumentOpen(e15)) {
|
|
8868
8946
|
s2.closeDocument(e15).wait(() => {
|
|
8869
8947
|
}, () => {
|
|
@@ -8916,7 +8994,12 @@ const tt = class extends BasePlugin {
|
|
|
8916
8994
|
return !s2.isSegmentLoaded(e14, n2);
|
|
8917
8995
|
}
|
|
8918
8996
|
refreshLayout() {
|
|
8919
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
8997
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
8998
|
+
}
|
|
8999
|
+
pushVisibleLoads() {
|
|
9000
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
9001
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
9002
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
8920
9003
|
}
|
|
8921
9004
|
syncReadyChapterSizes() {
|
|
8922
9005
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -9026,6 +9109,12 @@ const tt = class extends BasePlugin {
|
|
|
9026
9109
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
9027
9110
|
});
|
|
9028
9111
|
}
|
|
9112
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
9113
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
9114
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
9115
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
9116
|
+
return a2;
|
|
9117
|
+
}
|
|
9029
9118
|
recomputeVisible() {
|
|
9030
9119
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
9031
9120
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -9033,7 +9122,9 @@ const tt = class extends BasePlugin {
|
|
|
9033
9122
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
9034
9123
|
let n2 = r9;
|
|
9035
9124
|
for (; n2 < e14; ) {
|
|
9036
|
-
const e15 = this.getPageSize(n2)
|
|
9125
|
+
const e15 = this.getPageSize(n2);
|
|
9126
|
+
if (e15.height <= 0) break;
|
|
9127
|
+
const t3 = this.offsets[n2];
|
|
9037
9128
|
if (e15.height, t3 >= s2) break;
|
|
9038
9129
|
n2++;
|
|
9039
9130
|
}
|
|
@@ -9044,7 +9135,7 @@ const tt = class extends BasePlugin {
|
|
|
9044
9135
|
const e15 = this.offsets[h2], r10 = e15 + this.getPageSize(h2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
9045
9136
|
n3 > i2 && (i2 = n3, o2 = h2);
|
|
9046
9137
|
}
|
|
9047
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
9138
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
9048
9139
|
}
|
|
9049
9140
|
findFirstVisibleIndex(e14) {
|
|
9050
9141
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -9778,7 +9869,7 @@ function Gt(e14) {
|
|
|
9778
9869
|
return r9;
|
|
9779
9870
|
}
|
|
9780
9871
|
const zt = { kind: "first-wins" };
|
|
9781
|
-
function
|
|
9872
|
+
function Vt(e14, t2, s2) {
|
|
9782
9873
|
if (1 === t2.length) return t2[0].chapterId;
|
|
9783
9874
|
switch (s2.kind) {
|
|
9784
9875
|
case "first-wins":
|
|
@@ -9796,7 +9887,7 @@ function Rt(e14, t2, s2) {
|
|
|
9796
9887
|
return s2.resolve(e14, t2);
|
|
9797
9888
|
}
|
|
9798
9889
|
}
|
|
9799
|
-
class
|
|
9890
|
+
class Rt {
|
|
9800
9891
|
constructor(e14) {
|
|
9801
9892
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
9802
9893
|
for (const t2 of e14) {
|
|
@@ -9841,7 +9932,7 @@ function _t(e14, t2 = zt) {
|
|
|
9841
9932
|
}
|
|
9842
9933
|
}
|
|
9843
9934
|
const r10 = /* @__PURE__ */ new Map();
|
|
9844
|
-
for (const [n3, a3] of s3) r10.set(n3,
|
|
9935
|
+
for (const [n3, a3] of s3) r10.set(n3, Vt(n3, a3, t3));
|
|
9845
9936
|
return r10;
|
|
9846
9937
|
})(e14, t2), r9 = /* @__PURE__ */ new Map();
|
|
9847
9938
|
for (const i2 of e14.chapters) r9.set(i2.chapterId, i2);
|
|
@@ -9853,7 +9944,7 @@ function _t(e14, t2 = zt) {
|
|
|
9853
9944
|
const [n3] = t3.globalPageRange, [h2] = t3.localPageRange, d2 = h2 + (i2 - n3);
|
|
9854
9945
|
a2.push({ globalPageIndex: o2++, globalPageNumber: i2, chapterId: e15, localPageIndex: d2 });
|
|
9855
9946
|
}
|
|
9856
|
-
return new
|
|
9947
|
+
return new Rt(a2);
|
|
9857
9948
|
}
|
|
9858
9949
|
const qt = class r7 extends BasePlugin {
|
|
9859
9950
|
constructor(e14, r9) {
|
|
@@ -10185,8 +10276,8 @@ const qt = class r7 extends BasePlugin {
|
|
|
10185
10276
|
}
|
|
10186
10277
|
};
|
|
10187
10278
|
qt.id = "chapter-manager";
|
|
10188
|
-
let
|
|
10189
|
-
function
|
|
10279
|
+
let Bt = qt;
|
|
10280
|
+
function Wt(e14, t2) {
|
|
10190
10281
|
if (e14 === t2) return true;
|
|
10191
10282
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
10192
10283
|
for (let s2 = 0; s2 < e14.items.length; s2++) {
|
|
@@ -10195,9 +10286,9 @@ function Bt(e14, t2) {
|
|
|
10195
10286
|
}
|
|
10196
10287
|
return true;
|
|
10197
10288
|
}
|
|
10198
|
-
const
|
|
10289
|
+
const Ht2 = class extends BasePlugin {
|
|
10199
10290
|
constructor(e14, s2) {
|
|
10200
|
-
super(e14, s2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
10291
|
+
super(e14, s2), this.layoutChange$ = createBehaviorEmitter(void 0, Wt), this.visibleChange$ = createBehaviorEmitter(), this.virtualPageMap = null, this.pageSizes = /* @__PURE__ */ new Map(), this.offsets = [], this.totalHeight = 0, this.totalWidth = 0, this.viewportEl = null, this.viewportObservers = null, this.currentVisible = [], this.currentGlobalPageIndex = 0, this.chapterManagerUnsubs = [], this.chapterManager = this.registry.getPlugin(Bt.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
10201
10292
|
}
|
|
10202
10293
|
async initialize(e14) {
|
|
10203
10294
|
this.config = { placeholderPageHeight: e14.placeholderPageHeight ?? 1200, placeholderPageWidth: e14.placeholderPageWidth ?? 900, bufferSize: e14.bufferSize ?? 2, pageGap: e14.pageGap ?? 20 }, this.virtualPageMap = this.chapterManager.provides().getVirtualPageMap(), this.rebuildOffsets(), this.chapterManagerUnsubs.push(this.chapterManager.provides().onManifestChange(({ map: e15 }) => {
|
|
@@ -10221,7 +10312,12 @@ const Wt = class extends BasePlugin {
|
|
|
10221
10312
|
return !s2.isSegmentLoaded(e14, n2);
|
|
10222
10313
|
}
|
|
10223
10314
|
refreshLayout() {
|
|
10224
|
-
this.layoutChange$.emit(this.computeLayout());
|
|
10315
|
+
this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
10316
|
+
}
|
|
10317
|
+
pushVisibleLoads() {
|
|
10318
|
+
if (!this.virtualPageMap || 0 === this.currentVisible.length) return;
|
|
10319
|
+
const e14 = this.expandIndicesWithBuffer(this.currentVisible, this.virtualPageMap.totalPages);
|
|
10320
|
+
0 !== e14.length && this.chapterManager.provides().setVisibleGlobalPages(e14);
|
|
10225
10321
|
}
|
|
10226
10322
|
syncReadyChapterSizes() {
|
|
10227
10323
|
for (const e14 of this.chapterManager.provides().getManifest().chapters) {
|
|
@@ -10331,6 +10427,12 @@ const Wt = class extends BasePlugin {
|
|
|
10331
10427
|
requestAnimationFrame(() => this.recomputeVisible());
|
|
10332
10428
|
});
|
|
10333
10429
|
}
|
|
10430
|
+
expandIndicesWithBuffer(e14, t2) {
|
|
10431
|
+
if (0 === e14.length || t2 <= 0) return [];
|
|
10432
|
+
const s2 = this.config.bufferSize, r9 = Math.max(0, e14[0] - s2), n2 = Math.min(t2 - 1, e14[e14.length - 1] + s2), a2 = [];
|
|
10433
|
+
for (let o2 = r9; o2 <= n2; o2++) a2.push(o2);
|
|
10434
|
+
return a2;
|
|
10435
|
+
}
|
|
10334
10436
|
recomputeVisible() {
|
|
10335
10437
|
if (!this.viewportEl || !this.virtualPageMap) return;
|
|
10336
10438
|
const e14 = this.virtualPageMap.totalPages;
|
|
@@ -10338,7 +10440,9 @@ const Wt = class extends BasePlugin {
|
|
|
10338
10440
|
const t2 = this.viewportEl.scrollTop, s2 = t2 + this.viewportEl.clientHeight, r9 = this.findFirstVisibleIndex(t2);
|
|
10339
10441
|
let n2 = r9;
|
|
10340
10442
|
for (; n2 < e14; ) {
|
|
10341
|
-
const e15 = this.getPageSize(n2)
|
|
10443
|
+
const e15 = this.getPageSize(n2);
|
|
10444
|
+
if (e15.height <= 0) break;
|
|
10445
|
+
const t3 = this.offsets[n2];
|
|
10342
10446
|
if (e15.height, t3 >= s2) break;
|
|
10343
10447
|
n2++;
|
|
10344
10448
|
}
|
|
@@ -10349,7 +10453,7 @@ const Wt = class extends BasePlugin {
|
|
|
10349
10453
|
const e15 = this.offsets[h2], r10 = e15 + this.getPageSize(h2).height, n3 = Math.max(0, Math.min(r10, s2) - Math.max(e15, t2));
|
|
10350
10454
|
n3 > i2 && (i2 = n3, o2 = h2);
|
|
10351
10455
|
}
|
|
10352
|
-
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.
|
|
10456
|
+
this.currentVisible = a2, this.currentGlobalPageIndex = o2, this.visibleChange$.emit({ visibleGlobalPageIndices: a2, currentGlobalPageIndex: o2 }), this.pushVisibleLoads(), this.layoutChange$.emit(this.computeLayout());
|
|
10353
10457
|
}
|
|
10354
10458
|
findFirstVisibleIndex(e14) {
|
|
10355
10459
|
let t2 = 0, s2 = this.offsets.length - 1, r9 = 0;
|
|
@@ -10395,8 +10499,8 @@ const Wt = class extends BasePlugin {
|
|
|
10395
10499
|
s2 && this.scrollToIndex(s2.globalPageIndex, t2);
|
|
10396
10500
|
}
|
|
10397
10501
|
};
|
|
10398
|
-
|
|
10399
|
-
let jt =
|
|
10502
|
+
Ht2.id = "chapter-scroll";
|
|
10503
|
+
let jt = Ht2;
|
|
10400
10504
|
function Kt(e14) {
|
|
10401
10505
|
const t2 = e14[e14.length - 1];
|
|
10402
10506
|
return { x: t2.origin.x + t2.size.width, y: t2.origin.y + t2.size.height };
|
|
@@ -10699,12 +10803,12 @@ async function Gs(e14, t2, s2) {
|
|
|
10699
10803
|
function zs(e14) {
|
|
10700
10804
|
return JSON.stringify(e14, null, 2);
|
|
10701
10805
|
}
|
|
10702
|
-
function
|
|
10806
|
+
function Vs(e14) {
|
|
10703
10807
|
const t2 = JSON.parse(e14);
|
|
10704
10808
|
if (!t2 || "object" != typeof t2 || !t2.chapters) throw new Error("无效的章节标注 JSON");
|
|
10705
10809
|
return t2;
|
|
10706
10810
|
}
|
|
10707
|
-
function
|
|
10811
|
+
function Rs(e14) {
|
|
10708
10812
|
return JSON.stringify(e14, null, 2);
|
|
10709
10813
|
}
|
|
10710
10814
|
function _s(e14) {
|
|
@@ -10716,11 +10820,11 @@ function qs(e14, t2) {
|
|
|
10716
10820
|
const s2 = new Blob([t2], { type: "application/json;charset=utf-8" }), r9 = URL.createObjectURL(s2), n2 = document.createElement("a");
|
|
10717
10821
|
n2.href = r9, n2.download = e14, n2.click(), URL.revokeObjectURL(r9);
|
|
10718
10822
|
}
|
|
10719
|
-
function
|
|
10823
|
+
function Bs(e14, t2 = "chapter-annotations.json") {
|
|
10720
10824
|
qs(t2, zs(e14));
|
|
10721
10825
|
}
|
|
10722
|
-
function
|
|
10723
|
-
qs(t2 ?? `chapter-annotations-${e14.chapterId}.json`,
|
|
10826
|
+
function Ws(e14, t2) {
|
|
10827
|
+
qs(t2 ?? `chapter-annotations-${e14.chapterId}.json`, Rs(e14));
|
|
10724
10828
|
}
|
|
10725
10829
|
const DEFAULT_CHAPTER_TEXT_SELECTION_BACKGROUND = "rgba(33, 150, 243)";
|
|
10726
10830
|
({
|
|
@@ -11532,7 +11636,7 @@ export {
|
|
|
11532
11636
|
G as buildChapterViewerCatalog,
|
|
11533
11637
|
pr as buildParagraphBookmarkAnchor,
|
|
11534
11638
|
zs as chapterAnnotationsArchiveToJson,
|
|
11535
|
-
|
|
11639
|
+
Rs as chapterAnnotationsSnapshotToJson,
|
|
11536
11640
|
_ as chapterDescriptorFromTreeNode,
|
|
11537
11641
|
Ms as copyTextToClipboard,
|
|
11538
11642
|
Ur as createChapterViewerBundle,
|
|
@@ -11540,8 +11644,8 @@ export {
|
|
|
11540
11644
|
Tr as createChapterViewerEditorOptions,
|
|
11541
11645
|
Sr as createPdfChapterEditor,
|
|
11542
11646
|
P as defaultOverlapStrategy,
|
|
11543
|
-
|
|
11544
|
-
|
|
11647
|
+
Bs as downloadChapterAnnotationsArchive,
|
|
11648
|
+
Ws as downloadChapterAnnotationsSnapshot,
|
|
11545
11649
|
qs as downloadJsonFile,
|
|
11546
11650
|
As2 as exportAllChapterAnnotations,
|
|
11547
11651
|
Os as exportChapterAnnotations,
|
|
@@ -11549,7 +11653,7 @@ export {
|
|
|
11549
11653
|
Ns as importChapterAnnotations,
|
|
11550
11654
|
Gs as importChapterAnnotationsArchive,
|
|
11551
11655
|
v as overlapStrategyForSamePageOwner,
|
|
11552
|
-
|
|
11656
|
+
Vs as parseChapterAnnotationsArchiveJson,
|
|
11553
11657
|
_s as parseChapterAnnotationsSnapshotJson,
|
|
11554
11658
|
C as toChapterTreeNodes,
|
|
11555
11659
|
useCapability2 as useCapability,
|