推进 INI 面板 shell integration readiness helper
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user