Make Background a native feature

- Background replaces the Background Slideshow plugin and the background image of Appearance. It shows a folder as a slideshow, or one image.
- It is on by default. Its module loads at launch only when a folder or an image is chosen.
- Rust keeps the one folder in background-folder.json. The interface never sends a path. Eight background_* commands replace the six deprecated backgrounds_* commands.
- The first start moves the slideshow folder and settings, and keeps the saved image as the image source.
- One blur worker with a cache, fewer folder reads, and a decode before each fade. The hub writes only the changed properties.
- Remove the deprecated folder methods of api.backgrounds. set, get, and subscribe stay for the Project Management plugin.
- Show the view buttons in the workbench test without text, after UI-056.
- Update the tests, the measurement tool, the docs, and UI-057.
This commit is contained in:
Knotty Wyvern
2026-10-29 17:25:17 -07:00
parent 115c32fa92
commit ab868bbe8e
81 changed files with 3179 additions and 812 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
/** The feature folders. The runtime files directly in `src/lib/features/` stay in the main bundle. */
export const FEATURE_FOLDERS = ["git"];
export const FEATURE_FOLDERS = ["git", "background"];
/** Libraries that only features need. */
export const FEATURE_LIBRARIES = ["@xterm", "pdfjs-dist", "yaml"];
+4 -1
View File
@@ -31,7 +31,10 @@ export const TABLE = {
background: {
plugin: { id: "runestone.bg-slideshow", repo: "runestone-bg-slideshow", tag: "v0.0.11", zip: `${PLUGIN_RELEASES}/RuneStone_Background_Slideshow/releases/runestone.bg-slideshow-0.0.11.zip` },
nativeKey: "background",
/** The style property of the body that holds the current background image. The action counts its changes. */
/**
* The style property of the body that holds the current background image. The action counts its changes.
* Native: `backgroundHub.applyApp` (src/lib/plugins/backgrounds.ts) sets it for each new image of Background.
*/
imageProperty: { plugin: "--rs-background-image", native: "--rs-background-image" },
changes: 3,
seconds: 10,
+15 -1
View File
@@ -3,7 +3,7 @@
// The tool starts a test build with an isolated identifier, drives it through CDP, and stops only the process tree that it started.
// Run `node scripts/measureFeatures.mjs --help` for the arguments. The results go to output/phase-7/<stage>/.
import { existsSync } from "node:fs";
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
import { mkdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { setTimeout as sleep } from "node:timers/promises";
@@ -47,6 +47,19 @@ async function seedBackgroundPlugin(folders, backgrounds) {
await writeFile(path.join(folder, "settings.json"), JSON.stringify({ grant, folder: backgrounds, seconds: TABLE.features.background.seconds, order: "name", enabled: true, targets: ["app"], overlay: 0, position: "center", size: "cover" }));
}
/**
* Write the `background` settings and the host folder file of the native Background before the first start
* (src/lib/features/backgroundSettings.ts and src-tauri/src/backgrounds.rs). The settings file has no other section,
* so the first start keeps it and migrates only the feature switches.
*/
async function seedBackgroundNative(folders, backgrounds) {
await mkdir(folders.roaming, { recursive: true });
const background = { source: "folder", seconds: TABLE.features.background.seconds, order: "name", paused: false, targets: ["app"], overlay: 0, position: "center", size: "cover" };
await writeFile(path.join(folders.roaming, "settings.json"), JSON.stringify({ schema: 1, revision: 1, background }, null, 2) + "\n");
// The host accepts the folder only at its resolved path.
await writeFile(path.join(folders.roaming, "background-folder.json"), JSON.stringify({ schema: 1, path: await realpath.native(backgrounds) }, null, 2));
}
/** The features that are on in the running app. */
async function readState(app, mode, invoke) {
if (mode === "plugin") {
@@ -142,6 +155,7 @@ export async function main(argv = process.argv.slice(2)) {
log(`Resetting ${folders.roaming} and ${folders.local}.`);
await resetData(folders, options.identifier);
if (options.mode === "plugin" && options.features.includes("background")) await seedBackgroundPlugin(folders, fixture.backgrounds);
if (options.mode === "native" && options.features.includes("background")) await seedBackgroundNative(folders, fixture.backgrounds);
// The setup start opens the workspace. It also proves the test identity.
let session = await app.launch({ exe, port: options.port });