This build was committed by a bot.

This commit is contained in:
github-actions[bot]
2026-09-04 16:50:23 +00:00
parent 5b410bfe40
commit 007f07652b
3 changed files with 206 additions and 42 deletions

View File

@@ -326,7 +326,11 @@ var el = window.el = Object.fromEntries([
"threadFolderBtn",
"threadSyncBtn",
"suneRepoInput",
"suneSyncBtn"
"suneSyncBtn",
"suneSyncBadge",
"suneSyncPopover",
"suneSyncUploadBtn",
"suneSyncDownloadBtn"
].map((id) => [id, document.getElementById(id)]));
//#endregion
//#region src/utils.js
@@ -883,6 +887,7 @@ var SYSTEM_KEYS = new Set([
"active_sune_id",
"thread_repo_url",
"sune_repo_url",
"sunes_updated_at",
"user_name",
"user_avatar",
"provider",
@@ -914,6 +919,48 @@ var cleanSuneStorage = (id) => {
if (k.startsWith(p)) localStorage.removeItem(k);
});
};
var isSyncPulling = false;
var getLocalSunesUpdatedAt = () => num(localStorage.getItem("sunes_updated_at"), 0);
var setLocalSunesUpdatedAt = (ts = Date.now()) => localStorage.setItem("sunes_updated_at", ts);
var markLocalDirty = () => {
if (isSyncPulling) return;
setLocalSunesUpdatedAt();
setSuneSyncStatus("desynced");
};
var _origSetItem = localStorage.setItem.bind(localStorage), _origRemoveItem = localStorage.removeItem.bind(localStorage);
localStorage.setItem = (k, v) => {
_origSetItem(k, v);
if (!isSyncPulling && k.startsWith("sune_")) markLocalDirty();
};
localStorage.removeItem = (k) => {
_origRemoveItem(k);
if (!isSyncPulling && k.startsWith("sune_")) markLocalDirty();
};
function setSuneSyncStatus(status) {
const b = el.suneSyncBadge;
if (!b) return;
if (!(el.suneRepoInput?.value || "").trim().startsWith("gh://")) {
b.className = "hidden";
return;
}
b.className = "absolute -top-1 -right-1 block h-2.5 w-2.5 rounded-full ring-2 ring-white";
switch (status) {
case "checking":
b.classList.add("bg-blue-500", "animate-pulse");
break;
case "synced":
b.classList.add("bg-green-500");
break;
case "desynced":
b.classList.add("bg-amber-500");
break;
case "error":
b.classList.add("bg-red-500");
break;
default: b.classList.add("bg-gray-400");
}
el.suneSyncBtn?.querySelector("svg")?.classList.toggle("animate-spin", status === "checking");
}
var suneStorage = {
get(k, def = null) {
const id = SUNE.id;
@@ -1017,6 +1064,7 @@ var SUNE = window.SUNE = new Proxy({
const s = makeSune(p);
sunes.unshift(s);
su.save(sunes);
markLocalDirty();
return s;
},
delete(id) {
@@ -1025,6 +1073,7 @@ var SUNE = window.SUNE = new Proxy({
su.save(sunes);
cleanSuneStorage(id);
gcStorage();
markLocalDirty();
if (sunes.length === 0) {
const def = this.create({ name: "Default" });
this.setActive(def.id);
@@ -1163,6 +1212,7 @@ var SUNE = window.SUNE = new Proxy({
target[p] = value;
sunes[i].updatedAt = Date.now();
su.save(sunes);
markLocalDirty();
}
return true;
}
@@ -1445,6 +1495,14 @@ function showSunePopover(btn, id) {
positionPopover(btn, el.sunePopover);
icons();
}
var hideSuneSyncPopover = () => {
el.suneSyncPopover.classList.add("hidden");
};
function showSuneSyncPopover(btn) {
el.suneSyncPopover.classList.remove("hidden");
positionPopover(btn || el.suneSyncBtn, el.suneSyncPopover);
icons();
}
$(el.threadList).on("click", async (e) => {
const openBtn = e.target.closest("[data-open-thread]"), menuBtn = e.target.closest("[data-thread-menu]");
if (openBtn) {
@@ -1635,6 +1693,7 @@ $(el.sunePopover).on("click", async (e) => {
SUNE.save();
renderSidebar();
await reflectActiveSune();
markLocalDirty();
};
if (act === "pin") {
s.pinned = !s.pinned;
@@ -1661,6 +1720,14 @@ $(el.sunePopover).on("click", async (e) => {
} else if (act === "export") dl(`sune-${(s.name || "sune").replace(/\W/g, "_")}-${ts()}.sune`, [s]);
hideSunePopover();
});
$(el.suneSyncUploadBtn).on("click", () => {
hideSuneSyncPopover();
performSuneUpload();
});
$(el.suneSyncDownloadBtn).on("click", () => {
hideSuneSyncPopover();
performSuneDownload(false);
});
function updateAttachBadge() {
const n = state.attachments.length;
el.attachBadge.textContent = String(n);
@@ -2050,6 +2117,7 @@ async function init() {
renderSidebar();
renderUserUI();
await reflectActiveSune();
if (suR.startsWith("gh://")) checkSuneSyncStatus();
clearChat();
icons();
kbBind();
@@ -2058,6 +2126,10 @@ async function init() {
$(window).on("resize", () => {
hideThreadPopover();
hideSunePopover();
hideSuneSyncPopover();
});
$(document).on("click", (e) => {
if (el.suneSyncPopover && !el.suneSyncPopover.classList.contains("hidden") && !el.suneSyncPopover.contains(e.target) && !el.suneSyncBtn.contains(e.target)) hideSuneSyncPopover();
});
var htmlTabs = {
index: ["htmlTab_index", "htmlEditor"],
@@ -2218,17 +2290,99 @@ $(el.threadSyncBtn).on("click", async () => {
alert("Sync failed: " + e.message);
}
});
$(el.suneRepoInput).on("change", () => {
localStorage.setItem("sune_repo_url", el.suneRepoInput.value.trim());
});
$(el.suneSyncBtn).on("click", async () => {
var suneSyncBusy = false;
var checkSuneSyncStatus = async () => {
const u = el.suneRepoInput.value.trim();
if (!u.startsWith("gh://")) return setSuneSyncStatus("idle");
if (suneSyncBusy) return;
suneSyncBusy = true;
setSuneSyncStatus("checking");
const info = parseGhUrl(u);
try {
const res = await ghApi(`${info.apiPath}/sunes.json?ref=${info.branch}`);
if (!res) return setSuneSyncStatus("desynced");
res.sha;
let remoteData = null;
if (res.content && res.encoding === "base64") try {
remoteData = JSON.parse(btou(res.content));
} catch {}
if (!remoteData && res.sha) {
const text = await ghGetFileContent(info, "sunes.json");
if (text) try {
remoteData = JSON.parse(text);
} catch {}
}
if (!remoteData) return setSuneSyncStatus("error");
const diff = num(remoteData.updatedAt, 0) - getLocalSunesUpdatedAt();
if (diff > 1e4) await performSuneDownload(true, remoteData, res.sha);
else if (diff < -1e4) setSuneSyncStatus("desynced");
else setSuneSyncStatus("synced");
} catch {
setSuneSyncStatus("error");
} finally {
suneSyncBusy = false;
}
};
var performSuneDownload = async (isAuto = false, prefData = null, prefSha = null) => {
const u = el.suneRepoInput.value.trim();
if (!u.startsWith("gh://")) return;
const mode = confirm("Sync Sunes:\nOK = Upload (Push)\nCancel = Download (Pull)"), info = parseGhUrl(u);
if (!isAuto && !confirm("Overwrite local sunes with remote version from GitHub?")) return;
setSuneSyncStatus("checking");
const info = parseGhUrl(u);
try {
if (mode) {
let data = prefData;
if (!data) {
const res = await ghApi(`${info.apiPath}/sunes.json?ref=${info.branch}`);
if (!res) throw new Error("sunes.json not found");
res.sha;
if (res.content && res.encoding === "base64") try {
data = JSON.parse(btou(res.content));
} catch {}
if (!data) {
const text = await ghGetFileContent(info, "sunes.json");
if (!text) throw new Error("Could not read sunes.json");
data = JSON.parse(text);
}
}
if (!data) throw new Error("Invalid data");
isSyncPulling = true;
try {
if (Array.isArray(data.sunes)) {
sunes = data.sunes.map(makeSune);
su.save(sunes);
if (data.activeId) SUNE.setActive(data.activeId);
}
if (data.storage && typeof data.storage === "object") {
Object.keys(localStorage).forEach((k) => {
if (k.startsWith("sune_")) localStorage.removeItem(k);
});
Object.entries(data.storage).forEach(([k, v]) => localStorage.setItem(k, v));
}
setLocalSunesUpdatedAt(num(data.updatedAt, Date.now()));
} finally {
isSyncPulling = false;
}
renderSidebar();
await reflectActiveSune();
setSuneSyncStatus("synced");
if (!isAuto) alert("Sunes pulled.");
} catch (e) {
setSuneSyncStatus("error");
if (!isAuto) alert("Pull failed: " + e.message);
}
};
var performSuneUpload = async () => {
const u = el.suneRepoInput.value.trim();
if (!u.startsWith("gh://")) return;
if (!confirm("Overwrite remote file on GitHub with local version?")) return;
setSuneSyncStatus("checking");
const info = parseGhUrl(u);
try {
const now = Date.now();
setLocalSunesUpdatedAt(now);
const data = {
version: 1,
updatedAt: now,
sunes: SUNE.list,
activeId: SUNE.id,
storage: {}
@@ -2240,30 +2394,30 @@ $(el.suneSyncBtn).on("click", async () => {
});
});
const x = await ghApi(`${info.apiPath}/sunes.json?ref=${info.branch}`);
await ghApi(`${info.apiPath}/sunes.json`, "PUT", {
(await ghApi(`${info.apiPath}/sunes.json`, "PUT", {
message: "Sync Sunes",
content: utob(JSON.stringify(data, null, 2)),
branch: info.branch,
sha: x?.sha
});
}))?.content?.sha;
setSuneSyncStatus("synced");
alert("Sunes pushed.");
} else {
const text = await ghGetFileContent(info, "sunes.json");
if (!text) throw new Error("sunes.json not found");
const data = JSON.parse(text);
if (data.sunes) {
sunes = data.sunes.map(makeSune);
SUNE.save();
if (data.activeId) SUNE.setActive(data.activeId);
}
if (data.storage) Object.entries(data.storage).forEach(([k, v]) => localStorage.setItem(k, v));
renderSidebar();
await reflectActiveSune();
alert("Sunes pulled.");
}
} catch (e) {
alert("Sync failed: " + e.message);
setSuneSyncStatus("error");
alert("Push failed: " + e.message);
}
};
$(el.suneRepoInput).on("change", () => {
localStorage.setItem("sune_repo_url", el.suneRepoInput.value.trim());
checkSuneSyncStatus();
});
$(el.suneSyncBtn).on("click", (e) => {
e.stopPropagation();
if (!el.suneRepoInput.value.trim().startsWith("gh://")) return;
showSuneSyncPopover(el.suneSyncBtn);
});
$(el.sidebarBtnLeft).on("click", () => {
if (el.suneRepoInput.value.trim().startsWith("gh://")) checkSuneSyncStatus();
});
init();
var accountTabs = {
@@ -2581,6 +2735,12 @@ Object.assign(window, {
showThreadPopover,
hideSunePopover,
showSunePopover,
hideSuneSyncPopover,
showSuneSyncPopover,
setSuneSyncStatus,
checkSuneSyncStatus,
performSuneDownload,
performSuneUpload,
updateAttachBadge,
toAttach,
ensureJars,

10
dist/index.html vendored
View File

@@ -13,7 +13,7 @@
<script defer src="//unpkg.com/alpinejs"></script>
<script type="module" crossorigin src="/assets/index-CFtWZ3ac.js"></script>
<script type="module" crossorigin src="/assets/index-CIiJlteO.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DUC1RW1F.css">
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
<body class="bg-white text-gray-900 selection:bg-black/10" x-data @click.window="if($event.target.closest('button')) haptic(); if(!document.getElementById('threadPopover').contains($event.target)&&!$event.target.closest('[data-thread-menu]')) hideThreadPopover(); if(!document.getElementById('sunePopover').contains($event.target)&&!$event.target.closest('[data-sune-menu]')) hideSunePopover(); if(!document.getElementById('userMenu').contains($event.target)&&!document.getElementById('userMenuBtn').contains($event.target)) document.getElementById('userMenu').classList.add('hidden')">
@@ -42,13 +42,13 @@
</footer>
</div>
<div id="sidebarOverlayLeft" class="fixed inset-0 z-40 bg-black/20 hidden" @click="document.getElementById('sidebarLeft').classList.add('-translate-x-full');$el.classList.add('hidden');document.getElementById('sidebarRight').classList.add('translate-x-full');document.getElementById('sidebarOverlayRight').classList.add('hidden');hideThreadPopover();hideSunePopover()"></div>
<div id="sidebarOverlayLeft" class="fixed inset-0 z-40 bg-black/20 hidden" @click="document.getElementById('sidebarLeft').classList.add('-translate-x-full');$el.classList.add('hidden');document.getElementById('sidebarRight').classList.add('translate-x-full');document.getElementById('sidebarOverlayRight').classList.add('hidden');hideThreadPopover();hideSunePopover();hideSuneSyncPopover()"></div>
<aside id="sidebarLeft" class="fixed inset-y-0 left-0 z-50 w-72 max-w-[85vw] bg-white border-r border-gray-200 shadow-xl transform -translate-x-full transition-transform duration-200 ease-out flex flex-col">
<div class="p-2 border-b flex flex-col gap-2">
<input id="suneRepoInput" type="text" placeholder="gh://owner/sunes" class="w-full h-9 rounded-lg border-0 bg-gray-100 px-3 text-xs font-mono focus:ring-2 focus:ring-black focus:bg-white"/>
<div class="flex items-center justify-between gap-2">
<button id="newSuneBtn" class="px-3 py-1.5 rounded-lg bg-black text-white text-[10px] font-bold uppercase tracking-wider hover:bg-black/90 transition">New Sune</button>
<button id="suneSyncBtn" class="px-3 py-1.5 rounded-lg bg-gray-100 text-gray-900 text-[10px] font-bold uppercase tracking-wider hover:bg-gray-200 transition flex items-center gap-1"><i data-lucide="refresh-cw" class="h-3 w-3"></i><span>Sync</span></button>
<button id="suneSyncBtn" class="relative px-3 py-1.5 rounded-lg bg-gray-100 text-gray-900 text-[10px] font-bold uppercase tracking-wider hover:bg-gray-200 transition flex items-center gap-1"><i data-lucide="refresh-cw" class="h-3 w-3"></i><span>Sync</span><span id="suneSyncBadge" class="absolute -top-1 -right-1 block h-2.5 w-2.5 rounded-full ring-2 ring-white hidden"></span></button>
</div>
</div>
<div id="suneList" class="flex-1 overflow-y-auto divide-y"></div>
@@ -94,6 +94,10 @@
<button data-action="pfp" class="menu-item"><i data-lucide="image" class="h-4 w-4"></i><span>Change pfp</span></button>
<button data-action="export" class="menu-item"><i data-lucide="download" class="h-4 w-4"></i><span>Export sune (.sune)</span></button>
</div>
<div id="suneSyncPopover" class="menu-card hidden">
<button id="suneSyncUploadBtn" class="menu-item"><i data-lucide="upload-cloud" class="h-4 w-4"></i><span>Upload to GitHub</span></button>
<button id="suneSyncDownloadBtn" class="menu-item"><i data-lucide="download-cloud" class="h-4 w-4"></i><span>Download from GitHub</span></button>
</div>
<div id="suneModal" class="hidden fixed inset-0 z-50">
<div class="absolute inset-0 bg-black/30"></div>
<div class="absolute inset-x-0 top-12 mx-auto w-full max-w-md px-4">

2
dist/sw.js vendored
View File

@@ -1 +1 @@
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didnt register its module`);return e}));self.define=(n,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let o={};const c=e=>i(e,r),l={module:{uri:r},exports:o,require:c};s[r]=Promise.all(n.map(e=>l[e]||c(e))).then(e=>(t(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"6cf89f14b8b1b835c1ce78df06770d25"},{url:"assets/index-DUC1RW1F.css",revision:null},{url:"assets/index-CFtWZ3ac.js",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
if(!self.define){let e,i={};const s=(s,n)=>(s=new URL(s+".js",n).href,i[s]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=s,e.onload=i,document.head.appendChild(e)}else e=s,importScripts(s),i()}).then(()=>{let e=i[s];if(!e)throw new Error(`Module ${s} didnt register its module`);return e}));self.define=(n,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(i[r])return;let o={};const l=e=>s(e,r),d={module:{uri:r},exports:o,require:l};i[r]=Promise.all(n.map(e=>d[e]||l(e))).then(e=>(t(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"045ea755906b79a6e8657e409e3ad7f3"},{url:"assets/index-DUC1RW1F.css",revision:null},{url:"assets/index-CIiJlteO.js",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});