Files
FreeCADWasmDev/tools/fcweb/ui-surface-inventory.mjs
wangdequan 300c8efb01 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>
2026-11-23 01:30:31 +08:00

63 lines
2.7 KiB
JavaScript

#!/usr/bin/env node
// Builds the authoritative inventory of Web FreeCAD UI surfaces: every shell
// region, dock, task panel, dialog, preference page, menu, toolbar, status bar
// item and viewport tool, paired with its React owner and desktop source.
//
// node tools/fcweb/ui-surface-inventory.mjs
// node tools/fcweb/ui-surface-inventory.mjs --stable # reproducible bytes
// node tools/fcweb/ui-surface-inventory.mjs --check # compare, exit 1 on drift
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { scanSurfaces } from "./ui-surface-scan.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(here, "../..");
const desktopRoot = path.join(repoRoot, "freecad-source");
const webSrcRoot = path.join(repoRoot, "web", "src");
const args = process.argv.slice(2);
const argValue = (name, fallback) => {
const index = args.indexOf(name);
return index >= 0 && args[index + 1] ? args[index + 1] : fallback;
};
const inventoryPath = path.resolve(argValue("--inventory", path.join(here, "out", "ui-inventory.json")));
const outPath = path.resolve(argValue("--out", path.join(here, "out", "ui-surface-inventory.json")));
const stable = args.includes("--stable") || args.includes("--check");
const fail = (message, code = 2) => {
console.error(`[ui-surface-inventory] ${message}`);
process.exit(code);
};
if (!fs.existsSync(inventoryPath)) fail(`missing inventory: ${inventoryPath} (run ui-inventory.mjs first)`);
const inventory = JSON.parse(fs.readFileSync(inventoryPath, "utf8"));
const manualFeaturesPath = path.join(repoRoot, "web", "manual", "data", "manual-features.json");
const manualFeatures = fs.existsSync(manualFeaturesPath)
? JSON.parse(fs.readFileSync(manualFeaturesPath, "utf8"))
: null;
const result = scanSurfaces({ repoRoot, desktopRoot, inventory, manualFeatures, webSrcRoot, stable });
if (args.includes("--check")) {
if (!fs.existsSync(outPath)) fail(`--check: missing ${outPath}`, 1);
const previous = JSON.parse(fs.readFileSync(outPath, "utf8"));
const strip = value => JSON.stringify({ ...value, generatedAt: "__stable__" });
if (strip(previous) !== strip(result)) fail("--check: surface inventory is stale; rebuild without --check", 1);
console.log(JSON.stringify({ ok: true, checked: outPath, total: result.counts.total, gaps: result.counts.gaps }));
process.exit(0);
}
fs.mkdirSync(path.dirname(outPath), { recursive: true });
fs.writeFileSync(outPath, `${JSON.stringify(result, null, 2)}\n`);
console.log(JSON.stringify({
ok: true,
out: outPath,
total: result.counts.total,
byCategory: result.counts.byCategory,
byStatus: result.counts.byStatus,
gaps: result.counts.gaps,
}));