Compare commits

...
Author SHA1 Message Date
Dylan M. TaylorandNikita Rakitin 187afbd4e5 Reuse shared RTF text escaping and Windows-1252 decoding
Keep outline parser and formatting policy local. Preserve exact escaping with explicit compatibility policy and exhaustive scalar/byte oracles. Original text writer and preserved oracle by Nikita Rakitin (beb883d0).

Co-authored-by: Nikita Rakitin <nnnrrr93@gmail.com>
2026-11-15 13:01:05 -05:00
Mex 1af57126a0 fix: reject incomplete Base64 character tails (#2152)
* fix: reject incomplete Base64 character tails

Reject a final six-bit fragment that cannot form a byte while preserving existing accepted encoding forms.

* fix: reject Base64 data after padding

Track padding before accumulator updates and cover the reviewed Zg==A case while retaining whitespace and repeated padding.
2026-11-15 15:55:35 +00:00
Mex b0c532d2d1 fix: lowercase Greek sigma across formatting runs (#2151)
Use whole-text lowercase context while preserving the output pieces for each formatting run, including Unicode expansion.
2026-11-15 15:08:12 +00:00
Mex 3bad02d1f1 fix: skip escaped symbols in RTF Unicode fallback (#2150)
Count an escaped RTF control symbol as one Unicode fallback character and keep parser positions at UTF-8 boundaries. Extend the parser regressions for escaped fallback sequences.
2026-11-15 14:51:32 +00:00
Mex 1ff3b87f5a fix: honor Arabic Letter Mark in paragraph direction detection (#2149)
Recognize U+061C alongside RLM before the alphabetic-character check. Extend directional-mark coverage to preserve first-strong precedence.
2026-11-15 14:12:23 +00:00
Mex 9f7d1c426f fix: round engineering notation after forming the mantissa (#2148)
Keep chart labels such as 999.94 in ##0.0E+00 at 999.9E+00 until the full mantissa actually rounds past its available digits. Add regression coverage for widths, signs, small values, carries and decimal localization.
2026-11-15 13:44:43 +00:00
autocraft-bot[bot] a4674dbd1c Merge pull request #2133 from MMexicann/patch-3
fix(xtask): reject numeric prereleases with leading zeroes
2026-11-15 03:53:24 +00:00
autocraft-bot[bot] 04907481c1 Apply review fixes
- xtask/src/version.rs
2026-11-15 03:43:10 +00:00
autocraft-bot[bot] 3c60448691 Apply review fixes
- xtask/src/version.rs
2026-11-15 03:20:15 +00:00
Mex 772219838e docs: correct the control protocol method reference (#2132)
* DOC2: correct the control method reference

Updated descriptions for various UI commands and actions, including clarifications on parameters and behaviors.

* DOC2: clarify text replacement and slide-show key limits

* DOC2: describe the grid shortcut restriction
2026-11-15 03:01:23 +00:00
FredAppsandFredApps e86c25af9c Release: DeckCraft v0.19.0 on main (#2134)
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
2026-11-14 21:45:54 +01:00
Mex 10fef35fe6 M1: reject leading-zero numeric prerelease versions 2026-11-14 21:35:21 +01:00
10 changed files with 267 additions and 70 deletions
Generated
+33 -18
View File
@@ -853,6 +853,11 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-codepage"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725"
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
@@ -909,6 +914,15 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-rtf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725"
dependencies = [
"craft-codepage",
"encoding_rs",
]
[[package]]
name = "craft-ui"
version = "0.1.0"
@@ -1059,7 +1073,7 @@ checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "deckcraft"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"arboard",
"chrono",
@@ -1081,7 +1095,7 @@ dependencies = [
[[package]]
name = "deckcraft-anim"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"deckcraft-geom",
"deckcraft-model",
@@ -1090,7 +1104,7 @@ dependencies = [
[[package]]
name = "deckcraft-cli"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"deckcraft-engine",
"deckcraft-mcp",
@@ -1100,14 +1114,14 @@ dependencies = [
[[package]]
name = "deckcraft-color"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"serde",
]
[[package]]
name = "deckcraft-engine"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"chrono",
"deckcraft-anim",
@@ -1133,7 +1147,7 @@ dependencies = [
[[package]]
name = "deckcraft-fonts"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"epaint_default_fonts",
"harfrust 0.13.3",
@@ -1145,8 +1159,9 @@ dependencies = [
[[package]]
name = "deckcraft-format"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-rtf",
"deckcraft-model",
"serde",
"serde_json",
@@ -1156,7 +1171,7 @@ dependencies = [
[[package]]
name = "deckcraft-geom"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"kurbo",
"serde",
@@ -1164,7 +1179,7 @@ dependencies = [
[[package]]
name = "deckcraft-mcp"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"deckcraft-engine",
"deckcraft-render",
@@ -1174,7 +1189,7 @@ dependencies = [
[[package]]
name = "deckcraft-media"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-audio",
"craft-media",
@@ -1187,7 +1202,7 @@ dependencies = [
[[package]]
name = "deckcraft-model"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"deckcraft-color",
"deckcraft-geom",
@@ -1199,7 +1214,7 @@ dependencies = [
[[package]]
name = "deckcraft-pdf"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-pdf",
"deckcraft-fonts",
@@ -1217,7 +1232,7 @@ dependencies = [
[[package]]
name = "deckcraft-pptx"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"deckcraft-color",
"deckcraft-engine",
@@ -1233,7 +1248,7 @@ dependencies = [
[[package]]
name = "deckcraft-render"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-metafile",
"deckcraft-anim",
@@ -1252,7 +1267,7 @@ dependencies = [
[[package]]
name = "deckcraft-text"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"chrono",
"deckcraft-color",
@@ -1266,7 +1281,7 @@ dependencies = [
[[package]]
name = "deckcraft-ui-egui"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-ui",
"craft-update",
@@ -1292,7 +1307,7 @@ dependencies = [
[[package]]
name = "deckcraft-web"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"craft-web-api",
"craft-web-host",
@@ -6277,7 +6292,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee"
[[package]]
name = "xtask"
version = "0.18.1"
version = "0.19.0"
dependencies = [
"serde_json",
]
+2 -1
View File
@@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"]
default-members = ["crates/*", "apps/deckcraft", "apps/deckcraft-cli"]
[workspace.package]
version = "0.18.1"
version = "0.19.0"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
@@ -49,6 +49,7 @@ vello_cpu = "0.2"
vello_common = { version = "0.2", default-features = false }
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp", "gif", "tiff", "bmp"] }
# craft-media, craft-audio and craft-video share types and stay on one rev.
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0" }
craft-media = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0", default-features = false }
craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0", default-features = false, features = ["opus-decode"] }
# H.264, HEVC, VP9 and AV1 decoders.
+40 -2
View File
@@ -628,6 +628,7 @@ pub fn base64_decode(s: &str) -> Option<Vec<u8>> {
let mut out = Vec::with_capacity(s.len() / 4 * 3);
let mut acc = 0u32;
let mut bits = 0;
let mut padded = false;
for c in s.bytes() {
let v = match c {
b'A'..=b'Z' => c - b'A',
@@ -635,9 +636,17 @@ pub fn base64_decode(s: &str) -> Option<Vec<u8>> {
b'0'..=b'9' => c - b'0' + 52,
b'+' | b'-' => 62,
b'/' | b'_' => 63,
b'=' | b'\n' | b'\r' | b' ' => continue,
b'=' => {
padded = true;
continue;
}
b'\n' | b'\r' | b' ' => continue,
_ => return None,
} as u32;
// Padding ends the payload; no further data may be decoded.
if padded {
return None;
}
acc = (acc << 6) | v;
bits += 6;
if bits >= 8 {
@@ -645,13 +654,42 @@ pub fn base64_decode(s: &str) -> Option<Vec<u8>> {
out.push(((acc >> bits) & 0xff) as u8);
}
}
Some(out)
// A trailing lone Base64 character cannot encode another byte.
(bits != 6).then_some(out)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn base64_rejects_a_single_character_tail() {
for (encoded, decoded) in [
("", b"".as_slice()),
("Zg==", b"f"),
("Zg", b"f"),
("Zm8=", b"fo"),
("Zm8", b"fo"),
(" Zm9v \r\n", b"foo"),
("data:text/plain;base64,Zm9v", b"foo"),
("+/8=", &[0xfb, 0xff]),
("-_8=", &[0xfb, 0xff]),
] {
assert_eq!(base64_decode(encoded).as_deref(), Some(decoded), "{encoded:?}");
}
for encoded in ["A", "AAAAA", "Zm9vZ", " Zm9vZ \r\n", "data:text/plain;base64,Z"] {
assert!(base64_decode(encoded).is_none(), "{encoded:?}");
}
}
#[test]
fn base64_rejects_data_after_padding() {
assert_eq!(base64_decode("Zg== \r\n=="), Some(b"f".to_vec()));
for encoded in ["Zg==A", "Zg== Zm8=", "Zm8=A", "=Zg", "Zg==\r\nA", "data:text/plain;base64,Zg==A"] {
assert!(base64_decode(encoded).is_none(), "{encoded:?}");
}
}
#[test]
fn the_palette_skips_a_command_that_needs_a_value() {
assert!(needs_arguments("{path}"));
+1
View File
@@ -9,6 +9,7 @@ description = "DeckCraft native file format (.deckcraft: zip of a JSON manifest
workspace = true
[dependencies]
craft-rtf = { workspace = true }
deckcraft-model = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
+102 -29
View File
@@ -10,24 +10,24 @@ use deckcraft_model::text::{Paragraph, RunKind};
/// RTF-escape `s` (non-ASCII as `\uN?`, UTF-16, signed as RTF wants).
fn escape(out: &mut String, s: &str) {
for c in s.chars() {
match c {
'\\' | '{' | '}' => {
out.push('\\');
out.push(c);
}
'\t' => out.push_str("\\tab "),
'\u{b}' | '\n' => out.push_str("\\line "),
c if c.is_ascii() && !c.is_ascii_control() => out.push(c),
c if c.is_ascii() => {}
c => {
let mut buf = [0u16; 2];
for u in c.encode_utf16(&mut buf) {
out.push_str(&format!("\\u{}?", *u as i16));
}
}
}
// Keep outline text literal: the shared writer also supports page/column breaks and
// shorthand controls that this app's deliberately small outline reader does not consume.
// Delegate ordinary spans, including UTF-16 escaping, without allocating a second string.
let mut start = 0;
for (i, c) in s.char_indices() {
let replacement = match c {
'\u{000C}' | '\u{000E}' => "",
'\u{00A0}' => "\\u160?",
'\u{00AD}' => "\\u173?",
'\u{2011}' => "\\u8209?",
'\u{2028}' => "\\u8232?",
_ => continue,
};
craft_rtf::push_esc(out, &s[start..i]);
out.push_str(replacement);
start = i + c.len_utf8();
}
craft_rtf::push_esc(out, &s[start..]);
}
fn runs(out: &mut String, p: &Paragraph) {
@@ -276,6 +276,9 @@ impl Outline<'_> {
while k > 0 && self.i < self.b.len() {
if self.b[self.i] == b'\\' && self.b.get(self.i + 1) == Some(&b'\'') {
self.i = advance(self.rtf, self.i, 4);
} else if self.b[self.i] == b'\\' && self.b.get(self.i + 1).is_some_and(|b| !b.is_ascii_alphabetic()) {
// An escaped control symbol counts as one Unicode fallback character.
self.i = advance(self.rtf, self.i + 1, 1);
} else if matches!(self.b[self.i], b'{' | b'}' | b'\\') {
break;
} else {
@@ -294,7 +297,7 @@ impl Outline<'_> {
&& let Some(h) = hex
&& h != 0
{
self.line.push(cp1252(h));
self.line.push(craft_rtf::codepage::cp1252(h));
}
}
@@ -381,22 +384,75 @@ fn finish_surrogates(s: String) -> String {
out
}
fn cp1252(b: u8) -> char {
const HIGH: [char; 32] = [
'€', '\u{81}', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '\u{8d}', 'Ž', '\u{8f}', '\u{90}', '‘', '’', '“', '”', '•', '–', '—',
'˜', '™', 'š', '›', 'œ', '\u{9d}', 'ž', 'Ÿ',
];
match b {
0x80..=0x9f => HIGH[(b - 0x80) as usize],
_ => b as char,
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
// Frozen pre-cutover implementations are test oracles, not production parsers.
fn legacy_escape(out: &mut String, s: &str) {
for c in s.chars() {
match c {
'\\' | '{' | '}' => {
out.push('\\');
out.push(c);
}
'\t' => out.push_str("\\tab "),
'\u{b}' | '\n' => out.push_str("\\line "),
c if c.is_ascii() && !c.is_ascii_control() => out.push(c),
c if c.is_ascii() => {}
c => {
let mut buf = [0u16; 2];
for u in c.encode_utf16(&mut buf) {
out.push_str(&format!("\\u{}?", *u as i16));
}
}
}
}
}
fn legacy_cp1252(b: u8) -> char {
const HIGH: [char; 32] = [
'€', '\u{81}', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '\u{8d}', 'Ž', '\u{8f}', '\u{90}', '‘', '’', '“', '”', '•', '–',
'—', '˜', '™', 'š', '›', 'œ', '\u{9d}', 'ž', 'Ÿ',
];
match b {
0x80..=0x9f => HIGH[(b - 0x80) as usize],
_ => b as char,
}
}
#[test]
fn shared_escape_preserves_every_unicode_scalar() {
for value in 0..=0x10ffff {
let Some(c) = char::from_u32(value) else { continue };
let mut buf = [0; 4];
let text = c.encode_utf8(&mut buf);
let mut expected = String::new();
let mut actual = String::new();
legacy_escape(&mut expected, text);
escape(&mut actual, text);
assert_eq!(actual, expected, "U+{value:04X}");
}
}
#[test]
fn shared_escape_preserves_mixed_spans_and_append() {
let text = "a\t中\u{a0}b\u{ad}c\u{2011}d\u{2028}e\u{c}f\u{e}g\n😀{}\\";
let mut expected = String::from("prefix:");
let mut actual = expected.clone();
legacy_escape(&mut expected, text);
escape(&mut actual, text);
assert_eq!(actual, expected);
}
#[test]
fn shared_cp1252_preserves_all_bytes() {
for b in 0..=u8::MAX {
assert_eq!(craft_rtf::codepage::cp1252(b), legacy_cp1252(b));
}
}
/// A sign in a `\'hh` escape is not a hex digit and must be ignored.
#[test]
fn hex_escape_rejects_sign() {
@@ -422,6 +478,23 @@ mod tests {
assert_eq!(rtf_to_outline(r"{\rtf1 x\u-70000?y\par}"), "x\u{ee90}y\n");
}
#[test]
fn unicode_fallback_control_symbols_are_skipped() {
for (rtf, expected) in [
(r"{\rtf1\uc1 \u92\\X\par}", "\\X\n"),
(r"{\rtf1\uc1 \u123\{X\par}", "{X\n"),
(r"{\rtf1\uc1 \u125\}X\par}", "}X\n"),
(r"{\rtf1\uc2 \u233\{\}X\par}", "éX\n"),
(r"{\rtf1\uc0 \u92\\X\par}", "\\\\X\n"),
(r"{\rtf1 \\ \{ \}X\par}", "\\ { }X\n"),
(r"{\rtf1\uc1 \u233{X}\par}", "éX\n"),
(r"{\rtf1\uc1 \u233\éX\par}", "éX\n"),
(r"{\rtf1\uc1 \u233\", "é\n"),
] {
assert_eq!(rtf_to_outline(rtf), expected, "{rtf:?}");
}
}
#[test]
fn multibyte_control_symbol_keeps_character_and_following_text() {
assert_eq!(rtf_to_outline("{\\rtf1 A\\éB\\par}"), "AéB\n");
+6 -2
View File
@@ -10,8 +10,8 @@
/// Cyrillic, CJK…) give `false`. Neutral, weak, and whitespace characters are skipped.
pub fn first_strong_is_rtl(text: &str) -> bool {
for c in text.chars() {
if c == '\u{200F}' {
// Right-to-Left Mark (RLM)
if c == '\u{200F}' || c == '\u{061C}' {
// RLM and ALM are strong RTL controls, although neither is alphabetic.
return true;
}
if c == '\u{200E}' {
@@ -76,6 +76,10 @@ mod tests {
#[test]
fn honours_directional_marks() {
assert!(first_strong_is_rtl("\u{200F}Hello"));
assert!(first_strong_is_rtl("\u{061C}Hello"));
assert!(first_strong_is_rtl("\u{061C}"));
assert!(!first_strong_is_rtl("Hello\u{061C}"));
assert!(!first_strong_is_rtl("\u{200E}\u{061C}"));
assert!(!first_strong_is_rtl("\u{200E}مرحبا"));
}
}
+18 -1
View File
@@ -528,6 +528,12 @@ pub fn change_case(s: &str, mode: &str) -> String {
/// `title` and `sentence` carry their word/sentence state across piece boundaries. Each output
/// piece is the changed form of the matching input piece, even where a character changes length.
pub fn change_case_parts(parts: &[&str], mode: &str) -> Vec<String> {
if mode == "lower" {
let lower = parts.concat().to_lowercase();
let mut chars = lower.chars();
// Context changes sigma's form, while each character's expansion length stays the same.
return parts.iter().map(|s| chars.by_ref().take(s.chars().map(|c| c.to_lowercase().count()).sum()).collect()).collect();
}
let mut start = true;
// All characters of all pieces, so word-final sigma sees neighbours across piece boundaries.
let all: Vec<char> = parts.iter().flat_map(|s| s.chars()).collect();
@@ -536,7 +542,6 @@ pub fn change_case_parts(parts: &[&str], mode: &str) -> Vec<String> {
.iter()
.map(|s| match mode {
"upper" => s.to_uppercase(),
"lower" => s.to_lowercase(),
"toggle" => s.chars().map(|c| if c.is_uppercase() { c.to_lowercase().collect::<String>() } else { c.to_uppercase().collect() }).collect(),
_ => {
// `title` restarts after whitespace, sentence case after sentence punctuation.
@@ -593,6 +598,18 @@ mod tests {
assert_eq!(change_case_parts(&["ΟΔΟΣ", " ΜΟΥ"], "title"), ["Οδος", " Μου"]);
}
#[test]
fn lowercase_keeps_context_and_run_boundaries() {
assert_eq!(change_case_parts(&["ΟΔΟ", "Σ"], "lower"), ["οδο", "ς"]);
assert_eq!(change_case_parts(&["ΟΣ", "Α"], "lower"), ["οσ", "α"]);
assert_eq!(change_case_parts(&["", "ΟΔΟ", "", "Σ", ""], "lower"), ["", "οδο", "", "ς", ""]);
assert_eq!(change_case_parts(&["İΟΔΟ", "Σ"], "lower"), ["i\u{307}οδο", "ς"]);
assert_eq!(change_case_parts(&["Ο", "\u{301}", "Σ"], "lower"), ["ο", "\u{301}", "ς"]);
assert_eq!(change_case_parts(&["ΟΣ", "\u{301}", "Α"], "lower"), ["οσ", "\u{301}", "α"]);
assert_eq!(change_case_parts(&["", "", ""], "lower"), ["", "", ""]);
assert!(change_case_parts(&[], "lower").is_empty());
}
#[test]
fn insert_and_split() {
let mut b = body("Hello");
+22 -5
View File
@@ -234,16 +234,18 @@ fn sci(toks: &[Tok], v: f64, sep: char, dec: char) -> Option<String> {
m *= 10.0;
exp -= 1;
}
// Rounding the mantissa to its digits can reach 10 (9.999 as `0.00`).
if format!("{m:.mant_frac$}").starts_with("10") {
m /= 10.0;
exp += 1;
}
}
let step = mant.iter().take_while(|t| **t != Tok::Dot).filter(|t| matches!(t, Tok::Digit(_))).count().max(1) as i32;
let shift = exp.rem_euclid(step);
exp -= shift;
m *= 10f64.powi(shift);
// Round after forming the engineering mantissa: 999.94 as `##0.0` stays 999.9.
// Carry only when rounding exceeds all of the format's integer placeholders.
let carry = 10f64.powi(step);
if format!("{m:.mant_frac$}").parse::<f64>().is_ok_and(|rounded| rounded >= carry) {
m /= carry;
exp += step;
}
let mantissa = fixed(mant, mfirst, mlast, m, sep, dec);
let sign = if exp < 0 {
"-"
@@ -404,6 +406,21 @@ mod tests {
assert_eq!(format("##0.0E+0", 999.96, None), "1.0E+3");
}
#[test]
fn engineering_formats_round_the_full_mantissa() {
for (code, value, expected) in [
("##0.0E+00", 999.94, "999.9E+00"),
("##0.0E+00", 0.99994, "999.9E-03"),
("##0.0E+00", -999.94, "-999.9E+00"),
("#0.0E+00", 99.94, "99.9E+00"),
("##0.0E+00", 999.96, "1.0E+03"),
("#0.0E+00", 99.96, "1.0E+02"),
] {
assert_eq!(format(code, value, None), expected, "{code}, {value}");
}
assert_eq!(format("##0.0E+00", 999.94, Some("de-DE")), "999,9E+00");
}
#[test]
fn never_panics() {
for code in ["", ";", ";;;", "\"", "[", "\\", "0.", ".", "#,", "%", "_", "*", "@", "0E+00", "[$", "\"unterminated"] {
+19 -9
View File
@@ -32,16 +32,11 @@ Coordinates are slide points (1/72 inch; a 16:9 slide is 960 × 540) unless note
| `engine.execute` / `ui.menu.invoke` / `command` | `{command, params}` | Run any command (see `engine.commands`; `deckcraft-cli describe COMMAND` documents one) |
| `engine.commands` | — | Every command: id, label, menu path, shortcut, params doc, enabled / disabled reason |
| `document.inspect` | — | Slides, sections, layouts, shapes, selection |
| `slide.actions` | `{index?}` | Actions on one slide; returns `{index, slideId, actions}`. Each action has an `owner` (shape id/name and group path; text actions also include paragraph/run indexes and run text, plus table row/cell indexes for table text), `event` (`click`, `hover`, `textLink`, or `textHover`), action `type`, `target`, and the full `hyperlink`. Listing is read-only and never executes an action. An empty slide returns `"actions": []`. |
| `ui.inspect` | — | UI state, active tool, window/canvas/slide rects, dialog, `home` (the File tab open over a presentation), `backstage` (its page, also the start screen), slide show state (`grid`, `zoomArm`, `zoom`, `blank`, `presenterPaused`, `presenterSecs`, `notesPx`, `custom`, `goto`; `cells` while See All Slides is open), documents, perf (fps, render ms) |
| `ui.inspect` | — | UI state, active tool, window/canvas/slide rects, dialog, `home` (the File tab open over a presentation), `backstage` (its page, also the start screen), slide show state, `animPreview` (canvas playback: slide, time, duration), documents, perf (fps, render ms) |
| `ui.inspect` | — | UI state, active tool, window/canvas/slide rects, dialog, `home` (the File tab over an open presentation), `backstage` (the current File page, including the start screen), slide show state (`grid`, `zoomArm`, `zoom`, `blank`, `presenterPaused`, `presenterSecs`, `notesPx`, `custom`, `goto`; `cells` when See All Slides is open), `animPreview` (canvas playback: slide, time, duration), documents, perf (fps, render ms) |
| `ui.tool.select` | `{tool, preset?}` | `select`, `text`, `shape` + preset, any preset name, `curve`, `freeform`, `scribble`, `pen`, `highlighter`, `eraser` |
| `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick\|contextclick, x, y, mods?}], mods?}` | Drive the active tool in slide points through the same code path as the mouse (`contextclick`: the right-button press that selects before the context menu) |
| `ui.key` / `ui.text` | `{key, shift?, alt?, cmd?}` / `{text}` | Keyboard input (also drives a running slide show: digits then Enter go to that slide, G is See All Slides, Z arms zoom, T pauses the presenter timer, R resets it, `[` and `]` change notes size, Esc clears a slide number, the grid and zoom before it leaves the show) |
| `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick, x, y, mods?}], mods?}` | Drive the active tool in slide points through the same code path as the mouse |
| `ui.key` / `ui.text` | `{key, shift?, alt?, cmd?}` / `{text}` | Keyboard input (also drives a running slide show; Escape stops the canvas animation preview) |
| `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick, x, y, mods?, pressure?}], mods?}` | Drive the active tool in slide points through the same code path as the mouse. `pressure` is `0..=1` for a pen; omit it for a mouse |
| `ui.key` / `ui.text` | `{key, shift?, alt?, cmd?}` / `{text}` | Keyboard input (also drives a running slide show) |
| `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick\|contextclick, x, y, mods?, pressure?}], mods?}` | Send slide-point pointer events through the active tool's mouse path. `contextclick` performs the right-click selection used by context menus; `pressure` is `0..=1` for a pen and can be omitted for a mouse |
| `ui.key` | `{key, shift?, alt?, cmd?}` | Send a key press. During an active slide show, digits followed by Enter jump to that slide; G opens See All Slides, Z arms zoom, T toggles the presenter timer's pause, R resets it, and `[` / `]` resize notes. Esc clears a typed slide number or backs out of the grid/zoom before ending the active show. Close See All Slides with Esc or G before using the other listed show shortcuts. Slide-show keys ignore modifier flags; use `show.end` to leave the end-of-show screen. Outside a show, Escape stops canvas animation preview |
| `ui.text` | `{text}` | Insert into the current text edit. With one shape selected and no active text edit, begin editing and replace the shape's existing text |
| `ui.ime` | `{preedit, active?: [start, end]}` / `{commit}` | An input method's composition through egui, as a real one arrives: shown in place on the slide or in a focused field; `{"preedit": ""}` cancels |
| `ui.move` / `ui.click` / `ui.drag` | screen points | Real egui pointer input — reaches every widget, menu and pane |
| `ui.set` | `{tab?, view?, pane?, notes?, zoom?, brightness?, ruler?, gridlines?, guides?, …}` | UI state (returns the full state) |
@@ -54,3 +49,18 @@ Coordinates are slide points (1/72 inch; a 16:9 slide is 960 × 540) unless note
The MCP server (`deckcraft-cli mcp`, see [mcp.md](mcp.md)) wraps the same methods for Claude
and other agents; `deckcraft-cli app --method METHOD [PARAMS]` sends one request from a shell.
## Inspecting slide actions
Run the `slide.actions` engine command through `engine.execute`:
```json
{"id": 2, "method": "engine.execute", "params": {"command": "slide.actions", "params": {"index": 0}}}
```
`index` is zero-based and optional; omitting it inspects the selected slide. The reply's `result`
contains `{index, slideId, actions}`. Each action includes an `owner` with the shape id/name and
its group path; text actions also identify the paragraph/run and run text, plus the table row/cell
for table text. Actions report their `event` (`click`, `hover`, `textLink`, or `textHover`),
`type`, `target`, and full `hyperlink`. Inspection never runs an action. A slide without actions
returns `"actions": []`.
+24 -3
View File
@@ -45,11 +45,20 @@ pub fn validate(v: &str) -> Result<(), String> {
None => (v, None),
};
let nums: Vec<&str> = core.split('.').collect();
if nums.len() != 3 || nums.iter().any(|n| n.is_empty() || !n.bytes().all(|b| b.is_ascii_digit()) || (n.len() > 1 && n.starts_with('0'))) {
if nums.len() != 3
|| nums
.iter()
.any(|n| n.is_empty() || !n.bytes().all(|b| b.is_ascii_digit()) || n.parse::<u64>().is_err() || (n.len() > 1 && n.starts_with('0')))
{
return bad();
}
if let Some(p) = pre
&& (p.is_empty() || p.split('.').any(|id| id.is_empty() || !id.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-')))
&& (p.is_empty()
|| p.split('.').any(|id| {
id.is_empty()
|| !id.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-')
|| (id.len() > 1 && id.starts_with('0') && id.bytes().all(|b| b.is_ascii_digit()))
}))
{
return bad();
}
@@ -138,12 +147,24 @@ mod tests {
for ok in ["0.1.0", "1.20.300", "1.0.0-rc.1", "1.0.0-alpha", "1.0.0-x-y.2"] {
assert!(validate(ok).is_ok(), "{ok}");
}
for bad in ["1.0", "1.0.0.0", "v1.0.0", "01.0.0", "1.0.0-", "1.0.0-a..b", "1.0.0+meta", "1.a.0", ""] {
for bad in ["1.0", "1.0.0.0", "v1.0.0", "01.0.0", "1.0.0-", "1.0.0-a..b", "1.0.0+meta", "1.a.0", "18446744073709551616.0.0", ""] {
assert!(validate(bad).is_err(), "{bad}");
}
assert!(replace(MANIFEST, "nope").is_err());
}
#[test]
fn numeric_prerelease_identifiers_have_no_leading_zeroes() {
for bad in ["1.0.0-00", "1.0.0-01", "1.0.0-rc.01"] {
assert!(validate(bad).is_err(), "{bad}");
assert!(replace(MANIFEST, bad).is_err(), "{bad} must not reach the manifest");
}
for ok in ["1.0.0-0", "1.0.0-rc.0", "1.0.0-01a", "1.0.0-0-1"] {
assert!(validate(ok).is_ok(), "{ok}");
assert_eq!(read(&replace(MANIFEST, ok).unwrap()).unwrap(), ok);
}
}
#[test]
fn the_real_manifest_has_a_valid_version() {
let text = std::fs::read_to_string(crate::root().join("Cargo.toml")).unwrap();