@eternalheart/vue-file-preview 1.7.2 → 1.8.0

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 +28 -0
  2. package/README.zh-CN.md +28 -0
  3. package/lib/FilePreviewContent.vue.d.ts +25 -11
  4. package/lib/FilePreviewEmbed.vue.d.ts +20 -11
  5. package/lib/FilePreviewModal.vue.d.ts +20 -11
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-Dna6LmVT.mjs → EmptyState.vue_vue_type_script_setup_true_lang-98G0nOSe.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-dPsP28D5.mjs → avifLoader-CAUzjn-d-BaqsWKGB.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-T-k1DSgY.mjs → heicLoader-D_9PukkA-C9OkgWGg.mjs} +1 -1
  9. package/lib/chunks/index-B5B5upNy.mjs +112 -0
  10. package/lib/chunks/{index-cRhwUlQN.mjs → index-B9xl_UYv.mjs} +26 -26
  11. package/lib/chunks/{index-B5hprvcF.mjs → index-BKpp6GvN.mjs} +2516 -2085
  12. package/lib/chunks/{index-oJF-hur2.mjs → index-BNNGXI8X.mjs} +1 -1
  13. package/lib/chunks/{index-eNZr1h6f.mjs → index-BV5eiYIr.mjs} +23 -23
  14. package/lib/chunks/{index-BjHEHkZ8.mjs → index-Bghv1art.mjs} +1 -1
  15. package/lib/chunks/{index-TZv0MqBH.mjs → index-Bl530kxA.mjs} +5 -5
  16. package/lib/chunks/index-CCHdh2Ta.mjs +220 -0
  17. package/lib/chunks/{index-QPk2c2Tl.mjs → index-CDd2zFE5.mjs} +2 -2
  18. package/lib/chunks/{index-C95y29OL.mjs → index-CHpO-VOr.mjs} +19 -19
  19. package/lib/chunks/index-CSxcgc5S.mjs +401 -0
  20. package/lib/chunks/{index-Cv3Sg87O.mjs → index-CcyrSSZO.mjs} +17 -17
  21. package/lib/chunks/{index-JjVQZbDt.mjs → index-CzBIAq6E.mjs} +25 -25
  22. package/lib/chunks/{index-BPutNVAf.mjs → index-D-18qa-n.mjs} +1 -1
  23. package/lib/chunks/{index-BN__EwfT.mjs → index-D4OWPWnl.mjs} +1 -1
  24. package/lib/chunks/{index-Dnyl1HQk.mjs → index-DcEoeHsV.mjs} +10 -10
  25. package/lib/chunks/{index-DInI3RTN.mjs → index-DjCn0C-U.mjs} +33 -33
  26. package/lib/chunks/{index-DHba2Axz.mjs → index-Dtr0MERf.mjs} +53 -53
  27. package/lib/chunks/{index-CqOGKCyE.mjs → index-UBINFnHY.mjs} +1 -1
  28. package/lib/chunks/{index-BlZ6RmeR.mjs → index-YyZE4Nkm.mjs} +4 -4
  29. package/lib/chunks/{index-CegPYMyO.mjs → index-mdCIanDM.mjs} +27 -27
  30. package/lib/chunks/{index-DXzvgRuo.mjs → index-s_jqndx-.mjs} +1 -1
  31. package/lib/chunks/{jp2Loader-Dig19xyo-hrIg_KJ3.mjs → jp2Loader-Dig19xyo-CD7_CVVV.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-B2cJ4s7t.mjs → psdLoader-C0tKUXXl-Bf25O3n4.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-BNV-Wmzr.mjs → rawLoader-C-tPeFAB-CZ65svhu.mjs} +5 -5
  34. package/lib/chunks/{tiffLoader-BlhByX8w-BzSrLE9Y.mjs → tiffLoader-BlhByX8w-BEFJubN7.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-CpL0RAQg.mjs → useShikiHighlight-axL5ux5r.mjs} +1 -1
  36. package/lib/composables/useRendererBridge.d.ts +19 -0
  37. package/lib/composables/useRequest.d.ts +1 -13
  38. package/lib/core/index.d.ts +9 -1
  39. package/lib/core/renderer-bridge/bridge.d.ts +53 -0
  40. package/lib/core/renderer-bridge/hub.d.ts +58 -0
  41. package/lib/core/renderer-bridge/types.d.ts +141 -0
  42. package/lib/core/types.d.ts +0 -7
  43. package/lib/core/utils/rendererId.d.ts +7 -0
  44. package/lib/core/utils/spreadsheetSheets.d.ts +17 -0
  45. package/lib/index.cjs +60 -60
  46. package/lib/index.css +1 -1
  47. package/lib/index.d.ts +1 -1
  48. package/lib/index.mjs +8 -8
  49. package/lib/renderers/Xlsx/index.vue.d.ts +4 -0
  50. package/lib/types.d.ts +7 -2
  51. package/package.json +1 -1
  52. package/lib/chunks/index-B_Spz6Wn.mjs +0 -359
  53. package/lib/chunks/index-DcvlMm9Q.mjs +0 -137
  54. package/lib/chunks/index-dOxDeWYi.mjs +0 -104
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const VERSION: string;
3
3
  export { default as FilePreviewModal } from './FilePreviewModal.vue.js';
