feat(tokens): M4-B6 收尾 —— 半像素清零 + 插件契约文件级豁免归零(3.26.49)
- style.css 剩余 16 处半像素字号并入闭集,删 2 条归并后重复的规则;守卫收紧为全文件断言 - 裁定 --iwb-control-h 不扩到全局控件(并排表单 vs 成组紧凑控件),新增「全局 input 不得写死 height」守卫 - plugin-theme-contract-test 重写:ALLOW_FILES 6 → 0,改为私有皮肤自声明(skin) + chroma 强调色判据 + 行内内容色标记;私有皮肤必须自洽(不引用宿主颜色 token) - token-audit 插件段同口径分三类报数;插件侧中性色写死归零 - 插件仓同步 4 个版本:browser 1.7.1 / batch-export 1.2.1 / image-annotate 1.20.7 / image-vectorize 0.6.1 - 视觉基线 8 张更新(含画布场景的字号栅格化变化),A/B 回退确认非环境噪声,复核 12/12
This commit is contained in:
1 parent
940c92982d
commit
c81a107b5f
22 files changed
+336
-89
No files matched your search
+33
-6
@@ -89,20 +89,43 @@ const tokenUse = {
|
||||
}
|
||||
|
||||
/* ---------- 4. 插件侧 ---------- */
|
||||
// 与 tests/plugin-theme-contract-test.js 同口径,分三类而不是只数 hex:
|
||||
// 私有皮肤(manifest 声明 skin:'private')—— 已声明的设计选择,不算欠债,但它不得引用宿主颜色 token
|
||||
// 强调色(chroma ≥ 24)—— 品牌/危险/成功色,亮暗两端都可读,允许写死
|
||||
// 中性色(chroma < 24)—— 表面/文字/边框,写死在暗色下必然白板或黑洞,这才是要修的
|
||||
const chromaOf = (hex) => {
|
||||
let h = hex.replace('#', '')
|
||||
if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2]
|
||||
if (h.length !== 6) return 0
|
||||
const n = parseInt(h, 16)
|
||||
const c = [(n >> 16) & 255, (n >> 8) & 255, n & 255]
|
||||
return Math.max(c[0], c[1], c[2]) - Math.min(c[0], c[1], c[2])
|
||||
}
|
||||
const pluginBad = []
|
||||
const pluginPrivate = []
|
||||
const pluginAccent = []
|
||||
for (const f of pluginFiles) {
|
||||
const src = read(f)
|
||||
// 与 tests/plugin-theme-contract-test.js 同口径:只数 background/color/border 声明里直接写 hex
|
||||
const re = /(background(?:-color)?|color|border(?:-color)?)\s*:\s*([^;'"]{0,80})/gi
|
||||
const isPrivate = /skin:\s*'private'/.test(src.slice(0, 4096))
|
||||
const re = /(background(?:-color)?|color|border(?:-color)?)\s*:\s*([^;'"}]{0,80})/gi
|
||||
let m
|
||||
let n = 0
|
||||
let neutral = 0
|
||||
let accent = 0
|
||||
while ((m = re.exec(src))) {
|
||||
const val = m[2]
|
||||
if (!/#[0-9a-f]{3,8}/i.test(val)) continue
|
||||
if (/\/\*iwb:content\*\//.test(val)) continue
|
||||
if (/var\(--[a-z0-9-]+\s*,\s*#[0-9a-f]{3,8}/i.test(val)) continue
|
||||
n++
|
||||
// 纯白文字压在图片/色块上:内容对比,不是主题表面色(契约测试同款例外)
|
||||
if (/^color$/i.test(m[1]) && /^#(?:fff|ffffff)$/i.test(val.trim().replace(/[}\s]+$/, ''))) continue
|
||||
for (const h of val.match(/#[0-9a-f]{3,8}/gi) || []) {
|
||||
if (chromaOf(h) >= 24) accent++
|
||||
else neutral++
|
||||
}
|
||||
}
|
||||
if (n) pluginBad.push({ file: path.relative(ROOT, f), hex: n })
|
||||
if (isPrivate) { pluginPrivate.push({ file: path.relative(ROOT, f), hex: neutral + accent }); continue }
|
||||
if (neutral) pluginBad.push({ file: path.relative(ROOT, f), hex: neutral })
|
||||
if (accent) pluginAccent.push({ file: path.relative(ROOT, f), hex: accent })
|
||||
}
|
||||
const pluginTokenUse = pluginFiles.reduce((a, f) => a + count(/var\(--iwb-/g, read(f)), 0)
|
||||
|
||||
@@ -202,7 +225,11 @@ console.log(`| z-index | ${report.zindex.distinct.length} | ${report.zindex.dist
|
||||
console.log(`| box-shadow 写法 | ${report.shadows.distinct} | — |`)
|
||||
console.log('\n## 5. 插件侧\n')
|
||||
console.log(`- 插件文件数:${pluginFiles.length},引用 var(--iwb-*) 共 ${pluginTokenUse} 次`)
|
||||
console.log('- 含硬编码 hex 的文件:')
|
||||
console.log(`- 文件级豁免:0(B6 起按角色分类,不再整文件放行)`)
|
||||
console.log(`- 写死「中性色」的文件(暗色下会白板/黑洞,必须修):${pluginBad.length}`)
|
||||
for (const p of pluginBad.sort((a, b) => b.hex - a.hex)) console.log(` - ${p.file} → ${p.hex} 处`)
|
||||
console.log(`- 声明了私有皮肤的插件(已确认不跟随主题,代价是不得引用宿主颜色 token):${pluginPrivate.length}`)
|
||||
for (const p of pluginPrivate) console.log(` - ${p.file} → ${p.hex} 处(skin: 'private')`)
|
||||
console.log(`- 强调色写死(品牌/危险/成功,亮暗两端可读,允许):${pluginAccent.reduce((a, p) => a + p.hex, 0)} 处 / ${pluginAccent.length} 个文件`)
|
||||
console.log('\n## 6. 官网样式\n')
|
||||
console.log(`- site/assets/style.css 定义变量:${siteVars.join(' ') || '(无)'}`)
|
||||
Reference in new issue
Block a user