@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,30 +1,30 @@
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 = {
1
+ import { defineComponent as ce, ref as d, watch as Y, onMounted as fe, onBeforeUnmount as pe, openBlock as h, createElementBlock as m, createBlock as ve, createCommentVNode as W, createElementVNode as p, toDisplayString as L, unref as N, normalizeStyle as z, createVNode as de, Fragment as O, renderList as Z } from "vue";
2
+ import he from "@likecoin/epub-ts";
3
+ import { List as me, ChevronLeft as ge, ChevronRight as be, Minimize2 as xe, Maximize2 as we, X as ye } from "lucide-vue-next";
4
+ import { u as ke, a as _e, b as Te } from "./index-c-pYJEmH.mjs";
5
+ import { _ as ze } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ import { T as Ce } from "./base.types-DaftHyg7.mjs";
7
+ const Se = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, We = {
8
8
  key: 1,
9
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 = {
10
+ }, Me = { class: "vfp-renderer-loading-content" }, Ee = { class: "vfp-renderer-loading-text" }, $e = {
11
11
  class: "vfp-flex vfp-items-center vfp-justify-between vfp-flex-shrink-0",
12
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 = {
13
+ }, He = { style: { color: "white", "font-weight": "500", "font-size": "14px" } }, Re = {
14
14
  class: "vfp-flex-1 vfp-overflow-y-auto",
15
15
  style: { padding: "8px 4px" }
16
- }, He = ["title", "onClick", "onMouseenter", "onMouseleave"], Re = ["title", "onClick", "onMouseenter", "onMouseleave"], Le = 794, qe = /* @__PURE__ */ ue({
16
+ }, Le = ["title", "onClick", "onMouseenter", "onMouseleave"], Ae = ["title", "onClick", "onMouseenter", "onMouseleave"], Fe = 794, Ie = /* @__PURE__ */ ce({
17
17
  __name: "index",
18
18
  props: {
19
19
  url: {}
20
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], () => {
21
+ setup(ee, { expose: te }) {
22
+ const C = ee, q = new Ce(), { t: v } = ke(), oe = _e(), G = Te(), 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
+ Y([g, w, b, s, () => x.value.length], () => {
24
24
  q.notify();
25
25
  });
26
26
  let c = null, e = null, k = 0, _ = null;
27
- const G = () => {
27
+ const I = () => {
28
28
  var t;
29
29
  try {
30
30
  (t = e == null ? void 0 : e.destroy) == null || t.call(e);
@@ -35,28 +35,28 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
35
35
  } catch {
36
36
  }
37
37
  e = null, c = null, k = 0, _ = null;
38
- }, oe = () => {
39
- e == null || e.prev();
40
38
  }, ae = () => {
41
- e == null || e.next();
39
+ e == null || e.prev();
42
40
  }, re = () => {
41
+ e == null || e.next();
42
+ }, le = () => {
43
43
  b.value = !b.value, setTimeout(() => {
44
44
  r.value && e && (e.resize(r.value.offsetWidth, r.value.offsetHeight), _ && e.display(_), P());
45
45
  }, 350);
46
- }, le = () => {
46
+ }, ne = () => {
47
47
  s.value = !s.value;
48
- }, I = (t) => {
48
+ }, V = (t) => {
49
49
  A.value = t, e == null || e.display(t), s.value = !1;
50
50
  }, f = (t) => t === A.value;
51
- ee({
51
+ te({
52
52
  getToolbarGroups: () => [
53
53
  {
54
54
  items: [
55
55
  {
56
56
  type: "button",
57
- icon: he,
57
+ icon: me,
58
58
  tooltip: v.value("toolbar.toc"),
59
- action: le,
59
+ action: ne,
60
60
  disabled: x.value.length === 0,
61
61
  active: s.value
62
62
  }
@@ -66,9 +66,9 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
66
66
  items: [
67
67
  {
68
68
  type: "button",
69
- icon: me,
69
+ icon: ge,
70
70
  tooltip: v.value("toolbar.prev_page"),
71
- action: oe,
71
+ action: ae,
72
72
  disabled: g.value <= 1
73
73
  },
74
74
  {
@@ -78,9 +78,9 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
78
78
  },
79
79
  {
80
80
  type: "button",
81
- icon: ge,
81
+ icon: be,
82
82
  tooltip: v.value("toolbar.next_page"),
83
- action: ae,
83
+ action: re,
84
84
  disabled: g.value >= w.value
85
85
  }
86
86
  ]
@@ -89,9 +89,9 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
89
89
  items: [
90
90
  {
91
91
  type: "button",
92
- icon: b.value ? be : xe,
92
+ icon: b.value ? xe : we,
93
93
  tooltip: b.value ? v.value("toolbar.normal_width") : v.value("toolbar.full_width"),
94
- action: re,
94
+ action: le,
95
95
  active: b.value
96
96
  }
97
97
  ]
@@ -99,13 +99,13 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
99
99
  ],
100
100
  onToolbarChange: (t) => q.subscribe(t)
101
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();
102
+ const X = async () => {
103
+ if (G.begin(C.url), !!r.value) {
104
+ M.value = !0, y.value = null, x.value = [], s.value = !1, r.value.innerHTML = "", I();
105
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);
106
+ let t = C.url;
107
+ C.url.startsWith("blob:") && (t = await (await oe.value(C.url)).arrayBuffer());
108
+ const l = he(t);
109
109
  c = l;
110
110
  const o = new Promise((a, n) => {
111
111
  l.on("openFailed", (i) => {
@@ -146,27 +146,27 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
146
146
  });
147
147
  const T = await Promise.race([c.loaded.navigation, o]);
148
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;
149
+ var U, J, K;
150
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) {
151
+ if ((U = n == null ? void 0 : n.start) != null && U.cfi && (_ = n.start.cfi), (J = n == null ? void 0 : n.start) != null && J.href) {
152
+ const B = n.start.href, D = [], Q = (ue) => {
153
+ for (const H of ue) {
154
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);
155
+ R && (B === R || B.endsWith("/" + R) || B.endsWith(R)) && D.push(H.href), H.subitems && Q(H.subitems);
156
156
  }
157
157
  };
158
- K(x.value), D.length === 1 && (A.value = D[0]);
158
+ Q(x.value), D.length === 1 && (A.value = D[0]);
159
159
  }
160
- const i = (J = n == null ? void 0 : n.start) == null ? void 0 : J.location;
160
+ const i = (K = n == null ? void 0 : n.start) == null ? void 0 : K.location;
161
161
  typeof i == "number" && k > 0 && (g.value = i + 1, w.value = k);
162
162
  });
163
163
  } catch (t) {
164
- console.error(v.value("epub.load_failed") + ":", t), y.value = v.value("epub.load_failed"), M.value = !1;
164
+ console.error(v.value("epub.load_failed") + ":", t), y.value = v.value("epub.load_failed"), M.value = !1, G.error(t);
165
165
  }
166
166
  }
167
167
  };
168
- let E = null, C = null, $ = { width: 0, height: 0 }, X = !0;
169
- const ne = () => {
168
+ let E = null, S = null, $ = { width: 0, height: 0 }, j = !0;
169
+ const ie = () => {
170
170
  if (!(!r.value || !e)) {
171
171
  if (e.resize(r.value.offsetWidth, r.value.offsetHeight), _)
172
172
  try {
@@ -175,15 +175,15 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
175
175
  }
176
176
  P();
177
177
  }
178
- }, ie = () => {
178
+ }, se = () => {
179
179
  r.value && (E = new ResizeObserver(() => {
180
180
  if (!r.value) return;
181
- if (X) {
182
- X = !1, $ = { width: r.value.offsetWidth, height: r.value.offsetHeight };
181
+ if (j) {
182
+ j = !1, $ = { width: r.value.offsetWidth, height: r.value.offsetHeight };
183
183
  return;
184
184
  }
185
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));
186
+ l < 10 && o < 10 || ($ = t, S !== null && clearTimeout(S), S = window.setTimeout(ie, 350));
187
187
  }), E.observe(r.value));
188
188
  };
189
189
  let u = null;
@@ -205,24 +205,24 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
205
205
  };
206
206
  requestAnimationFrame(t);
207
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, {
208
+ return fe(() => {
209
+ X(), se(), P();
210
+ }), Y(() => C.url, (t) => {
211
+ t && X();
212
+ }), pe(() => {
213
+ E && E.disconnect(), S !== null && clearTimeout(S), u == null || u.removeEventListener("scroll", F), I();
214
+ }), (t, l) => (h(), m("div", Se, [
215
+ y.value ? (h(), ve(ze, {
216
216
  key: 0,
217
217
  message: y.value,
218
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, [
219
+ }, null, 8, ["message"])) : W("", !0),
220
+ M.value && !y.value ? (h(), m("div", We, [
221
+ p("div", Me, [
222
222
  l[2] || (l[2] = p("div", { class: "vfp-renderer-spinner" }, null, -1)),
223
- p("span", We, L(N(v)("common.loading")), 1)
223
+ p("span", Ee, L(N(v)("common.loading")), 1)
224
224
  ])
225
- ])) : S("", !0),
225
+ ])) : W("", !0),
226
226
  x.value.length > 0 ? (h(), m("div", {
227
227
  key: 2,
228
228
  class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex",
@@ -240,17 +240,17 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
240
240
  transition: "transform 0.3s ease"
241
241
  })
242
242
  }, [
243
- p("div", Me, [
244
- p("span", Ee, L(N(v)("toolbar.toc")), 1),
243
+ p("div", $e, [
244
+ p("span", He, L(N(v)("toolbar.toc")), 1),
245
245
  p("button", {
246
246
  style: { color: "rgba(255,255,255,0.6)", background: "none", border: "none", cursor: "pointer", padding: "4px" },
247
247
  onClick: l[0] || (l[0] = (o) => s.value = !1)
248
248
  }, [
249
- ve(N(we), { style: { width: "16px", height: "16px" } })
249
+ de(N(ye), { style: { width: "16px", height: "16px" } })
250
250
  ])
251
251
  ]),
252
- p("div", $e, [
253
- (h(!0), m(O, null, Y(x.value, (o, T) => (h(), m(O, {
252
+ p("div", Re, [
253
+ (h(!0), m(O, null, Z(x.value, (o, T) => (h(), m(O, {
254
254
  key: `${o.href}-${T}`
255
255
  }, [
256
256
  p("button", {
@@ -272,11 +272,11 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
272
272
  transition: "all 0.15s"
273
273
  }),
274
274
  title: o.label,
275
- onClick: (a) => I(o.href),
275
+ onClick: (a) => V(o.href),
276
276
  onMouseenter: (a) => !f(o.href) && (a.target.style.background = "rgba(255,255,255,0.1)"),
277
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", {
278
+ }, L(o.label.trim()), 45, Le),
279
+ o.subitems && o.subitems.length > 0 ? (h(!0), m(O, { key: 0 }, Z(o.subitems, (a, n) => (h(), m("button", {
280
280
  key: `${a.href}-${n}`,
281
281
  style: z({
282
282
  width: "100%",
@@ -296,10 +296,10 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
296
296
  transition: "all 0.15s"
297
297
  }),
298
298
  title: a.label,
299
- onClick: (i) => I(a.href),
299
+ onClick: (i) => V(a.href),
300
300
  onMouseenter: (i) => !f(a.href) && (i.target.style.background = "rgba(255,255,255,0.1)"),
301
301
  onMouseleave: (i) => !f(a.href) && (i.target.style.background = "none")
302
- }, L(a.label.trim()), 45, Re))), 128)) : S("", !0)
302
+ }, L(a.label.trim()), 45, Ae))), 128)) : W("", !0)
303
303
  ], 64))), 128))
304
304
  ])
305
305
  ], 4),
@@ -308,14 +308,14 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
308
308
  style: z({ background: s.value ? "rgba(0,0,0,0.3)" : "transparent", transition: "background 0.3s" }),
309
309
  onClick: l[1] || (l[1] = (o) => s.value = !1)
310
310
  }, null, 4)
311
- ], 4)) : S("", !0),
312
- y.value ? S("", !0) : (h(), m("div", {
311
+ ], 4)) : W("", !0),
312
+ y.value ? W("", !0) : (h(), m("div", {
313
313
  key: 3,
314
314
  ref_key: "viewerRef",
315
315
  ref: r,
316
316
  class: "vfp-h-full vfp-bg-surface-toolbar",
317
317
  style: z({
318
- width: b.value ? "100%" : `${Le}px`,
318
+ width: b.value ? "100%" : `${Fe}px`,
319
319
  maxWidth: "100%",
320
320
  transition: "width 0.3s ease",
321
321
  boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
@@ -326,5 +326,5 @@ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
326
326
  }
327
327
  });
328
328
  export {
329
- qe as default
329
+ Ie as default
330
330
  };
@@ -1,31 +1,31 @@
1
- import { defineComponent as h, ref as v, onMounted as w, watch as x, onBeforeUnmount as b, openBlock as c, createBlock as E, createElementBlock as m, createElementVNode as a, toDisplayString as C, unref as D, createCommentVNode as B } from "vue";
2
- import N from "video.js";
3
- import { u as P, y } from "./index-DZZN3kYi.mjs";
4
- import { _ as R } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
- const S = {
1
+ import { defineComponent as h, ref as c, onMounted as w, watch as x, onBeforeUnmount as E, openBlock as f, createBlock as C, createElementBlock as _, createElementVNode as a, toDisplayString as j, unref as D, createCommentVNode as P } from "vue";
2
+ import B from "video.js";
3
+ import { u as N, b as R, j as y } from "./index-c-pYJEmH.mjs";
4
+ import { _ as S } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ const U = {
6
6
  key: 1,
7
7
  class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
8
- }, U = { class: "vfp-w-full vfp-h-full vfp-relative" }, V = {
8
+ }, V = { class: "vfp-w-full vfp-h-full vfp-relative" }, q = {
9
9
  key: 0,
10
10
  class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-3 vfp-backdrop-blur-sm vfp-z-10"
11
- }, j = { class: "vfp-renderer-loading-content" }, q = { class: "vfp-renderer-loading-text" }, M = /* @__PURE__ */ h({
11
+ }, L = { class: "vfp-renderer-loading-content" }, G = { class: "vfp-renderer-loading-text" }, X = /* @__PURE__ */ h({
12
12
  __name: "index",
13
13
  props: {
14
14
  url: {},
15
15
  fileName: {},
16
16
  mimeType: {}
17
17
  },
18
- setup(_, { expose: g }) {
19
- const o = _, { t } = P(), k = /* @__PURE__ */ new Set(["avi", "wmv", "flv"]), i = v(null), u = v(!0), d = v(null);
18
+ setup(g, { expose: k }) {
19
+ const o = g, { t } = N(), d = R(), T = /* @__PURE__ */ new Set(["avi", "wmv", "flv"]), i = c(null), u = c(!0), p = c(null);
20
20
  let e = null;
21
- const T = (s, r) => {
21
+ const b = (s, r) => {
22
22
  var n;
23
23
  return ((n = (r || s).split(".").pop()) == null ? void 0 : n.toLowerCase().split("?")[0]) || "";
24
24
  };
25
25
  return w(() => {
26
- if (!d.value || e) return;
27
- const s = T(o.url, o.fileName);
28
- if (k.has(s)) {
26
+ if (d.begin(o.url), !p.value || e) return;
27
+ const s = b(o.url, o.fileName);
28
+ if (T.has(s)) {
29
29
  i.value = {
30
30
  title: t.value("video.unsupported_title"),
31
31
  detail: t.value("video.unsupported_detail", { format: s.toUpperCase() })
@@ -33,13 +33,13 @@ const S = {
33
33
  return;
34
34
  }
35
35
  const r = document.createElement("video-js");
36
- r.classList.add("vjs-big-play-centered", "rfp-video-player"), d.value.appendChild(r);
37
- const p = y(o.url, o.mimeType);
36
+ r.classList.add("vjs-big-play-centered", "rfp-video-player"), p.value.appendChild(r);
37
+ const v = y(o.url, o.mimeType);
38
38
  let n;
39
- p === "video/quicktime" ? n = [
39
+ v === "video/quicktime" ? n = [
40
40
  { src: o.url, type: "video/quicktime" },
41
41
  { src: o.url, type: "video/mp4" }
42
- ] : n = [{ src: o.url, type: p }], e = N(r, {
42
+ ] : n = [{ src: o.url, type: v }], e = B(r, {
43
43
  controls: !0,
44
44
  fill: !0,
45
45
  preload: "auto",
@@ -67,8 +67,8 @@ const S = {
67
67
  },
68
68
  sources: n
69
69
  });
70
- const f = e.el().querySelector("video");
71
- f && (f.style.objectFit = "contain"), e.on("loadeddata", () => {
70
+ const m = e.el().querySelector("video");
71
+ m && (m.style.objectFit = "contain"), e.on("loadeddata", () => {
72
72
  u.value = !1;
73
73
  }), e.on("error", () => {
74
74
  const l = e == null ? void 0 : e.error();
@@ -80,32 +80,32 @@ const S = {
80
80
  } : i.value = {
81
81
  title: t.value("video.load_failed"),
82
82
  detail: (l == null ? void 0 : l.message) || t.value("common.unknown_error")
83
- }, u.value = !1;
83
+ }, u.value = !1, d.error(l ?? new Error("video load failed"), (l == null ? void 0 : l.code) === 2 ? "request" : "parse");
84
84
  });
85
85
  }), x(
86
86
  [() => o.url, () => o.mimeType],
87
87
  () => {
88
- e && !e.isDisposed() && e.src({ src: o.url, type: y(o.url, o.mimeType) });
88
+ d.begin(o.url), e && !e.isDisposed() && e.src({ src: o.url, type: y(o.url, o.mimeType) });
89
89
  }
90
- ), b(() => {
90
+ ), E(() => {
91
91
  e && !e.isDisposed() && (e.dispose(), e = null);
92
- }), g({
92
+ }), k({
93
93
  getToolbarGroups: () => []
94
- }), (s, r) => i.value ? (c(), E(R, {
94
+ }), (s, r) => i.value ? (f(), C(S, {
95
95
  key: 0,
96
96
  message: i.value.title,
97
97
  detail: i.value.detail
98
- }, null, 8, ["message", "detail"])) : (c(), m("div", S, [
99
- a("div", U, [
100
- u.value ? (c(), m("div", V, [
101
- a("div", j, [
98
+ }, null, 8, ["message", "detail"])) : (f(), _("div", U, [
99
+ a("div", V, [
100
+ u.value ? (f(), _("div", q, [
101
+ a("div", L, [
102
102
  r[0] || (r[0] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
103
- a("p", q, C(D(t)("video.loading")), 1)
103
+ a("p", G, j(D(t)("video.loading")), 1)
104
104
  ])
105
- ])) : B("", !0),
105
+ ])) : P("", !0),
106
106
  a("div", {
107
107
  ref_key: "videoContainerRef",
108
- ref: d,
108
+ ref: p,
109
109
  class: "vfp-overflow-hidden vfp-w-full vfp-h-full",
110
110
  style: { "box-shadow": "0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)" }
111
111
  }, null, 512)
@@ -114,5 +114,5 @@ const S = {
114
114
  }
115
115
  });
116
116
  export {
117
- M as default
117
+ X as default
118
118
  };
@@ -0,0 +1,157 @@
1
+ import { defineComponent as N, ref as v, onMounted as q, watch as A, onBeforeUnmount as I, computed as O, openBlock as p, createElementBlock as h, createElementVNode as E, toDisplayString as S, unref as R, createCommentVNode as b, createVNode as z, normalizeStyle as $ } from "vue";
2
+ import { u as G, a as J, b as U, s as j, J as k, V as K, p as Q } from "./index-c-pYJEmH.mjs";
3
+ import { init as D } from "pptx-preview";
4
+ import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ import { _ as Y } from "./EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs";
6
+ const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, ee = {
7
+ key: 0,
8
+ class: "vfp-renderer-overlay vfp-renderer-loading"
9
+ }, te = { class: "vfp-renderer-loading-content" }, re = { class: "vfp-renderer-loading-text" }, ie = {
10
+ key: 1,
11
+ class: "vfp-renderer-overlay"
12
+ }, le = {
13
+ key: 2,
14
+ class: "vfp-renderer-overlay"
15
+ }, de = /* @__PURE__ */ N({
16
+ __name: "index",
17
+ props: {
18
+ url: {},
19
+ tiled: { type: Boolean, default: !0 },
20
+ emptyHint: {}
21
+ },
22
+ setup(H, { expose: V }) {
23
+ const o = H, { t: s } = G(), W = J(), M = U(), n = v(!0), u = v(null), m = v(!1), w = v(0), i = v(null);
24
+ let l = null, y = null, c = null, f = null, _ = { width: 0, height: 0 }, B = 9 / 16;
25
+ const g = () => {
26
+ var d;
27
+ if (!i.value) return { width: 960, height: 540 };
28
+ const t = i.value.clientWidth, e = ((d = i.value.parentElement) == null ? void 0 : d.clientWidth) || 0, r = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(r * B);
29
+ return { width: r, height: a };
30
+ }, P = async () => {
31
+ if (!(!i.value || !c || w.value === 0))
32
+ try {
33
+ if (l)
34
+ try {
35
+ l.destroy();
36
+ } catch {
37
+ }
38
+ i.value.innerHTML = "";
39
+ const t = g();
40
+ l = D(i.value, {
41
+ width: t.width,
42
+ height: o.tiled ? t.height * w.value : t.height,
43
+ mode: o.tiled ? "list" : "slide"
44
+ }), await l.preview(c);
45
+ } catch {
46
+ }
47
+ }, C = async () => {
48
+ if (M.begin(o.url), !i.value) return;
49
+ n.value = !0, u.value = null, m.value = !1;
50
+ let t = window.setTimeout(() => {
51
+ u.value = s.value("pptx.timeout"), n.value = !1;
52
+ }, 3e4);
53
+ try {
54
+ const e = await W.value(o.url, {
55
+ mode: "cors",
56
+ credentials: "omit",
57
+ redirect: "follow"
58
+ });
59
+ if (!e.ok)
60
+ throw e.status === 404 ? new Error(s.value("pptx.not_found")) : e.status === 403 ? new k("file.forbidden") : e.status >= 500 ? new k("file.server_error") : new k("file.load_failed_status", { status: e.status });
61
+ const r = await e.arrayBuffer();
62
+ if (r.byteLength === 0) {
63
+ t !== null && clearTimeout(t), m.value = !0, n.value = !1;
64
+ return;
65
+ }
66
+ c = r, B = (await K(r)).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(r);
77
+ } catch {
78
+ throw new Error(s.value("pptx.invalid_format"));
79
+ }
80
+ const x = d.slideCount;
81
+ if (!x || x === 0) throw new Error(s.value("pptx.no_pages"));
82
+ d.destroy(), w.value = x, i.value && (i.value.innerHTML = "");
83
+ const T = g();
84
+ l = D(i.value, {
85
+ width: T.width,
86
+ height: o.tiled ? T.height * x : T.height,
87
+ mode: o.tiled ? "list" : "slide"
88
+ }), await l.preview(r), 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 r = s.value("pptx.parse_failed");
95
+ e instanceof Error ? r = Q(s.value, e) : typeof e == "string" && (r = e), u.value = r, n.value = !1, M.error(e);
96
+ }
97
+ };
98
+ q(() => {
99
+ if (!i.value) return;
100
+ let t = !0;
101
+ y = new ResizeObserver(() => {
102
+ if (t) {
103
+ t = !1, _ = g();
104
+ return;
105
+ }
106
+ const e = g(), r = Math.abs(_.width - e.width), a = Math.abs(_.height - e.height);
107
+ r < 10 && a < 10 || (_ = e, f !== null && clearTimeout(f), f = window.setTimeout(() => {
108
+ l && c && P();
109
+ }, 800));
110
+ }), y.observe(i.value), setTimeout(() => {
111
+ requestAnimationFrame(() => requestAnimationFrame(() => C()));
112
+ }, 150);
113
+ }), A(
114
+ () => o.url,
115
+ (t) => {
116
+ t && C();
117
+ }
118
+ ), I(() => {
119
+ if (y && y.disconnect(), f !== null && clearTimeout(f), c = null, w.value = 0, l)
120
+ try {
121
+ l.destroy();
122
+ } catch {
123
+ }
124
+ l = null;
125
+ });
126
+ const F = () => [], L = O(() => j(o.emptyHint, "structured"));
127
+ return V({
128
+ getToolbarGroups: F
129
+ }), (t, e) => (p(), h("div", Z, [
130
+ n.value ? (p(), h("div", ee, [
131
+ E("div", te, [
132
+ e[0] || (e[0] = E("div", { class: "vfp-renderer-spinner" }, null, -1)),
133
+ E("p", re, S(R(s)("pptx.loading")), 1)
134
+ ])
135
+ ])) : b("", !0),
136
+ m.value && !n.value && L.value ? (p(), h("div", ie, [
137
+ z(Y)
138
+ ])) : b("", !0),
139
+ u.value && !n.value ? (p(), h("div", le, [
140
+ z(X, {
141
+ message: R(s)("pptx.load_failed"),
142
+ detail: u.value
143
+ }, null, 8, ["message", "detail"])
144
+ ])) : b("", !0),
145
+ u.value ? b("", !0) : (p(), h("div", {
146
+ key: 3,
147
+ ref_key: "containerRef",
148
+ ref: i,
149
+ class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
150
+ style: $({ opacity: n.value || m.value ? 0 : 1 })
151
+ }, null, 4))
152
+ ]));
153
+ }
154
+ });
155
+ export {
156
+ de as default
157
+ };