An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
import {getHostCapabilities} from "../../util/hostCapabilities";
import {normalizeHTMLAssetIFrameSources} from "../../asset/html";
export const addWidgetCacheVersion = (src: string, version: string) => {
if (!src.startsWith("/widgets/")) {
return src;
}
try {
const url = new URL(src, "http://127.0.0.1");
if (!url.pathname.startsWith("/widgets/")) {
return src;
}
url.searchParams.set("siyuan-version", version);
return url.pathname + url.search + url.hash;
} catch {
return src;
}
};
export const updateWidgetCacheVersion = (root: ParentNode, version: string) => {
if (!getHostCapabilities().widgets) {
normalizeHTMLAssetIFrameSources(root, true);
return;
}
root.querySelectorAll<HTMLIFrameElement>('[data-type="NodeWidget"] iframe').forEach(item => {
const src = item.getAttribute("src");
if (src) {
item.setAttribute("src", addWidgetCacheVersion(src, version));
}
});
};