@eternalheart/vue-file-preview 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-Dna6LmVT.mjs} +1 -1
- package/lib/chunks/{avifLoader-CAUzjn-d-CnJpGYJ2.mjs → avifLoader-CAUzjn-d-dPsP28D5.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-g_dLrWLP.mjs → heicLoader-D_9PukkA-T-k1DSgY.mjs} +1 -1
- package/lib/chunks/{index-c-pYJEmH.mjs → index-B5hprvcF.mjs} +1747 -1709
- package/lib/chunks/index-BN__EwfT.mjs +333 -0
- package/lib/chunks/{index-z9RqL2wI.mjs → index-BPutNVAf.mjs} +453 -453
- package/lib/chunks/{index-BfOWoMpY.mjs → index-B_Spz6Wn.mjs} +77 -77
- package/lib/chunks/{index-D5IF9F-D.mjs → index-BjHEHkZ8.mjs} +22 -22
- package/lib/chunks/{index-LPGxJDnT.mjs → index-BlZ6RmeR.mjs} +18 -18
- package/lib/chunks/{index-CrVQPnFj.mjs → index-C95y29OL.mjs} +18 -18
- package/lib/chunks/{index-DFeKS8tR.mjs → index-CegPYMyO.mjs} +22 -22
- package/lib/chunks/{index-C4hIk6pa.mjs → index-CqOGKCyE.mjs} +2 -2
- package/lib/chunks/{index-6XZXYqbp.mjs → index-Cv3Sg87O.mjs} +29 -32
- package/lib/chunks/{index-zLQlyNR2.mjs → index-DHba2Axz.mjs} +62 -62
- package/lib/chunks/{index-CWPdNhoe.mjs → index-DInI3RTN.mjs} +60 -60
- package/lib/chunks/{index-C8lyQPe3.mjs → index-DXzvgRuo.mjs} +3 -3
- package/lib/chunks/{index-BPSzwMOC.mjs → index-DcvlMm9Q.mjs} +46 -46
- package/lib/chunks/index-Dnyl1HQk.mjs +51 -0
- package/lib/chunks/{index-aKiIuKKx.mjs → index-JjVQZbDt.mjs} +50 -50
- package/lib/chunks/{index-DZe0BxAB.mjs → index-QPk2c2Tl.mjs} +20 -20
- package/lib/chunks/{index-DM8Dfl-m.mjs → index-TZv0MqBH.mjs} +15 -15
- package/lib/chunks/{index-BzwJ0VWu.mjs → index-cRhwUlQN.mjs} +33 -33
- package/lib/chunks/{index-BYQ9S7Mk.mjs → index-dOxDeWYi.mjs} +30 -30
- package/lib/chunks/{index-Bg8poMIm.mjs → index-eNZr1h6f.mjs} +29 -29
- package/lib/chunks/{index-Bf94DwQu.mjs → index-oJF-hur2.mjs} +24 -24
- package/lib/chunks/{jp2Loader-Dig19xyo-fCO1knZ0.mjs → jp2Loader-Dig19xyo-hrIg_KJ3.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-DihMskai.mjs → psdLoader-C0tKUXXl-B2cJ4s7t.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-BSfDPl-z.mjs → rawLoader-C-tPeFAB-BNV-Wmzr.mjs} +1 -1
- package/lib/chunks/{tiffLoader-BlhByX8w-JY5DaTre.mjs → tiffLoader-BlhByX8w-BzSrLE9Y.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-C-ztcJBE.mjs → useShikiHighlight-CpL0RAQg.mjs} +1 -1
- package/lib/composables/usePreviewEvents.d.ts +2 -2
- package/lib/composables/useRequest.d.ts +8 -2
- package/lib/core/events.d.ts +18 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/index.cjs +54 -54
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { u as
|
|
1
|
+
import { defineComponent as $, ref as o, watch as w, nextTick as B, computed as T, openBlock as i, createElementBlock as p, createElementVNode as l, toDisplayString as N, unref as I, createBlock as F, normalizeStyle as d, Fragment as V, renderList as C } from "vue";
|
|
2
|
+
import { u as R, a as j, b as q, V as z, J, c as O, n as U } from "./index-B5hprvcF.mjs";
|
|
3
3
|
import W from "mammoth";
|
|
4
4
|
import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
5
|
const Y = {
|
|
@@ -9,55 +9,55 @@ const Y = {
|
|
|
9
9
|
key: 2,
|
|
10
10
|
class: "vfp-docx-container vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
11
11
|
style: { background: "rgba(0, 0, 0, 0.15)" }
|
|
12
|
-
}, ee = ["innerHTML"], te = ["innerHTML"], b = 1123, k = 60, E = 50, ne = 24, ie = /* @__PURE__ */
|
|
12
|
+
}, ee = ["innerHTML"], te = ["innerHTML"], b = 1123, k = 60, E = 50, ne = 24, ie = /* @__PURE__ */ $({
|
|
13
13
|
__name: "index",
|
|
14
14
|
props: {
|
|
15
15
|
url: {}
|
|
16
16
|
},
|
|
17
17
|
setup(G, { expose: H }) {
|
|
18
|
-
const P = b - k * 2,
|
|
19
|
-
|
|
18
|
+
const P = b - k * 2, v = G, { t: f } = R(), A = j(), m = q(), a = o(""), h = o(!0), c = o(null), s = o([]), _ = o({}), g = o(null), S = async () => {
|
|
19
|
+
m.begin(v.url), h.value = !0, c.value = null, a.value = "", s.value = [], _.value = {};
|
|
20
20
|
try {
|
|
21
|
-
const e = await A.value(
|
|
22
|
-
if (!e.ok) throw new
|
|
23
|
-
const n = await e.arrayBuffer(), [t,
|
|
24
|
-
W.convertToHtml({ arrayBuffer: n }, { styleMap:
|
|
25
|
-
|
|
21
|
+
const e = await A.value(v.url);
|
|
22
|
+
if (!e.ok) throw new J("file.load_failed");
|
|
23
|
+
const n = await e.arrayBuffer(), [t, r] = await Promise.all([
|
|
24
|
+
W.convertToHtml({ arrayBuffer: n }, { styleMap: O }),
|
|
25
|
+
U(n).catch(() => ({}))
|
|
26
26
|
]);
|
|
27
|
-
|
|
27
|
+
_.value = r, a.value = t.value, m.ready();
|
|
28
28
|
} catch (e) {
|
|
29
|
-
console.error(
|
|
29
|
+
console.error(f.value("docx.parse_failed") + ":", e), c.value = f.value("docx.parse_failed"), m.error(e);
|
|
30
30
|
} finally {
|
|
31
|
-
|
|
31
|
+
h.value = !1;
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, D = () => {
|
|
34
34
|
const e = g.value;
|
|
35
|
-
if (!e || !
|
|
35
|
+
if (!e || !a.value) return;
|
|
36
36
|
const n = Array.from(e.children);
|
|
37
37
|
if (n.length === 0) {
|
|
38
|
-
s.value = [
|
|
38
|
+
s.value = [a.value];
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const t = [[]];
|
|
42
|
-
let
|
|
42
|
+
let r = 0;
|
|
43
43
|
for (const u of n) {
|
|
44
44
|
const y = u.offsetHeight;
|
|
45
|
-
|
|
45
|
+
r > 0 && r + y > P && (t.push([]), r = 0), t[t.length - 1].push(u.outerHTML), r += y;
|
|
46
46
|
}
|
|
47
47
|
t.length === 0 && t.push([]), s.value = t.map((u) => u.join(""));
|
|
48
48
|
};
|
|
49
|
-
w(() =>
|
|
49
|
+
w(() => v.url, (e) => {
|
|
50
50
|
e && S();
|
|
51
|
-
}, { immediate: !0 }), w(
|
|
52
|
-
|
|
51
|
+
}, { immediate: !0 }), w(a, async () => {
|
|
52
|
+
a.value && (await B(), requestAnimationFrame(() => D()));
|
|
53
53
|
});
|
|
54
|
-
const x = T(() =>
|
|
54
|
+
const x = T(() => z(_.value)), L = T(() => ({
|
|
55
55
|
...x.value,
|
|
56
56
|
position: "absolute",
|
|
57
57
|
visibility: "hidden",
|
|
58
58
|
width: `${794 - E * 2}px`,
|
|
59
59
|
pointerEvents: "none"
|
|
60
|
-
})),
|
|
60
|
+
})), M = {
|
|
61
61
|
width: "100%",
|
|
62
62
|
maxWidth: "794px",
|
|
63
63
|
minHeight: `${b}px`,
|
|
@@ -68,10 +68,10 @@ const Y = {
|
|
|
68
68
|
};
|
|
69
69
|
return H({
|
|
70
70
|
getToolbarGroups: () => []
|
|
71
|
-
}), (e, n) =>
|
|
71
|
+
}), (e, n) => h.value ? (i(), p("div", Y, [
|
|
72
72
|
l("div", K, [
|
|
73
73
|
n[0] || (n[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
74
|
-
l("span", Q,
|
|
74
|
+
l("span", Q, N(I(f)("common.loading")), 1)
|
|
75
75
|
])
|
|
76
76
|
])) : c.value ? (i(), F(X, {
|
|
77
77
|
key: 1,
|
|
@@ -80,22 +80,22 @@ const Y = {
|
|
|
80
80
|
l("div", {
|
|
81
81
|
ref_key: "measureRef",
|
|
82
82
|
ref: g,
|
|
83
|
-
style:
|
|
84
|
-
innerHTML:
|
|
83
|
+
style: d(L.value),
|
|
84
|
+
innerHTML: a.value
|
|
85
85
|
}, null, 12, ee),
|
|
86
86
|
l("div", {
|
|
87
87
|
class: "vfp-flex vfp-flex-col vfp-items-center",
|
|
88
|
-
style:
|
|
88
|
+
style: d({ gap: `${ne}px` })
|
|
89
89
|
}, [
|
|
90
|
-
(i(!0), p(
|
|
91
|
-
key:
|
|
92
|
-
style:
|
|
93
|
-
...
|
|
90
|
+
(i(!0), p(V, null, C(s.value.length > 0 ? s.value : [""], (t, r) => (i(), p("div", {
|
|
91
|
+
key: r,
|
|
92
|
+
style: d({
|
|
93
|
+
...M,
|
|
94
94
|
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(0, 0, 0, 0.10)"
|
|
95
95
|
})
|
|
96
96
|
}, [
|
|
97
97
|
l("div", {
|
|
98
|
-
style:
|
|
98
|
+
style: d(x.value),
|
|
99
99
|
innerHTML: t
|
|
100
100
|
}, null, 12, te)
|
|
101
101
|
], 4))), 128))
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as D, ref as m, onMounted as z, watch as M, onBeforeUnmount as G, openBlock as v, createElementBlock as w, createElementVNode as g, toDisplayString as N, unref as S, createCommentVNode as b, createBlock as B, normalizeStyle as C } from "vue";
|
|
2
2
|
import { S as H } from "./index-CyBXARuf.mjs";
|
|
3
|
-
import { u as R, a as W, b as
|
|
3
|
+
import { u as R, a as W, b as E, f as F, G as L, Y as O, Q } from "./index-B5hprvcF.mjs";
|
|
4
4
|
import { _ as V } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
-
const
|
|
5
|
+
const Y = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, q = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
8
|
-
},
|
|
8
|
+
}, A = { class: "vfp-renderer-loading-content" }, I = { class: "vfp-renderer-loading-text" }, K = /* @__PURE__ */ D({
|
|
9
9
|
__name: "index",
|
|
10
10
|
props: {
|
|
11
11
|
url: {},
|
|
12
12
|
fileName: {}
|
|
13
13
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
14
|
+
setup(y, { expose: T }) {
|
|
15
|
+
const a = y, { t: d } = R(), k = W(), h = E(), r = m(!0), n = m(null), l = m(null);
|
|
16
16
|
let o = null, u = null, i = null, c = { width: 0, height: 0 };
|
|
17
|
-
const
|
|
17
|
+
const p = () => {
|
|
18
18
|
if (!l.value) return { width: 800, height: 600 };
|
|
19
19
|
const e = l.value.clientWidth, t = l.value.clientHeight, s = e > 100 ? e : 800, f = t > 100 ? t : 600;
|
|
20
20
|
return { width: s, height: f };
|
|
21
21
|
}, _ = () => {
|
|
22
22
|
if (!l.value || !o) return;
|
|
23
23
|
l.value.innerHTML = "";
|
|
24
|
-
const { width: e, height: t } =
|
|
24
|
+
const { width: e, height: t } = p(), s = e < 640;
|
|
25
25
|
new H(l.value, {
|
|
26
26
|
mode: "read",
|
|
27
27
|
showToolbar: !1,
|
|
@@ -43,13 +43,13 @@ const q = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
43
43
|
}
|
|
44
44
|
}).loadData(o);
|
|
45
45
|
}, x = async () => {
|
|
46
|
-
if (
|
|
47
|
-
r.value = !0,
|
|
46
|
+
if (h.begin(a.url), !!l.value) {
|
|
47
|
+
r.value = !0, n.value = null;
|
|
48
48
|
try {
|
|
49
|
-
const e = await
|
|
50
|
-
o =
|
|
49
|
+
const e = await F(a.url, { fetcher: k.value }), t = L(e, { delimiter: O(a.fileName) });
|
|
50
|
+
o = Q(t.header, t.rows, a.fileName), _(), r.value = !1, h.ready();
|
|
51
51
|
} catch (e) {
|
|
52
|
-
console.error(d.value("csv.parse_failed") + ":", e),
|
|
52
|
+
console.error(d.value("csv.parse_failed") + ":", e), n.value = d.value("csv.load_failed"), r.value = !1, h.error(e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
};
|
|
@@ -58,10 +58,10 @@ const q = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
58
58
|
let e = !0;
|
|
59
59
|
u = new ResizeObserver(() => {
|
|
60
60
|
if (e) {
|
|
61
|
-
e = !1, c =
|
|
61
|
+
e = !1, c = p();
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const t =
|
|
64
|
+
const t = p(), s = Math.abs(c.width - t.width), f = Math.abs(c.height - t.height);
|
|
65
65
|
s < 10 && f < 10 || (c = t, i !== null && clearTimeout(i), i = window.setTimeout(() => {
|
|
66
66
|
o && _();
|
|
67
67
|
}, 500));
|
|
@@ -69,36 +69,36 @@ const q = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
69
69
|
requestAnimationFrame(() => x());
|
|
70
70
|
}, 100);
|
|
71
71
|
}), M(
|
|
72
|
-
() =>
|
|
72
|
+
() => a.url,
|
|
73
73
|
() => {
|
|
74
74
|
x();
|
|
75
75
|
}
|
|
76
|
-
),
|
|
76
|
+
), G(() => {
|
|
77
77
|
u && u.disconnect(), i !== null && clearTimeout(i), o = null, l.value && (l.value.innerHTML = "");
|
|
78
|
-
}),
|
|
78
|
+
}), T({
|
|
79
79
|
getToolbarGroups: () => []
|
|
80
|
-
}), (e, t) => (v(),
|
|
81
|
-
r.value ? (v(),
|
|
82
|
-
|
|
83
|
-
t[0] || (t[0] =
|
|
84
|
-
|
|
80
|
+
}), (e, t) => (v(), w("div", Y, [
|
|
81
|
+
r.value ? (v(), w("div", q, [
|
|
82
|
+
g("div", A, [
|
|
83
|
+
t[0] || (t[0] = g("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
84
|
+
g("p", I, N(S(d)("csv.loading")), 1)
|
|
85
85
|
])
|
|
86
|
-
])) :
|
|
87
|
-
|
|
86
|
+
])) : b("", !0),
|
|
87
|
+
n.value && !r.value ? (v(), B(V, {
|
|
88
88
|
key: 1,
|
|
89
|
-
message:
|
|
89
|
+
message: n.value,
|
|
90
90
|
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
91
|
-
}, null, 8, ["message"])) :
|
|
92
|
-
|
|
91
|
+
}, null, 8, ["message"])) : b("", !0),
|
|
92
|
+
n.value ? b("", !0) : (v(), w("div", {
|
|
93
93
|
key: 2,
|
|
94
94
|
ref_key: "containerRef",
|
|
95
95
|
ref: l,
|
|
96
96
|
class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
|
|
97
|
-
style:
|
|
97
|
+
style: C({ opacity: r.value ? 0 : 1 })
|
|
98
98
|
}, null, 4))
|
|
99
99
|
]));
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
export {
|
|
103
|
-
|
|
103
|
+
K as default
|
|
104
104
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as $, ref as f, computed as d, watch as T, unref as m, openBlock as t, createElementBlock as i, createElementVNode as l, toDisplayString as
|
|
1
|
+
import { defineComponent as $, ref as f, computed as d, watch as T, unref as m, openBlock as t, createElementBlock as i, createElementVNode as l, toDisplayString as _, createBlock as E, normalizeClass as H, normalizeStyle as z, Fragment as S, renderList as G } from "vue";
|
|
2
2
|
import { WrapText as M, Code as P, Eye as W } from "lucide-vue-next";
|
|
3
|
-
import { u as
|
|
4
|
-
import { u as
|
|
5
|
-
import { _ as
|
|
6
|
-
import { _ as
|
|
7
|
-
import { T as
|
|
8
|
-
const
|
|
3
|
+
import { u as X, a as D, b as R, X as V, S as j, T as q, f as A } from "./index-B5hprvcF.mjs";
|
|
4
|
+
import { u as I } from "./useShikiHighlight-CpL0RAQg.mjs";
|
|
5
|
+
import { _ as J } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
6
|
+
import { _ as K } from "./EmptyState.vue_vue_type_script_setup_true_lang-Dna6LmVT.mjs";
|
|
7
|
+
import { T as O } from "./base.types-DaftHyg7.mjs";
|
|
8
|
+
const Q = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "vfp-renderer-loading"
|
|
11
|
-
},
|
|
11
|
+
}, U = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
|
|
12
12
|
key: 3,
|
|
13
13
|
class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
|
|
14
14
|
}, ee = ["srcdoc", "title"], le = {
|
|
@@ -26,26 +26,26 @@ const U = {
|
|
|
26
26
|
fileName: {},
|
|
27
27
|
emptyHint: {}
|
|
28
28
|
},
|
|
29
|
-
setup(
|
|
30
|
-
const v =
|
|
31
|
-
() => !p.value && !c.value &&
|
|
29
|
+
setup(b, { expose: C }) {
|
|
30
|
+
const v = b, w = new O(), { t: s } = X(), L = D(), g = R(), o = f(!0), a = f(!1), r = f(""), p = f(!0), c = f(null), n = d(() => V(v.fileName)), N = d(() => n.value !== "text" ? r.value : ""), { lineHtmls: y, loading: B } = I(N, n), x = d(() => n.value === "html"), F = d(
|
|
31
|
+
() => !p.value && !c.value && j(r.value) && q(v.emptyHint, "textual")
|
|
32
32
|
);
|
|
33
33
|
T([o, a, p, x], () => {
|
|
34
|
-
|
|
34
|
+
w.notify();
|
|
35
35
|
}), T(() => v.url, async () => {
|
|
36
|
-
|
|
36
|
+
g.begin(v.url), p.value = !0, c.value = null;
|
|
37
37
|
try {
|
|
38
|
-
const e = await
|
|
39
|
-
r.value = e;
|
|
38
|
+
const e = await A(v.url, { fetcher: L.value });
|
|
39
|
+
r.value = e, g.ready();
|
|
40
40
|
} catch (e) {
|
|
41
|
-
console.error(e), c.value = s.value("text.load_failed"),
|
|
41
|
+
console.error(e), c.value = s.value("text.load_failed"), g.error(e);
|
|
42
42
|
} finally {
|
|
43
43
|
p.value = !1;
|
|
44
44
|
}
|
|
45
45
|
}, { immediate: !0 });
|
|
46
46
|
const k = d(() => r.value.split(`
|
|
47
47
|
`));
|
|
48
|
-
return
|
|
48
|
+
return C({
|
|
49
49
|
getToolbarGroups: () => {
|
|
50
50
|
const e = [];
|
|
51
51
|
return e.push({
|
|
@@ -74,36 +74,36 @@ const U = {
|
|
|
74
74
|
]
|
|
75
75
|
}), e;
|
|
76
76
|
},
|
|
77
|
-
onToolbarChange: (e) =>
|
|
78
|
-
}), (e, u) => p.value || n.value !== "text" && m(B) ? (t(), i("div",
|
|
79
|
-
l("div",
|
|
77
|
+
onToolbarChange: (e) => w.subscribe(e)
|
|
78
|
+
}), (e, u) => p.value || n.value !== "text" && m(B) ? (t(), i("div", Q, [
|
|
79
|
+
l("div", U, [
|
|
80
80
|
u[0] || (u[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
81
|
-
l("span", Y,
|
|
81
|
+
l("span", Y, _(m(s)("common.loading")), 1)
|
|
82
82
|
])
|
|
83
|
-
])) : c.value ? (t(), E(
|
|
83
|
+
])) : c.value ? (t(), E(J, {
|
|
84
84
|
key: 1,
|
|
85
85
|
message: c.value
|
|
86
|
-
}, null, 8, ["message"])) : F.value ? (t(), E(
|
|
86
|
+
}, null, 8, ["message"])) : F.value ? (t(), E(K, { key: 2 })) : a.value && n.value === "html" ? (t(), i("div", Z, [
|
|
87
87
|
l("iframe", {
|
|
88
88
|
srcdoc: r.value,
|
|
89
89
|
sandbox: "allow-same-origin",
|
|
90
90
|
class: "vfp-w-full vfp-h-full vfp-border-0",
|
|
91
|
-
title:
|
|
91
|
+
title: b.fileName
|
|
92
92
|
}, null, 8, ee)
|
|
93
|
-
])) : n.value === "text" || m(
|
|
93
|
+
])) : n.value === "text" || m(y).length === 0 ? (t(), i("div", le, [
|
|
94
94
|
l("pre", {
|
|
95
95
|
class: H(["vfp-py-6 vfp-px-4 vfp-text-fg-primary vfp-font-mono vfp-text-sm", o.value ? "vfp-whitespace-pre-wrap vfp-break-words" : "vfp-whitespace-pre"])
|
|
96
|
-
},
|
|
96
|
+
}, _(r.value), 3)
|
|
97
97
|
])) : (t(), i("div", te, [
|
|
98
98
|
l("div", {
|
|
99
99
|
class: H(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !o.value }]),
|
|
100
100
|
style: z({ gridTemplateRows: `repeat(${k.value.length}, auto) minmax(1.5rem, 1fr)` })
|
|
101
101
|
}, [
|
|
102
|
-
(t(!0), i(
|
|
103
|
-
l("span", oe, h
|
|
102
|
+
(t(!0), i(S, null, G(k.value, (ne, h) => (t(), i(S, { key: h }, [
|
|
103
|
+
l("span", oe, _(h + 1), 1),
|
|
104
104
|
l("span", {
|
|
105
105
|
class: "vfp-code-line",
|
|
106
|
-
innerHTML: m(
|
|
106
|
+
innerHTML: m(y)[h] ?? ""
|
|
107
107
|
}, null, 8, ae)
|
|
108
108
|
], 64))), 128)),
|
|
109
109
|
u[1] || (u[1] = l("span", { class: "vfp-code-gutter-filler" }, null, -1)),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as ge, ref as u, watch as ce, onMounted as ve, onBeforeUnmount as de, openBlock as N, createElementBlock as D, createBlock as Ne, createCommentVNode as W, createElementVNode as c, toDisplayString as me, unref as B, normalizeStyle as U, createVNode as be, h as R } from "vue";
|
|
2
|
-
import { u as Re, a as ze, b as Ae, J as he,
|
|
2
|
+
import { u as Re, a as ze, b as Ae, J as he, d as Le } from "./index-B5hprvcF.mjs";
|
|
3
3
|
import { List as Pe, ChevronLeft as Fe, ChevronRight as He, Minimize2 as $e, Maximize2 as De, X as We } from "lucide-vue-next";
|
|
4
4
|
import "foliate-js/view.js";
|
|
5
5
|
import { _ as Be } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
@@ -91,7 +91,7 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
91
91
|
try {
|
|
92
92
|
await Promise.race([
|
|
93
93
|
t,
|
|
94
|
-
new Promise((
|
|
94
|
+
new Promise((K, L) => {
|
|
95
95
|
a = window.setTimeout(
|
|
96
96
|
() => L(new he("mobi.timeout")),
|
|
97
97
|
1e4
|
|
@@ -101,16 +101,16 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
101
101
|
} finally {
|
|
102
102
|
a !== void 0 && window.clearTimeout(a);
|
|
103
103
|
}
|
|
104
|
-
}, k = l,
|
|
105
|
-
let e = null,
|
|
104
|
+
}, k = l, Z = new Ue(), { t: f } = Re(), ye = ze(), X = Ae(), O = u(null);
|
|
105
|
+
let e = null, J = 1;
|
|
106
106
|
const h = u(1), T = u(1), g = u(!0), x = u(null), y = u([]), n = u(!1), E = u(""), v = u(!1);
|
|
107
107
|
ce([h, T, v, n, g, () => y.value.length], () => {
|
|
108
|
-
|
|
108
|
+
Z.notify();
|
|
109
109
|
});
|
|
110
110
|
const A = (o, t) => {
|
|
111
|
-
Number.isFinite(t) && t > 0 && (
|
|
111
|
+
Number.isFinite(t) && t > 0 && (J = t);
|
|
112
112
|
const a = Number.isFinite(o) ? o : 0;
|
|
113
|
-
h.value = Math.max(1, a + 1), T.value =
|
|
113
|
+
h.value = Math.max(1, a + 1), T.value = J;
|
|
114
114
|
}, _e = () => {
|
|
115
115
|
e == null || e.prev().catch(() => {
|
|
116
116
|
});
|
|
@@ -174,7 +174,7 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
174
174
|
]
|
|
175
175
|
}
|
|
176
176
|
],
|
|
177
|
-
onToolbarChange: (o) =>
|
|
177
|
+
onToolbarChange: (o) => Z.subscribe(o)
|
|
178
178
|
});
|
|
179
179
|
const I = (o) => {
|
|
180
180
|
var t;
|
|
@@ -182,11 +182,11 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
182
182
|
};
|
|
183
183
|
ve(() => window.addEventListener("error", I)), de(() => window.removeEventListener("error", I));
|
|
184
184
|
const ee = async () => {
|
|
185
|
-
var d,
|
|
186
|
-
|
|
187
|
-
const o =
|
|
185
|
+
var d, K, L;
|
|
186
|
+
X.begin(k.url);
|
|
187
|
+
const o = O.value;
|
|
188
188
|
if (!o) return;
|
|
189
|
-
g.value = !0, x.value = null, y.value = [], n.value = !1, E.value = "",
|
|
189
|
+
g.value = !0, x.value = null, y.value = [], n.value = !1, E.value = "", J = 1, h.value = 1, T.value = 1, o.replaceChildren(), e = null;
|
|
190
190
|
let t = !1;
|
|
191
191
|
const a = /* @__PURE__ */ new Map();
|
|
192
192
|
try {
|
|
@@ -211,15 +211,15 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
211
211
|
H = C;
|
|
212
212
|
else {
|
|
213
213
|
const w = ((ie = e == null ? void 0 : e.book) == null ? void 0 : ie.sections) ?? [], ue = ((se = w[P]) == null ? void 0 : se.size) ?? 0, Me = ue > 0 ? b / ue : 0;
|
|
214
|
-
let
|
|
214
|
+
let Y = 0;
|
|
215
215
|
for (let S = 0; S < ae; S++)
|
|
216
216
|
if (a.has(S))
|
|
217
|
-
|
|
217
|
+
Y += a.get(S);
|
|
218
218
|
else {
|
|
219
219
|
const Se = ((fe = w[S]) == null ? void 0 : fe.size) ?? 0;
|
|
220
|
-
|
|
220
|
+
Y += Math.max(1, Math.round(Se * Me));
|
|
221
221
|
}
|
|
222
|
-
H = Math.max(C,
|
|
222
|
+
H = Math.max(C, Y);
|
|
223
223
|
}
|
|
224
224
|
A(C - 1, H);
|
|
225
225
|
const $ = i.tocItem;
|
|
@@ -238,9 +238,9 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
238
238
|
const F = i.tocItem;
|
|
239
239
|
F != null && F.href && (E.value = F.href);
|
|
240
240
|
});
|
|
241
|
-
const
|
|
242
|
-
if (!
|
|
243
|
-
const Ce = await
|
|
241
|
+
const Q = await ye.value(k.url);
|
|
242
|
+
if (!Q.ok) throw new he("request.failed", { status: Q.status });
|
|
243
|
+
const Ce = await Q.blob();
|
|
244
244
|
let te = "book.mobi";
|
|
245
245
|
try {
|
|
246
246
|
const i = new URL(k.url, window.location.href).pathname.split("/").pop();
|
|
@@ -249,9 +249,9 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
249
249
|
}
|
|
250
250
|
await s.open(new File([Ce], te));
|
|
251
251
|
const p = s.renderer;
|
|
252
|
-
p && (p.setAttribute("animated", ""), p.setAttribute("max-inline-size", "720"), p.setAttribute("margin", "48"), p.setAttribute("gap", "5%"), await V(p), (d = p.setStyles) == null || d.call(p, z)), y.value = ((
|
|
252
|
+
p && (p.setAttribute("animated", ""), p.setAttribute("max-inline-size", "720"), p.setAttribute("margin", "48"), p.setAttribute("gap", "5%"), await V(p), (d = p.setStyles) == null || d.call(p, z)), y.value = ((K = s.book) == null ? void 0 : K.toc) ?? [], g.value = !1, X.ready(), t || A(0, ((L = s.book) == null ? void 0 : L.sections.length) ?? 1);
|
|
253
253
|
} catch (s) {
|
|
254
|
-
console.error(f.value("mobi.load_failed") + ":", s), x.value = f.value("mobi.load_failed"), g.value = !1,
|
|
254
|
+
console.error(f.value("mobi.load_failed") + ":", s), x.value = f.value("mobi.load_failed"), g.value = !1, X.error(s);
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
return ve(() => {
|
|
@@ -268,7 +268,7 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
268
268
|
(a = (t = e == null ? void 0 : e.book) == null ? void 0 : t.destroy) == null || a.call(t);
|
|
269
269
|
} catch {
|
|
270
270
|
}
|
|
271
|
-
e = null, (d =
|
|
271
|
+
e = null, (d = O.value) == null || d.replaceChildren();
|
|
272
272
|
}), (o, t) => (N(), D("div", je, [
|
|
273
273
|
x.value ? (N(), Ne(Be, {
|
|
274
274
|
key: 0,
|
|
@@ -316,7 +316,7 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
316
316
|
x.value ? W("", !0) : (N(), D("div", {
|
|
317
317
|
key: 3,
|
|
318
318
|
ref_key: "hostRef",
|
|
319
|
-
ref:
|
|
319
|
+
ref: O,
|
|
320
320
|
class: "vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg",
|
|
321
321
|
style: U({
|
|
322
322
|
width: v.value ? "100%" : "794px",
|
|
@@ -328,7 +328,7 @@ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
|
|
|
328
328
|
}, null, 4))
|
|
329
329
|
]));
|
|
330
330
|
}
|
|
331
|
-
}), rt = /* @__PURE__ */ Le(Qe, [["__scopeId", "data-v-
|
|
331
|
+
}), rt = /* @__PURE__ */ Le(Qe, [["__scopeId", "data-v-8eb76047"]]);
|
|
332
332
|
export {
|
|
333
333
|
rt as default
|
|
334
334
|
};
|