@embedpdf-editor/vue3-chapter-viewer 0.3.0 → 0.3.1
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/README.md +212 -215
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +70 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +967 -937
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/vite.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed, h, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, createVNode, withCtx, renderSlot, createCommentVNode, ref, watch, onBeforeUnmount, Fragment, renderList, createElementVNode, toDisplayString, onMounted, createBlock, resolveDynamicComponent, withModifiers, isRef, normalizeProps, guardReactiveProps, createSlots } from "vue";
|
|
1
|
+
import { defineComponent, computed, h as h$1, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, createVNode, withCtx, renderSlot, createCommentVNode, ref, watch, onBeforeUnmount, Fragment, renderList, createElementVNode, toDisplayString, onMounted, createBlock, resolveDynamicComponent, withModifiers, isRef, normalizeProps, guardReactiveProps, createSlots } from "vue";
|
|
2
2
|
import { useRegistry, useCapability, EmbedPDF } from "@embedpdf/core/vue";
|
|
3
3
|
import { EmbedPDF as EmbedPDF2, useCapability as useCapability2, useRegistry as useRegistry2 } from "@embedpdf/core/vue";
|
|
4
4
|
import { LockModeType, AnnotationPluginPackage, AnnotationPlugin, ANNOTATION_PLUGIN_ID } from "@embedpdf/plugin-annotation";
|
|
@@ -29,23 +29,23 @@ function we$1(e14, t2) {
|
|
|
29
29
|
return 0 === t2 ? e14 : e14.map((e15) => ({ origin: { x: e15.origin.x, y: e15.origin.y + t2 }, size: { ...e15.size } }));
|
|
30
30
|
}
|
|
31
31
|
function ye(e14) {
|
|
32
|
-
let t2 = 1 / 0, a3 = 1 / 0, s9 = -1 / 0,
|
|
33
|
-
for (const o of e14) t2 = Math.min(t2, o.origin.x), a3 = Math.min(a3, o.origin.y), s9 = Math.max(s9, o.origin.x + o.size.width),
|
|
34
|
-
return { origin: { x: t2, y: a3 }, size: { width: s9 - t2, height:
|
|
32
|
+
let t2 = 1 / 0, a3 = 1 / 0, s9 = -1 / 0, i2 = -1 / 0;
|
|
33
|
+
for (const o of e14) t2 = Math.min(t2, o.origin.x), a3 = Math.min(a3, o.origin.y), s9 = Math.max(s9, o.origin.x + o.size.width), i2 = Math.max(i2, o.origin.y + o.size.height);
|
|
34
|
+
return { origin: { x: t2, y: a3 }, size: { width: s9 - t2, height: i2 - a3 } };
|
|
35
35
|
}
|
|
36
|
-
function Ce(e14, t2, a3, s9,
|
|
36
|
+
function Ce(e14, t2, a3, s9, i2) {
|
|
37
37
|
const o = a3.forDocument(e14), r2 = s9.forDocument(e14);
|
|
38
38
|
if (!o || !r2) return false;
|
|
39
39
|
const n2 = "highlight" === t2 ? "highlight" : "underline" === t2 ? "underline" : "squiggly" === t2 ? "squiggly" : "strikeout", l = a3.getTool(n2);
|
|
40
40
|
if (!l) return false;
|
|
41
|
-
const h2 = l.defaults,
|
|
41
|
+
const h2 = l.defaults, d2 = (function(e15, t3) {
|
|
42
42
|
return { ...be$1[e15], ...null == t3 ? void 0 : t3[e15] };
|
|
43
|
-
})(t2,
|
|
43
|
+
})(t2, i2), c = r2.getFormattedSelection();
|
|
44
44
|
if (0 === c.length) return false;
|
|
45
45
|
o.setLocked({ type: LockModeType.Exclude, categories: ["markup", "shape"] });
|
|
46
46
|
for (const u of c) {
|
|
47
|
-
const e15 = uuidV4(), a4 =
|
|
48
|
-
o.createAnnotation(u.pageIndex, { id: e15, created: /* @__PURE__ */ new Date(), flags: ["print"], type: Pe$1[t2], ..."highlight" === t2 ? { blendMode: PdfBlendMode.Multiply } : {}, strokeColor: a4, opacity: s10, ...null !=
|
|
47
|
+
const e15 = uuidV4(), a4 = d2.color ?? h2.color ?? h2.strokeColor, s10 = d2.opacity ?? h2.opacity, i3 = d2.thickness ?? h2.strokeWidth, r3 = d2.offsetY ?? 0, n3 = "underline" === t2 || "squiggly" === t2 || "strikeout" === t2 ? we$1(u.segmentRects, r3) : u.segmentRects, l2 = "underline" === t2 || "squiggly" === t2 || "strikeout" === t2 ? ye(n3) : u.rect;
|
|
48
|
+
o.createAnnotation(u.pageIndex, { id: e15, created: /* @__PURE__ */ new Date(), flags: ["print"], type: Pe$1[t2], ..."highlight" === t2 ? { blendMode: PdfBlendMode.Multiply } : {}, strokeColor: a4, opacity: s10, ...null != i3 ? { strokeWidth: i3 } : {}, pageIndex: u.pageIndex, rect: l2, segmentRects: n3 });
|
|
49
49
|
}
|
|
50
50
|
return r2.clear(), true;
|
|
51
51
|
}
|
|
@@ -57,7 +57,7 @@ function Me(e14) {
|
|
|
57
57
|
const t2 = Ie(null == e14 ? void 0 : e14.markup, { enabled: true }), a3 = Ie(null == e14 ? void 0 : e14.bookmarks, { enabled: true }), s9 = Ie(null == e14 ? void 0 : e14.notes, { enabled: true });
|
|
58
58
|
return { markup: t2, bookmarks: a3, notes: s9, zoom: Ie(null == e14 ? void 0 : e14.zoom, { enabled: true, min: 0.5, max: 3, initial: 1 }), selectionToolbar: Ie(void 0 === (null == e14 ? void 0 : e14.selectionToolbar) ? false !== t2.enabled || false !== s9.enabled : e14.selectionToolbar, { enabled: true }) };
|
|
59
59
|
}
|
|
60
|
-
class
|
|
60
|
+
class xe {
|
|
61
61
|
constructor(e14) {
|
|
62
62
|
this.cb = e14;
|
|
63
63
|
}
|
|
@@ -65,9 +65,9 @@ class Se {
|
|
|
65
65
|
return this.cb(e14, t2);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
function
|
|
68
|
+
const De = "chapter-manager", Oe = { id: De, name: "Chapter Manager Plugin", version: "0.1.0", provides: ["chapter-manager"], requires: ["document-manager"], optional: [], defaultConfig: { manifest: { chapters: [] }, prefetchChapters: 1, unloadTimeoutMs: 6e4, autoActivateOnLoad: true } };
|
|
69
|
+
const Ge = { kind: "first-wins" };
|
|
70
|
+
function Ne(e14, t2, a3) {
|
|
71
71
|
if (1 === t2.length) return t2[0].chapterId;
|
|
72
72
|
switch (a3.kind) {
|
|
73
73
|
case "first-wins":
|
|
@@ -85,7 +85,7 @@ function $e(e14, t2, a3) {
|
|
|
85
85
|
return a3.resolve(e14, t2);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
let
|
|
88
|
+
let Ae = class {
|
|
89
89
|
constructor(e14) {
|
|
90
90
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
91
91
|
for (const t2 of e14) {
|
|
@@ -119,37 +119,37 @@ let ze = class {
|
|
|
119
119
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
function
|
|
123
|
-
const a3 = (function(e15, t3 =
|
|
122
|
+
function Ve(e14, t2 = Ge) {
|
|
123
|
+
const a3 = (function(e15, t3 = Ge) {
|
|
124
124
|
const a4 = /* @__PURE__ */ new Map();
|
|
125
|
-
for (const
|
|
126
|
-
const [e16, t4] =
|
|
125
|
+
for (const i3 of e15.chapters) {
|
|
126
|
+
const [e16, t4] = i3.globalPageRange;
|
|
127
127
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
128
128
|
const e17 = a4.get(s11);
|
|
129
|
-
e17 ? e17.push(
|
|
129
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
const s10 = /* @__PURE__ */ new Map();
|
|
133
|
-
for (const [
|
|
133
|
+
for (const [i3, o2] of a4) s10.set(i3, Ne(i3, o2, t3));
|
|
134
134
|
return s10;
|
|
135
135
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
136
136
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
137
|
-
const
|
|
137
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
138
138
|
let r2 = 0;
|
|
139
|
-
for (const n2 of
|
|
139
|
+
for (const n2 of i2) {
|
|
140
140
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
141
141
|
if (!t3) continue;
|
|
142
|
-
const [
|
|
142
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
143
143
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
144
144
|
}
|
|
145
|
-
return new
|
|
145
|
+
return new Ae(o);
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const _e = class e extends BasePlugin {
|
|
148
148
|
constructor(e14, t2) {
|
|
149
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
149
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Ge, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
150
150
|
}
|
|
151
151
|
async initialize(e14) {
|
|
152
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
152
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Ge, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
153
153
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
154
154
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
155
155
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -175,16 +175,16 @@ const De = class e extends BasePlugin {
|
|
|
175
175
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
176
176
|
for (const s10 of e14.chapters) {
|
|
177
177
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
178
|
-
const [e15,
|
|
179
|
-
if (e15 >
|
|
178
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
179
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
180
180
|
}
|
|
181
181
|
return t3;
|
|
182
182
|
})(t2);
|
|
183
183
|
a3.length > 0 && this.logger.warn(e.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
184
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
185
|
-
for (const e14 of s9)
|
|
184
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
185
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
186
186
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
187
|
-
this.manifest = t2, this.virtualPageMap =
|
|
187
|
+
this.manifest = t2, this.virtualPageMap = Ve(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
188
188
|
}
|
|
189
189
|
eagerPrefetchFromManifest() {
|
|
190
190
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -211,20 +211,20 @@ const De = class e extends BasePlugin {
|
|
|
211
211
|
e15 && s9.add(e15.chapterId);
|
|
212
212
|
}
|
|
213
213
|
if (0 === s9.size) return;
|
|
214
|
-
const
|
|
214
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
215
215
|
for (const n2 of s9) {
|
|
216
|
-
const e15 =
|
|
217
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
216
|
+
const e15 = i2.indexOf(n2);
|
|
217
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
218
218
|
}
|
|
219
219
|
const r2 = /* @__PURE__ */ new Set();
|
|
220
|
-
for (const n2 of o) r2.add(
|
|
220
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
221
221
|
for (const n2 of r2) {
|
|
222
222
|
this.chapterLastUsed.set(n2, t2);
|
|
223
223
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
224
224
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
225
225
|
}
|
|
226
226
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
227
|
-
const e15 =
|
|
227
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
228
228
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
229
229
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
230
230
|
}
|
|
@@ -247,10 +247,10 @@ const De = class e extends BasePlugin {
|
|
|
247
247
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
248
248
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
249
249
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
250
|
-
const
|
|
250
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
251
251
|
this.pendingLoadPromises.delete(e14);
|
|
252
252
|
});
|
|
253
|
-
return this.pendingLoadPromises.set(e14,
|
|
253
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
254
254
|
}
|
|
255
255
|
async resolvePdfPayload(e14) {
|
|
256
256
|
const t2 = e14.source;
|
|
@@ -268,17 +268,17 @@ const De = class e extends BasePlugin {
|
|
|
268
268
|
const s9 = t2.chapterId;
|
|
269
269
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
270
270
|
try {
|
|
271
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
271
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
272
272
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
273
273
|
});
|
|
274
274
|
return await new Promise((e15, t3) => {
|
|
275
275
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
276
276
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
277
|
-
} catch (
|
|
277
|
+
} catch (i2) {
|
|
278
278
|
const t3 = this.chapterStatus.get(s9);
|
|
279
279
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
280
|
-
const t4 =
|
|
281
|
-
this.logger.error(e.id, "LoadChapter", t4,
|
|
280
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
281
|
+
this.logger.error(e.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
282
282
|
}
|
|
283
283
|
return this.chapterStatus.get(s9) ?? "error";
|
|
284
284
|
}
|
|
@@ -296,13 +296,13 @@ const De = class e extends BasePlugin {
|
|
|
296
296
|
async handleDocumentError(t2, a3, s9) {
|
|
297
297
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
298
298
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
299
|
+
const i2 = this.findChapter(t2);
|
|
300
|
+
if (!i2) return;
|
|
301
301
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
302
302
|
this.passwordAttempts.set(t2, o);
|
|
303
303
|
let r2 = null;
|
|
304
304
|
try {
|
|
305
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
305
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
306
306
|
} catch (n2) {
|
|
307
307
|
this.logger.error(e.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
308
308
|
}
|
|
@@ -322,11 +322,11 @@ const De = class e extends BasePlugin {
|
|
|
322
322
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
|
-
|
|
326
|
-
let
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
function
|
|
325
|
+
_e.id = "chapter-manager";
|
|
326
|
+
let Ee = _e;
|
|
327
|
+
const Re = { manifest: Oe, create: (e14) => new Ee(De, e14), reducer: (e14) => e14, initialState: {} }, Fe = "chapter-scroll", Ue = { id: Fe, name: "Chapter Scroll Plugin", version: "0.1.0", provides: ["chapter-scroll"], requires: ["chapter-manager"], optional: [], defaultConfig: { placeholderPageHeight: 1200, placeholderPageWidth: 900, bufferSize: 2, pageGap: 20 } };
|
|
328
|
+
const qe = { kind: "first-wins" };
|
|
329
|
+
function We(e14, t2, a3) {
|
|
330
330
|
if (1 === t2.length) return t2[0].chapterId;
|
|
331
331
|
switch (a3.kind) {
|
|
332
332
|
case "first-wins":
|
|
@@ -344,7 +344,7 @@ function _e(e14, t2, a3) {
|
|
|
344
344
|
return a3.resolve(e14, t2);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
let
|
|
347
|
+
let He = class {
|
|
348
348
|
constructor(e14) {
|
|
349
349
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
350
350
|
for (const t2 of e14) {
|
|
@@ -378,37 +378,37 @@ let Ee = class {
|
|
|
378
378
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
|
-
function
|
|
382
|
-
const a3 = (function(e15, t3 =
|
|
381
|
+
function Be(e14, t2 = qe) {
|
|
382
|
+
const a3 = (function(e15, t3 = qe) {
|
|
383
383
|
const a4 = /* @__PURE__ */ new Map();
|
|
384
|
-
for (const
|
|
385
|
-
const [e16, t4] =
|
|
384
|
+
for (const i3 of e15.chapters) {
|
|
385
|
+
const [e16, t4] = i3.globalPageRange;
|
|
386
386
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
387
387
|
const e17 = a4.get(s11);
|
|
388
|
-
e17 ? e17.push(
|
|
388
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
const s10 = /* @__PURE__ */ new Map();
|
|
392
|
-
for (const [
|
|
392
|
+
for (const [i3, o2] of a4) s10.set(i3, We(i3, o2, t3));
|
|
393
393
|
return s10;
|
|
394
394
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
395
395
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
396
|
-
const
|
|
396
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
397
397
|
let r2 = 0;
|
|
398
|
-
for (const n2 of
|
|
398
|
+
for (const n2 of i2) {
|
|
399
399
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
400
400
|
if (!t3) continue;
|
|
401
|
-
const [
|
|
401
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
402
402
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
403
403
|
}
|
|
404
|
-
return new
|
|
404
|
+
return new He(o);
|
|
405
405
|
}
|
|
406
|
-
const
|
|
406
|
+
const je = class e2 extends BasePlugin {
|
|
407
407
|
constructor(e14, t2) {
|
|
408
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
408
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = qe, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
409
409
|
}
|
|
410
410
|
async initialize(e14) {
|
|
411
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
411
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? qe, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
412
412
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
413
413
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
414
414
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -434,16 +434,16 @@ const Fe = class e2 extends BasePlugin {
|
|
|
434
434
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
435
435
|
for (const s10 of e14.chapters) {
|
|
436
436
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
437
|
-
const [e15,
|
|
438
|
-
if (e15 >
|
|
437
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
438
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
439
439
|
}
|
|
440
440
|
return t3;
|
|
441
441
|
})(t2);
|
|
442
442
|
a3.length > 0 && this.logger.warn(e2.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
443
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
444
|
-
for (const e14 of s9)
|
|
443
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
444
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
445
445
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
446
|
-
this.manifest = t2, this.virtualPageMap =
|
|
446
|
+
this.manifest = t2, this.virtualPageMap = Be(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
447
447
|
}
|
|
448
448
|
eagerPrefetchFromManifest() {
|
|
449
449
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -470,20 +470,20 @@ const Fe = class e2 extends BasePlugin {
|
|
|
470
470
|
e15 && s9.add(e15.chapterId);
|
|
471
471
|
}
|
|
472
472
|
if (0 === s9.size) return;
|
|
473
|
-
const
|
|
473
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
474
474
|
for (const n2 of s9) {
|
|
475
|
-
const e15 =
|
|
476
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
475
|
+
const e15 = i2.indexOf(n2);
|
|
476
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
477
477
|
}
|
|
478
478
|
const r2 = /* @__PURE__ */ new Set();
|
|
479
|
-
for (const n2 of o) r2.add(
|
|
479
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
480
480
|
for (const n2 of r2) {
|
|
481
481
|
this.chapterLastUsed.set(n2, t2);
|
|
482
482
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
483
483
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
484
484
|
}
|
|
485
485
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
486
|
-
const e15 =
|
|
486
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
487
487
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
488
488
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
489
489
|
}
|
|
@@ -506,10 +506,10 @@ const Fe = class e2 extends BasePlugin {
|
|
|
506
506
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
507
507
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
508
508
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
509
|
-
const
|
|
509
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
510
510
|
this.pendingLoadPromises.delete(e14);
|
|
511
511
|
});
|
|
512
|
-
return this.pendingLoadPromises.set(e14,
|
|
512
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
513
513
|
}
|
|
514
514
|
async resolvePdfPayload(e14) {
|
|
515
515
|
const t2 = e14.source;
|
|
@@ -527,17 +527,17 @@ const Fe = class e2 extends BasePlugin {
|
|
|
527
527
|
const s9 = t2.chapterId;
|
|
528
528
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
529
529
|
try {
|
|
530
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
530
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
531
531
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
532
532
|
});
|
|
533
533
|
return await new Promise((e15, t3) => {
|
|
534
534
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
535
535
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
536
|
-
} catch (
|
|
536
|
+
} catch (i2) {
|
|
537
537
|
const t3 = this.chapterStatus.get(s9);
|
|
538
538
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
539
|
-
const t4 =
|
|
540
|
-
this.logger.error(e2.id, "LoadChapter", t4,
|
|
539
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
540
|
+
this.logger.error(e2.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
541
541
|
}
|
|
542
542
|
return this.chapterStatus.get(s9) ?? "error";
|
|
543
543
|
}
|
|
@@ -555,13 +555,13 @@ const Fe = class e2 extends BasePlugin {
|
|
|
555
555
|
async handleDocumentError(t2, a3, s9) {
|
|
556
556
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
557
557
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
558
|
+
const i2 = this.findChapter(t2);
|
|
559
|
+
if (!i2) return;
|
|
560
560
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
561
561
|
this.passwordAttempts.set(t2, o);
|
|
562
562
|
let r2 = null;
|
|
563
563
|
try {
|
|
564
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
564
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
565
565
|
} catch (n2) {
|
|
566
566
|
this.logger.error(e2.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
567
567
|
}
|
|
@@ -581,20 +581,20 @@ const Fe = class e2 extends BasePlugin {
|
|
|
581
581
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
|
-
|
|
585
|
-
let
|
|
586
|
-
function
|
|
584
|
+
je.id = "chapter-manager";
|
|
585
|
+
let Ze = je;
|
|
586
|
+
function Ye(e14, t2) {
|
|
587
587
|
if (e14 === t2) return true;
|
|
588
588
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
589
589
|
for (let a3 = 0; a3 < e14.items.length; a3++) {
|
|
590
|
-
const s9 = e14.items[a3],
|
|
591
|
-
if (s9.globalPageIndex !==
|
|
590
|
+
const s9 = e14.items[a3], i2 = t2.items[a3];
|
|
591
|
+
if (s9.globalPageIndex !== i2.globalPageIndex || s9.isPlaceholder !== i2.isPlaceholder || s9.chapterId !== i2.chapterId || s9.localPageIndex !== i2.localPageIndex || s9.offsetTop !== i2.offsetTop || s9.width !== i2.width || s9.height !== i2.height) return false;
|
|
592
592
|
}
|
|
593
593
|
return true;
|
|
594
594
|
}
|
|
595
|
-
const
|
|
595
|
+
const Ke = class extends BasePlugin {
|
|
596
596
|
constructor(e14, t2) {
|
|
597
|
-
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
597
|
+
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, Ye), 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(Ze.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
598
598
|
}
|
|
599
599
|
async initialize(e14) {
|
|
600
600
|
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 }) => {
|
|
@@ -648,8 +648,8 @@ const We = class extends BasePlugin {
|
|
|
648
648
|
this.offsets = new Array(e14);
|
|
649
649
|
let t2 = 0, a3 = 0;
|
|
650
650
|
for (let s9 = 0; s9 < e14; s9++) {
|
|
651
|
-
const { width: e15, height:
|
|
652
|
-
this.offsets[s9] = t2, t2 +=
|
|
651
|
+
const { width: e15, height: i2 } = this.getPageSize(s9);
|
|
652
|
+
this.offsets[s9] = t2, t2 += i2 + this.config.pageGap, e15 > a3 && (a3 = e15);
|
|
653
653
|
}
|
|
654
654
|
this.totalHeight = e14 > 0 ? t2 - this.config.pageGap : 0, this.totalWidth = a3, this.layoutChange$.emit(this.computeLayout());
|
|
655
655
|
}
|
|
@@ -659,8 +659,8 @@ const We = class extends BasePlugin {
|
|
|
659
659
|
for (const s9 of t2) {
|
|
660
660
|
const t3 = this.virtualPageMap.toGlobal(e14, s9.localPageIndex);
|
|
661
661
|
if (!t3) continue;
|
|
662
|
-
const
|
|
663
|
-
|
|
662
|
+
const i2 = this.pageSizes.get(t3.globalPageIndex);
|
|
663
|
+
i2 && i2.width === s9.width && i2.height === s9.height || (this.pageSizes.set(t3.globalPageIndex, { width: s9.width, height: s9.height }), a3 = true);
|
|
664
664
|
}
|
|
665
665
|
if (a3) {
|
|
666
666
|
const e15 = this.currentGlobalPageIndex, t3 = this.offsets[e15] ?? 0;
|
|
@@ -678,10 +678,10 @@ const We = class extends BasePlugin {
|
|
|
678
678
|
harvestChapterSizes(e14, t2 = 0) {
|
|
679
679
|
var a3;
|
|
680
680
|
if (!this.virtualPageMap) return;
|
|
681
|
-
const s9 = this.documentManager.provides().getDocument(e14),
|
|
682
|
-
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 ===
|
|
681
|
+
const s9 = this.documentManager.provides().getDocument(e14), i2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
682
|
+
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === i2.length) return void (t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1)));
|
|
683
683
|
const o = this.getChapterDocumentScale(e14), r2 = [];
|
|
684
|
-
for (const n2 of
|
|
684
|
+
for (const n2 of i2) {
|
|
685
685
|
const e15 = s9.pages[n2.localPageIndex];
|
|
686
686
|
(null == e15 ? void 0 : e15.size) && r2.push({ localPageIndex: n2.localPageIndex, width: e15.size.width * o, height: e15.size.height * o });
|
|
687
687
|
}
|
|
@@ -712,38 +712,38 @@ const We = class extends BasePlugin {
|
|
|
712
712
|
const e14 = this.virtualPageMap.totalPages;
|
|
713
713
|
if (0 === e14) return this.currentVisible = [], this.currentGlobalPageIndex = 0, void this.layoutChange$.emit(this.computeLayout());
|
|
714
714
|
const t2 = this.viewportEl.scrollTop, a3 = t2 + this.viewportEl.clientHeight, s9 = this.findFirstVisibleIndex(t2);
|
|
715
|
-
let
|
|
716
|
-
for (;
|
|
717
|
-
const e15 = this.getPageSize(
|
|
715
|
+
let i2 = s9;
|
|
716
|
+
for (; i2 < e14; ) {
|
|
717
|
+
const e15 = this.getPageSize(i2), t3 = this.offsets[i2];
|
|
718
718
|
if (e15.height, t3 >= a3) break;
|
|
719
|
-
|
|
719
|
+
i2++;
|
|
720
720
|
}
|
|
721
721
|
const o = [];
|
|
722
722
|
let r2 = s9, n2 = -1;
|
|
723
|
-
for (let l = s9; l <
|
|
723
|
+
for (let l = s9; l < i2; l++) {
|
|
724
724
|
o.push(l);
|
|
725
|
-
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height,
|
|
726
|
-
|
|
725
|
+
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height, i3 = Math.max(0, Math.min(s10, a3) - Math.max(e15, t2));
|
|
726
|
+
i3 > n2 && (n2 = i3, r2 = l);
|
|
727
727
|
}
|
|
728
728
|
this.currentVisible = o, this.currentGlobalPageIndex = r2, this.visibleChange$.emit({ visibleGlobalPageIndices: o, currentGlobalPageIndex: r2 }), this.chapterManager.provides().setVisibleGlobalPages(o), this.layoutChange$.emit(this.computeLayout());
|
|
729
729
|
}
|
|
730
730
|
findFirstVisibleIndex(e14) {
|
|
731
731
|
let t2 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
732
732
|
for (; t2 <= a3; ) {
|
|
733
|
-
const
|
|
734
|
-
this.offsets[
|
|
733
|
+
const i2 = t2 + a3 >> 1;
|
|
734
|
+
this.offsets[i2] <= e14 ? (s9 = i2, t2 = i2 + 1) : a3 = i2 - 1;
|
|
735
735
|
}
|
|
736
736
|
return s9;
|
|
737
737
|
}
|
|
738
738
|
computeLayout() {
|
|
739
|
-
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14),
|
|
739
|
+
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14), i2 = [];
|
|
740
740
|
if (this.virtualPageMap && this.offsets.length > 0) for (let o = t2; o <= s9; o++) {
|
|
741
741
|
const e15 = this.virtualPageMap.atIndex(o);
|
|
742
742
|
if (!e15) continue;
|
|
743
743
|
const t3 = this.getPageSize(o), a4 = this.isChapterPagePlaceholder(e15.chapterId);
|
|
744
|
-
|
|
744
|
+
i2.push({ globalPageIndex: o, globalPageNumber: e15.globalPageNumber, chapterId: e15.chapterId, localPageIndex: e15.localPageIndex, width: t3.width, height: t3.height, offsetTop: this.offsets[o], isPlaceholder: a4 });
|
|
745
745
|
}
|
|
746
|
-
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items:
|
|
746
|
+
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items: i2, pageGap: this.config.pageGap };
|
|
747
747
|
}
|
|
748
748
|
scrollToIndex(e14, t2) {
|
|
749
749
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length) return;
|
|
@@ -753,11 +753,11 @@ const We = class extends BasePlugin {
|
|
|
753
753
|
scrollToGlobalPdfPoint(e14, t2, a3) {
|
|
754
754
|
var s9;
|
|
755
755
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
756
|
-
const
|
|
756
|
+
const i2 = (null == a3 ? void 0 : a3.marginTop) ?? 80, o = this.virtualPageMap.atIndex(e14);
|
|
757
757
|
if (!o) return void this.scrollToIndex(e14, a3);
|
|
758
758
|
const r2 = this.pageSizes.get(e14), n2 = null == (s9 = this.documentManager.provides().getDocument(o.chapterId)) ? void 0 : s9.pages[o.localPageIndex];
|
|
759
759
|
if (!r2 || !n2) return void this.scrollToIndex(e14, a3);
|
|
760
|
-
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l -
|
|
760
|
+
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l - i2;
|
|
761
761
|
this.viewportEl.scrollTo({ top: Math.max(0, h2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
762
762
|
}
|
|
763
763
|
scrollToChapter(e14, t2) {
|
|
@@ -771,12 +771,12 @@ const We = class extends BasePlugin {
|
|
|
771
771
|
a3 && this.scrollToIndex(a3.globalPageIndex, t2);
|
|
772
772
|
}
|
|
773
773
|
};
|
|
774
|
-
|
|
775
|
-
let
|
|
776
|
-
const
|
|
774
|
+
Ke.id = "chapter-scroll";
|
|
775
|
+
let Xe = Ke;
|
|
776
|
+
const Qe = { manifest: Ue, create: (e14) => new Xe(Fe, e14), reducer: (e14) => e14, initialState: {} }, Je = "note", et$1 = { id: Je, name: "Note Plugin", version: "0.1.0", provides: ["note"], requires: ["selection", "chapter-scroll", "chapter-manager"], optional: [], defaultConfig: { callbacks: { onCreateNote: async () => null, onActivateNote: () => {
|
|
777
777
|
} }, markerSize: 18 } };
|
|
778
|
-
const
|
|
779
|
-
function
|
|
778
|
+
const tt$1 = { kind: "first-wins" };
|
|
779
|
+
function at$1(e14, t2, a3) {
|
|
780
780
|
if (1 === t2.length) return t2[0].chapterId;
|
|
781
781
|
switch (a3.kind) {
|
|
782
782
|
case "first-wins":
|
|
@@ -794,7 +794,7 @@ function Ke(e14, t2, a3) {
|
|
|
794
794
|
return a3.resolve(e14, t2);
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
|
-
let
|
|
797
|
+
let st$1 = class st {
|
|
798
798
|
constructor(e14) {
|
|
799
799
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
800
800
|
for (const t2 of e14) {
|
|
@@ -828,37 +828,37 @@ let Xe = class {
|
|
|
828
828
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
|
-
function
|
|
832
|
-
const a3 = (function(e15, t3 =
|
|
831
|
+
function it$1(e14, t2 = tt$1) {
|
|
832
|
+
const a3 = (function(e15, t3 = tt$1) {
|
|
833
833
|
const a4 = /* @__PURE__ */ new Map();
|
|
834
|
-
for (const
|
|
835
|
-
const [e16, t4] =
|
|
834
|
+
for (const i3 of e15.chapters) {
|
|
835
|
+
const [e16, t4] = i3.globalPageRange;
|
|
836
836
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
837
837
|
const e17 = a4.get(s11);
|
|
838
|
-
e17 ? e17.push(
|
|
838
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
const s10 = /* @__PURE__ */ new Map();
|
|
842
|
-
for (const [
|
|
842
|
+
for (const [i3, o2] of a4) s10.set(i3, at$1(i3, o2, t3));
|
|
843
843
|
return s10;
|
|
844
844
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
845
845
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
846
|
-
const
|
|
846
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
847
847
|
let r2 = 0;
|
|
848
|
-
for (const n2 of
|
|
848
|
+
for (const n2 of i2) {
|
|
849
849
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
850
850
|
if (!t3) continue;
|
|
851
|
-
const [
|
|
851
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
852
852
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
853
853
|
}
|
|
854
|
-
return new
|
|
854
|
+
return new st$1(o);
|
|
855
855
|
}
|
|
856
|
-
const
|
|
856
|
+
const ot$1 = class e3 extends BasePlugin {
|
|
857
857
|
constructor(e14, t2) {
|
|
858
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
858
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = tt$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
859
859
|
}
|
|
860
860
|
async initialize(e14) {
|
|
861
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
861
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? tt$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
862
862
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
863
863
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
864
864
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -884,16 +884,16 @@ const Je = class e3 extends BasePlugin {
|
|
|
884
884
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
885
885
|
for (const s10 of e14.chapters) {
|
|
886
886
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
887
|
-
const [e15,
|
|
888
|
-
if (e15 >
|
|
887
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
888
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
889
889
|
}
|
|
890
890
|
return t3;
|
|
891
891
|
})(t2);
|
|
892
892
|
a3.length > 0 && this.logger.warn(e3.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
893
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
894
|
-
for (const e14 of s9)
|
|
893
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
894
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
895
895
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
896
|
-
this.manifest = t2, this.virtualPageMap =
|
|
896
|
+
this.manifest = t2, this.virtualPageMap = it$1(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
897
897
|
}
|
|
898
898
|
eagerPrefetchFromManifest() {
|
|
899
899
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -920,20 +920,20 @@ const Je = class e3 extends BasePlugin {
|
|
|
920
920
|
e15 && s9.add(e15.chapterId);
|
|
921
921
|
}
|
|
922
922
|
if (0 === s9.size) return;
|
|
923
|
-
const
|
|
923
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
924
924
|
for (const n2 of s9) {
|
|
925
|
-
const e15 =
|
|
926
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
925
|
+
const e15 = i2.indexOf(n2);
|
|
926
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
927
927
|
}
|
|
928
928
|
const r2 = /* @__PURE__ */ new Set();
|
|
929
|
-
for (const n2 of o) r2.add(
|
|
929
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
930
930
|
for (const n2 of r2) {
|
|
931
931
|
this.chapterLastUsed.set(n2, t2);
|
|
932
932
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
933
933
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
934
934
|
}
|
|
935
935
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
936
|
-
const e15 =
|
|
936
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
937
937
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
938
938
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
939
939
|
}
|
|
@@ -956,10 +956,10 @@ const Je = class e3 extends BasePlugin {
|
|
|
956
956
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
957
957
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
958
958
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
959
|
-
const
|
|
959
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
960
960
|
this.pendingLoadPromises.delete(e14);
|
|
961
961
|
});
|
|
962
|
-
return this.pendingLoadPromises.set(e14,
|
|
962
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
963
963
|
}
|
|
964
964
|
async resolvePdfPayload(e14) {
|
|
965
965
|
const t2 = e14.source;
|
|
@@ -977,17 +977,17 @@ const Je = class e3 extends BasePlugin {
|
|
|
977
977
|
const s9 = t2.chapterId;
|
|
978
978
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
979
979
|
try {
|
|
980
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
980
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
981
981
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
982
982
|
});
|
|
983
983
|
return await new Promise((e15, t3) => {
|
|
984
984
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
985
985
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
986
|
-
} catch (
|
|
986
|
+
} catch (i2) {
|
|
987
987
|
const t3 = this.chapterStatus.get(s9);
|
|
988
988
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
989
|
-
const t4 =
|
|
990
|
-
this.logger.error(e3.id, "LoadChapter", t4,
|
|
989
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
990
|
+
this.logger.error(e3.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
991
991
|
}
|
|
992
992
|
return this.chapterStatus.get(s9) ?? "error";
|
|
993
993
|
}
|
|
@@ -1005,13 +1005,13 @@ const Je = class e3 extends BasePlugin {
|
|
|
1005
1005
|
async handleDocumentError(t2, a3, s9) {
|
|
1006
1006
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
1007
1007
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
1008
|
-
const
|
|
1009
|
-
if (!
|
|
1008
|
+
const i2 = this.findChapter(t2);
|
|
1009
|
+
if (!i2) return;
|
|
1010
1010
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
1011
1011
|
this.passwordAttempts.set(t2, o);
|
|
1012
1012
|
let r2 = null;
|
|
1013
1013
|
try {
|
|
1014
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
1014
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
1015
1015
|
} catch (n2) {
|
|
1016
1016
|
this.logger.error(e3.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
1017
1017
|
}
|
|
@@ -1031,10 +1031,10 @@ const Je = class e3 extends BasePlugin {
|
|
|
1031
1031
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
1032
1032
|
}
|
|
1033
1033
|
};
|
|
1034
|
-
|
|
1035
|
-
let
|
|
1036
|
-
const
|
|
1037
|
-
function
|
|
1034
|
+
ot$1.id = "chapter-manager";
|
|
1035
|
+
let rt$1 = ot$1;
|
|
1036
|
+
const nt$1 = { kind: "first-wins" };
|
|
1037
|
+
function lt$1(e14, t2, a3) {
|
|
1038
1038
|
if (1 === t2.length) return t2[0].chapterId;
|
|
1039
1039
|
switch (a3.kind) {
|
|
1040
1040
|
case "first-wins":
|
|
@@ -1052,7 +1052,7 @@ function at$1(e14, t2, a3) {
|
|
|
1052
1052
|
return a3.resolve(e14, t2);
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
1055
|
-
let
|
|
1055
|
+
let ht$1 = class ht {
|
|
1056
1056
|
constructor(e14) {
|
|
1057
1057
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
1058
1058
|
for (const t2 of e14) {
|
|
@@ -1086,37 +1086,37 @@ let st$1 = class st {
|
|
|
1086
1086
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
1087
1087
|
}
|
|
1088
1088
|
};
|
|
1089
|
-
function
|
|
1090
|
-
const a3 = (function(e15, t3 =
|
|
1089
|
+
function dt$1(e14, t2 = nt$1) {
|
|
1090
|
+
const a3 = (function(e15, t3 = nt$1) {
|
|
1091
1091
|
const a4 = /* @__PURE__ */ new Map();
|
|
1092
|
-
for (const
|
|
1093
|
-
const [e16, t4] =
|
|
1092
|
+
for (const i3 of e15.chapters) {
|
|
1093
|
+
const [e16, t4] = i3.globalPageRange;
|
|
1094
1094
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
1095
1095
|
const e17 = a4.get(s11);
|
|
1096
|
-
e17 ? e17.push(
|
|
1096
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
const s10 = /* @__PURE__ */ new Map();
|
|
1100
|
-
for (const [
|
|
1100
|
+
for (const [i3, o2] of a4) s10.set(i3, lt$1(i3, o2, t3));
|
|
1101
1101
|
return s10;
|
|
1102
1102
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
1103
1103
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
1104
|
-
const
|
|
1104
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
1105
1105
|
let r2 = 0;
|
|
1106
|
-
for (const n2 of
|
|
1106
|
+
for (const n2 of i2) {
|
|
1107
1107
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
1108
1108
|
if (!t3) continue;
|
|
1109
|
-
const [
|
|
1109
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
1110
1110
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
1111
1111
|
}
|
|
1112
|
-
return new
|
|
1112
|
+
return new ht$1(o);
|
|
1113
1113
|
}
|
|
1114
|
-
const
|
|
1114
|
+
const ct$1 = class e4 extends BasePlugin {
|
|
1115
1115
|
constructor(e14, t2) {
|
|
1116
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
1116
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = nt$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
1117
1117
|
}
|
|
1118
1118
|
async initialize(e14) {
|
|
1119
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
1119
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? nt$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
1120
1120
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
1121
1121
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
1122
1122
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -1142,16 +1142,16 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1142
1142
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
1143
1143
|
for (const s10 of e14.chapters) {
|
|
1144
1144
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
1145
|
-
const [e15,
|
|
1146
|
-
if (e15 >
|
|
1145
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
1146
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
1147
1147
|
}
|
|
1148
1148
|
return t3;
|
|
1149
1149
|
})(t2);
|
|
1150
1150
|
a3.length > 0 && this.logger.warn(e4.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
1151
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
1152
|
-
for (const e14 of s9)
|
|
1151
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
1152
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
1153
1153
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
1154
|
-
this.manifest = t2, this.virtualPageMap =
|
|
1154
|
+
this.manifest = t2, this.virtualPageMap = dt$1(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
1155
1155
|
}
|
|
1156
1156
|
eagerPrefetchFromManifest() {
|
|
1157
1157
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -1178,20 +1178,20 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1178
1178
|
e15 && s9.add(e15.chapterId);
|
|
1179
1179
|
}
|
|
1180
1180
|
if (0 === s9.size) return;
|
|
1181
|
-
const
|
|
1181
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
1182
1182
|
for (const n2 of s9) {
|
|
1183
|
-
const e15 =
|
|
1184
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
1183
|
+
const e15 = i2.indexOf(n2);
|
|
1184
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
1185
1185
|
}
|
|
1186
1186
|
const r2 = /* @__PURE__ */ new Set();
|
|
1187
|
-
for (const n2 of o) r2.add(
|
|
1187
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
1188
1188
|
for (const n2 of r2) {
|
|
1189
1189
|
this.chapterLastUsed.set(n2, t2);
|
|
1190
1190
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
1191
1191
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
1192
1192
|
}
|
|
1193
1193
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
1194
|
-
const e15 =
|
|
1194
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
1195
1195
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
1196
1196
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
1197
1197
|
}
|
|
@@ -1214,10 +1214,10 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1214
1214
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
1215
1215
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
1216
1216
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
1217
|
-
const
|
|
1217
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
1218
1218
|
this.pendingLoadPromises.delete(e14);
|
|
1219
1219
|
});
|
|
1220
|
-
return this.pendingLoadPromises.set(e14,
|
|
1220
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
1221
1221
|
}
|
|
1222
1222
|
async resolvePdfPayload(e14) {
|
|
1223
1223
|
const t2 = e14.source;
|
|
@@ -1235,17 +1235,17 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1235
1235
|
const s9 = t2.chapterId;
|
|
1236
1236
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
1237
1237
|
try {
|
|
1238
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
1238
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
1239
1239
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
1240
1240
|
});
|
|
1241
1241
|
return await new Promise((e15, t3) => {
|
|
1242
1242
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
1243
1243
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
1244
|
-
} catch (
|
|
1244
|
+
} catch (i2) {
|
|
1245
1245
|
const t3 = this.chapterStatus.get(s9);
|
|
1246
1246
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
1247
|
-
const t4 =
|
|
1248
|
-
this.logger.error(e4.id, "LoadChapter", t4,
|
|
1247
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
1248
|
+
this.logger.error(e4.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
1249
1249
|
}
|
|
1250
1250
|
return this.chapterStatus.get(s9) ?? "error";
|
|
1251
1251
|
}
|
|
@@ -1263,13 +1263,13 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1263
1263
|
async handleDocumentError(t2, a3, s9) {
|
|
1264
1264
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
1265
1265
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
1266
|
-
const
|
|
1267
|
-
if (!
|
|
1266
|
+
const i2 = this.findChapter(t2);
|
|
1267
|
+
if (!i2) return;
|
|
1268
1268
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
1269
1269
|
this.passwordAttempts.set(t2, o);
|
|
1270
1270
|
let r2 = null;
|
|
1271
1271
|
try {
|
|
1272
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
1272
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
1273
1273
|
} catch (n2) {
|
|
1274
1274
|
this.logger.error(e4.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
1275
1275
|
}
|
|
@@ -1289,20 +1289,20 @@ const ot$1 = class e4 extends BasePlugin {
|
|
|
1289
1289
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
1290
1290
|
}
|
|
1291
1291
|
};
|
|
1292
|
-
|
|
1293
|
-
let
|
|
1294
|
-
function
|
|
1292
|
+
ct$1.id = "chapter-manager";
|
|
1293
|
+
let ut = ct$1;
|
|
1294
|
+
function pt(e14, t2) {
|
|
1295
1295
|
if (e14 === t2) return true;
|
|
1296
1296
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
1297
1297
|
for (let a3 = 0; a3 < e14.items.length; a3++) {
|
|
1298
|
-
const s9 = e14.items[a3],
|
|
1299
|
-
if (s9.globalPageIndex !==
|
|
1298
|
+
const s9 = e14.items[a3], i2 = t2.items[a3];
|
|
1299
|
+
if (s9.globalPageIndex !== i2.globalPageIndex || s9.isPlaceholder !== i2.isPlaceholder || s9.chapterId !== i2.chapterId || s9.localPageIndex !== i2.localPageIndex || s9.offsetTop !== i2.offsetTop || s9.width !== i2.width || s9.height !== i2.height) return false;
|
|
1300
1300
|
}
|
|
1301
1301
|
return true;
|
|
1302
1302
|
}
|
|
1303
|
-
const
|
|
1303
|
+
const gt = class extends BasePlugin {
|
|
1304
1304
|
constructor(e14, t2) {
|
|
1305
|
-
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
1305
|
+
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, pt), 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(ut.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
1306
1306
|
}
|
|
1307
1307
|
async initialize(e14) {
|
|
1308
1308
|
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 }) => {
|
|
@@ -1356,8 +1356,8 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1356
1356
|
this.offsets = new Array(e14);
|
|
1357
1357
|
let t2 = 0, a3 = 0;
|
|
1358
1358
|
for (let s9 = 0; s9 < e14; s9++) {
|
|
1359
|
-
const { width: e15, height:
|
|
1360
|
-
this.offsets[s9] = t2, t2 +=
|
|
1359
|
+
const { width: e15, height: i2 } = this.getPageSize(s9);
|
|
1360
|
+
this.offsets[s9] = t2, t2 += i2 + this.config.pageGap, e15 > a3 && (a3 = e15);
|
|
1361
1361
|
}
|
|
1362
1362
|
this.totalHeight = e14 > 0 ? t2 - this.config.pageGap : 0, this.totalWidth = a3, this.layoutChange$.emit(this.computeLayout());
|
|
1363
1363
|
}
|
|
@@ -1367,8 +1367,8 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1367
1367
|
for (const s9 of t2) {
|
|
1368
1368
|
const t3 = this.virtualPageMap.toGlobal(e14, s9.localPageIndex);
|
|
1369
1369
|
if (!t3) continue;
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1370
|
+
const i2 = this.pageSizes.get(t3.globalPageIndex);
|
|
1371
|
+
i2 && i2.width === s9.width && i2.height === s9.height || (this.pageSizes.set(t3.globalPageIndex, { width: s9.width, height: s9.height }), a3 = true);
|
|
1372
1372
|
}
|
|
1373
1373
|
if (a3) {
|
|
1374
1374
|
const e15 = this.currentGlobalPageIndex, t3 = this.offsets[e15] ?? 0;
|
|
@@ -1386,10 +1386,10 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1386
1386
|
harvestChapterSizes(e14, t2 = 0) {
|
|
1387
1387
|
var a3;
|
|
1388
1388
|
if (!this.virtualPageMap) return;
|
|
1389
|
-
const s9 = this.documentManager.provides().getDocument(e14),
|
|
1390
|
-
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 ===
|
|
1389
|
+
const s9 = this.documentManager.provides().getDocument(e14), i2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
1390
|
+
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === i2.length) return void (t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1)));
|
|
1391
1391
|
const o = this.getChapterDocumentScale(e14), r2 = [];
|
|
1392
|
-
for (const n2 of
|
|
1392
|
+
for (const n2 of i2) {
|
|
1393
1393
|
const e15 = s9.pages[n2.localPageIndex];
|
|
1394
1394
|
(null == e15 ? void 0 : e15.size) && r2.push({ localPageIndex: n2.localPageIndex, width: e15.size.width * o, height: e15.size.height * o });
|
|
1395
1395
|
}
|
|
@@ -1420,38 +1420,38 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1420
1420
|
const e14 = this.virtualPageMap.totalPages;
|
|
1421
1421
|
if (0 === e14) return this.currentVisible = [], this.currentGlobalPageIndex = 0, void this.layoutChange$.emit(this.computeLayout());
|
|
1422
1422
|
const t2 = this.viewportEl.scrollTop, a3 = t2 + this.viewportEl.clientHeight, s9 = this.findFirstVisibleIndex(t2);
|
|
1423
|
-
let
|
|
1424
|
-
for (;
|
|
1425
|
-
const e15 = this.getPageSize(
|
|
1423
|
+
let i2 = s9;
|
|
1424
|
+
for (; i2 < e14; ) {
|
|
1425
|
+
const e15 = this.getPageSize(i2), t3 = this.offsets[i2];
|
|
1426
1426
|
if (e15.height, t3 >= a3) break;
|
|
1427
|
-
|
|
1427
|
+
i2++;
|
|
1428
1428
|
}
|
|
1429
1429
|
const o = [];
|
|
1430
1430
|
let r2 = s9, n2 = -1;
|
|
1431
|
-
for (let l = s9; l <
|
|
1431
|
+
for (let l = s9; l < i2; l++) {
|
|
1432
1432
|
o.push(l);
|
|
1433
|
-
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height,
|
|
1434
|
-
|
|
1433
|
+
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height, i3 = Math.max(0, Math.min(s10, a3) - Math.max(e15, t2));
|
|
1434
|
+
i3 > n2 && (n2 = i3, r2 = l);
|
|
1435
1435
|
}
|
|
1436
1436
|
this.currentVisible = o, this.currentGlobalPageIndex = r2, this.visibleChange$.emit({ visibleGlobalPageIndices: o, currentGlobalPageIndex: r2 }), this.chapterManager.provides().setVisibleGlobalPages(o), this.layoutChange$.emit(this.computeLayout());
|
|
1437
1437
|
}
|
|
1438
1438
|
findFirstVisibleIndex(e14) {
|
|
1439
1439
|
let t2 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
1440
1440
|
for (; t2 <= a3; ) {
|
|
1441
|
-
const
|
|
1442
|
-
this.offsets[
|
|
1441
|
+
const i2 = t2 + a3 >> 1;
|
|
1442
|
+
this.offsets[i2] <= e14 ? (s9 = i2, t2 = i2 + 1) : a3 = i2 - 1;
|
|
1443
1443
|
}
|
|
1444
1444
|
return s9;
|
|
1445
1445
|
}
|
|
1446
1446
|
computeLayout() {
|
|
1447
|
-
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14),
|
|
1447
|
+
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14), i2 = [];
|
|
1448
1448
|
if (this.virtualPageMap && this.offsets.length > 0) for (let o = t2; o <= s9; o++) {
|
|
1449
1449
|
const e15 = this.virtualPageMap.atIndex(o);
|
|
1450
1450
|
if (!e15) continue;
|
|
1451
1451
|
const t3 = this.getPageSize(o), a4 = this.isChapterPagePlaceholder(e15.chapterId);
|
|
1452
|
-
|
|
1452
|
+
i2.push({ globalPageIndex: o, globalPageNumber: e15.globalPageNumber, chapterId: e15.chapterId, localPageIndex: e15.localPageIndex, width: t3.width, height: t3.height, offsetTop: this.offsets[o], isPlaceholder: a4 });
|
|
1453
1453
|
}
|
|
1454
|
-
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items:
|
|
1454
|
+
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items: i2, pageGap: this.config.pageGap };
|
|
1455
1455
|
}
|
|
1456
1456
|
scrollToIndex(e14, t2) {
|
|
1457
1457
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length) return;
|
|
@@ -1461,11 +1461,11 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1461
1461
|
scrollToGlobalPdfPoint(e14, t2, a3) {
|
|
1462
1462
|
var s9;
|
|
1463
1463
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
1464
|
-
const
|
|
1464
|
+
const i2 = (null == a3 ? void 0 : a3.marginTop) ?? 80, o = this.virtualPageMap.atIndex(e14);
|
|
1465
1465
|
if (!o) return void this.scrollToIndex(e14, a3);
|
|
1466
1466
|
const r2 = this.pageSizes.get(e14), n2 = null == (s9 = this.documentManager.provides().getDocument(o.chapterId)) ? void 0 : s9.pages[o.localPageIndex];
|
|
1467
1467
|
if (!r2 || !n2) return void this.scrollToIndex(e14, a3);
|
|
1468
|
-
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l -
|
|
1468
|
+
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l - i2;
|
|
1469
1469
|
this.viewportEl.scrollTo({ top: Math.max(0, h2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
1470
1470
|
}
|
|
1471
1471
|
scrollToChapter(e14, t2) {
|
|
@@ -1479,11 +1479,11 @@ const lt$1 = class lt extends BasePlugin {
|
|
|
1479
1479
|
a3 && this.scrollToIndex(a3.globalPageIndex, t2);
|
|
1480
1480
|
}
|
|
1481
1481
|
};
|
|
1482
|
-
|
|
1483
|
-
let
|
|
1484
|
-
const
|
|
1482
|
+
gt.id = "chapter-scroll";
|
|
1483
|
+
let ft$1 = gt;
|
|
1484
|
+
const mt$1 = class e5 extends BasePlugin {
|
|
1485
1485
|
constructor(e14, t2) {
|
|
1486
|
-
super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(
|
|
1486
|
+
super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(ft$1.id), this.chapterManager = this.registry.getPlugin(rt$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
1487
1487
|
}
|
|
1488
1488
|
async initialize(t2) {
|
|
1489
1489
|
if (this.config = t2, t2.callbacks.loadNotes) try {
|
|
@@ -1521,7 +1521,7 @@ const dt$1 = class e5 extends BasePlugin {
|
|
|
1521
1521
|
this.notesChange$.emit(this.listAll());
|
|
1522
1522
|
}
|
|
1523
1523
|
buildDraft(e14) {
|
|
1524
|
-
return { chapterId: e14.chapterId, localPageIndex: e14.localPageIndex, globalPageNumber: e14.globalPageNumber, globalPageIndex: e14.globalPageIndex, rectsPdfCoord: e14.rectsPdfCoord, endAnchor:
|
|
1524
|
+
return { chapterId: e14.chapterId, localPageIndex: e14.localPageIndex, globalPageNumber: e14.globalPageNumber, globalPageIndex: e14.globalPageIndex, rectsPdfCoord: e14.rectsPdfCoord, endAnchor: bt$1(e14.rectsPdfCoord), selectedText: e14.selectedText, content: e14.content };
|
|
1525
1525
|
}
|
|
1526
1526
|
async requestCreateFromSelection(e14) {
|
|
1527
1527
|
if (0 === e14.rectsPdfCoord.length) return null;
|
|
@@ -1535,14 +1535,14 @@ const dt$1 = class e5 extends BasePlugin {
|
|
|
1535
1535
|
if (0 === t2.rectsPdfCoord.length) return null;
|
|
1536
1536
|
const a3 = this.buildDraft(t2), s9 = this.config.callbacks.onCreateNote;
|
|
1537
1537
|
if (!s9) return this.logger.error(e5.id, "CreateNote", "Missing onCreateNote / onRequestCreateNote"), null;
|
|
1538
|
-
let
|
|
1538
|
+
let i2 = null;
|
|
1539
1539
|
try {
|
|
1540
|
-
|
|
1540
|
+
i2 = await s9(a3);
|
|
1541
1541
|
} catch (r2) {
|
|
1542
1542
|
return this.logger.error(e5.id, "OnCreateNote", "Callback failed", r2), null;
|
|
1543
1543
|
}
|
|
1544
|
-
if (!
|
|
1545
|
-
const o = { ...a3, noteId:
|
|
1544
|
+
if (!i2) return null;
|
|
1545
|
+
const o = { ...a3, noteId: i2.noteId };
|
|
1546
1546
|
return this.registerNote(o), o;
|
|
1547
1547
|
}
|
|
1548
1548
|
async deleteNote(t2) {
|
|
@@ -1550,19 +1550,19 @@ const dt$1 = class e5 extends BasePlugin {
|
|
|
1550
1550
|
if (this.notes.has(t2)) {
|
|
1551
1551
|
try {
|
|
1552
1552
|
await (null == (s9 = (a3 = this.config.callbacks).onDeleteNote) ? void 0 : s9.call(a3, t2));
|
|
1553
|
-
} catch (
|
|
1554
|
-
return void this.logger.error(e5.id, "OnDeleteNote", "Callback failed",
|
|
1553
|
+
} catch (i2) {
|
|
1554
|
+
return void this.logger.error(e5.id, "OnDeleteNote", "Callback failed", i2);
|
|
1555
1555
|
}
|
|
1556
1556
|
this.notes.delete(t2), this.notesChange$.emit(this.listAll());
|
|
1557
1557
|
}
|
|
1558
1558
|
}
|
|
1559
1559
|
async updateNoteContent(t2, a3) {
|
|
1560
|
-
var s9,
|
|
1560
|
+
var s9, i2;
|
|
1561
1561
|
const o = this.notes.get(t2);
|
|
1562
1562
|
if (!o) return;
|
|
1563
1563
|
const r2 = { ...o, content: a3 };
|
|
1564
1564
|
try {
|
|
1565
|
-
await (null == (
|
|
1565
|
+
await (null == (i2 = (s9 = this.config.callbacks).onUpdateNote) ? void 0 : i2.call(s9, r2));
|
|
1566
1566
|
} catch (n2) {
|
|
1567
1567
|
return void this.logger.error(e5.id, "OnUpdateNote", "Callback failed", n2);
|
|
1568
1568
|
}
|
|
@@ -1580,23 +1580,23 @@ const dt$1 = class e5 extends BasePlugin {
|
|
|
1580
1580
|
const t2 = this.chapterScroll.provides(), a3 = t2.getLayout().items.find((t3) => t3.globalPageIndex === e14 && !t3.isPlaceholder);
|
|
1581
1581
|
return a3 ? Promise.resolve(a3) : new Promise((a4) => {
|
|
1582
1582
|
const s9 = setTimeout(() => {
|
|
1583
|
-
|
|
1584
|
-
}, 2500),
|
|
1583
|
+
i2(), a4(null);
|
|
1584
|
+
}, 2500), i2 = t2.onLayoutChange((t3) => {
|
|
1585
1585
|
const o = t3.items.find((t4) => t4.globalPageIndex === e14 && !t4.isPlaceholder);
|
|
1586
|
-
o && (clearTimeout(s9),
|
|
1586
|
+
o && (clearTimeout(s9), i2(), a4(o));
|
|
1587
1587
|
});
|
|
1588
1588
|
});
|
|
1589
1589
|
}
|
|
1590
1590
|
};
|
|
1591
|
-
|
|
1592
|
-
let
|
|
1593
|
-
function
|
|
1591
|
+
mt$1.id = "note";
|
|
1592
|
+
let vt$1 = mt$1;
|
|
1593
|
+
function bt$1(e14) {
|
|
1594
1594
|
const t2 = e14[e14.length - 1];
|
|
1595
1595
|
return { x: t2.origin.x + t2.size.width, y: t2.origin.y + t2.size.height };
|
|
1596
1596
|
}
|
|
1597
|
-
const
|
|
1598
|
-
const
|
|
1599
|
-
function
|
|
1597
|
+
const Pt$1 = { manifest: et$1, create: (e14) => new vt$1(Je, e14), reducer: (e14) => e14, initialState: {} }, wt$1 = "paragraph-bookmark", yt$1 = { id: wt$1, name: "Paragraph Bookmark Plugin", version: "0.1.0", provides: ["paragraph-bookmark"], requires: ["chapter-scroll", "chapter-manager"], optional: [], defaultConfig: {} };
|
|
1598
|
+
const Ct$1 = { kind: "first-wins" };
|
|
1599
|
+
function It$1(e14, t2, a3) {
|
|
1600
1600
|
if (1 === t2.length) return t2[0].chapterId;
|
|
1601
1601
|
switch (a3.kind) {
|
|
1602
1602
|
case "first-wins":
|
|
@@ -1614,7 +1614,7 @@ function vt$1(e14, t2, a3) {
|
|
|
1614
1614
|
return a3.resolve(e14, t2);
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
let
|
|
1617
|
+
let Mt$1 = class Mt {
|
|
1618
1618
|
constructor(e14) {
|
|
1619
1619
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
1620
1620
|
for (const t2 of e14) {
|
|
@@ -1648,37 +1648,37 @@ let bt$1 = class bt {
|
|
|
1648
1648
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
1649
1649
|
}
|
|
1650
1650
|
};
|
|
1651
|
-
function
|
|
1652
|
-
const a3 = (function(e15, t3 =
|
|
1651
|
+
function St$1(e14, t2 = Ct$1) {
|
|
1652
|
+
const a3 = (function(e15, t3 = Ct$1) {
|
|
1653
1653
|
const a4 = /* @__PURE__ */ new Map();
|
|
1654
|
-
for (const
|
|
1655
|
-
const [e16, t4] =
|
|
1654
|
+
for (const i3 of e15.chapters) {
|
|
1655
|
+
const [e16, t4] = i3.globalPageRange;
|
|
1656
1656
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
1657
1657
|
const e17 = a4.get(s11);
|
|
1658
|
-
e17 ? e17.push(
|
|
1658
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
1659
1659
|
}
|
|
1660
1660
|
}
|
|
1661
1661
|
const s10 = /* @__PURE__ */ new Map();
|
|
1662
|
-
for (const [
|
|
1662
|
+
for (const [i3, o2] of a4) s10.set(i3, It$1(i3, o2, t3));
|
|
1663
1663
|
return s10;
|
|
1664
1664
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
1665
1665
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
1666
|
-
const
|
|
1666
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
1667
1667
|
let r2 = 0;
|
|
1668
|
-
for (const n2 of
|
|
1668
|
+
for (const n2 of i2) {
|
|
1669
1669
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
1670
1670
|
if (!t3) continue;
|
|
1671
|
-
const [
|
|
1671
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
1672
1672
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
1673
1673
|
}
|
|
1674
|
-
return new
|
|
1674
|
+
return new Mt$1(o);
|
|
1675
1675
|
}
|
|
1676
|
-
const
|
|
1676
|
+
const xt$1 = class e6 extends BasePlugin {
|
|
1677
1677
|
constructor(e14, t2) {
|
|
1678
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
1678
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Ct$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
1679
1679
|
}
|
|
1680
1680
|
async initialize(e14) {
|
|
1681
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
1681
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Ct$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
1682
1682
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
1683
1683
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
1684
1684
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -1704,16 +1704,16 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1704
1704
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
1705
1705
|
for (const s10 of e14.chapters) {
|
|
1706
1706
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
1707
|
-
const [e15,
|
|
1708
|
-
if (e15 >
|
|
1707
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
1708
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
1709
1709
|
}
|
|
1710
1710
|
return t3;
|
|
1711
1711
|
})(t2);
|
|
1712
1712
|
a3.length > 0 && this.logger.warn(e6.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
1713
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
1714
|
-
for (const e14 of s9)
|
|
1713
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
1714
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
1715
1715
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
1716
|
-
this.manifest = t2, this.virtualPageMap =
|
|
1716
|
+
this.manifest = t2, this.virtualPageMap = St$1(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
1717
1717
|
}
|
|
1718
1718
|
eagerPrefetchFromManifest() {
|
|
1719
1719
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -1740,20 +1740,20 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1740
1740
|
e15 && s9.add(e15.chapterId);
|
|
1741
1741
|
}
|
|
1742
1742
|
if (0 === s9.size) return;
|
|
1743
|
-
const
|
|
1743
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
1744
1744
|
for (const n2 of s9) {
|
|
1745
|
-
const e15 =
|
|
1746
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
1745
|
+
const e15 = i2.indexOf(n2);
|
|
1746
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
1747
1747
|
}
|
|
1748
1748
|
const r2 = /* @__PURE__ */ new Set();
|
|
1749
|
-
for (const n2 of o) r2.add(
|
|
1749
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
1750
1750
|
for (const n2 of r2) {
|
|
1751
1751
|
this.chapterLastUsed.set(n2, t2);
|
|
1752
1752
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
1753
1753
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
1754
1754
|
}
|
|
1755
1755
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
1756
|
-
const e15 =
|
|
1756
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
1757
1757
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
1758
1758
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
1759
1759
|
}
|
|
@@ -1776,10 +1776,10 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1776
1776
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
1777
1777
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
1778
1778
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
1779
|
-
const
|
|
1779
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
1780
1780
|
this.pendingLoadPromises.delete(e14);
|
|
1781
1781
|
});
|
|
1782
|
-
return this.pendingLoadPromises.set(e14,
|
|
1782
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
1783
1783
|
}
|
|
1784
1784
|
async resolvePdfPayload(e14) {
|
|
1785
1785
|
const t2 = e14.source;
|
|
@@ -1797,17 +1797,17 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1797
1797
|
const s9 = t2.chapterId;
|
|
1798
1798
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
1799
1799
|
try {
|
|
1800
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
1800
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
1801
1801
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
1802
1802
|
});
|
|
1803
1803
|
return await new Promise((e15, t3) => {
|
|
1804
1804
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
1805
1805
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
1806
|
-
} catch (
|
|
1806
|
+
} catch (i2) {
|
|
1807
1807
|
const t3 = this.chapterStatus.get(s9);
|
|
1808
1808
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
1809
|
-
const t4 =
|
|
1810
|
-
this.logger.error(e6.id, "LoadChapter", t4,
|
|
1809
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
1810
|
+
this.logger.error(e6.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
1811
1811
|
}
|
|
1812
1812
|
return this.chapterStatus.get(s9) ?? "error";
|
|
1813
1813
|
}
|
|
@@ -1825,13 +1825,13 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1825
1825
|
async handleDocumentError(t2, a3, s9) {
|
|
1826
1826
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
1827
1827
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
1828
|
-
const
|
|
1829
|
-
if (!
|
|
1828
|
+
const i2 = this.findChapter(t2);
|
|
1829
|
+
if (!i2) return;
|
|
1830
1830
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
1831
1831
|
this.passwordAttempts.set(t2, o);
|
|
1832
1832
|
let r2 = null;
|
|
1833
1833
|
try {
|
|
1834
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
1834
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
1835
1835
|
} catch (n2) {
|
|
1836
1836
|
this.logger.error(e6.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
1837
1837
|
}
|
|
@@ -1851,10 +1851,10 @@ const wt$1 = class e6 extends BasePlugin {
|
|
|
1851
1851
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
1852
1852
|
}
|
|
1853
1853
|
};
|
|
1854
|
-
|
|
1855
|
-
let
|
|
1856
|
-
const
|
|
1857
|
-
function
|
|
1854
|
+
xt$1.id = "chapter-manager";
|
|
1855
|
+
let kt$1 = xt$1;
|
|
1856
|
+
const Lt$1 = { kind: "first-wins" };
|
|
1857
|
+
function $t$1(e14, t2, a3) {
|
|
1858
1858
|
if (1 === t2.length) return t2[0].chapterId;
|
|
1859
1859
|
switch (a3.kind) {
|
|
1860
1860
|
case "first-wins":
|
|
@@ -1872,7 +1872,7 @@ function It$1(e14, t2, a3) {
|
|
|
1872
1872
|
return a3.resolve(e14, t2);
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
|
-
let
|
|
1875
|
+
let zt$1 = class zt {
|
|
1876
1876
|
constructor(e14) {
|
|
1877
1877
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
1878
1878
|
for (const t2 of e14) {
|
|
@@ -1906,37 +1906,37 @@ let Mt$1 = class Mt {
|
|
|
1906
1906
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
1907
1907
|
}
|
|
1908
1908
|
};
|
|
1909
|
-
function
|
|
1910
|
-
const a3 = (function(e15, t3 =
|
|
1909
|
+
function Tt$1(e14, t2 = Lt$1) {
|
|
1910
|
+
const a3 = (function(e15, t3 = Lt$1) {
|
|
1911
1911
|
const a4 = /* @__PURE__ */ new Map();
|
|
1912
|
-
for (const
|
|
1913
|
-
const [e16, t4] =
|
|
1912
|
+
for (const i3 of e15.chapters) {
|
|
1913
|
+
const [e16, t4] = i3.globalPageRange;
|
|
1914
1914
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
1915
1915
|
const e17 = a4.get(s11);
|
|
1916
|
-
e17 ? e17.push(
|
|
1916
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
1917
1917
|
}
|
|
1918
1918
|
}
|
|
1919
1919
|
const s10 = /* @__PURE__ */ new Map();
|
|
1920
|
-
for (const [
|
|
1920
|
+
for (const [i3, o2] of a4) s10.set(i3, $t$1(i3, o2, t3));
|
|
1921
1921
|
return s10;
|
|
1922
1922
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
1923
1923
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
1924
|
-
const
|
|
1924
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
1925
1925
|
let r2 = 0;
|
|
1926
|
-
for (const n2 of
|
|
1926
|
+
for (const n2 of i2) {
|
|
1927
1927
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
1928
1928
|
if (!t3) continue;
|
|
1929
|
-
const [
|
|
1929
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
1930
1930
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
1931
1931
|
}
|
|
1932
|
-
return new
|
|
1932
|
+
return new zt$1(o);
|
|
1933
1933
|
}
|
|
1934
|
-
const
|
|
1934
|
+
const Dt$1 = class e7 extends BasePlugin {
|
|
1935
1935
|
constructor(e14, t2) {
|
|
1936
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
1936
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Lt$1, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
1937
1937
|
}
|
|
1938
1938
|
async initialize(e14) {
|
|
1939
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
1939
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Lt$1, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
1940
1940
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
1941
1941
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
1942
1942
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -1962,16 +1962,16 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
1962
1962
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
1963
1963
|
for (const s10 of e14.chapters) {
|
|
1964
1964
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
1965
|
-
const [e15,
|
|
1966
|
-
if (e15 >
|
|
1965
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
1966
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
1967
1967
|
}
|
|
1968
1968
|
return t3;
|
|
1969
1969
|
})(t2);
|
|
1970
1970
|
a3.length > 0 && this.logger.warn(e7.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
1971
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
1972
|
-
for (const e14 of s9)
|
|
1971
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
1972
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
1973
1973
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
1974
|
-
this.manifest = t2, this.virtualPageMap =
|
|
1974
|
+
this.manifest = t2, this.virtualPageMap = Tt$1(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
1975
1975
|
}
|
|
1976
1976
|
eagerPrefetchFromManifest() {
|
|
1977
1977
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -1998,20 +1998,20 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
1998
1998
|
e15 && s9.add(e15.chapterId);
|
|
1999
1999
|
}
|
|
2000
2000
|
if (0 === s9.size) return;
|
|
2001
|
-
const
|
|
2001
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
2002
2002
|
for (const n2 of s9) {
|
|
2003
|
-
const e15 =
|
|
2004
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
2003
|
+
const e15 = i2.indexOf(n2);
|
|
2004
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
2005
2005
|
}
|
|
2006
2006
|
const r2 = /* @__PURE__ */ new Set();
|
|
2007
|
-
for (const n2 of o) r2.add(
|
|
2007
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
2008
2008
|
for (const n2 of r2) {
|
|
2009
2009
|
this.chapterLastUsed.set(n2, t2);
|
|
2010
2010
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
2011
2011
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
2012
2012
|
}
|
|
2013
2013
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
2014
|
-
const e15 =
|
|
2014
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
2015
2015
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
2016
2016
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
2017
2017
|
}
|
|
@@ -2034,10 +2034,10 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
2034
2034
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
2035
2035
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
2036
2036
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
2037
|
-
const
|
|
2037
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
2038
2038
|
this.pendingLoadPromises.delete(e14);
|
|
2039
2039
|
});
|
|
2040
|
-
return this.pendingLoadPromises.set(e14,
|
|
2040
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
2041
2041
|
}
|
|
2042
2042
|
async resolvePdfPayload(e14) {
|
|
2043
2043
|
const t2 = e14.source;
|
|
@@ -2055,17 +2055,17 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
2055
2055
|
const s9 = t2.chapterId;
|
|
2056
2056
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
2057
2057
|
try {
|
|
2058
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
2058
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
2059
2059
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
2060
2060
|
});
|
|
2061
2061
|
return await new Promise((e15, t3) => {
|
|
2062
2062
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
2063
2063
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
2064
|
-
} catch (
|
|
2064
|
+
} catch (i2) {
|
|
2065
2065
|
const t3 = this.chapterStatus.get(s9);
|
|
2066
2066
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
2067
|
-
const t4 =
|
|
2068
|
-
this.logger.error(e7.id, "LoadChapter", t4,
|
|
2067
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
2068
|
+
this.logger.error(e7.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
2069
2069
|
}
|
|
2070
2070
|
return this.chapterStatus.get(s9) ?? "error";
|
|
2071
2071
|
}
|
|
@@ -2083,13 +2083,13 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
2083
2083
|
async handleDocumentError(t2, a3, s9) {
|
|
2084
2084
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
2085
2085
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
2086
|
-
const
|
|
2087
|
-
if (!
|
|
2086
|
+
const i2 = this.findChapter(t2);
|
|
2087
|
+
if (!i2) return;
|
|
2088
2088
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
2089
2089
|
this.passwordAttempts.set(t2, o);
|
|
2090
2090
|
let r2 = null;
|
|
2091
2091
|
try {
|
|
2092
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
2092
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
2093
2093
|
} catch (n2) {
|
|
2094
2094
|
this.logger.error(e7.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
2095
2095
|
}
|
|
@@ -2109,20 +2109,20 @@ const xt$1 = class e7 extends BasePlugin {
|
|
|
2109
2109
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
2110
2110
|
}
|
|
2111
2111
|
};
|
|
2112
|
-
|
|
2113
|
-
let
|
|
2114
|
-
function
|
|
2112
|
+
Dt$1.id = "chapter-manager";
|
|
2113
|
+
let Ot$1 = Dt$1;
|
|
2114
|
+
function Gt$1(e14, t2) {
|
|
2115
2115
|
if (e14 === t2) return true;
|
|
2116
2116
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
2117
2117
|
for (let a3 = 0; a3 < e14.items.length; a3++) {
|
|
2118
|
-
const s9 = e14.items[a3],
|
|
2119
|
-
if (s9.globalPageIndex !==
|
|
2118
|
+
const s9 = e14.items[a3], i2 = t2.items[a3];
|
|
2119
|
+
if (s9.globalPageIndex !== i2.globalPageIndex || s9.isPlaceholder !== i2.isPlaceholder || s9.chapterId !== i2.chapterId || s9.localPageIndex !== i2.localPageIndex || s9.offsetTop !== i2.offsetTop || s9.width !== i2.width || s9.height !== i2.height) return false;
|
|
2120
2120
|
}
|
|
2121
2121
|
return true;
|
|
2122
2122
|
}
|
|
2123
|
-
const
|
|
2123
|
+
const Nt = class extends BasePlugin {
|
|
2124
2124
|
constructor(e14, t2) {
|
|
2125
|
-
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
2125
|
+
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, Gt$1), 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(Ot$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
2126
2126
|
}
|
|
2127
2127
|
async initialize(e14) {
|
|
2128
2128
|
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 }) => {
|
|
@@ -2176,8 +2176,8 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2176
2176
|
this.offsets = new Array(e14);
|
|
2177
2177
|
let t2 = 0, a3 = 0;
|
|
2178
2178
|
for (let s9 = 0; s9 < e14; s9++) {
|
|
2179
|
-
const { width: e15, height:
|
|
2180
|
-
this.offsets[s9] = t2, t2 +=
|
|
2179
|
+
const { width: e15, height: i2 } = this.getPageSize(s9);
|
|
2180
|
+
this.offsets[s9] = t2, t2 += i2 + this.config.pageGap, e15 > a3 && (a3 = e15);
|
|
2181
2181
|
}
|
|
2182
2182
|
this.totalHeight = e14 > 0 ? t2 - this.config.pageGap : 0, this.totalWidth = a3, this.layoutChange$.emit(this.computeLayout());
|
|
2183
2183
|
}
|
|
@@ -2187,8 +2187,8 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2187
2187
|
for (const s9 of t2) {
|
|
2188
2188
|
const t3 = this.virtualPageMap.toGlobal(e14, s9.localPageIndex);
|
|
2189
2189
|
if (!t3) continue;
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2190
|
+
const i2 = this.pageSizes.get(t3.globalPageIndex);
|
|
2191
|
+
i2 && i2.width === s9.width && i2.height === s9.height || (this.pageSizes.set(t3.globalPageIndex, { width: s9.width, height: s9.height }), a3 = true);
|
|
2192
2192
|
}
|
|
2193
2193
|
if (a3) {
|
|
2194
2194
|
const e15 = this.currentGlobalPageIndex, t3 = this.offsets[e15] ?? 0;
|
|
@@ -2206,10 +2206,10 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2206
2206
|
harvestChapterSizes(e14, t2 = 0) {
|
|
2207
2207
|
var a3;
|
|
2208
2208
|
if (!this.virtualPageMap) return;
|
|
2209
|
-
const s9 = this.documentManager.provides().getDocument(e14),
|
|
2210
|
-
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 ===
|
|
2209
|
+
const s9 = this.documentManager.provides().getDocument(e14), i2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
2210
|
+
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === i2.length) return void (t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1)));
|
|
2211
2211
|
const o = this.getChapterDocumentScale(e14), r2 = [];
|
|
2212
|
-
for (const n2 of
|
|
2212
|
+
for (const n2 of i2) {
|
|
2213
2213
|
const e15 = s9.pages[n2.localPageIndex];
|
|
2214
2214
|
(null == e15 ? void 0 : e15.size) && r2.push({ localPageIndex: n2.localPageIndex, width: e15.size.width * o, height: e15.size.height * o });
|
|
2215
2215
|
}
|
|
@@ -2240,38 +2240,38 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2240
2240
|
const e14 = this.virtualPageMap.totalPages;
|
|
2241
2241
|
if (0 === e14) return this.currentVisible = [], this.currentGlobalPageIndex = 0, void this.layoutChange$.emit(this.computeLayout());
|
|
2242
2242
|
const t2 = this.viewportEl.scrollTop, a3 = t2 + this.viewportEl.clientHeight, s9 = this.findFirstVisibleIndex(t2);
|
|
2243
|
-
let
|
|
2244
|
-
for (;
|
|
2245
|
-
const e15 = this.getPageSize(
|
|
2243
|
+
let i2 = s9;
|
|
2244
|
+
for (; i2 < e14; ) {
|
|
2245
|
+
const e15 = this.getPageSize(i2), t3 = this.offsets[i2];
|
|
2246
2246
|
if (e15.height, t3 >= a3) break;
|
|
2247
|
-
|
|
2247
|
+
i2++;
|
|
2248
2248
|
}
|
|
2249
2249
|
const o = [];
|
|
2250
2250
|
let r2 = s9, n2 = -1;
|
|
2251
|
-
for (let l = s9; l <
|
|
2251
|
+
for (let l = s9; l < i2; l++) {
|
|
2252
2252
|
o.push(l);
|
|
2253
|
-
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height,
|
|
2254
|
-
|
|
2253
|
+
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height, i3 = Math.max(0, Math.min(s10, a3) - Math.max(e15, t2));
|
|
2254
|
+
i3 > n2 && (n2 = i3, r2 = l);
|
|
2255
2255
|
}
|
|
2256
2256
|
this.currentVisible = o, this.currentGlobalPageIndex = r2, this.visibleChange$.emit({ visibleGlobalPageIndices: o, currentGlobalPageIndex: r2 }), this.chapterManager.provides().setVisibleGlobalPages(o), this.layoutChange$.emit(this.computeLayout());
|
|
2257
2257
|
}
|
|
2258
2258
|
findFirstVisibleIndex(e14) {
|
|
2259
2259
|
let t2 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
2260
2260
|
for (; t2 <= a3; ) {
|
|
2261
|
-
const
|
|
2262
|
-
this.offsets[
|
|
2261
|
+
const i2 = t2 + a3 >> 1;
|
|
2262
|
+
this.offsets[i2] <= e14 ? (s9 = i2, t2 = i2 + 1) : a3 = i2 - 1;
|
|
2263
2263
|
}
|
|
2264
2264
|
return s9;
|
|
2265
2265
|
}
|
|
2266
2266
|
computeLayout() {
|
|
2267
|
-
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14),
|
|
2267
|
+
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14), i2 = [];
|
|
2268
2268
|
if (this.virtualPageMap && this.offsets.length > 0) for (let o = t2; o <= s9; o++) {
|
|
2269
2269
|
const e15 = this.virtualPageMap.atIndex(o);
|
|
2270
2270
|
if (!e15) continue;
|
|
2271
2271
|
const t3 = this.getPageSize(o), a4 = this.isChapterPagePlaceholder(e15.chapterId);
|
|
2272
|
-
|
|
2272
|
+
i2.push({ globalPageIndex: o, globalPageNumber: e15.globalPageNumber, chapterId: e15.chapterId, localPageIndex: e15.localPageIndex, width: t3.width, height: t3.height, offsetTop: this.offsets[o], isPlaceholder: a4 });
|
|
2273
2273
|
}
|
|
2274
|
-
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items:
|
|
2274
|
+
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items: i2, pageGap: this.config.pageGap };
|
|
2275
2275
|
}
|
|
2276
2276
|
scrollToIndex(e14, t2) {
|
|
2277
2277
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length) return;
|
|
@@ -2281,11 +2281,11 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2281
2281
|
scrollToGlobalPdfPoint(e14, t2, a3) {
|
|
2282
2282
|
var s9;
|
|
2283
2283
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
2284
|
-
const
|
|
2284
|
+
const i2 = (null == a3 ? void 0 : a3.marginTop) ?? 80, o = this.virtualPageMap.atIndex(e14);
|
|
2285
2285
|
if (!o) return void this.scrollToIndex(e14, a3);
|
|
2286
2286
|
const r2 = this.pageSizes.get(e14), n2 = null == (s9 = this.documentManager.provides().getDocument(o.chapterId)) ? void 0 : s9.pages[o.localPageIndex];
|
|
2287
2287
|
if (!r2 || !n2) return void this.scrollToIndex(e14, a3);
|
|
2288
|
-
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l -
|
|
2288
|
+
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l - i2;
|
|
2289
2289
|
this.viewportEl.scrollTo({ top: Math.max(0, h2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
2290
2290
|
}
|
|
2291
2291
|
scrollToChapter(e14, t2) {
|
|
@@ -2299,56 +2299,56 @@ const $t$1 = class $t extends BasePlugin {
|
|
|
2299
2299
|
a3 && this.scrollToIndex(a3.globalPageIndex, t2);
|
|
2300
2300
|
}
|
|
2301
2301
|
};
|
|
2302
|
-
|
|
2303
|
-
let
|
|
2304
|
-
function
|
|
2302
|
+
Nt.id = "chapter-scroll";
|
|
2303
|
+
let At$1 = Nt;
|
|
2304
|
+
function Vt(e14) {
|
|
2305
2305
|
if (0 === e14.length) throw new Error("unionRects: empty rects");
|
|
2306
|
-
let t2 = 1 / 0, a3 = 1 / 0, s9 = -1 / 0,
|
|
2307
|
-
for (const o of e14) t2 = Math.min(t2, o.origin.x), a3 = Math.min(a3, o.origin.y), s9 = Math.max(s9, o.origin.x + o.size.width),
|
|
2308
|
-
return { origin: { x: t2, y: a3 }, size: { width: s9 - t2, height:
|
|
2306
|
+
let t2 = 1 / 0, a3 = 1 / 0, s9 = -1 / 0, i2 = -1 / 0;
|
|
2307
|
+
for (const o of e14) t2 = Math.min(t2, o.origin.x), a3 = Math.min(a3, o.origin.y), s9 = Math.max(s9, o.origin.x + o.size.width), i2 = Math.max(i2, o.origin.y + o.size.height);
|
|
2308
|
+
return { origin: { x: t2, y: a3 }, size: { width: s9 - t2, height: i2 - a3 } };
|
|
2309
2309
|
}
|
|
2310
|
-
function
|
|
2310
|
+
function _t(e14) {
|
|
2311
2311
|
const t2 = e14[e14.length - 1];
|
|
2312
2312
|
return { x: t2.origin.x + t2.size.width, y: t2.origin.y + t2.size.height };
|
|
2313
2313
|
}
|
|
2314
|
-
function
|
|
2315
|
-
const a3 = e14.origin.y, s9 = e14.origin.y + e14.size.height,
|
|
2314
|
+
function Et(e14, t2) {
|
|
2315
|
+
const a3 = e14.origin.y, s9 = e14.origin.y + e14.size.height, i2 = t2.origin.y, o = t2.origin.y + t2.size.height, r2 = Math.max(s9, o) - Math.min(a3, i2);
|
|
2316
2316
|
if (r2 <= 0) return 0;
|
|
2317
|
-
return Math.max(0, Math.min(s9, o) - Math.max(a3,
|
|
2317
|
+
return Math.max(0, Math.min(s9, o) - Math.max(a3, i2)) / r2;
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function Rt(e14, t2) {
|
|
2320
2320
|
var a3, s9;
|
|
2321
2321
|
if (e14.chapterId !== t2.chapterId || e14.localPageIndex !== t2.localPageIndex) return false;
|
|
2322
|
-
const
|
|
2322
|
+
const i2 = (null == (a3 = e14.rectsPdfCoord) ? void 0 : a3.length) ? e14.rectsPdfCoord : [e14.rectPdfCoord], o = (null == (s9 = t2.rectsPdfCoord) ? void 0 : s9.length) ? t2.rectsPdfCoord : [t2.rectPdfCoord], r2 = e14.markerAnchor ?? _t(i2), n2 = t2.markerAnchor ?? _t(o);
|
|
2323
2323
|
if (Math.hypot(r2.x - n2.x, r2.y - n2.y) <= 6) return true;
|
|
2324
|
-
for (const l of
|
|
2325
|
-
if (
|
|
2324
|
+
for (const l of i2) for (const e15 of o) {
|
|
2325
|
+
if (Et(l, e15) < 0.5) continue;
|
|
2326
2326
|
const t3 = Math.max(l.origin.x, e15.origin.x);
|
|
2327
2327
|
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;
|
|
2328
2328
|
}
|
|
2329
2329
|
return false;
|
|
2330
2330
|
}
|
|
2331
|
-
function
|
|
2332
|
-
const
|
|
2333
|
-
if (0 ===
|
|
2334
|
-
return { chapterId: e14, localPageIndex: t2, globalPageIndex: null == s9 ? void 0 : s9.globalPageIndex, globalPageNumber: null == s9 ? void 0 : s9.globalPageNumber, rectPdfCoord:
|
|
2331
|
+
function Ft(e14, t2, a3, s9) {
|
|
2332
|
+
const i2 = a3.length > 0 ? a3 : [];
|
|
2333
|
+
if (0 === i2.length) throw new Error("buildParagraphBookmarkAnchor: no rects");
|
|
2334
|
+
return { chapterId: e14, localPageIndex: t2, globalPageIndex: null == s9 ? void 0 : s9.globalPageIndex, globalPageNumber: null == s9 ? void 0 : s9.globalPageNumber, rectPdfCoord: Vt(i2), rectsPdfCoord: i2, markerAnchor: _t(i2) };
|
|
2335
2335
|
}
|
|
2336
|
-
async function
|
|
2336
|
+
async function Ut(e14, t2, a3) {
|
|
2337
2337
|
e14.scrollToGlobalPageIndex(t2), await (function(e15, t3, a4 = 2500) {
|
|
2338
2338
|
const s9 = e15.getLayout().items.find((e16) => e16.globalPageIndex === t3 && !e16.isPlaceholder);
|
|
2339
2339
|
return s9 ? Promise.resolve(s9) : new Promise((s10) => {
|
|
2340
|
-
const
|
|
2340
|
+
const i2 = setTimeout(() => {
|
|
2341
2341
|
o(), s10(null);
|
|
2342
2342
|
}, a4), o = e15.onLayoutChange((e16) => {
|
|
2343
2343
|
const a5 = e16.items.find((e17) => e17.globalPageIndex === t3 && !e17.isPlaceholder);
|
|
2344
|
-
a5 && (clearTimeout(
|
|
2344
|
+
a5 && (clearTimeout(i2), o(), s10(a5));
|
|
2345
2345
|
});
|
|
2346
2346
|
});
|
|
2347
2347
|
})(e14, t2), e14.scrollToGlobalPdfPoint(t2, a3, { marginTop: 80 });
|
|
2348
2348
|
}
|
|
2349
|
-
const
|
|
2349
|
+
const qt = class e8 extends BasePlugin {
|
|
2350
2350
|
constructor(e14, t2) {
|
|
2351
|
-
super(e14, t2), this.change$ = createBehaviorEmitter([]), this.entries = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(
|
|
2351
|
+
super(e14, t2), this.change$ = createBehaviorEmitter([]), this.entries = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(At$1.id), this.chapterManager = this.registry.getPlugin(kt$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
2352
2352
|
}
|
|
2353
2353
|
async initialize(t2) {
|
|
2354
2354
|
var a3;
|
|
@@ -2364,7 +2364,7 @@ const Vt = class e8 extends BasePlugin {
|
|
|
2364
2364
|
return { addBookmark: (e14) => this.addBookmark(e14), removeBookmark: (e14) => this.removeBookmark(e14), updateBookmark: (e14, t2) => this.updateBookmark(e14, t2), listBookmarks: () => this.list(), getBookmark: (e14) => this.entries.get(e14) ?? null, scrollToBookmark: (e14) => this.scrollToBookmark(e14), requestRemoveBookmark: (e14) => this.requestRemoveBookmark(e14), listBookmarksForChapter: (e14) => this.listBookmarksForChapter(e14), replaceBookmarksForChapter: (e14, t2) => this.replaceBookmarksForChapter(e14, t2), onBookmarksChange: this.change$.on };
|
|
2365
2365
|
}
|
|
2366
2366
|
addBookmark(e14) {
|
|
2367
|
-
for (const s9 of this.entries.values()) if (
|
|
2367
|
+
for (const s9 of this.entries.values()) if (Rt(s9.anchor, e14.anchor)) return s9;
|
|
2368
2368
|
const t2 = e14.id ?? `bm-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, a3 = { id: t2, label: e14.label, anchor: e14.anchor, metadata: e14.metadata, createdAt: Date.now() };
|
|
2369
2369
|
return this.entries.set(t2, a3), this.notifyAndPersist(), a3;
|
|
2370
2370
|
}
|
|
@@ -2374,11 +2374,11 @@ const Vt = class e8 extends BasePlugin {
|
|
|
2374
2374
|
}
|
|
2375
2375
|
async requestRemoveBookmark(t2) {
|
|
2376
2376
|
var a3, s9;
|
|
2377
|
-
const
|
|
2378
|
-
if (!
|
|
2377
|
+
const i2 = this.entries.get(t2);
|
|
2378
|
+
if (!i2) return false;
|
|
2379
2379
|
const o = null == (s9 = null == (a3 = this.config) ? void 0 : a3.callbacks) ? void 0 : s9.onRequestRemove;
|
|
2380
2380
|
if (o) try {
|
|
2381
|
-
if (!await o(
|
|
2381
|
+
if (!await o(i2)) return false;
|
|
2382
2382
|
} catch (r2) {
|
|
2383
2383
|
return this.logger.error(e8.id, "RequestRemove", "callback failed", r2), false;
|
|
2384
2384
|
}
|
|
@@ -2415,18 +2415,18 @@ const Vt = class e8 extends BasePlugin {
|
|
|
2415
2415
|
if (!e15) return;
|
|
2416
2416
|
s9 = e15.globalPageIndex;
|
|
2417
2417
|
}
|
|
2418
|
-
const
|
|
2418
|
+
const i2 = (function(e15) {
|
|
2419
2419
|
if (e15.markerAnchor) return e15.markerAnchor.y;
|
|
2420
2420
|
const t3 = e15.rectPdfCoord;
|
|
2421
2421
|
return t3.origin.y + t3.size.height;
|
|
2422
2422
|
})(t2.anchor);
|
|
2423
|
-
await
|
|
2423
|
+
await Ut(a3, s9, i2);
|
|
2424
2424
|
}
|
|
2425
2425
|
};
|
|
2426
|
-
|
|
2427
|
-
let
|
|
2428
|
-
const Et = { manifest: ft$1, create: (e14) => new _t(gt, e14), reducer: (e14) => e14, initialState: {} }, Rt = { "annotation-toolbar": { id: "annotation-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"], show: ["overflow-annotation-tools"] }, md: { minWidth: 640, hide: ["overflow-annotation-tools"], show: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"] } } }, permanent: false, categories: ["annotation"], items: [{ type: "spacer", id: "spacer-3", flex: true }, { type: "group", id: "annotation-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-highlight", commandId: "annotation:add-highlight", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-highlight"] }, { type: "command-button", id: "add-strikeout", commandId: "annotation:add-strikeout", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-strikeout"] }, { type: "command-button", id: "add-underline", commandId: "annotation:add-underline", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-underline"] }, { type: "command-button", id: "add-squiggly", commandId: "annotation:add-squiggly", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-squiggly"] }, { type: "command-button", id: "add-ink", commandId: "annotation:add-ink", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-ink-highlighter", commandId: "annotation:add-ink-highlighter", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-text", commandId: "annotation:add-text", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "add-insert-text", commandId: "annotation:add-insert-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-insert-text"] }, { type: "command-button", id: "add-replace-text", commandId: "annotation:add-replace-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-replace-text"] }, { type: "command-button", id: "add-comment", commandId: "annotation:add-comment", variant: "icon", categories: ["annotation", "annotation-comment-tool"] }, { type: "command-button", id: "add-callout", commandId: "annotation:add-callout", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "overflow-annotation-tools", commandId: "annotation:overflow-tools", variant: "icon", categories: ["annotation", "annotation-overflow"] }, { type: "divider", id: "annotation-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "annotation-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-4", flex: true }] }, "shapes-toolbar": { id: "shapes-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-polygon", "add-polyline"], show: ["overflow-shapes-tools"] }, md: { minWidth: 640, hide: ["overflow-shapes-tools"], show: ["add-polygon", "add-polyline"] } } }, permanent: false, categories: ["annotation", "annotation-shape"], items: [{ type: "spacer", id: "spacer-5", flex: true }, { type: "group", id: "shapes-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rectangle", commandId: "annotation:add-rectangle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-rectangle"] }, { type: "command-button", id: "add-circle", commandId: "annotation:add-circle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-circle"] }, { type: "command-button", id: "add-line", commandId: "annotation:add-line", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-line"] }, { type: "command-button", id: "add-arrow", commandId: "annotation:add-arrow", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-arrow"] }, { type: "command-button", id: "add-polygon", commandId: "annotation:add-polygon", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polygon"] }, { type: "command-button", id: "add-polyline", commandId: "annotation:add-polyline", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polyline"] }, { type: "command-button", id: "overflow-shapes-tools", commandId: "annotation:overflow-shapes", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-overflow"] }, { type: "divider", id: "shapes-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "shapes-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-6", flex: true }] }, "form-toolbar": { id: "form-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-form-select", "add-form-listbox"], show: ["overflow-forms-tools"] }, md: { minWidth: 640, hide: ["overflow-forms-tools"], show: ["add-form-select", "add-form-listbox"] } } }, permanent: false, categories: ["form"], items: [{ type: "spacer", id: "spacer-form-1", flex: true }, { type: "group", id: "form-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-form-textfield", commandId: "form:add-textfield", variant: "icon", categories: ["form", "form-textfield"] }, { type: "command-button", id: "add-form-checkbox", commandId: "form:add-checkbox", variant: "icon", categories: ["form", "form-checkbox"] }, { type: "command-button", id: "add-form-radio", commandId: "form:add-radio", variant: "icon", categories: ["form", "form-radio"] }, { type: "command-button", id: "add-form-select", commandId: "form:add-select", variant: "icon", categories: ["form", "form-select"] }, { type: "command-button", id: "add-form-listbox", commandId: "form:add-listbox", variant: "icon", categories: ["form", "form-listbox"] }, { type: "command-button", id: "overflow-forms-tools", commandId: "form:overflow-tools", variant: "icon", categories: ["form", "form-overflow"] }, { type: "divider", id: "form-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "command-button", id: "toggle-form-fill-mode", commandId: "form:toggle-fill-mode", variant: "icon", categories: ["form", "form-fill-mode"] }, { type: "divider", id: "form-tools-divider-2", orientation: "vertical" }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-form-2", flex: true }] }, "insert-toolbar": { id: "insert-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["insert"], items: [{ type: "spacer", id: "spacer-insert-1", flex: true }, { type: "group", id: "insert-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rubber-stamp", commandId: "insert:add-rubber-stamp", variant: "icon", categories: ["insert", "insert-rubber-stamp"] }, { type: "command-button", id: "add-signature", commandId: "insert:add-signature", variant: "icon", categories: ["insert", "insert-signature"] }, { type: "command-button", id: "add-image", commandId: "insert:add-image", variant: "icon", categories: ["insert", "insert-image"] }, { type: "divider", id: "insert-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "insert-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-insert-2", flex: true }] }, "redaction-toolbar": { id: "redaction-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["redaction"], items: [{ type: "spacer", id: "spacer-7", flex: true }, { type: "group", id: "redaction-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "redact", commandId: "redaction:redact", variant: "icon", categories: ["redaction", "redaction-combined"] }, { type: "divider", id: "redaction-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-redaction-panel", commandId: "panel:toggle-redaction", variant: "icon", categories: ["panel", "panel-redaction"] }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "redaction-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-8", flex: true }] } };
|
|
2429
|
-
class
|
|
2426
|
+
qt.id = "paragraph-bookmark";
|
|
2427
|
+
let Wt = qt;
|
|
2428
|
+
const Ht$1 = { manifest: yt$1, create: (e14) => new Wt(wt$1, e14), reducer: (e14) => e14, initialState: {} }, Bt$1 = { "annotation-toolbar": { id: "annotation-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"], show: ["overflow-annotation-tools"] }, md: { minWidth: 640, hide: ["overflow-annotation-tools"], show: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"] } } }, permanent: false, categories: ["annotation"], items: [{ type: "spacer", id: "spacer-3", flex: true }, { type: "group", id: "annotation-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-highlight", commandId: "annotation:add-highlight", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-highlight"] }, { type: "command-button", id: "add-strikeout", commandId: "annotation:add-strikeout", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-strikeout"] }, { type: "command-button", id: "add-underline", commandId: "annotation:add-underline", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-underline"] }, { type: "command-button", id: "add-squiggly", commandId: "annotation:add-squiggly", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-squiggly"] }, { type: "command-button", id: "add-ink", commandId: "annotation:add-ink", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-ink-highlighter", commandId: "annotation:add-ink-highlighter", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-text", commandId: "annotation:add-text", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "add-insert-text", commandId: "annotation:add-insert-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-insert-text"] }, { type: "command-button", id: "add-replace-text", commandId: "annotation:add-replace-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-replace-text"] }, { type: "command-button", id: "add-comment", commandId: "annotation:add-comment", variant: "icon", categories: ["annotation", "annotation-comment-tool"] }, { type: "command-button", id: "add-callout", commandId: "annotation:add-callout", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "overflow-annotation-tools", commandId: "annotation:overflow-tools", variant: "icon", categories: ["annotation", "annotation-overflow"] }, { type: "divider", id: "annotation-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "annotation-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-4", flex: true }] }, "shapes-toolbar": { id: "shapes-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-polygon", "add-polyline"], show: ["overflow-shapes-tools"] }, md: { minWidth: 640, hide: ["overflow-shapes-tools"], show: ["add-polygon", "add-polyline"] } } }, permanent: false, categories: ["annotation", "annotation-shape"], items: [{ type: "spacer", id: "spacer-5", flex: true }, { type: "group", id: "shapes-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rectangle", commandId: "annotation:add-rectangle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-rectangle"] }, { type: "command-button", id: "add-circle", commandId: "annotation:add-circle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-circle"] }, { type: "command-button", id: "add-line", commandId: "annotation:add-line", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-line"] }, { type: "command-button", id: "add-arrow", commandId: "annotation:add-arrow", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-arrow"] }, { type: "command-button", id: "add-polygon", commandId: "annotation:add-polygon", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polygon"] }, { type: "command-button", id: "add-polyline", commandId: "annotation:add-polyline", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polyline"] }, { type: "command-button", id: "overflow-shapes-tools", commandId: "annotation:overflow-shapes", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-overflow"] }, { type: "divider", id: "shapes-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "shapes-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-6", flex: true }] }, "form-toolbar": { id: "form-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-form-select", "add-form-listbox"], show: ["overflow-forms-tools"] }, md: { minWidth: 640, hide: ["overflow-forms-tools"], show: ["add-form-select", "add-form-listbox"] } } }, permanent: false, categories: ["form"], items: [{ type: "spacer", id: "spacer-form-1", flex: true }, { type: "group", id: "form-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-form-textfield", commandId: "form:add-textfield", variant: "icon", categories: ["form", "form-textfield"] }, { type: "command-button", id: "add-form-checkbox", commandId: "form:add-checkbox", variant: "icon", categories: ["form", "form-checkbox"] }, { type: "command-button", id: "add-form-radio", commandId: "form:add-radio", variant: "icon", categories: ["form", "form-radio"] }, { type: "command-button", id: "add-form-select", commandId: "form:add-select", variant: "icon", categories: ["form", "form-select"] }, { type: "command-button", id: "add-form-listbox", commandId: "form:add-listbox", variant: "icon", categories: ["form", "form-listbox"] }, { type: "command-button", id: "overflow-forms-tools", commandId: "form:overflow-tools", variant: "icon", categories: ["form", "form-overflow"] }, { type: "divider", id: "form-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "command-button", id: "toggle-form-fill-mode", commandId: "form:toggle-fill-mode", variant: "icon", categories: ["form", "form-fill-mode"] }, { type: "divider", id: "form-tools-divider-2", orientation: "vertical" }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-form-2", flex: true }] }, "insert-toolbar": { id: "insert-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["insert"], items: [{ type: "spacer", id: "spacer-insert-1", flex: true }, { type: "group", id: "insert-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rubber-stamp", commandId: "insert:add-rubber-stamp", variant: "icon", categories: ["insert", "insert-rubber-stamp"] }, { type: "command-button", id: "add-signature", commandId: "insert:add-signature", variant: "icon", categories: ["insert", "insert-signature"] }, { type: "command-button", id: "add-image", commandId: "insert:add-image", variant: "icon", categories: ["insert", "insert-image"] }, { type: "divider", id: "insert-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "insert-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-insert-2", flex: true }] }, "redaction-toolbar": { id: "redaction-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["redaction"], items: [{ type: "spacer", id: "spacer-7", flex: true }, { type: "group", id: "redaction-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "redact", commandId: "redaction:redact", variant: "icon", categories: ["redaction", "redaction-combined"] }, { type: "divider", id: "redaction-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-redaction-panel", commandId: "panel:toggle-redaction", variant: "icon", categories: ["panel", "panel-redaction"] }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "redaction-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-8", flex: true }] } };
|
|
2429
|
+
class jt {
|
|
2430
2430
|
constructor() {
|
|
2431
2431
|
this.specs = [];
|
|
2432
2432
|
}
|
|
@@ -2441,30 +2441,30 @@ class Ft {
|
|
|
2441
2441
|
return this.specs;
|
|
2442
2442
|
}
|
|
2443
2443
|
buildToolbars() {
|
|
2444
|
-
const e14 = structuredClone(
|
|
2444
|
+
const e14 = structuredClone(Bt$1);
|
|
2445
2445
|
for (const t2 of this.specs) {
|
|
2446
2446
|
const a3 = e14[t2.toolbarSlot];
|
|
2447
2447
|
if (!a3) continue;
|
|
2448
2448
|
const s9 = { type: "command-button", id: t2.id, commandId: t2.commandId, variant: "icon", ...t2.icon ? { icon: t2.icon } : {}, ...t2.i18nKey ? { labelKey: t2.i18nKey } : {}, ...t2.label ? { label: t2.label } : {}, categories: t2.categories ?? [] };
|
|
2449
|
-
a3.items =
|
|
2449
|
+
a3.items = Zt(a3.items, s9, t2.position);
|
|
2450
2450
|
}
|
|
2451
2451
|
return e14;
|
|
2452
2452
|
}
|
|
2453
2453
|
}
|
|
2454
|
-
function
|
|
2454
|
+
function Zt(e14, t2, a3) {
|
|
2455
2455
|
return (null == a3 ? void 0 : a3.after) || (null == a3 ? void 0 : a3.before) ? (function(e15, t3, a4) {
|
|
2456
2456
|
const s9 = (e16) => {
|
|
2457
|
-
const
|
|
2458
|
-
for (const o of e16) "group" !== o.type ? a4.before && o.id === a4.before ?
|
|
2459
|
-
return
|
|
2457
|
+
const i2 = [];
|
|
2458
|
+
for (const o of e16) "group" !== o.type ? a4.before && o.id === a4.before ? i2.push(t3, o) : (i2.push(o), a4.after && o.id === a4.after && i2.push(t3)) : i2.push({ ...o, items: s9(o.items) });
|
|
2459
|
+
return i2;
|
|
2460
2460
|
};
|
|
2461
2461
|
return s9(e15);
|
|
2462
2462
|
})(e14, t2, a3) : (function(e15, t3) {
|
|
2463
2463
|
return e15.map((e16) => "group" === e16.type ? { ...e16, items: [...e16.items, t3] } : e16);
|
|
2464
2464
|
})(e14, t2);
|
|
2465
2465
|
}
|
|
2466
|
-
const
|
|
2467
|
-
function
|
|
2466
|
+
const Yt = { annotate: "annotation-toolbar", shapes: "shapes-toolbar", insert: "insert-toolbar", form: "form-toolbar", redact: "redaction-toolbar" };
|
|
2467
|
+
function Kt() {
|
|
2468
2468
|
return { "mode:view": { id: "mode:view", label: "View", categories: ["mode", "mode-view"], action: ({ registry: e14, documentId: t2 }) => {
|
|
2469
2469
|
var _a2, _b, _c, _d;
|
|
2470
2470
|
const a3 = (_a2 = e14.getPlugin("ui")) == null ? void 0 : _a2.provides(), s9 = (_b = e14.getPlugin("interaction-manager")) == null ? void 0 : _b.provides();
|
|
@@ -2491,28 +2491,28 @@ function Wt() {
|
|
|
2491
2491
|
a3 && (a3.setActiveToolbar("top", "secondary", "redaction-toolbar", t2), (_b = e14.getPlugin(ANNOTATION_PLUGIN_ID)) == null ? void 0 : _b.provides().forDocument(t2).setLocked({ type: LockModeType.Include, categories: ["form"] }));
|
|
2492
2492
|
}, active: ({ state: e14, documentId: t2 }) => isToolbarOpen(e14.plugins, t2, "top", "secondary", "redaction-toolbar") } };
|
|
2493
2493
|
}
|
|
2494
|
-
function
|
|
2494
|
+
function Xt(e14) {
|
|
2495
2495
|
var _a2, _b, _c, _d, _e2, _f;
|
|
2496
|
-
const t2 = e14.toolbar ?? {}, a3 = t2.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"], s9 = a3.length > 0, { schema:
|
|
2497
|
-
var t3, a4, s10,
|
|
2498
|
-
const n3 = new Set(e15.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"]), l = new
|
|
2496
|
+
const t2 = e14.toolbar ?? {}, a3 = t2.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"], s9 = a3.length > 0, { schema: i2, operationRegistry: o } = (function(e15 = {}) {
|
|
2497
|
+
var t3, a4, s10, i3, o2, r3;
|
|
2498
|
+
const n3 = new Set(e15.enabledModes ?? ["view", "annotate", "shapes", "insert", "form", "redact"]), l = new jt();
|
|
2499
2499
|
(null == (t3 = e15.customOperations) ? void 0 : t3.length) && l.registerAll(e15.customOperations);
|
|
2500
|
-
const h2 = l.buildToolbars(),
|
|
2500
|
+
const h2 = l.buildToolbars(), d2 = {};
|
|
2501
2501
|
for (const u of n3) {
|
|
2502
2502
|
if ("view" === u) continue;
|
|
2503
|
-
const e16 =
|
|
2504
|
-
h2[e16] && (
|
|
2503
|
+
const e16 = Yt[u];
|
|
2504
|
+
h2[e16] && (d2[e16] = h2[e16]);
|
|
2505
2505
|
}
|
|
2506
2506
|
const c = (function(e16) {
|
|
2507
2507
|
if (0 === e16.size) return null;
|
|
2508
2508
|
const t4 = (e17, t5, a5) => ({ type: "command-button", id: `${e17}-mode`, commandId: a5, variant: "text", label: t5, categories: ["mode", e17] });
|
|
2509
2509
|
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 }] };
|
|
2510
2510
|
})(n3);
|
|
2511
|
-
return c && (
|
|
2512
|
-
})({ ...t2, enabledModes: a3 }), r2 = { ...s9 ?
|
|
2513
|
-
return e14.notes && n2.push(createPluginRegistration(
|
|
2511
|
+
return c && (d2["chapter-editor-main-toolbar"] = c), (null == (a4 = e15.extend) ? void 0 : a4.toolbars) && Object.assign(d2, e15.extend.toolbars), { schema: { id: "chapter-pdf-editor-ui", version: "1.0.0", toolbars: d2, menus: (null == (s10 = e15.extend) ? void 0 : s10.menus) ?? {}, sidebars: (null == (i3 = e15.extend) ? void 0 : i3.sidebars) ?? {}, modals: (null == (o2 = e15.extend) ? void 0 : o2.modals) ?? {}, selectionMenus: (null == (r3 = e15.extend) ? void 0 : r3.selectionMenus) ?? {} }, operationRegistry: l };
|
|
2512
|
+
})({ ...t2, enabledModes: a3 }), r2 = { ...s9 ? Kt() : {}, ...s9 ? Qt(o.list()) : {}, ...e14.commands ?? {} }, n2 = [createPluginRegistration(DocumentManagerPluginPackage, { initialDocuments: [] }), createPluginRegistration(Re, { manifest: e14.manifest, overlapStrategy: e14.overlapStrategy, passwordProvider: e14.passwordProvider, chapterPdfLoader: e14.chapterPdfLoader, prefetchChapters: e14.prefetchChapters, unloadTimeoutMs: e14.unloadTimeoutMs }), createPluginRegistration(Qe, { 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(r2).length > 0 ? [createPluginRegistration(CommandsPluginPackage, { commands: r2 })] : [], ...s9 ? [createPluginRegistration(I18nPluginPackage), createPluginRegistration(UIPluginPackage, { schema: i2 })] : []];
|
|
2513
|
+
return e14.notes && n2.push(createPluginRegistration(Pt$1, { callbacks: e14.notes.callbacks, ui: (_b = (_a2 = e14.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.marker })), e14.bookmarks && n2.push(createPluginRegistration(Ht$1, { 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: n2, uiSchema: i2, operationRegistry: o };
|
|
2514
2514
|
}
|
|
2515
|
-
function
|
|
2515
|
+
function Qt(e14) {
|
|
2516
2516
|
const t2 = {};
|
|
2517
2517
|
for (const a3 of e14) a3.handler && (t2[a3.commandId] = { id: a3.commandId, labelKey: a3.i18nKey, label: a3.label, icon: a3.icon, categories: a3.categories, action: ({ documentId: e15 }) => {
|
|
2518
2518
|
var _a2;
|
|
@@ -2520,55 +2520,55 @@ function Bt$1(e14) {
|
|
|
2520
2520
|
} });
|
|
2521
2521
|
return t2;
|
|
2522
2522
|
}
|
|
2523
|
-
const
|
|
2524
|
-
function
|
|
2525
|
-
return
|
|
2523
|
+
const Jt = Me(), ea = {};
|
|
2524
|
+
function ta(e14) {
|
|
2525
|
+
return Xt({ ...e14, toolbar: e14.toolbar ?? { enabledModes: [] }, features: Me(e14.features) });
|
|
2526
2526
|
}
|
|
2527
|
-
const
|
|
2528
|
-
function
|
|
2527
|
+
const aa = { overlapStrategy: { kind: "first-wins" }, passwordProvider: new xe(async () => null), prefetchChapters: 1, loadDefaultStampLibrary: false, unloadTimeoutMs: 12e4, toolbar: { enabledModes: [] } };
|
|
2528
|
+
function sa(e14) {
|
|
2529
2529
|
return (function(e15) {
|
|
2530
2530
|
return "callbacks" in e15.notes;
|
|
2531
2531
|
})(e14) ? { manifest: e14.manifest, chapterPdfLoader: e14.chapterPdfLoader, notes: e14.notes.callbacks, bookmarks: e14.bookmarks.callbacks } : e14;
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2534
|
-
return { manifest: e14.manifest, chapterPdfLoader: e14.chapterPdfLoader,
|
|
2533
|
+
function ia(e14) {
|
|
2534
|
+
return { ...aa, manifest: e14.manifest, chapterPdfLoader: e14.chapterPdfLoader, overlapStrategy: e14.overlapStrategy ?? aa.overlapStrategy, notes: { callbacks: e14.notes }, bookmarks: { callbacks: e14.bookmarks }, features: Me(e14.features) };
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2537
|
-
const t2 =
|
|
2536
|
+
function oa(e14) {
|
|
2537
|
+
const t2 = ia(sa(e14)), { plugins: a3 } = ta(t2);
|
|
2538
2538
|
return { plugins: a3, features: t2.features, editorOptions: t2 };
|
|
2539
2539
|
}
|
|
2540
|
-
function
|
|
2541
|
-
const { features: t2, ...a3 } =
|
|
2540
|
+
function ra(e14) {
|
|
2541
|
+
const { features: t2, ...a3 } = ia(sa(e14));
|
|
2542
2542
|
return a3;
|
|
2543
2543
|
}
|
|
2544
|
-
function
|
|
2544
|
+
function na(e14, t2 = 0.5, a3 = 3) {
|
|
2545
2545
|
return Math.min(a3, Math.max(t2, e14));
|
|
2546
2546
|
}
|
|
2547
|
-
function
|
|
2547
|
+
function la(i2, o) {
|
|
2548
2548
|
var _a2;
|
|
2549
|
-
const r2 = isRef(
|
|
2549
|
+
const r2 = isRef(i2) ? i2 : computed(() => i2), { registry: n2 } = useRegistry(), { provides: l } = useCapability(DocumentManagerPlugin.id), { provides: h2 } = useCapability(Ee.id), d2 = ref(((_a2 = o.value) == null ? void 0 : _a2.initial) ?? 1), c = ref(d2.value), u = () => {
|
|
2550
2550
|
var _a3;
|
|
2551
2551
|
return ((_a3 = o.value) == null ? void 0 : _a3.min) ?? 0.5;
|
|
2552
|
-
},
|
|
2552
|
+
}, p2 = () => {
|
|
2553
2553
|
var _a3;
|
|
2554
2554
|
return ((_a3 = o.value) == null ? void 0 : _a3.max) ?? 3;
|
|
2555
|
-
},
|
|
2555
|
+
}, g2 = () => {
|
|
2556
2556
|
var _a3;
|
|
2557
2557
|
return (_a3 = o.value) == null ? void 0 : _a3.pageWidth;
|
|
2558
2558
|
};
|
|
2559
2559
|
function f(e14) {
|
|
2560
|
-
const t2 =
|
|
2561
|
-
c.value = t2,
|
|
2560
|
+
const t2 = na(e14, u(), p2());
|
|
2561
|
+
c.value = t2, d2.value = t2, (function(e15, t3, a3, s9 = 0.5, i3 = 3) {
|
|
2562
2562
|
const o2 = e15 == null ? void 0 : e15.getStore();
|
|
2563
2563
|
if (!o2) return;
|
|
2564
|
-
const r3 =
|
|
2564
|
+
const r3 = na(a3, s9, i3);
|
|
2565
2565
|
o2.dispatchToCore(setDefaultScale(r3));
|
|
2566
2566
|
for (const n3 of t3.chapters) o2.getState().core.documents[n3.chapterId] && o2.dispatchToCore(setScale(r3, n3.chapterId));
|
|
2567
|
-
})(n2.value, r2.value, t2, u(),
|
|
2567
|
+
})(n2.value, r2.value, t2, u(), p2());
|
|
2568
2568
|
}
|
|
2569
2569
|
function m(e14) {
|
|
2570
|
-
|
|
2571
|
-
const t2 =
|
|
2570
|
+
g2() ? (function(e15) {
|
|
2571
|
+
const t2 = g2();
|
|
2572
2572
|
if (!t2 || !l.value) return;
|
|
2573
2573
|
const a3 = l.value.getDocument(e15);
|
|
2574
2574
|
a3 && f((function(e16, t3, a4 = 0) {
|
|
@@ -2586,7 +2586,7 @@ function aa(i, o) {
|
|
|
2586
2586
|
return (_a3 = o.value) == null ? void 0 : _a3.pageWidth;
|
|
2587
2587
|
}], () => {
|
|
2588
2588
|
var _a3;
|
|
2589
|
-
n2.value && (
|
|
2589
|
+
n2.value && (g2() || f(((_a3 = o.value) == null ? void 0 : _a3.initial) ?? 1));
|
|
2590
2590
|
}, { immediate: true }), watch([h2, r2, () => {
|
|
2591
2591
|
var _a3;
|
|
2592
2592
|
return (_a3 = o.value) == null ? void 0 : _a3.pageWidth;
|
|
@@ -2598,24 +2598,24 @@ function aa(i, o) {
|
|
|
2598
2598
|
"loaded" === e15.status && m(e15.chapterId);
|
|
2599
2599
|
});
|
|
2600
2600
|
}
|
|
2601
|
-
}, { immediate: true }), { scale:
|
|
2601
|
+
}, { immediate: true }), { scale: d2, setScale: f, zoomEnabled: () => {
|
|
2602
2602
|
var _a3;
|
|
2603
2603
|
return false !== ((_a3 = o.value) == null ? void 0 : _a3.enabled);
|
|
2604
|
-
}, minZoom: u, maxZoom:
|
|
2604
|
+
}, minZoom: u, maxZoom: p2 };
|
|
2605
2605
|
}
|
|
2606
|
-
function
|
|
2606
|
+
function ha(e14, t2, a3) {
|
|
2607
2607
|
return Math.min(a3, Math.max(t2, e14));
|
|
2608
2608
|
}
|
|
2609
|
-
function
|
|
2609
|
+
function da(e14, t2) {
|
|
2610
2610
|
if (!e14 || false === t2.enabled) return () => {
|
|
2611
2611
|
};
|
|
2612
|
-
let a3 = null, s9 = null,
|
|
2612
|
+
let a3 = null, s9 = null, i2 = 0;
|
|
2613
2613
|
const o = () => {
|
|
2614
2614
|
const s10 = e14.querySelector("[data-chapter-scroll-viewport]");
|
|
2615
|
-
return !!s10 && (a3 == null ? void 0 : a3(), a3 = (function({ container: e15, getScale: t3, setScale: a4, minZoom: s11 = 0.5, maxZoom:
|
|
2615
|
+
return !!s10 && (a3 == null ? void 0 : a3(), a3 = (function({ container: e15, getScale: t3, setScale: a4, minZoom: s11 = 0.5, maxZoom: i3 = 3 }) {
|
|
2616
2616
|
let o2 = 0, r2 = 1, n2 = null, l = 1, h2 = 1;
|
|
2617
|
-
const
|
|
2618
|
-
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === n2 ? (h2 = t3(), l = 1) : clearTimeout(n2), l *= 1 - 0.01 * e16.deltaY, l =
|
|
2617
|
+
const d2 = (e16) => {
|
|
2618
|
+
(e16.ctrlKey || e16.metaKey) && (e16.preventDefault(), null === n2 ? (h2 = t3(), l = 1) : clearTimeout(n2), l *= 1 - 0.01 * e16.deltaY, l = ha(l, 0.1, 10), a4(ha(h2 * l, s11, i3)), n2 = setTimeout(() => {
|
|
2619
2619
|
n2 = null;
|
|
2620
2620
|
}, 120));
|
|
2621
2621
|
}, c = /* @__PURE__ */ new Map(), u = (e16) => {
|
|
@@ -2623,46 +2623,46 @@ function ia(e14, t2) {
|
|
|
2623
2623
|
const [e17, a5] = [...c.values()];
|
|
2624
2624
|
o2 = Math.hypot(a5.x - e17.x, a5.y - e17.y), r2 = t3();
|
|
2625
2625
|
}
|
|
2626
|
-
},
|
|
2626
|
+
}, p2 = (e16) => {
|
|
2627
2627
|
if (c.has(e16.pointerId) && (c.set(e16.pointerId, { x: e16.clientX, y: e16.clientY }), 2 === c.size && o2 > 0)) {
|
|
2628
2628
|
e16.preventDefault();
|
|
2629
2629
|
const [t4, n3] = [...c.values()], l2 = Math.hypot(n3.x - t4.x, n3.y - t4.y);
|
|
2630
|
-
a4(
|
|
2630
|
+
a4(ha(r2 * (l2 / o2), s11, i3));
|
|
2631
2631
|
}
|
|
2632
|
-
},
|
|
2632
|
+
}, g2 = (e16) => {
|
|
2633
2633
|
c.delete(e16.pointerId), c.size < 2 && (o2 = 0);
|
|
2634
2634
|
};
|
|
2635
|
-
return e15.addEventListener("wheel",
|
|
2636
|
-
e15.removeEventListener("wheel",
|
|
2635
|
+
return e15.addEventListener("wheel", d2, { passive: false }), e15.addEventListener("pointerdown", u), e15.addEventListener("pointermove", p2, { passive: false }), e15.addEventListener("pointerup", g2), e15.addEventListener("pointercancel", g2), () => {
|
|
2636
|
+
e15.removeEventListener("wheel", d2), e15.removeEventListener("pointerdown", u), e15.removeEventListener("pointermove", p2), e15.removeEventListener("pointerup", g2), e15.removeEventListener("pointercancel", g2), n2 && clearTimeout(n2);
|
|
2637
2637
|
};
|
|
2638
2638
|
})({ container: s10, getScale: t2.getScale, setScale: t2.setScale, minZoom: t2.minZoom, maxZoom: t2.maxZoom }), true);
|
|
2639
2639
|
};
|
|
2640
2640
|
return o() || (s9 = new MutationObserver(() => {
|
|
2641
2641
|
o() && (s9 == null ? void 0 : s9.disconnect(), s9 = null);
|
|
2642
|
-
}), s9.observe(e14, { childList: true, subtree: true }),
|
|
2643
|
-
|
|
2642
|
+
}), s9.observe(e14, { childList: true, subtree: true }), i2 = requestAnimationFrame(() => o())), () => {
|
|
2643
|
+
i2 && cancelAnimationFrame(i2), s9 == null ? void 0 : s9.disconnect(), a3 == null ? void 0 : a3();
|
|
2644
2644
|
};
|
|
2645
2645
|
}
|
|
2646
|
-
const
|
|
2647
|
-
function
|
|
2648
|
-
const o = ref(null), { provides: r2 } = useCapability(
|
|
2646
|
+
const ca = { chapters: [] };
|
|
2647
|
+
function ua(e14) {
|
|
2648
|
+
const o = ref(null), { provides: r2 } = useCapability(Ee.id), n2 = computed(() => {
|
|
2649
2649
|
var _a2;
|
|
2650
|
-
return ((_a2 = r2.value) == null ? void 0 : _a2.getManifest()) ??
|
|
2650
|
+
return ((_a2 = r2.value) == null ? void 0 : _a2.getManifest()) ?? ca;
|
|
2651
2651
|
}), l = computed(() => {
|
|
2652
2652
|
var _a2;
|
|
2653
2653
|
return (_a2 = e14.value) == null ? void 0 : _a2.zoom;
|
|
2654
|
-
}), { scale: h2, setScale:
|
|
2654
|
+
}), { scale: h2, setScale: d2, zoomEnabled: c, minZoom: u, maxZoom: p2 } = la(n2, l);
|
|
2655
2655
|
return (function(e15, t2) {
|
|
2656
2656
|
let a3 = null;
|
|
2657
2657
|
watch([e15, t2], () => {
|
|
2658
2658
|
a3 == null ? void 0 : a3();
|
|
2659
2659
|
const s9 = t2.value;
|
|
2660
|
-
a3 =
|
|
2660
|
+
a3 = da(e15.value ?? null, { enabled: s9.enabled, getScale: s9.getScale, setScale: s9.setScale, minZoom: s9.minZoom, maxZoom: s9.maxZoom });
|
|
2661
2661
|
}, { deep: true, flush: "post" }), onBeforeUnmount(() => a3 == null ? void 0 : a3());
|
|
2662
|
-
})(o, computed(() => ({ enabled: c(), getScale: () => h2.value, setScale:
|
|
2662
|
+
})(o, computed(() => ({ enabled: c(), getScale: () => h2.value, setScale: d2, minZoom: u(), maxZoom: p2() }))), { hostRef: o, scale: h2, setScale: d2, zoomEnabled: c };
|
|
2663
2663
|
}
|
|
2664
|
-
const
|
|
2665
|
-
function
|
|
2664
|
+
const pa = { kind: "first-wins" };
|
|
2665
|
+
function ga(e14, t2, a3) {
|
|
2666
2666
|
if (1 === t2.length) return t2[0].chapterId;
|
|
2667
2667
|
switch (a3.kind) {
|
|
2668
2668
|
case "first-wins":
|
|
@@ -2680,7 +2680,7 @@ function la(e14, t2, a3) {
|
|
|
2680
2680
|
return a3.resolve(e14, t2);
|
|
2681
2681
|
}
|
|
2682
2682
|
}
|
|
2683
|
-
|
|
2683
|
+
class fa {
|
|
2684
2684
|
constructor(e14) {
|
|
2685
2685
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
2686
2686
|
for (const t2 of e14) {
|
|
@@ -2713,38 +2713,38 @@ let ha = class {
|
|
|
2713
2713
|
const a3 = null == (t2 = this._byChapter.get(e14)) ? void 0 : t2[0];
|
|
2714
2714
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
2715
2715
|
}
|
|
2716
|
-
}
|
|
2717
|
-
function
|
|
2718
|
-
const a3 = (function(e15, t3 =
|
|
2716
|
+
}
|
|
2717
|
+
function ma(e14, t2 = pa) {
|
|
2718
|
+
const a3 = (function(e15, t3 = pa) {
|
|
2719
2719
|
const a4 = /* @__PURE__ */ new Map();
|
|
2720
|
-
for (const
|
|
2721
|
-
const [e16, t4] =
|
|
2720
|
+
for (const i3 of e15.chapters) {
|
|
2721
|
+
const [e16, t4] = i3.globalPageRange;
|
|
2722
2722
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
2723
2723
|
const e17 = a4.get(s11);
|
|
2724
|
-
e17 ? e17.push(
|
|
2724
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
2725
2725
|
}
|
|
2726
2726
|
}
|
|
2727
2727
|
const s10 = /* @__PURE__ */ new Map();
|
|
2728
|
-
for (const [
|
|
2728
|
+
for (const [i3, o2] of a4) s10.set(i3, ga(i3, o2, t3));
|
|
2729
2729
|
return s10;
|
|
2730
2730
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
2731
2731
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
2732
|
-
const
|
|
2732
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
2733
2733
|
let r2 = 0;
|
|
2734
|
-
for (const n2 of
|
|
2734
|
+
for (const n2 of i2) {
|
|
2735
2735
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
2736
2736
|
if (!t3) continue;
|
|
2737
|
-
const [
|
|
2737
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
2738
2738
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
2739
2739
|
}
|
|
2740
|
-
return new
|
|
2740
|
+
return new fa(o);
|
|
2741
2741
|
}
|
|
2742
|
-
const
|
|
2742
|
+
const va = class e9 extends BasePlugin {
|
|
2743
2743
|
constructor(e14, t2) {
|
|
2744
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
2744
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = pa, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
2745
2745
|
}
|
|
2746
2746
|
async initialize(e14) {
|
|
2747
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
2747
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? pa, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
2748
2748
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
2749
2749
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
2750
2750
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -2770,16 +2770,16 @@ const ca = class e9 extends BasePlugin {
|
|
|
2770
2770
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
2771
2771
|
for (const s10 of e14.chapters) {
|
|
2772
2772
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
2773
|
-
const [e15,
|
|
2774
|
-
if (e15 >
|
|
2773
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
2774
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
2775
2775
|
}
|
|
2776
2776
|
return t3;
|
|
2777
2777
|
})(t2);
|
|
2778
2778
|
a3.length > 0 && this.logger.warn(e9.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
2779
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
2780
|
-
for (const e14 of s9)
|
|
2779
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
2780
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
2781
2781
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
2782
|
-
this.manifest = t2, this.virtualPageMap =
|
|
2782
|
+
this.manifest = t2, this.virtualPageMap = ma(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
2783
2783
|
}
|
|
2784
2784
|
eagerPrefetchFromManifest() {
|
|
2785
2785
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -2806,20 +2806,20 @@ const ca = class e9 extends BasePlugin {
|
|
|
2806
2806
|
e15 && s9.add(e15.chapterId);
|
|
2807
2807
|
}
|
|
2808
2808
|
if (0 === s9.size) return;
|
|
2809
|
-
const
|
|
2809
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
2810
2810
|
for (const n2 of s9) {
|
|
2811
|
-
const e15 =
|
|
2812
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
2811
|
+
const e15 = i2.indexOf(n2);
|
|
2812
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
2813
2813
|
}
|
|
2814
2814
|
const r2 = /* @__PURE__ */ new Set();
|
|
2815
|
-
for (const n2 of o) r2.add(
|
|
2815
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
2816
2816
|
for (const n2 of r2) {
|
|
2817
2817
|
this.chapterLastUsed.set(n2, t2);
|
|
2818
2818
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
2819
2819
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
2820
2820
|
}
|
|
2821
2821
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
2822
|
-
const e15 =
|
|
2822
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
2823
2823
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
2824
2824
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
2825
2825
|
}
|
|
@@ -2842,10 +2842,10 @@ const ca = class e9 extends BasePlugin {
|
|
|
2842
2842
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
2843
2843
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
2844
2844
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
2845
|
-
const
|
|
2845
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
2846
2846
|
this.pendingLoadPromises.delete(e14);
|
|
2847
2847
|
});
|
|
2848
|
-
return this.pendingLoadPromises.set(e14,
|
|
2848
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
2849
2849
|
}
|
|
2850
2850
|
async resolvePdfPayload(e14) {
|
|
2851
2851
|
const t2 = e14.source;
|
|
@@ -2863,17 +2863,17 @@ const ca = class e9 extends BasePlugin {
|
|
|
2863
2863
|
const s9 = t2.chapterId;
|
|
2864
2864
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
2865
2865
|
try {
|
|
2866
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
2866
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
2867
2867
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
2868
2868
|
});
|
|
2869
2869
|
return await new Promise((e15, t3) => {
|
|
2870
2870
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
2871
2871
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
2872
|
-
} catch (
|
|
2872
|
+
} catch (i2) {
|
|
2873
2873
|
const t3 = this.chapterStatus.get(s9);
|
|
2874
2874
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
2875
|
-
const t4 =
|
|
2876
|
-
this.logger.error(e9.id, "LoadChapter", t4,
|
|
2875
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
2876
|
+
this.logger.error(e9.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
2877
2877
|
}
|
|
2878
2878
|
return this.chapterStatus.get(s9) ?? "error";
|
|
2879
2879
|
}
|
|
@@ -2891,13 +2891,13 @@ const ca = class e9 extends BasePlugin {
|
|
|
2891
2891
|
async handleDocumentError(t2, a3, s9) {
|
|
2892
2892
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
2893
2893
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
2894
|
-
const
|
|
2895
|
-
if (!
|
|
2894
|
+
const i2 = this.findChapter(t2);
|
|
2895
|
+
if (!i2) return;
|
|
2896
2896
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
2897
2897
|
this.passwordAttempts.set(t2, o);
|
|
2898
2898
|
let r2 = null;
|
|
2899
2899
|
try {
|
|
2900
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
2900
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
2901
2901
|
} catch (n2) {
|
|
2902
2902
|
this.logger.error(e9.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
2903
2903
|
}
|
|
@@ -2917,20 +2917,20 @@ const ca = class e9 extends BasePlugin {
|
|
|
2917
2917
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
2918
2918
|
}
|
|
2919
2919
|
};
|
|
2920
|
-
|
|
2921
|
-
let
|
|
2922
|
-
function
|
|
2920
|
+
va.id = "chapter-manager";
|
|
2921
|
+
let ba = va;
|
|
2922
|
+
function Pa(e14, t2) {
|
|
2923
2923
|
if (e14 === t2) return true;
|
|
2924
2924
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
2925
2925
|
for (let a3 = 0; a3 < e14.items.length; a3++) {
|
|
2926
|
-
const s9 = e14.items[a3],
|
|
2927
|
-
if (s9.globalPageIndex !==
|
|
2926
|
+
const s9 = e14.items[a3], i2 = t2.items[a3];
|
|
2927
|
+
if (s9.globalPageIndex !== i2.globalPageIndex || s9.isPlaceholder !== i2.isPlaceholder || s9.chapterId !== i2.chapterId || s9.localPageIndex !== i2.localPageIndex || s9.offsetTop !== i2.offsetTop || s9.width !== i2.width || s9.height !== i2.height) return false;
|
|
2928
2928
|
}
|
|
2929
2929
|
return true;
|
|
2930
2930
|
}
|
|
2931
|
-
const
|
|
2931
|
+
const wa = class extends BasePlugin {
|
|
2932
2932
|
constructor(e14, t2) {
|
|
2933
|
-
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
2933
|
+
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, Pa), 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(ba.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
2934
2934
|
}
|
|
2935
2935
|
async initialize(e14) {
|
|
2936
2936
|
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 }) => {
|
|
@@ -2984,8 +2984,8 @@ const ga = class extends BasePlugin {
|
|
|
2984
2984
|
this.offsets = new Array(e14);
|
|
2985
2985
|
let t2 = 0, a3 = 0;
|
|
2986
2986
|
for (let s9 = 0; s9 < e14; s9++) {
|
|
2987
|
-
const { width: e15, height:
|
|
2988
|
-
this.offsets[s9] = t2, t2 +=
|
|
2987
|
+
const { width: e15, height: i2 } = this.getPageSize(s9);
|
|
2988
|
+
this.offsets[s9] = t2, t2 += i2 + this.config.pageGap, e15 > a3 && (a3 = e15);
|
|
2989
2989
|
}
|
|
2990
2990
|
this.totalHeight = e14 > 0 ? t2 - this.config.pageGap : 0, this.totalWidth = a3, this.layoutChange$.emit(this.computeLayout());
|
|
2991
2991
|
}
|
|
@@ -2995,8 +2995,8 @@ const ga = class extends BasePlugin {
|
|
|
2995
2995
|
for (const s9 of t2) {
|
|
2996
2996
|
const t3 = this.virtualPageMap.toGlobal(e14, s9.localPageIndex);
|
|
2997
2997
|
if (!t3) continue;
|
|
2998
|
-
const
|
|
2999
|
-
|
|
2998
|
+
const i2 = this.pageSizes.get(t3.globalPageIndex);
|
|
2999
|
+
i2 && i2.width === s9.width && i2.height === s9.height || (this.pageSizes.set(t3.globalPageIndex, { width: s9.width, height: s9.height }), a3 = true);
|
|
3000
3000
|
}
|
|
3001
3001
|
if (a3) {
|
|
3002
3002
|
const e15 = this.currentGlobalPageIndex, t3 = this.offsets[e15] ?? 0;
|
|
@@ -3014,10 +3014,10 @@ const ga = class extends BasePlugin {
|
|
|
3014
3014
|
harvestChapterSizes(e14, t2 = 0) {
|
|
3015
3015
|
var a3;
|
|
3016
3016
|
if (!this.virtualPageMap) return;
|
|
3017
|
-
const s9 = this.documentManager.provides().getDocument(e14),
|
|
3018
|
-
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 ===
|
|
3017
|
+
const s9 = this.documentManager.provides().getDocument(e14), i2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
3018
|
+
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === i2.length) return void (t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1)));
|
|
3019
3019
|
const o = this.getChapterDocumentScale(e14), r2 = [];
|
|
3020
|
-
for (const n2 of
|
|
3020
|
+
for (const n2 of i2) {
|
|
3021
3021
|
const e15 = s9.pages[n2.localPageIndex];
|
|
3022
3022
|
(null == e15 ? void 0 : e15.size) && r2.push({ localPageIndex: n2.localPageIndex, width: e15.size.width * o, height: e15.size.height * o });
|
|
3023
3023
|
}
|
|
@@ -3048,38 +3048,38 @@ const ga = class extends BasePlugin {
|
|
|
3048
3048
|
const e14 = this.virtualPageMap.totalPages;
|
|
3049
3049
|
if (0 === e14) return this.currentVisible = [], this.currentGlobalPageIndex = 0, void this.layoutChange$.emit(this.computeLayout());
|
|
3050
3050
|
const t2 = this.viewportEl.scrollTop, a3 = t2 + this.viewportEl.clientHeight, s9 = this.findFirstVisibleIndex(t2);
|
|
3051
|
-
let
|
|
3052
|
-
for (;
|
|
3053
|
-
const e15 = this.getPageSize(
|
|
3051
|
+
let i2 = s9;
|
|
3052
|
+
for (; i2 < e14; ) {
|
|
3053
|
+
const e15 = this.getPageSize(i2), t3 = this.offsets[i2];
|
|
3054
3054
|
if (e15.height, t3 >= a3) break;
|
|
3055
|
-
|
|
3055
|
+
i2++;
|
|
3056
3056
|
}
|
|
3057
3057
|
const o = [];
|
|
3058
3058
|
let r2 = s9, n2 = -1;
|
|
3059
|
-
for (let l = s9; l <
|
|
3059
|
+
for (let l = s9; l < i2; l++) {
|
|
3060
3060
|
o.push(l);
|
|
3061
|
-
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height,
|
|
3062
|
-
|
|
3061
|
+
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height, i3 = Math.max(0, Math.min(s10, a3) - Math.max(e15, t2));
|
|
3062
|
+
i3 > n2 && (n2 = i3, r2 = l);
|
|
3063
3063
|
}
|
|
3064
3064
|
this.currentVisible = o, this.currentGlobalPageIndex = r2, this.visibleChange$.emit({ visibleGlobalPageIndices: o, currentGlobalPageIndex: r2 }), this.chapterManager.provides().setVisibleGlobalPages(o), this.layoutChange$.emit(this.computeLayout());
|
|
3065
3065
|
}
|
|
3066
3066
|
findFirstVisibleIndex(e14) {
|
|
3067
3067
|
let t2 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
3068
3068
|
for (; t2 <= a3; ) {
|
|
3069
|
-
const
|
|
3070
|
-
this.offsets[
|
|
3069
|
+
const i2 = t2 + a3 >> 1;
|
|
3070
|
+
this.offsets[i2] <= e14 ? (s9 = i2, t2 = i2 + 1) : a3 = i2 - 1;
|
|
3071
3071
|
}
|
|
3072
3072
|
return s9;
|
|
3073
3073
|
}
|
|
3074
3074
|
computeLayout() {
|
|
3075
|
-
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14),
|
|
3075
|
+
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14), i2 = [];
|
|
3076
3076
|
if (this.virtualPageMap && this.offsets.length > 0) for (let o = t2; o <= s9; o++) {
|
|
3077
3077
|
const e15 = this.virtualPageMap.atIndex(o);
|
|
3078
3078
|
if (!e15) continue;
|
|
3079
3079
|
const t3 = this.getPageSize(o), a4 = this.isChapterPagePlaceholder(e15.chapterId);
|
|
3080
|
-
|
|
3080
|
+
i2.push({ globalPageIndex: o, globalPageNumber: e15.globalPageNumber, chapterId: e15.chapterId, localPageIndex: e15.localPageIndex, width: t3.width, height: t3.height, offsetTop: this.offsets[o], isPlaceholder: a4 });
|
|
3081
3081
|
}
|
|
3082
|
-
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items:
|
|
3082
|
+
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items: i2, pageGap: this.config.pageGap };
|
|
3083
3083
|
}
|
|
3084
3084
|
scrollToIndex(e14, t2) {
|
|
3085
3085
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length) return;
|
|
@@ -3089,11 +3089,11 @@ const ga = class extends BasePlugin {
|
|
|
3089
3089
|
scrollToGlobalPdfPoint(e14, t2, a3) {
|
|
3090
3090
|
var s9;
|
|
3091
3091
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
3092
|
-
const
|
|
3092
|
+
const i2 = (null == a3 ? void 0 : a3.marginTop) ?? 80, o = this.virtualPageMap.atIndex(e14);
|
|
3093
3093
|
if (!o) return void this.scrollToIndex(e14, a3);
|
|
3094
3094
|
const r2 = this.pageSizes.get(e14), n2 = null == (s9 = this.documentManager.provides().getDocument(o.chapterId)) ? void 0 : s9.pages[o.localPageIndex];
|
|
3095
3095
|
if (!r2 || !n2) return void this.scrollToIndex(e14, a3);
|
|
3096
|
-
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l -
|
|
3096
|
+
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l - i2;
|
|
3097
3097
|
this.viewportEl.scrollTo({ top: Math.max(0, h2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
3098
3098
|
}
|
|
3099
3099
|
scrollToChapter(e14, t2) {
|
|
@@ -3107,14 +3107,14 @@ const ga = class extends BasePlugin {
|
|
|
3107
3107
|
a3 && this.scrollToIndex(a3.globalPageIndex, t2);
|
|
3108
3108
|
}
|
|
3109
3109
|
};
|
|
3110
|
-
|
|
3111
|
-
let
|
|
3112
|
-
const
|
|
3110
|
+
wa.id = "chapter-scroll";
|
|
3111
|
+
let ya = wa;
|
|
3112
|
+
const Ca = ["data-global-page-index", "data-chapter-id", "data-local-page-index"], Ia = /* @__PURE__ */ ((e14, t2) => {
|
|
3113
3113
|
const a3 = e14.__vccOpts || e14;
|
|
3114
|
-
for (const [s9,
|
|
3114
|
+
for (const [s9, i2] of t2) a3[s9] = i2;
|
|
3115
3115
|
return a3;
|
|
3116
3116
|
})(/* @__PURE__ */ defineComponent({ __name: "ChapterScroller", props: { class: {}, style: {} }, setup(e14) {
|
|
3117
|
-
const { provides: t2 } = useCapability(
|
|
3117
|
+
const { provides: t2 } = useCapability(ya.id), o = ref(null), f = ref(null);
|
|
3118
3118
|
let m = null;
|
|
3119
3119
|
const v = () => {
|
|
3120
3120
|
null == m || m(), m = null, t2.value && (t2.value.registerViewport(o.value), m = t2.value.onLayoutChange((e15) => {
|
|
@@ -3125,12 +3125,12 @@ const ma = ["data-global-page-index", "data-chapter-id", "data-local-page-index"
|
|
|
3125
3125
|
var e15;
|
|
3126
3126
|
null == m || m(), null == (e15 = t2.value) || e15.registerViewport(null);
|
|
3127
3127
|
}), watch(t2, v), (e15, t3) => {
|
|
3128
|
-
var a3, s9,
|
|
3129
|
-
return openBlock(), createElementBlock("div", { ref_key: "containerRef", ref: o, "data-chapter-scroll-viewport": "", class: normalizeClass(e15.$props.class), style: normalizeStyle({ overflow: "auto", position: "relative", width: "100%", height: "100%", ...e15.$props.style }) }, [createElementVNode("div", { style: normalizeStyle({ position: "relative", width: `${(null == (a3 = f.value) ? void 0 : a3.totalWidth) ?? 0}px`, height: `${(null == (s9 = f.value) ? void 0 : s9.totalHeight) ?? 0}px`, margin: "0 auto" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList((null == (
|
|
3128
|
+
var a3, s9, i2;
|
|
3129
|
+
return openBlock(), createElementBlock("div", { ref_key: "containerRef", ref: o, "data-chapter-scroll-viewport": "", class: normalizeClass(e15.$props.class), style: normalizeStyle({ overflow: "auto", position: "relative", width: "100%", height: "100%", ...e15.$props.style }) }, [createElementVNode("div", { style: normalizeStyle({ position: "relative", width: `${(null == (a3 = f.value) ? void 0 : a3.totalWidth) ?? 0}px`, height: `${(null == (s9 = f.value) ? void 0 : s9.totalHeight) ?? 0}px`, margin: "0 auto" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList((null == (i2 = f.value) ? void 0 : i2.items) ?? [], (a4) => (openBlock(), createElementBlock("div", { key: a4.globalPageIndex, "data-global-page-index": a4.globalPageIndex, "data-chapter-id": a4.chapterId, "data-local-page-index": a4.localPageIndex, style: normalizeStyle({ position: "absolute", top: `${a4.offsetTop}px`, left: "50%", transform: "translateX(-50%)", width: `${a4.width}px`, height: `${a4.height}px`, backgroundColor: a4.isPlaceholder ? "#f3f4f6" : "#fff", boxShadow: "0 1px 4px rgba(0,0,0,0.08)" }) }, [a4.isPlaceholder ? renderSlot(e15.$slots, "placeholder", { key: 0, item: a4 }, () => [t3[0] || (t3[0] = createElementVNode("div", { class: "chapter-scroll-placeholder" }, "Loading chapter…", -1))], true) : renderSlot(e15.$slots, "page", { key: 1, item: a4 }, void 0, true)], 12, Ca))), 128))], 4)], 6);
|
|
3130
3130
|
};
|
|
3131
|
-
} }), [["__scopeId", "data-v-8a737137"]]),
|
|
3132
|
-
const
|
|
3133
|
-
function
|
|
3131
|
+
} }), [["__scopeId", "data-v-8a737137"]]), Ma = /* @__PURE__ */ defineComponent({ __name: "ChapterRenderLayer", props: { chapterId: {}, localPageIndex: {}, scale: {}, dpr: {}, class: {} }, setup: (e14) => (t2, a3) => (openBlock(), createBlock(unref(RenderLayer), { "document-id": e14.chapterId, "page-index": e14.localPageIndex, scale: e14.scale, dpr: e14.dpr, class: normalizeClass(e14.class), style: { pointerEvents: "none" } }, null, 8, ["document-id", "page-index", "scale", "dpr", "class"])) });
|
|
3132
|
+
const Sa = { kind: "first-wins" };
|
|
3133
|
+
function xa(e14, t2, a3) {
|
|
3134
3134
|
if (1 === t2.length) return t2[0].chapterId;
|
|
3135
3135
|
switch (a3.kind) {
|
|
3136
3136
|
case "first-wins":
|
|
@@ -3148,7 +3148,7 @@ function wa(e14, t2, a3) {
|
|
|
3148
3148
|
return a3.resolve(e14, t2);
|
|
3149
3149
|
}
|
|
3150
3150
|
}
|
|
3151
|
-
let
|
|
3151
|
+
let ka = class {
|
|
3152
3152
|
constructor(e14) {
|
|
3153
3153
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
3154
3154
|
for (const t2 of e14) {
|
|
@@ -3182,37 +3182,37 @@ let ya = class {
|
|
|
3182
3182
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
3183
3183
|
}
|
|
3184
3184
|
};
|
|
3185
|
-
function
|
|
3186
|
-
const a3 = (function(e15, t3 =
|
|
3185
|
+
function La(e14, t2 = Sa) {
|
|
3186
|
+
const a3 = (function(e15, t3 = Sa) {
|
|
3187
3187
|
const a4 = /* @__PURE__ */ new Map();
|
|
3188
|
-
for (const
|
|
3189
|
-
const [e16, t4] =
|
|
3188
|
+
for (const i3 of e15.chapters) {
|
|
3189
|
+
const [e16, t4] = i3.globalPageRange;
|
|
3190
3190
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
3191
3191
|
const e17 = a4.get(s11);
|
|
3192
|
-
e17 ? e17.push(
|
|
3192
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
3193
3193
|
}
|
|
3194
3194
|
}
|
|
3195
3195
|
const s10 = /* @__PURE__ */ new Map();
|
|
3196
|
-
for (const [
|
|
3196
|
+
for (const [i3, o2] of a4) s10.set(i3, xa(i3, o2, t3));
|
|
3197
3197
|
return s10;
|
|
3198
3198
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
3199
3199
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
3200
|
-
const
|
|
3200
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
3201
3201
|
let r2 = 0;
|
|
3202
|
-
for (const n2 of
|
|
3202
|
+
for (const n2 of i2) {
|
|
3203
3203
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
3204
3204
|
if (!t3) continue;
|
|
3205
|
-
const [
|
|
3205
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
3206
3206
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
3207
3207
|
}
|
|
3208
|
-
return new
|
|
3208
|
+
return new ka(o);
|
|
3209
3209
|
}
|
|
3210
|
-
const
|
|
3210
|
+
const $a = class e10 extends BasePlugin {
|
|
3211
3211
|
constructor(e14, t2) {
|
|
3212
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
3212
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Sa, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
3213
3213
|
}
|
|
3214
3214
|
async initialize(e14) {
|
|
3215
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
3215
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Sa, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
3216
3216
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
3217
3217
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
3218
3218
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -3238,16 +3238,16 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3238
3238
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
3239
3239
|
for (const s10 of e14.chapters) {
|
|
3240
3240
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
3241
|
-
const [e15,
|
|
3242
|
-
if (e15 >
|
|
3241
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
3242
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
3243
3243
|
}
|
|
3244
3244
|
return t3;
|
|
3245
3245
|
})(t2);
|
|
3246
3246
|
a3.length > 0 && this.logger.warn(e10.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
3247
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
3248
|
-
for (const e14 of s9)
|
|
3247
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
3248
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
3249
3249
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
3250
|
-
this.manifest = t2, this.virtualPageMap =
|
|
3250
|
+
this.manifest = t2, this.virtualPageMap = La(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
3251
3251
|
}
|
|
3252
3252
|
eagerPrefetchFromManifest() {
|
|
3253
3253
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -3274,20 +3274,20 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3274
3274
|
e15 && s9.add(e15.chapterId);
|
|
3275
3275
|
}
|
|
3276
3276
|
if (0 === s9.size) return;
|
|
3277
|
-
const
|
|
3277
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
3278
3278
|
for (const n2 of s9) {
|
|
3279
|
-
const e15 =
|
|
3280
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
3279
|
+
const e15 = i2.indexOf(n2);
|
|
3280
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
3281
3281
|
}
|
|
3282
3282
|
const r2 = /* @__PURE__ */ new Set();
|
|
3283
|
-
for (const n2 of o) r2.add(
|
|
3283
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
3284
3284
|
for (const n2 of r2) {
|
|
3285
3285
|
this.chapterLastUsed.set(n2, t2);
|
|
3286
3286
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
3287
3287
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
3288
3288
|
}
|
|
3289
3289
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
3290
|
-
const e15 =
|
|
3290
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
3291
3291
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
3292
3292
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
3293
3293
|
}
|
|
@@ -3310,10 +3310,10 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3310
3310
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
3311
3311
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
3312
3312
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
3313
|
-
const
|
|
3313
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
3314
3314
|
this.pendingLoadPromises.delete(e14);
|
|
3315
3315
|
});
|
|
3316
|
-
return this.pendingLoadPromises.set(e14,
|
|
3316
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
3317
3317
|
}
|
|
3318
3318
|
async resolvePdfPayload(e14) {
|
|
3319
3319
|
const t2 = e14.source;
|
|
@@ -3331,17 +3331,17 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3331
3331
|
const s9 = t2.chapterId;
|
|
3332
3332
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
3333
3333
|
try {
|
|
3334
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
3334
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
3335
3335
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
3336
3336
|
});
|
|
3337
3337
|
return await new Promise((e15, t3) => {
|
|
3338
3338
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
3339
3339
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
3340
|
-
} catch (
|
|
3340
|
+
} catch (i2) {
|
|
3341
3341
|
const t3 = this.chapterStatus.get(s9);
|
|
3342
3342
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
3343
|
-
const t4 =
|
|
3344
|
-
this.logger.error(e10.id, "LoadChapter", t4,
|
|
3343
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
3344
|
+
this.logger.error(e10.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
3345
3345
|
}
|
|
3346
3346
|
return this.chapterStatus.get(s9) ?? "error";
|
|
3347
3347
|
}
|
|
@@ -3359,13 +3359,13 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3359
3359
|
async handleDocumentError(t2, a3, s9) {
|
|
3360
3360
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
3361
3361
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
3362
|
-
const
|
|
3363
|
-
if (!
|
|
3362
|
+
const i2 = this.findChapter(t2);
|
|
3363
|
+
if (!i2) return;
|
|
3364
3364
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
3365
3365
|
this.passwordAttempts.set(t2, o);
|
|
3366
3366
|
let r2 = null;
|
|
3367
3367
|
try {
|
|
3368
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
3368
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
3369
3369
|
} catch (n2) {
|
|
3370
3370
|
this.logger.error(e10.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
3371
3371
|
}
|
|
@@ -3385,10 +3385,10 @@ const Ia = class e10 extends BasePlugin {
|
|
|
3385
3385
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
3386
3386
|
}
|
|
3387
3387
|
};
|
|
3388
|
-
|
|
3389
|
-
let
|
|
3390
|
-
const
|
|
3391
|
-
function
|
|
3388
|
+
$a.id = "chapter-manager";
|
|
3389
|
+
let za = $a;
|
|
3390
|
+
const Ta = { kind: "first-wins" };
|
|
3391
|
+
function Da(e14, t2, a3) {
|
|
3392
3392
|
if (1 === t2.length) return t2[0].chapterId;
|
|
3393
3393
|
switch (a3.kind) {
|
|
3394
3394
|
case "first-wins":
|
|
@@ -3406,7 +3406,7 @@ function xa(e14, t2, a3) {
|
|
|
3406
3406
|
return a3.resolve(e14, t2);
|
|
3407
3407
|
}
|
|
3408
3408
|
}
|
|
3409
|
-
class
|
|
3409
|
+
class Oa {
|
|
3410
3410
|
constructor(e14) {
|
|
3411
3411
|
this._pages = e14, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
3412
3412
|
for (const t2 of e14) {
|
|
@@ -3440,37 +3440,37 @@ class ka {
|
|
|
3440
3440
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
3441
3441
|
}
|
|
3442
3442
|
}
|
|
3443
|
-
function
|
|
3444
|
-
const a3 = (function(e15, t3 =
|
|
3443
|
+
function Ga(e14, t2 = Ta) {
|
|
3444
|
+
const a3 = (function(e15, t3 = Ta) {
|
|
3445
3445
|
const a4 = /* @__PURE__ */ new Map();
|
|
3446
|
-
for (const
|
|
3447
|
-
const [e16, t4] =
|
|
3446
|
+
for (const i3 of e15.chapters) {
|
|
3447
|
+
const [e16, t4] = i3.globalPageRange;
|
|
3448
3448
|
for (let s11 = e16; s11 <= t4; s11++) {
|
|
3449
3449
|
const e17 = a4.get(s11);
|
|
3450
|
-
e17 ? e17.push(
|
|
3450
|
+
e17 ? e17.push(i3) : a4.set(s11, [i3]);
|
|
3451
3451
|
}
|
|
3452
3452
|
}
|
|
3453
3453
|
const s10 = /* @__PURE__ */ new Map();
|
|
3454
|
-
for (const [
|
|
3454
|
+
for (const [i3, o2] of a4) s10.set(i3, Da(i3, o2, t3));
|
|
3455
3455
|
return s10;
|
|
3456
3456
|
})(e14, t2), s9 = /* @__PURE__ */ new Map();
|
|
3457
3457
|
for (const n2 of e14.chapters) s9.set(n2.chapterId, n2);
|
|
3458
|
-
const
|
|
3458
|
+
const i2 = Array.from(a3.keys()).sort((e15, t3) => e15 - t3), o = [];
|
|
3459
3459
|
let r2 = 0;
|
|
3460
|
-
for (const n2 of
|
|
3460
|
+
for (const n2 of i2) {
|
|
3461
3461
|
const e15 = a3.get(n2), t3 = s9.get(e15);
|
|
3462
3462
|
if (!t3) continue;
|
|
3463
|
-
const [
|
|
3463
|
+
const [i3] = t3.globalPageRange, [l] = t3.localPageRange, h2 = l + (n2 - i3);
|
|
3464
3464
|
o.push({ globalPageIndex: r2++, globalPageNumber: n2, chapterId: e15, localPageIndex: h2 });
|
|
3465
3465
|
}
|
|
3466
|
-
return new
|
|
3466
|
+
return new Oa(o);
|
|
3467
3467
|
}
|
|
3468
|
-
const
|
|
3468
|
+
const Na = class e11 extends BasePlugin {
|
|
3469
3469
|
constructor(e14, t2) {
|
|
3470
|
-
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy =
|
|
3470
|
+
super(e14, t2), this.statusChange$ = createBehaviorEmitter(), this.manifestChange$ = createEmitter(), this.overlapStrategy = Ta, this.chapterStatus = /* @__PURE__ */ new Map(), this.chapterLastUsed = /* @__PURE__ */ new Map(), this.passwordAttempts = /* @__PURE__ */ new Map(), this.pendingLoadPromises = /* @__PURE__ */ new Map(), this.unloadTimer = null, this.documentManagerUnsubs = [], this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
3471
3471
|
}
|
|
3472
3472
|
async initialize(e14) {
|
|
3473
|
-
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ??
|
|
3473
|
+
if (this.config = e14, this.passwordProvider = e14.passwordProvider, this.overlapStrategy = e14.overlapStrategy ?? Ta, this.documentManagerUnsubs.push(this.documentManager.provides().onDocumentOpened((e15) => {
|
|
3474
3474
|
this.isOwnedChapter(e15.id) && (this.passwordAttempts.delete(e15.id), this.updateStatus(e15.id, "loaded"));
|
|
3475
3475
|
}), this.documentManager.provides().onDocumentClosed((e15) => {
|
|
3476
3476
|
this.isOwnedChapter(e15) && this.updateStatus(e15, "closed");
|
|
@@ -3496,16 +3496,16 @@ const $a = class e11 extends BasePlugin {
|
|
|
3496
3496
|
const t3 = [], a4 = /* @__PURE__ */ new Set();
|
|
3497
3497
|
for (const s10 of e14.chapters) {
|
|
3498
3498
|
a4.has(s10.chapterId) && t3.push(`Duplicate chapterId: ${s10.chapterId}`), a4.add(s10.chapterId);
|
|
3499
|
-
const [e15,
|
|
3500
|
-
if (e15 >
|
|
3499
|
+
const [e15, i3] = s10.globalPageRange, [o, r2] = s10.localPageRange;
|
|
3500
|
+
if (e15 > i3 && t3.push(`${s10.chapterId}: invalid globalPageRange [${e15},${i3}]`), o > r2 && t3.push(`${s10.chapterId}: invalid localPageRange [${o},${r2}]`), i3 - e15 !== r2 - o && t3.push(`${s10.chapterId}: page-count mismatch (global ${i3 - e15 + 1} vs local ${r2 - o + 1})`), s10.ownedGlobalPages) for (const a5 of s10.ownedGlobalPages) (a5 < e15 || a5 > i3) && t3.push(`${s10.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
3501
3501
|
}
|
|
3502
3502
|
return t3;
|
|
3503
3503
|
})(t2);
|
|
3504
3504
|
a3.length > 0 && this.logger.warn(e11.id, "ManifestValidation", `Chapter manifest has issues: ${a3.join("; ")}`);
|
|
3505
|
-
const s9 = new Set(this.chapterStatus.keys()),
|
|
3506
|
-
for (const e14 of s9)
|
|
3505
|
+
const s9 = new Set(this.chapterStatus.keys()), i2 = new Set(t2.chapters.map((e14) => e14.chapterId));
|
|
3506
|
+
for (const e14 of s9) i2.has(e14) || (this.closeChapter(e14), this.chapterStatus.delete(e14));
|
|
3507
3507
|
for (const e14 of t2.chapters) this.chapterStatus.has(e14.chapterId) || this.chapterStatus.set(e14.chapterId, "idle");
|
|
3508
|
-
this.manifest = t2, this.virtualPageMap =
|
|
3508
|
+
this.manifest = t2, this.virtualPageMap = Ga(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
3509
3509
|
}
|
|
3510
3510
|
eagerPrefetchFromManifest() {
|
|
3511
3511
|
const e14 = this.config.prefetchChapters ?? 0;
|
|
@@ -3532,20 +3532,20 @@ const $a = class e11 extends BasePlugin {
|
|
|
3532
3532
|
e15 && s9.add(e15.chapterId);
|
|
3533
3533
|
}
|
|
3534
3534
|
if (0 === s9.size) return;
|
|
3535
|
-
const
|
|
3535
|
+
const i2 = this.manifest.chapters.map((e15) => e15.chapterId), o = /* @__PURE__ */ new Set();
|
|
3536
3536
|
for (const n2 of s9) {
|
|
3537
|
-
const e15 =
|
|
3538
|
-
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 <
|
|
3537
|
+
const e15 = i2.indexOf(n2);
|
|
3538
|
+
if (-1 !== e15) for (let t3 = e15 - a3; t3 <= e15 + a3; t3++) t3 >= 0 && t3 < i2.length && o.add(t3);
|
|
3539
3539
|
}
|
|
3540
3540
|
const r2 = /* @__PURE__ */ new Set();
|
|
3541
|
-
for (const n2 of o) r2.add(
|
|
3541
|
+
for (const n2 of o) r2.add(i2[n2]);
|
|
3542
3542
|
for (const n2 of r2) {
|
|
3543
3543
|
this.chapterLastUsed.set(n2, t2);
|
|
3544
3544
|
const e15 = this.chapterStatus.get(n2) ?? "idle";
|
|
3545
3545
|
"idle" !== e15 && "closed" !== e15 && "error" !== e15 || this.ensureChapterLoaded(n2);
|
|
3546
3546
|
}
|
|
3547
3547
|
if (this.config.autoActivateOnLoad ?? 1) {
|
|
3548
|
-
const e15 =
|
|
3548
|
+
const e15 = i2.find((e16) => s9.has(e16));
|
|
3549
3549
|
if (e15 && this.documentManager.provides().isDocumentOpen(e15)) {
|
|
3550
3550
|
this.documentManager.provides().getActiveDocumentId() !== e15 && this.documentManager.provides().setActiveDocument(e15);
|
|
3551
3551
|
}
|
|
@@ -3568,10 +3568,10 @@ const $a = class e11 extends BasePlugin {
|
|
|
3568
3568
|
const s9 = this.chapterStatus.get(e14) ?? "idle";
|
|
3569
3569
|
if ("loaded" === s9) return this.chapterLastUsed.set(e14, Date.now()), Promise.resolve("loaded");
|
|
3570
3570
|
if ("loading" === s9) return this.waitForTerminalStatus(e14);
|
|
3571
|
-
const
|
|
3571
|
+
const i2 = this.startLoad(a3).finally(() => {
|
|
3572
3572
|
this.pendingLoadPromises.delete(e14);
|
|
3573
3573
|
});
|
|
3574
|
-
return this.pendingLoadPromises.set(e14,
|
|
3574
|
+
return this.pendingLoadPromises.set(e14, i2), i2;
|
|
3575
3575
|
}
|
|
3576
3576
|
async resolvePdfPayload(e14) {
|
|
3577
3577
|
const t2 = e14.source;
|
|
@@ -3589,17 +3589,17 @@ const $a = class e11 extends BasePlugin {
|
|
|
3589
3589
|
const s9 = t2.chapterId;
|
|
3590
3590
|
this.updateStatus(s9, "loading"), this.chapterLastUsed.set(s9, Date.now());
|
|
3591
3591
|
try {
|
|
3592
|
-
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null,
|
|
3592
|
+
const e14 = t2.encrypted && (null == (a3 = this.passwordProvider) ? void 0 : a3.getCachedPassword) ? this.passwordProvider.getCachedPassword(s9) : null, i2 = await this.resolvePdfPayload(t2), o = this.documentManager.provides(), r2 = "url" in i2 ? o.openDocumentUrl({ documentId: s9, url: i2.url, name: t2.title, password: e14 ?? void 0, autoActivate: false }) : o.openDocumentBuffer({ documentId: s9, buffer: i2.buffer, name: t2.title, password: e14 ?? void 0, autoActivate: false }), n2 = await new Promise((e15, t3) => {
|
|
3593
3593
|
r2.wait((t4) => e15(t4), (e16) => t3(e16));
|
|
3594
3594
|
});
|
|
3595
3595
|
return await new Promise((e15, t3) => {
|
|
3596
3596
|
n2.task.wait(() => e15(), (e16) => t3(e16));
|
|
3597
3597
|
}), o.isDocumentOpen(s9) && this.updateStatus(s9, "loaded"), this.waitForTerminalStatus(s9);
|
|
3598
|
-
} catch (
|
|
3598
|
+
} catch (i2) {
|
|
3599
3599
|
const t3 = this.chapterStatus.get(s9);
|
|
3600
3600
|
if ("loaded" !== t3 && "password-required" !== t3) {
|
|
3601
|
-
const t4 =
|
|
3602
|
-
this.logger.error(e11.id, "LoadChapter", t4,
|
|
3601
|
+
const t4 = i2 instanceof Error ? i2.message : `Failed to load chapter "${s9}"`;
|
|
3602
|
+
this.logger.error(e11.id, "LoadChapter", t4, i2), this.updateStatus(s9, "error", t4);
|
|
3603
3603
|
}
|
|
3604
3604
|
return this.chapterStatus.get(s9) ?? "error";
|
|
3605
3605
|
}
|
|
@@ -3617,13 +3617,13 @@ const $a = class e11 extends BasePlugin {
|
|
|
3617
3617
|
async handleDocumentError(t2, a3, s9) {
|
|
3618
3618
|
if (a3 !== PdfErrorCode.Password) return void this.updateStatus(t2, "error");
|
|
3619
3619
|
if (!this.passwordProvider) return void this.updateStatus(t2, "password-required");
|
|
3620
|
-
const
|
|
3621
|
-
if (!
|
|
3620
|
+
const i2 = this.findChapter(t2);
|
|
3621
|
+
if (!i2) return;
|
|
3622
3622
|
const o = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
3623
3623
|
this.passwordAttempts.set(t2, o);
|
|
3624
3624
|
let r2 = null;
|
|
3625
3625
|
try {
|
|
3626
|
-
r2 = await this.passwordProvider.resolvePassword(
|
|
3626
|
+
r2 = await this.passwordProvider.resolvePassword(i2, o - 1);
|
|
3627
3627
|
} catch (n2) {
|
|
3628
3628
|
this.logger.error(e11.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
3629
3629
|
}
|
|
@@ -3643,20 +3643,20 @@ const $a = class e11 extends BasePlugin {
|
|
|
3643
3643
|
this.chapterStatus.get(e14) !== t2 && (this.chapterStatus.set(e14, t2), this.statusChange$.emit({ chapterId: e14, status: t2, ..."error" === t2 && a3 ? { error: { message: a3 } } : {} }));
|
|
3644
3644
|
}
|
|
3645
3645
|
};
|
|
3646
|
-
|
|
3647
|
-
let
|
|
3648
|
-
function
|
|
3646
|
+
Na.id = "chapter-manager";
|
|
3647
|
+
let Aa = Na;
|
|
3648
|
+
function Va(e14, t2) {
|
|
3649
3649
|
if (e14 === t2) return true;
|
|
3650
3650
|
if (e14.totalHeight !== t2.totalHeight || e14.totalWidth !== t2.totalWidth || e14.pageGap !== t2.pageGap || e14.items.length !== t2.items.length) return false;
|
|
3651
3651
|
for (let a3 = 0; a3 < e14.items.length; a3++) {
|
|
3652
|
-
const s9 = e14.items[a3],
|
|
3653
|
-
if (s9.globalPageIndex !==
|
|
3652
|
+
const s9 = e14.items[a3], i2 = t2.items[a3];
|
|
3653
|
+
if (s9.globalPageIndex !== i2.globalPageIndex || s9.isPlaceholder !== i2.isPlaceholder || s9.chapterId !== i2.chapterId || s9.localPageIndex !== i2.localPageIndex || s9.offsetTop !== i2.offsetTop || s9.width !== i2.width || s9.height !== i2.height) return false;
|
|
3654
3654
|
}
|
|
3655
3655
|
return true;
|
|
3656
3656
|
}
|
|
3657
|
-
const
|
|
3657
|
+
const _a = class extends BasePlugin {
|
|
3658
3658
|
constructor(e14, t2) {
|
|
3659
|
-
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0,
|
|
3659
|
+
super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, Va), 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(Aa.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
3660
3660
|
}
|
|
3661
3661
|
async initialize(e14) {
|
|
3662
3662
|
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 }) => {
|
|
@@ -3710,8 +3710,8 @@ const Da = class extends BasePlugin {
|
|
|
3710
3710
|
this.offsets = new Array(e14);
|
|
3711
3711
|
let t2 = 0, a3 = 0;
|
|
3712
3712
|
for (let s9 = 0; s9 < e14; s9++) {
|
|
3713
|
-
const { width: e15, height:
|
|
3714
|
-
this.offsets[s9] = t2, t2 +=
|
|
3713
|
+
const { width: e15, height: i2 } = this.getPageSize(s9);
|
|
3714
|
+
this.offsets[s9] = t2, t2 += i2 + this.config.pageGap, e15 > a3 && (a3 = e15);
|
|
3715
3715
|
}
|
|
3716
3716
|
this.totalHeight = e14 > 0 ? t2 - this.config.pageGap : 0, this.totalWidth = a3, this.layoutChange$.emit(this.computeLayout());
|
|
3717
3717
|
}
|
|
@@ -3721,8 +3721,8 @@ const Da = class extends BasePlugin {
|
|
|
3721
3721
|
for (const s9 of t2) {
|
|
3722
3722
|
const t3 = this.virtualPageMap.toGlobal(e14, s9.localPageIndex);
|
|
3723
3723
|
if (!t3) continue;
|
|
3724
|
-
const
|
|
3725
|
-
|
|
3724
|
+
const i2 = this.pageSizes.get(t3.globalPageIndex);
|
|
3725
|
+
i2 && i2.width === s9.width && i2.height === s9.height || (this.pageSizes.set(t3.globalPageIndex, { width: s9.width, height: s9.height }), a3 = true);
|
|
3726
3726
|
}
|
|
3727
3727
|
if (a3) {
|
|
3728
3728
|
const e15 = this.currentGlobalPageIndex, t3 = this.offsets[e15] ?? 0;
|
|
@@ -3740,10 +3740,10 @@ const Da = class extends BasePlugin {
|
|
|
3740
3740
|
harvestChapterSizes(e14, t2 = 0) {
|
|
3741
3741
|
var a3;
|
|
3742
3742
|
if (!this.virtualPageMap) return;
|
|
3743
|
-
const s9 = this.documentManager.provides().getDocument(e14),
|
|
3744
|
-
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 ===
|
|
3743
|
+
const s9 = this.documentManager.provides().getDocument(e14), i2 = this.virtualPageMap.pagesOfChapter(e14);
|
|
3744
|
+
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === i2.length) return void (t2 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(e14, t2 + 1)));
|
|
3745
3745
|
const o = this.getChapterDocumentScale(e14), r2 = [];
|
|
3746
|
-
for (const n2 of
|
|
3746
|
+
for (const n2 of i2) {
|
|
3747
3747
|
const e15 = s9.pages[n2.localPageIndex];
|
|
3748
3748
|
(null == e15 ? void 0 : e15.size) && r2.push({ localPageIndex: n2.localPageIndex, width: e15.size.width * o, height: e15.size.height * o });
|
|
3749
3749
|
}
|
|
@@ -3774,38 +3774,38 @@ const Da = class extends BasePlugin {
|
|
|
3774
3774
|
const e14 = this.virtualPageMap.totalPages;
|
|
3775
3775
|
if (0 === e14) return this.currentVisible = [], this.currentGlobalPageIndex = 0, void this.layoutChange$.emit(this.computeLayout());
|
|
3776
3776
|
const t2 = this.viewportEl.scrollTop, a3 = t2 + this.viewportEl.clientHeight, s9 = this.findFirstVisibleIndex(t2);
|
|
3777
|
-
let
|
|
3778
|
-
for (;
|
|
3779
|
-
const e15 = this.getPageSize(
|
|
3777
|
+
let i2 = s9;
|
|
3778
|
+
for (; i2 < e14; ) {
|
|
3779
|
+
const e15 = this.getPageSize(i2), t3 = this.offsets[i2];
|
|
3780
3780
|
if (e15.height, t3 >= a3) break;
|
|
3781
|
-
|
|
3781
|
+
i2++;
|
|
3782
3782
|
}
|
|
3783
3783
|
const o = [];
|
|
3784
3784
|
let r2 = s9, n2 = -1;
|
|
3785
|
-
for (let l = s9; l <
|
|
3785
|
+
for (let l = s9; l < i2; l++) {
|
|
3786
3786
|
o.push(l);
|
|
3787
|
-
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height,
|
|
3788
|
-
|
|
3787
|
+
const e15 = this.offsets[l], s10 = e15 + this.getPageSize(l).height, i3 = Math.max(0, Math.min(s10, a3) - Math.max(e15, t2));
|
|
3788
|
+
i3 > n2 && (n2 = i3, r2 = l);
|
|
3789
3789
|
}
|
|
3790
3790
|
this.currentVisible = o, this.currentGlobalPageIndex = r2, this.visibleChange$.emit({ visibleGlobalPageIndices: o, currentGlobalPageIndex: r2 }), this.chapterManager.provides().setVisibleGlobalPages(o), this.layoutChange$.emit(this.computeLayout());
|
|
3791
3791
|
}
|
|
3792
3792
|
findFirstVisibleIndex(e14) {
|
|
3793
3793
|
let t2 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
3794
3794
|
for (; t2 <= a3; ) {
|
|
3795
|
-
const
|
|
3796
|
-
this.offsets[
|
|
3795
|
+
const i2 = t2 + a3 >> 1;
|
|
3796
|
+
this.offsets[i2] <= e14 ? (s9 = i2, t2 = i2 + 1) : a3 = i2 - 1;
|
|
3797
3797
|
}
|
|
3798
3798
|
return s9;
|
|
3799
3799
|
}
|
|
3800
3800
|
computeLayout() {
|
|
3801
|
-
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14),
|
|
3801
|
+
const e14 = this.config.bufferSize, t2 = Math.max(0, (this.currentVisible[0] ?? 0) - e14), a3 = this.currentVisible[this.currentVisible.length - 1] ?? -1, s9 = Math.min(this.offsets.length - 1, (a3 >= 0 ? a3 : 0) + e14), i2 = [];
|
|
3802
3802
|
if (this.virtualPageMap && this.offsets.length > 0) for (let o = t2; o <= s9; o++) {
|
|
3803
3803
|
const e15 = this.virtualPageMap.atIndex(o);
|
|
3804
3804
|
if (!e15) continue;
|
|
3805
3805
|
const t3 = this.getPageSize(o), a4 = this.isChapterPagePlaceholder(e15.chapterId);
|
|
3806
|
-
|
|
3806
|
+
i2.push({ globalPageIndex: o, globalPageNumber: e15.globalPageNumber, chapterId: e15.chapterId, localPageIndex: e15.localPageIndex, width: t3.width, height: t3.height, offsetTop: this.offsets[o], isPlaceholder: a4 });
|
|
3807
3807
|
}
|
|
3808
|
-
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items:
|
|
3808
|
+
return { totalHeight: this.totalHeight, totalWidth: this.totalWidth || this.config.placeholderPageWidth, items: i2, pageGap: this.config.pageGap };
|
|
3809
3809
|
}
|
|
3810
3810
|
scrollToIndex(e14, t2) {
|
|
3811
3811
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length) return;
|
|
@@ -3815,11 +3815,11 @@ const Da = class extends BasePlugin {
|
|
|
3815
3815
|
scrollToGlobalPdfPoint(e14, t2, a3) {
|
|
3816
3816
|
var s9;
|
|
3817
3817
|
if (!this.viewportEl || e14 < 0 || e14 >= this.offsets.length || !this.virtualPageMap) return;
|
|
3818
|
-
const
|
|
3818
|
+
const i2 = (null == a3 ? void 0 : a3.marginTop) ?? 80, o = this.virtualPageMap.atIndex(e14);
|
|
3819
3819
|
if (!o) return void this.scrollToIndex(e14, a3);
|
|
3820
3820
|
const r2 = this.pageSizes.get(e14), n2 = null == (s9 = this.documentManager.provides().getDocument(o.chapterId)) ? void 0 : s9.pages[o.localPageIndex];
|
|
3821
3821
|
if (!r2 || !n2) return void this.scrollToIndex(e14, a3);
|
|
3822
|
-
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l -
|
|
3822
|
+
const l = r2.height / n2.size.height, h2 = (this.offsets[e14] ?? 0) + t2 * l - i2;
|
|
3823
3823
|
this.viewportEl.scrollTo({ top: Math.max(0, h2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
3824
3824
|
}
|
|
3825
3825
|
scrollToChapter(e14, t2) {
|
|
@@ -3833,11 +3833,11 @@ const Da = class extends BasePlugin {
|
|
|
3833
3833
|
a3 && this.scrollToIndex(a3.globalPageIndex, t2);
|
|
3834
3834
|
}
|
|
3835
3835
|
};
|
|
3836
|
-
|
|
3837
|
-
let
|
|
3838
|
-
const
|
|
3836
|
+
_a.id = "chapter-scroll";
|
|
3837
|
+
let Ea = _a;
|
|
3838
|
+
const Ra = class e12 extends BasePlugin {
|
|
3839
3839
|
constructor(e14, t2) {
|
|
3840
|
-
super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(
|
|
3840
|
+
super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(Ea.id), this.chapterManager = this.registry.getPlugin(za.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
3841
3841
|
}
|
|
3842
3842
|
async initialize(t2) {
|
|
3843
3843
|
if (this.config = t2, t2.callbacks.loadNotes) try {
|
|
@@ -3875,7 +3875,7 @@ const Ga = class e12 extends BasePlugin {
|
|
|
3875
3875
|
this.notesChange$.emit(this.listAll());
|
|
3876
3876
|
}
|
|
3877
3877
|
buildDraft(e14) {
|
|
3878
|
-
return { chapterId: e14.chapterId, localPageIndex: e14.localPageIndex, globalPageNumber: e14.globalPageNumber, globalPageIndex: e14.globalPageIndex, rectsPdfCoord: e14.rectsPdfCoord, endAnchor:
|
|
3878
|
+
return { chapterId: e14.chapterId, localPageIndex: e14.localPageIndex, globalPageNumber: e14.globalPageNumber, globalPageIndex: e14.globalPageIndex, rectsPdfCoord: e14.rectsPdfCoord, endAnchor: Ua(e14.rectsPdfCoord), selectedText: e14.selectedText, content: e14.content };
|
|
3879
3879
|
}
|
|
3880
3880
|
async requestCreateFromSelection(e14) {
|
|
3881
3881
|
if (0 === e14.rectsPdfCoord.length) return null;
|
|
@@ -3889,14 +3889,14 @@ const Ga = class e12 extends BasePlugin {
|
|
|
3889
3889
|
if (0 === t2.rectsPdfCoord.length) return null;
|
|
3890
3890
|
const a3 = this.buildDraft(t2), s9 = this.config.callbacks.onCreateNote;
|
|
3891
3891
|
if (!s9) return this.logger.error(e12.id, "CreateNote", "Missing onCreateNote / onRequestCreateNote"), null;
|
|
3892
|
-
let
|
|
3892
|
+
let i2 = null;
|
|
3893
3893
|
try {
|
|
3894
|
-
|
|
3894
|
+
i2 = await s9(a3);
|
|
3895
3895
|
} catch (r2) {
|
|
3896
3896
|
return this.logger.error(e12.id, "OnCreateNote", "Callback failed", r2), null;
|
|
3897
3897
|
}
|
|
3898
|
-
if (!
|
|
3899
|
-
const o = { ...a3, noteId:
|
|
3898
|
+
if (!i2) return null;
|
|
3899
|
+
const o = { ...a3, noteId: i2.noteId };
|
|
3900
3900
|
return this.registerNote(o), o;
|
|
3901
3901
|
}
|
|
3902
3902
|
async deleteNote(t2) {
|
|
@@ -3904,19 +3904,19 @@ const Ga = class e12 extends BasePlugin {
|
|
|
3904
3904
|
if (this.notes.has(t2)) {
|
|
3905
3905
|
try {
|
|
3906
3906
|
await (null == (s9 = (a3 = this.config.callbacks).onDeleteNote) ? void 0 : s9.call(a3, t2));
|
|
3907
|
-
} catch (
|
|
3908
|
-
return void this.logger.error(e12.id, "OnDeleteNote", "Callback failed",
|
|
3907
|
+
} catch (i2) {
|
|
3908
|
+
return void this.logger.error(e12.id, "OnDeleteNote", "Callback failed", i2);
|
|
3909
3909
|
}
|
|
3910
3910
|
this.notes.delete(t2), this.notesChange$.emit(this.listAll());
|
|
3911
3911
|
}
|
|
3912
3912
|
}
|
|
3913
3913
|
async updateNoteContent(t2, a3) {
|
|
3914
|
-
var s9,
|
|
3914
|
+
var s9, i2;
|
|
3915
3915
|
const o = this.notes.get(t2);
|
|
3916
3916
|
if (!o) return;
|
|
3917
3917
|
const r2 = { ...o, content: a3 };
|
|
3918
3918
|
try {
|
|
3919
|
-
await (null == (
|
|
3919
|
+
await (null == (i2 = (s9 = this.config.callbacks).onUpdateNote) ? void 0 : i2.call(s9, r2));
|
|
3920
3920
|
} catch (n2) {
|
|
3921
3921
|
return void this.logger.error(e12.id, "OnUpdateNote", "Callback failed", n2);
|
|
3922
3922
|
}
|
|
@@ -3934,32 +3934,32 @@ const Ga = class e12 extends BasePlugin {
|
|
|
3934
3934
|
const t2 = this.chapterScroll.provides(), a3 = t2.getLayout().items.find((t3) => t3.globalPageIndex === e14 && !t3.isPlaceholder);
|
|
3935
3935
|
return a3 ? Promise.resolve(a3) : new Promise((a4) => {
|
|
3936
3936
|
const s9 = setTimeout(() => {
|
|
3937
|
-
|
|
3938
|
-
}, 2500),
|
|
3937
|
+
i2(), a4(null);
|
|
3938
|
+
}, 2500), i2 = t2.onLayoutChange((t3) => {
|
|
3939
3939
|
const o = t3.items.find((t4) => t4.globalPageIndex === e14 && !t4.isPlaceholder);
|
|
3940
|
-
o && (clearTimeout(s9),
|
|
3940
|
+
o && (clearTimeout(s9), i2(), a4(o));
|
|
3941
3941
|
});
|
|
3942
3942
|
});
|
|
3943
3943
|
}
|
|
3944
3944
|
};
|
|
3945
|
-
|
|
3946
|
-
let
|
|
3947
|
-
function
|
|
3945
|
+
Ra.id = "note";
|
|
3946
|
+
let Fa = Ra;
|
|
3947
|
+
function Ua(e14) {
|
|
3948
3948
|
const t2 = e14[e14.length - 1];
|
|
3949
3949
|
return { x: t2.origin.x + t2.size.width, y: t2.origin.y + t2.size.height };
|
|
3950
3950
|
}
|
|
3951
|
-
function
|
|
3952
|
-
const { markerPdf: t2, lineRects: a3, sx: s9, sy:
|
|
3953
|
-
let h2,
|
|
3954
|
-
l ? (h2 = (l.origin.x + l.size.width) * s9 + n2,
|
|
3951
|
+
function qa(e14) {
|
|
3952
|
+
const { markerPdf: t2, lineRects: a3, sx: s9, sy: i2, cssPageWidth: o, iconSize: r2, gapPx: n2 = 6 } = e14, l = (a3 == null ? void 0 : a3.length) ? a3[a3.length - 1] : void 0;
|
|
3953
|
+
let h2, d2;
|
|
3954
|
+
l ? (h2 = (l.origin.x + l.size.width) * s9 + n2, d2 = l.origin.y * i2 + (l.size.height * i2 - r2) / 2) : (h2 = t2.x * s9 - r2 / 2, d2 = t2.y * i2 - r2 - n2);
|
|
3955
3955
|
const c = Math.max(0, o - r2 - 2);
|
|
3956
|
-
return h2 > c && (h2 = c),
|
|
3956
|
+
return h2 > c && (h2 = c), d2 < 0 && (d2 = 0), { left: h2, top: d2 };
|
|
3957
3957
|
}
|
|
3958
|
-
const
|
|
3959
|
-
const o = e14, { provides: r2 } = useCapability(
|
|
3958
|
+
const Wa = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "none", zIndex: 25 } }, Ha = ["onMouseenter"], Ba = ["data-note-marker-zone", "onMouseenter", "onMouseleave"], ja = ["onClick"], Za = ["onClick"], Ya = ["onClick"], Ka = /* @__PURE__ */ defineComponent({ __name: "NoteMarkerLayer", props: { chapterId: {}, localPageIndex: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, ui: {} }, setup(e14) {
|
|
3959
|
+
const o = e14, { provides: r2 } = useCapability(Fa.id), d2 = ref([]), g2 = ref(null), f = ref(null);
|
|
3960
3960
|
watch(r2, (e15) => {
|
|
3961
3961
|
if (e15) return e15.onNotesChange((e16) => {
|
|
3962
|
-
|
|
3962
|
+
d2.value = e16.filter((e17) => e17.chapterId === o.chapterId && e17.localPageIndex === o.localPageIndex);
|
|
3963
3963
|
});
|
|
3964
3964
|
}, { immediate: true });
|
|
3965
3965
|
let P = null;
|
|
@@ -3967,7 +3967,7 @@ const _a = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
|
|
|
3967
3967
|
P && (document.removeEventListener("mousedown", P), P = null), e15 && (P = (t2) => {
|
|
3968
3968
|
var _a2;
|
|
3969
3969
|
const a3 = t2.target;
|
|
3970
|
-
((_a2 = a3.closest) == null ? void 0 : _a2.call(a3, `[data-note-marker-zone="${e15}"]`)) || (f.value = null,
|
|
3970
|
+
((_a2 = a3.closest) == null ? void 0 : _a2.call(a3, `[data-note-marker-zone="${e15}"]`)) || (f.value = null, g2.value = null);
|
|
3971
3971
|
}, document.addEventListener("mousedown", P));
|
|
3972
3972
|
}), onBeforeUnmount(() => {
|
|
3973
3973
|
P && document.removeEventListener("mousedown", P);
|
|
@@ -3980,37 +3980,37 @@ const _a = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
|
|
|
3980
3980
|
return ((_a2 = o.ui) == null ? void 0 : _a2.highlightColor) ?? "rgba(245, 158, 11, 0.08)";
|
|
3981
3981
|
});
|
|
3982
3982
|
function C(e15) {
|
|
3983
|
-
const t2 = o.cssPageWidth / o.pdfPageWidth, a3 = o.cssPageHeight / o.pdfPageHeight, s9 = w.value, { left:
|
|
3984
|
-
let s10 = 1 / 0,
|
|
3985
|
-
for (const n3 of e16) s10 = Math.min(s10, n3.origin.x * t3),
|
|
3986
|
-
return { left: s10, top:
|
|
3987
|
-
})(e15.rectsPdfCoord, t2, a3), l = f.value === e15.noteId ? 72 : 0, h2 = Math.max(0, Math.min(n2.left,
|
|
3988
|
-
return { zoneLeft: h2, zoneTop:
|
|
3989
|
-
}
|
|
3990
|
-
return (t2, a3) => unref(r2) &&
|
|
3991
|
-
}, ["stop"])), onClick: withModifiers((t3) => f.value = f.value === e15.noteId ? null : e15.noteId, ["stop"]) }, " 💬 ", 44,
|
|
3983
|
+
const t2 = o.cssPageWidth / o.pdfPageWidth, a3 = o.cssPageHeight / o.pdfPageHeight, s9 = w.value, { left: i2, top: r3 } = qa({ markerPdf: e15.endAnchor, lineRects: e15.rectsPdfCoord, sx: t2, sy: a3, cssPageWidth: o.cssPageWidth, iconSize: s9 }), n2 = (function(e16, t3, a4) {
|
|
3984
|
+
let s10 = 1 / 0, i3 = 1 / 0, o2 = -1 / 0, r4 = -1 / 0;
|
|
3985
|
+
for (const n3 of e16) s10 = Math.min(s10, n3.origin.x * t3), i3 = Math.min(i3, n3.origin.y * a4), o2 = Math.max(o2, (n3.origin.x + n3.size.width) * t3), r4 = Math.max(r4, (n3.origin.y + n3.size.height) * a4);
|
|
3986
|
+
return { left: s10, top: i3, width: o2 - s10, height: r4 - i3 };
|
|
3987
|
+
})(e15.rectsPdfCoord, t2, a3), l = f.value === e15.noteId ? 72 : 0, h2 = Math.max(0, Math.min(n2.left, i2) - 8), d3 = Math.max(0, Math.min(n2.top, r3) - 8);
|
|
3988
|
+
return { zoneLeft: h2, zoneTop: d3, zoneW: Math.min(o.cssPageWidth, Math.max(n2.left + n2.width, i2 + s9) + 8) - h2, zoneH: Math.max(n2.top + n2.height, r3 + s9 + 6 + l) + 8 - d3, iconLeft: i2, iconTop: r3, sx: t2, sy: a3 };
|
|
3989
|
+
}
|
|
3990
|
+
return (t2, a3) => unref(r2) && d2.value.length && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", Wa, [(openBlock(true), createElementBlock(Fragment, null, renderList(d2.value, (e15) => (openBlock(), createElementBlock(Fragment, { key: e15.noteId }, [(openBlock(true), createElementBlock(Fragment, null, renderList(e15.rectsPdfCoord, (t3, a4) => (openBlock(), createElementBlock("div", { key: `${e15.noteId}-bg-${a4}`, style: normalizeStyle({ position: "absolute", left: t3.origin.x * C(e15).sx + "px", top: t3.origin.y * C(e15).sy + "px", width: t3.size.width * C(e15).sx + "px", height: t3.size.height * C(e15).sy + "px", background: y.value, borderRadius: "2px", pointerEvents: "auto" }), onMouseenter: (t4) => g2.value = e15.noteId }, null, 44, Ha))), 128)), g2.value === e15.noteId || f.value === e15.noteId ? (openBlock(), createElementBlock("div", { key: 0, "data-note-marker-zone": e15.noteId, style: normalizeStyle({ position: "absolute", left: `${C(e15).zoneLeft}px`, top: `${C(e15).zoneTop}px`, width: `${C(e15).zoneW}px`, height: `${C(e15).zoneH}px`, pointerEvents: "auto", zIndex: 26 }), onMouseenter: (t3) => g2.value = e15.noteId, onMouseleave: (t3) => f.value !== e15.noteId && (g2.value = null) }, [createElementVNode("button", { type: "button", title: "笔记", style: normalizeStyle({ position: "absolute", left: C(e15).iconLeft - C(e15).zoneLeft + "px", top: C(e15).iconTop - C(e15).zoneTop + "px", width: `${w.value}px`, height: `${w.value}px`, border: "none", borderRadius: "50%", background: "#f59e0b", color: "#fff", cursor: "pointer", fontSize: "11px", padding: 0 }), onMousedown: a3[0] || (a3[0] = withModifiers(() => {
|
|
3991
|
+
}, ["stop"])), onClick: withModifiers((t3) => f.value = f.value === e15.noteId ? null : e15.noteId, ["stop"]) }, " 💬 ", 44, ja), f.value === e15.noteId ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: C(e15).iconLeft - C(e15).zoneLeft + "px", top: `${C(e15).iconTop - C(e15).zoneTop + w.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: a3[1] || (a3[1] = withModifiers(() => {
|
|
3992
3992
|
}, ["stop"])) }, [createElementVNode("button", { type: "button", style: { display: "block", width: "100%", padding: "6px 8px", "font-size": "12px", border: "none", "border-radius": "4px", background: "transparent", color: "#334155", cursor: "pointer", "text-align": "left" }, onClick: (t3) => (function(e16) {
|
|
3993
3993
|
var _a2;
|
|
3994
3994
|
(_a2 = r2.value) == null ? void 0 : _a2.requestEditNote(e16.noteId, e16);
|
|
3995
|
-
})(e15) }, " 编辑 ", 8,
|
|
3995
|
+
})(e15) }, " 编辑 ", 8, Za), createElementVNode("button", { type: "button", style: { display: "block", width: "100%", padding: "6px 8px", "font-size": "12px", border: "none", "border-radius": "4px", background: "transparent", color: "#dc2626", cursor: "pointer", "text-align": "left" }, onClick: (t3) => {
|
|
3996
3996
|
var _a2;
|
|
3997
3997
|
return a4 = e15.noteId, (_a2 = r2.value) == null ? void 0 : _a2.requestDeleteNote(a4), void (f.value = null);
|
|
3998
3998
|
var a4;
|
|
3999
|
-
} }, " 删除 ", 8,
|
|
4000
|
-
} }),
|
|
4001
|
-
const o = e14, { provides: r2 } = useCapability(
|
|
3999
|
+
} }, " 删除 ", 8, Ya)], 36)) : createCommentVNode("", true)], 44, Ba)) : createCommentVNode("", true)], 64))), 128))])) : createCommentVNode("", true);
|
|
4000
|
+
} }), Xa = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "none" } }, Qa = ["title", "onClick"], Ja = ["onClick"], es = /* @__PURE__ */ defineComponent({ __name: "BookmarkMarkerLayer", props: { chapterId: {}, localPageIndex: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, ui: {} }, setup(e14) {
|
|
4001
|
+
const o = e14, { provides: r2 } = useCapability(Wt.id), d2 = ref([]), g2 = ref(null), f = ref(null);
|
|
4002
4002
|
function P() {
|
|
4003
4003
|
const e15 = r2.value;
|
|
4004
|
-
e15 && (
|
|
4004
|
+
e15 && (d2.value = e15.listBookmarks().filter((e16) => e16.anchor.chapterId === o.chapterId && e16.anchor.localPageIndex === o.localPageIndex));
|
|
4005
4005
|
}
|
|
4006
4006
|
watch(r2, (e15) => {
|
|
4007
4007
|
if (e15) return P(), e15.onBookmarksChange(P);
|
|
4008
4008
|
}, { immediate: true });
|
|
4009
4009
|
let w = null;
|
|
4010
|
-
watch(
|
|
4010
|
+
watch(g2, (e15) => {
|
|
4011
4011
|
w && (document.removeEventListener("mousedown", w), w = null), e15 && (w = (e16) => {
|
|
4012
4012
|
var _a2;
|
|
4013
|
-
((_a2 = f.value) == null ? void 0 : _a2.contains(e16.target)) || (
|
|
4013
|
+
((_a2 = f.value) == null ? void 0 : _a2.contains(e16.target)) || (g2.value = null);
|
|
4014
4014
|
}, document.addEventListener("mousedown", w));
|
|
4015
4015
|
}), onBeforeUnmount(() => {
|
|
4016
4016
|
w && document.removeEventListener("mousedown", w);
|
|
@@ -4023,46 +4023,46 @@ const _a = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
|
|
|
4023
4023
|
const { left: t2, top: a3 } = (function(e16) {
|
|
4024
4024
|
var _a2;
|
|
4025
4025
|
const t3 = o.cssPageWidth / o.pdfPageWidth, a4 = o.cssPageHeight / o.pdfPageHeight, s9 = ((_a2 = e16.anchor.rectsPdfCoord) == null ? void 0 : _a2.length) ? e16.anchor.rectsPdfCoord : [e16.anchor.rectPdfCoord];
|
|
4026
|
-
return
|
|
4026
|
+
return qa({ markerPdf: e16.anchor.markerAnchor ?? { x: e16.anchor.rectPdfCoord.origin.x + e16.anchor.rectPdfCoord.size.width, y: e16.anchor.rectPdfCoord.origin.y + e16.anchor.rectPdfCoord.size.height }, lineRects: s9, sx: t3, sy: a4, cssPageWidth: o.cssPageWidth, iconSize: y.value });
|
|
4027
4027
|
})(e15);
|
|
4028
4028
|
return { position: "absolute", left: `${Math.max(0, t2 - 6)}px`, top: `${Math.max(0, a3 - 6)}px`, width: `${y.value + 12}px`, height: `${y.value + 12}px`, pointerEvents: "auto", zIndex: 20 };
|
|
4029
4029
|
}
|
|
4030
|
-
return (t2, a3) => unref(r2) &&
|
|
4031
|
-
}, ["stop"])) }, [createElementVNode("button", { type: "button", title: e15.label, style: normalizeStyle({ position: "absolute", left: "6px", top: "6px", width: `${y.value}px`, height: `${y.value}px`, border: "none", borderRadius: "4px", background: "#3b82f6", color: "#fff", cursor: "pointer", boxShadow: "0 2px 6px rgba(37, 99, 235, 0.35)", fontSize: "11px", padding: 0 }), onClick: withModifiers((t3) =>
|
|
4030
|
+
return (t2, a3) => unref(r2) && d2.value.length && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", Xa, [(openBlock(true), createElementBlock(Fragment, null, renderList(d2.value, (e15) => (openBlock(), createElementBlock("div", { key: e15.id, style: normalizeStyle(C(e15)), onMousedown: a3[1] || (a3[1] = withModifiers(() => {
|
|
4031
|
+
}, ["stop"])) }, [createElementVNode("button", { type: "button", title: e15.label, style: normalizeStyle({ position: "absolute", left: "6px", top: "6px", width: `${y.value}px`, height: `${y.value}px`, border: "none", borderRadius: "4px", background: "#3b82f6", color: "#fff", cursor: "pointer", boxShadow: "0 2px 6px rgba(37, 99, 235, 0.35)", fontSize: "11px", padding: 0 }), onClick: withModifiers((t3) => g2.value = g2.value === e15.id ? null : e15.id, ["stop"]) }, " 🔖 ", 12, Qa), g2.value === e15.id ? (openBlock(), createElementBlock("div", { key: 0, ref_for: true, ref_key: "deleteMenuRef", ref: f, style: { position: "absolute", left: "6px", top: "-36px", zIndex: 30, pointerEvents: "auto", minWidth: "88px", padding: "4px", borderRadius: "6px", background: "#fff", border: "1px solid #e5e7eb", boxShadow: "0 4px 12px rgba(0,0,0,0.12)" }, onClick: a3[0] || (a3[0] = withModifiers(() => {
|
|
4032
4032
|
}, ["stop"])) }, [createElementVNode("button", { type: "button", style: { width: "100%", padding: "6px 8px", "font-size": "12px", border: "none", "border-radius": "4px", background: "transparent", color: "#dc2626", cursor: "pointer", "text-align": "left" }, onClick: (t3) => (async function(e16) {
|
|
4033
4033
|
const t4 = r2.value;
|
|
4034
4034
|
if (!t4) return;
|
|
4035
|
-
await t4.requestRemoveBookmark(e16) && (
|
|
4036
|
-
})(e15.id) }, " 删除书签 ", 8,
|
|
4035
|
+
await t4.requestRemoveBookmark(e16) && (g2.value = null);
|
|
4036
|
+
})(e15.id) }, " 删除书签 ", 8, Ja)], 512)) : createCommentVNode("", true)], 36))), 128))])) : createCommentVNode("", true);
|
|
4037
4037
|
} });
|
|
4038
|
-
function
|
|
4038
|
+
function ts(e14) {
|
|
4039
4039
|
return e14.chapterId;
|
|
4040
4040
|
}
|
|
4041
|
-
function
|
|
4041
|
+
function as(e14, t2) {
|
|
4042
4042
|
e14.wait(t2, () => {
|
|
4043
4043
|
});
|
|
4044
4044
|
}
|
|
4045
|
-
const
|
|
4046
|
-
const a3 = e14,
|
|
4045
|
+
const ss = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props: { item: {}, features: {}, showNoteMarkers: { type: Boolean }, showBookmarkMarkers: { type: Boolean }, showRedactionLayer: { type: Boolean }, noteMarkerUi: {}, bookmarkMarkerUi: {}, buildSelectionMenu: { type: Function }, createNote: {}, annotationSelectionMenu: {}, redactionSelectionMenu: {}, renderPageOverlay: { type: Function } }, setup(e14) {
|
|
4046
|
+
const a3 = e14, i2 = computed(() => ts(a3.item));
|
|
4047
4047
|
!(function(e15) {
|
|
4048
4048
|
const { provides: t2 } = useCapability(DocumentManagerPlugin.id);
|
|
4049
4049
|
watch([t2, e15], ([e16, t3]) => {
|
|
4050
4050
|
e16 && t3 && e16.isDocumentOpen(t3) && e16.setActiveDocument(t3);
|
|
4051
4051
|
}, { immediate: true });
|
|
4052
|
-
})(
|
|
4052
|
+
})(i2);
|
|
4053
4053
|
const { provides: o } = useCapability(DocumentManagerPlugin.id), { provides: r2 } = useCapability(SelectionPlugin.id), l = computed(() => {
|
|
4054
4054
|
var _a2, _b;
|
|
4055
|
-
return (_b = (_a2 = o.value) == null ? void 0 : _a2.getDocument(
|
|
4055
|
+
return (_b = (_a2 = o.value) == null ? void 0 : _a2.getDocument(i2.value)) == null ? void 0 : _b.pages[a3.item.localPageIndex];
|
|
4056
4056
|
});
|
|
4057
|
-
function
|
|
4057
|
+
function h2(e15, t2) {
|
|
4058
4058
|
const s9 = a3.createNote.value;
|
|
4059
4059
|
if (s9) return (a4) => {
|
|
4060
4060
|
var _a2;
|
|
4061
|
-
const
|
|
4062
|
-
return h("div", a4.menuWrapperProps, [h("div", { style:
|
|
4061
|
+
const i3 = { position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: ((_a2 = a4.placement) == null ? void 0 : _a2.suggestTop) ? -40 : a4.rect.size.height + 8 };
|
|
4062
|
+
return h$1("div", a4.menuWrapperProps, [h$1("div", { style: i3 }, h$1("button", { type: "button", style: { padding: "6px 10px", fontSize: "12px", border: "1px solid #e2e8f0", borderRadius: "6px", background: "#fff", cursor: "pointer" }, onClick: () => {
|
|
4063
4063
|
if (!r2.value) return;
|
|
4064
4064
|
const a5 = r2.value.getHighlightRectsForPage(e15.localPageIndex, t2);
|
|
4065
|
-
|
|
4065
|
+
as(r2.value.getSelectedText(t2), (t3) => {
|
|
4066
4066
|
s9((function(e16, t4, a6) {
|
|
4067
4067
|
return { chapterId: e16.chapterId, localPageIndex: e16.localPageIndex, globalPageIndex: e16.globalPageIndex, globalPageNumber: e16.globalPageNumber, rectsPdfCoord: t4, selectedText: a6 };
|
|
4068
4068
|
})(e15, a5, t3.join("\n")));
|
|
@@ -4070,8 +4070,8 @@ const Xa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
4070
4070
|
} }, "添加附注"))]);
|
|
4071
4071
|
};
|
|
4072
4072
|
}
|
|
4073
|
-
const
|
|
4074
|
-
const e15 = a3.buildSelectionMenu, t2 = { item: a3.item, defaultMenu:
|
|
4073
|
+
const d2 = computed(() => {
|
|
4074
|
+
const e15 = a3.buildSelectionMenu, t2 = { item: a3.item, defaultMenu: h2(a3.item, i2.value), createNote: a3.createNote.value };
|
|
4075
4075
|
if (e15) {
|
|
4076
4076
|
const a4 = e15(t2);
|
|
4077
4077
|
if (a4) return a4;
|
|
@@ -4081,22 +4081,22 @@ const Xa = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
|
|
|
4081
4081
|
var _a2;
|
|
4082
4082
|
return (_a2 = a3.renderPageOverlay) == null ? void 0 : _a2.call(a3, a3.item);
|
|
4083
4083
|
});
|
|
4084
|
-
return (t2, a4) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id":
|
|
4084
|
+
return (t2, a4) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id": i2.value }, { default: withCtx(() => [createVNode(unref(Rotate), { "document-id": i2.value, "page-index": e14.item.localPageIndex, style: { backgroundColor: "#fff" } }, { default: withCtx(() => [createVNode(unref(PagePointerProvider), { "document-id": i2.value, "page-index": e14.item.localPageIndex }, { default: withCtx(() => [createVNode(unref(Ma), { "chapter-id": i2.value, "local-page-index": e14.item.localPageIndex }, null, 8, ["chapter-id", "local-page-index"]), createVNode(unref(SelectionLayer), { "document-id": i2.value, "page-index": e14.item.localPageIndex, "selection-menu": d2.value }, null, 8, ["document-id", "page-index", "selection-menu"]), e14.showRedactionLayer ? (openBlock(), createBlock(unref(RedactionLayer), { key: 0, "document-id": i2.value, "page-index": e14.item.localPageIndex, "selection-menu": e14.redactionSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"])) : createCommentVNode("", true), createVNode(unref(AnnotationLayer), { "document-id": i2.value, "page-index": e14.item.localPageIndex, "selection-menu": e14.annotationSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"]), e14.showBookmarkMarkers && l.value ? (openBlock(), createBlock(es, { key: 1, "chapter-id": i2.value, "local-page-index": e14.item.localPageIndex, "pdf-page-width": l.value.size.width, "pdf-page-height": l.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), c.value ? (openBlock(), createBlock(resolveDynamicComponent(c.value), { key: 2 })) : createCommentVNode("", true), e14.showNoteMarkers && l.value ? (openBlock(), createBlock(Ka, { key: 3, "chapter-id": i2.value, "local-page-index": e14.item.localPageIndex, "pdf-page-width": l.value.size.width, "pdf-page-height": l.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"])]), _: 3 }, 8, ["document-id", "page-index"])]), _: 3 }, 8, ["document-id"]));
|
|
4085
4085
|
} });
|
|
4086
|
-
const
|
|
4087
|
-
const o = e14, r2 = computed(() =>
|
|
4086
|
+
const is = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props: { item: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, hoverUi: {} }, setup(e14) {
|
|
4087
|
+
const o = e14, r2 = computed(() => ts(o.item)), { provides: d2 } = useCapability(SelectionPlugin.id), { provides: u } = useCapability(Wt.id), p2 = ref(null), g2 = ref(null), f = ref(null), P = ref(null), w = computed(() => {
|
|
4088
4088
|
var _a2;
|
|
4089
4089
|
return ((_a2 = o.hoverUi) == null ? void 0 : _a2.iconSize) ?? 16;
|
|
4090
4090
|
}), y = computed(() => P.value ?? f.value);
|
|
4091
4091
|
let C = null, I = 0;
|
|
4092
4092
|
function M() {
|
|
4093
|
-
const e15 =
|
|
4093
|
+
const e15 = d2.value;
|
|
4094
4094
|
if (!e15) return;
|
|
4095
4095
|
const t2 = e15.forDocument(r2.value).getState().geometry[o.item.localPageIndex];
|
|
4096
|
-
t2 && (
|
|
4096
|
+
t2 && (g2.value = t2);
|
|
4097
4097
|
}
|
|
4098
|
-
watch([
|
|
4099
|
-
if (C == null ? void 0 : C(), C = null, cancelAnimationFrame(I),
|
|
4098
|
+
watch([d2, r2, () => o.item.localPageIndex], ([e15]) => {
|
|
4099
|
+
if (C == null ? void 0 : C(), C = null, cancelAnimationFrame(I), g2.value = null, !e15) return;
|
|
4100
4100
|
const t2 = e15.forDocument(r2.value);
|
|
4101
4101
|
C = t2.onSelectionChange(M);
|
|
4102
4102
|
let a3 = false;
|
|
@@ -4114,37 +4114,37 @@ const Qa = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
|
|
|
4114
4114
|
};
|
|
4115
4115
|
}, { immediate: true });
|
|
4116
4116
|
let x = null;
|
|
4117
|
-
watch([
|
|
4118
|
-
x && (document.removeEventListener("mousemove", x), x = null),
|
|
4117
|
+
watch([g2, () => o.pdfPageWidth, P, d2], () => {
|
|
4118
|
+
x && (document.removeEventListener("mousemove", x), x = null), g2.value && o.pdfPageWidth && (x = (e15) => {
|
|
4119
4119
|
if (P.value) return;
|
|
4120
|
-
const t2 =
|
|
4120
|
+
const t2 = d2.value;
|
|
4121
4121
|
if (t2) try {
|
|
4122
4122
|
if (t2.forDocument(r2.value).getState().selecting) return void (f.value = null);
|
|
4123
4123
|
} catch {
|
|
4124
4124
|
}
|
|
4125
|
-
const a3 =
|
|
4125
|
+
const a3 = p2.value;
|
|
4126
4126
|
if (!a3) return;
|
|
4127
4127
|
const s9 = a3.getBoundingClientRect();
|
|
4128
4128
|
if (e15.clientX < s9.left || e15.clientX > s9.right || e15.clientY < s9.top || e15.clientY > s9.bottom) return void (f.value = null);
|
|
4129
|
-
const
|
|
4129
|
+
const i2 = (function(e16, t3) {
|
|
4130
4130
|
const a4 = glyphAt(e16, t3);
|
|
4131
4131
|
if (a4 < 0) return null;
|
|
4132
4132
|
const s10 = expandToLineBoundary(e16, a4);
|
|
4133
4133
|
if (!s10) return null;
|
|
4134
|
-
const
|
|
4135
|
-
return 0 ===
|
|
4136
|
-
})(
|
|
4137
|
-
f.value = (
|
|
4134
|
+
const i3 = rectsWithinSlice(e16, s10.from, s10.to);
|
|
4135
|
+
return 0 === i3.length ? null : { lineRects: i3, charFrom: s10.from, charTo: s10.to };
|
|
4136
|
+
})(g2.value, { x: (e15.clientX - s9.left) / (o.cssPageWidth / o.pdfPageWidth), y: (e15.clientY - s9.top) / (o.cssPageHeight / o.pdfPageHeight) });
|
|
4137
|
+
f.value = (i2 == null ? void 0 : i2.lineRects) ?? null;
|
|
4138
4138
|
}, document.addEventListener("mousemove", x));
|
|
4139
4139
|
}, { immediate: true }), onBeforeUnmount(() => {
|
|
4140
4140
|
x && document.removeEventListener("mousemove", x), cancelAnimationFrame(I), C == null ? void 0 : C();
|
|
4141
4141
|
});
|
|
4142
4142
|
const k2 = computed(() => {
|
|
4143
4143
|
const e15 = y.value;
|
|
4144
|
-
return (e15 == null ? void 0 : e15.length) ?
|
|
4144
|
+
return (e15 == null ? void 0 : e15.length) ? Ft(o.item.chapterId, o.item.localPageIndex, e15, { globalPageIndex: o.item.globalPageIndex, globalPageNumber: o.item.globalPageNumber }) : null;
|
|
4145
4145
|
}), L2 = computed(() => {
|
|
4146
4146
|
const e15 = k2.value, t2 = u.value;
|
|
4147
|
-
return !(!e15 || !t2) && t2.listBookmarks().some((t3) =>
|
|
4147
|
+
return !(!e15 || !t2) && t2.listBookmarks().some((t3) => Rt(t3.anchor, e15));
|
|
4148
4148
|
});
|
|
4149
4149
|
function $2() {
|
|
4150
4150
|
const e15 = u.value, t2 = k2.value;
|
|
@@ -4153,45 +4153,45 @@ const Qa = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
|
|
|
4153
4153
|
const z = computed(() => {
|
|
4154
4154
|
const e15 = y.value, t2 = e15 == null ? void 0 : e15[e15.length - 1];
|
|
4155
4155
|
if (!t2 || !o.pdfPageWidth) return null;
|
|
4156
|
-
const a3 = o.cssPageWidth / o.pdfPageWidth, s9 = o.cssPageHeight / o.pdfPageHeight,
|
|
4157
|
-
return { iconLeft: Math.min((t2.origin.x + t2.size.width) * a3 + 6, Math.max(0, o.cssPageWidth -
|
|
4156
|
+
const a3 = o.cssPageWidth / o.pdfPageWidth, s9 = o.cssPageHeight / o.pdfPageHeight, i2 = w.value;
|
|
4157
|
+
return { iconLeft: Math.min((t2.origin.x + t2.size.width) * a3 + 6, Math.max(0, o.cssPageWidth - i2 - 2)), iconTop: t2.origin.y * s9 + (t2.size.height * s9 - i2) / 2, zoneLeft: Math.max(0, (t2.origin.x + t2.size.width) * a3 - 4), zoneTop: Math.max(0, t2.origin.y * s9 - 4), size: i2 };
|
|
4158
4158
|
});
|
|
4159
4159
|
return (t2, a3) => {
|
|
4160
4160
|
var _a2;
|
|
4161
|
-
return unref(u) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref:
|
|
4161
|
+
return unref(u) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref: p2, style: { position: "absolute", inset: "0", zIndex: 14, pointerEvents: "none" } }, [z.value && y.value && !L2.value ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: `${z.value.zoneLeft}px`, top: `${z.value.zoneTop}px`, width: `${z.value.size + 20}px`, height: `${(((_a2 = y.value[y.value.length - 1]) == null ? void 0 : _a2.size.height) ?? 0) * (e14.cssPageHeight / e14.pdfPageHeight) + z.value.size + 12}px`, pointerEvents: "auto" }), onMouseenter: a3[0] || (a3[0] = (e15) => P.value = y.value), onMouseleave: a3[1] || (a3[1] = (e15) => P.value = null) }, [createElementVNode("button", { type: "button", title: "添加书签", style: normalizeStyle({ position: "absolute", left: z.value.iconLeft - z.value.zoneLeft + "px", top: z.value.iconTop - z.value.zoneTop + "px", width: `${z.value.size}px`, height: `${z.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($2, ["stop"]) }, " 🔖 ", 4)], 36)) : createCommentVNode("", true)], 512)) : createCommentVNode("", true);
|
|
4162
4162
|
};
|
|
4163
|
-
} }),
|
|
4164
|
-
const
|
|
4163
|
+
} }), os = { key: 0, width: "24", height: "24", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "" }, rs = { key: 0, x: "5", y: "4", width: "18", height: "20", rx: "3", fill: "#fde047" }, ns = { key: 1, d: "M6 22h16", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, ls = { 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" }, hs = { key: 3, d: "M5 14h18", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, ds = { key: 1, width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, cs = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarIcons", props: { kind: {} }, setup: (e14) => (t2, a3) => "note" !== e14.kind ? (openBlock(), createElementBlock("svg", os, ["highlight" === e14.kind ? (openBlock(), createElementBlock("rect", rs)) : createCommentVNode("", true), a3[0] || (a3[0] = 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", ns)) : "squiggly" === e14.kind ? (openBlock(), createElementBlock("path", ls)) : "strikeout" === e14.kind ? (openBlock(), createElementBlock("path", hs)) : createCommentVNode("", true)])) : (openBlock(), createElementBlock("svg", ds, [...a3[1] || (a3[1] = [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)])])) }), us = ["title", "aria-label", "onMouseenter", "onClick"], ps = ["title", "onMouseenter", "onClick"], gs = { style: { "font-size": "11px", "font-weight": "600" } }, fs = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarCard", props: { placementAbove: { type: Boolean }, anchorHeight: {}, hiddenBuiltinActions: {}, extraActions: {} }, emits: ["action"], setup(e14, { emit: s9 }) {
|
|
4164
|
+
const i2 = e14, o = s9, r2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }, { id: "note", label: "添加笔记" }], d2 = computed(() => new Set(i2.hiddenBuiltinActions ?? [])), g2 = computed(() => r2.filter((e15) => "note" !== e15.id && !d2.value.has(e15.id))), f = computed(() => !d2.value.has("note")), m = computed(() => [...i2.extraActions ?? []].sort((e15, t2) => (e15.order ?? 0) - (t2.order ?? 0))), v = ref(null), P = computed(() => ({ position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: i2.placementAbove ? void 0 : `${i2.anchorHeight + 10}px`, bottom: i2.placementAbove ? `${i2.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)" }));
|
|
4165
4165
|
function y(e15, t2 = false) {
|
|
4166
4166
|
return { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px", padding: 0, margin: 0, border: "none", borderRadius: "8px", background: v.value === e15 ? t2 ? "#fffbeb" : "#f1f5f9" : "transparent", color: t2 ? "#b45309" : "#334155", cursor: "pointer", flexShrink: 0, WebkitAppearance: "none", appearance: "none" };
|
|
4167
4167
|
}
|
|
4168
4168
|
const C = { width: "1px", height: "20px", margin: "0 4px", background: "rgba(15, 23, 42, 0.1)", flexShrink: 0 };
|
|
4169
|
-
return (e15, t2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(P.value) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
4170
|
-
} }),
|
|
4171
|
-
const
|
|
4172
|
-
const a3 = e14, s9 = computed(() => a3.features), { hostRef:
|
|
4169
|
+
return (e15, t2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(P.value) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(g2.value, (e16) => (openBlock(), createElementBlock("button", { key: e16.id, type: "button", title: e16.label, "aria-label": e16.label, style: normalizeStyle(y(e16.id)), onMouseenter: (t3) => v.value = e16.id, onMouseleave: t2[0] || (t2[0] = (e17) => v.value = null), onClick: (t3) => o("action", e16.id) }, [createVNode(cs, { kind: e16.id }, null, 8, ["kind"])], 44, us))), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(m.value, (e16) => (openBlock(), createElementBlock("button", { key: e16.id, type: "button", title: e16.label, style: normalizeStyle(y(e16.id)), onMouseenter: (t3) => v.value = e16.id, onMouseleave: t2[1] || (t2[1] = (e17) => v.value = null), onClick: (t3) => o("action", e16.id) }, [createElementVNode("span", gs, toDisplayString(e16.label.slice(0, 2)), 1)], 44, ps))), 128)), f.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", { style: C, "aria-hidden": "" }), createElementVNode("button", { type: "button", title: "添加笔记", "aria-label": "添加笔记", style: normalizeStyle(y("note", true)), onMouseenter: t2[2] || (t2[2] = (e16) => v.value = "note"), onMouseleave: t2[3] || (t2[3] = (e16) => v.value = null), onClick: t2[4] || (t2[4] = (e16) => o("action", "note")) }, [createVNode(cs, { kind: "note" })], 36)], 64)) : createCommentVNode("", true)], 4));
|
|
4170
|
+
} }), ms = { highlight: "highlight", underline: "underline", squiggly: "squiggly", strikeout: "strikeout" };
|
|
4171
|
+
const vs = /* @__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) {
|
|
4172
|
+
const a3 = e14, s9 = computed(() => a3.features), { hostRef: i2 } = ua(s9), o = (function() {
|
|
4173
4173
|
const { registry: e15 } = useRegistry();
|
|
4174
4174
|
return computed(() => {
|
|
4175
4175
|
var _a2, _b, _c;
|
|
4176
|
-
const t2 = (_c = (_b = (_a2 = e15.value) == null ? void 0 : _a2.getPlugin(
|
|
4176
|
+
const t2 = (_c = (_b = (_a2 = e15.value) == null ? void 0 : _a2.getPlugin(vt$1.id)) == null ? void 0 : _b.provides) == null ? void 0 : _c.call(_b);
|
|
4177
4177
|
return t2 ? (e16) => t2.createNoteFromSelection(e16) : null;
|
|
4178
4178
|
});
|
|
4179
4179
|
})(), r2 = (function() {
|
|
4180
4180
|
const { registry: e15 } = useRegistry();
|
|
4181
4181
|
return computed(() => {
|
|
4182
4182
|
var _a2;
|
|
4183
|
-
return !!((_a2 = e15.value) == null ? void 0 : _a2.getPlugin(
|
|
4183
|
+
return !!((_a2 = e15.value) == null ? void 0 : _a2.getPlugin(vt$1.id));
|
|
4184
4184
|
});
|
|
4185
4185
|
})(), c = (function() {
|
|
4186
4186
|
const { registry: e15 } = useRegistry();
|
|
4187
4187
|
return computed(() => {
|
|
4188
4188
|
var _a2;
|
|
4189
|
-
return !!((_a2 = e15.value) == null ? void 0 : _a2.getPlugin(
|
|
4189
|
+
return !!((_a2 = e15.value) == null ? void 0 : _a2.getPlugin(Wt.id));
|
|
4190
4190
|
});
|
|
4191
4191
|
})(), u = computed(() => {
|
|
4192
4192
|
var _a2, _b;
|
|
4193
4193
|
return a3.showNoteMarkers && r2.value && false !== ((_b = (_a2 = a3.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.enabled);
|
|
4194
|
-
}),
|
|
4194
|
+
}), p2 = computed(() => {
|
|
4195
4195
|
var _a2, _b;
|
|
4196
4196
|
return a3.showBookmarkMarkers && c.value && false !== ((_b = (_a2 = a3.features) == null ? void 0 : _a2.bookmarks) == null ? void 0 : _b.enabled);
|
|
4197
4197
|
}), f = computed(() => {
|
|
@@ -4201,34 +4201,34 @@ const cs = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
4201
4201
|
const s10 = computed(() => {
|
|
4202
4202
|
var _a2;
|
|
4203
4203
|
return (_a2 = e15()) == null ? void 0 : _a2.selectionToolbar;
|
|
4204
|
-
}),
|
|
4204
|
+
}), i3 = computed(() => {
|
|
4205
4205
|
var _a2, _b;
|
|
4206
4206
|
return false !== ((_b = (_a2 = e15()) == null ? void 0 : _a2.markup) == null ? void 0 : _b.enabled);
|
|
4207
4207
|
}), o2 = computed(() => {
|
|
4208
4208
|
var _a2, _b;
|
|
4209
4209
|
return false !== ((_b = (_a2 = e15()) == null ? void 0 : _a2.notes) == null ? void 0 : _b.enabled);
|
|
4210
|
-
}), { provides: r3 } = useCapability(SelectionPlugin.id), { provides: n2 } = useCapability(AnnotationPlugin.id), { provides: l } = useCapability(
|
|
4210
|
+
}), { provides: r3 } = useCapability(SelectionPlugin.id), { provides: n2 } = useCapability(AnnotationPlugin.id), { provides: l } = useCapability(vt$1.id);
|
|
4211
4211
|
return computed(() => {
|
|
4212
4212
|
var _a2, _b, _c;
|
|
4213
|
-
if (false !== ((_a2 = s10.value) == null ? void 0 : _a2.enabled) && (
|
|
4214
|
-
const
|
|
4215
|
-
return (
|
|
4213
|
+
if (false !== ((_a2 = s10.value) == null ? void 0 : _a2.enabled) && (i3.value || o2.value || ((_c = (_b = s10.value) == null ? void 0 : _b.extraActions) == null ? void 0 : _c.length))) return (t2) => {
|
|
4214
|
+
const h2 = ts(t2.item);
|
|
4215
|
+
return (d2) => {
|
|
4216
4216
|
var _a3, _b2, _c2;
|
|
4217
|
-
return h("div",
|
|
4217
|
+
return h$1("div", d2.menuWrapperProps, h$1(fs, { placementAbove: !!((_a3 = d2.placement) == null ? void 0 : _a3.suggestTop), anchorHeight: d2.rect.size.height, hiddenBuiltinActions: (_b2 = s10.value) == null ? void 0 : _b2.hiddenBuiltinActions, extraActions: (_c2 = s10.value) == null ? void 0 : _c2.extraActions, onAction: (s11) => {
|
|
4218
4218
|
var _a4, _b3, _c3;
|
|
4219
4219
|
if ("highlight" !== s11 && "underline" !== s11 && "squiggly" !== s11 && "strikeout" !== s11) {
|
|
4220
4220
|
if ("note" === s11) {
|
|
4221
4221
|
if (!r3.value || !l.value || !o2.value) return;
|
|
4222
|
-
const e16 = r3.value.getHighlightRectsForPage(t2.item.localPageIndex,
|
|
4223
|
-
return void
|
|
4222
|
+
const e16 = r3.value.getHighlightRectsForPage(t2.item.localPageIndex, h2);
|
|
4223
|
+
return void as(r3.value.getSelectedText(h2), (a5) => {
|
|
4224
4224
|
var _a5;
|
|
4225
4225
|
(_a5 = l.value) == null ? void 0 : _a5.requestCreateFromSelection({ chapterId: t2.item.chapterId, localPageIndex: t2.item.localPageIndex, globalPageIndex: t2.item.globalPageIndex, globalPageNumber: t2.item.globalPageNumber, rectsPdfCoord: e16, selectedText: a5.join("\n") });
|
|
4226
4226
|
});
|
|
4227
4227
|
}
|
|
4228
4228
|
(_a4 = a4 == null ? void 0 : a4.onExtraAction) == null ? void 0 : _a4.call(a4, s11, t2);
|
|
4229
4229
|
} else {
|
|
4230
|
-
if (!r3.value || !n2.value || !
|
|
4231
|
-
Ce(
|
|
4230
|
+
if (!r3.value || !n2.value || !i3.value) return;
|
|
4231
|
+
Ce(h2, ms[s11], n2.value, r3.value, (_c3 = (_b3 = e15()) == null ? void 0 : _b3.markup) == null ? void 0 : _c3.styles);
|
|
4232
4232
|
}
|
|
4233
4233
|
} }));
|
|
4234
4234
|
};
|
|
@@ -4246,52 +4246,52 @@ const cs = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
4246
4246
|
if (f.value) {
|
|
4247
4247
|
const s11 = (function(e16) {
|
|
4248
4248
|
var _a3, _b, _c, _d;
|
|
4249
|
-
const t3 =
|
|
4250
|
-
return e16.isPlaceholder || !s12 ? null : h(
|
|
4249
|
+
const t3 = ts(e16), s12 = (_b = (_a3 = y.value) == null ? void 0 : _a3.getDocument(t3)) == null ? void 0 : _b.pages[e16.localPageIndex];
|
|
4250
|
+
return e16.isPlaceholder || !s12 ? null : h$1(is, { item: e16, pdfPageWidth: s12.size.width, pdfPageHeight: s12.size.height, cssPageWidth: e16.width, cssPageHeight: e16.height, hoverUi: (_d = (_c = a3.features) == null ? void 0 : _c.bookmarks) == null ? void 0 : _d.hover });
|
|
4251
4251
|
})(e15);
|
|
4252
4252
|
s11 && t2.push(s11);
|
|
4253
4253
|
}
|
|
4254
4254
|
const s10 = (_a2 = a3.renderPageOverlay) == null ? void 0 : _a2.call(a3, e15);
|
|
4255
|
-
if (s10 && t2.push(s10), t2.length) return h("div", t2);
|
|
4255
|
+
if (s10 && t2.push(s10), t2.length) return h$1("div", t2);
|
|
4256
4256
|
}
|
|
4257
|
-
return (t2, a4) => (openBlock(), createElementBlock("div", { ref_key: "hostRef", ref:
|
|
4257
|
+
return (t2, a4) => (openBlock(), createElementBlock("div", { ref_key: "hostRef", ref: i2, class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(ve$1)) }, [createVNode(unref(Ia), { class: normalizeClass(e14.className) }, { page: withCtx(({ item: t3 }) => {
|
|
4258
4258
|
var _a2, _b, _c, _d;
|
|
4259
|
-
return [createVNode(
|
|
4259
|
+
return [createVNode(ss, { item: t3, features: e14.features, "show-note-markers": u.value, "show-bookmark-markers": p2.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": b.value, "create-note": unref(o), "annotation-selection-menu": e14.annotationSelectionMenu, "redaction-selection-menu": e14.redactionSelectionMenu, "render-page-overlay": I }, 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"])];
|
|
4260
4260
|
}), _: 1 }, 8, ["class"]), renderSlot(t2.$slots, "default")], 6));
|
|
4261
|
-
} }),
|
|
4261
|
+
} }), bs = { key: 0, style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, width: "100%" } }, Ps = /* @__PURE__ */ defineComponent({ __name: "ChapterPdfViewer", props: { engine: {}, options: {}, editorOptions: {}, features: {}, className: {}, viewportClassName: {}, onExtraSelectionAction: { type: Function } }, setup(e14) {
|
|
4262
4262
|
const a3 = e14, s9 = computed(() => (function(e15) {
|
|
4263
|
-
if (e15.options) return
|
|
4263
|
+
if (e15.options) return oa(e15.options);
|
|
4264
4264
|
if (!e15.editorOptions) throw new Error("ChapterPdfViewer: 请传入 `options`(推荐),或同时传入 `editorOptions` 与 `features`");
|
|
4265
|
-
const t2 = Me(e15.features), { plugins: a4 } =
|
|
4265
|
+
const t2 = Me(e15.features), { plugins: a4 } = ta({ ...e15.editorOptions, features: t2 });
|
|
4266
4266
|
return { plugins: a4, features: t2, editorOptions: { ...e15.editorOptions, features: t2 } };
|
|
4267
4267
|
})({ engine: a3.engine, options: a3.options, editorOptions: a3.editorOptions, features: a3.features }));
|
|
4268
|
-
return (t2, a4) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(ve$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: s9.value.plugins }, { default: withCtx(({ pluginsReady: a5 }) => [a5 ? (openBlock(), createElementBlock("div",
|
|
4269
|
-
} }),
|
|
4268
|
+
return (t2, a4) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(ve$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: s9.value.plugins }, { default: withCtx(({ pluginsReady: a5 }) => [a5 ? (openBlock(), createElementBlock("div", bs, [renderSlot(t2.$slots, "prepend"), createVNode(vs, { class: normalizeClass(e14.viewportClassName), style: { flex: 1, minHeight: 0 }, features: s9.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));
|
|
4269
|
+
} }), ws = { class: "chapter-tree-row" }, ys = ["aria-expanded"], Cs = { key: 1, class: "chapter-tree-toggle-spacer", "aria-hidden": "" }, Is = { class: "chapter-tree-label" }, Ms = { class: "chapter-tree-meta" }, Ss = { key: 0 }, xs = (e14, t2) => {
|
|
4270
4270
|
const a3 = e14.__vccOpts || e14;
|
|
4271
|
-
for (const [s9,
|
|
4271
|
+
for (const [s9, i2] of t2) a3[s9] = i2;
|
|
4272
4272
|
return a3;
|
|
4273
|
-
},
|
|
4274
|
-
const s9 = { idle: "未加载", loading: "加载中", loaded: "已加载", closed: "已卸载", error: "失败", "password-required": "需密码" },
|
|
4275
|
-
return (t2, a3) => (openBlock(), createElementBlock("li", null, [createElementVNode("div",
|
|
4276
|
-
} }), [["__scopeId", "data-v-315bbf7a"]]),
|
|
4277
|
-
const o = e14, r2 = t2, { provides: h2 } = useCapability(
|
|
4278
|
-
function
|
|
4279
|
-
if (!
|
|
4273
|
+
}, ks = /* @__PURE__ */ xs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreeItem", props: { node: {}, depth: {}, activeChapterId: {}, chapterStatus: {} }, emits: ["select"], setup(e14) {
|
|
4274
|
+
const s9 = { idle: "未加载", loading: "加载中", loaded: "已加载", closed: "已卸载", error: "失败", "password-required": "需密码" }, i2 = e14, o = computed(() => i2.node.children ?? []), r2 = computed(() => o.value.length > 0), h2 = ref(i2.depth < 1), u = computed(() => i2.activeChapterId === i2.node.id), p2 = computed(() => i2.chapterStatus[i2.node.id] ?? "idle"), g2 = computed(() => !r2.value);
|
|
4275
|
+
return (t2, a3) => (openBlock(), createElementBlock("li", null, [createElementVNode("div", ws, [r2.value ? (openBlock(), createElementBlock("button", { key: 0, type: "button", class: "chapter-tree-toggle", "aria-expanded": h2.value, onClick: a3[0] || (a3[0] = (e15) => h2.value = !h2.value) }, toDisplayString(h2.value ? "▼" : "▶"), 9, ys)) : (openBlock(), createElementBlock("span", Cs)), createElementVNode("button", { type: "button", class: normalizeClass(["chapter-tree-btn", { "chapter-tree-btn-active": u.value }]), onClick: a3[1] || (a3[1] = (a4) => t2.$emit("select", e14.node.id)) }, [createElementVNode("div", Is, toDisplayString(e14.node.title), 1), createElementVNode("div", Ms, [createElementVNode("span", null, " 第 " + toDisplayString(e14.node.startPage) + toDisplayString(e14.node.endPage !== e14.node.startPage ? `–${e14.node.endPage}` : "") + " 页 ", 1), g2.value ? (openBlock(), createElementBlock("span", Ss, toDisplayString(s9[p2.value]), 1)) : createCommentVNode("", true)])], 2)]), r2.value && h2.value ? (openBlock(), createBlock(Ls, { key: 0, nodes: o.value, depth: e14.depth + 1, "active-chapter-id": e14.activeChapterId, "chapter-status": e14.chapterStatus, onSelect: a3[2] || (a3[2] = (e15) => t2.$emit("select", e15)) }, null, 8, ["nodes", "depth", "active-chapter-id", "chapter-status"])) : createCommentVNode("", true)]));
|
|
4276
|
+
} }), [["__scopeId", "data-v-315bbf7a"]]), Ls = /* @__PURE__ */ xs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreeList", props: { nodes: {}, depth: {}, activeChapterId: {}, chapterStatus: {} }, emits: ["select"], setup: (e14) => (t2, a3) => (openBlock(), createElementBlock("ul", { class: "chapter-tree-list", style: normalizeStyle({ marginLeft: e14.depth > 0 ? "12px" : "0" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(e14.nodes, (s9) => (openBlock(), createBlock(ks, { key: s9.id, node: s9, depth: e14.depth, "active-chapter-id": e14.activeChapterId, "chapter-status": e14.chapterStatus, onSelect: a3[0] || (a3[0] = (e15) => t2.$emit("select", e15)) }, null, 8, ["node", "depth", "active-chapter-id", "chapter-status"]))), 128))], 4)) }), [["__scopeId", "data-v-eb742e4f"]]), $s = { class: "chapter-tree" }, zs = { class: "chapter-tree-nav", "aria-label": "章节目录" }, Ts = /* @__PURE__ */ xs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreePanel", props: { tree: {}, activeChapterId: {} }, emits: ["active-chapter-change"], setup(e14, { emit: t2 }) {
|
|
4277
|
+
const o = e14, r2 = t2, { provides: h2 } = useCapability(Xe.id), { provides: d2 } = useCapability(Ee.id), u = ref({});
|
|
4278
|
+
function p2() {
|
|
4279
|
+
if (!d2.value) return;
|
|
4280
4280
|
const e15 = {}, t3 = (a3) => {
|
|
4281
4281
|
var _a2;
|
|
4282
|
-
for (const s9 of a3) e15[s9.id] =
|
|
4282
|
+
for (const s9 of a3) e15[s9.id] = d2.value.getChapterStatus(s9.id), ((_a2 = s9.children) == null ? void 0 : _a2.length) && t3(s9.children);
|
|
4283
4283
|
};
|
|
4284
4284
|
t3(o.tree), u.value = e15;
|
|
4285
4285
|
}
|
|
4286
|
-
watch([
|
|
4287
|
-
let
|
|
4286
|
+
watch([d2, () => o.tree], p2, { immediate: true });
|
|
4287
|
+
let g2 = null;
|
|
4288
4288
|
function f(e15) {
|
|
4289
4289
|
var _a2;
|
|
4290
4290
|
r2("active-chapter-change", e15), (_a2 = h2.value) == null ? void 0 : _a2.scrollToChapter(e15);
|
|
4291
4291
|
}
|
|
4292
|
-
return watch(
|
|
4293
|
-
|
|
4294
|
-
}, { immediate: true }), onBeforeUnmount(() =>
|
|
4292
|
+
return watch(d2, (e15) => {
|
|
4293
|
+
g2 == null ? void 0 : g2(), g2 = e15 ? e15.onChapterStatusChange(p2) : null;
|
|
4294
|
+
}, { immediate: true }), onBeforeUnmount(() => g2 == null ? void 0 : g2()), (t3, a3) => (openBlock(), createElementBlock("aside", $s, [a3[0] || (a3[0] = createElementVNode("h2", { class: "chapter-tree-title" }, "章节目录", -1)), createElementVNode("nav", zs, [createVNode(Ls, { nodes: e14.tree, depth: 0, "active-chapter-id": e14.activeChapterId, "chapter-status": u.value, onSelect: f }, null, 8, ["nodes", "active-chapter-id", "chapter-status"])])]));
|
|
4295
4295
|
} }), [["__scopeId", "data-v-d7a0838d"]]);
|
|
4296
4296
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4297
4297
|
__name: "ChapterPdfViewer",
|
|
@@ -4305,7 +4305,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4305
4305
|
},
|
|
4306
4306
|
setup(__props) {
|
|
4307
4307
|
return (_ctx, _cache) => {
|
|
4308
|
-
return openBlock(), createBlock(unref(
|
|
4308
|
+
return openBlock(), createBlock(unref(Ps), normalizeProps(guardReactiveProps(_ctx.$props)), createSlots({
|
|
4309
4309
|
default: withCtx(() => [
|
|
4310
4310
|
renderSlot(_ctx.$slots, "default")
|
|
4311
4311
|
]),
|
|
@@ -4323,47 +4323,47 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4323
4323
|
}
|
|
4324
4324
|
});
|
|
4325
4325
|
function e13(e22) {
|
|
4326
|
-
const t2 = [],
|
|
4327
|
-
for (const
|
|
4328
|
-
|
|
4329
|
-
const [e32,
|
|
4330
|
-
if (e32 >
|
|
4326
|
+
const t2 = [], n2 = /* @__PURE__ */ new Set();
|
|
4327
|
+
for (const r2 of e22.chapters) {
|
|
4328
|
+
n2.has(r2.chapterId) && t2.push(`Duplicate chapterId: ${r2.chapterId}`), n2.add(r2.chapterId);
|
|
4329
|
+
const [e32, s22] = r2.globalPageRange, [a22, o] = r2.localPageRange;
|
|
4330
|
+
if (e32 > s22 && t2.push(`${r2.chapterId}: invalid globalPageRange [${e32},${s22}]`), a22 > o && t2.push(`${r2.chapterId}: invalid localPageRange [${a22},${o}]`), s22 - e32 !== o - a22 && t2.push(`${r2.chapterId}: page-count mismatch (global ${s22 - e32 + 1} vs local ${o - a22 + 1})`), r2.ownedGlobalPages) for (const n3 of r2.ownedGlobalPages) (n3 < e32 || n3 > s22) && t2.push(`${r2.chapterId}: ownedGlobalPages contains ${n3} outside range`);
|
|
4331
4331
|
}
|
|
4332
4332
|
return t2;
|
|
4333
4333
|
}
|
|
4334
|
-
const t = { kind: "first-wins" };
|
|
4335
|
-
function
|
|
4336
|
-
const
|
|
4334
|
+
const t$1 = { kind: "first-wins" };
|
|
4335
|
+
function n(e22, n2 = t$1) {
|
|
4336
|
+
const s22 = /* @__PURE__ */ new Map();
|
|
4337
4337
|
for (const t2 of e22.chapters) {
|
|
4338
|
-
const [e32,
|
|
4339
|
-
for (let
|
|
4340
|
-
const e42 =
|
|
4341
|
-
e42 ? e42.push(t2) :
|
|
4338
|
+
const [e32, n3] = t2.globalPageRange;
|
|
4339
|
+
for (let r2 = e32; r2 <= n3; r2++) {
|
|
4340
|
+
const e42 = s22.get(r2);
|
|
4341
|
+
e42 ? e42.push(t2) : s22.set(r2, [t2]);
|
|
4342
4342
|
}
|
|
4343
4343
|
}
|
|
4344
|
-
const
|
|
4345
|
-
for (const [t2, o] of
|
|
4346
|
-
return
|
|
4344
|
+
const a22 = /* @__PURE__ */ new Map();
|
|
4345
|
+
for (const [t2, o] of s22) a22.set(t2, r(t2, o, n2));
|
|
4346
|
+
return a22;
|
|
4347
4347
|
}
|
|
4348
|
-
function
|
|
4348
|
+
function r(e22, t2, n2) {
|
|
4349
4349
|
if (1 === t2.length) return t2[0].chapterId;
|
|
4350
|
-
switch (
|
|
4350
|
+
switch (n2.kind) {
|
|
4351
4351
|
case "first-wins":
|
|
4352
4352
|
return t2[0].chapterId;
|
|
4353
4353
|
case "last-wins":
|
|
4354
4354
|
return t2[t2.length - 1].chapterId;
|
|
4355
4355
|
case "explicit": {
|
|
4356
|
-
const
|
|
4356
|
+
const n3 = t2.find((t3) => {
|
|
4357
4357
|
var _a2;
|
|
4358
4358
|
return (_a2 = t3.ownedGlobalPages) == null ? void 0 : _a2.includes(e22);
|
|
4359
4359
|
});
|
|
4360
|
-
return
|
|
4360
|
+
return n3 ? n3.chapterId : t2[0].chapterId;
|
|
4361
4361
|
}
|
|
4362
4362
|
case "custom":
|
|
4363
|
-
return
|
|
4363
|
+
return n2.resolve(e22, t2);
|
|
4364
4364
|
}
|
|
4365
4365
|
}
|
|
4366
|
-
class
|
|
4366
|
+
class s {
|
|
4367
4367
|
constructor(e22) {
|
|
4368
4368
|
this._pages = e22, this._byChapter = /* @__PURE__ */ new Map(), this._byGlobalNumber = /* @__PURE__ */ new Map();
|
|
4369
4369
|
for (const t2 of e22) {
|
|
@@ -4385,8 +4385,8 @@ class n {
|
|
|
4385
4385
|
return this._byGlobalNumber.get(e22) ?? null;
|
|
4386
4386
|
}
|
|
4387
4387
|
toGlobal(e22, t2) {
|
|
4388
|
-
const
|
|
4389
|
-
return
|
|
4388
|
+
const n2 = this._byChapter.get(e22);
|
|
4389
|
+
return n2 ? n2.find((e32) => e32.localPageIndex === t2) ?? null : null;
|
|
4390
4390
|
}
|
|
4391
4391
|
pagesOfChapter(e22) {
|
|
4392
4392
|
return this._byChapter.get(e22) ?? [];
|
|
@@ -4397,25 +4397,25 @@ class n {
|
|
|
4397
4397
|
return t2 ? this._pages.indexOf(t2) : -1;
|
|
4398
4398
|
}
|
|
4399
4399
|
}
|
|
4400
|
-
function
|
|
4401
|
-
const
|
|
4400
|
+
function a(e22, r2 = t$1) {
|
|
4401
|
+
const a22 = n(e22, r2), o = /* @__PURE__ */ new Map();
|
|
4402
4402
|
for (const t2 of e22.chapters) o.set(t2.chapterId, t2);
|
|
4403
|
-
const
|
|
4404
|
-
let
|
|
4405
|
-
for (const t2 of
|
|
4406
|
-
const e32 =
|
|
4407
|
-
if (!
|
|
4408
|
-
const [
|
|
4409
|
-
|
|
4410
|
-
}
|
|
4411
|
-
return new
|
|
4403
|
+
const c = Array.from(a22.keys()).sort((e32, t2) => e32 - t2), l = [];
|
|
4404
|
+
let i2 = 0;
|
|
4405
|
+
for (const t2 of c) {
|
|
4406
|
+
const e32 = a22.get(t2), n2 = o.get(e32);
|
|
4407
|
+
if (!n2) continue;
|
|
4408
|
+
const [r3] = n2.globalPageRange, [s22] = n2.localPageRange, c2 = s22 + (t2 - r3);
|
|
4409
|
+
l.push({ globalPageIndex: i2++, globalPageNumber: t2, chapterId: e32, localPageIndex: c2 });
|
|
4410
|
+
}
|
|
4411
|
+
return new s(l);
|
|
4412
4412
|
}
|
|
4413
4413
|
const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
4414
4414
|
constructor(id, registry) {
|
|
4415
4415
|
super(id, registry);
|
|
4416
4416
|
this.statusChange$ = createBehaviorEmitter();
|
|
4417
4417
|
this.manifestChange$ = createEmitter();
|
|
4418
|
-
this.overlapStrategy = t;
|
|
4418
|
+
this.overlapStrategy = t$1;
|
|
4419
4419
|
this.chapterStatus = /* @__PURE__ */ new Map();
|
|
4420
4420
|
this.chapterLastUsed = /* @__PURE__ */ new Map();
|
|
4421
4421
|
this.passwordAttempts = /* @__PURE__ */ new Map();
|
|
@@ -4427,7 +4427,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
4427
4427
|
async initialize(config) {
|
|
4428
4428
|
this.config = config;
|
|
4429
4429
|
this.passwordProvider = config.passwordProvider;
|
|
4430
|
-
this.overlapStrategy = config.overlapStrategy ?? t;
|
|
4430
|
+
this.overlapStrategy = config.overlapStrategy ?? t$1;
|
|
4431
4431
|
this.documentManagerUnsubs.push(
|
|
4432
4432
|
this.documentManager.provides().onDocumentOpened((docState) => {
|
|
4433
4433
|
if (!this.isOwnedChapter(docState.id)) return;
|
|
@@ -4498,7 +4498,7 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
4498
4498
|
}
|
|
4499
4499
|
}
|
|
4500
4500
|
this.manifest = manifest2;
|
|
4501
|
-
this.virtualPageMap =
|
|
4501
|
+
this.virtualPageMap = a(manifest2, this.overlapStrategy);
|
|
4502
4502
|
this.manifestChange$.emit({ manifest: manifest2, map: this.virtualPageMap });
|
|
4503
4503
|
this.eagerPrefetchFromManifest();
|
|
4504
4504
|
}
|
|
@@ -4508,8 +4508,8 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
4508
4508
|
if (prefetch <= 0 || this.manifest.chapters.length === 0) return;
|
|
4509
4509
|
const now = Date.now();
|
|
4510
4510
|
const count = Math.min(prefetch, this.manifest.chapters.length);
|
|
4511
|
-
for (let
|
|
4512
|
-
const chapterId = this.manifest.chapters[
|
|
4511
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
4512
|
+
const chapterId = this.manifest.chapters[i2].chapterId;
|
|
4513
4513
|
this.chapterLastUsed.set(chapterId, now);
|
|
4514
4514
|
const st3 = this.chapterStatus.get(chapterId) ?? "idle";
|
|
4515
4515
|
if (st3 === "idle" || st3 === "closed" || st3 === "error") {
|
|
@@ -4537,14 +4537,14 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
|
|
|
4537
4537
|
const orderedIds = this.manifest.chapters.map((c) => c.chapterId);
|
|
4538
4538
|
const neededIdx = /* @__PURE__ */ new Set();
|
|
4539
4539
|
for (const cid of visibleChapters) {
|
|
4540
|
-
const
|
|
4541
|
-
if (
|
|
4542
|
-
for (let k2 =
|
|
4540
|
+
const i2 = orderedIds.indexOf(cid);
|
|
4541
|
+
if (i2 === -1) continue;
|
|
4542
|
+
for (let k2 = i2 - prefetch; k2 <= i2 + prefetch; k2++) {
|
|
4543
4543
|
if (k2 >= 0 && k2 < orderedIds.length) neededIdx.add(k2);
|
|
4544
4544
|
}
|
|
4545
4545
|
}
|
|
4546
4546
|
const needed = /* @__PURE__ */ new Set();
|
|
4547
|
-
for (const
|
|
4547
|
+
for (const i2 of neededIdx) needed.add(orderedIds[i2]);
|
|
4548
4548
|
for (const cid of needed) {
|
|
4549
4549
|
this.chapterLastUsed.set(cid, now);
|
|
4550
4550
|
const st3 = this.chapterStatus.get(cid) ?? "idle";
|
|
@@ -4804,12 +4804,12 @@ function T(t2, e14 = k) {
|
|
|
4804
4804
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
4805
4805
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
4806
4806
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
4807
|
-
let
|
|
4807
|
+
let i2 = 0;
|
|
4808
4808
|
for (const n2 of o) {
|
|
4809
4809
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
4810
4810
|
if (!e15) continue;
|
|
4811
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
4812
|
-
r2.push({ globalPageIndex:
|
|
4811
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
4812
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
4813
4813
|
}
|
|
4814
4814
|
return new $(r2);
|
|
4815
4815
|
}
|
|
@@ -4844,8 +4844,8 @@ const D = class s2 extends BasePlugin {
|
|
|
4844
4844
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
4845
4845
|
for (const s9 of t3.chapters) {
|
|
4846
4846
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
4847
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
4848
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
4847
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
4848
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
4849
4849
|
}
|
|
4850
4850
|
return e15;
|
|
4851
4851
|
})(t2);
|
|
@@ -4885,9 +4885,9 @@ const D = class s2 extends BasePlugin {
|
|
|
4885
4885
|
const t3 = o.indexOf(n2);
|
|
4886
4886
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
4887
4887
|
}
|
|
4888
|
-
const
|
|
4889
|
-
for (const n2 of r2)
|
|
4890
|
-
for (const n2 of
|
|
4888
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
4889
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
4890
|
+
for (const n2 of i2) {
|
|
4891
4891
|
this.chapterLastUsed.set(n2, e14);
|
|
4892
4892
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
4893
4893
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -4937,8 +4937,8 @@ const D = class s2 extends BasePlugin {
|
|
|
4937
4937
|
const a3 = t2.chapterId;
|
|
4938
4938
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
4939
4939
|
try {
|
|
4940
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
4941
|
-
|
|
4940
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
4941
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
4942
4942
|
});
|
|
4943
4943
|
return await new Promise((t3, e15) => {
|
|
4944
4944
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -4969,15 +4969,15 @@ const D = class s2 extends BasePlugin {
|
|
|
4969
4969
|
if (!o) return;
|
|
4970
4970
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
4971
4971
|
this.passwordAttempts.set(t2, r2);
|
|
4972
|
-
let
|
|
4972
|
+
let i2 = null;
|
|
4973
4973
|
try {
|
|
4974
|
-
|
|
4974
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
4975
4975
|
} catch (n2) {
|
|
4976
4976
|
this.logger.error(s2.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
4977
4977
|
}
|
|
4978
|
-
if (!
|
|
4978
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
4979
4979
|
this.updateStatus(t2, "loading");
|
|
4980
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
4980
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
4981
4981
|
}, () => {
|
|
4982
4982
|
});
|
|
4983
4983
|
}
|
|
@@ -5062,12 +5062,12 @@ function E(t2, e14 = N) {
|
|
|
5062
5062
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
5063
5063
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
5064
5064
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
5065
|
-
let
|
|
5065
|
+
let i2 = 0;
|
|
5066
5066
|
for (const n2 of o) {
|
|
5067
5067
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
5068
5068
|
if (!e15) continue;
|
|
5069
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
5070
|
-
r2.push({ globalPageIndex:
|
|
5069
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
5070
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
5071
5071
|
}
|
|
5072
5072
|
return new F(r2);
|
|
5073
5073
|
}
|
|
@@ -5102,8 +5102,8 @@ const U = class s3 extends BasePlugin {
|
|
|
5102
5102
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
5103
5103
|
for (const s9 of t3.chapters) {
|
|
5104
5104
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
5105
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
5106
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
5105
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
5106
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
5107
5107
|
}
|
|
5108
5108
|
return e15;
|
|
5109
5109
|
})(t2);
|
|
@@ -5143,9 +5143,9 @@ const U = class s3 extends BasePlugin {
|
|
|
5143
5143
|
const t3 = o.indexOf(n2);
|
|
5144
5144
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
5145
5145
|
}
|
|
5146
|
-
const
|
|
5147
|
-
for (const n2 of r2)
|
|
5148
|
-
for (const n2 of
|
|
5146
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
5147
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
5148
|
+
for (const n2 of i2) {
|
|
5149
5149
|
this.chapterLastUsed.set(n2, e14);
|
|
5150
5150
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
5151
5151
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -5195,8 +5195,8 @@ const U = class s3 extends BasePlugin {
|
|
|
5195
5195
|
const a3 = t2.chapterId;
|
|
5196
5196
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
5197
5197
|
try {
|
|
5198
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
5199
|
-
|
|
5198
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
5199
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
5200
5200
|
});
|
|
5201
5201
|
return await new Promise((t3, e15) => {
|
|
5202
5202
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -5227,15 +5227,15 @@ const U = class s3 extends BasePlugin {
|
|
|
5227
5227
|
if (!o) return;
|
|
5228
5228
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
5229
5229
|
this.passwordAttempts.set(t2, r2);
|
|
5230
|
-
let
|
|
5230
|
+
let i2 = null;
|
|
5231
5231
|
try {
|
|
5232
|
-
|
|
5232
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
5233
5233
|
} catch (n2) {
|
|
5234
5234
|
this.logger.error(s3.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
5235
5235
|
}
|
|
5236
|
-
if (!
|
|
5236
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
5237
5237
|
this.updateStatus(t2, "loading");
|
|
5238
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
5238
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
5239
5239
|
}, () => {
|
|
5240
5240
|
});
|
|
5241
5241
|
}
|
|
@@ -5348,12 +5348,12 @@ const q = class extends BasePlugin {
|
|
|
5348
5348
|
if (!this.virtualPageMap) return;
|
|
5349
5349
|
const s9 = this.documentManager.provides().getDocument(t2), o = this.virtualPageMap.pagesOfChapter(t2);
|
|
5350
5350
|
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === o.length) return void (e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1)));
|
|
5351
|
-
const r2 = this.getChapterDocumentScale(t2),
|
|
5351
|
+
const r2 = this.getChapterDocumentScale(t2), i2 = [];
|
|
5352
5352
|
for (const n2 of o) {
|
|
5353
5353
|
const t3 = s9.pages[n2.localPageIndex];
|
|
5354
|
-
(null == t3 ? void 0 : t3.size) &&
|
|
5354
|
+
(null == t3 ? void 0 : t3.size) && i2.push({ localPageIndex: n2.localPageIndex, width: t3.size.width * r2, height: t3.size.height * r2 });
|
|
5355
5355
|
}
|
|
5356
|
-
0 !==
|
|
5356
|
+
0 !== i2.length ? this.applyChapterPageSizes(t2, i2) : e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1));
|
|
5357
5357
|
}
|
|
5358
5358
|
onScaleChanged(t2) {
|
|
5359
5359
|
const e14 = this.coreState.core.documents[t2];
|
|
@@ -5387,13 +5387,13 @@ const q = class extends BasePlugin {
|
|
|
5387
5387
|
o++;
|
|
5388
5388
|
}
|
|
5389
5389
|
const r2 = [];
|
|
5390
|
-
let
|
|
5390
|
+
let i2 = s9, n2 = -1;
|
|
5391
5391
|
for (let h2 = s9; h2 < o; h2++) {
|
|
5392
5392
|
r2.push(h2);
|
|
5393
5393
|
const t3 = this.offsets[h2], s10 = t3 + this.getPageSize(h2).height, o2 = Math.max(0, Math.min(s10, a3) - Math.max(t3, e14));
|
|
5394
|
-
o2 > n2 && (n2 = o2,
|
|
5394
|
+
o2 > n2 && (n2 = o2, i2 = h2);
|
|
5395
5395
|
}
|
|
5396
|
-
this.currentVisible = r2, this.currentGlobalPageIndex =
|
|
5396
|
+
this.currentVisible = r2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: r2, currentGlobalPageIndex: i2 }), this.chapterManager.provides().setVisibleGlobalPages(r2), this.layoutChange$.emit(this.computeLayout());
|
|
5397
5397
|
}
|
|
5398
5398
|
findFirstVisibleIndex(t2) {
|
|
5399
5399
|
let e14 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
@@ -5423,10 +5423,10 @@ const q = class extends BasePlugin {
|
|
|
5423
5423
|
if (!this.viewportEl || t2 < 0 || t2 >= this.offsets.length || !this.virtualPageMap) return;
|
|
5424
5424
|
const o = (null == a3 ? void 0 : a3.marginTop) ?? 80, r2 = this.virtualPageMap.atIndex(t2);
|
|
5425
5425
|
if (!r2) return void this.scrollToIndex(t2, a3);
|
|
5426
|
-
const
|
|
5427
|
-
if (!
|
|
5428
|
-
const h2 =
|
|
5429
|
-
this.viewportEl.scrollTo({ top: Math.max(0,
|
|
5426
|
+
const i2 = this.pageSizes.get(t2), n2 = null == (s9 = this.documentManager.provides().getDocument(r2.chapterId)) ? void 0 : s9.pages[r2.localPageIndex];
|
|
5427
|
+
if (!i2 || !n2) return void this.scrollToIndex(t2, a3);
|
|
5428
|
+
const h2 = i2.height / n2.size.height, d2 = (this.offsets[t2] ?? 0) + e14 * h2 - o;
|
|
5429
|
+
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
5430
5430
|
}
|
|
5431
5431
|
scrollToChapter(t2, e14) {
|
|
5432
5432
|
if (!this.virtualPageMap) return;
|
|
@@ -5509,12 +5509,12 @@ function Y(t2, e14 = J) {
|
|
|
5509
5509
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
5510
5510
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
5511
5511
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
5512
|
-
let
|
|
5512
|
+
let i2 = 0;
|
|
5513
5513
|
for (const n2 of o) {
|
|
5514
5514
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
5515
5515
|
if (!e15) continue;
|
|
5516
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
5517
|
-
r2.push({ globalPageIndex:
|
|
5516
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
5517
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
5518
5518
|
}
|
|
5519
5519
|
return new Q(r2);
|
|
5520
5520
|
}
|
|
@@ -5549,8 +5549,8 @@ const X = class s4 extends BasePlugin {
|
|
|
5549
5549
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
5550
5550
|
for (const s9 of t3.chapters) {
|
|
5551
5551
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
5552
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
5553
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
5552
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
5553
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
5554
5554
|
}
|
|
5555
5555
|
return e15;
|
|
5556
5556
|
})(t2);
|
|
@@ -5590,9 +5590,9 @@ const X = class s4 extends BasePlugin {
|
|
|
5590
5590
|
const t3 = o.indexOf(n2);
|
|
5591
5591
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
5592
5592
|
}
|
|
5593
|
-
const
|
|
5594
|
-
for (const n2 of r2)
|
|
5595
|
-
for (const n2 of
|
|
5593
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
5594
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
5595
|
+
for (const n2 of i2) {
|
|
5596
5596
|
this.chapterLastUsed.set(n2, e14);
|
|
5597
5597
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
5598
5598
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -5642,8 +5642,8 @@ const X = class s4 extends BasePlugin {
|
|
|
5642
5642
|
const a3 = t2.chapterId;
|
|
5643
5643
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
5644
5644
|
try {
|
|
5645
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
5646
|
-
|
|
5645
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
5646
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
5647
5647
|
});
|
|
5648
5648
|
return await new Promise((t3, e15) => {
|
|
5649
5649
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -5674,15 +5674,15 @@ const X = class s4 extends BasePlugin {
|
|
|
5674
5674
|
if (!o) return;
|
|
5675
5675
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
5676
5676
|
this.passwordAttempts.set(t2, r2);
|
|
5677
|
-
let
|
|
5677
|
+
let i2 = null;
|
|
5678
5678
|
try {
|
|
5679
|
-
|
|
5679
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
5680
5680
|
} catch (n2) {
|
|
5681
5681
|
this.logger.error(s4.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
5682
5682
|
}
|
|
5683
|
-
if (!
|
|
5683
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
5684
5684
|
this.updateStatus(t2, "loading");
|
|
5685
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
5685
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
5686
5686
|
}, () => {
|
|
5687
5687
|
});
|
|
5688
5688
|
}
|
|
@@ -5767,12 +5767,12 @@ function st2(t2, e14 = tt) {
|
|
|
5767
5767
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
5768
5768
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
5769
5769
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
5770
|
-
let
|
|
5770
|
+
let i2 = 0;
|
|
5771
5771
|
for (const n2 of o) {
|
|
5772
5772
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
5773
5773
|
if (!e15) continue;
|
|
5774
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
5775
|
-
r2.push({ globalPageIndex:
|
|
5774
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
5775
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
5776
5776
|
}
|
|
5777
5777
|
return new at(r2);
|
|
5778
5778
|
}
|
|
@@ -5807,8 +5807,8 @@ const ot = class s5 extends BasePlugin {
|
|
|
5807
5807
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
5808
5808
|
for (const s9 of t3.chapters) {
|
|
5809
5809
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
5810
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
5811
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
5810
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
5811
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
5812
5812
|
}
|
|
5813
5813
|
return e15;
|
|
5814
5814
|
})(t2);
|
|
@@ -5848,9 +5848,9 @@ const ot = class s5 extends BasePlugin {
|
|
|
5848
5848
|
const t3 = o.indexOf(n2);
|
|
5849
5849
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
5850
5850
|
}
|
|
5851
|
-
const
|
|
5852
|
-
for (const n2 of r2)
|
|
5853
|
-
for (const n2 of
|
|
5851
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
5852
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
5853
|
+
for (const n2 of i2) {
|
|
5854
5854
|
this.chapterLastUsed.set(n2, e14);
|
|
5855
5855
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
5856
5856
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -5900,8 +5900,8 @@ const ot = class s5 extends BasePlugin {
|
|
|
5900
5900
|
const a3 = t2.chapterId;
|
|
5901
5901
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
5902
5902
|
try {
|
|
5903
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
5904
|
-
|
|
5903
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
5904
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
5905
5905
|
});
|
|
5906
5906
|
return await new Promise((t3, e15) => {
|
|
5907
5907
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -5932,15 +5932,15 @@ const ot = class s5 extends BasePlugin {
|
|
|
5932
5932
|
if (!o) return;
|
|
5933
5933
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
5934
5934
|
this.passwordAttempts.set(t2, r2);
|
|
5935
|
-
let
|
|
5935
|
+
let i2 = null;
|
|
5936
5936
|
try {
|
|
5937
|
-
|
|
5937
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
5938
5938
|
} catch (n2) {
|
|
5939
5939
|
this.logger.error(s5.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
5940
5940
|
}
|
|
5941
|
-
if (!
|
|
5941
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
5942
5942
|
this.updateStatus(t2, "loading");
|
|
5943
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
5943
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
5944
5944
|
}, () => {
|
|
5945
5945
|
});
|
|
5946
5946
|
}
|
|
@@ -6053,12 +6053,12 @@ const nt = class extends BasePlugin {
|
|
|
6053
6053
|
if (!this.virtualPageMap) return;
|
|
6054
6054
|
const s9 = this.documentManager.provides().getDocument(t2), o = this.virtualPageMap.pagesOfChapter(t2);
|
|
6055
6055
|
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === o.length) return void (e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1)));
|
|
6056
|
-
const r2 = this.getChapterDocumentScale(t2),
|
|
6056
|
+
const r2 = this.getChapterDocumentScale(t2), i2 = [];
|
|
6057
6057
|
for (const n2 of o) {
|
|
6058
6058
|
const t3 = s9.pages[n2.localPageIndex];
|
|
6059
|
-
(null == t3 ? void 0 : t3.size) &&
|
|
6059
|
+
(null == t3 ? void 0 : t3.size) && i2.push({ localPageIndex: n2.localPageIndex, width: t3.size.width * r2, height: t3.size.height * r2 });
|
|
6060
6060
|
}
|
|
6061
|
-
0 !==
|
|
6061
|
+
0 !== i2.length ? this.applyChapterPageSizes(t2, i2) : e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1));
|
|
6062
6062
|
}
|
|
6063
6063
|
onScaleChanged(t2) {
|
|
6064
6064
|
const e14 = this.coreState.core.documents[t2];
|
|
@@ -6092,13 +6092,13 @@ const nt = class extends BasePlugin {
|
|
|
6092
6092
|
o++;
|
|
6093
6093
|
}
|
|
6094
6094
|
const r2 = [];
|
|
6095
|
-
let
|
|
6095
|
+
let i2 = s9, n2 = -1;
|
|
6096
6096
|
for (let h2 = s9; h2 < o; h2++) {
|
|
6097
6097
|
r2.push(h2);
|
|
6098
6098
|
const t3 = this.offsets[h2], s10 = t3 + this.getPageSize(h2).height, o2 = Math.max(0, Math.min(s10, a3) - Math.max(t3, e14));
|
|
6099
|
-
o2 > n2 && (n2 = o2,
|
|
6099
|
+
o2 > n2 && (n2 = o2, i2 = h2);
|
|
6100
6100
|
}
|
|
6101
|
-
this.currentVisible = r2, this.currentGlobalPageIndex =
|
|
6101
|
+
this.currentVisible = r2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: r2, currentGlobalPageIndex: i2 }), this.chapterManager.provides().setVisibleGlobalPages(r2), this.layoutChange$.emit(this.computeLayout());
|
|
6102
6102
|
}
|
|
6103
6103
|
findFirstVisibleIndex(t2) {
|
|
6104
6104
|
let e14 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
@@ -6128,10 +6128,10 @@ const nt = class extends BasePlugin {
|
|
|
6128
6128
|
if (!this.viewportEl || t2 < 0 || t2 >= this.offsets.length || !this.virtualPageMap) return;
|
|
6129
6129
|
const o = (null == a3 ? void 0 : a3.marginTop) ?? 80, r2 = this.virtualPageMap.atIndex(t2);
|
|
6130
6130
|
if (!r2) return void this.scrollToIndex(t2, a3);
|
|
6131
|
-
const
|
|
6132
|
-
if (!
|
|
6133
|
-
const h2 =
|
|
6134
|
-
this.viewportEl.scrollTo({ top: Math.max(0,
|
|
6131
|
+
const i2 = this.pageSizes.get(t2), n2 = null == (s9 = this.documentManager.provides().getDocument(r2.chapterId)) ? void 0 : s9.pages[r2.localPageIndex];
|
|
6132
|
+
if (!i2 || !n2) return void this.scrollToIndex(t2, a3);
|
|
6133
|
+
const h2 = i2.height / n2.size.height, d2 = (this.offsets[t2] ?? 0) + e14 * h2 - o;
|
|
6134
|
+
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
6135
6135
|
}
|
|
6136
6136
|
scrollToChapter(t2, e14) {
|
|
6137
6137
|
if (!this.virtualPageMap) return;
|
|
@@ -6145,10 +6145,10 @@ const nt = class extends BasePlugin {
|
|
|
6145
6145
|
}
|
|
6146
6146
|
};
|
|
6147
6147
|
nt.id = "chapter-scroll";
|
|
6148
|
-
let
|
|
6148
|
+
let ht2 = nt;
|
|
6149
6149
|
const dt = class s6 extends BasePlugin {
|
|
6150
6150
|
constructor(t2, s9) {
|
|
6151
|
-
super(t2, s9), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(
|
|
6151
|
+
super(t2, s9), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(ht2.id), this.chapterManager = this.registry.getPlugin(Z.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
6152
6152
|
}
|
|
6153
6153
|
async initialize(t2) {
|
|
6154
6154
|
if (this.config = t2, t2.callbacks.loadNotes) try {
|
|
@@ -6203,8 +6203,8 @@ const dt = class s6 extends BasePlugin {
|
|
|
6203
6203
|
let o = null;
|
|
6204
6204
|
try {
|
|
6205
6205
|
o = await a3(e14);
|
|
6206
|
-
} catch (
|
|
6207
|
-
return this.logger.error(s6.id, "OnCreateNote", "Callback failed",
|
|
6206
|
+
} catch (i2) {
|
|
6207
|
+
return this.logger.error(s6.id, "OnCreateNote", "Callback failed", i2), null;
|
|
6208
6208
|
}
|
|
6209
6209
|
if (!o) return null;
|
|
6210
6210
|
const r2 = { ...e14, noteId: o.noteId };
|
|
@@ -6225,13 +6225,13 @@ const dt = class s6 extends BasePlugin {
|
|
|
6225
6225
|
var a3, o;
|
|
6226
6226
|
const r2 = this.notes.get(t2);
|
|
6227
6227
|
if (!r2) return;
|
|
6228
|
-
const
|
|
6228
|
+
const i2 = { ...r2, content: e14 };
|
|
6229
6229
|
try {
|
|
6230
|
-
await (null == (o = (a3 = this.config.callbacks).onUpdateNote) ? void 0 : o.call(a3,
|
|
6230
|
+
await (null == (o = (a3 = this.config.callbacks).onUpdateNote) ? void 0 : o.call(a3, i2));
|
|
6231
6231
|
} catch (n2) {
|
|
6232
6232
|
return void this.logger.error(s6.id, "OnUpdateNote", "Callback failed", n2);
|
|
6233
6233
|
}
|
|
6234
|
-
this.notes.set(t2,
|
|
6234
|
+
this.notes.set(t2, i2), this.notesChange$.emit(this.listAll());
|
|
6235
6235
|
}
|
|
6236
6236
|
async scrollToNote(t2) {
|
|
6237
6237
|
var e14;
|
|
@@ -6254,7 +6254,7 @@ const dt = class s6 extends BasePlugin {
|
|
|
6254
6254
|
}
|
|
6255
6255
|
};
|
|
6256
6256
|
dt.id = "note";
|
|
6257
|
-
let
|
|
6257
|
+
let lt = dt;
|
|
6258
6258
|
function ct(t2) {
|
|
6259
6259
|
const e14 = t2[t2.length - 1];
|
|
6260
6260
|
return { x: e14.origin.x + e14.size.width, y: e14.origin.y + e14.size.height };
|
|
@@ -6312,7 +6312,7 @@ let vt = class {
|
|
|
6312
6312
|
return a3 ? this._pages.indexOf(a3) : -1;
|
|
6313
6313
|
}
|
|
6314
6314
|
};
|
|
6315
|
-
function
|
|
6315
|
+
function bt(t2, e14 = ft) {
|
|
6316
6316
|
const a3 = (function(t3, e15 = ft) {
|
|
6317
6317
|
const a4 = /* @__PURE__ */ new Map();
|
|
6318
6318
|
for (const o2 of t3.chapters) {
|
|
@@ -6328,12 +6328,12 @@ function bt2(t2, e14 = ft) {
|
|
|
6328
6328
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
6329
6329
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
6330
6330
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
6331
|
-
let
|
|
6331
|
+
let i2 = 0;
|
|
6332
6332
|
for (const n2 of o) {
|
|
6333
6333
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
6334
6334
|
if (!e15) continue;
|
|
6335
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
6336
|
-
r2.push({ globalPageIndex:
|
|
6335
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
6336
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
6337
6337
|
}
|
|
6338
6338
|
return new vt(r2);
|
|
6339
6339
|
}
|
|
@@ -6368,8 +6368,8 @@ const Pt = class s7 extends BasePlugin {
|
|
|
6368
6368
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
6369
6369
|
for (const s9 of t3.chapters) {
|
|
6370
6370
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
6371
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
6372
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
6371
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
6372
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
6373
6373
|
}
|
|
6374
6374
|
return e15;
|
|
6375
6375
|
})(t2);
|
|
@@ -6377,7 +6377,7 @@ const Pt = class s7 extends BasePlugin {
|
|
|
6377
6377
|
const a3 = new Set(this.chapterStatus.keys()), o = new Set(t2.chapters.map((t3) => t3.chapterId));
|
|
6378
6378
|
for (const s9 of a3) o.has(s9) || (this.closeChapter(s9), this.chapterStatus.delete(s9));
|
|
6379
6379
|
for (const s9 of t2.chapters) this.chapterStatus.has(s9.chapterId) || this.chapterStatus.set(s9.chapterId, "idle");
|
|
6380
|
-
this.manifest = t2, this.virtualPageMap =
|
|
6380
|
+
this.manifest = t2, this.virtualPageMap = bt(t2, this.overlapStrategy), this.manifestChange$.emit({ manifest: t2, map: this.virtualPageMap }), this.eagerPrefetchFromManifest();
|
|
6381
6381
|
}
|
|
6382
6382
|
eagerPrefetchFromManifest() {
|
|
6383
6383
|
const t2 = this.config.prefetchChapters ?? 0;
|
|
@@ -6409,9 +6409,9 @@ const Pt = class s7 extends BasePlugin {
|
|
|
6409
6409
|
const t3 = o.indexOf(n2);
|
|
6410
6410
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
6411
6411
|
}
|
|
6412
|
-
const
|
|
6413
|
-
for (const n2 of r2)
|
|
6414
|
-
for (const n2 of
|
|
6412
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
6413
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
6414
|
+
for (const n2 of i2) {
|
|
6415
6415
|
this.chapterLastUsed.set(n2, e14);
|
|
6416
6416
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
6417
6417
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -6461,8 +6461,8 @@ const Pt = class s7 extends BasePlugin {
|
|
|
6461
6461
|
const a3 = t2.chapterId;
|
|
6462
6462
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
6463
6463
|
try {
|
|
6464
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
6465
|
-
|
|
6464
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
6465
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
6466
6466
|
});
|
|
6467
6467
|
return await new Promise((t3, e15) => {
|
|
6468
6468
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -6493,15 +6493,15 @@ const Pt = class s7 extends BasePlugin {
|
|
|
6493
6493
|
if (!o) return;
|
|
6494
6494
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
6495
6495
|
this.passwordAttempts.set(t2, r2);
|
|
6496
|
-
let
|
|
6496
|
+
let i2 = null;
|
|
6497
6497
|
try {
|
|
6498
|
-
|
|
6498
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
6499
6499
|
} catch (n2) {
|
|
6500
6500
|
this.logger.error(s7.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
6501
6501
|
}
|
|
6502
|
-
if (!
|
|
6502
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
6503
6503
|
this.updateStatus(t2, "loading");
|
|
6504
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
6504
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
6505
6505
|
}, () => {
|
|
6506
6506
|
});
|
|
6507
6507
|
}
|
|
@@ -6586,12 +6586,12 @@ function Mt2(t2, e14 = yt) {
|
|
|
6586
6586
|
})(t2, e14), s9 = /* @__PURE__ */ new Map();
|
|
6587
6587
|
for (const n2 of t2.chapters) s9.set(n2.chapterId, n2);
|
|
6588
6588
|
const o = Array.from(a3.keys()).sort((t3, e15) => t3 - e15), r2 = [];
|
|
6589
|
-
let
|
|
6589
|
+
let i2 = 0;
|
|
6590
6590
|
for (const n2 of o) {
|
|
6591
6591
|
const t3 = a3.get(n2), e15 = s9.get(t3);
|
|
6592
6592
|
if (!e15) continue;
|
|
6593
|
-
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange,
|
|
6594
|
-
r2.push({ globalPageIndex:
|
|
6593
|
+
const [o2] = e15.globalPageRange, [h2] = e15.localPageRange, d2 = h2 + (n2 - o2);
|
|
6594
|
+
r2.push({ globalPageIndex: i2++, globalPageNumber: n2, chapterId: t3, localPageIndex: d2 });
|
|
6595
6595
|
}
|
|
6596
6596
|
return new Ct(r2);
|
|
6597
6597
|
}
|
|
@@ -6626,8 +6626,8 @@ const St = class s8 extends BasePlugin {
|
|
|
6626
6626
|
const e15 = [], a4 = /* @__PURE__ */ new Set();
|
|
6627
6627
|
for (const s9 of t3.chapters) {
|
|
6628
6628
|
a4.has(s9.chapterId) && e15.push(`Duplicate chapterId: ${s9.chapterId}`), a4.add(s9.chapterId);
|
|
6629
|
-
const [t4, o2] = s9.globalPageRange, [r2,
|
|
6630
|
-
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 >
|
|
6629
|
+
const [t4, o2] = s9.globalPageRange, [r2, i2] = s9.localPageRange;
|
|
6630
|
+
if (t4 > o2 && e15.push(`${s9.chapterId}: invalid globalPageRange [${t4},${o2}]`), r2 > i2 && e15.push(`${s9.chapterId}: invalid localPageRange [${r2},${i2}]`), o2 - t4 !== i2 - r2 && e15.push(`${s9.chapterId}: page-count mismatch (global ${o2 - t4 + 1} vs local ${i2 - r2 + 1})`), s9.ownedGlobalPages) for (const a5 of s9.ownedGlobalPages) (a5 < t4 || a5 > o2) && e15.push(`${s9.chapterId}: ownedGlobalPages contains ${a5} outside range`);
|
|
6631
6631
|
}
|
|
6632
6632
|
return e15;
|
|
6633
6633
|
})(t2);
|
|
@@ -6667,9 +6667,9 @@ const St = class s8 extends BasePlugin {
|
|
|
6667
6667
|
const t3 = o.indexOf(n2);
|
|
6668
6668
|
if (-1 !== t3) for (let e15 = t3 - a3; e15 <= t3 + a3; e15++) e15 >= 0 && e15 < o.length && r2.add(e15);
|
|
6669
6669
|
}
|
|
6670
|
-
const
|
|
6671
|
-
for (const n2 of r2)
|
|
6672
|
-
for (const n2 of
|
|
6670
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
6671
|
+
for (const n2 of r2) i2.add(o[n2]);
|
|
6672
|
+
for (const n2 of i2) {
|
|
6673
6673
|
this.chapterLastUsed.set(n2, e14);
|
|
6674
6674
|
const t3 = this.chapterStatus.get(n2) ?? "idle";
|
|
6675
6675
|
"idle" !== t3 && "closed" !== t3 && "error" !== t3 || this.ensureChapterLoaded(n2);
|
|
@@ -6719,8 +6719,8 @@ const St = class s8 extends BasePlugin {
|
|
|
6719
6719
|
const a3 = t2.chapterId;
|
|
6720
6720
|
this.updateStatus(a3, "loading"), this.chapterLastUsed.set(a3, Date.now());
|
|
6721
6721
|
try {
|
|
6722
|
-
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(),
|
|
6723
|
-
|
|
6722
|
+
const s9 = t2.encrypted && (null == (e14 = this.passwordProvider) ? void 0 : e14.getCachedPassword) ? this.passwordProvider.getCachedPassword(a3) : null, o = await this.resolvePdfPayload(t2), r2 = this.documentManager.provides(), i2 = "url" in o ? r2.openDocumentUrl({ documentId: a3, url: o.url, name: t2.title, password: s9 ?? void 0, autoActivate: false }) : r2.openDocumentBuffer({ documentId: a3, buffer: o.buffer, name: t2.title, password: s9 ?? void 0, autoActivate: false }), n2 = await new Promise((t3, e15) => {
|
|
6723
|
+
i2.wait((e16) => t3(e16), (t4) => e15(t4));
|
|
6724
6724
|
});
|
|
6725
6725
|
return await new Promise((t3, e15) => {
|
|
6726
6726
|
n2.task.wait(() => t3(), (t4) => e15(t4));
|
|
@@ -6751,15 +6751,15 @@ const St = class s8 extends BasePlugin {
|
|
|
6751
6751
|
if (!o) return;
|
|
6752
6752
|
const r2 = (this.passwordAttempts.get(t2) ?? 0) + 1;
|
|
6753
6753
|
this.passwordAttempts.set(t2, r2);
|
|
6754
|
-
let
|
|
6754
|
+
let i2 = null;
|
|
6755
6755
|
try {
|
|
6756
|
-
|
|
6756
|
+
i2 = await this.passwordProvider.resolvePassword(o, r2 - 1);
|
|
6757
6757
|
} catch (n2) {
|
|
6758
6758
|
this.logger.error(s8.id, "PasswordProvider", `Provider rejected for ${t2}`, n2);
|
|
6759
6759
|
}
|
|
6760
|
-
if (!
|
|
6760
|
+
if (!i2) return void this.updateStatus(t2, "password-required");
|
|
6761
6761
|
this.updateStatus(t2, "loading");
|
|
6762
|
-
this.documentManager.provides().retryDocument(t2, { password:
|
|
6762
|
+
this.documentManager.provides().retryDocument(t2, { password: i2 }).wait(() => {
|
|
6763
6763
|
}, () => {
|
|
6764
6764
|
});
|
|
6765
6765
|
}
|
|
@@ -6872,12 +6872,12 @@ const Lt = class extends BasePlugin {
|
|
|
6872
6872
|
if (!this.virtualPageMap) return;
|
|
6873
6873
|
const s9 = this.documentManager.provides().getDocument(t2), o = this.virtualPageMap.pagesOfChapter(t2);
|
|
6874
6874
|
if (!(null == (a3 = null == s9 ? void 0 : s9.pages) ? void 0 : a3.length) || 0 === o.length) return void (e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1)));
|
|
6875
|
-
const r2 = this.getChapterDocumentScale(t2),
|
|
6875
|
+
const r2 = this.getChapterDocumentScale(t2), i2 = [];
|
|
6876
6876
|
for (const n2 of o) {
|
|
6877
6877
|
const t3 = s9.pages[n2.localPageIndex];
|
|
6878
|
-
(null == t3 ? void 0 : t3.size) &&
|
|
6878
|
+
(null == t3 ? void 0 : t3.size) && i2.push({ localPageIndex: n2.localPageIndex, width: t3.size.width * r2, height: t3.size.height * r2 });
|
|
6879
6879
|
}
|
|
6880
|
-
0 !==
|
|
6880
|
+
0 !== i2.length ? this.applyChapterPageSizes(t2, i2) : e14 < 60 && requestAnimationFrame(() => this.harvestChapterSizes(t2, e14 + 1));
|
|
6881
6881
|
}
|
|
6882
6882
|
onScaleChanged(t2) {
|
|
6883
6883
|
const e14 = this.coreState.core.documents[t2];
|
|
@@ -6911,13 +6911,13 @@ const Lt = class extends BasePlugin {
|
|
|
6911
6911
|
o++;
|
|
6912
6912
|
}
|
|
6913
6913
|
const r2 = [];
|
|
6914
|
-
let
|
|
6914
|
+
let i2 = s9, n2 = -1;
|
|
6915
6915
|
for (let h2 = s9; h2 < o; h2++) {
|
|
6916
6916
|
r2.push(h2);
|
|
6917
6917
|
const t3 = this.offsets[h2], s10 = t3 + this.getPageSize(h2).height, o2 = Math.max(0, Math.min(s10, a3) - Math.max(t3, e14));
|
|
6918
|
-
o2 > n2 && (n2 = o2,
|
|
6918
|
+
o2 > n2 && (n2 = o2, i2 = h2);
|
|
6919
6919
|
}
|
|
6920
|
-
this.currentVisible = r2, this.currentGlobalPageIndex =
|
|
6920
|
+
this.currentVisible = r2, this.currentGlobalPageIndex = i2, this.visibleChange$.emit({ visibleGlobalPageIndices: r2, currentGlobalPageIndex: i2 }), this.chapterManager.provides().setVisibleGlobalPages(r2), this.layoutChange$.emit(this.computeLayout());
|
|
6921
6921
|
}
|
|
6922
6922
|
findFirstVisibleIndex(t2) {
|
|
6923
6923
|
let e14 = 0, a3 = this.offsets.length - 1, s9 = 0;
|
|
@@ -6947,10 +6947,10 @@ const Lt = class extends BasePlugin {
|
|
|
6947
6947
|
if (!this.viewportEl || t2 < 0 || t2 >= this.offsets.length || !this.virtualPageMap) return;
|
|
6948
6948
|
const o = (null == a3 ? void 0 : a3.marginTop) ?? 80, r2 = this.virtualPageMap.atIndex(t2);
|
|
6949
6949
|
if (!r2) return void this.scrollToIndex(t2, a3);
|
|
6950
|
-
const
|
|
6951
|
-
if (!
|
|
6952
|
-
const h2 =
|
|
6953
|
-
this.viewportEl.scrollTo({ top: Math.max(0,
|
|
6950
|
+
const i2 = this.pageSizes.get(t2), n2 = null == (s9 = this.documentManager.provides().getDocument(r2.chapterId)) ? void 0 : s9.pages[r2.localPageIndex];
|
|
6951
|
+
if (!i2 || !n2) return void this.scrollToIndex(t2, a3);
|
|
6952
|
+
const h2 = i2.height / n2.size.height, d2 = (this.offsets[t2] ?? 0) + e14 * h2 - o;
|
|
6953
|
+
this.viewportEl.scrollTo({ top: Math.max(0, d2), behavior: (null == a3 ? void 0 : a3.behavior) ?? "auto" });
|
|
6954
6954
|
}
|
|
6955
6955
|
scrollToChapter(t2, e14) {
|
|
6956
6956
|
if (!this.virtualPageMap) return;
|
|
@@ -6964,21 +6964,21 @@ const Lt = class extends BasePlugin {
|
|
|
6964
6964
|
}
|
|
6965
6965
|
};
|
|
6966
6966
|
Lt.id = "chapter-scroll";
|
|
6967
|
-
let $
|
|
6967
|
+
let $t = Lt;
|
|
6968
6968
|
function Tt(t2) {
|
|
6969
6969
|
const e14 = t2[t2.length - 1];
|
|
6970
6970
|
return { x: e14.origin.x + e14.size.width, y: e14.origin.y + e14.size.height };
|
|
6971
6971
|
}
|
|
6972
6972
|
function Dt(t2, e14) {
|
|
6973
|
-
const a3 = t2.origin.y, s9 = t2.origin.y + t2.size.height, o = e14.origin.y, r2 = e14.origin.y + e14.size.height,
|
|
6974
|
-
if (
|
|
6975
|
-
return Math.max(0, Math.min(s9, r2) - Math.max(a3, o)) /
|
|
6973
|
+
const a3 = t2.origin.y, s9 = t2.origin.y + t2.size.height, o = e14.origin.y, r2 = e14.origin.y + e14.size.height, i2 = Math.max(s9, r2) - Math.min(a3, o);
|
|
6974
|
+
if (i2 <= 0) return 0;
|
|
6975
|
+
return Math.max(0, Math.min(s9, r2) - Math.max(a3, o)) / i2;
|
|
6976
6976
|
}
|
|
6977
6977
|
function Ot(t2, e14) {
|
|
6978
6978
|
var a3, s9;
|
|
6979
6979
|
if (t2.chapterId !== e14.chapterId || t2.localPageIndex !== e14.localPageIndex) return false;
|
|
6980
|
-
const o = (null == (a3 = t2.rectsPdfCoord) ? void 0 : a3.length) ? t2.rectsPdfCoord : [t2.rectPdfCoord], r2 = (null == (s9 = e14.rectsPdfCoord) ? void 0 : s9.length) ? e14.rectsPdfCoord : [e14.rectPdfCoord],
|
|
6981
|
-
if (Math.hypot(
|
|
6980
|
+
const o = (null == (a3 = t2.rectsPdfCoord) ? void 0 : a3.length) ? t2.rectsPdfCoord : [t2.rectPdfCoord], r2 = (null == (s9 = e14.rectsPdfCoord) ? void 0 : s9.length) ? e14.rectsPdfCoord : [e14.rectPdfCoord], i2 = t2.markerAnchor ?? Tt(o), n2 = e14.markerAnchor ?? Tt(r2);
|
|
6981
|
+
if (Math.hypot(i2.x - n2.x, i2.y - n2.y) <= 6) return true;
|
|
6982
6982
|
for (const h2 of o) for (const t3 of r2) {
|
|
6983
6983
|
if (Dt(h2, t3) < 0.5) continue;
|
|
6984
6984
|
const e15 = Math.max(h2.origin.x, t3.origin.x);
|
|
@@ -6999,9 +6999,9 @@ async function Gt(t2, e14, a3) {
|
|
|
6999
6999
|
});
|
|
7000
7000
|
})(t2, e14), t2.scrollToGlobalPdfPoint(e14, a3, { marginTop: 80 });
|
|
7001
7001
|
}
|
|
7002
|
-
const
|
|
7002
|
+
const zt2 = class a2 extends BasePlugin {
|
|
7003
7003
|
constructor(t2, a3) {
|
|
7004
|
-
super(t2, a3), this.change$ = createBehaviorEmitter([]), this.entries = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin($
|
|
7004
|
+
super(t2, a3), this.change$ = createBehaviorEmitter([]), this.entries = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin($t.id), this.chapterManager = this.registry.getPlugin(wt.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
|
|
7005
7005
|
}
|
|
7006
7006
|
async initialize(t2) {
|
|
7007
7007
|
var e14;
|
|
@@ -7032,8 +7032,8 @@ const zt = class a2 extends BasePlugin {
|
|
|
7032
7032
|
const r2 = null == (s9 = null == (e14 = this.config) ? void 0 : e14.callbacks) ? void 0 : s9.onRequestRemove;
|
|
7033
7033
|
if (r2) try {
|
|
7034
7034
|
if (!await r2(o)) return false;
|
|
7035
|
-
} catch (
|
|
7036
|
-
return this.logger.error(a2.id, "RequestRemove", "callback failed",
|
|
7035
|
+
} catch (i2) {
|
|
7036
|
+
return this.logger.error(a2.id, "RequestRemove", "callback failed", i2), false;
|
|
7037
7037
|
}
|
|
7038
7038
|
return this.removeBookmark(t2), true;
|
|
7039
7039
|
}
|
|
@@ -7076,8 +7076,8 @@ const zt = class a2 extends BasePlugin {
|
|
|
7076
7076
|
await Gt(a3, s9, o);
|
|
7077
7077
|
}
|
|
7078
7078
|
};
|
|
7079
|
-
|
|
7080
|
-
let At =
|
|
7079
|
+
zt2.id = "paragraph-bookmark";
|
|
7080
|
+
let At = zt2;
|
|
7081
7081
|
function Bt(t2, e14) {
|
|
7082
7082
|
const a3 = t2;
|
|
7083
7083
|
return false === t2 ? { ...e14, enabled: false } : true === t2 || void 0 === t2 ? { ...e14, enabled: e14.enabled ?? true } : { ...e14, ...a3, enabled: false !== (null == a3 ? void 0 : a3.enabled) };
|
|
@@ -7119,7 +7119,7 @@ function ne(t2) {
|
|
|
7119
7119
|
}
|
|
7120
7120
|
function he(t2) {
|
|
7121
7121
|
var _a2, _b, _c, _d;
|
|
7122
|
-
const e14 = (_a2 = t2.getPlugin(AnnotationPlugin.id)) == null ? void 0 : _a2.provides(), a3 = (_b = t2.getPlugin(
|
|
7122
|
+
const e14 = (_a2 = t2.getPlugin(AnnotationPlugin.id)) == null ? void 0 : _a2.provides(), a3 = (_b = t2.getPlugin(lt.id)) == null ? void 0 : _b.provides(), s9 = (_c = t2.getPlugin(At.id)) == null ? void 0 : _c.provides(), o = (_d = t2.getPlugin(O.id)) == null ? void 0 : _d.provides();
|
|
7123
7123
|
return { annotation: e14, note: a3, bookmark: s9, chapterManager: o };
|
|
7124
7124
|
}
|
|
7125
7125
|
async function de(t2, e14, a3) {
|
|
@@ -7128,10 +7128,10 @@ async function de(t2, e14, a3) {
|
|
|
7128
7128
|
if ("loaded" !== s9) throw new Error(`章节 ${e14} 未加载成功(${s9}),无法导入/导出划线`);
|
|
7129
7129
|
}
|
|
7130
7130
|
async function le(t2, e14, a3) {
|
|
7131
|
-
const s9 = ne(a3), { annotation: o, note: r2, bookmark:
|
|
7131
|
+
const s9 = ne(a3), { annotation: o, note: r2, bookmark: i2, chapterManager: n2 } = he(t2), h2 = { chapterId: e14 };
|
|
7132
7132
|
if (s9.bookmarks) {
|
|
7133
|
-
if (!
|
|
7134
|
-
h2.bookmarks =
|
|
7133
|
+
if (!i2) throw new Error("paragraph-bookmark 插件未注册");
|
|
7134
|
+
h2.bookmarks = i2.listBookmarksForChapter(e14);
|
|
7135
7135
|
}
|
|
7136
7136
|
if (s9.notes) {
|
|
7137
7137
|
if (!r2) throw new Error("note 插件未注册");
|
|
@@ -7140,41 +7140,41 @@ async function le(t2, e14, a3) {
|
|
|
7140
7140
|
if (s9.markup) {
|
|
7141
7141
|
if (!o) throw new Error("annotation 插件未注册");
|
|
7142
7142
|
await de(n2, e14, false !== (a3 == null ? void 0 : a3.ensureChapterLoaded));
|
|
7143
|
-
const t3 = await (
|
|
7144
|
-
|
|
7143
|
+
const t3 = await (d2 = o.forDocument(e14).exportAnnotations(), new Promise((t4, e15) => {
|
|
7144
|
+
d2.wait((e16) => t4(e16), (t5) => e15(t5));
|
|
7145
7145
|
}));
|
|
7146
7146
|
h2.markup = re(t3);
|
|
7147
7147
|
}
|
|
7148
|
-
var
|
|
7148
|
+
var d2;
|
|
7149
7149
|
return h2;
|
|
7150
7150
|
}
|
|
7151
7151
|
async function ce(t2, e14, a3) {
|
|
7152
7152
|
const s9 = {};
|
|
7153
7153
|
for (const o of e14.chapters) {
|
|
7154
|
-
const e15 = await le(t2, o.chapterId, a3), { chapterId: r2, ...
|
|
7155
|
-
s9[o.chapterId] =
|
|
7154
|
+
const e15 = await le(t2, o.chapterId, a3), { chapterId: r2, ...i2 } = e15;
|
|
7155
|
+
s9[o.chapterId] = i2;
|
|
7156
7156
|
}
|
|
7157
7157
|
return { version: 1, exportedAt: /* @__PURE__ */ (/* @__PURE__ */ new Date()).toISOString(), chapters: s9 };
|
|
7158
7158
|
}
|
|
7159
7159
|
async function ue(t2, e14, a3) {
|
|
7160
|
-
const s9 = ne(a3), o = (a3 == null ? void 0 : a3.mode) ?? "replace", { annotation: r2, note:
|
|
7160
|
+
const s9 = ne(a3), o = (a3 == null ? void 0 : a3.mode) ?? "replace", { annotation: r2, note: i2, bookmark: n2, chapterManager: h2 } = he(t2), d2 = e14.chapterId;
|
|
7161
7161
|
if (s9.bookmarks && e14.bookmarks) {
|
|
7162
7162
|
if (!n2) throw new Error("paragraph-bookmark 插件未注册");
|
|
7163
|
-
if ("replace" === o) n2.replaceBookmarksForChapter(
|
|
7163
|
+
if ("replace" === o) n2.replaceBookmarksForChapter(d2, e14.bookmarks);
|
|
7164
7164
|
else for (const t3 of e14.bookmarks) n2.addBookmark(t3);
|
|
7165
7165
|
}
|
|
7166
7166
|
if (s9.notes && e14.notes) {
|
|
7167
|
-
if (!
|
|
7168
|
-
if ("replace" === o)
|
|
7169
|
-
else for (const t3 of e14.notes)
|
|
7167
|
+
if (!i2) throw new Error("note 插件未注册");
|
|
7168
|
+
if ("replace" === o) i2.replaceNotesForChapter(d2, e14.notes);
|
|
7169
|
+
else for (const t3 of e14.notes) i2.registerNote(t3);
|
|
7170
7170
|
}
|
|
7171
7171
|
if (s9.markup && e14.markup) {
|
|
7172
7172
|
if (!r2) throw new Error("annotation 插件未注册");
|
|
7173
|
-
await de(h2,
|
|
7174
|
-
const t3 = r2.forDocument(
|
|
7173
|
+
await de(h2, d2, false !== (a3 == null ? void 0 : a3.ensureChapterLoaded));
|
|
7174
|
+
const t3 = r2.forDocument(d2), s10 = ie(e14.markup);
|
|
7175
7175
|
"replace" === o && t3.deleteAllAnnotations(), t3.importAnnotations(s10);
|
|
7176
7176
|
}
|
|
7177
|
-
(a3 == null ? void 0 : a3.persistNotes) &&
|
|
7177
|
+
(a3 == null ? void 0 : a3.persistNotes) && i2 && await a3.persistNotes(i2.listAllNotes()), (a3 == null ? void 0 : a3.persistBookmarks) && n2 && await a3.persistBookmarks(n2.listBookmarks());
|
|
7178
7178
|
}
|
|
7179
7179
|
async function pe(t2, e14, a3) {
|
|
7180
7180
|
if (1 !== e14.version) throw new Error(`不支持的归档版本 ${e14.version},当前为 1`);
|
|
@@ -7206,33 +7206,63 @@ function Pe(t2, e14 = "chapter-annotations.json") {
|
|
|
7206
7206
|
function we(t2, e14) {
|
|
7207
7207
|
be(e14 ?? `chapter-annotations-${t2.chapterId}.json`, me(t2));
|
|
7208
7208
|
}
|
|
7209
|
+
const t = { kind: "first-wins" };
|
|
7210
|
+
function i(e14) {
|
|
7211
|
+
return "last" === e14 ? { kind: "last-wins" } : { kind: "first-wins" };
|
|
7212
|
+
}
|
|
7213
|
+
function h(e14) {
|
|
7214
|
+
const t2 = e14.endPage - e14.startPage + 1;
|
|
7215
|
+
return { chapterId: e14.chapterId, title: e14.title, globalPageRange: [e14.startPage, e14.endPage], localPageRange: [0, t2 - 1], ...e14.source ? { source: e14.source } : {}, ...e14.encrypted ? { encrypted: e14.encrypted } : {} };
|
|
7216
|
+
}
|
|
7217
|
+
function p(e14) {
|
|
7218
|
+
const t2 = [], n2 = (e15) => {
|
|
7219
|
+
var _a2;
|
|
7220
|
+
for (const r2 of e15) t2.push(h(r2)), ((_a2 = r2.children) == null ? void 0 : _a2.length) && n2(r2.children);
|
|
7221
|
+
};
|
|
7222
|
+
return n2(e14), t2;
|
|
7223
|
+
}
|
|
7224
|
+
function g(e14) {
|
|
7225
|
+
return e14.map((e15) => {
|
|
7226
|
+
var _a2;
|
|
7227
|
+
return { id: e15.chapterId, title: e15.title, startPage: e15.startPage, endPage: e15.endPage, children: ((_a2 = e15.children) == null ? void 0 : _a2.length) ? g(e15.children) : void 0 };
|
|
7228
|
+
});
|
|
7229
|
+
}
|
|
7230
|
+
function d(e14) {
|
|
7231
|
+
return { tree: g(e14), manifest: { chapters: p(e14) } };
|
|
7232
|
+
}
|
|
7209
7233
|
export {
|
|
7210
7234
|
se as CHAPTER_ANNOTATIONS_ARCHIVE_VERSION,
|
|
7211
|
-
|
|
7235
|
+
xe as CallbackPasswordProvider,
|
|
7212
7236
|
ChapterManagerPlugin,
|
|
7213
7237
|
_sfc_main as ChapterPdfViewer,
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7238
|
+
Ts as ChapterTreePanel,
|
|
7239
|
+
ea as DEFAULT_CHAPTER_VIEWER_CONFIG,
|
|
7240
|
+
Jt as DEFAULT_CHAPTER_VIEWER_FEATURES,
|
|
7217
7241
|
EmbedPDF2 as EmbedPDF,
|
|
7218
|
-
|
|
7242
|
+
vs as PdfChapterViewport,
|
|
7219
7243
|
Ce as applySelectionMarkup,
|
|
7220
|
-
|
|
7244
|
+
d as buildChapterViewerCatalog,
|
|
7245
|
+
Ft as buildParagraphBookmarkAnchor,
|
|
7221
7246
|
ge as chapterAnnotationsArchiveToJson,
|
|
7222
7247
|
me as chapterAnnotationsSnapshotToJson,
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7248
|
+
h as chapterDescriptorFromTreeNode,
|
|
7249
|
+
oa as createChapterViewerBundle,
|
|
7250
|
+
ta as createChapterViewerEditor,
|
|
7251
|
+
ra as createChapterViewerEditorOptions,
|
|
7252
|
+
Xt as createPdfChapterEditor,
|
|
7253
|
+
t as defaultOverlapStrategy,
|
|
7227
7254
|
Pe as downloadChapterAnnotationsArchive,
|
|
7228
7255
|
we as downloadChapterAnnotationsSnapshot,
|
|
7229
7256
|
be as downloadJsonFile,
|
|
7230
7257
|
ce as exportAllChapterAnnotations,
|
|
7231
7258
|
le as exportChapterAnnotations,
|
|
7259
|
+
p as flattenChapterTree,
|
|
7232
7260
|
ue as importChapterAnnotations,
|
|
7233
7261
|
pe as importChapterAnnotationsArchive,
|
|
7262
|
+
i as overlapStrategyForSamePageOwner,
|
|
7234
7263
|
fe as parseChapterAnnotationsArchiveJson,
|
|
7235
7264
|
ve as parseChapterAnnotationsSnapshotJson,
|
|
7265
|
+
g as toChapterTreeNodes,
|
|
7236
7266
|
useCapability2 as useCapability,
|
|
7237
7267
|
usePdfiumEngine,
|
|
7238
7268
|
useRegistry2 as useRegistry
|