mirror of
https://github.com/multipleof4/sune.git
synced 2026-06-07 19:32:14 +00:00
This build was committed by a bot.
This commit is contained in:
@@ -526,6 +526,38 @@ var parseGhUrl = (u) => {
|
||||
apiPath: `${owner}/${repo}/contents${path ? "/" + path : ""}`
|
||||
};
|
||||
};
|
||||
var ghGetFileContent = async (info, fileName) => {
|
||||
const meta = await ghApi(`${info.apiPath}/${fileName}?ref=${info.branch}`);
|
||||
if (!meta) {
|
||||
console.warn("[Sune] GH file not found:", fileName);
|
||||
return null;
|
||||
}
|
||||
console.log("[Sune] GH file meta:", {
|
||||
name: fileName,
|
||||
size: meta.size,
|
||||
encoding: meta.encoding,
|
||||
hasContent: !!(meta.content && meta.content.trim()),
|
||||
sha: meta.sha
|
||||
});
|
||||
if (meta.content && meta.encoding === "base64") try {
|
||||
return btou(meta.content);
|
||||
} catch (e) {
|
||||
console.error("[Sune] decode (contents) failed:", e);
|
||||
}
|
||||
if (meta.sha) try {
|
||||
const blob = await ghApi(`${info.owner}/${info.repo}/git/blobs/${meta.sha}`);
|
||||
console.log("[Sune] GH blob:", {
|
||||
size: blob?.size,
|
||||
encoding: blob?.encoding,
|
||||
hasContent: !!(blob?.content && blob.content.trim())
|
||||
});
|
||||
if (blob && blob.content && blob.encoding === "base64") return btou(blob.content);
|
||||
} catch (e) {
|
||||
console.error("[Sune] blob fetch failed:", e);
|
||||
}
|
||||
console.warn("[Sune] Could not retrieve content for", fileName);
|
||||
return null;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/markdown.js
|
||||
var md = window.md = window.markdownit({
|
||||
@@ -1331,16 +1363,19 @@ $(el.threadList).on("click", async (e) => {
|
||||
clearChat();
|
||||
const u = el.threadRepoInput.value.trim(), prefix = u.startsWith("gh://") ? "rem_t_" : "t_";
|
||||
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));
|
||||
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("Remote fetch failed", e);
|
||||
console.error("[Sune] Remote fetch failed", e);
|
||||
}
|
||||
state.messages = Array.isArray(msgs) ? [...msgs] : [];
|
||||
for (const m of state.messages) {
|
||||
@@ -2385,6 +2420,7 @@ Object.assign(window, {
|
||||
cacheStore,
|
||||
ghApi,
|
||||
parseGhUrl,
|
||||
ghGetFileContent,
|
||||
pullThreads
|
||||
});
|
||||
//#endregion
|
||||
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -13,7 +13,7 @@
|
||||
<script defer src="//unpkg.com/alpinejs"></script>
|
||||
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-CyJ4d9Tf.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-Dkjswwpy.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DaGRC7Kr.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,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-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"6fb424e8125bb9d640d2dc5435d8abcf"},{url:"assets/index-DaGRC7Kr.css",revision:null},{url:"assets/index-CyJ4d9Tf.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:"c59f6739a7fe91142d3b8530653b2d5c"},{url:"assets/index-Dkjswwpy.js",revision:null},{url:"assets/index-DaGRC7Kr.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