4
4
  export { default as FilePreviewEmbed } from './FilePreviewEmbed.vue.js';
5
5
  export { default as FilePreviewContent } from './FilePreviewContent.vue.js';
6
- export type { PreviewFile, PreviewFileLink, PreviewFileInput, FileType, PreviewState, ToolbarAction, CustomRenderer, CustomRendererContext, CustomRendererEventPayload, RequestHandler, RequestInitFactory, RequestOptions, Fetcher, ShouldFetchAsBlob, FileContent, FileLoader, } from './types.js';
6
+ export type { PreviewFile, PreviewFileLink, PreviewFileInput, FileType, PreviewState, ToolbarAction, CustomRenderer, CustomRendererContext, CustomRendererEventPayload, RequestHandler, RequestInitFactory, RequestOptions, Fetcher, FileContent, FileLoader, RendererId, RendererEvent, RendererEventSource, NativeInstanceChange, SubscribeOptions, RendererHooks, AttachContext, RendererBridgeSpec, RendererAttachHook, RendererProps, RendererController, XlsxSheetState, XlsxController, PreviewRendererAccessor, } from './types.js';
7
7
  export { normalizeFile, normalizeFiles, getFileType, configurePdfWorker, SUPPORTED_FILE_TYPES, PreviewRequestError, withHeaders, } from './core/index.js';
8
8
  export type { PdfWorkerOptions } from './core/index.js';
9
9
  export type { PreviewErrorStage, PreviewErrorPayload, PreviewRenderedPayload, PreviewReporter, } from './core/index.js';
package/lib/index.mjs CHANGED
@@ -1,18 +1,18 @@
1
- import { w as s, x as r, y as i, g as o, N as l, C as P, K as E, r as t, j as n, P as v, Z as w, a0 as F, b as d, u, a1 as m } from "./chunks/index-B5hprvcF.mjs";
1
+ import { X as s, Y as r, a0 as i, L as o, o as l, a1 as E, a2 as P, M as t, F, a3 as n, a4 as v, a5 as w, b as d, u, a6 as L } from "./chunks/index-BKpp6GvN.mjs";
2
2
  export {
3
3
  s as FilePreviewContent,
4
4
  r as FilePreviewEmbed,
5
5
  i as FilePreviewModal,
6
6
  o as LOCALE_KEY,
7
7
  l as PreviewRequestError,
8
- P as SUPPORTED_FILE_TYPES,
9
- E as VERSION,
8
+ E as SUPPORTED_FILE_TYPES,
9
+ P as VERSION,
10
10
  t as configurePdfWorker,
11
- n as getFileType,
12
- v as normalizeFile,
13
- w as normalizeFiles,
14
- F as provideLocale,
11
+ F as getFileType,
12
+ n as normalizeFile,
13
+ v as normalizeFiles,
14
+ w as provideLocale,
15
15
  d as usePreviewEvents,
16
16
  u as useTranslator,
17
- m as withHeaders
17
+ L as withHeaders
18
18
  };
@@ -4,6 +4,10 @@ type __VLS_Props = {
4
4
  url: string;
5
5
  /** 保留通用预览参数;空 Excel 始终展示默认工作簿。 */
6
6
  emptyHint?: EmptyHintMode;
7
+ /** 受控的当前 sheet 名(优先于 activeSheetIndex) */
8
+ activeSheetName?: string;
9
+ /** 受控的当前 sheet 下标 */
10
+ activeSheetIndex?: number;
7
11
  };
