- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
50 lines
2.0 KiB
Rust
50 lines
2.0 KiB
Rust
//! The old plugin packages of the native features. The frontend reads them one time for each feature,
|
|
//! when the `features` settings section has no switch for it (`src/lib/features/migration.ts`).
|
|
//! Nothing here changes plugin files.
|
|
|
|
use tauri::AppHandle;
|
|
|
|
use crate::error::{Error, Result};
|
|
use crate::plugins::{legacy_packages, LegacyPackage};
|
|
|
|
/// The packages that native features replace. A request for another ID fails.
|
|
pub const LEGACY_PACKAGES: [&str; 5] = ["runestone.git", "runestone.bg-slideshow", "runestone.terminal", "runestone.pdf-viewer", "runestone.pm"];
|
|
|
|
fn check(ids: &[String]) -> Result<()> {
|
|
if ids.len() > LEGACY_PACKAGES.len() {
|
|
return Err(Error::new("Too many feature packages."));
|
|
}
|
|
match ids.iter().find(|id| !LEGACY_PACKAGES.contains(&id.as_str())) {
|
|
Some(id) => Err(Error::new(format!("Unknown feature package: {id}"))),
|
|
None => Ok(()),
|
|
}
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn features_legacy(app: AppHandle, ids: Vec<String>) -> Result<Vec<LegacyPackage>> {
|
|
check(&ids)?;
|
|
legacy_packages(&app, ids).await
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn only_the_packages_of_native_features_are_read() {
|
|
assert!(check(&["runestone.git".into()]).is_ok());
|
|
assert!(check(&["runestone.git".into(), "runestone.bg-slideshow".into()]).is_ok());
|
|
assert!(check(&["runestone.terminal".into()]).is_ok());
|
|
assert!(check(&["runestone.pdf-viewer".into()]).is_ok());
|
|
assert!(check(&["runestone.pm".into()]).is_ok());
|
|
assert!(check(&LEGACY_PACKAGES.map(String::from)).is_ok());
|
|
assert!(check(&[]).is_ok());
|
|
for id in ["runestone.csv-viewer", "../plugin-state", "runestone.git/..", ""] {
|
|
assert!(check(&[id.into()]).is_err(), "{id}");
|
|
}
|
|
let too_many = ["runestone.git", "runestone.bg-slideshow", "runestone.terminal", "runestone.pdf-viewer", "runestone.pm", "runestone.git"].map(String::from);
|
|
assert!(too_many.len() > LEGACY_PACKAGES.len());
|
|
assert!(check(&too_many).is_err());
|
|
}
|
|
}
|