Skip to content

Commit c0a8276

Browse files
authored
Merge pull request #143 from C5Lab/main
Sync with Main
2 parents 919df27 + f6fbc6c commit c0a8276

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

docs/janos_flash.html

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ <h2>Browser support</h2>
320320

321321
const state = {
322322
manifest: null,
323+
latestRelease: null,
323324
files: [],
324325
port: null,
325326
transport: null,
@@ -366,7 +367,7 @@ <h2>Browser support</h2>
366367
} catch {}
367368
let cleaned = path.startsWith("/") ? path.slice(1) : path;
368369
const branch = getBranch();
369-
if (branch !== "main" && cleaned.startsWith("firmware/")) {
370+
if (cleaned.startsWith("firmware/")) {
370371
cleaned = cleaned.replace(/^firmware\//, "ESP32C5/binaries-esp32c5/");
371372
}
372373
return `https://raw.githubusercontent.com/C5Lab/projectZero/${branch}/${cleaned}`;
@@ -395,6 +396,13 @@ <h2>Browser support</h2>
395396
return next;
396397
};
397398

399+
const fetchLatestRelease = async () => {
400+
const apiUrl = "https://api.github.com/repos/C5Lab/projectZero/releases/latest";
401+
const res = await fetch(apiUrl, { cache: "no-store" });
402+
if (!res.ok) throw new Error(`GitHub release fetch failed: ${res.status} ${res.statusText}`);
403+
return res.json();
404+
};
405+
398406
const loadManifest = async () => {
399407
try {
400408
const manifestUrl = getManifestUrl();
@@ -403,10 +411,21 @@ <h2>Browser support</h2>
403411
const manifestRaw = await res.json();
404412
const manifest = rewritePartsForBranch(manifestRaw, getBranch());
405413
state.manifest = manifest;
414+
let releaseLabel = manifest.version || "n/a";
415+
if (getBranch() === "main") {
416+
try {
417+
const release = await fetchLatestRelease();
418+
state.latestRelease = release;
419+
releaseLabel = release.tag_name || release.name || releaseLabel;
420+
} catch (err) {
421+
console.warn(err);
422+
}
423+
}
406424
ui.manifest.style.display = "inline-flex";
407-
ui.manifest.textContent = `Build ${manifest.build || "n/a"} - ${manifest.version || "n/a"} - ${getBranch()}`;
425+
ui.manifest.textContent = `Build ${manifest.build || "n/a"} - ${releaseLabel} - ${getBranch()}`;
408426
const files = (manifest.parts || []).length;
409-
ui.releaseInfo.innerHTML = `<span class="badge">Manifest</span> ${manifest.name || "projectZero"} - ${files} file(s) - chip ${manifest.chipFamily || "ESP32-C5"} - ${getBranch()}`;
427+
const releaseText = state.latestRelease ? ` - latest ${releaseLabel}` : "";
428+
ui.releaseInfo.innerHTML = `<span class="badge">Manifest</span> ${manifest.name || "projectZero"}${releaseText} - ${files} file(s) - chip ${manifest.chipFamily || "ESP32-C5"} - ${getBranch()}`;
410429
setStatus("Manifest loaded.");
411430
} catch (err) {
412431
setStatus("Manifest not found. Publish a release first.", "error");

0 commit comments

Comments
 (0)