Add interface languages and improve themes and workspace controls for 0.1.36

This commit is contained in:
Knotty Wyvern
2026-10-15 10:55:59 -07:00
parent b066359b66
commit 68e86ab6eb
98 changed files with 5499 additions and 874 deletions
+40
View File
@@ -2,6 +2,7 @@ import test from "node:test";
import assert from "node:assert/strict";
import { ExternalSession } from "../src/lib/plugins/externalSession.ts";
import type { PluginApi } from "../src/lib/plugins/sdk.ts";
import { locale } from "../src/lib/i18n/index.ts";
function fixture() {
let writes = 0;
const session = new ExternalSession("org.test.demo", {
@@ -12,6 +13,25 @@ function fixture() {
return { session, writes: () => writes };
}
test("plugin language changes stop before cleanup and reject later access", async () => {
const { session } = fixture();
const changes: string[] = [];
let api!: PluginApi;
try {
await session.start({ activate(value) {
api = value;
api.i18n!.subscribe(language => changes.push(language));
api.onDispose(() => { locale.set('ja'); });
} });
locale.set('fr');
assert.equal(api.i18n!.t('Settings'), 'Paramètres');
await session.stop();
assert.deepEqual(changes, ['en', 'fr']);
assert.throws(() => api.i18n!.t('Settings'), /disabled/);
assert.throws(() => api.i18n!.locale, /disabled/);
} finally { await session.stop(); locale.set('en'); }
});
test("native Markdown discovery remains optional and is revoked on disable", async () => {
let api!: PluginApi;
let scans = 0;
@@ -93,3 +113,23 @@ test("cleanup returned by late activation still blocks shutdown when it fails",
await Promise.resolve(); const stopping = session.stop(); done();
await assert.rejects(starting, /Late cleanup failed/); await assert.rejects(stopping, /Late cleanup failed/);
});
test("batch workspace reads remain optional and stop when the plugin is disabled", async () => {
let api!: PluginApi;
let calls = 0;
const rows = [{ path: "Card.md", source: "Card source" }, { path: "Missing.md", error: "File not found" }];
const session = new ExternalSession("org.test.batch", {
workspace: { list: async () => [], read: async () => "", write: async () => {},
readMany: async paths => { calls++; assert.deepEqual(paths, ["Card.md", "Missing.md"]); return rows; } },
settings: { read: async () => null, write: async () => {} },
assets: { read: async () => new Uint8Array() },
}, () => {}, () => {});
await session.start({ activate(value) { api = value; } });
assert.deepEqual(await api.workspace.readMany!(["Card.md", "Missing.md"]), rows);
await session.stop();
assert.throws(() => api.workspace.readMany!(["Card.md"]), /disabled/);
assert.equal(calls, 1);
const old = fixture().session;
await old.start({ activate(value) { assert.equal(value.workspace.readMany, undefined); } });
await old.stop();
});