feat(hero): 机房场景退役 + 抽象数据场落库(ADR-0016 §17 撤回 / §17.5 继任)
退役(零视觉影响:NEXT_PUBLIC_HERO_SCENE 从未在任何 .env* 设置): - 删 hero-scene.tsx(694行)/caption/单测/文案真源/CC0 机柜/海报帧 - R26 删除、R22 登记归零、e2e heroSceneMask 移除(无命中的假安全网) - R22 自证改可注入(夹具不再依赖生产条目) 落库(flag NEXT_PUBLIC_HERO_FIELD 样期默认关 ⇒ 基线零影响): - hero-field.tsx 三拍:噪声→增长→判断;bloom 半分辨率;DPR≤1.5 - 降级统一看结论帧(reduced-motion 定格 T_HOLD=40500 非 0) - 文案真源含承诺词正则守卫(禁帮助/赋能/提升/%/倍) - 海报帧 capture 脚本与资产同批入库(1920x864/26.9KB,可复现) - eslint 忽略 demo/**/vendor/**(vendored three 不可被 lint-staged --fix 改写) 守卫重建:R26 指向 hero-field(43260ms/3 拍合规);R22 登记 HeroField 条目 验证:tsc 0 / eslint 0 error / jest 162 套件 1906 例 / check:grammar 26+26 / check:a11y 0 违规 / 默认构建首页 DOM 冒烟 E 案不变
This commit was merged in pull request #65.
This commit is contained in:
1 parent
2bb342cfa9
commit
6ce794164a
108 files changed
+98666
-1005
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 抓取首屏「抽象数据场」的海报帧(结论态定格)。
|
||||
*
|
||||
* 用法(三步,顺序不能反):
|
||||
* 1. NEXT_PUBLIC_HERO_FIELD=1 NEXT_PUBLIC_HERO_FIELD_CAPTURE=1 ./node_modules/.bin/next build
|
||||
* 2. NEXT_PUBLIC_HERO_FIELD=1 NEXT_PUBLIC_HERO_FIELD_CAPTURE=1 ./node_modules/.bin/next start -p 3123
|
||||
* 3. node scripts/capture-hero-field-poster.mjs --url http://localhost:3123/
|
||||
*
|
||||
* 为什么不用 dev server:flag 是构建期内联的,dev 是热编译但与生产栅格化路径不同;
|
||||
* 海报帧要的是**结论态的确定性像素**,用生产构建抓取才有可复现性。
|
||||
*
|
||||
* 产出:public/images/home/hero-field-poster.webp(登记于 asset-provenance §6 与 R22 登记表)。
|
||||
*/
|
||||
import { chromium } from 'playwright';
|
||||
import sharp from 'sharp';
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const urlIdx = args.indexOf('--url');
|
||||
const url = urlIdx !== -1 ? args[urlIdx + 1] : 'http://localhost:3123/';
|
||||
const outRel = 'public/images/home/hero-field-poster.webp';
|
||||
|
||||
const browser = await chromium.launch({ args: ['--no-proxy-server'] });
|
||||
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1 });
|
||||
await page.goto(url, { waitUntil: 'load', timeout: 180000 });
|
||||
|
||||
// 等场景完成首帧(CAPTURE 模式下定格在结论帧,不进 rAF 循环)
|
||||
await page.waitForSelector('[data-testid="hero-field"][data-rendered="1"]', { timeout: 60000 });
|
||||
await page.waitForTimeout(1500);
|
||||
|
||||
const dataUrl = await page.evaluate(() => {
|
||||
const canvas = document.querySelector('[data-testid="hero-field"] canvas');
|
||||
if (!canvas) throw new Error('hero-field 画布不存在 —— flag 是否开启?');
|
||||
return canvas.toDataURL('image/png');
|
||||
});
|
||||
|
||||
const png = Buffer.from(dataUrl.split(',')[1], 'base64');
|
||||
const meta = await sharp(png).metadata();
|
||||
console.log(`画布像素 ${meta.width}×${meta.height},转 webp(1920 宽)…`);
|
||||
|
||||
const outAbs = path.join(process.cwd(), outRel);
|
||||
mkdirSync(path.dirname(outAbs), { recursive: true });
|
||||
await sharp(png).resize({ width: 1920 }).webp({ quality: 82 }).toFile(outAbs);
|
||||
writeFileSync(path.join(process.cwd(), 'public/images/home/hero-field-poster.png.meta.txt'),
|
||||
`source=capture date=${new Date().toISOString()} srcPx=${meta.width}x${meta.height}\n`);
|
||||
console.log(`✓ 已写入 ${outRel}`);
|
||||
await browser.close();
|
||||
@@ -53,24 +53,20 @@ const HOVER_LIFT_CEILING = 28;
|
||||
const EXTERNAL_OWNED = ["--radix-accordion-content-height"];
|
||||
|
||||
/**
|
||||
* R26 的落点:首屏 3D 场景组件。放在模块级而不是规则内部,是因为**自证夹具也要用它** ——
|
||||
* 路径手抄两份的结局是这个仓已经踩过的「夹具写死旧路径 ⇒ 判据看起来坏了」。
|
||||
*/
|
||||
/**
|
||||
* R22 的**视觉层登记表**(2026-12-02 第三态:零影像 → 登记制,理由见规则注释)。
|
||||
* R22 的**视觉层登记表**(2026-12-02 第五态:登记制恢复为一条)。
|
||||
*
|
||||
* 变迁:三态登记 `HeroScene`(机房场景)→ 四态随机房撤回**归零** → 五态随抽象数据场落地
|
||||
* 恢复为一条。R22 的语义不变:"任何视觉层都要先登记",登记即批准、未登记即判红。
|
||||
*
|
||||
* 每一条必须给三样东西,缺一样这条登记就无效:
|
||||
* marker —— 载体标记,必须真的出现在首屏区块内(防「登记了但载体已换」)
|
||||
* origin —— 出处(ADR 编号),供追溯为什么允许它出现在首屏
|
||||
* poster —— 海报帧相对 `public/` 的路径,必须真实存在(防「降级链写在文档里」)
|
||||
*
|
||||
* 新增任何首屏视觉层都必须在这里登记 —— 这正是零影像时代那条硬禁的替代物:
|
||||
* 不再问「有没有影像」,而问「这个视觉层是谁批准的、失败时退到哪」。
|
||||
*/
|
||||
const HERO_VISUAL_REGISTRY = new Map([
|
||||
[
|
||||
"src/app/(marketing)/home-content-v17.tsx",
|
||||
{ markers: ["HeroScene"], origin: "ADR-0016 §3", poster: "/images/home/hero-scene-poster.webp" },
|
||||
{ markers: ["HeroField"], origin: "ADR-0016 §17.5", poster: "/images/home/hero-field-poster.webp" },
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -78,18 +74,16 @@ const HERO_VISUAL_REGISTRY = new Map([
|
||||
* 首屏「视觉层」的载体集合,捕获组 = 载体名(与登记表 `markers` 用同一套字符串)。
|
||||
* `canvas` 单列是因为有人会绕过组件直接画 —— 零影像时代它整个落在扫描盲区。
|
||||
*/
|
||||
const VISUAL_LAYER_RE = /<(HeroPlate|Image|HeroScene|canvas|Canvas)\b/g;
|
||||
const VISUAL_LAYER_RE = /<(HeroPlate|Image|HeroField|canvas|Canvas)\b/g;
|
||||
|
||||
const HERO_SCENE_FILE = "src/components/home/hero-scene.tsx";
|
||||
|
||||
/**
|
||||
* 分镜一轮的时长上下限(ADR-0016 §10.5 例外条款 ①②)。
|
||||
* 上限 60s:再长就不再是「环境」,观众会开始等下一镜;
|
||||
* 下限 20s:太短就有脉冲感 —— 而「同一动画的等间隔重复」正是 E 案拒掉 pulseVertical 的理由。
|
||||
*/
|
||||
/* R26 的落点:首屏抽象数据场组件(ADR-0016 §17.5)。路径单点维护,自证夹具引用它。 */
|
||||
const HERO_FIELD_FILE = "src/components/home/hero-field.tsx";
|
||||
/* 分镜一轮的时长上下限(ADR-0016 §10.5 例外条款 ①②,随 §17.5 继任者沿用)。 */
|
||||
const HERO_CYCLE_CEILING = 60_000;
|
||||
const HERO_CYCLE_FLOOR = 20_000;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* R22 的落点:ADR-0011 §4.2 的「六页 hub × 一组参数」在 2026-12-01 扩到**全部营销页首屏**。
|
||||
*
|
||||
@@ -767,7 +761,7 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
* 次日又裁定首页改用**全幅 3D 场景**(ADR-0016)⇒ 零影像这条不再成立。
|
||||
*
|
||||
* **为什么不是「零影像」而是「登记制」**:零影像只能回答「影像有没有偷偷回来」,
|
||||
* 却对 `<canvas>` / `<HeroScene>` 完全失明 —— 而它才是今天首屏最重的视觉层。
|
||||
* 却对 `<canvas>` / `<HeroPlate>` 完全失明 —— 而它们才是首屏最重的视觉层。
|
||||
* 一个对主要形态静默放行的闸,等于没有闸。
|
||||
*
|
||||
* 现行语义:首屏出现任何视觉层(影像 / 3D 场景 / canvas)时,**该文件必须在
|
||||
@@ -798,10 +792,15 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
const j = src.indexOf('</section>', i);
|
||||
return j === -1 ? src.slice(i) : src.slice(i, j);
|
||||
};
|
||||
/* 登记表可注入:自证夹具不该依赖生产数据(本仓踩过「夹具写死生产条目 ⇒ 条目一删判据就崩」)。
|
||||
生产调用不传,仍用下面的 HERO_VISUAL_REGISTRY。 */
|
||||
const registry = opts.visualRegistry ?? HERO_VISUAL_REGISTRY;
|
||||
const posterExists = opts.posterExists ??
|
||||
((p) => existsSync(path.join(process.cwd(), "public", p.replace(/^\//, ""))));
|
||||
for (const rel of hubPresent) {
|
||||
const src = stripComments(files.get(rel) ?? "", { line: true });
|
||||
const scope = heroSlice(src);
|
||||
const entry = HERO_VISUAL_REGISTRY.get(rel);
|
||||
const entry = registry.get(rel);
|
||||
const tokens = [...scope.matchAll(VISUAL_LAYER_RE)].map((m) => m[1]);
|
||||
if (!entry) {
|
||||
if (tokens.length > 0) {
|
||||
@@ -819,13 +818,12 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
if (!entry.markers.some((m) => tokens.includes(m))) {
|
||||
r22Red.push(`${rel}:登记表批准的是 ${entry.markers.map((m) => `<${m}>`).join(" / ")},但首屏内一个都没找到 —— 登记表过期(换了载体没改登记,或标记被删)`);
|
||||
}
|
||||
const posterAbs = path.join(process.cwd(), "public", entry.poster.replace(/^\//, ""));
|
||||
if (!existsSync(posterAbs)) {
|
||||
if (!posterExists(entry.poster)) {
|
||||
r22Red.push(`${rel}:登记的海报帧 public${entry.poster} 不存在 —— 降级链是假的(WebGL 失败/移动档会露出空白)`);
|
||||
}
|
||||
}
|
||||
// 登记表里登记了却不在扫描名单里的文件 = 表在自说自话
|
||||
for (const rel of HERO_VISUAL_REGISTRY.keys()) {
|
||||
for (const rel of registry.keys()) {
|
||||
if (!HUB_HERO_FILES.includes(rel)) {
|
||||
r22Red.push(`${rel}:在 R22 登记表里,但不在 HUB_HERO_FILES —— 登记与扫描面不一致,这一条对它空转`);
|
||||
}
|
||||
@@ -834,7 +832,7 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
r22Red.push(`营销页首屏只找到 ${hubPresent.length}/${hubFloor} 页 —— 路径改名或文件被移动,本条对缺的那几页空转`);
|
||||
}
|
||||
rule({ id: "R22", name: "营销页首屏视觉层必须登记(载体 + 出处 + 海报帧)", denominator: hubPresent.length, red: r22Red,
|
||||
note: `找到 ${hubPresent.length}/${HUB_HERO_FILES.length} 页 · 已登记 ${HERO_VISUAL_REGISTRY.size} 页 · 未登记文件出现 ${VISUAL_LAYER_RE.source} 任一即判红` });
|
||||
note: `找到 ${hubPresent.length}/${HUB_HERO_FILES.length} 页 · 已登记 ${registry.size} 页 · 未登记文件出现 ${VISUAL_LAYER_RE.source} 任一即判红` });
|
||||
|
||||
/**
|
||||
* R23 正文构型:每页必须命中登记过的那一件(表见 COMPOSITION_FILES 注释)。
|
||||
@@ -913,8 +911,10 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
note: `裸写 ${rawTotal} 处 · 上限 ${rawCeiling}(次数口径,新增第 ${rawCeiling + 1} 处即判红)${rawTotal < rawCeiling ? " ⇒ 请把上限下调到实测值" : ""}`,
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* R26 首屏 3D 场景契约 —— ADR-0016 §10.5 那条例外条款的**机器可判部分**。
|
||||
* R26 首屏抽象数据场契约 —— ADR-0016 §17.5 分镜判据的**机器可判部分**
|
||||
* (机房场景撤回后随继任者重建;判据同 §10.5)。
|
||||
*
|
||||
* 为什么必须有这条:例外条款如果只写在 CONTEXT 里,就是把「首屏可以循环」交给下一个人
|
||||
* 自觉。`check:motion` 只扫 CSS 时长字面量与贝塞尔曲线,**WebGL 的 rAF 完全在它视野外**
|
||||
@@ -925,17 +925,17 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
* ② 必须尊重 `prefers-reduced-motion`(定格);
|
||||
* ③ 必须离屏/后台即停(`IntersectionObserver` + `visibilitychange` 两者都要);
|
||||
* ④ 禁止 `autoRotate`(自转 = 同一动画重复播放,例外条款明禁)。
|
||||
* 「不得脉冲式重复」没有静态形态可判,与 R22 的排版支点同理,交由人工评审 —— note 里写明,不假装自动。
|
||||
* 「不得脉冲式重复」没有静态形态可判,交由人工评审 —— note 里写明,不假装自动。
|
||||
*
|
||||
* 文件不存在时**不判红**(与 R22 缺页判红相反):场景是可选特性,未启用就是 E 案,
|
||||
* 缺席不是违规。但一旦存在,就必须满足上述四条 —— 否则等于开了口子没人守。
|
||||
*/
|
||||
const heroSceneSrc = files.get(HERO_SCENE_FILE);
|
||||
const heroFieldSrc = files.get(HERO_FIELD_FILE);
|
||||
const r26Red = [];
|
||||
let cycleMs = 0;
|
||||
let shotCount = 0;
|
||||
if (heroSceneSrc) {
|
||||
const live = stripComments(heroSceneSrc, { line: true });
|
||||
if (heroFieldSrc) {
|
||||
const live = stripComments(heroFieldSrc, { line: true });
|
||||
const shotMs = [...live.matchAll(/\bms:\s*(\d+)/g)].map((m) => Number(m[1]));
|
||||
const dipMatch = live.match(/DIP_MS\s*=\s*(\d+)/);
|
||||
const dipMs = dipMatch ? Number(dipMatch[1]) : 0;
|
||||
@@ -943,11 +943,11 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
cycleMs = shotMs.reduce((a, b) => a + b, 0) + dipMs * Math.max(shotCount, 1);
|
||||
|
||||
if (shotCount === 0) {
|
||||
r26Red.push(`${HERO_SCENE_FILE}:解析不到任何 \`ms:\` 镜头时长 —— 结构已变,本条对本文件空转(请同步改判据)`);
|
||||
r26Red.push(`${HERO_FIELD_FILE}:解析不到任何 \`ms:\` 拍次时长 —— 结构已变,本条对本文件空转(请同步改判据)`);
|
||||
} else if (cycleMs > HERO_CYCLE_CEILING) {
|
||||
r26Red.push(`分镜一轮 ${cycleMs}ms > 上限 ${HERO_CYCLE_CEILING}ms(${shotCount} 镜)—— 例外条款只允许「环境级」编排`);
|
||||
r26Red.push(`分镜一轮 ${cycleMs}ms > 上限 ${HERO_CYCLE_CEILING}ms(${shotCount} 拍)—— 例外条款只允许「环境级」编排`);
|
||||
} else if (cycleMs < HERO_CYCLE_FLOOR) {
|
||||
r26Red.push(`分镜一轮 ${cycleMs}ms < 下限 ${HERO_CYCLE_FLOOR}ms(${shotCount} 镜)—— 过短即成脉冲式重复`);
|
||||
r26Red.push(`分镜一轮 ${cycleMs}ms < 下限 ${HERO_CYCLE_FLOOR}ms(${shotCount} 拍)—— 过短即成脉冲式重复`);
|
||||
}
|
||||
if (!/prefers-reduced-motion/.test(live)) {
|
||||
r26Red.push("未尊重 prefers-reduced-motion —— 例外条款要求静态定格,不能强制所有人看运镜");
|
||||
@@ -961,11 +961,11 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
}
|
||||
rule({
|
||||
id: "R26",
|
||||
name: "首屏 3D 场景契约(周期 / 定格 / 离屏停 / 禁自转)",
|
||||
denominator: heroSceneSrc ? 1 : 0,
|
||||
name: "首屏抽象数据场契约(周期 / 定格 / 离屏停 / 禁自转)",
|
||||
denominator: heroFieldSrc ? 1 : 0,
|
||||
red: r26Red,
|
||||
note: heroSceneSrc
|
||||
? `周期 ${cycleMs}ms(${shotCount} 镜)· 区间 [${HERO_CYCLE_FLOOR}, ${HERO_CYCLE_CEILING}]ms · 「不得脉冲式重复」无静态形态,由人工评审兜`
|
||||
note: heroFieldSrc
|
||||
? `周期 ${cycleMs}ms(${shotCount} 拍)· 区间 [${HERO_CYCLE_FLOOR}, ${HERO_CYCLE_CEILING}]ms · 「不得脉冲式重复」无静态形态,由人工评审兜`
|
||||
: "场景组件未启用(E 案)—— 本条不适用",
|
||||
});
|
||||
|
||||
@@ -975,14 +975,16 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) {
|
||||
// ---- 自证(负例):喂一批明知违规的样本,不判红就宣布上面全部不作数 ----
|
||||
function selftest() {
|
||||
const bad = `:root {\n --radius-xs: 3px;\n --radius-sm: 6px;\n --radius-full: 0px;\n --shadow-brand: 0 6px 24px rgba(196,30,58,.22);\n --badge-radius: var(--radius-full);\n}\n.bain-card:hover { transform: translateY(-4px); }\n/* R21 的「已定义」一侧:夹具里必须真实存在一个自定义类名,否则只会测到"全判红" */\n.container-x { max-width: 1360px; }\n`;
|
||||
|
||||
// R26 三向自证夹具:①周期超标 ②合规基线 ③缺 reduced-motion。
|
||||
// 三份都刻意不含 className / 高档字阶,避免污染 R1–R25 的读数(夹具互相串味是这仓踩过的坑)。
|
||||
const heroDirty = `const SHOTS = [{ ms: 40000 }, { ms: 40000 }];\nconst DIP_MS = 420;\nconst prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nnew IntersectionObserver(() => {});\ndocument.addEventListener('visibilitychange', () => {});\n`;
|
||||
const heroClean = `const SHOTS = [{ ms: 16000 }, { ms: 13000 }, { ms: 13000 }];\nconst DIP_MS = 420;\nconst prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nnew IntersectionObserver(() => {});\ndocument.addEventListener('visibilitychange', () => {});\n`;
|
||||
const heroNoReduced = heroClean.replace("prefers-reduced-motion", "no-such-motion-query");
|
||||
const fieldDirty = `const ACTS = [{ ms: 40000 }, { ms: 40000 }];\nconst DIP_MS = 420;\nconst prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nnew IntersectionObserver(() => {});\ndocument.addEventListener('visibilitychange', () => {});\n`;
|
||||
const fieldClean = `const ACTS = [{ ms: 16000 }, { ms: 13000 }, { ms: 13000 }];\nconst DIP_MS = 420;\nconst prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nnew IntersectionObserver(() => {});\ndocument.addEventListener('visibilitychange', () => {});\n`;
|
||||
const fieldNoReduced = fieldClean.replace("prefers-reduced-motion", "no-such-motion-query");
|
||||
|
||||
const files = new Map([
|
||||
[HERO_SCENE_FILE, heroDirty],
|
||||
[HERO_FIELD_FILE, fieldDirty],
|
||||
|
||||
["src/app/globals.css", bad],
|
||||
["src/components/ui/cta-button.tsx", 'className="rounded-full"'],
|
||||
// R9 双向都要被抓到:文字档仍是胶囊 **且** icon 档被方角化
|
||||
@@ -1053,13 +1055,13 @@ function selftest() {
|
||||
* 第二向是防「一律报红」的坏判据,第三向是防「只认周期、其余三条形同虚设」。
|
||||
*/
|
||||
const r26RedFor = (src) =>
|
||||
checkGrammar(bad, new Map([[HERO_SCENE_FILE, src]]), RADIX_REF, {
|
||||
checkGrammar(bad, new Map([[HERO_FIELD_FILE, src]]), RADIX_REF, {
|
||||
compositionUnmetCeiling: 0,
|
||||
rawStatementCeiling: 0,
|
||||
}).find((x) => x.id === "R26").red;
|
||||
const r26TooLong = r26RedFor(heroDirty);
|
||||
const r26Clean = r26RedFor(heroClean);
|
||||
const r26NoReduced = r26RedFor(heroNoReduced);
|
||||
const r26TooLong = r26RedFor(fieldDirty);
|
||||
const r26Clean = r26RedFor(fieldClean);
|
||||
const r26NoReduced = r26RedFor(fieldNoReduced);
|
||||
const r26CatchesPeriod = r26TooLong.some((m) => m.includes("上限"));
|
||||
const r26PassesClean = r26Clean.length === 0;
|
||||
const r26CatchesReduced = r26NoReduced.some((m) => m.includes("prefers-reduced-motion"));
|
||||
@@ -1076,11 +1078,15 @@ function selftest() {
|
||||
* 第三维单独测「注释掉的 <HeroPlate> 不算数」—— 这是本仓踩过的同一类坑
|
||||
* (`constants.ts` 注释里的示例 import 曾骗过再导出正则)。
|
||||
*/
|
||||
// ── R22 登记制自证(2026-12-02 第三态)──
|
||||
// 五向:未登记载体判红 / 登记页通过 / 表过期判红 / 未批准载体判红 / 注释不算数 / 缺页判红。
|
||||
// 登记页的文件名从登记表里取,不手抄 —— 手抄路径腐化过一次(夹具写死旧路径 ⇒ 判据看着像坏了)。
|
||||
const REG_REL = [...HERO_VISUAL_REGISTRY.keys()][0];
|
||||
const REG_APPROVED = `export function Hero(){ return (<div><${HERO_VISUAL_REGISTRY.get(REG_REL).markers[0]} /></div>); }`;
|
||||
// ── R22 登记制自证(2026-12-02 第四态:生产登记表已归零)──
|
||||
// 六向:未登记载体判红 / 登记页通过 / 表过期判红 / 未批准载体判红 / 注释不算数 / 缺页判红。
|
||||
// ⚠ 生产登记表现在是**空表**(首屏零视觉层)。若夹具从生产表里取条目,表一空自证就崩 ——
|
||||
// 所以这里注入一张夹具表,测的是「登记机制」而不是「当前登记了什么」。
|
||||
const REG_REL = HUB_HERO_FILES[0];
|
||||
const FIXTURE_REG = new Map([
|
||||
[REG_REL, { markers: ["HeroPlate"], origin: "fixture", poster: "/_fixture-poster.webp" }],
|
||||
]);
|
||||
const REG_APPROVED = `export function Hero(){ return (<div><${FIXTURE_REG.get(REG_REL).markers[0]} /></div>); }`;
|
||||
const hubDirty = 'export function Hero(){ return (<div><HeroPlate variant="facade" /></div>); }';
|
||||
const hubCanvas = 'export function Hero(){ return (<div><canvas /></div>); }';
|
||||
const hubClean = 'export function Hero(){ return (<div className="text-6xl">纯排版首屏</div>); }';
|
||||
@@ -1092,7 +1098,12 @@ function selftest() {
|
||||
);
|
||||
};
|
||||
const r22RedFor = (map, opts) =>
|
||||
checkGrammar(bad, map, "", { floor: 0, ...opts }).find((x) => x.id === "R22").red;
|
||||
checkGrammar(bad, map, "", {
|
||||
floor: 0,
|
||||
visualRegistry: FIXTURE_REG,
|
||||
posterExists: () => true,
|
||||
...opts,
|
||||
}).find((x) => x.id === "R22").red;
|
||||
const r22Clean = r22RedFor(cleanMap(), { hubFloor: 0 });
|
||||
const r22Plate = r22RedFor(cleanMap(hubDirty), { hubFloor: 0 });
|
||||
const r22Canvas = r22RedFor(cleanMap(hubCanvas), { hubFloor: 0 });
|
||||
@@ -1101,7 +1112,7 @@ function selftest() {
|
||||
new Map(HUB_HERO_FILES.map((r) => [r, hubClean])),
|
||||
{ hubFloor: 0 },
|
||||
);
|
||||
// 未批准载体:登记页里出现 <Image(只批准了 HeroScene)
|
||||
// 未批准载体:登记页里出现 <Image>(夹具表只批准了 HeroPlate)
|
||||
const r22Unapproved = r22RedFor(
|
||||
new Map(HUB_HERO_FILES.map((r) => [r, r === REG_REL ? `${REG_APPROVED}<Image src="/x.webp" alt="" />` : hubClean])),
|
||||
{ hubFloor: 0 },
|
||||
@@ -1138,8 +1149,8 @@ function selftest() {
|
||||
* 只测「区块外有图 → 不报」的话,判据可能已经不再扫首屏。
|
||||
*/
|
||||
const HOME_REL = HUB_HERO_FILES[0];
|
||||
const homeWithCover = `<section data-testid="hero-section"><HeroScene /><h1>好</h1></section><section><Image src="/cover.webp" alt="" /></section>`;
|
||||
const homeWithHeroImg = `<section data-testid="hero-section"><HeroScene /><Image src="/x.webp" alt="" /><h1>差</h1></section><section><Image src="/cover.webp" alt="" /></section>`;
|
||||
const homeWithCover = `<section data-testid="hero-section"><HeroPlate /><h1>好</h1></section><section><Image src="/cover.webp" alt="" /></section>`;
|
||||
const homeWithHeroImg = `<section data-testid="hero-section"><HeroPlate /><Image src="/x.webp" alt="" /><h1>差</h1></section><section><Image src="/cover.webp" alt="" /></section>`;
|
||||
const r22Cover = r22RedFor(new Map([[HOME_REL, homeWithCover]]), { hubFloor: 0, floor: 0 });
|
||||
const r22HeroImg = r22RedFor(new Map([[HOME_REL, homeWithHeroImg]]), { hubFloor: 0, floor: 0 });
|
||||
const r22ScopeOk = r22Cover.length === 0 && r22HeroImg.length === 1 && r22HeroImg[0].includes(HOME_REL);
|
||||
|
||||
Reference in new issue
Block a user