@l1yp/file-viewer 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ArchiveBrowser.js +1 -1
- package/dist/components/ArchiveBrowser.js.map +1 -1
- package/dist/components/ArchiveBrowser.vue_vue_type_script_setup_true_lang.js +105 -94
- package/dist/components/ArchiveBrowser.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/FileViewerBody.js +1 -1
- package/dist/components/FileViewerBody.js.map +1 -1
- package/dist/components/FileViewerBody.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ImageLightbox.js +1 -1
- package/dist/components/ImageLightbox.js.map +1 -1
- package/dist/components/ImageLightbox.vue_vue_type_script_setup_true_lang.js +101 -55
- package/dist/components/ImageLightbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/JsonlViewer.js +1 -1
- package/dist/components/JsonlViewer.js.map +1 -1
- package/dist/components/JsonlViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/LightboxGalleryStrip.js +9 -0
- package/dist/components/LightboxGalleryStrip.js.map +1 -0
- package/dist/components/LightboxGalleryStrip.vue.d.ts +12 -0
- package/dist/components/LightboxGalleryStrip.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/components/LightboxGalleryStrip.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/PdfNavigationPane.js +9 -0
- package/dist/components/PdfNavigationPane.js.map +1 -0
- package/dist/components/PdfNavigationPane.vue.d.ts +24 -0
- package/dist/components/PdfNavigationPane.vue_vue_type_script_setup_true_lang.js +149 -0
- package/dist/components/PdfNavigationPane.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/PdfViewer.js +1 -1
- package/dist/components/PdfViewer.js.map +1 -1
- package/dist/components/PdfViewer.vue.d.ts +0 -11
- package/dist/components/PdfViewer.vue_vue_type_script_setup_true_lang.js +131 -69
- package/dist/components/PdfViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/SevenZipBrowser.js +1 -1
- package/dist/components/SevenZipBrowser.js.map +1 -1
- package/dist/components/SevenZipBrowser.vue_vue_type_script_setup_true_lang.js +157 -146
- package/dist/components/SevenZipBrowser.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ZipBrowser.js +1 -1
- package/dist/components/ZipBrowser.js.map +1 -1
- package/dist/components/ZipBrowser.vue_vue_type_script_setup_true_lang.js +70 -61
- package/dist/components/ZipBrowser.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ZoomImage.js +1 -1
- package/dist/components/ZoomImage.js.map +1 -1
- package/dist/components/ZoomImage.vue.d.ts +2 -0
- package/dist/components/ZoomImage.vue_vue_type_script_setup_true_lang.js +104 -95
- package/dist/components/ZoomImage.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useArchiveImageGallery.d.ts +15 -0
- package/dist/composables/useArchiveImageGallery.js +62 -0
- package/dist/composables/useArchiveImageGallery.js.map +1 -0
- package/dist/composables/useLightbox.d.ts +29 -21
- package/dist/composables/useLightbox.js +72 -12
- package/dist/composables/useLightbox.js.map +1 -1
- package/dist/lib/archiveImages.d.ts +14 -0
- package/dist/lib/archiveImages.js +15 -0
- package/dist/lib/archiveImages.js.map +1 -0
- package/dist/lib/pdfNavigation.d.ts +11 -0
- package/dist/lib/pdfNavigation.js +32 -0
- package/dist/lib/pdfNavigation.js.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
export interface PdfNavigationItem {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
level: number;
|
|
6
|
+
pageNumber: number | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadPdfNavigation(document: PDFDocumentProxy): Promise<{
|
|
9
|
+
outline: PdfNavigationItem[];
|
|
10
|
+
pageLabels: string[];
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/lib/pdfNavigation.ts
|
|
2
|
+
async function e(e, t) {
|
|
3
|
+
if (!t) return null;
|
|
4
|
+
try {
|
|
5
|
+
let n = (typeof t == "string" ? await e.getDestination(t) : t)?.[0];
|
|
6
|
+
return !n || typeof n == "number" ? typeof n == "number" ? n + 1 : null : await e.getPageIndex(n) + 1;
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function t(n, r, i = 0, a = "root") {
|
|
12
|
+
return (await Promise.all(r.map(async (r, o) => {
|
|
13
|
+
let s = `${a}-${o}`;
|
|
14
|
+
return [{
|
|
15
|
+
id: `pdf-outline-${s}`,
|
|
16
|
+
title: r.title.trim() || "未命名书签",
|
|
17
|
+
level: i,
|
|
18
|
+
pageNumber: await e(n, r.dest)
|
|
19
|
+
}, ...await t(n, r.items ?? [], i + 1, s)];
|
|
20
|
+
}))).flat();
|
|
21
|
+
}
|
|
22
|
+
async function n(e) {
|
|
23
|
+
let [n, r] = await Promise.all([e.getOutline().then((n) => t(e, n ?? [])).catch(() => []), e.getPageLabels().catch(() => null)]);
|
|
24
|
+
return {
|
|
25
|
+
outline: n,
|
|
26
|
+
pageLabels: r ?? []
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { n as loadPdfNavigation };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=pdfNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfNavigation.js","names":[],"sources":["../../src/lib/pdfNavigation.ts"],"sourcesContent":["import type { PDFDocumentProxy } from 'pdfjs-dist'\n\nexport interface PdfNavigationItem {\n id: string\n title: string\n level: number\n pageNumber: number | null\n}\n\ntype PdfOutline = Awaited<ReturnType<PDFDocumentProxy['getOutline']>>\ntype PdfOutlineItem = NonNullable<PdfOutline>[number]\ntype PdfPageReference = Parameters<PDFDocumentProxy['getPageIndex']>[0]\n\nasync function resolvePageNumber(\n document: PDFDocumentProxy,\n destination: PdfOutlineItem['dest'],\n): Promise<number | null> {\n if (!destination) return null\n\n try {\n const resolved =\n typeof destination === 'string' ? await document.getDestination(destination) : destination\n const pageReference = resolved?.[0]\n if (!pageReference || typeof pageReference === 'number') {\n return typeof pageReference === 'number' ? pageReference + 1 : null\n }\n return (await document.getPageIndex(pageReference as PdfPageReference)) + 1\n } catch {\n return null\n }\n}\n\nasync function flattenOutline(\n document: PDFDocumentProxy,\n items: readonly PdfOutlineItem[],\n level = 0,\n parentPath = 'root',\n): Promise<PdfNavigationItem[]> {\n const groups = await Promise.all(\n items.map(async (item, index) => {\n const path = `${parentPath}-${index}`\n const current: PdfNavigationItem = {\n id: `pdf-outline-${path}`,\n title: item.title.trim() || '未命名书签',\n level,\n pageNumber: await resolvePageNumber(document, item.dest),\n }\n const children = await flattenOutline(document, item.items ?? [], level + 1, path)\n return [current, ...children]\n }),\n )\n return groups.flat()\n}\n\nexport async function loadPdfNavigation(document: PDFDocumentProxy): Promise<{\n outline: PdfNavigationItem[]\n pageLabels: string[]\n}> {\n const [outline, pageLabels] = await Promise.all([\n document\n .getOutline()\n .then((items) => flattenOutline(document, items ?? []))\n .catch(() => []),\n document.getPageLabels().catch(() => null),\n ])\n return {\n outline,\n pageLabels: pageLabels ?? [],\n }\n}\n"],"mappings":";AAaA,eAAe,EACb,GACA,GACwB;CACxB,IAAI,CAAC,GAAa,OAAO;CAEzB,IAAI;EAGF,IAAM,KADJ,OAAO,KAAgB,WAAW,MAAM,EAAS,eAAe,CAAW,IAAI,EAAA,GAChD;EAIjC,OAHI,CAAC,KAAiB,OAAO,KAAkB,WACtC,OAAO,KAAkB,WAAW,IAAgB,IAAI,OAEzD,MAAM,EAAS,aAAa,CAAiC,IAAK;CAC5E,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAe,EACb,GACA,GACA,IAAQ,GACR,IAAa,QACiB;CAc9B,QAAO,MAbc,QAAQ,IAC3B,EAAM,IAAI,OAAO,GAAM,MAAU;EAC/B,IAAM,IAAO,GAAG,EAAW,GAAG;EAQ9B,OAAO,CAAC;GANN,IAAI,eAAe;GACnB,OAAO,EAAK,MAAM,KAAK,KAAK;GAC5B;GACA,YAAY,MAAM,EAAkB,GAAU,EAAK,IAAI;EAGjD,GAAS,GAAG,MADG,EAAe,GAAU,EAAK,SAAS,CAAC,GAAG,IAAQ,GAAG,CAAI,CACrD;CAC9B,CAAC,CACH,EAAA,CACc,KAAK;AACrB;AAEA,eAAsB,EAAkB,GAGrC;CACD,IAAM,CAAC,GAAS,KAAc,MAAM,QAAQ,IAAI,CAC9C,EACG,WAAW,CAAC,CACZ,MAAM,MAAU,EAAe,GAAU,KAAS,CAAC,CAAC,CAAC,CAAC,CACtD,YAAY,CAAC,CAAC,GACjB,EAAS,cAAc,CAAC,CAAC,YAAY,IAAI,CAC3C,CAAC;CACD,OAAO;EACL;EACA,YAAY,KAAc,CAAC;CAC7B;AACF"}
|