Skip to content

Commit

Permalink
Introduce chromium for MacOS arm64 downloads (#2256)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Jul 17, 2023
1 parent fdcaed6 commit 60ca95b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
14 changes: 10 additions & 4 deletions lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BrowserFetcher : IBrowserFetcher

private const string PublishSingleFileLocalApplicationDataFolderName = "PuppeteerSharp";

private static readonly Dictionary<Product, string> _hosts = new Dictionary<Product, string>
private static readonly Dictionary<Product, string> _hosts = new()
{
[Product.Chrome] = "https://storage.googleapis.com",
[Product.Firefox] = "https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central",
Expand All @@ -37,15 +37,17 @@ public class BrowserFetcher : IBrowserFetcher
{
[(Product.Chrome, Platform.Linux)] = "{0}/chromium-browser-snapshots/Linux_x64/{1}/{2}.zip",
[(Product.Chrome, Platform.MacOS)] = "{0}/chromium-browser-snapshots/Mac/{1}/{2}.zip",
[(Product.Chrome, Platform.MacOSArm64)] = "{0}/chromium-browser-snapshots/Mac_Arm/{1}/{2}.zip",
[(Product.Chrome, Platform.Win32)] = "{0}/chromium-browser-snapshots/Win/{1}/{2}.zip",
[(Product.Chrome, Platform.Win64)] = "{0}/chromium-browser-snapshots/Win_x64/{1}/{2}.zip",
[(Product.Firefox, Platform.Linux)] = "{0}/firefox-{1}.en-US.{2}-x86_64.tar.bz2",
[(Product.Firefox, Platform.MacOSArm64)] = "{0}/firefox-{1}.en-US.{2}.dmg",
[(Product.Firefox, Platform.MacOS)] = "{0}/firefox-{1}.en-US.{2}.dmg",
[(Product.Firefox, Platform.Win32)] = "{0}/firefox-{1}.en-US.{2}.zip",
[(Product.Firefox, Platform.Win64)] = "{0}/firefox-{1}.en-US.{2}.zip",
};

private readonly WebClient _webClient = new WebClient();
private readonly WebClient _webClient = new();
private readonly CustomFileDownloadAction _customFileDownload;
private bool _isDisposed;

Expand Down Expand Up @@ -94,7 +96,7 @@ public BrowserFetcher(BrowserFetcherOptions options)
public string DownloadHost { get; }

/// <inheritdoc/>
public Platform Platform { get; }
public Platform Platform { get; set; }

/// <inheritdoc/>
public Product Product { get; }
Expand Down Expand Up @@ -122,6 +124,7 @@ public static string GetExecutablePath(Product product, Platform platform, strin
switch (platform)
{
case Platform.MacOS:
case Platform.MacOSArm64:
return Path.Combine(
folderPath,
GetArchiveName(product, platform, revision),
Expand All @@ -146,6 +149,7 @@ public static string GetExecutablePath(Product product, Platform platform, strin
switch (platform)
{
case Platform.MacOS:
case Platform.MacOSArm64:
return Path.Combine(
folderPath,
"Firefox Nightly.app",
Expand Down Expand Up @@ -337,7 +341,7 @@ internal static Platform GetCurrentPlatform()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return Platform.MacOS;
return RuntimeInformation.OSArchitecture == Architecture.Arm64 ? Platform.MacOSArm64 : Platform.MacOS;
}

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

case Platform.MacOS:
case Platform.MacOSArm64:
return "chrome-mac";

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

case Platform.MacOS:
case Platform.MacOSArm64:
return "mac";

case Platform.Win32:
Expand Down
7 changes: 6 additions & 1 deletion lib/PuppeteerSharp/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ public enum Platform
Unknown,

/// <summary>
/// MacOS.
/// MacOS intel.
/// </summary>
MacOS,

/// <summary>
/// MacOS arm64.
/// </summary>
MacOSArm64,

/// <summary>
/// Linux.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<Description>Headless Browser .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageVersion>10.1.1</PackageVersion>
<ReleaseVersion>10.1.1</ReleaseVersion>
<AssemblyVersion>10.1.1.0</AssemblyVersion>
<FileVersion>10.1.1.0</FileVersion>
<PackageVersion>10.1.2</PackageVersion>
<ReleaseVersion>10.1.2</ReleaseVersion>
<AssemblyVersion>10.1.2.0</AssemblyVersion>
<FileVersion>10.1.2.0</FileVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<DebugType>embedded</DebugType>
Expand Down

0 comments on commit 60ca95b

Please sign in to comment.