推进 INI 面板 shell handoff control-page mount workflow helper

This commit is contained in:
2026-06-15 12:23:51 +08:00
parent 298aa5e403
commit c3d9b90de1
9 changed files with 234 additions and 9 deletions

View File

@@ -109,6 +109,7 @@
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
renderIniPanelShellSessionHandoffMountState,
} from "./ui-shell.js";
@@ -198,6 +199,14 @@
documentRef: document,
})
),
mountShellSessionHandoffFromControlPage: (options) => (
mountIniPanelShellSessionHandoffFromControlPage({
handoffPackage: shellViewModel.shellSessionHandoffPackage,
packageRenderState: shellViewModel.shellSessionHandoffPackageRenderState,
documentRef: document,
...(options ?? {}),
})
),
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
getLauncherLinks: () => shellViewModel.launcherLinks,
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,

View File

@@ -147,6 +147,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
"getShellSessionHandoffMountDomReadiness",
"renderShellSessionHandoffMountState",
"mountShellSessionHandoff",
"mountShellSessionHandoffFromControlPage",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -1263,6 +1264,70 @@ export function mountIniPanelShellSessionHandoff({
}
}
export function mountIniPanelShellSessionHandoffFromControlPage({
controlPageApi = null,
sessionLoadState = null,
loadSessionStateMethod = "loadControlPageSessionState",
handoffPackage = createIniPanelShellSessionHandoffPackage(),
packageRenderState = createIniPanelShellSessionHandoffPackageRenderState(),
rowDatasetPrefix = "handoffMount",
contract = createIniPanelShellSessionHandoffMountDomContract({ rowDatasetPrefix }),
documentRef = globalThis.document,
mountNode = documentRef?.querySelector?.(contract.selectors.mount),
statusNode = documentRef?.querySelector?.(contract.selectors.status),
rowsNode = documentRef?.querySelector?.(contract.selectors.rows),
} = {}) {
let observedSessionLoadState = sessionLoadState;
let sessionLoadError = null;
if (!observedSessionLoadState) {
const loadSessionState = controlPageApi?.[loadSessionStateMethod];
if (typeof loadSessionState === "function") {
try {
observedSessionLoadState = loadSessionState.call(controlPageApi);
} catch (error) {
sessionLoadError = error?.message ?? String(error);
observedSessionLoadState = createControlPageSessionLoadState({
phase: "error",
error: sessionLoadError,
});
}
} else {
observedSessionLoadState = createControlPageSessionLoadState({ phase: "waiting-api" });
}
}
const mountState = createIniPanelShellSessionHandoffPackageMountState({
handoffPackage,
packageRenderState,
sessionLoadState: observedSessionLoadState,
});
const mountDisplayViewModel = createIniPanelShellSessionHandoffPackageMountDisplayViewModel(mountState);
const mountRenderState = createIniPanelShellSessionHandoffPackageMountRenderState(mountDisplayViewModel);
const mountWorkflow = mountIniPanelShellSessionHandoff({
renderState: mountRenderState,
contract,
documentRef,
mountNode,
statusNode,
rowsNode,
});
return {
apiName: "ini-panel-shell-session-handoff-control-page-mount-workflow",
workflowVersion: 1,
phase: mountWorkflow.phase,
ready: mountWorkflow.ready,
statusLine: mountWorkflow.statusLine,
loadSessionStateMethod,
sessionLoadState: observedSessionLoadState,
sessionLoadError,
mountState,
mountDisplayViewModel,
mountRenderState,
mountWorkflow,
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
@@ -1381,6 +1446,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
createShellSessionHandoffMountDomReadiness: createIniPanelShellSessionHandoffMountDomReadiness,
renderShellSessionHandoffMountState: renderIniPanelShellSessionHandoffMountState,
mountShellSessionHandoff: mountIniPanelShellSessionHandoff,
mountShellSessionHandoffFromControlPage: mountIniPanelShellSessionHandoffFromControlPage,
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),