From 5007bbcbc9da6f77a1259ba1ff037283c669feaf Mon Sep 17 00:00:00 2001 From: Sulidi Maimaitiming Date: Thu, 12 Mar 2026 01:43:47 +0100 Subject: [PATCH 1/3] Do not broaden return type of PDFDocument --- src/api/PDFDocument.ts | 2 +- src/core/writers/PDFWriter.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/PDFDocument.ts b/src/api/PDFDocument.ts index b223dc6a3..5a81e0e02 100644 --- a/src/api/PDFDocument.ts +++ b/src/api/PDFDocument.ts @@ -1560,7 +1560,7 @@ export default class PDFDocument { * @param options The options to be used when saving the document. * @returns Resolves with the bytes of the serialized document. */ - async save(options: SaveOptions = {}): Promise { + async save(options: SaveOptions = {}) { const vparts = this.context.header.getVersionString().split('.'); const uOS = options.rewrite || Number(vparts[0]) > 1 || Number(vparts[1]) >= 5; diff --git a/src/core/writers/PDFWriter.ts b/src/core/writers/PDFWriter.ts index dee0be87b..9e0a168c9 100644 --- a/src/core/writers/PDFWriter.ts +++ b/src/core/writers/PDFWriter.ts @@ -111,7 +111,7 @@ class PDFWriter { return should; } - async serializeToBuffer(): Promise { + async serializeToBuffer() { const incremental = !(this.snapshot instanceof DefaultDocumentSnapshot); const { size, header, indirectObjects, xref, trailerDict, trailer } = await this.computeBufferSize(incremental); From ea680bacb32534e97fe55f483ee33db8bf53caf2 Mon Sep 17 00:00:00 2001 From: Sulidi Maimaitiming Date: Mon, 26 Jan 2026 01:18:30 +0100 Subject: [PATCH 2/3] Restrict types from Uint8Array to Uint8Array --- package.json | 6 ++--- src/utils/png.ts | 2 +- yarn.lock | 70 +++++++++++++----------------------------------- 3 files changed, 22 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index 272ac4ed0..5333ddee1 100644 --- a/package.json +++ b/package.json @@ -119,8 +119,8 @@ "@types/color": "^3.0.1", "@types/crypto-js": "^4.2.2", "@types/jest": "^29.5.12", - "@types/node-fetch": "^2.5.7", - "@types/pako": "^1.0.1", + "@types/node": "^25.1.0", + "@types/pako": "^2.0.4", "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", "downlevel-dts": "^0.11.0", @@ -139,7 +139,7 @@ "rimraf": "^5.0.5", "rollup": "^4.9.6", "ts-jest": "^29.0", - "typescript": "^4.9.5" + "typescript": "^5.9.3" }, "license": "MIT", "private": false, diff --git a/src/utils/png.ts b/src/utils/png.ts index 2148874d1..8cdd33b3c 100644 --- a/src/utils/png.ts +++ b/src/utils/png.ts @@ -52,7 +52,7 @@ export class PNG { ? UPNG : (UPNG as unknown as { default: typeof UPNG }).default; - const upng = UPNGmod.decode(pngData); + const upng = UPNGmod.decode(pngData as unknown as ArrayBuffer); const frames = UPNGmod.toRGBA8(upng); if (frames.length > 1) throw new Error('Animated PNGs are not supported'); diff --git a/yarn.lock b/yarn.lock index 7fe78da46..62392969d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1104,25 +1104,17 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/node-fetch@^2.5.7": - version "2.6.11" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.11.tgz#9b39b78665dae0e82a08f02f4967d62c66f95d24" - integrity sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g== +"@types/node@*", "@types/node@^25.1.0": + version "25.1.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-25.1.0.tgz#95cc584f1f478301efc86de4f1867e5875e83571" + integrity sha512-t7frlewr6+cbx+9Ohpl0NOTKXZNV9xHRmNOvql47BFJKcEG1CxtxlPEEe+gR9uhVWM4DwhnvTF110mIL4yP9RA== dependencies: - "@types/node" "*" - form-data "^4.0.0" - -"@types/node@*": - version "20.11.13" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.13.tgz#188263ee2c8d590e181d3f5bfa7e485a932957cb" - integrity sha512-5G4zQwdiQBSWYTDAH1ctw2eidqdhMJaNsiIDKHFr55ihz5Trl2qqR8fdrT732yPBho5gkNxXm67OxWFBqX9aPg== - dependencies: - undici-types "~5.26.4" + undici-types "~7.16.0" -"@types/pako@^1.0.1": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.7.tgz#aa0e4af9855d81153a29ff84cc44cce25298eda9" - integrity sha512-YBtzT2ztNF6R/9+UXj2wTGFnC9NklAnASt3sC0h2m1bbH7G6FyBIkt4AN8ThZpNfxUo1b2iMVO0UawiJymEt8A== +"@types/pako@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/pako/-/pako-2.0.4.tgz#c3575ef8125e176c345fa0e7b301c1db41170c15" + integrity sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw== "@types/parse-json@^4.0.0": version "4.0.2" @@ -1397,11 +1389,6 @@ async@^2.6.4: dependencies: lodash "^4.17.14" -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" @@ -1812,13 +1799,6 @@ colorette@^2.0.20: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - commander@^13.1.0: version "13.1.0" resolved "https://registry.yarnpkg.com/commander/-/commander-13.1.0.tgz#776167db68c78f38dcce1f9b8d7b8b9a488abf46" @@ -2067,11 +2047,6 @@ degenerator@^5.0.0: escodegen "^2.1.0" esprima "^4.0.1" -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - deprecation@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -2623,15 +2598,6 @@ form-data-encoder@^2.1.2: resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-2.1.4.tgz#261ea35d2a70d48d30ec7a9603130fa5515e9cd5" integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw== -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - formdata-polyfill@^4.0.10: version "4.0.10" resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" @@ -4233,7 +4199,7 @@ mime-db@1.52.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@2.1.35, mime-types@^2.1.12: +mime-types@2.1.35: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -5663,10 +5629,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -typescript@^4.9.5: - version "4.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@^5.9.3: + version "5.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== typescript@next: version "5.4.0-dev.20240202" @@ -5683,10 +5649,10 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -undici-types@~5.26.4: - version "5.26.5" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" - integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +undici-types@~7.16.0: + version "7.16.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" + integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== unicorn-magic@^0.1.0: version "0.1.0" From 319bbf41e2d88b880d049fe2fdfbd6aed7280a39 Mon Sep 17 00:00:00 2001 From: Sulidi Maimaitiming Date: Thu, 12 Mar 2026 02:04:10 +0100 Subject: [PATCH 3/3] Autoremove unused eslint-disable with yarn lint --- src/core/streams/FlateStream.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/streams/FlateStream.ts b/src/core/streams/FlateStream.ts index aa7e7cd48..25f14be65 100644 --- a/src/core/streams/FlateStream.ts +++ b/src/core/streams/FlateStream.ts @@ -272,7 +272,6 @@ class FlateStream extends DecodeStream { buffer = this.buffer; let limit = buffer ? buffer.length : 0; let pos = this.bufferLength; - // eslint-disable-next-line no-constant-condition while (true) { let code1 = this.getCode(litCodeTable); if (code1 < 256) {