From 52216495c23f414e6c8f74aaddbd7cb22d6dd9b7 Mon Sep 17 00:00:00 2001 From: pdmarf <135653545+pdmarf@users.noreply.github.com> Date: Fri, 24 Apr 2026 07:50:44 +0100 Subject: [PATCH] Deploy stable-rebuild v1.0.26 plugin.js to master Staff on v1.0.25 check master's version.json for updates. Previously master was on 1.0.22 (< 1.0.25) so the updater always said "already up to date". Now master serves the stable-rebuild v1.0.26 binary so staff can self-update via Check for Updates. Co-Authored-By: Claude Sonnet 4.6 --- com.pdma.notion-timer.sdPlugin/bin/plugin.js | 111 ++++++------------ .../bin/plugin.js.sig | Bin 64 -> 64 bytes version.json | 2 +- 3 files changed, 40 insertions(+), 73 deletions(-) diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js b/com.pdma.notion-timer.sdPlugin/bin/plugin.js index 95dbf08..d772d8f 100644 --- a/com.pdma.notion-timer.sdPlugin/bin/plugin.js +++ b/com.pdma.notion-timer.sdPlugin/bin/plugin.js @@ -6438,22 +6438,18 @@ async function stopTimer(token, entryId) { } // src/plugin.ts -var CURRENT_VERSION = "1.0.22"; -var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master"; +var CURRENT_VERSION = "1.0.26"; +var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild"; var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4= -----END PUBLIC KEY-----`; function isNewerVersion(remote, current) { const parse = (v) => v.split(".").map(Number); - const r = parse(remote); - const c = parse(current); - const len = Math.max(r.length, c.length); - for (let i = 0; i < len; i++) { - const rv = r[i] ?? 0; - const cv = c[i] ?? 0; - if (rv !== cv) return rv > cv; - } - return false; + const [rMaj, rMin, rPat] = parse(remote); + const [cMaj, cMin, cPat] = parse(current); + if (rMaj !== cMaj) return rMaj > cMaj; + if (rMin !== cMin) return rMin > cMin; + return rPat > cPat; } function fetchWithTimeout2(url) { const controller = new AbortController(); @@ -6468,16 +6464,15 @@ async function checkForUpdates(sendStatus) { return; } const { version } = await resp.json(); - if (!/^\d+(\.\d+)+$/.test(version)) return; + if (!/^\d+\.\d+\.\d+$/.test(version)) return; if (!isNewerVersion(version, CURRENT_VERSION)) { sendStatus?.(`Already up to date (v${CURRENT_VERSION})`); return; } sendStatus?.(`Updating to v${version}\u2026`); - const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`; const [pluginResp, sigResp] = await Promise.all([ - fetchWithTimeout2(`${PLUGIN_BASE}/bin/plugin.js`), - fetchWithTimeout2(`${PLUGIN_BASE}/bin/plugin.js.sig`) + fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`), + fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`) ]); if (!pluginResp.ok || !sigResp.ok) { sendStatus?.("Download failed"); @@ -6493,30 +6488,7 @@ async function checkForUpdates(sendStatus) { return; } const fs3 = await import("fs"); - const path5 = await import("path"); - const pluginRoot = path5.join(path5.dirname(__filename), ".."); - const ASSETS = [ - "ui/property-inspector.html", - "ui/global-property-inspector.html", - "imgs/idle.png", - "imgs/running.png" - ]; - const assetResps = await Promise.all(ASSETS.map((p) => fetchWithTimeout2(`${PLUGIN_BASE}/${p}`))); fs3.writeFileSync(__filename, newCode); - for (let i = 0; i < ASSETS.length; i++) { - if (!assetResps[i].ok) { - plugin_default.logger.warn(`Asset download failed: ${ASSETS[i]}`); - continue; - } - fs3.writeFileSync(path5.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer())); - } - const LEGACY = ["imgs/idle.svg", "imgs/running.svg"]; - for (const f of LEGACY) { - try { - fs3.unlinkSync(path5.join(pluginRoot, f)); - } catch { - } - } plugin_default.logger.info(`Updated to ${version}, restarting\u2026`); process.exit(0); } catch (err) { @@ -6546,31 +6518,6 @@ async function setRunningEntry(entryId) { const stored = await plugin_default.settings.getGlobalSettings(); await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId }); } -async function sendProjectsToPI(overrideToken) { - try { - const global = await getGlobal(); - const token = overrideToken || global.notionToken; - if (!token) { - await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION }); - return; - } - let usersResult = []; - let usersError; - const [projects] = await Promise.all([ - fetchProjects(token, global.projectsDbId), - fetchUsers(token).then((u) => { - usersResult = u; - }).catch((err) => { - plugin_default.logger.error("Failed to fetch users:", err); - usersError = err instanceof Error ? err.message : String(err); - }) - ]); - await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, usersError, version: CURRENT_VERSION }); - } catch (err) { - plugin_default.logger.error("Failed to fetch projects:", err); - await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION }); - } -} function isConfigured(g) { return !!(g.notionToken && g.userId); } @@ -6598,8 +6545,25 @@ var TimerToggle = class extends SingletonAction { } } } - async onPropertyInspectorDidAppear(_ev) { - await sendProjectsToPI(); + async onPropertyInspectorDidAppear(ev) { + try { + const global = await getGlobal(); + if (!global.notionToken) { + await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: "Enter your Notion API token above.", version: CURRENT_VERSION }); + return; + } + const [projects, usersResult] = await Promise.all([ + fetchProjects(global.notionToken, global.projectsDbId), + fetchUsers(global.notionToken).catch((err) => { + plugin_default.logger.error("Failed to fetch users:", err); + return []; + }) + ]); + await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: projects, users: usersResult, version: CURRENT_VERSION }); + } catch (err) { + plugin_default.logger.error("Failed to fetch projects:", err); + await plugin_default.ui.sendToPropertyInspector({ event: "projects", data: [], error: String(err), version: CURRENT_VERSION }); + } } async onKeyDown(ev) { this.settingsCache.set(ev.action.id, ev.payload.settings); @@ -6625,6 +6589,16 @@ var TimerToggle = class extends SingletonAction { await setRunningEntry(null); } else { const prevEntryId = await getRunningEntryId(); + if (prevEntryId) { + for (const other of this.actions) { + if (other.id === ev.action.id) continue; + const otherSettings = this.settingsCache.get(other.id); + if (otherSettings?.activeEntryId === prevEntryId) { + await Promise.all([other.setState(0), other.setTitle(buttonTitle(otherSettings.projectName || ""))]); + } + } + } + await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]); if (prevEntryId) { await stopTimer(global.notionToken, prevEntryId); for (const other of this.actions) { @@ -6634,8 +6608,6 @@ var TimerToggle = class extends SingletonAction { const stopped = { ...otherSettings, activeEntryId: null }; await other.setSettings(stopped); this.settingsCache.set(other.id, stopped); - await other.setState(0); - await other.setTitle(buttonTitle(otherSettings.projectName || "")); } } } @@ -6650,8 +6622,6 @@ var TimerToggle = class extends SingletonAction { await ev.action.setSettings(started); this.settingsCache.set(ev.action.id, started); await setRunningEntry(entryId); - await ev.action.setState(1); - await ev.action.setTitle(`\u23F1 ${title}`); } } catch (err) { plugin_default.logger.error("Timer toggle failed:", err); @@ -6670,9 +6640,6 @@ plugin_default.ui.onSendToPlugin(async (ev) => { const title = buttonTitle(ev.payload.settings.projectName || ""); if (title) await ev.action.setTitle(title); } - if (ev.payload.event === "refresh") { - await sendProjectsToPI(ev.payload.notionToken); - } if (ev.payload.event === "checkForUpdates") { const send = (msg) => plugin_default.ui.sendToPropertyInspector({ event: "updateStatus", message: msg }); send("Checking\u2026"); diff --git a/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig b/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig index 73daef021cef16394c7ba69bb5a2eee66289bbf4..6d5f1bcbcaaf19e814e9feed3b6ab646c0b2bf20 100644 GIT binary patch literal 64 zcmV-G0KfkLIiLM&7SSv5ahw4*E+Lfw literal 64 zcmV-G0Kfks7Mo$Na#GsLEQ$qtco|ACQ^V1f^0L@t)^#!1Jo+`eOSrE4C}F2B2&V?a W$Ec9IHjrn?43TebPD{6RuKon<;~#$j diff --git a/version.json b/version.json index f7bc7e1..f78be80 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{ "version": "1.0.22" } +{ "version": "1.0.26" }