From e13921c666a34f524699f05e0181c418abead507 Mon Sep 17 00:00:00 2001 From: Andrii Vitiv Date: Wed, 18 Sep 2024 19:27:42 +0300 Subject: [PATCH 1/2] Upgrade `react-pdf` to v9.1.1 --- package-lock.json | 226 +++++++++++++++++-------------------------- package.json | 4 +- src/PDFPreviewer.tsx | 4 +- 3 files changed, 94 insertions(+), 140 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef1f25b..890cd18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.14", "license": "MIT", "dependencies": { - "react-pdf": "^7.7.0", + "react-pdf": "^9.1.1", "react-window": "^1.8.10" }, "devDependencies": { @@ -21,7 +21,6 @@ "@types/lodash": "^4.14.198", "@types/react": "^18.2.17", "@types/react-dom": "^18.2.7", - "@types/react-pdf": "^7.0.0", "@types/react-window": "^1.8.5", "@typescript-eslint/eslint-plugin": "^6.2.0", "@typescript-eslint/parser": "^6.2.0", @@ -46,12 +45,13 @@ "webpack-dev-server": "^4.15.1" }, "engines": { - "node": "20.10.0", - "npm": "10.2.3" + "node": ">=20.10.0", + "npm": ">=10.2.3" }, "peerDependencies": { "lodash": "4.x", "prop-types": "15.x", + "pdfjs-dist": "4.x", "react": "18.x", "react-dom": "18.x" } @@ -2105,18 +2105,6 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, - "node_modules/@mapbox/node-pre-gyp/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "optional": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@mapbox/node-pre-gyp/node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -2142,13 +2130,10 @@ } }, "node_modules/@mapbox/node-pre-gyp/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "optional": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -2156,12 +2141,6 @@ "node": ">=10" } }, - "node_modules/@mapbox/node-pre-gyp/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "optional": true - }, "node_modules/@nicolo-ribaudo/chokidar-2": { "version": "2.1.8-no-fsevents.3", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", @@ -2346,7 +2325,8 @@ "node_modules/@types/prop-types": { "version": "15.7.6", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.6.tgz", - "integrity": "sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==" + "integrity": "sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==", + "devOptional": true }, "node_modules/@types/qs": { "version": "6.9.8", @@ -2364,6 +2344,7 @@ "version": "18.2.22", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.22.tgz", "integrity": "sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==", + "devOptional": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -2379,16 +2360,6 @@ "@types/react": "*" } }, - "node_modules/@types/react-pdf": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@types/react-pdf/-/react-pdf-7.0.0.tgz", - "integrity": "sha512-G0a+5UiKk3AvEauBP/Js7r9kGZNW3iBbS6kXkH0foGSaKWR6K3ElTe7Y4tlolc2VKbM9udmMxpkbxh/dtR2wXA==", - "deprecated": "This is a stub types definition. react-pdf provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "react-pdf": "*" - } - }, "node_modules/@types/react-window": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.5.tgz", @@ -2407,7 +2378,8 @@ "node_modules/@types/scheduler": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" + "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==", + "devOptional": true }, "node_modules/@types/semver": { "version": "7.5.2", @@ -3134,6 +3106,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "deprecated": "This package is no longer supported.", "optional": true, "dependencies": { "delegates": "^1.0.0", @@ -4017,7 +3990,8 @@ "node_modules/csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "devOptional": true }, "node_modules/damerau-levenshtein": { "version": "1.0.8", @@ -4146,9 +4120,9 @@ } }, "node_modules/detect-libc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", - "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", "optional": true, "engines": { "node": ">=8" @@ -5427,6 +5401,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "deprecated": "This package is no longer supported.", "optional": true, "dependencies": { "aproba": "^1.0.3 || ^2.0.0", @@ -6872,14 +6847,19 @@ "dev": true }, "node_modules/merge-refs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge-refs/-/merge-refs-1.2.1.tgz", - "integrity": "sha512-pRPz39HQz2xzHdXAGvtJ9S8aEpNgpUjzb5yPC3ytozodmsHg+9nqgRs7/YOmn9fM/TLzntAC8AdGTidKxOq9TQ==", - "dependencies": { - "@types/react": "*" - }, + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/merge-refs/-/merge-refs-1.3.0.tgz", + "integrity": "sha512-nqXPXbso+1dcKDpPCXvwZyJILz+vSLqGGOnDrYHQYE+B8n9JTCekVLC65AfCpR4ggVyA/45Y0iR9LDyS2iI+zA==", "funding": { "url": "https://github.com/wojtekmaj/merge-refs?sponsor=1" + }, + "peerDependencies": { + "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } } }, "node_modules/merge-stream": { @@ -7072,9 +7052,9 @@ } }, "node_modules/nan": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", - "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", + "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==", "optional": true }, "node_modules/nanoid": { @@ -7201,6 +7181,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "deprecated": "This package is no longer supported.", "optional": true, "dependencies": { "are-we-there-yet": "^2.0.0", @@ -7582,25 +7563,25 @@ "node": ">=8" } }, - "node_modules/path2d-polyfill": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path2d-polyfill/-/path2d-polyfill-2.0.1.tgz", - "integrity": "sha512-ad/3bsalbbWhmBo0D6FZ4RNMwsLsPpL6gnvhuSaU5Vm7b06Kr5ubSltQQ0T7YKsiJQO+g22zJ4dJKNTXIyOXtA==", + "node_modules/path2d": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/path2d/-/path2d-0.2.1.tgz", + "integrity": "sha512-Fl2z/BHvkTNvkuBzYTpTuirHZg6wW9z8+4SND/3mDTEcYbbNKWAy21dz9D3ePNNwrrK8pqZO5vLPZ1hLF6T7XA==", "optional": true, "engines": { - "node": ">=8" + "node": ">=6" } }, "node_modules/pdfjs-dist": { - "version": "3.11.174", - "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.11.174.tgz", - "integrity": "sha512-TdTZPf1trZ8/UFu5Cx/GXB7GZM30LT+wWUNfsi6Bq8ePLnb+woNKtDymI2mxZYBpMbonNFqKmiz684DIfnd8dA==", + "version": "4.4.168", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.4.168.tgz", + "integrity": "sha512-MbkAjpwka/dMHaCfQ75RY1FXX3IewBVu6NGZOcxerRFlaBiIkZmUoR0jotX5VUzYZEXAGzSFtknWs5xRKliXPA==", "engines": { "node": ">=18" }, "optionalDependencies": { "canvas": "^2.11.2", - "path2d-polyfill": "^2.0.1" + "path2d": "^0.2.0" } }, "node_modules/picocolors": { @@ -8022,17 +8003,16 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-pdf": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-7.7.0.tgz", - "integrity": "sha512-704ObLnRDm5lixL4e6NXNLaincBHGNLo+NGdbO3rEXE963NlNzwLxFpmKcbdXHAMQL4rYJQWb1L0w5IL6y8Osw==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-9.1.1.tgz", + "integrity": "sha512-Cn3RTJZMqVOOCgLMRXDamLk4LPGfyB2Np3OwQAUjmHIh47EpuGW1OpAA1Z1GVDLoHx4d5duEDo/YbUkDbr4QFQ==", "dependencies": { "clsx": "^2.0.0", "dequal": "^2.0.3", "make-cancellable-promise": "^1.3.1", "make-event-props": "^1.6.0", - "merge-refs": "^1.2.1", - "pdfjs-dist": "3.11.174", - "prop-types": "^15.6.2", + "merge-refs": "^1.3.0", + "pdfjs-dist": "4.4.168", "tiny-invariant": "^1.0.0", "warning": "^4.0.0" }, @@ -8040,9 +8020,9 @@ "url": "https://github.com/wojtekmaj/react-pdf?sponsor=1" }, "peerDependencies": { - "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "peerDependenciesMeta": { "@types/react": { @@ -9038,9 +9018,9 @@ } }, "node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "optional": true, "dependencies": { "chownr": "^2.0.0", @@ -11506,15 +11486,6 @@ "tar": "^6.1.11" }, "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "optional": true, - "requires": { - "yallist": "^4.0.0" - } - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -11533,18 +11504,9 @@ } }, "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "optional": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "optional": true } } @@ -11724,7 +11686,8 @@ "@types/prop-types": { "version": "15.7.6", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.6.tgz", - "integrity": "sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==" + "integrity": "sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==", + "devOptional": true }, "@types/qs": { "version": "6.9.8", @@ -11742,6 +11705,7 @@ "version": "18.2.22", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.22.tgz", "integrity": "sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==", + "devOptional": true, "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -11757,15 +11721,6 @@ "@types/react": "*" } }, - "@types/react-pdf": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@types/react-pdf/-/react-pdf-7.0.0.tgz", - "integrity": "sha512-G0a+5UiKk3AvEauBP/Js7r9kGZNW3iBbS6kXkH0foGSaKWR6K3ElTe7Y4tlolc2VKbM9udmMxpkbxh/dtR2wXA==", - "dev": true, - "requires": { - "react-pdf": "*" - } - }, "@types/react-window": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.5.tgz", @@ -11784,7 +11739,8 @@ "@types/scheduler": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" + "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==", + "devOptional": true }, "@types/semver": { "version": "7.5.2", @@ -13002,7 +12958,8 @@ "csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "devOptional": true }, "damerau-levenshtein": { "version": "1.0.8", @@ -13095,9 +13052,9 @@ "dev": true }, "detect-libc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", - "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", "optional": true }, "detect-node": { @@ -15138,12 +15095,10 @@ "dev": true }, "merge-refs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge-refs/-/merge-refs-1.2.1.tgz", - "integrity": "sha512-pRPz39HQz2xzHdXAGvtJ9S8aEpNgpUjzb5yPC3ytozodmsHg+9nqgRs7/YOmn9fM/TLzntAC8AdGTidKxOq9TQ==", - "requires": { - "@types/react": "*" - } + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/merge-refs/-/merge-refs-1.3.0.tgz", + "integrity": "sha512-nqXPXbso+1dcKDpPCXvwZyJILz+vSLqGGOnDrYHQYE+B8n9JTCekVLC65AfCpR4ggVyA/45Y0iR9LDyS2iI+zA==", + "requires": {} }, "merge-stream": { "version": "2.0.0", @@ -15283,9 +15238,9 @@ } }, "nan": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", - "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", + "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==", "optional": true }, "nanoid": { @@ -15656,19 +15611,19 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, - "path2d-polyfill": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path2d-polyfill/-/path2d-polyfill-2.0.1.tgz", - "integrity": "sha512-ad/3bsalbbWhmBo0D6FZ4RNMwsLsPpL6gnvhuSaU5Vm7b06Kr5ubSltQQ0T7YKsiJQO+g22zJ4dJKNTXIyOXtA==", + "path2d": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/path2d/-/path2d-0.2.1.tgz", + "integrity": "sha512-Fl2z/BHvkTNvkuBzYTpTuirHZg6wW9z8+4SND/3mDTEcYbbNKWAy21dz9D3ePNNwrrK8pqZO5vLPZ1hLF6T7XA==", "optional": true }, "pdfjs-dist": { - "version": "3.11.174", - "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.11.174.tgz", - "integrity": "sha512-TdTZPf1trZ8/UFu5Cx/GXB7GZM30LT+wWUNfsi6Bq8ePLnb+woNKtDymI2mxZYBpMbonNFqKmiz684DIfnd8dA==", + "version": "4.4.168", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.4.168.tgz", + "integrity": "sha512-MbkAjpwka/dMHaCfQ75RY1FXX3IewBVu6NGZOcxerRFlaBiIkZmUoR0jotX5VUzYZEXAGzSFtknWs5xRKliXPA==", "requires": { "canvas": "^2.11.2", - "path2d-polyfill": "^2.0.1" + "path2d": "^0.2.0" } }, "picocolors": { @@ -15949,17 +15904,16 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "react-pdf": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-7.7.0.tgz", - "integrity": "sha512-704ObLnRDm5lixL4e6NXNLaincBHGNLo+NGdbO3rEXE963NlNzwLxFpmKcbdXHAMQL4rYJQWb1L0w5IL6y8Osw==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-9.1.1.tgz", + "integrity": "sha512-Cn3RTJZMqVOOCgLMRXDamLk4LPGfyB2Np3OwQAUjmHIh47EpuGW1OpAA1Z1GVDLoHx4d5duEDo/YbUkDbr4QFQ==", "requires": { "clsx": "^2.0.0", "dequal": "^2.0.3", "make-cancellable-promise": "^1.3.1", "make-event-props": "^1.6.0", - "merge-refs": "^1.2.1", - "pdfjs-dist": "3.11.174", - "prop-types": "^15.6.2", + "merge-refs": "^1.3.0", + "pdfjs-dist": "4.4.168", "tiny-invariant": "^1.0.0", "warning": "^4.0.0" } @@ -16716,9 +16670,9 @@ "dev": true }, "tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "optional": true, "requires": { "chownr": "^2.0.0", diff --git a/package.json b/package.json index c060559..b2acfac 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,13 @@ }, "homepage": "https://github.com/Expensify/react-fast-pdf#readme", "dependencies": { - "react-pdf": "^7.7.0", + "react-pdf": "^9.1.1", "react-window": "^1.8.10" }, "peerDependencies": { "lodash": "4.x", "prop-types": "15.x", + "pdfjs-dist": "4.x", "react": "18.x", "react-dom": "18.x" }, @@ -47,7 +48,6 @@ "@types/lodash": "^4.14.198", "@types/react": "^18.2.17", "@types/react-dom": "^18.2.7", - "@types/react-pdf": "^7.0.0", "@types/react-window": "^1.8.5", "@typescript-eslint/eslint-plugin": "^6.2.0", "@typescript-eslint/parser": "^6.2.0", diff --git a/src/PDFPreviewer.tsx b/src/PDFPreviewer.tsx index e810d23..bbac165 100644 --- a/src/PDFPreviewer.tsx +++ b/src/PDFPreviewer.tsx @@ -1,6 +1,6 @@ // @ts-expect-error - This line imports a module from 'pdfjs-dist' package which lacks TypeScript typings. -// eslint-disable-next-line import/no-extraneous-dependencies -import pdfWorkerSource from 'pdfjs-dist/legacy/build/pdf.worker'; +// eslint-disable-next-line import/extensions +import pdfWorkerSource from 'pdfjs-dist/legacy/build/pdf.worker.mjs'; import React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react'; import type {CSSProperties, ReactNode} from 'react'; import times from 'lodash/times'; From 4d97e3d3681cf6b8f112f026301af74b60ee1807 Mon Sep 17 00:00:00 2001 From: Andrii Vitiv Date: Thu, 19 Sep 2024 11:27:18 +0300 Subject: [PATCH 2/2] Remove PropTypes See https://github.com/wojtekmaj/react-pdf/wiki/Upgrade-guide-from-version-7.x-to-8.x#proptypes-were-removed --- .eslintrc.json | 1 + package-lock.json | 13 +++++++---- package.json | 1 - src/PDFPasswordForm.tsx | 24 -------------------- src/PDFPreviewer.tsx | 49 ++++++++--------------------------------- src/PageRenderer.tsx | 27 ----------------------- 6 files changed, 19 insertions(+), 96 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index f3d9c55..7bb17a4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,6 +22,7 @@ } ], "no-invalid-this": "error", + "react/require-default-props": "off", "react/function-component-definition": [ "error", { diff --git a/package-lock.json b/package-lock.json index 890cd18..7b08360 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,6 @@ }, "peerDependencies": { "lodash": "4.x", - "prop-types": "15.x", "pdfjs-dist": "4.x", "react": "18.x", "react-dom": "18.x" @@ -7206,6 +7205,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "devOptional": true, "engines": { "node": ">=0.10.0" } @@ -7858,6 +7858,7 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -8000,7 +8001,8 @@ "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true }, "node_modules/react-pdf": { "version": "9.1.1", @@ -15346,7 +15348,8 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "devOptional": true }, "object-inspect": { "version": "1.12.3", @@ -15799,6 +15802,7 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, "requires": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -15901,7 +15905,8 @@ "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true }, "react-pdf": { "version": "9.1.1", diff --git a/package.json b/package.json index b2acfac..0d5f5d9 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ }, "peerDependencies": { "lodash": "4.x", - "prop-types": "15.x", "pdfjs-dist": "4.x", "react": "18.x", "react-dom": "18.x" diff --git a/src/PDFPasswordForm.tsx b/src/PDFPasswordForm.tsx index c06d0cd..f86d773 100644 --- a/src/PDFPasswordForm.tsx +++ b/src/PDFPasswordForm.tsx @@ -1,5 +1,4 @@ import React, {useState, useRef, useMemo, type ChangeEvent, type FormEventHandler} from 'react'; -import PropTypes from 'prop-types'; import {pdfPasswordFormStyles as styles} from './styles'; import {isSafari} from './helpers'; @@ -11,27 +10,6 @@ type Props = { onPasswordFieldFocus?: (isFocused: boolean) => void; }; -const propTypes = { - /** If the submitted password is invalid (show an error message) */ - isPasswordInvalid: PropTypes.bool, - - /** Notify parent that the password form has been submitted */ - onSubmit: PropTypes.func, - - /** Notify parent that the password has been updated/edited */ - onPasswordChange: PropTypes.func, - - /** Notify parent that a text field has been focused or blurred */ - onPasswordFieldFocus: PropTypes.func, -}; - -const defaultProps = { - isPasswordInvalid: false, - onSubmit: () => {}, - onPasswordChange: () => {}, - onPasswordFieldFocus: () => {}, -}; - function PDFPasswordForm({isPasswordInvalid, onSubmit, onPasswordChange, onPasswordFieldFocus}: Props) { const [password, setPassword] = useState(''); const [validationErrorText, setValidationErrorText] = useState(''); @@ -151,8 +129,6 @@ function PDFPasswordForm({isPasswordInvalid, onSubmit, onPasswordChange, onPassw ); } -PDFPasswordForm.propTypes = propTypes; -PDFPasswordForm.defaultProps = defaultProps; PDFPasswordForm.displayName = 'PDFPasswordForm'; export type {Props as PDFPasswordFormProps}; diff --git a/src/PDFPreviewer.tsx b/src/PDFPreviewer.tsx index bbac165..f5f44b1 100644 --- a/src/PDFPreviewer.tsx +++ b/src/PDFPreviewer.tsx @@ -4,7 +4,6 @@ import pdfWorkerSource from 'pdfjs-dist/legacy/build/pdf.worker.mjs'; import React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react'; import type {CSSProperties, ReactNode} from 'react'; import times from 'lodash/times'; -import PropTypes from 'prop-types'; import {VariableSizeList as List} from 'react-window'; import {Document, pdfjs} from 'react-pdf'; import 'react-pdf/dist/Page/AnnotationLayer.css'; @@ -21,9 +20,9 @@ type Props = { file: string; pageMaxWidth: number; isSmallScreen: boolean; - maxCanvasWidth: number | null; - maxCanvasHeight: number | null; - maxCanvasArea: number | null; + maxCanvasWidth?: number; + maxCanvasHeight?: number; + maxCanvasArea?: number; renderPasswordForm?: ({isPasswordInvalid, onSubmit, onPasswordChange}: Omit) => ReactNode | null; LoadingComponent?: ReactNode; ErrorComponent?: ReactNode; @@ -35,39 +34,11 @@ type Props = { type OnPasswordCallback = (password: string | null) => void; -const propTypes = { - file: PropTypes.string.isRequired, - pageMaxWidth: PropTypes.number.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - maxCanvasWidth: PropTypes.number, - maxCanvasHeight: PropTypes.number, - maxCanvasArea: PropTypes.number, - renderPasswordForm: PropTypes.func, - LoadingComponent: PropTypes.node, - ErrorComponent: PropTypes.node, - shouldShowErrorComponent: PropTypes.bool, - onLoadError: PropTypes.func, - // eslint-disable-next-line react/forbid-prop-types - containerStyle: PropTypes.object, - // eslint-disable-next-line react/forbid-prop-types - contentContainerStyle: PropTypes.object, -}; - -const defaultProps = { - maxCanvasWidth: null, - maxCanvasHeight: null, - maxCanvasArea: null, - renderPasswordForm: null, - LoadingComponent:

Loading...

, - ErrorComponent:

Failed to load the PDF file :(

, - shouldShowErrorComponent: true, - containerStyle: {}, - contentContainerStyle: {}, - onLoadError: () => {}, -}; - pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'})); +const DefaultLoadingComponent =

Loading...

; +const DefaultErrorComponent =

Failed to load the PDF file :(

; + function PDFPreviewer({ file, pageMaxWidth, @@ -75,12 +46,12 @@ function PDFPreviewer({ maxCanvasWidth, maxCanvasHeight, maxCanvasArea, - LoadingComponent, - ErrorComponent, + LoadingComponent = DefaultLoadingComponent, + ErrorComponent = DefaultErrorComponent, renderPasswordForm, containerStyle, contentContainerStyle, - shouldShowErrorComponent, + shouldShowErrorComponent = true, onLoadError, }: Props) { const [pageViewports, setPageViewports] = useState([]); @@ -285,7 +256,5 @@ function PDFPreviewer({ } PDFPasswordForm.displayName = 'PDFPreviewer'; -PDFPreviewer.propTypes = propTypes; -PDFPreviewer.defaultProps = defaultProps; export default memo(PDFPreviewer); diff --git a/src/PageRenderer.tsx b/src/PageRenderer.tsx index 262a421..237483d 100644 --- a/src/PageRenderer.tsx +++ b/src/PageRenderer.tsx @@ -1,5 +1,4 @@ import React, {memo, type CSSProperties} from 'react'; -import PropTypes from 'prop-types'; import {Page} from 'react-pdf'; import {pdfPreviewerStyles as styles} from './styles'; import {PAGE_BORDER} from './constants'; @@ -17,31 +16,6 @@ type Props = { }; }; -const propTypes = { - /** Index of the PDF page to be displayed passed by VariableSizeList */ - index: PropTypes.number.isRequired, - - /** Page extra data passed by VariableSizeList's data prop */ - data: PropTypes.shape({ - /** Width of a single page in the document */ - pageWidth: PropTypes.number.isRequired, - /** The estimated height of a single page in the document */ - estimatedPageHeight: PropTypes.number.isRequired, - /** Function that calculates the height of a page given its index */ - calculatePageHeight: PropTypes.func.isRequired, - /** Function that calculates the pixel ratio for a page given its calculated width and height */ - getDevicePixelRatio: PropTypes.func.isRequired, - /** The number of pages in the document */ - numPages: PropTypes.number.isRequired, - /** The height of the container view */ - containerHeight: PropTypes.number.isRequired, - }).isRequired, - - /** Additional style props passed by VariableSizeList */ - // eslint-disable-next-line react/forbid-prop-types - style: PropTypes.object.isRequired, -}; - function PageRenderer({index, style, data}: Props) { const {pageWidth, estimatedPageHeight, calculatePageHeight, getDevicePixelRatio, numPages, containerHeight} = data; /** @@ -70,6 +44,5 @@ function PageRenderer({index, style, data}: Props) { } PageRenderer.displayName = 'PageRenderer'; -PageRenderer.propTypes = propTypes; export default memo(PageRenderer);