推进 INI 面板 shell handoff readonly status workflow helper
This commit is contained in:
@@ -110,6 +110,7 @@
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
mountIniPanelShellSessionHandoffFromControlPage,
|
||||
readIniPanelShellSessionHandoffStatusFromControlPage,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
} from "./ui-shell.js";
|
||||
|
||||
@@ -207,6 +208,12 @@
|
||||
...(options ?? {}),
|
||||
})
|
||||
),
|
||||
readShellSessionHandoffStatusFromControlPage: (options) => (
|
||||
readIniPanelShellSessionHandoffStatusFromControlPage({
|
||||
handoffSummary: shellViewModel.shellSessionHandoffSummary,
|
||||
...(options ?? {}),
|
||||
})
|
||||
),
|
||||
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
|
||||
@@ -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