@eternalheart/vue-file-preview 1.6.7 → 1.6.9

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 (40) hide show
  1. package/README.md +17 -3
  2. package/README.zh-CN.md +17 -3
  3. package/lib/chunks/{index-sPfLaVRe.mjs → index-BB5sxTpZ.mjs} +832 -830
  4. package/lib/chunks/index-BHpXaB9I.mjs +113 -0
  5. package/lib/chunks/index-BMpMXQVn.mjs +354 -0
  6. package/lib/chunks/{index-CR3QkKJt.mjs → index-Bcq3GaYf.mjs} +94 -91
  7. package/lib/chunks/index-Bexr8qBs.mjs +118 -0
  8. package/lib/chunks/index-BjrqA9rc.mjs +104 -0
  9. package/lib/chunks/index-Bpw-3elB.mjs +90 -0
  10. package/lib/chunks/{index-BflKoE04.mjs → index-BrlnSL9B.mjs} +33 -33
  11. package/lib/chunks/{index-DdbaVSB8.mjs → index-Bw94R-j4.mjs} +1031 -1082
  12. package/lib/chunks/index-CKb19_XL.mjs +52 -0
  13. package/lib/chunks/{index-CSY197_j.mjs → index-COgE_EN8.mjs} +98 -95
  14. package/lib/chunks/{index-BgTW_P3u.mjs → index-C_0pROOm.mjs} +174 -171
  15. package/lib/chunks/{index-CK43N0Ho.mjs → index-CsP5e8u1.mjs} +26 -26
  16. package/lib/chunks/{index-DlIRXpmw.mjs → index-D02VAnb_.mjs} +71 -68
  17. package/lib/chunks/{index--sqXkUEP.mjs → index-D5CgW1SY.mjs} +32 -32
  18. package/lib/chunks/{index-06Ivpw6V.mjs → index-D9DjYf4b.mjs} +148 -143
  19. package/lib/chunks/index-DAmkmR7C.mjs +51 -0
  20. package/lib/chunks/{index-B6UNmyiS.mjs → index-Dbt450tb.mjs} +1 -1
  21. package/lib/chunks/index-DcYqyPdh.mjs +155 -0
  22. package/lib/chunks/index-DjQ_Fllz.mjs +108 -0
  23. package/lib/chunks/{index-CBN0qoP1.mjs → index-Tm4rnJiV.mjs} +28 -28
  24. package/lib/chunks/{index-B3jcS1UB.mjs → index-aceY97Xi.mjs} +692 -689
  25. package/lib/chunks/{useShikiHighlight-J62fUszo.mjs → useShikiHighlight-DqskZVn5.mjs} +1 -1
  26. package/lib/composables/useThemeMode.d.ts +3 -0
  27. package/lib/index.cjs +50 -50
  28. package/lib/index.css +1 -1
  29. package/lib/index.mjs +1 -1
  30. package/lib/renderers/base.types.d.ts +1 -2
  31. package/package.json +1 -1
  32. package/lib/chunks/index-BWNmKHd0.mjs +0 -110
  33. package/lib/chunks/index-BmsJxBJa.mjs +0 -320
  34. package/lib/chunks/index-CXAEvuVP.mjs +0 -49
  35. package/lib/chunks/index-Cr7raBmi.mjs +0 -104
  36. package/lib/chunks/index-Cv0lIWeI.mjs +0 -105
  37. package/lib/chunks/index-CyIp8Xfg.mjs +0 -48
  38. package/lib/chunks/index-D_XKzCZJ.mjs +0 -152
  39. package/lib/chunks/index-DoqCnKkl.mjs +0 -87
  40. package/lib/chunks/index-Xta2zHnj.mjs +0 -115
package/README.md CHANGED
@@ -53,23 +53,29 @@ By default, the component automatically uses unpkg CDN to load PDF.js, no additi
53
53
  1. Copy PDF.js files to your public directory:
54
54
 
55
55
  ```bash
56
- cp -r node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdfjs/
56
+ cp -r node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs public/pdfjs/
57
57
  cp -r node_modules/pdfjs-dist/cmaps public/pdfjs/
58
+ cp -r node_modules/pdfjs-dist/standard_fonts public/pdfjs/
59
+ cp -r node_modules/pdfjs-dist/wasm public/pdfjs/
58
60
  ```
