@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
@@ -0,0 +1,137 @@
1
+ import { defineComponent as W, ref as g, onMounted as z, watch as L, onBeforeUnmount as B, openBlock as d, createElementBlock as h, createElementVNode as _, toDisplayString as H, unref as T, createCommentVNode as y, createVNode as F, normalizeStyle as R } from "vue";
2
+ import { u as A, a as C, b as G, J as v, L as N, E as U, U as V, z as J, t as O, F as q, p as I } from "./index-DBzyeU0G.mjs";
3
+ import P from "exceljs";
4
+ import { S as X } from "./index-CyBXARuf.mjs";
5
+ import { _ as $ } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ const j = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, K = {
7
+ key: 0,
8
+ class: "vfp-renderer-overlay vfp-renderer-loading"
9
+ }, Q = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
10
+ key: 1,
11
+ class: "vfp-renderer-overlay"
12
+ }, oe = /* @__PURE__ */ W({
13
+ __name: "index",
14
+ props: {
15
+ url: {},
16
+ emptyHint: {}
17
+ },
18
+ setup(E, { expose: D }) {
19
+ async function M(e) {
20
+ try {
21
+ return await new P.Workbook().xlsx.load(e.slice().buffer);
22
+ } catch (t) {
23
+ throw t instanceof TypeError && /sheets/i.test(t.message) ? new v("xlsx.invalid_format") : t;
24
+ }
25
+ }
26
+ const p = E, { t: a } = A(), S = C(), m = G(), o = g(!0), n = g(null), l = g(null);
27
+ let i = null, w = 100, f = null, u = null, c = { width: 0, height: 0 };
28
+ const x = () => {
29
+ if (!l.value) return { width: 800, height: 600 };
30
+ const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
31
+ return { width: r, height: s };
32
+ }, b = () => {
33
+ if (!l.value || !i) return;
34
+ l.value.innerHTML = "";
35
+ const { width: e, height: t } = x(), r = e < 640;
36
+ new X(l.value, {
37
+ mode: "read",
38
+ showToolbar: !1,
39
+ showContextmenu: !1,
40
+ showGrid: !0,
41
+ row: {
42
+ len: w,
43
+ height: 25
44
+ },
45
+ col: {
46
+ len: 26,
47
+ width: r ? 80 : 100,
48
+ indexWidth: r ? 40 : 60,
49
+ minWidth: r ? 40 : 60
50
+ },
51
+ view: {
52
+ height: () => t,
53
+ width: () => e
54
+ }
55
+ }).loadData(i);
56
+ }, k = async () => {
57
+ if (m.begin(p.url), !!l.value) {
58
+ o.value = !0, n.value = null;
59
+ try {
60
+ const e = await S.value(p.url, {
61
+ mode: "cors",
62
+ credentials: "omit",
63
+ redirect: "follow"
64
+ });
65
+ if (!e.ok)
66
+ throw e.status === 404 ? new Error(a.value("xlsx.not_found")) : e.status === 403 ? new v("file.forbidden") : new v("file.load_failed_status", { status: e.status });
67
+ const t = N(await e.arrayBuffer());
68
+ let r;
69
+ if (t.byteLength === 0)
70
+ r = [{ name: "Sheet1" }];
71
+ else if (U(t)) {
72
+ const s = V(t);
73
+ if (!s || !Array.isArray(s.sheets))
74
+ throw new v("xlsx.invalid_legacy_data");
75
+ r = J(s);
76
+ } else
77
+ r = O(
78
+ await M(t)
79
+ );
80
+ i = r.length ? r : [{ name: "Sheet1" }], w = q(r), b(), o.value = !1, m.ready();
81
+ } catch (e) {
82
+ console.error(a.value("xlsx.parse_failed") + ":", e);
83
+ let t = a.value("xlsx.parse_failed");
84
+ e instanceof Error && (t = I(a.value, e)), n.value = t, o.value = !1, m.error(e);
85
+ }
86
+ }
87
+ };
88
+ return z(() => {
89
+ if (!l.value) return;
90
+ let e = !0;
91
+ f = new ResizeObserver(() => {
92
+ if (e) {
93
+ e = !1, c = x();
94
+ return;
95
+ }
96
+ const t = x(), 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 && b();
99
+ }, 500));
100
+ }), f.observe(l.value), setTimeout(() => {
101
+ requestAnimationFrame(() => k());
102
+ }, 100);
103
+ }), L(
104
+ () => p.url,
105
+ (e) => {
106
+ e && k();
107
+ }
108
+ ), B(() => {
109
+ f && f.disconnect(), u !== null && clearTimeout(u), i = null, w = 100, l.value && (l.value.innerHTML = "");
110
+ }), D({
111
+ getToolbarGroups: () => []
112
+ }), (e, t) => (d(), h("div", j, [
113
+ o.value ? (d(), h("div", K, [
114
+ _("div", Q, [
115
+ t[0] || (t[0] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
116
+ _("p", Y, H(T(a)("xlsx.loading")), 1)
117
+ ])
118
+ ])) : y("", !0),
119
+ n.value && !o.value ? (d(), h("div", Z, [
120
+ F($, {
121
+ message: T(a)("xlsx.load_failed"),
122
+ detail: n.value
123
+ }, null, 8, ["message", "detail"])
124
+ ])) : y("", !0),
125
+ n.value ? y("", !0) : (d(), h("div", {
126
+ key: 2,
127
+ ref_key: "containerRef",
128
+ ref: l,
129
+ class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
130
+ style: R({ opacity: o.value ? 0 : 1 })
131
+ }, null, 4))
132
+ ]));
133
+ }
134
+ });
135
+ export {
136
+ oe as default
137
+ };
@@ -1,13 +1,13 @@
1
- import { defineComponent as be, ref as c, watch as ce, onMounted as ue, onBeforeUnmount as ve, openBlock as S, createElementBlock as D, createBlock as Se, createCommentVNode as W, createElementVNode as u, toDisplayString as de, unref as B, normalizeStyle as U, createVNode as me, h as N } from "vue";
2
- import { u as Ne, c as Re, k as he, _ as ze } from "./index-DZZN3kYi.mjs";
3
- import { List as Ae, ChevronLeft as Le, ChevronRight as Fe, Minimize2 as Pe, Maximize2 as He, X as $e } from "lucide-vue-next";
1
+ import { defineComponent as ge, ref as u, watch as ce, onMounted as ve, onBeforeUnmount as de, openBlock as N, createElementBlock as D, createBlock as Ne, createCommentVNode as W, createElementVNode as c, toDisplayString as me, unref as B, normalizeStyle as U, createVNode as be, h as R } from "vue";
2
+ import { u as Re, a as ze, b as Ae, J as he, d as Le } from "./index-DBzyeU0G.mjs";
3
+ import { List as Pe, ChevronLeft as Fe, ChevronRight as He, Minimize2 as $e, Maximize2 as De, X as We } from "lucide-vue-next";
4
4
  import "foliate-js/view.js";
