mirror of
https://github.com/multipleof4/sune.git
synced 2026-09-18 03:25:44 +00:00
Merge pull request #23 from sune-org/upgrade_github_sync_logic
Upgrade GitHub sync logic
This commit is contained in:
@@ -328,9 +328,9 @@ var el = window.el = Object.fromEntries([
|
|||||||
"suneRepoInput",
|
"suneRepoInput",
|
||||||
"suneSyncBtn",
|
"suneSyncBtn",
|
||||||
"suneSyncBadge",
|
"suneSyncBadge",
|
||||||
"suneSyncPopover",
|
"sunesSyncPopover",
|
||||||
"suneSyncUploadBtn",
|
"sunesSyncUploadBtn",
|
||||||
"suneSyncDownloadBtn"
|
"sunesSyncDownloadBtn"
|
||||||
].map((id) => [id, document.getElementById(id)]));
|
].map((id) => [id, document.getElementById(id)]));
|
||||||
//#endregion
|
//#endregion
|
||||||
//#region src/utils.js
|
//#region src/utils.js
|
||||||
@@ -927,14 +927,15 @@ var markLocalDirty = () => {
|
|||||||
setLocalSunesUpdatedAt();
|
setLocalSunesUpdatedAt();
|
||||||
setSuneSyncStatus("desynced");
|
setSuneSyncStatus("desynced");
|
||||||
};
|
};
|
||||||
|
var isSuneStorageKey = (k) => !SYSTEM_KEYS.has(k) && /^sune_[^_]+_/.test(k);
|
||||||
var _origSetItem = localStorage.setItem.bind(localStorage), _origRemoveItem = localStorage.removeItem.bind(localStorage);
|
var _origSetItem = localStorage.setItem.bind(localStorage), _origRemoveItem = localStorage.removeItem.bind(localStorage);
|
||||||
localStorage.setItem = (k, v) => {
|
localStorage.setItem = (k, v) => {
|
||||||
_origSetItem(k, v);
|
_origSetItem(k, v);
|
||||||
if (!isSyncPulling && k.startsWith("sune_")) markLocalDirty();
|
if (!isSyncPulling && isSuneStorageKey(k)) markLocalDirty();
|
||||||
};
|
};
|
||||||
localStorage.removeItem = (k) => {
|
localStorage.removeItem = (k) => {
|
||||||
_origRemoveItem(k);
|
_origRemoveItem(k);
|
||||||
if (!isSyncPulling && k.startsWith("sune_")) markLocalDirty();
|
if (!isSyncPulling && isSuneStorageKey(k)) markLocalDirty();
|
||||||
};
|
};
|
||||||
function setSuneSyncStatus(status) {
|
function setSuneSyncStatus(status) {
|
||||||
const b = el.suneSyncBadge;
|
const b = el.suneSyncBadge;
|
||||||
@@ -1495,14 +1496,15 @@ function showSunePopover(btn, id) {
|
|||||||
positionPopover(btn, el.sunePopover);
|
positionPopover(btn, el.sunePopover);
|
||||||
icons();
|
icons();
|
||||||
}
|
}
|
||||||
var hideSuneSyncPopover = () => {
|
var hideSunesSyncPopover = () => {
|
||||||
el.suneSyncPopover.classList.add("hidden");
|
el.sunesSyncPopover.classList.add("hidden");
|
||||||
};
|
}, hideSuneSyncPopover = hideSunesSyncPopover;
|
||||||
function showSuneSyncPopover(btn) {
|
function showSunesSyncPopover(btn) {
|
||||||
el.suneSyncPopover.classList.remove("hidden");
|
el.sunesSyncPopover.classList.remove("hidden");
|
||||||
positionPopover(btn || el.suneSyncBtn, el.suneSyncPopover);
|
positionPopover(btn || el.suneSyncBtn, el.sunesSyncPopover);
|
||||||
icons();
|
icons();
|
||||||
}
|
}
|
||||||
|
var showSuneSyncPopover = showSunesSyncPopover;
|
||||||
$(el.threadList).on("click", async (e) => {
|
$(el.threadList).on("click", async (e) => {
|
||||||
const openBtn = e.target.closest("[data-open-thread]"), menuBtn = e.target.closest("[data-thread-menu]");
|
const openBtn = e.target.closest("[data-open-thread]"), menuBtn = e.target.closest("[data-thread-menu]");
|
||||||
if (openBtn) {
|
if (openBtn) {
|
||||||
@@ -1720,12 +1722,12 @@ $(el.sunePopover).on("click", async (e) => {
|
|||||||
} else if (act === "export") dl(`sune-${(s.name || "sune").replace(/\W/g, "_")}-${ts()}.sune`, [s]);
|
} else if (act === "export") dl(`sune-${(s.name || "sune").replace(/\W/g, "_")}-${ts()}.sune`, [s]);
|
||||||
hideSunePopover();
|
hideSunePopover();
|
||||||
});
|
});
|
||||||
$(el.suneSyncUploadBtn).on("click", () => {
|
$(el.sunesSyncUploadBtn).on("click", () => {
|
||||||
hideSuneSyncPopover();
|
hideSunesSyncPopover();
|
||||||
performSuneUpload();
|
performSuneUpload();
|
||||||
});
|
});
|
||||||
$(el.suneSyncDownloadBtn).on("click", () => {
|
$(el.sunesSyncDownloadBtn).on("click", () => {
|
||||||
hideSuneSyncPopover();
|
hideSunesSyncPopover();
|
||||||
performSuneDownload(false);
|
performSuneDownload(false);
|
||||||
});
|
});
|
||||||
function updateAttachBadge() {
|
function updateAttachBadge() {
|
||||||
@@ -2126,10 +2128,10 @@ async function init() {
|
|||||||
$(window).on("resize", () => {
|
$(window).on("resize", () => {
|
||||||
hideThreadPopover();
|
hideThreadPopover();
|
||||||
hideSunePopover();
|
hideSunePopover();
|
||||||
hideSuneSyncPopover();
|
hideSunesSyncPopover();
|
||||||
});
|
});
|
||||||
$(document).on("click", (e) => {
|
$(document).on("click", (e) => {
|
||||||
if (el.suneSyncPopover && !el.suneSyncPopover.classList.contains("hidden") && !el.suneSyncPopover.contains(e.target) && !el.suneSyncBtn.contains(e.target)) hideSuneSyncPopover();
|
if (el.sunesSyncPopover && !el.sunesSyncPopover.classList.contains("hidden") && !el.sunesSyncPopover.contains(e.target) && !el.suneSyncBtn.contains(e.target)) hideSunesSyncPopover();
|
||||||
});
|
});
|
||||||
var htmlTabs = {
|
var htmlTabs = {
|
||||||
index: ["htmlTab_index", "htmlEditor"],
|
index: ["htmlTab_index", "htmlEditor"],
|
||||||
@@ -2350,13 +2352,16 @@ var performSuneDownload = async (isAuto = false, prefData = null, prefSha = null
|
|||||||
if (Array.isArray(data.sunes)) {
|
if (Array.isArray(data.sunes)) {
|
||||||
sunes = data.sunes.map(makeSune);
|
sunes = data.sunes.map(makeSune);
|
||||||
su.save(sunes);
|
su.save(sunes);
|
||||||
if (data.activeId) SUNE.setActive(data.activeId);
|
const nextActive = data.activeId || (sunes.some((s) => s.id === su.getActiveId()) ? su.getActiveId() : sunes[0]?.id);
|
||||||
|
if (nextActive) SUNE.setActive(nextActive);
|
||||||
}
|
}
|
||||||
if (data.storage && typeof data.storage === "object") {
|
if (data.storage && typeof data.storage === "object") {
|
||||||
Object.keys(localStorage).forEach((k) => {
|
Object.keys(localStorage).forEach((k) => {
|
||||||
if (k.startsWith("sune_")) localStorage.removeItem(k);
|
if (isSuneStorageKey(k)) localStorage.removeItem(k);
|
||||||
|
});
|
||||||
|
Object.entries(data.storage).forEach(([k, v]) => {
|
||||||
|
if (isSuneStorageKey(k)) localStorage.setItem(k, v);
|
||||||
});
|
});
|
||||||
Object.entries(data.storage).forEach(([k, v]) => localStorage.setItem(k, v));
|
|
||||||
}
|
}
|
||||||
setLocalSunesUpdatedAt(num(data.updatedAt, Date.now()));
|
setLocalSunesUpdatedAt(num(data.updatedAt, Date.now()));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2379,7 +2384,6 @@ var performSuneUpload = async () => {
|
|||||||
const info = parseGhUrl(u);
|
const info = parseGhUrl(u);
|
||||||
try {
|
try {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
setLocalSunesUpdatedAt(now);
|
|
||||||
const data = {
|
const data = {
|
||||||
version: 1,
|
version: 1,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
@@ -2394,12 +2398,14 @@ var performSuneUpload = async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
const x = await ghApi(`${info.apiPath}/sunes.json?ref=${info.branch}`);
|
const x = await ghApi(`${info.apiPath}/sunes.json?ref=${info.branch}`);
|
||||||
(await ghApi(`${info.apiPath}/sunes.json`, "PUT", {
|
const res = await ghApi(`${info.apiPath}/sunes.json`, "PUT", {
|
||||||
message: "Sync Sunes",
|
message: "Sync Sunes",
|
||||||
content: utob(JSON.stringify(data, null, 2)),
|
content: utob(JSON.stringify(data, null, 2)),
|
||||||
branch: info.branch,
|
branch: info.branch,
|
||||||
sha: x?.sha
|
sha: x?.sha
|
||||||
}))?.content?.sha;
|
});
|
||||||
|
setLocalSunesUpdatedAt(now);
|
||||||
|
res?.content?.sha;
|
||||||
setSuneSyncStatus("synced");
|
setSuneSyncStatus("synced");
|
||||||
alert("Sunes pushed.");
|
alert("Sunes pushed.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -2414,7 +2420,7 @@ $(el.suneRepoInput).on("change", () => {
|
|||||||
$(el.suneSyncBtn).on("click", (e) => {
|
$(el.suneSyncBtn).on("click", (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!el.suneRepoInput.value.trim().startsWith("gh://")) return;
|
if (!el.suneRepoInput.value.trim().startsWith("gh://")) return;
|
||||||
showSuneSyncPopover(el.suneSyncBtn);
|
showSunesSyncPopover(el.suneSyncBtn);
|
||||||
});
|
});
|
||||||
$(el.sidebarBtnLeft).on("click", () => {
|
$(el.sidebarBtnLeft).on("click", () => {
|
||||||
if (el.suneRepoInput.value.trim().startsWith("gh://")) checkSuneSyncStatus();
|
if (el.suneRepoInput.value.trim().startsWith("gh://")) checkSuneSyncStatus();
|
||||||
@@ -2737,6 +2743,8 @@ Object.assign(window, {
|
|||||||
showSunePopover,
|
showSunePopover,
|
||||||
hideSuneSyncPopover,
|
hideSuneSyncPopover,
|
||||||
showSuneSyncPopover,
|
showSuneSyncPopover,
|
||||||
|
hideSunesSyncPopover,
|
||||||
|
showSunesSyncPopover,
|
||||||
setSuneSyncStatus,
|
setSuneSyncStatus,
|
||||||
checkSuneSyncStatus,
|
checkSuneSyncStatus,
|
||||||
performSuneDownload,
|
performSuneDownload,
|
||||||
10
dist/index.html
vendored
10
dist/index.html
vendored
@@ -13,7 +13,7 @@
|
|||||||
<script defer src="//unpkg.com/alpinejs"></script>
|
<script defer src="//unpkg.com/alpinejs"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type="module" crossorigin src="/assets/index-CIiJlteO.js"></script>
|
<script type="module" crossorigin src="/assets/index-TjHmRKFx.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DUC1RW1F.css">
|
<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>
|
<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')">
|
<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,7 +42,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</div>
|
</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>
|
<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();hideSunesSyncPopover()"></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">
|
<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">
|
<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"/>
|
<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"/>
|
||||||
@@ -94,9 +94,9 @@
|
|||||||
<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="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>
|
<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>
|
||||||
<div id="suneSyncPopover" class="menu-card hidden">
|
<div id="sunesSyncPopover" 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="sunesSyncUploadBtn" 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>
|
<button id="sunesSyncDownloadBtn" class="menu-item"><i data-lucide="download-cloud" class="h-4 w-4"></i><span>Download from GitHub</span></button>
|
||||||
</div>
|
</div>
|
||||||
<div id="suneModal" class="hidden fixed inset-0 z-50">
|
<div id="suneModal" class="hidden fixed inset-0 z-50">
|
||||||
<div class="absolute inset-0 bg-black/30"></div>
|
<div class="absolute inset-0 bg-black/30"></div>
|
||||||
|
|||||||
2
dist/sw.js
vendored
2
dist/sw.js
vendored
@@ -1 +1 @@
|
|||||||
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} didn’t 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")))});
|
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} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),c={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>c[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"a64ac52329387d11ea67cf7b0a2b461d"},{url:"assets/index-TjHmRKFx.js",revision:null},{url:"assets/index-DUC1RW1F.css",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ export const el = window.el = Object.fromEntries(
|
|||||||
'importAccountSettingsInput','accountTabUser','accountPanelUser','set_user_name',
|
'importAccountSettingsInput','accountTabUser','accountPanelUser','set_user_name',
|
||||||
'userAvatarPreview','setUserAvatarBtn','userAvatarInput','threadRepoInput','threadBackBtn',
|
'userAvatarPreview','setUserAvatarBtn','userAvatarInput','threadRepoInput','threadBackBtn',
|
||||||
'threadFolderBtn','threadSyncBtn','suneRepoInput','suneSyncBtn',
|
'threadFolderBtn','threadSyncBtn','suneRepoInput','suneSyncBtn',
|
||||||
'suneSyncBadge','suneSyncPopover','suneSyncUploadBtn','suneSyncDownloadBtn'
|
'suneSyncBadge','sunesSyncPopover','sunesSyncUploadBtn','sunesSyncDownloadBtn'
|
||||||
].map(id => [id, document.getElementById(id)])
|
].map(id => [id, document.getElementById(id)])
|
||||||
);
|
);
|
||||||
|
|||||||
31
src/main.js
31
src/main.js
@@ -25,9 +25,10 @@ let isSyncPulling=false,suneSyncStatus='idle',remoteSha=null;
|
|||||||
const getLocalSunesUpdatedAt=()=>num(localStorage.getItem('sunes_updated_at'),0);
|
const getLocalSunesUpdatedAt=()=>num(localStorage.getItem('sunes_updated_at'),0);
|
||||||
const setLocalSunesUpdatedAt=(ts=Date.now())=>localStorage.setItem('sunes_updated_at',ts);
|
const setLocalSunesUpdatedAt=(ts=Date.now())=>localStorage.setItem('sunes_updated_at',ts);
|
||||||
const markLocalDirty=()=>{if(isSyncPulling)return;setLocalSunesUpdatedAt();setSuneSyncStatus('desynced')};
|
const markLocalDirty=()=>{if(isSyncPulling)return;setLocalSunesUpdatedAt();setSuneSyncStatus('desynced')};
|
||||||
|
const isSuneStorageKey=k=>!SYSTEM_KEYS.has(k)&&/^sune_[^_]+_/.test(k);
|
||||||
const _origSetItem=localStorage.setItem.bind(localStorage),_origRemoveItem=localStorage.removeItem.bind(localStorage);
|
const _origSetItem=localStorage.setItem.bind(localStorage),_origRemoveItem=localStorage.removeItem.bind(localStorage);
|
||||||
localStorage.setItem=(k,v)=>{_origSetItem(k,v);if(!isSyncPulling&&k.startsWith('sune_'))markLocalDirty()};
|
localStorage.setItem=(k,v)=>{_origSetItem(k,v);if(!isSyncPulling&&isSuneStorageKey(k))markLocalDirty()};
|
||||||
localStorage.removeItem=k=>{_origRemoveItem(k);if(!isSyncPulling&&k.startsWith('sune_'))markLocalDirty()};
|
localStorage.removeItem=k=>{_origRemoveItem(k);if(!isSyncPulling&&isSuneStorageKey(k))markLocalDirty()};
|
||||||
|
|
||||||
function setSuneSyncStatus(status){
|
function setSuneSyncStatus(status){
|
||||||
suneSyncStatus=status;
|
suneSyncStatus=status;
|
||||||
@@ -96,8 +97,9 @@ let menuThreadId=null;const hideThreadPopover=()=>{el.threadPopover.classList.ad
|
|||||||
function showThreadPopover(btn,id){menuThreadId=id;el.threadPopover.classList.remove('hidden');positionPopover(btn,el.threadPopover);icons()}
|
function showThreadPopover(btn,id){menuThreadId=id;el.threadPopover.classList.remove('hidden');positionPopover(btn,el.threadPopover);icons()}
|
||||||
let menuSuneId=null;const hideSunePopover=()=>{el.sunePopover.classList.add('hidden');menuSuneId=null}
|
let menuSuneId=null;const hideSunePopover=()=>{el.sunePopover.classList.add('hidden');menuSuneId=null}
|
||||||
function showSunePopover(btn,id){menuSuneId=id;el.sunePopover.classList.remove('hidden');positionPopover(btn,el.sunePopover);icons()}
|
function showSunePopover(btn,id){menuSuneId=id;el.sunePopover.classList.remove('hidden');positionPopover(btn,el.sunePopover);icons()}
|
||||||
const hideSuneSyncPopover=()=>{el.suneSyncPopover.classList.add('hidden')}
|
const hideSunesSyncPopover=()=>{el.sunesSyncPopover.classList.add('hidden')},hideSuneSyncPopover=hideSunesSyncPopover;
|
||||||
function showSuneSyncPopover(btn){el.suneSyncPopover.classList.remove('hidden');positionPopover(btn||el.suneSyncBtn,el.suneSyncPopover);icons()}
|
function showSunesSyncPopover(btn){el.sunesSyncPopover.classList.remove('hidden');positionPopover(btn||el.suneSyncBtn,el.sunesSyncPopover);icons()}
|
||||||
|
const showSuneSyncPopover=showSunesSyncPopover;
|
||||||
$(el.threadList).on('click',async e=>{const openBtn=e.target.closest('[data-open-thread]'),menuBtn=e.target.closest('[data-thread-menu]');if(openBtn){const id=openBtn.getAttribute('data-open-thread'),type=openBtn.getAttribute('data-type');if(type==='file'){const u=el.threadRepoInput.value.trim();if(u.startsWith('gh://')){const info=parseGhUrl(u);window.open(`https://github.com/${info.owner}/${info.repo}/blob/${info.branch}/${id}`,'_blank')}return}if(type==='folder'){const u=el.threadRepoInput.value.trim();el.threadRepoInput.value=u+(u.endsWith('/')?'':'/')+id;el.threadRepoInput.dispatchEvent(new Event('change'));return}if(id!==state.currentThreadId&&state.busy){state.controller?.disconnect?.();setBtnSend();state.busy=false;state.controller=null}const th=THREAD.get(id);if(!th)return;if(id===state.currentThreadId){el.sidebarRight.classList.add('translate-x-full');el.sidebarOverlayRight.classList.add('hidden');hideThreadPopover();return}state.currentThreadId=id;clearChat();const u=el.threadRepoInput.value.trim(),prefix=u.startsWith('gh://')?'rem_t_':'t_';let msgs=await localforage.getItem(prefix+id);if((!msgs||!Array.isArray(msgs)||!msgs.length)&&u.startsWith('gh://')){try{const info=parseGhUrl(u),fileName=serializeThreadName(th),text=await ghGetFileContent(info,fileName);if(text){try{msgs=JSON.parse(text);await localforage.setItem(prefix+id,msgs);th.status='synced';await THREAD.save()}catch(pe){console.error('[Sune] Thread JSON parse failed for',fileName,'len',text.length,pe)}}else{console.warn('[Sune] Remote thread returned no content:',fileName)}}catch(e){console.error('[Sune] Remote fetch failed',e)}}state.messages=Array.isArray(msgs)?[...msgs]:[];for(const m of state.messages){const b=msgRow(m);b.dataset.mid=m.id||'';renderMarkdown(b,partsToText(m))}await renderSuneHTML();syncWhileBusy();queueMicrotask(()=>el.chat.scrollTo({top:el.chat.scrollHeight,behavior:'smooth'}));el.sidebarRight.classList.add('translate-x-full');el.sidebarOverlayRight.classList.add('hidden');hideThreadPopover();return}if(menuBtn){e.stopPropagation();showThreadPopover(menuBtn,menuBtn.getAttribute('[data-thread-menu]')?menuBtn.getAttribute('[data-thread-menu]'):menuBtn.getAttribute('data-thread-menu'))}})
|
$(el.threadList).on('click',async e=>{const openBtn=e.target.closest('[data-open-thread]'),menuBtn=e.target.closest('[data-thread-menu]');if(openBtn){const id=openBtn.getAttribute('data-open-thread'),type=openBtn.getAttribute('data-type');if(type==='file'){const u=el.threadRepoInput.value.trim();if(u.startsWith('gh://')){const info=parseGhUrl(u);window.open(`https://github.com/${info.owner}/${info.repo}/blob/${info.branch}/${id}`,'_blank')}return}if(type==='folder'){const u=el.threadRepoInput.value.trim();el.threadRepoInput.value=u+(u.endsWith('/')?'':'/')+id;el.threadRepoInput.dispatchEvent(new Event('change'));return}if(id!==state.currentThreadId&&state.busy){state.controller?.disconnect?.();setBtnSend();state.busy=false;state.controller=null}const th=THREAD.get(id);if(!th)return;if(id===state.currentThreadId){el.sidebarRight.classList.add('translate-x-full');el.sidebarOverlayRight.classList.add('hidden');hideThreadPopover();return}state.currentThreadId=id;clearChat();const u=el.threadRepoInput.value.trim(),prefix=u.startsWith('gh://')?'rem_t_':'t_';let msgs=await localforage.getItem(prefix+id);if((!msgs||!Array.isArray(msgs)||!msgs.length)&&u.startsWith('gh://')){try{const info=parseGhUrl(u),fileName=serializeThreadName(th),text=await ghGetFileContent(info,fileName);if(text){try{msgs=JSON.parse(text);await localforage.setItem(prefix+id,msgs);th.status='synced';await THREAD.save()}catch(pe){console.error('[Sune] Thread JSON parse failed for',fileName,'len',text.length,pe)}}else{console.warn('[Sune] Remote thread returned no content:',fileName)}}catch(e){console.error('[Sune] Remote fetch failed',e)}}state.messages=Array.isArray(msgs)?[...msgs]:[];for(const m of state.messages){const b=msgRow(m);b.dataset.mid=m.id||'';renderMarkdown(b,partsToText(m))}await renderSuneHTML();syncWhileBusy();queueMicrotask(()=>el.chat.scrollTo({top:el.chat.scrollHeight,behavior:'smooth'}));el.sidebarRight.classList.add('translate-x-full');el.sidebarOverlayRight.classList.add('hidden');hideThreadPopover();return}if(menuBtn){e.stopPropagation();showThreadPopover(menuBtn,menuBtn.getAttribute('[data-thread-menu]')?menuBtn.getAttribute('[data-thread-menu]'):menuBtn.getAttribute('data-thread-menu'))}})
|
||||||
$(el.threadList).on('scroll',()=>{
|
$(el.threadList).on('scroll',()=>{
|
||||||
if(isAddingThreads||el.threadList.scrollTop+el.threadList.clientHeight<el.threadList.scrollHeight-200)return;
|
if(isAddingThreads||el.threadList.scrollTop+el.threadList.clientHeight<el.threadList.scrollHeight-200)return;
|
||||||
@@ -114,8 +116,8 @@ $(el.threadList).on('scroll',()=>{
|
|||||||
$(el.threadPopover).on('click',async e=>{const act=e.target.closest('[data-action]')?.getAttribute('data-action');if(!act||!menuThreadId)return;const th=THREAD.get(menuThreadId);if(!th)return;const u=el.threadRepoInput.value.trim(),prefix=u.startsWith('gh://')?'rem_t_':'t_';if(act==='pin'){th.pinned=!th.pinned;if(u.startsWith('gh://')&&th.status!=='new')th.status='modified'}else if(act==='rename'){const nv=prompt('Rename to:',th.title);if(nv!=null){th.title=titleFrom(nv);th.updatedAt=Date.now();if(u.startsWith('gh://')&&th.status!=='new')th.status='modified'}}else if(act==='duplicate'){const newId=gid(),msgs=await localforage.getItem(prefix+th.id)||[];const newTh={...th,id:newId,title:th.title+' (Copy)',updatedAt:Date.now()};if(u.startsWith('gh://'))newTh.status='new';THREAD.list.unshift(newTh);await localforage.setItem(prefix+newId,msgs);await THREAD.save();await renderThreads()}else if(act==='delete'){if(confirm('Delete this chat?')){if(u.startsWith('gh://')){th.status='deleted';th.updatedAt=Date.now()}else{THREAD.list=THREAD.list.filter(x=>!th.id!==th.id);await localforage.removeItem(prefix+th.id)}if(state.currentThreadId===th.id){state.currentThreadId=null;clearChat()}}}else if(act==='count_tokens'){const msgs=await localforage.getItem(prefix+th.id)||[];let totalChars=0;for(const m of msgs){if(!m||!m.role||m.role==='system')continue;totalChars+=String(partsToText(m)||'').length}const tokens=Math.max(0,Math.ceil(totalChars/4));const k=tokens>=1000?Math.round(tokens/1000)+'k':String(tokens);alert(tokens+' tokens ('+k+')')}else if(act==='export'){const msgs=await localforage.getItem(prefix+th.id)||[];dl(`thread-${(th.title||'thread').replace(/\W/g,'_')}-${ts()}.json`,{...th,messages:msgs})}else if(act==='copy_path'){const u=el.threadRepoInput.value.trim();if(u.startsWith('gh://')){const info=parseGhUrl(u);if(await copyToClipboard(`${info.owner}/${info.repo}@${info.branch}/${th.id}`))alert('Path copied.')}}hideThreadPopover();await THREAD.save();renderThreads()})
|
$(el.threadPopover).on('click',async e=>{const act=e.target.closest('[data-action]')?.getAttribute('data-action');if(!act||!menuThreadId)return;const th=THREAD.get(menuThreadId);if(!th)return;const u=el.threadRepoInput.value.trim(),prefix=u.startsWith('gh://')?'rem_t_':'t_';if(act==='pin'){th.pinned=!th.pinned;if(u.startsWith('gh://')&&th.status!=='new')th.status='modified'}else if(act==='rename'){const nv=prompt('Rename to:',th.title);if(nv!=null){th.title=titleFrom(nv);th.updatedAt=Date.now();if(u.startsWith('gh://')&&th.status!=='new')th.status='modified'}}else if(act==='duplicate'){const newId=gid(),msgs=await localforage.getItem(prefix+th.id)||[];const newTh={...th,id:newId,title:th.title+' (Copy)',updatedAt:Date.now()};if(u.startsWith('gh://'))newTh.status='new';THREAD.list.unshift(newTh);await localforage.setItem(prefix+newId,msgs);await THREAD.save();await renderThreads()}else if(act==='delete'){if(confirm('Delete this chat?')){if(u.startsWith('gh://')){th.status='deleted';th.updatedAt=Date.now()}else{THREAD.list=THREAD.list.filter(x=>!th.id!==th.id);await localforage.removeItem(prefix+th.id)}if(state.currentThreadId===th.id){state.currentThreadId=null;clearChat()}}}else if(act==='count_tokens'){const msgs=await localforage.getItem(prefix+th.id)||[];let totalChars=0;for(const m of msgs){if(!m||!m.role||m.role==='system')continue;totalChars+=String(partsToText(m)||'').length}const tokens=Math.max(0,Math.ceil(totalChars/4));const k=tokens>=1000?Math.round(tokens/1000)+'k':String(tokens);alert(tokens+' tokens ('+k+')')}else if(act==='export'){const msgs=await localforage.getItem(prefix+th.id)||[];dl(`thread-${(th.title||'thread').replace(/\W/g,'_')}-${ts()}.json`,{...th,messages:msgs})}else if(act==='copy_path'){const u=el.threadRepoInput.value.trim();if(u.startsWith('gh://')){const info=parseGhUrl(u);if(await copyToClipboard(`${info.owner}/${info.repo}@${info.branch}/${th.id}`))alert('Path copied.')}}hideThreadPopover();await THREAD.save();renderThreads()})
|
||||||
$(el.suneList).on('click',async e=>{const menuBtn=e.target.closest('[data-sune-menu]');if(menuBtn){e.stopPropagation();showSunePopover(menuBtn,menuBtn.getAttribute('[data-sune-menu]')?menuBtn.getAttribute('[data-sune-menu]'):menuBtn.getAttribute('data-sune-menu'));return}const btn=e.target.closest('[data-sune-id]');if(!btn)return;const id=btn.getAttribute('data-sune-id');if(id){if(state.busy){state.controller?.disconnect?.();setBtnSend();state.busy=false;state.controller=null};SUNE.setActive(id);renderSidebar();await reflectActiveSune();state.currentThreadId=null;clearChat();document.getElementById('sidebarLeft').classList.add('-translate-x-full');document.getElementById('sidebarOverlayLeft').classList.add('hidden')}})
|
$(el.suneList).on('click',async e=>{const menuBtn=e.target.closest('[data-sune-menu]');if(menuBtn){e.stopPropagation();showSunePopover(menuBtn,menuBtn.getAttribute('[data-sune-menu]')?menuBtn.getAttribute('[data-sune-menu]'):menuBtn.getAttribute('data-sune-menu'));return}const btn=e.target.closest('[data-sune-id]');if(!btn)return;const id=btn.getAttribute('data-sune-id');if(id){if(state.busy){state.controller?.disconnect?.();setBtnSend();state.busy=false;state.controller=null};SUNE.setActive(id);renderSidebar();await reflectActiveSune();state.currentThreadId=null;clearChat();document.getElementById('sidebarLeft').classList.add('-translate-x-full');document.getElementById('sidebarOverlayLeft').classList.add('hidden')}})
|
||||||
$(el.sunePopover).on('click',async e=>{const act=e.target.closest('[data-action]')?.getAttribute('data-action');if(!act||!menuSuneId)return;const s=SUNE.get(menuSuneId);if(!s)return;const updateAndRender=async()=>{s.updatedAt=Date.now();SUNE.save();renderSidebar();await reflectActiveSune();markLocalDirty()};if(act==='pin'){s.pinned=!s.pinned;await updateAndRender()}else if(act==='rename'){const n=prompt('Rename sune to:',s.name);if(n!=null){s.name=n.trim();await updateAndRender()}}else if(act==='pfp'){const i=document.createElement('input');i.type='file';i.accept='image/*';i.onchange=async()=>{const f=i.files?.[0];if(!f)return;try{s.avatar=await imgToWebp(f);await updateAndRender()}catch{}};i.click()}else if(act==='export')dl(`sune-${(s.name||'sune').replace(/\W/g,'_')}-${ts()}.sune`,[s]);hideSunePopover()})
|
$(el.sunePopover).on('click',async e=>{const act=e.target.closest('[data-action]')?.getAttribute('data-action');if(!act||!menuSuneId)return;const s=SUNE.get(menuSuneId);if(!s)return;const updateAndRender=async()=>{s.updatedAt=Date.now();SUNE.save();renderSidebar();await reflectActiveSune();markLocalDirty()};if(act==='pin'){s.pinned=!s.pinned;await updateAndRender()}else if(act==='rename'){const n=prompt('Rename sune to:',s.name);if(n!=null){s.name=n.trim();await updateAndRender()}}else if(act==='pfp'){const i=document.createElement('input');i.type='file';i.accept='image/*';i.onchange=async()=>{const f=i.files?.[0];if(!f)return;try{s.avatar=await imgToWebp(f);await updateAndRender()}catch{}};i.click()}else if(act==='export')dl(`sune-${(s.name||'sune').replace(/\W/g,'_')}-${ts()}.sune`,[s]);hideSunePopover()})
|
||||||
$(el.suneSyncUploadBtn).on('click',()=>{hideSuneSyncPopover();performSuneUpload()});
|
$(el.sunesSyncUploadBtn).on('click',()=>{hideSunesSyncPopover();performSuneUpload()});
|
||||||
$(el.suneSyncDownloadBtn).on('click',()=>{hideSuneSyncPopover();performSuneDownload(false)});
|
$(el.sunesSyncDownloadBtn).on('click',()=>{hideSunesSyncPopover();performSuneDownload(false)});
|
||||||
function updateAttachBadge(){const n=state.attachments.length;el.attachBadge.textContent=String(n);el.attachBadge.classList.toggle('hidden',n===0)}
|
function updateAttachBadge(){const n=state.attachments.length;el.attachBadge.textContent=String(n);el.attachBadge.classList.toggle('hidden',n===0)}
|
||||||
$(el.attachBtn).on('click',()=>{if(state.busy)return;if(state.attachments.length){state.attachments=[];updateAttachBadge();el.fileInput.value=''};el.fileInput.click()})
|
$(el.attachBtn).on('click',()=>{if(state.busy)return;if(state.attachments.length){state.attachments=[];updateAttachBadge();el.fileInput.value=''};el.fileInput.click()})
|
||||||
$(el.fileInput).on('change',async()=>{const files=[...(el.fileInput.files||[])];if(!files.length)return;for(const f of files){const at=await toAttach(f).catch(()=>null);if(at)state.attachments.push(at)}updateAttachBadge()})
|
$(el.fileInput).on('change',async()=>{const files=[...(el.fileInput.files||[])];if(!files.length)return;for(const f of files){const at=await toAttach(f).catch(()=>null);if(at)state.attachments.push(at)}updateAttachBadge()})
|
||||||
@@ -185,8 +187,8 @@ USER.logMany = async msgs => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function init(){gcStorage();const u=localStorage.getItem('thread_repo_url')||'',suR=localStorage.getItem('sune_repo_url')||'';el.threadRepoInput.value=u;el.suneRepoInput.value=suR;el.threadFolderBtn.classList.toggle('hidden',!u.startsWith('gh://'));el.threadBackBtn.classList.toggle('hidden',!u.startsWith('gh://')||u.split('/').length<=3);await THREAD.load();await renderThreads();await Promise.allSettled(STICKY_SUNES.map(s=>SUNE.fetchDotSune(s)));renderSidebar();renderUserUI();await reflectActiveSune();if(suR.startsWith('gh://'))checkSuneSyncStatus();clearChat();icons();kbBind();kbUpdate()}
|
async function init(){gcStorage();const u=localStorage.getItem('thread_repo_url')||'',suR=localStorage.getItem('sune_repo_url')||'';el.threadRepoInput.value=u;el.suneRepoInput.value=suR;el.threadFolderBtn.classList.toggle('hidden',!u.startsWith('gh://'));el.threadBackBtn.classList.toggle('hidden',!u.startsWith('gh://')||u.split('/').length<=3);await THREAD.load();await renderThreads();await Promise.allSettled(STICKY_SUNES.map(s=>SUNE.fetchDotSune(s)));renderSidebar();renderUserUI();await reflectActiveSune();if(suR.startsWith('gh://'))checkSuneSyncStatus();clearChat();icons();kbBind();kbUpdate()}
|
||||||
$(window).on('resize',()=>{hideThreadPopover();hideSunePopover();hideSuneSyncPopover()})
|
$(window).on('resize',()=>{hideThreadPopover();hideSunePopover();hideSunesSyncPopover()})
|
||||||
$(document).on('click',e=>{if(el.suneSyncPopover&&!el.suneSyncPopover.classList.contains('hidden')&&!el.suneSyncPopover.contains(e.target)&&!el.suneSyncBtn.contains(e.target))hideSuneSyncPopover()});
|
$(document).on('click',e=>{if(el.sunesSyncPopover&&!el.sunesSyncPopover.classList.contains('hidden')&&!el.sunesSyncPopover.contains(e.target)&&!el.suneSyncBtn.contains(e.target))hideSunesSyncPopover()});
|
||||||
const htmlTabs={index:['htmlTab_index','htmlEditor'],extension:['htmlTab_extension','extensionHtmlEditor']};function showHtmlTab(key){Object.entries(htmlTabs).forEach(([k,[tb,pn]])=>{const a=k===key;el[tb].classList.toggle('border-black',a);el[tb].classList.toggle('border-transparent',!a);el[tb].classList.toggle('hover:border-gray-300',!a);el[pn].classList.toggle('hidden',!a)})}
|
const htmlTabs={index:['htmlTab_index','htmlEditor'],extension:['htmlTab_extension','extensionHtmlEditor']};function showHtmlTab(key){Object.entries(htmlTabs).forEach(([k,[tb,pn]])=>{const a=k===key;el[tb].classList.toggle('border-black',a);el[tb].classList.toggle('border-transparent',!a);el[tb].classList.toggle('hover:border-gray-300',!a);el[pn].classList.toggle('hidden',!a)})}
|
||||||
el.htmlTab_index.textContent='index.html';el.htmlTab_extension.textContent='extension.html';
|
el.htmlTab_index.textContent='index.html';el.htmlTab_extension.textContent='extension.html';
|
||||||
el.htmlTab_index.onclick=()=>showHtmlTab('index');el.htmlTab_extension.onclick=()=>showHtmlTab('extension');
|
el.htmlTab_index.onclick=()=>showHtmlTab('index');el.htmlTab_extension.onclick=()=>showHtmlTab('extension');
|
||||||
@@ -251,11 +253,12 @@ const performSuneDownload=async(isAuto=false,prefData=null,prefSha=null)=>{
|
|||||||
if(Array.isArray(data.sunes)){
|
if(Array.isArray(data.sunes)){
|
||||||
sunes=data.sunes.map(makeSune);
|
sunes=data.sunes.map(makeSune);
|
||||||
su.save(sunes);
|
su.save(sunes);
|
||||||
if(data.activeId)SUNE.setActive(data.activeId);
|
const nextActive=data.activeId||(sunes.some(s=>s.id===su.getActiveId())?su.getActiveId():sunes[0]?.id);
|
||||||
|
if(nextActive)SUNE.setActive(nextActive);
|
||||||
}
|
}
|
||||||
if(data.storage&&typeof data.storage==='object'){
|
if(data.storage&&typeof data.storage==='object'){
|
||||||
Object.keys(localStorage).forEach(k=>{if(k.startsWith('sune_'))localStorage.removeItem(k)});
|
Object.keys(localStorage).forEach(k=>{if(isSuneStorageKey(k))localStorage.removeItem(k)});
|
||||||
Object.entries(data.storage).forEach(([k,v])=>localStorage.setItem(k,v));
|
Object.entries(data.storage).forEach(([k,v])=>{if(isSuneStorageKey(k))localStorage.setItem(k,v)});
|
||||||
}
|
}
|
||||||
setLocalSunesUpdatedAt(num(data.updatedAt,Date.now()));
|
setLocalSunesUpdatedAt(num(data.updatedAt,Date.now()));
|
||||||
remoteSha=sha;
|
remoteSha=sha;
|
||||||
@@ -280,7 +283,6 @@ const performSuneUpload=async()=>{
|
|||||||
const info=parseGhUrl(u);
|
const info=parseGhUrl(u);
|
||||||
try{
|
try{
|
||||||
const now=Date.now();
|
const now=Date.now();
|
||||||
setLocalSunesUpdatedAt(now);
|
|
||||||
const data={version:1,updatedAt:now,sunes:SUNE.list,activeId:SUNE.id,storage:{}};
|
const data={version:1,updatedAt:now,sunes:SUNE.list,activeId:SUNE.id,storage:{}};
|
||||||
SUNE.list.forEach(s=>{
|
SUNE.list.forEach(s=>{
|
||||||
const p=`sune_${s.id}_`;
|
const p=`sune_${s.id}_`;
|
||||||
@@ -293,6 +295,7 @@ const performSuneUpload=async()=>{
|
|||||||
branch:info.branch,
|
branch:info.branch,
|
||||||
sha:x?.sha
|
sha:x?.sha
|
||||||
});
|
});
|
||||||
|
setLocalSunesUpdatedAt(now);
|
||||||
remoteSha=res?.content?.sha||null;
|
remoteSha=res?.content?.sha||null;
|
||||||
setSuneSyncStatus('synced');
|
setSuneSyncStatus('synced');
|
||||||
alert('Sunes pushed.');
|
alert('Sunes pushed.');
|
||||||
@@ -310,7 +313,7 @@ $(el.suneSyncBtn).on('click',e=>{
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const u=el.suneRepoInput.value.trim();
|
const u=el.suneRepoInput.value.trim();
|
||||||
if(!u.startsWith('gh://'))return;
|
if(!u.startsWith('gh://'))return;
|
||||||
showSuneSyncPopover(el.suneSyncBtn);
|
showSunesSyncPopover(el.suneSyncBtn);
|
||||||
});
|
});
|
||||||
$(el.sidebarBtnLeft).on('click',()=>{
|
$(el.sidebarBtnLeft).on('click',()=>{
|
||||||
if(el.suneRepoInput.value.trim().startsWith('gh://'))checkSuneSyncStatus();
|
if(el.suneRepoInput.value.trim().startsWith('gh://'))checkSuneSyncStatus();
|
||||||
@@ -343,4 +346,4 @@ const getActiveJar=()=>!el.htmlEditor.classList.contains('hidden')?jars.html:jar
|
|||||||
$(el.copyHTML).on('click',async()=>{const jar=getActiveJar();await copyToClipboard(jar?jar.toString():'')})
|
$(el.copyHTML).on('click',async()=>{const jar=getActiveJar();await copyToClipboard(jar?jar.toString():'')})
|
||||||
$(el.pasteHTML).on('click',async()=>{try{const t=await navigator.clipboard.readText();const jar=getActiveJar();if(jar)jar.updateCode(t)}catch{}})
|
$(el.pasteHTML).on('click',async()=>{try{const t=await navigator.clipboard.readText();const jar=getActiveJar();if(jar)jar.updateCode(t)}catch{}})
|
||||||
|
|
||||||
Object.assign(window,{icons,haptic,clamp,num,int,gid,esc,positionPopover,sid,fmtSize,asDataURL,b64,makeSune,getModelShort,resolveSuneSrc,processSuneIncludes,renderSuneHTML,reflectActiveSune,suneRow,renderUserUI,enhanceCodeBlocks,getSuneLabel,_createMessageRow,msgRow,partsToText,copyToClipboard,addSuneBubbleStreaming,clearChat,payloadWithSampling,setBtnStop,setBtnSend,localDemoReply,titleFrom,serializeThreadName,deserializeThreadName,ensureThreadOnFirstUser,generateTitleWithAI,threadRow,renderThreads,hideThreadPopover,showThreadPopover,hideSunePopover,showSunePopover,hideSuneSyncPopover,showSuneSyncPopover,setSuneSyncStatus,checkSuneSyncStatus,performSuneDownload,performSuneUpload,updateAttachBadge,toAttach,ensureJars,openSettings,closeSettings,showTab,dl,ts,kbUpdate,kbBind,activeMeta,init,showHtmlTab,showAccountTab,openAccountSettings,closeAccountSettings,getBubbleById,syncActiveThread,syncWhileBusy,onForeground,getActiveJar,imgToWebp,cacheStore,ghApi,parseGhUrl,ghGetFileContent,pullThreads,suneStorage,gcStorage,cleanSuneStorage});
|
Object.assign(window,{icons,haptic,clamp,num,int,gid,esc,positionPopover,sid,fmtSize,asDataURL,b64,makeSune,getModelShort,resolveSuneSrc,processSuneIncludes,renderSuneHTML,reflectActiveSune,suneRow,renderUserUI,enhanceCodeBlocks,getSuneLabel,_createMessageRow,msgRow,partsToText,copyToClipboard,addSuneBubbleStreaming,clearChat,payloadWithSampling,setBtnStop,setBtnSend,localDemoReply,titleFrom,serializeThreadName,deserializeThreadName,ensureThreadOnFirstUser,generateTitleWithAI,threadRow,renderThreads,hideThreadPopover,showThreadPopover,hideSunePopover,showSunePopover,hideSuneSyncPopover,showSuneSyncPopover,hideSunesSyncPopover,showSunesSyncPopover,setSuneSyncStatus,checkSuneSyncStatus,performSuneDownload,performSuneUpload,updateAttachBadge,toAttach,ensureJars,openSettings,closeSettings,showTab,dl,ts,kbUpdate,kbBind,activeMeta,init,showHtmlTab,showAccountTab,openAccountSettings,closeAccountSettings,getBubbleById,syncActiveThread,syncWhileBusy,onForeground,getActiveJar,imgToWebp,cacheStore,ghApi,parseGhUrl,ghGetFileContent,pullThreads,suneStorage,gcStorage,cleanSuneStorage});
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
<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="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>
|
<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>
|
||||||
<div id="suneSyncPopover" class="menu-card hidden">
|
<div id="sunesSyncPopover" 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="sunesSyncUploadBtn" 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>
|
<button id="sunesSyncDownloadBtn" class="menu-item"><i data-lucide="download-cloud" class="h-4 w-4"></i><span>Download from GitHub</span></button>
|
||||||
</div>
|
</div>
|
||||||
<div id="suneModal" class="hidden fixed inset-0 z-50">
|
<div id="suneModal" class="hidden fixed inset-0 z-50">
|
||||||
<div class="absolute inset-0 bg-black/30"></div>
|
<div class="absolute inset-0 bg-black/30"></div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<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>
|
<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();hideSunesSyncPopover()"></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">
|
<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">
|
<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"/>
|
<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"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user