@eternalheart/vue-file-preview 1.6.11 → 1.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/lib/FilePreviewContent.vue.d.ts +9 -1
  4. package/lib/FilePreviewEmbed.vue.d.ts +4 -1
  5. package/lib/FilePreviewModal.vue.d.ts +4 -1
  6. package/lib/chunks/EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs +20 -0
  7. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs +32 -0
  8. package/lib/chunks/{avifLoader-CAUzjn-d-Bv80osgL.mjs → avifLoader-CAUzjn-d-C0KRpetN.mjs} +1 -1
  9. package/lib/chunks/{heicLoader-D_9PukkA-c40agcEu.mjs → heicLoader-D_9PukkA-Czof_5FJ.mjs} +1 -1
  10. package/lib/chunks/{index-CO713RPO.mjs → index--612Smof.mjs} +118 -118
  11. package/lib/chunks/{index-Dw6YZA28.mjs → index-8Vpbg2kS.mjs} +2 -2
  12. package/lib/chunks/index-B21EAyWz.mjs +137 -0
  13. package/lib/chunks/{index-CrLeFRdr.mjs → index-BASg1cr4.mjs} +2 -2
  14. package/lib/chunks/index-BB0i4QqI.mjs +117 -0
  15. package/lib/chunks/{index-C92b547K.mjs → index-BVdrGK3Q.mjs} +80 -80
  16. package/lib/chunks/index-BlrFFeqc.mjs +330 -0
  17. package/lib/chunks/index-Bp9CuvMZ.mjs +157 -0
  18. package/lib/chunks/index-BuqPb5mP.mjs +306 -0
  19. package/lib/chunks/{index-Df-1MbYj.mjs → index-BvBqDq3O.mjs} +2 -2
  20. package/lib/chunks/{index-BkqPtbFz.mjs → index-Bxpf9v5j.mjs} +29 -29
  21. package/lib/chunks/{index-DpY9eMSI.mjs → index-C9mAajbD.mjs} +231 -226
  22. package/lib/chunks/{index-DTZVumT8.mjs → index-CDg6vIbT.mjs} +14 -14
  23. package/lib/chunks/{index-By8q8XPn.mjs → index-CWE-hKSs.mjs} +10 -10
  24. package/lib/chunks/{index-DbOpSm8f.mjs → index-CY3xzGgt.mjs} +19 -19
  25. package/lib/chunks/{index-C8pOqpTq.mjs → index-CxKZKUJj.mjs} +521 -523
  26. package/lib/chunks/{index-Cyg4lWK-.mjs → index-D30L8tm9.mjs} +12 -12
  27. package/lib/chunks/{index-DfC_cA90.mjs → index-DN4Ui0Gh.mjs} +24 -24
  28. package/lib/chunks/{index-B3uQ1OoT.mjs → index-DZZN3kYi.mjs} +832 -812
  29. package/lib/chunks/{index-BpKvjFVp.mjs → index-Dkro_8Fy.mjs} +20 -20
  30. package/lib/chunks/{index-B35jLxPz.mjs → index-VdzIFJJW.mjs} +26 -26
  31. package/lib/chunks/{index--D2MwF_x.mjs → index-aoXgVLBb.mjs} +10 -10
  32. package/lib/chunks/{jp2Loader-Dig19xyo-82PXw2fC.mjs → jp2Loader-Dig19xyo-CKUaGhPl.mjs} +1 -1
  33. package/lib/chunks/{psdLoader-C0tKUXXl-DRn7RYLA.mjs → psdLoader-C0tKUXXl-CYWoQis5.mjs} +1 -1
  34. package/lib/chunks/{rawLoader-C-tPeFAB-DP397Cnq.mjs → rawLoader-C-tPeFAB-C35zC8nZ.mjs} +1 -1
  35. package/lib/chunks/{tiffLoader-BlhByX8w-BC52z4Tf.mjs → tiffLoader-BlhByX8w-BOxg_Du5.mjs} +1 -1
  36. package/lib/chunks/{useShikiHighlight-DSyCygls.mjs → useShikiHighlight-BPmcxA-h.mjs} +1 -1
  37. package/lib/index.cjs +63 -63
  38. package/lib/index.css +1 -1
  39. package/lib/index.d.ts +1 -1
  40. package/lib/index.mjs +6 -6
  41. package/lib/renderers/Cad/toolbar.d.ts +1 -0
  42. package/lib/renderers/EmptyState.vue.d.ts +2 -0
  43. package/lib/renderers/Json/index.vue.d.ts +5 -0
  44. package/lib/renderers/Pptx/index.vue.d.ts +3 -0
  45. package/lib/renderers/Text/index.vue.d.ts +3 -0
  46. package/lib/renderers/Xlsx/index.vue.d.ts +3 -0
  47. package/lib/renderers/registry.d.ts +3 -1
  48. package/package.json +1 -1
  49. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs +0 -30
  50. package/lib/chunks/index-2xdBoG-I.mjs +0 -141
  51. package/lib/chunks/index-B2xLxhp0.mjs +0 -133
  52. package/lib/chunks/index-DKJ_iQ70.mjs +0 -295
  53. package/lib/chunks/index-DMwZXKa4.mjs +0 -322
  54. package/lib/chunks/index-DyP3rhuf.mjs +0 -113