5
- import { _ as De } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
- import { T as We } from "./base.types-DaftHyg7.mjs";
7
- const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, Ue = {
5
+ import { _ as Be } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ import { T as Ue } from "./base.types-DaftHyg7.mjs";
7
+ const je = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, qe = {
8
8
  key: 1,
9
9
  class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
10
- }, je = { class: "vfp-renderer-loading-content" }, qe = { class: "vfp-renderer-loading-text" }, Ge = { class: "vfp-flex vfp-items-center vfp-justify-between vfp-px-4 vfp-py-3 vfp-border-b vfp-border-line-weak vfp-flex-shrink-0" }, Ve = { class: "vfp-text-fg-primary vfp-font-medium vfp-text-sm" }, Xe = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, ge = be({
10
+ }, Ge = { class: "vfp-renderer-loading-content" }, Ve = { class: "vfp-renderer-loading-text" }, Xe = { class: "vfp-flex vfp-items-center vfp-justify-between vfp-px-4 vfp-py-3 vfp-border-b vfp-border-line-weak vfp-flex-shrink-0" }, Oe = { class: "vfp-text-fg-primary vfp-font-medium vfp-text-sm" }, Je = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, xe = ge({
11
11
  name: "MobiTocList",
12
12
  props: {
13
13
  items: { type: Array, required: !0 },
@@ -16,14 +16,14 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
16
16
  },
17
17
  emits: ["select"],
18
18
  render() {
19
- return N(
19
+ return R(
20
20
  "ul",
21
21
  { style: { listStyle: "none", padding: 0, margin: this.depth > 0 ? "0 0 0 16px" : 0 } },
22
22
  this.items.map(
23
23
  (l, j) => {
24
- var R, q, G;
25
- return N("li", { key: `${l.href ?? l.label}-${j}` }, [
26
- l.href ? N(
24
+ var z, q, G;
25
+ return R("li", { key: `${l.href ?? l.label}-${j}` }, [
26
+ l.href ? R(
27
27
  "button",
28
28
  {
29
29
  onClick: () => this.$emit("select", l.href),
@@ -34,13 +34,13 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
34
34
  title: l.label,
35
35
  style: "background: none; border: none; cursor: pointer"
36
36
  },
37
- (R = l.label) == null ? void 0 : R.trim()
38
- ) : N(
37
+ (z = l.label) == null ? void 0 : z.trim()
38
+ ) : R(
39
39
  "div",
40
40
  { class: "vfp-w-full vfp-py-2 vfp-px-3 vfp-text-sm vfp-text-fg-tertiary vfp-truncate" },
41
41
  (q = l.label) == null ? void 0 : q.trim()
42
42
  ),
43
- (G = l.subitems) != null && G.length ? N(ge, {
43
+ (G = l.subitems) != null && G.length ? R(xe, {
44
44
  items: l.subitems,
45
45
  activeHref: this.activeHref,
46
46
  depth: this.depth + 1,
@@ -51,13 +51,13 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
51
51
  )
52
52
  );
53
53
  }
54
- }), Oe = { name: "MobiRenderer" }, Je = /* @__PURE__ */ be({
55
- ...Oe,
54
+ }), Ke = { name: "MobiRenderer" }, Qe = /* @__PURE__ */ ge({
55
+ ...Ke,
56
56
  props: {
57
57
  url: {}
58
58
  },
59
59
  setup(l, { expose: j }) {
60
- const R = `
60
+ const z = `
61
61
  @namespace epub "http://www.idpf.org/2007/ops";
62
62
  :root {
63
63
  --theme-bg-color: #ffffff;
@@ -91,7 +91,7 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
91
91
  try {
92
92
  await Promise.race([
93
93
  t,
94
- new Promise((J, L) => {
94
+ new Promise((K, L) => {
95
95
  a = window.setTimeout(
96
96
  () => L(new he("mobi.timeout")),
97
97
  1e4
@@ -101,28 +101,28 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
101
101
  } finally {
102
102
  a !== void 0 && window.clearTimeout(a);
103
103
  }
104
- }, z = l, Y = new We(), { t: s } = Ne(), xe = Re(), X = c(null);
105
- let e = null, O = 1;
106
- const b = c(1), k = c(1), g = c(!0), x = c(null), y = c([]), n = c(!1), T = c(""), v = c(!1);
107
- ce([b, k, v, n, g, () => y.value.length], () => {
108
- Y.notify();
104
+ }, k = l, Z = new Ue(), { t: f } = Re(), ye = ze(), X = Ae(), O = u(null);
105
+ let e = null, J = 1;
106
+ const h = u(1), T = u(1), g = u(!0), x = u(null), y = u([]), n = u(!1), E = u(""), v = u(!1);
107
+ ce([h, T, v, n, g, () => y.value.length], () => {
108
+ Z.notify();
109
109
  });
110
110
  const A = (o, t) => {
111
- Number.isFinite(t) && t > 0 && (O = t);
111
+ Number.isFinite(t) && t > 0 && (J = t);
112
112
  const a = Number.isFinite(o) ? o : 0;
113
- b.value = Math.max(1, a + 1), k.value = O;
114
- }, ye = () => {
113
+ h.value = Math.max(1, a + 1), T.value = J;
114
+ }, _e = () => {
115
115
  e == null || e.prev().catch(() => {
116
116
  });
117
- }, _e = () => {
117
+ }, we = () => {
118
118
  e == null || e.next().catch(() => {
119
119
  });
120
- }, we = () => {
121
- n.value = !n.value;
122
120
  }, ke = () => {
121
+ n.value = !n.value;
122
+ }, Te = () => {
123
123
  v.value = !v.value, e != null && e.renderer && e.renderer.setAttribute("max-inline-size", v.value ? "9999" : "720");
124
- }, Te = (o) => {
125
- T.value = o, n.value = !1, e == null || e.goTo(o).catch(() => {
124
+ }, Ee = (o) => {
125
+ E.value = o, n.value = !1, e == null || e.goTo(o).catch(() => {
126
126
  });
127
127
  };
128
128
  j({
@@ -131,9 +131,9 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
131
131
  items: [
132
132
  {
133
133
  type: "button",
134
- icon: Ae,
135
- tooltip: s.value("toolbar.toc"),
136
- action: we,
134
+ icon: Pe,
135
+ tooltip: f.value("toolbar.toc"),
136
+ action: ke,
137
137
  disabled: y.value.length === 0,
138
138
  active: n.value
139
139
  }
@@ -143,22 +143,22 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
143
143
  items: [
144
144
  {
145
145
  type: "button",
146
- icon: Le,
147
- tooltip: s.value("toolbar.prev_page"),
148
- action: ye,
149
- disabled: b.value <= 1
146
+ icon: Fe,
147
+ tooltip: f.value("toolbar.prev_page"),
148
+ action: _e,
149
+ disabled: h.value <= 1
150
150
  },
151
151
  {
152
152
  type: "text",
153
- content: `${b.value} / ${k.value}`,
153
+ content: `${h.value} / ${T.value}`,
154
154
  minWidth: "4rem"
155
155
  },
156
156
  {
157
157
  type: "button",
158
- icon: Fe,
159
- tooltip: s.value("toolbar.next_page"),
160
- action: _e,
161
- disabled: b.value >= k.value
158
+ icon: He,
159
+ tooltip: f.value("toolbar.next_page"),
160
+ action: we,
161
+ disabled: h.value >= T.value
162
162
  }
163
163
  ]
164
164
  },
@@ -166,63 +166,64 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
166
166
  items: [
167
167
  {
168
168
  type: "button",
169
- icon: v.value ? Pe : He,
170
- tooltip: v.value ? s.value("toolbar.normal_width") : s.value("toolbar.full_width"),
171
- action: ke,
169
+ icon: v.value ? $e : De,
170
+ tooltip: v.value ? f.value("toolbar.normal_width") : f.value("toolbar.full_width"),
171
+ action: Te,
172
172
  active: v.value
173
173
  }
174
174
  ]
175
175
  }
176
176
  ],
177
- onToolbarChange: (o) => Y.subscribe(o)
177
+ onToolbarChange: (o) => Z.subscribe(o)
178
178
  });
179
- const Z = (o) => {
179
+ const I = (o) => {
180
180
  var t;
181
181
  (t = o.filename) != null && t.includes("paginator") && o.preventDefault();
182
182
  };
183
- ue(() => window.addEventListener("error", Z)), ve(() => window.removeEventListener("error", Z));
184
- const I = async () => {
185
- var d, J, L;
186
- const o = X.value;
183
+ ve(() => window.addEventListener("error", I)), de(() => window.removeEventListener("error", I));
184
+ const ee = async () => {
185
+ var d, K, L;
186
+ X.begin(k.url);
187
+ const o = O.value;
187
188
  if (!o) return;
188
- g.value = !0, x.value = null, y.value = [], n.value = !1, T.value = "", O = 1, b.value = 1, k.value = 1, o.replaceChildren(), e = null;
189
+ g.value = !0, x.value = null, y.value = [], n.value = !1, E.value = "", J = 1, h.value = 1, T.value = 1, o.replaceChildren(), e = null;
189
190
  let t = !1;
190
191
  const a = /* @__PURE__ */ new Map();
191
192
  try {
192
- const f = document.createElement("foliate-view");
193
- o.appendChild(f), e = f, f.addEventListener("relocate", (te) => {
194
- var ae, re, le, ne, ie, se, fe;
195
- const i = te.detail;
193
+ const s = document.createElement("foliate-view");
194
+ o.appendChild(s), e = s, s.addEventListener("relocate", (oe) => {
195
+ var re, le, ne, ie, se, fe, pe;
196
+ const i = oe.detail;
196
197
  if (!i) return;
197
- const oe = ((ae = e == null ? void 0 : e.book) == null ? void 0 : ae.sections.length) ?? 0, r = e == null ? void 0 : e.renderer, F = ((le = (re = r == null ? void 0 : r.getContents) == null ? void 0 : re.call(r)[0]) == null ? void 0 : le.index) ?? -1;
198
- if (r && typeof r.page == "number" && Number.isFinite(r.page) && typeof r.pages == "number" && Number.isFinite(r.pages) && r.pages > 2 && F >= 0) {
198
+ const ae = ((re = e == null ? void 0 : e.book) == null ? void 0 : re.sections.length) ?? 0, r = e == null ? void 0 : e.renderer, P = ((ne = (le = r == null ? void 0 : r.getContents) == null ? void 0 : le.call(r)[0]) == null ? void 0 : ne.index) ?? -1;
199
+ if (r && typeof r.page == "number" && Number.isFinite(r.page) && typeof r.pages == "number" && Number.isFinite(r.pages) && r.pages > 2 && P >= 0) {
199
200
  t = !0;
200
- const h = r.pages - 2;
201
- a.set(F, h);
201
+ const b = r.pages - 2;
202
+ a.set(P, b);
202
203
  let _ = 0;
203
- for (let w = 0; w < F; w++)
204
+ for (let w = 0; w < P; w++)
204
205
  _ += a.get(w) ?? 0;
205
- const C = _ + Math.min(h, Math.max(1, r.page)), E = (i.fraction ?? 0) >= 0.999;
206
+ const C = _ + Math.min(b, Math.max(1, r.page)), M = (i.fraction ?? 0) >= 0.999;
206
207
  let H;
207
- if (oe === 1)
208
- H = h;
209
- else if (E)
208
+ if (ae === 1)
209
+ H = b;
210
+ else if (M)
210
211
  H = C;
211
212
  else {
212
- const w = ((ne = e == null ? void 0 : e.book) == null ? void 0 : ne.sections) ?? [], pe = ((ie = w[F]) == null ? void 0 : ie.size) ?? 0, Ee = pe > 0 ? h / pe : 0;
213
- let Q = 0;
214
- for (let M = 0; M < oe; M++)
215
- if (a.has(M))
216
- Q += a.get(M);
213
+ const w = ((ie = e == null ? void 0 : e.book) == null ? void 0 : ie.sections) ?? [], ue = ((se = w[P]) == null ? void 0 : se.size) ?? 0, Me = ue > 0 ? b / ue : 0;
214
+ let Y = 0;
215
+ for (let S = 0; S < ae; S++)
216
+ if (a.has(S))
217
+ Y += a.get(S);
217
218
  else {
218
- const Me = ((se = w[M]) == null ? void 0 : se.size) ?? 0;
219
- Q += Math.max(1, Math.round(Me * Ee));
219
+ const Se = ((fe = w[S]) == null ? void 0 : fe.size) ?? 0;
220
+ Y += Math.max(1, Math.round(Se * Me));
220
221
  }
221
- H = Math.max(C, Q);
222
+ H = Math.max(C, Y);
222
223
  }
223
224
  A(C - 1, H);
224
225
  const $ = i.tocItem;
225
- $ != null && $.href && (T.value = $.href);
226
+ $ != null && $.href && (E.value = $.href);
226
227
  return;
227
228
  }
228
229
  const m = i.location;
@@ -231,33 +232,33 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
231
232
  const _ = (i.fraction ?? 0) >= 0.999 ? m.current + 1 : m.total;
232
233
  A(m.current, _);
233
234
  } else {
234
- const h = ((fe = e == null ? void 0 : e.book) == null ? void 0 : fe.sections) ?? [], _ = i.index ?? 0, C = i.fraction ?? 0, E = Math.max(h.length, 1);
235
- A(Math.round((_ + C) / E * E), E);
235
+ const b = ((pe = e == null ? void 0 : e.book) == null ? void 0 : pe.sections) ?? [], _ = i.index ?? 0, C = i.fraction ?? 0, M = Math.max(b.length, 1);
236
+ A(Math.round((_ + C) / M * M), M);
236
237
  }
237
- const P = i.tocItem;
238
- P != null && P.href && (T.value = P.href);
238
+ const F = i.tocItem;
239
+ F != null && F.href && (E.value = F.href);
239
240
  });
240
- const K = await xe.value(z.url);
241
- if (!K.ok) throw new he("request.failed", { status: K.status });
242
- const Ce = await K.blob();
243
- let ee = "book.mobi";
241
+ const Q = await ye.value(k.url);
242
+ if (!Q.ok) throw new he("request.failed", { status: Q.status });
243
+ const Ce = await Q.blob();
244
+ let te = "book.mobi";
244
245
  try {
245
- const i = new URL(z.url, window.location.href).pathname.split("/").pop();
246
- i && (ee = decodeURIComponent(i));
246
+ const i = new URL(k.url, window.location.href).pathname.split("/").pop();
247
+ i && (te = decodeURIComponent(i));
247
248
  } catch {
248
249
  }
249
- await f.open(new File([Ce], ee));
250
- const p = f.renderer;
251
- p && (p.setAttribute("animated", ""), p.setAttribute("max-inline-size", "720"), p.setAttribute("margin", "48"), p.setAttribute("gap", "5%"), await V(p), (d = p.setStyles) == null || d.call(p, R)), y.value = ((J = f.book) == null ? void 0 : J.toc) ?? [], g.value = !1, t || A(0, ((L = f.book) == null ? void 0 : L.sections.length) ?? 1);
252
- } catch (f) {
253
- console.error(s.value("mobi.load_failed") + ":", f), x.value = s.value("mobi.load_failed"), g.value = !1;
250
+ await s.open(new File([Ce], te));
251
+ const p = s.renderer;
252
+ p && (p.setAttribute("animated", ""), p.setAttribute("max-inline-size", "720"), p.setAttribute("margin", "48"), p.setAttribute("gap", "5%"), await V(p), (d = p.setStyles) == null || d.call(p, z)), y.value = ((K = s.book) == null ? void 0 : K.toc) ?? [], g.value = !1, X.ready(), t || A(0, ((L = s.book) == null ? void 0 : L.sections.length) ?? 1);
253
+ } catch (s) {
254
+ console.error(f.value("mobi.load_failed") + ":", s), x.value = f.value("mobi.load_failed"), g.value = !1, X.error(s);
254
255
  }
255
256
  };
256
- return ue(() => {
257
- z.url && I();
258
- }), ce(() => z.url, (o, t) => {
259
- o && o !== t && I();
260
- }), ve(() => {
257
+ return ve(() => {
258
+ k.url && ee();
259
+ }), ce(() => k.url, (o, t) => {
260
+ o && o !== t && ee();
261
+ }), de(() => {
261
262
  var o, t, a, d;
262
263
  try {
263
264
  (o = e == null ? void 0 : e.close) == null || o.call(e);
@@ -267,55 +268,55 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
267
268
  (a = (t = e == null ? void 0 : e.book) == null ? void 0 : t.destroy) == null || a.call(t);
268
269
  } catch {
269
270
  }
270
- e = null, (d = X.value) == null || d.replaceChildren();
271
- }), (o, t) => (S(), D("div", Be, [
272
- x.value ? (S(), Se(De, {
271
+ e = null, (d = O.value) == null || d.replaceChildren();
272
+ }), (o, t) => (N(), D("div", je, [
273
+ x.value ? (N(), Ne(Be, {
273
274
  key: 0,
274
275
  message: x.value,
275
276
  class: "vfp-absolute vfp-inset-0"
276
277
  }, null, 8, ["message"])) : W("", !0),
277
- g.value && !x.value ? (S(), D("div", Ue, [
278
- u("div", je, [
279
- t[2] || (t[2] = u("div", { class: "vfp-renderer-spinner" }, null, -1)),
280
- u("span", qe, de(B(s)("common.loading")), 1)
278
+ g.value && !x.value ? (N(), D("div", qe, [
279
+ c("div", Ge, [
280
+ t[2] || (t[2] = c("div", { class: "vfp-renderer-spinner" }, null, -1)),
281
+ c("span", Ve, me(B(f)("common.loading")), 1)
281
282
  ])
282
283
  ])) : W("", !0),
283
- y.value.length > 0 ? (S(), D("div", {
284
+ y.value.length > 0 ? (N(), D("div", {
284
285
  key: 2,
285
286
  class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex vfp-transition-opacity vfp-duration-300",
286
287
  style: U({ opacity: n.value ? 1 : 0, pointerEvents: n.value ? "auto" : "none" })
287
288
  }, [
288
- u("div", {
289
+ c("div", {
289
290
  class: "vfp-w-72 vfp-max-w-[80%] vfp-h-full vfp-bg-surface-overlay vfp-backdrop-blur-xl vfp-border-r vfp-border-line-weak vfp-flex vfp-flex-col vfp-shadow-2xl vfp-transition-transform vfp-duration-300",
290
291
  style: U({ transform: n.value ? "translateX(0)" : "translateX(-100%)" })
291
292
  }, [
292
- u("div", Ge, [
293
- u("span", Ve, de(B(s)("toolbar.toc")), 1),
294
- u("button", {
293
+ c("div", Xe, [
294
+ c("span", Oe, me(B(f)("toolbar.toc")), 1),
295
+ c("button", {
295
296
  class: "toc-close-btn",
296
297
  onClick: t[0] || (t[0] = (a) => n.value = !1)
297
298
  }, [
298
- me(B($e), { class: "vfp-w-4 vfp-h-4" })
299
+ be(B(We), { class: "vfp-w-4 vfp-h-4" })
299
300
  ])
300
301
  ]),
301
- u("div", Xe, [
302
- me(B(ge), {
302
+ c("div", Je, [
303
+ be(B(xe), {
303
304
  items: y.value,
304
- "active-href": T.value,
305
- onSelect: Te
305
+ "active-href": E.value,
306
+ onSelect: Ee
306
307
  }, null, 8, ["items", "active-href"])
307
308
  ])
308
309
  ], 4),
309
- u("div", {
310
+ c("div", {
310
311
  class: "vfp-flex-1 vfp-transition-opacity vfp-duration-300",
311
312
  style: U({ background: n.value ? "rgba(0,0,0,0.3)" : "transparent" }),
312
313
  onClick: t[1] || (t[1] = (a) => n.value = !1)
313
314
  }, null, 4)
314
315
  ], 4)) : W("", !0),
315
- x.value ? W("", !0) : (S(), D("div", {
316
+ x.value ? W("", !0) : (N(), D("div", {
316
317
  key: 3,
317
318
  ref_key: "hostRef",
318
- ref: X,
319
+ ref: O,
319
320
  class: "vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg",
320
321
  style: U({
321
322
  width: v.value ? "100%" : "794px",
@@ -327,7 +328,7 @@ const Be = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
327
328
  }, null, 4))
328
329
  ]));
329
330
  }
330
- }), ot = /* @__PURE__ */ ze(Je, [["__scopeId", "data-v-b68e7c2a"]]);
331
+ }), rt = /* @__PURE__ */ Le(Qe, [["__scopeId", "data-v-8eb76047"]]);
331
332
  export {
332
- ot as default
333
+ rt as default
333
334
  };
@@ -0,0 +1,51 @@
1
+ import { defineComponent as m, ref as p, watch as g, openBlock as u, createElementBlock as c, createElementVNode as o, toDisplayString as h, unref as y, createBlock as w } from "vue";
2
+ import { u as k, a as x, b, J as T, s as B } from "./index-DBzyeU0G.mjs";
3
+ import { _ as E } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
4
+ const G = {
5
+ key: 0,
6
+ class: "vfp-renderer-loading"
7
+ }, H = { class: "vfp-renderer-loading-content" }, L = { class: "vfp-renderer-loading-text" }, M = {
8
+ key: 2,
9
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-6 vfp-px-4"
10
+ }, P = ["innerHTML"], N = /* @__PURE__ */ m({
11
+ __name: "index",
12
+ props: {
13
+ url: {}
14
+ },
15
+ setup(f, { expose: v }) {
16
+ const s = f, { t } = k(), d = x(), l = b(), n = p(""), i = p(!0), r = p(null), _ = async () => {
17
+ l.begin(s.url), i.value = !0, r.value = null, n.value = "";
18
+ try {
19
+ const e = await d.value(s.url);
20
+ if (!e.ok) throw new T("file.load_failed");
21
+ const a = await e.arrayBuffer();
22
+ n.value = await B(a), l.ready();
23
+ } catch (e) {
24
+ console.error(t.value("ppt.parse_failed") + ":", e), r.value = t.value("ppt.parse_failed"), l.error(e);
25
+ } finally {
26
+ i.value = !1;
27
+ }
28
+ };
29
+ return g(() => s.url, (e) => {
30
+ e && _();
31
+ }, { immediate: !0 }), v({
32
+ getToolbarGroups: () => []
33
+ }), (e, a) => i.value ? (u(), c("div", G, [
34
+ o("div", H, [
35
+ a[0] || (a[0] = o("div", { class: "vfp-renderer-spinner" }, null, -1)),
36
+ o("span", L, h(y(t)("common.loading")), 1)
37
+ ])
38
+ ])) : r.value ? (u(), w(E, {
39
+ key: 1,
40
+ message: r.value
41
+ }, null, 8, ["message"])) : (u(), c("div", M, [
42
+ o("div", {
43
+ class: "vfp-legacy-ppt-wrap",
44
+ innerHTML: n.value
45
+ }, null, 8, P)
46
+ ]));
47
+ }
48
+ });
49
+ export {
50
+ N as default
51
+ };