diff --git a/src/lib/modules/store/i18n.ts b/src/lib/modules/store/i18n.ts index 8b2a31a..a27e563 100644 --- a/src/lib/modules/store/i18n.ts +++ b/src/lib/modules/store/i18n.ts @@ -19,6 +19,7 @@ export const t = dict( version: "Version", downloads: "Downloads", details: "Details", + whatsNew: "What's new", source: "Source", draft: "Draft", updated: (date: string) => `Updated ${date}`, @@ -161,6 +162,7 @@ export const t = dict( version: "Версия", downloads: "Загрузки", details: "Подробнее", + whatsNew: "Что нового", source: "Исходники", draft: "Черновик", updated: (date) => `Обновлено ${date}`, @@ -300,6 +302,7 @@ export const t = dict( version: "Версія", downloads: "Завантаження", details: "Докладніше", + whatsNew: "Що нового", source: "Код", draft: "Чернетка", updated: (date) => `Оновлено ${date}`, @@ -439,6 +442,7 @@ export const t = dict( version: "Versión", downloads: "Descargas", details: "Detalles", + whatsNew: "Novedades", source: "Código", draft: "Borrador", updated: (date) => `Actualizado el ${date}`, @@ -576,6 +580,7 @@ export const t = dict( version: "वर्शन", downloads: "डाउनलोड", details: "विवरण", + whatsNew: "नया क्या है", source: "सोर्स", draft: "ड्राफ़्ट", updated: (date) => `${date} को अपडेट हुआ`, diff --git a/src/lib/modules/store/lib/firmware.ts b/src/lib/modules/store/lib/firmware.ts index b17170b..1d97b1b 100644 --- a/src/lib/modules/store/lib/firmware.ts +++ b/src/lib/modules/store/lib/firmware.ts @@ -42,3 +42,23 @@ export const testedKey = (tested: unknown): "hardware" | "emulator" | null => */ export const recordDevice = (device: unknown): string => String(device || DEFAULT_DEVICE); export const flashable = (device: unknown) => Object.hasOwn(BOARDS, recordDevice(device)); + +export interface ReleaseNote { + /** "Stub 9" for the patched firmware, the App Loader's version otherwise. */ + title: string; + /** Markdown. */ + notes: string; +} + +/** + * A record's `changelog` (`[{version, stub?, notes}]`, newest first; fmc_pocketbase + * 1755300000_firmware_changelog.js), the same list FMC Companion shows under What's new. + * Entries without notes are dropped; anything that isn't such a list reads as none. + */ +export const releaseNotes = (changelog: unknown): ReleaseNote[] => + (Array.isArray(changelog) ? changelog : []) + .filter((e) => e && typeof e.notes === "string" && e.notes.trim()) + .map((e) => ({ + title: typeof e.stub === "number" && e.stub > 0 ? `Stub ${e.stub}` : String(e.version ?? ""), + notes: e.notes, + })); diff --git a/src/lib/modules/store/pages/firmware.svelte b/src/lib/modules/store/pages/firmware.svelte index 583ebe1..64d8654 100644 --- a/src/lib/modules/store/pages/firmware.svelte +++ b/src/lib/modules/store/pages/firmware.svelte @@ -19,6 +19,7 @@ flashable, isLoader, recordDevice, + releaseNotes, testedKey, testedOnHardware, } from "../lib/firmware"; @@ -86,6 +87,7 @@ const deviceName = $derived(DEVICES.find((d) => d.value === device)?.label ?? device); // another watch's image: FMC only downloads it, the Install button isn't there to press const ota = $derived(flashable(device)); + const notes = $derived(releaseNotes(fw?.changelog)); const stats = $derived( fw ? [ @@ -233,6 +235,19 @@

+ {#if notes.length} + +
+

{$t.whatsNew}

+ {#each notes as note, i (i)} +
+

{note.title}

+ +
+ {/each} +
+ {/if} +
{$t.details}
@@ -431,6 +446,16 @@ cursor: pointer; } } + .whats-new { + display: flex; + flex-direction: column; + gap: 0.875rem; + + h2, + h3 { + margin: 0 0 0.25rem; + } + } .more-body { display: flex; flex-direction: column; diff --git a/tests/firmware-release-notes.test.ts b/tests/firmware-release-notes.test.ts new file mode 100644 index 0000000..1769f0c --- /dev/null +++ b/tests/firmware-release-notes.test.ts @@ -0,0 +1,21 @@ +// The firmware page's What's new: the record's changelog as FMC Companion reads it. +import { expect, test } from "vitest"; +import { releaseNotes } from "$lib/modules/store/lib/firmware"; + +test("the patched firmware's entries are titled by stub, the loader's by version", () => { + expect( + releaseNotes([ + { version: "1.0.0.73-wp2.13", stub: 10, notes: "- Columns." }, + { version: "2026-11-23-cccaf79", notes: "- Icons." }, + ]), + ).toEqual([ + { title: "Stub 10", notes: "- Columns." }, + { title: "2026-11-23-cccaf79", notes: "- Icons." }, + ]); +}); + +test("no list, or entries without notes, read as nothing", () => { + expect(releaseNotes(null)).toEqual([]); + expect(releaseNotes("x")).toEqual([]); + expect(releaseNotes([{ version: "v", notes: " " }, null, { version: "w" }])).toEqual([]); +});