推进 INI 面板 shell handoff readonly status workflow helper
This commit is contained in:
@@ -148,6 +148,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"renderShellSessionHandoffMountState",
|
||||
"mountShellSessionHandoff",
|
||||
"mountShellSessionHandoffFromControlPage",
|
||||
"readShellSessionHandoffStatusFromControlPage",
|
||||
"isSupportedShellSessionHandoffPackage",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -1328,6 +1329,53 @@ export function mountIniPanelShellSessionHandoffFromControlPage({
|
||||
};
|
||||
}
|
||||
|
||||
export function readIniPanelShellSessionHandoffStatusFromControlPage({
|
||||
controlPageApi = null,
|
||||
readonlyStatus = null,
|
||||
readStatusMethod = "readControlPageStatus",
|
||||
handoffSummary = createIniPanelShellSessionHandoffSummary(),
|
||||
expectedStatusFields = handoffSummary?.readonlyStatusFields ?? [],
|
||||
} = {}) {
|
||||
let observedStatus = readonlyStatus;
|
||||
let readError = null;
|
||||
if (!observedStatus) {
|
||||
const readStatus = controlPageApi?.[readStatusMethod];
|
||||
if (typeof readStatus === "function") {
|
||||
try {
|
||||
observedStatus = readStatus.call(controlPageApi);
|
||||
} catch (error) {
|
||||
readError = error?.message ?? String(error);
|
||||
observedStatus = null;
|
||||
}
|
||||
} else {
|
||||
readError = `Missing ${readStatusMethod}`;
|
||||
observedStatus = null;
|
||||
}
|
||||
}
|
||||
|
||||
const statusObject = observedStatus && typeof observedStatus === "object" ? observedStatus : {};
|
||||
const expectedFields = Array.isArray(expectedStatusFields) ? [...expectedStatusFields] : [];
|
||||
const presentStatusFields = expectedFields.filter((fieldName) => Object.hasOwn(statusObject, fieldName));
|
||||
const missingStatusFields = expectedFields.filter((fieldName) => !Object.hasOwn(statusObject, fieldName));
|
||||
const ready = !readError && missingStatusFields.length === 0;
|
||||
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-readonly-status-result",
|
||||
resultVersion: 1,
|
||||
phase: ready ? "ready" : "blocked",
|
||||
ready,
|
||||
statusLine: ready
|
||||
? "Ready: readonly status fields available"
|
||||
: `Blocked: ${readError ?? missingStatusFields.join(", ")}`,
|
||||
readStatusMethod,
|
||||
expectedStatusFields: expectedFields,
|
||||
presentStatusFields,
|
||||
missingStatusFields,
|
||||
readonlyStatus: observedStatus,
|
||||
readError,
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
|
||||
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
|
||||
@@ -1447,6 +1495,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
renderShellSessionHandoffMountState: renderIniPanelShellSessionHandoffMountState,
|
||||
mountShellSessionHandoff: mountIniPanelShellSessionHandoff,
|
||||
mountShellSessionHandoffFromControlPage: mountIniPanelShellSessionHandoffFromControlPage,
|
||||
readShellSessionHandoffStatusFromControlPage: readIniPanelShellSessionHandoffStatusFromControlPage,
|
||||
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
|
||||
Reference in New Issue
Block a user