@eternalheart/vue-file-preview 1.6.13 → 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.
Files changed (128) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/lib/FilePreviewContent.vue.d.ts +25 -6
  4. package/lib/FilePreviewEmbed.vue.d.ts +19 -6
  5. package/lib/FilePreviewModal.vue.d.ts +19 -6
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-Cf00sjt2.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-cn1P7b2x.mjs} +1 -1
  9. package/lib/chunks/{index-BASg1cr4.mjs → index-0VXtKKev.mjs} +1018 -1018
  10. package/lib/chunks/index-0fXL30y0.mjs +333 -0
  11. package/lib/chunks/{index-C9mAajbD.mjs → index-B1AwVHWI.mjs} +191 -191
  12. package/lib/chunks/{index-BvBqDq3O.mjs → index-B77rFiau.mjs} +2023 -2023
  13. package/lib/chunks/index-BB10as16.mjs +108 -0
  14. package/lib/chunks/index-BBIn-k4u.mjs +359 -0
  15. package/lib/chunks/index-BSzaI9ea.mjs +122 -0
  16. package/lib/chunks/index-BZvy39tn.mjs +117 -0
  17. package/lib/chunks/index-BlJEM2Lb.mjs +383 -0
  18. package/lib/chunks/{index-CxKZKUJj.mjs → index-CZlnxQFA.mjs} +1385 -1385
  19. package/lib/chunks/index-ClhTPqDI.mjs +137 -0
  20. package/lib/chunks/{index-8Vpbg2kS.mjs → index-D690gnNu.mjs} +118 -117
  21. package/lib/chunks/index-D7WykPYL.mjs +51 -0
  22. package/lib/chunks/{index-DZZN3kYi.mjs → index-DBzyeU0G.mjs} +1609 -1375
  23. package/lib/chunks/{index-Dkro_8Fy.mjs → index-DKFX5ToE.mjs} +33 -33
  24. package/lib/chunks/index-DRmKaFXK.mjs +157 -0
  25. package/lib/chunks/index-DXf3wXT5.mjs +155 -0
  26. package/lib/chunks/{index-BuqPb5mP.mjs → index-Dp7QQjNH.mjs} +114 -114
  27. package/lib/chunks/index-FzI__DHC.mjs +104 -0
  28. package/lib/chunks/index-PWjCziZG.mjs +90 -0
  29. package/lib/chunks/index-bT6XWKO_.mjs +52 -0
  30. package/lib/chunks/{index-DN4Ui0Gh.mjs → index-tX9VR6Vo.mjs} +122 -122
  31. package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-D-OEDL3n.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-CVN06LUc.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-DBqcJPFK.mjs} +5 -5
  34. package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-8-0icdyL.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-a_GUszuU.mjs} +1 -1
  36. package/lib/composables/useAudioPlayer.d.ts +1 -1
  37. package/lib/composables/usePreviewEvents.d.ts +27 -0
  38. package/lib/composables/useRequest.d.ts +16 -4
  39. package/lib/composables/useThemeMode.d.ts +1 -1
  40. package/lib/composables/useTranslator.d.ts +2 -2
  41. package/lib/core/events.d.ts +69 -0
  42. package/lib/core/i18n/index.d.ts +29 -0
  43. package/lib/core/i18n/messages/en-US.d.ts +5 -0
  44. package/lib/core/i18n/messages/index.d.ts +9 -0
  45. package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
  46. package/lib/core/i18n/types.d.ts +23 -0
  47. package/lib/core/index.d.ts +34 -0
  48. package/lib/core/loaders/avifLoader.d.ts +22 -0
  49. package/lib/core/loaders/heicLoader.d.ts +21 -0
  50. package/lib/core/loaders/jp2Loader.d.ts +16 -0
  51. package/lib/core/loaders/jp2Worker.d.ts +1 -0
  52. package/lib/core/loaders/psdLoader.d.ts +14 -0
  53. package/lib/core/loaders/rawLoader.d.ts +14 -0
  54. package/lib/core/loaders/registry.d.ts +32 -0
  55. package/lib/core/loaders/tiffLoader.d.ts +28 -0
  56. package/lib/core/loaders/types.d.ts +56 -0
  57. package/lib/core/types.d.ts +89 -0
  58. package/lib/core/utils/csvParser.d.ts +31 -0
  59. package/lib/core/utils/emptyState.d.ts +28 -0
  60. package/lib/core/utils/excelDataConverter.d.ts +61 -0
  61. package/lib/core/utils/fileNormalizer.d.ts +21 -0
  62. package/lib/core/utils/fileType.d.ts +21 -0
  63. package/lib/core/utils/legacy-office/doc.d.ts +25 -0
  64. package/lib/core/utils/legacy-office/index.d.ts +8 -0
  65. package/lib/core/utils/legacy-office/ole.d.ts +8 -0
  66. package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
  67. package/lib/core/utils/legacy-office/xls.d.ts +28 -0
  68. package/lib/core/utils/mimeTypes.d.ts +29 -0
  69. package/lib/core/utils/ooxml/docx.d.ts +17 -0
  70. package/lib/core/utils/ooxml/index.d.ts +4 -0
  71. package/lib/core/utils/ooxml/pptx.d.ts +7 -0
  72. package/lib/core/utils/ooxml/xml.d.ts +15 -0
  73. package/lib/core/utils/ooxml/zip.d.ts +3 -0
  74. package/lib/core/utils/pdfWorker.d.ts +61 -0
  75. package/lib/core/utils/previewMode.d.ts +7 -0
  76. package/lib/core/utils/request.d.ts +49 -0
  77. package/lib/core/utils/subtitleParser.d.ts +44 -0
  78. package/lib/core/utils/textDecoder.d.ts +30 -0
  79. package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
  80. package/lib/core/utils/zipReader.d.ts +51 -0
  81. package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
  82. package/lib/core/workers/workerClient.d.ts +14 -0
  83. package/lib/i18n/localeKey.d.ts +1 -1
  84. package/lib/index.cjs +60 -60
  85. package/lib/index.css +1 -1
  86. package/lib/index.d.ts +11 -9
  87. package/lib/index.mjs +15 -12
  88. package/lib/renderers/Audio/index.vue.d.ts +1 -1
  89. package/lib/renderers/Cad/index.vue.d.ts +1 -1
  90. package/lib/renderers/Cad/toolbar.d.ts +2 -2
  91. package/lib/renderers/Csv/index.vue.d.ts +1 -1
  92. package/lib/renderers/Doc/index.vue.d.ts +1 -1
  93. package/lib/renderers/Docx/index.vue.d.ts +1 -1
  94. package/lib/renderers/Epub/index.vue.d.ts +1 -1
  95. package/lib/renderers/Font/index.vue.d.ts +1 -1
  96. package/lib/renderers/Image/index.vue.d.ts +2 -2
  97. package/lib/renderers/Json/index.vue.d.ts +2 -2
  98. package/lib/renderers/Markdown/index.vue.d.ts +1 -1
  99. package/lib/renderers/Mobi/index.vue.d.ts +1 -1
  100. package/lib/renderers/Msg/index.vue.d.ts +1 -1
  101. package/lib/renderers/Pdf/index.vue.d.ts +1 -1
  102. package/lib/renderers/Ppt/index.vue.d.ts +1 -1
  103. package/lib/renderers/Pptx/index.vue.d.ts +2 -2
  104. package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
  105. package/lib/renderers/Text/index.vue.d.ts +2 -2
  106. package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
  107. package/lib/renderers/Video/index.vue.d.ts +1 -1
  108. package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
  109. package/lib/renderers/Xml/index.vue.d.ts +1 -1
  110. package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
  111. package/lib/renderers/Zip/index.vue.d.ts +1 -1
  112. package/lib/renderers/base.types.d.ts +1 -1
  113. package/lib/renderers/registry.d.ts +1 -1
  114. package/lib/types.d.ts +3 -3
  115. package/package.json +2 -2
  116. package/lib/chunks/index--612Smof.mjs +0 -383
  117. package/lib/chunks/index-B21EAyWz.mjs +0 -137
  118. package/lib/chunks/index-BB0i4QqI.mjs +0 -117
  119. package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
  120. package/lib/chunks/index-BlrFFeqc.mjs +0 -330
  121. package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
  122. package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
  123. package/lib/chunks/index-CDg6vIbT.mjs +0 -51
  124. package/lib/chunks/index-CWE-hKSs.mjs +0 -90
  125. package/lib/chunks/index-CY3xzGgt.mjs +0 -108
  126. package/lib/chunks/index-D30L8tm9.mjs +0 -155
  127. package/lib/chunks/index-VdzIFJJW.mjs +0 -118
  128. package/lib/chunks/index-aoXgVLBb.mjs +0 -52
