Merge pull request #241 from Sparticuz/chromium/123

This commit is contained in:
Kyle McNally 2024-03-20 14:32:30 -04:00 committed by GitHub
commit 2c5dabf81b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 35 deletions

View File

@ -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.5 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.6 --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

View File

@ -50,8 +50,8 @@ const test = require("node:test");
const puppeteer = require("puppeteer-core");
const chromium = require("@sparticuz/chromium");
// 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.
// Optional: If you'd like to use the new headless mode. "shell" is the default.
// NOTE: Because we build the 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;
@ -260,8 +260,8 @@ By default, this package uses `swiftshader`/`angle` to do CPU acceleration for W
| `args` | `Array<string>` | 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<string>` | Returns the path the Chromium binary was extracted to. |
| `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 |
| `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"shell"` |
| `headless` | `true \| "shell"` | Returns `true` or `"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 |

View File

@ -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=1250580
chromium_revision=1262506

Binary file not shown.

Binary file not shown.

32
package-lock.json generated
View File

@ -9,17 +9,17 @@
"version": "122.0.0",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.5",
"follow-redirects": "^1.15.6",
"tar-fs": "^3.0.5"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@tsconfig/strictest": "^2.0.3",
"@types/follow-redirects": "^1.14.4",
"@types/node": "^20.11.19",
"@types/node": "^20.11.30",
"@types/tar-fs": "^2.0.4",
"clean-modules": "^3.0.4",
"typescript": "^5.3.3"
"clean-modules": "^3.0.5",
"typescript": "^5.4.2"
},
"engines": {
"node": ">= 16"
@ -47,9 +47,9 @@
}
},
"node_modules/@types/node": {
"version": "20.11.19",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz",
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==",
"version": "20.11.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
"integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@ -113,9 +113,9 @@
}
},
"node_modules/clean-modules": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.4.tgz",
"integrity": "sha512-UtidYdwZScv7TEmPuNBU1IDh2UrLH9FNYnhKYterm3jTtOGtSOa02J5aKHvnauqS/TKqJGPpC4bmuRDAXk61EQ==",
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.5.tgz",
"integrity": "sha512-gRW2hxNEE+xunuv/lkdPQ6UAqhs6CGoshLxOZ6eqy2ytkUAyzSoQ4fFj8/51jAfmJhrbuBGd/8hnvplIp8KRDg==",
"dev": true,
"dependencies": {
"clipanion": "^3.2.1",
@ -157,9 +157,9 @@
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
},
"node_modules/follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
@ -299,9 +299,9 @@
"dev": true
},
"node_modules/typescript": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",

View File

@ -36,17 +36,17 @@
"test": "make clean && make && make pretest && make test"
},
"dependencies": {
"follow-redirects": "^1.15.5",
"follow-redirects": "^1.15.6",
"tar-fs": "^3.0.5"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@tsconfig/strictest": "^2.0.3",
"@types/follow-redirects": "^1.14.4",
"@types/node": "^20.11.19",
"@types/node": "^20.11.30",
"@types/tar-fs": "^2.0.4",
"clean-modules": "^3.0.4",
"typescript": "^5.3.3"
"clean-modules": "^3.0.5",
"typescript": "^5.4.2"
},
"engines": {
"node": ">= 16"

View File

@ -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 | "chrome-headless-shell" = "chrome-headless-shell";
private static headlessMode: true | "shell" = "shell";
/**
* If true, the graphics stack and webgl is enabled,
@ -254,7 +254,7 @@ class Chromium {
];
const headlessFlags = [
this.headless === "chrome-headless-shell" ? "--headless='chrome-headless-shell'" : "--headless",
this.headless === "shell" ? "--headless='shell'" : "--headless",
];
return [
@ -349,10 +349,10 @@ class Chromium {
/**
* Returns the headless mode.
* "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode.
* "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 | "chrome-headless-shell"
* @returns true | "shell"
*/
public static get headless() {
return this.headlessMode;
@ -360,18 +360,18 @@ class Chromium {
/**
* Sets the headless mode.
* "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode.
* "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 "chrome-headless-shell"
* @default "shell"
*/
public static set setHeadlessMode(value: true | "chrome-headless-shell") {
public static set setHeadlessMode(value: true | "shell") {
if (
(typeof value === "string" && value !== "chrome-headless-shell") ||
(typeof value === "string" && value !== "shell") ||
(typeof value === "boolean" && value !== true)
) {
throw new Error(
`Headless mode must be either \`true\` or 'chrome-headless-shell', you entered '${value}'`
`Headless mode must be either \`true\` or 'shell', you entered '${value}'`
);
}
this.headlessMode = value;