@eternalheart/vue-file-preview 1.6.7 → 1.6.9

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 (40) hide show
  1. package/README.md +17 -3
  2. package/README.zh-CN.md +17 -3
  3. package/lib/chunks/{index-sPfLaVRe.mjs → index-BB5sxTpZ.mjs} +832 -830
  4. package/lib/chunks/index-BHpXaB9I.mjs +113 -0
  5. package/lib/chunks/index-BMpMXQVn.mjs +354 -0
  6. package/lib/chunks/{index-CR3QkKJt.mjs → index-Bcq3GaYf.mjs} +94 -91
  7. package/lib/chunks/index-Bexr8qBs.mjs +118 -0
  8. package/lib/chunks/index-BjrqA9rc.mjs +104 -0
  9. package/lib/chunks/index-Bpw-3elB.mjs +90 -0
  10. package/lib/chunks/{index-BflKoE04.mjs → index-BrlnSL9B.mjs} +33 -33
  11. package/lib/chunks/{index-DdbaVSB8.mjs → index-Bw94R-j4.mjs} +1031 -1082
  12. package/lib/chunks/index-CKb19_XL.mjs +52 -0
  13. package/lib/chunks/{index-CSY197_j.mjs → index-COgE_EN8.mjs} +98 -95
  14. package/lib/chunks/{index-BgTW_P3u.mjs → index-C_0pROOm.mjs} +174 -171
  15. package/lib/chunks/{index-CK43N0Ho.mjs → index-CsP5e8u1.mjs} +26 -26
  16. package/lib/chunks/{index-DlIRXpmw.mjs → index-D02VAnb_.mjs} +71 -68
  17. package/lib/chunks/{index--sqXkUEP.mjs → index-D5CgW1SY.mjs} +32 -32
  18. package/lib/chunks/{index-06Ivpw6V.mjs → index-D9DjYf4b.mjs} +148 -143
  19. package/lib/chunks/index-DAmkmR7C.mjs +51 -0
  20. package/lib/chunks/{index-B6UNmyiS.mjs → index-Dbt450tb.mjs} +1 -1
  21. package/lib/chunks/index-DcYqyPdh.mjs +155 -0
  22. package/lib/chunks/index-DjQ_Fllz.mjs +108 -0
  23. package/lib/chunks/{index-CBN0qoP1.mjs → index-Tm4rnJiV.mjs} +28 -28
  24. package/lib/chunks/{index-B3jcS1UB.mjs → index-aceY97Xi.mjs} +692 -689
  25. package/lib/chunks/{useShikiHighlight-J62fUszo.mjs → useShikiHighlight-DqskZVn5.mjs} +1 -1
  26. package/lib/composables/useThemeMode.d.ts +3 -0
  27. package/lib/index.cjs +50 -50
  28. package/lib/index.css +1 -1
  29. package/lib/index.mjs +1 -1
  30. package/lib/renderers/base.types.d.ts +1 -2
  31. package/package.json +1 -1
  32. package/lib/chunks/index-BWNmKHd0.mjs +0 -110
  33. package/lib/chunks/index-BmsJxBJa.mjs +0 -320
  34. package/lib/chunks/index-CXAEvuVP.mjs +0 -49
  35. package/lib/chunks/index-Cr7raBmi.mjs +0 -104
  36. package/lib/chunks/index-Cv0lIWeI.mjs +0 -105
  37. package/lib/chunks/index-CyIp8Xfg.mjs +0 -48
  38. package/lib/chunks/index-D_XKzCZJ.mjs +0 -152
  39. package/lib/chunks/index-DoqCnKkl.mjs +0 -87
  40. package/lib/chunks/index-Xta2zHnj.mjs +0 -115
@@ -1,13 +1,13 @@
1
- import { defineComponent as me, ref as p, watch as ue, onMounted as ce, onBeforeUnmount as ve, openBlock as S, createElementBlock as B, createBlock as Me, createCommentVNode as D, createElementVNode as h, normalizeStyle as W, toDisplayString as Ce, unref as K, createVNode as de, h as N } from "vue";
1
+ import { defineComponent as he, ref as p, watch as ce, onMounted as ue, onBeforeUnmount as ve, openBlock as S, createElementBlock as B, createBlock as Ce, createCommentVNode as D, createElementVNode as c, toDisplayString as de, unref as W, normalizeStyle as O, createVNode as me, h as N } from "vue";
2
2
  import { List as Se, ChevronLeft as Ne, ChevronRight as Re, Minimize2 as ze, Maximize2 as Ae, X as Le } from "lucide-vue-next";
