@@ -529,16 +529,20 @@ var property = null;
529
529
// returns an ordering for the platform names, an array of regexps
530
530
// note that the entries are sorted in a good order, so return an order
531
531
// that only brings the locally desired entries to the top
532
- function getPlatformOrder() {
532
+ function getPlatformOrder(ua ) {
533
533
var p = navigator.platform;
534
534
var p2 = navigator.appVersion;
535
535
var p3 = navigator.userAgent;
536
536
function l(str) {
537
537
return (p.indexOf(str) != -1 ) || (p2.indexOf(str) != -1 ) || (p3.indexOf(str) != -1 );
538
538
}
539
+ function is_win_arm64() {
540
+ return (ua && ua.platform == 'Windows ' && ua.architecture === 'arm ' && ua.bitness === '64 ');
541
+ }
539
542
var Win = /Windows/,
540
- Win64 = /Windows.*64 /,
543
+ Win64 = /Windows.*x64 /,
541
544
Win32 = /Windows.*32/,
545
+ WinArm64 = /Windows.*Arm/,
542
546
Mac = /Mac/,
543
547
MacIntel = /Mac.*Intel/,
544
548
MacIntel64 = /Mac.*Intel.*64/,
@@ -551,9 +555,10 @@ var property = null;
551
555
Unix = /Unix/,
552
556
Solaris = /Solaris/;
553
557
if (p == null) return [];
558
+ else if (is_win_arm64()) return [WinArm64, Win64, Win];
554
559
else if (l("SunOS " )) return [Solaris, Unix];
555
- else if (l("Win64 " )) return [Win64, Win];
556
- else if (l("WOW64 " )) return [Win64, Win];
560
+ else if (l("Win64 " )) return [Win64, WinArm64, Win];
561
+ else if (l("WOW64 " )) return [Win64, WinArm64, Win];
557
562
else if (l("Win " )) return [Win32, Win];
558
563
else if (l("Mac " )) return [
559
564
l("Intel " ) ? MacARM64 : MacPPC,
@@ -566,10 +571,10 @@ var property = null;
566
571
else return [];
567
572
}
568
573
569
- function orderPlatform(platforms) {
574
+ function orderPlatform(platforms, ua ) {
570
575
var len = platforms.length;
571
576
// get the order and a make a sorting function
572
- var order = getPlatformOrder();
577
+ var order = getPlatformOrder(ua );
573
578
function getOrder(str) {
574
579
for (var i = 0 ; i < order.length; i++)
575
580
if (str.search(order[i]) >= 0 ) return i;
@@ -598,9 +603,11 @@ var property = null;
598
603
});
599
604
}
600
605
601
- forEach(allInstallers, function (dist) {
602
- orderPlatform(dist.installers);
603
- });
606
+ function orderAllPlatforms(ua) {
607
+ forEach(allInstallers, function (dist) {
608
+ orderPlatform(dist.installers, ua);
609
+ });
610
+ }
604
611
605
612
function getAllPlatforms(allInstallers, currentDist) {
606
613
return filter(allInstallers, function (group) {
@@ -718,7 +725,8 @@ var property = null;
718
725
return elem('div ', {}, children);
719
726
}
720
727
721
- function init () {
728
+ function init (ua) {
729
+ orderAllPlatforms(ua)
722
730
var currentDist = initialDist;
723
731
var allPlatforms = getAllPlatforms(allInstallers, currentDist);
724
732
var currentPlatform = allPlatforms[0 ].platform;
@@ -731,7 +739,11 @@ var property = null;
731
739
}, toDraw);
732
740
}
733
741
734
- init ();
742
+ if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
743
+ navigator.userAgentData.getHighEntropyValues(["architecture " , "bitness " ])
744
+ .then(ua => { init (ua) })
745
+ } else
746
+ init (false )
735
747
736
748
function showWhen(e, b) {
737
749
document.getElementById(e).style.display = b ? 'block ' : 'none ';
0 commit comments