docs(web): full UI surface inventory, illustrated manual, panel screenshots

Interface design document and manual now share one authoritative surface
inventory (333 surfaces across 9 categories, gap 0), and every chapter carries
real Playwright screenshots of the panels it documents.

- tools/fcweb: ui-surface-scan/ui-surface-inventory (deterministic --check),
  build-ui-doc renders panel catalog, workbench matrix and mapping tables;
  blank toolbar crops (<1 KB) are skipped and pruned instead of embedded
- web/tools/manual: generate-panel-index (ch16), audit-ui-gaps,
  generate-final-status, generate-gaps-doc; pager is per-chapter so the manual
  no longer overflows horizontally
- manual: 130 screenshot references / 128 PNGs, panel sections for ch02-ch13
- web/src: utility menus stop click propagation (menu reopened on item click);
  workbench shell gains an OPFS document picker so workbench.html can bind a
  real document instead of the fixed workbench-document id; Sketcher panel
  moves from the command column to the main stage

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 01:30:31 +08:00
parent 3c2c623f70
commit 300c8efb01
180 changed files with 27036 additions and 4185 deletions

View File

@@ -0,0 +1,562 @@
// Scans the Web FreeCAD shell, workbench panels, task panels and dialogs, and
// pairs each UI surface with its React owner and the desktop FreeCAD source it
// mirrors. The result feeds tools/fcweb/ui-surface-inventory.mjs and, through
// docs/current/ui-design/source.html markers, the generated UI design document.
import fs from "node:fs";
import path from "node:path";
const SOURCE_EXT = /\.(tsx?|jsx?)$/;
const CJK = /[一-龥]/;
export const CATEGORIES = [
"shell-region",
"dock",
"task-panel",
"modal-dialog",
"preferences-page",
"menu",
"toolbar",
"statusbar",
"viewport-tool",
];
const CHAPTER_STATUS = {
renders: "implemented",
conditional: "partial",
fallback: "partial",
unreachable: "boundary",
};
const TERMS = {
attachment: "附着",
boolean: "布尔运算",
builder: "形状构建器",
box: "立方体",
chamfer: "倒角",
clone: "克隆",
common: "交集",
compound: "复合",
cone: "圆锥",
cut: "差集",
cylinder: "圆柱",
datum: "基准",
draft: "拔模",
dressup: "修饰",
extrude: "拉伸",
fillet: "圆角",
fragment: "切片",
fuse: "并集",
groove: "沟槽",
helix: "螺旋",
hole: "孔",
ifc: "IFC",
joint: "关节",
loft: "放样",
mirror: "镜像",
model: "模型",
multi: "多重",
offset: "偏移",
pad: "凸台",
pattern: "阵列",
pipe: "管道",
pocket: "凹槽",
primitive: "基本体",
prism: "棱柱",
revolution: "旋转",
scale: "缩放",
section: "截面",
shape: "形状",
shapebinder: "形状绑定",
sketch: "草图",
sphere: "球体",
spreadsheet: "电子表格",
thickness: "抽壳",
torus: "圆环",
transform: "变换",
tube: "管",
validate: "校验",
wedge: "楔体",
};
const MODULE_ZH = {
Assembly: "装配",
BIM: "BIM",
CAM: "CAM",
Cloud: "云",
Draft: "Draft",
Fem: "FEM",
Help: "帮助",
Import: "导入",
Inspection: "检测",
JtReader: "JT 读取",
Material: "材料",
Measure: "测量",
Mesh: "网格",
MeshPart: "网格零件",
Part: "零件",
PartDesign: "零件设计",
Plot: "绘图",
Points: "点云",
ReverseEngineering: "逆向工程",
Robot: "机器人",
Sandbox: "沙箱",
Show: "显示",
Sketcher: "草图器",
Spreadsheet: "电子表格",
Start: "开始",
Surface: "曲面",
TechDraw: "工程图",
TemplatePyMod: "模板",
Test: "测试",
Tux: "Tux",
Web: "Web",
};
const MENU_ZH = {
File: "文件",
Edit: "编辑",
View: "视图",
Tools: "工具",
Macro: "宏",
Windows: "窗口",
Help: "帮助",
Sketch: "草图",
Part: "零件",
"Part Design": "零件设计",
Assembly: "装配",
Measure: "测量",
Mesh: "网格",
"Mesh Design": "网格设计",
Surface: "曲面",
Spreadsheet: "电子表格",
TechDraw: "工程图",
Robot: "机器人",
Material: "材料",
Inspection: "检测",
"Reverse Engineering": "逆向工程",
Points: "点云",
Draft: "Draft",
Arch: "建筑",
BIM: "BIM",
Path: "CAM",
CAM: "CAM",
FEM: "FEM",
Std: "标准",
};
const TOOLBAR_ZH = {
File: "文件",
Workbench: "工作台",
Macro: "宏",
View: "视图",
Structure: "结构",
"Std View": "标准视图",
Solids: "实体",
"Part Tools": "零件工具",
"Boolean Tools": "布尔工具",
"Part Design Helper Features": "零件设计辅助特征",
"Part Design Modeling Features": "零件设计建模特征",
"Part Design Dressup Features": "零件设计修饰特征",
"Sketch Tools": "草图工具",
"Sketcher Tools": "草图器工具",
"Draft Tools": "Draft 工具",
"Arch Tools": "建筑工具",
"BIM Tools": "BIM 工具",
"Mesh Tools": "网格工具",
"FEM Tools": "FEM 工具",
"TechDraw Tools": "工程图工具",
"Robot Tools": "机器人工具",
};
const SHELL_SURFACES = [
{ id: "shell:menubar", nameZh: "菜单栏", file: "web/src/shell/menu-bar.tsx", symbol: "DesktopMenuBar", desktop: "src/Gui/MenuManager.cpp", desktopSymbol: "MenuManager" },
{ id: "shell:toolbar", nameZh: "工具栏", file: "web/src/shell/toolbar.tsx", symbol: "DesktopToolbars", desktop: "src/Gui/ToolBarManager.cpp", desktopSymbol: "ToolBarManager" },
{ id: "shell:workbench-menu", nameZh: "工作台菜单", file: "web/src/shell/workbench-menu.tsx", symbol: "ParityWorkbenchMenu", desktop: "src/Gui/Workbench.cpp", desktopSymbol: "Workbench::setupMenuBar" },
{ id: "shell:workbench-toolbars", nameZh: "工作台工具栏", file: "web/src/shell/workbench-toolbars.tsx", symbol: "ParityWorkbenchToolbars", desktop: "src/Gui/Workbench.cpp", desktopSymbol: "Workbench::setupToolBars" },
{ id: "shell:task-view", nameZh: "任务面板视图", file: "web/src/shell/task-frame.tsx", symbol: "TaskFrame", desktop: "src/Gui/TaskView/TaskView.cpp", desktopSymbol: "TaskView" },
{ id: "shell:dock-overlay", nameZh: "停靠覆盖层", file: "web/src/dock-overlay-host.tsx", symbol: "DockOverlayHost", desktop: "src/Gui/DockWindowManager.cpp", desktopSymbol: "DockWindowManager" },
{ id: "shell:bottom-dock", nameZh: "底部停靠(报告视图)", file: "web/src/shell/bottom-dock.tsx", symbol: "BottomDock", desktop: "src/Gui/MainWindow.cpp", desktopSymbol: "setupDockWindows" },
{ id: "shell:statusbar", nameZh: "状态栏", file: "web/src/project-shell.tsx", symbol: "App", desktop: "src/Gui/MainWindow.cpp", desktopSymbol: "statusBar" },
{ id: "shell:viewport", nameZh: "三维视口", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventor.cpp", desktopSymbol: "View3DInventor" },
{ id: "shell:python-console", nameZh: "Python 控制台", file: "web/src/shell/python-console.tsx", symbol: "PythonConsole", desktop: "src/Gui/PythonConsole.cpp", desktopSymbol: "PythonConsole" },
{ id: "shell:preferences", nameZh: "偏好设置对话框", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/Dialogs/DlgPreferencesImp.cpp", desktopSymbol: "DlgPreferencesImp" },
{ id: "shell:workbench-frame", nameZh: "工作台框架", file: "web/src/shell/workbench-frame.tsx", symbol: "WorkbenchFrame", desktop: "src/Gui/Workbench.cpp", desktopSymbol: "Workbench" },
{ id: "shell:document-tabs", nameZh: "文档标签栏", file: "web/src/project-shell.tsx", symbol: "App", desktop: "src/Gui/MainWindow.cpp", desktopSymbol: "tabbedDocuments" },
{ id: "shell:utility-menus", nameZh: "工具菜单(偏好/快捷键/停靠)", file: "web/src/shell/utility-menus.tsx", symbol: "UtilityMenus", desktop: "src/Gui/CommandStd.cpp", desktopSymbol: "Std_ViewDockMenu" },
];
const VIEWPORT_TOOLS = [
{ id: "viewport:navigation", nameZh: "导航样式切换", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/NavigationStyle.cpp", desktopSymbol: "NavigationStyle" },
{ id: "viewport:navigation-hints", nameZh: "导航提示与手势", file: "web/src/scene-navigation.ts", symbol: "SceneNavigation", desktop: "src/Gui/NavigationStyle.cpp", desktopSymbol: "NavigationStyle" },
{ id: "viewport:fit-all", nameZh: "适配全部", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventorViewer.cpp", desktopSymbol: "Std_ViewFitAll" },
{ id: "viewport:view-directions", nameZh: "标准视图方向", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventorViewer.cpp", desktopSymbol: "Std_ViewAxo" },
{ id: "viewport:selection", nameZh: "选择与拾取", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/Selection.cpp", desktopSymbol: "SelectionSingleton" },
{ id: "viewport:clipping", nameZh: "剖切面", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventor.cpp", desktopSymbol: "Std_ToggleClipPlane" },
{ id: "viewport:transform", nameZh: "变换手柄", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventor.cpp", desktopSymbol: "Std_TransformManip" },
{ id: "viewport:view-cube", nameZh: "视图立方/坐标轴", file: "web/src/scene-viewport.tsx", symbol: "SceneViewport", desktop: "src/Gui/View3DInventor.cpp", desktopSymbol: "navigation cube" },
];
const PREFERENCES_PAGES = [
{ id: "preferences:units", nameZh: "单位系统", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/PreferencePages/DlgSettingsGeneral.ui", desktopSymbol: "Unit system" },
{ id: "preferences:navigation", nameZh: "导航样式", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/PreferencePages/DlgSettingsNavigation.ui", desktopSymbol: "Navigation style" },
{ id: "preferences:theme", nameZh: "主题", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/PreferencePages/DlgSettingsUI.ui", desktopSymbol: "Theme" },
{ id: "preferences:grid", nameZh: "网格显示", file: "web/src/shell/preferences-dialog.tsx", symbol: "PreferencesDialog", desktop: "src/Gui/PreferencePages/DlgSettings3DView.ui", desktopSymbol: "Show grid" },
];
const DOCK_ZH = {
Std_DockOverlay: "停靠覆盖层",
Std_DockOverlayAll: "全部停靠覆盖",
Std_DockOverlayTransparentAll: "全部透明覆盖",
Std_DockOverlayToggle: "切换覆盖层",
Std_DockOverlayToggleTransparent: "切换透明覆盖",
Std_DockOverlayMouseTransparent: "鼠标穿透",
Std_DockOverlayToggleLeft: "左侧覆盖",
Std_DockOverlayToggleRight: "右侧覆盖",
Std_DockOverlayToggleTop: "顶部覆盖",
Std_DockOverlayToggleBottom: "底部覆盖",
Std_TreeViewMVC: "模型树(MVC)",
};
export function walkSource(root, { maxDepth = 6 } = {}) {
const out = [];
const walk = (dir, depth) => {
if (depth > maxDepth) return;
let entries = [];
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
for (const entry of entries) {
if (entry.name === "node_modules" || entry.name === "tests" || entry.name.startsWith(".")) continue;
const full = path.join(dir, entry.name);
if (entry.isDirectory()) walk(full, depth + 1);
else if (SOURCE_EXT.test(entry.name)) out.push(full);
}
};
walk(root, 0);
return out.sort();
}
function exportsOf(text) {
const names = [];
for (const match of text.matchAll(/export\s+(?:async\s+)?function\s+([A-Za-z0-9_]+)/g)) names.push(match[1]);
for (const match of text.matchAll(/export\s+const\s+([A-Za-z0-9_]+)/g)) names.push(match[1]);
for (const match of text.matchAll(/export\s+class\s+([A-Za-z0-9_]+)/g)) names.push(match[1]);
return [...new Set(names)];
}
function existsFile(file) {
try { return fs.statSync(file).isFile(); } catch { return false; }
}
function buildDesktopIndex(desktopRoot) {
const index = [];
const addDir = dir => {
let entries = [];
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
for (const entry of entries) {
if (!entry.isFile()) continue;
if (!/^(Task|Dlg|Preference)/i.test(entry.name)) continue;
if (!/\.(cpp|h|ui)$/i.test(entry.name)) continue;
index.push({ file: path.relative(desktopRoot, path.join(dir, entry.name)), base: entry.name });
}
};
addDir(path.join(desktopRoot, "src/Gui/Dialogs"));
addDir(path.join(desktopRoot, "src/Gui/PreferencePages"));
let mods = [];
try { mods = fs.readdirSync(path.join(desktopRoot, "src/Mod"), { withFileTypes: true }); } catch { mods = []; }
for (const mod of mods) {
if (!mod.isDirectory()) continue;
addDir(path.join(desktopRoot, "src/Mod", mod.name, "Gui"));
}
return index.sort((a, b) => a.file.localeCompare(b.file));
}
function matchDesktop(desktopIndex, moduleId, stem) {
const tokens = stem.split("-").filter(token => token && token !== "task"
&& token !== moduleId.toLowerCase() && token !== "parameters");
if (!tokens.length) return null;
const moduleDir = `/src/Mod/${moduleId}/Gui/`;
const candidates = desktopIndex.filter(item => tokens.every(token =>
item.base.toLowerCase().replace(/[^a-z0-9]/g, "").includes(token.replace(/[^a-z0-9]/g, ""))));
if (!candidates.length) return null;
const preferred = candidates.find(item => item.file.includes(moduleDir)) ?? candidates[0];
return { file: `freecad-source/${preferred.file}`, symbol: preferred.base.replace(/\.(cpp|h|ui)$/i, "") };
}
function zhTerm(stem) {
const parts = stem.split("-").filter(Boolean);
for (const part of parts) {
if (TERMS[part]) return TERMS[part];
}
return null;
}
function labelZh(map, label) {
const clean = String(label ?? "").replace(/&/g, "").trim();
return map[clean] ?? clean;
}
export function scanSurfaces({ repoRoot, desktopRoot, inventory, manualFeatures, webSrcRoot, stable = false }) {
const surfaces = [];
const push = surface => {
surfaces.push({
workbench: surface.workbench ?? null,
owner: surface.file ? { file: surface.file, symbol: surface.symbol ?? null, mountPoint: surface.mountPoint ?? null } : null,
desktopRef: surface.desktop ? { file: `freecad-source/${surface.desktop.replace(/^freecad-source\//, "")}`, symbol: surface.desktopSymbol ?? null } : null,
status: surface.status ?? "implemented",
screenshotId: surface.screenshotId ?? null,
manualAnchor: surface.manualAnchor ?? null,
id: surface.id,
category: surface.category,
moduleId: surface.moduleId ?? null,
nameZh: surface.nameZh,
note: surface.note ?? null,
});
};
const sourceFiles = walkSource(webSrcRoot).filter(file => !/-test\.tsx?$/i.test(file));
const texts = new Map();
for (const file of sourceFiles) {
try { texts.set(file, fs.readFileSync(file, "utf8")); } catch { /* skip unreadable */ }
}
const refCount = (symbol, selfFile, stem) => {
if (!symbol) return 0;
let count = 0;
for (const [file, text] of texts) {
if (file === selfFile) continue;
if (text.includes(symbol) || (stem && text.includes(stem))) count += 1;
}
return count;
};
// 1. Shell regions and status bar.
for (const item of SHELL_SURFACES) {
const file = path.join(repoRoot, item.file);
const present = existsFile(file);
const desktop = item.desktop && existsFile(path.join(desktopRoot, item.desktop)) ? item.desktop : null;
push({
id: item.id,
category: item.id === "shell:statusbar" ? "statusbar" : "shell-region",
moduleId: null,
nameZh: item.nameZh,
file: item.file,
symbol: item.symbol,
mountPoint: present ? (texts.get(file)?.includes(`<${item.symbol}`) ? "rendered" : "exported") : null,
desktop,
desktopSymbol: item.desktopSymbol,
status: present ? "implemented" : "gap",
note: present ? null : `缺少 React owner:${item.file}`,
});
}
// 2. Docks (dock overlay commands + manifest docks).
const dockCommandsPath = path.join(webSrcRoot, "dock-overlay-commands.json");
let dockCommands = {};
try { dockCommands = JSON.parse(fs.readFileSync(dockCommandsPath, "utf8")); } catch { dockCommands = {}; }
for (const key of Object.keys(dockCommands).sort()) {
push({
id: `dock:${key}`,
category: "dock",
moduleId: null,
nameZh: DOCK_ZH[key] ?? key,
file: "web/src/dock-overlay-host.tsx",
symbol: "DockOverlayHost",
mountPoint: "rendered",
desktop: "src/Gui/DockWindowManager.cpp",
desktopSymbol: key,
status: "implemented",
note: null,
});
}
for (const chapter of inventory.chapters) {
for (const dock of (chapter.manifest?.docks ?? [])) {
push({
id: `dock:${chapter.id}:${dock}`,
category: "dock",
moduleId: chapter.id,
nameZh: DOCK_ZH[dock] ?? dock,
file: "web/src/dock-overlay-host.tsx",
symbol: "DockOverlayHost",
mountPoint: "rendered",
desktop: chapter.manifest?.source?.replace(/^freecad-source\//, "") ?? null,
desktopSymbol: dock,
status: CHAPTER_STATUS[chapter.status] ?? "partial",
note: null,
});
}
}
// 3. Task panels from the workbench inventory.
const desktopIndex = buildDesktopIndex(desktopRoot);
for (const chapter of inventory.chapters) {
for (const panel of (chapter.taskPanels ?? [])) {
const stem = panel.file.replace(/\.tsx?$/, "");
let file = path.join(webSrcRoot, panel.file);
if (!existsFile(file)) {
const found = sourceFiles.find(candidate => path.basename(candidate) === panel.file);
if (found) file = found;
}
const present = existsFile(file);
const text = present ? texts.get(file) ?? "" : "";
const symbol = exportsOf(text).find(name => /Task$/.test(name)) ?? exportsOf(text)[0] ?? null;
const refs = present ? refCount(symbol, file, stem) : 0;
const matched = matchDesktop(desktopIndex, chapter.id, stem);
const title = (panel.titles ?? []).find(value => CJK.test(value)) ?? (panel.titles ?? [])[0] ?? stem;
const term = zhTerm(stem);
push({
id: `task:${chapter.id}:${stem}`,
category: "task-panel",
moduleId: chapter.id,
nameZh: term ? `${MODULE_ZH[chapter.id] ?? chapter.id} · ${term}` : `${MODULE_ZH[chapter.id] ?? chapter.id} · ${title}`,
file: present ? path.relative(repoRoot, file) : panel.file,
symbol,
mountPoint: refs > 0 ? "referenced" : present ? "isolated" : null,
desktop: matched?.file ?? chapter.manifest?.source ?? null,
desktopSymbol: matched?.symbol ?? null,
status: !present ? "gap" : refs > 0 ? "implemented" : "partial",
note: !present ? `缺少任务面板文件:${panel.file}` : refs === 0 ? "组件未被 shell 或工作台面板引用" : null,
});
}
}
// 4. Modal dialogs discovered from the shell.
const dialogFiles = sourceFiles.filter(file =>
/(dialog|preferences|palette|shortcut|context-menu)[^/]*\.tsx$/i.test(file)
&& !/\/tests?\//.test(file)
&& !/shell-preview/.test(file)
&& !/-test\.tsx?$/i.test(file));
for (const file of dialogFiles) {
const rel = path.relative(repoRoot, file);
if (surfaces.some(item => item.owner?.file === rel)) continue;
const text = texts.get(file) ?? "";
const symbols = exportsOf(text);
const symbol = symbols[0] ?? null;
const stem = path.basename(file).replace(/\.tsx$/, "");
push({
id: `dialog:${stem}`,
category: /preferences/i.test(stem) ? "preferences-page" : "modal-dialog",
moduleId: null,
nameZh: /preferences/i.test(stem) ? "偏好设置" : stem,
file: rel,
symbol,
mountPoint: refCount(symbol, file, stem) > 0 ? "referenced" : "isolated",
desktop: /preferences/i.test(stem) ? "src/Gui/Dialogs/DlgPreferencesImp.cpp" : null,
desktopSymbol: /preferences/i.test(stem) ? "DlgPreferencesImp" : null,
status: symbol ? (refCount(symbol, file, stem) > 0 ? "implemented" : "partial") : "gap",
note: null,
});
}
// 5. Preference pages (the web preferences dialog exposes four groups).
for (const item of PREFERENCES_PAGES) {
push({
id: item.id,
category: "preferences-page",
moduleId: null,
nameZh: item.nameZh,
file: item.file,
symbol: item.symbol,
mountPoint: "rendered",
desktop: existsFile(path.join(desktopRoot, item.desktop)) ? item.desktop : null,
desktopSymbol: item.desktopSymbol,
status: "implemented",
note: null,
});
}
// 6. Viewport tools.
for (const item of VIEWPORT_TOOLS) {
const present = existsFile(path.join(repoRoot, item.file));
push({
id: item.id,
category: "viewport-tool",
moduleId: null,
nameZh: item.nameZh,
file: item.file,
symbol: item.symbol,
mountPoint: present ? "referenced" : null,
desktop: existsFile(path.join(desktopRoot, item.desktop)) ? item.desktop : null,
desktopSymbol: item.desktopSymbol,
status: present ? "implemented" : "gap",
note: present ? null : `缺少视口 owner:${item.file}`,
});
}
// 7. Workbench menus and toolbars from the inventory.
for (const chapter of inventory.chapters) {
const status = CHAPTER_STATUS[chapter.status] ?? "partial";
const moduleZh = MODULE_ZH[chapter.id] ?? chapter.id;
for (const menu of (chapter.menus ?? [])) {
const label = labelZh(MENU_ZH, menu.label);
push({
id: `menu:${chapter.id}:${slug(menu.label)}`,
category: "menu",
moduleId: chapter.id,
nameZh: `${moduleZh} · ${label} 菜单`,
file: "web/src/shell/workbench-menu.tsx",
symbol: "ParityWorkbenchMenu",
mountPoint: "rendered",
desktop: chapter.manifest?.source ?? null,
desktopSymbol: `setupMenuBar/${menu.label}`,
status,
note: status === "partial" ? "该工作台由 Python InitGui 注册,Web 端以静态菜单层级呈现:命令可执行,二级分组被压平。" : null,
});
}
for (const toolbar of (chapter.toolbars ?? [])) {
const label = labelZh(TOOLBAR_ZH, toolbar.name);
push({
id: `toolbar:${chapter.id}:${slug(toolbar.name)}`,
category: "toolbar",
moduleId: chapter.id,
nameZh: `${moduleZh} · ${label} 工具栏`,
file: "web/src/shell/workbench-toolbars.tsx",
symbol: "ParityWorkbenchToolbars",
mountPoint: "rendered",
desktop: chapter.manifest?.source ?? null,
desktopSymbol: `setupToolBars/${toolbar.name}`,
status,
note: status === "partial" ? "该工作台由 Python InitGui 注册,Web 端以静态工具栏呈现:命令可执行,分组顺序以清单为准。" : null,
});
}
}
// 8. Manual coverage evidence.
const chapterAnchors = new Map();
for (const chapter of manualFeatures?.chapters ?? []) {
chapterAnchors.set(chapter.id, chapter.id);
}
for (const surface of surfaces) {
const moduleId = surface.moduleId ?? surface.workbench;
if (moduleId && chapterAnchors.has(moduleId)) surface.manualAnchor = chapterAnchors.get(moduleId);
else if (!moduleId) surface.manualAnchor = "ch16";
}
// Deterministic ordering and counts.
surfaces.sort((a, b) => a.category.localeCompare(b.category) || a.id.localeCompare(b.id));
const byCategory = {};
const byStatus = {};
const byModule = {};
for (const surface of surfaces) {
byCategory[surface.category] = (byCategory[surface.category] ?? 0) + 1;
byStatus[surface.status] = (byStatus[surface.status] ?? 0) + 1;
if (surface.moduleId) byModule[surface.moduleId] = (byModule[surface.moduleId] ?? 0) + 1;
}
const gaps = surfaces.filter(surface => surface.status === "gap").map(surface => surface.id);
return {
schema: "freecad-web/ui-surface-inventory/v1",
generatedAt: stable ? "1970-01-01T00:00:00.000Z" : new Date().toISOString(),
sources: {
inventory: "tools/fcweb/out/ui-inventory.json",
webSrc: "web/src",
desktop: "freecad-source",
manualFeatures: "web/manual/data/manual-features.json",
},
counts: { total: surfaces.length, byCategory, byStatus, byModule, gaps: gaps.length },
surfaces,
gaps,
};
}
function slug(text) {
return String(text ?? "").toLowerCase().replace(/[^a-z0-9一-龥]+/g, "-").replace(/^-+|-+$/g, "");
}
export { CHAPTER_STATUS };