Files
workinf_Blender_Wasm/tools/web/complete/probe-menu-operators.mjs
mes123456 d884f89f00
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
test(web): audit menu operator identifiers
All 329 nativeAdd/queueLocalDesktopOperator/invokeNativeOperator ids resolve
in the embedded WM registry.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-14 10:27:56 +08:00

54 lines
10 KiB
JavaScript

#!/usr/bin/env node
/** Audit: every menu operator identifier resolves in the embedded WM registry. */
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(90_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(hit); return; }
if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); }
};
const timer = setInterval(read, 250);
for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeOps.py", console: false } } });
}), { requestId, source }, { timeout: 300000 });
};
try {
await openApp(page, BASE);
await openFile(page, ASSETS.studio);
await waitScene(page, { objects: 6, timeout: 240_000 });
const result = await python(`import bpy, json
ops = ['curve.cyclic_toggle', 'curve.de_select_first', 'curve.de_select_last', 'curve.decimate', 'curve.delete', 'curve.dissolve_verts', 'curve.draw', 'curve.duplicate', 'curve.duplicate_move', 'curve.extrude', 'curve.extrude_move', 'curve.handle_type_set', 'curve.hide', 'curve.make_segment', 'curve.match_texture_space', 'curve.normals_make_consistent', 'curve.pen', 'curve.primitive_bezier_circle_add', 'curve.primitive_bezier_curve_add', 'curve.primitive_nurbs_circle_add', 'curve.primitive_nurbs_curve_add', 'curve.primitive_nurbs_path_add', 'curve.radius_set', 'curve.reveal', 'curve.select_all', 'curve.select_less', 'curve.select_linked', 'curve.select_linked_pick', 'curve.select_more', 'curve.select_next', 'curve.select_nth', 'curve.select_previous', 'curve.select_random', 'curve.select_row', 'curve.select_similar', 'curve.separate', 'curve.shade_flat', 'curve.shade_smooth', 'curve.shortest_path_pick', 'curve.smooth', 'curve.smooth_radius', 'curve.smooth_tilt', 'curve.smooth_weight', 'curve.spline_type_set', 'curve.spline_weight_set', 'curve.split', 'curve.subdivide', 'curve.switch_direction', 'curve.tilt_clear', 'curve.vertex_add', 'mesh.average_normals', 'mesh.beautify_fill', 'mesh.bevel', 'mesh.bisect', 'mesh.circularize', 'mesh.colors_reverse', 'mesh.colors_rotate', 'mesh.convex_hull', 'mesh.customdata_custom_splitnormals_add', 'mesh.customdata_custom_splitnormals_clear', 'mesh.customdata_face_sets_clear', 'mesh.customdata_mask_clear', 'mesh.customdata_skin_add', 'mesh.customdata_skin_clear', 'mesh.decimate', 'mesh.delete_edgeloop', 'mesh.delete_loose', 'mesh.dissolve_degenerate', 'mesh.dissolve_edges', 'mesh.dissolve_faces', 'mesh.dissolve_limited', 'mesh.dissolve_verts', 'mesh.dupli_extrude_cursor', 'mesh.duplicate', 'mesh.duplicate_move', 'mesh.edge_collapse', 'mesh.edge_face_add', 'mesh.edge_rotate', 'mesh.edge_split', 'mesh.edgering_select', 'mesh.edges_select_sharp', 'mesh.extrude_context', 'mesh.extrude_context_move', 'mesh.extrude_edges_indiv', 'mesh.extrude_edges_move', 'mesh.extrude_faces_indiv', 'mesh.extrude_faces_move', 'mesh.extrude_manifold', 'mesh.extrude_region', 'mesh.extrude_region_move', 'mesh.extrude_region_shrink_fatten', 'mesh.extrude_repeat', 'mesh.extrude_vertices_move', 'mesh.extrude_verts_indiv', 'mesh.face_make_planar', 'mesh.face_split_by_edges', 'mesh.faces_select_linked_flat', 'mesh.faces_shade_flat', 'mesh.faces_shade_smooth', 'mesh.fill_grid', 'mesh.fill_holes', 'mesh.flatten', 'mesh.flip_normals', 'mesh.flip_quad_tessellation', 'mesh.hide', 'mesh.inset', 'mesh.intersect', 'mesh.intersect_boolean', 'mesh.knife_project', 'mesh.knife_tool', 'mesh.loop_select', 'mesh.loop_to_region', 'mesh.loopcut_slide', 'mesh.mark_freestyle_edge', 'mesh.mark_freestyle_face', 'mesh.mark_seam', 'mesh.mark_sharp', 'mesh.merge_normals', 'mesh.offset_edge_loops', 'mesh.offset_edge_loops_slide', 'mesh.point_normals', 'mesh.poke', 'mesh.polybuild_delete_at_cursor', 'mesh.polybuild_dissolve_at_cursor', 'mesh.polybuild_extrude_at_cursor_move', 'mesh.polybuild_face_at_cursor', 'mesh.polybuild_face_at_cursor_move', 'mesh.polybuild_split_at_cursor', 'mesh.polybuild_split_at_cursor_move', 'mesh.polybuild_transform_at_cursor', 'mesh.polybuild_transform_at_cursor_move', 'mesh.primitive_circle_add', 'mesh.primitive_cone_add', 'mesh.primitive_cube_add', 'mesh.primitive_cube_add_gizmo', 'mesh.primitive_cylinder_add', 'mesh.primitive_grid_add', 'mesh.primitive_ico_sphere_add', 'mesh.primitive_monkey_add', 'mesh.primitive_plane_add', 'mesh.primitive_torus_add', 'mesh.primitive_uv_sphere_add', 'mesh.quads_convert_to_tris', 'mesh.region_to_loop', 'mesh.remove_doubles', 'mesh.reorder_vertices_spatial', 'mesh.reveal', 'mesh.rip', 'mesh.rip_edge', 'mesh.rip_edge_move', 'mesh.rip_move', 'mesh.screw', 'mesh.select_all', 'mesh.select_axis', 'mesh.select_boundary_loop_multi', 'mesh.select_by_pole_count', 'mesh.select_edge_loop_multi', 'mesh.select_edge_ring_multi', 'mesh.select_face_by_sides', 'mesh.select_interior_faces', 'mesh.select_less', 'mesh.select_linked', 'mesh.select_linked_pick', 'mesh.select_loose', 'mesh.select_mirror', 'mesh.select_more', 'mesh.select_non_manifold', 'mesh.select_nth', 'mesh.select_random', 'mesh.select_similar', 'mesh.select_similar_region', 'mesh.select_ungrouped', 'mesh.set_normals_from_faces', 'mesh.set_sharpness_by_angle', 'mesh.shape_propagate_to_all', 'mesh.shortest_path_pick', 'mesh.shortest_path_select', 'mesh.smooth_normals', 'mesh.solidify', 'mesh.sort_elements', 'mesh.space_edge_loops_evenly', 'mesh.spin', 'mesh.split', 'mesh.split_normals', 'mesh.subdivide_edgering', 'mesh.symmetrize', 'mesh.symmetry_snap', 'mesh.tris_convert_to_quads', 'mesh.unsubdivide', 'mesh.uv_texture_add', 'mesh.uv_texture_remove', 'mesh.uvs_reverse', 'mesh.uvs_rotate', 'mesh.vert_connect', 'mesh.vert_connect_concave', 'mesh.vert_connect_nonplanar', 'mesh.vert_connect_path', 'mesh.vertices_smooth', 'mesh.vertices_smooth_laplacian', 'mesh.wireframe', 'object.add', 'object.armature_add', 'object.camera_add', 'object.collection_instance_add', 'object.convert', 'object.curves_empty_hair_add', 'object.curves_random_add', 'object.data_instance_add', 'object.effector_add', 'object.empty_add', 'object.grease_pencil_add', 'object.lattice_add_to_selected', 'object.light_add', 'object.lightprobe_add', 'object.location_clear', 'object.make_links_data', 'object.make_links_scene', 'object.make_local', 'object.make_single_user', 'object.metaball_add', 'object.modifier_apply', 'object.origin_clear', 'object.origin_set', 'object.parent_clear', 'object.parent_set', 'object.pointcloud_random_add', 'object.rotation_clear', 'object.scale_clear', 'object.select_all', 'object.select_by_type', 'object.select_grouped', 'object.select_less', 'object.select_linked', 'object.select_mirror', 'object.select_more', 'object.select_same_collection', 'object.shade_auto_smooth', 'object.shade_flat', 'object.shade_smooth', 'object.shade_smooth_by_angle', 'object.shape_key_add', 'object.shape_key_apply_to_basis', 'object.shape_key_clear', 'object.shape_key_copy', 'object.shape_key_make_basis', 'object.shape_key_mirror', 'object.shape_key_move', 'object.shape_key_remove', 'object.speaker_add', 'object.text_add', 'object.transform_apply', 'object.vertex_group_add', 'object.vertex_group_assign', 'object.vertex_group_assign_new', 'object.vertex_group_clean', 'object.vertex_group_copy_to_selected', 'object.vertex_group_deselect', 'object.vertex_group_invert', 'object.vertex_group_limit_total', 'object.vertex_group_mirror', 'object.vertex_group_normalize_all', 'object.vertex_group_remove', 'object.vertex_group_remove_from', 'object.vertex_group_select', 'object.vertex_group_smooth', 'object.volume_add', 'scene.delete', 'scene.new', 'scene.view_layer_add', 'scene.view_layer_remove', 'screen.redo_last', 'screen.repeat_history', 'screen.repeat_last', 'surface.primitive_nurbs_surface_circle_add', 'surface.primitive_nurbs_surface_curve_add', 'surface.primitive_nurbs_surface_cylinder_add', 'surface.primitive_nurbs_surface_sphere_add', 'surface.primitive_nurbs_surface_surface_add', 'surface.primitive_nurbs_surface_torus_add', 'uv.align', 'uv.arrange_islands', 'uv.average_islands_scale', 'uv.copy', 'uv.copy_mirrored_faces', 'uv.cube_project', 'uv.cursor_set', 'uv.custom_region_set', 'uv.cylinder_project', 'uv.hide', 'uv.mark_seam', 'uv.minimize_stretch', 'uv.move_on_axis', 'uv.pack_islands', 'uv.paste', 'uv.pin', 'uv.project_from_view', 'uv.remove_doubles', 'uv.reset', 'uv.reveal', 'uv.rip', 'uv.rip_move', 'uv.seams_from_islands', 'uv.select_all', 'uv.select_box', 'uv.select_by_winding', 'uv.select_circle', 'uv.select_edge_ring', 'uv.select_lasso', 'uv.select_less', 'uv.select_linked', 'uv.select_linked_pick', 'uv.select_loop', 'uv.select_mode', 'uv.select_more', 'uv.select_overlap', 'uv.select_pinned', 'uv.select_similar', 'uv.select_split', 'uv.shortest_path_pick', 'uv.shortest_path_select', 'uv.smart_project', 'uv.snap_cursor', 'uv.snap_selected', 'uv.sphere_project', 'uv.stitch', 'uv.unwrap', 'uv.weld', 'wm.obj_export', 'wm.obj_import']
missing = []
for identifier in ops:
family, name = identifier.split('.', 1)
try:
getattr(getattr(bpy.ops, family), name).get_rna_type()
except BaseException as error:
missing.append([identifier, type(error).__name__, str(error)])
print('OPS_AUDIT ' + json.dumps({'total': len(ops), 'missing': missing}))
`);
log(result?.result?.json?.output ?? JSON.stringify(result));
} catch (error) {
log("probe error", error instanceof Error ? error.message : String(error));
} finally {
log("consoleErrors", JSON.stringify(consoleErrors.slice(-6)));
await context.close();
await browser.close();
}