推进 INI 面板 launch API schema 暴露
This commit is contained in:
@@ -88,8 +88,10 @@ Use `createIniPanelLaunchApiManifest()` or
|
||||
single read-only description of launch methods, visible entries, target pages,
|
||||
the control-page browser API methods, and OPFS/session persistence capabilities
|
||||
for machine files, session snapshots, and read-only status.
|
||||
Use `createIniPanelLaunchApiSchema()` or `manifestVersion` when an outer shell
|
||||
needs to check launch manifest compatibility before consuming these fields.
|
||||
Use `createIniPanelLaunchApiSchema()`,
|
||||
`linuxCncIniPanelLaunchApi.getLaunchApiSchema()`, or `manifestVersion` when an
|
||||
outer shell needs to check launch manifest compatibility before consuming these
|
||||
fields.
|
||||
|
||||
The control-page refresh workflow lives in
|
||||
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
}
|
||||
|
||||
window.linuxCncIniPanelLaunchApi = {
|
||||
getLaunchApiSchema: () => shellViewModel.launchApiSchema,
|
||||
getLaunchApiManifest: () => shellViewModel.launchApiManifest,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
|
||||
@@ -83,6 +83,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
apiName: schema.apiName,
|
||||
manifestVersion: schema.manifestVersion,
|
||||
methods: [
|
||||
"getLaunchApiSchema",
|
||||
"getLaunchApiManifest",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -155,6 +156,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
title,
|
||||
})),
|
||||
launcherLinks: createIniPanelLauncherLinkViewModel(entries),
|
||||
launchApiSchema: createIniPanelLaunchApiSchema(),
|
||||
launchApiManifest: createIniPanelLaunchApiManifest(entries),
|
||||
controlPage: {
|
||||
browserApiMethods: createControlPageBrowserApiMethods(),
|
||||
|
||||
@@ -65,9 +65,25 @@
|
||||
|
||||
const launchDoc = await loadLaunchFrame();
|
||||
const launchApi = launchDoc.defaultView.linuxCncIniPanelLaunchApi;
|
||||
if (!launchApi?.getLaunchApiManifest || !launchApi?.getLauncherLinks || !launchApi?.getControlPageApiMethods) {
|
||||
if (
|
||||
!launchApi?.getLaunchApiSchema ||
|
||||
!launchApi?.getLaunchApiManifest ||
|
||||
!launchApi?.getLauncherLinks ||
|
||||
!launchApi?.getControlPageApiMethods
|
||||
) {
|
||||
throw new Error("launch API namespace did not expose shell helpers");
|
||||
}
|
||||
const launchApiSchema = launchApi.getLaunchApiSchema();
|
||||
assertEqual(
|
||||
launchApiSchema.manifestVersion,
|
||||
1,
|
||||
"launch API schema manifest version",
|
||||
);
|
||||
assertEqual(
|
||||
launchApiSchema.fields.includes("persistenceCapabilities"),
|
||||
true,
|
||||
"launch API schema persistence field",
|
||||
);
|
||||
const launchApiManifest = launchApi.getLaunchApiManifest();
|
||||
assertEqual(
|
||||
launchApiManifest.apiName,
|
||||
@@ -81,7 +97,7 @@
|
||||
);
|
||||
assertEqual(
|
||||
launchApiManifest.methods.join(","),
|
||||
"getLaunchApiManifest,getLauncherLinks,getControlPageApiMethods",
|
||||
"getLaunchApiSchema,getLaunchApiManifest,getLauncherLinks,getControlPageApiMethods",
|
||||
"launch API manifest methods",
|
||||
);
|
||||
assertEqual(
|
||||
|
||||
@@ -100,6 +100,7 @@ assert.deepEqual(
|
||||
);
|
||||
assert.deepEqual(createIniPanelShellViewModel().pages, getVisibleIniPanelEntries());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.equal(createIniPanelShellViewModel().launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion);
|
||||
assert.deepEqual(
|
||||
@@ -138,6 +139,7 @@ assert.match(shellText, /\bexport function createIniPanelLaunchApiSchema\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiSchema\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiManifest\b/);
|
||||
assert.match(launchText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageContract\b/);
|
||||
@@ -148,6 +150,7 @@ assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageContract\
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.readControlPageStatus\b/);
|
||||
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
|
||||
assert.match(docText, /\bcreateIniPanelLaunchApiSchema\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiSchema\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiManifest\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
|
||||
assert.match(docText, /\bOPFS\/session persistence capabilities\b/);
|
||||
|
||||
@@ -38,6 +38,7 @@ assert.deepEqual(manifest, {
|
||||
apiName: "ini-panel-launch",
|
||||
manifestVersion: 1,
|
||||
methods: [
|
||||
"getLaunchApiSchema",
|
||||
"getLaunchApiManifest",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -85,6 +86,7 @@ assert.deepEqual(manifest, {
|
||||
});
|
||||
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, manifest);
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, schema);
|
||||
assert.equal(createIniPanelShellViewModel().launchApiManifest.manifestVersion, schema.manifestVersion);
|
||||
assert.deepEqual(getVisibleIniPanelEntries(), INI_PANEL_ENTRIES);
|
||||
|
||||
@@ -120,6 +122,7 @@ assert.deepEqual(customManifest.targetPages, [
|
||||
|
||||
assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelLaunchApiSchema\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiSchema\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiManifest\b/);
|
||||
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ assert.deepEqual(shellViewModel.pages, [
|
||||
},
|
||||
]);
|
||||
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(shellViewModel.launchApiSchema, createIniPanelLaunchApiSchema());
|
||||
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.equal(shellViewModel.launchApiManifest.manifestVersion, createIniPanelLaunchApiSchema().manifestVersion);
|
||||
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
|
||||
|
||||
Reference in New Issue
Block a user