feat(env-utils): add getCpuArch

This commit is contained in:
Jiri Zbytovsky
2025-03-31 20:37:07 +02:00
committed by Jiri Zbytovsky
parent 1973c02f62
commit b3deeb546b
4 changed files with 15 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ const getDeviceType = () => '';
const getOsVersion = () => Promise.resolve(`${Platform.Version}`);
const getDeprecatedOsVersion = () => `${Platform.Version}`;
const getCpuArch = () => Promise.resolve('');
const getSuiteVersion = () => Constants.expoConfig?.version || '';
const getCommitHash = () => Constants.expoConfig?.extra?.commitHash;
@@ -94,6 +96,7 @@ export const envUtils: EnvUtils = {
getDeviceType,
getOsVersion,
getDeprecatedOsVersion,
getCpuArch,
getSuiteVersion,
isFirefox,
getPlatform,

View File

@@ -50,6 +50,15 @@ const getOsVersion = async () => {
/** @deprecated: Use the async getOsVersion instead. */
const getDeprecatedOsVersion = () => getUserAgentParser().getOS().version || '';
/**
* Similar to `getOsVersion`. Here, the sync fn works everywhere but macOS, hence we use async.
*/
const getCpuArch = async () => {
const { architecture } = await getUserAgentParser().getCPU().withClientHints();
return architecture ?? '';
};
const getSuiteVersion = () => process.env.VERSION || '';
const getBrowserName = () => {
@@ -147,6 +156,7 @@ export const envUtils: EnvUtils = {
isChromeOs,
getOsVersion,
getDeprecatedOsVersion,
getCpuArch,
getBrowserName,
getBrowserVersion,
getCommitHash,

View File

@@ -16,6 +16,7 @@ export const {
getDeviceType,
getOsVersion,
getDeprecatedOsVersion,
getCpuArch,
getSuiteVersion,
isFirefox,
getPlatform,

View File

@@ -14,6 +14,7 @@ export interface EnvUtils {
getDeviceType: () => string | undefined;
getOsVersion: () => Promise<string>;
getDeprecatedOsVersion: () => string;
getCpuArch: () => Promise<string>;
getSuiteVersion: () => string;
isFirefox: () => boolean;
getPlatform: () => string;