@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.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/lib/FilePreviewContent.vue.d.ts +17 -6
- package/lib/FilePreviewEmbed.vue.d.ts +14 -6
- package/lib/FilePreviewModal.vue.d.ts +14 -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
- package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-CnJpGYJ2.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-g_dLrWLP.mjs} +1 -1
- package/lib/chunks/index-6XZXYqbp.mjs +125 -0
- package/lib/chunks/{index-B21EAyWz.mjs → index-BPSzwMOC.mjs} +51 -51
- package/lib/chunks/index-BYQ9S7Mk.mjs +104 -0
- package/lib/chunks/{index-8Vpbg2kS.mjs → index-Bf94DwQu.mjs} +105 -104
- package/lib/chunks/index-BfOWoMpY.mjs +359 -0
- package/lib/chunks/index-Bg8poMIm.mjs +117 -0
- package/lib/chunks/index-BzwJ0VWu.mjs +108 -0
- package/lib/chunks/index-C41YET0_.mjs +51 -0
- package/lib/chunks/{index-BvBqDq3O.mjs → index-C4hIk6pa.mjs} +2023 -2023
- package/lib/chunks/{index-BASg1cr4.mjs → index-C8lyQPe3.mjs} +1018 -1018
- package/lib/chunks/{index-C9mAajbD.mjs → index-CWPdNhoe.mjs} +200 -200
- package/lib/chunks/{index-BuqPb5mP.mjs → index-CrVQPnFj.mjs} +112 -112
- package/lib/chunks/{index-D30L8tm9.mjs → index-D5IF9F-D.mjs} +57 -57
- package/lib/chunks/{index-DN4Ui0Gh.mjs → index-DFeKS8tR.mjs} +120 -120
- package/lib/chunks/index-DM8Dfl-m.mjs +52 -0
- package/lib/chunks/index-DZe0BxAB.mjs +90 -0
- package/lib/chunks/{index-BlrFFeqc.mjs → index-GFcSJEwj.mjs} +75 -75
- package/lib/chunks/{index-Dkro_8Fy.mjs → index-LPGxJDnT.mjs} +32 -32
- package/lib/chunks/index-aKiIuKKx.mjs +157 -0
- package/lib/chunks/{index-DZZN3kYi.mjs → index-c-pYJEmH.mjs} +1589 -1394
- package/lib/chunks/{index-CxKZKUJj.mjs → index-z9RqL2wI.mjs} +1651 -1651
- package/lib/chunks/index-zLQlyNR2.mjs +383 -0
- package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-fCO1knZ0.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-DihMskai.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-BSfDPl-z.mjs} +5 -5
- package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-JY5DaTre.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-C-ztcJBE.mjs} +1 -1
- package/lib/composables/useAudioPlayer.d.ts +1 -1
- package/lib/composables/usePreviewEvents.d.ts +27 -0
- package/lib/composables/useRequest.d.ts +16 -4
- package/lib/composables/useThemeMode.d.ts +1 -1
- package/lib/composables/useTranslator.d.ts +2 -2
- package/lib/core/events.d.ts +52 -0
- package/lib/core/i18n/index.d.ts +29 -0
- package/lib/core/i18n/messages/en-US.d.ts +5 -0
- package/lib/core/i18n/messages/index.d.ts +9 -0
- package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
- package/lib/core/i18n/types.d.ts +23 -0
- package/lib/core/index.d.ts +34 -0
- package/lib/core/loaders/avifLoader.d.ts +22 -0
- package/lib/core/loaders/heicLoader.d.ts +21 -0
- package/lib/core/loaders/jp2Loader.d.ts +16 -0
- package/lib/core/loaders/jp2Worker.d.ts +1 -0
- package/lib/core/loaders/psdLoader.d.ts +14 -0
- package/lib/core/loaders/rawLoader.d.ts +14 -0
- package/lib/core/loaders/registry.d.ts +32 -0
- package/lib/core/loaders/tiffLoader.d.ts +28 -0
- package/lib/core/loaders/types.d.ts +56 -0
- package/lib/core/types.d.ts +89 -0
- package/lib/core/utils/csvParser.d.ts +31 -0
- package/lib/core/utils/emptyState.d.ts +28 -0
- package/lib/core/utils/excelDataConverter.d.ts +61 -0
- package/lib/core/utils/fileNormalizer.d.ts +21 -0
- package/lib/core/utils/fileType.d.ts +21 -0
- package/lib/core/utils/legacy-office/doc.d.ts +25 -0
- package/lib/core/utils/legacy-office/index.d.ts +8 -0
- package/lib/core/utils/legacy-office/ole.d.ts +8 -0
- package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
- package/lib/core/utils/legacy-office/xls.d.ts +28 -0
- package/lib/core/utils/mimeTypes.d.ts +29 -0
- package/lib/core/utils/ooxml/docx.d.ts +17 -0
- package/lib/core/utils/ooxml/index.d.ts +4 -0
- package/lib/core/utils/ooxml/pptx.d.ts +7 -0
- package/lib/core/utils/ooxml/xml.d.ts +15 -0
- package/lib/core/utils/ooxml/zip.d.ts +3 -0
- package/lib/core/utils/pdfWorker.d.ts +61 -0
- package/lib/core/utils/previewMode.d.ts +7 -0
- package/lib/core/utils/request.d.ts +49 -0
- package/lib/core/utils/subtitleParser.d.ts +44 -0
- package/lib/core/utils/textDecoder.d.ts +30 -0
- package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
- package/lib/core/utils/zipReader.d.ts +51 -0
- package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
- package/lib/core/workers/workerClient.d.ts +14 -0
- package/lib/i18n/localeKey.d.ts +1 -1
- package/lib/index.cjs +60 -60
- package/lib/index.css +1 -1
- package/lib/index.d.ts +11 -9
- package/lib/index.mjs +15 -12
- package/lib/renderers/Audio/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/toolbar.d.ts +2 -2
- package/lib/renderers/Csv/index.vue.d.ts +1 -1
- package/lib/renderers/Doc/index.vue.d.ts +1 -1
- package/lib/renderers/Docx/index.vue.d.ts +1 -1
- package/lib/renderers/Epub/index.vue.d.ts +1 -1
- package/lib/renderers/Font/index.vue.d.ts +1 -1
- package/lib/renderers/Image/index.vue.d.ts +2 -2
- package/lib/renderers/Json/index.vue.d.ts +2 -2
- package/lib/renderers/Markdown/index.vue.d.ts +1 -1
- package/lib/renderers/Mobi/index.vue.d.ts +1 -1
- package/lib/renderers/Msg/index.vue.d.ts +1 -1
- package/lib/renderers/Pdf/index.vue.d.ts +1 -1
- package/lib/renderers/Ppt/index.vue.d.ts +1 -1
- package/lib/renderers/Pptx/index.vue.d.ts +2 -2
- package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
- package/lib/renderers/Text/index.vue.d.ts +2 -2
- package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
- package/lib/renderers/Video/index.vue.d.ts +1 -1
- package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
- package/lib/renderers/Xml/index.vue.d.ts +1 -1
- package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
- package/lib/renderers/Zip/index.vue.d.ts +1 -1
- package/lib/renderers/base.types.d.ts +1 -1
- package/lib/renderers/registry.d.ts +1 -1
- package/lib/types.d.ts +3 -3
- package/package.json +2 -2
- package/lib/chunks/index--612Smof.mjs +0 -383
- package/lib/chunks/index-BB0i4QqI.mjs +0 -117
- package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
- package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
- package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
- package/lib/chunks/index-CDg6vIbT.mjs +0 -51
- package/lib/chunks/index-CWE-hKSs.mjs +0 -90
- package/lib/chunks/index-CY3xzGgt.mjs +0 -108
- package/lib/chunks/index-VdzIFJJW.mjs +0 -118
- package/lib/chunks/index-aoXgVLBb.mjs +0 -52
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { defineComponent as Me, ref as s, watch as Z, onBeforeUnmount as te, onMounted as Re, computed as ae, openBlock as w, createElementBlock as U, normalizeStyle as le, createElementVNode as _, createTextVNode as Le, toDisplayString as b, unref as W, createCommentVNode as E, createBlock as ne, normalizeClass as ke } from "vue";
|
|
2
|
-
import { u as Ee, V as Ce, a as Te, k as Ue, n as Ye, R as ze, W as oe, s as Se } from "./index-DZZN3kYi.mjs";
|
|
3
|
-
import { ZoomOut as Xe, ZoomIn as We, Scan as Be, Maximize2 as De, RotateCcw as Oe, RotateCw as Pe, RefreshCw as $e } from "lucide-vue-next";
|
|
4
|
-
import { _ as ie } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
-
import { T as je } from "./base.types-DaftHyg7.mjs";
|
|
6
|
-
const He = {
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-1/80 vfp-z-10"
|
|
9
|
-
}, Ze = { class: "vfp-renderer-loading-content" }, Ve = { class: "vfp-renderer-loading-text" }, Ne = { key: 0 }, Ge = {
|
|
10
|
-
key: 2,
|
|
11
|
-
class: "vfp-renderer-loading"
|
|
12
|
-
}, Ie = { class: "vfp-renderer-loading-content" }, Qe = { class: "vfp-renderer-loading-text" }, Ae = ["src"], Fe = {
|
|
13
|
-
key: 5,
|
|
14
|
-
class: "vfp-absolute vfp-bottom-2 vfp-right-3 vfp-text-[10px] vfp-text-fg-disabled hover:vfp-text-fg-secondary vfp-transition-colors vfp-pointer-events-auto vfp-select-none vfp-cursor-default"
|
|
15
|
-
}, Ke = {
|
|
16
|
-
key: 6,
|
|
17
|
-
class: "vfp-absolute vfp-bottom-2 vfp-left-1/2 -vfp-translate-x-1/2 vfp-flex vfp-items-center vfp-gap-2 vfp-px-3 vfp-py-1.5 vfp-bg-surface-toolbar vfp-border vfp-border-line vfp-rounded-lg vfp-text-sm vfp-text-fg-primary vfp-shadow-md"
|
|
18
|
-
}, qe = ["disabled"], Je = { class: "vfp-text-fg-secondary vfp-tabular-nums" }, et = ["disabled"], st = /* @__PURE__ */ Me({
|
|
19
|
-
__name: "index",
|
|
20
|
-
props: {
|
|
21
|
-
url: {},
|
|
22
|
-
fileSize: {},
|
|
23
|
-
file: {}
|
|
24
|
-
},
|
|
25
|
-
setup(se, { expose: ue }) {
|
|
26
|
-
const f = se, G = new je(), { t: i } = Ee(), u = s(1), C = s(0), T = s(!1), M = s(null), p = s(!1), B = s(0), R = s(null), L = s(""), k = s(1), Y = s(1), I = s(!1), l = s({ x: 0, y: 0 }), y = s(!1);
|
|
27
|
-
let z = { x: 0, y: 0 };
|
|
28
|
-
const m = s(1), v = s({ width: 0, height: 0 });
|
|
29
|
-
Z([u, C], () => {
|
|
30
|
-
G.notify();
|
|
31
|
-
}), ue({
|
|
32
|
-
getToolbarGroups: () => [
|
|
33
|
-
{
|
|
34
|
-
items: [
|
|
35
|
-
{
|
|
36
|
-
type: "button",
|
|
37
|
-
icon: Xe,
|
|
38
|
-
tooltip: i.value("toolbar.zoom_out"),
|
|
39
|
-
action: ce,
|
|
40
|
-
disabled: u.value <= 0.01
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: "text",
|
|
44
|
-
content: `${Math.round(u.value * 100)}%`,
|
|
45
|
-
minWidth: "3rem"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: "button",
|
|
49
|
-
icon: We,
|
|
50
|
-
tooltip: i.value("toolbar.zoom_in"),
|
|
51
|
-
action: re,
|
|
52
|
-
disabled: u.value >= 10
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
items: [
|
|
58
|
-
{
|
|
59
|
-
type: "button",
|
|
60
|
-
icon: Be,
|
|
61
|
-
tooltip: i.value("toolbar.fit_to_window"),
|
|
62
|
-
action: Q
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: "button",
|
|
66
|
-
icon: De,
|
|
67
|
-
tooltip: i.value("toolbar.original_size"),
|
|
68
|
-
action: fe
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
items: [
|
|
74
|
-
{
|
|
75
|
-
type: "button",
|
|
76
|
-
icon: Oe,
|
|
77
|
-
tooltip: i.value("toolbar.rotate_left"),
|
|
78
|
-
action: de
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: "button",
|
|
82
|
-
icon: Pe,
|
|
83
|
-
tooltip: i.value("toolbar.rotate_right"),
|
|
84
|
-
action: ve
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
items: [
|
|
90
|
-
{
|
|
91
|
-
type: "button",
|
|
92
|
-
icon: $e,
|
|
93
|
-
tooltip: i.value("toolbar.reset"),
|
|
94
|
-
action: he
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
|
-
onToolbarChange: (e) => G.subscribe(e)
|
|
100
|
-
});
|
|
101
|
-
const re = () => {
|
|
102
|
-
u.value = Math.min(u.value + 0.1, 10);
|
|
103
|
-
}, ce = () => {
|
|
104
|
-
u.value = Math.max(u.value - 0.1, 0.01);
|
|
105
|
-
}, ve = () => {
|
|
106
|
-
C.value = (C.value + 90) % 360;
|
|
107
|
-
}, de = () => {
|
|
108
|
-
C.value = (C.value - 90 + 360) % 360;
|
|
109
|
-
}, fe = () => {
|
|
110
|
-
u.value = 1, C.value = 0, l.value = { x: 0, y: 0 };
|
|
111
|
-
}, he = () => {
|
|
112
|
-
Q();
|
|
113
|
-
}, Q = () => {
|
|
114
|
-
if (h.value && v.value.width > 0 && v.value.height > 0) {
|
|
115
|
-
const e = h.value.clientWidth, t = h.value.clientHeight, a = e / v.value.width, r = t / v.value.height;
|
|
116
|
-
u.value = Math.max(0.01, Math.min(10, Math.min(a, r))), l.value = { x: 0, y: 0 };
|
|
117
|
-
}
|
|
118
|
-
}, pe = s(null), h = s(null);
|
|
119
|
-
let S = null, D = null, O = null;
|
|
120
|
-
const g = /* @__PURE__ */ new Map();
|
|
121
|
-
let P = !1, $ = 0, A = 1, V = { x: 0, y: 0 }, F = 0;
|
|
122
|
-
Z(
|
|
123
|
-
() => [f.url, f.file],
|
|
124
|
-
async () => {
|
|
125
|
-
if (L.value = "", T.value = !1, M.value = null, p.value = !1, R.value = null, B.value = 0, l.value = { x: 0, y: 0 }, m.value = 1, u.value = 1, k.value = 1, Y.value = 1, I.value = !1, S && (URL.revokeObjectURL(S), S = null), g.forEach((e) => URL.revokeObjectURL(e)), g.clear(), D = null, O = null, !f.file) {
|
|
126
|
-
L.value = f.url;
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const e = await Ce(f.file), t = await Te(e);
|
|
131
|
-
if (!t || !await t.needsDecode(e)) {
|
|
132
|
-
L.value = f.url;
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
p.value = !0;
|
|
136
|
-
let a;
|
|
137
|
-
if (f.file instanceof Blob)
|
|
138
|
-
a = f.file;
|
|
139
|
-
else if (f.file.file instanceof Blob)
|
|
140
|
-
a = f.file.file;
|
|
141
|
-
else {
|
|
142
|
-
const o = await fetch(f.url);
|
|
143
|
-
if (!o.ok) throw new Ue("file.load_failed");
|
|
144
|
-
a = await o.blob();
|
|
145
|
-
}
|
|
146
|
-
if (D = a, O = t, e.startsWith("image/x-") && (I.value = !0), t.getMetadata)
|
|
147
|
-
try {
|
|
148
|
-
const o = await t.getMetadata(a);
|
|
149
|
-
o.pageCount && o.pageCount > 1 && (Y.value = o.pageCount);
|
|
150
|
-
} catch {
|
|
151
|
-
}
|
|
152
|
-
const c = {
|
|
153
|
-
page: 1,
|
|
154
|
-
fullQuality: !1,
|
|
155
|
-
onProgress: (o) => {
|
|
156
|
-
B.value = o;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
let n;
|
|
160
|
-
if (Ye(e))
|
|
161
|
-
try {
|
|
162
|
-
n = await ze(
|
|
163
|
-
e,
|
|
164
|
-
await a.arrayBuffer(),
|
|
165
|
-
{ page: 1, fullQuality: !1 }
|
|
166
|
-
);
|
|
167
|
-
} catch {
|
|
168
|
-
n = await t.decode(a, c);
|
|
169
|
-
}
|
|
170
|
-
else
|
|
171
|
-
n = await t.decode(a, c);
|
|
172
|
-
const d = typeof n == "string" ? n : URL.createObjectURL(n);
|
|
173
|
-
S = d, g.set(1, d), L.value = d, p.value = !1;
|
|
174
|
-
} catch (e) {
|
|
175
|
-
R.value = oe(i.value, e) || i.value("image.decode_failed"), p.value = !1;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
{ immediate: !0 }
|
|
179
|
-
);
|
|
180
|
-
const K = async (e) => {
|
|
181
|
-
if (!D || !O || e < 1 || e > Y.value) return;
|
|
182
|
-
const t = g.get(e);
|
|
183
|
-
if (t) {
|
|
184
|
-
k.value = e, L.value = t;
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
p.value = !0;
|
|
188
|
-
try {
|
|
189
|
-
const a = await O.decode(D, { page: e }), r = typeof a == "string" ? a : URL.createObjectURL(a);
|
|
190
|
-
if (g.size >= 10) {
|
|
191
|
-
const c = g.keys().next().value;
|
|
192
|
-
if (c !== void 0) {
|
|
193
|
-
const n = g.get(c);
|
|
194
|
-
n && URL.revokeObjectURL(n), g.delete(c);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
g.set(e, r), k.value = e, L.value = r, p.value = !1;
|
|
198
|
-
} catch (a) {
|
|
199
|
-
R.value = oe(i.value, a) || i.value("image.page_decode_failed"), p.value = !1;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
te(() => {
|
|
203
|
-
S && URL.revokeObjectURL(S), g.forEach((t) => URL.revokeObjectURL(t)), g.clear();
|
|
204
|
-
const e = h.value;
|
|
205
|
-
e && e.removeEventListener("wheel", N);
|
|
206
|
-
}), Z(u, (e) => {
|
|
207
|
-
m.value = e;
|
|
208
|
-
}), Z(m, (e) => {
|
|
209
|
-
u.value = e;
|
|
210
|
-
});
|
|
211
|
-
const j = (e, t) => {
|
|
212
|
-
const a = h.value;
|
|
213
|
-
if (!a || v.value.width === 0) return e;
|
|
214
|
-
const r = a.clientWidth, c = a.clientHeight, n = v.value.width * t, d = v.value.height * t, o = Math.min(80, r * 0.15, c * 0.15), x = (r + n) / 2 - o, X = (c + d) / 2 - o;
|
|
215
|
-
return {
|
|
216
|
-
x: x > 0 ? Math.max(-x, Math.min(x, e.x)) : 0,
|
|
217
|
-
y: X > 0 ? Math.max(-X, Math.min(X, e.y)) : 0
|
|
218
|
-
};
|
|
219
|
-
}, me = (e) => {
|
|
220
|
-
T.value = !0;
|
|
221
|
-
const t = e.currentTarget;
|
|
222
|
-
if (v.value = { width: t.naturalWidth, height: t.naturalHeight }, h.value && v.value.width > 0 && v.value.height > 0) {
|
|
223
|
-
const a = h.value.clientWidth, r = h.value.clientHeight, c = a / v.value.width, n = r / v.value.height, d = Math.min(c, n);
|
|
224
|
-
u.value = Math.max(0.01, Math.min(10, d)), l.value = { x: 0, y: 0 };
|
|
225
|
-
}
|
|
226
|
-
}, ge = () => {
|
|
227
|
-
M.value = i.value("image.load_failed"), T.value = !0;
|
|
228
|
-
}, be = () => {
|
|
229
|
-
l.value = { x: 0, y: 0 }, u.value = 1;
|
|
230
|
-
}, N = (e) => {
|
|
231
|
-
e.preventDefault(), e.stopPropagation();
|
|
232
|
-
const t = h.value;
|
|
233
|
-
if (!t) return;
|
|
234
|
-
const a = t.getBoundingClientRect(), r = e.clientX - a.left - a.width / 2, c = e.clientY - a.top - a.height / 2, n = e.deltaY > 0 ? -0.05 : 0.05, d = m.value, o = Math.max(0.01, Math.min(10, d + n)), x = o / d;
|
|
235
|
-
l.value = j(
|
|
236
|
-
{
|
|
237
|
-
x: r - x * (r - l.value.x),
|
|
238
|
-
y: c - x * (c - l.value.y)
|
|
239
|
-
},
|
|
240
|
-
o
|
|
241
|
-
), m.value = o;
|
|
242
|
-
};
|
|
243
|
-
Re(() => {
|
|
244
|
-
const e = h.value;
|
|
245
|
-
e && (e.addEventListener("wheel", N, { passive: !1 }), e.addEventListener("touchstart", J, { passive: !1 }), e.addEventListener("touchmove", ee, { passive: !1 }), e.addEventListener("touchend", H), e.addEventListener("touchcancel", H));
|
|
246
|
-
}), te(() => {
|
|
247
|
-
const e = h.value;
|
|
248
|
-
e && (e.removeEventListener("wheel", N), e.removeEventListener("touchstart", J), e.removeEventListener("touchmove", ee), e.removeEventListener("touchend", H), e.removeEventListener("touchcancel", H));
|
|
249
|
-
});
|
|
250
|
-
const ye = (e) => {
|
|
251
|
-
P || e.button === 0 && (y.value = !0, z = {
|
|
252
|
-
x: e.clientX - l.value.x,
|
|
253
|
-
y: e.clientY - l.value.y
|
|
254
|
-
});
|
|
255
|
-
}, xe = (e) => {
|
|
256
|
-
P || y.value && (l.value = j(
|
|
257
|
-
{
|
|
258
|
-
x: e.clientX - z.x,
|
|
259
|
-
y: e.clientY - z.y
|
|
260
|
-
},
|
|
261
|
-
m.value
|
|
262
|
-
));
|
|
263
|
-
}, q = () => {
|
|
264
|
-
P || (y.value = !1);
|
|
265
|
-
}, J = (e) => {
|
|
266
|
-
P = !0, e.preventDefault();
|
|
267
|
-
const t = e.touches;
|
|
268
|
-
if (t.length === 1) {
|
|
269
|
-
y.value = !0, z = {
|
|
270
|
-
x: t[0].clientX - l.value.x,
|
|
271
|
-
y: t[0].clientY - l.value.y
|
|
272
|
-
};
|
|
273
|
-
const a = Date.now();
|
|
274
|
-
a - F < 300 && (l.value = { x: 0, y: 0 }, u.value = 1), F = a;
|
|
275
|
-
} else t.length === 2 && (y.value = !1, $ = Math.hypot(
|
|
276
|
-
t[1].clientX - t[0].clientX,
|
|
277
|
-
t[1].clientY - t[0].clientY
|
|
278
|
-
), A = m.value, V = { ...l.value });
|
|
279
|
-
}, ee = (e) => {
|
|
280
|
-
e.preventDefault();
|
|
281
|
-
const t = e.touches;
|
|
282
|
-
if (t.length === 1 && y.value)
|
|
283
|
-
l.value = j(
|
|
284
|
-
{
|
|
285
|
-
x: t[0].clientX - z.x,
|
|
286
|
-
y: t[0].clientY - z.y
|
|
287
|
-
},
|
|
288
|
-
m.value
|
|
289
|
-
);
|
|
290
|
-
else if (t.length === 2) {
|
|
291
|
-
const a = h.value;
|
|
292
|
-
if (!a) return;
|
|
293
|
-
const r = Math.hypot(
|
|
294
|
-
t[1].clientX - t[0].clientX,
|
|
295
|
-
t[1].clientY - t[0].clientY
|
|
296
|
-
);
|
|
297
|
-
if (Math.abs(r - $) < 5) return;
|
|
298
|
-
const c = r / $, n = Math.max(0.01, Math.min(10, A * c)), d = a.getBoundingClientRect(), o = (t[0].clientX + t[1].clientX) / 2 - d.left - d.width / 2, x = (t[0].clientY + t[1].clientY) / 2 - d.top - d.height / 2, X = n / m.value;
|
|
299
|
-
l.value = j(
|
|
300
|
-
{
|
|
301
|
-
x: o - X * (o - V.x),
|
|
302
|
-
y: x - X * (x - V.y)
|
|
303
|
-
},
|
|
304
|
-
n
|
|
305
|
-
), m.value = n;
|
|
306
|
-
}
|
|
307
|
-
}, H = () => {
|
|
308
|
-
y.value = !1, $ = 0;
|
|
309
|
-
}, we = ae(() => ({
|
|
310
|
-
transform: `translate(${l.value.x}px, ${l.value.y}px) scale(${m.value}) rotate(${C.value}deg)`,
|
|
311
|
-
transformOrigin: "center",
|
|
312
|
-
transition: y.value ? "none" : "transform 0.3s ease-out",
|
|
313
|
-
opacity: T.value && !M.value && !R.value ? 1 : 0
|
|
314
|
-
})), _e = ae(() => f.fileSize == null ? "" : ` · ${Se(f.fileSize)}`);
|
|
315
|
-
return (e, t) => (w(), U("div", {
|
|
316
|
-
ref_key: "containerRef",
|
|
317
|
-
ref: h,
|
|
318
|
-
class: "vfp-relative vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full vfp-overflow-hidden",
|
|
319
|
-
style: le({ cursor: y.value ? "grabbing" : "grab", touchAction: "none" }),
|
|
320
|
-
onMousedown: ye,
|
|
321
|
-
onMousemove: xe,
|
|
322
|
-
onMouseup: q,
|
|
323
|
-
onMouseleave: q
|
|
324
|
-
}, [
|
|
325
|
-
p.value ? (w(), U("div", He, [
|
|
326
|
-
_("div", Ze, [
|
|
327
|
-
t[2] || (t[2] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
328
|
-
_("p", Ve, [
|
|
329
|
-
Le(b(W(i)("image.decoding")) + " ", 1),
|
|
330
|
-
B.value > 0 ? (w(), U("span", Ne, b(Math.round(B.value)) + "%", 1)) : E("", !0)
|
|
331
|
-
])
|
|
332
|
-
])
|
|
333
|
-
])) : E("", !0),
|
|
334
|
-
R.value ? (w(), ne(ie, {
|
|
335
|
-
key: 1,
|
|
336
|
-
message: W(i)("image.decode_failed"),
|
|
337
|
-
detail: R.value
|
|
338
|
-
}, null, 8, ["message", "detail"])) : E("", !0),
|
|
339
|
-
!T.value && !M.value && !p.value && !R.value ? (w(), U("div", Ge, [
|
|
340
|
-
_("div", Ie, [
|
|
341
|
-
t[3] || (t[3] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
342
|
-
_("span", Qe, b(W(i)("common.loading")), 1)
|
|
343
|
-
])
|
|
344
|
-
])) : E("", !0),
|
|
345
|
-
M.value ? (w(), ne(ie, {
|
|
346
|
-
key: 3,
|
|
347
|
-
message: M.value
|
|
348
|
-
}, null, 8, ["message"])) : E("", !0),
|
|
349
|
-
L.value ? (w(), U("img", {
|
|
350
|
-
key: 4,
|
|
351
|
-
ref_key: "imgRef",
|
|
352
|
-
ref: pe,
|
|
353
|
-
src: L.value,
|
|
354
|
-
alt: "Preview",
|
|
355
|
-
class: ke(["vfp-max-w-none vfp-select-none", (!T.value || M.value || R.value) && "vfp-hidden"]),
|
|
356
|
-
style: le(we.value),
|
|
357
|
-
draggable: !1,
|
|
358
|
-
onLoad: me,
|
|
359
|
-
onError: ge,
|
|
360
|
-
onDblclick: be
|
|
361
|
-
}, null, 46, Ae)) : E("", !0),
|
|
362
|
-
T.value && !M.value && v.value.width > 0 ? (w(), U("div", Fe, b(v.value.width) + " × " + b(v.value.height) + b(_e.value), 1)) : E("", !0),
|
|
363
|
-
Y.value > 1 ? (w(), U("div", Ke, [
|
|
364
|
-
_("button", {
|
|
365
|
-
type: "button",
|
|
366
|
-
disabled: k.value <= 1 || p.value,
|
|
367
|
-
class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
|
|
368
|
-
onClick: t[0] || (t[0] = (a) => K(k.value - 1))
|
|
369
|
-
}, b(W(i)("toolbar.prev_page")), 9, qe),
|
|
370
|
-
_("span", Je, b(k.value) + " / " + b(Y.value), 1),
|
|
371
|
-
_("button", {
|
|
372
|
-
type: "button",
|
|
373
|
-
disabled: k.value >= Y.value || p.value,
|
|
374
|
-
class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
|
|
375
|
-
onClick: t[1] || (t[1] = (a) => K(k.value + 1))
|
|
376
|
-
}, b(W(i)("toolbar.next_page")), 9, et)
|
|
377
|
-
])) : E("", !0)
|
|
378
|
-
], 36));
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
export {
|
|
382
|
-
st as default
|
|
383
|
-
};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { defineComponent as F, ref as c, computed as f, watch as k, unref as m, openBlock as t, createElementBlock as i, createElementVNode as l, toDisplayString as h, createBlock as T, normalizeClass as H, normalizeStyle as $, Fragment as C, renderList as z } from "vue";
|
|
2
|
-
import { WrapText as G, Code as M, Eye as W } from "lucide-vue-next";
|
|
3
|
-
import { u as X, c as D, C as P, w as R, l as V, X as j } from "./index-DZZN3kYi.mjs";
|
|
4
|
-
import { u as q } from "./useShikiHighlight-BPmcxA-h.mjs";
|
|
5
|
-
import { _ as A } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
6
|
-
import { _ as I } from "./EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs";
|
|
7
|
-
import { T as J } from "./base.types-DaftHyg7.mjs";
|
|
8
|
-
const K = {
|
|
9
|
-
key: 0,
|
|
10
|
-
class: "vfp-renderer-loading"
|
|
11
|
-
}, O = { class: "vfp-renderer-loading-content" }, Q = { class: "vfp-renderer-loading-text" }, U = {
|
|
12
|
-
key: 3,
|
|
13
|
-
class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
|
|
14
|
-
}, Y = ["srcdoc", "title"], Z = {
|
|
15
|
-
key: 4,
|
|
16
|
-
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
17
|
-
style: { background: "var(--fp-code-bg)" }
|
|
18
|
-
}, ee = {
|
|
19
|
-
key: 5,
|
|
20
|
-
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
21
|
-
style: { background: "var(--fp-code-bg)" }
|
|
22
|
-
}, le = { class: "vfp-code-gutter" }, te = ["innerHTML"], fe = /* @__PURE__ */ F({
|
|
23
|
-
__name: "index",
|
|
24
|
-
props: {
|
|
25
|
-
url: {},
|
|
26
|
-
fileName: {},
|
|
27
|
-
emptyHint: {}
|
|
28
|
-
},
|
|
29
|
-
setup(w, { expose: E }) {
|
|
30
|
-
const d = w, _ = new J(), { t: s } = X(), L = D(), o = c(!0), a = c(!1), r = c(""), v = c(!0), p = c(null), n = f(() => P(d.fileName)), N = f(() => n.value !== "text" ? r.value : ""), { lineHtmls: y, loading: S } = q(N, n), b = f(() => n.value === "html"), B = f(
|
|
31
|
-
() => !v.value && !p.value && R(r.value) && V(d.emptyHint, "textual")
|
|
32
|
-
);
|
|
33
|
-
k([o, a, v, b], () => {
|
|
34
|
-
_.notify();
|
|
35
|
-
}), k(() => d.url, async () => {
|
|
36
|
-
v.value = !0, p.value = null;
|
|
37
|
-
try {
|
|
38
|
-
const e = await j(d.url, { fetcher: L.value });
|
|
39
|
-
r.value = e;
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error(e), p.value = s.value("text.load_failed");
|
|
42
|
-
} finally {
|
|
43
|
-
v.value = !1;
|
|
44
|
-
}
|
|
45
|
-
}, { immediate: !0 });
|
|
46
|
-
const x = f(() => r.value.split(`
|
|
47
|
-
`));
|
|
48
|
-
return E({
|
|
49
|
-
getToolbarGroups: () => {
|
|
50
|
-
const e = [];
|
|
51
|
-
return e.push({
|
|
52
|
-
items: [
|
|
53
|
-
{
|
|
54
|
-
type: "button",
|
|
55
|
-
icon: G,
|
|
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
|
-
}), b.value && e.push({
|
|
64
|
-
items: [
|
|
65
|
-
{
|
|
66
|
-
type: "button",
|
|
67
|
-
icon: a.value ? M : 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) => v.value || n.value !== "text" && m(S) ? (t(), i("div", K, [
|
|
79
|
-
l("div", O, [
|
|
80
|
-
u[0] || (u[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
81
|
-
l("span", Q, h(m(s)("common.loading")), 1)
|
|
82
|
-
])
|
|
83
|
-
])) : p.value ? (t(), T(A, {
|
|
84
|
-
key: 1,
|
|
85
|
-
message: p.value
|
|
86
|
-
}, null, 8, ["message"])) : B.value ? (t(), T(I, { key: 2 })) : a.value && n.value === "html" ? (t(), i("div", U, [
|
|
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: w.fileName
|
|
92
|
-
}, null, 8, Y)
|
|
93
|
-
])) : n.value === "text" || m(y).length === 0 ? (t(), i("div", Z, [
|
|
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", ee, [
|
|
98
|
-
l("div", {
|
|
99
|
-
class: H(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !o.value }]),
|
|
100
|
-
style: $({ gridTemplateRows: `repeat(${x.value.length}, auto) minmax(1.5rem, 1fr)` })
|
|
101
|
-
}, [
|
|
102
|
-
(t(!0), i(C, null, z(x.value, (se, g) => (t(), i(C, { key: g }, [
|
|
103
|
-
l("span", le, h(g + 1), 1),
|
|
104
|
-
l("span", {
|
|
105
|
-
class: "vfp-code-line",
|
|
106
|
-
innerHTML: m(y)[g] ?? ""
|
|
107
|
-
}, null, 8, te)
|
|
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
|
-
fe as default
|
|
117
|
-
};
|