fix: review fixes — bump CHROMIUM_VERSION to v145, add colorScheme to JS, guard download fallback

This commit is contained in:
CloakHQ
2026-03-02 02:59:23 +01:00
parent f417fe2530
commit 8eb666885f
7 changed files with 14 additions and 6 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ Usage:
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any from typing import Any, Literal
from urllib.parse import unquote, urlparse, urlunparse from urllib.parse import unquote, urlparse, urlunparse
from .config import DEFAULT_VIEWPORT, get_default_stealth_args from .config import DEFAULT_VIEWPORT, get_default_stealth_args
@@ -168,7 +168,7 @@ def launch_context(
viewport: dict | None = None, viewport: dict | None = None,
locale: str | None = None, locale: str | None = None,
timezone_id: str | None = None, timezone_id: str | None = None,
color_scheme: str | None = None, color_scheme: Literal["light", "dark", "no-preference"] | None = None,
geoip: bool = False, geoip: bool = False,
**kwargs: Any, **kwargs: Any,
) -> Any: ) -> Any:
+1 -1
View File
@@ -12,7 +12,7 @@ from ._version import __version__
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Chromium version shipped with this release # Chromium version shipped with this release
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
CHROMIUM_VERSION = "142.0.7444.175" CHROMIUM_VERSION = "145.0.7632.109"
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Default stealth arguments passed to the patched Chromium binary. # Default stealth arguments passed to the patched Chromium binary.
+3 -1
View File
@@ -121,10 +121,12 @@ def _download_and_extract(version: str | None = None) -> None:
tmp_path = Path(tmp.name) tmp_path = Path(tmp.name)
try: try:
# Try primary, fall back to GitHub Releases # Try primary, fall back to GitHub Releases (skip fallback if custom URL)
try: try:
_download_file(primary_url, tmp_path) _download_file(primary_url, tmp_path)
except Exception as primary_err: except Exception as primary_err:
if os.environ.get("CLOAKBROWSER_DOWNLOAD_URL"):
raise
logger.warning( logger.warning(
"Primary download failed (%s), trying GitHub Releases...", "Primary download failed (%s), trying GitHub Releases...",
primary_err, primary_err,
+1 -1
View File
@@ -10,7 +10,7 @@ import path from "node:path";
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Chromium version shipped with this release // Chromium version shipped with this release
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
export const CHROMIUM_VERSION = "142.0.7444.175"; export const CHROMIUM_VERSION = "145.0.7632.109";
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Platform detection // Platform detection
+4 -1
View File
@@ -151,10 +151,13 @@ async function downloadAndExtract(version?: string): Promise<void> {
); );
try { try {
// Try primary server, fall back to GitHub Releases // Try primary server, fall back to GitHub Releases (skip fallback if custom URL)
try { try {
await downloadFile(primaryUrl, tmpPath); await downloadFile(primaryUrl, tmpPath);
} catch (primaryErr) { } catch (primaryErr) {
if (process.env.CLOAKBROWSER_DOWNLOAD_URL) {
throw primaryErr;
}
console.warn( console.warn(
`[cloakbrowser] Primary download failed (${primaryErr instanceof Error ? primaryErr.message : primaryErr}), trying GitHub Releases...` `[cloakbrowser] Primary download failed (${primaryErr instanceof Error ? primaryErr.message : primaryErr}), trying GitHub Releases...`
); );
+1
View File
@@ -71,6 +71,7 @@ export async function launchContext(
viewport: options.viewport ?? DEFAULT_VIEWPORT, viewport: options.viewport ?? DEFAULT_VIEWPORT,
...(resolved.locale ? { locale: resolved.locale } : {}), ...(resolved.locale ? { locale: resolved.locale } : {}),
...(resolved.timezone ? { timezoneId: resolved.timezone } : {}), ...(resolved.timezone ? { timezoneId: resolved.timezone } : {}),
...(options.colorScheme ? { colorScheme: options.colorScheme } : {}),
}); });
} catch (err) { } catch (err) {
await browser.close(); await browser.close();
+2
View File
@@ -30,6 +30,8 @@ export interface LaunchContextOptions extends LaunchOptions {
locale?: string; locale?: string;
/** Timezone, e.g. "America/New_York". */ /** Timezone, e.g. "America/New_York". */
timezoneId?: string; timezoneId?: string;
/** Color scheme preference — 'light', 'dark', or 'no-preference'. */
colorScheme?: "light" | "dark" | "no-preference";
} }
export interface BinaryInfo { export interface BinaryInfo {