@eternalheart/vue-file-preview 1.6.13 → 1.7.0

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 (125) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/lib/FilePreviewContent.vue.d.ts +17 -6
  4. package/lib/FilePreviewEmbed.vue.d.ts +14 -6
  5. package/lib/FilePreviewModal.vue.d.ts +14 -6
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-CnJpGYJ2.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-g_dLrWLP.mjs} +1 -1
  9. package/lib/chunks/index-6XZXYqbp.mjs +125 -0
  10. package/lib/chunks/{index-B21EAyWz.mjs → index-BPSzwMOC.mjs} +51 -51
  11. package/lib/chunks/index-BYQ9S7Mk.mjs +104 -0
  12. package/lib/chunks/{index-8Vpbg2kS.mjs → index-Bf94DwQu.mjs} +105 -104
  13. package/lib/chunks/index-BfOWoMpY.mjs +359 -0
  14. package/lib/chunks/index-Bg8poMIm.mjs +117 -0
  15. package/lib/chunks/index-BzwJ0VWu.mjs +108 -0
  16. package/lib/chunks/index-C41YET0_.mjs +51 -0
  17. package/lib/chunks/{index-BvBqDq3O.mjs → index-C4hIk6pa.mjs} +2023 -2023
  18. package/lib/chunks/{index-BASg1cr4.mjs → index-C8lyQPe3.mjs} +1018 -1018
  19. package/lib/chunks/{index-C9mAajbD.mjs → index-CWPdNhoe.mjs} +200 -200
  20. package/lib/chunks/{index-BuqPb5mP.mjs → index-CrVQPnFj.mjs} +112 -112
  21. package/lib/chunks/{index-D30L8tm9.mjs → index-D5IF9F-D.mjs} +57 -57
  22. package/lib/chunks/{index-DN4Ui0Gh.mjs → index-DFeKS8tR.mjs} +120 -120
  23. package/lib/chunks/index-DM8Dfl-m.mjs +52 -0
  24. package/lib/chunks/index-DZe0BxAB.mjs +90 -0
  25. package/lib/chunks/{index-BlrFFeqc.mjs → index-GFcSJEwj.mjs} +75 -75
  26. package/lib/chunks/{index-Dkro_8Fy.mjs → index-LPGxJDnT.mjs} +32 -32
  27. package/lib/chunks/index-aKiIuKKx.mjs +157 -0
  28. package/lib/chunks/{index-DZZN3kYi.mjs → index-c-pYJEmH.mjs} +1589 -1394
  29. package/lib/chunks/{index-CxKZKUJj.mjs → index-z9RqL2wI.mjs} +1651 -1651
  30. package/lib/chunks/index-zLQlyNR2.mjs +383 -0
  31. package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-fCO1knZ0.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-DihMskai.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-BSfDPl-z.mjs} +5 -5
  34. package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-JY5DaTre.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-C-ztcJBE.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 +52 -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-BB0i4QqI.mjs +0 -117
  118. package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
  119. package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
  120. package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
  121. package/lib/chunks/index-CDg6vIbT.mjs +0 -51
  122. package/lib/chunks/index-CWE-hKSs.mjs +0 -90
  123. package/lib/chunks/index-CY3xzGgt.mjs +0 -108
  124. package/lib/chunks/index-VdzIFJJW.mjs +0 -118
  125. package/lib/chunks/index-aoXgVLBb.mjs +0 -52
