diff --git a/Makefile b/Makefile index 303db64..e75c6e7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ test: npm install --fund=false --package-lock=false npm run build mkdir -p nodejs - npm install --prefix nodejs/ tar-fs@3.0.4 follow-redirects@1.15.5 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false + npm install --prefix nodejs/ tar-fs@3.0.5 follow-redirects@1.15.5 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false npm pack mkdir -p nodejs/node_modules/@sparticuz/chromium/ tar --directory nodejs/node_modules/@sparticuz/chromium/ --extract --file sparticuz-chromium-*.tgz --strip-components=1 diff --git a/README.md b/README.md index 37c9659..0df98ac 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ const test = require("node:test"); const puppeteer = require("puppeteer-core"); const chromium = require("@sparticuz/chromium"); -// Optional: If you'd like to use the legacy headless mode. "new" is the default. +// Optional: If you'd like to use the new headless mode. "chrome-headless-shell" is the default. +// NOTE: Because we build the chrome-headless-shell binary, this option does not work. +// However, this option will stay so when we migrate to full chromium it will work. chromium.setHeadlessMode = true; // Optional: If you'd like to disable webgl, true is the default. @@ -163,7 +165,7 @@ Here are some example projects and help with other services ### Running Locally & Headless/Headful mode -This version of `chromium` is built using the `headless.gn` build variables, which does not appear to even include a GUI. [Also, at this point, AWS Lambda 2 does not support a modern version of `glibc`](https://github.com/aws/aws-lambda-base-images/issues/59), so this package does not include an ARM version yet, which means it will not work on any M Series Apple products. If you need to test your code using a headful or ARM version, please use your locally installed version of `chromium/chrome`, or you may use the `puppeteer` provided version. +This version of `chromium` is built using the `headless.gn` build variables, which does not appear to even include a GUI. [Also, at this point, AWS Lambda 2 does not support a modern version of `glibc`](https://github.com/aws/aws-lambda-base-images/issues/59), so this package does not include an ARM version yet, which means it will not work on any M Series Apple products. If you need to test your code using a headful or ARM version, please use your locally installed version of `chromium/chrome`, or you may use the `puppeteer` provided version. Users have reported installing `rosetta` on MacOS will also work. ```shell npx @puppeteer/browsers install chromium@latest --path /tmp/localChromium @@ -258,8 +260,8 @@ By default, this package uses `swiftshader`/`angle` to do CPU acceleration for W | `args` | `Array` | Provides a list of recommended additional [Chromium flags](https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md). | | `defaultViewport` | `Object` | Returns a sensible default viewport for serverless. | | `executablePath(location?: string)` | `Promise` | Returns the path the Chromium binary was extracted to. | -| `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"new"` | -| `headless` | `true \| "new"` | Returns `true` or `"new"` depending on what version of chrome's headless you are running | +| `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"chrome-headless-shell"` | +| `headless` | `true \| "chrome-headless-shell"` | Returns `true` or `"chrome-headless-shell"` depending on what version of chrome's headless you are running | | `setGraphicsMode` | `void` | Sets the graphics mode to either `true` or `false` | | `graphics` | `boolean` | Returns a boolean depending on whether webgl is enabled or disabled | diff --git a/_/amazon/events/example.com.json b/_/amazon/events/example.com.json index b12afd7..3420325 100644 --- a/_/amazon/events/example.com.json +++ b/_/amazon/events/example.com.json @@ -3,21 +3,14 @@ "url": "https://example.com", "expected": { "title": "Example Domain", - "screenshot": "3f1863ac017614ce6a389cf719da28b774595abe" - } - }, - { - "url": "https://example.com", - "expected": { - "title": "Example Domain", - "screenshot": "3f1863ac017614ce6a389cf719da28b774595abe" + "screenshot": "835f3ccc8fdbcb3a4a067666f1e9648e9e513570" } }, { "url": "https://get.webgl.org", "expected": { "remove": "logo-container", - "screenshot": "bf35ed6405670c506b549906f6b467421bc8b430" + "screenshot": "7b4110af7294ae55452d636dd8e900574b21ea2d" } } ] diff --git a/_/amazon/handlers/index.js b/_/amazon/handlers/index.js index 46c065f..f6a5124 100644 --- a/_/amazon/handlers/index.js +++ b/_/amazon/handlers/index.js @@ -21,7 +21,7 @@ exports.handler = async (event, context) => { const contexts = [browser.defaultBrowserContext()]; while (contexts.length < event.length) { - contexts.push(await browser.createIncognitoBrowserContext()); + contexts.push(await browser.createBrowserContext()); } for (let context of contexts) { diff --git a/_/ansible/inventory.ini b/_/ansible/inventory.ini index f479d1f..7760bee 100644 --- a/_/ansible/inventory.ini +++ b/_/ansible/inventory.ini @@ -14,4 +14,4 @@ instance_size=c6i.12xlarge ansible_connection=ssh ansible_python_interpreter=auto_silent ansible_ssh_private_key_file=ansible.pem -chromium_revision=1233107 +chromium_revision=1250580 diff --git a/bin/chromium.br b/bin/chromium.br old mode 100755 new mode 100644 index 3f3120a..c0457a2 Binary files a/bin/chromium.br and b/bin/chromium.br differ diff --git a/bin/swiftshader.tar.br b/bin/swiftshader.tar.br index a2bf23f..e19369b 100644 Binary files a/bin/swiftshader.tar.br and b/bin/swiftshader.tar.br differ diff --git a/package-lock.json b/package-lock.json index ad519a1..2555df1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,13 +10,13 @@ "license": "MIT", "dependencies": { "follow-redirects": "^1.15.5", - "tar-fs": "^3.0.4" + "tar-fs": "^3.0.5" }, "devDependencies": { "@tsconfig/node16": "^16.1.1", - "@tsconfig/strictest": "^2.0.2", + "@tsconfig/strictest": "^2.0.3", "@types/follow-redirects": "^1.14.4", - "@types/node": "^20.11.10", + "@types/node": "^20.11.19", "@types/tar-fs": "^2.0.4", "clean-modules": "^3.0.4", "typescript": "^5.3.3" @@ -32,9 +32,9 @@ "dev": true }, "node_modules/@tsconfig/strictest": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.2.tgz", - "integrity": "sha512-jt4jIsWKvUvuY6adJnQJlb/UR7DdjC8CjHI/OaSQruj2yX9/K6+KOvDt/vD6udqos/FUk5Op66CvYT7TBLYO5Q==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.3.tgz", + "integrity": "sha512-MroLvRhMbqtXI5WBSwoomro6OQS4xnCoudUrMb20JO0vLKUs0bAaCEcvM/immEBSJjFAK1l6jW1oAO8q3Ancrg==", "dev": true }, "node_modules/@types/follow-redirects": { @@ -47,9 +47,9 @@ } }, "node_modules/@types/node": { - "version": "20.11.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.10.tgz", - "integrity": "sha512-rZEfe/hJSGYmdfX9tvcPMYeYPW2sNl50nsw4jZmRcaG0HIAb0WYEpsB05GOb53vjqpyE9GUhlDQ4jLSoB5q9kg==", + "version": "20.11.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", + "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -79,6 +79,39 @@ "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz", "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==" }, + "node_modules/bare-events": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.2.0.tgz", + "integrity": "sha512-Yyyqff4PIFfSuthCZqLlPISTWHmnQxoPuAvkmgzsJEmG3CesdIv6Xweayl0JkCZJSB2yYIdJyEz97tpxNhgjbg==", + "optional": true + }, + "node_modules/bare-fs": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.1.5.tgz", + "integrity": "sha512-5t0nlecX+N2uJqdxe9d18A98cp2u9BETelbjKpiVgQqzzmVNFYWEAjQHqS+2Khgto1vcwhik9cXucaj5ve2WWA==", + "optional": true, + "dependencies": { + "bare-events": "^2.0.0", + "bare-os": "^2.0.0", + "bare-path": "^2.0.0", + "streamx": "^2.13.0" + } + }, + "node_modules/bare-os": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.2.0.tgz", + "integrity": "sha512-hD0rOPfYWOMpVirTACt4/nK8mC55La12K5fY1ij8HAdfQakD62M+H4o4tpfKzVGLgRDTuk3vjA4GqGXXCeFbag==", + "optional": true + }, + "node_modules/bare-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-2.1.0.tgz", + "integrity": "sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==", + "optional": true, + "dependencies": { + "bare-os": "^2.1.0" + } + }, "node_modules/clean-modules": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.4.tgz", @@ -142,11 +175,6 @@ } } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -242,13 +270,16 @@ } }, "node_modules/tar-fs": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz", - "integrity": "sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.5.tgz", + "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "dependencies": { - "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^3.1.5" + }, + "optionalDependencies": { + "bare-fs": "^2.1.1", + "bare-path": "^2.1.0" } }, "node_modules/tar-stream": { diff --git a/package.json b/package.json index c27c56e..dda423d 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,13 @@ }, "dependencies": { "follow-redirects": "^1.15.5", - "tar-fs": "^3.0.4" + "tar-fs": "^3.0.5" }, "devDependencies": { "@tsconfig/node16": "^16.1.1", - "@tsconfig/strictest": "^2.0.2", + "@tsconfig/strictest": "^2.0.3", "@types/follow-redirects": "^1.14.4", - "@types/node": "^20.11.10", + "@types/node": "^20.11.19", "@types/tar-fs": "^2.0.4", "clean-modules": "^3.0.4", "typescript": "^5.3.3" diff --git a/source/index.ts b/source/index.ts index 522cbbe..569f030 100644 --- a/source/index.ts +++ b/source/index.ts @@ -93,7 +93,7 @@ class Chromium { * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * @values true or "new" */ - private static headlessMode: true | "new" = "new"; + private static headlessMode: true | "chrome-headless-shell" = "chrome-headless-shell"; /** * If true, the graphics stack and webgl is enabled, @@ -223,6 +223,7 @@ class Chromium { "--no-default-browser-check", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoDefaultBrowserCheck&ss=chromium "--no-pings", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoPings&ss=chromium "--single-process", // Needs to be single-process to avoid `prctl(PR_SET_NO_NEW_PRIVS) failed` error + "--font-render-hinting=none", // https://github.com/puppeteer/puppeteer/issues/2410#issuecomment-560573612 ]; const chromiumDisableFeatures = [ "AudioServiceOutOfProcess", @@ -253,7 +254,7 @@ class Chromium { ]; const headlessFlags = [ - this.headless === "new" ? "--headless='new'" : "--headless", + this.headless === "chrome-headless-shell" ? "--headless='chrome-headless-shell'" : "--headless", ]; return [ @@ -348,10 +349,10 @@ class Chromium { /** * Returns the headless mode. - * `true` means the 'old' (legacy, chromium < 112) headless mode. - * "new" means the 'new' headless mode. + * "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode. + * `true` means the 'new' headless mode. * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless - * @returns true | "new" + * @returns true | "chrome-headless-shell" */ public static get headless() { return this.headlessMode; @@ -359,18 +360,18 @@ class Chromium { /** * Sets the headless mode. - * `true` means the 'old' (legacy, chromium < 112) headless mode. - * "new" means the 'new' headless mode. + * "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode. + * `true` means the 'new' headless mode. * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless - * @default "new" + * @default "chrome-headless-shell" */ - public static set setHeadlessMode(value: true | "new") { + public static set setHeadlessMode(value: true | "chrome-headless-shell") { if ( - (typeof value === "string" && value !== "new") || + (typeof value === "string" && value !== "chrome-headless-shell") || (typeof value === "boolean" && value !== true) ) { throw new Error( - `Headless mode must be either \`true\` or 'new', you entered '${value}'` + `Headless mode must be either \`true\` or 'chrome-headless-shell', you entered '${value}'` ); } this.headlessMode = value;