收敛 INI 面板状态 API namespace
This commit is contained in:
67
text11.txt
67
text11.txt
@@ -761,3 +761,70 @@ host_wasm_opfs_browser_smokes=ok
|
||||
INI panel API namespace,例如 `window.linuxCncIniPanelApi.getMachineSessionStateReport()`
|
||||
和 `getMachineSessionStateReportExport()`,为后续控制网页界面调用 save/restore/load/run
|
||||
工作流预留统一入口;仍先不做复杂按钮,不解析 CNC 语义,不扩大 LinuxCNC runtime 边界。
|
||||
|
||||
七、2026-06-14 继续执行记录:INI panel API namespace
|
||||
|
||||
本轮继续推进“控制网页界面/API surface”方向,把上轮的 report/export getter 收敛到
|
||||
明确的 INI panel API namespace,为后续统一暴露 save、restore、load、run 工作流入口做准备。
|
||||
|
||||
完成内容:
|
||||
|
||||
- `wasm-port/runtime/ui/ini-panel/app.js` 新增
|
||||
`window.linuxCncIniPanelApi`;
|
||||
- namespace 当前暴露:
|
||||
- `getMachineSessionStateReport()`;
|
||||
- `getMachineSessionStateReportExport()`;
|
||||
- 保留旧的 `window.getMachineSessionStateReport()` 与
|
||||
`window.getMachineSessionStateReportExport()` 作为兼容 shim;
|
||||
- `wasm-port/tests/browser/ini_panel_smoke.html` 改为优先通过
|
||||
`window.linuxCncIniPanelApi` 读取 report/export;
|
||||
- browser smoke 继续验证旧 global getter 与 namespace getter 输出一致;
|
||||
- `wasm-port/docs/ui-panel-state-summary.md` 明确上层 UI/API 应读取
|
||||
`window.linuxCncIniPanelApi.getMachineSessionStateReport()`,不要抓 DOM 或直接依赖
|
||||
`window.linuxCncIniPanelMachineSessionState`;
|
||||
- 未新增复杂 UI 按钮;
|
||||
- 未改变 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
|
||||
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_ini_panel_browser.sh
|
||||
wasm-port/tests/ui/node/verify_ui_node_smokes.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
|
||||
browser_ini_opfs_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
|
||||
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
|
||||
```
|
||||
|
||||
下一步建议:
|
||||
|
||||
继续按“实质性能力优先”推进。下一批建议在 `window.linuxCncIniPanelApi` 下暴露第一个
|
||||
只读/低风险 workflow-facing helper,例如 `getMachineSessionState()` 或
|
||||
`getMachineSessionWorkflowStatus()`,把当前 last action、error、readiness、session/run
|
||||
摘要合并为控制网页界面可直接轮询的状态对象;仍不新增按钮、不解析 G-code、不把 CNC
|
||||
语义搬进 JS。
|
||||
|
||||
@@ -12,8 +12,11 @@ state so browser tests or future UI consumers can compare panel state without
|
||||
reading ad hoc DOM text.
|
||||
|
||||
Upper-level UI/API consumers should read `createMachineSessionStateReport(...)`
|
||||
or `window.getMachineSessionStateReport()` rather than scraping DOM nodes or
|
||||
depending on `window.linuxCncIniPanelMachineSessionState` directly.
|
||||
or `window.linuxCncIniPanelApi.getMachineSessionStateReport()` rather than
|
||||
scraping DOM nodes or depending on `window.linuxCncIniPanelMachineSessionState`
|
||||
directly. The legacy `window.getMachineSessionStateReport()` and
|
||||
`window.getMachineSessionStateReportExport()` globals remain as compatibility
|
||||
shims.
|
||||
|
||||
## `createIniPanelStateSummary(input)`
|
||||
|
||||
|
||||
@@ -174,6 +174,10 @@ function updatePanelMachineSessionState(patch = {}) {
|
||||
return panelMachineSessionState;
|
||||
}
|
||||
|
||||
window.linuxCncIniPanelApi = {
|
||||
getMachineSessionStateReport,
|
||||
getMachineSessionStateReportExport,
|
||||
};
|
||||
window.getMachineSessionStateReport = getMachineSessionStateReport;
|
||||
window.getMachineSessionStateReportExport = getMachineSessionStateReportExport;
|
||||
window.linuxCncIniPanelMachineSessionState = panelMachineSessionState;
|
||||
|
||||
@@ -367,6 +367,10 @@ TOOL_TABLE = browser-tool.tbl
|
||||
() => uiDocument.getElementById("opfs-badge")?.textContent.includes("ready"),
|
||||
"INI panel OPFS readiness",
|
||||
);
|
||||
const uiApi = uiDocument.defaultView.linuxCncIniPanelApi;
|
||||
if (!uiApi?.getMachineSessionStateReport || !uiApi?.getMachineSessionStateReportExport) {
|
||||
throw new Error("INI panel API namespace did not expose state report getters");
|
||||
}
|
||||
|
||||
uiDocument.getElementById("ini-editor").value = iniText;
|
||||
uiDocument.getElementById("query").click();
|
||||
@@ -493,7 +497,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
) {
|
||||
throw new Error(`UI saved snapshot log missing metadata summary: ${savedSnapshotLog}`);
|
||||
}
|
||||
const savedMachineSessionStateReport = uiDocument.defaultView.getMachineSessionStateReport();
|
||||
const savedMachineSessionStateReport = uiApi.getMachineSessionStateReport();
|
||||
assertEqual(
|
||||
savedMachineSessionStateReport.session.snapshotLabel,
|
||||
"ui-machine-session/ui-machine-session.json",
|
||||
@@ -588,7 +592,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
) {
|
||||
throw new Error(`UI restore/load session log missing OPFS default file mapping: ${uiLog}`);
|
||||
}
|
||||
const restoredLoadedMachineSessionStateReport = uiDocument.defaultView.getMachineSessionStateReport();
|
||||
const restoredLoadedMachineSessionStateReport = uiApi.getMachineSessionStateReport();
|
||||
assertEqual(
|
||||
restoredLoadedMachineSessionStateReport.session.snapshotLabel,
|
||||
"ui-machine-session/ui-machine-session.json",
|
||||
@@ -697,7 +701,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
2,
|
||||
"UI snapshot run summary motion snapshot count",
|
||||
);
|
||||
const machineSessionStateReport = uiDocument.defaultView.getMachineSessionStateReport();
|
||||
const machineSessionStateReport = uiApi.getMachineSessionStateReport();
|
||||
assertEqual(
|
||||
machineSessionStateReport.status.lastAction,
|
||||
"run-gcode",
|
||||
@@ -743,7 +747,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
2,
|
||||
"UI machine session state report motion snapshot count",
|
||||
);
|
||||
const machineSessionStateReportExport = uiDocument.defaultView.getMachineSessionStateReportExport();
|
||||
const machineSessionStateReportExport = uiApi.getMachineSessionStateReportExport();
|
||||
assertEqual(
|
||||
machineSessionStateReportExport.filename,
|
||||
"machine-session-state-report.json",
|
||||
@@ -769,6 +773,16 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"snapshot",
|
||||
"UI machine session state report export program source",
|
||||
);
|
||||
assertEqual(
|
||||
uiDocument.defaultView.getMachineSessionStateReport().status.lastAction,
|
||||
machineSessionStateReport.status.lastAction,
|
||||
"UI legacy machine session state report getter matches API namespace",
|
||||
);
|
||||
assertEqual(
|
||||
uiDocument.defaultView.getMachineSessionStateReportExport().text,
|
||||
machineSessionStateReportExport.text,
|
||||
"UI legacy machine session state report export getter matches API namespace",
|
||||
);
|
||||
if (
|
||||
!runLog.includes("canon_event=STRAIGHT_TRAVERSE") ||
|
||||
!runLog.includes("canon_event=STRAIGHT_FEED")
|
||||
|
||||
@@ -330,4 +330,15 @@ assert.deepEqual(
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
{
|
||||
getMachineSessionStateReport: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateReport,
|
||||
getMachineSessionStateReportExport: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateReportExport,
|
||||
},
|
||||
{
|
||||
getMachineSessionStateReport: "undefined",
|
||||
getMachineSessionStateReportExport: "undefined",
|
||||
},
|
||||
);
|
||||
|
||||
console.log("ini_panel_state_summary_node_smoke=ok");
|
||||
|
||||
Reference in New Issue
Block a user