@eternalheart/vue-file-preview 1.6.12 → 1.6.13

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 (51) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/lib/FilePreviewContent.vue.d.ts +9 -1
  4. package/lib/FilePreviewEmbed.vue.d.ts +4 -1
  5. package/lib/FilePreviewModal.vue.d.ts +4 -1
  6. package/lib/chunks/EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs +20 -0
  7. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs +32 -0
  8. package/lib/chunks/{avifLoader-CAUzjn-d-CTy7cevh.mjs → avifLoader-CAUzjn-d-C0KRpetN.mjs} +1 -1
  9. package/lib/chunks/{heicLoader-D_9PukkA-DdDu94xL.mjs → heicLoader-D_9PukkA-Czof_5FJ.mjs} +1 -1
  10. package/lib/chunks/{index-CLM9sOKN.mjs → index--612Smof.mjs} +112 -112
  11. package/lib/chunks/{index-De-oaCgN.mjs → index-8Vpbg2kS.mjs} +2 -2
  12. package/lib/chunks/{index-2VQLB2Mi.mjs → index-B21EAyWz.mjs} +53 -49
  13. package/lib/chunks/{index-DmEMePjL.mjs → index-BASg1cr4.mjs} +2 -2
  14. package/lib/chunks/index-BB0i4QqI.mjs +117 -0
  15. package/lib/chunks/{index-Bmqn45d_.mjs → index-BVdrGK3Q.mjs} +72 -72
  16. package/lib/chunks/index-BlrFFeqc.mjs +330 -0
  17. package/lib/chunks/index-Bp9CuvMZ.mjs +157 -0
  18. package/lib/chunks/{index-i-KacQvS.mjs → index-BuqPb5mP.mjs} +3 -3
  19. package/lib/chunks/{index-DVG1fZAv.mjs → index-BvBqDq3O.mjs} +2 -2
  20. package/lib/chunks/{index-D6te_qaB.mjs → index-Bxpf9v5j.mjs} +26 -26
  21. package/lib/chunks/{index-D9z6lQat.mjs → index-C9mAajbD.mjs} +225 -220
  22. package/lib/chunks/{index-CM11hSQu.mjs → index-CDg6vIbT.mjs} +11 -11
  23. package/lib/chunks/{index-BxmX005K.mjs → index-CWE-hKSs.mjs} +11 -11
  24. package/lib/chunks/{index-BPmyF7Wr.mjs → index-CY3xzGgt.mjs} +18 -18
  25. package/lib/chunks/{index-t9kSzzMg.mjs → index-CxKZKUJj.mjs} +521 -523
  26. package/lib/chunks/{index-CuiEjR23.mjs → index-D30L8tm9.mjs} +15 -15
  27. package/lib/chunks/{index-DOAOk6m5.mjs → index-DN4Ui0Gh.mjs} +11 -11
  28. package/lib/chunks/{index-CEk6FKm3.mjs → index-DZZN3kYi.mjs} +551 -531
  29. package/lib/chunks/{index-D6Pjjxi0.mjs → index-Dkro_8Fy.mjs} +20 -20
  30. package/lib/chunks/{index-CiGUKdlt.mjs → index-VdzIFJJW.mjs} +23 -23
  31. package/lib/chunks/{index-WcAnJA2t.mjs → index-aoXgVLBb.mjs} +14 -14
  32. package/lib/chunks/{jp2Loader-Dig19xyo-BBR3tcPW.mjs → jp2Loader-Dig19xyo-CKUaGhPl.mjs} +1 -1
  33. package/lib/chunks/{psdLoader-C0tKUXXl-DGOmJwkQ.mjs → psdLoader-C0tKUXXl-CYWoQis5.mjs} +1 -1
  34. package/lib/chunks/{rawLoader-C-tPeFAB-CrCtXMup.mjs → rawLoader-C-tPeFAB-C35zC8nZ.mjs} +1 -1
  35. package/lib/chunks/{tiffLoader-BlhByX8w-jsxHlbyu.mjs → tiffLoader-BlhByX8w-BOxg_Du5.mjs} +1 -1
  36. package/lib/chunks/{useShikiHighlight-BdhPCj48.mjs → useShikiHighlight-BPmcxA-h.mjs} +1 -1
  37. package/lib/index.cjs +59 -59
  38. package/lib/index.css +1 -1
  39. package/lib/index.d.ts +1 -1
  40. package/lib/index.mjs +4 -4
  41. package/lib/renderers/EmptyState.vue.d.ts +2 -0
  42. package/lib/renderers/Json/index.vue.d.ts +5 -0
  43. package/lib/renderers/Pptx/index.vue.d.ts +3 -0
  44. package/lib/renderers/Text/index.vue.d.ts +3 -0
  45. package/lib/renderers/Xlsx/index.vue.d.ts +3 -0
  46. package/lib/renderers/registry.d.ts +3 -1
  47. package/package.json +1 -1
  48. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs +0 -30
  49. package/lib/chunks/index-Bfg5zM8l.mjs +0 -141
  50. package/lib/chunks/index-Cud9j9Xy.mjs +0 -322
  51. package/lib/chunks/index-D4jhvs5m.mjs +0 -113
