@eternalheart/vue-file-preview 1.3.6 → 1.3.7
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/lib/FilePreviewContent.vue.d.ts.map +1 -1
- package/lib/FilePreviewEmbed.vue.d.ts.map +1 -1
- package/lib/FilePreviewModal.vue.d.ts.map +1 -1
- package/lib/chunks/index-BI0dSTSM.mjs +77 -0
- package/lib/chunks/index-BI0dSTSM.mjs.map +1 -0
- package/lib/chunks/index-BW61ZRev.mjs +111 -0
- package/lib/chunks/index-BW61ZRev.mjs.map +1 -0
- package/lib/chunks/index-C8ZF84WX.mjs +113 -0
- package/lib/chunks/index-C8ZF84WX.mjs.map +1 -0
- package/lib/chunks/index-CB0zCxJb.mjs +353 -0
- package/lib/chunks/index-CB0zCxJb.mjs.map +1 -0
- package/lib/chunks/index-CBCQs1ZC.mjs +116 -0
- package/lib/chunks/index-CBCQs1ZC.mjs.map +1 -0
- package/lib/chunks/index-CbKSdAt_.mjs +391 -0
- package/lib/chunks/index-CbKSdAt_.mjs.map +1 -0
- package/lib/chunks/index-CcJ5NmY1.mjs +152 -0
- package/lib/chunks/index-CcJ5NmY1.mjs.map +1 -0
- package/lib/chunks/index-ClxBxmPR.mjs +249 -0
- package/lib/chunks/index-ClxBxmPR.mjs.map +1 -0
- package/lib/chunks/index-D9lByoJw.mjs +111 -0
- package/lib/chunks/index-D9lByoJw.mjs.map +1 -0
- package/lib/chunks/index-DTLDLOGO.mjs +129 -0
- package/lib/chunks/index-DTLDLOGO.mjs.map +1 -0
- package/lib/chunks/index-DUUsS_T4.mjs +134 -0
- package/lib/chunks/index-DUUsS_T4.mjs.map +1 -0
- package/lib/chunks/index-Doy0FvQW.mjs +136 -0
- package/lib/chunks/index-Doy0FvQW.mjs.map +1 -0
- package/lib/chunks/index-DpAxU2JM.mjs +2017 -0
- package/lib/chunks/index-DpAxU2JM.mjs.map +1 -0
- package/lib/chunks/index-DsznjwsH.mjs +103 -0
- package/lib/chunks/index-DsznjwsH.mjs.map +1 -0
- package/lib/chunks/index-SAfVQyNJ.mjs +281 -0
- package/lib/chunks/index-SAfVQyNJ.mjs.map +1 -0
- package/lib/chunks/index-S_kGRh6H.mjs +203 -0
- package/lib/chunks/index-S_kGRh6H.mjs.map +1 -0
- package/lib/chunks/index-kBPb_OKm.mjs +139 -0
- package/lib/chunks/index-kBPb_OKm.mjs.map +1 -0
- package/lib/chunks/index-yMb1JUC4.mjs +84 -0
- package/lib/chunks/index-yMb1JUC4.mjs.map +1 -0
- package/lib/composables/useResolvedTheme.d.ts +15 -0
- package/lib/composables/useResolvedTheme.d.ts.map +1 -0
- package/lib/index.cjs +24 -499
- package/lib/index.cjs.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.mjs +12 -44597
- package/lib/index.mjs.map +1 -1
- package/lib/renderers/Audio/index.vue.d.ts.map +1 -1
- package/lib/renderers/Csv/index.vue.d.ts.map +1 -1
- package/lib/renderers/Json/index.vue.d.ts.map +1 -1
- package/lib/renderers/Markdown/index.vue.d.ts.map +1 -1
- package/lib/renderers/Pptx/index.vue.d.ts.map +1 -1
- package/lib/renderers/RendererLoading.vue.d.ts +3 -0
- package/lib/renderers/RendererLoading.vue.d.ts.map +1 -0
- package/lib/renderers/Text/index.vue.d.ts.map +1 -1
- package/lib/renderers/Video/index.vue.d.ts.map +1 -1
- package/lib/renderers/Xlsx/index.vue.d.ts.map +1 -1
- package/lib/renderers/Xml/index.vue.d.ts.map +1 -1
- package/lib/renderers/Zip/index.vue.d.ts.map +1 -1
- package/lib/renderers/lazy.d.ts +19 -0
- package/lib/renderers/lazy.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewContent.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewContent.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilePreviewContent.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewContent.vue"],"names":[],"mappings":"AAmvBA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,0BAA0B,EAChC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,SAAS,CAAC;AAoCrE,UAAU,KAAK;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;;;;;;;;;;UAXQ,OAAO,GAAG,OAAO;WAUhB,KAAK;qBAZK,cAAc,EAAE;qBAIhB,MAAM;YAEf,MAAM;cAEJ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;cAE1C,OAAO;;AAkrCpB,wBAQG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewEmbed.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewEmbed.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilePreviewEmbed.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewEmbed.vue"],"names":[],"mappings":"AAsGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,UAAU,KAAK;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;;;;;;;;YATU,MAAM,GAAG,MAAM;WAFhB,MAAM,GAAG,MAAM;WAUf,KAAK;kBAbE,MAAM;qBACH,cAAc,EAAE;YAMzB,MAAM;cAEJ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;cAE1C,OAAO;;AAwJpB,wBAQG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewModal.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilePreviewModal.vue.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.vue"],"names":[],"mappings":"AAoHA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,UAAU,KAAK;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;;;;;;;;;;WADS,KAAK;qBARK,cAAc,EAAE;YAEzB,MAAM;cAEJ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;cAE1C,OAAO;;AAyMpB,wBAQG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { defineComponent as x, ref as n, computed as y, watch as h, openBlock as e, createElementBlock as t, createElementVNode as v, toDisplayString as m, normalizeClass as w } from "vue";
|
|
2
|
+
import { u as _, b, j as k, h as T, _ as B } from "./index-DpAxU2JM.mjs";
|
|
3
|
+
import { codeToHtml as N } from "shiki";
|
|
4
|
+
const j = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
7
|
+
}, H = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
10
|
+
}, W = { class: "vfp-text-fg-secondary vfp-text-center" }, C = { class: "vfp-text-lg" }, E = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
|
|
13
|
+
}, L = ["srcdoc", "title"], M = {
|
|
14
|
+
key: 3,
|
|
15
|
+
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
16
|
+
style: { background: "var(--fp-code-bg)" }
|
|
17
|
+
}, P = ["innerHTML"], z = /* @__PURE__ */ x({
|
|
18
|
+
__name: "index",
|
|
19
|
+
props: {
|
|
20
|
+
url: {},
|
|
21
|
+
fileName: {},
|
|
22
|
+
wordWrap: { type: Boolean, default: !0 },
|
|
23
|
+
htmlPreview: { type: Boolean, default: !1 }
|
|
24
|
+
},
|
|
25
|
+
setup(l) {
|
|
26
|
+
const i = l, { t: g } = _(), u = b(), o = n(""), a = n(""), p = n(!0), r = n(null), f = y(() => k(i.fileName)), c = async () => {
|
|
27
|
+
p.value = !0, r.value = null;
|
|
28
|
+
try {
|
|
29
|
+
const s = await T(i.url);
|
|
30
|
+
if (o.value = s, f.value !== "text")
|
|
31
|
+
try {
|
|
32
|
+
a.value = await N(s, {
|
|
33
|
+
lang: f.value,
|
|
34
|
+
theme: u.value === "light" ? "github-light" : "dark-plus"
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
a.value = "";
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
a.value = "";
|
|
41
|
+
} catch (s) {
|
|
42
|
+
console.error(s), r.value = g.value("text.load_failed");
|
|
43
|
+
} finally {
|
|
44
|
+
p.value = !1;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return h(() => i.url, c, { immediate: !0 }), h(u, () => {
|
|
48
|
+
o.value && f.value !== "text" && c();
|
|
49
|
+
}), (s, d) => p.value ? (e(), t("div", j, [...d[0] || (d[0] = [
|
|
50
|
+
v("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)
|
|
51
|
+
])])) : r.value ? (e(), t("div", H, [
|
|
52
|
+
v("div", W, [
|
|
53
|
+
v("p", C, m(r.value), 1)
|
|
54
|
+
])
|
|
55
|
+
])) : l.htmlPreview && f.value === "html" ? (e(), t("div", E, [
|
|
56
|
+
v("iframe", {
|
|
57
|
+
srcdoc: o.value,
|
|
58
|
+
sandbox: "allow-same-origin",
|
|
59
|
+
class: "vfp-w-full vfp-h-full vfp-border-0",
|
|
60
|
+
title: l.fileName
|
|
61
|
+
}, null, 8, L)
|
|
62
|
+
])) : (e(), t("div", M, [
|
|
63
|
+
a.value ? (e(), t("div", {
|
|
64
|
+
key: 1,
|
|
65
|
+
class: w(["shiki-wrapper", { "no-wrap": !l.wordWrap }]),
|
|
66
|
+
innerHTML: a.value
|
|
67
|
+
}, null, 10, P)) : (e(), t("pre", {
|
|
68
|
+
key: 0,
|
|
69
|
+
class: w(["vfp-p-6 vfp-text-fg-primary vfp-font-mono vfp-text-sm", l.wordWrap ? "vfp-whitespace-pre-wrap vfp-break-words" : "vfp-whitespace-pre"])
|
|
70
|
+
}, m(o.value), 3))
|
|
71
|
+
]));
|
|
72
|
+
}
|
|
73
|
+
}), S = /* @__PURE__ */ B(z, [["__scopeId", "data-v-22859c1e"]]);
|
|
74
|
+
export {
|
|
75
|
+
S as default
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=index-BI0dSTSM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BI0dSTSM.mjs","sources":["../../src/renderers/Text/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue';\nimport { getLanguageFromFileName, fetchTextUtf8 } from '@eternalheart/file-preview-core';\nimport { codeToHtml } from 'shiki';\nimport { useTranslator } from '../../composables/useTranslator';\nimport { useResolvedTheme } from '../../composables/useResolvedTheme';\n\nconst props = withDefaults(defineProps<{\n url: string;\n fileName: string;\n wordWrap?: boolean;\n htmlPreview?: boolean;\n}>(), {\n wordWrap: true,\n htmlPreview: false,\n});\n\nconst { t } = useTranslator();\nconst resolvedTheme = useResolvedTheme();\n\nconst content = ref<string>('');\nconst highlighted = ref<string>('');\nconst loading = ref(true);\nconst error = ref<string | null>(null);\n\nconst language = computed(() => getLanguageFromFileName(props.fileName));\n\nconst loadText = async () => {\n loading.value = true;\n error.value = null;\n try {\n const text = await fetchTextUtf8(props.url);\n content.value = text;\n\n if (language.value !== 'text') {\n try {\n highlighted.value = await codeToHtml(text, {\n lang: language.value,\n theme: resolvedTheme.value === 'light' ? 'github-light' : 'dark-plus',\n });\n } catch {\n highlighted.value = '';\n }\n } else {\n highlighted.value = '';\n }\n } catch (err) {\n console.error(err);\n error.value = t.value('text.load_failed');\n } finally {\n loading.value = false;\n }\n};\n\nwatch(() => props.url, loadText, { immediate: true });\nwatch(resolvedTheme, () => {\n // 主题切换时重新高亮\n if (content.value && language.value !== 'text') {\n loadText();\n }\n});\n</script>\n\n<template>\n <div v-if=\"loading\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div\n 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\"\n />\n </div>\n\n <div v-else-if=\"error\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div class=\"vfp-text-fg-secondary vfp-text-center\">\n <p class=\"vfp-text-lg\">{{ error }}</p>\n </div>\n </div>\n\n <!-- HTML 预览模式 -->\n <div v-else-if=\"htmlPreview && language === 'html'\" class=\"vfp-w-full vfp-h-full vfp-bg-surface-toolbar\">\n <iframe\n :srcdoc=\"content\"\n sandbox=\"allow-same-origin\"\n class=\"vfp-w-full vfp-h-full vfp-border-0\"\n :title=\"fileName\"\n />\n </div>\n\n <!-- 源码模式 -->\n <div v-else class=\"vfp-w-full vfp-h-full vfp-overflow-auto\" style=\"background: var(--fp-code-bg);\">\n <pre\n v-if=\"!highlighted\"\n class=\"vfp-p-6 vfp-text-fg-primary vfp-font-mono vfp-text-sm\"\n :class=\"wordWrap ? 'vfp-whitespace-pre-wrap vfp-break-words' : 'vfp-whitespace-pre'\"\n >{{ content }}</pre>\n <div v-else class=\"shiki-wrapper\" :class=\"{ 'no-wrap': !wordWrap }\" v-html=\"highlighted\" />\n </div>\n</template>\n\n<style scoped>\n.shiki-wrapper :deep(pre) {\n margin: 0;\n padding: 1.5rem 1.5rem 1.5rem 0;\n background: transparent !important;\n font-size: 0.875rem;\n overflow-x: auto;\n}\n.shiki-wrapper :deep(code) {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n counter-reset: line;\n}\n.shiki-wrapper :deep(code .line) {\n counter-increment: line;\n}\n.shiki-wrapper :deep(code .line::before) {\n content: counter(line);\n display: inline-block;\n width: 3em;\n padding-right: 1em;\n margin-right: 0.5em;\n text-align: right;\n color: var(--fp-fg-disabled);\n user-select: none;\n border-right: 1px solid var(--fp-line);\n}\n.shiki-wrapper.no-wrap :deep(code) {\n white-space: pre;\n word-break: normal;\n overflow-wrap: normal;\n}\n.shiki-wrapper:not(.no-wrap) :deep(code) {\n white-space: pre-wrap;\n word-break: break-word;\n overflow-wrap: break-word;\n}\n</style>\n"],"names":["props","__props","t","useTranslator","resolvedTheme","useResolvedTheme","content","ref","highlighted","loading","error","language","computed","getLanguageFromFileName","loadText","text","fetchTextUtf8","codeToHtml","err","watch","_openBlock","_createElementBlock","_hoisted_1","_cache","_createElementVNode","_hoisted_2","_hoisted_3","_hoisted_4","_toDisplayString","_hoisted_5","_hoisted_7","_normalizeClass"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,UAAMA,IAAQC,GAUR,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IAAgBC,EAAA,GAEhBC,IAAUC,EAAY,EAAE,GACxBC,IAAcD,EAAY,EAAE,GAC5BE,IAAUF,EAAI,EAAI,GAClBG,IAAQH,EAAmB,IAAI,GAE/BI,IAAWC,EAAS,MAAMC,EAAwBb,EAAM,QAAQ,CAAC,GAEjEc,IAAW,YAAY;AAC3B,MAAAL,EAAQ,QAAQ,IAChBC,EAAM,QAAQ;AACd,UAAI;AACF,cAAMK,IAAO,MAAMC,EAAchB,EAAM,GAAG;AAG1C,YAFAM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AKU,EAAA,CAAC,iBAAe,EAAA,WAAA,CAAuB9B,EAAA,SAAA,CAAQ,CAAA;AAAA,QAAI,WAAQO,EAAA;AAAA,MAAA,yBAL5Ea,EAIoB,OAAA;AAAA;QAFlB,OAAKU,EAAA,CAAC,yDACE9B,EAAA,WAAQ,4CAAA,oBAAA,CAAA;AAAA,MAAA,KACdK,EAAA,KAAO,GAAA,CAAA;AAAA;;;"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { defineComponent as T, ref as x, onMounted as D, watch as z, onBeforeUnmount as M, openBlock as u, createElementBlock as c, createElementVNode as f, toDisplayString as w, unref as b, createCommentVNode as g, createVNode as N, normalizeStyle as S } from "vue";
|
|
2
|
+
import { FileSpreadsheet as C } from "lucide-vue-next";
|
|
3
|
+
import H from "x-data-spreadsheet";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { u as R, h as V, g as W, m as j, k as B } from "./index-DpAxU2JM.mjs";
|
|
6
|
+
const E = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, F = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
9
|
+
}, L = { class: "vfp-text-center" }, O = { class: "vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, q = {
|
|
10
|
+
key: 1,
|
|
11
|
+
class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
12
|
+
}, A = { class: "vfp-text-center vfp-max-w-sm md:vfp-max-w-md vfp-px-4" }, G = { class: "vfp-w-24 vfp-h-24 md:vfp-w-32 md:vfp-h-32 vfp-mx-auto vfp-mb-4 md:vfp-mb-6 vfp-rounded-2xl md:vfp-rounded-3xl vfp-bg-gradient-to-br vfp-from-green-500 vfp-via-emerald-500 vfp-to-teal-500 vfp-flex vfp-items-center vfp-justify-center vfp-shadow-2xl" }, I = { class: "vfp-text-lg md:vfp-text-xl vfp-text-fg-primary vfp-mb-2 md:vfp-mb-3 vfp-font-medium" }, U = { class: "vfp-text-xs md:vfp-text-sm vfp-text-fg-tertiary vfp-mb-4 md:vfp-mb-6" }, Y = /* @__PURE__ */ T({
|
|
13
|
+
__name: "index",
|
|
14
|
+
props: {
|
|
15
|
+
url: {},
|
|
16
|
+
fileName: {}
|
|
17
|
+
},
|
|
18
|
+
setup(k) {
|
|
19
|
+
const a = k, { t: m } = R(), n = x(!0), r = x(null), s = x(null);
|
|
20
|
+
let i = null, v = null, o = null, p = { width: 0, height: 0 };
|
|
21
|
+
const h = () => {
|
|
22
|
+
if (!s.value) return { width: 800, height: 600 };
|
|
23
|
+
const t = s.value.clientWidth, e = s.value.clientHeight, l = t > 100 ? t : 800, d = e > 100 ? e : 600;
|
|
24
|
+
return { width: l, height: d };
|
|
25
|
+
}, _ = () => {
|
|
26
|
+
if (!s.value || !i) return;
|
|
27
|
+
s.value.innerHTML = "";
|
|
28
|
+
const { width: t, height: e } = h(), l = t < 640;
|
|
29
|
+
new H(s.value, {
|
|
30
|
+
mode: "read",
|
|
31
|
+
showToolbar: !1,
|
|
32
|
+
showContextmenu: !1,
|
|
33
|
+
showGrid: !0,
|
|
34
|
+
row: {
|
|
35
|
+
len: 100,
|
|
36
|
+
height: 25
|
|
37
|
+
},
|
|
38
|
+
col: {
|
|
39
|
+
len: 26,
|
|
40
|
+
width: l ? 80 : 100,
|
|
41
|
+
indexWidth: l ? 40 : 60,
|
|
42
|
+
minWidth: l ? 40 : 60
|
|
43
|
+
},
|
|
44
|
+
view: {
|
|
45
|
+
height: () => e,
|
|
46
|
+
width: () => t
|
|
47
|
+
}
|
|
48
|
+
}).loadData(i);
|
|
49
|
+
}, y = async () => {
|
|
50
|
+
if (s.value) {
|
|
51
|
+
n.value = !0, r.value = null;
|
|
52
|
+
try {
|
|
53
|
+
const t = await V(a.url), e = W(t, { delimiter: j(a.fileName) });
|
|
54
|
+
i = B(e.header, e.rows, a.fileName), _(), n.value = !1;
|
|
55
|
+
} catch (t) {
|
|
56
|
+
console.error("CSV 解析错误:", t), r.value = m.value("csv.load_failed"), n.value = !1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return D(() => {
|
|
61
|
+
if (!s.value) return;
|
|
62
|
+
let t = !0;
|
|
63
|
+
v = new ResizeObserver(() => {
|
|
64
|
+
if (t) {
|
|
65
|
+
t = !1, p = h();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const e = h(), l = Math.abs(p.width - e.width), d = Math.abs(p.height - e.height);
|
|
69
|
+
l < 10 && d < 10 || (p = e, o !== null && clearTimeout(o), o = window.setTimeout(() => {
|
|
70
|
+
i && _();
|
|
71
|
+
}, 500));
|
|
72
|
+
}), v.observe(s.value), setTimeout(() => {
|
|
73
|
+
requestAnimationFrame(() => y());
|
|
74
|
+
}, 100);
|
|
75
|
+
}), z(
|
|
76
|
+
() => a.url,
|
|
77
|
+
() => {
|
|
78
|
+
y();
|
|
79
|
+
}
|
|
80
|
+
), M(() => {
|
|
81
|
+
v && v.disconnect(), o !== null && clearTimeout(o), i = null, s.value && (s.value.innerHTML = "");
|
|
82
|
+
}), (t, e) => (u(), c("div", E, [
|
|
83
|
+
n.value ? (u(), c("div", F, [
|
|
84
|
+
f("div", L, [
|
|
85
|
+
e[0] || (e[0] = f("div", { class: "vfp-w-10 vfp-h-10 md:vfp-w-12 md:vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)),
|
|
86
|
+
f("p", O, w(b(m)("csv.loading")), 1)
|
|
87
|
+
])
|
|
88
|
+
])) : g("", !0),
|
|
89
|
+
r.value && !n.value ? (u(), c("div", q, [
|
|
90
|
+
f("div", A, [
|
|
91
|
+
f("div", G, [
|
|
92
|
+
N(b(C), { class: "vfp-w-12 vfp-h-12 md:vfp-w-16 md:vfp-h-16 vfp-text-fg-primary" })
|
|
93
|
+
]),
|
|
94
|
+
f("p", I, w(b(m)("csv.load_failed")), 1),
|
|
95
|
+
f("p", U, w(r.value), 1)
|
|
96
|
+
])
|
|
97
|
+
])) : g("", !0),
|
|
98
|
+
r.value ? g("", !0) : (u(), c("div", {
|
|
99
|
+
key: 2,
|
|
100
|
+
ref_key: "containerRef",
|
|
101
|
+
ref: s,
|
|
102
|
+
class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
|
|
103
|
+
style: S({ opacity: n.value ? 0 : 1 })
|
|
104
|
+
}, null, 4))
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
export {
|
|
109
|
+
Y as default
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=index-BW61ZRev.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BW61ZRev.mjs","sources":["../../src/renderers/Csv/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount } from 'vue';\nimport { FileSpreadsheet } from 'lucide-vue-next';\nimport Spreadsheet from 'x-data-spreadsheet';\nimport 'x-data-spreadsheet/dist/xspreadsheet.css';\nimport {\n parseCsv,\n guessCsvDelimiter,\n fetchTextUtf8,\n convertCsvToSpreadsheetData,\n} from '@eternalheart/file-preview-core';\nimport { useTranslator } from '../../composables/useTranslator';\n\nconst props = defineProps<{\n url: string;\n fileName: string;\n}>();\n\nconst { t } = useTranslator();\n\nconst loading = ref(true);\nconst error = ref<string | null>(null);\nconst containerRef = ref<HTMLDivElement | null>(null);\nlet sheetData: Record<string, unknown>[] | null = null;\nlet resizeObserver: ResizeObserver | null = null;\nlet resizeTimeout: number | null = null;\nlet lastDimensions = { width: 0, height: 0 };\n\nconst calculateDimensions = () => {\n if (!containerRef.value) return { width: 800, height: 600 };\n const rawWidth = containerRef.value.clientWidth;\n const rawHeight = containerRef.value.clientHeight;\n const width = rawWidth > 100 ? rawWidth : 800;\n const height = rawHeight > 100 ? rawHeight : 600;\n return { width, height };\n};\n\nconst mountSpreadsheet = () => {\n if (!containerRef.value || !sheetData) return;\n\n containerRef.value.innerHTML = '';\n\n const { width, height } = calculateDimensions();\n const isMobile = width < 640;\n\n const s = new Spreadsheet(containerRef.value, {\n mode: 'read',\n showToolbar: false,\n showContextmenu: false,\n showGrid: true,\n row: {\n len: 100,\n height: 25,\n },\n col: {\n len: 26,\n width: isMobile ? 80 : 100,\n indexWidth: isMobile ? 40 : 60,\n minWidth: isMobile ? 40 : 60,\n },\n view: {\n height: () => height,\n width: () => width,\n },\n });\n\n s.loadData(sheetData as unknown as Record<string, unknown>);\n};\n\nconst loadCsv = async () => {\n if (!containerRef.value) return;\n\n loading.value = true;\n error.value = null;\n\n try {\n const text = await fetchTextUtf8(props.url);\n const parsed = parseCsv(text, { delimiter: guessCsvDelimiter(props.fileName) });\n const data = convertCsvToSpreadsheetData(parsed.header, parsed.rows, props.fileName);\n\n sheetData = data as unknown as Record<string, unknown>[];\n mountSpreadsheet();\n loading.value = false;\n } catch (err) {\n console.error('CSV 解析错误:', err);\n error.value = t.value('csv.load_failed');\n loading.value = false;\n }\n};\n\nonMounted(() => {\n if (!containerRef.value) return;\n\n let isInitialRender = true;\n\n resizeObserver = new ResizeObserver(() => {\n if (isInitialRender) {\n isInitialRender = false;\n lastDimensions = calculateDimensions();\n return;\n }\n\n const newDimensions = calculateDimensions();\n const widthDiff = Math.abs(lastDimensions.width - newDimensions.width);\n const heightDiff = Math.abs(lastDimensions.height - newDimensions.height);\n\n if (widthDiff < 10 && heightDiff < 10) return;\n\n lastDimensions = newDimensions;\n\n if (resizeTimeout !== null) clearTimeout(resizeTimeout);\n\n resizeTimeout = window.setTimeout(() => {\n if (sheetData) mountSpreadsheet();\n }, 500);\n });\n\n resizeObserver.observe(containerRef.value);\n\n setTimeout(() => {\n requestAnimationFrame(() => loadCsv());\n }, 100);\n});\n\nwatch(\n () => props.url,\n () => {\n loadCsv();\n }\n);\n\nonBeforeUnmount(() => {\n if (resizeObserver) resizeObserver.disconnect();\n if (resizeTimeout !== null) clearTimeout(resizeTimeout);\n sheetData = null;\n if (containerRef.value) containerRef.value.innerHTML = '';\n});\n</script>\n\n<template>\n <div class=\"vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full\">\n <div\n v-if=\"loading\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10\"\n >\n <div class=\"vfp-text-center\">\n <div\n class=\"vfp-w-10 vfp-h-10 md:vfp-w-12 md:vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\"\n />\n <p class=\"vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium\">{{ t('csv.loading') }}</p>\n </div>\n </div>\n\n <div\n v-if=\"error && !loading\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10\"\n >\n <div class=\"vfp-text-center vfp-max-w-sm md:vfp-max-w-md vfp-px-4\">\n <div\n class=\"vfp-w-24 vfp-h-24 md:vfp-w-32 md:vfp-h-32 vfp-mx-auto vfp-mb-4 md:vfp-mb-6 vfp-rounded-2xl md:vfp-rounded-3xl vfp-bg-gradient-to-br vfp-from-green-500 vfp-via-emerald-500 vfp-to-teal-500 vfp-flex vfp-items-center vfp-justify-center vfp-shadow-2xl\"\n >\n <FileSpreadsheet class=\"vfp-w-12 vfp-h-12 md:vfp-w-16 md:vfp-h-16 vfp-text-fg-primary\" />\n </div>\n <p class=\"vfp-text-lg md:vfp-text-xl vfp-text-fg-primary vfp-mb-2 md:vfp-mb-3 vfp-font-medium\">\n {{ t('csv.load_failed') }}\n </p>\n <p class=\"vfp-text-xs md:vfp-text-sm vfp-text-fg-tertiary vfp-mb-4 md:vfp-mb-6\">{{ error }}</p>\n </div>\n </div>\n\n <div\n v-if=\"!error\"\n ref=\"containerRef\"\n class=\"xlsx-spreadsheet-container vfp-w-full vfp-h-full\"\n :style=\"{ opacity: loading ? 0 : 1 }\"\n />\n </div>\n</template>\n"],"names":["props","__props","t","useTranslator","loading","ref","error","containerRef","sheetData","resizeObserver","resizeTimeout","lastDimensions","calculateDimensions","rawWidth","rawHeight","width","height","mountSpreadsheet","isMobile","Spreadsheet","loadCsv","text","fetchTextUtf8","parsed","parseCsv","guessCsvDelimiter","convertCsvToSpreadsheetData","err","onMounted","isInitialRender","newDimensions","widthDiff","heightDiff","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_hoisted_2","_createElementVNode","_hoisted_3","_hoisted_4","_toDisplayString","_unref","_hoisted_5","_hoisted_6","_hoisted_7","_createVNode","FileSpreadsheet","_hoisted_8","_hoisted_9"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,UAAMA,IAAQC,GAKR,EAAE,GAAAC,EAAA,IAAMC,EAAA,GAERC,IAAUC,EAAI,EAAI,GAClBC,IAAQD,EAAmB,IAAI,GAC/BE,IAAeF,EAA2B,IAAI;AACpD,QAAIG,IAA8C,MAC9CC,IAAwC,MACxCC,IAA+B,MAC/BC,IAAiB,EAAE,OAAO,GAAG,QAAQ,EAAA;AAEzC,UAAMC,IAAsB,MAAM;AAChC,UAAI,CAACL,EAAa,MAAO,QAAO,EAAE,OAAO,KAAK,QAAQ,IAAA;AACtD,YAAMM,IAAWN,EAAa,MAAM,aAC9BO,IAAYP,EAAa,MAAM,cAC/BQ,IAAQF,IAAW,MAAMA,IAAW,KACpCG,IAASF,IAAY,MAAMA,IAAY;AAC7C,aAAO,EAAE,OAAAC,GAAO,QAAAC,EAAA;AAAA,IAClB,GAEMC,IAAmB,MAAM;AAC7B,UAAI,CAACV,EAAa,SAAS,CAACC,E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JU,GAEIP,EADCC,EAAAzC,CAAA,EAAC,iBAAA,CAAA,GAAA,CAAA;AAAA,UAENqC,EAA+F,KAA/FW,GAA+FR,EAAZpC,EAAA,KAAK,GAAA,CAAA;AAAA,QAAA;;MAKnFA,EAAA,0BADT8B,EAKE,OAAA;AAAA;iBAHI;AAAA,QAAJ,KAAI7B;AAAA,QACJ,OAAM;AAAA,QACL,oBAAkBH,EAAA,QAAO,IAAA,GAAA;AAAA,MAAA;;;;"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineComponent as x, ref as p, onMounted as g, watch as k, onBeforeUnmount as b, openBlock as a, createElementBlock as d, createElementVNode as t, toDisplayString as c, unref as m, createCommentVNode as w } from "vue";
|
|
2
|
+
import j from "video.js";
|
|
3
|
+
import { u as T, a as h } from "./index-DpAxU2JM.mjs";
|
|
4
|
+
const C = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
7
|
+
}, D = { class: "vfp-text-center" }, B = { class: "vfp-text-lg vfp-font-medium vfp-text-fg-primary vfp-mb-2" }, E = { class: "vfp-text-sm vfp-text-fg-tertiary" }, L = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
10
|
+
}, P = { class: "vfp-w-full vfp-h-full vfp-relative" }, V = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-3 vfp-backdrop-blur-sm vfp-z-10"
|
|
13
|
+
}, q = { class: "vfp-text-center" }, N = { class: "vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, A = /* @__PURE__ */ x({
|
|
14
|
+
__name: "index",
|
|
15
|
+
props: {
|
|
16
|
+
url: {}
|
|
17
|
+
},
|
|
18
|
+
setup(y) {
|
|
19
|
+
const o = y, { t: s } = T(), n = p(null), f = p(!0), v = p(null);
|
|
20
|
+
let e = null;
|
|
21
|
+
return g(() => {
|
|
22
|
+
if (!v.value || e) return;
|
|
23
|
+
const l = document.createElement("video-js");
|
|
24
|
+
l.classList.add("vjs-big-play-centered", "vjs-theme-apple"), v.value.appendChild(l);
|
|
25
|
+
const r = h(o.url), _ = r === "video/quicktime" ? [
|
|
26
|
+
{ src: o.url, type: "video/quicktime" },
|
|
27
|
+
{ src: o.url, type: "video/mp4" }
|
|
28
|
+
] : [{ src: o.url, type: r }];
|
|
29
|
+
e = j(l, {
|
|
30
|
+
controls: !0,
|
|
31
|
+
fill: !0,
|
|
32
|
+
preload: "auto",
|
|
33
|
+
controlBar: {
|
|
34
|
+
children: [
|
|
35
|
+
"playToggle",
|
|
36
|
+
"volumePanel",
|
|
37
|
+
"currentTimeDisplay",
|
|
38
|
+
"timeDivider",
|
|
39
|
+
"durationDisplay",
|
|
40
|
+
"progressControl",
|
|
41
|
+
"remainingTimeDisplay",
|
|
42
|
+
"fullscreenToggle"
|
|
43
|
+
],
|
|
44
|
+
volumePanel: {
|
|
45
|
+
inline: !1
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
html5: {
|
|
49
|
+
vhs: {
|
|
50
|
+
overrideNative: !0
|
|
51
|
+
},
|
|
52
|
+
nativeVideoTracks: !1,
|
|
53
|
+
nativeAudioTracks: !1,
|
|
54
|
+
nativeTextTracks: !1
|
|
55
|
+
},
|
|
56
|
+
sources: _
|
|
57
|
+
});
|
|
58
|
+
const u = e.el().querySelector("video");
|
|
59
|
+
u && (u.style.objectFit = "contain"), e.on("loadeddata", () => {
|
|
60
|
+
f.value = !1;
|
|
61
|
+
}), e.on("error", () => {
|
|
62
|
+
const i = e == null ? void 0 : e.error();
|
|
63
|
+
console.error("Video.js error:", i), n.value = s.value("video.load_failed_with_error", { error: (i == null ? void 0 : i.message) || s.value("common.unknown_error") }), f.value = !1;
|
|
64
|
+
});
|
|
65
|
+
}), k(
|
|
66
|
+
() => o.url,
|
|
67
|
+
() => {
|
|
68
|
+
e && !e.isDisposed() && e.src({ src: o.url, type: h(o.url) });
|
|
69
|
+
}
|
|
70
|
+
), b(() => {
|
|
71
|
+
e && !e.isDisposed() && (e.dispose(), e = null);
|
|
72
|
+
}), (l, r) => n.value ? (a(), d("div", C, [
|
|
73
|
+
t("div", D, [
|
|
74
|
+
r[0] || (r[0] = t("div", { class: "vfp-w-16 vfp-h-16 vfp-mx-auto vfp-mb-4 vfp-rounded-full vfp-bg-red-500/10 vfp-flex vfp-items-center vfp-justify-center" }, [
|
|
75
|
+
t("svg", {
|
|
76
|
+
class: "vfp-w-8 vfp-h-8 vfp-text-red-400",
|
|
77
|
+
fill: "none",
|
|
78
|
+
viewBox: "0 0 24 24",
|
|
79
|
+
stroke: "currentColor"
|
|
80
|
+
}, [
|
|
81
|
+
t("path", {
|
|
82
|
+
"stroke-linecap": "round",
|
|
83
|
+
"stroke-linejoin": "round",
|
|
84
|
+
"stroke-width": "2",
|
|
85
|
+
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
86
|
+
})
|
|
87
|
+
])
|
|
88
|
+
], -1)),
|
|
89
|
+
t("p", B, c(m(s)("video.load_failed")), 1),
|
|
90
|
+
t("p", E, c(n.value), 1)
|
|
91
|
+
])
|
|
92
|
+
])) : (a(), d("div", L, [
|
|
93
|
+
t("div", P, [
|
|
94
|
+
f.value ? (a(), d("div", V, [
|
|
95
|
+
t("div", q, [
|
|
96
|
+
r[1] || (r[1] = t("div", { class: "vfp-w-12 vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)),
|
|
97
|
+
t("p", N, c(m(s)("video.loading")), 1)
|
|
98
|
+
])
|
|
99
|
+
])) : w("", !0),
|
|
100
|
+
t("div", {
|
|
101
|
+
ref_key: "videoContainerRef",
|
|
102
|
+
ref: v,
|
|
103
|
+
class: "vfp-overflow-hidden vfp-w-full vfp-h-full",
|
|
104
|
+
style: { "box-shadow": "0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)" }
|
|
105
|
+
}, null, 512)
|
|
106
|
+
])
|
|
107
|
+
]));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
export {
|
|
111
|
+
A as default
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=index-C8ZF84WX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C8ZF84WX.mjs","sources":["../../src/renderers/Video/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport videojs from 'video.js';\nimport 'video.js/dist/video-js.css';\nimport { getVideoMimeType } from '@eternalheart/file-preview-core';\nimport { useTranslator } from '../../composables/useTranslator';\n\ntype VideoJsPlayer = ReturnType<typeof videojs>;\n\nconst props = defineProps<{\n url: string;\n}>();\n\nconst { t } = useTranslator();\n\nconst error = ref<string | null>(null);\nconst isLoading = ref(true);\nconst videoContainerRef = ref<HTMLDivElement | null>(null);\nlet player: VideoJsPlayer | null = null;\n\nconst initPlayer = () => {\n if (!videoContainerRef.value || player) return;\n\n const videoElement = document.createElement('video-js');\n videoElement.classList.add('vjs-big-play-centered', 'vjs-theme-apple');\n videoContainerRef.value.appendChild(videoElement);\n\n const videoType = getVideoMimeType(props.url);\n\n const sources =\n videoType === 'video/quicktime'\n ? [\n { src: props.url, type: 'video/quicktime' },\n { src: props.url, type: 'video/mp4' },\n ]\n : [{ src: props.url, type: videoType }];\n\n player = videojs(videoElement, {\n controls: true,\n fill: true,\n preload: 'auto',\n controlBar: {\n children: [\n 'playToggle',\n 'volumePanel',\n 'currentTimeDisplay',\n 'timeDivider',\n 'durationDisplay',\n 'progressControl',\n 'remainingTimeDisplay',\n 'fullscreenToggle',\n ],\n volumePanel: {\n inline: false,\n },\n },\n html5: {\n vhs: {\n overrideNative: true,\n },\n nativeVideoTracks: false,\n nativeAudioTracks: false,\n nativeTextTracks: false,\n },\n sources,\n });\n\n const videoEl = player.el().querySelector('video');\n if (videoEl) {\n (videoEl as HTMLVideoElement).style.objectFit = 'contain';\n }\n\n player.on('loadeddata', () => {\n isLoading.value = false;\n });\n\n player.on('error', () => {\n const err = player?.error();\n console.error('Video.js error:', err);\n error.value = t.value('video.load_failed_with_error', { error: err?.message || t.value('common.unknown_error') });\n isLoading.value = false;\n });\n};\n\nonMounted(initPlayer);\n\nwatch(\n () => props.url,\n () => {\n if (player && !player.isDisposed()) {\n player.src({ src: props.url, type: getVideoMimeType(props.url) });\n }\n }\n);\n\nonBeforeUnmount(() => {\n if (player && !player.isDisposed()) {\n player.dispose();\n player = null;\n }\n});\n</script>\n\n<template>\n <div v-if=\"error\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div class=\"vfp-text-center\">\n <div\n class=\"vfp-w-16 vfp-h-16 vfp-mx-auto vfp-mb-4 vfp-rounded-full vfp-bg-red-500/10 vfp-flex vfp-items-center vfp-justify-center\"\n >\n <svg\n class=\"vfp-w-8 vfp-h-8 vfp-text-red-400\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <p class=\"vfp-text-lg vfp-font-medium vfp-text-fg-primary vfp-mb-2\">{{ t('video.load_failed') }}</p>\n <p class=\"vfp-text-sm vfp-text-fg-tertiary\">{{ error }}</p>\n </div>\n </div>\n\n <div v-else class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div class=\"vfp-w-full vfp-h-full vfp-relative\">\n <div\n v-if=\"isLoading\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-3 vfp-backdrop-blur-sm vfp-z-10\"\n >\n <div class=\"vfp-text-center\">\n <div\n class=\"vfp-w-12 vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\"\n />\n <p class=\"vfp-text-sm vfp-text-fg-secondary vfp-font-medium\">{{ t('video.loading') }}</p>\n </div>\n </div>\n\n <div\n ref=\"videoContainerRef\"\n class=\"vfp-overflow-hidden vfp-w-full vfp-h-full\"\n style=\"box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)\"\n />\n </div>\n </div>\n</template>\n"],"names":["props","__props","t","useTranslator","error","ref","isLoading","videoContainerRef","player","onMounted","videoElement","videoType","getVideoMimeType","sources","videojs","videoEl","err","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","_toDisplayString","_unref","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9"],"mappings":";;;;;;;;;;;;;;;;;;AASA,UAAMA,IAAQC,GAIR,EAAE,GAAAC,EAAA,IAAMC,EAAA,GAERC,IAAQC,EAAmB,IAAI,GAC/BC,IAAYD,EAAI,EAAI,GACpBE,IAAoBF,EAA2B,IAAI;AACzD,QAAIG,IAA+B;AAkEnC,WAAAC,EAhEmB,MAAM;AACvB,UAAI,CAACF,EAAkB,SAASC,EAAQ;AAExC,YAAME,IAAe,SAAS,cAAc,UAAU;AACtD,MAAAA,EAAa,UAAU,IAAI,yBAAyB,iBAAiB,GACrEH,EAAkB,MAAM,YAAYG,CAAY;AAEhD,YAAMC,IAAYC,EAAiBZ,EAAM,GAAG,GAEtCa,IACJF,MAAc,oBACV;AAAA,Q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