推进 INI 面板 shell integration manifest

This commit is contained in:
2026-06-15 07:42:22 +08:00
parent b3f131fa5f
commit 7b17603601
11 changed files with 406 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ import {
createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel,
createIniPanelShellControlPageContract,
createIniPanelShellIntegrationManifest,
createIniPanelShellIntegrationSchema,
createIniPanelShellViewModel,
createMachineSessionReadonlyStatus,
createMachineSessionReadonlyStatusApiManifest,
@@ -23,6 +25,7 @@ import {
getVisibleIniPanelEntries,
isSupportedIniPanelControlPageApiManifest,
isSupportedIniPanelLaunchApiManifest,
isSupportedIniPanelShellIntegrationManifest,
} from "../../../runtime/ui/ini-panel/ui-shell.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -51,11 +54,14 @@ const requiredShellExports = [
"createIniPanelLaunchApiSchema",
"createIniPanelLauncherLinkViewModel",
"createIniPanelShellControlPageContract",
"createIniPanelShellIntegrationManifest",
"createIniPanelShellIntegrationSchema",
"createIniPanelShellViewModel",
"getIniPanelEntryByHref",
"getVisibleIniPanelEntries",
"isSupportedIniPanelControlPageApiManifest",
"isSupportedIniPanelLaunchApiManifest",
"isSupportedIniPanelShellIntegrationManifest",
"createMachineSessionControlPageController",
"createMachineSessionReadonlyStatus",
"createMachineSessionReadonlyStatusApiManifest",
@@ -108,6 +114,15 @@ assert.deepEqual(
);
assert.deepEqual(createIniPanelShellViewModel().pages, getVisibleIniPanelEntries());
assert.deepEqual(createIniPanelShellViewModel().launcherLinks, createIniPanelLauncherLinkViewModel());
assert.deepEqual(
createIniPanelShellViewModel().shellIntegrationSchema,
createIniPanelShellIntegrationSchema(),
);
assert.deepEqual(
createIniPanelShellViewModel().shellIntegrationManifest,
createIniPanelShellIntegrationManifest(),
);
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
assert.equal(isSupportedIniPanelLaunchApiManifest(createIniPanelShellViewModel().launchApiManifest), true);
@@ -157,8 +172,11 @@ 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 createIniPanelLaunchApiManifest\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelControlPageApiManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelLaunchApiManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelShellIntegrationManifest\b/);
assert.match(controlPageText, /\bisSupportedControlPageApiManifest\b/);
assert.match(controlPageText, /\bgetControlPageApiSchema\b/);
assert.match(controlPageText, /\bgetControlPageApiManifest\b/);
@@ -167,6 +185,8 @@ assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
assert.match(launchText, /\bisSupportedLaunchApiManifest\b/);
assert.match(launchText, /\bgetLaunchApiSchema\b/);
assert.match(launchText, /\bgetLaunchApiManifest\b/);
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
assert.match(launchText, /\bgetControlPageApiMethods\b/);
assert.match(controlPageText, /\bgetControlPageContract\b/);
assert.match(controlPageText, /\breadControlPageStatus\b/);
@@ -181,11 +201,16 @@ assert.match(docText, /\bcreateControlPageBrowserApiManifest\b/);
assert.match(docText, /\bcreateControlPageBrowserApiSchema\b/);
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
assert.match(docText, /\bcreateIniPanelLaunchApiSchema\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationManifest\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationSchema\b/);
assert.match(docText, /\bisSupportedIniPanelControlPageApiManifest\b/);
assert.match(docText, /\bisSupportedIniPanelLaunchApiManifest\b/);
assert.match(docText, /\bisSupportedIniPanelShellIntegrationManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.isSupportedLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiSchema\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellIntegrationSchema\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellIntegrationManifest\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
assert.match(docText, /\bOPFS\/session persistence capabilities\b/);
assert.match(docText, /\bmachine files\b/);

View File

@@ -8,6 +8,7 @@ import {
createControlPageBrowserApiMethods,
createIniPanelLaunchApiManifest,
createIniPanelLaunchApiSchema,
createIniPanelShellIntegrationManifest,
createIniPanelShellViewModel,
getVisibleIniPanelEntries,
isSupportedIniPanelLaunchApiManifest,
@@ -42,6 +43,8 @@ assert.deepEqual(manifest, {
"isSupportedLaunchApiManifest",
"getLaunchApiSchema",
"getLaunchApiManifest",
"getShellIntegrationSchema",
"getShellIntegrationManifest",
"getLauncherLinks",
"getControlPageApiMethods",
],
@@ -89,6 +92,10 @@ assert.deepEqual(manifest, {
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, manifest);
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, schema);
assert.deepEqual(
createIniPanelShellViewModel().shellIntegrationManifest,
createIniPanelShellIntegrationManifest(),
);
assert.equal(createIniPanelShellViewModel().launchApiManifest.manifestVersion, schema.manifestVersion);
assert.equal(isSupportedIniPanelLaunchApiManifest(manifest), true);
assert.equal(isSupportedIniPanelLaunchApiManifest({ ...manifest, manifestVersion: 2 }), false);
@@ -135,6 +142,8 @@ assert.match(shellText, /\bexport function isSupportedIniPanelLaunchApiManifest\
assert.match(launchText, /\bisSupportedLaunchApiManifest\b/);
assert.match(launchText, /\bgetLaunchApiSchema\b/);
assert.match(launchText, /\bgetLaunchApiManifest\b/);
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
console.log("ini_panel_launch_api_manifest_node_smoke=ok");

View File

@@ -0,0 +1,127 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
INI_PANEL_ENTRIES,
createControlPageBrowserApiManifest,
createControlPageBrowserApiSchema,
createIniPanelLaunchApiManifest,
createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel,
createIniPanelShellIntegrationManifest,
createIniPanelShellIntegrationSchema,
getVisibleIniPanelEntries,
isSupportedIniPanelShellIntegrationManifest,
} from "../../../runtime/ui/ini-panel/ui-shell.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = resolve(__dirname, "../../..");
const shellText = readFileSync(resolve(root, "runtime/ui/ini-panel/ui-shell.js"), "utf8");
const launchText = readFileSync(resolve(root, "runtime/ui/ini-panel/launch.html"), "utf8");
const docText = readFileSync(resolve(root, "docs/panel-entry.md"), "utf8");
const schema = createIniPanelShellIntegrationSchema();
const manifest = createIniPanelShellIntegrationManifest();
assert.deepEqual(schema, {
apiName: "ini-panel-shell-integration",
manifestVersion: 1,
fields: [
"apiName",
"manifestVersion",
"pages",
"launcherLinks",
"launchApiSchema",
"launchApiManifest",
"controlPageApiSchema",
"controlPageApiManifest",
"compatibility",
"persistenceCapabilities",
],
});
assert.deepEqual(manifest, {
apiName: "ini-panel-shell-integration",
manifestVersion: 1,
pages: getVisibleIniPanelEntries(),
launcherLinks: createIniPanelLauncherLinkViewModel(),
launchApiSchema: createIniPanelLaunchApiSchema(),
launchApiManifest: createIniPanelLaunchApiManifest(),
controlPageApiSchema: createControlPageBrowserApiSchema(),
controlPageApiManifest: createControlPageBrowserApiManifest(),
compatibility: {
launchApiManifest: true,
controlPageApiManifest: true,
},
persistenceCapabilities: createIniPanelLaunchApiManifest().persistenceCapabilities,
});
assert.equal(isSupportedIniPanelShellIntegrationManifest(manifest), true);
assert.equal(isSupportedIniPanelShellIntegrationManifest({ ...manifest, manifestVersion: 2 }), false);
assert.equal(isSupportedIniPanelShellIntegrationManifest({ ...manifest, apiName: "other" }), false);
const missingControlPageManifest = { ...manifest };
delete missingControlPageManifest.controlPageApiManifest;
assert.equal(isSupportedIniPanelShellIntegrationManifest(missingControlPageManifest), false);
assert.equal(isSupportedIniPanelShellIntegrationManifest(null), false);
manifest.pages[0].title = "changed";
manifest.launcherLinks[0].label = "changed";
manifest.launchApiManifest.visibleEntries[0].title = "changed";
manifest.controlPageApiManifest.methods.push("changedMethod");
manifest.persistenceCapabilities[0].label = "changed";
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
assert.equal(createIniPanelShellIntegrationManifest().pages[0].title, "Open edit and run panel");
assert.equal(createIniPanelShellIntegrationManifest().launcherLinks[0].label, "Open edit and run panel");
assert.equal(
createIniPanelShellIntegrationManifest().launchApiManifest.visibleEntries[0].title,
"Open edit and run panel",
);
assert.equal(
createIniPanelShellIntegrationManifest().controlPageApiManifest.methods.includes("changedMethod"),
false,
);
assert.equal(
createIniPanelShellIntegrationManifest().persistenceCapabilities[0].label,
"Machine text files",
);
const customManifest = createIniPanelShellIntegrationManifest([
{
id: "custom",
href: "./custom.html",
title: "Custom entry",
},
]);
assert.deepEqual(customManifest.pages, [
{
id: "custom",
href: "./custom.html",
title: "Custom entry",
},
]);
assert.deepEqual(customManifest.launcherLinks, [
{
entryId: "custom",
href: "./custom.html",
label: "Custom entry",
},
]);
assert.deepEqual(customManifest.launchApiManifest.targetPages, [
{
entryId: "custom",
href: "./custom.html",
},
]);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationManifest\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelShellIntegrationManifest\b/);
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationManifest\b/);
assert.match(docText, /\bisSupportedIniPanelShellIntegrationManifest\b/);
assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/);
console.log("ini_panel_shell_integration_manifest_node_smoke=ok");

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
node "$ROOT_DIR/tests/ui/node/verify_ini_panel_shell_integration_manifest.mjs"

