@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
@@ -1,356 +0,0 @@
1
- import { defineComponent as Z, ref as d, computed as $, onMounted as ie, onBeforeUnmount as J, watch as O, openBlock as r, createElementBlock as c, normalizeStyle as E, Fragment as U, createElementVNode as a, normalizeClass as F, toDisplayString as _, unref as g, withDirectives as q, renderSlot as N, vShow as V, resolveComponent as se, createVNode as H, createBlock as D, resolveDynamicComponent as A, renderList as Q, createCommentVNode as ee, defineAsyncComponent as re, withCtx as G, Teleport as ve } from "vue";
2
- import { u as te, _ as ne, q as fe, s as de, c as pe, r as X, k as ue, v as ce, x as me, z as he, A as ge } from "./index-DZZN3kYi.mjs";
3
- import { FileImage as we, FileText as xe, FileCode as be, File as ye, ChevronRight as ke, FolderOpen as Le, Folder as ze } from "lucide-vue-next";
4
- import { _ as Y } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.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" }, _e = { 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-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Re = { class: "vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden" }, Ce = /* @__PURE__ */ Z({
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(s, { expose: I }) {
21
- const n = s, { t: u } = te(), w = d(null), f = d(
22
- (() => {
23
- if (n.storageKey && typeof window < "u") {
24
- const i = Number(window.localStorage.getItem(n.storageKey));
25
- if (!isNaN(i) && i > 0) return i;
26
- }
27
- return n.initialLeftWidth;
28
- })()
29
- ), S = d(!1), T = d(!1), x = d(!0), b = d("left");
30
- let l = null, t = null;
31
- const v = () => {
32
- l && (T.value = l.matches);
33
- }, L = $(
34
- () => T.value && x.value ? { width: `${f.value}px` } : void 0
35
- ), p = $(() => T.value && x.value), y = (i) => {
36
- if (!w.value) return;
37
- const k = w.value.getBoundingClientRect(), B = i.clientX - k.left, P = k.width - n.minRightWidth - 6, j = Math.min(n.maxLeftWidth, P);
38
- f.value = Math.max(
39
- n.minLeftWidth,
40
- Math.min(j, B)
41
- );
42
- }, R = () => {
43
- if (S.value && (S.value = !1, window.removeEventListener("mousemove", y), window.removeEventListener("mouseup", R), 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
- }, W = (i) => {
49
- i.preventDefault(), S.value = !0, window.addEventListener("mousemove", y), window.addEventListener("mouseup", R), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
50
- };
51
- ie(() => {
52
- if (typeof window < "u") {
53
- l = window.matchMedia(n.desktopMedia), v(), l.addEventListener("change", v);
54
- const i = () => {
55
- w.value && (x.value = w.value.getBoundingClientRect().width >= n.minLeftWidth + n.minRightWidth + 6);
56
- };
57
- i(), t = typeof ResizeObserver < "u" ? new ResizeObserver(i) : null, t == null || t.observe(w.value);
58
- }
59
- }), J(() => {
60
- l && l.removeEventListener("change", v), t == null || t.disconnect(), t = null, window.removeEventListener("mousemove", y), window.removeEventListener("mouseup", R), S.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
61
- }), O(
62
- () => n.initialLeftWidth,
63
- (i) => {
64
- n.storageKey || (f.value = i);
65
- }
66
- );
67
- const C = (i) => {
68
- b.value = i;
69
- };
70
- return I({ switchTab: C }), (i, k) => (r(), c("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: E(p.value ? void 0 : { flexDirection: "column" })
75
- }, [
76
- s.mobileTabMode && !p.value ? (r(), c(U, { key: 0 }, [
77
- a("div", Te, [
78
- a("button", {
79
- type: "button",
80
- class: F(["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: k[0] || (k[0] = (B) => C("left"))
82
- }, _(s.leftTabLabel ?? g(u)("zip.file_tree")), 3),
83
- a("button", {
84
- type: "button",
85
- class: F(["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: k[1] || (k[1] = (B) => C("right"))
87
- }, _(s.rightTabLabel ?? g(u)("toolbar.preview")), 3)
88
- ]),
89
- q(a("div", _e, [
90
- N(i.$slots, "left", {}, void 0, !0)
91
- ], 512), [
92
- [V, b.value === "left"]
93
- ]),
94
- q(a("div", $e, [
95
- N(i.$slots, "right", {}, void 0, !0)
96
- ], 512), [
97
- [V, b.value === "right"]
98
- ])
99
- ], 64)) : (r(), c(U, { key: 1 }, [
100
- a("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(L.value)
103
- }, [
104
- N(i.$slots, "left", {}, void 0, !0)
105
- ], 4),
106
- a("div", {
107
- role: "separator",
108
- "aria-orientation": "vertical",
109
- class: F(["split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors", S.value ? "dragging" : ""]),
110
- style: E(p.value ? void 0 : { display: "none" }),
111
- onMousedown: W
112
- }, [...k[2] || (k[2] = [
113
- a("span", { class: "vfp-absolute vfp-inset-y-0 hit-area" }, null, -1)
114
- ])], 38),
115
- a("div", Re, [
116
- N(i.$slots, "right", {}, void 0, !0)
117
- ])
118
- ], 64))
119
- ], 4));
120
- }
121
- }), Me = /* @__PURE__ */ ne(Ce, [["__scopeId", "data-v-45379cb1"]]), We = { key: 0 }, Ee = { class: "vfp-truncate vfp-flex-1 vfp-min-w-0" }, De = { class: "vfp-flex-1 vfp-truncate vfp-min-w-0" }, Ie = { class: "vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2" }, Fe = { name: "ZipTreeItem" }, Ue = /* @__PURE__ */ Z({
122
- ...Fe,
123
- props: {
124
- node: {},
125
- depth: {},
126
- selectedPath: {},
127
- expanded: {}
128
- },
129
- emits: ["toggle", "select", "hover", "leave"],
130
- setup(s, { emit: I }) {
131
- const n = s, u = I, w = $(() => ({ paddingLeft: `${n.depth * 14 + 10}px` })), f = $(() => n.expanded.has(n.node.path)), S = $(() => n.selectedPath === n.node.path), T = $(() => {
132
- const l = fe({ name: n.node.name, type: "" });
133
- return l === "image" ? we : l === "text" || l === "markdown" || l === "json" || l === "csv" || l === "xml" || l === "subtitle" ? n.node.name.endsWith(".md") || n.node.name.endsWith(".markdown") ? xe : be : ye;
134
- }), x = (l) => {
135
- const t = l.currentTarget.getBoundingClientRect();
136
- u("hover", n.node.name || "/", t);
137
- }, b = () => u("leave");
138
- return (l, t) => {
139
- const v = se("ZipTreeItem");
140
- return s.node.isDir ? (r(), c("div", We, [
141
- a("button", {
142
- type: "button",
143
- class: "tree-row dir-row",
144
- style: E(w.value),
145
- onClick: t[0] || (t[0] = (L) => u("toggle", s.node.path)),
146
- onMouseenter: x,
147
- onMouseleave: b
148
- }, [
149
- H(g(ke), {
150
- class: F(["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
- (r(), D(A(f.value ? g(Le) : g(ze)), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80" })),
153
- a("span", Ee, _(s.node.name || "/"), 1)
154
- ], 36),
155
- f.value && s.node.children ? (r(!0), c(U, { key: 0 }, Q(s.node.children, (L) => (r(), D(v, {
156
- key: L.path,
157
- node: L,
158
- depth: s.depth + 1,
159
- "selected-path": s.selectedPath,
160
- expanded: s.expanded,
161
- onToggle: t[1] || (t[1] = (p) => u("toggle", p)),
162
- onSelect: t[2] || (t[2] = (p) => u("select", p)),
163
- onHover: t[3] || (t[3] = (p, y) => u("hover", p, y)),
164
- onLeave: t[4] || (t[4] = (p) => u("leave"))
165
- }, null, 8, ["node", "depth", "selected-path", "expanded"]))), 128)) : ee("", !0)
166
- ])) : (r(), c("button", {
167
- key: 1,
168
- type: "button",
169
- class: F(["tree-row file-row", { selected: S.value }]),
170
- style: E(w.value),
171
- onClick: t[5] || (t[5] = (L) => u("select", s.node)),
172
- onMouseenter: x,
173
- onMouseleave: b
174
- }, [
175
- t[6] || (t[6] = a("span", { class: "vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0" }, null, -1)),
176
- (r(), D(A(T.value), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary" })),
177
- a("span", De, _(s.node.name), 1),
178
- a("span", Ie, _(g(de)(s.node.size)), 1)
179
- ], 38));
180
- };
181
- }
182
- }), Be = /* @__PURE__ */ ne(Ue, [["__scopeId", "data-v-124c382d"]]), Ke = {
183
- key: 0,
184
- class: "vfp-renderer-loading"
185
- }, Ne = { class: "vfp-renderer-loading-content" }, He = { class: "vfp-renderer-loading-text" }, Pe = { class: "vfp-w-full vfp-h-full vfp-overflow-auto" }, je = { class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col" }, Oe = {
186
- key: 0,
187
- class: "vfp-renderer-loading vfp-flex-1"
188
- }, Ze = { class: "vfp-renderer-loading-content" }, qe = { class: "vfp-renderer-loading-text" }, Ve = {
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
- }, Ge = {
195
- key: 3,
196
- class: "vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0"
197
- }, tt = /* @__PURE__ */ Z({
198
- __name: "index",
199
- props: {
200
- url: {},
201
- nestingDepth: { default: 0 }
202
- },
203
- setup(s, { expose: I }) {
204
- const n = re(
205
- () => import("./index-DZZN3kYi.mjs").then((e) => e.$)
206
- ), u = s, w = new Se(), { t: f } = te(), S = pe(), T = d(null), x = d(null), b = d(!0), l = d(null), t = d(/* @__PURE__ */ new Set([""])), v = d(null), L = d(!1), p = d(null), y = d(null), R = d(null), W = d(null), C = () => {
207
- var e;
208
- (e = v.value) != null && e.blobUrl && URL.revokeObjectURL(v.value.blobUrl);
209
- }, i = async () => {
210
- C(), v.value = null, b.value = !0, l.value = null;
211
- try {
212
- const e = await S.value(u.url);
213
- if (!e.ok) throw new ue("common.load_failed");
214
- const o = await e.arrayBuffer(), m = await ce(o), z = me(m), h = he(z);
215
- T.value = m, x.value = h;
216
- const M = /* @__PURE__ */ new Set([""]);
217
- if (h.children)
218
- for (const K of h.children) K.isDir && M.add(K.path);
219
- t.value = M;
220
- } catch (e) {
221
- console.error(e), l.value = f.value("zip.load_failed");
222
- } finally {
223
- b.value = !1;
224
- }
225
- };
226
- O(() => u.url, (e) => {
227
- e && i();
228
- }, { immediate: !0 }), J(() => {
229
- C();
230
- });
231
- const k = $(() => {
232
- if (!x.value) return null;
233
- let e = 0, o = 0, m = 0;
234
- const z = (h) => {
235
- var M;
236
- h.isDir ? (h.path && o++, (M = h.children) == null || M.forEach(z)) : (e++, m += h.size);
237
- };
238
- return z(x.value), { files: e, dirs: o, size: m };
239
- });
240
- O(k, () => w.notify()), I({
241
- getToolbarGroups: () => [],
242
- onToolbarChange: (e) => w.subscribe(e)
243
- });
244
- const P = (e) => {
245
- const o = new Set(t.value);
246
- o.has(e) ? o.delete(e) : o.add(e), t.value = o;
247
- }, j = (e, o) => {
248
- const m = typeof window < "u" ? window.innerWidth - 328 : o.right + 8;
249
- y.value = { text: e, x: Math.max(8, Math.min(o.right + 8, m)), y: o.top + o.height / 2 };
250
- }, le = () => {
251
- y.value = null;
252
- }, oe = async (e) => {
253
- var o, m, z;
254
- if (!(!T.value || e.isDir || ((o = v.value) == null ? void 0 : o.path) === e.path || W.value === e.path)) {
255
- W.value = e.path, C(), v.value = null, L.value = !0, p.value = null;
256
- try {
257
- const h = X(e.name), M = await ge(T.value, e.path, h !== "application/octet-stream" ? h : void 0), K = URL.createObjectURL(M);
258
- v.value = { path: e.path, name: e.name, size: e.size, blobUrl: K }, (m = R.value) == null || m.switchTab("right");
259
- } catch (h) {
260
- console.error(h), p.value = f.value("zip.entry_read_failed"), (z = R.value) == null || z.switchTab("right");
261
- } finally {
262
- L.value = !1, W.value === e.path && (W.value = null);
263
- }
264
- }
265
- }, ae = $(() => v.value ? [{ name: v.value.name, url: v.value.blobUrl, type: X(v.value.name) }] : []);
266
- return (e, o) => b.value ? (r(), c("div", Ke, [
267
- a("div", Ne, [
268
- o[0] || (o[0] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
269
- a("span", He, _(g(f)("common.loading")), 1)
270
- ])
271
- ])) : l.value || !x.value ? (r(), D(Y, {
272
- key: 1,
273
- message: l.value || g(f)("zip.parse_failed")
274
- }, null, 8, ["message"])) : (r(), c(U, { key: 2 }, [
275
- H(Me, {
276
- ref_key: "splitRef",
277
- ref: R,
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": g(f)("zip.file_tree"),
284
- "right-tab-label": g(f)("toolbar.preview")
285
- }, {
286
- left: G(() => [
287
- a("div", Pe, [
288
- (r(!0), c(U, null, Q(x.value.children || [], (m) => {
289
- var z;
290
- return r(), D(Be, {
291
- key: m.path,
292
- node: m,
293
- depth: 0,
294
- "selected-path": ((z = v.value) == null ? void 0 : z.path) ?? null,
295
- expanded: t.value,
296
- onToggle: P,
297
- onSelect: oe,
298
- onHover: j,
299
- onLeave: le
300
- }, null, 8, ["node", "selected-path", "expanded"]);
301
- }), 128))
302
- ])
303
- ]),
304
- right: G(() => [
305
- a("div", je, [
306
- L.value ? (r(), c("div", Oe, [
307
- a("div", Ze, [
308
- o[1] || (o[1] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
309
- a("span", qe, _(g(f)("common.loading")), 1)
310
- ])
311
- ])) : p.value ? (r(), c("div", Ve, [
312
- H(Y, { message: p.value }, null, 8, ["message"])
313
- ])) : v.value ? (r(), c("div", Ge, [
314
- H(g(n), {
315
- mode: "embed",
316
- files: ae.value,
317
- "current-index": 0,
318
- "zip-nesting-depth": s.nestingDepth + 1
319
- }, null, 8, ["files", "zip-nesting-depth"])
320
- ])) : (r(), c("div", Ae, _(g(f)("zip.select_file")), 1))
321
- ])
322
- ]),
323
- _: 1
324
- }, 8, ["left-tab-label", "right-tab-label"]),
325
- (r(), D(ve, { to: "body" }, [
326
- y.value ? (r(), c("div", {
327
- key: 0,
328
- class: "vfp-zip-tip",
329
- style: E({
330
- position: "fixed",
331
- zIndex: 2147483647,
332
- pointerEvents: "none",
333
- display: "block",
334
- transform: "translateY(-50%)",
335
- padding: "4px 8px",
336
- background: "rgba(0, 0, 0, 0.85)",
337
- color: "#fff",
338
- fontSize: "12px",
339
- lineHeight: 1.5,
340
- borderRadius: "4px",
341
- whiteSpace: "nowrap",
342
- maxWidth: "min(320px, calc(100vw - 16px))",
343
- overflow: "hidden",
344
- textOverflow: "ellipsis",
345
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.3)",
346
- left: y.value.x + "px",
347
- top: y.value.y + "px"
348
- })
349
- }, _(y.value.text), 5)) : ee("", !0)
350
- ]))
351
- ], 64));
352
- }
353
- });
354
- export {
355
- tt as default
356
- };
@@ -1,157 +0,0 @@
1
- import { defineComponent as P, ref as v, onMounted as V, watch as q, onBeforeUnmount as A, computed as I, openBlock as p, createElementBlock as h, createElementVNode as k, toDisplayString as O, unref as C, createCommentVNode as T, createVNode as W, normalizeStyle as S } from "vue";
2
- import { u as $, c as G, l as U, k as E, t as j, W as J } from "./index-DZZN3kYi.mjs";
3
- import { init as D } from "pptx-preview";
4
- import { _ as K } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
- import { _ as Q } from "./EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs";
6
- const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, Y = {
7
- key: 0,
8
- class: "vfp-renderer-overlay vfp-renderer-loading"
9
- }, Z = { class: "vfp-renderer-loading-content" }, ee = { class: "vfp-renderer-loading-text" }, te = {
10
- key: 1,
11
- class: "vfp-renderer-overlay"
12
- }, ie = {
13
- key: 2,
14
- class: "vfp-renderer-overlay"
15
- }, se = /* @__PURE__ */ P({
16
- __name: "index",
17
- props: {
18
- url: {},
19
- tiled: { type: Boolean, default: !0 },
20
- emptyHint: {}
21
- },
22
- setup(R, { expose: z }) {
23
- const s = R, { t: o } = $(), H = G(), n = v(!0), u = v(null), m = v(!1), w = v(0), l = v(null);
24
- let r = null, y = null, c = null, f = null, _ = { width: 0, height: 0 }, M = 9 / 16;
25
- const g = () => {
26
- var d;
27
- if (!l.value) return { width: 960, height: 540 };
28
- const t = l.value.clientWidth, e = ((d = l.value.parentElement) == null ? void 0 : d.clientWidth) || 0, i = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(i * M);
29
- return { width: i, height: a };
30
- }, F = async () => {
31
- if (!(!l.value || !c || w.value === 0))
32
- try {
33
- if (r)
34
- try {
35
- r.destroy();
36
- } catch {
37
- }
38
- l.value.innerHTML = "";
39
- const t = g();
40
- r = D(l.value, {
41
- width: t.width,
42
- height: s.tiled ? t.height * w.value : t.height,
43
- mode: s.tiled ? "list" : "slide"
44
- }), await r.preview(c);
45
- } catch {
46
- }
47
- }, B = async () => {
48
- if (!l.value) return;
49
- n.value = !0, u.value = null, m.value = !1;
50
- let t = window.setTimeout(() => {
51
- u.value = o.value("pptx.timeout"), n.value = !1;
52
- }, 3e4);
53
- try {
54
- const e = await H.value(s.url, {
55
- mode: "cors",
56
- credentials: "omit",
57
- redirect: "follow"
58
- });
59
- if (!e.ok)
60
- throw e.status === 404 ? new Error(o.value("pptx.not_found")) : e.status === 403 ? new E("file.forbidden") : e.status >= 500 ? new E("file.server_error") : new E("file.load_failed_status", { status: e.status });
61
- const i = await e.arrayBuffer();
62
- if (i.byteLength === 0) {
63
- t !== null && clearTimeout(t), m.value = !0, n.value = !1;
64
- return;
65
- }
66
- c = i, M = (await j(i)).ratio;
67
- const a = document.createElement("div");
68
- a.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(a);
69
- try {
70
- const d = D(a, {
71
- width: 100,
72
- height: 100,
73
- mode: "slide"
74
- });
75
- try {
76
- await d.preview(i);
77
- } catch {
78
- throw new Error(o.value("pptx.invalid_format"));
79
- }
80
- const x = d.slideCount;
81
- if (!x || x === 0) throw new Error(o.value("pptx.no_pages"));
82
- d.destroy(), w.value = x, l.value && (l.value.innerHTML = "");
83
- const b = g();
84
- r = D(l.value, {
85
- width: b.width,
86
- height: s.tiled ? b.height * x : b.height,
87
- mode: s.tiled ? "list" : "slide"
88
- }), await r.preview(i), t !== null && (clearTimeout(t), t = null), n.value = !1;
89
- } finally {
90
- document.body.contains(a) && document.body.removeChild(a);
91
- }
92
- } catch (e) {
93
- t !== null && clearTimeout(t);
94
- let i = o.value("pptx.parse_failed");
95
- e instanceof Error ? i = J(o.value, e) : typeof e == "string" && (i = e), u.value = i, n.value = !1;
96
- }
97
- };
98
- V(() => {
99
- if (!l.value) return;
100
- let t = !0;
101
- y = new ResizeObserver(() => {
102
- if (t) {
103
- t = !1, _ = g();
104
- return;
105
- }
106
- const e = g(), i = Math.abs(_.width - e.width), a = Math.abs(_.height - e.height);
107
- i < 10 && a < 10 || (_ = e, f !== null && clearTimeout(f), f = window.setTimeout(() => {
108
- r && c && F();
109
- }, 800));
110
- }), y.observe(l.value), setTimeout(() => {
111
- requestAnimationFrame(() => requestAnimationFrame(() => B()));
112
- }, 150);
113
- }), q(
114
- () => s.url,
115
- (t) => {
116
- t && B();
117
- }
118
- ), A(() => {
119
- if (y && y.disconnect(), f !== null && clearTimeout(f), c = null, w.value = 0, r)
120
- try {
121
- r.destroy();
122
- } catch {
123
- }
124
- r = null;
125
- });
126
- const L = () => [], N = I(() => U(s.emptyHint, "structured"));
127
- return z({
128
- getToolbarGroups: L
129
- }), (t, e) => (p(), h("div", X, [
130
- n.value ? (p(), h("div", Y, [
131
- k("div", Z, [
132
- e[0] || (e[0] = k("div", { class: "vfp-renderer-spinner" }, null, -1)),
133
- k("p", ee, O(C(o)("pptx.loading")), 1)
134
- ])
135
- ])) : T("", !0),
136
- m.value && !n.value && N.value ? (p(), h("div", te, [
137
- W(Q)
138
- ])) : T("", !0),
139
- u.value && !n.value ? (p(), h("div", ie, [
140
- W(K, {
141
- message: C(o)("pptx.load_failed"),
142
- detail: u.value
143
- }, null, 8, ["message", "detail"])
144
- ])) : T("", !0),
145
- u.value ? T("", !0) : (p(), h("div", {
146
- key: 3,
147
- ref_key: "containerRef",
148
- ref: l,
149
- class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
150
- style: S({ opacity: n.value || m.value ? 0 : 1 })
151
- }, null, 4))
152
- ]));
153
- }
154
- });
155
- export {
156
- se as default
157
- };
@@ -1,104 +0,0 @@
1
- import { defineComponent as k, ref as p, onMounted as D, watch as z, onBeforeUnmount as M, openBlock as v, createElementBlock as m, createElementVNode as w, toDisplayString as N, unref as S, createCommentVNode as g, createBlock as B, normalizeStyle as C } from "vue";
2
- import { S as H } from "./index-CyBXARuf.mjs";
3
- import { u as R, c as W, X as G, m as E, T as F, p as L } from "./index-DZZN3kYi.mjs";
4
- import { _ as O } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
- const V = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, X = {
6
- key: 0,
7
- class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
8
- }, j = { class: "vfp-renderer-loading-content" }, q = { class: "vfp-renderer-loading-text" }, K = /* @__PURE__ */ k({
9
- __name: "index",
10
- props: {
11
- url: {},
12
- fileName: {}
13
- },
14
- setup(T, { expose: x }) {
15
- const i = T, { t: d } = R(), y = W(), a = p(!0), n = p(null), l = p(null);
16
- let r = null, u = null, o = null, c = { width: 0, height: 0 };
17
- const h = () => {
18
- if (!l.value) return { width: 800, height: 600 };
19
- const t = l.value.clientWidth, e = l.value.clientHeight, s = t > 100 ? t : 800, f = e > 100 ? e : 600;
20
- return { width: s, height: f };
21
- }, b = () => {
22
- if (!l.value || !r) return;
23
- l.value.innerHTML = "";
24
- const { width: t, height: e } = h(), s = t < 640;
25
- new H(l.value, {
26
- mode: "read",
27
- showToolbar: !1,
28
- showContextmenu: !1,
29
- showGrid: !0,
30
- row: {
31
- len: 100,
32
- height: 25
33
- },
34
- col: {
35
- len: 26,
36
- width: s ? 80 : 100,
37
- indexWidth: s ? 40 : 60,
38
- minWidth: s ? 40 : 60
39
- },
40
- view: {
41
- height: () => e,
42
- width: () => t
43
- }
44
- }).loadData(r);
45
- }, _ = async () => {
46
- if (l.value) {
47
- a.value = !0, n.value = null;
48
- try {
49
- const t = await G(i.url, { fetcher: y.value }), e = E(t, { delimiter: F(i.fileName) });
50
- r = L(e.header, e.rows, i.fileName), b(), a.value = !1;
51
- } catch (t) {
52
- console.error(d.value("csv.parse_failed") + ":", t), n.value = d.value("csv.load_failed"), a.value = !1;
53
- }
54
- }
55
- };
56
- return D(() => {
57
- if (!l.value) return;
58
- let t = !0;
59
- u = new ResizeObserver(() => {
60
- if (t) {
61
- t = !1, c = h();
62
- return;
63
- }
64
- const e = h(), s = Math.abs(c.width - e.width), f = Math.abs(c.height - e.height);
65
- s < 10 && f < 10 || (c = e, o !== null && clearTimeout(o), o = window.setTimeout(() => {
66
- r && b();
67
- }, 500));
68
- }), u.observe(l.value), setTimeout(() => {
69
- requestAnimationFrame(() => _());
70
- }, 100);
71
- }), z(
72
- () => i.url,
73
- () => {
74
- _();
75
- }
76
- ), M(() => {
77
- u && u.disconnect(), o !== null && clearTimeout(o), r = null, l.value && (l.value.innerHTML = "");
78
- }), x({
79
- getToolbarGroups: () => []
80
- }), (t, e) => (v(), m("div", V, [
81
- a.value ? (v(), m("div", X, [
82
- w("div", j, [
83
- e[0] || (e[0] = w("div", { class: "vfp-renderer-spinner" }, null, -1)),
84
- w("p", q, N(S(d)("csv.loading")), 1)
85
- ])
86
- ])) : g("", !0),
87
- n.value && !a.value ? (v(), B(O, {
88
- key: 1,
89
- message: n.value,
90
- class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
91
- }, null, 8, ["message"])) : g("", !0),
92
- n.value ? g("", !0) : (v(), m("div", {
93
- key: 2,
94
- ref_key: "containerRef",
95
- ref: l,
96
- class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
97
- style: C({ opacity: a.value ? 0 : 1 })
98
- }, null, 4))
99
- ]));
100
- }
101
- });
102
- export {
103
- K as default
104
- };
@@ -1,51 +0,0 @@
1
- import { defineComponent as m, ref as n, watch as _, openBlock as c, createElementBlock as p, createElementVNode as r, toDisplayString as g, unref as h, createBlock as y } from "vue";
2
- import { u as w, c as k, k as x, B } from "./index-DZZN3kYi.mjs";
3
- import { _ as T } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
4
- const b = {
5
- key: 0,
6
- class: "vfp-renderer-loading"
7
- }, E = { class: "vfp-renderer-loading-content" }, G = { class: "vfp-renderer-loading-text" }, H = {
8
- key: 2,
9
- class: "vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-6 vfp-px-4"
10
- }, L = ["innerHTML"], N = /* @__PURE__ */ m({
11
- __name: "index",
12
- props: {
13
- url: {}
14
- },
15
- setup(u, { expose: f }) {
16
- const i = u, { t: l } = w(), d = k(), t = n(""), s = n(!0), a = n(null), v = async () => {
17
- s.value = !0, a.value = null, t.value = "";
18
- try {
19
- const e = await d.value(i.url);
20
- if (!e.ok) throw new x("file.load_failed");
21
- const o = await e.arrayBuffer();
22
- t.value = await B(o);
23
- } catch (e) {
24
- console.error(l.value("ppt.parse_failed") + ":", e), a.value = l.value("ppt.parse_failed");
25
- } finally {
26
- s.value = !1;
27
- }
28
- };
29
- return _(() => i.url, (e) => {
30
- e && v();
31
- }, { immediate: !0 }), f({
32
- getToolbarGroups: () => []
33
- }), (e, o) => s.value ? (c(), p("div", b, [
34
- r("div", E, [
35
- o[0] || (o[0] = r("div", { class: "vfp-renderer-spinner" }, null, -1)),
36
- r("span", G, g(h(l)("common.loading")), 1)
37
- ])
38
- ])) : a.value ? (c(), y(T, {
39
- key: 1,
40
- message: a.value
41
- }, null, 8, ["message"])) : (c(), p("div", H, [
42
- r("div", {
43
- class: "vfp-legacy-ppt-wrap",
44
- innerHTML: t.value
45
- }, null, 8, L)
46
- ]));
47
- }
48
- });
49
- export {
50
- N as default
51
- };