推进 INI 面板 shell integration manifest
This commit is contained in:
@@ -94,6 +94,8 @@
|
||||
isSupportedLaunchApiManifest: isSupportedIniPanelLaunchApiManifest,
|
||||
getLaunchApiSchema: () => shellViewModel.launchApiSchema,
|
||||
getLaunchApiManifest: () => shellViewModel.launchApiManifest,
|
||||
getShellIntegrationSchema: () => shellViewModel.shellIntegrationSchema,
|
||||
getShellIntegrationManifest: () => shellViewModel.shellIntegrationManifest,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
};
|
||||
|
||||
@@ -123,6 +123,8 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"isSupportedLaunchApiManifest",
|
||||
"getLaunchApiSchema",
|
||||
"getLaunchApiManifest",
|
||||
"getShellIntegrationSchema",
|
||||
"getShellIntegrationManifest",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
],
|
||||
@@ -201,6 +203,68 @@ export function createControlPageBrowserApiManifest() {
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellIntegrationSchema() {
|
||||
return {
|
||||
apiName: "ini-panel-shell-integration",
|
||||
manifestVersion: 1,
|
||||
fields: [
|
||||
"apiName",
|
||||
"manifestVersion",
|
||||
"pages",
|
||||
"launcherLinks",
|
||||
"launchApiSchema",
|
||||
"launchApiManifest",
|
||||
"controlPageApiSchema",
|
||||
"controlPageApiManifest",
|
||||
"compatibility",
|
||||
"persistenceCapabilities",
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function isSupportedIniPanelShellIntegrationManifest(
|
||||
manifest,
|
||||
schema = createIniPanelShellIntegrationSchema(),
|
||||
) {
|
||||
if (!manifest || typeof manifest !== "object") {
|
||||
return false;
|
||||
}
|
||||
if (manifest.apiName !== schema.apiName || manifest.manifestVersion !== schema.manifestVersion) {
|
||||
return false;
|
||||
}
|
||||
return schema.fields.every((fieldName) => Object.hasOwn(manifest, fieldName));
|
||||
}
|
||||
|
||||
export function createIniPanelShellIntegrationManifest(entries = getVisibleIniPanelEntries()) {
|
||||
const schema = createIniPanelShellIntegrationSchema();
|
||||
const launchApiSchema = createIniPanelLaunchApiSchema();
|
||||
const launchApiManifest = createIniPanelLaunchApiManifest(entries);
|
||||
const controlPageApiSchema = createControlPageBrowserApiSchema();
|
||||
const controlPageApiManifest = createControlPageBrowserApiManifest();
|
||||
return {
|
||||
apiName: schema.apiName,
|
||||
manifestVersion: schema.manifestVersion,
|
||||
pages: entries.map(({ id, href, title }) => ({
|
||||
id,
|
||||
href,
|
||||
title,
|
||||
})),
|
||||
launcherLinks: createIniPanelLauncherLinkViewModel(entries),
|
||||
launchApiSchema,
|
||||
launchApiManifest,
|
||||
controlPageApiSchema,
|
||||
controlPageApiManifest,
|
||||
compatibility: {
|
||||
launchApiManifest: isSupportedIniPanelLaunchApiManifest(launchApiManifest, launchApiSchema),
|
||||
controlPageApiManifest: isSupportedIniPanelControlPageApiManifest(
|
||||
controlPageApiManifest,
|
||||
controlPageApiSchema,
|
||||
),
|
||||
},
|
||||
persistenceCapabilities: launchApiManifest.persistenceCapabilities,
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
return {
|
||||
pages: entries.map(({ id, href, title }) => ({
|
||||
@@ -209,8 +273,11 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
title,
|
||||
})),
|
||||
launcherLinks: createIniPanelLauncherLinkViewModel(entries),
|
||||
shellIntegrationSchema: createIniPanelShellIntegrationSchema(),
|
||||
shellIntegrationManifest: createIniPanelShellIntegrationManifest(entries),
|
||||
launchApiSchema: createIniPanelLaunchApiSchema(),
|
||||
launchApiManifest: createIniPanelLaunchApiManifest(entries),
|
||||
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
browserApiManifest: createControlPageBrowserApiManifest(),
|
||||
|
||||
Reference in New Issue
Block a user