@eternalheart/vue-file-preview 1.6.13 → 1.7.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 (125) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/lib/FilePreviewContent.vue.d.ts +17 -6
  4. package/lib/FilePreviewEmbed.vue.d.ts +14 -6
  5. package/lib/FilePreviewModal.vue.d.ts +14 -6
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-CnJpGYJ2.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-g_dLrWLP.mjs} +1 -1
  9. package/lib/chunks/index-6XZXYqbp.mjs +125 -0
  10. package/lib/chunks/{index-B21EAyWz.mjs → index-BPSzwMOC.mjs} +51 -51
  11. package/lib/chunks/index-BYQ9S7Mk.mjs +104 -0
  12. package/lib/chunks/{index-8Vpbg2kS.mjs → index-Bf94DwQu.mjs} +105 -104
  13. package/lib/chunks/index-BfOWoMpY.mjs +359 -0
  14. package/lib/chunks/index-Bg8poMIm.mjs +117 -0
  15. package/lib/chunks/index-BzwJ0VWu.mjs +108 -0
  16. package/lib/chunks/index-C41YET0_.mjs +51 -0
  17. package/lib/chunks/{index-BvBqDq3O.mjs → index-C4hIk6pa.mjs} +2023 -2023
  18. package/lib/chunks/{index-BASg1cr4.mjs → index-C8lyQPe3.mjs} +1018 -1018
  19. package/lib/chunks/{index-C9mAajbD.mjs → index-CWPdNhoe.mjs} +200 -200
  20. package/lib/chunks/{index-BuqPb5mP.mjs → index-CrVQPnFj.mjs} +112 -112
  21. package/lib/chunks/{index-D30L8tm9.mjs → index-D5IF9F-D.mjs} +57 -57
  22. package/lib/chunks/{index-DN4Ui0Gh.mjs → index-DFeKS8tR.mjs} +120 -120
  23. package/lib/chunks/index-DM8Dfl-m.mjs +52 -0
  24. package/lib/chunks/index-DZe0BxAB.mjs +90 -0
  25. package/lib/chunks/{index-BlrFFeqc.mjs → index-GFcSJEwj.mjs} +75 -75
  26. package/lib/chunks/{index-Dkro_8Fy.mjs → index-LPGxJDnT.mjs} +32 -32
  27. package/lib/chunks/index-aKiIuKKx.mjs +157 -0
  28. package/lib/chunks/{index-DZZN3kYi.mjs → index-c-pYJEmH.mjs} +1589 -1394
  29. package/lib/chunks/{index-CxKZKUJj.mjs → index-z9RqL2wI.mjs} +1651 -1651
  30. package/lib/chunks/index-zLQlyNR2.mjs +383 -0
  31. package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-fCO1knZ0.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-DihMskai.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-BSfDPl-z.mjs} +5 -5
  34. package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-JY5DaTre.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-C-ztcJBE.mjs} +1 -1
  36. package/lib/composables/useAudioPlayer.d.ts +1 -1
  37. package/lib/composables/usePreviewEvents.d.ts +27 -0
  38. package/lib/composables/useRequest.d.ts +16 -4
  39. package/lib/composables/useThemeMode.d.ts +1 -1
  40. package/lib/composables/useTranslator.d.ts +2 -2
  41. package/lib/core/events.d.ts +52 -0
  42. package/lib/core/i18n/index.d.ts +29 -0
  43. package/lib/core/i18n/messages/en-US.d.ts +5 -0
  44. package/lib/core/i18n/messages/index.d.ts +9 -0
  45. package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
  46. package/lib/core/i18n/types.d.ts +23 -0
  47. package/lib/core/index.d.ts +34 -0
  48. package/lib/core/loaders/avifLoader.d.ts +22 -0
  49. package/lib/core/loaders/heicLoader.d.ts +21 -0
  50. package/lib/core/loaders/jp2Loader.d.ts +16 -0
  51. package/lib/core/loaders/jp2Worker.d.ts +1 -0
  52. package/lib/core/loaders/psdLoader.d.ts +14 -0
  53. package/lib/core/loaders/rawLoader.d.ts +14 -0
  54. package/lib/core/loaders/registry.d.ts +32 -0
  55. package/lib/core/loaders/tiffLoader.d.ts +28 -0
  56. package/lib/core/loaders/types.d.ts +56 -0
  57. package/lib/core/types.d.ts +89 -0
  58. package/lib/core/utils/csvParser.d.ts +31 -0
  59. package/lib/core/utils/emptyState.d.ts +28 -0
  60. package/lib/core/utils/excelDataConverter.d.ts +61 -0
  61. package/lib/core/utils/fileNormalizer.d.ts +21 -0
  62. package/lib/core/utils/fileType.d.ts +21 -0
  63. package/lib/core/utils/legacy-office/doc.d.ts +25 -0
  64. package/lib/core/utils/legacy-office/index.d.ts +8 -0
  65. package/lib/core/utils/legacy-office/ole.d.ts +8 -0
  66. package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
  67. package/lib/core/utils/legacy-office/xls.d.ts +28 -0
  68. package/lib/core/utils/mimeTypes.d.ts +29 -0
  69. package/lib/core/utils/ooxml/docx.d.ts +17 -0
  70. package/lib/core/utils/ooxml/index.d.ts +4 -0
  71. package/lib/core/utils/ooxml/pptx.d.ts +7 -0
  72. package/lib/core/utils/ooxml/xml.d.ts +15 -0
  73. package/lib/core/utils/ooxml/zip.d.ts +3 -0
  74. package/lib/core/utils/pdfWorker.d.ts +61 -0
  75. package/lib/core/utils/previewMode.d.ts +7 -0
  76. package/lib/core/utils/request.d.ts +49 -0
  77. package/lib/core/utils/subtitleParser.d.ts +44 -0
  78. package/lib/core/utils/textDecoder.d.ts +30 -0
  79. package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
  80. package/lib/core/utils/zipReader.d.ts +51 -0
  81. package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
  82. package/lib/core/workers/workerClient.d.ts +14 -0
  83. package/lib/i18n/localeKey.d.ts +1 -1
  84. package/lib/index.cjs +60 -60
  85. package/lib/index.css +1 -1
  86. package/lib/index.d.ts +11 -9
  87. package/lib/index.mjs +15 -12
  88. package/lib/renderers/Audio/index.vue.d.ts +1 -1
  89. package/lib/renderers/Cad/index.vue.d.ts +1 -1
  90. package/lib/renderers/Cad/toolbar.d.ts +2 -2
  91. package/lib/renderers/Csv/index.vue.d.ts +1 -1
  92. package/lib/renderers/Doc/index.vue.d.ts +1 -1
  93. package/lib/renderers/Docx/index.vue.d.ts +1 -1
  94. package/lib/renderers/Epub/index.vue.d.ts +1 -1
  95. package/lib/renderers/Font/index.vue.d.ts +1 -1
  96. package/lib/renderers/Image/index.vue.d.ts +2 -2
  97. package/lib/renderers/Json/index.vue.d.ts +2 -2
  98. package/lib/renderers/Markdown/index.vue.d.ts +1 -1
  99. package/lib/renderers/Mobi/index.vue.d.ts +1 -1
  100. package/lib/renderers/Msg/index.vue.d.ts +1 -1
  101. package/lib/renderers/Pdf/index.vue.d.ts +1 -1
  102. package/lib/renderers/Ppt/index.vue.d.ts +1 -1
  103. package/lib/renderers/Pptx/index.vue.d.ts +2 -2
  104. package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
  105. package/lib/renderers/Text/index.vue.d.ts +2 -2
  106. package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
  107. package/lib/renderers/Video/index.vue.d.ts +1 -1
  108. package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
  109. package/lib/renderers/Xml/index.vue.d.ts +1 -1
  110. package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
  111. package/lib/renderers/Zip/index.vue.d.ts +1 -1
  112. package/lib/renderers/base.types.d.ts +1 -1
  113. package/lib/renderers/registry.d.ts +1 -1
  114. package/lib/types.d.ts +3 -3
  115. package/package.json +2 -2
  116. package/lib/chunks/index--612Smof.mjs +0 -383
  117. package/lib/chunks/index-BB0i4QqI.mjs +0 -117
  118. package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
  119. package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
  120. package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
  121. package/lib/chunks/index-CDg6vIbT.mjs +0 -51
  122. package/lib/chunks/index-CWE-hKSs.mjs +0 -90
  123. package/lib/chunks/index-CY3xzGgt.mjs +0 -108
  124. package/lib/chunks/index-VdzIFJJW.mjs +0 -118
  125. package/lib/chunks/index-aoXgVLBb.mjs +0 -52
