Skip to content

Commit 60ca95b

Browse files
authored
Introduce chromium for MacOS arm64 downloads (#2256)
1 parent fdcaed6 commit 60ca95b

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

lib/PuppeteerSharp/BrowserFetcher.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class BrowserFetcher : IBrowserFetcher
2727

2828
private const string PublishSingleFileLocalApplicationDataFolderName = "PuppeteerSharp";
2929

30-
private static readonly Dictionary<Product, string> _hosts = new Dictionary<Product, string>
30+
private static readonly Dictionary<Product, string> _hosts = new()
3131
{
3232
[Product.Chrome] = "https://storage.googleapis.com",
3333
[Product.Firefox] = "https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central",
@@ -37,15 +37,17 @@ public class BrowserFetcher : IBrowserFetcher
3737
{
3838
[(Product.Chrome, Platform.Linux)] = "{0}/chromium-browser-snapshots/Linux_x64/{1}/{2}.zip",
3939
[(Product.Chrome, Platform.MacOS)] = "{0}/chromium-browser-snapshots/Mac/{1}/{2}.zip",
40+
[(Product.Chrome, Platform.MacOSArm64)] = "{0}/chromium-browser-snapshots/Mac_Arm/{1}/{2}.zip",
4041
[(Product.Chrome, Platform.Win32)] = "{0}/chromium-browser-snapshots/Win/{1}/{2}.zip",
4142
[(Product.Chrome, Platform.Win64)] = "{0}/chromium-browser-snapshots/Win_x64/{1}/{2}.zip",
4243
[(Product.Firefox, Platform.Linux)] = "{0}/firefox-{1}.en-US.{2}-x86_64.tar.bz2",
44+
[(Product.Firefox, Platform.MacOSArm64)] = "{0}/firefox-{1}.en-US.{2}.dmg",
4345
[(Product.Firefox, Platform.MacOS)] = "{0}/firefox-{1}.en-US.{2}.dmg",
4446
[(Product.Firefox, Platform.Win32)] = "{0}/firefox-{1}.en-US.{2}.zip",
4547
[(Product.Firefox, Platform.Win64)] = "{0}/firefox-{1}.en-US.{2}.zip",
4648
};
4749

48-
private readonly WebClient _webClient = new WebClient();
50+
private readonly WebClient _webClient = new();
4951
private readonly CustomFileDownloadAction _customFileDownload;
5052
private bool _isDisposed;
5153

@@ -94,7 +96,7 @@ public BrowserFetcher(BrowserFetcherOptions options)
9496
public string DownloadHost { get; }
9597

9698
/// <inheritdoc/>
97-
public Platform Platform { get; }
99+
public Platform Platform { get; set; }
98100

99101
/// <inheritdoc/>
100102
public Product Product { get; }
@@ -122,6 +124,7 @@ public static string GetExecutablePath(Product product, Platform platform, strin
122124
switch (platform)
123125
{
124126
case Platform.MacOS:
127+
case Platform.MacOSArm64:
125128
return Path.Combine(
126129
folderPath,
127130
GetArchiveName(product, platform, revision),
@@ -146,6 +149,7 @@ public static string GetExecutablePath(Product product, Platform platform, strin
146149
switch (platform)
147150
{
148151
case Platform.MacOS:
152+
case Platform.MacOSArm64:
149153
return Path.Combine(
150154
folderPath,
151155
"Firefox Nightly.app",
@@ -337,7 +341,7 @@ internal static Platform GetCurrentPlatform()
337341
{
338342
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
339343
{
340-
return Platform.MacOS;
344+
return RuntimeInformation.OSArchitecture == Architecture.Arm64 ? Platform.MacOSArm64 : Platform.MacOS;
341345
}
342346

343347
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
@@ -414,6 +418,7 @@ private static string GetArchiveName(Product product, Platform platform, string
414418
return "chrome-linux";
415419

416420
case Platform.MacOS:
421+
case Platform.MacOSArm64:
417422
return "chrome-mac";
418423

419424
case Platform.Win32:
@@ -432,6 +437,7 @@ private static string GetArchiveName(Product product, Platform platform, string
432437
return "linux";
433438

434439
case Platform.MacOS:
440+
case Platform.MacOSArm64:
435441
return "mac";
436442

437443
case Platform.Win32:

lib/PuppeteerSharp/Platform.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ public enum Platform
1313
Unknown,
1414

1515
/// <summary>
16-
/// MacOS.
16+
/// MacOS intel.
1717
/// </summary>
1818
MacOS,
1919

20+
/// <summary>
21+
/// MacOS arm64.
22+
/// </summary>
23+
MacOSArm64,
24+
2025
/// <summary>
2126
/// Linux.
2227
/// </summary>

lib/PuppeteerSharp/PuppeteerSharp.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<Description>Headless Browser .NET API</Description>
1313
<PackageId>PuppeteerSharp</PackageId>
1414
<PackageReleaseNotes></PackageReleaseNotes>
15-
<PackageVersion>10.1.1</PackageVersion>
16-
<ReleaseVersion>10.1.1</ReleaseVersion>
17-
<AssemblyVersion>10.1.1.0</AssemblyVersion>
18-
<FileVersion>10.1.1.0</FileVersion>
15+
<PackageVersion>10.1.2</PackageVersion>
16+
<ReleaseVersion>10.1.2</ReleaseVersion>
17+
<AssemblyVersion>10.1.2.0</AssemblyVersion>
18+
<FileVersion>10.1.2.0</FileVersion>
1919
<SynchReleaseVersion>false</SynchReleaseVersion>
2020
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
2121
<DebugType>embedded</DebugType>

0 commit comments

Comments
 (0)