From 223516c03fd866ba6aed0a4d88c1fa870ff46d37 Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Tue, 13 May 2025 22:31:38 +0200 Subject: [PATCH] Add support for detailed auto-updater event handling Expanded event constructors to include more detailed update metadata such as version, files, release information, and system requirements. Added a `downloadUpdate` method to the AutoUpdater facade. These updates enhance event broadcasting and improve client interaction with the auto-updater. --- src/AutoUpdater.php | 5 +++ src/Events/AutoUpdater/DownloadProgress.php | 8 ++++- src/Events/AutoUpdater/Error.php | 6 +++- src/Events/AutoUpdater/UpdateAvailable.php | 10 +++++- src/Events/AutoUpdater/UpdateCancelled.php | 31 +++++++++++++++++++ src/Events/AutoUpdater/UpdateDownloaded.php | 11 ++++++- src/Events/AutoUpdater/UpdateNotAvailable.php | 10 ++++++ src/Facades/AutoUpdater.php | 1 + 8 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/Events/AutoUpdater/UpdateCancelled.php diff --git a/src/AutoUpdater.php b/src/AutoUpdater.php index e714a0f..7950045 100644 --- a/src/AutoUpdater.php +++ b/src/AutoUpdater.php @@ -17,4 +17,9 @@ public function quitAndInstall(): void { $this->client->post('auto-updater/quit-and-install'); } + + public function downloadUpdate(): void + { + $this->client->post('auto-updater/download-update'); + } } diff --git a/src/Events/AutoUpdater/DownloadProgress.php b/src/Events/AutoUpdater/DownloadProgress.php index 42045b2..2339315 100644 --- a/src/Events/AutoUpdater/DownloadProgress.php +++ b/src/Events/AutoUpdater/DownloadProgress.php @@ -12,7 +12,13 @@ class DownloadProgress implements ShouldBroadcastNow { use Dispatchable, InteractsWithSockets, SerializesModels; - public function __construct(public int $total, public int $delta, public int $transferred, public float $percent, public int $bytesPerSecond) {} + public function __construct( + public int $total, + public int $delta, + public int $transferred, + public float $percent, + public int $bytesPerSecond + ) {} public function broadcastOn() { diff --git a/src/Events/AutoUpdater/Error.php b/src/Events/AutoUpdater/Error.php index 8444dcd..9d2219d 100644 --- a/src/Events/AutoUpdater/Error.php +++ b/src/Events/AutoUpdater/Error.php @@ -12,7 +12,11 @@ class Error implements ShouldBroadcastNow { use Dispatchable, InteractsWithSockets, SerializesModels; - public function __construct(public string $error) {} + public function __construct( + public string $name, + public string $message, + public ?string $stack, + ) {} public function broadcastOn() { diff --git a/src/Events/AutoUpdater/UpdateAvailable.php b/src/Events/AutoUpdater/UpdateAvailable.php index 5dc55cd..1fb05fb 100644 --- a/src/Events/AutoUpdater/UpdateAvailable.php +++ b/src/Events/AutoUpdater/UpdateAvailable.php @@ -12,7 +12,15 @@ class UpdateAvailable implements ShouldBroadcastNow { use Dispatchable, InteractsWithSockets, SerializesModels; - public function __construct() {} + public function __construct( + public string $version, + public array $files, + public string $releaseDate, + public ?string $releaseName, + public string|array|null $releaseNotes, + public ?int $stagingPercentage, + public ?string $minimumSystemVersion, + ) {} public function broadcastOn() { diff --git a/src/Events/AutoUpdater/UpdateCancelled.php b/src/Events/AutoUpdater/UpdateCancelled.php new file mode 100644 index 0000000..09d01b6 --- /dev/null +++ b/src/Events/AutoUpdater/UpdateCancelled.php @@ -0,0 +1,31 @@ +