@eternalheart/vue-file-preview 1.6.8 → 1.6.9

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.
Files changed (38) hide show
  1. package/lib/chunks/{index-DL3r7NGE.mjs → index-BB5sxTpZ.mjs} +832 -830
  2. package/lib/chunks/index-BHpXaB9I.mjs +113 -0
  3. package/lib/chunks/index-BMpMXQVn.mjs +354 -0
  4. package/lib/chunks/{index-D18co0be.mjs → index-Bcq3GaYf.mjs} +94 -91
  5. package/lib/chunks/index-Bexr8qBs.mjs +118 -0
  6. package/lib/chunks/index-BjrqA9rc.mjs +104 -0
  7. package/lib/chunks/index-Bpw-3elB.mjs +90 -0
  8. package/lib/chunks/{index-CG01fzip.mjs → index-BrlnSL9B.mjs} +33 -33
  9. package/lib/chunks/{index-Hj5oboUU.mjs → index-Bw94R-j4.mjs} +1002 -1048
  10. package/lib/chunks/index-CKb19_XL.mjs +52 -0
  11. package/lib/chunks/{index-bgq5MUC6.mjs → index-COgE_EN8.mjs} +98 -95
  12. package/lib/chunks/{index-CodGY6nz.mjs → index-C_0pROOm.mjs} +174 -171
  13. package/lib/chunks/{index-BgtFv2mf.mjs → index-CsP5e8u1.mjs} +26 -26
  14. package/lib/chunks/{index-C3isZ_ue.mjs → index-D02VAnb_.mjs} +71 -68
  15. package/lib/chunks/{index-DbQYYr9C.mjs → index-D5CgW1SY.mjs} +32 -32
  16. package/lib/chunks/{index-B1OYfn_2.mjs → index-D9DjYf4b.mjs} +148 -143
  17. package/lib/chunks/index-DAmkmR7C.mjs +51 -0
  18. package/lib/chunks/{index-D6tN6EZR.mjs → index-Dbt450tb.mjs} +1 -1
  19. package/lib/chunks/index-DcYqyPdh.mjs +155 -0
  20. package/lib/chunks/index-DjQ_Fllz.mjs +108 -0
  21. package/lib/chunks/{index-D4O2OC-3.mjs → index-Tm4rnJiV.mjs} +28 -28
  22. package/lib/chunks/{index-CRTvjRyt.mjs → index-aceY97Xi.mjs} +692 -689
  23. package/lib/chunks/{useShikiHighlight-xcK26Bn3.mjs → useShikiHighlight-DqskZVn5.mjs} +1 -1
  24. package/lib/composables/useThemeMode.d.ts +3 -0
  25. package/lib/index.cjs +49 -49
  26. package/lib/index.css +1 -1
  27. package/lib/index.mjs +1 -1
  28. package/lib/renderers/base.types.d.ts +1 -2
  29. package/package.json +1 -1
  30. package/lib/chunks/index-BJpiAJuf.mjs +0 -87
  31. package/lib/chunks/index-CJYCIk06.mjs +0 -49
  32. package/lib/chunks/index-CVN9K0qA.mjs +0 -105
  33. package/lib/chunks/index-D5JP7cnv.mjs +0 -110
  34. package/lib/chunks/index-DJAZU94G.mjs +0 -104
  35. package/lib/chunks/index-DYI-zHxA.mjs +0 -152
  36. package/lib/chunks/index-TlmEk0Wz.mjs +0 -48
  37. package/lib/chunks/index-XEPcqTt4.mjs +0 -115
  38. package/lib/chunks/index-Z3_lfqRQ.mjs +0 -348
