推进 INI 面板 launch persistence capabilities manifest

This commit is contained in:
2026-06-15 06:40:55 +08:00
parent 4d471a3555
commit 2dcf8095dc
6 changed files with 122 additions and 1 deletions

View File

@@ -85,7 +85,8 @@ 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 browser API methods, and OPFS/session persistence capabilities
for machine files, session snapshots, and read-only status.
The control-page refresh workflow lives in
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use

View File

@@ -79,6 +79,23 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
href,
})),
controlPageApiMethods: createControlPageBrowserApiMethods(),
persistenceCapabilities: [
{
id: "machine-files",
label: "Machine text files",
scope: "opfs",
},
{
id: "session-snapshot",
label: "Machine session snapshot",
scope: "opfs",
},
{
id: "readonly-status",
label: "Read-only machine session status",
scope: "control-page",
},
],
};
}

View File

@@ -89,6 +89,21 @@
"./control-page.html",
"launch API manifest control target",
);
assertEqual(
launchApiManifest.persistenceCapabilities.length,
3,
"launch API manifest persistence capability count",
);
assertEqual(
launchApiManifest.persistenceCapabilities.map((capability) => capability.id).join(","),
"machine-files,session-snapshot,readonly-status",
"launch API manifest persistence capability ids",
);
assertEqual(
launchApiManifest.persistenceCapabilities[2].scope,
"control-page",
"launch API manifest readonly status scope",
);
assertEqual(
launchDoc.querySelector('a[href="./index.html"]').textContent,
"Open edit and run panel",

View File

@@ -145,6 +145,10 @@ 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, /\bOPFS\/session persistence capabilities\b/);
assert.match(docText, /\bmachine files\b/);
assert.match(docText, /\bsession snapshots\b/);
assert.match(docText, /\bread-only status\b/);
for (const entry of INI_PANEL_ENTRIES) {
const escapedHref = entry.href.replace(".", "\\.");

View File

@@ -48,6 +48,23 @@ assert.deepEqual(manifest, {
},
],
controlPageApiMethods: createControlPageBrowserApiMethods(),
persistenceCapabilities: [
{
id: "machine-files",
label: "Machine text files",
scope: "opfs",
},
{
id: "session-snapshot",
label: "Machine session snapshot",
scope: "opfs",
},
{
id: "readonly-status",
label: "Read-only machine session status",
scope: "control-page",
},
],
});
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, manifest);
@@ -56,9 +73,11 @@ assert.deepEqual(getVisibleIniPanelEntries(), INI_PANEL_ENTRIES);
manifest.visibleEntries[0].title = "changed";
manifest.targetPages[0].href = "./changed.html";
manifest.controlPageApiMethods.push("changedMethod");
manifest.persistenceCapabilities[0].label = "changed";
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
assert.equal(createIniPanelLaunchApiManifest().targetPages[0].href, "./index.html");
assert.deepEqual(createIniPanelLaunchApiManifest().controlPageApiMethods, createControlPageBrowserApiMethods());
assert.equal(createIniPanelLaunchApiManifest().persistenceCapabilities[0].label, "Machine text files");
const customManifest = createIniPanelLaunchApiManifest([
{