8
12
  declare const _default: import("vue").DefineComponent<__VLS_Props, {
9
13
  getToolbarGroups: () => ToolbarGroup[];
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type { PreviewFile, PreviewFileLink, PreviewFileInput, FileType, PreviewState, CustomRendererEventPayload, RequestHandler, RequestInitFactory, RequestOptions, Fetcher, ShouldFetchAsBlob, FileContent, FileLoader, } from './core/index.js';
2
- import type { PreviewFile, Locale, Translator } from './core/index.js';
1
+ export type { PreviewFile, PreviewFileLink, PreviewFileInput, FileType, PreviewState, CustomRendererEventPayload, RequestHandler, RequestInitFactory, RequestOptions, Fetcher, FileContent, FileLoader, RendererId, RendererEvent, RendererEventSource, NativeInstanceChange, SubscribeOptions, RendererHooks, AttachContext, RendererBridgeSpec, RendererAttachHook, RendererBridge, RendererProps, RendererController, XlsxSheetState, XlsxController, PreviewRendererAccessor, } from './core/index.js';
2
+ import type { PreviewFile, Locale, Translator, RendererBridge, RendererBridgeSpec } from './core/index.js';
3
3
  import type { Component, VNode } from 'vue';
4
4
  import type { ToolbarGroup } from './renderers/toolbar.types.js';
5
5
  /**
@@ -21,6 +21,11 @@ export interface CustomRendererContext {
21
21
  t: Translator;
22
22
  theme: 'dark' | 'light';
23
23
  locale: Locale;
24
+ /**
25
+ * 可选:把自定义渲染器接入统一的渲染器事件桥。
26
+ * 注册后宿主的 `on` / `getState` / `getNativeInstance` / `getController` 对该渲染器生效。
27
+ */
28
+ registerBridge?: (spec: RendererBridgeSpec<unknown>) => RendererBridge<unknown> | null;
24
29
  }
