From 25268404cb04e3c15e5020c85e8bdb88b30e0971 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 14 Jun 2026 22:18:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E8=BF=9B=20INI=20=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=20report=20JSON=20=E5=AF=BC=E5=87=BA=20helpe?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- text11.txt | 67 +++++++++++++++++++ wasm-port/docs/ui-panel-state-summary.md | 15 +++++ wasm-port/runtime/ui/ini-panel/app.js | 6 ++ .../ui/ini-panel/panel-state-summary.js | 10 +++ wasm-port/tests/browser/ini_panel_smoke.html | 26 +++++++ .../node/verify_ini_panel_state_summary.mjs | 62 +++++++++++++++++ 6 files changed, 186 insertions(+) diff --git a/text11.txt b/text11.txt index 132f1d7..bb3b0e3 100644 --- a/text11.txt +++ b/text11.txt @@ -694,3 +694,70 @@ host_wasm_opfs_browser_smokes=ok 补一个更靠近上层消费者的 report export helper 或 SDK-facing wrapper,例如把 report 序列化成稳定 JSON 文本/Blob 输入;仍只组合已有 host/runtime boundary facts,不解析 G-code、不推导 CNC 语义、不读取 DOM。 + +六、2026-06-14 继续执行记录:INI panel state report JSON export helper + +本轮继续推进“导出层”,在不新增复制/下载按钮的前提下,把 machine session state report +包装成上层 UI/API 可直接复用的稳定 JSON export payload。 + +完成内容: + +- `wasm-port/runtime/ui/ini-panel/panel-state-summary.js` 新增 + `createMachineSessionStateReportExport(state, options)`; +- export helper 返回: + - `filename`; + - `mediaType: "application/json"`; + - `report`; + - 带末尾换行的 pretty JSON `text`; +- `wasm-port/runtime/ui/ini-panel/app.js` 暴露 + `window.getMachineSessionStateReportExport()`; +- `wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs` 覆盖默认 filename、 + media type、report 和 JSON text; +- `wasm-port/tests/browser/ini_panel_smoke.html` 在真实 save、restore-load、run 后读取 + browser export getter,并验证 JSON text 可解析、run count 和 program source 稳定; +- `wasm-port/docs/ui-panel-state-summary.md` 增加 export helper 说明; +- 未新增 UI 按钮,未抓 DOM,未直接依赖临时 window state; +- 未改变 OPFS/session persistence、LinuxCNC interpreter、G-code 文本、canonical-event + 语义、tool、parameter、planner 或 LinuxCNC-owned runtime semantics。 + +验证已通过: + +```bash +git diff --check +wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh +wasm-port/tests/ui/node/verify_ui_node_smokes.sh +SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_ini_panel_browser.sh +wasm-port/tools/verify_vendor_sync.sh +wasm-port/tools/verify_no_standalone_cnc_semantics.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh +wasm-port/tests/host/verify_host_smokes.sh +``` + +关键输出: + +```text +ini_panel_state_summary_node_smoke=ok +ini_panel_run_summary_node_smoke=ok +ini_panel_run_workflow_node_smoke=ok +ini_panel_session_summary_node_smoke=ok +ini_panel_session_workflow_node_smoke=ok +ini_panel_machine_file_summary_node_smoke=ok +ui_node_smokes=ok +browser_ini_opfs_smoke=ok +vendor sync up to date +standalone CNC semantics guard complete +interp_wasm_node_smoke=ok +sim_configs_wasm_node_inventory_executed=28 +sim_configs_wasm_node_inventory_passed=28 +sim_configs_wasm_node_inventory_skipped=131 +sim_configs_wasm_node_inventory_unexpected_fail=0 +host_wasm_opfs_browser_smokes=ok +``` + +下一步建议: + +继续按“实质性能力优先”推进。下一批建议把 report/export getter 收敛成一个更明确的 +INI panel API namespace,例如 `window.linuxCncIniPanelApi.getMachineSessionStateReport()` +和 `getMachineSessionStateReportExport()`,为后续控制网页界面调用 save/restore/load/run +工作流预留统一入口;仍先不做复杂按钮,不解析 CNC 语义,不扩大 LinuxCNC runtime 边界。 diff --git a/wasm-port/docs/ui-panel-state-summary.md b/wasm-port/docs/ui-panel-state-summary.md index ff1c267..f9c5521 100644 --- a/wasm-port/docs/ui-panel-state-summary.md +++ b/wasm-port/docs/ui-panel-state-summary.md @@ -85,6 +85,21 @@ with four sections: The report is intended for upper-level UI consumers or export paths that want a stable summary shape without touching DOM nodes. +## `createMachineSessionStateReportExport(state, options)` + +This helper wraps the report in a stable export payload: + +```js +{ + filename: "machine-session-state-report.json", + mediaType: "application/json", + report: { ... }, + text: "{\n ...\n}\n" +} +``` + +It is a small export-layer helper for future copy/download/UI SDK wrappers. + ## Boundary Rules - Do not parse G-code text in this helper. diff --git a/wasm-port/runtime/ui/ini-panel/app.js b/wasm-port/runtime/ui/ini-panel/app.js index d555925..5d79595 100644 --- a/wasm-port/runtime/ui/ini-panel/app.js +++ b/wasm-port/runtime/ui/ini-panel/app.js @@ -48,6 +48,7 @@ import { import { createMachineSessionStateSnapshot, createMachineSessionStateReport, + createMachineSessionStateReportExport, } from "./panel-state-summary.js"; const SAMPLE_PATH = @@ -156,6 +157,10 @@ function getMachineSessionStateReport() { return createMachineSessionStateReport(window.linuxCncIniPanelMachineSessionState); } +function getMachineSessionStateReportExport() { + return createMachineSessionStateReportExport(window.linuxCncIniPanelMachineSessionState); +} + function updatePanelMachineSessionState(patch = {}) { panelMachineSessionState = createMachineSessionStateSnapshot({ ...panelMachineSessionState, @@ -170,6 +175,7 @@ function updatePanelMachineSessionState(patch = {}) { } window.getMachineSessionStateReport = getMachineSessionStateReport; +window.getMachineSessionStateReportExport = getMachineSessionStateReportExport; window.linuxCncIniPanelMachineSessionState = panelMachineSessionState; function setBadge(node, text, className = "badge") { diff --git a/wasm-port/runtime/ui/ini-panel/panel-state-summary.js b/wasm-port/runtime/ui/ini-panel/panel-state-summary.js index 75e35f9..048838e 100644 --- a/wasm-port/runtime/ui/ini-panel/panel-state-summary.js +++ b/wasm-port/runtime/ui/ini-panel/panel-state-summary.js @@ -108,3 +108,13 @@ export function createMachineSessionStateReport(state = {}) { }, }; } + +export function createMachineSessionStateReportExport(state = {}, options = {}) { + const report = createMachineSessionStateReport(state); + return { + filename: options.filename ?? "machine-session-state-report.json", + mediaType: "application/json", + report, + text: `${JSON.stringify(report, null, 2)}\n`, + }; +} diff --git a/wasm-port/tests/browser/ini_panel_smoke.html b/wasm-port/tests/browser/ini_panel_smoke.html index 02f4e01..6feb160 100644 --- a/wasm-port/tests/browser/ini_panel_smoke.html +++ b/wasm-port/tests/browser/ini_panel_smoke.html @@ -743,6 +743,32 @@ TOOL_TABLE = browser-tool.tbl 2, "UI machine session state report motion snapshot count", ); + const machineSessionStateReportExport = uiDocument.defaultView.getMachineSessionStateReportExport(); + assertEqual( + machineSessionStateReportExport.filename, + "machine-session-state-report.json", + "UI machine session state report export filename", + ); + assertEqual( + machineSessionStateReportExport.mediaType, + "application/json", + "UI machine session state report export media type", + ); + assertEqual( + machineSessionStateReportExport.text.endsWith("\n"), + true, + "UI machine session state report export newline", + ); + assertEqual( + JSON.parse(machineSessionStateReportExport.text).run.canonicalEventCount, + 2, + "UI machine session state report export canonical event count", + ); + assertEqual( + JSON.parse(machineSessionStateReportExport.text).program.source, + "snapshot", + "UI machine session state report export program source", + ); if ( !runLog.includes("canon_event=STRAIGHT_TRAVERSE") || !runLog.includes("canon_event=STRAIGHT_FEED") diff --git a/wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs b/wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs index f81dec3..c0fbed5 100644 --- a/wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs +++ b/wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs @@ -4,6 +4,7 @@ import { createIniPanelStateSummary, createMachineSessionStateSnapshot, createMachineSessionStateReport, + createMachineSessionStateReportExport, } from "../../../runtime/ui/ini-panel/panel-state-summary.js"; const summary = createIniPanelStateSummary({ @@ -268,4 +269,65 @@ assert.deepEqual( }, ); +const expectedExportReport = { + readiness: { + ini: "INI WASM: ready", + interp: "Interpreter WASM: ready", + opfs: "OPFS: ready", + }, + session: { + snapshotLabel: "ui-machine-session/ui-machine-session.json", + workflow: null, + ini: "/work/session-machine.ini", + parameters: null, + toolTable: null, + gcode: null, + }, + loaded: { + iniWasmPath: "/work/session-machine.ini", + parameterWasmPath: null, + toolTableWasmPath: null, + }, + program: { + source: null, + opfsPath: null, + wasmPath: null, + }, + run: { + status: null, + canonicalEventCount: 0, + motionSnapshotCount: 0, + iniWasmPath: null, + }, + status: { + lastAction: "save-session-snapshot", + error: null, + fiveaxisRemap: null, + }, +}; + +assert.deepEqual( + createMachineSessionStateReportExport({ + badges: { + ini: "INI WASM: ready", + interp: "Interpreter WASM: ready", + opfs: "OPFS: ready", + }, + fields: { + sessionSnapshot: "ui-machine-session/ui-machine-session.json", + sessionIni: "/work/session-machine.ini", + }, + sessionLoad: { + iniWasmPath: "/work/session-machine.ini", + }, + lastAction: "save-session-snapshot", + }), + { + filename: "machine-session-state-report.json", + mediaType: "application/json", + report: expectedExportReport, + text: `${JSON.stringify(expectedExportReport, null, 2)}\n`, + }, +); + console.log("ini_panel_state_summary_node_smoke=ok");