From 0c1351f01b021d961e5bbf497350247f679db2df Mon Sep 17 00:00:00 2001 From: Sparticuz Date: Mon, 27 Mar 2023 09:24:08 -0400 Subject: [PATCH] Refactor headless mode now uses getter and setter --- source/index.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/index.ts b/source/index.ts index b2dd265..1eca617 100644 --- a/source/index.ts +++ b/source/index.ts @@ -64,7 +64,7 @@ class Chromium { * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless * @values true or "new" */ - static headlessMode: true | "new" = "new"; + private static headlessMode: true | "new" = "new"; /** * If true, the graphics stack and webgl is enabled, @@ -222,7 +222,7 @@ class Chromium { ]; const headlessFlags = [ - this.headlessMode === "new" ? "--headless='new'" : "--headless", + this.headless === "new" ? "--headless='new'" : "--headless", ]; return [ @@ -300,9 +300,27 @@ class Chromium { return result.shift() as string; } - static get headless() { + /** + * Returns the headless mode. + * `true` means the 'old' (legacy, chromium < 112) headless mode. + * "new" means the 'new' headless mode. + * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless + * @returns true | "new" + */ + public static get headless() { return this.headlessMode; } + + /** + * Sets the headless mode. + * `true` means the 'old' (legacy, chromium < 112) headless mode. + * "new" means the 'new' headless mode. + * https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless + * @default "new" + */ + public static set setHeadlessMode(value: true | "new") { + this.headlessMode = value; + } } export = Chromium;