25
30
  /**
26
31
  * 自定义渲染器:根据文件类型匹配并返回 Vue 组件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eternalheart/vue-file-preview",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "description": "A modern, feature-rich file preview component for Vue 3 with support for images, videos, audio, PDFs, Office documents (Word, Excel, PowerPoint), Markdown, and code files.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.cjs",
@@ -1,359 +0,0 @@
1
- import { defineComponent as O, ref as d, computed as C, onMounted as re, onBeforeUnmount as Y, watch as P, openBlock as v, createElementBlock as u, normalizeStyle as W, Fragment as B, createElementVNode as i, normalizeClass as U, toDisplayString as T, unref as g, withDirectives as V, renderSlot as N, vShow as Z, resolveComponent as ve, createVNode as j, createBlock as D, resolveDynamicComponent as q, renderList as Q, createCommentVNode as ee, defineAsyncComponent as fe, withCtx as G, Teleport as de } from "vue";
2
- import { u as te, d as ne, j as pe, A as ue, a as ce, b as me, W as X, J as he, k as ge, l as we, H as be, m as xe } from "./index-B5hprvcF.mjs";
3
- import { FileImage as ye, FileText as ke, FileCode as Le, File as ze, ChevronRight as Se, FolderOpen as Te, Folder as _e } from "lucide-vue-next";
4
- import { _ as J } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
- import { T as $e } from "./base.types-DaftHyg7.mjs";
6
- const Re = { class: "vfp-flex vfp-flex-shrink-0 vfp-border-b vfp-border-line-weak vfp-bg-surface-toolbar" }, Ce = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Ee = { class: "vfp-flex-1 vfp-min-h-0 vfp-min-w-0 vfp-w-full vfp-overflow-hidden" }, Me = { class: "vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden" }, We = /* @__PURE__ */ O({
7
- name: "ResizableSplit",
8
- __name: "ResizableSplit",
9
- props: {
10
- initialLeftWidth: { default: 280 },
11
- minLeftWidth: { default: 160 },
12
- maxLeftWidth: { default: 640 },
13
- minRightWidth: { default: 200 },
14
- storageKey: {},
15
- desktopMedia: { default: "(min-width: 768px)" },
16
- mobileTabMode: { type: Boolean, default: !1 },
17
- leftTabLabel: {},
18
- rightTabLabel: {}
19
- },
20
- setup(r, { expose: I }) {
21
- const n = r, { t: p } = te(), w = d(null), f = d(
22
- (() => {
23
- if (n.storageKey && typeof window < "u") {
24
- const l = Number(window.localStorage.getItem(n.storageKey));
25
- if (!isNaN(l) && l > 0) return l;
26
- }
27
- return n.initialLeftWidth;
28
- })()
29
- ), z = d(!1), y = d(!1), _ = d(!0), b = d("left");
30
- let o = null, t = null;
31
- const k = () => {
32
- o && (y.value = o.matches);
33
- }, x = C(
34
- () => y.value && _.value ? { width: `${f.value}px` } : void 0
35
- ), a = C(() => y.value && _.value), S = (l) => {
36
- if (!w.value) return;
37
- const c = w.value.getBoundingClientRect(), F = l.clientX - c.left, K = c.width - n.minRightWidth - 6, A = Math.min(n.maxLeftWidth, K);
38
- f.value = Math.max(
39
- n.minLeftWidth,
40
- Math.min(A, F)
41
- );
42
- }, $ = () => {
43
- if (z.value && (z.value = !1, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", $), document.body.style.cursor = "", document.body.style.userSelect = "", n.storageKey))
44
- try {
45
- window.localStorage.setItem(n.storageKey, String(f.value));
46
- } catch {
47
- }
48
- }, R = (l) => {
49
- l.preventDefault(), z.value = !0, window.addEventListener("mousemove", S), window.addEventListener("mouseup", $), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
50
- };
51
- re(() => {
52
- if (typeof window < "u") {
53
- o = window.matchMedia(n.desktopMedia), k(), o.addEventListener("change", k);
54
- const l = () => {
55
- w.value && (_.value = w.value.getBoundingClientRect().width >= n.minLeftWidth + n.minRightWidth + 6);
56
- };
57
- l(), t = typeof ResizeObserver < "u" ? new ResizeObserver(l) : null, t == null || t.observe(w.value);
58
- }
59
- }), Y(() => {
60
- o && o.removeEventListener("change", k), t == null || t.disconnect(), t = null, window.removeEventListener("mousemove", S), window.removeEventListener("mouseup", $), z.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
61
- }), P(
62
- () => n.initialLeftWidth,
63
- (l) => {
64
- n.storageKey || (f.value = l);
65
- }
66
- );
67
- const E = (l) => {
68
- b.value = l;
69
- };
70
- return I({ switchTab: E }), (l, c) => (v(), u("div", {
71
- ref_key: "containerRef",
72
- ref: w,
73
- class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col md:vfp-flex-row vfp-min-h-0 vfp-min-w-0",
74
- style: W(a.value ? void 0 : { flexDirection: "column" })
75
- }, [
76
- r.mobileTabMode && !a.value ? (v(), u(B, { key: 0 }, [
77
- i("div", Re, [
78
- i("button", {
79
- type: "button",
80
- class: U(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", b.value === "left" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
81
- onClick: c[0] || (c[0] = (F) => E("left"))
82
- }, T(r.leftTabLabel ?? g(p)("zip.file_tree")), 3),
83
- i("button", {
84
- type: "button",
85
- class: U(["vfp-flex-1 vfp-py-2.5 vfp-text-sm vfp-transition-colors", b.value === "right" ? "vfp-text-fg-primary vfp-border-b-2 vfp-border-fg-primary -vfp-mb-px" : "vfp-text-fg-secondary"]),
86
- onClick: c[1] || (c[1] = (F) => E("right"))
87
- }, T(r.rightTabLabel ?? g(p)("toolbar.preview")), 3)
88
- ]),
89
- V(i("div", Ce, [
90
- N(l.$slots, "left", {}, void 0, !0)
91
- ], 512), [
92
- [Z, b.value === "left"]
93
- ]),
94
- V(i("div", Ee, [
95
- N(l.$slots, "right", {}, void 0, !0)
96
- ], 512), [
97
- [Z, b.value === "right"]
98
- ])
99
- ], 64)) : (v(), u(B, { key: 1 }, [
100
- i("div", {
101
- class: "vfp-min-h-0 vfp-min-w-0 vfp-flex-shrink-0 vfp-w-full vfp-max-h-60 md:vfp-h-full md:vfp-max-h-none",
102
- style: W(x.value)
103
- }, [
104
- N(l.$slots, "left", {}, void 0, !0)
105
- ], 4),
106
- i("div", {
107
- role: "separator",
108
- "aria-orientation": "vertical",
109
- class: U(["split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors", z.value ? "dragging" : ""]),
110
- style: W(a.value ? void 0 : { display: "none" }),
111
- onMousedown: R
112
- }, [...c[2] || (c[2] = [
113
- i("span", { class: "vfp-absolute vfp-inset-y-0 hit-area" }, null, -1)
114
- ])], 38),
115
- i("div", Me, [
116
- N(l.$slots, "right", {}, void 0, !0)
117
- ])
118
- ], 64))
119
- ], 4));
120
- }
121
- }), De = /* @__PURE__ */ ne(We, [["__scopeId", "data-v-45379cb1"]]), Ie = { key: 0 }, Fe = { class: "vfp-truncate vfp-flex-1 vfp-min-w-0" }, Ue = { class: "vfp-flex-1 vfp-truncate vfp-min-w-0" }, Be = { class: "vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2" }, He = { name: "ZipTreeItem" }, Ne = /* @__PURE__ */ O({
122
- ...He,
123
- props: {
124
- node: {},
125
- depth: {},
126
- selectedPath: {},
127
- expanded: {}
128
- },
129
- emits: ["toggle", "select", "hover", "leave"],
130
- setup(r, { emit: I }) {
131
- const n = r, p = I, w = C(() => ({ paddingLeft: `${n.depth * 14 + 10}px` })), f = C(() => n.expanded.has(n.node.path)), z = C(() => n.selectedPath === n.node.path), y = C(() => {
132
- const o = pe({ name: n.node.name, type: "" });
133
- return o === "image" ? ye : o === "text" || o === "markdown" || o === "json" || o === "csv" || o === "xml" || o === "subtitle" ? n.node.name.endsWith(".md") || n.node.name.endsWith(".markdown") ? ke : Le : ze;
134
- }), _ = (o) => {
135
- const t = o.currentTarget.getBoundingClientRect();
136
- p("hover", n.node.name || "/", t);
137
- }, b = () => p("leave");
138
- return (o, t) => {
139
- const k = ve("ZipTreeItem");
140
- return r.node.isDir ? (v(), u("div", Ie, [
141
- i("button", {
142
- type: "button",
143
- class: "tree-row dir-row",
144
- style: W(w.value),
145
- onClick: t[0] || (t[0] = (x) => p("toggle", r.node.path)),
146
- onMouseenter: _,
147
- onMouseleave: b
148
- }, [
149
- j(g(Se), {
150
- class: U(["vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0 vfp-transition-transform", { "vfp-rotate-90": f.value }])
151
- }, null, 8, ["class"]),
152
- (v(), D(q(f.value ? g(Te) : g(_e)), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80" })),
153
- i("span", Fe, T(r.node.name || "/"), 1)
154
- ], 36),
155
- f.value && r.node.children ? (v(!0), u(B, { key: 0 }, Q(r.node.children, (x) => (v(), D(k, {
156
- key: x.path,
157
- node: x,
158
- depth: r.depth + 1,
159
- "selected-path": r.selectedPath,
160
- expanded: r.expanded,
161
- onToggle: t[1] || (t[1] = (a) => p("toggle", a)),
162
- onSelect: t[2] || (t[2] = (a) => p("select", a)),
163
- onHover: t[3] || (t[3] = (a, S) => p("hover", a, S)),
164
- onLeave: t[4] || (t[4] = (a) => p("leave"))
165
- }, null, 8, ["node", "depth", "selected-path", "expanded"]))), 128)) : ee("", !0)
166
- ])) : (v(), u("button", {
167
- key: 1,
168
- type: "button",
169
- class: U(["tree-row file-row", { selected: z.value }]),
170
- style: W(w.value),
171
- onClick: t[5] || (t[5] = (x) => p("select", r.node)),
172
- onMouseenter: _,
173
- onMouseleave: b
174
- }, [
175
- t[6] || (t[6] = i("span", { class: "vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0" }, null, -1)),
176
- (v(), D(q(y.value), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary" })),
177
- i("span", Ue, T(r.node.name), 1),
178
- i("span", Be, T(g(ue)(r.node.size)), 1)
179
- ], 38));
180
- };
181
- }
182
- }), je = /* @__PURE__ */ ne(Ne, [["__scopeId", "data-v-124c382d"]]), Ke = {
183
- key: 0,
184
- class: "vfp-renderer-loading"
185
- }, Pe = { class: "vfp-renderer-loading-content" }, Oe = { class: "vfp-renderer-loading-text" }, Ae = { class: "vfp-w-full vfp-h-full vfp-overflow-auto" }, Ve = { class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col" }, Ze = {
186
- key: 0,
187
- class: "vfp-renderer-loading vfp-flex-1"
188
- }, qe = { class: "vfp-renderer-loading-content" }, Ge = { class: "vfp-renderer-loading-text" }, Xe = {
189
- key: 1,
190
- class: "vfp-flex-1"
191
- }, Je = {
192
- key: 2,
193
- class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-muted vfp-text-sm vfp-p-6"
194
- }, Ye = {
195
- key: 3,
196
- class: "vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0"
197
- }, ot = /* @__PURE__ */ O({
198
- __name: "index",
199
- props: {
200
- url: {},
201
- nestingDepth: { default: 0 }
202
- },
203
- setup(r, { expose: I }) {
204
- const n = fe(
205
- () => import("./index-B5hprvcF.mjs").then((e) => e.a2)
206
- ), p = r, w = new $e(), { t: f } = te(), z = ce(), y = me(), _ = (e) => {
207
- y.error(e.error, e.stage);
208
- }, b = d(null), o = d(null), t = d(!0), k = d(null), x = d(/* @__PURE__ */ new Set([""])), a = d(null), S = d(!1), $ = d(null), R = d(null), E = d(null), l = d(null), c = () => {
209
- var e;
210
- (e = a.value) != null && e.blobUrl && URL.revokeObjectURL(a.value.blobUrl);
211
- }, F = async () => {
212
- y.begin(p.url), c(), a.value = null, t.value = !0, k.value = null;
213
- try {
214
- const e = await z.value(p.url);
215
- if (!e.ok) throw new he("common.load_failed");
216
- const s = await e.arrayBuffer(), m = await ge(s), L = we(m), h = be(L);
217
- b.value = m, o.value = h;
218
- const M = /* @__PURE__ */ new Set([""]);
219
- if (h.children)
220
- for (const H of h.children) H.isDir && M.add(H.path);
221
- x.value = M, y.ready();
222
- } catch (e) {
223
- console.error(e), k.value = f.value("zip.load_failed"), y.error(e);
224
- } finally {
225
- t.value = !1;
226
- }
227
- };
228
- P(() => p.url, (e) => {
229
- e && F();
230
- }, { immediate: !0 }), Y(() => {
231
- c();
232
- });
233
- const K = C(() => {
234
- if (!o.value) return null;
235
- let e = 0, s = 0, m = 0;
236
- const L = (h) => {
237
- var M;
238
- h.isDir ? (h.path && s++, (M = h.children) == null || M.forEach(L)) : (e++, m += h.size);
239
- };
240
- return L(o.value), { files: e, dirs: s, size: m };
241
- });
242
- P(K, () => w.notify()), I({
243
- getToolbarGroups: () => [],
244
- onToolbarChange: (e) => w.subscribe(e)
245
- });
246
- const le = (e) => {
247
- const s = new Set(x.value);
248
- s.has(e) ? s.delete(e) : s.add(e), x.value = s;
249
- }, oe = (e, s) => {
250
- const m = typeof window < "u" ? window.innerWidth - 328 : s.right + 8;
251
- R.value = { text: e, x: Math.max(8, Math.min(s.right + 8, m)), y: s.top + s.height / 2 };
252
- }, ae = () => {
253
- R.value = null;
254
- }, se = async (e) => {
255
- var s, m, L;
256
- if (!(!b.value || e.isDir || ((s = a.value) == null ? void 0 : s.path) === e.path || l.value === e.path)) {
257
- l.value = e.path, c(), a.value = null, S.value = !0, $.value = null;
258
- try {
259
- const h = X(e.name), M = await xe(b.value, e.path, h !== "application/octet-stream" ? h : void 0), H = URL.createObjectURL(M);
260
- a.value = { path: e.path, name: e.name, size: e.size, blobUrl: H }, (m = E.value) == null || m.switchTab("right");
261
- } catch (h) {
262
- console.error(h), $.value = f.value("zip.entry_read_failed"), (L = E.value) == null || L.switchTab("right");
263
- } finally {
264
- S.value = !1, l.value === e.path && (l.value = null);
265
- }
266
- }
267
- }, ie = C(() => a.value ? [{ name: a.value.name, url: a.value.blobUrl, type: X(a.value.name) }] : []);
268
- return (e, s) => t.value ? (v(), u("div", Ke, [
269
- i("div", Pe, [
270
- s[0] || (s[0] = i("div", { class: "vfp-renderer-spinner" }, null, -1)),
271
- i("span", Oe, T(g(f)("common.loading")), 1)
272
- ])
273
- ])) : k.value || !o.value ? (v(), D(J, {
274
- key: 1,
275
- message: k.value || g(f)("zip.parse_failed")
276
- }, null, 8, ["message"])) : (v(), u(B, { key: 2 }, [
277
- j(De, {
278
- ref_key: "splitRef",
279
- ref: E,
280
- "initial-left-width": 280,
281
- "min-left-width": 180,
282
- "max-left-width": 560,
283
- "storage-key": "vfp-zip-split-left",
284
- "mobile-tab-mode": "",
285
- "left-tab-label": g(f)("zip.file_tree"),
286
- "right-tab-label": g(f)("toolbar.preview")
287
- }, {
288
- left: G(() => [
289
- i("div", Ae, [
290
- (v(!0), u(B, null, Q(o.value.children || [], (m) => {
291
- var L;
292
- return v(), D(je, {
293
- key: m.path,
294
- node: m,
295
- depth: 0,
296
- "selected-path": ((L = a.value) == null ? void 0 : L.path) ?? null,
297
- expanded: x.value,
298
- onToggle: le,
299
- onSelect: se,
300
- onHover: oe,
301
- onLeave: ae
302
- }, null, 8, ["node", "selected-path", "expanded"]);
303
- }), 128))
304
- ])
305
- ]),
306
- right: G(() => [
307
- i("div", Ve, [
308
- S.value ? (v(), u("div", Ze, [
309
- i("div", qe, [
310
- s[1] || (s[1] = i("div", { class: "vfp-renderer-spinner" }, null, -1)),
311
- i("span", Ge, T(g(f)("common.loading")), 1)
312
- ])
313
- ])) : $.value ? (v(), u("div", Xe, [
314
- j(J, { message: $.value }, null, 8, ["message"])
315
- ])) : a.value ? (v(), u("div", Ye, [
316
- j(g(n), {
317
- mode: "embed",
318
- files: ie.value,
319
- "current-index": 0,
320
- "zip-nesting-depth": r.nestingDepth + 1,
321
- onError: _
322
- }, null, 8, ["files", "zip-nesting-depth"])
323
- ])) : (v(), u("div", Je, T(g(f)("zip.select_file")), 1))
324
- ])
325
- ]),
326
- _: 1
327
- }, 8, ["left-tab-label", "right-tab-label"]),
328
- (v(), D(de, { to: "body" }, [
329
- R.value ? (v(), u("div", {
330
- key: 0,
331
- class: "vfp-zip-tip",
332
- style: W({
333
- position: "fixed",
334
- zIndex: 2147483647,
335
- pointerEvents: "none",
336
- display: "block",
337
- transform: "translateY(-50%)",
338
- padding: "4px 8px",
339
- background: "rgba(0, 0, 0, 0.85)",
340
- color: "#fff",
341
- fontSize: "12px",
342
- lineHeight: 1.5,
343
- borderRadius: "4px",
344
- whiteSpace: "nowrap",
345
- maxWidth: "min(320px, calc(100vw - 16px))",
346
- overflow: "hidden",
347
- textOverflow: "ellipsis",
348
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.3)",
349
- left: R.value.x + "px",
350
- top: R.value.y + "px"
351
- })
352
- }, T(R.value.text), 5)) : ee("", !0)
353
- ]))
354
- ], 64));
355
- }
356
- });
357
- export {
358
- ot as default
359
- };
@@ -1,137 +0,0 @@
1
- import { defineComponent as W, ref as g, onMounted as z, watch as L, onBeforeUnmount as B, openBlock as d, createElementBlock as h, createElementVNode as _, toDisplayString as H, unref as T, createCommentVNode as y, createVNode as F, normalizeStyle as R } from "vue";
2
- import { u as A, a as C, b as G, J as v, L as N, E as U, U as V, z as J, t as O, F as q, p as I } from "./index-B5hprvcF.mjs";
3
- import P from "exceljs";
4
- import { S as X } from "./index-CyBXARuf.mjs";
5
- import { _ as $ } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
- const j = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, K = {
7
- key: 0,
8
- class: "vfp-renderer-overlay vfp-renderer-loading"
9
- }, Q = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
10
- key: 1,
11
- class: "vfp-renderer-overlay"
12
- }, oe = /* @__PURE__ */ W({
13
- __name: "index",
14
- props: {
15
- url: {},
16
- emptyHint: {}
17
- },
18
- setup(E, { expose: D }) {
19
- async function M(e) {
20
- try {
21
- return await new P.Workbook().xlsx.load(e.slice().buffer);
22
- } catch (t) {
23
- throw t instanceof TypeError && /sheets/i.test(t.message) ? new v("xlsx.invalid_format") : t;
24
- }
25
- }
26
- const p = E, { t: a } = A(), S = C(), m = G(), o = g(!0), n = g(null), l = g(null);
27
- let i = null, w = 100, f = null, u = null, c = { width: 0, height: 0 };
28
- const x = () => {
29
- if (!l.value) return { width: 800, height: 600 };
30
- const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
31
- return { width: r, height: s };
32
- }, b = () => {
33
- if (!l.value || !i) return;
34
- l.value.innerHTML = "";
35
- const { width: e, height: t } = x(), r = e < 640;
36
- new X(l.value, {
37
- mode: "read",
38
- showToolbar: !1,
39
- showContextmenu: !1,
40
- showGrid: !0,
41
- row: {
42
- len: w,
43
- height: 25
44
- },
45
- col: {
46
- len: 26,
47
- width: r ? 80 : 100,
48
- indexWidth: r ? 40 : 60,
49
- minWidth: r ? 40 : 60
50
- },
51
- view: {
52
- height: () => t,
53
- width: () => e
54
- }
55
- }).loadData(i);
56
- }, k = async () => {
57
- if (m.begin(p.url), !!l.value) {
58
- o.value = !0, n.value = null;
59
- try {
60
- const e = await S.value(p.url, {
61
- mode: "cors",
62
- credentials: "omit",
63
- redirect: "follow"
64
- });
65
- if (!e.ok)
66
- throw e.status === 404 ? new Error(a.value("xlsx.not_found")) : e.status === 403 ? new v("file.forbidden") : new v("file.load_failed_status", { status: e.status });
67
- const t = N(await e.arrayBuffer());
68
- let r;
69
- if (t.byteLength === 0)
70
- r = [{ name: "Sheet1" }];
71
- else if (U(t)) {
72
- const s = V(t);
73
- if (!s || !Array.isArray(s.sheets))
74
- throw new v("xlsx.invalid_legacy_data");
75
- r = J(s);
76
- } else
77
- r = O(
78
- await M(t)
79
- );
80
- i = r.length ? r : [{ name: "Sheet1" }], w = q(r), b(), o.value = !1, m.ready();
81
- } catch (e) {
82
- console.error(a.value("xlsx.parse_failed") + ":", e);
83
- let t = a.value("xlsx.parse_failed");
84
- e instanceof Error && (t = I(a.value, e)), n.value = t, o.value = !1, m.error(e);
85
- }
86
- }
87
- };
88
- return z(() => {
89
- if (!l.value) return;
90
- let e = !0;
91
- f = new ResizeObserver(() => {
92
- if (e) {
93
- e = !1, c = x();
94
- return;
95
- }
96
- const t = x(), r = Math.abs(c.width - t.width), s = Math.abs(c.height - t.height);
97
- r < 10 && s < 10 || (c = t, u !== null && clearTimeout(u), u = window.setTimeout(() => {
98
- i && b();
99
- }, 500));
100
- }), f.observe(l.value), setTimeout(() => {
101
- requestAnimationFrame(() => k());
102
- }, 100);
103
- }), L(
104
- () => p.url,
105
- (e) => {
106
- e && k();
107
- }
108
- ), B(() => {
109
- f && f.disconnect(), u !== null && clearTimeout(u), i = null, w = 100, l.value && (l.value.innerHTML = "");
110
- }), D({
111
- getToolbarGroups: () => []
112
- }), (e, t) => (d(), h("div", j, [
113
- o.value ? (d(), h("div", K, [
114
- _("div", Q, [
115
- t[0] || (t[0] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
116
- _("p", Y, H(T(a)("xlsx.loading")), 1)
117
- ])
118
- ])) : y("", !0),
119
- n.value && !o.value ? (d(), h("div", Z, [
120
- F($, {
121
- message: T(a)("xlsx.load_failed"),
122
- detail: n.value
123
- }, null, 8, ["message", "detail"])
124
- ])) : y("", !0),
125
- n.value ? y("", !0) : (d(), h("div", {
126
- key: 2,
127
- ref_key: "containerRef",
128
- ref: l,
129
- class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
130
- style: R({ opacity: o.value ? 0 : 1 })
131
- }, null, 4))
132
- ]));
133
- }
134
- });
135
- export {
136
- oe as default
137
- };