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