Files
workinf_Blender_Wasm/tools/web/complete/probe-add-params.mjs
mes123456 4eb08faf31 chore(web): checkpoint export fixes, operator routing and three-domain evidence
- 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>
2026-11-14 06:12:44 +08:00

102 lines
4.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Focused case: Add-menu operator channel parameters (location/rotation/scale/
* align) and failure boundaries, driven through the product worker.
*
* node tools/web/complete/probe-add-params.mjs --base-url http://127.0.0.1:5176
*/
import { ASSETS, parseArgs, launchBrowser, newPage, openApp, openFile, waitScene } from "../course/lib/lesson-recorder.mjs";
const args = parseArgs();
const BASE = args.baseUrl || "http://127.0.0.1:5176";
const browser = await launchBrowser(args.gpu);
const { context, page, consoleErrors } = await newPage(browser, {});
page.setDefaultTimeout(60_000);
await page.addInitScript(() => {
const NativeWorker = window.Worker;
window.__probeWorkers = [];
window.__probeMessages = [];
window.Worker = class extends NativeWorker {
constructor(...params) {
super(...params);
window.__probeWorkers.push(this);
this.addEventListener("message", (event) => window.__probeMessages.push(event.data));
}
};
});
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
const python = async (source) => {
const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`;
return await page.evaluate(({ requestId, source }) => new Promise((resolve) => {
const started = Date.now();
const read = () => {
const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result");
if (hit) { clearInterval(timer); resolve({ elapsedMs: Date.now() - started, response: hit }); return; }
if (Date.now() - started > 240000) { clearInterval(timer); resolve({ elapsedMs: Date.now() - started, timeout: true }); }
};
const timer = setInterval(read, 250);
for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeAdd.py", console: false } } });
}), { requestId, source }, { timeout: 300_000 });
};
try {
await openApp(page, BASE);
await openFile(page, ASSETS.studio);
await waitScene(page, { objects: 6, timeout: 240_000 });
log("--- stage 1: params ---");
log(JSON.stringify(await python(`
import json, web_blender
revision = web_blender.snapshot().get('revision')
web_blender.desktop_operator({
'operator': 'mesh.primitive_cube_add',
'properties': {'location': [1.0, 2.0, 3.0], 'rotation': [0.0, 0.0, 0.5], 'scale': [2.0, 2.0, 2.0], 'align': 'WORLD'},
'baseRevision': revision, 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True,
})
import bpy
obj = bpy.context.view_layer.objects.active
print('PROBE_PARAMS ' + json.dumps({'name': obj.name, 'location': list(obj.location), 'rotation': list(obj.rotation_euler), 'scale': list(obj.scale), 'dimensions': list(obj.dimensions), 'objects': len(bpy.data.objects)}))
`)));
log("--- stage 1b: enter_editmode ---");
log(JSON.stringify(await python(`
import json, web_blender
web_blender.desktop_operator({
'operator': 'mesh.primitive_cube_add',
'properties': {'enter_editmode': True},
'baseRevision': web_blender.snapshot().get('revision'), 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True,
})
import bpy
print('PROBE_EDITMODE ' + json.dumps({'mode': bpy.context.mode, 'active': bpy.context.view_layer.objects.active.name}))
bpy.ops.object.mode_set(mode='OBJECT')
`)));
log("--- stage 2: stale revision ---");
log(JSON.stringify(await python(`
import json, web_blender
revision = web_blender.snapshot().get('revision')
try:
web_blender.desktop_operator({'operator': 'mesh.primitive_cube_add', 'properties': {}, 'baseRevision': revision + 9, 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True})
print('PROBE_STALE NO_ERROR')
except Exception as error:
print('PROBE_STALE ' + repr(error))
`)));
log("--- stage 3: wrong area ---");
log(JSON.stringify(await python(`
import json, web_blender
try:
web_blender.desktop_operator({'operator': 'mesh.primitive_cube_add', 'properties': {}, 'baseRevision': web_blender.snapshot().get('revision'), 'areaType': 'INFO', 'mode': 'OBJECT', 'native': True})
print('PROBE_AREA NO_ERROR')
except Exception as error:
print('PROBE_AREA ' + repr(error))
`)));
} catch (error) {
log("probe error", error instanceof Error ? error.message : String(error));
} finally {
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
await context.close();
await browser.close();
}