@eternalheart/vue-file-preview 1.7.0 → 1.7.2

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 (46) 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 +6 -1
  5. package/lib/FilePreviewModal.vue.d.ts +6 -1
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs → EmptyState.vue_vue_type_script_setup_true_lang-Dna6LmVT.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-CnJpGYJ2.mjs → avifLoader-CAUzjn-d-dPsP28D5.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-g_dLrWLP.mjs → heicLoader-D_9PukkA-T-k1DSgY.mjs} +1 -1
  9. package/lib/chunks/{index-c-pYJEmH.mjs → index-B5hprvcF.mjs} +1747 -1709
  10. package/lib/chunks/index-BN__EwfT.mjs +333 -0
  11. package/lib/chunks/{index-z9RqL2wI.mjs → index-BPutNVAf.mjs} +453 -453
  12. package/lib/chunks/{index-BfOWoMpY.mjs → index-B_Spz6Wn.mjs} +77 -77
  13. package/lib/chunks/{index-D5IF9F-D.mjs → index-BjHEHkZ8.mjs} +22 -22
  14. package/lib/chunks/{index-LPGxJDnT.mjs → index-BlZ6RmeR.mjs} +18 -18
  15. package/lib/chunks/{index-CrVQPnFj.mjs → index-C95y29OL.mjs} +18 -18
  16. package/lib/chunks/{index-DFeKS8tR.mjs → index-CegPYMyO.mjs} +22 -22
  17. package/lib/chunks/{index-C4hIk6pa.mjs → index-CqOGKCyE.mjs} +2 -2
  18. package/lib/chunks/{index-6XZXYqbp.mjs → index-Cv3Sg87O.mjs} +29 -32
  19. package/lib/chunks/{index-zLQlyNR2.mjs → index-DHba2Axz.mjs} +62 -62
  20. package/lib/chunks/{index-CWPdNhoe.mjs → index-DInI3RTN.mjs} +60 -60
  21. package/lib/chunks/{index-C8lyQPe3.mjs → index-DXzvgRuo.mjs} +3 -3
  22. package/lib/chunks/{index-BPSzwMOC.mjs → index-DcvlMm9Q.mjs} +46 -46
  23. package/lib/chunks/index-Dnyl1HQk.mjs +51 -0
  24. package/lib/chunks/{index-aKiIuKKx.mjs → index-JjVQZbDt.mjs} +50 -50
  25. package/lib/chunks/{index-DZe0BxAB.mjs → index-QPk2c2Tl.mjs} +20 -20
  26. package/lib/chunks/{index-DM8Dfl-m.mjs → index-TZv0MqBH.mjs} +15 -15
  27. package/lib/chunks/{index-BzwJ0VWu.mjs → index-cRhwUlQN.mjs} +33 -33
  28. package/lib/chunks/{index-BYQ9S7Mk.mjs → index-dOxDeWYi.mjs} +30 -30
  29. package/lib/chunks/{index-Bg8poMIm.mjs → index-eNZr1h6f.mjs} +29 -29
  30. package/lib/chunks/{index-Bf94DwQu.mjs → index-oJF-hur2.mjs} +24 -24
  31. package/lib/chunks/{jp2Loader-Dig19xyo-fCO1knZ0.mjs → jp2Loader-Dig19xyo-hrIg_KJ3.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-DihMskai.mjs → psdLoader-C0tKUXXl-B2cJ4s7t.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-BSfDPl-z.mjs → rawLoader-C-tPeFAB-BNV-Wmzr.mjs} +1 -1
  34. package/lib/chunks/{tiffLoader-BlhByX8w-JY5DaTre.mjs → tiffLoader-BlhByX8w-BzSrLE9Y.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-C-ztcJBE.mjs → useShikiHighlight-CpL0RAQg.mjs} +1 -1
  36. package/lib/composables/usePreviewEvents.d.ts +2 -2
  37. package/lib/composables/useRequest.d.ts +8 -2
  38. package/lib/core/events.d.ts +18 -1
  39. package/lib/core/index.d.ts +1 -1
  40. package/lib/index.cjs +54 -54
  41. package/lib/index.css +1 -1
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.mjs +5 -5
  44. package/package.json +1 -1
  45. package/lib/chunks/index-C41YET0_.mjs +0 -51
  46. package/lib/chunks/index-GFcSJEwj.mjs +0 -330
