From 8e6838a00fd8077300d6238e8fa2e7465f141a99 Mon Sep 17 00:00:00 2001 From: faumaray Date: Tue, 20 Oct 2026 09:15:44 +0300 Subject: [PATCH] Move the BBCode reader and the Twemoji archive into voelin-ui-vm Both are pure (no Slint): vm/bbcode.rs and emoji.rs with their tests and the packed archive (assets/twemoji.bin, with its license note; the packing script writes it there). voelin-ui keeps the paths crate::vm::bbcode and crate::emoji as re-exports until the callers move. Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 3 ++- crates/voelin-ui-vm/Cargo.toml | 4 ++++ crates/voelin-ui-vm/assets/README.md | 11 +++++++++++ .../{voelin-ui => voelin-ui-vm}/assets/twemoji.bin | Bin .../src/vm => voelin-ui-vm/src}/bbcode.rs | 0 crates/{voelin-ui => voelin-ui-vm}/src/emoji.rs | 8 +------- crates/voelin-ui-vm/src/lib.rs | 2 ++ crates/voelin-ui/Cargo.toml | 2 -- crates/voelin-ui/assets/README.md | 8 ++------ crates/voelin-ui/src/lib.rs | 4 +++- crates/voelin-ui/src/vm/mod.rs | 2 +- scripts/pack-twemoji.py | 6 +++--- 12 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 crates/voelin-ui-vm/assets/README.md rename crates/{voelin-ui => voelin-ui-vm}/assets/twemoji.bin (100%) rename crates/{voelin-ui/src/vm => voelin-ui-vm/src}/bbcode.rs (100%) rename crates/{voelin-ui => voelin-ui-vm}/src/emoji.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index d9e5ed9..08f4313 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9735,7 +9735,6 @@ dependencies = [ "chrono", "dirs", "image", - "miniz_oxide 0.8.9", "png", "serde", "serde_json", @@ -9761,7 +9760,9 @@ name = "voelin-ui-vm" version = "0.0.1-alpha" dependencies = [ "image", + "miniz_oxide 0.8.9", "png", + "unicode-segmentation", "voelin-core", ] diff --git a/crates/voelin-ui-vm/Cargo.toml b/crates/voelin-ui-vm/Cargo.toml index 0e19e2d..0c92157 100644 --- a/crates/voelin-ui-vm/Cargo.toml +++ b/crates/voelin-ui-vm/Cargo.toml @@ -18,6 +18,10 @@ path = "src/lib.rs" # Picture sizes (the header of a file); PNG and JPEG are listed as the # front end's toolkit used to bring them. image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp", "ico"] } +# The Twemoji archive's blocks (raw deflate). +miniz_oxide = "0.8" +# Grapheme clusters for emoji in chat text. +unicode-segmentation = "1.13" voelin-core = { path = "../voelin-core", default-features = false } [dev-dependencies] diff --git a/crates/voelin-ui-vm/assets/README.md b/crates/voelin-ui-vm/assets/README.md new file mode 100644 index 0000000..9cf1e4a --- /dev/null +++ b/crates/voelin-ui-vm/assets/README.md @@ -0,0 +1,11 @@ +# Bundled assets + +- `twemoji.bin`: the Twemoji 15.0 SVGs (3720 emoji, from the `@twemoji/svg` + 15.0.0 package) packed by `scripts/pack-twemoji.py` into blocks of raw + deflate with an index; `src/emoji.rs` reads it. Twemoji graphics by Twitter, + Inc and other contributors, licensed under CC-BY 4.0 + (https://creativecommons.org/licenses/by/4.0/). The files are unchanged + apart from surrounding whitespace. + +It is credited in `THIRD_PARTY_NOTICES.md` and the About page, with the fonts +and icons of the Slint front end (`crates/voelin-ui/assets/README.md`). diff --git a/crates/voelin-ui/assets/twemoji.bin b/crates/voelin-ui-vm/assets/twemoji.bin similarity index 100% rename from crates/voelin-ui/assets/twemoji.bin rename to crates/voelin-ui-vm/assets/twemoji.bin diff --git a/crates/voelin-ui/src/vm/bbcode.rs b/crates/voelin-ui-vm/src/bbcode.rs similarity index 100% rename from crates/voelin-ui/src/vm/bbcode.rs rename to crates/voelin-ui-vm/src/bbcode.rs diff --git a/crates/voelin-ui/src/emoji.rs b/crates/voelin-ui-vm/src/emoji.rs similarity index 98% rename from crates/voelin-ui/src/emoji.rs rename to crates/voelin-ui-vm/src/emoji.rs index 413e950..1d7aaee 100644 --- a/crates/voelin-ui/src/emoji.rs +++ b/crates/voelin-ui-vm/src/emoji.rs @@ -119,12 +119,6 @@ impl Archive { .map(|i| &self.entries[i]) } - /// Number of emoji in the archive. - #[cfg(test)] - pub fn len(&self) -> usize { - self.entries.len() - } - pub fn contains(&self, key: &str) -> bool { self.find(key).is_some() } @@ -350,7 +344,7 @@ mod tests { #[test] fn archive_opens() { let a = archive(); - assert!(a.len() > 3000); + assert!(a.entries.len() > 3000); assert!(a.contains("1f600")); assert!(!a.contains("zzz")); assert_eq!(a.name("1f600"), Some("grinning face")); diff --git a/crates/voelin-ui-vm/src/lib.rs b/crates/voelin-ui-vm/src/lib.rs index 2cbd0a7..65297b6 100644 --- a/crates/voelin-ui-vm/src/lib.rs +++ b/crates/voelin-ui-vm/src/lib.rs @@ -3,8 +3,10 @@ //! Neither Slint nor GPUI is a dependency; each front end converts these //! types (docs/ui.md, "Two crates"). +pub mod bbcode; pub mod bridge; pub mod color; +pub mod emoji; pub mod image; pub mod list; pub mod studio_bridge; diff --git a/crates/voelin-ui/Cargo.toml b/crates/voelin-ui/Cargo.toml index 1a83fa9..db3cfc7 100644 --- a/crates/voelin-ui/Cargo.toml +++ b/crates/voelin-ui/Cargo.toml @@ -24,8 +24,6 @@ dirs = "6" # avatars, icons and banners on TeamSpeak servers are GIF and WebP too (the # decoders are in the tree already, for SVG pictures). image = { version = "0.25", default-features = false, features = ["gif", "webp", "bmp", "ico"] } -# Twemoji archive blocks (raw deflate); already used by png. -miniz_oxide = "0.8" png = "0.18" serde = { version = "1", features = ["derive"] } # Settings and gateway values as JSON (the advanced and integrations pages). diff --git a/crates/voelin-ui/assets/README.md b/crates/voelin-ui/assets/README.md index 0819924..7b0e831 100644 --- a/crates/voelin-ui/assets/README.md +++ b/crates/voelin-ui/assets/README.md @@ -1,11 +1,7 @@ # Bundled assets -- `twemoji.bin`: the Twemoji 15.0 SVGs (3720 emoji, from the `@twemoji/svg` - 15.0.0 package) packed by `scripts/pack-twemoji.py` into blocks of raw - deflate with an index; `src/emoji.rs` reads it. Twemoji graphics by Twitter, - Inc and other contributors, licensed under CC-BY 4.0 - (https://creativecommons.org/licenses/by/4.0/). The files are unchanged - apart from surrounding whitespace. +The Twemoji archive is with the code that reads it, in +`crates/voelin-ui-vm/assets/` (its license note is there). The fonts (Inter, SIL OFL 1.1) and icons (Lucide, ISC) that the Slint files import are under `ui/assets/`, each with its license. All three are credited diff --git a/crates/voelin-ui/src/lib.rs b/crates/voelin-ui/src/lib.rs index 69ca05d..53065d3 100644 --- a/crates/voelin-ui/src/lib.rs +++ b/crates/voelin-ui/src/lib.rs @@ -6,7 +6,6 @@ mod bind; mod camera; mod chat; mod dev; -mod emoji; mod events; mod home; mod hotkey; @@ -28,5 +27,8 @@ mod studio; mod video; mod vm; +// The Twemoji archive and text splitting live with the view models. +use voelin_ui_vm::emoji; + pub use app::{HostedEngine, RunOptions, run}; pub use inbox::{Request, request}; diff --git a/crates/voelin-ui/src/vm/mod.rs b/crates/voelin-ui/src/vm/mod.rs index bee6a0a..a79a6e5 100644 --- a/crates/voelin-ui/src/vm/mod.rs +++ b/crates/voelin-ui/src/vm/mod.rs @@ -4,7 +4,7 @@ //! [`list::sync`], so a small change redraws only what changed. pub mod avatar; -pub mod bbcode; +pub use voelin_ui_vm::bbcode; pub mod chat; pub mod home; pub mod list; diff --git a/scripts/pack-twemoji.py b/scripts/pack-twemoji.py index 3a9918b..a188dc8 100755 --- a/scripts/pack-twemoji.py +++ b/scripts/pack-twemoji.py @@ -2,7 +2,7 @@ """Pack the Twemoji SVGs into one compressed archive for the UI. Colour emoji cannot go through the software renderer's text path, so the UI -shows them as images: `crates/voelin-ui/src/emoji.rs` reads this archive +shows them as images: `crates/voelin-ui-vm/src/emoji.rs` reads this archive (embedded in the binary) and decodes single emoji on demand. Usage: @@ -11,7 +11,7 @@ Usage: The package is @twemoji/svg (15.0.0: `npm pack @twemoji/svg`, unpacked); the directory holds the SVGs named by code points (`1f600.svg`, `1f468-200d-1f4bb.svg`). `out` defaults to -crates/voelin-ui/assets/twemoji.bin. Only the Python standard library is +crates/voelin-ui-vm/assets/twemoji.bin. Only the Python standard library is needed; names come from its `unicodedata` plus a table for the emoji newer than it (Unicode 15), so any Python 3.11+ gives the same file. @@ -247,7 +247,7 @@ def main(): sys.exit(2) src = sys.argv[1] root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - out = sys.argv[2] if len(sys.argv) > 2 else os.path.join(root, "crates/voelin-ui/assets/twemoji.bin") + out = sys.argv[2] if len(sys.argv) > 2 else os.path.join(root, "crates/voelin-ui-vm/assets/twemoji.bin") items = [] for file in os.listdir(src): if not file.endswith(".svg"):