59
61
 
60
62
  2. Configure PDF.js in your app entry:
61
63
 
62
64
  ```ts
63
- import * as pdfjsLib from 'pdfjs-dist/build/pdf.mjs';
65
+ import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
64
66
  import { configurePdfWorker } from '@eternalheart/vue-file-preview';
65
67
 
66
68
  configurePdfWorker(pdfjsLib, {
67
69
  workerSrc: '/pdfjs/pdf.worker.min.mjs',
68
70
  cMapUrl: '/pdfjs/cmaps/',
69
71
  cMapPacked: true,
72
+ standardFontDataUrl: '/pdfjs/standard_fonts/',
73
+ wasmUrl: '/pdfjs/wasm/',
70
74
  });
71
75
  ```
72
76
 
77
+ Call this during client application initialization, before the first PDF render. The worker must use the legacy build matching the installed `pdfjs-dist` version.
78
+
73
79
  #### Auto-copy with Vite (Recommended)
74
80
 
75
81
  Configure auto-copy in `vite.config.ts`:
@@ -83,12 +89,20 @@ export default defineConfig({
83
89
  viteStaticCopy({
84
90
  targets: [
85
91
  {
86
- src: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs',
92
+ src: 'node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs',
87
93
  dest: 'pdfjs'
88
94
  },
89
95
  {
90
96
  src: 'node_modules/pdfjs-dist/cmaps',
91
97
  dest: 'pdfjs'
98
+ },
99
+ {
100
+ src: 'node_modules/pdfjs-dist/standard_fonts',
101
+ dest: 'pdfjs'
102
+ },
103
+ {
104
+ src: 'node_modules/pdfjs-dist/wasm',
105
+ dest: 'pdfjs'
92
106
  }
93
107
  ]
94
108
  })
package/README.zh-CN.md CHANGED
@@ -53,23 +53,29 @@ import '@eternalheart/vue-file-preview/style.css';
53
53
  1. 将 PDF.js 文件复制到你的 public 目录:
54
54
 
55
55
  ```bash
56
- cp -r node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdfjs/
56
+ cp -r node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs public/pdfjs/
57
57
  cp -r node_modules/pdfjs-dist/cmaps public/pdfjs/
58
+ cp -r node_modules/pdfjs-dist/standard_fonts public/pdfjs/
59
+ cp -r node_modules/pdfjs-dist/wasm public/pdfjs/
58
60
  ```
59
61
 
60
62
  2. 在应用入口配置 PDF.js:
61
63
 
62
64
  ```ts
63
- import * as pdfjsLib from 'pdfjs-dist/build/pdf.mjs';
65
+ import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
64
66
  import { configurePdfWorker } from '@eternalheart/vue-file-preview';
65
67
 
66
68
  configurePdfWorker(pdfjsLib, {
67
69
  workerSrc: '/pdfjs/pdf.worker.min.mjs',
68
70
  cMapUrl: '/pdfjs/cmaps/',
69
71
  cMapPacked: true,
72
+ standardFontDataUrl: '/pdfjs/standard_fonts/',
73
+ wasmUrl: '/pdfjs/wasm/',
70
74
  });
71
75
  ```
72
76
 
77
+ 请在客户端应用初始化阶段、首次渲染 PDF 前调用。Worker 必须使用与当前 `pdfjs-dist` 版本匹配的 legacy 构建。
78
+
73
79
  #### 使用 Vite 自动复制(推荐)
74
80
 
75
81
  在 `vite.config.ts` 中配置自动复制:
@@ -83,12 +89,20 @@ export default defineConfig({
83
89
  viteStaticCopy({
84
90
  targets: [
85
91
  {
86
- src: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs',
92
+ src: 'node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs',
87
93
  dest: 'pdfjs'
88
94
  },
89
95
  {
90
96
  src: 'node_modules/pdfjs-dist/cmaps',
91
97
  dest: 'pdfjs'
98
+ },
99
+ {
100
+ src: 'node_modules/pdfjs-dist/standard_fonts',
101
+ dest: 'pdfjs'
102
+ },
103
+ {
104
+ src: 'node_modules/pdfjs-dist/wasm',
105
+ dest: 'pdfjs'
92
106
  }
93
107
  ]
94
108
  })