实测聚焦时 outlineStyle 仍为 solid(D8 焦点环 2px+offset 会再画一个方框);此处焦点改由 .iwb-node-selected 表达,其余控件保留 D8 环。守卫补 outline 断言,verify:ci 与 16 张基线复跑全绿。
136 lines
7.3 KiB
JavaScript
136 lines
7.3 KiB
JavaScript
// B5 节点:三条不变量
|
||
//
|
||
// 这一批的病灶和 B3/B4 同源,但表现更狠:节点卡内部的控件沿用了「面板」的表面色
|
||
// (--iwb-layer / --iwb-layer2)。深色下这两个值是 #161616 / #1c1c1c,而节点卡是 #3d3d3d ——
|
||
// 端口就成了一颗嵌在卡片上的纯黑洞(差 39 级),任务卡里的等待按钮同理。
|
||
// 按 D10 的相对派生原则:**控件明暗由贴着的那张卡片决定**,节点卡内一律用 --iwb-field。
|
||
//
|
||
// 另一类:浮条底是 --iwb-panel,子项 hover 也用 --iwb-layer2,深色下两者都是 #1c1c1c,
|
||
// hover 完全没有反馈 —— 这类「改数字不生效」只能靠断言兜。
|
||
|
||
const assert = require('assert')
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
|
||
const root = path.join(__dirname, '..')
|
||
const css = fs.readFileSync(path.join(root, 'style.css'), 'utf8')
|
||
|
||
// 按 } 切块,取每块选择器的最后一行(多选择器组只影响可读性,不影响 body)
|
||
const blocks = []
|
||
for (const chunk of css.split('}')) {
|
||
const i = chunk.lastIndexOf('{')
|
||
if (i < 0) continue
|
||
const sel = chunk.slice(0, i).split('\n').filter((l) => l.trim()).pop() || ''
|
||
blocks.push({ sel: sel.trim(), body: chunk.slice(i + 1) })
|
||
}
|
||
|
||
const NODE_SCOPE = /^\.iwb-(node|gen|port|relay|conn|lod|ref|resize|task|size)/
|
||
const nodeBlocks = blocks.filter((b) => NODE_SCOPE.test(b.sel))
|
||
|
||
// ── 1. 节点卡内部不许用「面板表面色」 ──
|
||
// 浮条例外:它是浮层(底就是 --iwb-panel),不贴在卡片上。
|
||
const PANEL_SURFACE = /background(?:-color)?:\s*var\(--iwb-(?:layer|layer2|panel)\)/
|
||
const offenders = nodeBlocks
|
||
.filter((b) => !/floatbar/.test(b.sel))
|
||
.filter((b) => PANEL_SURFACE.test(b.body))
|
||
.map((b) => b.sel)
|
||
assert.deepStrictEqual(
|
||
offenders,
|
||
[],
|
||
'节点卡内部的控件必须用 --iwb-field(深色下 layer/layer2 #161616/#1c1c1c 打在节点卡 #3d3d3d 上等于黑洞)'
|
||
)
|
||
|
||
// 端口是本批的「样板」:它的底色必须是 field,三个态都不能退回 layer/panel
|
||
const port = blocks.find((b) => b.sel === '.iwb-port')
|
||
assert.ok(port, '找不到 .iwb-port 规则')
|
||
assert.ok(port.body.includes('background: var(--iwb-field)'), '.iwb-port 底色必须是 --iwb-field')
|
||
// 描边必须由文字色派生:深色下 --iwb-border2 是 #4d4d4d,与填充 --iwb-field(#494949) 同色,
|
||
// 描边等于没有,12px 的小圆点会糊成一团。这条断言守的是「边缘锐度」而不只是「颜色对」。
|
||
assert.ok(
|
||
/border:\s*1\.5px solid color-mix\(in srgb, var\(--iwb-text\)/.test(port.body),
|
||
'.iwb-port 描边必须由 --iwb-text 派生(--iwb-border2 在深色下与填充同色,端口边缘会糊)'
|
||
)
|
||
for (const sel of ['.iwb-node:hover .iwb-port', '.iwb-port:hover', '.iwb-node-selected .iwb-port:not(.iwb-port-linked)']) {
|
||
const b = blocks.find((x) => x.sel === sel)
|
||
assert.ok(b, '找不到规则:' + sel)
|
||
assert.ok(
|
||
!/var\(--iwb-(?:layer|layer2|panel)\)/.test(b.body),
|
||
sel + ' 不能用面板表面色 —— 端口贴在节点卡上,深色下会变成黑洞'
|
||
)
|
||
}
|
||
|
||
// ── 2. 节点区字号必须走档位,不写死 ──
|
||
// 例外:8px / 10px 是微缩徽标(序号角标、图片计数),闭集最低档 11px 会把它们撑出圆点;
|
||
// 14px 是尺寸自定义输入(属于图像设置浮层,不在节点卡内)。
|
||
const MICRO = new Set(['8px', '10px', '14px'])
|
||
const bareFont = []
|
||
for (const b of nodeBlocks) {
|
||
for (const m of b.body.matchAll(/font-size:\s*([\d.]+px)/g)) {
|
||
if (!MICRO.has(m[1])) bareFont.push(b.sel + ' → ' + m[1])
|
||
}
|
||
}
|
||
assert.deepStrictEqual(bareFont, [], '节点区字号必须用 --iwb-font-*,不写死 px(微缩徽标 8/10px 除外)')
|
||
|
||
// ── 3. 节点区间距与圆角同样走档位 ──
|
||
// 例外:端口热区 inset 是负数(扩大点击区,不是节奏值);圆角只允许 token 或 50%/2px(圆形与占位条)
|
||
const bareSpace = []
|
||
for (const b of nodeBlocks) {
|
||
for (const m of b.body.matchAll(/(?:padding|margin|gap)(?:-(?:top|right|bottom|left))?:\s*([^;}]+)/g)) {
|
||
if (/(^|[\s(])\d+px/.test(m[1])) bareSpace.push(b.sel + ' → ' + m[0].trim())
|
||
}
|
||
}
|
||
assert.deepStrictEqual(bareSpace, [], '节点区间距必须用 --iwb-space-*,不写死 px')
|
||
|
||
const bareRadius = []
|
||
for (const b of nodeBlocks) {
|
||
for (const m of b.body.matchAll(/border-radius:\s*([\d.]+px)/g)) {
|
||
if (m[1] !== '2px') bareRadius.push(b.sel + ' → ' + m[1])
|
||
}
|
||
}
|
||
assert.deepStrictEqual(bareRadius, [], '节点区圆角必须用 --iwb-radius-*,不写死 px(2px 占位条除外)')
|
||
|
||
// ── 4. 已删除的死规则不许回来 ──
|
||
// 判据:dist/app.js 与 plugins/** 里都是 0 次(尺寸/质量行已并入图像设置浮层)。
|
||
const DEAD = [
|
||
'.iwb-gen-sizerow', '.iwb-gen-qualityrow', '.iwb-gen-tag',
|
||
'.iwb-size-x', '.iwb-size-align', '.iwb-size-badge',
|
||
]
|
||
for (const cls of DEAD) {
|
||
const re = new RegExp('\\' + cls + '(?![-A-Za-z0-9_])')
|
||
assert.ok(!re.test(css), cls + ' 已确认无生产者(DOM 与插件都不再产出),不该重新出现')
|
||
}
|
||
|
||
// ── 5. 节点正文文本区不是控件面(v3.26.52,用户截图反馈)──
|
||
// 病灶:灰色提示词/文本节点里文字后面是白色,编辑时还多一个方框。
|
||
// ① `.iwb-node .iwb-textarea` 把 --iwb-field(亮色=纯白)刷到**所有**文本区,
|
||
// 优先级(0,2,0) 盖掉 `.iwb-textarea-plain`(0,1,0) 的 transparent;
|
||
// ② `.iwb-textarea:focus` 写在 plain:focus 之后且同优先级,2px 聚焦光晕又冒出来。
|
||
// 规则:正文文本区透明继承卡片底色(含 data-bg 自定义色),常态与编辑态都不画控件框;
|
||
// 全局 D8 键盘焦点环在这里也关掉(它会再画一个 2px 方框),焦点反馈改由节点选中框承担。
|
||
const prose = blocks.find((b) => b.sel === '.iwb-node .iwb-textarea-plain')
|
||
assert.ok(prose, '找不到 .iwb-node .iwb-textarea-plain 规则')
|
||
assert.ok(/background:\s*transparent/.test(prose.body), '节点正文文本区必须透明继承卡片底色')
|
||
assert.ok(
|
||
!/var\(--iwb-(?:field|layer|layer2|panel)\)/.test(prose.body),
|
||
'节点正文文本区不得铺控件面/面板色(--iwb-field 只给可交互控件)'
|
||
)
|
||
assert.ok(/border:\s*0/.test(prose.body), '节点正文文本区不得有控件边框')
|
||
assert.ok(/box-shadow:\s*none/.test(prose.body), '节点正文文本区不得有阴影')
|
||
|
||
const proseFocus = blocks.find((b) => /\.iwb-node \.iwb-textarea-plain:focus/.test(b.sel))
|
||
assert.ok(proseFocus, '找不到节点正文文本区的聚焦规则')
|
||
assert.ok(/box-shadow:\s*none/.test(proseFocus.body), '编辑态不得出现聚焦方框(2px 光晕)')
|
||
assert.ok(/outline:\s*none/.test(proseFocus.body), '编辑态不得出现全局键盘焦点环(同样是个方框)')
|
||
assert.ok(
|
||
css.indexOf('.iwb-node .iwb-textarea-plain:focus') > css.indexOf('.iwb-input:focus, .iwb-textarea:focus'),
|
||
'节点正文的聚焦规则必须写在基础 .iwb-textarea:focus 之后(同优先级靠后生效)'
|
||
)
|
||
const scopedField = blocks.find((b) => b.sel.startsWith('.iwb-node .iwb-input'))
|
||
assert.ok(scopedField, '找不到节点控件面规则')
|
||
assert.ok(
|
||
scopedField.sel.includes(':not(.iwb-textarea-plain)'),
|
||
'控件面(--iwb-field)规则必须排除正文文本区'
|
||
)
|
||
|
||
console.log('node scope checks passed(端口用 field / ' + nodeBlocks.length + ' 条节点规则字号·间距·圆角全走档位 / ' + DEAD.length + ' 个死类名不复现 / 正文文本区透明无框)')
|