@eternalheart/vue-file-preview 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/lib/FilePreviewContent.vue.d.ts +9 -1
- package/lib/FilePreviewEmbed.vue.d.ts +6 -1
- package/lib/FilePreviewModal.vue.d.ts +6 -1
- package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs → EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs} +1 -1
- package/lib/chunks/{avifLoader-CAUzjn-d-CnJpGYJ2.mjs → avifLoader-CAUzjn-d-Cf00sjt2.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-g_dLrWLP.mjs → heicLoader-D_9PukkA-cn1P7b2x.mjs} +1 -1
- package/lib/chunks/{index-C8lyQPe3.mjs → index-0VXtKKev.mjs} +3 -3
- package/lib/chunks/index-0fXL30y0.mjs +333 -0
- package/lib/chunks/{index-CWPdNhoe.mjs → index-B1AwVHWI.mjs} +60 -60
- package/lib/chunks/{index-C4hIk6pa.mjs → index-B77rFiau.mjs} +2 -2
- package/lib/chunks/{index-BzwJ0VWu.mjs → index-BB10as16.mjs} +33 -33
- package/lib/chunks/{index-BfOWoMpY.mjs → index-BBIn-k4u.mjs} +77 -77
- package/lib/chunks/{index-6XZXYqbp.mjs → index-BSzaI9ea.mjs} +29 -32
- package/lib/chunks/{index-Bg8poMIm.mjs → index-BZvy39tn.mjs} +29 -29
- package/lib/chunks/{index-zLQlyNR2.mjs → index-BlJEM2Lb.mjs} +62 -62
- package/lib/chunks/{index-z9RqL2wI.mjs → index-CZlnxQFA.mjs} +453 -453
- package/lib/chunks/{index-BPSzwMOC.mjs → index-ClhTPqDI.mjs} +46 -46
- package/lib/chunks/{index-Bf94DwQu.mjs → index-D690gnNu.mjs} +24 -24
- package/lib/chunks/index-D7WykPYL.mjs +51 -0
- package/lib/chunks/{index-c-pYJEmH.mjs → index-DBzyeU0G.mjs} +1028 -989
- package/lib/chunks/{index-LPGxJDnT.mjs → index-DKFX5ToE.mjs} +18 -18
- package/lib/chunks/{index-aKiIuKKx.mjs → index-DRmKaFXK.mjs} +50 -50
- package/lib/chunks/{index-D5IF9F-D.mjs → index-DXf3wXT5.mjs} +22 -22
- package/lib/chunks/{index-CrVQPnFj.mjs → index-Dp7QQjNH.mjs} +18 -18
- package/lib/chunks/{index-BYQ9S7Mk.mjs → index-FzI__DHC.mjs} +30 -30
- package/lib/chunks/{index-DZe0BxAB.mjs → index-PWjCziZG.mjs} +20 -20
- package/lib/chunks/{index-DM8Dfl-m.mjs → index-bT6XWKO_.mjs} +15 -15
- package/lib/chunks/{index-DFeKS8tR.mjs → index-tX9VR6Vo.mjs} +22 -22
- package/lib/chunks/{jp2Loader-Dig19xyo-fCO1knZ0.mjs → jp2Loader-Dig19xyo-D-OEDL3n.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-DihMskai.mjs → psdLoader-C0tKUXXl-CVN06LUc.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-BSfDPl-z.mjs → rawLoader-C-tPeFAB-DBqcJPFK.mjs} +1 -1
- package/lib/chunks/{tiffLoader-BlhByX8w-JY5DaTre.mjs → tiffLoader-BlhByX8w-8-0icdyL.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-C-ztcJBE.mjs → useShikiHighlight-a_GUszuU.mjs} +1 -1
- package/lib/composables/usePreviewEvents.d.ts +2 -2
- package/lib/core/events.d.ts +18 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/index.cjs +48 -48
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +5 -5
- package/package.json +1 -1
- package/lib/chunks/index-C41YET0_.mjs +0 -51
- package/lib/chunks/index-GFcSJEwj.mjs +0 -330
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as h, ref as c, onMounted as w, watch as x, onBeforeUnmount as E, openBlock as f, createBlock as C, createElementBlock as _, createElementVNode as a, toDisplayString as
|
|
2
|
-
import
|
|
3
|
-
import { u as
|
|
4
|
-
import { _ as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as h, ref as c, onMounted as w, watch as x, onBeforeUnmount as E, openBlock as f, createBlock as C, createElementBlock as _, createElementVNode as a, toDisplayString as B, unref as D, createCommentVNode as P } from "vue";
|
|
2
|
+
import N from "video.js";
|
|
3
|
+
import { u as R, b as S, B as y } from "./index-DBzyeU0G.mjs";
|
|
4
|
+
import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
const V = {
|
|
6
6
|
key: 1,
|
|
7
7
|
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
8
|
-
},
|
|
8
|
+
}, j = { class: "vfp-w-full vfp-h-full vfp-relative" }, q = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-3 vfp-backdrop-blur-sm vfp-z-10"
|
|
11
11
|
}, L = { class: "vfp-renderer-loading-content" }, G = { class: "vfp-renderer-loading-text" }, X = /* @__PURE__ */ h({
|
|
@@ -16,20 +16,20 @@ const U = {
|
|
|
16
16
|
mimeType: {}
|
|
17
17
|
},
|
|
18
18
|
setup(g, { expose: k }) {
|
|
19
|
-
const o = g, { t } =
|
|
19
|
+
const o = g, { t } = R(), u = S(), T = /* @__PURE__ */ new Set(["avi", "wmv", "flv"]), i = c(null), d = c(!0), p = c(null);
|
|
20
20
|
let e = null;
|
|
21
21
|
const b = (s, r) => {
|
|
22
22
|
var n;
|
|
23
23
|
return ((n = (r || s).split(".").pop()) == null ? void 0 : n.toLowerCase().split("?")[0]) || "";
|
|
24
24
|
};
|
|
25
25
|
return w(() => {
|
|
26
|
-
if (
|
|
26
|
+
if (u.begin(o.url), !p.value || e) return;
|
|
27
27
|
const s = b(o.url, o.fileName);
|
|
28
28
|
if (T.has(s)) {
|
|
29
29
|
i.value = {
|
|
30
30
|
title: t.value("video.unsupported_title"),
|
|
31
31
|
detail: t.value("video.unsupported_detail", { format: s.toUpperCase() })
|
|
32
|
-
},
|
|
32
|
+
}, d.value = !1;
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const r = document.createElement("video-js");
|
|
@@ -39,7 +39,7 @@ const U = {
|
|
|
39
39
|
v === "video/quicktime" ? n = [
|
|
40
40
|
{ src: o.url, type: "video/quicktime" },
|
|
41
41
|
{ src: o.url, type: "video/mp4" }
|
|
42
|
-
] : n = [{ src: o.url, type: v }], e =
|
|
42
|
+
] : n = [{ src: o.url, type: v }], e = N(r, {
|
|
43
43
|
controls: !0,
|
|
44
44
|
fill: !0,
|
|
45
45
|
preload: "auto",
|
|
@@ -69,7 +69,7 @@ const U = {
|
|
|
69
69
|
});
|
|
70
70
|
const m = e.el().querySelector("video");
|
|
71
71
|
m && (m.style.objectFit = "contain"), e.on("loadeddata", () => {
|
|
72
|
-
|
|
72
|
+
d.value = !1, u.ready();
|
|
73
73
|
}), e.on("error", () => {
|
|
74
74
|
const l = e == null ? void 0 : e.error();
|
|
75
75
|
console.warn("[VideoRenderer] Video playback error:", (l == null ? void 0 : l.message) || "Unknown error"), (l == null ? void 0 : l.code) === 4 ? i.value = {
|
|
@@ -80,27 +80,27 @@ const U = {
|
|
|
80
80
|
} : i.value = {
|
|
81
81
|
title: t.value("video.load_failed"),
|
|
82
82
|
detail: (l == null ? void 0 : l.message) || t.value("common.unknown_error")
|
|
83
|
-
},
|
|
83
|
+
}, d.value = !1, u.error(l ?? new Error("video load failed"), (l == null ? void 0 : l.code) === 2 ? "request" : "parse");
|
|
84
84
|
});
|
|
85
85
|
}), x(
|
|
86
86
|
[() => o.url, () => o.mimeType],
|
|
87
87
|
() => {
|
|
88
|
-
|
|
88
|
+
u.begin(o.url), e && !e.isDisposed() && e.src({ src: o.url, type: y(o.url, o.mimeType) });
|
|
89
89
|
}
|
|
90
90
|
), E(() => {
|
|
91
91
|
e && !e.isDisposed() && (e.dispose(), e = null);
|
|
92
92
|
}), k({
|
|
93
93
|
getToolbarGroups: () => []
|
|
94
|
-
}), (s, r) => i.value ? (f(), C(
|
|
94
|
+
}), (s, r) => i.value ? (f(), C(U, {
|
|
95
95
|
key: 0,
|
|
96
96
|
message: i.value.title,
|
|
97
97
|
detail: i.value.detail
|
|
98
|
-
}, null, 8, ["message", "detail"])) : (f(), _("div",
|
|
99
|
-
a("div",
|
|
100
|
-
|
|
98
|
+
}, null, 8, ["message", "detail"])) : (f(), _("div", V, [
|
|
99
|
+
a("div", j, [
|
|
100
|
+
d.value ? (f(), _("div", q, [
|
|
101
101
|
a("div", L, [
|
|
102
102
|
r[0] || (r[0] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
103
|
-
a("p", G,
|
|
103
|
+
a("p", G, B(D(t)("video.loading")), 1)
|
|
104
104
|
])
|
|
105
105
|
])) : P("", !0),
|
|
106
106
|
a("div", {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { u as G, a as J, b as U,
|
|
3
|
-
import { init as
|
|
1
|
+
import { defineComponent as V, ref as v, onMounted as q, watch as A, onBeforeUnmount as I, computed as O, openBlock as p, createElementBlock as h, createElementVNode as k, toDisplayString as S, unref as C, createCommentVNode as b, createVNode as z, normalizeStyle as $ } from "vue";
|
|
2
|
+
import { u as G, a as J, b as U, T as j, J as D, R as K, p as Q } from "./index-DBzyeU0G.mjs";
|
|
3
|
+
import { init as M } from "pptx-preview";
|
|
4
4
|
import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
-
import { _ as Y } from "./EmptyState.vue_vue_type_script_setup_true_lang
|
|
5
|
+
import { _ as Y } from "./EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs";
|
|
6
6
|
const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, ee = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "vfp-renderer-overlay vfp-renderer-loading"
|
|
@@ -12,23 +12,23 @@ const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
12
12
|
}, le = {
|
|
13
13
|
key: 2,
|
|
14
14
|
class: "vfp-renderer-overlay"
|
|
15
|
-
}, de = /* @__PURE__ */
|
|
15
|
+
}, de = /* @__PURE__ */ V({
|
|
16
16
|
__name: "index",
|
|
17
17
|
props: {
|
|
18
18
|
url: {},
|
|
19
19
|
tiled: { type: Boolean, default: !0 },
|
|
20
20
|
emptyHint: {}
|
|
21
21
|
},
|
|
22
|
-
setup(H, { expose:
|
|
23
|
-
const o = H, { t: s } = G(),
|
|
24
|
-
let l = null,
|
|
25
|
-
const
|
|
22
|
+
setup(H, { expose: W }) {
|
|
23
|
+
const o = H, { t: s } = G(), P = J(), m = U(), n = v(!0), u = v(null), w = v(!1), y = v(0), i = v(null);
|
|
24
|
+
let l = null, _ = null, c = null, f = null, g = { width: 0, height: 0 }, R = 9 / 16;
|
|
25
|
+
const x = () => {
|
|
26
26
|
var d;
|
|
27
27
|
if (!i.value) return { width: 960, height: 540 };
|
|
28
|
-
const t = i.value.clientWidth, e = ((d = i.value.parentElement) == null ? void 0 : d.clientWidth) || 0, r = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(r *
|
|
28
|
+
const t = i.value.clientWidth, e = ((d = i.value.parentElement) == null ? void 0 : d.clientWidth) || 0, r = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(r * R);
|
|
29
29
|
return { width: r, height: a };
|
|
30
|
-
},
|
|
31
|
-
if (!(!i.value || !c ||
|
|
30
|
+
}, F = async () => {
|
|
31
|
+
if (!(!i.value || !c || y.value === 0))
|
|
32
32
|
try {
|
|
33
33
|
if (l)
|
|
34
34
|
try {
|
|
@@ -36,38 +36,38 @@ const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
36
36
|
} catch {
|
|
37
37
|
}
|
|
38
38
|
i.value.innerHTML = "";
|
|
39
|
-
const t =
|
|
40
|
-
l =
|
|
39
|
+
const t = x();
|
|
40
|
+
l = M(i.value, {
|
|
41
41
|
width: t.width,
|
|
42
|
-
height: o.tiled ? t.height *
|
|
42
|
+
height: o.tiled ? t.height * y.value : t.height,
|
|
43
43
|
mode: o.tiled ? "list" : "slide"
|
|
44
44
|
}), await l.preview(c);
|
|
45
45
|
} catch {
|
|
46
46
|
}
|
|
47
|
-
},
|
|
48
|
-
if (
|
|
49
|
-
n.value = !0, u.value = null,
|
|
47
|
+
}, B = async () => {
|
|
48
|
+
if (m.begin(o.url), !i.value) return;
|
|
49
|
+
n.value = !0, u.value = null, w.value = !1;
|
|
50
50
|
let t = window.setTimeout(() => {
|
|
51
51
|
u.value = s.value("pptx.timeout"), n.value = !1;
|
|
52
52
|
}, 3e4);
|
|
53
53
|
try {
|
|
54
|
-
const e = await
|
|
54
|
+
const e = await P.value(o.url, {
|
|
55
55
|
mode: "cors",
|
|
56
56
|
credentials: "omit",
|
|
57
57
|
redirect: "follow"
|
|
58
58
|
});
|
|
59
59
|
if (!e.ok)
|
|
60
|
-
throw e.status === 404 ? new Error(s.value("pptx.not_found")) : e.status === 403 ? new
|
|
60
|
+
throw e.status === 404 ? new Error(s.value("pptx.not_found")) : e.status === 403 ? new D("file.forbidden") : e.status >= 500 ? new D("file.server_error") : new D("file.load_failed_status", { status: e.status });
|
|
61
61
|
const r = await e.arrayBuffer();
|
|
62
62
|
if (r.byteLength === 0) {
|
|
63
|
-
t !== null && clearTimeout(t),
|
|
63
|
+
t !== null && clearTimeout(t), w.value = !0, n.value = !1, m.ready();
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
c = r,
|
|
66
|
+
c = r, R = (await K(r)).ratio;
|
|
67
67
|
const a = document.createElement("div");
|
|
68
68
|
a.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(a);
|
|
69
69
|
try {
|
|
70
|
-
const d =
|
|
70
|
+
const d = M(a, {
|
|
71
71
|
width: 100,
|
|
72
72
|
height: 100,
|
|
73
73
|
mode: "slide"
|
|
@@ -77,68 +77,68 @@ const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
77
77
|
} catch {
|
|
78
78
|
throw new Error(s.value("pptx.invalid_format"));
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
d.destroy(),
|
|
83
|
-
const
|
|
84
|
-
l =
|
|
85
|
-
width:
|
|
86
|
-
height: o.tiled ?
|
|
80
|
+
const T = d.slideCount;
|
|
81
|
+
if (!T || T === 0) throw new Error(s.value("pptx.no_pages"));
|
|
82
|
+
d.destroy(), y.value = T, i.value && (i.value.innerHTML = "");
|
|
83
|
+
const E = x();
|
|
84
|
+
l = M(i.value, {
|
|
85
|
+
width: E.width,
|
|
86
|
+
height: o.tiled ? E.height * T : E.height,
|
|
87
87
|
mode: o.tiled ? "list" : "slide"
|
|
88
|
-
}), await l.preview(r), t !== null && (clearTimeout(t), t = null), n.value = !1;
|
|
88
|
+
}), await l.preview(r), t !== null && (clearTimeout(t), t = null), n.value = !1, m.ready();
|
|
89
89
|
} finally {
|
|
90
90
|
document.body.contains(a) && document.body.removeChild(a);
|
|
91
91
|
}
|
|
92
92
|
} catch (e) {
|
|
93
93
|
t !== null && clearTimeout(t);
|
|
94
94
|
let r = s.value("pptx.parse_failed");
|
|
95
|
-
e instanceof Error ? r = Q(s.value, e) : typeof e == "string" && (r = e), u.value = r, n.value = !1,
|
|
95
|
+
e instanceof Error ? r = Q(s.value, e) : typeof e == "string" && (r = e), u.value = r, n.value = !1, m.error(e);
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
q(() => {
|
|
99
99
|
if (!i.value) return;
|
|
100
100
|
let t = !0;
|
|
101
|
-
|
|
101
|
+
_ = new ResizeObserver(() => {
|
|
102
102
|
if (t) {
|
|
103
|
-
t = !1,
|
|
103
|
+
t = !1, g = x();
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
const e =
|
|
107
|
-
r < 10 && a < 10 || (
|
|
108
|
-
l && c &&
|
|
106
|
+
const e = x(), r = Math.abs(g.width - e.width), a = Math.abs(g.height - e.height);
|
|
107
|
+
r < 10 && a < 10 || (g = e, f !== null && clearTimeout(f), f = window.setTimeout(() => {
|
|
108
|
+
l && c && F();
|
|
109
109
|
}, 800));
|
|
110
|
-
}),
|
|
111
|
-
requestAnimationFrame(() => requestAnimationFrame(() =>
|
|
110
|
+
}), _.observe(i.value), setTimeout(() => {
|
|
111
|
+
requestAnimationFrame(() => requestAnimationFrame(() => B()));
|
|
112
112
|
}, 150);
|
|
113
113
|
}), A(
|
|
114
114
|
() => o.url,
|
|
115
115
|
(t) => {
|
|
116
|
-
t &&
|
|
116
|
+
t && B();
|
|
117
117
|
}
|
|
118
118
|
), I(() => {
|
|
119
|
-
if (
|
|
119
|
+
if (_ && _.disconnect(), f !== null && clearTimeout(f), c = null, y.value = 0, l)
|
|
120
120
|
try {
|
|
121
121
|
l.destroy();
|
|
122
122
|
} catch {
|
|
123
123
|
}
|
|
124
124
|
l = null;
|
|
125
125
|
});
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
getToolbarGroups:
|
|
126
|
+
const L = () => [], N = O(() => j(o.emptyHint, "structured"));
|
|
127
|
+
return W({
|
|
128
|
+
getToolbarGroups: L
|
|
129
129
|
}), (t, e) => (p(), h("div", Z, [
|
|
130
130
|
n.value ? (p(), h("div", ee, [
|
|
131
|
-
|
|
132
|
-
e[0] || (e[0] =
|
|
133
|
-
|
|
131
|
+
k("div", te, [
|
|
132
|
+
e[0] || (e[0] = k("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
133
|
+
k("p", re, S(C(s)("pptx.loading")), 1)
|
|
134
134
|
])
|
|
135
135
|
])) : b("", !0),
|
|
136
|
-
|
|
136
|
+
w.value && !n.value && N.value ? (p(), h("div", ie, [
|
|
137
137
|
z(Y)
|
|
138
138
|
])) : b("", !0),
|
|
139
139
|
u.value && !n.value ? (p(), h("div", le, [
|
|
140
140
|
z(X, {
|
|
141
|
-
message:
|
|
141
|
+
message: C(s)("pptx.load_failed"),
|
|
142
142
|
detail: u.value
|
|
143
143
|
}, null, 8, ["message", "detail"])
|
|
144
144
|
])) : b("", !0),
|
|
@@ -147,7 +147,7 @@ const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
147
147
|
ref_key: "containerRef",
|
|
148
148
|
ref: i,
|
|
149
149
|
class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
|
|
150
|
-
style: $({ opacity: n.value ||
|
|
150
|
+
style: $({ opacity: n.value || w.value ? 0 : 1 })
|
|
151
151
|
}, null, 4))
|
|
152
152
|
]));
|
|
153
153
|
}
|
|
@@ -3,13 +3,13 @@ import F from "markdown-it";
|
|
|
3
3
|
import W from "@traptitech/markdown-it-katex";
|
|
4
4
|
import { codeToHtml as L } from "shiki";
|
|
5
5
|
import { Code as z, Eye as J } from "lucide-vue-next";
|
|
6
|
-
import { u as Q, a as U, b as X,
|
|
6
|
+
import { u as Q, a as U, b as X, e as Z, f as ee, d as te } from "./index-DBzyeU0G.mjs";
|
|
7
7
|
import { _ as oe } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
8
8
|
import { T as re } from "./base.types-DaftHyg7.mjs";
|
|
9
9
|
const ne = {
|
|
10
10
|
key: 0,
|
|
11
11
|
class: "vfp-renderer-loading"
|
|
12
|
-
}, se = { class: "vfp-renderer-loading-content" },
|
|
12
|
+
}, se = { class: "vfp-renderer-loading-content" }, ae = { class: "vfp-renderer-loading-text" }, le = {
|
|
13
13
|
key: 2,
|
|
14
14
|
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
15
15
|
style: { background: "var(--fp-code-bg)" }
|
|
@@ -25,9 +25,9 @@ const ne = {
|
|
|
25
25
|
url: {}
|
|
26
26
|
},
|
|
27
27
|
setup(G, { expose: $ }) {
|
|
28
|
-
const _ = G,
|
|
28
|
+
const _ = G, T = new re(), { t: l } = Q(), j = U(), b = X(), A = Z(), x = O(() => A.value === "light" ? "github-light" : "github-dark"), c = i("preview"), C = i(""), v = i(""), h = i(""), u = i(!0), f = i(null), m = i(null);
|
|
29
29
|
k([c, u], () => {
|
|
30
|
-
|
|
30
|
+
T.notify();
|
|
31
31
|
}), $({
|
|
32
32
|
getToolbarGroups: () => {
|
|
33
33
|
const e = [];
|
|
@@ -36,7 +36,7 @@ const ne = {
|
|
|
36
36
|
{
|
|
37
37
|
type: "button",
|
|
38
38
|
icon: c.value === "preview" ? z : J,
|
|
39
|
-
tooltip: c.value === "preview" ?
|
|
39
|
+
tooltip: c.value === "preview" ? l.value("toolbar.source") : l.value("toolbar.preview"),
|
|
40
40
|
action: () => {
|
|
41
41
|
c.value = c.value === "preview" ? "source" : "preview";
|
|
42
42
|
},
|
|
@@ -45,7 +45,7 @@ const ne = {
|
|
|
45
45
|
]
|
|
46
46
|
}), e;
|
|
47
47
|
},
|
|
48
|
-
onToolbarChange: (e) =>
|
|
48
|
+
onToolbarChange: (e) => T.subscribe(e)
|
|
49
49
|
});
|
|
50
50
|
const s = new F({
|
|
51
51
|
html: !0,
|
|
@@ -74,21 +74,21 @@ const ne = {
|
|
|
74
74
|
const I = s.renderer.rules.table_close || ((e, r, t, n, o) => o.renderToken(e, r, t));
|
|
75
75
|
s.renderer.rules.table_close = (e, r, t, n, o) => I(e, r, t, n, o) + "</div>";
|
|
76
76
|
const M = async () => {
|
|
77
|
-
|
|
77
|
+
b.begin(_.url), u.value = !0, f.value = null;
|
|
78
78
|
try {
|
|
79
79
|
const e = await ee(_.url, { fetcher: j.value });
|
|
80
|
-
|
|
80
|
+
C.value = e, v.value = s.render(e), u.value = !1, b.ready();
|
|
81
81
|
try {
|
|
82
|
-
h.value = await L(e, { lang: "markdown", theme:
|
|
82
|
+
h.value = await L(e, { lang: "markdown", theme: x.value });
|
|
83
83
|
} catch {
|
|
84
84
|
h.value = "";
|
|
85
85
|
}
|
|
86
86
|
} catch (e) {
|
|
87
|
-
console.error(e), f.value =
|
|
87
|
+
console.error(e), f.value = l.value("markdown.load_failed"), u.value = !1, b.error(e);
|
|
88
88
|
}
|
|
89
89
|
}, S = (e, r) => {
|
|
90
90
|
const t = document.createElement("button");
|
|
91
|
-
return t.type = "button", t.className = r ? "code-copy-btn" : "code-copy-btn code-copy-float", t.title =
|
|
91
|
+
return t.type = "button", t.className = r ? "code-copy-btn" : "code-copy-btn code-copy-float", t.title = l.value("markdown.copy_code"), t.innerHTML = r ? q : V, t.addEventListener("click", async (n) => {
|
|
92
92
|
n.stopPropagation();
|
|
93
93
|
try {
|
|
94
94
|
await navigator.clipboard.writeText(e);
|
|
@@ -96,8 +96,8 @@ const ne = {
|
|
|
96
96
|
const o = document.createElement("textarea");
|
|
97
97
|
o.value = e, document.body.appendChild(o), o.select(), document.execCommand("copy"), document.body.removeChild(o);
|
|
98
98
|
}
|
|
99
|
-
t.innerHTML = r ? pe : ve, t.title =
|
|
100
|
-
t.innerHTML = r ? q : V, t.title =
|
|
99
|
+
t.innerHTML = r ? pe : ve, t.title = l.value("markdown.copied"), setTimeout(() => {
|
|
100
|
+
t.innerHTML = r ? q : V, t.title = l.value("markdown.copy_code");
|
|
101
101
|
}, 2e3);
|
|
102
102
|
}), t;
|
|
103
103
|
}, D = async () => {
|
|
@@ -105,9 +105,9 @@ const ne = {
|
|
|
105
105
|
if (!m.value) return;
|
|
106
106
|
const e = m.value.querySelectorAll('pre[data-shiki-pending="1"]');
|
|
107
107
|
for (const o of e) {
|
|
108
|
-
const w = o.getAttribute("data-lang") || "text",
|
|
108
|
+
const w = o.getAttribute("data-lang") || "text", a = ((t = o.querySelector("code")) == null ? void 0 : t.textContent) || "";
|
|
109
109
|
try {
|
|
110
|
-
const g = await L(
|
|
110
|
+
const g = await L(a, { lang: w, theme: x.value }), H = document.createElement("div");
|
|
111
111
|
H.innerHTML = g;
|
|
112
112
|
const E = H.firstElementChild;
|
|
113
113
|
E && o.replaceWith(E);
|
|
@@ -118,28 +118,28 @@ const ne = {
|
|
|
118
118
|
const r = m.value.querySelectorAll(".code-block-wrapper");
|
|
119
119
|
for (const o of r) {
|
|
120
120
|
if (o.querySelector(".code-copy-btn")) continue;
|
|
121
|
-
const w = o.querySelector(".code-block-header"),
|
|
121
|
+
const w = o.querySelector(".code-block-header"), a = o.querySelector("pre"), g = ((n = a == null ? void 0 : a.querySelector("code")) == null ? void 0 : n.textContent) ?? (a == null ? void 0 : a.textContent) ?? "";
|
|
122
122
|
w ? w.appendChild(S(g, !0)) : o.appendChild(S(g, !1));
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
return k(() => _.url, M, { immediate: !0 }), k(v, async () => {
|
|
126
126
|
v.value && (await R(), D());
|
|
127
|
-
}), k(
|
|
128
|
-
|
|
127
|
+
}), k(x, () => {
|
|
128
|
+
C.value && M();
|
|
129
129
|
}), (e, r) => u.value ? (d(), p("div", ne, [
|
|
130
130
|
y("div", se, [
|
|
131
131
|
r[0] || (r[0] = y("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
132
|
-
y("span",
|
|
132
|
+
y("span", ae, B(N(l)("common.loading")), 1)
|
|
133
133
|
])
|
|
134
134
|
])) : f.value ? (d(), Y(oe, {
|
|
135
135
|
key: 1,
|
|
136
136
|
message: f.value
|
|
137
|
-
}, null, 8, ["message"])) : c.value === "source" ? (d(), p("div",
|
|
137
|
+
}, null, 8, ["message"])) : c.value === "source" ? (d(), p("div", le, [
|
|
138
138
|
h.value ? (d(), p("div", {
|
|
139
139
|
key: 1,
|
|
140
140
|
class: "shiki-wrapper",
|
|
141
141
|
innerHTML: h.value
|
|
142
|
-
}, null, 8, ie)) : (d(), p("pre", ce, B(
|
|
142
|
+
}, null, 8, ie)) : (d(), p("pre", ce, B(C.value), 1))
|
|
143
143
|
])) : (d(), p("div", de, [
|
|
144
144
|
y("div", {
|
|
145
145
|
ref_key: "containerRef",
|
|
@@ -149,7 +149,7 @@ const ne = {
|
|
|
149
149
|
}, null, 8, ue)
|
|
150
150
|
]));
|
|
151
151
|
}
|
|
152
|
-
}), Ce = /* @__PURE__ */ te(he, [["__scopeId", "data-v-
|
|
152
|
+
}), Ce = /* @__PURE__ */ te(he, [["__scopeId", "data-v-67620d24"]]);
|
|
153
153
|
export {
|
|
154
154
|
Ce as default
|
|
155
155
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as re, ref as z, onMounted as se, onUnmounted as ae, watch as le, openBlock as
|
|
2
|
-
import { u as ce, a as pe, b as me, J as ve } from "./index-
|
|
1
|
+
import { defineComponent as re, ref as z, onMounted as se, onUnmounted as ae, watch as le, openBlock as U, createElementBlock as V, createVNode as fe, createCommentVNode as q, createElementVNode as k, toDisplayString as ue, unref as de } from "vue";
|
|
2
|
+
import { u as ce, a as pe, b as me, J as ve } from "./index-DBzyeU0G.mjs";
|
|
3
3
|
import * as o from "three";
|
|
4
4
|
import { OrbitControls as ge } from "three/examples/jsm/controls/OrbitControls";
|
|
5
5
|
import { DXFLoader as he } from "three-dxf-loader";
|
|
@@ -84,7 +84,7 @@ const Ae = {
|
|
|
84
84
|
} catch {
|
|
85
85
|
return "";
|
|
86
86
|
}
|
|
87
|
-
},
|
|
87
|
+
}, W = (e, t, i, s) => {
|
|
88
88
|
const c = Math.max(s.x, s.y, s.z), g = Number.isFinite(c) && c > 0 ? c : 1;
|
|
89
89
|
if (e instanceof o.OrthographicCamera) {
|
|
90
90
|
const l = (e.right - e.left) / (e.top - e.bottom), h = (Math.max(s.y, s.x / l) || g) * 0.55;
|
|
@@ -93,15 +93,15 @@ const Ae = {
|
|
|
93
93
|
}
|
|
94
94
|
const n = e.fov * (Math.PI / 180), a = Math.abs(g / 2 / Math.tan(n / 2)) * 1.5;
|
|
95
95
|
e.near = Math.max(g * 1e-3, 1e-4), e.far = Math.max(a * 4, i.length() * 2 + g * 4, e.near * 100), e.position.set(i.x + a, i.y + a, i.z + a), e.lookAt(i), t.target.copy(i), t.update(), e.updateProjectionMatrix();
|
|
96
|
-
}, v = m, { t: A } = ce(), Y = pe(),
|
|
96
|
+
}, v = m, { t: A } = ce(), Y = pe(), N = me(), x = z(null), P = z(!0), _ = z(null), T = z(!1), F = z(!0), G = z(!0);
|
|
97
97
|
let r = null, f = null, d = null, u = null, C = null, p = null, w = null, R = null, D = null, S = null, M = !1, L = !0;
|
|
98
|
-
const O = new xe(),
|
|
98
|
+
const O = new xe(), H = (e, t, i) => {
|
|
99
99
|
var s, c, g;
|
|
100
100
|
return i != null && i.name ? ((s = i.name.split(".").pop()) == null ? void 0 : s.toLowerCase()) || "" : t ? ((c = t.split(".").pop()) == null ? void 0 : c.toLowerCase()) || "" : ((g = e.split(".").pop()) == null ? void 0 : g.toLowerCase().split("?")[0]) || "";
|
|
101
101
|
}, Z = () => {
|
|
102
102
|
if (!u || !f || !C) return;
|
|
103
103
|
const e = new o.Box3().setFromObject(C), t = e.getCenter(new o.Vector3()), i = e.getSize(new o.Vector3());
|
|
104
|
-
|
|
104
|
+
W(f, u, t, i), L = !0;
|
|
105
105
|
}, $ = () => {
|
|
106
106
|
T.value = !T.value, C && C.traverse((e) => {
|
|
107
107
|
if (e instanceof o.Mesh) {
|
|
@@ -130,7 +130,7 @@ const Ae = {
|
|
|
130
130
|
b({
|
|
131
131
|
getToolbarGroups: () => _e({
|
|
132
132
|
cadRef: { resetView: Z, toggleWireframe: $, toggleGrid: K, toggleAxes: Q },
|
|
133
|
-
isDxf:
|
|
133
|
+
isDxf: H(v.url, v.fileName, v.file) === "dxf",
|
|
134
134
|
wireframe: T.value,
|
|
135
135
|
showGrid: F.value,
|
|
136
136
|
showAxes: G.value,
|
|
@@ -151,7 +151,7 @@ const Ae = {
|
|
|
151
151
|
M = !1, S = new AbortController();
|
|
152
152
|
const e = x.value, t = e.clientWidth, i = e.clientHeight;
|
|
153
153
|
r = new o.Scene(), r.background = new o.Color(1710618);
|
|
154
|
-
const s =
|
|
154
|
+
const s = H(v.url, v.fileName, v.file) === "dxf", c = Math.max(t, 1) / Math.max(i, 1);
|
|
155
155
|
f = s ? new o.OrthographicCamera(-c, c, 1, -1, 0, 1e6) : new o.PerspectiveCamera(45, c, 0.01, 1e6), f.position.set(100, 100, 100), d = new o.WebGLRenderer({ antialias: !0 }), d.setSize(t, i), d.setPixelRatio(Math.min(window.devicePixelRatio, 2)), L = !0, e.appendChild(d.domElement), u = new ge(f, d.domElement), u.enableDamping = !0, u.dampingFactor = 0.05, s && (u.enableRotate = !1, u.screenSpacePanning = !0, u.mouseButtons.LEFT = o.MOUSE.PAN, u.touches.ONE = o.TOUCH.PAN, u.touches.TWO = o.TOUCH.DOLLY_PAN);
|
|
156
156
|
const g = new o.AmbientLight(16777215, 0.6);
|
|
157
157
|
r.add(g);
|
|
@@ -165,8 +165,8 @@ const Ae = {
|
|
|
165
165
|
};
|
|
166
166
|
l(), R = new ResizeObserver(ie), R.observe(e);
|
|
167
167
|
}, oe = () => {
|
|
168
|
-
if (
|
|
169
|
-
const e =
|
|
168
|
+
if (N.begin(v.url), !r || !f || !u || M) return;
|
|
169
|
+
const e = H(v.url, v.fileName, v.file);
|
|
170
170
|
let t;
|
|
171
171
|
const i = new o.LoadingManager();
|
|
172
172
|
if (e === "dxf")
|
|
@@ -214,9 +214,9 @@ const Ae = {
|
|
|
214
214
|
}
|
|
215
215
|
r.add(l), C = l;
|
|
216
216
|
const y = h.getCenter(new o.Vector3()), B = h.getSize(new o.Vector3());
|
|
217
|
-
ee(h),
|
|
217
|
+
ee(h), W(f, u, y, B), L = !0, P.value = !1, O.notify(), N.ready();
|
|
218
218
|
}, c = (n) => {
|
|
219
|
-
M || n.name !== "AbortError" && (_.value = A.value("cad.load_failed"), P.value = !1,
|
|
219
|
+
M || n.name !== "AbortError" && (_.value = A.value("cad.load_failed"), P.value = !1, N.error(n));
|
|
220
220
|
};
|
|
221
221
|
(v.file ? v.file.arrayBuffer() : Y.value(v.url, { signal: S == null ? void 0 : S.signal }).then((n) => {
|
|
222
222
|
if (!M) {
|
|
@@ -284,18 +284,18 @@ const Ae = {
|
|
|
284
284
|
J();
|
|
285
285
|
}), le(() => v.url, () => {
|
|
286
286
|
J(), P.value = !0, _.value = null, x.value && I();
|
|
287
|
-
}), (e, t) => (
|
|
287
|
+
}), (e, t) => (U(), V("div", {
|
|
288
288
|
ref_key: "containerRef",
|
|
289
289
|
ref: x,
|
|
290
290
|
class: "vfp-relative vfp-w-full vfp-h-full vfp-bg-media-bg"
|
|
291
291
|
}, [
|
|
292
|
-
_.value ? (
|
|
292
|
+
_.value ? (U(), V("div", Ae, [
|
|
293
293
|
fe(ye, { message: _.value }, null, 8, ["message"])
|
|
294
294
|
])) : q("", !0),
|
|
295
|
-
P.value ? (
|
|
296
|
-
|
|
297
|
-
t[0] || (t[0] =
|
|
298
|
-
|
|
295
|
+
P.value ? (U(), V("div", Re, [
|
|
296
|
+
k("div", Se, [
|
|
297
|
+
t[0] || (t[0] = k("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
298
|
+
k("p", ze, ue(de(A)("cad.loading")), 1)
|
|
299
299
|
])
|
|
300
300
|
])) : q("", !0)
|
|
301
301
|
], 512));
|