From eff273f7f2f3919bab62eacded781c61d5f03f91 Mon Sep 17 00:00:00 2001 From: cflmy Date: Fri, 27 Nov 2026 08:57:22 +0800 Subject: [PATCH] feat: consume the WEB-03 handoff with output-relative source links Bump the fixed Design revision to the handoff/graph/slice/drift candidate and make web handoff use handoff_relative_to with the output directory, so source links stay relative when the delivery file is written elsewhere. CI asserts the links are relative (no absolute/file targets) and that sources are present. Refs cflmy/marqdo-web-preview#1, cflmy/marqdo-web-design#2, cflmy/marqdo#6 --- Cargo.lock | 2 +- Cargo.toml | 2 +- docs/evidence/WEB-02-preview-candidate.md | 4 ++-- scripts/ci.sh | 10 ++++++++++ src/main.rs | 13 ++++++++++--- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6627e10..eed057e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" [[package]] name = "marqdo-web-design" version = "0.1.0" -source = "git+https://git.cflmy.cn/cflmy/marqdo-web-design?rev=2f18dede8540c82611819e2c24a19db138d5ac14#2f18dede8540c82611819e2c24a19db138d5ac14" +source = "git+https://git.cflmy.cn/cflmy/marqdo-web-design?rev=1b6607fd3cc09801b4f6eacd2fba547caa0ec637#1b6607fd3cc09801b4f6eacd2fba547caa0ec637" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index c66f48e..cdf062b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,5 +7,5 @@ license = "MIT OR Apache-2.0" description = "Offline Web design preview and the unique marqdo web Tool" [dependencies] -marqdo-web-design = { git = "https://git.cflmy.cn/cflmy/marqdo-web-design", rev = "2f18dede8540c82611819e2c24a19db138d5ac14" } +marqdo-web-design = { git = "https://git.cflmy.cn/cflmy/marqdo-web-design", rev = "1b6607fd3cc09801b4f6eacd2fba547caa0ec637" } serde_json = "1" diff --git a/docs/evidence/WEB-02-preview-candidate.md b/docs/evidence/WEB-02-preview-candidate.md index 7cfbe47..449019d 100644 --- a/docs/evidence/WEB-02-preview-candidate.md +++ b/docs/evidence/WEB-02-preview-candidate.md @@ -9,7 +9,7 @@ | 对象 | 身份 | | --- | --- | | CLI | 由根固定 `cli/deadf6e` 构建的 `marqdo 3.0.0-rc.4`,SHA-256 `sha256:6ede3b9e...` | -| Design 依赖 | `marqdo-web-design@2f18dede8540c82611819e2c24a19db138d5ac14`(`Cargo.lock` 固定 git rev;不是 `../design` 路径依赖) | +| Design 依赖 | `marqdo-web-design@1b6607fd3cc09801b4f6eacd2fba547caa0ec637`(WEB-03 handoff/图/切片)(`Cargo.lock` 固定 git rev;不是 `../design` 路径依赖) | | 平台 | Linux x86_64(本机验证) | ## 执行 @@ -33,7 +33,7 @@ MARQDO_BIN= scripts/ci.sh ## 未验证 / 后续(不隐藏) -- 真实浏览器(Playwright/file://)行为、responsive 390px 无横向溢出、按钮实际状态切换的 DOM 断言未执行;当前只有静态制品断言。 +- WEB-03 交付内容由图/切片/漂移提供,Preview 已验证相对链接;真实浏览器(Playwright/file://)行为、responsive 390px 无横向溢出、按钮实际状态切换的 DOM 断言未执行;当前只有静态制品断言。 - 图片/本地 raster 资产复制、魔数/大小校验、远端图片文本占位尚未实现(当前不渲染图片)。 - 完整安全负例矩阵(``/Unicode/双引号 fixture、输出预算边界、超时/进程限制)未系统性覆盖。 - 冷安装(root 生态 `web` Tool 与 WEB-05)未开始;WEB-04 生产交付试验未开始。 diff --git a/scripts/ci.sh b/scripts/ci.sh index b97fc92..c79bdab 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -27,6 +27,16 @@ handoff="$work/handoff.md" "$MARQDO_BIN" web handoff tests/fixture/index.mq.md --unit 工作台 --out "$handoff" test -s "$handoff" grep -q "Design handoff" "$handoff" +grep -q "components/nav.mq.md#导航" "$handoff" +python3 - "$handoff" <<'PY' +import pathlib, sys, re +text = pathlib.Path(sys.argv[1]).read_text() +assert "](" in text +for target in re.findall(r"\]\(([^)]+)\)", text): + assert not target.startswith("/"), target + assert not target.startswith("file:"), target +print("handoff links are relative") +PY if "$MARQDO_BIN" web preview tests/fixture/index.mq.md --unit 工作台 --out "$preview" 2>/dev/null; then echo "preview overwrote an existing directory" >&2 exit 1 diff --git a/src/main.rs b/src/main.rs index e56f38c..bb25364 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,8 @@ use std::path::{Path, PathBuf}; use std::process::ExitCode; use marqdo_web_design::{ - handoff, load, ComponentDef, ContentBlock, Design, Error, Instance, LoadConfig, Scenario, Width, + handoff_relative_to, load, ComponentDef, ContentBlock, Design, Error, Instance, LoadConfig, + Scenario, Width, }; const CSS: &str = r#" @@ -574,12 +575,18 @@ fn run_handoff(args: &Args) -> ExitCode { return ExitCode::from(code); } }; - let text = handoff(&design); + let out = PathBuf::from(out); + let base = out + .parent() + .filter(|parent| !parent.as_os_str().is_empty()) + .map(Path::to_path_buf) + .unwrap_or_else(|| PathBuf::from(".")); + let base = base.canonicalize().unwrap_or(base); + let text = handoff_relative_to(&design, &base); if text.len() > 4 * 1024 * 1024 { eprintln!("web handoff: error: handoff exceeds the 4 MiB budget"); return ExitCode::from(2); } - let out = PathBuf::from(out); if let Some(parent) = out.parent() { if !parent.as_os_str().is_empty() && !parent.is_dir() { eprintln!("web handoff: error: output parent is not a directory");