@@ -0,0 +1,359 @@
1
+ import { defineComponent as O, ref as d, computed as C, onMounted as re, onBeforeUnmount as Y, watch as j, 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 K, 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, e as ne, S as pe, X as ue, a as ce, b as me, r as J, J as he, w as ge, x as we, z as xe, H as be } from "./index-c-pYJEmH.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 A } 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
+ ), L = d(!1), z = d(!1), _ = d(!0), x = d("left");
30
+ let o = null, t = null;
31
+ const y = () => {
32
+ o && (z.value = o.matches);
33
+ }, b = C(
34
+ () => z.value && _.value ? { width: `${f.value}px` } : void 0
35
+ ), a = C(() => z.value && _.value), S = (l) => {
36
+ if (!w.value) return;
37
+ const c = w.value.getBoundingClientRect(), F = l.clientX - c.left, P = c.width - n.minRightWidth - 6, X = Math.min(n.maxLeftWidth, P);
38
+ f.value = Math.max(
39
+ n.minLeftWidth,
40
+ Math.min(X, F)
41
+ );
42
+ }, $ = () => {
43
+ if (L.value && (L.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(), L.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), y(), o.addEventListener("change", y);
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", y), t == null || t.disconnect(), t = null, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", $), L.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
61
+ }), j(
62
+ () => n.initialLeftWidth,
63
+ (l) => {
64
+ n.storageKey || (f.value = l);
65
+ }
66
+ );
67
+ const E = (l) => {
68
+ x.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", x.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", x.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, x.value === "left"]
93
+ ]),
94
+ V(i("div", Ee, [
95
+ N(l.$slots, "right", {}, void 0, !0)
96
+ ], 512), [
97
+ [Z, x.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(b.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", L.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)), L = C(() => n.selectedPath === n.node.path), z = 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
+ }, x = () => p("leave");
138
+ return (o, t) => {
139
+ const y = 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] = (b) => p("toggle", r.node.path)),
146
+ onMouseenter: _,
147
+ onMouseleave: x
148
+ }, [
149
+ K(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, (b) => (v(), D(y, {
156
+ key: b.path,
157
+ node: b,
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: L.value }]),
170
+ style: W(w.value),
171
+ onClick: t[5] || (t[5] = (b) => p("select", r.node)),
172
+ onMouseenter: _,
173
+ onMouseleave: x
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(z.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
+ }), Ke = /* @__PURE__ */ ne(Ne, [["__scopeId", "data-v-124c382d"]]), Pe = {
183
+ key: 0,
184
+ class: "vfp-renderer-loading"
185
+ }, je = { class: "vfp-renderer-loading-content" }, Oe = { class: "vfp-renderer-loading-text" }, Xe = { 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" }, Je = {
189
+ key: 1,
190
+ class: "vfp-flex-1"
191
+ }, Ae = {
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-c-pYJEmH.mjs").then((e) => e.a2)
206
+ ), p = r, w = new $e(), { t: f } = te(), L = ce(), z = me(), _ = (e) => {
207
+ z.error(e.error, e.stage);
208
+ }, x = d(null), o = d(null), t = d(!0), y = d(null), b = 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
+ z.begin(p.url), c(), a.value = null, t.value = !0, y.value = null;
213
+ try {
214
+ const e = await L.value(p.url);
215
+ if (!e.ok) throw new he("common.load_failed");
216
+ const s = await e.arrayBuffer(), m = await ge(s), k = we(m), h = xe(k);
217
+ x.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
+ b.value = M;
222
+ } catch (e) {
223
+ console.error(e), y.value = f.value("zip.load_failed"), z.error(e);
224
+ } finally {
225
+ t.value = !1;
226
+ }
227
+ };
228
+ j(() => p.url, (e) => {
229
+ e && F();
230
+ }, { immediate: !0 }), Y(() => {
231
+ c();
232
+ });
233
+ const P = C(() => {
234
+ if (!o.value) return null;
235
+ let e = 0, s = 0, m = 0;
236
+ const k = (h) => {
237
+ var M;
238
+ h.isDir ? (h.path && s++, (M = h.children) == null || M.forEach(k)) : (e++, m += h.size);
239
+ };
240
+ return k(o.value), { files: e, dirs: s, size: m };
241
+ });
242
+ j(P, () => w.notify()), I({
243
+ getToolbarGroups: () => [],
244
+ onToolbarChange: (e) => w.subscribe(e)
245
+ });
246
+ const le = (e) => {
247
+ const s = new Set(b.value);
248
+ s.has(e) ? s.delete(e) : s.add(e), b.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, k;
256
+ if (!(!x.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 = J(e.name), M = await be(x.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"), (k = E.value) == null || k.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: J(a.value.name) }] : []);
268
+ return (e, s) => t.value ? (v(), u("div", Pe, [
269
+ i("div", je, [
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
+ ])) : y.value || !o.value ? (v(), D(A, {
274
+ key: 1,
275
+ message: y.value || g(f)("zip.parse_failed")
276
+ }, null, 8, ["message"])) : (v(), u(B, { key: 2 }, [
277
+ K(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", Xe, [
290
+ (v(!0), u(B, null, Q(o.value.children || [], (m) => {
291
+ var k;
292
+ return v(), D(Ke, {
293
+ key: m.path,
294
+ node: m,
295
+ depth: 0,
296
+ "selected-path": ((k = a.value) == null ? void 0 : k.path) ?? null,
297
+ expanded: b.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", Je, [
314
+ K(A, { message: $.value }, null, 8, ["message"])
315
+ ])) : a.value ? (v(), u("div", Ye, [
316
+ K(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", Ae, 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,117 @@
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 h, createBlock as E, normalizeClass as H, normalizeStyle as z, Fragment as C, renderList as G } from "vue";
2
+ import { WrapText as M, Code as P, Eye as W } from "lucide-vue-next";
3
+ import { u as D, a as R, b as V, T as j, y as q, s as A, h as I } from "./index-c-pYJEmH.mjs";
4
+ import { u as J } from "./useShikiHighlight-C-ztcJBE.mjs";
5
+ import { _ as K } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ import { _ as O } from "./EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs";
7
+ import { T as Q } from "./base.types-DaftHyg7.mjs";
8
+ const U = {
9
+ key: 0,
10
+ class: "vfp-renderer-loading"
11
+ }, X = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
12
+ key: 3,
13
+ class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
14
+ }, ee = ["srcdoc", "title"], le = {
15
+ key: 4,
16
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
17
+ style: { background: "var(--fp-code-bg)" }
18
+ }, te = {
19
+ key: 5,
20
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
21
+ style: { background: "var(--fp-code-bg)" }
22
+ }, oe = { class: "vfp-code-gutter" }, ae = ["innerHTML"], me = /* @__PURE__ */ $({
23
+ __name: "index",
24
+ props: {
25
+ url: {},
26
+ fileName: {},
27
+ emptyHint: {}
28
+ },
29
+ setup(y, { expose: L }) {
30
+ const v = y, _ = new Q(), { t: s } = D(), N = R(), b = V(), o = f(!0), a = f(!1), r = f(""), p = f(!0), c = f(null), n = d(() => j(v.fileName)), S = d(() => n.value !== "text" ? r.value : ""), { lineHtmls: w, loading: B } = J(S, n), x = d(() => n.value === "html"), F = d(
31
+ () => !p.value && !c.value && q(r.value) && A(v.emptyHint, "textual")
32
+ );
33
+ T([o, a, p, x], () => {
34
+ _.notify();
35
+ }), T(() => v.url, async () => {
36
+ b.begin(v.url), p.value = !0, c.value = null;
37
+ try {
38
+ const e = await I(v.url, { fetcher: N.value });
39
+ r.value = e;
40
+ } catch (e) {
41
+ console.error(e), c.value = s.value("text.load_failed"), b.error(e);
42
+ } finally {
43
+ p.value = !1;
44
+ }
45
+ }, { immediate: !0 });
46
+ const k = d(() => r.value.split(`
47
+ `));
48
+ return L({
49
+ getToolbarGroups: () => {
50
+ const e = [];
51
+ return e.push({
52
+ items: [
53
+ {
54
+ type: "button",
55
+ icon: M,
56
+ tooltip: o.value ? s.value("toolbar.wrap_off") : s.value("toolbar.wrap_on"),
57
+ action: () => {
58
+ o.value = !o.value;
59
+ },
60
+ active: o.value
61
+ }
62
+ ]
63
+ }), x.value && e.push({
64
+ items: [
65
+ {
66
+ type: "button",
67
+ icon: a.value ? P : W,
68
+ tooltip: a.value ? s.value("toolbar.source") : s.value("toolbar.preview"),
69
+ action: () => {
70
+ a.value = !a.value;
71
+ },
72
+ active: a.value
73
+ }
74
+ ]
75
+ }), e;
76
+ },
77
+ onToolbarChange: (e) => _.subscribe(e)
78
+ }), (e, u) => p.value || n.value !== "text" && m(B) ? (t(), i("div", U, [
79
+ l("div", X, [
80
+ u[0] || (u[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
81
+ l("span", Y, h(m(s)("common.loading")), 1)
82
+ ])
83
+ ])) : c.value ? (t(), E(K, {
84
+ key: 1,
85
+ message: c.value
86
+ }, null, 8, ["message"])) : F.value ? (t(), E(O, { key: 2 })) : a.value && n.value === "html" ? (t(), i("div", Z, [
87
+ l("iframe", {
88
+ srcdoc: r.value,
89
+ sandbox: "allow-same-origin",
90
+ class: "vfp-w-full vfp-h-full vfp-border-0",
91
+ title: y.fileName
92
+ }, null, 8, ee)
93
+ ])) : n.value === "text" || m(w).length === 0 ? (t(), i("div", le, [
94
+ l("pre", {
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
+ }, h(r.value), 3)
97
+ ])) : (t(), i("div", te, [
98
+ l("div", {
99
+ class: H(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !o.value }]),
100
+ style: z({ gridTemplateRows: `repeat(${k.value.length}, auto) minmax(1.5rem, 1fr)` })
101
+ }, [
102
+ (t(!0), i(C, null, G(k.value, (ne, g) => (t(), i(C, { key: g }, [
103
+ l("span", oe, h(g + 1), 1),
104
+ l("span", {
105
+ class: "vfp-code-line",
106
+ innerHTML: m(w)[g] ?? ""
107
+ }, null, 8, ae)
108
+ ], 64))), 128)),
109
+ u[1] || (u[1] = l("span", { class: "vfp-code-gutter-filler" }, null, -1)),
110
+ u[2] || (u[2] = l("span", { class: "vfp-code-line-filler" }, null, -1))
111
+ ], 6)
112
+ ]));
113
+ }
114
+ });
115
+ export {
116
+ me as default
117
+ };
@@ -0,0 +1,108 @@
1
+ import { defineComponent as M, ref as a, watch as w, nextTick as $, computed as T, openBlock as i, createElementBlock as p, createElementVNode as l, toDisplayString as B, unref as I, createBlock as F, normalizeStyle as f, Fragment as C, renderList as R } from "vue";
2
+ import { u as j, a as q, b as z, f as J, J as O, N as U, d as V } from "./index-c-pYJEmH.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__ */ M({
13
+ __name: "index",
14
+ props: {
15
+ url: {}
16
+ },
17
+ setup(G, { expose: H }) {
18
+ const P = b - k * 2, d = G, { t: v } = j(), A = q(), _ = z(), r = a(""), m = a(!0), c = a(null), s = a([]), h = a({}), g = a(null), S = async () => {
19
+ _.begin(d.url), m.value = !0, c.value = null, r.value = "", s.value = [], h.value = {};
20
+ try {
21
+ const e = await A.value(d.url);
22
+ if (!e.ok) throw new O("file.load_failed");
23
+ const n = await e.arrayBuffer(), [t, o] = await Promise.all([
24
+ W.convertToHtml({ arrayBuffer: n }, { styleMap: U }),
25
+ V(n).catch(() => ({}))
26
+ ]);
27
+ h.value = o, r.value = t.value;
28
+ } catch (e) {
29
+ console.error(v.value("docx.parse_failed") + ":", e), c.value = v.value("docx.parse_failed"), _.error(e);
30
+ } finally {
31
+ m.value = !1;
32
+ }
33
+ }, N = () => {
34
+ const e = g.value;
35
+ if (!e || !r.value) return;
36
+ const n = Array.from(e.children);
37
+ if (n.length === 0) {
38
+ s.value = [r.value];
39
+ return;
40
+ }
41
+ const t = [[]];
42
+ let o = 0;
43
+ for (const u of n) {
44
+ const y = u.offsetHeight;
45
+ o > 0 && o + y > P && (t.push([]), o = 0), t[t.length - 1].push(u.outerHTML), o += y;
46
+ }
47
+ t.length === 0 && t.push([]), s.value = t.map((u) => u.join(""));
48
+ };
49
+ w(() => d.url, (e) => {
50
+ e && S();
51
+ }, { immediate: !0 }), w(r, async () => {
52
+ r.value && (await $(), requestAnimationFrame(() => N()));
53
+ });
54
+ const x = T(() => J(h.value)), D = T(() => ({
55
+ ...x.value,
56
+ position: "absolute",
57
+ visibility: "hidden",
58
+ width: `${794 - E * 2}px`,
59
+ pointerEvents: "none"
60
+ })), L = {
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) => m.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, B(I(v)("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: f(D.value),
84
+ innerHTML: r.value
85
+ }, null, 12, ee),
86
+ l("div", {
87
+ class: "vfp-flex vfp-flex-col vfp-items-center",
88
+ style: f({ gap: `${ne}px` })
89
+ }, [
90
+ (i(!0), p(C, null, R(s.value.length > 0 ? s.value : [""], (t, o) => (i(), p("div", {
91
+ key: o,
92
+ style: f({
93
+ ...L,
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: f(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,51 @@
1
+ import { defineComponent as m, ref as i, watch as g, openBlock as p, createElementBlock as c, createElementVNode as a, toDisplayString as h, unref as w, createBlock as y } from "vue";
2
+ import { u as k, a as x, b, J as T, C as B } from "./index-c-pYJEmH.mjs";
3
+ import { _ as E } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
4
+ const C = {
5
+ key: 0,
6
+ class: "vfp-renderer-loading"
7
+ }, G = { class: "vfp-renderer-loading-content" }, H = { class: "vfp-renderer-loading-text" }, L = {
8
+ key: 2,
9
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-6 vfp-px-4"
10
+ }, M = ["innerHTML"], J = /* @__PURE__ */ m({
11
+ __name: "index",
12
+ props: {
13
+ url: {}
14
+ },
15
+ setup(f, { expose: v }) {
16
+ const t = f, { t: s } = k(), d = x(), u = b(), l = i(""), n = i(!0), r = i(null), _ = async () => {
17
+ u.begin(t.url), n.value = !0, r.value = null, l.value = "";
18
+ try {
19
+ const e = await d.value(t.url);
20
+ if (!e.ok) throw new T("file.load_failed");
21
+ const o = await e.arrayBuffer();
22
+ l.value = await B(o);
23
+ } catch (e) {
24
+ console.error(s.value("ppt.parse_failed") + ":", e), r.value = s.value("ppt.parse_failed"), u.error(e);
25
+ } finally {
26
+ n.value = !1;
27
+ }
28
+ };
29
+ return g(() => t.url, (e) => {
30
+ e && _();
31
+ }, { immediate: !0 }), v({
32
+ getToolbarGroups: () => []
33
+ }), (e, o) => n.value ? (p(), c("div", C, [
34
+ a("div", G, [
35
+ o[0] || (o[0] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
36
+ a("span", H, h(w(s)("common.loading")), 1)
37
+ ])
38
+ ])) : r.value ? (p(), y(E, {
39
+ key: 1,
40
+ message: r.value
41
+ }, null, 8, ["message"])) : (p(), c("div", L, [
42
+ a("div", {
43
+ class: "vfp-legacy-ppt-wrap",
44
+ innerHTML: l.value
45
+ }, null, 8, M)
46
+ ]));
47
+ }
48
+ });
49
+ export {
50
+ J as default
51
+ };