diff --git a/example/example.ts b/example/example.ts index 4616598..6b14448 100644 --- a/example/example.ts +++ b/example/example.ts @@ -1,3 +1,3 @@ import { init } from '../dist/es2015'; -init('http://localhost:8080/pdf.worker.min.js'); \ No newline at end of file +init('http://localhost:8080/pdf.worker.min.mjs'); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a0fb873..833481d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "document-viewer-ts", - "version": "0.7.0-legacy", + "version": "1.0.0-legacy", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "document-viewer-ts", - "version": "0.7.0-legacy", + "version": "1.0.0-legacy", "license": "MIT", "devDependencies": { "@playwright/test": "^1.42.1", @@ -23,7 +23,7 @@ "core-js": "~3.23.3", "eslint": "~8.38.0", "express": "^4.18.3", - "pdfjs-dist": "3.11.174", + "pdfjs-dist": "4.3.136", "process": "~0.11.10", "react": "^16.9.0", "react-dom": "^16.9.0", @@ -3178,27 +3178,27 @@ "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.0", + "resolved": "https://registry.npmjs.org/path2d/-/path2d-0.2.0.tgz", + "integrity": "sha512-KdPAykQX6kmLSOO6Jpu2KNcCED7CKjmaBNGGNuctOsG0hgYO1OdYQaan6cYXJiG0WmXOwZZPILPBimu5QAIw3A==", "dev": true, "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.3.136", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.3.136.tgz", + "integrity": "sha512-gzfnt1qc4yA+U46golPGYtU4WM2ssqP2MvFjKga8GEKOrEnzRPrA/9jogLLPYHiA3sGBPJ+p7BdAq+ytmw3jEg==", "dev": true, "engines": { "node": ">=18" }, "optionalDependencies": { "canvas": "^2.11.2", - "path2d-polyfill": "^2.0.1" + "path2d": "^0.2.0" } }, "node_modules/picocolors": { diff --git a/package.json b/package.json index f4b0ce3..6a9dcca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "document-viewer-ts", - "version": "0.7.1-legacy", + "version": "1.0.0-legacy", "description": "PDF and MS Doc viewer written in TypeScript for React and vanilla JavaScript", "main": "dist/lib/index.js", "module": "dist/es2015/index.js", @@ -13,8 +13,7 @@ "styles" ], "scripts": { - "build": "npm run build-es2015 && npm run build-cjs", - "build-cjs": "tsc -p tsconfig.commonjs.json", + "build": "npm run build-es2015", "build-es2015": "tsc -p tsconfig.json", "build-example": "npm run build && tsc -p tsconfig.example.json && webpack", "clean": "rimraf ./dist ./build", @@ -68,7 +67,7 @@ "core-js": "~3.23.3", "eslint": "~8.38.0", "express": "^4.18.3", - "pdfjs-dist": "3.11.174", + "pdfjs-dist": "4.3.136", "process": "~0.11.10", "react": "^16.9.0", "react-dom": "^16.9.0", diff --git a/src/base.ts b/src/base.ts index 51ef4aa..069a87e 100644 --- a/src/base.ts +++ b/src/base.ts @@ -1,4 +1,4 @@ -import { GlobalWorkerOptions, PDFDocumentProxy, PDFPageProxy, PageViewport, getDocument, renderTextLayer } from 'pdfjs-dist/legacy/build/pdf'; +import { GlobalWorkerOptions, PDFDocumentProxy, PDFPageProxy, PageViewport, getDocument, renderTextLayer } from 'pdfjs-dist/legacy/build/pdf.mjs'; import type { TextContent } from 'pdfjs-dist/types/src/display/api'; const chevronLeft = ` @@ -36,7 +36,7 @@ const scaleTextLayer = async ( textContentSource: textContent, container: textLayerFragment, viewport: vs - }).promise; + })?.promise; textLayerDiv.appendChild(textLayerFragment); }; diff --git a/tsconfig.commonjs.json b/tsconfig.commonjs.json deleted file mode 100644 index 6620f81..0000000 --- a/tsconfig.commonjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "./dist/lib", - }, -} diff --git a/tsconfig.example.json b/tsconfig.example.json index 992ee72..d7b550f 100644 --- a/tsconfig.example.json +++ b/tsconfig.example.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "commonjs", "outDir": "./build", }, "include": [ diff --git a/webpack.config.js b/webpack.config.js index 70c56ae..e2b73a8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,7 +14,7 @@ module.exports = { }, plugins: [ new webpack.ProvidePlugin({ - process: 'process/browser', + process: 'process/browser.js', }), ] }; \ No newline at end of file