From 5a6d38a53f05da6e2694a3d735890112e5edef4e Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Mon, 8 Dec 2025 17:39:24 +0100 Subject: [PATCH] Tauri: Correctly detect UA on macOS (#6506) --- package-lock.json | 8 ++++++++ package.json | 1 + src/@types/global.d.ts | 2 ++ src/util/browser/windowEnvironment.ts | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 31238810d..c5bf007b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -108,6 +108,7 @@ "tsx": "^4.20.6", "typescript": "5.9.3", "typescript-eslint": "^8.46.4", + "user-agent-data-types": "^0.4.2", "webpack": "^5.102.1", "webpack-dev-server": "^5.2.2" }, @@ -20413,6 +20414,13 @@ "punycode": "^2.1.0" } }, + "node_modules/user-agent-data-types": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/user-agent-data-types/-/user-agent-data-types-0.4.2.tgz", + "integrity": "sha512-jXep3kO/dGNmDOkbDa8ccp4QArgxR4I76m3QVcJ1aOF0B9toc+YtSXtX5gLdDTZXyWlpQYQrABr6L1L2GZOghw==", + "dev": true, + "license": "MIT" + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 176307638..54c1e6b0e 100644 --- a/package.json +++ b/package.json @@ -120,6 +120,7 @@ "tsx": "^4.20.6", "typescript": "5.9.3", "typescript-eslint": "^8.46.4", + "user-agent-data-types": "^0.4.2", "webpack": "^5.102.1", "webpack-dev-server": "^5.2.2" }, diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index c112952cb..5dd1ab7a0 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -1,3 +1,5 @@ +/// + declare const process: NodeJS.Process; declare module '*.module.scss'; diff --git a/src/util/browser/windowEnvironment.ts b/src/util/browser/windowEnvironment.ts index 5e3a4ee87..80711abf3 100644 --- a/src/util/browser/windowEnvironment.ts +++ b/src/util/browser/windowEnvironment.ts @@ -32,7 +32,9 @@ export const IS_LINUX = PLATFORM_ENV === 'Linux'; export const IS_IOS = PLATFORM_ENV === 'iOS'; export const IS_ANDROID = PLATFORM_ENV === 'Android'; export const IS_MOBILE = IS_IOS || IS_ANDROID; -export const IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); +export const IS_CHROMIUM = navigator.userAgentData?.brands.some((data) => data.brand === 'Chromium') + || /Chrom(e|ium)\//.test(navigator.userAgent); +export const IS_SAFARI = !IS_CHROMIUM && /applewebkit/i.test(navigator.userAgent); export const IS_YA_BROWSER = navigator.userAgent.includes('YaBrowser'); export const IS_FIREFOX = navigator.userAgent.toLowerCase().includes('firefox') || navigator.userAgent.toLowerCase().includes('iceweasel')