推进 INI 面板 shell integration readiness helper
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellIntegrationManifest,
|
||||
createIniPanelShellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationSchema,
|
||||
createIniPanelShellViewModel,
|
||||
getIniPanelEntryByHref,
|
||||
@@ -118,6 +119,11 @@ needs one versioned read of pages, launcher links, launch API metadata,
|
||||
control-page API metadata, OPFS/session persistence capabilities, and current
|
||||
compatibility status. Use `isSupportedIniPanelShellIntegrationManifest()` when
|
||||
the outer shell needs to check that integration manifest before consuming it.
|
||||
Use `createIniPanelShellIntegrationReadiness()` or
|
||||
`linuxCncIniPanelLaunchApi.getShellIntegrationReadiness()` when the outer shell
|
||||
needs a read-only `ready`/`blocked` status, failed check names, API names, and
|
||||
counts for pages, methods, and persistence capabilities before mounting any
|
||||
embedded control page.
|
||||
|
||||
The control-page refresh workflow lives in
|
||||
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
getLaunchApiManifest: () => shellViewModel.launchApiManifest,
|
||||
getShellIntegrationSchema: () => shellViewModel.shellIntegrationSchema,
|
||||
getShellIntegrationManifest: () => shellViewModel.shellIntegrationManifest,
|
||||
getShellIntegrationReadiness: () => shellViewModel.shellIntegrationReadiness,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
};
|
||||
|
||||
@@ -125,6 +125,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"getLaunchApiManifest",
|
||||
"getShellIntegrationSchema",
|
||||
"getShellIntegrationManifest",
|
||||
"getShellIntegrationReadiness",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
],
|
||||
@@ -265,7 +266,66 @@ export function createIniPanelShellIntegrationManifest(entries = getVisibleIniPa
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellIntegrationReadiness(
|
||||
manifest = createIniPanelShellIntegrationManifest(),
|
||||
) {
|
||||
const integrationManifestSupported = isSupportedIniPanelShellIntegrationManifest(manifest);
|
||||
const launchApiManifestSupported = integrationManifestSupported
|
||||
&& isSupportedIniPanelLaunchApiManifest(manifest.launchApiManifest, manifest.launchApiSchema);
|
||||
const controlPageApiManifestSupported = integrationManifestSupported
|
||||
&& isSupportedIniPanelControlPageApiManifest(
|
||||
manifest.controlPageApiManifest,
|
||||
manifest.controlPageApiSchema,
|
||||
);
|
||||
const compatibility = integrationManifestSupported && manifest.compatibility
|
||||
? {
|
||||
launchApiManifest: Boolean(manifest.compatibility.launchApiManifest),
|
||||
controlPageApiManifest: Boolean(manifest.compatibility.controlPageApiManifest),
|
||||
}
|
||||
: {
|
||||
launchApiManifest: false,
|
||||
controlPageApiManifest: false,
|
||||
};
|
||||
const checks = {
|
||||
integrationManifestSupported,
|
||||
launchApiManifestSupported,
|
||||
controlPageApiManifestSupported,
|
||||
launchCompatibility: compatibility.launchApiManifest,
|
||||
controlPageCompatibility: compatibility.controlPageApiManifest,
|
||||
};
|
||||
const missing = Object.entries(checks)
|
||||
.filter(([, passed]) => !passed)
|
||||
.map(([name]) => name);
|
||||
const ready = missing.length === 0;
|
||||
|
||||
return {
|
||||
phase: ready ? "ready" : "blocked",
|
||||
ready,
|
||||
checks,
|
||||
missing,
|
||||
counts: {
|
||||
pages: Array.isArray(manifest?.pages) ? manifest.pages.length : 0,
|
||||
launcherLinks: Array.isArray(manifest?.launcherLinks) ? manifest.launcherLinks.length : 0,
|
||||
launchMethods: Array.isArray(manifest?.launchApiManifest?.methods)
|
||||
? manifest.launchApiManifest.methods.length
|
||||
: 0,
|
||||
controlPageMethods: Array.isArray(manifest?.controlPageApiManifest?.methods)
|
||||
? manifest.controlPageApiManifest.methods.length
|
||||
: 0,
|
||||
persistenceCapabilities: Array.isArray(manifest?.persistenceCapabilities)
|
||||
? manifest.persistenceCapabilities.length
|
||||
: 0,
|
||||
},
|
||||
apiNames: {
|
||||
integration: manifest?.apiName ?? null,
|
||||
launch: manifest?.launchApiManifest?.apiName ?? null,
|
||||
controlPage: manifest?.controlPageApiManifest?.apiName ?? null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
|
||||
return {
|
||||
pages: entries.map(({ id, href, title }) => ({
|
||||
id,
|
||||
@@ -274,10 +334,12 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
})),
|
||||
launcherLinks: createIniPanelLauncherLinkViewModel(entries),
|
||||
shellIntegrationSchema: createIniPanelShellIntegrationSchema(),
|
||||
shellIntegrationManifest: createIniPanelShellIntegrationManifest(entries),
|
||||
shellIntegrationManifest,
|
||||
shellIntegrationReadiness: createIniPanelShellIntegrationReadiness(shellIntegrationManifest),
|
||||
launchApiSchema: createIniPanelLaunchApiSchema(),
|
||||
launchApiManifest: createIniPanelLaunchApiManifest(entries),
|
||||
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
|
||||
createShellIntegrationReadiness: createIniPanelShellIntegrationReadiness,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
browserApiManifest: createControlPageBrowserApiManifest(),
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
!launchApi?.getLaunchApiManifest ||
|
||||
!launchApi?.getShellIntegrationSchema ||
|
||||
!launchApi?.getShellIntegrationManifest ||
|
||||
!launchApi?.getShellIntegrationReadiness ||
|
||||
!launchApi?.getLauncherLinks ||
|
||||
!launchApi?.getControlPageApiMethods
|
||||
) {
|
||||
@@ -111,11 +112,12 @@
|
||||
);
|
||||
assertEqual(
|
||||
launchApiManifest.methods.join(","),
|
||||
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getLauncherLinks,getControlPageApiMethods",
|
||||
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getShellIntegrationReadiness,getLauncherLinks,getControlPageApiMethods",
|
||||
"launch API manifest methods",
|
||||
);
|
||||
const shellIntegrationSchema = launchApi.getShellIntegrationSchema();
|
||||
const shellIntegrationManifest = launchApi.getShellIntegrationManifest();
|
||||
const shellIntegrationReadiness = launchApi.getShellIntegrationReadiness();
|
||||
assertEqual(
|
||||
shellIntegrationSchema.manifestVersion,
|
||||
1,
|
||||
@@ -141,6 +143,21 @@
|
||||
"ini-panel-control-page",
|
||||
"shell integration control-page manifest name",
|
||||
);
|
||||
assertEqual(
|
||||
shellIntegrationReadiness.ready,
|
||||
true,
|
||||
"shell integration readiness",
|
||||
);
|
||||
assertEqual(
|
||||
shellIntegrationReadiness.counts.persistenceCapabilities,
|
||||
3,
|
||||
"shell integration readiness capability count",
|
||||
);
|
||||
assertEqual(
|
||||
shellIntegrationReadiness.missing.join(","),
|
||||
"",
|
||||
"shell integration readiness missing checks",
|
||||
);
|
||||
assertEqual(
|
||||
JSON.stringify(shellIntegrationManifest),
|
||||
JSON.stringify(createIniPanelShellIntegrationManifest()),
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellIntegrationManifest,
|
||||
createIniPanelShellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationSchema,
|
||||
createIniPanelShellViewModel,
|
||||
createMachineSessionReadonlyStatus,
|
||||
@@ -55,6 +56,7 @@ const requiredShellExports = [
|
||||
"createIniPanelLauncherLinkViewModel",
|
||||
"createIniPanelShellControlPageContract",
|
||||
"createIniPanelShellIntegrationManifest",
|
||||
"createIniPanelShellIntegrationReadiness",
|
||||
"createIniPanelShellIntegrationSchema",
|
||||
"createIniPanelShellViewModel",
|
||||
"getIniPanelEntryByHref",
|
||||
@@ -122,6 +124,10 @@ assert.deepEqual(
|
||||
createIniPanelShellViewModel().shellIntegrationManifest,
|
||||
createIniPanelShellIntegrationManifest(),
|
||||
);
|
||||
assert.deepEqual(
|
||||
createIniPanelShellViewModel().shellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationReadiness(createIniPanelShellViewModel().shellIntegrationManifest),
|
||||
);
|
||||
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
@@ -174,6 +180,7 @@ 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 createIniPanelShellIntegrationReadiness\b/);
|
||||
assert.match(shellText, /\bexport function isSupportedIniPanelControlPageApiManifest\b/);
|
||||
assert.match(shellText, /\bexport function isSupportedIniPanelLaunchApiManifest\b/);
|
||||
assert.match(shellText, /\bexport function isSupportedIniPanelShellIntegrationManifest\b/);
|
||||
@@ -187,6 +194,7 @@ assert.match(launchText, /\bgetLaunchApiSchema\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationReadiness\b/);
|
||||
assert.match(launchText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageContract\b/);
|
||||
assert.match(controlPageText, /\breadControlPageStatus\b/);
|
||||
@@ -202,6 +210,7 @@ assert.match(docText, /\bcreateControlPageBrowserApiSchema\b/);
|
||||
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
|
||||
assert.match(docText, /\bcreateIniPanelLaunchApiSchema\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellIntegrationManifest\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellIntegrationReadiness\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellIntegrationSchema\b/);
|
||||
assert.match(docText, /\bisSupportedIniPanelControlPageApiManifest\b/);
|
||||
assert.match(docText, /\bisSupportedIniPanelLaunchApiManifest\b/);
|
||||
@@ -211,6 +220,7 @@ 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\.getShellIntegrationReadiness\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
|
||||
assert.match(docText, /\bOPFS\/session persistence capabilities\b/);
|
||||
assert.match(docText, /\bmachine files\b/);
|
||||
|
||||
@@ -45,6 +45,7 @@ assert.deepEqual(manifest, {
|
||||
"getLaunchApiManifest",
|
||||
"getShellIntegrationSchema",
|
||||
"getShellIntegrationManifest",
|
||||
"getShellIntegrationReadiness",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
],
|
||||
@@ -144,6 +145,7 @@ assert.match(launchText, /\bgetLaunchApiSchema\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationReadiness\b/);
|
||||
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
|
||||
|
||||
console.log("ini_panel_launch_api_manifest_node_smoke=ok");
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
createIniPanelLaunchApiSchema,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellIntegrationManifest,
|
||||
createIniPanelShellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationSchema,
|
||||
getVisibleIniPanelEntries,
|
||||
isSupportedIniPanelShellIntegrationManifest,
|
||||
@@ -24,6 +25,7 @@ const docText = readFileSync(resolve(root, "docs/panel-entry.md"), "utf8");
|
||||
|
||||
const schema = createIniPanelShellIntegrationSchema();
|
||||
const manifest = createIniPanelShellIntegrationManifest();
|
||||
const readiness = createIniPanelShellIntegrationReadiness(manifest);
|
||||
|
||||
assert.deepEqual(schema, {
|
||||
apiName: "ini-panel-shell-integration",
|
||||
@@ -65,6 +67,80 @@ const missingControlPageManifest = { ...manifest };
|
||||
delete missingControlPageManifest.controlPageApiManifest;
|
||||
assert.equal(isSupportedIniPanelShellIntegrationManifest(missingControlPageManifest), false);
|
||||
assert.equal(isSupportedIniPanelShellIntegrationManifest(null), false);
|
||||
assert.deepEqual(readiness, {
|
||||
phase: "ready",
|
||||
ready: true,
|
||||
checks: {
|
||||
integrationManifestSupported: true,
|
||||
launchApiManifestSupported: true,
|
||||
controlPageApiManifestSupported: true,
|
||||
launchCompatibility: true,
|
||||
controlPageCompatibility: true,
|
||||
},
|
||||
missing: [],
|
||||
counts: {
|
||||
pages: 2,
|
||||
launcherLinks: 2,
|
||||
launchMethods: 8,
|
||||
controlPageMethods: 11,
|
||||
persistenceCapabilities: 3,
|
||||
},
|
||||
apiNames: {
|
||||
integration: "ini-panel-shell-integration",
|
||||
launch: "ini-panel-launch",
|
||||
controlPage: "ini-panel-control-page",
|
||||
},
|
||||
});
|
||||
const blockedManifest = {
|
||||
...createIniPanelShellIntegrationManifest(),
|
||||
compatibility: {
|
||||
launchApiManifest: false,
|
||||
controlPageApiManifest: true,
|
||||
},
|
||||
};
|
||||
assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
checks: {
|
||||
integrationManifestSupported: true,
|
||||
launchApiManifestSupported: true,
|
||||
controlPageApiManifestSupported: true,
|
||||
launchCompatibility: false,
|
||||
controlPageCompatibility: true,
|
||||
},
|
||||
missing: ["launchCompatibility"],
|
||||
counts: {
|
||||
pages: 2,
|
||||
launcherLinks: 2,
|
||||
launchMethods: 8,
|
||||
controlPageMethods: 11,
|
||||
persistenceCapabilities: 3,
|
||||
},
|
||||
apiNames: {
|
||||
integration: "ini-panel-shell-integration",
|
||||
launch: "ini-panel-launch",
|
||||
controlPage: "ini-panel-control-page",
|
||||
},
|
||||
});
|
||||
const malformedReadiness = createIniPanelShellIntegrationReadiness({
|
||||
apiName: "other",
|
||||
});
|
||||
assert.equal(malformedReadiness.phase, "blocked");
|
||||
assert.equal(malformedReadiness.ready, false);
|
||||
assert.deepEqual(malformedReadiness.missing, [
|
||||
"integrationManifestSupported",
|
||||
"launchApiManifestSupported",
|
||||
"controlPageApiManifestSupported",
|
||||
"launchCompatibility",
|
||||
"controlPageCompatibility",
|
||||
]);
|
||||
assert.deepEqual(malformedReadiness.counts, {
|
||||
pages: 0,
|
||||
launcherLinks: 0,
|
||||
launchMethods: 0,
|
||||
controlPageMethods: 0,
|
||||
persistenceCapabilities: 0,
|
||||
});
|
||||
|
||||
manifest.pages[0].title = "changed";
|
||||
manifest.launcherLinks[0].label = "changed";
|
||||
@@ -117,10 +193,13 @@ assert.deepEqual(customManifest.launchApiManifest.targetPages, [
|
||||
|
||||
assert.match(shellText, /\bexport function createIniPanelShellIntegrationSchema\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellIntegrationManifest\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellIntegrationReadiness\b/);
|
||||
assert.match(shellText, /\bexport function isSupportedIniPanelShellIntegrationManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
|
||||
assert.match(launchText, /\bgetShellIntegrationReadiness\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellIntegrationManifest\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellIntegrationReadiness\b/);
|
||||
assert.match(docText, /\bisSupportedIniPanelShellIntegrationManifest\b/);
|
||||
assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellIntegrationManifest,
|
||||
createIniPanelShellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationSchema,
|
||||
createIniPanelShellViewModel,
|
||||
createMachineSessionReadonlyStatus,
|
||||
@@ -61,6 +62,7 @@ assert.equal(typeof createIniPanelLaunchApiManifest, "function");
|
||||
assert.equal(typeof createIniPanelLaunchApiSchema, "function");
|
||||
assert.equal(typeof createIniPanelShellControlPageContract, "function");
|
||||
assert.equal(typeof createIniPanelShellIntegrationManifest, "function");
|
||||
assert.equal(typeof createIniPanelShellIntegrationReadiness, "function");
|
||||
assert.equal(typeof createIniPanelShellIntegrationSchema, "function");
|
||||
assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
|
||||
assert.equal(typeof readMachineSessionReadonlyStatus, "function");
|
||||
@@ -107,6 +109,10 @@ assert.deepEqual(shellViewModel.pages, [
|
||||
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(shellViewModel.shellIntegrationSchema, createIniPanelShellIntegrationSchema());
|
||||
assert.deepEqual(shellViewModel.shellIntegrationManifest, createIniPanelShellIntegrationManifest());
|
||||
assert.deepEqual(
|
||||
shellViewModel.shellIntegrationReadiness,
|
||||
createIniPanelShellIntegrationReadiness(shellViewModel.shellIntegrationManifest),
|
||||
);
|
||||
assert.equal(
|
||||
isSupportedIniPanelShellIntegrationManifest(shellViewModel.shellIntegrationManifest),
|
||||
true,
|
||||
@@ -121,6 +127,8 @@ assert.deepEqual(shellViewModel.shellIntegrationManifest.compatibility, {
|
||||
launchApiManifest: true,
|
||||
controlPageApiManifest: true,
|
||||
});
|
||||
assert.equal(shellViewModel.shellIntegrationReadiness.ready, true);
|
||||
assert.deepEqual(shellViewModel.shellIntegrationReadiness.missing, []);
|
||||
assert.deepEqual(shellViewModel.launchApiSchema, createIniPanelLaunchApiSchema());
|
||||
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.equal(isSupportedIniPanelLaunchApiManifest(shellViewModel.launchApiManifest), true);
|
||||
@@ -135,6 +143,7 @@ assert.equal(
|
||||
);
|
||||
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
|
||||
assert.equal(shellViewModel.isSupportedShellIntegrationManifest, isSupportedIniPanelShellIntegrationManifest);
|
||||
assert.equal(shellViewModel.createShellIntegrationReadiness, createIniPanelShellIntegrationReadiness);
|
||||
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());
|
||||
assert.equal(shellViewModel.controlPage.isSupportedBrowserApiManifest, isSupportedIniPanelControlPageApiManifest);
|
||||
assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow);
|
||||
|
||||
Reference in New Issue
Block a user