3
3
  import "foliate-js/view.js";
4
- import { u as Fe, b as Pe, _ as $e } from "./index-DdbaVSB8.mjs";
4
+ import { u as Fe, b as Pe, _ as $e } from "./index-Bw94R-j4.mjs";
5
5
  import { _ as He } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
6
6
  import { T as Be } from "./base.types-DaftHyg7.mjs";
7
7
  const De = { 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
- class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-z-10"
10
- }, je = { 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" }, Ue = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, he = me({
9
+ class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
10
+ }, Oe = { class: "vfp-renderer-loading-content" }, Ue = { class: "vfp-renderer-loading-text" }, je = { 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" }, Ge = { class: "vfp-text-fg-primary vfp-font-medium vfp-text-sm" }, Ve = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, be = he({
11
11
  name: "MobiTocList",
12
12
  props: {
13
13
  items: { type: Array, required: !0 },
@@ -20,9 +20,9 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
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
- (l, j) => {
24
- var R, O, U;
25
- return N("li", { key: `${l.href ?? l.label}-${j}` }, [
23
+ (l, U) => {
24
+ var R, j, G;
25
+ return N("li", { key: `${l.href ?? l.label}-${U}` }, [
26
26
  l.href ? N(
27
27
  "button",
28
28
  {
@@ -38,25 +38,25 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
38
38
  ) : N(
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
- (O = l.label) == null ? void 0 : O.trim()
41
+ (j = l.label) == null ? void 0 : j.trim()
42
42
  ),
43
- (U = l.subitems) != null && U.length ? N(he, {
43
+ (G = l.subitems) != null && G.length ? N(be, {
44
44
  items: l.subitems,
45
45
  activeHref: this.activeHref,
46
46
  depth: this.depth + 1,
47
- onSelect: (G) => this.$emit("select", G)
47
+ onSelect: (V) => this.$emit("select", V)
48
48
  }) : null
49
49
  ]);
50
50
  }
51
51
  )
52
52
  );
53
53
  }
54
- }), Ge = { name: "MobiRenderer" }, Ve = /* @__PURE__ */ me({
55
- ...Ge,
54
+ }), Xe = { name: "MobiRenderer" }, qe = /* @__PURE__ */ he({
55
+ ...Xe,
56
56
  props: {
57
57
  url: {}
58
58
  },
59
- setup(l, { expose: j }) {
59
+ setup(l, { expose: U }) {
60
60
  const R = `
61
61
  @namespace epub "http://www.idpf.org/2007/ops";
62
62
  html { color-scheme: light; }
@@ -79,15 +79,15 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
79
79
  img { max-width: 100% !important; height: auto !important; }
80
80
  a { color: #2563eb; text-decoration: none; }
81
81
  pre { white-space: pre-wrap !important; }
82
- `, G = async (o) => {
83
- var c;
84
- const t = (c = o.next) == null ? void 0 : c.call(o);
82
+ `, V = async (o) => {
83
+ var d;
84
+ const t = (d = o.next) == null ? void 0 : d.call(o);
85
85
  if (!t) return;
86
86
  let a;
87
87
  try {
88
88
  await Promise.race([
89
89
  t,
90
- new Promise((q, L) => {
90
+ new Promise((Z, L) => {
91
91
  a = window.setTimeout(
92
92
  () => L(new Error("MOBI initial render timed out")),
93
93
  1e4
@@ -97,39 +97,39 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
97
97
  } finally {
98
98
  a !== void 0 && window.clearTimeout(a);
99
99
  }
100
- }, z = l, Q = new Be(), { t: d } = Fe(), be = Pe(), V = p(null);
101
- let e = null, X = 1;
102
- const b = p(1), _ = p(1), k = p(!1), g = p(null), x = p([]), n = p(!1), T = p(""), u = p(!1);
103
- ue([b, _, u, n, k, () => x.value.length], () => {
100
+ }, z = l, Q = new Be(), { t: u } = Fe(), ge = Pe(), X = p(null);
101
+ let e = null, q = 1;
102
+ const b = p(1), w = p(1), k = p(!1), g = p(null), x = p([]), n = p(!1), T = p(""), v = p(!1);
103
+ ce([b, w, v, n, k, () => x.value.length], () => {
104
104
  Q.notify();
105
105
  });
106
106
  const A = (o, t) => {
107
- Number.isFinite(t) && t > 0 && (X = t);
107
+ Number.isFinite(t) && t > 0 && (q = t);
108
108
  const a = Number.isFinite(o) ? o : 0;
109
- b.value = Math.max(1, a + 1), _.value = X;
110
- }, ge = () => {
109
+ b.value = Math.max(1, a + 1), w.value = q;
110
+ }, xe = () => {
111
111
  e == null || e.prev().catch(() => {
112
112
  });
113
- }, xe = () => {
113
+ }, ye = () => {
114
114
  e == null || e.next().catch(() => {
115
115
  });
116
- }, ye = () => {
116
+ }, _e = () => {
117
117
  n.value = !n.value;
118
118
  }, we = () => {
119
- u.value = !u.value, e != null && e.renderer && e.renderer.setAttribute("max-inline-size", u.value ? "9999" : "720");
120
- }, _e = (o) => {
119
+ v.value = !v.value, e != null && e.renderer && e.renderer.setAttribute("max-inline-size", v.value ? "9999" : "720");
120
+ }, ke = (o) => {
121
121
  T.value = o, n.value = !1, e == null || e.goTo(o).catch(() => {
122
122
  });
123
123
  };
124
- j({
124
+ U({
125
125
  getToolbarGroups: () => [
126
126
  {
127
127
  items: [
128
128
  {
129
129
  type: "button",
130
130
  icon: Se,
131
- tooltip: d.value("toolbar.toc"),
132
- action: ye,
131
+ tooltip: u.value("toolbar.toc"),
132
+ action: _e,
133
133
  disabled: x.value.length === 0,
134
134
  active: n.value
135
135
  }
@@ -140,21 +140,21 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
140
140
  {
141
141
  type: "button",
142
142
  icon: Ne,
143
- tooltip: d.value("toolbar.prev_page"),
144
- action: ge,
143
+ tooltip: u.value("toolbar.prev_page"),
144
+ action: xe,
145
145
  disabled: b.value <= 1
146
146
  },
147
147
  {
148
148
  type: "text",
149
- content: `${b.value} / ${_.value}`,
149
+ content: `${b.value} / ${w.value}`,
150
150
  minWidth: "4rem"
151
151
  },
152
152
  {
153
153
  type: "button",
154
154
  icon: Re,
155
- tooltip: d.value("toolbar.next_page"),
156
- action: xe,
157
- disabled: b.value >= _.value
155
+ tooltip: u.value("toolbar.next_page"),
156
+ action: ye,
157
+ disabled: b.value >= w.value
158
158
  }
159
159
  ]
160
160
  },
@@ -162,10 +162,10 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
162
162
  items: [
163
163
  {
164
164
  type: "button",
165
- icon: u.value ? ze : Ae,
166
- tooltip: u.value ? d.value("toolbar.normal_width") : d.value("toolbar.full_width"),
165
+ icon: v.value ? ze : Ae,
166
+ tooltip: v.value ? u.value("toolbar.normal_width") : u.value("toolbar.full_width"),
167
167
  action: we,
168
- active: u.value
168
+ active: v.value
169
169
  }
170
170
  ]
171
171
  }
@@ -176,12 +176,12 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
176
176
  var t;
177
177
  (t = o.filename) != null && t.includes("paginator") && o.preventDefault();
178
178
  };
179
- ce(() => window.addEventListener("error", Y)), ve(() => window.removeEventListener("error", Y));
179
+ ue(() => window.addEventListener("error", Y)), ve(() => window.removeEventListener("error", Y));
180
180
  const I = async () => {
181
- var c, q, L;
182
- const o = V.value;
181
+ var d, Z, L;
182
+ const o = X.value;
183
183
  if (!o) return;
184
- k.value = !0, g.value = null, x.value = [], n.value = !1, T.value = "", X = 1, b.value = 1, _.value = 1, o.replaceChildren(), e = null;
184
+ k.value = !0, g.value = null, x.value = [], n.value = !1, T.value = "", q = 1, b.value = 1, w.value = 1, o.replaceChildren(), e = null;
185
185
  let t = !1;
186
186
  const a = /* @__PURE__ */ new Map();
187
187
  try {
@@ -193,68 +193,68 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
193
193
  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;
194
194
  if (r && typeof r.page == "number" && Number.isFinite(r.page) && typeof r.pages == "number" && Number.isFinite(r.pages) && r.pages > 2 && F >= 0) {
195
195
  t = !0;
196
- const m = r.pages - 2;
197
- a.set(F, m);
196
+ const h = r.pages - 2;
197
+ a.set(F, h);
198
198
  let y = 0;
199
- for (let w = 0; w < F; w++)
200
- y += a.get(w) ?? 0;
201
- const E = y + Math.min(m, Math.max(1, r.page)), M = (i.fraction ?? 0) >= 0.999;
199
+ for (let _ = 0; _ < F; _++)
200
+ y += a.get(_) ?? 0;
201
+ const E = y + Math.min(h, Math.max(1, r.page)), M = (i.fraction ?? 0) >= 0.999;
202
202
  let $;
203
203
  if (oe === 1)
204
- $ = m;
204
+ $ = h;
205
205
  else if (M)
206
206
  $ = E;
207
207
  else {
208
- const w = ((ne = e == null ? void 0 : e.book) == null ? void 0 : ne.sections) ?? [], pe = ((ie = w[F]) == null ? void 0 : ie.size) ?? 0, Te = pe > 0 ? m / pe : 0;
209
- let J = 0;
208
+ const _ = ((ne = e == null ? void 0 : e.book) == null ? void 0 : ne.sections) ?? [], pe = ((ie = _[F]) == null ? void 0 : ie.size) ?? 0, Ee = pe > 0 ? h / pe : 0;
209
+ let K = 0;
210
210
  for (let C = 0; C < oe; C++)
211
211
  if (a.has(C))
212
- J += a.get(C);
212
+ K += a.get(C);
213
213
  else {
214
- const Ee = ((se = w[C]) == null ? void 0 : se.size) ?? 0;
215
- J += Math.max(1, Math.round(Ee * Te));
214
+ const Me = ((se = _[C]) == null ? void 0 : se.size) ?? 0;
215
+ K += Math.max(1, Math.round(Me * Ee));
216
216
  }
217
- $ = Math.max(E, J);
217
+ $ = Math.max(E, K);
218
218
  }
219
219
  A(E - 1, $);
220
220
  const H = i.tocItem;
221
221
  H != null && H.href && (T.value = H.href);
222
222
  return;
223
223
  }
224
- const v = i.location;
225
- if (v && typeof v.current == "number" && Number.isFinite(v.current) && typeof v.total == "number" && Number.isFinite(v.total)) {
224
+ const m = i.location;
225
+ if (m && typeof m.current == "number" && Number.isFinite(m.current) && typeof m.total == "number" && Number.isFinite(m.total)) {
226
226
  t = !0;
227
- const y = (i.fraction ?? 0) >= 0.999 ? v.current + 1 : v.total;
228
- A(v.current, y);
227
+ const y = (i.fraction ?? 0) >= 0.999 ? m.current + 1 : m.total;
228
+ A(m.current, y);
229
229
  } else {
230
- const m = ((fe = e == null ? void 0 : e.book) == null ? void 0 : fe.sections) ?? [], y = i.index ?? 0, E = i.fraction ?? 0, M = Math.max(m.length, 1);
230
+ const h = ((fe = e == null ? void 0 : e.book) == null ? void 0 : fe.sections) ?? [], y = i.index ?? 0, E = i.fraction ?? 0, M = Math.max(h.length, 1);
231
231
  A(Math.round((y + E) / M * M), M);
232
232
  }
233
233
  const P = i.tocItem;
234
234
  P != null && P.href && (T.value = P.href);
235
235
  });
236
- const Z = await be.value(z.url);
237
- if (!Z.ok) throw new Error(`请求失败: ${Z.status}`);
238
- const ke = await Z.blob();
236
+ const J = await ge.value(z.url);
237
+ if (!J.ok) throw new Error(`请求失败: ${J.status}`);
238
+ const Te = await J.blob();
239
239
  let ee = "book.mobi";
240
240
  try {
241
241
  const i = new URL(z.url, window.location.href).pathname.split("/").pop();
242
242
  i && (ee = decodeURIComponent(i));
243
243
  } catch {
244
244
  }
245
- await s.open(new File([ke], ee));
245
+ await s.open(new File([Te], ee));
246
246
  const f = s.renderer;
247
- f && (f.setAttribute("animated", ""), f.setAttribute("max-inline-size", "720"), f.setAttribute("margin", "48"), f.setAttribute("gap", "5%"), await G(f), (c = f.setStyles) == null || c.call(f, R)), x.value = ((q = s.book) == null ? void 0 : q.toc) ?? [], k.value = !1, t || A(0, ((L = s.book) == null ? void 0 : L.sections.length) ?? 1);
247
+ f && (f.setAttribute("animated", ""), f.setAttribute("max-inline-size", "720"), f.setAttribute("margin", "48"), f.setAttribute("gap", "5%"), await V(f), (d = f.setStyles) == null || d.call(f, R)), x.value = ((Z = s.book) == null ? void 0 : Z.toc) ?? [], k.value = !1, t || A(0, ((L = s.book) == null ? void 0 : L.sections.length) ?? 1);
248
248
  } catch (s) {
249
- console.error("MOBI/AZW3 加载错误:", s), g.value = d.value("mobi.load_failed"), k.value = !1;
249
+ console.error("MOBI/AZW3 加载错误:", s), g.value = u.value("mobi.load_failed"), k.value = !1;
250
250
  }
251
251
  };
252
- return ce(() => {
252
+ return ue(() => {
253
253
  z.url && I();
254
- }), ue(() => z.url, (o, t) => {
254
+ }), ce(() => z.url, (o, t) => {
255
255
  o && o !== t && I();
256
256
  }), ve(() => {
257
- var o, t, a, c;
257
+ var o, t, a, d;
258
258
  try {
259
259
  (o = e == null ? void 0 : e.close) == null || o.call(e);
260
260
  } catch {
@@ -263,58 +263,61 @@ const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-cen
263
263
  (a = (t = e == null ? void 0 : e.book) == null ? void 0 : t.destroy) == null || a.call(t);
264
264
  } catch {
265
265
  }
266
- e = null, (c = V.value) == null || c.replaceChildren();
266
+ e = null, (d = X.value) == null || d.replaceChildren();
267
267
  }), (o, t) => (S(), B("div", De, [
268
- g.value ? (S(), Me(He, {
268
+ g.value ? (S(), Ce(He, {
269
269
  key: 0,
270
270
  message: g.value,
271
271
  class: "vfp-absolute vfp-inset-0"
272
272
  }, null, 8, ["message"])) : D("", !0),
273
- k.value && !g.value ? (S(), B("div", We, [...t[2] || (t[2] = [
274
- h("div", { class: "vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)
275
- ])])) : D("", !0),
273
+ k.value && !g.value ? (S(), B("div", We, [
274
+ c("div", Oe, [
275
+ t[2] || (t[2] = c("div", { class: "vfp-renderer-spinner" }, null, -1)),
276
+ c("span", Ue, de(W(u)("common.loading")), 1)
277
+ ])
278
+ ])) : D("", !0),
276
279
  x.value.length > 0 ? (S(), B("div", {
277
280
  key: 2,
278
281
  class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex vfp-transition-opacity vfp-duration-300",
279
- style: W({ opacity: n.value ? 1 : 0, pointerEvents: n.value ? "auto" : "none" })
282
+ style: O({ opacity: n.value ? 1 : 0, pointerEvents: n.value ? "auto" : "none" })
280
283
  }, [
281
- h("div", {
284
+ c("div", {
282
285
  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",
283
- style: W({ transform: n.value ? "translateX(0)" : "translateX(-100%)" })
286
+ style: O({ transform: n.value ? "translateX(0)" : "translateX(-100%)" })
284
287
  }, [
285
- h("div", je, [
286
- h("span", Oe, Ce(K(d)("toolbar.toc")), 1),
287
- h("button", {
288
+ c("div", je, [
289
+ c("span", Ge, de(W(u)("toolbar.toc")), 1),
290
+ c("button", {
288
291
  class: "toc-close-btn",
289
292
  onClick: t[0] || (t[0] = (a) => n.value = !1)
290
293
  }, [
291
- de(K(Le), { class: "vfp-w-4 vfp-h-4" })
294
+ me(W(Le), { class: "vfp-w-4 vfp-h-4" })
292
295
  ])
293
296
  ]),
294
- h("div", Ue, [
295
- de(K(he), {
297
+ c("div", Ve, [
298
+ me(W(be), {
296
299
  items: x.value,
297
300
  "active-href": T.value,
298
- onSelect: _e
301
+ onSelect: ke
299
302
  }, null, 8, ["items", "active-href"])
300
303
  ])
301
304
  ], 4),
302
- h("div", {
305
+ c("div", {
303
306
  class: "vfp-flex-1 vfp-transition-opacity vfp-duration-300",
304
- style: W({ background: n.value ? "rgba(0,0,0,0.3)" : "transparent" }),
307
+ style: O({ background: n.value ? "rgba(0,0,0,0.3)" : "transparent" }),
305
308
  onClick: t[1] || (t[1] = (a) => n.value = !1)
306
309
  }, null, 4)
307
310
  ], 4)) : D("", !0),
308
311
  g.value ? D("", !0) : (S(), B("div", {
309
312
  key: 3,
310
313
  ref_key: "hostRef",
311
- ref: V,
314
+ ref: X,
312
315
  class: "vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg",
313
- style: W({ width: u.value ? "100%" : "794px", maxWidth: "100%", transition: "width 0.3s ease" })
316
+ style: O({ width: v.value ? "100%" : "794px", maxWidth: "100%", transition: "width 0.3s ease" })
314
317
  }, null, 4))
315
318
  ]));
316
319
  }
317
- }), Ie = /* @__PURE__ */ $e(Ve, [["__scopeId", "data-v-0302202a"]]);
320
+ }), tt = /* @__PURE__ */ $e(qe, [["__scopeId", "data-v-b3d35d2b"]]);
318
321
  export {
319
- Ie as default
322
+ tt as default
320
323
  };
@@ -0,0 +1,118 @@
1
+ import { defineComponent as $, ref as g, watch as G, computed as y, openBlock as a, createElementBlock as r, createElementVNode as e, toDisplayString as o, unref as n, createBlock as S, normalizeClass as b, Fragment as h, renderList as k, createCommentVNode as T } from "vue";
2
+ import { u as V, b as z, M as A, $ as d, e as D, _ as I } from "./index-Bw94R-j4.mjs";
3
+ import { _ as O } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
4
+ const R = {
5
+ key: 0,
6
+ class: "vfp-renderer-loading vfp-bg-[#0f0f12]"
7
+ }, X = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, j = { class: "content-scroll" }, q = { class: "timeline" }, H = { class: "cues" }, J = { class: "cue-meta" }, K = { class: "cue-time" }, P = { class: "cue-time" }, Q = { class: "cue-id" }, U = {
8
+ key: 0,
9
+ class: "cue-style"
10
+ }, W = {
11
+ key: 0,
12
+ class: "cue-words"
13
+ }, Z = ["title"], ee = { class: "cue-word-time" }, se = { class: "cue-word-text" }, te = { class: "status-pill" }, le = /* @__PURE__ */ $({
14
+ __name: "index",
15
+ props: {
16
+ url: {},
17
+ fileName: {}
18
+ },
19
+ setup(B, { expose: C }) {
20
+ const v = B, { t: i } = V(), F = z(), p = g(""), f = g(!0), u = g(null), N = {
21
+ srt: "srt",
22
+ vtt: "vtt",
23
+ lrc: "lrc",
24
+ elrc: "elrc",
25
+ ass: "ass",
26
+ ssa: "ssa",
27
+ ttml: "ttml",
28
+ dfxp: "ttml"
29
+ }, E = (t) => {
30
+ var l;
31
+ const s = ((l = t.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
32
+ return N[s];
33
+ };
34
+ G(() => v.url, async () => {
35
+ f.value = !0, u.value = null;
36
+ try {
37
+ p.value = await D(v.url, { fetcher: F.value });
38
+ } catch (t) {
39
+ console.error(t), u.value = i.value("subtitle.load_failed");
40
+ } finally {
41
+ f.value = !1;
42
+ }
43
+ }, { immediate: !0 });
44
+ const c = y(() => {
45
+ if (!p.value) return null;
46
+ try {
47
+ return A(p.value, E(v.fileName));
48
+ } catch (t) {
49
+ return console.error(t), null;
50
+ }
51
+ }), m = y(() => {
52
+ var t, s;
53
+ return ((t = c.value) == null ? void 0 : t.format) === "lrc" || ((s = c.value) == null ? void 0 : s.format) === "elrc";
54
+ }), x = y(() => {
55
+ var t;
56
+ return ((t = c.value) == null ? void 0 : t.metadata) ?? {};
57
+ }), L = (t) => d(t).slice(3, 8);
58
+ return C({
59
+ getToolbarGroups: () => []
60
+ }), (t, s) => f.value ? (a(), r("div", R, [
61
+ e("div", X, [
62
+ s[0] || (s[0] = e("div", { class: "vfp-renderer-spinner" }, null, -1)),
63
+ e("span", Y, o(n(i)("common.loading")), 1)
64
+ ])
65
+ ])) : u.value || !c.value ? (a(), S(O, {
66
+ key: 1,
67
+ message: u.value || n(i)("subtitle.parse_failed"),
68
+ class: "vfp-bg-[#0f0f12]"
69
+ }, null, 8, ["message"])) : (a(), r("div", {
70
+ key: 2,
71
+ class: b(["vfp-relative vfp-w-full vfp-h-full vfp-bg-[#0f0f12]", m.value ? "flavor-lyric" : "flavor-subtitle"])
72
+ }, [
73
+ e("div", j, [
74
+ e("div", q, [
75
+ s[3] || (s[3] = e("div", { class: "timeline-line" }, null, -1)),
76
+ e("ol", H, [
77
+ (a(!0), r(h, null, k(c.value.cues, (l, w) => (a(), r("li", {
78
+ key: "cue-" + w,
79
+ class: "cue-row"
80
+ }, [
81
+ s[2] || (s[2] = e("div", { class: "cue-dot" }, null, -1)),
82
+ e("div", J, [
83
+ e("span", K, o(n(d)(l.start)), 1),
84
+ s[1] || (s[1] = e("span", { class: "cue-arrow" }, "→", -1)),
85
+ e("span", P, o(n(d)(l.end)), 1),
86
+ e("span", Q, "#" + o(l.id ?? w + 1), 1),
87
+ l.style ? (a(), r("span", U, o(l.style), 1)) : T("", !0)
88
+ ]),
89
+ l.words && l.words.length > 0 ? (a(), r("div", W, [
90
+ (a(!0), r(h, null, k(l.words, (_, M) => (a(), r("span", {
91
+ key: "w-" + M,
92
+ class: "cue-word",
93
+ title: n(d)(_.start)
94
+ }, [
95
+ e("span", ee, o(L(_.start)), 1),
96
+ e("span", se, o(_.text), 1)
97
+ ], 8, Z))), 128))
98
+ ])) : (a(), r("p", {
99
+ key: 1,
100
+ class: b(["cue-text", { lyric: m.value }])
101
+ }, o(l.text), 3))
102
+ ]))), 128))
103
+ ])
104
+ ])
105
+ ]),
106
+ e("div", te, [
107
+ e("span", null, o(c.value.cues.length) + " " + o(m.value ? n(i)("subtitle.lines") : n(i)("subtitle.cues")), 1),
108
+ x.value.length ? (a(), r(h, { key: 0 }, [
109
+ s[4] || (s[4] = e("span", { class: "dot" }, "·", -1)),
110
+ e("span", null, o(x.value.length), 1)
111
+ ], 64)) : T("", !0)
112
+ ])
113
+ ], 2));
114
+ }
115
+ }), ie = /* @__PURE__ */ I(le, [["__scopeId", "data-v-e2b8685e"]]);
116
+ export {
117
+ ie as default
118
+ };
@@ -0,0 +1,104 @@
1
+ import { defineComponent as k, ref as h, onMounted as D, watch as z, onBeforeUnmount as M, openBlock as v, createElementBlock as p, createElementVNode as m, toDisplayString as S, unref as C, createCommentVNode as w, createBlock as N, normalizeStyle as B } from "vue";
2
+ import { S as H } from "./index-CyBXARuf.mjs";
3
+ import { u as O, b as R, e as W, d as G, O as V, l as E } from "./index-Bw94R-j4.mjs";
4
+ import { _ as F } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
5
+ const L = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, q = {
6
+ key: 0,
7
+ class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
8
+ }, A = { class: "vfp-renderer-loading-content" }, I = { class: "vfp-renderer-loading-text vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, P = /* @__PURE__ */ k({
9
+ __name: "index",
10
+ props: {
11
+ url: {},
12
+ fileName: {}
13
+ },
14
+ setup(x, { expose: y }) {
15
+ const i = x, { t: g } = O(), T = R(), n = h(!0), r = h(null), l = h(null);
16
+ let a = null, u = null, o = null, f = { width: 0, height: 0 };
17
+ const d = () => {
18
+ if (!l.value) return { width: 800, height: 600 };
19
+ const t = l.value.clientWidth, e = l.value.clientHeight, s = t > 100 ? t : 800, c = e > 100 ? e : 600;
20
+ return { width: s, height: c };
21
+ }, b = () => {
22
+ if (!l.value || !a) return;
23
+ l.value.innerHTML = "";
24
+ const { width: t, height: e } = d(), s = t < 640;
25
+ new H(l.value, {
26
+ mode: "read",
27
+ showToolbar: !1,
28
+ showContextmenu: !1,
29
+ showGrid: !0,
30
+ row: {
31
+ len: 100,
32
+ height: 25
33
+ },
34
+ col: {
35
+ len: 26,
36
+ width: s ? 80 : 100,
37
+ indexWidth: s ? 40 : 60,
38
+ minWidth: s ? 40 : 60
39
+ },
40
+ view: {
41
+ height: () => e,
42
+ width: () => t
43
+ }
44
+ }).loadData(a);
45
+ }, _ = async () => {
46
+ if (l.value) {
47
+ n.value = !0, r.value = null;
48
+ try {
49
+ const t = await W(i.url, { fetcher: T.value }), e = G(t, { delimiter: V(i.fileName) });
50
+ a = E(e.header, e.rows, i.fileName), b(), n.value = !1;
51
+ } catch (t) {
52
+ console.error("CSV 解析错误:", t), r.value = g.value("csv.load_failed"), n.value = !1;
53
+ }
54
+ }
55
+ };
56
+ return D(() => {
57
+ if (!l.value) return;
58
+ let t = !0;
59
+ u = new ResizeObserver(() => {
60
+ if (t) {
61
+ t = !1, f = d();
62
+ return;
63
+ }
64
+ const e = d(), s = Math.abs(f.width - e.width), c = Math.abs(f.height - e.height);
65
+ s < 10 && c < 10 || (f = e, o !== null && clearTimeout(o), o = window.setTimeout(() => {
66
+ a && b();
67
+ }, 500));
68
+ }), u.observe(l.value), setTimeout(() => {
69
+ requestAnimationFrame(() => _());
70
+ }, 100);
71
+ }), z(
72
+ () => i.url,
73
+ () => {
74
+ _();
75
+ }
76
+ ), M(() => {
77
+ u && u.disconnect(), o !== null && clearTimeout(o), a = null, l.value && (l.value.innerHTML = "");
78
+ }), y({
79
+ getToolbarGroups: () => []
80
+ }), (t, e) => (v(), p("div", L, [
81
+ n.value ? (v(), p("div", q, [
82
+ m("div", A, [
83
+ e[0] || (e[0] = m("div", { class: "vfp-renderer-spinner" }, null, -1)),
84
+ m("p", I, S(C(g)("csv.loading")), 1)
85
+ ])
86
+ ])) : w("", !0),
87
+ r.value && !n.value ? (v(), N(F, {
88
+ key: 1,
89
+ message: r.value,
90
+ class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
91
+ }, null, 8, ["message"])) : w("", !0),
92
+ r.value ? w("", !0) : (v(), p("div", {
93
+ key: 2,
94
+ ref_key: "containerRef",
95
+ ref: l,
96
+ class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
97
+ style: B({ opacity: n.value ? 0 : 1 })
98
+ }, null, 4))
99
+ ]));
100
+ }
101
+ });
102
+ export {
103
+ P as default
104
+ };