View File

@@ -10,6 +10,8 @@ import {
createIniPanelLaunchApiSchema,
createIniPanelLauncherLinkViewModel,
createIniPanelShellControlPageContract,
createIniPanelShellIntegrationManifest,
createIniPanelShellIntegrationSchema,
createIniPanelShellViewModel,
createMachineSessionReadonlyStatus,
createMachineSessionReadonlyStatusApiManifest,
@@ -21,6 +23,7 @@ import {
getVisibleIniPanelEntries,
isSupportedIniPanelControlPageApiManifest,
isSupportedIniPanelLaunchApiManifest,
isSupportedIniPanelShellIntegrationManifest,
loadMachineSessionForControlPageWorkflow,
readMachineSessionReadonlyStatus,
refreshMachineSessionControlPage,
@@ -57,12 +60,15 @@ assert.equal(typeof createControlPageBrowserApiSchema, "function");
assert.equal(typeof createIniPanelLaunchApiManifest, "function");
assert.equal(typeof createIniPanelLaunchApiSchema, "function");
assert.equal(typeof createIniPanelShellControlPageContract, "function");
assert.equal(typeof createIniPanelShellIntegrationManifest, "function");
assert.equal(typeof createIniPanelShellIntegrationSchema, "function");
assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
assert.equal(typeof readMachineSessionReadonlyStatus, "function");
assert.equal(typeof refreshMachineSessionControlPage, "function");
assert.equal(typeof renderMachineSessionControlView, "function");
assert.equal(typeof isSupportedIniPanelControlPageApiManifest, "function");
assert.equal(typeof isSupportedIniPanelLaunchApiManifest, "function");
assert.equal(typeof isSupportedIniPanelShellIntegrationManifest, "function");
const shellManifest = getIniPanelEntryManifest();
shellManifest[0].title = "changed";
@@ -99,6 +105,22 @@ assert.deepEqual(shellViewModel.pages, [
},
]);
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
assert.deepEqual(shellViewModel.shellIntegrationSchema, createIniPanelShellIntegrationSchema());
assert.deepEqual(shellViewModel.shellIntegrationManifest, createIniPanelShellIntegrationManifest());
assert.equal(
isSupportedIniPanelShellIntegrationManifest(shellViewModel.shellIntegrationManifest),
true,
);
assert.equal(
shellViewModel.shellIntegrationManifest.manifestVersion,
createIniPanelShellIntegrationSchema().manifestVersion,
);
assert.deepEqual(shellViewModel.shellIntegrationManifest.pages, shellViewModel.pages);
assert.deepEqual(shellViewModel.shellIntegrationManifest.launcherLinks, shellViewModel.launcherLinks);
assert.deepEqual(shellViewModel.shellIntegrationManifest.compatibility, {
launchApiManifest: true,
controlPageApiManifest: true,
});
assert.deepEqual(shellViewModel.launchApiSchema, createIniPanelLaunchApiSchema());
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
assert.equal(isSupportedIniPanelLaunchApiManifest(shellViewModel.launchApiManifest), true);
@@ -112,6 +134,7 @@ assert.equal(
createControlPageBrowserApiSchema().manifestVersion,
);
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
assert.equal(shellViewModel.isSupportedShellIntegrationManifest, isSupportedIniPanelShellIntegrationManifest);
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());
assert.equal(shellViewModel.controlPage.isSupportedBrowserApiManifest, isSupportedIniPanelControlPageApiManifest);
assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow);

View File

@@ -15,6 +15,7 @@ ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_readonly_status_api.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_entry_manifest.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_launch_api_manifest.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_shell_integration_manifest.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_ui_shell.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_shell_control_page_contract.sh"
"$ROOT_DIR/tests/ui/node/verify_ini_panel_entry_docs.sh"