mirror of
https://github.com/multipleof4/sune.git
synced 2026-07-18 08:45:42 +00:00
Compare commits
7 Commits
ed5a2b84af
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33eab61d6c | ||
| 3f19e1964a | |||
|
|
1bb924d44c | ||
| f536e4f325 | |||
|
|
78732b902d | ||
| 5d832fd99c | |||
|
|
c7b58c37e1 |
@@ -526,6 +526,38 @@ var parseGhUrl = (u) => {
|
|||||||
apiPath: `${owner}/${repo}/contents${path ? "/" + path : ""}`
|
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
|
//#endregion
|
||||||
//#region src/markdown.js
|
//#region src/markdown.js
|
||||||
var md = window.md = window.markdownit({
|
var md = window.md = window.markdownit({
|
||||||
@@ -807,7 +839,7 @@ var __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|||||||
o != k && ((k = o) ? (history.pushState({ k: 1 }, ""), addEventListener("popstate", f)) : (removeEventListener("popstate", f), history.state?.k && history.back()));
|
o != k && ((k = o) ? (history.pushState({ k: 1 }, ""), addEventListener("popstate", f)) : (removeEventListener("popstate", f), history.state?.k && history.back()));
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
var DEFAULT_MODEL = "anthropic/claude-opus-4.7";
|
var DEFAULT_MODEL = "openrouter/free";
|
||||||
var icons = () => window.lucide && lucide.createIcons();
|
var icons = () => window.lucide && lucide.createIcons();
|
||||||
var haptic = () => /android/i.test(navigator.userAgent) && navigator.vibrate?.(1);
|
var haptic = () => /android/i.test(navigator.userAgent) && navigator.vibrate?.(1);
|
||||||
var su = {
|
var su = {
|
||||||
@@ -1331,16 +1363,19 @@ $(el.threadList).on("click", async (e) => {
|
|||||||
clearChat();
|
clearChat();
|
||||||
const u = el.threadRepoInput.value.trim(), prefix = u.startsWith("gh://") ? "rem_t_" : "t_";
|
const u = el.threadRepoInput.value.trim(), prefix = u.startsWith("gh://") ? "rem_t_" : "t_";
|
||||||
let msgs = await localforage.getItem(prefix + id);
|
let msgs = await localforage.getItem(prefix + id);
|
||||||
if (!msgs && u.startsWith("gh://")) try {
|
if ((!msgs || !Array.isArray(msgs) || !msgs.length) && u.startsWith("gh://")) try {
|
||||||
const info = parseGhUrl(u), fileName = serializeThreadName(th), res = await ghApi(`${info.apiPath}/${fileName}?ref=${info.branch}`);
|
const info = parseGhUrl(u), fileName = serializeThreadName(th), text = await ghGetFileContent(info, fileName);
|
||||||
if (res && res.content) {
|
if (text) try {
|
||||||
msgs = JSON.parse(btou(res.content));
|
msgs = JSON.parse(text);
|
||||||
await localforage.setItem(prefix + id, msgs);
|
await localforage.setItem(prefix + id, msgs);
|
||||||
th.status = "synced";
|
th.status = "synced";
|
||||||
await THREAD.save();
|
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) {
|
} catch (e) {
|
||||||
console.error("Remote fetch failed", e);
|
console.error("[Sune] Remote fetch failed", e);
|
||||||
}
|
}
|
||||||
state.messages = Array.isArray(msgs) ? [...msgs] : [];
|
state.messages = Array.isArray(msgs) ? [...msgs] : [];
|
||||||
for (const m of state.messages) {
|
for (const m of state.messages) {
|
||||||
@@ -2385,6 +2420,7 @@ Object.assign(window, {
|
|||||||
cacheStore,
|
cacheStore,
|
||||||
ghApi,
|
ghApi,
|
||||||
parseGhUrl,
|
parseGhUrl,
|
||||||
|
ghGetFileContent,
|
||||||
pullThreads
|
pullThreads
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
@import url(https://fonts.bunny.net/css?family=assistant:500);
|
@import url(https://fonts.bunny.net/css?family=assistant:500);
|
||||||
:root{--safe-bottom:env(safe-area-inset-bottom)}
|
:root{--safe-bottom:env(safe-area-inset-bottom)}::-webkit-scrollbar{height:8px;width:8px}::-webkit-scrollbar-thumb{background:#e5e7eb;border-radius:999px}@media(pointer: coarse){.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}}
|
||||||
::-webkit-scrollbar{height:8px;width:8px}
|
|
||||||
::-webkit-scrollbar-thumb{background:#e5e7eb;border-radius:999px}
|
|
||||||
@media(pointer: coarse){.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}}
|
|
||||||
html,body{overscroll-behavior-y:contain;font-family:'Assistant',sans-serif}
|
html,body{overscroll-behavior-y:contain;font-family:'Assistant',sans-serif}
|
||||||
.markdown-body{font-size:14px;line-height:1.6}
|
.markdown-body{font-size:14px;line-height:1.6}.markdown-body pre{overflow:auto}
|
||||||
.markdown-body pre{overflow:auto}
|
|
||||||
.markdown-body ul,.markdown-body ol{list-style:revert;padding-left:2em}
|
.markdown-body ul,.markdown-body ol{list-style:revert;padding-left:2em}
|
||||||
.msg-bubble{overflow-x:auto}
|
.msg-bubble{overflow-x:auto}
|
||||||
.msg-avatar{font-size:16px}
|
.msg-avatar{font-size:16px}
|
||||||
@@ -14,6 +10,7 @@ html,body{overscroll-behavior-y:contain;font-family:'Assistant',sans-serif}
|
|||||||
#htmlEditor,#extensionHtmlEditor,#jsonSchemaEditor{outline:none;white-space:pre!important;font-size:11px;line-height:1.5;}
|
#htmlEditor,#extensionHtmlEditor,#jsonSchemaEditor{outline:none;white-space:pre!important;font-size:11px;line-height:1.5;}
|
||||||
:not(pre)>code{font-size:85%;padding:.2em .4em;margin:0;border-radius:6px;background-color:rgba(175,184,193,0.2)}
|
:not(pre)>code{font-size:85%;padding:.2em .4em;margin:0;border-radius:6px;background-color:rgba(175,184,193,0.2)}
|
||||||
#threadRepoInput::placeholder{font-family:sans-serif;font-weight:500;color:#9ca3af}
|
#threadRepoInput::placeholder{font-family:sans-serif;font-weight:500;color:#9ca3af}
|
||||||
|
|
||||||
/* MathJax 3 SVG Scaling & Alignment */
|
/* MathJax 3 SVG Scaling & Alignment */
|
||||||
mjx-container[jax="SVG"] {
|
mjx-container[jax="SVG"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
4
dist/index.html
vendored
4
dist/index.html
vendored
@@ -13,8 +13,8 @@
|
|||||||
<script defer src="//unpkg.com/alpinejs"></script>
|
<script defer src="//unpkg.com/alpinejs"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type="module" crossorigin src="/assets/index-CyJ4d9Tf.js"></script>
|
<script type="module" crossorigin src="/assets/index-Cu66jDo0.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DaGRC7Kr.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')">
|
||||||
<div class="flex flex-col h-dvh max-h-dvh overflow-hidden">
|
<div class="flex flex-col h-dvh max-h-dvh overflow-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 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:"7b534141e72adae9028c64d6d22b3c40"},{url:"assets/index-DUC1RW1F.css",revision:null},{url:"assets/index-Cu66jDo0.js",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { titleFrom, serializeThreadName, deserializeThreadName } from './threads
|
|||||||
import { resolveSuneSrc, processSuneIncludes, renderSuneHTML } from './sune-html.js';
|
import { resolveSuneSrc, processSuneIncludes, renderSuneHTML } from './sune-html.js';
|
||||||
|
|
||||||
(()=>{let k,v=visualViewport;const f=()=>{removeEventListener('popstate',f),document.activeElement?.blur()};v.onresize=()=>{let o=v.height<innerHeight;o!=k&&((k=o)?(history.pushState({k:1},''),addEventListener('popstate',f)):(removeEventListener('popstate',f),history.state?.k&&history.back()))}})()
|
(()=>{let k,v=visualViewport;const f=()=>{removeEventListener('popstate',f),document.activeElement?.blur()};v.onresize=()=>{let o=v.height<innerHeight;o!=k&&((k=o)?(history.pushState({k:1},''),addEventListener('popstate',f)):(removeEventListener('popstate',f),history.state?.k&&history.back()))}})()
|
||||||
const DEFAULT_MODEL='anthropic/claude-opus-4.7'
|
const DEFAULT_MODEL='openrouter/free'
|
||||||
const icons=()=>window.lucide&&lucide.createIcons()
|
const icons=()=>window.lucide&&lucide.createIcons()
|
||||||
const haptic=()=>/android/i.test(navigator.userAgent)&&navigator.vibrate?.(1)
|
const haptic=()=>/android/i.test(navigator.userAgent)&&navigator.vibrate?.(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user