@eternalheart/vue-file-preview 1.6.9 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/lib/chunks/{avifLoader-BP3fgcMm-BnpxLhxp.mjs → avifLoader-CAUzjn-d-Bv80osgL.mjs} +18 -17
- package/lib/chunks/heicLoader-D_9PukkA-c40agcEu.mjs +37 -0
- package/lib/chunks/index--D2MwF_x.mjs +52 -0
- package/lib/chunks/index-2xdBoG-I.mjs +141 -0
- package/lib/chunks/index-B2xLxhp0.mjs +133 -0
- package/lib/chunks/{index-Bexr8qBs.mjs → index-B35jLxPz.mjs} +25 -25
- package/lib/chunks/index-B3uQ1OoT.mjs +5414 -0
- package/lib/chunks/{index-BjrqA9rc.mjs → index-BkqPtbFz.mjs} +31 -31
- package/lib/chunks/{index-D5CgW1SY.mjs → index-BpKvjFVp.mjs} +17 -16
- package/lib/chunks/{index-Bpw-3elB.mjs → index-By8q8XPn.mjs} +2 -2
- package/lib/chunks/{index-aceY97Xi.mjs → index-C8pOqpTq.mjs} +1706 -1713
- package/lib/chunks/index-C92b547K.mjs +356 -0
- package/lib/chunks/index-CO713RPO.mjs +383 -0
- package/lib/chunks/{index-C_0pROOm.mjs → index-CrLeFRdr.mjs} +203 -203
- package/lib/chunks/{index-DcYqyPdh.mjs → index-Cyg4lWK-.mjs} +17 -17
- package/lib/chunks/index-DKJ_iQ70.mjs +295 -0
- package/lib/chunks/{index-D02VAnb_.mjs → index-DMwZXKa4.mjs} +59 -59
- package/lib/chunks/index-DTZVumT8.mjs +51 -0
- package/lib/chunks/index-DbOpSm8f.mjs +108 -0
- package/lib/chunks/{index-BB5sxTpZ.mjs → index-Df-1MbYj.mjs} +2505 -2504
- package/lib/chunks/{index-Dbt450tb.mjs → index-DfC_cA90.mjs} +18 -18
- package/lib/chunks/{index-COgE_EN8.mjs → index-DpY9eMSI.mjs} +40 -40
- package/lib/chunks/{index-Bcq3GaYf.mjs → index-Dw6YZA28.mjs} +121 -111
- package/lib/chunks/{index-BHpXaB9I.mjs → index-DyP3rhuf.mjs} +13 -13
- package/lib/chunks/jp2Loader-Dig19xyo-82PXw2fC.mjs +122 -0
- package/lib/chunks/psdLoader-C0tKUXXl-DRn7RYLA.mjs +79 -0
- package/lib/chunks/rawLoader-C-tPeFAB-DP397Cnq.mjs +82 -0
- package/lib/chunks/tiffLoader-BlhByX8w-BC52z4Tf.mjs +60 -0
- package/lib/chunks/{useShikiHighlight-DqskZVn5.mjs → useShikiHighlight-DSyCygls.mjs} +5 -5
- package/lib/components/ResizableSplit.vue.d.ts +0 -2
- package/lib/composables/useTranslator.d.ts +3 -2
- package/lib/index.cjs +70 -64
- package/lib/index.css +1 -1
- package/lib/index.mjs +9 -9
- package/lib/renderers/Cad/index.vue.d.ts +1 -0
- package/lib/renderers/Video/index.vue.d.ts +1 -0
- package/package.json +2 -2
- package/lib/chunks/heicLoader-CH_raQNn-1fBLaICM.mjs +0 -36
- package/lib/chunks/index-BMpMXQVn.mjs +0 -354
- package/lib/chunks/index-BrlnSL9B.mjs +0 -141
- package/lib/chunks/index-Bw94R-j4.mjs +0 -5175
- package/lib/chunks/index-CKb19_XL.mjs +0 -52
- package/lib/chunks/index-CsP5e8u1.mjs +0 -116
- package/lib/chunks/index-D9DjYf4b.mjs +0 -383
- package/lib/chunks/index-DAmkmR7C.mjs +0 -51
- package/lib/chunks/index-DjQ_Fllz.mjs +0 -108
- package/lib/chunks/index-Tm4rnJiV.mjs +0 -270
- package/lib/chunks/jp2Loader-ldvCSsvm-ldvCSsvm.mjs +0 -121
- package/lib/chunks/psdLoader-D5CkupyY-DMppLen1.mjs +0 -78
- package/lib/chunks/rawLoader-0mLvxCNp-CJmERiK7.mjs +0 -81
- package/lib/chunks/tiffLoader-CmUAD1vO-DABms0J3.mjs +0 -59
package/README.md
CHANGED
|
@@ -374,7 +374,7 @@ Differences from `FilePreviewModal`:
|
|
|
374
374
|
| `currentIndex` | `number` | ✅ | Current file index |
|
|
375
375
|
| `isOpen` | `boolean` | ✅ | Whether the modal is open |
|
|
376
376
|
| `customRenderers` | `CustomRenderer[]` | ❌ | Custom renderers for specific file types |
|
|
377
|
-
| `locale` | `Locale` | ❌ | UI language (`'
|
|
377
|
+
| `locale` | `Locale` | ❌ | UI language (`'en-US'` default, `'zh-CN'` built-in) |
|
|
378
378
|
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | Custom translation overrides |
|
|
379
379
|
| `headless` | `boolean` | ❌ | Headless mode — hides toolbar and navigation arrows |
|
|
380
380
|
| `theme` | `Theme` | ❌ | Theme mode: `'auto' \| 'dark' \| 'light'` (default `'dark'`) |
|
|
@@ -399,7 +399,7 @@ Differences from `FilePreviewModal`:
|
|
|
399
399
|
| `customRenderers` | `CustomRenderer[]` | ❌ | - | Custom renderers |
|
|
400
400
|
| `width` | `number \| string` | ❌ | `'100%'` | Container width |
|
|
401
401
|
| `height` | `number \| string` | ❌ | `'100%'` | Container height |
|
|
402
|
-
| `locale` | `Locale` | ❌ | `'
|
|
402
|
+
| `locale` | `Locale` | ❌ | `'en-US'` | UI language (`'zh-CN'` or `'en-US'`) |
|
|
403
403
|
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | - | Custom translation overrides |
|
|
404
404
|
| `headless` | `boolean` | ❌ | `false` | Headless mode — hides toolbar and navigation arrows |
|
|
405
405
|
| `theme` | `Theme` | ❌ | `'dark'` | Theme mode: `'auto' \| 'dark' \| 'light'` |
|
package/README.zh-CN.md
CHANGED
|
@@ -374,7 +374,7 @@ const files = [
|
|
|
374
374
|
| `currentIndex` | `number` | ✅ | 当前文件索引 |
|
|
375
375
|
| `isOpen` | `boolean` | ✅ | 是否打开预览 |
|
|
376
376
|
| `customRenderers` | `CustomRenderer[]` | ❌ | 自定义渲染器 |
|
|
377
|
-
| `locale` | `Locale` | ❌ | 界面语言(默认 `'
|
|
377
|
+
| `locale` | `Locale` | ❌ | 界面语言(默认 `'en-US'`,内置 `'zh-CN'`) |
|
|
378
378
|
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | 自定义翻译覆盖 |
|
|
379
379
|
| `headless` | `boolean` | ❌ | 无头模式,隐藏工具栏和导航箭头 |
|
|
380
380
|
| `theme` | `Theme` | ❌ | 主题模式: `'auto' \| 'dark' \| 'light'`(默认 `'dark'`) |
|
|
@@ -399,7 +399,7 @@ const files = [
|
|
|
399
399
|
| `customRenderers` | `CustomRenderer[]` | ❌ | - | 自定义渲染器 |
|
|
400
400
|
| `width` | `number \| string` | ❌ | `'100%'` | 容器宽度 |
|
|
401
401
|
| `height` | `number \| string` | ❌ | `'100%'` | 容器高度 |
|
|
402
|
-
| `locale` | `Locale` | ❌ | `'
|
|
402
|
+
| `locale` | `Locale` | ❌ | `'en-US'` | 界面语言(`'zh-CN'` 或 `'en-US'`) |
|
|
403
403
|
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | - | 自定义翻译覆盖 |
|
|
404
404
|
| `headless` | `boolean` | ❌ | `false` | 无头模式,隐藏工具栏和导航箭头 |
|
|
405
405
|
| `theme` | `Theme` | ❌ | `'dark'` | 主题模式: `'auto' \| 'dark' \| 'light'` |
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { k as t } from "./index-B3uQ1OoT.mjs";
|
|
1
2
|
let a = null;
|
|
2
3
|
async function B() {
|
|
3
|
-
return a !== null ? a : new Promise((
|
|
4
|
+
return a !== null ? a : new Promise((o) => {
|
|
4
5
|
const A = new Image();
|
|
5
6
|
A.onload = () => {
|
|
6
|
-
a = A.width === 1 && A.height === 1,
|
|
7
|
+
a = A.width === 1 && A.height === 1, o(a);
|
|
7
8
|
}, A.onerror = () => {
|
|
8
|
-
a = !1,
|
|
9
|
+
a = !1, o(!1);
|
|
9
10
|
}, A.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=";
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
|
-
class
|
|
13
|
+
class s {
|
|
13
14
|
/**
|
|
14
15
|
* 检测是否需要解码:仅在浏览器不原生支持 AVIF 时需要
|
|
15
16
|
*/
|
|
@@ -23,21 +24,21 @@ class d {
|
|
|
23
24
|
if (await B())
|
|
24
25
|
return A instanceof Blob ? A : new Blob([A], { type: "image/avif" });
|
|
25
26
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
throw new
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
|
|
27
|
+
const n = await import("@jsquash/avif"), l = A instanceof Blob ? await A.arrayBuffer() : A, i = await n.decode(l), e = document.createElement("canvas");
|
|
28
|
+
e.width = i.width, e.height = i.height;
|
|
29
|
+
const c = e.getContext("2d");
|
|
30
|
+
if (!c)
|
|
31
|
+
throw new t("image.canvas_context_failed");
|
|
32
|
+
return c.putImageData(i, 0, 0), new Promise((m, g) => {
|
|
33
|
+
e.toBlob(
|
|
34
|
+
(d) => {
|
|
35
|
+
d ? m(d) : g(new t("image.canvas_export_failed", { format: "AVIF", output: "PNG" }));
|
|
35
36
|
},
|
|
36
37
|
(r == null ? void 0 : r.outputFormat) || "image/png"
|
|
37
38
|
);
|
|
38
39
|
});
|
|
39
|
-
} catch (
|
|
40
|
-
throw new
|
|
40
|
+
} catch (n) {
|
|
41
|
+
throw new t("image.avif_decode_failed", void 0, n || new t("common.unknown_error"));
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
@@ -49,7 +50,7 @@ class d {
|
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const f = new s();
|
|
53
54
|
export {
|
|
54
|
-
|
|
55
|
+
f as default
|
|
55
56
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { k as o } from "./index-B3uQ1OoT.mjs";
|
|
2
|
+
class l {
|
|
3
|
+
/**
|
|
4
|
+
* HEIC 格式浏览器均不原生支持,始终需要解码
|
|
5
|
+
*/
|
|
6
|
+
async needsDecode(e) {
|
|
7
|
+
return e === "image/heic" || e === "image/heif";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 解码 HEIC 文件为 JPEG Blob
|
|
11
|
+
*/
|
|
12
|
+
async decode(e, i) {
|
|
13
|
+
var t, r;
|
|
14
|
+
try {
|
|
15
|
+
const a = await import("heic2any"), c = e instanceof Blob ? e : new Blob([e], { type: "image/heic" }), n = await a.default({
|
|
16
|
+
blob: c,
|
|
17
|
+
toType: (i == null ? void 0 : i.outputFormat) || "image/jpeg",
|
|
18
|
+
quality: 0.9
|
|
19
|
+
});
|
|
20
|
+
return Array.isArray(n) ? n[0] : n;
|
|
21
|
+
} catch (a) {
|
|
22
|
+
throw (t = a == null ? void 0 : a.message) != null && t.includes("DRM") || (r = a == null ? void 0 : a.message) != null && r.includes("protected") ? new o("image.heic_drm") : new o("image.heic_decode_failed", void 0, a || new o("common.unknown_error"));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 获取 HEIC 元数据(当前版本暂不实现,返回空对象)
|
|
27
|
+
*/
|
|
28
|
+
async getMetadata(e) {
|
|
29
|
+
return {
|
|
30
|
+
format: "heic"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const u = new l();
|
|
35
|
+
export {
|
|
36
|
+
u as default
|
|
37
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineComponent as _, ref as n, watch as m, openBlock as c, createElementBlock as f, createElementVNode as o, toDisplayString as h, unref as g, createBlock as y } from "vue";
|
|
2
|
+
import { u as x, b as k, k as w, E as T } from "./index-B3uQ1OoT.mjs";
|
|
3
|
+
import { _ as b } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
4
|
+
const B = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "vfp-renderer-loading"
|
|
7
|
+
}, E = { class: "vfp-renderer-loading-content" }, D = { class: "vfp-renderer-loading-text" }, G = {
|
|
8
|
+
key: 2,
|
|
9
|
+
class: "vfp-docx-container vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-6 vfp-px-4"
|
|
10
|
+
}, H = { class: "vfp-flex vfp-flex-col vfp-items-center" }, L = { class: "vfp-legacy-doc-paper" }, M = ["innerHTML"], V = /* @__PURE__ */ _({
|
|
11
|
+
__name: "index",
|
|
12
|
+
props: {
|
|
13
|
+
url: {}
|
|
14
|
+
},
|
|
15
|
+
setup(u, { expose: d }) {
|
|
16
|
+
const i = u, { t: l } = x(), p = k(), r = n(""), t = n(!0), s = n(null), v = async () => {
|
|
17
|
+
t.value = !0, s.value = null, r.value = "";
|
|
18
|
+
try {
|
|
19
|
+
const e = await p.value(i.url);
|
|
20
|
+
if (!e.ok) throw new w("file.load_failed");
|
|
21
|
+
const a = await e.arrayBuffer();
|
|
22
|
+
r.value = await T(a);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(l.value("doc.parse_failed") + ":", e), s.value = l.value("doc.parse_failed");
|
|
25
|
+
} finally {
|
|
26
|
+
t.value = !1;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return m(() => i.url, (e) => {
|
|
30
|
+
e && v();
|
|
31
|
+
}, { immediate: !0 }), d({
|
|
32
|
+
getToolbarGroups: () => []
|
|
33
|
+
}), (e, a) => t.value ? (c(), f("div", B, [
|
|
34
|
+
o("div", E, [
|
|
35
|
+
a[0] || (a[0] = o("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
36
|
+
o("span", D, h(g(l)("common.loading")), 1)
|
|
37
|
+
])
|
|
38
|
+
])) : s.value ? (c(), y(b, {
|
|
39
|
+
key: 1,
|
|
40
|
+
message: s.value
|
|
41
|
+
}, null, 8, ["message"])) : (c(), f("div", G, [
|
|
42
|
+
o("div", H, [
|
|
43
|
+
o("div", L, [
|
|
44
|
+
o("div", { innerHTML: r.value }, null, 8, M)
|
|
45
|
+
])
|
|
46
|
+
])
|
|
47
|
+
]));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
V as default
|
|
52
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { defineComponent as F, ref as y, onMounted as L, watch as P, onBeforeUnmount as q, openBlock as g, createElementBlock as _, createElementVNode as T, toDisplayString as A, unref as M, createCommentVNode as k, createBlock as G, normalizeStyle as H } from "vue";
|
|
2
|
+
import { u as I, b as N, k as x, e as O, Z as S } from "./index-B3uQ1OoT.mjs";
|
|
3
|
+
import { init as B } from "pptx-preview";
|
|
4
|
+
import { _ as V } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
5
|
+
const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, U = {
|
|
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
|
+
}, $ = { class: "vfp-renderer-loading-content" }, j = { class: "vfp-renderer-loading-text vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, ee = /* @__PURE__ */ F({
|
|
9
|
+
__name: "index",
|
|
10
|
+
props: {
|
|
11
|
+
url: {},
|
|
12
|
+
tiled: { type: Boolean, default: !0 }
|
|
13
|
+
},
|
|
14
|
+
setup(z, { expose: C }) {
|
|
15
|
+
const s = z, { t: o } = I(), R = N(), a = y(!0), u = y(null), p = y(0), r = y(null);
|
|
16
|
+
let l = null, v = null, d = null, c = null, h = { width: 0, height: 0 }, D = 9 / 16;
|
|
17
|
+
const m = () => {
|
|
18
|
+
var f;
|
|
19
|
+
if (!r.value) return { width: 960, height: 540 };
|
|
20
|
+
const t = r.value.clientWidth, e = ((f = r.value.parentElement) == null ? void 0 : f.clientWidth) || 0, i = t > 100 ? t : e > 100 ? e : 300, n = Math.floor(i * D);
|
|
21
|
+
return { width: i, height: n };
|
|
22
|
+
}, W = async () => {
|
|
23
|
+
if (!(!r.value || !d || p.value === 0))
|
|
24
|
+
try {
|
|
25
|
+
if (l)
|
|
26
|
+
try {
|
|
27
|
+
l.destroy();
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
r.value.innerHTML = "";
|
|
31
|
+
const t = m();
|
|
32
|
+
l = B(r.value, {
|
|
33
|
+
width: t.width,
|
|
34
|
+
height: s.tiled ? t.height * p.value : t.height,
|
|
35
|
+
mode: s.tiled ? "list" : "slide"
|
|
36
|
+
}), await l.preview(d);
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}, E = async () => {
|
|
40
|
+
if (!r.value) return;
|
|
41
|
+
a.value = !0, u.value = null;
|
|
42
|
+
let t = window.setTimeout(() => {
|
|
43
|
+
u.value = o.value("pptx.timeout"), a.value = !1;
|
|
44
|
+
}, 3e4);
|
|
45
|
+
try {
|
|
46
|
+
const e = await R.value(s.url, {
|
|
47
|
+
mode: "cors",
|
|
48
|
+
credentials: "omit",
|
|
49
|
+
redirect: "follow"
|
|
50
|
+
});
|
|
51
|
+
if (!e.ok)
|
|
52
|
+
throw e.status === 404 ? new Error(o.value("pptx.not_found")) : e.status === 403 ? new x("file.forbidden") : e.status >= 500 ? new x("file.server_error") : new x("file.load_failed_status", { status: e.status });
|
|
53
|
+
const i = await e.arrayBuffer();
|
|
54
|
+
if (i.byteLength === 0) throw new x("file.empty");
|
|
55
|
+
d = i, D = (await O(i)).ratio;
|
|
56
|
+
const n = document.createElement("div");
|
|
57
|
+
n.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(n);
|
|
58
|
+
try {
|
|
59
|
+
const f = B(n, {
|
|
60
|
+
width: 100,
|
|
61
|
+
height: 100,
|
|
62
|
+
mode: "slide"
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
await f.preview(i);
|
|
66
|
+
} catch {
|
|
67
|
+
throw new Error(o.value("pptx.invalid_format"));
|
|
68
|
+
}
|
|
69
|
+
const w = f.slideCount;
|
|
70
|
+
if (!w || w === 0) throw new Error(o.value("pptx.no_pages"));
|
|
71
|
+
f.destroy(), p.value = w, r.value && (r.value.innerHTML = "");
|
|
72
|
+
const b = m();
|
|
73
|
+
l = B(r.value, {
|
|
74
|
+
width: b.width,
|
|
75
|
+
height: s.tiled ? b.height * w : b.height,
|
|
76
|
+
mode: s.tiled ? "list" : "slide"
|
|
77
|
+
}), await l.preview(i), t !== null && (clearTimeout(t), t = null), a.value = !1;
|
|
78
|
+
} finally {
|
|
79
|
+
document.body.contains(n) && document.body.removeChild(n);
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
t !== null && clearTimeout(t);
|
|
83
|
+
let i = o.value("pptx.parse_failed");
|
|
84
|
+
e instanceof Error ? i = S(o.value, e) : typeof e == "string" && (i = e), u.value = i, a.value = !1;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return L(() => {
|
|
88
|
+
if (!r.value) return;
|
|
89
|
+
let t = !0;
|
|
90
|
+
v = new ResizeObserver(() => {
|
|
91
|
+
if (t) {
|
|
92
|
+
t = !1, h = m();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const e = m(), i = Math.abs(h.width - e.width), n = Math.abs(h.height - e.height);
|
|
96
|
+
i < 10 && n < 10 || (h = e, c !== null && clearTimeout(c), c = window.setTimeout(() => {
|
|
97
|
+
l && d && W();
|
|
98
|
+
}, 800));
|
|
99
|
+
}), v.observe(r.value), setTimeout(() => {
|
|
100
|
+
requestAnimationFrame(() => requestAnimationFrame(() => E()));
|
|
101
|
+
}, 150);
|
|
102
|
+
}), P(
|
|
103
|
+
() => s.url,
|
|
104
|
+
(t) => {
|
|
105
|
+
t && E();
|
|
106
|
+
}
|
|
107
|
+
), q(() => {
|
|
108
|
+
if (v && v.disconnect(), c !== null && clearTimeout(c), d = null, p.value = 0, l)
|
|
109
|
+
try {
|
|
110
|
+
l.destroy();
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
113
|
+
l = null;
|
|
114
|
+
}), C({
|
|
115
|
+
getToolbarGroups: () => []
|
|
116
|
+
}), (t, e) => (g(), _("div", Z, [
|
|
117
|
+
a.value ? (g(), _("div", U, [
|
|
118
|
+
T("div", $, [
|
|
119
|
+
e[0] || (e[0] = T("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
120
|
+
T("p", j, A(M(o)("pptx.loading")), 1)
|
|
121
|
+
])
|
|
122
|
+
])) : k("", !0),
|
|
123
|
+
u.value && !a.value ? (g(), G(V, {
|
|
124
|
+
key: 1,
|
|
125
|
+
message: M(o)("pptx.load_failed"),
|
|
126
|
+
detail: u.value,
|
|
127
|
+
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
128
|
+
}, null, 8, ["message", "detail"])) : k("", !0),
|
|
129
|
+
u.value ? k("", !0) : (g(), _("div", {
|
|
130
|
+
key: 2,
|
|
131
|
+
ref_key: "containerRef",
|
|
132
|
+
ref: r,
|
|
133
|
+
class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
|
|
134
|
+
style: H({ opacity: a.value ? 0 : 1 })
|
|
135
|
+
}, null, 4))
|
|
136
|
+
]));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
export {
|
|
140
|
+
ee as default
|
|
141
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defineComponent as E, ref as m, onMounted as z, watch as B, onBeforeUnmount as S, openBlock as v, createElementBlock as w, createElementVNode as x, toDisplayString as H, unref as k, createCommentVNode as g, createBlock as L, normalizeStyle as R } from "vue";
|
|
2
|
+
import { u as A, b as C, k as u, i as G, c as Z, W as F, p as N, x as O, d as V, Z as q } from "./index-B3uQ1OoT.mjs";
|
|
3
|
+
import I from "exceljs";
|
|
4
|
+
import { S as J } from "./index-CyBXARuf.mjs";
|
|
5
|
+
import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
6
|
+
const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, $ = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
9
|
+
}, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, re = /* @__PURE__ */ E({
|
|
10
|
+
__name: "index",
|
|
11
|
+
props: {
|
|
12
|
+
url: {}
|
|
13
|
+
},
|
|
14
|
+
setup(T, { expose: W }) {
|
|
15
|
+
async function D(e) {
|
|
16
|
+
try {
|
|
17
|
+
return await new I.Workbook().xlsx.load(e.slice().buffer);
|
|
18
|
+
} catch (t) {
|
|
19
|
+
throw t instanceof TypeError && /sheets/i.test(t.message) ? new u("xlsx.invalid_format") : t;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const b = T, { t: o } = A(), M = C(), a = m(!0), n = m(null), l = m(null);
|
|
23
|
+
let i = null, h = 100, c = null, f = null, d = { width: 0, height: 0 };
|
|
24
|
+
const p = () => {
|
|
25
|
+
if (!l.value) return { width: 800, height: 600 };
|
|
26
|
+
const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
|
|
27
|
+
return { width: r, height: s };
|
|
28
|
+
}, _ = () => {
|
|
29
|
+
if (!l.value || !i) return;
|
|
30
|
+
l.value.innerHTML = "";
|
|
31
|
+
const { width: e, height: t } = p(), r = e < 640;
|
|
32
|
+
new J(l.value, {
|
|
33
|
+
mode: "read",
|
|
34
|
+
showToolbar: !1,
|
|
35
|
+
showContextmenu: !1,
|
|
36
|
+
showGrid: !0,
|
|
37
|
+
row: {
|
|
38
|
+
len: h,
|
|
39
|
+
height: 25
|
|
40
|
+
},
|
|
41
|
+
col: {
|
|
42
|
+
len: 26,
|
|
43
|
+
width: r ? 80 : 100,
|
|
44
|
+
indexWidth: r ? 40 : 60,
|
|
45
|
+
minWidth: r ? 40 : 60
|
|
46
|
+
},
|
|
47
|
+
view: {
|
|
48
|
+
height: () => t,
|
|
49
|
+
width: () => e
|
|
50
|
+
}
|
|
51
|
+
}).loadData(i);
|
|
52
|
+
}, y = async () => {
|
|
53
|
+
if (l.value) {
|
|
54
|
+
a.value = !0, n.value = null;
|
|
55
|
+
try {
|
|
56
|
+
const e = await M.value(b.url, {
|
|
57
|
+
mode: "cors",
|
|
58
|
+
credentials: "omit",
|
|
59
|
+
redirect: "follow"
|
|
60
|
+
});
|
|
61
|
+
if (!e.ok)
|
|
62
|
+
throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new u("file.forbidden") : new u("file.load_failed_status", { status: e.status });
|
|
63
|
+
const t = G(await e.arrayBuffer());
|
|
64
|
+
if (t.byteLength === 0)
|
|
65
|
+
throw new u("file.empty");
|
|
66
|
+
let r;
|
|
67
|
+
if (Z(t)) {
|
|
68
|
+
const s = F(t);
|
|
69
|
+
if (!s || !Array.isArray(s.sheets))
|
|
70
|
+
throw new u("xlsx.invalid_legacy_data");
|
|
71
|
+
r = N(s);
|
|
72
|
+
} else
|
|
73
|
+
r = O(
|
|
74
|
+
await D(t)
|
|
75
|
+
);
|
|
76
|
+
i = r, h = V(r), _(), a.value = !1;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error(o.value("xlsx.parse_failed") + ":", e);
|
|
79
|
+
let t = o.value("xlsx.parse_failed");
|
|
80
|
+
e instanceof Error && (t = q(o.value, e)), n.value = t, a.value = !1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return z(() => {
|
|
85
|
+
if (!l.value) return;
|
|
86
|
+
let e = !0;
|
|
87
|
+
c = new ResizeObserver(() => {
|
|
88
|
+
if (e) {
|
|
89
|
+
e = !1, d = p();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const t = p(), r = Math.abs(d.width - t.width), s = Math.abs(d.height - t.height);
|
|
93
|
+
r < 10 && s < 10 || (d = t, f !== null && clearTimeout(f), f = window.setTimeout(() => {
|
|
94
|
+
i && _();
|
|
95
|
+
}, 500));
|
|
96
|
+
}), c.observe(l.value), setTimeout(() => {
|
|
97
|
+
requestAnimationFrame(() => y());
|
|
98
|
+
}, 100);
|
|
99
|
+
}), B(
|
|
100
|
+
() => b.url,
|
|
101
|
+
(e) => {
|
|
102
|
+
e && y();
|
|
103
|
+
}
|
|
104
|
+
), S(() => {
|
|
105
|
+
c && c.disconnect(), f !== null && clearTimeout(f), i = null, h = 100, l.value && (l.value.innerHTML = "");
|
|
106
|
+
}), W({
|
|
107
|
+
getToolbarGroups: () => []
|
|
108
|
+
}), (e, t) => (v(), w("div", X, [
|
|
109
|
+
a.value ? (v(), w("div", $, [
|
|
110
|
+
x("div", j, [
|
|
111
|
+
t[0] || (t[0] = x("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
112
|
+
x("p", K, H(k(o)("xlsx.loading")), 1)
|
|
113
|
+
])
|
|
114
|
+
])) : g("", !0),
|
|
115
|
+
n.value && !a.value ? (v(), L(U, {
|
|
116
|
+
key: 1,
|
|
117
|
+
message: k(o)("xlsx.load_failed"),
|
|
118
|
+
detail: n.value,
|
|
119
|
+
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
120
|
+
}, null, 8, ["message", "detail"])) : g("", !0),
|
|
121
|
+
n.value ? g("", !0) : (v(), w("div", {
|
|
122
|
+
key: 2,
|
|
123
|
+
ref_key: "containerRef",
|
|
124
|
+
ref: l,
|
|
125
|
+
class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
|
|
126
|
+
style: R({ opacity: a.value ? 0 : 1 })
|
|
127
|
+
}, null, 4))
|
|
128
|
+
]));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
export {
|
|
132
|
+
re as default
|
|
133
|
+
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { u as
|
|
3
|
-
import { _ as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as L, ref as y, watch as G, computed as g, openBlock as a, createElementBlock as r, createElementVNode as e, toDisplayString as o, unref as n, createBlock as V, normalizeClass as b, Fragment as h, renderList as k, createCommentVNode as B } from "vue";
|
|
2
|
+
import { u as z, b as D, A as I, B as d, S as M, _ as O } from "./index-B3uQ1OoT.mjs";
|
|
3
|
+
import { _ as R } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
4
|
+
const X = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "vfp-renderer-loading vfp-bg-[#0f0f12]"
|
|
7
|
-
},
|
|
7
|
+
}, Y = { class: "vfp-renderer-loading-content" }, $ = { 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
8
|
key: 0,
|
|
9
9
|
class: "cue-style"
|
|
10
10
|
}, W = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "cue-words"
|
|
13
|
-
}, Z = ["title"], ee = { class: "cue-word-time" }, se = { class: "cue-word-text" }, te = { class: "status-pill" }, le = /* @__PURE__ */
|
|
13
|
+
}, Z = ["title"], ee = { class: "cue-word-time" }, se = { class: "cue-word-text" }, te = { class: "status-pill" }, le = /* @__PURE__ */ L({
|
|
14
14
|
__name: "index",
|
|
15
15
|
props: {
|
|
16
16
|
url: {},
|
|
17
17
|
fileName: {}
|
|
18
18
|
},
|
|
19
|
-
setup(
|
|
20
|
-
const v =
|
|
19
|
+
setup(T, { expose: C }) {
|
|
20
|
+
const v = T, { t: i } = z(), F = D(), p = y(""), f = y(!0), u = y(null), N = {
|
|
21
21
|
srt: "srt",
|
|
22
22
|
vtt: "vtt",
|
|
23
23
|
lrc: "lrc",
|
|
@@ -26,7 +26,7 @@ const R = {
|
|
|
26
26
|
ssa: "ssa",
|
|
27
27
|
ttml: "ttml",
|
|
28
28
|
dfxp: "ttml"
|
|
29
|
-
},
|
|
29
|
+
}, S = (t) => {
|
|
30
30
|
var l;
|
|
31
31
|
const s = ((l = t.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
|
|
32
32
|
return N[s];
|
|
@@ -34,35 +34,35 @@ const R = {
|
|
|
34
34
|
G(() => v.url, async () => {
|
|
35
35
|
f.value = !0, u.value = null;
|
|
36
36
|
try {
|
|
37
|
-
p.value = await
|
|
37
|
+
p.value = await M(v.url, { fetcher: F.value });
|
|
38
38
|
} catch (t) {
|
|
39
39
|
console.error(t), u.value = i.value("subtitle.load_failed");
|
|
40
40
|
} finally {
|
|
41
41
|
f.value = !1;
|
|
42
42
|
}
|
|
43
43
|
}, { immediate: !0 });
|
|
44
|
-
const c =
|
|
44
|
+
const c = g(() => {
|
|
45
45
|
if (!p.value) return null;
|
|
46
46
|
try {
|
|
47
|
-
return
|
|
47
|
+
return I(p.value, S(v.fileName));
|
|
48
48
|
} catch (t) {
|
|
49
49
|
return console.error(t), null;
|
|
50
50
|
}
|
|
51
|
-
}), m =
|
|
51
|
+
}), m = g(() => {
|
|
52
52
|
var t, s;
|
|
53
53
|
return ((t = c.value) == null ? void 0 : t.format) === "lrc" || ((s = c.value) == null ? void 0 : s.format) === "elrc";
|
|
54
|
-
}), x =
|
|
54
|
+
}), x = g(() => {
|
|
55
55
|
var t;
|
|
56
56
|
return ((t = c.value) == null ? void 0 : t.metadata) ?? {};
|
|
57
|
-
}),
|
|
57
|
+
}), A = (t) => d(t).slice(3, 8);
|
|
58
58
|
return C({
|
|
59
59
|
getToolbarGroups: () => []
|
|
60
|
-
}), (t, s) => f.value ? (a(), r("div",
|
|
61
|
-
e("div",
|
|
60
|
+
}), (t, s) => f.value ? (a(), r("div", X, [
|
|
61
|
+
e("div", Y, [
|
|
62
62
|
s[0] || (s[0] = e("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
63
|
-
e("span",
|
|
63
|
+
e("span", $, o(n(i)("common.loading")), 1)
|
|
64
64
|
])
|
|
65
|
-
])) : u.value || !c.value ? (a(),
|
|
65
|
+
])) : u.value || !c.value ? (a(), V(R, {
|
|
66
66
|
key: 1,
|
|
67
67
|
message: u.value || n(i)("subtitle.parse_failed"),
|
|
68
68
|
class: "vfp-bg-[#0f0f12]"
|
|
@@ -84,15 +84,15 @@ const R = {
|
|
|
84
84
|
s[1] || (s[1] = e("span", { class: "cue-arrow" }, "→", -1)),
|
|
85
85
|
e("span", P, o(n(d)(l.end)), 1),
|
|
86
86
|
e("span", Q, "#" + o(l.id ?? w + 1), 1),
|
|
87
|
-
l.style ? (a(), r("span", U, o(l.style), 1)) :
|
|
87
|
+
l.style ? (a(), r("span", U, o(l.style), 1)) : B("", !0)
|
|
88
88
|
]),
|
|
89
89
|
l.words && l.words.length > 0 ? (a(), r("div", W, [
|
|
90
|
-
(a(!0), r(h, null, k(l.words, (_,
|
|
91
|
-
key: "w-" +
|
|
90
|
+
(a(!0), r(h, null, k(l.words, (_, E) => (a(), r("span", {
|
|
91
|
+
key: "w-" + E,
|
|
92
92
|
class: "cue-word",
|
|
93
93
|
title: n(d)(_.start)
|
|
94
94
|
}, [
|
|
95
|
-
e("span", ee, o(
|
|
95
|
+
e("span", ee, o(A(_.start)), 1),
|
|
96
96
|
e("span", se, o(_.text), 1)
|
|
97
97
|
], 8, Z))), 128))
|
|
98
98
|
])) : (a(), r("p", {
|
|
@@ -108,11 +108,11 @@ const R = {
|
|
|
108
108
|
x.value.length ? (a(), r(h, { key: 0 }, [
|
|
109
109
|
s[4] || (s[4] = e("span", { class: "dot" }, "·", -1)),
|
|
110
110
|
e("span", null, o(x.value.length), 1)
|
|
111
|
-
], 64)) :
|
|
111
|
+
], 64)) : B("", !0)
|
|
112
112
|
])
|
|
113
113
|
], 2));
|
|
114
114
|
}
|
|
115
|
-
}), ie = /* @__PURE__ */
|
|
115
|
+
}), ie = /* @__PURE__ */ O(le, [["__scopeId", "data-v-e2b8685e"]]);
|
|
116
116
|
export {
|
|
117
117
|
ie as default
|
|
118
118
|
};
|