From 3a106aab75c22582d510b2a07632aa44d6917b3d Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Sat, 26 Apr 2025 15:51:50 +0200 Subject: [PATCH 1/3] Add AutoUpdater feature with events and facade support Introduces the `AutoUpdater` class to manage update processes via the client. Adds events such as `UpdateAvailable`, `UpdateDownloaded`, and others for broadcasting update states. A facade is also provided for convenient usage. --- src/AutoUpdater.php | 20 ++++++++++++++++ src/Events/AutoUpdater/CheckingForUpdate.php | 23 +++++++++++++++++++ src/Events/AutoUpdater/Error.php | 23 +++++++++++++++++++ src/Events/AutoUpdater/UpdateAvailable.php | 23 +++++++++++++++++++ src/Events/AutoUpdater/UpdateDownloaded.php | 23 +++++++++++++++++++ src/Events/AutoUpdater/UpdateNotAvailable.php | 21 +++++++++++++++++ src/Facades/AutoUpdater.php | 17 ++++++++++++++ 7 files changed, 150 insertions(+) create mode 100644 src/AutoUpdater.php create mode 100644 src/Events/AutoUpdater/CheckingForUpdate.php create mode 100644 src/Events/AutoUpdater/Error.php create mode 100644 src/Events/AutoUpdater/UpdateAvailable.php create mode 100644 src/Events/AutoUpdater/UpdateDownloaded.php create mode 100644 src/Events/AutoUpdater/UpdateNotAvailable.php create mode 100644 src/Facades/AutoUpdater.php diff --git a/src/AutoUpdater.php b/src/AutoUpdater.php new file mode 100644 index 00000000..e714a0f1 --- /dev/null +++ b/src/AutoUpdater.php @@ -0,0 +1,20 @@ +client->post('auto-updater/check-for-updates'); + } + + public function quitAndInstall(): void + { + $this->client->post('auto-updater/quit-and-install'); + } +} diff --git a/src/Events/AutoUpdater/CheckingForUpdate.php b/src/Events/AutoUpdater/CheckingForUpdate.php new file mode 100644 index 00000000..a646d329 --- /dev/null +++ b/src/Events/AutoUpdater/CheckingForUpdate.php @@ -0,0 +1,23 @@ + Date: Mon, 28 Apr 2025 21:46:31 +0200 Subject: [PATCH 2/3] Add DownloadProgress event for real-time update broadcasting This event handles broadcasting download progress updates through a 'nativephp' channel. It includes details such as total size, delta, transferred bytes, percentage completed, and speed. --- src/Events/AutoUpdater/DownloadProgress.php | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Events/AutoUpdater/DownloadProgress.php diff --git a/src/Events/AutoUpdater/DownloadProgress.php b/src/Events/AutoUpdater/DownloadProgress.php new file mode 100644 index 00000000..fcc8f31c --- /dev/null +++ b/src/Events/AutoUpdater/DownloadProgress.php @@ -0,0 +1,23 @@ + Date: Tue, 29 Apr 2025 19:30:48 +0200 Subject: [PATCH 3/3] fix: update property types in DownloadProgress constructor Adjusted the types of total, delta, and bytesPerSecond from float to int to ensure type consistency and accuracy. This change prevents potential precision issues and aligns with expected data formats. --- src/Events/AutoUpdater/DownloadProgress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Events/AutoUpdater/DownloadProgress.php b/src/Events/AutoUpdater/DownloadProgress.php index fcc8f31c..42045b27 100644 --- a/src/Events/AutoUpdater/DownloadProgress.php +++ b/src/Events/AutoUpdater/DownloadProgress.php @@ -12,7 +12,7 @@ class DownloadProgress implements ShouldBroadcastNow { use Dispatchable, InteractsWithSockets, SerializesModels; - public function __construct(public float $total, public float $delta, public float $transferred, public float $percent, public float $bytesPerSecond) {} + public function __construct(public int $total, public int $delta, public int $transferred, public float $percent, public int $bytesPerSecond) {} public function broadcastOn() {