@zinejs/pdf 0.7.4 → 0.8.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.
package/README.md CHANGED
@@ -63,10 +63,10 @@ Image-only books can skip pdf.js and use a plain classic script:
63
63
 
64
64
  ## The pdf.js worker (`workerSrc`)
65
65
 
66
- pdf.js parses and rasterizes in a Web Worker, a separate file the host must locate. By default `PdfSource` resolves it to:
66
+ pdf.js parses and rasterizes in a Web Worker, a separate file the host must locate. By default `PdfSource` resolves it to (the `legacy/` path since `legacy` defaults to true; `build/` when `legacy: false`):
67
67
 
68
68
  ```js
69
- new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).href
69
+ new URL('pdfjs-dist/legacy/build/pdf.worker.min.mjs', import.meta.url).href
70
70
  ```
71
71
 
72
72
  Resolution precedence: an explicit `workerSrc` option → an already-set `pdfjsLib.GlobalWorkerOptions.workerSrc` → the auto-default above. You only pass `workerSrc` when the default can't apply.
@@ -108,7 +108,18 @@ new PdfSource(src, {
108
108
  maxCacheBytes, // soft cap on cached page bytes (default ~256 MB); LRU-evicts beyond it
109
109
  progressive: true, // paint a low-res page first, then swap to crisp (faster first paint)
110
110
  disableAutoFetch: true, // fetch only the byte ranges visible pages need (range-capable servers)
111
+ legacy: true, // load pdf.js's transpiled build (default); false serves the lean modern build
111
112
  });
112
113
  ```
113
114
 
114
115
  `src` is a URL string, `ArrayBuffer`/`Uint8Array` of PDF bytes, or a pre-created pdf.js document.
116
+
117
+ ### Legacy vs modern build (`legacy`)
118
+
119
+ pdf.js ships two builds. The `legacy` build is transpiled with polyfills and runs on both older and current browsers; the `modern` build is smaller and a touch faster but needs a recent engine. `PdfSource` defaults to `legacy: true`, favouring reach. Pass `legacy: false` to load the modern build when your audience is on current browsers:
120
+
121
+ ```js
122
+ new PdfSource('document.pdf', { legacy: false });
123
+ ```
124
+
125
+ The flag also picks the matching worker (`legacy/build/pdf.worker.min.mjs` vs `build/pdf.worker.min.mjs`) — the two must be a matched pair. It's ignored when you pass a pre-created document or set `globalThis.pdfjsLib`, since those already chose their build.