推进 INI 面板 control-page API manifest predicate

This commit is contained in:
2026-06-15 07:36:48 +08:00
parent 01d168e247
commit b3f131fa5f
8 changed files with 274 additions and 0 deletions

View File

@@ -1481,3 +1481,91 @@ host_wasm_opfs_browser_smokes=ok
继续推进 browser/UI workflow。下一批建议把 control-page browser API 也补齐 schema/version 与 继续推进 browser/UI workflow。下一批建议把 control-page browser API 也补齐 schema/version 与
compatibility predicate使 launch API 和 control-page API 具备一致的外部 shell 接入模型;仍保持 compatibility predicate使 launch API 和 control-page API 具备一致的外部 shell 接入模型;仍保持
只读,不新增控制按钮,不解析 G-code。 只读,不新增控制按钮,不解析 G-code。
十九、2026-06-15 继续执行记录INI panel control-page API manifest compatibility predicate
本轮按“第一原则:加快实质性推进”继续推进 browser/UI workflow把 control-page browser API
补齐 schema/version、manifest 和 compatibility predicate使 launch API 与 control-page API
具备一致的外部 shell 接入模型。
完成内容:
- `wasm-port/runtime/ui/ini-panel/ui-shell.js` 新增:
- `createControlPageBrowserApiSchema()`
- `createControlPageBrowserApiManifest()`
- `isSupportedIniPanelControlPageApiManifest()`
- `createControlPageBrowserApiMethods()` 新增:
- `isSupportedControlPageApiManifest`
- `getControlPageApiSchema`
- `getControlPageApiManifest`
- `createIniPanelShellViewModel().controlPage` 新增:
- `browserApiSchema`
- `browserApiManifest`
- `isSupportedBrowserApiManifest`
- `control-page.js` 的 `window.linuxCncIniPanelControlPageApi` 新增真实 browser 入口:
- `isSupportedControlPageApiManifest()`
- `getControlPageApiSchema()`
- `getControlPageApiManifest()`
- `ini_panel_control_page_smoke.html` 在真实 control-page iframe 中校验:
- schema `manifestVersion`
- schema fields 包含 `readonlyStatusApiManifest`
- 当前 manifest 被 predicate 接受;
- 错误 `apiName` 被 predicate 拒绝;
- manifest methods 与 browser API methods 一致;
- manifest 暴露 readonly status API manifest
- `verify_ini_panel_shell_control_page_contract.mjs` 覆盖 control-page browser API schema、
manifest、supported、错误 version、错误 apiName、缺少字段和 null 输入;
- `verify_ini_panel_ui_shell.mjs`、`verify_ini_panel_entry_docs.mjs` 与 `docs/panel-entry.md`
记录并校验 control-page browser API schema/manifest/predicate
- launch manifest 继续通过同一 `createControlPageBrowserApiMethods()` 获取 control-page
方法清单;
- 未新增控制按钮;
- 未解析 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_shell_control_page_contract.sh
wasm-port/tests/ui/node/verify_ini_panel_ui_shell.sh
wasm-port/tests/ui/node/verify_ini_panel_entry_docs.sh
wasm-port/tests/ui/node/verify_ini_panel_launch_api_manifest.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_shell_control_page_contract_node_smoke=ok
ini_panel_ui_shell_node_smoke=ok
ini_panel_entry_docs_node_smoke=ok
ini_panel_launch_api_manifest_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
```
下一步建议:
继续推进 SDK/API surface。下一批建议把 launch API 和 control-page API 的 manifest 组合成一个
可复用的 shell integration manifest例如 `createIniPanelShellIntegrationManifest()`),让外部
shell 一次读取入口页、目标页、launch API、control-page API、OPFS/session persistence 能力与
compatibility predicate 状态;仍保持只读,不新增控制按钮,不解析 G-code。

View File

@@ -10,7 +10,9 @@ control view:
```js ```js
import { import {
INI_PANEL_ENTRIES, INI_PANEL_ENTRIES,
createControlPageBrowserApiManifest,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createControlPageBrowserApiSchema,
createIniPanelLaunchApiManifest, createIniPanelLaunchApiManifest,
createIniPanelLaunchApiSchema, createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
@@ -27,6 +29,7 @@ import {
refreshMachineSessionControlPage, refreshMachineSessionControlPage,
controlPageStatusText, controlPageStatusText,
renderMachineSessionControlView, renderMachineSessionControlView,
isSupportedIniPanelControlPageApiManifest,
isSupportedIniPanelLaunchApiManifest, isSupportedIniPanelLaunchApiManifest,
} from "../runtime/ui/ini-panel/ui-shell.js"; } from "../runtime/ui/ini-panel/ui-shell.js";
``` ```
@@ -78,6 +81,14 @@ smokes can verify the same API shape before reading the embedded panel state.
Use `linuxCncIniPanelControlPageApi.getControlPageApiMethods()` when a browser Use `linuxCncIniPanelControlPageApi.getControlPageApiMethods()` when a browser
outer page needs the exact exposed method list before calling the read-only outer page needs the exact exposed method list before calling the read-only
control page API. control page API.
Use `createControlPageBrowserApiSchema()`,
`createControlPageBrowserApiManifest()`, or
`linuxCncIniPanelControlPageApi.getControlPageApiSchema()` and
`linuxCncIniPanelControlPageApi.getControlPageApiManifest()` when a browser
outer page needs a versioned control-page API description before reading the
embedded panel. Use `isSupportedIniPanelControlPageApiManifest()` or
`linuxCncIniPanelControlPageApi.isSupportedControlPageApiManifest()` for a
read-only compatibility predicate before consuming that manifest.
Use `linuxCncIniPanelControlPageApi.readControlPageStatus()` when a browser Use `linuxCncIniPanelControlPageApi.readControlPageStatus()` when a browser
outer page needs the same readonly status snapshot from the real embedded outer page needs the same readonly status snapshot from the real embedded
control page after save/load session workflows. control page after save/load session workflows.

View File

@@ -5,8 +5,11 @@ import {
createMachineSessionControlPageController, createMachineSessionControlPageController,
} from "./control-page-controller.js"; } from "./control-page-controller.js";
import { import {
createControlPageBrowserApiManifest,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createControlPageBrowserApiSchema,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
isSupportedIniPanelControlPageApiManifest,
} from "./ui-shell.js"; } from "./ui-shell.js";
const panelFrameNode = document.getElementById("panel-frame"); const panelFrameNode = document.getElementById("panel-frame");
@@ -23,6 +26,9 @@ const controller = createMachineSessionControlPageController({
controller.mount(); controller.mount();
window.linuxCncIniPanelControlPageApi = { window.linuxCncIniPanelControlPageApi = {
isSupportedControlPageApiManifest: isSupportedIniPanelControlPageApiManifest,
getControlPageApiSchema: createControlPageBrowserApiSchema,
getControlPageApiManifest: createControlPageBrowserApiManifest,
getControlPageApiMethods: createControlPageBrowserApiMethods, getControlPageApiMethods: createControlPageBrowserApiMethods,
getControlView: controller.getControlView, getControlView: controller.getControlView,
getControlPageContract: createIniPanelShellControlPageContract, getControlPageContract: createIniPanelShellControlPageContract,

View File

@@ -87,6 +87,33 @@ export function isSupportedIniPanelLaunchApiManifest(manifest, schema = createIn
return schema.fields.every((fieldName) => Object.hasOwn(manifest, fieldName)); return schema.fields.every((fieldName) => Object.hasOwn(manifest, fieldName));
} }
export function createControlPageBrowserApiSchema() {
return {
apiName: "ini-panel-control-page",
manifestVersion: 1,
fields: [
"apiName",
"manifestVersion",
"methods",
"contract",
"readonlyStatusApiManifest",
],
};
}
export function isSupportedIniPanelControlPageApiManifest(
manifest,
schema = createControlPageBrowserApiSchema(),
) {
if (!manifest || typeof manifest !== "object") {
return false;
}
if (manifest.apiName !== schema.apiName || manifest.manifestVersion !== schema.manifestVersion) {
return false;
}
return schema.fields.every((fieldName) => Object.hasOwn(manifest, fieldName));
}
export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntries()) { export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntries()) {
const schema = createIniPanelLaunchApiSchema(); const schema = createIniPanelLaunchApiSchema();
return { return {
@@ -148,6 +175,9 @@ export function createIniPanelShellControlPageContract() {
export function createControlPageBrowserApiMethods() { export function createControlPageBrowserApiMethods() {
return [ return [
"isSupportedControlPageApiManifest",
"getControlPageApiSchema",
"getControlPageApiManifest",
"getControlPageApiMethods", "getControlPageApiMethods",
"getControlPageContract", "getControlPageContract",
"getControlView", "getControlView",
@@ -159,6 +189,18 @@ export function createControlPageBrowserApiMethods() {
]; ];
} }
export function createControlPageBrowserApiManifest() {
const schema = createControlPageBrowserApiSchema();
const contract = createIniPanelShellControlPageContract();
return {
apiName: schema.apiName,
manifestVersion: schema.manifestVersion,
methods: createControlPageBrowserApiMethods(),
contract,
readonlyStatusApiManifest: contract.readonlyStatusApiManifest,
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) { export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
return { return {
pages: entries.map(({ id, href, title }) => ({ pages: entries.map(({ id, href, title }) => ({
@@ -170,9 +212,12 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
launchApiSchema: createIniPanelLaunchApiSchema(), launchApiSchema: createIniPanelLaunchApiSchema(),
launchApiManifest: createIniPanelLaunchApiManifest(entries), launchApiManifest: createIniPanelLaunchApiManifest(entries),
controlPage: { controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),
browserApiManifest: createControlPageBrowserApiManifest(),
browserApiMethods: createControlPageBrowserApiMethods(), browserApiMethods: createControlPageBrowserApiMethods(),
contract: createIniPanelShellControlPageContract(), contract: createIniPanelShellControlPageContract(),
createController: createMachineSessionControlPageController, createController: createMachineSessionControlPageController,
isSupportedBrowserApiManifest: isSupportedIniPanelControlPageApiManifest,
loadSessionState: loadMachineSessionForControlPageWorkflow, loadSessionState: loadMachineSessionForControlPageWorkflow,
readonlyStatusApiManifest: createMachineSessionReadonlyStatusApiManifest(), readonlyStatusApiManifest: createMachineSessionReadonlyStatusApiManifest(),
readStatus: readMachineSessionReadonlyStatus, readStatus: readMachineSessionReadonlyStatus,

View File

@@ -62,6 +62,9 @@ TOOL_TABLE = browser-tool.tbl
const controlDoc = await loadControlPageFrame(); const controlDoc = await loadControlPageFrame();
const controlPageApi = controlDoc.defaultView.linuxCncIniPanelControlPageApi; const controlPageApi = controlDoc.defaultView.linuxCncIniPanelControlPageApi;
const expectedControlPageApiMethods = [ const expectedControlPageApiMethods = [
"isSupportedControlPageApiManifest",
"getControlPageApiSchema",
"getControlPageApiManifest",
"getControlPageApiMethods", "getControlPageApiMethods",
"getControlPageContract", "getControlPageContract",
"getControlView", "getControlView",
@@ -72,6 +75,9 @@ TOOL_TABLE = browser-tool.tbl
"renderControlPage", "renderControlPage",
]; ];
if ( if (
!controlPageApi?.isSupportedControlPageApiManifest ||
!controlPageApi?.getControlPageApiSchema ||
!controlPageApi?.getControlPageApiManifest ||
!controlPageApi?.getControlPageApiMethods || !controlPageApi?.getControlPageApiMethods ||
!controlPageApi?.getControlView || !controlPageApi?.getControlView ||
!controlPageApi?.getControlPageContract || !controlPageApi?.getControlPageContract ||
@@ -94,6 +100,39 @@ TOOL_TABLE = browser-tool.tbl
"control page browser API namespace methods", "control page browser API namespace methods",
); );
const controlPageApiSchema = controlPageApi.getControlPageApiSchema();
assertEqual(
controlPageApiSchema.manifestVersion,
1,
"control page API schema manifest version",
);
assertEqual(
controlPageApiSchema.fields.includes("readonlyStatusApiManifest"),
true,
"control page API schema readonly status field",
);
const controlPageApiManifest = controlPageApi.getControlPageApiManifest();
assertEqual(
controlPageApi.isSupportedControlPageApiManifest(controlPageApiManifest),
true,
"control page API supports manifest",
);
assertEqual(
controlPageApi.isSupportedControlPageApiManifest({ ...controlPageApiManifest, apiName: "other" }),
false,
"control page API rejects unsupported manifest name",
);
assertEqual(
controlPageApiManifest.methods.join(","),
expectedControlPageApiMethods.join(","),
"control page API manifest methods",
);
assertEqual(
controlPageApiManifest.readonlyStatusApiManifest.apiName,
"machine-session-readonly-status",
"control page API manifest readonly status API name",
);
const controlPageContract = controlPageApi.getControlPageContract(); const controlPageContract = controlPageApi.getControlPageContract();
assertEqual( assertEqual(
controlPageContract.methodNames.join(","), controlPageContract.methodNames.join(","),

View File

@@ -6,8 +6,10 @@ import { dirname, resolve } from "node:path";
import { import {
INI_PANEL_ENTRIES, INI_PANEL_ENTRIES,
controlPageStatusText, controlPageStatusText,
createControlPageBrowserApiManifest,
createControlPageSessionLoadState, createControlPageSessionLoadState,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createControlPageBrowserApiSchema,
createIniPanelLaunchApiManifest, createIniPanelLaunchApiManifest,
createIniPanelLaunchApiSchema, createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
@@ -19,6 +21,7 @@ import {
readMachineSessionReadonlyStatus, readMachineSessionReadonlyStatus,
refreshMachineSessionControlPage, refreshMachineSessionControlPage,
getVisibleIniPanelEntries, getVisibleIniPanelEntries,
isSupportedIniPanelControlPageApiManifest,
isSupportedIniPanelLaunchApiManifest, isSupportedIniPanelLaunchApiManifest,
} from "../../../runtime/ui/ini-panel/ui-shell.js"; } from "../../../runtime/ui/ini-panel/ui-shell.js";
@@ -40,7 +43,9 @@ const sessionWorkflowText = readFileSync(
const requiredShellExports = [ const requiredShellExports = [
"INI_PANEL_ENTRIES", "INI_PANEL_ENTRIES",
"controlPageStatusText", "controlPageStatusText",
"createControlPageBrowserApiManifest",
"createControlPageBrowserApiMethods", "createControlPageBrowserApiMethods",
"createControlPageBrowserApiSchema",
"createControlPageSessionLoadState", "createControlPageSessionLoadState",
"createIniPanelLaunchApiManifest", "createIniPanelLaunchApiManifest",
"createIniPanelLaunchApiSchema", "createIniPanelLaunchApiSchema",
@@ -49,6 +54,7 @@ const requiredShellExports = [
"createIniPanelShellViewModel", "createIniPanelShellViewModel",
"getIniPanelEntryByHref", "getIniPanelEntryByHref",
"getVisibleIniPanelEntries", "getVisibleIniPanelEntries",
"isSupportedIniPanelControlPageApiManifest",
"isSupportedIniPanelLaunchApiManifest", "isSupportedIniPanelLaunchApiManifest",
"createMachineSessionControlPageController", "createMachineSessionControlPageController",
"createMachineSessionReadonlyStatus", "createMachineSessionReadonlyStatus",
@@ -106,6 +112,15 @@ assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelL
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest()); assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
assert.equal(isSupportedIniPanelLaunchApiManifest(createIniPanelShellViewModel().launchApiManifest), true); assert.equal(isSupportedIniPanelLaunchApiManifest(createIniPanelShellViewModel().launchApiManifest), true);
assert.equal(createIniPanelShellViewModel().launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion); assert.equal(createIniPanelShellViewModel().launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion);
assert.deepEqual(
createIniPanelShellViewModel().controlPage.browserApiSchema,
createControlPageBrowserApiSchema(),
);
assert.deepEqual(
createIniPanelShellViewModel().controlPage.browserApiManifest,
createControlPageBrowserApiManifest(),
);
assert.equal(isSupportedIniPanelControlPageApiManifest(createIniPanelShellViewModel().controlPage.browserApiManifest), true);
assert.deepEqual( assert.deepEqual(
createIniPanelShellViewModel().controlPage.contract, createIniPanelShellViewModel().controlPage.contract,
createIniPanelShellControlPageContract(), createIniPanelShellControlPageContract(),
@@ -138,9 +153,15 @@ 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 createControlPageBrowserApiManifest\b/);
assert.match(shellText, /\bexport function createControlPageBrowserApiSchema\b/);
assert.match(shellText, /\bexport function createIniPanelLaunchApiSchema\b/); assert.match(shellText, /\bexport function createIniPanelLaunchApiSchema\b/);
assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/); assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelControlPageApiManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelLaunchApiManifest\b/); assert.match(shellText, /\bexport function isSupportedIniPanelLaunchApiManifest\b/);
assert.match(controlPageText, /\bisSupportedControlPageApiManifest\b/);
assert.match(controlPageText, /\bgetControlPageApiSchema\b/);
assert.match(controlPageText, /\bgetControlPageApiManifest\b/);
assert.match(controlPageText, /\bgetControlPageApiMethods\b/); assert.match(controlPageText, /\bgetControlPageApiMethods\b/);
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/); assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
assert.match(launchText, /\bisSupportedLaunchApiManifest\b/); assert.match(launchText, /\bisSupportedLaunchApiManifest\b/);
@@ -151,10 +172,16 @@ assert.match(controlPageText, /\bgetControlPageContract\b/);
assert.match(controlPageText, /\breadControlPageStatus\b/); assert.match(controlPageText, /\breadControlPageStatus\b/);
assert.match(controlPageText, /\bcreateIniPanelShellControlPageContract\b/); assert.match(controlPageText, /\bcreateIniPanelShellControlPageContract\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/); assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiSchema\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.isSupportedControlPageApiManifest\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, /\bcreateControlPageBrowserApiManifest\b/);
assert.match(docText, /\bcreateControlPageBrowserApiSchema\b/);
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/); assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
assert.match(docText, /\bcreateIniPanelLaunchApiSchema\b/); assert.match(docText, /\bcreateIniPanelLaunchApiSchema\b/);
assert.match(docText, /\bisSupportedIniPanelControlPageApiManifest\b/);
assert.match(docText, /\bisSupportedIniPanelLaunchApiManifest\b/); assert.match(docText, /\bisSupportedIniPanelLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.isSupportedLaunchApiManifest\b/); assert.match(docText, /\blinuxCncIniPanelLaunchApi\.isSupportedLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiSchema\b/); assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiSchema\b/);

View File

@@ -4,7 +4,9 @@ import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { import {
createControlPageBrowserApiManifest,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createControlPageBrowserApiSchema,
createIniPanelLaunchApiManifest, createIniPanelLaunchApiManifest,
createIniPanelShellControlPageContract, createIniPanelShellControlPageContract,
createIniPanelShellViewModel, createIniPanelShellViewModel,
@@ -14,6 +16,7 @@ import {
readMachineSessionReadonlyStatus, readMachineSessionReadonlyStatus,
refreshMachineSessionControlPage, refreshMachineSessionControlPage,
renderMachineSessionControlView, renderMachineSessionControlView,
isSupportedIniPanelControlPageApiManifest,
} from "../../../runtime/ui/ini-panel/ui-shell.js"; } from "../../../runtime/ui/ini-panel/ui-shell.js";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -31,6 +34,20 @@ const expectedMethodNames = [
const contract = createIniPanelShellControlPageContract(); const contract = createIniPanelShellControlPageContract();
const manifest = createMachineSessionReadonlyStatusApiManifest(); const manifest = createMachineSessionReadonlyStatusApiManifest();
const browserApiSchema = createControlPageBrowserApiSchema();
const browserApiManifest = createControlPageBrowserApiManifest();
assert.deepEqual(browserApiSchema, {
apiName: "ini-panel-control-page",
manifestVersion: 1,
fields: [
"apiName",
"manifestVersion",
"methods",
"contract",
"readonlyStatusApiManifest",
],
});
assert.deepEqual(contract, { assert.deepEqual(contract, {
methodNames: expectedMethodNames, methodNames: expectedMethodNames,
@@ -55,22 +72,43 @@ assert.deepEqual(contract, {
], ],
}); });
assert.deepEqual(browserApiManifest, {
apiName: "ini-panel-control-page",
manifestVersion: 1,
methods: createControlPageBrowserApiMethods(),
contract,
readonlyStatusApiManifest: manifest,
});
assert.equal(isSupportedIniPanelControlPageApiManifest(browserApiManifest), true);
assert.equal(isSupportedIniPanelControlPageApiManifest({ ...browserApiManifest, manifestVersion: 2 }), false);
assert.equal(isSupportedIniPanelControlPageApiManifest({ ...browserApiManifest, apiName: "other" }), false);
const missingReadonlyManifest = { ...browserApiManifest };
delete missingReadonlyManifest.readonlyStatusApiManifest;
assert.equal(isSupportedIniPanelControlPageApiManifest(missingReadonlyManifest), false);
assert.equal(isSupportedIniPanelControlPageApiManifest(null), false);
const shellViewModel = createIniPanelShellViewModel(); const shellViewModel = createIniPanelShellViewModel();
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest()); assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
assert.deepEqual(Object.keys(shellViewModel.controlPage), [ assert.deepEqual(Object.keys(shellViewModel.controlPage), [
"browserApiSchema",
"browserApiManifest",
"browserApiMethods", "browserApiMethods",
"contract", "contract",
"createController", "createController",
"isSupportedBrowserApiManifest",
"loadSessionState", "loadSessionState",
"readonlyStatusApiManifest", "readonlyStatusApiManifest",
"readStatus", "readStatus",
"refresh", "refresh",
"renderView", "renderView",
]); ]);
assert.deepEqual(shellViewModel.controlPage.browserApiSchema, browserApiSchema);
assert.deepEqual(shellViewModel.controlPage.browserApiManifest, browserApiManifest);
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods()); assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
assert.deepEqual(shellViewModel.controlPage.contract, contract); assert.deepEqual(shellViewModel.controlPage.contract, contract);
assert.deepEqual(shellViewModel.controlPage.readonlyStatusApiManifest, manifest); assert.deepEqual(shellViewModel.controlPage.readonlyStatusApiManifest, manifest);
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController); assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
assert.equal(shellViewModel.controlPage.isSupportedBrowserApiManifest, isSupportedIniPanelControlPageApiManifest);
assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow); assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow);
assert.equal(shellViewModel.controlPage.readStatus, readMachineSessionReadonlyStatus); assert.equal(shellViewModel.controlPage.readStatus, readMachineSessionReadonlyStatus);
assert.equal(shellViewModel.controlPage.refresh, refreshMachineSessionControlPage); assert.equal(shellViewModel.controlPage.refresh, refreshMachineSessionControlPage);
@@ -86,8 +124,14 @@ for (const fieldName of contract.readonlyStatusApiStatusFields) {
} }
assert.match(shellText, /\bexport function createIniPanelShellControlPageContract\b/); assert.match(shellText, /\bexport function createIniPanelShellControlPageContract\b/);
assert.match(shellText, /\bexport function createControlPageBrowserApiManifest\b/);
assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/); assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/);
assert.match(shellText, /\bexport function createControlPageBrowserApiSchema\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelControlPageApiManifest\b/);
assert.match(docText, /\bcreateIniPanelShellControlPageContract\b/); assert.match(docText, /\bcreateIniPanelShellControlPageContract\b/);
assert.match(docText, /\bcreateControlPageBrowserApiManifest\b/);
assert.match(docText, /\bcreateControlPageBrowserApiSchema\b/);
assert.match(docText, /\bisSupportedIniPanelControlPageApiManifest\b/);
assert.match(docText, /\bcontrolPage\.contract\b/); assert.match(docText, /\bcontrolPage\.contract\b/);
assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/); assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/);

View File

@@ -3,7 +3,9 @@ import assert from "node:assert/strict";
import { import {
INI_PANEL_ENTRIES, INI_PANEL_ENTRIES,
controlPageStatusText, controlPageStatusText,
createControlPageBrowserApiManifest,
createControlPageBrowserApiMethods, createControlPageBrowserApiMethods,
createControlPageBrowserApiSchema,
createIniPanelLaunchApiManifest, createIniPanelLaunchApiManifest,
createIniPanelLaunchApiSchema, createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel, createIniPanelLauncherLinkViewModel,
@@ -17,6 +19,7 @@ import {
getIniPanelEntryByHref, getIniPanelEntryByHref,
getIniPanelEntryManifest, getIniPanelEntryManifest,
getVisibleIniPanelEntries, getVisibleIniPanelEntries,
isSupportedIniPanelControlPageApiManifest,
isSupportedIniPanelLaunchApiManifest, isSupportedIniPanelLaunchApiManifest,
loadMachineSessionForControlPageWorkflow, loadMachineSessionForControlPageWorkflow,
readMachineSessionReadonlyStatus, readMachineSessionReadonlyStatus,
@@ -48,7 +51,9 @@ assert.equal(getIniPanelEntryByHref("./index.html")?.id, "edit-run");
assert.equal(typeof createMachineSessionControlPageController, "function"); 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 createControlPageBrowserApiManifest, "function");
assert.equal(typeof createControlPageBrowserApiMethods, "function"); assert.equal(typeof createControlPageBrowserApiMethods, "function");
assert.equal(typeof createControlPageBrowserApiSchema, "function");
assert.equal(typeof createIniPanelLaunchApiManifest, "function"); assert.equal(typeof createIniPanelLaunchApiManifest, "function");
assert.equal(typeof createIniPanelLaunchApiSchema, "function"); assert.equal(typeof createIniPanelLaunchApiSchema, "function");
assert.equal(typeof createIniPanelShellControlPageContract, "function"); assert.equal(typeof createIniPanelShellControlPageContract, "function");
@@ -56,6 +61,7 @@ assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
assert.equal(typeof readMachineSessionReadonlyStatus, "function"); assert.equal(typeof readMachineSessionReadonlyStatus, "function");
assert.equal(typeof refreshMachineSessionControlPage, "function"); assert.equal(typeof refreshMachineSessionControlPage, "function");
assert.equal(typeof renderMachineSessionControlView, "function"); assert.equal(typeof renderMachineSessionControlView, "function");
assert.equal(typeof isSupportedIniPanelControlPageApiManifest, "function");
assert.equal(typeof isSupportedIniPanelLaunchApiManifest, "function"); assert.equal(typeof isSupportedIniPanelLaunchApiManifest, "function");
const shellManifest = getIniPanelEntryManifest(); const shellManifest = getIniPanelEntryManifest();
@@ -97,9 +103,17 @@ assert.deepEqual(shellViewModel.launchApiSchema, createIniPanelLaunchApiSchema()
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest()); assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
assert.equal(isSupportedIniPanelLaunchApiManifest(shellViewModel.launchApiManifest), true); assert.equal(isSupportedIniPanelLaunchApiManifest(shellViewModel.launchApiManifest), true);
assert.equal(shellViewModel.launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion); assert.equal(shellViewModel.launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion);
assert.deepEqual(shellViewModel.controlPage.browserApiSchema, createControlPageBrowserApiSchema());
assert.deepEqual(shellViewModel.controlPage.browserApiManifest, createControlPageBrowserApiManifest());
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods()); assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
assert.equal(isSupportedIniPanelControlPageApiManifest(shellViewModel.controlPage.browserApiManifest), true);
assert.equal(
shellViewModel.controlPage.browserApiManifest.manifestVersion,
createControlPageBrowserApiSchema().manifestVersion,
);
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController); assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract()); assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());
assert.equal(shellViewModel.controlPage.isSupportedBrowserApiManifest, isSupportedIniPanelControlPageApiManifest);
assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow); assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow);
assert.equal(shellViewModel.controlPage.readonlyStatusApiManifest.apiName, "machine-session-readonly-status"); assert.equal(shellViewModel.controlPage.readonlyStatusApiManifest.apiName, "machine-session-readonly-status");
assert.deepEqual(shellViewModel.controlPage.readonlyStatusApiManifest, createMachineSessionReadonlyStatusApiManifest()); assert.deepEqual(shellViewModel.controlPage.readonlyStatusApiManifest, createMachineSessionReadonlyStatusApiManifest());