- Web engine CMake: apply WITH_WEB_USD_PYTHON to blender_web_engine_core, embed /usd resources, link pxr Python bindings after the core archive and whole-archive the monolithic OpenUSD archive. Fixes the wm.usd_export abort and restores Alembic/USD embedded export. - ?ui=web menus: fix inverted localOnly gating and route queueLocalDesktopOperator and nativeAdd through the desktop operator channel with a VIEW_3D context; non-mesh edit-mode selection uses the native VIEW3D_SELECT bridge. - Refresh WebEngine wasm/js artifacts, manual/course pages and the complete course video asset. - Record focused Chromium probes for Add/F3/parameters/modifier/UV/curve/deform, scene operations, OPFS save/reopen and worker restart. Evidence is NOT_CLAIMED. Co-Authored-By: Claude Code <noreply@anthropic.com>
75 lines
4.5 KiB
JavaScript
75 lines
4.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Validate the generated 24-module complete beginner course and its media.
|
|
* Usage: node tools/web/course/check-complete-course.mjs
|
|
*/
|
|
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
const DIR = path.join(REPO, "web/app/public/tutorial/complete");
|
|
const INDEX = path.join(DIR, "index.html");
|
|
const SOURCE = path.join(REPO, "tools/web/course/complete-course.json");
|
|
const errors = [];
|
|
|
|
const course = fs.existsSync(SOURCE) ? JSON.parse(fs.readFileSync(SOURCE, "utf8")) : { modules: [], videos: [] };
|
|
const expectedModules = course.modules.length;
|
|
const html = fs.existsSync(INDEX) ? fs.readFileSync(INDEX, "utf8") : "";
|
|
if (!html) errors.push("missing index.html");
|
|
const modules = [...html.matchAll(/class="course-module"/g)].length;
|
|
if (modules !== expectedModules) errors.push(`expected ${expectedModules} modules, found ${modules}`);
|
|
if (expectedModules < 20) errors.push(`complete course has only ${expectedModules} modules`);
|
|
if (!html.includes("OPFS")) errors.push("course does not mention OPFS");
|
|
if (/<script\b/i.test(html)) errors.push("course page has inline script");
|
|
if (/<style\b/i.test(html)) errors.push("course page has inline style");
|
|
if (/https?:\/\//i.test(html)) errors.push("course page references a remote URL");
|
|
if (!/<video\b/i.test(html)) errors.push("course page has no video");
|
|
|
|
const checkAsset = (src) => {
|
|
if (!src || /^https?:/i.test(src)) return;
|
|
const file = src.startsWith("/") ? path.join(REPO, "web/app/public", src.slice(1)) : path.join(DIR, src);
|
|
if (!fs.existsSync(file)) errors.push(`missing asset ${src}`);
|
|
};
|
|
for (const match of html.matchAll(/<img[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
|
for (const match of html.matchAll(/<video[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
|
for (const match of html.matchAll(/<track[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
|
|
|
const media = [];
|
|
for (const match of html.matchAll(/<video[^>]+src="([^"]+)"/g)) {
|
|
const file = match[1].startsWith("/") ? path.join(REPO, "web/app/public", match[1].slice(1)) : path.join(DIR, match[1]);
|
|
if (!fs.existsSync(file)) continue;
|
|
const probe = JSON.parse(execFileSync("/usr/bin/ffprobe", ["-v", "error", "-show_entries",
|
|
"format=duration,size:stream=codec_type,codec_name,width,height", "-of", "json", file], { encoding: "utf8" }));
|
|
const video = probe.streams.find((stream) => stream.codec_type === "video") ?? {};
|
|
const audio = probe.streams.find((stream) => stream.codec_type === "audio") ?? {};
|
|
media.push({ src: match[1], duration: Number(probe.format?.duration ?? 0), bytes: Number(probe.format?.size ?? 0), width: video.width, height: video.height, videoCodec: video.codec_name, audioCodec: audio.codec_name });
|
|
if (video.codec_name !== "h264" || audio.codec_name !== "aac") errors.push(`${match[1]} is not H.264/AAC`);
|
|
if (video.width !== 1280 || video.height !== 720) errors.push(`${match[1]} is not 1280x720`);
|
|
if (Number(probe.format?.duration ?? 0) < 1200 || Number(probe.format?.duration ?? 0) > 90 * 60) errors.push(`${match[1]} duration outside 20-90 minutes`);
|
|
}
|
|
|
|
for (const module of course.modules) {
|
|
if (!html.includes(`id="${module.id}"`)) errors.push(`module ${module.id} missing from HTML`);
|
|
const article = html.split(`id="${module.id}"`)[1]?.split("</article>")[0] ?? "";
|
|
const images = [...article.matchAll(/<img\b/g)].length;
|
|
if (images < module.steps.length) errors.push(`module ${module.id} has ${images} images for ${module.steps.length} steps`);
|
|
if (!article.includes("course-objectives")) errors.push(`module ${module.id} has no objectives`);
|
|
if (module.checks?.length && !article.includes("完成检查") && !article.includes("checks")) { /* checks rendered as part of steps in this template */ }
|
|
}
|
|
|
|
const vtt = course.videos?.[0]?.vtt;
|
|
if (vtt) {
|
|
const file = vtt.startsWith("/") ? path.join(REPO, "web/app/public", vtt.slice(1)) : path.join(DIR, vtt);
|
|
if (!fs.existsSync(file)) errors.push(`missing narration VTT ${vtt}`);
|
|
else {
|
|
const cues = (fs.readFileSync(file, "utf8").match(/-->/g) ?? []).length;
|
|
if (cues < expectedModules) errors.push(`VTT has ${cues} cues for ${expectedModules} modules`);
|
|
}
|
|
}
|
|
|
|
const result = { schemaVersion: 1, status: errors.length === 0 ? "PASS" : "FAIL", modules, videos: media.length, totalMediaBytes: media.reduce((total, item) => total + (item.bytes ?? 0), 0), media, errors };
|
|
console.log(JSON.stringify(result, null, 2));
|
|
if (errors.length > 0) process.exitCode = 1;
|