Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

chore(web): 雪碧图每一枚 symbol 都有归属

longmeidaodfc520ed70bc
diff --git a/scripts/vendor_web_dependencies.mjs b/scripts/vendor_web_dependencies.mjs
index eb1c5ed7c..d6cd00f08 100644
--- a/scripts/vendor_web_dependencies.mjs
+++ b/scripts/vendor_web_dependencies.mjs
@@ -77,6 +77,17 @@ const lucideIcons = new Map([
["chevron-up", "chevron-up"], ["chevron-down", "chevron-down"], ["heart", "heart"],
["upload", "upload"], ["database", "database"], ["play", "play"], ["clock", "clock"],
["external-link", "external-link"], ["bookmark-plus", "bookmark-plus"],
+ // 这七枚只画在雪碧图里、不在这张表上,`npm run vendor:web` 从不刷新它们。
+ // 名字和上游对不上的只有排序键:Peach 叫 `sort`,Lucide 叫 `sort-desc`。
+ ["sort", "sort-desc"], ["arrow-up", "arrow-up"], ["arrow-down", "arrow-down"],
+ ["calendar", "calendar"], ["download", "download"], ["monitor", "monitor"],
+ ["volume-2", "volume-2"],
+]);
+
+// 自绘 symbol:没有上游可对,所以在这里逐个点名。下面那道分区检查要求雪碧图里
+// 每一枚要么由某一套生成、要么写在这张名单上——漏一枚就会被当成忘了纳管。
+const handDrawnIcons = new Set([
+ "alert", "pics", "jav", "theater-enter", "theater-exit", "brand-x",
]);
const svgInner = source => {
@@ -145,7 +156,8 @@ stage("web/vendor/lucide-ORIGIN.md",
`- npm lock integrity:\`${integrity("lucide-static")}\`\n` +
`- 许可证:ISC;原文见 \`lucide-LICENSE.txt\`\n` +
`- 消费者:\`web/index.html\` 内联的 ${lucideIcons.size} 个 symbol\n\n` +
- "`i-jav`、`i-alert` 是 Peach 自绘图标;RSS 与拖动点保留填充修正,避免小圆点在全局描边样式下消失。\n");
+ `雪碧图里另有 ${handDrawnIcons.size} 枚自绘 symbol(${[...handDrawnIcons].join("、")})与 16 枚 player-* 前缀的播放器图标,都没有上游可对。\n` +
+ "RSS 与拖动点保留填充修正,避免小圆点在全局描边样式下消失。\n");
stage("web/vendor/phosphor-LICENSE.txt", lfText("node_modules", "@phosphor-icons/core", "LICENSE"));
stage("web/vendor/phosphor-ORIGIN.md",
`# Phosphor icons ${versions["@phosphor-icons/core"]}\n\n` +
@@ -163,6 +175,17 @@ stage("web/vendor/healthicons-ORIGIN.md",
"- 许可证:npm 包为 MIT,图标由上游声明为 CC0/public domain;原文见 `healthicons-LICENSE.txt`\n" +
"- 消费者:`web/index.html` 的 `sperm` outline-24px symbol\n");
+// 雪碧图的分区检查。少了它,新画一枚 symbol 只会安静地待在 index.html 里,
+// 换 Lucide 版本时不跟着刷新,也没人看得出它是自绘的还是忘了纳管。
+const spriteSymbols = [...index.matchAll(/id="i-([a-z0-9-]+)"/g)].map(m => m[1]);
+const owned = new Set([...lucideIcons.keys(), ...phosphorIcons.keys(),
+ ...handDrawnIcons, "sperm"]);
+const orphans = spriteSymbols.filter(
+ name => !name.startsWith("player-") && !owned.has(name));
+if (orphans.length) {
+ throw new Error(`雪碧图里这些 symbol 没有归属,加进对应图标集或 handDrawnIcons:${orphans.join("、")}`);
+}
+
const versionRoots = [
["web/vendor/videojs", versions["video.js"]],
["web/vendor/swiper", versions.swiper],
diff --git a/tests/test_dependency_policy.py b/tests/test_dependency_policy.py
index 865785ee8..61f45e1fb 100644
--- a/tests/test_dependency_policy.py
+++ b/tests/test_dependency_policy.py
@@ -90,6 +90,37 @@ class DependencyPolicyTests(unittest.TestCase):
self.assertIn(f"Phosphor {versions['@phosphor-icons/core']} regular", index)
self.assertIn(f"/vendor/swiper/{versions['swiper']}/", app)
+ def test_every_sprite_symbol_has_a_declared_owner(self):
+ """雪碧图里每一枚 symbol 都归某一套图标集或自绘名单。
+
+ 没有归属的那几枚只画在 index.html 里,`npm run vendor:web` 从不刷新它们,
+ 换上游版本时新旧画法混在同一条按钮上。归属由生成脚本自己在写文件前拦,
+ 这里核的是那道拦阻还在、名单也还覆盖得住实际的雪碧图。
+ """
+ generator = (ROOT / "scripts" / "vendor_web_dependencies.mjs").read_text(
+ encoding="utf-8")
+ self.assertIn("const handDrawnIcons = new Set([", generator)
+ self.assertIn("if (orphans.length) {", generator)
+
+ def body(block: str) -> str:
+ return generator.split(block, 1)[1].split("]);", 1)[0]
+
+ def map_keys(block: str) -> set[str]:
+ # Map 的第二项是上游名字,只取键;否则 sort-desc 这类上游名会混进来。
+ return set(re.findall(r'\["([a-z0-9-]+)"', body(block)))
+
+ owned = (map_keys("const lucideIcons = new Map([")
+ | map_keys("const phosphorIcons = new Map([")
+ | set(re.findall(r'"([a-z0-9-]+)"',
+ body("const handDrawnIcons = new Set([")))
+ | {"sperm"})
+ index = (ROOT / "web" / "index.html").read_text(encoding="utf-8")
+ sprite = {name for name in re.findall(r'id="i-([a-z0-9-]+)"', index)
+ if not name.startswith("player-")}
+ self.assertEqual(sprite - owned, set())
+ # 名单里挂着雪碧图已经没有的名字,等于换版本时静默少刷一枚。
+ self.assertEqual(owned - sprite - {"sperm"}, set())
+
def test_automation_monitors_all_dependency_manifests(self):
dependabot = (ROOT / ".github" / "dependabot.yml").read_text(encoding="utf-8")
for ecosystem in ("pip", "npm", "github-actions"):
diff --git a/web/index.html b/web/index.html
index 9aaefa0a5..af8eaa1e4 100644
--- a/web/index.html
+++ b/web/index.html
@@ -35,7 +35,7 @@
<symbol id="i-arrow-up" viewBox="0 0 24 24"><path d="m5 12 7-7 7 7" /><path d="M12 19V5" /></symbol>
<symbol id="i-chart" viewBox="0 0 24 24"><path d="M5 21v-6" /><path d="M12 21V3" /><path d="M19 21V9" /></symbol>
<symbol id="i-settings" viewBox="0 0 24 24"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" /><circle cx="12" cy="12" r="3" /></symbol>
- <symbol id="i-monitor" viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2" /><path d="M8 21h8" /><path d="M12 17v4" /></symbol>
+ <symbol id="i-monitor" viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2" /><line x1="8" x2="16" y1="21" y2="21" /><line x1="12" x2="12" y1="17" y2="21" /></symbol>
<symbol id="i-monitor-cog" viewBox="0 0 24 24"><path d="M12 17v4" /><path d="m14.305 7.53.923-.382" /><path d="m15.228 4.852-.923-.383" /><path d="m16.852 3.228-.383-.924" /><path d="m16.852 8.772-.383.923" /><path d="m19.148 3.228.383-.924" /><path d="m19.53 9.696-.382-.924" /><path d="m20.772 4.852.924-.383" /><path d="m20.772 7.148.924.383" /><path d="M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7" /><path d="M8 21h8" /><circle cx="18" cy="6" r="3" /></symbol>
<symbol id="i-gauge" viewBox="0 0 24 24"><path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" /></symbol>
<symbol id="i-theater-enter" viewBox="0 0 24 24"><rect x="2" y="3" width="20" height="18" rx="1.5"/><path d="M2 16h20M8.5 7 5.5 10l3 3M15.5 7l3 3-3 3"/></symbol>
@@ -69,7 +69,7 @@
<symbol id="i-info" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" /></symbol>
<symbol id="i-hard-drive" viewBox="0 0 24 24"><path d="M10 16h.01" /><path d="M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" /><path d="M21.946 12.013H2.054" /><path d="M6 16h.01" /></symbol>
<symbol id="i-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" /><path d="M2 12h20" /></symbol>
- <symbol id="i-volume-2" viewBox="0 0 24 24"><path d="M11 5 6 9H2v6h4l5 4z" /><path d="M15.54 8.46a5 5 0 0 1 0 7.07" /><path d="M19.07 4.93a10 10 0 0 1 0 14.14" /></symbol>
+ <symbol id="i-volume-2" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z" /><path d="M16 9a5 5 0 0 1 0 6" /><path d="M19.364 18.364a9 9 0 0 0 0-12.728" /></symbol>
<symbol id="i-rss" viewBox="0 0 24 24"><path d="M4 11a9 9 0 0 1 9 9" /><path d="M4 4a16 16 0 0 1 16 16" /><circle cx="5" cy="19" r="1" fill="currentColor" stroke="none"/></symbol>
<symbol id="i-thumbs-up" viewBox="0 0 24 24"><path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" /><path d="M7 10v12" /></symbol>
<symbol id="i-thumbs-down" viewBox="0 0 24 24"><path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" /><path d="M17 14V2" /></symbol>
@@ -92,7 +92,7 @@
<symbol id="i-chevron-down" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6" /></symbol>
<symbol id="i-heart" viewBox="0 0 24 24"><path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5" /></symbol>
<symbol id="i-upload" viewBox="0 0 24 24"><path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /></symbol>
- <symbol id="i-download" viewBox="0 0 24 24"><path d="M12 15V3" /><path d="m7 10 5 5 5-5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /></symbol>
+ <symbol id="i-download" viewBox="0 0 24 24"><path d="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="m7 10 5 5 5-5" /></symbol>
<symbol id="i-database" viewBox="0 0 24 24"><ellipse cx="12" cy="5" rx="9" ry="3" /><path d="M3 5V19A9 3 0 0 0 21 19V5" /><path d="M3 12A9 3 0 0 0 21 12" /></symbol>
<symbol id="i-play" viewBox="0 0 24 24"><path d="M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" /></symbol>
<symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /><path d="M12 6v6l4 2" /></symbol>
diff --git a/web/vendor/lucide-ORIGIN.md b/web/vendor/lucide-ORIGIN.md
index cb601d0c3..e8604ef18 100644
--- a/web/vendor/lucide-ORIGIN.md
+++ b/web/vendor/lucide-ORIGIN.md
@@ -3,6 +3,7 @@
- npm 包:`[email protected]`
- npm lock integrity:`sha512-uAp0oHMWE8T6XycokgjswDF3epVTFhUJQG4EdMsZOC/Jbmi5dFvdto0c6gcVQqswQDIGWguSvbJ0got6Vy3RXQ==`
- 许可证:ISC;原文见 `lucide-LICENSE.txt`
-- 消费者:`web/index.html` 内联的 45 个 symbol
+- 消费者:`web/index.html` 内联的 52 个 symbol
-`i-jav`、`i-alert` 是 Peach 自绘图标;RSS 与拖动点保留填充修正,避免小圆点在全局描边样式下消失。
+雪碧图里另有 6 枚自绘 symbol(alert、pics、jav、theater-enter、theater-exit、brand-x)与 16 枚 player-* 前缀的播放器图标,都没有上游可对。
+RSS 与拖动点保留填充修正,避免小圆点在全局描边样式下消失。