推进 INI 面板 launch API manifest

This commit is contained in:
2026-06-15 06:25:47 +08:00
parent 6ba8e43850
commit 7d906f1809
8 changed files with 150 additions and 1 deletions

View File

@@ -1065,3 +1065,80 @@ host_wasm_opfs_browser_smokes=ok
继续推进 SDK/API surface。下一批建议把 `linuxCncIniPanelLaunchApi` 也整理为轻量 launch API 继续推进 SDK/API surface。下一批建议把 `linuxCncIniPanelLaunchApi` 也整理为轻量 launch API
manifest明确 `getLauncherLinks()`、`getControlPageApiMethods()`、visible entries 和目标页面 manifest明确 `getLauncherLinks()`、`getControlPageApiMethods()`、visible entries 和目标页面
路径,供外部 shell 在不读 DOM 的情况下发现入口;仍保持只读,不新增控制按钮,不解析 G-code。 路径,供外部 shell 在不读 DOM 的情况下发现入口;仍保持只读,不新增控制按钮,不解析 G-code。
十三、2026-06-15 继续执行记录INI panel launch API manifest
本轮按“第一原则:加快实质性推进”继续推进 SDK/API surface为 launch page 增加轻量 API
manifest使外部 shell 可以在不读取 DOM、不加载 control-page iframe 的情况下发现入口方法、
visible entries、目标页面路径和 read-only control-page browser API 清单。
完成内容:
- `wasm-port/runtime/ui/ini-panel/ui-shell.js` 新增
`createIniPanelLaunchApiManifest()`
- `createIniPanelShellViewModel()` 新增 `launchApiManifest`
- launch API manifest 固定包含:
- `apiName`
- `methods`
- `visibleEntries`
- `targetPages`
- `controlPageApiMethods`
- `launch.html` 的 `window.linuxCncIniPanelLaunchApi` 新增 `getLaunchApiManifest()`
- `ini_panel_launch_smoke.html` 在真实 launch iframe 中校验:
- manifest API name
- manifest method list
- visible entry count
- control-page target href
- launch API 与 shell helper 一致;
- `verify_ini_panel_ui_shell.mjs`、`verify_ini_panel_shell_control_page_contract.mjs` 和
`verify_ini_panel_entry_docs.mjs` 覆盖 shell view-model、launch API manifest helper 与文档入口;
- `docs/panel-entry.md` 记录 `createIniPanelLaunchApiManifest()` 和
`linuxCncIniPanelLaunchApi.getLaunchApiManifest()`
- 未新增控制按钮;
- 未解析 G-code
- 未解释 canonical events
- 未改变 OPFS/session persistence、LinuxCNC interpreter、tool、parameter、planner 或
LinuxCNC-owned runtime semantics。
验证已通过:
```bash
git diff --check
wasm-port/tests/ui/node/verify_ini_panel_ui_shell.sh
wasm-port/tests/ui/node/verify_ini_panel_shell_control_page_contract.sh
wasm-port/tests/ui/node/verify_ini_panel_entry_docs.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_ui_shell_node_smoke=ok
ini_panel_shell_control_page_contract_node_smoke=ok
ini_panel_entry_docs_node_smoke=ok
ui_node_smokes=ok
browser_ini_opfs_smoke=ok
browser_ini_control_page_smoke=ok
browser_ini_launch_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
```
下一步建议:
继续推进 browser/UI workflow。下一批建议给 launch API manifest 增加一个 focused Node smoke
`verify_ini_panel_launch_api_manifest.sh`,直接校验 manifest shape、entries 深拷贝、target page
映射和 control-page API methods避免这些能力只被大 smoke 间接覆盖;仍保持只读,不新增控制
按钮,不解析 G-code。

View File

