in src/components/App.ts [16:61]
function osVersionName(os: string): ((version: string) => string | undefined) | undefined {
function windows_nt_10_label(version: string): string {
const [_ntversion, build] = version.split("@", 1);
if (parseInt(build) >= 22000) {
return 'Windows 11';
}
else {
return 'Windows 10';
}
}
const OS_VERSION_NAMES: { [key: string]: { [prefix: string]: string | ((version: string) => string) } } = {
"Mac": {
"19.": 'macOS 10.15 "Catalina"',
"20.": 'macOS 11 "Big Sur"',
"21.": 'macOS 12 "Monterey"',
"22.": 'macOS 13 "Ventura"',
"23.": 'macOS 14 "Sonoma"',
"24.": 'macOS 15 "Sequoia"',
},
"Windows": {
"5.1": 'Windows XP',
"5.2": 'Windows XP',
"6.0": 'Windows Vista',
"6.1": 'Windows 7',
"6.2": 'Windows 8',
"6.3": 'Windows 8.1',
"10.0": windows_nt_10_label
},
};
if (os in OS_VERSION_NAMES) {
const names = Object.entries(OS_VERSION_NAMES[os]);
return (version: string) => {
const match = names.find(([k, _]) => version.startsWith(k));
if (match) {
const name = match[1];
if (typeof name == "string") {
return name;
} else {
return name(version);
}
}
};
}
}