Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

refactor(effects): a package names its own extra shelves

Jareerf9584ab3af92
diff --git a/src/crates/concat-effects/packages/concat.bloom-pulse/effect.toml b/src/crates/concat-effects/packages/concat.bloom-pulse/effect.toml
index 6474423e..b4d10c24 100644
--- a/src/crates/concat-effects/packages/concat.bloom-pulse/effect.toml
+++ b/src/crates/concat-effects/packages/concat.bloom-pulse/effect.toml
@@ -5,6 +5,7 @@ id = "concat.bloom-pulse"
name = "Bloom Pulse"
kind = "effect"
category = "Light"
+shelves = ["Featured"]
order = 72
version = 2
intensity = "amount"
diff --git a/src/crates/concat-effects/packages/concat.film-grain/effect.toml b/src/crates/concat-effects/packages/concat.film-grain/effect.toml
index 51bf7788..a7e4f768 100644
--- a/src/crates/concat-effects/packages/concat.film-grain/effect.toml
+++ b/src/crates/concat-effects/packages/concat.film-grain/effect.toml
@@ -6,6 +6,7 @@ name = "Film Grain"
version = 2
kind = "effect"
category = "Stylize"
+shelves = ["Retro & Film"]
order = 41
intensity = "amount"
aliases = ["film-grain"]
diff --git a/src/crates/concat-effects/packages/concat.fisheye/effect.toml b/src/crates/concat-effects/packages/concat.fisheye/effect.toml
index 46b21c68..ddbc1f3e 100644
--- a/src/crates/concat-effects/packages/concat.fisheye/effect.toml
+++ b/src/crates/concat-effects/packages/concat.fisheye/effect.toml
@@ -6,6 +6,7 @@ name = "Fisheye"
version = 2
kind = "effect"
category = "Distort"
+shelves = ["Optical & Lens"]
order = 52
intensity = "strength"
aliases = ["fisheye"]
diff --git a/src/crates/concat-effects/packages/concat.glow/effect.toml b/src/crates/concat-effects/packages/concat.glow/effect.toml
index 3173b0f6..561ffe11 100644
--- a/src/crates/concat-effects/packages/concat.glow/effect.toml
+++ b/src/crates/concat-effects/packages/concat.glow/effect.toml
@@ -5,6 +5,7 @@ id = "concat.glow"
name = "Glow"
kind = "effect"
category = "Stylize"
+shelves = ["Featured", "Light & Shadow"]
order = 42
version = 2
intensity = "amount"
diff --git a/src/crates/concat-effects/packages/concat.neon/effect.toml b/src/crates/concat-effects/packages/concat.neon/effect.toml
index 1832c81b..5e082b3b 100644
--- a/src/crates/concat-effects/packages/concat.neon/effect.toml
+++ b/src/crates/concat-effects/packages/concat.neon/effect.toml
@@ -5,6 +5,7 @@ id = "concat.neon"
name = "Neon"
kind = "filter"
category = "Stylised"
+shelves = ["Party & Club"]
order = 51
intensity = "glow"
description = "Magenta in the shadows, cyan in the highlights, hard contrast, colour turned up, and the lights themselves blooming. Night streets and signage."
diff --git a/src/crates/concat-effects/packages/concat.swirl/effect.toml b/src/crates/concat-effects/packages/concat.swirl/effect.toml
index 2de7f00d..fcdda2fd 100644
--- a/src/crates/concat-effects/packages/concat.swirl/effect.toml
+++ b/src/crates/concat-effects/packages/concat.swirl/effect.toml
@@ -5,6 +5,7 @@ id = "concat.swirl"
name = "Swirl"
kind = "transition"
category = "Spin"
+shelves = ["Distortion & Glitch"]
order = 7
description = "The cut twists both pictures around its centre and untwists into the next shot."
diff --git a/src/crates/concat-effects/src/catalogue.rs b/src/crates/concat-effects/src/catalogue.rs
index 983d05d5..a6d92ec9 100644
--- a/src/crates/concat-effects/src/catalogue.rs
+++ b/src/crates/concat-effects/src/catalogue.rs
@@ -423,59 +423,40 @@ impl Package {
/// Whether this package belongs to or matches a category filter.
pub fn matches_category(&self, category: &str) -> bool {
- let cat = self.category();
if category.is_empty() || category.eq_ignore_ascii_case("All") {
return true;
}
- if cat.eq_ignore_ascii_case(category) {
+ // The package's own shelf, and any it names besides.
+ let named = |shelf: &str| {
+ self.category().eq_ignore_ascii_case(shelf)
+ || self
+ .manifest
+ .effect
+ .shelves
+ .iter()
+ .any(|own| own.eq_ignore_ascii_case(shelf))
+ };
+ if named(category) {
return true;
}
- match category {
+ // The library's combined shelves, each the categories it gathers:
+ // names, never package ids, so a package of anyone's lands on one
+ // by what it says about itself (audit 2026-10-04, `matches_category`).
+ let gathers: &[&str] = match category {
"Featured" => {
- cat.eq_ignore_ascii_case("Featured")
- || self.manifest.effect.order < 10
- || matches!(self.id(), "concat.glow" | "concat.bloom-pulse")
- }
- "Retro & Film" => {
- cat.eq_ignore_ascii_case("Retro")
- || cat.eq_ignore_ascii_case("Film")
- || cat.eq_ignore_ascii_case("Cinematic")
- || cat.eq_ignore_ascii_case("Retro & Film")
- || matches!(
- self.id(),
- "concat.vhs" | "concat.film-grain" | "concat.falling-dust"
- )
- }
- "Optical & Lens" => {
- cat.eq_ignore_ascii_case("Optical")
- || cat.eq_ignore_ascii_case("Lens")
- || cat.eq_ignore_ascii_case("Blur")
- || cat.eq_ignore_ascii_case("Optical & Lens")
- || matches!(
- self.id(),
- "concat.fisheye" | "concat.gaussian-blur" | "concat.motion-blur"
- )
- }
- "Distortion & Glitch" => {
- cat.eq_ignore_ascii_case("Distort")
- || cat.eq_ignore_ascii_case("Glitch")
- || cat.eq_ignore_ascii_case("Distortion & Glitch")
- || matches!(self.id(), "concat.fisheye" | "concat.swirl")
- }
- "Party & Club" => {
- cat.eq_ignore_ascii_case("Party")
- || cat.eq_ignore_ascii_case("Club")
- || cat.eq_ignore_ascii_case("Party & Club")
- || matches!(self.id(), "concat.neon")
- }
- "Light & Shadow" => {
- cat.eq_ignore_ascii_case("Light")
- || cat.eq_ignore_ascii_case("Shadow")
- || cat.eq_ignore_ascii_case("Light & Shadow")
- || matches!(self.id(), "concat.glow" | "concat.bloom-pulse")
+ if self.manifest.effect.order < 10 {
+ return true;
+ }
+ &[]
}
- _ => false,
- }
+ "Retro & Film" => &["Retro", "Film", "Cinematic"],
+ "Optical & Lens" => &["Optical", "Lens", "Blur"],
+ "Distortion & Glitch" => &["Distort", "Glitch"],
+ "Party & Club" => &["Party", "Club"],
+ "Light & Shadow" => &["Light", "Shadow"],
+ _ => &[],
+ };
+ gathers.iter().any(|shelf| named(shelf))
}
/// Which catalogue the package belongs to.
@@ -1409,6 +1390,50 @@ mod tests {
);
}
+ /// The library's shelves come from what each package says: its
+ /// category, the shelves it names, and the categories a combined shelf
+ /// gathers - no package is named in the code.
+ #[test]
+ fn a_package_lands_on_the_shelves_it_names() {
+ let catalogue = Catalogue::compiled_in();
+ let on = |id: &str, shelf: &str| catalogue.get(id).expect(id).matches_category(shelf);
+ for (id, shelf) in [
+ ("concat.glow", "Featured"),
+ ("concat.glow", "Light & Shadow"),
+ ("concat.bloom-pulse", "Featured"),
+ ("concat.bloom-pulse", "Light & Shadow"),
+ ("concat.vhs", "Retro & Film"),
+ ("concat.film-grain", "Retro & Film"),
+ ("concat.falling-dust", "Retro & Film"),
+ ("concat.fisheye", "Optical & Lens"),
+ ("concat.fisheye", "Distortion & Glitch"),
+ ("concat.gaussian-blur", "Optical & Lens"),
+ ("concat.motion-blur", "Optical & Lens"),
+ ("concat.swirl", "Distortion & Glitch"),
+ ("concat.neon", "Party & Club"),
+ ] {
+ assert!(on(id, shelf), "{id} on {shelf}");
+ }
+ assert!(!on("concat.neon", "Retro & Film"));
+ assert!(on("concat.neon", "All") && on("concat.neon", ""));
+ let mut catalogue = catalogue;
+ let manifest = "format = 2\n[effect]\nid = \"a.lift\"\nname = \"Lift\"\nkind = \"effect\"\n\
+ category = \"Colour\"\nshelves = [\"party & club\"]\n\
+ [[param]]\nkey = \"stops\"\nlabel = \"Stops\"\nmin = -2\nmax = 2\n\
+ [wgsl]\nentry = \"effect.wgsl\"\n";
+ let probe = "[[probe]]\nname = \"up\"\nparams = { stops = 1 }\ninput = [0.25, 0.25, 0.25, 1]\nexpect = [0.5, 0.5, 0.5, 1]\n";
+ let shader = "struct Params { stops: f32 }\nfn effect(uv: vec2<f32>) -> vec4<f32> { let c = sample(uv); return vec4<f32>(exposure(c.rgb, params.stops), c.a); }";
+ catalogue
+ .add(Package::from_sources(manifest, Some(probe), Some(shader)).expect("loads"))
+ .expect("adds");
+ assert!(
+ catalogue
+ .get("a.lift")
+ .expect("there")
+ .matches_category("Party & Club")
+ );
+ }
+
/// A chain reads the frame and its own table and no other file.
#[test]
fn a_chain_that_names_a_file_is_refused() {
diff --git a/src/crates/concat-effects/src/manifest.rs b/src/crates/concat-effects/src/manifest.rs
index 9e979787..061657a0 100644
--- a/src/crates/concat-effects/src/manifest.rs
+++ b/src/crates/concat-effects/src/manifest.rs
@@ -150,6 +150,12 @@ pub struct Meta {
/// The shelf the card sits on, e.g. "Blur". Free text.
#[serde(default)]
pub category: String,
+ /// Other shelves the card also shows on, by name: a glow that belongs
+ /// under "Light & Shadow" as well as its own. Free text, matched as
+ /// the category is; the package says where it goes, the app names no
+ /// package.
+ #[serde(default)]
+ pub shelves: Vec<String>,
/// The package's own version, bumped when its output changes.
#[serde(default = "one")]
pub version: u32,