package/README.md CHANGED
@@ -390,6 +390,7 @@ Differences from `FilePreviewModal`:
390
390
  |-------|---------|-------------|
391
391
  | `close` | - | Emitted when the modal should close |
392
392
  | `navigate` | `number` | Emitted when navigating to a different file index |
393
+ | `error` | `PreviewErrorPayload` | Emitted when loading or rendering fails (at most once per load) |
393
394
 
394
395
  ### FilePreviewEmbed Props
395
396
 
@@ -415,6 +416,7 @@ Differences from `FilePreviewModal`:
415
416
  | Event | Payload | Description |
416
417
  |-------|---------|-------------|
417
418
  | `navigate` | `number` | Emitted when navigating to a different file index |
419
+ | `error` | `PreviewErrorPayload` | Emitted when loading or rendering fails (at most once per load) |
418
420
 
419
421
  ### FilePreviewContent (advanced)
420
422
 
package/README.zh-CN.md CHANGED
@@ -390,6 +390,7 @@ const files = [
390
390
  |------|------|------|
391
391
  | `close` | - | 关闭预览时触发 |
392
392
  | `navigate` | `number` | 导航到其他文件时触发 |
393
+ | `error` | `PreviewErrorPayload` | 加载或渲染失败时触发(每次加载最多一次) |
393
394
 
394
395
  ### FilePreviewEmbed Props
395
396
 
@@ -415,6 +416,7 @@ const files = [
415
416
  | 事件 | 参数 | 说明 |
416
417
  |------|------|------|
417
418
  | `navigate` | `number` | 导航到其他文件时触发 |
419
+ | `error` | `PreviewErrorPayload` | 加载或渲染失败时触发(每次加载最多一次) |
418
420
 
419
421
  ### FilePreviewContent(高级用法)
420
422
 
@@ -1,5 +1,5 @@
1
- import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob, type EmptyHintMode } from '@eternalheart/file-preview-core';
2
- import type { CustomRenderer } from './types';
1
+ import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob, type FileLoader, type EmptyHintMode, type PreviewErrorPayload } from './core/index.js';
2
+ import type { CustomRenderer } from './types.js';
3
3
  interface Props {
4
4
  files: PreviewFileInput[];
5
5
  currentIndex: number;
@@ -16,16 +16,23 @@ interface Props {
16
16
  headless?: boolean;
17
17
  /** 主题模式,默认 'dark' */
18
18
  theme?: Theme;
19
- /** 自定义 RequestInit(或工厂函数):注入 Authorization 等鉴权头 */
19
+ /** 统一取数入口:鉴权 / 签名场景下由宿主决定文件怎么取 */
20
+ loadFile?: FileLoader;
21
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
20
22
  requestInit?: RequestInitFactory;
21
- /** 自定义请求处理器:完全接管库内 fetch */
23
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
22
24
  requestHandler?: RequestHandler;
23
- /** 返回 true 时,对应文件先 fetcher→blob URL 后喂给 image/video/audio/pdf 等 renderer */
25
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
24
26
  shouldFetchAsBlob?: ShouldFetchAsBlob;
25
27
  /** 自定义下载回调;不传时库内默认通过 fetcher 拉 Blob 触发下载 */
26
28
  onDownload?: (file: PreviewFile) => void | Promise<void>;
27
29
  /** 关闭回调 */
28
30
  onClose?: () => void;
31
+ /**
32
+ * 加载/渲染失败回调(与 `@error` 等价)。
33
+ * 每次加载最多触发一次,payload 已由顶层补全 file/index/stage。
34
+ */
35
+ onError?: (payload: PreviewErrorPayload) => void;
29
36
  /** 是否显示关闭按钮,默认根据 mode 决定(modal: true, embed: false) */
30
37
  showClose?: boolean;
31
38
  /** 是否显示下载按钮,默认 true */
@@ -43,16 +50,21 @@ interface Props {
43
50
  emptyHint?: EmptyHintMode;
44
51
  }
45
52
  declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
53
+ error: (payload: PreviewErrorPayload) => any;
46
54
  close: () => any;
47
55
  navigate: (index: number) => any;
48
56
  "custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
49
57
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
58
+ onError?: ((payload: PreviewErrorPayload) => any) | undefined;
50
59
  onClose?: (() => any) | undefined;
51
60
  onNavigate?: ((index: number) => any) | undefined;
52
61
  "onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
53
62
  }>, {
54
63
  requestInit: RequestInitFactory;
55
64
  requestHandler: RequestHandler;
65
+ shouldFetchAsBlob: ShouldFetchAsBlob;
66
+ loadFile: FileLoader;
67
+ onError: (payload: PreviewErrorPayload) => void;
56
68
  mode: "modal" | "embed";
57
69
  emptyHint: EmptyHintMode;
58
70
  onClose: () => void;
@@ -62,7 +74,6 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
62
74
  locale: Locale;
63
75
  messages: Partial<Record<Locale, Partial<Messages>>>;
64
76
  headless: boolean;
65
- shouldFetchAsBlob: ShouldFetchAsBlob;
66
77
  onDownload: (file: PreviewFile) => void | Promise<void>;
67
78
  showClose: boolean;
68
79
  showDownload: boolean;
@@ -1,5 +1,5 @@
1
- import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
2
- import type { CustomRenderer } from './types';
1
+ import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload } from './core/index.js';
2
+ import type { CustomRenderer } from './types.js';
3
3
  interface Props {
4
4
  files: PreviewFileInput[];
5
5
  currentIndex?: number;
@@ -16,16 +16,20 @@ interface Props {
16
16
  headless?: boolean;
17
17
  /** 主题模式,默认 'dark' */
18
18
  theme?: Theme;
19
- /** 自定义 RequestInit(或工厂函数):注入 Authorization 等鉴权头 */
19
+ /** 统一取数入口:鉴权 / 签名场景下由宿主决定文件怎么取 */
20
+ loadFile?: FileLoader;
21
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
20
22
  requestInit?: RequestInitFactory;
21
- /** 自定义请求处理器:完全接管库内 fetch */
23
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
22
24
  requestHandler?: RequestHandler;
23
- /** 返回 true 时,对应文件先 fetcher→blob URL 后喂给 image/video/audio/pdf 等 renderer */
25
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
24
26
  shouldFetchAsBlob?: ShouldFetchAsBlob;
25
27
  /** 自定义下载回调;不传时库内默认通过 fetcher 拉 Blob 触发下载 */
26
28
  onDownload?: (file: PreviewFile) => void | Promise<void>;
27
29
  /** 关闭回调 */
28
30
  onClose?: () => void;
31
+ /** 加载/渲染失败回调(与 `@error` 等价) */
32
+ onError?: (payload: PreviewErrorPayload) => void;
29
33
  /** 是否显示关闭按钮,默认根据 mode 决定(embed: false) */
30
34
  showClose?: boolean;
31
35
  /** 是否显示下载按钮,默认 true */
@@ -38,16 +42,21 @@ interface Props {
38
42
  emptyHint?: EmptyHintMode;
39
43
  }
40
44
  declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
45
+ error: (payload: PreviewErrorPayload) => any;
41
46
  close: () => any;
42
47
  navigate: (index: number) => any;
43
48
  "custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
44
49
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
50
+ onError?: ((payload: PreviewErrorPayload) => any) | undefined;
45
51
  onClose?: (() => any) | undefined;
46
52
  onNavigate?: ((index: number) => any) | undefined;
47
53
  "onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
48
54
  }>, {
49
55
  requestInit: RequestInitFactory;
50
56
  requestHandler: RequestHandler;
57
+ shouldFetchAsBlob: ShouldFetchAsBlob;
58
+ loadFile: FileLoader;
59
+ onError: (payload: PreviewErrorPayload) => void;
51
60
  height: number | string;
52
61
  width: number | string;
53
62
  emptyHint: EmptyHintMode;
@@ -58,7 +67,6 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
58
67
  locale: Locale;
59
68
  messages: Partial<Record<Locale, Partial<Messages>>>;
60
69
  headless: boolean;
61
- shouldFetchAsBlob: ShouldFetchAsBlob;
62
70
  onDownload: (file: PreviewFile) => void | Promise<void>;
63
71
  showClose: boolean;
64
72
  showDownload: boolean;
@@ -1,5 +1,5 @@
1
- import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
2
- import type { CustomRenderer } from './types';
1
+ import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob, FileLoader, PreviewErrorPayload } from './core/index.js';
2
+ import type { CustomRenderer } from './types.js';
3
3
  interface Props {
4
4
  files: PreviewFileInput[];
5
5
  currentIndex: number;
@@ -13,11 +13,13 @@ interface Props {
13
13
  headless?: boolean;
14
14
  /** 主题模式,默认 'dark' */
15
15
  theme?: Theme;
16
- /** 自定义 RequestInit(或工厂函数):注入 Authorization 等鉴权头 */
16
+ /** 统一取数入口:鉴权 / 签名场景下由宿主决定文件怎么取 */
17
+ loadFile?: FileLoader;
18
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
17
19
  requestInit?: RequestInitFactory;
18
- /** 自定义请求处理器:完全接管库内 fetch */
20
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
19
21
  requestHandler?: RequestHandler;
20
- /** 返回 true 时,对应文件先 fetcher→blob URL 后喂给 image/video/audio/pdf 等 renderer */
22
+ /** @deprecated 将在 1.8.0 移除;请改用 `loadFile` */
21
23
  shouldFetchAsBlob?: ShouldFetchAsBlob;
22
24
  /** 自定义下载回调;不传时库内默认通过 fetcher 拉 Blob 触发下载 */
23
25
  onDownload?: (file: PreviewFile) => void | Promise<void>;
@@ -31,25 +33,31 @@ interface Props {
31
33
  loopNavigation?: boolean;
32
34
  /** 空内容提示策略,默认 'auto'(文本类空白、结构化类型提示) */
33
35
  emptyHint?: EmptyHintMode;
36
+ /** 加载/渲染失败回调(与 `@error` 等价) */
37
+ onError?: (payload: PreviewErrorPayload) => void;
34
38
  }
35
39
  declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
40
+ error: (payload: PreviewErrorPayload) => any;
36
41
  close: () => any;
37
42
  navigate: (index: number) => any;
38
43
  "custom-event": (payload: CustomRendererEventPayload<unknown>) => any;
39
44
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
45
+ onError?: ((payload: PreviewErrorPayload) => any) | undefined;
40
46
  onClose?: (() => any) | undefined;
41
47
  onNavigate?: ((index: number) => any) | undefined;
42
48
  "onCustom-event"?: ((payload: CustomRendererEventPayload<unknown>) => any) | undefined;
43
49
  }>, {
44
50
  requestInit: RequestInitFactory;
45
51
  requestHandler: RequestHandler;
52
+ shouldFetchAsBlob: ShouldFetchAsBlob;
53
+ loadFile: FileLoader;
54
+ onError: (payload: PreviewErrorPayload) => void;
46
55
  emptyHint: EmptyHintMode;
47
56
  theme: Theme;
48
57
  customRenderers: CustomRenderer[];
49
58
  locale: Locale;
50
59
  messages: Partial<Record<Locale, Partial<Messages>>>;
51
60
  headless: boolean;
52
- shouldFetchAsBlob: ShouldFetchAsBlob;
53
61
  onDownload: (file: PreviewFile) => void | Promise<void>;
54
62
  showClose: boolean;
55
63
  showDownload: boolean;
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as s, openBlock as o, createElementBlock as p, createElementVNode as e, createVNode as n, unref as t, toDisplayString as f } from "vue";
2
2
  import { FileMinus as c } from "lucide-vue-next";
3
- import { u as i } from "./index-DZZN3kYi.mjs";
3
+ import { u as i } from "./index-c-pYJEmH.mjs";
4
4
  const a = { class: "vfp-renderer-empty" }, m = { class: "vfp-renderer-empty-content" }, _ = { class: "vfp-w-12 vfp-h-12 vfp-rounded-full vfp-bg-surface-2 vfp-flex vfp-items-center vfp-justify-center" }, l = { class: "vfp-renderer-empty-text" }, g = /* @__PURE__ */ s({
5
5
  __name: "EmptyState",
6
6
  setup(v) {
@@ -1,4 +1,4 @@
1
- import { k as t } from "./index-DZZN3kYi.mjs";
1
+ import { J as t } from "./index-c-pYJEmH.mjs";
2
2
  let a = null;
3
3
  async function B() {
4
4
  return a !== null ? a : new Promise((o) => {
@@ -1,4 +1,4 @@
1
- import { k as o } from "./index-DZZN3kYi.mjs";
1
+ import { J as o } from "./index-c-pYJEmH.mjs";
2
2
  class l {
3
3
  /**
4
4
  * HEIC 格式浏览器均不原生支持,始终需要解码
@@ -0,0 +1,125 @@
1
+ import { defineComponent as z, ref as y, watch as T, computed as v, openBlock as r, createElementBlock as o, createElementVNode as s, toDisplayString as a, unref as n, createBlock as A, normalizeClass as B, Fragment as w, renderList as C, createCommentVNode as E } from "vue";
2
+ import { u as D, a as I, b as M, o as O, W as p, h as P, e as R } from "./index-c-pYJEmH.mjs";
3
+ import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
4
+ const Y = {
5
+ key: 0,
6
+ class: "vfp-renderer-loading vfp-bg-[#0f0f12]"
7
+ }, $ = { class: "vfp-renderer-loading-content" }, j = { class: "vfp-renderer-loading-text" }, q = { class: "content-scroll" }, H = { class: "timeline" }, J = { class: "cues" }, K = { class: "cue-meta" }, Q = { class: "cue-time" }, U = { class: "cue-time" }, Z = { class: "cue-id" }, ee = {
8
+ key: 0,
9
+ class: "cue-style"
10
+ }, se = {
11
+ key: 0,
12
+ class: "cue-words"
13
+ }, te = ["title"], le = { class: "cue-word-time" }, re = { class: "cue-word-text" }, ae = { class: "status-pill" }, oe = /* @__PURE__ */ z({
14
+ __name: "index",
15
+ props: {
16
+ url: {},
17
+ fileName: {}
18
+ },
19
+ setup(F, { expose: N }) {
20
+ const i = F, { t: u } = D(), L = I(), f = M(), m = y(""), _ = y(!0), d = y(null), S = {
21
+ srt: "srt",
22
+ vtt: "vtt",
23
+ lrc: "lrc",
24
+ elrc: "elrc",
25
+ ass: "ass",
26
+ ssa: "ssa",
27
+ ttml: "ttml",
28
+ dfxp: "ttml"
29
+ }, G = (e) => {
30
+ var l;
31
+ const t = ((l = e.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
32
+ return S[t];
33
+ };
34
+ T(() => i.url, async () => {
35
+ f.begin(i.url), _.value = !0, d.value = null;
36
+ try {
37
+ m.value = await P(i.url, { fetcher: L.value });
38
+ } catch (e) {
39
+ console.error(e), d.value = u.value("subtitle.load_failed"), f.error(e);
40
+ } finally {
41
+ _.value = !1;
42
+ }
43
+ }, { immediate: !0 });
44
+ const x = v(() => {
45
+ if (!m.value) return { value: null, error: null };
46
+ try {
47
+ return { value: O(m.value, G(i.fileName)), error: null };
48
+ } catch (e) {
49
+ return console.error(e), { value: null, error: e };
50
+ }
51
+ });
52
+ T(
53
+ () => x.value.error,
54
+ (e) => {
55
+ e && f.error(e);
56
+ }
57
+ );
58
+ const c = v(() => x.value.value), g = v(() => {
59
+ var e, t;
60
+ return ((e = c.value) == null ? void 0 : e.format) === "lrc" || ((t = c.value) == null ? void 0 : t.format) === "elrc";
61
+ }), b = v(() => {
62
+ var e;
63
+ return ((e = c.value) == null ? void 0 : e.metadata) ?? {};
64
+ }), V = (e) => p(e).slice(3, 8);
65
+ return N({
66
+ getToolbarGroups: () => []
67
+ }), (e, t) => _.value ? (r(), o("div", Y, [
68
+ s("div", $, [
69
+ t[0] || (t[0] = s("div", { class: "vfp-renderer-spinner" }, null, -1)),
70
+ s("span", j, a(n(u)("common.loading")), 1)
71
+ ])
72
+ ])) : d.value || !c.value ? (r(), A(X, {
73
+ key: 1,
74
+ message: d.value || n(u)("subtitle.parse_failed"),
75
+ class: "vfp-bg-[#0f0f12]"
76
+ }, null, 8, ["message"])) : (r(), o("div", {
77
+ key: 2,
78
+ class: B(["vfp-relative vfp-w-full vfp-h-full vfp-bg-[#0f0f12]", g.value ? "flavor-lyric" : "flavor-subtitle"])
79
+ }, [
80
+ s("div", q, [
81
+ s("div", H, [
82
+ t[3] || (t[3] = s("div", { class: "timeline-line" }, null, -1)),
83
+ s("ol", J, [
84
+ (r(!0), o(w, null, C(c.value.cues, (l, k) => (r(), o("li", {
85
+ key: "cue-" + k,
86
+ class: "cue-row"
87
+ }, [
88
+ t[2] || (t[2] = s("div", { class: "cue-dot" }, null, -1)),
89
+ s("div", K, [
90
+ s("span", Q, a(n(p)(l.start)), 1),
91
+ t[1] || (t[1] = s("span", { class: "cue-arrow" }, "→", -1)),
92
+ s("span", U, a(n(p)(l.end)), 1),
93
+ s("span", Z, "#" + a(l.id ?? k + 1), 1),
94
+ l.style ? (r(), o("span", ee, a(l.style), 1)) : E("", !0)
95
+ ]),
96
+ l.words && l.words.length > 0 ? (r(), o("div", se, [
97
+ (r(!0), o(w, null, C(l.words, (h, W) => (r(), o("span", {
98
+ key: "w-" + W,
99
+ class: "cue-word",
100
+ title: n(p)(h.start)
101
+ }, [
102
+ s("span", le, a(V(h.start)), 1),
103
+ s("span", re, a(h.text), 1)
104
+ ], 8, te))), 128))
105
+ ])) : (r(), o("p", {
106
+ key: 1,
107
+ class: B(["cue-text", { lyric: g.value }])
108
+ }, a(l.text), 3))
109
+ ]))), 128))
110
+ ])
111
+ ])
112
+ ]),
113
+ s("div", ae, [
114
+ s("span", null, a(c.value.cues.length) + " " + a(g.value ? n(u)("subtitle.lines") : n(u)("subtitle.cues")), 1),
115
+ b.value.length ? (r(), o(w, { key: 0 }, [
116
+ t[4] || (t[4] = s("span", { class: "dot" }, "·", -1)),
117
+ s("span", null, a(b.value.length), 1)
118
+ ], 64)) : E("", !0)
119
+ ])
120
+ ], 2));
121
+ }
122
+ }), ve = /* @__PURE__ */ R(oe, [["__scopeId", "data-v-4f53a8e5"]]);
123
+ export {
124
+ ve as default
125
+ };
@@ -1,45 +1,45 @@
1
- import { defineComponent as S, ref as w, onMounted as E, watch as B, onBeforeUnmount as H, openBlock as d, createElementBlock as h, createElementVNode as x, toDisplayString as z, unref as k, createCommentVNode as g, createVNode as L, normalizeStyle as R } from "vue";
2
- import { u as A, c as C, k as v, e as G, o as J, J as N, h as V, f as F, Z as O, W as Z } from "./index-DZZN3kYi.mjs";
3
- import q from "exceljs";
4
- import { S as I } from "./index-CyBXARuf.mjs";
5
- import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
- const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, $ = {
1
+ import { defineComponent as W, ref as x, onMounted as L, watch as B, onBeforeUnmount as H, openBlock as d, createElementBlock as h, createElementVNode as g, toDisplayString as z, unref as T, createCommentVNode as _, createVNode as R, normalizeStyle as A } from "vue";
2
+ import { u as C, a as G, b as N, J as v, m as V, t as F, Q as J, E as O, L as Q, k as q, p as I } from "./index-c-pYJEmH.mjs";
3
+ import P from "exceljs";
4
+ import { S as U } from "./index-CyBXARuf.mjs";
5
+ import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ const $ = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, j = {
7
7
  key: 0,
8
8
  class: "vfp-renderer-overlay vfp-renderer-loading"
9
- }, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text" }, P = {
9
+ }, K = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
10
10
  key: 1,
11
11
  class: "vfp-renderer-overlay"
12
- }, se = /* @__PURE__ */ S({
12
+ }, ae = /* @__PURE__ */ W({
13
13
  __name: "index",
14
14
  props: {
15
15
  url: {},
16
16
  emptyHint: {}
17
17
  },
18
- setup(T, { expose: W }) {
19
- async function D(e) {
18
+ setup(E, { expose: D }) {
19
+ async function M(e) {
20
20
  try {
21
- return await new q.Workbook().xlsx.load(e.slice().buffer);
21
+ return await new P.Workbook().xlsx.load(e.slice().buffer);
22
22
  } catch (t) {
23
23
  throw t instanceof TypeError && /sheets/i.test(t.message) ? new v("xlsx.invalid_format") : t;
24
24
  }
25
25
  }
26
- const _ = T, { t: o } = A(), M = C(), a = w(!0), n = w(null), l = w(null);
27
- let i = null, m = 100, f = null, u = null, c = { width: 0, height: 0 };
28
- const p = () => {
26
+ const m = E, { t: o } = C(), S = G(), y = N(), a = x(!0), n = x(null), l = x(null);
27
+ let i = null, p = 100, f = null, u = null, c = { width: 0, height: 0 };
28
+ const w = () => {
29
29
  if (!l.value) return { width: 800, height: 600 };
30
30
  const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
31
31
  return { width: r, height: s };
32
- }, y = () => {
32
+ }, b = () => {
33
33
  if (!l.value || !i) return;
34
34
  l.value.innerHTML = "";
35
- const { width: e, height: t } = p(), r = e < 640;
36
- new I(l.value, {
35
+ const { width: e, height: t } = w(), r = e < 640;
36
+ new U(l.value, {
37
37
  mode: "read",
38
38
  showToolbar: !1,
39
39
  showContextmenu: !1,
40
40
  showGrid: !0,
41
41
  row: {
42
- len: m,
42
+ len: p,
43
43
  height: 25
44
44
  },
45
45
  col: {
@@ -53,85 +53,85 @@ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
53
53
  width: () => e
54
54
  }
55
55
  }).loadData(i);
56
- }, b = async () => {
57
- if (l.value) {
56
+ }, k = async () => {
57
+ if (y.begin(m.url), !!l.value) {
58
58
  a.value = !0, n.value = null;
59
59
  try {
60
- const e = await M.value(_.url, {
60
+ const e = await S.value(m.url, {
61
61
  mode: "cors",
62
62
  credentials: "omit",
63
63
  redirect: "follow"
64
64
  });
65
65
  if (!e.ok)
66
66
  throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new v("file.forbidden") : new v("file.load_failed_status", { status: e.status });
67
- const t = G(await e.arrayBuffer());
67
+ const t = V(await e.arrayBuffer());
68
68
  let r;
69
69
  if (t.byteLength === 0)
70
70
  r = [{ name: "Sheet1" }];
71
- else if (J(t)) {
72
- const s = N(t);
71
+ else if (F(t)) {
72
+ const s = J(t);
73
73
  if (!s || !Array.isArray(s.sheets))
74
74
  throw new v("xlsx.invalid_legacy_data");
75
- r = V(s);
75
+ r = O(s);
76
76
  } else
77
- r = F(
78
- await D(t)
77
+ r = Q(
78
+ await M(t)
79
79
  );
80
- i = r.length ? r : [{ name: "Sheet1" }], m = O(r), y(), a.value = !1;
80
+ i = r.length ? r : [{ name: "Sheet1" }], p = q(r), b(), a.value = !1;
81
81
  } catch (e) {
82
82
  console.error(o.value("xlsx.parse_failed") + ":", e);
83
83
  let t = o.value("xlsx.parse_failed");
84
- e instanceof Error && (t = Z(o.value, e)), n.value = t, a.value = !1;
84
+ e instanceof Error && (t = I(o.value, e)), n.value = t, a.value = !1, y.error(e);
85
85
  }
86
86
  }
87
87
  };
88
- return E(() => {
88
+ return L(() => {
89
89
  if (!l.value) return;
90
90
  let e = !0;
91
91
  f = new ResizeObserver(() => {
92
92
  if (e) {
93
- e = !1, c = p();
93
+ e = !1, c = w();
94
94
  return;
95
95
  }
96
- const t = p(), r = Math.abs(c.width - t.width), s = Math.abs(c.height - t.height);
96
+ const t = w(), r = Math.abs(c.width - t.width), s = Math.abs(c.height - t.height);
97
97
  r < 10 && s < 10 || (c = t, u !== null && clearTimeout(u), u = window.setTimeout(() => {
98
- i && y();
98
+ i && b();
99
99
  }, 500));
100
100
  }), f.observe(l.value), setTimeout(() => {
101
- requestAnimationFrame(() => b());
101
+ requestAnimationFrame(() => k());
102
102
  }, 100);
103
103
  }), B(
104
- () => _.url,
104
+ () => m.url,
105
105
  (e) => {
106
- e && b();
106
+ e && k();
107
107
  }
108
108
  ), H(() => {
109
- f && f.disconnect(), u !== null && clearTimeout(u), i = null, m = 100, l.value && (l.value.innerHTML = "");
110
- }), W({
109
+ f && f.disconnect(), u !== null && clearTimeout(u), i = null, p = 100, l.value && (l.value.innerHTML = "");
110
+ }), D({
111
111
  getToolbarGroups: () => []
112
- }), (e, t) => (d(), h("div", X, [
113
- a.value ? (d(), h("div", $, [
114
- x("div", j, [
115
- t[0] || (t[0] = x("div", { class: "vfp-renderer-spinner" }, null, -1)),
116
- x("p", K, z(k(o)("xlsx.loading")), 1)
112
+ }), (e, t) => (d(), h("div", $, [
113
+ a.value ? (d(), h("div", j, [
114
+ g("div", K, [
115
+ t[0] || (t[0] = g("div", { class: "vfp-renderer-spinner" }, null, -1)),
116
+ g("p", Y, z(T(o)("xlsx.loading")), 1)
117
117
  ])
118
- ])) : g("", !0),
119
- n.value && !a.value ? (d(), h("div", P, [
120
- L(U, {
121
- message: k(o)("xlsx.load_failed"),
118
+ ])) : _("", !0),
119
+ n.value && !a.value ? (d(), h("div", Z, [
120
+ R(X, {
121
+ message: T(o)("xlsx.load_failed"),
122
122
  detail: n.value
123
123
  }, null, 8, ["message", "detail"])
124
- ])) : g("", !0),
125
- n.value ? g("", !0) : (d(), h("div", {
124
+ ])) : _("", !0),
125
+ n.value ? _("", !0) : (d(), h("div", {
126
126
  key: 2,
127
127
  ref_key: "containerRef",
128
128
  ref: l,
129
129
  class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
130
- style: R({ opacity: a.value ? 0 : 1 })
130
+ style: A({ opacity: a.value ? 0 : 1 })
131
131
  }, null, 4))
132
132
  ]));
133
133
  }
134
134
  });
135
135
  export {
136
- se as default
136
+ ae as default
137
137
  };
@@ -0,0 +1,104 @@
1
+ import { defineComponent as k, ref as p, onMounted as z, watch as M, onBeforeUnmount as N, openBlock as v, createElementBlock as m, createElementVNode as w, toDisplayString as S, unref as B, createCommentVNode as g, createBlock as C, normalizeStyle as F } from "vue";
2
+ import { S as H } from "./index-CyBXARuf.mjs";
3
+ import { u as R, a as W, b as A, h as E, D as G, A as L, F as O } from "./index-c-pYJEmH.mjs";
4
+ import { _ as V } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ const q = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, I = {
6
+ key: 0,
7
+ class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
8
+ }, P = { class: "vfp-renderer-loading-content" }, U = { class: "vfp-renderer-loading-text" }, X = /* @__PURE__ */ k({
9
+ __name: "index",
10
+ props: {
11
+ url: {},
12
+ fileName: {}
13
+ },
14
+ setup(T, { expose: y }) {
15
+ const n = T, { t: d } = R(), D = W(), b = A(), r = p(!0), a = p(null), l = p(null);
16
+ let o = null, u = null, i = null, c = { width: 0, height: 0 };
17
+ const h = () => {
18
+ if (!l.value) return { width: 800, height: 600 };
19
+ const e = l.value.clientWidth, t = l.value.clientHeight, s = e > 100 ? e : 800, f = t > 100 ? t : 600;
20
+ return { width: s, height: f };
21
+ }, _ = () => {
22
+ if (!l.value || !o) return;
23
+ l.value.innerHTML = "";
24
+ const { width: e, height: t } = h(), s = e < 640;
25
+ new H(l.value, {
26
+ mode: "read",
27
+ showToolbar: !1,
28
+ showContextmenu: !1,
29
+ showGrid: !0,
30
+ row: {
31
+ len: 100,
32
+ height: 25
33
+ },
34
+ col: {
35
+ len: 26,
36
+ width: s ? 80 : 100,
37
+ indexWidth: s ? 40 : 60,
38
+ minWidth: s ? 40 : 60
39
+ },
40
+ view: {
41
+ height: () => t,
42
+ width: () => e
43
+ }
44
+ }).loadData(o);
45
+ }, x = async () => {
46
+ if (b.begin(n.url), !!l.value) {
47
+ r.value = !0, a.value = null;
48
+ try {
49
+ const e = await E(n.url, { fetcher: D.value }), t = G(e, { delimiter: L(n.fileName) });
50
+ o = O(t.header, t.rows, n.fileName), _(), r.value = !1;
51
+ } catch (e) {
52
+ console.error(d.value("csv.parse_failed") + ":", e), a.value = d.value("csv.load_failed"), r.value = !1, b.error(e);
53
+ }
54
+ }
55
+ };
56
+ return z(() => {
57
+ if (!l.value) return;
58
+ let e = !0;
59
+ u = new ResizeObserver(() => {
60
+ if (e) {
61
+ e = !1, c = h();
62
+ return;
63
+ }
64
+ const t = h(), s = Math.abs(c.width - t.width), f = Math.abs(c.height - t.height);
65
+ s < 10 && f < 10 || (c = t, i !== null && clearTimeout(i), i = window.setTimeout(() => {
66
+ o && _();
67
+ }, 500));
68
+ }), u.observe(l.value), setTimeout(() => {
69
+ requestAnimationFrame(() => x());
70
+ }, 100);
71
+ }), M(
72
+ () => n.url,
73
+ () => {
74
+ x();
75
+ }
76
+ ), N(() => {
77
+ u && u.disconnect(), i !== null && clearTimeout(i), o = null, l.value && (l.value.innerHTML = "");
78
+ }), y({
79
+ getToolbarGroups: () => []
80
+ }), (e, t) => (v(), m("div", q, [
81
+ r.value ? (v(), m("div", I, [
82
+ w("div", P, [
83
+ t[0] || (t[0] = w("div", { class: "vfp-renderer-spinner" }, null, -1)),
84
+ w("p", U, S(B(d)("csv.loading")), 1)
85
+ ])
86
+ ])) : g("", !0),
87
+ a.value && !r.value ? (v(), C(V, {
88
+ key: 1,
89
+ message: a.value,
90
+ class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
91
+ }, null, 8, ["message"])) : g("", !0),
92
+ a.value ? g("", !0) : (v(), m("div", {
93
+ key: 2,
94
+ ref_key: "containerRef",
95
+ ref: l,
96
+ class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
97
+ style: F({ opacity: r.value ? 0 : 1 })
98
+ }, null, 4))
99
+ ]));
100
+ }
101
+ });
102
+ export {
103
+ X as default
104
+ };