Skip to content

Commit

Permalink
chore(deps)!: upgrade to Puppeteer v23.0.0
Browse files Browse the repository at this point in the history
Upgrade to Puppeteer v23 and drop support for previous Puppeteer
versions.

BREAKING CHANGE: The minimum supported version of Puppeteer is now v23.
BREAKING CHANGE: The `renderMermaid()` function now returns a
                 `Uint8Array` instead of a `Buffer`, as Puppeteer v23
                 now returns a `Uint8Array`.
  • Loading branch information
aloisklink committed Aug 26, 2024
1 parent 3e0a647 commit 25e5d11
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
"mermaid": "^11.0.2"
},
"peerDependencies": {
"puppeteer": "^19 || ^20 || ^21 || ^22"
"puppeteer": "^23"
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^6.5.2",
"@mermaid-js/layout-elk": "^0.1.2",
"@mermaid-js/mermaid-zenuml": "^0.2.0",
"@tsconfig/node18": "^18.2.4",
"@types/node": "~18.19.31",
"puppeteer": "^22.10.0",
"jest": "^29.0.1",
"puppeteer": "^23.1.1",
"standard": "^17.0.0",
"typescript": "^5.0.1-rc",
"vite": "^4.0.3",
Expand Down
10 changes: 5 additions & 5 deletions src-test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ async function compileDiagram (workflow, file, format, { puppeteerConfigFile } =
/**
* Confirms the filetype of the given bytes
*
* @param {Buffer} bytes - The bytes of the file to check
* @param {Uint8Array} bytes - The bytes of the file to check
* @param {"png"|"pdf"|"svg"} fileType - The filetype to check for
*/
function expectBytesAreFormat (bytes, fileType) {
switch (fileType) {
// see https://en.wikipedia.org/wiki/List_of_file_signatures
case 'png':
return expect(bytes.subarray(0, 8)).toEqual(Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]))
return expect(new Uint8Array(bytes).subarray(0, 8)).toEqual(Uint8Array.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]))
case 'pdf':
return expect(bytes.subarray(0, 5)).toEqual(Buffer.from('%PDF-', 'utf8'))
return expect(new Uint8Array(bytes).subarray(0, 5)).toEqual(Uint8Array.from(Buffer.from('%PDF-', 'utf8')))
case 'svg':
return expect(bytes.subarray(0, 4)).toEqual(Buffer.from('<svg', 'utf8'))
return expect(new Uint8Array(bytes).subarray(0, 4)).toEqual(Uint8Array.from(Buffer.from('<svg', 'utf8')))
default:
throw new Error('Unsupported filetype')
}
Expand Down Expand Up @@ -407,7 +407,7 @@ describe("NodeJS API (import ... from '@mermaid-js/mermaid-cli')", () => {
test('should return bytes from mmd', async () => {
const mmdInput = 'graph TD;\n nA-->B;\n'
const { data: bytes } = await renderMermaid(browser, mmdInput, 'svg')
expect(bytes).toBeInstanceOf(Buffer)
expect(bytes).toBeInstanceOf(Uint8Array)
expectBytesAreFormat(bytes, 'svg')
})

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async function cli () {
* @param {string} definition - Mermaid diagram definition
* @param {"svg" | "png" | "pdf"} outputFormat - Mermaid output format.
* @param {ParseMDDOptions} [opt] - Options, see {@link ParseMDDOptions} for details.
* @returns {Promise<{title: string | null, desc: string | null, data: Buffer}>} The output file in bytes,
* @returns {Promise<{title: string | null, desc: string | null, data: Uint8Array}>} The output file in bytes,
* with optional metadata.
*/
async function renderMermaid (browser, definition, outputFormat, { viewport, backgroundColor = 'white', mermaidConfig = {}, myCSS, pdfFit, svgId } = {}) {
Expand Down
52 changes: 30 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -962,12 +962,12 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@puppeteer/browsers@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.3.0.tgz#791ea7d80450fea24eb19fb1d70c367ad4e08cae"
integrity sha512-ioXoq9gPxkss4MYhD+SFaU9p1IHFUX0ILAWFPyjGaBdjLsYAlZw6j1iLA0N/m12uVHLFDfSYNF7EQccjinIMDA==
"@puppeteer/browsers@2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.3.1.tgz#238200dbdce5c00ae28c8f2a55ac053c3be71668"
integrity sha512-uK7o3hHkK+naEobMSJ+2ySYyXtQkBxIH8Gn4MK9ciePjNV+Pf+PgY/W7iPzn2MTjl3stcYB5AlcTmPYw7AXDwA==
dependencies:
debug "^4.3.5"
debug "^4.3.6"
extract-zip "^2.0.1"
progress "^2.0.3"
proxy-agent "^6.4.0"
Expand Down Expand Up @@ -1778,10 +1778,10 @@ chokidar@^3.5.3:
optionalDependencies:
fsevents "~2.3.2"

chromium-bidi@0.6.3:
version "0.6.3"
resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.6.3.tgz#363fe1ca6b9c6122b9f1b2a47f9449ecf712f755"
integrity sha512-qXlsCmpCZJAnoTYI83Iu6EdYQpMYdVkCfq08KDh2pmlVqK5t5IA9mGs4/LwCwp4fqisSOMXZxP3HIh8w8aRn0A==
chromium-bidi@0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.6.4.tgz#627d76bae2819d59b61a413babe9664e0a16b71d"
integrity sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==
dependencies:
mitt "3.0.1"
urlpattern-polyfill "10.0.0"
Expand Down Expand Up @@ -2340,7 +2340,7 @@ debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.3.4, debug@^4.3.5, debug@^4.3.6:
debug@^4.3.4, debug@^4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
Expand Down Expand Up @@ -4857,26 +4857,29 @@ punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz"

puppeteer-core@22.15.0:
version "22.15.0"
resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-22.15.0.tgz#c76926cce5dbc177572797a9dacc325c313fa91a"
integrity sha512-cHArnywCiAAVXa3t4GGL2vttNxh7GqXtIYGym99egkNJ3oG//wL9LkvO4WE8W1TJe95t1F1ocu9X4xWaGsOKOA==
puppeteer-core@23.1.1:
version "23.1.1"
resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-23.1.1.tgz#7e018c0c66faeb3e1df81d1012862bb8a5d7ce03"
integrity sha512-OeTqNiYGF9qZtwZU4Yc88DDqFJs4TJ4rnK81jkillh6MwDeQodyisM9xe5lBmPhwiDy92s5J5DQtQLjCKHFQ3g==
dependencies:
"@puppeteer/browsers" "2.3.0"
chromium-bidi "0.6.3"
"@puppeteer/browsers" "2.3.1"
chromium-bidi "0.6.4"
debug "^4.3.6"
devtools-protocol "0.0.1312386"
typed-query-selector "^2.12.0"
ws "^8.18.0"

puppeteer@^22.10.0:
version "22.15.0"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-22.15.0.tgz#4f842087090f1d9017ce947512e7baff55a10e75"
integrity sha512-XjCY1SiSEi1T7iSYuxS82ft85kwDJUS7wj1Z0eGVXKdtr5g4xnVcbjwxhq5xBnpK/E7x1VZZoJDxpjAOasHT4Q==
puppeteer@^23.1.1:
version "23.1.1"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-23.1.1.tgz#fedac19bed4a6ad6129463221732938cac60fb89"
integrity sha512-giN4Ikwl5hkkouH/dVyxIPTPslWuqZ8fjALdSw5Cvt+r0LuDpLdfPxRADlB75YJ2UjPZhgok+xYBYk8ffzv4MA==
dependencies:
"@puppeteer/browsers" "2.3.0"
"@puppeteer/browsers" "2.3.1"
chromium-bidi "0.6.4"
cosmiconfig "^9.0.0"
devtools-protocol "0.0.1312386"
puppeteer-core "22.15.0"
puppeteer-core "23.1.1"
typed-query-selector "^2.12.0"

pure-rand@^6.0.0:
version "6.0.1"
Expand Down Expand Up @@ -5582,6 +5585,11 @@ typed-array-length@^1.0.4:
for-each "^0.3.3"
is-typed-array "^1.1.9"

typed-query-selector@^2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.0.tgz#92b65dbc0a42655fccf4aeb1a08b1dddce8af5f2"
integrity sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==

typescript@^5.0.1-rc:
version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
Expand Down

0 comments on commit 25e5d11

Please sign in to comment.