maint: hotreload updated to 1.13.7

This commit is contained in:
Chris
2026-01-06 22:42:15 -05:00
parent 796dbca5d8
commit 105da8850a
128 changed files with 3538 additions and 738 deletions

View File

@@ -5,6 +5,9 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using SingularityGroup.HotReload.Editor.Cli;
using SingularityGroup.HotReload.Editor.Localization;
using SingularityGroup.HotReload.Localization;
using Translations = SingularityGroup.HotReload.Editor.Localization.Translations;
namespace SingularityGroup.HotReload.Editor {
static class DownloadUtility {
@@ -19,11 +22,11 @@ namespace SingularityGroup.HotReload.Editor {
}
}
public static string GetPackagePrefix(string version) {
public static string GetPackagePrefix(string version, string locale) {
if (PackageConst.IsAssetStoreBuild) {
return $"releases/asset-store/{version.Replace('.', '-')}";
return $"releases/asset-store/{(locale == Locale.SimplifiedChinese ? "zh/" : "")}{version.Replace('.', '-')}";
}
return $"releases/{version.Replace('.', '-')}";
return $"releases/{(locale == Locale.SimplifiedChinese ? "zh/" : "")}{version.Replace('.', '-')}";
}
public static string GetDownloadUrl(string key) {
@@ -34,11 +37,11 @@ namespace SingularityGroup.HotReload.Editor {
// Get the http headers first to examine the content length
using (var response = await client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false)) {
if (response.StatusCode != HttpStatusCode.OK) {
throw new DownloadException($"Download failed with status code {response.StatusCode} and reason {response.ReasonPhrase}");
throw new DownloadException(string.Format(Translations.Errors.ExceptionDownloadFailed, response.StatusCode, response.ReasonPhrase));
}
var contentLength = response.Content.Headers.ContentLength;
if (!contentLength.HasValue) {
throw new DownloadException("Download failed: Content length unknown");
throw new DownloadException(Translations.Errors.ExceptionDownloadContentLengthUnknown);
}
using (var fs = new FileStream(destinationFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
@@ -55,7 +58,7 @@ namespace SingularityGroup.HotReload.Editor {
}
await fs.FlushAsync().ConfigureAwait(false);
if (fs.Length != contentLength.Value) {
throw new DownloadException("Download failed: download file is corrupted");
throw new DownloadException(Translations.Errors.ExceptionDownloadFileCorrupted);
}
return new DownloadResult(HttpStatusCode.OK, null);
}
@@ -66,11 +69,11 @@ namespace SingularityGroup.HotReload.Editor {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (!source.CanRead)
throw new ArgumentException("Has to be readable", nameof(source));
throw new ArgumentException(Translations.Utility.StreamHasToBeReadable, nameof(source));
if (destination == null)
throw new ArgumentNullException(nameof(destination));
if (!destination.CanWrite)
throw new ArgumentException("Has to be writable", nameof(destination));
throw new ArgumentException(Translations.Utility.StreamHasToBeWritable, nameof(destination));
if (bufferSize < 0)
throw new ArgumentOutOfRangeException(nameof(bufferSize));

View File

@@ -7,9 +7,11 @@ using System.Threading;
using System.Threading.Tasks;
using SingularityGroup.HotReload.DTO;
using SingularityGroup.HotReload.Editor.Cli;
using SingularityGroup.HotReload.Localization;
using SingularityGroup.HotReload.Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
using Translations = SingularityGroup.HotReload.Editor.Localization.Translations;
namespace SingularityGroup.HotReload.Editor {
internal class ServerDownloader : IProgress<float> {
@@ -80,7 +82,7 @@ namespace SingularityGroup.HotReload.Editor {
var error = $"{e.GetType().Name}: {e.Message}";
errors = (errors ?? new HashSet<string>());
if (errors.Add(error)) {
Log.Warning($"Download attempt failed. If the issue persists please reach out to customer support for assistance. Exception: {error}");
Log.Warning(Translations.Errors.ErrorDownloadFailed, error);
}
}
if (!sucess) {
@@ -96,7 +98,7 @@ namespace SingularityGroup.HotReload.Editor {
};
// sending telemetry requires server to be running so we only attempt after server is downloaded
RequestHelper.RequestEditorEventWithRetry(new Stat(StatSource.Client, StatLevel.Error, StatFeature.Editor, StatEventType.Download), data).Forget();
Log.Info("Download succeeded!");
Log.Info(Translations.Errors.ErrorDownloadSucceeded);
}
const int ERROR_ALREADY_EXISTS = 0xB7;
@@ -131,8 +133,7 @@ namespace SingularityGroup.HotReload.Editor {
}
if (!File.Exists(customBinaryPath)) {
Log.Warning($"unable to find server binary for platform '{cliController.PlatformName}' at '{customBinaryPath}'. " +
$"Will proceed with downloading the binary (default behavior)");
Log.Warning(Translations.Errors.ErrorServerBinaryNotFound, cliController.PlatformName, customBinaryPath);
return false;
}
@@ -148,14 +149,15 @@ namespace SingularityGroup.HotReload.Editor {
}
return true;
} catch(IOException ex) {
Log.Warning("encountered exception when copying server binary in the specified custom executable path '{0}':\n{1}", customBinaryPath, ex);
Log.Warning(Translations.Errors.ErrorCopyingServerBinary, customBinaryPath, ex);
return false;
}
}
static string GetDownloadUrl(ICliController cliController) {
const string version = PackageConst.ServerVersion;
var key = $"{DownloadUtility.GetPackagePrefix(version)}/server/{cliController.PlatformName}/{cliController.BinaryFileName}";
// NOTE: server is not translated at the moment so we always use english
var key = $"{DownloadUtility.GetPackagePrefix(version, Locale.English)}/server/{cliController.PlatformName}/{cliController.BinaryFileName}";
return DownloadUtility.GetDownloadUrl(key);
}
@@ -165,18 +167,16 @@ namespace SingularityGroup.HotReload.Editor {
public Task<bool> PromptForDownload() {
if (EditorUtility.DisplayDialog(
title: "Install platform specific components",
message: InstallDescription,
ok: "Install",
cancel: "More Info")
title: Translations.Dialogs.DialogTitleInstallComponents,
message: Translations.Dialogs.DialogMessageInstallComponents,
ok: Translations.Dialogs.DialogButtonInstall,
cancel: Translations.Dialogs.DialogButtonMoreInfo)
) {
return EnsureDownloaded(HotReloadCli.controller, CancellationToken.None);
}
Application.OpenURL(Constants.AdditionalContentURL);
return Task.FromResult(false);
}
public const string InstallDescription = "For Hot Reload to work, additional components specific to your operating system have to be installed";
}
class DownloadResult {

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using SingularityGroup.HotReload.Editor.Cli;
using SingularityGroup.HotReload.Editor.Localization;
using SingularityGroup.HotReload.RuntimeDependencies;
using UnityEditor;
#if UNITY_EDITOR_WIN
@@ -18,17 +19,17 @@ namespace SingularityGroup.HotReload.Editor {
string serverDir;
if(!CliUtils.TryFindServerDir(out serverDir)) {
progress?.Report(1);
return "unable to locate hot reload package";
return Translations.Utility.UnableToLocateHotReloadPackage;
}
var packageDir = Path.GetDirectoryName(Path.GetFullPath(serverDir));
var cacheDir = Path.GetFullPath(PackageConst.LibraryCachePath);
if(Path.GetPathRoot(packageDir) != Path.GetPathRoot(cacheDir)) {
progress?.Report(1);
return "unable to update package because it is located on a different drive than the unity project";
return Translations.Utility.UnableToUpdatePackageDifferentDrive;
}
var updatedPackageCopy = BackupPackage(packageDir, version);
var key = $"{DownloadUtility.GetPackagePrefix(version)}/HotReload.zip";
var key = $"{DownloadUtility.GetPackagePrefix(version, PackageConst.DefaultLocale)}/HotReload.zip";
var url = DownloadUtility.GetDownloadUrl(key);
var targetFileName = $"HotReload{version.Replace('.', '-')}.zip";
var targetFilePath = CliUtils.GetTempDownloadFilePath(targetFileName);