@@ -1,4 +1,4 @@
1
- import { J as i } from "./index-c-pYJEmH.mjs";
1
+ import { J as i } from "./index-B5hprvcF.mjs";
2
2
  class f {
3
3
  async needsDecode(t) {
4
4
  return t === "image/vnd.adobe.photoshop";
@@ -1,4 +1,4 @@
1
- import { J as b } from "./index-c-pYJEmH.mjs";
1
+ import { J as b } from "./index-B5hprvcF.mjs";
2
2
  const B = /* @__PURE__ */ new Set([
3
3
  "image/x-canon-cr2",
4
4
  "image/x-nikon-nef",
@@ -1,4 +1,4 @@
1
- import { J as i } from "./index-c-pYJEmH.mjs";
1
+ import { J as i } from "./index-B5hprvcF.mjs";
2
2
  class p {
3
3
  /**
4
4
  * TIFF 浏览器均不原生支持(除 Safari 部分版本),始终需要解码
@@ -1,6 +1,6 @@
1
1
  import { ref as i, watch as c } from "vue";
2
2
  import { codeToHtml as h } from "shiki";
3
- import { g as f } from "./index-c-pYJEmH.mjs";
3
+ import { e as f } from "./index-B5hprvcF.mjs";
4
4
  function T(t, n) {
5
5
  const a = f(), e = i(""), r = i([]), l = i(!0);
6
6
  return c([t, n, a], async () => {
@@ -1,4 +1,4 @@
1
- import { type PreviewErrorPayload, type PreviewErrorStage, type PreviewFile, type PreviewReporter } from '../core/index.js';
1
+ import { type PreviewErrorPayload, type PreviewErrorStage, type PreviewFile, type PreviewRenderedPayload, type PreviewReporter } from '../core/index.js';
2
2
  /** 顶层聚合时补齐的上下文。 */
3
3
  export interface PreviewEventsHostContext {
4
4
  /** 当前文件 */
@@ -22,6 +22,6 @@ export interface PreviewEventsHost {
22
22
  * - 顶层通过返回值里的 report 直接上报(请求层、错误边界等);
23
23
  * - 去重与代次校验在这里统一完成,宿主只会收到干净的 payload。
24
24
  */
25
- export declare function providePreviewEvents(getContext: () => PreviewEventsHostContext, dispatch: (payload: PreviewErrorPayload) => void): PreviewEventsHost;
25
+ export declare function providePreviewEvents(getContext: () => PreviewEventsHostContext, dispatch: (payload: PreviewErrorPayload) => void, dispatchRendered?: (payload: PreviewRenderedPayload) => void): PreviewEventsHost;
26
26
  /** 渲染器侧使用;未接入事件通道时返回 noop。 */
27
27
  export declare function usePreviewEvents(): PreviewReporter;
@@ -18,7 +18,13 @@ export declare function provideRequestContext(options: {
18
18
  shouldFetchAsBlob?: ShouldFetchAsBlob;
19
19
  onRequestError?: (url: string, error: unknown) => void;
20
20
  })): ComputedRef<RequestContextValue>;
21
- export declare function useRequestContext(): ComputedRef<RequestContextValue>;
21
+ /**
22
+ * 获取请求上下文。
23
+ *
24
+ * Vue 的 `inject` 只读取父级 provides,同组件内先 `provide` 再 `inject` 拿不到自身值;
25
+ * 因此组件内如需使用自己 provide 的上下文,必须通过 `context` 显式传入。
26
+ */
27
+ export declare function useRequestContext(context?: ComputedRef<RequestContextValue>): ComputedRef<RequestContextValue>;
22
28
  export declare function useFetcher(): ComputedRef<Fetcher>;
23
29
  declare const DEPRECATED_REQUEST_PROPS: readonly ["requestInit", "requestHandler", "shouldFetchAsBlob"];
24
30
  /** 过渡期提示:旧鉴权参数已废弃,1.8.0 移除。 */
@@ -31,5 +37,5 @@ export declare function warnDeprecatedRequestProps(used: Partial<Record<(typeof
31
37
  *
32
38
  * onError 用于把取数失败上报给宿主(默认仍回退原 URL 继续尝试)。
33
39
  */
34
- export declare function useResolvedUrl(file: Ref<PreviewFile | undefined>, onError?: (error: unknown) => void): ComputedRef<string>;
40
+ export declare function useResolvedUrl(file: Ref<PreviewFile | undefined>, onError?: (error: unknown) => void, context?: ComputedRef<RequestContextValue>): ComputedRef<string>;
35
41
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PreviewError } from './i18n/index.js';
2
- import type { PreviewFile } from './types.js';
2
+ import type { FileType, PreviewFile } from './types.js';
3
3
  /** 失败发生的阶段:取数 / 解析 / 渲染。 */
4
4
  export type PreviewErrorStage = 'request' | 'parse' | 'render';
5
5
  /**
@@ -18,6 +18,20 @@ export interface PreviewErrorPayload {
18
18
  /** 框架侧补充的诊断信息(如 React ErrorInfo),其他端可能为空。 */
19
19
  cause?: unknown;
20
20
  }
21
+ /**
22
+ * 渲染成功(首屏内容就绪)时对外派发的载荷。
23
+ * 与 error 一样按一次加载去重,`fileType` 为 getFileType(file) 的结果。
24
+ */
25
+ export interface PreviewRenderedPayload {
26
+ /** 渲染成功的文件 */
27
+ file: PreviewFile;
28
+ /** 文件索引 */
29
+ index: number;
30
+ /** 文件类型(getFileType 结果),便于按类型统计 */
31
+ fileType: FileType;
32
+ /** 从 begin 到 ready 的耗时(毫秒);未调用 begin 时省略 */
33
+ durationMs?: number;
34
+ }
21
35
  /**
22
36
  * 请求阶段异常标记。
23
37
  * 由 createFetcher 统一包装抛出,渲染器 catch 后无需判断即可让 stage
@@ -35,6 +49,7 @@ export declare class PreviewRequestError extends PreviewError {
35
49
  * - 显式传入 stage 时优先采用;
36
50
  * - 请求包装异常推断为 'request';
37
51
  * - 响应状态类 key(HTTP 非 2xx)推断为 'request';
52
+ * - 第三方库响应异常 / 网络 TypeError 推断为 'request';
38
53
  * - 其余一律视为 'parse'。
39
54
  */
40
55
  export declare function resolveErrorStage(error: unknown, explicit?: PreviewErrorStage): PreviewErrorStage;
@@ -47,6 +62,8 @@ export declare function resolveErrorStage(error: unknown, explicit?: PreviewErro
47
62
  export interface PreviewReporter {
48
63
  begin(url: string): void;
49
64
  error(error: unknown, stage?: PreviewErrorStage): void;
65
+ /** 本次加载首次产出可交互内容时调用;重复调用会被忽略 */
66
+ ready(): void;
50
67
  }
51
68
  /** 未接入事件通道时的占位实现,保证渲染器可无条件调用。 */
52
69
  export declare const noopReporter: PreviewReporter;
@@ -12,7 +12,7 @@ export { decodeText, decodeUtf8, fetchTextUtf8 } from './utils/textDecoder.js';
12
12
  export type { FetchTextOptions } from './utils/textDecoder.js';
13
13
  export { createFetcher, fetchAsBlobUrl, downloadFileWithFetcher, isInlineResourceUrl, resolveConsumableUrl, withHeaders, } from './utils/request.js';
14
14
  export { PreviewRequestError, resolveErrorStage, noopReporter, } from './events.js';
15
- export type { PreviewErrorStage, PreviewErrorPayload, PreviewReporter, } from './events.js';
15
+ export type { PreviewErrorStage, PreviewErrorPayload, PreviewRenderedPayload, PreviewReporter, } from './events.js';
16
16
  export { parseSubtitle, formatSubtitleTime } from './utils/subtitleParser.js';
17
17
  export type { SubtitleCue, SubtitleWord, SubtitleParseResult, SubtitleFormat, } from './utils/subtitleParser.js';
18
18
  export { loadZip, listZipEntries, buildZipTree, readZipEntryText, readZipEntryBlob, } from './utils/zipReader.js';