@eternalheart/vue-file-preview 1.7.0 → 1.7.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 +2 -0
- package/README.zh-CN.md +2 -0
- package/lib/FilePreviewContent.vue.d.ts +9 -1
- package/lib/FilePreviewEmbed.vue.d.ts +6 -1
- package/lib/FilePreviewModal.vue.d.ts +6 -1
- package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs → EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs} +1 -1
- package/lib/chunks/{avifLoader-CAUzjn-d-CnJpGYJ2.mjs → avifLoader-CAUzjn-d-Cf00sjt2.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-g_dLrWLP.mjs → heicLoader-D_9PukkA-cn1P7b2x.mjs} +1 -1
- package/lib/chunks/{index-C8lyQPe3.mjs → index-0VXtKKev.mjs} +3 -3
- package/lib/chunks/index-0fXL30y0.mjs +333 -0
- package/lib/chunks/{index-CWPdNhoe.mjs → index-B1AwVHWI.mjs} +60 -60
- package/lib/chunks/{index-C4hIk6pa.mjs → index-B77rFiau.mjs} +2 -2
- package/lib/chunks/{index-BzwJ0VWu.mjs → index-BB10as16.mjs} +33 -33
- package/lib/chunks/{index-BfOWoMpY.mjs → index-BBIn-k4u.mjs} +77 -77
- package/lib/chunks/{index-6XZXYqbp.mjs → index-BSzaI9ea.mjs} +29 -32
- package/lib/chunks/{index-Bg8poMIm.mjs → index-BZvy39tn.mjs} +29 -29
- package/lib/chunks/{index-zLQlyNR2.mjs → index-BlJEM2Lb.mjs} +62 -62
- package/lib/chunks/{index-z9RqL2wI.mjs → index-CZlnxQFA.mjs} +453 -453
- package/lib/chunks/{index-BPSzwMOC.mjs → index-ClhTPqDI.mjs} +46 -46
- package/lib/chunks/{index-Bf94DwQu.mjs → index-D690gnNu.mjs} +24 -24
- package/lib/chunks/index-D7WykPYL.mjs +51 -0
- package/lib/chunks/{index-c-pYJEmH.mjs → index-DBzyeU0G.mjs} +1028 -989
- package/lib/chunks/{index-LPGxJDnT.mjs → index-DKFX5ToE.mjs} +18 -18
- package/lib/chunks/{index-aKiIuKKx.mjs → index-DRmKaFXK.mjs} +50 -50
- package/lib/chunks/{index-D5IF9F-D.mjs → index-DXf3wXT5.mjs} +22 -22
- package/lib/chunks/{index-CrVQPnFj.mjs → index-Dp7QQjNH.mjs} +18 -18
- package/lib/chunks/{index-BYQ9S7Mk.mjs → index-FzI__DHC.mjs} +30 -30
- package/lib/chunks/{index-DZe0BxAB.mjs → index-PWjCziZG.mjs} +20 -20
- package/lib/chunks/{index-DM8Dfl-m.mjs → index-bT6XWKO_.mjs} +15 -15
- package/lib/chunks/{index-DFeKS8tR.mjs → index-tX9VR6Vo.mjs} +22 -22
- package/lib/chunks/{jp2Loader-Dig19xyo-fCO1knZ0.mjs → jp2Loader-Dig19xyo-D-OEDL3n.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-DihMskai.mjs → psdLoader-C0tKUXXl-CVN06LUc.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-BSfDPl-z.mjs → rawLoader-C-tPeFAB-DBqcJPFK.mjs} +1 -1
- package/lib/chunks/{tiffLoader-BlhByX8w-JY5DaTre.mjs → tiffLoader-BlhByX8w-8-0icdyL.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-C-ztcJBE.mjs → useShikiHighlight-a_GUszuU.mjs} +1 -1
- package/lib/composables/usePreviewEvents.d.ts +2 -2
- package/lib/core/events.d.ts +18 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/index.cjs +48 -48
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +5 -5
- package/package.json +1 -1
- package/lib/chunks/index-C41YET0_.mjs +0 -51
- package/lib/chunks/index-GFcSJEwj.mjs +0 -330
package/README.md
CHANGED
|
@@ -391,6 +391,7 @@ Differences from `FilePreviewModal`:
|
|
|
391
391
|
| `close` | - | Emitted when the modal should close |
|
|
392
392
|
| `navigate` | `number` | Emitted when navigating to a different file index |
|
|
393
393
|
| `error` | `PreviewErrorPayload` | Emitted when loading or rendering fails (at most once per load) |
|
|
394
|
+
| `rendered` | `PreviewRenderedPayload` | Emitted when the first screen is ready (at most once per load) |
|
|
394
395
|
|
|
395
396
|
### FilePreviewEmbed Props
|
|
396
397
|
|
|
@@ -417,6 +418,7 @@ Differences from `FilePreviewModal`:
|
|
|
417
418
|
|-------|---------|-------------|
|
|
418
419
|
| `navigate` | `number` | Emitted when navigating to a different file index |
|
|
419
420
|
| `error` | `PreviewErrorPayload` | Emitted when loading or rendering fails (at most once per load) |
|
|
421
|
+
| `rendered` | `PreviewRenderedPayload` | Emitted when the first screen is ready (at most once per load) |
|
|
420
422
|
|
|
421
423
|
### FilePreviewContent (advanced)
|
|
422
424
|
|
package/README.zh-CN.md
CHANGED
|
@@ -391,6 +391,7 @@ const files = [
|
|
|
391
391
|
| `close` | - | 关闭预览时触发 |
|
|
392
392
|
| `navigate` | `number` | 导航到其他文件时触发 |
|
|
393
393
|
| `error` | `PreviewErrorPayload` | 加载或渲染失败时触发(每次加载最多一次) |
|
|
394
|
+
| `rendered` | `PreviewRenderedPayload` | 首屏内容就绪时触发(每次加载最多一次) |
|
|
394
395
|
|
|
395
396
|
### FilePreviewEmbed Props
|
|
396
397
|
|
|
@@ -417,6 +418,7 @@ const files = [
|
|
|
417
418
|
|------|------|------|
|
|
418
419
|
| `navigate` | `number` | 导航到其他文件时触发 |
|
|
419
420
|
| `error` | `PreviewErrorPayload` | 加载或渲染失败时触发(每次加载最多一次) |
|
|
421
|
+
| `rendered` | `PreviewRenderedPayload` | 首屏内容就绪时触发(每次加载最多一次) |
|
|
420
422
|
|
|
421
423
|
### FilePreviewContent(高级用法)
|
|
422
424
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob, type FileLoader, type EmptyHintMode, type PreviewErrorPayload } from './core/index.js';
|
|
1
|
+
import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob, type FileLoader, type EmptyHintMode, type PreviewErrorPayload, type PreviewRenderedPayload } from './core/index.js';
|
|
2
2
|
import type { CustomRenderer } from './types.js';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -33,6 +33,11 @@ interface Props {
|
|
|
33
33
|
* 每次加载最多触发一次,payload 已由顶层补全 file/index/stage。
|
|
34
34
|
*/
|
|
35
35
|
onError?: (payload: PreviewErrorPayload) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 首屏内容可交互回调(与 `@rendered` 等价)。
|
|
38
|
+
* 每次加载最多触发一次,payload 含 file/index/fileType/耗时。
|
|
39
|
+
*/
|
|
40
|
+
onRendered?: (payload: PreviewRenderedPayload) => void;
|
|
36
41
|
/** 是否显示关闭按钮,默认根据 mode 决定(modal: true, embed: false) */
|
|
37
42
|
showClose?: boolean;
|
|
38
43
|
/** 是否显示下载按钮,默认 true */
|
|
@@ -53,11 +58,13 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
53
58
|
error: (payload: PreviewErrorPayload) => any;
|
|
54
59
|
close: () => any;
|
|
55
60
|
navigate: (index: number) => any;
|
|
61
|
+
rendered: (payload: PreviewRenderedPayload) => any;
|
|
56
62
|
"custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
|
|
57
63
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
58
64
|
onError?: ((payload: PreviewErrorPayload) => any) | undefined;
|
|
59
65
|
onClose?: (() => any) | undefined;
|
|
60
66
|
onNavigate?: ((index: number) => any) | undefined;
|
|
67
|
+
onRendered?: ((payload: PreviewRenderedPayload) => any) | undefined;
|
|
61
68
|
"onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
|
|
62
69
|
}>, {
|
|
63
70
|
requestInit: RequestInitFactory;
|
|
@@ -75,6 +82,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
75
82
|
messages: Partial<Record<Locale, Partial<Messages>>>;
|
|
76
83
|
headless: boolean;
|
|
77
84
|
onDownload: (file: PreviewFile) => void | Promise<void>;
|
|
85
|
+
onRendered: (payload: PreviewRenderedPayload) => void;
|
|
78
86
|
showClose: boolean;
|
|
79
87
|
showDownload: boolean;
|
|
80
88
|
showNavigation: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload } from './core/index.js';
|
|
1
|
+
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload, PreviewRenderedPayload } from './core/index.js';
|
|
2
2
|
import type { CustomRenderer } from './types.js';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -30,6 +30,8 @@ interface Props {
|
|
|
30
30
|
onClose?: () => void;
|
|
31
31
|
/** 加载/渲染失败回调(与 `@error` 等价) */
|
|
32
32
|
onError?: (payload: PreviewErrorPayload) => void;
|
|
33
|
+
/** 首屏内容可交互回调(与 `@rendered` 等价) */
|
|
34
|
+
onRendered?: (payload: PreviewRenderedPayload) => void;
|
|
33
35
|
/** 是否显示关闭按钮,默认根据 mode 决定(embed: false) */
|
|
34
36
|
showClose?: boolean;
|
|
35
37
|
/** 是否显示下载按钮,默认 true */
|
|
@@ -45,11 +47,13 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
45
47
|
error: (payload: PreviewErrorPayload) => any;
|
|
46
48
|
close: () => any;
|
|
47
49
|
navigate: (index: number) => any;
|
|
50
|
+
rendered: (payload: PreviewRenderedPayload) => any;
|
|
48
51
|
"custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
|
|
49
52
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
50
53
|
onError?: ((payload: PreviewErrorPayload) => any) | undefined;
|
|
51
54
|
onClose?: (() => any) | undefined;
|
|
52
55
|
onNavigate?: ((index: number) => any) | undefined;
|
|
56
|
+
onRendered?: ((payload: PreviewRenderedPayload) => any) | undefined;
|
|
53
57
|
"onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
|
|
54
58
|
}>, {
|
|
55
59
|
requestInit: RequestInitFactory;
|
|
@@ -68,6 +72,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
68
72
|
messages: Partial<Record<Locale, Partial<Messages>>>;
|
|
69
73
|
headless: boolean;
|
|
70
74
|
onDownload: (file: PreviewFile) => void | Promise<void>;
|
|
75
|
+
onRendered: (payload: PreviewRenderedPayload) => void;
|
|
71
76
|
showClose: boolean;
|
|
72
77
|
showDownload: boolean;
|
|
73
78
|
showNavigation: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload } from './core/index.js';
|
|
1
|
+
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload, PreviewRenderedPayload } from './core/index.js';
|
|
2
2
|
import type { CustomRenderer } from './types.js';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -35,16 +35,20 @@ interface Props {
|
|
|
35
35
|
emptyHint?: EmptyHintMode;
|
|
36
36
|
/** 加载/渲染失败回调(与 `@error` 等价) */
|
|
37
37
|
onError?: (payload: PreviewErrorPayload) => void;
|
|
38
|
+
/** 首屏内容可交互回调(与 `@rendered` 等价) */
|
|
39
|
+
onRendered?: (payload: PreviewRenderedPayload) => void;
|
|
38
40
|
}
|
|
39
41
|
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
40
42
|
error: (payload: PreviewErrorPayload) => any;
|
|
41
43
|
close: () => any;
|
|
42
44
|
navigate: (index: number) => any;
|
|
45
|
+
rendered: (payload: PreviewRenderedPayload) => any;
|
|
43
46
|
"custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
|
|
44
47
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
45
48
|
onError?: ((payload: PreviewErrorPayload) => any) | undefined;
|
|
46
49
|
onClose?: (() => any) | undefined;
|
|
47
50
|
onNavigate?: ((index: number) => any) | undefined;
|
|
51
|
+
onRendered?: ((payload: PreviewRenderedPayload) => any) | undefined;
|
|
48
52
|
"onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
|
|
49
53
|
}>, {
|
|
50
54
|
requestInit: RequestInitFactory;
|
|
@@ -59,6 +63,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
59
63
|
messages: Partial<Record<Locale, Partial<Messages>>>;
|
|
60
64
|
headless: boolean;
|
|
61
65
|
onDownload: (file: PreviewFile) => void | Promise<void>;
|
|
66
|
+
onRendered: (payload: PreviewRenderedPayload) => void;
|
|
62
67
|
showClose: boolean;
|
|
63
68
|
showDownload: boolean;
|
|
64
69
|
showNavigation: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as s, openBlock as o, createElementBlock as p, createElementVNode as e, createVNode as n, unref as t, toDisplayString as f } from "vue";
|
|
2
2
|
import { FileMinus as c } from "lucide-vue-next";
|
|
3
|
-
import { u as i } from "./index-
|
|
3
|
+
import { u as i } from "./index-DBzyeU0G.mjs";
|
|
4
4
|
const a = { class: "vfp-renderer-empty" }, m = { class: "vfp-renderer-empty-content" }, _ = { class: "vfp-w-12 vfp-h-12 vfp-rounded-full vfp-bg-surface-2 vfp-flex vfp-items-center vfp-justify-center" }, l = { class: "vfp-renderer-empty-text" }, g = /* @__PURE__ */ s({
|
|
5
5
|
__name: "EmptyState",
|
|
6
6
|
setup(v) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as er, ref as qe, watch as tr, computed as te, openBlock as J, createElementBlock as Q, createElementVNode as F, toDisplayString as ne, unref as ae, createBlock as rr, createVNode as he, createCommentVNode as oe, normalizeStyle as ir, Fragment as nr, renderList as ar, createTextVNode as sr, normalizeClass as or } from "vue";
|
|
2
|
-
import { u as cr, a as fr, b as ur, J as hr,
|
|
2
|
+
import { u as cr, a as fr, b as ur, J as hr, d as lr } from "./index-DBzyeU0G.mjs";
|
|
3
3
|
import { User as dr, Users as Ve, Calendar as mt, Clock as Et, Tag as gt, Mail as pr, Paperclip as yr, Hash as br } from "lucide-vue-next";
|
|
4
4
|
import { _ as vr } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
5
|
var fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
@@ -12936,7 +12936,7 @@ const Ni = /* @__PURE__ */ mr(Vt), Li = {
|
|
|
12936
12936
|
const S = await c.value(a.url);
|
|
12937
12937
|
if (!S.ok) throw new hr("file.load_failed");
|
|
12938
12938
|
const L = await S.arrayBuffer(), V = new Ni(L);
|
|
12939
|
-
d.value = V.getFileData();
|
|
12939
|
+
d.value = V.getFileData(), u.ready();
|
|
12940
12940
|
} catch (S) {
|
|
12941
12941
|
console.error(n.value("msg.parse_failed") + ":", S), s.value = n.value("msg.parse_failed"), u.error(S);
|
|
12942
12942
|
} finally {
|
|
@@ -13188,7 +13188,7 @@ const Ni = /* @__PURE__ */ mr(Vt), Li = {
|
|
|
13188
13188
|
])
|
|
13189
13189
|
]));
|
|
13190
13190
|
}
|
|
13191
|
-
}), jn = /* @__PURE__ */ lr(kn, [["__scopeId", "data-v-
|
|
13191
|
+
}), jn = /* @__PURE__ */ lr(kn, [["__scopeId", "data-v-f95182ce"]]);
|
|
13192
13192
|
export {
|
|
13193
13193
|
jn as default
|
|
13194
13194
|
};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { defineComponent as fe, ref as v, watch as Z, onMounted as pe, onBeforeUnmount as ve, openBlock as d, createElementBlock as g, createBlock as de, createCommentVNode as M, createElementVNode as f, toDisplayString as L, unref as q, normalizeStyle as z, createVNode as he, Fragment as G, renderList as ee } from "vue";
|
|
2
|
+
import me from "@likecoin/epub-ts";
|
|
3
|
+
import { List as ge, ChevronLeft as be, ChevronRight as we, Minimize2 as xe, Maximize2 as ye, X as ke } from "lucide-vue-next";
|
|
4
|
+
import { u as _e, a as Te, b as ze, N as Ce, J as Se } from "./index-DBzyeU0G.mjs";
|
|
5
|
+
import { _ as Me } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
6
|
+
import { T as We } from "./base.types-DaftHyg7.mjs";
|
|
7
|
+
const Ee = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, $e = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
|
|
10
|
+
}, He = { class: "vfp-renderer-loading-content" }, Re = { class: "vfp-renderer-loading-text" }, Le = {
|
|
11
|
+
class: "vfp-flex vfp-items-center vfp-justify-between vfp-flex-shrink-0",
|
|
12
|
+
style: { padding: "12px 16px", "border-bottom": "1px solid rgba(255,255,255,0.1)" }
|
|
13
|
+
}, Ae = { style: { color: "white", "font-weight": "500", "font-size": "14px" } }, Fe = {
|
|
14
|
+
class: "vfp-flex-1 vfp-overflow-y-auto",
|
|
15
|
+
style: { padding: "8px 4px" }
|
|
16
|
+
}, Pe = ["title", "onClick", "onMouseenter", "onMouseleave"], Be = ["title", "onClick", "onMouseenter", "onMouseleave"], De = 794, je = /* @__PURE__ */ fe({
|
|
17
|
+
__name: "index",
|
|
18
|
+
props: {
|
|
19
|
+
url: {}
|
|
20
|
+
},
|
|
21
|
+
setup(te, { expose: oe }) {
|
|
22
|
+
const A = te, I = new We(), { t: p } = _e(), ae = Te(), F = ze(), b = v(1), y = v(1), l = v(null), W = v(!0), k = v(null), w = v(!1), x = v([]), s = v(!1), P = v("");
|
|
23
|
+
Z([b, y, w, s, () => x.value.length], () => {
|
|
24
|
+
I.notify();
|
|
25
|
+
});
|
|
26
|
+
let u = null, e = null, _ = 0, T = null;
|
|
27
|
+
const V = () => {
|
|
28
|
+
var t;
|
|
29
|
+
try {
|
|
30
|
+
(t = e == null ? void 0 : e.destroy) == null || t.call(e);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
u == null || u.destroy();
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
e = null, u = null, _ = 0, T = null;
|
|
38
|
+
}, re = () => {
|
|
39
|
+
e == null || e.prev();
|
|
40
|
+
}, le = () => {
|
|
41
|
+
e == null || e.next();
|
|
42
|
+
}, ne = () => {
|
|
43
|
+
w.value = !w.value, setTimeout(() => {
|
|
44
|
+
l.value && e && (e.resize(l.value.offsetWidth, l.value.offsetHeight), T && e.display(T), D());
|
|
45
|
+
}, 350);
|
|
46
|
+
}, se = () => {
|
|
47
|
+
s.value = !s.value;
|
|
48
|
+
}, X = (t) => {
|
|
49
|
+
P.value = t, e == null || e.display(t), s.value = !1;
|
|
50
|
+
}, c = (t) => t === P.value;
|
|
51
|
+
oe({
|
|
52
|
+
getToolbarGroups: () => [
|
|
53
|
+
{
|
|
54
|
+
items: [
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
icon: ge,
|
|
58
|
+
tooltip: p.value("toolbar.toc"),
|
|
59
|
+
action: se,
|
|
60
|
+
disabled: x.value.length === 0,
|
|
61
|
+
active: s.value
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
items: [
|
|
67
|
+
{
|
|
68
|
+
type: "button",
|
|
69
|
+
icon: be,
|
|
70
|
+
tooltip: p.value("toolbar.prev_page"),
|
|
71
|
+
action: re,
|
|
72
|
+
disabled: b.value <= 1
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "text",
|
|
76
|
+
content: `${b.value} / ${y.value}`,
|
|
77
|
+
minWidth: "4rem"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "button",
|
|
81
|
+
icon: we,
|
|
82
|
+
tooltip: p.value("toolbar.next_page"),
|
|
83
|
+
action: le,
|
|
84
|
+
disabled: b.value >= y.value
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
items: [
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
icon: w.value ? xe : ye,
|
|
93
|
+
tooltip: w.value ? p.value("toolbar.normal_width") : p.value("toolbar.full_width"),
|
|
94
|
+
action: ne,
|
|
95
|
+
active: w.value
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
onToolbarChange: (t) => I.subscribe(t)
|
|
101
|
+
});
|
|
102
|
+
const j = async () => {
|
|
103
|
+
if (F.begin(A.url), !!l.value) {
|
|
104
|
+
W.value = !0, k.value = null, x.value = [], s.value = !1, l.value.innerHTML = "", V();
|
|
105
|
+
try {
|
|
106
|
+
const t = await ae.value(A.url);
|
|
107
|
+
if (!t.ok)
|
|
108
|
+
throw new Ce(
|
|
109
|
+
new Se("request.failed", { status: t.status })
|
|
110
|
+
);
|
|
111
|
+
const n = await t.arrayBuffer(), o = me(n);
|
|
112
|
+
u = o;
|
|
113
|
+
const S = new Promise((h, a) => {
|
|
114
|
+
o.on("openFailed", (m) => {
|
|
115
|
+
a(m instanceof Error ? m : new Error("EPUB open failed"));
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
e = o.renderTo(l.value, {
|
|
119
|
+
manager: "continuous",
|
|
120
|
+
flow: "scrolled",
|
|
121
|
+
width: "100%",
|
|
122
|
+
height: "100%"
|
|
123
|
+
}), e.themes.register("default", {
|
|
124
|
+
body: {
|
|
125
|
+
background: "#ffffff !important",
|
|
126
|
+
color: "#1a1a1a !important",
|
|
127
|
+
"font-family": '"Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important',
|
|
128
|
+
"font-size": "16px !important",
|
|
129
|
+
"line-height": "2 !important",
|
|
130
|
+
padding: "40px 60px !important",
|
|
131
|
+
"max-width": "100% !important",
|
|
132
|
+
"box-sizing": "border-box !important",
|
|
133
|
+
"word-break": "break-word !important",
|
|
134
|
+
"overflow-wrap": "break-word !important"
|
|
135
|
+
},
|
|
136
|
+
p: { "text-indent": "2em !important", margin: "0.8em 0 !important" },
|
|
137
|
+
h1: { "text-align": "center !important", margin: "1.5em 0 1em !important" },
|
|
138
|
+
h2: { margin: "1.2em 0 0.8em !important" },
|
|
139
|
+
h3: { margin: "1em 0 0.6em !important" },
|
|
140
|
+
img: { "max-width": "100% !important", height: "auto !important" },
|
|
141
|
+
a: { color: "#2563eb !important", "text-decoration": "none !important" }
|
|
142
|
+
}), e.themes.select("default"), await Promise.race([u.ready, S]), u.locations.generate(1024).then(() => {
|
|
143
|
+
var m;
|
|
144
|
+
if (!u) return;
|
|
145
|
+
_ = u.locations.length();
|
|
146
|
+
const h = e == null ? void 0 : e.currentLocation(), a = ((m = h == null ? void 0 : h.start) == null ? void 0 : m.location) ?? 0;
|
|
147
|
+
b.value = a + 1, y.value = _;
|
|
148
|
+
}).catch(() => {
|
|
149
|
+
});
|
|
150
|
+
const r = await Promise.race([u.loaded.navigation, S]);
|
|
151
|
+
Array.isArray(r == null ? void 0 : r.toc) && (x.value = r.toc), await Promise.race([e.display(), S]), W.value = !1, F.ready(), b.value = 1, y.value = _ || 1, e.on("relocated", (h) => {
|
|
152
|
+
var J, K, Q;
|
|
153
|
+
const a = h;
|
|
154
|
+
if ((J = a == null ? void 0 : a.start) != null && J.cfi && (T = a.start.cfi), (K = a == null ? void 0 : a.start) != null && K.href) {
|
|
155
|
+
const N = a.start.href, O = [], Y = (ce) => {
|
|
156
|
+
for (const H of ce) {
|
|
157
|
+
const R = H.href.split("#")[0];
|
|
158
|
+
R && (N === R || N.endsWith("/" + R) || N.endsWith(R)) && O.push(H.href), H.subitems && Y(H.subitems);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
Y(x.value), O.length === 1 && (P.value = O[0]);
|
|
162
|
+
}
|
|
163
|
+
const m = (Q = a == null ? void 0 : a.start) == null ? void 0 : Q.location;
|
|
164
|
+
typeof m == "number" && _ > 0 && (b.value = m + 1, y.value = _);
|
|
165
|
+
});
|
|
166
|
+
} catch (t) {
|
|
167
|
+
console.error(p.value("epub.load_failed") + ":", t), k.value = p.value("epub.load_failed"), W.value = !1, F.error(t);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
let E = null, C = null, $ = { width: 0, height: 0 }, U = !0;
|
|
172
|
+
const ie = () => {
|
|
173
|
+
if (!(!l.value || !e)) {
|
|
174
|
+
if (e.resize(l.value.offsetWidth, l.value.offsetHeight), T)
|
|
175
|
+
try {
|
|
176
|
+
e.display(T);
|
|
177
|
+
} catch {
|
|
178
|
+
}
|
|
179
|
+
D();
|
|
180
|
+
}
|
|
181
|
+
}, ue = () => {
|
|
182
|
+
l.value && (E = new ResizeObserver(() => {
|
|
183
|
+
if (!l.value) return;
|
|
184
|
+
if (U) {
|
|
185
|
+
U = !1, $ = { width: l.value.offsetWidth, height: l.value.offsetHeight };
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const t = { width: l.value.offsetWidth, height: l.value.offsetHeight }, n = Math.abs($.width - t.width), o = Math.abs($.height - t.height);
|
|
189
|
+
n < 10 && o < 10 || ($ = t, C !== null && clearTimeout(C), C = window.setTimeout(ie, 350));
|
|
190
|
+
}), E.observe(l.value));
|
|
191
|
+
};
|
|
192
|
+
let i = null;
|
|
193
|
+
const B = () => {
|
|
194
|
+
var n;
|
|
195
|
+
if (!i) return;
|
|
196
|
+
const t = i;
|
|
197
|
+
if (t.scrollTop + t.clientHeight >= t.scrollHeight - 200)
|
|
198
|
+
try {
|
|
199
|
+
const o = e == null ? void 0 : e.manager;
|
|
200
|
+
(n = o == null ? void 0 : o.check) == null || n.call(o, 500, 500);
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
}, D = () => {
|
|
204
|
+
i && (i.removeEventListener("scroll", B), i = null);
|
|
205
|
+
const t = () => {
|
|
206
|
+
var n;
|
|
207
|
+
i = ((n = l.value) == null ? void 0 : n.querySelector(".epub-container")) ?? null, i ? i.addEventListener("scroll", B, { passive: !0 }) : requestAnimationFrame(t);
|
|
208
|
+
};
|
|
209
|
+
requestAnimationFrame(t);
|
|
210
|
+
};
|
|
211
|
+
return pe(() => {
|
|
212
|
+
j(), ue(), D();
|
|
213
|
+
}), Z(() => A.url, (t) => {
|
|
214
|
+
t && j();
|
|
215
|
+
}), ve(() => {
|
|
216
|
+
E && E.disconnect(), C !== null && clearTimeout(C), i == null || i.removeEventListener("scroll", B), V();
|
|
217
|
+
}), (t, n) => (d(), g("div", Ee, [
|
|
218
|
+
k.value ? (d(), de(Me, {
|
|
219
|
+
key: 0,
|
|
220
|
+
message: k.value,
|
|
221
|
+
class: "vfp-absolute vfp-inset-0"
|
|
222
|
+
}, null, 8, ["message"])) : M("", !0),
|
|
223
|
+
W.value && !k.value ? (d(), g("div", $e, [
|
|
224
|
+
f("div", He, [
|
|
225
|
+
n[2] || (n[2] = f("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
226
|
+
f("span", Re, L(q(p)("common.loading")), 1)
|
|
227
|
+
])
|
|
228
|
+
])) : M("", !0),
|
|
229
|
+
x.value.length > 0 ? (d(), g("div", {
|
|
230
|
+
key: 2,
|
|
231
|
+
class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex",
|
|
232
|
+
style: z({ opacity: s.value ? 1 : 0, pointerEvents: s.value ? "auto" : "none", transition: "opacity 0.3s" })
|
|
233
|
+
}, [
|
|
234
|
+
f("div", {
|
|
235
|
+
class: "vfp-w-72 vfp-h-full vfp-flex vfp-flex-col",
|
|
236
|
+
style: z({
|
|
237
|
+
maxWidth: "80%",
|
|
238
|
+
background: "rgba(0,0,0,0.9)",
|
|
239
|
+
backdropFilter: "blur(12px)",
|
|
240
|
+
borderRight: "1px solid rgba(255,255,255,0.1)",
|
|
241
|
+
boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)",
|
|
242
|
+
transform: s.value ? "translateX(0)" : "translateX(-100%)",
|
|
243
|
+
transition: "transform 0.3s ease"
|
|
244
|
+
})
|
|
245
|
+
}, [
|
|
246
|
+
f("div", Le, [
|
|
247
|
+
f("span", Ae, L(q(p)("toolbar.toc")), 1),
|
|
248
|
+
f("button", {
|
|
249
|
+
style: { color: "rgba(255,255,255,0.6)", background: "none", border: "none", cursor: "pointer", padding: "4px" },
|
|
250
|
+
onClick: n[0] || (n[0] = (o) => s.value = !1)
|
|
251
|
+
}, [
|
|
252
|
+
he(q(ke), { style: { width: "16px", height: "16px" } })
|
|
253
|
+
])
|
|
254
|
+
]),
|
|
255
|
+
f("div", Fe, [
|
|
256
|
+
(d(!0), g(G, null, ee(x.value, (o, S) => (d(), g(G, {
|
|
257
|
+
key: `${o.href}-${S}`
|
|
258
|
+
}, [
|
|
259
|
+
f("button", {
|
|
260
|
+
style: z({
|
|
261
|
+
width: "100%",
|
|
262
|
+
textAlign: "left",
|
|
263
|
+
padding: "8px 12px",
|
|
264
|
+
fontSize: "14px",
|
|
265
|
+
color: c(o.href) ? "white" : "rgba(255,255,255,0.7)",
|
|
266
|
+
fontWeight: c(o.href) ? "500" : "400",
|
|
267
|
+
background: c(o.href) ? "rgba(255,255,255,0.15)" : "none",
|
|
268
|
+
border: "none",
|
|
269
|
+
cursor: "pointer",
|
|
270
|
+
borderRadius: "4px",
|
|
271
|
+
overflow: "hidden",
|
|
272
|
+
textOverflow: "ellipsis",
|
|
273
|
+
whiteSpace: "nowrap",
|
|
274
|
+
display: "block",
|
|
275
|
+
transition: "all 0.15s"
|
|
276
|
+
}),
|
|
277
|
+
title: o.label,
|
|
278
|
+
onClick: (r) => X(o.href),
|
|
279
|
+
onMouseenter: (r) => !c(o.href) && (r.target.style.background = "rgba(255,255,255,0.1)"),
|
|
280
|
+
onMouseleave: (r) => !c(o.href) && (r.target.style.background = "none")
|
|
281
|
+
}, L(o.label.trim()), 45, Pe),
|
|
282
|
+
o.subitems && o.subitems.length > 0 ? (d(!0), g(G, { key: 0 }, ee(o.subitems, (r, h) => (d(), g("button", {
|
|
283
|
+
key: `${r.href}-${h}`,
|
|
284
|
+
style: z({
|
|
285
|
+
width: "100%",
|
|
286
|
+
textAlign: "left",
|
|
287
|
+
padding: "8px 12px 8px 28px",
|
|
288
|
+
fontSize: "13px",
|
|
289
|
+
color: c(r.href) ? "white" : "rgba(255,255,255,0.6)",
|
|
290
|
+
fontWeight: c(r.href) ? "500" : "400",
|
|
291
|
+
background: c(r.href) ? "rgba(255,255,255,0.15)" : "none",
|
|
292
|
+
border: "none",
|
|
293
|
+
cursor: "pointer",
|
|
294
|
+
borderRadius: "4px",
|
|
295
|
+
overflow: "hidden",
|
|
296
|
+
textOverflow: "ellipsis",
|
|
297
|
+
whiteSpace: "nowrap",
|
|
298
|
+
display: "block",
|
|
299
|
+
transition: "all 0.15s"
|
|
300
|
+
}),
|
|
301
|
+
title: r.label,
|
|
302
|
+
onClick: (a) => X(r.href),
|
|
303
|
+
onMouseenter: (a) => !c(r.href) && (a.target.style.background = "rgba(255,255,255,0.1)"),
|
|
304
|
+
onMouseleave: (a) => !c(r.href) && (a.target.style.background = "none")
|
|
305
|
+
}, L(r.label.trim()), 45, Be))), 128)) : M("", !0)
|
|
306
|
+
], 64))), 128))
|
|
307
|
+
])
|
|
308
|
+
], 4),
|
|
309
|
+
f("div", {
|
|
310
|
+
class: "vfp-flex-1",
|
|
311
|
+
style: z({ background: s.value ? "rgba(0,0,0,0.3)" : "transparent", transition: "background 0.3s" }),
|
|
312
|
+
onClick: n[1] || (n[1] = (o) => s.value = !1)
|
|
313
|
+
}, null, 4)
|
|
314
|
+
], 4)) : M("", !0),
|
|
315
|
+
k.value ? M("", !0) : (d(), g("div", {
|
|
316
|
+
key: 3,
|
|
317
|
+
ref_key: "viewerRef",
|
|
318
|
+
ref: l,
|
|
319
|
+
class: "vfp-h-full vfp-bg-surface-toolbar",
|
|
320
|
+
style: z({
|
|
321
|
+
width: w.value ? "100%" : `${De}px`,
|
|
322
|
+
maxWidth: "100%",
|
|
323
|
+
transition: "width 0.3s ease",
|
|
324
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
|
|
325
|
+
overflow: "hidden"
|
|
326
|
+
})
|
|
327
|
+
}, null, 4))
|
|
328
|
+
]));
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
export {
|
|
332
|
+
je as default
|
|
333
|
+
};
|