- lock the three-column height chain on workbench/PartDesign pages so each side panel scrolls independently and the centre stage keeps its size - dock module task panels above the layout with their own scrollbar instead of letting them push the stage out of the viewport - add tools/layout-probe.mjs (page scroll, aside bounds, pane scrolling, stage stability) and CLI mode for tools/static-host.mjs with relative --root support - add the P0-P4 browser functional suite, manual scenarios and capture tooling; document it under docs/current/web-functional-suite Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
204 lines
9.7 KiB
JavaScript
204 lines
9.7 KiB
JavaScript
#!/usr/bin/env node
|
||
// Generates web/manual/content/ch16-panel-index.md from the authoritative UI
|
||
// surface inventory (tools/fcweb/out/ui-surface-inventory.json).
|
||
//
|
||
// The chapter is a reference appendix: every shell region, dock, task panel,
|
||
// modal dialog, preference page, menu, toolbar, status bar item and viewport
|
||
// tool with its React owner and desktop reference. Deterministic output: no
|
||
// timestamps, sorted by category then module then id.
|
||
//
|
||
// node tools/manual/generate-panel-index.mjs
|
||
// node tools/manual/generate-panel-index.mjs --check # exit 1 on drift
|
||
import fs from "node:fs";
|
||
import path from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
|
||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||
const webRoot = path.resolve(here, "../..");
|
||
const repoRoot = path.resolve(webRoot, "..");
|
||
const inventoryPath = path.join(repoRoot, "tools/fcweb/out/ui-surface-inventory.json");
|
||
const outPath = path.join(webRoot, "manual/content/ch16-panel-index.md");
|
||
|
||
const args = process.argv.slice(2);
|
||
const check = args.includes("--check");
|
||
|
||
if (!fs.existsSync(inventoryPath)) {
|
||
console.error(`[generate-panel-index] missing ${inventoryPath}; run tools/fcweb/ui-surface-inventory.mjs first`);
|
||
process.exit(2);
|
||
}
|
||
const inventory = JSON.parse(fs.readFileSync(inventoryPath, "utf8"));
|
||
|
||
const CATEGORY_ORDER = ["shell-region", "statusbar", "viewport-tool", "dock", "task-panel", "modal-dialog", "preferences-page", "menu", "toolbar"];
|
||
const CATEGORY_TITLE = {
|
||
"shell-region": "壳层区域",
|
||
statusbar: "状态栏",
|
||
"viewport-tool": "视口工具",
|
||
dock: "停靠面板",
|
||
"task-panel": "任务面板",
|
||
"modal-dialog": "模态对话框",
|
||
"preferences-page": "偏好设置页",
|
||
menu: "菜单",
|
||
toolbar: "工具栏",
|
||
};
|
||
const CATEGORY_INTRO = {
|
||
"shell-region": "主窗口骨架:标题栏、工作台切换器、菜单栏容器、工具栏容器、视口、停靠区、底部报告区、命令面板与快捷键入口。",
|
||
statusbar: "底部状态栏:文档名、保存状态、网格与渲染统计。",
|
||
"viewport-tool": "三维视口右上角与导航立方体旁的视图工具:视图切换、剖切面、导航方式等。",
|
||
dock: "可停靠面板:模型树、属性编辑器、任务面板宿主等,由右侧停靠区承载,可折叠、可切换。",
|
||
"task-panel": "工作台任务面板:每个 `<module>-<feature>-task.tsx` 对应一个桌面 TaskDialog 参数页,统一由 `TaskFrame` 挂载。",
|
||
"modal-dialog": "应用级模态对话框:阻断主界面交互、需要确认或选择后才能继续的操作。",
|
||
"preferences-page": "偏好设置对话框的分页,对应桌面 Edit → Preferences。",
|
||
menu: "菜单栏条目:按工作台聚合,每项菜单展开后给出命令列表。",
|
||
toolbar: "工具栏组:每个工作台一组,命令与桌面工具栏一一对应。",
|
||
};
|
||
const STATUS_ZH = { implemented: "已实现", partial: "部分实现", gap: "缺口", boundary: "边界" };
|
||
|
||
const esc = value => String(value ?? "")
|
||
.replace(/\|/g, "\\|")
|
||
.replace(/\n+/g, " ")
|
||
.trim();
|
||
|
||
const surfaceRows = inventory.surfaces
|
||
.slice()
|
||
.sort((a, b) => {
|
||
const ca = CATEGORY_ORDER.indexOf(a.category);
|
||
const cb = CATEGORY_ORDER.indexOf(b.category);
|
||
if (ca !== cb) return ca - cb;
|
||
const ma = a.moduleId ?? "";
|
||
const mb = b.moduleId ?? "";
|
||
if (ma !== mb) return ma.localeCompare(mb, "en");
|
||
return a.id.localeCompare(b.id, "en");
|
||
});
|
||
|
||
const byCategory = new Map();
|
||
for (const surface of surfaceRows) {
|
||
if (!byCategory.has(surface.category)) byCategory.set(surface.category, []);
|
||
byCategory.get(surface.category).push(surface);
|
||
}
|
||
|
||
const counts = inventory.counts;
|
||
const lines = [];
|
||
lines.push("---");
|
||
lines.push("id: ch16");
|
||
lines.push("order: 16");
|
||
lines.push("title: 全功能面板索引与实现映射");
|
||
lines.push("level: appendix");
|
||
lines.push("---");
|
||
lines.push("");
|
||
lines.push("# 第 16 章 全功能面板索引与实现映射");
|
||
lines.push("");
|
||
lines.push("本章由 `tools/fcweb/ui-surface-inventory.mjs` 生成,是 Web FreeCAD 全部界面表面的权威索引。");
|
||
lines.push(`当前共 **${counts.total}** 个界面表面,覆盖 ${Object.keys(counts.byCategory).length} 类;状态分布:` +
|
||
Object.entries(counts.byStatus).map(([status, count]) => `${STATUS_ZH[status] ?? status} ${count}`).join("、") +
|
||
"(缺口 " + counts.gaps + " 项)。");
|
||
lines.push("");
|
||
lines.push("> 改动 `web/src` 后请重跑 `node tools/fcweb/ui-surface-inventory.mjs` 与本生成器,不要手改本章。");
|
||
lines.push("");
|
||
lines.push("## 16.1 分类总览");
|
||
lines.push("");
|
||
lines.push("| 类别 | 数量 | 说明 |");
|
||
lines.push("| --- | ---: | --- |");
|
||
for (const category of CATEGORY_ORDER) {
|
||
const rows = byCategory.get(category) ?? [];
|
||
lines.push(`| ${CATEGORY_TITLE[category]}(\`${category}\`) | ${rows.length} | ${esc(CATEGORY_INTRO[category])} |`);
|
||
}
|
||
lines.push("");
|
||
lines.push("### 状态口径");
|
||
lines.push("");
|
||
lines.push("| 状态 | 含义 |");
|
||
lines.push("| --- | --- |");
|
||
lines.push("| 已实现 | React 组件存在、已注册并能从界面到达,有对应命令或路由。 |");
|
||
lines.push("| 部分实现 | 组件存在但未完全注册/挂载,或仅覆盖桌面能力的一部分。 |");
|
||
lines.push("| 缺口 | 桌面 FreeCAD 有、Web 端缺失。按项目铁律用 React 组件补齐,不得留作 blocked。 |");
|
||
lines.push("| 边界 | 受内核或平台限制无法实现(如跨 Worker 文档桥),需写明原因与解除条件。 |");
|
||
lines.push("");
|
||
lines.push("## 16.2 界面表面实拍");
|
||
lines.push("");
|
||
lines.push("以下截图由 `web/manual/scenarios/ch16-shell-surfaces.json` 在真实运行的 Web FreeCAD 上采集(Playwright,1440×900)。");
|
||
lines.push("");
|
||
const SHOTS = [
|
||
["01-shell-overview", "完整壳层:应用菜单栏、工作台工具栏、对象树、属性面板、三维视口、任务区与文档标签。"],
|
||
["02-tools-menu", "Tools 菜单:偏好设置、快捷键定制、命令面板入口。"],
|
||
["03-preferences", "偏好设置对话框:单位制、导航风格、视图与保存选项。"],
|
||
["04-shortcuts", "快捷键编辑器:按命令搜索并重绑按键。"],
|
||
["05-command-palette", "命令面板(Ctrl+Shift+P):模糊搜索全部已注册命令。"],
|
||
["06-bottom-dock", "底部停靠:Selection view / Report view / Python console 三个页签,可浮动、可全屏。"],
|
||
["07-viewport-tools", "视口工具条:移动 / 旋转 / 关闭、局部坐标、「局部坐标…」编辑入口与位置读数。"],
|
||
["08-task-panel", "任务面板:Part 立方体创建任务,含 Box dimensions、Volume 与 Bounds,底部为关闭与取消按钮。"],
|
||
];
|
||
for (const [name, caption] of SHOTS) {
|
||
lines.push(``);
|
||
lines.push("");
|
||
}
|
||
lines.push("");
|
||
|
||
let sectionNumber = 3;
|
||
for (const category of CATEGORY_ORDER) {
|
||
const rows = byCategory.get(category) ?? [];
|
||
if (!rows.length) continue;
|
||
lines.push(`## 16.${sectionNumber} ${CATEGORY_TITLE[category]}(${rows.length})`);
|
||
lines.push("");
|
||
lines.push(CATEGORY_INTRO[category]);
|
||
lines.push("");
|
||
lines.push("| 名称 | React 实现 | 桌面参考 | 状态 | 注释 |");
|
||
lines.push("| --- | --- | --- | --- | --- |");
|
||
for (const surface of rows) {
|
||
const owner = surface.owner?.file
|
||
? `\`${esc(surface.owner.file.replace(/^web\//, ""))}${surface.owner.symbol ? `#${esc(surface.owner.symbol)}` : ""}\``
|
||
: "—";
|
||
const desktop = surface.desktopRef?.file
|
||
? `\`${esc(surface.desktopRef.file.replace(/^freecad-source\//, ""))}${surface.desktopRef.symbol ? `#${esc(surface.desktopRef.symbol)}` : ""}\``
|
||
: "—";
|
||
const label = category === "menu" || category === "toolbar" ? esc(surface.nameZh) : `${esc(surface.nameZh)}(\`${esc(surface.id)}\`)`;
|
||
lines.push(`| ${label} | ${owner} | ${desktop} | ${STATUS_ZH[surface.status] ?? surface.status} | ${esc(surface.note ?? "") || "—"} |`);
|
||
}
|
||
lines.push("");
|
||
sectionNumber += 1;
|
||
}
|
||
|
||
lines.push("## 16." + sectionNumber + " 缺口与边界清单");
|
||
lines.push("");
|
||
const gaps = inventory.gaps ?? [];
|
||
if (!gaps.length) {
|
||
lines.push("当前清单无 `gap`/`boundary` 项:全部界面表面均有 React 实现。");
|
||
} else {
|
||
lines.push("| 表面 | 类别 | 状态 | 原因 | 解除条件 |");
|
||
lines.push("| --- | --- | --- | --- | --- |");
|
||
for (const gap of gaps) {
|
||
lines.push(`| \`${esc(gap.id)}\` | ${esc(CATEGORY_TITLE[gap.category] ?? gap.category)} | ${STATUS_ZH[gap.status] ?? gap.status} | ${esc(gap.reason ?? "")} | ${esc(gap.resolution ?? "")} |`);
|
||
}
|
||
}
|
||
lines.push("");
|
||
lines.push("## 16." + (sectionNumber + 1) + " 复核命令");
|
||
lines.push("");
|
||
lines.push("```bash");
|
||
lines.push('R="/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD"');
|
||
lines.push('node "$R/tools/fcweb/ui-inventory.mjs"');
|
||
lines.push('node "$R/tools/fcweb/ui-surface-inventory.mjs" # 生成清单');
|
||
lines.push('node "$R/tools/fcweb/ui-surface-inventory.mjs" --check # 漂移检查');
|
||
lines.push('node "$R/web/tools/manual/generate-panel-index.mjs" # 重生成本章');
|
||
lines.push("```");
|
||
lines.push("");
|
||
|
||
const markdown = lines.join("\n");
|
||
|
||
if (check) {
|
||
const previous = fs.existsSync(outPath) ? fs.readFileSync(outPath, "utf8") : "";
|
||
if (previous !== markdown) {
|
||
console.error("[generate-panel-index] --check: ch16-panel-index.md is stale");
|
||
process.exit(1);
|
||
}
|
||
console.log(JSON.stringify({ ok: true, checked: path.relative(repoRoot, outPath), surfaces: counts.total }));
|
||
process.exit(0);
|
||
}
|
||
|
||
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
||
fs.writeFileSync(outPath, markdown);
|
||
console.log(JSON.stringify({
|
||
ok: true,
|
||
out: path.relative(repoRoot, outPath),
|
||
surfaces: counts.total,
|
||
sections: sectionNumber - 1,
|
||
bytes: Buffer.byteLength(markdown),
|
||
}));
|