Open History to see the last commit
1import type { DesktopRuntimeArch, DesktopRuntimeInfo } from "@t3tools/contracts";
2
3interface ResolveDesktopRuntimeInfoInput {
4 readonly platform: NodeJS.Platform;
5 readonly processArch: string;
6 readonly runningUnderArm64Translation: boolean;
7}
8
9function normalizeDesktopArch(arch: string): DesktopRuntimeArch {
10 if (arch === "arm64") return "arm64";
11 if (arch === "x64") return "x64";
12 return "other";
13}
14
15export function resolveDesktopRuntimeInfo(
16 input: ResolveDesktopRuntimeInfoInput,
17): DesktopRuntimeInfo {
18 const appArch = normalizeDesktopArch(input.processArch);
19
20 if (input.platform !== "darwin") {
21 return {
22 hostArch: appArch,
23 appArch,
24 runningUnderArm64Translation: false,
25 };
26 }
27
28 const hostArch = appArch === "arm64" || input.runningUnderArm64Translation ? "arm64" : appArch;
29
30 return {
31 hostArch,
32 appArch,
33 runningUnderArm64Translation: input.runningUnderArm64Translation,
34 };
35}
36
37export function isArm64HostRunningIntelBuild(runtimeInfo: DesktopRuntimeInfo): boolean {
38 return runtimeInfo.hostArch === "arm64" && runtimeInfo.appArch === "x64";
39}