diff --git a/.github/workflows/windows-arm64.yml b/.github/workflows/windows-arm64.yml index a671ff2f2..167839e9e 100644 --- a/.github/workflows/windows-arm64.yml +++ b/.github/workflows/windows-arm64.yml @@ -25,8 +25,8 @@ permissions: jobs: windows-arm64: - # Immutable supporting workflow revision until the new install contract lands upstream. - uses: storytold/craft-common-actions/.github/workflows/windows-arm64.yml@8bb4e5ab95443171104ad88113fe1ef9b0e5ce3f + # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. + uses: storytold/craft-common-actions/.github/workflows/windows-arm64.yml@main with: app-name: cadcraft app-dir: CADCraft diff --git a/AGENTS.md b/AGENTS.md index e436894b2..e3d7418d7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,3 +66,8 @@ People trust CADCraft with their drawings; a crash loses their work. **This outr GitHub profiles). Never hand-edit `contributors.json`. - Maintainers refresh the stats with `python3 ../../craftrules/scripts/contributors.py .` (it also re-verifies who wrote each `people.toml` entry; `--check` only verifies). + +## CI workflows +- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here. +- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time. +- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it. diff --git a/CLAUDE.md b/CLAUDE.md index 33e6a2121..8e4a1fdfa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,3 +47,8 @@ People trust CADCraft with their drawings; a crash loses their work. **This outr ## Roadmap `ROADMAP.md` (committed) is the one-page summary: stage, parity numbers, estimates. It follows craftrules' `standards/progress-docs.md`: the assessment is `docs/target-app-parity.md`, the work list `docs/gaps.md` (pick work from its top rows), milestones `docs/roadmap.md`, deep checklists `docs/geometry-parity.md`, `docs/ui-parity.md`, `docs/file-format-parity.md`, `docs/hardware-parity.md`, `docs/localization-parity.md`. When work lands, update the affected rows and the docs' status lines and revision history. `cargo xtask parity` regenerates the menu-breadth checklist in `docs/parity-checklist.md`. + +## CI workflows +- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here. +- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time. +- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it. diff --git a/Cargo.lock b/Cargo.lock index 34cfc44cc..51693203d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -268,7 +268,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.61.2", + "windows-sys 0.59.0", "wl-clipboard-rs", "x11rb", ] @@ -1191,13 +1191,14 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13afff77f38b5c11b73aa0#92d392cff132eaf53e13afff77f38b5c11b73aa0" +source = "git+https://github.com/storytold/craft-libs?rev=04aa1703b32d299e54f78fcde4182f2b393a9116#04aa1703b32d299e54f78fcde4182f2b393a9116" dependencies = [ "chrono", "dunce", "egui", "flate2", "getrandom 0.3.4", + "image", "log", "plist", "semver", @@ -1642,7 +1643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -3434,7 +3435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4029,7 +4030,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4086,7 +4087,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4561,10 +4562,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.5", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5470,7 +5471,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -6114,9 +6115,9 @@ dependencies = [ [[package]] name = "zip" -version = "9.1.1" +version = "9.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518b847fd864440c379748ad684c449f293af68978a485a4ff16f7c901c1f7c4" +checksum = "1156b39d142a34b999c2310a50455e0cb3760bf7efad0122f796d813bee26ccb" dependencies = [ "crc32fast", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 1d4d7c530..da6bca3b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,8 @@ eframe = { version = "0.37", default-features = false } egui-wgpu = "0.37" # Monotonic time on native and web (performance.now on wasm). web-time = "1.1" -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", features = ["egui"] } +# craft-update: app-specific pretend versions apply to startup and manual checks. +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "04aa1703b32d299e54f78fcde4182f2b393a9116", features = ["egui"] } rfd = "0.17" arboard = { version = "3.6", default-features = false } diff --git a/apps/cadcraft/src/main.rs b/apps/cadcraft/src/main.rs index 19546d6ce..4d7bdc39b 100644 --- a/apps/cadcraft/src/main.rs +++ b/apps/cadcraft/src/main.rs @@ -218,7 +218,7 @@ fn main() -> eframe::Result { let logger = logging::install(); // The update helper relaunches this binary after a self-update; it runs and exits here. #[cfg(not(target_arch = "wasm32"))] - if let Some(done) = craft_update::self_update::finish(&craft_update::suite::CADCRAFT, &std::env::args_os().skip(1).collect::>()) { + if let Some(done) = craft_update::self_update::finish(&cadcraft_ui_egui::UPDATE_APP, &std::env::args_os().skip(1).collect::>()) { if let Err(e) = done { eprintln!("CADCraft update helper failed: {e}"); std::process::exit(1); diff --git a/contributors/people.toml b/contributors/people.toml index 101a329ac..28564415e 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -96,3 +96,6 @@ real_name = "Doan Huynh Huu Khuong" display_name = "Doan Huynh Huu Khuong" sync_github_name = false + +[people.dylanmtaylor] +sync_github_name = true diff --git a/crates/constraints/src/auto.rs b/crates/constraints/src/auto.rs index fe7764205..211be6b93 100644 --- a/crates/constraints/src/auto.rs +++ b/crates/constraints/src/auto.rs @@ -52,15 +52,11 @@ fn collect(d: &Drawing, handles: &[Handle]) -> Geo { g.curves.push((GeomRef::whole(h), ga.center, a.radius)); } } - EntityKind::Circle(c) => { - if c.center.is_finite() && c.radius.is_finite() { - g.curves.push((GeomRef::whole(h), c.center.xy(), c.radius)); - } + EntityKind::Circle(c) if c.center.is_finite() && c.radius.is_finite() => { + g.curves.push((GeomRef::whole(h), c.center.xy(), c.radius)); } - EntityKind::Point(p) => { - if p.p.is_finite() { - g.points.push((GeomRef::whole(h), p.p.xy())); - } + EntityKind::Point(p) if p.p.is_finite() => { + g.points.push((GeomRef::whole(h), p.p.xy())); } EntityKind::LwPolyline(p) => { let n = p.vertices.len(); diff --git a/crates/engine/src/audit.rs b/crates/engine/src/audit.rs index f78de7efe..c055bff25 100644 --- a/crates/engine/src/audit.rs +++ b/crates/engine/src/audit.rs @@ -460,17 +460,13 @@ fn references(d: &mut Drawing, out: &mut Vec) { m.style = "Standard".into(); } } - EntityKind::Table(t) => { - if !has_name(&d.table_styles, &t.style, |s| &s.name) { - note("table style", &t.style); - t.style = "Standard".into(); - } + EntityKind::Table(t) if !has_name(&d.table_styles, &t.style, |s| &s.name) => { + note("table style", &t.style); + t.style = "Standard".into(); } - EntityKind::Leader(l) => { - if !ok_dim(d, &l.style) { - note("dimension style", &l.style); - l.style = "Standard".into(); - } + EntityKind::Leader(l) if !ok_dim(d, &l.style) => { + note("dimension style", &l.style); + l.style = "Standard".into(); } EntityKind::Dimension(dim) => { if !ok_dim(d, &dim.style) { diff --git a/crates/engine/src/cmd/inquiry.rs b/crates/engine/src/cmd/inquiry.rs index c7f59a0cf..0fa342e23 100644 --- a/crates/engine/src/cmd/inquiry.rs +++ b/crates/engine/src/cmd/inquiry.rs @@ -840,11 +840,9 @@ impl Interactive for DistM { let model = model_points(&self.sources); s.echo(format!("Distance = {}", fmt_d(s, path_len(model.as_deref().unwrap_or(pts), &self.bulges)))); } - Input::Keyword(k) if k == "Undo" => { - if pts.len() > 1 { - self.arcs.undo(pts, &mut self.bulges); - self.sources.pop(); - } + Input::Keyword(k) if k == "Undo" && pts.len() > 1 => { + self.arcs.undo(pts, &mut self.bulges); + self.sources.pop(); } Input::Keyword(k) if k == "Length" => self.length = true, Input::Keyword(k) if k == "Total" => return self.total(s, false), @@ -852,10 +850,8 @@ impl Interactive for DistM { self.arcs.close(pts, &mut self.bulges)?; return self.total(s, true); } - Input::Keyword(k) => { - if !self.arcs.keyword(&k, pts) { - s.echo(format!("{k}: not available yet")); - } + Input::Keyword(k) if !self.arcs.keyword(&k, pts) => { + s.echo(format!("{k}: not available yet")); } Input::Enter => return self.total(s, false), _ => {} diff --git a/crates/engine/src/mtext_edit.rs b/crates/engine/src/mtext_edit.rs index 30da0b897..97ecede6f 100644 --- a/crates/engine/src/mtext_edit.rs +++ b/crates/engine/src/mtext_edit.rs @@ -136,11 +136,9 @@ impl Formatted { i += 2; match code { None => {} - Some('P') => { - if f.paras.len() < MAX_PARAS { - f.push_char('\n', &cur); - f.paras.push(props.clone()); - } + Some('P') if f.paras.len() < MAX_PARAS => { + f.push_char('\n', &cur); + f.paras.push(props.clone()); } Some(c @ ('\\' | '{' | '}')) => f.push_char(c, &cur), Some('L') => cur.underline = true, diff --git a/crates/geom/src/nurbs.rs b/crates/geom/src/nurbs.rs index 5268203b1..104ba8d3c 100644 --- a/crates/geom/src/nurbs.rs +++ b/crates/geom/src/nurbs.rs @@ -487,7 +487,7 @@ impl Spline { /// Arc length between parameters `a` and `b` (adaptive Gauss–Legendre over each knot span). pub fn length_between(&self, a: f64, b: f64) -> f64 { - if !self.is_valid() || !(a.is_finite() && b.is_finite()) { + if !(self.is_valid() && a.is_finite() && b.is_finite()) { return 0.0; } let (lo, hi) = self.domain(); diff --git a/crates/io/src/dxf_raw.rs b/crates/io/src/dxf_raw.rs index 0154b01d3..9b755f80f 100644 --- a/crates/io/src/dxf_raw.rs +++ b/crates/io/src/dxf_raw.rs @@ -135,10 +135,8 @@ fn head(tags: &[Tag]) -> Head { h.has_reactors |= group.as_deref() == Some("ACAD_REACTORS"); } (_, Some("ACAD_REACTORS")) => h.reactors.push(norm(&t.str())), - (_, Some("ACAD_XDICTIONARY")) => { - if h.xdict.is_none() { - h.xdict = Some(norm(&t.str())); - } + (_, Some("ACAD_XDICTIONARY")) if h.xdict.is_none() => { + h.xdict = Some(norm(&t.str())); } (_, Some(_)) => {} (5 | 105, None) if h.handle.is_none() => h.handle = Some(norm(&t.str())), diff --git a/crates/io/src/dxf_read/document.rs b/crates/io/src/dxf_read/document.rs index 02ea0f532..d732f4450 100644 --- a/crates/io/src/dxf_read/document.rs +++ b/crates/io/src/dxf_read/document.rs @@ -35,13 +35,11 @@ pub(super) fn parse_entities( extra = more; kindent = Some((c, k)); } - "INSERT" => { - if t.i(66) == Some(1) { - let ins_layer = kindent.as_ref().map(|(c, _)| c.layer.clone()).unwrap_or_default(); - let attribs = insert_attribs(recs, &mut i, &ins_layer); - if let Some((_, EntityKind::Insert(ins))) = kindent.as_mut() { - ins.attribs = attribs; - } + "INSERT" if t.i(66) == Some(1) => { + let ins_layer = kindent.as_ref().map(|(c, _)| c.layer.clone()).unwrap_or_default(); + let attribs = insert_attribs(recs, &mut i, &ins_layer); + if let Some((_, EntityKind::Insert(ins))) = kindent.as_mut() { + ins.attribs = attribs; } } // A VERTEX or ATTRIB with no POLYLINE or INSERT before it; a stray SEQEND holds nothing. diff --git a/crates/render/src/dim/linear.rs b/crates/render/src/dim/linear.rs index 8127aef8f..da1b2a746 100644 --- a/crates/render/src/dim/linear.rs +++ b/crates/render/src/dim/linear.rs @@ -151,9 +151,7 @@ fn position_linear_text(config: &DimConfig<'_>, state: &mut LinearDimState) { state.side_out = if (config.dimension.defpt.xy() - state.p1).dot(state.n) >= 0.0 { state.n } else { -state.n }; state.text_axis = Vec2::from_angle(state.angle); let clearance = |axis: Vec2, across: f64| { - config.gap - + state.text_width * state.text_axis.dot(axis).abs() / 2.0 - + state.text_height * state.text_axis.perp().dot(axis).abs() * across + config.gap + state.text_width * state.text_axis.dot(axis).abs() / 2.0 + state.text_height * state.text_axis.perp().dot(axis).abs() * across }; // Empirical #2004 match: 0.595× height with SHX and 0.601× with TrueType. let off_along = |axis: Vec2| clearance(axis, if st.text_above == 1 { 0.6 } else { 0.5 }); @@ -186,11 +184,8 @@ fn position_linear_text(config: &DimConfig<'_>, state: &mut LinearDimState) { // Half the text height either way, whatever DIMTAD says (#2222). let clear = clearance(state.side_out, 0.5); let lift = clear + 2.0 * config.arrow_size.max(config.tick_size); - state.text_mid = if st.text_move == 1 { - mid + state.side_out * lift + state.u * state.half_extent - } else { - mid + state.side_out * (lift + clear) - }; + state.text_mid = + if st.text_move == 1 { mid + state.side_out * lift + state.u * state.half_extent } else { mid + state.side_out * (lift + clear) }; } else if !config.dimension.user_text_pos { state.text_mid = state.along_center + state.offset; } diff --git a/crates/render/src/text.rs b/crates/render/src/text.rs index 1f80d7af4..8e692facd 100644 --- a/crates/render/src/text.rs +++ b/crates/render/src/text.rs @@ -77,7 +77,7 @@ pub(super) fn mesh(g: &TextGlyph, xf: Mat3, pixel: f64) -> Arc { let contours = ttf::glyph_contours(&g.face, g.gid); let points = contours.iter().map(Vec::len).try_fold(0usize, usize::checked_add); // Font data is untrusted; don't hand unbounded or invalid paths to the tessellator. - if !points.is_some_and(|n| n <= MAX_POINTS) || contours.iter().flatten().any(|p| !p.is_finite() || p.x.abs().max(p.y.abs()) > 1.0e6) { + if points.is_none_or(|n| n > MAX_POINTS) || contours.iter().flatten().any(|p| !p.is_finite() || p.x.abs().max(p.y.abs()) > 1.0e6) { return Arc::new(Mesh { contours: Arc::default(), triangles: Vec::new() }); } let contours = match detail { diff --git a/crates/ui-egui/src/cmdline.rs b/crates/ui-egui/src/cmdline.rs index d78561551..9d8bd9821 100644 --- a/crates/ui-egui/src/cmdline.rs +++ b/crates/ui-egui/src/cmdline.rs @@ -379,13 +379,11 @@ pub fn keyboard(app: &mut CadApp, ctx: &egui::Context) { app.cmd.buffer.pop(); } } - Key::ArrowUp if !modifiers.any() => { - if !app.cmd.history.is_empty() { - let n = app.cmd.history.len(); - let pos = app.cmd.history_pos.map(|p| p.saturating_sub(1)).unwrap_or(n - 1); - app.cmd.history_pos = Some(pos); - app.cmd.buffer = app.cmd.history.get(pos).cloned().unwrap_or_default(); - } + Key::ArrowUp if !modifiers.any() && !app.cmd.history.is_empty() => { + let n = app.cmd.history.len(); + let pos = app.cmd.history_pos.map(|p| p.saturating_sub(1)).unwrap_or(n - 1); + app.cmd.history_pos = Some(pos); + app.cmd.buffer = app.cmd.history.get(pos).cloned().unwrap_or_default(); } Key::ArrowDown if !modifiers.any() => { if !options_key(app, 1) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 22e325cbe..311dd4cbf 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -8,6 +8,15 @@ #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] #![forbid(unsafe_code)] +/// CADCraft as craft-update knows it, with its 128 px icon and accent colour: the update +/// prompt shows both, and an AppImage's menu entry gets the icon. +#[cfg(not(target_arch = "wasm32"))] +pub const UPDATE_APP: craft_update::app::App = craft_update::app::App { + icon_png: Some(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.cadcraft.png")), + accent: Some([0x3e, 0xa6, 0xe8]), + ..craft_update::suite::CADCRAFT +}; + pub mod aliasdlg; pub mod animation; pub mod autosave; diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 1bd05c6f8..ffc625767 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -2,7 +2,6 @@ //! Updates… (desktop only; the web build is always the latest). The flow itself is //! `craft_update::updater::Updater`. -use craft_update::suite::CADCRAFT; use craft_update::updater::{Action, Status, Updater}; use crate::CadApp; @@ -21,7 +20,7 @@ pub struct Runtime { impl Default for Runtime { fn default() -> Self { - Self { updater: Updater::new(&CADCRAFT, VERSION), enabled: false, check_requested: false } + Self { updater: Updater::new(&crate::UPDATE_APP, VERSION), enabled: false, check_requested: false } } } diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs index aab245784..d8db1c526 100644 --- a/xtask/src/layers.rs +++ b/xtask/src/layers.rs @@ -167,11 +167,11 @@ pub fn check(crates: &[Crate]) -> Vec { match classify(&d.name) { // Unregistered deps are reported on their own entry. None => {} - Some(Class::Testkit) => { - if d.kind != DepKind::Dev { - out.push(Violation::TestkitAsNormalDep { krate: c.name.clone() }); - } + Some(Class::Testkit) if d.kind != DepKind::Dev => { + out.push(Violation::TestkitAsNormalDep { krate: c.name.clone() }); } + // Test support is allowed as a dev-dependency, regardless of its layer. + Some(Class::Testkit) => {} Some(dc) => { let to = dc.layer().unwrap_or(u8::MAX); if to >= layer && !(to == layer && intra_layer_allowed(&c.name, &d.name)) {