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:
+15
-9
@@ -63,10 +63,10 @@ Windows is the primary platform. macOS and Linux builds are experimental.
|
||||
| `plugins.rs` | Plugin package review, installation, enable state, removal, and recovery |
|
||||
| `plugin_sources.rs` | Plugin downloads from Gitea releases |
|
||||
| `git.rs` | The Git service of the Git feature. It runs the `git` program. |
|
||||
| `features.rs` | Reads the old plugin packages of the native features one time, for the switch migration. It changes no plugin file. |
|
||||
| `features.rs` | Reads the old plugin packages of the native features one time, for the first-start migration. It changes no plugin file. |
|
||||
| `pty.rs`, `terminal_platform.rs` | Pseudo-terminals for the Terminal plugin |
|
||||
| `browser.rs` | The process of the built-in browser engine |
|
||||
| `backgrounds.rs` | Background image folders for themes and plugins |
|
||||
| `backgrounds.rs` | The image folder of the Background feature: the folder dialog, the kept folder (`background-folder.json` in the app data folder), the image list and reads, the sidecar file, and the folder migration from the Background Slideshow plugin |
|
||||
| `spelling.rs` | Spelling suggestions from the operating system (Windows) |
|
||||
| `settings.rs`, `theme.rs` | The Settings window and theme export |
|
||||
| `preferences.rs` | The settings file of the user. It reads, writes, and migrates the file, and replaces a damaged file. |
|
||||
@@ -88,7 +88,7 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
|
||||
| `settings/` | The settings store (`store.ts`), and the code that moves the old browser values to the settings file (`migration.ts`) |
|
||||
| `plugins/` | The plugin runtime, the host types (`sdk.ts`, which also exports the SDK types), and Settings → Plug-ins |
|
||||
| `browser/` | The interface of the built-in browser |
|
||||
| `features/` | The native features with an off switch: the catalog (`catalog.ts`), the switches (`state.ts`), the first-start migration, the loader, and one folder for each feature (`git/`). See [Native features](#native-features). |
|
||||
| `features/` | The native features with an off switch: the catalog (`catalog.ts`), the switches (`state.ts`), the first-start migration, the loader, the launch rules, the Background settings (`backgroundSettings.ts`), and one folder for each feature (`git/`, `background/`). See [Native features](#native-features). |
|
||||
| `completion/` | Contracts and services that plugins use |
|
||||
| `git/` | The Git service and its types, for the Git feature and the line history in the status bar |
|
||||
| `theme/` | Appearance settings, palettes, and the theme tokens (`tokens.css`) |
|
||||
@@ -116,7 +116,8 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
|
||||
| Documents | Ordinary files in the workspace folder |
|
||||
| Workspace state: tab order, pins, bookmarks, templates, Project Management boards | `.runestone/` in the workspace |
|
||||
| Installed plugins and their settings | The app data folder. See [plugin storage](plugin-host.md#storage-and-recovery). |
|
||||
| Preferences: general settings, appearance, custom themes, display language | `settings.json` in the app config folder |
|
||||
| Preferences: general settings, appearance, custom themes, display language, feature switches, Background | `settings.json` in the app config folder |
|
||||
| The image folder of Background | `background-folder.json` in the app data folder. The image of the image source stays in the WebView storage (IndexedDB). |
|
||||
| Browser profiles, bookmarks, history, browser settings, and Chromium caches | `browser/` in the local app data folder. On Windows, this is `%LOCALAPPDATA%\com.runestone.app\browser\`. See [Built-in browser runtime](#built-in-browser-runtime). |
|
||||
| Window layout and the open tabs of each workspace | The WebView storage (`localStorage`) of the app. RuneStone can lose these values without harm. |
|
||||
|
||||
@@ -135,13 +136,14 @@ On macOS, it is `~/Library/Application Support/<identifier>/`. On Linux, it is `
|
||||
"customThemes": [],
|
||||
"customThemesLegacy": [],
|
||||
"language": "en",
|
||||
"features": { "git": true }
|
||||
"features": { "git": true, "background": true },
|
||||
"background": { "source": "folder", "seconds": 60, "order": "name", "paused": false, "targets": ["app"], "overlay": 0, "position": "center", "size": "cover" }
|
||||
}
|
||||
```
|
||||
|
||||
| Rule | Detail |
|
||||
| --- | --- |
|
||||
| Sections | `general`, `appearance`, `customThemes`, `customThemesLegacy` (the original version 1 themes), `language`, and `features` (the switches of the native features). The host does not interpret their values. The frontend normalizes each section. |
|
||||
| Sections | `general`, `appearance`, `customThemes`, `customThemesLegacy` (the original version 1 themes), `language`, `features` (the switches of the native features), and `background` (the source, the timing, the targets, and the folder layout of Background). The host does not interpret their values. The frontend normalizes each section. |
|
||||
| Size | At most 8 MiB in total. The appearance can hold an image data URL of up to 3,000,000 characters. |
|
||||
| Writes | `settings_write` replaces one section. The host writes a complete temporary file and renames it. Then it sends `settings-changed` to all windows with the section, the revision, and the value. |
|
||||
| Damaged file | The host moves the file to `settings.corrupt-<seconds>.json` and writes a new file with the defaults. The first window that reads the settings shows a message one time. |
|
||||
@@ -206,22 +208,26 @@ Errors of the plugin API stay in English, because they are for plugin developers
|
||||
|
||||
## Native features
|
||||
|
||||
Git is a native feature: host code with an off switch in **Settings → Features**. It does not use the plugin API.
|
||||
Git and Background are native features: host code with an off switch in **Settings → Features**. They do not use the plugin API.
|
||||
|
||||
| Part | File |
|
||||
| --- | --- |
|
||||
| The catalog: ID, old plugin ID, name, views, and commands | `src/lib/features/catalog.ts` |
|
||||
| The switches: the `features` settings section | `src/lib/features/state.ts` |
|
||||
| The first start: each switch takes the state of the old plugin package | `src/lib/features/migration.ts` and `src-tauri/src/features.rs` |
|
||||
| The first start: each switch takes the state of the old plugin package, or the default of the feature when `followsPackage` is false | `src/lib/features/migration.ts` and `src-tauri/src/features.rs` |
|
||||
| One import at first need in each window | `src/lib/features/loader.ts` |
|
||||
| A start without a view: the launch rules, also the rule for browser windows | `src/lib/features/launch.ts` |
|
||||
| Views and commands in the workbench | `src/lib/features/session.ts` and `src/lib/plugins/external.ts` |
|
||||
| The feature code | `src/lib/features/<feature>/index.ts` and its components |
|
||||
|
||||
- The catalog holds only static data, so the main bundle stays small. The feature code loads when the user first opens a view, a tab, or a command of the feature. An off feature loads nothing.
|
||||
- A command without a view loads the feature and calls `FeatureInstance.run`. A launch rule starts the instance at once when it wants it, and again after each change of its settings.
|
||||
- Background has a launch rule: it loads when the `background` section selects a folder, or an image that exists. Its settings section and its "has a source" test are in `src/lib/features/backgroundSettings.ts`, in the main bundle. It also runs in browser windows. In the settings window, only its settings component loads (`mountSettings`).
|
||||
- The first start makes the `background` section from the kept settings of the Background Slideshow plugin and from the old background image. `background_migrate` copies the folder of the old plugin grant to the host only when the host has no folder.
|
||||
- Host code never imports a feature folder statically. `pnpm check:features` builds the app. It fails when a feature module, or a library that only a feature needs, is in a chunk that loads at start.
|
||||
- Saved tabs and tab transfers keep the ID of the old plugin package as the owner ID, for example `runestone.git`. `builtInPackages` in `external.ts` lists the old package, so it never loads.
|
||||
- Off stops the feature at once in each window and closes its views. The loaded module stays in memory until the window reloads.
|
||||
- To add a feature, add its entry to `catalog.ts`, its import to `loader.ts`, its folder to `FEATURE_FOLDERS` in `scripts/featureChunks.mjs`, and its old plugin ID to `LEGACY_PACKAGES` in `src-tauri/src/features.rs`.
|
||||
- To add a feature, add its entry to `catalog.ts`, its import to `loader.ts`, its folder to `FEATURE_FOLDERS` in `scripts/featureChunks.mjs`, and its old plugin ID to `LEGACY_PACKAGES` in `src-tauri/src/features.rs`. Add a launch rule only when the feature must run without a view.
|
||||
|
||||
## Plugin SDK
|
||||
|
||||
|
||||
Reference in New Issue
Block a user