From 1cbb52fad4b4e631f4cdc82cc1f15399cc394024 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 4 Apr 2024 11:10:23 -0400 Subject: [PATCH] Load playlet lib as squashfs (#357) * Load playlet lib as squashfs * typo --- CHANGELOG.md | 2 +- .../src/components/BootstrapScene/BootstrapScene.bs | 11 ++++++----- playlet-app/src/manifest | 7 ++++--- playlet-app/src/source/Manifest.spec.bs | 5 +++-- playlet-web/src/lib/Api/PlayletApi.ts | 6 ++++++ .../SettingControls/PlayletLibVersionControl.svelte | 11 ++++++++--- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf98edb..99777b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Squashfs signed build artifacts to releases +- Loading Playlet lib as squashfs, with fallback to the zip file. This significantly decreases load times. ## [0.22.3] - 2024-03-31 diff --git a/playlet-app/src/components/BootstrapScene/BootstrapScene.bs b/playlet-app/src/components/BootstrapScene/BootstrapScene.bs index d25c7d3b..181ce633 100644 --- a/playlet-app/src/components/BootstrapScene/BootstrapScene.bs +++ b/playlet-app/src/components/BootstrapScene/BootstrapScene.bs @@ -22,8 +22,8 @@ end function function GetPlayletLibUrls() as object #if DEBUG - debug = { type: "debug", link: Manifest.ReadValue("playlet_lib_debug_url") } - embedded = { type: "embedded", link: Manifest.ReadValue("playlet_lib_embedded_url") } + debug = { type: "debug-zip", link: Manifest.ReadValue("playlet_lib_zip_debug_url") } + embedded = { type: "embedded-zip", link: Manifest.ReadValue("playlet_lib_zip_embedded_url") } #if DEBUG_FALLBACK_TO_EMBEDDED return [debug, embedded] #else @@ -36,9 +36,10 @@ function GetPlayletLibUrls() as object return savedUrls end if - github = { type: "github", link: Manifest.ReadValue("playlet_lib_remote_url") } - embedded = { type: "embedded", link: Manifest.ReadValue("playlet_lib_embedded_url") } - return [github, embedded] + githubSquashFs = { type: "github-squashfs", link: Manifest.ReadValue("playlet_lib_squashfs_remote_url") } + githubZip = { type: "github-zip", link: Manifest.ReadValue("playlet_lib_zip_remote_url") } + embedded = { type: "embedded-zip", link: Manifest.ReadValue("playlet_lib_zip_embedded_url") } + return [githubSquashFs, githubZip, embedded] #end if end function diff --git a/playlet-app/src/manifest b/playlet-app/src/manifest index 11d4c42a..be6f43df 100644 --- a/playlet-app/src/manifest +++ b/playlet-app/src/manifest @@ -27,9 +27,10 @@ confirm_partner_button=1 supports_input_launch=1 -playlet_lib_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip -playlet_lib_embedded_url=pkg:/lib/playlet-lib.zip -playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip +playlet_lib_squashfs_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg +playlet_lib_zip_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip +playlet_lib_zip_embedded_url=pkg:/lib/playlet-lib.zip +playlet_lib_zip_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip git_commit_sha=unknown diff --git a/playlet-app/src/source/Manifest.spec.bs b/playlet-app/src/source/Manifest.spec.bs index 8acfb0f3..a9fd10fb 100644 --- a/playlet-app/src/source/Manifest.spec.bs +++ b/playlet-app/src/source/Manifest.spec.bs @@ -8,8 +8,9 @@ namespace Tests @it("Reads values from manifest") @params("title", "Playlet") @params("supports_input_launch", "1") - @params("playlet_lib_remote_url", "https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip") - @params("playlet_lib_embedded_url", "pkg:/lib/playlet-lib.zip") + @params("playlet_lib_squashfs_remote_url", "https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg") + @params("playlet_lib_zip_remote_url", "https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip") + @params("playlet_lib_zip_embedded_url", "pkg:/lib/playlet-lib.zip") function _(key as string, expectedValue as string) m.assertEqual(Manifest.ReadValue(key), expectedValue) end function diff --git a/playlet-web/src/lib/Api/PlayletApi.ts b/playlet-web/src/lib/Api/PlayletApi.ts index ff6f2ce1..00e18ef9 100644 --- a/playlet-web/src/lib/Api/PlayletApi.ts +++ b/playlet-web/src/lib/Api/PlayletApi.ts @@ -142,6 +142,9 @@ export class PlayletApi { static async setPlayletLibVersion(tag) { if (tag !== "") { const urls = [{ + link: `https://github.com/iBicha/playlet/releases/download/${tag}/playlet-lib.squashfs.pkg`, + type: 'custom' + }, { link: `https://github.com/iBicha/playlet/releases/download/${tag}/playlet-lib.zip`, type: 'custom' }] @@ -149,6 +152,9 @@ export class PlayletApi { // To avoid the "not found" error, we fallback to the default "latest" release. if (tag === "canary") { urls.push({ + link: `https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg`, + type: 'custom' + }, { link: `https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip`, type: 'custom' }) diff --git a/playlet-web/src/lib/Screens/Settings/SettingControls/PlayletLibVersionControl.svelte b/playlet-web/src/lib/Screens/Settings/SettingControls/PlayletLibVersionControl.svelte index fb20d791..b9a11b38 100644 --- a/playlet-web/src/lib/Screens/Settings/SettingControls/PlayletLibVersionControl.svelte +++ b/playlet-web/src/lib/Screens/Settings/SettingControls/PlayletLibVersionControl.svelte @@ -38,7 +38,9 @@ const release = releases[i].name; if ( libUrl === - `https://github.com/iBicha/playlet/releases/download/${release}/playlet-lib.zip` + `https://github.com/iBicha/playlet/releases/download/${release}/playlet-lib.zip` || + libUrl === + `https://github.com/iBicha/playlet/releases/download/${release}/playlet-lib.squashfs.pkg` ) { selectedRelease = release; break; @@ -55,8 +57,11 @@ return { name: release.tag_name, enabled: - release.assets.filter((asset) => asset.name === "playlet-lib.zip") - .length > 0, + release.assets.filter( + (asset) => + asset.name === "playlet-lib.zip" || + asset.name === "playlet-lib.squashfs.pkg" + ).length > 0, }; }); }