diff --git a/crates/canvas-pilot/src/device_ui.rs b/crates/canvas-pilot/src/device_ui.rs index 02f68a4..b19b408 100644 --- a/crates/canvas-pilot/src/device_ui.rs +++ b/crates/canvas-pilot/src/device_ui.rs @@ -367,6 +367,7 @@ impl Editor { ui, self.device.snapshot.as_ref(), self.layout.layer_info(i).device_link.as_ref(), + self.layout.layer_info(i).id, ); } diff --git a/crates/canvas-pilot/src/exchange_metadata.rs b/crates/canvas-pilot/src/exchange_metadata.rs index 46c2cd0..9ee7cb2 100644 --- a/crates/canvas-pilot/src/exchange_metadata.rs +++ b/crates/canvas-pilot/src/exchange_metadata.rs @@ -8,10 +8,7 @@ const MAX_METADATA: usize = 1024 * 1024; const PREFIX: &str = "beffroi-midra-parameters:"; pub fn supported(codec: Codec) -> bool { - !matches!( - codec, - Codec::Dwg | Codec::Figma | Codec::Figcraft | Codec::Illustrator - ) + !matches!(codec, Codec::Dwg | Codec::Figma | Codec::Illustrator) } /// Exclude unexported layers, unused inputs, image bytes and device capture bindings. @@ -19,6 +16,7 @@ pub fn snapshot(project: &Project, ids: &[usize]) -> Result { project.layout()?; let mut p = project.clone(); p.layers.retain(|l| ids.contains(&l.id)); + p.input_proposals.retain(|p| ids.contains(&p.layer_id)); p.editor.selected_layer_ids.retain(|id| ids.contains(id)); p.folders .retain(|f| p.layers.iter().any(|l| &l.folder == f)); @@ -68,6 +66,9 @@ pub(crate) fn embed( return Err("Extra parameters are not supported by this format's current codec.".into()); } let payload = encode(project, ids)?; + if codec == Codec::Figcraft { + return embed_figcraft(&bytes, &payload); + } if codec == Codec::Pptx { return embed_pptx(&bytes, &payload); } @@ -205,7 +206,9 @@ pub fn extract(bytes: &[u8], codec: Codec) -> Result, String> { if !supported(codec) { return Ok(None); } - let payload = if codec == Codec::Pptx { + let payload = if codec == Codec::Figcraft { + figcraft_payload(bytes)? + } else if codec == Codec::Pptx { let mut zip = zip::ZipArchive::new(Cursor::new(bytes)).map_err(|e| e.to_string())?; let text = match zip.by_name("docProps/custom.xml") { Ok(file) => read_bounded(file)?, @@ -350,3 +353,91 @@ fn embed_pptx(bytes: &[u8], payload: &str) -> Result, String> { .map(|c| c.into_inner()) .map_err(|e| e.to_string()) } + +// FigCraft's native node plugin_data survives its normal load/save cycle. This is +// deliberately not used for FIG: that exporter drops plugin_data. +fn figcraft_document(bytes: &[u8]) -> Result { + let mut text = Vec::new(); + if bytes.starts_with(b"PK") { + let mut zip = zip::ZipArchive::new(Cursor::new(bytes)).map_err(|e| e.to_string())?; + if zip + .file_names() + .filter(|name| *name == "document.json") + .count() + != 1 + { + return Err("FigCraft requires exactly one document.json.".into()); + } + zip.by_name("document.json") + .map_err(|e| e.to_string())? + .take((crate::exchange::MAX_EXCHANGE_BYTES + 1) as u64) + .read_to_end(&mut text) + .map_err(|e| e.to_string())?; + } else { + text.extend_from_slice(bytes); + } + if text.len() > crate::exchange::MAX_EXCHANGE_BYTES { + return Err("FigCraft document exceeds 16 MiB.".into()); + } + let document: serde_json::Value = serde_json::from_slice(&text).map_err(|e| e.to_string())?; + if document["format"] != "figcraft" || document["version"] != 1 { + return Err("Unsupported FigCraft metadata carrier version.".into()); + } + Ok(document) +} +fn figcraft_payload(bytes: &[u8]) -> Result, String> { + let document = figcraft_document(bytes)?; + let nodes = document["nodes"] + .as_object() + .ok_or("Missing FigCraft nodes")?; + let mut found = None; + for node in nodes.values() { + if let Some(value) = node.get("plugin_data").and_then(|v| v.get(KEY)) { + if found.is_some() { + return Err("Multiple extra-parameter snapshots in FigCraft.".into()); + } + found = Some( + value + .as_str() + .ok_or("Invalid FigCraft parameters")? + .to_owned(), + ); + } + } + Ok(found) +} +fn embed_figcraft(bytes: &[u8], payload: &str) -> Result, String> { + let mut document = figcraft_document(bytes)?; + let page = document["pages"] + .as_array() + .and_then(|p| p.first()) + .and_then(|p| p.as_u64()) + .ok_or("Missing FigCraft page")? + .to_string(); + let node = document["nodes"] + .get_mut(&page) + .ok_or("Missing FigCraft page node")?; + node["plugin_data"][KEY] = payload.into(); + let json = serde_json::to_vec(&document).map_err(|e| e.to_string())?; + let mut archive = zip::ZipArchive::new(Cursor::new(bytes)).map_err(|e| e.to_string())?; + let mut writer = zip::ZipWriter::new(Cursor::new(Vec::new())); + for i in 0..archive.len() { + let file = archive.by_index(i).map_err(|e| e.to_string())?; + if file.name() == "document.json" { + writer + .start_file( + "document.json", + zip::write::SimpleFileOptions::default() + .compression_method(zip::CompressionMethod::Deflated), + ) + .map_err(|e| e.to_string())?; + writer.write_all(&json).map_err(|e| e.to_string())?; + } else { + writer.raw_copy_file(file).map_err(|e| e.to_string())?; + } + } + writer + .finish() + .map(|c| c.into_inner()) + .map_err(|e| e.to_string()) +} diff --git a/crates/canvas-pilot/src/input_proposal.rs b/crates/canvas-pilot/src/input_proposal.rs new file mode 100644 index 0000000..4a803f9 --- /dev/null +++ b/crates/canvas-pilot/src/input_proposal.rs @@ -0,0 +1,82 @@ +//! Inert, explicitly saved input corrections. These are never device commands. +use crate::{DeviceLink, device::Family}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct InputProposal { + pub layer_id: usize, + pub device_link: DeviceLink, + pub input: String, + pub plug: String, + /// Only the documented Midra setting suffixes are permitted; never arbitrary paths. + pub settings: BTreeMap, +} +impl InputProposal { + pub fn validate(&self) -> Result<(), String> { + self.device_link.validate()?; + let decimal = |s: &str| { + !s.is_empty() + && s.len() <= 16 + && s.bytes().all(|b| b.is_ascii_digit()) + && !s.starts_with('0') + }; + if self.layer_id == 0 + || self.device_link.family != Family::Midra4k + || !self.input.strip_prefix("INPUT_").is_some_and(decimal) + || !decimal(&self.plug) + || self.settings.is_empty() + || self.settings.len() > 9 + { + return Err("Invalid input proposal identity or settings count.".into()); + } + for (key, value) in &self.settings { + let options: &[&str] = match key.as_str() { + "aspect/pp/signal" => &[ + "NATIVE", "5_4", "4_3", "16_10", "15_9", "16_9", "21_9", "256_135", "64_27", + ], + "aspect/pp/transformTo" => &[ + "SIGNAL", "5_4", "4_3", "16_10", "15_9", "16_9", "21_9", "CUSTOM", + ], + "aspect/pp/layerFill" => { + &["LAYER_SETTING", "1_1", "CENTERED", "FULLSCREEN", "CROPPED"] + } + "cropping/control/pp/predefined" => &[ + "NONE", + "LETTERBOX_1_78", + "LETTERBOX_1_85", + "LETTERBOX_2_35", + "PILLARBOX_1_33", + ], + "aspect/pp/customRatio" => { + if !value.as_i64().is_some_and(|v| (250..=10000).contains(&v)) { + return Err("Invalid proposal custom ratio.".into()); + } + continue; + } + "cropping/control/pp/left" + | "cropping/control/pp/right" + | "cropping/control/pp/top" + | "cropping/control/pp/bottom" => { + if !value.as_i64().is_some_and(|v| (0..=8191).contains(&v)) { + return Err("Invalid proposal input crop.".into()); + } + continue; + } + _ => return Err("Unsupported input proposal setting.".into()), + }; + if !value.as_str().is_some_and(|v| options.contains(&v)) { + return Err(format!("Invalid input proposal value for {key}.")); + } + } + Ok(()) + } + pub fn base(&self) -> String { + format!( + "/device/inputList/items/{}/plugList/items/{}/settings", + self.input, self.plug + ) + } +} diff --git a/crates/canvas-pilot/src/input_ui.rs b/crates/canvas-pilot/src/input_ui.rs index a936a76..8e1b9d2 100644 --- a/crates/canvas-pilot/src/input_ui.rs +++ b/crates/canvas-pilot/src/input_ui.rs @@ -1,4 +1,4 @@ -//! Session-only, explicitly enabled edits to the device's shared input settings. +//! Explicit device edits and separately saved, inactive input-setting proposals. use super::*; use canvas_pilot::{ device::Snapshot, @@ -10,6 +10,8 @@ use std::collections::{BTreeMap, BTreeSet}; #[derive(Default)] pub(super) struct InputEdits { pub enabled: bool, + pub saved: Vec, + message: Option, // Only fields actually edited are staged; opening the tab never stages defaults. values: BTreeMap, } @@ -44,7 +46,9 @@ fn setting_label(value: &str) -> String { impl InputEdits { pub fn clear(&mut self) { - *self = Self::default(); + self.enabled = false; + self.values.clear(); + self.message = None; } pub fn show( @@ -52,7 +56,36 @@ impl InputEdits { ui: &mut egui::Ui, snapshot: Option<&Snapshot>, link: Option<&canvas_pilot::DeviceLink>, + layer_id: usize, ) { + if let Some(saved) = self.saved.iter().find(|p| p.layer_id == layer_id).cloned() { + ui.label(format!( + "Saved proposal: {} · plug {} (inactive until staged)", + saved.input, saved.plug + )); + for (key, value) in &saved.settings { + ui.small(format!("{key}: {value}")); + } + let can_stage = + self.enabled && snapshot.is_some_and(|s| Self::proposal_matches(&saved, s, link)); + if ui + .add_enabled(can_stage, egui::Button::new("Stage saved input proposal")) + .clicked() + && let Some(snapshot) = snapshot + { + self.message = Some(match self.stage_proposal(&saved, snapshot, link) { + Ok(()) => "Proposal staged. Review mappings before sending.".into(), + Err(error) => error, + }); + } + ui.small("To stage: connect, match this layer's saved mapping and routed input/plug, then enable advanced input edits. Send remains a separate action."); + if ui.button("Remove saved input proposal").clicked() { + self.saved.retain(|p| p.layer_id != layer_id); + } + } + if let Some(message) = &self.message { + ui.label(message); + } if snapshot.is_some_and(|s| !s.profile.advanced_inputs()) { ui.label("Shared input corrections for this adapter are managed in WebRCS. Layer crop and zoom remain available in the editor."); return; @@ -206,8 +239,90 @@ impl InputEdits { } } }); + let prefix = format!("{base}/"); + let settings: BTreeMap<_, _> = self + .values + .iter() + .filter_map(|(path, value)| { + path.strip_prefix(&prefix) + .map(|key| (key.to_owned(), value.clone())) + }) + .collect(); + if ui + .add_enabled( + !settings.is_empty(), + egui::Button::new("Save staged input edits as a project proposal"), + ) + .clicked() + && let Some(link) = link + { + let proposal = canvas_pilot::input_proposal::InputProposal { + layer_id, + device_link: link.clone(), + input: base.split('/').nth(4).unwrap_or_default().into(), + plug: base.split('/').nth(7).unwrap_or_default().into(), + settings, + }; + if proposal.validate().is_ok() { + self.saved.retain(|p| p.layer_id != layer_id); + self.saved.push(proposal); + } + } + ui.small("Saving a proposal is opt-in. Project saves and extra-parameter exports retain it; reopening never stages or sends it."); ui.small("Edits wait for Send; opening this tab or enabling the checkbox sends nothing. Refresh/load after sending to inspect the device's resulting content dimensions."); } + fn proposal_matches( + proposal: &canvas_pilot::input_proposal::InputProposal, + snapshot: &Snapshot, + link: Option<&canvas_pilot::DeviceLink>, + ) -> bool { + proposal.validate().is_ok() + && snapshot.profile.advanced_inputs() + && link == Some(&proposal.device_link) + && snapshot + .screens + .iter() + .find(|s| s.id == proposal.device_link.screen) + .and_then(|s| { + input_path( + snapshot, + &s.id, + &s.preview_bank, + &proposal.device_link.layer, + ) + }) + .as_deref() + == Some(proposal.base().as_str()) + } + fn stage_proposal( + &mut self, + proposal: &canvas_pilot::input_proposal::InputProposal, + snapshot: &Snapshot, + link: Option<&canvas_pilot::DeviceLink>, + ) -> Result<(), String> { + if !self.enabled || !Self::proposal_matches(proposal, snapshot, link) { + return Err( + "Enable edits and verify the saved layer, input and plug mapping first.".into(), + ); + } + let values: Vec<_> = proposal + .settings + .iter() + .map(|(key, value)| { + let path = format!("{}/{key}", proposal.base()); + let original = snapshot + .raw + .pointer(&path) + .ok_or("Refresh device: proposal field unavailable.")? + .clone(); + Ok((path, value.clone(), original)) + }) + .collect::>()?; + for (path, value, original) in values { + self.stage(path, value, &original); + } + Ok(()) + } fn stage(&mut self, path: String, value: Value, original: &Value) { if &value == original { self.values.remove(&path); @@ -311,7 +426,7 @@ mod tests { }, |ctx| { egui::CentralPanel::default() - .show(ctx, |ui| edits.show(ui, Some(&snapshot), Some(&link))); + .show(ctx, |ui| edits.show(ui, Some(&snapshot), Some(&link), 1)); }, ) }; @@ -419,4 +534,79 @@ mod tests { edits.stage(path, json!("SIGNAL"), &json!("SIGNAL")); assert!(edits.values.is_empty()); } + #[test] + fn restored_proposals_are_inert_and_stage_only_after_route_and_field_review() { + let mut snapshot = fixture(); + snapshot.screens.push(canvas_pilot::device::Screen { + id: "1".into(), + resolution: [1920, 1080], + preview_bank: "UP".into(), + program_bank: "DOWN".into(), + layers: vec![], + }); + let proposal = canvas_pilot::input_proposal::InputProposal { + layer_id: 1, + device_link: canvas_pilot::DeviceLink { + family: Default::default(), + screen: "1".into(), + layer: "1".into(), + }, + input: "INPUT_4".into(), + plug: "2".into(), + settings: [ + ("aspect/pp/transformTo".into(), json!("CUSTOM")), + ("aspect/pp/customRatio".into(), json!(1778)), + ] + .into(), + }; + let mut edits = InputEdits { + saved: vec![proposal.clone()], + ..Default::default() + }; + let link = Some(&proposal.device_link); + let mut plan = empty_plan(); + edits + .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) + .unwrap(); + assert!(plan.changes.is_empty()); + assert!(edits.stage_proposal(&proposal, &snapshot, link).is_err()); + edits.enabled = true; + edits + .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) + .unwrap(); + assert!( + plan.changes.is_empty(), + "Enabling alone must not stage saved data" + ); + let mut wrong = proposal.clone(); + wrong.input = "INPUT_9".into(); + assert!(edits.stage_proposal(&wrong, &snapshot, link).is_err()); + assert!(edits.stage_proposal(&proposal, &snapshot, None).is_err()); + let mut missing = snapshot.clone(); + missing + .raw + .pointer_mut("/device/inputList/items/INPUT_4/plugList/items/2/settings/aspect/pp") + .unwrap() + .as_object_mut() + .unwrap() + .remove("transformTo"); + assert!(edits.stage_proposal(&proposal, &missing, link).is_err()); + assert!( + edits.values.is_empty(), + "Missing fields reject staging atomically" + ); + edits.stage_proposal(&proposal, &snapshot, link).unwrap(); + edits + .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) + .unwrap(); + assert_eq!(plan.changes.len(), 2); + assert!(plan.changes.iter().all(|c| { + c.path + .join("/") + .starts_with("device/inputList/items/INPUT_4/plugList/items/2/settings/aspect/pp/") + })); + edits.clear(); + assert!(!edits.enabled && edits.values.is_empty()); + assert_eq!(edits.saved, vec![proposal]); + } } diff --git a/crates/canvas-pilot/src/lib.rs b/crates/canvas-pilot/src/lib.rs index ab9bb61..7b17171 100644 --- a/crates/canvas-pilot/src/lib.rs +++ b/crates/canvas-pilot/src/lib.rs @@ -9,6 +9,7 @@ mod folders; pub mod formats; mod geometry_formats; pub mod import; +pub mod input_proposal; pub mod interchange; pub mod project; pub mod snapping; diff --git a/crates/canvas-pilot/src/project.rs b/crates/canvas-pilot/src/project.rs index d064463..a7d2e10 100644 --- a/crates/canvas-pilot/src/project.rs +++ b/crates/canvas-pilot/src/project.rs @@ -163,6 +163,7 @@ impl Preview { #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct Project { + pub input_proposals: Vec, pub folders: Vec, pub workspace: Workspace, pub format: String, @@ -180,7 +181,8 @@ impl Project { folders: layout.folders.clone(), workspace: Workspace::default(), format: FORMAT.into(), - version: 15, + version: 16, + input_proposals: Vec::new(), next_layer_id: layout.next_id, output_resolution: layout.formats.output.into(), inputs: (0..layout.formats.sources.len()) @@ -231,12 +233,30 @@ impl Project { } /// Build a fresh document only after validating the entire file. No history is restored. pub fn layout(&self) -> Result { - if self.format != FORMAT || self.version != 15 { + if self.format != FORMAT || self.version != 16 { return Err( - "Unsupported project format/version; expected beffroi.midra-layout version 15." + "Unsupported project format/version; expected beffroi.midra-layout version 16." .into(), ); } + if self.input_proposals.len() > 256 { + return Err("Too many input proposals.".into()); + } + let mut proposal_layers = std::collections::BTreeSet::new(); + for proposal in &self.input_proposals { + proposal.validate()?; + if !proposal_layers.insert(proposal.layer_id) + || !self.layers.iter().any(|l| { + l.id == proposal.layer_id + && l.device_link.as_ref() == Some(&proposal.device_link) + }) + { + return Err( + "Input proposal must refer to a distinct layer with its matching device link." + .into(), + ); + } + } if self.editor.backdrop_title.chars().count() > 128 || self.editor.backdrop_title.chars().any(char::is_control) { @@ -427,8 +447,8 @@ impl Project { } let header: Header = serde_json::from_str(text).map_err(|e| format!("Invalid project JSON: {e}"))?; - if !(1..=15).contains(&header.version) { - return Err("Unsupported project version; expected versions 1–15.".into()); + if !(1..=16).contains(&header.version) { + return Err("Unsupported project version; expected versions 1–16.".into()); } let mut migrated: serde_json::Value = if header.version == 1 || header.version == 2 { let mut value: serde_json::Value = @@ -652,6 +672,13 @@ impl Project { } migrated["version"] = 15.into(); } + if header.version <= 15 { + if migrated.get("input_proposals").is_some() { + return Err("Unexpected input_proposals in legacy project.".into()); + } + migrated["input_proposals"] = serde_json::json!([]); + migrated["version"] = 16.into(); + } let p: Self = serde_json::from_value(migrated).map_err(|e| format!("Invalid project JSON: {e}"))?; p.layout()?; diff --git a/crates/canvas-pilot/src/project_ui.rs b/crates/canvas-pilot/src/project_ui.rs index dd44ba7..f8a562e 100644 --- a/crates/canvas-pilot/src/project_ui.rs +++ b/crates/canvas-pilot/src/project_ui.rs @@ -62,6 +62,19 @@ impl PreparedProject { impl Editor { pub(super) fn project(&self) -> Project { let mut p = Project::from_layout(&self.layout); + p.input_proposals = self + .device + .input_edits + .saved + .iter() + .filter(|proposal| { + p.layers.iter().any(|l| { + l.id == proposal.layer_id + && l.device_link.as_ref() == Some(&proposal.device_link) + }) + }) + .cloned() + .collect(); p.editor.position_point = self.corner; p.editor.position_layer_point = self.position_layer_point; p.editor.backdrop_title = self.backdrop_title.clone(); @@ -127,6 +140,7 @@ impl Editor { let e = project.editor; self.device.reset_mappings(); self.device.input_edits.clear(); + self.device.input_edits.saved = project.input_proposals; self.capture.clear_preview(); let mut layer_ui = layers_ui::LayerUi::default(); layer_ui.collapsed = project.workspace.collapsed_folders.into_iter().collect(); @@ -345,7 +359,9 @@ impl Editor { if let Some(path) = rfd::FileDialog::new() .add_filter( "Exports with Canvas Pilot parameters", - &["svg", "drawio", "xml", "json", "csv", "dxf", "html", "pptx"], + &[ + "svg", "drawio", "xml", "json", "csv", "dxf", "html", "pptx", "figcraft", + ], ) .pick_file() { @@ -676,6 +692,25 @@ mod tests { assert_eq!(app.files.manual_saved_at, time); } + #[test] + fn saved_input_proposals_reopen_inactive_and_follow_layer_identity() { + let ctx = egui::Context::default(); + let mut app = Editor::default(); + let project = Project::from_json(include_str!( + "../../../docs/interfaces/canvas-pilot-v16.example.json" + )) + .unwrap(); + app.device.input_edits.enabled = true; + app.install_project(&ctx, project.clone()).unwrap(); + assert!(!app.device.input_edits.enabled); + assert_eq!(app.project().input_proposals, project.input_proposals); + app.layout.set_device_link(0, None).unwrap(); + assert!(app.project().input_proposals.is_empty()); + app.install_project(&ctx, Project::from_layout(&Layout::default())) + .unwrap(); + assert!(app.device.input_edits.saved.is_empty()); + } + #[test] fn measurement_clicks_autosave_only_points_and_exports_keep_project_target() { use super::super::tests::click_text; diff --git a/crates/canvas-pilot/tests/aquilon.rs b/crates/canvas-pilot/tests/aquilon.rs index 1625322..56ec167 100644 --- a/crates/canvas-pilot/tests/aquilon.rs +++ b/crates/canvas-pilot/tests/aquilon.rs @@ -240,7 +240,7 @@ fn family_links_save_migrate_recover_and_validate() { let mut old: Value = serde_json::from_str(old).unwrap(); old["layers"][0]["midra_link"] = json!({"screen":"001","layer":"02"}); let p = Project::from_json(&old.to_string()).unwrap(); - assert_eq!(p.version, 15); + assert_eq!(p.version, 16); assert_eq!( p.layers[0].device_link.as_ref().unwrap().family, Family::Midra4k @@ -300,7 +300,7 @@ fn documented_v13_example_contains_native_aquilon_link() { "../../../docs/interfaces/canvas-pilot-v13.example.json" )) .unwrap(); - assert_eq!(p.version, 15); + assert_eq!(p.version, 16); let link = p.layers[0].device_link.as_ref().unwrap(); assert_eq!(link.family, Family::Aquilon); assert_eq!(link.screen, "S1"); diff --git a/crates/canvas-pilot/tests/exchange_metadata.rs b/crates/canvas-pilot/tests/exchange_metadata.rs index 348178a..cf0ed7a 100644 --- a/crates/canvas-pilot/tests/exchange_metadata.rs +++ b/crates/canvas-pilot/tests/exchange_metadata.rs @@ -140,12 +140,7 @@ fn metadata_is_optional_versioned_and_not_silently_applied_to_edited_artwork() { assert!(interchange::import(&invalid, "x.json").is_ok()); json.as_object_mut().unwrap().remove(metadata::KEY); assert!(interchange::import(&serde_json::to_vec(&json).unwrap(), "x.json").is_err()); - for codec in [ - Codec::Dwg, - Codec::Figma, - Codec::Figcraft, - Codec::Illustrator, - ] { + for codec in [Codec::Dwg, Codec::Figma, Codec::Illustrator] { assert!(!metadata::supported(codec)); assert!( interchange::export( @@ -269,3 +264,248 @@ fn documented_metadata_example_and_pptx_package_relationships_are_valid() { } } } + +#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))] +#[test] +fn figcraft_native_resave_preserves_snapshot_after_artwork_edits() { + let p = fixture(); + let ids = [p.layers[0].id]; + let bytes = interchange::export( + &p, + &ids, + Codec::Figcraft, + Options { + extra_parameters: true, + placeholders: true, + background: true, + }, + ) + .unwrap(); + let (mut document, warnings) = figcraft_format::load_bytes(&bytes).unwrap(); + assert!(warnings.is_empty(), "{warnings:?}"); + let before = interchange::import(&bytes, "original.figcraft").unwrap(); + let id = document + .nodes() + .find(|n| n.name == p.layers[0].name) + .unwrap() + .id; + document.node_mut(id).unwrap().width += 100.; + document.name = "Edited in native codec".into(); + let bytes = figcraft_format::save_bytes(&document, None).unwrap(); + let after = interchange::import(&bytes, "edited.figcraft").unwrap(); + let widths = |pages: Vec| { + pages + .into_iter() + .flat_map(|p| p.document.shapes.into_iter().map(|s| s.geometry.width)) + .collect::>() + }; + assert_ne!( + widths(before), + widths(after), + "Geometry import must see the edited artwork" + ); + assert_eq!( + metadata::extract(&bytes, Codec::Figcraft).unwrap(), + Some(metadata::snapshot(&p, &ids).unwrap()) + ); + assert!( + !interchange::import(&bytes, "resaved.figcraft") + .unwrap() + .is_empty() + ); + use std::io::Read; + let mut archive = zip::ZipArchive::new(std::io::Cursor::new(bytes)).unwrap(); + let mut json = String::new(); + archive + .by_name("document.json") + .unwrap() + .read_to_string(&mut json) + .unwrap(); + assert_eq!( + metadata::extract(json.as_bytes(), Codec::Figcraft).unwrap(), + Some(metadata::snapshot(&p, &ids).unwrap()) + ); + let mut value: serde_json::Value = serde_json::from_str(&json).unwrap(); + let nodes = value["nodes"].as_object_mut().unwrap(); + let payload = nodes + .values() + .find_map(|n| n["plugin_data"][metadata::KEY].as_str()) + .unwrap() + .to_string(); + let other = nodes + .values_mut() + .find(|n| n["plugin_data"][metadata::KEY].is_null()) + .unwrap(); + other["plugin_data"][metadata::KEY] = payload.into(); + assert!( + metadata::extract(&serde_json::to_vec(&value).unwrap(), Codec::Figcraft) + .unwrap_err() + .contains("Multiple") + ); +} + +#[test] +fn every_snapshot_codec_roundtrips_all_fit_modes_masks_sources_links_and_proposals() { + use canvas_pilot::{ + formats::{Crop, LayerFit, Mask}, + input_proposal::InputProposal, + }; + for fit in [ + None, + Some(LayerFit::OneToOne), + Some(LayerFit::Centered), + Some(LayerFit::Fullscreen), + Some(LayerFit::Cropped), + ] { + let mut layout = Layout::default(); + layout + .set_layer_fit( + 0, + fit, + Crop { + left: 40.25, + right: 70.5, + top: 20.125, + bottom: 35.75, + }, + ) + .unwrap(); + layout + .set_mask( + 0, + Mask { + left: 0.125, + right: 0.0625, + top: 0.25, + bottom: 0.125, + }, + ) + .unwrap(); + let mut p = Project::from_layout(&layout); + p.inputs[0].input_crop = Crop { + left: 10.25, + right: 20.5, + top: 5.25, + bottom: 10.75, + }; + p.layers[0].name = "Speaker — é".into(); + p.layers[0].folder = "Scene".into(); + p.folders = vec!["Scene".into(), "Unused".into()]; + p.layers[0].pivot = [0.25, 0.75]; + p.layers[0].device_link = Some(canvas_pilot::DeviceLink { + family: Default::default(), + screen: "1".into(), + layer: "3".into(), + }); + p.layers[1].source_id = p.layers[0].source_id; + let native = &p.inputs[0].native_resolution; + let input = p.inputs[0] + .input_crop + .remaining([native.width as f64, native.height as f64]) + .unwrap(); + for layer in &mut p.layers { + if layer.layer_fit.is_none() { + layer.advanced_crop = canvas_pilot::formats::crop_from_framing( + input, + [layer.bounds.width, layer.bounds.height], + Default::default(), + ) + .unwrap(); + } + } + + p.layers[1].locked = true; + p.editor.selected_layer_ids = vec![p.layers[0].id]; + p.workspace.collapsed_folders = vec!["Scene".into()]; + p.workspace.grid_spacing = Some(10); + p.editor.viewport_pan = [17., -23.]; + p.editor.show_source_pattern = true; + p.editor.viewport_zoom = 1.75; + p.editor.backdrop_title = "Round trip".into(); + p.editor.keep_aspect_ratio = false; + p.editor.outline_layers = true; + p.editor.show_toolbar_icon_names = true; + p.workspace.resize_mode = canvas_pilot::ResizeMode::Mirror; + p.workspace.capture_interval_seconds = 17; + p.workspace.show_empty_inputs = true; + p.workspace.snapping.enabled = true; + p.workspace.snapping.pixels = false; + p.workspace.snapping.grid = true; + p.workspace.snapping.grid_divisions = [7, 5]; + + p.input_proposals.push(InputProposal { + layer_id: p.layers[0].id, + device_link: p.layers[0].device_link.clone().unwrap(), + input: "INPUT_4".into(), + plug: "2".into(), + settings: serde_json::from_value(serde_json::json!({ + "aspect/pp/signal":"16_9", "aspect/pp/transformTo":"CUSTOM", + "aspect/pp/customRatio":1778, "aspect/pp/layerFill":"CENTERED", + "cropping/control/pp/predefined":"NONE", "cropping/control/pp/left":41, + "cropping/control/pp/right":17, "cropping/control/pp/top":3, + "cropping/control/pp/bottom":9 + })) + .unwrap(), + }); + let ids: Vec<_> = p.layers.iter().map(|l| l.id).collect(); + assert_eq!(Project::from_json(&p.to_json().unwrap()).unwrap(), p); + let expected = metadata::snapshot(&p, &ids).unwrap(); + assert_eq!(expected.layers, p.layers); + assert_eq!(expected.inputs.len(), 1); + assert_eq!(expected.input_proposals, p.input_proposals); + assert_eq!(expected.layers[0].mask, p.layers[0].mask); + assert_eq!(expected.layers[0].layer_fit, fit); + assert!( + metadata::snapshot(&p, &[p.layers[1].id]) + .unwrap() + .input_proposals + .is_empty() + ); + for codec in Codec::available() + .into_iter() + .filter(|&c| metadata::supported(c)) + { + let bytes = interchange::export( + &p, + &ids, + codec, + Options { + extra_parameters: true, + ..Default::default() + }, + ) + .unwrap(); + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join(format!("roundtrip.{}", codec.extension())); + std::fs::write(&path, &bytes).unwrap(); + let (restored, native) = interchange::read_project_or_parameters(&path).unwrap(); + assert!(!native); + assert_eq!(restored, expected, "{codec:?} / {fit:?}"); + assert_eq!( + restored.layout().unwrap().formats().masks, + expected.layout().unwrap().formats().masks + ); + let second = interchange::export( + &restored, + &ids, + codec, + Options { + extra_parameters: true, + ..Default::default() + }, + ) + .unwrap(); + assert_eq!( + metadata::extract(&second, codec).unwrap(), + Some(expected.clone()) + ); + assert_eq!( + interchange::import(&bytes, &format!("x.{}", codec.extension())).unwrap()[0] + .document + .shapes + .len(), + 2 + ); + } + } +} diff --git a/crates/canvas-pilot/tests/folders.rs b/crates/canvas-pilot/tests/folders.rs index 706a9af..8794603 100644 --- a/crates/canvas-pilot/tests/folders.rs +++ b/crates/canvas-pilot/tests/folders.rs @@ -134,7 +134,7 @@ fn explicit_empty_folders_survive_history_save_rename_and_membership_changes() { fn version_12_explicit_folder_validation_and_v11_migration() { let old = include_str!("../../../docs/interfaces/canvas-pilot-v11.example.json"); let p = Project::from_json(old).unwrap(); - assert_eq!(p.version, 15); + assert_eq!(p.version, 16); assert!(p.folders.is_empty()); let example = include_str!("../../../docs/interfaces/canvas-pilot-v12.example.json"); assert_eq!( diff --git a/crates/canvas-pilot/tests/layer_fit.rs b/crates/canvas-pilot/tests/layer_fit.rs index 3cc7869..cc94f4f 100644 --- a/crates/canvas-pilot/tests/layer_fit.rs +++ b/crates/canvas-pilot/tests/layer_fit.rs @@ -84,7 +84,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() { layout.apply(0, box_geometry()).unwrap(); assert_eq!(layout.formats().advanced[0], crop); let before = Project::from_layout(&layout); - assert_eq!(before.version, 15); + assert_eq!(before.version, 16); let loaded = Project::from_json(&before.to_json().unwrap()).unwrap(); assert_eq!(loaded, before); assert_eq!( @@ -107,7 +107,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() { fn v13_migration_defaults_to_normal_crop_and_v14_requires_valid_fit() { let text = include_str!("../../../docs/interfaces/canvas-pilot-v13.example.json"); let migrated = Project::from_json(text).unwrap(); - assert_eq!(migrated.version, 15); + assert_eq!(migrated.version, 16); assert!(migrated.layers.iter().all(|l| l.layer_fit.is_none())); let mut json = serde_json::to_value(&migrated).unwrap(); json["layers"][0] @@ -125,7 +125,7 @@ fn current_documented_example_is_valid() { "../../../docs/interfaces/canvas-pilot-v14.example.json" )) .unwrap(); - assert_eq!(p.version, 15); + assert_eq!(p.version, 16); p.layout().unwrap(); } diff --git a/crates/canvas-pilot/tests/masking.rs b/crates/canvas-pilot/tests/masking.rs index a6763f5..ad1891b 100644 --- a/crates/canvas-pilot/tests/masking.rs +++ b/crates/canvas-pilot/tests/masking.rs @@ -102,7 +102,7 @@ fn mask_schema_migration_validation_reorder_resize_and_atomic_import() { assert_eq!(Project::from_json(&p.to_json().unwrap()).unwrap(), p); let old = include_str!("../../../docs/interfaces/canvas-pilot-v14.example.json"); let migrated = Project::from_json(old).unwrap(); - assert_eq!(migrated.version, 15); + assert_eq!(migrated.version, 16); assert!(migrated.layers.iter().all(|l| l.mask == Mask::default())); let mut json = serde_json::to_value(&p).unwrap(); json["layers"][0].as_object_mut().unwrap().remove("mask"); diff --git a/crates/canvas-pilot/tests/project.rs b/crates/canvas-pilot/tests/project.rs index ed31463..7073e26 100644 --- a/crates/canvas-pilot/tests/project.rs +++ b/crates/canvas-pilot/tests/project.rs @@ -234,7 +234,7 @@ fn persistent_device_links_roundtrip_migrate_and_undo() { include_str!("../../../docs/interfaces/canvas-pilot-v5.example.json"), ] { let p = Project::from_json(text).unwrap(); - assert_eq!(p.version, 15); + assert_eq!(p.version, 16); assert!(p.layers.iter().all(|l| l.device_link.is_none())); } let mut value = serde_json::to_value(&project).unwrap(); @@ -311,7 +311,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() { .unwrap(); old["editor"]["position_corner"] = name.into(); let loaded = Project::from_json(&old.to_string()).unwrap(); - assert_eq!(loaded.version, 15); + assert_eq!(loaded.version, 16); assert_eq!(loaded.editor.position_point, expected); old["editor"]["position_corner"] = "center".into(); assert!(Project::from_json(&old.to_string()).is_err()); @@ -320,7 +320,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() { assert!(Project::from_json(&old.to_string()).is_err()); } let value: serde_json::Value = serde_json::from_str(¤t.to_json().unwrap()).unwrap(); - for version in [0, 16] { + for version in [0, 17] { let mut invalid = value.clone(); invalid["version"] = version.into(); assert!( @@ -361,7 +361,7 @@ fn backdrop_title_roundtrips_and_older_projects_gain_the_default() { } let old = include_str!("../../../docs/interfaces/canvas-pilot-v6.example.json"); let migrated = Project::from_json(old).unwrap(); - assert_eq!(migrated.version, 15); + assert_eq!(migrated.version, 16); assert_eq!(migrated.editor.backdrop_title, DEFAULT_BACKDROP_TITLE); let mut invalid: serde_json::Value = serde_json::from_str(old).unwrap(); invalid["editor"]["backdrop_title"] = "Unexpected".into(); @@ -432,7 +432,7 @@ fn saved_pivots_roundtrip_and_old_projects_default_to_center() { assert_eq!(loaded.layer_info(0).pivot, custom); assert_eq!(loaded.layer_info(1).pivot, [0.5; 2]); let example = include_str!("../../../docs/interfaces/canvas-pilot-v9.example.json"); - assert_eq!(Project::from_json(example).unwrap().version, 15); + assert_eq!(Project::from_json(example).unwrap().version, 16); let old = include_str!("../../../docs/interfaces/canvas-pilot-v8.example.json"); let migrated = Project::from_json(old).unwrap(); assert!(migrated.layers.iter().all(|l| l.pivot == [0.5; 2])); @@ -464,7 +464,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz let reference = serde_json::json!({"name":"guide.png","image_base64":STANDARD.encode(b"image bytes"),"visible":false,"opacity":0.4,"preserve_ratio":true,"native_size":false,"offset":[0.0,0.0]}); old["reference"] = reference.clone(); let migrated = Project::from_json(&old.to_string()).unwrap(); - assert_eq!(migrated.version, 15); + assert_eq!(migrated.version, 16); assert_eq!(migrated.references.len(), 1); assert!(!migrated.references[0].visible); assert_eq!(migrated.references[0].opacity, 0.4); @@ -484,7 +484,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz gallery.references = vec![migrated.references[0].clone(); 33]; assert!(gallery.to_json().unwrap_err().contains("32 reference")); let example = include_str!("../../../docs/interfaces/canvas-pilot-v10.example.json"); - assert_eq!(Project::from_json(example).unwrap().version, 15); + assert_eq!(Project::from_json(example).unwrap().version, 16); } #[test] @@ -606,3 +606,55 @@ fn workspace_roundtrip_migration_and_validation() { missing.as_object_mut().unwrap().remove("workspace"); assert!(Project::from_json(&missing.to_string()).is_err()); } + +#[test] +fn input_proposals_migrate_validate_and_require_explicit_version_16() { + let old = include_str!("../../../docs/interfaces/canvas-pilot-v15.example.json"); + let migrated = Project::from_json(old).unwrap(); + assert_eq!(migrated.version, 16); + assert!(migrated.input_proposals.is_empty()); + let fixture = include_str!("../../../docs/interfaces/canvas-pilot-v16.example.json"); + let project = Project::from_json(fixture).unwrap(); + assert_eq!(project.input_proposals.len(), 1); + assert_eq!( + Project::from_json(&project.to_json().unwrap()).unwrap(), + project + ); + let mut json = serde_json::to_value(&project).unwrap(); + json.as_object_mut().unwrap().remove("input_proposals"); + assert!(Project::from_json(&json.to_string()).is_err()); + for (pointer, value) in [ + ("/version", serde_json::json!(15)), + ("/input_proposals/0/layer_id", serde_json::json!(999)), + ( + "/input_proposals/0/input", + serde_json::json!("INPUT_4/../../source"), + ), + ("/input_proposals/0/plug", serde_json::json!("0")), + ( + "/input_proposals/0/device_link/layer", + serde_json::json!("999"), + ), + ( + "/input_proposals/0/settings/aspect~1pp~1customRatio", + serde_json::json!(0), + ), + ] { + let mut invalid = serde_json::to_value(&project).unwrap(); + *invalid.pointer_mut(pointer).unwrap() = value; + assert!( + Project::from_json(&invalid.to_string()).is_err(), + "{pointer}" + ); + } + let mut invalid = project.clone(); + invalid.input_proposals[0] + .settings + .insert("source/pp/input".into(), serde_json::json!("INPUT_9")); + assert!(invalid.to_json().is_err()); + let mut duplicate = project.clone(); + duplicate + .input_proposals + .push(project.input_proposals[0].clone()); + assert!(duplicate.to_json().is_err()); +} diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 11d60bc..92c3bf5 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,15 @@ ## Unreleased +- Added opt-in saved input correction proposals (project v16), restored inactive + until mapping/input review and explicit staging; older projects migrate safely. +- Added FigCraft embedded snapshots and full-state round-trip coverage across all + snapshot codecs, including fit modes, blanking, shared inputs and mappings. +- Ranked file formats and starter downloads by preservation tier, with compact + format pills and a separate advanced feature matrix. FIG, DWG and AI still + require a companion project for editable settings. + + - Classified book and application localization as a stretch goal, retaining its detailed roadmap and acceptance checklist. diff --git a/docs/canvas-pilot/guide/advanced-exchange.md b/docs/canvas-pilot/guide/advanced-exchange.md new file mode 100644 index 0000000..57c103d --- /dev/null +++ b/docs/canvas-pilot/guide/advanced-exchange.md @@ -0,0 +1,85 @@ +# Advanced exchange feature matrix + +[Format tiers and basic matrix](format-matrix.md) · [Starter downloads](../../templates/canvas-pilot/catalog.md) + +Gold saves the full project. Silver restores an optional embedded snapshot. Bronze +imports geometry only. These tiers describe Canvas Pilot state preservation, not +application quality or a guarantee that third-party editors retain metadata. + +## Which editing features survive? + +This table separates editable state from a picture of its appearance. “Snapshot” +means a supported exchange format exported with extra parameters and reopened through **Restore parameters from export**. + +| Feature | Project Open/Save | Plain geometry file import | Snapshot restore | +| --- | :---: | :---: | :---: | +| Layer position and size | ✅ | ✅ | ✅ | +| Full-precision saved coordinates | ✅ | ❌ [1](#editing-notes) | ✅ | +| Output screen resolution | ✅ | ❌ | ✅ | +| Layer names and stacking order | ✅ | ❌ | ✅ | +| Folders, collapsed folders, visibility and locks | ✅ | ❌ | ✅ [2](#editing-notes) | +| Source formats, assignments and shared input relationships | ✅ | ❌ | ✅ [2](#editing-notes) | +| Input crop edges | ✅ | ❌ | ✅ | +| Normal layer crop zoom and offsets | ✅ | ❌ | ✅ | +| Advanced fit modes and their crop edges | ✅ | ❌ | ✅ | +| Editable blanking masks | ✅ | ❌ | ✅ | +| Resize pivots and group resize settings | ✅ | ❌ | ✅ | +| Saved device screen/layer links (not physical source routing) | ✅ | ❌ | ✅ | +| Opt-in saved device input correction proposals, restored inactive | ✅ | ❌ | ✅ | +| Reference images and their individual settings | ✅ | ❌ | ❌ | +| Capture assignments and saved preview stills | ✅ | ❌ | ❌ | +| Selection, camera, guides, snapping and workspace settings | ✅ | ❌ | ✅ [2](#editing-notes) | +| Undo history, pending edits and active device operations | ❌ | ❌ | ❌ | +| Application theme, connection history and Program permission | ❌ [3](#editing-notes) | ❌ | ❌ | + +### Editing notes + +1. Geometry **exports round boxes to whole pixels**; import can retain fractional + coordinates where the reader supports them. Use a project or snapshot for + full-precision recovery. Geometry import never reorders destination layers. +2. Snapshot restoration includes only exported layers and their referenced inputs; + selection and folders are filtered accordingly. It replaces the document with + the saved snapshot, not a merge of the external artwork's latest edits. +3. Application preferences are saved separately from projects. Opening a project + or restoring a snapshot does not connect or send to a switcher. + +For a complete editable backup, **Save project** remains the recommended choice. + +## Saved input corrections + +In the advanced input controls, explicitly choose **Save staged input edits as a +project proposal** to retain the corrections you have staged. Projects save these +proposals; Silver exports include them only when **Include extra Canvas Pilot +parameters (experimental)** is enabled. Saving a proposal is optional and separate +from staging or sending it. + +Proposals cover Content ratio, Transform to, custom ratio, layer fill, input crop +preset and the four input crop edges. Local source dimensions/crops and shared +source assignments already belong to the project and need no proposal. + +Opening a project or restoring a snapshot leaves corrections **inactive**. Connect, +check the layer's device mapping and routed input/plug, enable advanced input edits, +and choose **Stage saved input proposal**. Review before sending. A changed mapping, +input/plug or missing device field prevents staging. Corrections affect shared +inputs and can therefore affect other layers and Program. Removing a saved proposal +does not undo device changes or discard separately staged edits. + +## Limits and round trips + +Silver formats are SVG, draw.io, geometry JSON, HTML, PPTX, FigCraft, CSV and DXF. +Their snapshots preserve the original values, independently of rounded artwork. +They do not turn crop, mask or source settings into native editing controls in the +other application. Background/placeholder pictures can show the result, but cannot +restore editable state by themselves. + +FIG, DWG and AI have no verified metadata carrier through the current codecs. +Keep a `.pilot.json` companion when using these Bronze formats. Clipboard geometry +also does not restore embedded snapshots. Use **Restore parameters from export** +for Silver; use ordinary geometry import for the artwork's latest positions. + +Automated round trips cover all fit modes, fractional crops and masks, shared +inputs, mappings, saved proposals and workspace state through every Silver codec. +FigCraft metadata is also tested through its native load/save cycle. External +application resaves can strip metadata; this is not a promise of lossless round +trips through every editor. See the [carrier contract](../../interfaces/midra-extra-parameters.md) +for format-specific limits and validation evidence. diff --git a/docs/canvas-pilot/guide/device.md b/docs/canvas-pilot/guide/device.md index 0e30473..69407f1 100644 --- a/docs/canvas-pilot/guide/device.md +++ b/docs/canvas-pilot/guide/device.md @@ -190,3 +190,5 @@ store. Connect, load and send remain background operations. Input snapshots reta pooled, throttled, opt-in behavior, including inputs above 16. Older firmware, linked units and other Aquilon models remain unverified. See the [adapter contract](../../interfaces/device-adapters.md) for tested scope and limits. + +Saved device input corrections are optional [inactive proposals](advanced-exchange.md#saved-input-corrections); opening a file never enables or sends them. diff --git a/docs/canvas-pilot/guide/files.md b/docs/canvas-pilot/guide/files.md index 6a7e341..71e2d43 100644 --- a/docs/canvas-pilot/guide/files.md +++ b/docs/canvas-pilot/guide/files.md @@ -329,7 +329,9 @@ refresh reopens paused until you capture or resume it explicitly. Connection history, startup connection, theme and Program permission remain in application preferences. Unsaved drafts, undo history, open menus, active editing gestures and pending device operations are temporary. Transfer scope, target bank, -sizing strategy and opt-in advanced device input edits remain session choices. +sizing strategy and the permission to send advanced input edits remain session choices. +Explicitly saved input correction proposals persist, but always reopen inactive. +See [saved input corrections](advanced-exchange.md#saved-input-corrections). See the [complete persistence audit](../../interfaces/canvas-pilot-persistence-audit.md) and [versioned project contract](../../interfaces/canvas-pilot.md). @@ -338,10 +340,10 @@ and [versioned project contract](../../interfaces/canvas-pilot.md). See [which editing features survive](#which-editing-features-survive) for a comparison of project saves, plain geometry import and snapshot restoration. -In **Export layers**, enable **Include extra Midra parameters (experimental)** to -store the exported layers' source/crop settings, names, folders, links and workspace +In **Export layers**, enable **Include extra Canvas Pilot parameters (experimental)** to +store the exported layers' source/crop settings, fit modes, masks, saved input proposals, names, folders, links and workspace setup alongside the geometry. It is available for SVG, draw.io, JSON, CSV, DXF, -HTML and PPTX. Images/capture assignments are excluded from this snapshot; the +HTML, PPTX and FigCraft. Images/capture assignments are excluded from this snapshot; the background and placeholder options remain separate. DWG, FIG and AI show why the option is unavailable with the current codecs. @@ -357,41 +359,8 @@ See the [format-by-format audit and metadata contract](../../interfaces/midra-ex ## Which editing features survive? -This table separates editable state from a picture of its appearance. “Snapshot” -means a supported exchange format exported with extra parameters and reopened through **Restore parameters from export**. - -| Feature | Project Open/Save | Plain geometry file import | Snapshot restore | -| --- | :---: | :---: | :---: | -| Layer position and size | ✅ | ✅ | ✅ | -| Full-precision saved coordinates | ✅ | ❌ [1](#editing-notes) | ✅ | -| Output screen resolution | ✅ | ❌ | ✅ | -| Layer names and stacking order | ✅ | ❌ | ✅ | -| Folders, collapsed folders, visibility and locks | ✅ | ❌ | ✅ [2](#editing-notes) | -| Source formats, assignments and shared input relationships | ✅ | ❌ | ✅ [2](#editing-notes) | -| Input crop edges | ✅ | ❌ | ✅ | -| Normal layer crop zoom and offsets | ✅ | ❌ | ✅ | -| Advanced fit modes and their crop edges | ✅ | ❌ | ✅ | -| Editable blanking masks | ✅ | ❌ | ✅ | -| Resize pivots and group resize settings | ✅ | ❌ | ✅ | -| Saved device screen/layer links | ✅ | ❌ | ✅ | -| Reference images and their individual settings | ✅ | ❌ | ❌ | -| Capture assignments and saved preview stills | ✅ | ❌ | ❌ | -| Selection, camera, guides, snapping and workspace settings | ✅ | ❌ | ✅ [2](#editing-notes) | -| Undo history, pending edits and active device operations | ❌ | ❌ | ❌ | -| Application theme, connection history and Program permission | ❌ [3](#editing-notes) | ❌ | ❌ | - -### Editing notes - -1. Geometry **exports round boxes to whole pixels**; import can retain fractional - coordinates where the reader supports them. Use a project or snapshot for - full-precision recovery. Geometry import never reorders destination layers. -2. Snapshot restoration includes only exported layers and their referenced inputs; - selection and folders are filtered accordingly. It replaces the document with - the saved snapshot, not a merge of the external artwork's latest edits. -3. Application preferences are saved separately from projects. Opening a project - or restoring a snapshot does not connect or send to a switcher. - -For a complete editable backup, **Save project** remains the recommended choice. +See the [advanced feature matrix](advanced-exchange.md) for complete project, snapshot +and geometry-only preservation, including input corrections. ## Illustrator AI: optional converter required diff --git a/docs/canvas-pilot/guide/format-matrix.md b/docs/canvas-pilot/guide/format-matrix.md index 2769029..c1dc588 100644 --- a/docs/canvas-pilot/guide/format-matrix.md +++ b/docs/canvas-pilot/guide/format-matrix.md @@ -15,31 +15,32 @@ a reference, not interactive controls. ## File exchange matrix -Rows run from fullest support to most limited: complete project saves first, -then formats with restorable settings (pictures break ties), then geometry/artwork -formats without those settings. AI comes last because it also needs an external -converter. Formats with matching capabilities are effectively tied; choose the -one your editor supports. +**Gold — complete project:** `.pilot.json` retains editable state and images. +**Silver — optional snapshot:** eight exchange formats preserve advanced settings +when extra parameters are enabled. **Bronze — geometry/artwork:** FIG, DWG and AI +need a companion project to retain those settings. Tiers describe preservation; +formats within a tier are tied, with picture-capable formats listed first. +See the [advanced feature matrix](advanced-exchange.md) for every saved feature. All eleven exchange formats import and export layer positions and sizes. Geometry import maps boxes to **existing destination layers**: it keeps their names, source settings and device links, and does not change the output resolution. File names and layer labels can help identify the boxes; they do not rename destinations. -| File | Import | Export | Layer names in export | Background picture [1](#file-notes) | Crop/mask preview pictures [1](#file-notes) | Extra settings snapshot | +| File / tier | Import | Export | Exported names | Background [1](#file-notes) | Crop/mask pictures [1](#file-notes) | Settings snapshot | | --- | :---: | :---: | :---: | :---: | :---: | :---: | -| Canvas Pilot project (`.pilot.json`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| SVG (`.svg`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | -| draw.io (`.drawio`, XML) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | -| Geometry JSON (`.json`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | -| HTML / CSS (`.html`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | -| PowerPoint (`.pptx`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | -| Geometry CSV (`.csv`) | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ [4](#file-notes) | -| DXF (`.dxf`) | ✅ | ✅ | ✅ [2](#file-notes) | ❌ | ❌ | ✅ [4](#file-notes) | -| Figma file (`.fig`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | -| FigCraft file (`.figcraft`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | -| DWG (`.dwg`) [3](#file-notes) | ✅ | ✅ | ✅ [2](#file-notes) | ❌ | ❌ | ❌ | -| Illustrator file (`.ai`) [3](#file-notes) | ✅ | ✅ | ✅ [2](#file-notes) | ✅ | ✅ | ❌ | +| 🥇 Gold
![Canvas Pilot](../../images/formats/project.svg) Canvas Pilot project (`.pilot.json`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 🥈 Silver
![SVG](../../images/formats/svg.svg) SVG (`.svg`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![draw.io](../../images/formats/drawio.svg) draw.io (`.drawio`, XML) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![JSON](../../images/formats/json.svg) Geometry JSON (`.json`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![HTML](../../images/formats/html.svg) HTML / CSS (`.html`) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![PowerPoint](../../images/formats/pptx.svg) PowerPoint (`.pptx`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![FigCraft](../../images/formats/figcraft.svg) FigCraft file (`.figcraft`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ [4](#file-notes) | +| 🥈 Silver
![CSV](../../images/formats/csv.svg) Geometry CSV (`.csv`) | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ [4](#file-notes) | +| 🥈 Silver
![DXF](../../images/formats/dxf.svg) DXF (`.dxf`) | ✅ | ✅ | ✅ [2](#file-notes) | ❌ | ❌ | ✅ [4](#file-notes) | +| 🥉 Bronze
![Figma](../../images/formats/fig.svg) Figma file (`.fig`) [3](#file-notes) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 🥉 Bronze
![DWG](../../images/formats/dwg.svg) DWG (`.dwg`) [3](#file-notes) | ✅ | ✅ | ✅ [2](#file-notes) | ❌ | ❌ | ❌ | +| 🥉 Bronze
![Illustrator](../../images/formats/ai.svg) Illustrator file (`.ai`) [3](#file-notes) | ✅ | ✅ | ✅ [2](#file-notes) | ✅ | ✅ | ❌ | ### File notes @@ -99,5 +100,5 @@ PNG, JPEG and BMP are **reference-image imports**, not layer-geometry formats. PDF, PSD, VSDX and ODG are not supported geometry-exchange choices. For advanced save and restore details, see -[which editing features survive](files.md#which-editing-features-survive) in the +[the advanced feature matrix](advanced-exchange.md) in the import/export guide. diff --git a/docs/canvas-pilot/guide/formats-and-crop.md b/docs/canvas-pilot/guide/formats-and-crop.md index df2df78..105caf6 100644 --- a/docs/canvas-pilot/guide/formats-and-crop.md +++ b/docs/canvas-pilot/guide/formats-and-crop.md @@ -112,7 +112,7 @@ Opening Source, checking the box, or changing a value does not send. Only fields actually edited are staged for the next explicit Send, and only when that send includes a destination routed to the same input/plug. Untouched aspect/crop settings stay as they are on the machine. Unchecking discards staged edits. -The opt-in and device edits are session-only: disconnecting, changing the device +The permission and staged device edits are session-only: disconnecting, changing the device address or loading a project clears them. Source routing is never changed. Refresh/load after sending to inspect the resulting device content dimensions. @@ -260,3 +260,5 @@ preview model must distinguish sampled input pixels from corrected display proportions and avoid applying a correction twice when loading device-reported content dimensions. These details need evidence before claiming an exact device round trip. + +Saved device input corrections are optional [inactive proposals](advanced-exchange.md#saved-input-corrections); opening a file never enables or sends them. diff --git a/docs/images/formats/ai.svg b/docs/images/formats/ai.svg new file mode 100644 index 0000000..8eee381 --- /dev/null +++ b/docs/images/formats/ai.svg @@ -0,0 +1 @@ +Illustrator diff --git a/docs/images/formats/csv.svg b/docs/images/formats/csv.svg new file mode 100644 index 0000000..0cf33d0 --- /dev/null +++ b/docs/images/formats/csv.svg @@ -0,0 +1 @@ +CSV diff --git a/docs/images/formats/drawio.svg b/docs/images/formats/drawio.svg new file mode 100644 index 0000000..d9f1fe7 --- /dev/null +++ b/docs/images/formats/drawio.svg @@ -0,0 +1 @@ +draw.io diff --git a/docs/images/formats/dwg.svg b/docs/images/formats/dwg.svg new file mode 100644 index 0000000..a9309a5 --- /dev/null +++ b/docs/images/formats/dwg.svg @@ -0,0 +1 @@ +DWG diff --git a/docs/images/formats/dxf.svg b/docs/images/formats/dxf.svg new file mode 100644 index 0000000..db99bc6 --- /dev/null +++ b/docs/images/formats/dxf.svg @@ -0,0 +1 @@ +DXF diff --git a/docs/images/formats/fig.svg b/docs/images/formats/fig.svg new file mode 100644 index 0000000..2848996 --- /dev/null +++ b/docs/images/formats/fig.svg @@ -0,0 +1 @@ +Figma diff --git a/docs/images/formats/figcraft.svg b/docs/images/formats/figcraft.svg new file mode 100644 index 0000000..fd78a9b --- /dev/null +++ b/docs/images/formats/figcraft.svg @@ -0,0 +1 @@ +FigCraft diff --git a/docs/images/formats/html.svg b/docs/images/formats/html.svg new file mode 100644 index 0000000..2c86fb0 --- /dev/null +++ b/docs/images/formats/html.svg @@ -0,0 +1 @@ +HTML diff --git a/docs/images/formats/json.svg b/docs/images/formats/json.svg new file mode 100644 index 0000000..5eee78d --- /dev/null +++ b/docs/images/formats/json.svg @@ -0,0 +1 @@ +JSON diff --git a/docs/images/formats/pptx.svg b/docs/images/formats/pptx.svg new file mode 100644 index 0000000..b5d5651 --- /dev/null +++ b/docs/images/formats/pptx.svg @@ -0,0 +1 @@ +PowerPoint diff --git a/docs/images/formats/project.svg b/docs/images/formats/project.svg new file mode 100644 index 0000000..3aec02b --- /dev/null +++ b/docs/images/formats/project.svg @@ -0,0 +1 @@ +Canvas Pilot diff --git a/docs/images/formats/svg.svg b/docs/images/formats/svg.svg new file mode 100644 index 0000000..9334542 --- /dev/null +++ b/docs/images/formats/svg.svg @@ -0,0 +1 @@ +SVG diff --git a/docs/interfaces/canvas-pilot-exchange.md b/docs/interfaces/canvas-pilot-exchange.md index 6952c03..f498559 100644 --- a/docs/interfaces/canvas-pilot-exchange.md +++ b/docs/interfaces/canvas-pilot-exchange.md @@ -5,7 +5,7 @@ Canvas Pilot was formerly named Midra Layout. The rename preserves existing wire The Export menu writes **SVG v2**, **draw.io v1**, **geometry JSON v1**, **geometry CSV v1**, **DXF/DWG**, **HTML/CSS v1**, **PPTX**, **Figma FIG / FigCraft** and **Illustrator AI** (the latter via a local VectorCraft CLI). Project -JSON is version 15 and is the full-fidelity save format. These exchanges +JSON is version 16 and is the full-fidelity save format. These exchanges preserve layer **visible-box geometry**, not sources, crop settings, zoom, pivots, Midra links, locks, visibility, camera or selection. Pictures illustrate current cropping; importing a picture does not reconstruct its crop or source settings. @@ -176,9 +176,10 @@ extension; unsupported future versions are rejected by the upstream reader. Geometry, page/frame selection, reserved background names and artwork follow the FIG contract above. Export rounds positions and sizes to whole screen pixels; import retains fractional coordinates. One output-sized frame contains the named -layer rectangles. Background and placeholder pictures are optional. Midra source, -crop, mapping and workspace settings are omitted; extra-parameter embedding is -not enabled. FigCraft history, branches and library data are not imported into +layer rectangles. Background and placeholder pictures are optional. Source, crop, fit, mask, +mapping, inactive input proposals and workspace settings can be stored in the +optional [extra-parameter snapshot](midra-extra-parameters.md). Plain geometry import +does not restore these settings. FigCraft history, branches and library data are not imported into Midra or recreated on export. Reader repair warnings appear in the import review. This option shares the FIG vendor feature and is excluded by `no_proprietary`. Tests cover native resaving, bare JSON, geometry, artwork and both starter sizes. @@ -430,10 +431,10 @@ The verifier now uses the unified byte importer for text and binary formats. The `.ai` starter ZIP is only a download wrapper, not a new import format; its two entries must remain byte-identical to the `.ai` fixtures (Python regression). -## Optional extra Midra parameters +## Optional extra Canvas Pilot parameters -Export layers offers **Include extra Midra parameters (experimental)** for SVG, -draw.io, JSON, CSV, DXF, HTML and PPTX. This embeds an inert snapshot separately +Export layers offers **Include extra Canvas Pilot parameters (experimental)** for SVG, +draw.io, JSON, CSV, DXF, HTML, PPTX and FigCraft. This embeds an inert snapshot separately from the artwork. JSON/CSV use geometry version 2 only when enabled; plain exports remain version 1. Other carrier versions remain unchanged. Existing omissions in this document describe plain geometry export; the optional snapshot preserves @@ -442,10 +443,10 @@ capture bindings. See the [complete carrier contract and format audit](midra-ext Restore the original snapshot with **Project → Restore parameters from export…**. Normal geometry import continues to use the artwork's current boxes, including any -external edits. Third-party editors may strip metadata. DWG, FIG, FIGCRAFT and AI are not +external edits. Third-party editors may strip metadata. DWG, FIG and AI are not enabled until their current codec paths can preserve it reliably. -Embedded project snapshots now contain project version 15 and family-aware `device_link` objects. Geometry representation versions are unchanged. Existing embedded versions 1–13 migrate using the [project contract](canvas-pilot.md); plain geometry continues to omit device destinations. +Embedded project snapshots now contain project version 16 and family-aware `device_link` objects. Geometry representation versions are unchanged. Existing embedded versions 1–15 migrate using the [project contract](canvas-pilot.md); plain geometry continues to omit device destinations. Project v14 additionally preserves `layer_fit` in embedded snapshots. Geometry alone describes the layer container when explicit fit is enabled and omits crop diff --git a/docs/interfaces/canvas-pilot-persistence-audit.md b/docs/interfaces/canvas-pilot-persistence-audit.md index cdc6f49..8f94fb8 100644 --- a/docs/interfaces/canvas-pilot-persistence-audit.md +++ b/docs/interfaces/canvas-pilot-persistence-audit.md @@ -2,7 +2,7 @@ Audited against the editor, project loader, application settings, capture controls, layer tree, format properties, import/export controls and device transfer state. -Implemented with [project version 12](canvas-pilot.md). This is an ownership audit: +Current ownership for [project version 16](canvas-pilot.md). This is an ownership audit: not every control should become document data. | Parameters | Owner and decision | @@ -10,7 +10,7 @@ not every control should become document data. | Output resolution / aspect | Project: exact width/height. The output aspect preset is derived from them, not stored twice. | | Layer position, dimensions, stacking order | Project: full-precision bounds and array order; display/export rounding never changes the saved values. | | Input format, native dimensions, custom input crop, shared input slot | Project: `inputs` and layer `source_id`, already saved. | -| Layer format, dynamic crop, zoom and offset | Project: final bounds and advanced crop, already saved. Zoom/offset/aspect are derived from these authoritative values. | +| Layer format, dynamic crop, zoom and offset, explicit fit modes and blanking masks | Project: final bounds and advanced crop, already saved. Zoom/offset/aspect are derived from these authoritative values. | | Names, stable IDs, next ID, folder membership, visibility, lock, pivot | Project, already saved. Folder visibility/locking acts on members, so there is no separate state to save. Explicit folder names are saved separately in project v12 and may have no members. | | Device screen/layer mapping | Project, already saved per layer. Physical source routing is separate and is not silently changed by a geometry send. | | Reference images, order, visibility, opacity, fit/native sizing, offset | Project, already embedded. Focused reference row is temporary. | @@ -33,12 +33,23 @@ not every control should become document data. The [application settings contract](canvas-pilot-settings.md) is unchanged (v8). The [recovery envelope](canvas-pilot-recovery.md) is unchanged (v1); its nested -project migrates to v12. Geometry export representations are unchanged and omit +project migrates to v16. Geometry export representations are unchanged and omit capture images/settings; optional fixed-reference backgrounds retain their existing behavior. -Regression coverage includes current-schema round trips, versions 1–11 migration, +Regression coverage includes current-schema round trips, versions 1–15 migration, invalid assignments/settings and unknown/missing fields, embedded-still decoding, atomic failure on malformed images, cleared stale previews, restore-without-fetch, manual resumption eligibility and saved resize setup. The guide and example JSON are updated with the schema. + +## Version 16 addition: saved input proposals + +Explicitly saved advanced input corrections now belong to the project as inert +`input_proposals`, maintained by `InputEdits.saved` and project save/restore. +The enable flag and staged device writes remain session-only. Opening/recovery +clears those flags and pending writes before installing saved proposals. Export +snapshots filter proposals to included, correctly mapped layers. The +[project contract](canvas-pilot.md#inactive-input-correction-proposals) defines +validation and the [advanced matrix](../canvas-pilot/guide/advanced-exchange.md) +distinguishes these proposals from source geometry and actual device routing. diff --git a/docs/interfaces/canvas-pilot-recovery.md b/docs/interfaces/canvas-pilot-recovery.md index 4c5793a..15b7040 100644 --- a/docs/interfaces/canvas-pilot-recovery.md +++ b/docs/interfaces/canvas-pilot-recovery.md @@ -7,7 +7,7 @@ not a named project export. Headless/default editors never access this path. | Field | Meaning | | --- | --- | | `version` | Integer `1`; other versions rejected | -| `project` | Complete [project v15](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding | +| `project` | Complete [project v16](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding | | `project_path` | Last opened/successfully saved named JSON path, or null; geometry exports do not change it | | `manual_saved_at` | Unix UTC seconds of the last successful explicit project save, or null when unknown; recovery and measurement-point autosaves do not update it | @@ -34,11 +34,11 @@ last successful writer wins. Recovery retains applied values only: no undo history, pending text/format/import drafts, transient tools, or credentials. A normal exit cancels unfinished canvas gestures before the final checkpoint. The schema does not replace named project -JSON: Save continues to emit a bare project v15 document. Opening/New replaces the +JSON: Save continues to emit a bare project v16 document. Opening/New replaces the single recovery slot; New warns with the manual-save age and Save/Discard/Cancel. A failed or cancelled manual save never completes Save-and-create-new. -[Legacy recovery example (embedded project v9, migrated to v15)](canvas-pilot-recovery-v1.example.json) is exercised by the startup regression test. +[Legacy recovery example (embedded project v9, migrated to v16)](canvas-pilot-recovery-v1.example.json) is exercised by the startup regression test. Future breaking envelope changes require a version bump and explicit migration or rejection. Recovery is not an interchange format; use Save for portable files. diff --git a/docs/interfaces/canvas-pilot-v16.example.json b/docs/interfaces/canvas-pilot-v16.example.json new file mode 100644 index 0000000..07cc38c --- /dev/null +++ b/docs/interfaces/canvas-pilot-v16.example.json @@ -0,0 +1,166 @@ +{ + "format": "beffroi.midra-layout", + "version": 16, + "output_resolution": { + "width": 1920, + "height": 1080 + }, + "inputs": [ + { + "id": 1, + "source_format": "sixteen_nine", + "native_resolution": { + "width": 1920, + "height": 1080 + }, + "input_crop": { + "left": 0.0, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + } + }, + { + "id": 2, + "source_format": "sixteen_nine", + "native_resolution": { + "width": 1920, + "height": 1080 + }, + "input_crop": { + "left": 0.0, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + } + } + ], + "layers": [ + { + "id": 2, + "source_id": 1, + "bounds": { + "x": 120.0, + "y": 180.0, + "width": 640.0, + "height": 360.0 + }, + "advanced_crop": { + "left": 0.0, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + }, + "visible": true, + "locked": false, + "name": "Slides", + "folder": "", + "pivot": [ + 0.5, + 0.5 + ], + "device_link": { + "family": "midra4k", + "screen": "1", + "layer": "1" + }, + "layer_fit": null, + "mask": { + "left": 0.0, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + } + }, + { + "id": 1, + "source_id": 2, + "bounds": { + "x": 1160.0, + "y": 180.0, + "width": 640.0, + "height": 360.0 + }, + "advanced_crop": { + "left": 0.0, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + }, + "visible": true, + "locked": false, + "name": "Presenter", + "folder": "", + "pivot": [ + 0.5, + 0.5 + ], + "device_link": null, + "layer_fit": "fullscreen", + "mask": { + "left": 0.1, + "right": 0.0, + "top": 0.0, + "bottom": 0.0 + } + } + ], + "editor": { + "backdrop_title": "Example Conference Name", + "selected_layer_ids": [ + 1 + ], + "position_point": "top_left", + "keep_aspect_ratio": true, + "viewport_zoom": 1.0, + "viewport_pan": [ + 0.0, + 0.0 + ], + "show_source_pattern": false, + "show_toolbar_icon_names": false, + "outline_layers": false, + "position_layer_point": null + }, + "next_layer_id": 3, + "references": [], + "workspace": { + "snapping": { + "enabled": false, + "pixels": true, + "screen_edges": true, + "layer_edges": true, + "grid": false, + "show_grid": true, + "grid_divisions": [ + 8, + 6 + ] + }, + "resize_mode": "individual", + "grid_spacing": null, + "collapsed_folders": [], + "capture_interval_seconds": 10, + "show_empty_inputs": false, + "previews": [] + }, + "folders": [ + "Memory A" + ], + "input_proposals": [ + { + "layer_id": 2, + "device_link": { + "family": "midra4k", + "screen": "1", + "layer": "1" + }, + "input": "INPUT_4", + "plug": "2", + "settings": { + "aspect/pp/transformTo": "CUSTOM", + "aspect/pp/customRatio": 1778 + } + } + ] +} diff --git a/docs/interfaces/canvas-pilot.md b/docs/interfaces/canvas-pilot.md index fcf0bad..8f1b48b 100644 --- a/docs/interfaces/canvas-pilot.md +++ b/docs/interfaces/canvas-pilot.md @@ -7,7 +7,7 @@ These are offline editor formats, not Analog Way REST payloads. Implementation: [`project.rs`](../../crates/canvas-pilot/tests/project.rs). Update this contract, examples and tests in the same change as any save/export schema change. -## Project JSON, version 15 +## Project JSON, version 16 Suggested filename: `layout.pilot.json`. **Open project** accepts any `.json` filename, including legacy `.midra.json` projects, and validates the project @@ -27,10 +27,10 @@ and `next_layer_id: 3`; other values are preserved. The [version 1 example](canvas-pilot-v1.example.json) remains a migration fixture. Version 4 adds `editor.outline_layers: false`, and reference `native_size: false` and `offset: [0, 0]` when migrating versions 1–3. Old fitting behavior is preserved. -Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Version 11 adds required `workspace` settings and embedded layer previews. Versions 1–10 gain the documented workspace defaults, with no captures or collapsed folders; supplying `workspace` in an older schema is rejected. Version 12 adds required `folders`, the explicit folder names that survive without members. Versions 1–11 gain `folders: []`, preserving their existing implicit layer grouping; supplying this field under an older version is rejected. Version 13 replaces `midra_link` with required `device_link`, adding the explicit device family. Versions 1–12 migrate numeric links to `family: "midra4k"`; null remains null, and legacy decimal IDs with leading zeros are canonicalized. Unknown legacy fields are rejected. Version 14 adds required `layers[].layer_fit`: versions 1–13 migrate to null, preserving normal crop/zoom behavior; supplying this field under an older schema is rejected. Version 15 adds required `layers[].mask`; versions 1–14 migrate with four zero edges and reject masks supplied under an older version. Saving always writes version 15; older applications reject it. +Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Version 11 adds required `workspace` settings and embedded layer previews. Versions 1–10 gain the documented workspace defaults, with no captures or collapsed folders; supplying `workspace` in an older schema is rejected. Version 12 adds required `folders`, the explicit folder names that survive without members. Versions 1–11 gain `folders: []`, preserving their existing implicit layer grouping; supplying this field under an older version is rejected. Version 13 replaces `midra_link` with required `device_link`, adding the explicit device family. Versions 1–12 migrate numeric links to `family: "midra4k"`; null remains null, and legacy decimal IDs with leading zeros are canonicalized. Unknown legacy fields are rejected. Version 14 adds required `layers[].layer_fit`: versions 1–13 migrate to null, preserving normal crop/zoom behavior; supplying this field under an older schema is rejected. Version 15 adds required `layers[].mask`; versions 1–14 migrate with four zero edges and reject masks supplied under an older version. Version 16 adds required root `input_proposals`; versions 1–15 migrate to an empty array and reject this field if supplied under an older version. Saving always writes version 16; older applications reject it. Incompatible files are never partially applied. -[Complete example](canvas-pilot-v15.example.json) is a valid project with an empty `Memory A` folder and an Aquilon S1/layer 1 link, +[Complete example](canvas-pilot-v16.example.json) is a valid project with an empty `Memory A` folder, a Midra link and an inactive input correction proposal, with an unlinked Fullscreen example layer and no reference image. New projects label the lower layer `02 / Slides` and the upper layer `01 / Presenter`; existing projects retain their saved IDs/names. It is loaded by the regression tests. @@ -38,7 +38,8 @@ It is loaded by the regression tests. | Root field | Representation / meaning | | --- | --- | | `format` | Exactly `"beffroi.midra-layout"` | -| `version` | Integer `15` | +| `version` | Integer `16` | +| `input_proposals` | Required array, 0–256 inactive correction proposals; at most one per existing layer, with an exactly matching `device_link`. See below. | | `folders` | Required array of 0–256 unique explicit folder names, each trimmed and 1–128 characters. Explicit folders remain even with no members; layer folder labels also form implicit groups. | | `next_layer_id` | Positive integer strictly greater than every layer ID; not rewound by undo | | `output_resolution` | `{ "width": integer, "height": integer }`, screen pixels | @@ -48,6 +49,32 @@ It is loaded by the regression tests. | `editor` | Selection, positioning and viewport preferences | | `workspace` | Required working setup and layer previews, described below | +### Inactive input correction proposals + +Each object has exactly `layer_id` (stable layer ID), `device_link` (the layer's +Midra link), `input` (`INPUT_` plus a canonical positive decimal ID), `plug` +(canonical positive decimal ID) and `settings` (1–9 whitelisted suffix/value pairs). +IDs have at most 16 digits; only the Midra adapter currently supports proposals. +Unknown fields, paths, values, duplicates or mismatched links are rejected. + +| Setting suffix | Value / units | +| --- | --- | +| `aspect/pp/signal` | `NATIVE`, `5_4`, `4_3`, `16_10`, `15_9`, `16_9`, `21_9`, `256_135`, `64_27` | +| `aspect/pp/transformTo` | `SIGNAL`, `5_4`, `4_3`, `16_10`, `15_9`, `16_9`, `21_9`, `CUSTOM` | +| `aspect/pp/customRatio` | Integer 250–10000, thousandths of width/height ratio; 1778 means 1.778:1 | +| `aspect/pp/layerFill` | `LAYER_SETTING`, `1_1`, `CENTERED`, `FULLSCREEN`, `CROPPED` | +| `cropping/control/pp/predefined` | `NONE`, `LETTERBOX_1_78`, `LETTERBOX_1_85`, `LETTERBOX_2_35`, `PILLARBOX_1_33` | +| `cropping/control/pp/left`, `right`, `top`, `bottom` | Integer 0–8191, input pixels; each edge uses the full prefix | + +Proposals are explicitly saved, never inferred from connected-device defaults. +Opening, recovery and snapshot restoration do not enable or stage them. Staging +requires explicit permission, a matching mapped Preview input/plug and every +referenced field in the current snapshot; Send remains separate and preflighted. +They contain no host, authentication, source-routing command or update pulse. +A proposal is a reviewable suggestion, not proof of the connected unit's identity. +Deleting/remapping a layer filters its proposal from subsequent saves. Exports keep +only proposals for included layers. Values retain integer precision. + Input objects: | Field | Representation / meaning | @@ -153,7 +180,7 @@ files require explicit replacement confirmation for Save/exports. Measurement-po clicks and the independent-point toggle are an exception: they reread the current project and atomically update only `editor.position_point` and `editor.position_layer_point`, preserving its other stored values (including external edits). -Older schemas migrate to v15 on this write. No project path is stored in settings; +Older schemas migrate to v16 on this write. No project path is stored in settings; new documents require a first Save. Geometry exports never change the active project path. Missing/invalid/unwritable projects are left untouched and an error is shown; active in-memory choices remain available for a manual Save. A failed no-overwrite write @@ -233,7 +260,7 @@ and `viewBox="0 0 W H"` equal to the output screen. The root carries ## Compatibility changes -Project version 15 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump +Project version 16 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump `version` and either implement a tested migration or clearly reject older/newer files. Changing rectangle/marker semantics requires a corresponding documented exchange-interface revision and importer tests. Update this document and its example @@ -251,7 +278,7 @@ retarget existing links; choosing a destination there explicitly replaces that layer's saved link. Direct send/load actions use each layer's saved screen, independently of the screen currently displayed in the configuration window. -Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 15. +Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 16. ## Folder-scoped Midra transfers @@ -317,7 +344,7 @@ background export behavior. For the complete persistence audit and the reasons for keeping other controls out of project files, see [Project persistence audit](canvas-pilot-persistence-audit.md). -Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 15 and use the same migration on import. +Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 16 and use the same migration on import. ### Explicit layer fit (v14) diff --git a/docs/interfaces/midra-extra-parameters.md b/docs/interfaces/midra-extra-parameters.md index 70e7c54..d7288f2 100644 --- a/docs/interfaces/midra-extra-parameters.md +++ b/docs/interfaces/midra-extra-parameters.md @@ -1,6 +1,6 @@ -# Extra Midra parameters in geometry exports +# Extra Canvas Pilot parameters in geometry exports -This optional extension is selected by **Export layers → Include extra Midra +This optional extension is selected by **Export layers → Include extra Canvas Pilot parameters (experimental)**. It defaults off. Plain exports retain their existing representation. Native **Save project** already saves the full project and needs no additional switch. @@ -24,10 +24,10 @@ external editor moves/resizes a shape without updating the embedded snapshot. | HTML | `` in `` | Inert document metadata, no scripts or hidden visible objects. HTML geometry version stays 1. | | PPTX | `docProps/custom.xml`, string property `beffroi_midra_parameters` | Standard custom-properties content type and package-root relationship; `vt:lpwstr`, pid 2, fmtid `{D5CDD505-2E9C-101B-9397-08002B2CF9AE}`. Existing ZIP parts are preserved; native DeckCraft import checks unchanged geometry. Microsoft PowerPoint resave not tested here. | | DWG | Not enabled | DXF comments do not provide a reliable binary-DWG carrier. XRECORD/XData are potential future paths, but the current Craft conversion bridge has no verified application-payload round trip. No bytes are appended to the binary file. | -| FigCraft FIGCRAFT | Not enabled | Native geometry and image exchange only; no Midra snapshot field is emitted or restored. | +| FigCraft FIGCRAFT | First page node `plugin_data.beffroi_midra_parameters` in native v1 `document.json` | ZIP and bare JSON restore supported. Native FigCraft 0.5.1 load/save preserves the field. Duplicate payloads are rejected; document JSON reads are bounded to 16 MiB. Other ZIP members are preserved. | | Figma FIG | Not enabled | Figma has plugin data, but the installed FigCraft 0.5.1 native exporter explicitly warns `plugin data was left out`. Its model field is not evidence of native preservation. | | Illustrator AI | Not enabled | PDF-compatible AI can have document metadata, but the current VectorCraft SVG↔AI conversion path has no verified application-payload preservation. No unverified PDF/AI trailer changes are made. | -| Midra project JSON | Already complete | Project v13 remains the authoritative full-fidelity save. This task does not change its schema. | +| Midra project JSON | Already complete | Project v16 remains the authoritative full-fidelity save. | Unsupported codecs disable the option with an explanation. Programmatic attempts to request the extension on those codecs fail explicitly, never silently discard @@ -36,14 +36,14 @@ it. Vendor availability and the `no_proprietary` build flag still apply. ## Payload contract (extension version 1) `BASE64` is standard padded RFC 4648 base64 of UTF-8, pretty-printed -[project JSON](canvas-pilot.md), currently version 13. It is inert data, not an +[project JSON](canvas-pilot.md), currently version 16. It is inert data, not an executable instruction, URL or file path. Project format/version and validation remain authoritative. Future incompatible carrier/payload meanings require a new extension version and explicit migration or rejection. The snapshot includes only exported layer IDs, in document stack order, with -full-precision bounds, names, folders, visibility, locks, pivots, Midra links, -source/input crop and advanced crop. Only referenced input slots are included; +full-precision bounds, names, folders, visibility, locks, pivots, family-aware device links, +source/input crop, normal/advanced layer crop, all fit modes and blanking masks. Explicitly saved inactive input proposals are filtered to included layers; they never grant permission to stage or send. Only referenced input slots are included; source IDs are remapped consecutively, preserving shared source relationships. Selection, explicit folders and collapsed folders are filtered to retained layers; unrelated empty folders are omitted. Output resolution, positioning, camera, guide and workspace settings remain available. Pixel-rounded diff --git a/docs/manuals/canvas-pilot/SUMMARY.md b/docs/manuals/canvas-pilot/SUMMARY.md index 063aec1..6482eb2 100644 --- a/docs/manuals/canvas-pilot/SUMMARY.md +++ b/docs/manuals/canvas-pilot/SUMMARY.md @@ -14,6 +14,7 @@ - [Layers and editing](../../canvas-pilot/guide/editing.md) - [Canvas and reference images](../../canvas-pilot/guide/canvas.md) - [File and clipboard feature matrix](../../canvas-pilot/guide/format-matrix.md) + - [Advanced exchange feature matrix](../../canvas-pilot/guide/advanced-exchange.md) - [Formats, crop and precision](../../canvas-pilot/guide/formats-and-crop.md) - [Import, export and project files](../../canvas-pilot/guide/files.md) - [Menus and preferences](../../canvas-pilot/guide/preferences.md) diff --git a/docs/manuals/canvas-pilot/book.toml b/docs/manuals/canvas-pilot/book.toml index d230b8e..1dba1e5 100644 --- a/docs/manuals/canvas-pilot/book.toml +++ b/docs/manuals/canvas-pilot/book.toml @@ -8,6 +8,7 @@ src = "src" create-missing = false [output.html] +additional-css = ["manual.css"] site-url = "/manuals/canvas-pilot/" default-theme = "light" preferred-dark-theme = "navy" diff --git a/docs/manuals/canvas-pilot/manual.css b/docs/manuals/canvas-pilot/manual.css new file mode 100644 index 0000000..fbf6c99 --- /dev/null +++ b/docs/manuals/canvas-pilot/manual.css @@ -0,0 +1,5 @@ +/* Keep feature matrices readable within the normal book column. */ +table td, +table thead th { + padding: 4px 10px; +} diff --git a/docs/templates/canvas-pilot/catalog.md b/docs/templates/canvas-pilot/catalog.md index 9c2d5eb..ad66597 100644 --- a/docs/templates/canvas-pilot/catalog.md +++ b/docs/templates/canvas-pilot/catalog.md @@ -27,33 +27,38 @@ Choose your canvas and format, download the file, then edit it in the matching application or import it through **Import → Geometry file…** in Canvas Pilot. Review the detected rectangles and their destination layers before applying. -| Format | Full HD · 1920 × 1080 | UHD 4K · 3840 × 2160 | Use with | -| --- | --- | --- | --- | -| SVG | [Download .svg](canvas-pilot-1080p-2-layers.svg) | [Download .svg](canvas-pilot-4k-2-layers.svg) | Vector editors and browsers | -| draw.io | [Download .drawio](canvas-pilot-1080p-2-layers.drawio) | [Download .drawio](canvas-pilot-4k-2-layers.drawio) | diagrams.net / draw.io | -| Geometry JSON | [Download .json](canvas-pilot-1080p-2-layers.json) | [Download .json](canvas-pilot-4k-2-layers.json) | Scripts and geometry exchange | -| Geometry CSV | [Download .csv](canvas-pilot-1080p-2-layers.csv) | [Download .csv](canvas-pilot-4k-2-layers.csv) | Spreadsheets and data tools | -| DXF | [Download .dxf](canvas-pilot-1080p-2-layers.dxf) | [Download .dxf](canvas-pilot-4k-2-layers.dxf) | CAD tools | -| DWG | [Download .dwg](canvas-pilot-1080p-2-layers.dwg) | [Download .dwg](canvas-pilot-4k-2-layers.dwg) | CAD tools; Craft bridge | -| HTML | [Download .html](canvas-pilot-1080p-2-layers.html) | [Download .html](canvas-pilot-4k-2-layers.html) | Browsers and web layouts | -| PowerPoint | [Download .pptx](canvas-pilot-1080p-2-layers.pptx) | [Download .pptx](canvas-pilot-4k-2-layers.pptx) | PowerPoint, LibreOffice Impress or DeckCraft | -| Figma FIG | [Download .fig](canvas-pilot-1080p-2-layers.fig) | [Download .fig](canvas-pilot-4k-2-layers.fig) | Figma or FigCraft | -| FigCraft | [Download .figcraft](canvas-pilot-1080p-2-layers.figcraft) | [Download .figcraft](canvas-pilot-4k-2-layers.figcraft) | FigCraft | -| Illustrator AI (optional) | [Download .ai](canvas-pilot-1080p-2-layers.ai) | [Download .ai](canvas-pilot-4k-2-layers.ai) | Requires VectorCraft CLI for Midra import/export; prefer SVG | +Tiers follow the [format matrix](../../canvas-pilot/guide/format-matrix.md): +**Gold** is a complete `.pilot.json` project saved in Canvas Pilot; **Silver** formats +can carry optional advanced-settings snapshots; **Bronze** exchanges geometry/artwork. +These starter downloads are plain geometry templates, without embedded snapshots. + +| Tier | Format | Full HD · 1920 × 1080 | UHD 4K · 3840 × 2160 | Use with | +| --- | --- | --- | --- | --- | +| 🥈 Silver | ![SVG](../../images/formats/svg.svg) SVG | [Download .svg](canvas-pilot-1080p-2-layers.svg) | [Download .svg](canvas-pilot-4k-2-layers.svg) | Vector editors and browsers | +| 🥈 Silver | ![draw.io](../../images/formats/drawio.svg) draw.io | [Download .drawio](canvas-pilot-1080p-2-layers.drawio) | [Download .drawio](canvas-pilot-4k-2-layers.drawio) | diagrams.net / draw.io | +| 🥈 Silver | ![JSON](../../images/formats/json.svg) Geometry JSON | [Download .json](canvas-pilot-1080p-2-layers.json) | [Download .json](canvas-pilot-4k-2-layers.json) | Scripts and geometry exchange | +| 🥈 Silver | ![HTML](../../images/formats/html.svg) HTML | [Download .html](canvas-pilot-1080p-2-layers.html) | [Download .html](canvas-pilot-4k-2-layers.html) | Browsers and web layouts | +| 🥈 Silver | ![PowerPoint](../../images/formats/pptx.svg) PowerPoint | [Download .pptx](canvas-pilot-1080p-2-layers.pptx) | [Download .pptx](canvas-pilot-4k-2-layers.pptx) | PowerPoint, LibreOffice Impress or DeckCraft | +| 🥈 Silver | ![FigCraft](../../images/formats/figcraft.svg) FigCraft | [Download .figcraft](canvas-pilot-1080p-2-layers.figcraft) | [Download .figcraft](canvas-pilot-4k-2-layers.figcraft) | FigCraft | +| 🥈 Silver | ![CSV](../../images/formats/csv.svg) Geometry CSV | [Download .csv](canvas-pilot-1080p-2-layers.csv) | [Download .csv](canvas-pilot-4k-2-layers.csv) | Spreadsheets and data tools | +| 🥈 Silver | ![DXF](../../images/formats/dxf.svg) DXF | [Download .dxf](canvas-pilot-1080p-2-layers.dxf) | [Download .dxf](canvas-pilot-4k-2-layers.dxf) | CAD tools | +| 🥉 Bronze | ![Figma](../../images/formats/fig.svg) Figma FIG | [Download .fig](canvas-pilot-1080p-2-layers.fig) | [Download .fig](canvas-pilot-4k-2-layers.fig) | Figma or FigCraft | +| 🥉 Bronze | ![DWG](../../images/formats/dwg.svg) DWG | [Download .dwg](canvas-pilot-1080p-2-layers.dwg) | [Download .dwg](canvas-pilot-4k-2-layers.dwg) | CAD tools; Craft bridge | +| 🥉 Bronze | ![Illustrator](../../images/formats/ai.svg) Illustrator AI (optional) | [Download .ai](canvas-pilot-1080p-2-layers.ai) | [Download .ai](canvas-pilot-4k-2-layers.ai) | Requires VectorCraft CLI for Canvas Pilot import/export; prefer SVG | FIG, FIGCRAFT, DXF and DWG import/export were manually reviewed on 2026-11-15. PPTX, draw.io and SVG were previously confirmed; see the [format acceptance list](../../canvas-pilot/plan.md#completed-acceptance). **Prefer SVG when exchanging layouts with Illustrator.** The AI templates remain -available for compatibility, but Midra needs the separately installed VectorCraft +available for compatibility, but Canvas Pilot needs the separately installed VectorCraft CLI to import or export them. See [AI setup](../../canvas-pilot/guide/files.md#illustrator-ai-optional-converter-required). ## Geometry files and saved projects These files exchange visible layer boxes. They do not store the complete editor state, source assignments, crop settings or device links. In particular, the -`.json` starter is **geometry JSON**, not a saved Midra project. Use **Project → +`.json` starter is **geometry JSON**, not a saved Canvas Pilot project. Use **Project → Save project…** for a full `.pilot.json` project; see the [project format](../../interfaces/canvas-pilot.md). Versioned schema and migration examples stay beside their [interface contracts](../../interfaces/README.md). diff --git a/scripts/manuals.py b/scripts/manuals.py index 8e6c88f..2d8c246 100644 --- a/scripts/manuals.py +++ b/scripts/manuals.py @@ -72,6 +72,15 @@ def stage_book(book, destination, root=ROOT): config = book["config"].read_text().split("[manual]", 1)[0] (destination / "book.toml").write_text(config) (src / "SUMMARY.md").write_text(book["summary"]) + for name in book["data"].get("output", {}).get("html", {}).get("additional-css", []): + relative = Path(name) + if relative.is_absolute() or ".." in relative.parts: + raise ValueError(f"Stylesheet must be relative to the book: {name}") + source = source_path(root, book["config"].parent, name) + target = destination / relative + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(root / source, target) + def copy_asset(path): target = src / path diff --git a/tests/test_manuals.py b/tests/test_manuals.py index c0e0030..c6b9ec8 100644 --- a/tests/test_manuals.py +++ b/tests/test_manuals.py @@ -29,11 +29,14 @@ class ManualTests(unittest.TestCase): title = "Example" description = "Example manual" src = "src" +[output.html] +additional-css = ["manual.css"] [manual] icon = "docs/icon.png" ''') self.write("docs/manuals/example/SUMMARY.md", "# Summary\n\n" "- [Intro](../../tool/README.md)\n- [Details](../../tool/detail.md)\n") + self.write("docs/manuals/example/manual.css", "table { color: inherit; }") self.write("docs/icon.png", "image fixture") self.write("docs/tool/README.md", '# Intro\n\n[Detail](detail.md#values)\n' '[Other](../other.md)\n![Icon](../icon.png)\n' @@ -60,6 +63,7 @@ icon = "docs/icon.png" (self.root / "docs/sample.json").read_bytes()) self.assertFalse((stage / "src/docs/other.md").exists()) self.assertNotIn("[manual]", (stage / "book.toml").read_text()) + self.assertEqual((stage / "manual.css").read_text(), "table { color: inherit; }") self.assertEqual((self.root / "docs/tool/README.md").read_bytes(), before) def test_missing_duplicate_outside_and_symlinked_sources_are_rejected(self):