Skip to content

Commit 6ebafb8

Browse files
feat: upgrade PDF.js to v4.1038
1 parent e70250a commit 6ebafb8

11 files changed

Lines changed: 2447 additions & 2846 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: pnpm/action-setup@v3
1818
- uses: actions/setup-node@v4
1919
with:
20-
node-version: 20
20+
node-version: 22
2121
cache: pnpm
2222
- run: pnpm install
2323
- run: pnpm run build:pdfjs

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: pnpm/action-setup@v3
1919
- uses: actions/setup-node@v4
2020
with:
21-
node-version: 20
21+
node-version: 22
2222
registry-url: https://registry.npmjs.org/
2323
cache: pnpm
2424

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This library is also intended as a modern alternative to the unmaintained but st
1616

1717
## PDF.js Compatibility
1818

19-
The serverless build of PDF.js provided by `unpdf` is based on PDF.js v4.6.82. If you need a different version, you can [use another PDF.js build](#use-official-or-legacy-pdfjs-build).
19+
The serverless build of PDF.js provided by `unpdf` is based on PDF.js v4.10.38. If you need a different version, you can [use another PDF.js build](#use-official-or-legacy-pdfjs-build).
2020

2121
## Installation
2222

@@ -89,7 +89,7 @@ for (let i = 1; i <= doc.numPages; i++) {
8989
Generally speaking, you don't need to worry about the PDF.js build. `unpdf` ships with a serverless build of the latest PDF.js version. However, if you want to use the official PDF.js version or the legacy build, you can define a custom PDF.js module.
9090

9191
> [!WARNING]
92-
> The latest PDF.js v4.6.82 uses `Promise.withResolvers`, which may not be supported in all environments, such as Node < 22. Consider to use the bundled serverless build, which includes a polyfill, or use an older version of PDF.js.
92+
> The latest PDF.js v4.10.38 uses `Promise.withResolvers`, which may not be supported in all environments, such as Node < 22. Consider to use the bundled serverless build, which includes a polyfill, or use an older version of PDF.js.
9393
9494
```ts
9595
// Before using any other method, define the PDF.js module

package.json

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "unpdf",
33
"type": "module",
44
"version": "0.12.2",
5-
"packageManager": "pnpm@9.12.1",
5+
"packageManager": "pnpm@10.10.0",
66
"description": "Utilities to work with PDFs in Node.js, browser and workers",
77
"author": "Johann Schopplich <[email protected]>",
88
"license": "MIT",
@@ -62,32 +62,27 @@
6262
"test:types": "tsc --noEmit"
6363
},
6464
"optionalDependencies": {
65-
"canvas": "^2.11.2"
65+
"canvas": "^3.1.0"
6666
},
6767
"devDependencies": {
68-
"@antfu/eslint-config": "^3.7.3",
68+
"@antfu/eslint-config": "^4.12.0",
6969
"@rollup/plugin-alias": "^5.1.1",
70-
"@rollup/plugin-commonjs": "^28.0.0",
70+
"@rollup/plugin-commonjs": "^28.0.3",
7171
"@rollup/plugin-inject": "^5.0.5",
72-
"@rollup/plugin-node-resolve": "^15.3.0",
73-
"@rollup/plugin-replace": "^6.0.1",
72+
"@rollup/plugin-node-resolve": "^16.0.1",
73+
"@rollup/plugin-replace": "^6.0.2",
7474
"@rollup/plugin-terser": "^0.4.4",
75-
"@rollup/plugin-typescript": "^12.1.0",
76-
"@types/node": "^20.16.11",
77-
"bumpp": "^9.6.1",
78-
"eslint": "^9.12.0",
79-
"fast-glob": "^3.3.2",
80-
"pdfjs-dist": "~4.6.82",
81-
"rollup": "^4.24.0",
82-
"tslib": "^2.7.0",
83-
"typescript": "^5.5.4",
84-
"unbuild": "^3.0.0-rc.11",
75+
"@rollup/plugin-typescript": "^12.1.2",
76+
"@types/node": "^22.15.3",
77+
"bumpp": "^10.1.0",
78+
"eslint": "^9.25.1",
79+
"fast-glob": "^3.3.3",
80+
"pdfjs-dist": "~4.10.38",
81+
"rollup": "^4.40.1",
82+
"tslib": "^2.8.1",
83+
"typescript": "^5.8.3",
84+
"unbuild": "^3.5.0",
8585
"unenv": "^1.10.0",
86-
"vitest": "^2.1.2"
87-
},
88-
"pnpm": {
89-
"patchedDependencies": {
90-
91-
}
86+
"vitest": "^3.1.2"
9287
}
9388
}

patches/[email protected]

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
diff --git a/build/pdf.mjs b/build/pdf.mjs
2+
index 0d201af6b5ffdeaedd0ed5b1b12050e51335e3ee..f1c4d0f2e7d93f86b6ca7023a608b50c842251f9 100644
3+
--- a/build/pdf.mjs
4+
+++ b/build/pdf.mjs
5+
@@ -20,9 +20,10 @@
6+
* JavaScript code in this page
7+
*/
8+
9+
+export async function __main__() {
10+
/******/ // The require scope
11+
/******/ var __webpack_require__ = {};
12+
-/******/
13+
+/******/
14+
/************************************************************************/
15+
/******/ /* webpack/runtime/define property getters */
16+
/******/ (() => {
17+
@@ -35,12 +36,12 @@
18+
/******/ }
19+
/******/ };
20+
/******/ })();
21+
-/******/
22+
+/******/
23+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
24+
/******/ (() => {
25+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
26+
/******/ })();
27+
-/******/
28+
+/******/
29+
/************************************************************************/
30+
var __webpack_exports__ = globalThis.pdfjsLib = {};
31+
32+
@@ -21571,6 +21572,54 @@ var __webpack_exports__setLayerDimensions = __webpack_exports__.setLayerDimensio
33+
var __webpack_exports__shadow = __webpack_exports__.shadow;
34+
var __webpack_exports__stopEvent = __webpack_exports__.stopEvent;
35+
var __webpack_exports__version = __webpack_exports__.version;
36+
-export { __webpack_exports__AbortException as AbortException, __webpack_exports__AnnotationEditorLayer as AnnotationEditorLayer, __webpack_exports__AnnotationEditorParamsType as AnnotationEditorParamsType, __webpack_exports__AnnotationEditorType as AnnotationEditorType, __webpack_exports__AnnotationEditorUIManager as AnnotationEditorUIManager, __webpack_exports__AnnotationLayer as AnnotationLayer, __webpack_exports__AnnotationMode as AnnotationMode, __webpack_exports__ColorPicker as ColorPicker, __webpack_exports__DOMSVGFactory as DOMSVGFactory, __webpack_exports__DrawLayer as DrawLayer, __webpack_exports__FeatureTest as FeatureTest, __webpack_exports__GlobalWorkerOptions as GlobalWorkerOptions, __webpack_exports__ImageKind as ImageKind, __webpack_exports__InvalidPDFException as InvalidPDFException, __webpack_exports__MissingPDFException as MissingPDFException, __webpack_exports__OPS as OPS, __webpack_exports__OutputScale as OutputScale, __webpack_exports__PDFDataRangeTransport as PDFDataRangeTransport, __webpack_exports__PDFDateString as PDFDateString, __webpack_exports__PDFWorker as PDFWorker, __webpack_exports__PasswordResponses as PasswordResponses, __webpack_exports__PermissionFlag as PermissionFlag, __webpack_exports__PixelsPerInch as PixelsPerInch, __webpack_exports__RenderingCancelledException as RenderingCancelledException, __webpack_exports__TextLayer as TextLayer, __webpack_exports__TouchManager as TouchManager, __webpack_exports__UnexpectedResponseException as UnexpectedResponseException, __webpack_exports__Util as Util, __webpack_exports__VerbosityLevel as VerbosityLevel, __webpack_exports__XfaLayer as XfaLayer, __webpack_exports__build as build, __webpack_exports__createValidAbsoluteUrl as createValidAbsoluteUrl, __webpack_exports__fetchData as fetchData, __webpack_exports__getDocument as getDocument, __webpack_exports__getFilenameFromUrl as getFilenameFromUrl, __webpack_exports__getPdfFilenameFromUrl as getPdfFilenameFromUrl, __webpack_exports__getXfaPageViewport as getXfaPageViewport, __webpack_exports__isDataScheme as isDataScheme, __webpack_exports__isPdfFile as isPdfFile, __webpack_exports__noContextMenu as noContextMenu, __webpack_exports__normalizeUnicode as normalizeUnicode, __webpack_exports__setLayerDimensions as setLayerDimensions, __webpack_exports__shadow as shadow, __webpack_exports__stopEvent as stopEvent, __webpack_exports__version as version };
37+
+// export { __webpack_exports__AbortException as AbortException, __webpack_exports__AnnotationEditorLayer as AnnotationEditorLayer, __webpack_exports__AnnotationEditorParamsType as AnnotationEditorParamsType, __webpack_exports__AnnotationEditorType as AnnotationEditorType, __webpack_exports__AnnotationEditorUIManager as AnnotationEditorUIManager, __webpack_exports__AnnotationLayer as AnnotationLayer, __webpack_exports__AnnotationMode as AnnotationMode, __webpack_exports__ColorPicker as ColorPicker, __webpack_exports__DOMSVGFactory as DOMSVGFactory, __webpack_exports__DrawLayer as DrawLayer, __webpack_exports__FeatureTest as FeatureTest, __webpack_exports__GlobalWorkerOptions as GlobalWorkerOptions, __webpack_exports__ImageKind as ImageKind, __webpack_exports__InvalidPDFException as InvalidPDFException, __webpack_exports__MissingPDFException as MissingPDFException, __webpack_exports__OPS as OPS, __webpack_exports__OutputScale as OutputScale, __webpack_exports__PDFDataRangeTransport as PDFDataRangeTransport, __webpack_exports__PDFDateString as PDFDateString, __webpack_exports__PDFWorker as PDFWorker, __webpack_exports__PasswordResponses as PasswordResponses, __webpack_exports__PermissionFlag as PermissionFlag, __webpack_exports__PixelsPerInch as PixelsPerInch, __webpack_exports__RenderingCancelledException as RenderingCancelledException, __webpack_exports__TextLayer as TextLayer, __webpack_exports__TouchManager as TouchManager, __webpack_exports__UnexpectedResponseException as UnexpectedResponseException, __webpack_exports__Util as Util, __webpack_exports__VerbosityLevel as VerbosityLevel, __webpack_exports__XfaLayer as XfaLayer, __webpack_exports__build as build, __webpack_exports__createValidAbsoluteUrl as createValidAbsoluteUrl, __webpack_exports__fetchData as fetchData, __webpack_exports__getDocument as getDocument, __webpack_exports__getFilenameFromUrl as getFilenameFromUrl, __webpack_exports__getPdfFilenameFromUrl as getPdfFilenameFromUrl, __webpack_exports__getXfaPageViewport as getXfaPageViewport, __webpack_exports__isDataScheme as isDataScheme, __webpack_exports__isPdfFile as isPdfFile, __webpack_exports__noContextMenu as noContextMenu, __webpack_exports__normalizeUnicode as normalizeUnicode, __webpack_exports__setLayerDimensions as setLayerDimensions, __webpack_exports__shadow as shadow, __webpack_exports__stopEvent as stopEvent, __webpack_exports__version as version };
38+
+return {
39+
+ AbortException: __webpack_exports__AbortException,
40+
+ AnnotationEditorLayer: __webpack_exports__AnnotationEditorLayer,
41+
+ AnnotationEditorParamsType: __webpack_exports__AnnotationEditorParamsType,
42+
+ AnnotationEditorType: __webpack_exports__AnnotationEditorType,
43+
+ AnnotationEditorUIManager: __webpack_exports__AnnotationEditorUIManager,
44+
+ AnnotationLayer: __webpack_exports__AnnotationLayer,
45+
+ AnnotationMode: __webpack_exports__AnnotationMode,
46+
+ ColorPicker: __webpack_exports__ColorPicker,
47+
+ DOMSVGFactory: __webpack_exports__DOMSVGFactory,
48+
+ DrawLayer: __webpack_exports__DrawLayer,
49+
+ FeatureTest: __webpack_exports__FeatureTest,
50+
+ GlobalWorkerOptions: __webpack_exports__GlobalWorkerOptions,
51+
+ ImageKind: __webpack_exports__ImageKind,
52+
+ InvalidPDFException: __webpack_exports__InvalidPDFException,
53+
+ MissingPDFException: __webpack_exports__MissingPDFException,
54+
+ OPS: __webpack_exports__OPS,
55+
+ OutputScale: __webpack_exports__OutputScale,
56+
+ PDFDataRangeTransport: __webpack_exports__PDFDataRangeTransport,
57+
+ PDFDateString: __webpack_exports__PDFDateString,
58+
+ PDFWorker: __webpack_exports__PDFWorker,
59+
+ PasswordResponses: __webpack_exports__PasswordResponses,
60+
+ PermissionFlag: __webpack_exports__PermissionFlag,
61+
+ PixelsPerInch: __webpack_exports__PixelsPerInch,
62+
+ RenderingCancelledException: __webpack_exports__RenderingCancelledException,
63+
+ TextLayer: __webpack_exports__TextLayer,
64+
+ TouchManager: __webpack_exports__TouchManager,
65+
+ UnexpectedResponseException: __webpack_exports__UnexpectedResponseException,
66+
+ Util: __webpack_exports__Util,
67+
+ VerbosityLevel: __webpack_exports__VerbosityLevel,
68+
+ XfaLayer: __webpack_exports__XfaLayer,
69+
+ build: __webpack_exports__build,
70+
+ createValidAbsoluteUrl: __webpack_exports__createValidAbsoluteUrl,
71+
+ fetchData: __webpack_exports__fetchData,
72+
+ getDocument: __webpack_exports__getDocument,
73+
+ getFilenameFromUrl: __webpack_exports__getFilenameFromUrl,
74+
+ getPdfFilenameFromUrl: __webpack_exports__getPdfFilenameFromUrl,
75+
+ getXfaPageViewport: __webpack_exports__getXfaPageViewport,
76+
+ isDataScheme: __webpack_exports__isDataScheme,
77+
+ isPdfFile: __webpack_exports__isPdfFile,
78+
+ noContextMenu: __webpack_exports__noContextMenu,
79+
+ normalizeUnicode: __webpack_exports__normalizeUnicode,
80+
+ setLayerDimensions: __webpack_exports__setLayerDimensions,
81+
+ shadow: __webpack_exports__shadow,
82+
+ stopEvent: __webpack_exports__stopEvent,
83+
+ version: __webpack_exports__version
84+
+};
85+
+};
86+
87+
//# sourceMappingURL=pdf.mjs.map

0 commit comments

Comments
 (0)