Skip to content

Commit

Permalink
Merge pull request #241 from Sparticuz/chromium/123
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz committed Mar 20, 2024
2 parents 8efe5f9 + c0b12ce commit 2c5dabf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 |

Expand Down
2 changes: 1 addition & 1 deletion _/ansible/inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 modified bin/chromium.br
Binary file not shown.
Binary file modified bin/swiftshader.tar.br
Binary file not shown.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 [
Expand Down Expand Up @@ -349,29 +349,29 @@ 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;
}

/**
* 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;
Expand Down

0 comments on commit 2c5dabf

Please sign in to comment.