推进 INI 面板状态 report JSON 导出 helper
This commit is contained in:
67
text11.txt
67
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 边界。
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user