From ce553320d82872f8aa4565420a0de4eb2f7957ae Mon Sep 17 00:00:00 2001 From: Kyle McNally Date: Wed, 20 Mar 2024 14:23:39 -0400 Subject: [PATCH] Fix types --- README.md | 8 ++++---- source/index.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0df98ac..762d902 100644 --- a/README.md +++ b/README.md @@ -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` | 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 `"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 | diff --git a/source/index.ts b/source/index.ts index 569f030..a420692 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 | "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;