diff --git a/.github/workflows/audio.yml b/.github/workflows/audio.yml index 5fd971c629..5b9c965a79 100644 --- a/.github/workflows/audio.yml +++ b/.github/workflows/audio.yml @@ -3,9 +3,9 @@ name: Shared audio on: push: branches: [main] - paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "scripts/fetch-opus-vectors.sh", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"] + paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "scripts/fetch-opus-vectors.sh", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"] pull_request: - paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "scripts/fetch-opus-vectors.sh", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"] + paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "scripts/fetch-opus-vectors.sh", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"] workflow_dispatch: permissions: diff --git a/.github/workflows/media.yml b/.github/workflows/media.yml index f4c4e6689b..7d570980dd 100644 --- a/.github/workflows/media.yml +++ b/.github/workflows/media.yml @@ -3,9 +3,9 @@ name: Shared media on: push: branches: [main] - paths: ["crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/media.yml"] + paths: ["crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/media.yml"] pull_request: - paths: ["crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/media.yml"] + paths: ["crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/media.yml"] workflow_dispatch: permissions: diff --git a/.github/workflows/video.yml b/.github/workflows/video.yml index 20afe0d700..0db0f19f30 100644 --- a/.github/workflows/video.yml +++ b/.github/workflows/video.yml @@ -3,9 +3,9 @@ name: Shared video on: push: branches: [main] - paths: ["crates/video/**", "crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/video.yml"] + paths: ["crates/video/**", "crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/video.yml"] pull_request: - paths: ["crates/video/**", "crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/video.yml"] + paths: ["crates/video/**", "crates/media/**", "crates/media-testkit/**", "crates/testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/video.yml"] workflow_dispatch: permissions: diff --git a/Cargo.lock b/Cargo.lock index c636547209..d9a4bed7c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1905,6 +1905,7 @@ dependencies = [ "craft-pst", "craft-quit", "craft-raster-codecs", + "craft-raster3d", "craft-raw", "craft-review", "craft-rtf", @@ -3254,9 +3255,11 @@ dependencies = [ "craft-ui-macros", "craft-xml", "egui", + "global-hotkey", "serde", "serde_json", "tempfile", + "x11rb", ] [[package]] @@ -3803,6 +3806,7 @@ dependencies = [ "craft-docpath", "craft-host", "craft-i18n", + "craft-testkit", "craft-theme", "fmv-macos-events", "futures-lite", @@ -4017,6 +4021,14 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-raster3d" +version = "0.1.0" +dependencies = [ + "rayon", + "thiserror 2.0.21", +] + [[package]] name = "craft-raw" version = "0.1.0" @@ -4747,6 +4759,7 @@ dependencies = [ "base64 0.22.1", "chrono", "craft-host", + "craft-testkit", "craft-theme", "craft-ui", "dunce", @@ -6943,6 +6956,23 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" +[[package]] +name = "global-hotkey" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adda8c76a5139df3bae0eb0413c2cd746f66594e0bb66231a4daa0be3172da70" +dependencies = [ + "crossbeam-channel", + "keyboard-types", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "once_cell", + "thiserror 2.0.21", + "windows-sys 0.59.0", + "x11rb", + "xkeysym", +] + [[package]] name = "glow" version = "0.17.0" diff --git a/Cargo.toml b/Cargo.toml index 817f5c1065..a8c497808f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -236,6 +236,7 @@ craft-text = { path = "crates/text" } craft-tcraft = { path = "crates/tcraft" } craft-texture = { path = "crates/texture" } craft-pbr = { path = "crates/pbr" } +craft-raster3d = { path = "crates/raster3d" } craft-tga = { path = "crates/tga" } craft-timeline = { path = "crates/timeline" } craft-tiff = { path = "crates/tiff" } diff --git a/NOTICE b/NOTICE index baa994eb47..9e09cf4494 100644 --- a/NOTICE +++ b/NOTICE @@ -486,3 +486,11 @@ The Y4M range-backed source in crates/media-source/src/y4m.rs adapts FilmCraft's original implementation (3f137a7ed420cac79b32145f5243b7f98b31f71c), licensed MIT OR Apache-2.0. Source notice retained: Copyright (c) 2026 ArtCraft Team and the FilmCraft contributors. + +The CPU renderer in crates/raster3d (rasterizer, shading, shadow maps, resolve and encoding) and +the copy of it in crates/raster3d/tests/it/reference/ are moved from: +- EffectCraft, crates/render/src/three_d/adv.rs, adv/raster.rs, adv/shade.rs and adv/scene.rs, + revision 2f16feb12f4d5ef601b35b2858f9c9a87077f61e, licensed under the MIT License or the Apache + License, Version 2.0, at your option. + https://github.com/storytold/effectcraft + Copyright (c) 2026 ArtCraft Team and the EffectCraft contributors. diff --git a/README.md b/README.md index 8169bedf9a..64698d8c48 100644 --- a/README.md +++ b/README.md @@ -394,6 +394,11 @@ See the [release notes](CHANGELOG.md) for included functionality and known limit - [`craft-quit`](crates/quit/README.md): native macOS quit, a window close held for unsaved documents, the Quit menu item id and the unsaved-changes question one document at a time (`CloseGuard`). The prompt and the saving stay in each app. +- [`craft-raster3d`](crates/raster3d/README.md): a CPU renderer for a prepared 3D scene, from + EffectCraft: clipping, rasterization with a top-left fill rule, physically based shading, + shadow maps, a box resolve of supersampled output and sRGB encoding. Scenes and sizes are + checked before the target is allocated. `Limits` bounds sizes and coverage work. Preparation can + allocate clipping and triangle buffers before a work-limit error. Building the scene stays in each app. - [`craft-rtf`](crates/rtf/README.md): Rich Text Format: a tokenizer, text decoding in the file's code pages (`\uN`, `\'hh`, single-byte and East Asian multibyte pages), escaping and dates, and a reader and writer for a small neutral model (paragraphs, character formatting, outline levels, tables). @@ -436,7 +441,8 @@ See the [release notes](CHANGELOG.md) for included functionality and known limit test when the variable the caller names is `1`. Any other value of that variable except empty fails the test as a configuration error. Its `corpus` module (the `corpus` feature) checks a corpus folder against a pinned SHA-256 list. Its `fixtures` module (native targets only) generates test fixtures - under `target/fixtures` and publishes each one under a lock. Not published. + under `target/fixtures` and publishes each one under a lock. Its `temp` module makes a new test folder, private to the user on + Unix, that is removed with its contents when dropped (best effort). Not published. - [`craft-text`](crates/text/README.md): text processing below the composer. Its `hyphen` module finds hyphenation points, with a bundled US English dictionary and patterns and optional hypher patterns for 47 more languages (one cargo feature each). With `ui`, the canvas text editor, Character and diff --git a/crates/atomic/src/tests.rs b/crates/atomic/src/tests.rs index 132fd5a0a6..05ce79d82d 100644 --- a/crates/atomic/src/tests.rs +++ b/crates/atomic/src/tests.rs @@ -241,6 +241,35 @@ fn temp_name_format_is_valid() { assert!(name.ends_with(".craft_tmp")); } +#[test] +fn temp_name_keeps_long_non_latin_names_under_the_name_limit() { + // 62 four-byte characters plus ".json" is a valid 253-byte name. + let file = format!("{}.json", "\u{1F600}".repeat(62)); + assert_eq!(file.len(), 253); + let name = temp_name(&file); + assert!(name.len() <= 255, "{} bytes", name.len()); + assert!(name.starts_with(&format!(".{}.", "\u{1F600}".repeat(TEMP_STEM_BYTES / 4)))); + assert!(name.ends_with(".craft_tmp")); +} + +#[test] +fn temp_name_cuts_at_a_character_boundary() { + // TEMP_STEM_BYTES - 1 ASCII bytes, then a two-byte character that would end one byte past the limit. + let file = format!("{}\u{e9}tail", "a".repeat(TEMP_STEM_BYTES - 1)); + let name = temp_name(&file); + assert!(name.starts_with(&format!(".{}.", "a".repeat(TEMP_STEM_BYTES - 1)))); +} + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn saves_a_long_non_latin_name() { + let d = TempDir::new("long-name"); + let p = d.0.join(format!("{}.json", "\u{1F600}".repeat(62))); + assert!(atomic_write(&p, b"saved").is_ok()); + assert_eq!(std::fs::read(&p).ok(), Some(b"saved".to_vec())); + assert_no_temp(&d.0); +} + /// What a [`Planting`] filesystem puts at a stage name just before the stage is created there. #[derive(Clone, Copy, Debug)] enum Obstacle { diff --git a/crates/cloud-ui/src/cloud/mod.rs b/crates/cloud-ui/src/cloud/mod.rs index b99ea2f612..457fb357d5 100644 --- a/crates/cloud-ui/src/cloud/mod.rs +++ b/crates/cloud-ui/src/cloud/mod.rs @@ -6,7 +6,7 @@ //! that says whose storage this is, a Save As page that picks a folder and //! names a file, and a save that refuses to overwrite somebody else's work. //! -//! Three things shape the implementation. +//! Four things shape the implementation. //! //! Nothing here opens a socket. Every call goes through [`CloudBackend`]. A //! host writes that half. This module never learns what it reaches. That keeps @@ -21,6 +21,12 @@ //! list under a heading reads to a user as a broken window. A feature the //! provider does not have is therefore absent, heading and all. //! +//! Nothing here acts on a stale answer. Every answer carries the account +//! generation its job was issued in, and [`pump`] drops one whose generation +//! is no longer current, so a reply that arrives after a sign-out or a new +//! sign-in is not applied to the session that replaced its own. A new kind of +//! answer follows the same rule. +//! //! The application supplies [`CloudApp`]. That is what it alone can answer. //! What its documents are, how bytes become one and back, and the words it //! shows them in. diff --git a/crates/cloud-ui/src/share/mod.rs b/crates/cloud-ui/src/share/mod.rs index 9d03472e50..91c9673e38 100644 --- a/crates/cloud-ui/src/share/mod.rs +++ b/crates/cloud-ui/src/share/mod.rs @@ -5,12 +5,11 @@ //! look or change, add a note, decide whether an email goes out, and see who //! already has access so one of them can be taken away again. //! -//! Three things shape the implementation. +//! Four things shape the implementation. //! //! Nothing here opens a socket. Every call goes through [`ShareBackend`], and //! nothing here reaches the network. A host writes the backend, and this //! module never learns what it talks to. -//! this file. //! //! Nothing here blocks. Answers arrive on a channel and are read once per //! frame. Autocomplete waits [`DEBOUNCE`] after the last keystroke before it @@ -21,6 +20,17 @@ //! false until the service says sharing exists, and an app hides its Share //! control rather than offering a button that fails. Contacts and mail are //! reported separately and are hidden the same way. +//! +//! Nothing here acts on a stale answer. Every request carries a sequence +//! number, and its answer comes back with it. An answer is applied only while +//! the request it answers still stands: an answer to a query the +//! user has typed past, a link granted or an account linked for a sheet that +//! has since closed or moved to another document, and a capabilities answer +//! to a question asked before [`ShareDialog::refresh`], +//! [`ShareDialog::connect`] or [`ShareDialog::signed_out`] are dropped. A +//! withdrawal is the one answer applied by share id instead: the share is gone +//! on the service, so it leaves every list that still shows it. A new kind of +//! answer follows the sequence rule. use std::collections::HashMap; use std::sync::mpsc::{Receiver, Sender}; @@ -226,7 +236,9 @@ struct Sheet { /// Where it could be saved. `None` until the answer arrives. destinations: Option>, destinations_seq: Option, - link_seq: Option, + /// Account links in flight, by request. More than one can be: every + /// unlinked destination stays clickable while another one links. + linking: Vec, /// Which one is selected, by id. destination: Option, /// The name typed while the document still has nowhere to live. @@ -248,7 +260,7 @@ impl Sheet { Sheet { destinations: None, destinations_seq: None, - link_seq: None, + linking: Vec::new(), destination: None, save_as: title.clone(), saving: None, @@ -740,16 +752,16 @@ impl ShareDialog { } } Answer::Linked => { - // An account arrived, so the list is stale. With no sheet open - // there is no list to reload. - if self.open.is_some() { - if let Some(sheet) = &mut self.open { - sheet.destinations = None; - } - let seq = self.issue(Request::Destinations); - if let Some(sheet) = &mut self.open { - sheet.destinations_seq = Some(seq); - } + // Only for the sheet that asked: after the sheet closed, moved + // to another document or the account signed out, a late + // answer asks the service for nothing. + let Some(sheet) = self.open.as_mut().filter(|sheet| sheet.linking.contains(&seq)) else { return }; + // An account arrived, so the list is stale. + sheet.linking.retain(|s| *s != seq); + sheet.destinations = None; + let seq = self.issue(Request::Destinations); + if let Some(sheet) = &mut self.open { + sheet.destinations_seq = Some(seq); } } Answer::Withdrawn { share_id } => { @@ -802,8 +814,8 @@ impl ShareDialog { sheet.destinations_seq = None; sheet.destinations = Some(Vec::new()); sheet.save_error = Some(reason); - } else if sheet.link_seq == Some(seq) { - sheet.link_seq = None; + } else if sheet.linking.contains(&seq) { + sheet.linking.retain(|s| *s != seq); sheet.save_error = Some(reason); } } @@ -845,7 +857,7 @@ impl ShareDialog { // application's business and not this crate's. let seq = self.issue(Request::Link { destination }); if let Some(sheet) = &mut self.open { - sheet.link_seq = Some(seq); + sheet.linking.push(seq); sheet.error = None; } } diff --git a/crates/cloud-ui/src/share/tests.rs b/crates/cloud-ui/src/share/tests.rs index 283ce0274b..188fcdb7fc 100644 --- a/crates/cloud-ui/src/share/tests.rs +++ b/crates/cloud-ui/src/share/tests.rs @@ -307,6 +307,49 @@ fn a_link_granted_after_the_sheet_moved_on_is_not_copied() { assert!(copied(&ctx).is_empty(), "nor after the sheet closed"); } +fn destinations_asked(backend: &Silent) -> usize { + backend.seen().iter().filter(|r| **r == Request::Destinations).count() +} + +fn last_link(dialog: &ShareDialog) -> u64 { + dialog.open.as_ref().and_then(|s| s.linking.last().copied()).expect("asked") +} + +#[test] +fn an_account_linked_for_a_sheet_that_moved_on_asks_for_nothing() { + let (ctx, mut dialog, _) = ready(); + dialog.apply(&ctx, vec![Act::Link("drive".into())]); + let first = last_link(&dialog); + // A second destination is clicked before the first one answers. + dialog.apply(&ctx, vec![Act::Link("mail".into())]); + let second = last_link(&dialog); + dialog.receive(&ctx, first, Ok(Answer::Linked)); + let sheet = dialog.open.as_ref().expect("open"); + assert!(sheet.destinations_seq.is_some(), "the sheet that asked fetches its destinations again"); + assert_eq!(sheet.linking, [second], "the later link is still in flight"); + dialog.receive(&ctx, second, Err("no account".into())); + let sheet = dialog.open.as_ref().expect("open"); + assert!(sheet.linking.is_empty()); + assert_eq!(sheet.save_error.as_deref(), Some("no account")); + + let (ctx, mut dialog, backend) = ready(); + dialog.apply(&ctx, vec![Act::Link("drive".into())]); + let linking = last_link(&dialog); + dialog.close(); + dialog.open("files/plan.docx", "Plan"); + let before = destinations_asked(&backend); + dialog.receive(&ctx, linking, Ok(Answer::Linked)); + assert_eq!(destinations_asked(&backend), before, "the budget's link answer must not ask anything for the plan"); + + let (ctx, mut dialog, backend) = ready(); + dialog.apply(&ctx, vec![Act::Link("drive".into())]); + let linking = last_link(&dialog); + dialog.signed_out(); + let before = destinations_asked(&backend); + dialog.receive(&ctx, linking, Ok(Answer::Linked)); + assert_eq!(destinations_asked(&backend), before, "nothing is asked for an account that signed out"); +} + /// Whether one frame of the sheet offers "Get a link" as a button that can /// be pressed, read off the accessibility tree. fn link_button_enabled(dialog: &mut ShareDialog) -> Option { diff --git a/crates/craft/Cargo.toml b/crates/craft/Cargo.toml index 3aa4039ef3..fbaafba855 100644 --- a/crates/craft/Cargo.toml +++ b/crates/craft/Cargo.toml @@ -238,6 +238,7 @@ craft-shared-vec = { workspace = true, optional = true } craft-ease = { workspace = true, optional = true } craft-i18n-build = { workspace = true, optional = true } craft-pbr = { workspace = true, optional = true } +craft-raster3d = { workspace = true, optional = true } [features] ui = [ @@ -622,6 +623,7 @@ jxl-encode = ["jxl", "craft-jxl/encode"] keymap = ["dep:craft-keymap"] keymap-egui = ["keymap", "craft-keymap/egui"] +keymap-global = ["keymap", "craft-keymap/global"] kiwi = ["dep:craft-kiwi"] @@ -801,6 +803,8 @@ quit = ["dep:craft-quit"] raster-codecs = ["dep:craft-raster-codecs"] +raster3d = ["dep:craft-raster3d"] + raw = ["dep:craft-raw"] raw-arw = ["raw", "craft-raw/arw"] raw-cr2 = ["raw", "craft-raw/cr2"] diff --git a/crates/craft/src/lib.rs b/crates/craft/src/lib.rs index ed6ccb2f84..f3865fae1d 100644 --- a/crates/craft/src/lib.rs +++ b/crates/craft/src/lib.rs @@ -331,6 +331,8 @@ pub use craft_pst as pst; pub use craft_quit as quit; #[cfg(feature = "raster-codecs")] pub use craft_raster_codecs as raster_codecs; +#[cfg(feature = "raster3d")] +pub use craft_raster3d as raster3d; #[cfg(feature = "raw")] pub use craft_raw as raw; #[cfg(feature = "review")] diff --git a/crates/fonts-build/README.md b/crates/fonts-build/README.md index 4d72f41aad..f987b9ca9e 100644 --- a/crates/fonts-build/README.md +++ b/crates/fonts-build/README.md @@ -106,7 +106,10 @@ index, bytes, role }` literals; any struct with those fields and that name in sc `None`, or `Some("tab")` on the face `tab_face()` adds; craft-ui's font stack leads the Monospace family with the `mono` face, the signature family (`FontRef::signature()`) with the `signature` face and the tab-title family with the `tab` face. `EmbeddedFace` itself has `name()`, -`has_script(tag)`, `is_cjk()` and `weight()`. +`has_script(tag)`, `is_cjk()` and `weight()`. Tests and tables written by hand build a face with +`EmbeddedFace::new(family, style, scripts, bytes)`, which sets no `role`, plus `.with_index(n)` +for a face in a collection; both are `const fn`. Code that uses `new` keeps compiling when a +field with a default is added; a struct literal does not. ## Document fonts diff --git a/crates/fonts-build/src/lib.rs b/crates/fonts-build/src/lib.rs index e2d7ed3868..b453ac8b97 100644 --- a/crates/fonts-build/src/lib.rs +++ b/crates/fonts-build/src/lib.rs @@ -87,6 +87,26 @@ pub struct EmbeddedFace { } impl EmbeddedFace { + /// A face at index 0 of `bytes` with no `role`, for tests and for tables written by hand. Code + /// that builds faces with `new` keeps compiling when a field with a default is added; a struct + /// literal does not. + /// + /// ``` + /// use craft_fonts_build::EmbeddedFace; + /// + /// static FACE: EmbeddedFace = EmbeddedFace::new("Sans", "Bold", &["Latn"], b"").with_index(2); + /// assert_eq!((FACE.name().as_str(), FACE.index), ("Sans Bold", 2)); + /// ``` + pub const fn new(family: &'static str, style: &'static str, scripts: &'static [&'static str], bytes: &'static [u8]) -> Self { + Self { family, style, scripts, index: 0, bytes, role: None } + } + + /// The same face at `index` in a font collection (`.ttc`). + #[must_use] + pub const fn with_index(self, index: u32) -> Self { + Self { index, ..self } + } + /// `"