@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
@@ -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,330 +0,0 @@
1
- import { defineComponent as ue, ref as d, watch as Q, onMounted as ce, onBeforeUnmount as fe, openBlock as h, createElementBlock as m, createBlock as pe, createCommentVNode as S, createElementVNode as p, toDisplayString as L, unref as N, normalizeStyle as z, createVNode as ve, Fragment as O, renderList as Y } from "vue";
2
- import de from "@likecoin/epub-ts";
3
- import { List as he, ChevronLeft as me, ChevronRight as ge, Minimize2 as be, Maximize2 as xe, X as we } from "lucide-vue-next";
4
- import { u as ye, c as ke } from "./index-DZZN3kYi.mjs";
5
- import { _ as _e } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
- import { T as Te } from "./base.types-DaftHyg7.mjs";
7
- const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, Ce = {
8
- key: 1,
9
- class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
10
- }, Se = { class: "vfp-renderer-loading-content" }, We = { class: "vfp-renderer-loading-text" }, Me = {
11
- class: "vfp-flex vfp-items-center vfp-justify-between vfp-flex-shrink-0",
12
- style: { padding: "12px 16px", "border-bottom": "1px solid rgba(255,255,255,0.1)" }
13
- }, Ee = { style: { color: "white", "font-weight": "500", "font-size": "14px" } }, $e = {
14
- class: "vfp-flex-1 vfp-overflow-y-auto",
15
- style: { padding: "8px 4px" }
16
- }, He = ["title", "onClick", "onMouseenter", "onMouseleave"], Re = ["title", "onClick", "onMouseenter", "onMouseleave"], Le = 794, qe = /* @__PURE__ */ ue({
17
- __name: "index",
18
- props: {
19
- url: {}
20
- },
21
- setup(Z, { expose: ee }) {
22
- const W = Z, q = new Te(), { t: v } = ye(), te = ke(), g = d(1), w = d(1), r = d(null), M = d(!0), y = d(null), b = d(!1), x = d([]), s = d(!1), A = d("");
23
- Q([g, w, b, s, () => x.value.length], () => {
24
- q.notify();
25
- });
26
- let c = null, e = null, k = 0, _ = null;
27
- const G = () => {
28
- var t;
29
- try {
30
- (t = e == null ? void 0 : e.destroy) == null || t.call(e);
31
- } catch {
32
- }
33
- try {
34
- c == null || c.destroy();
35
- } catch {
36
- }
37
- e = null, c = null, k = 0, _ = null;
38
- }, oe = () => {
39
- e == null || e.prev();
40
- }, ae = () => {
41
- e == null || e.next();
42
- }, re = () => {
43
- b.value = !b.value, setTimeout(() => {
44
- r.value && e && (e.resize(r.value.offsetWidth, r.value.offsetHeight), _ && e.display(_), P());
45
- }, 350);
46
- }, le = () => {
47
- s.value = !s.value;
48
- }, I = (t) => {
49
- A.value = t, e == null || e.display(t), s.value = !1;
50
- }, f = (t) => t === A.value;
51
- ee({
52
- getToolbarGroups: () => [
53
- {
54
- items: [
55
- {
56
- type: "button",
57
- icon: he,
58
- tooltip: v.value("toolbar.toc"),
59
- action: le,
60
- disabled: x.value.length === 0,
61
- active: s.value
62
- }
63
- ]
64
- },
65
- {
66
- items: [
67
- {
68
- type: "button",
69
- icon: me,
70
- tooltip: v.value("toolbar.prev_page"),
71
- action: oe,
72
- disabled: g.value <= 1
73
- },
74
- {
75
- type: "text",
76
- content: `${g.value} / ${w.value}`,
77
- minWidth: "4rem"
78
- },
79
- {
80
- type: "button",
81
- icon: ge,
82
- tooltip: v.value("toolbar.next_page"),
83
- action: ae,
84
- disabled: g.value >= w.value
85
- }
86
- ]
87
- },
88
- {
89
- items: [
90
- {
91
- type: "button",
92
- icon: b.value ? be : xe,
93
- tooltip: b.value ? v.value("toolbar.normal_width") : v.value("toolbar.full_width"),
94
- action: re,
95
- active: b.value
96
- }
97
- ]
98
- }
99
- ],
100
- onToolbarChange: (t) => q.subscribe(t)
101
- });
102
- const V = async () => {
103
- if (r.value) {
104
- M.value = !0, y.value = null, x.value = [], s.value = !1, r.value.innerHTML = "", G();
105
- try {
106
- let t = W.url;
107
- W.url.startsWith("blob:") && (t = await (await te.value(W.url)).arrayBuffer());
108
- const l = de(t);
109
- c = l;
110
- const o = new Promise((a, n) => {
111
- l.on("openFailed", (i) => {
112
- n(i instanceof Error ? i : new Error("EPUB open failed"));
113
- });
114
- });
115
- e = l.renderTo(r.value, {
116
- manager: "continuous",
117
- flow: "scrolled",
118
- width: "100%",
119
- height: "100%"
120
- }), e.themes.register("default", {
121
- body: {
122
- background: "#ffffff !important",
123
- color: "#1a1a1a !important",
124
- "font-family": '"Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important',
125
- "font-size": "16px !important",
126
- "line-height": "2 !important",
127
- padding: "40px 60px !important",
128
- "max-width": "100% !important",
129
- "box-sizing": "border-box !important",
130
- "word-break": "break-word !important",
131
- "overflow-wrap": "break-word !important"
132
- },
133
- p: { "text-indent": "2em !important", margin: "0.8em 0 !important" },
134
- h1: { "text-align": "center !important", margin: "1.5em 0 1em !important" },
135
- h2: { margin: "1.2em 0 0.8em !important" },
136
- h3: { margin: "1em 0 0.6em !important" },
137
- img: { "max-width": "100% !important", height: "auto !important" },
138
- a: { color: "#2563eb !important", "text-decoration": "none !important" }
139
- }), e.themes.select("default"), await Promise.race([c.ready, o]), c.locations.generate(1024).then(() => {
140
- var i;
141
- if (!c) return;
142
- k = c.locations.length();
143
- const a = e == null ? void 0 : e.currentLocation(), n = ((i = a == null ? void 0 : a.start) == null ? void 0 : i.location) ?? 0;
144
- g.value = n + 1, w.value = k;
145
- }).catch(() => {
146
- });
147
- const T = await Promise.race([c.loaded.navigation, o]);
148
- Array.isArray(T == null ? void 0 : T.toc) && (x.value = T.toc), await Promise.race([e.display(), o]), M.value = !1, g.value = 1, w.value = k || 1, e.on("relocated", (a) => {
149
- var j, U, J;
150
- const n = a;
151
- if ((j = n == null ? void 0 : n.start) != null && j.cfi && (_ = n.start.cfi), (U = n == null ? void 0 : n.start) != null && U.href) {
152
- const B = n.start.href, D = [], K = (se) => {
153
- for (const H of se) {
154
- const R = H.href.split("#")[0];
155
- R && (B === R || B.endsWith("/" + R) || B.endsWith(R)) && D.push(H.href), H.subitems && K(H.subitems);
156
- }
157
- };
158
- K(x.value), D.length === 1 && (A.value = D[0]);
159
- }
160
- const i = (J = n == null ? void 0 : n.start) == null ? void 0 : J.location;
161
- typeof i == "number" && k > 0 && (g.value = i + 1, w.value = k);
162
- });
163
- } catch (t) {
164
- console.error(v.value("epub.load_failed") + ":", t), y.value = v.value("epub.load_failed"), M.value = !1;
165
- }
166
- }
167
- };
168
- let E = null, C = null, $ = { width: 0, height: 0 }, X = !0;
169
- const ne = () => {
170
- if (!(!r.value || !e)) {
171
- if (e.resize(r.value.offsetWidth, r.value.offsetHeight), _)
172
- try {
173
- e.display(_);
174
- } catch {
175
- }
176
- P();
177
- }
178
- }, ie = () => {
179
- r.value && (E = new ResizeObserver(() => {
180
- if (!r.value) return;
181
- if (X) {
182
- X = !1, $ = { width: r.value.offsetWidth, height: r.value.offsetHeight };
183
- return;
184
- }
185
- const t = { width: r.value.offsetWidth, height: r.value.offsetHeight }, l = Math.abs($.width - t.width), o = Math.abs($.height - t.height);
186
- l < 10 && o < 10 || ($ = t, C !== null && clearTimeout(C), C = window.setTimeout(ne, 350));
187
- }), E.observe(r.value));
188
- };
189
- let u = null;
190
- const F = () => {
191
- var l;
192
- if (!u) return;
193
- const t = u;
194
- if (t.scrollTop + t.clientHeight >= t.scrollHeight - 200)
195
- try {
196
- const o = e == null ? void 0 : e.manager;
197
- (l = o == null ? void 0 : o.check) == null || l.call(o, 500, 500);
198
- } catch {
199
- }
200
- }, P = () => {
201
- u && (u.removeEventListener("scroll", F), u = null);
202
- const t = () => {
203
- var l;
204
- u = ((l = r.value) == null ? void 0 : l.querySelector(".epub-container")) ?? null, u ? u.addEventListener("scroll", F, { passive: !0 }) : requestAnimationFrame(t);
205
- };
206
- requestAnimationFrame(t);
207
- };
208
- return ce(() => {
209
- V(), ie(), P();
210
- }), Q(() => W.url, (t) => {
211
- t && V();
212
- }), fe(() => {
213
- E && E.disconnect(), C !== null && clearTimeout(C), u == null || u.removeEventListener("scroll", F), G();
214
- }), (t, l) => (h(), m("div", ze, [
215
- y.value ? (h(), pe(_e, {
216
- key: 0,
217
- message: y.value,
218
- class: "vfp-absolute vfp-inset-0"
219
- }, null, 8, ["message"])) : S("", !0),
220
- M.value && !y.value ? (h(), m("div", Ce, [
221
- p("div", Se, [
222
- l[2] || (l[2] = p("div", { class: "vfp-renderer-spinner" }, null, -1)),
223
- p("span", We, L(N(v)("common.loading")), 1)
224
- ])
225
- ])) : S("", !0),
226
- x.value.length > 0 ? (h(), m("div", {
227
- key: 2,
228
- class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex",
229
- style: z({ opacity: s.value ? 1 : 0, pointerEvents: s.value ? "auto" : "none", transition: "opacity 0.3s" })
230
- }, [
231
- p("div", {
232
- class: "vfp-w-72 vfp-h-full vfp-flex vfp-flex-col",
233
- style: z({
234
- maxWidth: "80%",
235
- background: "rgba(0,0,0,0.9)",
236
- backdropFilter: "blur(12px)",
237
- borderRight: "1px solid rgba(255,255,255,0.1)",
238
- boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)",
239
- transform: s.value ? "translateX(0)" : "translateX(-100%)",
240
- transition: "transform 0.3s ease"
241
- })
242
- }, [
243
- p("div", Me, [
244
- p("span", Ee, L(N(v)("toolbar.toc")), 1),
245
- p("button", {
246
- style: { color: "rgba(255,255,255,0.6)", background: "none", border: "none", cursor: "pointer", padding: "4px" },
247
- onClick: l[0] || (l[0] = (o) => s.value = !1)
248
- }, [
249
- ve(N(we), { style: { width: "16px", height: "16px" } })
250
- ])
251
- ]),
252
- p("div", $e, [
253
- (h(!0), m(O, null, Y(x.value, (o, T) => (h(), m(O, {
254
- key: `${o.href}-${T}`
255
- }, [
256
- p("button", {
257
- style: z({
258
- width: "100%",
259
- textAlign: "left",
260
- padding: "8px 12px",
261
- fontSize: "14px",
262
- color: f(o.href) ? "white" : "rgba(255,255,255,0.7)",
263
- fontWeight: f(o.href) ? "500" : "400",
264
- background: f(o.href) ? "rgba(255,255,255,0.15)" : "none",
265
- border: "none",
266
- cursor: "pointer",
267
- borderRadius: "4px",
268
- overflow: "hidden",
269
- textOverflow: "ellipsis",
270
- whiteSpace: "nowrap",
271
- display: "block",
272
- transition: "all 0.15s"
273
- }),
274
- title: o.label,
275
- onClick: (a) => I(o.href),
276
- onMouseenter: (a) => !f(o.href) && (a.target.style.background = "rgba(255,255,255,0.1)"),
277
- onMouseleave: (a) => !f(o.href) && (a.target.style.background = "none")
278
- }, L(o.label.trim()), 45, He),
279
- o.subitems && o.subitems.length > 0 ? (h(!0), m(O, { key: 0 }, Y(o.subitems, (a, n) => (h(), m("button", {
280
- key: `${a.href}-${n}`,
281
- style: z({
282
- width: "100%",
283
- textAlign: "left",
284
- padding: "8px 12px 8px 28px",
285
- fontSize: "13px",
286
- color: f(a.href) ? "white" : "rgba(255,255,255,0.6)",
287
- fontWeight: f(a.href) ? "500" : "400",
288
- background: f(a.href) ? "rgba(255,255,255,0.15)" : "none",
289
- border: "none",
290
- cursor: "pointer",
291
- borderRadius: "4px",
292
- overflow: "hidden",
293
- textOverflow: "ellipsis",
294
- whiteSpace: "nowrap",
295
- display: "block",
296
- transition: "all 0.15s"
297
- }),
298
- title: a.label,
299
- onClick: (i) => I(a.href),
300
- onMouseenter: (i) => !f(a.href) && (i.target.style.background = "rgba(255,255,255,0.1)"),
301
- onMouseleave: (i) => !f(a.href) && (i.target.style.background = "none")
302
- }, L(a.label.trim()), 45, Re))), 128)) : S("", !0)
303
- ], 64))), 128))
304
- ])
305
- ], 4),
306
- p("div", {
307
- class: "vfp-flex-1",
308
- style: z({ background: s.value ? "rgba(0,0,0,0.3)" : "transparent", transition: "background 0.3s" }),
309
- onClick: l[1] || (l[1] = (o) => s.value = !1)
310
- }, null, 4)
311
- ], 4)) : S("", !0),
312
- y.value ? S("", !0) : (h(), m("div", {
313
- key: 3,
314
- ref_key: "viewerRef",
315
- ref: r,
316
- class: "vfp-h-full vfp-bg-surface-toolbar",
317
- style: z({
318
- width: b.value ? "100%" : `${Le}px`,
319
- maxWidth: "100%",
320
- transition: "width 0.3s ease",
321
- boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
322
- overflow: "hidden"
323
- })
324
- }, null, 4))
325
- ]));
326
- }
327
- });
328
- export {
329
- qe as default
330
- };