@@ -1,295 +0,0 @@
1
- import { defineComponent as ne, ref as S, onMounted as ie, onUnmounted as ae, watch as se, openBlock as W, createElementBlock as D, createVNode as le, createCommentVNode as q, createElementVNode as H, toDisplayString as ue, unref as fe } from "vue";
2
- import { u as de, b as ce, k as me } from "./index-B3uQ1OoT.mjs";
3
- import * as n from "three";
4
- import { OrbitControls as pe } from "three/examples/jsm/controls/OrbitControls";
5
- import { DXFLoader as ve } from "three-dxf-loader";
6
- import { STLLoader as ge } from "three/examples/jsm/loaders/STLLoader";
7
- import { OBJLoader as he } from "three/examples/jsm/loaders/OBJLoader";
8
- import { GLTFLoader as we } from "three/examples/jsm/loaders/GLTFLoader";
9
- import { _ as be } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
10
- import { T as ye } from "./base.types-DaftHyg7.mjs";
11
- import { RotateCcw as Me, Box as xe, Grid3x3 as Le, Axis3d as _e } from "lucide-vue-next";
12
- function ze(u) {
13
- return [
14
- {
15
- items: [
16
- {
17
- type: "button",
18
- icon: Me,
19
- tooltip: u.t("toolbar.reset"),
20
- action: () => {
21
- var p;
22
- return (p = u.cadRef) == null ? void 0 : p.resetView();
23
- }
24
- }
25
- ]
26
- },
27
- {
28
- items: [
29
- {
30
- type: "button",
31
- icon: xe,
32
- tooltip: u.wireframe ? u.t("cad.solid") : u.t("cad.wireframe"),
33
- active: u.wireframe,
34
- action: () => {
35
- var p;
36
- return (p = u.cadRef) == null ? void 0 : p.toggleWireframe();
37
- }
38
- },
39
- {
40
- type: "button",
41
- icon: Le,
42
- tooltip: u.t("cad.grid"),
43
- active: u.showGrid,
44
- action: () => {
45
- var p;
46
- return (p = u.cadRef) == null ? void 0 : p.toggleGrid();
47
- }
48
- },
49
- {
50
- type: "button",
51
- icon: _e,
52
- tooltip: u.t("cad.axes"),
53
- active: u.showAxes,
54
- action: () => {
55
- var p;
56
- return (p = u.cadRef) == null ? void 0 : p.toggleAxes();
57
- }
58
- }
59
- ]
60
- }
61
- ];
62
- }
63
- const Ee = {
64
- key: 0,
65
- class: "vfp-absolute vfp-inset-0 vfp-bg-surface-3 vfp-z-10"
66
- }, Ce = {
67
- key: 1,
68
- class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-3 vfp-z-10"
69
- }, Ae = { class: "vfp-renderer-loading-content" }, Re = { class: "vfp-renderer-loading-text vfp-text-fg-secondary" }, He = /* @__PURE__ */ ne({
70
- __name: "index",
71
- props: {
72
- url: {},
73
- file: {},
74
- fileName: {},
75
- baseUrl: {}
76
- },
77
- setup(u, { expose: p }) {
78
- const J = (e) => {
79
- if (!e || e.startsWith("blob:") || e.startsWith("data:")) return "";
80
- try {
81
- return new URL(".", new URL(e, document.baseURI)).href;
82
- } catch {
83
- return "";
84
- }
85
- }, N = (e, t, o, a) => {
86
- const l = Number.isFinite(a) && a > 0 ? a : 1, b = e.fov * (Math.PI / 180), r = Math.abs(l / 2 / Math.tan(b / 2)) * 1.5;
87
- e.near = Math.max(l * 1e-3, 1e-4), e.far = Math.max(r * 4, o.length() * 2 + l * 4, e.near * 100), e.position.set(o.x + r, o.y + r, o.z + r), e.lookAt(o), t.target.copy(o), t.update(), e.updateProjectionMatrix();
88
- }, M = u, { t: C } = de(), X = ce(), y = S(null), z = S(!0), E = S(null), P = S(!1), F = S(!0), G = S(!0);
89
- let i = null, v = null, s = null, f = null, x = null, d = null, c = null, k = null, R = null, g = !1, L = !0;
90
- const T = new ye(), Z = (e, t, o) => {
91
- var a, l, b;
92
- return o != null && o.name ? ((a = o.name.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "" : t ? ((l = t.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "" : ((b = e.split(".").pop()) == null ? void 0 : b.toLowerCase().split("?")[0]) || "";
93
- }, $ = () => {
94
- if (!f || !v || !x) return;
95
- const e = new n.Box3().setFromObject(x), t = e.getCenter(new n.Vector3()), o = e.getSize(new n.Vector3()), a = Math.max(o.x, o.y, o.z);
96
- N(v, f, t, a), L = !0;
97
- }, K = () => {
98
- P.value = !P.value, x && x.traverse((e) => {
99
- if (e instanceof n.Mesh) {
100
- const t = e.material;
101
- t && (Array.isArray(t) ? t.forEach((o) => {
102
- o.wireframe = P.value;
103
- }) : t.wireframe = P.value);
104
- }
105
- }), L = !0, T.notify();
106
- }, Q = () => {
107
- F.value = !F.value, d && (d.visible = F.value), L = !0, T.notify();
108
- }, Y = () => {
109
- G.value = !G.value, c && (c.visible = G.value), L = !0, T.notify();
110
- }, ee = (e) => {
111
- if (!i) return;
112
- const t = e.getSize(new n.Vector3()), o = Math.max(t.x, t.y, t.z), a = Number.isFinite(o) && o > 0 ? o : 1, l = Math.max(
113
- Math.abs(e.min.x),
114
- Math.abs(e.max.x),
115
- Math.abs(e.min.y),
116
- Math.abs(e.max.y),
117
- Math.abs(e.min.z),
118
- Math.abs(e.max.z)
119
- ), b = Number.isFinite(l) ? l : a, r = Math.max(a, b * 1.25), m = Math.max(a * 2, b * 2.5);
120
- d && (d.geometry.dispose(), d.material.dispose(), i.remove(d)), c && (c.geometry.dispose(), c.material.dispose(), i.remove(c)), d = new n.GridHelper(m, 20, 4473924, 2236962), d.visible = F.value, i.add(d), c = new n.AxesHelper(r), c.visible = G.value, i.add(c);
121
- };
122
- p({
123
- getToolbarGroups: () => ze({
124
- cadRef: { resetView: $, toggleWireframe: K, toggleGrid: Q, toggleAxes: Y },
125
- wireframe: P.value,
126
- showGrid: F.value,
127
- showAxes: G.value,
128
- t: C.value
129
- }),
130
- onToolbarChange: (e) => T.subscribe(e)
131
- });
132
- const te = (e) => {
133
- e.traverse((t) => {
134
- t.geometry && t.geometry.dispose(), t.material && (Array.isArray(t.material) ? t.material.forEach((o) => {
135
- U(o);
136
- }) : U(t.material));
137
- });
138
- }, U = (e) => {
139
- e.map && e.map.dispose(), e.lightMap && e.lightMap.dispose(), e.bumpMap && e.bumpMap.dispose(), e.normalMap && e.normalMap.dispose(), e.specularMap && e.specularMap.dispose(), e.envMap && e.envMap.dispose(), e.dispose();
140
- }, j = () => {
141
- if (!y.value) return;
142
- g = !1, R = new AbortController();
143
- const e = y.value, t = e.clientWidth, o = e.clientHeight;
144
- i = new n.Scene(), i.background = new n.Color(1710618), v = new n.PerspectiveCamera(45, t / o, 0.01, 1e6), v.position.set(100, 100, 100), s = new n.WebGLRenderer({ antialias: !0 }), s.setSize(t, o), s.setPixelRatio(Math.min(window.devicePixelRatio, 2)), L = !0, e.appendChild(s.domElement), f = new pe(v, s.domElement), f.enableDamping = !0, f.dampingFactor = 0.05;
145
- const a = new n.AmbientLight(16777215, 0.6);
146
- i.add(a);
147
- const l = new n.DirectionalLight(16777215, 0.8);
148
- l.position.set(1, 1, 1), i.add(l);
149
- const b = new n.DirectionalLight(16777215, 0.4);
150
- b.position.set(-1, -1, -1), i.add(b), oe();
151
- const r = () => {
152
- if (g) return;
153
- k = requestAnimationFrame(r), ((f == null ? void 0 : f.update()) || L) && i && v && s && (s.render(i, v), L = !1);
154
- };
155
- r(), window.addEventListener("resize", O);
156
- }, oe = () => {
157
- if (!i || !v || !f || g) return;
158
- const e = Z(M.url, M.fileName, M.file);
159
- let t;
160
- const o = new n.LoadingManager();
161
- if (e === "dxf")
162
- t = new ve();
163
- else if (e === "stl")
164
- t = new ge(o);
165
- else if (e === "obj")
166
- t = new he(o);
167
- else if (e === "gltf" || e === "glb")
168
- t = new we(o);
169
- else {
170
- E.value = C.value("cad.parse_failed"), z.value = !1;
171
- return;
172
- }
173
- const a = (r, m) => {
174
- if (g) return;
175
- if (!r) {
176
- E.value = C.value("cad.parse_failed"), z.value = !1;
177
- return;
178
- }
179
- let h;
180
- if (m === "stl") {
181
- const V = r, re = new n.MeshPhongMaterial({
182
- color: 8947848,
183
- flatShading: !0,
184
- side: n.DoubleSide
185
- });
186
- h = new n.Mesh(V, re);
187
- } else if (m === "gltf" || m === "glb") {
188
- if (h = r.scene, !h) {
189
- E.value = C.value("cad.parse_failed"), z.value = !1;
190
- return;
191
- }
192
- } else
193
- h = r, h.traverse((V) => {
194
- V instanceof n.Mesh && !V.material && (V.material = new n.MeshPhongMaterial({
195
- color: 8947848,
196
- side: n.DoubleSide
197
- }));
198
- });
199
- const _ = new n.Box3().setFromObject(h);
200
- if (_.isEmpty()) {
201
- E.value = C.value("cad.parse_failed"), z.value = !1;
202
- return;
203
- }
204
- i.add(h), x = h;
205
- const w = _.getCenter(new n.Vector3()), A = _.getSize(new n.Vector3()), B = Math.max(A.x, A.y, A.z);
206
- ee(_), N(v, f, w, B), L = !0, z.value = !1, T.notify();
207
- }, l = (r) => {
208
- g || r.name !== "AbortError" && (E.value = C.value("cad.load_failed"), z.value = !1);
209
- };
210
- (M.file ? M.file.arrayBuffer() : X.value(M.url, { signal: R == null ? void 0 : R.signal }).then((r) => {
211
- if (!g) {
212
- if (!r.ok) throw new me("file.load_failed");
213
- return r.arrayBuffer();
214
- }
215
- })).then((r) => {
216
- if (!(g || !r)) {
217
- if (e === "stl") {
218
- const m = t.parse(r);
219
- a(m, e);
220
- } else if (e === "obj") {
221
- const h = new TextDecoder("utf-8").decode(r), _ = t.parse(h);
222
- a(_, e);
223
- } else if (e === "gltf" || e === "glb")
224
- t.parse(
225
- r,
226
- J(M.baseUrl || M.url),
227
- (m) => {
228
- g || a(m, e);
229
- },
230
- (m) => l(m)
231
- );
232
- else if (e === "dxf") {
233
- const h = new TextDecoder("utf-8").decode(r), _ = n.BufferGeometry.prototype.setFromPoints;
234
- n.BufferGeometry.prototype.setFromPoints = function(w) {
235
- const A = (w || []).filter(
236
- (B) => B && B.x !== void 0 && B.y !== void 0
237
- );
238
- return _.call(this, A);
239
- };
240
- try {
241
- t.loadString(
242
- h,
243
- (w) => {
244
- if (!g) {
245
- const A = (w == null ? void 0 : w.entity) || w;
246
- a(A, e);
247
- }
248
- },
249
- (w) => {
250
- l(w);
251
- }
252
- );
253
- } catch (w) {
254
- l(w);
255
- } finally {
256
- n.BufferGeometry.prototype.setFromPoints = _;
257
- }
258
- }
259
- }
260
- }).catch((r) => {
261
- g || l(r);
262
- });
263
- }, O = () => {
264
- if (!y.value || !v || !s || g) return;
265
- const e = y.value.clientWidth, t = y.value.clientHeight;
266
- v.aspect = e / t, v.updateProjectionMatrix(), s.setSize(e, t), L = !0;
267
- }, I = () => {
268
- g = !0, R && R.abort(), k !== null && (cancelAnimationFrame(k), k = null), window.removeEventListener("resize", O), x && (te(x), i == null || i.remove(x), x = null), d && (d.geometry.dispose(), d.material.dispose(), i == null || i.remove(d), d = null), c && (c.geometry.dispose(), c.material.dispose(), i == null || i.remove(c), c = null), f == null || f.dispose(), s == null || s.dispose(), y.value && (s != null && s.domElement) && y.value.contains(s.domElement) && y.value.removeChild(s.domElement), i = null, v = null, s = null, f = null;
269
- };
270
- return ie(() => {
271
- j();
272
- }), ae(() => {
273
- I();
274
- }), se(() => M.url, () => {
275
- I(), z.value = !0, E.value = null, y.value && j();
276
- }), (e, t) => (W(), D("div", {
277
- ref_key: "containerRef",
278
- ref: y,
279
- class: "vfp-relative vfp-w-full vfp-h-full vfp-bg-media-bg"
280
- }, [
281
- E.value ? (W(), D("div", Ee, [
282
- le(be, { message: E.value }, null, 8, ["message"])
283
- ])) : q("", !0),
284
- z.value ? (W(), D("div", Ce, [
285
- H("div", Ae, [
286
- t[0] || (t[0] = H("div", { class: "vfp-renderer-spinner" }, null, -1)),
287
- H("p", Re, ue(fe(C)("cad.loading")), 1)
288
- ])
289
- ])) : q("", !0)
290
- ], 512));
291
- }
292
- });
293
- export {
294
- He as default
295
- };
@@ -1,322 +0,0 @@
1
- import { defineComponent as ie, ref as v, watch as J, onMounted as se, onBeforeUnmount as ue, openBlock as d, createElementBlock as h, createBlock as fe, createCommentVNode as C, createElementVNode as c, toDisplayString as A, unref as O, normalizeStyle as T, createVNode as ce, Fragment as q, renderList as K } from "vue";
2
- import pe from "@likecoin/epub-ts";
3
- import { List as ve, ChevronLeft as de, ChevronRight as he, Minimize2 as ge, Maximize2 as me, X as be } from "lucide-vue-next";
4
- import { u as xe, b as ye } from "./index-B3uQ1OoT.mjs";
5
- import { _ as we } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
6
- import { T as ke } from "./base.types-DaftHyg7.mjs";
7
- const _e = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, Te = {
8
- key: 1,
9
- class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
10
- }, ze = { class: "vfp-renderer-loading-content" }, Ce = { class: "vfp-renderer-loading-text" }, Se = {
11
- class: "vfp-flex vfp-items-center vfp-justify-between vfp-flex-shrink-0",
12
- style: { padding: "12px 16px", "border-bottom": "1px solid rgba(255,255,255,0.1)" }
13
- }, We = { style: { color: "white", "font-weight": "500", "font-size": "14px" } }, Me = {
14
- class: "vfp-flex-1 vfp-overflow-y-auto",
15
- style: { padding: "8px 4px" }
16
- }, $e = ["title", "onClick", "onMouseenter", "onMouseleave"], He = ["title", "onClick", "onMouseenter", "onMouseleave"], Re = 794, Oe = /* @__PURE__ */ ie({
17
- __name: "index",
18
- props: {
19
- url: {}
20
- },
21
- setup(Q, { expose: Y }) {
22
- const S = Q, G = new ke(), { t: p } = xe(), Z = ye(), g = v(1), y = v(1), r = v(null), W = v(!0), w = v(null), m = v(!1), b = v([]), i = v(!1), E = v("");
23
- J([g, y, m, i, () => b.value.length], () => {
24
- G.notify();
25
- });
26
- let s = null, e = null, k = 0, _ = null;
27
- const I = () => {
28
- var o;
29
- try {
30
- (o = e == null ? void 0 : e.destroy) == null || o.call(e);
31
- } catch {
32
- }
33
- try {
34
- s == null || s.destroy();
35
- } catch {
36
- }
37
- e = null, s = null, k = 0, _ = null;
38
- }, ee = () => {
39
- e == null || e.prev();
40
- }, te = () => {
41
- e == null || e.next();
42
- }, oe = () => {
43
- m.value = !m.value, setTimeout(() => {
44
- r.value && e && (e.resize(r.value.offsetWidth, r.value.offsetHeight), _ && e.display(_), D());
45
- }, 350);
46
- }, ae = () => {
47
- i.value = !i.value;
48
- }, P = (o) => {
49
- E.value = o, e == null || e.display(o), i.value = !1;
50
- }, f = (o) => o === E.value;
51
- Y({
52
- getToolbarGroups: () => [
53
- {
54
- items: [
55
- {
56
- type: "button",
57
- icon: ve,
58
- tooltip: p.value("toolbar.toc"),
59
- action: ae,
60
- disabled: b.value.length === 0,
61
- active: i.value
62
- }
63
- ]
64
- },
65
- {
66
- items: [
67
- {
68
- type: "button",
69
- icon: de,
70
- tooltip: p.value("toolbar.prev_page"),
71
- action: ee,
72
- disabled: g.value <= 1
73
- },
74
- {
75
- type: "text",
76
- content: `${g.value} / ${y.value}`,
77
- minWidth: "4rem"
78
- },
79
- {
80
- type: "button",
81
- icon: he,
82
- tooltip: p.value("toolbar.next_page"),
83
- action: te,
84
- disabled: g.value >= y.value
85
- }
86
- ]
87
- },
88
- {
89
- items: [
90
- {
91
- type: "button",
92
- icon: m.value ? ge : me,
93
- tooltip: m.value ? p.value("toolbar.normal_width") : p.value("toolbar.full_width"),
94
- action: oe,
95
- active: m.value
96
- }
97
- ]
98
- }
99
- ],
100
- onToolbarChange: (o) => G.subscribe(o)
101
- });
102
- const V = async () => {
103
- if (r.value) {
104
- W.value = !0, w.value = null, b.value = [], i.value = !1, r.value.innerHTML = "", I();
105
- try {
106
- let o = S.url;
107
- S.url.startsWith("blob:") && (o = await (await Z.value(S.url)).arrayBuffer()), s = pe(o), e = s.renderTo(r.value, {
108
- manager: "continuous",
109
- flow: "scrolled",
110
- width: "100%",
111
- height: "100%"
112
- }), e.themes.register("default", {
113
- body: {
114
- background: "#ffffff !important",
115
- color: "#1a1a1a !important",
116
- "font-family": '"Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important',
117
- "font-size": "16px !important",
118
- "line-height": "2 !important",
119
- padding: "40px 60px !important",
120
- "max-width": "100% !important",
121
- "box-sizing": "border-box !important",
122
- "word-break": "break-word !important",
123
- "overflow-wrap": "break-word !important"
124
- },
125
- p: { "text-indent": "2em !important", margin: "0.8em 0 !important" },
126
- h1: { "text-align": "center !important", margin: "1.5em 0 1em !important" },
127
- h2: { margin: "1.2em 0 0.8em !important" },
128
- h3: { margin: "1em 0 0.6em !important" },
129
- img: { "max-width": "100% !important", height: "auto !important" },
130
- a: { color: "#2563eb !important", "text-decoration": "none !important" }
131
- }), e.themes.select("default"), await s.ready, s.locations.generate(1024).then(() => {
132
- var a;
133
- if (!s) return;
134
- k = s.locations.length();
135
- const t = e == null ? void 0 : e.currentLocation(), n = ((a = t == null ? void 0 : t.start) == null ? void 0 : a.location) ?? 0;
136
- g.value = n + 1, y.value = k;
137
- }).catch(() => {
138
- });
139
- const l = await s.loaded.navigation;
140
- Array.isArray(l == null ? void 0 : l.toc) && (b.value = l.toc), await e.display(), W.value = !1, g.value = 1, y.value = k || 1, e.on("relocated", (t) => {
141
- var H, x, j;
142
- const n = t;
143
- if ((H = n == null ? void 0 : n.start) != null && H.cfi && (_ = n.start.cfi), (x = n == null ? void 0 : n.start) != null && x.href) {
144
- const B = n.start.href, N = [], U = (ne) => {
145
- for (const R of ne) {
146
- const L = R.href.split("#")[0];
147
- L && (B === L || B.endsWith("/" + L) || B.endsWith(L)) && N.push(R.href), R.subitems && U(R.subitems);
148
- }
149
- };
150
- U(b.value), N.length === 1 && (E.value = N[0]);
151
- }
152
- const a = (j = n == null ? void 0 : n.start) == null ? void 0 : j.location;
153
- typeof a == "number" && k > 0 && (g.value = a + 1, y.value = k);
154
- });
155
- } catch (o) {
156
- console.error(p.value("epub.load_failed") + ":", o), w.value = p.value("epub.load_failed"), W.value = !1;
157
- }
158
- }
159
- };
160
- let M = null, z = null, $ = { width: 0, height: 0 }, X = !0;
161
- const le = () => {
162
- if (!(!r.value || !e)) {
163
- if (e.resize(r.value.offsetWidth, r.value.offsetHeight), _)
164
- try {
165
- e.display(_);
166
- } catch {
167
- }
168
- D();
169
- }
170
- }, re = () => {
171
- r.value && (M = new ResizeObserver(() => {
172
- if (!r.value) return;
173
- if (X) {
174
- X = !1, $ = { width: r.value.offsetWidth, height: r.value.offsetHeight };
175
- return;
176
- }
177
- const o = { width: r.value.offsetWidth, height: r.value.offsetHeight }, l = Math.abs($.width - o.width), t = Math.abs($.height - o.height);
178
- l < 10 && t < 10 || ($ = o, z !== null && clearTimeout(z), z = window.setTimeout(le, 350));
179
- }), M.observe(r.value));
180
- };
181
- let u = null;
182
- const F = () => {
183
- var l;
184
- if (!u) return;
185
- const o = u;
186
- if (o.scrollTop + o.clientHeight >= o.scrollHeight - 200)
187
- try {
188
- const t = e == null ? void 0 : e.manager;
189
- (l = t == null ? void 0 : t.check) == null || l.call(t, 500, 500);
190
- } catch {
191
- }
192
- }, D = () => {
193
- u && (u.removeEventListener("scroll", F), u = null);
194
- const o = () => {
195
- var l;
196
- u = ((l = r.value) == null ? void 0 : l.querySelector(".epub-container")) ?? null, u ? u.addEventListener("scroll", F, { passive: !0 }) : requestAnimationFrame(o);
197
- };
198
- requestAnimationFrame(o);
199
- };
200
- return se(() => {
201
- V(), re(), D();
202
- }), J(() => S.url, (o) => {
203
- o && V();
204
- }), ue(() => {
205
- M && M.disconnect(), z !== null && clearTimeout(z), u == null || u.removeEventListener("scroll", F), I();
206
- }), (o, l) => (d(), h("div", _e, [
207
- w.value ? (d(), fe(we, {
208
- key: 0,
209
- message: w.value,
210
- class: "vfp-absolute vfp-inset-0"
211
- }, null, 8, ["message"])) : C("", !0),
212
- W.value && !w.value ? (d(), h("div", Te, [
213
- c("div", ze, [
214
- l[2] || (l[2] = c("div", { class: "vfp-renderer-spinner" }, null, -1)),
215
- c("span", Ce, A(O(p)("common.loading")), 1)
216
- ])
217
- ])) : C("", !0),
218
- b.value.length > 0 ? (d(), h("div", {
219
- key: 2,
220
- class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex",
221
- style: T({ opacity: i.value ? 1 : 0, pointerEvents: i.value ? "auto" : "none", transition: "opacity 0.3s" })
222
- }, [
223
- c("div", {
224
- class: "vfp-w-72 vfp-h-full vfp-flex vfp-flex-col",
225
- style: T({
226
- maxWidth: "80%",
227
- background: "rgba(0,0,0,0.9)",
228
- backdropFilter: "blur(12px)",
229
- borderRight: "1px solid rgba(255,255,255,0.1)",
230
- boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)",
231
- transform: i.value ? "translateX(0)" : "translateX(-100%)",
232
- transition: "transform 0.3s ease"
233
- })
234
- }, [
235
- c("div", Se, [
236
- c("span", We, A(O(p)("toolbar.toc")), 1),
237
- c("button", {
238
- style: { color: "rgba(255,255,255,0.6)", background: "none", border: "none", cursor: "pointer", padding: "4px" },
239
- onClick: l[0] || (l[0] = (t) => i.value = !1)
240
- }, [
241
- ce(O(be), { style: { width: "16px", height: "16px" } })
242
- ])
243
- ]),
244
- c("div", Me, [
245
- (d(!0), h(q, null, K(b.value, (t, n) => (d(), h(q, {
246
- key: `${t.href}-${n}`
247
- }, [
248
- c("button", {
249
- style: T({
250
- width: "100%",
251
- textAlign: "left",
252
- padding: "8px 12px",
253
- fontSize: "14px",
254
- color: f(t.href) ? "white" : "rgba(255,255,255,0.7)",
255
- fontWeight: f(t.href) ? "500" : "400",
256
- background: f(t.href) ? "rgba(255,255,255,0.15)" : "none",
257
- border: "none",
258
- cursor: "pointer",
259
- borderRadius: "4px",
260
- overflow: "hidden",
261
- textOverflow: "ellipsis",
262
- whiteSpace: "nowrap",
263
- display: "block",
264
- transition: "all 0.15s"
265
- }),
266
- title: t.label,
267
- onClick: (a) => P(t.href),
268
- onMouseenter: (a) => !f(t.href) && (a.target.style.background = "rgba(255,255,255,0.1)"),
269
- onMouseleave: (a) => !f(t.href) && (a.target.style.background = "none")
270
- }, A(t.label.trim()), 45, $e),
271
- t.subitems && t.subitems.length > 0 ? (d(!0), h(q, { key: 0 }, K(t.subitems, (a, H) => (d(), h("button", {
272
- key: `${a.href}-${H}`,
273
- style: T({
274
- width: "100%",
275
- textAlign: "left",
276
- padding: "8px 12px 8px 28px",
277
- fontSize: "13px",
278
- color: f(a.href) ? "white" : "rgba(255,255,255,0.6)",
279
- fontWeight: f(a.href) ? "500" : "400",
280
- background: f(a.href) ? "rgba(255,255,255,0.15)" : "none",
281
- border: "none",
282
- cursor: "pointer",
283
- borderRadius: "4px",
284
- overflow: "hidden",
285
- textOverflow: "ellipsis",
286
- whiteSpace: "nowrap",
287
- display: "block",
288
- transition: "all 0.15s"
289
- }),
290
- title: a.label,
291
- onClick: (x) => P(a.href),
292
- onMouseenter: (x) => !f(a.href) && (x.target.style.background = "rgba(255,255,255,0.1)"),
293
- onMouseleave: (x) => !f(a.href) && (x.target.style.background = "none")
294
- }, A(a.label.trim()), 45, He))), 128)) : C("", !0)
295
- ], 64))), 128))
296
- ])
297
- ], 4),
298
- c("div", {
299
- class: "vfp-flex-1",
300
- style: T({ background: i.value ? "rgba(0,0,0,0.3)" : "transparent", transition: "background 0.3s" }),
301
- onClick: l[1] || (l[1] = (t) => i.value = !1)
302
- }, null, 4)
303
- ], 4)) : C("", !0),
304
- w.value ? C("", !0) : (d(), h("div", {
305
- key: 3,
306
- ref_key: "viewerRef",
307
- ref: r,
308
- class: "vfp-h-full vfp-bg-surface-toolbar",
309
- style: T({
310
- width: m.value ? "100%" : `${Re}px`,
311
- maxWidth: "100%",
312
- transition: "width 0.3s ease",
313
- boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
314
- overflow: "hidden"
315
- })
316
- }, null, 4))
317
- ]));
318
- }
319
- });
320
- export {
321
- Oe as default
322
- };