@octanejs/pdf 0.0.30 → 0.0.32

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
@@ -13,7 +13,7 @@ pnpm add @octanejs/pdf
13
13
  import { Document, Page, pdfjs } from '@octanejs/pdf';
14
14
 
15
15
  pdfjs.GlobalWorkerOptions.workerSrc = new URL(
16
- 'pdfjs-dist/build/pdf.worker.min.mjs',
16
+ 'pdfjs-dist/legacy/build/pdf.worker.min.mjs',
17
17
  import.meta.url,
18
18
  ).toString();
19
19
 
@@ -24,6 +24,12 @@ export function Preview({ file }: { file: string }) {
24
24
  }
25
25
  ```
26
26
 
27
+ Use the legacy worker path shown above, including when upgrading an existing
28
+ integration. The worker runs in a separate browser context, so the modern worker
29
+ can still fail on browsers without newer APIs such as `Promise.withResolvers`.
30
+ The PDF.js legacy build supplies compatibility polyfills, which may modify global
31
+ objects when those APIs are missing.
32
+
27
33
  The binding preserves `Document`, `Page`, `Thumbnail`, `Outline`, the three
28
34
  context hooks, `PasswordResponses`, `pdfjs`, and the published root types. It
29
35
  uses Octane refs-as-props and native DOM events; no React renderer is loaded by
@@ -46,8 +52,8 @@ modules.
46
52
 
47
53
  ## Server rendering
48
54
 
49
- The package resolves PDF.js's legacy build on the server and its modern build
50
- in browsers. Server rendering emits deterministic loading, no-data, and error
55
+ The package resolves PDF.js's legacy build on the server and in browsers.
56
+ Server rendering emits deterministic loading, no-data, and error
51
57
  shells without starting a worker or touching canvas. Hydration adopts those
52
58
  shells before client-side PDF loading begins.
53
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/pdf",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,7 +46,7 @@
46
46
  "pdfjs-dist": "5.4.296"
47
47
  },
48
48
  "peerDependencies": {
49
- "octane": "^0.12.0"
49
+ "octane": "^0.14.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/react": "19.2.7",
@@ -57,7 +57,7 @@
57
57
  "dequal": "^2.0.3",
58
58
  "make-cancellable-promise": "^2.0.0",
59
59
  "merge-refs": "^2.0.0",
60
- "octane": "0.12.0",
60
+ "octane": "0.14.0",
61
61
  "playwright": "^1.61.1",
62
62
  "react": "19.2.3",
63
63
  "react-dom": "19.2.3",
@@ -201,7 +201,7 @@ export function Document(props: DocumentProps = {}) {
201
201
  setPdfError(null);
202
202
  if (!source) return;
203
203
 
204
- void import('pdfjs-dist')
204
+ void import('pdfjs-dist/legacy/build/pdf.mjs')
205
205
  .then((pdfjs) => {
206
206
  if (!active) return;
207
207
  loadingTask = pdfjs.getDocument({ ...source, ...options } as never);
@@ -499,7 +499,7 @@ export function Page(props: PageProps = {}) {
499
499
  canvas.style.width = `${Math.floor(viewport.width)}px`;
500
500
  canvas.style.height = `${Math.floor(viewport.height)}px`;
501
501
  canvas.style.visibility = 'hidden';
502
- void import('pdfjs-dist')
502
+ void import('pdfjs-dist/legacy/build/pdf.mjs')
503
503
  .then((pdfjs) => {
504
504
  if (!active) return;
505
505
  renderTask = page.render({
@@ -545,7 +545,7 @@ export function Page(props: PageProps = {}) {
545
545
  if (!active) return;
546
546
  contentLoaded = true;
547
547
  onGetTextSuccess?.(content);
548
- const pdfjs = await import('pdfjs-dist');
548
+ const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs');
549
549
  if (!active) return;
550
550
  textLayer = new pdfjs.TextLayer({
551
551
  container: element,
@@ -608,7 +608,7 @@ export function Page(props: PageProps = {}) {
608
608
  const annotations = filterAnnotations
609
609
  ? filterAnnotations({ annotations: loadedAnnotations })
610
610
  : loadedAnnotations;
611
- const pdfjs = await import('pdfjs-dist');
611
+ const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs');
612
612
  if (!active) return;
613
613
  const annotationViewport = viewport.clone({ dontFlip: true });
614
614
  const parameters = {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as pdfjs from 'pdfjs-dist';
1
+ import * as pdfjs from 'pdfjs-dist/legacy/build/pdf.mjs';
2
2
 
3
3
  // OCTANE DIVERGENCE[pdf-octane-node-ref-event-types][differential:react-pdf-document-shells]
4
4
  // OCTANE DIVERGENCE[pdf-star-export-surface][types:pdf-adapted]
@@ -43,8 +43,8 @@
43
43
  },
44
44
  {
45
45
  "upstream": "pdfjs-dist/build/pdf.worker.min.mjs",
46
- "octane": "pdfjs-dist/build/pdf.worker.min.mjs",
47
- "classification": "unchanged-framework-neutral-dependency"
46
+ "octane": "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
47
+ "classification": "adapted-framework-neutral-dependency"
48
48
  }
49
49
  ],
50
50
  "wildcardPolicy": {