@@ -0,0 +1,108 @@
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-DBzyeU0G.mjs";
3
+ import W from "mammoth";
4
+ import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ const Y = {
6
+ key: 0,
7
+ class: "vfp-renderer-loading"
8
+ }, K = { class: "vfp-renderer-loading-content" }, Q = { class: "vfp-renderer-loading-text" }, Z = {
9
+ key: 2,
10
+ class: "vfp-docx-container vfp-w-full vfp-h-full vfp-overflow-auto",
11
+ style: { background: "rgba(0, 0, 0, 0.15)" }
12
+ }, ee = ["innerHTML"], te = ["innerHTML"], b = 1123, k = 60, E = 50, ne = 24, ie = /* @__PURE__ */ $({
13
+ __name: "index",
14
+ props: {
15
+ url: {}
16
+ },
17
+ setup(G, { expose: H }) {
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
+ try {
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
+ ]);
27
+ _.value = r, a.value = t.value, m.ready();
28
+ } catch (e) {
29
+ console.error(f.value("docx.parse_failed") + ":", e), c.value = f.value("docx.parse_failed"), m.error(e);
30
+ } finally {
31
+ h.value = !1;
32
+ }
33
+ }, D = () => {
34
+ const e = g.value;
35
+ if (!e || !a.value) return;
36
+ const n = Array.from(e.children);
37
+ if (n.length === 0) {
38
+ s.value = [a.value];
39
+ return;
40
+ }
41
+ const t = [[]];
42
+ let r = 0;
43
+ for (const u of n) {
44
+ const y = u.offsetHeight;
45
+ r > 0 && r + y > P && (t.push([]), r = 0), t[t.length - 1].push(u.outerHTML), r += y;
46
+ }
47
+ t.length === 0 && t.push([]), s.value = t.map((u) => u.join(""));
48
+ };
49
+ w(() => v.url, (e) => {
50
+ e && S();
51
+ }, { immediate: !0 }), w(a, async () => {
52
+ a.value && (await B(), requestAnimationFrame(() => D()));
53
+ });
54
+ const x = T(() => z(_.value)), L = T(() => ({
55
+ ...x.value,
56
+ position: "absolute",
57
+ visibility: "hidden",
58
+ width: `${794 - E * 2}px`,
59
+ pointerEvents: "none"
60
+ })), M = {
61
+ width: "100%",
62
+ maxWidth: "794px",
63
+ minHeight: `${b}px`,
64
+ background: "white",
65
+ boxShadow: "0 2px 12px rgba(0, 0, 0, 0.15)",
66
+ flexShrink: 0,
67
+ padding: `${k}px ${E}px`
68
+ };
69
+ return H({
70
+ getToolbarGroups: () => []
71
+ }), (e, n) => h.value ? (i(), p("div", Y, [
72
+ l("div", K, [
73
+ n[0] || (n[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
74
+ l("span", Q, N(I(f)("common.loading")), 1)
75
+ ])
76
+ ])) : c.value ? (i(), F(X, {
77
+ key: 1,
78
+ message: c.value
79
+ }, null, 8, ["message"])) : (i(), p("div", Z, [
80
+ l("div", {
81
+ ref_key: "measureRef",
82
+ ref: g,
83
+ style: d(L.value),
84
+ innerHTML: a.value
85
+ }, null, 12, ee),
86
+ l("div", {
87
+ class: "vfp-flex vfp-flex-col vfp-items-center",
88
+ style: d({ gap: `${ne}px` })
89
+ }, [
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
+ boxShadow: "0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(0, 0, 0, 0.10)"
95
+ })
96
+ }, [
97
+ l("div", {
98
+ style: d(x.value),
99
+ innerHTML: t
100
+ }, null, 12, te)
101
+ ], 4))), 128))
102
+ ], 4)
103
+ ]));
104
+ }
105
+ });
106
+ export {
107
+ ie as default
108
+ };
@@ -0,0 +1,359 @@
1
+ import { defineComponent as O, ref as d, computed as C, onMounted as re, onBeforeUnmount as Y, watch as P, openBlock as v, createElementBlock as u, normalizeStyle as W, Fragment as B, createElementVNode as i, normalizeClass as U, toDisplayString as T, unref as g, withDirectives as V, renderSlot as N, vShow as Z, resolveComponent as ve, createVNode as j, createBlock as D, resolveDynamicComponent as q, renderList as Q, createCommentVNode as ee, defineAsyncComponent as fe, withCtx as G, Teleport as de } from "vue";
2
+ import { u as te, d as ne, j as pe, A as ue, a as ce, b as me, W as X, J as he, k as ge, l as we, H as be, m as xe } from "./index-DBzyeU0G.mjs";
3
+ import { FileImage as ye, FileText as ke, FileCode as Le, File as ze, ChevronRight as Se, FolderOpen as Te, Folder as _e } from "lucide-vue-next";
4
+ import { _ as J } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ import { T as $e } from "./base.types-DaftHyg7.mjs";
6
+ const Re = { class: "vfp-flex vfp-flex-shrink-0 vfp-border-b vfp-border-line-weak vfp-bg-surface-toolbar" }, Ce = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Ee = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Me = { class: "vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden" }, We = /* @__PURE__ */ O({
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: {},
18
+ rightTabLabel: {}
19
+ },
20
+ setup(r, { expose: I }) {
21
+ const n = r, { t: p } = te(), w = d(null), f = d(
22
+ (() => {
23
+ if (n.storageKey && typeof window < "u") {
24
+ const l = Number(window.localStorage.getItem(n.storageKey));
25
+ if (!isNaN(l) && l > 0) return l;
26
+ }
27
+ return n.initialLeftWidth;
28
+ })()
29
+ ), z = d(!1), y = d(!1), _ = d(!0), b = d("left");
30
+ let o = null, t = null;
31
+ const k = () => {
32
+ o && (y.value = o.matches);
33
+ }, x = C(
34
+ () => y.value && _.value ? { width: `${f.value}px` } : void 0
35
+ ), a = C(() => y.value && _.value), S = (l) => {
36
+ if (!w.value) return;
37
+ const c = w.value.getBoundingClientRect(), F = l.clientX - c.left, K = c.width - n.minRightWidth - 6, A = Math.min(n.maxLeftWidth, K);
38
+ f.value = Math.max(
39
+ n.minLeftWidth,
40
+ Math.min(A, F)
41
+ );
42
+ }, $ = () => {
43
+ if (z.value && (z.value = !1, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", $), document.body.style.cursor = "", document.body.style.userSelect = "", n.storageKey))
44
+ try {
45
+ window.localStorage.setItem(n.storageKey, String(f.value));
46
+ } catch {
47
+ }
48
+ }, R = (l) => {
49
+ l.preventDefault(), z.value = !0, window.addEventListener("mousemove", S), window.addEventListener("mouseup", $), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
50
+ };
51
+ re(() => {
52
+ if (typeof window < "u") {
53
+ o = window.matchMedia(n.desktopMedia), k(), o.addEventListener("change", k);
54
+ const l = () => {
55
+ w.value && (_.value = w.value.getBoundingClientRect().width >= n.minLeftWidth + n.minRightWidth + 6);
56
+ };
57
+ l(), t = typeof ResizeObserver < "u" ? new ResizeObserver(l) : null, t == null || t.observe(w.value);
58
+ }
59
+ }), Y(() => {
60
+ o && o.removeEventListener("change", k), t == null || t.disconnect(), t = null, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", $), z.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
61
+ }), P(
62
+ () => n.initialLeftWidth,
63
+ (l) => {
64
+ n.storageKey || (f.value = l);
65
+ }
66
+ );
67
+ const E = (l) => {
68
+ b.value = l;
69
+ };
70
+ return I({ switchTab: E }), (l, c) => (v(), u("div", {
71
+ ref_key: "containerRef",
72
+ ref: w,
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: W(a.value ? void 0 : { flexDirection: "column" })
75
+ }, [
76
+ r.mobileTabMode && !a.value ? (v(), u(B, { key: 0 }, [
77
+ i("div", Re, [
78
+ i("button", {
79
+ type: "button",
80
+ class: U(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", b.value === "left" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
81
+ onClick: c[0] || (c[0] = (F) => E("left"))
82
+ }, T(r.leftTabLabel ?? g(p)("zip.file_tree")), 3),
83
+ i("button", {
84
+ type: "button",
85
+ class: U(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", b.value === "right" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
86
+ onClick: c[1] || (c[1] = (F) => E("right"))
87
+ }, T(r.rightTabLabel ?? g(p)("toolbar.preview")), 3)
88
+ ]),
89
+ V(i("div", Ce, [
90
+ N(l.$slots, "left", {}, void 0, !0)
91
+ ], 512), [
92
+ [Z, b.value === "left"]
93
+ ]),
94
+ V(i("div", Ee, [
95
+ N(l.$slots, "right", {}, void 0, !0)
96
+ ], 512), [
97
+ [Z, b.value === "right"]
98
+ ])
99
+ ], 64)) : (v(), u(B, { key: 1 }, [
100
+ i("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: W(x.value)
103
+ }, [
104
+ N(l.$slots, "left", {}, void 0, !0)
105
+ ], 4),
106
+ i("div", {
107
+ role: "separator",
108
+ "aria-orientation": "vertical",
109
+ class: U(["split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors", z.value ? "dragging" : ""]),
110
+ style: W(a.value ? void 0 : { display: "none" }),
111
+ onMousedown: R
112
+ }, [...c[2] || (c[2] = [
113
+ i("span", { class: "vfp-absolute vfp-inset-y-0 hit-area" }, null, -1)
114
+ ])], 38),
115
+ i("div", Me, [
116
+ N(l.$slots, "right", {}, void 0, !0)
117
+ ])
118
+ ], 64))
119
+ ], 4));
120
+ }
121
+ }), De = /* @__PURE__ */ ne(We, [["__scopeId", "data-v-45379cb1"]]), Ie = { key: 0 }, Fe = { class: "vfp-truncate vfp-flex-1 vfp-min-w-0" }, Ue = { class: "vfp-flex-1 vfp-truncate vfp-min-w-0" }, Be = { class: "vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2" }, He = { name: "ZipTreeItem" }, Ne = /* @__PURE__ */ O({
122
+ ...He,
123
+ props: {
124
+ node: {},
125
+ depth: {},
126
+ selectedPath: {},
127
+ expanded: {}
128
+ },
129
+ emits: ["toggle", "select", "hover", "leave"],
130
+ setup(r, { emit: I }) {
131
+ const n = r, p = I, w = C(() => ({ paddingLeft: `${n.depth * 14 + 10}px` })), f = C(() => n.expanded.has(n.node.path)), z = C(() => n.selectedPath === n.node.path), y = C(() => {
132
+ const o = pe({ name: n.node.name, type: "" });
133
+ return o === "image" ? ye : o === "text" || o === "markdown" || o === "json" || o === "csv" || o === "xml" || o === "subtitle" ? n.node.name.endsWith(".md") || n.node.name.endsWith(".markdown") ? ke : Le : ze;
134
+ }), _ = (o) => {
135
+ const t = o.currentTarget.getBoundingClientRect();
136
+ p("hover", n.node.name || "/", t);
137
+ }, b = () => p("leave");
138
+ return (o, t) => {
139
+ const k = ve("ZipTreeItem");
140
+ return r.node.isDir ? (v(), u("div", Ie, [
141
+ i("button", {
142
+ type: "button",
143
+ class: "tree-row dir-row",
144
+ style: W(w.value),
145
+ onClick: t[0] || (t[0] = (x) => p("toggle", r.node.path)),
146
+ onMouseenter: _,
147
+ onMouseleave: b
148
+ }, [
149
+ j(g(Se), {
150
+ class: U(["vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0 vfp-transition-transform", { "vfp-rotate-90": f.value }])
151
+ }, null, 8, ["class"]),
152
+ (v(), D(q(f.value ? g(Te) : g(_e)), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80" })),
153
+ i("span", Fe, T(r.node.name || "/"), 1)
154
+ ], 36),
155
+ f.value && r.node.children ? (v(!0), u(B, { key: 0 }, Q(r.node.children, (x) => (v(), D(k, {
156
+ key: x.path,
157
+ node: x,
158
+ depth: r.depth + 1,
159
+ "selected-path": r.selectedPath,
160
+ expanded: r.expanded,
161
+ onToggle: t[1] || (t[1] = (a) => p("toggle", a)),
162
+ onSelect: t[2] || (t[2] = (a) => p("select", a)),
163
+ onHover: t[3] || (t[3] = (a, S) => p("hover", a, S)),
164
+ onLeave: t[4] || (t[4] = (a) => p("leave"))
165
+ }, null, 8, ["node", "depth", "selected-path", "expanded"]))), 128)) : ee("", !0)
166
+ ])) : (v(), u("button", {
167
+ key: 1,
168
+ type: "button",
169
+ class: U(["tree-row file-row", { selected: z.value }]),
170
+ style: W(w.value),
171
+ onClick: t[5] || (t[5] = (x) => p("select", r.node)),
172
+ onMouseenter: _,
173
+ onMouseleave: b
174
+ }, [
175
+ t[6] || (t[6] = i("span", { class: "vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0" }, null, -1)),
176
+ (v(), D(q(y.value), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary" })),
177
+ i("span", Ue, T(r.node.name), 1),
178
+ i("span", Be, T(g(ue)(r.node.size)), 1)
179
+ ], 38));
180
+ };
181
+ }
182
+ }), je = /* @__PURE__ */ ne(Ne, [["__scopeId", "data-v-124c382d"]]), Ke = {
183
+ key: 0,
184
+ class: "vfp-renderer-loading"
185
+ }, Pe = { class: "vfp-renderer-loading-content" }, Oe = { class: "vfp-renderer-loading-text" }, Ae = { class: "vfp-w-full vfp-h-full vfp-overflow-auto" }, Ve = { class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col" }, Ze = {
186
+ key: 0,
187
+ class: "vfp-renderer-loading vfp-flex-1"
188
+ }, qe = { class: "vfp-renderer-loading-content" }, Ge = { class: "vfp-renderer-loading-text" }, Xe = {
189
+ key: 1,
190
+ class: "vfp-flex-1"
191
+ }, Je = {
192
+ key: 2,
193
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-muted vfp-text-sm vfp-p-6"
194
+ }, Ye = {
195
+ key: 3,
196
+ class: "vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0"
197
+ }, ot = /* @__PURE__ */ O({
198
+ __name: "index",
199
+ props: {
200
+ url: {},
201
+ nestingDepth: { default: 0 }
202
+ },
203
+ setup(r, { expose: I }) {
204
+ const n = fe(
205
+ () => import("./index-DBzyeU0G.mjs").then((e) => e.a2)
206
+ ), p = r, w = new $e(), { t: f } = te(), z = ce(), y = me(), _ = (e) => {
207
+ y.error(e.error, e.stage);
208
+ }, b = d(null), o = d(null), t = d(!0), k = d(null), x = d(/* @__PURE__ */ new Set([""])), a = d(null), S = d(!1), $ = d(null), R = d(null), E = d(null), l = d(null), c = () => {
209
+ var e;
210
+ (e = a.value) != null && e.blobUrl && URL.revokeObjectURL(a.value.blobUrl);
211
+ }, F = async () => {
212
+ y.begin(p.url), c(), a.value = null, t.value = !0, k.value = null;
213
+ try {
214
+ const e = await z.value(p.url);
215
+ if (!e.ok) throw new he("common.load_failed");
216
+ const s = await e.arrayBuffer(), m = await ge(s), L = we(m), h = be(L);
217
+ b.value = m, o.value = h;
218
+ const M = /* @__PURE__ */ new Set([""]);
219
+ if (h.children)
220
+ for (const H of h.children) H.isDir && M.add(H.path);
221
+ x.value = M, y.ready();
222
+ } catch (e) {
223
+ console.error(e), k.value = f.value("zip.load_failed"), y.error(e);
224
+ } finally {
225
+ t.value = !1;
226
+ }
227
+ };
228
+ P(() => p.url, (e) => {
229
+ e && F();
230
+ }, { immediate: !0 }), Y(() => {
231
+ c();
232
+ });
233
+ const K = C(() => {
234
+ if (!o.value) return null;
235
+ let e = 0, s = 0, m = 0;
236
+ const L = (h) => {
237
+ var M;
238
+ h.isDir ? (h.path && s++, (M = h.children) == null || M.forEach(L)) : (e++, m += h.size);
239
+ };
240
+ return L(o.value), { files: e, dirs: s, size: m };
241
+ });
242
+ P(K, () => w.notify()), I({
243
+ getToolbarGroups: () => [],
244
+ onToolbarChange: (e) => w.subscribe(e)
245
+ });
246
+ const le = (e) => {
247
+ const s = new Set(x.value);
248
+ s.has(e) ? s.delete(e) : s.add(e), x.value = s;
249
+ }, oe = (e, s) => {
250
+ const m = typeof window < "u" ? window.innerWidth - 328 : s.right + 8;
251
+ R.value = { text: e, x: Math.max(8, Math.min(s.right + 8, m)), y: s.top + s.height / 2 };
252
+ }, ae = () => {
253
+ R.value = null;
254
+ }, se = async (e) => {
255
+ var s, m, L;
256
+ if (!(!b.value || e.isDir || ((s = a.value) == null ? void 0 : s.path) === e.path || l.value === e.path)) {
257
+ l.value = e.path, c(), a.value = null, S.value = !0, $.value = null;
258
+ try {
259
+ const h = X(e.name), M = await xe(b.value, e.path, h !== "application/octet-stream" ? h : void 0), H = URL.createObjectURL(M);
260
+ a.value = { path: e.path, name: e.name, size: e.size, blobUrl: H }, (m = E.value) == null || m.switchTab("right");
261
+ } catch (h) {
262
+ console.error(h), $.value = f.value("zip.entry_read_failed"), (L = E.value) == null || L.switchTab("right");
263
+ } finally {
264
+ S.value = !1, l.value === e.path && (l.value = null);
265
+ }
266
+ }
267
+ }, ie = C(() => a.value ? [{ name: a.value.name, url: a.value.blobUrl, type: X(a.value.name) }] : []);
268
+ return (e, s) => t.value ? (v(), u("div", Ke, [
269
+ i("div", Pe, [
270
+ s[0] || (s[0] = i("div", { class: "vfp-renderer-spinner" }, null, -1)),
271
+ i("span", Oe, T(g(f)("common.loading")), 1)
272
+ ])
273
+ ])) : k.value || !o.value ? (v(), D(J, {
274
+ key: 1,
275
+ message: k.value || g(f)("zip.parse_failed")
276
+ }, null, 8, ["message"])) : (v(), u(B, { key: 2 }, [
277
+ j(De, {
278
+ ref_key: "splitRef",
279
+ ref: E,
280
+ "initial-left-width": 280,
281
+ "min-left-width": 180,
282
+ "max-left-width": 560,
283
+ "storage-key": "vfp-zip-split-left",
284
+ "mobile-tab-mode": "",
285
+ "left-tab-label": g(f)("zip.file_tree"),
286
+ "right-tab-label": g(f)("toolbar.preview")
287
+ }, {
288
+ left: G(() => [
289
+ i("div", Ae, [
290
+ (v(!0), u(B, null, Q(o.value.children || [], (m) => {
291
+ var L;
292
+ return v(), D(je, {
293
+ key: m.path,
294
+ node: m,
295
+ depth: 0,
296
+ "selected-path": ((L = a.value) == null ? void 0 : L.path) ?? null,
297
+ expanded: x.value,
298
+ onToggle: le,
299
+ onSelect: se,
300
+ onHover: oe,
301
+ onLeave: ae
302
+ }, null, 8, ["node", "selected-path", "expanded"]);
303
+ }), 128))
304
+ ])
305
+ ]),
306
+ right: G(() => [
307
+ i("div", Ve, [
308
+ S.value ? (v(), u("div", Ze, [
309
+ i("div", qe, [
310
+ s[1] || (s[1] = i("div", { class: "vfp-renderer-spinner" }, null, -1)),
311
+ i("span", Ge, T(g(f)("common.loading")), 1)
312
+ ])
313
+ ])) : $.value ? (v(), u("div", Xe, [
314
+ j(J, { message: $.value }, null, 8, ["message"])
315
+ ])) : a.value ? (v(), u("div", Ye, [
316
+ j(g(n), {
317
+ mode: "embed",
318
+ files: ie.value,
319
+ "current-index": 0,
320
+ "zip-nesting-depth": r.nestingDepth + 1,
321
+ onError: _
322
+ }, null, 8, ["files", "zip-nesting-depth"])
323
+ ])) : (v(), u("div", Je, T(g(f)("zip.select_file")), 1))
324
+ ])
325
+ ]),
326
+ _: 1
327
+ }, 8, ["left-tab-label", "right-tab-label"]),
328
+ (v(), D(de, { to: "body" }, [
329
+ R.value ? (v(), u("div", {
330
+ key: 0,
331
+ class: "vfp-zip-tip",
332
+ style: W({
333
+ position: "fixed",
334
+ zIndex: 2147483647,
335
+ pointerEvents: "none",
336
+ display: "block",
337
+ transform: "translateY(-50%)",
338
+ padding: "4px 8px",
339
+ background: "rgba(0, 0, 0, 0.85)",
340
+ color: "#fff",
341
+ fontSize: "12px",
342
+ lineHeight: 1.5,
343
+ borderRadius: "4px",
344
+ whiteSpace: "nowrap",
345
+ maxWidth: "min(320px, calc(100vw - 16px))",
346
+ overflow: "hidden",
347
+ textOverflow: "ellipsis",
348
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.3)",
349
+ left: R.value.x + "px",
350
+ top: R.value.y + "px"
351
+ })
352
+ }, T(R.value.text), 5)) : ee("", !0)
353
+ ]))
354
+ ], 64));
355
+ }
356
+ });
357
+ export {
358
+ ot as default
359
+ };
@@ -0,0 +1,122 @@
1
+ import { defineComponent as A, ref as h, watch as T, computed as p, openBlock as r, createElementBlock as o, createElementVNode as s, toDisplayString as a, unref as n, createBlock as D, normalizeClass as B, Fragment as w, renderList as C, createCommentVNode as E } from "vue";
2
+ import { u as I, a as J, b as M, i as O, o as f, f as P, d as R } from "./index-DBzyeU0G.mjs";
3
+ import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
4
+ const Y = {
5
+ key: 0,
6
+ class: "vfp-renderer-loading vfp-bg-[#0f0f12]"
7
+ }, $ = { class: "vfp-renderer-loading-content" }, j = { class: "vfp-renderer-loading-text" }, q = { class: "content-scroll" }, H = { class: "timeline" }, K = { class: "cues" }, Q = { class: "cue-meta" }, U = { class: "cue-time" }, W = { class: "cue-time" }, Z = { class: "cue-id" }, ee = {
8
+ key: 0,
9
+ class: "cue-style"
10
+ }, se = {
11
+ key: 0,
12
+ class: "cue-words"
13
+ }, te = ["title"], le = { class: "cue-word-time" }, re = { class: "cue-word-text" }, ae = { class: "status-pill" }, oe = /* @__PURE__ */ A({
14
+ __name: "index",
15
+ props: {
16
+ url: {},
17
+ fileName: {}
18
+ },
19
+ setup(F, { expose: N }) {
20
+ const i = F, { t: u } = I(), L = J(), d = M(), m = h(""), _ = h(!0), v = h(null), S = {
21
+ srt: "srt",
22
+ vtt: "vtt",
23
+ lrc: "lrc",
24
+ elrc: "elrc",
25
+ ass: "ass",
26
+ ssa: "ssa",
27
+ ttml: "ttml",
28
+ dfxp: "ttml"
29
+ }, G = (e) => {
30
+ var l;
31
+ const t = ((l = e.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
32
+ return S[t];
33
+ };
34
+ T(() => i.url, async () => {
35
+ d.begin(i.url), _.value = !0, v.value = null;
36
+ try {
37
+ m.value = await P(i.url, { fetcher: L.value });
38
+ } catch (e) {
39
+ console.error(e), v.value = u.value("subtitle.load_failed"), d.error(e);
40
+ } finally {
41
+ _.value = !1;
42
+ }
43
+ }, { immediate: !0 });
44
+ const x = p(() => {
45
+ if (!m.value) return { value: null, error: null };
46
+ try {
47
+ return { value: O(m.value, G(i.fileName)), error: null };
48
+ } catch (e) {
49
+ return console.error(e), { value: null, error: e };
50
+ }
51
+ });
52
+ T(x, (e) => {
53
+ e.error ? d.error(e.error) : e.value && d.ready();
54
+ });
55
+ const c = p(() => x.value.value), y = p(() => {
56
+ var e, t;
57
+ return ((e = c.value) == null ? void 0 : e.format) === "lrc" || ((t = c.value) == null ? void 0 : t.format) === "elrc";
58
+ }), b = p(() => {
59
+ var e;
60
+ return ((e = c.value) == null ? void 0 : e.metadata) ?? {};
61
+ }), V = (e) => f(e).slice(3, 8);
62
+ return N({
63
+ getToolbarGroups: () => []
64
+ }), (e, t) => _.value ? (r(), o("div", Y, [
65
+ s("div", $, [
66
+ t[0] || (t[0] = s("div", { class: "vfp-renderer-spinner" }, null, -1)),
67
+ s("span", j, a(n(u)("common.loading")), 1)
68
+ ])
69
+ ])) : v.value || !c.value ? (r(), D(X, {
70
+ key: 1,
71
+ message: v.value || n(u)("subtitle.parse_failed"),
72
+ class: "vfp-bg-[#0f0f12]"
73
+ }, null, 8, ["message"])) : (r(), o("div", {
74
+ key: 2,
75
+ class: B(["vfp-relative vfp-w-full vfp-h-full vfp-bg-[#0f0f12]", y.value ? "flavor-lyric" : "flavor-subtitle"])
76
+ }, [
77
+ s("div", q, [
78
+ s("div", H, [
79
+ t[3] || (t[3] = s("div", { class: "timeline-line" }, null, -1)),
80
+ s("ol", K, [
81
+ (r(!0), o(w, null, C(c.value.cues, (l, k) => (r(), o("li", {
82
+ key: "cue-" + k,
83
+ class: "cue-row"
84
+ }, [
85
+ t[2] || (t[2] = s("div", { class: "cue-dot" }, null, -1)),
86
+ s("div", Q, [
87
+ s("span", U, a(n(f)(l.start)), 1),
88
+ t[1] || (t[1] = s("span", { class: "cue-arrow" }, "→", -1)),
89
+ s("span", W, a(n(f)(l.end)), 1),
90
+ s("span", Z, "#" + a(l.id ?? k + 1), 1),
91
+ l.style ? (r(), o("span", ee, a(l.style), 1)) : E("", !0)
92
+ ]),
93
+ l.words && l.words.length > 0 ? (r(), o("div", se, [
94
+ (r(!0), o(w, null, C(l.words, (g, z) => (r(), o("span", {
95
+ key: "w-" + z,
96
+ class: "cue-word",
97
+ title: n(f)(g.start)
98
+ }, [
99
+ s("span", le, a(V(g.start)), 1),
100
+ s("span", re, a(g.text), 1)
101
+ ], 8, te))), 128))
102
+ ])) : (r(), o("p", {
103
+ key: 1,
104
+ class: B(["cue-text", { lyric: y.value }])
105
+ }, a(l.text), 3))
106
+ ]))), 128))
107
+ ])
108
+ ])
109
+ ]),
110
+ s("div", ae, [
111
+ s("span", null, a(c.value.cues.length) + " " + a(y.value ? n(u)("subtitle.lines") : n(u)("subtitle.cues")), 1),
112
+ b.value.length ? (r(), o(w, { key: 0 }, [
113
+ t[4] || (t[4] = s("span", { class: "dot" }, "·", -1)),
114
+ s("span", null, a(b.value.length), 1)
115
+ ], 64)) : E("", !0)
116
+ ])
117
+ ], 2));
118
+ }
119
+ }), ve = /* @__PURE__ */ R(oe, [["__scopeId", "data-v-f89221c5"]]);
120
+ export {
121
+ ve as default
122
+ };