diff --git a/package.json b/package.json index 194c4cd..87b1ac4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "mermaid": "^10.3.1", "pako": "^2.1.0", "path-to-regexp": "^7.0.0", - "puppeteer": "^22.4.1" + "puppeteer": "^23.0.2" }, "devDependencies": { "@happy-dom/jest-environment": "^14.3.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a116786..c9a53fe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,8 +33,8 @@ dependencies: specifier: ^7.0.0 version: 7.1.0 puppeteer: - specifier: ^22.4.1 - version: 22.14.0 + specifier: ^23.0.2 + version: 23.0.2 devDependencies: '@happy-dom/jest-environment': @@ -1379,8 +1379,8 @@ packages: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} dev: false - /chromium-bidi@0.6.2(devtools-protocol@0.0.1312386): - resolution: {integrity: sha512-4WVBa6ijmUTVr9cZD4eicQD8Mdy/HCX3bzEIYYpmk0glqYLoWH+LqQEvV9RpDRzoQSbY1KJHloYXbDMXMbDPhg==} + /chromium-bidi@0.6.4(devtools-protocol@0.0.1312386): + resolution: {integrity: sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==} peerDependencies: devtools-protocol: '*' dependencies: @@ -3675,12 +3675,12 @@ packages: once: 1.4.0 dev: false - /puppeteer-core@22.14.0: - resolution: {integrity: sha512-rl4tOY5LcA3e374GAlsGGHc05HL3eGNf5rZ+uxkl6id9zVZKcwcp1Z+Nd6byb6WPiPeecT/dwz8f/iUm+AZQSw==} + /puppeteer-core@23.0.2: + resolution: {integrity: sha512-MvOHn+g1TYkAR2oVd/bf/YWXKqFTJmkhyyurYgxkrjh8rBOL1ZH5VyOsLJi0bLO7/yoipAmk1gFZEx9HUJnaoA==} engines: {node: '>=18'} dependencies: '@puppeteer/browsers': 2.3.0 - chromium-bidi: 0.6.2(devtools-protocol@0.0.1312386) + chromium-bidi: 0.6.4(devtools-protocol@0.0.1312386) debug: 4.3.6 devtools-protocol: 0.0.1312386 ws: 8.18.0 @@ -3690,16 +3690,17 @@ packages: - utf-8-validate dev: false - /puppeteer@22.14.0: - resolution: {integrity: sha512-MGTR6/pM8zmWbTdazb6FKnwIihzsSEXBPH49mFFU96DNZpQOevCAZMnjBZGlZRGRzRK6aADCavR6SQtrbv5dQw==} + /puppeteer@23.0.2: + resolution: {integrity: sha512-I/l1P8s8brcLG+oW9AwF8hUaOSGGJcGKMflXRgULUH0S3ABptlLI9ZKjqWDo8ipY6v789ZKd+bNKtcCwpTh5Ww==} engines: {node: '>=18'} hasBin: true requiresBuild: true dependencies: '@puppeteer/browsers': 2.3.0 + chromium-bidi: 0.6.4(devtools-protocol@0.0.1312386) cosmiconfig: 9.0.0 devtools-protocol: 0.0.1312386 - puppeteer-core: 22.14.0 + puppeteer-core: 23.0.2 transitivePeerDependencies: - bufferutil - supports-color diff --git a/src/views/img.js b/src/views/img.js index 926b914..db01892 100644 --- a/src/views/img.js +++ b/src/views/img.js @@ -34,7 +34,7 @@ const img = async (ctx, page, size) => { // dynamically set media type ctx.type = `image/${type}`; - ctx.body = image; + ctx.body = Buffer.from(image); }; module.exports = renderImgOrSvg(img); diff --git a/src/views/pdf.js b/src/views/pdf.js index 5c7531a..a653b92 100644 --- a/src/views/pdf.js +++ b/src/views/pdf.js @@ -63,7 +63,7 @@ const pdf = async (ctx, page, size) => { debug('printed to pdf, file size: %o', pdf.length); ctx.type = 'application/pdf'; - ctx.body = pdf; + ctx.body = Buffer.from(pdf); }; module.exports = renderImgOrSvg(pdf); diff --git a/test/kitchensink.test.js b/test/kitchensink.test.js index 471f0a2..b4f71ba 100644 --- a/test/kitchensink.test.js +++ b/test/kitchensink.test.js @@ -406,7 +406,7 @@ describe('app', () => { ); expect(resp.status).toEqual(200); expect(resp.type).toEqual('application/pdf'); - expect(resp.body.length).toBeGreaterThan(19 * KB); + expect(resp.body.length).toBeGreaterThan(17 * KB); await PDFDocument.load(resp.body.toString('base64')); }); @@ -417,7 +417,7 @@ describe('app', () => { ); expect(resp.status).toEqual(200); expect(resp.type).toEqual('application/pdf'); - expect(resp.body.length).toBeGreaterThan(19 * KB); + expect(resp.body.length).toBeGreaterThan(17 * KB); const pdfDoc = await PDFDocument.load(resp.body.toString('base64')); const pages = pdfDoc.getPages();