@@ -1,41 +1,45 @@
1
- import { defineComponent as E, ref as m, onMounted as z, watch as B, onBeforeUnmount as S, openBlock as v, createElementBlock as w, createElementVNode as x, toDisplayString as H, unref as k, createCommentVNode as g, createBlock as L, normalizeStyle as R } from "vue";
2
- import { u as A, b as C, k as u, d as G, W as F, p as N, o as O, e as V, x as Z, Z as q } from "./index-CEk6FKm3.mjs";
3
- import I from "exceljs";
4
- import { S as J } from "./index-CyBXARuf.mjs";
5
- import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
1
+ import { defineComponent as S, ref as w, onMounted as E, watch as B, onBeforeUnmount as H, openBlock as d, createElementBlock as h, createElementVNode as x, toDisplayString as z, unref as k, createCommentVNode as g, createVNode as L, normalizeStyle as R } from "vue";
2
+ import { u as A, c as C, k as v, e as G, o as J, J as N, h as V, f as F, Z as O, W as Z } from "./index-DZZN3kYi.mjs";
3
+ import q from "exceljs";
4
+ import { S as I } from "./index-CyBXARuf.mjs";
5
+ import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
6
  const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, $ = {
7
7
  key: 0,
8
- class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
9
- }, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, re = /* @__PURE__ */ E({
8
+ class: "vfp-renderer-overlay vfp-renderer-loading"
9
+ }, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text" }, P = {
10
+ key: 1,
11
+ class: "vfp-renderer-overlay"
12
+ }, se = /* @__PURE__ */ S({
10
13
  __name: "index",
11
14
  props: {
12
- url: {}
15
+ url: {},
16
+ emptyHint: {}
13
17
  },
14
18
  setup(T, { expose: W }) {
15
19
  async function D(e) {
16
20
  try {
17
- return await new I.Workbook().xlsx.load(e.slice().buffer);
21
+ return await new q.Workbook().xlsx.load(e.slice().buffer);
18
22
  } catch (t) {
19
- throw t instanceof TypeError && /sheets/i.test(t.message) ? new u("xlsx.invalid_format") : t;
23
+ throw t instanceof TypeError && /sheets/i.test(t.message) ? new v("xlsx.invalid_format") : t;
20
24
  }
21
25
  }
22
- const b = T, { t: o } = A(), M = C(), a = m(!0), n = m(null), l = m(null);
23
- let i = null, h = 100, c = null, f = null, d = { width: 0, height: 0 };
26
+ const _ = T, { t: o } = A(), M = C(), a = w(!0), n = w(null), l = w(null);
27
+ let i = null, m = 100, f = null, u = null, c = { width: 0, height: 0 };
24
28
  const p = () => {
25
29
  if (!l.value) return { width: 800, height: 600 };
26
30
  const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
27
31
  return { width: r, height: s };
28
- }, _ = () => {
32
+ }, y = () => {
29
33
  if (!l.value || !i) return;
30
34
  l.value.innerHTML = "";
31
35
  const { width: e, height: t } = p(), r = e < 640;
32
- new J(l.value, {
36
+ new I(l.value, {
33
37
  mode: "read",
34
38
  showToolbar: !1,
35
39
  showContextmenu: !1,
36
40
  showGrid: !0,
37
41
  row: {
38
- len: h,
42
+ len: m,
39
43
  height: 25
40
44
  },
41
45
  col: {
@@ -49,76 +53,76 @@ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
49
53
  width: () => e
50
54
  }
51
55
  }).loadData(i);
52
- }, y = async () => {
56
+ }, b = async () => {
53
57
  if (l.value) {
54
58
  a.value = !0, n.value = null;
55
59
  try {
56
- const e = await M.value(b.url, {
60
+ const e = await M.value(_.url, {
57
61
  mode: "cors",
58
62
  credentials: "omit",
59
63
  redirect: "follow"
60
64
  });
61
65
  if (!e.ok)
62
- throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new u("file.forbidden") : new u("file.load_failed_status", { status: e.status });
66
+ throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new v("file.forbidden") : new v("file.load_failed_status", { status: e.status });
63
67
  const t = G(await e.arrayBuffer());
64
- if (t.byteLength === 0)
65
- throw new u("file.empty");
66
68
  let r;
67
- if (F(t)) {
69
+ if (t.byteLength === 0)
70
+ r = [{ name: "Sheet1" }];
71
+ else if (J(t)) {
68
72
  const s = N(t);
69
73
  if (!s || !Array.isArray(s.sheets))
70
- throw new u("xlsx.invalid_legacy_data");
71
- r = O(s);
74
+ throw new v("xlsx.invalid_legacy_data");
75
+ r = V(s);
72
76
  } else
73
- r = V(
77
+ r = F(
74
78
  await D(t)
75
79
  );
76
- i = r, h = Z(r), _(), a.value = !1;
80
+ i = r.length ? r : [{ name: "Sheet1" }], m = O(r), y(), a.value = !1;
77
81
  } catch (e) {
78
82
  console.error(o.value("xlsx.parse_failed") + ":", e);
79
83
  let t = o.value("xlsx.parse_failed");
80
- e instanceof Error && (t = q(o.value, e)), n.value = t, a.value = !1;
84
+ e instanceof Error && (t = Z(o.value, e)), n.value = t, a.value = !1;
81
85
  }
82
86
  }
83
87
  };
84
- return z(() => {
88
+ return E(() => {
85
89
  if (!l.value) return;
86
90
  let e = !0;
87
- c = new ResizeObserver(() => {
91
+ f = new ResizeObserver(() => {
88
92
  if (e) {
89
- e = !1, d = p();
93
+ e = !1, c = p();
90
94
  return;
91
95
  }
92
- const t = p(), r = Math.abs(d.width - t.width), s = Math.abs(d.height - t.height);
93
- r < 10 && s < 10 || (d = t, f !== null && clearTimeout(f), f = window.setTimeout(() => {
94
- i && _();
96
+ const t = p(), r = Math.abs(c.width - t.width), s = Math.abs(c.height - t.height);
97
+ r < 10 && s < 10 || (c = t, u !== null && clearTimeout(u), u = window.setTimeout(() => {
98
+ i && y();
95
99
  }, 500));
96
- }), c.observe(l.value), setTimeout(() => {
97
- requestAnimationFrame(() => y());
100
+ }), f.observe(l.value), setTimeout(() => {
101
+ requestAnimationFrame(() => b());
98
102
  }, 100);
99
103
  }), B(
100
- () => b.url,
104
+ () => _.url,
101
105
  (e) => {
102
- e && y();
106
+ e && b();
103
107
  }
104
- ), S(() => {
105
- c && c.disconnect(), f !== null && clearTimeout(f), i = null, h = 100, l.value && (l.value.innerHTML = "");
108
+ ), H(() => {
109
+ f && f.disconnect(), u !== null && clearTimeout(u), i = null, m = 100, l.value && (l.value.innerHTML = "");
106
110
  }), W({
107
111
  getToolbarGroups: () => []
108
- }), (e, t) => (v(), w("div", X, [
109
- a.value ? (v(), w("div", $, [
112
+ }), (e, t) => (d(), h("div", X, [
113
+ a.value ? (d(), h("div", $, [
110
114
  x("div", j, [
111
115
  t[0] || (t[0] = x("div", { class: "vfp-renderer-spinner" }, null, -1)),
112
- x("p", K, H(k(o)("xlsx.loading")), 1)
116
+ x("p", K, z(k(o)("xlsx.loading")), 1)
113
117
  ])
114
118
  ])) : g("", !0),
115
- n.value && !a.value ? (v(), L(U, {
116
- key: 1,
117
- message: k(o)("xlsx.load_failed"),
118
- detail: n.value,
119
- class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
120
- }, null, 8, ["message", "detail"])) : g("", !0),
121
- n.value ? g("", !0) : (v(), w("div", {
119
+ n.value && !a.value ? (d(), h("div", P, [
120
+ L(U, {
121
+ message: k(o)("xlsx.load_failed"),
122
+ detail: n.value
123
+ }, null, 8, ["message", "detail"])
124
+ ])) : g("", !0),
125
+ n.value ? g("", !0) : (d(), h("div", {
122
126
  key: 2,
123
127
  ref_key: "containerRef",
124
128
  ref: l,
@@ -129,5 +133,5 @@ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
129
133
  }
130
134
  });
131
135
  export {
132
- re as default
136
+ se as default
133
137
  };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as er, ref as qe, watch as tr, computed as te, openBlock as J, createElementBlock as Q, createElementVNode as D, toDisplayString as ne, unref as ae, createBlock as rr, createVNode as he, createCommentVNode as oe, normalizeStyle as ir, Fragment as nr, renderList as ar, createTextVNode as sr, normalizeClass as or } from "vue";
2
- import { u as cr, b as fr, k as ur, _ as hr } from "./index-CEk6FKm3.mjs";
2
+ import { u as cr, c as fr, k as ur, _ as hr } from "./index-DZZN3kYi.mjs";
3
3
  import { User as lr, Users as Ve, Calendar as mt, Clock as Et, Tag as gt, Mail as dr, Paperclip as pr, Hash as yr } from "lucide-vue-next";
4
- import { _ as br } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
4
+ import { _ as br } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
5
  var fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
6
6
  function vr(e) {
7
7
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -0,0 +1,117 @@
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
+ };