- 新数据链 web/teaching/cases/carrier-partdesign:20 件零件(spec.json 唯一来源)、 内核建造器 parts/*.mjs、traces/FCStd/replay 全量产物;装配 20 插入 + 19 关节。 - 工具包 tools/carrier:catalog / preflight / create-part / create-assembly / create-all / list / self-test / README,按零件与装配拆分为独立工具。 - 共享驱动扩展 web/tools/cad-ui-rebuild:Loft/Pipe/Hole/Fillet/Chamfer/Mirrored/ LinearPattern 交互,Reversed 复选框补齐;装配 saveAssemblyBundle 先 Accept 再保存。 - 教学:lessons.mjs 新增 carrier 组(环境课 + 20 件 + 装配),suite-runner 增加 carrier-part/carrier-assembly,生成 carrier-toolkit.html 并接入 index 与控制台证据。 验证:20 件 210 步全部有头通过(P05 修复后 39640 m³;P06 回归 8/8); 装配 20/20 插入、19/19 关节、20 组件 0 畸形、0 mismatch;check:carrier、 check:reducer、check-console --live 全绿。 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
42 lines
1.8 KiB
JavaScript
42 lines
1.8 KiB
JavaScript
// Where a step's screenshot is written, and what it is called.
|
|
//
|
|
// The writer (drive.mjs) and the checker (accept.mjs) must agree exactly, or a
|
|
// project that never had a video pipeline gets a false "missing still" for
|
|
// every step. A course script, when present, supplies the scene id and title;
|
|
// without one the step number is enough. Both sides call these helpers.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
/** Scene id for step index (0-based): `S01` unless a course script says otherwise. */
|
|
export function sceneId(project, part, index, steps) {
|
|
const declared = part.sceneTitles?.[index + 1];
|
|
if (declared) return declared;
|
|
const script = readScript(project, part);
|
|
const hit = script?.scenes?.find(item => item.step === index + 1);
|
|
return hit?.id ?? `S${String(index + 1).padStart(2, "0")}`;
|
|
}
|
|
|
|
/** Human title for a step, used inside the filename. */
|
|
export function sceneTitle(project, part, index, steps) {
|
|
const script = readScript(project, part);
|
|
return script?.scenes?.find(item => item.step === index + 1)?.title
|
|
?? steps[index]?.label ?? `step ${index + 1}`;
|
|
}
|
|
|
|
/** Filename stem (no extension) for a step's still. */
|
|
export function stillName(project, part, index, steps) {
|
|
const title = String(sceneTitle(project, part, index, steps)).replace(/[^\w一-龥-]+/g, "_");
|
|
return `${sceneId(project, part, index, steps)}-${title}`;
|
|
}
|
|
|
|
/** Absolute path a step's still is written to. */
|
|
export function stillPath(project, part, index, steps) {
|
|
return path.join(project.paths.stillsDir, part.id, `${stillName(project, part, index, steps)}.png`);
|
|
}
|
|
|
|
function readScript(project, part) {
|
|
const file = path.join(project.root, "episodes", part.id, "script.zh.json");
|
|
if (!fs.existsSync(file)) return null;
|
|
try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
|
|
}
|