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 install --fund=false --package-lock=false
npm run build npm run build
mkdir -p nodejs 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 npm pack
mkdir -p nodejs/node_modules/@sparticuz/chromium/ mkdir -p nodejs/node_modules/@sparticuz/chromium/
tar --directory nodejs/node_modules/@sparticuz/chromium/ --extract --file sparticuz-chromium-*.tgz --strip-components=1 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 puppeteer = require("puppeteer-core");
const chromium = require("@sparticuz/chromium"); const chromium = require("@sparticuz/chromium");
// Optional: If you'd like to use the new headless mode. "chrome-headless-shell" is the default. // Optional: If you'd like to use the new headless mode. "shell" is the default.
// NOTE: Because we build the chrome-headless-shell binary, this option does not work. // 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. // However, this option will stay so when we migrate to full chromium it will work.
chromium.setHeadlessMode = true; 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). | | `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. | | `defaultViewport` | `Object` | Returns a sensible default viewport for serverless. |
| `executablePath(location?: string)` | `Promise<string>` | Returns the path the Chromium binary was extracted to. | | `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"` | | `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"shell"` |
| `headless` | `true \| "chrome-headless-shell"` | Returns `true` or `"chrome-headless-shell"` depending on what version of chrome's headless you are running | | `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` | | `setGraphicsMode` | `void` | Sets the graphics mode to either `true` or `false` |
| `graphics` | `boolean` | Returns a boolean depending on whether webgl is enabled or disabled | | `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_connection=ssh
ansible_python_interpreter=auto_silent ansible_python_interpreter=auto_silent
ansible_ssh_private_key_file=ansible.pem 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", "version": "122.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.5", "follow-redirects": "^1.15.6",
"tar-fs": "^3.0.5" "tar-fs": "^3.0.5"
}, },
"devDependencies": { "devDependencies": {
"@tsconfig/node16": "^16.1.1", "@tsconfig/node16": "^16.1.1",
"@tsconfig/strictest": "^2.0.3", "@tsconfig/strictest": "^2.0.3",
"@types/follow-redirects": "^1.14.4", "@types/follow-redirects": "^1.14.4",
"@types/node": "^20.11.19", "@types/node": "^20.11.30",
"@types/tar-fs": "^2.0.4", "@types/tar-fs": "^2.0.4",
"clean-modules": "^3.0.4", "clean-modules": "^3.0.5",
"typescript": "^5.3.3" "typescript": "^5.4.2"
}, },
"engines": { "engines": {
"node": ">= 16" "node": ">= 16"
@ -47,9 +47,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.11.19", "version": "20.11.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
@ -113,9 +113,9 @@
} }
}, },
"node_modules/clean-modules": { "node_modules/clean-modules": {
"version": "3.0.4", "version": "3.0.5",
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.4.tgz", "resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.5.tgz",
"integrity": "sha512-UtidYdwZScv7TEmPuNBU1IDh2UrLH9FNYnhKYterm3jTtOGtSOa02J5aKHvnauqS/TKqJGPpC4bmuRDAXk61EQ==", "integrity": "sha512-gRW2hxNEE+xunuv/lkdPQ6UAqhs6CGoshLxOZ6eqy2ytkUAyzSoQ4fFj8/51jAfmJhrbuBGd/8hnvplIp8KRDg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"clipanion": "^3.2.1", "clipanion": "^3.2.1",
@ -157,9 +157,9 @@
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw==" "integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
}, },
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.15.5", "version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@ -299,9 +299,9 @@
"dev": true "dev": true
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.3.3", "version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",

View File

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

View File

@ -93,7 +93,7 @@ class Chromium {
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
* @values true or "new" * @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, * If true, the graphics stack and webgl is enabled,
@ -254,7 +254,7 @@ class Chromium {
]; ];
const headlessFlags = [ const headlessFlags = [
this.headless === "chrome-headless-shell" ? "--headless='chrome-headless-shell'" : "--headless", this.headless === "shell" ? "--headless='shell'" : "--headless",
]; ];
return [ return [
@ -349,10 +349,10 @@ class Chromium {
/** /**
* Returns the headless mode. * 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. * `true` means the 'new' headless mode.
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
* @returns true | "chrome-headless-shell" * @returns true | "shell"
*/ */
public static get headless() { public static get headless() {
return this.headlessMode; return this.headlessMode;
@ -360,18 +360,18 @@ class Chromium {
/** /**
* Sets the headless mode. * 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. * `true` means the 'new' headless mode.
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * 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 ( if (
(typeof value === "string" && value !== "chrome-headless-shell") || (typeof value === "string" && value !== "shell") ||
(typeof value === "boolean" && value !== true) (typeof value === "boolean" && value !== true)
) { ) {
throw new Error( 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; this.headlessMode = value;