mirror of
https://github.com/multipleof4/sune.git
synced 2026-02-04 01:57:55 +00:00
This build was committed by a bot.
This commit is contained in:
@@ -274,7 +274,18 @@ const imgToWebp = (f, D = 128, q = 80) => new Promise((r, j) => {
|
||||
i.src = URL.createObjectURL(f);
|
||||
});
|
||||
const b64 = (x) => x.split(",")[1] || "";
|
||||
const utob = (s) => btoa(unescape(encodeURIComponent(s)));
|
||||
const utob = (s) => btoa(unescape(encodeURIComponent(s))), btou = (s) => decodeURIComponent(escape(atob(s.replace(/\s/g, ""))));
|
||||
const ghApi = async (path, method = "GET", body = null) => {
|
||||
const t = USER.githubToken;
|
||||
if (!t) throw new Error("No GH token");
|
||||
const r = await fetch(`https://api.github.com/repos/${path}`, { method, headers: { "Authorization": `token ${t}`, "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json" }, body: body ? JSON.stringify(body) : null });
|
||||
if (!r.ok && r.status !== 404) throw new Error(`GH API ${r.status}`);
|
||||
return r.status === 404 ? null : r.json();
|
||||
};
|
||||
const parseGhUrl = (u) => {
|
||||
const p = u.substring(5).split("/"), owner = p[0], repoPart = p[1] || "", branch = repoPart.includes("@") ? repoPart.split("@")[1] : "main", repo = repoPart.split("@")[0], path = p.slice(2).join("/").replace(/\/$/, "");
|
||||
return { owner, repo, branch, path, apiPath: `${owner}/${repo}/contents${path ? "/" + path : ""}` };
|
||||
};
|
||||
const su = { key: "sunes_v1", activeKey: "active_sune_id", load() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(this.key) || "[]");
|
||||
@@ -773,7 +784,18 @@ $(el.threadList).on("click", async (e) => {
|
||||
state.currentThreadId = id;
|
||||
clearChat();
|
||||
const u = el.threadRepoInput.value.trim(), prefix = u.startsWith("gh://") ? "rem_t_" : "t_";
|
||||
const msgs = await localforage.getItem(prefix + id);
|
||||
let msgs = await localforage.getItem(prefix + id);
|
||||
if (!msgs && u.startsWith("gh://")) {
|
||||
try {
|
||||
const info = parseGhUrl(u), fileName = serializeThreadName(th), res = await ghApi(`${info.apiPath}/${fileName}?ref=${info.branch}`);
|
||||
if (res && res.content) {
|
||||
msgs = JSON.parse(btou(res.content));
|
||||
await localforage.setItem(prefix + id, msgs);
|
||||
}
|
||||
} catch (e2) {
|
||||
console.error("Remote fetch failed", e2);
|
||||
}
|
||||
}
|
||||
state.messages = Array.isArray(msgs) ? [...msgs] : [];
|
||||
for (const m of state.messages) {
|
||||
const b = msgRow(m);
|
||||
@@ -1379,17 +1401,6 @@ el.htmlTab_index.textContent = "index.html";
|
||||
el.htmlTab_extension.textContent = "extension.html";
|
||||
el.htmlTab_index.onclick = () => showHtmlTab("index");
|
||||
el.htmlTab_extension.onclick = () => showHtmlTab("extension");
|
||||
const ghApi = async (path, method = "GET", body = null) => {
|
||||
const t = USER.githubToken;
|
||||
if (!t) throw new Error("No GH token");
|
||||
const r = await fetch(`https://api.github.com/repos/${path}`, { method, headers: { "Authorization": `token ${t}`, "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json" }, body: body ? JSON.stringify(body) : null });
|
||||
if (!r.ok && r.status !== 404) throw new Error(`GH API ${r.status}`);
|
||||
return r.status === 404 ? null : r.json();
|
||||
};
|
||||
const parseGhUrl = (u) => {
|
||||
const p = u.substring(5).split("/"), owner = p[0], repoPart = p[1] || "", branch = repoPart.includes("@") ? repoPart.split("@")[1] : "main", repo = repoPart.split("@")[0], path = p.slice(2).join("/").replace(/\/$/, "");
|
||||
return { owner, repo, branch, path, apiPath: `${owner}/${repo}/contents${path ? "/" + path : ""}` };
|
||||
};
|
||||
$(el.threadRepoInput).on("change", async () => {
|
||||
const u = el.threadRepoInput.value.trim();
|
||||
localStorage.setItem("thread_repo_url", u);
|
||||
@@ -1409,6 +1420,7 @@ $(el.threadBackBtn).on("click", () => {
|
||||
if (p.length > 3) {
|
||||
p.pop();
|
||||
el.threadRepoInput.value = p.join("/");
|
||||
el.threadRepoInput.value = p.join("/");
|
||||
el.threadRepoInput.dispatchEvent(new Event("change"));
|
||||
}
|
||||
});
|
||||
@@ -1711,4 +1723,4 @@ $(el.pasteHTML).on("click", async () => {
|
||||
} catch {
|
||||
}
|
||||
});
|
||||
Object.assign(window, { icons, haptic, clamp, num, int, gid, esc, positionPopover, sid, fmtSize, asDataURL, b64, makeSune, getModelShort, resolveSuneSrc, processSuneIncludes, renderSuneHTML, reflectActiveSune, suneRow, enhanceCodeBlocks, getSuneLabel, _createMessageRow, msgRow, partsToText, addSuneBubbleStreaming, clearChat, payloadWithSampling, setBtnStop, setBtnSend, localDemoReply, titleFrom, serializeThreadName, deserializeThreadName, ensureThreadOnFirstUser, generateTitleWithAI, threadRow, renderThreads, hideThreadPopover, showThreadPopover, hideSunePopover, showSunePopover, updateAttachBadge, toAttach, ensureJars, openSettings, closeSettings, showTab, dl, ts, kbUpdate, kbBind, activeMeta, init, showHtmlTab, showAccountTab, openAccountSettings, closeAccountSettings, getBubbleById, syncActiveThread, syncWhileBusy, onForeground, getActiveHtmlParts, imgToWebp, cacheStore });
|
||||
Object.assign(window, { icons, haptic, clamp, num, int, gid, esc, positionPopover, sid, fmtSize, asDataURL, b64, makeSune, getModelShort, resolveSuneSrc, processSuneIncludes, renderSuneHTML, reflectActiveSune, suneRow, enhanceCodeBlocks, getSuneLabel, _createMessageRow, msgRow, partsToText, addSuneBubbleStreaming, clearChat, payloadWithSampling, setBtnStop, setBtnSend, localDemoReply, titleFrom, serializeThreadName, deserializeThreadName, ensureThreadOnFirstUser, generateTitleWithAI, threadRow, renderThreads, hideThreadPopover, showThreadPopover, hideSunePopover, showSunePopover, updateAttachBadge, toAttach, ensureJars, openSettings, closeSettings, showTab, dl, ts, kbUpdate, kbBind, activeMeta, init, showHtmlTab, showAccountTab, openAccountSettings, closeAccountSettings, getBubbleById, syncActiveThread, syncWhileBusy, onForeground, getActiveHtmlParts, imgToWebp, cacheStore, ghApi, parseGhUrl });
|
||||
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -12,7 +12,7 @@
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/cash-dom/dist/cash.min.js"></script>
|
||||
<script defer src="//unpkg.com/alpinejs"></script>
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-DiYgOCm5.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-ZFLC2W_P.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-JLEDB1oP.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')">
|
||||
|
||||
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,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(i[t])return;let o={};const c=e=>s(e,t),l={module:{uri:t},exports:o,require:c};i[t]=Promise.all(n.map(e=>l[e]||c(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"0bdb9c92bc46620107f6d34ba6a9bbae"},{url:"assets/index-JLEDB1oP.css",revision:null},{url:"assets/index-DiYgOCm5.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 d=e=>i(e,t),l={module:{uri:t},exports:o,require:d};s[t]=Promise.all(n.map(e=>l[e]||d(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"ee3a0cbe5bf8b1e5b886dbed2223626d"},{url:"assets/index-ZFLC2W_P.js",revision:null},{url:"assets/index-JLEDB1oP.css",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|
||||
|
||||
Reference in New Issue
Block a user