@@ -11,6 +11,7 @@ control view:
import { import {
INI_PANEL_ENTRIES, INI_PANEL_ENTRIES,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
createIniPanelShellViewModel, createIniPanelShellViewModel,
@@ -81,6 +82,10 @@ control page after save/load session workflows.
The launch page exposes `linuxCncIniPanelLaunchApi.getControlPageApiMethods()` The launch page exposes `linuxCncIniPanelLaunchApi.getControlPageApiMethods()`
from the same shell view-model so entry pages can consume the available from the same shell view-model so entry pages can consume the available
read-only control-page API list without loading the control-page iframe first. read-only control-page API list without loading the control-page iframe first.
Use `createIniPanelLaunchApiManifest()` or
`linuxCncIniPanelLaunchApi.getLaunchApiManifest()` when an outer shell needs a
single read-only description of launch methods, visible entries, target pages,
and the control-page browser API methods.
The control-page refresh workflow lives in The control-page refresh workflow lives in
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use `runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use

View File

@@ -90,6 +90,7 @@
} }
window.linuxCncIniPanelLaunchApi = { window.linuxCncIniPanelLaunchApi = {
getLaunchApiManifest: () => shellViewModel.launchApiManifest,
getLauncherLinks: () => shellViewModel.launcherLinks, getLauncherLinks: () => shellViewModel.launcherLinks,
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods, getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
}; };

View File

@@ -61,6 +61,27 @@ export function createIniPanelLauncherLinkViewModel(entries = getVisibleIniPanel
})); }));
} }
export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntries()) {
return {
apiName: "ini-panel-launch",
methods: [
"getLaunchApiManifest",
"getLauncherLinks",
"getControlPageApiMethods",
],
visibleEntries: entries.map(({ id, href, title }) => ({
id,
href,
title,
})),
targetPages: entries.map(({ id, href }) => ({
entryId: id,
href,
})),
controlPageApiMethods: createControlPageBrowserApiMethods(),
};
}
export function createIniPanelShellControlPageContract() { export function createIniPanelShellControlPageContract() {
const readonlyStatusApiManifest = createMachineSessionReadonlyStatusApiManifest(); const readonlyStatusApiManifest = createMachineSessionReadonlyStatusApiManifest();
return { return {
@@ -99,6 +120,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
title, title,
})), })),
launcherLinks: createIniPanelLauncherLinkViewModel(entries), launcherLinks: createIniPanelLauncherLinkViewModel(entries),
launchApiManifest: createIniPanelLaunchApiManifest(entries),
controlPage: { controlPage: {
browserApiMethods: createControlPageBrowserApiMethods(), browserApiMethods: createControlPageBrowserApiMethods(),
contract: createIniPanelShellControlPageContract(), contract: createIniPanelShellControlPageContract(),

View File

@@ -9,6 +9,7 @@
<script type="module"> <script type="module">
import { import {
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
createIniPanelShellViewModel, createIniPanelShellViewModel,
getIniPanelEntryByHref, getIniPanelEntryByHref,
@@ -51,12 +52,43 @@
createControlPageBrowserApiMethods().join(","), createControlPageBrowserApiMethods().join(","),
"launch shell control-page browser API methods", "launch shell control-page browser API methods",
); );
assertEqual(
createIniPanelShellViewModel().launchApiManifest.apiName,
"ini-panel-launch",
"launch shell API manifest name",
);
assertEqual(
createIniPanelShellViewModel().launchApiManifest.methods.join(","),
createIniPanelLaunchApiManifest().methods.join(","),
"launch shell API manifest methods",
);
const launchDoc = await loadLaunchFrame(); const launchDoc = await loadLaunchFrame();
const launchApi = launchDoc.defaultView.linuxCncIniPanelLaunchApi; const launchApi = launchDoc.defaultView.linuxCncIniPanelLaunchApi;
if (!launchApi?.getLauncherLinks || !launchApi?.getControlPageApiMethods) { if (!launchApi?.getLaunchApiManifest || !launchApi?.getLauncherLinks || !launchApi?.getControlPageApiMethods) {
throw new Error("launch API namespace did not expose shell helpers"); throw new Error("launch API namespace did not expose shell helpers");
} }
const launchApiManifest = launchApi.getLaunchApiManifest();
assertEqual(
launchApiManifest.apiName,
"ini-panel-launch",
"launch API manifest name",
);
assertEqual(
launchApiManifest.methods.join(","),
"getLaunchApiManifest,getLauncherLinks,getControlPageApiMethods",
"launch API manifest methods",
);
assertEqual(
launchApiManifest.visibleEntries.length,
2,
"launch API manifest visible entry count",
);
assertEqual(
launchApiManifest.targetPages[1].href,
"./control-page.html",
"launch API manifest control target",
);
assertEqual( assertEqual(
launchDoc.querySelector('a[href="./index.html"]').textContent, launchDoc.querySelector('a[href="./index.html"]').textContent,
"Open edit and run panel", "Open edit and run panel",

View File

@@ -8,6 +8,7 @@ import {
controlPageStatusText, controlPageStatusText,
createControlPageSessionLoadState, createControlPageSessionLoadState,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
createIniPanelShellViewModel, createIniPanelShellViewModel,
@@ -39,6 +40,7 @@ const requiredShellExports = [
"controlPageStatusText", "controlPageStatusText",
"createControlPageBrowserApiMethods", "createControlPageBrowserApiMethods",
"createControlPageSessionLoadState", "createControlPageSessionLoadState",
"createIniPanelLaunchApiManifest",
"createIniPanelLauncherLinkViewModel", "createIniPanelLauncherLinkViewModel",
"createIniPanelShellControlPageContract", "createIniPanelShellControlPageContract",
"createIniPanelShellViewModel", "createIniPanelShellViewModel",
@@ -96,6 +98,7 @@ assert.deepEqual(
); );
assert.deepEqual(createIniPanelShellViewModel().pages, getVisibleIniPanelEntries()); assert.deepEqual(createIniPanelShellViewModel().pages, getVisibleIniPanelEntries());
assert.deepEqual(createIniPanelShellViewModel().launcherLinks, createIniPanelLauncherLinkViewModel()); assert.deepEqual(createIniPanelShellViewModel().launcherLinks, createIniPanelLauncherLinkViewModel());
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
assert.deepEqual( assert.deepEqual(
createIniPanelShellViewModel().controlPage.contract, createIniPanelShellViewModel().controlPage.contract,
createIniPanelShellControlPageContract(), createIniPanelShellControlPageContract(),
@@ -128,8 +131,10 @@ assert.equal(createIniPanelShellViewModel().controlPage.readStatus, readMachineS
assert.equal(createIniPanelShellViewModel().controlPage.refresh, refreshMachineSessionControlPage); assert.equal(createIniPanelShellViewModel().controlPage.refresh, refreshMachineSessionControlPage);
assert.equal(typeof createIniPanelShellViewModel().controlPage.renderView, "function"); assert.equal(typeof createIniPanelShellViewModel().controlPage.renderView, "function");
assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/); assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/);
assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/);
assert.match(controlPageText, /\bgetControlPageApiMethods\b/); assert.match(controlPageText, /\bgetControlPageApiMethods\b/);
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/); assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
assert.match(launchText, /\bgetLaunchApiManifest\b/);
assert.match(launchText, /\bgetControlPageApiMethods\b/); assert.match(launchText, /\bgetControlPageApiMethods\b/);
assert.match(controlPageText, /\bgetControlPageContract\b/); assert.match(controlPageText, /\bgetControlPageContract\b/);
assert.match(controlPageText, /\breadControlPageStatus\b/); assert.match(controlPageText, /\breadControlPageStatus\b/);
@@ -137,6 +142,8 @@ assert.match(controlPageText, /\bcreateIniPanelShellControlPageContract\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/); assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageContract\b/); assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageContract\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.readControlPageStatus\b/); assert.match(docText, /\blinuxCncIniPanelControlPageApi\.readControlPageStatus\b/);
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/); assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
for (const entry of INI_PANEL_ENTRIES) { for (const entry of INI_PANEL_ENTRIES) {

View File

@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
import { import {
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
createIniPanelShellViewModel, createIniPanelShellViewModel,
createMachineSessionControlPageController, createMachineSessionControlPageController,
@@ -55,6 +56,7 @@ assert.deepEqual(contract, {
}); });
const shellViewModel = createIniPanelShellViewModel(); const shellViewModel = createIniPanelShellViewModel();
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
assert.deepEqual(Object.keys(shellViewModel.controlPage), [ assert.deepEqual(Object.keys(shellViewModel.controlPage), [
"browserApiMethods", "browserApiMethods",
"contract", "contract",

View File

@@ -4,6 +4,7 @@ import {
INI_PANEL_ENTRIES, INI_PANEL_ENTRIES,
controlPageStatusText, controlPageStatusText,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
createIniPanelShellViewModel, createIniPanelShellViewModel,
@@ -46,6 +47,7 @@ assert.equal(typeof createMachineSessionControlPageController, "function");
assert.equal(typeof createMachineSessionReadonlyStatus, "function"); assert.equal(typeof createMachineSessionReadonlyStatus, "function");
assert.equal(typeof createMachineSessionReadonlyStatusApiManifest, "function"); assert.equal(typeof createMachineSessionReadonlyStatusApiManifest, "function");
assert.equal(typeof createControlPageBrowserApiMethods, "function"); assert.equal(typeof createControlPageBrowserApiMethods, "function");
assert.equal(typeof createIniPanelLaunchApiManifest, "function");
assert.equal(typeof createIniPanelShellControlPageContract, "function"); assert.equal(typeof createIniPanelShellControlPageContract, "function");
assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function"); assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
assert.equal(typeof readMachineSessionReadonlyStatus, "function"); assert.equal(typeof readMachineSessionReadonlyStatus, "function");
@@ -87,6 +89,7 @@ assert.deepEqual(shellViewModel.pages, [
}, },
]); ]);
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel()); assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods()); assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController); assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract()); assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());