Skip to content

Commit

Permalink
Merge pull request #425 from xylabs/feature/upgrade-puppeteer
Browse files Browse the repository at this point in the history
Upgrade Puppeteer
  • Loading branch information
JoelBCarter authored Aug 12, 2024
2 parents 5c79074 + 56fd552 commit 790d991
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"lru-cache": "^11.0.0",
"mime": "^4.0.4",
"minimatch": "^10.0.1",
"puppeteer": "^22.15.0",
"puppeteer": "^23.0.2",
"serve-static": "^1.15.0",
"yargs": "^17.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/browser/useBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ process.env.PUPPETEER_DISABLE_HEADLESS_WARNING = 'true'
export const useBrowser = async (viewport: Viewport = viewPortDefaults): Promise<Browser> => {
const defaultViewport: Viewport = { ...viewPortDefaults, ...viewport }
const browser = await launch({
acceptInsecureCerts: true,
args: getBrowserArgs(),
defaultViewport,
devtools: false,
headless: true,
ignoreHTTPSErrors: true,
waitForInitialPage,
})
return browser
Expand Down
8 changes: 4 additions & 4 deletions src/modules/metaServer/lib/image/generateImageFromPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ export const generateImageStringFromPage = (page: Page, screenshotOptions: Scree
return page.screenshot(options)
}

export const generateImageBufferFromPage = (page: Page, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions): Promise<Buffer> => {
export const generateImageBufferFromPage = (page: Page, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions): Promise<Uint8Array> => {
const options = { ...screenshotOptions, encoding: 'binary' } as const
return page.screenshot(options)
}

export const generateImageFromPage = (
page: Page,
screenshotOptions: ScreenshotOptions = defaultScreenshotOptions,
): Promise<Buffer | string | undefined> => {
): Promise<Uint8Array> => {
return page.screenshot(screenshotOptions)
}

export const renderAndGenerateImageFromPage = async (
url: string,
pageRenderingOptions: PageRenderingOptions = defaultPageRenderingOptions,
screenshotOptions: ScreenshotOptions = defaultScreenshotOptions,
): Promise<Buffer | string | undefined> => {
let image: Buffer | string | undefined = undefined
): Promise<Uint8Array> => {
let image: Uint8Array = new Uint8Array(0)
await usePage(url, pageRenderingOptions, async (page: Page) => {
image = await generateImageFromPage(page, screenshotOptions)
})
Expand Down
33 changes: 17 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5271,7 +5271,7 @@ __metadata:
mime: "npm:^4.0.4"
minimatch: "npm:^10.0.1"
nodemon: "npm:^3.1.4"
puppeteer: "npm:^22.15.0"
puppeteer: "npm:^23.0.2"
serve-static: "npm:^1.15.0"
supertest: "npm:^7.0.0"
ts-jest: "npm:^29.2.4"
Expand Down Expand Up @@ -6590,16 +6590,16 @@ __metadata:
languageName: node
linkType: hard

"chromium-bidi@npm:0.6.3":
version: 0.6.3
resolution: "chromium-bidi@npm:0.6.3"
"chromium-bidi@npm:0.6.4":
version: 0.6.4
resolution: "chromium-bidi@npm:0.6.4"
dependencies:
mitt: "npm:3.0.1"
urlpattern-polyfill: "npm:10.0.0"
zod: "npm:3.23.8"
peerDependencies:
devtools-protocol: "*"
checksum: 10/5a4dd35a09cc26c6610883055dfda4212a09d761aa020bcbcf96824bea008e34a48fef712af40a2e07e804fff7302d0213233292a63b868605beba63320601f4
checksum: 10/b7abf812793861e20698a5a758775d0d15300c968dc1a7177238fdcc76ba66946e7cde9c6dd822aa11de3f79d64c883990e32c9d151802b82827e96226a85430
languageName: node
linkType: hard

Expand Down Expand Up @@ -13357,30 +13357,31 @@ __metadata:
languageName: node
linkType: hard

"puppeteer-core@npm:22.15.0":
version: 22.15.0
resolution: "puppeteer-core@npm:22.15.0"
"puppeteer-core@npm:23.0.2":
version: 23.0.2
resolution: "puppeteer-core@npm:23.0.2"
dependencies:
"@puppeteer/browsers": "npm:2.3.0"
chromium-bidi: "npm:0.6.3"
chromium-bidi: "npm:0.6.4"
debug: "npm:^4.3.6"
devtools-protocol: "npm:0.0.1312386"
ws: "npm:^8.18.0"
checksum: 10/904d98673c1a96373cd3d29e296708bf0a6e7f1c945591fa7848af74f86a415fdd677db908dedf2257aeb88f8131cfdadeb81d81ba8740cca1f65bb05f83834c
checksum: 10/cdb007c1f0ece6f08f3bcb7026a1ce4cc0c1b7b6f1099ed626ad861100062faef10b098a8170ae3433ea41dd8a0bbd0c31ef79fa57f8fdd3087fb6a24286cbac
languageName: node
linkType: hard

"puppeteer@npm:^22.15.0":
version: 22.15.0
resolution: "puppeteer@npm:22.15.0"
"puppeteer@npm:^23.0.2":
version: 23.0.2
resolution: "puppeteer@npm:23.0.2"
dependencies:
"@puppeteer/browsers": "npm:2.3.0"
chromium-bidi: "npm:0.6.4"
cosmiconfig: "npm:^9.0.0"
devtools-protocol: "npm:0.0.1312386"
puppeteer-core: "npm:22.15.0"
puppeteer-core: "npm:23.0.2"
bin:
puppeteer: lib/esm/puppeteer/node/cli.js
checksum: 10/500ea99250e2a48ef3e943c82b5d3983db846e0083863dd57086874db19d6e9ac0bf03c31bc80fa1154e795e3904820e1fe0a9052a454206cfb411f0b57ff70f
puppeteer: lib/cjs/puppeteer/node/cli.js
checksum: 10/9d5b8c6ceaa0c7c2d20e3790c4924b2022bf61030f61c6ff4fb26efd118c6f2f272ec3bfae741949eabadedd3b8dc06af0c0c853aaf7f9230c665495d0275168
languageName: node
linkType: hard

Expand Down

0 comments on commit 790d991

Please sign in to comment.