Release RuneStone 0.1.4 with installable plugins and settings

This commit is contained in:
Knotty Wyvern
2026-10-04 15:05:51 -07:00
parent 0268c5c9f0
commit 6b7af0d527
82 changed files with 4150 additions and 212 deletions
+36
View File
@@ -0,0 +1,36 @@
import { readFile } from "node:fs/promises";
/** Load the actual compiled packages through the production Blob module loader. */
export async function mockFeaturePlugins(surface) {
const packages = await Promise.all(["terminal", "table-formulas"].map(async name => {
const root = new URL(`../plugin-packages/${name}/`, import.meta.url);
return {
manifest: JSON.parse(await readFile(new URL("plugin.json", root), "utf8")),
code: await readFile(new URL("main.js", root), "utf8"),
css: name === "terminal" ? await readFile(new URL("style.css", root), "base64") : "",
};
}));
await surface.addInitScript(packages => {
const key = "test.installed-plugins";
const root = "C:\\AppData\\RuneStone\\plugins";
const defaults = packages.map(item => ({ manifest: item.manifest, hash: "test-hash", enabled: true, path: root + "\\" + item.manifest.id, error: null, removal: false }));
const read = () => JSON.parse(localStorage.getItem(key) || JSON.stringify(defaults));
const write = rows => { localStorage.setItem(key, JSON.stringify(rows)); window.__TEST__?.emit("plugins-changed", {}); };
if (!localStorage.getItem(key)) localStorage.setItem(key, JSON.stringify(defaults));
window.addEventListener("storage", event => { if (event.key === key) window.__TEST__?.emit("plugins-changed", {}); });
const original = window.__TAURI_INTERNALS__.invoke;
window.__TAURI_INTERNALS__.invoke = async (command, args = {}) => {
if (!command.startsWith("plugins_")) return original(command, args);
window.__TEST__?.calls.push({ command, args });
if (command === "plugins_snapshot") return { root, plugins: read() };
if (command === "plugins_load") return packages.find(item => item.manifest.id === args.id).code;
if (command === "plugins_asset") return packages.find(item => item.manifest.id === args.id).css;
if (command === "plugins_set_enabled") { write(read().map(item => item.manifest.id === args.id ? { ...item, enabled: args.enabled } : item)); return; }
if (command === "plugins_prepare_remove") return { token: args.id, plugin: read().find(item => item.manifest.id === args.id) };
if (command === "plugins_remove") { write(read().filter(item => item.manifest.id !== args.token)); return; }
if (command === "plugins_data") return "null";
if (["plugins_release", "plugins_cancel", "plugins_reveal"].includes(command)) return;
throw new Error(`Unhandled plugin IPC: ${command}`);
};
}, packages);
}