P2 of docs/subsystems/plugin-runtime.md, the second page after Sessions.
- library.js and library.css move to assets/plugins/library/ (client.js,
library.css). The script registers with the kernel
(magpie.plugin("library")) and adds its page to the "page" slot. Its
hooks: open and relang load, redraw, close (its modal), dirty, discard.
What it set up at load (list scroll and resize, the modal's backdrop
and Escape, beforeunload, the stuck header, a quiet reload on focus)
runs in mount.
- app.js calls those through magpie.call instead of window.loadLibrary,
redrawLibrary, closeLibraryModal, libraryDirty and discardLibrary. It
no longer lists library in its title map, hide loop or OPEN_VIEWS; the
kernel's pages are in them.
- index.html: <main id="view-library"> goes, the kernel makes it.
library.css keeps its place in the cascade.
- The 560 strings only Library says move from i18n.js to
plugins/library/i18n.js (4 languages). i18n.js: 18826 → 16584 lines.
- plugins/library/library.go lists the client files.
- Tests that read i18n.js for a Library string read strings.cjs (i18n.js
and the plugins'): 8 library tests and mcp-editor-cancel,
mcp-oauth-app, mcp-signin-health. font-cascade, win-fonts and
assets_revalidate_test.go name the new paths.
- "Check again" stays in i18n.js: Library said it alone when the words
were split, and a5d72a095 (Settings' search keys) says it too since.
i18n-keys has a new test, "a plugin's words are its own": a key in a
plugin's i18n.js that any file outside the plugin's folder says fails
it, naming the file. It was red on this key, and search-keys.test.cjs
said "Check again" had no zh translation.
- docs: library.md, gui-shell.md, plugin-runtime.md.
Run, at this tree:
- 101 GUI test files touching Library, skills, MCP, the plugins, the
shell and every language (gui-de/ja/zh-tw, i18n-keys, page-width,
view-no-sideways, mobile-web, text-size, …): Chromium and WebKit, 4 at
a time, all green but one. text-size's "zh: 100% picked at the foot"
failed once in Chromium under load ("scrolled from 160 to 109 (max
115)"); it passed alone, 6 at once here and on origin/main 8f34bbcd1,
and at 6× and 12× CPU throttling. It's the Settings page, already
"fixed" by 50dd39104, so I filed it as #2058.
- After rebasing onto origin/main 75cbc7e1e: i18n-keys, search-keys,
library-mcp-tools, library-all, gui-de, mono-icon-redraw,
group-first-token, Chromium and WebKit, green.
- go test ./internal/gui/ ./internal/pluginrt/ ./plugins/...; gofmt;
go vet on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
46 lines
2.8 KiB
JavaScript
46 lines
2.8 KiB
JavaScript
// Defaults keep the authored cascade, including a code span under bold UI.
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
const assets = path.resolve(__dirname, "../assets");
|
|
const choice = (family, weight, style) => ({ family, name: "Chosen", weight, style, stretch: 100 });
|
|
|
|
for (const [name, engine] of [["chromium", chromium], ["webkit", webkit]]) {
|
|
test(`${name}: font reset restores the original cascade and explicit emphasis`, async () => {
|
|
const css = (await Promise.all(["app.css", "plugins/library/library.css", "routing.css", "plugins/sessions/sessions.css", "plugins.css"].map(f => fs.readFile(path.join(assets, f), "utf8")))).join("\n");
|
|
const js = await fs.readFile(path.join(assets, "fonts.js"), "utf8");
|
|
const browser = await engine.launch();
|
|
try {
|
|
const page = await browser.newPage();
|
|
await page.setContent(`<style>${css}</style>
|
|
<div class="sess-line"><b><code id="code">model-id</code></b></div>
|
|
<b><span class="key none" id="ui">No key</span></b>
|
|
<div class="acc"><input id="emphasis" class="rename mono" value="Account"></div>
|
|
<span id="badge" class="mk-badge">Code badge</span>`);
|
|
await page.addScriptTag({ content: js });
|
|
const read = () => page.evaluate(() => ["code", "ui", "emphasis", "badge"].map(id => {
|
|
const s = getComputedStyle(document.getElementById(id));
|
|
return { weight: s.fontWeight, style: s.fontStyle, family: s.fontFamily };
|
|
}));
|
|
const defaults = await read();
|
|
assert.equal(defaults[0].weight, "400", "code's authored regular weight must not inherit its bold parent");
|
|
assert.equal(defaults[1].weight, "400", "a UI family override must not discard the key's authored weight");
|
|
assert.equal(defaults[2].weight, "450");
|
|
await page.evaluate(s => window.desktopFonts.apply(s), { uiFont: choice("Arial", 500, "normal"), codeFont: choice("Consolas", 700, "italic") });
|
|
const picked = await read();
|
|
assert.equal(picked[0].weight, "700");
|
|
assert.equal(picked[0].style, "italic");
|
|
assert.equal(picked[1].weight, "500");
|
|
assert.equal(picked[2].weight, "450", "component emphasis stays explicit");
|
|
await page.evaluate(() => window.desktopFonts.apply({}));
|
|
assert.deepEqual(await read(), defaults, "reset restores every original font trait");
|
|
await page.evaluate(s => window.desktopFonts.apply(s), { uiFont: choice("Arial", 600, "italic"), codeFont: choice("Consolas", 400, "normal") });
|
|
const independent = await read();
|
|
assert.equal(independent[3].weight, "400");
|
|
assert.equal(independent[3].style, "normal", "code badges don't inherit the chosen interface slope");
|
|
} finally { await browser.close(); }
|
|
});
|
|
}
|