@@ -0,0 +1,113 @@
1
+ import { defineComponent as S, ref as v, computed as f, watch as k, unref as d, openBlock as a, createElementBlock as u, createElementVNode as l, toDisplayString as h, createBlock as B, normalizeClass as T, normalizeStyle as F, Fragment as E, renderList as z } from "vue";
2
+ import { WrapText as G, Code as M, Eye as W } from "lucide-vue-next";
3
+ import { u as $, b as D, k as P, e as R } from "./index-Bw94R-j4.mjs";
4
+ import { u as V } from "./useShikiHighlight-DqskZVn5.mjs";
5
+ import { _ as j } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
6
+ import { T as q } from "./base.types-DaftHyg7.mjs";
7
+ const A = {
8
+ key: 0,
9
+ class: "vfp-renderer-loading"
10
+ }, I = { class: "vfp-renderer-loading-content" }, J = { class: "vfp-renderer-loading-text" }, K = {
11
+ key: 2,
12
+ class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
13
+ }, O = ["srcdoc", "title"], Q = {
14
+ key: 3,
15
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
16
+ style: { background: "var(--fp-code-bg)" }
17
+ }, U = {
18
+ key: 4,
19
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
20
+ style: { background: "var(--fp-code-bg)" }
21
+ }, X = { class: "vfp-code-gutter" }, Y = ["innerHTML"], ue = /* @__PURE__ */ S({
22
+ __name: "index",
23
+ props: {
24
+ url: {},
25
+ fileName: {}
26
+ },
27
+ setup(b, { expose: H }) {
28
+ const m = b, w = new q(), { t: s } = $(), C = D(), t = v(!0), o = v(!1), i = v(""), p = v(!0), c = v(null), r = f(() => P(m.fileName)), L = f(() => r.value !== "text" ? i.value : ""), { lineHtmls: _, loading: N } = V(L, r), y = f(() => r.value === "html");
29
+ k([t, o, p, y], () => {
30
+ w.notify();
31
+ }), k(() => m.url, async () => {
32
+ p.value = !0, c.value = null;
33
+ try {
34
+ const e = await R(m.url, { fetcher: C.value });
35
+ i.value = e;
36
+ } catch (e) {
37
+ console.error(e), c.value = s.value("text.load_failed");
38
+ } finally {
39
+ p.value = !1;
40
+ }
41
+ }, { immediate: !0 });
42
+ const x = f(() => i.value.split(`
43
+ `));
44
+ return H({
45
+ getToolbarGroups: () => {
46
+ const e = [];
47
+ return e.push({
48
+ items: [
49
+ {
50
+ type: "button",
51
+ icon: G,
52
+ tooltip: t.value ? s.value("toolbar.wrap_off") : s.value("toolbar.wrap_on"),
53
+ action: () => {
54
+ t.value = !t.value;
55
+ },
56
+ active: t.value
57
+ }
58
+ ]
59
+ }), y.value && e.push({
60
+ items: [
61
+ {
62
+ type: "button",
63
+ icon: o.value ? M : W,
64
+ tooltip: o.value ? s.value("toolbar.source") : s.value("toolbar.preview"),
65
+ action: () => {
66
+ o.value = !o.value;
67
+ },
68
+ active: o.value
69
+ }
70
+ ]
71
+ }), e;
72
+ },
73
+ onToolbarChange: (e) => w.subscribe(e)
74
+ }), (e, n) => p.value || r.value !== "text" && d(N) ? (a(), u("div", A, [
75
+ l("div", I, [
76
+ n[0] || (n[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
77
+ l("span", J, h(d(s)("common.loading")), 1)
78
+ ])
79
+ ])) : c.value ? (a(), B(j, {
80
+ key: 1,
81
+ message: c.value
82
+ }, null, 8, ["message"])) : o.value && r.value === "html" ? (a(), u("div", K, [
83
+ l("iframe", {
84
+ srcdoc: i.value,
85
+ sandbox: "allow-same-origin",
86
+ class: "vfp-w-full vfp-h-full vfp-border-0",
87
+ title: b.fileName
88
+ }, null, 8, O)
89
+ ])) : r.value === "text" || d(_).length === 0 ? (a(), u("div", Q, [
90
+ l("pre", {
91
+ class: T(["vfp-py-6 vfp-px-4 vfp-text-fg-primary vfp-font-mono vfp-text-sm", t.value ? "vfp-whitespace-pre-wrap vfp-break-words" : "vfp-whitespace-pre"])
92
+ }, h(i.value), 3)
93
+ ])) : (a(), u("div", U, [
94
+ l("div", {
95
+ class: T(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !t.value }]),
96
+ style: F({ gridTemplateRows: `repeat(${x.value.length}, auto) minmax(1.5rem, 1fr)` })
97
+ }, [
98
+ (a(!0), u(E, null, z(x.value, (le, g) => (a(), u(E, { key: g }, [
99
+ l("span", X, h(g + 1), 1),
100
+ l("span", {
101
+ class: "vfp-code-line",
102
+ innerHTML: d(_)[g] ?? ""
103
+ }, null, 8, Y)
104
+ ], 64))), 128)),
105
+ n[1] || (n[1] = l("span", { class: "vfp-code-gutter-filler" }, null, -1)),
106
+ n[2] || (n[2] = l("span", { class: "vfp-code-line-filler" }, null, -1))
107
+ ], 6)
108
+ ]));
109
+ }
110
+ });
111
+ export {
112
+ ue as default
113
+ };
@@ -0,0 +1,354 @@
1
+ import { defineComponent as H, ref as v, computed as R, onMounted as oe, onBeforeUnmount as A, watch as j, openBlock as r, createElementBlock as m, normalizeStyle as E, Fragment as F, createElementVNode as s, normalizeClass as I, toDisplayString as T, withDirectives as O, renderSlot as B, vShow as Z, resolveComponent as ae, createVNode as N, unref as $, createBlock as W, resolveDynamicComponent as q, renderList as Y, createCommentVNode as J, defineAsyncComponent as se, withCtx as G, Teleport as ie } from "vue";
2
+ import { _ as Q, V as re, R as fe, u as ve, b as de, f as X, h as pe, I as ue, K as ce, w as me } from "./index-Bw94R-j4.mjs";
3
+ import { FileImage as he, FileText as ge, FileCode as xe, File as we, ChevronRight as ye, FolderOpen as be, Folder as ke } from "lucide-vue-next";
4
+ import { _ as Le } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
5
+ import { T as Se } from "./base.types-DaftHyg7.mjs";
6
+ const Te = { class: "vfp-flex vfp-flex-shrink-0 vfp-border-b vfp-border-line-weak vfp-bg-surface-toolbar" }, ze = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Re = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, $e = { class: "vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden" }, Ce = /* @__PURE__ */ H({
7
+ name: "ResizableSplit",
8
+ __name: "ResizableSplit",
9
+ props: {
10
+ initialLeftWidth: { default: 280 },
11
+ minLeftWidth: { default: 160 },
12
+ maxLeftWidth: { default: 640 },
13
+ minRightWidth: { default: 200 },
14
+ storageKey: {},
15
+ desktopMedia: { default: "(min-width: 768px)" },
16
+ mobileTabMode: { type: Boolean, default: !1 },
17
+ leftTabLabel: { default: "文件树" },
18
+ rightTabLabel: { default: "预览" }
19
+ },
20
+ setup(i, { expose: _ }) {
21
+ const t = i, f = v(null), k = v(
22
+ (() => {
23
+ if (t.storageKey && typeof window < "u") {
24
+ const o = Number(window.localStorage.getItem(t.storageKey));
25
+ if (!isNaN(o) && o > 0) return o;
26
+ }
27
+ return t.initialLeftWidth;
28
+ })()
29
+ ), u = v(!1), C = v(!1), S = v(!0), c = v("left");
30
+ let h = null, l = null;
31
+ const n = () => {
32
+ h && (C.value = h.matches);
33
+ }, d = R(
34
+ () => C.value && S.value ? { width: `${k.value}px` } : void 0
35
+ ), x = R(() => C.value && S.value), p = (o) => {
36
+ if (!f.value) return;
37
+ const b = f.value.getBoundingClientRect(), D = o.clientX - b.left, P = b.width - t.minRightWidth - 6, K = Math.min(t.maxLeftWidth, P);
38
+ k.value = Math.max(
39
+ t.minLeftWidth,
40
+ Math.min(K, D)
41
+ );
42
+ }, w = () => {
43
+ if (u.value && (u.value = !1, window.removeEventListener("mousemove", p), window.removeEventListener("mouseup", w), document.body.style.cursor = "", document.body.style.userSelect = "", t.storageKey))
44
+ try {
45
+ window.localStorage.setItem(t.storageKey, String(k.value));
46
+ } catch {
47
+ }
48
+ }, U = (o) => {
49
+ o.preventDefault(), u.value = !0, window.addEventListener("mousemove", p), window.addEventListener("mouseup", w), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
50
+ };
51
+ oe(() => {
52
+ if (typeof window < "u") {
53
+ h = window.matchMedia(t.desktopMedia), n(), h.addEventListener("change", n);
54
+ const o = () => {
55
+ f.value && (S.value = f.value.getBoundingClientRect().width >= t.minLeftWidth + t.minRightWidth + 6);
56
+ };
57
+ o(), l = typeof ResizeObserver < "u" ? new ResizeObserver(o) : null, l == null || l.observe(f.value);
58
+ }
59
+ }), A(() => {
60
+ h && h.removeEventListener("change", n), l == null || l.disconnect(), l = null, window.removeEventListener("mousemove", p), window.removeEventListener("mouseup", w), u.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
61
+ }), j(
62
+ () => t.initialLeftWidth,
63
+ (o) => {
64
+ t.storageKey || (k.value = o);
65
+ }
66
+ );
67
+ const z = (o) => {
68
+ c.value = o;
69
+ };
70
+ return _({ switchTab: z }), (o, b) => (r(), m("div", {
71
+ ref_key: "containerRef",
72
+ ref: f,
73
+ class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col md:vfp-flex-row vfp-min-h-0 vfp-min-w-0",
74
+ style: E(x.value ? void 0 : { flexDirection: "column" })
75
+ }, [
76
+ i.mobileTabMode && !x.value ? (r(), m(F, { key: 0 }, [
77
+ s("div", Te, [
78
+ s("button", {
79
+ type: "button",
80
+ class: I(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", c.value === "left" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
81
+ onClick: b[0] || (b[0] = (D) => z("left"))
82
+ }, T(i.leftTabLabel), 3),
83
+ s("button", {
84
+ type: "button",
85
+ class: I(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", c.value === "right" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
86
+ onClick: b[1] || (b[1] = (D) => z("right"))
87
+ }, T(i.rightTabLabel), 3)
88
+ ]),
89
+ O(s("div", ze, [
90
+ B(o.$slots, "left", {}, void 0, !0)
91
+ ], 512), [
92
+ [Z, c.value === "left"]
93
+ ]),
94
+ O(s("div", Re, [
95
+ B(o.$slots, "right", {}, void 0, !0)
96
+ ], 512), [
97
+ [Z, c.value === "right"]
98
+ ])
99
+ ], 64)) : (r(), m(F, { key: 1 }, [
100
+ s("div", {
101
+ class: "vfp-min-h-0 vfp-min-w-0 vfp-flex-shrink-0 vfp-w-full vfp-max-h-60 md:vfp-h-full md:vfp-max-h-none",
102
+ style: E(d.value)
103
+ }, [
104
+ B(o.$slots, "left", {}, void 0, !0)
105
+ ], 4),
106
+ s("div", {
107
+ role: "separator",
108
+ "aria-orientation": "vertical",
109
+ class: I(["split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors", u.value ? "dragging" : ""]),
110
+ style: E(x.value ? void 0 : { display: "none" }),
111
+ onMousedown: U
112
+ }, [...b[2] || (b[2] = [
113
+ s("span", { class: "vfp-absolute vfp-inset-y-0 hit-area" }, null, -1)
114
+ ])], 38),
115
+ s("div", $e, [
116
+ B(o.$slots, "right", {}, void 0, !0)
117
+ ])
118
+ ], 64))
119
+ ], 4));
120
+ }
121
+ }), Me = /* @__PURE__ */ Q(Ce, [["__scopeId", "data-v-f34907bf"]]), Ee = { key: 0 }, We = { class: "vfp-truncate vfp-flex-1 vfp-min-w-0" }, _e = { class: "vfp-flex-1 vfp-truncate vfp-min-w-0" }, De = { class: "vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2" }, Ie = { name: "ZipTreeItem" }, Fe = /* @__PURE__ */ H({
122
+ ...Ie,
123
+ props: {
124
+ node: {},
125
+ depth: {},
126
+ selectedPath: {},
127
+ expanded: {}
128
+ },
129
+ emits: ["toggle", "select", "hover", "leave"],
130
+ setup(i, { emit: _ }) {
131
+ const t = i, f = _, k = R(() => ({ paddingLeft: `${t.depth * 14 + 10}px` })), u = R(() => t.expanded.has(t.node.path)), C = R(() => t.selectedPath === t.node.path), S = R(() => {
132
+ const l = re({ name: t.node.name, type: "" });
133
+ return l === "image" ? he : l === "text" || l === "markdown" || l === "json" || l === "csv" || l === "xml" || l === "subtitle" ? t.node.name.endsWith(".md") || t.node.name.endsWith(".markdown") ? ge : xe : we;
134
+ }), c = (l) => {
135
+ const n = l.currentTarget.getBoundingClientRect();
136
+ f("hover", t.node.name || "/", n);
137
+ }, h = () => f("leave");
138
+ return (l, n) => {
139
+ const d = ae("ZipTreeItem");
140
+ return i.node.isDir ? (r(), m("div", Ee, [
141
+ s("button", {
142
+ type: "button",
143
+ class: "tree-row dir-row",
144
+ style: E(k.value),
145
+ onClick: n[0] || (n[0] = (x) => f("toggle", i.node.path)),
146
+ onMouseenter: c,
147
+ onMouseleave: h
148
+ }, [
149
+ N($(ye), {
150
+ class: I(["vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0 vfp-transition-transform", { "vfp-rotate-90": u.value }])
151
+ }, null, 8, ["class"]),
152
+ (r(), W(q(u.value ? $(be) : $(ke)), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80" })),
153
+ s("span", We, T(i.node.name || "/"), 1)
154
+ ], 36),
155
+ u.value && i.node.children ? (r(!0), m(F, { key: 0 }, Y(i.node.children, (x) => (r(), W(d, {
156
+ key: x.path,
157
+ node: x,
158
+ depth: i.depth + 1,
159
+ "selected-path": i.selectedPath,
160
+ expanded: i.expanded,
161
+ onToggle: n[1] || (n[1] = (p) => f("toggle", p)),
162
+ onSelect: n[2] || (n[2] = (p) => f("select", p)),
163
+ onHover: n[3] || (n[3] = (p, w) => f("hover", p, w)),
164
+ onLeave: n[4] || (n[4] = (p) => f("leave"))
165
+ }, null, 8, ["node", "depth", "selected-path", "expanded"]))), 128)) : J("", !0)
166
+ ])) : (r(), m("button", {
167
+ key: 1,
168
+ type: "button",
169
+ class: I(["tree-row file-row", { selected: C.value }]),
170
+ style: E(k.value),
171
+ onClick: n[5] || (n[5] = (x) => f("select", i.node)),
172
+ onMouseenter: c,
173
+ onMouseleave: h
174
+ }, [
175
+ n[6] || (n[6] = s("span", { class: "vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0" }, null, -1)),
176
+ (r(), W(q(S.value), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary" })),
177
+ s("span", _e, T(i.node.name), 1),
178
+ s("span", De, T($(fe)(i.node.size)), 1)
179
+ ], 38));
180
+ };
181
+ }
182
+ }), Ue = /* @__PURE__ */ Q(Fe, [["__scopeId", "data-v-124c382d"]]), Be = {
183
+ key: 0,
184
+ class: "vfp-renderer-loading"
185
+ }, Ke = { class: "vfp-renderer-loading-content" }, je = { class: "vfp-renderer-loading-text" }, Ne = { class: "vfp-w-full vfp-h-full vfp-overflow-auto" }, He = { class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col" }, Pe = {
186
+ key: 0,
187
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-muted vfp-text-sm vfp-p-6"
188
+ }, Ve = {
189
+ key: 1,
190
+ class: "vfp-renderer-loading vfp-flex-1"
191
+ }, Oe = { class: "vfp-renderer-loading-content" }, Ze = { class: "vfp-renderer-loading-text" }, qe = {
192
+ key: 2,
193
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-secondary"
194
+ }, Ge = {
195
+ key: 3,
196
+ class: "vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0"
197
+ }, et = /* @__PURE__ */ H({
198
+ __name: "index",
199
+ props: {
200
+ url: {},
201
+ nestingDepth: { default: 0 }
202
+ },
203
+ setup(i, { expose: _ }) {
204
+ const t = se(
205
+ () => import("./index-Bw94R-j4.mjs").then((e) => e.x)
206
+ ), f = i, k = new Se(), { t: u } = ve(), C = de(), S = v(null), c = v(null), h = v(!0), l = v(null), n = v(/* @__PURE__ */ new Set([""])), d = v(null), x = v(!1), p = v(null), w = v(null), U = v(null), z = v(null), o = () => {
207
+ var e;
208
+ (e = d.value) != null && e.blobUrl && URL.revokeObjectURL(d.value.blobUrl);
209
+ }, b = async () => {
210
+ o(), d.value = null, h.value = !0, l.value = null;
211
+ try {
212
+ const e = await C.value(f.url);
213
+ if (!e.ok) throw new Error("加载失败");
214
+ const a = await e.arrayBuffer(), g = await pe(a), y = ue(g), L = ce(y);
215
+ S.value = g, c.value = L;
216
+ const M = /* @__PURE__ */ new Set([""]);
217
+ if (L.children)
218
+ for (const V of L.children) V.isDir && M.add(V.path);
219
+ n.value = M;
220
+ } catch (e) {
221
+ console.error(e), l.value = u.value("zip.load_failed");
222
+ } finally {
223
+ h.value = !1;
224
+ }
225
+ };
226
+ j(() => f.url, (e) => {
227
+ e && b();
228
+ }, { immediate: !0 }), A(() => {
229
+ o();
230
+ });
231
+ const D = R(() => {
232
+ if (!c.value) return null;
233
+ let e = 0, a = 0, g = 0;
234
+ const y = (L) => {
235
+ var M;
236
+ L.isDir ? (L.path && a++, (M = L.children) == null || M.forEach(y)) : (e++, g += L.size);
237
+ };
238
+ return y(c.value), { files: e, dirs: a, size: g };
239
+ });
240
+ j(D, () => k.notify()), _({
241
+ getToolbarGroups: () => [],
242
+ onToolbarChange: (e) => k.subscribe(e)
243
+ });
244
+ const K = (e) => {
245
+ const a = new Set(n.value);
246
+ a.has(e) ? a.delete(e) : a.add(e), n.value = a;
247
+ }, ee = (e, a) => {
248
+ const g = typeof window < "u" ? window.innerWidth - 328 : a.right + 8;
249
+ w.value = { text: e, x: Math.max(8, Math.min(a.right + 8, g)), y: a.top + a.height / 2 };
250
+ }, te = () => {
251
+ w.value = null;
252
+ }, ne = async (e) => {
253
+ var a, g;
254
+ if (!(!S.value || e.isDir || ((a = d.value) == null ? void 0 : a.path) === e.path || z.value === e.path)) {
255
+ z.value = e.path, o(), x.value = !0, p.value = null;
256
+ try {
257
+ const y = X(e.name), L = await me(S.value, e.path, y !== "application/octet-stream" ? y : void 0), M = URL.createObjectURL(L);
258
+ d.value = { path: e.path, name: e.name, size: e.size, blobUrl: M }, (g = U.value) == null || g.switchTab("right");
259
+ } catch (y) {
260
+ console.error(y), p.value = "条目读取失败";
261
+ } finally {
262
+ x.value = !1, z.value === e.path && (z.value = null);
263
+ }
264
+ }
265
+ }, le = R(() => d.value ? [{ name: d.value.name, url: d.value.blobUrl, type: X(d.value.name) }] : []);
266
+ return (e, a) => h.value ? (r(), m("div", Be, [
267
+ s("div", Ke, [
268
+ a[0] || (a[0] = s("div", { class: "vfp-renderer-spinner" }, null, -1)),
269
+ s("span", je, T($(u)("common.loading")), 1)
270
+ ])
271
+ ])) : l.value || !c.value ? (r(), W(Le, {
272
+ key: 1,
273
+ message: l.value || $(u)("zip.parse_failed")
274
+ }, null, 8, ["message"])) : (r(), m(F, { key: 2 }, [
275
+ N(Me, {
276
+ ref_key: "splitRef",
277
+ ref: U,
278
+ "initial-left-width": 280,
279
+ "min-left-width": 180,
280
+ "max-left-width": 560,
281
+ "storage-key": "vfp-zip-split-left",
282
+ "mobile-tab-mode": "",
283
+ "left-tab-label": "文件树",
284
+ "right-tab-label": "预览"
285
+ }, {
286
+ left: G(() => [
287
+ s("div", Ne, [
288
+ (r(!0), m(F, null, Y(c.value.children || [], (g) => {
289
+ var y;
290
+ return r(), W(Ue, {
291
+ key: g.path,
292
+ node: g,
293
+ depth: 0,
294
+ "selected-path": ((y = d.value) == null ? void 0 : y.path) ?? null,
295
+ expanded: n.value,
296
+ onToggle: K,
297
+ onSelect: ne,
298
+ onHover: ee,
299
+ onLeave: te
300
+ }, null, 8, ["node", "selected-path", "expanded"]);
301
+ }), 128))
302
+ ])
303
+ ]),
304
+ right: G(() => [
305
+ s("div", He, [
306
+ d.value ? x.value ? (r(), m("div", Ve, [
307
+ s("div", Oe, [
308
+ a[1] || (a[1] = s("div", { class: "vfp-renderer-spinner" }, null, -1)),
309
+ s("span", Ze, T($(u)("common.loading")), 1)
310
+ ])
311
+ ])) : p.value ? (r(), m("div", qe, T(p.value), 1)) : (r(), m("div", Ge, [
312
+ N($(t), {
313
+ mode: "embed",
314
+ files: le.value,
315
+ "current-index": 0,
316
+ "zip-nesting-depth": i.nestingDepth + 1
317
+ }, null, 8, ["files", "zip-nesting-depth"])
318
+ ])) : (r(), m("div", Pe, " 从左侧选择一个文件以预览 "))
319
+ ])
320
+ ]),
321
+ _: 1
322
+ }, 512),
323
+ (r(), W(ie, { to: "body" }, [
324
+ w.value ? (r(), m("div", {
325
+ key: 0,
326
+ class: "vfp-zip-tip",
327
+ style: E({
328
+ position: "fixed",
329
+ zIndex: 2147483647,
330
+ pointerEvents: "none",
331
+ display: "block",
332
+ transform: "translateY(-50%)",
333
+ padding: "4px 8px",
334
+ background: "rgba(0, 0, 0, 0.85)",
335
+ color: "#fff",
336
+ fontSize: "12px",
337
+ lineHeight: 1.5,
338
+ borderRadius: "4px",
339
+ whiteSpace: "nowrap",
340
+ maxWidth: "min(320px, calc(100vw - 16px))",
341
+ overflow: "hidden",
342
+ textOverflow: "ellipsis",
343
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.3)",
344
+ left: w.value.x + "px",
345
+ top: w.value.y + "px"
346
+ })
347
+ }, T(w.value.text), 5)) : J("", !0)
348
+ ]))
349
+ ], 64));
350
+ }
351
+ });
352
+ export {
353
+ et as default
354
+ };