PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Remove shared main repairs from Smart Filters feature scope
abc2cba33b7929a040
diff --git a/Cargo.toml b/Cargo.tomlindex 36e608b71..7502ff4fd 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -100,11 +100,6 @@ opt-level = "s"[profile.wasm-release.package.photocraft-ui-egui]opt-level = "z"-# Prefer compact command dispatch and parameter handling in the browser. Native profiles-# and the speed-oriented pixel-processing crates below keep their existing settings.-[profile.wasm-release.package.photocraft-engine]-opt-level = "z"-[profile.wasm-release.package.photocraft-raster]opt-level = 3[profile.wasm-release.package.photocraft-color]diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rsindex 400c0d9e1..d8e82503e 100644--- a/crates/automation/src/workspace.rs+++ b/crates/automation/src/workspace.rs@@ -307,8 +307,7 @@ fn params_contain_ambient_path(id: &str, params: &Value) -> bool {}fn profile_command_may_read_ambient(id: &str, params: &Value) -> bool {- // Installed profiles scan OS and user directories even without a request path.- if matches!(id, "color.profileMismatch" | "edit.colorSettings" | "edit.installedProfiles" | "view.proofSetup") {+ if matches!(id, "color.profileMismatch" | "edit.colorSettings" | "view.proofSetup") {return true;}matches!(id, "edit.assignProfile" | "edit.convertToProfile" | "edit.profileInfo")@@ -753,22 +752,6 @@ mod tests {assert!(authorize_engine_command("prefs.set", &serde_json::json!({"path": "interface.language", "value": "fr"})).is_ok());}- #[test]- fn installed_profile_discovery_requires_filesystem_authority() {- for params in [serde_json::json!({}), serde_json::json!({"class": "output", "colorSpace": "cmyk"}), serde_json::json!({"path": "/outside/profile.icc"})]- {- assert!(authorize_engine_command("edit.installedProfiles", ¶ms).is_err());- assert!(authorize_desktop_engine_command("edit.installedProfiles", ¶ms).is_err());- assert!(authorize_engine_step("edit.installedProfiles", ¶ms).is_err());- assert!(authorize_desktop_engine_step("edit.installedProfiles", ¶ms).is_err());- }- // Built-in profiles remain usable without reading installed profile files.- for id in ["edit.assignProfile", "edit.convertToProfile", "edit.profileInfo"] {- assert!(authorize_engine_command(id, &serde_json::json!({"profile": "srgb"})).is_ok());- assert!(authorize_desktop_engine_command(id, &serde_json::json!({"profile": "srgb"})).is_ok());- }- }-#[test]fn registry_filesystem_path_params_are_classified() {let probe = serde_json::json!({diff --git a/crates/engine/src/adjust_params.rs b/crates/engine/src/adjust_params.rsindex 8bc99a40b..00fb67dd0 100644--- a/crates/engine/src/adjust_params.rs+++ b/crates/engine/src/adjust_params.rs@@ -1240,12 +1240,9 @@ mod tests {#[test]fn destructive_levels_dont_clip_in_32_bit() {// Input 15..230, gamma 1.3, output 10..245: black and white land on the output range in- // integer documents. A 32-bit document evaluates the signed power curve beyond both- // ranges, retaining negative values and highlights above 1. The float expectations- // below were evaluated independently from the configured curve, not a clipped LUT.+ // integer documents, but in a 32-bit document the curve runs on past it (then 0..1).let params = json!({"inBlack": 15, "inWhite": 230, "gamma": 1.3, "outBlack": 10, "outWhite": 245});- for depth in [8, 16, 32] {- let (low, high, tolerance) = if depth == 32 { (-0.079_642_7, 1.042_158, 1e-6) } else { (10.0 / 255.0, 245.0 / 255.0, 0.6 / 255.0) };+ for (depth, low, high) in [(8, 10.0, 245.0), (16, 10.0, 245.0), (32, 0.0, 255.0)] {let mut s = crate::Session::new();s.execute("file.new", json!({"width": 16, "height": 16, "depth": depth, "background": "white"})).unwrap();s.execute("select.rect", json!({"x": 0, "y": 0, "width": 8, "height": 16})).unwrap();@@ -1253,10 +1250,8 @@ mod tests {s.execute("select.deselect", json!({})).unwrap();s.execute("image.adjustments.levels", params.clone()).unwrap();let px = pixels(&s);- assert!((px[0][0] - low).abs() < tolerance, "black @{depth}: {:?}", px[0]);- assert!((px[1][0] - high).abs() < tolerance, "white @{depth}: {:?}", px[1]);- assert_eq!(px[0][3], 1.0, "Levels keeps alpha");- assert_eq!(px[1][3], 1.0, "Levels keeps alpha");+ assert!((px[0][0] * 255.0 - low).abs() < 0.6, "black @{depth}: {:?}", px[0]);+ assert!((px[1][0] * 255.0 - high).abs() < 0.6, "white @{depth}: {:?}", px[1]);}}diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex cf4a1159a..87d1bbf65 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -145,7 +145,7 @@ automation permissions.UI-level commands (`view.zoomIn`, `window.theme.pro`, `edit.search`, …) are also accepted by `engine.execute` and `ui.menu.invoke`.-Commands that read or write files by path, instead of through the automation roots, are refused with "automation command `…` uses ambient filesystem paths and is disabled; use capability-scoped document methods". That covers every `file.*` command except `file.new`, the `file.close*` commands and a few path-free ones such as `file.fileInfo`, so `file.open`, `file.save`, `file.saveAs` and `file.saveACopy` always fail here: open and save with `app.open` / `app.save`. Path parameters of other commands (`layer.exportAs {path}`, `filter.distort.displace {mapPath}`, preset imports, and plug-in install/reload) are refused the same way. `prefs.set` rejects whole-preference updates and file-backed sections (`colorSettings`, `scriptEvents`, `historyLog`, `plugIns` and `scratchDisks`) so automation cannot configure ambient file access indirectly. `edit.installedProfiles` is also refused because it scans OS and user profile directories outside the automation roots, even without a request path. The desktop app also refuses `image.mode.*`, which can load the colour profiles set in its preferences. The rules are in `crates/automation/src/workspace.rs`.+Commands that read or write files by path, instead of through the automation roots, are refused with "automation command `…` uses ambient filesystem paths and is disabled; use capability-scoped document methods". That covers every `file.*` command except `file.new`, the `file.close*` commands and a few path-free ones such as `file.fileInfo`, so `file.open`, `file.save`, `file.saveAs` and `file.saveACopy` always fail here: open and save with `app.open` / `app.save`. Path parameters of other commands (`layer.exportAs {path}`, `filter.distort.displace {mapPath}`, preset imports, and plug-in install/reload) are refused the same way. `prefs.set` rejects whole-preference updates and file-backed sections (`colorSettings`, `scriptEvents`, `historyLog`, `plugIns` and `scratchDisks`) so automation cannot configure ambient file access indirectly. The desktop app also refuses `image.mode.*`, which can load the colour profiles set in its preferences. The rules are in `crates/automation/src/workspace.rs`.Embedded Smart Objects can be opened with `layer.smartObjects.editContents {layer?}` orunpacked with `layer.smartObjects.convertToLayers {layer?}`. This includes Photoshop sources